[PATCH v2] erofs-utils: lib: capture errors from {mkfs,rebuild}_handle_inode()

Hongzhen Luo hongzhen at linux.alibaba.com
Tue Nov 12 13:08:30 AEDT 2024


Currently, the error code returned by erofs_{mkfs,rebuild}_handle_inode()
in erofs_mkfs_dump_tree() may be ignored. This patch introduces `err2` to
capture errors from {mkfs,rebuild}_handle_inode().

Signed-off-by: Hongzhen Luo <hongzhen at linux.alibaba.com>
---
v2: Clean up the patch and revise the commit message.
v1: https://lore.kernel.org/all/20241111110926.3909753-1-hongzhen@linux.alibaba.com/
---
 lib/inode.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/lib/inode.c b/lib/inode.c
index 7abde7f4a3b5..f553becb0be0 100644
--- a/lib/inode.c
+++ b/lib/inode.c
@@ -1706,7 +1706,7 @@ static int erofs_mkfs_dump_tree(struct erofs_inode *root, bool rebuild,
 {
 	struct erofs_sb_info *sbi = root->sbi;
 	struct erofs_inode *dumpdir = erofs_igrab(root);
-	int err;
+	int err, err2;
 
 	erofs_mark_parent_inode(root, root);	/* rootdir mark */
 	root->next_dirwrite = NULL;
@@ -1733,7 +1733,6 @@ static int erofs_mkfs_dump_tree(struct erofs_inode *root, bool rebuild,
 	}
 
 	do {
-		int err;
 		struct erofs_inode *dir = dumpdir;
 		/* used for adding sub-directories in reverse order due to FIFO */
 		struct erofs_inode *head, **last = &head;
@@ -1770,10 +1769,10 @@ static int erofs_mkfs_dump_tree(struct erofs_inode *root, bool rebuild,
 		}
 		*last = dumpdir;	/* fixup the last (or the only) one */
 		dumpdir = head;
-		err = erofs_mkfs_go(sbi, EROFS_MKFS_JOB_DIR_BH,
+		err2 = erofs_mkfs_go(sbi, EROFS_MKFS_JOB_DIR_BH,
 				    &dir, sizeof(dir));
-		if (err)
-			return err;
+		if (err || err2)
+			return err ? err : err2;
 	} while (dumpdir);
 
 	return err;
-- 
2.43.5



More information about the Linux-erofs mailing list