erofs-utils: lib: capture errors from {mkfs,rebuild}_handle_inode()
authorHongzhen Luo <hongzhen@linux.alibaba.com>
Tue, 12 Nov 2024 02:08:30 +0000 (10:08 +0800)
committerGao Xiang <hsiangkao@linux.alibaba.com>
Tue, 12 Nov 2024 02:42:51 +0000 (10:42 +0800)
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@linux.alibaba.com>
Link: https://lore.kernel.org/r/20241112020830.849210-1-hongzhen@linux.alibaba.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
lib/inode.c

index 7abde7f4a3b5482afa9bdf7de7cde8a65629ad65..f553becb0be0fd590a9ca5cd865dd400b3c49e06 100644 (file)
@@ -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;