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

Gao Xiang hsiangkao at linux.alibaba.com
Tue Nov 12 12:10:53 AEDT 2024



On 2024/11/11 19:09, Hongzhen Luo wrote:
> Currently, the error code returned by erofs_{mkfs,rebuild}_handle_inode()
> in erofs_mkfs_dump_tree() may be ignored. This patch introduces `err1` and
> `err2` to capture errors from the {mkfs,rebuild}_handle_inode() functions.
> 
> Signed-off-by: Hongzhen Luo <hongzhen at linux.alibaba.com>
> ---
>   lib/inode.c | 14 +++++++-------
>   1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/lib/inode.c b/lib/inode.c
> index 7abde7f4a3b5..e2ca07f1c18c 100644
> --- a/lib/inode.c
> +++ b/lib/inode.c
> @@ -1733,7 +1733,7 @@ static int erofs_mkfs_dump_tree(struct erofs_inode *root, bool rebuild,

add `int err, err2` here.

>   	}
>   
>   	do {
> -		int err;
> +		int err1, err2;

here the original `int err` is redundant.

>   		struct erofs_inode *dir = dumpdir;
>   		/* used for adding sub-directories in reverse order due to FIFO */
>   		struct erofs_inode *head, **last = &head;
> @@ -1753,11 +1753,11 @@ static int erofs_mkfs_dump_tree(struct erofs_inode *root, bool rebuild,
>   				erofs_mark_parent_inode(inode, dir);
>   
>   				if (!rebuild)
> -					err = erofs_mkfs_handle_inode(inode);
> +					err1 = erofs_mkfs_handle_inode(inode);
>   				else
> -					err = erofs_rebuild_handle_inode(inode,
> +					err1 = erofs_rebuild_handle_inode(inode,
>   								incremental);
> -				if (err)
> +				if (err1)
>   					break;

no need to change this.

>   				if (S_ISDIR(inode->i_mode)) {
>   					*last = inode;
> @@ -1770,10 +1770,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));
		err2 = ...

> -		if (err)
> -			return err;
> +		if (err1 || err2)
> +			return err1 ? err1 : err2;

		if (err || err2)
			return err ? err : err2;
>   	} while (dumpdir);
>   
>   	return err;



More information about the Linux-erofs mailing list