提交 0c0c267b 编写于 作者: J J. Bruce Fields

nfsd4: kill WRITEMEM

Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
上级 b64c7f3b
...@@ -1683,12 +1683,6 @@ nfsd4_decode_compound(struct nfsd4_compoundargs *argp) ...@@ -1683,12 +1683,6 @@ nfsd4_decode_compound(struct nfsd4_compoundargs *argp)
DECODE_TAIL; DECODE_TAIL;
} }
#define WRITEMEM(ptr,nbytes) do { if (nbytes > 0) { \
*(p + XDR_QUADLEN(nbytes) -1) = 0; \
memcpy(p, ptr, nbytes); \
p += XDR_QUADLEN(nbytes); \
}} while (0)
static void write32(__be32 **p, u32 n) static void write32(__be32 **p, u32 n)
{ {
*(*p)++ = htonl(n); *(*p)++ = htonl(n);
...@@ -1769,8 +1763,7 @@ static __be32 nfsd4_encode_components_esc(struct xdr_stream *xdr, char sep, ...@@ -1769,8 +1763,7 @@ static __be32 nfsd4_encode_components_esc(struct xdr_stream *xdr, char sep,
p = xdr_reserve_space(xdr, strlen + 4); p = xdr_reserve_space(xdr, strlen + 4);
if (!p) if (!p)
return nfserr_resource; return nfserr_resource;
*p++ = cpu_to_be32(strlen); p = xdr_encode_opaque(p, str, strlen);
WRITEMEM(str, strlen);
count++; count++;
} }
else else
...@@ -1865,8 +1858,7 @@ static __be32 nfsd4_encode_path(struct xdr_stream *xdr, ...@@ -1865,8 +1858,7 @@ static __be32 nfsd4_encode_path(struct xdr_stream *xdr,
spin_unlock(&dentry->d_lock); spin_unlock(&dentry->d_lock);
goto out_free; goto out_free;
} }
*p++ = cpu_to_be32(len); p = xdr_encode_opaque(p, dentry->d_name.name, len);
WRITEMEM(dentry->d_name.name, len);
dprintk("/%s", dentry->d_name.name); dprintk("/%s", dentry->d_name.name);
spin_unlock(&dentry->d_lock); spin_unlock(&dentry->d_lock);
dput(dentry); dput(dentry);
...@@ -2239,7 +2231,7 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, ...@@ -2239,7 +2231,7 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp,
*p++ = cpu_to_be32(MINOR(stat.dev)); *p++ = cpu_to_be32(MINOR(stat.dev));
break; break;
case FSIDSOURCE_UUID: case FSIDSOURCE_UUID:
WRITEMEM(exp->ex_uuid, 16); p = xdr_encode_opaque_fixed(p, exp->ex_uuid, 16);
break; break;
} }
} }
...@@ -2326,8 +2318,8 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, ...@@ -2326,8 +2318,8 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp,
p = xdr_reserve_space(xdr, fhp->fh_handle.fh_size + 4); p = xdr_reserve_space(xdr, fhp->fh_handle.fh_size + 4);
if (!p) if (!p)
goto out_resource; goto out_resource;
*p++ = cpu_to_be32(fhp->fh_handle.fh_size); p = xdr_encode_opaque(p, &fhp->fh_handle.fh_base,
WRITEMEM(&fhp->fh_handle.fh_base, fhp->fh_handle.fh_size); fhp->fh_handle.fh_size);
} }
if (bmval0 & FATTR4_WORD0_FILEID) { if (bmval0 & FATTR4_WORD0_FILEID) {
p = xdr_reserve_space(xdr, 8); p = xdr_reserve_space(xdr, 8);
...@@ -2748,7 +2740,8 @@ nfsd4_encode_stateid(struct xdr_stream *xdr, stateid_t *sid) ...@@ -2748,7 +2740,8 @@ nfsd4_encode_stateid(struct xdr_stream *xdr, stateid_t *sid)
if (!p) if (!p)
return nfserr_resource; return nfserr_resource;
*p++ = cpu_to_be32(sid->si_generation); *p++ = cpu_to_be32(sid->si_generation);
WRITEMEM(&sid->si_opaque, sizeof(stateid_opaque_t)); p = xdr_encode_opaque_fixed(p, &sid->si_opaque,
sizeof(stateid_opaque_t));
return 0; return 0;
} }
...@@ -2777,7 +2770,8 @@ static __be32 nfsd4_encode_bind_conn_to_session(struct nfsd4_compoundres *resp, ...@@ -2777,7 +2770,8 @@ static __be32 nfsd4_encode_bind_conn_to_session(struct nfsd4_compoundres *resp,
p = xdr_reserve_space(xdr, NFS4_MAX_SESSIONID_LEN + 8); p = xdr_reserve_space(xdr, NFS4_MAX_SESSIONID_LEN + 8);
if (!p) if (!p)
return nfserr_resource; return nfserr_resource;
WRITEMEM(bcts->sessionid.data, NFS4_MAX_SESSIONID_LEN); p = xdr_encode_opaque_fixed(p, bcts->sessionid.data,
NFS4_MAX_SESSIONID_LEN);
*p++ = cpu_to_be32(bcts->dir); *p++ = cpu_to_be32(bcts->dir);
/* Sorry, we do not yet support RDMA over 4.1: */ /* Sorry, we do not yet support RDMA over 4.1: */
*p++ = cpu_to_be32(0); *p++ = cpu_to_be32(0);
...@@ -2807,7 +2801,8 @@ nfsd4_encode_commit(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_ ...@@ -2807,7 +2801,8 @@ nfsd4_encode_commit(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_
p = xdr_reserve_space(xdr, NFS4_VERIFIER_SIZE); p = xdr_reserve_space(xdr, NFS4_VERIFIER_SIZE);
if (!p) if (!p)
return nfserr_resource; return nfserr_resource;
WRITEMEM(commit->co_verf.data, NFS4_VERIFIER_SIZE); p = xdr_encode_opaque_fixed(p, commit->co_verf.data,
NFS4_VERIFIER_SIZE);
} }
return nfserr; return nfserr;
} }
...@@ -2858,8 +2853,7 @@ nfsd4_encode_getfh(struct nfsd4_compoundres *resp, __be32 nfserr, struct svc_fh ...@@ -2858,8 +2853,7 @@ nfsd4_encode_getfh(struct nfsd4_compoundres *resp, __be32 nfserr, struct svc_fh
p = xdr_reserve_space(xdr, len + 4); p = xdr_reserve_space(xdr, len + 4);
if (!p) if (!p)
return nfserr_resource; return nfserr_resource;
*p++ = cpu_to_be32(len); p = xdr_encode_opaque(p, &fhp->fh_handle.fh_base, len);
WRITEMEM(&fhp->fh_handle.fh_base, len);
} }
return nfserr; return nfserr;
} }
...@@ -2892,9 +2886,8 @@ nfsd4_encode_lock_denied(struct xdr_stream *xdr, struct nfsd4_lock_denied *ld) ...@@ -2892,9 +2886,8 @@ nfsd4_encode_lock_denied(struct xdr_stream *xdr, struct nfsd4_lock_denied *ld)
p = xdr_encode_hyper(p, ld->ld_length); p = xdr_encode_hyper(p, ld->ld_length);
*p++ = cpu_to_be32(ld->ld_type); *p++ = cpu_to_be32(ld->ld_type);
if (conf->len) { if (conf->len) {
WRITEMEM(&ld->ld_clientid, 8); p = xdr_encode_opaque_fixed(p, &ld->ld_clientid, 8);
*p++ = cpu_to_be32(conf->len); p = xdr_encode_opaque(p, conf->data, conf->len);
WRITEMEM(conf->data, conf->len);
} else { /* non - nfsv4 lock in conflict, no clientid nor owner */ } else { /* non - nfsv4 lock in conflict, no clientid nor owner */
p = xdr_encode_hyper(p, (u64)0); /* clientid */ p = xdr_encode_hyper(p, (u64)0); /* clientid */
*p++ = cpu_to_be32(0); /* length of owner name */ *p++ = cpu_to_be32(0); /* length of owner name */
...@@ -3459,8 +3452,7 @@ nfsd4_do_encode_secinfo(struct xdr_stream *xdr, ...@@ -3459,8 +3452,7 @@ nfsd4_do_encode_secinfo(struct xdr_stream *xdr,
if (!p) if (!p)
goto out; goto out;
*p++ = cpu_to_be32(RPC_AUTH_GSS); *p++ = cpu_to_be32(RPC_AUTH_GSS);
*p++ = cpu_to_be32(info.oid.len); p = xdr_encode_opaque(p, info.oid.data, info.oid.len);
WRITEMEM(info.oid.data, info.oid.len);
*p++ = cpu_to_be32(info.qop); *p++ = cpu_to_be32(info.qop);
*p++ = cpu_to_be32(info.service); *p++ = cpu_to_be32(info.service);
} else if (pf < RPC_AUTH_MAXFLAVOR) { } else if (pf < RPC_AUTH_MAXFLAVOR) {
...@@ -3542,8 +3534,9 @@ nfsd4_encode_setclientid(struct nfsd4_compoundres *resp, __be32 nfserr, struct n ...@@ -3542,8 +3534,9 @@ nfsd4_encode_setclientid(struct nfsd4_compoundres *resp, __be32 nfserr, struct n
p = xdr_reserve_space(xdr, 8 + NFS4_VERIFIER_SIZE); p = xdr_reserve_space(xdr, 8 + NFS4_VERIFIER_SIZE);
if (!p) if (!p)
return nfserr_resource; return nfserr_resource;
WRITEMEM(&scd->se_clientid, 8); p = xdr_encode_opaque_fixed(p, &scd->se_clientid, 8);
WRITEMEM(&scd->se_confirm, NFS4_VERIFIER_SIZE); p = xdr_encode_opaque_fixed(p, &scd->se_confirm,
NFS4_VERIFIER_SIZE);
} }
else if (nfserr == nfserr_clid_inuse) { else if (nfserr == nfserr_clid_inuse) {
p = xdr_reserve_space(xdr, 8); p = xdr_reserve_space(xdr, 8);
...@@ -3567,7 +3560,8 @@ nfsd4_encode_write(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_w ...@@ -3567,7 +3560,8 @@ nfsd4_encode_write(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_w
return nfserr_resource; return nfserr_resource;
*p++ = cpu_to_be32(write->wr_bytes_written); *p++ = cpu_to_be32(write->wr_bytes_written);
*p++ = cpu_to_be32(write->wr_how_written); *p++ = cpu_to_be32(write->wr_how_written);
WRITEMEM(write->wr_verifier.data, NFS4_VERIFIER_SIZE); p = xdr_encode_opaque_fixed(p, write->wr_verifier.data,
NFS4_VERIFIER_SIZE);
} }
return nfserr; return nfserr;
} }
...@@ -3608,7 +3602,7 @@ nfsd4_encode_exchange_id(struct nfsd4_compoundres *resp, __be32 nfserr, ...@@ -3608,7 +3602,7 @@ nfsd4_encode_exchange_id(struct nfsd4_compoundres *resp, __be32 nfserr,
if (!p) if (!p)
return nfserr_resource; return nfserr_resource;
WRITEMEM(&exid->clientid, 8); p = xdr_encode_opaque_fixed(p, &exid->clientid, 8);
*p++ = cpu_to_be32(exid->seqid); *p++ = cpu_to_be32(exid->seqid);
*p++ = cpu_to_be32(exid->flags); *p++ = cpu_to_be32(exid->flags);
...@@ -3648,12 +3642,10 @@ nfsd4_encode_exchange_id(struct nfsd4_compoundres *resp, __be32 nfserr, ...@@ -3648,12 +3642,10 @@ nfsd4_encode_exchange_id(struct nfsd4_compoundres *resp, __be32 nfserr,
/* The server_owner struct */ /* The server_owner struct */
p = xdr_encode_hyper(p, minor_id); /* Minor id */ p = xdr_encode_hyper(p, minor_id); /* Minor id */
/* major id */ /* major id */
*p++ = cpu_to_be32(major_id_sz); p = xdr_encode_opaque(p, major_id, major_id_sz);
WRITEMEM(major_id, major_id_sz);
/* Server scope */ /* Server scope */
*p++ = cpu_to_be32(server_scope_sz); p = xdr_encode_opaque(p, server_scope, server_scope_sz);
WRITEMEM(server_scope, server_scope_sz);
/* Implementation id */ /* Implementation id */
*p++ = cpu_to_be32(0); /* zero length nfs_impl_id4 array */ *p++ = cpu_to_be32(0); /* zero length nfs_impl_id4 array */
...@@ -3673,7 +3665,8 @@ nfsd4_encode_create_session(struct nfsd4_compoundres *resp, __be32 nfserr, ...@@ -3673,7 +3665,8 @@ nfsd4_encode_create_session(struct nfsd4_compoundres *resp, __be32 nfserr,
p = xdr_reserve_space(xdr, 24); p = xdr_reserve_space(xdr, 24);
if (!p) if (!p)
return nfserr_resource; return nfserr_resource;
WRITEMEM(sess->sessionid.data, NFS4_MAX_SESSIONID_LEN); p = xdr_encode_opaque_fixed(p, sess->sessionid.data,
NFS4_MAX_SESSIONID_LEN);
*p++ = cpu_to_be32(sess->seqid); *p++ = cpu_to_be32(sess->seqid);
*p++ = cpu_to_be32(sess->flags); *p++ = cpu_to_be32(sess->flags);
...@@ -3728,7 +3721,8 @@ nfsd4_encode_sequence(struct nfsd4_compoundres *resp, __be32 nfserr, ...@@ -3728,7 +3721,8 @@ nfsd4_encode_sequence(struct nfsd4_compoundres *resp, __be32 nfserr,
p = xdr_reserve_space(xdr, NFS4_MAX_SESSIONID_LEN + 20); p = xdr_reserve_space(xdr, NFS4_MAX_SESSIONID_LEN + 20);
if (!p) if (!p)
return nfserr_resource; return nfserr_resource;
WRITEMEM(seq->sessionid.data, NFS4_MAX_SESSIONID_LEN); p = xdr_encode_opaque_fixed(p, seq->sessionid.data,
NFS4_MAX_SESSIONID_LEN);
*p++ = cpu_to_be32(seq->seqid); *p++ = cpu_to_be32(seq->seqid);
*p++ = cpu_to_be32(seq->slotid); *p++ = cpu_to_be32(seq->slotid);
/* Note slotid's are numbered from zero: */ /* Note slotid's are numbered from zero: */
...@@ -3957,7 +3951,7 @@ nfsd4_encode_replay(struct xdr_stream *xdr, struct nfsd4_op *op) ...@@ -3957,7 +3951,7 @@ nfsd4_encode_replay(struct xdr_stream *xdr, struct nfsd4_op *op)
*p++ = cpu_to_be32(op->opnum); *p++ = cpu_to_be32(op->opnum);
*p++ = rp->rp_status; /* already xdr'ed */ *p++ = rp->rp_status; /* already xdr'ed */
WRITEMEM(rp->rp_buf, rp->rp_buflen); p = xdr_encode_opaque_fixed(p, rp->rp_buf, rp->rp_buflen);
} }
int int
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册