[PATCH] ext4 Fix setting random pages PageUptodate

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Markus Trippelsdorf
Date: Tuesday, November 16, 2010 - 4:13 am

On 2010.11.15 at 13:23 -0800, Hugh Dickins wrote:

ext4_end_bio calls put_page and kmem_cache_free before calling
SetPageUpdate(). This can result in setting the PageUptodate bit on
random pages and causes the following BUG:

 BUG: Bad page state in process rm  pfn:52e54
 page:ffffea0001222260 count:0 mapcount:0 mapping:          (null) index:0x0
 arch kernel: page flags: 0x4000000000000008(uptodate)

Fix the problem by moving put_io_page() after the SetPageUpdate() call.

Thanks to Hugh Dickins for analyzing this problem.

Reported-and-tested-by: Markus Trippelsdorf <markus@trippelsdorf.de>
Signed-off-by: Markus Trippelsdorf <markus@trippelsdorf.de>

---
 fs/ext4/page-io.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c
index 7f5451c..beacce1 100644
--- a/fs/ext4/page-io.c
+++ b/fs/ext4/page-io.c
@@ -237,8 +237,6 @@ static void ext4_end_bio(struct bio *bio, int error)
 			} while (bh != head);
 		}
 
-		put_io_page(io_end->pages[i]);
-
 		/*
 		 * If this is a partial write which happened to make
 		 * all buffers uptodate then we can optimize away a
@@ -248,6 +246,8 @@ static void ext4_end_bio(struct bio *bio, int error)
 		 */
 		if (!partial_write)
 			SetPageUptodate(page);
+
+		put_io_page(io_end->pages[i]);
 	}
 	io_end->num_io_pages = 0;
 	inode = io_end->inode;

-- 
Markus
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
BUG: Bad page state in process (current git), Markus Trippelsdorf, (Wed Nov 10, 8:25 am)
Re: BUG: Bad page state in process (current git), Markus Trippelsdorf, (Wed Nov 10, 8:40 am)
Re: BUG: Bad page state in process (current git), Christoph Lameter, (Wed Nov 10, 2:46 pm)
Re: BUG: Bad page state in process (current git), Markus Trippelsdorf, (Fri Nov 12, 5:20 am)
Re: BUG: Bad page state in process (current git), Markus Trippelsdorf, (Mon Nov 15, 5:38 am)
Re: BUG: Bad page state in process (current git), Markus Trippelsdorf, (Mon Nov 15, 12:54 pm)
Re: BUG: Bad page state in process (current git), Hugh Dickins, (Mon Nov 15, 2:23 pm)
[PATCH] ext4 Fix setting random pages PageUptodate, Markus Trippelsdorf, (Tue Nov 16, 4:13 am)