Skip to content

Commit 92cc9ac

Browse files
committed
Merge tag 'fuse-update-6.14' of git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/fuse
Pull fuse updates from Miklos Szeredi: "Add support for io-uring communication between kernel and userspace using IORING_OP_URING_CMD (Bernd Schubert). Following features enable gains in performance compared to the regular interface: - Allow processing multiple requests with less syscall overhead - Combine commit of old and fetch of new fuse request - CPU/NUMA affinity of queues Patches were reviewed by several people, including Pavel Begunkov, io-uring co-maintainer" * tag 'fuse-update-6.14' of git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/fuse: fuse: prevent disabling io-uring on active connections fuse: enable fuse-over-io-uring fuse: block request allocation until io-uring init is complete fuse: {io-uring} Prevent mount point hang on fuse-server termination fuse: Allow to queue bg requests through io-uring fuse: Allow to queue fg requests through io-uring fuse: {io-uring} Make fuse_dev_queue_{interrupt,forget} non-static fuse: {io-uring} Handle teardown of ring entries fuse: Add io-uring sqe commit and fetch support fuse: {io-uring} Make hash-list req unique finding functions non-static fuse: Add fuse-io-uring handling into fuse_copy fuse: Make fuse_copy non static fuse: {io-uring} Handle SQEs - register commands fuse: make args->in_args[0] to be always the header fuse: Add fuse-io-uring design documentation fuse: Move request bits fuse: Move fuse_get_dev to header file fuse: rename to fuse_dev_end_requests and make non-static
2 parents 27560b3 + 2d4fde5 commit 92cc9ac

File tree

14 files changed

+1924
-78
lines changed

14 files changed

+1924
-78
lines changed
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
.. SPDX-License-Identifier: GPL-2.0
2+
3+
=======================================
4+
FUSE-over-io-uring design documentation
5+
=======================================
6+
7+
This documentation covers basic details how the fuse
8+
kernel/userspace communication through io-uring is configured
9+
and works. For generic details about FUSE see fuse.rst.
10+
11+
This document also covers the current interface, which is
12+
still in development and might change.
13+
14+
Limitations
15+
===========
16+
As of now not all requests types are supported through io-uring, userspace
17+
is required to also handle requests through /dev/fuse after io-uring setup
18+
is complete. Specifically notifications (initiated from the daemon side)
19+
and interrupts.
20+
21+
Fuse io-uring configuration
22+
===========================
23+
24+
Fuse kernel requests are queued through the classical /dev/fuse
25+
read/write interface - until io-uring setup is complete.
26+
27+
In order to set up fuse-over-io-uring fuse-server (user-space)
28+
needs to submit SQEs (opcode = IORING_OP_URING_CMD) to the /dev/fuse
29+
connection file descriptor. Initial submit is with the sub command
30+
FUSE_URING_REQ_REGISTER, which will just register entries to be
31+
available in the kernel.
32+
33+
Once at least one entry per queue is submitted, kernel starts
34+
to enqueue to ring queues.
35+
Note, every CPU core has its own fuse-io-uring queue.
36+
Userspace handles the CQE/fuse-request and submits the result as
37+
subcommand FUSE_URING_REQ_COMMIT_AND_FETCH - kernel completes
38+
the requests and also marks the entry available again. If there are
39+
pending requests waiting the request will be immediately submitted
40+
to the daemon again.
41+
42+
Initial SQE
43+
-----------::
44+
45+
| | FUSE filesystem daemon
46+
| |
47+
| | >io_uring_submit()
48+
| | IORING_OP_URING_CMD /
49+
| | FUSE_URING_CMD_REGISTER
50+
| | [wait cqe]
51+
| | >io_uring_wait_cqe() or
52+
| | >io_uring_submit_and_wait()
53+
| |
54+
| >fuse_uring_cmd() |
55+
| >fuse_uring_register() |
56+
57+
58+
Sending requests with CQEs
59+
--------------------------::
60+
61+
| | FUSE filesystem daemon
62+
| | [waiting for CQEs]
63+
| "rm /mnt/fuse/file" |
64+
| |
65+
| >sys_unlink() |
66+
| >fuse_unlink() |
67+
| [allocate request] |
68+
| >fuse_send_one() |
69+
| ... |
70+
| >fuse_uring_queue_fuse_req |
71+
| [queue request on fg queue] |
72+
| >fuse_uring_add_req_to_ring_ent() |
73+
| ... |
74+
| >fuse_uring_copy_to_ring() |
75+
| >io_uring_cmd_done() |
76+
| >request_wait_answer() |
77+
| [sleep on req->waitq] |
78+
| | [receives and handles CQE]
79+
| | [submit result and fetch next]
80+
| | >io_uring_submit()
81+
| | IORING_OP_URING_CMD/
82+
| | FUSE_URING_CMD_COMMIT_AND_FETCH
83+
| >fuse_uring_cmd() |
84+
| >fuse_uring_commit_fetch() |
85+
| >fuse_uring_commit() |
86+
| >fuse_uring_copy_from_ring() |
87+
| [ copy the result to the fuse req] |
88+
| >fuse_uring_req_end() |
89+
| >fuse_request_end() |
90+
| [wake up req->waitq] |
91+
| >fuse_uring_next_fuse_req |
92+
| [wait or handle next req] |
93+
| |
94+
| [req->waitq woken up] |
95+
| <fuse_unlink() |
96+
| <sys_unlink() |
97+
98+
99+

Documentation/filesystems/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ Documentation for filesystem implementations.
9898
hpfs
9999
fuse
100100
fuse-io
101+
fuse-io-uring
101102
inotify
102103
isofs
103104
nilfs2

fs/fuse/Kconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,15 @@ config FUSE_PASSTHROUGH
6363
to be performed directly on a backing file.
6464

6565
If you want to allow passthrough operations, answer Y.
66+
67+
config FUSE_IO_URING
68+
bool "FUSE communication over io-uring"
69+
default y
70+
depends on FUSE_FS
71+
depends on IO_URING
72+
help
73+
This allows sending FUSE requests over the io-uring interface and
74+
also adds request core affinity.
75+
76+
If you want to allow fuse server/client communication through io-uring,
77+
answer Y

fs/fuse/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@ fuse-y += iomode.o
1515
fuse-$(CONFIG_FUSE_DAX) += dax.o
1616
fuse-$(CONFIG_FUSE_PASSTHROUGH) += passthrough.o
1717
fuse-$(CONFIG_SYSCTL) += sysctl.o
18+
fuse-$(CONFIG_FUSE_IO_URING) += dev_uring.o
1819

1920
virtiofs-y := virtio_fs.o

fs/fuse/dax.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -240,11 +240,12 @@ static int fuse_send_removemapping(struct inode *inode,
240240

241241
args.opcode = FUSE_REMOVEMAPPING;
242242
args.nodeid = fi->nodeid;
243-
args.in_numargs = 2;
244-
args.in_args[0].size = sizeof(*inargp);
245-
args.in_args[0].value = inargp;
246-
args.in_args[1].size = inargp->count * sizeof(*remove_one);
247-
args.in_args[1].value = remove_one;
243+
args.in_numargs = 3;
244+
fuse_set_zero_arg0(&args);
245+
args.in_args[1].size = sizeof(*inargp);
246+
args.in_args[1].value = inargp;
247+
args.in_args[2].size = inargp->count * sizeof(*remove_one);
248+
args.in_args[2].value = remove_one;
248249
return fuse_simple_request(fm, &args);
249250
}
250251

0 commit comments

Comments
 (0)