1*ba302d2aSMauro Carvalho Chehab.. SPDX-License-Identifier: GPL-2.0 2*ba302d2aSMauro Carvalho Chehab 3*ba302d2aSMauro Carvalho Chehab============== 4*ba302d2aSMauro Carvalho ChehabFuse I/O Modes 5*ba302d2aSMauro Carvalho Chehab============== 6*ba302d2aSMauro Carvalho Chehab 7*ba302d2aSMauro Carvalho ChehabFuse supports the following I/O modes: 8*ba302d2aSMauro Carvalho Chehab 9*ba302d2aSMauro Carvalho Chehab- direct-io 10*ba302d2aSMauro Carvalho Chehab- cached 11*ba302d2aSMauro Carvalho Chehab + write-through 12*ba302d2aSMauro Carvalho Chehab + writeback-cache 13*ba302d2aSMauro Carvalho Chehab 14*ba302d2aSMauro Carvalho ChehabThe direct-io mode can be selected with the FOPEN_DIRECT_IO flag in the 15*ba302d2aSMauro Carvalho ChehabFUSE_OPEN reply. 16*ba302d2aSMauro Carvalho Chehab 17*ba302d2aSMauro Carvalho ChehabIn direct-io mode the page cache is completely bypassed for reads and writes. 18*ba302d2aSMauro Carvalho ChehabNo read-ahead takes place. Shared mmap is disabled. 19*ba302d2aSMauro Carvalho Chehab 20*ba302d2aSMauro Carvalho ChehabIn cached mode reads may be satisfied from the page cache, and data may be 21*ba302d2aSMauro Carvalho Chehabread-ahead by the kernel to fill the cache. The cache is always kept consistent 22*ba302d2aSMauro Carvalho Chehabafter any writes to the file. All mmap modes are supported. 23*ba302d2aSMauro Carvalho Chehab 24*ba302d2aSMauro Carvalho ChehabThe cached mode has two sub modes controlling how writes are handled. The 25*ba302d2aSMauro Carvalho Chehabwrite-through mode is the default and is supported on all kernels. The 26*ba302d2aSMauro Carvalho Chehabwriteback-cache mode may be selected by the FUSE_WRITEBACK_CACHE flag in the 27*ba302d2aSMauro Carvalho ChehabFUSE_INIT reply. 28*ba302d2aSMauro Carvalho Chehab 29*ba302d2aSMauro Carvalho ChehabIn write-through mode each write is immediately sent to userspace as one or more 30*ba302d2aSMauro Carvalho ChehabWRITE requests, as well as updating any cached pages (and caching previously 31*ba302d2aSMauro Carvalho Chehabuncached, but fully written pages). No READ requests are ever sent for writes, 32*ba302d2aSMauro Carvalho Chehabso when an uncached page is partially written, the page is discarded. 33*ba302d2aSMauro Carvalho Chehab 34*ba302d2aSMauro Carvalho ChehabIn writeback-cache mode (enabled by the FUSE_WRITEBACK_CACHE flag) writes go to 35*ba302d2aSMauro Carvalho Chehabthe cache only, which means that the write(2) syscall can often complete very 36*ba302d2aSMauro Carvalho Chehabfast. Dirty pages are written back implicitly (background writeback or page 37*ba302d2aSMauro Carvalho Chehabreclaim on memory pressure) or explicitly (invoked by close(2), fsync(2) and 38*ba302d2aSMauro Carvalho Chehabwhen the last ref to the file is being released on munmap(2)). This mode 39*ba302d2aSMauro Carvalho Chehabassumes that all changes to the filesystem go through the FUSE kernel module 40*ba302d2aSMauro Carvalho Chehab(size and atime/ctime/mtime attributes are kept up-to-date by the kernel), so 41*ba302d2aSMauro Carvalho Chehabit's generally not suitable for network filesystems. If a partial page is 42*ba302d2aSMauro Carvalho Chehabwritten, then the page needs to be first read from userspace. This means, that 43*ba302d2aSMauro Carvalho Chehabeven for files opened for O_WRONLY it is possible that READ requests will be 44*ba302d2aSMauro Carvalho Chehabgenerated by the kernel. 45