From nobody Sat Feb 7 11:05:16 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 64F78C77B7E for ; Thu, 1 Jun 2023 11:24:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232739AbjFALX6 (ORCPT ); Thu, 1 Jun 2023 07:23:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232252AbjFALXy (ORCPT ); Thu, 1 Jun 2023 07:23:54 -0400 Received: from out30-101.freemail.mail.aliyun.com (out30-101.freemail.mail.aliyun.com [115.124.30.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B4679123 for ; Thu, 1 Jun 2023 04:23:52 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R181e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046049;MF=hsiangkao@linux.alibaba.com;NM=1;PH=DS;RN=3;SR=0;TI=SMTPD_---0Vk5zEu._1685618622; Received: from e18g06460.et15sqa.tbsite.net(mailfrom:hsiangkao@linux.alibaba.com fp:SMTPD_---0Vk5zEu._1685618622) by smtp.aliyun-inc.com; Thu, 01 Jun 2023 19:23:50 +0800 From: Gao Xiang To: linux-erofs@lists.ozlabs.org Cc: LKML , Gao Xiang Subject: [PATCH] erofs: fix compact 4B support for 16k block size Date: Thu, 1 Jun 2023 19:23:41 +0800 Message-Id: <20230601112341.56960-1-hsiangkao@linux.alibaba.com> X-Mailer: git-send-email 2.24.4 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" In compact 4B, two adjacent lclusters are packed together as a unit to form on-disk indexes for effective random access, as below: (amortized =3D 4, vcnt =3D 2) _____________________________________________ |___@_____ encoded bits __________|_ blkaddr _| 0 . amortized * vcnt =3D 8 . . . . amortized * vcnt - 4 =3D 4 . . .____________________________. |_type (2 bits)_|_clusterofs_| Therefore, encoded bits for each pack are 32 bits (4 bytes). IOWs, since each lcluster can get 16 bits for its type and clusterofs, the maximum supported lclustersize for compact 4B format is 16k (14 bits). Fix this to enable compact 4B format for 16k lclusters (blocks), which is tested on an arm64 server with 16k page size. Fixes: 152a333a5895 ("staging: erofs: add compacted compression indexes sup= port") Signed-off-by: Gao Xiang --- fs/erofs/zmap.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/fs/erofs/zmap.c b/fs/erofs/zmap.c index d37c5c89c728..920fb4dbc731 100644 --- a/fs/erofs/zmap.c +++ b/fs/erofs/zmap.c @@ -129,7 +129,7 @@ static int unpack_compacted_index(struct z_erofs_maprec= order *m, u8 *in, type; bool big_pcluster; =20 - if (1 << amortizedshift =3D=3D 4) + if (1 << amortizedshift =3D=3D 4 && lclusterbits <=3D 14) vcnt =3D 2; else if (1 << amortizedshift =3D=3D 2 && lclusterbits =3D=3D 12) vcnt =3D 16; @@ -231,7 +231,6 @@ static int compacted_load_cluster_from_disk(struct z_er= ofs_maprecorder *m, { struct inode *const inode =3D m->inode; struct erofs_inode *const vi =3D EROFS_I(inode); - const unsigned int lclusterbits =3D vi->z_logical_clusterbits; const erofs_off_t ebase =3D sizeof(struct z_erofs_map_header) + ALIGN(erofs_iloc(inode) + vi->inode_isize + vi->xattr_isize, 8); unsigned int totalidx =3D erofs_iblks(inode); @@ -239,9 +238,6 @@ static int compacted_load_cluster_from_disk(struct z_er= ofs_maprecorder *m, unsigned int amortizedshift; erofs_off_t pos; =20 - if (lclusterbits !=3D 12) - return -EOPNOTSUPP; - if (lcn >=3D totalidx) return -EINVAL; =20 --=20 2.24.4