[PATCH v2 01/10] erofs-utils: simplify erofs_insert_ihash
Gao Xiang
hsiangkao at linux.alibaba.com
Tue Jun 18 18:24:06 AEST 2024
Get rid of unnecessary arguments for simplicity.
Signed-off-by: Gao Xiang <hsiangkao at linux.alibaba.com>
---
include/erofs/inode.h | 2 +-
lib/inode.c | 16 +++++++---------
lib/rebuild.c | 2 +-
3 files changed, 9 insertions(+), 11 deletions(-)
diff --git a/include/erofs/inode.h b/include/erofs/inode.h
index 3bdc2b4..557150c 100644
--- a/include/erofs/inode.h
+++ b/include/erofs/inode.h
@@ -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);
diff --git a/lib/inode.c b/lib/inode.c
index 1ec73fe..e27399d 100644
--- a/lib/inode.c
+++ b/lib/inode.c
@@ -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;
}
diff --git a/lib/rebuild.c b/lib/rebuild.c
index 806d8b2..b9bced2 100644
--- a/lib/rebuild.c
+++ b/lib/rebuild.c
@@ -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;
}
--
2.39.3
More information about the Linux-erofs
mailing list