[PATCH] erofs-utils: fix incorrect i_nlink in the unified rebuild logic
Gao Xiang
hsiangkao at linux.alibaba.com
Thu Jun 13 12:37:06 AEST 2024
Fixes: 203c847cc7d1 ("erofs-utils: unify the tree traversal for the rebuild mode")
Closes: https://github.com/erofs/erofsnightly/actions/runs/9492427961/job/26159566596
Signed-off-by: Gao Xiang <hsiangkao at linux.alibaba.com>
---
lib/inode.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/lib/inode.c b/lib/inode.c
index 7d4ccc4..9219759 100644
--- a/lib/inode.c
+++ b/lib/inode.c
@@ -1386,7 +1386,7 @@ static int erofs_rebuild_handle_directory(struct erofs_inode *dir)
int ret;
nr_subdirs = 0;
- i_nlink = 2;
+ i_nlink = 0;
list_for_each_entry_safe(d, n, &dir->i_subdirs, d_child) {
if (cfg.c_ovlfs_strip && erofs_inode_is_whiteout(d->inode)) {
erofs_dbg("remove whiteout %s", d->inode->i_srcpath);
@@ -1399,6 +1399,8 @@ static int erofs_rebuild_handle_directory(struct erofs_inode *dir)
++nr_subdirs;
}
+ DBG_BUGON(i_nlink < 2); /* should have `.` and `..` */
+ DBG_BUGON(nr_subdirs < i_nlink);
ret = erofs_prepare_dir_layout(dir, nr_subdirs);
if (ret)
return ret;
--
2.39.3
More information about the Linux-erofs
mailing list