요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
.. SPDX-License-Identifier: GPL-2.0
==============
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 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 by default. To allow shared
mmap, the FUSE_DIRECT_IO_ALLOW_MMAP flag may be enabled in the FUSE_INIT reply.
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 close(2), fsync(2) and
when the last ref to the file is being released on munmap(2)). This mode
assumes 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), so
it's generally not suitable for network filesystems. 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.
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
Direct I/O와 cached I/O
1-21FUSE는 direct-io와 cached라는 두 상위 I/O mode를 지원합니다. cached mode의 쓰기 정책은 다시 write-through와 writeback-cache로 나뉩니다.
direct-io는 FUSE_OPEN reply에서 `FOPEN_DIRECT_IO` flag를 설정해 선택합니다.
direct-io mode에서는 read와 write 모두 page cache를 완전히 우회합니다. kernel read-ahead도 수행하지 않습니다.
shared mmap은 direct-io에서 기본적으로 비활성화됩니다. 허용하려면 FUSE_INIT reply에서 `FUSE_DIRECT_IO_ALLOW_MMAP` flag를 활성화해야 합니다.
cached mode에서는 page cache가 read를 충족할 수 있고 kernel이 cache를 채우기 위해 read-ahead를 수행할 수 있습니다. 파일에 write한 뒤에는 cache가 항상 일관된 상태로 유지됩니다.
cached mode는 모든 mmap mode를 지원합니다. 따라서 page cache를 통한 반복 읽기와 memory mapping이 필요한 workload는 cached mode의 특성을 활용할 수 있습니다.
page cache, read-ahead, mmap 지원의 차이입니다.
.. SPDX-License-Identifier: GPL-2.0
==============
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 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 by default. To allow shared
mmap, the FUSE_DIRECT_IO_ALLOW_MMAP flag may be enabled in the FUSE_INIT reply.
In cached mode reads may be satisfied from the page cache, and data may be
Write-through와 writeback-cache
22-45cached mode에는 write 처리 방식을 결정하는 두 submode가 있습니다. write-through는 기본값이며 모든 kernel에서 지원합니다. writeback-cache는 FUSE_INIT reply의 `FUSE_WRITEBACK_CACHE` flag로 선택합니다.
write-through에서는 각 write를 즉시 하나 이상의 FUSE `WRITE` request로 사용자 공간에 전달하고 cache된 page도 갱신합니다. 이전에 cache되지 않았지만 전체가 write된 page는 새로 cache합니다.
write-through는 write 처리를 위해 `READ` request를 보내지 않습니다. 따라서 cache에 없는 page의 일부만 write하면 나머지 내용을 채우기 위해 읽지 않고 그 page를 버립니다.
writeback-cache에서는 write가 cache에만 반영되므로 `write(2)` syscall이 매우 빠르게 끝날 수 있습니다. dirty page의 실제 writeback은 background writeback이나 memory pressure의 page reclaim으로 암묵적으로, 또는 `close(2)`, `fsync(2)`, `munmap(2)`에서 파일의 마지막 reference가 해제될 때 명시적으로 일어납니다.
이 mode는 filesystem의 모든 변경이 FUSE kernel module을 통과한다고 가정합니다. kernel이 size와 atime·ctime·mtime attribute를 최신 상태로 유지하기 때문입니다. 서버 측이나 다른 client가 kernel 밖에서 변경할 수 있는 network filesystem에는 일반적으로 적합하지 않습니다.
writeback-cache에서 page의 일부만 write하려면 보존할 나머지 byte가 필요하므로 먼저 사용자 공간에서 page를 읽어야 합니다. 그 결과 파일을 `O_WRONLY`로 열었더라도 kernel이 FUSE `READ` request를 만들 수 있습니다.
write syscall 완료와 사용자 공간 request 생성 시점을 비교합니다.
O_WRONLY에서도 READ가 생길 수 있는 이유입니다.
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 close(2), fsync(2) and
when the last ref to the file is being released on munmap(2)). This mode
assumes 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), so
it's generally not suitable for network filesystems. 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.
요약·해설
fuse-io.rst:1-45FUSE direct-io는 page cache와 read-ahead를 우회하고 shared mmap을 별도 flag로만 허용합니다. cached mode는 page cache·read-ahead·모든 mmap mode를 지원하며 write-through 또는 writeback-cache로 쓰기 시점을 선택합니다.
writeback-cache는 syscall 지연을 줄이지만 모든 변경이 FUSE kernel module을 통과한다는 전제가 필요하고, 부분 page write를 보존하기 위해 `O_WRONLY` 파일에도 `READ` request를 만들 수 있습니다.
workload와 일관성 전제에 따른 선택 흐름입니다.