Skip to content

Commit b37c907

Browse files
zhangyi089tytso
authored andcommitted
ext4: warn if delalloc counters are not zero on inactive
The per-inode i_reserved_data_blocks count the reserved delalloc blocks in a regular file, it should be zero when destroying the file. The per-fs s_dirtyclusters_counter count all reserved delalloc blocks in a filesystem, it also should be zero when umounting the filesystem. Now we have only an error message if the i_reserved_data_blocks is not zero, which is unable to be simply captured, so add WARN_ON_ONCE to make it more visable. Signed-off-by: Zhang Yi <[email protected]> Reviewed-by: Jan Kara <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Theodore Ts'o <[email protected]>
1 parent 0ea6560 commit b37c907

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

fs/ext4/super.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1327,6 +1327,9 @@ static void ext4_put_super(struct super_block *sb)
13271327

13281328
ext4_group_desc_free(sbi);
13291329
ext4_flex_groups_free(sbi);
1330+
1331+
WARN_ON_ONCE(!(sbi->s_mount_state & EXT4_ERROR_FS) &&
1332+
percpu_counter_sum(&sbi->s_dirtyclusters_counter));
13301333
ext4_percpu_param_destroy(sbi);
13311334
#ifdef CONFIG_QUOTA
13321335
for (int i = 0; i < EXT4_MAXQUOTAS; i++)
@@ -1457,7 +1460,8 @@ static void ext4_destroy_inode(struct inode *inode)
14571460
dump_stack();
14581461
}
14591462

1460-
if (EXT4_I(inode)->i_reserved_data_blocks)
1463+
if (!(EXT4_SB(inode->i_sb)->s_mount_state & EXT4_ERROR_FS) &&
1464+
WARN_ON_ONCE(EXT4_I(inode)->i_reserved_data_blocks))
14611465
ext4_msg(inode->i_sb, KERN_ERR,
14621466
"Inode %lu (%p): i_reserved_data_blocks (%u) not cleared!",
14631467
inode->i_ino, EXT4_I(inode),

0 commit comments

Comments
 (0)