Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2731829pxj; Mon, 10 May 2021 09:29:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxS6M+MSgfKd3IFEKEVlFXUeqx+9JdIzqeMzAikEPyt1i/Nw3zWaK7bMa1/yUXIIm6WQSgZ X-Received: by 2002:a17:906:c453:: with SMTP id ck19mr27181599ejb.439.1620664148902; Mon, 10 May 2021 09:29:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620664148; cv=none; d=google.com; s=arc-20160816; b=CgzQdtz/oCMdDNbhbUR7/4iTr/BQyK3I0WqA2KhlivfxA9XL0GPbbK1ZmTIfQWfFZo yZANlpJxnJyjOzTbPSpnMeUB7n4iAuBUf7+o7BN2435Hn65q6rEIoZLZMPx0KDioODle jeGdvJyWZnXSANk6zcOX6IhV6tSq7PoGuARx9UJpgPL200+QAcfyk0QJvBV+6t0TvGDb mnjs0xbRfjHeERQiikKym5P2rGosIhtbUgazWUykkmgh93VSioi84C25r0bpMOmIh8bT oAZ4EflRjW2PdXL2/jmWFBF3TrML/NKcr+v2kKncElzay0U37eiHfI67NsWyLpIK+TbE C6fA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=MPXWd82VBtn09pLIO3cQpeC9ihPoRQ3FBEa8bs/6UXw=; b=iIc6b4bvmwYZ3DlPcR66WUsd96ESbSnoZcilSaN+gC0gvK3cDz7OKppVum4limK9hX i6OfRDreEoY62/iuDhLXbKDwgc3G2a02QdgehUZKROqSmIg2alnCaC/bYqdBp2WxPmdp gqCroJdDC0yg2o7qT3qkf2F88pCDD9Dylo3qa6T6ILkvqHLYVOJ9GDH7PkcOZOE7vaes eB9MpOW/RzQVBMf1lzcy9h9Mh0Dlmeq0vQeoOyM3QVpKKXn44lh6MGmPs1e5YjzTZ7GM 8l/ghPj3rTaELWnTW83xhYgESUdvDzgHEnxVFeJtjHPwo0IUYEd1PIfxHQ8DW8t3aWVG 7wHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SAYK5kYA; 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 lo25si13456145ejb.456.2021.05.10.09.28.45; Mon, 10 May 2021 09:29:08 -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=SAYK5kYA; 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 S231540AbhEJQ03 (ORCPT + 99 others); Mon, 10 May 2021 12:26:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:35056 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231524AbhEJQ0S (ORCPT ); Mon, 10 May 2021 12:26:18 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id DD5B86115C; Mon, 10 May 2021 16:25:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620663912; bh=0sGD9fIWHzAGppiTJVBPY+gvT2e0mny1/7etx8/kjZw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SAYK5kYA8yI0S7TPrvaAXPbnlamPcmf6tou4z6GGlnceH7aNheMr4gC08z3bCeWKG TRSnNRIXmbZJB4JtCoRSS5IF7VUg7mNJgXNc2n+THfBvY8JLX+CLysnueVcHI6zVL3 LiWPGrjQRUJVgKg0MtCKx3yBsmYj3QXz8DVUxab2idPjtPoopRfkvNO3Mqdi9SMTW/ RxDjeQa3YUT4chPvzaH/suZGYtLVsC6mcFrIwa3Qn13WZsq+3Lp54ztENNqb7xzchR hbYSPwtva+r4q4m3VdqcqzL8jVpJDzPyYyVI/R5IyPUsufSE2VX3paNvbY/r/1vD+M 6qJk/Q4TeNE7Q== From: Gao Xiang To: linux-erofs@lists.ozlabs.org, Chao Yu Cc: LKML , Gao Xiang Subject: [PATCH 2/2] erofs: update documentation about data compression Date: Tue, 11 May 2021 00:25:06 +0800 Message-Id: <20210510162506.28637-2-xiang@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210510162506.28637-1-xiang@kernel.org> References: <20210510162506.28637-1-xiang@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add more description about (NON)HEAD lclusters, and the new big pcluster feature. Signed-off-by: Gao Xiang --- Documentation/filesystems/erofs.rst | 68 +++++++++++++++++++++-------- 1 file changed, 49 insertions(+), 19 deletions(-) diff --git a/Documentation/filesystems/erofs.rst b/Documentation/filesystems/erofs.rst index 869b183ff215..17ad46c10b26 100644 --- a/Documentation/filesystems/erofs.rst +++ b/Documentation/filesystems/erofs.rst @@ -50,8 +50,8 @@ Here is the main features of EROFS: - Support POSIX.1e ACLs by using xattrs; - - Support transparent file compression as an option: - LZ4 algorithm with 4 KB fixed-sized output compression for high performance. + - Support transparent data compression as an option: + LZ4 algorithm with the fixed-sized output compression for high performance. The following git tree provides the file system user-space tools under development (ex, formatting tool mkfs.erofs): @@ -210,10 +210,21 @@ Note that apart from the offset of the first filename, nameoff0 also indicates the total number of directory entries in this block since it is no need to introduce another on-disk field at all. -Compression ------------ -Currently, EROFS supports 4KB fixed-sized output transparent file compression, -as illustrated below:: +Data compression +---------------- +EROFS implements LZ4 fixed-sized output compression which generates fixed-sized +compressed data blocks from variable-sized input in contrast to other existing +fixed-sized input solutions. Relatively higher compression ratios can be gotten +by using fixed-sized output compression since nowadays popular data compression +algorithms are mostly LZ77-based and such fixed-sized output approach can be +benefited from the historical dictionary (aka. sliding window). + +In details, original (uncompressed) data is turned into several variable-sized +extents and in the meanwhile, compressed into physical clusters (pclusters). +In order to record each variable-sized extent, logical clusters (lclusters) are +introduced as the basic unit of compress indexes to indicate whether a new +extent is generated within the range (HEAD) or not (NONHEAD). Lclusters are now +fixed in block size, as illustrated below:: |<- variable-sized extent ->|<- VLE ->| clusterofs clusterofs clusterofs @@ -222,18 +233,37 @@ as illustrated below:: ... | . | | . | | . ... ____|____._________|______________|________.___ _|______________|__.________ |-> lcluster <-|-> lcluster <-|-> lcluster <-|-> lcluster <-| - size size size size . . - . . . . - . . . . - . . . . - _______.______________.______________.______________._________________ + (HEAD) (NONHEAD) (HEAD) (NONHEAD) . + . CBLKCNT . . + . . . + . . . + _______._____________________________.______________._________________ ... | | | | ... _______|______________|______________|______________|_________________ - |-> pcluster <-|-> pcluster <-|-> pcluster <-| - size size size - -Currently each on-disk physical cluster can contain 4KB (un)compressed data -at most. For each logical cluster, there is a corresponding on-disk index to -describe its cluster type, physical cluster address, etc. - -See "struct z_erofs_vle_decompressed_index" in erofs_fs.h for more details. + |-> big pcluster <-|-> pcluster <-| + +A physical cluster can be seen as a container of physical compressed blocks +which contains compressed data. Previously, only lcluster-sized (4KB) pclusters +were supported. After big pcluster feature is introduced (available since +Linux v5.13), pcluster can be a multiple of lcluster size. + +For each HEAD lcluster, clusterofs is recorded to indicate where a new extent +starts and blkaddr is used to seek the compressed data. For each NONHEAD +lcluster, delta0 and delta1 are available instead of blkaddr to indicate the +distance to its HEAD lcluster and the next HEAD lcluster. A PLAIN lcluster is +also a HEAD lcluster except that its data is uncompressed. See the comments +around "struct z_erofs_vle_decompressed_index" in erofs_fs.h for more details. + +If big pcluster is enabled, pcluster size in lclusters needs to be recorded as +well. Let the delta0 of the first NONHEAD lcluster store the compressed block +count with a special flag as a new called CBLKCNT NONHEAD lcluster. It's easy +to understand its delta0 is constantly 1, as illustrated below:: + + __________________________________________________________ + | HEAD | NONHEAD | NONHEAD | ... | NONHEAD | HEAD | HEAD | + |__:___|_(CBLKCNT)_|_________|_____|_________|__:___|____:_| + |<------ a big pcluster with CBLKCNT ------->|<-- -->| + ^ a pcluster with 1 + +If another HEAD follows a HEAD lcluster, there is no room to record CBLKCNT, +but it's easy to know the size of such pcluster is 1 lcluster as well. -- 2.20.1