Commit 8786fde8 authored by Matthew Wilcox (Oracle)'s avatar Matthew Wilcox (Oracle) Committed by Trond Myklebust
Browse files

Convert NFS from readpages to readahead



NFS is one of the last two users of the deprecated ->readpages aop.
This conversion looks straightforward, but I have only compile-tested
it.

Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
parent 98c27f27
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -514,7 +514,7 @@ static void nfs_swap_deactivate(struct file *file)


const struct address_space_operations nfs_file_aops = {
const struct address_space_operations nfs_file_aops = {
	.readpage = nfs_readpage,
	.readpage = nfs_readpage,
	.readpages = nfs_readpages,
	.readahead = nfs_readahead,
	.set_page_dirty = __set_page_dirty_nobuffers,
	.set_page_dirty = __set_page_dirty_nobuffers,
	.writepage = nfs_writepage,
	.writepage = nfs_writepage,
	.writepages = nfs_writepages,
	.writepages = nfs_writepages,
+3 −3
Original line number Original line Diff line number Diff line
@@ -889,11 +889,11 @@ TRACE_EVENT(nfs_aop_readpage_done,
TRACE_EVENT(nfs_aop_readahead,
TRACE_EVENT(nfs_aop_readahead,
		TP_PROTO(
		TP_PROTO(
			const struct inode *inode,
			const struct inode *inode,
			struct page *page,
			loff_t pos,
			unsigned int nr_pages
			unsigned int nr_pages
		),
		),


		TP_ARGS(inode, page, nr_pages),
		TP_ARGS(inode, pos, nr_pages),


		TP_STRUCT__entry(
		TP_STRUCT__entry(
			__field(dev_t, dev)
			__field(dev_t, dev)
@@ -911,7 +911,7 @@ TRACE_EVENT(nfs_aop_readahead,
			__entry->fileid = nfsi->fileid;
			__entry->fileid = nfsi->fileid;
			__entry->fhandle = nfs_fhandle_hash(&nfsi->fh);
			__entry->fhandle = nfs_fhandle_hash(&nfsi->fh);
			__entry->version = inode_peek_iversion_raw(inode);
			__entry->version = inode_peek_iversion_raw(inode);
			__entry->offset = page_index(page) << PAGE_SHIFT;
			__entry->offset = pos;
			__entry->nr_pages = nr_pages;
			__entry->nr_pages = nr_pages;
		),
		),


+13 −8
Original line number Original line Diff line number Diff line
@@ -290,9 +290,8 @@ static void nfs_readpage_result(struct rpc_task *task,
}
}


static int
static int
readpage_async_filler(void *data, struct page *page)
readpage_async_filler(struct nfs_readdesc *desc, struct page *page)
{
{
	struct nfs_readdesc *desc = data;
	struct inode *inode = page_file_mapping(page)->host;
	struct inode *inode = page_file_mapping(page)->host;
	unsigned int rsize = NFS_SERVER(inode)->rsize;
	unsigned int rsize = NFS_SERVER(inode)->rsize;
	struct nfs_page *new;
	struct nfs_page *new;
@@ -397,14 +396,16 @@ int nfs_readpage(struct file *file, struct page *page)
	return ret;
	return ret;
}
}


int nfs_readpages(struct file *file, struct address_space *mapping,
void nfs_readahead(struct readahead_control *ractl)
		struct list_head *pages, unsigned nr_pages)
{
{
	unsigned int nr_pages = readahead_count(ractl);
	struct file *file = ractl->file;
	struct nfs_readdesc desc;
	struct nfs_readdesc desc;
	struct inode *inode = mapping->host;
	struct inode *inode = ractl->mapping->host;
	struct page *page;
	int ret;
	int ret;


	trace_nfs_aop_readahead(inode, lru_to_page(pages), nr_pages);
	trace_nfs_aop_readahead(inode, readahead_pos(ractl), nr_pages);
	nfs_inc_stats(inode, NFSIOS_VFSREADPAGES);
	nfs_inc_stats(inode, NFSIOS_VFSREADPAGES);


	ret = -ESTALE;
	ret = -ESTALE;
@@ -422,14 +423,18 @@ int nfs_readpages(struct file *file, struct address_space *mapping,
	nfs_pageio_init_read(&desc.pgio, inode, false,
	nfs_pageio_init_read(&desc.pgio, inode, false,
			     &nfs_async_read_completion_ops);
			     &nfs_async_read_completion_ops);


	ret = read_cache_pages(mapping, pages, readpage_async_filler, &desc);
	while ((page = readahead_page(ractl)) != NULL) {
		ret = readpage_async_filler(&desc, page);
		put_page(page);
		if (ret)
			break;
	}


	nfs_pageio_complete_read(&desc.pgio);
	nfs_pageio_complete_read(&desc.pgio);


	put_nfs_open_context(desc.ctx);
	put_nfs_open_context(desc.ctx);
out:
out:
	trace_nfs_aop_readahead_done(inode, nr_pages, ret);
	trace_nfs_aop_readahead_done(inode, nr_pages, ret);
	return ret;
}
}


int __init nfs_init_readpagecache(void)
int __init nfs_init_readpagecache(void)
+1 −2
Original line number Original line Diff line number Diff line
@@ -601,8 +601,7 @@ nfs_have_writebacks(struct inode *inode)
 * linux/fs/nfs/read.c
 * linux/fs/nfs/read.c
 */
 */
extern int  nfs_readpage(struct file *, struct page *);
extern int  nfs_readpage(struct file *, struct page *);
extern int  nfs_readpages(struct file *, struct address_space *,
void nfs_readahead(struct readahead_control *);
		struct list_head *, unsigned);


/*
/*
 * inline functions
 * inline functions