[Nix-dev] The fsync issues with nix

Lluís Batlle i Rossell viric at viric.name
Wed Mar 21 20:58:43 CET 2012


On Wed, Mar 21, 2012 at 08:39:20PM +0100, Lluís Batlle i Rossell wrote:
> On Wed, Mar 21, 2012 at 08:21:46PM +0100, Marc Weber wrote:
> > You're asking to do fsync before registering store paths valid,
> > correct?
> > 
> > If its not done yet it makes much sense to me.
> 
> Well, I think there are only two available operations: fsync(int fd) and sync().
> One is much faster and less intrusive than the other. But what to do, when it
> isn't nix that writes the files, and thus, nix has not the handles open?
> Maybe sync() is the quick solution? Or should nix open all files and fsync them?

Just as an additional note, and as 'cwillu' pointed at #btrfs, 'mv' is an atomic
operation for file entries, but not about the file contents. Only succesful
fsync/sync will ensure the changes go to the hardcopy of the fs.

Additionally, I don't know if fsync() can be used effectively on a file already
written and closed, by reopening it again. By the manpage I understand that it's
possible to do that. But then I don't know why I can't find any user tool that
fsyncs files.

Regards,
Lluís


More information about the nix-dev mailing list