1e66d8631SMauro Carvalho Chehab.. SPDX-License-Identifier: GPL-2.0 2e66d8631SMauro Carvalho Chehab 3e66d8631SMauro Carvalho Chehab====================================== 46e95d0a0SGao XiangEROFS - Enhanced Read-Only File System 5e66d8631SMauro Carvalho Chehab====================================== 6e66d8631SMauro Carvalho Chehab 7e66d8631SMauro Carvalho ChehabOverview 8e66d8631SMauro Carvalho Chehab======== 9e66d8631SMauro Carvalho Chehab 106e95d0a0SGao XiangEROFS filesystem stands for Enhanced Read-Only File System. It aims to form a 116e95d0a0SGao Xianggeneric read-only filesystem solution for various read-only use cases instead 126e95d0a0SGao Xiangof just focusing on storage space saving without considering any side effects 136e95d0a0SGao Xiangof runtime performance. 14e66d8631SMauro Carvalho Chehab 156e95d0a0SGao XiangIt is designed to meet the needs of flexibility, feature extendability and user 166e95d0a0SGao Xiangpayload friendly, etc. Apart from those, it is still kept as a simple 176e95d0a0SGao Xiangrandom-access friendly high-performance filesystem to get rid of unneeded I/O 186e95d0a0SGao Xiangamplification and memory-resident overhead compared to similar approaches. 196e95d0a0SGao Xiang 206e95d0a0SGao XiangIt is implemented to be a better choice for the following scenarios: 21e66d8631SMauro Carvalho Chehab 22e66d8631SMauro Carvalho Chehab - read-only storage media or 23e66d8631SMauro Carvalho Chehab 24e66d8631SMauro Carvalho Chehab - part of a fully trusted read-only solution, which means it needs to be 25e66d8631SMauro Carvalho Chehab immutable and bit-for-bit identical to the official golden image for 266e95d0a0SGao Xiang their releases due to security or other considerations and 27e66d8631SMauro Carvalho Chehab 28dfeab2e9SGao Xiang - hope to minimize extra storage space with guaranteed end-to-end performance 29dfeab2e9SGao Xiang by using compact layout, transparent file compression and direct access, 30dfeab2e9SGao Xiang especially for those embedded devices with limited memory and high-density 316e95d0a0SGao Xiang hosts with numerous containers. 32e66d8631SMauro Carvalho Chehab 332109901dSGao XiangHere are the main features of EROFS: 34e66d8631SMauro Carvalho Chehab 35e66d8631SMauro Carvalho Chehab - Little endian on-disk design; 36e66d8631SMauro Carvalho Chehab 372109901dSGao Xiang - Block-based distribution and file-based distribution over fscache are 382109901dSGao Xiang supported; 392109901dSGao Xiang 402109901dSGao Xiang - Support multiple devices to refer to external blobs, which can be used 412109901dSGao Xiang for container images; 422109901dSGao Xiang 43d3c4bdccSJingbo Xu - 32-bit block addresses for each device, therefore 16TiB address space at 44d3c4bdccSJingbo Xu most with 4KiB block size for now; 45e66d8631SMauro Carvalho Chehab 466e95d0a0SGao Xiang - Two inode layouts for different requirements: 47e66d8631SMauro Carvalho Chehab 486e95d0a0SGao Xiang ===================== ============ ====================================== 49e66d8631SMauro Carvalho Chehab compact (v1) extended (v2) 506e95d0a0SGao Xiang ===================== ============ ====================================== 51e66d8631SMauro Carvalho Chehab Inode metadata size 32 bytes 64 bytes 526e95d0a0SGao Xiang Max file size 4 GiB 16 EiB (also limited by max. vol size) 53e66d8631SMauro Carvalho Chehab Max uids/gids 65536 4294967296 54a1108dcdSDavid Anderson Per-inode timestamp no yes (64 + 32-bit timestamp) 55e66d8631SMauro Carvalho Chehab Max hardlinks 65536 4294967296 566e95d0a0SGao Xiang Metadata reserved 8 bytes 18 bytes 576e95d0a0SGao Xiang ===================== ============ ====================================== 586e95d0a0SGao Xiang 592109901dSGao Xiang - Support extended attributes as an option; 60e66d8631SMauro Carvalho Chehab 61*3048102dSJingbo Xu - Support a bloom filter that speeds up negative extended attribute lookups; 62*3048102dSJingbo Xu 632109901dSGao Xiang - Support POSIX.1e ACLs by using extended attributes; 64e66d8631SMauro Carvalho Chehab 6546f2e044SGao Xiang - Support transparent data compression as an option: 66*3048102dSJingbo Xu LZ4, MicroLZMA and DEFLATE algorithms can be used on a per-file basis; In 67*3048102dSJingbo Xu addition, inplace decompression is also supported to avoid bounce compressed 68*3048102dSJingbo Xu buffers and unnecessary page cache thrashing. 69dfeab2e9SGao Xiang 702109901dSGao Xiang - Support chunk-based data deduplication and rolling-hash compressed data 712109901dSGao Xiang deduplication; 722109901dSGao Xiang 732109901dSGao Xiang - Support tailpacking inline compared to byte-addressed unaligned metadata 742109901dSGao Xiang or smaller block size alternatives; 752109901dSGao Xiang 762109901dSGao Xiang - Support merging tail-end data into a special inode as fragments. 772109901dSGao Xiang 78e6687b89SJingbo Xu - Support large folios for uncompressed files. 79e6687b89SJingbo Xu 806e95d0a0SGao Xiang - Support direct I/O on uncompressed files to avoid double caching for loop 816e95d0a0SGao Xiang devices; 826e95d0a0SGao Xiang 836e95d0a0SGao Xiang - Support FSDAX on uncompressed images for secure containers and ramdisks in 846e95d0a0SGao Xiang order to get rid of unnecessary page cache. 856e95d0a0SGao Xiang 866e95d0a0SGao Xiang - Support file-based on-demand loading with the Fscache infrastructure. 87e66d8631SMauro Carvalho Chehab 88e66d8631SMauro Carvalho ChehabThe following git tree provides the file system user-space tools under 896e95d0a0SGao Xiangdevelopment, such as a formatting tool (mkfs.erofs), an on-disk consistency & 906e95d0a0SGao Xiangcompatibility checking tool (fsck.erofs), and a debugging tool (dump.erofs): 91e66d8631SMauro Carvalho Chehab 92e66d8631SMauro Carvalho Chehab- git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs-utils.git 93e66d8631SMauro Carvalho Chehab 94e66d8631SMauro Carvalho ChehabBugs and patches are welcome, please kindly help us and send to the following 95e66d8631SMauro Carvalho Chehablinux-erofs mailing list: 96e66d8631SMauro Carvalho Chehab 97e66d8631SMauro Carvalho Chehab- linux-erofs mailing list <linux-erofs@lists.ozlabs.org> 98e66d8631SMauro Carvalho Chehab 99e66d8631SMauro Carvalho ChehabMount options 100e66d8631SMauro Carvalho Chehab============= 101e66d8631SMauro Carvalho Chehab 102e66d8631SMauro Carvalho Chehab=================== ========================================================= 103e66d8631SMauro Carvalho Chehab(no)user_xattr Setup Extended User Attributes. Note: xattr is enabled 104e66d8631SMauro Carvalho Chehab by default if CONFIG_EROFS_FS_XATTR is selected. 105e66d8631SMauro Carvalho Chehab(no)acl Setup POSIX Access Control List. Note: acl is enabled 106e66d8631SMauro Carvalho Chehab by default if CONFIG_EROFS_FS_POSIX_ACL is selected. 107e66d8631SMauro Carvalho Chehabcache_strategy=%s Select a strategy for cached decompression from now on: 108e66d8631SMauro Carvalho Chehab 109e66d8631SMauro Carvalho Chehab ========== ============================================= 110e66d8631SMauro Carvalho Chehab disabled In-place I/O decompression only; 111e66d8631SMauro Carvalho Chehab readahead Cache the last incomplete compressed physical 112e66d8631SMauro Carvalho Chehab cluster for further reading. It still does 113e66d8631SMauro Carvalho Chehab in-place I/O decompression for the rest 114e66d8631SMauro Carvalho Chehab compressed physical clusters; 115e66d8631SMauro Carvalho Chehab readaround Cache the both ends of incomplete compressed 116e66d8631SMauro Carvalho Chehab physical clusters for further reading. 117e66d8631SMauro Carvalho Chehab It still does in-place I/O decompression 118e66d8631SMauro Carvalho Chehab for the rest compressed physical clusters. 119e66d8631SMauro Carvalho Chehab ========== ============================================= 12006252e9cSGao Xiangdax={always,never} Use direct access (no page cache). See 12106252e9cSGao Xiang Documentation/filesystems/dax.rst. 12206252e9cSGao Xiangdax A legacy option which is an alias for ``dax=always``. 123dfeab2e9SGao Xiangdevice=%s Specify a path to an extra device to be used together. 1246e95d0a0SGao Xiangfsid=%s Specify a filesystem image ID for Fscache back-end. 125b22c7b97SJingbo Xudomain_id=%s Specify a domain ID in fscache mode so that different images 126b22c7b97SJingbo Xu with the same blobs under a given domain ID can share storage. 127e66d8631SMauro Carvalho Chehab=================== ========================================================= 128e66d8631SMauro Carvalho Chehab 129168e9a76SHuang JiananSysfs Entries 130168e9a76SHuang Jianan============= 131168e9a76SHuang Jianan 132168e9a76SHuang JiananInformation about mounted erofs file systems can be found in /sys/fs/erofs. 133168e9a76SHuang JiananEach mounted filesystem will have a directory in /sys/fs/erofs based on its 134168e9a76SHuang Jianandevice name (i.e., /sys/fs/erofs/sda). 135168e9a76SHuang Jianan(see also Documentation/ABI/testing/sysfs-fs-erofs) 136168e9a76SHuang Jianan 137e66d8631SMauro Carvalho ChehabOn-disk details 138e66d8631SMauro Carvalho Chehab=============== 139e66d8631SMauro Carvalho Chehab 140e66d8631SMauro Carvalho ChehabSummary 141e66d8631SMauro Carvalho Chehab------- 142e66d8631SMauro Carvalho ChehabDifferent from other read-only file systems, an EROFS volume is designed 143e66d8631SMauro Carvalho Chehabto be as simple as possible:: 144e66d8631SMauro Carvalho Chehab 145e66d8631SMauro Carvalho Chehab |-> aligned with the block size 146e66d8631SMauro Carvalho Chehab ____________________________________________________________ 147e66d8631SMauro Carvalho Chehab | |SB| | ... | Metadata | ... | Data | Metadata | ... | Data | 148e66d8631SMauro Carvalho Chehab |_|__|_|_____|__________|_____|______|__________|_____|______| 149e66d8631SMauro Carvalho Chehab 0 +1K 150e66d8631SMauro Carvalho Chehab 151e66d8631SMauro Carvalho ChehabAll data areas should be aligned with the block size, but metadata areas 152e66d8631SMauro Carvalho Chehabmay not. All metadatas can be now observed in two different spaces (views): 153e66d8631SMauro Carvalho Chehab 154e66d8631SMauro Carvalho Chehab 1. Inode metadata space 155e66d8631SMauro Carvalho Chehab 156e66d8631SMauro Carvalho Chehab Each valid inode should be aligned with an inode slot, which is a fixed 157e66d8631SMauro Carvalho Chehab value (32 bytes) and designed to be kept in line with compact inode size. 158e66d8631SMauro Carvalho Chehab 159e66d8631SMauro Carvalho Chehab Each inode can be directly found with the following formula: 160e66d8631SMauro Carvalho Chehab inode offset = meta_blkaddr * block_size + 32 * nid 161e66d8631SMauro Carvalho Chehab 162e66d8631SMauro Carvalho Chehab :: 163e66d8631SMauro Carvalho Chehab 164e66d8631SMauro Carvalho Chehab |-> aligned with 8B 165e66d8631SMauro Carvalho Chehab |-> followed closely 166e66d8631SMauro Carvalho Chehab + meta_blkaddr blocks |-> another slot 167e66d8631SMauro Carvalho Chehab _____________________________________________________________________ 168e66d8631SMauro Carvalho Chehab | ... | inode | xattrs | extents | data inline | ... | inode ... 169e66d8631SMauro Carvalho Chehab |________|_______|(optional)|(optional)|__(optional)_|_____|__________ 170e66d8631SMauro Carvalho Chehab |-> aligned with the inode slot size 171e66d8631SMauro Carvalho Chehab . . 172e66d8631SMauro Carvalho Chehab . . 173e66d8631SMauro Carvalho Chehab . . 174e66d8631SMauro Carvalho Chehab . . 175e66d8631SMauro Carvalho Chehab . . 176e66d8631SMauro Carvalho Chehab . . 177e66d8631SMauro Carvalho Chehab .____________________________________________________|-> aligned with 4B 178e66d8631SMauro Carvalho Chehab | xattr_ibody_header | shared xattrs | inline xattrs | 179e66d8631SMauro Carvalho Chehab |____________________|_______________|_______________| 180e66d8631SMauro Carvalho Chehab |-> 12 bytes <-|->x * 4 bytes<-| . 181e66d8631SMauro Carvalho Chehab . . . 182e66d8631SMauro Carvalho Chehab . . . 183e66d8631SMauro Carvalho Chehab . . . 184e66d8631SMauro Carvalho Chehab ._______________________________.______________________. 185e66d8631SMauro Carvalho Chehab | id | id | id | id | ... | id | ent | ... | ent| ... | 186e66d8631SMauro Carvalho Chehab |____|____|____|____|______|____|_____|_____|____|_____| 187e66d8631SMauro Carvalho Chehab |-> aligned with 4B 188e66d8631SMauro Carvalho Chehab |-> aligned with 4B 189e66d8631SMauro Carvalho Chehab 190e66d8631SMauro Carvalho Chehab Inode could be 32 or 64 bytes, which can be distinguished from a common 191e66d8631SMauro Carvalho Chehab field which all inode versions have -- i_format:: 192e66d8631SMauro Carvalho Chehab 193e66d8631SMauro Carvalho Chehab __________________ __________________ 194e66d8631SMauro Carvalho Chehab | i_format | | i_format | 195e66d8631SMauro Carvalho Chehab |__________________| |__________________| 196e66d8631SMauro Carvalho Chehab | ... | | ... | 197e66d8631SMauro Carvalho Chehab | | | | 198e66d8631SMauro Carvalho Chehab |__________________| 32 bytes | | 199e66d8631SMauro Carvalho Chehab | | 200e66d8631SMauro Carvalho Chehab |__________________| 64 bytes 201e66d8631SMauro Carvalho Chehab 202e66d8631SMauro Carvalho Chehab Xattrs, extents, data inline are followed by the corresponding inode with 203e66d8631SMauro Carvalho Chehab proper alignment, and they could be optional for different data mappings. 2042a9dc7a8SGao Xiang _currently_ total 5 data layouts are supported: 205e66d8631SMauro Carvalho Chehab 206e66d8631SMauro Carvalho Chehab == ==================================================================== 207e66d8631SMauro Carvalho Chehab 0 flat file data without data inline (no extent); 208e66d8631SMauro Carvalho Chehab 1 fixed-sized output data compression (with non-compacted indexes); 209e66d8631SMauro Carvalho Chehab 2 flat file data with tail packing data inline (no extent); 2102a9dc7a8SGao Xiang 3 fixed-sized output data compression (with compacted indexes, v5.3+); 2112a9dc7a8SGao Xiang 4 chunk-based file (v5.15+). 212e66d8631SMauro Carvalho Chehab == ==================================================================== 213e66d8631SMauro Carvalho Chehab 214e66d8631SMauro Carvalho Chehab The size of the optional xattrs is indicated by i_xattr_count in inode 215e66d8631SMauro Carvalho Chehab header. Large xattrs or xattrs shared by many different files can be 216e66d8631SMauro Carvalho Chehab stored in shared xattrs metadata rather than inlined right after inode. 217e66d8631SMauro Carvalho Chehab 218e66d8631SMauro Carvalho Chehab 2. Shared xattrs metadata space 219e66d8631SMauro Carvalho Chehab 220e66d8631SMauro Carvalho Chehab Shared xattrs space is similar to the above inode space, started with 221e66d8631SMauro Carvalho Chehab a specific block indicated by xattr_blkaddr, organized one by one with 222e66d8631SMauro Carvalho Chehab proper align. 223e66d8631SMauro Carvalho Chehab 224e66d8631SMauro Carvalho Chehab Each share xattr can also be directly found by the following formula: 225e66d8631SMauro Carvalho Chehab xattr offset = xattr_blkaddr * block_size + 4 * xattr_id 226e66d8631SMauro Carvalho Chehab 227e66d8631SMauro Carvalho Chehab:: 228e66d8631SMauro Carvalho Chehab 229e66d8631SMauro Carvalho Chehab |-> aligned by 4 bytes 230e66d8631SMauro Carvalho Chehab + xattr_blkaddr blocks |-> aligned with 4 bytes 231e66d8631SMauro Carvalho Chehab _________________________________________________________________________ 232e66d8631SMauro Carvalho Chehab | ... | xattr_entry | xattr data | ... | xattr_entry | xattr data ... 233e66d8631SMauro Carvalho Chehab |________|_____________|_____________|_____|______________|_______________ 234e66d8631SMauro Carvalho Chehab 235e66d8631SMauro Carvalho ChehabDirectories 236e66d8631SMauro Carvalho Chehab----------- 237e66d8631SMauro Carvalho ChehabAll directories are now organized in a compact on-disk format. Note that 238e66d8631SMauro Carvalho Chehabeach directory block is divided into index and name areas in order to support 239e66d8631SMauro Carvalho Chehabrandom file lookup, and all directory entries are _strictly_ recorded in 240e66d8631SMauro Carvalho Chehabalphabetical order in order to support improved prefix binary search 241e66d8631SMauro Carvalho Chehabalgorithm (could refer to the related source code). 242e66d8631SMauro Carvalho Chehab 243e66d8631SMauro Carvalho Chehab:: 244e66d8631SMauro Carvalho Chehab 245e66d8631SMauro Carvalho Chehab ___________________________ 246e66d8631SMauro Carvalho Chehab / | 247e66d8631SMauro Carvalho Chehab / ______________|________________ 248e66d8631SMauro Carvalho Chehab / / | nameoff1 | nameoffN-1 249e66d8631SMauro Carvalho Chehab ____________.______________._______________v________________v__________ 250e66d8631SMauro Carvalho Chehab | dirent | dirent | ... | dirent | filename | filename | ... | filename | 251e66d8631SMauro Carvalho Chehab |___.0___|____1___|_____|___N-1__|____0_____|____1_____|_____|___N-1____| 252e66d8631SMauro Carvalho Chehab \ ^ 253e66d8631SMauro Carvalho Chehab \ | * could have 254e66d8631SMauro Carvalho Chehab \ | trailing '\0' 255e66d8631SMauro Carvalho Chehab \________________________| nameoff0 256e66d8631SMauro Carvalho Chehab Directory block 257e66d8631SMauro Carvalho Chehab 258e66d8631SMauro Carvalho ChehabNote that apart from the offset of the first filename, nameoff0 also indicates 259e66d8631SMauro Carvalho Chehabthe total number of directory entries in this block since it is no need to 260e66d8631SMauro Carvalho Chehabintroduce another on-disk field at all. 261e66d8631SMauro Carvalho Chehab 2626e95d0a0SGao XiangChunk-based files 2636e95d0a0SGao Xiang----------------- 2642a9dc7a8SGao XiangIn order to support chunk-based data deduplication, a new inode data layout has 2652a9dc7a8SGao Xiangbeen supported since Linux v5.15: Files are split in equal-sized data chunks 2662a9dc7a8SGao Xiangwith ``extents`` area of the inode metadata indicating how to get the chunk 2672a9dc7a8SGao Xiangdata: these can be simply as a 4-byte block address array or in the 8-byte 2682a9dc7a8SGao Xiangchunk index form (see struct erofs_inode_chunk_index in erofs_fs.h for more 2692a9dc7a8SGao Xiangdetails.) 2702a9dc7a8SGao Xiang 2712a9dc7a8SGao XiangBy the way, chunk-based files are all uncompressed for now. 2722a9dc7a8SGao Xiang 273*3048102dSJingbo XuLong extended attribute name prefixes 274*3048102dSJingbo Xu------------------------------------- 275*3048102dSJingbo XuThere are use cases where extended attributes with different values can have 276*3048102dSJingbo Xuonly a few common prefixes (such as overlayfs xattrs). The predefined prefixes 277*3048102dSJingbo Xuwork inefficiently in both image size and runtime performance in such cases. 278*3048102dSJingbo Xu 279*3048102dSJingbo XuThe long xattr name prefixes feature is introduced to address this issue. The 280*3048102dSJingbo Xuoverall idea is that, apart from the existing predefined prefixes, the xattr 281*3048102dSJingbo Xuentry could also refer to user-specified long xattr name prefixes, e.g. 282*3048102dSJingbo Xu"trusted.overlay.". 283*3048102dSJingbo Xu 284*3048102dSJingbo XuWhen referring to a long xattr name prefix, the highest bit (bit 7) of 285*3048102dSJingbo Xuerofs_xattr_entry.e_name_index is set, while the lower bits (bit 0-6) as a whole 286*3048102dSJingbo Xurepresent the index of the referred long name prefix among all long name 287*3048102dSJingbo Xuprefixes. Therefore, only the trailing part of the name apart from the long 288*3048102dSJingbo Xuxattr name prefix is stored in erofs_xattr_entry.e_name, which could be empty if 289*3048102dSJingbo Xuthe full xattr name matches exactly as its long xattr name prefix. 290*3048102dSJingbo Xu 291*3048102dSJingbo XuAll long xattr prefixes are stored one by one in the packed inode as long as 292*3048102dSJingbo Xuthe packed inode is valid, or in the meta inode otherwise. The 293*3048102dSJingbo Xuxattr_prefix_count (of the on-disk superblock) indicates the total number of 294*3048102dSJingbo Xulong xattr name prefixes, while (xattr_prefix_start * 4) indicates the start 295*3048102dSJingbo Xuoffset of long name prefixes in the packed/meta inode. Note that, long extended 296*3048102dSJingbo Xuattribute name prefixes are disabled if xattr_prefix_count is 0. 297*3048102dSJingbo Xu 298*3048102dSJingbo XuEach long name prefix is stored in the format: ALIGN({__le16 len, data}, 4), 299*3048102dSJingbo Xuwhere len represents the total size of the data part. The data part is actually 300*3048102dSJingbo Xurepresented by 'struct erofs_xattr_long_prefix', where base_index represents the 301*3048102dSJingbo Xuindex of the predefined xattr name prefix, e.g. EROFS_XATTR_INDEX_TRUSTED for 302*3048102dSJingbo Xu"trusted.overlay." long name prefix, while the infix string keeps the string 303*3048102dSJingbo Xuafter stripping the short prefix, e.g. "overlay." for the example above. 304*3048102dSJingbo Xu 30546f2e044SGao XiangData compression 30646f2e044SGao Xiang---------------- 3072109901dSGao XiangEROFS implements fixed-sized output compression which generates fixed-sized 30846f2e044SGao Xiangcompressed data blocks from variable-sized input in contrast to other existing 30946f2e044SGao Xiangfixed-sized input solutions. Relatively higher compression ratios can be gotten 31046f2e044SGao Xiangby using fixed-sized output compression since nowadays popular data compression 31146f2e044SGao Xiangalgorithms are mostly LZ77-based and such fixed-sized output approach can be 31246f2e044SGao Xiangbenefited from the historical dictionary (aka. sliding window). 31346f2e044SGao Xiang 31446f2e044SGao XiangIn details, original (uncompressed) data is turned into several variable-sized 31546f2e044SGao Xiangextents and in the meanwhile, compressed into physical clusters (pclusters). 31646f2e044SGao XiangIn order to record each variable-sized extent, logical clusters (lclusters) are 31746f2e044SGao Xiangintroduced as the basic unit of compress indexes to indicate whether a new 31846f2e044SGao Xiangextent is generated within the range (HEAD) or not (NONHEAD). Lclusters are now 31946f2e044SGao Xiangfixed in block size, as illustrated below:: 320e66d8631SMauro Carvalho Chehab 3211b55767dSGao Xiang |<- variable-sized extent ->|<- VLE ->| 322e66d8631SMauro Carvalho Chehab clusterofs clusterofs clusterofs 3231b55767dSGao Xiang | | | 3241b55767dSGao Xiang _________v_________________________________v_______________________v________ 3251b55767dSGao Xiang ... | . | | . | | . ... 3261b55767dSGao Xiang ____|____._________|______________|________.___ _|______________|__.________ 3271b55767dSGao Xiang |-> lcluster <-|-> lcluster <-|-> lcluster <-|-> lcluster <-| 32846f2e044SGao Xiang (HEAD) (NONHEAD) (HEAD) (NONHEAD) . 32946f2e044SGao Xiang . CBLKCNT . . 33046f2e044SGao Xiang . . . 33146f2e044SGao Xiang . . . 33246f2e044SGao Xiang _______._____________________________.______________._________________ 3331b55767dSGao Xiang ... | | | | ... 3341b55767dSGao Xiang _______|______________|______________|______________|_________________ 33546f2e044SGao Xiang |-> big pcluster <-|-> pcluster <-| 336e66d8631SMauro Carvalho Chehab 33746f2e044SGao XiangA physical cluster can be seen as a container of physical compressed blocks 33846f2e044SGao Xiangwhich contains compressed data. Previously, only lcluster-sized (4KB) pclusters 33946f2e044SGao Xiangwere supported. After big pcluster feature is introduced (available since 34046f2e044SGao XiangLinux v5.13), pcluster can be a multiple of lcluster size. 341e66d8631SMauro Carvalho Chehab 34246f2e044SGao XiangFor each HEAD lcluster, clusterofs is recorded to indicate where a new extent 34346f2e044SGao Xiangstarts and blkaddr is used to seek the compressed data. For each NONHEAD 34446f2e044SGao Xianglcluster, delta0 and delta1 are available instead of blkaddr to indicate the 34546f2e044SGao Xiangdistance to its HEAD lcluster and the next HEAD lcluster. A PLAIN lcluster is 34646f2e044SGao Xiangalso a HEAD lcluster except that its data is uncompressed. See the comments 34746f2e044SGao Xiangaround "struct z_erofs_vle_decompressed_index" in erofs_fs.h for more details. 34846f2e044SGao Xiang 34946f2e044SGao XiangIf big pcluster is enabled, pcluster size in lclusters needs to be recorded as 35046f2e044SGao Xiangwell. Let the delta0 of the first NONHEAD lcluster store the compressed block 35146f2e044SGao Xiangcount with a special flag as a new called CBLKCNT NONHEAD lcluster. It's easy 35246f2e044SGao Xiangto understand its delta0 is constantly 1, as illustrated below:: 35346f2e044SGao Xiang 35446f2e044SGao Xiang __________________________________________________________ 35546f2e044SGao Xiang | HEAD | NONHEAD | NONHEAD | ... | NONHEAD | HEAD | HEAD | 35646f2e044SGao Xiang |__:___|_(CBLKCNT)_|_________|_____|_________|__:___|____:_| 35746f2e044SGao Xiang |<----- a big pcluster (with CBLKCNT) ------>|<-- -->| 35846f2e044SGao Xiang a lcluster-sized pcluster (without CBLKCNT) ^ 35946f2e044SGao Xiang 36046f2e044SGao XiangIf another HEAD follows a HEAD lcluster, there is no room to record CBLKCNT, 36146f2e044SGao Xiangbut it's easy to know the size of such pcluster is 1 lcluster as well. 3622109901dSGao Xiang 3632109901dSGao XiangSince Linux v6.1, each pcluster can be used for multiple variable-sized extents, 3642109901dSGao Xiangtherefore it can be used for compressed data deduplication. 365