~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/Documentation/filesystems/ext4/orphan.rst

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 .. SPDX-License-Identifier: GPL-2.0
  2 
  3 Orphan file
  4 -----------
  5 
  6 In unix there can inodes that are unlinked from directory hierarchy but that
  7 are still alive because they are open. In case of crash the filesystem has to
  8 clean up these inodes as otherwise they (and the blocks referenced from them)
  9 would leak. Similarly if we truncate or extend the file, we need not be able
 10 to perform the operation in a single journalling transaction. In such case we
 11 track the inode as orphan so that in case of crash extra blocks allocated to
 12 the file get truncated.
 13 
 14 Traditionally ext4 tracks orphan inodes in a form of single linked list where
 15 superblock contains the inode number of the last orphan inode (s_last_orphan
 16 field) and then each inode contains inode number of the previously orphaned
 17 inode (we overload i_dtime inode field for this). However this filesystem
 18 global single linked list is a scalability bottleneck for workloads that result
 19 in heavy creation of orphan inodes. When orphan file feature
 20 (COMPAT_ORPHAN_FILE) is enabled, the filesystem has a special inode
 21 (referenced from the superblock through s_orphan_file_inum) with several
 22 blocks. Each of these blocks has a structure:
 23 
 24 ============= ================ =============== ===============================
 25 Offset        Type             Name            Description
 26 ============= ================ =============== ===============================
 27 0x0           Array of         Orphan inode    Each __le32 entry is either
 28               __le32 entries   entries         empty (0) or it contains
 29                                                inode number of an orphan
 30                                                inode.
 31 blocksize-8   __le32           ob_magic        Magic value stored in orphan
 32                                                block tail (0x0b10ca04)
 33 blocksize-4   __le32           ob_checksum     Checksum of the orphan block.
 34 ============= ================ =============== ===============================
 35 
 36 When a filesystem with orphan file feature is writeably mounted, we set
 37 RO_COMPAT_ORPHAN_PRESENT feature in the superblock to indicate there may
 38 be valid orphan entries. In case we see this feature when mounting the
 39 filesystem, we read the whole orphan file and process all orphan inodes found
 40 there as usual. When cleanly unmounting the filesystem we remove the
 41 RO_COMPAT_ORPHAN_PRESENT feature to avoid unnecessary scanning of the orphan
 42 file and also make the filesystem fully compatible with older kernels.

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php