msync · shipping · also msync()

msync

msync is an operation that synchronizes a range of a shared file-backed memory mapping with its underlying file, with MS_SYNC waiting for completion.

Related Observatory article: Read on hesela.com

Completion: MS_SYNC waits for synchronization of the mapped range. Linux MS_ASYNC is a no-op since 2.6.19, not a persistence acknowledgement. The starting address must be page-aligned; an unaligned address yields EINVAL, which does not by itself diagnose a storage failure. [1]

Transaction boundary: ordinary activity may write shared dirty pages before msync. The call supplies neither isolation from other readers nor an all-or-nothing multi-page commit. A successful call on a MAP_PRIVATE mapping does not copy private changes into its file. [4]

Distinct flag: MS_SYNC is not the DAX-oriented MAP_SYNC option to mmap. [2]

Partial-page tail: Linux documents that stores beyond EOF within the final mapped page can remain visible in later mappings after close and unmap; msync does not clear this cached tail on tmpfs. [2] Hesela's separate fresh-process probe observed that boundary on Linux 6.8 with ext4 and tmpfs controls; the in-file payload and file length stayed unchanged. This is not evidence of persistence after reboot or a portable tail-clearing contract. [5]

Relations

related
Failure-atomic msync, fsync, fdatasync, sync_file_range, Memory-mapped file, File truncation, Memory locking (mlock), FlushViewOfFile

Advantages

  • Provides explicit synchronization for a selected mapped range.

Limitations

  • Portable callers select exactly one of MS_SYNC and MS_ASYNC.
  • A cached reread is not independent evidence of recovery after a power failure.

Citations

  1. Linux man-pages 6.19: msync(2), flags and Linux behavior (accessed 2026-10-17)
  2. Linux man-pages 6.19: mmap(2), shared/private mappings and MAP_SYNC (accessed 2026-10-18)
  3. POSIX.1-2017: msync(), completion and background writeback (accessed 2026-10-17)
  4. Hesela: Memory-mapped files: visibility, size and synchronization (accessed 2026-10-18)

Further reading

  1. Hesela: File and mapped-range synchronization boundaries (accessed 2026-10-13)

JSON: /data/terms/msync.json

Published by Hesela team · Updated

Report a correction · Editorial standards · Reuse guidance

Cite this page
Hesela team. msync. Hesela. 2026-11-21. https://hesela.dev/terms/msync/