提交 bb8b27e5 编写于 作者: T Trond Myklebust

NFSv4: Clean up the NFSv4 setclientid operation

Reviewed-by: NChuck Lever <chuck.lever@oracle.com>
Signed-off-by: NTrond Myklebust <Trond.Myklebust@netapp.com>
上级 d7cf8dd0
...@@ -206,8 +206,8 @@ extern ssize_t nfs4_listxattr(struct dentry *, char *, size_t); ...@@ -206,8 +206,8 @@ extern ssize_t nfs4_listxattr(struct dentry *, char *, size_t);
/* nfs4proc.c */ /* nfs4proc.c */
extern int nfs4_proc_setclientid(struct nfs_client *, u32, unsigned short, struct rpc_cred *); extern int nfs4_proc_setclientid(struct nfs_client *, u32, unsigned short, struct rpc_cred *, struct nfs4_setclientid_res *);
extern int nfs4_proc_setclientid_confirm(struct nfs_client *, struct rpc_cred *); extern int nfs4_proc_setclientid_confirm(struct nfs_client *, struct nfs4_setclientid_res *arg, struct rpc_cred *);
extern int nfs4_proc_exchange_id(struct nfs_client *clp, struct rpc_cred *cred); extern int nfs4_proc_exchange_id(struct nfs_client *clp, struct rpc_cred *cred);
extern int nfs4_proc_async_renew(struct nfs_client *, struct rpc_cred *); extern int nfs4_proc_async_renew(struct nfs_client *, struct rpc_cred *);
extern int nfs4_proc_renew(struct nfs_client *, struct rpc_cred *); extern int nfs4_proc_renew(struct nfs_client *, struct rpc_cred *);
......
...@@ -3511,7 +3511,9 @@ nfs4_async_handle_error(struct rpc_task *task, const struct nfs_server *server, ...@@ -3511,7 +3511,9 @@ nfs4_async_handle_error(struct rpc_task *task, const struct nfs_server *server,
return _nfs4_async_handle_error(task, server, server->nfs_client, state); return _nfs4_async_handle_error(task, server, server->nfs_client, state);
} }
int nfs4_proc_setclientid(struct nfs_client *clp, u32 program, unsigned short port, struct rpc_cred *cred) int nfs4_proc_setclientid(struct nfs_client *clp, u32 program,
unsigned short port, struct rpc_cred *cred,
struct nfs4_setclientid_res *res)
{ {
nfs4_verifier sc_verifier; nfs4_verifier sc_verifier;
struct nfs4_setclientid setclientid = { struct nfs4_setclientid setclientid = {
...@@ -3521,7 +3523,7 @@ int nfs4_proc_setclientid(struct nfs_client *clp, u32 program, unsigned short po ...@@ -3521,7 +3523,7 @@ int nfs4_proc_setclientid(struct nfs_client *clp, u32 program, unsigned short po
struct rpc_message msg = { struct rpc_message msg = {
.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_SETCLIENTID], .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_SETCLIENTID],
.rpc_argp = &setclientid, .rpc_argp = &setclientid,
.rpc_resp = clp, .rpc_resp = res,
.rpc_cred = cred, .rpc_cred = cred,
}; };
__be32 *p; __be32 *p;
...@@ -3564,12 +3566,14 @@ int nfs4_proc_setclientid(struct nfs_client *clp, u32 program, unsigned short po ...@@ -3564,12 +3566,14 @@ int nfs4_proc_setclientid(struct nfs_client *clp, u32 program, unsigned short po
return status; return status;
} }
static int _nfs4_proc_setclientid_confirm(struct nfs_client *clp, struct rpc_cred *cred) static int _nfs4_proc_setclientid_confirm(struct nfs_client *clp,
struct nfs4_setclientid_res *arg,
struct rpc_cred *cred)
{ {
struct nfs_fsinfo fsinfo; struct nfs_fsinfo fsinfo;
struct rpc_message msg = { struct rpc_message msg = {
.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_SETCLIENTID_CONFIRM], .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_SETCLIENTID_CONFIRM],
.rpc_argp = clp, .rpc_argp = arg,
.rpc_resp = &fsinfo, .rpc_resp = &fsinfo,
.rpc_cred = cred, .rpc_cred = cred,
}; };
...@@ -3587,12 +3591,14 @@ static int _nfs4_proc_setclientid_confirm(struct nfs_client *clp, struct rpc_cre ...@@ -3587,12 +3591,14 @@ static int _nfs4_proc_setclientid_confirm(struct nfs_client *clp, struct rpc_cre
return status; return status;
} }
int nfs4_proc_setclientid_confirm(struct nfs_client *clp, struct rpc_cred *cred) int nfs4_proc_setclientid_confirm(struct nfs_client *clp,
struct nfs4_setclientid_res *arg,
struct rpc_cred *cred)
{ {
long timeout = 0; long timeout = 0;
int err; int err;
do { do {
err = _nfs4_proc_setclientid_confirm(clp, cred); err = _nfs4_proc_setclientid_confirm(clp, arg, cred);
switch (err) { switch (err) {
case 0: case 0:
return err; return err;
......
...@@ -62,6 +62,7 @@ static LIST_HEAD(nfs4_clientid_list); ...@@ -62,6 +62,7 @@ static LIST_HEAD(nfs4_clientid_list);
int nfs4_init_clientid(struct nfs_client *clp, struct rpc_cred *cred) int nfs4_init_clientid(struct nfs_client *clp, struct rpc_cred *cred)
{ {
struct nfs4_setclientid_res clid;
unsigned short port; unsigned short port;
int status; int status;
...@@ -69,11 +70,15 @@ int nfs4_init_clientid(struct nfs_client *clp, struct rpc_cred *cred) ...@@ -69,11 +70,15 @@ int nfs4_init_clientid(struct nfs_client *clp, struct rpc_cred *cred)
if (clp->cl_addr.ss_family == AF_INET6) if (clp->cl_addr.ss_family == AF_INET6)
port = nfs_callback_tcpport6; port = nfs_callback_tcpport6;
status = nfs4_proc_setclientid(clp, NFS4_CALLBACK, port, cred); status = nfs4_proc_setclientid(clp, NFS4_CALLBACK, port, cred, &clid);
if (status == 0) if (status != 0)
status = nfs4_proc_setclientid_confirm(clp, cred); goto out;
if (status == 0) status = nfs4_proc_setclientid_confirm(clp, &clid, cred);
nfs4_schedule_state_renewal(clp); if (status != 0)
goto out;
clp->cl_clientid = clid.clientid;
nfs4_schedule_state_renewal(clp);
out:
return status; return status;
} }
......
...@@ -1504,14 +1504,14 @@ static void encode_setclientid(struct xdr_stream *xdr, const struct nfs4_setclie ...@@ -1504,14 +1504,14 @@ static void encode_setclientid(struct xdr_stream *xdr, const struct nfs4_setclie
hdr->replen += decode_setclientid_maxsz; hdr->replen += decode_setclientid_maxsz;
} }
static void encode_setclientid_confirm(struct xdr_stream *xdr, const struct nfs_client *client_state, struct compound_hdr *hdr) static void encode_setclientid_confirm(struct xdr_stream *xdr, const struct nfs4_setclientid_res *arg, struct compound_hdr *hdr)
{ {
__be32 *p; __be32 *p;
p = reserve_space(xdr, 12 + NFS4_VERIFIER_SIZE); p = reserve_space(xdr, 12 + NFS4_VERIFIER_SIZE);
*p++ = cpu_to_be32(OP_SETCLIENTID_CONFIRM); *p++ = cpu_to_be32(OP_SETCLIENTID_CONFIRM);
p = xdr_encode_hyper(p, client_state->cl_clientid); p = xdr_encode_hyper(p, arg->clientid);
xdr_encode_opaque_fixed(p, client_state->cl_confirm.data, NFS4_VERIFIER_SIZE); xdr_encode_opaque_fixed(p, arg->confirm.data, NFS4_VERIFIER_SIZE);
hdr->nops++; hdr->nops++;
hdr->replen += decode_setclientid_confirm_maxsz; hdr->replen += decode_setclientid_confirm_maxsz;
} }
...@@ -2324,7 +2324,7 @@ static int nfs4_xdr_enc_setclientid(struct rpc_rqst *req, __be32 *p, struct nfs4 ...@@ -2324,7 +2324,7 @@ static int nfs4_xdr_enc_setclientid(struct rpc_rqst *req, __be32 *p, struct nfs4
/* /*
* a SETCLIENTID_CONFIRM request * a SETCLIENTID_CONFIRM request
*/ */
static int nfs4_xdr_enc_setclientid_confirm(struct rpc_rqst *req, __be32 *p, struct nfs_client *clp) static int nfs4_xdr_enc_setclientid_confirm(struct rpc_rqst *req, __be32 *p, struct nfs4_setclientid_res *arg)
{ {
struct xdr_stream xdr; struct xdr_stream xdr;
struct compound_hdr hdr = { struct compound_hdr hdr = {
...@@ -2334,7 +2334,7 @@ static int nfs4_xdr_enc_setclientid_confirm(struct rpc_rqst *req, __be32 *p, str ...@@ -2334,7 +2334,7 @@ static int nfs4_xdr_enc_setclientid_confirm(struct rpc_rqst *req, __be32 *p, str
xdr_init_encode(&xdr, &req->rq_snd_buf, p); xdr_init_encode(&xdr, &req->rq_snd_buf, p);
encode_compound_hdr(&xdr, req, &hdr); encode_compound_hdr(&xdr, req, &hdr);
encode_setclientid_confirm(&xdr, clp, &hdr); encode_setclientid_confirm(&xdr, arg, &hdr);
encode_putrootfh(&xdr, &hdr); encode_putrootfh(&xdr, &hdr);
encode_fsinfo(&xdr, lease_bitmap, &hdr); encode_fsinfo(&xdr, lease_bitmap, &hdr);
encode_nops(&hdr); encode_nops(&hdr);
...@@ -4397,7 +4397,7 @@ static int decode_setattr(struct xdr_stream *xdr) ...@@ -4397,7 +4397,7 @@ static int decode_setattr(struct xdr_stream *xdr)
return -EIO; return -EIO;
} }
static int decode_setclientid(struct xdr_stream *xdr, struct nfs_client *clp) static int decode_setclientid(struct xdr_stream *xdr, struct nfs4_setclientid_res *res)
{ {
__be32 *p; __be32 *p;
uint32_t opnum; uint32_t opnum;
...@@ -4417,8 +4417,8 @@ static int decode_setclientid(struct xdr_stream *xdr, struct nfs_client *clp) ...@@ -4417,8 +4417,8 @@ static int decode_setclientid(struct xdr_stream *xdr, struct nfs_client *clp)
p = xdr_inline_decode(xdr, 8 + NFS4_VERIFIER_SIZE); p = xdr_inline_decode(xdr, 8 + NFS4_VERIFIER_SIZE);
if (unlikely(!p)) if (unlikely(!p))
goto out_overflow; goto out_overflow;
p = xdr_decode_hyper(p, &clp->cl_clientid); p = xdr_decode_hyper(p, &res->clientid);
memcpy(clp->cl_confirm.data, p, NFS4_VERIFIER_SIZE); memcpy(res->confirm.data, p, NFS4_VERIFIER_SIZE);
} else if (nfserr == NFSERR_CLID_INUSE) { } else if (nfserr == NFSERR_CLID_INUSE) {
uint32_t len; uint32_t len;
...@@ -5498,7 +5498,7 @@ static int nfs4_xdr_dec_renew(struct rpc_rqst *rqstp, __be32 *p, void *dummy) ...@@ -5498,7 +5498,7 @@ static int nfs4_xdr_dec_renew(struct rpc_rqst *rqstp, __be32 *p, void *dummy)
* Decode SETCLIENTID response * Decode SETCLIENTID response
*/ */
static int nfs4_xdr_dec_setclientid(struct rpc_rqst *req, __be32 *p, static int nfs4_xdr_dec_setclientid(struct rpc_rqst *req, __be32 *p,
struct nfs_client *clp) struct nfs4_setclientid_res *res)
{ {
struct xdr_stream xdr; struct xdr_stream xdr;
struct compound_hdr hdr; struct compound_hdr hdr;
...@@ -5507,7 +5507,7 @@ static int nfs4_xdr_dec_setclientid(struct rpc_rqst *req, __be32 *p, ...@@ -5507,7 +5507,7 @@ static int nfs4_xdr_dec_setclientid(struct rpc_rqst *req, __be32 *p,
xdr_init_decode(&xdr, &req->rq_rcv_buf, p); xdr_init_decode(&xdr, &req->rq_rcv_buf, p);
status = decode_compound_hdr(&xdr, &hdr); status = decode_compound_hdr(&xdr, &hdr);
if (!status) if (!status)
status = decode_setclientid(&xdr, clp); status = decode_setclientid(&xdr, res);
return status; return status;
} }
......
...@@ -44,7 +44,6 @@ struct nfs_client { ...@@ -44,7 +44,6 @@ struct nfs_client {
#ifdef CONFIG_NFS_V4 #ifdef CONFIG_NFS_V4
u64 cl_clientid; /* constant */ u64 cl_clientid; /* constant */
nfs4_verifier cl_confirm;
unsigned long cl_state; unsigned long cl_state;
struct rb_root cl_openowner_id; struct rb_root cl_openowner_id;
......
...@@ -824,6 +824,11 @@ struct nfs4_setclientid { ...@@ -824,6 +824,11 @@ struct nfs4_setclientid {
u32 sc_cb_ident; u32 sc_cb_ident;
}; };
struct nfs4_setclientid_res {
u64 clientid;
nfs4_verifier confirm;
};
struct nfs4_statfs_arg { struct nfs4_statfs_arg {
const struct nfs_fh * fh; const struct nfs_fh * fh;
const u32 * bitmask; const u32 * bitmask;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册