diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2006-03-20 13:44:45 -0500 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2006-03-20 13:44:45 -0500 |
commit | d47166244860eb5dfdb12ee4703968beef8a0db2 (patch) | |
tree | 423a78e1aefc84b13800e4e257bee30ac4bbcb75 /fs/lockd/svc4proc.c | |
parent | 92737230dd3f1478033819d4bc20339f8da852da (diff) |
lockd: Add helper for *_RES callbacks
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/lockd/svc4proc.c')
-rw-r--r-- | fs/lockd/svc4proc.c | 150 |
1 files changed, 55 insertions, 95 deletions
diff --git a/fs/lockd/svc4proc.c b/fs/lockd/svc4proc.c index cb51c7025825..a2dd9ccb9b32 100644 --- a/fs/lockd/svc4proc.c +++ b/fs/lockd/svc4proc.c | |||
@@ -21,10 +21,6 @@ | |||
21 | 21 | ||
22 | #define NLMDBG_FACILITY NLMDBG_CLIENT | 22 | #define NLMDBG_FACILITY NLMDBG_CLIENT |
23 | 23 | ||
24 | static u32 nlm4svc_callback(struct svc_rqst *, u32, struct nlm_res *); | ||
25 | |||
26 | static const struct rpc_call_ops nlm4svc_callback_ops; | ||
27 | |||
28 | /* | 24 | /* |
29 | * Obtain client and file from arguments | 25 | * Obtain client and file from arguments |
30 | */ | 26 | */ |
@@ -234,83 +230,89 @@ nlm4svc_proc_granted(struct svc_rqst *rqstp, struct nlm_args *argp, | |||
234 | } | 230 | } |
235 | 231 | ||
236 | /* | 232 | /* |
233 | * This is the generic lockd callback for async RPC calls | ||
234 | */ | ||
235 | static void nlm4svc_callback_exit(struct rpc_task *task, void *data) | ||
236 | { | ||
237 | dprintk("lockd: %4d callback returned %d\n", task->tk_pid, | ||
238 | -task->tk_status); | ||
239 | } | ||
240 | |||
241 | static void nlm4svc_callback_release(void *data) | ||
242 | { | ||
243 | nlm_release_call(data); | ||
244 | } | ||
245 | |||
246 | static const struct rpc_call_ops nlm4svc_callback_ops = { | ||
247 | .rpc_call_done = nlm4svc_callback_exit, | ||
248 | .rpc_release = nlm4svc_callback_release, | ||
249 | }; | ||
250 | |||
251 | /* | ||
237 | * `Async' versions of the above service routines. They aren't really, | 252 | * `Async' versions of the above service routines. They aren't really, |
238 | * because we send the callback before the reply proper. I hope this | 253 | * because we send the callback before the reply proper. I hope this |
239 | * doesn't break any clients. | 254 | * doesn't break any clients. |
240 | */ | 255 | */ |
241 | static int | 256 | static int nlm4svc_callback(struct svc_rqst *rqstp, u32 proc, struct nlm_args *argp, |
242 | nlm4svc_proc_test_msg(struct svc_rqst *rqstp, struct nlm_args *argp, | 257 | int (*func)(struct svc_rqst *, struct nlm_args *, struct nlm_res *)) |
243 | void *resp) | ||
244 | { | 258 | { |
245 | struct nlm_res res; | 259 | struct nlm_host *host; |
246 | u32 stat; | 260 | struct nlm_rqst *call; |
261 | int stat; | ||
247 | 262 | ||
248 | dprintk("lockd: TEST_MSG called\n"); | 263 | host = nlmsvc_lookup_host(rqstp); |
249 | memset(&res, 0, sizeof(res)); | 264 | if (host == NULL) |
265 | return rpc_system_err; | ||
266 | |||
267 | call = nlm_alloc_call(host); | ||
268 | if (call == NULL) | ||
269 | return rpc_system_err; | ||
270 | |||
271 | stat = func(rqstp, argp, &call->a_res); | ||
272 | if (stat != 0) { | ||
273 | nlm_release_call(call); | ||
274 | return stat; | ||
275 | } | ||
250 | 276 | ||
251 | if ((stat = nlm4svc_proc_test(rqstp, argp, &res)) == 0) | 277 | call->a_flags = RPC_TASK_ASYNC; |
252 | stat = nlm4svc_callback(rqstp, NLMPROC_TEST_RES, &res); | 278 | if (nlm_async_reply(call, proc, &nlm4svc_callback_ops) < 0) |
253 | return stat; | 279 | return rpc_system_err; |
280 | return rpc_success; | ||
254 | } | 281 | } |
255 | 282 | ||
256 | static int | 283 | static int nlm4svc_proc_test_msg(struct svc_rqst *rqstp, struct nlm_args *argp, |
257 | nlm4svc_proc_lock_msg(struct svc_rqst *rqstp, struct nlm_args *argp, | ||
258 | void *resp) | 284 | void *resp) |
259 | { | 285 | { |
260 | struct nlm_res res; | 286 | dprintk("lockd: TEST_MSG called\n"); |
261 | u32 stat; | 287 | return nlm4svc_callback(rqstp, NLMPROC_TEST_RES, argp, nlm4svc_proc_test); |
288 | } | ||
262 | 289 | ||
290 | static int nlm4svc_proc_lock_msg(struct svc_rqst *rqstp, struct nlm_args *argp, | ||
291 | void *resp) | ||
292 | { | ||
263 | dprintk("lockd: LOCK_MSG called\n"); | 293 | dprintk("lockd: LOCK_MSG called\n"); |
264 | memset(&res, 0, sizeof(res)); | 294 | return nlm4svc_callback(rqstp, NLMPROC_LOCK_RES, argp, nlm4svc_proc_lock); |
265 | |||
266 | if ((stat = nlm4svc_proc_lock(rqstp, argp, &res)) == 0) | ||
267 | stat = nlm4svc_callback(rqstp, NLMPROC_LOCK_RES, &res); | ||
268 | return stat; | ||
269 | } | 295 | } |
270 | 296 | ||
271 | static int | 297 | static int nlm4svc_proc_cancel_msg(struct svc_rqst *rqstp, struct nlm_args *argp, |
272 | nlm4svc_proc_cancel_msg(struct svc_rqst *rqstp, struct nlm_args *argp, | ||
273 | void *resp) | 298 | void *resp) |
274 | { | 299 | { |
275 | struct nlm_res res; | ||
276 | u32 stat; | ||
277 | |||
278 | dprintk("lockd: CANCEL_MSG called\n"); | 300 | dprintk("lockd: CANCEL_MSG called\n"); |
279 | memset(&res, 0, sizeof(res)); | 301 | return nlm4svc_callback(rqstp, NLMPROC_CANCEL_RES, argp, nlm4svc_proc_cancel); |
280 | |||
281 | if ((stat = nlm4svc_proc_cancel(rqstp, argp, &res)) == 0) | ||
282 | stat = nlm4svc_callback(rqstp, NLMPROC_CANCEL_RES, &res); | ||
283 | return stat; | ||
284 | } | 302 | } |
285 | 303 | ||
286 | static int | 304 | static int nlm4svc_proc_unlock_msg(struct svc_rqst *rqstp, struct nlm_args *argp, |
287 | nlm4svc_proc_unlock_msg(struct svc_rqst *rqstp, struct nlm_args *argp, | ||
288 | void *resp) | 305 | void *resp) |
289 | { | 306 | { |
290 | struct nlm_res res; | ||
291 | u32 stat; | ||
292 | |||
293 | dprintk("lockd: UNLOCK_MSG called\n"); | 307 | dprintk("lockd: UNLOCK_MSG called\n"); |
294 | memset(&res, 0, sizeof(res)); | 308 | return nlm4svc_callback(rqstp, NLMPROC_UNLOCK_RES, argp, nlm4svc_proc_unlock); |
295 | |||
296 | if ((stat = nlm4svc_proc_unlock(rqstp, argp, &res)) == 0) | ||
297 | stat = nlm4svc_callback(rqstp, NLMPROC_UNLOCK_RES, &res); | ||
298 | return stat; | ||
299 | } | 309 | } |
300 | 310 | ||
301 | static int | 311 | static int nlm4svc_proc_granted_msg(struct svc_rqst *rqstp, struct nlm_args *argp, |
302 | nlm4svc_proc_granted_msg(struct svc_rqst *rqstp, struct nlm_args *argp, | ||
303 | void *resp) | 312 | void *resp) |
304 | { | 313 | { |
305 | struct nlm_res res; | ||
306 | u32 stat; | ||
307 | |||
308 | dprintk("lockd: GRANTED_MSG called\n"); | 314 | dprintk("lockd: GRANTED_MSG called\n"); |
309 | memset(&res, 0, sizeof(res)); | 315 | return nlm4svc_callback(rqstp, NLMPROC_GRANTED_RES, argp, nlm4svc_proc_granted); |
310 | |||
311 | if ((stat = nlm4svc_proc_granted(rqstp, argp, &res)) == 0) | ||
312 | stat = nlm4svc_callback(rqstp, NLMPROC_GRANTED_RES, &res); | ||
313 | return stat; | ||
314 | } | 316 | } |
315 | 317 | ||
316 | /* | 318 | /* |
@@ -472,48 +474,6 @@ nlm4svc_proc_granted_res(struct svc_rqst *rqstp, struct nlm_res *argp, | |||
472 | 474 | ||
473 | 475 | ||
474 | /* | 476 | /* |
475 | * This is the generic lockd callback for async RPC calls | ||
476 | */ | ||
477 | static u32 | ||
478 | nlm4svc_callback(struct svc_rqst *rqstp, u32 proc, struct nlm_res *resp) | ||
479 | { | ||
480 | struct nlm_host *host; | ||
481 | struct nlm_rqst *call; | ||
482 | |||
483 | host = nlmsvc_lookup_host(rqstp); | ||
484 | if (host == NULL) | ||
485 | return rpc_system_err; | ||
486 | |||
487 | call = nlm_alloc_call(host); | ||
488 | if (call == NULL) | ||
489 | return rpc_system_err; | ||
490 | |||
491 | |||
492 | call->a_flags = RPC_TASK_ASYNC; | ||
493 | memcpy(&call->a_args, resp, sizeof(*resp)); | ||
494 | |||
495 | if (nlm_async_call(call, proc, &nlm4svc_callback_ops) < 0) | ||
496 | return rpc_system_err; | ||
497 | return rpc_success; | ||
498 | } | ||
499 | |||
500 | static void nlm4svc_callback_exit(struct rpc_task *task, void *data) | ||
501 | { | ||
502 | dprintk("lockd: %4d callback returned %d\n", task->tk_pid, | ||
503 | -task->tk_status); | ||
504 | } | ||
505 | |||
506 | static void nlm4svc_callback_release(void *data) | ||
507 | { | ||
508 | nlm_release_call(data); | ||
509 | } | ||
510 | |||
511 | static const struct rpc_call_ops nlm4svc_callback_ops = { | ||
512 | .rpc_call_done = nlm4svc_callback_exit, | ||
513 | .rpc_release = nlm4svc_callback_release, | ||
514 | }; | ||
515 | |||
516 | /* | ||
517 | * NLM Server procedures. | 477 | * NLM Server procedures. |
518 | */ | 478 | */ |
519 | 479 | ||