Commit 41f035c0 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'erofs-for-5.13-rc2-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs

Pull erofs fixes from Gao Xiang:
 "This mainly fixes 1 lcluster-sized pclusters for the big pcluster
  feature, which can be forcely generated by mkfs as a specific on-disk
  case for per-(sub)file compression strategies but missed to handle in
  runtime properly.

  Also, documentation updates are included to fix the broken
  illustration due to the ReST conversion by accident and complete the
  big pcluster introduction.

  Summary:

   - update documentation to fix the broken illustration due to ReST
     conversion by accident at that time and complete the big pcluster
     introduction

   - fix 1 lcluster-sized pclusters for the big pcluster feature"

* tag 'erofs-for-5.13-rc2-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs:
  erofs: fix 1 lcluster-sized pcluster for big pcluster
  erofs: update documentation about data compression
  erofs: fix broken illustration in documentation
parents a5ce4296 0852b6ca
...@@ -50,8 +50,8 @@ Here is the main features of EROFS: ...@@ -50,8 +50,8 @@ Here is the main features of EROFS:
- Support POSIX.1e ACLs by using xattrs; - Support POSIX.1e ACLs by using xattrs;
- Support transparent file compression as an option: - Support transparent data compression as an option:
LZ4 algorithm with 4 KB fixed-sized output compression for high performance. LZ4 algorithm with the fixed-sized output compression for high performance.
The following git tree provides the file system user-space tools under The following git tree provides the file system user-space tools under
development (ex, formatting tool mkfs.erofs): development (ex, formatting tool mkfs.erofs):
...@@ -175,7 +175,7 @@ may not. All metadatas can be now observed in two different spaces (views): ...@@ -175,7 +175,7 @@ may not. All metadatas can be now observed in two different spaces (views):
Each share xattr can also be directly found by the following formula: Each share xattr can also be directly found by the following formula:
xattr offset = xattr_blkaddr * block_size + 4 * xattr_id xattr offset = xattr_blkaddr * block_size + 4 * xattr_id
:: ::
|-> aligned by 4 bytes |-> aligned by 4 bytes
+ xattr_blkaddr blocks |-> aligned with 4 bytes + xattr_blkaddr blocks |-> aligned with 4 bytes
...@@ -204,37 +204,66 @@ algorithm (could refer to the related source code). ...@@ -204,37 +204,66 @@ algorithm (could refer to the related source code).
\ | * could have \ | * could have
\ | trailing '\0' \ | trailing '\0'
\________________________| nameoff0 \________________________| nameoff0
Directory block Directory block
Note that apart from the offset of the first filename, nameoff0 also indicates 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 the total number of directory entries in this block since it is no need to
introduce another on-disk field at all. introduce another on-disk field at all.
Compression Data compression
----------- ----------------
Currently, EROFS supports 4KB fixed-sized output transparent file compression, EROFS implements LZ4 fixed-sized output compression which generates fixed-sized
as illustrated below:: compressed data blocks from variable-sized input in contrast to other existing
fixed-sized input solutions. Relatively higher compression ratios can be gotten
|---- Variant-Length Extent ----|-------- VLE --------|----- VLE ----- 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 clusterofs clusterofs clusterofs
| | | logical data | | |
_________v_______________________________v_____________________v_______________ _________v_________________________________v_______________________v________
... | . | | . | | . | ... ... | . | | . | | . ...
____|____.________|_____________|________.____|_____________|__.__________|____ ____|____._________|______________|________.___ _|______________|__.________
|-> cluster <-|-> cluster <-|-> cluster <-|-> cluster <-|-> cluster <-| |-> lcluster <-|-> lcluster <-|-> lcluster <-|-> lcluster <-|
size size size size size (HEAD) (NONHEAD) (HEAD) (NONHEAD) .
. . . . . CBLKCNT . .
. . . . . . .
. . . . . . .
_______._____________._____________._____________._____________________ _______._____________________________.______________._________________
... | | | | ... physical data ... | | | | ...
_______|_____________|_____________|_____________|_____________________ _______|______________|______________|______________|_________________
|-> cluster <-|-> cluster <-|-> cluster <-| |-> big pcluster <-|-> pcluster <-|
size size size
A physical cluster can be seen as a container of physical compressed blocks
Currently each on-disk physical cluster can contain 4KB (un)compressed data which contains compressed data. Previously, only lcluster-sized (4KB) pclusters
at most. For each logical cluster, there is a corresponding on-disk index to were supported. After big pcluster feature is introduced (available since
describe its cluster type, physical cluster address, etc. Linux v5.13), pcluster can be a multiple of lcluster size.
See "struct z_erofs_vle_decompressed_index" in erofs_fs.h for more details. 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 lcluster-sized pcluster (without CBLKCNT) ^
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.
...@@ -450,14 +450,31 @@ static int z_erofs_get_extent_compressedlen(struct z_erofs_maprecorder *m, ...@@ -450,14 +450,31 @@ static int z_erofs_get_extent_compressedlen(struct z_erofs_maprecorder *m,
lcn = m->lcn + 1; lcn = m->lcn + 1;
if (m->compressedlcs) if (m->compressedlcs)
goto out; goto out;
if (lcn == initial_lcn)
goto err_bonus_cblkcnt;
err = z_erofs_load_cluster_from_disk(m, lcn); err = z_erofs_load_cluster_from_disk(m, lcn);
if (err) if (err)
return err; return err;
/*
* If the 1st NONHEAD lcluster has already been handled initially w/o
* valid compressedlcs, 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
* BUG_ON in the debugging mode only for developers to notice that.
*/
DBG_BUGON(lcn == initial_lcn &&
m->type == Z_EROFS_VLE_CLUSTER_TYPE_NONHEAD);
switch (m->type) { switch (m->type) {
case Z_EROFS_VLE_CLUSTER_TYPE_PLAIN:
case Z_EROFS_VLE_CLUSTER_TYPE_HEAD:
/*
* if the 1st NONHEAD lcluster is actually PLAIN or HEAD type
* rather than CBLKCNT, it's a 1 lcluster-sized pcluster.
*/
m->compressedlcs = 1;
break;
case Z_EROFS_VLE_CLUSTER_TYPE_NONHEAD: case Z_EROFS_VLE_CLUSTER_TYPE_NONHEAD:
if (m->delta[0] != 1) if (m->delta[0] != 1)
goto err_bonus_cblkcnt; goto err_bonus_cblkcnt;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment