btrfs: remove fs_info from btrfs_should_throttle_delayed_refs
authorLu Fengqi <lufq.fnst@cn.fujitsu.com>
Thu, 11 Oct 2018 05:40:36 +0000 (13:40 +0800)
committerDavid Sterba <dsterba@suse.com>
Mon, 15 Oct 2018 15:23:41 +0000 (17:23 +0200)
The avg_delayed_ref_runtime can be referenced from the transaction
handle.

Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com>
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/ctree.h
fs/btrfs/extent-tree.c
fs/btrfs/inode.c
fs/btrfs/transaction.c

index 4002c9fd924b85e121d096c736385cb48d7ea39e..68ca41dbbef387f93de28ca845c144fc37bbab79 100644 (file)
@@ -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;
 }
 
-int btrfs_should_throttle_delayed_refs(struct btrfs_trans_handle *trans,
-                                      struct btrfs_fs_info *fs_info);
+int btrfs_should_throttle_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,
                                         const u64 start);
index c7de1e720f56a71767e0381dc27cf7fa6ca46394..a4cd0221bc8d3684b26ef68ece99fc984f06a911 100644 (file)
@@ -2826,8 +2826,7 @@ int btrfs_check_space_for_delayed_refs(struct btrfs_trans_handle *trans)
        return ret;
 }
 
-int btrfs_should_throttle_delayed_refs(struct btrfs_trans_handle *trans,
-                                      struct btrfs_fs_info *fs_info)
+int btrfs_should_throttle_delayed_refs(struct btrfs_trans_handle *trans)
 {
        u64 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,
        u64 val;
 
        smp_mb();
-       avg_runtime = fs_info->avg_delayed_ref_runtime;
+       avg_runtime = trans->fs_info->avg_delayed_ref_runtime;
        val = num_entries * avg_runtime;
        if (val >= NSEC_PER_SEC)
                return 1;
index 6a5557e8909df68c58db6a6772bb524689db729c..f22f77172c5ff5299b37aa8e10be770929c61a44 100644 (file)
@@ -4713,7 +4713,7 @@ delete:
                                btrfs_abort_transaction(trans, ret);
                                break;
                        }
-                       if (btrfs_should_throttle_delayed_refs(trans, fs_info))
+                       if (btrfs_should_throttle_delayed_refs(trans))
                                btrfs_async_run_delayed_refs(fs_info,
                                        trans->delayed_ref_updates * 2,
                                        trans->transid, 0);
@@ -4722,8 +4722,7 @@ delete:
                                                         extent_num_bytes)) {
                                        should_end = true;
                                }
-                               if (btrfs_should_throttle_delayed_refs(trans,
-                                                                      fs_info))
+                               if (btrfs_should_throttle_delayed_refs(trans))
                                        should_throttle = true;
                        }
                }
index c5015458c5c8bcbbc1cc1d4c3e5c5b3656efeb49..5686290a50e1186133ed43fe33cd4b86b811544e 100644 (file)
@@ -835,7 +835,7 @@ static int __btrfs_end_transaction(struct btrfs_trans_handle *trans,
        trans->delayed_ref_updates = 0;
        if (!trans->sync) {
                must_run_delayed_refs =
-                       btrfs_should_throttle_delayed_refs(trans, info);
+                       btrfs_should_throttle_delayed_refs(trans);
                cur = max_t(unsigned long, cur, 32);
 
                /*