Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) .. SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) =======================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) Squashfs 4.0 Filesystem
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) =======================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) Squashfs is a compressed read-only filesystem for Linux.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) It uses zlib, lz4, lzo, or xz compression to compress files, inodes and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) directories.  Inodes in the system are very small and all blocks are packed to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) minimise data overhead. Block sizes greater than 4K are supported up to a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) maximum of 1Mbytes (default block size 128K).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) Squashfs is intended for general read-only filesystem use, for archival
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) use (i.e. in cases where a .tar.gz file may be used), and in constrained
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) block device/memory systems (e.g. embedded systems) where low overhead is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) needed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) Mailing list: squashfs-devel@lists.sourceforge.net
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) Web site: www.squashfs.org
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 1. Filesystem Features
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) ----------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) Squashfs filesystem features versus Cramfs:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) ============================== 	=========		==========
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 				Squashfs		Cramfs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) ============================== 	=========		==========
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) Max filesystem size		2^64			256 MiB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) Max file size			~ 2 TiB			16 MiB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) Max files			unlimited		unlimited
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) Max directories			unlimited		unlimited
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) Max entries per directory	unlimited		unlimited
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) Max block size			1 MiB			4 KiB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) Metadata compression		yes			no
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) Directory indexes		yes			no
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) Sparse file support		yes			no
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) Tail-end packing (fragments)	yes			no
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) Exportable (NFS etc.)		yes			no
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) Hard link support		yes			no
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) "." and ".." in readdir		yes			no
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) Real inode numbers		yes			no
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 32-bit uids/gids		yes			no
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) File creation time		yes			no
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) Xattr support			yes			no
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) ACL support			no			no
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) ============================== 	=========		==========
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) Squashfs compresses data, inodes and directories.  In addition, inode and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) directory data are highly compacted, and packed on byte boundaries.  Each
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) compressed inode is on average 8 bytes in length (the exact length varies on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) file type, i.e. regular file, directory, symbolic link, and block/char device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) inodes have different sizes).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 2. Using Squashfs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) -----------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) As squashfs is a read-only filesystem, the mksquashfs program must be used to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) create populated squashfs filesystems.  This and other squashfs utilities
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) can be obtained from http://www.squashfs.org.  Usage instructions can be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) obtained from this site also.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) The squashfs-tools development tree is now located on kernel.org
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	git://git.kernel.org/pub/scm/fs/squashfs/squashfs-tools.git
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 3. Squashfs Filesystem Design
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) -----------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) A squashfs filesystem consists of a maximum of nine parts, packed together on a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) byte alignment::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	 ---------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	|  superblock 	|
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	|---------------|
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	|  compression  |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	|    options    |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	|---------------|
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	|  datablocks   |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	|  & fragments  |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	|---------------|
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	|  inode table	|
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	|---------------|
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	|   directory	|
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	|     table     |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	|---------------|
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	|   fragment	|
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	|    table      |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	|---------------|
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	|    export     |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	|    table      |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	|---------------|
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	|    uid/gid	|
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	|  lookup table	|
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	|---------------|
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	|     xattr     |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	|     table	|
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	 ---------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) Compressed data blocks are written to the filesystem as files are read from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) the source directory, and checked for duplicates.  Once all file data has been
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) written the completed inode, directory, fragment, export, uid/gid lookup and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) xattr tables are written.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 3.1 Compression options
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) -----------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) Compressors can optionally support compression specific options (e.g.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) dictionary size).  If non-default compression options have been used, then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) these are stored here.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 3.2 Inodes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) ----------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) Metadata (inodes and directories) are compressed in 8Kbyte blocks.  Each
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) compressed block is prefixed by a two byte length, the top bit is set if the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) block is uncompressed.  A block will be uncompressed if the -noI option is set,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) or if the compressed block was larger than the uncompressed block.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) Inodes are packed into the metadata blocks, and are not aligned to block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) boundaries, therefore inodes overlap compressed blocks.  Inodes are identified
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) by a 48-bit number which encodes the location of the compressed metadata block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) containing the inode, and the byte offset into that block where the inode is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) placed (<block, offset>).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) To maximise compression there are different inodes for each file type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) (regular file, directory, device, etc.), the inode contents and length
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) varying with the type.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) To further maximise compression, two types of regular file inode and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) directory inode are defined: inodes optimised for frequently occurring
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) regular files and directories, and extended types where extra
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) information has to be stored.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 3.3 Directories
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) ---------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) Like inodes, directories are packed into compressed metadata blocks, stored
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) in a directory table.  Directories are accessed using the start address of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) the metablock containing the directory and the offset into the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) decompressed block (<block, offset>).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) Directories are organised in a slightly complex way, and are not simply
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) a list of file names.  The organisation takes advantage of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) fact that (in most cases) the inodes of the files will be in the same
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) compressed metadata block, and therefore, can share the start block.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) Directories are therefore organised in a two level list, a directory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) header containing the shared start block value, and a sequence of directory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) entries, each of which share the shared start block.  A new directory header
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) is written once/if the inode start block changes.  The directory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) header/directory entry list is repeated as many times as necessary.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) Directories are sorted, and can contain a directory index to speed up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) file lookup.  Directory indexes store one entry per metablock, each entry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) storing the index/filename mapping to the first directory header
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) in each metadata block.  Directories are sorted in alphabetical order,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) and at lookup the index is scanned linearly looking for the first filename
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) alphabetically larger than the filename being looked up.  At this point the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) location of the metadata block the filename is in has been found.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) The general idea of the index is to ensure only one metadata block needs to be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) decompressed to do a lookup irrespective of the length of the directory.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) This scheme has the advantage that it doesn't require extra memory overhead
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) and doesn't require much extra storage on disk.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 3.4 File data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) -------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) Regular files consist of a sequence of contiguous compressed blocks, and/or a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) compressed fragment block (tail-end packed block).   The compressed size
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) of each datablock is stored in a block list contained within the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) file inode.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) To speed up access to datablocks when reading 'large' files (256 Mbytes or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) larger), the code implements an index cache that caches the mapping from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) block index to datablock location on disk.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) The index cache allows Squashfs to handle large files (up to 1.75 TiB) while
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) retaining a simple and space-efficient block list on disk.  The cache
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) is split into slots, caching up to eight 224 GiB files (128 KiB blocks).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) Larger files use multiple slots, with 1.75 TiB files using all 8 slots.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) The index cache is designed to be memory efficient, and by default uses
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 16 KiB.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 3.5 Fragment lookup table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) -------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) Regular files can contain a fragment index which is mapped to a fragment
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) location on disk and compressed size using a fragment lookup table.  This
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) fragment lookup table is itself stored compressed into metadata blocks.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) A second index table is used to locate these.  This second index table for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) speed of access (and because it is small) is read at mount time and cached
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) in memory.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 3.6 Uid/gid lookup table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) ------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) For space efficiency regular files store uid and gid indexes, which are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) converted to 32-bit uids/gids using an id look up table.  This table is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) stored compressed into metadata blocks.  A second index table is used to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) locate these.  This second index table for speed of access (and because it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) is small) is read at mount time and cached in memory.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 3.7 Export table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) ----------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) To enable Squashfs filesystems to be exportable (via NFS etc.) filesystems
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) can optionally (disabled with the -no-exports Mksquashfs option) contain
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) an inode number to inode disk location lookup table.  This is required to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) enable Squashfs to map inode numbers passed in filehandles to the inode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) location on disk, which is necessary when the export code reinstantiates
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) expired/flushed inodes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) This table is stored compressed into metadata blocks.  A second index table is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) used to locate these.  This second index table for speed of access (and because
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) it is small) is read at mount time and cached in memory.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 3.8 Xattr table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) ---------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) The xattr table contains extended attributes for each inode.  The xattrs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) for each inode are stored in a list, each list entry containing a type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) name and value field.  The type field encodes the xattr prefix
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) ("user.", "trusted." etc) and it also encodes how the name/value fields
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) should be interpreted.  Currently the type indicates whether the value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) is stored inline (in which case the value field contains the xattr value),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) or if it is stored out of line (in which case the value field stores a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) reference to where the actual value is stored).  This allows large values
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) to be stored out of line improving scanning and lookup performance and it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) also allows values to be de-duplicated, the value being stored once, and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) all other occurrences holding an out of line reference to that value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) The xattr lists are packed into compressed 8K metadata blocks.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) To reduce overhead in inodes, rather than storing the on-disk
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) location of the xattr list inside each inode, a 32-bit xattr id
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) is stored.  This xattr id is mapped into the location of the xattr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) list using a second xattr id lookup table.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 4. TODOs and Outstanding Issues
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) -------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 4.1 TODO list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) -------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) Implement ACL support.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 4.2 Squashfs Internal Cache
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) ---------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) Blocks in Squashfs are compressed.  To avoid repeatedly decompressing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) recently accessed data Squashfs uses two small metadata and fragment caches.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) The cache is not used for file datablocks, these are decompressed and cached in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) the page-cache in the normal way.  The cache is used to temporarily cache
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) fragment and metadata blocks which have been read as a result of a metadata
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) (i.e. inode or directory) or fragment access.  Because metadata and fragments
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) are packed together into blocks (to gain greater compression) the read of a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) particular piece of metadata or fragment will retrieve other metadata/fragments
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) which have been packed with it, these because of locality-of-reference may be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) read in the near future. Temporarily caching them ensures they are available
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) for near future access without requiring an additional read and decompress.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) In the future this internal cache may be replaced with an implementation which
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) uses the kernel page cache.  Because the page cache operates on page sized
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) units this may introduce additional complexity in terms of locking and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) associated race conditions.