diff options
author | Liu Bo <bo.li.liu@oracle.com> | 2017-05-19 11:39:15 -0600 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2017-06-19 18:26:00 +0200 |
commit | 28785f70ef882e4798cd5706066a55dbf7adf80e (patch) | |
tree | eb5eb82b9956fe7810520054a508c353d67e0b77 /fs/btrfs/extent-tree.c | |
parent | 4e2814ef04080fae123edf8fcef555f5a424e7ba (diff) | |
download | lwn-28785f70ef882e4798cd5706066a55dbf7adf80e.tar.gz lwn-28785f70ef882e4798cd5706066a55dbf7adf80e.zip |
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 <nborisov@suse.com>
Reported-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/extent-tree.c')
-rw-r--r-- | fs/btrfs/extent-tree.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 87eab8fdac73..da8e49e04eb0 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; } |