From nobody Sat Jun 20 04:58:54 2026 Received: from out30-112.freemail.mail.aliyun.com (out30-112.freemail.mail.aliyun.com [115.124.30.112]) (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 181BF38238A for ; Mon, 20 Apr 2026 10:11:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.112 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776679920; cv=none; b=mX4jQLYVFp9k821dTqTEJQIyzNtK4qojbKtT1rzlSr5uNNP7uioT89nZG2io6l6hrHBIoqG2DhS/NI8v1ihmU3Ze4fwe5QFAhvDuiV5QaUEKNkxff/oyVN5I9mMTbvvlf/40yxooag1IkNEwIC4rfeyX1adeIyoLrqWAoWhoFuw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776679920; c=relaxed/simple; bh=5XU1w0KxyDTnzlkr0NX785cKUQ8kxAEy38ATJUftumM=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=T5U5a9DaBUlgixIHlcoKYugK7ISgYKbGEQ4pkUIH+FBKVW3e/TbZ9b1bbaD3TvoGR/kqhcbDs8k9pzNtxB/x9tkb5Vq6bU18r4ZQveAVenfoEmqvWe/JQ91vn0ygQzFue90hsSm20JA93t2mfK6iAggigS+z5QFETxUTY1sNqIU= 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=MLKM7tf6; arc=none smtp.client-ip=115.124.30.112 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="MLKM7tf6" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1776679907; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=q1mLRfj46AfSk/H+1p54oLfcyRecT0auHAGSov+MSSk=; b=MLKM7tf6SO92OSYstWFihf6C2prAK7ZbPkcpmI9s/iDjETMG0WJRfVPo4F+zI9yKdy6Z+mH43/3hNcdwyEb6l8z+txd0Ku5ogaWZo4htJZ7/N5nQuU/7GGv5gw8ZWq/s6RiqAAbk5v2mb87bn5SweVbH9DLEMN34impRBNyHM74= X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R141e4;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=4;SR=0;TI=SMTPD_---0X1KSTIw_1776679903; Received: from x31i01179.sqa.na131.tbsite.net(mailfrom:hsiangkao@linux.alibaba.com fp:SMTPD_---0X1KSTIw_1776679903 cluster:ay36) by smtp.aliyun-inc.com; Mon, 20 Apr 2026 18:11:47 +0800 From: Gao Xiang To: linux-erofs@lists.ozlabs.org Cc: LKML , oliver.yang@linux.alibaba.com, Gao Xiang Subject: [PATCH] erofs: unify lcn as u64 for 32-bit platforms Date: Mon, 20 Apr 2026 18:11:42 +0800 Message-ID: <20260420101142.2440026-1-hsiangkao@linux.alibaba.com> X-Mailer: git-send-email 2.43.5 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" As sashiko reported [1], `lcn` was typed as `unsigned long` (or `unsigned int` sometimes), which is only 32 bits wide on 32-bit platforms, which causes `(lcn << lclusterbits)` to be truncated at 4 GiB. In order to consolidate the logic, just use `u64` consistently around the codebase. [1] https://sashiko.dev/r/20260420034612.1899973-1-hsiangkao%40linux.alibab= a.com Fixes: 152a333a5895 ("staging: erofs: add compacted compression indexes sup= port") Signed-off-by: Gao Xiang --- fs/erofs/zmap.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/fs/erofs/zmap.c b/fs/erofs/zmap.c index 30775502b56d..abf7ddc64c63 100644 --- a/fs/erofs/zmap.c +++ b/fs/erofs/zmap.c @@ -10,7 +10,7 @@ struct z_erofs_maprecorder { struct inode *inode; struct erofs_map_blocks *map; - unsigned long lcn; + u64 lcn; /* compression extent information gathered */ u8 type, headtype; u16 clusterofs; @@ -20,8 +20,7 @@ struct z_erofs_maprecorder { bool partialref, in_mbox; }; =20 -static int z_erofs_load_full_lcluster(struct z_erofs_maprecorder *m, - unsigned long lcn) +static int z_erofs_load_full_lcluster(struct z_erofs_maprecorder *m, u64 l= cn) { struct inode *const inode =3D m->inode; struct erofs_inode *const vi =3D EROFS_I(inode); @@ -94,7 +93,7 @@ static int get_compacted_la_distance(unsigned int lobits, } =20 static int z_erofs_load_compact_lcluster(struct z_erofs_maprecorder *m, - unsigned long lcn, bool lookahead) + u64 lcn, bool lookahead) { struct inode *const inode =3D m->inode; struct erofs_inode *const vi =3D EROFS_I(inode); @@ -234,7 +233,7 @@ static int z_erofs_load_compact_lcluster(struct z_erofs= _maprecorder *m, } =20 static int z_erofs_load_lcluster_from_disk(struct z_erofs_maprecorder *m, - unsigned int lcn, bool lookahead) + u64 lcn, bool lookahead) { struct erofs_inode *vi =3D EROFS_I(m->inode); int err; @@ -249,7 +248,7 @@ static int z_erofs_load_lcluster_from_disk(struct z_ero= fs_maprecorder *m, return err; =20 if (m->type >=3D Z_EROFS_LCLUSTER_TYPE_MAX) { - erofs_err(m->inode->i_sb, "unknown type %u @ lcn %u of nid %llu", + erofs_err(m->inode->i_sb, "unknown type %u @ lcn %llu of nid %llu", m->type, lcn, EROFS_I(m->inode)->nid); DBG_BUGON(1); return -EOPNOTSUPP; @@ -269,7 +268,7 @@ static int z_erofs_extent_lookback(struct z_erofs_mapre= corder *m, const unsigned int lclusterbits =3D vi->z_lclusterbits; =20 while (m->lcn >=3D lookback_distance) { - unsigned long lcn =3D m->lcn - lookback_distance; + u64 lcn =3D m->lcn - lookback_distance; int err; =20 if (!lookback_distance) @@ -286,7 +285,7 @@ static int z_erofs_extent_lookback(struct z_erofs_mapre= corder *m, m->map->m_la =3D (lcn << lclusterbits) | m->clusterofs; return 0; } - erofs_err(sb, "bogus lookback distance %u @ lcn %lu of nid %llu", + erofs_err(sb, "bogus lookback distance %u @ lcn %llu of nid %llu", lookback_distance, m->lcn, vi->nid); DBG_BUGON(1); return -EFSCORRUPTED; @@ -300,7 +299,7 @@ static int z_erofs_get_extent_compressedlen(struct z_er= ofs_maprecorder *m, struct erofs_inode *vi =3D EROFS_I(inode); bool bigpcl1 =3D vi->z_advise & Z_EROFS_ADVISE_BIG_PCLUSTER_1; bool bigpcl2 =3D vi->z_advise & Z_EROFS_ADVISE_BIG_PCLUSTER_2; - unsigned long lcn =3D m->lcn + 1; + u64 lcn =3D m->lcn + 1; int err; =20 DBG_BUGON(m->type =3D=3D Z_EROFS_LCLUSTER_TYPE_NONHEAD); @@ -331,7 +330,7 @@ static int z_erofs_get_extent_compressedlen(struct z_er= ofs_maprecorder *m, m->type =3D=3D Z_EROFS_LCLUSTER_TYPE_NONHEAD); =20 if (m->type =3D=3D Z_EROFS_LCLUSTER_TYPE_NONHEAD && m->delta[0] !=3D 1) { - erofs_err(sb, "bogus CBLKCNT @ lcn %lu of nid %llu", lcn, vi->nid); + erofs_err(sb, "bogus CBLKCNT @ lcn %llu of nid %llu", lcn, vi->nid); DBG_BUGON(1); return -EFSCORRUPTED; } --=20 2.43.5