* [PATCH 0/6] ext4: Test for resize overflow
@ 2018-05-29 16:55 Jan Kara
2018-05-29 16:55 ` [PATCH 1/6] dmhugedisk: Allow specifying of chunk size Jan Kara
` (5 more replies)
0 siblings, 6 replies; 8+ messages in thread
From: Jan Kara @ 2018-05-29 16:55 UTC (permalink / raw)
To: fstests; +Cc: Jan Kara
Hello,
this series add a test for ext4 resize oveflow bug. It also contains a few
other cleanups that Eryu wanted.
Honza
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/6] dmhugedisk: Allow specifying of chunk size
2018-05-29 16:55 [PATCH 0/6] ext4: Test for resize overflow Jan Kara
@ 2018-05-29 16:55 ` Jan Kara
2018-05-29 16:55 ` [PATCH 2/6] ext4: Test for s_inodes_count overflow during fs resize Jan Kara
` (4 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Jan Kara @ 2018-05-29 16:55 UTC (permalink / raw)
To: fstests; +Cc: Jan Kara
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.
Signed-off-by: Jan Kara <jack@suse.cz>
---
common/dmhugedisk | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/common/dmhugedisk b/common/dmhugedisk
index 4d3b63fcfcca..733b10cd2292 100644
--- a/common/dmhugedisk
+++ b/common/dmhugedisk
@@ -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"
--
2.13.6
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/6] ext4: Test for s_inodes_count overflow during fs resize
2018-05-29 16:55 [PATCH 0/6] ext4: Test for resize overflow Jan Kara
2018-05-29 16:55 ` [PATCH 1/6] dmhugedisk: Allow specifying of chunk size Jan Kara
@ 2018-05-29 16:55 ` Jan Kara
2018-05-29 16:55 ` [PATCH 3/6] xfs/310: Cleanup Jan Kara
` (3 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Jan Kara @ 2018-05-29 16:55 UTC (permalink / raw)
To: fstests; +Cc: Jan Kara
Test for overflow of s_inodes_count during filesystem resizing.
Signed-off-by: Jan Kara <jack@suse.cz>
---
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
diff --git a/common/config b/common/config
index 51380231aed3..6efc8f9fc4a5 100644
--- a/common/config
+++ b/common/config
@@ -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)"
diff --git a/tests/ext4/033 b/tests/ext4/033
new file mode 100755
index 000000000000..d3e56ab7d1ba
--- /dev/null
+++ b/tests/ext4/033
@@ -0,0 +1,123 @@
+#! /bin/bash
+# FS QA Test 033
+#
+# Test s_inodes_count overflow for huge filesystems. This bug was fixed
+# by commit "ext4: Forbid overflowing inode count when resizing".
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2018 Jan Kara, SUSE. All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+#-----------------------------------------------------------------------
+#
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1 # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+ umount $SCRATCH_MNT >/dev/null 2>&1
+ _dmhugedisk_cleanup
+ cd /
+ rm -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/dmhugedisk
+
+# remove previous $seqres.full before test
+rm -f $seqres.full
+
+# real QA test starts here
+_supported_fs ext4
+_supported_os Linux
+_require_scratch_nocheck
+_require_dmhugedisk
+_require_dumpe2fs
+_require_command "$RESIZE2FS_PROG" resize2fs
+
+# Figure out whether device is large enough
+devsize=$(blockdev --getsize64 $SCRATCH_DEV)
+if [ $devsize -lt 4294967296 ]; then
+ _notrun "Too small scratch device, need at least 4G"
+fi
+
+# Figure out block size
+echo "Figure out block size"
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount >> $seqres.full
+blksz="$(_get_block_size $SCRATCH_MNT)"
+_scratch_unmount
+
+inodes_per_group=$((blksz*8))
+group_blocks=$((blksz*8))
+
+# Number of groups to overflow s_inodes_count
+limit_groups=$(((1<<32)/inodes_per_group))
+
+# Create device huge enough so that overflowing inode count is possible.
+# Set chunk size to 16 sectors. Group descriptors with META_BG feature
+# are rather sparse and that leads to huge overallocation especially with
+# 1k blocksize.
+echo "Format huge device"
+_dmhugedisk_init $(((limit_groups + 16)*group_blocks*(blksz/512))) 16
+
+# Start with small fs
+group_count=$((limit_groups - 16))
+_mkfs_dev -N $((group_count*inodes_per_group)) -b $blksz \
+ $DMHUGEDISK_DEV $((group_count*group_blocks))
+
+_mount $DMHUGEDISK_DEV $SCRATCH_MNT
+
+echo "Initial fs dump" >> $seqres.full
+$DUMPE2FS_PROG -h $DMHUGEDISK_DEV >> $seqres.full 2>&1
+
+# This should fail, s_inodes_count would just overflow!
+echo "Resizing to inode limit + 1..."
+$RESIZE2FS_PROG $DMHUGEDISK_DEV $((limit_groups*group_blocks)) >> $seqres.full 2>&1
+if [ $? -eq 0 ]; then
+ echo "Resizing succeeded but it should fail!"
+ exit
+fi
+
+# This should succeed, we are maxing out inodes
+echo "Resizing to max group count..."
+$RESIZE2FS_PROG $DMHUGEDISK_DEV $(((limit_groups-1)*group_blocks)) >> $seqres.full 2>&1
+if [ $? -ne 0 ]; then
+ echo "Resizing failed!"
+ exit
+fi
+
+echo "Fs dump after resize" >> $seqres.full
+$DUMPE2FS_PROG -h $DMHUGEDISK_DEV >> $seqres.full 2>&1
+
+# This should fail, s_inodes_count would overflow by quite a bit!
+echo "Resizing to device size..."
+$RESIZE2FS_PROG $DMHUGEDISK_DEV >> $seqres.full 2>&1
+if [ $? -eq 0 ]; then
+ echo "Resizing succeeded but it should fail!"
+ exit
+fi
+
+# success, all done
+status=0
+exit
diff --git a/tests/ext4/033.out b/tests/ext4/033.out
new file mode 100644
index 000000000000..24c251cbb2b3
--- /dev/null
+++ b/tests/ext4/033.out
@@ -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...
diff --git a/tests/ext4/group b/tests/ext4/group
index 5bd15f82b3be..b850f568e674 100644
--- a/tests/ext4/group
+++ b/tests/ext4/group
@@ -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
--
2.13.6
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 3/6] xfs/310: Cleanup
2018-05-29 16:55 [PATCH 0/6] ext4: Test for resize overflow Jan Kara
2018-05-29 16:55 ` [PATCH 1/6] dmhugedisk: Allow specifying of chunk size Jan Kara
2018-05-29 16:55 ` [PATCH 2/6] ext4: Test for s_inodes_count overflow during fs resize Jan Kara
@ 2018-05-29 16:55 ` Jan Kara
2018-05-29 22:01 ` Dave Chinner
2018-05-29 16:55 ` [PATCH 4/6] ext4/032: Fix up resize2fs usage Jan Kara
` (2 subsequent siblings)
5 siblings, 1 reply; 8+ messages in thread
From: Jan Kara @ 2018-05-29 16:55 UTC (permalink / raw)
To: fstests; +Cc: Jan Kara
Cleanup 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.
Signed-off-by: Jan Kara <jack@suse.cz>
---
tests/xfs/310 | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/tests/xfs/310 b/tests/xfs/310
index f33a15ad028c..5c1f20ce453c 100755
--- a/tests/xfs/310
+++ b/tests/xfs/310
@@ -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"
--
2.13.6
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 4/6] ext4/032: Fix up resize2fs usage
2018-05-29 16:55 [PATCH 0/6] ext4: Test for resize overflow Jan Kara
` (2 preceding siblings ...)
2018-05-29 16:55 ` [PATCH 3/6] xfs/310: Cleanup Jan Kara
@ 2018-05-29 16:55 ` Jan Kara
2018-05-29 16:56 ` [PATCH 5/6] ext4/010: Fixup resize2fs and dumpe2fs usage Jan Kara
2018-05-29 16:56 ` [PATCH 6/6] ext4/306: Fixup resize2fs usage Jan Kara
5 siblings, 0 replies; 8+ messages in thread
From: Jan Kara @ 2018-05-29 16:55 UTC (permalink / raw)
To: fstests; +Cc: Jan Kara
The test uses resize2fs(8) without proper feature test macro and also
without specifying full path to it. Fix that.
Signed-off-by: Jan Kara <jack@suse.cz>
---
tests/ext4/032 | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tests/ext4/032 b/tests/ext4/032
index 22cd533be8e8..13faa26a0f9f 100755
--- a/tests/ext4/032
+++ b/tests/ext4/032
@@ -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
--
2.13.6
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 5/6] ext4/010: Fixup resize2fs and dumpe2fs usage
2018-05-29 16:55 [PATCH 0/6] ext4: Test for resize overflow Jan Kara
` (3 preceding siblings ...)
2018-05-29 16:55 ` [PATCH 4/6] ext4/032: Fix up resize2fs usage Jan Kara
@ 2018-05-29 16:56 ` Jan Kara
2018-05-29 16:56 ` [PATCH 6/6] ext4/306: Fixup resize2fs usage Jan Kara
5 siblings, 0 replies; 8+ messages in thread
From: Jan Kara @ 2018-05-29 16:56 UTC (permalink / raw)
To: fstests; +Cc: Jan Kara
Use $RESIZE2FS_PROG and $DUMPE2FS_PROG instead of names directly to make
progs be executed with full path. Also add proper feature test macros.
Signed-off-by: Jan Kara <jack@suse.cz>
---
tests/ext4/010 | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/tests/ext4/010 b/tests/ext4/010
index c877bd7af43f..37ba2aaa7c85 100755
--- a/tests/ext4/010
+++ b/tests/ext4/010
@@ -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
--
2.13.6
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 6/6] ext4/306: Fixup resize2fs usage
2018-05-29 16:55 [PATCH 0/6] ext4: Test for resize overflow Jan Kara
` (4 preceding siblings ...)
2018-05-29 16:56 ` [PATCH 5/6] ext4/010: Fixup resize2fs and dumpe2fs usage Jan Kara
@ 2018-05-29 16:56 ` Jan Kara
5 siblings, 0 replies; 8+ messages in thread
From: Jan Kara @ 2018-05-29 16:56 UTC (permalink / raw)
To: fstests; +Cc: Jan Kara
Use $RESIZE2FS_PROG instead of direct name to call program with full
path. Also add an appropriate feature test.
Signed-off-by: Jan Kara <jack@suse.cz>
---
tests/ext4/306 | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tests/ext4/306 b/tests/ext4/306
index 7d00bad6c1ce..5b3744d0597c 100755
--- a/tests/ext4/306
+++ b/tests/ext4/306
@@ -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
--
2.13.6
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 3/6] xfs/310: Cleanup
2018-05-29 16:55 ` [PATCH 3/6] xfs/310: Cleanup Jan Kara
@ 2018-05-29 22:01 ` Dave Chinner
0 siblings, 0 replies; 8+ messages in thread
From: Dave Chinner @ 2018-05-29 22:01 UTC (permalink / raw)
To: Jan Kara; +Cc: fstests
On Tue, May 29, 2018 at 06:55:58PM +0200, Jan Kara wrote:
> Cleanup 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.
>
> Signed-off-by: Jan Kara <jack@suse.cz>
Looks good.
Reviewed-by: Dave Chinner <dchinner@redhat.com>
--
Dave Chinner
david@fromorbit.com
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2018-05-29 22:01 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-29 16:55 [PATCH 0/6] ext4: Test for resize overflow Jan Kara
2018-05-29 16:55 ` [PATCH 1/6] dmhugedisk: Allow specifying of chunk size Jan Kara
2018-05-29 16:55 ` [PATCH 2/6] ext4: Test for s_inodes_count overflow during fs resize Jan Kara
2018-05-29 16:55 ` [PATCH 3/6] xfs/310: Cleanup Jan Kara
2018-05-29 22:01 ` Dave Chinner
2018-05-29 16:55 ` [PATCH 4/6] ext4/032: Fix up resize2fs usage Jan Kara
2018-05-29 16:56 ` [PATCH 5/6] ext4/010: Fixup resize2fs and dumpe2fs usage Jan Kara
2018-05-29 16:56 ` [PATCH 6/6] ext4/306: Fixup resize2fs usage Jan Kara
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.