fuse: move io_uring related members to fuse_chan

Move:

 - io_uring
 - ring

Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
This commit is contained in:
Miklos Szeredi 2026-03-17 15:29:04 +01:00
parent 599ad4427b
commit 0ea79b7d07
6 changed files with 26 additions and 26 deletions

View File

@ -80,7 +80,7 @@ void fuse_set_initialized(struct fuse_conn *fc)
static bool fuse_block_alloc(struct fuse_conn *fc, bool for_background)
{
return !fc->chan->initialized || (for_background && fc->chan->blocked) ||
(fc->io_uring && fc->chan->connected && !fuse_uring_ready(fc));
(fc->chan->io_uring && fc->chan->connected && !fuse_uring_ready(fc));
}
static void fuse_drop_waiting(struct fuse_conn *fc)

View File

@ -159,7 +159,7 @@ static bool ent_list_request_expired(struct fuse_conn *fc, struct list_head *lis
bool fuse_uring_request_expired(struct fuse_conn *fc)
{
struct fuse_ring *ring = fc->ring;
struct fuse_ring *ring = fc->chan->ring;
struct fuse_ring_queue *queue;
int qid;
@ -187,7 +187,7 @@ bool fuse_uring_request_expired(struct fuse_conn *fc)
void fuse_uring_destruct(struct fuse_conn *fc)
{
struct fuse_ring *ring = fc->ring;
struct fuse_ring *ring = fc->chan->ring;
int qid;
if (!ring)
@ -218,7 +218,7 @@ void fuse_uring_destruct(struct fuse_conn *fc)
kfree(ring->queues);
kfree(ring);
fc->ring = NULL;
fc->chan->ring = NULL;
}
/*
@ -231,7 +231,7 @@ static struct fuse_ring *fuse_uring_create(struct fuse_conn *fc)
struct fuse_ring *res = NULL;
size_t max_payload_size;
ring = kzalloc_obj(*fc->ring, GFP_KERNEL_ACCOUNT);
ring = kzalloc_obj(*fc->chan->ring, GFP_KERNEL_ACCOUNT);
if (!ring)
return NULL;
@ -248,10 +248,10 @@ static struct fuse_ring *fuse_uring_create(struct fuse_conn *fc)
spin_unlock(&fc->lock);
goto out_err;
}
if (fc->ring) {
if (fc->chan->ring) {
/* race, another thread created the ring in the meantime */
spin_unlock(&fc->lock);
res = fc->ring;
res = fc->chan->ring;
goto out_err;
}
@ -260,7 +260,7 @@ static struct fuse_ring *fuse_uring_create(struct fuse_conn *fc)
ring->nr_queues = nr_queues;
ring->fc = fc;
ring->max_payload_sz = max_payload_size;
smp_store_release(&fc->ring, ring);
smp_store_release(&fc->chan->ring, ring);
spin_unlock(&fc->lock);
return ring;
@ -898,7 +898,7 @@ static int fuse_uring_commit_fetch(struct io_uring_cmd *cmd, int issue_flags,
struct fuse_uring_cmd_req);
struct fuse_ring_ent *ent;
int err;
struct fuse_ring *ring = fc->ring;
struct fuse_ring *ring = fc->chan->ring;
struct fuse_ring_queue *queue;
uint64_t commit_id = READ_ONCE(cmd_req->commit_id);
unsigned int qid = READ_ONCE(cmd_req->qid);
@ -1118,7 +1118,7 @@ static int fuse_uring_register(struct io_uring_cmd *cmd,
{
const struct fuse_uring_cmd_req *cmd_req = io_uring_sqe128_cmd(cmd->sqe,
struct fuse_uring_cmd_req);
struct fuse_ring *ring = smp_load_acquire(&fc->ring);
struct fuse_ring *ring = smp_load_acquire(&fc->chan->ring);
struct fuse_ring_queue *queue;
struct fuse_ring_ent *ent;
int err;
@ -1183,7 +1183,7 @@ int fuse_uring_cmd(struct io_uring_cmd *cmd, unsigned int issue_flags)
fc = fud->fc;
/* Once a connection has io-uring enabled on it, it can't be disabled */
if (!enable_uring && !fc->io_uring) {
if (!enable_uring && !fc->chan->io_uring) {
pr_info_ratelimited("fuse-io-uring is disabled\n");
return -EOPNOTSUPP;
}
@ -1206,7 +1206,7 @@ int fuse_uring_cmd(struct io_uring_cmd *cmd, unsigned int issue_flags)
if (err) {
pr_info_once("FUSE_IO_URING_CMD_REGISTER failed err=%d\n",
err);
fc->io_uring = 0;
fc->chan->io_uring = 0;
wake_up_all(&fc->chan->blocked_waitq);
return err;
}
@ -1307,7 +1307,7 @@ static void fuse_uring_dispatch_ent(struct fuse_ring_ent *ent)
void fuse_uring_queue_fuse_req(struct fuse_iqueue *fiq, struct fuse_req *req)
{
struct fuse_conn *fc = req->fm->fc;
struct fuse_ring *ring = fc->ring;
struct fuse_ring *ring = fc->chan->ring;
struct fuse_ring_queue *queue;
struct fuse_ring_ent *ent = NULL;
int err;
@ -1350,7 +1350,7 @@ void fuse_uring_queue_fuse_req(struct fuse_iqueue *fiq, struct fuse_req *req)
bool fuse_uring_queue_bq_req(struct fuse_req *req)
{
struct fuse_conn *fc = req->fm->fc;
struct fuse_ring *ring = fc->ring;
struct fuse_ring *ring = fc->chan->ring;
struct fuse_ring_queue *queue;
struct fuse_ring_ent *ent = NULL;

View File

@ -148,7 +148,7 @@ bool fuse_uring_request_expired(struct fuse_conn *fc);
static inline void fuse_uring_abort(struct fuse_conn *fc)
{
struct fuse_ring *ring = fc->ring;
struct fuse_ring *ring = fc->chan->ring;
if (ring == NULL)
return;
@ -161,7 +161,7 @@ static inline void fuse_uring_abort(struct fuse_conn *fc)
static inline void fuse_uring_wait_stopped_queues(struct fuse_conn *fc)
{
struct fuse_ring *ring = fc->ring;
struct fuse_ring *ring = fc->chan->ring;
if (ring)
wait_event(ring->stop_waitq,
@ -170,7 +170,7 @@ static inline void fuse_uring_wait_stopped_queues(struct fuse_conn *fc)
static inline bool fuse_uring_ready(struct fuse_conn *fc)
{
struct fuse_ring *ring = READ_ONCE(fc->ring);
struct fuse_ring *ring = READ_ONCE(fc->chan->ring);
return ring && smp_load_acquire(&ring->ready);
}

View File

@ -127,6 +127,14 @@ struct fuse_chan {
/** The number of requests waiting for completion */
atomic_t num_waiting;
/* Use io_uring for communication */
unsigned int io_uring;
#ifdef CONFIG_FUSE_IO_URING
/** uring connection information*/
struct fuse_ring *ring;
#endif
};
#define FUSE_PQ_HASH_BITS 8

View File

@ -764,9 +764,6 @@ struct fuse_conn {
/* Is synchronous FUSE_INIT allowed? */
unsigned int sync_init:1;
/* Use io_uring for communication */
unsigned int io_uring;
/** Maximum stack depth for passthrough backing files */
int max_stack_depth;
@ -819,11 +816,6 @@ struct fuse_conn {
struct idr backing_files_map;
#endif
#ifdef CONFIG_FUSE_IO_URING
/** uring connection information*/
struct fuse_ring *ring;
#endif
/** Only used if the connection opts into request timeouts */
struct {
/* Worker for checking if any requests have timed out */

View File

@ -1412,7 +1412,7 @@ static void process_init_reply(struct fuse_mount *fm, struct fuse_args *args,
ok = false;
}
if (flags & FUSE_OVER_IO_URING && fuse_uring_enabled())
fc->io_uring = 1;
fc->chan->io_uring = 1;
if (flags & FUSE_REQUEST_TIMEOUT)
timeout = arg->request_timeout;