Some random regression tests
cover Some random regression tests
I'm porting more tests from RH internal test case pool.
The first patch is containing 6 sub-tests, and each sub-test is relatively small, so I grouped them together.
Thanks,
Eryu
Eryu Guan (5):
generic: test some mount/umount corner cases
generic: test quota handling on remount ro failure
generic: test hardlink to unlinked file
shared: test truncate orphan inodes when mounting extN
generic: test fs freeze/unfreeze and mount/umount race
tests/generic/067 | 143 ++++++++++++++++++++++++++++++++++++++++++++++++++ tests/generic/067.out | 2 + tests/generic/071 | 69 ++++++++++++++++++++++++ tests/generic/071.out | 3 ++ tests/generic/072 | 99 ++++++++++++++++++++++++++++++++++ tests/generic/072.out | 2 + tests/generic/073 | 98 ++++++++++++++++++++++++++++++++++ tests/generic/073.out | 2 + tests/generic/group | 4 ++ tests/shared/001 | 71 +++++++++++++++++++++++++ tests/shared/001.out | 2 + tests/shared/group | 1 + 12 files changed, 496 insertions(+) create mode 100755 tests/generic/067 create mode 100644 tests/generic/067.out create mode 100755 tests/generic/071 create mode 100644 tests/generic/071.out create mode 100755 tests/generic/072 create mode 100644 tests/generic/072.out create mode 100755 tests/generic/073 create mode 100644 tests/generic/073.out create mode 100755 tests/shared/001 create mode 100644 tests/shared/001.out
Signature · 1 line
1.8.3.1
PATCH 1/5 generic: test some mount/umount corner cases
There're six test cases:
- mount at a nonexistent mount point
- mount a free loop device
- mount with a wrong fs type
- umount an symlink to device which is not mounted
- umount a path with too long name
- lazy umount a symlink
--- tests/generic/067 | 143 ++++++++++++++++++++++++++++++++++++++++++++++++++ tests/generic/067.out | 2 + tests/generic/group | 1 + 3 files changed, 146 insertions(+) create mode 100755 tests/generic/067 create mode 100644 tests/generic/067.out
tests/generic/067 new file +143 -0
@@ -0,0 +1,143 @@ +#! /bin/bash +# FS QA Test No. 067 +# +# Some random mount/umount corner case tests +# +# - mount at a nonexistent mount point +# - mount a free loop device +# - mount with a wrong fs type specified +# - umount an symlink to device which is not mounted +# - umount a path with too long name +# - lazy umount a symlink +# +#----------------------------------------------------------------------- +# Copyright (c) 2015 Red Hat Inc. 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() +{ + cd / + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +# real QA test starts here + +# Modify as appropriate. +_supported_fs generic +_supported_os Linux +_require_test +_require_scratch +_require_loop + +rm -f $seqres.full + +_scratch_mkfs >>$seqres.full 2>&1 + +# kernel should not hang nor oops when mounting fs to nonexistent mount point +mount_nonexistent_mnt() +{ + echo "# mount to nonexistent mount point" >>$seqres.full + rm -rf $TEST_DIR/nosuchdir + $MOUNT_PROG $SCRATCH_DEV $TEST_DIR/nosuchdir >>$seqres.full 2>&1 +} + +# fs driver should be able to handle mounting a free loop device gracefully +# xfs ever hung, "ec53d1d xfs: don't block on buffer read errors" fixed it +mount_free_loopdev() +{ + echo "# mount a free loop device" >>$seqres.full + loopdev=`losetup -f` + $MOUNT_PROG -t $FSTYP $loopdev $SCRATCH_MNT >>$seqres.full 2>&1 +} + +# mount with wrong fs type specified. +# This should fail gracefully, no hang no oops are expected +mount_wrong_fstype() +{ + local fs=ext4 + if [ "$FSTYP" == "ext4" ]; then + fs=xfs + fi + echo "# mount with wrong fs type" >>$seqres.full + $MOUNT_PROG -t $fs $SCRATCH_DEV $SCRATCH_MNT >>$seqres.full 2>&1 +} + +# umount a symlink to device, which is not mounted. +# This should fail gracefully, no hang no oops are expected +umount_symlink_device() +{ + local symlink=$TEST_DIR/$seq.scratch_dev_symlink + rm -f $symlink + echo "# umount symlink to device, which is not mounted" >>$seqres.full + ln -s $SCRATCH_DEV $symlink + $UMOUNT_PROG $symlink >>$seqres.full 2>&1 +} + +# umount a path name that is 256 bytes long, this should fail gracefully, +# and the following umount should not hang nor oops +umount_toolong_name() +{ + local longname=$SCRATCH_MNT/`$PERL_PROG -e 'print "a"x256;'` + + _scratch_mount 2>&1 | tee -a $seqres.full + + echo "# umount a too-long name" >>$seqres.full + $UMOUNT_PROG $longname >>$seqres.full 2>&1 + _scratch_unmount 2>&1 | tee -a $seqres.full +} + +# lazy umount a symlink should not block following umount. +# This is the test case described in https://lkml.org/lkml/2014/7/21/98 +lazy_umount_symlink() +{ + local symlink=$SCRATCH_MNT/$seq.testdir_symlink + echo "# lazy umount a symlink" >>$seqres.full + _scratch_mount 2>&1 | tee -a $seqres.full + mkdir -p $SCRATCH_MNT/testdir + rm -f $symlink + ln -s $SCRATCH_MNT/testdir $symlink + + $UMOUNT_PROG -l $symlink >>$seqres.full 2>&1 + # umount $SCRATCH_MNT should not be blocked + _scratch_unmount 2>&1 | tee -a $seqres.full +} + +echo "Silence is golden" + +mount_nonexistent_mnt +mount_free_loopdev +mount_wrong_fstype + +umount_symlink_device +umount_toolong_name +lazy_umount_symlink + +status=0 +exit
tests/generic/067.out new file +2 -0
@@ -0,0 +1,2 @@ +QA output created by 067 +Silence is golden
tests/generic/group +1 -0
@@ -69,6 +69,7 @@ 064 auto quick prealloc 065 metadata auto quick 066 metadata auto quick +067 auto quick mount 068 other auto freeze dangerous stress 069 rw udf auto quick 070 attr udf auto quick stress
Signature · 1 line
1.8.3.1
PATCH 2/5 generic: test quota handling on remount ro failure
In reply to Eryu GuanRemount ro should not turn qouta off unconditionally, even remount ro failed, also kernel should not oops on the next succeeded remount ro.
--- tests/generic/071 | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++ tests/generic/071.out | 3 +++ tests/generic/group | 1 + 3 files changed, 73 insertions(+) create mode 100755 tests/generic/071 create mode 100644 tests/generic/071.out
tests/generic/071 new file +69 -0
@@ -0,0 +1,69 @@ +#! /bin/bash +# FS QA Test No. 071 +# +# Test quota handling on remount ro failure +# +#----------------------------------------------------------------------- +# Copyright (c) 2015 Red Hat Inc. 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() +{ + cd / + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/quota + +# real QA test starts here + +# Modify as appropriate. +_supported_fs generic +_supported_os Linux +_require_test +_require_scratch +_require_quota + +rm -f $seqres.full + +_scratch_mkfs >>$seqres.full 2>&1 +_scratch_mount "-o usrquota,grpquota" + +quotacheck -ug $SCRATCH_MNT >/dev/null 2>&1 +quotaon $SCRATCH_MNT >/dev/null 2>&1 + +# first remount ro with a bad option, a failed remount ro should not disable quota +_scratch_mount "-o remount,ro,nosuchopt" >>$seqres.full 2>&1 +quotaon -p $SCRATCH_MNT | _filter_scratch +# second remount should succeed, no oops or hang expected +_scratch_mount "-o remount,ro" + +# success, all done +status=0 +exit
tests/generic/071.out new file +3 -0
@@ -0,0 +1,3 @@ +QA output created by 071 +group quota on SCRATCH_MNT (SCRATCH_DEV) is on +user quota on SCRATCH_MNT (SCRATCH_DEV) is on
tests/generic/group +1 -0
@@ -73,6 +73,7 @@ 068 other auto freeze dangerous stress 069 rw udf auto quick 070 attr udf auto quick stress +071 auto quick quota 074 rw udf auto 075 rw udf auto quick 076 metadata rw udf auto quick stress
Signature · 1 line
1.8.3.1
PATCH 3/5 generic: test hardlink to unlinked file
In reply to Eryu GuanKernel commit
aae8a97 fs: Don't allow to create hardlink for deleted file
disabled hardlink to unlinked file.
Test the race between link and unlink, which could end up adding link count to an unlinked file and leading to fs corruption on xfs.
Test case was originally written by Eric Sandeen.
--- tests/generic/072 | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++ tests/generic/072.out | 2 ++ tests/generic/group | 1 + 3 files changed, 102 insertions(+) create mode 100755 tests/generic/072 create mode 100644 tests/generic/072.out
tests/generic/072 new file +99 -0
@@ -0,0 +1,99 @@ +#! /bin/bash +# FS QA Test No. 072 +# +# Test hardlink to unlinked file. +# +# Regression test for commit: +# aae8a97 fs: Don't allow to create hardlink for deleted file +# +#----------------------------------------------------------------------- +# Copyright (c) 2015 Red Hat Inc. 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() +{ + cd / + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +# real QA test starts here + +# Modify as appropriate. +_supported_fs generic +_supported_os Linux +_require_test + +link_unlink_storm() +{ + local src=$1 + local target=$2 + + while true; do + ln -f $src $target >/dev/null 2>&1 + rm -f $target >/dev/null 2>&1 + done +} + +rm -f $seqres.full +nr_cpu=`$here/src/feature -o` +echo "Silence is golden" + +# create, open & unlinked files so unlinked inode list is not empty +for i in `seq 1 64`; do + testfile=$TEST_DIR/$seq.unlinked.$i + touch $testfile + tail -f $testfile & + tail_pids="$tail_pids $!" + rm -f $testfile +done + +# start link/unlink storm +src=$TEST_DIR/$seq.target +touch $testfile +for i in `seq 1 $nr_cpu`; do + target=$TEST_DIR/$seq.target.link.$i + link_unlink_storm $src $target & + link_pids="$link_pids $!" +done + +# remove & re-create target to race with link/unlink +while true; do + rm -f $src + touch $src +done & +sleep 5 +kill $! >/dev/null 2>&1 + +kill $tail_pids $link_pids >/dev/null 2>&1 +wait $tail_pids $link_pids + +# all done, no oops/hang expected, _check_filesystems checks TEST_DEV after test +status=0 +exit
tests/generic/072.out new file +2 -0
@@ -0,0 +1,2 @@ +QA output created by 072 +Silence is golden
tests/generic/group +1 -0
@@ -74,6 +74,7 @@ 069 rw udf auto quick 070 attr udf auto quick stress 071 auto quick quota +072 auto metadata 074 rw udf auto 075 rw udf auto quick 076 metadata rw udf auto quick stress
Signature · 1 line
1.8.3.1
PATCH 4/5 shared: test truncate orphan inodes when mounting extN
In reply to Eryu Guanext4 should hold i_mutex when truncating orhpan inodes, or a WARNING would be triggered. This commit fixed this issue.
721e3eb ext4: lock i_mutex when truncating orphan inodes
Though it's an ext4 specific issue, there's no harm to test on ext2/3 too, as debugfs is used to set orphan inode list.
This test is based on a script from Lukas Czerner.
--- tests/shared/001 | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/shared/001.out | 2 ++ tests/shared/group | 1 + 3 files changed, 74 insertions(+) create mode 100755 tests/shared/001 create mode 100644 tests/shared/001.out
tests/shared/001 new file +71 -0
@@ -0,0 +1,71 @@ +#! /bin/bash +# FS QA Test No. 005 +# +# Test truncate orphan inodes when mounting extN. +# ext4 used to hit WARNING, this commit fixed the issue +# +# 721e3eb ext4: lock i_mutex when truncating orphan inodes +# +#----------------------------------------------------------------------- +# Copyright (c) 2015 Red Hat Inc. 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() +{ + cd / + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +# real QA test starts here +_supported_fs ext2 ext3 ext4 +_supported_os Linux +_require_scratch + +rm -f $seqres.full +echo "Silence is golden" + +_scratch_mkfs_sized $((16*1024*1024)) >>$seqres.full 2>&1 +_scratch_mount + +# create a file and get its inode number, usually it's 12, but to be accurate +testfile=$SCRATCH_MNT/testfile +touch $testfile +inode=`ls -i $testfile | awk '{print $1}'` + +# add the inode in orphan inode list +_scratch_unmount +debugfs -w -R "set_super_value last_orphan $inode" $SCRATCH_DEV \ + >>$seqres.full 2>&1 + +# mount again to truncate orphan inode, _check_dmesg will catch the WARNING +_scratch_mount + +status=0 +exit
tests/shared/001.out new file +2 -0
@@ -0,0 +1,2 @@ +QA output created by 001 +Silence is golden
tests/shared/group +1 -0
@@ -3,6 +3,7 @@ # - do not start group names with a digit # - comment line before each group is "new" description # +001 auto quick 006 auto enospc 032 mkfs auto quick 051 acl udf auto quick
Signature · 1 line
1.8.3.1
PATCH 5/5 generic: test fs freeze/unfreeze and mount/umount race
In reply to Eryu GuanExercise fs freeze/unfreeze and mount/umount race, which could lead to use-after-free oops.
This commit fixed the issue:
1494583 fix get_active_super()/umount() race
This test case is based on a script from Monakhov Dmitriy.
--- tests/generic/073 | 98 +++++++++++++++++++++++++++++++++++++++++++++++++++ tests/generic/073.out | 2 ++ tests/generic/group | 1 + 3 files changed, 101 insertions(+) create mode 100755 tests/generic/073 create mode 100644 tests/generic/073.out
tests/generic/073 new file +98 -0
@@ -0,0 +1,98 @@ +#! /bin/bash +# FS QA Test No. 073 +# +# Exercise fs freeze/unfreeze and mount/umount race, which could lead to +# use-after-free oops. +# +# This commit fixed the issue: +# 1494583 fix get_active_super()/umount() race +# +#----------------------------------------------------------------------- +# Copyright (c) 2015 Red Hat Inc. 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() +{ + cd / + rm -f $tmp.* + cleanup_dmdev +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +# real QA test starts here +_supported_fs generic +_supported_os Linux +_require_scratch +_require_block_device $SCRATCH_DEV +_require_command $DMSETUP_PROG +_require_freeze + +setup_dmdev() +{ + table="0 $size_in_sector linear $SCRATCH_DEV 0" + $DMSETUP_PROG create $node --table "$table" >>$seqres.full 2>&1 + $DMSETUP_PROG mknodes >/dev/null 2>&1 +} + +cleanup_dmdev() +{ + # in case it's still suspended and/or mounted + $DMSETUP_PROG resume $lvdev >/dev/null 2>&1 + $UMOUNT_PROG $lvdev >/dev/null 2>&1 + + $DMSETUP_PROG remove $node >>$seqres.full 2>&1 + $DMSETUP_PROG mknodes >/dev/null 2>&1 +} + +rm -f $seqres.full +echo "Silence is golden" + +size=$((256 * 1024 * 1024)) +size_in_sector=$((size / 512)) +_scratch_mkfs_sized $size >>$seqres.full 2>&1 + +node=$seq-test +lvdev=/dev/mapper/$node +setup_dmdev + +for ((i=0; i<100; i++)); do + $DMSETUP_PROG suspend $lvdev >/dev/null 2>&1 + $DMSETUP_PROG resume $lvdev >/dev/null 2>&1 +done & +pid=$! +for ((i=0; i<100; i++)); do + $MOUNT_PROG $lvdev $SCRATCH_MNT >/dev/null 2>&1 + $UMOUNT_PROG $lvdev >/dev/null 2>&1 +done & +pid="$pid $!" + +wait $pid + +status=0 +exit
tests/generic/073.out new file +2 -0
@@ -0,0 +1,2 @@ +QA output created by 073 +Silence is golden
tests/generic/group +1 -0
@@ -75,6 +75,7 @@ 070 attr udf auto quick stress 071 auto quick quota 072 auto metadata +073 auto freeze mount 074 rw udf auto 075 rw udf auto quick 076 metadata rw udf auto quick stress
Signature · 1 line
1.8.3.1