diff mbox series

btrfs: move QUOTA_ENABLED check to rescan_should_stop from btrfs_qgroup_rescan_worker

Message ID 20220113151618.2149736-1-nborisov@suse.com (mailing list archive)
State New, archived
Headers show
Series btrfs: move QUOTA_ENABLED check to rescan_should_stop from btrfs_qgroup_rescan_worker | expand

Commit Message

Nikolay Borisov Jan. 13, 2022, 3:16 p.m. UTC
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>
---
 fs/btrfs/qgroup.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

--
2.25.1

Comments

David Sterba Jan. 24, 2022, 7:55 p.m. UTC | #1
On Thu, Jan 13, 2022 at 05:16:18PM +0200, Nikolay Borisov wrote:
> 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>

Added to misc-next, thanks.
diff mbox series

Patch

diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
index 83d38d68f8e2..59e19e646f6e 100644
--- a/fs/btrfs/qgroup.c
+++ b/fs/btrfs/qgroup.c
@@ -3253,7 +3253,8 @@  static int qgroup_rescan_leaf(struct btrfs_trans_handle *trans,
 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)
@@ -3283,11 +3284,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
@@ -3301,7 +3300,7 @@  static void btrfs_qgroup_rescan_worker(struct btrfs_work *work)
 	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);