linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] btrfs: Reduce scope of delayed_rsv->lock in may_commit_trans
@ 2017-11-07  9:22 Nikolay Borisov
  2017-11-07 20:18 ` David Sterba
  0 siblings, 1 reply; 4+ messages in thread
From: Nikolay Borisov @ 2017-11-07  9:22 UTC (permalink / raw)
  To: dsterba; +Cc: linux-btrfs, josef, Nikolay Borisov

After commit ('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 <nborisov@suse.com>
---

This is based on David's misc-4.15 branch 

 fs/btrfs/extent-tree.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 673ac4e01dd0..11b7d613140b 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -4952,12 +4952,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);
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-11-07 21:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-07  9:22 [PATCH] btrfs: Reduce scope of delayed_rsv->lock in may_commit_trans Nikolay Borisov
2017-11-07 20:18 ` David Sterba
2017-11-07 20:42   ` Nikolay Borisov
2017-11-07 21:15     ` David Sterba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).