All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/4] generic: test quota handling on remount ro failure
@ 2015-04-03  7:15 Eryu Guan
  2015-04-03  7:17 ` [PATCH v3 2/4] generic: test hardlink to unlinked file Eryu Guan
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Eryu Guan @ 2015-04-03  7:15 UTC (permalink / raw)
  To: fstests; +Cc: Eryu Guan

Remount ro should not turn qouta off unconditionally, even remount ro
failed, also kernel should not oops on the next succeeded remount ro.

Signed-off-by: Eryu Guan <eguan@redhat.com>
---
v2:
- rebase and re-numbered to generic/082
- add comments to quotacheck and quotaon
- add comments to the first remount,ro with unknown option
- fail the test if the second remount,ro failed

 tests/generic/082     | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/082.out |  3 +++
 tests/generic/group   |  1 +
 3 files changed, 77 insertions(+)
 create mode 100755 tests/generic/082
 create mode 100644 tests/generic/082.out

diff --git a/tests/generic/082 b/tests/generic/082
new file mode 100755
index 0000000..ca77c25
--- /dev/null
+++ b/tests/generic/082
@@ -0,0 +1,73 @@
+#! /bin/bash
+# FS QA Test No. 082
+#
+# 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
+_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"
+
+# xfs doesn't need these setups and quotacheck even fails on xfs, so just
+# redirect the output to $seqres.full for debug purpose and ignore the results,
+# as we check the quota status later anyway.
+quotacheck -ug $SCRATCH_MNT >>$seqres.full 2>&1
+quotaon $SCRATCH_MNT >>$seqres.full 2>&1
+
+# first remount ro with a bad option, a failed remount ro should not disable
+# quota, but currently xfs doesn't fail in this case, the unknown option is
+# just ignored, but quota is still on. This may change in future, let's
+# re-consider the case then.
+_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" || _fail "second remount,ro failed"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/082.out b/tests/generic/082.out
new file mode 100644
index 0000000..1acc7e4
--- /dev/null
+++ b/tests/generic/082.out
@@ -0,0 +1,3 @@
+QA output created by 082
+group quota on SCRATCH_MNT (SCRATCH_DEV) is on
+user quota on SCRATCH_MNT (SCRATCH_DEV) is on
diff --git a/tests/generic/group b/tests/generic/group
index 63b883c..4fe2189 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -84,6 +84,7 @@
 079 acl attr ioctl metadata auto quick
 080 auto quick
 081 auto quick
+082 auto quick
 083 rw auto enospc stress
 088 perms auto quick
 089 metadata auto
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v3 2/4] generic: test hardlink to unlinked file
  2015-04-03  7:15 [PATCH v2 1/4] generic: test quota handling on remount ro failure Eryu Guan
@ 2015-04-03  7:17 ` Eryu Guan
  2015-04-07 13:15   ` Brian Foster
  2015-04-03  7:18 ` [PATCH v2 3/4] shared: test truncate orphan inodes when mounting extN Eryu Guan
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 7+ messages in thread
From: Eryu Guan @ 2015-04-03  7:17 UTC (permalink / raw)
  To: fstests; +Cc: Eryu Guan

Kernel 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.

Signed-off-by: Eryu Guan <eguan@redhat.com>
---
v3:
- rebase and re-numbered to generic/084
- sleep 1 before removing all files being tailed

v2:
- create different link file in each iteration in link_unlink_storm(), which
  is confirmed to be able to reproduce the original corruption
- remove all newly created & tail'ed files at last, out of the loop, to avoid
  tail & rm race
- iterate $nr_cpu times to do the link_unlink_storm, not a fixed number
- add to quick group

 tests/generic/084     | 104 ++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/084.out |   2 +
 tests/generic/group   |   1 +
 3 files changed, 107 insertions(+)
 create mode 100755 tests/generic/084
 create mode 100644 tests/generic/084.out

diff --git a/tests/generic/084 b/tests/generic/084
new file mode 100755
index 0000000..3fec6c2
--- /dev/null
+++ b/tests/generic/084
@@ -0,0 +1,104 @@
+#! /bin/bash
+# FS QA Test No. 084
+#
+# 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
+_supported_fs generic
+_supported_os Linux
+_require_scratch
+
+link_unlink_storm()
+{
+	local src=$1
+	local target=$2
+	local i=0
+
+	while true; do
+		ln -f $src $target.$i >/dev/null 2>&1
+		rm -f $target.$i >/dev/null 2>&1
+		let i=i+1
+	done
+}
+
+rm -f $seqres.full
+nr_cpu=`$here/src/feature -o`
+echo "Silence is golden"
+
+_scratch_mkfs >>$seqres.full 2>&1
+_scratch_mount
+
+# create, open & unlinked files so unlinked inode list is not empty
+for i in `seq 1 $nr_cpu`; do
+	testfile=$SCRATCH_MNT/$seq.unlinked.$i
+	touch $testfile
+	tail -f $testfile &
+	tail_pids="$tail_pids $!"
+done
+# give tail some time to open the file before the file is removed
+sleep 1
+rm -f $SCRATCH_MNT/$seq.unlinked.*
+
+# start link/unlink storm
+src=$SCRATCH_MNT/$seq.target
+touch $src
+for i in `seq 1 $nr_cpu`; do
+	target=$SCRATCH_MNT/$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 SCRATCH_DEV after test
+status=0
+exit
diff --git a/tests/generic/084.out b/tests/generic/084.out
new file mode 100644
index 0000000..022f013
--- /dev/null
+++ b/tests/generic/084.out
@@ -0,0 +1,2 @@
+QA output created by 084
+Silence is golden
diff --git a/tests/generic/group b/tests/generic/group
index 4fe2189..5cbc1fe 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -86,6 +86,7 @@
 081 auto quick
 082 auto quick
 083 rw auto enospc stress
+084 auto metadata quick
 088 perms auto quick
 089 metadata auto
 091 rw auto quick
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 3/4] shared: test truncate orphan inodes when mounting extN
  2015-04-03  7:15 [PATCH v2 1/4] generic: test quota handling on remount ro failure Eryu Guan
  2015-04-03  7:17 ` [PATCH v3 2/4] generic: test hardlink to unlinked file Eryu Guan
@ 2015-04-03  7:18 ` Eryu Guan
  2015-04-03  7:18 ` [PATCH v3 4/4] generic: test fs freeze/unfreeze and mount/umount race Eryu Guan
  2015-04-07 13:15 ` [PATCH v2 1/4] generic: test quota handling on remount ro failure Brian Foster
  3 siblings, 0 replies; 7+ messages in thread
From: Eryu Guan @ 2015-04-03  7:18 UTC (permalink / raw)
  To: fstests; +Cc: linux-ext4, Eryu Guan, Lukas Czerner

ext4 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.

Cc: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
---
v2:
- fix wrong seq number at the beginning of the test

 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

diff --git a/tests/shared/001 b/tests/shared/001
new file mode 100755
index 0000000..49991fd
--- /dev/null
+++ b/tests/shared/001
@@ -0,0 +1,71 @@
+#! /bin/bash
+# FS QA Test No. 001
+#
+# 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
diff --git a/tests/shared/001.out b/tests/shared/001.out
new file mode 100644
index 0000000..88678b8
--- /dev/null
+++ b/tests/shared/001.out
@@ -0,0 +1,2 @@
+QA output created by 001
+Silence is golden
diff --git a/tests/shared/group b/tests/shared/group
index 429f2b4..0134f81 100644
--- a/tests/shared/group
+++ b/tests/shared/group
@@ -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
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v3 4/4] generic: test fs freeze/unfreeze and mount/umount race
  2015-04-03  7:15 [PATCH v2 1/4] generic: test quota handling on remount ro failure Eryu Guan
  2015-04-03  7:17 ` [PATCH v3 2/4] generic: test hardlink to unlinked file Eryu Guan
  2015-04-03  7:18 ` [PATCH v2 3/4] shared: test truncate orphan inodes when mounting extN Eryu Guan
@ 2015-04-03  7:18 ` Eryu Guan
  2015-04-07 13:15   ` Brian Foster
  2015-04-07 13:15 ` [PATCH v2 1/4] generic: test quota handling on remount ro failure Brian Foster
  3 siblings, 1 reply; 7+ messages in thread
From: Eryu Guan @ 2015-04-03  7:18 UTC (permalink / raw)
  To: fstests; +Cc: Eryu Guan

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

This test case is based on a script from Monakhov Dmitriy.

Signed-off-by: Eryu Guan <eguan@redhat.com>
---
v3:
- rebase and re-numbered to generic/085
- add more comments to explain why results of suspend/resume, mount/umount are ignored

v2:
- add comments to explain dmsetup is used not xfs_freeze to freeze filesystem
- detect failures in setup phase, so test exits not continus with errors

 tests/generic/085     | 106 ++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/085.out |   2 +
 tests/generic/group   |   1 +
 3 files changed, 109 insertions(+)
 create mode 100755 tests/generic/085
 create mode 100644 tests/generic/085.out

diff --git a/tests/generic/085 b/tests/generic/085
new file mode 100755
index 0000000..8398752
--- /dev/null
+++ b/tests/generic/085
@@ -0,0 +1,106 @@
+#! /bin/bash
+# FS QA Test No. 085
+#
+# 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
+	return $?
+}
+
+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 || _fail "setup dm device failed"
+
+# take use of dmsetup suspend to freeze the fs.
+# xfs_freeze/fsfreeze cannot be used in this test, because it can possibly
+# freeze the root fs of the host when SCRATCH_MNT is not mounted
+#
+# And the results of the racing commands (suspend/resume, mount/umount) are not
+# important, as long as they're racing with each other. So just throw away the
+# outputs and ignore the results.
+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
diff --git a/tests/generic/085.out b/tests/generic/085.out
new file mode 100644
index 0000000..76aef1a
--- /dev/null
+++ b/tests/generic/085.out
@@ -0,0 +1,2 @@
+QA output created by 085
+Silence is golden
diff --git a/tests/generic/group b/tests/generic/group
index 5cbc1fe..a96b901 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -87,6 +87,7 @@
 082 auto quick
 083 rw auto enospc stress
 084 auto metadata quick
+085 auto freeze mount
 088 perms auto quick
 089 metadata auto
 091 rw auto quick
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 1/4] generic: test quota handling on remount ro failure
  2015-04-03  7:15 [PATCH v2 1/4] generic: test quota handling on remount ro failure Eryu Guan
                   ` (2 preceding siblings ...)
  2015-04-03  7:18 ` [PATCH v3 4/4] generic: test fs freeze/unfreeze and mount/umount race Eryu Guan
@ 2015-04-07 13:15 ` Brian Foster
  3 siblings, 0 replies; 7+ messages in thread
From: Brian Foster @ 2015-04-07 13:15 UTC (permalink / raw)
  To: Eryu Guan; +Cc: fstests

On Fri, Apr 03, 2015 at 03:15:51PM +0800, Eryu Guan wrote:
> Remount ro should not turn qouta off unconditionally, even remount ro
> failed, also kernel should not oops on the next succeeded remount ro.
> 
> Signed-off-by: Eryu Guan <eguan@redhat.com>
> ---

Looks good to me:

Reviewed-by: Brian Foster <bfoster@redhat.com>

> v2:
> - rebase and re-numbered to generic/082
> - add comments to quotacheck and quotaon
> - add comments to the first remount,ro with unknown option
> - fail the test if the second remount,ro failed
> 
>  tests/generic/082     | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++
>  tests/generic/082.out |  3 +++
>  tests/generic/group   |  1 +
>  3 files changed, 77 insertions(+)
>  create mode 100755 tests/generic/082
>  create mode 100644 tests/generic/082.out
> 
> diff --git a/tests/generic/082 b/tests/generic/082
> new file mode 100755
> index 0000000..ca77c25
> --- /dev/null
> +++ b/tests/generic/082
> @@ -0,0 +1,73 @@
> +#! /bin/bash
> +# FS QA Test No. 082
> +#
> +# 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
> +_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"
> +
> +# xfs doesn't need these setups and quotacheck even fails on xfs, so just
> +# redirect the output to $seqres.full for debug purpose and ignore the results,
> +# as we check the quota status later anyway.
> +quotacheck -ug $SCRATCH_MNT >>$seqres.full 2>&1
> +quotaon $SCRATCH_MNT >>$seqres.full 2>&1
> +
> +# first remount ro with a bad option, a failed remount ro should not disable
> +# quota, but currently xfs doesn't fail in this case, the unknown option is
> +# just ignored, but quota is still on. This may change in future, let's
> +# re-consider the case then.
> +_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" || _fail "second remount,ro failed"
> +
> +# success, all done
> +status=0
> +exit
> diff --git a/tests/generic/082.out b/tests/generic/082.out
> new file mode 100644
> index 0000000..1acc7e4
> --- /dev/null
> +++ b/tests/generic/082.out
> @@ -0,0 +1,3 @@
> +QA output created by 082
> +group quota on SCRATCH_MNT (SCRATCH_DEV) is on
> +user quota on SCRATCH_MNT (SCRATCH_DEV) is on
> diff --git a/tests/generic/group b/tests/generic/group
> index 63b883c..4fe2189 100644
> --- a/tests/generic/group
> +++ b/tests/generic/group
> @@ -84,6 +84,7 @@
>  079 acl attr ioctl metadata auto quick
>  080 auto quick
>  081 auto quick
> +082 auto quick
>  083 rw auto enospc stress
>  088 perms auto quick
>  089 metadata auto
> -- 
> 1.8.3.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe fstests" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v3 2/4] generic: test hardlink to unlinked file
  2015-04-03  7:17 ` [PATCH v3 2/4] generic: test hardlink to unlinked file Eryu Guan
@ 2015-04-07 13:15   ` Brian Foster
  0 siblings, 0 replies; 7+ messages in thread
From: Brian Foster @ 2015-04-07 13:15 UTC (permalink / raw)
  To: Eryu Guan; +Cc: fstests

On Fri, Apr 03, 2015 at 03:17:20PM +0800, Eryu Guan wrote:
> Kernel 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.
> 
> Signed-off-by: Eryu Guan <eguan@redhat.com>
> ---

Looks good and runs fine for me now:

Reviewed-by: Brian Foster <bfoster@redhat.com>

> v3:
> - rebase and re-numbered to generic/084
> - sleep 1 before removing all files being tailed
> 
> v2:
> - create different link file in each iteration in link_unlink_storm(), which
>   is confirmed to be able to reproduce the original corruption
> - remove all newly created & tail'ed files at last, out of the loop, to avoid
>   tail & rm race
> - iterate $nr_cpu times to do the link_unlink_storm, not a fixed number
> - add to quick group
> 
>  tests/generic/084     | 104 ++++++++++++++++++++++++++++++++++++++++++++++++++
>  tests/generic/084.out |   2 +
>  tests/generic/group   |   1 +
>  3 files changed, 107 insertions(+)
>  create mode 100755 tests/generic/084
>  create mode 100644 tests/generic/084.out
> 
> diff --git a/tests/generic/084 b/tests/generic/084
> new file mode 100755
> index 0000000..3fec6c2
> --- /dev/null
> +++ b/tests/generic/084
> @@ -0,0 +1,104 @@
> +#! /bin/bash
> +# FS QA Test No. 084
> +#
> +# 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
> +_supported_fs generic
> +_supported_os Linux
> +_require_scratch
> +
> +link_unlink_storm()
> +{
> +	local src=$1
> +	local target=$2
> +	local i=0
> +
> +	while true; do
> +		ln -f $src $target.$i >/dev/null 2>&1
> +		rm -f $target.$i >/dev/null 2>&1
> +		let i=i+1
> +	done
> +}
> +
> +rm -f $seqres.full
> +nr_cpu=`$here/src/feature -o`
> +echo "Silence is golden"
> +
> +_scratch_mkfs >>$seqres.full 2>&1
> +_scratch_mount
> +
> +# create, open & unlinked files so unlinked inode list is not empty
> +for i in `seq 1 $nr_cpu`; do
> +	testfile=$SCRATCH_MNT/$seq.unlinked.$i
> +	touch $testfile
> +	tail -f $testfile &
> +	tail_pids="$tail_pids $!"
> +done
> +# give tail some time to open the file before the file is removed
> +sleep 1
> +rm -f $SCRATCH_MNT/$seq.unlinked.*
> +
> +# start link/unlink storm
> +src=$SCRATCH_MNT/$seq.target
> +touch $src
> +for i in `seq 1 $nr_cpu`; do
> +	target=$SCRATCH_MNT/$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 SCRATCH_DEV after test
> +status=0
> +exit
> diff --git a/tests/generic/084.out b/tests/generic/084.out
> new file mode 100644
> index 0000000..022f013
> --- /dev/null
> +++ b/tests/generic/084.out
> @@ -0,0 +1,2 @@
> +QA output created by 084
> +Silence is golden
> diff --git a/tests/generic/group b/tests/generic/group
> index 4fe2189..5cbc1fe 100644
> --- a/tests/generic/group
> +++ b/tests/generic/group
> @@ -86,6 +86,7 @@
>  081 auto quick
>  082 auto quick
>  083 rw auto enospc stress
> +084 auto metadata quick
>  088 perms auto quick
>  089 metadata auto
>  091 rw auto quick
> -- 
> 1.8.3.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe fstests" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v3 4/4] generic: test fs freeze/unfreeze and mount/umount race
  2015-04-03  7:18 ` [PATCH v3 4/4] generic: test fs freeze/unfreeze and mount/umount race Eryu Guan
@ 2015-04-07 13:15   ` Brian Foster
  0 siblings, 0 replies; 7+ messages in thread
From: Brian Foster @ 2015-04-07 13:15 UTC (permalink / raw)
  To: Eryu Guan; +Cc: fstests

On Fri, Apr 03, 2015 at 03:18:34PM +0800, Eryu Guan wrote:
> 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
> 
> This test case is based on a script from Monakhov Dmitriy.
> 
> Signed-off-by: Eryu Guan <eguan@redhat.com>
> ---

Reviewed-by: Brian Foster <bfoster@redhat.com>

> v3:
> - rebase and re-numbered to generic/085
> - add more comments to explain why results of suspend/resume, mount/umount are ignored
> 
> v2:
> - add comments to explain dmsetup is used not xfs_freeze to freeze filesystem
> - detect failures in setup phase, so test exits not continus with errors
> 
>  tests/generic/085     | 106 ++++++++++++++++++++++++++++++++++++++++++++++++++
>  tests/generic/085.out |   2 +
>  tests/generic/group   |   1 +
>  3 files changed, 109 insertions(+)
>  create mode 100755 tests/generic/085
>  create mode 100644 tests/generic/085.out
> 
> diff --git a/tests/generic/085 b/tests/generic/085
> new file mode 100755
> index 0000000..8398752
> --- /dev/null
> +++ b/tests/generic/085
> @@ -0,0 +1,106 @@
> +#! /bin/bash
> +# FS QA Test No. 085
> +#
> +# 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
> +	return $?
> +}
> +
> +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 || _fail "setup dm device failed"
> +
> +# take use of dmsetup suspend to freeze the fs.
> +# xfs_freeze/fsfreeze cannot be used in this test, because it can possibly
> +# freeze the root fs of the host when SCRATCH_MNT is not mounted
> +#
> +# And the results of the racing commands (suspend/resume, mount/umount) are not
> +# important, as long as they're racing with each other. So just throw away the
> +# outputs and ignore the results.
> +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
> diff --git a/tests/generic/085.out b/tests/generic/085.out
> new file mode 100644
> index 0000000..76aef1a
> --- /dev/null
> +++ b/tests/generic/085.out
> @@ -0,0 +1,2 @@
> +QA output created by 085
> +Silence is golden
> diff --git a/tests/generic/group b/tests/generic/group
> index 5cbc1fe..a96b901 100644
> --- a/tests/generic/group
> +++ b/tests/generic/group
> @@ -87,6 +87,7 @@
>  082 auto quick
>  083 rw auto enospc stress
>  084 auto metadata quick
> +085 auto freeze mount
>  088 perms auto quick
>  089 metadata auto
>  091 rw auto quick
> -- 
> 1.8.3.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe fstests" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-04-07 13:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-03  7:15 [PATCH v2 1/4] generic: test quota handling on remount ro failure Eryu Guan
2015-04-03  7:17 ` [PATCH v3 2/4] generic: test hardlink to unlinked file Eryu Guan
2015-04-07 13:15   ` Brian Foster
2015-04-03  7:18 ` [PATCH v2 3/4] shared: test truncate orphan inodes when mounting extN Eryu Guan
2015-04-03  7:18 ` [PATCH v3 4/4] generic: test fs freeze/unfreeze and mount/umount race Eryu Guan
2015-04-07 13:15   ` Brian Foster
2015-04-07 13:15 ` [PATCH v2 1/4] generic: test quota handling on remount ro failure Brian Foster

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.