aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/nfs4xdr.c
diff options
context:
space:
mode:
authorBenny Halevy <bhalevy@panasas.com>2009-08-14 10:19:25 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2009-08-14 13:17:17 -0400
commit13c65ce90006badccd5663e558e3c85869ae5ce6 (patch)
tree9a88d57aba72e38f3bf55344b8a94212b9d2ddcd /fs/nfs/nfs4xdr.c
parent2220f13a8b90d2259f3094cb54cf4de67d8eee2d (diff)
nfs: nfs4xdr: change RESERVE_SPACE macro into a static helper
In order to open code and expose the result pointer assignment. Alternatively, we can open code the call to xdr_reserve_space and do the BUG_ON an the error case at the call site. Signed-off-by: Benny Halevy <bhalevy@panasas.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/nfs4xdr.c')
-rw-r--r--fs/nfs/nfs4xdr.c138
1 files changed, 65 insertions, 73 deletions
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index 7c2b162dd845..3bcde49fbea8 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -702,20 +702,12 @@ struct compound_hdr {
702 u32 minorversion; 702 u32 minorversion;
703}; 703};
704 704
705/* 705static __be32 *reserve_space(struct xdr_stream *xdr, size_t nbytes)
706 * START OF "GENERIC" ENCODE ROUTINES. 706{
707 * These may look a little ugly since they are imported from a "generic" 707 __be32 *p = xdr_reserve_space(xdr, nbytes);
708 * set of XDR encode/decode routines which are intended to be shared by 708 BUG_ON(!p);
709 * all of our NFSv4 implementations (OpenBSD, MacOS X...). 709 return p;
710 * 710}
711 * If the pain of reading these is too great, it should be a straightforward
712 * task to translate them into Linux-specific versions which are more
713 * consistent with the style used in NFSv2/v3...
714 */
715#define RESERVE_SPACE(nbytes) do { \
716 p = xdr_reserve_space(xdr, nbytes); \
717 BUG_ON(!p); \
718} while (0)
719 711
720static void encode_string(struct xdr_stream *xdr, unsigned int len, const char *str) 712static void encode_string(struct xdr_stream *xdr, unsigned int len, const char *str)
721{ 713{
@@ -740,7 +732,7 @@ static void encode_compound_hdr(struct xdr_stream *xdr,
740 732
741 dprintk("encode_compound: tag=%.*s\n", (int)hdr->taglen, hdr->tag); 733 dprintk("encode_compound: tag=%.*s\n", (int)hdr->taglen, hdr->tag);
742 BUG_ON(hdr->taglen > NFS4_MAXTAGLEN); 734 BUG_ON(hdr->taglen > NFS4_MAXTAGLEN);
743 RESERVE_SPACE(12 + hdr->taglen); 735 p = reserve_space(xdr, 12 + hdr->taglen);
744 *p++ = cpu_to_be32(hdr->taglen); 736 *p++ = cpu_to_be32(hdr->taglen);
745 p = xdr_encode_opaque_fixed(p, hdr->tag, hdr->taglen); 737 p = xdr_encode_opaque_fixed(p, hdr->tag, hdr->taglen);
746 *p++ = cpu_to_be32(hdr->minorversion); 738 *p++ = cpu_to_be32(hdr->minorversion);
@@ -820,7 +812,7 @@ static void encode_attrs(struct xdr_stream *xdr, const struct iattr *iap, const
820 len += 16; 812 len += 16;
821 else if (iap->ia_valid & ATTR_MTIME) 813 else if (iap->ia_valid & ATTR_MTIME)
822 len += 4; 814 len += 4;
823 RESERVE_SPACE(len); 815 p = reserve_space(xdr, len);
824 816
825 /* 817 /*
826 * We write the bitmap length now, but leave the bitmap and the attribute 818 * We write the bitmap length now, but leave the bitmap and the attribute
@@ -891,7 +883,7 @@ static void encode_access(struct xdr_stream *xdr, u32 access, struct compound_hd
891{ 883{
892 __be32 *p; 884 __be32 *p;
893 885
894 RESERVE_SPACE(8); 886 p = reserve_space(xdr, 8);
895 *p++ = cpu_to_be32(OP_ACCESS); 887 *p++ = cpu_to_be32(OP_ACCESS);
896 *p++ = cpu_to_be32(access); 888 *p++ = cpu_to_be32(access);
897 hdr->nops++; 889 hdr->nops++;
@@ -902,7 +894,7 @@ static void encode_close(struct xdr_stream *xdr, const struct nfs_closeargs *arg
902{ 894{
903 __be32 *p; 895 __be32 *p;
904 896
905 RESERVE_SPACE(8+NFS4_STATEID_SIZE); 897 p = reserve_space(xdr, 8+NFS4_STATEID_SIZE);
906 *p++ = cpu_to_be32(OP_CLOSE); 898 *p++ = cpu_to_be32(OP_CLOSE);
907 *p++ = cpu_to_be32(arg->seqid->sequence->counter); 899 *p++ = cpu_to_be32(arg->seqid->sequence->counter);
908 p = xdr_encode_opaque_fixed(p, arg->stateid->data, NFS4_STATEID_SIZE); 900 p = xdr_encode_opaque_fixed(p, arg->stateid->data, NFS4_STATEID_SIZE);
@@ -914,7 +906,7 @@ static void encode_commit(struct xdr_stream *xdr, const struct nfs_writeargs *ar
914{ 906{
915 __be32 *p; 907 __be32 *p;
916 908
917 RESERVE_SPACE(16); 909 p = reserve_space(xdr, 16);
918 *p++ = cpu_to_be32(OP_COMMIT); 910 *p++ = cpu_to_be32(OP_COMMIT);
919 p = xdr_encode_hyper(p, args->offset); 911 p = xdr_encode_hyper(p, args->offset);
920 *p++ = cpu_to_be32(args->count); 912 *p++ = cpu_to_be32(args->count);
@@ -926,19 +918,19 @@ static void encode_create(struct xdr_stream *xdr, const struct nfs4_create_arg *
926{ 918{
927 __be32 *p; 919 __be32 *p;
928 920
929 RESERVE_SPACE(8); 921 p = reserve_space(xdr, 8);
930 *p++ = cpu_to_be32(OP_CREATE); 922 *p++ = cpu_to_be32(OP_CREATE);
931 *p++ = cpu_to_be32(create->ftype); 923 *p++ = cpu_to_be32(create->ftype);
932 924
933 switch (create->ftype) { 925 switch (create->ftype) {
934 case NF4LNK: 926 case NF4LNK:
935 RESERVE_SPACE(4); 927 p = reserve_space(xdr, 4);
936 *p++ = cpu_to_be32(create->u.symlink.len); 928 *p++ = cpu_to_be32(create->u.symlink.len);
937 xdr_write_pages(xdr, create->u.symlink.pages, 0, create->u.symlink.len); 929 xdr_write_pages(xdr, create->u.symlink.pages, 0, create->u.symlink.len);
938 break; 930 break;
939 931
940 case NF4BLK: case NF4CHR: 932 case NF4BLK: case NF4CHR:
941 RESERVE_SPACE(8); 933 p = reserve_space(xdr, 8);
942 *p++ = cpu_to_be32(create->u.device.specdata1); 934 *p++ = cpu_to_be32(create->u.device.specdata1);
943 *p++ = cpu_to_be32(create->u.device.specdata2); 935 *p++ = cpu_to_be32(create->u.device.specdata2);
944 break; 936 break;
@@ -947,7 +939,7 @@ static void encode_create(struct xdr_stream *xdr, const struct nfs4_create_arg *
947 break; 939 break;
948 } 940 }
949 941
950 RESERVE_SPACE(4 + create->name->len); 942 p = reserve_space(xdr, 4 + create->name->len);
951 *p++ = cpu_to_be32(create->name->len); 943 *p++ = cpu_to_be32(create->name->len);
952 p = xdr_encode_opaque_fixed(p, create->name->name, create->name->len); 944 p = xdr_encode_opaque_fixed(p, create->name->name, create->name->len);
953 hdr->nops++; 945 hdr->nops++;
@@ -960,7 +952,7 @@ static void encode_getattr_one(struct xdr_stream *xdr, uint32_t bitmap, struct c
960{ 952{
961 __be32 *p; 953 __be32 *p;
962 954
963 RESERVE_SPACE(12); 955 p = reserve_space(xdr, 12);
964 *p++ = cpu_to_be32(OP_GETATTR); 956 *p++ = cpu_to_be32(OP_GETATTR);
965 *p++ = cpu_to_be32(1); 957 *p++ = cpu_to_be32(1);
966 *p++ = cpu_to_be32(bitmap); 958 *p++ = cpu_to_be32(bitmap);
@@ -972,7 +964,7 @@ static void encode_getattr_two(struct xdr_stream *xdr, uint32_t bm0, uint32_t bm
972{ 964{
973 __be32 *p; 965 __be32 *p;
974 966
975 RESERVE_SPACE(16); 967 p = reserve_space(xdr, 16);
976 *p++ = cpu_to_be32(OP_GETATTR); 968 *p++ = cpu_to_be32(OP_GETATTR);
977 *p++ = cpu_to_be32(2); 969 *p++ = cpu_to_be32(2);
978 *p++ = cpu_to_be32(bm0); 970 *p++ = cpu_to_be32(bm0);
@@ -1003,7 +995,7 @@ static void encode_getfh(struct xdr_stream *xdr, struct compound_hdr *hdr)
1003{ 995{
1004 __be32 *p; 996 __be32 *p;
1005 997
1006 RESERVE_SPACE(4); 998 p = reserve_space(xdr, 4);
1007 *p++ = cpu_to_be32(OP_GETFH); 999 *p++ = cpu_to_be32(OP_GETFH);
1008 hdr->nops++; 1000 hdr->nops++;
1009 hdr->replen += decode_getfh_maxsz; 1001 hdr->replen += decode_getfh_maxsz;
@@ -1013,7 +1005,7 @@ static void encode_link(struct xdr_stream *xdr, const struct qstr *name, struct
1013{ 1005{
1014 __be32 *p; 1006 __be32 *p;
1015 1007
1016 RESERVE_SPACE(8 + name->len); 1008 p = reserve_space(xdr, 8 + name->len);
1017 *p++ = cpu_to_be32(OP_LINK); 1009 *p++ = cpu_to_be32(OP_LINK);
1018 *p++ = cpu_to_be32(name->len); 1010 *p++ = cpu_to_be32(name->len);
1019 p = xdr_encode_opaque_fixed(p, name->name, name->len); 1011 p = xdr_encode_opaque_fixed(p, name->name, name->len);
@@ -1043,7 +1035,7 @@ static void encode_lock(struct xdr_stream *xdr, const struct nfs_lock_args *args
1043{ 1035{
1044 __be32 *p; 1036 __be32 *p;
1045 1037
1046 RESERVE_SPACE(32); 1038 p = reserve_space(xdr, 32);
1047 *p++ = cpu_to_be32(OP_LOCK); 1039 *p++ = cpu_to_be32(OP_LOCK);
1048 *p++ = cpu_to_be32(nfs4_lock_type(args->fl, args->block)); 1040 *p++ = cpu_to_be32(nfs4_lock_type(args->fl, args->block));
1049 *p++ = cpu_to_be32(args->reclaim); 1041 *p++ = cpu_to_be32(args->reclaim);
@@ -1051,7 +1043,7 @@ static void encode_lock(struct xdr_stream *xdr, const struct nfs_lock_args *args
1051 p = xdr_encode_hyper(p, nfs4_lock_length(args->fl)); 1043 p = xdr_encode_hyper(p, nfs4_lock_length(args->fl));
1052 *p++ = cpu_to_be32(args->new_lock_owner); 1044 *p++ = cpu_to_be32(args->new_lock_owner);
1053 if (args->new_lock_owner){ 1045 if (args->new_lock_owner){
1054 RESERVE_SPACE(4+NFS4_STATEID_SIZE+32); 1046 p = reserve_space(xdr, 4+NFS4_STATEID_SIZE+32);
1055 *p++ = cpu_to_be32(args->open_seqid->sequence->counter); 1047 *p++ = cpu_to_be32(args->open_seqid->sequence->counter);
1056 p = xdr_encode_opaque_fixed(p, args->open_stateid->data, NFS4_STATEID_SIZE); 1048 p = xdr_encode_opaque_fixed(p, args->open_stateid->data, NFS4_STATEID_SIZE);
1057 *p++ = cpu_to_be32(args->lock_seqid->sequence->counter); 1049 *p++ = cpu_to_be32(args->lock_seqid->sequence->counter);
@@ -1061,7 +1053,7 @@ static void encode_lock(struct xdr_stream *xdr, const struct nfs_lock_args *args
1061 p = xdr_encode_hyper(p, args->lock_owner.id); 1053 p = xdr_encode_hyper(p, args->lock_owner.id);
1062 } 1054 }
1063 else { 1055 else {
1064 RESERVE_SPACE(NFS4_STATEID_SIZE+4); 1056 p = reserve_space(xdr, NFS4_STATEID_SIZE+4);
1065 p = xdr_encode_opaque_fixed(p, args->lock_stateid->data, NFS4_STATEID_SIZE); 1057 p = xdr_encode_opaque_fixed(p, args->lock_stateid->data, NFS4_STATEID_SIZE);
1066 *p++ = cpu_to_be32(args->lock_seqid->sequence->counter); 1058 *p++ = cpu_to_be32(args->lock_seqid->sequence->counter);
1067 } 1059 }
@@ -1073,7 +1065,7 @@ static void encode_lockt(struct xdr_stream *xdr, const struct nfs_lockt_args *ar
1073{ 1065{
1074 __be32 *p; 1066 __be32 *p;
1075 1067
1076 RESERVE_SPACE(52); 1068 p = reserve_space(xdr, 52);
1077 *p++ = cpu_to_be32(OP_LOCKT); 1069 *p++ = cpu_to_be32(OP_LOCKT);
1078 *p++ = cpu_to_be32(nfs4_lock_type(args->fl, 0)); 1070 *p++ = cpu_to_be32(nfs4_lock_type(args->fl, 0));
1079 p = xdr_encode_hyper(p, args->fl->fl_start); 1071 p = xdr_encode_hyper(p, args->fl->fl_start);
@@ -1090,7 +1082,7 @@ static void encode_locku(struct xdr_stream *xdr, const struct nfs_locku_args *ar
1090{ 1082{
1091 __be32 *p; 1083 __be32 *p;
1092 1084
1093 RESERVE_SPACE(12+NFS4_STATEID_SIZE+16); 1085 p = reserve_space(xdr, 12+NFS4_STATEID_SIZE+16);
1094 *p++ = cpu_to_be32(OP_LOCKU); 1086 *p++ = cpu_to_be32(OP_LOCKU);
1095 *p++ = cpu_to_be32(nfs4_lock_type(args->fl, 0)); 1087 *p++ = cpu_to_be32(nfs4_lock_type(args->fl, 0));
1096 *p++ = cpu_to_be32(args->seqid->sequence->counter); 1088 *p++ = cpu_to_be32(args->seqid->sequence->counter);
@@ -1106,7 +1098,7 @@ static void encode_lookup(struct xdr_stream *xdr, const struct qstr *name, struc
1106 int len = name->len; 1098 int len = name->len;
1107 __be32 *p; 1099 __be32 *p;
1108 1100
1109 RESERVE_SPACE(8 + len); 1101 p = reserve_space(xdr, 8 + len);
1110 *p++ = cpu_to_be32(OP_LOOKUP); 1102 *p++ = cpu_to_be32(OP_LOOKUP);
1111 *p++ = cpu_to_be32(len); 1103 *p++ = cpu_to_be32(len);
1112 p = xdr_encode_opaque_fixed(p, name->name, len); 1104 p = xdr_encode_opaque_fixed(p, name->name, len);
@@ -1118,7 +1110,7 @@ static void encode_share_access(struct xdr_stream *xdr, fmode_t fmode)
1118{ 1110{
1119 __be32 *p; 1111 __be32 *p;
1120 1112
1121 RESERVE_SPACE(8); 1113 p = reserve_space(xdr, 8);
1122 switch (fmode & (FMODE_READ|FMODE_WRITE)) { 1114 switch (fmode & (FMODE_READ|FMODE_WRITE)) {
1123 case FMODE_READ: 1115 case FMODE_READ:
1124 *p++ = cpu_to_be32(NFS4_SHARE_ACCESS_READ); 1116 *p++ = cpu_to_be32(NFS4_SHARE_ACCESS_READ);
@@ -1142,11 +1134,11 @@ static inline void encode_openhdr(struct xdr_stream *xdr, const struct nfs_opena
1142 * opcode 4, seqid 4, share_access 4, share_deny 4, clientid 8, ownerlen 4, 1134 * opcode 4, seqid 4, share_access 4, share_deny 4, clientid 8, ownerlen 4,
1143 * owner 4 = 32 1135 * owner 4 = 32
1144 */ 1136 */
1145 RESERVE_SPACE(8); 1137 p = reserve_space(xdr, 8);
1146 *p++ = cpu_to_be32(OP_OPEN); 1138 *p++ = cpu_to_be32(OP_OPEN);
1147 *p++ = cpu_to_be32(arg->seqid->sequence->counter); 1139 *p++ = cpu_to_be32(arg->seqid->sequence->counter);
1148 encode_share_access(xdr, arg->fmode); 1140 encode_share_access(xdr, arg->fmode);
1149 RESERVE_SPACE(28); 1141 p = reserve_space(xdr, 28);
1150 p = xdr_encode_hyper(p, arg->clientid); 1142 p = xdr_encode_hyper(p, arg->clientid);
1151 *p++ = cpu_to_be32(16); 1143 *p++ = cpu_to_be32(16);
1152 p = xdr_encode_opaque_fixed(p, "open id:", 8); 1144 p = xdr_encode_opaque_fixed(p, "open id:", 8);
@@ -1157,7 +1149,7 @@ static inline void encode_createmode(struct xdr_stream *xdr, const struct nfs_op
1157{ 1149{
1158 __be32 *p; 1150 __be32 *p;
1159 1151
1160 RESERVE_SPACE(4); 1152 p = reserve_space(xdr, 4);
1161 switch(arg->open_flags & O_EXCL) { 1153 switch(arg->open_flags & O_EXCL) {
1162 case 0: 1154 case 0:
1163 *p++ = cpu_to_be32(NFS4_CREATE_UNCHECKED); 1155 *p++ = cpu_to_be32(NFS4_CREATE_UNCHECKED);
@@ -1173,7 +1165,7 @@ static void encode_opentype(struct xdr_stream *xdr, const struct nfs_openargs *a
1173{ 1165{
1174 __be32 *p; 1166 __be32 *p;
1175 1167
1176 RESERVE_SPACE(4); 1168 p = reserve_space(xdr, 4);
1177 switch (arg->open_flags & O_CREAT) { 1169 switch (arg->open_flags & O_CREAT) {
1178 case 0: 1170 case 0:
1179 *p++ = cpu_to_be32(NFS4_OPEN_NOCREATE); 1171 *p++ = cpu_to_be32(NFS4_OPEN_NOCREATE);
@@ -1189,7 +1181,7 @@ static inline void encode_delegation_type(struct xdr_stream *xdr, fmode_t delega
1189{ 1181{
1190 __be32 *p; 1182 __be32 *p;
1191 1183
1192 RESERVE_SPACE(4); 1184 p = reserve_space(xdr, 4);
1193 switch (delegation_type) { 1185 switch (delegation_type) {
1194 case 0: 1186 case 0:
1195 *p++ = cpu_to_be32(NFS4_OPEN_DELEGATE_NONE); 1187 *p++ = cpu_to_be32(NFS4_OPEN_DELEGATE_NONE);
@@ -1209,7 +1201,7 @@ static inline void encode_claim_null(struct xdr_stream *xdr, const struct qstr *
1209{ 1201{
1210 __be32 *p; 1202 __be32 *p;
1211 1203
1212 RESERVE_SPACE(4); 1204 p = reserve_space(xdr, 4);
1213 *p++ = cpu_to_be32(NFS4_OPEN_CLAIM_NULL); 1205 *p++ = cpu_to_be32(NFS4_OPEN_CLAIM_NULL);
1214 encode_string(xdr, name->len, name->name); 1206 encode_string(xdr, name->len, name->name);
1215} 1207}
@@ -1218,7 +1210,7 @@ static inline void encode_claim_previous(struct xdr_stream *xdr, fmode_t type)
1218{ 1210{
1219 __be32 *p; 1211 __be32 *p;
1220 1212
1221 RESERVE_SPACE(4); 1213 p = reserve_space(xdr, 4);
1222 *p++ = cpu_to_be32(NFS4_OPEN_CLAIM_PREVIOUS); 1214 *p++ = cpu_to_be32(NFS4_OPEN_CLAIM_PREVIOUS);
1223 encode_delegation_type(xdr, type); 1215 encode_delegation_type(xdr, type);
1224} 1216}
@@ -1227,7 +1219,7 @@ static inline void encode_claim_delegate_cur(struct xdr_stream *xdr, const struc
1227{ 1219{
1228 __be32 *p; 1220 __be32 *p;
1229 1221
1230 RESERVE_SPACE(4+NFS4_STATEID_SIZE); 1222 p = reserve_space(xdr, 4+NFS4_STATEID_SIZE);
1231 *p++ = cpu_to_be32(NFS4_OPEN_CLAIM_DELEGATE_CUR); 1223 *p++ = cpu_to_be32(NFS4_OPEN_CLAIM_DELEGATE_CUR);
1232 p = xdr_encode_opaque_fixed(p, stateid->data, NFS4_STATEID_SIZE); 1224 p = xdr_encode_opaque_fixed(p, stateid->data, NFS4_STATEID_SIZE);
1233 encode_string(xdr, name->len, name->name); 1225 encode_string(xdr, name->len, name->name);
@@ -1258,7 +1250,7 @@ static void encode_open_confirm(struct xdr_stream *xdr, const struct nfs_open_co
1258{ 1250{
1259 __be32 *p; 1251 __be32 *p;
1260 1252
1261 RESERVE_SPACE(4+NFS4_STATEID_SIZE+4); 1253 p = reserve_space(xdr, 4+NFS4_STATEID_SIZE+4);
1262 *p++ = cpu_to_be32(OP_OPEN_CONFIRM); 1254 *p++ = cpu_to_be32(OP_OPEN_CONFIRM);
1263 p = xdr_encode_opaque_fixed(p, arg->stateid->data, NFS4_STATEID_SIZE); 1255 p = xdr_encode_opaque_fixed(p, arg->stateid->data, NFS4_STATEID_SIZE);
1264 *p++ = cpu_to_be32(arg->seqid->sequence->counter); 1256 *p++ = cpu_to_be32(arg->seqid->sequence->counter);
@@ -1270,7 +1262,7 @@ static void encode_open_downgrade(struct xdr_stream *xdr, const struct nfs_close
1270{ 1262{
1271 __be32 *p; 1263 __be32 *p;
1272 1264
1273 RESERVE_SPACE(4+NFS4_STATEID_SIZE+4); 1265 p = reserve_space(xdr, 4+NFS4_STATEID_SIZE+4);
1274 *p++ = cpu_to_be32(OP_OPEN_DOWNGRADE); 1266 *p++ = cpu_to_be32(OP_OPEN_DOWNGRADE);
1275 p = xdr_encode_opaque_fixed(p, arg->stateid->data, NFS4_STATEID_SIZE); 1267 p = xdr_encode_opaque_fixed(p, arg->stateid->data, NFS4_STATEID_SIZE);
1276 *p++ = cpu_to_be32(arg->seqid->sequence->counter); 1268 *p++ = cpu_to_be32(arg->seqid->sequence->counter);
@@ -1285,7 +1277,7 @@ encode_putfh(struct xdr_stream *xdr, const struct nfs_fh *fh, struct compound_hd
1285 int len = fh->size; 1277 int len = fh->size;
1286 __be32 *p; 1278 __be32 *p;
1287 1279
1288 RESERVE_SPACE(8 + len); 1280 p = reserve_space(xdr, 8 + len);
1289 *p++ = cpu_to_be32(OP_PUTFH); 1281 *p++ = cpu_to_be32(OP_PUTFH);
1290 *p++ = cpu_to_be32(len); 1282 *p++ = cpu_to_be32(len);
1291 p = xdr_encode_opaque_fixed(p, fh->data, len); 1283 p = xdr_encode_opaque_fixed(p, fh->data, len);
@@ -1297,7 +1289,7 @@ static void encode_putrootfh(struct xdr_stream *xdr, struct compound_hdr *hdr)
1297{ 1289{
1298 __be32 *p; 1290 __be32 *p;
1299 1291
1300 RESERVE_SPACE(4); 1292 p = reserve_space(xdr, 4);
1301 *p++ = cpu_to_be32(OP_PUTROOTFH); 1293 *p++ = cpu_to_be32(OP_PUTROOTFH);
1302 hdr->nops++; 1294 hdr->nops++;
1303 hdr->replen += decode_putrootfh_maxsz; 1295 hdr->replen += decode_putrootfh_maxsz;
@@ -1308,7 +1300,7 @@ static void encode_stateid(struct xdr_stream *xdr, const struct nfs_open_context
1308 nfs4_stateid stateid; 1300 nfs4_stateid stateid;
1309 __be32 *p; 1301 __be32 *p;
1310 1302
1311 RESERVE_SPACE(NFS4_STATEID_SIZE); 1303 p = reserve_space(xdr, NFS4_STATEID_SIZE);
1312 if (ctx->state != NULL) { 1304 if (ctx->state != NULL) {
1313 nfs4_copy_stateid(&stateid, ctx->state, ctx->lockowner); 1305 nfs4_copy_stateid(&stateid, ctx->state, ctx->lockowner);
1314 p = xdr_encode_opaque_fixed(p, stateid.data, NFS4_STATEID_SIZE); 1306 p = xdr_encode_opaque_fixed(p, stateid.data, NFS4_STATEID_SIZE);
@@ -1320,12 +1312,12 @@ static void encode_read(struct xdr_stream *xdr, const struct nfs_readargs *args,
1320{ 1312{
1321 __be32 *p; 1313 __be32 *p;
1322 1314
1323 RESERVE_SPACE(4); 1315 p = reserve_space(xdr, 4);
1324 *p++ = cpu_to_be32(OP_READ); 1316 *p++ = cpu_to_be32(OP_READ);
1325 1317
1326 encode_stateid(xdr, args->context); 1318 encode_stateid(xdr, args->context);
1327 1319
1328 RESERVE_SPACE(12); 1320 p = reserve_space(xdr, 12);
1329 p = xdr_encode_hyper(p, args->offset); 1321 p = xdr_encode_hyper(p, args->offset);
1330 *p++ = cpu_to_be32(args->count); 1322 *p++ = cpu_to_be32(args->count);
1331 hdr->nops++; 1323 hdr->nops++;
@@ -1340,7 +1332,7 @@ static void encode_readdir(struct xdr_stream *xdr, const struct nfs4_readdir_arg
1340 }; 1332 };
1341 __be32 *p; 1333 __be32 *p;
1342 1334
1343 RESERVE_SPACE(12+NFS4_VERIFIER_SIZE+20); 1335 p = reserve_space(xdr, 12+NFS4_VERIFIER_SIZE+20);
1344 *p++ = cpu_to_be32(OP_READDIR); 1336 *p++ = cpu_to_be32(OP_READDIR);
1345 p = xdr_encode_hyper(p, readdir->cookie); 1337 p = xdr_encode_hyper(p, readdir->cookie);
1346 p = xdr_encode_opaque_fixed(p, readdir->verifier.data, NFS4_VERIFIER_SIZE); 1338 p = xdr_encode_opaque_fixed(p, readdir->verifier.data, NFS4_VERIFIER_SIZE);
@@ -1369,7 +1361,7 @@ static void encode_readlink(struct xdr_stream *xdr, const struct nfs4_readlink *
1369{ 1361{
1370 __be32 *p; 1362 __be32 *p;
1371 1363
1372 RESERVE_SPACE(4); 1364 p = reserve_space(xdr, 4);
1373 *p++ = cpu_to_be32(OP_READLINK); 1365 *p++ = cpu_to_be32(OP_READLINK);
1374 hdr->nops++; 1366 hdr->nops++;
1375 hdr->replen += decode_readlink_maxsz; 1367 hdr->replen += decode_readlink_maxsz;
@@ -1379,7 +1371,7 @@ static void encode_remove(struct xdr_stream *xdr, const struct qstr *name, struc
1379{ 1371{
1380 __be32 *p; 1372 __be32 *p;
1381 1373
1382 RESERVE_SPACE(8 + name->len); 1374 p = reserve_space(xdr, 8 + name->len);
1383 *p++ = cpu_to_be32(OP_REMOVE); 1375 *p++ = cpu_to_be32(OP_REMOVE);
1384 *p++ = cpu_to_be32(name->len); 1376 *p++ = cpu_to_be32(name->len);
1385 p = xdr_encode_opaque_fixed(p, name->name, name->len); 1377 p = xdr_encode_opaque_fixed(p, name->name, name->len);
@@ -1391,12 +1383,12 @@ static void encode_rename(struct xdr_stream *xdr, const struct qstr *oldname, co
1391{ 1383{
1392 __be32 *p; 1384 __be32 *p;
1393 1385
1394 RESERVE_SPACE(8 + oldname->len); 1386 p = reserve_space(xdr, 8 + oldname->len);
1395 *p++ = cpu_to_be32(OP_RENAME); 1387 *p++ = cpu_to_be32(OP_RENAME);
1396 *p++ = cpu_to_be32(oldname->len); 1388 *p++ = cpu_to_be32(oldname->len);
1397 p = xdr_encode_opaque_fixed(p, oldname->name, oldname->len); 1389 p = xdr_encode_opaque_fixed(p, oldname->name, oldname->len);
1398 1390
1399 RESERVE_SPACE(4 + newname->len); 1391 p = reserve_space(xdr, 4 + newname->len);
1400 *p++ = cpu_to_be32(newname->len); 1392 *p++ = cpu_to_be32(newname->len);
1401 p = xdr_encode_opaque_fixed(p, newname->name, newname->len); 1393 p = xdr_encode_opaque_fixed(p, newname->name, newname->len);
1402 hdr->nops++; 1394 hdr->nops++;
@@ -1407,7 +1399,7 @@ static void encode_renew(struct xdr_stream *xdr, const struct nfs_client *client
1407{ 1399{
1408 __be32 *p; 1400 __be32 *p;
1409 1401
1410 RESERVE_SPACE(12); 1402 p = reserve_space(xdr, 12);
1411 *p++ = cpu_to_be32(OP_RENEW); 1403 *p++ = cpu_to_be32(OP_RENEW);
1412 p = xdr_encode_hyper(p, client_stateid->cl_clientid); 1404 p = xdr_encode_hyper(p, client_stateid->cl_clientid);
1413 hdr->nops++; 1405 hdr->nops++;
@@ -1419,7 +1411,7 @@ encode_restorefh(struct xdr_stream *xdr, struct compound_hdr *hdr)
1419{ 1411{
1420 __be32 *p; 1412 __be32 *p;
1421 1413
1422 RESERVE_SPACE(4); 1414 p = reserve_space(xdr, 4);
1423 *p++ = cpu_to_be32(OP_RESTOREFH); 1415 *p++ = cpu_to_be32(OP_RESTOREFH);
1424 hdr->nops++; 1416 hdr->nops++;
1425 hdr->replen += decode_restorefh_maxsz; 1417 hdr->replen += decode_restorefh_maxsz;
@@ -1430,15 +1422,15 @@ encode_setacl(struct xdr_stream *xdr, struct nfs_setaclargs *arg, struct compoun
1430{ 1422{
1431 __be32 *p; 1423 __be32 *p;
1432 1424
1433 RESERVE_SPACE(4+NFS4_STATEID_SIZE); 1425 p = reserve_space(xdr, 4+NFS4_STATEID_SIZE);
1434 *p++ = cpu_to_be32(OP_SETATTR); 1426 *p++ = cpu_to_be32(OP_SETATTR);
1435 p = xdr_encode_opaque_fixed(p, zero_stateid.data, NFS4_STATEID_SIZE); 1427 p = xdr_encode_opaque_fixed(p, zero_stateid.data, NFS4_STATEID_SIZE);
1436 RESERVE_SPACE(2*4); 1428 p = reserve_space(xdr, 2*4);
1437 *p++ = cpu_to_be32(1); 1429 *p++ = cpu_to_be32(1);
1438 *p++ = cpu_to_be32(FATTR4_WORD0_ACL); 1430 *p++ = cpu_to_be32(FATTR4_WORD0_ACL);
1439 if (arg->acl_len % 4) 1431 if (arg->acl_len % 4)
1440 return -EINVAL; 1432 return -EINVAL;
1441 RESERVE_SPACE(4); 1433 p = reserve_space(xdr, 4);
1442 *p++ = cpu_to_be32(arg->acl_len); 1434 *p++ = cpu_to_be32(arg->acl_len);
1443 xdr_write_pages(xdr, arg->acl_pages, arg->acl_pgbase, arg->acl_len); 1435 xdr_write_pages(xdr, arg->acl_pages, arg->acl_pgbase, arg->acl_len);
1444 hdr->nops++; 1436 hdr->nops++;
@@ -1451,7 +1443,7 @@ encode_savefh(struct xdr_stream *xdr, struct compound_hdr *hdr)
1451{ 1443{
1452 __be32 *p; 1444 __be32 *p;
1453 1445
1454 RESERVE_SPACE(4); 1446 p = reserve_space(xdr, 4);
1455 *p++ = cpu_to_be32(OP_SAVEFH); 1447 *p++ = cpu_to_be32(OP_SAVEFH);
1456 hdr->nops++; 1448 hdr->nops++;
1457 hdr->replen += decode_savefh_maxsz; 1449 hdr->replen += decode_savefh_maxsz;
@@ -1461,7 +1453,7 @@ static void encode_setattr(struct xdr_stream *xdr, const struct nfs_setattrargs
1461{ 1453{
1462 __be32 *p; 1454 __be32 *p;
1463 1455
1464 RESERVE_SPACE(4+NFS4_STATEID_SIZE); 1456 p = reserve_space(xdr, 4+NFS4_STATEID_SIZE);
1465 *p++ = cpu_to_be32(OP_SETATTR); 1457 *p++ = cpu_to_be32(OP_SETATTR);
1466 p = xdr_encode_opaque_fixed(p, arg->stateid.data, NFS4_STATEID_SIZE); 1458 p = xdr_encode_opaque_fixed(p, arg->stateid.data, NFS4_STATEID_SIZE);
1467 hdr->nops++; 1459 hdr->nops++;
@@ -1473,16 +1465,16 @@ static void encode_setclientid(struct xdr_stream *xdr, const struct nfs4_setclie
1473{ 1465{
1474 __be32 *p; 1466 __be32 *p;
1475 1467
1476 RESERVE_SPACE(4 + NFS4_VERIFIER_SIZE); 1468 p = reserve_space(xdr, 4 + NFS4_VERIFIER_SIZE);
1477 *p++ = cpu_to_be32(OP_SETCLIENTID); 1469 *p++ = cpu_to_be32(OP_SETCLIENTID);
1478 p = xdr_encode_opaque_fixed(p, setclientid->sc_verifier->data, NFS4_VERIFIER_SIZE); 1470 p = xdr_encode_opaque_fixed(p, setclientid->sc_verifier->data, NFS4_VERIFIER_SIZE);
1479 1471
1480 encode_string(xdr, setclientid->sc_name_len, setclientid->sc_name); 1472 encode_string(xdr, setclientid->sc_name_len, setclientid->sc_name);
1481 RESERVE_SPACE(4); 1473 p = reserve_space(xdr, 4);
1482 *p++ = cpu_to_be32(setclientid->sc_prog); 1474 *p++ = cpu_to_be32(setclientid->sc_prog);
1483 encode_string(xdr, setclientid->sc_netid_len, setclientid->sc_netid); 1475 encode_string(xdr, setclientid->sc_netid_len, setclientid->sc_netid);
1484 encode_string(xdr, setclientid->sc_uaddr_len, setclientid->sc_uaddr); 1476 encode_string(xdr, setclientid->sc_uaddr_len, setclientid->sc_uaddr);
1485 RESERVE_SPACE(4); 1477 p = reserve_space(xdr, 4);
1486 *p++ = cpu_to_be32(setclientid->sc_cb_ident); 1478 *p++ = cpu_to_be32(setclientid->sc_cb_ident);
1487 hdr->nops++; 1479 hdr->nops++;
1488 hdr->replen += decode_setclientid_maxsz; 1480 hdr->replen += decode_setclientid_maxsz;
@@ -1492,7 +1484,7 @@ static void encode_setclientid_confirm(struct xdr_stream *xdr, const struct nfs_
1492{ 1484{
1493 __be32 *p; 1485 __be32 *p;
1494 1486
1495 RESERVE_SPACE(12 + NFS4_VERIFIER_SIZE); 1487 p = reserve_space(xdr, 12 + NFS4_VERIFIER_SIZE);
1496 *p++ = cpu_to_be32(OP_SETCLIENTID_CONFIRM); 1488 *p++ = cpu_to_be32(OP_SETCLIENTID_CONFIRM);
1497 p = xdr_encode_hyper(p, client_state->cl_clientid); 1489 p = xdr_encode_hyper(p, client_state->cl_clientid);
1498 p = xdr_encode_opaque_fixed(p, client_state->cl_confirm.data, NFS4_VERIFIER_SIZE); 1490 p = xdr_encode_opaque_fixed(p, client_state->cl_confirm.data, NFS4_VERIFIER_SIZE);
@@ -1504,12 +1496,12 @@ static void encode_write(struct xdr_stream *xdr, const struct nfs_writeargs *arg
1504{ 1496{
1505 __be32 *p; 1497 __be32 *p;
1506 1498
1507 RESERVE_SPACE(4); 1499 p = reserve_space(xdr, 4);
1508 *p++ = cpu_to_be32(OP_WRITE); 1500 *p++ = cpu_to_be32(OP_WRITE);
1509 1501
1510 encode_stateid(xdr, args->context); 1502 encode_stateid(xdr, args->context);
1511 1503
1512 RESERVE_SPACE(16); 1504 p = reserve_space(xdr, 16);
1513 p = xdr_encode_hyper(p, args->offset); 1505 p = xdr_encode_hyper(p, args->offset);
1514 *p++ = cpu_to_be32(args->stable); 1506 *p++ = cpu_to_be32(args->stable);
1515 *p++ = cpu_to_be32(args->count); 1507 *p++ = cpu_to_be32(args->count);
@@ -1523,7 +1515,7 @@ static void encode_delegreturn(struct xdr_stream *xdr, const nfs4_stateid *state
1523{ 1515{
1524 __be32 *p; 1516 __be32 *p;
1525 1517
1526 RESERVE_SPACE(4+NFS4_STATEID_SIZE); 1518 p = reserve_space(xdr, 4+NFS4_STATEID_SIZE);
1527 1519
1528 *p++ = cpu_to_be32(OP_DELEGRETURN); 1520 *p++ = cpu_to_be32(OP_DELEGRETURN);
1529 p = xdr_encode_opaque_fixed(p, stateid->data, NFS4_STATEID_SIZE); 1521 p = xdr_encode_opaque_fixed(p, stateid->data, NFS4_STATEID_SIZE);
@@ -1539,13 +1531,13 @@ static void encode_exchange_id(struct xdr_stream *xdr,
1539{ 1531{
1540 __be32 *p; 1532 __be32 *p;
1541 1533
1542 RESERVE_SPACE(4 + sizeof(args->verifier->data)); 1534 p = reserve_space(xdr, 4 + sizeof(args->verifier->data));
1543 *p++ = cpu_to_be32(OP_EXCHANGE_ID); 1535 *p++ = cpu_to_be32(OP_EXCHANGE_ID);
1544 p = xdr_encode_opaque_fixed(p, args->verifier->data, sizeof(args->verifier->data)); 1536 p = xdr_encode_opaque_fixed(p, args->verifier->data, sizeof(args->verifier->data));
1545 1537
1546 encode_string(xdr, args->id_len, args->id); 1538 encode_string(xdr, args->id_len, args->id);
1547 1539
1548 RESERVE_SPACE(12); 1540 p = reserve_space(xdr, 12);
1549 *p++ = cpu_to_be32(args->flags); 1541 *p++ = cpu_to_be32(args->flags);
1550 *p++ = cpu_to_be32(0); /* zero length state_protect4_a */ 1542 *p++ = cpu_to_be32(0); /* zero length state_protect4_a */
1551 *p++ = cpu_to_be32(0); /* zero length implementation id array */ 1543 *p++ = cpu_to_be32(0); /* zero length implementation id array */
@@ -1565,7 +1557,7 @@ static void encode_create_session(struct xdr_stream *xdr,
1565 len = scnprintf(machine_name, sizeof(machine_name), "%s", 1557 len = scnprintf(machine_name, sizeof(machine_name), "%s",
1566 clp->cl_ipaddr); 1558 clp->cl_ipaddr);
1567 1559
1568 RESERVE_SPACE(20 + 2*28 + 20 + len + 12); 1560 p = reserve_space(xdr, 20 + 2*28 + 20 + len + 12);
1569 *p++ = cpu_to_be32(OP_CREATE_SESSION); 1561 *p++ = cpu_to_be32(OP_CREATE_SESSION);
1570 p = xdr_encode_hyper(p, clp->cl_ex_clid); 1562 p = xdr_encode_hyper(p, clp->cl_ex_clid);
1571 *p++ = cpu_to_be32(clp->cl_seqid); /*Sequence id */ 1563 *p++ = cpu_to_be32(clp->cl_seqid); /*Sequence id */
@@ -1609,7 +1601,7 @@ static void encode_destroy_session(struct xdr_stream *xdr,
1609 struct compound_hdr *hdr) 1601 struct compound_hdr *hdr)
1610{ 1602{
1611 __be32 *p; 1603 __be32 *p;
1612 RESERVE_SPACE(4 + NFS4_MAX_SESSIONID_LEN); 1604 p = reserve_space(xdr, 4 + NFS4_MAX_SESSIONID_LEN);
1613 *p++ = cpu_to_be32(OP_DESTROY_SESSION); 1605 *p++ = cpu_to_be32(OP_DESTROY_SESSION);
1614 p = xdr_encode_opaque_fixed(p, session->sess_id.data, NFS4_MAX_SESSIONID_LEN); 1606 p = xdr_encode_opaque_fixed(p, session->sess_id.data, NFS4_MAX_SESSIONID_LEN);
1615 hdr->nops++; 1607 hdr->nops++;
@@ -1635,7 +1627,7 @@ static void encode_sequence(struct xdr_stream *xdr,
1635 WARN_ON(args->sa_slotid == NFS4_MAX_SLOT_TABLE); 1627 WARN_ON(args->sa_slotid == NFS4_MAX_SLOT_TABLE);
1636 slot = tp->slots + args->sa_slotid; 1628 slot = tp->slots + args->sa_slotid;
1637 1629
1638 RESERVE_SPACE(4 + NFS4_MAX_SESSIONID_LEN + 16); 1630 p = reserve_space(xdr, 4 + NFS4_MAX_SESSIONID_LEN + 16);
1639 *p++ = cpu_to_be32(OP_SEQUENCE); 1631 *p++ = cpu_to_be32(OP_SEQUENCE);
1640 1632
1641 /* 1633 /*