Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1455887rwb; Fri, 12 Aug 2022 00:53:40 -0700 (PDT) X-Google-Smtp-Source: AA6agR6JYMOT8/mK8o9i1btzNSuYNNOB0/T+QqgzMhfHAtLdXpzbQOsPrTVNX3QBp+zMYGBM6XbD X-Received: by 2002:a17:90a:3c87:b0:1f8:b8d4:8ab7 with SMTP id g7-20020a17090a3c8700b001f8b8d48ab7mr3913925pjc.188.1660290820604; Fri, 12 Aug 2022 00:53:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660290820; cv=none; d=google.com; s=arc-20160816; b=tkJHQJ1JwwiTtEAF2nNpKIARd/nhfcsCvDWmK6jbXNxiBLhlZmQHEDIp8wZoT/EEbv 8XDSlw2w5lNM+HNbrH17Zu1QUhdBYRh/uZ53z20cjTR7xBeC/vpdbKjWpMiABiuJvae5 qYexD3F16S2r9wDk6U/iMaW2aFB3NZ6dYJC8GsvhmsmNm0sQuhRUEwqzIHVcDNMhqqHp OwaBfb25lS3kaA1RgMt34M7DxoB7LvpK6FMLEFhFb2r6XF+Ej4lX75Vl5UUCCX06sZze Qz2WteTnhNGf/oUMFfIi9C+FMEhkLbNmMpk0BLn9WRyW8omdnForqWHZ1NuwiEqQW4P0 SHFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=Nk4N3mo2WjWxoDU0dQ3FXsu2LNxbqAiN34WikbSrEq8=; b=S5h1ME7jZXc0TRw5NI98hgeBpr2pe/ZC6i35Iab1Mzgo7feXNvmhxJS6ib3qCmsVR9 mfua3axGctHXlB/rEMcg1t3bUbhgk/nCd1a/JHLn0hV5DdhwnZR0jwA9RjcRd5A0yuxK 78D3iUTaJ++OqASQLFa81GqlDhDfLe2XUjIPbHQEuUZYPmBK2Z1G9LVuVxvEGbZMRneW DlLgExCySSoRbyU7L5QQWVPowF1LOkhQU7C5GdjexPIJnERfu0UwCXkB7CJ6TWj5u+Id XV94oqYuTwOZlW8iIOYEAeHqh5EOO2VvWPDgiG2H4CvDx2VB0xyxHpFOSUF6P5wIWeem eBow== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h11-20020a170902f70b00b0016daf0c464asi1621837plo.128.2022.08.12.00.53.27; Fri, 12 Aug 2022 00:53:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237545AbiHLHp6 (ORCPT + 99 others); Fri, 12 Aug 2022 03:45:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237221AbiHLHp5 (ORCPT ); Fri, 12 Aug 2022 03:45:57 -0400 Received: from out199-18.us.a.mail.aliyun.com (out199-18.us.a.mail.aliyun.com [47.90.199.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55B7CA6C0E for ; Fri, 12 Aug 2022 00:45:55 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R131e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045192;MF=hsiangkao@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0VM0lU6C_1660290349; Received: from B-P7TQMD6M-0146.local(mailfrom:hsiangkao@linux.alibaba.com fp:SMTPD_---0VM0lU6C_1660290349) by smtp.aliyun-inc.com; Fri, 12 Aug 2022 15:45:51 +0800 Date: Fri, 12 Aug 2022 15:45:48 +0800 From: Gao Xiang To: Yue Hu Cc: xiang@kernel.org, chao@kernel.org, linux-erofs@lists.ozlabs.org, linux-kernel@vger.kernel.org, huyue2@coolpad.com, zhangwen@coolpad.com Subject: Re: [PATCH] erofs: avoid the potentially wrong m_plen for big pcluster Message-ID: References: <20220812060150.8510-1-huyue2@coolpad.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20220812060150.8510-1-huyue2@coolpad.com> X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Yue, On Fri, Aug 12, 2022 at 02:01:50PM +0800, Yue Hu wrote: > Actually, 'compressedlcs' stores compressed block count rather than > lcluster count. Therefore, the number of bits for shifting the count > should be 'LOG_BLOCK_SIZE' rather than 'lclusterbits' although current > lcluster size is 4K. The value of 'm_plen' will be wrong once we enable > the non 4K-sized lcluster. I'd like to make the last sentence into a separate paragraph. I could update it when applying. > > Signed-off-by: Yue Hu Otherwise it looks good to me, Reviewed-by: Gao Xiang Thanks, Gao Xiang > --- > fs/erofs/zmap.c | 16 ++++++++-------- > 1 file changed, 8 insertions(+), 8 deletions(-) > > diff --git a/fs/erofs/zmap.c b/fs/erofs/zmap.c > index 572f0b8151ba..d58549ca1df9 100644 > --- a/fs/erofs/zmap.c > +++ b/fs/erofs/zmap.c > @@ -141,7 +141,7 @@ struct z_erofs_maprecorder { > u8 type, headtype; > u16 clusterofs; > u16 delta[2]; > - erofs_blk_t pblk, compressedlcs; > + erofs_blk_t pblk, compressedblks; > erofs_off_t nextpackoff; > }; > > @@ -192,7 +192,7 @@ static int legacy_load_cluster_from_disk(struct z_erofs_maprecorder *m, > DBG_BUGON(1); > return -EFSCORRUPTED; > } > - m->compressedlcs = m->delta[0] & > + m->compressedblks = m->delta[0] & > ~Z_EROFS_VLE_DI_D0_CBLKCNT; > m->delta[0] = 1; > } > @@ -293,7 +293,7 @@ static int unpack_compacted_index(struct z_erofs_maprecorder *m, > DBG_BUGON(1); > return -EFSCORRUPTED; > } > - m->compressedlcs = lo & ~Z_EROFS_VLE_DI_D0_CBLKCNT; > + m->compressedblks = lo & ~Z_EROFS_VLE_DI_D0_CBLKCNT; > m->delta[0] = 1; > return 0; > } else if (i + 1 != (int)vcnt) { > @@ -497,7 +497,7 @@ static int z_erofs_get_extent_compressedlen(struct z_erofs_maprecorder *m, > return 0; > } > lcn = m->lcn + 1; > - if (m->compressedlcs) > + if (m->compressedblks) > goto out; > > err = z_erofs_load_cluster_from_disk(m, lcn, false); > @@ -506,7 +506,7 @@ static int z_erofs_get_extent_compressedlen(struct z_erofs_maprecorder *m, > > /* > * If the 1st NONHEAD lcluster has already been handled initially w/o > - * valid compressedlcs, which means at least it mustn't be CBLKCNT, or > + * valid compressedblks, which means at least it mustn't be CBLKCNT, or > * an internal implemenatation error is detected. > * > * The following code can also handle it properly anyway, but let's > @@ -523,12 +523,12 @@ static int z_erofs_get_extent_compressedlen(struct z_erofs_maprecorder *m, > * if the 1st NONHEAD lcluster is actually PLAIN or HEAD type > * rather than CBLKCNT, it's a 1 lcluster-sized pcluster. > */ > - m->compressedlcs = 1; > + m->compressedblks = 1 << (lclusterbits - LOG_BLOCK_SIZE); > break; > case Z_EROFS_VLE_CLUSTER_TYPE_NONHEAD: > if (m->delta[0] != 1) > goto err_bonus_cblkcnt; > - if (m->compressedlcs) > + if (m->compressedblks) > break; > fallthrough; > default: > @@ -539,7 +539,7 @@ static int z_erofs_get_extent_compressedlen(struct z_erofs_maprecorder *m, > return -EFSCORRUPTED; > } > out: > - map->m_plen = (u64)m->compressedlcs << lclusterbits; > + map->m_plen = (u64)m->compressedblks << LOG_BLOCK_SIZE; > return 0; > err_bonus_cblkcnt: > erofs_err(m->inode->i_sb, > -- > 2.17.1