From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out30-119.freemail.mail.aliyun.com (out30-119.freemail.mail.aliyun.com [115.124.30.119]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B7C573242D5 for ; Thu, 27 Nov 2025 07:31:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.119 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764228701; cv=none; b=nhH3d2MUseoHQ7Xn3I8YJpzOCDVv1IwHN1sd8whgpwhImJnuD6NMq/YW6KeDkD3H0B0GILtAF/IVsCM2GXhsMhzxlrlKJhaDHGY4983pm2otGY67H6Cv1JfO3HnP3E8BVzcrz6xkYRITqbtqCl/vL7mNzHKbVliNySjkG3e2sPc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764228701; c=relaxed/simple; bh=jiKWU8iwjGfbLYxUPrMYpB9uprcxKRWaE5gLasyArkE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KX4vwF4px7fDjRC/dYZfAh00/qKmDqSu2l/w9HXqQPD9/kE/pLjz2pbzOw+cOSd9yQKy2bL0qAk1XcIG/DBdoskmYbrHOaeHpGoQbYe1Y6TX7UQlsysS7dW4YGK71RAgwvcln9yRU8Bl52mXaYNpIMlbKI9ar4KNz96AzTzJRL0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=YgypE7vA; arc=none smtp.client-ip=115.124.30.119 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="YgypE7vA" DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1764228690; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=mnm/SyF5+AnakOhGEYOeFuZGqAHAdF95wHRRpNISF90=; b=YgypE7vAuxm3p6IHlYEVXvWzygWBsgnzVVZtTAeJSqkLyHFYiRa+cURlp+kn6eb26FqYMvtwr39m9gz17T+bM7E0Xr3QEaUFz4O/jA8dFkeB8YsQRg6EK+XDtNwPrKnCqUS+GUPv6U5i2pkWhhvt2R2JHNgZpqvDLHo4/L54hf4= Received: from x31i01179.sqa.na131.tbsite.net(mailfrom:hsiangkao@linux.alibaba.com fp:SMTPD_---0WtWGgGK_1764228689 cluster:ay36) by smtp.aliyun-inc.com; Thu, 27 Nov 2025 15:31:29 +0800 From: Gao Xiang To: linux-erofs@lists.ozlabs.org Cc: LKML , Gao Xiang Subject: [PATCH 3/4] erofs: enable error reporting for z_erofs_stream_switch_bufs() Date: Thu, 27 Nov 2025 15:31:21 +0800 Message-ID: <20251127073122.2542542-3-hsiangkao@linux.alibaba.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20251127073122.2542542-1-hsiangkao@linux.alibaba.com> References: <20251127073122.2542542-1-hsiangkao@linux.alibaba.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Enable propagation of detailed errors to callers. Signed-off-by: Gao Xiang --- fs/erofs/compress.h | 4 ++-- fs/erofs/decompressor.c | 23 +++++++++-------------- fs/erofs/decompressor_deflate.c | 4 ++-- fs/erofs/decompressor_lzma.c | 6 +++--- fs/erofs/decompressor_zstd.c | 4 ++-- 5 files changed, 18 insertions(+), 23 deletions(-) diff --git a/fs/erofs/compress.h b/fs/erofs/compress.h index 1ee4ad934c1f..91dbc8bb5ddf 100644 --- a/fs/erofs/compress.h +++ b/fs/erofs/compress.h @@ -70,8 +70,8 @@ struct z_erofs_stream_dctx { bool bounced; /* is the bounce buffer used now? */ }; -int z_erofs_stream_switch_bufs(struct z_erofs_stream_dctx *dctx, void **dst, - void **src, struct page **pgpl); +const char *z_erofs_stream_switch_bufs(struct z_erofs_stream_dctx *dctx, + void **dst, void **src, struct page **pgpl); int z_erofs_fixup_insize(struct z_erofs_decompress_req *rq, const char *padbuf, unsigned int padbufsize); int __init z_erofs_init_decompressor(void); diff --git a/fs/erofs/decompressor.c b/fs/erofs/decompressor.c index f9d29f43666f..638b5f87bd0c 100644 --- a/fs/erofs/decompressor.c +++ b/fs/erofs/decompressor.c @@ -342,19 +342,16 @@ static const char *z_erofs_transform_plain(struct z_erofs_decompress_req *rq, return NULL; } -int z_erofs_stream_switch_bufs(struct z_erofs_stream_dctx *dctx, void **dst, - void **src, struct page **pgpl) +const char *z_erofs_stream_switch_bufs(struct z_erofs_stream_dctx *dctx, + void **dst, void **src, struct page **pgpl) { struct z_erofs_decompress_req *rq = dctx->rq; - struct super_block *sb = rq->sb; struct page **pgo, *tmppage; unsigned int j; if (!dctx->avail_out) { - if (++dctx->no >= rq->outpages || !rq->outputsize) { - erofs_err(sb, "insufficient space for decompressed data"); - return -EFSCORRUPTED; - } + if (++dctx->no >= rq->outpages || !rq->outputsize) + return "insufficient space for decompressed data"; if (dctx->kout) kunmap_local(dctx->kout); @@ -365,7 +362,7 @@ int z_erofs_stream_switch_bufs(struct z_erofs_stream_dctx *dctx, void **dst, *pgo = erofs_allocpage(pgpl, rq->gfp); if (!*pgo) { dctx->kout = NULL; - return -ENOMEM; + return ERR_PTR(-ENOMEM); } set_page_private(*pgo, Z_EROFS_SHORTLIVED_PAGE); } @@ -379,10 +376,8 @@ int z_erofs_stream_switch_bufs(struct z_erofs_stream_dctx *dctx, void **dst, } if (dctx->inbuf_pos == dctx->inbuf_sz && rq->inputsize) { - if (++dctx->ni >= rq->inpages) { - erofs_err(sb, "invalid compressed data"); - return -EFSCORRUPTED; - } + if (++dctx->ni >= rq->inpages) + return "invalid compressed data"; if (dctx->kout) /* unlike kmap(), take care of the orders */ kunmap_local(dctx->kout); kunmap_local(dctx->kin); @@ -417,12 +412,12 @@ int z_erofs_stream_switch_bufs(struct z_erofs_stream_dctx *dctx, void **dst, continue; tmppage = erofs_allocpage(pgpl, rq->gfp); if (!tmppage) - return -ENOMEM; + return ERR_PTR(-ENOMEM); set_page_private(tmppage, Z_EROFS_SHORTLIVED_PAGE); copy_highpage(tmppage, rq->in[j]); rq->in[j] = tmppage; } - return 0; + return NULL; } const struct z_erofs_decompressor *z_erofs_decomp[] = { diff --git a/fs/erofs/decompressor_deflate.c b/fs/erofs/decompressor_deflate.c index 46cc1fd19bce..afc73abd8db5 100644 --- a/fs/erofs/decompressor_deflate.c +++ b/fs/erofs/decompressor_deflate.c @@ -144,10 +144,10 @@ static const char *__z_erofs_deflate_decompress(struct z_erofs_decompress_req *r while (1) { dctx.avail_out = strm->z.avail_out; dctx.inbuf_sz = strm->z.avail_in; - err = z_erofs_stream_switch_bufs(&dctx, + reason = z_erofs_stream_switch_bufs(&dctx, (void **)&strm->z.next_out, (void **)&strm->z.next_in, pgpl); - if (err) + if (reason) break; strm->z.avail_out = dctx.avail_out; strm->z.avail_in = dctx.inbuf_sz; diff --git a/fs/erofs/decompressor_lzma.c b/fs/erofs/decompressor_lzma.c index 98a8c22cdbde..0161f3375efd 100644 --- a/fs/erofs/decompressor_lzma.c +++ b/fs/erofs/decompressor_lzma.c @@ -189,9 +189,9 @@ static const char *z_erofs_lzma_decompress(struct z_erofs_decompress_req *rq, dctx.avail_out = buf.out_size - buf.out_pos; dctx.inbuf_sz = buf.in_size; dctx.inbuf_pos = buf.in_pos; - err = z_erofs_stream_switch_bufs(&dctx, (void **)&buf.out, - (void **)&buf.in, pgpl); - if (err) + reason = z_erofs_stream_switch_bufs(&dctx, (void **)&buf.out, + (void **)&buf.in, pgpl); + if (reason) break; if (buf.out_size == buf.out_pos) { diff --git a/fs/erofs/decompressor_zstd.c b/fs/erofs/decompressor_zstd.c index aff6825cacde..ae51faeb504d 100644 --- a/fs/erofs/decompressor_zstd.c +++ b/fs/erofs/decompressor_zstd.c @@ -175,9 +175,9 @@ static const char *z_erofs_zstd_decompress(struct z_erofs_decompress_req *rq, do { dctx.inbuf_sz = in_buf.size; dctx.inbuf_pos = in_buf.pos; - err = z_erofs_stream_switch_bufs(&dctx, &out_buf.dst, + reason = z_erofs_stream_switch_bufs(&dctx, &out_buf.dst, (void **)&in_buf.src, pgpl); - if (err) + if (reason) break; if (out_buf.size == out_buf.pos) { -- 2.43.5