Re: [RFC PATCH 3/6] mm: Push readahead_control down into force_page_cache_readahead() [ver #2]

From: Matthew Wilcox
Date: Wed Sep 02 2020 - 11:54:41 EST


On Wed, Sep 02, 2020 at 04:44:38PM +0100, David Howells wrote:
> +++ b/mm/fadvise.c
> @@ -104,7 +104,10 @@ int generic_fadvise(struct file *file, loff_t offset, loff_t len, int advice)
> if (!nrpages)
> nrpages = ~0UL;
>
> - force_page_cache_readahead(mapping, file, start_index, nrpages);
> + {
> + DEFINE_READAHEAD(rac, file, mapping, start_index);
> + force_page_cache_readahead(&rac, nrpages);
> + }
> break;

This is kind of awkward. How about this:

static void force_page_cache_readahead(struct address_space *mapping,
struct file *file, pgoff_t index, unsigned long nr_to_read)
{
DEFINE_READAHEAD(rac, file, mapping, index);
force_page_cache_ra(&rac, nr_to_read);
}

in mm/internal.h for now (and it can migrate if it needs to be somewhere else)