Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2625817pxb; Sun, 17 Oct 2021 20:53:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyXFAcGXTbQwy0vzQpaBv9MsSzrxAgOUo5GtvcY1twgy2oxVm1ABREvexoy7n/UzJu2hNg/ X-Received: by 2002:a17:90a:4595:: with SMTP id v21mr4307180pjg.43.1634528734420; Sun, 17 Oct 2021 20:45:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634528734; cv=none; d=google.com; s=arc-20160816; b=szu1H+RwZM/hGhypnL7oHVgUe239rPyUqgG+AuI1HT/G8EqUZ5gL67N01rSuT5idyA ohmM5PfGRhMlbPOmzuTehOU7/iG0SNA2tZC4fVqbQQmLN35fNntF8xIgBLD7FWe/3tB8 MjBZS3qV/cZP8AA0Ipm/0uHrUsYoK4eduSfQ1vxJmO1iZgvFvH4D6OCs9IMZSlOF0x17 75RHKDjIL/jEwdDI2Rh6STX2wQ+a7acN0p1Q3o42mwH4Ac1nnG6QLOCwtulP+F1Xsw1c l+AAukaJYP7SU2HKeMaAuBIi8NHRSKRbCcxDO8SFNyzLyqKShsnsxrzxj98hbq15GjsR 50OQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=DxIMJaTeW/RbdihQFGkt8fqac8nSIrVsvI9YPXkyiG0=; b=dJK+nmJiv0ZxYXUIFb3isPrZ0N6Ucl/4MewdOyOvsDDns9BMlQpBOkxvqeJ1O8IJ99 Od4kwTTvk+BtV7lQvcSLXdfxL+cxKhAiZsaYtFPvmPMMoKz4iKJKx2t+NCL4yC4P9pFh gFwyR5MBoxXAq0Fvh1upnBowlHOnc8j09fb/yaIz9sqYUqRppXbND3cNdH20ytIVUvHT uEw5e/N59z5sCB11IE/oV19Q8j4co8Fin/SHQjxZ7m97BqbovUGwh4wk3CG8EEi+3EG8 le9zm3YfRHTwNfNjAXm3mdWIZndkSHpDFy6j/dms0WL/4cgtFiDlBRxxORBta7TQduLF X4Ow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tIiHk11j; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s12si13326927pgp.44.2021.10.17.20.45.22; Sun, 17 Oct 2021 20:45:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tIiHk11j; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343955AbhJQPaP (ORCPT + 98 others); Sun, 17 Oct 2021 11:30:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:52550 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343951AbhJQPaM (ORCPT ); Sun, 17 Oct 2021 11:30:12 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E9A6160FE3; Sun, 17 Oct 2021 15:28:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1634484483; bh=PNJBWudaj4UdT5rrn60hnrCNulmXWQLafb1LOAfGlTg=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=tIiHk11j1V+EeTGmq9LG6Up6ScmZ+h0DxAbJrmFrJVqWaBbO/1K16lQ/KVUSCq0hr xaVh5Ez8fF7Y4oqeLFWyIezwn3R9c/ACzy8N5fMpF68zbUFtABdSWvOg0EdazvLrxr UkyEP/rR06AKkIYJb7irjzAfhWvPWYKvw50tK5Fl8gn+/ppsPGBd4JGVzzoDd9fh5e wzPhonOzQ1N4eSCU/80kMg3Expg9GRrCXjLArH4aAHwwIq930KXPyu+nJvndrbvCgE RyWir90G5DYn09/ky4ZFGU8wi8OpXicIzIPLkEyUcdXXEwdjTOCt6ztOOM4VlkyDfb D1Dcv1Df+QYVw== Message-ID: Date: Sun, 17 Oct 2021 23:27:54 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0 Subject: Re: [PATCH v3 2/3] erofs: introduce the secondary compression head Content-Language: en-US To: Gao Xiang , linux-erofs@lists.ozlabs.org Cc: LKML , Yue Hu , Gao Xiang References: <20211008200839.24541-3-xiang@kernel.org> <20211009181209.23041-1-xiang@kernel.org> From: Chao Yu In-Reply-To: <20211009181209.23041-1-xiang@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/10/10 2:12, Gao Xiang wrote: > From: Gao Xiang > > Previously, for each HEAD lcluster, it can be either HEAD or PLAIN > lcluster to indicate whether the whole pcluster is compressed or not. > > In this patch, a new HEAD2 head type is introduced to specify another > compression algorithm other than the primary algorithm for each > compressed file, which can be used for upcoming LZMA compression and > LZ4 range dictionary compression for various data patterns. > > It has been stayed in the EROFS roadmap for years. Complete it now! > > Signed-off-by: Gao Xiang > --- > v2: https://lore.kernel.org/r/20211008200839.24541-3-xiang@kernel.org > changes since v2: > - simplify z_algorithmtype check suggested by Yue. > > fs/erofs/erofs_fs.h | 8 +++++--- > fs/erofs/zmap.c | 38 ++++++++++++++++++++++++++------------ > 2 files changed, 31 insertions(+), 15 deletions(-) > > diff --git a/fs/erofs/erofs_fs.h b/fs/erofs/erofs_fs.h > index b0b23f41abc3..f579c8c78fff 100644 > --- a/fs/erofs/erofs_fs.h > +++ b/fs/erofs/erofs_fs.h > @@ -21,11 +21,13 @@ > #define EROFS_FEATURE_INCOMPAT_COMPR_CFGS 0x00000002 > #define EROFS_FEATURE_INCOMPAT_BIG_PCLUSTER 0x00000002 > #define EROFS_FEATURE_INCOMPAT_CHUNKED_FILE 0x00000004 > +#define EROFS_FEATURE_INCOMPAT_COMPR_HEAD2 0x00000008 > #define EROFS_ALL_FEATURE_INCOMPAT \ > (EROFS_FEATURE_INCOMPAT_LZ4_0PADDING | \ > EROFS_FEATURE_INCOMPAT_COMPR_CFGS | \ > EROFS_FEATURE_INCOMPAT_BIG_PCLUSTER | \ > - EROFS_FEATURE_INCOMPAT_CHUNKED_FILE) > + EROFS_FEATURE_INCOMPAT_CHUNKED_FILE | \ > + EROFS_FEATURE_INCOMPAT_COMPR_HEAD2) > > #define EROFS_SB_EXTSLOT_SIZE 16 > > @@ -314,9 +316,9 @@ struct z_erofs_map_header { > */ > enum { > Z_EROFS_VLE_CLUSTER_TYPE_PLAIN = 0, > - Z_EROFS_VLE_CLUSTER_TYPE_HEAD = 1, > + Z_EROFS_VLE_CLUSTER_TYPE_HEAD1 = 1, > Z_EROFS_VLE_CLUSTER_TYPE_NONHEAD = 2, > - Z_EROFS_VLE_CLUSTER_TYPE_RESERVED = 3, > + Z_EROFS_VLE_CLUSTER_TYPE_HEAD2 = 3, It needs to update comments above as well. Thanks, > Z_EROFS_VLE_CLUSTER_TYPE_MAX > }; > > diff --git a/fs/erofs/zmap.c b/fs/erofs/zmap.c > index 9d9c26343dab..864d9d5474d5 100644 > --- a/fs/erofs/zmap.c > +++ b/fs/erofs/zmap.c > @@ -28,7 +28,7 @@ static int z_erofs_fill_inode_lazy(struct inode *inode) > { > struct erofs_inode *const vi = EROFS_I(inode); > struct super_block *const sb = inode->i_sb; > - int err; > + int err, headnr; > erofs_off_t pos; > struct page *page; > void *kaddr; > @@ -68,9 +68,11 @@ static int z_erofs_fill_inode_lazy(struct inode *inode) > vi->z_algorithmtype[0] = h->h_algorithmtype & 15; > vi->z_algorithmtype[1] = h->h_algorithmtype >> 4; > > - if (vi->z_algorithmtype[0] >= Z_EROFS_COMPRESSION_MAX) { > - erofs_err(sb, "unknown compression format %u for nid %llu, please upgrade kernel", > - vi->z_algorithmtype[0], vi->nid); > + headnr = 0; > + if (vi->z_algorithmtype[0] >= Z_EROFS_COMPRESSION_MAX || > + vi->z_algorithmtype[++headnr] >= Z_EROFS_COMPRESSION_MAX) { > + erofs_err(sb, "unknown HEAD%u format %u for nid %llu, please upgrade kernel", > + headnr + 1, vi->z_algorithmtype[headnr], vi->nid); > err = -EOPNOTSUPP; > goto unmap_done; > } > @@ -189,7 +191,8 @@ static int legacy_load_cluster_from_disk(struct z_erofs_maprecorder *m, > m->delta[1] = le16_to_cpu(di->di_u.delta[1]); > break; > case Z_EROFS_VLE_CLUSTER_TYPE_PLAIN: > - case Z_EROFS_VLE_CLUSTER_TYPE_HEAD: > + case Z_EROFS_VLE_CLUSTER_TYPE_HEAD1: > + case Z_EROFS_VLE_CLUSTER_TYPE_HEAD2: > m->clusterofs = le16_to_cpu(di->di_clusterofs); > m->pblk = le32_to_cpu(di->di_u.blkaddr); > break; > @@ -446,7 +449,8 @@ static int z_erofs_extent_lookback(struct z_erofs_maprecorder *m, > } > return z_erofs_extent_lookback(m, m->delta[0]); > case Z_EROFS_VLE_CLUSTER_TYPE_PLAIN: > - case Z_EROFS_VLE_CLUSTER_TYPE_HEAD: > + case Z_EROFS_VLE_CLUSTER_TYPE_HEAD1: > + case Z_EROFS_VLE_CLUSTER_TYPE_HEAD2: > m->headtype = m->type; > map->m_la = (lcn << lclusterbits) | m->clusterofs; > break; > @@ -470,13 +474,18 @@ static int z_erofs_get_extent_compressedlen(struct z_erofs_maprecorder *m, > int err; > > DBG_BUGON(m->type != Z_EROFS_VLE_CLUSTER_TYPE_PLAIN && > - m->type != Z_EROFS_VLE_CLUSTER_TYPE_HEAD); > + m->type != Z_EROFS_VLE_CLUSTER_TYPE_HEAD1 && > + m->type != Z_EROFS_VLE_CLUSTER_TYPE_HEAD2); > + DBG_BUGON(m->type != m->headtype); > + > if (m->headtype == Z_EROFS_VLE_CLUSTER_TYPE_PLAIN || > - !(vi->z_advise & Z_EROFS_ADVISE_BIG_PCLUSTER_1)) { > + ((m->headtype == Z_EROFS_VLE_CLUSTER_TYPE_HEAD1) && > + !(vi->z_advise & Z_EROFS_ADVISE_BIG_PCLUSTER_1)) || > + ((m->headtype == Z_EROFS_VLE_CLUSTER_TYPE_HEAD2) && > + !(vi->z_advise & Z_EROFS_ADVISE_BIG_PCLUSTER_2))) { > map->m_plen = 1 << lclusterbits; > return 0; > } > - > lcn = m->lcn + 1; > if (m->compressedlcs) > goto out; > @@ -498,7 +507,8 @@ static int z_erofs_get_extent_compressedlen(struct z_erofs_maprecorder *m, > > switch (m->type) { > case Z_EROFS_VLE_CLUSTER_TYPE_PLAIN: > - case Z_EROFS_VLE_CLUSTER_TYPE_HEAD: > + case Z_EROFS_VLE_CLUSTER_TYPE_HEAD1: > + case Z_EROFS_VLE_CLUSTER_TYPE_HEAD2: > /* > * if the 1st NONHEAD lcluster is actually PLAIN or HEAD type > * rather than CBLKCNT, it's a 1 lcluster-sized pcluster. > @@ -553,7 +563,8 @@ static int z_erofs_get_extent_decompressedlen(struct z_erofs_maprecorder *m) > DBG_BUGON(!m->delta[1] && > m->clusterofs != 1 << lclusterbits); > } else if (m->type == Z_EROFS_VLE_CLUSTER_TYPE_PLAIN || > - m->type == Z_EROFS_VLE_CLUSTER_TYPE_HEAD) { > + m->type == Z_EROFS_VLE_CLUSTER_TYPE_HEAD1 || > + m->type == Z_EROFS_VLE_CLUSTER_TYPE_HEAD2) { > /* go on until the next HEAD lcluster */ > if (lcn != headlcn) > break; > @@ -612,7 +623,8 @@ int z_erofs_map_blocks_iter(struct inode *inode, > > switch (m.type) { > case Z_EROFS_VLE_CLUSTER_TYPE_PLAIN: > - case Z_EROFS_VLE_CLUSTER_TYPE_HEAD: > + case Z_EROFS_VLE_CLUSTER_TYPE_HEAD1: > + case Z_EROFS_VLE_CLUSTER_TYPE_HEAD2: > if (endoff >= m.clusterofs) { > m.headtype = m.type; > map->m_la = (m.lcn << lclusterbits) | m.clusterofs; > @@ -654,6 +666,8 @@ int z_erofs_map_blocks_iter(struct inode *inode, > > if (m.headtype == Z_EROFS_VLE_CLUSTER_TYPE_PLAIN) > map->m_algorithmformat = Z_EROFS_COMPRESSION_SHIFTED; > + else if (m.headtype == Z_EROFS_VLE_CLUSTER_TYPE_HEAD2) > + map->m_algorithmformat = vi->z_algorithmtype[1]; > else > map->m_algorithmformat = vi->z_algorithmtype[0]; > >