From: Miklos Szeredi <mszeredi@redhat.com>
To: fuse-devel@lists.linux.dev, linux-fsdevel@vger.kernel.org
Subject: [PATCH 22/32] fuse: change req->fm to req->chan
Date: Thu, 16 Apr 2026 11:16:46 +0200 [thread overview]
Message-ID: <20260416091658.462783-23-mszeredi@redhat.com> (raw)
In-Reply-To: <20260416091658.462783-1-mszeredi@redhat.com>
Store a struct fuse_chan pointer in fuse_req instead of a struct fuse_mount
pointer.
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
---
fs/fuse/dev.c | 117 +++++++++++++++++++++----------------------
fs/fuse/dev_uring.c | 17 +++----
fs/fuse/fuse_dev_i.h | 4 +-
fs/fuse/fuse_trace.h | 4 +-
4 files changed, 69 insertions(+), 73 deletions(-)
diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index f1e7e67912a3..5b74bd4d7cc3 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -35,22 +35,22 @@ static DECLARE_WAIT_QUEUE_HEAD(fuse_dev_waitq);
static struct kmem_cache *fuse_req_cachep;
-static void fuse_request_init(struct fuse_mount *fm, struct fuse_req *req)
+static void fuse_request_init(struct fuse_chan *fch, struct fuse_req *req)
{
INIT_LIST_HEAD(&req->list);
INIT_LIST_HEAD(&req->intr_entry);
init_waitqueue_head(&req->waitq);
refcount_set(&req->count, 1);
__set_bit(FR_PENDING, &req->flags);
- req->fm = fm;
+ req->chan = fch;
req->create_time = jiffies;
}
-static struct fuse_req *fuse_request_alloc(struct fuse_mount *fm, gfp_t flags)
+static struct fuse_req *fuse_request_alloc(struct fuse_chan *fch, gfp_t flags)
{
struct fuse_req *req = kmem_cache_zalloc(fuse_req_cachep, flags);
if (req)
- fuse_request_init(fm, req);
+ fuse_request_init(fch, req);
return req;
}
@@ -85,17 +85,17 @@ static bool fuse_block_alloc(struct fuse_conn *fc, bool for_background)
(fc->chan->io_uring && fc->chan->connected && !fuse_uring_ready(fc->chan));
}
-static void fuse_drop_waiting(struct fuse_conn *fc)
+static void fuse_drop_waiting(struct fuse_chan *fch)
{
/*
- * lockess check of fc->chan->connected is okay, because atomic_dec_and_test()
+ * lockess check of fch->connected is okay, because atomic_dec_and_test()
* provides a memory barrier matched with the one in fuse_chan_wait_aborted()
* to ensure no wake-up is missed.
*/
- if (atomic_dec_and_test(&fc->chan->num_waiting) &&
- !READ_ONCE(fc->chan->connected)) {
+ if (atomic_dec_and_test(&fch->num_waiting) &&
+ !READ_ONCE(fch->connected)) {
/* wake up aborters */
- wake_up_all(&fc->chan->blocked_waitq);
+ wake_up_all(&fch->blocked_waitq);
}
}
@@ -132,7 +132,7 @@ static struct fuse_req *fuse_get_req(struct mnt_idmap *idmap,
if (fc->conn_error)
goto out;
- req = fuse_request_alloc(fm, GFP_KERNEL);
+ req = fuse_request_alloc(fc->chan, GFP_KERNEL);
err = -ENOMEM;
if (!req) {
if (for_background)
@@ -169,13 +169,13 @@ static struct fuse_req *fuse_get_req(struct mnt_idmap *idmap,
return req;
out:
- fuse_drop_waiting(fc);
+ fuse_drop_waiting(fc->chan);
return ERR_PTR(err);
}
static void fuse_put_request(struct fuse_req *req)
{
- struct fuse_conn *fc = req->fm->fc;
+ struct fuse_chan *fch = req->chan;
if (refcount_dec_and_test(&req->count)) {
if (test_bit(FR_BACKGROUND, &req->flags)) {
@@ -183,15 +183,15 @@ static void fuse_put_request(struct fuse_req *req)
* We get here in the unlikely case that a background
* request was allocated but not sent
*/
- spin_lock(&fc->chan->bg_lock);
- if (!fc->chan->blocked)
- wake_up(&fc->chan->blocked_waitq);
- spin_unlock(&fc->chan->bg_lock);
+ spin_lock(&fch->bg_lock);
+ if (!fch->blocked)
+ wake_up(&fch->blocked_waitq);
+ spin_unlock(&fch->bg_lock);
}
if (test_bit(FR_WAITING, &req->flags)) {
__clear_bit(FR_WAITING, &req->flags);
- fuse_drop_waiting(fc);
+ fuse_drop_waiting(fch);
}
fuse_request_free(req);
@@ -594,9 +594,8 @@ static void flush_bg_queue(struct fuse_chan *fch)
*/
void fuse_request_end(struct fuse_req *req)
{
- struct fuse_mount *fm = req->fm;
- struct fuse_conn *fc = fm->fc;
- struct fuse_iqueue *fiq = &fc->chan->iq;
+ struct fuse_chan *fch = req->chan;
+ struct fuse_iqueue *fiq = &fch->iq;
if (test_and_set_bit(FR_FINISHED, &req->flags))
goto put_request;
@@ -615,26 +614,26 @@ void fuse_request_end(struct fuse_req *req)
WARN_ON(test_bit(FR_PENDING, &req->flags));
WARN_ON(test_bit(FR_SENT, &req->flags));
if (test_bit(FR_BACKGROUND, &req->flags)) {
- spin_lock(&fc->chan->bg_lock);
+ spin_lock(&fch->bg_lock);
clear_bit(FR_BACKGROUND, &req->flags);
- if (fc->chan->num_background == fc->chan->max_background) {
- fc->chan->blocked = 0;
- wake_up(&fc->chan->blocked_waitq);
- } else if (!fc->chan->blocked) {
+ if (fch->num_background == fch->max_background) {
+ fch->blocked = 0;
+ wake_up(&fch->blocked_waitq);
+ } else if (!fch->blocked) {
/*
* Wake up next waiter, if any. It's okay to use
* waitqueue_active(), as we've already synced up
- * fc->chan->blocked with waiters with the wake_up() call
+ * fch->blocked with waiters with the wake_up() call
* above.
*/
- if (waitqueue_active(&fc->chan->blocked_waitq))
- wake_up(&fc->chan->blocked_waitq);
+ if (waitqueue_active(&fch->blocked_waitq))
+ wake_up(&fch->blocked_waitq);
}
- fc->chan->num_background--;
- fc->chan->active_background--;
- flush_bg_queue(fc->chan);
- spin_unlock(&fc->chan->bg_lock);
+ fch->num_background--;
+ fch->active_background--;
+ flush_bg_queue(fch);
+ spin_unlock(&fch->bg_lock);
} else {
/* Wake up waiter sleeping in request_wait_answer() */
wake_up(&req->waitq);
@@ -649,7 +648,7 @@ EXPORT_SYMBOL_GPL(fuse_request_end);
static int queue_interrupt(struct fuse_req *req)
{
- struct fuse_iqueue *fiq = &req->fm->fc->chan->iq;
+ struct fuse_iqueue *fiq = &req->chan->iq;
/* Check for we've sent request to interrupt this req */
if (unlikely(!test_bit(FR_INTERRUPTED, &req->flags)))
@@ -680,11 +679,11 @@ bool fuse_remove_pending_req(struct fuse_req *req, spinlock_t *lock)
static void request_wait_answer(struct fuse_req *req)
{
- struct fuse_conn *fc = req->fm->fc;
- struct fuse_iqueue *fiq = &fc->chan->iq;
+ struct fuse_chan *fch = req->chan;
+ struct fuse_iqueue *fiq = &fch->iq;
int err;
- if (!fc->chan->no_interrupt) {
+ if (!fch->no_interrupt) {
/* Any signal may interrupt this */
err = wait_event_interruptible(req->waitq,
test_bit(FR_FINISHED, &req->flags));
@@ -708,7 +707,7 @@ static void request_wait_answer(struct fuse_req *req)
return;
if (req->args->abort_on_kill) {
- fuse_chan_abort(fc->chan, false);
+ fuse_chan_abort(fch, false);
return;
}
@@ -729,7 +728,7 @@ static void request_wait_answer(struct fuse_req *req)
static void __fuse_request_send(struct fuse_req *req)
{
- struct fuse_iqueue *fiq = &req->fm->fc->chan->iq;
+ struct fuse_iqueue *fiq = &req->chan->iq;
BUG_ON(test_bit(FR_BACKGROUND, &req->flags));
@@ -776,11 +775,11 @@ static void fuse_adjust_compat(struct fuse_conn *fc, struct fuse_args *args)
}
}
-static void fuse_force_creds(struct fuse_req *req)
+static void fuse_force_creds(struct fuse_mount *fm, struct fuse_req *req)
{
- struct fuse_conn *fc = req->fm->fc;
+ struct fuse_conn *fc = fm->fc;
- if (!req->fm->sb || req->fm->sb->s_iflags & SB_I_NOIDMAP) {
+ if (!fm->sb || fm->sb->s_iflags & SB_I_NOIDMAP) {
req->in.h.uid = from_kuid_munged(fc->user_ns, current_fsuid());
req->in.h.gid = from_kgid_munged(fc->user_ns, current_fsgid());
} else {
@@ -812,10 +811,10 @@ ssize_t __fuse_simple_request(struct mnt_idmap *idmap,
if (args->force) {
atomic_inc(&fc->chan->num_waiting);
- req = fuse_request_alloc(fm, GFP_KERNEL | __GFP_NOFAIL);
+ req = fuse_request_alloc(fc->chan, GFP_KERNEL | __GFP_NOFAIL);
if (!args->nocreds)
- fuse_force_creds(req);
+ fuse_force_creds(fm, req);
__set_bit(FR_WAITING, &req->flags);
if (!args->abort_on_kill)
@@ -845,10 +844,9 @@ ssize_t __fuse_simple_request(struct mnt_idmap *idmap,
}
#ifdef CONFIG_FUSE_IO_URING
-static bool fuse_request_queue_background_uring(struct fuse_conn *fc,
- struct fuse_req *req)
+static bool fuse_request_queue_background_uring(struct fuse_req *req)
{
- struct fuse_iqueue *fiq = &fc->chan->iq;
+ struct fuse_iqueue *fiq = &req->chan->iq;
req->in.h.len = sizeof(struct fuse_in_header) +
fuse_len_args(req->args->in_numargs,
@@ -864,32 +862,31 @@ static bool fuse_request_queue_background_uring(struct fuse_conn *fc,
*/
static int fuse_request_queue_background(struct fuse_req *req)
{
- struct fuse_mount *fm = req->fm;
- struct fuse_conn *fc = fm->fc;
+ struct fuse_chan *fch = req->chan;
bool queued = false;
WARN_ON(!test_bit(FR_BACKGROUND, &req->flags));
if (!test_bit(FR_WAITING, &req->flags)) {
__set_bit(FR_WAITING, &req->flags);
- atomic_inc(&fc->chan->num_waiting);
+ atomic_inc(&fch->num_waiting);
}
__set_bit(FR_ISREPLY, &req->flags);
#ifdef CONFIG_FUSE_IO_URING
- if (fuse_uring_ready(fc->chan))
- return fuse_request_queue_background_uring(fc, req);
+ if (fuse_uring_ready(fch))
+ return fuse_request_queue_background_uring(req);
#endif
- spin_lock(&fc->chan->bg_lock);
- if (likely(fc->chan->connected)) {
- fc->chan->num_background++;
- if (fc->chan->num_background == fc->chan->max_background)
- fc->chan->blocked = 1;
- list_add_tail(&req->list, &fc->chan->bg_queue);
- flush_bg_queue(fc->chan);
+ spin_lock(&fch->bg_lock);
+ if (likely(fch->connected)) {
+ fch->num_background++;
+ if (fch->num_background == fch->max_background)
+ fch->blocked = 1;
+ list_add_tail(&req->list, &fch->bg_queue);
+ flush_bg_queue(fch);
queued = true;
}
- spin_unlock(&fc->chan->bg_lock);
+ spin_unlock(&fch->bg_lock);
return queued;
}
@@ -901,7 +898,7 @@ int fuse_simple_background(struct fuse_mount *fm, struct fuse_args *args,
if (args->force) {
WARN_ON(!args->nocreds);
- req = fuse_request_alloc(fm, gfp_flags);
+ req = fuse_request_alloc(fm->fc->chan, gfp_flags);
if (!req)
return -ENOMEM;
__set_bit(FR_BACKGROUND, &req->flags);
diff --git a/fs/fuse/dev_uring.c b/fs/fuse/dev_uring.c
index 4a0291a1f371..3ef7977dc8de 100644
--- a/fs/fuse/dev_uring.c
+++ b/fs/fuse/dev_uring.c
@@ -1262,8 +1262,7 @@ static void fuse_uring_dispatch_ent(struct fuse_ring_ent *ent)
/* queue a fuse request and send it if a ring entry is available */
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->chan->ring;
+ struct fuse_ring *ring = req->chan->ring;
struct fuse_ring_queue *queue;
struct fuse_ring_ent *ent = NULL;
int err;
@@ -1305,8 +1304,8 @@ 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->chan->ring;
+ struct fuse_chan *fch = req->chan;
+ struct fuse_ring *ring = fch->ring;
struct fuse_ring_queue *queue;
struct fuse_ring_ent *ent = NULL;
@@ -1326,12 +1325,12 @@ bool fuse_uring_queue_bq_req(struct fuse_req *req)
ent = list_first_entry_or_null(&queue->ent_avail_queue,
struct fuse_ring_ent, list);
- spin_lock(&fc->chan->bg_lock);
- fc->chan->num_background++;
- if (fc->chan->num_background == fc->chan->max_background)
- fc->chan->blocked = 1;
+ spin_lock(&fch->bg_lock);
+ fch->num_background++;
+ if (fch->num_background == fch->max_background)
+ fch->blocked = 1;
fuse_uring_flush_bg(queue);
- spin_unlock(&fc->chan->bg_lock);
+ spin_unlock(&fch->bg_lock);
/*
* Due to bg_queue flush limits there might be other bg requests
diff --git a/fs/fuse/fuse_dev_i.h b/fs/fuse/fuse_dev_i.h
index 534d037799ff..3248a417ade9 100644
--- a/fs/fuse/fuse_dev_i.h
+++ b/fs/fuse/fuse_dev_i.h
@@ -97,8 +97,8 @@ struct fuse_req {
void *argbuf;
#endif
- /** fuse_mount this request belongs to */
- struct fuse_mount *fm;
+ /** fuse_chan this request belongs to */
+ struct fuse_chan *chan;
#ifdef CONFIG_FUSE_IO_URING
void *ring_entry;
diff --git a/fs/fuse/fuse_trace.h b/fs/fuse/fuse_trace.h
index bbe9ddd8c716..4e34ddb172ed 100644
--- a/fs/fuse/fuse_trace.h
+++ b/fs/fuse/fuse_trace.h
@@ -90,7 +90,7 @@ TRACE_EVENT(fuse_request_send,
),
TP_fast_assign(
- __entry->connection = req->fm->fc->dev;
+ __entry->connection = req->chan->conn->dev;
__entry->unique = req->in.h.unique;
__entry->opcode = req->in.h.opcode;
__entry->len = req->in.h.len;
@@ -114,7 +114,7 @@ TRACE_EVENT(fuse_request_end,
),
TP_fast_assign(
- __entry->connection = req->fm->fc->dev;
+ __entry->connection = req->chan->conn->dev;
__entry->unique = req->in.h.unique;
__entry->len = req->out.h.len;
__entry->error = req->out.h.error;
--
2.53.0
next prev parent reply other threads:[~2026-04-16 9:17 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-16 9:16 [PATCH 00/32] fuse: improve transport and fs layer separation Miklos Szeredi
2026-04-16 9:16 ` [PATCH 01/32] fuse: move request timeout code to a new source file Miklos Szeredi
2026-04-16 9:16 ` [PATCH 02/32] fuse: add struct fuse_chan Miklos Szeredi
2026-04-16 9:16 ` [PATCH 03/32] fuse: move fuse_iqueue to fuse_chan Miklos Szeredi
2026-04-16 9:16 ` [PATCH 04/32] fuse: move fuse_dev and fuse_pqueue to dev.c Miklos Szeredi
2026-04-16 9:16 ` [PATCH 05/32] fuse: move 'devices' member from fuse_conn to fuse_chan Miklos Szeredi
2026-04-16 9:16 ` [PATCH 06/32] fuse: move background queuing related members " Miklos Szeredi
2026-04-22 17:53 ` Joanne Koong
2026-04-23 7:20 ` Miklos Szeredi
2026-04-16 9:16 ` [PATCH 07/32] fuse: move request blocking " Miklos Szeredi
2026-04-16 9:16 ` [PATCH 08/32] fuse: move io_uring " Miklos Szeredi
2026-04-16 9:16 ` [PATCH 09/32] fuse: move interrupt " Miklos Szeredi
2026-04-16 9:16 ` [PATCH 10/32] fuse: split off fch->lock from fc->lock Miklos Szeredi
2026-04-16 9:16 ` [PATCH 11/32] fuse: add back pointer from fuse_chan to fuse_conn Miklos Szeredi
2026-04-16 9:16 ` [PATCH 12/32] fuse: move request timeout to fuse_chan Miklos Szeredi
2026-04-16 9:16 ` [PATCH 13/32] fuse: move struct fuse_req and related to fuse_dev_i.h Miklos Szeredi
2026-04-16 9:16 ` [PATCH 14/32] fuse: don't access transport layer structs directly from the fs layer Miklos Szeredi
2026-04-16 9:16 ` [PATCH 15/32] fuse: move forget related struct and helpers Miklos Szeredi
2026-04-16 9:16 ` [PATCH 16/32] fuse: move fuse_dev_waitq to dev.c Miklos Szeredi
2026-04-16 9:16 ` [PATCH 17/32] fuse: remove #include "fuse_i.h" from "dev_uring_i.h" Miklos Szeredi
2026-04-16 9:16 ` [PATCH 18/32] fuse: remove #include "fuse_i.h" from "req_timeout.c" Miklos Szeredi
2026-04-16 9:16 ` [PATCH 19/32] fuse: abort related layering cleanup Miklos Szeredi
2026-04-16 9:16 ` [PATCH 20/32] fuse: split off fuse_args and related definitions into a separate header Miklos Szeredi
2026-04-17 21:52 ` Joanne Koong
2026-04-20 10:14 ` Miklos Szeredi
2026-04-16 9:16 ` [PATCH 21/32] fuse: remove fm arg of args->end callback Miklos Szeredi
2026-04-16 9:16 ` Miklos Szeredi [this message]
2026-04-16 9:16 ` [PATCH 23/32] fuse: split out filesystem part of request sending Miklos Szeredi
2026-04-16 9:16 ` [PATCH 24/32] fuse: change fud->fc to fud->chan Miklos Szeredi
2026-04-16 9:16 ` [PATCH 25/32] fuse: create poll.c Miklos Szeredi
2026-04-16 9:16 ` [PATCH 26/32] fuse: create notify.c Miklos Szeredi
2026-04-16 9:16 ` [PATCH 27/32] fuse: set params in fuse_chan_set_initialized() Miklos Szeredi
2026-04-22 17:41 ` Joanne Koong
2026-04-23 7:19 ` Miklos Szeredi
2026-04-16 9:16 ` [PATCH 28/32] fuse: remove fuse_mutex protection from fuse_dev_ioctl_sync_init() Miklos Szeredi
2026-04-16 9:16 ` [PATCH 29/32] fuse: change ring->fc to ring->chan Miklos Szeredi
2026-04-16 9:16 ` [PATCH 30/32] fuse: remove #include "fuse_i.h" from dev.c and dev_uring.c Miklos Szeredi
2026-04-16 9:16 ` [PATCH 31/32] fuse: alloc pqueue before installing fch in fuse_dev Miklos Szeredi
2026-04-22 19:30 ` Joanne Koong
2026-04-16 9:16 ` [PATCH 32/32] fuse: simplify fuse_dev_ioctl_clone() Miklos Szeredi
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=20260416091658.462783-23-mszeredi@redhat.com \
--to=mszeredi@redhat.com \
--cc=fuse-devel@lists.linux.dev \
--cc=linux-fsdevel@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox