From: Jan Kara Date: Thu, 26 Mar 2026 09:54:13 +0000 (+0100) Subject: ext4: Sync and invalidate metadata buffers from ext4_evict_inode() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=77ff1ff2f3c5b333ac9d049e90570eb404549a4a;p=thirdparty%2Fkernel%2Flinux.git ext4: Sync and invalidate metadata buffers from ext4_evict_inode() There are only very few filesystems using generic metadata buffer head tracking and everybody is paying the overhead. When we remove this tracking for inode reclaim code .evict will start to see inodes with metadata buffers attached so write them out and prune them. Acked-by: Theodore Ts'o Signed-off-by: Jan Kara Link: https://patch.msgid.link/20260326095354.16340-61-jack@suse.cz Tested-by: syzbot@syzkaller.appspotmail.com Signed-off-by: Christian Brauner --- diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index d18d94acddcc1..6f892abef003c 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -185,7 +185,9 @@ void ext4_evict_inode(struct inode *inode) ext4_evict_ea_inode(inode); if (inode->i_nlink) { truncate_inode_pages_final(&inode->i_data); - + /* Avoid mballoc special inode which has no proper iops */ + if (!EXT4_SB(inode->i_sb)->s_journal) + sync_mapping_buffers(&inode->i_data); goto no_delete; } diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 43f680c750ae6..ea827b0ecc8dc 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -1524,7 +1524,8 @@ static void destroy_inodecache(void) void ext4_clear_inode(struct inode *inode) { ext4_fc_del(inode); - invalidate_inode_buffers(inode); + if (!EXT4_SB(inode->i_sb)->s_journal) + invalidate_inode_buffers(inode); clear_inode(inode); ext4_discard_preallocations(inode); ext4_es_remove_extent(inode, 0, EXT_MAX_BLOCKS);