瀏覽代碼

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 <nborisov@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Nikolay Borisov 7 年之前
父節點
當前提交
057aac3e62
共有 1 個文件被更改,包括 2 次插入2 次删除
  1. 2 2
      fs/btrfs/extent-tree.c

+ 2 - 2
fs/btrfs/extent-tree.c

@@ -4945,12 +4945,12 @@ static int may_commit_transaction(struct btrfs_fs_info *fs_info,
 		bytes = 0;
 		bytes = 0;
 	else
 	else
 		bytes -= delayed_rsv->size;
 		bytes -= delayed_rsv->size;
+	spin_unlock(&delayed_rsv->lock);
+
 	if (percpu_counter_compare(&space_info->total_bytes_pinned,
 	if (percpu_counter_compare(&space_info->total_bytes_pinned,
 				   bytes) < 0) {
 				   bytes) < 0) {
-		spin_unlock(&delayed_rsv->lock);
 		return -ENOSPC;
 		return -ENOSPC;
 	}
 	}
-	spin_unlock(&delayed_rsv->lock);
 
 
 commit:
 commit:
 	trans = btrfs_join_transaction(fs_info->extent_root);
 	trans = btrfs_join_transaction(fs_info->extent_root);