Changes since last update:
- 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. -----BEGIN PGP SIGNATURE----- iIcEABYIAC8WIQThPAmQN9sSA0DVxtI5NzHcH7XmBAUCYJ8DGBEceGlhbmdAa2Vy bmVsLm9yZwAKCRA5NzHcH7XmBAC0AQDaap8fSTWMLroLLBCcr1MwTqoS6wf44tx8 iq2FFcU/hQD+PqrnCFJW7wjWjMC84weOudRvh2/lu/GKH2a5LgJ5Xgs= =UTkq -----END PGP SIGNATURE----- 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
This commit is contained in:
Коммит
41f035c062
|
@ -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):
|
||||||
|
@ -113,31 +113,31 @@ may not. All metadatas can be now observed in two different spaces (views):
|
||||||
|
|
||||||
::
|
::
|
||||||
|
|
||||||
|-> aligned with 8B
|
|-> aligned with 8B
|
||||||
|-> followed closely
|
|-> followed closely
|
||||||
+ meta_blkaddr blocks |-> another slot
|
+ meta_blkaddr blocks |-> another slot
|
||||||
_____________________________________________________________________
|
_____________________________________________________________________
|
||||||
| ... | inode | xattrs | extents | data inline | ... | inode ...
|
| ... | inode | xattrs | extents | data inline | ... | inode ...
|
||||||
|________|_______|(optional)|(optional)|__(optional)_|_____|__________
|
|________|_______|(optional)|(optional)|__(optional)_|_____|__________
|
||||||
|-> aligned with the inode slot size
|
|-> aligned with the inode slot size
|
||||||
. .
|
. .
|
||||||
. .
|
. .
|
||||||
. .
|
. .
|
||||||
. .
|
. .
|
||||||
. .
|
. .
|
||||||
. .
|
. .
|
||||||
.____________________________________________________|-> aligned with 4B
|
.____________________________________________________|-> aligned with 4B
|
||||||
| xattr_ibody_header | shared xattrs | inline xattrs |
|
| xattr_ibody_header | shared xattrs | inline xattrs |
|
||||||
|____________________|_______________|_______________|
|
|____________________|_______________|_______________|
|
||||||
|-> 12 bytes <-|->x * 4 bytes<-| .
|
|-> 12 bytes <-|->x * 4 bytes<-| .
|
||||||
. . .
|
. . .
|
||||||
. . .
|
. . .
|
||||||
. . .
|
. . .
|
||||||
._______________________________.______________________.
|
._______________________________.______________________.
|
||||||
| id | id | id | id | ... | id | ent | ... | ent| ... |
|
| id | id | id | id | ... | id | ent | ... | ent| ... |
|
||||||
|____|____|____|____|______|____|_____|_____|____|_____|
|
|____|____|____|____|______|____|_____|_____|____|_____|
|
||||||
|-> aligned with 4B
|
|-> aligned with 4B
|
||||||
|-> aligned with 4B
|
|-> aligned with 4B
|
||||||
|
|
||||||
Inode could be 32 or 64 bytes, which can be distinguished from a common
|
Inode could be 32 or 64 bytes, which can be distinguished from a common
|
||||||
field which all inode versions have -- i_format::
|
field which all inode versions have -- i_format::
|
||||||
|
@ -175,13 +175,13 @@ 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
|
||||||
_________________________________________________________________________
|
_________________________________________________________________________
|
||||||
| ... | xattr_entry | xattr data | ... | xattr_entry | xattr data ...
|
| ... | xattr_entry | xattr data | ... | xattr_entry | xattr data ...
|
||||||
|________|_____________|_____________|_____|______________|_______________
|
|________|_____________|_____________|_____|______________|_______________
|
||||||
|
|
||||||
Directories
|
Directories
|
||||||
-----------
|
-----------
|
||||||
|
@ -193,48 +193,77 @@ algorithm (could refer to the related source code).
|
||||||
|
|
||||||
::
|
::
|
||||||
|
|
||||||
___________________________
|
___________________________
|
||||||
/ |
|
/ |
|
||||||
/ ______________|________________
|
/ ______________|________________
|
||||||
/ / | nameoff1 | nameoffN-1
|
/ / | nameoff1 | nameoffN-1
|
||||||
____________.______________._______________v________________v__________
|
____________.______________._______________v________________v__________
|
||||||
| dirent | dirent | ... | dirent | filename | filename | ... | filename |
|
| dirent | dirent | ... | dirent | filename | filename | ... | filename |
|
||||||
|___.0___|____1___|_____|___N-1__|____0_____|____1_____|_____|___N-1____|
|
|___.0___|____1___|_____|___N-1__|____0_____|____1_____|_____|___N-1____|
|
||||||
\ ^
|
\ ^
|
||||||
\ | * 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
|
||||||
|
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).
|
||||||
|
|
||||||
|---- Variant-Length Extent ----|-------- VLE --------|----- VLE -----
|
In details, original (uncompressed) data is turned into several variable-sized
|
||||||
clusterofs clusterofs clusterofs
|
extents and in the meanwhile, compressed into physical clusters (pclusters).
|
||||||
| | | logical data
|
In order to record each variable-sized extent, logical clusters (lclusters) are
|
||||||
_________v_______________________________v_____________________v_______________
|
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::
|
||||||
|-> cluster <-|-> cluster <-|-> cluster <-|-> cluster <-|-> cluster <-|
|
|
||||||
size size size size size
|
|
||||||
. . . .
|
|
||||||
. . . .
|
|
||||||
. . . .
|
|
||||||
_______._____________._____________._____________._____________________
|
|
||||||
... | | | | ... physical data
|
|
||||||
_______|_____________|_____________|_____________|_____________________
|
|
||||||
|-> cluster <-|-> cluster <-|-> cluster <-|
|
|
||||||
size size size
|
|
||||||
|
|
||||||
Currently each on-disk physical cluster can contain 4KB (un)compressed data
|
|<- variable-sized extent ->|<- VLE ->|
|
||||||
at most. For each logical cluster, there is a corresponding on-disk index to
|
clusterofs clusterofs clusterofs
|
||||||
describe its cluster type, physical cluster address, etc.
|
| | |
|
||||||
|
_________v_________________________________v_______________________v________
|
||||||
|
... | . | | . | | . ...
|
||||||
|
____|____._________|______________|________.___ _|______________|__.________
|
||||||
|
|-> lcluster <-|-> lcluster <-|-> lcluster <-|-> lcluster <-|
|
||||||
|
(HEAD) (NONHEAD) (HEAD) (NONHEAD) .
|
||||||
|
. CBLKCNT . .
|
||||||
|
. . .
|
||||||
|
. . .
|
||||||
|
_______._____________________________.______________._________________
|
||||||
|
... | | | | ...
|
||||||
|
_______|______________|______________|______________|_________________
|
||||||
|
|-> big pcluster <-|-> pcluster <-|
|
||||||
|
|
||||||
See "struct z_erofs_vle_decompressed_index" in erofs_fs.h for more details.
|
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 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,
|
||||||
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;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче