diff options
author | Andreas Dilger <adilger@dilger.ca> | 2008-03-31 12:14:22 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2008-03-31 14:28:38 -0400 |
commit | 0d5439c8e0bc63438f45315755e7f0d9dcb09ccf (patch) | |
tree | 88869bb9e6897b185d42feeb53d4c80740bde69a /e2fsck/super.c | |
parent | 0d47b68c2f00959665eecacaf2a2c90b546b3811 (diff) | |
download | e2fsprogs-0d5439c8e0bc63438f45315755e7f0d9dcb09ccf.tar.gz |
e2fsck: Add check to enforce a valid block bitmap in last block group
Add a check for the UNINIT_BLOCKS flag set in the last group. The kernel
patch doesn't handle this gracefully, because it assumes there are a full
set of blocks in each group marked UNINIT_BLOCKS. The kernel should be
fixed up, but in the meantime this avoids hitting the problem, and is
more consistent with lazy_bg not marking the last group UNINIT.
Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'e2fsck/super.c')
-rw-r--r-- | e2fsck/super.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/e2fsck/super.c b/e2fsck/super.c index 6753a147..87a0d78d 100644 --- a/e2fsck/super.c +++ b/e2fsck/super.c @@ -631,11 +631,13 @@ void check_super_block(e2fsck_t ctx) (gd->bg_used_dirs_count > sb->s_inodes_per_group)) ext2fs_unmark_valid(fs); + should_be = 0; if (!ext2fs_group_desc_csum_verify(fs, i)) { if (fix_problem(ctx, PR_0_GDT_CSUM, &pctx)) { gd->bg_flags &= ~(EXT2_BG_BLOCK_UNINIT | EXT2_BG_INODE_UNINIT); gd->bg_itable_unused = 0; + should_be = 1; } ext2fs_unmark_valid(fs); } @@ -647,23 +649,42 @@ void check_super_block(e2fsck_t ctx) gd->bg_flags &= ~(EXT2_BG_BLOCK_UNINIT | EXT2_BG_INODE_UNINIT); gd->bg_itable_unused = 0; + should_be = 1; } ext2fs_unmark_valid(fs); } + + if (i == fs->group_desc_count - 1 && + gd->bg_flags & EXT2_BG_BLOCK_UNINIT) { + if (fix_problem(ctx, PR_0_BB_UNINIT_LAST, &pctx)) { + gd->bg_flags &= ~EXT2_BG_BLOCK_UNINIT; + should_be = 1; + } + ext2fs_unmark_valid(fs); + } + if (gd->bg_flags & EXT2_BG_BLOCK_UNINIT && !(gd->bg_flags & EXT2_BG_INODE_UNINIT)) { - if (fix_problem(ctx, PR_0_BB_UNINIT_IB_INIT, &pctx)) + if (fix_problem(ctx, PR_0_BB_UNINIT_IB_INIT, &pctx)) { gd->bg_flags &= ~EXT2_BG_BLOCK_UNINIT; + should_be = 1; + } ext2fs_unmark_valid(fs); } + if (csum_flag && (gd->bg_itable_unused > gd->bg_free_inodes_count || gd->bg_itable_unused > sb->s_inodes_per_group)) { pctx.blk = gd->bg_itable_unused; - if (fix_problem(ctx, PR_0_GDT_ITABLE_UNUSED, &pctx)) + if (fix_problem(ctx, PR_0_GDT_ITABLE_UNUSED, &pctx)) { gd->bg_itable_unused = 0; + should_be = 1; + } ext2fs_unmark_valid(fs); } + + if (should_be) + ext2fs_group_desc_csum_set(fs, i); } /* |