요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
.. SPDX-License-Identifier: GPL-2.0
.. _virtiofs_index:
===================================================
virtiofs: virtio-fs host<->guest shared file system
===================================================
- Copyright (C) 2019 Red Hat, Inc.
Introduction
============
The virtiofs file system for Linux implements a driver for the paravirtualized
VIRTIO "virtio-fs" device for guest<->host file system sharing. It allows a
guest to mount a directory that has been exported on the host.
Guests often require access to files residing on the host or remote systems.
Use cases include making files available to new guests during installation,
booting from a root file system located on the host, persistent storage for
stateless or ephemeral guests, and sharing a directory between guests.
Although it is possible to use existing network file systems for some of these
tasks, they require configuration steps that are hard to automate and they
expose the storage network to the guest. The virtio-fs device was designed to
solve these problems by providing file system access without networking.
Furthermore the virtio-fs device takes advantage of the co-location of the
guest and host to increase performance and provide semantics that are not
possible with network file systems.
Usage
=====
Mount file system with tag ``myfs`` on ``/mnt``:
.. code-block:: sh
guest# mount -t virtiofs myfs /mnt
Please see https://virtio-fs.gitlab.io/ for details on how to configure QEMU
and the virtiofsd daemon.
Mount options
-------------
virtiofs supports general VFS mount options, for example, remount,
ro, rw, context, etc. It also supports FUSE mount options.
atime behavior
^^^^^^^^^^^^^^
The atime-related mount options, for example, noatime, strictatime,
are ignored. The atime behavior for virtiofs is the same as the
underlying filesystem of the directory that has been exported
on the host.
Internals
=========
Since the virtio-fs device uses the FUSE protocol for file system requests, the
virtiofs file system for Linux is integrated closely with the FUSE file system
client. The guest acts as the FUSE client while the host acts as the FUSE
server. The /dev/fuse interface between the kernel and userspace is replaced
with the virtio-fs device interface.
FUSE requests are placed into a virtqueue and processed by the host. The
response portion of the buffer is filled in by the host and the guest handles
the request completion.
Mapping /dev/fuse to virtqueues requires solving differences in semantics
between /dev/fuse and virtqueues. Each time the /dev/fuse device is read, the
FUSE client may choose which request to transfer, making it possible to
prioritize certain requests over others. Virtqueues have queue semantics and
it is not possible to change the order of requests that have been enqueued.
This is especially important if the virtqueue becomes full since it is then
impossible to add high priority requests. In order to address this difference,
the virtio-fs device uses a "hiprio" virtqueue specifically for requests that
have priority over normal requests.
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
virtio-fs 장치와 공유 파일 시스템
1-12이 문서는 GPL-2.0에 따라 배포되며 2019년 Red Hat, Inc.의 저작권 고지를 포함한다. Linux의 virtiofs 파일 시스템은 paravirtualized VIRTIO `virtio-fs` 장치를 구동하여 guest와 host 사이에 파일 시스템을 공유한다.
host가 export한 directory를 guest가 mount할 수 있다는 것이 핵심이다. guest 안에서 보이는 파일 시스템 namespace와 실제 directory를 제공하는 host를 연결하되, 일반적인 network file system처럼 별도의 storage network를 guest에 노출하지 않는다.
여기서 paravirtualization은 guest가 실제 hardware를 흉내 낸 장치가 아니라 hypervisor 환경에 맞춘 VIRTIO interface와 협력한다는 뜻이다. 따라서 virtiofs는 guest kernel의 VFS 경로를 virtio-fs transport와 host-side server로 이어 주는 공유 파일 시스템이다.
host가 export한 directory를 guest의 mountpoint에서 사용하는 전체 경로다.
각 구성 요소가 공유 파일 시스템에서 맡는 역할을 구분한다.
.. SPDX-License-Identifier: GPL-2.0
.. _virtiofs_index:
===================================================
virtiofs: virtio-fs host<->guest shared file system
===================================================
- Copyright (C) 2019 Red Hat, Inc.
Introduction
============
사용 사례와 network file system과의 차이
13-27guest는 host 또는 remote system에 있는 파일에 접근해야 할 때가 많다. 설치 중 새 guest에 파일을 제공하거나, host에 놓인 root file system으로 부팅하거나, 상태를 자체 보관하지 않는 stateless·ephemeral guest에 persistent storage를 제공하거나, 여러 guest 사이에서 directory를 공유하는 경우가 대표적이다.
이들 작업 중 일부는 기존 network file system으로도 수행할 수 있다. 그러나 network file system은 자동화하기 까다로운 설정 절차가 필요할 수 있고, guest에 storage network를 직접 노출한다. virtio-fs 장치는 networking 없이 파일 시스템 접근을 제공하여 이 두 문제를 해결하도록 설계됐다.
또한 guest와 host가 같은 machine에 함께 배치된다는 co-location 특성을 활용한다. 이 배치는 network round trip과 별개인 shared-memory·VIRTIO 기반 최적화의 여지를 주며, 일반적인 network file system에서는 제공하기 어려운 파일 시스템 semantics를 구현할 수 있게 한다.
원문이 제시한 네 가지 배치 목적과 필요한 특성이다.
virtiofs가 co-location을 전제로 해결하는 차이를 요약한다.
The virtiofs file system for Linux implements a driver for the paravirtualized
VIRTIO "virtio-fs" device for guest<->host file system sharing. It allows a
guest to mount a directory that has been exported on the host.
Guests often require access to files residing on the host or remote systems.
Use cases include making files available to new guests during installation,
booting from a root file system located on the host, persistent storage for
stateless or ephemeral guests, and sharing a directory between guests.
Although it is possible to use existing network file systems for some of these
tasks, they require configuration steps that are hard to automate and they
expose the storage network to the guest. The virtio-fs device was designed to
solve these problems by providing file system access without networking.
Furthermore the virtio-fs device takes advantage of the co-location of the
Mount 명령과 option
28-50tag가 `myfs`인 파일 시스템을 guest의 `/mnt`에 mount하려면 다음 명령을 실행한다. `myfs`는 host 측 VM 설정에서 virtio-fs 장치의 export와 연결한 tag이며, `/mnt`는 guest의 mountpoint다.
guest# mount -t virtiofs myfs /mnt
QEMU와 `virtiofsd` daemon을 구성하는 구체적인 절차는 원문이 안내하는 `https://virtio-fs.gitlab.io/`를 참고한다. guest의 mount 명령만으로 host export가 만들어지는 것은 아니므로, 먼저 host 측 장치와 daemon이 같은 tag를 제공하도록 구성해야 한다.
virtiofs는 remount, `ro`, `rw`, `context` 등 일반 VFS mount option을 지원하며 FUSE mount option도 지원한다. 실제로 사용할 수 있는 option은 VFS·FUSE 계층의 계약과 해당 kernel 및 userspace daemon 구성에 함께 영향을 받는다.
`noatime`, `strictatime` 같은 atime 관련 mount option은 virtiofs에서 무시된다. guest mount의 atime option이 동작을 결정하는 대신, host에서 export한 directory의 underlying filesystem이 가진 atime 동작을 그대로 따른다. 따라서 atime 정책을 바꾸려면 guest 명령만이 아니라 host backing filesystem의 정책을 확인해야 한다.
`myfs` tag가 host export와 guest mountpoint를 연결한다.
virtiofs가 지원하거나 별도로 처리하는 option 범주다.
guest option보다 host backing filesystem이 실제 timestamp 동작을 결정한다.
guest and host to increase performance and provide semantics that are not
possible with network file systems.
Usage
=====
Mount file system with tag ``myfs`` on ``/mnt``:
.. code-block:: sh
guest# mount -t virtiofs myfs /mnt
Please see https://virtio-fs.gitlab.io/ for details on how to configure QEMU
and the virtiofsd daemon.
Mount options
-------------
virtiofs supports general VFS mount options, for example, remount,
ro, rw, context, etc. It also supports FUSE mount options.
atime behavior
^^^^^^^^^^^^^^
FUSE client와 virtio-fs transport 통합
51-61virtio-fs 장치는 파일 시스템 request에 FUSE protocol을 사용하므로 Linux의 virtiofs 구현은 FUSE filesystem client와 밀접하게 통합된다. guest가 FUSE client로 동작하고 host가 FUSE server로 동작한다.
일반 FUSE에서는 kernel과 userspace daemon 사이를 `/dev/fuse` interface가 연결한다. virtiofs에서는 이 interface를 virtio-fs device interface가 대신한다. 상위 FUSE request semantics는 재사용하면서 request를 guest 밖의 host로 전달하는 transport가 바뀌는 구조다.
guest의 VFS operation은 FUSE request로 변환되어 virtqueue의 buffer에 놓인다. host가 request를 처리하고 같은 buffer의 response 영역을 채운다. 이후 guest가 request completion을 처리해 기다리던 filesystem operation을 완료한다.
guest VFS 요청이 host에서 처리된 뒤 completion으로 돌아오는 경로다.
FUSE protocol은 유지하고 kernel 밖으로 나가는 transport를 교체한다.
The atime-related mount options, for example, noatime, strictatime,
are ignored. The atime behavior for virtiofs is the same as the
underlying filesystem of the directory that has been exported
on the host.
Internals
=========
Since the virtio-fs device uses the FUSE protocol for file system requests, the
virtiofs file system for Linux is integrated closely with the FUSE file system
client. The guest acts as the FUSE client while the host acts as the FUSE
server. The /dev/fuse interface between the kernel and userspace is replaced
Virtqueue 순서 제약과 hiprio queue
62-76`/dev/fuse`를 virtqueue에 대응시키려면 두 interface의 semantics 차이를 해결해야 한다. `/dev/fuse` device를 읽을 때마다 FUSE client는 전송할 request를 선택할 수 있으므로, 일부 request를 다른 request보다 먼저 보내는 우선순위 결정을 할 수 있다.
반면 virtqueue는 queue semantics를 따른다. 한 번 enqueue한 request의 순서를 나중에 바꿀 수 없다. 특히 normal virtqueue가 가득 차면 이미 들어간 request를 밀어내거나 순서를 바꿀 수 없어, 뒤늦게 발생한 high-priority request를 추가하는 것조차 불가능해진다.
virtio-fs는 이 차이를 해결하기 위해 normal request보다 우선해야 하는 request 전용 `hiprio` virtqueue를 둔다. normal queue가 포화되어도 priority traffic이 별도 queue로 진입할 수 있으므로, progress와 자원 회수에 중요한 request가 일반 I/O 뒤에서 무기한 막히는 상황을 피한다.
`hiprio`는 이미 enqueue된 normal request의 순서를 재배치하는 기능이 아니다. request를 enqueue하기 전에 우선순위 범주를 구분하여 별도 queue에 넣는 설계다. 따라서 host와 guest 양쪽은 normal queue와 `hiprio` queue를 각각 처리할 수 있어야 한다.
request 선택 시점과 queue 포화 시 동작이 다르다.
enqueue 전에 request 성격을 판별해 서로 다른 queue에 넣는다.
with the virtio-fs device interface.
FUSE requests are placed into a virtqueue and processed by the host. The
response portion of the buffer is filled in by the host and the guest handles
the request completion.
Mapping /dev/fuse to virtqueues requires solving differences in semantics
between /dev/fuse and virtqueues. Each time the /dev/fuse device is read, the
FUSE client may choose which request to transfer, making it possible to
prioritize certain requests over others. Virtqueues have queue semantics and
it is not possible to change the order of requests that have been enqueued.
This is especially important if the virtqueue becomes full since it is then
impossible to add high priority requests. In order to address this difference,
the virtio-fs device uses a "hiprio" virtqueue specifically for requests that
have priority over normal requests.
요약·해설
virtiofs.rst:1-76virtiofs는 guest의 FUSE client와 host의 FUSE server를 VIRTIO `virtio-fs` 장치로 연결해 host directory를 guest에 mount한다. 별도 storage network를 guest에 노출하지 않으며 co-location을 활용한다.
일반 VFS와 FUSE mount option을 지원하지만 atime 관련 option은 무시하고 host export directory의 underlying filesystem 정책을 따른다. 운영 시 guest mount option과 host backing filesystem 설정을 함께 확인해야 한다.
FUSE request는 virtqueue로 왕복한다. Enqueue 뒤 순서를 바꿀 수 없는 제약과 queue 포화 문제를 해결하기 위해 priority request 전용 `hiprio` virtqueue를 별도로 사용한다.
mount tag부터 FUSE request completion까지의 핵심 흐름이다.