diff options
Diffstat (limited to 'fs/nfs/nfs4xdr.c')
-rw-r--r-- | fs/nfs/nfs4xdr.c | 2493 |
1 files changed, 1610 insertions, 883 deletions
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c index 08ef91291132..e6e8f3b9a1de 100644 --- a/fs/nfs/nfs4xdr.c +++ b/fs/nfs/nfs4xdr.c | |||
@@ -46,12 +46,14 @@ | |||
46 | #include <linux/kdev_t.h> | 46 | #include <linux/kdev_t.h> |
47 | #include <linux/sunrpc/clnt.h> | 47 | #include <linux/sunrpc/clnt.h> |
48 | #include <linux/sunrpc/msg_prot.h> | 48 | #include <linux/sunrpc/msg_prot.h> |
49 | #include <linux/sunrpc/gss_api.h> | ||
49 | #include <linux/nfs.h> | 50 | #include <linux/nfs.h> |
50 | #include <linux/nfs4.h> | 51 | #include <linux/nfs4.h> |
51 | #include <linux/nfs_fs.h> | 52 | #include <linux/nfs_fs.h> |
52 | #include <linux/nfs_idmap.h> | 53 | #include <linux/nfs_idmap.h> |
53 | #include "nfs4_fs.h" | 54 | #include "nfs4_fs.h" |
54 | #include "internal.h" | 55 | #include "internal.h" |
56 | #include "pnfs.h" | ||
55 | 57 | ||
56 | #define NFSDBG_FACILITY NFSDBG_XDR | 58 | #define NFSDBG_FACILITY NFSDBG_XDR |
57 | 59 | ||
@@ -70,8 +72,8 @@ static int nfs4_stat_to_errno(int); | |||
70 | /* lock,open owner id: | 72 | /* lock,open owner id: |
71 | * we currently use size 2 (u64) out of (NFS4_OPAQUE_LIMIT >> 2) | 73 | * we currently use size 2 (u64) out of (NFS4_OPAQUE_LIMIT >> 2) |
72 | */ | 74 | */ |
73 | #define open_owner_id_maxsz (1 + 4) | 75 | #define open_owner_id_maxsz (1 + 1 + 4) |
74 | #define lock_owner_id_maxsz (1 + 4) | 76 | #define lock_owner_id_maxsz (1 + 1 + 4) |
75 | #define decode_lockowner_maxsz (1 + XDR_QUADLEN(IDMAP_NAMESZ)) | 77 | #define decode_lockowner_maxsz (1 + XDR_QUADLEN(IDMAP_NAMESZ)) |
76 | #define compound_encode_hdr_maxsz (3 + (NFS4_MAXTAGLEN >> 2)) | 78 | #define compound_encode_hdr_maxsz (3 + (NFS4_MAXTAGLEN >> 2)) |
77 | #define compound_decode_hdr_maxsz (3 + (NFS4_MAXTAGLEN >> 2)) | 79 | #define compound_decode_hdr_maxsz (3 + (NFS4_MAXTAGLEN >> 2)) |
@@ -89,7 +91,7 @@ static int nfs4_stat_to_errno(int); | |||
89 | #define encode_getfh_maxsz (op_encode_hdr_maxsz) | 91 | #define encode_getfh_maxsz (op_encode_hdr_maxsz) |
90 | #define decode_getfh_maxsz (op_decode_hdr_maxsz + 1 + \ | 92 | #define decode_getfh_maxsz (op_decode_hdr_maxsz + 1 + \ |
91 | ((3+NFS4_FHSIZE) >> 2)) | 93 | ((3+NFS4_FHSIZE) >> 2)) |
92 | #define nfs4_fattr_bitmap_maxsz 3 | 94 | #define nfs4_fattr_bitmap_maxsz 4 |
93 | #define encode_getattr_maxsz (op_encode_hdr_maxsz + nfs4_fattr_bitmap_maxsz) | 95 | #define encode_getattr_maxsz (op_encode_hdr_maxsz + nfs4_fattr_bitmap_maxsz) |
94 | #define nfs4_name_maxsz (1 + ((3 + NFS4_MAXNAMLEN) >> 2)) | 96 | #define nfs4_name_maxsz (1 + ((3 + NFS4_MAXNAMLEN) >> 2)) |
95 | #define nfs4_path_maxsz (1 + ((3 + NFS4_MAXPATHLEN) >> 2)) | 97 | #define nfs4_path_maxsz (1 + ((3 + NFS4_MAXPATHLEN) >> 2)) |
@@ -111,7 +113,7 @@ static int nfs4_stat_to_errno(int); | |||
111 | #define encode_restorefh_maxsz (op_encode_hdr_maxsz) | 113 | #define encode_restorefh_maxsz (op_encode_hdr_maxsz) |
112 | #define decode_restorefh_maxsz (op_decode_hdr_maxsz) | 114 | #define decode_restorefh_maxsz (op_decode_hdr_maxsz) |
113 | #define encode_fsinfo_maxsz (encode_getattr_maxsz) | 115 | #define encode_fsinfo_maxsz (encode_getattr_maxsz) |
114 | #define decode_fsinfo_maxsz (op_decode_hdr_maxsz + 11) | 116 | #define decode_fsinfo_maxsz (op_decode_hdr_maxsz + 15) |
115 | #define encode_renew_maxsz (op_encode_hdr_maxsz + 3) | 117 | #define encode_renew_maxsz (op_encode_hdr_maxsz + 3) |
116 | #define decode_renew_maxsz (op_decode_hdr_maxsz) | 118 | #define decode_renew_maxsz (op_decode_hdr_maxsz) |
117 | #define encode_setclientid_maxsz \ | 119 | #define encode_setclientid_maxsz \ |
@@ -252,6 +254,8 @@ static int nfs4_stat_to_errno(int); | |||
252 | (encode_getattr_maxsz) | 254 | (encode_getattr_maxsz) |
253 | #define decode_fs_locations_maxsz \ | 255 | #define decode_fs_locations_maxsz \ |
254 | (0) | 256 | (0) |
257 | #define encode_secinfo_maxsz (op_encode_hdr_maxsz + nfs4_name_maxsz) | ||
258 | #define decode_secinfo_maxsz (op_decode_hdr_maxsz + 1 + ((NFS_MAX_SECFLAVORS * (16 + GSS_OID_MAX_LEN)) / 4)) | ||
255 | 259 | ||
256 | #if defined(CONFIG_NFS_V4_1) | 260 | #if defined(CONFIG_NFS_V4_1) |
257 | #define NFS4_MAX_MACHINE_NAME_LEN (64) | 261 | #define NFS4_MAX_MACHINE_NAME_LEN (64) |
@@ -310,6 +314,35 @@ static int nfs4_stat_to_errno(int); | |||
310 | XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + 5) | 314 | XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + 5) |
311 | #define encode_reclaim_complete_maxsz (op_encode_hdr_maxsz + 4) | 315 | #define encode_reclaim_complete_maxsz (op_encode_hdr_maxsz + 4) |
312 | #define decode_reclaim_complete_maxsz (op_decode_hdr_maxsz + 4) | 316 | #define decode_reclaim_complete_maxsz (op_decode_hdr_maxsz + 4) |
317 | #define encode_getdeviceinfo_maxsz (op_encode_hdr_maxsz + 4 + \ | ||
318 | XDR_QUADLEN(NFS4_DEVICEID4_SIZE)) | ||
319 | #define decode_getdeviceinfo_maxsz (op_decode_hdr_maxsz + \ | ||
320 | 1 /* layout type */ + \ | ||
321 | 1 /* opaque devaddr4 length */ + \ | ||
322 | /* devaddr4 payload is read into page */ \ | ||
323 | 1 /* notification bitmap length */ + \ | ||
324 | 1 /* notification bitmap */) | ||
325 | #define encode_layoutget_maxsz (op_encode_hdr_maxsz + 10 + \ | ||
326 | encode_stateid_maxsz) | ||
327 | #define decode_layoutget_maxsz (op_decode_hdr_maxsz + 8 + \ | ||
328 | decode_stateid_maxsz + \ | ||
329 | XDR_QUADLEN(PNFS_LAYOUT_MAXSIZE)) | ||
330 | #define encode_layoutcommit_maxsz (op_encode_hdr_maxsz + \ | ||
331 | 2 /* offset */ + \ | ||
332 | 2 /* length */ + \ | ||
333 | 1 /* reclaim */ + \ | ||
334 | encode_stateid_maxsz + \ | ||
335 | 1 /* new offset (true) */ + \ | ||
336 | 2 /* last byte written */ + \ | ||
337 | 1 /* nt_timechanged (false) */ + \ | ||
338 | 1 /* layoutupdate4 layout type */ + \ | ||
339 | 1 /* NULL filelayout layoutupdate4 payload */) | ||
340 | #define decode_layoutcommit_maxsz (op_decode_hdr_maxsz + 3) | ||
341 | #define encode_layoutreturn_maxsz (8 + op_encode_hdr_maxsz + \ | ||
342 | encode_stateid_maxsz + \ | ||
343 | 1 /* FIXME: opaque lrf_body always empty at the moment */) | ||
344 | #define decode_layoutreturn_maxsz (op_decode_hdr_maxsz + \ | ||
345 | 1 + decode_stateid_maxsz) | ||
313 | #else /* CONFIG_NFS_V4_1 */ | 346 | #else /* CONFIG_NFS_V4_1 */ |
314 | #define encode_sequence_maxsz 0 | 347 | #define encode_sequence_maxsz 0 |
315 | #define decode_sequence_maxsz 0 | 348 | #define decode_sequence_maxsz 0 |
@@ -662,6 +695,14 @@ static int nfs4_stat_to_errno(int); | |||
662 | decode_putfh_maxsz + \ | 695 | decode_putfh_maxsz + \ |
663 | decode_lookup_maxsz + \ | 696 | decode_lookup_maxsz + \ |
664 | decode_fs_locations_maxsz) | 697 | decode_fs_locations_maxsz) |
698 | #define NFS4_enc_secinfo_sz (compound_encode_hdr_maxsz + \ | ||
699 | encode_sequence_maxsz + \ | ||
700 | encode_putfh_maxsz + \ | ||
701 | encode_secinfo_maxsz) | ||
702 | #define NFS4_dec_secinfo_sz (compound_decode_hdr_maxsz + \ | ||
703 | decode_sequence_maxsz + \ | ||
704 | decode_putfh_maxsz + \ | ||
705 | decode_secinfo_maxsz) | ||
665 | #if defined(CONFIG_NFS_V4_1) | 706 | #if defined(CONFIG_NFS_V4_1) |
666 | #define NFS4_enc_exchange_id_sz \ | 707 | #define NFS4_enc_exchange_id_sz \ |
667 | (compound_encode_hdr_maxsz + \ | 708 | (compound_encode_hdr_maxsz + \ |
@@ -699,6 +740,38 @@ static int nfs4_stat_to_errno(int); | |||
699 | #define NFS4_dec_reclaim_complete_sz (compound_decode_hdr_maxsz + \ | 740 | #define NFS4_dec_reclaim_complete_sz (compound_decode_hdr_maxsz + \ |
700 | decode_sequence_maxsz + \ | 741 | decode_sequence_maxsz + \ |
701 | decode_reclaim_complete_maxsz) | 742 | decode_reclaim_complete_maxsz) |
743 | #define NFS4_enc_getdeviceinfo_sz (compound_encode_hdr_maxsz + \ | ||
744 | encode_sequence_maxsz +\ | ||
745 | encode_getdeviceinfo_maxsz) | ||
746 | #define NFS4_dec_getdeviceinfo_sz (compound_decode_hdr_maxsz + \ | ||
747 | decode_sequence_maxsz + \ | ||
748 | decode_getdeviceinfo_maxsz) | ||
749 | #define NFS4_enc_layoutget_sz (compound_encode_hdr_maxsz + \ | ||
750 | encode_sequence_maxsz + \ | ||
751 | encode_putfh_maxsz + \ | ||
752 | encode_layoutget_maxsz) | ||
753 | #define NFS4_dec_layoutget_sz (compound_decode_hdr_maxsz + \ | ||
754 | decode_sequence_maxsz + \ | ||
755 | decode_putfh_maxsz + \ | ||
756 | decode_layoutget_maxsz) | ||
757 | #define NFS4_enc_layoutcommit_sz (compound_encode_hdr_maxsz + \ | ||
758 | encode_sequence_maxsz +\ | ||
759 | encode_putfh_maxsz + \ | ||
760 | encode_layoutcommit_maxsz + \ | ||
761 | encode_getattr_maxsz) | ||
762 | #define NFS4_dec_layoutcommit_sz (compound_decode_hdr_maxsz + \ | ||
763 | decode_sequence_maxsz + \ | ||
764 | decode_putfh_maxsz + \ | ||
765 | decode_layoutcommit_maxsz + \ | ||
766 | decode_getattr_maxsz) | ||
767 | #define NFS4_enc_layoutreturn_sz (compound_encode_hdr_maxsz + \ | ||
768 | encode_sequence_maxsz + \ | ||
769 | encode_putfh_maxsz + \ | ||
770 | encode_layoutreturn_maxsz) | ||
771 | #define NFS4_dec_layoutreturn_sz (compound_decode_hdr_maxsz + \ | ||
772 | decode_sequence_maxsz + \ | ||
773 | decode_putfh_maxsz + \ | ||
774 | decode_layoutreturn_maxsz) | ||
702 | 775 | ||
703 | const u32 nfs41_maxwrite_overhead = ((RPC_MAX_HEADER_WITH_AUTH + | 776 | const u32 nfs41_maxwrite_overhead = ((RPC_MAX_HEADER_WITH_AUTH + |
704 | compound_encode_hdr_maxsz + | 777 | compound_encode_hdr_maxsz + |
@@ -816,7 +889,7 @@ static void encode_attrs(struct xdr_stream *xdr, const struct iattr *iap, const | |||
816 | if (iap->ia_valid & ATTR_MODE) | 889 | if (iap->ia_valid & ATTR_MODE) |
817 | len += 4; | 890 | len += 4; |
818 | if (iap->ia_valid & ATTR_UID) { | 891 | if (iap->ia_valid & ATTR_UID) { |
819 | owner_namelen = nfs_map_uid_to_name(server->nfs_client, iap->ia_uid, owner_name); | 892 | owner_namelen = nfs_map_uid_to_name(server, iap->ia_uid, owner_name, IDMAP_NAMESZ); |
820 | if (owner_namelen < 0) { | 893 | if (owner_namelen < 0) { |
821 | dprintk("nfs: couldn't resolve uid %d to string\n", | 894 | dprintk("nfs: couldn't resolve uid %d to string\n", |
822 | iap->ia_uid); | 895 | iap->ia_uid); |
@@ -828,7 +901,7 @@ static void encode_attrs(struct xdr_stream *xdr, const struct iattr *iap, const | |||
828 | len += 4 + (XDR_QUADLEN(owner_namelen) << 2); | 901 | len += 4 + (XDR_QUADLEN(owner_namelen) << 2); |
829 | } | 902 | } |
830 | if (iap->ia_valid & ATTR_GID) { | 903 | if (iap->ia_valid & ATTR_GID) { |
831 | owner_grouplen = nfs_map_gid_to_group(server->nfs_client, iap->ia_gid, owner_group); | 904 | owner_grouplen = nfs_map_gid_to_group(server, iap->ia_gid, owner_group, IDMAP_NAMESZ); |
832 | if (owner_grouplen < 0) { | 905 | if (owner_grouplen < 0) { |
833 | dprintk("nfs: couldn't resolve gid %d to string\n", | 906 | dprintk("nfs: couldn't resolve gid %d to string\n", |
834 | iap->ia_gid); | 907 | iap->ia_gid); |
@@ -1060,10 +1133,11 @@ static void encode_lockowner(struct xdr_stream *xdr, const struct nfs_lowner *lo | |||
1060 | { | 1133 | { |
1061 | __be32 *p; | 1134 | __be32 *p; |
1062 | 1135 | ||
1063 | p = reserve_space(xdr, 28); | 1136 | p = reserve_space(xdr, 32); |
1064 | p = xdr_encode_hyper(p, lowner->clientid); | 1137 | p = xdr_encode_hyper(p, lowner->clientid); |
1065 | *p++ = cpu_to_be32(16); | 1138 | *p++ = cpu_to_be32(20); |
1066 | p = xdr_encode_opaque_fixed(p, "lock id:", 8); | 1139 | p = xdr_encode_opaque_fixed(p, "lock id:", 8); |
1140 | *p++ = cpu_to_be32(lowner->s_dev); | ||
1067 | xdr_encode_hyper(p, lowner->id); | 1141 | xdr_encode_hyper(p, lowner->id); |
1068 | } | 1142 | } |
1069 | 1143 | ||
@@ -1182,10 +1256,11 @@ static inline void encode_openhdr(struct xdr_stream *xdr, const struct nfs_opena | |||
1182 | *p++ = cpu_to_be32(OP_OPEN); | 1256 | *p++ = cpu_to_be32(OP_OPEN); |
1183 | *p = cpu_to_be32(arg->seqid->sequence->counter); | 1257 | *p = cpu_to_be32(arg->seqid->sequence->counter); |
1184 | encode_share_access(xdr, arg->fmode); | 1258 | encode_share_access(xdr, arg->fmode); |
1185 | p = reserve_space(xdr, 28); | 1259 | p = reserve_space(xdr, 32); |
1186 | p = xdr_encode_hyper(p, arg->clientid); | 1260 | p = xdr_encode_hyper(p, arg->clientid); |
1187 | *p++ = cpu_to_be32(16); | 1261 | *p++ = cpu_to_be32(20); |
1188 | p = xdr_encode_opaque_fixed(p, "open id:", 8); | 1262 | p = xdr_encode_opaque_fixed(p, "open id:", 8); |
1263 | *p++ = cpu_to_be32(arg->server->s_dev); | ||
1189 | xdr_encode_hyper(p, arg->id); | 1264 | xdr_encode_hyper(p, arg->id); |
1190 | } | 1265 | } |
1191 | 1266 | ||
@@ -1354,7 +1429,7 @@ static void encode_putrootfh(struct xdr_stream *xdr, struct compound_hdr *hdr) | |||
1354 | hdr->replen += decode_putrootfh_maxsz; | 1429 | hdr->replen += decode_putrootfh_maxsz; |
1355 | } | 1430 | } |
1356 | 1431 | ||
1357 | static void encode_stateid(struct xdr_stream *xdr, const struct nfs_open_context *ctx, const struct nfs_lock_context *l_ctx) | 1432 | static void encode_stateid(struct xdr_stream *xdr, const struct nfs_open_context *ctx, const struct nfs_lock_context *l_ctx, int zero_seqid) |
1358 | { | 1433 | { |
1359 | nfs4_stateid stateid; | 1434 | nfs4_stateid stateid; |
1360 | __be32 *p; | 1435 | __be32 *p; |
@@ -1362,6 +1437,8 @@ static void encode_stateid(struct xdr_stream *xdr, const struct nfs_open_context | |||
1362 | p = reserve_space(xdr, NFS4_STATEID_SIZE); | 1437 | p = reserve_space(xdr, NFS4_STATEID_SIZE); |
1363 | if (ctx->state != NULL) { | 1438 | if (ctx->state != NULL) { |
1364 | nfs4_copy_stateid(&stateid, ctx->state, l_ctx->lockowner, l_ctx->pid); | 1439 | nfs4_copy_stateid(&stateid, ctx->state, l_ctx->lockowner, l_ctx->pid); |
1440 | if (zero_seqid) | ||
1441 | stateid.stateid.seqid = 0; | ||
1365 | xdr_encode_opaque_fixed(p, stateid.data, NFS4_STATEID_SIZE); | 1442 | xdr_encode_opaque_fixed(p, stateid.data, NFS4_STATEID_SIZE); |
1366 | } else | 1443 | } else |
1367 | xdr_encode_opaque_fixed(p, zero_stateid.data, NFS4_STATEID_SIZE); | 1444 | xdr_encode_opaque_fixed(p, zero_stateid.data, NFS4_STATEID_SIZE); |
@@ -1374,7 +1451,8 @@ static void encode_read(struct xdr_stream *xdr, const struct nfs_readargs *args, | |||
1374 | p = reserve_space(xdr, 4); | 1451 | p = reserve_space(xdr, 4); |
1375 | *p = cpu_to_be32(OP_READ); | 1452 | *p = cpu_to_be32(OP_READ); |
1376 | 1453 | ||
1377 | encode_stateid(xdr, args->context, args->lock_context); | 1454 | encode_stateid(xdr, args->context, args->lock_context, |
1455 | hdr->minorversion); | ||
1378 | 1456 | ||
1379 | p = reserve_space(xdr, 12); | 1457 | p = reserve_space(xdr, 12); |
1380 | p = xdr_encode_hyper(p, args->offset); | 1458 | p = xdr_encode_hyper(p, args->offset); |
@@ -1386,23 +1464,33 @@ static void encode_read(struct xdr_stream *xdr, const struct nfs_readargs *args, | |||
1386 | static void encode_readdir(struct xdr_stream *xdr, const struct nfs4_readdir_arg *readdir, struct rpc_rqst *req, struct compound_hdr *hdr) | 1464 | static void encode_readdir(struct xdr_stream *xdr, const struct nfs4_readdir_arg *readdir, struct rpc_rqst *req, struct compound_hdr *hdr) |
1387 | { | 1465 | { |
1388 | uint32_t attrs[2] = { | 1466 | uint32_t attrs[2] = { |
1389 | FATTR4_WORD0_RDATTR_ERROR|FATTR4_WORD0_FILEID, | 1467 | FATTR4_WORD0_RDATTR_ERROR, |
1390 | FATTR4_WORD1_MOUNTED_ON_FILEID, | 1468 | FATTR4_WORD1_MOUNTED_ON_FILEID, |
1391 | }; | 1469 | }; |
1470 | uint32_t dircount = readdir->count >> 1; | ||
1392 | __be32 *p; | 1471 | __be32 *p; |
1393 | 1472 | ||
1473 | if (readdir->plus) { | ||
1474 | attrs[0] |= FATTR4_WORD0_TYPE|FATTR4_WORD0_CHANGE|FATTR4_WORD0_SIZE| | ||
1475 | FATTR4_WORD0_FSID|FATTR4_WORD0_FILEHANDLE|FATTR4_WORD0_FILEID; | ||
1476 | attrs[1] |= FATTR4_WORD1_MODE|FATTR4_WORD1_NUMLINKS|FATTR4_WORD1_OWNER| | ||
1477 | FATTR4_WORD1_OWNER_GROUP|FATTR4_WORD1_RAWDEV| | ||
1478 | FATTR4_WORD1_SPACE_USED|FATTR4_WORD1_TIME_ACCESS| | ||
1479 | FATTR4_WORD1_TIME_METADATA|FATTR4_WORD1_TIME_MODIFY; | ||
1480 | dircount >>= 1; | ||
1481 | } | ||
1482 | /* Use mounted_on_fileid only if the server supports it */ | ||
1483 | if (!(readdir->bitmask[1] & FATTR4_WORD1_MOUNTED_ON_FILEID)) | ||
1484 | attrs[0] |= FATTR4_WORD0_FILEID; | ||
1485 | |||
1394 | p = reserve_space(xdr, 12+NFS4_VERIFIER_SIZE+20); | 1486 | p = reserve_space(xdr, 12+NFS4_VERIFIER_SIZE+20); |
1395 | *p++ = cpu_to_be32(OP_READDIR); | 1487 | *p++ = cpu_to_be32(OP_READDIR); |
1396 | p = xdr_encode_hyper(p, readdir->cookie); | 1488 | p = xdr_encode_hyper(p, readdir->cookie); |
1397 | p = xdr_encode_opaque_fixed(p, readdir->verifier.data, NFS4_VERIFIER_SIZE); | 1489 | p = xdr_encode_opaque_fixed(p, readdir->verifier.data, NFS4_VERIFIER_SIZE); |
1398 | *p++ = cpu_to_be32(readdir->count >> 1); /* We're not doing readdirplus */ | 1490 | *p++ = cpu_to_be32(dircount); |
1399 | *p++ = cpu_to_be32(readdir->count); | 1491 | *p++ = cpu_to_be32(readdir->count); |
1400 | *p++ = cpu_to_be32(2); | 1492 | *p++ = cpu_to_be32(2); |
1401 | /* Switch to mounted_on_fileid if the server supports it */ | 1493 | |
1402 | if (readdir->bitmask[1] & FATTR4_WORD1_MOUNTED_ON_FILEID) | ||
1403 | attrs[0] &= ~FATTR4_WORD0_FILEID; | ||
1404 | else | ||
1405 | attrs[1] &= ~FATTR4_WORD1_MOUNTED_ON_FILEID; | ||
1406 | *p++ = cpu_to_be32(attrs[0] & readdir->bitmask[0]); | 1494 | *p++ = cpu_to_be32(attrs[0] & readdir->bitmask[0]); |
1407 | *p = cpu_to_be32(attrs[1] & readdir->bitmask[1]); | 1495 | *p = cpu_to_be32(attrs[1] & readdir->bitmask[1]); |
1408 | hdr->nops++; | 1496 | hdr->nops++; |
@@ -1471,7 +1559,7 @@ encode_restorefh(struct xdr_stream *xdr, struct compound_hdr *hdr) | |||
1471 | hdr->replen += decode_restorefh_maxsz; | 1559 | hdr->replen += decode_restorefh_maxsz; |
1472 | } | 1560 | } |
1473 | 1561 | ||
1474 | static int | 1562 | static void |
1475 | encode_setacl(struct xdr_stream *xdr, struct nfs_setaclargs *arg, struct compound_hdr *hdr) | 1563 | encode_setacl(struct xdr_stream *xdr, struct nfs_setaclargs *arg, struct compound_hdr *hdr) |
1476 | { | 1564 | { |
1477 | __be32 *p; | 1565 | __be32 *p; |
@@ -1482,14 +1570,12 @@ encode_setacl(struct xdr_stream *xdr, struct nfs_setaclargs *arg, struct compoun | |||
1482 | p = reserve_space(xdr, 2*4); | 1570 | p = reserve_space(xdr, 2*4); |
1483 | *p++ = cpu_to_be32(1); | 1571 | *p++ = cpu_to_be32(1); |
1484 | *p = cpu_to_be32(FATTR4_WORD0_ACL); | 1572 | *p = cpu_to_be32(FATTR4_WORD0_ACL); |
1485 | if (arg->acl_len % 4) | 1573 | BUG_ON(arg->acl_len % 4); |
1486 | return -EINVAL; | ||
1487 | p = reserve_space(xdr, 4); | 1574 | p = reserve_space(xdr, 4); |
1488 | *p = cpu_to_be32(arg->acl_len); | 1575 | *p = cpu_to_be32(arg->acl_len); |
1489 | xdr_write_pages(xdr, arg->acl_pages, arg->acl_pgbase, arg->acl_len); | 1576 | xdr_write_pages(xdr, arg->acl_pages, arg->acl_pgbase, arg->acl_len); |
1490 | hdr->nops++; | 1577 | hdr->nops++; |
1491 | hdr->replen += decode_setacl_maxsz; | 1578 | hdr->replen += decode_setacl_maxsz; |
1492 | return 0; | ||
1493 | } | 1579 | } |
1494 | 1580 | ||
1495 | static void | 1581 | static void |
@@ -1553,7 +1639,8 @@ static void encode_write(struct xdr_stream *xdr, const struct nfs_writeargs *arg | |||
1553 | p = reserve_space(xdr, 4); | 1639 | p = reserve_space(xdr, 4); |
1554 | *p = cpu_to_be32(OP_WRITE); | 1640 | *p = cpu_to_be32(OP_WRITE); |
1555 | 1641 | ||
1556 | encode_stateid(xdr, args->context, args->lock_context); | 1642 | encode_stateid(xdr, args->context, args->lock_context, |
1643 | hdr->minorversion); | ||
1557 | 1644 | ||
1558 | p = reserve_space(xdr, 16); | 1645 | p = reserve_space(xdr, 16); |
1559 | p = xdr_encode_hyper(p, args->offset); | 1646 | p = xdr_encode_hyper(p, args->offset); |
@@ -1577,6 +1664,18 @@ static void encode_delegreturn(struct xdr_stream *xdr, const nfs4_stateid *state | |||
1577 | hdr->replen += decode_delegreturn_maxsz; | 1664 | hdr->replen += decode_delegreturn_maxsz; |
1578 | } | 1665 | } |
1579 | 1666 | ||
1667 | static void encode_secinfo(struct xdr_stream *xdr, const struct qstr *name, struct compound_hdr *hdr) | ||
1668 | { | ||
1669 | int len = name->len; | ||
1670 | __be32 *p; | ||
1671 | |||
1672 | p = reserve_space(xdr, 8 + len); | ||
1673 | *p++ = cpu_to_be32(OP_SECINFO); | ||
1674 | xdr_encode_opaque(p, name->name, len); | ||
1675 | hdr->nops++; | ||
1676 | hdr->replen += decode_secinfo_maxsz; | ||
1677 | } | ||
1678 | |||
1580 | #if defined(CONFIG_NFS_V4_1) | 1679 | #if defined(CONFIG_NFS_V4_1) |
1581 | /* NFSv4.1 operations */ | 1680 | /* NFSv4.1 operations */ |
1582 | static void encode_exchange_id(struct xdr_stream *xdr, | 1681 | static void encode_exchange_id(struct xdr_stream *xdr, |
@@ -1621,12 +1720,12 @@ static void encode_create_session(struct xdr_stream *xdr, | |||
1621 | 1720 | ||
1622 | p = reserve_space(xdr, 20 + 2*28 + 20 + len + 12); | 1721 | p = reserve_space(xdr, 20 + 2*28 + 20 + len + 12); |
1623 | *p++ = cpu_to_be32(OP_CREATE_SESSION); | 1722 | *p++ = cpu_to_be32(OP_CREATE_SESSION); |
1624 | p = xdr_encode_hyper(p, clp->cl_ex_clid); | 1723 | p = xdr_encode_hyper(p, clp->cl_clientid); |
1625 | *p++ = cpu_to_be32(clp->cl_seqid); /*Sequence id */ | 1724 | *p++ = cpu_to_be32(clp->cl_seqid); /*Sequence id */ |
1626 | *p++ = cpu_to_be32(args->flags); /*flags */ | 1725 | *p++ = cpu_to_be32(args->flags); /*flags */ |
1627 | 1726 | ||
1628 | /* Fore Channel */ | 1727 | /* Fore Channel */ |
1629 | *p++ = cpu_to_be32(args->fc_attrs.headerpadsz); /* header padding size */ | 1728 | *p++ = cpu_to_be32(0); /* header padding size */ |
1630 | *p++ = cpu_to_be32(args->fc_attrs.max_rqst_sz); /* max req size */ | 1729 | *p++ = cpu_to_be32(args->fc_attrs.max_rqst_sz); /* max req size */ |
1631 | *p++ = cpu_to_be32(args->fc_attrs.max_resp_sz); /* max resp size */ | 1730 | *p++ = cpu_to_be32(args->fc_attrs.max_resp_sz); /* max resp size */ |
1632 | *p++ = cpu_to_be32(max_resp_sz_cached); /* Max resp sz cached */ | 1731 | *p++ = cpu_to_be32(max_resp_sz_cached); /* Max resp sz cached */ |
@@ -1635,7 +1734,7 @@ static void encode_create_session(struct xdr_stream *xdr, | |||
1635 | *p++ = cpu_to_be32(0); /* rdmachannel_attrs */ | 1734 | *p++ = cpu_to_be32(0); /* rdmachannel_attrs */ |
1636 | 1735 | ||
1637 | /* Back Channel */ | 1736 | /* Back Channel */ |
1638 | *p++ = cpu_to_be32(args->fc_attrs.headerpadsz); /* header padding size */ | 1737 | *p++ = cpu_to_be32(0); /* header padding size */ |
1639 | *p++ = cpu_to_be32(args->bc_attrs.max_rqst_sz); /* max req size */ | 1738 | *p++ = cpu_to_be32(args->bc_attrs.max_rqst_sz); /* max req size */ |
1640 | *p++ = cpu_to_be32(args->bc_attrs.max_resp_sz); /* max resp size */ | 1739 | *p++ = cpu_to_be32(args->bc_attrs.max_resp_sz); /* max resp size */ |
1641 | *p++ = cpu_to_be32(args->bc_attrs.max_resp_sz_cached); /* Max resp sz cached */ | 1740 | *p++ = cpu_to_be32(args->bc_attrs.max_resp_sz_cached); /* Max resp sz cached */ |
@@ -1726,6 +1825,121 @@ static void encode_sequence(struct xdr_stream *xdr, | |||
1726 | #endif /* CONFIG_NFS_V4_1 */ | 1825 | #endif /* CONFIG_NFS_V4_1 */ |
1727 | } | 1826 | } |
1728 | 1827 | ||
1828 | #ifdef CONFIG_NFS_V4_1 | ||
1829 | static void | ||
1830 | encode_getdeviceinfo(struct xdr_stream *xdr, | ||
1831 | const struct nfs4_getdeviceinfo_args *args, | ||
1832 | struct compound_hdr *hdr) | ||
1833 | { | ||
1834 | __be32 *p; | ||
1835 | |||
1836 | p = reserve_space(xdr, 16 + NFS4_DEVICEID4_SIZE); | ||
1837 | *p++ = cpu_to_be32(OP_GETDEVICEINFO); | ||
1838 | p = xdr_encode_opaque_fixed(p, args->pdev->dev_id.data, | ||
1839 | NFS4_DEVICEID4_SIZE); | ||
1840 | *p++ = cpu_to_be32(args->pdev->layout_type); | ||
1841 | *p++ = cpu_to_be32(args->pdev->pglen); /* gdia_maxcount */ | ||
1842 | *p++ = cpu_to_be32(0); /* bitmap length 0 */ | ||
1843 | hdr->nops++; | ||
1844 | hdr->replen += decode_getdeviceinfo_maxsz; | ||
1845 | } | ||
1846 | |||
1847 | static void | ||
1848 | encode_layoutget(struct xdr_stream *xdr, | ||
1849 | const struct nfs4_layoutget_args *args, | ||
1850 | struct compound_hdr *hdr) | ||
1851 | { | ||
1852 | __be32 *p; | ||
1853 | |||
1854 | p = reserve_space(xdr, 44 + NFS4_STATEID_SIZE); | ||
1855 | *p++ = cpu_to_be32(OP_LAYOUTGET); | ||
1856 | *p++ = cpu_to_be32(0); /* Signal layout available */ | ||
1857 | *p++ = cpu_to_be32(args->type); | ||
1858 | *p++ = cpu_to_be32(args->range.iomode); | ||
1859 | p = xdr_encode_hyper(p, args->range.offset); | ||
1860 | p = xdr_encode_hyper(p, args->range.length); | ||
1861 | p = xdr_encode_hyper(p, args->minlength); | ||
1862 | p = xdr_encode_opaque_fixed(p, &args->stateid.data, NFS4_STATEID_SIZE); | ||
1863 | *p = cpu_to_be32(args->maxcount); | ||
1864 | |||
1865 | dprintk("%s: 1st type:0x%x iomode:%d off:%lu len:%lu mc:%d\n", | ||
1866 | __func__, | ||
1867 | args->type, | ||
1868 | args->range.iomode, | ||
1869 | (unsigned long)args->range.offset, | ||
1870 | (unsigned long)args->range.length, | ||
1871 | args->maxcount); | ||
1872 | hdr->nops++; | ||
1873 | hdr->replen += decode_layoutget_maxsz; | ||
1874 | } | ||
1875 | |||
1876 | static int | ||
1877 | encode_layoutcommit(struct xdr_stream *xdr, | ||
1878 | struct inode *inode, | ||
1879 | const struct nfs4_layoutcommit_args *args, | ||
1880 | struct compound_hdr *hdr) | ||
1881 | { | ||
1882 | __be32 *p; | ||
1883 | |||
1884 | dprintk("%s: lbw: %llu type: %d\n", __func__, args->lastbytewritten, | ||
1885 | NFS_SERVER(args->inode)->pnfs_curr_ld->id); | ||
1886 | |||
1887 | p = reserve_space(xdr, 44 + NFS4_STATEID_SIZE); | ||
1888 | *p++ = cpu_to_be32(OP_LAYOUTCOMMIT); | ||
1889 | /* Only whole file layouts */ | ||
1890 | p = xdr_encode_hyper(p, 0); /* offset */ | ||
1891 | p = xdr_encode_hyper(p, NFS4_MAX_UINT64); /* length */ | ||
1892 | *p++ = cpu_to_be32(0); /* reclaim */ | ||
1893 | p = xdr_encode_opaque_fixed(p, args->stateid.data, NFS4_STATEID_SIZE); | ||
1894 | *p++ = cpu_to_be32(1); /* newoffset = TRUE */ | ||
1895 | p = xdr_encode_hyper(p, args->lastbytewritten); | ||
1896 | *p++ = cpu_to_be32(0); /* Never send time_modify_changed */ | ||
1897 | *p++ = cpu_to_be32(NFS_SERVER(args->inode)->pnfs_curr_ld->id);/* type */ | ||
1898 | |||
1899 | if (NFS_SERVER(inode)->pnfs_curr_ld->encode_layoutcommit) | ||
1900 | NFS_SERVER(inode)->pnfs_curr_ld->encode_layoutcommit( | ||
1901 | NFS_I(inode)->layout, xdr, args); | ||
1902 | else { | ||
1903 | p = reserve_space(xdr, 4); | ||
1904 | *p = cpu_to_be32(0); /* no layout-type payload */ | ||
1905 | } | ||
1906 | |||
1907 | hdr->nops++; | ||
1908 | hdr->replen += decode_layoutcommit_maxsz; | ||
1909 | return 0; | ||
1910 | } | ||
1911 | |||
1912 | static void | ||
1913 | encode_layoutreturn(struct xdr_stream *xdr, | ||
1914 | const struct nfs4_layoutreturn_args *args, | ||
1915 | struct compound_hdr *hdr) | ||
1916 | { | ||
1917 | __be32 *p; | ||
1918 | |||
1919 | p = reserve_space(xdr, 20); | ||
1920 | *p++ = cpu_to_be32(OP_LAYOUTRETURN); | ||
1921 | *p++ = cpu_to_be32(0); /* reclaim. always 0 for now */ | ||
1922 | *p++ = cpu_to_be32(args->layout_type); | ||
1923 | *p++ = cpu_to_be32(IOMODE_ANY); | ||
1924 | *p = cpu_to_be32(RETURN_FILE); | ||
1925 | p = reserve_space(xdr, 16 + NFS4_STATEID_SIZE); | ||
1926 | p = xdr_encode_hyper(p, 0); | ||
1927 | p = xdr_encode_hyper(p, NFS4_MAX_UINT64); | ||
1928 | spin_lock(&args->inode->i_lock); | ||
1929 | xdr_encode_opaque_fixed(p, &args->stateid.data, NFS4_STATEID_SIZE); | ||
1930 | spin_unlock(&args->inode->i_lock); | ||
1931 | if (NFS_SERVER(args->inode)->pnfs_curr_ld->encode_layoutreturn) { | ||
1932 | NFS_SERVER(args->inode)->pnfs_curr_ld->encode_layoutreturn( | ||
1933 | NFS_I(args->inode)->layout, xdr, args); | ||
1934 | } else { | ||
1935 | p = reserve_space(xdr, 4); | ||
1936 | *p = cpu_to_be32(0); | ||
1937 | } | ||
1938 | hdr->nops++; | ||
1939 | hdr->replen += decode_layoutreturn_maxsz; | ||
1940 | } | ||
1941 | #endif /* CONFIG_NFS_V4_1 */ | ||
1942 | |||
1729 | /* | 1943 | /* |
1730 | * END OF "GENERIC" ENCODE ROUTINES. | 1944 | * END OF "GENERIC" ENCODE ROUTINES. |
1731 | */ | 1945 | */ |
@@ -1742,393 +1956,362 @@ static u32 nfs4_xdr_minorversion(const struct nfs4_sequence_args *args) | |||
1742 | /* | 1956 | /* |
1743 | * Encode an ACCESS request | 1957 | * Encode an ACCESS request |
1744 | */ | 1958 | */ |
1745 | static int nfs4_xdr_enc_access(struct rpc_rqst *req, __be32 *p, const struct nfs4_accessargs *args) | 1959 | static void nfs4_xdr_enc_access(struct rpc_rqst *req, struct xdr_stream *xdr, |
1960 | const struct nfs4_accessargs *args) | ||
1746 | { | 1961 | { |
1747 | struct xdr_stream xdr; | ||
1748 | struct compound_hdr hdr = { | 1962 | struct compound_hdr hdr = { |
1749 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | 1963 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
1750 | }; | 1964 | }; |
1751 | 1965 | ||
1752 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); | 1966 | encode_compound_hdr(xdr, req, &hdr); |
1753 | encode_compound_hdr(&xdr, req, &hdr); | 1967 | encode_sequence(xdr, &args->seq_args, &hdr); |
1754 | encode_sequence(&xdr, &args->seq_args, &hdr); | 1968 | encode_putfh(xdr, args->fh, &hdr); |
1755 | encode_putfh(&xdr, args->fh, &hdr); | 1969 | encode_access(xdr, args->access, &hdr); |
1756 | encode_access(&xdr, args->access, &hdr); | 1970 | encode_getfattr(xdr, args->bitmask, &hdr); |
1757 | encode_getfattr(&xdr, args->bitmask, &hdr); | ||
1758 | encode_nops(&hdr); | 1971 | encode_nops(&hdr); |
1759 | return 0; | ||
1760 | } | 1972 | } |
1761 | 1973 | ||
1762 | /* | 1974 | /* |
1763 | * Encode LOOKUP request | 1975 | * Encode LOOKUP request |
1764 | */ | 1976 | */ |
1765 | static int nfs4_xdr_enc_lookup(struct rpc_rqst *req, __be32 *p, const struct nfs4_lookup_arg *args) | 1977 | static void nfs4_xdr_enc_lookup(struct rpc_rqst *req, struct xdr_stream *xdr, |
1978 | const struct nfs4_lookup_arg *args) | ||
1766 | { | 1979 | { |
1767 | struct xdr_stream xdr; | ||
1768 | struct compound_hdr hdr = { | 1980 | struct compound_hdr hdr = { |
1769 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | 1981 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
1770 | }; | 1982 | }; |
1771 | 1983 | ||
1772 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); | 1984 | encode_compound_hdr(xdr, req, &hdr); |
1773 | encode_compound_hdr(&xdr, req, &hdr); | 1985 | encode_sequence(xdr, &args->seq_args, &hdr); |
1774 | encode_sequence(&xdr, &args->seq_args, &hdr); | 1986 | encode_putfh(xdr, args->dir_fh, &hdr); |
1775 | encode_putfh(&xdr, args->dir_fh, &hdr); | 1987 | encode_lookup(xdr, args->name, &hdr); |
1776 | encode_lookup(&xdr, args->name, &hdr); | 1988 | encode_getfh(xdr, &hdr); |
1777 | encode_getfh(&xdr, &hdr); | 1989 | encode_getfattr(xdr, args->bitmask, &hdr); |
1778 | encode_getfattr(&xdr, args->bitmask, &hdr); | ||
1779 | encode_nops(&hdr); | 1990 | encode_nops(&hdr); |
1780 | return 0; | ||
1781 | } | 1991 | } |
1782 | 1992 | ||
1783 | /* | 1993 | /* |
1784 | * Encode LOOKUP_ROOT request | 1994 | * Encode LOOKUP_ROOT request |
1785 | */ | 1995 | */ |
1786 | static int nfs4_xdr_enc_lookup_root(struct rpc_rqst *req, __be32 *p, const struct nfs4_lookup_root_arg *args) | 1996 | static void nfs4_xdr_enc_lookup_root(struct rpc_rqst *req, |
1997 | struct xdr_stream *xdr, | ||
1998 | const struct nfs4_lookup_root_arg *args) | ||
1787 | { | 1999 | { |
1788 | struct xdr_stream xdr; | ||
1789 | struct compound_hdr hdr = { | 2000 | struct compound_hdr hdr = { |
1790 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | 2001 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
1791 | }; | 2002 | }; |
1792 | 2003 | ||
1793 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); | 2004 | encode_compound_hdr(xdr, req, &hdr); |
1794 | encode_compound_hdr(&xdr, req, &hdr); | 2005 | encode_sequence(xdr, &args->seq_args, &hdr); |
1795 | encode_sequence(&xdr, &args->seq_args, &hdr); | 2006 | encode_putrootfh(xdr, &hdr); |
1796 | encode_putrootfh(&xdr, &hdr); | 2007 | encode_getfh(xdr, &hdr); |
1797 | encode_getfh(&xdr, &hdr); | 2008 | encode_getfattr(xdr, args->bitmask, &hdr); |
1798 | encode_getfattr(&xdr, args->bitmask, &hdr); | ||
1799 | encode_nops(&hdr); | 2009 | encode_nops(&hdr); |
1800 | return 0; | ||
1801 | } | 2010 | } |
1802 | 2011 | ||
1803 | /* | 2012 | /* |
1804 | * Encode REMOVE request | 2013 | * Encode REMOVE request |
1805 | */ | 2014 | */ |
1806 | static int nfs4_xdr_enc_remove(struct rpc_rqst *req, __be32 *p, const struct nfs_removeargs *args) | 2015 | static void nfs4_xdr_enc_remove(struct rpc_rqst *req, struct xdr_stream *xdr, |
2016 | const struct nfs_removeargs *args) | ||
1807 | { | 2017 | { |
1808 | struct xdr_stream xdr; | ||
1809 | struct compound_hdr hdr = { | 2018 | struct compound_hdr hdr = { |
1810 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | 2019 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
1811 | }; | 2020 | }; |
1812 | 2021 | ||
1813 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); | 2022 | encode_compound_hdr(xdr, req, &hdr); |
1814 | encode_compound_hdr(&xdr, req, &hdr); | 2023 | encode_sequence(xdr, &args->seq_args, &hdr); |
1815 | encode_sequence(&xdr, &args->seq_args, &hdr); | 2024 | encode_putfh(xdr, args->fh, &hdr); |
1816 | encode_putfh(&xdr, args->fh, &hdr); | 2025 | encode_remove(xdr, &args->name, &hdr); |
1817 | encode_remove(&xdr, &args->name, &hdr); | 2026 | encode_getfattr(xdr, args->bitmask, &hdr); |
1818 | encode_getfattr(&xdr, args->bitmask, &hdr); | ||
1819 | encode_nops(&hdr); | 2027 | encode_nops(&hdr); |
1820 | return 0; | ||
1821 | } | 2028 | } |
1822 | 2029 | ||
1823 | /* | 2030 | /* |
1824 | * Encode RENAME request | 2031 | * Encode RENAME request |
1825 | */ | 2032 | */ |
1826 | static int nfs4_xdr_enc_rename(struct rpc_rqst *req, __be32 *p, const struct nfs4_rename_arg *args) | 2033 | static void nfs4_xdr_enc_rename(struct rpc_rqst *req, struct xdr_stream *xdr, |
2034 | const struct nfs_renameargs *args) | ||
1827 | { | 2035 | { |
1828 | struct xdr_stream xdr; | ||
1829 | struct compound_hdr hdr = { | 2036 | struct compound_hdr hdr = { |
1830 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | 2037 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
1831 | }; | 2038 | }; |
1832 | 2039 | ||
1833 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); | 2040 | encode_compound_hdr(xdr, req, &hdr); |
1834 | encode_compound_hdr(&xdr, req, &hdr); | 2041 | encode_sequence(xdr, &args->seq_args, &hdr); |
1835 | encode_sequence(&xdr, &args->seq_args, &hdr); | 2042 | encode_putfh(xdr, args->old_dir, &hdr); |
1836 | encode_putfh(&xdr, args->old_dir, &hdr); | 2043 | encode_savefh(xdr, &hdr); |
1837 | encode_savefh(&xdr, &hdr); | 2044 | encode_putfh(xdr, args->new_dir, &hdr); |
1838 | encode_putfh(&xdr, args->new_dir, &hdr); | 2045 | encode_rename(xdr, args->old_name, args->new_name, &hdr); |
1839 | encode_rename(&xdr, args->old_name, args->new_name, &hdr); | 2046 | encode_getfattr(xdr, args->bitmask, &hdr); |
1840 | encode_getfattr(&xdr, args->bitmask, &hdr); | 2047 | encode_restorefh(xdr, &hdr); |
1841 | encode_restorefh(&xdr, &hdr); | 2048 | encode_getfattr(xdr, args->bitmask, &hdr); |
1842 | encode_getfattr(&xdr, args->bitmask, &hdr); | ||
1843 | encode_nops(&hdr); | 2049 | encode_nops(&hdr); |
1844 | return 0; | ||
1845 | } | 2050 | } |
1846 | 2051 | ||
1847 | /* | 2052 | /* |
1848 | * Encode LINK request | 2053 | * Encode LINK request |
1849 | */ | 2054 | */ |
1850 | static int nfs4_xdr_enc_link(struct rpc_rqst *req, __be32 *p, const struct nfs4_link_arg *args) | 2055 | static void nfs4_xdr_enc_link(struct rpc_rqst *req, struct xdr_stream *xdr, |
2056 | const struct nfs4_link_arg *args) | ||
1851 | { | 2057 | { |
1852 | struct xdr_stream xdr; | ||
1853 | struct compound_hdr hdr = { | 2058 | struct compound_hdr hdr = { |
1854 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | 2059 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
1855 | }; | 2060 | }; |
1856 | 2061 | ||
1857 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); | 2062 | encode_compound_hdr(xdr, req, &hdr); |
1858 | encode_compound_hdr(&xdr, req, &hdr); | 2063 | encode_sequence(xdr, &args->seq_args, &hdr); |
1859 | encode_sequence(&xdr, &args->seq_args, &hdr); | 2064 | encode_putfh(xdr, args->fh, &hdr); |
1860 | encode_putfh(&xdr, args->fh, &hdr); | 2065 | encode_savefh(xdr, &hdr); |
1861 | encode_savefh(&xdr, &hdr); | 2066 | encode_putfh(xdr, args->dir_fh, &hdr); |
1862 | encode_putfh(&xdr, args->dir_fh, &hdr); | 2067 | encode_link(xdr, args->name, &hdr); |
1863 | encode_link(&xdr, args->name, &hdr); | 2068 | encode_getfattr(xdr, args->bitmask, &hdr); |
1864 | encode_getfattr(&xdr, args->bitmask, &hdr); | 2069 | encode_restorefh(xdr, &hdr); |
1865 | encode_restorefh(&xdr, &hdr); | 2070 | encode_getfattr(xdr, args->bitmask, &hdr); |
1866 | encode_getfattr(&xdr, args->bitmask, &hdr); | ||
1867 | encode_nops(&hdr); | 2071 | encode_nops(&hdr); |
1868 | return 0; | ||
1869 | } | 2072 | } |
1870 | 2073 | ||
1871 | /* | 2074 | /* |
1872 | * Encode CREATE request | 2075 | * Encode CREATE request |
1873 | */ | 2076 | */ |
1874 | static int nfs4_xdr_enc_create(struct rpc_rqst *req, __be32 *p, const struct nfs4_create_arg *args) | 2077 | static void nfs4_xdr_enc_create(struct rpc_rqst *req, struct xdr_stream *xdr, |
2078 | const struct nfs4_create_arg *args) | ||
1875 | { | 2079 | { |
1876 | struct xdr_stream xdr; | ||
1877 | struct compound_hdr hdr = { | 2080 | struct compound_hdr hdr = { |
1878 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | 2081 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
1879 | }; | 2082 | }; |
1880 | 2083 | ||
1881 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); | 2084 | encode_compound_hdr(xdr, req, &hdr); |
1882 | encode_compound_hdr(&xdr, req, &hdr); | 2085 | encode_sequence(xdr, &args->seq_args, &hdr); |
1883 | encode_sequence(&xdr, &args->seq_args, &hdr); | 2086 | encode_putfh(xdr, args->dir_fh, &hdr); |
1884 | encode_putfh(&xdr, args->dir_fh, &hdr); | 2087 | encode_savefh(xdr, &hdr); |
1885 | encode_savefh(&xdr, &hdr); | 2088 | encode_create(xdr, args, &hdr); |
1886 | encode_create(&xdr, args, &hdr); | 2089 | encode_getfh(xdr, &hdr); |
1887 | encode_getfh(&xdr, &hdr); | 2090 | encode_getfattr(xdr, args->bitmask, &hdr); |
1888 | encode_getfattr(&xdr, args->bitmask, &hdr); | 2091 | encode_restorefh(xdr, &hdr); |
1889 | encode_restorefh(&xdr, &hdr); | 2092 | encode_getfattr(xdr, args->bitmask, &hdr); |
1890 | encode_getfattr(&xdr, args->bitmask, &hdr); | ||
1891 | encode_nops(&hdr); | 2093 | encode_nops(&hdr); |
1892 | return 0; | ||
1893 | } | 2094 | } |
1894 | 2095 | ||
1895 | /* | 2096 | /* |
1896 | * Encode SYMLINK request | 2097 | * Encode SYMLINK request |
1897 | */ | 2098 | */ |
1898 | static int nfs4_xdr_enc_symlink(struct rpc_rqst *req, __be32 *p, const struct nfs4_create_arg *args) | 2099 | static void nfs4_xdr_enc_symlink(struct rpc_rqst *req, struct xdr_stream *xdr, |
2100 | const struct nfs4_create_arg *args) | ||
1899 | { | 2101 | { |
1900 | return nfs4_xdr_enc_create(req, p, args); | 2102 | nfs4_xdr_enc_create(req, xdr, args); |
1901 | } | 2103 | } |
1902 | 2104 | ||
1903 | /* | 2105 | /* |
1904 | * Encode GETATTR request | 2106 | * Encode GETATTR request |
1905 | */ | 2107 | */ |
1906 | static int nfs4_xdr_enc_getattr(struct rpc_rqst *req, __be32 *p, const struct nfs4_getattr_arg *args) | 2108 | static void nfs4_xdr_enc_getattr(struct rpc_rqst *req, struct xdr_stream *xdr, |
2109 | const struct nfs4_getattr_arg *args) | ||
1907 | { | 2110 | { |
1908 | struct xdr_stream xdr; | ||
1909 | struct compound_hdr hdr = { | 2111 | struct compound_hdr hdr = { |
1910 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | 2112 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
1911 | }; | 2113 | }; |
1912 | 2114 | ||
1913 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); | 2115 | encode_compound_hdr(xdr, req, &hdr); |
1914 | encode_compound_hdr(&xdr, req, &hdr); | 2116 | encode_sequence(xdr, &args->seq_args, &hdr); |
1915 | encode_sequence(&xdr, &args->seq_args, &hdr); | 2117 | encode_putfh(xdr, args->fh, &hdr); |
1916 | encode_putfh(&xdr, args->fh, &hdr); | 2118 | encode_getfattr(xdr, args->bitmask, &hdr); |
1917 | encode_getfattr(&xdr, args->bitmask, &hdr); | ||
1918 | encode_nops(&hdr); | 2119 | encode_nops(&hdr); |
1919 | return 0; | ||
1920 | } | 2120 | } |
1921 | 2121 | ||
1922 | /* | 2122 | /* |
1923 | * Encode a CLOSE request | 2123 | * Encode a CLOSE request |
1924 | */ | 2124 | */ |
1925 | static int nfs4_xdr_enc_close(struct rpc_rqst *req, __be32 *p, struct nfs_closeargs *args) | 2125 | static void nfs4_xdr_enc_close(struct rpc_rqst *req, struct xdr_stream *xdr, |
2126 | struct nfs_closeargs *args) | ||
1926 | { | 2127 | { |
1927 | struct xdr_stream xdr; | ||
1928 | struct compound_hdr hdr = { | 2128 | struct compound_hdr hdr = { |
1929 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | 2129 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
1930 | }; | 2130 | }; |
1931 | 2131 | ||
1932 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); | 2132 | encode_compound_hdr(xdr, req, &hdr); |
1933 | encode_compound_hdr(&xdr, req, &hdr); | 2133 | encode_sequence(xdr, &args->seq_args, &hdr); |
1934 | encode_sequence(&xdr, &args->seq_args, &hdr); | 2134 | encode_putfh(xdr, args->fh, &hdr); |
1935 | encode_putfh(&xdr, args->fh, &hdr); | 2135 | encode_close(xdr, args, &hdr); |
1936 | encode_close(&xdr, args, &hdr); | 2136 | encode_getfattr(xdr, args->bitmask, &hdr); |
1937 | encode_getfattr(&xdr, args->bitmask, &hdr); | ||
1938 | encode_nops(&hdr); | 2137 | encode_nops(&hdr); |
1939 | return 0; | ||
1940 | } | 2138 | } |
1941 | 2139 | ||
1942 | /* | 2140 | /* |
1943 | * Encode an OPEN request | 2141 | * Encode an OPEN request |
1944 | */ | 2142 | */ |
1945 | static int nfs4_xdr_enc_open(struct rpc_rqst *req, __be32 *p, struct nfs_openargs *args) | 2143 | static void nfs4_xdr_enc_open(struct rpc_rqst *req, struct xdr_stream *xdr, |
2144 | struct nfs_openargs *args) | ||
1946 | { | 2145 | { |
1947 | struct xdr_stream xdr; | ||
1948 | struct compound_hdr hdr = { | 2146 | struct compound_hdr hdr = { |
1949 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | 2147 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
1950 | }; | 2148 | }; |
1951 | 2149 | ||
1952 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); | 2150 | encode_compound_hdr(xdr, req, &hdr); |
1953 | encode_compound_hdr(&xdr, req, &hdr); | 2151 | encode_sequence(xdr, &args->seq_args, &hdr); |
1954 | encode_sequence(&xdr, &args->seq_args, &hdr); | 2152 | encode_putfh(xdr, args->fh, &hdr); |
1955 | encode_putfh(&xdr, args->fh, &hdr); | 2153 | encode_savefh(xdr, &hdr); |
1956 | encode_savefh(&xdr, &hdr); | 2154 | encode_open(xdr, args, &hdr); |
1957 | encode_open(&xdr, args, &hdr); | 2155 | encode_getfh(xdr, &hdr); |
1958 | encode_getfh(&xdr, &hdr); | 2156 | encode_getfattr(xdr, args->bitmask, &hdr); |
1959 | encode_getfattr(&xdr, args->bitmask, &hdr); | 2157 | encode_restorefh(xdr, &hdr); |
1960 | encode_restorefh(&xdr, &hdr); | 2158 | encode_getfattr(xdr, args->bitmask, &hdr); |
1961 | encode_getfattr(&xdr, args->bitmask, &hdr); | ||
1962 | encode_nops(&hdr); | 2159 | encode_nops(&hdr); |
1963 | return 0; | ||
1964 | } | 2160 | } |
1965 | 2161 | ||
1966 | /* | 2162 | /* |
1967 | * Encode an OPEN_CONFIRM request | 2163 | * Encode an OPEN_CONFIRM request |
1968 | */ | 2164 | */ |
1969 | static int nfs4_xdr_enc_open_confirm(struct rpc_rqst *req, __be32 *p, struct nfs_open_confirmargs *args) | 2165 | static void nfs4_xdr_enc_open_confirm(struct rpc_rqst *req, |
2166 | struct xdr_stream *xdr, | ||
2167 | struct nfs_open_confirmargs *args) | ||
1970 | { | 2168 | { |
1971 | struct xdr_stream xdr; | ||
1972 | struct compound_hdr hdr = { | 2169 | struct compound_hdr hdr = { |
1973 | .nops = 0, | 2170 | .nops = 0, |
1974 | }; | 2171 | }; |
1975 | 2172 | ||
1976 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); | 2173 | encode_compound_hdr(xdr, req, &hdr); |
1977 | encode_compound_hdr(&xdr, req, &hdr); | 2174 | encode_putfh(xdr, args->fh, &hdr); |
1978 | encode_putfh(&xdr, args->fh, &hdr); | 2175 | encode_open_confirm(xdr, args, &hdr); |
1979 | encode_open_confirm(&xdr, args, &hdr); | ||
1980 | encode_nops(&hdr); | 2176 | encode_nops(&hdr); |
1981 | return 0; | ||
1982 | } | 2177 | } |
1983 | 2178 | ||
1984 | /* | 2179 | /* |
1985 | * Encode an OPEN request with no attributes. | 2180 | * Encode an OPEN request with no attributes. |
1986 | */ | 2181 | */ |
1987 | static int nfs4_xdr_enc_open_noattr(struct rpc_rqst *req, __be32 *p, struct nfs_openargs *args) | 2182 | static void nfs4_xdr_enc_open_noattr(struct rpc_rqst *req, |
2183 | struct xdr_stream *xdr, | ||
2184 | struct nfs_openargs *args) | ||
1988 | { | 2185 | { |
1989 | struct xdr_stream xdr; | ||
1990 | struct compound_hdr hdr = { | 2186 | struct compound_hdr hdr = { |
1991 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | 2187 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
1992 | }; | 2188 | }; |
1993 | 2189 | ||
1994 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); | 2190 | encode_compound_hdr(xdr, req, &hdr); |
1995 | encode_compound_hdr(&xdr, req, &hdr); | 2191 | encode_sequence(xdr, &args->seq_args, &hdr); |
1996 | encode_sequence(&xdr, &args->seq_args, &hdr); | 2192 | encode_putfh(xdr, args->fh, &hdr); |
1997 | encode_putfh(&xdr, args->fh, &hdr); | 2193 | encode_open(xdr, args, &hdr); |
1998 | encode_open(&xdr, args, &hdr); | 2194 | encode_getfattr(xdr, args->bitmask, &hdr); |
1999 | encode_getfattr(&xdr, args->bitmask, &hdr); | ||
2000 | encode_nops(&hdr); | 2195 | encode_nops(&hdr); |
2001 | return 0; | ||
2002 | } | 2196 | } |
2003 | 2197 | ||
2004 | /* | 2198 | /* |
2005 | * Encode an OPEN_DOWNGRADE request | 2199 | * Encode an OPEN_DOWNGRADE request |
2006 | */ | 2200 | */ |
2007 | static int nfs4_xdr_enc_open_downgrade(struct rpc_rqst *req, __be32 *p, struct nfs_closeargs *args) | 2201 | static void nfs4_xdr_enc_open_downgrade(struct rpc_rqst *req, |
2202 | struct xdr_stream *xdr, | ||
2203 | struct nfs_closeargs *args) | ||
2008 | { | 2204 | { |
2009 | struct xdr_stream xdr; | ||
2010 | struct compound_hdr hdr = { | 2205 | struct compound_hdr hdr = { |
2011 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | 2206 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
2012 | }; | 2207 | }; |
2013 | 2208 | ||
2014 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); | 2209 | encode_compound_hdr(xdr, req, &hdr); |
2015 | encode_compound_hdr(&xdr, req, &hdr); | 2210 | encode_sequence(xdr, &args->seq_args, &hdr); |
2016 | encode_sequence(&xdr, &args->seq_args, &hdr); | 2211 | encode_putfh(xdr, args->fh, &hdr); |
2017 | encode_putfh(&xdr, args->fh, &hdr); | 2212 | encode_open_downgrade(xdr, args, &hdr); |
2018 | encode_open_downgrade(&xdr, args, &hdr); | 2213 | encode_getfattr(xdr, args->bitmask, &hdr); |
2019 | encode_getfattr(&xdr, args->bitmask, &hdr); | ||
2020 | encode_nops(&hdr); | 2214 | encode_nops(&hdr); |
2021 | return 0; | ||
2022 | } | 2215 | } |
2023 | 2216 | ||
2024 | /* | 2217 | /* |
2025 | * Encode a LOCK request | 2218 | * Encode a LOCK request |
2026 | */ | 2219 | */ |
2027 | static int nfs4_xdr_enc_lock(struct rpc_rqst *req, __be32 *p, struct nfs_lock_args *args) | 2220 | static void nfs4_xdr_enc_lock(struct rpc_rqst *req, struct xdr_stream *xdr, |
2221 | struct nfs_lock_args *args) | ||
2028 | { | 2222 | { |
2029 | struct xdr_stream xdr; | ||
2030 | struct compound_hdr hdr = { | 2223 | struct compound_hdr hdr = { |
2031 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | 2224 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
2032 | }; | 2225 | }; |
2033 | 2226 | ||
2034 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); | 2227 | encode_compound_hdr(xdr, req, &hdr); |
2035 | encode_compound_hdr(&xdr, req, &hdr); | 2228 | encode_sequence(xdr, &args->seq_args, &hdr); |
2036 | encode_sequence(&xdr, &args->seq_args, &hdr); | 2229 | encode_putfh(xdr, args->fh, &hdr); |
2037 | encode_putfh(&xdr, args->fh, &hdr); | 2230 | encode_lock(xdr, args, &hdr); |
2038 | encode_lock(&xdr, args, &hdr); | ||
2039 | encode_nops(&hdr); | 2231 | encode_nops(&hdr); |
2040 | return 0; | ||
2041 | } | 2232 | } |
2042 | 2233 | ||
2043 | /* | 2234 | /* |
2044 | * Encode a LOCKT request | 2235 | * Encode a LOCKT request |
2045 | */ | 2236 | */ |
2046 | static int nfs4_xdr_enc_lockt(struct rpc_rqst *req, __be32 *p, struct nfs_lockt_args *args) | 2237 | static void nfs4_xdr_enc_lockt(struct rpc_rqst *req, struct xdr_stream *xdr, |
2238 | struct nfs_lockt_args *args) | ||
2047 | { | 2239 | { |
2048 | struct xdr_stream xdr; | ||
2049 | struct compound_hdr hdr = { | 2240 | struct compound_hdr hdr = { |
2050 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | 2241 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
2051 | }; | 2242 | }; |
2052 | 2243 | ||
2053 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); | 2244 | encode_compound_hdr(xdr, req, &hdr); |
2054 | encode_compound_hdr(&xdr, req, &hdr); | 2245 | encode_sequence(xdr, &args->seq_args, &hdr); |
2055 | encode_sequence(&xdr, &args->seq_args, &hdr); | 2246 | encode_putfh(xdr, args->fh, &hdr); |
2056 | encode_putfh(&xdr, args->fh, &hdr); | 2247 | encode_lockt(xdr, args, &hdr); |
2057 | encode_lockt(&xdr, args, &hdr); | ||
2058 | encode_nops(&hdr); | 2248 | encode_nops(&hdr); |
2059 | return 0; | ||
2060 | } | 2249 | } |
2061 | 2250 | ||
2062 | /* | 2251 | /* |
2063 | * Encode a LOCKU request | 2252 | * Encode a LOCKU request |
2064 | */ | 2253 | */ |
2065 | static int nfs4_xdr_enc_locku(struct rpc_rqst *req, __be32 *p, struct nfs_locku_args *args) | 2254 | static void nfs4_xdr_enc_locku(struct rpc_rqst *req, struct xdr_stream *xdr, |
2255 | struct nfs_locku_args *args) | ||
2066 | { | 2256 | { |
2067 | struct xdr_stream xdr; | ||
2068 | struct compound_hdr hdr = { | 2257 | struct compound_hdr hdr = { |
2069 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | 2258 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
2070 | }; | 2259 | }; |
2071 | 2260 | ||
2072 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); | 2261 | encode_compound_hdr(xdr, req, &hdr); |
2073 | encode_compound_hdr(&xdr, req, &hdr); | 2262 | encode_sequence(xdr, &args->seq_args, &hdr); |
2074 | encode_sequence(&xdr, &args->seq_args, &hdr); | 2263 | encode_putfh(xdr, args->fh, &hdr); |
2075 | encode_putfh(&xdr, args->fh, &hdr); | 2264 | encode_locku(xdr, args, &hdr); |
2076 | encode_locku(&xdr, args, &hdr); | ||
2077 | encode_nops(&hdr); | 2265 | encode_nops(&hdr); |
2078 | return 0; | ||
2079 | } | 2266 | } |
2080 | 2267 | ||
2081 | static int nfs4_xdr_enc_release_lockowner(struct rpc_rqst *req, __be32 *p, struct nfs_release_lockowner_args *args) | 2268 | static void nfs4_xdr_enc_release_lockowner(struct rpc_rqst *req, |
2269 | struct xdr_stream *xdr, | ||
2270 | struct nfs_release_lockowner_args *args) | ||
2082 | { | 2271 | { |
2083 | struct xdr_stream xdr; | ||
2084 | struct compound_hdr hdr = { | 2272 | struct compound_hdr hdr = { |
2085 | .minorversion = 0, | 2273 | .minorversion = 0, |
2086 | }; | 2274 | }; |
2087 | 2275 | ||
2088 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); | 2276 | encode_compound_hdr(xdr, req, &hdr); |
2089 | encode_compound_hdr(&xdr, req, &hdr); | 2277 | encode_release_lockowner(xdr, &args->lock_owner, &hdr); |
2090 | encode_release_lockowner(&xdr, &args->lock_owner, &hdr); | ||
2091 | encode_nops(&hdr); | 2278 | encode_nops(&hdr); |
2092 | return 0; | ||
2093 | } | 2279 | } |
2094 | 2280 | ||
2095 | /* | 2281 | /* |
2096 | * Encode a READLINK request | 2282 | * Encode a READLINK request |
2097 | */ | 2283 | */ |
2098 | static int nfs4_xdr_enc_readlink(struct rpc_rqst *req, __be32 *p, const struct nfs4_readlink *args) | 2284 | static void nfs4_xdr_enc_readlink(struct rpc_rqst *req, struct xdr_stream *xdr, |
2285 | const struct nfs4_readlink *args) | ||
2099 | { | 2286 | { |
2100 | struct xdr_stream xdr; | ||
2101 | struct compound_hdr hdr = { | 2287 | struct compound_hdr hdr = { |
2102 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | 2288 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
2103 | }; | 2289 | }; |
2104 | 2290 | ||
2105 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); | 2291 | encode_compound_hdr(xdr, req, &hdr); |
2106 | encode_compound_hdr(&xdr, req, &hdr); | 2292 | encode_sequence(xdr, &args->seq_args, &hdr); |
2107 | encode_sequence(&xdr, &args->seq_args, &hdr); | 2293 | encode_putfh(xdr, args->fh, &hdr); |
2108 | encode_putfh(&xdr, args->fh, &hdr); | 2294 | encode_readlink(xdr, args, req, &hdr); |
2109 | encode_readlink(&xdr, args, req, &hdr); | ||
2110 | 2295 | ||
2111 | xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, args->pages, | 2296 | xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, args->pages, |
2112 | args->pgbase, args->pglen); | 2297 | args->pgbase, args->pglen); |
2113 | encode_nops(&hdr); | 2298 | encode_nops(&hdr); |
2114 | return 0; | ||
2115 | } | 2299 | } |
2116 | 2300 | ||
2117 | /* | 2301 | /* |
2118 | * Encode a READDIR request | 2302 | * Encode a READDIR request |
2119 | */ | 2303 | */ |
2120 | static int nfs4_xdr_enc_readdir(struct rpc_rqst *req, __be32 *p, const struct nfs4_readdir_arg *args) | 2304 | static void nfs4_xdr_enc_readdir(struct rpc_rqst *req, struct xdr_stream *xdr, |
2305 | const struct nfs4_readdir_arg *args) | ||
2121 | { | 2306 | { |
2122 | struct xdr_stream xdr; | ||
2123 | struct compound_hdr hdr = { | 2307 | struct compound_hdr hdr = { |
2124 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | 2308 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
2125 | }; | 2309 | }; |
2126 | 2310 | ||
2127 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); | 2311 | encode_compound_hdr(xdr, req, &hdr); |
2128 | encode_compound_hdr(&xdr, req, &hdr); | 2312 | encode_sequence(xdr, &args->seq_args, &hdr); |
2129 | encode_sequence(&xdr, &args->seq_args, &hdr); | 2313 | encode_putfh(xdr, args->fh, &hdr); |
2130 | encode_putfh(&xdr, args->fh, &hdr); | 2314 | encode_readdir(xdr, args, req, &hdr); |
2131 | encode_readdir(&xdr, args, req, &hdr); | ||
2132 | 2315 | ||
2133 | xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, args->pages, | 2316 | xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, args->pages, |
2134 | args->pgbase, args->count); | 2317 | args->pgbase, args->count); |
@@ -2136,413 +2319,477 @@ static int nfs4_xdr_enc_readdir(struct rpc_rqst *req, __be32 *p, const struct nf | |||
2136 | __func__, hdr.replen << 2, args->pages, | 2319 | __func__, hdr.replen << 2, args->pages, |
2137 | args->pgbase, args->count); | 2320 | args->pgbase, args->count); |
2138 | encode_nops(&hdr); | 2321 | encode_nops(&hdr); |
2139 | return 0; | ||
2140 | } | 2322 | } |
2141 | 2323 | ||
2142 | /* | 2324 | /* |
2143 | * Encode a READ request | 2325 | * Encode a READ request |
2144 | */ | 2326 | */ |
2145 | static int nfs4_xdr_enc_read(struct rpc_rqst *req, __be32 *p, struct nfs_readargs *args) | 2327 | static void nfs4_xdr_enc_read(struct rpc_rqst *req, struct xdr_stream *xdr, |
2328 | struct nfs_readargs *args) | ||
2146 | { | 2329 | { |
2147 | struct xdr_stream xdr; | ||
2148 | struct compound_hdr hdr = { | 2330 | struct compound_hdr hdr = { |
2149 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | 2331 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
2150 | }; | 2332 | }; |
2151 | 2333 | ||
2152 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); | 2334 | encode_compound_hdr(xdr, req, &hdr); |
2153 | encode_compound_hdr(&xdr, req, &hdr); | 2335 | encode_sequence(xdr, &args->seq_args, &hdr); |
2154 | encode_sequence(&xdr, &args->seq_args, &hdr); | 2336 | encode_putfh(xdr, args->fh, &hdr); |
2155 | encode_putfh(&xdr, args->fh, &hdr); | 2337 | encode_read(xdr, args, &hdr); |
2156 | encode_read(&xdr, args, &hdr); | ||
2157 | 2338 | ||
2158 | xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, | 2339 | xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, |
2159 | args->pages, args->pgbase, args->count); | 2340 | args->pages, args->pgbase, args->count); |
2160 | req->rq_rcv_buf.flags |= XDRBUF_READ; | 2341 | req->rq_rcv_buf.flags |= XDRBUF_READ; |
2161 | encode_nops(&hdr); | 2342 | encode_nops(&hdr); |
2162 | return 0; | ||
2163 | } | 2343 | } |
2164 | 2344 | ||
2165 | /* | 2345 | /* |
2166 | * Encode an SETATTR request | 2346 | * Encode an SETATTR request |
2167 | */ | 2347 | */ |
2168 | static int nfs4_xdr_enc_setattr(struct rpc_rqst *req, __be32 *p, struct nfs_setattrargs *args) | 2348 | static void nfs4_xdr_enc_setattr(struct rpc_rqst *req, struct xdr_stream *xdr, |
2349 | struct nfs_setattrargs *args) | ||
2169 | { | 2350 | { |
2170 | struct xdr_stream xdr; | ||
2171 | struct compound_hdr hdr = { | 2351 | struct compound_hdr hdr = { |
2172 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | 2352 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
2173 | }; | 2353 | }; |
2174 | 2354 | ||
2175 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); | 2355 | encode_compound_hdr(xdr, req, &hdr); |
2176 | encode_compound_hdr(&xdr, req, &hdr); | 2356 | encode_sequence(xdr, &args->seq_args, &hdr); |
2177 | encode_sequence(&xdr, &args->seq_args, &hdr); | 2357 | encode_putfh(xdr, args->fh, &hdr); |
2178 | encode_putfh(&xdr, args->fh, &hdr); | 2358 | encode_setattr(xdr, args, args->server, &hdr); |
2179 | encode_setattr(&xdr, args, args->server, &hdr); | 2359 | encode_getfattr(xdr, args->bitmask, &hdr); |
2180 | encode_getfattr(&xdr, args->bitmask, &hdr); | ||
2181 | encode_nops(&hdr); | 2360 | encode_nops(&hdr); |
2182 | return 0; | ||
2183 | } | 2361 | } |
2184 | 2362 | ||
2185 | /* | 2363 | /* |
2186 | * Encode a GETACL request | 2364 | * Encode a GETACL request |
2187 | */ | 2365 | */ |
2188 | static int | 2366 | static void nfs4_xdr_enc_getacl(struct rpc_rqst *req, struct xdr_stream *xdr, |
2189 | nfs4_xdr_enc_getacl(struct rpc_rqst *req, __be32 *p, | 2367 | struct nfs_getaclargs *args) |
2190 | struct nfs_getaclargs *args) | ||
2191 | { | 2368 | { |
2192 | struct xdr_stream xdr; | ||
2193 | struct compound_hdr hdr = { | 2369 | struct compound_hdr hdr = { |
2194 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | 2370 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
2195 | }; | 2371 | }; |
2196 | uint32_t replen; | 2372 | uint32_t replen; |
2197 | 2373 | ||
2198 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); | 2374 | encode_compound_hdr(xdr, req, &hdr); |
2199 | encode_compound_hdr(&xdr, req, &hdr); | 2375 | encode_sequence(xdr, &args->seq_args, &hdr); |
2200 | encode_sequence(&xdr, &args->seq_args, &hdr); | 2376 | encode_putfh(xdr, args->fh, &hdr); |
2201 | encode_putfh(&xdr, args->fh, &hdr); | ||
2202 | replen = hdr.replen + op_decode_hdr_maxsz + nfs4_fattr_bitmap_maxsz + 1; | 2377 | replen = hdr.replen + op_decode_hdr_maxsz + nfs4_fattr_bitmap_maxsz + 1; |
2203 | encode_getattr_two(&xdr, FATTR4_WORD0_ACL, 0, &hdr); | 2378 | encode_getattr_two(xdr, FATTR4_WORD0_ACL, 0, &hdr); |
2204 | 2379 | ||
2205 | xdr_inline_pages(&req->rq_rcv_buf, replen << 2, | 2380 | xdr_inline_pages(&req->rq_rcv_buf, replen << 2, |
2206 | args->acl_pages, args->acl_pgbase, args->acl_len); | 2381 | args->acl_pages, args->acl_pgbase, args->acl_len); |
2207 | encode_nops(&hdr); | 2382 | encode_nops(&hdr); |
2208 | return 0; | ||
2209 | } | 2383 | } |
2210 | 2384 | ||
2211 | /* | 2385 | /* |
2212 | * Encode a WRITE request | 2386 | * Encode a WRITE request |
2213 | */ | 2387 | */ |
2214 | static int nfs4_xdr_enc_write(struct rpc_rqst *req, __be32 *p, struct nfs_writeargs *args) | 2388 | static void nfs4_xdr_enc_write(struct rpc_rqst *req, struct xdr_stream *xdr, |
2389 | struct nfs_writeargs *args) | ||
2215 | { | 2390 | { |
2216 | struct xdr_stream xdr; | ||
2217 | struct compound_hdr hdr = { | 2391 | struct compound_hdr hdr = { |
2218 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | 2392 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
2219 | }; | 2393 | }; |
2220 | 2394 | ||
2221 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); | 2395 | encode_compound_hdr(xdr, req, &hdr); |
2222 | encode_compound_hdr(&xdr, req, &hdr); | 2396 | encode_sequence(xdr, &args->seq_args, &hdr); |
2223 | encode_sequence(&xdr, &args->seq_args, &hdr); | 2397 | encode_putfh(xdr, args->fh, &hdr); |
2224 | encode_putfh(&xdr, args->fh, &hdr); | 2398 | encode_write(xdr, args, &hdr); |
2225 | encode_write(&xdr, args, &hdr); | ||
2226 | req->rq_snd_buf.flags |= XDRBUF_WRITE; | 2399 | req->rq_snd_buf.flags |= XDRBUF_WRITE; |
2227 | encode_getfattr(&xdr, args->bitmask, &hdr); | 2400 | if (args->bitmask) |
2401 | encode_getfattr(xdr, args->bitmask, &hdr); | ||
2228 | encode_nops(&hdr); | 2402 | encode_nops(&hdr); |
2229 | return 0; | ||
2230 | } | 2403 | } |
2231 | 2404 | ||
2232 | /* | 2405 | /* |
2233 | * a COMMIT request | 2406 | * a COMMIT request |
2234 | */ | 2407 | */ |
2235 | static int nfs4_xdr_enc_commit(struct rpc_rqst *req, __be32 *p, struct nfs_writeargs *args) | 2408 | static void nfs4_xdr_enc_commit(struct rpc_rqst *req, struct xdr_stream *xdr, |
2409 | struct nfs_writeargs *args) | ||
2236 | { | 2410 | { |
2237 | struct xdr_stream xdr; | ||
2238 | struct compound_hdr hdr = { | 2411 | struct compound_hdr hdr = { |
2239 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | 2412 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
2240 | }; | 2413 | }; |
2241 | 2414 | ||
2242 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); | 2415 | encode_compound_hdr(xdr, req, &hdr); |
2243 | encode_compound_hdr(&xdr, req, &hdr); | 2416 | encode_sequence(xdr, &args->seq_args, &hdr); |
2244 | encode_sequence(&xdr, &args->seq_args, &hdr); | 2417 | encode_putfh(xdr, args->fh, &hdr); |
2245 | encode_putfh(&xdr, args->fh, &hdr); | 2418 | encode_commit(xdr, args, &hdr); |
2246 | encode_commit(&xdr, args, &hdr); | 2419 | if (args->bitmask) |
2247 | encode_getfattr(&xdr, args->bitmask, &hdr); | 2420 | encode_getfattr(xdr, args->bitmask, &hdr); |
2248 | encode_nops(&hdr); | 2421 | encode_nops(&hdr); |
2249 | return 0; | ||
2250 | } | 2422 | } |
2251 | 2423 | ||
2252 | /* | 2424 | /* |
2253 | * FSINFO request | 2425 | * FSINFO request |
2254 | */ | 2426 | */ |
2255 | static int nfs4_xdr_enc_fsinfo(struct rpc_rqst *req, __be32 *p, struct nfs4_fsinfo_arg *args) | 2427 | static void nfs4_xdr_enc_fsinfo(struct rpc_rqst *req, struct xdr_stream *xdr, |
2428 | struct nfs4_fsinfo_arg *args) | ||
2256 | { | 2429 | { |
2257 | struct xdr_stream xdr; | ||
2258 | struct compound_hdr hdr = { | 2430 | struct compound_hdr hdr = { |
2259 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | 2431 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
2260 | }; | 2432 | }; |
2261 | 2433 | ||
2262 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); | 2434 | encode_compound_hdr(xdr, req, &hdr); |
2263 | encode_compound_hdr(&xdr, req, &hdr); | 2435 | encode_sequence(xdr, &args->seq_args, &hdr); |
2264 | encode_sequence(&xdr, &args->seq_args, &hdr); | 2436 | encode_putfh(xdr, args->fh, &hdr); |
2265 | encode_putfh(&xdr, args->fh, &hdr); | 2437 | encode_fsinfo(xdr, args->bitmask, &hdr); |
2266 | encode_fsinfo(&xdr, args->bitmask, &hdr); | ||
2267 | encode_nops(&hdr); | 2438 | encode_nops(&hdr); |
2268 | return 0; | ||
2269 | } | 2439 | } |
2270 | 2440 | ||
2271 | /* | 2441 | /* |
2272 | * a PATHCONF request | 2442 | * a PATHCONF request |
2273 | */ | 2443 | */ |
2274 | static int nfs4_xdr_enc_pathconf(struct rpc_rqst *req, __be32 *p, const struct nfs4_pathconf_arg *args) | 2444 | static void nfs4_xdr_enc_pathconf(struct rpc_rqst *req, struct xdr_stream *xdr, |
2445 | const struct nfs4_pathconf_arg *args) | ||
2275 | { | 2446 | { |
2276 | struct xdr_stream xdr; | ||
2277 | struct compound_hdr hdr = { | 2447 | struct compound_hdr hdr = { |
2278 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | 2448 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
2279 | }; | 2449 | }; |
2280 | 2450 | ||
2281 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); | 2451 | encode_compound_hdr(xdr, req, &hdr); |
2282 | encode_compound_hdr(&xdr, req, &hdr); | 2452 | encode_sequence(xdr, &args->seq_args, &hdr); |
2283 | encode_sequence(&xdr, &args->seq_args, &hdr); | 2453 | encode_putfh(xdr, args->fh, &hdr); |
2284 | encode_putfh(&xdr, args->fh, &hdr); | 2454 | encode_getattr_one(xdr, args->bitmask[0] & nfs4_pathconf_bitmap[0], |
2285 | encode_getattr_one(&xdr, args->bitmask[0] & nfs4_pathconf_bitmap[0], | ||
2286 | &hdr); | 2455 | &hdr); |
2287 | encode_nops(&hdr); | 2456 | encode_nops(&hdr); |
2288 | return 0; | ||
2289 | } | 2457 | } |
2290 | 2458 | ||
2291 | /* | 2459 | /* |
2292 | * a STATFS request | 2460 | * a STATFS request |
2293 | */ | 2461 | */ |
2294 | static int nfs4_xdr_enc_statfs(struct rpc_rqst *req, __be32 *p, const struct nfs4_statfs_arg *args) | 2462 | static void nfs4_xdr_enc_statfs(struct rpc_rqst *req, struct xdr_stream *xdr, |
2463 | const struct nfs4_statfs_arg *args) | ||
2295 | { | 2464 | { |
2296 | struct xdr_stream xdr; | ||
2297 | struct compound_hdr hdr = { | 2465 | struct compound_hdr hdr = { |
2298 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | 2466 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
2299 | }; | 2467 | }; |
2300 | 2468 | ||
2301 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); | 2469 | encode_compound_hdr(xdr, req, &hdr); |
2302 | encode_compound_hdr(&xdr, req, &hdr); | 2470 | encode_sequence(xdr, &args->seq_args, &hdr); |
2303 | encode_sequence(&xdr, &args->seq_args, &hdr); | 2471 | encode_putfh(xdr, args->fh, &hdr); |
2304 | encode_putfh(&xdr, args->fh, &hdr); | 2472 | encode_getattr_two(xdr, args->bitmask[0] & nfs4_statfs_bitmap[0], |
2305 | encode_getattr_two(&xdr, args->bitmask[0] & nfs4_statfs_bitmap[0], | ||
2306 | args->bitmask[1] & nfs4_statfs_bitmap[1], &hdr); | 2473 | args->bitmask[1] & nfs4_statfs_bitmap[1], &hdr); |
2307 | encode_nops(&hdr); | 2474 | encode_nops(&hdr); |
2308 | return 0; | ||
2309 | } | 2475 | } |
2310 | 2476 | ||
2311 | /* | 2477 | /* |
2312 | * GETATTR_BITMAP request | 2478 | * GETATTR_BITMAP request |
2313 | */ | 2479 | */ |
2314 | static int nfs4_xdr_enc_server_caps(struct rpc_rqst *req, __be32 *p, | 2480 | static void nfs4_xdr_enc_server_caps(struct rpc_rqst *req, |
2315 | struct nfs4_server_caps_arg *args) | 2481 | struct xdr_stream *xdr, |
2482 | struct nfs4_server_caps_arg *args) | ||
2316 | { | 2483 | { |
2317 | struct xdr_stream xdr; | ||
2318 | struct compound_hdr hdr = { | 2484 | struct compound_hdr hdr = { |
2319 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | 2485 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
2320 | }; | 2486 | }; |
2321 | 2487 | ||
2322 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); | 2488 | encode_compound_hdr(xdr, req, &hdr); |
2323 | encode_compound_hdr(&xdr, req, &hdr); | 2489 | encode_sequence(xdr, &args->seq_args, &hdr); |
2324 | encode_sequence(&xdr, &args->seq_args, &hdr); | 2490 | encode_putfh(xdr, args->fhandle, &hdr); |
2325 | encode_putfh(&xdr, args->fhandle, &hdr); | 2491 | encode_getattr_one(xdr, FATTR4_WORD0_SUPPORTED_ATTRS| |
2326 | encode_getattr_one(&xdr, FATTR4_WORD0_SUPPORTED_ATTRS| | ||
2327 | FATTR4_WORD0_LINK_SUPPORT| | 2492 | FATTR4_WORD0_LINK_SUPPORT| |
2328 | FATTR4_WORD0_SYMLINK_SUPPORT| | 2493 | FATTR4_WORD0_SYMLINK_SUPPORT| |
2329 | FATTR4_WORD0_ACLSUPPORT, &hdr); | 2494 | FATTR4_WORD0_ACLSUPPORT, &hdr); |
2330 | encode_nops(&hdr); | 2495 | encode_nops(&hdr); |
2331 | return 0; | ||
2332 | } | 2496 | } |
2333 | 2497 | ||
2334 | /* | 2498 | /* |
2335 | * a RENEW request | 2499 | * a RENEW request |
2336 | */ | 2500 | */ |
2337 | static int nfs4_xdr_enc_renew(struct rpc_rqst *req, __be32 *p, struct nfs_client *clp) | 2501 | static void nfs4_xdr_enc_renew(struct rpc_rqst *req, struct xdr_stream *xdr, |
2502 | struct nfs_client *clp) | ||
2338 | { | 2503 | { |
2339 | struct xdr_stream xdr; | ||
2340 | struct compound_hdr hdr = { | 2504 | struct compound_hdr hdr = { |
2341 | .nops = 0, | 2505 | .nops = 0, |
2342 | }; | 2506 | }; |
2343 | 2507 | ||
2344 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); | 2508 | encode_compound_hdr(xdr, req, &hdr); |
2345 | encode_compound_hdr(&xdr, req, &hdr); | 2509 | encode_renew(xdr, clp, &hdr); |
2346 | encode_renew(&xdr, clp, &hdr); | ||
2347 | encode_nops(&hdr); | 2510 | encode_nops(&hdr); |
2348 | return 0; | ||
2349 | } | 2511 | } |
2350 | 2512 | ||
2351 | /* | 2513 | /* |
2352 | * a SETCLIENTID request | 2514 | * a SETCLIENTID request |
2353 | */ | 2515 | */ |
2354 | static int nfs4_xdr_enc_setclientid(struct rpc_rqst *req, __be32 *p, struct nfs4_setclientid *sc) | 2516 | static void nfs4_xdr_enc_setclientid(struct rpc_rqst *req, |
2517 | struct xdr_stream *xdr, | ||
2518 | struct nfs4_setclientid *sc) | ||
2355 | { | 2519 | { |
2356 | struct xdr_stream xdr; | ||
2357 | struct compound_hdr hdr = { | 2520 | struct compound_hdr hdr = { |
2358 | .nops = 0, | 2521 | .nops = 0, |
2359 | }; | 2522 | }; |
2360 | 2523 | ||
2361 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); | 2524 | encode_compound_hdr(xdr, req, &hdr); |
2362 | encode_compound_hdr(&xdr, req, &hdr); | 2525 | encode_setclientid(xdr, sc, &hdr); |
2363 | encode_setclientid(&xdr, sc, &hdr); | ||
2364 | encode_nops(&hdr); | 2526 | encode_nops(&hdr); |
2365 | return 0; | ||
2366 | } | 2527 | } |
2367 | 2528 | ||
2368 | /* | 2529 | /* |
2369 | * a SETCLIENTID_CONFIRM request | 2530 | * a SETCLIENTID_CONFIRM request |
2370 | */ | 2531 | */ |
2371 | static int nfs4_xdr_enc_setclientid_confirm(struct rpc_rqst *req, __be32 *p, struct nfs4_setclientid_res *arg) | 2532 | static void nfs4_xdr_enc_setclientid_confirm(struct rpc_rqst *req, |
2533 | struct xdr_stream *xdr, | ||
2534 | struct nfs4_setclientid_res *arg) | ||
2372 | { | 2535 | { |
2373 | struct xdr_stream xdr; | ||
2374 | struct compound_hdr hdr = { | 2536 | struct compound_hdr hdr = { |
2375 | .nops = 0, | 2537 | .nops = 0, |
2376 | }; | 2538 | }; |
2377 | const u32 lease_bitmap[2] = { FATTR4_WORD0_LEASE_TIME, 0 }; | 2539 | const u32 lease_bitmap[2] = { FATTR4_WORD0_LEASE_TIME, 0 }; |
2378 | 2540 | ||
2379 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); | 2541 | encode_compound_hdr(xdr, req, &hdr); |
2380 | encode_compound_hdr(&xdr, req, &hdr); | 2542 | encode_setclientid_confirm(xdr, arg, &hdr); |
2381 | encode_setclientid_confirm(&xdr, arg, &hdr); | 2543 | encode_putrootfh(xdr, &hdr); |
2382 | encode_putrootfh(&xdr, &hdr); | 2544 | encode_fsinfo(xdr, lease_bitmap, &hdr); |
2383 | encode_fsinfo(&xdr, lease_bitmap, &hdr); | ||
2384 | encode_nops(&hdr); | 2545 | encode_nops(&hdr); |
2385 | return 0; | ||
2386 | } | 2546 | } |
2387 | 2547 | ||
2388 | /* | 2548 | /* |
2389 | * DELEGRETURN request | 2549 | * DELEGRETURN request |
2390 | */ | 2550 | */ |
2391 | static int nfs4_xdr_enc_delegreturn(struct rpc_rqst *req, __be32 *p, const struct nfs4_delegreturnargs *args) | 2551 | static void nfs4_xdr_enc_delegreturn(struct rpc_rqst *req, |
2552 | struct xdr_stream *xdr, | ||
2553 | const struct nfs4_delegreturnargs *args) | ||
2392 | { | 2554 | { |
2393 | struct xdr_stream xdr; | ||
2394 | struct compound_hdr hdr = { | 2555 | struct compound_hdr hdr = { |
2395 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | 2556 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
2396 | }; | 2557 | }; |
2397 | 2558 | ||
2398 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); | 2559 | encode_compound_hdr(xdr, req, &hdr); |
2399 | encode_compound_hdr(&xdr, req, &hdr); | 2560 | encode_sequence(xdr, &args->seq_args, &hdr); |
2400 | encode_sequence(&xdr, &args->seq_args, &hdr); | 2561 | encode_putfh(xdr, args->fhandle, &hdr); |
2401 | encode_putfh(&xdr, args->fhandle, &hdr); | 2562 | encode_delegreturn(xdr, args->stateid, &hdr); |
2402 | encode_delegreturn(&xdr, args->stateid, &hdr); | 2563 | encode_getfattr(xdr, args->bitmask, &hdr); |
2403 | encode_getfattr(&xdr, args->bitmask, &hdr); | ||
2404 | encode_nops(&hdr); | 2564 | encode_nops(&hdr); |
2405 | return 0; | ||
2406 | } | 2565 | } |
2407 | 2566 | ||
2408 | /* | 2567 | /* |
2409 | * Encode FS_LOCATIONS request | 2568 | * Encode FS_LOCATIONS request |
2410 | */ | 2569 | */ |
2411 | static int nfs4_xdr_enc_fs_locations(struct rpc_rqst *req, __be32 *p, struct nfs4_fs_locations_arg *args) | 2570 | static void nfs4_xdr_enc_fs_locations(struct rpc_rqst *req, |
2571 | struct xdr_stream *xdr, | ||
2572 | struct nfs4_fs_locations_arg *args) | ||
2412 | { | 2573 | { |
2413 | struct xdr_stream xdr; | ||
2414 | struct compound_hdr hdr = { | 2574 | struct compound_hdr hdr = { |
2415 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | 2575 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
2416 | }; | 2576 | }; |
2417 | uint32_t replen; | 2577 | uint32_t replen; |
2418 | 2578 | ||
2419 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); | 2579 | encode_compound_hdr(xdr, req, &hdr); |
2420 | encode_compound_hdr(&xdr, req, &hdr); | 2580 | encode_sequence(xdr, &args->seq_args, &hdr); |
2421 | encode_sequence(&xdr, &args->seq_args, &hdr); | 2581 | encode_putfh(xdr, args->dir_fh, &hdr); |
2422 | encode_putfh(&xdr, args->dir_fh, &hdr); | 2582 | encode_lookup(xdr, args->name, &hdr); |
2423 | encode_lookup(&xdr, args->name, &hdr); | ||
2424 | replen = hdr.replen; /* get the attribute into args->page */ | 2583 | replen = hdr.replen; /* get the attribute into args->page */ |
2425 | encode_fs_locations(&xdr, args->bitmask, &hdr); | 2584 | encode_fs_locations(xdr, args->bitmask, &hdr); |
2426 | 2585 | ||
2427 | xdr_inline_pages(&req->rq_rcv_buf, replen << 2, &args->page, | 2586 | xdr_inline_pages(&req->rq_rcv_buf, replen << 2, &args->page, |
2428 | 0, PAGE_SIZE); | 2587 | 0, PAGE_SIZE); |
2429 | encode_nops(&hdr); | 2588 | encode_nops(&hdr); |
2430 | return 0; | 2589 | } |
2590 | |||
2591 | /* | ||
2592 | * Encode SECINFO request | ||
2593 | */ | ||
2594 | static void nfs4_xdr_enc_secinfo(struct rpc_rqst *req, | ||
2595 | struct xdr_stream *xdr, | ||
2596 | struct nfs4_secinfo_arg *args) | ||
2597 | { | ||
2598 | struct compound_hdr hdr = { | ||
2599 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | ||
2600 | }; | ||
2601 | |||
2602 | encode_compound_hdr(xdr, req, &hdr); | ||
2603 | encode_sequence(xdr, &args->seq_args, &hdr); | ||
2604 | encode_putfh(xdr, args->dir_fh, &hdr); | ||
2605 | encode_secinfo(xdr, args->name, &hdr); | ||
2606 | encode_nops(&hdr); | ||
2431 | } | 2607 | } |
2432 | 2608 | ||
2433 | #if defined(CONFIG_NFS_V4_1) | 2609 | #if defined(CONFIG_NFS_V4_1) |
2434 | /* | 2610 | /* |
2435 | * EXCHANGE_ID request | 2611 | * EXCHANGE_ID request |
2436 | */ | 2612 | */ |
2437 | static int nfs4_xdr_enc_exchange_id(struct rpc_rqst *req, uint32_t *p, | 2613 | static void nfs4_xdr_enc_exchange_id(struct rpc_rqst *req, |
2438 | struct nfs41_exchange_id_args *args) | 2614 | struct xdr_stream *xdr, |
2615 | struct nfs41_exchange_id_args *args) | ||
2439 | { | 2616 | { |
2440 | struct xdr_stream xdr; | ||
2441 | struct compound_hdr hdr = { | 2617 | struct compound_hdr hdr = { |
2442 | .minorversion = args->client->cl_mvops->minor_version, | 2618 | .minorversion = args->client->cl_mvops->minor_version, |
2443 | }; | 2619 | }; |
2444 | 2620 | ||
2445 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); | 2621 | encode_compound_hdr(xdr, req, &hdr); |
2446 | encode_compound_hdr(&xdr, req, &hdr); | 2622 | encode_exchange_id(xdr, args, &hdr); |
2447 | encode_exchange_id(&xdr, args, &hdr); | ||
2448 | encode_nops(&hdr); | 2623 | encode_nops(&hdr); |
2449 | return 0; | ||
2450 | } | 2624 | } |
2451 | 2625 | ||
2452 | /* | 2626 | /* |
2453 | * a CREATE_SESSION request | 2627 | * a CREATE_SESSION request |
2454 | */ | 2628 | */ |
2455 | static int nfs4_xdr_enc_create_session(struct rpc_rqst *req, uint32_t *p, | 2629 | static void nfs4_xdr_enc_create_session(struct rpc_rqst *req, |
2456 | struct nfs41_create_session_args *args) | 2630 | struct xdr_stream *xdr, |
2631 | struct nfs41_create_session_args *args) | ||
2457 | { | 2632 | { |
2458 | struct xdr_stream xdr; | ||
2459 | struct compound_hdr hdr = { | 2633 | struct compound_hdr hdr = { |
2460 | .minorversion = args->client->cl_mvops->minor_version, | 2634 | .minorversion = args->client->cl_mvops->minor_version, |
2461 | }; | 2635 | }; |
2462 | 2636 | ||
2463 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); | 2637 | encode_compound_hdr(xdr, req, &hdr); |
2464 | encode_compound_hdr(&xdr, req, &hdr); | 2638 | encode_create_session(xdr, args, &hdr); |
2465 | encode_create_session(&xdr, args, &hdr); | ||
2466 | encode_nops(&hdr); | 2639 | encode_nops(&hdr); |
2467 | return 0; | ||
2468 | } | 2640 | } |
2469 | 2641 | ||
2470 | /* | 2642 | /* |
2471 | * a DESTROY_SESSION request | 2643 | * a DESTROY_SESSION request |
2472 | */ | 2644 | */ |
2473 | static int nfs4_xdr_enc_destroy_session(struct rpc_rqst *req, uint32_t *p, | 2645 | static void nfs4_xdr_enc_destroy_session(struct rpc_rqst *req, |
2474 | struct nfs4_session *session) | 2646 | struct xdr_stream *xdr, |
2647 | struct nfs4_session *session) | ||
2475 | { | 2648 | { |
2476 | struct xdr_stream xdr; | ||
2477 | struct compound_hdr hdr = { | 2649 | struct compound_hdr hdr = { |
2478 | .minorversion = session->clp->cl_mvops->minor_version, | 2650 | .minorversion = session->clp->cl_mvops->minor_version, |
2479 | }; | 2651 | }; |
2480 | 2652 | ||
2481 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); | 2653 | encode_compound_hdr(xdr, req, &hdr); |
2482 | encode_compound_hdr(&xdr, req, &hdr); | 2654 | encode_destroy_session(xdr, session, &hdr); |
2483 | encode_destroy_session(&xdr, session, &hdr); | ||
2484 | encode_nops(&hdr); | 2655 | encode_nops(&hdr); |
2485 | return 0; | ||
2486 | } | 2656 | } |
2487 | 2657 | ||
2488 | /* | 2658 | /* |
2489 | * a SEQUENCE request | 2659 | * a SEQUENCE request |
2490 | */ | 2660 | */ |
2491 | static int nfs4_xdr_enc_sequence(struct rpc_rqst *req, uint32_t *p, | 2661 | static void nfs4_xdr_enc_sequence(struct rpc_rqst *req, struct xdr_stream *xdr, |
2492 | struct nfs4_sequence_args *args) | 2662 | struct nfs4_sequence_args *args) |
2493 | { | 2663 | { |
2494 | struct xdr_stream xdr; | ||
2495 | struct compound_hdr hdr = { | 2664 | struct compound_hdr hdr = { |
2496 | .minorversion = nfs4_xdr_minorversion(args), | 2665 | .minorversion = nfs4_xdr_minorversion(args), |
2497 | }; | 2666 | }; |
2498 | 2667 | ||
2499 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); | 2668 | encode_compound_hdr(xdr, req, &hdr); |
2500 | encode_compound_hdr(&xdr, req, &hdr); | 2669 | encode_sequence(xdr, args, &hdr); |
2501 | encode_sequence(&xdr, args, &hdr); | ||
2502 | encode_nops(&hdr); | 2670 | encode_nops(&hdr); |
2503 | return 0; | ||
2504 | } | 2671 | } |
2505 | 2672 | ||
2506 | /* | 2673 | /* |
2507 | * a GET_LEASE_TIME request | 2674 | * a GET_LEASE_TIME request |
2508 | */ | 2675 | */ |
2509 | static int nfs4_xdr_enc_get_lease_time(struct rpc_rqst *req, uint32_t *p, | 2676 | static void nfs4_xdr_enc_get_lease_time(struct rpc_rqst *req, |
2510 | struct nfs4_get_lease_time_args *args) | 2677 | struct xdr_stream *xdr, |
2678 | struct nfs4_get_lease_time_args *args) | ||
2511 | { | 2679 | { |
2512 | struct xdr_stream xdr; | ||
2513 | struct compound_hdr hdr = { | 2680 | struct compound_hdr hdr = { |
2514 | .minorversion = nfs4_xdr_minorversion(&args->la_seq_args), | 2681 | .minorversion = nfs4_xdr_minorversion(&args->la_seq_args), |
2515 | }; | 2682 | }; |
2516 | const u32 lease_bitmap[2] = { FATTR4_WORD0_LEASE_TIME, 0 }; | 2683 | const u32 lease_bitmap[2] = { FATTR4_WORD0_LEASE_TIME, 0 }; |
2517 | 2684 | ||
2518 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); | 2685 | encode_compound_hdr(xdr, req, &hdr); |
2519 | encode_compound_hdr(&xdr, req, &hdr); | 2686 | encode_sequence(xdr, &args->la_seq_args, &hdr); |
2520 | encode_sequence(&xdr, &args->la_seq_args, &hdr); | 2687 | encode_putrootfh(xdr, &hdr); |
2521 | encode_putrootfh(&xdr, &hdr); | 2688 | encode_fsinfo(xdr, lease_bitmap, &hdr); |
2522 | encode_fsinfo(&xdr, lease_bitmap, &hdr); | ||
2523 | encode_nops(&hdr); | 2689 | encode_nops(&hdr); |
2524 | return 0; | ||
2525 | } | 2690 | } |
2526 | 2691 | ||
2527 | /* | 2692 | /* |
2528 | * a RECLAIM_COMPLETE request | 2693 | * a RECLAIM_COMPLETE request |
2529 | */ | 2694 | */ |
2530 | static int nfs4_xdr_enc_reclaim_complete(struct rpc_rqst *req, uint32_t *p, | 2695 | static void nfs4_xdr_enc_reclaim_complete(struct rpc_rqst *req, |
2531 | struct nfs41_reclaim_complete_args *args) | 2696 | struct xdr_stream *xdr, |
2697 | struct nfs41_reclaim_complete_args *args) | ||
2532 | { | 2698 | { |
2533 | struct xdr_stream xdr; | ||
2534 | struct compound_hdr hdr = { | 2699 | struct compound_hdr hdr = { |
2535 | .minorversion = nfs4_xdr_minorversion(&args->seq_args) | 2700 | .minorversion = nfs4_xdr_minorversion(&args->seq_args) |
2536 | }; | 2701 | }; |
2537 | 2702 | ||
2538 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); | 2703 | encode_compound_hdr(xdr, req, &hdr); |
2539 | encode_compound_hdr(&xdr, req, &hdr); | 2704 | encode_sequence(xdr, &args->seq_args, &hdr); |
2540 | encode_sequence(&xdr, &args->seq_args, &hdr); | 2705 | encode_reclaim_complete(xdr, args, &hdr); |
2541 | encode_reclaim_complete(&xdr, args, &hdr); | 2706 | encode_nops(&hdr); |
2707 | } | ||
2708 | |||
2709 | /* | ||
2710 | * Encode GETDEVICEINFO request | ||
2711 | */ | ||
2712 | static void nfs4_xdr_enc_getdeviceinfo(struct rpc_rqst *req, | ||
2713 | struct xdr_stream *xdr, | ||
2714 | struct nfs4_getdeviceinfo_args *args) | ||
2715 | { | ||
2716 | struct compound_hdr hdr = { | ||
2717 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | ||
2718 | }; | ||
2719 | |||
2720 | encode_compound_hdr(xdr, req, &hdr); | ||
2721 | encode_sequence(xdr, &args->seq_args, &hdr); | ||
2722 | encode_getdeviceinfo(xdr, args, &hdr); | ||
2723 | |||
2724 | /* set up reply kvec. Subtract notification bitmap max size (2) | ||
2725 | * so that notification bitmap is put in xdr_buf tail */ | ||
2726 | xdr_inline_pages(&req->rq_rcv_buf, (hdr.replen - 2) << 2, | ||
2727 | args->pdev->pages, args->pdev->pgbase, | ||
2728 | args->pdev->pglen); | ||
2729 | |||
2730 | encode_nops(&hdr); | ||
2731 | } | ||
2732 | |||
2733 | /* | ||
2734 | * Encode LAYOUTGET request | ||
2735 | */ | ||
2736 | static void nfs4_xdr_enc_layoutget(struct rpc_rqst *req, | ||
2737 | struct xdr_stream *xdr, | ||
2738 | struct nfs4_layoutget_args *args) | ||
2739 | { | ||
2740 | struct compound_hdr hdr = { | ||
2741 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | ||
2742 | }; | ||
2743 | |||
2744 | encode_compound_hdr(xdr, req, &hdr); | ||
2745 | encode_sequence(xdr, &args->seq_args, &hdr); | ||
2746 | encode_putfh(xdr, NFS_FH(args->inode), &hdr); | ||
2747 | encode_layoutget(xdr, args, &hdr); | ||
2748 | |||
2749 | xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, | ||
2750 | args->layout.pages, 0, args->layout.pglen); | ||
2751 | |||
2752 | encode_nops(&hdr); | ||
2753 | } | ||
2754 | |||
2755 | /* | ||
2756 | * Encode LAYOUTCOMMIT request | ||
2757 | */ | ||
2758 | static void nfs4_xdr_enc_layoutcommit(struct rpc_rqst *req, | ||
2759 | struct xdr_stream *xdr, | ||
2760 | struct nfs4_layoutcommit_args *args) | ||
2761 | { | ||
2762 | struct nfs4_layoutcommit_data *data = | ||
2763 | container_of(args, struct nfs4_layoutcommit_data, args); | ||
2764 | struct compound_hdr hdr = { | ||
2765 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | ||
2766 | }; | ||
2767 | |||
2768 | encode_compound_hdr(xdr, req, &hdr); | ||
2769 | encode_sequence(xdr, &args->seq_args, &hdr); | ||
2770 | encode_putfh(xdr, NFS_FH(args->inode), &hdr); | ||
2771 | encode_layoutcommit(xdr, data->args.inode, args, &hdr); | ||
2772 | encode_getfattr(xdr, args->bitmask, &hdr); | ||
2542 | encode_nops(&hdr); | 2773 | encode_nops(&hdr); |
2543 | return 0; | ||
2544 | } | 2774 | } |
2545 | 2775 | ||
2776 | /* | ||
2777 | * Encode LAYOUTRETURN request | ||
2778 | */ | ||
2779 | static void nfs4_xdr_enc_layoutreturn(struct rpc_rqst *req, | ||
2780 | struct xdr_stream *xdr, | ||
2781 | struct nfs4_layoutreturn_args *args) | ||
2782 | { | ||
2783 | struct compound_hdr hdr = { | ||
2784 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | ||
2785 | }; | ||
2786 | |||
2787 | encode_compound_hdr(xdr, req, &hdr); | ||
2788 | encode_sequence(xdr, &args->seq_args, &hdr); | ||
2789 | encode_putfh(xdr, NFS_FH(args->inode), &hdr); | ||
2790 | encode_layoutreturn(xdr, args, &hdr); | ||
2791 | encode_nops(&hdr); | ||
2792 | } | ||
2546 | #endif /* CONFIG_NFS_V4_1 */ | 2793 | #endif /* CONFIG_NFS_V4_1 */ |
2547 | 2794 | ||
2548 | static void print_overflow_msg(const char *func, const struct xdr_stream *xdr) | 2795 | static void print_overflow_msg(const char *func, const struct xdr_stream *xdr) |
@@ -2676,7 +2923,10 @@ out_overflow: | |||
2676 | static int decode_attr_supported(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *bitmask) | 2923 | static int decode_attr_supported(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *bitmask) |
2677 | { | 2924 | { |
2678 | if (likely(bitmap[0] & FATTR4_WORD0_SUPPORTED_ATTRS)) { | 2925 | if (likely(bitmap[0] & FATTR4_WORD0_SUPPORTED_ATTRS)) { |
2679 | decode_attr_bitmap(xdr, bitmask); | 2926 | int ret; |
2927 | ret = decode_attr_bitmap(xdr, bitmask); | ||
2928 | if (unlikely(ret < 0)) | ||
2929 | return ret; | ||
2680 | bitmap[0] &= ~FATTR4_WORD0_SUPPORTED_ATTRS; | 2930 | bitmap[0] &= ~FATTR4_WORD0_SUPPORTED_ATTRS; |
2681 | } else | 2931 | } else |
2682 | bitmask[0] = bitmask[1] = 0; | 2932 | bitmask[0] = bitmask[1] = 0; |
@@ -2848,6 +3098,57 @@ out_overflow: | |||
2848 | return -EIO; | 3098 | return -EIO; |
2849 | } | 3099 | } |
2850 | 3100 | ||
3101 | static int decode_attr_error(struct xdr_stream *xdr, uint32_t *bitmap, int32_t *res) | ||
3102 | { | ||
3103 | __be32 *p; | ||
3104 | |||
3105 | if (unlikely(bitmap[0] & (FATTR4_WORD0_RDATTR_ERROR - 1U))) | ||
3106 | return -EIO; | ||
3107 | if (likely(bitmap[0] & FATTR4_WORD0_RDATTR_ERROR)) { | ||
3108 | p = xdr_inline_decode(xdr, 4); | ||
3109 | if (unlikely(!p)) | ||
3110 | goto out_overflow; | ||
3111 | bitmap[0] &= ~FATTR4_WORD0_RDATTR_ERROR; | ||
3112 | *res = -be32_to_cpup(p); | ||
3113 | } | ||
3114 | return 0; | ||
3115 | out_overflow: | ||
3116 | print_overflow_msg(__func__, xdr); | ||
3117 | return -EIO; | ||
3118 | } | ||
3119 | |||
3120 | static int decode_attr_filehandle(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs_fh *fh) | ||
3121 | { | ||
3122 | __be32 *p; | ||
3123 | int len; | ||
3124 | |||
3125 | if (fh != NULL) | ||
3126 | memset(fh, 0, sizeof(*fh)); | ||
3127 | |||
3128 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILEHANDLE - 1U))) | ||
3129 | return -EIO; | ||
3130 | if (likely(bitmap[0] & FATTR4_WORD0_FILEHANDLE)) { | ||
3131 | p = xdr_inline_decode(xdr, 4); | ||
3132 | if (unlikely(!p)) | ||
3133 | goto out_overflow; | ||
3134 | len = be32_to_cpup(p); | ||
3135 | if (len > NFS4_FHSIZE) | ||
3136 | return -EIO; | ||
3137 | p = xdr_inline_decode(xdr, len); | ||
3138 | if (unlikely(!p)) | ||
3139 | goto out_overflow; | ||
3140 | if (fh != NULL) { | ||
3141 | memcpy(fh->data, p, len); | ||
3142 | fh->size = len; | ||
3143 | } | ||
3144 | bitmap[0] &= ~FATTR4_WORD0_FILEHANDLE; | ||
3145 | } | ||
3146 | return 0; | ||
3147 | out_overflow: | ||
3148 | print_overflow_msg(__func__, xdr); | ||
3149 | return -EIO; | ||
3150 | } | ||
3151 | |||
2851 | static int decode_attr_aclsupport(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) | 3152 | static int decode_attr_aclsupport(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
2852 | { | 3153 | { |
2853 | __be32 *p; | 3154 | __be32 *p; |
@@ -2906,7 +3207,7 @@ static int decode_attr_mounted_on_fileid(struct xdr_stream *xdr, uint32_t *bitma | |||
2906 | goto out_overflow; | 3207 | goto out_overflow; |
2907 | xdr_decode_hyper(p, fileid); | 3208 | xdr_decode_hyper(p, fileid); |
2908 | bitmap[1] &= ~FATTR4_WORD1_MOUNTED_ON_FILEID; | 3209 | bitmap[1] &= ~FATTR4_WORD1_MOUNTED_ON_FILEID; |
2909 | ret = NFS_ATTR_FATTR_FILEID; | 3210 | ret = NFS_ATTR_FATTR_MOUNTED_ON_FILEID; |
2910 | } | 3211 | } |
2911 | dprintk("%s: fileid=%Lu\n", __func__, (unsigned long long)*fileid); | 3212 | dprintk("%s: fileid=%Lu\n", __func__, (unsigned long long)*fileid); |
2912 | return ret; | 3213 | return ret; |
@@ -3271,7 +3572,7 @@ out_overflow: | |||
3271 | } | 3572 | } |
3272 | 3573 | ||
3273 | static int decode_attr_owner(struct xdr_stream *xdr, uint32_t *bitmap, | 3574 | static int decode_attr_owner(struct xdr_stream *xdr, uint32_t *bitmap, |
3274 | struct nfs_client *clp, uint32_t *uid, int may_sleep) | 3575 | const struct nfs_server *server, uint32_t *uid, int may_sleep) |
3275 | { | 3576 | { |
3276 | uint32_t len; | 3577 | uint32_t len; |
3277 | __be32 *p; | 3578 | __be32 *p; |
@@ -3291,7 +3592,7 @@ static int decode_attr_owner(struct xdr_stream *xdr, uint32_t *bitmap, | |||
3291 | if (!may_sleep) { | 3592 | if (!may_sleep) { |
3292 | /* do nothing */ | 3593 | /* do nothing */ |
3293 | } else if (len < XDR_MAX_NETOBJ) { | 3594 | } else if (len < XDR_MAX_NETOBJ) { |
3294 | if (nfs_map_name_to_uid(clp, (char *)p, len, uid) == 0) | 3595 | if (nfs_map_name_to_uid(server, (char *)p, len, uid) == 0) |
3295 | ret = NFS_ATTR_FATTR_OWNER; | 3596 | ret = NFS_ATTR_FATTR_OWNER; |
3296 | else | 3597 | else |
3297 | dprintk("%s: nfs_map_name_to_uid failed!\n", | 3598 | dprintk("%s: nfs_map_name_to_uid failed!\n", |
@@ -3309,7 +3610,7 @@ out_overflow: | |||
3309 | } | 3610 | } |
3310 | 3611 | ||
3311 | static int decode_attr_group(struct xdr_stream *xdr, uint32_t *bitmap, | 3612 | static int decode_attr_group(struct xdr_stream *xdr, uint32_t *bitmap, |
3312 | struct nfs_client *clp, uint32_t *gid, int may_sleep) | 3613 | const struct nfs_server *server, uint32_t *gid, int may_sleep) |
3313 | { | 3614 | { |
3314 | uint32_t len; | 3615 | uint32_t len; |
3315 | __be32 *p; | 3616 | __be32 *p; |
@@ -3329,7 +3630,7 @@ static int decode_attr_group(struct xdr_stream *xdr, uint32_t *bitmap, | |||
3329 | if (!may_sleep) { | 3630 | if (!may_sleep) { |
3330 | /* do nothing */ | 3631 | /* do nothing */ |
3331 | } else if (len < XDR_MAX_NETOBJ) { | 3632 | } else if (len < XDR_MAX_NETOBJ) { |
3332 | if (nfs_map_group_to_gid(clp, (char *)p, len, gid) == 0) | 3633 | if (nfs_map_group_to_gid(server, (char *)p, len, gid) == 0) |
3333 | ret = NFS_ATTR_FATTR_GROUP; | 3634 | ret = NFS_ATTR_FATTR_GROUP; |
3334 | else | 3635 | else |
3335 | dprintk("%s: nfs_map_group_to_gid failed!\n", | 3636 | dprintk("%s: nfs_map_group_to_gid failed!\n", |
@@ -3521,6 +3822,24 @@ static int decode_attr_time_metadata(struct xdr_stream *xdr, uint32_t *bitmap, s | |||
3521 | return status; | 3822 | return status; |
3522 | } | 3823 | } |
3523 | 3824 | ||
3825 | static int decode_attr_time_delta(struct xdr_stream *xdr, uint32_t *bitmap, | ||
3826 | struct timespec *time) | ||
3827 | { | ||
3828 | int status = 0; | ||
3829 | |||
3830 | time->tv_sec = 0; | ||
3831 | time->tv_nsec = 0; | ||
3832 | if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_DELTA - 1U))) | ||
3833 | return -EIO; | ||
3834 | if (likely(bitmap[1] & FATTR4_WORD1_TIME_DELTA)) { | ||
3835 | status = decode_attr_time(xdr, time); | ||
3836 | bitmap[1] &= ~FATTR4_WORD1_TIME_DELTA; | ||
3837 | } | ||
3838 | dprintk("%s: time_delta=%ld %ld\n", __func__, (long)time->tv_sec, | ||
3839 | (long)time->tv_nsec); | ||
3840 | return status; | ||
3841 | } | ||
3842 | |||
3524 | static int decode_attr_time_modify(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec *time) | 3843 | static int decode_attr_time_modify(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec *time) |
3525 | { | 3844 | { |
3526 | int status = 0; | 3845 | int status = 0; |
@@ -3744,29 +4063,14 @@ xdr_error: | |||
3744 | return status; | 4063 | return status; |
3745 | } | 4064 | } |
3746 | 4065 | ||
3747 | static int decode_getfattr(struct xdr_stream *xdr, struct nfs_fattr *fattr, | 4066 | static int decode_getfattr_attrs(struct xdr_stream *xdr, uint32_t *bitmap, |
4067 | struct nfs_fattr *fattr, struct nfs_fh *fh, | ||
3748 | const struct nfs_server *server, int may_sleep) | 4068 | const struct nfs_server *server, int may_sleep) |
3749 | { | 4069 | { |
3750 | __be32 *savep; | ||
3751 | uint32_t attrlen, | ||
3752 | bitmap[2] = {0}, | ||
3753 | type; | ||
3754 | int status; | 4070 | int status; |
3755 | umode_t fmode = 0; | 4071 | umode_t fmode = 0; |
3756 | uint64_t fileid; | 4072 | uint32_t type; |
3757 | 4073 | int32_t err; | |
3758 | status = decode_op_hdr(xdr, OP_GETATTR); | ||
3759 | if (status < 0) | ||
3760 | goto xdr_error; | ||
3761 | |||
3762 | status = decode_attr_bitmap(xdr, bitmap); | ||
3763 | if (status < 0) | ||
3764 | goto xdr_error; | ||
3765 | |||
3766 | status = decode_attr_length(xdr, &attrlen, &savep); | ||
3767 | if (status < 0) | ||
3768 | goto xdr_error; | ||
3769 | |||
3770 | 4074 | ||
3771 | status = decode_attr_type(xdr, bitmap, &type); | 4075 | status = decode_attr_type(xdr, bitmap, &type); |
3772 | if (status < 0) | 4076 | if (status < 0) |
@@ -3792,6 +4096,17 @@ static int decode_getfattr(struct xdr_stream *xdr, struct nfs_fattr *fattr, | |||
3792 | goto xdr_error; | 4096 | goto xdr_error; |
3793 | fattr->valid |= status; | 4097 | fattr->valid |= status; |
3794 | 4098 | ||
4099 | err = 0; | ||
4100 | status = decode_attr_error(xdr, bitmap, &err); | ||
4101 | if (status < 0) | ||
4102 | goto xdr_error; | ||
4103 | if (err == -NFS4ERR_WRONGSEC) | ||
4104 | nfs_fixup_secinfo_attributes(fattr, fh); | ||
4105 | |||
4106 | status = decode_attr_filehandle(xdr, bitmap, fh); | ||
4107 | if (status < 0) | ||
4108 | goto xdr_error; | ||
4109 | |||
3795 | status = decode_attr_fileid(xdr, bitmap, &fattr->fileid); | 4110 | status = decode_attr_fileid(xdr, bitmap, &fattr->fileid); |
3796 | if (status < 0) | 4111 | if (status < 0) |
3797 | goto xdr_error; | 4112 | goto xdr_error; |
@@ -3817,14 +4132,12 @@ static int decode_getfattr(struct xdr_stream *xdr, struct nfs_fattr *fattr, | |||
3817 | goto xdr_error; | 4132 | goto xdr_error; |
3818 | fattr->valid |= status; | 4133 | fattr->valid |= status; |
3819 | 4134 | ||
3820 | status = decode_attr_owner(xdr, bitmap, server->nfs_client, | 4135 | status = decode_attr_owner(xdr, bitmap, server, &fattr->uid, may_sleep); |
3821 | &fattr->uid, may_sleep); | ||
3822 | if (status < 0) | 4136 | if (status < 0) |
3823 | goto xdr_error; | 4137 | goto xdr_error; |
3824 | fattr->valid |= status; | 4138 | fattr->valid |= status; |
3825 | 4139 | ||
3826 | status = decode_attr_group(xdr, bitmap, server->nfs_client, | 4140 | status = decode_attr_group(xdr, bitmap, server, &fattr->gid, may_sleep); |
3827 | &fattr->gid, may_sleep); | ||
3828 | if (status < 0) | 4141 | if (status < 0) |
3829 | goto xdr_error; | 4142 | goto xdr_error; |
3830 | fattr->valid |= status; | 4143 | fattr->valid |= status; |
@@ -3854,13 +4167,39 @@ static int decode_getfattr(struct xdr_stream *xdr, struct nfs_fattr *fattr, | |||
3854 | goto xdr_error; | 4167 | goto xdr_error; |
3855 | fattr->valid |= status; | 4168 | fattr->valid |= status; |
3856 | 4169 | ||
3857 | status = decode_attr_mounted_on_fileid(xdr, bitmap, &fileid); | 4170 | status = decode_attr_mounted_on_fileid(xdr, bitmap, &fattr->mounted_on_fileid); |
4171 | if (status < 0) | ||
4172 | goto xdr_error; | ||
4173 | fattr->valid |= status; | ||
4174 | |||
4175 | xdr_error: | ||
4176 | dprintk("%s: xdr returned %d\n", __func__, -status); | ||
4177 | return status; | ||
4178 | } | ||
4179 | |||
4180 | static int decode_getfattr_generic(struct xdr_stream *xdr, struct nfs_fattr *fattr, | ||
4181 | struct nfs_fh *fh, const struct nfs_server *server, int may_sleep) | ||
4182 | { | ||
4183 | __be32 *savep; | ||
4184 | uint32_t attrlen, | ||
4185 | bitmap[2] = {0}; | ||
4186 | int status; | ||
4187 | |||
4188 | status = decode_op_hdr(xdr, OP_GETATTR); | ||
4189 | if (status < 0) | ||
4190 | goto xdr_error; | ||
4191 | |||
4192 | status = decode_attr_bitmap(xdr, bitmap); | ||
4193 | if (status < 0) | ||
4194 | goto xdr_error; | ||
4195 | |||
4196 | status = decode_attr_length(xdr, &attrlen, &savep); | ||
4197 | if (status < 0) | ||
4198 | goto xdr_error; | ||
4199 | |||
4200 | status = decode_getfattr_attrs(xdr, bitmap, fattr, fh, server, may_sleep); | ||
3858 | if (status < 0) | 4201 | if (status < 0) |
3859 | goto xdr_error; | 4202 | goto xdr_error; |
3860 | if (status != 0 && !(fattr->valid & status)) { | ||
3861 | fattr->fileid = fileid; | ||
3862 | fattr->valid |= status; | ||
3863 | } | ||
3864 | 4203 | ||
3865 | status = verify_attr_len(xdr, savep, attrlen); | 4204 | status = verify_attr_len(xdr, savep, attrlen); |
3866 | xdr_error: | 4205 | xdr_error: |
@@ -3868,6 +4207,66 @@ xdr_error: | |||
3868 | return status; | 4207 | return status; |
3869 | } | 4208 | } |
3870 | 4209 | ||
4210 | static int decode_getfattr(struct xdr_stream *xdr, struct nfs_fattr *fattr, | ||
4211 | const struct nfs_server *server, int may_sleep) | ||
4212 | { | ||
4213 | return decode_getfattr_generic(xdr, fattr, NULL, server, may_sleep); | ||
4214 | } | ||
4215 | |||
4216 | /* | ||
4217 | * Decode potentially multiple layout types. Currently we only support | ||
4218 | * one layout driver per file system. | ||
4219 | */ | ||
4220 | static int decode_first_pnfs_layout_type(struct xdr_stream *xdr, | ||
4221 | uint32_t *layouttype) | ||
4222 | { | ||
4223 | uint32_t *p; | ||
4224 | int num; | ||
4225 | |||
4226 | p = xdr_inline_decode(xdr, 4); | ||
4227 | if (unlikely(!p)) | ||
4228 | goto out_overflow; | ||
4229 | num = be32_to_cpup(p); | ||
4230 | |||
4231 | /* pNFS is not supported by the underlying file system */ | ||
4232 | if (num == 0) { | ||
4233 | *layouttype = 0; | ||
4234 | return 0; | ||
4235 | } | ||
4236 | if (num > 1) | ||
4237 | printk(KERN_INFO "%s: Warning: Multiple pNFS layout drivers " | ||
4238 | "per filesystem not supported\n", __func__); | ||
4239 | |||
4240 | /* Decode and set first layout type, move xdr->p past unused types */ | ||
4241 | p = xdr_inline_decode(xdr, num * 4); | ||
4242 | if (unlikely(!p)) | ||
4243 | goto out_overflow; | ||
4244 | *layouttype = be32_to_cpup(p); | ||
4245 | return 0; | ||
4246 | out_overflow: | ||
4247 | print_overflow_msg(__func__, xdr); | ||
4248 | return -EIO; | ||
4249 | } | ||
4250 | |||
4251 | /* | ||
4252 | * The type of file system exported. | ||
4253 | * Note we must ensure that layouttype is set in any non-error case. | ||
4254 | */ | ||
4255 | static int decode_attr_pnfstype(struct xdr_stream *xdr, uint32_t *bitmap, | ||
4256 | uint32_t *layouttype) | ||
4257 | { | ||
4258 | int status = 0; | ||
4259 | |||
4260 | dprintk("%s: bitmap is %x\n", __func__, bitmap[1]); | ||
4261 | if (unlikely(bitmap[1] & (FATTR4_WORD1_FS_LAYOUT_TYPES - 1U))) | ||
4262 | return -EIO; | ||
4263 | if (bitmap[1] & FATTR4_WORD1_FS_LAYOUT_TYPES) { | ||
4264 | status = decode_first_pnfs_layout_type(xdr, layouttype); | ||
4265 | bitmap[1] &= ~FATTR4_WORD1_FS_LAYOUT_TYPES; | ||
4266 | } else | ||
4267 | *layouttype = 0; | ||
4268 | return status; | ||
4269 | } | ||
3871 | 4270 | ||
3872 | static int decode_fsinfo(struct xdr_stream *xdr, struct nfs_fsinfo *fsinfo) | 4271 | static int decode_fsinfo(struct xdr_stream *xdr, struct nfs_fsinfo *fsinfo) |
3873 | { | 4272 | { |
@@ -3894,6 +4293,12 @@ static int decode_fsinfo(struct xdr_stream *xdr, struct nfs_fsinfo *fsinfo) | |||
3894 | if ((status = decode_attr_maxwrite(xdr, bitmap, &fsinfo->wtmax)) != 0) | 4293 | if ((status = decode_attr_maxwrite(xdr, bitmap, &fsinfo->wtmax)) != 0) |
3895 | goto xdr_error; | 4294 | goto xdr_error; |
3896 | fsinfo->wtpref = fsinfo->wtmax; | 4295 | fsinfo->wtpref = fsinfo->wtmax; |
4296 | status = decode_attr_time_delta(xdr, bitmap, &fsinfo->time_delta); | ||
4297 | if (status != 0) | ||
4298 | goto xdr_error; | ||
4299 | status = decode_attr_pnfstype(xdr, bitmap, &fsinfo->layouttype); | ||
4300 | if (status != 0) | ||
4301 | goto xdr_error; | ||
3897 | 4302 | ||
3898 | status = verify_attr_len(xdr, savep, attrlen); | 4303 | status = verify_attr_len(xdr, savep, attrlen); |
3899 | xdr_error: | 4304 | xdr_error: |
@@ -3950,13 +4355,13 @@ static int decode_lock_denied (struct xdr_stream *xdr, struct file_lock *fl) | |||
3950 | __be32 *p; | 4355 | __be32 *p; |
3951 | uint32_t namelen, type; | 4356 | uint32_t namelen, type; |
3952 | 4357 | ||
3953 | p = xdr_inline_decode(xdr, 32); | 4358 | p = xdr_inline_decode(xdr, 32); /* read 32 bytes */ |
3954 | if (unlikely(!p)) | 4359 | if (unlikely(!p)) |
3955 | goto out_overflow; | 4360 | goto out_overflow; |
3956 | p = xdr_decode_hyper(p, &offset); | 4361 | p = xdr_decode_hyper(p, &offset); /* read 2 8-byte long words */ |
3957 | p = xdr_decode_hyper(p, &length); | 4362 | p = xdr_decode_hyper(p, &length); |
3958 | type = be32_to_cpup(p++); | 4363 | type = be32_to_cpup(p++); /* 4 byte read */ |
3959 | if (fl != NULL) { | 4364 | if (fl != NULL) { /* manipulate file lock */ |
3960 | fl->fl_start = (loff_t)offset; | 4365 | fl->fl_start = (loff_t)offset; |
3961 | fl->fl_end = fl->fl_start + (loff_t)length - 1; | 4366 | fl->fl_end = fl->fl_start + (loff_t)length - 1; |
3962 | if (length == ~(uint64_t)0) | 4367 | if (length == ~(uint64_t)0) |
@@ -3966,9 +4371,9 @@ static int decode_lock_denied (struct xdr_stream *xdr, struct file_lock *fl) | |||
3966 | fl->fl_type = F_RDLCK; | 4371 | fl->fl_type = F_RDLCK; |
3967 | fl->fl_pid = 0; | 4372 | fl->fl_pid = 0; |
3968 | } | 4373 | } |
3969 | p = xdr_decode_hyper(p, &clientid); | 4374 | p = xdr_decode_hyper(p, &clientid); /* read 8 bytes */ |
3970 | namelen = be32_to_cpup(p); | 4375 | namelen = be32_to_cpup(p); /* read 4 bytes */ /* have read all 32 bytes now */ |
3971 | p = xdr_inline_decode(xdr, namelen); | 4376 | p = xdr_inline_decode(xdr, namelen); /* variable size field */ |
3972 | if (likely(p)) | 4377 | if (likely(p)) |
3973 | return -NFS4ERR_DENIED; | 4378 | return -NFS4ERR_DENIED; |
3974 | out_overflow: | 4379 | out_overflow: |
@@ -4180,7 +4585,7 @@ static int decode_read(struct xdr_stream *xdr, struct rpc_rqst *req, struct nfs_ | |||
4180 | goto out_overflow; | 4585 | goto out_overflow; |
4181 | eof = be32_to_cpup(p++); | 4586 | eof = be32_to_cpup(p++); |
4182 | count = be32_to_cpup(p); | 4587 | count = be32_to_cpup(p); |
4183 | hdrlen = (u8 *) p - (u8 *) iov->iov_base; | 4588 | hdrlen = (u8 *) xdr->p - (u8 *) iov->iov_base; |
4184 | recvd = req->rq_rcv_buf.len - hdrlen; | 4589 | recvd = req->rq_rcv_buf.len - hdrlen; |
4185 | if (count > recvd) { | 4590 | if (count > recvd) { |
4186 | dprintk("NFS: server cheating in read reply: " | 4591 | dprintk("NFS: server cheating in read reply: " |
@@ -4200,12 +4605,9 @@ out_overflow: | |||
4200 | static int decode_readdir(struct xdr_stream *xdr, struct rpc_rqst *req, struct nfs4_readdir_res *readdir) | 4605 | static int decode_readdir(struct xdr_stream *xdr, struct rpc_rqst *req, struct nfs4_readdir_res *readdir) |
4201 | { | 4606 | { |
4202 | struct xdr_buf *rcvbuf = &req->rq_rcv_buf; | 4607 | struct xdr_buf *rcvbuf = &req->rq_rcv_buf; |
4203 | struct page *page = *rcvbuf->pages; | ||
4204 | struct kvec *iov = rcvbuf->head; | 4608 | struct kvec *iov = rcvbuf->head; |
4205 | size_t hdrlen; | 4609 | size_t hdrlen; |
4206 | u32 recvd, pglen = rcvbuf->page_len; | 4610 | u32 recvd, pglen = rcvbuf->page_len; |
4207 | __be32 *end, *entry, *p, *kaddr; | ||
4208 | unsigned int nr = 0; | ||
4209 | int status; | 4611 | int status; |
4210 | 4612 | ||
4211 | status = decode_op_hdr(xdr, OP_READDIR); | 4613 | status = decode_op_hdr(xdr, OP_READDIR); |
@@ -4225,71 +4627,8 @@ static int decode_readdir(struct xdr_stream *xdr, struct rpc_rqst *req, struct n | |||
4225 | pglen = recvd; | 4627 | pglen = recvd; |
4226 | xdr_read_pages(xdr, pglen); | 4628 | xdr_read_pages(xdr, pglen); |
4227 | 4629 | ||
4228 | BUG_ON(pglen + readdir->pgbase > PAGE_CACHE_SIZE); | 4630 | |
4229 | kaddr = p = kmap_atomic(page, KM_USER0); | 4631 | return pglen; |
4230 | end = p + ((pglen + readdir->pgbase) >> 2); | ||
4231 | entry = p; | ||
4232 | |||
4233 | /* Make sure the packet actually has a value_follows and EOF entry */ | ||
4234 | if ((entry + 1) > end) | ||
4235 | goto short_pkt; | ||
4236 | |||
4237 | for (; *p++; nr++) { | ||
4238 | u32 len, attrlen, xlen; | ||
4239 | if (end - p < 3) | ||
4240 | goto short_pkt; | ||
4241 | dprintk("cookie = %Lu, ", *((unsigned long long *)p)); | ||
4242 | p += 2; /* cookie */ | ||
4243 | len = ntohl(*p++); /* filename length */ | ||
4244 | if (len > NFS4_MAXNAMLEN) { | ||
4245 | dprintk("NFS: giant filename in readdir (len 0x%x)\n", | ||
4246 | len); | ||
4247 | goto err_unmap; | ||
4248 | } | ||
4249 | xlen = XDR_QUADLEN(len); | ||
4250 | if (end - p < xlen + 1) | ||
4251 | goto short_pkt; | ||
4252 | dprintk("filename = %*s\n", len, (char *)p); | ||
4253 | p += xlen; | ||
4254 | len = ntohl(*p++); /* bitmap length */ | ||
4255 | if (end - p < len + 1) | ||
4256 | goto short_pkt; | ||
4257 | p += len; | ||
4258 | attrlen = XDR_QUADLEN(ntohl(*p++)); | ||
4259 | if (end - p < attrlen + 2) | ||
4260 | goto short_pkt; | ||
4261 | p += attrlen; /* attributes */ | ||
4262 | entry = p; | ||
4263 | } | ||
4264 | /* | ||
4265 | * Apparently some server sends responses that are a valid size, but | ||
4266 | * contain no entries, and have value_follows==0 and EOF==0. For | ||
4267 | * those, just set the EOF marker. | ||
4268 | */ | ||
4269 | if (!nr && entry[1] == 0) { | ||
4270 | dprintk("NFS: readdir reply truncated!\n"); | ||
4271 | entry[1] = 1; | ||
4272 | } | ||
4273 | out: | ||
4274 | kunmap_atomic(kaddr, KM_USER0); | ||
4275 | return 0; | ||
4276 | short_pkt: | ||
4277 | /* | ||
4278 | * When we get a short packet there are 2 possibilities. We can | ||
4279 | * return an error, or fix up the response to look like a valid | ||
4280 | * response and return what we have so far. If there are no | ||
4281 | * entries and the packet was short, then return -EIO. If there | ||
4282 | * are valid entries in the response, return them and pretend that | ||
4283 | * the call was successful, but incomplete. The caller can retry the | ||
4284 | * readdir starting at the last cookie. | ||
4285 | */ | ||
4286 | dprintk("%s: short packet at entry %d\n", __func__, nr); | ||
4287 | entry[0] = entry[1] = 0; | ||
4288 | if (nr) | ||
4289 | goto out; | ||
4290 | err_unmap: | ||
4291 | kunmap_atomic(kaddr, KM_USER0); | ||
4292 | return -errno_NFSERR_IO; | ||
4293 | } | 4632 | } |
4294 | 4633 | ||
4295 | static int decode_readlink(struct xdr_stream *xdr, struct rpc_rqst *req) | 4634 | static int decode_readlink(struct xdr_stream *xdr, struct rpc_rqst *req) |
@@ -4299,7 +4638,6 @@ static int decode_readlink(struct xdr_stream *xdr, struct rpc_rqst *req) | |||
4299 | size_t hdrlen; | 4638 | size_t hdrlen; |
4300 | u32 len, recvd; | 4639 | u32 len, recvd; |
4301 | __be32 *p; | 4640 | __be32 *p; |
4302 | char *kaddr; | ||
4303 | int status; | 4641 | int status; |
4304 | 4642 | ||
4305 | status = decode_op_hdr(xdr, OP_READLINK); | 4643 | status = decode_op_hdr(xdr, OP_READLINK); |
@@ -4330,9 +4668,7 @@ static int decode_readlink(struct xdr_stream *xdr, struct rpc_rqst *req) | |||
4330 | * and and null-terminate the text (the VFS expects | 4668 | * and and null-terminate the text (the VFS expects |
4331 | * null-termination). | 4669 | * null-termination). |
4332 | */ | 4670 | */ |
4333 | kaddr = (char *)kmap_atomic(rcvbuf->pages[0], KM_USER0); | 4671 | xdr_terminate_string(rcvbuf, len); |
4334 | kaddr[len+rcvbuf->page_base] = '\0'; | ||
4335 | kunmap_atomic(kaddr, KM_USER0); | ||
4336 | return 0; | 4672 | return 0; |
4337 | out_overflow: | 4673 | out_overflow: |
4338 | print_overflow_msg(__func__, xdr); | 4674 | print_overflow_msg(__func__, xdr); |
@@ -4529,6 +4865,79 @@ static int decode_delegreturn(struct xdr_stream *xdr) | |||
4529 | return decode_op_hdr(xdr, OP_DELEGRETURN); | 4865 | return decode_op_hdr(xdr, OP_DELEGRETURN); |
4530 | } | 4866 | } |
4531 | 4867 | ||
4868 | static int decode_secinfo_gss(struct xdr_stream *xdr, struct nfs4_secinfo_flavor *flavor) | ||
4869 | { | ||
4870 | __be32 *p; | ||
4871 | |||
4872 | p = xdr_inline_decode(xdr, 4); | ||
4873 | if (unlikely(!p)) | ||
4874 | goto out_overflow; | ||
4875 | flavor->gss.sec_oid4.len = be32_to_cpup(p); | ||
4876 | if (flavor->gss.sec_oid4.len > GSS_OID_MAX_LEN) | ||
4877 | goto out_err; | ||
4878 | |||
4879 | p = xdr_inline_decode(xdr, flavor->gss.sec_oid4.len); | ||
4880 | if (unlikely(!p)) | ||
4881 | goto out_overflow; | ||
4882 | memcpy(flavor->gss.sec_oid4.data, p, flavor->gss.sec_oid4.len); | ||
4883 | |||
4884 | p = xdr_inline_decode(xdr, 8); | ||
4885 | if (unlikely(!p)) | ||
4886 | goto out_overflow; | ||
4887 | flavor->gss.qop4 = be32_to_cpup(p++); | ||
4888 | flavor->gss.service = be32_to_cpup(p); | ||
4889 | |||
4890 | return 0; | ||
4891 | |||
4892 | out_overflow: | ||
4893 | print_overflow_msg(__func__, xdr); | ||
4894 | return -EIO; | ||
4895 | out_err: | ||
4896 | return -EINVAL; | ||
4897 | } | ||
4898 | |||
4899 | static int decode_secinfo(struct xdr_stream *xdr, struct nfs4_secinfo_res *res) | ||
4900 | { | ||
4901 | struct nfs4_secinfo_flavor *sec_flavor; | ||
4902 | int status; | ||
4903 | __be32 *p; | ||
4904 | int i, num_flavors; | ||
4905 | |||
4906 | status = decode_op_hdr(xdr, OP_SECINFO); | ||
4907 | if (status) | ||
4908 | goto out; | ||
4909 | p = xdr_inline_decode(xdr, 4); | ||
4910 | if (unlikely(!p)) | ||
4911 | goto out_overflow; | ||
4912 | |||
4913 | res->flavors->num_flavors = 0; | ||
4914 | num_flavors = be32_to_cpup(p); | ||
4915 | |||
4916 | for (i = 0; i < num_flavors; i++) { | ||
4917 | sec_flavor = &res->flavors->flavors[i]; | ||
4918 | if ((char *)&sec_flavor[1] - (char *)res->flavors > PAGE_SIZE) | ||
4919 | break; | ||
4920 | |||
4921 | p = xdr_inline_decode(xdr, 4); | ||
4922 | if (unlikely(!p)) | ||
4923 | goto out_overflow; | ||
4924 | sec_flavor->flavor = be32_to_cpup(p); | ||
4925 | |||
4926 | if (sec_flavor->flavor == RPC_AUTH_GSS) { | ||
4927 | status = decode_secinfo_gss(xdr, sec_flavor); | ||
4928 | if (status) | ||
4929 | goto out; | ||
4930 | } | ||
4931 | res->flavors->num_flavors++; | ||
4932 | } | ||
4933 | |||
4934 | out: | ||
4935 | return status; | ||
4936 | out_overflow: | ||
4937 | print_overflow_msg(__func__, xdr); | ||
4938 | return -EIO; | ||
4939 | } | ||
4940 | |||
4532 | #if defined(CONFIG_NFS_V4_1) | 4941 | #if defined(CONFIG_NFS_V4_1) |
4533 | static int decode_exchange_id(struct xdr_stream *xdr, | 4942 | static int decode_exchange_id(struct xdr_stream *xdr, |
4534 | struct nfs41_exchange_id_res *res) | 4943 | struct nfs41_exchange_id_res *res) |
@@ -4546,7 +4955,7 @@ static int decode_exchange_id(struct xdr_stream *xdr, | |||
4546 | p = xdr_inline_decode(xdr, 8); | 4955 | p = xdr_inline_decode(xdr, 8); |
4547 | if (unlikely(!p)) | 4956 | if (unlikely(!p)) |
4548 | goto out_overflow; | 4957 | goto out_overflow; |
4549 | xdr_decode_hyper(p, &clp->cl_ex_clid); | 4958 | xdr_decode_hyper(p, &clp->cl_clientid); |
4550 | p = xdr_inline_decode(xdr, 12); | 4959 | p = xdr_inline_decode(xdr, 12); |
4551 | if (unlikely(!p)) | 4960 | if (unlikely(!p)) |
4552 | goto out_overflow; | 4961 | goto out_overflow; |
@@ -4588,12 +4997,14 @@ static int decode_chan_attrs(struct xdr_stream *xdr, | |||
4588 | struct nfs4_channel_attrs *attrs) | 4997 | struct nfs4_channel_attrs *attrs) |
4589 | { | 4998 | { |
4590 | __be32 *p; | 4999 | __be32 *p; |
4591 | u32 nr_attrs; | 5000 | u32 nr_attrs, val; |
4592 | 5001 | ||
4593 | p = xdr_inline_decode(xdr, 28); | 5002 | p = xdr_inline_decode(xdr, 28); |
4594 | if (unlikely(!p)) | 5003 | if (unlikely(!p)) |
4595 | goto out_overflow; | 5004 | goto out_overflow; |
4596 | attrs->headerpadsz = be32_to_cpup(p++); | 5005 | val = be32_to_cpup(p++); /* headerpadsz */ |
5006 | if (val) | ||
5007 | return -EINVAL; /* no support for header padding yet */ | ||
4597 | attrs->max_rqst_sz = be32_to_cpup(p++); | 5008 | attrs->max_rqst_sz = be32_to_cpup(p++); |
4598 | attrs->max_resp_sz = be32_to_cpup(p++); | 5009 | attrs->max_resp_sz = be32_to_cpup(p++); |
4599 | attrs->max_resp_sz_cached = be32_to_cpup(p++); | 5010 | attrs->max_resp_sz_cached = be32_to_cpup(p++); |
@@ -4668,7 +5079,6 @@ static int decode_sequence(struct xdr_stream *xdr, | |||
4668 | struct rpc_rqst *rqstp) | 5079 | struct rpc_rqst *rqstp) |
4669 | { | 5080 | { |
4670 | #if defined(CONFIG_NFS_V4_1) | 5081 | #if defined(CONFIG_NFS_V4_1) |
4671 | struct nfs4_slot *slot; | ||
4672 | struct nfs4_sessionid id; | 5082 | struct nfs4_sessionid id; |
4673 | u32 dummy; | 5083 | u32 dummy; |
4674 | int status; | 5084 | int status; |
@@ -4700,15 +5110,14 @@ static int decode_sequence(struct xdr_stream *xdr, | |||
4700 | goto out_overflow; | 5110 | goto out_overflow; |
4701 | 5111 | ||
4702 | /* seqid */ | 5112 | /* seqid */ |
4703 | slot = &res->sr_session->fc_slot_table.slots[res->sr_slotid]; | ||
4704 | dummy = be32_to_cpup(p++); | 5113 | dummy = be32_to_cpup(p++); |
4705 | if (dummy != slot->seq_nr) { | 5114 | if (dummy != res->sr_slot->seq_nr) { |
4706 | dprintk("%s Invalid sequence number\n", __func__); | 5115 | dprintk("%s Invalid sequence number\n", __func__); |
4707 | goto out_err; | 5116 | goto out_err; |
4708 | } | 5117 | } |
4709 | /* slot id */ | 5118 | /* slot id */ |
4710 | dummy = be32_to_cpup(p++); | 5119 | dummy = be32_to_cpup(p++); |
4711 | if (dummy != res->sr_slotid) { | 5120 | if (dummy != res->sr_slot - res->sr_session->fc_slot_table.slots) { |
4712 | dprintk("%s Invalid slot id\n", __func__); | 5121 | dprintk("%s Invalid slot id\n", __func__); |
4713 | goto out_err; | 5122 | goto out_err; |
4714 | } | 5123 | } |
@@ -4731,6 +5140,190 @@ out_overflow: | |||
4731 | #endif /* CONFIG_NFS_V4_1 */ | 5140 | #endif /* CONFIG_NFS_V4_1 */ |
4732 | } | 5141 | } |
4733 | 5142 | ||
5143 | #if defined(CONFIG_NFS_V4_1) | ||
5144 | |||
5145 | static int decode_getdeviceinfo(struct xdr_stream *xdr, | ||
5146 | struct pnfs_device *pdev) | ||
5147 | { | ||
5148 | __be32 *p; | ||
5149 | uint32_t len, type; | ||
5150 | int status; | ||
5151 | |||
5152 | status = decode_op_hdr(xdr, OP_GETDEVICEINFO); | ||
5153 | if (status) { | ||
5154 | if (status == -ETOOSMALL) { | ||
5155 | p = xdr_inline_decode(xdr, 4); | ||
5156 | if (unlikely(!p)) | ||
5157 | goto out_overflow; | ||
5158 | pdev->mincount = be32_to_cpup(p); | ||
5159 | dprintk("%s: Min count too small. mincnt = %u\n", | ||
5160 | __func__, pdev->mincount); | ||
5161 | } | ||
5162 | return status; | ||
5163 | } | ||
5164 | |||
5165 | p = xdr_inline_decode(xdr, 8); | ||
5166 | if (unlikely(!p)) | ||
5167 | goto out_overflow; | ||
5168 | type = be32_to_cpup(p++); | ||
5169 | if (type != pdev->layout_type) { | ||
5170 | dprintk("%s: layout mismatch req: %u pdev: %u\n", | ||
5171 | __func__, pdev->layout_type, type); | ||
5172 | return -EINVAL; | ||
5173 | } | ||
5174 | /* | ||
5175 | * Get the length of the opaque device_addr4. xdr_read_pages places | ||
5176 | * the opaque device_addr4 in the xdr_buf->pages (pnfs_device->pages) | ||
5177 | * and places the remaining xdr data in xdr_buf->tail | ||
5178 | */ | ||
5179 | pdev->mincount = be32_to_cpup(p); | ||
5180 | xdr_read_pages(xdr, pdev->mincount); /* include space for the length */ | ||
5181 | |||
5182 | /* Parse notification bitmap, verifying that it is zero. */ | ||
5183 | p = xdr_inline_decode(xdr, 4); | ||
5184 | if (unlikely(!p)) | ||
5185 | goto out_overflow; | ||
5186 | len = be32_to_cpup(p); | ||
5187 | if (len) { | ||
5188 | uint32_t i; | ||
5189 | |||
5190 | p = xdr_inline_decode(xdr, 4 * len); | ||
5191 | if (unlikely(!p)) | ||
5192 | goto out_overflow; | ||
5193 | for (i = 0; i < len; i++, p++) { | ||
5194 | if (be32_to_cpup(p)) { | ||
5195 | dprintk("%s: notifications not supported\n", | ||
5196 | __func__); | ||
5197 | return -EIO; | ||
5198 | } | ||
5199 | } | ||
5200 | } | ||
5201 | return 0; | ||
5202 | out_overflow: | ||
5203 | print_overflow_msg(__func__, xdr); | ||
5204 | return -EIO; | ||
5205 | } | ||
5206 | |||
5207 | static int decode_layoutget(struct xdr_stream *xdr, struct rpc_rqst *req, | ||
5208 | struct nfs4_layoutget_res *res) | ||
5209 | { | ||
5210 | __be32 *p; | ||
5211 | int status; | ||
5212 | u32 layout_count; | ||
5213 | struct xdr_buf *rcvbuf = &req->rq_rcv_buf; | ||
5214 | struct kvec *iov = rcvbuf->head; | ||
5215 | u32 hdrlen, recvd; | ||
5216 | |||
5217 | status = decode_op_hdr(xdr, OP_LAYOUTGET); | ||
5218 | if (status) | ||
5219 | return status; | ||
5220 | p = xdr_inline_decode(xdr, 8 + NFS4_STATEID_SIZE); | ||
5221 | if (unlikely(!p)) | ||
5222 | goto out_overflow; | ||
5223 | res->return_on_close = be32_to_cpup(p++); | ||
5224 | p = xdr_decode_opaque_fixed(p, res->stateid.data, NFS4_STATEID_SIZE); | ||
5225 | layout_count = be32_to_cpup(p); | ||
5226 | if (!layout_count) { | ||
5227 | dprintk("%s: server responded with empty layout array\n", | ||
5228 | __func__); | ||
5229 | return -EINVAL; | ||
5230 | } | ||
5231 | |||
5232 | p = xdr_inline_decode(xdr, 28); | ||
5233 | if (unlikely(!p)) | ||
5234 | goto out_overflow; | ||
5235 | p = xdr_decode_hyper(p, &res->range.offset); | ||
5236 | p = xdr_decode_hyper(p, &res->range.length); | ||
5237 | res->range.iomode = be32_to_cpup(p++); | ||
5238 | res->type = be32_to_cpup(p++); | ||
5239 | res->layoutp->len = be32_to_cpup(p); | ||
5240 | |||
5241 | dprintk("%s roff:%lu rlen:%lu riomode:%d, lo_type:0x%x, lo.len:%d\n", | ||
5242 | __func__, | ||
5243 | (unsigned long)res->range.offset, | ||
5244 | (unsigned long)res->range.length, | ||
5245 | res->range.iomode, | ||
5246 | res->type, | ||
5247 | res->layoutp->len); | ||
5248 | |||
5249 | hdrlen = (u8 *) xdr->p - (u8 *) iov->iov_base; | ||
5250 | recvd = req->rq_rcv_buf.len - hdrlen; | ||
5251 | if (res->layoutp->len > recvd) { | ||
5252 | dprintk("NFS: server cheating in layoutget reply: " | ||
5253 | "layout len %u > recvd %u\n", | ||
5254 | res->layoutp->len, recvd); | ||
5255 | return -EINVAL; | ||
5256 | } | ||
5257 | |||
5258 | xdr_read_pages(xdr, res->layoutp->len); | ||
5259 | |||
5260 | if (layout_count > 1) { | ||
5261 | /* We only handle a length one array at the moment. Any | ||
5262 | * further entries are just ignored. Note that this means | ||
5263 | * the client may see a response that is less than the | ||
5264 | * minimum it requested. | ||
5265 | */ | ||
5266 | dprintk("%s: server responded with %d layouts, dropping tail\n", | ||
5267 | __func__, layout_count); | ||
5268 | } | ||
5269 | |||
5270 | return 0; | ||
5271 | out_overflow: | ||
5272 | print_overflow_msg(__func__, xdr); | ||
5273 | return -EIO; | ||
5274 | } | ||
5275 | |||
5276 | static int decode_layoutreturn(struct xdr_stream *xdr, | ||
5277 | struct nfs4_layoutreturn_res *res) | ||
5278 | { | ||
5279 | __be32 *p; | ||
5280 | int status; | ||
5281 | |||
5282 | status = decode_op_hdr(xdr, OP_LAYOUTRETURN); | ||
5283 | if (status) | ||
5284 | return status; | ||
5285 | p = xdr_inline_decode(xdr, 4); | ||
5286 | if (unlikely(!p)) | ||
5287 | goto out_overflow; | ||
5288 | res->lrs_present = be32_to_cpup(p); | ||
5289 | if (res->lrs_present) | ||
5290 | status = decode_stateid(xdr, &res->stateid); | ||
5291 | return status; | ||
5292 | out_overflow: | ||
5293 | print_overflow_msg(__func__, xdr); | ||
5294 | return -EIO; | ||
5295 | } | ||
5296 | |||
5297 | static int decode_layoutcommit(struct xdr_stream *xdr, | ||
5298 | struct rpc_rqst *req, | ||
5299 | struct nfs4_layoutcommit_res *res) | ||
5300 | { | ||
5301 | __be32 *p; | ||
5302 | __u32 sizechanged; | ||
5303 | int status; | ||
5304 | |||
5305 | status = decode_op_hdr(xdr, OP_LAYOUTCOMMIT); | ||
5306 | if (status) | ||
5307 | return status; | ||
5308 | |||
5309 | p = xdr_inline_decode(xdr, 4); | ||
5310 | if (unlikely(!p)) | ||
5311 | goto out_overflow; | ||
5312 | sizechanged = be32_to_cpup(p); | ||
5313 | |||
5314 | if (sizechanged) { | ||
5315 | /* throw away new size */ | ||
5316 | p = xdr_inline_decode(xdr, 8); | ||
5317 | if (unlikely(!p)) | ||
5318 | goto out_overflow; | ||
5319 | } | ||
5320 | return 0; | ||
5321 | out_overflow: | ||
5322 | print_overflow_msg(__func__, xdr); | ||
5323 | return -EIO; | ||
5324 | } | ||
5325 | #endif /* CONFIG_NFS_V4_1 */ | ||
5326 | |||
4734 | /* | 5327 | /* |
4735 | * END OF "GENERIC" DECODE ROUTINES. | 5328 | * END OF "GENERIC" DECODE ROUTINES. |
4736 | */ | 5329 | */ |
@@ -4738,26 +5331,26 @@ out_overflow: | |||
4738 | /* | 5331 | /* |
4739 | * Decode OPEN_DOWNGRADE response | 5332 | * Decode OPEN_DOWNGRADE response |
4740 | */ | 5333 | */ |
4741 | static int nfs4_xdr_dec_open_downgrade(struct rpc_rqst *rqstp, __be32 *p, struct nfs_closeres *res) | 5334 | static int nfs4_xdr_dec_open_downgrade(struct rpc_rqst *rqstp, |
5335 | struct xdr_stream *xdr, | ||
5336 | struct nfs_closeres *res) | ||
4742 | { | 5337 | { |
4743 | struct xdr_stream xdr; | ||
4744 | struct compound_hdr hdr; | 5338 | struct compound_hdr hdr; |
4745 | int status; | 5339 | int status; |
4746 | 5340 | ||
4747 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); | 5341 | status = decode_compound_hdr(xdr, &hdr); |
4748 | status = decode_compound_hdr(&xdr, &hdr); | ||
4749 | if (status) | 5342 | if (status) |
4750 | goto out; | 5343 | goto out; |
4751 | status = decode_sequence(&xdr, &res->seq_res, rqstp); | 5344 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
4752 | if (status) | 5345 | if (status) |
4753 | goto out; | 5346 | goto out; |
4754 | status = decode_putfh(&xdr); | 5347 | status = decode_putfh(xdr); |
4755 | if (status) | 5348 | if (status) |
4756 | goto out; | 5349 | goto out; |
4757 | status = decode_open_downgrade(&xdr, res); | 5350 | status = decode_open_downgrade(xdr, res); |
4758 | if (status != 0) | 5351 | if (status != 0) |
4759 | goto out; | 5352 | goto out; |
4760 | decode_getfattr(&xdr, res->fattr, res->server, | 5353 | decode_getfattr(xdr, res->fattr, res->server, |
4761 | !RPC_IS_ASYNC(rqstp->rq_task)); | 5354 | !RPC_IS_ASYNC(rqstp->rq_task)); |
4762 | out: | 5355 | out: |
4763 | return status; | 5356 | return status; |
@@ -4766,26 +5359,25 @@ out: | |||
4766 | /* | 5359 | /* |
4767 | * Decode ACCESS response | 5360 | * Decode ACCESS response |
4768 | */ | 5361 | */ |
4769 | static int nfs4_xdr_dec_access(struct rpc_rqst *rqstp, __be32 *p, struct nfs4_accessres *res) | 5362 | static int nfs4_xdr_dec_access(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
5363 | struct nfs4_accessres *res) | ||
4770 | { | 5364 | { |
4771 | struct xdr_stream xdr; | ||
4772 | struct compound_hdr hdr; | 5365 | struct compound_hdr hdr; |
4773 | int status; | 5366 | int status; |
4774 | 5367 | ||
4775 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); | 5368 | status = decode_compound_hdr(xdr, &hdr); |
4776 | status = decode_compound_hdr(&xdr, &hdr); | ||
4777 | if (status) | 5369 | if (status) |
4778 | goto out; | 5370 | goto out; |
4779 | status = decode_sequence(&xdr, &res->seq_res, rqstp); | 5371 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
4780 | if (status) | 5372 | if (status) |
4781 | goto out; | 5373 | goto out; |
4782 | status = decode_putfh(&xdr); | 5374 | status = decode_putfh(xdr); |
4783 | if (status != 0) | 5375 | if (status != 0) |
4784 | goto out; | 5376 | goto out; |
4785 | status = decode_access(&xdr, res); | 5377 | status = decode_access(xdr, res); |
4786 | if (status != 0) | 5378 | if (status != 0) |
4787 | goto out; | 5379 | goto out; |
4788 | decode_getfattr(&xdr, res->fattr, res->server, | 5380 | decode_getfattr(xdr, res->fattr, res->server, |
4789 | !RPC_IS_ASYNC(rqstp->rq_task)); | 5381 | !RPC_IS_ASYNC(rqstp->rq_task)); |
4790 | out: | 5382 | out: |
4791 | return status; | 5383 | return status; |
@@ -4794,26 +5386,28 @@ out: | |||
4794 | /* | 5386 | /* |
4795 | * Decode LOOKUP response | 5387 | * Decode LOOKUP response |
4796 | */ | 5388 | */ |
4797 | static int nfs4_xdr_dec_lookup(struct rpc_rqst *rqstp, __be32 *p, struct nfs4_lookup_res *res) | 5389 | static int nfs4_xdr_dec_lookup(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
5390 | struct nfs4_lookup_res *res) | ||
4798 | { | 5391 | { |
4799 | struct xdr_stream xdr; | ||
4800 | struct compound_hdr hdr; | 5392 | struct compound_hdr hdr; |
4801 | int status; | 5393 | int status; |
4802 | 5394 | ||
4803 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); | 5395 | status = decode_compound_hdr(xdr, &hdr); |
4804 | status = decode_compound_hdr(&xdr, &hdr); | ||
4805 | if (status) | 5396 | if (status) |
4806 | goto out; | 5397 | goto out; |
4807 | status = decode_sequence(&xdr, &res->seq_res, rqstp); | 5398 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
4808 | if (status) | 5399 | if (status) |
4809 | goto out; | 5400 | goto out; |
4810 | if ((status = decode_putfh(&xdr)) != 0) | 5401 | status = decode_putfh(xdr); |
5402 | if (status) | ||
4811 | goto out; | 5403 | goto out; |
4812 | if ((status = decode_lookup(&xdr)) != 0) | 5404 | status = decode_lookup(xdr); |
5405 | if (status) | ||
4813 | goto out; | 5406 | goto out; |
4814 | if ((status = decode_getfh(&xdr, res->fh)) != 0) | 5407 | status = decode_getfh(xdr, res->fh); |
5408 | if (status) | ||
4815 | goto out; | 5409 | goto out; |
4816 | status = decode_getfattr(&xdr, res->fattr, res->server | 5410 | status = decode_getfattr(xdr, res->fattr, res->server |
4817 | ,!RPC_IS_ASYNC(rqstp->rq_task)); | 5411 | ,!RPC_IS_ASYNC(rqstp->rq_task)); |
4818 | out: | 5412 | out: |
4819 | return status; | 5413 | return status; |
@@ -4822,23 +5416,25 @@ out: | |||
4822 | /* | 5416 | /* |
4823 | * Decode LOOKUP_ROOT response | 5417 | * Decode LOOKUP_ROOT response |
4824 | */ | 5418 | */ |
4825 | static int nfs4_xdr_dec_lookup_root(struct rpc_rqst *rqstp, __be32 *p, struct nfs4_lookup_res *res) | 5419 | static int nfs4_xdr_dec_lookup_root(struct rpc_rqst *rqstp, |
5420 | struct xdr_stream *xdr, | ||
5421 | struct nfs4_lookup_res *res) | ||
4826 | { | 5422 | { |
4827 | struct xdr_stream xdr; | ||
4828 | struct compound_hdr hdr; | 5423 | struct compound_hdr hdr; |
4829 | int status; | 5424 | int status; |
4830 | 5425 | ||
4831 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); | 5426 | status = decode_compound_hdr(xdr, &hdr); |
4832 | status = decode_compound_hdr(&xdr, &hdr); | ||
4833 | if (status) | 5427 | if (status) |
4834 | goto out; | 5428 | goto out; |
4835 | status = decode_sequence(&xdr, &res->seq_res, rqstp); | 5429 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
4836 | if (status) | 5430 | if (status) |
4837 | goto out; | 5431 | goto out; |
4838 | if ((status = decode_putrootfh(&xdr)) != 0) | 5432 | status = decode_putrootfh(xdr); |
5433 | if (status) | ||
4839 | goto out; | 5434 | goto out; |
4840 | if ((status = decode_getfh(&xdr, res->fh)) == 0) | 5435 | status = decode_getfh(xdr, res->fh); |
4841 | status = decode_getfattr(&xdr, res->fattr, res->server, | 5436 | if (status == 0) |
5437 | status = decode_getfattr(xdr, res->fattr, res->server, | ||
4842 | !RPC_IS_ASYNC(rqstp->rq_task)); | 5438 | !RPC_IS_ASYNC(rqstp->rq_task)); |
4843 | out: | 5439 | out: |
4844 | return status; | 5440 | return status; |
@@ -4847,24 +5443,25 @@ out: | |||
4847 | /* | 5443 | /* |
4848 | * Decode REMOVE response | 5444 | * Decode REMOVE response |
4849 | */ | 5445 | */ |
4850 | static int nfs4_xdr_dec_remove(struct rpc_rqst *rqstp, __be32 *p, struct nfs_removeres *res) | 5446 | static int nfs4_xdr_dec_remove(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
5447 | struct nfs_removeres *res) | ||
4851 | { | 5448 | { |
4852 | struct xdr_stream xdr; | ||
4853 | struct compound_hdr hdr; | 5449 | struct compound_hdr hdr; |
4854 | int status; | 5450 | int status; |
4855 | 5451 | ||
4856 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); | 5452 | status = decode_compound_hdr(xdr, &hdr); |
4857 | status = decode_compound_hdr(&xdr, &hdr); | ||
4858 | if (status) | 5453 | if (status) |
4859 | goto out; | 5454 | goto out; |
4860 | status = decode_sequence(&xdr, &res->seq_res, rqstp); | 5455 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
4861 | if (status) | 5456 | if (status) |
4862 | goto out; | 5457 | goto out; |
4863 | if ((status = decode_putfh(&xdr)) != 0) | 5458 | status = decode_putfh(xdr); |
5459 | if (status) | ||
4864 | goto out; | 5460 | goto out; |
4865 | if ((status = decode_remove(&xdr, &res->cinfo)) != 0) | 5461 | status = decode_remove(xdr, &res->cinfo); |
5462 | if (status) | ||
4866 | goto out; | 5463 | goto out; |
4867 | decode_getfattr(&xdr, res->dir_attr, res->server, | 5464 | decode_getfattr(xdr, res->dir_attr, res->server, |
4868 | !RPC_IS_ASYNC(rqstp->rq_task)); | 5465 | !RPC_IS_ASYNC(rqstp->rq_task)); |
4869 | out: | 5466 | out: |
4870 | return status; | 5467 | return status; |
@@ -4873,34 +5470,38 @@ out: | |||
4873 | /* | 5470 | /* |
4874 | * Decode RENAME response | 5471 | * Decode RENAME response |
4875 | */ | 5472 | */ |
4876 | static int nfs4_xdr_dec_rename(struct rpc_rqst *rqstp, __be32 *p, struct nfs4_rename_res *res) | 5473 | static int nfs4_xdr_dec_rename(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
5474 | struct nfs_renameres *res) | ||
4877 | { | 5475 | { |
4878 | struct xdr_stream xdr; | ||
4879 | struct compound_hdr hdr; | 5476 | struct compound_hdr hdr; |
4880 | int status; | 5477 | int status; |
4881 | 5478 | ||
4882 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); | 5479 | status = decode_compound_hdr(xdr, &hdr); |
4883 | status = decode_compound_hdr(&xdr, &hdr); | ||
4884 | if (status) | 5480 | if (status) |
4885 | goto out; | 5481 | goto out; |
4886 | status = decode_sequence(&xdr, &res->seq_res, rqstp); | 5482 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
4887 | if (status) | 5483 | if (status) |
4888 | goto out; | 5484 | goto out; |
4889 | if ((status = decode_putfh(&xdr)) != 0) | 5485 | status = decode_putfh(xdr); |
5486 | if (status) | ||
4890 | goto out; | 5487 | goto out; |
4891 | if ((status = decode_savefh(&xdr)) != 0) | 5488 | status = decode_savefh(xdr); |
5489 | if (status) | ||
4892 | goto out; | 5490 | goto out; |
4893 | if ((status = decode_putfh(&xdr)) != 0) | 5491 | status = decode_putfh(xdr); |
5492 | if (status) | ||
4894 | goto out; | 5493 | goto out; |
4895 | if ((status = decode_rename(&xdr, &res->old_cinfo, &res->new_cinfo)) != 0) | 5494 | status = decode_rename(xdr, &res->old_cinfo, &res->new_cinfo); |
5495 | if (status) | ||
4896 | goto out; | 5496 | goto out; |
4897 | /* Current FH is target directory */ | 5497 | /* Current FH is target directory */ |
4898 | if (decode_getfattr(&xdr, res->new_fattr, res->server, | 5498 | if (decode_getfattr(xdr, res->new_fattr, res->server, |
4899 | !RPC_IS_ASYNC(rqstp->rq_task)) != 0) | 5499 | !RPC_IS_ASYNC(rqstp->rq_task)) != 0) |
4900 | goto out; | 5500 | goto out; |
4901 | if ((status = decode_restorefh(&xdr)) != 0) | 5501 | status = decode_restorefh(xdr); |
5502 | if (status) | ||
4902 | goto out; | 5503 | goto out; |
4903 | decode_getfattr(&xdr, res->old_fattr, res->server, | 5504 | decode_getfattr(xdr, res->old_fattr, res->server, |
4904 | !RPC_IS_ASYNC(rqstp->rq_task)); | 5505 | !RPC_IS_ASYNC(rqstp->rq_task)); |
4905 | out: | 5506 | out: |
4906 | return status; | 5507 | return status; |
@@ -4909,37 +5510,41 @@ out: | |||
4909 | /* | 5510 | /* |
4910 | * Decode LINK response | 5511 | * Decode LINK response |
4911 | */ | 5512 | */ |
4912 | static int nfs4_xdr_dec_link(struct rpc_rqst *rqstp, __be32 *p, struct nfs4_link_res *res) | 5513 | static int nfs4_xdr_dec_link(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
5514 | struct nfs4_link_res *res) | ||
4913 | { | 5515 | { |
4914 | struct xdr_stream xdr; | ||
4915 | struct compound_hdr hdr; | 5516 | struct compound_hdr hdr; |
4916 | int status; | 5517 | int status; |
4917 | 5518 | ||
4918 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); | 5519 | status = decode_compound_hdr(xdr, &hdr); |
4919 | status = decode_compound_hdr(&xdr, &hdr); | ||
4920 | if (status) | 5520 | if (status) |
4921 | goto out; | 5521 | goto out; |
4922 | status = decode_sequence(&xdr, &res->seq_res, rqstp); | 5522 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
4923 | if (status) | 5523 | if (status) |
4924 | goto out; | 5524 | goto out; |
4925 | if ((status = decode_putfh(&xdr)) != 0) | 5525 | status = decode_putfh(xdr); |
5526 | if (status) | ||
4926 | goto out; | 5527 | goto out; |
4927 | if ((status = decode_savefh(&xdr)) != 0) | 5528 | status = decode_savefh(xdr); |
5529 | if (status) | ||
4928 | goto out; | 5530 | goto out; |
4929 | if ((status = decode_putfh(&xdr)) != 0) | 5531 | status = decode_putfh(xdr); |
5532 | if (status) | ||
4930 | goto out; | 5533 | goto out; |
4931 | if ((status = decode_link(&xdr, &res->cinfo)) != 0) | 5534 | status = decode_link(xdr, &res->cinfo); |
5535 | if (status) | ||
4932 | goto out; | 5536 | goto out; |
4933 | /* | 5537 | /* |
4934 | * Note order: OP_LINK leaves the directory as the current | 5538 | * Note order: OP_LINK leaves the directory as the current |
4935 | * filehandle. | 5539 | * filehandle. |
4936 | */ | 5540 | */ |
4937 | if (decode_getfattr(&xdr, res->dir_attr, res->server, | 5541 | if (decode_getfattr(xdr, res->dir_attr, res->server, |
4938 | !RPC_IS_ASYNC(rqstp->rq_task)) != 0) | 5542 | !RPC_IS_ASYNC(rqstp->rq_task)) != 0) |
4939 | goto out; | 5543 | goto out; |
4940 | if ((status = decode_restorefh(&xdr)) != 0) | 5544 | status = decode_restorefh(xdr); |
5545 | if (status) | ||
4941 | goto out; | 5546 | goto out; |
4942 | decode_getfattr(&xdr, res->fattr, res->server, | 5547 | decode_getfattr(xdr, res->fattr, res->server, |
4943 | !RPC_IS_ASYNC(rqstp->rq_task)); | 5548 | !RPC_IS_ASYNC(rqstp->rq_task)); |
4944 | out: | 5549 | out: |
4945 | return status; | 5550 | return status; |
@@ -4948,33 +5553,37 @@ out: | |||
4948 | /* | 5553 | /* |
4949 | * Decode CREATE response | 5554 | * Decode CREATE response |
4950 | */ | 5555 | */ |
4951 | static int nfs4_xdr_dec_create(struct rpc_rqst *rqstp, __be32 *p, struct nfs4_create_res *res) | 5556 | static int nfs4_xdr_dec_create(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
5557 | struct nfs4_create_res *res) | ||
4952 | { | 5558 | { |
4953 | struct xdr_stream xdr; | ||
4954 | struct compound_hdr hdr; | 5559 | struct compound_hdr hdr; |
4955 | int status; | 5560 | int status; |
4956 | 5561 | ||
4957 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); | 5562 | status = decode_compound_hdr(xdr, &hdr); |
4958 | status = decode_compound_hdr(&xdr, &hdr); | ||
4959 | if (status) | 5563 | if (status) |
4960 | goto out; | 5564 | goto out; |
4961 | status = decode_sequence(&xdr, &res->seq_res, rqstp); | 5565 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
4962 | if (status) | 5566 | if (status) |
4963 | goto out; | 5567 | goto out; |
4964 | if ((status = decode_putfh(&xdr)) != 0) | 5568 | status = decode_putfh(xdr); |
5569 | if (status) | ||
4965 | goto out; | 5570 | goto out; |
4966 | if ((status = decode_savefh(&xdr)) != 0) | 5571 | status = decode_savefh(xdr); |
5572 | if (status) | ||
4967 | goto out; | 5573 | goto out; |
4968 | if ((status = decode_create(&xdr,&res->dir_cinfo)) != 0) | 5574 | status = decode_create(xdr, &res->dir_cinfo); |
5575 | if (status) | ||
4969 | goto out; | 5576 | goto out; |
4970 | if ((status = decode_getfh(&xdr, res->fh)) != 0) | 5577 | status = decode_getfh(xdr, res->fh); |
5578 | if (status) | ||
4971 | goto out; | 5579 | goto out; |
4972 | if (decode_getfattr(&xdr, res->fattr, res->server, | 5580 | if (decode_getfattr(xdr, res->fattr, res->server, |
4973 | !RPC_IS_ASYNC(rqstp->rq_task)) != 0) | 5581 | !RPC_IS_ASYNC(rqstp->rq_task)) != 0) |
4974 | goto out; | 5582 | goto out; |
4975 | if ((status = decode_restorefh(&xdr)) != 0) | 5583 | status = decode_restorefh(xdr); |
5584 | if (status) | ||
4976 | goto out; | 5585 | goto out; |
4977 | decode_getfattr(&xdr, res->dir_fattr, res->server, | 5586 | decode_getfattr(xdr, res->dir_fattr, res->server, |
4978 | !RPC_IS_ASYNC(rqstp->rq_task)); | 5587 | !RPC_IS_ASYNC(rqstp->rq_task)); |
4979 | out: | 5588 | out: |
4980 | return status; | 5589 | return status; |
@@ -4983,31 +5592,31 @@ out: | |||
4983 | /* | 5592 | /* |
4984 | * Decode SYMLINK response | 5593 | * Decode SYMLINK response |
4985 | */ | 5594 | */ |
4986 | static int nfs4_xdr_dec_symlink(struct rpc_rqst *rqstp, __be32 *p, struct nfs4_create_res *res) | 5595 | static int nfs4_xdr_dec_symlink(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
5596 | struct nfs4_create_res *res) | ||
4987 | { | 5597 | { |
4988 | return nfs4_xdr_dec_create(rqstp, p, res); | 5598 | return nfs4_xdr_dec_create(rqstp, xdr, res); |
4989 | } | 5599 | } |
4990 | 5600 | ||
4991 | /* | 5601 | /* |
4992 | * Decode GETATTR response | 5602 | * Decode GETATTR response |
4993 | */ | 5603 | */ |
4994 | static int nfs4_xdr_dec_getattr(struct rpc_rqst *rqstp, __be32 *p, struct nfs4_getattr_res *res) | 5604 | static int nfs4_xdr_dec_getattr(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
5605 | struct nfs4_getattr_res *res) | ||
4995 | { | 5606 | { |
4996 | struct xdr_stream xdr; | ||
4997 | struct compound_hdr hdr; | 5607 | struct compound_hdr hdr; |
4998 | int status; | 5608 | int status; |
4999 | 5609 | ||
5000 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); | 5610 | status = decode_compound_hdr(xdr, &hdr); |
5001 | status = decode_compound_hdr(&xdr, &hdr); | ||
5002 | if (status) | 5611 | if (status) |
5003 | goto out; | 5612 | goto out; |
5004 | status = decode_sequence(&xdr, &res->seq_res, rqstp); | 5613 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
5005 | if (status) | 5614 | if (status) |
5006 | goto out; | 5615 | goto out; |
5007 | status = decode_putfh(&xdr); | 5616 | status = decode_putfh(xdr); |
5008 | if (status) | 5617 | if (status) |
5009 | goto out; | 5618 | goto out; |
5010 | status = decode_getfattr(&xdr, res->fattr, res->server, | 5619 | status = decode_getfattr(xdr, res->fattr, res->server, |
5011 | !RPC_IS_ASYNC(rqstp->rq_task)); | 5620 | !RPC_IS_ASYNC(rqstp->rq_task)); |
5012 | out: | 5621 | out: |
5013 | return status; | 5622 | return status; |
@@ -5016,46 +5625,40 @@ out: | |||
5016 | /* | 5625 | /* |
5017 | * Encode an SETACL request | 5626 | * Encode an SETACL request |
5018 | */ | 5627 | */ |
5019 | static int | 5628 | static void nfs4_xdr_enc_setacl(struct rpc_rqst *req, struct xdr_stream *xdr, |
5020 | nfs4_xdr_enc_setacl(struct rpc_rqst *req, __be32 *p, struct nfs_setaclargs *args) | 5629 | struct nfs_setaclargs *args) |
5021 | { | 5630 | { |
5022 | struct xdr_stream xdr; | ||
5023 | struct compound_hdr hdr = { | 5631 | struct compound_hdr hdr = { |
5024 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | 5632 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
5025 | }; | 5633 | }; |
5026 | int status; | ||
5027 | 5634 | ||
5028 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); | 5635 | encode_compound_hdr(xdr, req, &hdr); |
5029 | encode_compound_hdr(&xdr, req, &hdr); | 5636 | encode_sequence(xdr, &args->seq_args, &hdr); |
5030 | encode_sequence(&xdr, &args->seq_args, &hdr); | 5637 | encode_putfh(xdr, args->fh, &hdr); |
5031 | encode_putfh(&xdr, args->fh, &hdr); | 5638 | encode_setacl(xdr, args, &hdr); |
5032 | status = encode_setacl(&xdr, args, &hdr); | ||
5033 | encode_nops(&hdr); | 5639 | encode_nops(&hdr); |
5034 | return status; | ||
5035 | } | 5640 | } |
5036 | 5641 | ||
5037 | /* | 5642 | /* |
5038 | * Decode SETACL response | 5643 | * Decode SETACL response |
5039 | */ | 5644 | */ |
5040 | static int | 5645 | static int |
5041 | nfs4_xdr_dec_setacl(struct rpc_rqst *rqstp, __be32 *p, | 5646 | nfs4_xdr_dec_setacl(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
5042 | struct nfs_setaclres *res) | 5647 | struct nfs_setaclres *res) |
5043 | { | 5648 | { |
5044 | struct xdr_stream xdr; | ||
5045 | struct compound_hdr hdr; | 5649 | struct compound_hdr hdr; |
5046 | int status; | 5650 | int status; |
5047 | 5651 | ||
5048 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); | 5652 | status = decode_compound_hdr(xdr, &hdr); |
5049 | status = decode_compound_hdr(&xdr, &hdr); | ||
5050 | if (status) | 5653 | if (status) |
5051 | goto out; | 5654 | goto out; |
5052 | status = decode_sequence(&xdr, &res->seq_res, rqstp); | 5655 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
5053 | if (status) | 5656 | if (status) |
5054 | goto out; | 5657 | goto out; |
5055 | status = decode_putfh(&xdr); | 5658 | status = decode_putfh(xdr); |
5056 | if (status) | 5659 | if (status) |
5057 | goto out; | 5660 | goto out; |
5058 | status = decode_setattr(&xdr); | 5661 | status = decode_setattr(xdr); |
5059 | out: | 5662 | out: |
5060 | return status; | 5663 | return status; |
5061 | } | 5664 | } |
@@ -5064,24 +5667,22 @@ out: | |||
5064 | * Decode GETACL response | 5667 | * Decode GETACL response |
5065 | */ | 5668 | */ |
5066 | static int | 5669 | static int |
5067 | nfs4_xdr_dec_getacl(struct rpc_rqst *rqstp, __be32 *p, | 5670 | nfs4_xdr_dec_getacl(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
5068 | struct nfs_getaclres *res) | 5671 | struct nfs_getaclres *res) |
5069 | { | 5672 | { |
5070 | struct xdr_stream xdr; | ||
5071 | struct compound_hdr hdr; | 5673 | struct compound_hdr hdr; |
5072 | int status; | 5674 | int status; |
5073 | 5675 | ||
5074 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); | 5676 | status = decode_compound_hdr(xdr, &hdr); |
5075 | status = decode_compound_hdr(&xdr, &hdr); | ||
5076 | if (status) | 5677 | if (status) |
5077 | goto out; | 5678 | goto out; |
5078 | status = decode_sequence(&xdr, &res->seq_res, rqstp); | 5679 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
5079 | if (status) | 5680 | if (status) |
5080 | goto out; | 5681 | goto out; |
5081 | status = decode_putfh(&xdr); | 5682 | status = decode_putfh(xdr); |
5082 | if (status) | 5683 | if (status) |
5083 | goto out; | 5684 | goto out; |
5084 | status = decode_getacl(&xdr, rqstp, &res->acl_len); | 5685 | status = decode_getacl(xdr, rqstp, &res->acl_len); |
5085 | 5686 | ||
5086 | out: | 5687 | out: |
5087 | return status; | 5688 | return status; |
@@ -5090,23 +5691,22 @@ out: | |||
5090 | /* | 5691 | /* |
5091 | * Decode CLOSE response | 5692 | * Decode CLOSE response |
5092 | */ | 5693 | */ |
5093 | static int nfs4_xdr_dec_close(struct rpc_rqst *rqstp, __be32 *p, struct nfs_closeres *res) | 5694 | static int nfs4_xdr_dec_close(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
5695 | struct nfs_closeres *res) | ||
5094 | { | 5696 | { |
5095 | struct xdr_stream xdr; | ||
5096 | struct compound_hdr hdr; | 5697 | struct compound_hdr hdr; |
5097 | int status; | 5698 | int status; |
5098 | 5699 | ||
5099 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); | 5700 | status = decode_compound_hdr(xdr, &hdr); |
5100 | status = decode_compound_hdr(&xdr, &hdr); | ||
5101 | if (status) | 5701 | if (status) |
5102 | goto out; | 5702 | goto out; |
5103 | status = decode_sequence(&xdr, &res->seq_res, rqstp); | 5703 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
5104 | if (status) | 5704 | if (status) |
5105 | goto out; | 5705 | goto out; |
5106 | status = decode_putfh(&xdr); | 5706 | status = decode_putfh(xdr); |
5107 | if (status) | 5707 | if (status) |
5108 | goto out; | 5708 | goto out; |
5109 | status = decode_close(&xdr, res); | 5709 | status = decode_close(xdr, res); |
5110 | if (status != 0) | 5710 | if (status != 0) |
5111 | goto out; | 5711 | goto out; |
5112 | /* | 5712 | /* |
@@ -5115,7 +5715,7 @@ static int nfs4_xdr_dec_close(struct rpc_rqst *rqstp, __be32 *p, struct nfs_clos | |||
5115 | * an ESTALE error. Shouldn't be a problem, | 5715 | * an ESTALE error. Shouldn't be a problem, |
5116 | * though, since fattr->valid will remain unset. | 5716 | * though, since fattr->valid will remain unset. |
5117 | */ | 5717 | */ |
5118 | decode_getfattr(&xdr, res->fattr, res->server, | 5718 | decode_getfattr(xdr, res->fattr, res->server, |
5119 | !RPC_IS_ASYNC(rqstp->rq_task)); | 5719 | !RPC_IS_ASYNC(rqstp->rq_task)); |
5120 | out: | 5720 | out: |
5121 | return status; | 5721 | return status; |
@@ -5124,36 +5724,35 @@ out: | |||
5124 | /* | 5724 | /* |
5125 | * Decode OPEN response | 5725 | * Decode OPEN response |
5126 | */ | 5726 | */ |
5127 | static int nfs4_xdr_dec_open(struct rpc_rqst *rqstp, __be32 *p, struct nfs_openres *res) | 5727 | static int nfs4_xdr_dec_open(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
5728 | struct nfs_openres *res) | ||
5128 | { | 5729 | { |
5129 | struct xdr_stream xdr; | ||
5130 | struct compound_hdr hdr; | 5730 | struct compound_hdr hdr; |
5131 | int status; | 5731 | int status; |
5132 | 5732 | ||
5133 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); | 5733 | status = decode_compound_hdr(xdr, &hdr); |
5134 | status = decode_compound_hdr(&xdr, &hdr); | ||
5135 | if (status) | 5734 | if (status) |
5136 | goto out; | 5735 | goto out; |
5137 | status = decode_sequence(&xdr, &res->seq_res, rqstp); | 5736 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
5138 | if (status) | 5737 | if (status) |
5139 | goto out; | 5738 | goto out; |
5140 | status = decode_putfh(&xdr); | 5739 | status = decode_putfh(xdr); |
5141 | if (status) | 5740 | if (status) |
5142 | goto out; | 5741 | goto out; |
5143 | status = decode_savefh(&xdr); | 5742 | status = decode_savefh(xdr); |
5144 | if (status) | 5743 | if (status) |
5145 | goto out; | 5744 | goto out; |
5146 | status = decode_open(&xdr, res); | 5745 | status = decode_open(xdr, res); |
5147 | if (status) | 5746 | if (status) |
5148 | goto out; | 5747 | goto out; |
5149 | if (decode_getfh(&xdr, &res->fh) != 0) | 5748 | if (decode_getfh(xdr, &res->fh) != 0) |
5150 | goto out; | 5749 | goto out; |
5151 | if (decode_getfattr(&xdr, res->f_attr, res->server, | 5750 | if (decode_getfattr(xdr, res->f_attr, res->server, |
5152 | !RPC_IS_ASYNC(rqstp->rq_task)) != 0) | 5751 | !RPC_IS_ASYNC(rqstp->rq_task)) != 0) |
5153 | goto out; | 5752 | goto out; |
5154 | if (decode_restorefh(&xdr) != 0) | 5753 | if (decode_restorefh(xdr) != 0) |
5155 | goto out; | 5754 | goto out; |
5156 | decode_getfattr(&xdr, res->dir_attr, res->server, | 5755 | decode_getfattr(xdr, res->dir_attr, res->server, |
5157 | !RPC_IS_ASYNC(rqstp->rq_task)); | 5756 | !RPC_IS_ASYNC(rqstp->rq_task)); |
5158 | out: | 5757 | out: |
5159 | return status; | 5758 | return status; |
@@ -5162,20 +5761,20 @@ out: | |||
5162 | /* | 5761 | /* |
5163 | * Decode OPEN_CONFIRM response | 5762 | * Decode OPEN_CONFIRM response |
5164 | */ | 5763 | */ |
5165 | static int nfs4_xdr_dec_open_confirm(struct rpc_rqst *rqstp, __be32 *p, struct nfs_open_confirmres *res) | 5764 | static int nfs4_xdr_dec_open_confirm(struct rpc_rqst *rqstp, |
5765 | struct xdr_stream *xdr, | ||
5766 | struct nfs_open_confirmres *res) | ||
5166 | { | 5767 | { |
5167 | struct xdr_stream xdr; | ||
5168 | struct compound_hdr hdr; | 5768 | struct compound_hdr hdr; |
5169 | int status; | 5769 | int status; |
5170 | 5770 | ||
5171 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); | 5771 | status = decode_compound_hdr(xdr, &hdr); |
5172 | status = decode_compound_hdr(&xdr, &hdr); | ||
5173 | if (status) | 5772 | if (status) |
5174 | goto out; | 5773 | goto out; |
5175 | status = decode_putfh(&xdr); | 5774 | status = decode_putfh(xdr); |
5176 | if (status) | 5775 | if (status) |
5177 | goto out; | 5776 | goto out; |
5178 | status = decode_open_confirm(&xdr, res); | 5777 | status = decode_open_confirm(xdr, res); |
5179 | out: | 5778 | out: |
5180 | return status; | 5779 | return status; |
5181 | } | 5780 | } |
@@ -5183,26 +5782,26 @@ out: | |||
5183 | /* | 5782 | /* |
5184 | * Decode OPEN response | 5783 | * Decode OPEN response |
5185 | */ | 5784 | */ |
5186 | static int nfs4_xdr_dec_open_noattr(struct rpc_rqst *rqstp, __be32 *p, struct nfs_openres *res) | 5785 | static int nfs4_xdr_dec_open_noattr(struct rpc_rqst *rqstp, |
5786 | struct xdr_stream *xdr, | ||
5787 | struct nfs_openres *res) | ||
5187 | { | 5788 | { |
5188 | struct xdr_stream xdr; | ||
5189 | struct compound_hdr hdr; | 5789 | struct compound_hdr hdr; |
5190 | int status; | 5790 | int status; |
5191 | 5791 | ||
5192 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); | 5792 | status = decode_compound_hdr(xdr, &hdr); |
5193 | status = decode_compound_hdr(&xdr, &hdr); | ||
5194 | if (status) | 5793 | if (status) |
5195 | goto out; | 5794 | goto out; |
5196 | status = decode_sequence(&xdr, &res->seq_res, rqstp); | 5795 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
5197 | if (status) | 5796 | if (status) |
5198 | goto out; | 5797 | goto out; |
5199 | status = decode_putfh(&xdr); | 5798 | status = decode_putfh(xdr); |
5200 | if (status) | 5799 | if (status) |
5201 | goto out; | 5800 | goto out; |
5202 | status = decode_open(&xdr, res); | 5801 | status = decode_open(xdr, res); |
5203 | if (status) | 5802 | if (status) |
5204 | goto out; | 5803 | goto out; |
5205 | decode_getfattr(&xdr, res->f_attr, res->server, | 5804 | decode_getfattr(xdr, res->f_attr, res->server, |
5206 | !RPC_IS_ASYNC(rqstp->rq_task)); | 5805 | !RPC_IS_ASYNC(rqstp->rq_task)); |
5207 | out: | 5806 | out: |
5208 | return status; | 5807 | return status; |
@@ -5211,26 +5810,26 @@ out: | |||
5211 | /* | 5810 | /* |
5212 | * Decode SETATTR response | 5811 | * Decode SETATTR response |
5213 | */ | 5812 | */ |
5214 | static int nfs4_xdr_dec_setattr(struct rpc_rqst *rqstp, __be32 *p, struct nfs_setattrres *res) | 5813 | static int nfs4_xdr_dec_setattr(struct rpc_rqst *rqstp, |
5814 | struct xdr_stream *xdr, | ||
5815 | struct nfs_setattrres *res) | ||
5215 | { | 5816 | { |
5216 | struct xdr_stream xdr; | ||
5217 | struct compound_hdr hdr; | 5817 | struct compound_hdr hdr; |
5218 | int status; | 5818 | int status; |
5219 | 5819 | ||
5220 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); | 5820 | status = decode_compound_hdr(xdr, &hdr); |
5221 | status = decode_compound_hdr(&xdr, &hdr); | ||
5222 | if (status) | 5821 | if (status) |
5223 | goto out; | 5822 | goto out; |
5224 | status = decode_sequence(&xdr, &res->seq_res, rqstp); | 5823 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
5225 | if (status) | 5824 | if (status) |
5226 | goto out; | 5825 | goto out; |
5227 | status = decode_putfh(&xdr); | 5826 | status = decode_putfh(xdr); |
5228 | if (status) | 5827 | if (status) |
5229 | goto out; | 5828 | goto out; |
5230 | status = decode_setattr(&xdr); | 5829 | status = decode_setattr(xdr); |
5231 | if (status) | 5830 | if (status) |
5232 | goto out; | 5831 | goto out; |
5233 | decode_getfattr(&xdr, res->fattr, res->server, | 5832 | decode_getfattr(xdr, res->fattr, res->server, |
5234 | !RPC_IS_ASYNC(rqstp->rq_task)); | 5833 | !RPC_IS_ASYNC(rqstp->rq_task)); |
5235 | out: | 5834 | out: |
5236 | return status; | 5835 | return status; |
@@ -5239,23 +5838,22 @@ out: | |||
5239 | /* | 5838 | /* |
5240 | * Decode LOCK response | 5839 | * Decode LOCK response |
5241 | */ | 5840 | */ |
5242 | static int nfs4_xdr_dec_lock(struct rpc_rqst *rqstp, __be32 *p, struct nfs_lock_res *res) | 5841 | static int nfs4_xdr_dec_lock(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
5842 | struct nfs_lock_res *res) | ||
5243 | { | 5843 | { |
5244 | struct xdr_stream xdr; | ||
5245 | struct compound_hdr hdr; | 5844 | struct compound_hdr hdr; |
5246 | int status; | 5845 | int status; |
5247 | 5846 | ||
5248 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); | 5847 | status = decode_compound_hdr(xdr, &hdr); |
5249 | status = decode_compound_hdr(&xdr, &hdr); | ||
5250 | if (status) | 5848 | if (status) |
5251 | goto out; | 5849 | goto out; |
5252 | status = decode_sequence(&xdr, &res->seq_res, rqstp); | 5850 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
5253 | if (status) | 5851 | if (status) |
5254 | goto out; | 5852 | goto out; |
5255 | status = decode_putfh(&xdr); | 5853 | status = decode_putfh(xdr); |
5256 | if (status) | 5854 | if (status) |
5257 | goto out; | 5855 | goto out; |
5258 | status = decode_lock(&xdr, res); | 5856 | status = decode_lock(xdr, res); |
5259 | out: | 5857 | out: |
5260 | return status; | 5858 | return status; |
5261 | } | 5859 | } |
@@ -5263,23 +5861,22 @@ out: | |||
5263 | /* | 5861 | /* |
5264 | * Decode LOCKT response | 5862 | * Decode LOCKT response |
5265 | */ | 5863 | */ |
5266 | static int nfs4_xdr_dec_lockt(struct rpc_rqst *rqstp, __be32 *p, struct nfs_lockt_res *res) | 5864 | static int nfs4_xdr_dec_lockt(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
5865 | struct nfs_lockt_res *res) | ||
5267 | { | 5866 | { |
5268 | struct xdr_stream xdr; | ||
5269 | struct compound_hdr hdr; | 5867 | struct compound_hdr hdr; |
5270 | int status; | 5868 | int status; |
5271 | 5869 | ||
5272 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); | 5870 | status = decode_compound_hdr(xdr, &hdr); |
5273 | status = decode_compound_hdr(&xdr, &hdr); | ||
5274 | if (status) | 5871 | if (status) |
5275 | goto out; | 5872 | goto out; |
5276 | status = decode_sequence(&xdr, &res->seq_res, rqstp); | 5873 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
5277 | if (status) | 5874 | if (status) |
5278 | goto out; | 5875 | goto out; |
5279 | status = decode_putfh(&xdr); | 5876 | status = decode_putfh(xdr); |
5280 | if (status) | 5877 | if (status) |
5281 | goto out; | 5878 | goto out; |
5282 | status = decode_lockt(&xdr, res); | 5879 | status = decode_lockt(xdr, res); |
5283 | out: | 5880 | out: |
5284 | return status; | 5881 | return status; |
5285 | } | 5882 | } |
@@ -5287,61 +5884,58 @@ out: | |||
5287 | /* | 5884 | /* |
5288 | * Decode LOCKU response | 5885 | * Decode LOCKU response |
5289 | */ | 5886 | */ |
5290 | static int nfs4_xdr_dec_locku(struct rpc_rqst *rqstp, __be32 *p, struct nfs_locku_res *res) | 5887 | static int nfs4_xdr_dec_locku(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
5888 | struct nfs_locku_res *res) | ||
5291 | { | 5889 | { |
5292 | struct xdr_stream xdr; | ||
5293 | struct compound_hdr hdr; | 5890 | struct compound_hdr hdr; |
5294 | int status; | 5891 | int status; |
5295 | 5892 | ||
5296 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); | 5893 | status = decode_compound_hdr(xdr, &hdr); |
5297 | status = decode_compound_hdr(&xdr, &hdr); | ||
5298 | if (status) | 5894 | if (status) |
5299 | goto out; | 5895 | goto out; |
5300 | status = decode_sequence(&xdr, &res->seq_res, rqstp); | 5896 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
5301 | if (status) | 5897 | if (status) |
5302 | goto out; | 5898 | goto out; |
5303 | status = decode_putfh(&xdr); | 5899 | status = decode_putfh(xdr); |
5304 | if (status) | 5900 | if (status) |
5305 | goto out; | 5901 | goto out; |
5306 | status = decode_locku(&xdr, res); | 5902 | status = decode_locku(xdr, res); |
5307 | out: | 5903 | out: |
5308 | return status; | 5904 | return status; |
5309 | } | 5905 | } |
5310 | 5906 | ||
5311 | static int nfs4_xdr_dec_release_lockowner(struct rpc_rqst *rqstp, __be32 *p, void *dummy) | 5907 | static int nfs4_xdr_dec_release_lockowner(struct rpc_rqst *rqstp, |
5908 | struct xdr_stream *xdr, void *dummy) | ||
5312 | { | 5909 | { |
5313 | struct xdr_stream xdr; | ||
5314 | struct compound_hdr hdr; | 5910 | struct compound_hdr hdr; |
5315 | int status; | 5911 | int status; |
5316 | 5912 | ||
5317 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); | 5913 | status = decode_compound_hdr(xdr, &hdr); |
5318 | status = decode_compound_hdr(&xdr, &hdr); | ||
5319 | if (!status) | 5914 | if (!status) |
5320 | status = decode_release_lockowner(&xdr); | 5915 | status = decode_release_lockowner(xdr); |
5321 | return status; | 5916 | return status; |
5322 | } | 5917 | } |
5323 | 5918 | ||
5324 | /* | 5919 | /* |
5325 | * Decode READLINK response | 5920 | * Decode READLINK response |
5326 | */ | 5921 | */ |
5327 | static int nfs4_xdr_dec_readlink(struct rpc_rqst *rqstp, __be32 *p, | 5922 | static int nfs4_xdr_dec_readlink(struct rpc_rqst *rqstp, |
5923 | struct xdr_stream *xdr, | ||
5328 | struct nfs4_readlink_res *res) | 5924 | struct nfs4_readlink_res *res) |
5329 | { | 5925 | { |
5330 | struct xdr_stream xdr; | ||
5331 | struct compound_hdr hdr; | 5926 | struct compound_hdr hdr; |
5332 | int status; | 5927 | int status; |
5333 | 5928 | ||
5334 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); | 5929 | status = decode_compound_hdr(xdr, &hdr); |
5335 | status = decode_compound_hdr(&xdr, &hdr); | ||
5336 | if (status) | 5930 | if (status) |
5337 | goto out; | 5931 | goto out; |
5338 | status = decode_sequence(&xdr, &res->seq_res, rqstp); | 5932 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
5339 | if (status) | 5933 | if (status) |
5340 | goto out; | 5934 | goto out; |
5341 | status = decode_putfh(&xdr); | 5935 | status = decode_putfh(xdr); |
5342 | if (status) | 5936 | if (status) |
5343 | goto out; | 5937 | goto out; |
5344 | status = decode_readlink(&xdr, rqstp); | 5938 | status = decode_readlink(xdr, rqstp); |
5345 | out: | 5939 | out: |
5346 | return status; | 5940 | return status; |
5347 | } | 5941 | } |
@@ -5349,23 +5943,22 @@ out: | |||
5349 | /* | 5943 | /* |
5350 | * Decode READDIR response | 5944 | * Decode READDIR response |
5351 | */ | 5945 | */ |
5352 | static int nfs4_xdr_dec_readdir(struct rpc_rqst *rqstp, __be32 *p, struct nfs4_readdir_res *res) | 5946 | static int nfs4_xdr_dec_readdir(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
5947 | struct nfs4_readdir_res *res) | ||
5353 | { | 5948 | { |
5354 | struct xdr_stream xdr; | ||
5355 | struct compound_hdr hdr; | 5949 | struct compound_hdr hdr; |
5356 | int status; | 5950 | int status; |
5357 | 5951 | ||
5358 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); | 5952 | status = decode_compound_hdr(xdr, &hdr); |
5359 | status = decode_compound_hdr(&xdr, &hdr); | ||
5360 | if (status) | 5953 | if (status) |
5361 | goto out; | 5954 | goto out; |
5362 | status = decode_sequence(&xdr, &res->seq_res, rqstp); | 5955 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
5363 | if (status) | 5956 | if (status) |
5364 | goto out; | 5957 | goto out; |
5365 | status = decode_putfh(&xdr); | 5958 | status = decode_putfh(xdr); |
5366 | if (status) | 5959 | if (status) |
5367 | goto out; | 5960 | goto out; |
5368 | status = decode_readdir(&xdr, rqstp, res); | 5961 | status = decode_readdir(xdr, rqstp, res); |
5369 | out: | 5962 | out: |
5370 | return status; | 5963 | return status; |
5371 | } | 5964 | } |
@@ -5373,23 +5966,22 @@ out: | |||
5373 | /* | 5966 | /* |
5374 | * Decode Read response | 5967 | * Decode Read response |
5375 | */ | 5968 | */ |
5376 | static int nfs4_xdr_dec_read(struct rpc_rqst *rqstp, __be32 *p, struct nfs_readres *res) | 5969 | static int nfs4_xdr_dec_read(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
5970 | struct nfs_readres *res) | ||
5377 | { | 5971 | { |
5378 | struct xdr_stream xdr; | ||
5379 | struct compound_hdr hdr; | 5972 | struct compound_hdr hdr; |
5380 | int status; | 5973 | int status; |
5381 | 5974 | ||
5382 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); | 5975 | status = decode_compound_hdr(xdr, &hdr); |
5383 | status = decode_compound_hdr(&xdr, &hdr); | ||
5384 | if (status) | 5976 | if (status) |
5385 | goto out; | 5977 | goto out; |
5386 | status = decode_sequence(&xdr, &res->seq_res, rqstp); | 5978 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
5387 | if (status) | 5979 | if (status) |
5388 | goto out; | 5980 | goto out; |
5389 | status = decode_putfh(&xdr); | 5981 | status = decode_putfh(xdr); |
5390 | if (status) | 5982 | if (status) |
5391 | goto out; | 5983 | goto out; |
5392 | status = decode_read(&xdr, rqstp, res); | 5984 | status = decode_read(xdr, rqstp, res); |
5393 | if (!status) | 5985 | if (!status) |
5394 | status = res->count; | 5986 | status = res->count; |
5395 | out: | 5987 | out: |
@@ -5399,27 +5991,27 @@ out: | |||
5399 | /* | 5991 | /* |
5400 | * Decode WRITE response | 5992 | * Decode WRITE response |
5401 | */ | 5993 | */ |
5402 | static int nfs4_xdr_dec_write(struct rpc_rqst *rqstp, __be32 *p, struct nfs_writeres *res) | 5994 | static int nfs4_xdr_dec_write(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
5995 | struct nfs_writeres *res) | ||
5403 | { | 5996 | { |
5404 | struct xdr_stream xdr; | ||
5405 | struct compound_hdr hdr; | 5997 | struct compound_hdr hdr; |
5406 | int status; | 5998 | int status; |
5407 | 5999 | ||
5408 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); | 6000 | status = decode_compound_hdr(xdr, &hdr); |
5409 | status = decode_compound_hdr(&xdr, &hdr); | ||
5410 | if (status) | 6001 | if (status) |
5411 | goto out; | 6002 | goto out; |
5412 | status = decode_sequence(&xdr, &res->seq_res, rqstp); | 6003 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
5413 | if (status) | 6004 | if (status) |
5414 | goto out; | 6005 | goto out; |
5415 | status = decode_putfh(&xdr); | 6006 | status = decode_putfh(xdr); |
5416 | if (status) | 6007 | if (status) |
5417 | goto out; | 6008 | goto out; |
5418 | status = decode_write(&xdr, res); | 6009 | status = decode_write(xdr, res); |
5419 | if (status) | 6010 | if (status) |
5420 | goto out; | 6011 | goto out; |
5421 | decode_getfattr(&xdr, res->fattr, res->server, | 6012 | if (res->fattr) |
5422 | !RPC_IS_ASYNC(rqstp->rq_task)); | 6013 | decode_getfattr(xdr, res->fattr, res->server, |
6014 | !RPC_IS_ASYNC(rqstp->rq_task)); | ||
5423 | if (!status) | 6015 | if (!status) |
5424 | status = res->count; | 6016 | status = res->count; |
5425 | out: | 6017 | out: |
@@ -5429,27 +6021,27 @@ out: | |||
5429 | /* | 6021 | /* |
5430 | * Decode COMMIT response | 6022 | * Decode COMMIT response |
5431 | */ | 6023 | */ |
5432 | static int nfs4_xdr_dec_commit(struct rpc_rqst *rqstp, __be32 *p, struct nfs_writeres *res) | 6024 | static int nfs4_xdr_dec_commit(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
6025 | struct nfs_writeres *res) | ||
5433 | { | 6026 | { |
5434 | struct xdr_stream xdr; | ||
5435 | struct compound_hdr hdr; | 6027 | struct compound_hdr hdr; |
5436 | int status; | 6028 | int status; |
5437 | 6029 | ||
5438 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); | 6030 | status = decode_compound_hdr(xdr, &hdr); |
5439 | status = decode_compound_hdr(&xdr, &hdr); | ||
5440 | if (status) | 6031 | if (status) |
5441 | goto out; | 6032 | goto out; |
5442 | status = decode_sequence(&xdr, &res->seq_res, rqstp); | 6033 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
5443 | if (status) | 6034 | if (status) |
5444 | goto out; | 6035 | goto out; |
5445 | status = decode_putfh(&xdr); | 6036 | status = decode_putfh(xdr); |
5446 | if (status) | 6037 | if (status) |
5447 | goto out; | 6038 | goto out; |
5448 | status = decode_commit(&xdr, res); | 6039 | status = decode_commit(xdr, res); |
5449 | if (status) | 6040 | if (status) |
5450 | goto out; | 6041 | goto out; |
5451 | decode_getfattr(&xdr, res->fattr, res->server, | 6042 | if (res->fattr) |
5452 | !RPC_IS_ASYNC(rqstp->rq_task)); | 6043 | decode_getfattr(xdr, res->fattr, res->server, |
6044 | !RPC_IS_ASYNC(rqstp->rq_task)); | ||
5453 | out: | 6045 | out: |
5454 | return status; | 6046 | return status; |
5455 | } | 6047 | } |
@@ -5457,85 +6049,80 @@ out: | |||
5457 | /* | 6049 | /* |
5458 | * Decode FSINFO response | 6050 | * Decode FSINFO response |
5459 | */ | 6051 | */ |
5460 | static int nfs4_xdr_dec_fsinfo(struct rpc_rqst *req, __be32 *p, | 6052 | static int nfs4_xdr_dec_fsinfo(struct rpc_rqst *req, struct xdr_stream *xdr, |
5461 | struct nfs4_fsinfo_res *res) | 6053 | struct nfs4_fsinfo_res *res) |
5462 | { | 6054 | { |
5463 | struct xdr_stream xdr; | ||
5464 | struct compound_hdr hdr; | 6055 | struct compound_hdr hdr; |
5465 | int status; | 6056 | int status; |
5466 | 6057 | ||
5467 | xdr_init_decode(&xdr, &req->rq_rcv_buf, p); | 6058 | status = decode_compound_hdr(xdr, &hdr); |
5468 | status = decode_compound_hdr(&xdr, &hdr); | ||
5469 | if (!status) | 6059 | if (!status) |
5470 | status = decode_sequence(&xdr, &res->seq_res, req); | 6060 | status = decode_sequence(xdr, &res->seq_res, req); |
5471 | if (!status) | 6061 | if (!status) |
5472 | status = decode_putfh(&xdr); | 6062 | status = decode_putfh(xdr); |
5473 | if (!status) | 6063 | if (!status) |
5474 | status = decode_fsinfo(&xdr, res->fsinfo); | 6064 | status = decode_fsinfo(xdr, res->fsinfo); |
5475 | return status; | 6065 | return status; |
5476 | } | 6066 | } |
5477 | 6067 | ||
5478 | /* | 6068 | /* |
5479 | * Decode PATHCONF response | 6069 | * Decode PATHCONF response |
5480 | */ | 6070 | */ |
5481 | static int nfs4_xdr_dec_pathconf(struct rpc_rqst *req, __be32 *p, | 6071 | static int nfs4_xdr_dec_pathconf(struct rpc_rqst *req, struct xdr_stream *xdr, |
5482 | struct nfs4_pathconf_res *res) | 6072 | struct nfs4_pathconf_res *res) |
5483 | { | 6073 | { |
5484 | struct xdr_stream xdr; | ||
5485 | struct compound_hdr hdr; | 6074 | struct compound_hdr hdr; |
5486 | int status; | 6075 | int status; |
5487 | 6076 | ||
5488 | xdr_init_decode(&xdr, &req->rq_rcv_buf, p); | 6077 | status = decode_compound_hdr(xdr, &hdr); |
5489 | status = decode_compound_hdr(&xdr, &hdr); | ||
5490 | if (!status) | 6078 | if (!status) |
5491 | status = decode_sequence(&xdr, &res->seq_res, req); | 6079 | status = decode_sequence(xdr, &res->seq_res, req); |
5492 | if (!status) | 6080 | if (!status) |
5493 | status = decode_putfh(&xdr); | 6081 | status = decode_putfh(xdr); |
5494 | if (!status) | 6082 | if (!status) |
5495 | status = decode_pathconf(&xdr, res->pathconf); | 6083 | status = decode_pathconf(xdr, res->pathconf); |
5496 | return status; | 6084 | return status; |
5497 | } | 6085 | } |
5498 | 6086 | ||
5499 | /* | 6087 | /* |
5500 | * Decode STATFS response | 6088 | * Decode STATFS response |
5501 | */ | 6089 | */ |
5502 | static int nfs4_xdr_dec_statfs(struct rpc_rqst *req, __be32 *p, | 6090 | static int nfs4_xdr_dec_statfs(struct rpc_rqst *req, struct xdr_stream *xdr, |
5503 | struct nfs4_statfs_res *res) | 6091 | struct nfs4_statfs_res *res) |
5504 | { | 6092 | { |
5505 | struct xdr_stream xdr; | ||
5506 | struct compound_hdr hdr; | 6093 | struct compound_hdr hdr; |
5507 | int status; | 6094 | int status; |
5508 | 6095 | ||
5509 | xdr_init_decode(&xdr, &req->rq_rcv_buf, p); | 6096 | status = decode_compound_hdr(xdr, &hdr); |
5510 | status = decode_compound_hdr(&xdr, &hdr); | ||
5511 | if (!status) | 6097 | if (!status) |
5512 | status = decode_sequence(&xdr, &res->seq_res, req); | 6098 | status = decode_sequence(xdr, &res->seq_res, req); |
5513 | if (!status) | 6099 | if (!status) |
5514 | status = decode_putfh(&xdr); | 6100 | status = decode_putfh(xdr); |
5515 | if (!status) | 6101 | if (!status) |
5516 | status = decode_statfs(&xdr, res->fsstat); | 6102 | status = decode_statfs(xdr, res->fsstat); |
5517 | return status; | 6103 | return status; |
5518 | } | 6104 | } |
5519 | 6105 | ||
5520 | /* | 6106 | /* |
5521 | * Decode GETATTR_BITMAP response | 6107 | * Decode GETATTR_BITMAP response |
5522 | */ | 6108 | */ |
5523 | static int nfs4_xdr_dec_server_caps(struct rpc_rqst *req, __be32 *p, struct nfs4_server_caps_res *res) | 6109 | static int nfs4_xdr_dec_server_caps(struct rpc_rqst *req, |
6110 | struct xdr_stream *xdr, | ||
6111 | struct nfs4_server_caps_res *res) | ||
5524 | { | 6112 | { |
5525 | struct xdr_stream xdr; | ||
5526 | struct compound_hdr hdr; | 6113 | struct compound_hdr hdr; |
5527 | int status; | 6114 | int status; |
5528 | 6115 | ||
5529 | xdr_init_decode(&xdr, &req->rq_rcv_buf, p); | 6116 | status = decode_compound_hdr(xdr, &hdr); |
5530 | status = decode_compound_hdr(&xdr, &hdr); | ||
5531 | if (status) | 6117 | if (status) |
5532 | goto out; | 6118 | goto out; |
5533 | status = decode_sequence(&xdr, &res->seq_res, req); | 6119 | status = decode_sequence(xdr, &res->seq_res, req); |
5534 | if (status) | 6120 | if (status) |
5535 | goto out; | 6121 | goto out; |
5536 | if ((status = decode_putfh(&xdr)) != 0) | 6122 | status = decode_putfh(xdr); |
6123 | if (status) | ||
5537 | goto out; | 6124 | goto out; |
5538 | status = decode_server_caps(&xdr, res); | 6125 | status = decode_server_caps(xdr, res); |
5539 | out: | 6126 | out: |
5540 | return status; | 6127 | return status; |
5541 | } | 6128 | } |
@@ -5543,79 +6130,77 @@ out: | |||
5543 | /* | 6130 | /* |
5544 | * Decode RENEW response | 6131 | * Decode RENEW response |
5545 | */ | 6132 | */ |
5546 | static int nfs4_xdr_dec_renew(struct rpc_rqst *rqstp, __be32 *p, void *dummy) | 6133 | static int nfs4_xdr_dec_renew(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
6134 | void *__unused) | ||
5547 | { | 6135 | { |
5548 | struct xdr_stream xdr; | ||
5549 | struct compound_hdr hdr; | 6136 | struct compound_hdr hdr; |
5550 | int status; | 6137 | int status; |
5551 | 6138 | ||
5552 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); | 6139 | status = decode_compound_hdr(xdr, &hdr); |
5553 | status = decode_compound_hdr(&xdr, &hdr); | ||
5554 | if (!status) | 6140 | if (!status) |
5555 | status = decode_renew(&xdr); | 6141 | status = decode_renew(xdr); |
5556 | return status; | 6142 | return status; |
5557 | } | 6143 | } |
5558 | 6144 | ||
5559 | /* | 6145 | /* |
5560 | * Decode SETCLIENTID response | 6146 | * Decode SETCLIENTID response |
5561 | */ | 6147 | */ |
5562 | static int nfs4_xdr_dec_setclientid(struct rpc_rqst *req, __be32 *p, | 6148 | static int nfs4_xdr_dec_setclientid(struct rpc_rqst *req, |
5563 | struct nfs4_setclientid_res *res) | 6149 | struct xdr_stream *xdr, |
6150 | struct nfs4_setclientid_res *res) | ||
5564 | { | 6151 | { |
5565 | struct xdr_stream xdr; | ||
5566 | struct compound_hdr hdr; | 6152 | struct compound_hdr hdr; |
5567 | int status; | 6153 | int status; |
5568 | 6154 | ||
5569 | xdr_init_decode(&xdr, &req->rq_rcv_buf, p); | 6155 | status = decode_compound_hdr(xdr, &hdr); |
5570 | status = decode_compound_hdr(&xdr, &hdr); | ||
5571 | if (!status) | 6156 | if (!status) |
5572 | status = decode_setclientid(&xdr, res); | 6157 | status = decode_setclientid(xdr, res); |
5573 | return status; | 6158 | return status; |
5574 | } | 6159 | } |
5575 | 6160 | ||
5576 | /* | 6161 | /* |
5577 | * Decode SETCLIENTID_CONFIRM response | 6162 | * Decode SETCLIENTID_CONFIRM response |
5578 | */ | 6163 | */ |
5579 | static int nfs4_xdr_dec_setclientid_confirm(struct rpc_rqst *req, __be32 *p, struct nfs_fsinfo *fsinfo) | 6164 | static int nfs4_xdr_dec_setclientid_confirm(struct rpc_rqst *req, |
6165 | struct xdr_stream *xdr, | ||
6166 | struct nfs_fsinfo *fsinfo) | ||
5580 | { | 6167 | { |
5581 | struct xdr_stream xdr; | ||
5582 | struct compound_hdr hdr; | 6168 | struct compound_hdr hdr; |
5583 | int status; | 6169 | int status; |
5584 | 6170 | ||
5585 | xdr_init_decode(&xdr, &req->rq_rcv_buf, p); | 6171 | status = decode_compound_hdr(xdr, &hdr); |
5586 | status = decode_compound_hdr(&xdr, &hdr); | ||
5587 | if (!status) | 6172 | if (!status) |
5588 | status = decode_setclientid_confirm(&xdr); | 6173 | status = decode_setclientid_confirm(xdr); |
5589 | if (!status) | 6174 | if (!status) |
5590 | status = decode_putrootfh(&xdr); | 6175 | status = decode_putrootfh(xdr); |
5591 | if (!status) | 6176 | if (!status) |
5592 | status = decode_fsinfo(&xdr, fsinfo); | 6177 | status = decode_fsinfo(xdr, fsinfo); |
5593 | return status; | 6178 | return status; |
5594 | } | 6179 | } |
5595 | 6180 | ||
5596 | /* | 6181 | /* |
5597 | * Decode DELEGRETURN response | 6182 | * Decode DELEGRETURN response |
5598 | */ | 6183 | */ |
5599 | static int nfs4_xdr_dec_delegreturn(struct rpc_rqst *rqstp, __be32 *p, struct nfs4_delegreturnres *res) | 6184 | static int nfs4_xdr_dec_delegreturn(struct rpc_rqst *rqstp, |
6185 | struct xdr_stream *xdr, | ||
6186 | struct nfs4_delegreturnres *res) | ||
5600 | { | 6187 | { |
5601 | struct xdr_stream xdr; | ||
5602 | struct compound_hdr hdr; | 6188 | struct compound_hdr hdr; |
5603 | int status; | 6189 | int status; |
5604 | 6190 | ||
5605 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); | 6191 | status = decode_compound_hdr(xdr, &hdr); |
5606 | status = decode_compound_hdr(&xdr, &hdr); | ||
5607 | if (status) | 6192 | if (status) |
5608 | goto out; | 6193 | goto out; |
5609 | status = decode_sequence(&xdr, &res->seq_res, rqstp); | 6194 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
5610 | if (status) | 6195 | if (status) |
5611 | goto out; | 6196 | goto out; |
5612 | status = decode_putfh(&xdr); | 6197 | status = decode_putfh(xdr); |
5613 | if (status != 0) | 6198 | if (status != 0) |
5614 | goto out; | 6199 | goto out; |
5615 | status = decode_delegreturn(&xdr); | 6200 | status = decode_delegreturn(xdr); |
5616 | if (status != 0) | 6201 | if (status != 0) |
5617 | goto out; | 6202 | goto out; |
5618 | decode_getfattr(&xdr, res->fattr, res->server, | 6203 | decode_getfattr(xdr, res->fattr, res->server, |
5619 | !RPC_IS_ASYNC(rqstp->rq_task)); | 6204 | !RPC_IS_ASYNC(rqstp->rq_task)); |
5620 | out: | 6205 | out: |
5621 | return status; | 6206 | return status; |
@@ -5624,159 +6209,303 @@ out: | |||
5624 | /* | 6209 | /* |
5625 | * Decode FS_LOCATIONS response | 6210 | * Decode FS_LOCATIONS response |
5626 | */ | 6211 | */ |
5627 | static int nfs4_xdr_dec_fs_locations(struct rpc_rqst *req, __be32 *p, | 6212 | static int nfs4_xdr_dec_fs_locations(struct rpc_rqst *req, |
6213 | struct xdr_stream *xdr, | ||
5628 | struct nfs4_fs_locations_res *res) | 6214 | struct nfs4_fs_locations_res *res) |
5629 | { | 6215 | { |
5630 | struct xdr_stream xdr; | ||
5631 | struct compound_hdr hdr; | 6216 | struct compound_hdr hdr; |
5632 | int status; | 6217 | int status; |
5633 | 6218 | ||
5634 | xdr_init_decode(&xdr, &req->rq_rcv_buf, p); | 6219 | status = decode_compound_hdr(xdr, &hdr); |
5635 | status = decode_compound_hdr(&xdr, &hdr); | ||
5636 | if (status) | 6220 | if (status) |
5637 | goto out; | 6221 | goto out; |
5638 | status = decode_sequence(&xdr, &res->seq_res, req); | 6222 | status = decode_sequence(xdr, &res->seq_res, req); |
5639 | if (status) | 6223 | if (status) |
5640 | goto out; | 6224 | goto out; |
5641 | if ((status = decode_putfh(&xdr)) != 0) | 6225 | status = decode_putfh(xdr); |
6226 | if (status) | ||
5642 | goto out; | 6227 | goto out; |
5643 | if ((status = decode_lookup(&xdr)) != 0) | 6228 | status = decode_lookup(xdr); |
6229 | if (status) | ||
5644 | goto out; | 6230 | goto out; |
5645 | xdr_enter_page(&xdr, PAGE_SIZE); | 6231 | xdr_enter_page(xdr, PAGE_SIZE); |
5646 | status = decode_getfattr(&xdr, &res->fs_locations->fattr, | 6232 | status = decode_getfattr(xdr, &res->fs_locations->fattr, |
5647 | res->fs_locations->server, | 6233 | res->fs_locations->server, |
5648 | !RPC_IS_ASYNC(req->rq_task)); | 6234 | !RPC_IS_ASYNC(req->rq_task)); |
5649 | out: | 6235 | out: |
5650 | return status; | 6236 | return status; |
5651 | } | 6237 | } |
5652 | 6238 | ||
6239 | /* | ||
6240 | * Decode SECINFO response | ||
6241 | */ | ||
6242 | static int nfs4_xdr_dec_secinfo(struct rpc_rqst *rqstp, | ||
6243 | struct xdr_stream *xdr, | ||
6244 | struct nfs4_secinfo_res *res) | ||
6245 | { | ||
6246 | struct compound_hdr hdr; | ||
6247 | int status; | ||
6248 | |||
6249 | status = decode_compound_hdr(xdr, &hdr); | ||
6250 | if (status) | ||
6251 | goto out; | ||
6252 | status = decode_sequence(xdr, &res->seq_res, rqstp); | ||
6253 | if (status) | ||
6254 | goto out; | ||
6255 | status = decode_putfh(xdr); | ||
6256 | if (status) | ||
6257 | goto out; | ||
6258 | status = decode_secinfo(xdr, res); | ||
6259 | if (status) | ||
6260 | goto out; | ||
6261 | out: | ||
6262 | return status; | ||
6263 | } | ||
6264 | |||
5653 | #if defined(CONFIG_NFS_V4_1) | 6265 | #if defined(CONFIG_NFS_V4_1) |
5654 | /* | 6266 | /* |
5655 | * Decode EXCHANGE_ID response | 6267 | * Decode EXCHANGE_ID response |
5656 | */ | 6268 | */ |
5657 | static int nfs4_xdr_dec_exchange_id(struct rpc_rqst *rqstp, uint32_t *p, | 6269 | static int nfs4_xdr_dec_exchange_id(struct rpc_rqst *rqstp, |
6270 | struct xdr_stream *xdr, | ||
5658 | void *res) | 6271 | void *res) |
5659 | { | 6272 | { |
5660 | struct xdr_stream xdr; | ||
5661 | struct compound_hdr hdr; | 6273 | struct compound_hdr hdr; |
5662 | int status; | 6274 | int status; |
5663 | 6275 | ||
5664 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); | 6276 | status = decode_compound_hdr(xdr, &hdr); |
5665 | status = decode_compound_hdr(&xdr, &hdr); | ||
5666 | if (!status) | 6277 | if (!status) |
5667 | status = decode_exchange_id(&xdr, res); | 6278 | status = decode_exchange_id(xdr, res); |
5668 | return status; | 6279 | return status; |
5669 | } | 6280 | } |
5670 | 6281 | ||
5671 | /* | 6282 | /* |
5672 | * Decode CREATE_SESSION response | 6283 | * Decode CREATE_SESSION response |
5673 | */ | 6284 | */ |
5674 | static int nfs4_xdr_dec_create_session(struct rpc_rqst *rqstp, uint32_t *p, | 6285 | static int nfs4_xdr_dec_create_session(struct rpc_rqst *rqstp, |
6286 | struct xdr_stream *xdr, | ||
5675 | struct nfs41_create_session_res *res) | 6287 | struct nfs41_create_session_res *res) |
5676 | { | 6288 | { |
5677 | struct xdr_stream xdr; | ||
5678 | struct compound_hdr hdr; | 6289 | struct compound_hdr hdr; |
5679 | int status; | 6290 | int status; |
5680 | 6291 | ||
5681 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); | 6292 | status = decode_compound_hdr(xdr, &hdr); |
5682 | status = decode_compound_hdr(&xdr, &hdr); | ||
5683 | if (!status) | 6293 | if (!status) |
5684 | status = decode_create_session(&xdr, res); | 6294 | status = decode_create_session(xdr, res); |
5685 | return status; | 6295 | return status; |
5686 | } | 6296 | } |
5687 | 6297 | ||
5688 | /* | 6298 | /* |
5689 | * Decode DESTROY_SESSION response | 6299 | * Decode DESTROY_SESSION response |
5690 | */ | 6300 | */ |
5691 | static int nfs4_xdr_dec_destroy_session(struct rpc_rqst *rqstp, uint32_t *p, | 6301 | static int nfs4_xdr_dec_destroy_session(struct rpc_rqst *rqstp, |
5692 | void *dummy) | 6302 | struct xdr_stream *xdr, |
6303 | void *res) | ||
5693 | { | 6304 | { |
5694 | struct xdr_stream xdr; | ||
5695 | struct compound_hdr hdr; | 6305 | struct compound_hdr hdr; |
5696 | int status; | 6306 | int status; |
5697 | 6307 | ||
5698 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); | 6308 | status = decode_compound_hdr(xdr, &hdr); |
5699 | status = decode_compound_hdr(&xdr, &hdr); | ||
5700 | if (!status) | 6309 | if (!status) |
5701 | status = decode_destroy_session(&xdr, dummy); | 6310 | status = decode_destroy_session(xdr, res); |
5702 | return status; | 6311 | return status; |
5703 | } | 6312 | } |
5704 | 6313 | ||
5705 | /* | 6314 | /* |
5706 | * Decode SEQUENCE response | 6315 | * Decode SEQUENCE response |
5707 | */ | 6316 | */ |
5708 | static int nfs4_xdr_dec_sequence(struct rpc_rqst *rqstp, uint32_t *p, | 6317 | static int nfs4_xdr_dec_sequence(struct rpc_rqst *rqstp, |
6318 | struct xdr_stream *xdr, | ||
5709 | struct nfs4_sequence_res *res) | 6319 | struct nfs4_sequence_res *res) |
5710 | { | 6320 | { |
5711 | struct xdr_stream xdr; | ||
5712 | struct compound_hdr hdr; | 6321 | struct compound_hdr hdr; |
5713 | int status; | 6322 | int status; |
5714 | 6323 | ||
5715 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); | 6324 | status = decode_compound_hdr(xdr, &hdr); |
5716 | status = decode_compound_hdr(&xdr, &hdr); | ||
5717 | if (!status) | 6325 | if (!status) |
5718 | status = decode_sequence(&xdr, res, rqstp); | 6326 | status = decode_sequence(xdr, res, rqstp); |
5719 | return status; | 6327 | return status; |
5720 | } | 6328 | } |
5721 | 6329 | ||
5722 | /* | 6330 | /* |
5723 | * Decode GET_LEASE_TIME response | 6331 | * Decode GET_LEASE_TIME response |
5724 | */ | 6332 | */ |
5725 | static int nfs4_xdr_dec_get_lease_time(struct rpc_rqst *rqstp, uint32_t *p, | 6333 | static int nfs4_xdr_dec_get_lease_time(struct rpc_rqst *rqstp, |
6334 | struct xdr_stream *xdr, | ||
5726 | struct nfs4_get_lease_time_res *res) | 6335 | struct nfs4_get_lease_time_res *res) |
5727 | { | 6336 | { |
5728 | struct xdr_stream xdr; | ||
5729 | struct compound_hdr hdr; | 6337 | struct compound_hdr hdr; |
5730 | int status; | 6338 | int status; |
5731 | 6339 | ||
5732 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); | 6340 | status = decode_compound_hdr(xdr, &hdr); |
5733 | status = decode_compound_hdr(&xdr, &hdr); | ||
5734 | if (!status) | 6341 | if (!status) |
5735 | status = decode_sequence(&xdr, &res->lr_seq_res, rqstp); | 6342 | status = decode_sequence(xdr, &res->lr_seq_res, rqstp); |
5736 | if (!status) | 6343 | if (!status) |
5737 | status = decode_putrootfh(&xdr); | 6344 | status = decode_putrootfh(xdr); |
5738 | if (!status) | 6345 | if (!status) |
5739 | status = decode_fsinfo(&xdr, res->lr_fsinfo); | 6346 | status = decode_fsinfo(xdr, res->lr_fsinfo); |
5740 | return status; | 6347 | return status; |
5741 | } | 6348 | } |
5742 | 6349 | ||
5743 | /* | 6350 | /* |
5744 | * Decode RECLAIM_COMPLETE response | 6351 | * Decode RECLAIM_COMPLETE response |
5745 | */ | 6352 | */ |
5746 | static int nfs4_xdr_dec_reclaim_complete(struct rpc_rqst *rqstp, uint32_t *p, | 6353 | static int nfs4_xdr_dec_reclaim_complete(struct rpc_rqst *rqstp, |
6354 | struct xdr_stream *xdr, | ||
5747 | struct nfs41_reclaim_complete_res *res) | 6355 | struct nfs41_reclaim_complete_res *res) |
5748 | { | 6356 | { |
5749 | struct xdr_stream xdr; | ||
5750 | struct compound_hdr hdr; | 6357 | struct compound_hdr hdr; |
5751 | int status; | 6358 | int status; |
5752 | 6359 | ||
5753 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); | 6360 | status = decode_compound_hdr(xdr, &hdr); |
5754 | status = decode_compound_hdr(&xdr, &hdr); | ||
5755 | if (!status) | 6361 | if (!status) |
5756 | status = decode_sequence(&xdr, &res->seq_res, rqstp); | 6362 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
5757 | if (!status) | 6363 | if (!status) |
5758 | status = decode_reclaim_complete(&xdr, (void *)NULL); | 6364 | status = decode_reclaim_complete(xdr, (void *)NULL); |
6365 | return status; | ||
6366 | } | ||
6367 | |||
6368 | /* | ||
6369 | * Decode GETDEVINFO response | ||
6370 | */ | ||
6371 | static int nfs4_xdr_dec_getdeviceinfo(struct rpc_rqst *rqstp, | ||
6372 | struct xdr_stream *xdr, | ||
6373 | struct nfs4_getdeviceinfo_res *res) | ||
6374 | { | ||
6375 | struct compound_hdr hdr; | ||
6376 | int status; | ||
6377 | |||
6378 | status = decode_compound_hdr(xdr, &hdr); | ||
6379 | if (status != 0) | ||
6380 | goto out; | ||
6381 | status = decode_sequence(xdr, &res->seq_res, rqstp); | ||
6382 | if (status != 0) | ||
6383 | goto out; | ||
6384 | status = decode_getdeviceinfo(xdr, res->pdev); | ||
6385 | out: | ||
6386 | return status; | ||
6387 | } | ||
6388 | |||
6389 | /* | ||
6390 | * Decode LAYOUTGET response | ||
6391 | */ | ||
6392 | static int nfs4_xdr_dec_layoutget(struct rpc_rqst *rqstp, | ||
6393 | struct xdr_stream *xdr, | ||
6394 | struct nfs4_layoutget_res *res) | ||
6395 | { | ||
6396 | struct compound_hdr hdr; | ||
6397 | int status; | ||
6398 | |||
6399 | status = decode_compound_hdr(xdr, &hdr); | ||
6400 | if (status) | ||
6401 | goto out; | ||
6402 | status = decode_sequence(xdr, &res->seq_res, rqstp); | ||
6403 | if (status) | ||
6404 | goto out; | ||
6405 | status = decode_putfh(xdr); | ||
6406 | if (status) | ||
6407 | goto out; | ||
6408 | status = decode_layoutget(xdr, rqstp, res); | ||
6409 | out: | ||
6410 | return status; | ||
6411 | } | ||
6412 | |||
6413 | /* | ||
6414 | * Decode LAYOUTRETURN response | ||
6415 | */ | ||
6416 | static int nfs4_xdr_dec_layoutreturn(struct rpc_rqst *rqstp, | ||
6417 | struct xdr_stream *xdr, | ||
6418 | struct nfs4_layoutreturn_res *res) | ||
6419 | { | ||
6420 | struct compound_hdr hdr; | ||
6421 | int status; | ||
6422 | |||
6423 | status = decode_compound_hdr(xdr, &hdr); | ||
6424 | if (status) | ||
6425 | goto out; | ||
6426 | status = decode_sequence(xdr, &res->seq_res, rqstp); | ||
6427 | if (status) | ||
6428 | goto out; | ||
6429 | status = decode_putfh(xdr); | ||
6430 | if (status) | ||
6431 | goto out; | ||
6432 | status = decode_layoutreturn(xdr, res); | ||
6433 | out: | ||
6434 | return status; | ||
6435 | } | ||
6436 | |||
6437 | /* | ||
6438 | * Decode LAYOUTCOMMIT response | ||
6439 | */ | ||
6440 | static int nfs4_xdr_dec_layoutcommit(struct rpc_rqst *rqstp, | ||
6441 | struct xdr_stream *xdr, | ||
6442 | struct nfs4_layoutcommit_res *res) | ||
6443 | { | ||
6444 | struct compound_hdr hdr; | ||
6445 | int status; | ||
6446 | |||
6447 | status = decode_compound_hdr(xdr, &hdr); | ||
6448 | if (status) | ||
6449 | goto out; | ||
6450 | status = decode_sequence(xdr, &res->seq_res, rqstp); | ||
6451 | if (status) | ||
6452 | goto out; | ||
6453 | status = decode_putfh(xdr); | ||
6454 | if (status) | ||
6455 | goto out; | ||
6456 | status = decode_layoutcommit(xdr, rqstp, res); | ||
6457 | if (status) | ||
6458 | goto out; | ||
6459 | decode_getfattr(xdr, res->fattr, res->server, | ||
6460 | !RPC_IS_ASYNC(rqstp->rq_task)); | ||
6461 | out: | ||
5759 | return status; | 6462 | return status; |
5760 | } | 6463 | } |
5761 | #endif /* CONFIG_NFS_V4_1 */ | 6464 | #endif /* CONFIG_NFS_V4_1 */ |
5762 | 6465 | ||
5763 | __be32 *nfs4_decode_dirent(__be32 *p, struct nfs_entry *entry, int plus) | 6466 | /** |
6467 | * nfs4_decode_dirent - Decode a single NFSv4 directory entry stored in | ||
6468 | * the local page cache. | ||
6469 | * @xdr: XDR stream where entry resides | ||
6470 | * @entry: buffer to fill in with entry data | ||
6471 | * @plus: boolean indicating whether this should be a readdirplus entry | ||
6472 | * | ||
6473 | * Returns zero if successful, otherwise a negative errno value is | ||
6474 | * returned. | ||
6475 | * | ||
6476 | * This function is not invoked during READDIR reply decoding, but | ||
6477 | * rather whenever an application invokes the getdents(2) system call | ||
6478 | * on a directory already in our cache. | ||
6479 | */ | ||
6480 | int nfs4_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry, | ||
6481 | int plus) | ||
5764 | { | 6482 | { |
5765 | uint32_t bitmap[2] = {0}; | 6483 | uint32_t bitmap[2] = {0}; |
5766 | uint32_t len; | 6484 | uint32_t len; |
5767 | 6485 | __be32 *p = xdr_inline_decode(xdr, 4); | |
5768 | if (!*p++) { | 6486 | if (unlikely(!p)) |
5769 | if (!*p) | 6487 | goto out_overflow; |
5770 | return ERR_PTR(-EAGAIN); | 6488 | if (*p == xdr_zero) { |
6489 | p = xdr_inline_decode(xdr, 4); | ||
6490 | if (unlikely(!p)) | ||
6491 | goto out_overflow; | ||
6492 | if (*p == xdr_zero) | ||
6493 | return -EAGAIN; | ||
5771 | entry->eof = 1; | 6494 | entry->eof = 1; |
5772 | return ERR_PTR(-EBADCOOKIE); | 6495 | return -EBADCOOKIE; |
5773 | } | 6496 | } |
5774 | 6497 | ||
6498 | p = xdr_inline_decode(xdr, 12); | ||
6499 | if (unlikely(!p)) | ||
6500 | goto out_overflow; | ||
5775 | entry->prev_cookie = entry->cookie; | 6501 | entry->prev_cookie = entry->cookie; |
5776 | p = xdr_decode_hyper(p, &entry->cookie); | 6502 | p = xdr_decode_hyper(p, &entry->cookie); |
5777 | entry->len = ntohl(*p++); | 6503 | entry->len = be32_to_cpup(p); |
6504 | |||
6505 | p = xdr_inline_decode(xdr, entry->len); | ||
6506 | if (unlikely(!p)) | ||
6507 | goto out_overflow; | ||
5778 | entry->name = (const char *) p; | 6508 | entry->name = (const char *) p; |
5779 | p += XDR_QUADLEN(entry->len); | ||
5780 | 6509 | ||
5781 | /* | 6510 | /* |
5782 | * In case the server doesn't return an inode number, | 6511 | * In case the server doesn't return an inode number, |
@@ -5784,32 +6513,31 @@ __be32 *nfs4_decode_dirent(__be32 *p, struct nfs_entry *entry, int plus) | |||
5784 | * since glibc seems to choke on it...) | 6513 | * since glibc seems to choke on it...) |
5785 | */ | 6514 | */ |
5786 | entry->ino = 1; | 6515 | entry->ino = 1; |
6516 | entry->fattr->valid = 0; | ||
5787 | 6517 | ||
5788 | len = ntohl(*p++); /* bitmap length */ | 6518 | if (decode_attr_bitmap(xdr, bitmap) < 0) |
5789 | if (len-- > 0) { | 6519 | goto out_overflow; |
5790 | bitmap[0] = ntohl(*p++); | ||
5791 | if (len-- > 0) { | ||
5792 | bitmap[1] = ntohl(*p++); | ||
5793 | p += len; | ||
5794 | } | ||
5795 | } | ||
5796 | len = XDR_QUADLEN(ntohl(*p++)); /* attribute buffer length */ | ||
5797 | if (len > 0) { | ||
5798 | if (bitmap[0] & FATTR4_WORD0_RDATTR_ERROR) { | ||
5799 | bitmap[0] &= ~FATTR4_WORD0_RDATTR_ERROR; | ||
5800 | /* Ignore the return value of rdattr_error for now */ | ||
5801 | p++; | ||
5802 | len--; | ||
5803 | } | ||
5804 | if (bitmap[0] == 0 && bitmap[1] == FATTR4_WORD1_MOUNTED_ON_FILEID) | ||
5805 | xdr_decode_hyper(p, &entry->ino); | ||
5806 | else if (bitmap[0] == FATTR4_WORD0_FILEID) | ||
5807 | xdr_decode_hyper(p, &entry->ino); | ||
5808 | p += len; | ||
5809 | } | ||
5810 | 6520 | ||
5811 | entry->eof = !p[0] && p[1]; | 6521 | if (decode_attr_length(xdr, &len, &p) < 0) |
5812 | return p; | 6522 | goto out_overflow; |
6523 | |||
6524 | if (decode_getfattr_attrs(xdr, bitmap, entry->fattr, entry->fh, | ||
6525 | entry->server, 1) < 0) | ||
6526 | goto out_overflow; | ||
6527 | if (entry->fattr->valid & NFS_ATTR_FATTR_MOUNTED_ON_FILEID) | ||
6528 | entry->ino = entry->fattr->mounted_on_fileid; | ||
6529 | else if (entry->fattr->valid & NFS_ATTR_FATTR_FILEID) | ||
6530 | entry->ino = entry->fattr->fileid; | ||
6531 | |||
6532 | entry->d_type = DT_UNKNOWN; | ||
6533 | if (entry->fattr->valid & NFS_ATTR_FATTR_TYPE) | ||
6534 | entry->d_type = nfs_umode_to_dtype(entry->fattr->mode); | ||
6535 | |||
6536 | return 0; | ||
6537 | |||
6538 | out_overflow: | ||
6539 | print_overflow_msg(__func__, xdr); | ||
6540 | return -EAGAIN; | ||
5813 | } | 6541 | } |
5814 | 6542 | ||
5815 | /* | 6543 | /* |
@@ -5840,8 +6568,6 @@ static struct { | |||
5840 | { NFS4ERR_DQUOT, -EDQUOT }, | 6568 | { NFS4ERR_DQUOT, -EDQUOT }, |
5841 | { NFS4ERR_STALE, -ESTALE }, | 6569 | { NFS4ERR_STALE, -ESTALE }, |
5842 | { NFS4ERR_BADHANDLE, -EBADHANDLE }, | 6570 | { NFS4ERR_BADHANDLE, -EBADHANDLE }, |
5843 | { NFS4ERR_BADOWNER, -EINVAL }, | ||
5844 | { NFS4ERR_BADNAME, -EINVAL }, | ||
5845 | { NFS4ERR_BAD_COOKIE, -EBADCOOKIE }, | 6571 | { NFS4ERR_BAD_COOKIE, -EBADCOOKIE }, |
5846 | { NFS4ERR_NOTSUPP, -ENOTSUPP }, | 6572 | { NFS4ERR_NOTSUPP, -ENOTSUPP }, |
5847 | { NFS4ERR_TOOSMALL, -ETOOSMALL }, | 6573 | { NFS4ERR_TOOSMALL, -ETOOSMALL }, |
@@ -5851,10 +6577,6 @@ static struct { | |||
5851 | { NFS4ERR_SYMLINK, -ELOOP }, | 6577 | { NFS4ERR_SYMLINK, -ELOOP }, |
5852 | { NFS4ERR_OP_ILLEGAL, -EOPNOTSUPP }, | 6578 | { NFS4ERR_OP_ILLEGAL, -EOPNOTSUPP }, |
5853 | { NFS4ERR_DEADLOCK, -EDEADLK }, | 6579 | { NFS4ERR_DEADLOCK, -EDEADLK }, |
5854 | { NFS4ERR_WRONGSEC, -EPERM }, /* FIXME: this needs | ||
5855 | * to be handled by a | ||
5856 | * middle-layer. | ||
5857 | */ | ||
5858 | { -1, -EIO } | 6580 | { -1, -EIO } |
5859 | }; | 6581 | }; |
5860 | 6582 | ||
@@ -5885,8 +6607,8 @@ nfs4_stat_to_errno(int stat) | |||
5885 | #define PROC(proc, argtype, restype) \ | 6607 | #define PROC(proc, argtype, restype) \ |
5886 | [NFSPROC4_CLNT_##proc] = { \ | 6608 | [NFSPROC4_CLNT_##proc] = { \ |
5887 | .p_proc = NFSPROC4_COMPOUND, \ | 6609 | .p_proc = NFSPROC4_COMPOUND, \ |
5888 | .p_encode = (kxdrproc_t) nfs4_xdr_##argtype, \ | 6610 | .p_encode = (kxdreproc_t)nfs4_xdr_##argtype, \ |
5889 | .p_decode = (kxdrproc_t) nfs4_xdr_##restype, \ | 6611 | .p_decode = (kxdrdproc_t)nfs4_xdr_##restype, \ |
5890 | .p_arglen = NFS4_##argtype##_sz, \ | 6612 | .p_arglen = NFS4_##argtype##_sz, \ |
5891 | .p_replen = NFS4_##restype##_sz, \ | 6613 | .p_replen = NFS4_##restype##_sz, \ |
5892 | .p_statidx = NFSPROC4_CLNT_##proc, \ | 6614 | .p_statidx = NFSPROC4_CLNT_##proc, \ |
@@ -5894,48 +6616,53 @@ nfs4_stat_to_errno(int stat) | |||
5894 | } | 6616 | } |
5895 | 6617 | ||
5896 | struct rpc_procinfo nfs4_procedures[] = { | 6618 | struct rpc_procinfo nfs4_procedures[] = { |
5897 | PROC(READ, enc_read, dec_read), | 6619 | PROC(READ, enc_read, dec_read), |
5898 | PROC(WRITE, enc_write, dec_write), | 6620 | PROC(WRITE, enc_write, dec_write), |
5899 | PROC(COMMIT, enc_commit, dec_commit), | 6621 | PROC(COMMIT, enc_commit, dec_commit), |
5900 | PROC(OPEN, enc_open, dec_open), | 6622 | PROC(OPEN, enc_open, dec_open), |
5901 | PROC(OPEN_CONFIRM, enc_open_confirm, dec_open_confirm), | 6623 | PROC(OPEN_CONFIRM, enc_open_confirm, dec_open_confirm), |
5902 | PROC(OPEN_NOATTR, enc_open_noattr, dec_open_noattr), | 6624 | PROC(OPEN_NOATTR, enc_open_noattr, dec_open_noattr), |
5903 | PROC(OPEN_DOWNGRADE, enc_open_downgrade, dec_open_downgrade), | 6625 | PROC(OPEN_DOWNGRADE, enc_open_downgrade, dec_open_downgrade), |
5904 | PROC(CLOSE, enc_close, dec_close), | 6626 | PROC(CLOSE, enc_close, dec_close), |
5905 | PROC(SETATTR, enc_setattr, dec_setattr), | 6627 | PROC(SETATTR, enc_setattr, dec_setattr), |
5906 | PROC(FSINFO, enc_fsinfo, dec_fsinfo), | 6628 | PROC(FSINFO, enc_fsinfo, dec_fsinfo), |
5907 | PROC(RENEW, enc_renew, dec_renew), | 6629 | PROC(RENEW, enc_renew, dec_renew), |
5908 | PROC(SETCLIENTID, enc_setclientid, dec_setclientid), | 6630 | PROC(SETCLIENTID, enc_setclientid, dec_setclientid), |
5909 | PROC(SETCLIENTID_CONFIRM, enc_setclientid_confirm, dec_setclientid_confirm), | 6631 | PROC(SETCLIENTID_CONFIRM, enc_setclientid_confirm, dec_setclientid_confirm), |
5910 | PROC(LOCK, enc_lock, dec_lock), | 6632 | PROC(LOCK, enc_lock, dec_lock), |
5911 | PROC(LOCKT, enc_lockt, dec_lockt), | 6633 | PROC(LOCKT, enc_lockt, dec_lockt), |
5912 | PROC(LOCKU, enc_locku, dec_locku), | 6634 | PROC(LOCKU, enc_locku, dec_locku), |
5913 | PROC(ACCESS, enc_access, dec_access), | 6635 | PROC(ACCESS, enc_access, dec_access), |
5914 | PROC(GETATTR, enc_getattr, dec_getattr), | 6636 | PROC(GETATTR, enc_getattr, dec_getattr), |
5915 | PROC(LOOKUP, enc_lookup, dec_lookup), | 6637 | PROC(LOOKUP, enc_lookup, dec_lookup), |
5916 | PROC(LOOKUP_ROOT, enc_lookup_root, dec_lookup_root), | 6638 | PROC(LOOKUP_ROOT, enc_lookup_root, dec_lookup_root), |
5917 | PROC(REMOVE, enc_remove, dec_remove), | 6639 | PROC(REMOVE, enc_remove, dec_remove), |
5918 | PROC(RENAME, enc_rename, dec_rename), | 6640 | PROC(RENAME, enc_rename, dec_rename), |
5919 | PROC(LINK, enc_link, dec_link), | 6641 | PROC(LINK, enc_link, dec_link), |
5920 | PROC(SYMLINK, enc_symlink, dec_symlink), | 6642 | PROC(SYMLINK, enc_symlink, dec_symlink), |
5921 | PROC(CREATE, enc_create, dec_create), | 6643 | PROC(CREATE, enc_create, dec_create), |
5922 | PROC(PATHCONF, enc_pathconf, dec_pathconf), | 6644 | PROC(PATHCONF, enc_pathconf, dec_pathconf), |
5923 | PROC(STATFS, enc_statfs, dec_statfs), | 6645 | PROC(STATFS, enc_statfs, dec_statfs), |
5924 | PROC(READLINK, enc_readlink, dec_readlink), | 6646 | PROC(READLINK, enc_readlink, dec_readlink), |
5925 | PROC(READDIR, enc_readdir, dec_readdir), | 6647 | PROC(READDIR, enc_readdir, dec_readdir), |
5926 | PROC(SERVER_CAPS, enc_server_caps, dec_server_caps), | 6648 | PROC(SERVER_CAPS, enc_server_caps, dec_server_caps), |
5927 | PROC(DELEGRETURN, enc_delegreturn, dec_delegreturn), | 6649 | PROC(DELEGRETURN, enc_delegreturn, dec_delegreturn), |
5928 | PROC(GETACL, enc_getacl, dec_getacl), | 6650 | PROC(GETACL, enc_getacl, dec_getacl), |
5929 | PROC(SETACL, enc_setacl, dec_setacl), | 6651 | PROC(SETACL, enc_setacl, dec_setacl), |
5930 | PROC(FS_LOCATIONS, enc_fs_locations, dec_fs_locations), | 6652 | PROC(FS_LOCATIONS, enc_fs_locations, dec_fs_locations), |
5931 | PROC(RELEASE_LOCKOWNER, enc_release_lockowner, dec_release_lockowner), | 6653 | PROC(RELEASE_LOCKOWNER, enc_release_lockowner, dec_release_lockowner), |
6654 | PROC(SECINFO, enc_secinfo, dec_secinfo), | ||
5932 | #if defined(CONFIG_NFS_V4_1) | 6655 | #if defined(CONFIG_NFS_V4_1) |
5933 | PROC(EXCHANGE_ID, enc_exchange_id, dec_exchange_id), | 6656 | PROC(EXCHANGE_ID, enc_exchange_id, dec_exchange_id), |
5934 | PROC(CREATE_SESSION, enc_create_session, dec_create_session), | 6657 | PROC(CREATE_SESSION, enc_create_session, dec_create_session), |
5935 | PROC(DESTROY_SESSION, enc_destroy_session, dec_destroy_session), | 6658 | PROC(DESTROY_SESSION, enc_destroy_session, dec_destroy_session), |
5936 | PROC(SEQUENCE, enc_sequence, dec_sequence), | 6659 | PROC(SEQUENCE, enc_sequence, dec_sequence), |
5937 | PROC(GET_LEASE_TIME, enc_get_lease_time, dec_get_lease_time), | 6660 | PROC(GET_LEASE_TIME, enc_get_lease_time, dec_get_lease_time), |
5938 | PROC(RECLAIM_COMPLETE, enc_reclaim_complete, dec_reclaim_complete), | 6661 | PROC(RECLAIM_COMPLETE, enc_reclaim_complete, dec_reclaim_complete), |
6662 | PROC(GETDEVICEINFO, enc_getdeviceinfo, dec_getdeviceinfo), | ||
6663 | PROC(LAYOUTGET, enc_layoutget, dec_layoutget), | ||
6664 | PROC(LAYOUTCOMMIT, enc_layoutcommit, dec_layoutcommit), | ||
6665 | PROC(LAYOUTRETURN, enc_layoutreturn, dec_layoutreturn), | ||
5939 | #endif /* CONFIG_NFS_V4_1 */ | 6666 | #endif /* CONFIG_NFS_V4_1 */ |
5940 | }; | 6667 | }; |
5941 | 6668 | ||