btrfs: remove super block argument from btrfs_iget()
authorFilipe Manana <fdmanana@suse.com>
Thu, 13 Jun 2024 10:36:26 +0000 (11:36 +0100)
committerDavid Sterba <dsterba@suse.com>
Thu, 11 Jul 2024 13:33:25 +0000 (15:33 +0200)
It's pointless to pass a super block argument to btrfs_iget() because we
always pass a root and from it we can get the super block through:

   root->fs_info->sb

So remove the super block argument.

Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/btrfs_inode.h
fs/btrfs/defrag.c
fs/btrfs/export.c
fs/btrfs/inode.c
fs/btrfs/ioctl.c
fs/btrfs/relocation.c
fs/btrfs/send.c
fs/btrfs/super.c
fs/btrfs/tree-log.c

index 7a18582..4867b0d 100644 (file)
@@ -576,7 +576,7 @@ int __init btrfs_init_cachep(void);
 void __cold btrfs_destroy_cachep(void);
 struct inode *btrfs_iget_path(struct super_block *s, u64 ino,
                              struct btrfs_root *root, struct btrfs_path *path);
-struct inode *btrfs_iget(struct super_block *s, u64 ino, struct btrfs_root *root);
+struct inode *btrfs_iget(u64 ino, struct btrfs_root *root);
 struct extent_map *btrfs_get_extent(struct btrfs_inode *inode,
                                    struct page *page, u64 start, u64 len);
 int btrfs_update_inode(struct btrfs_trans_handle *trans,
index 6fb94e8..e7a24f0 100644 (file)
@@ -255,7 +255,7 @@ again:
                goto cleanup;
        }
 
-       inode = btrfs_iget(fs_info->sb, defrag->ino, inode_root);
+       inode = btrfs_iget(defrag->ino, inode_root);
        btrfs_put_root(inode_root);
        if (IS_ERR(inode)) {
                ret = PTR_ERR(inode);
index 5da56e2..e2b22be 100644 (file)
@@ -84,7 +84,7 @@ struct dentry *btrfs_get_dentry(struct super_block *sb, u64 objectid,
        if (IS_ERR(root))
                return ERR_CAST(root);
 
-       inode = btrfs_iget(sb, objectid, root);
+       inode = btrfs_iget(objectid, root);
        btrfs_put_root(root);
        if (IS_ERR(inode))
                return ERR_CAST(inode);
@@ -210,7 +210,7 @@ struct dentry *btrfs_get_parent(struct dentry *child)
                                        found_key.offset, 0);
        }
 
-       return d_obtain_alias(btrfs_iget(fs_info->sb, key.objectid, root));
+       return d_obtain_alias(btrfs_iget(key.objectid, root));
 fail:
        btrfs_free_path(path);
        return ERR_PTR(ret);
index cc8db6b..58e9bf4 100644 (file)
@@ -3577,7 +3577,7 @@ int btrfs_orphan_cleanup(struct btrfs_root *root)
                found_key.objectid = found_key.offset;
                found_key.type = BTRFS_INODE_ITEM_KEY;
                found_key.offset = 0;
-               inode = btrfs_iget(fs_info->sb, last_objectid, root);
+               inode = btrfs_iget(last_objectid, root);
                if (IS_ERR(inode)) {
                        ret = PTR_ERR(inode);
                        inode = NULL;
@@ -5630,9 +5630,9 @@ error:
        return ERR_PTR(ret);
 }
 
-struct inode *btrfs_iget(struct super_block *s, u64 ino, struct btrfs_root *root)
+struct inode *btrfs_iget(u64 ino, struct btrfs_root *root)
 {
-       return btrfs_iget_path(s, ino, root, NULL);
+       return btrfs_iget_path(root->fs_info->sb, ino, root, NULL);
 }
 
 static struct inode *new_simple_dir(struct inode *dir,
@@ -5704,7 +5704,7 @@ struct inode *btrfs_lookup_dentry(struct inode *dir, struct dentry *dentry)
                return ERR_PTR(ret);
 
        if (location.type == BTRFS_INODE_ITEM_KEY) {
-               inode = btrfs_iget(dir->i_sb, location.objectid, root);
+               inode = btrfs_iget(location.objectid, root);
                if (IS_ERR(inode))
                        return inode;
 
@@ -5728,7 +5728,7 @@ struct inode *btrfs_lookup_dentry(struct inode *dir, struct dentry *dentry)
                else
                        inode = new_simple_dir(dir, &location, root);
        } else {
-               inode = btrfs_iget(dir->i_sb, location.objectid, sub_root);
+               inode = btrfs_iget(location.objectid, sub_root);
                btrfs_put_root(sub_root);
 
                if (IS_ERR(inode))
@@ -6403,8 +6403,7 @@ int btrfs_create_new_inode(struct btrfs_trans_handle *trans,
                 * Subvolumes inherit properties from their parent subvolume,
                 * not the directory they were created in.
                 */
-               parent = btrfs_iget(fs_info->sb, BTRFS_FIRST_FREE_OBJECTID,
-                                   BTRFS_I(dir)->root);
+               parent = btrfs_iget(BTRFS_FIRST_FREE_OBJECTID, BTRFS_I(dir)->root);
                if (IS_ERR(parent)) {
                        ret = PTR_ERR(parent);
                } else {
index 1dca986..06447ee 100644 (file)
@@ -1914,7 +1914,6 @@ static int btrfs_search_path_in_tree_user(struct mnt_idmap *idmap,
                                struct btrfs_ioctl_ino_lookup_user_args *args)
 {
        struct btrfs_fs_info *fs_info = BTRFS_I(inode)->root->fs_info;
-       struct super_block *sb = inode->i_sb;
        u64 upper_limit = btrfs_ino(BTRFS_I(inode));
        u64 treeid = btrfs_root_id(BTRFS_I(inode)->root);
        u64 dirid = args->dirid;
@@ -2003,7 +2002,7 @@ static int btrfs_search_path_in_tree_user(struct mnt_idmap *idmap,
                         * btree and lock the same leaf.
                         */
                        btrfs_release_path(path);
-                       temp_inode = btrfs_iget(sb, key2.objectid, root);
+                       temp_inode = btrfs_iget(key2.objectid, root);
                        if (IS_ERR(temp_inode)) {
                                ret = PTR_ERR(temp_inode);
                                goto out_put;
index 320e436..6ea4072 100644 (file)
@@ -3376,7 +3376,7 @@ static int delete_block_group_cache(struct btrfs_fs_info *fs_info,
        if (inode)
                goto truncate;
 
-       inode = btrfs_iget(fs_info->sb, ino, root);
+       inode = btrfs_iget(ino, root);
        if (IS_ERR(inode))
                return -ENOENT;
 
@@ -3913,7 +3913,7 @@ static noinline_for_stack struct inode *create_reloc_inode(
        if (ret)
                goto out;
 
-       inode = btrfs_iget(fs_info->sb, objectid, root);
+       inode = btrfs_iget(objectid, root);
        if (IS_ERR(inode)) {
                delete_orphan_inode(trans, root, objectid);
                ret = PTR_ERR(inode);
index 8159695..bc2acda 100644 (file)
@@ -5188,11 +5188,10 @@ out:
 static int process_verity(struct send_ctx *sctx)
 {
        int ret = 0;
-       struct btrfs_fs_info *fs_info = sctx->send_root->fs_info;
        struct inode *inode;
        struct fs_path *p;
 
-       inode = btrfs_iget(fs_info->sb, sctx->cur_ino, sctx->send_root);
+       inode = btrfs_iget(sctx->cur_ino, sctx->send_root);
        if (IS_ERR(inode))
                return PTR_ERR(inode);
 
@@ -5550,7 +5549,7 @@ static int send_encoded_inline_extent(struct send_ctx *sctx,
        size_t inline_size;
        int ret;
 
-       inode = btrfs_iget(fs_info->sb, sctx->cur_ino, root);
+       inode = btrfs_iget(sctx->cur_ino, root);
        if (IS_ERR(inode))
                return PTR_ERR(inode);
 
@@ -5617,7 +5616,7 @@ static int send_encoded_extent(struct send_ctx *sctx, struct btrfs_path *path,
        u32 crc;
        int ret;
 
-       inode = btrfs_iget(fs_info->sb, sctx->cur_ino, root);
+       inode = btrfs_iget(sctx->cur_ino, root);
        if (IS_ERR(inode))
                return PTR_ERR(inode);
 
@@ -5746,7 +5745,7 @@ static int send_extent_data(struct send_ctx *sctx, struct btrfs_path *path,
        if (sctx->cur_inode == NULL) {
                struct btrfs_root *root = sctx->send_root;
 
-               sctx->cur_inode = btrfs_iget(root->fs_info->sb, sctx->cur_ino, root);
+               sctx->cur_inode = btrfs_iget(sctx->cur_ino, root);
                if (IS_ERR(sctx->cur_inode)) {
                        int err = PTR_ERR(sctx->cur_inode);
 
index 549ad70..715686e 100644 (file)
@@ -949,7 +949,7 @@ static int btrfs_fill_super(struct super_block *sb,
                return err;
        }
 
-       inode = btrfs_iget(sb, BTRFS_FIRST_FREE_OBJECTID, fs_info->fs_root);
+       inode = btrfs_iget(BTRFS_FIRST_FREE_OBJECTID, fs_info->fs_root);
        if (IS_ERR(inode)) {
                err = PTR_ERR(inode);
                btrfs_handle_fs_error(fs_info, err, NULL);
index 4c9cc8e..f0cf8ce 100644 (file)
@@ -151,7 +151,7 @@ static struct inode *btrfs_iget_logging(u64 objectid, struct btrfs_root *root)
         * attempt a transaction commit, resulting in a deadlock.
         */
        nofs_flag = memalloc_nofs_save();
-       inode = btrfs_iget(root->fs_info->sb, objectid, root);
+       inode = btrfs_iget(objectid, root);
        memalloc_nofs_restore(nofs_flag);
 
        return inode;