westerndigitalcorporation / zenfs

ZenFS is a storage backend for RocksDB that enables support for ZNS SSDs and SMR HDDs.
GNU General Public License v2.0
239 stars 87 forks source link

Make sure that file size matches sum of extent lenghts after mount #95

Closed yhr closed 2 years ago

yhr commented 2 years ago

While writing to a file, the file size is increases - but the current active extent won't be persisted unless we get an fsync() or a close() call.
If we do a metadata roll, the file size will be persisted as part of a snapshot, so if we get a crash or an ungraceful shutdown after that we can end up having a file without extents but with a file size > 0.

ZenFS is not required to persist un-fsync data, but we should make sure that the file size matches the persisted extent lengths. We can simply truncate the file size to the sum of all extent lenghts, and we'll be consistent after mount.

yhr commented 2 years ago

This is fixed as a result of merging the inline extents on master - any open files will be recovered after a crash and the file size recalculated