ext4: Test for resize overflow
cover ext4: Test for resize overflow
Hello,
this series add a test for ext4 resize oveflow bug. It also contains a few other cleanups that Eryu wanted.
Honza
PATCH 1/6 dmhugedisk: Allow specifying of chunk size
Ext4 will want to use dmhugedisk infrastructure for testing resize bugs. Ext4 fs images are rather sparse (especially with smaller block sizes) so the current chunk size of 512 sectors leads to large space consumption. Allow test to specify chunk size.
--- common/dmhugedisk | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
common/dmhugedisk +6 -1
@@ -31,6 +31,11 @@ _dmhugedisk_init() { test -z "$1" && _fatal "must specify sector count to _dmhugedisk_init" local dm_backing_dev=$SCRATCH_DEV + local chunk_size="$2" + + if [ -z "$chunk_size" ]; then + chunk_size=512 + fi $DMSETUP_PROG remove huge-test > /dev/null 2>&1 $DMSETUP_PROG remove huge-test-zero > /dev/null 2>&1
@@ -41,7 +46,7 @@ _dmhugedisk_init() DMHUGEDISK_DEV='/dev/mapper/huge-test' DMHUGEDISK_ZERO_TABLE="0 $blk_dev_size zero" - DMHUGEDISK_DEV_TABLE="0 $blk_dev_size snapshot $DMHUGEDISK_ZERO $SCRATCH_DEV N 512" + DMHUGEDISK_DEV_TABLE="0 $blk_dev_size snapshot $DMHUGEDISK_ZERO $SCRATCH_DEV N $chunk_size" $DMSETUP_PROG create huge-test-zero --table "$DMHUGEDISK_ZERO_TABLE" || \ _fatal "failed to create dm huge zero device"
Signature · 1 line
2.13.6
PATCH 2/6 ext4: Test for s_inodes_count overflow during fs resize
In reply to Jan KaraTest for overflow of s_inodes_count during filesystem resizing.
--- common/config | 1 + tests/ext4/033 | 123 +++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/ext4/033.out | 6 +++ tests/ext4/group | 1 + 4 files changed, 131 insertions(+) create mode 100755 tests/ext4/033 create mode 100644 tests/ext4/033.out
common/config +1 -0
@@ -173,6 +173,7 @@ export INDENT_PROG="$(type -P indent)" export XFS_COPY_PROG="$(type -P xfs_copy)" export FSTRIM_PROG="$(type -P fstrim)" export DUMPE2FS_PROG="$(type -P dumpe2fs)" +export RESIZE2FS_PROG="$(type -P resize2fs)" export FIO_PROG="$(type -P fio)" export FILEFRAG_PROG="$(type -P filefrag)" export E4DEFRAG_PROG="$(type -P e4defrag)"
tests/ext4/033 new file +123 -0
123 lines not on this page · raw message
tests/ext4/033.out new file +6 -0
@@ -0,0 +1,6 @@ +QA output created by 033 +Figure out block size +Format huge device +Resizing to inode limit + 1... +Resizing to max group count... +Resizing to device size...
tests/ext4/group +1 -0
@@ -35,6 +35,7 @@ 030 auto quick dax 031 auto quick dax 032 auto quick ioctl resize +033 auto ioctl resize 271 auto rw quick 301 aio auto ioctl rw stress defrag 302 aio auto ioctl rw stress defrag
Signature · 1 line
2.13.6
PATCH 3/6 xfs/310: Cleanup
In reply to Jan KaraCleanup couple of things that were objected to when creating test ext4/033 out of this one.
Use _require_scratch_nocheck instead of recreating scratch fs before exiting. Avoid needless cleanup of dmhugedev on exit - _cleanup takes care of that. Use _scratch_unmount where possible.
--- tests/xfs/310 | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
tests/xfs/310 +2 -4
@@ -35,7 +35,6 @@ _cleanup() umount $SCRATCH_MNT > /dev/null 2>&1 _dmhugedisk_cleanup rm -rf $tmp.* - _scratch_mkfs >/dev/null 2>&1 } # get standard environment, filters and checks
@@ -46,7 +45,7 @@ _cleanup() # real QA test starts here _supported_os Linux _supported_fs xfs -_require_scratch +_require_scratch_nocheck _require_xfs_scratch_rmapbt _require_xfs_io_command "falloc"
@@ -60,7 +59,7 @@ _scratch_mount >> $seqres.full testdir=$SCRATCH_MNT/test-$seq blksz="$(_get_block_size $SCRATCH_MNT)" -umount $SCRATCH_MNT +_scratch_unmount echo "Format huge device" nr_blks=2100000 # 2^21 plus a little more
@@ -110,7 +109,6 @@ test $nr_rmaps -eq 1 || xfs_db -c 'agf 0' -c 'addr rmaproot' -c 'p' $DMHUGEDISK_ echo "Check and fake-repair huge filesystem again" | tee -a $seqres.full $XFS_DB_PROG -c 'check' $DMHUGEDISK_DEV $XFS_REPAIR_PROG -n $DMHUGEDISK_DEV >> $seqres.full 2>&1 -_dmhugedisk_cleanup echo "Done"
Signature · 1 line
2.13.6
Re: [PATCH 3/6] xfs/310: Cleanup
Quoted 8 lines · Jan Kara
Cleanup couple of things that were objected to when creating test ext4/033 out of this one.
Use
_require_scratch_nocheckinstead of recreating scratch fs before exiting. Avoid needless cleanup of dmhugedev on exit -_cleanuptakes care of that. Use_scratch_unmountwhere possible.Signed-off-by Jan Kara <[email protected]>
Looks good.
Signature · 2 lines
Dave Chinner [email protected]
PATCH 4/6 ext4/032: Fix up resize2fs usage
In reply to Jan KaraThe test uses resize2fs(8) without proper feature test macro and also without specifying full path to it. Fix that.
--- tests/ext4/032 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tests/ext4/032 +2 -1
@@ -72,7 +72,7 @@ ext4_online_resize() echo "+++ resize fs to $final_size" | tee -a $seqres.full - resize2fs -f ${LOOP_DEVICE} $final_size >$tmp.resize2fs 2>&1 + $RESIZE2FS_PROG -f ${LOOP_DEVICE} $final_size >$tmp.resize2fs 2>&1 if [ $? -ne 0 ]; then if [ $check_if_supported -eq 1 ]; then grep -iq "operation not supported" $tmp.resize2fs \
@@ -114,6 +114,7 @@ _require_scratch # We use resize_inode to make sure that block group descriptor table # can be extended. _require_scratch_ext4_feature "bigalloc,resize_inode" +_require_command "$RESIZE2FS_PROG" resize2fs _scratch_mkfs >>$seqres.full 2>&1 _scratch_mount
Signature · 1 line
2.13.6
PATCH 5/6 ext4/010: Fixup resize2fs and dumpe2fs usage
In reply to Jan KaraUse $RESIZE2FS_PROG and $DUMPE2FS_PROG instead of names directly to make progs be executed with full path. Also add proper feature test macros.
--- tests/ext4/010 | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
tests/ext4/010 +6 -4
@@ -47,8 +47,10 @@ _supported_fs ext4 _supported_os Linux _require_scratch +_require_dumpe2fs test -n "${FORCE_FUZZ}" || _require_scratch_ext4_crc _require_attrs +_require_command "$RESIZE2FS_PROG" resize2fs rm -f $seqres.full TESTDIR="${SCRATCH_MNT}/scratchdir"
@@ -56,9 +58,9 @@ TESTFILE="${TESTDIR}/testfile" echo "+ create scratch fs" _scratch_mkfs_ext4 > /dev/null 2>&1 -dumpe2fs -g "${SCRATCH_DEV}" > /dev/null 2>&1 || _notrun "dumpe2fs -g not supported" -resize2fs -M "${SCRATCH_DEV}" >> $seqres.full 2>&1 -nr_groups="$(dumpe2fs -g "${SCRATCH_DEV}" 2> /dev/null | tail -n 1 | cut -d : -f 1)" +$DUMPE2FS_PROG -g "${SCRATCH_DEV}" > /dev/null 2>&1 || _notrun "dumpe2fs -g not supported" +$RESIZE2FS_PROG -M "${SCRATCH_DEV}" >> $seqres.full 2>&1 +nr_groups="$($DUMPE2FS_PROG -g "${SCRATCH_DEV}" 2> /dev/null | tail -n 1 | cut -d : -f 1)" echo "+ mount fs image" _scratch_mount
@@ -74,7 +76,7 @@ echo "+ check fs" e2fsck -fn "${SCRATCH_DEV}" >> $seqres.full 2>&1 || _fail "fsck should not fail" echo "+ corrupt image" -dumpe2fs -g "${SCRATCH_DEV}" 2>/dev/null | awk -F ':' '{if (int($6) > 0) {print $6}}' | while read blk; do +$DUMPE2FS_PROG -g "${SCRATCH_DEV}" 2>/dev/null | awk -F ':' '{if (int($6) > 0) {print $6}}' | while read blk; do debugfs -w -n -R "zap_block ${blk}" "${SCRATCH_DEV}" >> $seqres.full 2>&1 || _fail "inode bitmap fuzz failed" done
Signature · 1 line
2.13.6
PATCH 6/6 ext4/306: Fixup resize2fs usage
In reply to Jan KaraUse $RESIZE2FS_PROG instead of direct name to call program with full path. Also add an appropriate feature test.
--- tests/ext4/306 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tests/ext4/306 +2 -1
@@ -44,6 +44,7 @@ _supported_fs ext4 _supported_os Linux _require_scratch +_require_command "$RESIZE2FS_PROG" resize2fs rm -f $seqres.full
@@ -67,7 +68,7 @@ df -h $SCRATCH_MNT >> $seqres.full # Grow fs by 512m echo "Resize to 1g" -resize2fs $SCRATCH_DEV 1g >> $seqres.full 2>&1 || _fail "Could not resize to 1g" +$RESIZE2FS_PROG $SCRATCH_DEV 1g >> $seqres.full 2>&1 || _fail "Could not resize to 1g" df -h $SCRATCH_MNT >> $seqres.full # See if we can add more blocks to the files
Signature · 1 line
2.13.6