* [patch 12/12] fix a race between set_page_dirty and truncate
@ 2002-08-10 0:58 Andrew Morton
0 siblings, 0 replies; only message in thread
From: Andrew Morton @ 2002-08-10 0:58 UTC (permalink / raw)
To: Linus Torvalds; +Cc: lkml
Fix a race between set_page_dirty() and truncate.
The page could have been removed from the mapping while this CPU is
spinning on the lock. __free_pages_ok() will go BUG.
This has not been observed in practice - most callers of
set_page_dirty() hold the page lock which gives exclusion from
truncate. But zap_pte_range() does not.
A fix for this has been sent to Marcelo also.
page-writeback.c | 12 ++++++++----
1 files changed, 8 insertions, 4 deletions
--- 2.5.30/mm/page-writeback.c~set_page_dirty-race Fri Aug 9 17:36:48 2002
+++ 2.5.30-akpm/mm/page-writeback.c Fri Aug 9 17:36:48 2002
@@ -477,8 +477,10 @@ int __set_page_dirty_buffers(struct page
if (!TestSetPageDirty(page)) {
write_lock(&mapping->page_lock);
- list_del(&page->list);
- list_add(&page->list, &mapping->dirty_pages);
+ if (page->mapping) { /* Race with truncate? */
+ list_del(&page->list);
+ list_add(&page->list, &mapping->dirty_pages);
+ }
write_unlock(&mapping->page_lock);
__mark_inode_dirty(mapping->host, I_DIRTY_PAGES);
}
@@ -511,8 +513,10 @@ int __set_page_dirty_nobuffers(struct pa
if (mapping) {
write_lock(&mapping->page_lock);
- list_del(&page->list);
- list_add(&page->list, &mapping->dirty_pages);
+ if (page->mapping) { /* Race with truncate? */
+ list_del(&page->list);
+ list_add(&page->list, &mapping->dirty_pages);
+ }
write_unlock(&mapping->page_lock);
__mark_inode_dirty(mapping->host, I_DIRTY_PAGES);
}
.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2002-08-10 0:58 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-08-10 0:58 [patch 12/12] fix a race between set_page_dirty and truncate Andrew Morton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox