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>
This commit is contained in:
committed by
J. Bruce Fields
parent
7723ec9777
commit
150b393456
@@ -2657,6 +2657,7 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
|
||||
struct file_lock conflock;
|
||||
__be32 status = 0;
|
||||
unsigned int strhashval;
|
||||
unsigned int cmd;
|
||||
int err;
|
||||
|
||||
dprintk("NFSD: nfsd4_lock: start=%Ld length=%Ld\n",
|
||||
@@ -2739,10 +2740,12 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
|
||||
case NFS4_READ_LT:
|
||||
case NFS4_READW_LT:
|
||||
file_lock.fl_type = F_RDLCK;
|
||||
cmd = F_SETLK;
|
||||
break;
|
||||
case NFS4_WRITE_LT:
|
||||
case NFS4_WRITEW_LT:
|
||||
file_lock.fl_type = F_WRLCK;
|
||||
cmd = F_SETLK;
|
||||
break;
|
||||
default:
|
||||
status = nfserr_inval;
|
||||
@@ -2769,9 +2772,8 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
|
||||
|
||||
/* XXX?: Just to divert the locks_release_private at the start of
|
||||
* locks_copy_lock: */
|
||||
conflock.fl_ops = NULL;
|
||||
conflock.fl_lmops = NULL;
|
||||
err = posix_lock_file_conf(filp, &file_lock, &conflock);
|
||||
locks_init_lock(&conflock);
|
||||
err = posix_lock_file(filp, &file_lock, &conflock);
|
||||
switch (-err) {
|
||||
case 0: /* success! */
|
||||
update_stateid(&lock_stp->st_stateid);
|
||||
@@ -2933,7 +2935,7 @@ nfsd4_locku(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
|
||||
/*
|
||||
* Try to unlock the file in the VFS.
|
||||
*/
|
||||
err = posix_lock_file(filp, &file_lock);
|
||||
err = posix_lock_file(filp, &file_lock, NULL);
|
||||
if (err) {
|
||||
dprintk("NFSD: nfs4_locku: posix_lock_file failed!\n");
|
||||
goto out_nfserr;
|
||||
|
Reference in New Issue
Block a user