Skip to content

Fix resize2fs data/filesystem corruption bugs

Theodore Ts'o linux-ext4 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest3 patches 1 replyIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3resize2fs: Fix data corruption bug when growing an ext4 filesystem off-lineresize/resize2fs.c+21 -00 replies
2/3resize2fs: Fix data corruption bug when shrinking the inode table for ext4resize/online.c resize/resize2fs.c resize/resize2fs.h+44 -150 replies
3/3resize2fs: Fix corruption bug impacting ext4 filesystems with uninit_bgresize/resize2fs.c+1 -10 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/3] Fix resize2fs data/filesystem corruption bugs

These patches fix some nasty resize2fs bugs when growing or shrinking ext4 filesystems off-line. Eric, you'll probably want get these patches into Fedora's e2fsprogs before F11 goes live.

The test case I've been using for these patches are as follows.

#!/bin/sh
mke2fs -i 8192 -b 1024 -t ext4 /dev/closure/testext4 1048576 mount /dev/closure/testext4 /mnt
cd /mnt
mkdir 1 2 3 4
cd 1; tar xjf /usr/projects/uml/shars/linux-2.6.11.tar.bz2; cd .. cd 2; tar xjf /usr/projects/uml/shars/linux-2.6.11.tar.bz2; cd .. cd 3; tar xjf /usr/projects/uml/shars/linux-2.6.11.tar.bz2; cd .. cd 4; tar xjf /usr/projects/uml/shars/linux-2.6.11.tar.bz2; cd .. cd /
umount /mnt
e2fsck -f /dev/closure/testext4

Then try resizing the filesystem smaller or larger. With e2fsprogs 1.41.4, "resize2fs -M -p /dev/closure/testext4" will just plain fail in the middle with the resize operation:

# /sbin/resize2fs  -M -p /dev/closure/testext4
resize2fs 1.41.4 (27-Jan-2009)
Resizing the filesystem on /dev/closure/textext4 to 863610 (1k) blocks.
Begin pass 2 (max = 116149)
Relocating blocks             XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Begin pass 3 (max = 128)
Scanning inode table          XXXXXXXXXXXXXXXXXXXX/sbin/resize2fs: No space left on device while trying to resize /dev/closure/textext4

The bugs fixed include potentially overwriting part of the existing inode table when shrinking the filesystem, and potentially overwriting in-use data blocks when growing the filesystem. So these are pretty serious errors, and means an e2fsprogs 1.41.5 will be coming out real soon now.

With these patches, I've resized the filesystem and then run a CRC checksum test across the unpacked 2.6.11 source tree. (Why 2.6.11? Because it was what I happened to have handy on my laptop at the time. :-)

- Ted