diff options
author | Marc Eshel <eshel@almaden.ibm.com> | 2007-01-18 16:15:35 -0500 |
---|---|---|
committer | J. Bruce Fields <bfields@citi.umich.edu> | 2007-05-06 19:23:24 -0400 |
commit | 150b393456e5a23513cace286a019e87151e47f0 (patch) | |
tree | 91599ec9b759f7e3c5defcb8dd361acd7288154c /fs/nfsd/nfs4state.c | |
parent | 7723ec9777d9832849b76475b1a21a2872a40d20 (diff) |
locks: allow {vfs,posix}_lock_file to return conflicting lock
The nfsv4 protocol's lock operation, in the case of a conflict, returns
information about the conflicting lock.
It's unclear how clients can use this, so for now we're not going so far as to
add a filesystem method that can return a conflicting lock, but we may as well
return something in the local case when it's easy to.
Signed-off-by: Marc Eshel <eshel@almaden.ibm.com>
Signed-off-by: "J. Bruce Fields" <bfields@citi.umich.edu>
Diffstat (limited to 'fs/nfsd/nfs4state.c')
-rw-r--r-- | fs/nfsd/nfs4state.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index e42c7a0eb6fa..03b0578781cb 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c | |||
@@ -2657,6 +2657,7 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | |||
2657 | struct file_lock conflock; | 2657 | struct file_lock conflock; |
2658 | __be32 status = 0; | 2658 | __be32 status = 0; |
2659 | unsigned int strhashval; | 2659 | unsigned int strhashval; |
2660 | unsigned int cmd; | ||
2660 | int err; | 2661 | int err; |
2661 | 2662 | ||
2662 | dprintk("NFSD: nfsd4_lock: start=%Ld length=%Ld\n", | 2663 | dprintk("NFSD: nfsd4_lock: start=%Ld length=%Ld\n", |
@@ -2739,10 +2740,12 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | |||
2739 | case NFS4_READ_LT: | 2740 | case NFS4_READ_LT: |
2740 | case NFS4_READW_LT: | 2741 | case NFS4_READW_LT: |
2741 | file_lock.fl_type = F_RDLCK; | 2742 | file_lock.fl_type = F_RDLCK; |
2743 | cmd = F_SETLK; | ||
2742 | break; | 2744 | break; |
2743 | case NFS4_WRITE_LT: | 2745 | case NFS4_WRITE_LT: |
2744 | case NFS4_WRITEW_LT: | 2746 | case NFS4_WRITEW_LT: |
2745 | file_lock.fl_type = F_WRLCK; | 2747 | file_lock.fl_type = F_WRLCK; |
2748 | cmd = F_SETLK; | ||
2746 | break; | 2749 | break; |
2747 | default: | 2750 | default: |
2748 | status = nfserr_inval; | 2751 | status = nfserr_inval; |
@@ -2769,9 +2772,8 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | |||
2769 | 2772 | ||
2770 | /* XXX?: Just to divert the locks_release_private at the start of | 2773 | /* XXX?: Just to divert the locks_release_private at the start of |
2771 | * locks_copy_lock: */ | 2774 | * locks_copy_lock: */ |
2772 | conflock.fl_ops = NULL; | 2775 | locks_init_lock(&conflock); |
2773 | conflock.fl_lmops = NULL; | 2776 | err = posix_lock_file(filp, &file_lock, &conflock); |
2774 | err = posix_lock_file_conf(filp, &file_lock, &conflock); | ||
2775 | switch (-err) { | 2777 | switch (-err) { |
2776 | case 0: /* success! */ | 2778 | case 0: /* success! */ |
2777 | update_stateid(&lock_stp->st_stateid); | 2779 | update_stateid(&lock_stp->st_stateid); |
@@ -2933,7 +2935,7 @@ nfsd4_locku(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | |||
2933 | /* | 2935 | /* |
2934 | * Try to unlock the file in the VFS. | 2936 | * Try to unlock the file in the VFS. |
2935 | */ | 2937 | */ |
2936 | err = posix_lock_file(filp, &file_lock); | 2938 | err = posix_lock_file(filp, &file_lock, NULL); |
2937 | if (err) { | 2939 | if (err) { |
2938 | dprintk("NFSD: nfs4_locku: posix_lock_file failed!\n"); | 2940 | dprintk("NFSD: nfs4_locku: posix_lock_file failed!\n"); |
2939 | goto out_nfserr; | 2941 | goto out_nfserr; |