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