Skip to content

Commit f2a09af

Browse files
xiaoqiangnktytso
authored andcommitted
ext4: check free inode count before allocating an inode
Recently, I ecountered some corrupted filesystems in which some groups' free inode counts were 65535, it seemed that free inode count was overflow. This patch teaches ext4 to check free inode count before allocaing an inode. Signed-off-by: Yongqiang Yang <xiaoqiangnk@gmail.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
1 parent 838cd0c commit f2a09af

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

‎fs/ext4/ialloc.c‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,15 @@ struct inode *ext4_new_inode(handle_t *handle, struct inode *dir, umode_t mode,
697697
if (!gdp)
698698
goto fail;
699699

700+
/*
701+
* Check free inodes count before loading bitmap.
702+
*/
703+
if (ext4_free_inodes_count(sb, gdp) == 0) {
704+
if (++group == ngroups)
705+
group = 0;
706+
continue;
707+
}
708+
700709
brelse(inode_bitmap_bh);
701710
inode_bitmap_bh = ext4_read_inode_bitmap(sb, group);
702711
if (!inode_bitmap_bh)

0 commit comments

Comments
 (0)