提交 1f94533d 编写于 作者: T Theodore Ts'o

ext4: fix a BUG_ON crash by checking that page has buffers attached to it

In ext4_num_dirty_pages() we were calling page_buffers() before
checking to see if the page actually had pages attached to it; this
would cause a BUG check crash in the inline function page_buffers().

Thanks to Markus Trippelsdorf for reporting this bug.
Signed-off-by: N"Theodore Ts'o" <tytso@mit.edu>
上级 c1fccc06
...@@ -1146,8 +1146,8 @@ static int check_block_validity(struct inode *inode, const char *msg, ...@@ -1146,8 +1146,8 @@ static int check_block_validity(struct inode *inode, const char *msg,
} }
/* /*
* Return the number of dirty pages in the given inode starting at * Return the number of contiguous dirty pages in a given inode
* page frame idx. * starting at page frame idx.
*/ */
static pgoff_t ext4_num_dirty_pages(struct inode *inode, pgoff_t idx, static pgoff_t ext4_num_dirty_pages(struct inode *inode, pgoff_t idx,
unsigned int max_pages) unsigned int max_pages)
...@@ -1181,15 +1181,15 @@ static pgoff_t ext4_num_dirty_pages(struct inode *inode, pgoff_t idx, ...@@ -1181,15 +1181,15 @@ static pgoff_t ext4_num_dirty_pages(struct inode *inode, pgoff_t idx,
unlock_page(page); unlock_page(page);
break; break;
} }
head = page_buffers(page); if (page_has_buffers(page)) {
bh = head; bh = head = page_buffers(page);
do { do {
if (!buffer_delay(bh) && if (!buffer_delay(bh) &&
!buffer_unwritten(bh)) { !buffer_unwritten(bh))
done = 1; done = 1;
break; bh = bh->b_this_page;
} } while (!done && (bh != head));
} while ((bh = bh->b_this_page) != head); }
unlock_page(page); unlock_page(page);
if (done) if (done)
break; break;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册