From: Andrew Morton <akpm@zip.com.au>
To: Linus Torvalds <torvalds@transmeta.com>
Cc: lkml <linux-kernel@vger.kernel.org>
Subject: [patch 24/27] fix invalidate_inode_pages2() race
Date: Thu, 04 Jul 2002 16:55:19 -0700 [thread overview]
Message-ID: <3D24E067.37C94B91@zip.com.au> (raw)
Fix a buglet in invalidate_list_pages2(): there is a small window in
which writeback could start against the page before this function locks
it.
The patch closes the race by performing the PageWriteback test inside
PageLocked.
Testing PageWriteback inside PageLocked is "definitive" - when a page
is locked, writeback cannot start against it.
filemap.c | 16 +++++++++-------
1 files changed, 9 insertions(+), 7 deletions(-)
--- 2.5.24/mm/filemap.c~invalidate-race Thu Jul 4 16:17:32 2002
+++ 2.5.24-akpm/mm/filemap.c Thu Jul 4 16:17:32 2002
@@ -367,16 +367,18 @@ static int invalidate_list_pages2(struct
while (curr != head) {
page = list_entry(curr, struct page, list);
- if (PageWriteback(page)) {
- write_unlock(&mapping->page_lock);
- wait_on_page_writeback(page);
- unlocked = 1;
- write_lock(&mapping->page_lock);
- goto restart;
- }
if (!TestSetPageLocked(page)) {
int __unlocked;
+ if (PageWriteback(page)) {
+ write_unlock(&mapping->page_lock);
+ wait_on_page_writeback(page);
+ unlocked = 1;
+ write_lock(&mapping->page_lock);
+ unlock_page(page);
+ goto restart;
+ }
+
__unlocked = invalidate_this_page2(mapping, page, curr, head);
unlock_page(page);
unlocked |= __unlocked;
-
reply other threads:[~2002-07-04 23:50 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=3D24E067.37C94B91@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