Commit 9f246926 authored by Josef Bacik's avatar Josef Bacik Committed by David Sterba

btrfs: don't pass system_chunk into can_overcommit

We have the space_info, we can just check its flags to see if it's the
system chunk space info.
Reviewed-by: default avatarNikolay Borisov <nborisov@suse.com>
Reviewed-by: default avatarQu Wenruo <wqu@suse.com>
Reviewed-by: default avatarJohannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: default avatarJosef Bacik <josef@toxicpanda.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 511a32b5
...@@ -161,8 +161,7 @@ static inline u64 calc_global_rsv_need_space(struct btrfs_block_rsv *global) ...@@ -161,8 +161,7 @@ static inline u64 calc_global_rsv_need_space(struct btrfs_block_rsv *global)
static int can_overcommit(struct btrfs_fs_info *fs_info, static int can_overcommit(struct btrfs_fs_info *fs_info,
struct btrfs_space_info *space_info, u64 bytes, struct btrfs_space_info *space_info, u64 bytes,
enum btrfs_reserve_flush_enum flush, enum btrfs_reserve_flush_enum flush)
bool system_chunk)
{ {
u64 profile; u64 profile;
u64 avail; u64 avail;
...@@ -173,7 +172,7 @@ static int can_overcommit(struct btrfs_fs_info *fs_info, ...@@ -173,7 +172,7 @@ static int can_overcommit(struct btrfs_fs_info *fs_info,
if (space_info->flags & BTRFS_BLOCK_GROUP_DATA) if (space_info->flags & BTRFS_BLOCK_GROUP_DATA)
return 0; return 0;
if (system_chunk) if (space_info->flags & BTRFS_BLOCK_GROUP_SYSTEM)
profile = btrfs_system_alloc_profile(fs_info); profile = btrfs_system_alloc_profile(fs_info);
else else
profile = btrfs_metadata_alloc_profile(fs_info); profile = btrfs_metadata_alloc_profile(fs_info);
...@@ -227,8 +226,7 @@ void btrfs_try_granting_tickets(struct btrfs_fs_info *fs_info, ...@@ -227,8 +226,7 @@ void btrfs_try_granting_tickets(struct btrfs_fs_info *fs_info,
/* Check and see if our ticket can be satisified now. */ /* Check and see if our ticket can be satisified now. */
if ((used + ticket->bytes <= space_info->total_bytes) || if ((used + ticket->bytes <= space_info->total_bytes) ||
can_overcommit(fs_info, space_info, ticket->bytes, flush, can_overcommit(fs_info, space_info, ticket->bytes, flush)) {
false)) {
btrfs_space_info_update_bytes_may_use(fs_info, btrfs_space_info_update_bytes_may_use(fs_info,
space_info, space_info,
ticket->bytes); ticket->bytes);
...@@ -626,8 +624,7 @@ static void flush_space(struct btrfs_fs_info *fs_info, ...@@ -626,8 +624,7 @@ static void flush_space(struct btrfs_fs_info *fs_info,
static inline u64 static inline u64
btrfs_calc_reclaim_metadata_size(struct btrfs_fs_info *fs_info, btrfs_calc_reclaim_metadata_size(struct btrfs_fs_info *fs_info,
struct btrfs_space_info *space_info, struct btrfs_space_info *space_info)
bool system_chunk)
{ {
struct reserve_ticket *ticket; struct reserve_ticket *ticket;
u64 used; u64 used;
...@@ -643,13 +640,12 @@ btrfs_calc_reclaim_metadata_size(struct btrfs_fs_info *fs_info, ...@@ -643,13 +640,12 @@ btrfs_calc_reclaim_metadata_size(struct btrfs_fs_info *fs_info,
to_reclaim = min_t(u64, num_online_cpus() * SZ_1M, SZ_16M); to_reclaim = min_t(u64, num_online_cpus() * SZ_1M, SZ_16M);
if (can_overcommit(fs_info, space_info, to_reclaim, if (can_overcommit(fs_info, space_info, to_reclaim,
BTRFS_RESERVE_FLUSH_ALL, system_chunk)) BTRFS_RESERVE_FLUSH_ALL))
return 0; return 0;
used = btrfs_space_info_used(space_info, true); used = btrfs_space_info_used(space_info, true);
if (can_overcommit(fs_info, space_info, SZ_1M, if (can_overcommit(fs_info, space_info, SZ_1M, BTRFS_RESERVE_FLUSH_ALL))
BTRFS_RESERVE_FLUSH_ALL, system_chunk))
expected = div_factor_fine(space_info->total_bytes, 95); expected = div_factor_fine(space_info->total_bytes, 95);
else else
expected = div_factor_fine(space_info->total_bytes, 90); expected = div_factor_fine(space_info->total_bytes, 90);
...@@ -665,7 +661,7 @@ btrfs_calc_reclaim_metadata_size(struct btrfs_fs_info *fs_info, ...@@ -665,7 +661,7 @@ btrfs_calc_reclaim_metadata_size(struct btrfs_fs_info *fs_info,
static inline int need_do_async_reclaim(struct btrfs_fs_info *fs_info, static inline int need_do_async_reclaim(struct btrfs_fs_info *fs_info,
struct btrfs_space_info *space_info, struct btrfs_space_info *space_info,
u64 used, bool system_chunk) u64 used)
{ {
u64 thresh = div_factor_fine(space_info->total_bytes, 98); u64 thresh = div_factor_fine(space_info->total_bytes, 98);
...@@ -673,8 +669,7 @@ static inline int need_do_async_reclaim(struct btrfs_fs_info *fs_info, ...@@ -673,8 +669,7 @@ static inline int need_do_async_reclaim(struct btrfs_fs_info *fs_info,
if ((space_info->bytes_used + space_info->bytes_reserved) >= thresh) if ((space_info->bytes_used + space_info->bytes_reserved) >= thresh)
return 0; return 0;
if (!btrfs_calc_reclaim_metadata_size(fs_info, space_info, if (!btrfs_calc_reclaim_metadata_size(fs_info, space_info))
system_chunk))
return 0; return 0;
return (used >= thresh && !btrfs_fs_closing(fs_info) && return (used >= thresh && !btrfs_fs_closing(fs_info) &&
...@@ -765,8 +760,7 @@ static void btrfs_async_reclaim_metadata_space(struct work_struct *work) ...@@ -765,8 +760,7 @@ static void btrfs_async_reclaim_metadata_space(struct work_struct *work)
space_info = btrfs_find_space_info(fs_info, BTRFS_BLOCK_GROUP_METADATA); space_info = btrfs_find_space_info(fs_info, BTRFS_BLOCK_GROUP_METADATA);
spin_lock(&space_info->lock); spin_lock(&space_info->lock);
to_reclaim = btrfs_calc_reclaim_metadata_size(fs_info, space_info, to_reclaim = btrfs_calc_reclaim_metadata_size(fs_info, space_info);
false);
if (!to_reclaim) { if (!to_reclaim) {
space_info->flush = 0; space_info->flush = 0;
spin_unlock(&space_info->lock); spin_unlock(&space_info->lock);
...@@ -785,8 +779,7 @@ static void btrfs_async_reclaim_metadata_space(struct work_struct *work) ...@@ -785,8 +779,7 @@ static void btrfs_async_reclaim_metadata_space(struct work_struct *work)
return; return;
} }
to_reclaim = btrfs_calc_reclaim_metadata_size(fs_info, to_reclaim = btrfs_calc_reclaim_metadata_size(fs_info,
space_info, space_info);
false);
if (last_tickets_id == space_info->tickets_id) { if (last_tickets_id == space_info->tickets_id) {
flush_state++; flush_state++;
} else { } else {
...@@ -858,8 +851,7 @@ static void priority_reclaim_metadata_space(struct btrfs_fs_info *fs_info, ...@@ -858,8 +851,7 @@ static void priority_reclaim_metadata_space(struct btrfs_fs_info *fs_info,
int flush_state; int flush_state;
spin_lock(&space_info->lock); spin_lock(&space_info->lock);
to_reclaim = btrfs_calc_reclaim_metadata_size(fs_info, space_info, to_reclaim = btrfs_calc_reclaim_metadata_size(fs_info, space_info);
false);
if (!to_reclaim) { if (!to_reclaim) {
spin_unlock(&space_info->lock); spin_unlock(&space_info->lock);
return; return;
...@@ -990,8 +982,7 @@ static int handle_reserve_ticket(struct btrfs_fs_info *fs_info, ...@@ -990,8 +982,7 @@ static int handle_reserve_ticket(struct btrfs_fs_info *fs_info,
static int __reserve_metadata_bytes(struct btrfs_fs_info *fs_info, static int __reserve_metadata_bytes(struct btrfs_fs_info *fs_info,
struct btrfs_space_info *space_info, struct btrfs_space_info *space_info,
u64 orig_bytes, u64 orig_bytes,
enum btrfs_reserve_flush_enum flush, enum btrfs_reserve_flush_enum flush)
bool system_chunk)
{ {
struct reserve_ticket ticket; struct reserve_ticket ticket;
u64 used; u64 used;
...@@ -1013,8 +1004,7 @@ static int __reserve_metadata_bytes(struct btrfs_fs_info *fs_info, ...@@ -1013,8 +1004,7 @@ static int __reserve_metadata_bytes(struct btrfs_fs_info *fs_info,
*/ */
if (!pending_tickets && if (!pending_tickets &&
((used + orig_bytes <= space_info->total_bytes) || ((used + orig_bytes <= space_info->total_bytes) ||
can_overcommit(fs_info, space_info, orig_bytes, flush, can_overcommit(fs_info, space_info, orig_bytes, flush))) {
system_chunk))) {
btrfs_space_info_update_bytes_may_use(fs_info, space_info, btrfs_space_info_update_bytes_may_use(fs_info, space_info,
orig_bytes); orig_bytes);
ret = 0; ret = 0;
...@@ -1054,8 +1044,7 @@ static int __reserve_metadata_bytes(struct btrfs_fs_info *fs_info, ...@@ -1054,8 +1044,7 @@ static int __reserve_metadata_bytes(struct btrfs_fs_info *fs_info,
* the async reclaim as we will panic. * the async reclaim as we will panic.
*/ */
if (!test_bit(BTRFS_FS_LOG_RECOVERING, &fs_info->flags) && if (!test_bit(BTRFS_FS_LOG_RECOVERING, &fs_info->flags) &&
need_do_async_reclaim(fs_info, space_info, need_do_async_reclaim(fs_info, space_info, used) &&
used, system_chunk) &&
!work_busy(&fs_info->async_reclaim_work)) { !work_busy(&fs_info->async_reclaim_work)) {
trace_btrfs_trigger_flush(fs_info, space_info->flags, trace_btrfs_trigger_flush(fs_info, space_info->flags,
orig_bytes, flush, "preempt"); orig_bytes, flush, "preempt");
...@@ -1092,10 +1081,9 @@ int btrfs_reserve_metadata_bytes(struct btrfs_root *root, ...@@ -1092,10 +1081,9 @@ int btrfs_reserve_metadata_bytes(struct btrfs_root *root,
struct btrfs_fs_info *fs_info = root->fs_info; struct btrfs_fs_info *fs_info = root->fs_info;
struct btrfs_block_rsv *global_rsv = &fs_info->global_block_rsv; struct btrfs_block_rsv *global_rsv = &fs_info->global_block_rsv;
int ret; int ret;
bool system_chunk = (root == fs_info->chunk_root);
ret = __reserve_metadata_bytes(fs_info, block_rsv->space_info, ret = __reserve_metadata_bytes(fs_info, block_rsv->space_info,
orig_bytes, flush, system_chunk); orig_bytes, flush);
if (ret == -ENOSPC && if (ret == -ENOSPC &&
unlikely(root->orphan_cleanup_state == ORPHAN_CLEANUP_STARTED)) { unlikely(root->orphan_cleanup_state == ORPHAN_CLEANUP_STARTED)) {
if (block_rsv != global_rsv && if (block_rsv != global_rsv &&
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment