2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* linux/fs/nfs/read.c
|
|
|
|
*
|
|
|
|
* Block I/O for NFS
|
|
|
|
*
|
|
|
|
* Partial copy of Linus' read cache modifications to fs/nfs/file.c
|
|
|
|
* modified for async RPC by okir@monad.swb.de
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/time.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/fcntl.h>
|
|
|
|
#include <linux/stat.h>
|
|
|
|
#include <linux/mm.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/pagemap.h>
|
|
|
|
#include <linux/sunrpc/clnt.h>
|
|
|
|
#include <linux/nfs_fs.h>
|
|
|
|
#include <linux/nfs_page.h>
|
2011-03-01 01:34:16 +00:00
|
|
|
#include <linux/module.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2009-04-01 13:22:25 +00:00
|
|
|
#include "nfs4_fs.h"
|
2006-12-05 05:35:38 +00:00
|
|
|
#include "internal.h"
|
2006-03-20 18:44:14 +00:00
|
|
|
#include "iostat.h"
|
2009-04-03 15:42:44 +00:00
|
|
|
#include "fscache.h"
|
2006-03-20 18:44:14 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
#define NFSDBG_FACILITY NFSDBG_PAGECACHE
|
|
|
|
|
2011-06-10 17:30:23 +00:00
|
|
|
static const struct nfs_pageio_ops nfs_pageio_read_ops;
|
2012-04-20 18:47:46 +00:00
|
|
|
static const struct rpc_call_ops nfs_read_common_ops;
|
2012-04-20 18:47:48 +00:00
|
|
|
static const struct nfs_pgio_completion_ops nfs_async_read_completion_ops;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-12-07 04:33:20 +00:00
|
|
|
static struct kmem_cache *nfs_rdata_cachep;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2012-05-04 17:54:24 +00:00
|
|
|
struct nfs_read_header *nfs_readhdr_alloc(void)
|
2006-03-20 18:44:37 +00:00
|
|
|
{
|
2012-04-20 18:47:46 +00:00
|
|
|
struct nfs_read_header *rhdr;
|
2006-03-20 18:44:37 +00:00
|
|
|
|
2012-04-20 18:47:46 +00:00
|
|
|
rhdr = kmem_cache_zalloc(nfs_rdata_cachep, GFP_KERNEL);
|
|
|
|
if (rhdr) {
|
|
|
|
struct nfs_pgio_header *hdr = &rhdr->header;
|
2012-04-20 18:47:44 +00:00
|
|
|
|
|
|
|
INIT_LIST_HEAD(&hdr->pages);
|
2012-04-20 18:47:46 +00:00
|
|
|
INIT_LIST_HEAD(&hdr->rpc_list);
|
|
|
|
spin_lock_init(&hdr->lock);
|
|
|
|
atomic_set(&hdr->refcnt, 0);
|
|
|
|
}
|
|
|
|
return rhdr;
|
|
|
|
}
|
2012-07-30 20:05:25 +00:00
|
|
|
EXPORT_SYMBOL_GPL(nfs_readhdr_alloc);
|
2012-04-20 18:47:46 +00:00
|
|
|
|
2012-04-20 18:47:51 +00:00
|
|
|
static struct nfs_read_data *nfs_readdata_alloc(struct nfs_pgio_header *hdr,
|
|
|
|
unsigned int pagecount)
|
2012-04-20 18:47:46 +00:00
|
|
|
{
|
|
|
|
struct nfs_read_data *data, *prealloc;
|
|
|
|
|
|
|
|
prealloc = &container_of(hdr, struct nfs_read_header, header)->rpc_data;
|
|
|
|
if (prealloc->header == NULL)
|
|
|
|
data = prealloc;
|
|
|
|
else
|
|
|
|
data = kzalloc(sizeof(*data), GFP_KERNEL);
|
|
|
|
if (!data)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
if (nfs_pgarray_set(&data->pages, pagecount)) {
|
2012-04-20 18:47:44 +00:00
|
|
|
data->header = hdr;
|
2012-04-20 18:47:46 +00:00
|
|
|
atomic_inc(&hdr->refcnt);
|
|
|
|
} else {
|
|
|
|
if (data != prealloc)
|
|
|
|
kfree(data);
|
|
|
|
data = NULL;
|
2006-03-20 18:44:37 +00:00
|
|
|
}
|
2012-04-20 18:47:46 +00:00
|
|
|
out:
|
|
|
|
return data;
|
2006-03-20 18:44:37 +00:00
|
|
|
}
|
|
|
|
|
2012-04-20 18:47:44 +00:00
|
|
|
void nfs_readhdr_free(struct nfs_pgio_header *hdr)
|
2006-03-20 18:44:37 +00:00
|
|
|
{
|
2012-04-20 18:47:44 +00:00
|
|
|
struct nfs_read_header *rhdr = container_of(hdr, struct nfs_read_header, header);
|
|
|
|
|
|
|
|
kmem_cache_free(nfs_rdata_cachep, rhdr);
|
2006-03-20 18:44:37 +00:00
|
|
|
}
|
2012-07-30 20:05:25 +00:00
|
|
|
EXPORT_SYMBOL_GPL(nfs_readhdr_free);
|
2006-03-20 18:44:37 +00:00
|
|
|
|
2011-07-13 19:58:28 +00:00
|
|
|
void nfs_readdata_release(struct nfs_read_data *rdata)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2012-04-20 18:47:46 +00:00
|
|
|
struct nfs_pgio_header *hdr = rdata->header;
|
|
|
|
struct nfs_read_header *read_header = container_of(hdr, struct nfs_read_header, header);
|
|
|
|
|
2008-02-20 01:04:20 +00:00
|
|
|
put_nfs_open_context(rdata->args.context);
|
2012-04-20 18:47:45 +00:00
|
|
|
if (rdata->pages.pagevec != rdata->pages.page_array)
|
|
|
|
kfree(rdata->pages.pagevec);
|
2013-01-04 17:47:04 +00:00
|
|
|
if (rdata == &read_header->rpc_data) {
|
2012-04-20 18:47:46 +00:00
|
|
|
rdata->header = NULL;
|
2013-01-04 17:47:04 +00:00
|
|
|
rdata = NULL;
|
|
|
|
}
|
2012-04-20 18:47:46 +00:00
|
|
|
if (atomic_dec_and_test(&hdr->refcnt))
|
2012-04-20 18:47:48 +00:00
|
|
|
hdr->completion_ops->completion(hdr);
|
2013-01-04 17:47:04 +00:00
|
|
|
/* Note: we only free the rpc_task after callbacks are done.
|
|
|
|
* See the comment in rpc_free_task() for why
|
|
|
|
*/
|
|
|
|
kfree(rdata);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2012-07-30 20:05:25 +00:00
|
|
|
EXPORT_SYMBOL_GPL(nfs_readdata_release);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
static
|
|
|
|
int nfs_return_empty_page(struct page *page)
|
|
|
|
{
|
2008-02-05 06:28:29 +00:00
|
|
|
zero_user(page, 0, PAGE_CACHE_SIZE);
|
2005-04-16 22:20:36 +00:00
|
|
|
SetPageUptodate(page);
|
|
|
|
unlock_page(page);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-06-20 19:53:47 +00:00
|
|
|
void nfs_pageio_init_read(struct nfs_pageio_descriptor *pgio,
|
2012-04-20 18:47:48 +00:00
|
|
|
struct inode *inode,
|
|
|
|
const struct nfs_pgio_completion_ops *compl_ops)
|
2011-06-10 17:30:23 +00:00
|
|
|
{
|
2012-04-20 18:47:48 +00:00
|
|
|
nfs_pageio_init(pgio, inode, &nfs_pageio_read_ops, compl_ops,
|
2011-06-10 17:30:23 +00:00
|
|
|
NFS_SERVER(inode)->rsize, 0);
|
|
|
|
}
|
2012-07-30 20:05:23 +00:00
|
|
|
EXPORT_SYMBOL_GPL(nfs_pageio_init_read);
|
2011-06-10 17:30:23 +00:00
|
|
|
|
2011-07-13 19:58:28 +00:00
|
|
|
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;
|
|
|
|
}
|
2011-07-13 19:59:57 +00:00
|
|
|
EXPORT_SYMBOL_GPL(nfs_pageio_reset_read_mds);
|
2011-07-13 19:58:28 +00:00
|
|
|
|
2009-04-03 15:42:44 +00:00
|
|
|
int nfs_readpage_async(struct nfs_open_context *ctx, struct inode *inode,
|
|
|
|
struct page *page)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct nfs_page *new;
|
|
|
|
unsigned int len;
|
2011-03-03 15:13:48 +00:00
|
|
|
struct nfs_pageio_descriptor pgio;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-12-05 05:35:38 +00:00
|
|
|
len = nfs_page_length(page);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (len == 0)
|
|
|
|
return nfs_return_empty_page(page);
|
|
|
|
new = nfs_create_request(ctx, inode, page, 0, len);
|
|
|
|
if (IS_ERR(new)) {
|
|
|
|
unlock_page(page);
|
|
|
|
return PTR_ERR(new);
|
|
|
|
}
|
|
|
|
if (len < PAGE_CACHE_SIZE)
|
2008-02-05 06:28:29 +00:00
|
|
|
zero_user_segment(page, len, PAGE_CACHE_SIZE);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2012-06-20 19:53:47 +00:00
|
|
|
NFS_PROTO(inode)->read_pageio_init(&pgio, inode, &nfs_async_read_completion_ops);
|
2011-06-10 17:30:23 +00:00
|
|
|
nfs_pageio_add_request(&pgio, new);
|
2011-06-10 17:30:23 +00:00
|
|
|
nfs_pageio_complete(&pgio);
|
2012-05-24 17:13:24 +00:00
|
|
|
NFS_I(inode)->read_io += pgio.pg_bytes_written;
|
2005-04-16 22:20:36 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void nfs_readpage_release(struct nfs_page *req)
|
|
|
|
{
|
2011-06-22 22:40:12 +00:00
|
|
|
struct inode *d_inode = req->wb_context->dentry->d_inode;
|
2009-04-03 15:42:45 +00:00
|
|
|
|
|
|
|
if (PageUptodate(req->wb_page))
|
|
|
|
nfs_readpage_to_fscache(d_inode, req->wb_page, 0);
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
unlock_page(req->wb_page);
|
|
|
|
|
|
|
|
dprintk("NFS: read done (%s/%Ld %d@%Ld)\n",
|
2011-06-22 22:40:12 +00:00
|
|
|
req->wb_context->dentry->d_inode->i_sb->s_id,
|
|
|
|
(long long)NFS_FILEID(req->wb_context->dentry->d_inode),
|
2005-04-16 22:20:36 +00:00
|
|
|
req->wb_bytes,
|
|
|
|
(long long)req_offset(req));
|
2005-09-23 04:44:28 +00:00
|
|
|
nfs_release_request(req);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2012-04-20 18:47:46 +00:00
|
|
|
/* Note io was page aligned */
|
2012-04-20 18:47:48 +00:00
|
|
|
static void nfs_read_completion(struct nfs_pgio_header *hdr)
|
2012-04-20 18:47:46 +00:00
|
|
|
{
|
|
|
|
unsigned long bytes = 0;
|
|
|
|
|
|
|
|
if (test_bit(NFS_IOHDR_REDO, &hdr->flags))
|
|
|
|
goto out;
|
2012-05-01 16:49:58 +00:00
|
|
|
while (!list_empty(&hdr->pages)) {
|
|
|
|
struct nfs_page *req = nfs_list_entry(hdr->pages.next);
|
|
|
|
struct page *page = req->wb_page;
|
|
|
|
|
|
|
|
if (test_bit(NFS_IOHDR_EOF, &hdr->flags)) {
|
|
|
|
if (bytes > hdr->good_bytes)
|
|
|
|
zero_user(page, 0, PAGE_SIZE);
|
|
|
|
else if (hdr->good_bytes - bytes < PAGE_SIZE)
|
|
|
|
zero_user_segment(page,
|
|
|
|
hdr->good_bytes & ~PAGE_MASK,
|
|
|
|
PAGE_SIZE);
|
2012-04-20 18:47:46 +00:00
|
|
|
}
|
2012-05-01 16:49:58 +00:00
|
|
|
bytes += req->wb_bytes;
|
|
|
|
if (test_bit(NFS_IOHDR_ERROR, &hdr->flags)) {
|
2012-04-20 18:47:46 +00:00
|
|
|
if (bytes <= hdr->good_bytes)
|
2012-05-01 16:49:58 +00:00
|
|
|
SetPageUptodate(page);
|
|
|
|
} else
|
|
|
|
SetPageUptodate(page);
|
|
|
|
nfs_list_remove_request(req);
|
|
|
|
nfs_readpage_release(req);
|
2012-04-20 18:47:46 +00:00
|
|
|
}
|
|
|
|
out:
|
|
|
|
hdr->release(hdr);
|
|
|
|
}
|
|
|
|
|
2012-04-20 18:47:41 +00:00
|
|
|
int nfs_initiate_read(struct rpc_clnt *clnt,
|
|
|
|
struct nfs_read_data *data,
|
2012-04-27 21:53:44 +00:00
|
|
|
const struct rpc_call_ops *call_ops, int flags)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2012-04-20 18:47:44 +00:00
|
|
|
struct inode *inode = data->header->inode;
|
2007-07-14 19:39:59 +00:00
|
|
|
int swap_flags = IS_SWAPFILE(inode) ? NFS_RPC_SWAPFLAGS : 0;
|
2007-10-25 22:42:54 +00:00
|
|
|
struct rpc_task *task;
|
2007-07-14 19:40:00 +00:00
|
|
|
struct rpc_message msg = {
|
|
|
|
.rpc_argp = &data->args,
|
|
|
|
.rpc_resp = &data->res,
|
2012-04-20 18:47:44 +00:00
|
|
|
.rpc_cred = data->header->cred,
|
2007-07-14 19:40:00 +00:00
|
|
|
};
|
2007-07-14 19:39:59 +00:00
|
|
|
struct rpc_task_setup task_setup_data = {
|
2007-10-25 22:42:54 +00:00
|
|
|
.task = &data->task,
|
2011-03-01 01:34:16 +00:00
|
|
|
.rpc_client = clnt,
|
2007-07-14 19:40:00 +00:00
|
|
|
.rpc_message = &msg,
|
2007-07-14 19:39:59 +00:00
|
|
|
.callback_ops = call_ops,
|
|
|
|
.callback_data = data,
|
2008-02-20 01:04:23 +00:00
|
|
|
.workqueue = nfsiod_workqueue,
|
2012-04-27 21:53:44 +00:00
|
|
|
.flags = RPC_TASK_ASYNC | swap_flags | flags,
|
2007-07-14 19:39:59 +00:00
|
|
|
};
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2011-03-01 01:34:16 +00:00
|
|
|
/* Set up the initial task struct. */
|
|
|
|
NFS_PROTO(inode)->read_setup(data, &msg);
|
|
|
|
|
|
|
|
dprintk("NFS: %5u initiated read call (req %s/%lld, %u bytes @ "
|
|
|
|
"offset %llu)\n",
|
|
|
|
data->task.tk_pid,
|
|
|
|
inode->i_sb->s_id,
|
|
|
|
(long long)NFS_FILEID(inode),
|
|
|
|
data->args.count,
|
|
|
|
(unsigned long long)data->args.offset);
|
|
|
|
|
|
|
|
task = rpc_run_task(&task_setup_data);
|
|
|
|
if (IS_ERR(task))
|
|
|
|
return PTR_ERR(task);
|
|
|
|
rpc_put_task(task);
|
|
|
|
return 0;
|
|
|
|
}
|
2011-03-01 01:34:19 +00:00
|
|
|
EXPORT_SYMBOL_GPL(nfs_initiate_read);
|
2011-03-01 01:34:16 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Set up the NFS read request struct
|
|
|
|
*/
|
2012-04-20 18:47:46 +00:00
|
|
|
static void nfs_read_rpcsetup(struct nfs_read_data *data,
|
2011-07-12 17:42:02 +00:00
|
|
|
unsigned int count, unsigned int offset)
|
2011-03-01 01:34:16 +00:00
|
|
|
{
|
2012-04-20 18:47:46 +00:00
|
|
|
struct nfs_page *req = data->header->req;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2012-04-20 18:47:46 +00:00
|
|
|
data->args.fh = NFS_FH(data->header->inode);
|
2005-04-16 22:20:36 +00:00
|
|
|
data->args.offset = req_offset(req) + offset;
|
|
|
|
data->args.pgbase = req->wb_pgbase + offset;
|
2012-04-20 18:47:45 +00:00
|
|
|
data->args.pages = data->pages.pagevec;
|
2005-04-16 22:20:36 +00:00
|
|
|
data->args.count = count;
|
2008-02-20 01:04:20 +00:00
|
|
|
data->args.context = get_nfs_open_context(req->wb_context);
|
2010-06-25 20:35:53 +00:00
|
|
|
data->args.lock_context = req->wb_lock_context;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
data->res.fattr = &data->fattr;
|
|
|
|
data->res.count = count;
|
|
|
|
data->res.eof = 0;
|
2005-10-28 02:12:38 +00:00
|
|
|
nfs_fattr_init(&data->fattr);
|
2011-07-12 17:42:02 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2011-07-12 17:42:02 +00:00
|
|
|
static int nfs_do_read(struct nfs_read_data *data,
|
2011-07-13 19:58:28 +00:00
|
|
|
const struct rpc_call_ops *call_ops)
|
2011-07-12 17:42:02 +00:00
|
|
|
{
|
2012-04-20 18:47:44 +00:00
|
|
|
struct inode *inode = data->header->inode;
|
2011-07-12 17:42:02 +00:00
|
|
|
|
2012-04-27 21:53:44 +00:00
|
|
|
return nfs_initiate_read(NFS_CLIENT(inode), data, call_ops, 0);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2011-07-12 17:42:02 +00:00
|
|
|
static int
|
|
|
|
nfs_do_multiple_reads(struct list_head *head,
|
2011-07-13 19:58:28 +00:00
|
|
|
const struct rpc_call_ops *call_ops)
|
2011-07-12 17:42:02 +00:00
|
|
|
{
|
|
|
|
struct nfs_read_data *data;
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
while (!list_empty(head)) {
|
|
|
|
int ret2;
|
|
|
|
|
2012-04-20 18:47:46 +00:00
|
|
|
data = list_first_entry(head, struct nfs_read_data, list);
|
2011-07-12 17:42:02 +00:00
|
|
|
list_del_init(&data->list);
|
|
|
|
|
2011-07-13 19:58:28 +00:00
|
|
|
ret2 = nfs_do_read(data, call_ops);
|
2011-07-12 17:42:02 +00:00
|
|
|
if (ret == 0)
|
|
|
|
ret = ret2;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2012-04-20 18:47:48 +00:00
|
|
|
static void
|
2005-04-16 22:20:36 +00:00
|
|
|
nfs_async_read_error(struct list_head *head)
|
|
|
|
{
|
|
|
|
struct nfs_page *req;
|
|
|
|
|
|
|
|
while (!list_empty(head)) {
|
|
|
|
req = nfs_list_entry(head->next);
|
|
|
|
nfs_list_remove_request(req);
|
|
|
|
nfs_readpage_release(req);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-20 18:47:48 +00:00
|
|
|
static const struct nfs_pgio_completion_ops nfs_async_read_completion_ops = {
|
|
|
|
.error_cleanup = nfs_async_read_error,
|
|
|
|
.completion = nfs_read_completion,
|
|
|
|
};
|
|
|
|
|
2012-05-01 16:07:22 +00:00
|
|
|
static void nfs_pagein_error(struct nfs_pageio_descriptor *desc,
|
|
|
|
struct nfs_pgio_header *hdr)
|
|
|
|
{
|
|
|
|
set_bit(NFS_IOHDR_REDO, &hdr->flags);
|
|
|
|
while (!list_empty(&hdr->rpc_list)) {
|
|
|
|
struct nfs_read_data *data = list_first_entry(&hdr->rpc_list,
|
|
|
|
struct nfs_read_data, list);
|
|
|
|
list_del(&data->list);
|
|
|
|
nfs_readdata_release(data);
|
|
|
|
}
|
|
|
|
desc->pg_completion_ops->error_cleanup(&desc->pg_list);
|
|
|
|
}
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* Generate multiple requests to fill a single page.
|
|
|
|
*
|
|
|
|
* We optimize to reduce the number of read operations on the wire. If we
|
|
|
|
* detect that we're reading a page, or an area of a page, that is past the
|
|
|
|
* end of file, we do not generate NFS read operations but just clear the
|
|
|
|
* parts of the page that would have come back zero from the server anyway.
|
|
|
|
*
|
|
|
|
* We rely on the cached value of i_size to make this determination; another
|
|
|
|
* client can fill pages on the server past our cached end-of-file, but we
|
|
|
|
* won't see the new data until our attribute cache is updated. This is more
|
|
|
|
* or less conventional NFS client behavior.
|
|
|
|
*/
|
2012-04-20 18:47:46 +00:00
|
|
|
static int nfs_pagein_multi(struct nfs_pageio_descriptor *desc,
|
|
|
|
struct nfs_pgio_header *hdr)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2012-04-20 18:47:46 +00:00
|
|
|
struct nfs_page *req = hdr->req;
|
2005-04-16 22:20:36 +00:00
|
|
|
struct page *page = req->wb_page;
|
|
|
|
struct nfs_read_data *data;
|
2011-07-12 17:42:02 +00:00
|
|
|
size_t rsize = desc->pg_bsize, nbytes;
|
2006-09-08 16:48:54 +00:00
|
|
|
unsigned int offset;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2011-07-12 17:42:02 +00:00
|
|
|
offset = 0;
|
2011-03-03 15:13:48 +00:00
|
|
|
nbytes = desc->pg_count;
|
2006-09-08 16:48:54 +00:00
|
|
|
do {
|
|
|
|
size_t len = min(nbytes,rsize);
|
|
|
|
|
2012-04-20 18:47:46 +00:00
|
|
|
data = nfs_readdata_alloc(hdr, 1);
|
2012-05-01 16:07:22 +00:00
|
|
|
if (!data) {
|
|
|
|
nfs_pagein_error(desc, hdr);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
2012-04-20 18:47:45 +00:00
|
|
|
data->pages.pagevec[0] = page;
|
2012-04-20 18:47:46 +00:00
|
|
|
nfs_read_rpcsetup(data, len, offset);
|
|
|
|
list_add(&data->list, &hdr->rpc_list);
|
2006-09-08 16:48:54 +00:00
|
|
|
nbytes -= len;
|
2011-07-12 17:42:02 +00:00
|
|
|
offset += len;
|
2012-05-01 15:21:43 +00:00
|
|
|
} while (nbytes != 0);
|
2012-05-01 16:07:22 +00:00
|
|
|
|
|
|
|
nfs_list_remove_request(req);
|
|
|
|
nfs_list_add_request(req, &hdr->pages);
|
2012-04-20 18:47:46 +00:00
|
|
|
desc->pg_rpc_callops = &nfs_read_common_ops;
|
2012-05-01 15:21:43 +00:00
|
|
|
return 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2012-04-20 18:47:46 +00:00
|
|
|
static int nfs_pagein_one(struct nfs_pageio_descriptor *desc,
|
|
|
|
struct nfs_pgio_header *hdr)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct nfs_page *req;
|
|
|
|
struct page **pages;
|
2012-04-20 18:47:46 +00:00
|
|
|
struct nfs_read_data *data;
|
2011-03-03 15:13:48 +00:00
|
|
|
struct list_head *head = &desc->pg_list;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2012-04-20 18:47:46 +00:00
|
|
|
data = nfs_readdata_alloc(hdr, nfs_page_array_len(desc->pg_base,
|
|
|
|
desc->pg_count));
|
|
|
|
if (!data) {
|
2012-05-01 16:07:22 +00:00
|
|
|
nfs_pagein_error(desc, hdr);
|
2012-05-01 15:21:43 +00:00
|
|
|
return -ENOMEM;
|
2011-03-01 01:34:15 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2012-04-20 18:47:45 +00:00
|
|
|
pages = data->pages.pagevec;
|
2005-04-16 22:20:36 +00:00
|
|
|
while (!list_empty(head)) {
|
|
|
|
req = nfs_list_entry(head->next);
|
|
|
|
nfs_list_remove_request(req);
|
2012-04-20 18:47:46 +00:00
|
|
|
nfs_list_add_request(req, &hdr->pages);
|
2005-04-16 22:20:36 +00:00
|
|
|
*pages++ = req->wb_page;
|
|
|
|
}
|
|
|
|
|
2012-04-20 18:47:46 +00:00
|
|
|
nfs_read_rpcsetup(data, desc->pg_count, 0);
|
|
|
|
list_add(&data->list, &hdr->rpc_list);
|
|
|
|
desc->pg_rpc_callops = &nfs_read_common_ops;
|
2012-05-01 15:21:43 +00:00
|
|
|
return 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2012-04-20 18:47:46 +00:00
|
|
|
int nfs_generic_pagein(struct nfs_pageio_descriptor *desc,
|
|
|
|
struct nfs_pgio_header *hdr)
|
2011-07-13 19:58:28 +00:00
|
|
|
{
|
|
|
|
if (desc->pg_bsize < PAGE_CACHE_SIZE)
|
2012-04-20 18:47:46 +00:00
|
|
|
return nfs_pagein_multi(desc, hdr);
|
|
|
|
return nfs_pagein_one(desc, hdr);
|
2011-07-13 19:58:28 +00:00
|
|
|
}
|
2012-07-30 20:05:25 +00:00
|
|
|
EXPORT_SYMBOL_GPL(nfs_generic_pagein);
|
2011-07-13 19:58:28 +00:00
|
|
|
|
|
|
|
static int nfs_generic_pg_readpages(struct nfs_pageio_descriptor *desc)
|
2011-06-10 17:30:23 +00:00
|
|
|
{
|
2012-04-20 18:47:46 +00:00
|
|
|
struct nfs_read_header *rhdr;
|
|
|
|
struct nfs_pgio_header *hdr;
|
2011-07-12 17:42:02 +00:00
|
|
|
int ret;
|
|
|
|
|
2012-04-20 18:47:46 +00:00
|
|
|
rhdr = nfs_readhdr_alloc();
|
|
|
|
if (!rhdr) {
|
2012-04-20 18:47:48 +00:00
|
|
|
desc->pg_completion_ops->error_cleanup(&desc->pg_list);
|
2012-04-20 18:47:46 +00:00
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
hdr = &rhdr->header;
|
|
|
|
nfs_pgheader_init(desc, hdr, nfs_readhdr_free);
|
|
|
|
atomic_inc(&hdr->refcnt);
|
|
|
|
ret = nfs_generic_pagein(desc, hdr);
|
2011-07-12 17:42:02 +00:00
|
|
|
if (ret == 0)
|
2012-04-20 18:47:46 +00:00
|
|
|
ret = nfs_do_multiple_reads(&hdr->rpc_list,
|
|
|
|
desc->pg_rpc_callops);
|
|
|
|
if (atomic_dec_and_test(&hdr->refcnt))
|
2012-04-20 18:47:48 +00:00
|
|
|
hdr->completion_ops->completion(hdr);
|
2011-07-12 17:42:02 +00:00
|
|
|
return ret;
|
2011-06-10 17:30:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct nfs_pageio_ops nfs_pageio_read_ops = {
|
|
|
|
.pg_test = nfs_generic_pg_test,
|
|
|
|
.pg_doio = nfs_generic_pg_readpages,
|
|
|
|
};
|
|
|
|
|
2006-11-14 21:12:23 +00:00
|
|
|
/*
|
|
|
|
* This is the callback from RPC telling us whether a reply was
|
|
|
|
* received or some error occurred (timeout or socket shutdown).
|
|
|
|
*/
|
|
|
|
int nfs_readpage_result(struct rpc_task *task, struct nfs_read_data *data)
|
|
|
|
{
|
2012-04-20 18:47:44 +00:00
|
|
|
struct inode *inode = data->header->inode;
|
2006-11-14 21:12:23 +00:00
|
|
|
int status;
|
|
|
|
|
2008-05-02 20:42:44 +00:00
|
|
|
dprintk("NFS: %s: %5u, (status %d)\n", __func__, task->tk_pid,
|
2006-11-14 21:12:23 +00:00
|
|
|
task->tk_status);
|
|
|
|
|
2012-04-20 18:47:44 +00:00
|
|
|
status = NFS_PROTO(inode)->read_done(task, data);
|
2006-11-14 21:12:23 +00:00
|
|
|
if (status != 0)
|
|
|
|
return status;
|
|
|
|
|
2012-04-20 18:47:44 +00:00
|
|
|
nfs_add_stats(inode, NFSIOS_SERVERREADBYTES, data->res.count);
|
2006-11-14 21:12:23 +00:00
|
|
|
|
|
|
|
if (task->tk_status == -ESTALE) {
|
2012-04-20 18:47:44 +00:00
|
|
|
set_bit(NFS_INO_STALE, &NFS_I(inode)->flags);
|
|
|
|
nfs_mark_for_revalidate(inode);
|
2006-11-14 21:12:23 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-04-15 20:33:58 +00:00
|
|
|
static void nfs_readpage_retry(struct rpc_task *task, struct nfs_read_data *data)
|
2006-11-14 21:12:23 +00:00
|
|
|
{
|
|
|
|
struct nfs_readargs *argp = &data->args;
|
|
|
|
struct nfs_readres *resp = &data->res;
|
|
|
|
|
|
|
|
/* This is a short read! */
|
2012-04-20 18:47:44 +00:00
|
|
|
nfs_inc_stats(data->header->inode, NFSIOS_SHORTREAD);
|
2006-11-14 21:12:23 +00:00
|
|
|
/* Has the server at least made some progress? */
|
2012-04-20 18:47:46 +00:00
|
|
|
if (resp->count == 0) {
|
|
|
|
nfs_set_pgio_error(data->header, -EIO, argp->offset);
|
2009-12-06 00:32:19 +00:00
|
|
|
return;
|
2012-04-20 18:47:46 +00:00
|
|
|
}
|
2006-11-14 21:12:23 +00:00
|
|
|
/* Yes, so retry the read at the end of the data */
|
2011-03-01 01:34:20 +00:00
|
|
|
data->mds_offset += resp->count;
|
2006-11-14 21:12:23 +00:00
|
|
|
argp->offset += resp->count;
|
|
|
|
argp->pgbase += resp->count;
|
|
|
|
argp->count -= resp->count;
|
2011-10-19 19:17:29 +00:00
|
|
|
rpc_restart_call_prepare(task);
|
2006-11-14 21:12:23 +00:00
|
|
|
}
|
|
|
|
|
2012-04-20 18:47:46 +00:00
|
|
|
static void nfs_readpage_result_common(struct rpc_task *task, void *calldata)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2006-03-20 18:44:27 +00:00
|
|
|
struct nfs_read_data *data = calldata;
|
2012-04-20 18:47:46 +00:00
|
|
|
struct nfs_pgio_header *hdr = data->header;
|
|
|
|
|
|
|
|
/* Note the only returns of nfs_readpage_result are 0 and -EAGAIN */
|
2006-03-20 18:44:27 +00:00
|
|
|
if (nfs_readpage_result(task, data) != 0)
|
|
|
|
return;
|
2008-04-15 20:33:58 +00:00
|
|
|
if (task->tk_status < 0)
|
2012-04-20 18:47:46 +00:00
|
|
|
nfs_set_pgio_error(hdr, task->tk_status, data->args.offset);
|
|
|
|
else if (data->res.eof) {
|
|
|
|
loff_t bound;
|
|
|
|
|
|
|
|
bound = data->args.offset + data->res.count;
|
|
|
|
spin_lock(&hdr->lock);
|
|
|
|
if (bound < hdr->io_start + hdr->good_bytes) {
|
|
|
|
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 (data->res.count != data->args.count)
|
|
|
|
nfs_readpage_retry(task, data);
|
2008-04-15 20:33:58 +00:00
|
|
|
}
|
|
|
|
|
2012-04-20 18:47:46 +00:00
|
|
|
static void nfs_readpage_release_common(void *calldata)
|
2008-04-15 20:33:58 +00:00
|
|
|
{
|
2012-04-20 18:47:46 +00:00
|
|
|
nfs_readdata_release(calldata);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2009-04-01 13:22:25 +00:00
|
|
|
void nfs_read_prepare(struct rpc_task *task, void *calldata)
|
|
|
|
{
|
|
|
|
struct nfs_read_data *data = calldata;
|
2012-04-20 18:47:44 +00:00
|
|
|
NFS_PROTO(data->header->inode)->read_rpc_prepare(task, data);
|
2009-04-01 13:22:25 +00:00
|
|
|
}
|
|
|
|
|
2012-04-20 18:47:46 +00:00
|
|
|
static const struct rpc_call_ops nfs_read_common_ops = {
|
2009-04-01 13:22:25 +00:00
|
|
|
.rpc_call_prepare = nfs_read_prepare,
|
2012-04-20 18:47:46 +00:00
|
|
|
.rpc_call_done = nfs_readpage_result_common,
|
|
|
|
.rpc_release = nfs_readpage_release_common,
|
2006-03-20 18:44:27 +00:00
|
|
|
};
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* Read a page over NFS.
|
|
|
|
* We read the page synchronously in the following case:
|
|
|
|
* - The error flag is set for this page. This happens only when a
|
|
|
|
* previous async read operation failed.
|
|
|
|
*/
|
|
|
|
int nfs_readpage(struct file *file, struct page *page)
|
|
|
|
{
|
|
|
|
struct nfs_open_context *ctx;
|
2012-07-31 23:45:06 +00:00
|
|
|
struct inode *inode = page_file_mapping(page)->host;
|
2005-04-16 22:20:36 +00:00
|
|
|
int error;
|
|
|
|
|
|
|
|
dprintk("NFS: nfs_readpage (%p %ld@%lu)\n",
|
2012-07-31 23:45:06 +00:00
|
|
|
page, PAGE_CACHE_SIZE, page_file_index(page));
|
2006-03-20 18:44:14 +00:00
|
|
|
nfs_inc_stats(inode, NFSIOS_VFSREADPAGE);
|
|
|
|
nfs_add_stats(inode, NFSIOS_READPAGES, 1);
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* Try to flush any pending writes to the file..
|
|
|
|
*
|
|
|
|
* NOTE! Because we own the page lock, there cannot
|
|
|
|
* be any new pending writes generated at this point
|
|
|
|
* for this page (other pages can be written to).
|
|
|
|
*/
|
|
|
|
error = nfs_wb_page(inode, page);
|
|
|
|
if (error)
|
2007-05-20 17:05:05 +00:00
|
|
|
goto out_unlock;
|
|
|
|
if (PageUptodate(page))
|
|
|
|
goto out_unlock;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-09-14 18:03:14 +00:00
|
|
|
error = -ESTALE;
|
|
|
|
if (NFS_STALE(inode))
|
2007-05-20 17:05:05 +00:00
|
|
|
goto out_unlock;
|
2006-09-14 18:03:14 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
if (file == NULL) {
|
2006-11-19 21:44:52 +00:00
|
|
|
error = -EBADF;
|
2005-11-04 20:33:38 +00:00
|
|
|
ctx = nfs_find_open_context(inode, NULL, FMODE_READ);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (ctx == NULL)
|
2007-05-20 17:05:05 +00:00
|
|
|
goto out_unlock;
|
2005-04-16 22:20:36 +00:00
|
|
|
} else
|
2007-08-10 21:44:32 +00:00
|
|
|
ctx = get_nfs_open_context(nfs_file_open_context(file));
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2009-04-03 15:42:44 +00:00
|
|
|
if (!IS_SYNC(inode)) {
|
|
|
|
error = nfs_readpage_from_fscache(ctx, inode, page);
|
|
|
|
if (error == 0)
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2006-12-13 20:23:44 +00:00
|
|
|
error = nfs_readpage_async(ctx, inode, page);
|
|
|
|
|
2009-04-03 15:42:44 +00:00
|
|
|
out:
|
2005-04-16 22:20:36 +00:00
|
|
|
put_nfs_open_context(ctx);
|
|
|
|
return error;
|
2007-05-20 17:05:05 +00:00
|
|
|
out_unlock:
|
2005-04-16 22:20:36 +00:00
|
|
|
unlock_page(page);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct nfs_readdesc {
|
2007-04-02 22:48:28 +00:00
|
|
|
struct nfs_pageio_descriptor *pgio;
|
2005-04-16 22:20:36 +00:00
|
|
|
struct nfs_open_context *ctx;
|
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
|
|
|
readpage_async_filler(void *data, struct page *page)
|
|
|
|
{
|
|
|
|
struct nfs_readdesc *desc = (struct nfs_readdesc *)data;
|
2012-07-31 23:45:06 +00:00
|
|
|
struct inode *inode = page_file_mapping(page)->host;
|
2005-04-16 22:20:36 +00:00
|
|
|
struct nfs_page *new;
|
|
|
|
unsigned int len;
|
2007-05-20 17:05:05 +00:00
|
|
|
int error;
|
|
|
|
|
2006-12-05 05:35:38 +00:00
|
|
|
len = nfs_page_length(page);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (len == 0)
|
|
|
|
return nfs_return_empty_page(page);
|
2007-05-20 17:05:05 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
new = nfs_create_request(desc->ctx, inode, page, 0, len);
|
2007-05-20 17:05:05 +00:00
|
|
|
if (IS_ERR(new))
|
|
|
|
goto out_error;
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
if (len < PAGE_CACHE_SIZE)
|
2008-02-05 06:28:29 +00:00
|
|
|
zero_user_segment(page, len, PAGE_CACHE_SIZE);
|
nfs: don't ignore return value from nfs_pageio_add_request
Ignoring the return value from nfs_pageio_add_request can cause deadlocks.
In read path:
call nfs_pageio_add_request from readpage_async_filler
assume at this point that there are requests already in desc, that
can't be merged with the current request.
so nfs_pageio_doio is fired up to clear out desc.
assume something goes wrong in setting up the io, so desc->pg_error is set.
This causes nfs_pageio_add_request to return 0, *WITHOUT* adding the original
request.
BUT, since return code is ignored, readpage_async_filler assumes it has
been added, and does nothing further, leaving page locked.
do_generic_mapping_read will eventually call lock_page, resulting in deadlock
In write path:
page is marked dirty by generic_perform_write
nfs_writepages is called
call nfs_pageio_add_request from nfs_page_async_flush
assume at this point that there are requests already in desc, that
can't be merged with the current request.
so nfs_pageio_doio is fired up to clear out desc.
assume something goes wrong in setting up the io, so desc->pg_error is set.
This causes nfs_page_async_flush to return 0, *WITHOUT* adding the original
request, yet marking the request as locked (PG_BUSY) and in writeback,
clearing dirty marks.
The next time a write is done to the page, deadlock will result as
nfs_write_end calls nfs_update_request
Signed-off-by: Fred Isaman <iisaman@citi.umich.edu>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
2008-03-19 15:24:39 +00:00
|
|
|
if (!nfs_pageio_add_request(desc->pgio, new)) {
|
|
|
|
error = desc->pgio->pg_error;
|
|
|
|
goto out_unlock;
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
return 0;
|
2007-05-20 17:05:05 +00:00
|
|
|
out_error:
|
|
|
|
error = PTR_ERR(new);
|
|
|
|
out_unlock:
|
|
|
|
unlock_page(page);
|
|
|
|
return error;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int nfs_readpages(struct file *filp, struct address_space *mapping,
|
|
|
|
struct list_head *pages, unsigned nr_pages)
|
|
|
|
{
|
2007-04-02 22:48:28 +00:00
|
|
|
struct nfs_pageio_descriptor pgio;
|
2005-04-16 22:20:36 +00:00
|
|
|
struct nfs_readdesc desc = {
|
2007-04-02 22:48:28 +00:00
|
|
|
.pgio = &pgio,
|
2005-04-16 22:20:36 +00:00
|
|
|
};
|
|
|
|
struct inode *inode = mapping->host;
|
2007-04-02 22:48:28 +00:00
|
|
|
unsigned long npages;
|
2006-09-14 18:03:14 +00:00
|
|
|
int ret = -ESTALE;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
dprintk("NFS: nfs_readpages (%s/%Ld %d)\n",
|
|
|
|
inode->i_sb->s_id,
|
|
|
|
(long long)NFS_FILEID(inode),
|
|
|
|
nr_pages);
|
2006-03-20 18:44:14 +00:00
|
|
|
nfs_inc_stats(inode, NFSIOS_VFSREADPAGES);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-09-14 18:03:14 +00:00
|
|
|
if (NFS_STALE(inode))
|
|
|
|
goto out;
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
if (filp == NULL) {
|
2005-11-04 20:33:38 +00:00
|
|
|
desc.ctx = nfs_find_open_context(inode, NULL, FMODE_READ);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (desc.ctx == NULL)
|
|
|
|
return -EBADF;
|
|
|
|
} else
|
2007-08-10 21:44:32 +00:00
|
|
|
desc.ctx = get_nfs_open_context(nfs_file_open_context(filp));
|
2009-04-03 15:42:44 +00:00
|
|
|
|
|
|
|
/* attempt to read as many of the pages as possible from the cache
|
|
|
|
* - this returns -ENOBUFS immediately if the cookie is negative
|
|
|
|
*/
|
|
|
|
ret = nfs_readpages_from_fscache(desc.ctx, inode, mapping,
|
|
|
|
pages, &nr_pages);
|
|
|
|
if (ret == 0)
|
|
|
|
goto read_complete; /* all pages were read */
|
|
|
|
|
2012-06-20 19:53:47 +00:00
|
|
|
NFS_PROTO(inode)->read_pageio_init(&pgio, inode, &nfs_async_read_completion_ops);
|
2007-04-02 22:48:28 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
ret = read_cache_pages(mapping, pages, readpage_async_filler, &desc);
|
2007-04-02 22:48:28 +00:00
|
|
|
|
|
|
|
nfs_pageio_complete(&pgio);
|
2012-05-24 17:13:24 +00:00
|
|
|
NFS_I(inode)->read_io += pgio.pg_bytes_written;
|
2007-04-02 22:48:28 +00:00
|
|
|
npages = (pgio.pg_bytes_written + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
|
|
|
|
nfs_add_stats(inode, NFSIOS_READPAGES, npages);
|
2009-04-03 15:42:44 +00:00
|
|
|
read_complete:
|
2005-04-16 22:20:36 +00:00
|
|
|
put_nfs_open_context(desc.ctx);
|
2006-09-14 18:03:14 +00:00
|
|
|
out:
|
2005-04-16 22:20:36 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
NFS: Split fs/nfs/inode.c
As fs/nfs/inode.c is rather large, heterogenous and unwieldy, the attached
patch splits it up into a number of files:
(*) fs/nfs/inode.c
Strictly inode specific functions.
(*) fs/nfs/super.c
Superblock management functions for NFS and NFS4, normal access, clones
and referrals. The NFS4 superblock functions _could_ move out into a
separate conditionally compiled file, but it's probably not worth it as
there're so many common bits.
(*) fs/nfs/namespace.c
Some namespace-specific functions have been moved here.
(*) fs/nfs/nfs4namespace.c
NFS4-specific namespace functions (this could be merged into the previous
file). This file is conditionally compiled.
(*) fs/nfs/internal.h
Inter-file declarations, plus a few simple utility functions moved from
fs/nfs/inode.c.
Additionally, all the in-.c-file externs have been moved here, and those
files they were moved from now includes this file.
For the most part, the functions have not been changed, only some multiplexor
functions have changed significantly.
I've also:
(*) Added some extra banner comments above some functions.
(*) Rearranged the function order within the files to be more logical and
better grouped (IMO), though someone may prefer a different order.
(*) Reduced the number of #ifdefs in .c files.
(*) Added missing __init and __exit directives.
Signed-Off-By: David Howells <dhowells@redhat.com>
2006-06-09 13:34:33 +00:00
|
|
|
int __init nfs_init_readpagecache(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
nfs_rdata_cachep = kmem_cache_create("nfs_read_data",
|
2012-04-20 18:47:44 +00:00
|
|
|
sizeof(struct nfs_read_header),
|
2005-04-16 22:20:36 +00:00
|
|
|
0, SLAB_HWCACHE_ALIGN,
|
2007-07-20 01:11:58 +00:00
|
|
|
NULL);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (nfs_rdata_cachep == NULL)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-06-27 19:59:15 +00:00
|
|
|
void nfs_destroy_readpagecache(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2006-09-27 08:49:40 +00:00
|
|
|
kmem_cache_destroy(nfs_rdata_cachep);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|