Petr
Petr

Reputation: 63349

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?

Upvotes: 13

Views: 2238

Answers (1)

Matthijs Kooijman
Matthijs Kooijman

Reputation: 2787

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.

Upvotes: 3

Related Questions