]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
btrfs: reduce critical section at btrfs_wait_ordered_extents()
authorFilipe Manana <fdmanana@suse.com>
Mon, 3 Jun 2024 12:30:35 +0000 (13:30 +0100)
committerDavid Sterba <dsterba@suse.com>
Thu, 11 Jul 2024 13:33:23 +0000 (15:33 +0200)
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 <josef@toxicpanda.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/ordered-data.c

index 15428a8d48861cced851a086346eb8f8796bfccc..1cabcfa85e7cda358e2f825a418ad6fd843f4a04 100644 (file)
@@ -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);