aboutsummaryrefslogtreecommitdiffstats
path: root/fs
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
parent92737230dd3f1478033819d4bc20339f8da852da (diff)
lockd: Add helper for *_RES callbacks
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/lockd/clntproc.c27
-rw-r--r--fs/lockd/svc4proc.c150
-rw-r--r--fs/lockd/svcproc.c143
3 files changed, 128 insertions, 192 deletions
diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
index 3f8ad7c54efa..f96e38155b5c 100644
--- a/fs/lockd/clntproc.c
+++ b/fs/lockd/clntproc.c
@@ -354,14 +354,10 @@ in_grace_period:
354/* 354/*
355 * Generic NLM call, async version. 355 * Generic NLM call, async version.
356 */ 356 */
357int nlm_async_call(struct nlm_rqst *req, u32 proc, const struct rpc_call_ops *tk_ops) 357static int __nlm_async_call(struct nlm_rqst *req, u32 proc, struct rpc_message *msg, const struct rpc_call_ops *tk_ops)
358{ 358{
359 struct nlm_host *host = req->a_host; 359 struct nlm_host *host = req->a_host;
360 struct rpc_clnt *clnt; 360 struct rpc_clnt *clnt;
361 struct rpc_message msg = {
362 .rpc_argp = &req->a_args,
363 .rpc_resp = &req->a_res,
364 };
365 int status = -ENOLCK; 361 int status = -ENOLCK;
366 362
367 dprintk("lockd: call procedure %d on %s (async)\n", 363 dprintk("lockd: call procedure %d on %s (async)\n",
@@ -371,10 +367,10 @@ int nlm_async_call(struct nlm_rqst *req, u32 proc, const struct rpc_call_ops *tk
371 clnt = nlm_bind_host(host); 367 clnt = nlm_bind_host(host);
372 if (clnt == NULL) 368 if (clnt == NULL)
373 goto out_err; 369 goto out_err;
374 msg.rpc_proc = &clnt->cl_procinfo[proc]; 370 msg->rpc_proc = &clnt->cl_procinfo[proc];
375 371
376 /* bootstrap and kick off the async RPC call */ 372 /* bootstrap and kick off the async RPC call */
377 status = rpc_call_async(clnt, &msg, RPC_TASK_ASYNC, tk_ops, req); 373 status = rpc_call_async(clnt, msg, RPC_TASK_ASYNC, tk_ops, req);
378 if (status == 0) 374 if (status == 0)
379 return 0; 375 return 0;
380out_err: 376out_err:
@@ -382,6 +378,23 @@ out_err:
382 return status; 378 return status;
383} 379}
384 380
381int nlm_async_call(struct nlm_rqst *req, u32 proc, const struct rpc_call_ops *tk_ops)
382{
383 struct rpc_message msg = {
384 .rpc_argp = &req->a_args,
385 .rpc_resp = &req->a_res,
386 };
387 return __nlm_async_call(req, proc, &msg, tk_ops);
388}
389
390int nlm_async_reply(struct nlm_rqst *req, u32 proc, const struct rpc_call_ops *tk_ops)
391{
392 struct rpc_message msg = {
393 .rpc_argp = &req->a_res,
394 };
395 return __nlm_async_call(req, proc, &msg, tk_ops);
396}
397
385/* 398/*
386 * TEST for the presence of a conflicting lock 399 * TEST for the presence of a conflicting lock
387 */ 400 */
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
24static u32 nlm4svc_callback(struct svc_rqst *, u32, struct nlm_res *);
25
26static 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 */
235static 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
241static void nlm4svc_callback_release(void *data)
242{
243 nlm_release_call(data);
244}
245
246static 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 */
241static int 256static int nlm4svc_callback(struct svc_rqst *rqstp, u32 proc, struct nlm_args *argp,
242nlm4svc_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
256static int 283static int nlm4svc_proc_test_msg(struct svc_rqst *rqstp, struct nlm_args *argp,
257nlm4svc_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
290static 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
271static int 297static int nlm4svc_proc_cancel_msg(struct svc_rqst *rqstp, struct nlm_args *argp,
272nlm4svc_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
286static int 304static int nlm4svc_proc_unlock_msg(struct svc_rqst *rqstp, struct nlm_args *argp,
287nlm4svc_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
301static int 311static int nlm4svc_proc_granted_msg(struct svc_rqst *rqstp, struct nlm_args *argp,
302nlm4svc_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 */
477static u32
478nlm4svc_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
500static 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
506static void nlm4svc_callback_release(void *data)
507{
508 nlm_release_call(data);
509}
510
511static 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
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