diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2006-06-29 16:38:34 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2006-07-05 13:13:17 -0400 |
commit | 9b07357490e5c7a1c3c2b6f4679d7ee4b4185ecd (patch) | |
tree | 020b1e8ed07374d45ae2691cae8ed550ef123137 /fs/lockd | |
parent | f475ae957db66650db66916c62604ac27409d884 (diff) |
NLM,NFSv4: Don't put UNLOCK requests on the wire unless we hold a lock
Use the new behaviour of {flock,posix}_file_lock(F_UNLCK) to determine if
we held a lock, and only send the RPC request to the server if this was the
case.
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/lockd')
-rw-r--r-- | fs/lockd/clntproc.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c index 5980c45998cc..24c691f5480e 100644 --- a/fs/lockd/clntproc.c +++ b/fs/lockd/clntproc.c | |||
@@ -454,7 +454,7 @@ static void nlmclnt_locks_init_private(struct file_lock *fl, struct nlm_host *ho | |||
454 | fl->fl_ops = &nlmclnt_lock_ops; | 454 | fl->fl_ops = &nlmclnt_lock_ops; |
455 | } | 455 | } |
456 | 456 | ||
457 | static void do_vfs_lock(struct file_lock *fl) | 457 | static int do_vfs_lock(struct file_lock *fl) |
458 | { | 458 | { |
459 | int res = 0; | 459 | int res = 0; |
460 | switch (fl->fl_flags & (FL_POSIX|FL_FLOCK)) { | 460 | switch (fl->fl_flags & (FL_POSIX|FL_FLOCK)) { |
@@ -467,9 +467,7 @@ static void do_vfs_lock(struct file_lock *fl) | |||
467 | default: | 467 | default: |
468 | BUG(); | 468 | BUG(); |
469 | } | 469 | } |
470 | if (res < 0) | 470 | return res; |
471 | printk(KERN_WARNING "%s: VFS is out of sync with lock manager!\n", | ||
472 | __FUNCTION__); | ||
473 | } | 471 | } |
474 | 472 | ||
475 | /* | 473 | /* |
@@ -541,7 +539,8 @@ again: | |||
541 | } | 539 | } |
542 | fl->fl_flags |= FL_SLEEP; | 540 | fl->fl_flags |= FL_SLEEP; |
543 | /* Ensure the resulting lock will get added to granted list */ | 541 | /* Ensure the resulting lock will get added to granted list */ |
544 | do_vfs_lock(fl); | 542 | if (do_vfs_lock(fl) < 0) |
543 | printk(KERN_WARNING "%s: VFS is out of sync with lock manager!\n", __FUNCTION__); | ||
545 | up_read(&host->h_rwsem); | 544 | up_read(&host->h_rwsem); |
546 | } | 545 | } |
547 | status = nlm_stat_to_errno(resp->status); | 546 | status = nlm_stat_to_errno(resp->status); |
@@ -606,15 +605,19 @@ nlmclnt_unlock(struct nlm_rqst *req, struct file_lock *fl) | |||
606 | { | 605 | { |
607 | struct nlm_host *host = req->a_host; | 606 | struct nlm_host *host = req->a_host; |
608 | struct nlm_res *resp = &req->a_res; | 607 | struct nlm_res *resp = &req->a_res; |
609 | int status; | 608 | int status = 0; |
610 | 609 | ||
611 | /* | 610 | /* |
612 | * Note: the server is supposed to either grant us the unlock | 611 | * Note: the server is supposed to either grant us the unlock |
613 | * request, or to deny it with NLM_LCK_DENIED_GRACE_PERIOD. In either | 612 | * request, or to deny it with NLM_LCK_DENIED_GRACE_PERIOD. In either |
614 | * case, we want to unlock. | 613 | * case, we want to unlock. |
615 | */ | 614 | */ |
615 | fl->fl_flags |= FL_EXISTS; | ||
616 | down_read(&host->h_rwsem); | 616 | down_read(&host->h_rwsem); |
617 | do_vfs_lock(fl); | 617 | if (do_vfs_lock(fl) == -ENOENT) { |
618 | up_read(&host->h_rwsem); | ||
619 | goto out; | ||
620 | } | ||
618 | up_read(&host->h_rwsem); | 621 | up_read(&host->h_rwsem); |
619 | 622 | ||
620 | if (req->a_flags & RPC_TASK_ASYNC) | 623 | if (req->a_flags & RPC_TASK_ASYNC) |
@@ -624,7 +627,6 @@ nlmclnt_unlock(struct nlm_rqst *req, struct file_lock *fl) | |||
624 | if (status < 0) | 627 | if (status < 0) |
625 | goto out; | 628 | goto out; |
626 | 629 | ||
627 | status = 0; | ||
628 | if (resp->status == NLM_LCK_GRANTED) | 630 | if (resp->status == NLM_LCK_GRANTED) |
629 | goto out; | 631 | goto out; |
630 | 632 | ||