Skip to content

Commit 24754db

Browse files
XanClicMiklos Szeredi
authored andcommitted
fuse: store fuse_conn in fuse_req
Every fuse_req belongs to a fuse_conn. Right now, we always know which fuse_conn that is based on the respective device, but we want to allow multiple (sub)mounts per single connection, and then the corresponding filesystem is not going to be so trivial to obtain. Storing a pointer to the associated fuse_conn in every fuse_req will allow us to trivially find any request's superblock (and thus filesystem) even then. Signed-off-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
1 parent c6ff213 commit 24754db

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

fs/fuse/dev.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,21 @@ static struct fuse_dev *fuse_get_dev(struct file *file)
4040
return READ_ONCE(file->private_data);
4141
}
4242

43-
static void fuse_request_init(struct fuse_req *req)
43+
static void fuse_request_init(struct fuse_conn *fc, struct fuse_req *req)
4444
{
4545
INIT_LIST_HEAD(&req->list);
4646
INIT_LIST_HEAD(&req->intr_entry);
4747
init_waitqueue_head(&req->waitq);
4848
refcount_set(&req->count, 1);
4949
__set_bit(FR_PENDING, &req->flags);
50+
req->fc = fc;
5051
}
5152

52-
static struct fuse_req *fuse_request_alloc(gfp_t flags)
53+
static struct fuse_req *fuse_request_alloc(struct fuse_conn *fc, gfp_t flags)
5354
{
5455
struct fuse_req *req = kmem_cache_zalloc(fuse_req_cachep, flags);
5556
if (req)
56-
fuse_request_init(req);
57+
fuse_request_init(fc, req);
5758

5859
return req;
5960
}
@@ -125,7 +126,7 @@ static struct fuse_req *fuse_get_req(struct fuse_conn *fc, bool for_background)
125126
if (fc->conn_error)
126127
goto out;
127128

128-
req = fuse_request_alloc(GFP_KERNEL);
129+
req = fuse_request_alloc(fc, GFP_KERNEL);
129130
err = -ENOMEM;
130131
if (!req) {
131132
if (for_background)
@@ -480,7 +481,7 @@ ssize_t fuse_simple_request(struct fuse_conn *fc, struct fuse_args *args)
480481

481482
if (args->force) {
482483
atomic_inc(&fc->num_waiting);
483-
req = fuse_request_alloc(GFP_KERNEL | __GFP_NOFAIL);
484+
req = fuse_request_alloc(fc, GFP_KERNEL | __GFP_NOFAIL);
484485

485486
if (!args->nocreds)
486487
fuse_force_creds(fc, req);
@@ -547,7 +548,7 @@ int fuse_simple_background(struct fuse_conn *fc, struct fuse_args *args,
547548

548549
if (args->force) {
549550
WARN_ON(!args->nocreds);
550-
req = fuse_request_alloc(gfp_flags);
551+
req = fuse_request_alloc(fc, gfp_flags);
551552
if (!req)
552553
return -ENOMEM;
553554
__set_bit(FR_BACKGROUND, &req->flags);

fs/fuse/fuse_i.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,9 @@ struct fuse_req {
374374
/** virtio-fs's physically contiguous buffer for in and out args */
375375
void *argbuf;
376376
#endif
377+
378+
/** fuse_conn this request belongs to */
379+
struct fuse_conn *fc;
377380
};
378381

379382
struct fuse_iqueue;

0 commit comments

Comments
 (0)