diff options
author | Trond Myklebust <trond.myklebust@primarydata.com> | 2015-02-18 14:30:18 -0500 |
---|---|---|
committer | Trond Myklebust <trond.myklebust@primarydata.com> | 2015-02-18 15:28:50 -0500 |
commit | 79969dd12e8756f64a999992c0536ccd91bf6e54 (patch) | |
tree | b66d51039b086df40fdc3420a977f10c248f3454 /fs/nfs/nfs4proc.c | |
parent | 65d2918e716afb89359cfa59734d76c1ff8700cb (diff) |
NFSv4.1: Clean up create_session
Don't decode directly into the shared struct session
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Diffstat (limited to 'fs/nfs/nfs4proc.c')
-rw-r--r-- | fs/nfs/nfs4proc.c | 42 |
1 files changed, 29 insertions, 13 deletions
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 2e7c9f7a6f7c..006bfa3da55b 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c | |||
@@ -7166,10 +7166,11 @@ static void nfs4_init_channel_attrs(struct nfs41_create_session_args *args) | |||
7166 | args->bc_attrs.max_reqs); | 7166 | args->bc_attrs.max_reqs); |
7167 | } | 7167 | } |
7168 | 7168 | ||
7169 | static int nfs4_verify_fore_channel_attrs(struct nfs41_create_session_args *args, struct nfs4_session *session) | 7169 | static int nfs4_verify_fore_channel_attrs(struct nfs41_create_session_args *args, |
7170 | struct nfs41_create_session_res *res) | ||
7170 | { | 7171 | { |
7171 | struct nfs4_channel_attrs *sent = &args->fc_attrs; | 7172 | struct nfs4_channel_attrs *sent = &args->fc_attrs; |
7172 | struct nfs4_channel_attrs *rcvd = &session->fc_attrs; | 7173 | struct nfs4_channel_attrs *rcvd = &res->fc_attrs; |
7173 | 7174 | ||
7174 | if (rcvd->max_resp_sz > sent->max_resp_sz) | 7175 | if (rcvd->max_resp_sz > sent->max_resp_sz) |
7175 | return -EINVAL; | 7176 | return -EINVAL; |
@@ -7188,10 +7189,11 @@ static int nfs4_verify_fore_channel_attrs(struct nfs41_create_session_args *args | |||
7188 | return 0; | 7189 | return 0; |
7189 | } | 7190 | } |
7190 | 7191 | ||
7191 | static int nfs4_verify_back_channel_attrs(struct nfs41_create_session_args *args, struct nfs4_session *session) | 7192 | static int nfs4_verify_back_channel_attrs(struct nfs41_create_session_args *args, |
7193 | struct nfs41_create_session_res *res) | ||
7192 | { | 7194 | { |
7193 | struct nfs4_channel_attrs *sent = &args->bc_attrs; | 7195 | struct nfs4_channel_attrs *sent = &args->bc_attrs; |
7194 | struct nfs4_channel_attrs *rcvd = &session->bc_attrs; | 7196 | struct nfs4_channel_attrs *rcvd = &res->bc_attrs; |
7195 | 7197 | ||
7196 | if (rcvd->max_rqst_sz > sent->max_rqst_sz) | 7198 | if (rcvd->max_rqst_sz > sent->max_rqst_sz) |
7197 | return -EINVAL; | 7199 | return -EINVAL; |
@@ -7208,14 +7210,23 @@ static int nfs4_verify_back_channel_attrs(struct nfs41_create_session_args *args | |||
7208 | } | 7210 | } |
7209 | 7211 | ||
7210 | static int nfs4_verify_channel_attrs(struct nfs41_create_session_args *args, | 7212 | static int nfs4_verify_channel_attrs(struct nfs41_create_session_args *args, |
7211 | struct nfs4_session *session) | 7213 | struct nfs41_create_session_res *res) |
7212 | { | 7214 | { |
7213 | int ret; | 7215 | int ret; |
7214 | 7216 | ||
7215 | ret = nfs4_verify_fore_channel_attrs(args, session); | 7217 | ret = nfs4_verify_fore_channel_attrs(args, res); |
7216 | if (ret) | 7218 | if (ret) |
7217 | return ret; | 7219 | return ret; |
7218 | return nfs4_verify_back_channel_attrs(args, session); | 7220 | return nfs4_verify_back_channel_attrs(args, res); |
7221 | } | ||
7222 | |||
7223 | static void nfs4_update_session(struct nfs4_session *session, | ||
7224 | struct nfs41_create_session_res *res) | ||
7225 | { | ||
7226 | nfs4_copy_sessionid(&session->sess_id, &res->sessionid); | ||
7227 | session->flags = res->flags; | ||
7228 | memcpy(&session->fc_attrs, &res->fc_attrs, sizeof(session->fc_attrs)); | ||
7229 | memcpy(&session->bc_attrs, &res->bc_attrs, sizeof(session->bc_attrs)); | ||
7219 | } | 7230 | } |
7220 | 7231 | ||
7221 | static int _nfs4_proc_create_session(struct nfs_client *clp, | 7232 | static int _nfs4_proc_create_session(struct nfs_client *clp, |
@@ -7224,11 +7235,12 @@ static int _nfs4_proc_create_session(struct nfs_client *clp, | |||
7224 | struct nfs4_session *session = clp->cl_session; | 7235 | struct nfs4_session *session = clp->cl_session; |
7225 | struct nfs41_create_session_args args = { | 7236 | struct nfs41_create_session_args args = { |
7226 | .client = clp, | 7237 | .client = clp, |
7238 | .clientid = clp->cl_clientid, | ||
7239 | .seqid = clp->cl_seqid, | ||
7227 | .cb_program = NFS4_CALLBACK, | 7240 | .cb_program = NFS4_CALLBACK, |
7228 | }; | 7241 | }; |
7229 | struct nfs41_create_session_res res = { | 7242 | struct nfs41_create_session_res res; |
7230 | .client = clp, | 7243 | |
7231 | }; | ||
7232 | struct rpc_message msg = { | 7244 | struct rpc_message msg = { |
7233 | .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_CREATE_SESSION], | 7245 | .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_CREATE_SESSION], |
7234 | .rpc_argp = &args, | 7246 | .rpc_argp = &args, |
@@ -7245,11 +7257,15 @@ static int _nfs4_proc_create_session(struct nfs_client *clp, | |||
7245 | 7257 | ||
7246 | if (!status) { | 7258 | if (!status) { |
7247 | /* Verify the session's negotiated channel_attrs values */ | 7259 | /* Verify the session's negotiated channel_attrs values */ |
7248 | status = nfs4_verify_channel_attrs(&args, session); | 7260 | status = nfs4_verify_channel_attrs(&args, &res); |
7249 | /* Increment the clientid slot sequence id */ | 7261 | /* Increment the clientid slot sequence id */ |
7250 | clp->cl_seqid++; | 7262 | if (clp->cl_seqid == res.seqid) |
7263 | clp->cl_seqid++; | ||
7264 | if (status) | ||
7265 | goto out; | ||
7266 | nfs4_update_session(session, &res); | ||
7251 | } | 7267 | } |
7252 | 7268 | out: | |
7253 | return status; | 7269 | return status; |
7254 | } | 7270 | } |
7255 | 7271 | ||