{
  "slug": "directory-fsync",
  "term": "Directory fsync",
  "aliases": [
    "directory synchronization",
    "parent-directory fsync"
  ],
  "definition": "Directory fsync is a synchronization request on a directory descriptor, used to persist namespace changes under the filesystem's directory-synchronization contract.",
  "note": "On Linux, syncing a file does not necessarily persist its directory entry. With working file and directory synchronization, a replacement within one already durable directory writes and syncs the temporary file, renames it, then syncs the containing directory. [fsync-api] [lwn-moyer]\n\nA 2014 study of 11 widely used applications found 60 static crash vulnerabilities, corresponding to 156 dynamic ones and failures in more than 4,000 crash states. Durability loss affected 7 applications, and 6 of them needed fsync calls on directories: three relied on a flushed file's directory entry being persisted implicitly, and four needed other directory fsyncs. In one key-value store, compaction output files whose directory entries were never persisted could vanish after a crash and leave the store unavailable. [alice]\n\nThe 2014 study found that implicit persistence of a flushed file's directory entry varied with the tested filesystem configuration; its findings do not establish a guarantee for other implementations. [alice] [fsync-api]\n\nA successful return still needs an implementation-specific interpretation. In Linux v6.12, FUSE_FSYNCDIR returning ENOSYS sets the connection's no_fsyncdir flag and becomes success; later directory syncs skip that daemon request after the bad-inode check. In libfuse 3.16.2's low-level dispatcher, an absent fsyncdir callback produces ENOSYS. This does not establish whether earlier namespace changes were persisted by another mechanism. Verify the daemon's backing-store contract before acknowledging durable publication. [fuse-dir-source] [libfuse-dispatch]\n\nDFSCQ provides a stronger implementation-specific scope: fsync flushes all pending metadata. This is not a portable Linux guarantee. [dfscq17]",
  "status": "shipping",
  "advantages": [
    {
      "text": "Explicit directory synchronization makes name persistence a separate checked step instead of relying on implicit persistence of directory entries, provided the implementation supports the required contract.",
      "citationIds": [
        "fsync-api",
        "fuse-dir-source"
      ]
    }
  ],
  "limitations": [
    {
      "text": "Safe-rename heuristics, which persist a file's data before a later rename on file systems with delayed allocation, matched only 3 of the 60 vulnerabilities found in the study.",
      "citationIds": [
        "alice"
      ]
    },
    {
      "text": "Even with a file system that promises full ordering between system calls, 4 of the 12 durability vulnerabilities in the study remained exposed.",
      "citationIds": [
        "alice"
      ]
    },
    {
      "text": "Directory synchronization does not by itself guarantee recursive synchronization of child-file contents or an atomic transaction across multiple directories.",
      "citationIds": [
        "fsync-api"
      ]
    },
    {
      "text": "After rename succeeds, a failed directory sync leaves durability unresolved; it does not establish that the visible namespace change was rolled back.",
      "citationIds": [
        "hesela-rename"
      ]
    }
  ],
  "supersedes": [],
  "supersededBy": [],
  "firstSeen": null,
  "lastSeen": null,
  "updated": "2026-12-04",
  "related": [
    "fsync",
    "persistence-ordering",
    "crash-consistency",
    "atomic-rename",
    "hard-link",
    "unlink",
    "fflush",
    "fuse",
    "o-path",
    "fdatasync",
    "scalefs",
    "dfscq"
  ],
  "citations": [
    {
      "id": "fsync-api",
      "title": "Linux man-pages 6.19, fsync(2): DESCRIPTION and error handling.",
      "url": "https://man7.org/linux/man-pages/man2/fsync.2.html",
      "accessed": "2026-10-23"
    },
    {
      "id": "hesela-rename",
      "title": "Hesela: Atomic rename is not a durable commit",
      "url": "https://hesela.com/analyses/atomic-rename-directory-durability/",
      "accessed": "2026-10-11"
    },
    {
      "id": "alice",
      "title": "Pillai et al. All File Systems Are Not Created Equal: On the Complexity of Crafting Crash-Consistent Applications. OSDI 2014.",
      "url": "https://files.usenix.org/s3fs-public/cdn/osdi14-paper-pillai.pdf",
      "accessed": "2026-10-23"
    },
    {
      "id": "lwn-moyer",
      "title": "Moyer. Ensuring data reaches disk. LWN.net, 7 September 2011.",
      "url": "https://lwn.net/Articles/457667/",
      "accessed": "2026-10-23"
    },
    {
      "id": "fuse-dir-source",
      "title": "Linux v6.12: fuse_dir_fsync and no_fsyncdir handling",
      "url": "https://github.com/torvalds/linux/blob/v6.12/fs/fuse/dir.c",
      "accessed": "2026-10-25"
    },
    {
      "id": "libfuse-dispatch",
      "title": "libfuse 3.16.2: do_fsyncdir and an absent low-level callback",
      "url": "https://github.com/libfuse/libfuse/blob/fuse-3.16.2/lib/fuse_lowlevel.c",
      "accessed": "2026-10-25"
    },
    {
      "id": "dfscq17",
      "title": "Chen et al. Verifying a high-performance crash-safe file system using a tree specification. SOSP 2017, section 4.",
      "url": "https://pdos.csail.mit.edu/papers/dfscq.pdf",
      "accessed": "2026-12-04"
    }
  ],
  "provenance": [
    "fsync-api is the Linux man-pages 6.19 fsync(2) page, re-read in the DESCRIPTION and ERRORS sections.",
    "alice is the OSDI 2014 paper by University of Wisconsin-Madison authors, read in the abstract and sections 4.2 to 4.4.",
    "lwn-moyer is a September 2011 LWN.net article by Jeff Moyer of Red Hat, read in full.",
    "The study counts vulnerabilities per application and update protocol, so its figures describe the tested versions rather than current releases.",
    "The FUSE qualification is a version-pinned source review of Linux v6.12 fuse_dir_fsync and libfuse 3.16.2 do_fsyncdir, not a mounted-filesystem or crash experiment."
  ]
}
