Commit cf5fa929 authored by Filipe Manana's avatar Filipe Manana Committed by David Sterba

btrfs: simplify btrfs_should_throttle_delayed_refs()

Currently btrfs_should_throttle_delayed_refs() returns 1 or 2 in case the
delayed refs should be throttled, however the only caller (inode eviction
and truncation path) does not care about those two different conditions,
it treats the return value as a boolean. This allows us to remove one of
the conditions in btrfs_should_throttle_delayed_refs() and change its
return value from 'int' to 'bool'. So just do that.
Reviewed-by: default avatarJosef Bacik <josef@toxicpanda.com>
Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 3a49a548
...@@ -53,7 +53,7 @@ bool btrfs_check_space_for_delayed_refs(struct btrfs_fs_info *fs_info) ...@@ -53,7 +53,7 @@ bool btrfs_check_space_for_delayed_refs(struct btrfs_fs_info *fs_info)
return ret; return ret;
} }
int btrfs_should_throttle_delayed_refs(struct btrfs_trans_handle *trans) bool btrfs_should_throttle_delayed_refs(struct btrfs_trans_handle *trans)
{ {
u64 num_entries = u64 num_entries =
atomic_read(&trans->transaction->delayed_refs.num_entries); atomic_read(&trans->transaction->delayed_refs.num_entries);
...@@ -63,10 +63,8 @@ int btrfs_should_throttle_delayed_refs(struct btrfs_trans_handle *trans) ...@@ -63,10 +63,8 @@ int btrfs_should_throttle_delayed_refs(struct btrfs_trans_handle *trans)
smp_mb(); smp_mb();
avg_runtime = trans->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)
return 1;
if (val >= NSEC_PER_SEC / 2) if (val >= NSEC_PER_SEC / 2)
return 2; return true;
return btrfs_check_space_for_delayed_refs(trans->fs_info); return btrfs_check_space_for_delayed_refs(trans->fs_info);
} }
......
...@@ -385,7 +385,7 @@ int btrfs_delayed_refs_rsv_refill(struct btrfs_fs_info *fs_info, ...@@ -385,7 +385,7 @@ 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, void btrfs_migrate_to_delayed_refs_rsv(struct btrfs_fs_info *fs_info,
struct btrfs_block_rsv *src, struct btrfs_block_rsv *src,
u64 num_bytes); u64 num_bytes);
int btrfs_should_throttle_delayed_refs(struct btrfs_trans_handle *trans); bool btrfs_should_throttle_delayed_refs(struct btrfs_trans_handle *trans);
bool btrfs_check_space_for_delayed_refs(struct btrfs_fs_info *fs_info); bool btrfs_check_space_for_delayed_refs(struct btrfs_fs_info *fs_info);
/* /*
......
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