]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-5.15/nfsd-move-svc_serv_ops-svo_function-into-struct-svc_.patch
Fixes for 5.15
[thirdparty/kernel/stable-queue.git] / queue-5.15 / nfsd-move-svc_serv_ops-svo_function-into-struct-svc_.patch
1 From 026255b4acd23ff7758be0d33ba77f541a4e8ce6 Mon Sep 17 00:00:00 2001
2 From: Sasha Levin <sashal@kernel.org>
3 Date: Wed, 16 Feb 2022 12:16:27 -0500
4 Subject: NFSD: Move svc_serv_ops::svo_function into struct svc_serv
5
6 From: Chuck Lever <chuck.lever@oracle.com>
7
8 [ Upstream commit 37902c6313090235c847af89c5515591261ee338 ]
9
10 Hoist svo_function back into svc_serv and remove struct
11 svc_serv_ops, since the struct is now devoid of fields.
12
13 Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
14 ---
15 fs/lockd/svc.c | 6 +-----
16 fs/nfs/callback.c | 43 ++++++++++----------------------------
17 fs/nfsd/nfssvc.c | 7 +------
18 include/linux/sunrpc/svc.h | 14 ++++---------
19 net/sunrpc/svc.c | 37 ++++++++++++++++++++++----------
20 5 files changed, 43 insertions(+), 64 deletions(-)
21
22 diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c
23 index bfde31124f3af..59ef8a1f843f3 100644
24 --- a/fs/lockd/svc.c
25 +++ b/fs/lockd/svc.c
26 @@ -349,10 +349,6 @@ static struct notifier_block lockd_inet6addr_notifier = {
27 };
28 #endif
29
30 -static const struct svc_serv_ops lockd_sv_ops = {
31 - .svo_function = lockd,
32 -};
33 -
34 static int lockd_get(void)
35 {
36 struct svc_serv *serv;
37 @@ -376,7 +372,7 @@ static int lockd_get(void)
38 nlm_timeout = LOCKD_DFLT_TIMEO;
39 nlmsvc_timeout = nlm_timeout * HZ;
40
41 - serv = svc_create(&nlmsvc_program, LOCKD_BUFSIZE, &lockd_sv_ops);
42 + serv = svc_create(&nlmsvc_program, LOCKD_BUFSIZE, lockd);
43 if (!serv) {
44 printk(KERN_WARNING "lockd_up: create service failed\n");
45 return -ENOMEM;
46 diff --git a/fs/nfs/callback.c b/fs/nfs/callback.c
47 index a494f9e7bd0a0..456af7d230cf1 100644
48 --- a/fs/nfs/callback.c
49 +++ b/fs/nfs/callback.c
50 @@ -231,29 +231,10 @@ static int nfs_callback_up_net(int minorversion, struct svc_serv *serv,
51 return ret;
52 }
53
54 -static const struct svc_serv_ops nfs40_cb_sv_ops = {
55 - .svo_function = nfs4_callback_svc,
56 -};
57 -#if defined(CONFIG_NFS_V4_1)
58 -static const struct svc_serv_ops nfs41_cb_sv_ops = {
59 - .svo_function = nfs41_callback_svc,
60 -};
61 -
62 -static const struct svc_serv_ops *nfs4_cb_sv_ops[] = {
63 - [0] = &nfs40_cb_sv_ops,
64 - [1] = &nfs41_cb_sv_ops,
65 -};
66 -#else
67 -static const struct svc_serv_ops *nfs4_cb_sv_ops[] = {
68 - [0] = &nfs40_cb_sv_ops,
69 - [1] = NULL,
70 -};
71 -#endif
72 -
73 static struct svc_serv *nfs_callback_create_svc(int minorversion)
74 {
75 struct nfs_callback_data *cb_info = &nfs_callback_info[minorversion];
76 - const struct svc_serv_ops *sv_ops;
77 + int (*threadfn)(void *data);
78 struct svc_serv *serv;
79
80 /*
81 @@ -262,17 +243,6 @@ static struct svc_serv *nfs_callback_create_svc(int minorversion)
82 if (cb_info->serv)
83 return svc_get(cb_info->serv);
84
85 - switch (minorversion) {
86 - case 0:
87 - sv_ops = nfs4_cb_sv_ops[0];
88 - break;
89 - default:
90 - sv_ops = nfs4_cb_sv_ops[1];
91 - }
92 -
93 - if (sv_ops == NULL)
94 - return ERR_PTR(-ENOTSUPP);
95 -
96 /*
97 * Sanity check: if there's no task,
98 * we should be the first user ...
99 @@ -281,7 +251,16 @@ static struct svc_serv *nfs_callback_create_svc(int minorversion)
100 printk(KERN_WARNING "nfs_callback_create_svc: no kthread, %d users??\n",
101 cb_info->users);
102
103 - serv = svc_create(&nfs4_callback_program, NFS4_CALLBACK_BUFSIZE, sv_ops);
104 + threadfn = nfs4_callback_svc;
105 +#if defined(CONFIG_NFS_V4_1)
106 + if (minorversion)
107 + threadfn = nfs41_callback_svc;
108 +#else
109 + if (minorversion)
110 + return ERR_PTR(-ENOTSUPP);
111 +#endif
112 + serv = svc_create(&nfs4_callback_program, NFS4_CALLBACK_BUFSIZE,
113 + threadfn);
114 if (!serv) {
115 printk(KERN_ERR "nfs_callback_create_svc: create service failed\n");
116 return ERR_PTR(-ENOMEM);
117 diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c
118 index d25d4c12a499a..2f74be98ff2d9 100644
119 --- a/fs/nfsd/nfssvc.c
120 +++ b/fs/nfsd/nfssvc.c
121 @@ -612,10 +612,6 @@ static int nfsd_get_default_max_blksize(void)
122 return ret;
123 }
124
125 -static const struct svc_serv_ops nfsd_thread_sv_ops = {
126 - .svo_function = nfsd,
127 -};
128 -
129 void nfsd_shutdown_threads(struct net *net)
130 {
131 struct nfsd_net *nn = net_generic(net, nfsd_net_id);
132 @@ -654,8 +650,7 @@ int nfsd_create_serv(struct net *net)
133 if (nfsd_max_blksize == 0)
134 nfsd_max_blksize = nfsd_get_default_max_blksize();
135 nfsd_reset_versions(nn);
136 - serv = svc_create_pooled(&nfsd_program, nfsd_max_blksize,
137 - &nfsd_thread_sv_ops);
138 + serv = svc_create_pooled(&nfsd_program, nfsd_max_blksize, nfsd);
139 if (serv == NULL)
140 return -ENOMEM;
141
142 diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
143 index 61768495354a0..1d9a81bab3fa2 100644
144 --- a/include/linux/sunrpc/svc.h
145 +++ b/include/linux/sunrpc/svc.h
146 @@ -52,13 +52,6 @@ struct svc_pool {
147 unsigned long sp_flags;
148 } ____cacheline_aligned_in_smp;
149
150 -struct svc_serv;
151 -
152 -struct svc_serv_ops {
153 - /* function for service threads to run */
154 - int (*svo_function)(void *);
155 -};
156 -
157 /*
158 * RPC service.
159 *
160 @@ -91,7 +84,8 @@ struct svc_serv {
161
162 unsigned int sv_nrpools; /* number of thread pools */
163 struct svc_pool * sv_pools; /* array of thread pools */
164 - const struct svc_serv_ops *sv_ops; /* server operations */
165 + int (*sv_threadfn)(void *data);
166 +
167 #if defined(CONFIG_SUNRPC_BACKCHANNEL)
168 struct list_head sv_cb_list; /* queue for callback requests
169 * that arrive over the same
170 @@ -494,7 +488,7 @@ int svc_rpcb_setup(struct svc_serv *serv, struct net *net);
171 void svc_rpcb_cleanup(struct svc_serv *serv, struct net *net);
172 int svc_bind(struct svc_serv *serv, struct net *net);
173 struct svc_serv *svc_create(struct svc_program *, unsigned int,
174 - const struct svc_serv_ops *);
175 + int (*threadfn)(void *data));
176 struct svc_rqst *svc_rqst_alloc(struct svc_serv *serv,
177 struct svc_pool *pool, int node);
178 void svc_rqst_replace_page(struct svc_rqst *rqstp,
179 @@ -502,7 +496,7 @@ void svc_rqst_replace_page(struct svc_rqst *rqstp,
180 void svc_rqst_free(struct svc_rqst *);
181 void svc_exit_thread(struct svc_rqst *);
182 struct svc_serv * svc_create_pooled(struct svc_program *, unsigned int,
183 - const struct svc_serv_ops *);
184 + int (*threadfn)(void *data));
185 int svc_set_num_threads(struct svc_serv *, struct svc_pool *, int);
186 int svc_pool_stats_open(struct svc_serv *serv, struct file *file);
187 int svc_process(struct svc_rqst *);
188 diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
189 index 239d10018216a..87da3ff46ce9a 100644
190 --- a/net/sunrpc/svc.c
191 +++ b/net/sunrpc/svc.c
192 @@ -448,7 +448,7 @@ __svc_init_bc(struct svc_serv *serv)
193 */
194 static struct svc_serv *
195 __svc_create(struct svc_program *prog, unsigned int bufsize, int npools,
196 - const struct svc_serv_ops *ops)
197 + int (*threadfn)(void *data))
198 {
199 struct svc_serv *serv;
200 unsigned int vers;
201 @@ -465,7 +465,7 @@ __svc_create(struct svc_program *prog, unsigned int bufsize, int npools,
202 bufsize = RPCSVC_MAXPAYLOAD;
203 serv->sv_max_payload = bufsize? bufsize : 4096;
204 serv->sv_max_mesg = roundup(serv->sv_max_payload + PAGE_SIZE, PAGE_SIZE);
205 - serv->sv_ops = ops;
206 + serv->sv_threadfn = threadfn;
207 xdrsize = 0;
208 while (prog) {
209 prog->pg_lovers = prog->pg_nvers-1;
210 @@ -511,22 +511,37 @@ __svc_create(struct svc_program *prog, unsigned int bufsize, int npools,
211 return serv;
212 }
213
214 -struct svc_serv *
215 -svc_create(struct svc_program *prog, unsigned int bufsize,
216 - const struct svc_serv_ops *ops)
217 +/**
218 + * svc_create - Create an RPC service
219 + * @prog: the RPC program the new service will handle
220 + * @bufsize: maximum message size for @prog
221 + * @threadfn: a function to service RPC requests for @prog
222 + *
223 + * Returns an instantiated struct svc_serv object or NULL.
224 + */
225 +struct svc_serv *svc_create(struct svc_program *prog, unsigned int bufsize,
226 + int (*threadfn)(void *data))
227 {
228 - return __svc_create(prog, bufsize, /*npools*/1, ops);
229 + return __svc_create(prog, bufsize, 1, threadfn);
230 }
231 EXPORT_SYMBOL_GPL(svc_create);
232
233 -struct svc_serv *
234 -svc_create_pooled(struct svc_program *prog, unsigned int bufsize,
235 - const struct svc_serv_ops *ops)
236 +/**
237 + * svc_create_pooled - Create an RPC service with pooled threads
238 + * @prog: the RPC program the new service will handle
239 + * @bufsize: maximum message size for @prog
240 + * @threadfn: a function to service RPC requests for @prog
241 + *
242 + * Returns an instantiated struct svc_serv object or NULL.
243 + */
244 +struct svc_serv *svc_create_pooled(struct svc_program *prog,
245 + unsigned int bufsize,
246 + int (*threadfn)(void *data))
247 {
248 struct svc_serv *serv;
249 unsigned int npools = svc_pool_map_get();
250
251 - serv = __svc_create(prog, bufsize, npools, ops);
252 + serv = __svc_create(prog, bufsize, npools, threadfn);
253 if (!serv)
254 goto out_err;
255 return serv;
256 @@ -736,7 +751,7 @@ svc_start_kthreads(struct svc_serv *serv, struct svc_pool *pool, int nrservs)
257 if (IS_ERR(rqstp))
258 return PTR_ERR(rqstp);
259
260 - task = kthread_create_on_node(serv->sv_ops->svo_function, rqstp,
261 + task = kthread_create_on_node(serv->sv_threadfn, rqstp,
262 node, "%s", serv->sv_name);
263 if (IS_ERR(task)) {
264 svc_exit_thread(rqstp);
265 --
266 2.43.0
267