Commit 2a1180f1 authored by Josef Bacik's avatar Josef Bacik Committed by Linus Torvalds

filemap: pass vm_fault to the mmap ra helpers

All of the arguments to these functions come from the vmf.

Cut down on the amount of arguments passed by simply passing in the vmf
to these two helpers.

Link: http://lkml.kernel.org/r/20181211173801.29535-3-josef@toxicpanda.comSigned-off-by: default avatarJosef Bacik <josef@toxicpanda.com>
Reviewed-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Reviewed-by: default avatarJan Kara <jack@suse.cz>
Cc: Dave Chinner <david@fromorbit.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Rik van Riel <riel@redhat.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: "Kirill A. Shutemov" <kirill@shutemov.name>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent ebc551f2
...@@ -2420,20 +2420,20 @@ static int page_cache_read(struct file *file, pgoff_t offset, gfp_t gfp_mask) ...@@ -2420,20 +2420,20 @@ static int page_cache_read(struct file *file, pgoff_t offset, gfp_t gfp_mask)
* Synchronous readahead happens when we don't even find * Synchronous readahead happens when we don't even find
* a page in the page cache at all. * a page in the page cache at all.
*/ */
static void do_sync_mmap_readahead(struct vm_area_struct *vma, static void do_sync_mmap_readahead(struct vm_fault *vmf)
struct file_ra_state *ra,
struct file *file,
pgoff_t offset)
{ {
struct file *file = vmf->vma->vm_file;
struct file_ra_state *ra = &file->f_ra;
struct address_space *mapping = file->f_mapping; struct address_space *mapping = file->f_mapping;
pgoff_t offset = vmf->pgoff;
/* If we don't want any read-ahead, don't bother */ /* If we don't want any read-ahead, don't bother */
if (vma->vm_flags & VM_RAND_READ) if (vmf->vma->vm_flags & VM_RAND_READ)
return; return;
if (!ra->ra_pages) if (!ra->ra_pages)
return; return;
if (vma->vm_flags & VM_SEQ_READ) { if (vmf->vma->vm_flags & VM_SEQ_READ) {
page_cache_sync_readahead(mapping, ra, file, offset, page_cache_sync_readahead(mapping, ra, file, offset,
ra->ra_pages); ra->ra_pages);
return; return;
...@@ -2463,16 +2463,16 @@ static void do_sync_mmap_readahead(struct vm_area_struct *vma, ...@@ -2463,16 +2463,16 @@ static void do_sync_mmap_readahead(struct vm_area_struct *vma,
* Asynchronous readahead happens when we find the page and PG_readahead, * Asynchronous readahead happens when we find the page and PG_readahead,
* so we want to possibly extend the readahead further.. * so we want to possibly extend the readahead further..
*/ */
static void do_async_mmap_readahead(struct vm_area_struct *vma, static void do_async_mmap_readahead(struct vm_fault *vmf,
struct file_ra_state *ra, struct page *page)
struct file *file,
struct page *page,
pgoff_t offset)
{ {
struct file *file = vmf->vma->vm_file;
struct file_ra_state *ra = &file->f_ra;
struct address_space *mapping = file->f_mapping; struct address_space *mapping = file->f_mapping;
pgoff_t offset = vmf->pgoff;
/* If we don't want any read-ahead, don't bother */ /* If we don't want any read-ahead, don't bother */
if (vma->vm_flags & VM_RAND_READ) if (vmf->vma->vm_flags & VM_RAND_READ)
return; return;
if (ra->mmap_miss > 0) if (ra->mmap_miss > 0)
ra->mmap_miss--; ra->mmap_miss--;
...@@ -2531,10 +2531,10 @@ vm_fault_t filemap_fault(struct vm_fault *vmf) ...@@ -2531,10 +2531,10 @@ vm_fault_t filemap_fault(struct vm_fault *vmf)
* We found the page, so try async readahead before * We found the page, so try async readahead before
* waiting for the lock. * waiting for the lock.
*/ */
do_async_mmap_readahead(vmf->vma, ra, file, page, offset); do_async_mmap_readahead(vmf, page);
} else if (!page) { } else if (!page) {
/* No page in the page cache at all */ /* No page in the page cache at all */
do_sync_mmap_readahead(vmf->vma, ra, file, offset); do_sync_mmap_readahead(vmf);
count_vm_event(PGMAJFAULT); count_vm_event(PGMAJFAULT);
count_memcg_event_mm(vmf->vma->vm_mm, PGMAJFAULT); count_memcg_event_mm(vmf->vma->vm_mm, PGMAJFAULT);
ret = VM_FAULT_MAJOR; ret = VM_FAULT_MAJOR;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment