tune2fs: rewrite metadata checksums when resizing inode size

When we use tune2fs -I new_ino_size to change inode size, if
everything is OK, the corresponding ext4_group_desc.bg_free_blocks_count
will be decreased, so obviously, we need to re-compute the group
descriptor checksums, and the inode 's size has also changed, we also
need to recompute the checksums of inodes for metadata_csum
filesystem, so here we choose to call a rewrite_metadata_checksums(),
this will fix checksum issues.

Meanwhile, the patch will trigger an existing memory write overflow,
which will casue segfault, please see the next patch.

Signed-off-by: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
crypto
Xiaoguang Wang 2014-12-02 22:29:29 -05:00 committed by Theodore Ts'o
parent 54f6faf7f2
commit 8386a42146
1 changed files with 5 additions and 2 deletions

View File

@ -2908,8 +2908,7 @@ retry_open:
EXT4_FEATURE_RO_COMPAT_METADATA_CSUM)) EXT4_FEATURE_RO_COMPAT_METADATA_CSUM))
rewrite_checksums = 1; rewrite_checksums = 1;
} }
if (rewrite_checksums)
rewrite_metadata_checksums(fs);
if (I_flag) { if (I_flag) {
if (mount_flags & EXT2_MF_MOUNTED) { if (mount_flags & EXT2_MF_MOUNTED) {
fputs(_("The inode size may only be " fputs(_("The inode size may only be "
@ -2935,6 +2934,7 @@ retry_open:
if (resize_inode(fs, new_inode_size) == 0) { if (resize_inode(fs, new_inode_size) == 0) {
printf(_("Setting inode size %lu\n"), printf(_("Setting inode size %lu\n"),
new_inode_size); new_inode_size);
rewrite_checksums = 1;
} else { } else {
printf("%s", _("Failed to change inode size\n")); printf("%s", _("Failed to change inode size\n"));
rc = 1; rc = 1;
@ -2942,6 +2942,9 @@ retry_open:
} }
} }
if (rewrite_checksums)
rewrite_metadata_checksums(fs);
if (l_flag) if (l_flag)
list_super(sb); list_super(sb);
if (stride_set) { if (stride_set) {