aboutsummaryrefslogtreecommitdiffstats
path: root/fs/lockd/clntproc.c
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2006-03-20 13:44:44 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2006-03-20 13:44:44 -0500
commit3a649b884637c4fdff50a6beebc3dc0e6082e048 (patch)
tree042455741f079fdbd4d33cd7da61c1c9e68db477 /fs/lockd/clntproc.c
parentd72b7a6b26b9009b7a05117fe2e04b3a73ae4a5c (diff)
NLM: Simplify client locks
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/lockd/clntproc.c')
-rw-r--r--fs/lockd/clntproc.c39
1 files changed, 16 insertions, 23 deletions
diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
index c25044f3b660..8af017105854 100644
--- a/fs/lockd/clntproc.c
+++ b/fs/lockd/clntproc.c
@@ -136,15 +136,14 @@ static void nlmclnt_setlockargs(struct nlm_rqst *req, struct file_lock *fl)
136 (unsigned int)fl->fl_u.nfs_fl.owner->pid, 136 (unsigned int)fl->fl_u.nfs_fl.owner->pid,
137 system_utsname.nodename); 137 system_utsname.nodename);
138 lock->svid = fl->fl_u.nfs_fl.owner->pid; 138 lock->svid = fl->fl_u.nfs_fl.owner->pid;
139 locks_copy_lock(&lock->fl, fl); 139 lock->fl.fl_start = fl->fl_start;
140 lock->fl.fl_end = fl->fl_end;
141 lock->fl.fl_type = fl->fl_type;
140} 142}
141 143
142static void nlmclnt_release_lockargs(struct nlm_rqst *req) 144static void nlmclnt_release_lockargs(struct nlm_rqst *req)
143{ 145{
144 struct file_lock *fl = &req->a_args.lock.fl; 146 BUG_ON(req->a_args.lock.fl.fl_ops != NULL);
145
146 if (fl->fl_ops && fl->fl_ops->fl_release_private)
147 fl->fl_ops->fl_release_private(fl);
148} 147}
149 148
150/* 149/*
@@ -455,7 +454,6 @@ static void nlmclnt_locks_release_private(struct file_lock *fl)
455{ 454{
456 list_del(&fl->fl_u.nfs_fl.list); 455 list_del(&fl->fl_u.nfs_fl.list);
457 nlm_put_lockowner(fl->fl_u.nfs_fl.owner); 456 nlm_put_lockowner(fl->fl_u.nfs_fl.owner);
458 fl->fl_ops = NULL;
459} 457}
460 458
461static struct file_lock_operations nlmclnt_lock_ops = { 459static struct file_lock_operations nlmclnt_lock_ops = {
@@ -515,41 +513,36 @@ nlmclnt_lock(struct nlm_rqst *req, struct file_lock *fl)
515{ 513{
516 struct nlm_host *host = req->a_host; 514 struct nlm_host *host = req->a_host;
517 struct nlm_res *resp = &req->a_res; 515 struct nlm_res *resp = &req->a_res;
518 long timeout; 516 struct nlm_wait *block = NULL;
519 int status; 517 int status = -ENOLCK;
520 518
521 if (!host->h_monitored && nsm_monitor(host) < 0) { 519 if (!host->h_monitored && nsm_monitor(host) < 0) {
522 printk(KERN_NOTICE "lockd: failed to monitor %s\n", 520 printk(KERN_NOTICE "lockd: failed to monitor %s\n",
523 host->h_name); 521 host->h_name);
524 status = -ENOLCK;
525 goto out; 522 goto out;
526 } 523 }
527 524
528 if (req->a_args.block) { 525 block = nlmclnt_prepare_block(host, fl);
529 status = nlmclnt_prepare_block(req, host, fl);
530 if (status < 0)
531 goto out;
532 }
533 for(;;) { 526 for(;;) {
534 status = nlmclnt_call(req, NLMPROC_LOCK); 527 status = nlmclnt_call(req, NLMPROC_LOCK);
535 if (status < 0) 528 if (status < 0)
536 goto out_unblock; 529 goto out_unblock;
537 if (resp->status != NLM_LCK_BLOCKED) 530 if (!req->a_args.block)
538 break; 531 break;
539 /* Wait on an NLM blocking lock */
540 timeout = nlmclnt_block(req, NLMCLNT_POLL_TIMEOUT);
541 /* Did a reclaimer thread notify us of a server reboot? */ 532 /* Did a reclaimer thread notify us of a server reboot? */
542 if (resp->status == NLM_LCK_DENIED_GRACE_PERIOD) 533 if (resp->status == NLM_LCK_DENIED_GRACE_PERIOD)
543 continue; 534 continue;
544 if (resp->status != NLM_LCK_BLOCKED) 535 if (resp->status != NLM_LCK_BLOCKED)
545 break; 536 break;
546 if (timeout >= 0) 537 /* Wait on an NLM blocking lock */
547 continue; 538 status = nlmclnt_block(block, req, NLMCLNT_POLL_TIMEOUT);
548 /* We were interrupted. Send a CANCEL request to the server 539 /* if we were interrupted. Send a CANCEL request to the server
549 * and exit 540 * and exit
550 */ 541 */
551 status = (int)timeout; 542 if (status < 0)
552 goto out_unblock; 543 goto out_unblock;
544 if (resp->status != NLM_LCK_BLOCKED)
545 break;
553 } 546 }
554 547
555 if (resp->status == NLM_LCK_GRANTED) { 548 if (resp->status == NLM_LCK_GRANTED) {
@@ -560,7 +553,7 @@ nlmclnt_lock(struct nlm_rqst *req, struct file_lock *fl)
560 } 553 }
561 status = nlm_stat_to_errno(resp->status); 554 status = nlm_stat_to_errno(resp->status);
562out_unblock: 555out_unblock:
563 nlmclnt_finish_block(req); 556 nlmclnt_finish_block(block);
564 /* Cancel the blocked request if it is still pending */ 557 /* Cancel the blocked request if it is still pending */
565 if (resp->status == NLM_LCK_BLOCKED) 558 if (resp->status == NLM_LCK_BLOCKED)
566 nlmclnt_cancel(host, req->a_args.block, fl); 559 nlmclnt_cancel(host, req->a_args.block, fl);