btrfs: move QUOTA_ENABLED check to rescan_should_stop from btrfs_qgroup_rescan_worker
authorNikolay Borisov <nborisov@suse.com>
Thu, 13 Jan 2022 15:16:18 +0000 (17:16 +0200)
committerDavid Sterba <dsterba@suse.com>
Mon, 14 Mar 2022 12:13:47 +0000 (13:13 +0100)
Instead of having 2 places that short circuit the qgroup leaf scan have
everything in the qgroup_rescan_leaf function. In addition to that, also
ensure that the inconsistent qgroup flag is set when rescan_should_stop
returns true. This both retains the old behavior when -EINTR was set in
the body of the loop and at the same time also extends this behavior
when scanning is interrupted due to remount or unmount operations.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/qgroup.c

index 30d42ea655ce93f25977074fddf6d043a599b7e0..4a9bde1e2c50f89cfc487810ca5016d1cd2f31c7 100644 (file)
@@ -3268,7 +3268,8 @@ out:
 static bool rescan_should_stop(struct btrfs_fs_info *fs_info)
 {
        return btrfs_fs_closing(fs_info) ||
-               test_bit(BTRFS_FS_STATE_REMOUNTING, &fs_info->fs_state);
+               test_bit(BTRFS_FS_STATE_REMOUNTING, &fs_info->fs_state) ||
+               !test_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags);
 }
 
 static void btrfs_qgroup_rescan_worker(struct btrfs_work *work)
@@ -3298,11 +3299,9 @@ static void btrfs_qgroup_rescan_worker(struct btrfs_work *work)
                        err = PTR_ERR(trans);
                        break;
                }
-               if (!test_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags)) {
-                       err = -EINTR;
-               } else {
-                       err = qgroup_rescan_leaf(trans, path);
-               }
+
+               err = qgroup_rescan_leaf(trans, path);
+
                if (err > 0)
                        btrfs_commit_transaction(trans);
                else
@@ -3316,7 +3315,7 @@ out:
        if (err > 0 &&
            fs_info->qgroup_flags & BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT) {
                fs_info->qgroup_flags &= ~BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT;
-       } else if (err < 0) {
+       } else if (err < 0 || stopped) {
                fs_info->qgroup_flags |= BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT;
        }
        mutex_unlock(&fs_info->qgroup_rescan_lock);