From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out30-132.freemail.mail.aliyun.com (out30-132.freemail.mail.aliyun.com [115.124.30.132]) (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 CCFC72BE7B6 for ; Fri, 3 Apr 2026 05:26:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.132 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775194024; cv=none; b=AtRtYIFEiUN9H1iI3WbmVmHtCclceYTZkBBVJMKKSxIKDcbVtNHxaLUMr+OOFqwmq4sGxYHnBFEbTRrxgakDRF04x7tMB1IDaw2rziCHQCmGnXxNGFoRARt+zVPEDyjm4YLGv2iKPa6xNs/K+1vnecOvoucb9L1pcOjlmAZl+Go= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775194024; c=relaxed/simple; bh=MjwjHGLDWbGOhjerP9SW8CgUUPgeJ4l2OE9+/ZvOrGs=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=obLLq6FDl2VasIXPA+3JScouYC+DKXYpZZ4kKrDkOBiq2QMnGpd/hnxWzjnmNSzLvmztg02xO1bS8dsoeihcA05K038u+9SJ4x0S11qb5xyjT1gGhEjVtzp+H7RxFneZZaAtmLSX35wkZk6D1QMqCIyB9QiWtFOBzy6HqZZGJE0= 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=yQPVzbS/; arc=none smtp.client-ip=115.124.30.132 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="yQPVzbS/" DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1775194017; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=8FXLUe5auZS0Plf2f8ZbXlDB0X1M0R90JJpBq7zD4bE=; b=yQPVzbS/SW5+o45PtRcnO21Fq2+f6THwlgon5O1DUgkmRiBdstRygL0wMGzbZrBBrwknz8XxMqA8Jnfo9fqHP6nwM8dR3RrXxH2JP/pqyvDkqpSv6bEHvFiDjeSss9kjkThCX/gzHfJ84JcoEM8hWe3Em2SCyxYPDrNf17Ki/CE= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R481e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033037033178;MF=hsiangkao@linux.alibaba.com;NM=1;PH=DS;RN=5;SR=0;TI=SMTPD_---0X0J9M6W_1775194016; Received: from 30.41.54.139(mailfrom:hsiangkao@linux.alibaba.com fp:SMTPD_---0X0J9M6W_1775194016 cluster:ay36) by smtp.aliyun-inc.com; Fri, 03 Apr 2026 13:26:57 +0800 Message-ID: Date: Fri, 3 Apr 2026 13:26:56 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] erofs: handle 48-bit blocks/uniaddr for extra devices To: Zhan Xusheng , Gao Xiang Cc: linux-erofs@lists.ozlabs.org, linux-kernel@vger.kernel.org, Zhan Xusheng References: <20260403033409.70704-1-zhanxusheng@xiaomi.com> From: Gao Xiang In-Reply-To: <20260403033409.70704-1-zhanxusheng@xiaomi.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 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