erofs-utils: simplify erofs_insert_ihash
authorGao Xiang <hsiangkao@linux.alibaba.com>
Tue, 18 Jun 2024 08:24:06 +0000 (16:24 +0800)
committerGao Xiang <hsiangkao@linux.alibaba.com>
Wed, 19 Jun 2024 03:11:32 +0000 (11:11 +0800)
Get rid of unnecessary arguments for simplicity.

Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20240618082414.47876-1-hsiangkao@linux.alibaba.com
include/erofs/inode.h
lib/inode.c
lib/rebuild.c

index 3bdc2b42b6398a1c7f25b987d72e04dbabab8128..557150c49a71bb434d3d3eacb1ab22621fc0659a 100644 (file)
@@ -26,7 +26,7 @@ unsigned char erofs_mode_to_ftype(umode_t mode);
 umode_t erofs_ftype_to_mode(unsigned int ftype, unsigned int perm);
 unsigned char erofs_ftype_to_dtype(unsigned int filetype);
 void erofs_inode_manager_init(void);
-void erofs_insert_ihash(struct erofs_inode *inode, dev_t dev, ino_t ino);
+void erofs_insert_ihash(struct erofs_inode *inode);
 struct erofs_inode *erofs_iget(dev_t dev, ino_t ino);
 struct erofs_inode *erofs_iget_by_nid(erofs_nid_t nid);
 unsigned int erofs_iput(struct erofs_inode *inode);
index 1ec73fe37db58b126210d3221072e98ea8d28a75..e27399d28ce51995a927691282a600454a1415ba 100644 (file)
@@ -94,10 +94,11 @@ void erofs_inode_manager_init(void)
                init_list_head(&inode_hashtable[i]);
 }
 
-void erofs_insert_ihash(struct erofs_inode *inode, dev_t dev, ino_t ino)
+void erofs_insert_ihash(struct erofs_inode *inode)
 {
-       list_add(&inode->i_hash,
-                &inode_hashtable[(ino ^ dev) % NR_INODE_HASHTABLE]);
+       unsigned int nr = (inode->i_ino[1] ^ inode->dev) % NR_INODE_HASHTABLE;
+
+       list_add(&inode->i_hash, &inode_hashtable[nr]);
 }
 
 /* get the inode from the (source) inode # */
@@ -991,11 +992,6 @@ static int erofs_fill_inode(struct erofs_inode *inode, struct stat *st,
        if (!inode->i_srcpath)
                return -ENOMEM;
 
-       if (!S_ISDIR(inode->i_mode)) {
-               inode->dev = st->st_dev;
-               inode->i_ino[1] = st->st_ino;
-       }
-
        if (erofs_should_use_inode_extended(inode)) {
                if (cfg.c_force_inodeversion == FORCE_INODE_COMPACT) {
                        erofs_err("file %s cannot be in compact form",
@@ -1007,7 +1003,9 @@ static int erofs_fill_inode(struct erofs_inode *inode, struct stat *st,
                inode->inode_isize = sizeof(struct erofs_inode_compact);
        }
 
-       erofs_insert_ihash(inode, st->st_dev, st->st_ino);
+       inode->dev = st->st_dev;
+       inode->i_ino[1] = st->st_ino;
+       erofs_insert_ihash(inode);
        return 0;
 }
 
index 806d8b2be81da977ab22cfe358e4eb9a61da3cc7..b9bced2fa6b11437b119d6165e3481cd49af8163 100644 (file)
@@ -346,7 +346,7 @@ static int erofs_rebuild_dirent_iter(struct erofs_dir_context *ctx)
                                goto out;
                        }
 
-                       erofs_insert_ihash(inode, inode->dev, inode->i_ino[1]);
+                       erofs_insert_ihash(inode);
                        parent = dir = inode;
                }