Patchwork [RFC,1/9,v1] ext4: fixup metadata reserve block warning when bigalloc and delalloc are enabled

login
register
mail settings
Submitter Zheng Liu
Date Dec. 24, 2012, 7:55 a.m.
Message ID <1356335742-11793-2-git-send-email-wenqing.lz@taobao.com>
Download mbox | patch
Permalink /patch/208031/
State Superseded
Headers show

Comments

Zheng Liu - Dec. 24, 2012, 7:55 a.m.
From: Zheng Liu <wenqing.lz@taobao.com>

When bigalloc and delalloc are enabled, some stress tests (e.g. xfstest #13)
will trigger this warning because all metadata reserved spaces will be released
after dirty pages are written out.  But we still needs to allocate one block,
such as growing the extent tree.  So *DO NOT* release these metadata blocks when
bigalloc and delaloc are enabled.

Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
---
 fs/ext4/inode.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

Patch

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index cb1c1ab..91542be 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -375,10 +375,16 @@  void ext4_da_update_reserve_space(struct inode *inode,
 		 * We can release all of the reserved metadata blocks
 		 * only when we have written all of the delayed
 		 * allocation blocks.
+		 * When bigalloc and delalloc are enabled, we couldn't release
+		 * all of reserved metadata blocks, although all delay blocks
+		 * are written out, because it still has some metadata blocks
+		 * which are allocated.
 		 */
-		percpu_counter_sub(&sbi->s_dirtyclusters_counter,
-				   ei->i_reserved_meta_blocks);
-		ei->i_reserved_meta_blocks = 0;
+		if (sbi->s_cluster_ratio == 1) {
+			percpu_counter_sub(&sbi->s_dirtyclusters_counter,
+					   ei->i_reserved_meta_blocks);
+			ei->i_reserved_meta_blocks = 0;
+		}
 		ei->i_da_metadata_calc_len = 0;
 	}
 	spin_unlock(&EXT4_I(inode)->i_block_reservation_lock);