From f445023f07be23198983215ef5954fed6e9e05eb Mon Sep 17 00:00:00 2001 From: Nick Piggin Date: Thu, 13 Jan 2011 15:45:51 -0800 Subject: [PATCH] --- yaml --- r: 230706 b: refs/heads/master c: 9cbb4cb21b19fff46cf1174d0ed699ef710e641c h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/mm/filemap.c | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) 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++;