From ad4ae1c732bc9159ffdeb225036c601dddbbbe75 Mon Sep 17 00:00:00 2001 From: "Matthew Wilcox (Oracle)" Date: Mon, 1 Jun 2020 21:46:18 -0700 Subject: mm: move readahead nr_pages check into read_pages Simplify the callers by moving the check for nr_pages and the BUG_ON into read_pages(). Signed-off-by: Matthew Wilcox (Oracle) Signed-off-by: Andrew Morton Reviewed-by: Zi Yan Reviewed-by: John Hubbard Reviewed-by: Christoph Hellwig Reviewed-by: William Kucharski Reviewed-by: Johannes Thumshirn Cc: Chao Yu Cc: Cong Wang Cc: Darrick J. Wong Cc: Dave Chinner Cc: Eric Biggers Cc: Gao Xiang Cc: Jaegeuk Kim Cc: Joseph Qi Cc: Junxiao Bi Cc: Michal Hocko Cc: Miklos Szeredi Link: http://lkml.kernel.org/r/20200414150233.24495-5-willy@infradead.org Signed-off-by: Linus Torvalds --- mm/readahead.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'mm/readahead.c') diff --git a/mm/readahead.c b/mm/readahead.c index 61b15b6b9e72..9fcd4e32b62d 100644 --- a/mm/readahead.c +++ b/mm/readahead.c @@ -119,6 +119,9 @@ static void read_pages(struct address_space *mapping, struct file *filp, struct blk_plug plug; unsigned page_idx; + if (!nr_pages) + return; + blk_start_plug(&plug); if (mapping->a_ops->readpages) { @@ -138,6 +141,8 @@ static void read_pages(struct address_space *mapping, struct file *filp, out: blk_finish_plug(&plug); + + BUG_ON(!list_empty(pages)); } /* @@ -180,8 +185,7 @@ void __do_page_cache_readahead(struct address_space *mapping, * contiguous pages before continuing with the next * batch. */ - if (nr_pages) - read_pages(mapping, filp, &page_pool, nr_pages, + read_pages(mapping, filp, &page_pool, nr_pages, gfp_mask); nr_pages = 0; continue; @@ -202,9 +206,7 @@ void __do_page_cache_readahead(struct address_space *mapping, * uptodate then the caller will launch readpage again, and * will then handle the error. */ - if (nr_pages) - read_pages(mapping, filp, &page_pool, nr_pages, gfp_mask); - BUG_ON(!list_empty(&page_pool)); + read_pages(mapping, filp, &page_pool, nr_pages, gfp_mask); } /* -- cgit v1.2.3-58-ga151