WWDC 2016: Introducing APFS
Improved File System Fundamentals
Flash/SSD-optimized
Novel copy-on-write metadata scheme for crash-protection
64-bit native fields (e.g. nanosecond timestamps, 64-bit inode numbers)
Extensible design for data structure growth
Prioritizes latency over throughput (so user actions are fast)
Space Sharing
APFS Container contains Volumes
Volumes can dynamically share space within a container
Cloning Files and Directories
Fast and space efficient clones using copy-on-write
File System Snapshots
Snapshot maintains references to data blocks
Potential gotcha: snapshot will maintain references to data blocks for files that have been deleted, so could lead to exhausting available space if dangling snapshot that's keeping data blocks from being deleted One use case is creating read-only snapshots to use for backing up
Can also revert entire file system to a snapshot
Fast Directory Sizing
File system can cache size of each directory, but tricky to safely update its parent, and its parent, and so on, since locking ordering violation to lock child -> parent
APFS side-steps locking order problem by storing the size separately [[Concurrency]]
Atomic Safe-Save Primitives
Could previously do atomic rename for safely modifying files, but POSIX semantics didn't allow for updating directories (e.g. .app
bundles, which are directories)
APFS can use atomic safe-save for directories (i.e. bundles)
renamex_np
sys calls
Encryption
Supports multiple levels of file system encryption:
- No encryption
- One key per Volume (similar to full-disk encryption)
- Multi-key encryption