linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Josef Bacik <josef@toxicpanda.com>
To: linux-btrfs@vger.kernel.org, kernel-team@fb.com
Subject: [PATCH 07/45] btrfs: kill the btrfs_read_fs_root_no_name helper
Date: Tue, 17 Dec 2019 10:35:57 -0500	[thread overview]
Message-ID: <20191217153635.44733-8-josef@toxicpanda.com> (raw)
In-Reply-To: <20191217153635.44733-1-josef@toxicpanda.com>

All this does is call btrfs_get_fs_root() with check_ref == true.  Just
use btrfs_get_fs_root() so we don't have a bunch of different helpers
that do the same thing.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
 fs/btrfs/disk-io.c     |  2 +-
 fs/btrfs/disk-io.h     |  6 ------
 fs/btrfs/export.c      |  2 +-
 fs/btrfs/file.c        |  2 +-
 fs/btrfs/inode.c       |  6 +++---
 fs/btrfs/ioctl.c       | 12 ++++++------
 fs/btrfs/scrub.c       |  2 +-
 fs/btrfs/send.c        |  4 ++--
 fs/btrfs/super.c       |  2 +-
 fs/btrfs/transaction.c |  2 +-
 fs/btrfs/tree-log.c    |  2 +-
 fs/btrfs/volumes.c     |  2 +-
 12 files changed, 19 insertions(+), 25 deletions(-)

diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index e3957d6b6bab..fba2ca4965c4 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -3179,7 +3179,7 @@ int __cold open_ctree(struct super_block *sb,
 	location.type = BTRFS_ROOT_ITEM_KEY;
 	location.offset = 0;
 
-	fs_info->fs_root = btrfs_read_fs_root_no_name(fs_info, &location);
+	fs_info->fs_root = btrfs_get_fs_root(fs_info, &location, true);
 	if (IS_ERR(fs_info->fs_root)) {
 		err = PTR_ERR(fs_info->fs_root);
 		btrfs_warn(fs_info, "failed to read fs tree: %d", err);
diff --git a/fs/btrfs/disk-io.h b/fs/btrfs/disk-io.h
index 614802bd709d..f5ef9ace903a 100644
--- a/fs/btrfs/disk-io.h
+++ b/fs/btrfs/disk-io.h
@@ -70,12 +70,6 @@ void btrfs_free_fs_roots(struct btrfs_fs_info *fs_info);
 struct btrfs_root *btrfs_get_fs_root(struct btrfs_fs_info *fs_info,
 				     struct btrfs_key *key,
 				     bool check_ref);
-static inline struct btrfs_root *
-btrfs_read_fs_root_no_name(struct btrfs_fs_info *fs_info,
-			   struct btrfs_key *location)
-{
-	return btrfs_get_fs_root(fs_info, location, true);
-}
 
 int btrfs_cleanup_fs_roots(struct btrfs_fs_info *fs_info);
 void btrfs_btree_balance_dirty(struct btrfs_fs_info *fs_info);
diff --git a/fs/btrfs/export.c b/fs/btrfs/export.c
index 72e312cae69d..08cd8c4a02a5 100644
--- a/fs/btrfs/export.c
+++ b/fs/btrfs/export.c
@@ -77,7 +77,7 @@ static struct dentry *btrfs_get_dentry(struct super_block *sb, u64 objectid,
 
 	index = srcu_read_lock(&fs_info->subvol_srcu);
 
-	root = btrfs_read_fs_root_no_name(fs_info, &key);
+	root = btrfs_get_fs_root(fs_info, &key, true);
 	if (IS_ERR(root)) {
 		err = PTR_ERR(root);
 		goto fail;
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index 32e620981485..8baa1b44d514 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -287,7 +287,7 @@ static int __btrfs_run_defrag_inode(struct btrfs_fs_info *fs_info,
 
 	index = srcu_read_lock(&fs_info->subvol_srcu);
 
-	inode_root = btrfs_read_fs_root_no_name(fs_info, &key);
+	inode_root = btrfs_get_fs_root(fs_info, &key, true);
 	if (IS_ERR(inode_root)) {
 		ret = PTR_ERR(inode_root);
 		goto cleanup;
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index fc0624fbe387..138c21f5ed12 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -2514,7 +2514,7 @@ static noinline int record_one_backref(u64 inum, u64 offset, u64 root_id,
 	key.type = BTRFS_ROOT_ITEM_KEY;
 	key.offset = (u64)-1;
 
-	root = btrfs_read_fs_root_no_name(fs_info, &key);
+	root = btrfs_get_fs_root(fs_info, &key, true);
 	if (IS_ERR(root)) {
 		if (PTR_ERR(root) == -ENOENT)
 			return 0;
@@ -2698,7 +2698,7 @@ static noinline int relink_extent_backref(struct btrfs_path *path,
 
 	index = srcu_read_lock(&fs_info->subvol_srcu);
 
-	root = btrfs_read_fs_root_no_name(fs_info, &key);
+	root = btrfs_get_fs_root(fs_info, &key, true);
 	if (IS_ERR(root)) {
 		srcu_read_unlock(&fs_info->subvol_srcu, index);
 		if (PTR_ERR(root) == -ENOENT)
@@ -5675,7 +5675,7 @@ static int fixup_tree_root_location(struct btrfs_fs_info *fs_info,
 
 	btrfs_release_path(path);
 
-	new_root = btrfs_read_fs_root_no_name(fs_info, location);
+	new_root = btrfs_get_fs_root(fs_info, location, true);
 	if (IS_ERR(new_root)) {
 		err = PTR_ERR(new_root);
 		goto out;
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 375befdecc19..95b0488b7da6 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -666,7 +666,7 @@ static noinline int create_subvol(struct inode *dir,
 		goto fail;
 
 	key.offset = (u64)-1;
-	new_root = btrfs_read_fs_root_no_name(fs_info, &key);
+	new_root = btrfs_get_fs_root(fs_info, &key, true);
 	if (IS_ERR(new_root)) {
 		ret = PTR_ERR(new_root);
 		btrfs_abort_transaction(trans, ret);
@@ -2179,7 +2179,7 @@ static noinline int search_ioctl(struct inode *inode,
 		key.objectid = sk->tree_id;
 		key.type = BTRFS_ROOT_ITEM_KEY;
 		key.offset = (u64)-1;
-		root = btrfs_read_fs_root_no_name(info, &key);
+		root = btrfs_get_fs_root(info, &key, true);
 		if (IS_ERR(root)) {
 			btrfs_free_path(path);
 			return PTR_ERR(root);
@@ -2314,7 +2314,7 @@ static noinline int btrfs_search_path_in_tree(struct btrfs_fs_info *info,
 	key.objectid = tree_id;
 	key.type = BTRFS_ROOT_ITEM_KEY;
 	key.offset = (u64)-1;
-	root = btrfs_read_fs_root_no_name(info, &key);
+	root = btrfs_get_fs_root(info, &key, true);
 	if (IS_ERR(root)) {
 		ret = PTR_ERR(root);
 		goto out;
@@ -2408,7 +2408,7 @@ static int btrfs_search_path_in_tree_user(struct inode *inode,
 		key.objectid = treeid;
 		key.type = BTRFS_ROOT_ITEM_KEY;
 		key.offset = (u64)-1;
-		root = btrfs_read_fs_root_no_name(fs_info, &key);
+		root = btrfs_get_fs_root(fs_info, &key, true);
 		if (IS_ERR(root)) {
 			ret = PTR_ERR(root);
 			goto out;
@@ -2653,7 +2653,7 @@ static int btrfs_ioctl_get_subvol_info(struct file *file, void __user *argp)
 	key.objectid = BTRFS_I(inode)->root->root_key.objectid;
 	key.type = BTRFS_ROOT_ITEM_KEY;
 	key.offset = (u64)-1;
-	root = btrfs_read_fs_root_no_name(fs_info, &key);
+	root = btrfs_get_fs_root(fs_info, &key, true);
 	if (IS_ERR(root)) {
 		ret = PTR_ERR(root);
 		goto out;
@@ -3986,7 +3986,7 @@ static long btrfs_ioctl_default_subvol(struct file *file, void __user *argp)
 	location.type = BTRFS_ROOT_ITEM_KEY;
 	location.offset = (u64)-1;
 
-	new_root = btrfs_read_fs_root_no_name(fs_info, &location);
+	new_root = btrfs_get_fs_root(fs_info, &location, true);
 	if (IS_ERR(new_root)) {
 		ret = PTR_ERR(new_root);
 		goto out;
diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
index e2c87220600f..eed3a8492092 100644
--- a/fs/btrfs/scrub.c
+++ b/fs/btrfs/scrub.c
@@ -652,7 +652,7 @@ static int scrub_print_warning_inode(u64 inum, u64 offset, u64 root,
 	root_key.objectid = root;
 	root_key.type = BTRFS_ROOT_ITEM_KEY;
 	root_key.offset = (u64)-1;
-	local_root = btrfs_read_fs_root_no_name(fs_info, &root_key);
+	local_root = btrfs_get_fs_root(fs_info, &root_key, true);
 	if (IS_ERR(local_root)) {
 		ret = PTR_ERR(local_root);
 		goto err;
diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index ae2db5eb1549..73e2e350f4a1 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -7200,7 +7200,7 @@ long btrfs_ioctl_send(struct file *mnt_file, struct btrfs_ioctl_send_args *arg)
 
 			index = srcu_read_lock(&fs_info->subvol_srcu);
 
-			clone_root = btrfs_read_fs_root_no_name(fs_info, &key);
+			clone_root = btrfs_get_fs_root(fs_info, &key, true);
 			if (IS_ERR(clone_root)) {
 				srcu_read_unlock(&fs_info->subvol_srcu, index);
 				ret = PTR_ERR(clone_root);
@@ -7239,7 +7239,7 @@ long btrfs_ioctl_send(struct file *mnt_file, struct btrfs_ioctl_send_args *arg)
 
 		index = srcu_read_lock(&fs_info->subvol_srcu);
 
-		sctx->parent_root = btrfs_read_fs_root_no_name(fs_info, &key);
+		sctx->parent_root = btrfs_get_fs_root(fs_info, &key, true);
 		if (IS_ERR(sctx->parent_root)) {
 			srcu_read_unlock(&fs_info->subvol_srcu, index);
 			ret = PTR_ERR(sctx->parent_root);
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index a98c3c71fc54..e387ca1ac0e5 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -1077,7 +1077,7 @@ static char *get_subvol_name_from_objectid(struct btrfs_fs_info *fs_info,
 		key.objectid = subvol_objectid;
 		key.type = BTRFS_ROOT_ITEM_KEY;
 		key.offset = (u64)-1;
-		fs_root = btrfs_read_fs_root_no_name(fs_info, &key);
+		fs_root = btrfs_get_fs_root(fs_info, &key, true);
 		if (IS_ERR(fs_root)) {
 			ret = PTR_ERR(fs_root);
 			goto err;
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 55d8fd68775a..e194d3e4e3a9 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -1631,7 +1631,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
 	}
 
 	key.offset = (u64)-1;
-	pending->snap = btrfs_read_fs_root_no_name(fs_info, &key);
+	pending->snap = btrfs_get_fs_root(fs_info, &key, true);
 	if (IS_ERR(pending->snap)) {
 		ret = PTR_ERR(pending->snap);
 		btrfs_abort_transaction(trans, ret);
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index 881d117a07db..a4321bdcbf3e 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -6291,7 +6291,7 @@ int btrfs_recover_log_trees(struct btrfs_root *log_root_tree)
 		tmp_key.type = BTRFS_ROOT_ITEM_KEY;
 		tmp_key.offset = (u64)-1;
 
-		wc.replay_dest = btrfs_read_fs_root_no_name(fs_info, &tmp_key);
+		wc.replay_dest = btrfs_get_fs_root(fs_info, &tmp_key, true);
 		if (IS_ERR(wc.replay_dest)) {
 			ret = PTR_ERR(wc.replay_dest);
 
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index d8e5560db285..904c3e03467f 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -4372,7 +4372,7 @@ static int btrfs_check_uuid_tree_entry(struct btrfs_fs_info *fs_info,
 	key.objectid = subid;
 	key.type = BTRFS_ROOT_ITEM_KEY;
 	key.offset = (u64)-1;
-	subvol_root = btrfs_read_fs_root_no_name(fs_info, &key);
+	subvol_root = btrfs_get_fs_root(fs_info, &key, true);
 	if (IS_ERR(subvol_root)) {
 		ret = PTR_ERR(subvol_root);
 		if (ret == -ENOENT)
-- 
2.23.0


  parent reply	other threads:[~2019-12-17 15:36 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-17 15:35 [PATCH 0/45][v2] Cleanup how we handle root refs, part 1 Josef Bacik
2019-12-17 15:35 ` [PATCH 01/45] btrfs: push __setup_root into btrfs_alloc_root Josef Bacik
2019-12-17 15:35 ` [PATCH 02/45] btrfs: move fs root init stuff into btrfs_init_fs_root Josef Bacik
2019-12-17 15:35 ` [PATCH 03/45] btrfs: make btrfs_find_orphan_roots use btrfs_get_fs_root Josef Bacik
2019-12-17 15:35 ` [PATCH 04/45] btrfs: export and use btrfs_read_tree_root Josef Bacik
2019-12-17 15:35 ` [PATCH 05/45] btrfs: make relocation use btrfs_read_tree_root() Josef Bacik
2019-12-17 15:35 ` [PATCH 06/45] btrfs: kill btrfs_read_fs_root Josef Bacik
2019-12-17 15:35 ` Josef Bacik [this message]
2019-12-17 15:35 ` [PATCH 08/45] btrfs: make the fs root init functions static Josef Bacik
2019-12-17 15:35 ` [PATCH 09/45] btrfs: handle NULL roots in btrfs_put/btrfs_grab_fs_root Josef Bacik
2019-12-17 15:36 ` [PATCH 10/45] btrfs: hold a ref on fs roots while they're in the radix tree Josef Bacik
2019-12-17 15:36 ` [PATCH 11/45] btrfs: hold a ref on the root in resolve_indirect_ref Josef Bacik
2019-12-17 15:36 ` [PATCH 12/45] btrfs: hold a root ref in btrfs_get_dentry Josef Bacik
2019-12-17 15:36 ` [PATCH 13/45] btrfs: hold a ref on the root in __btrfs_run_defrag_inode Josef Bacik
2019-12-17 15:36 ` [PATCH 14/45] btrfs: hold a ref for the root in record_one_backref Josef Bacik
2019-12-17 15:36 ` [PATCH 15/45] btrfs: grab a ref on the root in relink_extent_backref Josef Bacik
2019-12-17 15:36 ` [PATCH 16/45] btrfs: hold a ref on the root in fixup_tree_root_location Josef Bacik
2019-12-17 15:36 ` [PATCH 17/45] btrfs: hold a ref on the root in create_subvol Josef Bacik
2019-12-17 15:36 ` [PATCH 18/45] btrfs: hold a ref on the root in search_ioctl Josef Bacik
2019-12-17 15:36 ` [PATCH 19/45] btrfs: hold a ref on the root in btrfs_search_path_in_tree Josef Bacik
2019-12-17 15:36 ` [PATCH 20/45] btrfs: hold a ref on the root in btrfs_search_path_in_tree_user Josef Bacik
2019-12-17 15:36 ` [PATCH 21/45] btrfs: hold a ref on the root in btrfs_ioctl_get_subvol_info Josef Bacik
2019-12-17 15:36 ` [PATCH 22/45] btrfs: hold ref on root in btrfs_ioctl_default_subvol Josef Bacik
2019-12-17 15:36 ` [PATCH 23/45] btrfs: hold a ref on the root in build_backref_tree Josef Bacik
2019-12-17 15:36 ` [PATCH 24/45] btrfs: hold a ref on the root in prepare_to_merge Josef Bacik
2019-12-17 15:36 ` [PATCH 25/45] btrfs: hold a ref on the root in merge_reloc_roots Josef Bacik
2019-12-17 15:36 ` [PATCH 26/45] btrfs: hold a ref on the root in record_reloc_root_in_trans Josef Bacik
2019-12-17 15:36 ` [PATCH 27/45] btrfs: hold a ref on the root in find_data_references Josef Bacik
2019-12-17 15:36 ` [PATCH 28/45] btrfs: hold a ref on the root in create_reloc_inode Josef Bacik
2019-12-17 15:36 ` [PATCH 29/45] btrfs: hold a ref on the root in btrfs_recover_relocation Josef Bacik
2019-12-17 15:36 ` [PATCH 30/45] btrfs: push grab_fs_root into read_fs_root Josef Bacik
2019-12-17 15:36 ` [PATCH 31/45] btrfs: hold a ref for the root in btrfs_find_orphan_roots Josef Bacik
2019-12-17 15:36 ` [PATCH 32/45] btrfs: hold a ref on the root in scrub_print_warning_inode Josef Bacik
2019-12-17 15:36 ` [PATCH 33/45] btrfs: hold a ref on the root in btrfs_ioctl_send Josef Bacik
2019-12-17 15:36 ` [PATCH 34/45] btrfs: hold a ref on the root in get_subvol_name_from_objectid Josef Bacik
2019-12-17 15:36 ` [PATCH 35/45] btrfs: hold a ref on the root in create_pending_snapshot Josef Bacik
2019-12-17 15:36 ` [PATCH 36/45] btrfs: hold a ref on the root in btrfs_recover_log_trees Josef Bacik
2019-12-17 15:36 ` [PATCH 37/45] btrfs: hold a ref on the root in btrfs_check_uuid_tree_entry Josef Bacik
2019-12-17 15:36 ` [PATCH 38/45] btrfs: hold a ref on the root in open_ctree Josef Bacik
2019-12-17 15:36 ` [PATCH 39/45] btrfs: use btrfs_put_fs_root to free roots always Josef Bacik
2019-12-17 15:36 ` [PATCH 40/45] btrfs: push btrfs_grab_fs_root into btrfs_get_fs_root Josef Bacik
2019-12-17 15:36 ` [PATCH 41/45] btrfs: free more things in btrfs_free_fs_info Josef Bacik
2019-12-17 15:36 ` [PATCH 42/45] btrfs: move fs_info init work into it's own helper function Josef Bacik
2019-12-17 15:36 ` [PATCH 43/45] btrfs: make the init of static elements in fs_info separate Josef Bacik
2019-12-17 15:36 ` [PATCH 44/45] btrfs: add a leak check for roots Josef Bacik
2019-12-17 15:36 ` [PATCH 45/45] btrfs: rename btrfs_put_fs_root and btrfs_grab_fs_root Josef Bacik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191217153635.44733-8-josef@toxicpanda.com \
    --to=josef@toxicpanda.com \
    --cc=kernel-team@fb.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).