From: Yongqiang Yang Date: Wed, 14 Dec 2011 02:51:55 +0000 (-0500) Subject: ext4: avoid potential hang in mpage_submit_io() when blocksize < pagesize X-Git-Tag: v3.1.6~10 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=8afe1f656c3cb0eff4219e3a4a22b95579148ad6;p=karo-tx-linux.git ext4: avoid potential hang in mpage_submit_io() when blocksize < pagesize commit 13a79a4741d37fda2fbafb953f0f301dc007928f upstream. If there is an unwritten but clean buffer in a page and there is a dirty buffer after the buffer, then mpage_submit_io does not write the dirty buffer out. As a result, da_writepages loops forever. This patch fixes the problem by checking dirty flag. Signed-off-by: Yongqiang Yang Signed-off-by: "Theodore Ts'o" Signed-off-by: Greg Kroah-Hartman --- diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index d33c7375bfda..5dbdb6b91ae7 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -1261,8 +1261,11 @@ static int mpage_da_submit_io(struct mpage_da_data *mpd, clear_buffer_unwritten(bh); } - /* skip page if block allocation undone */ - if (buffer_delay(bh) || buffer_unwritten(bh)) + /* + * skip page if block allocation undone and + * block is dirty + */ + if (ext4_bh_delay_or_unwritten(NULL, bh)) skip_page = 1; bh = bh->b_this_page; block_start += bh->b_size;