[PATCH v2 04/10] erofs-utils: get rid of NULL_ADDR{,_UL}
Gao Xiang
hsiangkao at linux.alibaba.com
Thu Apr 10 02:32:53 AEST 2025
.. And replace them with EROFS_NULL_ADDR.
Signed-off-by: Gao Xiang <hsiangkao at linux.alibaba.com>
---
include/erofs/cache.h | 4 ++--
include/erofs/internal.h | 3 ---
lib/cache.c | 24 ++++++++++++------------
lib/inode.c | 2 +-
lib/rebuild.c | 2 +-
5 files changed, 16 insertions(+), 19 deletions(-)
diff --git a/include/erofs/cache.h b/include/erofs/cache.h
index 87d743a..0c665e8 100644
--- a/include/erofs/cache.h
+++ b/include/erofs/cache.h
@@ -107,8 +107,8 @@ static inline erofs_off_t erofs_btell(struct erofs_buffer_head *bh, bool end)
struct erofs_bufmgr *bmgr =
(struct erofs_bufmgr *)bb->buffers.fsprivate;
- if (bb->blkaddr == NULL_ADDR)
- return NULL_ADDR_UL;
+ if (bb->blkaddr == EROFS_NULL_ADDR)
+ return EROFS_NULL_ADDR;
return erofs_pos(bmgr->sbi, bb->blkaddr) +
(end ? list_next_entry(bh, list)->off : bh->off);
diff --git a/include/erofs/internal.h b/include/erofs/internal.h
index 36df13a..244aa82 100644
--- a/include/erofs/internal.h
+++ b/include/erofs/internal.h
@@ -44,9 +44,6 @@ typedef u64 erofs_nid_t;
/* data type for filesystem-wide blocks number */
typedef u32 erofs_blk_t;
-#define NULL_ADDR ((unsigned int)-1)
-#define NULL_ADDR_UL ((unsigned long)-1)
-
/* global sbi */
extern struct erofs_sb_info g_sbi;
diff --git a/lib/cache.c b/lib/cache.c
index eddf21f..b91a288 100644
--- a/lib/cache.c
+++ b/lib/cache.c
@@ -49,7 +49,7 @@ struct erofs_bufmgr *erofs_buffer_init(struct erofs_sb_info *sbi,
}
}
init_list_head(&bmgr->blkh.list);
- bmgr->blkh.blkaddr = NULL_ADDR;
+ bmgr->blkh.blkaddr = EROFS_NULL_ADDR;
bmgr->tail_blkaddr = startblk;
bmgr->last_mapped_block = &bmgr->blkh;
bmgr->dsunit = 0;
@@ -79,7 +79,7 @@ static void erofs_update_bwatermeter(struct erofs_buffer_block *bb, bool free)
struct erofs_bufmgr *bmgr = bb->buffers.fsprivate;
struct erofs_sb_info *sbi = bmgr->sbi;
unsigned int blksiz = erofs_blksiz(sbi);
- bool mapped = bb->blkaddr != NULL_ADDR;
+ bool mapped = bb->blkaddr != EROFS_NULL_ADDR;
struct list_head *h = bmgr->watermeter[bb->type][mapped];
unsigned int nr;
@@ -127,12 +127,12 @@ static int __erofs_battach(struct erofs_buffer_block *bb,
oob = cmpsgn(alignedoffset + incr + inline_ext,
bb->buffers.nblocks << sbi->blkszbits);
if (oob >= 0) {
- /* the next buffer block should be NULL_ADDR all the time */
- if (oob && list_next_entry(bb, list)->blkaddr != NULL_ADDR)
+ /* the next buffer block should be EROFS_NULL_ADDR all the time */
+ if (oob && list_next_entry(bb, list)->blkaddr != EROFS_NULL_ADDR)
return -EINVAL;
blkaddr = bb->blkaddr;
- if (blkaddr != NULL_ADDR) {
+ if (blkaddr != EROFS_NULL_ADDR) {
tailupdate = (bmgr->tail_blkaddr == blkaddr +
bb->buffers.nblocks);
if (oob && !tailupdate)
@@ -244,7 +244,7 @@ static int erofs_bfind_for_attach(struct erofs_bufmgr *bmgr,
/* skip the last mapped block */
if (mapped &&
- list_next_entry(cur, list)->blkaddr == NULL_ADDR) {
+ list_next_entry(cur, list)->blkaddr == EROFS_NULL_ADDR) {
DBG_BUGON(cur != bmgr->last_mapped_block);
cur = list_next_entry(cur, sibling);
if (&cur->sibling == bt)
@@ -252,7 +252,7 @@ static int erofs_bfind_for_attach(struct erofs_bufmgr *bmgr,
}
DBG_BUGON(cur->type != type);
- DBG_BUGON((cur->blkaddr != NULL_ADDR) ^ mapped);
+ DBG_BUGON((cur->blkaddr != EROFS_NULL_ADDR) ^ mapped);
DBG_BUGON(used != (cur->buffers.off & blkmask));
ret = __erofs_battach(cur, NULL, size, alignsize,
@@ -327,7 +327,7 @@ struct erofs_buffer_head *erofs_balloc(struct erofs_bufmgr *bmgr,
return ERR_PTR(-ENOMEM);
bb->type = type;
- bb->blkaddr = NULL_ADDR;
+ bb->blkaddr = EROFS_NULL_ADDR;
bb->buffers.off = 0;
bb->buffers.nblocks = 0;
bb->buffers.fsprivate = bmgr;
@@ -388,7 +388,7 @@ static void __erofs_mapbh(struct erofs_buffer_block *bb)
struct erofs_bufmgr *bmgr = bb->buffers.fsprivate;
erofs_blk_t blkaddr = bmgr->tail_blkaddr;
- if (bb->blkaddr == NULL_ADDR) {
+ if (bb->blkaddr == EROFS_NULL_ADDR) {
bb->blkaddr = blkaddr;
if (__erofs_unlikely(bmgr->dsunit > 1) && bb->type == DATA) {
struct erofs_buffer_block *pb = list_prev_entry(bb, list);
@@ -418,14 +418,14 @@ erofs_blk_t erofs_mapbh(struct erofs_bufmgr *bmgr,
bmgr = bb->buffers.fsprivate;
t = bmgr->last_mapped_block;
- if (bb && bb->blkaddr != NULL_ADDR)
+ if (bb && bb->blkaddr != EROFS_NULL_ADDR)
return bb->blkaddr;
do {
t = list_next_entry(t, list);
if (t == &bmgr->blkh)
break;
- DBG_BUGON(t->blkaddr != NULL_ADDR);
+ DBG_BUGON(t->blkaddr != EROFS_NULL_ADDR);
__erofs_mapbh(t);
} while (t != bb);
return bmgr->tail_blkaddr;
@@ -501,7 +501,7 @@ void erofs_bdrop(struct erofs_buffer_head *bh, bool tryrevoke)
bool rollback = false;
/* tail_blkaddr could be rolled back after revoking all bhs */
- if (tryrevoke && blkaddr != NULL_ADDR &&
+ if (tryrevoke && blkaddr != EROFS_NULL_ADDR &&
bmgr->tail_blkaddr == blkaddr + bb->buffers.nblocks)
rollback = true;
diff --git a/lib/inode.c b/lib/inode.c
index 7a10624..f99cbb0 100644
--- a/lib/inode.c
+++ b/lib/inode.c
@@ -189,7 +189,7 @@ int erofs_allocate_inode_bh_data(struct erofs_inode *inode, erofs_blk_t nblocks)
if (!nblocks) {
/* it has only tail-end data */
- inode->u.i_blkaddr = NULL_ADDR;
+ inode->u.i_blkaddr = EROFS_NULL_ADDR;
return 0;
}
diff --git a/lib/rebuild.c b/lib/rebuild.c
index 5787bb3..8892d11 100644
--- a/lib/rebuild.c
+++ b/lib/rebuild.c
@@ -249,7 +249,7 @@ static int erofs_rebuild_update_inode(struct erofs_sb_info *dst_sb,
break;
case S_IFREG:
if (!inode->i_size) {
- inode->u.i_blkaddr = NULL_ADDR;
+ inode->u.i_blkaddr = EROFS_NULL_ADDR;
break;
}
if (datamode == EROFS_REBUILD_DATA_BLOB_INDEX)
--
2.43.5
More information about the Linux-erofs
mailing list