aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2012-03-04 18:13:57 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2012-03-06 10:32:48 -0500
commit4ade9821602ada8f56f3a3eb444dedbe42f1730e (patch)
tree1e045d135dcb70e8607cc46cb886af1fb94fc6f7 /fs/nfs
parent6fdfb0bc2a43f5deb612b7f79d9c7750708e0184 (diff)
NFSv4: Add a helper for encoding NFSv4 sequence ids
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs')
-rw-r--r--fs/nfs/nfs4xdr.c47
1 files changed, 28 insertions, 19 deletions
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index d6e8306d02a7..3b38ca5bafe8 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -901,6 +901,20 @@ static void encode_string(struct xdr_stream *xdr, unsigned int len, const char *
901 xdr_encode_opaque(p, str, len); 901 xdr_encode_opaque(p, str, len);
902} 902}
903 903
904static void encode_uint32(struct xdr_stream *xdr, u32 n)
905{
906 __be32 *p;
907
908 p = reserve_space(xdr, 4);
909 *p = cpu_to_be32(n);
910}
911
912static void encode_nfs4_seqid(struct xdr_stream *xdr,
913 const struct nfs_seqid *seqid)
914{
915 encode_uint32(xdr, seqid->sequence->counter);
916}
917
904static void encode_compound_hdr(struct xdr_stream *xdr, 918static void encode_compound_hdr(struct xdr_stream *xdr,
905 struct rpc_rqst *req, 919 struct rpc_rqst *req,
906 struct compound_hdr *hdr) 920 struct compound_hdr *hdr)
@@ -1074,9 +1088,9 @@ static void encode_close(struct xdr_stream *xdr, const struct nfs_closeargs *arg
1074{ 1088{
1075 __be32 *p; 1089 __be32 *p;
1076 1090
1077 p = reserve_space(xdr, 8); 1091 p = reserve_space(xdr, 4);
1078 *p++ = cpu_to_be32(OP_CLOSE); 1092 *p = cpu_to_be32(OP_CLOSE);
1079 *p = cpu_to_be32(arg->seqid->sequence->counter); 1093 encode_nfs4_seqid(xdr, arg->seqid);
1080 encode_nfs4_stateid(xdr, arg->stateid); 1094 encode_nfs4_stateid(xdr, arg->stateid);
1081 hdr->nops++; 1095 hdr->nops++;
1082 hdr->replen += decode_close_maxsz; 1096 hdr->replen += decode_close_maxsz;
@@ -1264,17 +1278,14 @@ static void encode_lock(struct xdr_stream *xdr, const struct nfs_lock_args *args
1264 p = xdr_encode_hyper(p, nfs4_lock_length(args->fl)); 1278 p = xdr_encode_hyper(p, nfs4_lock_length(args->fl));
1265 *p = cpu_to_be32(args->new_lock_owner); 1279 *p = cpu_to_be32(args->new_lock_owner);
1266 if (args->new_lock_owner){ 1280 if (args->new_lock_owner){
1267 p = reserve_space(xdr, 4); 1281 encode_nfs4_seqid(xdr, args->open_seqid);
1268 *p = cpu_to_be32(args->open_seqid->sequence->counter);
1269 encode_nfs4_stateid(xdr, args->open_stateid); 1282 encode_nfs4_stateid(xdr, args->open_stateid);
1270 p = reserve_space(xdr, 4); 1283 encode_nfs4_seqid(xdr, args->lock_seqid);
1271 *p = cpu_to_be32(args->lock_seqid->sequence->counter);
1272 encode_lockowner(xdr, &args->lock_owner); 1284 encode_lockowner(xdr, &args->lock_owner);
1273 } 1285 }
1274 else { 1286 else {
1275 encode_nfs4_stateid(xdr, args->lock_stateid); 1287 encode_nfs4_stateid(xdr, args->lock_stateid);
1276 p = reserve_space(xdr, 4); 1288 encode_nfs4_seqid(xdr, args->lock_seqid);
1277 *p = cpu_to_be32(args->lock_seqid->sequence->counter);
1278 } 1289 }
1279 hdr->nops++; 1290 hdr->nops++;
1280 hdr->replen += decode_lock_maxsz; 1291 hdr->replen += decode_lock_maxsz;
@@ -1298,10 +1309,10 @@ static void encode_locku(struct xdr_stream *xdr, const struct nfs_locku_args *ar
1298{ 1309{
1299 __be32 *p; 1310 __be32 *p;
1300 1311
1301 p = reserve_space(xdr, 12); 1312 p = reserve_space(xdr, 8);
1302 *p++ = cpu_to_be32(OP_LOCKU); 1313 *p++ = cpu_to_be32(OP_LOCKU);
1303 *p++ = cpu_to_be32(nfs4_lock_type(args->fl, 0)); 1314 *p = cpu_to_be32(nfs4_lock_type(args->fl, 0));
1304 *p = cpu_to_be32(args->seqid->sequence->counter); 1315 encode_nfs4_seqid(xdr, args->seqid);
1305 encode_nfs4_stateid(xdr, args->stateid); 1316 encode_nfs4_stateid(xdr, args->stateid);
1306 p = reserve_space(xdr, 16); 1317 p = reserve_space(xdr, 16);
1307 p = xdr_encode_hyper(p, args->fl->fl_start); 1318 p = xdr_encode_hyper(p, args->fl->fl_start);
@@ -1360,9 +1371,9 @@ static inline void encode_openhdr(struct xdr_stream *xdr, const struct nfs_opena
1360 * opcode 4, seqid 4, share_access 4, share_deny 4, clientid 8, ownerlen 4, 1371 * opcode 4, seqid 4, share_access 4, share_deny 4, clientid 8, ownerlen 4,
1361 * owner 4 = 32 1372 * owner 4 = 32
1362 */ 1373 */
1363 p = reserve_space(xdr, 8); 1374 p = reserve_space(xdr, 4);
1364 *p++ = cpu_to_be32(OP_OPEN); 1375 *p = cpu_to_be32(OP_OPEN);
1365 *p = cpu_to_be32(arg->seqid->sequence->counter); 1376 encode_nfs4_seqid(xdr, arg->seqid);
1366 encode_share_access(xdr, arg->fmode); 1377 encode_share_access(xdr, arg->fmode);
1367 p = reserve_space(xdr, 32); 1378 p = reserve_space(xdr, 32);
1368 p = xdr_encode_hyper(p, arg->clientid); 1379 p = xdr_encode_hyper(p, arg->clientid);
@@ -1496,8 +1507,7 @@ static void encode_open_confirm(struct xdr_stream *xdr, const struct nfs_open_co
1496 p = reserve_space(xdr, 4); 1507 p = reserve_space(xdr, 4);
1497 *p = cpu_to_be32(OP_OPEN_CONFIRM); 1508 *p = cpu_to_be32(OP_OPEN_CONFIRM);
1498 encode_nfs4_stateid(xdr, arg->stateid); 1509 encode_nfs4_stateid(xdr, arg->stateid);
1499 p = reserve_space(xdr, 4); 1510 encode_nfs4_seqid(xdr, arg->seqid);
1500 *p = cpu_to_be32(arg->seqid->sequence->counter);
1501 hdr->nops++; 1511 hdr->nops++;
1502 hdr->replen += decode_open_confirm_maxsz; 1512 hdr->replen += decode_open_confirm_maxsz;
1503} 1513}
@@ -1509,8 +1519,7 @@ static void encode_open_downgrade(struct xdr_stream *xdr, const struct nfs_close
1509 p = reserve_space(xdr, 4); 1519 p = reserve_space(xdr, 4);
1510 *p = cpu_to_be32(OP_OPEN_DOWNGRADE); 1520 *p = cpu_to_be32(OP_OPEN_DOWNGRADE);
1511 encode_nfs4_stateid(xdr, arg->stateid); 1521 encode_nfs4_stateid(xdr, arg->stateid);
1512 p = reserve_space(xdr, 4); 1522 encode_nfs4_seqid(xdr, arg->seqid);
1513 *p = cpu_to_be32(arg->seqid->sequence->counter);
1514 encode_share_access(xdr, arg->fmode); 1523 encode_share_access(xdr, arg->fmode);
1515 hdr->nops++; 1524 hdr->nops++;
1516 hdr->replen += decode_open_downgrade_maxsz; 1525 hdr->replen += decode_open_downgrade_maxsz;