From: Gao Xiang <hsiangkao@linux.alibaba.com>
To: Zhan Xusheng <zhanxusheng1024@gmail.com>, Gao Xiang <xiang@kernel.org>
Cc: linux-erofs@lists.ozlabs.org, linux-kernel@vger.kernel.org,
Zhan Xusheng <zhanxusheng@xiaomi.com>
Subject: Re: [PATCH] erofs: handle 48-bit blocks/uniaddr for extra devices
Date: Fri, 3 Apr 2026 13:26:56 +0800 [thread overview]
Message-ID: <f54ce712-9d7b-488b-8dc2-9d5e2455f80c@linux.alibaba.com> (raw)
In-Reply-To: <20260403033409.70704-1-zhanxusheng@xiaomi.com>
On 2026/4/3 11:34, Zhan Xusheng wrote:
> erofs_init_device() only reads blocks_lo and uniaddr_lo from the
> on-disk device slot, ignoring blocks_hi and uniaddr_hi that were
> introduced alongside the 48-bit block addressing feature.
>
> For the primary device (dif0), erofs_read_superblock() already handles
> this correctly by combining blocks_lo with blocks_hi when 48-bit
> layout is enabled. But the same logic was not applied to extra
> devices.
>
> With a 48-bit EROFS image using extra devices whose uniaddr or blocks
> exceed 32-bit range, the truncated values cause erofs_map_dev() to
> compute wrong physical addresses, leading to silent data corruption.
>
> Fix this by reading blocks_hi and uniaddr_hi in erofs_init_device()
> when 48-bit layout is enabled, consistent with the primary device
> handling.
>
> Fixes: 61ba89b57905 ("erofs: add 48-bit block addressing on-disk support")
> Signed-off-by: Zhan Xusheng <zhanxusheng@xiaomi.com>
Yeah, it seems that part was never implemented,
but could you fix
__le32 blocks_hi; in `struct erofs_deviceslot` to `__le16` as well?
`blocks_hi` shouldn't be `__le32`.
> ---
> Note: erofs-utils also needs corresponding fixes for the write path
> (erofs_mkfs_format_devices) and a swapped hi/lo read in
> erofs_read_superblock, which will be sent separately.
> ---
> fs/erofs/super.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/fs/erofs/super.c b/fs/erofs/super.c
> index 972a0c82198d..a04e70ef4fcc 100644
> --- a/fs/erofs/super.c
> +++ b/fs/erofs/super.c
> @@ -177,6 +177,10 @@ static int erofs_init_device(struct erofs_buf *buf, struct super_block *sb,
>
> dif->blocks = le32_to_cpu(dis->blocks_lo);
> dif->uniaddr = le32_to_cpu(dis->uniaddr_lo);
> + if (erofs_sb_has_48bit(sbi)) {
> + dif->blocks |= (u64)le32_to_cpu(dis->blocks_hi) << 32;
> + dif->uniaddr |= (u64)le16_to_cpu(dis->uniaddr_hi) << 32;
> + }
Maybe just
bool _48bit = erofs_sb_has_48bit(sbi);
..
dif->blocks = le32_to_cpu(dis->blocks_lo) |
(_48bit ? (u64)le16_to_cpu(dis->blocks_hi) << 32 : 0);
dif->uniaddr = le32_to_cpu(dis->uniaddr_lo) |
(_48bit ? (u64)le16_to_cpu(dis->uniaddr_hi) << 32 : 0);
Thanks,
Gao Xiang
next prev parent reply other threads:[~2026-04-03 5:27 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-03 3:34 [PATCH] erofs: handle 48-bit blocks/uniaddr for extra devices Zhan Xusheng
2026-04-03 5:26 ` Gao Xiang [this message]
2026-04-03 6:36 ` [PATCH v2] " Zhan Xusheng
2026-04-03 8:27 ` Gao Xiang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f54ce712-9d7b-488b-8dc2-9d5e2455f80c@linux.alibaba.com \
--to=hsiangkao@linux.alibaba.com \
--cc=linux-erofs@lists.ozlabs.org \
--cc=linux-kernel@vger.kernel.org \
--cc=xiang@kernel.org \
--cc=zhanxusheng1024@gmail.com \
--cc=zhanxusheng@xiaomi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox