From: Song Liu Date: Mon, 23 Sep 2019 22:37:47 +0000 (-0700) Subject: filemap: check compound_head(page)->mapping in pagecache_get_page() X-Git-Tag: v5.15~5430^2~37 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=31895438e702f48e25b7aa6d88f9c97c795c79c7;p=platform%2Fkernel%2Flinux-starfive.git filemap: check compound_head(page)->mapping in pagecache_get_page() Similar to previous patch, pagecache_get_page() avoids race condition with truncate by checking page->mapping == mapping. This does not work for compound pages. This patch let it check compound_head(page)->mapping instead. Link: http://lkml.kernel.org/r/20190801184244.3169074-3-songliubraving@fb.com Signed-off-by: Song Liu Suggested-by: Johannes Weiner Acked-by: Johannes Weiner Cc: Hillf Danton Cc: Hugh Dickins Cc: Kirill A. Shutemov Cc: Rik van Riel Cc: William Kucharski Cc: Oleg Nesterov Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/mm/filemap.c b/mm/filemap.c index fc7818b..0b30110 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -1647,7 +1647,7 @@ repeat: } /* Has the page been truncated? */ - if (unlikely(page->mapping != mapping)) { + if (unlikely(compound_head(page)->mapping != mapping)) { unlock_page(page); put_page(page); goto repeat;