From: Liu Bo Date: Fri, 19 May 2017 17:39:15 +0000 (-0600) Subject: Btrfs: skip commit transaction if we don't have enough pinned bytes X-Git-Tag: v4.14-rc1~373^2~91 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=28785f70ef882e4798cd5706066a55dbf7adf80e;p=platform%2Fkernel%2Flinux-rpi.git Btrfs: skip commit transaction if we don't have enough pinned bytes We commit transaction in order to reclaim space from pinned bytes because it could process delayed refs, and in may_commit_transaction(), we check first if pinned bytes are enough for the required space, we then check if that plus bytes reserved for delayed insert are enough for the required space. This changes the code to the above logic. Fixes: b150a4f10d87 ("Btrfs: use a percpu to keep track of possibly pinned bytes") Tested-by: Nikolay Borisov Reported-by: Nikolay Borisov Reviewed-by: Nikolay Borisov Signed-off-by: Liu Bo Signed-off-by: David Sterba --- diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 87eab8f..da8e49e 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -4854,7 +4854,7 @@ static int may_commit_transaction(struct btrfs_fs_info *fs_info, spin_lock(&delayed_rsv->lock); if (percpu_counter_compare(&space_info->total_bytes_pinned, - bytes - delayed_rsv->size) >= 0) { + bytes - delayed_rsv->size) < 0) { spin_unlock(&delayed_rsv->lock); return -ENOSPC; }