aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/nfs4proc.c
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2006-06-29 16:38:34 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2006-07-05 13:13:17 -0400
commit9b07357490e5c7a1c3c2b6f4679d7ee4b4185ecd (patch)
tree020b1e8ed07374d45ae2691cae8ed550ef123137 /fs/nfs/nfs4proc.c
parentf475ae957db66650db66916c62604ac27409d884 (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/nfs/nfs4proc.c')
-rw-r--r--fs/nfs/nfs4proc.c31
1 files changed, 12 insertions, 19 deletions
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index b4916b092194..b8c63757f039 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -3144,9 +3144,6 @@ static int do_vfs_lock(struct file *file, struct file_lock *fl)
3144 default: 3144 default:
3145 BUG(); 3145 BUG();
3146 } 3146 }
3147 if (res < 0)
3148 printk(KERN_WARNING "%s: VFS is out of sync with lock manager!\n",
3149 __FUNCTION__);
3150 return res; 3147 return res;
3151} 3148}
3152 3149
@@ -3258,8 +3255,6 @@ static struct rpc_task *nfs4_do_unlck(struct file_lock *fl,
3258 return ERR_PTR(-ENOMEM); 3255 return ERR_PTR(-ENOMEM);
3259 } 3256 }
3260 3257
3261 /* Unlock _before_ we do the RPC call */
3262 do_vfs_lock(fl->fl_file, fl);
3263 return rpc_run_task(NFS_CLIENT(lsp->ls_state->inode), RPC_TASK_ASYNC, &nfs4_locku_ops, data); 3258 return rpc_run_task(NFS_CLIENT(lsp->ls_state->inode), RPC_TASK_ASYNC, &nfs4_locku_ops, data);
3264} 3259}
3265 3260
@@ -3270,30 +3265,28 @@ static int nfs4_proc_unlck(struct nfs4_state *state, int cmd, struct file_lock *
3270 struct rpc_task *task; 3265 struct rpc_task *task;
3271 int status = 0; 3266 int status = 0;
3272 3267
3273 /* Is this a delegated lock? */
3274 if (test_bit(NFS_DELEGATED_STATE, &state->flags))
3275 goto out_unlock;
3276 /* Is this open_owner holding any locks on the server? */
3277 if (test_bit(LK_STATE_IN_USE, &state->flags) == 0)
3278 goto out_unlock;
3279
3280 status = nfs4_set_lock_state(state, request); 3268 status = nfs4_set_lock_state(state, request);
3269 /* Unlock _before_ we do the RPC call */
3270 request->fl_flags |= FL_EXISTS;
3271 if (do_vfs_lock(request->fl_file, request) == -ENOENT)
3272 goto out;
3281 if (status != 0) 3273 if (status != 0)
3282 goto out_unlock; 3274 goto out;
3275 /* Is this a delegated lock? */
3276 if (test_bit(NFS_DELEGATED_STATE, &state->flags))
3277 goto out;
3283 lsp = request->fl_u.nfs4_fl.owner; 3278 lsp = request->fl_u.nfs4_fl.owner;
3284 status = -ENOMEM;
3285 seqid = nfs_alloc_seqid(&lsp->ls_seqid); 3279 seqid = nfs_alloc_seqid(&lsp->ls_seqid);
3280 status = -ENOMEM;
3286 if (seqid == NULL) 3281 if (seqid == NULL)
3287 goto out_unlock; 3282 goto out;
3288 task = nfs4_do_unlck(request, request->fl_file->private_data, lsp, seqid); 3283 task = nfs4_do_unlck(request, request->fl_file->private_data, lsp, seqid);
3289 status = PTR_ERR(task); 3284 status = PTR_ERR(task);
3290 if (IS_ERR(task)) 3285 if (IS_ERR(task))
3291 goto out_unlock; 3286 goto out;
3292 status = nfs4_wait_for_completion_rpc_task(task); 3287 status = nfs4_wait_for_completion_rpc_task(task);
3293 rpc_release_task(task); 3288 rpc_release_task(task);
3294 return status; 3289out:
3295out_unlock:
3296 do_vfs_lock(request->fl_file, request);
3297 return status; 3290 return status;
3298} 3291}
3299 3292