On Wed, Sep 20, 2017 at 6:37 PM, Nikolaus Rath <Nikolaus@xxxxxxxx> wrote: > On Sep 20 2017, Miklos Szeredi <mszeredi@xxxxxxxxxx> wrote: >>>> Writeback cache assumes that the file is never changed outside the >>>> mounted filesystem, so it's not suitable for any network fs currently. >>>> >>>> Apparently the above is not documented anywhere :( >>> >>> Ouch. >>> >>> I will of course put this into the libfuse documentation, but it would >>> be much nicer if things like that could be documented somewhere in the >>> kernel. After all, these are not properties of libfuse but the kernel >>> module - and some filesystems use the fuse interface without using >>> libfuse. >>> >>> (This actually applies to large chunk of information that's currently >>> only in the libfuse documentation). >>> >>> Any chance of that happening? I understand that bringing >>> Documentation/filesystems/fuse.txt up to date would be a major >>> endeavour, but maybe one could just start by putting at least this >>> information into e.g. a new Documentation/filesystems/fuse/writeback.txt >>> file? Together with the requirement that the filesystem has to support >>> reading from files opened O_WRONLY? >> >> Something like this? > > Anything is better than nothing. Well, almost anything, but that > definitely includes your draft :-). Thanks for your feedback. Fixed and expanded version: Fuse supports the following I/O modes: - direct-io - cached + write-through + writeback-cache The direct-io mode can be selected with the FOPEN_DIRECT_IO flag in the FUSE_OPEN reply. In direct-io mode the page cache is completely bypassed for reads and writes. No read-ahead takes place. Shared mmap is disabled. In cached mode reads may be satisfied from the page cache, and data may be read-ahead by the kernel to fill the cache. The cache is always kept consistent after any writes to the file. All mmap modes are supported. The cached mode has two sub modes controlling how writes are handled. The write-through mode is the default and is supported on all kernels. The writeback-cache mode may be selected by the FUSE_WRITEBACK_CACHE flag in the FUSE_INIT reply. In write-through mode each write is immediately sent to userspace as one or more WRITE requests, as well as updating any cached pages (and caching previously uncached, but fully written pages). No READ requests are ever sent for writes, so when an uncached page is partially written, the page is discarded. In writeback-cache mode (enabled by the FUSE_WRITEBACK_CACHE flag) writes go to the cache only, which means that the write(2) syscall can often complete very fast. Dirty pages are written back implicitly (background writeback or page reclaim on memory pressure) or explicitly (invoked by fsync(2)). This mode assumes that the file is never changed outside the mounted filesystem (the size time attributes are kept uptodate by the kernel), so it's not suitable for any any network filesystem even if no write operations are actually carried out. If a partial page is written, then the page needs to be first read from userspace. This means, that even for files opened for O_WRONLY it is possible that read requests will be generated by the kernel.