aboutsummaryrefslogtreecommitdiffstats
path: root/fs/lockd/svcproc.c
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2006-03-20 13:44:45 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2006-03-20 13:44:45 -0500
commitd47166244860eb5dfdb12ee4703968beef8a0db2 (patch)
tree423a78e1aefc84b13800e4e257bee30ac4bbcb75 /fs/lockd/svcproc.c
parent92737230dd3f1478033819d4bc20339f8da852da (diff)
lockd: Add helper for *_RES callbacks
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/lockd/svcproc.c')
-rw-r--r--fs/lockd/svcproc.c143
1 files changed, 53 insertions, 90 deletions
diff --git a/fs/lockd/svcproc.c b/fs/lockd/svcproc.c
index 956d1d71e2af..d210cf304e92 100644
--- a/fs/lockd/svcproc.c
+++ b/fs/lockd/svcproc.c
@@ -22,10 +22,6 @@
22 22
23#define NLMDBG_FACILITY NLMDBG_CLIENT 23#define NLMDBG_FACILITY NLMDBG_CLIENT
24 24
25static u32 nlmsvc_callback(struct svc_rqst *, u32, struct nlm_res *);
26
27static const struct rpc_call_ops nlmsvc_callback_ops;
28
29#ifdef CONFIG_LOCKD_V4 25#ifdef CONFIG_LOCKD_V4
30static u32 26static u32
31cast_to_nlm(u32 status, u32 vers) 27cast_to_nlm(u32 status, u32 vers)
@@ -262,83 +258,91 @@ nlmsvc_proc_granted(struct svc_rqst *rqstp, struct nlm_args *argp,
262} 258}
263 259
264/* 260/*
261 * This is the generic lockd callback for async RPC calls
262 */
263static void nlmsvc_callback_exit(struct rpc_task *task, void *data)
264{
265 dprintk("lockd: %4d callback returned %d\n", task->tk_pid,
266 -task->tk_status);
267}
268
269static void nlmsvc_callback_release(void *data)
270{
271 nlm_release_call(data);
272}
273
274static const struct rpc_call_ops nlmsvc_callback_ops = {
275 .rpc_call_done = nlmsvc_callback_exit,
276 .rpc_release = nlmsvc_callback_release,
277};
278
279/*
265 * `Async' versions of the above service routines. They aren't really, 280 * `Async' versions of the above service routines. They aren't really,
266 * because we send the callback before the reply proper. I hope this 281 * because we send the callback before the reply proper. I hope this
267 * doesn't break any clients. 282 * doesn't break any clients.
268 */ 283 */
269static int 284static int nlmsvc_callback(struct svc_rqst *rqstp, u32 proc, struct nlm_args *argp,
270nlmsvc_proc_test_msg(struct svc_rqst *rqstp, struct nlm_args *argp, 285 int (*func)(struct svc_rqst *, struct nlm_args *, struct nlm_res *))
271 void *resp)
272{ 286{
273 struct nlm_res res; 287 struct nlm_host *host;
274 u32 stat; 288 struct nlm_rqst *call;
289 int stat;
275 290
276 dprintk("lockd: TEST_MSG called\n"); 291 host = nlmsvc_lookup_host(rqstp);
277 memset(&res, 0, sizeof(res)); 292 if (host == NULL)
293 return rpc_system_err;
294
295 call = nlm_alloc_call(host);
296 if (call == NULL)
297 return rpc_system_err;
298
299 stat = func(rqstp, argp, &call->a_res);
300 if (stat != 0) {
301 nlm_release_call(call);
302 return stat;
303 }
278 304
279 if ((stat = nlmsvc_proc_test(rqstp, argp, &res)) == 0) 305 call->a_flags = RPC_TASK_ASYNC;
280 stat = nlmsvc_callback(rqstp, NLMPROC_TEST_RES, &res); 306 if (nlm_async_reply(call, proc, &nlmsvc_callback_ops) < 0)
281 return stat; 307 return rpc_system_err;
308 return rpc_success;
282} 309}
283 310
284static int 311static int nlmsvc_proc_test_msg(struct svc_rqst *rqstp, struct nlm_args *argp,
285nlmsvc_proc_lock_msg(struct svc_rqst *rqstp, struct nlm_args *argp,
286 void *resp) 312 void *resp)
287{ 313{
288 struct nlm_res res; 314 dprintk("lockd: TEST_MSG called\n");
289 u32 stat; 315 return nlmsvc_callback(rqstp, NLMPROC_TEST_RES, argp, nlmsvc_proc_test);
316}
290 317
318static int nlmsvc_proc_lock_msg(struct svc_rqst *rqstp, struct nlm_args *argp,
319 void *resp)
320{
291 dprintk("lockd: LOCK_MSG called\n"); 321 dprintk("lockd: LOCK_MSG called\n");
292 memset(&res, 0, sizeof(res)); 322 return nlmsvc_callback(rqstp, NLMPROC_LOCK_RES, argp, nlmsvc_proc_lock);
293
294 if ((stat = nlmsvc_proc_lock(rqstp, argp, &res)) == 0)
295 stat = nlmsvc_callback(rqstp, NLMPROC_LOCK_RES, &res);
296 return stat;
297} 323}
298 324
299static int 325static int nlmsvc_proc_cancel_msg(struct svc_rqst *rqstp, struct nlm_args *argp,
300nlmsvc_proc_cancel_msg(struct svc_rqst *rqstp, struct nlm_args *argp,
301 void *resp) 326 void *resp)
302{ 327{
303 struct nlm_res res;
304 u32 stat;
305
306 dprintk("lockd: CANCEL_MSG called\n"); 328 dprintk("lockd: CANCEL_MSG called\n");
307 memset(&res, 0, sizeof(res)); 329 return nlmsvc_callback(rqstp, NLMPROC_CANCEL_RES, argp, nlmsvc_proc_cancel);
308
309 if ((stat = nlmsvc_proc_cancel(rqstp, argp, &res)) == 0)
310 stat = nlmsvc_callback(rqstp, NLMPROC_CANCEL_RES, &res);
311 return stat;
312} 330}
313 331
314static int 332static int
315nlmsvc_proc_unlock_msg(struct svc_rqst *rqstp, struct nlm_args *argp, 333nlmsvc_proc_unlock_msg(struct svc_rqst *rqstp, struct nlm_args *argp,
316 void *resp) 334 void *resp)
317{ 335{
318 struct nlm_res res;
319 u32 stat;
320
321 dprintk("lockd: UNLOCK_MSG called\n"); 336 dprintk("lockd: UNLOCK_MSG called\n");
322 memset(&res, 0, sizeof(res)); 337 return nlmsvc_callback(rqstp, NLMPROC_UNLOCK_RES, argp, nlmsvc_proc_unlock);
323
324 if ((stat = nlmsvc_proc_unlock(rqstp, argp, &res)) == 0)
325 stat = nlmsvc_callback(rqstp, NLMPROC_UNLOCK_RES, &res);
326 return stat;
327} 338}
328 339
329static int 340static int
330nlmsvc_proc_granted_msg(struct svc_rqst *rqstp, struct nlm_args *argp, 341nlmsvc_proc_granted_msg(struct svc_rqst *rqstp, struct nlm_args *argp,
331 void *resp) 342 void *resp)
332{ 343{
333 struct nlm_res res;
334 u32 stat;
335
336 dprintk("lockd: GRANTED_MSG called\n"); 344 dprintk("lockd: GRANTED_MSG called\n");
337 memset(&res, 0, sizeof(res)); 345 return nlmsvc_callback(rqstp, NLMPROC_GRANTED_RES, argp, nlmsvc_proc_granted);
338
339 if ((stat = nlmsvc_proc_granted(rqstp, argp, &res)) == 0)
340 stat = nlmsvc_callback(rqstp, NLMPROC_GRANTED_RES, &res);
341 return stat;
342} 346}
343 347
344/* 348/*
@@ -497,47 +501,6 @@ nlmsvc_proc_granted_res(struct svc_rqst *rqstp, struct nlm_res *argp,
497} 501}
498 502
499/* 503/*
500 * This is the generic lockd callback for async RPC calls
501 */
502static u32
503nlmsvc_callback(struct svc_rqst *rqstp, u32 proc, struct nlm_res *resp)
504{
505 struct nlm_host *host;
506 struct nlm_rqst *call;
507
508 host = nlmsvc_lookup_host(rqstp);
509 if (host == NULL)
510 return rpc_system_err;
511
512 call = nlm_alloc_call(host);
513 if (call == NULL)
514 return rpc_system_err;
515
516 call->a_flags = RPC_TASK_ASYNC;
517 memcpy(&call->a_args, resp, sizeof(*resp));
518
519 if (nlm_async_call(call, proc, &nlmsvc_callback_ops) < 0)
520 return rpc_system_err;
521 return rpc_success;
522}
523
524static void nlmsvc_callback_exit(struct rpc_task *task, void *data)
525{
526 dprintk("lockd: %4d callback returned %d\n", task->tk_pid,
527 -task->tk_status);
528}
529
530static void nlmsvc_callback_release(void *data)
531{
532 nlm_release_call(data);
533}
534
535static const struct rpc_call_ops nlmsvc_callback_ops = {
536 .rpc_call_done = nlmsvc_callback_exit,
537 .rpc_release = nlmsvc_callback_release,
538};
539
540/*
541 * NLM Server procedures. 504 * NLM Server procedures.
542 */ 505 */
543 506