diff mbox series

[1/6] btrfs: reduce critical section at btrfs_wait_ordered_roots()

Message ID efe86c39d01caabe6ebb6f64a5161dd8e48473af.1717495660.git.fdmanana@suse.com (mailing list archive)
State New, archived
Headers show
Series btrfs: some tweaks and cleanups around ordered extents | expand

Commit Message

Filipe Manana June 4, 2024, 11:08 a.m. UTC
From: Filipe Manana <fdmanana@suse.com>

At btrfs_wait_ordered_roots(), there's no point in decrementing the
counter after locking fs_info->ordered_root_lock as the counter is local.
So change this to decrement the counter before taking the lock.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
 fs/btrfs/ordered-data.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c
index 65d0464cd646..15428a8d4886 100644
--- a/fs/btrfs/ordered-data.c
+++ b/fs/btrfs/ordered-data.c
@@ -829,10 +829,10 @@  void btrfs_wait_ordered_roots(struct btrfs_fs_info *fs_info, u64 nr,
 		done = btrfs_wait_ordered_extents(root, nr, bg);
 		btrfs_put_root(root);
 
-		spin_lock(&fs_info->ordered_root_lock);
-		if (nr != U64_MAX) {
+		if (nr != U64_MAX)
 			nr -= done;
-		}
+
+		spin_lock(&fs_info->ordered_root_lock);
 	}
 	list_splice_tail(&splice, &fs_info->ordered_roots);
 	spin_unlock(&fs_info->ordered_root_lock);