From: Filipe Manana Date: Mon, 3 Jun 2024 12:30:35 +0000 (+0100) Subject: btrfs: reduce critical section at btrfs_wait_ordered_extents() X-Git-Tag: io_uring-6.11-20240722~13^2~84 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=ac1f580c10f31063ce9dae840d3499d41e3854ce;p=linux-block.git btrfs: reduce critical section at btrfs_wait_ordered_extents() 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. 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 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);