{
  "slug": "falloc-fl-collapse-range",
  "term": "FALLOC_FL_COLLAPSE_RANGE",
  "aliases": [
    "collapse range",
    "fallocate --collapse-range"
  ],
  "definition": "The Linux collapse-range operation removes a byte range from a Linux file, shifts later data left and reduces the file size.",
  "note": "Transformation: removing length L at offset O moves the suffix beginning at O+L to O and subtracts L from logical length. Unlike hole punching, it leaves no gap. In a logical illustration of equal aligned chunks, removing B from ABCD produces ACD. [range-uapi]\n\nBoundaries: O must be nonnegative, L positive and O+L strictly below the old EOF. Removing a suffix through EOF calls for truncation instead. Filesystem support and alignment are required; no other mode flag, including KEEP_SIZE, may accompany collapse. [fallocate]\n\nInterface: util-linux exposes --collapse-range (-c). Check failures without assigning one universal errno to rejected flag combinations: Linux v6.12 vfs_fallocate uses EOPNOTSUPP for conflicting modes. [range-cli] [range-vfs]\n\nPersistence: the logical range transformation does not specify media sanitization. [range-uapi] Synchronizing modified file data and required metadata is a separate concern. [fsync]\n\nObserved offset trap: a bounded Linux/ext4 probe kept the open-file position at byte 8192 while collapse changed its next byte from C to D and insert from C to B. This is one environment, not a portability guarantee. [range-cursor]",
  "related": [
    "falloc-fl-insert-range",
    "hole-punching",
    "file-size",
    "file-offset",
    "file-truncation"
  ],
  "status": "shipping",
  "advantages": [],
  "limitations": [],
  "supersedes": [],
  "supersededBy": [],
  "firstSeen": null,
  "lastSeen": null,
  "updated": "2026-12-05",
  "citations": [
    {
      "id": "range-uapi",
      "title": "Linux v6.12: fallocate range-mode contracts",
      "url": "https://raw.githubusercontent.com/torvalds/linux/v6.12/include/uapi/linux/falloc.h",
      "accessed": "2026-12-05"
    },
    {
      "id": "fallocate",
      "title": "Linux man-pages: fallocate(2), range boundaries and mode restrictions",
      "url": "https://man7.org/linux/man-pages/man2/fallocate.2.html",
      "accessed": "2026-12-05"
    },
    {
      "id": "range-cli",
      "title": "util-linux v2.41.2: fallocate command options",
      "url": "https://raw.githubusercontent.com/util-linux/util-linux/v2.41.2/sys-utils/fallocate.1.adoc",
      "accessed": "2026-12-05"
    },
    {
      "id": "range-vfs",
      "title": "Linux v6.12: vfs_fallocate flag validation",
      "url": "https://raw.githubusercontent.com/torvalds/linux/v6.12/fs/open.c",
      "accessed": "2026-12-05"
    },
    {
      "id": "fsync",
      "title": "Linux man-pages: fsync(2), data and metadata synchronization",
      "url": "https://man7.org/linux/man-pages/man2/fsync.2.html",
      "accessed": "2026-12-05"
    },
    {
      "id": "hesela-capacity",
      "title": "Hesela: Sparse files, preallocation and thin-pool capacity",
      "url": "https://hesela.com/analyses/sparse-files-preallocation-thin-capacity/",
      "accessed": "2026-12-05"
    },
    {
      "id": "range-cursor",
      "title": "Hesela: Native range transformation and cursor observation",
      "url": "https://hesela.dev/research/range-cursor/README.md",
      "accessed": "2026-12-05"
    }
  ],
  "provenance": [
    "Primary-documentation synthesis with logical illustrations and a separately scoped native Linux/ext4 byte-and-cursor probe; not a performance or crash measurement.",
    "Pinned Linux v6.12 and util-linux v2.41.2 sources do not establish support for every filesystem configuration."
  ]
}
