From: Nikolay Borisov Date: Tue, 7 Nov 2017 09:22:54 +0000 (+0200) Subject: btrfs: Reduce scope of delayed_rsv->lock in may_commit_trans X-Git-Tag: v4.19~1424^2~159 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=057aac3e628f38df984b419f7458455bf698eb7e;p=platform%2Fkernel%2Flinux-rpi3.git btrfs: Reduce scope of delayed_rsv->lock in may_commit_trans After commit 996478ca9c460886ac1 ("btrfs: change how we decide to commit transactions during flushing") there is no need to hold the delayed_rsv during the percpu_counter_compare call since we get the byte's snapshot earlier. So hold the lock only while reading delayed_rsv. Signed-off-by: Nikolay Borisov Reviewed-by: David Sterba Signed-off-by: David Sterba --- diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 2f43285..41770ee 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -4945,12 +4945,12 @@ static int may_commit_transaction(struct btrfs_fs_info *fs_info, bytes = 0; else bytes -= delayed_rsv->size; + spin_unlock(&delayed_rsv->lock); + if (percpu_counter_compare(&space_info->total_bytes_pinned, bytes) < 0) { - spin_unlock(&delayed_rsv->lock); return -ENOSPC; } - spin_unlock(&delayed_rsv->lock); commit: trans = btrfs_join_transaction(fs_info->extent_root);