NFS: Remove private spinlock in struct nfs_pgio_header
authorTrond Myklebust <trond.myklebust@hammerspace.com>
Tue, 25 Sep 2018 16:34:43 +0000 (12:34 -0400)
committerTrond Myklebust <trond.myklebust@hammerspace.com>
Sun, 30 Sep 2018 19:35:17 +0000 (15:35 -0400)
Now that each struct nfs_pgio_header corresponds to one RPC call, we
only have one writer to the struct nfs_pgio_header.

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
fs/nfs/pagelist.c
fs/nfs/read.c
include/linux/nfs_xdr.h

index bb5476a..f97c455 100644 (file)
@@ -63,14 +63,14 @@ EXPORT_SYMBOL_GPL(nfs_pgheader_init);
 
 void nfs_set_pgio_error(struct nfs_pgio_header *hdr, int error, loff_t pos)
 {
-       spin_lock(&hdr->lock);
-       if (!test_and_set_bit(NFS_IOHDR_ERROR, &hdr->flags)
-           || pos < hdr->io_start + hdr->good_bytes) {
+       unsigned int new = pos - hdr->io_start;
+
+       if (hdr->good_bytes > new) {
+               hdr->good_bytes = new;
                clear_bit(NFS_IOHDR_EOF, &hdr->flags);
-               hdr->good_bytes = pos - hdr->io_start;
-               hdr->error = error;
+               if (!test_and_set_bit(NFS_IOHDR_ERROR, &hdr->flags))
+                       hdr->error = error;
        }
-       spin_unlock(&hdr->lock);
 }
 
 static inline struct nfs_page *
@@ -494,7 +494,6 @@ struct nfs_pgio_header *nfs_pgio_header_alloc(const struct nfs_rw_ops *ops)
 
        if (hdr) {
                INIT_LIST_HEAD(&hdr->pages);
-               spin_lock_init(&hdr->lock);
                hdr->rw_ops = ops;
        }
        return hdr;
index 48d7277..f9f1978 100644 (file)
@@ -276,16 +276,14 @@ static void nfs_readpage_result(struct rpc_task *task,
                                struct nfs_pgio_header *hdr)
 {
        if (hdr->res.eof) {
-               loff_t bound;
+               loff_t pos = hdr->args.offset + hdr->res.count;
+               unsigned int new = pos - hdr->io_start;
 
-               bound = hdr->args.offset + hdr->res.count;
-               spin_lock(&hdr->lock);
-               if (bound < hdr->io_start + hdr->good_bytes) {
+               if (hdr->good_bytes > new) {
+                       hdr->good_bytes = new;
                        set_bit(NFS_IOHDR_EOF, &hdr->flags);
                        clear_bit(NFS_IOHDR_ERROR, &hdr->flags);
-                       hdr->good_bytes = bound - hdr->io_start;
                }
-               spin_unlock(&hdr->lock);
        } else if (hdr->res.count < hdr->args.count)
                nfs_readpage_retry(task, hdr);
 }
index 343e441..0e01625 100644 (file)
@@ -1482,11 +1482,10 @@ struct nfs_pgio_header {
        const struct nfs_rw_ops *rw_ops;
        struct nfs_io_completion *io_completion;
        struct nfs_direct_req   *dreq;
-       spinlock_t              lock;
-       /* fields protected by lock */
+
        int                     pnfs_error;
        int                     error;          /* merge with pnfs_error */
-       unsigned long           good_bytes;     /* boundary of good data */
+       unsigned int            good_bytes;     /* boundary of good data */
        unsigned long           flags;
 
        /*