From: Andrew Morton <akpm@zip.com.au>
To: Linus Torvalds <torvalds@transmeta.com>
Cc: lkml <linux-kernel@vger.kernel.org>
Subject: [patch 6/10] Fix SMP race in truncate
Date: Sun, 05 May 2002 13:56:47 -0700 [thread overview]
Message-ID: <3CD59C8F.A228F2E2@zip.com.au> (raw)
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.
=====================================
--- 2.5.13/mm/filemap.c~truncate-race Sun May 5 13:32:00 2002
+++ 2.5.13-akpm/mm/filemap.c Sun May 5 13:32:35 2002
@@ -201,18 +201,18 @@ static int truncate_list_pages(struct ad
int failed;
page_cache_get(page);
- if (PageWriteback(page)) {
- /*
- * urgggh. This function is utterly foul,
- * and this addition doesn't help. Kill.
- */
+ failed = TestSetPageLocked(page);
+ if (!failed && PageWriteback(page)) {
+ unlock_page(page);
+ list_del(head);
+ list_add_tail(head, curr);
write_unlock(&mapping->page_lock);
wait_on_page_writeback(page);
+ page_cache_release(page);
unlocked = 1;
write_lock(&mapping->page_lock);
goto restart;
}
- failed = TestSetPageLocked(page);
list_del(head);
if (!failed)
-
reply other threads:[~2002-05-05 20:57 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=3CD59C8F.A228F2E2@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.