Soft Updates
Metadata
FFS only has file cache for data blocks.
Soft Updates manages to cache metadata blocks. Caching the metadata is more complicated, because the integrity needs to be guaranteed. After crash, the consistency should not fail. The modification must be propagated to stable storage in a specific order.
This will give noticeable performance improvement, as sync writes of metadata to disk will no longer be used. The sync write greatly slows down the speed to the speed of disk.
Solution
Track dependencies, and propagate to disk in a specific order.
Three rules
- Dangling pointer (Creation)
- Never reuse until all pointers cleared (Cleaning)
- Never reset the last pointer until the new one is stable (Rename, we do not want to lose file when renaming)
Granularity
If we track dependencies at the granularity of block, we will have cycles. To make it possible, we need to track the dependency at a smaller granularity, the filed or pointer.
Steps
Lock -> Roll Back -> Roll Forward -> Unlock We lock the disk block so that the app can't see the rolled-back state during the disk write.
Benefits
- No Sync writes needed
- Coalesce a bunch of operations into one I/O, improve performance
- No need to write to disk for the short lived files