From: Stefan Hajnoczi <stefanha@redhat.com>
To: Brian Song <hibriansong@gmail.com>
Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org, hreitz@redhat.com,
kwolf@redhat.com, eblake@redhat.com, armbru@redhat.com,
fam@euphon.net, bernd@bsbernd.com
Subject: Re: [Patch v4 2/7] fuse: io_uring mode init
Date: Wed, 11 Feb 2026 15:56:11 -0500 [thread overview]
Message-ID: <20260211205611.GB234157@fedora> (raw)
In-Reply-To: <20260207120901.17222-3-hibriansong@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 6332 bytes --]
On Sat, Feb 07, 2026 at 08:08:56PM +0800, Brian Song wrote:
> +typedef struct FuseUringEnt {
> + /* back pointer */
> + FuseUringQueue *rq;
> +
> + /* commit id of a fuse request */
> + uint64_t req_commit_id;
This field is only read by fuse_uring_resubmit() in this patch, never
assigned. Maybe some code later in the patch series should be squashed
into this patch so that this field is initialized somewhere?
Also, is it possible to drop req_commit_id and read from the existing
req_header.ring_ent_in_out.commit_id field instead?
> +static void fuse_uring_cqe_handler(CqeHandler *cqe_handler)
> +{
> + Coroutine *co;
> + FuseUringEnt *ent =
> + container_of(cqe_handler, FuseUringEnt, fuse_cqe_handler);
> + FuseExport *exp = ent->rq->q->exp;
> +
> + if (unlikely(exp->halted)) {
> + return;
Missing blk_exp_unref()?
> + }
> +
> + int err = cqe_handler->cqe.res;
> +
> + if (unlikely(err != 0)) {
> + switch (err) {
> + case -EAGAIN:
> + case -EINTR:
> + aio_add_sqe(fuse_uring_resubmit, ent, &ent->fuse_cqe_handler);
> + break;
> + case -ENOTCONN:
> + /* Connection already gone */
> + break;
> + default:
> + fuse_export_halt(exp);
> + break;
> + }
> +
> + /* A uring entry returned */
> + blk_exp_unref(&exp->common);
> + } else {
> + co = qemu_coroutine_create(co_fuse_uring_queue_handle_cqe, ent);
> + /* Account this request as in-flight */
> + fuse_inc_in_flight(exp);
> + qemu_coroutine_enter(co);
> + }
> +}
> +
> +static void
> +fuse_uring_sqe_set_req_data(struct fuse_uring_cmd_req *req,
> + const unsigned int rqid,
> + const unsigned int commit_id)
> +{
> + req->qid = rqid;
> + req->commit_id = commit_id;
> + req->flags = 0;
> +}
> +
> +static void
> +fuse_uring_sqe_prepare(struct io_uring_sqe *sqe, FuseQueue *q, __u32 cmd_op)
> +{
> + sqe->opcode = IORING_OP_URING_CMD;
> +
> + sqe->fd = q->fuse_fd;
> + sqe->rw_flags = 0;
> + sqe->ioprio = 0;
> + sqe->off = 0;
> +
> + sqe->cmd_op = cmd_op;
> + sqe->__pad1 = 0;
> +}
> +
> +static void fuse_uring_prep_sqe_register(struct io_uring_sqe *sqe, void *opaque)
> +{
> + FuseUringEnt *ent = opaque;
> + struct fuse_uring_cmd_req *req = (void *)&sqe->cmd[0];
> +
> + ent->last_cmd = FUSE_IO_URING_CMD_REGISTER;
> + fuse_uring_sqe_prepare(sqe, ent->rq->q, ent->last_cmd);
> +
> + sqe->addr = (uint64_t)(ent->iov);
> + sqe->len = 2;
> +
> + fuse_uring_sqe_set_req_data(req, ent->rq->rqid, 0);
> +}
> +
> +static void fuse_uring_resubmit(struct io_uring_sqe *sqe, void *opaque)
> +{
> + FuseUringEnt *ent = opaque;
> + struct fuse_uring_cmd_req *req = (void *)&sqe->cmd[0];
> +
> + fuse_uring_sqe_prepare(sqe, ent->rq->q, ent->last_cmd);
> +
> + switch (ent->last_cmd) {
> + case FUSE_IO_URING_CMD_REGISTER:
> + sqe->addr = (uint64_t)(ent->iov);
> + sqe->len = 2;
> + fuse_uring_sqe_set_req_data(req, ent->rq->rqid, 0);
> + break;
> + case FUSE_IO_URING_CMD_COMMIT_AND_FETCH:
> + fuse_uring_sqe_set_req_data(req, ent->rq->rqid, ent->req_commit_id);
> + break;
> + default:
> + error_report("Unknown command type: %d", ent->last_cmd);
> + break;
> + }
> +}
> +
> +static void fuse_uring_submit_register(void *opaque)
> +{
> + FuseUringQueue *rq = opaque;
> + FuseExport *exp = rq->q->exp;
> +
> + for (int j = 0; j < exp->uring_queue_depth; j++) {
> + /* Register a uring entry */
> + blk_exp_ref(&exp->common);
> +
> + aio_add_sqe(fuse_uring_prep_sqe_register, &rq->ent[j],
> + &rq->ent[j].fuse_cqe_handler);
> + }
> +}
> +
> +/**
> + * Distribute uring queues across FUSE queues in the round-robin manner.
> + * This ensures even distribution of kernel uring queues across user-specified
> + * FUSE queues.
> + *
> + * num_uring_queues > num_fuse_queues: Each IOThread manages multiple uring
> + * queues (multi-queue mapping).
> + * num_uring_queues < num_fuse_queues: Excess IOThreads remain idle with no
> + * assigned uring queues.
> + */
> +static void fuse_uring_setup_queues(FuseExport *exp, size_t bufsize)
> +{
> + int num_uring_queues = get_nprocs_conf();
> +
> + exp->num_uring_queues = num_uring_queues;
> + exp->uring_queues = g_new(FuseUringQueue, num_uring_queues);
> +
> + for (int i = 0; i < num_uring_queues; i++) {
> + FuseUringQueue *rq = &exp->uring_queues[i];
> + rq->rqid = i;
> + rq->ent = g_new(FuseUringEnt, exp->uring_queue_depth);
> +
> + for (int j = 0; j < exp->uring_queue_depth; j++) {
> + FuseUringEnt *ent = &rq->ent[j];
> + ent->rq = rq;
> + ent->req_payload_sz = bufsize - FUSE_BUFFER_HEADER_SIZE;
> + ent->req_payload = g_malloc0(ent->req_payload_sz);
I don't see a corresponding g_free() in this patch? Exports can be
deleted at runtime, so this memory must be freed.
> +
> + ent->iov[0] = (struct iovec) {
> + &ent->req_header,
> + sizeof(struct fuse_uring_req_header)
> + };
> + ent->iov[1] = (struct iovec) {
> + ent->req_payload,
> + ent->req_payload_sz
> + };
> +
> + ent->fuse_cqe_handler.cb = fuse_uring_cqe_handler;
> + }
> +
> + /* Distribute uring queues across FUSE queues */
> + rq->q = &exp->queues[i % exp->num_fuse_queues];
> + QLIST_INSERT_HEAD(&(rq->q->uring_queue_list), rq, next);
> + }
> +}
> +
> +static void
> +fuse_schedule_ring_queue_registrations(FuseExport *exp)
> +{
> + for (int i = 0; i < exp->num_fuse_queues; i++) {
> + FuseQueue *q = &exp->queues[i];
> + FuseUringQueue *rq;
> +
> + QLIST_FOREACH(rq, &q->uring_queue_list, next) {
> + aio_bh_schedule_oneshot(q->ctx, fuse_uring_submit_register, rq);
> + }
> + }
> +}
> +
> +static void fuse_uring_start(FuseExport *exp, struct fuse_init_out *out)
> +{
> + assert(!exp->uring_started);
> + exp->uring_started = true;
> +
> + /*
> + * Since we dont't enable the FUSE_MAX_PAGES feature, the value of
s/dont't/don't/
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2026-02-12 18:55 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-07 12:08 [PATCH v4 0/7] add fuse-over-io_uring support Brian Song
2026-02-07 12:08 ` [Patch v4 1/7] aio-posix: enable 128-byte SQEs Brian Song
2026-02-11 20:28 ` Stefan Hajnoczi
2026-02-07 12:08 ` [Patch v4 2/7] fuse: io_uring mode init Brian Song
2026-02-11 20:56 ` Stefan Hajnoczi [this message]
2026-02-13 8:40 ` Brian Song
2026-02-13 9:03 ` Brian Song
2026-02-19 14:42 ` Stefan Hajnoczi
2026-02-07 12:08 ` [Patch v4 3/7] fuse: uring support for write ops Brian Song
2026-02-11 21:08 ` Stefan Hajnoczi
2026-02-07 12:08 ` [Patch v4 4/7] fuse: refactor FUSE request handler Brian Song
2026-02-11 21:21 ` Stefan Hajnoczi
2026-02-13 8:07 ` Brian Song
2026-02-19 21:14 ` [PATCH] fuse: unify op_in for io_uring and classic FUSE Stefan Hajnoczi
2026-02-07 12:08 ` [Patch v4 5/6] fuse: safe termination for io_uring Brian Song
2026-02-11 21:52 ` Stefan Hajnoczi
2026-02-07 12:09 ` [Patch v4 6/7] fuse: add 'io-uring' option Brian Song
2026-02-09 5:24 ` Markus Armbruster
2026-02-11 22:50 ` Stefan Hajnoczi
2026-02-07 12:09 ` [Patch v4 7/7] fuse: add io_uring test support Brian Song
2026-02-11 21:53 ` Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260211205611.GB234157@fedora \
--to=stefanha@redhat.com \
--cc=armbru@redhat.com \
--cc=bernd@bsbernd.com \
--cc=eblake@redhat.com \
--cc=fam@euphon.net \
--cc=hibriansong@gmail.com \
--cc=hreitz@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.