[PATCH AUTOSEL for 4.9 092/293] Btrfs: skip commit transaction if we don't have enough pinned bytes
From: Liu Bo[ Upstream commit 28785f70ef882e4798cd5706066a55dbf7adf80e ] 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 Signed-off-by: Sasha Levin --- fs/btrfs/extent-tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index a29730c44850..f9d87903ef48 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -4818,7 +4818,7 @@ static int may_commit_transaction(struct btrfs_root *root, spin_lock(_rsv->lock); if (percpu_counter_compare(_info->total_bytes_pinned, - bytes - delayed_rsv->size) >= 0) { + bytes - delayed_rsv->size) < 0) { spin_unlock(_rsv->lock); return -ENOSPC; } -- 2.15.1
[PATCH AUTOSEL for 4.9 092/293] Btrfs: skip commit transaction if we don't have enough pinned bytes
From: Liu Bo [ Upstream commit 28785f70ef882e4798cd5706066a55dbf7adf80e ] 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 Signed-off-by: Sasha Levin --- fs/btrfs/extent-tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index a29730c44850..f9d87903ef48 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -4818,7 +4818,7 @@ static int may_commit_transaction(struct btrfs_root *root, spin_lock(_rsv->lock); if (percpu_counter_compare(_info->total_bytes_pinned, - bytes - delayed_rsv->size) >= 0) { + bytes - delayed_rsv->size) < 0) { spin_unlock(_rsv->lock); return -ENOSPC; } -- 2.15.1