Skip to content

Commit bd060af

Browse files
jankaratytso
authored andcommitted
ext4: make recently_deleted() properly work with lazy itable initialization
recently_deleted() checks whether inode has been used in the near past. However this can give false positive result when inode table is not initialized yet and we are in fact comparing to random garbage (or stale itable block of a filesystem before mkfs). Ultimately this results in uninitialized inodes being skipped during inode allocation and possibly they are never initialized and thus e2fsck complains. Verify if the inode has been initialized before checking for dtime. Signed-off-by: Jan Kara <jack@suse.cz> Reviewed-by: Zhang Yi <yi.zhang@huawei.com> Link: https://patch.msgid.link/20260216164848.3074-3-jack@suse.cz Signed-off-by: Theodore Ts'o <tytso@mit.edu> Cc: stable@kernel.org
1 parent b1d682f commit bd060af

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

fs/ext4/ialloc.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -686,6 +686,12 @@ static int recently_deleted(struct super_block *sb, ext4_group_t group, int ino)
686686
if (unlikely(!gdp))
687687
return 0;
688688

689+
/* Inode was never used in this filesystem? */
690+
if (ext4_has_group_desc_csum(sb) &&
691+
(gdp->bg_flags & cpu_to_le16(EXT4_BG_INODE_UNINIT) ||
692+
ino >= EXT4_INODES_PER_GROUP(sb) - ext4_itable_unused_count(sb, gdp)))
693+
return 0;
694+
689695
bh = sb_find_get_block(sb, ext4_inode_table(sb, gdp) +
690696
(ino / inodes_per_block));
691697
if (!bh || !buffer_uptodate(bh))

0 commit comments

Comments
 (0)