diff options
Diffstat (limited to 'fs/lockd/xdr.c')
-rw-r--r-- | fs/lockd/xdr.c | 258 |
1 files changed, 0 insertions, 258 deletions
diff --git a/fs/lockd/xdr.c b/fs/lockd/xdr.c index b583ab0a4cbb..0eb694dc497b 100644 --- a/fs/lockd/xdr.c +++ b/fs/lockd/xdr.c | |||
@@ -149,37 +149,6 @@ nlm_decode_lock(__be32 *p, struct nlm_lock *lock) | |||
149 | } | 149 | } |
150 | 150 | ||
151 | /* | 151 | /* |
152 | * Encode a lock as part of an NLM call | ||
153 | */ | ||
154 | static __be32 * | ||
155 | nlm_encode_lock(__be32 *p, struct nlm_lock *lock) | ||
156 | { | ||
157 | struct file_lock *fl = &lock->fl; | ||
158 | __s32 start, len; | ||
159 | |||
160 | if (!(p = xdr_encode_string(p, lock->caller)) | ||
161 | || !(p = nlm_encode_fh(p, &lock->fh)) | ||
162 | || !(p = nlm_encode_oh(p, &lock->oh))) | ||
163 | return NULL; | ||
164 | |||
165 | if (fl->fl_start > NLM_OFFSET_MAX | ||
166 | || (fl->fl_end > NLM_OFFSET_MAX && fl->fl_end != OFFSET_MAX)) | ||
167 | return NULL; | ||
168 | |||
169 | start = loff_t_to_s32(fl->fl_start); | ||
170 | if (fl->fl_end == OFFSET_MAX) | ||
171 | len = 0; | ||
172 | else | ||
173 | len = loff_t_to_s32(fl->fl_end - fl->fl_start + 1); | ||
174 | |||
175 | *p++ = htonl(lock->svid); | ||
176 | *p++ = htonl(start); | ||
177 | *p++ = htonl(len); | ||
178 | |||
179 | return p; | ||
180 | } | ||
181 | |||
182 | /* | ||
183 | * Encode result of a TEST/TEST_MSG call | 152 | * Encode result of a TEST/TEST_MSG call |
184 | */ | 153 | */ |
185 | static __be32 * | 154 | static __be32 * |
@@ -373,233 +342,6 @@ nlmsvc_encode_void(struct svc_rqst *rqstp, __be32 *p, void *dummy) | |||
373 | return xdr_ressize_check(rqstp, p); | 342 | return xdr_ressize_check(rqstp, p); |
374 | } | 343 | } |
375 | 344 | ||
376 | /* | ||
377 | * Now, the client side XDR functions | ||
378 | */ | ||
379 | #ifdef NLMCLNT_SUPPORT_SHARES | ||
380 | static int | ||
381 | nlmclt_decode_void(struct rpc_rqst *req, u32 *p, void *ptr) | ||
382 | { | ||
383 | return 0; | ||
384 | } | ||
385 | #endif | ||
386 | |||
387 | static int | ||
388 | nlmclt_encode_testargs(struct rpc_rqst *req, __be32 *p, nlm_args *argp) | ||
389 | { | ||
390 | struct nlm_lock *lock = &argp->lock; | ||
391 | |||
392 | if (!(p = nlm_encode_cookie(p, &argp->cookie))) | ||
393 | return -EIO; | ||
394 | *p++ = (lock->fl.fl_type == F_WRLCK)? xdr_one : xdr_zero; | ||
395 | if (!(p = nlm_encode_lock(p, lock))) | ||
396 | return -EIO; | ||
397 | req->rq_slen = xdr_adjust_iovec(req->rq_svec, p); | ||
398 | return 0; | ||
399 | } | ||
400 | |||
401 | static int | ||
402 | nlmclt_decode_testres(struct rpc_rqst *req, __be32 *p, struct nlm_res *resp) | ||
403 | { | ||
404 | if (!(p = nlm_decode_cookie(p, &resp->cookie))) | ||
405 | return -EIO; | ||
406 | resp->status = *p++; | ||
407 | if (resp->status == nlm_lck_denied) { | ||
408 | struct file_lock *fl = &resp->lock.fl; | ||
409 | u32 excl; | ||
410 | s32 start, len, end; | ||
411 | |||
412 | memset(&resp->lock, 0, sizeof(resp->lock)); | ||
413 | locks_init_lock(fl); | ||
414 | excl = ntohl(*p++); | ||
415 | resp->lock.svid = ntohl(*p++); | ||
416 | fl->fl_pid = (pid_t)resp->lock.svid; | ||
417 | if (!(p = nlm_decode_oh(p, &resp->lock.oh))) | ||
418 | return -EIO; | ||
419 | |||
420 | fl->fl_flags = FL_POSIX; | ||
421 | fl->fl_type = excl? F_WRLCK : F_RDLCK; | ||
422 | start = ntohl(*p++); | ||
423 | len = ntohl(*p++); | ||
424 | end = start + len - 1; | ||
425 | |||
426 | fl->fl_start = s32_to_loff_t(start); | ||
427 | if (len == 0 || end < 0) | ||
428 | fl->fl_end = OFFSET_MAX; | ||
429 | else | ||
430 | fl->fl_end = s32_to_loff_t(end); | ||
431 | } | ||
432 | return 0; | ||
433 | } | ||
434 | |||
435 | |||
436 | static int | ||
437 | nlmclt_encode_lockargs(struct rpc_rqst *req, __be32 *p, nlm_args *argp) | ||
438 | { | ||
439 | struct nlm_lock *lock = &argp->lock; | ||
440 | |||
441 | if (!(p = nlm_encode_cookie(p, &argp->cookie))) | ||
442 | return -EIO; | ||
443 | *p++ = argp->block? xdr_one : xdr_zero; | ||
444 | *p++ = (lock->fl.fl_type == F_WRLCK)? xdr_one : xdr_zero; | ||
445 | if (!(p = nlm_encode_lock(p, lock))) | ||
446 | return -EIO; | ||
447 | *p++ = argp->reclaim? xdr_one : xdr_zero; | ||
448 | *p++ = htonl(argp->state); | ||
449 | req->rq_slen = xdr_adjust_iovec(req->rq_svec, p); | ||
450 | return 0; | ||
451 | } | ||
452 | |||
453 | static int | ||
454 | nlmclt_encode_cancargs(struct rpc_rqst *req, __be32 *p, nlm_args *argp) | ||
455 | { | ||
456 | struct nlm_lock *lock = &argp->lock; | ||
457 | |||
458 | if (!(p = nlm_encode_cookie(p, &argp->cookie))) | ||
459 | return -EIO; | ||
460 | *p++ = argp->block? xdr_one : xdr_zero; | ||
461 | *p++ = (lock->fl.fl_type == F_WRLCK)? xdr_one : xdr_zero; | ||
462 | if (!(p = nlm_encode_lock(p, lock))) | ||
463 | return -EIO; | ||
464 | req->rq_slen = xdr_adjust_iovec(req->rq_svec, p); | ||
465 | return 0; | ||
466 | } | ||
467 | |||
468 | static int | ||
469 | nlmclt_encode_unlockargs(struct rpc_rqst *req, __be32 *p, nlm_args *argp) | ||
470 | { | ||
471 | struct nlm_lock *lock = &argp->lock; | ||
472 | |||
473 | if (!(p = nlm_encode_cookie(p, &argp->cookie))) | ||
474 | return -EIO; | ||
475 | if (!(p = nlm_encode_lock(p, lock))) | ||
476 | return -EIO; | ||
477 | req->rq_slen = xdr_adjust_iovec(req->rq_svec, p); | ||
478 | return 0; | ||
479 | } | ||
480 | |||
481 | static int | ||
482 | nlmclt_encode_res(struct rpc_rqst *req, __be32 *p, struct nlm_res *resp) | ||
483 | { | ||
484 | if (!(p = nlm_encode_cookie(p, &resp->cookie))) | ||
485 | return -EIO; | ||
486 | *p++ = resp->status; | ||
487 | req->rq_slen = xdr_adjust_iovec(req->rq_svec, p); | ||
488 | return 0; | ||
489 | } | ||
490 | |||
491 | static int | ||
492 | nlmclt_encode_testres(struct rpc_rqst *req, __be32 *p, struct nlm_res *resp) | ||
493 | { | ||
494 | if (!(p = nlm_encode_testres(p, resp))) | ||
495 | return -EIO; | ||
496 | req->rq_slen = xdr_adjust_iovec(req->rq_svec, p); | ||
497 | return 0; | ||
498 | } | ||
499 | |||
500 | static int | ||
501 | nlmclt_decode_res(struct rpc_rqst *req, __be32 *p, struct nlm_res *resp) | ||
502 | { | ||
503 | if (!(p = nlm_decode_cookie(p, &resp->cookie))) | ||
504 | return -EIO; | ||
505 | resp->status = *p++; | ||
506 | return 0; | ||
507 | } | ||
508 | |||
509 | #if (NLMCLNT_OHSIZE > XDR_MAX_NETOBJ) | ||
510 | # error "NLM host name cannot be larger than XDR_MAX_NETOBJ!" | ||
511 | #endif | ||
512 | |||
513 | /* | ||
514 | * Buffer requirements for NLM | ||
515 | */ | ||
516 | #define NLM_void_sz 0 | ||
517 | #define NLM_cookie_sz 1+XDR_QUADLEN(NLM_MAXCOOKIELEN) | ||
518 | #define NLM_caller_sz 1+XDR_QUADLEN(NLMCLNT_OHSIZE) | ||
519 | #define NLM_owner_sz 1+XDR_QUADLEN(NLMCLNT_OHSIZE) | ||
520 | #define NLM_fhandle_sz 1+XDR_QUADLEN(NFS2_FHSIZE) | ||
521 | #define NLM_lock_sz 3+NLM_caller_sz+NLM_owner_sz+NLM_fhandle_sz | ||
522 | #define NLM_holder_sz 4+NLM_owner_sz | ||
523 | |||
524 | #define NLM_testargs_sz NLM_cookie_sz+1+NLM_lock_sz | ||
525 | #define NLM_lockargs_sz NLM_cookie_sz+4+NLM_lock_sz | ||
526 | #define NLM_cancargs_sz NLM_cookie_sz+2+NLM_lock_sz | ||
527 | #define NLM_unlockargs_sz NLM_cookie_sz+NLM_lock_sz | ||
528 | |||
529 | #define NLM_testres_sz NLM_cookie_sz+1+NLM_holder_sz | ||
530 | #define NLM_res_sz NLM_cookie_sz+1 | ||
531 | #define NLM_norep_sz 0 | ||
532 | |||
533 | /* | ||
534 | * For NLM, a void procedure really returns nothing | ||
535 | */ | ||
536 | #define nlmclt_decode_norep NULL | ||
537 | |||
538 | #define PROC(proc, argtype, restype) \ | ||
539 | [NLMPROC_##proc] = { \ | ||
540 | .p_proc = NLMPROC_##proc, \ | ||
541 | .p_encode = (kxdrproc_t) nlmclt_encode_##argtype, \ | ||
542 | .p_decode = (kxdrproc_t) nlmclt_decode_##restype, \ | ||
543 | .p_arglen = NLM_##argtype##_sz, \ | ||
544 | .p_replen = NLM_##restype##_sz, \ | ||
545 | .p_statidx = NLMPROC_##proc, \ | ||
546 | .p_name = #proc, \ | ||
547 | } | ||
548 | |||
549 | static struct rpc_procinfo nlm_procedures[] = { | ||
550 | PROC(TEST, testargs, testres), | ||
551 | PROC(LOCK, lockargs, res), | ||
552 | PROC(CANCEL, cancargs, res), | ||
553 | PROC(UNLOCK, unlockargs, res), | ||
554 | PROC(GRANTED, testargs, res), | ||
555 | PROC(TEST_MSG, testargs, norep), | ||
556 | PROC(LOCK_MSG, lockargs, norep), | ||
557 | PROC(CANCEL_MSG, cancargs, norep), | ||
558 | PROC(UNLOCK_MSG, unlockargs, norep), | ||
559 | PROC(GRANTED_MSG, testargs, norep), | ||
560 | PROC(TEST_RES, testres, norep), | ||
561 | PROC(LOCK_RES, res, norep), | ||
562 | PROC(CANCEL_RES, res, norep), | ||
563 | PROC(UNLOCK_RES, res, norep), | ||
564 | PROC(GRANTED_RES, res, norep), | ||
565 | #ifdef NLMCLNT_SUPPORT_SHARES | ||
566 | PROC(SHARE, shareargs, shareres), | ||
567 | PROC(UNSHARE, shareargs, shareres), | ||
568 | PROC(NM_LOCK, lockargs, res), | ||
569 | PROC(FREE_ALL, notify, void), | ||
570 | #endif | ||
571 | }; | ||
572 | |||
573 | static struct rpc_version nlm_version1 = { | ||
574 | .number = 1, | ||
575 | .nrprocs = 16, | ||
576 | .procs = nlm_procedures, | ||
577 | }; | ||
578 | |||
579 | static struct rpc_version nlm_version3 = { | ||
580 | .number = 3, | ||
581 | .nrprocs = 24, | ||
582 | .procs = nlm_procedures, | ||
583 | }; | ||
584 | |||
585 | static struct rpc_version * nlm_versions[] = { | ||
586 | [1] = &nlm_version1, | ||
587 | [3] = &nlm_version3, | ||
588 | #ifdef CONFIG_LOCKD_V4 | ||
589 | [4] = &nlm_version4, | ||
590 | #endif | ||
591 | }; | ||
592 | |||
593 | static struct rpc_stat nlm_stats; | ||
594 | |||
595 | struct rpc_program nlm_program = { | ||
596 | .name = "lockd", | ||
597 | .number = NLM_PROGRAM, | ||
598 | .nrvers = ARRAY_SIZE(nlm_versions), | ||
599 | .version = nlm_versions, | ||
600 | .stats = &nlm_stats, | ||
601 | }; | ||
602 | |||
603 | #ifdef RPC_DEBUG | 345 | #ifdef RPC_DEBUG |
604 | const char *nlmdbg_cookie2a(const struct nlm_cookie *cookie) | 346 | const char *nlmdbg_cookie2a(const struct nlm_cookie *cookie) |
605 | { | 347 | { |