aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2012-03-04 18:13:57 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2012-03-06 10:32:47 -0500
commit6fdfb0bc2a43f5deb612b7f79d9c7750708e0184 (patch)
tree1c144e8448a2a392c2e86e4d7d42734e1b0c3617
parent2d2f24add1ff903ff8e0ce61c5c05635cc636985 (diff)
NFSv4: Minor clean ups for encode_string()
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
-rw-r--r--fs/nfs/nfs4xdr.c40
1 files changed, 18 insertions, 22 deletions
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index 76ef98632839..d6e8306d02a7 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -897,8 +897,7 @@ static void encode_string(struct xdr_stream *xdr, unsigned int len, const char *
897{ 897{
898 __be32 *p; 898 __be32 *p;
899 899
900 p = xdr_reserve_space(xdr, 4 + len); 900 p = reserve_space(xdr, 4 + len);
901 BUG_ON(p == NULL);
902 xdr_encode_opaque(p, str, len); 901 xdr_encode_opaque(p, str, len);
903} 902}
904 903
@@ -915,8 +914,8 @@ static void encode_compound_hdr(struct xdr_stream *xdr,
915 hdr->replen = RPC_REPHDRSIZE + auth->au_rslack + 3 + hdr->taglen; 914 hdr->replen = RPC_REPHDRSIZE + auth->au_rslack + 3 + hdr->taglen;
916 915
917 BUG_ON(hdr->taglen > NFS4_MAXTAGLEN); 916 BUG_ON(hdr->taglen > NFS4_MAXTAGLEN);
918 p = reserve_space(xdr, 4 + hdr->taglen + 8); 917 encode_string(xdr, hdr->taglen, hdr->tag);
919 p = xdr_encode_opaque(p, hdr->tag, hdr->taglen); 918 p = reserve_space(xdr, 8);
920 *p++ = cpu_to_be32(hdr->minorversion); 919 *p++ = cpu_to_be32(hdr->minorversion);
921 hdr->nops_p = p; 920 hdr->nops_p = p;
922 *p = cpu_to_be32(hdr->nops); 921 *p = cpu_to_be32(hdr->nops);
@@ -1216,9 +1215,9 @@ static void encode_link(struct xdr_stream *xdr, const struct qstr *name, struct
1216{ 1215{
1217 __be32 *p; 1216 __be32 *p;
1218 1217
1219 p = reserve_space(xdr, 8 + name->len); 1218 p = reserve_space(xdr, 4);
1220 *p++ = cpu_to_be32(OP_LINK); 1219 *p = cpu_to_be32(OP_LINK);
1221 xdr_encode_opaque(p, name->name, name->len); 1220 encode_string(xdr, name->len, name->name);
1222 hdr->nops++; 1221 hdr->nops++;
1223 hdr->replen += decode_link_maxsz; 1222 hdr->replen += decode_link_maxsz;
1224} 1223}
@@ -1324,12 +1323,11 @@ static void encode_release_lockowner(struct xdr_stream *xdr, const struct nfs_lo
1324 1323
1325static void encode_lookup(struct xdr_stream *xdr, const struct qstr *name, struct compound_hdr *hdr) 1324static void encode_lookup(struct xdr_stream *xdr, const struct qstr *name, struct compound_hdr *hdr)
1326{ 1325{
1327 int len = name->len;
1328 __be32 *p; 1326 __be32 *p;
1329 1327
1330 p = reserve_space(xdr, 8 + len); 1328 p = reserve_space(xdr, 4);
1331 *p++ = cpu_to_be32(OP_LOOKUP); 1329 *p = cpu_to_be32(OP_LOOKUP);
1332 xdr_encode_opaque(p, name->name, len); 1330 encode_string(xdr, name->len, name->name);
1333 hdr->nops++; 1331 hdr->nops++;
1334 hdr->replen += decode_lookup_maxsz; 1332 hdr->replen += decode_lookup_maxsz;
1335} 1333}
@@ -1521,12 +1519,11 @@ static void encode_open_downgrade(struct xdr_stream *xdr, const struct nfs_close
1521static void 1519static void
1522encode_putfh(struct xdr_stream *xdr, const struct nfs_fh *fh, struct compound_hdr *hdr) 1520encode_putfh(struct xdr_stream *xdr, const struct nfs_fh *fh, struct compound_hdr *hdr)
1523{ 1521{
1524 int len = fh->size;
1525 __be32 *p; 1522 __be32 *p;
1526 1523
1527 p = reserve_space(xdr, 8 + len); 1524 p = reserve_space(xdr, 4);
1528 *p++ = cpu_to_be32(OP_PUTFH); 1525 *p = cpu_to_be32(OP_PUTFH);
1529 xdr_encode_opaque(p, fh->data, len); 1526 encode_string(xdr, fh->size, fh->data);
1530 hdr->nops++; 1527 hdr->nops++;
1531 hdr->replen += decode_putfh_maxsz; 1528 hdr->replen += decode_putfh_maxsz;
1532} 1529}
@@ -1628,9 +1625,9 @@ static void encode_remove(struct xdr_stream *xdr, const struct qstr *name, struc
1628{ 1625{
1629 __be32 *p; 1626 __be32 *p;
1630 1627
1631 p = reserve_space(xdr, 8 + name->len); 1628 p = reserve_space(xdr, 4);
1632 *p++ = cpu_to_be32(OP_REMOVE); 1629 *p = cpu_to_be32(OP_REMOVE);
1633 xdr_encode_opaque(p, name->name, name->len); 1630 encode_string(xdr, name->len, name->name);
1634 hdr->nops++; 1631 hdr->nops++;
1635 hdr->replen += decode_remove_maxsz; 1632 hdr->replen += decode_remove_maxsz;
1636} 1633}
@@ -1776,12 +1773,11 @@ static void encode_delegreturn(struct xdr_stream *xdr, const nfs4_stateid *state
1776 1773
1777static void encode_secinfo(struct xdr_stream *xdr, const struct qstr *name, struct compound_hdr *hdr) 1774static void encode_secinfo(struct xdr_stream *xdr, const struct qstr *name, struct compound_hdr *hdr)
1778{ 1775{
1779 int len = name->len;
1780 __be32 *p; 1776 __be32 *p;
1781 1777
1782 p = reserve_space(xdr, 8 + len); 1778 p = reserve_space(xdr, 4);
1783 *p++ = cpu_to_be32(OP_SECINFO); 1779 *p = cpu_to_be32(OP_SECINFO);
1784 xdr_encode_opaque(p, name->name, len); 1780 encode_string(xdr, name->len, name->name);
1785 hdr->nops++; 1781 hdr->nops++;
1786 hdr->replen += decode_secinfo_maxsz; 1782 hdr->replen += decode_secinfo_maxsz;
1787} 1783}