@@ -50,16 +50,16 @@ bool btrfs_check_space_for_delayed_refs(struct btrfs_fs_info *fs_info)
return ret;
}
-bool btrfs_should_throttle_delayed_refs(struct btrfs_trans_handle *trans,
+bool btrfs_should_throttle_delayed_refs(struct btrfs_fs_info *fs_info,
+ struct btrfs_delayed_ref_root *delayed_refs,
bool for_throttle)
{
- u64 num_entries =
- atomic_read(&trans->transaction->delayed_refs.num_entries);
+ u64 num_entries = atomic_read(&delayed_refs->num_entries);
u64 avg_runtime;
u64 val;
smp_mb();
- avg_runtime = trans->fs_info->avg_delayed_ref_runtime;
+ avg_runtime = fs_info->avg_delayed_ref_runtime;
val = num_entries * avg_runtime;
if (val >= NSEC_PER_SEC)
return true;
@@ -371,7 +371,8 @@ int btrfs_delayed_refs_rsv_refill(struct btrfs_fs_info *fs_info,
void btrfs_migrate_to_delayed_refs_rsv(struct btrfs_fs_info *fs_info,
struct btrfs_block_rsv *src,
u64 num_bytes);
-bool btrfs_should_throttle_delayed_refs(struct btrfs_trans_handle *trans,
+bool btrfs_should_throttle_delayed_refs(struct btrfs_fs_info *fs_info,
+ struct btrfs_delayed_ref_root *delayed_refs,
bool for_throttle);
bool btrfs_check_space_for_delayed_refs(struct btrfs_fs_info *fs_info);
@@ -2272,7 +2272,7 @@ static void btrfs_async_run_delayed_refs(struct work_struct *work)
}
/* No longer over our threshold, lets bail. */
- if (!btrfs_should_throttle_delayed_refs(trans, true)) {
+ if (!btrfs_should_throttle_delayed_refs(fs_info, &trans->transaction->delayed_refs, true)) {
btrfs_end_transaction(trans);
break;
}
@@ -4349,8 +4349,9 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
break;
}
if (be_nice) {
- if (btrfs_should_throttle_delayed_refs(trans,
- true) ||
+ if (btrfs_should_throttle_delayed_refs(fs_info,
+ &trans->transaction->delayed_refs,
+ true) ||
btrfs_check_space_for_delayed_refs(fs_info))
should_throttle = true;
}
@@ -865,7 +865,7 @@ int btrfs_should_end_transaction(struct btrfs_trans_handle *trans)
cur_trans->delayed_refs.flushing)
return 1;
- if (btrfs_should_throttle_delayed_refs(trans, true) ||
+ if (btrfs_should_throttle_delayed_refs(fs_info, &cur_trans->delayed_refs, true) ||
btrfs_check_space_for_delayed_refs(fs_info))
return 1;
@@ -907,7 +907,8 @@ static int __btrfs_end_transaction(struct btrfs_trans_handle *trans,
return 0;
}
- if (btrfs_should_throttle_delayed_refs(trans, true))
+ if (btrfs_should_throttle_delayed_refs(info,
+ &cur_trans->delayed_refs, true))
run_async = true;
btrfs_trans_release_metadata(trans);
We want to be able to call this without a trans handle being open, so adjust the arguments to be the fs_info and the delayed_ref_root instead of the trans handle. Signed-off-by: Josef Bacik <josef@toxicpanda.com> --- fs/btrfs/delayed-ref.c | 8 ++++---- fs/btrfs/delayed-ref.h | 3 ++- fs/btrfs/extent-tree.c | 2 +- fs/btrfs/inode.c | 5 +++-- fs/btrfs/transaction.c | 5 +++-- 5 files changed, 13 insertions(+), 10 deletions(-)