From: Andrew Morton <akpm@zip.com.au>
To: Linus Torvalds <torvalds@transmeta.com>
Cc: lkml <linux-kernel@vger.kernel.org>
Subject: [patch 12/12] fix a race between set_page_dirty and truncate
Date: Fri, 09 Aug 2002 17:58:39 -0700 [thread overview]
Message-ID: <3D54653F.59964CA7@zip.com.au> (raw)
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);
}
.
reply other threads:[~2002-08-10 0:58 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3D54653F.59964CA7@zip.com.au \
--to=akpm@zip.com.au \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@transmeta.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox