atomic-rename · shipping · also atomic file replacement, rename atomicity

Atomic rename

Atomic rename replaces an existing destination pathname without exposing an intermediate missing destination to concurrent lookups.

For Linux rename(), source and destination must be on the same mounted filesystem; even separate mount points of one filesystem produce EXDEV. Existing descriptors retain their original file references, and other hard links are unaffected. Both pathnames may temporarily refer to the source, so the guarantee is not a two-path snapshot. Success establishes visibility, not crash durability: the file-data and directory-persistence requirements must be handled separately. A lock held on the old file does not automatically coordinate writers opening its replacement; see the scoped lock-identity observation. [6]

With ordinary final-component symbolic links, Linux rename() moves or replaces the link itself rather than following it. Renaming a distinct file over such a destination leaves its referent unchanged. Intermediate symlink components can still be followed. If both operands already name the same file, rename() succeeds without changing the names. [1]

Relations

related
Mount point, Directory fsync, Open file description, Inode, Hard link, Unlink, Crash consistency, Advisory file lock, Open-file-description lock, Symbolic link, Path resolution, OverlayFS, SpanFS

Advantages

  • Publishes a replacement without first removing the destination name.

Limitations

  • Does not redirect already-open descriptors or update other hard links.
  • Does not by itself make replacement data or directory entries crash-persistent.
  • On NFS, a reported rename failure can follow successful server execution; NFSv4.1 replay guarantees depend on session and reply-cache recovery.

Citations

  1. Linux man-pages 6.19: rename(2) (accessed 2026-11-03)
  2. Hesela: A lock follows the opened file, not the replacement name (accessed 2026-10-16)

Further reading

  1. Linux man-pages 6.19: open(2) (accessed 2026-10-15)
  2. Linux man-pages 6.19: fsync(2) (accessed 2026-10-15)
  3. Hesela: The name changes; existing readers do not (accessed 2026-10-15)
  4. RFC 8881: NFSv4.1 replay and persistence, sections 2.10.6 and 2.10.6.5 (accessed 2026-10-15)

JSON: /data/terms/atomic-rename.json

Published by Hesela team · Updated

Report a correction · Editorial standards · Reuse guidance

Cite this page
Hesela team. Atomic rename. Hesela. 2026-12-01. https://hesela.dev/terms/atomic-rename/