diff mbox series

[2/6] btrfs: reduce critical section at btrfs_wait_ordered_extents()

Message ID f0b57ef2d2bff5ce085483a7ef0f0f34f578240a.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_extents(), there's no point in updating the counters
after locking the root's ordered extent lock, as the counters are local.
So change this to update the counters before taking the lock.

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

Patch

diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c
index 15428a8d4886..1cabcfa85e7c 100644
--- a/fs/btrfs/ordered-data.c
+++ b/fs/btrfs/ordered-data.c
@@ -783,10 +783,10 @@  u64 btrfs_wait_ordered_extents(struct btrfs_root *root, u64 nr,
 		btrfs_queue_work(fs_info->flush_workers, &ordered->flush_work);
 
 		cond_resched();
-		spin_lock(&root->ordered_extent_lock);
 		if (nr != U64_MAX)
 			nr--;
 		count++;
+		spin_lock(&root->ordered_extent_lock);
 	}
 	list_splice_tail(&skipped, &root->ordered_extents);
 	list_splice_tail(&splice, &root->ordered_extents);