public inbox for linux-erofs@ozlabs.org
 help / color / mirror / Atom feed
From: Zhan Xusheng <zhanxusheng1024@gmail.com>
To: Gao Xiang <hsiangkao@linux.alibaba.com>
Cc: linux-erofs@lists.ozlabs.org, Zhan Xusheng <zhanxusheng@xiaomi.com>
Subject: [PATCH erofs-utils v2 1/2] erofs-utils: fix swapped hi/lo in 48-bit primary blocks read
Date: Fri,  3 Apr 2026 21:05:45 +0800	[thread overview]
Message-ID: <20260403130546.76579-2-zhanxusheng@xiaomi.com> (raw)
In-Reply-To: <20260403130546.76579-1-zhanxusheng@xiaomi.com>

erofs_read_superblock() combines the 48-bit primary device block count as:
    (primarydevice_blocks << 32) | blocks_hi

This places blocks_lo in the upper 32 bits and blocks_hi in the lower
16 bits, which is reversed.  The correct combination is:
      primarydevice_blocks | ((u64)blocks_hi << 32)

This is the same bug that was fixed in the Linux kernel by commit
0b96d9bed324 ("erofs: fix block count report when 48-bit layout is
on").  Apply the equivalent fix to erofs-utils.

Fixes: f5b492b27e53 ("erofs-utils: add 48-bit block addressing support")
Signed-off-by: Zhan Xusheng <zhanxusheng@xiaomi.com>
---
 lib/super.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/super.c b/lib/super.c
index 088c9a0..86d50a1 100644
--- a/lib/super.c
+++ b/lib/super.c
@@ -122,8 +122,8 @@ int erofs_read_superblock(struct erofs_sb_info *sbi)
 	sbi->xattr_prefix_count = dsb->xattr_prefix_count;
 	if (erofs_sb_has_48bit(sbi) && dsb->rootnid_8b) {
 		sbi->root_nid = le64_to_cpu(dsb->rootnid_8b);
-		sbi->primarydevice_blocks = (sbi->primarydevice_blocks << 32) |
-				le16_to_cpu(dsb->rb.blocks_hi);
+		sbi->primarydevice_blocks = sbi->primarydevice_blocks |
+				((u64)le16_to_cpu(dsb->rb.blocks_hi) << 32);
 	} else {
 		sbi->root_nid = le16_to_cpu(dsb->rb.rootnid_2b);
 	}
-- 
2.43.0



  reply	other threads:[~2026-04-03 13:06 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <12b129db-0206-44f3-a53c-9eec6fe3fda3@linux.alibaba.com>
2026-04-03 13:05 ` [PATCH erofs-utils v2 0/2] Fix 48-bit block addressing for extra devices Zhan Xusheng
2026-04-03 13:05   ` Zhan Xusheng [this message]
2026-04-07  7:47     ` [PATCH erofs-utils v2 1/2] erofs-utils: fix swapped hi/lo in 48-bit primary blocks read Gao Xiang
2026-04-07  8:25       ` Zhan Xusheng
2026-04-03 13:05   ` [PATCH erofs-utils v2 2/2] erofs-utils: handle 48-bit blocks/uniaddr for extra devices Zhan Xusheng
2026-04-07  3:22     ` Gao Xiang
2026-04-07  3:41       ` Zhan Xusheng

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=20260403130546.76579-2-zhanxusheng@xiaomi.com \
    --to=zhanxusheng1024@gmail.com \
    --cc=hsiangkao@linux.alibaba.com \
    --cc=linux-erofs@lists.ozlabs.org \
    --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