aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2012-06-08 11:56:09 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2012-06-28 17:20:50 -0400
commit2f2c63bc221c5fcded24de2704575d0abf96b910 (patch)
treedacf9f2bdbd101de6525a53571f0f1e48a75902e
parent98d9452448122486f81030c6c70f29471f65e1ce (diff)
NFS: Cleanup - only store the write verifier in struct nfs_page
The 'committed' field is not needed once we have put the struct nfs_page on the right list. Also correct the type of the verifier: it is not an array of __be32, but simply an 8 byte long opaque array. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
-rw-r--r--fs/nfs/nfs3xdr.c12
-rw-r--r--fs/nfs/nfs4filelayout.c6
-rw-r--r--fs/nfs/nfs4xdr.c12
-rw-r--r--fs/nfs/write.c4
-rw-r--r--include/linux/nfs_page.h2
-rw-r--r--include/linux/nfs_xdr.h6
6 files changed, 26 insertions, 16 deletions
diff --git a/fs/nfs/nfs3xdr.c b/fs/nfs/nfs3xdr.c
index 5013bdd85ab..6cbe89400df 100644
--- a/fs/nfs/nfs3xdr.c
+++ b/fs/nfs/nfs3xdr.c
@@ -325,14 +325,14 @@ static void encode_createverf3(struct xdr_stream *xdr, const __be32 *verifier)
325 memcpy(p, verifier, NFS3_CREATEVERFSIZE); 325 memcpy(p, verifier, NFS3_CREATEVERFSIZE);
326} 326}
327 327
328static int decode_writeverf3(struct xdr_stream *xdr, __be32 *verifier) 328static int decode_writeverf3(struct xdr_stream *xdr, struct nfs_write_verifier *verifier)
329{ 329{
330 __be32 *p; 330 __be32 *p;
331 331
332 p = xdr_inline_decode(xdr, NFS3_WRITEVERFSIZE); 332 p = xdr_inline_decode(xdr, NFS3_WRITEVERFSIZE);
333 if (unlikely(p == NULL)) 333 if (unlikely(p == NULL))
334 goto out_overflow; 334 goto out_overflow;
335 memcpy(verifier, p, NFS3_WRITEVERFSIZE); 335 memcpy(verifier->data, p, NFS3_WRITEVERFSIZE);
336 return 0; 336 return 0;
337out_overflow: 337out_overflow:
338 print_overflow_msg(__func__, xdr); 338 print_overflow_msg(__func__, xdr);
@@ -1668,20 +1668,22 @@ static int decode_write3resok(struct xdr_stream *xdr,
1668{ 1668{
1669 __be32 *p; 1669 __be32 *p;
1670 1670
1671 p = xdr_inline_decode(xdr, 4 + 4 + NFS3_WRITEVERFSIZE); 1671 p = xdr_inline_decode(xdr, 4 + 4);
1672 if (unlikely(p == NULL)) 1672 if (unlikely(p == NULL))
1673 goto out_overflow; 1673 goto out_overflow;
1674 result->count = be32_to_cpup(p++); 1674 result->count = be32_to_cpup(p++);
1675 result->verf->committed = be32_to_cpup(p++); 1675 result->verf->committed = be32_to_cpup(p++);
1676 if (unlikely(result->verf->committed > NFS_FILE_SYNC)) 1676 if (unlikely(result->verf->committed > NFS_FILE_SYNC))
1677 goto out_badvalue; 1677 goto out_badvalue;
1678 memcpy(result->verf->verifier, p, NFS3_WRITEVERFSIZE); 1678 if (decode_writeverf3(xdr, &result->verf->verifier))
1679 goto out_eio;
1679 return result->count; 1680 return result->count;
1680out_badvalue: 1681out_badvalue:
1681 dprintk("NFS: bad stable_how value: %u\n", result->verf->committed); 1682 dprintk("NFS: bad stable_how value: %u\n", result->verf->committed);
1682 return -EIO; 1683 return -EIO;
1683out_overflow: 1684out_overflow:
1684 print_overflow_msg(__func__, xdr); 1685 print_overflow_msg(__func__, xdr);
1686out_eio:
1685 return -EIO; 1687 return -EIO;
1686} 1688}
1687 1689
@@ -2314,7 +2316,7 @@ static int nfs3_xdr_dec_commit3res(struct rpc_rqst *req,
2314 goto out; 2316 goto out;
2315 if (status != NFS3_OK) 2317 if (status != NFS3_OK)
2316 goto out_status; 2318 goto out_status;
2317 error = decode_writeverf3(xdr, result->verf->verifier); 2319 error = decode_writeverf3(xdr, &result->verf->verifier);
2318out: 2320out:
2319 return error; 2321 return error;
2320out_status: 2322out_status:
diff --git a/fs/nfs/nfs4filelayout.c b/fs/nfs/nfs4filelayout.c
index e1340293872..85b70639921 100644
--- a/fs/nfs/nfs4filelayout.c
+++ b/fs/nfs/nfs4filelayout.c
@@ -351,9 +351,9 @@ static void prepare_to_resend_writes(struct nfs_commit_data *data)
351 struct nfs_page *first = nfs_list_entry(data->pages.next); 351 struct nfs_page *first = nfs_list_entry(data->pages.next);
352 352
353 data->task.tk_status = 0; 353 data->task.tk_status = 0;
354 memcpy(data->verf.verifier, first->wb_verf.verifier, 354 memcpy(&data->verf.verifier, &first->wb_verf,
355 sizeof(first->wb_verf.verifier)); 355 sizeof(data->verf.verifier));
356 data->verf.verifier[0]++; /* ensure verifier mismatch */ 356 data->verf.verifier.data[0]++; /* ensure verifier mismatch */
357} 357}
358 358
359static int filelayout_commit_done_cb(struct rpc_task *task, 359static int filelayout_commit_done_cb(struct rpc_task *task,
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index 1e2c47b3889..610ebccbde5 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -4158,13 +4158,18 @@ static int decode_verifier(struct xdr_stream *xdr, void *verifier)
4158 return decode_opaque_fixed(xdr, verifier, NFS4_VERIFIER_SIZE); 4158 return decode_opaque_fixed(xdr, verifier, NFS4_VERIFIER_SIZE);
4159} 4159}
4160 4160
4161static int decode_write_verifier(struct xdr_stream *xdr, struct nfs_write_verifier *verifier)
4162{
4163 return decode_opaque_fixed(xdr, verifier->data, NFS4_VERIFIER_SIZE);
4164}
4165
4161static int decode_commit(struct xdr_stream *xdr, struct nfs_commitres *res) 4166static int decode_commit(struct xdr_stream *xdr, struct nfs_commitres *res)
4162{ 4167{
4163 int status; 4168 int status;
4164 4169
4165 status = decode_op_hdr(xdr, OP_COMMIT); 4170 status = decode_op_hdr(xdr, OP_COMMIT);
4166 if (!status) 4171 if (!status)
4167 status = decode_verifier(xdr, res->verf->verifier); 4172 status = decode_write_verifier(xdr, &res->verf->verifier);
4168 return status; 4173 return status;
4169} 4174}
4170 4175
@@ -5192,13 +5197,12 @@ static int decode_write(struct xdr_stream *xdr, struct nfs_writeres *res)
5192 if (status) 5197 if (status)
5193 return status; 5198 return status;
5194 5199
5195 p = xdr_inline_decode(xdr, 16); 5200 p = xdr_inline_decode(xdr, 8);
5196 if (unlikely(!p)) 5201 if (unlikely(!p))
5197 goto out_overflow; 5202 goto out_overflow;
5198 res->count = be32_to_cpup(p++); 5203 res->count = be32_to_cpup(p++);
5199 res->verf->committed = be32_to_cpup(p++); 5204 res->verf->committed = be32_to_cpup(p++);
5200 memcpy(res->verf->verifier, p, NFS4_VERIFIER_SIZE); 5205 return decode_write_verifier(xdr, &res->verf->verifier);
5201 return 0;
5202out_overflow: 5206out_overflow:
5203 print_overflow_msg(__func__, xdr); 5207 print_overflow_msg(__func__, xdr);
5204 return -EIO; 5208 return -EIO;
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index 4d6861c0dc1..ee929e5e1f7 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -620,7 +620,7 @@ static void nfs_write_completion(struct nfs_pgio_header *hdr)
620 goto next; 620 goto next;
621 } 621 }
622 if (test_bit(NFS_IOHDR_NEED_COMMIT, &hdr->flags)) { 622 if (test_bit(NFS_IOHDR_NEED_COMMIT, &hdr->flags)) {
623 memcpy(&req->wb_verf, hdr->verf, sizeof(req->wb_verf)); 623 memcpy(&req->wb_verf, &hdr->verf->verifier, sizeof(req->wb_verf));
624 nfs_mark_request_commit(req, hdr->lseg, &cinfo); 624 nfs_mark_request_commit(req, hdr->lseg, &cinfo);
625 goto next; 625 goto next;
626 } 626 }
@@ -1547,7 +1547,7 @@ static void nfs_commit_release_pages(struct nfs_commit_data *data)
1547 1547
1548 /* Okay, COMMIT succeeded, apparently. Check the verifier 1548 /* Okay, COMMIT succeeded, apparently. Check the verifier
1549 * returned by the server against all stored verfs. */ 1549 * returned by the server against all stored verfs. */
1550 if (!memcmp(req->wb_verf.verifier, data->verf.verifier, sizeof(data->verf.verifier))) { 1550 if (!memcmp(&req->wb_verf, &data->verf.verifier, sizeof(req->wb_verf))) {
1551 /* We have a match */ 1551 /* We have a match */
1552 nfs_inode_remove_request(req); 1552 nfs_inode_remove_request(req);
1553 dprintk(" OK\n"); 1553 dprintk(" OK\n");
diff --git a/include/linux/nfs_page.h b/include/linux/nfs_page.h
index 88d166b555e..880805774f9 100644
--- a/include/linux/nfs_page.h
+++ b/include/linux/nfs_page.h
@@ -42,7 +42,7 @@ struct nfs_page {
42 wb_bytes; /* Length of request */ 42 wb_bytes; /* Length of request */
43 struct kref wb_kref; /* reference count */ 43 struct kref wb_kref; /* reference count */
44 unsigned long wb_flags; 44 unsigned long wb_flags;
45 struct nfs_writeverf wb_verf; /* Commit cookie */ 45 struct nfs_write_verifier wb_verf; /* Commit cookie */
46}; 46};
47 47
48struct nfs_pageio_descriptor; 48struct nfs_pageio_descriptor;
diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h
index 8aadd90b808..5c0014d1c96 100644
--- a/include/linux/nfs_xdr.h
+++ b/include/linux/nfs_xdr.h
@@ -514,9 +514,13 @@ struct nfs_writeargs {
514 struct nfs4_sequence_args seq_args; 514 struct nfs4_sequence_args seq_args;
515}; 515};
516 516
517struct nfs_write_verifier {
518 char data[8];
519};
520
517struct nfs_writeverf { 521struct nfs_writeverf {
522 struct nfs_write_verifier verifier;
518 enum nfs3_stable_how committed; 523 enum nfs3_stable_how committed;
519 __be32 verifier[2];
520}; 524};
521 525
522struct nfs_writeres { 526struct nfs_writeres {