Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do the 'sync' and 'syncfs' system calls map to FUSE's 'fsync' calls?

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?

like image 740
Petr Avatar asked Aug 31 '15 13:08

Petr


1 Answers

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.

like image 84
Matthijs Kooijman Avatar answered Nov 01 '22 08:11

Matthijs Kooijman