Merge tag 'for-5.19-rc3-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave...
authorLinus Torvalds <torvalds@linux-foundation.org>
Tue, 21 Jun 2022 17:06:04 +0000 (12:06 -0500)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 21 Jun 2022 17:06:04 +0000 (12:06 -0500)
Pull btrfs fixes from David Sterba:

 - print more error messages for invalid mount option values

 - prevent remount with v1 space cache for subpage filesystem

 - fix hang during unmount when block group reclaim task is running

* tag 'for-5.19-rc3-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux:
  btrfs: add error messages to all unrecognized mount options
  btrfs: prevent remounting to v1 space cache for subpage mount
  btrfs: fix hang during unmount when block group reclaim task is running

1  2 
fs/btrfs/disk-io.c

diff --combined fs/btrfs/disk-io.c
@@@ -996,12 -996,12 +996,12 @@@ static int btree_writepages(struct addr
        return btree_write_cache_pages(mapping, wbc);
  }
  
 -static int btree_releasepage(struct page *page, gfp_t gfp_flags)
 +static bool btree_release_folio(struct folio *folio, gfp_t gfp_flags)
  {
 -      if (PageWriteback(page) || PageDirty(page))
 -              return 0;
 +      if (folio_test_writeback(folio) || folio_test_dirty(folio))
 +              return false;
  
 -      return try_release_extent_buffer(page);
 +      return try_release_extent_buffer(&folio->page);
  }
  
  static void btree_invalidate_folio(struct folio *folio, size_t offset,
        struct extent_io_tree *tree;
        tree = &BTRFS_I(folio->mapping->host)->io_tree;
        extent_invalidate_folio(tree, folio, offset);
 -      btree_releasepage(&folio->page, GFP_NOFS);
 +      btree_release_folio(folio, GFP_NOFS);
        if (folio_get_private(folio)) {
                btrfs_warn(BTRFS_I(folio->mapping->host)->root->fs_info,
                           "folio private not zero on folio %llu",
@@@ -1071,7 -1071,7 +1071,7 @@@ static bool btree_dirty_folio(struct ad
  
  static const struct address_space_operations btree_aops = {
        .writepages     = btree_writepages,
 -      .releasepage    = btree_releasepage,
 +      .release_folio  = btree_release_folio,
        .invalidate_folio = btree_invalidate_folio,
  #ifdef CONFIG_MIGRATION
        .migratepage    = btree_migratepage,
@@@ -4232,7 -4232,6 +4232,7 @@@ static int wait_dev_supers(struct btrfs
   */
  static void btrfs_end_empty_barrier(struct bio *bio)
  {
 +      bio_uninit(bio);
        complete(bio->bi_private);
  }
  
   */
  static void write_dev_flush(struct btrfs_device *device)
  {
 -      struct bio *bio = device->flush_bio;
 +      struct bio *bio = &device->flush_bio;
  
  #ifndef CONFIG_BTRFS_FS_CHECK_INTEGRITY
        /*
         * of simplicity, since this is a debug tool and not meant for use in
         * non-debug builds.
         */
 -      struct request_queue *q = bdev_get_queue(device->bdev);
 -      if (!test_bit(QUEUE_FLAG_WC, &q->queue_flags))
 +      if (!bdev_write_cache(device->bdev))
                return;
  #endif
  
 -      bio_reset(bio, device->bdev, REQ_OP_WRITE | REQ_SYNC | REQ_PREFLUSH);
 +      bio_init(bio, device->bdev, NULL, 0,
 +               REQ_OP_WRITE | REQ_SYNC | REQ_PREFLUSH);
        bio->bi_end_io = btrfs_end_empty_barrier;
        init_completion(&device->flush_wait);
        bio->bi_private = &device->flush_wait;
   */
  static blk_status_t wait_dev_flush(struct btrfs_device *device)
  {
 -      struct bio *bio = device->flush_bio;
 +      struct bio *bio = &device->flush_bio;
  
        if (!test_bit(BTRFS_DEV_STATE_FLUSH_SENT, &device->dev_state))
                return BLK_STS_OK;
@@@ -4632,6 -4631,17 +4632,17 @@@ void __cold close_ctree(struct btrfs_fs
        int ret;
  
        set_bit(BTRFS_FS_CLOSING_START, &fs_info->flags);
+       /*
+        * We may have the reclaim task running and relocating a data block group,
+        * in which case it may create delayed iputs. So stop it before we park
+        * the cleaner kthread otherwise we can get new delayed iputs after
+        * parking the cleaner, and that can make the async reclaim task to hang
+        * if it's waiting for delayed iputs to complete, since the cleaner is
+        * parked and can not run delayed iputs - this will make us hang when
+        * trying to stop the async reclaim task.
+        */
+       cancel_work_sync(&fs_info->reclaim_bgs_work);
        /*
         * We don't want the cleaner to start new transactions, add more delayed
         * iputs, etc. while we're closing. We can't use kthread_stop() yet
        cancel_work_sync(&fs_info->async_data_reclaim_work);
        cancel_work_sync(&fs_info->preempt_reclaim_work);
  
-       cancel_work_sync(&fs_info->reclaim_bgs_work);
        /* Cancel or finish ongoing discard work */
        btrfs_discard_cleanup(fs_info);