summaryrefslogtreecommitdiff
path: root/fs/btrfs
diff options
context:
space:
mode:
authorJosef Bacik <josef@toxicpanda.com>2019-06-19 20:47:20 +0300
committerDavid Sterba <dsterba@suse.com>2019-07-02 13:30:54 +0300
commitfcec36224fc674953eadfca05c69225e6595641b (patch)
tree1de8986e37b3ace5667397db7628e2e15b8d3164 /fs/btrfs
parentfed14b323db868c3ac0071925763964a6ca58883 (diff)
downloadlinux-fcec36224fc674953eadfca05c69225e6595641b.tar.xz
btrfs: cleanup the target logic in __btrfs_block_rsv_release
This works for all callers already, but if we wanted to use the helper for the global_block_rsv it would end up trying to refill itself. Fix the logic to be able to be used no matter which block rsv is passed in to this helper. Signed-off-by: Josef Bacik <josef@toxicpanda.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r--fs/btrfs/extent-tree.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 486ddc4c436d..a457776c3e41 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -4680,12 +4680,18 @@ u64 __btrfs_block_rsv_release(struct btrfs_fs_info *fs_info,
{
struct btrfs_block_rsv *global_rsv = &fs_info->global_block_rsv;
struct btrfs_block_rsv *delayed_rsv = &fs_info->delayed_refs_rsv;
- struct btrfs_block_rsv *target = delayed_rsv;
+ struct btrfs_block_rsv *target = NULL;
- if (target->full || target == block_rsv)
+ /*
+ * If we are the delayed_rsv then push to the global rsv, otherwise dump
+ * into the delayed rsv if it is not full.
+ */
+ if (block_rsv == delayed_rsv)
target = global_rsv;
+ else if (block_rsv != global_rsv && !delayed_rsv->full)
+ target = delayed_rsv;
- if (block_rsv->space_info != target->space_info)
+ if (target && block_rsv->space_info != target->space_info)
target = NULL;
return block_rsv_release_bytes(fs_info, block_rsv, target, num_bytes,