]> git.karo-electronics.de Git - linux-beck.git/commitdiff
NFS: Fix O_DIRECT verifier problems
authorTrond Myklebust <trond.myklebust@primarydata.com>
Thu, 2 Jun 2016 01:32:24 +0000 (21:32 -0400)
committerTrond Myklebust <trond.myklebust@primarydata.com>
Tue, 5 Jul 2016 23:11:01 +0000 (19:11 -0400)
We should not be interested in looking at the value of the stable field,
since that could take any value.

Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
fs/nfs/direct.c
fs/nfs/internal.h
fs/nfs/write.c

index 979b3c4dee6aedbb354faefd1aca8cf1b3be8789..d6d43b5eafb3274de9df67b7eec1847363fbf35a 100644 (file)
@@ -196,6 +196,12 @@ static void nfs_direct_set_hdr_verf(struct nfs_direct_req *dreq,
        WARN_ON_ONCE(verfp->committed < 0);
 }
 
+static int nfs_direct_cmp_verf(const struct nfs_writeverf *v1,
+               const struct nfs_writeverf *v2)
+{
+       return nfs_write_verifier_cmp(&v1->verifier, &v2->verifier);
+}
+
 /*
  * nfs_direct_cmp_hdr_verf - compare verifier for pgio header
  * @dreq - direct request possibly spanning multiple servers
@@ -215,7 +221,7 @@ static int nfs_direct_set_or_cmp_hdr_verf(struct nfs_direct_req *dreq,
                nfs_direct_set_hdr_verf(dreq, hdr);
                return 0;
        }
-       return memcmp(verfp, &hdr->verf, sizeof(struct nfs_writeverf));
+       return nfs_direct_cmp_verf(verfp, &hdr->verf);
 }
 
 /*
@@ -238,7 +244,7 @@ static int nfs_direct_cmp_commit_data_verf(struct nfs_direct_req *dreq,
        if (verfp->committed < 0)
                return 1;
 
-       return memcmp(verfp, &data->verf, sizeof(struct nfs_writeverf));
+       return nfs_direct_cmp_verf(verfp, &data->verf);
 }
 
 /**
index 5154fa65a2f2a20efad5eeb9667bd10974f8aaed..150a8eb0f323a8887a31c50273d0b37e8e675799 100644 (file)
@@ -506,6 +506,13 @@ extern int nfs_migrate_page(struct address_space *,
 #define nfs_migrate_page NULL
 #endif
 
+static inline int
+nfs_write_verifier_cmp(const struct nfs_write_verifier *v1,
+               const struct nfs_write_verifier *v2)
+{
+       return memcmp(v1->data, v2->data, sizeof(v1->data));
+}
+
 /* unlink.c */
 extern struct rpc_task *
 nfs_async_rename(struct inode *old_dir, struct inode *new_dir,
index b13d48881d3ae3c5d09b4fc88bda3b49740bb3ab..3087fb6f1983015e044e602f1ea6bd35d837f50a 100644 (file)
@@ -1789,7 +1789,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, &data->verf.verifier, sizeof(req->wb_verf))) {
+               if (!nfs_write_verifier_cmp(&req->wb_verf, &data->verf.verifier)) {
                        /* We have a match */
                        nfs_inode_remove_request(req);
                        dprintk(" OK\n");