btrfs_clean_one_deleted_snapshot() will grab needed root from fs_info,
thus no need to pass a @root parameter.

Also refactor its sole caller, cleaner_kthread() to use fs_info other
than root.

Signed-off-by: Qu Wenruo <[email protected]>
---
 fs/btrfs/disk-io.c     | 7 +++----
 fs/btrfs/transaction.c | 4 ++--
 fs/btrfs/transaction.h | 2 +-
 3 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index deb74a8c191a..9c11ac5edef5 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -1689,8 +1689,7 @@ static void end_workqueue_fn(struct btrfs_work *work)
 
 static int cleaner_kthread(void *arg)
 {
-       struct btrfs_root *root = arg;
-       struct btrfs_fs_info *fs_info = root->fs_info;
+       struct btrfs_fs_info *fs_info = arg;
        int again;
 
        while (1) {
@@ -1723,7 +1722,7 @@ static int cleaner_kthread(void *arg)
 
                btrfs_run_delayed_iputs(fs_info);
 
-               again = btrfs_clean_one_deleted_snapshot(root);
+               again = btrfs_clean_one_deleted_snapshot(fs_info);
                mutex_unlock(&fs_info->cleaner_mutex);
 
                /*
@@ -3124,7 +3123,7 @@ int open_ctree(struct super_block *sb,
                goto fail_sysfs;
        }
 
-       fs_info->cleaner_kthread = kthread_run(cleaner_kthread, tree_root,
+       fs_info->cleaner_kthread = kthread_run(cleaner_kthread, fs_info,
                                               "btrfs-cleaner");
        if (IS_ERR(fs_info->cleaner_kthread))
                goto fail_sysfs;
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 3f6811cdf803..48d3b5123129 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -2296,10 +2296,10 @@ int btrfs_commit_transaction(struct btrfs_trans_handle 
*trans)
  * because btrfs_commit_super will poke cleaner thread and it will process it a
  * few seconds later.
  */
-int btrfs_clean_one_deleted_snapshot(struct btrfs_root *root)
+int btrfs_clean_one_deleted_snapshot(struct btrfs_fs_info *fs_info)
 {
+       struct btrfs_root *root;
        int ret;
-       struct btrfs_fs_info *fs_info = root->fs_info;
 
        spin_lock(&fs_info->trans_lock);
        if (list_empty(&fs_info->dead_roots)) {
diff --git a/fs/btrfs/transaction.h b/fs/btrfs/transaction.h
index 78c446c222b7..e72e6cf919e2 100644
--- a/fs/btrfs/transaction.h
+++ b/fs/btrfs/transaction.h
@@ -190,7 +190,7 @@ int btrfs_wait_for_commit(struct btrfs_fs_info *fs_info, 
u64 transid);
 
 void btrfs_add_dead_root(struct btrfs_root *root);
 int btrfs_defrag_root(struct btrfs_root *root);
-int btrfs_clean_one_deleted_snapshot(struct btrfs_root *root);
+int btrfs_clean_one_deleted_snapshot(struct btrfs_fs_info *fs_info);
 int btrfs_commit_transaction(struct btrfs_trans_handle *trans);
 int btrfs_commit_transaction_async(struct btrfs_trans_handle *trans,
                                   int wait_for_unblock);
-- 
2.22.0

Reply via email to