Discussion:
UBIFS: Do we need to fsync the parent directory?
(too old to reply)
Richard Weinberger
2018-12-10 13:42:17 UTC
Permalink
On Mon, Dec 10, 2018 at 1:16 PM Guillermo Rodriguez Garcia
Hi all,
fd = open(“foo.new”, O_WRONLY);
write(fd, buf, bufsize);
fsync(fd);
close(fd);
rename(“foo.new”, “foo”);
And assuming that we want to ensure not only that the update was
atomic, but also that the "new" version of the file will be available
in the event of a crash, normally one would also fsync the parent
directory.
Is this needed in UBIFS? The reason I am asking is this snippet from
fsync() may be called for directories - it synchronizes the directory inode meta-data. [...]
The fdatasync() call for directories is "no-op" in UBIFS and all UBIFS operations which change directory entries are synchronous.
If I am reading correctly, the latter ("all UBIFS operations which
change directory entries are synchronous") seems to imply that calling
fsync on the parent dir would not be necessary. However my tests seem
to indicate otherwise. Am I misreading the docs?
I fear the docs are ambiguous.
You need to sync the parent too, like on any other filesystem.
--
Thanks,
//richard
Continue reading on narkive:
Loading...