Skip to content

Commit

Permalink
afs: Fix afs_kill_pages()
Browse files Browse the repository at this point in the history
[ Upstream commit 7286a35 ]

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 <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
dhowells authored and gregkh committed Dec 20, 2017
1 parent 80f74ce commit 5e469e4
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions fs/afs/write.c
Original file line number Diff line number Diff line change
Expand Up @@ -299,10 +299,14 @@ static void afs_kill_pages(struct afs_vnode *vnode, bool error,
ASSERTCMP(pv.nr, ==, count);

for (loop = 0; loop < count; loop++) {
ClearPageUptodate(pv.pages[loop]);
struct page *page = pv.pages[loop];
ClearPageUptodate(page);
if (error)
SetPageError(pv.pages[loop]);
end_page_writeback(pv.pages[loop]);
SetPageError(page);
if (PageWriteback(page))
end_page_writeback(page);
if (page->index >= first)
first = page->index + 1;
}

__pagevec_release(&pv);
Expand Down

0 comments on commit 5e469e4

Please sign in to comment.