aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs
diff options
context:
space:
mode:
Diffstat (limited to 'fs/nfs')
-rw-r--r--fs/nfs/nfs4_fs.h1
-rw-r--r--fs/nfs/nfs4proc.c34
-rw-r--r--fs/nfs/nfs4renewd.c2
-rw-r--r--fs/nfs/nfs4state.c5
-rw-r--r--fs/nfs/super.c12
5 files changed, 36 insertions, 18 deletions
diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h
index b35069a2aa9e..bd1b9d663fb9 100644
--- a/fs/nfs/nfs4_fs.h
+++ b/fs/nfs/nfs4_fs.h
@@ -115,6 +115,7 @@ struct nfs4_lock_state {
115#define NFS_LOCK_INITIALIZED 1 115#define NFS_LOCK_INITIALIZED 1
116 int ls_flags; 116 int ls_flags;
117 struct nfs_seqid_counter ls_seqid; 117 struct nfs_seqid_counter ls_seqid;
118 struct rpc_sequence ls_sequence;
118 struct nfs_unique_id ls_id; 119 struct nfs_unique_id ls_id;
119 nfs4_stateid ls_stateid; 120 nfs4_stateid ls_stateid;
120 atomic_t ls_count; 121 atomic_t ls_count;
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index f03d9d5f5ba4..9e2e1c7291db 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -741,10 +741,10 @@ static void nfs4_open_confirm_done(struct rpc_task *task, void *calldata)
741 if (data->rpc_status == 0) { 741 if (data->rpc_status == 0) {
742 memcpy(data->o_res.stateid.data, data->c_res.stateid.data, 742 memcpy(data->o_res.stateid.data, data->c_res.stateid.data,
743 sizeof(data->o_res.stateid.data)); 743 sizeof(data->o_res.stateid.data));
744 nfs_confirm_seqid(&data->owner->so_seqid, 0);
744 renew_lease(data->o_res.server, data->timestamp); 745 renew_lease(data->o_res.server, data->timestamp);
745 data->rpc_done = 1; 746 data->rpc_done = 1;
746 } 747 }
747 nfs_confirm_seqid(&data->owner->so_seqid, data->rpc_status);
748 nfs_increment_open_seqid(data->rpc_status, data->c_arg.seqid); 748 nfs_increment_open_seqid(data->rpc_status, data->c_arg.seqid);
749} 749}
750 750
@@ -759,7 +759,6 @@ static void nfs4_open_confirm_release(void *calldata)
759 /* In case of error, no cleanup! */ 759 /* In case of error, no cleanup! */
760 if (!data->rpc_done) 760 if (!data->rpc_done)
761 goto out_free; 761 goto out_free;
762 nfs_confirm_seqid(&data->owner->so_seqid, 0);
763 state = nfs4_opendata_to_nfs4_state(data); 762 state = nfs4_opendata_to_nfs4_state(data);
764 if (!IS_ERR(state)) 763 if (!IS_ERR(state))
765 nfs4_close_state(&data->path, state, data->o_arg.open_flags); 764 nfs4_close_state(&data->path, state, data->o_arg.open_flags);
@@ -886,7 +885,6 @@ static void nfs4_open_release(void *calldata)
886 /* In case we need an open_confirm, no cleanup! */ 885 /* In case we need an open_confirm, no cleanup! */
887 if (data->o_res.rflags & NFS4_OPEN_RESULT_CONFIRM) 886 if (data->o_res.rflags & NFS4_OPEN_RESULT_CONFIRM)
888 goto out_free; 887 goto out_free;
889 nfs_confirm_seqid(&data->owner->so_seqid, 0);
890 state = nfs4_opendata_to_nfs4_state(data); 888 state = nfs4_opendata_to_nfs4_state(data);
891 if (!IS_ERR(state)) 889 if (!IS_ERR(state))
892 nfs4_close_state(&data->path, state, data->o_arg.open_flags); 890 nfs4_close_state(&data->path, state, data->o_arg.open_flags);
@@ -3333,6 +3331,12 @@ static struct nfs4_lockdata *nfs4_alloc_lockdata(struct file_lock *fl,
3333 3331
3334 p->arg.fh = NFS_FH(inode); 3332 p->arg.fh = NFS_FH(inode);
3335 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 }
3336 p->arg.lock_seqid = nfs_alloc_seqid(&lsp->ls_seqid); 3340 p->arg.lock_seqid = nfs_alloc_seqid(&lsp->ls_seqid);
3337 if (p->arg.lock_seqid == NULL) 3341 if (p->arg.lock_seqid == NULL)
3338 goto out_free; 3342 goto out_free;
@@ -3345,6 +3349,8 @@ static struct nfs4_lockdata *nfs4_alloc_lockdata(struct file_lock *fl,
3345 memcpy(&p->fl, fl, sizeof(p->fl)); 3349 memcpy(&p->fl, fl, sizeof(p->fl));
3346 return p; 3350 return p;
3347out_free: 3351out_free:
3352 if (p->arg.open_seqid != NULL)
3353 nfs_free_seqid(p->arg.open_seqid);
3348 kfree(p); 3354 kfree(p);
3349 return NULL; 3355 return NULL;
3350} 3356}
@@ -3361,23 +3367,23 @@ static void nfs4_lock_prepare(struct rpc_task *task, void *calldata)
3361 .rpc_cred = sp->so_cred, 3367 .rpc_cred = sp->so_cred,
3362 }; 3368 };
3363 3369
3364 if (nfs_wait_on_sequence(data->arg.lock_seqid, task) != 0)
3365 return;
3366 dprintk("%s: begin!\n", __FUNCTION__); 3370 dprintk("%s: begin!\n", __FUNCTION__);
3367 /* Do we need to do an open_to_lock_owner? */ 3371 /* Do we need to do an open_to_lock_owner? */
3368 if (!(data->arg.lock_seqid->sequence->flags & NFS_SEQID_CONFIRMED)) { 3372 if (!(data->arg.lock_seqid->sequence->flags & NFS_SEQID_CONFIRMED)) {
3369 data->arg.open_seqid = nfs_alloc_seqid(&sp->so_seqid); 3373 if (nfs_wait_on_sequence(data->arg.open_seqid, task) != 0)
3370 if (data->arg.open_seqid == NULL) { 3374 return;
3371 data->rpc_status = -ENOMEM;
3372 task->tk_action = NULL;
3373 goto out;
3374 }
3375 data->arg.open_stateid = &state->stateid; 3375 data->arg.open_stateid = &state->stateid;
3376 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;
3377 } 3380 }
3381 if (nfs_wait_on_sequence(data->arg.lock_seqid, task) != 0)
3382 return;
3383 data->arg.new_lock_owner = 0;
3384do_rpc:
3378 data->timestamp = jiffies; 3385 data->timestamp = jiffies;
3379 rpc_call_setup(task, &msg, 0); 3386 rpc_call_setup(task, &msg, 0);
3380out:
3381 dprintk("%s: done!, ret = %d\n", __FUNCTION__, data->rpc_status); 3387 dprintk("%s: done!, ret = %d\n", __FUNCTION__, data->rpc_status);
3382} 3388}
3383 3389
@@ -3413,8 +3419,6 @@ static void nfs4_lock_release(void *calldata)
3413 struct nfs4_lockdata *data = calldata; 3419 struct nfs4_lockdata *data = calldata;
3414 3420
3415 dprintk("%s: begin!\n", __FUNCTION__); 3421 dprintk("%s: begin!\n", __FUNCTION__);
3416 if (data->arg.open_seqid != NULL)
3417 nfs_free_seqid(data->arg.open_seqid);
3418 if (data->cancelled != 0) { 3422 if (data->cancelled != 0) {
3419 struct rpc_task *task; 3423 struct rpc_task *task;
3420 task = nfs4_do_unlck(&data->fl, data->ctx, data->lsp, 3424 task = nfs4_do_unlck(&data->fl, data->ctx, data->lsp,
@@ -3424,6 +3428,8 @@ static void nfs4_lock_release(void *calldata)
3424 dprintk("%s: cancelling lock!\n", __FUNCTION__); 3428 dprintk("%s: cancelling lock!\n", __FUNCTION__);
3425 } else 3429 } else
3426 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);
3427 nfs4_put_lock_state(data->lsp); 3433 nfs4_put_lock_state(data->lsp);
3428 put_nfs_open_context(data->ctx); 3434 put_nfs_open_context(data->ctx);
3429 kfree(data); 3435 kfree(data);
diff --git a/fs/nfs/nfs4renewd.c b/fs/nfs/nfs4renewd.c
index 3ea352d82eba..5e2e4af1a0e6 100644
--- a/fs/nfs/nfs4renewd.c
+++ b/fs/nfs/nfs4renewd.c
@@ -133,9 +133,7 @@ nfs4_renewd_prepare_shutdown(struct nfs_server *server)
133void 133void
134nfs4_kill_renewd(struct nfs_client *clp) 134nfs4_kill_renewd(struct nfs_client *clp)
135{ 135{
136 down_read(&clp->cl_sem);
137 cancel_delayed_work_sync(&clp->cl_renewd); 136 cancel_delayed_work_sync(&clp->cl_renewd);
138 up_read(&clp->cl_sem);
139} 137}
140 138
141/* 139/*
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
index 23a9a36556bf..5a39c6f78acf 100644
--- a/fs/nfs/nfs4state.c
+++ b/fs/nfs/nfs4state.c
@@ -509,7 +509,10 @@ static struct nfs4_lock_state *nfs4_alloc_lock_state(struct nfs4_state *state, f
509 lsp = kzalloc(sizeof(*lsp), GFP_KERNEL); 509 lsp = kzalloc(sizeof(*lsp), GFP_KERNEL);
510 if (lsp == NULL) 510 if (lsp == NULL)
511 return NULL; 511 return NULL;
512 lsp->ls_seqid.sequence = &state->owner->so_sequence; 512 rpc_init_wait_queue(&lsp->ls_sequence.wait, "lock_seqid_waitqueue");
513 spin_lock_init(&lsp->ls_sequence.lock);
514 INIT_LIST_HEAD(&lsp->ls_sequence.list);
515 lsp->ls_seqid.sequence = &lsp->ls_sequence;
513 atomic_set(&lsp->ls_count, 1); 516 atomic_set(&lsp->ls_count, 1);
514 lsp->ls_owner = fl_owner; 517 lsp->ls_owner = fl_owner;
515 spin_lock(&clp->cl_lock); 518 spin_lock(&clp->cl_lock);
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index ea929207f274..0b0c72a072ff 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -1475,7 +1475,7 @@ static int nfs_xdev_get_sb(struct file_system_type *fs_type, int flags,
1475 error = PTR_ERR(mntroot); 1475 error = PTR_ERR(mntroot);
1476 goto error_splat_super; 1476 goto error_splat_super;
1477 } 1477 }
1478 if (mntroot->d_inode->i_op != server->nfs_client->rpc_ops->dir_inode_ops) { 1478 if (mntroot->d_inode->i_op != NFS_SB(s)->nfs_client->rpc_ops->dir_inode_ops) {
1479 dput(mntroot); 1479 dput(mntroot);
1480 error = -ESTALE; 1480 error = -ESTALE;
1481 goto error_splat_super; 1481 goto error_splat_super;
@@ -1826,6 +1826,11 @@ static int nfs4_xdev_get_sb(struct file_system_type *fs_type, int flags,
1826 error = PTR_ERR(mntroot); 1826 error = PTR_ERR(mntroot);
1827 goto error_splat_super; 1827 goto error_splat_super;
1828 } 1828 }
1829 if (mntroot->d_inode->i_op != NFS_SB(s)->nfs_client->rpc_ops->dir_inode_ops) {
1830 dput(mntroot);
1831 error = -ESTALE;
1832 goto error_splat_super;
1833 }
1829 1834
1830 s->s_flags |= MS_ACTIVE; 1835 s->s_flags |= MS_ACTIVE;
1831 mnt->mnt_sb = s; 1836 mnt->mnt_sb = s;
@@ -1900,6 +1905,11 @@ static int nfs4_referral_get_sb(struct file_system_type *fs_type, int flags,
1900 error = PTR_ERR(mntroot); 1905 error = PTR_ERR(mntroot);
1901 goto error_splat_super; 1906 goto error_splat_super;
1902 } 1907 }
1908 if (mntroot->d_inode->i_op != NFS_SB(s)->nfs_client->rpc_ops->dir_inode_ops) {
1909 dput(mntroot);
1910 error = -ESTALE;
1911 goto error_splat_super;
1912 }
1903 1913
1904 s->s_flags |= MS_ACTIVE; 1914 s->s_flags |= MS_ACTIVE;
1905 mnt->mnt_sb = s; 1915 mnt->mnt_sb = s;