The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@zip.com.au>
To: Linus Torvalds <torvalds@transmeta.com>
Cc: lkml <linux-kernel@vger.kernel.org>
Subject: [patch 20/27] fix a writeback race
Date: Thu, 04 Jul 2002 16:54:57 -0700	[thread overview]
Message-ID: <3D24E051.A222D615@zip.com.au> (raw)



Fixes a bug in generic_writepages() and its cut-n-paste-cousin,
mpage_writepages().

The code was clearing PageDirty and then baling out if it discovered
the page was nder writeback.  Which would cause the dirty bit to be
lost.

It's a very small window, but reversing the order so PageDirty is only
cleared when we know for-sure that IO will be started fixes it up.



 fs/mpage.c          |    4 ++--
 mm/page-writeback.c |    4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

--- 2.5.24/fs/mpage.c~writeback-dirty-fix	Thu Jul  4 16:17:30 2002
+++ 2.5.24-akpm/fs/mpage.c	Thu Jul  4 16:22:05 2002
@@ -515,8 +515,8 @@ mpage_writepages(struct address_space *m
 
 		lock_page(page);
 
-		if (page->mapping && TestClearPageDirty(page) &&
-					!PageWriteback(page)) {
+		if (page->mapping && !PageWriteback(page) &&
+					TestClearPageDirty(page)) {
 			/* FIXME: batch this up */
 			if (!PageActive(page) && PageLRU(page)) {
 				spin_lock(&pagemap_lru_lock);
--- 2.5.24/mm/page-writeback.c~writeback-dirty-fix	Thu Jul  4 16:17:30 2002
+++ 2.5.24-akpm/mm/page-writeback.c	Thu Jul  4 16:22:05 2002
@@ -383,8 +383,8 @@ int generic_writepages(struct address_sp
 		lock_page(page);
 
 		/* It may have been removed from swapcache: check ->mapping */
-		if (page->mapping && TestClearPageDirty(page) &&
-					!PageWriteback(page)) {
+		if (page->mapping && !PageWriteback(page) &&
+					TestClearPageDirty(page)) {
 			/* FIXME: batch this up */
 			if (!PageActive(page) && PageLRU(page)) {
 				spin_lock(&pagemap_lru_lock);

-

                 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=3D24E051.A222D615@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