Merge tag 'split-asm_system_h-for-linus-20120328' of git://git.kernel.org/pub/scm...
[linux-2.6.git] / fs / nfs / read.c
index 75088f5..9a0e8ef 100644 (file)
@@ -20,7 +20,6 @@
 #include <linux/nfs_page.h>
 #include <linux/module.h>
 
-#include <asm/system.h>
 #include "pnfs.h"
 
 #include "nfs4_fs.h"
@@ -35,16 +34,13 @@ static const struct rpc_call_ops nfs_read_partial_ops;
 static const struct rpc_call_ops nfs_read_full_ops;
 
 static struct kmem_cache *nfs_rdata_cachep;
-static mempool_t *nfs_rdata_mempool;
-
-#define MIN_POOL_READ  (32)
 
 struct nfs_read_data *nfs_readdata_alloc(unsigned int pagecount)
 {
-       struct nfs_read_data *p = mempool_alloc(nfs_rdata_mempool, GFP_KERNEL);
+       struct nfs_read_data *p;
 
+       p = kmem_cache_zalloc(nfs_rdata_cachep, GFP_KERNEL);
        if (p) {
-               memset(p, 0, sizeof(*p));
                INIT_LIST_HEAD(&p->pages);
                p->npages = pagecount;
                if (pagecount <= ARRAY_SIZE(p->page_array))
@@ -52,7 +48,7 @@ struct nfs_read_data *nfs_readdata_alloc(unsigned int pagecount)
                else {
                        p->pagevec = kcalloc(pagecount, sizeof(struct page *), GFP_KERNEL);
                        if (!p->pagevec) {
-                               mempool_free(p, nfs_rdata_mempool);
+                               kmem_cache_free(nfs_rdata_cachep, p);
                                p = NULL;
                        }
                }
@@ -64,12 +60,11 @@ void nfs_readdata_free(struct nfs_read_data *p)
 {
        if (p && (p->pagevec != &p->page_array[0]))
                kfree(p->pagevec);
-       mempool_free(p, nfs_rdata_mempool);
+       kmem_cache_free(nfs_rdata_cachep, p);
 }
 
-static void nfs_readdata_release(struct nfs_read_data *rdata)
+void nfs_readdata_release(struct nfs_read_data *rdata)
 {
-       put_lseg(rdata->lseg);
        put_nfs_open_context(rdata->args.context);
        nfs_readdata_free(rdata);
 }
@@ -118,7 +113,13 @@ void nfs_pageio_init_read_mds(struct nfs_pageio_descriptor *pgio,
        nfs_pageio_init(pgio, inode, &nfs_pageio_read_ops,
                        NFS_SERVER(inode)->rsize, 0);
 }
-EXPORT_SYMBOL_GPL(nfs_pageio_init_read_mds);
+
+void nfs_pageio_reset_read_mds(struct nfs_pageio_descriptor *pgio)
+{
+       pgio->pg_ops = &nfs_pageio_read_ops;
+       pgio->pg_bsize = NFS_SERVER(pgio->pg_inode)->rsize;
+}
+EXPORT_SYMBOL_GPL(nfs_pageio_reset_read_mds);
 
 static void nfs_pageio_init_read(struct nfs_pageio_descriptor *pgio,
                struct inode *inode)
@@ -153,7 +154,7 @@ int nfs_readpage_async(struct nfs_open_context *ctx, struct inode *inode,
 
 static void nfs_readpage_release(struct nfs_page *req)
 {
-       struct inode *d_inode = req->wb_context->path.dentry->d_inode;
+       struct inode *d_inode = req->wb_context->dentry->d_inode;
 
        if (PageUptodate(req->wb_page))
                nfs_readpage_to_fscache(d_inode, req->wb_page, 0);
@@ -161,8 +162,8 @@ static void nfs_readpage_release(struct nfs_page *req)
        unlock_page(req->wb_page);
 
        dprintk("NFS: read done (%s/%Ld %d@%Ld)\n",
-                       req->wb_context->path.dentry->d_inode->i_sb->s_id,
-                       (long long)NFS_FILEID(req->wb_context->path.dentry->d_inode),
+                       req->wb_context->dentry->d_inode->i_sb->s_id,
+                       (long long)NFS_FILEID(req->wb_context->dentry->d_inode),
                        req->wb_bytes,
                        (long long)req_offset(req));
        nfs_release_request(req);
@@ -214,7 +215,7 @@ EXPORT_SYMBOL_GPL(nfs_initiate_read);
 static void nfs_read_rpcsetup(struct nfs_page *req, struct nfs_read_data *data,
                unsigned int count, unsigned int offset)
 {
-       struct inode *inode = req->wb_context->path.dentry->d_inode;
+       struct inode *inode = req->wb_context->dentry->d_inode;
 
        data->req         = req;
        data->inode       = inode;
@@ -235,26 +236,16 @@ static void nfs_read_rpcsetup(struct nfs_page *req, struct nfs_read_data *data,
 }
 
 static int nfs_do_read(struct nfs_read_data *data,
-               const struct rpc_call_ops *call_ops,
-               struct pnfs_layout_segment *lseg)
+               const struct rpc_call_ops *call_ops)
 {
-       struct inode *inode = data->args.context->path.dentry->d_inode;
-
-       if (lseg) {
-               data->lseg = get_lseg(lseg);
-               if (pnfs_try_to_read_data(data, call_ops) == PNFS_ATTEMPTED)
-                       return 0;
-               put_lseg(data->lseg);
-               data->lseg = NULL;
-       }
+       struct inode *inode = data->args.context->dentry->d_inode;
 
        return nfs_initiate_read(data, NFS_CLIENT(inode), call_ops);
 }
 
 static int
 nfs_do_multiple_reads(struct list_head *head,
-               const struct rpc_call_ops *call_ops,
-               struct pnfs_layout_segment *lseg)
+               const struct rpc_call_ops *call_ops)
 {
        struct nfs_read_data *data;
        int ret = 0;
@@ -265,7 +256,7 @@ nfs_do_multiple_reads(struct list_head *head,
                data = list_entry(head->next, struct nfs_read_data, list);
                list_del_init(&data->list);
 
-               ret2 = nfs_do_read(data, call_ops, lseg);
+               ret2 = nfs_do_read(data, call_ops);
                if (ret == 0)
                        ret = ret2;
        }
@@ -280,7 +271,6 @@ nfs_async_read_error(struct list_head *head)
        while (!list_empty(head)) {
                req = nfs_list_entry(head->next);
                nfs_list_remove_request(req);
-               SetPageError(req->wb_page);
                nfs_readpage_release(req);
        }
 }
@@ -326,7 +316,6 @@ static int nfs_pagein_multi(struct nfs_pageio_descriptor *desc, struct list_head
                offset += len;
        } while(nbytes != 0);
        atomic_set(&req->wb_complete, requests);
-       ClearPageError(page);
        desc->pg_rpc_callops = &nfs_read_partial_ops;
        return ret;
 out_bad:
@@ -335,7 +324,6 @@ out_bad:
                list_del(&data->list);
                nfs_readdata_free(data);
        }
-       SetPageError(page);
        nfs_readpage_release(req);
        return -ENOMEM;
 }
@@ -361,7 +349,6 @@ static int nfs_pagein_one(struct nfs_pageio_descriptor *desc, struct list_head *
                req = nfs_list_entry(head->next);
                nfs_list_remove_request(req);
                nfs_list_add_request(req, &data->pages);
-               ClearPageError(req->wb_page);
                *pages++ = req->wb_page;
        }
        req = nfs_list_entry(data->pages.next);
@@ -373,25 +360,23 @@ out:
        return ret;
 }
 
-int nfs_generic_pg_readpages(struct nfs_pageio_descriptor *desc)
+int nfs_generic_pagein(struct nfs_pageio_descriptor *desc, struct list_head *head)
+{
+       if (desc->pg_bsize < PAGE_CACHE_SIZE)
+               return nfs_pagein_multi(desc, head);
+       return nfs_pagein_one(desc, head);
+}
+
+static int nfs_generic_pg_readpages(struct nfs_pageio_descriptor *desc)
 {
        LIST_HEAD(head);
        int ret;
 
-       if (desc->pg_bsize < PAGE_CACHE_SIZE)
-               ret = nfs_pagein_multi(desc, &head);
-       else
-               ret = nfs_pagein_one(desc, &head);
-
+       ret = nfs_generic_pagein(desc, &head);
        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;
+               ret = nfs_do_multiple_reads(&head, desc->pg_rpc_callops);
        return ret;
 }
-EXPORT_SYMBOL_GPL(nfs_generic_pg_readpages);
-
 
 static const struct nfs_pageio_ops nfs_pageio_read_ops = {
        .pg_test = nfs_generic_pg_test,
@@ -441,7 +426,7 @@ static void nfs_readpage_retry(struct rpc_task *task, struct nfs_read_data *data
        argp->offset += resp->count;
        argp->pgbase += resp->count;
        argp->count -= resp->count;
-       nfs_restart_rpc(task, NFS_SERVER(data->inode)->nfs_client);
+       rpc_restart_call_prepare(task);
 }
 
 /*
@@ -468,33 +453,24 @@ static void nfs_readpage_release_partial(void *calldata)
        int status = data->task.tk_status;
 
        if (status < 0)
-               SetPageError(page);
+               set_bit(PG_PARTIAL_READ_FAILED, &req->wb_flags);
 
        if (atomic_dec_and_test(&req->wb_complete)) {
-               if (!PageError(page))
+               if (!test_bit(PG_PARTIAL_READ_FAILED, &req->wb_flags))
                        SetPageUptodate(page);
                nfs_readpage_release(req);
        }
        nfs_readdata_release(calldata);
 }
 
-#if defined(CONFIG_NFS_V4_1)
 void nfs_read_prepare(struct rpc_task *task, void *calldata)
 {
        struct nfs_read_data *data = calldata;
-
-       if (nfs4_setup_sequence(NFS_SERVER(data->inode),
-                               &data->args.seq_args, &data->res.seq_res,
-                               0, task))
-               return;
-       rpc_call_start(task);
+       NFS_PROTO(data->inode)->read_rpc_prepare(task, data);
 }
-#endif /* CONFIG_NFS_V4_1 */
 
 static const struct rpc_call_ops nfs_read_partial_ops = {
-#if defined(CONFIG_NFS_V4_1)
        .rpc_call_prepare = nfs_read_prepare,
-#endif /* CONFIG_NFS_V4_1 */
        .rpc_call_done = nfs_readpage_result_partial,
        .rpc_release = nfs_readpage_release_partial,
 };
@@ -558,9 +534,7 @@ static void nfs_readpage_release_full(void *calldata)
 }
 
 static const struct rpc_call_ops nfs_read_full_ops = {
-#if defined(CONFIG_NFS_V4_1)
        .rpc_call_prepare = nfs_read_prepare,
-#endif /* CONFIG_NFS_V4_1 */
        .rpc_call_done = nfs_readpage_result_full,
        .rpc_release = nfs_readpage_release_full,
 };
@@ -654,7 +628,6 @@ readpage_async_filler(void *data, struct page *page)
        return 0;
 out_error:
        error = PTR_ERR(new);
-       SetPageError(page);
 out_unlock:
        unlock_page(page);
        return error;
@@ -717,16 +690,10 @@ int __init nfs_init_readpagecache(void)
        if (nfs_rdata_cachep == NULL)
                return -ENOMEM;
 
-       nfs_rdata_mempool = mempool_create_slab_pool(MIN_POOL_READ,
-                                                    nfs_rdata_cachep);
-       if (nfs_rdata_mempool == NULL)
-               return -ENOMEM;
-
        return 0;
 }
 
 void nfs_destroy_readpagecache(void)
 {
-       mempool_destroy(nfs_rdata_mempool);
        kmem_cache_destroy(nfs_rdata_cachep);
 }