linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] Convert NFS from readpages to readahead
@ 2022-01-22 20:54 Matthew Wilcox (Oracle)
  2022-01-22 20:54 ` [PATCH 2/2] readahead: Remove read_cache_pages() Matthew Wilcox (Oracle)
  2022-01-31 14:39 ` [PATCH 1/2] Convert NFS from readpages to readahead Matthew Wilcox
  0 siblings, 2 replies; 7+ messages in thread
From: Matthew Wilcox (Oracle) @ 2022-01-22 20:54 UTC (permalink / raw)
  To: Trond Myklebust, Anna Schumaker, linux-nfs, linux-fsdevel,
	linux-kernel, David Howells
  Cc: Matthew Wilcox (Oracle)

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: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/nfs/file.c          |  2 +-
 fs/nfs/nfstrace.h      |  6 +++---
 fs/nfs/read.c          | 21 +++++++++++++--------
 include/linux/nfs_fs.h |  3 +--
 4 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/fs/nfs/file.c b/fs/nfs/file.c
index 76d76acbc594..4d681683d13c 100644
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -514,7 +514,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,
diff --git a/fs/nfs/nfstrace.h b/fs/nfs/nfstrace.h
index 317ce27bdc4b..4611aa3a21a4 100644
--- a/fs/nfs/nfstrace.h
+++ b/fs/nfs/nfstrace.h
@@ -889,11 +889,11 @@ TRACE_EVENT(nfs_aop_readpage_done,
 TRACE_EVENT(nfs_aop_readahead,
 		TP_PROTO(
 			const struct inode *inode,
-			struct page *page,
+			loff_t pos,
 			unsigned int nr_pages
 		),
 
-		TP_ARGS(inode, page, nr_pages),
+		TP_ARGS(inode, pos, nr_pages),
 
 		TP_STRUCT__entry(
 			__field(dev_t, dev)
@@ -911,7 +911,7 @@ TRACE_EVENT(nfs_aop_readahead,
 			__entry->fileid = nfsi->fileid;
 			__entry->fhandle = nfs_fhandle_hash(&nfsi->fh);
 			__entry->version = inode_peek_iversion_raw(inode);
-			__entry->offset = page_index(page) << PAGE_SHIFT;
+			__entry->offset = pos;
 			__entry->nr_pages = nr_pages;
 		),
 
diff --git a/fs/nfs/read.c b/fs/nfs/read.c
index eb00229c1a50..2472f962a9a2 100644
--- a/fs/nfs/read.c
+++ b/fs/nfs/read.c
@@ -290,9 +290,8 @@ static void nfs_readpage_result(struct rpc_task *task,
 }
 
 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;
 	unsigned int rsize = NFS_SERVER(inode)->rsize;
 	struct nfs_page *new;
@@ -397,14 +396,16 @@ int nfs_readpage(struct file *file, struct page *page)
 	return ret;
 }
 
-int nfs_readpages(struct file *file, struct address_space *mapping,
-		struct list_head *pages, unsigned nr_pages)
+void nfs_readahead(struct readahead_control *ractl)
 {
+	unsigned int nr_pages = readahead_count(ractl);
+	struct file *file = ractl->file;
 	struct nfs_readdesc desc;
-	struct inode *inode = mapping->host;
+	struct inode *inode = ractl->mapping->host;
+	struct page *page;
 	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);
 
 	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_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);
 
 	put_nfs_open_context(desc.ctx);
 out:
 	trace_nfs_aop_readahead_done(inode, nr_pages, ret);
-	return ret;
 }
 
 int __init nfs_init_readpagecache(void)
diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h
index 00835bacd236..e6ab516bc3d1 100644
--- a/include/linux/nfs_fs.h
+++ b/include/linux/nfs_fs.h
@@ -598,8 +598,7 @@ nfs_have_writebacks(struct inode *inode)
  * 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);
+void nfs_readahead(struct readahead_control *);
 
 /*
  * inline functions
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/2] readahead: Remove read_cache_pages()
  2022-01-22 20:54 [PATCH 1/2] Convert NFS from readpages to readahead Matthew Wilcox (Oracle)
@ 2022-01-22 20:54 ` Matthew Wilcox (Oracle)
  2022-01-31 14:39 ` [PATCH 1/2] Convert NFS from readpages to readahead Matthew Wilcox
  1 sibling, 0 replies; 7+ messages in thread
From: Matthew Wilcox (Oracle) @ 2022-01-22 20:54 UTC (permalink / raw)
  To: Trond Myklebust, Anna Schumaker, linux-nfs, linux-fsdevel,
	linux-kernel, David Howells
  Cc: Matthew Wilcox (Oracle)

With no remaining users, remove this function and the related
infrastructure.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 include/linux/pagemap.h |  2 --
 mm/readahead.c          | 76 -----------------------------------------
 2 files changed, 78 deletions(-)

diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index 270bf5136c34..34682f001344 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -632,8 +632,6 @@ struct page *read_cache_page(struct address_space *, pgoff_t index,
 		filler_t *filler, void *data);
 extern struct page * read_cache_page_gfp(struct address_space *mapping,
 				pgoff_t index, gfp_t gfp_mask);
-extern int read_cache_pages(struct address_space *mapping,
-		struct list_head *pages, filler_t *filler, void *data);
 
 static inline struct page *read_mapping_page(struct address_space *mapping,
 				pgoff_t index, void *data)
diff --git a/mm/readahead.c b/mm/readahead.c
index cf0dcf89eb69..7ba979bf8af3 100644
--- a/mm/readahead.c
+++ b/mm/readahead.c
@@ -37,82 +37,6 @@ file_ra_state_init(struct file_ra_state *ra, struct address_space *mapping)
 }
 EXPORT_SYMBOL_GPL(file_ra_state_init);
 
-/*
- * see if a page needs releasing upon read_cache_pages() failure
- * - the caller of read_cache_pages() may have set PG_private or PG_fscache
- *   before calling, such as the NFS fs marking pages that are cached locally
- *   on disk, thus we need to give the fs a chance to clean up in the event of
- *   an error
- */
-static void read_cache_pages_invalidate_page(struct address_space *mapping,
-					     struct page *page)
-{
-	if (page_has_private(page)) {
-		if (!trylock_page(page))
-			BUG();
-		page->mapping = mapping;
-		do_invalidatepage(page, 0, PAGE_SIZE);
-		page->mapping = NULL;
-		unlock_page(page);
-	}
-	put_page(page);
-}
-
-/*
- * release a list of pages, invalidating them first if need be
- */
-static void read_cache_pages_invalidate_pages(struct address_space *mapping,
-					      struct list_head *pages)
-{
-	struct page *victim;
-
-	while (!list_empty(pages)) {
-		victim = lru_to_page(pages);
-		list_del(&victim->lru);
-		read_cache_pages_invalidate_page(mapping, victim);
-	}
-}
-
-/**
- * read_cache_pages - populate an address space with some pages & start reads against them
- * @mapping: the address_space
- * @pages: The address of a list_head which contains the target pages.  These
- *   pages have their ->index populated and are otherwise uninitialised.
- * @filler: callback routine for filling a single page.
- * @data: private data for the callback routine.
- *
- * Hides the details of the LRU cache etc from the filesystems.
- *
- * Returns: %0 on success, error return by @filler otherwise
- */
-int read_cache_pages(struct address_space *mapping, struct list_head *pages,
-			int (*filler)(void *, struct page *), void *data)
-{
-	struct page *page;
-	int ret = 0;
-
-	while (!list_empty(pages)) {
-		page = lru_to_page(pages);
-		list_del(&page->lru);
-		if (add_to_page_cache_lru(page, mapping, page->index,
-				readahead_gfp_mask(mapping))) {
-			read_cache_pages_invalidate_page(mapping, page);
-			continue;
-		}
-		put_page(page);
-
-		ret = filler(data, page);
-		if (unlikely(ret)) {
-			read_cache_pages_invalidate_pages(mapping, pages);
-			break;
-		}
-		task_io_account_read(PAGE_SIZE);
-	}
-	return ret;
-}
-
-EXPORT_SYMBOL(read_cache_pages);
-
 static void read_pages(struct readahead_control *rac, struct list_head *pages,
 		bool skip_page)
 {
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] Convert NFS from readpages to readahead
  2022-01-22 20:54 [PATCH 1/2] Convert NFS from readpages to readahead Matthew Wilcox (Oracle)
  2022-01-22 20:54 ` [PATCH 2/2] readahead: Remove read_cache_pages() Matthew Wilcox (Oracle)
@ 2022-01-31 14:39 ` Matthew Wilcox
  2022-02-07 16:18   ` Matthew Wilcox
  1 sibling, 1 reply; 7+ messages in thread
From: Matthew Wilcox @ 2022-01-31 14:39 UTC (permalink / raw)
  To: Trond Myklebust, Anna Schumaker, linux-nfs, linux-fsdevel,
	linux-kernel, David Howells

On Sat, Jan 22, 2022 at 08:54:52PM +0000, Matthew Wilcox (Oracle) wrote:
> NFS is one of the last two users of the deprecated ->readpages aop.
> This conversion looks straightforward, but I have only compile-tested
> it.

These patches still apply to -rc2.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] Convert NFS from readpages to readahead
  2022-01-31 14:39 ` [PATCH 1/2] Convert NFS from readpages to readahead Matthew Wilcox
@ 2022-02-07 16:18   ` Matthew Wilcox
  2022-02-07 19:47     ` Trond Myklebust
  0 siblings, 1 reply; 7+ messages in thread
From: Matthew Wilcox @ 2022-02-07 16:18 UTC (permalink / raw)
  To: Trond Myklebust, Anna Schumaker, linux-nfs, linux-fsdevel,
	linux-kernel, David Howells

On Mon, Jan 31, 2022 at 02:39:17PM +0000, Matthew Wilcox wrote:
> On Sat, Jan 22, 2022 at 08:54:52PM +0000, Matthew Wilcox (Oracle) wrote:
> > NFS is one of the last two users of the deprecated ->readpages aop.
> > This conversion looks straightforward, but I have only compile-tested
> > it.
> 
> These patches still apply to -rc2.

And they still apply to rc3.

I'm just going to send them to Linus as part of the general fs-folio
work I'm doing during the next merge window.  If anybody would like to
test them, I'm happy to stick a Tested-by on them.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] Convert NFS from readpages to readahead
  2022-02-07 16:18   ` Matthew Wilcox
@ 2022-02-07 19:47     ` Trond Myklebust
  2022-02-25 23:22       ` Matthew Wilcox
  0 siblings, 1 reply; 7+ messages in thread
From: Trond Myklebust @ 2022-02-07 19:47 UTC (permalink / raw)
  To: linux-nfs, willy, anna.schumaker, linux-kernel, linux-fsdevel, dhowells

On Mon, 2022-02-07 at 16:18 +0000, Matthew Wilcox wrote:
> On Mon, Jan 31, 2022 at 02:39:17PM +0000, Matthew Wilcox wrote:
> > On Sat, Jan 22, 2022 at 08:54:52PM +0000, Matthew Wilcox (Oracle)
> > wrote:
> > > NFS is one of the last two users of the deprecated ->readpages
> > > aop.
> > > This conversion looks straightforward, but I have only compile-
> > > tested
> > > it.
> > 
> > These patches still apply to -rc2.
> 
> And they still apply to rc3.
> 
> I'm just going to send them to Linus as part of the general fs-folio
> work I'm doing during the next merge window.  If anybody would like
> to
> test them, I'm happy to stick a Tested-by on them.

Unless there is a strong external dependency, I'd prefer to send them
through the NFS tree, both for testing purposes, and in case we need to
make changes.

I already have them applied to my 'testing' branch, but I can't move
that into linux-next until Anna's pull request against -rc3 comes
through.

-- 
Trond Myklebust
Linux NFS client maintainer, Hammerspace
trond.myklebust@hammerspace.com



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] Convert NFS from readpages to readahead
  2022-02-07 19:47     ` Trond Myklebust
@ 2022-02-25 23:22       ` Matthew Wilcox
  2022-02-28  1:29         ` Trond Myklebust
  0 siblings, 1 reply; 7+ messages in thread
From: Matthew Wilcox @ 2022-02-25 23:22 UTC (permalink / raw)
  To: Trond Myklebust
  Cc: linux-nfs, anna.schumaker, linux-kernel, linux-fsdevel, dhowells

On Mon, Feb 07, 2022 at 07:47:08PM +0000, Trond Myklebust wrote:
> I already have them applied to my 'testing' branch, but I can't move
> that into linux-next until Anna's pull request against -rc3 comes
> through.

Hey Trond,

I'm not seeing any patches in linux-next to fs/nfs/ other than those
that have gone through Andrew Morton, Jens Axboe and Chuck Lever.
Has the linux-nfs tree dropped out of linux-next?


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] Convert NFS from readpages to readahead
  2022-02-25 23:22       ` Matthew Wilcox
@ 2022-02-28  1:29         ` Trond Myklebust
  0 siblings, 0 replies; 7+ messages in thread
From: Trond Myklebust @ 2022-02-28  1:29 UTC (permalink / raw)
  To: willy; +Cc: linux-nfs, linux-fsdevel, anna.schumaker, linux-kernel, dhowells

On Fri, 2022-02-25 at 23:22 +0000, Matthew Wilcox wrote:
> On Mon, Feb 07, 2022 at 07:47:08PM +0000, Trond Myklebust wrote:
> > I already have them applied to my 'testing' branch, but I can't
> > move
> > that into linux-next until Anna's pull request against -rc3 comes
> > through.
> 
> Hey Trond,
> 
> I'm not seeing any patches in linux-next to fs/nfs/ other than those
> that have gone through Andrew Morton, Jens Axboe and Chuck Lever.
> Has the linux-nfs tree dropped out of linux-next?
> 

Sorry about that. As I said, I was first waiting for Anna to merge the
remaining 5.17 fixes, then got distracted with other work.
Hopefully it should appear in Stephen's tree when he updates it.

Cheers
  Trond

-- 
Trond Myklebust
Linux NFS client maintainer, Hammerspace
trond.myklebust@hammerspace.com



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-02-28  1:30 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-22 20:54 [PATCH 1/2] Convert NFS from readpages to readahead Matthew Wilcox (Oracle)
2022-01-22 20:54 ` [PATCH 2/2] readahead: Remove read_cache_pages() Matthew Wilcox (Oracle)
2022-01-31 14:39 ` [PATCH 1/2] Convert NFS from readpages to readahead Matthew Wilcox
2022-02-07 16:18   ` Matthew Wilcox
2022-02-07 19:47     ` Trond Myklebust
2022-02-25 23:22       ` Matthew Wilcox
2022-02-28  1:29         ` Trond Myklebust

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).