diff --git a/[refs] b/[refs] index 2b7fbe5e5148..c626dfabfc3e 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: f0bc0a60b13f209df16062f94e9fb4b90dc08708 +refs/heads/master: 9cbb4cb21b19fff46cf1174d0ed699ef710e641c diff --git a/trunk/mm/filemap.c b/trunk/mm/filemap.c index ca389394fa2a..1a3dd5914726 100644 --- a/trunk/mm/filemap.c +++ b/trunk/mm/filemap.c @@ -837,9 +837,6 @@ unsigned find_get_pages_contig(struct address_space *mapping, pgoff_t index, 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 @@ unsigned find_get_pages_contig(struct address_space *mapping, pgoff_t index, 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++;