The FUSE API doesn't expose a file-system level sync
call, just fsync
and fsyncdir
. Does it mean that when sync
is called (or syncfs
inside a FUSE mountpoint), the kernel invokes fsync
on all open files on all FUSE mounted file-systems? Or is there a different semantics?
Looking at the kernel source, it seems that on sync
and syncfs
any pending writebacks are performed, but fsync
is not called (not AFAICS anyway), so there is not really any way to know that sync
or syncfs
is called.
Relevant code is in https://github.com/torvalds/linux/blob/v4.16/fs/sync.c, e.g. https://github.com/torvalds/linux/blob/v4.16/fs/sync.c#L31-L41
As shown, this calls the fsync_fs
operation on the fileystem superblock, but fuse does not define any:
https://github.com/torvalds/linux/blob/v4.16/fs/fuse/inode.c#L803-L814
I also recall reading a mailing list thread about this, which suggested that implementing sync_fs
in fuse is non-trivial, since it would allow a fuse filesystem (which might run as a non-privileged user) to block any global sync
system calls indefinitely, posing a security (DoS) problem. I can't quite find that thread anymore, though.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With