From: Miklos Szeredi <mszeredi@redhat.com>
To: fuse-devel@lists.linux.dev, linux-fsdevel@vger.kernel.org
Subject: [PATCH 02/32] fuse: add struct fuse_chan
Date: Thu, 16 Apr 2026 11:16:26 +0200 [thread overview]
Message-ID: <20260416091658.462783-3-mszeredi@redhat.com> (raw)
In-Reply-To: <20260416091658.462783-1-mszeredi@redhat.com>
The goal is to separate transport layer stuff out from struct fuse_conn,
leaving just the filesystem related members.
Add a new object referenced from fuse_conn. This patch just implements the
allocation and freeing of this object.
Following patches will move transport related members from fuse_conn to
fuse_chan.
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
---
fs/fuse/cuse.c | 7 ++++++-
fs/fuse/dev.c | 13 +++++++++++++
fs/fuse/dev.h | 7 +++++++
fs/fuse/fuse_dev_i.h | 4 ++++
fs/fuse/fuse_i.h | 6 +++++-
fs/fuse/inode.c | 10 ++++++++--
fs/fuse/virtio_fs.c | 8 +++++++-
7 files changed, 50 insertions(+), 5 deletions(-)
diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
index 174333633471..b135c3281a05 100644
--- a/fs/fuse/cuse.c
+++ b/fs/fuse/cuse.c
@@ -51,6 +51,7 @@
#include <linux/uio.h>
#include <linux/user_namespace.h>
+#include "dev.h"
#include "fuse_i.h"
#include "fuse_dev_i.h"
@@ -502,8 +503,12 @@ static int cuse_channel_open(struct inode *inode, struct file *file)
{
struct fuse_dev *fud;
struct cuse_conn *cc;
+ struct fuse_chan *fch __free(fuse_chan_free) = fuse_chan_new();
int rc;
+ if (!fch)
+ return -ENOMEM;
+
/* set up cuse_conn */
cc = kzalloc_obj(*cc);
if (!cc)
@@ -514,7 +519,7 @@ static int cuse_channel_open(struct inode *inode, struct file *file)
* be represented in file->f_cred->user_ns.
*/
fuse_conn_init(&cc->fc, &cc->fm, file->f_cred->user_ns,
- &fuse_dev_fiq_ops, NULL);
+ &fuse_dev_fiq_ops, NULL, no_free_ptr(fch));
cc->fc.release = cuse_fc_release;
fud = fuse_dev_alloc_install(&cc->fc);
diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index eea85eaa5e77..3e1e8ce83f1c 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -6,6 +6,7 @@
See the file COPYING.
*/
+#include "dev.h"
#include "dev_uring_i.h"
#include "fuse_i.h"
#include "fuse_dev_i.h"
@@ -319,6 +320,18 @@ const struct fuse_iqueue_ops fuse_dev_fiq_ops = {
};
EXPORT_SYMBOL_GPL(fuse_dev_fiq_ops);
+void fuse_chan_free(struct fuse_chan *fch)
+{
+ kfree(fch);
+}
+EXPORT_SYMBOL_GPL(fuse_chan_free);
+
+struct fuse_chan *fuse_chan_new(void)
+{
+ return kzalloc_obj(struct fuse_chan);
+}
+EXPORT_SYMBOL_GPL(fuse_chan_new);
+
static void fuse_send_one(struct fuse_iqueue *fiq, struct fuse_req *req)
{
req->in.h.len = sizeof(struct fuse_in_header) +
diff --git a/fs/fuse/dev.h b/fs/fuse/dev.h
index f7db15c33cf9..70e4a75e6942 100644
--- a/fs/fuse/dev.h
+++ b/fs/fuse/dev.h
@@ -3,7 +3,14 @@
#ifndef _FS_FUSE_DEV_H
#define _FS_FUSE_DEV_H
+#include <linux/cleanup.h>
+
struct fuse_conn;
+struct fuse_chan;
+
+struct fuse_chan *fuse_chan_new(void);
+void fuse_chan_free(struct fuse_chan *fch);
+DEFINE_FREE(fuse_chan_free, struct fuse_chan *, if (_T) fuse_chan_free(_T))
void fuse_init_server_timeout(struct fuse_conn *fc, unsigned int timeout);
diff --git a/fs/fuse/fuse_dev_i.h b/fs/fuse/fuse_dev_i.h
index 910f883cd090..8d69ea8761c5 100644
--- a/fs/fuse/fuse_dev_i.h
+++ b/fs/fuse/fuse_dev_i.h
@@ -21,6 +21,10 @@ struct fuse_req;
struct fuse_iqueue;
struct fuse_forget_link;
+struct fuse_chan {
+ /* will move stuff from struct fuse_conn */
+};
+
struct fuse_copy_state {
struct fuse_req *req;
struct iov_iter *iter;
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index 111fb6f3ebc4..deaffe245284 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -668,6 +668,9 @@ struct fuse_conn {
/** Input queue */
struct fuse_iqueue iq;
+ /* transport layer object */
+ struct fuse_chan *chan;
+
/** The next unique kernel file handle */
atomic64_t khctr;
@@ -1313,7 +1316,8 @@ void fuse_pqueue_init(struct fuse_pqueue *fpq);
*/
void fuse_conn_init(struct fuse_conn *fc, struct fuse_mount *fm,
struct user_namespace *user_ns,
- const struct fuse_iqueue_ops *fiq_ops, void *fiq_priv);
+ const struct fuse_iqueue_ops *fiq_ops, void *fiq_priv,
+ struct fuse_chan *fch);
/**
* Release reference to fuse_conn
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index db0ef19f4abe..758cefa9b9b6 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -997,7 +997,7 @@ void fuse_pqueue_init(struct fuse_pqueue *fpq)
void fuse_conn_init(struct fuse_conn *fc, struct fuse_mount *fm,
struct user_namespace *user_ns,
- const struct fuse_iqueue_ops *fiq_ops, void *fiq_priv)
+ const struct fuse_iqueue_ops *fiq_ops, void *fiq_priv, struct fuse_chan *fch)
{
memset(fc, 0, sizeof(*fc));
spin_lock_init(&fc->lock);
@@ -1035,6 +1035,7 @@ void fuse_conn_init(struct fuse_conn *fc, struct fuse_mount *fm,
INIT_LIST_HEAD(&fc->mounts);
list_add(&fm->fc_entry, &fc->mounts);
fm->fc = fc;
+ fc->chan = fch;
}
EXPORT_SYMBOL_GPL(fuse_conn_init);
@@ -1043,6 +1044,7 @@ static void delayed_release(struct rcu_head *p)
struct fuse_conn *fc = container_of(p, struct fuse_conn, rcu);
fuse_uring_destruct(fc);
+ fuse_chan_free(fc->chan);
put_user_ns(fc->user_ns);
fc->release(fc);
@@ -1982,8 +1984,12 @@ static int fuse_get_tree(struct fs_context *fsc)
struct fuse_conn *fc;
struct fuse_mount *fm;
struct super_block *sb;
+ struct fuse_chan *fch __free(fuse_chan_free) = fuse_chan_new();
int err;
+ if (!fch)
+ return -ENOMEM;
+
fc = kmalloc_obj(*fc);
if (!fc)
return -ENOMEM;
@@ -1994,7 +2000,7 @@ static int fuse_get_tree(struct fs_context *fsc)
return -ENOMEM;
}
- fuse_conn_init(fc, fm, fsc->user_ns, &fuse_dev_fiq_ops, NULL);
+ fuse_conn_init(fc, fm, fsc->user_ns, &fuse_dev_fiq_ops, NULL, no_free_ptr(fch));
fc->release = fuse_free_conn;
fsc->s_fs_info = fm;
diff --git a/fs/fuse/virtio_fs.c b/fs/fuse/virtio_fs.c
index 12300651a0f1..f6d41b760210 100644
--- a/fs/fuse/virtio_fs.c
+++ b/fs/fuse/virtio_fs.c
@@ -19,6 +19,7 @@
#include <linux/highmem.h>
#include <linux/cleanup.h>
#include <linux/uio.h>
+#include "dev.h"
#include "fuse_i.h"
#include "fuse_dev_i.h"
@@ -1683,8 +1684,12 @@ static int virtio_fs_get_tree(struct fs_context *fsc)
struct fuse_conn *fc = NULL;
struct fuse_mount *fm;
unsigned int virtqueue_size;
+ struct fuse_chan *fch __free(fuse_chan_free) = fuse_chan_new();
int err = -EIO;
+ if (!fch)
+ return -ENOMEM;
+
if (!fsc->source)
return invalf(fsc, "No source specified");
@@ -1711,7 +1716,8 @@ static int virtio_fs_get_tree(struct fs_context *fsc)
if (!fm)
goto out_err;
- fuse_conn_init(fc, fm, fsc->user_ns, &virtio_fs_fiq_ops, fs);
+ fuse_conn_init(fc, fm, fsc->user_ns, &virtio_fs_fiq_ops, fs, no_free_ptr(fch));
+
fc->release = fuse_free_conn;
fc->delete_stale = true;
fc->auto_submounts = true;
--
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 ` Miklos Szeredi [this message]
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 ` [PATCH 22/32] fuse: change req->fm to req->chan Miklos Szeredi
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-3-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