{
  "slug": "ext4-orphan-file",
  "term": "Ext4 orphan file",
  "aliases": [
    "orphan_file",
    "COMPAT_ORPHAN_FILE"
  ],
  "definition": "An ext4 orphan file is an internal metadata file that stores inode-number slots for orphan cleanup when the orphan_file filesystem feature is enabled.",
  "note": "The legacy orphan list starts at s_last_orphan and uses each inode's i_dtime field as a next-inode link. The orphan file instead uses the special inode referenced by s_orphan_file_inum; a zero slot is unused. RO_COMPAT_ORPHAN_PRESENT indicates that entries may require recovery, not that an orphan definitely exists. It is set during writable use and cleared on clean unmount. [linux-ext4-orphan-layout] Unlike COMPAT_ORPHAN_FILE, an unknown RO_COMPAT_ORPHAN_PRESENT bit prevents an older kernel from mounting read-write; clearing it removes this barrier, not restrictions from other features or older checking tools. [linux-ext4-superblock]\n\nLinux v6.12 falls back to the legacy list when orphan-file insertion returns ENOSPC. Here ENOSPC can mean no available orphan-file slots or a bounded slot search giving up, not necessarily filesystem-wide space exhaustion. This insertion path does not dynamically grow the preallocated orphan file, and fallback does not itself establish a user-visible operation failure. [linux-v6-12-ext4-orphan] See the paired recovery analysis. [hesela-ext4-orphan-cleanup]\n\nCapacity: a B-byte block reserves eight tail bytes, leaving (B - 8) / 4 inode slots: 1,022 at 4 KiB. [linux-orphan-capacity-layout] At Linux commit ca20d5a011d3, the size guard rejects files above max(512 x B, 2 MiB), not above 512 blocks universally: 1 KiB blocks allow 2,048 blocks through this guard. Passing it alone does not establish valid metadata or successful recovery. [linux-orphan-capacity-guard]",
  "status": "shipping",
  "advantages": [],
  "limitations": [
    {
      "text": "The feature changes recovery bookkeeping, not unlink semantics or application synchronization requirements.",
      "citationIds": [
        "linux-ext4-orphan-layout",
        "linux-unlink-2",
        "linux-fsync-2"
      ]
    }
  ],
  "related": [
    "ext4-orphan-inode",
    "inode",
    "unlink",
    "ext4"
  ],
  "supersedes": [],
  "supersededBy": [],
  "firstSeen": null,
  "lastSeen": null,
  "citations": [
    {
      "id": "linux-ext4-orphan-layout",
      "title": "Linux ext4 documentation: Orphan file (v6.12)",
      "url": "https://github.com/torvalds/linux/blob/adc218676eef25575469234709c2d87185ca223a/Documentation/filesystems/ext4/orphan.rst",
      "accessed": "2026-10-15"
    },
    {
      "id": "linux-v6-12-ext4-orphan",
      "title": "Linux v6.12: ext4 orphan inode handling",
      "url": "https://github.com/torvalds/linux/blob/adc218676eef25575469234709c2d87185ca223a/fs/ext4/orphan.c",
      "accessed": "2026-10-15"
    },
    {
      "id": "linux-ext4-superblock",
      "title": "Linux ext4 documentation: Super block feature compatibility (v6.12)",
      "url": "https://github.com/torvalds/linux/blob/adc218676eef25575469234709c2d87185ca223a/Documentation/filesystems/ext4/super.rst",
      "accessed": "2026-10-15"
    },
    {
      "id": "linux-unlink-2",
      "title": "Linux manual: unlink(2)",
      "url": "https://man7.org/linux/man-pages/man2/unlink.2.html",
      "accessed": "2026-10-15"
    },
    {
      "id": "linux-fsync-2",
      "title": "Linux manual: fsync(2)",
      "url": "https://man7.org/linux/man-pages/man2/fsync.2.html",
      "accessed": "2026-10-15"
    },
    {
      "id": "hesela-ext4-orphan-cleanup",
      "title": "Hesela: ext4 journal replay and orphan cleanup",
      "url": "https://hesela.com/analyses/ext4-journal-replay-revocation/#orphan-cleanup",
      "accessed": "2026-10-15"
    },
    {
      "id": "linux-orphan-capacity-layout",
      "title": "Linux ca20d5a011d3: orphan-block tail and slot count",
      "url": "https://github.com/torvalds/linux/blob/ca20d5a011d35fc25e328fe31ac47f7aae557c5a/fs/ext4/ext4.h#L1545-L1557",
      "accessed": "2026-11-30"
    },
    {
      "id": "linux-orphan-capacity-guard",
      "title": "Linux ca20d5a011d3: orphan-file initialization and size guard",
      "url": "https://github.com/torvalds/linux/blob/ca20d5a011d35fc25e328fe31ac47f7aae557c5a/fs/ext4/orphan.c#L577-L661",
      "accessed": "2026-11-30"
    },
    {
      "id": "hesela-orphan-capacity",
      "title": "Hesela: reproducible ext4 orphan-file capacity arithmetic and version boundaries",
      "url": "https://hesela.dev/research/ext4-orphan-capacity/README.md",
      "accessed": "2026-11-30"
    }
  ],
  "updated": "2026-11-30",
  "provenance": [
    "The capacity calculation is on-disk layout arithmetic, not a mounted-filesystem experiment or throughput measurement. The size guard is pinned to ca20d5a011d3; Linux v6.12 and intervening revisions have different checks."
  ]
}
