Skip to content

Commit

Permalink
tune2fs: rewrite metadata checksums when resizing inode size
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
wangxiaoguang authored and tytso committed Dec 3, 2014
1 parent 54f6faf commit 8386a42
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions misc/tune2fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -2908,8 +2908,7 @@ int main(int argc, char **argv)
EXT4_FEATURE_RO_COMPAT_METADATA_CSUM))
rewrite_checksums = 1;
}
if (rewrite_checksums)
rewrite_metadata_checksums(fs);

if (I_flag) {
if (mount_flags & EXT2_MF_MOUNTED) {
fputs(_("The inode size may only be "
Expand All @@ -2935,13 +2934,17 @@ int main(int argc, char **argv)
if (resize_inode(fs, new_inode_size) == 0) {
printf(_("Setting inode size %lu\n"),
new_inode_size);
rewrite_checksums = 1;
} else {
printf("%s", _("Failed to change inode size\n"));
rc = 1;
goto closefs;
}
}

if (rewrite_checksums)
rewrite_metadata_checksums(fs);

if (l_flag)
list_super(sb);
if (stride_set) {
Expand Down

0 comments on commit 8386a42

Please sign in to comment.