mirror of
https://github.com/torvalds/linux.git
synced 2026-11-26 16:33:17 +00:00
mm: find_get_pages_contig fixlet
Testing ->mapping and ->index without a ref is not stable as the page may have been reused at this point. Signed-off-by: Nick Piggin <[email protected]> Reviewed-by: Wu Fengguang <[email protected]> Reviewed-by: Minchan Kim <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
committed by
Linus Torvalds
parent
f0bc0a60b1
commit
9cbb4cb21b
+10
-3
@@ -837,9 +837,6 @@ repeat:
|
||||
if (radix_tree_deref_retry(page))
|
||||
goto restart;
|
||||
|
||||
if (page->mapping == NULL || page->index != index)
|
||||
break;
|
||||
|
||||
if (!page_cache_get_speculative(page))
|
||||
goto repeat;
|
||||
|
||||
@@ -849,6 +846,16 @@ repeat:
|
||||
goto repeat;
|
||||
}
|
||||
|
||||
/*
|
||||
* must check mapping and index after taking the ref.
|
||||
* otherwise we can get both false positives and false
|
||||
* negatives, which is just confusing to the caller.
|
||||
*/
|
||||
if (page->mapping == NULL || page->index != index) {
|
||||
page_cache_release(page);
|
||||
break;
|
||||
}
|
||||
|
||||
pages[ret] = page;
|
||||
ret++;
|
||||
index++;
|
||||
|
||||
Reference in New Issue
Block a user