Skip to content

Commit

Permalink
ext4: fix setting random pages PageUptodate
Browse files Browse the repository at this point in the history
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-by: Markus Trippelsdorf <markus@trippelsdorf.de>
Tested-by: Markus Trippelsdorf <markus@trippelsdorf.de>
Signed-off-by: Markus Trippelsdorf <markus@trippelsdorf.de>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
  • Loading branch information
Markus Trippelsdorf authored and Theodore Ts'o committed Nov 18, 2010
1 parent e53beac commit 08da119
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions fs/ext4/page-io.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand Down

0 comments on commit 08da119

Please sign in to comment.