diff options
author | Benny Halevy <bhalevy@panasas.com> | 2009-08-14 10:19:34 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2009-08-14 13:19:24 -0400 |
commit | 811652bd6edd66dd35bf9caacdfe96d19f75a47e (patch) | |
tree | 58e2a25334e878c207f3e9a7a423881cf7d69974 /fs | |
parent | 345585132a204859fbb7d8b662e9b6e5b563c6dc (diff) |
nfs: nfs4xdr: merge xdr_encode_int+xdr_encode_opaque_fixed into xdr_encode_opaque
use encode_string where appropriate.
Signed-off-by: Benny Halevy <bhalevy@panasas.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/nfs/nfs4xdr.c | 42 |
1 files changed, 14 insertions, 28 deletions
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c index d75f821cad01..efa78ad98228 100644 --- a/fs/nfs/nfs4xdr.c +++ b/fs/nfs/nfs4xdr.c | |||
@@ -732,9 +732,8 @@ static void encode_compound_hdr(struct xdr_stream *xdr, | |||
732 | 732 | ||
733 | dprintk("encode_compound: tag=%.*s\n", (int)hdr->taglen, hdr->tag); | 733 | dprintk("encode_compound: tag=%.*s\n", (int)hdr->taglen, hdr->tag); |
734 | BUG_ON(hdr->taglen > NFS4_MAXTAGLEN); | 734 | BUG_ON(hdr->taglen > NFS4_MAXTAGLEN); |
735 | p = reserve_space(xdr, 12 + hdr->taglen); | 735 | p = reserve_space(xdr, 4 + hdr->taglen + 8); |
736 | *p++ = cpu_to_be32(hdr->taglen); | 736 | p = xdr_encode_opaque(p, hdr->tag, hdr->taglen); |
737 | p = xdr_encode_opaque_fixed(p, hdr->tag, hdr->taglen); | ||
738 | *p++ = cpu_to_be32(hdr->minorversion); | 737 | *p++ = cpu_to_be32(hdr->minorversion); |
739 | hdr->nops_p = p; | 738 | hdr->nops_p = p; |
740 | *p = cpu_to_be32(hdr->nops); | 739 | *p = cpu_to_be32(hdr->nops); |
@@ -832,13 +831,11 @@ static void encode_attrs(struct xdr_stream *xdr, const struct iattr *iap, const | |||
832 | } | 831 | } |
833 | if (iap->ia_valid & ATTR_UID) { | 832 | if (iap->ia_valid & ATTR_UID) { |
834 | bmval1 |= FATTR4_WORD1_OWNER; | 833 | bmval1 |= FATTR4_WORD1_OWNER; |
835 | *p++ = cpu_to_be32(owner_namelen); | 834 | p = xdr_encode_opaque(p, owner_name, owner_namelen); |
836 | p = xdr_encode_opaque_fixed(p, owner_name, owner_namelen); | ||
837 | } | 835 | } |
838 | if (iap->ia_valid & ATTR_GID) { | 836 | if (iap->ia_valid & ATTR_GID) { |
839 | bmval1 |= FATTR4_WORD1_OWNER_GROUP; | 837 | bmval1 |= FATTR4_WORD1_OWNER_GROUP; |
840 | *p++ = cpu_to_be32(owner_grouplen); | 838 | p = xdr_encode_opaque(p, owner_group, owner_grouplen); |
841 | p = xdr_encode_opaque_fixed(p, owner_group, owner_grouplen); | ||
842 | } | 839 | } |
843 | if (iap->ia_valid & ATTR_ATIME_SET) { | 840 | if (iap->ia_valid & ATTR_ATIME_SET) { |
844 | bmval1 |= FATTR4_WORD1_TIME_ACCESS_SET; | 841 | bmval1 |= FATTR4_WORD1_TIME_ACCESS_SET; |
@@ -939,9 +936,7 @@ static void encode_create(struct xdr_stream *xdr, const struct nfs4_create_arg * | |||
939 | break; | 936 | break; |
940 | } | 937 | } |
941 | 938 | ||
942 | p = reserve_space(xdr, 4 + create->name->len); | 939 | encode_string(xdr, create->name->len, create->name->name); |
943 | *p++ = cpu_to_be32(create->name->len); | ||
944 | xdr_encode_opaque_fixed(p, create->name->name, create->name->len); | ||
945 | hdr->nops++; | 940 | hdr->nops++; |
946 | hdr->replen += decode_create_maxsz; | 941 | hdr->replen += decode_create_maxsz; |
947 | 942 | ||
@@ -1007,8 +1002,7 @@ static void encode_link(struct xdr_stream *xdr, const struct qstr *name, struct | |||
1007 | 1002 | ||
1008 | p = reserve_space(xdr, 8 + name->len); | 1003 | p = reserve_space(xdr, 8 + name->len); |
1009 | *p++ = cpu_to_be32(OP_LINK); | 1004 | *p++ = cpu_to_be32(OP_LINK); |
1010 | *p++ = cpu_to_be32(name->len); | 1005 | xdr_encode_opaque(p, name->name, name->len); |
1011 | xdr_encode_opaque_fixed(p, name->name, name->len); | ||
1012 | hdr->nops++; | 1006 | hdr->nops++; |
1013 | hdr->replen += decode_link_maxsz; | 1007 | hdr->replen += decode_link_maxsz; |
1014 | } | 1008 | } |
@@ -1100,8 +1094,7 @@ static void encode_lookup(struct xdr_stream *xdr, const struct qstr *name, struc | |||
1100 | 1094 | ||
1101 | p = reserve_space(xdr, 8 + len); | 1095 | p = reserve_space(xdr, 8 + len); |
1102 | *p++ = cpu_to_be32(OP_LOOKUP); | 1096 | *p++ = cpu_to_be32(OP_LOOKUP); |
1103 | *p++ = cpu_to_be32(len); | 1097 | xdr_encode_opaque(p, name->name, len); |
1104 | xdr_encode_opaque_fixed(p, name->name, len); | ||
1105 | hdr->nops++; | 1098 | hdr->nops++; |
1106 | hdr->replen += decode_lookup_maxsz; | 1099 | hdr->replen += decode_lookup_maxsz; |
1107 | } | 1100 | } |
@@ -1279,8 +1272,7 @@ encode_putfh(struct xdr_stream *xdr, const struct nfs_fh *fh, struct compound_hd | |||
1279 | 1272 | ||
1280 | p = reserve_space(xdr, 8 + len); | 1273 | p = reserve_space(xdr, 8 + len); |
1281 | *p++ = cpu_to_be32(OP_PUTFH); | 1274 | *p++ = cpu_to_be32(OP_PUTFH); |
1282 | *p++ = cpu_to_be32(len); | 1275 | xdr_encode_opaque(p, fh->data, len); |
1283 | xdr_encode_opaque_fixed(p, fh->data, len); | ||
1284 | hdr->nops++; | 1276 | hdr->nops++; |
1285 | hdr->replen += decode_putfh_maxsz; | 1277 | hdr->replen += decode_putfh_maxsz; |
1286 | } | 1278 | } |
@@ -1373,8 +1365,7 @@ static void encode_remove(struct xdr_stream *xdr, const struct qstr *name, struc | |||
1373 | 1365 | ||
1374 | p = reserve_space(xdr, 8 + name->len); | 1366 | p = reserve_space(xdr, 8 + name->len); |
1375 | *p++ = cpu_to_be32(OP_REMOVE); | 1367 | *p++ = cpu_to_be32(OP_REMOVE); |
1376 | *p++ = cpu_to_be32(name->len); | 1368 | xdr_encode_opaque(p, name->name, name->len); |
1377 | xdr_encode_opaque_fixed(p, name->name, name->len); | ||
1378 | hdr->nops++; | 1369 | hdr->nops++; |
1379 | hdr->replen += decode_remove_maxsz; | 1370 | hdr->replen += decode_remove_maxsz; |
1380 | } | 1371 | } |
@@ -1383,14 +1374,10 @@ static void encode_rename(struct xdr_stream *xdr, const struct qstr *oldname, co | |||
1383 | { | 1374 | { |
1384 | __be32 *p; | 1375 | __be32 *p; |
1385 | 1376 | ||
1386 | p = reserve_space(xdr, 8 + oldname->len); | 1377 | p = reserve_space(xdr, 4); |
1387 | *p++ = cpu_to_be32(OP_RENAME); | 1378 | *p = cpu_to_be32(OP_RENAME); |
1388 | *p++ = cpu_to_be32(oldname->len); | 1379 | encode_string(xdr, oldname->len, oldname->name); |
1389 | xdr_encode_opaque_fixed(p, oldname->name, oldname->len); | 1380 | encode_string(xdr, newname->len, newname->name); |
1390 | |||
1391 | p = reserve_space(xdr, 4 + newname->len); | ||
1392 | *p++ = cpu_to_be32(newname->len); | ||
1393 | xdr_encode_opaque_fixed(p, newname->name, newname->len); | ||
1394 | hdr->nops++; | 1381 | hdr->nops++; |
1395 | hdr->replen += decode_rename_maxsz; | 1382 | hdr->replen += decode_rename_maxsz; |
1396 | } | 1383 | } |
@@ -1587,8 +1574,7 @@ static void encode_create_session(struct xdr_stream *xdr, | |||
1587 | 1574 | ||
1588 | /* authsys_parms rfc1831 */ | 1575 | /* authsys_parms rfc1831 */ |
1589 | *p++ = cpu_to_be32((u32)clp->cl_boot_time.tv_nsec); /* stamp */ | 1576 | *p++ = cpu_to_be32((u32)clp->cl_boot_time.tv_nsec); /* stamp */ |
1590 | *p++ = cpu_to_be32(len); | 1577 | p = xdr_encode_opaque(p, machine_name, len); |
1591 | p = xdr_encode_opaque_fixed(p, machine_name, len); | ||
1592 | *p++ = cpu_to_be32(0); /* UID */ | 1578 | *p++ = cpu_to_be32(0); /* UID */ |
1593 | *p++ = cpu_to_be32(0); /* GID */ | 1579 | *p++ = cpu_to_be32(0); /* GID */ |
1594 | *p = cpu_to_be32(0); /* No more gids */ | 1580 | *p = cpu_to_be32(0); /* No more gids */ |