Skip to content

Commit 8f744bd

Browse files
committed
Merge tag 'virtio-fs-5.4' of git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/fuse
Pull fuse virtio-fs support from Miklos Szeredi: "Virtio-fs allows exporting directory trees on the host and mounting them in guest(s). This isn't actually a new filesystem, but a glue layer between the fuse filesystem and a virtio based back-end. It's similar in functionality to the existing virtio-9p solution, but significantly faster in benchmarks and has better POSIX compliance. Further permformance improvements can be achieved by sharing the page cache between host and guest, allowing for faster I/O and reduced memory use. Kata Containers have been including the out-of-tree virtio-fs (with the shared page cache patches as well) since version 1.7 as an experimental feature. They have been active in development and plan to switch from virtio-9p to virtio-fs as their default solution. There has been interest from other sources as well. The userspace infrastructure is slated to be merged into qemu once the kernel part hits mainline. This was developed by Vivek Goyal, Dave Gilbert and Stefan Hajnoczi" * tag 'virtio-fs-5.4' of git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/fuse: virtio-fs: add virtiofs filesystem virtio-fs: add Documentation/filesystems/virtiofs.rst fuse: reserve values for mapping protocol
2 parents 9977b1a + a62a8ef commit 8f744bd

File tree

11 files changed

+1329
-1
lines changed

11 files changed

+1329
-1
lines changed

Documentation/filesystems/index.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,13 @@ filesystem implementations.
3737
journalling
3838
fscrypt
3939
fsverity
40+
41+
Filesystems
42+
===========
43+
44+
Documentation for filesystem implementations.
45+
46+
.. toctree::
47+
:maxdepth: 2
48+
49+
virtiofs
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
.. SPDX-License-Identifier: GPL-2.0
2+
3+
===================================================
4+
virtiofs: virtio-fs host<->guest shared file system
5+
===================================================
6+
7+
- Copyright (C) 2019 Red Hat, Inc.
8+
9+
Introduction
10+
============
11+
The virtiofs file system for Linux implements a driver for the paravirtualized
12+
VIRTIO "virtio-fs" device for guest<->host file system sharing. It allows a
13+
guest to mount a directory that has been exported on the host.
14+
15+
Guests often require access to files residing on the host or remote systems.
16+
Use cases include making files available to new guests during installation,
17+
booting from a root file system located on the host, persistent storage for
18+
stateless or ephemeral guests, and sharing a directory between guests.
19+
20+
Although it is possible to use existing network file systems for some of these
21+
tasks, they require configuration steps that are hard to automate and they
22+
expose the storage network to the guest. The virtio-fs device was designed to
23+
solve these problems by providing file system access without networking.
24+
25+
Furthermore the virtio-fs device takes advantage of the co-location of the
26+
guest and host to increase performance and provide semantics that are not
27+
possible with network file systems.
28+
29+
Usage
30+
=====
31+
Mount file system with tag ``myfs`` on ``/mnt``:
32+
33+
.. code-block:: sh
34+
35+
guest# mount -t virtiofs myfs /mnt
36+
37+
Please see https://virtio-fs.gitlab.io/ for details on how to configure QEMU
38+
and the virtiofsd daemon.
39+
40+
Internals
41+
=========
42+
Since the virtio-fs device uses the FUSE protocol for file system requests, the
43+
virtiofs file system for Linux is integrated closely with the FUSE file system
44+
client. The guest acts as the FUSE client while the host acts as the FUSE
45+
server. The /dev/fuse interface between the kernel and userspace is replaced
46+
with the virtio-fs device interface.
47+
48+
FUSE requests are placed into a virtqueue and processed by the host. The
49+
response portion of the buffer is filled in by the host and the guest handles
50+
the request completion.
51+
52+
Mapping /dev/fuse to virtqueues requires solving differences in semantics
53+
between /dev/fuse and virtqueues. Each time the /dev/fuse device is read, the
54+
FUSE client may choose which request to transfer, making it possible to
55+
prioritize certain requests over others. Virtqueues have queue semantics and
56+
it is not possible to change the order of requests that have been enqueued.
57+
This is especially important if the virtqueue becomes full since it is then
58+
impossible to add high priority requests. In order to address this difference,
59+
the virtio-fs device uses a "hiprio" virtqueue specifically for requests that
60+
have priority over normal requests.

MAINTAINERS

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17280,6 +17280,18 @@ S: Supported
1728017280
F: drivers/s390/virtio/
1728117281
F: arch/s390/include/uapi/asm/virtio-ccw.h
1728217282

17283+
VIRTIO FILE SYSTEM
17284+
M: Vivek Goyal <[email protected]>
17285+
M: Stefan Hajnoczi <[email protected]>
17286+
M: Miklos Szeredi <[email protected]>
17287+
17288+
17289+
W: https://virtio-fs.gitlab.io/
17290+
S: Supported
17291+
F: fs/fuse/virtio_fs.c
17292+
F: include/uapi/linux/virtio_fs.h
17293+
F: Documentation/filesystems/virtiofs.rst
17294+
1728317295
VIRTIO GPU DRIVER
1728417296
M: David Airlie <[email protected]>
1728517297
M: Gerd Hoffmann <[email protected]>

fs/fuse/Kconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,14 @@ config CUSE
2727

2828
If you want to develop or use a userspace character device
2929
based on CUSE, answer Y or M.
30+
31+
config VIRTIO_FS
32+
tristate "Virtio Filesystem"
33+
depends on FUSE_FS
34+
select VIRTIO
35+
help
36+
The Virtio Filesystem allows guests to mount file systems from the
37+
host.
38+
39+
If you want to share files between guests or with the host, answer Y
40+
or M.

fs/fuse/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55

66
obj-$(CONFIG_FUSE_FS) += fuse.o
77
obj-$(CONFIG_CUSE) += cuse.o
8+
obj-$(CONFIG_VIRTIO_FS) += virtio_fs.o
89

910
fuse-objs := dev.o dir.o file.o inode.o control.o xattr.o acl.o readdir.o

fs/fuse/fuse_i.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,10 @@ struct fuse_req {
353353
/** Used to wake up the task waiting for completion of request*/
354354
wait_queue_head_t waitq;
355355

356+
#if IS_ENABLED(CONFIG_VIRTIO_FS)
357+
/** virtio-fs's physically contiguous buffer for in and out args */
358+
void *argbuf;
359+
#endif
356360
};
357361

358362
struct fuse_iqueue;
@@ -383,6 +387,11 @@ struct fuse_iqueue_ops {
383387
*/
384388
void (*wake_pending_and_unlock)(struct fuse_iqueue *fiq)
385389
__releases(fiq->lock);
390+
391+
/**
392+
* Clean up when fuse_iqueue is destroyed
393+
*/
394+
void (*release)(struct fuse_iqueue *fiq);
386395
};
387396

388397
/** /dev/fuse input queue operations */

fs/fuse/inode.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,10 @@ EXPORT_SYMBOL_GPL(fuse_conn_init);
630630
void fuse_conn_put(struct fuse_conn *fc)
631631
{
632632
if (refcount_dec_and_test(&fc->count)) {
633+
struct fuse_iqueue *fiq = &fc->iq;
634+
635+
if (fiq->ops->release)
636+
fiq->ops->release(fiq);
633637
put_pid_ns(fc->pid_ns);
634638
put_user_ns(fc->user_ns);
635639
fc->release(fc);

0 commit comments

Comments
 (0)