diff options
author | Yongqiang Yang <xiaoqiangnk@gmail.com> | 2012-09-24 05:16:03 +0200 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2012-09-24 05:16:03 +0200 |
commit | f2a09af645b762f8230e7eba7fee3b6f7e6e96e7 (patch) | |
tree | 990096ae1076171e1dba0029f087ab7373c441c6 /fs/ext4/ialloc.c | |
parent | ext4: check free block counters in ext4_mb_find_by_goal (diff) | |
download | linux-f2a09af645b762f8230e7eba7fee3b6f7e6e96e7.tar.xz linux-f2a09af645b762f8230e7eba7fee3b6f7e6e96e7.zip |
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>
Diffstat (limited to '')
-rw-r--r-- | fs/ext4/ialloc.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c index 26154b81b836..fa36372f3fdf 100644 --- a/fs/ext4/ialloc.c +++ b/fs/ext4/ialloc.c @@ -697,6 +697,15 @@ got_group: if (!gdp) goto fail; + /* + * Check free inodes count before loading bitmap. + */ + if (ext4_free_inodes_count(sb, gdp) == 0) { + if (++group == ngroups) + group = 0; + continue; + } + brelse(inode_bitmap_bh); inode_bitmap_bh = ext4_read_inode_bitmap(sb, group); if (!inode_bitmap_bh) |