From: Filipe Manana Date: Mon, 3 Jun 2024 12:25:00 +0000 (+0100) Subject: btrfs: reduce critical section at btrfs_wait_ordered_roots() X-Git-Tag: v6.11-rc1~157^2~84 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=03103ecf5ec95743615113e5d2d8feb8d1a42859;p=thirdparty%2Flinux.git btrfs: reduce critical section at btrfs_wait_ordered_roots() 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. Reviewed-by: Josef Bacik Reviewed-by: Qu Wenruo Reviewed-by: Johannes Thumshirn Signed-off-by: Filipe Manana Reviewed-by: David Sterba Signed-off-by: David Sterba --- diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c index 65d0464cd646f..15428a8d48861 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);