NFS: Convert readpage to readahead and use netfs_readahead for fscache
Subsystems (2)
PATCH 11/13 NFS: Convert readpage to readahead and use netfs_readahead for fscache
The new FS-Cache API does not have a readpages equivalent function, and instead of fscache_read_or_alloc_pages() it implements a readahead function, netfs_readahead(). Call netfs_readahead() if fscache is enabled, and if not, utilize readahead_page() to run through the pages needed calling readpage_async_filler().
Signed-off-by Dave Wysochanski <[email protected]>
--- fs/nfs/file.c | 2 +- fs/nfs/fscache.c | 49 ++++++++-------------------------------------- fs/nfs/fscache.h | 25 +++++++++-------------- fs/nfs/read.c | 32 +++++++++++++++--------------- include/linux/nfs_fs.h | 3 +-- include/linux/nfs_iostat.h | 2 +- 6 files changed, 36 insertions(+), 77 deletions(-)
fs/nfs/file.c +1 -1
@@ -519,7 +519,7 @@ static void nfs_swap_deactivate(struct file *file)const struct address_space_operations nfs_file_aops = { .readpage = nfs_readpage, - .readpages = nfs_readpages, + .readahead = nfs_readahead, .set_page_dirty = __set_page_dirty_nobuffers, .writepage = nfs_writepage, .writepages = nfs_writepages,
fs/nfs/fscache.c +8 -41
59 lines not on this page · raw message
fs/nfs/fscache.h +9 -16
@@ -94,11 +94,11 @@ struct nfs_fscache_inode_auxdata {extern int __nfs_readpage_from_fscache (struct file *filp,struct page *page,struct nfs_readdesc *desc); -extern int __nfs_readpages_from_fscache (struct nfs_open_context *, -struct inode *,struct address_space *, -struct list_head *,unsigned *); +extern int __nfs_readahead_from_fscache (struct nfs_readdesc *desc, +struct readahead_control *rac);extern void __nfs_read_completion_to_fscache (struct nfs_pgio_header *hdr,unsigned long bytes); +/* * Retrieve a page from an inode data storage object. */
@@ -114,15 +114,11 @@ static inline int nfs_readpage_from_fscache(struct file *filp,/* * Retrieve a set of pages from an inode data storage object. */ -static inline int nfs_readpages_from_fscache (struct nfs_open_context *ctx, -struct inode *inode, -struct address_space *mapping, -struct list_head *pages, -unsigned *nr_pages) +static inline int nfs_readahead_from_fscache (struct nfs_readdesc *desc, +struct readahead_control *rac) { -if (NFS_I (inode)->fscache) -return __nfs_readpages_from_fscache (ctx, inode, mapping, pages, - nr_pages); +if (NFS_I (rac->mapping->host)->fscache) +return __nfs_readahead_from_fscache (desc, rac);return -ENOBUFS ; }
@@ -195,11 +191,8 @@ static inline int nfs_readpage_from_fscache(struct file *filp, {return -ENOBUFS ; } -static inline int nfs_readpages_from_fscache (struct nfs_open_context *ctx, -struct inode *inode, -struct address_space *mapping, -struct list_head *pages, -unsigned *nr_pages) +static inline int nfs_readahead_from_fscache (struct nfs_readdesc *desc, +struct readahead_control *rac) {return -ENOBUFS ; }
fs/nfs/read.c +16 -16
@@ -390,50 +390,50 @@ int nfs_readpage(struct file *filp, struct page *page)return ret; } -int nfs_readpages (struct file *filp,struct address_space *mapping, -struct list_head *pages,unsigned nr_pages) +void nfs_readahead (struct readahead_control *rac) {struct nfs_readdesc desc; -struct inode *inode = mapping->host; +struct inode *inode = rac->mapping->host; +struct page *page;int ret; -dprintk ("NFS: nfs_readpages (%s/%Lu %d)\n" , - inode->i_sb->s_id, - (unsigned long long )NFS_FILEID (inode), - nr_pages); +dprintk ("NFS: %s (%s/%llu %lld)\n" , __func__, + inode->i_sb->s_id, + (unsigned long long )NFS_FILEID (inode), +readahead_length (rac));nfs_inc_stats (inode,NFSIOS_VFSREADPAGES ); ret = -ESTALE ;if (NFS_STALE (inode)) - goto out; +return ; -if (filp ==NULL ) { +if (rac->file ==NULL ) { ret = -EBADF ; desc.ctx =nfs_find_open_context (inode,NULL ,FMODE_READ );if (desc.ctx ==NULL ) - goto out; +return ; }else - desc.ctx =get_nfs_open_context (nfs_file_open_context (filp)); + desc.ctx =get_nfs_open_context (nfs_file_open_context (rac->file));/* 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); + ret =nfs_readahead_from_fscache (&desc, rac);if (ret ==0 ) goto read_complete;/* all pages were read */ nfs_pageio_init_read (&desc.pgio, inode, false, &nfs_async_read_completion_ops); - ret =read_cache_pages (mapping, pages, readpage_async_filler, &desc); +while ((page =readahead_page (rac))) { + ret =readpage_async_filler (&desc, page); +put_page (page); + }nfs_pageio_complete_read (&desc.pgio, inode); read_complete:put_nfs_open_context (desc.ctx); -out: -return ret; }int __init nfs_init_readpagecache (void )
include/linux/nfs_fs.h +1 -2
@@ -563,8 +563,7 @@ extern int nfs_access_get_cached(struct inode *inode, const struct cred *cred, s* linux/fs/nfs/read.c */ extern int nfs_readpage (struct file *,struct page *); -extern int nfs_readpages (struct file *,struct address_space *, -struct list_head *,unsigned ); +extern void nfs_readahead (struct readahead_control *rac);/* * inline functions
include/linux/nfs_iostat.h +1 -1
@@ -53,7 +53,7 @@* NFS page counters * * These count the number of pages read or written via nfs_readpage(), -* nfs_readpages(), or their write equivalents. +* nfs_readahead(), or their write equivalents. * * NB: When adding new byte counters, please include the measured * units in the name of each byte counter to help users of this
Signature · 1 line
1.8.3.1