From d3604d3795872e788fb3fe32bcd072bff53c169c Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 23 Jun 2006 02:05:48 -0700 Subject: [PATCH] --- yaml --- r: 29068 b: refs/heads/master c: e0f23603fb2607315ce52432cc4225df410828cf h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/mm/truncate.c | 22 ++++++++++++++++------ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/[refs] b/[refs] index 353f0026f7e3..4595db64fe0c 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 57ae2508610d50893cb3e3bbb869ff70ff724a2a +refs/heads/master: e0f23603fb2607315ce52432cc4225df410828cf diff --git a/trunk/mm/truncate.c b/trunk/mm/truncate.c index 6cb3fff25f67..cf1b015df4a7 100644 --- a/trunk/mm/truncate.c +++ b/trunk/mm/truncate.c @@ -230,14 +230,24 @@ unsigned long invalidate_mapping_pages(struct address_space *mapping, pagevec_lookup(&pvec, mapping, next, PAGEVEC_SIZE)) { for (i = 0; i < pagevec_count(&pvec); i++) { struct page *page = pvec.pages[i]; + pgoff_t index; + int lock_failed; - if (TestSetPageLocked(page)) { - next++; - continue; - } - if (page->index > next) - next = page->index; + lock_failed = TestSetPageLocked(page); + + /* + * We really shouldn't be looking at the ->index of an + * unlocked page. But we're not allowed to lock these + * pages. So we rely upon nobody altering the ->index + * of this (pinned-by-us) page. + */ + index = page->index; + if (index > next) + next = index; next++; + if (lock_failed) + continue; + if (PageDirty(page) || PageWriteback(page)) goto unlock; if (page_mapped(page))