Commit d028eab5 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] Fix SMP race in truncate

Closes a small race window: testing PageWriteback() outside the page
lock introduces the possibility that page could be redirtied and have
writeback started after we've inspected PageWriteback.
parent 49c7cfe7
...@@ -201,18 +201,18 @@ static int truncate_list_pages(struct address_space *mapping, ...@@ -201,18 +201,18 @@ static int truncate_list_pages(struct address_space *mapping,
int failed; int failed;
page_cache_get(page); page_cache_get(page);
if (PageWriteback(page)) { failed = TestSetPageLocked(page);
/* if (!failed && PageWriteback(page)) {
* urgggh. This function is utterly foul, unlock_page(page);
* and this addition doesn't help. Kill. list_del(head);
*/ list_add_tail(head, curr);
write_unlock(&mapping->page_lock); write_unlock(&mapping->page_lock);
wait_on_page_writeback(page); wait_on_page_writeback(page);
page_cache_release(page);
unlocked = 1; unlocked = 1;
write_lock(&mapping->page_lock); write_lock(&mapping->page_lock);
goto restart; goto restart;
} }
failed = TestSetPageLocked(page);
list_del(head); list_del(head);
if (!failed) if (!failed)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment