FIEMAP
A Linux ioctl interface that reports file extent mappings and associated state flags over a requested logical byte range.
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.
FIEMAP_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. [4]
Hesela'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. [6] The LAST flag may mark the range endpoint; a count query followed by a mapping query is not a snapshot. [4]
Sharing 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. [7] [8]
Relations
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.
Citations
- Linux v6.18 FIEMAP: XATTR query domain and returned extents crossing requested bounds
- Hesela: single-file FIEMAP query-domain observation, environment and source hash
- Linux v6.12: FIEMAP request flags, returned extent flags and SHARED bit
- Linux v6.12: iomap_to_fiemap translates IOMAP_F_SHARED into a result flag
Further reading
- Linux 6.12: FIEMAP ioctl, flags and access restrictions
- Hesela: measured FIEMAP observer intervention
- Linux v6.8 fs/ioctl.c: fiemap_prep writeback implementation
- Hesela: FIEMAP query domains and exact logical-range example
Sources & caveats
- 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.