Messages in this thread Patch in this message | | | From | Song Liu <> | Subject | [PATCH v10 2/7] filemap: check compound_head(page)->mapping in pagecache_get_page() | Date | Thu, 1 Aug 2019 11:42:39 -0700 |
| |
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.
Suggested-by: Johannes Weiner <hannes@cmpxchg.org> Signed-off-by: Song Liu <songliubraving@fb.com> --- mm/filemap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/filemap.c b/mm/filemap.c index d0bd9e585c2f..aaee1ef96f6d 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -1644,7 +1644,7 @@ struct page *pagecache_get_page(struct address_space *mapping, pgoff_t offset, } /* 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; -- 2.17.1
| |