History

nfs4.1: add BIND_CONN_TO_SESSION operation

This patch adds the BIND_CONN_TO_SESSION operation which is needed for upcoming SP4_MACH_CRED work and useful for recovering from broken connections without destroying the session.

Weston Andros Adamson committed 14 years ago

Commit 7c44f1a1 parent d23d61c5 files · +161 −0Browse files

Unified · Split

5 files
  1. fs/nfs/nfs4_fs.h +1 −0
  2. fs/nfs/nfs4proc.c +54 −0
  3. fs/nfs/nfs4xdr.c +95 −0
  4. include/linux/nfs4.h +5 −0
  5. include/linux/nfs_xdr.h +6 −0
fs/nfs/nfs4_fs.h+1−0
@@ -211,6 +211,7 @@ struct vfsmount *nfs4_submount(struct nfs_server *, struct dentry *, · 210 unmodified lines
211extern int nfs4_proc_setclientid(struct nfs_client *, u32, unsigned short, struct rpc_cred *, struct nfs4_setclientid_res *);211extern int nfs4_proc_setclientid(struct nfs_client *, u32, unsigned short, struct rpc_cred *, struct nfs4_setclientid_res *);
212extern int nfs4_proc_setclientid_confirm(struct nfs_client *, struct nfs4_setclientid_res *arg, struct rpc_cred *);212extern int nfs4_proc_setclientid_confirm(struct nfs_client *, struct nfs4_setclientid_res *arg, struct rpc_cred *);
213extern int nfs4_proc_get_rootfh(struct nfs_server *, struct nfs_fh *, struct nfs_fsinfo *);213extern int nfs4_proc_get_rootfh(struct nfs_server *, struct nfs_fh *, struct nfs_fsinfo *);
214extern int nfs4_proc_bind_conn_to_session(struct nfs_client *);
214extern int nfs4_proc_exchange_id(struct nfs_client *clp, struct rpc_cred *cred);215extern int nfs4_proc_exchange_id(struct nfs_client *clp, struct rpc_cred *cred);
215extern int nfs4_init_clientid(struct nfs_client *, struct rpc_cred *);216extern int nfs4_init_clientid(struct nfs_client *, struct rpc_cred *);
216extern int nfs41_init_clientid(struct nfs_client *, struct rpc_cred *);217extern int nfs41_init_clientid(struct nfs_client *, struct rpc_cred *);
fs/nfs/nfs4proc.c+54−0
@@ -5099,6 +5099,60 @@ nfs41_same_server_scope(struct nfs41_server_scope *a, · 5098 unmodified lines
5099 return false;5099 return false;
5100}5100}
5101 5101
5102/*
5103 * nfs4_proc_bind_conn_to_session()
5104 *
5105 * The 4.1 client currently uses the same TCP connection for the
5106 * fore and backchannel.
5107 */
5108int nfs4_proc_bind_conn_to_session(struct nfs_client *clp)
5109{
5110 int status;
5111 struct nfs41_bind_conn_to_session_res res;
5112 struct rpc_message msg = {
5113 .rpc_proc =
5114 &nfs4_procedures[NFSPROC4_CLNT_BIND_CONN_TO_SESSION],
5115 .rpc_argp = clp,
5116 .rpc_resp = &res,
5117 };
5118
5119 dprintk("--> %s\n", __func__);
5120 BUG_ON(clp == NULL);
5121
5122 res.session = kzalloc(sizeof(struct nfs4_session), GFP_NOFS);
5123 if (unlikely(res.session == NULL)) {
5124 status = -ENOMEM;
5125 goto out;
5126 }
5127
5128 status = rpc_call_sync(clp->cl_rpcclient, &msg, RPC_TASK_TIMEOUT);
5129 if (status == 0) {
5130 if (memcmp(res.session->sess_id.data,
5131 clp->cl_session->sess_id.data, NFS4_MAX_SESSIONID_LEN)) {
5132 dprintk("NFS: %s: Session ID mismatch\n", __func__);
5133 status = -EIO;
5134 goto out_session;
5135 }
5136 if (res.dir != NFS4_CDFS4_BOTH) {
5137 dprintk("NFS: %s: Unexpected direction from server\n",
5138 __func__);
5139 status = -EIO;
5140 goto out_session;
5141 }
5142 if (res.use_conn_in_rdma_mode) {
5143 dprintk("NFS: %s: Server returned RDMA mode = true\n",
5144 __func__);
5145 status = -EIO;
5146 goto out_session;
5147 }
5148 }
5149out_session:
5150 kfree(res.session);
5151out:
5152 dprintk("<-- %s status= %d\n", __func__, status);
5153 return status;
5154}
5155
5102/*5156/*
5103 * nfs4_proc_exchange_id()5157 * nfs4_proc_exchange_id()
5104 *5158 *
fs/nfs/nfs4xdr.c+95−0
@@ -326,6 +326,16 @@ static int nfs4_stat_to_errno(int); · 325 unmodified lines
326 1 /* csr_flags */ + \326 1 /* csr_flags */ + \
327 decode_channel_attrs_maxsz + \327 decode_channel_attrs_maxsz + \
328 decode_channel_attrs_maxsz)328 decode_channel_attrs_maxsz)
329#define encode_bind_conn_to_session_maxsz (op_encode_hdr_maxsz + \
330 /* bctsa_sessid */ \
331 XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + \
332 1 /* bctsa_dir */ + \
333 1 /* bctsa_use_conn_in_rdma_mode */)
334#define decode_bind_conn_to_session_maxsz (op_decode_hdr_maxsz + \
335 /* bctsr_sessid */ \
336 XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + \
337 1 /* bctsr_dir */ + \
338 1 /* bctsr_use_conn_in_rdma_mode */)
329#define encode_destroy_session_maxsz (op_encode_hdr_maxsz + 4)339#define encode_destroy_session_maxsz (op_encode_hdr_maxsz + 4)
330#define decode_destroy_session_maxsz (op_decode_hdr_maxsz)340#define decode_destroy_session_maxsz (op_decode_hdr_maxsz)
331#define encode_sequence_maxsz (op_encode_hdr_maxsz + \341#define encode_sequence_maxsz (op_encode_hdr_maxsz + \
@@ -719,6 +729,12 @@ static int nfs4_stat_to_errno(int); · 387 unmodified lines
719 decode_putfh_maxsz + \729 decode_putfh_maxsz + \
720 decode_secinfo_maxsz)730 decode_secinfo_maxsz)
721#if defined(CONFIG_NFS_V4_1)731#if defined(CONFIG_NFS_V4_1)
732#define NFS4_enc_bind_conn_to_session_sz \
733 (compound_encode_hdr_maxsz + \
734 encode_bind_conn_to_session_maxsz)
735#define NFS4_dec_bind_conn_to_session_sz \
736 (compound_decode_hdr_maxsz + \
737 decode_bind_conn_to_session_maxsz)
722#define NFS4_enc_exchange_id_sz \738#define NFS4_enc_exchange_id_sz \
723 (compound_encode_hdr_maxsz + \739 (compound_encode_hdr_maxsz + \
724 encode_exchange_id_maxsz)740 encode_exchange_id_maxsz)
@@ -1669,6 +1685,20 @@ static void encode_secinfo(struct xdr_stream *xdr, const struct qstr *name, stru · 944 unmodified lines
1669 1685
1670#if defined(CONFIG_NFS_V4_1)1686#if defined(CONFIG_NFS_V4_1)
1671/* NFSv4.1 operations */1687/* NFSv4.1 operations */
1688static void encode_bind_conn_to_session(struct xdr_stream *xdr,
1689 struct nfs4_session *session,
1690 struct compound_hdr *hdr)
1691{
1692 __be32 *p;
1693
1694 encode_op_hdr(xdr, OP_BIND_CONN_TO_SESSION,
1695 decode_bind_conn_to_session_maxsz, hdr);
1696 encode_opaque_fixed(xdr, session->sess_id.data, NFS4_MAX_SESSIONID_LEN);
1697 p = xdr_reserve_space(xdr, 8);
1698 *p++ = cpu_to_be32(NFS4_CDFC4_BACK_OR_BOTH);
1699 *p = 0; /* use_conn_in_rdma_mode = False */
1700}
1701
1672static void encode_exchange_id(struct xdr_stream *xdr,1702static void encode_exchange_id(struct xdr_stream *xdr,
1673 struct nfs41_exchange_id_args *args,1703 struct nfs41_exchange_id_args *args,
1674 struct compound_hdr *hdr)1704 struct compound_hdr *hdr)
@@ -2629,6 +2659,22 @@ static void nfs4_xdr_enc_secinfo(struct rpc_rqst *req, · 954 unmodified lines
2629}2659}
2630 2660
2631#if defined(CONFIG_NFS_V4_1)2661#if defined(CONFIG_NFS_V4_1)
2662/*
2663 * BIND_CONN_TO_SESSION request
2664 */
2665static void nfs4_xdr_enc_bind_conn_to_session(struct rpc_rqst *req,
2666 struct xdr_stream *xdr,
2667 struct nfs_client *clp)
2668{
2669 struct compound_hdr hdr = {
2670 .minorversion = clp->cl_mvops->minor_version,
2671 };
2672
2673 encode_compound_hdr(xdr, req, &hdr);
2674 encode_bind_conn_to_session(xdr, clp->cl_session, &hdr);
2675 encode_nops(&hdr);
2676}
2677
2632/*2678/*
2633 * EXCHANGE_ID request2679 * EXCHANGE_ID request
2634 */2680 */
@@ -5366,6 +5412,37 @@ static int decode_sessionid(struct xdr_stream *xdr, struct nfs4_sessionid *sid) · 2731 unmodified lines
5366 return decode_opaque_fixed(xdr, sid->data, NFS4_MAX_SESSIONID_LEN);5412 return decode_opaque_fixed(xdr, sid->data, NFS4_MAX_SESSIONID_LEN);
5367}5413}
5368 5414
5415static int decode_bind_conn_to_session(struct xdr_stream *xdr,
5416 struct nfs41_bind_conn_to_session_res *res)
5417{
5418 __be32 *p;
5419 int status;
5420
5421 status = decode_op_hdr(xdr, OP_BIND_CONN_TO_SESSION);
5422 if (!status)
5423 status = decode_sessionid(xdr, &res->session->sess_id);
5424 if (unlikely(status))
5425 return status;
5426
5427 /* dir flags, rdma mode bool */
5428 p = xdr_inline_decode(xdr, 8);
5429 if (unlikely(!p))
5430 goto out_overflow;
5431
5432 res->dir = be32_to_cpup(p++);
5433 if (res->dir == 0 || res->dir > NFS4_CDFS4_BOTH)
5434 return -EIO;
5435 if (be32_to_cpup(p) == 0)
5436 res->use_conn_in_rdma_mode = false;
5437 else
5438 res->use_conn_in_rdma_mode = true;
5439
5440 return 0;
5441out_overflow:
5442 print_overflow_msg(__func__, xdr);
5443 return -EIO;
5444}
5445
5369static int decode_create_session(struct xdr_stream *xdr,5446static int decode_create_session(struct xdr_stream *xdr,
5370 struct nfs41_create_session_res *res)5447 struct nfs41_create_session_res *res)
5371{5448{
@@ -6647,6 +6724,22 @@ out: · 1275 unmodified lines
6647}6724}
6648 6725
6649#if defined(CONFIG_NFS_V4_1)6726#if defined(CONFIG_NFS_V4_1)
6727/*
6728 * Decode BIND_CONN_TO_SESSION response
6729 */
6730static int nfs4_xdr_dec_bind_conn_to_session(struct rpc_rqst *rqstp,
6731 struct xdr_stream *xdr,
6732 void *res)
6733{
6734 struct compound_hdr hdr;
6735 int status;
6736
6737 status = decode_compound_hdr(xdr, &hdr);
6738 if (!status)
6739 status = decode_bind_conn_to_session(xdr, res);
6740 return status;
6741}
6742
6650/*6743/*
6651 * Decode EXCHANGE_ID response6744 * Decode EXCHANGE_ID response
6652 */6745 */
@@ -7128,6 +7221,8 @@ struct rpc_procinfo nfs4_procedures[] = { · 475 unmodified lines
7128 PROC(RELEASE_LOCKOWNER, enc_release_lockowner, dec_release_lockowner),7221 PROC(RELEASE_LOCKOWNER, enc_release_lockowner, dec_release_lockowner),
7129 PROC(SECINFO, enc_secinfo, dec_secinfo),7222 PROC(SECINFO, enc_secinfo, dec_secinfo),
7130#if defined(CONFIG_NFS_V4_1)7223#if defined(CONFIG_NFS_V4_1)
7224 PROC(BIND_CONN_TO_SESSION,
7225 enc_bind_conn_to_session, dec_bind_conn_to_session),
7131 PROC(EXCHANGE_ID, enc_exchange_id, dec_exchange_id),7226 PROC(EXCHANGE_ID, enc_exchange_id, dec_exchange_id),
7132 PROC(CREATE_SESSION, enc_create_session, dec_create_session),7227 PROC(CREATE_SESSION, enc_create_session, dec_create_session),
7133 PROC(DESTROY_SESSION, enc_destroy_session, dec_destroy_session),7228 PROC(DESTROY_SESSION, enc_destroy_session, dec_destroy_session),
include/linux/nfs4.h+5−0
@@ -69,6 +69,10 @@ · 68 unmodified lines
69#define NFS4_CDFC4_FORE_OR_BOTH 0x369#define NFS4_CDFC4_FORE_OR_BOTH 0x3
70#define NFS4_CDFC4_BACK_OR_BOTH 0x770#define NFS4_CDFC4_BACK_OR_BOTH 0x7
71 71
72#define NFS4_CDFS4_FORE 0x1
73#define NFS4_CDFS4_BACK 0x2
74#define NFS4_CDFS4_BOTH 0x3
75
72#define NFS4_SET_TO_SERVER_TIME 076#define NFS4_SET_TO_SERVER_TIME 0
73#define NFS4_SET_TO_CLIENT_TIME 177#define NFS4_SET_TO_CLIENT_TIME 1
74 78
@@ -589,6 +593,7 @@ enum { · 514 unmodified lines
589 NFSPROC4_CLNT_SECINFO,593 NFSPROC4_CLNT_SECINFO,
590 594
591 /* nfs41 */595 /* nfs41 */
596 NFSPROC4_CLNT_BIND_CONN_TO_SESSION,
592 NFSPROC4_CLNT_EXCHANGE_ID,597 NFSPROC4_CLNT_EXCHANGE_ID,
593 NFSPROC4_CLNT_CREATE_SESSION,598 NFSPROC4_CLNT_CREATE_SESSION,
594 NFSPROC4_CLNT_DESTROY_SESSION,599 NFSPROC4_CLNT_DESTROY_SESSION,
include/linux/nfs_xdr.h+6−0
@@ -1125,6 +1125,12 @@ struct nfs41_impl_id { · 1124 unmodified lines
1125 struct nfstime4 date;1125 struct nfstime4 date;
1126};1126};
1127 1127
1128struct nfs41_bind_conn_to_session_res {
1129 struct nfs4_session *session;
1130 u32 dir;
1131 bool use_conn_in_rdma_mode;
1132};
1133
1128struct nfs41_exchange_id_res {1134struct nfs41_exchange_id_res {
1129 struct nfs_client *client;1135 struct nfs_client *client;
1130 u32 flags;1136 u32 flags;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t