Fuse I/O Modes¶
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 theFUSE_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 beread-ahead by the kernel to fill the cache. The cache is always kept consistentafter any writes to the file. All mmap modes are supported.
The cached mode has two sub modes controlling how writes are handled. Thewrite-through mode is the default and is supported on all kernels. Thewriteback-cache mode may be selected by the FUSE_WRITEBACK_CACHE flag in theFUSE_INIT reply.
In write-through mode each write is immediately sent to userspace as one or moreWRITE requests, as well as updating any cached pages (and caching previouslyuncached, 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 tothe cache only, which means that the write(2) syscall can often complete veryfast. Dirty pages are written back implicitly (background writeback or pagereclaim on memory pressure) or explicitly (invoked by close(2), fsync(2) andwhen the last ref to the file is being released on munmap(2)). This modeassumes that all changes to the filesystem go through the FUSE kernel module(size and atime/ctime/mtime attributes are kept up-to-date by the kernel), soit’s generally not suitable for network filesystems. If a partial page iswritten, then the page needs to be first read from userspace. This means, thateven for files opened for O_WRONLY it is possible that READ requests will begenerated by the kernel.