diff options
Diffstat (limited to 'fs/btrfs/extent-tree.c')
-rw-r--r-- | fs/btrfs/extent-tree.c | 40 |
1 files changed, 23 insertions, 17 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index e2287c7c10be..53e12977bfd0 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -4838,7 +4838,7 @@ static inline int need_do_async_reclaim(struct btrfs_space_info *space_info, | |||
4838 | u64 thresh = div_factor_fine(space_info->total_bytes, 98); | 4838 | u64 thresh = div_factor_fine(space_info->total_bytes, 98); |
4839 | 4839 | ||
4840 | /* If we're just plain full then async reclaim just slows us down. */ | 4840 | /* If we're just plain full then async reclaim just slows us down. */ |
4841 | if (space_info->bytes_used >= thresh) | 4841 | if ((space_info->bytes_used + space_info->bytes_reserved) >= thresh) |
4842 | return 0; | 4842 | return 0; |
4843 | 4843 | ||
4844 | return (used >= thresh && !btrfs_fs_closing(fs_info) && | 4844 | return (used >= thresh && !btrfs_fs_closing(fs_info) && |
@@ -5373,27 +5373,33 @@ static void update_global_block_rsv(struct btrfs_fs_info *fs_info) | |||
5373 | 5373 | ||
5374 | block_rsv->size = min_t(u64, num_bytes, SZ_512M); | 5374 | block_rsv->size = min_t(u64, num_bytes, SZ_512M); |
5375 | 5375 | ||
5376 | num_bytes = sinfo->bytes_used + sinfo->bytes_pinned + | 5376 | if (block_rsv->reserved < block_rsv->size) { |
5377 | sinfo->bytes_reserved + sinfo->bytes_readonly + | 5377 | num_bytes = sinfo->bytes_used + sinfo->bytes_pinned + |
5378 | sinfo->bytes_may_use; | 5378 | sinfo->bytes_reserved + sinfo->bytes_readonly + |
5379 | 5379 | sinfo->bytes_may_use; | |
5380 | if (sinfo->total_bytes > num_bytes) { | 5380 | if (sinfo->total_bytes > num_bytes) { |
5381 | num_bytes = sinfo->total_bytes - num_bytes; | 5381 | num_bytes = sinfo->total_bytes - num_bytes; |
5382 | block_rsv->reserved += num_bytes; | 5382 | num_bytes = min(num_bytes, |
5383 | sinfo->bytes_may_use += num_bytes; | 5383 | block_rsv->size - block_rsv->reserved); |
5384 | trace_btrfs_space_reservation(fs_info, "space_info", | 5384 | block_rsv->reserved += num_bytes; |
5385 | sinfo->flags, num_bytes, 1); | 5385 | sinfo->bytes_may_use += num_bytes; |
5386 | } | 5386 | trace_btrfs_space_reservation(fs_info, "space_info", |
5387 | 5387 | sinfo->flags, num_bytes, | |
5388 | if (block_rsv->reserved >= block_rsv->size) { | 5388 | 1); |
5389 | } | ||
5390 | } else if (block_rsv->reserved > block_rsv->size) { | ||
5389 | num_bytes = block_rsv->reserved - block_rsv->size; | 5391 | num_bytes = block_rsv->reserved - block_rsv->size; |
5390 | sinfo->bytes_may_use -= num_bytes; | 5392 | sinfo->bytes_may_use -= num_bytes; |
5391 | trace_btrfs_space_reservation(fs_info, "space_info", | 5393 | trace_btrfs_space_reservation(fs_info, "space_info", |
5392 | sinfo->flags, num_bytes, 0); | 5394 | sinfo->flags, num_bytes, 0); |
5393 | block_rsv->reserved = block_rsv->size; | 5395 | block_rsv->reserved = block_rsv->size; |
5394 | block_rsv->full = 1; | ||
5395 | } | 5396 | } |
5396 | 5397 | ||
5398 | if (block_rsv->reserved == block_rsv->size) | ||
5399 | block_rsv->full = 1; | ||
5400 | else | ||
5401 | block_rsv->full = 0; | ||
5402 | |||
5397 | spin_unlock(&block_rsv->lock); | 5403 | spin_unlock(&block_rsv->lock); |
5398 | spin_unlock(&sinfo->lock); | 5404 | spin_unlock(&sinfo->lock); |
5399 | } | 5405 | } |
@@ -5752,7 +5758,7 @@ out_fail: | |||
5752 | 5758 | ||
5753 | /* | 5759 | /* |
5754 | * This is tricky, but first we need to figure out how much we | 5760 | * This is tricky, but first we need to figure out how much we |
5755 | * free'd from any free-ers that occured during this | 5761 | * free'd from any free-ers that occurred during this |
5756 | * reservation, so we reset ->csum_bytes to the csum_bytes | 5762 | * reservation, so we reset ->csum_bytes to the csum_bytes |
5757 | * before we dropped our lock, and then call the free for the | 5763 | * before we dropped our lock, and then call the free for the |
5758 | * number of bytes that were freed while we were trying our | 5764 | * number of bytes that were freed while we were trying our |
@@ -7018,7 +7024,7 @@ btrfs_lock_cluster(struct btrfs_block_group_cache *block_group, | |||
7018 | struct btrfs_free_cluster *cluster, | 7024 | struct btrfs_free_cluster *cluster, |
7019 | int delalloc) | 7025 | int delalloc) |
7020 | { | 7026 | { |
7021 | struct btrfs_block_group_cache *used_bg; | 7027 | struct btrfs_block_group_cache *used_bg = NULL; |
7022 | bool locked = false; | 7028 | bool locked = false; |
7023 | again: | 7029 | again: |
7024 | spin_lock(&cluster->refill_lock); | 7030 | spin_lock(&cluster->refill_lock); |