Skip to content

Commit

Permalink
mm: move readahead nr_pages check into read_pages
Browse files Browse the repository at this point in the history
Simplify the callers by moving the check for nr_pages and the BUG_ON
into read_pages().

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Zi Yan <ziy@nvidia.com>
Reviewed-by: John Hubbard <jhubbard@nvidia.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: William Kucharski <william.kucharski@oracle.com>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Cc: Chao Yu <yuchao0@huawei.com>
Cc: Cong Wang <xiyou.wangcong@gmail.com>
Cc: Darrick J. Wong <darrick.wong@oracle.com>
Cc: Dave Chinner <dchinner@redhat.com>
Cc: Eric Biggers <ebiggers@google.com>
Cc: Gao Xiang <gaoxiang25@huawei.com>
Cc: Jaegeuk Kim <jaegeuk@kernel.org>
Cc: Joseph Qi <joseph.qi@linux.alibaba.com>
Cc: Junxiao Bi <junxiao.bi@oracle.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Miklos Szeredi <mszeredi@redhat.com>
Link: http://lkml.kernel.org/r/20200414150233.24495-5-willy@infradead.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Matthew Wilcox (Oracle) authored and torvalds committed Jun 2, 2020
1 parent a1ef856 commit ad4ae1c
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions mm/readahead.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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));
}

/*
Expand Down Expand Up @@ -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;
Expand All @@ -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);
}

/*
Expand Down

0 comments on commit ad4ae1c

Please sign in to comment.