diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2010-04-16 16:43:06 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2010-05-14 15:09:30 -0400 |
commit | bb8b27e504c0f0463535fea31b42bcaa393c3fb0 (patch) | |
tree | fbf18d599a4a1bb5b509632ad9c906db288faeb3 /fs/nfs | |
parent | d7cf8dd01289b3c64057e38d34c2857f6633d52c (diff) |
NFSv4: Clean up the NFSv4 setclientid operation
Reviewed-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs')
-rw-r--r-- | fs/nfs/nfs4_fs.h | 4 | ||||
-rw-r--r-- | fs/nfs/nfs4proc.c | 18 | ||||
-rw-r--r-- | fs/nfs/nfs4state.c | 15 | ||||
-rw-r--r-- | fs/nfs/nfs4xdr.c | 20 |
4 files changed, 34 insertions, 23 deletions
diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h index a187200a7aac..509930664d74 100644 --- a/fs/nfs/nfs4_fs.h +++ b/fs/nfs/nfs4_fs.h | |||
@@ -206,8 +206,8 @@ extern ssize_t nfs4_listxattr(struct dentry *, char *, size_t); | |||
206 | 206 | ||
207 | 207 | ||
208 | /* nfs4proc.c */ | 208 | /* nfs4proc.c */ |
209 | extern int nfs4_proc_setclientid(struct nfs_client *, u32, unsigned short, struct rpc_cred *); | 209 | extern int nfs4_proc_setclientid(struct nfs_client *, u32, unsigned short, struct rpc_cred *, struct nfs4_setclientid_res *); |
210 | extern int nfs4_proc_setclientid_confirm(struct nfs_client *, struct rpc_cred *); | 210 | extern int nfs4_proc_setclientid_confirm(struct nfs_client *, struct nfs4_setclientid_res *arg, struct rpc_cred *); |
211 | extern int nfs4_proc_exchange_id(struct nfs_client *clp, struct rpc_cred *cred); | 211 | extern int nfs4_proc_exchange_id(struct nfs_client *clp, struct rpc_cred *cred); |
212 | extern int nfs4_proc_async_renew(struct nfs_client *, struct rpc_cred *); | 212 | extern int nfs4_proc_async_renew(struct nfs_client *, struct rpc_cred *); |
213 | extern int nfs4_proc_renew(struct nfs_client *, struct rpc_cred *); | 213 | extern int nfs4_proc_renew(struct nfs_client *, struct rpc_cred *); |
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 45f64701d4a6..04f4b2b2506b 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c | |||
@@ -3511,7 +3511,9 @@ nfs4_async_handle_error(struct rpc_task *task, const struct nfs_server *server, | |||
3511 | return _nfs4_async_handle_error(task, server, server->nfs_client, state); | 3511 | return _nfs4_async_handle_error(task, server, server->nfs_client, state); |
3512 | } | 3512 | } |
3513 | 3513 | ||
3514 | int nfs4_proc_setclientid(struct nfs_client *clp, u32 program, unsigned short port, struct rpc_cred *cred) | 3514 | int nfs4_proc_setclientid(struct nfs_client *clp, u32 program, |
3515 | unsigned short port, struct rpc_cred *cred, | ||
3516 | struct nfs4_setclientid_res *res) | ||
3515 | { | 3517 | { |
3516 | nfs4_verifier sc_verifier; | 3518 | nfs4_verifier sc_verifier; |
3517 | struct nfs4_setclientid setclientid = { | 3519 | struct nfs4_setclientid setclientid = { |
@@ -3521,7 +3523,7 @@ int nfs4_proc_setclientid(struct nfs_client *clp, u32 program, unsigned short po | |||
3521 | struct rpc_message msg = { | 3523 | struct rpc_message msg = { |
3522 | .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_SETCLIENTID], | 3524 | .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_SETCLIENTID], |
3523 | .rpc_argp = &setclientid, | 3525 | .rpc_argp = &setclientid, |
3524 | .rpc_resp = clp, | 3526 | .rpc_resp = res, |
3525 | .rpc_cred = cred, | 3527 | .rpc_cred = cred, |
3526 | }; | 3528 | }; |
3527 | __be32 *p; | 3529 | __be32 *p; |
@@ -3564,12 +3566,14 @@ int nfs4_proc_setclientid(struct nfs_client *clp, u32 program, unsigned short po | |||
3564 | return status; | 3566 | return status; |
3565 | } | 3567 | } |
3566 | 3568 | ||
3567 | static int _nfs4_proc_setclientid_confirm(struct nfs_client *clp, struct rpc_cred *cred) | 3569 | static int _nfs4_proc_setclientid_confirm(struct nfs_client *clp, |
3570 | struct nfs4_setclientid_res *arg, | ||
3571 | struct rpc_cred *cred) | ||
3568 | { | 3572 | { |
3569 | struct nfs_fsinfo fsinfo; | 3573 | struct nfs_fsinfo fsinfo; |
3570 | struct rpc_message msg = { | 3574 | struct rpc_message msg = { |
3571 | .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_SETCLIENTID_CONFIRM], | 3575 | .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_SETCLIENTID_CONFIRM], |
3572 | .rpc_argp = clp, | 3576 | .rpc_argp = arg, |
3573 | .rpc_resp = &fsinfo, | 3577 | .rpc_resp = &fsinfo, |
3574 | .rpc_cred = cred, | 3578 | .rpc_cred = cred, |
3575 | }; | 3579 | }; |
@@ -3587,12 +3591,14 @@ static int _nfs4_proc_setclientid_confirm(struct nfs_client *clp, struct rpc_cre | |||
3587 | return status; | 3591 | return status; |
3588 | } | 3592 | } |
3589 | 3593 | ||
3590 | int nfs4_proc_setclientid_confirm(struct nfs_client *clp, struct rpc_cred *cred) | 3594 | int nfs4_proc_setclientid_confirm(struct nfs_client *clp, |
3595 | struct nfs4_setclientid_res *arg, | ||
3596 | struct rpc_cred *cred) | ||
3591 | { | 3597 | { |
3592 | long timeout = 0; | 3598 | long timeout = 0; |
3593 | int err; | 3599 | int err; |
3594 | do { | 3600 | do { |
3595 | err = _nfs4_proc_setclientid_confirm(clp, cred); | 3601 | err = _nfs4_proc_setclientid_confirm(clp, arg, cred); |
3596 | switch (err) { | 3602 | switch (err) { |
3597 | case 0: | 3603 | case 0: |
3598 | return err; | 3604 | return err; |
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c index 6c5ed51f105e..cd2d90400d46 100644 --- a/fs/nfs/nfs4state.c +++ b/fs/nfs/nfs4state.c | |||
@@ -62,6 +62,7 @@ static LIST_HEAD(nfs4_clientid_list); | |||
62 | 62 | ||
63 | int nfs4_init_clientid(struct nfs_client *clp, struct rpc_cred *cred) | 63 | int nfs4_init_clientid(struct nfs_client *clp, struct rpc_cred *cred) |
64 | { | 64 | { |
65 | struct nfs4_setclientid_res clid; | ||
65 | unsigned short port; | 66 | unsigned short port; |
66 | int status; | 67 | int status; |
67 | 68 | ||
@@ -69,11 +70,15 @@ int nfs4_init_clientid(struct nfs_client *clp, struct rpc_cred *cred) | |||
69 | if (clp->cl_addr.ss_family == AF_INET6) | 70 | if (clp->cl_addr.ss_family == AF_INET6) |
70 | port = nfs_callback_tcpport6; | 71 | port = nfs_callback_tcpport6; |
71 | 72 | ||
72 | status = nfs4_proc_setclientid(clp, NFS4_CALLBACK, port, cred); | 73 | status = nfs4_proc_setclientid(clp, NFS4_CALLBACK, port, cred, &clid); |
73 | if (status == 0) | 74 | if (status != 0) |
74 | status = nfs4_proc_setclientid_confirm(clp, cred); | 75 | goto out; |
75 | if (status == 0) | 76 | status = nfs4_proc_setclientid_confirm(clp, &clid, cred); |
76 | nfs4_schedule_state_renewal(clp); | 77 | if (status != 0) |
78 | goto out; | ||
79 | clp->cl_clientid = clid.clientid; | ||
80 | nfs4_schedule_state_renewal(clp); | ||
81 | out: | ||
77 | return status; | 82 | return status; |
78 | } | 83 | } |
79 | 84 | ||
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c index 890580642dc0..6bdef28efa33 100644 --- a/fs/nfs/nfs4xdr.c +++ b/fs/nfs/nfs4xdr.c | |||
@@ -1504,14 +1504,14 @@ static void encode_setclientid(struct xdr_stream *xdr, const struct nfs4_setclie | |||
1504 | hdr->replen += decode_setclientid_maxsz; | 1504 | hdr->replen += decode_setclientid_maxsz; |
1505 | } | 1505 | } |
1506 | 1506 | ||
1507 | static void encode_setclientid_confirm(struct xdr_stream *xdr, const struct nfs_client *client_state, struct compound_hdr *hdr) | 1507 | static void encode_setclientid_confirm(struct xdr_stream *xdr, const struct nfs4_setclientid_res *arg, struct compound_hdr *hdr) |
1508 | { | 1508 | { |
1509 | __be32 *p; | 1509 | __be32 *p; |
1510 | 1510 | ||
1511 | p = reserve_space(xdr, 12 + NFS4_VERIFIER_SIZE); | 1511 | p = reserve_space(xdr, 12 + NFS4_VERIFIER_SIZE); |
1512 | *p++ = cpu_to_be32(OP_SETCLIENTID_CONFIRM); | 1512 | *p++ = cpu_to_be32(OP_SETCLIENTID_CONFIRM); |
1513 | p = xdr_encode_hyper(p, client_state->cl_clientid); | 1513 | p = xdr_encode_hyper(p, arg->clientid); |
1514 | xdr_encode_opaque_fixed(p, client_state->cl_confirm.data, NFS4_VERIFIER_SIZE); | 1514 | xdr_encode_opaque_fixed(p, arg->confirm.data, NFS4_VERIFIER_SIZE); |
1515 | hdr->nops++; | 1515 | hdr->nops++; |
1516 | hdr->replen += decode_setclientid_confirm_maxsz; | 1516 | hdr->replen += decode_setclientid_confirm_maxsz; |
1517 | } | 1517 | } |
@@ -2324,7 +2324,7 @@ static int nfs4_xdr_enc_setclientid(struct rpc_rqst *req, __be32 *p, struct nfs4 | |||
2324 | /* | 2324 | /* |
2325 | * a SETCLIENTID_CONFIRM request | 2325 | * a SETCLIENTID_CONFIRM request |
2326 | */ | 2326 | */ |
2327 | static int nfs4_xdr_enc_setclientid_confirm(struct rpc_rqst *req, __be32 *p, struct nfs_client *clp) | 2327 | static int nfs4_xdr_enc_setclientid_confirm(struct rpc_rqst *req, __be32 *p, struct nfs4_setclientid_res *arg) |
2328 | { | 2328 | { |
2329 | struct xdr_stream xdr; | 2329 | struct xdr_stream xdr; |
2330 | struct compound_hdr hdr = { | 2330 | struct compound_hdr hdr = { |
@@ -2334,7 +2334,7 @@ static int nfs4_xdr_enc_setclientid_confirm(struct rpc_rqst *req, __be32 *p, str | |||
2334 | 2334 | ||
2335 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); | 2335 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); |
2336 | encode_compound_hdr(&xdr, req, &hdr); | 2336 | encode_compound_hdr(&xdr, req, &hdr); |
2337 | encode_setclientid_confirm(&xdr, clp, &hdr); | 2337 | encode_setclientid_confirm(&xdr, arg, &hdr); |
2338 | encode_putrootfh(&xdr, &hdr); | 2338 | encode_putrootfh(&xdr, &hdr); |
2339 | encode_fsinfo(&xdr, lease_bitmap, &hdr); | 2339 | encode_fsinfo(&xdr, lease_bitmap, &hdr); |
2340 | encode_nops(&hdr); | 2340 | encode_nops(&hdr); |
@@ -4397,7 +4397,7 @@ out_overflow: | |||
4397 | return -EIO; | 4397 | return -EIO; |
4398 | } | 4398 | } |
4399 | 4399 | ||
4400 | static int decode_setclientid(struct xdr_stream *xdr, struct nfs_client *clp) | 4400 | static int decode_setclientid(struct xdr_stream *xdr, struct nfs4_setclientid_res *res) |
4401 | { | 4401 | { |
4402 | __be32 *p; | 4402 | __be32 *p; |
4403 | uint32_t opnum; | 4403 | uint32_t opnum; |
@@ -4417,8 +4417,8 @@ static int decode_setclientid(struct xdr_stream *xdr, struct nfs_client *clp) | |||
4417 | p = xdr_inline_decode(xdr, 8 + NFS4_VERIFIER_SIZE); | 4417 | p = xdr_inline_decode(xdr, 8 + NFS4_VERIFIER_SIZE); |
4418 | if (unlikely(!p)) | 4418 | if (unlikely(!p)) |
4419 | goto out_overflow; | 4419 | goto out_overflow; |
4420 | p = xdr_decode_hyper(p, &clp->cl_clientid); | 4420 | p = xdr_decode_hyper(p, &res->clientid); |
4421 | memcpy(clp->cl_confirm.data, p, NFS4_VERIFIER_SIZE); | 4421 | memcpy(res->confirm.data, p, NFS4_VERIFIER_SIZE); |
4422 | } else if (nfserr == NFSERR_CLID_INUSE) { | 4422 | } else if (nfserr == NFSERR_CLID_INUSE) { |
4423 | uint32_t len; | 4423 | uint32_t len; |
4424 | 4424 | ||
@@ -5498,7 +5498,7 @@ static int nfs4_xdr_dec_renew(struct rpc_rqst *rqstp, __be32 *p, void *dummy) | |||
5498 | * Decode SETCLIENTID response | 5498 | * Decode SETCLIENTID response |
5499 | */ | 5499 | */ |
5500 | static int nfs4_xdr_dec_setclientid(struct rpc_rqst *req, __be32 *p, | 5500 | static int nfs4_xdr_dec_setclientid(struct rpc_rqst *req, __be32 *p, |
5501 | struct nfs_client *clp) | 5501 | struct nfs4_setclientid_res *res) |
5502 | { | 5502 | { |
5503 | struct xdr_stream xdr; | 5503 | struct xdr_stream xdr; |
5504 | struct compound_hdr hdr; | 5504 | struct compound_hdr hdr; |
@@ -5507,7 +5507,7 @@ static int nfs4_xdr_dec_setclientid(struct rpc_rqst *req, __be32 *p, | |||
5507 | xdr_init_decode(&xdr, &req->rq_rcv_buf, p); | 5507 | xdr_init_decode(&xdr, &req->rq_rcv_buf, p); |
5508 | status = decode_compound_hdr(&xdr, &hdr); | 5508 | status = decode_compound_hdr(&xdr, &hdr); |
5509 | if (!status) | 5509 | if (!status) |
5510 | status = decode_setclientid(&xdr, clp); | 5510 | status = decode_setclientid(&xdr, res); |
5511 | return status; | 5511 | return status; |
5512 | } | 5512 | } |
5513 | 5513 | ||