NFS: Cache rpc_ops in struct nfs_pageio_descriptor
authorTrond Myklebust <Trond.Myklebust@netapp.com>
Tue, 12 Jul 2011 17:42:02 +0000 (13:42 -0400)
committerTrond Myklebust <Trond.Myklebust@netapp.com>
Fri, 15 Jul 2011 13:12:20 +0000 (09:12 -0400)
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
fs/nfs/read.c
fs/nfs/write.c
include/linux/nfs_page.h

index 0215bac35fc6bef5693f51ba925414d54e0606dd..c14362fbe65f94e7b0f6c80b25c6801d01205115 100644 (file)
@@ -327,6 +327,7 @@ static int nfs_pagein_multi(struct nfs_pageio_descriptor *desc, struct list_head
        } while(nbytes != 0);
        atomic_set(&req->wb_complete, requests);
        ClearPageError(page);
+       desc->pg_rpc_callops = &nfs_read_partial_ops;
        return ret;
 out_bad:
        while (!list_empty(res)) {
@@ -367,6 +368,7 @@ static int nfs_pagein_one(struct nfs_pageio_descriptor *desc, struct list_head *
 
        nfs_read_rpcsetup(req, data, desc->pg_count, 0);
        list_add(&data->list, res);
+       desc->pg_rpc_callops = &nfs_read_full_ops;
 out:
        return ret;
 }
@@ -376,19 +378,14 @@ int nfs_generic_pg_readpages(struct nfs_pageio_descriptor *desc)
        LIST_HEAD(head);
        int ret;
 
-       if (desc->pg_bsize < PAGE_CACHE_SIZE) {
+       if (desc->pg_bsize < PAGE_CACHE_SIZE)
                ret = nfs_pagein_multi(desc, &head);
-               if (ret == 0)
-                       ret = nfs_do_multiple_reads(&head,
-                                       &nfs_read_partial_ops,
-                                       desc->pg_lseg);
-       } else {
+       else
                ret = nfs_pagein_one(desc, &head);
-               if (ret == 0)
-                       ret = nfs_do_multiple_reads(&head,
-                                       &nfs_read_full_ops,
-                                       desc->pg_lseg);
-       }
+
+       if (ret == 0)
+               ret = nfs_do_multiple_reads(&head, desc->pg_rpc_callops,
+                               desc->pg_lseg);
        put_lseg(desc->pg_lseg);
        desc->pg_lseg = NULL;
        return ret;
index bd4b34e5870b6bf11fb5176756be6f3f6bbd3804..71fbba72ace3588fea4db68837afa679f203cc44 100644 (file)
@@ -975,6 +975,7 @@ static int nfs_flush_multi(struct nfs_pageio_descriptor *desc, struct list_head
                offset += len;
        } while (nbytes != 0);
        atomic_set(&req->wb_complete, requests);
+       desc->pg_rpc_callops = &nfs_write_partial_ops;
        return ret;
 
 out_bad:
@@ -1031,6 +1032,7 @@ static int nfs_flush_one(struct nfs_pageio_descriptor *desc, struct list_head *r
        /* Set up the argument struct */
        nfs_write_rpcsetup(req, data, desc->pg_count, 0, desc->pg_ioflags);
        list_add(&data->list, res);
+       desc->pg_rpc_callops = &nfs_write_full_ops;
 out:
        return ret;
 }
@@ -1040,21 +1042,13 @@ int nfs_generic_pg_writepages(struct nfs_pageio_descriptor *desc)
        LIST_HEAD(head);
        int ret;
 
-       if (desc->pg_bsize < PAGE_CACHE_SIZE) {
+       if (desc->pg_bsize < PAGE_CACHE_SIZE)
                ret = nfs_flush_multi(desc, &head);
-               if (ret == 0)
-                       ret = nfs_do_multiple_writes(&head,
-                                       &nfs_write_partial_ops,
-                                       desc->pg_lseg,
-                                       desc->pg_ioflags);
-       } else {
+       else
                ret = nfs_flush_one(desc, &head);
-               if (ret == 0)
-                       ret = nfs_do_multiple_writes(&head,
-                                       &nfs_write_full_ops,
-                                       desc->pg_lseg,
-                                       desc->pg_ioflags);
-       }
+       if (ret == 0)
+               ret = nfs_do_multiple_writes(&head, desc->pg_rpc_callops,
+                               desc->pg_lseg, desc->pg_ioflags);
        put_lseg(desc->pg_lseg);
        desc->pg_lseg = NULL;
        return ret;
index 9ac2dd158d0b1823c4762898208adfdbb8fbe88f..db3194f63479863b80d8e25fcf9d61b1d2672e0f 100644 (file)
@@ -74,6 +74,7 @@ struct nfs_pageio_descriptor {
        const struct nfs_pageio_ops *pg_ops;
        int                     pg_ioflags;
        int                     pg_error;
+       const struct rpc_call_ops *pg_rpc_callops;
        struct pnfs_layout_segment *pg_lseg;
 };