{
  "slug": "fiemap",
  "term": "FIEMAP",
  "aliases": [
    "FS_IOC_FIEMAP"
  ],
  "definition": "A Linux ioctl interface that reports file extent mappings and associated state flags over a requested logical byte range.",
  "note": "FIEMAP_FLAG_SYNC synchronizes before mapping, so the query can alter the observed state. DELALLOC also sets UNKNOWN; UNWRITTEN instead describes allocated zero-reading storage. Mappings can change between calls and are not permission to access a mounted filesystem through its block device. Record request flags and check for a full output buffer. Hesela's linked observation compares unsynchronized queries with explicit fsync and FIEMAP synchronization. In upstream Linux v6.8, fiemap_prep uses filemap_write_and_wait rather than fsync for this flag; it is not a substitute for a metadata-durability barrier.\n\nFIEMAP_FLAG_XATTR selects extended attributes, not the file-data tree. An empty attribute map does not prove absent file-data allocation. For range accounting, intersect returned logical extents with the requested interval; this gives logical overlap, not physical space saved. [fiemap-range-contract]\n\nHesela's single-file Linux/ext4 observation returned an empty attribute map alongside a nonempty data map. The data result marked LAST before the file's end. This is a recorded host-specific case, not an all-filesystem guarantee. [hesela-query-domain] The LAST flag may mark the range endpoint; a count query followed by a mapping query is not a snapshot. [fiemap-range-contract]\n\nSharing result: FIEMAP_EXTENT_SHARED (0x2000) is returned in fe_flags, not requested through fm_flags. It reports shared storage rather than asking for a clone. The ABI provides no reference count, so this bit alone cannot quantify deletion savings. [fiemap-uapi] [iomap-result]",
  "status": "shipping",
  "advantages": [],
  "limitations": [
    "A count-only query is not a stable snapshot for the following mapping call.",
    "Returned extents may cross the requested range; LAST can be range-scoped on some implementations."
  ],
  "related": [
    "file-extent",
    "delayed-allocation",
    "unwritten-extent",
    "fsync",
    "btrfs-filesystem-du"
  ],
  "supersedes": [],
  "supersededBy": [],
  "firstSeen": null,
  "lastSeen": null,
  "updated": "2026-11-21",
  "citations": [
    {
      "id": "fiemap-interface",
      "title": "Linux 6.12: FIEMAP ioctl, flags and access restrictions",
      "url": "https://docs.kernel.org/6.12/filesystems/fiemap.html",
      "accessed": "2026-10-16"
    },
    {
      "id": "hesela-observer",
      "title": "Hesela: measured FIEMAP observer intervention",
      "url": "https://hesela.com/analyses/sparse-files-preallocation-thin-capacity/#observer",
      "accessed": "2026-10-16"
    },
    {
      "id": "fiemap-writeback",
      "title": "Linux v6.8 fs/ioctl.c: fiemap_prep writeback implementation",
      "url": "https://raw.githubusercontent.com/torvalds/linux/v6.8/fs/ioctl.c",
      "accessed": "2026-10-16"
    },
    {
      "id": "fiemap-range-contract",
      "title": "Linux v6.18 FIEMAP: XATTR query domain and returned extents crossing requested bounds",
      "url": "https://www.kernel.org/doc/html/v6.18/filesystems/fiemap.html",
      "accessed": "2026-10-23"
    },
    {
      "id": "hesela-mapping-domain",
      "title": "Hesela: FIEMAP query domains and exact logical-range example",
      "url": "https://hesela.com/analyses/file-clones-deferred-copy-cost/#mapping-domain",
      "accessed": "2026-10-23"
    },
    {
      "id": "hesela-query-domain",
      "title": "Hesela: single-file FIEMAP query-domain observation, environment and source hash",
      "url": "https://hesela.dev/research/fiemap-query-domain.json",
      "accessed": "2026-10-23"
    },
    {
      "id": "fiemap-uapi",
      "title": "Linux v6.12: FIEMAP request flags, returned extent flags and SHARED bit",
      "url": "https://raw.githubusercontent.com/torvalds/linux/v6.12/include/uapi/linux/fiemap.h",
      "accessed": "2026-11-21"
    },
    {
      "id": "iomap-result",
      "title": "Linux v6.12: iomap_to_fiemap translates IOMAP_F_SHARED into a result flag",
      "url": "https://raw.githubusercontent.com/torvalds/linux/v6.12/fs/iomap/fiemap.c",
      "accessed": "2026-11-21"
    }
  ],
  "provenance": [
    "The SHARED interpretation is checked against the pinned UAPI and iomap implementation; the documentation's request wording is misleading.",
    "The lack of a reference count is an ABI observation; the deletion-savings limitation is an inference, not a measured filesystem result."
  ]
}
