1 From 7fcfa625f4bdba955d0fb0b717dc576b1e48b470 Mon Sep 17 00:00:00 2001
2 From: Theodore Ts'o <tytso@mit.edu>
3 Date: Wed, 30 Sep 2009 22:57:41 -0400
4 Subject: [PATCH 50/85] ext4: fix a BUG_ON crash by checking that page has buffers attached to it
6 (cherry picked from commit 1f94533d9cd75f6d2826018d54a971b9cc085992)
8 In ext4_num_dirty_pages() we were calling page_buffers() before
9 checking to see if the page actually had pages attached to it; this
10 would cause a BUG check crash in the inline function page_buffers().
12 Thanks to Markus Trippelsdorf for reporting this bug.
14 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
15 Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
17 fs/ext4/inode.c | 22 +++++++++++-----------
18 1 file changed, 11 insertions(+), 11 deletions(-)
22 @@ -1147,8 +1147,8 @@ static int check_block_validity(struct i
26 - * Return the number of dirty pages in the given inode starting at
28 + * Return the number of contiguous dirty pages in a given inode
29 + * starting at page frame idx.
31 static pgoff_t ext4_num_dirty_pages(struct inode *inode, pgoff_t idx,
32 unsigned int max_pages)
33 @@ -1182,15 +1182,15 @@ static pgoff_t ext4_num_dirty_pages(stru
37 - head = page_buffers(page);
40 - if (!buffer_delay(bh) &&
41 - !buffer_unwritten(bh)) {
45 - } while ((bh = bh->b_this_page) != head);
46 + if (page_has_buffers(page)) {
47 + bh = head = page_buffers(page);
49 + if (!buffer_delay(bh) &&
50 + !buffer_unwritten(bh))
52 + bh = bh->b_this_page;
53 + } while (!done && (bh != head));