Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 12272
b: refs/heads/master
c: 6bfc93e
h: refs/heads/master
v: v3
  • Loading branch information
Trond Myklebust authored and Trond Myklebust committed Nov 4, 2005
1 parent 44461eb commit a6c65d0
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 9 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 888e694c167975709f17526dbbed2d98f84e8f85
refs/heads/master: 6bfc93ef98f00b38f1913a7fdeae46ae8dbd7c52
36 changes: 28 additions & 8 deletions trunk/fs/nfs/nfs4proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2918,6 +2918,10 @@ static int nfs4_proc_unlck(struct nfs4_state *state, int cmd, struct file_lock *
struct nfs4_lock_state *lsp;
int status;

/* Is this a delegated lock? */
if (test_bit(NFS_DELEGATED_STATE, &state->flags))
return do_vfs_lock(request->fl_file, request);

status = nfs4_set_lock_state(state, request);
if (status != 0)
return status;
Expand Down Expand Up @@ -3032,6 +3036,9 @@ static int nfs4_lock_reclaim(struct nfs4_state *state, struct file_lock *request
struct nfs4_exception exception = { };
int err;

/* Cache the lock if possible... */
if (test_bit(NFS_DELEGATED_STATE, &state->flags))
return 0;
do {
err = _nfs4_do_setlk(state, F_SETLK, request, 1);
if (err != -NFS4ERR_DELAY)
Expand All @@ -3047,6 +3054,9 @@ static int nfs4_lock_expired(struct nfs4_state *state, struct file_lock *request
struct nfs4_exception exception = { };
int err;

err = nfs4_set_lock_state(state, request);
if (err != 0)
return err;
do {
err = _nfs4_do_setlk(state, F_SETLK, request, 0);
if (err != -NFS4ERR_DELAY)
Expand All @@ -3062,15 +3072,25 @@ static int _nfs4_proc_setlk(struct nfs4_state *state, int cmd, struct file_lock
int status;

down_read(&clp->cl_sem);
status = nfs4_set_lock_state(state, request);
if (status == 0)
status = _nfs4_do_setlk(state, cmd, request, 0);
if (status == 0) {
/* Note: we always want to sleep here! */
request->fl_flags |= FL_SLEEP;
if (do_vfs_lock(request->fl_file, request) < 0)
printk(KERN_WARNING "%s: VFS is out of sync with lock manager!\n", __FUNCTION__);
/* Is this a delegated open? */
if (test_bit(NFS_DELEGATED_STATE, &state->flags)) {
/* Yes: cache locks! */
status = do_vfs_lock(request->fl_file, request);
/* ...but avoid races with delegation recall... */
if (status < 0 || test_bit(NFS_DELEGATED_STATE, &state->flags))
goto out;
}
status = nfs4_set_lock_state(state, request);
if (status != 0)
goto out;
status = _nfs4_do_setlk(state, cmd, request, 0);
if (status != 0)
goto out;
/* Note: we always want to sleep here! */
request->fl_flags |= FL_SLEEP;
if (do_vfs_lock(request->fl_file, request) < 0)
printk(KERN_WARNING "%s: VFS is out of sync with lock manager!\n", __FUNCTION__);
out:
up_read(&clp->cl_sem);
return status;
}
Expand Down

0 comments on commit a6c65d0

Please sign in to comment.