aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2012-05-25 17:51:23 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2012-05-25 18:02:09 -0400
commit848f5bda54ef19435ff78f124082bf6eff2ab620 (patch)
tree06b86b2725e1c1c309067cb7c3bd7b16058662e9 /fs
parentad24ecfbcddfa88541bccc980e753aeda8bf4031 (diff)
NFSv4.1: Ensure we use the correct credentials for session create/destroy
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/nfs/nfs4_fs.h4
-rw-r--r--fs/nfs/nfs4proc.c27
-rw-r--r--fs/nfs/nfs4state.c10
3 files changed, 26 insertions, 15 deletions
diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h
index 5fcb1ad65e5e..a5dbe62130f1 100644
--- a/fs/nfs/nfs4_fs.h
+++ b/fs/nfs/nfs4_fs.h
@@ -241,8 +241,8 @@ extern int nfs41_setup_sequence(struct nfs4_session *session,
241 struct rpc_task *task); 241 struct rpc_task *task);
242extern void nfs4_destroy_session(struct nfs4_session *session); 242extern void nfs4_destroy_session(struct nfs4_session *session);
243extern struct nfs4_session *nfs4_alloc_session(struct nfs_client *clp); 243extern struct nfs4_session *nfs4_alloc_session(struct nfs_client *clp);
244extern int nfs4_proc_create_session(struct nfs_client *); 244extern int nfs4_proc_create_session(struct nfs_client *, struct rpc_cred *);
245extern int nfs4_proc_destroy_session(struct nfs4_session *); 245extern int nfs4_proc_destroy_session(struct nfs4_session *, struct rpc_cred *);
246extern int nfs4_init_session(struct nfs_server *server); 246extern int nfs4_init_session(struct nfs_server *server);
247extern int nfs4_proc_get_lease_time(struct nfs_client *clp, 247extern int nfs4_proc_get_lease_time(struct nfs_client *clp,
248 struct nfs_fsinfo *fsinfo); 248 struct nfs_fsinfo *fsinfo);
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index f8817e81096e..8fa3a36df185 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -5480,8 +5480,12 @@ struct nfs4_session *nfs4_alloc_session(struct nfs_client *clp)
5480void nfs4_destroy_session(struct nfs4_session *session) 5480void nfs4_destroy_session(struct nfs4_session *session)
5481{ 5481{
5482 struct rpc_xprt *xprt; 5482 struct rpc_xprt *xprt;
5483 struct rpc_cred *cred;
5483 5484
5484 nfs4_proc_destroy_session(session); 5485 cred = nfs4_get_exchange_id_cred(session->clp);
5486 nfs4_proc_destroy_session(session, cred);
5487 if (cred)
5488 put_rpccred(cred);
5485 5489
5486 rcu_read_lock(); 5490 rcu_read_lock();
5487 xprt = rcu_dereference(session->clp->cl_rpcclient->cl_xprt); 5491 xprt = rcu_dereference(session->clp->cl_rpcclient->cl_xprt);
@@ -5591,7 +5595,8 @@ static int nfs4_verify_channel_attrs(struct nfs41_create_session_args *args,
5591 return nfs4_verify_back_channel_attrs(args, session); 5595 return nfs4_verify_back_channel_attrs(args, session);
5592} 5596}
5593 5597
5594static int _nfs4_proc_create_session(struct nfs_client *clp) 5598static int _nfs4_proc_create_session(struct nfs_client *clp,
5599 struct rpc_cred *cred)
5595{ 5600{
5596 struct nfs4_session *session = clp->cl_session; 5601 struct nfs4_session *session = clp->cl_session;
5597 struct nfs41_create_session_args args = { 5602 struct nfs41_create_session_args args = {
@@ -5605,6 +5610,7 @@ static int _nfs4_proc_create_session(struct nfs_client *clp)
5605 .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_CREATE_SESSION], 5610 .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_CREATE_SESSION],
5606 .rpc_argp = &args, 5611 .rpc_argp = &args,
5607 .rpc_resp = &res, 5612 .rpc_resp = &res,
5613 .rpc_cred = cred,
5608 }; 5614 };
5609 int status; 5615 int status;
5610 5616
@@ -5629,7 +5635,7 @@ static int _nfs4_proc_create_session(struct nfs_client *clp)
5629 * It is the responsibility of the caller to verify the session is 5635 * It is the responsibility of the caller to verify the session is
5630 * expired before calling this routine. 5636 * expired before calling this routine.
5631 */ 5637 */
5632int nfs4_proc_create_session(struct nfs_client *clp) 5638int nfs4_proc_create_session(struct nfs_client *clp, struct rpc_cred *cred)
5633{ 5639{
5634 int status; 5640 int status;
5635 unsigned *ptr; 5641 unsigned *ptr;
@@ -5637,7 +5643,7 @@ int nfs4_proc_create_session(struct nfs_client *clp)
5637 5643
5638 dprintk("--> %s clp=%p session=%p\n", __func__, clp, session); 5644 dprintk("--> %s clp=%p session=%p\n", __func__, clp, session);
5639 5645
5640 status = _nfs4_proc_create_session(clp); 5646 status = _nfs4_proc_create_session(clp, cred);
5641 if (status) 5647 if (status)
5642 goto out; 5648 goto out;
5643 5649
@@ -5659,10 +5665,15 @@ out:
5659 * Issue the over-the-wire RPC DESTROY_SESSION. 5665 * Issue the over-the-wire RPC DESTROY_SESSION.
5660 * The caller must serialize access to this routine. 5666 * The caller must serialize access to this routine.
5661 */ 5667 */
5662int nfs4_proc_destroy_session(struct nfs4_session *session) 5668int nfs4_proc_destroy_session(struct nfs4_session *session,
5669 struct rpc_cred *cred)
5663{ 5670{
5671 struct rpc_message msg = {
5672 .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_DESTROY_SESSION],
5673 .rpc_argp = session,
5674 .rpc_cred = cred,
5675 };
5664 int status = 0; 5676 int status = 0;
5665 struct rpc_message msg;
5666 5677
5667 dprintk("--> nfs4_proc_destroy_session\n"); 5678 dprintk("--> nfs4_proc_destroy_session\n");
5668 5679
@@ -5670,10 +5681,6 @@ int nfs4_proc_destroy_session(struct nfs4_session *session)
5670 if (session->clp->cl_cons_state != NFS_CS_READY) 5681 if (session->clp->cl_cons_state != NFS_CS_READY)
5671 return status; 5682 return status;
5672 5683
5673 msg.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_DESTROY_SESSION];
5674 msg.rpc_argp = session;
5675 msg.rpc_resp = NULL;
5676 msg.rpc_cred = NULL;
5677 status = rpc_call_sync(session->clp->cl_rpcclient, &msg, RPC_TASK_TIMEOUT); 5684 status = rpc_call_sync(session->clp->cl_rpcclient, &msg, RPC_TASK_TIMEOUT);
5678 5685
5679 if (status) 5686 if (status)
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
index 419f8c44429e..15878404aa8c 100644
--- a/fs/nfs/nfs4state.c
+++ b/fs/nfs/nfs4state.c
@@ -256,7 +256,7 @@ int nfs41_init_clientid(struct nfs_client *clp, struct rpc_cred *cred)
256 goto out; 256 goto out;
257 set_bit(NFS4CLNT_LEASE_CONFIRM, &clp->cl_state); 257 set_bit(NFS4CLNT_LEASE_CONFIRM, &clp->cl_state);
258do_confirm: 258do_confirm:
259 status = nfs4_proc_create_session(clp); 259 status = nfs4_proc_create_session(clp, cred);
260 if (status != 0) 260 if (status != 0)
261 goto out; 261 goto out;
262 clear_bit(NFS4CLNT_LEASE_CONFIRM, &clp->cl_state); 262 clear_bit(NFS4CLNT_LEASE_CONFIRM, &clp->cl_state);
@@ -1717,10 +1717,12 @@ void nfs41_handle_sequence_flag_errors(struct nfs_client *clp, u32 flags)
1717 1717
1718static int nfs4_reset_session(struct nfs_client *clp) 1718static int nfs4_reset_session(struct nfs_client *clp)
1719{ 1719{
1720 struct rpc_cred *cred;
1720 int status; 1721 int status;
1721 1722
1722 nfs4_begin_drain_session(clp); 1723 nfs4_begin_drain_session(clp);
1723 status = nfs4_proc_destroy_session(clp->cl_session); 1724 cred = nfs4_get_exchange_id_cred(clp);
1725 status = nfs4_proc_destroy_session(clp->cl_session, cred);
1724 if (status && status != -NFS4ERR_BADSESSION && 1726 if (status && status != -NFS4ERR_BADSESSION &&
1725 status != -NFS4ERR_DEADSESSION) { 1727 status != -NFS4ERR_DEADSESSION) {
1726 status = nfs4_recovery_handle_error(clp, status); 1728 status = nfs4_recovery_handle_error(clp, status);
@@ -1728,7 +1730,7 @@ static int nfs4_reset_session(struct nfs_client *clp)
1728 } 1730 }
1729 1731
1730 memset(clp->cl_session->sess_id.data, 0, NFS4_MAX_SESSIONID_LEN); 1732 memset(clp->cl_session->sess_id.data, 0, NFS4_MAX_SESSIONID_LEN);
1731 status = nfs4_proc_create_session(clp); 1733 status = nfs4_proc_create_session(clp, cred);
1732 if (status) { 1734 if (status) {
1733 status = nfs4_recovery_handle_error(clp, status); 1735 status = nfs4_recovery_handle_error(clp, status);
1734 goto out; 1736 goto out;
@@ -1742,6 +1744,8 @@ static int nfs4_reset_session(struct nfs_client *clp)
1742 if (!test_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state)) 1744 if (!test_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state))
1743 nfs41_setup_state_renewal(clp); 1745 nfs41_setup_state_renewal(clp);
1744out: 1746out:
1747 if (cred)
1748 put_rpccred(cred);
1745 return status; 1749 return status;
1746} 1750}
1747 1751