diff options
| -rw-r--r-- | fs/nfs/nfs4proc.c | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 571b5ec92132..9e2e1c7291db 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c | |||
| @@ -3331,6 +3331,12 @@ static struct nfs4_lockdata *nfs4_alloc_lockdata(struct file_lock *fl, | |||
| 3331 | 3331 | ||
| 3332 | p->arg.fh = NFS_FH(inode); | 3332 | p->arg.fh = NFS_FH(inode); |
| 3333 | p->arg.fl = &p->fl; | 3333 | p->arg.fl = &p->fl; |
| 3334 | if (!(lsp->ls_seqid.flags & NFS_SEQID_CONFIRMED)) { | ||
| 3335 | p->arg.open_seqid = nfs_alloc_seqid(&lsp->ls_state->owner->so_seqid); | ||
| 3336 | if (p->arg.open_seqid == NULL) | ||
| 3337 | goto out_free; | ||
| 3338 | |||
| 3339 | } | ||
| 3334 | p->arg.lock_seqid = nfs_alloc_seqid(&lsp->ls_seqid); | 3340 | p->arg.lock_seqid = nfs_alloc_seqid(&lsp->ls_seqid); |
| 3335 | if (p->arg.lock_seqid == NULL) | 3341 | if (p->arg.lock_seqid == NULL) |
| 3336 | goto out_free; | 3342 | goto out_free; |
| @@ -3343,6 +3349,8 @@ static struct nfs4_lockdata *nfs4_alloc_lockdata(struct file_lock *fl, | |||
| 3343 | memcpy(&p->fl, fl, sizeof(p->fl)); | 3349 | memcpy(&p->fl, fl, sizeof(p->fl)); |
| 3344 | return p; | 3350 | return p; |
| 3345 | out_free: | 3351 | out_free: |
| 3352 | if (p->arg.open_seqid != NULL) | ||
| 3353 | nfs_free_seqid(p->arg.open_seqid); | ||
| 3346 | kfree(p); | 3354 | kfree(p); |
| 3347 | return NULL; | 3355 | return NULL; |
| 3348 | } | 3356 | } |
| @@ -3359,23 +3367,23 @@ static void nfs4_lock_prepare(struct rpc_task *task, void *calldata) | |||
| 3359 | .rpc_cred = sp->so_cred, | 3367 | .rpc_cred = sp->so_cred, |
| 3360 | }; | 3368 | }; |
| 3361 | 3369 | ||
| 3362 | if (nfs_wait_on_sequence(data->arg.lock_seqid, task) != 0) | ||
| 3363 | return; | ||
| 3364 | dprintk("%s: begin!\n", __FUNCTION__); | 3370 | dprintk("%s: begin!\n", __FUNCTION__); |
| 3365 | /* Do we need to do an open_to_lock_owner? */ | 3371 | /* Do we need to do an open_to_lock_owner? */ |
| 3366 | if (!(data->arg.lock_seqid->sequence->flags & NFS_SEQID_CONFIRMED)) { | 3372 | if (!(data->arg.lock_seqid->sequence->flags & NFS_SEQID_CONFIRMED)) { |
| 3367 | data->arg.open_seqid = nfs_alloc_seqid(&sp->so_seqid); | 3373 | if (nfs_wait_on_sequence(data->arg.open_seqid, task) != 0) |
| 3368 | if (data->arg.open_seqid == NULL) { | 3374 | return; |
| 3369 | data->rpc_status = -ENOMEM; | ||
| 3370 | task->tk_action = NULL; | ||
| 3371 | goto out; | ||
| 3372 | } | ||
| 3373 | data->arg.open_stateid = &state->stateid; | 3375 | data->arg.open_stateid = &state->stateid; |
| 3374 | data->arg.new_lock_owner = 1; | 3376 | data->arg.new_lock_owner = 1; |
| 3377 | /* Retest in case we raced... */ | ||
| 3378 | if (!(data->arg.lock_seqid->sequence->flags & NFS_SEQID_CONFIRMED)) | ||
| 3379 | goto do_rpc; | ||
| 3375 | } | 3380 | } |
| 3381 | if (nfs_wait_on_sequence(data->arg.lock_seqid, task) != 0) | ||
| 3382 | return; | ||
| 3383 | data->arg.new_lock_owner = 0; | ||
| 3384 | do_rpc: | ||
| 3376 | data->timestamp = jiffies; | 3385 | data->timestamp = jiffies; |
| 3377 | rpc_call_setup(task, &msg, 0); | 3386 | rpc_call_setup(task, &msg, 0); |
| 3378 | out: | ||
| 3379 | dprintk("%s: done!, ret = %d\n", __FUNCTION__, data->rpc_status); | 3387 | dprintk("%s: done!, ret = %d\n", __FUNCTION__, data->rpc_status); |
| 3380 | } | 3388 | } |
| 3381 | 3389 | ||
| @@ -3411,8 +3419,6 @@ static void nfs4_lock_release(void *calldata) | |||
| 3411 | struct nfs4_lockdata *data = calldata; | 3419 | struct nfs4_lockdata *data = calldata; |
| 3412 | 3420 | ||
| 3413 | dprintk("%s: begin!\n", __FUNCTION__); | 3421 | dprintk("%s: begin!\n", __FUNCTION__); |
| 3414 | if (data->arg.open_seqid != NULL) | ||
| 3415 | nfs_free_seqid(data->arg.open_seqid); | ||
| 3416 | if (data->cancelled != 0) { | 3422 | if (data->cancelled != 0) { |
| 3417 | struct rpc_task *task; | 3423 | struct rpc_task *task; |
| 3418 | task = nfs4_do_unlck(&data->fl, data->ctx, data->lsp, | 3424 | task = nfs4_do_unlck(&data->fl, data->ctx, data->lsp, |
| @@ -3422,6 +3428,8 @@ static void nfs4_lock_release(void *calldata) | |||
| 3422 | dprintk("%s: cancelling lock!\n", __FUNCTION__); | 3428 | dprintk("%s: cancelling lock!\n", __FUNCTION__); |
| 3423 | } else | 3429 | } else |
| 3424 | nfs_free_seqid(data->arg.lock_seqid); | 3430 | nfs_free_seqid(data->arg.lock_seqid); |
| 3431 | if (data->arg.open_seqid != NULL) | ||
| 3432 | nfs_free_seqid(data->arg.open_seqid); | ||
| 3425 | nfs4_put_lock_state(data->lsp); | 3433 | nfs4_put_lock_state(data->lsp); |
| 3426 | put_nfs_open_context(data->ctx); | 3434 | put_nfs_open_context(data->ctx); |
| 3427 | kfree(data); | 3435 | kfree(data); |
