btrfs: unify inode variable naming
authorDavid Sterba <dsterba@suse.com>
Mon, 3 Mar 2025 14:55:41 +0000 (15:55 +0100)
committerDavid Sterba <dsterba@suse.com>
Tue, 18 Mar 2025 19:35:49 +0000 (20:35 +0100)
Rename binode to inode in local variables or parameters so it's more
unified with the rest of the code.

Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/inode.c
fs/btrfs/ioctl.c

index 01fbaae47d7c73e2b23cd343242721e53a8c36c1..da763a61d4a785d483e9d18c20dad2a253abb415 100644 (file)
@@ -8513,8 +8513,6 @@ static int start_delalloc_inodes(struct btrfs_root *root,
                                 struct writeback_control *wbc, bool snapshot,
                                 bool in_reclaim_context)
 {
-       struct btrfs_inode *binode;
-       struct inode *inode;
        struct btrfs_delalloc_work *work, *next;
        LIST_HEAD(works);
        LIST_HEAD(splice);
@@ -8525,30 +8523,30 @@ static int start_delalloc_inodes(struct btrfs_root *root,
        spin_lock(&root->delalloc_lock);
        list_splice_init(&root->delalloc_inodes, &splice);
        while (!list_empty(&splice)) {
-               binode = list_entry(splice.next, struct btrfs_inode,
-                                   delalloc_inodes);
+               struct btrfs_inode *inode;
+               struct inode *tmp_inode;
 
-               list_move_tail(&binode->delalloc_inodes,
-                              &root->delalloc_inodes);
+               inode = list_entry(splice.next, struct btrfs_inode, delalloc_inodes);
+
+               list_move_tail(&inode->delalloc_inodes, &root->delalloc_inodes);
 
                if (in_reclaim_context &&
-                   test_bit(BTRFS_INODE_NO_DELALLOC_FLUSH, &binode->runtime_flags))
+                   test_bit(BTRFS_INODE_NO_DELALLOC_FLUSH, &inode->runtime_flags))
                        continue;
 
-               inode = igrab(&binode->vfs_inode);
-               if (!inode) {
+               tmp_inode = igrab(&inode->vfs_inode);
+               if (!tmp_inode) {
                        cond_resched_lock(&root->delalloc_lock);
                        continue;
                }
                spin_unlock(&root->delalloc_lock);
 
                if (snapshot)
-                       set_bit(BTRFS_INODE_SNAPSHOT_FLUSH,
-                               &binode->runtime_flags);
+                       set_bit(BTRFS_INODE_SNAPSHOT_FLUSH, &inode->runtime_flags);
                if (full_flush) {
-                       work = btrfs_alloc_delalloc_work(inode);
+                       work = btrfs_alloc_delalloc_work(&inode->vfs_inode);
                        if (!work) {
-                               iput(inode);
+                               iput(&inode->vfs_inode);
                                ret = -ENOMEM;
                                goto out;
                        }
@@ -8556,8 +8554,8 @@ static int start_delalloc_inodes(struct btrfs_root *root,
                        btrfs_queue_work(root->fs_info->flush_workers,
                                         &work->work);
                } else {
-                       ret = filemap_fdatawrite_wbc(inode->i_mapping, wbc);
-                       btrfs_add_delayed_iput(BTRFS_I(inode));
+                       ret = filemap_fdatawrite_wbc(inode->vfs_inode.i_mapping, wbc);
+                       btrfs_add_delayed_iput(inode);
                        if (ret || wbc->nr_to_write <= 0)
                                goto out;
                }
index 188fb7ec32d11747038a1049553b35fb0c8c2f22..fffa2868f3296d148cd4f2fec79d18e5c2df00f5 100644 (file)
@@ -133,11 +133,11 @@ static unsigned int btrfs_mask_fsflags_for_type(const struct inode *inode,
  * Export internal inode flags to the format expected by the FS_IOC_GETFLAGS
  * ioctl.
  */
-static unsigned int btrfs_inode_flags_to_fsflags(const struct btrfs_inode *binode)
+static unsigned int btrfs_inode_flags_to_fsflags(const struct btrfs_inode *inode)
 {
        unsigned int iflags = 0;
-       u32 flags = binode->flags;
-       u32 ro_flags = binode->ro_flags;
+       u32 flags = inode->flags;
+       u32 ro_flags = inode->ro_flags;
 
        if (flags & BTRFS_INODE_SYNC)
                iflags |= FS_SYNC_FL;
@@ -247,24 +247,23 @@ static int btrfs_check_ioctl_vol_args2_subvol_name(const struct btrfs_ioctl_vol_
  */
 int btrfs_fileattr_get(struct dentry *dentry, struct fileattr *fa)
 {
-       const struct btrfs_inode *binode = BTRFS_I(d_inode(dentry));
+       const struct btrfs_inode *inode = BTRFS_I(d_inode(dentry));
 
-       fileattr_fill_flags(fa, btrfs_inode_flags_to_fsflags(binode));
+       fileattr_fill_flags(fa, btrfs_inode_flags_to_fsflags(inode));
        return 0;
 }
 
 int btrfs_fileattr_set(struct mnt_idmap *idmap,
                       struct dentry *dentry, struct fileattr *fa)
 {
-       struct inode *inode = d_inode(dentry);
-       struct btrfs_fs_info *fs_info = inode_to_fs_info(inode);
-       struct btrfs_inode *binode = BTRFS_I(inode);
-       struct btrfs_root *root = binode->root;
+       struct btrfs_inode *inode = BTRFS_I(d_inode(dentry));
+       struct btrfs_root *root = inode->root;
+       struct btrfs_fs_info *fs_info = root->fs_info;
        struct btrfs_trans_handle *trans;
        unsigned int fsflags, old_fsflags;
        int ret;
        const char *comp = NULL;
-       u32 binode_flags;
+       u32 inode_flags;
 
        if (btrfs_root_readonly(root))
                return -EROFS;
@@ -272,8 +271,8 @@ int btrfs_fileattr_set(struct mnt_idmap *idmap,
        if (fileattr_has_fsx(fa))
                return -EOPNOTSUPP;
 
-       fsflags = btrfs_mask_fsflags_for_type(inode, fa->flags);
-       old_fsflags = btrfs_inode_flags_to_fsflags(binode);
+       fsflags = btrfs_mask_fsflags_for_type(&inode->vfs_inode, fa->flags);
+       old_fsflags = btrfs_inode_flags_to_fsflags(inode);
        ret = check_fsflags(old_fsflags, fsflags);
        if (ret)
                return ret;
@@ -282,27 +281,27 @@ int btrfs_fileattr_set(struct mnt_idmap *idmap,
        if (ret)
                return ret;
 
-       binode_flags = binode->flags;
+       inode_flags = inode->flags;
        if (fsflags & FS_SYNC_FL)
-               binode_flags |= BTRFS_INODE_SYNC;
+               inode_flags |= BTRFS_INODE_SYNC;
        else
-               binode_flags &= ~BTRFS_INODE_SYNC;
+               inode_flags &= ~BTRFS_INODE_SYNC;
        if (fsflags & FS_IMMUTABLE_FL)
-               binode_flags |= BTRFS_INODE_IMMUTABLE;
+               inode_flags |= BTRFS_INODE_IMMUTABLE;
        else
-               binode_flags &= ~BTRFS_INODE_IMMUTABLE;
+               inode_flags &= ~BTRFS_INODE_IMMUTABLE;
        if (fsflags & FS_APPEND_FL)
-               binode_flags |= BTRFS_INODE_APPEND;
+               inode_flags |= BTRFS_INODE_APPEND;
        else
-               binode_flags &= ~BTRFS_INODE_APPEND;
+               inode_flags &= ~BTRFS_INODE_APPEND;
        if (fsflags & FS_NODUMP_FL)
-               binode_flags |= BTRFS_INODE_NODUMP;
+               inode_flags |= BTRFS_INODE_NODUMP;
        else
-               binode_flags &= ~BTRFS_INODE_NODUMP;
+               inode_flags &= ~BTRFS_INODE_NODUMP;
        if (fsflags & FS_NOATIME_FL)
-               binode_flags |= BTRFS_INODE_NOATIME;
+               inode_flags |= BTRFS_INODE_NOATIME;
        else
-               binode_flags &= ~BTRFS_INODE_NOATIME;
+               inode_flags &= ~BTRFS_INODE_NOATIME;
 
        /* If coming from FS_IOC_FSSETXATTR then skip unconverted flags */
        if (!fa->flags_valid) {
@@ -314,32 +313,32 @@ int btrfs_fileattr_set(struct mnt_idmap *idmap,
        }
 
        if (fsflags & FS_DIRSYNC_FL)
-               binode_flags |= BTRFS_INODE_DIRSYNC;
+               inode_flags |= BTRFS_INODE_DIRSYNC;
        else
-               binode_flags &= ~BTRFS_INODE_DIRSYNC;
+               inode_flags &= ~BTRFS_INODE_DIRSYNC;
        if (fsflags & FS_NOCOW_FL) {
-               if (S_ISREG(inode->i_mode)) {
+               if (S_ISREG(inode->vfs_inode.i_mode)) {
                        /*
                         * It's safe to turn csums off here, no extents exist.
                         * Otherwise we want the flag to reflect the real COW
                         * status of the file and will not set it.
                         */
-                       if (inode->i_size == 0)
-                               binode_flags |= BTRFS_INODE_NODATACOW |
-                                               BTRFS_INODE_NODATASUM;
+                       if (inode->vfs_inode.i_size == 0)
+                               inode_flags |= BTRFS_INODE_NODATACOW |
+                                              BTRFS_INODE_NODATASUM;
                } else {
-                       binode_flags |= BTRFS_INODE_NODATACOW;
+                       inode_flags |= BTRFS_INODE_NODATACOW;
                }
        } else {
                /*
                 * Revert back under same assumptions as above
                 */
-               if (S_ISREG(inode->i_mode)) {
-                       if (inode->i_size == 0)
-                               binode_flags &= ~(BTRFS_INODE_NODATACOW |
-                                                 BTRFS_INODE_NODATASUM);
+               if (S_ISREG(inode->vfs_inode.i_mode)) {
+                       if (inode->vfs_inode.i_size == 0)
+                               inode_flags &= ~(BTRFS_INODE_NODATACOW |
+                                                BTRFS_INODE_NODATASUM);
                } else {
-                       binode_flags &= ~BTRFS_INODE_NODATACOW;
+                       inode_flags &= ~BTRFS_INODE_NODATACOW;
                }
        }
 
@@ -349,21 +348,21 @@ int btrfs_fileattr_set(struct mnt_idmap *idmap,
         * things smaller.
         */
        if (fsflags & FS_NOCOMP_FL) {
-               binode_flags &= ~BTRFS_INODE_COMPRESS;
-               binode_flags |= BTRFS_INODE_NOCOMPRESS;
+               inode_flags &= ~BTRFS_INODE_COMPRESS;
+               inode_flags |= BTRFS_INODE_NOCOMPRESS;
        } else if (fsflags & FS_COMPR_FL) {
 
-               if (IS_SWAPFILE(inode))
+               if (IS_SWAPFILE(&inode->vfs_inode))
                        return -ETXTBSY;
 
-               binode_flags |= BTRFS_INODE_COMPRESS;
-               binode_flags &= ~BTRFS_INODE_NOCOMPRESS;
+               inode_flags |= BTRFS_INODE_COMPRESS;
+               inode_flags &= ~BTRFS_INODE_NOCOMPRESS;
 
                comp = btrfs_compress_type2str(fs_info->compress_type);
                if (!comp || comp[0] == 0)
                        comp = btrfs_compress_type2str(BTRFS_COMPRESS_ZLIB);
        } else {
-               binode_flags &= ~(BTRFS_INODE_COMPRESS | BTRFS_INODE_NOCOMPRESS);
+               inode_flags &= ~(BTRFS_INODE_COMPRESS | BTRFS_INODE_NOCOMPRESS);
        }
 
        /*
@@ -375,15 +374,14 @@ int btrfs_fileattr_set(struct mnt_idmap *idmap,
                return PTR_ERR(trans);
 
        if (comp) {
-               ret = btrfs_set_prop(trans, BTRFS_I(inode), "btrfs.compression",
+               ret = btrfs_set_prop(trans, inode, "btrfs.compression",
                                     comp, strlen(comp), 0);
                if (ret) {
                        btrfs_abort_transaction(trans, ret);
                        goto out_end_trans;
                }
        } else {
-               ret = btrfs_set_prop(trans, BTRFS_I(inode), "btrfs.compression",
-                                    NULL, 0, 0);
+               ret = btrfs_set_prop(trans, inode, "btrfs.compression", NULL, 0, 0);
                if (ret && ret != -ENODATA) {
                        btrfs_abort_transaction(trans, ret);
                        goto out_end_trans;
@@ -391,12 +389,12 @@ int btrfs_fileattr_set(struct mnt_idmap *idmap,
        }
 
 update_flags:
-       binode->flags = binode_flags;
-       btrfs_update_inode_mapping_flags(binode);
-       btrfs_sync_inode_flags_to_i_flags(binode);
-       inode_inc_iversion(inode);
-       inode_set_ctime_current(inode);
-       ret = btrfs_update_inode(trans, BTRFS_I(inode));
+       inode->flags = inode_flags;
+       btrfs_update_inode_mapping_flags(inode);
+       btrfs_sync_inode_flags_to_i_flags(inode);
+       inode_inc_iversion(&inode->vfs_inode);
+       inode_set_ctime_current(&inode->vfs_inode);
+       ret = btrfs_update_inode(trans, inode);
 
  out_end_trans:
        btrfs_end_transaction(trans);