diff options
Diffstat (limited to 'fs/nfs/nfs4proc.c')
| -rw-r--r-- | fs/nfs/nfs4proc.c | 74 | 
1 files changed, 41 insertions, 33 deletions
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index b4916b092194..e6ee97f19d81 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; | 3289 | out: | 
| 3295 | out_unlock: | ||
| 3296 | do_vfs_lock(request->fl_file, request); | ||
| 3297 | return status; | 3290 | return status; | 
| 3298 | } | 3291 | } | 
| 3299 | 3292 | ||
| @@ -3461,10 +3454,10 @@ static int nfs4_lock_reclaim(struct nfs4_state *state, struct file_lock *request | |||
| 3461 | struct nfs4_exception exception = { }; | 3454 | struct nfs4_exception exception = { }; | 
| 3462 | int err; | 3455 | int err; | 
| 3463 | 3456 | ||
| 3464 | /* Cache the lock if possible... */ | ||
| 3465 | if (test_bit(NFS_DELEGATED_STATE, &state->flags)) | ||
| 3466 | return 0; | ||
| 3467 | do { | 3457 | do { | 
| 3458 | /* Cache the lock if possible... */ | ||
| 3459 | if (test_bit(NFS_DELEGATED_STATE, &state->flags) != 0) | ||
| 3460 | return 0; | ||
| 3468 | err = _nfs4_do_setlk(state, F_SETLK, request, 1); | 3461 | err = _nfs4_do_setlk(state, F_SETLK, request, 1); | 
| 3469 | if (err != -NFS4ERR_DELAY) | 3462 | if (err != -NFS4ERR_DELAY) | 
| 3470 | break; | 3463 | break; | 
| @@ -3483,6 +3476,8 @@ static int nfs4_lock_expired(struct nfs4_state *state, struct file_lock *request | |||
| 3483 | if (err != 0) | 3476 | if (err != 0) | 
| 3484 | return err; | 3477 | return err; | 
| 3485 | do { | 3478 | do { | 
| 3479 | if (test_bit(NFS_DELEGATED_STATE, &state->flags) != 0) | ||
| 3480 | return 0; | ||
| 3486 | err = _nfs4_do_setlk(state, F_SETLK, request, 0); | 3481 | err = _nfs4_do_setlk(state, F_SETLK, request, 0); | 
| 3487 | if (err != -NFS4ERR_DELAY) | 3482 | if (err != -NFS4ERR_DELAY) | 
| 3488 | break; | 3483 | break; | 
| @@ -3494,29 +3489,42 @@ static int nfs4_lock_expired(struct nfs4_state *state, struct file_lock *request | |||
| 3494 | static int _nfs4_proc_setlk(struct nfs4_state *state, int cmd, struct file_lock *request) | 3489 | static int _nfs4_proc_setlk(struct nfs4_state *state, int cmd, struct file_lock *request) | 
| 3495 | { | 3490 | { | 
| 3496 | struct nfs4_client *clp = state->owner->so_client; | 3491 | struct nfs4_client *clp = state->owner->so_client; | 
| 3492 | unsigned char fl_flags = request->fl_flags; | ||
| 3497 | int status; | 3493 | int status; | 
| 3498 | 3494 | ||
| 3499 | /* Is this a delegated open? */ | 3495 | /* Is this a delegated open? */ | 
| 3500 | if (NFS_I(state->inode)->delegation_state != 0) { | ||
| 3501 | /* Yes: cache locks! */ | ||
| 3502 | status = do_vfs_lock(request->fl_file, request); | ||
| 3503 | /* ...but avoid races with delegation recall... */ | ||
| 3504 | if (status < 0 || test_bit(NFS_DELEGATED_STATE, &state->flags)) | ||
| 3505 | return status; | ||
| 3506 | } | ||
| 3507 | down_read(&clp->cl_sem); | ||
| 3508 | status = nfs4_set_lock_state(state, request); | 3496 | status = nfs4_set_lock_state(state, request); | 
| 3509 | if (status != 0) | 3497 | if (status != 0) | 
| 3510 | goto out; | 3498 | goto out; | 
| 3499 | request->fl_flags |= FL_ACCESS; | ||
| 3500 | status = do_vfs_lock(request->fl_file, request); | ||
| 3501 | if (status < 0) | ||
| 3502 | goto out; | ||
| 3503 | down_read(&clp->cl_sem); | ||
| 3504 | if (test_bit(NFS_DELEGATED_STATE, &state->flags)) { | ||
| 3505 | struct nfs_inode *nfsi = NFS_I(state->inode); | ||
| 3506 | /* Yes: cache locks! */ | ||
| 3507 | down_read(&nfsi->rwsem); | ||
| 3508 | /* ...but avoid races with delegation recall... */ | ||
| 3509 | if (test_bit(NFS_DELEGATED_STATE, &state->flags)) { | ||
| 3510 | request->fl_flags = fl_flags & ~FL_SLEEP; | ||
| 3511 | status = do_vfs_lock(request->fl_file, request); | ||
| 3512 | up_read(&nfsi->rwsem); | ||
| 3513 | goto out_unlock; | ||
| 3514 | } | ||
| 3515 | up_read(&nfsi->rwsem); | ||
| 3516 | } | ||
| 3511 | status = _nfs4_do_setlk(state, cmd, request, 0); | 3517 | status = _nfs4_do_setlk(state, cmd, request, 0); | 
| 3512 | if (status != 0) | 3518 | if (status != 0) | 
| 3513 | goto out; | 3519 | goto out_unlock; | 
| 3514 | /* Note: we always want to sleep here! */ | 3520 | /* Note: we always want to sleep here! */ | 
| 3515 | request->fl_flags |= FL_SLEEP; | 3521 | request->fl_flags = fl_flags | FL_SLEEP; | 
| 3516 | if (do_vfs_lock(request->fl_file, request) < 0) | 3522 | if (do_vfs_lock(request->fl_file, request) < 0) | 
| 3517 | printk(KERN_WARNING "%s: VFS is out of sync with lock manager!\n", __FUNCTION__); | 3523 | printk(KERN_WARNING "%s: VFS is out of sync with lock manager!\n", __FUNCTION__); | 
| 3518 | out: | 3524 | out_unlock: | 
| 3519 | up_read(&clp->cl_sem); | 3525 | up_read(&clp->cl_sem); | 
| 3526 | out: | ||
| 3527 | request->fl_flags = fl_flags; | ||
| 3520 | return status; | 3528 | return status; | 
| 3521 | } | 3529 | } | 
| 3522 | 3530 | ||
