]> git.karo-electronics.de Git - linux-beck.git/commitdiff
NFS: Cleanup - only store the write verifier in struct nfs_page
authorTrond Myklebust <Trond.Myklebust@netapp.com>
Fri, 8 Jun 2012 15:56:09 +0000 (11:56 -0400)
committerTrond Myklebust <Trond.Myklebust@netapp.com>
Thu, 28 Jun 2012 21:20:50 +0000 (17:20 -0400)
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>
fs/nfs/nfs3xdr.c
fs/nfs/nfs4filelayout.c
fs/nfs/nfs4xdr.c
fs/nfs/write.c
include/linux/nfs_page.h
include/linux/nfs_xdr.h

index 5013bdd85ab935eab620f3822de32bc473ccaa06..6cbe89400dfcc134b9af58d6ad16ecf42bab911a 100644 (file)
@@ -325,14 +325,14 @@ static void encode_createverf3(struct xdr_stream *xdr, const __be32 *verifier)
        memcpy(p, verifier, NFS3_CREATEVERFSIZE);
 }
 
-static int decode_writeverf3(struct xdr_stream *xdr, __be32 *verifier)
+static int decode_writeverf3(struct xdr_stream *xdr, struct nfs_write_verifier *verifier)
 {
        __be32 *p;
 
        p = xdr_inline_decode(xdr, NFS3_WRITEVERFSIZE);
        if (unlikely(p == NULL))
                goto out_overflow;
-       memcpy(verifier, p, NFS3_WRITEVERFSIZE);
+       memcpy(verifier->data, p, NFS3_WRITEVERFSIZE);
        return 0;
 out_overflow:
        print_overflow_msg(__func__, xdr);
@@ -1668,20 +1668,22 @@ static int decode_write3resok(struct xdr_stream *xdr,
 {
        __be32 *p;
 
-       p = xdr_inline_decode(xdr, 4 + 4 + NFS3_WRITEVERFSIZE);
+       p = xdr_inline_decode(xdr, 4 + 4);
        if (unlikely(p == NULL))
                goto out_overflow;
        result->count = be32_to_cpup(p++);
        result->verf->committed = be32_to_cpup(p++);
        if (unlikely(result->verf->committed > NFS_FILE_SYNC))
                goto out_badvalue;
-       memcpy(result->verf->verifier, p, NFS3_WRITEVERFSIZE);
+       if (decode_writeverf3(xdr, &result->verf->verifier))
+               goto out_eio;
        return result->count;
 out_badvalue:
        dprintk("NFS: bad stable_how value: %u\n", result->verf->committed);
        return -EIO;
 out_overflow:
        print_overflow_msg(__func__, xdr);
+out_eio:
        return -EIO;
 }
 
@@ -2314,7 +2316,7 @@ static int nfs3_xdr_dec_commit3res(struct rpc_rqst *req,
                goto out;
        if (status != NFS3_OK)
                goto out_status;
-       error = decode_writeverf3(xdr, result->verf->verifier);
+       error = decode_writeverf3(xdr, &result->verf->verifier);
 out:
        return error;
 out_status:
index e1340293872c7a70e747d051888e5ab603db905e..85b70639921bd2d4ccb39b003bdac5a44166d487 100644 (file)
@@ -351,9 +351,9 @@ static void prepare_to_resend_writes(struct nfs_commit_data *data)
        struct nfs_page *first = nfs_list_entry(data->pages.next);
 
        data->task.tk_status = 0;
-       memcpy(data->verf.verifier, first->wb_verf.verifier,
-              sizeof(first->wb_verf.verifier));
-       data->verf.verifier[0]++; /* ensure verifier mismatch */
+       memcpy(&data->verf.verifier, &first->wb_verf,
+              sizeof(data->verf.verifier));
+       data->verf.verifier.data[0]++; /* ensure verifier mismatch */
 }
 
 static int filelayout_commit_done_cb(struct rpc_task *task,
index 1e2c47b3889da8072d27750699aee5b51d407fa0..610ebccbde5d6769389a2c239cc212035925f298 100644 (file)
@@ -4158,13 +4158,18 @@ static int decode_verifier(struct xdr_stream *xdr, void *verifier)
        return decode_opaque_fixed(xdr, verifier, NFS4_VERIFIER_SIZE);
 }
 
+static int decode_write_verifier(struct xdr_stream *xdr, struct nfs_write_verifier *verifier)
+{
+       return decode_opaque_fixed(xdr, verifier->data, NFS4_VERIFIER_SIZE);
+}
+
 static int decode_commit(struct xdr_stream *xdr, struct nfs_commitres *res)
 {
        int status;
 
        status = decode_op_hdr(xdr, OP_COMMIT);
        if (!status)
-               status = decode_verifier(xdr, res->verf->verifier);
+               status = decode_write_verifier(xdr, &res->verf->verifier);
        return status;
 }
 
@@ -5192,13 +5197,12 @@ static int decode_write(struct xdr_stream *xdr, struct nfs_writeres *res)
        if (status)
                return status;
 
-       p = xdr_inline_decode(xdr, 16);
+       p = xdr_inline_decode(xdr, 8);
        if (unlikely(!p))
                goto out_overflow;
        res->count = be32_to_cpup(p++);
        res->verf->committed = be32_to_cpup(p++);
-       memcpy(res->verf->verifier, p, NFS4_VERIFIER_SIZE);
-       return 0;
+       return decode_write_verifier(xdr, &res->verf->verifier);
 out_overflow:
        print_overflow_msg(__func__, xdr);
        return -EIO;
index 4d6861c0dc142a5ec41e5da405012b661aeb3bc4..ee929e5e1f7ba98f3bb63e216b0541aa3917fcbd 100644 (file)
@@ -620,7 +620,7 @@ static void nfs_write_completion(struct nfs_pgio_header *hdr)
                        goto next;
                }
                if (test_bit(NFS_IOHDR_NEED_COMMIT, &hdr->flags)) {
-                       memcpy(&req->wb_verf, hdr->verf, sizeof(req->wb_verf));
+                       memcpy(&req->wb_verf, &hdr->verf->verifier, sizeof(req->wb_verf));
                        nfs_mark_request_commit(req, hdr->lseg, &cinfo);
                        goto next;
                }
@@ -1547,7 +1547,7 @@ static void nfs_commit_release_pages(struct nfs_commit_data *data)
 
                /* Okay, COMMIT succeeded, apparently. Check the verifier
                 * returned by the server against all stored verfs. */
-               if (!memcmp(req->wb_verf.verifier, data->verf.verifier, sizeof(data->verf.verifier))) {
+               if (!memcmp(&req->wb_verf, &data->verf.verifier, sizeof(req->wb_verf))) {
                        /* We have a match */
                        nfs_inode_remove_request(req);
                        dprintk(" OK\n");
index 88d166b555e8539fa8ec5cb896c56ecea7417bdc..880805774f9f105425a7eade9721b9965f7d43c9 100644 (file)
@@ -42,7 +42,7 @@ struct nfs_page {
                                wb_bytes;       /* Length of request */
        struct kref             wb_kref;        /* reference count */
        unsigned long           wb_flags;
-       struct nfs_writeverf    wb_verf;        /* Commit cookie */
+       struct nfs_write_verifier       wb_verf;        /* Commit cookie */
 };
 
 struct nfs_pageio_descriptor;
index 8aadd90b808a67b466ceb66cbc0de0b57883e96b..5c0014d1c9692fab5f99d3ba6c6e2baf782fb261 100644 (file)
@@ -514,9 +514,13 @@ struct nfs_writeargs {
        struct nfs4_sequence_args       seq_args;
 };
 
+struct nfs_write_verifier {
+       char                    data[8];
+};
+
 struct nfs_writeverf {
+       struct nfs_write_verifier verifier;
        enum nfs3_stable_how    committed;
-       __be32                  verifier[2];
 };
 
 struct nfs_writeres {