Commit 7c861627 authored by Lu Fengqi's avatar Lu Fengqi Committed by David Sterba

btrfs: remove fs_info from btrfs_should_throttle_delayed_refs

The avg_delayed_ref_runtime can be referenced from the transaction
handle.
Signed-off-by: default avatarLu Fengqi <lufq.fnst@cn.fujitsu.com>
Reviewed-by: default avatarNikolay Borisov <nborisov@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent af9b8a0e
...@@ -2598,8 +2598,7 @@ static inline u64 btrfs_calc_trunc_metadata_size(struct btrfs_fs_info *fs_info, ...@@ -2598,8 +2598,7 @@ static inline u64 btrfs_calc_trunc_metadata_size(struct btrfs_fs_info *fs_info,
return (u64)fs_info->nodesize * BTRFS_MAX_LEVEL * num_items; return (u64)fs_info->nodesize * BTRFS_MAX_LEVEL * num_items;
} }
int btrfs_should_throttle_delayed_refs(struct btrfs_trans_handle *trans, int btrfs_should_throttle_delayed_refs(struct btrfs_trans_handle *trans);
struct btrfs_fs_info *fs_info);
int btrfs_check_space_for_delayed_refs(struct btrfs_trans_handle *trans); int btrfs_check_space_for_delayed_refs(struct btrfs_trans_handle *trans);
void btrfs_dec_block_group_reservations(struct btrfs_fs_info *fs_info, void btrfs_dec_block_group_reservations(struct btrfs_fs_info *fs_info,
const u64 start); const u64 start);
......
...@@ -2826,8 +2826,7 @@ int btrfs_check_space_for_delayed_refs(struct btrfs_trans_handle *trans) ...@@ -2826,8 +2826,7 @@ int btrfs_check_space_for_delayed_refs(struct btrfs_trans_handle *trans)
return ret; return ret;
} }
int btrfs_should_throttle_delayed_refs(struct btrfs_trans_handle *trans, int btrfs_should_throttle_delayed_refs(struct btrfs_trans_handle *trans)
struct btrfs_fs_info *fs_info)
{ {
u64 num_entries = u64 num_entries =
atomic_read(&trans->transaction->delayed_refs.num_entries); atomic_read(&trans->transaction->delayed_refs.num_entries);
...@@ -2835,7 +2834,7 @@ int btrfs_should_throttle_delayed_refs(struct btrfs_trans_handle *trans, ...@@ -2835,7 +2834,7 @@ int btrfs_should_throttle_delayed_refs(struct btrfs_trans_handle *trans,
u64 val; u64 val;
smp_mb(); smp_mb();
avg_runtime = fs_info->avg_delayed_ref_runtime; avg_runtime = trans->fs_info->avg_delayed_ref_runtime;
val = num_entries * avg_runtime; val = num_entries * avg_runtime;
if (val >= NSEC_PER_SEC) if (val >= NSEC_PER_SEC)
return 1; return 1;
......
...@@ -4713,7 +4713,7 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans, ...@@ -4713,7 +4713,7 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
break; break;
} }
if (btrfs_should_throttle_delayed_refs(trans, fs_info)) if (btrfs_should_throttle_delayed_refs(trans))
btrfs_async_run_delayed_refs(fs_info, btrfs_async_run_delayed_refs(fs_info,
trans->delayed_ref_updates * 2, trans->delayed_ref_updates * 2,
trans->transid, 0); trans->transid, 0);
...@@ -4722,8 +4722,7 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans, ...@@ -4722,8 +4722,7 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
extent_num_bytes)) { extent_num_bytes)) {
should_end = true; should_end = true;
} }
if (btrfs_should_throttle_delayed_refs(trans, if (btrfs_should_throttle_delayed_refs(trans))
fs_info))
should_throttle = true; should_throttle = true;
} }
} }
......
...@@ -835,7 +835,7 @@ static int __btrfs_end_transaction(struct btrfs_trans_handle *trans, ...@@ -835,7 +835,7 @@ static int __btrfs_end_transaction(struct btrfs_trans_handle *trans,
trans->delayed_ref_updates = 0; trans->delayed_ref_updates = 0;
if (!trans->sync) { if (!trans->sync) {
must_run_delayed_refs = must_run_delayed_refs =
btrfs_should_throttle_delayed_refs(trans, info); btrfs_should_throttle_delayed_refs(trans);
cur = max_t(unsigned long, cur, 32); cur = max_t(unsigned long, cur, 32);
/* /*
......
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