xref: /OK3568_Linux_fs/kernel/Documentation/filesystems/ext4/inlinedata.rst (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun.. SPDX-License-Identifier: GPL-2.0
2*4882a593Smuzhiyun
3*4882a593SmuzhiyunInline Data
4*4882a593Smuzhiyun-----------
5*4882a593Smuzhiyun
6*4882a593SmuzhiyunThe inline data feature was designed to handle the case that a file's
7*4882a593Smuzhiyundata is so tiny that it readily fits inside the inode, which
8*4882a593Smuzhiyun(theoretically) reduces disk block consumption and reduces seeks. If the
9*4882a593Smuzhiyunfile is smaller than 60 bytes, then the data are stored inline in
10*4882a593Smuzhiyun``inode.i_block``. If the rest of the file would fit inside the extended
11*4882a593Smuzhiyunattribute space, then it might be found as an extended attribute
12*4882a593Smuzhiyunsystem.data” within the inode body (“ibody EA”). This of course
13*4882a593Smuzhiyunconstrains the amount of extended attributes one can attach to an inode.
14*4882a593SmuzhiyunIf the data size increases beyond i\_block + ibody EA, a regular block
15*4882a593Smuzhiyunis allocated and the contents moved to that block.
16*4882a593Smuzhiyun
17*4882a593SmuzhiyunPending a change to compact the extended attribute key used to store
18*4882a593Smuzhiyuninline data, one ought to be able to store 160 bytes of data in a
19*4882a593Smuzhiyun256-byte inode (as of June 2015, when i\_extra\_isize is 28). Prior to
20*4882a593Smuzhiyunthat, the limit was 156 bytes due to inefficient use of inode space.
21*4882a593Smuzhiyun
22*4882a593SmuzhiyunThe inline data feature requires the presence of an extended attribute
23*4882a593Smuzhiyunfor “system.data”, even if the attribute value is zero length.
24*4882a593Smuzhiyun
25*4882a593SmuzhiyunInline Directories
26*4882a593Smuzhiyun~~~~~~~~~~~~~~~~~~
27*4882a593Smuzhiyun
28*4882a593SmuzhiyunThe first four bytes of i\_block are the inode number of the parent
29*4882a593Smuzhiyundirectory. Following that is a 56-byte space for an array of directory
30*4882a593Smuzhiyunentries; see ``struct ext4_dir_entry``. If there is a “system.data31*4882a593Smuzhiyunattribute in the inode body, the EA value is an array of
32*4882a593Smuzhiyun``struct ext4_dir_entry`` as well. Note that for inline directories, the
33*4882a593Smuzhiyuni\_block and EA space are treated as separate dirent blocks; directory
34*4882a593Smuzhiyunentries cannot span the two.
35*4882a593Smuzhiyun
36*4882a593SmuzhiyunInline directory entries are not checksummed, as the inode checksum
37*4882a593Smuzhiyunshould protect all inline data contents.
38