[WIP] [PATCH v3 06/12] erofs-utils: fuse: kill nid2addr, addr2nid

Gao Xiang hsiangkao at aol.com
Tue Nov 3 02:55:52 AEDT 2020


(will fold into the original patch.)

Signed-off-by: Gao Xiang <hsiangkao at aol.com>
---
 fuse/init.c   | 15 ---------------
 fuse/init.h   |  2 --
 fuse/namei.c  |  4 ++--
 fuse/readir.c |  2 +-
 fuse/zmap.c   |  6 +++---
 5 files changed, 6 insertions(+), 23 deletions(-)

diff --git a/fuse/init.c b/fuse/init.c
index f3f7f9750468..b4089a204409 100644
--- a/fuse/init.c
+++ b/fuse/init.c
@@ -88,21 +88,6 @@ erofs_nid_t erofs_get_root_nid(void)
 	return sbi.root_nid;
 }
 
-erofs_nid_t addr2nid(erofs_off_t addr)
-{
-	erofs_nid_t offset = (erofs_nid_t)sbi.meta_blkaddr * EROFS_BLKSIZ;
-
-	DBG_BUGON(!IS_SLOT_ALIGN(addr));
-	return (addr - offset) >> EROFS_ISLOTBITS;
-}
-
-erofs_off_t nid2addr(erofs_nid_t nid)
-{
-	erofs_off_t offset = (erofs_off_t)sbi.meta_blkaddr * EROFS_BLKSIZ;
-
-	return (nid <<  EROFS_ISLOTBITS) + offset;
-}
-
 void *erofs_init(struct fuse_conn_info *info)
 {
 	erofs_info("Using FUSE protocol %d.%d", info->proto_major, info->proto_minor);
diff --git a/fuse/init.h b/fuse/init.h
index 062cd69f6e4d..4bd48d18b003 100644
--- a/fuse/init.h
+++ b/fuse/init.h
@@ -15,8 +15,6 @@
 
 int erofs_read_superblock(void);
 erofs_nid_t erofs_get_root_nid(void);
-erofs_off_t nid2addr(erofs_nid_t nid);
-erofs_nid_t addr2nid(erofs_off_t addr);
 void *erofs_init(struct fuse_conn_info *info);
 
 #endif
diff --git a/fuse/namei.c b/fuse/namei.c
index 79273f89be1b..c3766f9a9f02 100644
--- a/fuse/namei.c
+++ b/fuse/namei.c
@@ -52,7 +52,7 @@ int erofs_iget_by_nid(erofs_nid_t nid, struct erofs_vnode *vi)
 	int ret, ifmt;
 	char buf[EROFS_BLKSIZ];
 	struct erofs_inode_compact *v1;
-	const erofs_off_t addr = nid2addr(nid);
+	const erofs_off_t addr = iloc(nid);
 	const size_t size = EROFS_BLKSIZ - erofs_blkoff(addr);
 
 	ret = dev_read(buf, addr, size);
@@ -173,7 +173,7 @@ struct dcache_entry *disk_lookup(struct dcache_entry *parent, const char *name,
 
 	if (v.datalayout == EROFS_INODE_FLAT_INLINE) {
 		uint32_t dir_off = erofs_blkoff(dirsize);
-		off_t dir_addr = nid2addr(dcache_get_nid(parent)) +
+		off_t dir_addr = iloc(dcache_get_nid(parent)) +
 			v.inode_isize + v.xattr_isize;
 
 		memset(buf, 0, sizeof(buf));
diff --git a/fuse/readir.c b/fuse/readir.c
index 8111047803df..496f4e73a9c2 100644
--- a/fuse/readir.c
+++ b/fuse/readir.c
@@ -108,7 +108,7 @@ int erofs_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
 	if (v.datalayout == EROFS_INODE_FLAT_INLINE) {
 		off_t addr;
 
-		addr = nid2addr(nid) + v.inode_isize + v.xattr_isize;
+		addr = iloc(nid) + v.inode_isize + v.xattr_isize;
 
 		memset(dirsbuf, 0, sizeof(dirsbuf));
 		ret = dev_read(dirsbuf, addr, dir_off);
diff --git a/fuse/zmap.c b/fuse/zmap.c
index 9860b770362c..cb667da4e0c8 100644
--- a/fuse/zmap.c
+++ b/fuse/zmap.c
@@ -40,7 +40,7 @@ static int z_erofs_fill_inode_lazy(struct erofs_vnode *vi)
 
 	DBG_BUGON(vi->datalayout == EROFS_INODE_FLAT_COMPRESSION_LEGACY);
 
-	pos = round_up(nid2addr(vi->nid) + vi->inode_isize + vi->xattr_isize, 8);
+	pos = round_up(iloc(vi->nid) + vi->inode_isize + vi->xattr_isize, 8);
 
 	ret = dev_read(buf, pos, 8);
 	if (ret < 0)
@@ -110,7 +110,7 @@ static int legacy_load_cluster_from_disk(struct z_erofs_maprecorder *m,
 					 unsigned long lcn)
 {
 	struct erofs_vnode *const vi = m->vnode;
-	const erofs_off_t ibase = nid2addr(vi->nid);
+	const erofs_off_t ibase = iloc(vi->nid);
 	const erofs_off_t pos =
 		Z_EROFS_VLE_LEGACY_INDEX_ALIGN(ibase + vi->inode_isize +
 					       vi->xattr_isize) +
@@ -228,7 +228,7 @@ static int compacted_load_cluster_from_disk(struct z_erofs_maprecorder *m,
 {
 	struct erofs_vnode *const vi = m->vnode;
 	const unsigned int lclusterbits = vi->z_logical_clusterbits;
-	const erofs_off_t ebase = round_up(nid2addr(vi->nid) + vi->inode_isize +
+	const erofs_off_t ebase = round_up(iloc(vi->nid) + vi->inode_isize +
 					   vi->xattr_isize, 8) +
 		sizeof(struct z_erofs_map_header);
 	const unsigned int totalidx = DIV_ROUND_UP(vi->i_size, EROFS_BLKSIZ);
-- 
2.24.0



More information about the Linux-erofs mailing list