]> www.infradead.org Git - linux.git/commitdiff
ext4: warn if delalloc counters are not zero on inactive
authorZhang Yi <yi.zhang@huawei.com>
Fri, 17 May 2024 12:39:58 +0000 (20:39 +0800)
committerTheodore Ts'o <tytso@mit.edu>
Thu, 27 Jun 2024 22:04:49 +0000 (18:04 -0400)
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 <yi.zhang@huawei.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Link: https://patch.msgid.link/20240517124005.347221-4-yi.zhang@huaweicloud.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
fs/ext4/super.c

index c682fb927b64b8a0fba027f32c27c968cbb8ed93..da980ca9e962885b46358680462b6d94293be180 100644 (file)
@@ -1327,6 +1327,9 @@ static void ext4_put_super(struct super_block *sb)
 
        ext4_group_desc_free(sbi);
        ext4_flex_groups_free(sbi);
+
+       WARN_ON_ONCE(!(sbi->s_mount_state & EXT4_ERROR_FS) &&
+                    percpu_counter_sum(&sbi->s_dirtyclusters_counter));
        ext4_percpu_param_destroy(sbi);
 #ifdef CONFIG_QUOTA
        for (int i = 0; i < EXT4_MAXQUOTAS; i++)
@@ -1457,7 +1460,8 @@ static void ext4_destroy_inode(struct inode *inode)
                dump_stack();
        }
 
-       if (EXT4_I(inode)->i_reserved_data_blocks)
+       if (!(EXT4_SB(inode->i_sb)->s_mount_state & EXT4_ERROR_FS) &&
+           WARN_ON_ONCE(EXT4_I(inode)->i_reserved_data_blocks))
                ext4_msg(inode->i_sb, KERN_ERR,
                         "Inode %lu (%p): i_reserved_data_blocks (%u) not cleared!",
                         inode->i_ino, EXT4_I(inode),