Move the 'fiq' member from fuse_conn to fuse_chan.
Move iqueue related structure definitions and function declarations from
"fuse_i.h" to "fuse_dev_i.h".
Add a fuse_dev_chan_new() helper, that returns a fuse_chan initialized with
the fuse_dev_fiq_ops.
Add a fuse_chan_release() function, that calls fiq->ops->release().
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
{
struct fuse_dev *fud;
struct cuse_conn *cc;
- struct fuse_chan *fch __free(fuse_chan_free) = fuse_chan_new();
+ struct fuse_chan *fch __free(fuse_chan_free) = fuse_dev_chan_new();
int rc;
if (!fch)
* Limit the cuse channel to requests that can
* 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, no_free_ptr(fch));
-
+ fuse_conn_init(&cc->fc, &cc->fm, file->f_cred->user_ns, no_free_ptr(fch));
cc->fc.release = cuse_fc_release;
fud = fuse_dev_alloc_install(&cc->fc);
fuse_conn_put(&cc->fc);
}
}
-const struct fuse_iqueue_ops fuse_dev_fiq_ops = {
+static const struct fuse_iqueue_ops fuse_dev_fiq_ops = {
.send_forget = fuse_dev_queue_forget,
.send_interrupt = fuse_dev_queue_interrupt,
.send_req = fuse_dev_queue_req,
};
-EXPORT_SYMBOL_GPL(fuse_dev_fiq_ops);
+
+void fuse_iqueue_init(struct fuse_iqueue *fiq, const struct fuse_iqueue_ops *ops, void *priv)
+{
+ spin_lock_init(&fiq->lock);
+ init_waitqueue_head(&fiq->waitq);
+ INIT_LIST_HEAD(&fiq->pending);
+ INIT_LIST_HEAD(&fiq->interrupts);
+ fiq->forget_list_tail = &fiq->forget_list_head;
+ fiq->connected = 1;
+ fiq->ops = ops;
+ fiq->priv = priv;
+}
+EXPORT_SYMBOL_GPL(fuse_iqueue_init);
+
+void fuse_chan_release(struct fuse_chan *fch)
+{
+ struct fuse_iqueue *fiq = &fch->iq;
+
+ if (fiq->ops->release)
+ fiq->ops->release(fiq);
+}
void fuse_chan_free(struct fuse_chan *fch)
{
}
EXPORT_SYMBOL_GPL(fuse_chan_new);
+struct fuse_chan *fuse_dev_chan_new(void)
+{
+ struct fuse_chan *fch = fuse_chan_new();
+ if (!fch)
+ return NULL;
+
+ fuse_iqueue_init(&fch->iq, &fuse_dev_fiq_ops, NULL);
+
+ return fch;
+}
+EXPORT_SYMBOL_GPL(fuse_dev_chan_new);
+
static void fuse_send_one(struct fuse_iqueue *fiq, struct fuse_req *req)
{
req->in.h.len = sizeof(struct fuse_in_header) +
void fuse_queue_forget(struct fuse_conn *fc, struct fuse_forget_link *forget,
u64 nodeid, u64 nlookup)
{
- struct fuse_iqueue *fiq = &fc->iq;
+ struct fuse_iqueue *fiq = &fc->chan->iq;
forget->forget_one.nodeid = nodeid;
forget->forget_one.nlookup = nlookup;
static void flush_bg_queue(struct fuse_conn *fc)
{
- struct fuse_iqueue *fiq = &fc->iq;
+ struct fuse_iqueue *fiq = &fc->chan->iq;
while (fc->active_background < fc->max_background &&
!list_empty(&fc->bg_queue)) {
{
struct fuse_mount *fm = req->fm;
struct fuse_conn *fc = fm->fc;
- struct fuse_iqueue *fiq = &fc->iq;
+ struct fuse_iqueue *fiq = &fc->chan->iq;
if (test_and_set_bit(FR_FINISHED, &req->flags))
goto put_request;
static int queue_interrupt(struct fuse_req *req)
{
- struct fuse_iqueue *fiq = &req->fm->fc->iq;
+ struct fuse_iqueue *fiq = &req->fm->fc->chan->iq;
/* Check for we've sent request to interrupt this req */
if (unlikely(!test_bit(FR_INTERRUPTED, &req->flags)))
static void request_wait_answer(struct fuse_req *req)
{
struct fuse_conn *fc = req->fm->fc;
- struct fuse_iqueue *fiq = &fc->iq;
+ struct fuse_iqueue *fiq = &fc->chan->iq;
int err;
if (!fc->no_interrupt) {
static void __fuse_request_send(struct fuse_req *req)
{
- struct fuse_iqueue *fiq = &req->fm->fc->iq;
+ struct fuse_iqueue *fiq = &req->fm->fc->chan->iq;
BUG_ON(test_bit(FR_BACKGROUND, &req->flags));
static bool fuse_request_queue_background_uring(struct fuse_conn *fc,
struct fuse_req *req)
{
- struct fuse_iqueue *fiq = &fc->iq;
+ struct fuse_iqueue *fiq = &fc->chan->iq;
req->in.h.len = sizeof(struct fuse_in_header) +
fuse_len_args(req->args->in_numargs,
struct fuse_args *args, u64 unique)
{
struct fuse_req *req;
- struct fuse_iqueue *fiq = &fm->fc->iq;
+ struct fuse_iqueue *fiq = &fm->fc->chan->iq;
req = fuse_get_req(&invalid_mnt_idmap, fm, false);
if (IS_ERR(req))
{
ssize_t err;
struct fuse_conn *fc = fud->fc;
- struct fuse_iqueue *fiq = &fc->iq;
+ struct fuse_iqueue *fiq = &fc->chan->iq;
struct fuse_pqueue *fpq = &fud->pq;
struct fuse_req *req;
struct fuse_args *args;
{
struct fuse_dev *fud;
struct fuse_req *req, *next;
- struct fuse_iqueue *fiq = &fc->iq;
+ struct fuse_iqueue *fiq = &fc->chan->iq;
LIST_HEAD(to_queue);
unsigned int i;
if (IS_ERR(fud))
return EPOLLERR;
- fiq = &fud->fc->iq;
+ fiq = &fud->fc->chan->iq;
poll_wait(file, &fiq->waitq, wait);
spin_lock(&fiq->lock);
*/
void fuse_abort_conn(struct fuse_conn *fc)
{
- struct fuse_iqueue *fiq = &fc->iq;
+ struct fuse_iqueue *fiq = &fc->chan->iq;
spin_lock(&fc->lock);
if (fc->connected) {
spin_unlock(&fc->lock);
if (last) {
- WARN_ON(fc->iq.fasync != NULL);
+ WARN_ON(fc->chan->iq.fasync != NULL);
fuse_abort_conn(fc);
}
fuse_conn_put(fc);
return PTR_ERR(fud);
/* No locking - fasync_helper does its own locking */
- return fasync_helper(fd, file, on, &fud->fc->iq.fasync);
+ return fasync_helper(fd, file, on, &fud->fc->chan->iq.fasync);
}
static long fuse_dev_ioctl_clone(struct file *file, __u32 __user *argp)
struct fuse_chan;
struct fuse_chan *fuse_chan_new(void);
+struct fuse_chan *fuse_dev_chan_new(void);
+void fuse_chan_release(struct fuse_chan *fch);
void fuse_chan_free(struct fuse_chan *fch);
DEFINE_FREE(fuse_chan_free, struct fuse_chan *, if (_T) fuse_chan_free(_T))
struct fuse_ring_queue *queue = ent->queue;
struct fuse_ring *ring = queue->ring;
struct fuse_conn *fc = ring->fc;
- struct fuse_iqueue *fiq = &fc->iq;
+ struct fuse_iqueue *fiq = &fc->chan->iq;
spin_lock(&fc->lock);
/* abort teardown path is running or has run */
#define _FS_FUSE_DEV_URING_I_H
#include "fuse_i.h"
+#include "fuse_dev_i.h"
#ifdef CONFIG_FUSE_IO_URING
struct fuse_iqueue;
struct fuse_forget_link;
+/**
+ * Input queue callbacks
+ *
+ * Input queue signalling is device-specific. For example, the /dev/fuse file
+ * uses fiq->waitq and fasync to wake processes that are waiting on queue
+ * readiness. These callbacks allow other device types to respond to input
+ * queue activity.
+ */
+struct fuse_iqueue_ops {
+ /**
+ * Send one forget
+ */
+ void (*send_forget)(struct fuse_iqueue *fiq, struct fuse_forget_link *link);
+
+ /**
+ * Send interrupt for request
+ */
+ void (*send_interrupt)(struct fuse_iqueue *fiq, struct fuse_req *req);
+
+ /**
+ * Send one request
+ */
+ void (*send_req)(struct fuse_iqueue *fiq, struct fuse_req *req);
+
+ /**
+ * Clean up when fuse_iqueue is destroyed
+ */
+ void (*release)(struct fuse_iqueue *fiq);
+};
+
+struct fuse_iqueue {
+ /** Connection established */
+ unsigned connected;
+
+ /** Lock protecting accesses to members of this structure */
+ spinlock_t lock;
+
+ /** Readers of the connection are waiting on this */
+ wait_queue_head_t waitq;
+
+ /** The next unique request id */
+ u64 reqctr;
+
+ /** The list of pending requests */
+ struct list_head pending;
+
+ /** Pending interrupts */
+ struct list_head interrupts;
+
+ /** Queue of pending forgets */
+ struct fuse_forget_link forget_list_head;
+ struct fuse_forget_link *forget_list_tail;
+
+ /** Batching of FORGET requests (positive indicates FORGET batch) */
+ int forget_batch;
+
+ /** O_ASYNC requests */
+ struct fasync_struct *fasync;
+
+ /** Device-specific callbacks */
+ const struct fuse_iqueue_ops *ops;
+
+ /** Device-specific state */
+ void *priv;
+};
+
struct fuse_chan {
- /* will move stuff from struct fuse_conn */
+ /** Input queue */
+ struct fuse_iqueue iq;
};
struct fuse_copy_state {
return fud;
}
+void fuse_iqueue_init(struct fuse_iqueue *fiq, const struct fuse_iqueue_ops *ops, void *priv);
+
struct fuse_dev *fuse_get_dev(struct file *file);
unsigned int fuse_req_hash(u64 unique);
bool fuse_request_expired(struct fuse_conn *fc, struct list_head *list);
+/**
+ * Assign a unique id to a fuse request
+ */
+void fuse_request_assign_unique(struct fuse_iqueue *fiq, struct fuse_req *req);
+
+/**
+ * Get the next unique ID for a request
+ */
+u64 fuse_get_unique(struct fuse_iqueue *fiq);
+
#endif
unsigned long create_time;
};
-struct fuse_iqueue;
-
-/**
- * Input queue callbacks
- *
- * Input queue signalling is device-specific. For example, the /dev/fuse file
- * uses fiq->waitq and fasync to wake processes that are waiting on queue
- * readiness. These callbacks allow other device types to respond to input
- * queue activity.
- */
-struct fuse_iqueue_ops {
- /**
- * Send one forget
- */
- void (*send_forget)(struct fuse_iqueue *fiq, struct fuse_forget_link *link);
-
- /**
- * Send interrupt for request
- */
- void (*send_interrupt)(struct fuse_iqueue *fiq, struct fuse_req *req);
-
- /**
- * Send one request
- */
- void (*send_req)(struct fuse_iqueue *fiq, struct fuse_req *req);
-
- /**
- * Clean up when fuse_iqueue is destroyed
- */
- void (*release)(struct fuse_iqueue *fiq);
-};
-
-/** /dev/fuse input queue operations */
-extern const struct fuse_iqueue_ops fuse_dev_fiq_ops;
-
-struct fuse_iqueue {
- /** Connection established */
- unsigned connected;
-
- /** Lock protecting accesses to members of this structure */
- spinlock_t lock;
-
- /** Readers of the connection are waiting on this */
- wait_queue_head_t waitq;
-
- /** The next unique request id */
- u64 reqctr;
-
- /** The list of pending requests */
- struct list_head pending;
-
- /** Pending interrupts */
- struct list_head interrupts;
-
- /** Queue of pending forgets */
- struct fuse_forget_link forget_list_head;
- struct fuse_forget_link *forget_list_tail;
-
- /** Batching of FORGET requests (positive indicates FORGET batch) */
- int forget_batch;
-
- /** O_ASYNC requests */
- struct fasync_struct *fasync;
-
- /** Device-specific callbacks */
- const struct fuse_iqueue_ops *ops;
-
- /** Device-specific state */
- void *priv;
-};
-
#define FUSE_PQ_HASH_BITS 8
#define FUSE_PQ_HASH_SIZE (1 << FUSE_PQ_HASH_BITS)
/** Constrain ->max_pages to this value during feature negotiation */
unsigned int max_pages_limit;
- /** Input queue */
- struct fuse_iqueue iq;
-
/* transport layer object */
struct fuse_chan *chan;
int fuse_simple_background(struct fuse_mount *fm, struct fuse_args *args,
gfp_t gfp_flags);
-/**
- * Assign a unique id to a fuse request
- */
-void fuse_request_assign_unique(struct fuse_iqueue *fiq, struct fuse_req *req);
-
/**
* End a finished request
*/
* Initialize fuse_conn
*/
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,
- struct fuse_chan *fch);
+ struct user_namespace *user_ns, struct fuse_chan *fch);
/**
* Release reference to fuse_conn
*/
unsigned int fuse_len_args(unsigned int numargs, struct fuse_arg *args);
-/**
- * Get the next unique ID for a request
- */
-u64 fuse_get_unique(struct fuse_iqueue *fiq);
void fuse_free_conn(struct fuse_conn *fc);
/* dax.c */
return 0;
}
-static void fuse_iqueue_init(struct fuse_iqueue *fiq,
- const struct fuse_iqueue_ops *ops,
- void *priv)
-{
- memset(fiq, 0, sizeof(struct fuse_iqueue));
- spin_lock_init(&fiq->lock);
- init_waitqueue_head(&fiq->waitq);
- INIT_LIST_HEAD(&fiq->pending);
- INIT_LIST_HEAD(&fiq->interrupts);
- fiq->forget_list_tail = &fiq->forget_list_head;
- fiq->connected = 1;
- fiq->ops = ops;
- fiq->priv = priv;
-}
-
void fuse_pqueue_init(struct fuse_pqueue *fpq)
{
unsigned int i;
}
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, struct fuse_chan *fch)
+ struct user_namespace *user_ns, struct fuse_chan *fch)
{
memset(fc, 0, sizeof(*fc));
spin_lock_init(&fc->lock);
atomic_set(&fc->epoch, 1);
INIT_WORK(&fc->epoch_work, fuse_epoch_work);
init_waitqueue_head(&fc->blocked_waitq);
- fuse_iqueue_init(&fc->iq, fiq_ops, fiq_priv);
INIT_LIST_HEAD(&fc->bg_queue);
INIT_LIST_HEAD(&fc->entry);
INIT_LIST_HEAD(&fc->devices);
void fuse_conn_put(struct fuse_conn *fc)
{
- struct fuse_iqueue *fiq = &fc->iq;
struct fuse_sync_bucket *bucket;
if (!refcount_dec_and_test(&fc->count))
if (fc->timeout.req_timeout)
cancel_delayed_work_sync(&fc->timeout.work);
cancel_work_sync(&fc->epoch_work);
- if (fiq->ops->release)
- fiq->ops->release(fiq);
+ fuse_chan_release(fc->chan);
put_pid_ns(fc->pid_ns);
bucket = rcu_dereference_protected(fc->curr_bucket, 1);
if (bucket) {
struct fuse_conn *fc;
struct fuse_mount *fm;
struct super_block *sb;
- struct fuse_chan *fch __free(fuse_chan_free) = fuse_chan_new();
+ struct fuse_chan *fch __free(fuse_chan_free) = fuse_dev_chan_new();
int err;
if (!fch)
return -ENOMEM;
}
- fuse_conn_init(fc, fm, fsc->user_ns, &fuse_dev_fiq_ops, NULL, no_free_ptr(fch));
+ fuse_conn_init(fc, fm, fsc->user_ns, no_free_ptr(fch));
fc->release = fuse_free_conn;
fsc->s_fs_info = fm;
struct delayed_work *dwork = to_delayed_work(work);
struct fuse_conn *fc = container_of(dwork, struct fuse_conn,
timeout.work);
- struct fuse_iqueue *fiq = &fc->iq;
+ struct fuse_iqueue *fiq = &fc->chan->iq;
struct fuse_dev *fud;
struct fuse_pqueue *fpq;
bool expired = false;
{
struct fuse_mount *fm = get_fuse_mount_super(sb);
struct fuse_conn *fc = fm->fc;
- struct virtio_fs *fs = fc->iq.priv;
+ struct virtio_fs *fs = fc->chan->iq.priv;
struct fuse_fs_context *ctx = fsc->fs_private;
unsigned int i;
int err;
static void virtio_fs_conn_destroy(struct fuse_mount *fm)
{
struct fuse_conn *fc = fm->fc;
- struct virtio_fs *vfs = fc->iq.priv;
+ struct virtio_fs *vfs = fc->chan->iq.priv;
struct virtio_fs_vq *fsvq = &vfs->vqs[VQ_HIPRIO];
/* Stop dax worker. Soon evict_inodes() will be called which
struct fuse_mount *fsc_fm = fsc->s_fs_info;
struct fuse_mount *sb_fm = get_fuse_mount_super(sb);
- return fsc_fm->fc->iq.priv == sb_fm->fc->iq.priv;
+ return fsc_fm->fc->chan->iq.priv == sb_fm->fc->chan->iq.priv;
}
static int virtio_fs_get_tree(struct fs_context *fsc)
return invalf(fsc, "No source specified");
/* This gets a reference on virtio_fs object. This ptr gets installed
- * in fc->iq->priv. Once fuse_conn is going away, it calls ->put()
+ * in chan->iq->priv. Once fuse_conn is going away, it calls ->put()
* to drop the reference to this object.
*/
fs = virtio_fs_find_instance(fsc->source);
if (!fm)
goto out_err;
- fuse_conn_init(fc, fm, fsc->user_ns, &virtio_fs_fiq_ops, fs, no_free_ptr(fch));
+ fuse_iqueue_init(&fch->iq, &virtio_fs_fiq_ops, fs);
+ fuse_conn_init(fc, fm, fsc->user_ns, no_free_ptr(fch));
fc->release = fuse_free_conn;
fc->delete_stale = true;