aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2017-03-16 12:27:48 -0400
committerDavid Howells <dhowells@redhat.com>2017-03-16 12:29:30 -0400
commit7286a35e893176169b09715096a4aca557e2ccd2 (patch)
treee49fd2d302b2d8b460219293b0bdb474ffd1ba52
parent6d06b0d25209c80e99c1e89700f1e09694a3766b (diff)
afs: Fix afs_kill_pages()
Fix afs_kill_pages() in two ways: (1) If a writeback has been partially flushed, then if we try and kill the pages it contains, some of them may no longer be undergoing writeback and end_page_writeback() will assert. Fix this by checking to see whether the page in question is actually undergoing writeback before ending that writeback. (2) The loop that scans for pages to kill doesn't increase the first page index, and so the loop may not terminate, but it will try to process the same pages over and over again. Fix this by increasing the first page index to one after the last page we processed. Signed-off-by: David Howells <dhowells@redhat.com>
-rw-r--r--fs/afs/write.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/fs/afs/write.c b/fs/afs/write.c
index 6e13e96c3db0..134de0667898 100644
--- a/fs/afs/write.c
+++ b/fs/afs/write.c
@@ -321,10 +321,14 @@ static void afs_kill_pages(struct afs_vnode *vnode, bool error,
321 ASSERTCMP(pv.nr, ==, count); 321 ASSERTCMP(pv.nr, ==, count);
322 322
323 for (loop = 0; loop < count; loop++) { 323 for (loop = 0; loop < count; loop++) {
324 ClearPageUptodate(pv.pages[loop]); 324 struct page *page = pv.pages[loop];
325 ClearPageUptodate(page);
325 if (error) 326 if (error)
326 SetPageError(pv.pages[loop]); 327 SetPageError(page);
327 end_page_writeback(pv.pages[loop]); 328 if (PageWriteback(page))
329 end_page_writeback(page);
330 if (page->index >= first)
331 first = page->index + 1;
328 } 332 }
329 333
330 __pagevec_release(&pv); 334 __pagevec_release(&pv);