summaryrefslogtreecommitdiffstats
path: root/fs/nfs/nfs4xdr.c
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2013-03-17 15:52:00 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2013-03-25 12:04:10 -0400
commit9b20614988199fb03580b335a28250922e902098 (patch)
treeeb8020ff76d93017af31f10dbdd4b5d929dd4369 /fs/nfs/nfs4xdr.c
parent8c86899f62738b8a22ca3a5f060e269b92e5545a (diff)
NFSv4: The stateid must remain the same for replayed RPC calls
If we replay a READ or WRITE call, we should not be changing the stateid. Currently, we may end up doing so, because the stateid is only selected at xdr encode time. This patch ensures that we select the stateid after we get an NFSv4.1 session slot, and that we keep that same stateid across retries. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/nfs4xdr.c')
-rw-r--r--fs/nfs/nfs4xdr.c28
1 files changed, 2 insertions, 26 deletions
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index e3edda554ac7..9d328777b4c1 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -1506,35 +1506,12 @@ static void encode_putrootfh(struct xdr_stream *xdr, struct compound_hdr *hdr)
1506 encode_op_hdr(xdr, OP_PUTROOTFH, decode_putrootfh_maxsz, hdr); 1506 encode_op_hdr(xdr, OP_PUTROOTFH, decode_putrootfh_maxsz, hdr);
1507} 1507}
1508 1508
1509static void encode_open_stateid(struct xdr_stream *xdr,
1510 const struct nfs_open_context *ctx,
1511 const struct nfs_lock_context *l_ctx,
1512 fmode_t fmode,
1513 int zero_seqid)
1514{
1515 nfs4_stateid stateid;
1516
1517 if (ctx->state != NULL) {
1518 const struct nfs_lockowner *lockowner = NULL;
1519
1520 if (l_ctx != NULL)
1521 lockowner = &l_ctx->lockowner;
1522 nfs4_select_rw_stateid(&stateid, ctx->state,
1523 fmode, lockowner);
1524 if (zero_seqid)
1525 stateid.seqid = 0;
1526 encode_nfs4_stateid(xdr, &stateid);
1527 } else
1528 encode_nfs4_stateid(xdr, &zero_stateid);
1529}
1530
1531static void encode_read(struct xdr_stream *xdr, const struct nfs_readargs *args, struct compound_hdr *hdr) 1509static void encode_read(struct xdr_stream *xdr, const struct nfs_readargs *args, struct compound_hdr *hdr)
1532{ 1510{
1533 __be32 *p; 1511 __be32 *p;
1534 1512
1535 encode_op_hdr(xdr, OP_READ, decode_read_maxsz, hdr); 1513 encode_op_hdr(xdr, OP_READ, decode_read_maxsz, hdr);
1536 encode_open_stateid(xdr, args->context, args->lock_context, 1514 encode_nfs4_stateid(xdr, &args->stateid);
1537 FMODE_READ, hdr->minorversion);
1538 1515
1539 p = reserve_space(xdr, 12); 1516 p = reserve_space(xdr, 12);
1540 p = xdr_encode_hyper(p, args->offset); 1517 p = xdr_encode_hyper(p, args->offset);
@@ -1670,8 +1647,7 @@ static void encode_write(struct xdr_stream *xdr, const struct nfs_writeargs *arg
1670 __be32 *p; 1647 __be32 *p;
1671 1648
1672 encode_op_hdr(xdr, OP_WRITE, decode_write_maxsz, hdr); 1649 encode_op_hdr(xdr, OP_WRITE, decode_write_maxsz, hdr);
1673 encode_open_stateid(xdr, args->context, args->lock_context, 1650 encode_nfs4_stateid(xdr, &args->stateid);
1674 FMODE_WRITE, hdr->minorversion);
1675 1651
1676 p = reserve_space(xdr, 16); 1652 p = reserve_space(xdr, 16);
1677 p = xdr_encode_hyper(p, args->offset); 1653 p = xdr_encode_hyper(p, args->offset);