On 14/04/14 10:49, Nathan Scott wrote:
...
There is a metadata vs data ordering assumption, I believe. We need to fsync
the newly created data files before the rename otherwise we could end up with
empty files on-disk - or files-filled-with-zeroes depending on the filesystem
implementation (in this case: directory metadata IO & new file inode metadata
IO completes up to the open(O_CREAT), but no data writes/allocation happen).
Nathan,
So before exit(), you're sugesting fsync() on each of the data files,
and I think I need fsync() on the container directory as well.
But we should be consistent. If this is the "right" way to do it then
surely all applications that can write PCP archives should do the same
thing.
I am not against doing this, although if one was concerned at this level
then I suspect an option to enforce O_SYNC might be better to guarantee
on disk for all writes, not just flushing everything at exit, but we
should choose one policy for writing PCP archives and implement it
consistently throughout the PCP ecosystem.
|