Skip to content

Commit b522c94

Browse files
walken-googletorvalds
authored andcommitted
mm: filemap_fault: unique path for locking page
Introduce a single location where filemap_fault() locks the desired page. There used to be two such places, depending if the initial find_get_page() was successful or not. Signed-off-by: Michel Lespinasse <walken@google.com> Acked-by: Rik van Riel <riel@redhat.com> Acked-by: Linus Torvalds <torvalds@linux-foundation.org> Cc: Nick Piggin <nickpiggin@yahoo.com.au> Reviewed-by: Wu Fengguang <fengguang.wu@intel.com> Cc: Ying Han <yinghan@google.com> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Ingo Molnar <mingo@elte.hu> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: <linux-arch@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 182fea8 commit b522c94

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

‎mm/filemap.c‎

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1539,25 +1539,27 @@ int filemap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
15391539
* waiting for the lock.
15401540
*/
15411541
do_async_mmap_readahead(vma, ra, file, page, offset);
1542-
lock_page(page);
1543-
1544-
/* Did it get truncated? */
1545-
if (unlikely(page->mapping != mapping)) {
1546-
unlock_page(page);
1547-
put_page(page);
1548-
goto no_cached_page;
1549-
}
15501542
} else {
15511543
/* No page in the page cache at all */
15521544
do_sync_mmap_readahead(vma, ra, file, offset);
15531545
count_vm_event(PGMAJFAULT);
15541546
ret = VM_FAULT_MAJOR;
15551547
retry_find:
1556-
page = find_lock_page(mapping, offset);
1548+
page = find_get_page(mapping, offset);
15571549
if (!page)
15581550
goto no_cached_page;
15591551
}
15601552

1553+
lock_page(page);
1554+
1555+
/* Did it get truncated? */
1556+
if (unlikely(page->mapping != mapping)) {
1557+
unlock_page(page);
1558+
put_page(page);
1559+
goto retry_find;
1560+
}
1561+
VM_BUG_ON(page->index != offset);
1562+
15611563
/*
15621564
* We have a locked page in the page cache, now we need to check
15631565
* that it's up-to-date. If not, it is going to be due to an error.

0 commit comments

Comments
 (0)