resize2fs: Clean up the resize inode properly if necessary

If the filesystem is grown to the point where the resize_inode is no
longer needed, clean it up properly so e2fsck doesn't have to.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
bitmap-optimize
Theodore Ts'o 2008-07-10 14:18:41 -04:00
parent 2be8fe4397
commit 8ade268cf2
1 changed files with 15 additions and 3 deletions

View File

@ -310,9 +310,6 @@ retry:
if (new > (int) fs->blocksize/4)
new = fs->blocksize/4;
fs->super->s_reserved_gdt_blocks = new;
if (new == 0)
fs->super->s_feature_compat &=
~EXT2_FEATURE_COMPAT_RESIZE_INODE;
}
/*
@ -1536,6 +1533,7 @@ static errcode_t fix_resize_inode(ext2_filsys fs)
struct ext2_inode inode;
errcode_t retval;
char * block_buf;
blk_t blk;
if (!(fs->super->s_feature_compat &
EXT2_FEATURE_COMPAT_RESIZE_INODE))
@ -1547,6 +1545,20 @@ static errcode_t fix_resize_inode(ext2_filsys fs)
retval = ext2fs_read_inode(fs, EXT2_RESIZE_INO, &inode);
if (retval) goto errout;
if (fs->super->s_reserved_gdt_blocks == 0) {
fs->super->s_feature_compat &=
~EXT2_FEATURE_COMPAT_RESIZE_INODE;
ext2fs_mark_super_dirty(fs);
if ((blk = inode.i_block[EXT2_DIND_BLOCK]) != 0)
ext2fs_block_alloc_stats(fs, blk, -1);
memset(&inode, 0, sizeof(inode));
retval = ext2fs_write_inode(fs, EXT2_RESIZE_INO, &inode);
goto errout;
}
ext2fs_iblk_set(fs, &inode, 1);
retval = ext2fs_write_inode(fs, EXT2_RESIZE_INO, &inode);