Re:Files Are Hard (2015)
by blattimwind on Sunday December 01, 2019 @10:39AM
(#21675934)
> - atomic file create with content
No FS guarantees this. You can emulate this by writing to a tmp location, syncing and performing a move.
When you use rename to overwrite a file, it guarentees that at any point in time, newpath will refer to either the original file, or the new file. This is atomic enough to give you effectivly atomic file creation with contents.
It is not technically atomic, because there is a period where oldpath and newpath both refer to the same file, but I don't think that is an issue for this usecase.
Linux has the O_TMPFILE flag to open, for which this is one of the use cases described in the man page. I can’t say about “guaranteed” though. I assume Microsoft Transactional NTFS (TxF) also had (or has) this capability—but deprecated.
Re:Files Are Hard (2015)
by blattimwind on Tuesday December 03, 2019 @08:10AM
(#21691953)
TxF is a corner stone of Windows Update, I can't really imagine them removing it. I always assumed they marked it deprecated to avoid supporting it towards customers.
- atomic file create with content
- atomic directory create
- atomic file move
- atomic file delete
- single-level file enumeration
No file modification in place which is the actual hard path. Not even appending to existing files.
Incidentally, reliable databases tend to also not rely on file modification, opting for a log-and-compact strategy instead.
It's when you start modifying existing data that 'just use a filesystem' becomes unviable.