Btrfs: some cleanups around btrfs_read_fs_root_no_name()
cover Btrfs: some cleanups around btrfs_read_fs_root_no_name()
Just some line deletions for callers of btrfs_read_fs_root_no_name(). They repeat the check for btrfs_root_refs() after calling btrfs_read_fs_root_no_name() and map the error to ENOENT in this case, and btrfs_read_fs_root_no_name() already does the same for you. send.c even checked the result for NULL which cannot happen. And one static inline function in delayed-inode.c that called btrfs_read_fs_root_no_name() was not at all used anymore.
Stefan Behrens (3):
Btrfs: delete unused function
Btrfs: cleanup, btrfs_read_fs_root_no_name() doesn't return NULL
Btrfs: cleanup: don't check the same thing twice
fs/btrfs/delayed-inode.c | 14 -------------- fs/btrfs/export.c | 5 ----- fs/btrfs/file.c | 4 ---- fs/btrfs/inode.c | 10 ---------- fs/btrfs/ioctl.c | 5 ----- fs/btrfs/send.c | 8 ++------ fs/btrfs/super.c | 3 --- 7 files changed, 2 insertions(+), 47 deletions(-)
Signature · 1 line
1.8.2.2
PATCH 1/3 Btrfs: delete unused function
--- fs/btrfs/delayed-inode.c | 14 -------------- 1 file changed, 14 deletions(-)
fs/btrfs/delayed-inode.c +0 -14
@@ -535,20 +535,6 @@ static struct btrfs_delayed_item *__btrfs_next_delayed_item(return next; } -static inline struct btrfs_root *btrfs_get_fs_root (struct btrfs_root *root, -u64 root_id) -{ -struct btrfs_key root_key; - -if (root->objectid == root_id) -return root; - - root_key.objectid = root_id; - root_key.type =BTRFS_ROOT_ITEM_KEY ; - root_key.offset = (u64)-1 ; -return btrfs_read_fs_root_no_name (root->fs_info, &root_key); -} -static int btrfs_delayed_item_reserve_metadata (struct btrfs_trans_handle *trans,struct btrfs_root *root,struct btrfs_delayed_item *item)
Signature · 1 line
1.8.2.2
PATCH 2/3 Btrfs: cleanup, btrfs_read_fs_root_no_name() doesn't return NULL
In reply to Stefan BehrensNo need to check for NULL in send.c.
--- fs/btrfs/send.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
fs/btrfs/send.c +2 -6
@@ -4663,10 +4663,6 @@ long btrfs_ioctl_send(struct file *mnt_file, void __user *arg_) key.type =BTRFS_ROOT_ITEM_KEY ; key.offset = (u64)-1 ; clone_root =btrfs_read_fs_root_no_name (fs_info, &key); -if (!clone_root) { - ret = -EINVAL ; - goto out; - }if (IS_ERR (clone_root)) { ret =PTR_ERR (clone_root); goto out;
@@ -4682,8 +4678,8 @@ long btrfs_ioctl_send(struct file *mnt_file, void __user *arg_) key.type =BTRFS_ROOT_ITEM_KEY ; key.offset = (u64)-1 ; sctx->parent_root =btrfs_read_fs_root_no_name (fs_info, &key); -if (!sctx->parent_root) { - ret = -EINVAL ; +if (IS_ERR (sctx->parent_root)) { + ret =PTR_ERR (sctx->parent_root); goto out; } }
Signature · 1 line
1.8.2.2
PATCH 3/3 Btrfs: cleanup: don't check the same thing twice
In reply to Stefan Behrensbtrfs_read_fs_root_no_name() already checks if btrfs_root_refs() is zero and returns ENOENT in this case. There is no need to do it again in six places.
--- fs/btrfs/export.c | 5 ----- fs/btrfs/file.c | 4 ---- fs/btrfs/inode.c | 10 ---------- fs/btrfs/ioctl.c | 5 ----- fs/btrfs/super.c | 3 --- 5 files changed, 27 deletions(-)
fs/btrfs/export.c +0 -5
@@ -82,11 +82,6 @@ static struct dentry *btrfs_get_dentry(struct super_block *sb, u64 objectid, goto fail; } -if (btrfs_root_refs (&root->root_item) ==0 ) { - err = -ENOENT ; - goto fail; - } - key.objectid = objectid;btrfs_set_key_type (&key,BTRFS_INODE_ITEM_KEY ); key.offset =0 ;
fs/btrfs/file.c +0 -4
@@ -308,10 +308,6 @@ static int __btrfs_run_defrag_inode(struct btrfs_fs_info *fs_info, ret =PTR_ERR (inode_root); goto cleanup; } -if (btrfs_root_refs (&inode_root->root_item) ==0 ) { - ret = -ENOENT ; - goto cleanup; - } key.objectid = defrag->ino;btrfs_set_key_type (&key,BTRFS_INODE_ITEM_KEY );
fs/btrfs/inode.c +0 -10
@@ -2258,11 +2258,6 @@ static noinline int relink_extent_backref(struct btrfs_path *path,return 0 ;return PTR_ERR (root); } -if (btrfs_root_refs (&root->root_item) ==0 ) { -srcu_read_unlock (&fs_info->subvol_srcu, index); -/* parse ENOENT to 0 */ -return 0 ; - }/* step 2: get inode */ key.objectid = backref->inum;
@@ -4816,11 +4811,6 @@ static int fixup_tree_root_location(struct btrfs_root *root, goto out; } -if (btrfs_root_refs (&new_root->root_item) ==0 ) { - err = -ENOENT ; - goto out; - } - *sub_root = new_root; location->objectid =btrfs_root_dirid (&new_root->root_item); location->type =BTRFS_INODE_ITEM_KEY ;
fs/btrfs/ioctl.c +0 -5
@@ -2951,11 +2951,6 @@ static long btrfs_ioctl_default_subvol(struct file *file, void __user *argp) goto out; } -if (btrfs_root_refs (&new_root->root_item) ==0 ) { - ret = -ENOENT ; - goto out; - } - path =btrfs_alloc_path ();if (!path) { ret = -ENOMEM ;
fs/btrfs/super.c +0 -3
@@ -775,9 +775,6 @@ find_root:if (IS_ERR (new_root))return ERR_CAST (new_root); -if (btrfs_root_refs (&new_root->root_item) ==0 ) -return ERR_PTR (-ENOENT ); - dir_id =btrfs_root_dirid (&new_root->root_item); setup_root: location.objectid = dir_id;
Signature · 1 line
1.8.2.2