]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-5.4/fuse-store-fuse_conn-in-fuse_req.patch
drop useless batman patches
[thirdparty/kernel/stable-queue.git] / queue-5.4 / fuse-store-fuse_conn-in-fuse_req.patch
1 From 437aa1e2b0ce897e451b5a41c9a5a3db6aa9f7e8 Mon Sep 17 00:00:00 2001
2 From: Sasha Levin <sashal@kernel.org>
3 Date: Mon, 20 Apr 2020 17:54:38 +0200
4 Subject: fuse: store fuse_conn in fuse_req
5
6 From: Max Reitz <mreitz@redhat.com>
7
8 [ Upstream commit 24754db2728a87c513cc480c70c09072a7a40ba6 ]
9
10 Every fuse_req belongs to a fuse_conn. Right now, we always know which
11 fuse_conn that is based on the respective device, but we want to allow
12 multiple (sub)mounts per single connection, and then the corresponding
13 filesystem is not going to be so trivial to obtain.
14
15 Storing a pointer to the associated fuse_conn in every fuse_req will
16 allow us to trivially find any request's superblock (and thus
17 filesystem) even then.
18
19 Signed-off-by: Max Reitz <mreitz@redhat.com>
20 Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
21 Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
22 Stable-dep-of: b1fe686a765e ("fuse: don't unhash root")
23 Signed-off-by: Sasha Levin <sashal@kernel.org>
24 ---
25 fs/fuse/dev.c | 13 +++++++------
26 fs/fuse/fuse_i.h | 3 +++
27 2 files changed, 10 insertions(+), 6 deletions(-)
28
29 diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
30 index ac6a8da340139..185cae8a7ce11 100644
31 --- a/fs/fuse/dev.c
32 +++ b/fs/fuse/dev.c
33 @@ -40,20 +40,21 @@ static struct fuse_dev *fuse_get_dev(struct file *file)
34 return READ_ONCE(file->private_data);
35 }
36
37 -static void fuse_request_init(struct fuse_req *req)
38 +static void fuse_request_init(struct fuse_conn *fc, struct fuse_req *req)
39 {
40 INIT_LIST_HEAD(&req->list);
41 INIT_LIST_HEAD(&req->intr_entry);
42 init_waitqueue_head(&req->waitq);
43 refcount_set(&req->count, 1);
44 __set_bit(FR_PENDING, &req->flags);
45 + req->fc = fc;
46 }
47
48 -static struct fuse_req *fuse_request_alloc(gfp_t flags)
49 +static struct fuse_req *fuse_request_alloc(struct fuse_conn *fc, gfp_t flags)
50 {
51 struct fuse_req *req = kmem_cache_zalloc(fuse_req_cachep, flags);
52 if (req)
53 - fuse_request_init(req);
54 + fuse_request_init(fc, req);
55
56 return req;
57 }
58 @@ -125,7 +126,7 @@ static struct fuse_req *fuse_get_req(struct fuse_conn *fc, bool for_background)
59 if (fc->conn_error)
60 goto out;
61
62 - req = fuse_request_alloc(GFP_KERNEL);
63 + req = fuse_request_alloc(fc, GFP_KERNEL);
64 err = -ENOMEM;
65 if (!req) {
66 if (for_background)
67 @@ -480,7 +481,7 @@ ssize_t fuse_simple_request(struct fuse_conn *fc, struct fuse_args *args)
68
69 if (args->force) {
70 atomic_inc(&fc->num_waiting);
71 - req = fuse_request_alloc(GFP_KERNEL | __GFP_NOFAIL);
72 + req = fuse_request_alloc(fc, GFP_KERNEL | __GFP_NOFAIL);
73
74 if (!args->nocreds)
75 fuse_force_creds(fc, req);
76 @@ -547,7 +548,7 @@ int fuse_simple_background(struct fuse_conn *fc, struct fuse_args *args,
77
78 if (args->force) {
79 WARN_ON(!args->nocreds);
80 - req = fuse_request_alloc(gfp_flags);
81 + req = fuse_request_alloc(fc, gfp_flags);
82 if (!req)
83 return -ENOMEM;
84 __set_bit(FR_BACKGROUND, &req->flags);
85 diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
86 index 83c2855bc7406..7138b780c9abd 100644
87 --- a/fs/fuse/fuse_i.h
88 +++ b/fs/fuse/fuse_i.h
89 @@ -363,6 +363,9 @@ struct fuse_req {
90 /** virtio-fs's physically contiguous buffer for in and out args */
91 void *argbuf;
92 #endif
93 +
94 + /** fuse_conn this request belongs to */
95 + struct fuse_conn *fc;
96 };
97
98 struct fuse_iqueue;
99 --
100 2.43.0
101