diff options
Diffstat (limited to 'fs/lockd/svc4proc.c')
| -rw-r--r-- | fs/lockd/svc4proc.c | 157 |
1 files changed, 55 insertions, 102 deletions
diff --git a/fs/lockd/svc4proc.c b/fs/lockd/svc4proc.c index b10f913aa06a..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; | ||
| 250 | 270 | ||
| 251 | if ((stat = nlm4svc_proc_test(rqstp, argp, &res)) == 0) | 271 | stat = func(rqstp, argp, &call->a_res); |
| 252 | stat = nlm4svc_callback(rqstp, NLMPROC_TEST_RES, &res); | 272 | if (stat != 0) { |
| 253 | return stat; | 273 | nlm_release_call(call); |
| 274 | return stat; | ||
| 275 | } | ||
| 276 | |||
| 277 | call->a_flags = RPC_TASK_ASYNC; | ||
| 278 | if (nlm_async_reply(call, proc, &nlm4svc_callback_ops) < 0) | ||
| 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,55 +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 | if (!(call = nlmclnt_alloc_call())) | ||
| 484 | return rpc_system_err; | ||
| 485 | |||
| 486 | host = nlmclnt_lookup_host(&rqstp->rq_addr, | ||
| 487 | rqstp->rq_prot, rqstp->rq_vers); | ||
| 488 | if (!host) { | ||
| 489 | kfree(call); | ||
| 490 | return rpc_system_err; | ||
| 491 | } | ||
| 492 | |||
| 493 | call->a_flags = RPC_TASK_ASYNC; | ||
| 494 | call->a_host = host; | ||
| 495 | memcpy(&call->a_args, resp, sizeof(*resp)); | ||
| 496 | |||
| 497 | if (nlmsvc_async_call(call, proc, &nlm4svc_callback_ops) < 0) | ||
| 498 | goto error; | ||
| 499 | |||
| 500 | return rpc_success; | ||
| 501 | error: | ||
| 502 | kfree(call); | ||
| 503 | nlm_release_host(host); | ||
| 504 | return rpc_system_err; | ||
| 505 | } | ||
| 506 | |||
| 507 | static void nlm4svc_callback_exit(struct rpc_task *task, void *data) | ||
| 508 | { | ||
| 509 | struct nlm_rqst *call = data; | ||
| 510 | |||
| 511 | if (task->tk_status < 0) { | ||
| 512 | dprintk("lockd: %4d callback failed (errno = %d)\n", | ||
| 513 | task->tk_pid, -task->tk_status); | ||
| 514 | } | ||
| 515 | nlm_release_host(call->a_host); | ||
| 516 | kfree(call); | ||
| 517 | } | ||
| 518 | |||
| 519 | static const struct rpc_call_ops nlm4svc_callback_ops = { | ||
| 520 | .rpc_call_done = nlm4svc_callback_exit, | ||
| 521 | }; | ||
| 522 | |||
| 523 | /* | ||
| 524 | * NLM Server procedures. | 477 | * NLM Server procedures. |
| 525 | */ | 478 | */ |
| 526 | 479 | ||
