Skip to contentSkip to conversation

xfstests: new btrfs stress test cases

PATCH Superseded Eryu Guan 4 participants 27 messages Aug 20, 2014 – Aug 21, 2014 Btrfs file system

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
author
#1 lore raw

cover xfstests: new btrfs stress test cases

In reply to Eryu Guan

This patchset add new stress test cases for btrfs by running two different btrfs operations simultaneously under fsstress to ensure btrfs doesn't hang or oops in such situations. btrfs scrub and btrfs check will be run after each test.

The test matrix is the combination of 6 btrfs operations:

balance
create/mount/umount/delete subvolume replace device
scrub
defrag
remount with different compress algorithms

Short descriptions:

	057: balance-subvolume
	058: balance-scrub
	059: balance-defrag
	060: balance-remount
	061: balance-replace
	062: subvolume-replace
	063: subvolume-scrub
	064: subvolume-defrag
	065: subvolume-remount
	066: replace-scrub
	067: replace-defrag
	068: replace-remount
	069: scrub-defrag
	070: scrub-remount
	071: defrag-remount

Some issues I've seen:

1. subvolume cannot be mounted with selinux context, so you'll see such logs in dmesg

SELinux: mount invalid. Same superblock, different security settings for (dev dm-8, type btrfs)

I've reported the bug to btrfs list, see [BUG] cannot mount subvolume with selinux context

2. btrfs replace operation always returns ENOENT if balance is running So in 061.full you'll see

ERROR: ioctl(DEV_REPLACE_START) failed on "/mnt/testarea/scratch": No such file or directory, no error

Not sure if it's btrfs bug, at least I think the error code is misleading

3. replace operation hangs the kernel(3.16-rc4+) with fsstress running So case 062/066/067/068 will hang

This is my first attemp to add these tests, any comments are welcomed!

Thanks,
Eryu Guan

Eryu Guan (15):
btrfs: new test to run btrfs balance and subvolume test simultaneously
btrfs: new test to run btrfs balance and scrub simltaneously
btrfs: new test to run btrfs balance and defrag operations simultaneously
btrfs: new case to run btrfs balance and remount with different compress algorithms
btrfs: new case to run btrfs balance and device replace simultaneously
btrfs: new case to run btrfs subvolume create/delete operations and device replace simultaneously
btrfs: new case to run btrfs subvolume create/delete operations and scrub simultaneously
btrfs: new case to run btrfs subvolume create/delete and defrag operations simultaneously
btrfs: new case to run subvolume create/delete and remount with different compress algorithms
btrfs: new case to run device replace and scrub operations simultaneously
btrfs: new case to run device replace and defrag operations simultaneously
btrfs: new case to run device replace and remount with different compress algorithms simultaneously
btrfs: new case to run btrfs scrub and defrag operations simultaneously
btrfs: new case to run btrfs scrub and remount with different compress algorithms simultaneously
btrfs: new case to run defrag and remount with different compress algorithms simultaneously

 common/rc           |  24 ++++++++
 tests/btrfs/057     | 147 ++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/057.out |   2 +
 tests/btrfs/058     | 141 +++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/058.out |   2 +
 tests/btrfs/059     | 150 +++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/059.out |   2 +
 tests/btrfs/060     | 142 +++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/060.out |   2 +
 tests/btrfs/061     | 161 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/061.out |   2 +
 tests/btrfs/062     | 167 ++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/062.out |   2 +
 tests/btrfs/063     | 146 ++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/063.out |   2 +
 tests/btrfs/064     | 155 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/064.out |   2 +
 tests/btrfs/065     | 148 +++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/065.out |   2 +
 tests/btrfs/066     | 161 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/066.out |   2 +
 tests/btrfs/067     | 171 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/067.out |   2 +
 tests/btrfs/068     | 163 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/068.out |   2 +
 tests/btrfs/069     | 150 +++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/069.out |   2 +
 tests/btrfs/070     | 142 +++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/070.out |   2 +
 tests/btrfs/071     | 152 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/071.out |   2 +
 tests/btrfs/group   |  15 +++++
 32 files changed, 2365 insertions(+)
 create mode 100755 tests/btrfs/057
 create mode 100644 tests/btrfs/057.out
 create mode 100755 tests/btrfs/058
 create mode 100644 tests/btrfs/058.out
 create mode 100755 tests/btrfs/059
 create mode 100644 tests/btrfs/059.out
 create mode 100755 tests/btrfs/060
 create mode 100644 tests/btrfs/060.out
 create mode 100755 tests/btrfs/061
 create mode 100644 tests/btrfs/061.out
 create mode 100755 tests/btrfs/062
 create mode 100644 tests/btrfs/062.out
 create mode 100755 tests/btrfs/063
 create mode 100644 tests/btrfs/063.out
 create mode 100755 tests/btrfs/064
 create mode 100644 tests/btrfs/064.out
 create mode 100755 tests/btrfs/065
 create mode 100644 tests/btrfs/065.out
 create mode 100755 tests/btrfs/066
 create mode 100644 tests/btrfs/066.out
 create mode 100755 tests/btrfs/067
 create mode 100644 tests/btrfs/067.out
 create mode 100755 tests/btrfs/068
 create mode 100644 tests/btrfs/068.out
 create mode 100755 tests/btrfs/069
 create mode 100644 tests/btrfs/069.out
 create mode 100755 tests/btrfs/070
 create mode 100644 tests/btrfs/070.out
 create mode 100755 tests/btrfs/071
 create mode 100644 tests/btrfs/071.out
Signature · 1 line
1.8.3.1
author
#2 lore raw

PATCH 1/15 btrfs: new test to run btrfs balance and subvolume test simultaneously

In reply to Eryu Guan

Run btrfs balance and subvolume create/mount/umount/delete simultaneously, with fsstress running in background.

---
 tests/btrfs/057     | 147 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/057.out |   2 +
 tests/btrfs/group   |   1 +
 3 files changed, 150 insertions(+)
 create mode 100755 tests/btrfs/057
 create mode 100644 tests/btrfs/057.out
tests/btrfs/057 new file +147 -0
new file mode 100755
index 0000000..2f507a7
@@ -0,0 +1,147 @@
+#! /bin/bash
+# FSQA Test No. btrfs/057
+#
+# Run btrfs balance and subvolume create/mount/umount/delete simultaneously,
+# with fsstress running in background.
+#
+#-----------------------------------------------------------------------
+# Copyright (C) 2014 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
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	rm -fr $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_fs btrfs
+_supported_os Linux
+_require_scratch
+_require_scratch_dev_pool 4
+
+rm -f $seqres.full
+
+# test case array
+tcs=(
+	"-m single -d single"
+	"-m dup -d single"
+	"-m raid0 -d raid0"
+	"-m raid1 -d raid0"
+	"-m raid1 -d raid1"
+	"-m raid10 -d raid10"
+	"-m raid5 -d raid5"
+	"-m raid6 -d raid6"
+)
+
+run_test()
+{
+	local mkfs_opts=$1
+	local saved_mkfs_opts=$MKFS_OPTIONS
+	local subvol_mnt=$tmp.mnt
+
+	echo "Test $mkfs_opts" >>$seqres.full
+
+	MKFS_OPTIONS="$MKFS_OPTIONS $mkfs_opts"
+	# dup only works on single device
+	if [[ "$mkfs_opts" =~ dup ]]; then
+		_scratch_mkfs >>$seqres.full 2>&1
+	else
+		_scratch_pool_mkfs >>$seqres.full 2>&1
+	fi
+	ret=$?
+	MKFS_OPTIONS=$saved_mkfs_opts
+	# make sure we created btrfs with desired options
+	if [ $ret -ne 0 ]; then
+		echo "mkfs $mkfs_opts failed"
+		return
+	fi
+
+	_scratch_mount >>$seqres.full 2>&1
+
+	args=`_scale_fsstress_args -p 20 -n 100 $FSSTRESS_AVOID -d $SCRATCH_MNT/stressdir`
+	echo "Run fsstress $args" >>$seqres.full
+	$FSSTRESS_PROG $args >/dev/null 2>&1 &
+	fsstress_pid=$!
+
+	echo -n "Start balance worker: " >>$seqres.full
+	(
+		while true; do
+			$BTRFS_UTIL_PROG balance start $SCRATCH_MNT
+		done
+	) >/dev/null 2>&1 &
+	balance_pid=$!
+	echo "$balance_pid" >>$seqres.full
+
+	echo -n "Start subvolume worker: " >>$seqres.full
+	mkdir -p $subvol_mnt
+	(
+		while true; do
+			$BTRFS_UTIL_PROG subvolume create $SCRATCH_MNT/subvol_$$
+			$MOUNT_PROG -o subvol=subvol_$$ $SCRATCH_DEV $subvol_mnt
+			$UMOUNT_PROG $subvol_mnt
+			$BTRFS_UTIL_PROG subvolume delete $SCRATCH_MNT/subvol_$$
+		done
+	) >/dev/null 2>&1 &
+	subvol_pid=$!
+	echo "$subvol_pid" >>$seqres.full
+
+	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
+	wait $fsstress_pid
+
+	kill $balance_pid $subvol_pid
+	wait
+	# the balance process might be still in D state and cannot be killed
+	# which could block umount, wait for it to finish
+	while ps aux | grep "balance start" | grep -qv grep; do
+		sleep 1
+	done
+
+	echo "Scrub the filesystem" >>$seqres.full
+	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
+	if [ $? -ne 0 ]; then
+		echo "Scrub find errors in \"$mkfs_opts\" test" | tee -a $seqres.full
+	fi
+
+	$BTRFS_UTIL_PROG filesystem sync $SCRATCH_MNT >/dev/null 2>&1
+	# in case the subvolume is still mounted
+	$UMOUNT_PROG $subvol_mnt >/dev/null 2>&1
+	_scratch_unmount
+	_check_scratch_fs
+}
+
+echo "Silence is golden"
+for t in "${tcs[@]}"; do
+	run_test "$t"
+done
+
+status=0
+exit
tests/btrfs/057.out new file +2 -0
new file mode 100644
index 0000000..185023c
@@ -0,0 +1,2 @@
+QA output created by 057
+Silence is golden
tests/btrfs/group +1 -0
index 2da7127..08fd54a 100644
@@ -59,3 +59,4 @@
 054 auto quick
 055 auto quick
 056 auto quick
+057 auto stress balance subvol
Signature · 1 line
1.8.3.1
author
#9 lore raw

PATCH 2/15 btrfs: new test to run btrfs balance and scrub simltaneously

In reply to Eryu Guan

Run btrfs balance and scrub operations simultaneously with fsstress running in background.

---
 tests/btrfs/058     | 141 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/058.out |   2 +
 tests/btrfs/group   |   1 +
 3 files changed, 144 insertions(+)
 create mode 100755 tests/btrfs/058
 create mode 100644 tests/btrfs/058.out
tests/btrfs/058 new file +141 -0
new file mode 100755
index 0000000..999727d
@@ -0,0 +1,141 @@
+#! /bin/bash
+# FSQA Test No. btrfs/058
+#
+# Run btrfs balance and scrub operations simultaneously with fsstress
+# running in background.
+#
+#-----------------------------------------------------------------------
+# Copyright (C) 2014 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
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	rm -fr $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_fs btrfs
+_supported_os Linux
+_require_scratch
+_require_scratch_dev_pool 4
+
+rm -f $seqres.full
+
+# test case array
+tcs=(
+	"-m single -d single"
+	"-m dup -d single"
+	"-m raid0 -d raid0"
+	"-m raid1 -d raid0"
+	"-m raid1 -d raid1"
+	"-m raid10 -d raid10"
+	"-m raid5 -d raid5"
+	"-m raid6 -d raid6"
+)
+
+run_test()
+{
+	local mkfs_opts=$1
+	local saved_mkfs_opts=$MKFS_OPTIONS
+
+	echo "Test $mkfs_opts" >>$seqres.full
+
+	MKFS_OPTIONS="$MKFS_OPTIONS $mkfs_opts"
+	# dup only works on single device
+	if [[ "$mkfs_opts" =~ dup ]]; then
+		_scratch_mkfs >>$seqres.full 2>&1
+	else
+		_scratch_pool_mkfs >>$seqres.full 2>&1
+	fi
+	local ret=$?
+	MKFS_OPTIONS=$saved_mkfs_opts
+	# make sure we created btrfs with desired options
+	if [ $ret -ne 0 ]; then
+		echo "mkfs $mkfs_opts failed"
+		return
+	fi
+	_scratch_mount >>$seqres.full 2>&1
+
+	args=`_scale_fsstress_args -p 20 -n 100 $FSSTRESS_AVOID -d $SCRATCH_MNT/stressdir`
+	echo "Run fsstress $args" >>$seqres.full
+	$FSSTRESS_PROG $args >/dev/null 2>&1 &
+	fsstress_pid=$!
+
+	echo -n "Start balance worker: " >>$seqres.full
+	(
+		while true; do
+			$BTRFS_UTIL_PROG balance start $SCRATCH_MNT
+		done
+	) >/dev/null 2>&1 &
+	balance_pid=$!
+	echo "$balance_pid" >>$seqres.full
+
+	echo -n "Start scrub worker: " >>$seqres.full
+	(
+		while true; do
+			$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
+		done
+	) &
+	scrub_pid=$!
+	echo "$scrub_pid" >>$seqres.full
+
+	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
+	wait $fsstress_pid
+	kill $balance_pid $scrub_pid
+	wait
+	# the balance/scrub process might be still in D state and cannot be killed
+	# which could block umount, wait for it to finish
+	while ps aux | grep "balance start" | grep -qv grep; do
+		sleep 1
+	done
+	while ps aux | grep "scrub start" | grep -qv grep; do
+		sleep 1
+	done
+
+	echo "Scrub the filesystem" >>$seqres.full
+	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
+	if [ $? -ne 0 ]; then
+		echo "Scrub find errors in \"$mkfs_opts\" test" | tee -a $seqres.full
+	fi
+
+	$BTRFS_UTIL_PROG filesystem sync $SCRATCH_MNT >/dev/null 2>&1
+	_scratch_unmount
+	_check_scratch_fs
+}
+
+echo "Silence is golden"
+for t in "${tcs[@]}"; do
+	run_test "$t"
+done
+
+status=0
+exit
tests/btrfs/058.out new file +2 -0
new file mode 100644
index 0000000..fb5ca60
@@ -0,0 +1,2 @@
+QA output created by 058
+Silence is golden
tests/btrfs/group +1 -0
index 08fd54a..c6b1baa 100644
@@ -60,3 +60,4 @@
 055 auto quick
 056 auto quick
 057 auto stress balance subvol
+058 auto stress balance scrub
Signature · 1 line
1.8.3.1
author
#10 lore raw

PATCH 3/15 btrfs: new test to run btrfs balance and defrag operations simultaneously

In reply to Eryu Guan

Run btrfs balance and defrag operations simultaneously with fsstress running in background.

---
 tests/btrfs/059     | 150 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/059.out |   2 +
 tests/btrfs/group   |   1 +
 3 files changed, 153 insertions(+)
 create mode 100755 tests/btrfs/059
 create mode 100644 tests/btrfs/059.out
tests/btrfs/059 new file +150 -0
new file mode 100755
index 0000000..897a300
@@ -0,0 +1,150 @@
+#! /bin/bash
+# FSQA Test No. btrfs/059
+#
+# Run btrfs balance and defrag operations simultaneously with fsstress
+# running in background.
+#
+#-----------------------------------------------------------------------
+# Copyright (C) 2014 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
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	rm -fr $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_fs btrfs
+_supported_os Linux
+_require_scratch
+_require_scratch_dev_pool 4
+
+rm -f $seqres.full
+
+# test case array
+tcs=(
+	"-m single -d single"
+	"-m dup -d single"
+	"-m raid0 -d raid0"
+	"-m raid1 -d raid0"
+	"-m raid1 -d raid1"
+	"-m raid10 -d raid10"
+	"-m raid5 -d raid5"
+	"-m raid6 -d raid6"
+)
+
+run_test()
+{
+	local mkfs_opts=$1
+	local with_compress=$2
+	local saved_mkfs_opts=$MKFS_OPTIONS
+
+	echo "Test $mkfs_opts with $with_compress" >>$seqres.full
+
+	MKFS_OPTIONS="$MKFS_OPTIONS $mkfs_opts"
+	# dup only works on single device
+	if [[ "$mkfs_opts" =~ dup ]]; then
+		_scratch_mkfs >>$seqres.full 2>&1
+	else
+		_scratch_pool_mkfs >>$seqres.full 2>&1
+	fi
+	local ret=$?
+	MKFS_OPTIONS=$saved_mkfs_opts
+	# make sure we created btrfs with desired options
+	if [ $ret -ne 0 ]; then
+		echo "mkfs $mkfs_opts failed"
+		return
+	fi
+	_scratch_mount >>$seqres.full 2>&1
+
+	args=`_scale_fsstress_args -p 20 -n 100 $FSSTRESS_AVOID -d $SCRATCH_MNT/stressdir`
+	echo "Run fsstress $args" >>$seqres.full
+	$FSSTRESS_PROG $args >/dev/null 2>&1 &
+	fsstress_pid=$!
+
+	echo -n "Start balance worker: " >>$seqres.full
+	(
+		while true; do
+			$BTRFS_UTIL_PROG balance start $SCRATCH_MNT
+		done
+	) >/dev/null 2>&1 &
+	balance_pid=$!
+	echo "$balance_pid" >>$seqres.full
+
+	echo -n "Start defrag worker: " >>$seqres.full
+	(
+		while true; do
+			if [ "$with_compress" == "nocompress" ]; then
+				find $SCRATCH_MNT \( -type f -o -type d \) -exec \
+					$BTRFS_UTIL_PROG filesystem defrag {} \; >>$seqres.full 2>&1
+			else
+				find $SCRATCH_MNT \( -type f -o -type d \) -exec \
+					$BTRFS_UTIL_PROG filesystem defrag -clzo {} \; >>$seqres.full 2>&1
+				find $SCRATCH_MNT \( -type f -o -type d \) -exec \
+					$BTRFS_UTIL_PROG filesystem defrag -czlib {} \; >>$seqres.full 2>&1
+			fi
+		done
+	) &
+	defrag_pid=$!
+	echo "$defrag_pid" >>$seqres.full
+
+	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
+	wait $fsstress_pid
+	kill $balance_pid $defrag_pid
+	wait
+	# wait for the balance and defrag operations to finish
+	while ps aux | grep "balance start" | grep -qv grep; do
+		sleep 1
+	done
+	while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do
+		sleep 1
+	done
+
+	echo "Scrub the filesystem" >>$seqres.full
+	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
+	if [ $? -ne 0 ]; then
+		echo "Scrub find errors in \"$mkfs_opts\" test" | tee -a $seqres.full
+	fi
+
+	$BTRFS_UTIL_PROG filesystem sync $SCRATCH_MNT >/dev/null 2>&1
+	_scratch_unmount
+	_check_scratch_fs
+}
+
+echo "Silence is golden"
+for t in "${tcs[@]}"; do
+	run_test "$t" nocompress
+	run_test "$t" compress
+done
+
+status=0
+exit
tests/btrfs/059.out new file +2 -0
new file mode 100644
index 0000000..36ebeea
@@ -0,0 +1,2 @@
+QA output created by 059
+Silence is golden
tests/btrfs/group +1 -0
index c6b1baa..73bae0f 100644
@@ -61,3 +61,4 @@
 056 auto quick
 057 auto stress balance subvol
 058 auto stress balance scrub
+059 auto stress balance defrag compress
Signature · 1 line
1.8.3.1
author
#11 lore raw

PATCH 4/15 btrfs: new case to run btrfs balance and remount with different compress algorithms

In reply to Eryu Guan

Run btrfs balance and remount with different compress algorithms simultaneously, with fsstress running in background.

---
 tests/btrfs/060     | 142 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/060.out |   2 +
 tests/btrfs/group   |   1 +
 3 files changed, 145 insertions(+)
 create mode 100755 tests/btrfs/060
 create mode 100644 tests/btrfs/060.out
tests/btrfs/060 new file +142 -0
new file mode 100755
index 0000000..8410a99
@@ -0,0 +1,142 @@
+#! /bin/bash
+# FSQA Test No. btrfs/060
+#
+# Run btrfs balance and remount with different compress algorithms
+# simultaneously, with fsstress running in background.
+#
+#-----------------------------------------------------------------------
+# Copyright (C) 2014 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
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	rm -fr $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_fs btrfs
+_supported_os Linux
+_require_scratch
+_require_scratch_dev_pool 4
+
+rm -f $seqres.full
+
+# test case array
+tcs=(
+	"-m single -d single"
+	"-m dup -d single"
+	"-m raid0 -d raid0"
+	"-m raid1 -d raid0"
+	"-m raid1 -d raid1"
+	"-m raid10 -d raid10"
+	"-m raid5 -d raid5"
+	"-m raid6 -d raid6"
+)
+
+run_test()
+{
+	local mkfs_opts=$1
+	local saved_mkfs_opts=$MKFS_OPTIONS
+
+	echo "Test $mkfs_opts" >>$seqres.full
+
+	MKFS_OPTIONS="$MKFS_OPTIONS $mkfs_opts"
+	# dup only works on single device
+	if [[ "$mkfs_opts" =~ dup ]]; then
+		_scratch_mkfs >>$seqres.full 2>&1
+	else
+		_scratch_pool_mkfs >>$seqres.full 2>&1
+	fi
+	local ret=$?
+	MKFS_OPTIONS=$saved_mkfs_opts
+	# make sure we created btrfs with desired options
+	if [ $ret -ne 0 ]; then
+		echo "mkfs $mkfs_opts failed"
+		return
+	fi
+	_scratch_mount >>$seqres.full 2>&1
+
+	args=`_scale_fsstress_args -p 20 -n 100 $FSSTRESS_AVOID -d $SCRATCH_MNT/stressdir`
+	echo "Run fsstress $args" >>$seqres.full
+	$FSSTRESS_PROG $args >/dev/null 2>&1 &
+	fsstress_pid=$!
+
+	echo -n "Start balance worker: " >>$seqres.full
+	(
+		while true; do
+			$BTRFS_UTIL_PROG balance start $SCRATCH_MNT
+		done
+	) >/dev/null 2>&1 &
+	balance_pid=$!
+	echo "$balance_pid" >>$seqres.full
+
+	echo -n "Start remount worker: " >>$seqres.full
+	(
+		while true; do
+			for algo in no zlib lzo; do
+				$MOUNT_PROG -o remount,compress=$algo $SCRATCH_MNT >>$seqres.full 2>&1
+			done
+		done
+	) >/dev/null 2>&1 &
+	remount_pid=$!
+	echo "$remount_pid" >>$seqres.full
+
+	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
+	wait $fsstress_pid
+	kill $balance_pid $remount_pid
+	wait
+	# wait for the balance and remount loop to finish
+	while ps aux | grep "balance start" | grep -qv grep; do
+		sleep 1
+	done
+	while ps aux | grep "mount.*$SCRATCH_MNT" | grep -qv grep; do
+		sleep 1
+	done
+
+	echo "Scrub the filesystem" >>$seqres.full
+	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
+	if [ $? -ne 0 ]; then
+		echo "Scrub find errors in \"$mkfs_opts\" test" | tee -a $seqres.full
+	fi
+
+	$BTRFS_UTIL_PROG filesystem sync $SCRATCH_MNT >/dev/null 2>&1
+	_scratch_unmount
+	_check_scratch_fs
+}
+
+echo "Silence is golden"
+for t in "${tcs[@]}"; do
+	run_test "$t"
+done
+
+status=0
+exit
tests/btrfs/060.out new file +2 -0
new file mode 100644
index 0000000..8ffce4d
@@ -0,0 +1,2 @@
+QA output created by 060
+Silence is golden
tests/btrfs/group +1 -0
index 73bae0f..5971993 100644
@@ -62,3 +62,4 @@
 057 auto stress balance subvol
 058 auto stress balance scrub
 059 auto stress balance defrag compress
+060 auto stress balance remount compress
Signature · 1 line
1.8.3.1
author
#12 lore raw

PATCH 5/15 btrfs: new case to run btrfs balance and device replace simultaneously

In reply to Eryu Guan

Run btrfs balance and replace operations simultaneously with fsstress running in background.

---
 common/rc           |  24 ++++++++
 tests/btrfs/061     | 161 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/061.out |   2 +
 tests/btrfs/group   |   1 +
 4 files changed, 188 insertions(+)
 create mode 100755 tests/btrfs/061
 create mode 100644 tests/btrfs/061.out
common/rc +24 -0
index 7ea1614..9212547 100644
@@ -1985,6 +1985,24 @@ _require_scratch_dev_pool()
 	done
 }
 
+# ensure devices in SCRATCH_DEV_POOL are of the same size
+# must be called after _require_scratch_dev_pool
+_require_scratch_dev_pool_equal_size()
+{
+	local _size
+	local _newsize
+	local _dev
+
+	# SCRATCH_DEV has been set to the first device in SCRATCH_DEV_POOL
+	_size=`_get_device_size $SCRATCH_DEV`
+	for _dev in $SCRATCH_DEV_POOL; do
+		_newsize=`_get_device_size $_dev`
+		if [ $_size -ne $_newsize ]; then
+			_notrun "This test requires devices in SCRATCH_DEV_POOL have the same size"
+		fi
+	done
+}
+
 # We will check if the device is deletable
 _require_deletable_scratch_dev_pool()
 {
@@ -2231,6 +2249,12 @@ _require_btrfs_fs_feature()
 		_notrun "Feature $feat not supported by the available btrfs version"
 }
 
+# return device size in kb
+_get_device_size()
+{
+	grep `_short_dev $1` /proc/partitions | awk '{print $3}'
+}
+
 init_rc()
 {
 	if [ "$iam" == new ]
tests/btrfs/061 new file +161 -0

161 lines not on this page · raw message

tests/btrfs/061.out new file +2 -0
new file mode 100644
index 0000000..273be9e
@@ -0,0 +1,2 @@
+QA output created by 061
+Silence is golden
tests/btrfs/group +1 -0
index 5971993..36fee18 100644
@@ -63,3 +63,4 @@
 058 auto stress balance scrub
 059 auto stress balance defrag compress
 060 auto stress balance remount compress
+061 auto stress balance replace
Signature · 1 line
1.8.3.1
author
#13 lore raw

PATCH 6/15 btrfs: new case to run btrfs subvolume create/delete operations and device replace simultaneously

In reply to Eryu Guan

Run btrfs subvolume create/mount/umount/delete and device replace operation simultaneously, with fsstress running in background.

---
 tests/btrfs/062     | 167 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/062.out |   2 +
 tests/btrfs/group   |   1 +
 3 files changed, 170 insertions(+)
 create mode 100755 tests/btrfs/062
 create mode 100644 tests/btrfs/062.out
tests/btrfs/062 new file +167 -0
new file mode 100755
index 0000000..d110af8
@@ -0,0 +1,167 @@
+#! /bin/bash
+# FSQA Test No. btrfs/062
+#
+# Run btrfs subvolume create/mount/umount/delete and device replace
+# operation simultaneously, with fsstress running in background.
+#
+#-----------------------------------------------------------------------
+# Copyright (C) 2014 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
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	rm -fr $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_fs btrfs
+_supported_os Linux
+_require_scratch
+_require_scratch_dev_pool 5
+_require_scratch_dev_pool_equal_size
+
+rm -f $seqres.full
+
+# test case array
+tcs=(
+	"-m single -d single"
+	"-m raid0 -d raid0"
+	"-m raid1 -d raid0"
+	"-m raid1 -d raid1"
+	"-m raid10 -d raid10"
+#	"-m raid5 -d raid5"	# raid5 does not support replace operation yet
+#	"-m raid6 -d raid6"	# raid6 does not support replace operation yet
+)
+
+run_test()
+{
+	local mkfs_opts=$1
+	local saved_mkfs_opts=$MKFS_OPTIONS
+	local saved_scratch_dev_pool=$SCRATCH_DEV_POOL
+	local subvol_mnt=$tmp.mnt
+
+	echo "Test $mkfs_opts" >>$seqres.full
+
+	# remove the last device from the SCRATCH_DEV_POOL list so
+	# _scratch_pool_mkfs won't use all devices in pool
+	local last_dev="`echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $NF}'`"
+	SCRATCH_DEV_POOL=`echo $SCRATCH_DEV_POOL | sed -e "s# *$last_dev *##"`
+	MKFS_OPTIONS="$MKFS_OPTIONS $mkfs_opts"
+	_scratch_pool_mkfs >>$seqres.full 2>&1
+	# make sure we created btrfs with desired options
+	if [ $? -ne 0 ]; then
+		echo "mkfs $mkfs_opts failed"
+		MKFS_OPTIONS=$saved_mkfs_opts
+		SCRATCH_DEV_POOL=$saved_scratch_dev_pool
+		return
+	fi
+
+	_scratch_mount >>$seqres.full 2>&1
+
+	args=`_scale_fsstress_args -p 20 -n 100 $FSSTRESS_AVOID -d $SCRATCH_MNT/stressdir`
+	echo "Run fsstress $args" >>$seqres.full
+	$FSSTRESS_PROG $args >/dev/null 2>&1 &
+	fsstress_pid=$!
+
+	echo -n "Start subvolume worker: " >>$seqres.full
+	mkdir -p $subvol_mnt
+	(
+		while true; do
+			$BTRFS_UTIL_PROG subvolume create $SCRATCH_MNT/subvol_$$
+			$MOUNT_PROG -o subvol=subvol_$$ $SCRATCH_DEV $subvol_mnt
+			$UMOUNT_PROG $subvol_mnt
+			$BTRFS_UTIL_PROG subvolume delete $SCRATCH_MNT/subvol_$$
+		done
+	) >/dev/null 2>&1 &
+	subvol_pid=$!
+	echo "$subvol_pid" >>$seqres.full
+
+	echo -n "Start replace worker: " >>$seqres.full
+	(
+		# take the last device as free device
+		free_dev=$last_dev
+		# replace all devices in btrfs_devices in turn
+		# do not replace SCRATCH_DEV which will be used in _scratch_mount
+		# and _check_scratch_fs etc.
+		btrfs_devices=`echo $SCRATCH_DEV_POOL | sed -e "s# *$SCRATCH_DEV *##"`
+		# set first device in btrfs_devices as first src_dev
+		src_dev=`echo $btrfs_devices | $AWK_PROG '{print $1}'`
+		echo "btrfs_devices=$btrfs_devices" >>$seqres.full
+		echo "free_dev=$free_dev, src_dev=$src_dev" >>$seqres.full
+		while true; do
+			echo "Replacing $src_dev with $free_dev" >>$seqres.full
+			$BTRFS_UTIL_PROG replace start -fB $src_dev $free_dev $SCRATCH_MNT >>$seqres.full 2>&1
+			if [ $? -ne 0 ]; then
+				continue
+			fi
+			btrfs_devices="$btrfs_devices $free_dev"
+			btrfs_devices=`echo $btrfs_devices | sed -e "s# *$src_dev *##"`
+			free_dev=$src_dev
+			src_dev=`echo $btrfs_devices | $AWK_PROG '{print $1}'`
+		done
+	) >/dev/null 2>&1 &
+	replace_pid=$!
+	echo "$replace_pid" >>$seqres.full
+
+	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
+	wait $fsstress_pid
+
+	kill $subvol_pid $replace_pid
+	wait
+	# the replace process might be still in D state and cannot be killed
+	# which could block umount, wait for it to finish
+	while ps aux | grep "replace start" | grep -qv grep; do
+		sleep 1
+	done
+
+	echo "Scrub the filesystem" >>$seqres.full
+	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
+	if [ $? -ne 0 ]; then
+		echo "Scrub find errors in \"$mkfs_opts\" test" | tee -a $seqres.full
+	fi
+
+	MKFS_OPTIONS=$saved_mkfs_opts
+	SCRATCH_DEV_POOL=$saved_scratch_dev_pool
+	$BTRFS_UTIL_PROG filesystem sync $SCRATCH_MNT >/dev/null 2>&1
+	# in case the subvolume is still mounted
+	$UMOUNT_PROG $subvol_mnt >/dev/null 2>&1
+	_scratch_unmount
+	_check_scratch_fs
+}
+
+echo "Silence is golden"
+for t in "${tcs[@]}"; do
+	run_test "$t"
+done
+
+status=0
+exit
tests/btrfs/062.out new file +2 -0
new file mode 100644
index 0000000..a1578f4
@@ -0,0 +1,2 @@
+QA output created by 062
+Silence is golden
tests/btrfs/group +1 -0
index 36fee18..0000845 100644
@@ -64,3 +64,4 @@
 059 auto stress balance defrag compress
 060 auto stress balance remount compress
 061 auto stress balance replace
+062 auto stress subvol replace
Signature · 1 line
1.8.3.1
author
#14 lore raw

PATCH 7/15 btrfs: new case to run btrfs subvolume create/delete operations and scrub simultaneously

In reply to Eryu Guan

Run btrfs subvolume create/mount/umount/delete and btrfs scrub operation simultaneously, with fsstress running in background.

---
 tests/btrfs/063     | 146 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/063.out |   2 +
 tests/btrfs/group   |   1 +
 3 files changed, 149 insertions(+)
 create mode 100755 tests/btrfs/063
 create mode 100644 tests/btrfs/063.out
tests/btrfs/063 new file +146 -0
new file mode 100755
index 0000000..68e6a25
@@ -0,0 +1,146 @@
+#! /bin/bash
+# FSQA Test No. btrfs/063
+#
+# Run btrfs subvolume create/mount/umount/delete and btrfs scrub
+# operation simultaneously, with fsstress running in background.
+#
+#-----------------------------------------------------------------------
+# Copyright (C) 2014 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
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	rm -fr $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_fs btrfs
+_supported_os Linux
+_require_scratch
+_require_scratch_dev_pool 4
+
+rm -f $seqres.full
+
+# test case array
+tcs=(
+	"-m single -d single"
+	"-m dup -d single"
+	"-m raid0 -d raid0"
+	"-m raid1 -d raid0"
+	"-m raid1 -d raid1"
+	"-m raid10 -d raid10"
+	"-m raid5 -d raid5"
+	"-m raid6 -d raid6"
+)
+
+run_test()
+{
+	local mkfs_opts=$1
+	local saved_mkfs_opts=$MKFS_OPTIONS
+	local subvol_mnt=$tmp.mnt
+
+	echo "Test $mkfs_opts" >>$seqres.full
+
+	MKFS_OPTIONS="$MKFS_OPTIONS $mkfs_opts"
+	# dup only works on single device
+	if [[ "$mkfs_opts" =~ dup ]]; then
+		_scratch_mkfs >>$seqres.full 2>&1
+	else
+		_scratch_pool_mkfs >>$seqres.full 2>&1
+	fi
+	local ret=$?
+	MKFS_OPTIONS=$saved_mkfs_opts
+	# make sure we created btrfs with desired options
+	if [ $? -ne 0 ]; then
+		echo "mkfs $mkfs_opts failed"
+		return
+	fi
+	_scratch_mount >>$seqres.full 2>&1
+
+	args=`_scale_fsstress_args -p 20 -n 100 $FSSTRESS_AVOID -d $SCRATCH_MNT/stressdir`
+	echo "Run fsstress $args" >>$seqres.full
+	$FSSTRESS_PROG $args >/dev/null 2>&1 &
+	fsstress_pid=$!
+
+	echo -n "Start subvolume worker: " >>$seqres.full
+	mkdir -p $subvol_mnt
+	(
+		while true; do
+			$BTRFS_UTIL_PROG subvolume create $SCRATCH_MNT/subvol_$$
+			$MOUNT_PROG -o subvol=subvol_$$ $SCRATCH_DEV $subvol_mnt
+			$UMOUNT_PROG $subvol_mnt
+			$BTRFS_UTIL_PROG subvolume delete $SCRATCH_MNT/subvol_$$
+		done
+	) >/dev/null 2>&1 &
+	subvol_pid=$!
+	echo "$subvol_pid" >>$seqres.full
+
+	echo -n "Start scrub worker: " >>$seqres.full
+	(
+		while true; do
+			$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
+		done
+	) &
+	scrub_pid=$!
+	echo "$scrub_pid" >>$seqres.full
+
+	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
+	wait $fsstress_pid
+
+	kill $subvol_pid $scrub_pid
+	wait
+	# the scrub process might be still in D state and cannot be killed
+	# which could block umount, wait for it to finish
+	while ps aux | grep "scrub start" | grep -qv grep; do
+		sleep 1
+	done
+
+	echo "Scrub the filesystem" >>$seqres.full
+	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
+	if [ $? -ne 0 ]; then
+		echo "Scrub find errors in \"$mkfs_opts\" test" | tee -a $seqres.full
+	fi
+
+	$BTRFS_UTIL_PROG filesystem sync $SCRATCH_MNT >/dev/null 2>&1
+	# in case the subvolume is still mounted
+	$UMOUNT_PROG $subvol_mnt >/dev/null 2>&1
+	_scratch_unmount
+	_check_scratch_fs
+}
+
+echo "Silence is golden"
+for t in "${tcs[@]}"; do
+	run_test "$t"
+done
+
+status=0
+exit
tests/btrfs/063.out new file +2 -0
new file mode 100644
index 0000000..de35fc5
@@ -0,0 +1,2 @@
+QA output created by 063
+Silence is golden
tests/btrfs/group +1 -0
index 0000845..0000b9d 100644
@@ -65,3 +65,4 @@
 060 auto stress balance remount compress
 061 auto stress balance replace
 062 auto stress subvol replace
+063 auto stress subvol scrub
Signature · 1 line
1.8.3.1
author
#15 lore raw

PATCH 8/15 btrfs: new case to run btrfs subvolume create/delete and defrag operations simultaneously

In reply to Eryu Guan

Run btrfs subvolume create/mount/umount/delete and btrfs defrag operation simultaneously, with fsstress running in background.

---
 tests/btrfs/064     | 155 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/064.out |   2 +
 tests/btrfs/group   |   1 +
 3 files changed, 158 insertions(+)
 create mode 100755 tests/btrfs/064
 create mode 100644 tests/btrfs/064.out
tests/btrfs/064 new file +155 -0
new file mode 100755
index 0000000..b8009aa
@@ -0,0 +1,155 @@
+#! /bin/bash
+# FSQA Test No. btrfs/064
+#
+# Run btrfs subvolume create/mount/umount/delete and btrfs defrag
+# operation simultaneously, with fsstress running in background.
+#
+#-----------------------------------------------------------------------
+# Copyright (C) 2014 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
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	rm -fr $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_fs btrfs
+_supported_os Linux
+_require_scratch
+_require_scratch_dev_pool 4
+
+rm -f $seqres.full
+
+# test case array
+tcs=(
+	"-m single -d single"
+	"-m dup -d single"
+	"-m raid0 -d raid0"
+	"-m raid1 -d raid0"
+	"-m raid1 -d raid1"
+	"-m raid10 -d raid10"
+	"-m raid5 -d raid5"
+	"-m raid6 -d raid6"
+)
+
+run_test()
+{
+	local mkfs_opts=$1
+	local with_compress=$2
+	local saved_mkfs_opts=$MKFS_OPTIONS
+	local subvol_mnt=$tmp.mnt
+
+	echo "Test $mkfs_opts with $with_compress" >>$seqres.full
+
+	MKFS_OPTIONS="$MKFS_OPTIONS $mkfs_opts"
+	# dup only works on single device
+	if [[ "$mkfs_opts" =~ dup ]]; then
+		_scratch_mkfs >>$seqres.full 2>&1
+	else
+		_scratch_pool_mkfs >>$seqres.full 2>&1
+	fi
+	local ret=$?
+	MKFS_OPTIONS=$saved_mkfs_opts
+	# make sure we created btrfs with desired options
+	if [ $ret -ne 0 ]; then
+		echo "mkfs $mkfs_opts failed"
+		return
+	fi
+	_scratch_mount >>$seqres.full 2>&1
+
+	args=`_scale_fsstress_args -p 20 -n 100 $FSSTRESS_AVOID -d $SCRATCH_MNT/stressdir`
+	echo "Run fsstress $args" >>$seqres.full
+	$FSSTRESS_PROG $args >/dev/null 2>&1 &
+	fsstress_pid=$!
+
+	echo -n "Start subvolume worker: " >>$seqres.full
+	mkdir -p $subvol_mnt
+	(
+		while true; do
+			$BTRFS_UTIL_PROG subvolume create $SCRATCH_MNT/subvol_$$
+			$MOUNT_PROG -o subvol=subvol_$$ $SCRATCH_DEV $subvol_mnt
+			$UMOUNT_PROG $subvol_mnt
+			$BTRFS_UTIL_PROG subvolume delete $SCRATCH_MNT/subvol_$$
+		done
+	) >/dev/null 2>&1 &
+	subvol_pid=$!
+	echo "$subvol_pid" >>$seqres.full
+
+	echo -n "Start defrag worker: " >>$seqres.full
+	(
+		while true; do
+			if [ "$with_compress" == "nocompress" ]; then
+				find $SCRATCH_MNT \( -type f -o -type d \) -exec \
+					$BTRFS_UTIL_PROG filesystem defrag {} \; >>$seqres.full 2>&1
+			else
+				find $SCRATCH_MNT \( -type f -o -type d \) -exec \
+					$BTRFS_UTIL_PROG filesystem defrag -clzo {} \; >>$seqres.full 2>&1
+				find $SCRATCH_MNT \( -type f -o -type d \) -exec \
+					$BTRFS_UTIL_PROG filesystem defrag -czlib {} \; >>$seqres.full 2>&1
+			fi
+		done
+	) &
+	defrag_pid=$!
+	echo "$defrag_pid" >>$seqres.full
+
+	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
+	wait $fsstress_pid
+
+	kill $subvol_pid $defrag_pid
+	wait
+	# wait for btrfs defrag process to exit, otherwise it will block umount
+	while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do
+		sleep 1
+	done
+
+	echo "Scrub the filesystem" >>$seqres.full
+	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
+	if [ $? -ne 0 ]; then
+		echo "Scrub find errors in \"$mkfs_opts\" test" | tee -a $seqres.full
+	fi
+
+	$BTRFS_UTIL_PROG filesystem sync $SCRATCH_MNT >/dev/null 2>&1
+	# in case the subvolume is still mounted
+	$UMOUNT_PROG $subvol_mnt >/dev/null 2>&1
+	_scratch_unmount
+	_check_scratch_fs
+}
+
+echo "Silence is golden"
+for t in "${tcs[@]}"; do
+	run_test "$t" nocompress
+	run_test "$t" compress
+done
+
+status=0
+exit
tests/btrfs/064.out new file +2 -0
new file mode 100644
index 0000000..d907654
@@ -0,0 +1,2 @@
+QA output created by 064
+Silence is golden
tests/btrfs/group +1 -0
index 0000b9d..7c0a72e 100644
@@ -66,3 +66,4 @@
 061 auto stress balance replace
 062 auto stress subvol replace
 063 auto stress subvol scrub
+064 auto stress subvol defrag compress
Signature · 1 line
1.8.3.1
author
#16 lore raw

PATCH 9/15 btrfs: new case to run subvolume create/delete and remount with different compress algorithms

In reply to Eryu Guan

Run btrfs subvolume create/mount/umount/delete and remount with different compress algorithms simultaneously, with fsstress running in background.

---
 tests/btrfs/065     | 148 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/065.out |   2 +
 tests/btrfs/group   |   1 +
 3 files changed, 151 insertions(+)
 create mode 100755 tests/btrfs/065
 create mode 100644 tests/btrfs/065.out
tests/btrfs/065 new file +148 -0
new file mode 100755
index 0000000..6737cb1
@@ -0,0 +1,148 @@
+#! /bin/bash
+# FSQA Test No. btrfs/065
+#
+# Run btrfs subvolume create/mount/umount/delete and remount with
+# different compress algorithms simultaneously, with fsstress running
+# in background.
+#
+#-----------------------------------------------------------------------
+# Copyright (C) 2014 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
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	rm -fr $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_fs btrfs
+_supported_os Linux
+_require_scratch
+_require_scratch_dev_pool 4
+
+rm -f $seqres.full
+
+# test case array
+tcs=(
+	"-m single -d single"
+	"-m dup -d single"
+	"-m raid0 -d raid0"
+	"-m raid1 -d raid0"
+	"-m raid1 -d raid1"
+	"-m raid10 -d raid10"
+	"-m raid5 -d raid5"
+	"-m raid6 -d raid6"
+)
+
+run_test()
+{
+	local mkfs_opts=$1
+	local saved_mkfs_opts=$MKFS_OPTIONS
+	local subvol_mnt=$tmp.mnt
+
+	echo "Test $mkfs_opts with $with_compress" >>$seqres.full
+
+	MKFS_OPTIONS="$MKFS_OPTIONS $mkfs_opts"
+	# dup only works on single device
+	if [[ "$mkfs_opts" =~ dup ]]; then
+		_scratch_mkfs >>$seqres.full 2>&1
+	else
+		_scratch_pool_mkfs >>$seqres.full 2>&1
+	fi
+	local ret=$?
+	MKFS_OPTIONS=$saved_mkfs_opts
+	# make sure we created btrfs with desired options
+	if [ $ret -ne 0 ]; then
+		echo "mkfs $mkfs_opts failed"
+		return
+	fi
+	_scratch_mount >>$seqres.full 2>&1
+
+	args=`_scale_fsstress_args -p 20 -n 100 $FSSTRESS_AVOID -d $SCRATCH_MNT/stressdir`
+	echo "Run fsstress $args" >>$seqres.full
+	$FSSTRESS_PROG $args >/dev/null 2>&1 &
+	fsstress_pid=$!
+
+	echo -n "Start subvolume worker: " >>$seqres.full
+	mkdir -p $subvol_mnt
+	(
+		while true; do
+			$BTRFS_UTIL_PROG subvolume create $SCRATCH_MNT/subvol_$$
+			$MOUNT_PROG -o subvol=subvol_$$ $SCRATCH_DEV $subvol_mnt
+			$UMOUNT_PROG $subvol_mnt
+			$BTRFS_UTIL_PROG subvolume delete $SCRATCH_MNT/subvol_$$
+		done
+	) >/dev/null 2>&1 &
+	subvol_pid=$!
+	echo "$subvol_pid" >>$seqres.full
+
+	echo -n "Start remount worker: " >>$seqres.full
+	(
+		while true; do
+			for algo in no zlib lzo; do
+				$MOUNT_PROG -o remount,compress=$algo $SCRATCH_MNT >>$seqres.full 2>&1
+			done
+		done
+	) >/dev/null 2>&1 &
+	remount_pid=$!
+	echo "$remount_pid" >>$seqres.full
+
+	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
+	wait $fsstress_pid
+
+	kill $subvol_pid $remount_pid
+	wait
+	# wait for the remount loop process to finish
+	while ps aux | grep "mount.*$SCRATCH_MNT" | grep -qv grep; do
+		sleep 1
+	done
+
+	echo "Scrub the filesystem" >>$seqres.full
+	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
+	if [ $? -ne 0 ]; then
+		echo "Scrub find errors in \"$mkfs_opts\" test" | tee -a $seqres.full
+	fi
+
+	$BTRFS_UTIL_PROG filesystem sync $SCRATCH_MNT >/dev/null 2>&1
+	# in case the subvolume is still mounted
+	$UMOUNT_PROG $subvol_mnt >/dev/null 2>&1
+	_scratch_unmount
+	_check_scratch_fs
+}
+
+echo "Silence is golden"
+for t in "${tcs[@]}"; do
+	run_test "$t"
+done
+
+status=0
+exit
tests/btrfs/065.out new file +2 -0
new file mode 100644
index 0000000..94476cd
@@ -0,0 +1,2 @@
+QA output created by 065
+Silence is golden
tests/btrfs/group +1 -0
index 7c0a72e..70aa3c3 100644
@@ -67,3 +67,4 @@
 062 auto stress subvol replace
 063 auto stress subvol scrub
 064 auto stress subvol defrag compress
+065 auto stress subvol remount compress
Signature · 1 line
1.8.3.1
author
#17 lore raw

PATCH 10/15 btrfs: new case to run device replace and scrub operations simultaneously

In reply to Eryu Guan

Run btrfs replace operations and scrub simultaneously with fsstress running in background.

---
 tests/btrfs/066     | 161 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/066.out |   2 +
 tests/btrfs/group   |   1 +
 3 files changed, 164 insertions(+)
 create mode 100755 tests/btrfs/066
 create mode 100644 tests/btrfs/066.out
tests/btrfs/066 new file +161 -0
new file mode 100755
index 0000000..5d9a42d
@@ -0,0 +1,161 @@
+#! /bin/bash
+# FSQA Test No. btrfs/066
+#
+# Run btrfs replace operations and scrub simultaneously with fsstress
+# running in background.
+#
+#-----------------------------------------------------------------------
+# Copyright (C) 2014 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
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	rm -fr $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_fs btrfs
+_supported_os Linux
+_require_scratch
+_require_scratch_dev_pool 5
+_require_scratch_dev_pool_equal_size
+
+rm -f $seqres.full
+
+# test case array
+tcs=(
+	"-m single -d single"
+	"-m raid0 -d raid0"
+	"-m raid1 -d raid0"
+	"-m raid1 -d raid1"
+	"-m raid10 -d raid10"
+#	"-m raid5 -d raid5"	# raid5 does not support replace operation yet
+#	"-m raid6 -d raid6"	# raid6 does not support replace operation yet
+)
+
+run_test()
+{
+	local mkfs_opts=$1
+	local saved_mkfs_opts=$MKFS_OPTIONS
+	local saved_scratch_dev_pool=$SCRATCH_DEV_POOL
+
+	echo "Test $mkfs_opts" >>$seqres.full
+
+	# remove the last device from the SCRATCH_DEV_POOL list so
+	# _scratch_pool_mkfs won't use all devices in pool
+	local last_dev="`echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $NF}'`"
+	SCRATCH_DEV_POOL=`echo $SCRATCH_DEV_POOL | sed -e "s# *$last_dev *##"`
+	MKFS_OPTIONS="$MKFS_OPTIONS $mkfs_opts"
+	_scratch_pool_mkfs >>$seqres.full 2>&1
+	# make sure we created btrfs with desired options
+	if [ $? -ne 0 ]; then
+		echo "mkfs $mkfs_opts failed"
+		MKFS_OPTIONS=$saved_mkfs_opts
+		SCRATCH_DEV_POOL=$saved_scratch_dev_pool
+		return
+	fi
+	_scratch_mount >>$seqres.full 2>&1
+
+	args=`_scale_fsstress_args -p 20 -n 100 $FSSTRESS_AVOID -d $SCRATCH_MNT/stressdir`
+	echo "Run fsstress $args" >>$seqres.full
+	$FSSTRESS_PROG $args >/dev/null 2>&1 &
+	fsstress_pid=$!
+
+	echo -n "Start replace worker: " >>$seqres.full
+	(
+		# take the last device as free device
+		free_dev=$last_dev
+		# replace all devices in btrfs_devices in turn
+		# do not replace SCRATCH_DEV which will be used in _scratch_mount
+		# and _check_scratch_fs etc.
+		btrfs_devices=`echo $SCRATCH_DEV_POOL | sed -e "s# *$SCRATCH_DEV *##"`
+		# set first device in btrfs_devices as first src_dev
+		src_dev=`echo $btrfs_devices | $AWK_PROG '{print $1}'`
+		echo "btrfs_devices=$btrfs_devices" >>$seqres.full
+		echo "free_dev=$free_dev, src_dev=$src_dev" >>$seqres.full
+		while true; do
+			echo "Replacing $src_dev with $free_dev" >>$seqres.full
+			$BTRFS_UTIL_PROG replace start -fB $src_dev $free_dev $SCRATCH_MNT >>$seqres.full 2>&1
+			if [ $? -ne 0 ]; then
+				continue
+			fi
+			btrfs_devices="$btrfs_devices $free_dev"
+			btrfs_devices=`echo $btrfs_devices | sed -e "s# *$src_dev *##"`
+			free_dev=$src_dev
+			src_dev=`echo $btrfs_devices | $AWK_PROG '{print $1}'`
+		done
+	) >/dev/null 2>&1 &
+	replace_pid=$!
+	echo "$replace_pid" >>$seqres.full
+
+	echo -n "Start scrub worker: " >>$seqres.full
+	(
+		while true; do
+			$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
+		done
+	) &
+	scrub_pid=$!
+	echo "$scrub_pid" >>$seqres.full
+
+	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
+	wait $fsstress_pid
+	kill $replace_pid $scrub_pid
+	wait
+
+	# wait for the scrub and replace operations to finish
+	while ps aux | grep "scrub start" | grep -qv grep; do
+		sleep 1
+	done
+	while ps aux | grep "replace start" | grep -qv grep; do
+		sleep 1
+	done
+
+	echo "Scrub the filesystem" >>$seqres.full
+	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
+	if [ $? -ne 0 ]; then
+		echo "Scrub find errors in \"$mkfs_opts\" test" | tee -a $seqres.full
+	fi
+
+	MKFS_OPTIONS=$saved_mkfs_opts
+	SCRATCH_DEV_POOL=$saved_scratch_dev_pool
+	$BTRFS_UTIL_PROG filesystem sync $SCRATCH_MNT >/dev/null 2>&1
+	_scratch_unmount
+	_check_scratch_fs
+}
+
+echo "Silence is golden"
+for t in "${tcs[@]}"; do
+	run_test "$t"
+done
+
+status=0
+exit
tests/btrfs/066.out new file +2 -0
new file mode 100644
index 0000000..b60cc24
@@ -0,0 +1,2 @@
+QA output created by 066
+Silence is golden
tests/btrfs/group +1 -0
index 70aa3c3..1649351 100644
@@ -68,3 +68,4 @@
 063 auto stress subvol scrub
 064 auto stress subvol defrag compress
 065 auto stress subvol remount compress
+066 auto stress replace scrub
Signature · 1 line
1.8.3.1
author
#18 lore raw

PATCH 11/15 btrfs: new case to run device replace and defrag operations simultaneously

In reply to Eryu Guan

Run btrfs replace operations and defrag simultaneously with fsstress running in background.

---
 tests/btrfs/067     | 171 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/067.out |   2 +
 tests/btrfs/group   |   1 +
 3 files changed, 174 insertions(+)
 create mode 100755 tests/btrfs/067
 create mode 100644 tests/btrfs/067.out
tests/btrfs/067 new file +171 -0
new file mode 100755
index 0000000..477b85f
@@ -0,0 +1,171 @@
+#! /bin/bash
+# FSQA Test No. btrfs/067
+#
+# Run btrfs replace operations and defrag simultaneously with fsstress
+# running in background.
+#
+#-----------------------------------------------------------------------
+# Copyright (C) 2014 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
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	rm -fr $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_fs btrfs
+_supported_os Linux
+_require_scratch
+_require_scratch_dev_pool 5
+_require_scratch_dev_pool_equal_size
+
+rm -f $seqres.full
+
+# test case array
+tcs=(
+	"-m single -d single"
+	"-m raid0 -d raid0"
+	"-m raid1 -d raid0"
+	"-m raid1 -d raid1"
+	"-m raid10 -d raid10"
+#	"-m raid5 -d raid5"	# raid5 does not support replace operation yet
+#	"-m raid6 -d raid6"	# raid6 does not support replace operation yet
+)
+
+run_test()
+{
+	local mkfs_opts=$1
+	local with_compress=$2
+	local saved_mkfs_opts=$MKFS_OPTIONS
+	local saved_scratch_dev_pool=$SCRATCH_DEV_POOL
+
+	echo "Test $mkfs_opts with $with_compress" >>$seqres.full
+
+	# remove the last device from the SCRATCH_DEV_POOL list so
+	# _scratch_pool_mkfs won't use all devices in pool
+	local last_dev="`echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $NF}'`"
+	SCRATCH_DEV_POOL=`echo $SCRATCH_DEV_POOL | sed -e "s# *$last_dev *##"`
+	MKFS_OPTIONS="$MKFS_OPTIONS $mkfs_opts"
+	_scratch_pool_mkfs >>$seqres.full 2>&1
+	# make sure we created btrfs with desired options
+	if [ $? -ne 0 ]; then
+		echo "mkfs $mkfs_opts failed"
+		MKFS_OPTIONS=$saved_mkfs_opts
+		SCRATCH_DEV_POOL=$saved_scratch_dev_pool
+		return
+	fi
+	_scratch_mount >>$seqres.full 2>&1
+
+	args=`_scale_fsstress_args -p 20 -n 100 $FSSTRESS_AVOID -d $SCRATCH_MNT/stressdir`
+	echo "Run fsstress $args" >>$seqres.full
+	$FSSTRESS_PROG $args >/dev/null 2>&1 &
+	fsstress_pid=$!
+
+	echo -n "Start replace worker: " >>$seqres.full
+	(
+		# take the last device as free device
+		free_dev=$last_dev
+		# replace all devices in btrfs_devices in turn
+		# do not replace SCRATCH_DEV which will be used in _scratch_mount
+		# and _check_scratch_fs etc.
+		btrfs_devices=`echo $SCRATCH_DEV_POOL | sed -e "s# *$SCRATCH_DEV *##"`
+		# set first device in btrfs_devices as first src_dev
+		src_dev=`echo $btrfs_devices | $AWK_PROG '{print $1}'`
+		echo "btrfs_devices=$btrfs_devices" >>$seqres.full
+		echo "free_dev=$free_dev, src_dev=$src_dev" >>$seqres.full
+		while true; do
+			echo "Replacing $src_dev with $free_dev" >>$seqres.full
+			$BTRFS_UTIL_PROG replace start -fB $src_dev $free_dev $SCRATCH_MNT >>$seqres.full 2>&1
+			if [ $? -ne 0 ]; then
+				continue
+			fi
+			btrfs_devices="$btrfs_devices $free_dev"
+			btrfs_devices=`echo $btrfs_devices | sed -e "s# *$src_dev *##"`
+			free_dev=$src_dev
+			src_dev=`echo $btrfs_devices | $AWK_PROG '{print $1}'`
+		done
+	) >/dev/null 2>&1 &
+	replace_pid=$!
+	echo "$replace_pid" >>$seqres.full
+
+	echo -n "Start defrag worker: " >>$seqres.full
+	(
+		while true; do
+			if [ "$with_compress" == "nocompress" ]; then
+				find $SCRATCH_MNT \( -type f -o -type d \) -exec \
+					$BTRFS_UTIL_PROG filesystem defrag {} \; >>$seqres.full 2>&1
+			else
+				find $SCRATCH_MNT \( -type f -o -type d \) -exec \
+					$BTRFS_UTIL_PROG filesystem defrag -clzo {} \; >>$seqres.full 2>&1
+				find $SCRATCH_MNT \( -type f -o -type d \) -exec \
+					$BTRFS_UTIL_PROG filesystem defrag -czlib {} \; >>$seqres.full 2>&1
+			fi
+		done
+	) &
+	defrag_pid=$!
+	echo "$defrag_pid" >>$seqres.full
+
+	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
+	wait $fsstress_pid
+	kill $replace_pid $defrag_pid
+	wait
+
+	# wait for the defrag and replace operations to finish
+	while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do
+		sleep 1
+	done
+	while ps aux | grep "replace start" | grep -qv grep; do
+		sleep 1
+	done
+
+	echo "Scrub the filesystem" >>$seqres.full
+	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
+	if [ $? -ne 0 ]; then
+		echo "Scrub find errors in \"$mkfs_opts\" test" | tee -a $seqres.full
+	fi
+
+	MKFS_OPTIONS=$saved_mkfs_opts
+	SCRATCH_DEV_POOL=$saved_scratch_dev_pool
+	$BTRFS_UTIL_PROG filesystem sync $SCRATCH_MNT >/dev/null 2>&1
+	_scratch_unmount
+	_check_scratch_fs
+}
+
+echo "Silence is golden"
+for t in "${tcs[@]}"; do
+	run_test "$t" nocompress
+	run_test "$t" compress
+done
+
+status=0
+exit
tests/btrfs/067.out new file +2 -0
new file mode 100644
index 0000000..daa1545
@@ -0,0 +1,2 @@
+QA output created by 067
+Silence is golden
tests/btrfs/group +1 -0
index 1649351..e82244e 100644
@@ -69,3 +69,4 @@
 064 auto stress subvol defrag compress
 065 auto stress subvol remount compress
 066 auto stress replace scrub
+067 auto stress replace defrag compress
Signature · 1 line
1.8.3.1
author
#19 lore raw

PATCH 12/15 btrfs: new case to run device replace and remount with different compress algorithms simultaneously

In reply to Eryu Guan

Run btrfs replace operations and remount with different compress algorithms simultaneously with fsstress running in background.

---
 tests/btrfs/068     | 163 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/068.out |   2 +
 tests/btrfs/group   |   1 +
 3 files changed, 166 insertions(+)
 create mode 100755 tests/btrfs/068
 create mode 100644 tests/btrfs/068.out
tests/btrfs/068 new file +163 -0
new file mode 100755
index 0000000..c66dd80
@@ -0,0 +1,163 @@
+#! /bin/bash
+# FSQA Test No. btrfs/068
+#
+# Run btrfs replace operations and remount with different compress
+# algorithms simultaneously with fsstress running in background.
+#
+#-----------------------------------------------------------------------
+# Copyright (C) 2014 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
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	rm -fr $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_fs btrfs
+_supported_os Linux
+_require_scratch
+_require_scratch_dev_pool 5
+_require_scratch_dev_pool_equal_size
+
+rm -f $seqres.full
+
+# test case array
+tcs=(
+	"-m single -d single"
+	"-m raid0 -d raid0"
+	"-m raid1 -d raid0"
+	"-m raid1 -d raid1"
+	"-m raid10 -d raid10"
+#	"-m raid5 -d raid5"	# raid5 does not support replace operation yet
+#	"-m raid6 -d raid6"	# raid6 does not support replace operation yet
+)
+
+run_test()
+{
+	local mkfs_opts=$1
+	local saved_mkfs_opts=$MKFS_OPTIONS
+	local saved_scratch_dev_pool=$SCRATCH_DEV_POOL
+
+	echo "Test $mkfs_opts" >>$seqres.full
+
+	# remove the last device from the SCRATCH_DEV_POOL list so
+	# _scratch_pool_mkfs won't use all devices in pool
+	local last_dev="`echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $NF}'`"
+	SCRATCH_DEV_POOL=`echo $SCRATCH_DEV_POOL | sed -e "s# *$last_dev *##"`
+	MKFS_OPTIONS="$MKFS_OPTIONS $mkfs_opts"
+	_scratch_pool_mkfs >>$seqres.full 2>&1
+	# make sure we created btrfs with desired options
+	if [ $? -ne 0 ]; then
+		echo "mkfs $mkfs_opts failed"
+		MKFS_OPTIONS=$saved_mkfs_opts
+		SCRATCH_DEV_POOL=$saved_scratch_dev_pool
+		return
+	fi
+	_scratch_mount >>$seqres.full 2>&1
+
+	args=`_scale_fsstress_args -p 20 -n 100 $FSSTRESS_AVOID -d $SCRATCH_MNT/stressdir`
+	echo "Run fsstress $args" >>$seqres.full
+	$FSSTRESS_PROG $args >/dev/null 2>&1 &
+	fsstress_pid=$!
+
+	echo -n "Start replace worker: " >>$seqres.full
+	(
+		# take the last device as free device
+		free_dev=$last_dev
+		# replace all devices in btrfs_devices in turn
+		# do not replace SCRATCH_DEV which will be used in _scratch_mount
+		# and _check_scratch_fs etc.
+		btrfs_devices=`echo $SCRATCH_DEV_POOL | sed -e "s# *$SCRATCH_DEV *##"`
+		# set first device in btrfs_devices as first src_dev
+		src_dev=`echo $btrfs_devices | $AWK_PROG '{print $1}'`
+		echo "btrfs_devices=$btrfs_devices" >>$seqres.full
+		echo "free_dev=$free_dev, src_dev=$src_dev" >>$seqres.full
+		while true; do
+			echo "Replacing $src_dev with $free_dev" >>$seqres.full
+			$BTRFS_UTIL_PROG replace start -fB $src_dev $free_dev $SCRATCH_MNT >>$seqres.full 2>&1
+			if [ $? -ne 0 ]; then
+				continue
+			fi
+			btrfs_devices="$btrfs_devices $free_dev"
+			btrfs_devices=`echo $btrfs_devices | sed -e "s# *$src_dev *##"`
+			free_dev=$src_dev
+			src_dev=`echo $btrfs_devices | $AWK_PROG '{print $1}'`
+		done
+	) >/dev/null 2>&1 &
+	replace_pid=$!
+	echo "$replace_pid" >>$seqres.full
+
+	echo -n "Start remount worker: " >>$seqres.full
+	(
+		while true; do
+			for algo in no zlib lzo; do
+				$MOUNT_PROG -o remount,compress=$algo $SCRATCH_MNT >>$seqres.full 2>&1
+			done
+		done
+	) >/dev/null 2>&1 &
+	remount_pid=$!
+	echo "$remount_pid" >>$seqres.full
+
+	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
+	wait $fsstress_pid
+	kill $replace_pid $remount_pid
+	wait
+
+	# wait for the remount and replace operations to finish
+	while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do
+		sleep 1
+	done
+	while ps aux | grep "mount.*$SCRATCH_MNT" | grep -qv grep; do
+		sleep 1
+	done
+
+	echo "Scrub the filesystem" >>$seqres.full
+	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
+	if [ $? -ne 0 ]; then
+		echo "Scrub find errors in \"$mkfs_opts\" test" | tee -a $seqres.full
+	fi
+
+	MKFS_OPTIONS=$saved_mkfs_opts
+	SCRATCH_DEV_POOL=$saved_scratch_dev_pool
+	$BTRFS_UTIL_PROG filesystem sync $SCRATCH_MNT >/dev/null 2>&1
+	_scratch_unmount
+	_check_scratch_fs
+}
+
+echo "Silence is golden"
+for t in "${tcs[@]}"; do
+	run_test "$t"
+done
+
+status=0
+exit
tests/btrfs/068.out new file +2 -0
new file mode 100644
index 0000000..d10c9bd
@@ -0,0 +1,2 @@
+QA output created by 068
+Silence is golden
tests/btrfs/group +1 -0
index e82244e..7aa66ad 100644
@@ -70,3 +70,4 @@
 065 auto stress subvol remount compress
 066 auto stress replace scrub
 067 auto stress replace defrag compress
+068 auto stress replace remount compress
Signature · 1 line
1.8.3.1
author
#20 lore raw

PATCH 13/15 btrfs: new case to run btrfs scrub and defrag operations simultaneously

In reply to Eryu Guan

Run btrfs scrub and defrag operations simultaneously with fsstress running in background.

---
 tests/btrfs/069     | 150 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/069.out |   2 +
 tests/btrfs/group   |   1 +
 3 files changed, 153 insertions(+)
 create mode 100755 tests/btrfs/069
 create mode 100644 tests/btrfs/069.out
tests/btrfs/069 new file +150 -0
new file mode 100755
index 0000000..9d773b1
@@ -0,0 +1,150 @@
+#! /bin/bash
+# FSQA Test No. btrfs/069
+#
+# Run btrfs scrub and defrag operations simultaneously with fsstress
+# running in background.
+#
+#-----------------------------------------------------------------------
+# Copyright (C) 2014 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
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	rm -fr $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_fs btrfs
+_supported_os Linux
+_require_scratch
+_require_scratch_dev_pool 4
+
+rm -f $seqres.full
+
+# test case array
+tcs=(
+	"-m single -d single"
+	"-m dup -d single"
+	"-m raid0 -d raid0"
+	"-m raid1 -d raid0"
+	"-m raid1 -d raid1"
+	"-m raid10 -d raid10"
+	"-m raid5 -d raid5"
+	"-m raid6 -d raid6"
+)
+
+run_test()
+{
+	local mkfs_opts=$1
+	local with_compress=$2
+	local saved_mkfs_opts=$MKFS_OPTIONS
+
+	echo "Test $mkfs_opts with $with_compress" >>$seqres.full
+
+	MKFS_OPTIONS="$MKFS_OPTIONS $mkfs_opts"
+	# dup only works on single device
+	if [[ "$mkfs_opts" =~ dup ]]; then
+		_scratch_mkfs >>$seqres.full 2>&1
+	else
+		_scratch_pool_mkfs >>$seqres.full 2>&1
+	fi
+	local ret=$?
+	MKFS_OPTIONS=$saved_mkfs_opts
+	# make sure we created btrfs with desired options
+	if [ $ret -ne 0 ]; then
+		echo "mkfs $mkfs_opts failed"
+		return
+	fi
+	_scratch_mount >>$seqres.full 2>&1
+
+	args=`_scale_fsstress_args -p 20 -n 100 $FSSTRESS_AVOID -d $SCRATCH_MNT/stressdir`
+	echo "Run fsstress $args" >>$seqres.full
+	$FSSTRESS_PROG $args >/dev/null 2>&1 &
+	fsstress_pid=$!
+
+	echo -n "Start scrub worker: " >>$seqres.full
+	(
+		while true; do
+			$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
+		done
+	) &
+	scrub_pid=$!
+	echo "$scrub_pid" >>$seqres.full
+
+	echo -n "Start defrag worker: " >>$seqres.full
+	(
+		while true; do
+			if [ "$with_compress" == "nocompress" ]; then
+				find $SCRATCH_MNT \( -type f -o -type d \) -exec \
+					$BTRFS_UTIL_PROG filesystem defrag {} \; >>$seqres.full 2>&1
+			else
+				find $SCRATCH_MNT \( -type f -o -type d \) -exec \
+					$BTRFS_UTIL_PROG filesystem defrag -clzo {} \; >>$seqres.full 2>&1
+				find $SCRATCH_MNT \( -type f -o -type d \) -exec \
+					$BTRFS_UTIL_PROG filesystem defrag -czlib {} \; >>$seqres.full 2>&1
+			fi
+		done
+	) &
+	defrag_pid=$!
+	echo "$defrag_pid" >>$seqres.full
+
+	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
+	wait $fsstress_pid
+	kill $scrub_pid $defrag_pid
+	wait
+	# wait for the scrub and defrag operations to finish
+	while ps aux | grep "scrub start" | grep -qv grep; do
+		sleep 1
+	done
+	while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do
+		sleep 1
+	done
+
+	echo "Scrub the filesystem" >>$seqres.full
+	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
+	if [ $? -ne 0 ]; then
+		echo "Scrub find errors in \"$mkfs_opts\" test" | tee -a $seqres.full
+	fi
+
+	$BTRFS_UTIL_PROG filesystem sync $SCRATCH_MNT >/dev/null 2>&1
+	_scratch_unmount
+	_check_scratch_fs
+}
+
+echo "Silence is golden"
+for t in "${tcs[@]}"; do
+	run_test "$t" nocompress
+	run_test "$t" compress
+done
+
+status=0
+exit
tests/btrfs/069.out new file +2 -0
new file mode 100644
index 0000000..532a929
@@ -0,0 +1,2 @@
+QA output created by 069
+Silence is golden
tests/btrfs/group +1 -0
index 7aa66ad..4c488ce 100644
@@ -71,3 +71,4 @@
 066 auto stress replace scrub
 067 auto stress replace defrag compress
 068 auto stress replace remount compress
+069 auto stress scrub defrag compress
Signature · 1 line
1.8.3.1
author
#21 lore raw

PATCH 14/15 btrfs: new case to run btrfs scrub and remount with different compress algorithms simultaneously

In reply to Eryu Guan

Run btrfs scrub and remount with different compress algorithms simultaneously with fsstress running in background.

---
 tests/btrfs/070     | 142 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/070.out |   2 +
 tests/btrfs/group   |   1 +
 3 files changed, 145 insertions(+)
 create mode 100755 tests/btrfs/070
 create mode 100644 tests/btrfs/070.out
tests/btrfs/070 new file +142 -0
new file mode 100755
index 0000000..b53198c
@@ -0,0 +1,142 @@
+#! /bin/bash
+# FSQA Test No. btrfs/070
+#
+# Run btrfs scrub and remount with different compress algorithms
+# simultaneously with fsstress running in background.
+#
+#-----------------------------------------------------------------------
+# Copyright (C) 2014 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
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	rm -fr $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_fs btrfs
+_supported_os Linux
+_require_scratch
+_require_scratch_dev_pool 4
+
+rm -f $seqres.full
+
+# test case array
+tcs=(
+	"-m single -d single"
+	"-m dup -d single"
+	"-m raid0 -d raid0"
+	"-m raid1 -d raid0"
+	"-m raid1 -d raid1"
+	"-m raid10 -d raid10"
+	"-m raid5 -d raid5"
+	"-m raid6 -d raid6"
+)
+
+run_test()
+{
+	local mkfs_opts=$1
+	local saved_mkfs_opts=$MKFS_OPTIONS
+
+	echo "Test $mkfs_opts with $with_compress" >>$seqres.full
+
+	MKFS_OPTIONS="$MKFS_OPTIONS $mkfs_opts"
+	# dup only works on single device
+	if [[ "$mkfs_opts" =~ dup ]]; then
+		_scratch_mkfs >>$seqres.full 2>&1
+	else
+		_scratch_pool_mkfs >>$seqres.full 2>&1
+	fi
+	local ret=$?
+	MKFS_OPTIONS=$saved_mkfs_opts
+	# make sure we created btrfs with desired options
+	if [ $ret -ne 0 ]; then
+		echo "mkfs $mkfs_opts failed"
+		return
+	fi
+	_scratch_mount >>$seqres.full 2>&1
+
+	args=`_scale_fsstress_args -p 20 -n 100 $FSSTRESS_AVOID -d $SCRATCH_MNT/stressdir`
+	echo "Run fsstress $args" >>$seqres.full
+	$FSSTRESS_PROG $args >/dev/null 2>&1 &
+	fsstress_pid=$!
+
+	echo -n "Start scrub worker: " >>$seqres.full
+	(
+		while true; do
+			$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
+		done
+	) &
+	scrub_pid=$!
+	echo "$scrub_pid" >>$seqres.full
+
+	echo -n "Start remount worker: " >>$seqres.full
+	(
+		while true; do
+			for algo in no zlib lzo; do
+				$MOUNT_PROG -o remount,compress=$algo $SCRATCH_MNT >>$seqres.full 2>&1
+			done
+		done
+	) >/dev/null 2>&1 &
+	remount_pid=$!
+	echo "$remount_pid" >>$seqres.full
+
+	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
+	wait $fsstress_pid
+	kill $scrub_pid $remount_pid
+	wait
+	# wait for the scrub and remount operations to finish
+	while ps aux | grep "scrub start" | grep -qv grep; do
+		sleep 1
+	done
+	while ps aux | grep "mount.*$SCRATCH_MNT" | grep -qv grep; do
+		sleep 1
+	done
+
+	echo "Scrub the filesystem" >>$seqres.full
+	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
+	if [ $? -ne 0 ]; then
+		echo "Scrub find errors in \"$mkfs_opts\" test" | tee -a $seqres.full
+	fi
+
+	$BTRFS_UTIL_PROG filesystem sync $SCRATCH_MNT >/dev/null 2>&1
+	_scratch_unmount
+	_check_scratch_fs
+}
+
+echo "Silence is golden"
+for t in "${tcs[@]}"; do
+	run_test "$t"
+done
+
+status=0
+exit
tests/btrfs/070.out new file +2 -0
new file mode 100644
index 0000000..8940c5d
@@ -0,0 +1,2 @@
+QA output created by 070
+Silence is golden
tests/btrfs/group +1 -0
index 4c488ce..4d6a36c 100644
@@ -72,3 +72,4 @@
 067 auto stress replace defrag compress
 068 auto stress replace remount compress
 069 auto stress scrub defrag compress
+070 auto stress scrub remount compress
Signature · 1 line
1.8.3.1
author
#22 lore raw

PATCH 15/15 btrfs: new case to run defrag and remount with different compress algorithms simultaneously

In reply to Eryu Guan

Run btrfs defrag operations and remount with different compress algorithms simultaneously with fsstress running in background.

---
 tests/btrfs/071     | 152 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/071.out |   2 +
 tests/btrfs/group   |   1 +
 3 files changed, 155 insertions(+)
 create mode 100755 tests/btrfs/071
 create mode 100644 tests/btrfs/071.out
tests/btrfs/071 new file +152 -0
new file mode 100755
index 0000000..4434cd6
@@ -0,0 +1,152 @@
+#! /bin/bash
+# FSQA Test No. btrfs/069
+#
+# Run btrfs defrag operations and remount with different compress algorithms
+# simultaneously with fsstress running in background.
+#
+#-----------------------------------------------------------------------
+# Copyright (C) 2014 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
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	rm -fr $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_fs btrfs
+_supported_os Linux
+_require_scratch
+_require_scratch_dev_pool 4
+
+rm -f $seqres.full
+
+# test case array
+tcs=(
+	"-m single -d single"
+	"-m dup -d single"
+	"-m raid0 -d raid0"
+	"-m raid1 -d raid0"
+	"-m raid1 -d raid1"
+	"-m raid10 -d raid10"
+	"-m raid5 -d raid5"
+	"-m raid6 -d raid6"
+)
+
+run_test()
+{
+	local mkfs_opts=$1
+	local with_compress=$2
+	local saved_mkfs_opts=$MKFS_OPTIONS
+
+	echo "Test $mkfs_opts with $with_compress" >>$seqres.full
+
+	MKFS_OPTIONS="$MKFS_OPTIONS $mkfs_opts"
+	# dup only works on single device
+	if [[ "$mkfs_opts" =~ dup ]]; then
+		_scratch_mkfs >>$seqres.full 2>&1
+	else
+		_scratch_pool_mkfs >>$seqres.full 2>&1
+	fi
+	local ret=$?
+	MKFS_OPTIONS=$saved_mkfs_opts
+	# make sure we created btrfs with desired options
+	if [ $ret -ne 0 ]; then
+		echo "mkfs $mkfs_opts failed"
+		return
+	fi
+	_scratch_mount >>$seqres.full 2>&1
+
+	args=`_scale_fsstress_args -p 20 -n 100 $FSSTRESS_AVOID -d $SCRATCH_MNT/stressdir`
+	echo "Run fsstress $args" >>$seqres.full
+	$FSSTRESS_PROG $args >/dev/null 2>&1 &
+	fsstress_pid=$!
+
+	echo -n "Start defrag worker: " >>$seqres.full
+	(
+		while true; do
+			if [ "$with_compress" == "nocompress" ]; then
+				find $SCRATCH_MNT \( -type f -o -type d \) -exec \
+					$BTRFS_UTIL_PROG filesystem defrag {} \; >>$seqres.full 2>&1
+			else
+				find $SCRATCH_MNT \( -type f -o -type d \) -exec \
+					$BTRFS_UTIL_PROG filesystem defrag -clzo {} \; >>$seqres.full 2>&1
+				find $SCRATCH_MNT \( -type f -o -type d \) -exec \
+					$BTRFS_UTIL_PROG filesystem defrag -czlib {} \; >>$seqres.full 2>&1
+			fi
+		done
+	) &
+	defrag_pid=$!
+	echo "$defrag_pid" >>$seqres.full
+
+	echo -n "Start remount worker: " >>$seqres.full
+	(
+		while true; do
+			for algo in no zlib lzo; do
+				$MOUNT_PROG -o remount,compress=$algo $SCRATCH_MNT >>$seqres.full 2>&1
+			done
+		done
+	) >/dev/null 2>&1 &
+	remount_pid=$!
+	echo "$remount_pid" >>$seqres.full
+
+	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
+	wait $fsstress_pid
+	kill $defrag_pid $remount_pid
+	wait
+	# wait for the defrag and remount operations to finish
+	while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do
+		sleep 1
+	done
+	while ps aux | grep "mount.*$SCRATCH_MNT" | grep -qv grep; do
+		sleep 1
+	done
+
+	echo "Scrub the filesystem" >>$seqres.full
+	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
+	if [ $? -ne 0 ]; then
+		echo "Scrub find errors in \"$mkfs_opts\" test" | tee -a $seqres.full
+	fi
+
+	$BTRFS_UTIL_PROG filesystem sync $SCRATCH_MNT >/dev/null 2>&1
+	_scratch_unmount
+	_check_scratch_fs
+}
+
+echo "Silence is golden"
+for t in "${tcs[@]}"; do
+	run_test "$t" nocompress
+	run_test "$t" compress
+done
+
+status=0
+exit
tests/btrfs/071.out new file +2 -0
new file mode 100644
index 0000000..9a9ef40
@@ -0,0 +1,2 @@
+QA output created by 071
+Silence is golden
tests/btrfs/group +1 -0
index 4d6a36c..3c89f9c 100644
@@ -73,3 +73,4 @@
 068 auto stress replace remount compress
 069 auto stress scrub defrag compress
 070 auto stress scrub remount compress
+071 auto stress defrag remount compress
Signature · 1 line
1.8.3.1

Eryu Guan

author
#0 lore raw

cover xfstests: new btrfs stress test cases

This patchset add new stress test cases for btrfs by running two different btrfs operations simultaneously under fsstress to ensure btrfs doesn't hang or oops in such situations. btrfs scrub and btrfs check will be run after each test.

The test matrix is the combination of 6 btrfs operations:

balance
create/mount/umount/delete subvolume replace device
scrub
defrag
remount with different compress algorithms

Short descriptions:

	057: balance-subvolume
	058: balance-scrub
	059: balance-defrag
	060: balance-remount
	061: balance-replace
	062: subvolume-replace
	063: subvolume-scrub
	064: subvolume-defrag
	065: subvolume-remount
	066: replace-scrub
	067: replace-defrag
	068: replace-remount
	069: scrub-defrag
	070: scrub-remount
	071: defrag-remount

Some issues I've seen:

1. subvolume cannot be mounted with selinux context, so you may see such logs in dmesg

SELinux: mount invalid. Same superblock, different security settings for (dev dm-8, type btrfs)

I've reported the bug to btrfs list, see [BUG] cannot mount subvolume with selinux context

2. btrfs replace operation always returns ENOENT if balance is running So in 061.full you'll see

ERROR: ioctl(DEV_REPLACE_START) failed on "/mnt/testarea/scratch": No such file or directory, no error

Not sure if it's btrfs bug, at least I think the error code is misleading

3. replace operation hangs the kernel(3.16-rc4+) with fsstress running So case 062/066/067/068 will hang

This is my first attemp to add these tests, any comments are welcomed!

Thanks,
Eryu Guan

Eryu Guan (15):
btrfs: new test to run btrfs balance and subvolume test simultaneously
btrfs: new test to run btrfs balance and scrub simltaneously
btrfs: new test to run btrfs balance and defrag operations simultaneously
btrfs: new case to run btrfs balance and remount with different compress algorithms
btrfs: new case to run btrfs balance and device replace simultaneously
btrfs: new case to run btrfs subvolume create/delete operations and device replace simultaneously
btrfs: new case to run btrfs subvolume create/delete operations and scrub simultaneously
btrfs: new case to run btrfs subvolume create/delete and defrag operations simultaneously
btrfs: new case to run subvolume create/delete and remount with different compress algorithms
btrfs: new case to run device replace and scrub operations simultaneously
btrfs: new case to run device replace and defrag operations simultaneously
btrfs: new case to run device replace and remount with different compress algorithms simultaneously
btrfs: new case to run btrfs scrub and defrag operations simultaneously
btrfs: new case to run btrfs scrub and remount with different compress algorithms simultaneously
btrfs: new case to run defrag and remount with different compress algorithms simultaneously

 common/rc           |  24 ++++++++
 tests/btrfs/057     | 147 ++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/057.out |   2 +
 tests/btrfs/058     | 141 +++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/058.out |   2 +
 tests/btrfs/059     | 150 +++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/059.out |   2 +
 tests/btrfs/060     | 142 +++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/060.out |   2 +
 tests/btrfs/061     | 161 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/061.out |   2 +
 tests/btrfs/062     | 167 ++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/062.out |   2 +
 tests/btrfs/063     | 146 ++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/063.out |   2 +
 tests/btrfs/064     | 155 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/064.out |   2 +
 tests/btrfs/065     | 148 +++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/065.out |   2 +
 tests/btrfs/066     | 161 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/066.out |   2 +
 tests/btrfs/067     | 171 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/067.out |   2 +
 tests/btrfs/068     | 163 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/068.out |   2 +
 tests/btrfs/069     | 150 +++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/069.out |   2 +
 tests/btrfs/070     | 142 +++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/070.out |   2 +
 tests/btrfs/071     | 152 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/071.out |   2 +
 tests/btrfs/group   |  15 +++++
 32 files changed, 2365 insertions(+)
 create mode 100755 tests/btrfs/057
 create mode 100644 tests/btrfs/057.out
 create mode 100755 tests/btrfs/058
 create mode 100644 tests/btrfs/058.out
 create mode 100755 tests/btrfs/059
 create mode 100644 tests/btrfs/059.out
 create mode 100755 tests/btrfs/060
 create mode 100644 tests/btrfs/060.out
 create mode 100755 tests/btrfs/061
 create mode 100644 tests/btrfs/061.out
 create mode 100755 tests/btrfs/062
 create mode 100644 tests/btrfs/062.out
 create mode 100755 tests/btrfs/063
 create mode 100644 tests/btrfs/063.out
 create mode 100755 tests/btrfs/064
 create mode 100644 tests/btrfs/064.out
 create mode 100755 tests/btrfs/065
 create mode 100644 tests/btrfs/065.out
 create mode 100755 tests/btrfs/066
 create mode 100644 tests/btrfs/066.out
 create mode 100755 tests/btrfs/067
 create mode 100644 tests/btrfs/067.out
 create mode 100755 tests/btrfs/068
 create mode 100644 tests/btrfs/068.out
 create mode 100755 tests/btrfs/069
 create mode 100644 tests/btrfs/069.out
 create mode 100755 tests/btrfs/070
 create mode 100644 tests/btrfs/070.out
 create mode 100755 tests/btrfs/071
 create mode 100644 tests/btrfs/071.out
Signature · 1 line
1.8.3.1
#23 lore raw
Quoted 4 lines · Eryu Guan

This patchset add new stress test cases for btrfs by running two different btrfs operations simultaneously under fsstress to ensure btrfs doesn't hang or oops in such situations. btrfs scrub and btrfs check will be run after each test.

Cool.

Quoted 11 lines

The test matrix is the combination of 6 btrfs operations:

balance
create/mount/umount/delete subvolume replace device
scrub
defrag
remount with different compress algorithms

Short descriptions:

Quoted 15 lines
	057: balance-subvolume
	058: balance-scrub
	059: balance-defrag
	060: balance-remount
	061: balance-replace
	062: subvolume-replace
	063: subvolume-scrub
	064: subvolume-defrag
	065: subvolume-remount
	066: replace-scrub
	067: replace-defrag
	068: replace-remount
	069: scrub-defrag
	070: scrub-remount
	071: defrag-remount

But I'm not sure it should be built this way.

At the very least each operation's implementation should be in a shared function somewhere instead of being duplicated in each test.

But I don't think there should be a seperate test for each combination. With a bit of fiddly bash you can automate generating unique combinations of operations that are defined as functions in one test.

btrfs_op_balance()
{
echo hi
}

btrfs_op_scrub()
{
echo hi
}

btrfs_op_defrag()
{
echo hi
}

ops=($(declare -F | awk '/-f btrfs_op_/ {print $3}')) nr=${#ops[@]}

for i in $(seq 0 $((nr - 2))); do
for j in $(seq $((i + 1)) $((nr - 1))); do

	echo ${ops[i]} ${ops[j]}

done
done

Something like that.

- z

#3 lore raw

Re: [PATCH 01/15] btrfs: new test to run btrfs balance and subvolume test simultaneously

In reply to Eryu Guan

-------- Original Message --------
Subject: [PATCH 01/15] btrfs: new test to run btrfs balance and subvolume test simultaneously
From: Eryu Guan <[email protected]>
To: <[email protected]>
Date: 2014年08月21日 01:33

Quoted 71 lines

Run btrfs balance and subvolume create/mount/umount/delete simultaneously, with fsstress running in background.

---
  tests/btrfs/057     | 147 ++++++++++++++++++++++++++++++++++++++++++++++++++++
  tests/btrfs/057.out |   2 +
  tests/btrfs/group   |   1 +
  3 files changed, 150 insertions(+)

create mode 100755 tests/btrfs/057
create mode 100644 tests/btrfs/057.out

tests/btrfs/057 new file +53 -0
new file mode 100755
index 0000000..2f507a7
@@ -0,0 +1,147 @@
+#! /bin/bash
+# FSQA Test No. btrfs/057
+#
+# Run btrfs balance and subvolume create/mount/umount/delete simultaneously,
+# with fsstress running in background.
+#
+#-----------------------------------------------------------------------
+# Copyright (C) 2014 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
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	rm -fr $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_fs btrfs
+_supported_os Linux
+_require_scratch
+_require_scratch_dev_pool 4
+
+rm -f $seqres.full
+
+# test case array

tests/btrfs/057 line 63

Quoted 10 lines
tests/btrfs/057 new file +10 -0
+tcs=(
+	"-m single -d single"
+	"-m dup -d single"
+	"-m raid0 -d raid0"
+	"-m raid1 -d raid0"
+	"-m raid1 -d raid1"
+	"-m raid10 -d raid10"
+	"-m raid5 -d raid5"
+	"-m raid6 -d raid6"
+)

I wonder should we add the mkfs options there.
Since xfstests already use environment MKFS_OPTIONS to do mkfs,
if really need to test all mkfs options, IMO it is better to change MKFS_OPTIONS on each test round.

Quoted 45 lines
tests/btrfs/057 new file +45 -0
+
+run_test()
+{
+	local mkfs_opts=$1
+	local saved_mkfs_opts=$MKFS_OPTIONS
+	local subvol_mnt=$tmp.mnt
+
+	echo "Test $mkfs_opts" >>$seqres.full
+
+	MKFS_OPTIONS="$MKFS_OPTIONS $mkfs_opts"
+	# dup only works on single device
+	if [[ "$mkfs_opts" =~ dup ]]; then
+		_scratch_mkfs >>$seqres.full 2>&1
+	else
+		_scratch_pool_mkfs >>$seqres.full 2>&1
+	fi
+	ret=$?
+	MKFS_OPTIONS=$saved_mkfs_opts
+	# make sure we created btrfs with desired options
+	if [ $ret -ne 0 ]; then
+		echo "mkfs $mkfs_opts failed"
+		return
+	fi
+
+	_scratch_mount >>$seqres.full 2>&1
+
+	args=`_scale_fsstress_args -p 20 -n 100 $FSSTRESS_AVOID -d $SCRATCH_MNT/stressdir`
+	echo "Run fsstress $args" >>$seqres.full
+	$FSSTRESS_PROG $args >/dev/null 2>&1 &
+	fsstress_pid=$!
+
+	echo -n "Start balance worker: " >>$seqres.full
+	(
+		while true; do
+			$BTRFS_UTIL_PROG balance start $SCRATCH_MNT
+		done
+	) >/dev/null 2>&1 &
+	balance_pid=$!
+	echo "$balance_pid" >>$seqres.full
+
+	echo -n "Start subvolume worker: " >>$seqres.full
+	mkdir -p $subvol_mnt
+	(
+		while true; do
+			$BTRFS_UTIL_PROG subvolume create $SCRATCH_MNT/subvol_$$

tests/btrfs/057 line 118

Quoted 10 lines
tests/btrfs/057 new file +10 -0
+			$MOUNT_PROG -o subvol=subvol_$$ $SCRATCH_DEV $subvol_mnt
+			$UMOUNT_PROG $subvol_mnt
+			$BTRFS_UTIL_PROG subvolume delete $SCRATCH_MNT/subvol_$$
+		done
+	) >/dev/null 2>&1 &
+	subvol_pid=$!
+	echo "$subvol_pid" >>$seqres.full
+
+	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
+	wait $fsstress_pid

What about integrate this 'run in background; record PID; wait; kill' thing into one function or two? and then thing would be like this:
add_test_background TEST_FUNC1 PID_RET1
add_test_background TEST_FUNC2 PID_RET2
...
stop_test_backgroupd PID_RET1
stop_test_backgroupd PID_RET2

Which will be much cleaner.

Quoted 4 lines
tests/btrfs/057 new file +4 -0
+
+	kill $balance_pid $subvol_pid
+	wait
+	# the balance process might be still in D state and cannot be killed

tests/btrfs/057 line 132

Quoted 10 lines
tests/btrfs/057 new file +10 -0
+	# which could block umount, wait for it to finish
+	while ps aux | grep "balance start" | grep -qv grep; do
+		sleep 1
+	done
+
+	echo "Scrub the filesystem" >>$seqres.full
+	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
+	if [ $? -ne 0 ]; then
+		echo "Scrub find errors in \"$mkfs_opts\" test" | tee -a $seqres.full
+	fi

All your testcases uses almost same scrub/replace/subvolume operations,
it would be better move them to common operations in common/ like _scratch_mount in common/rc. (since all these are btrfs only operations, maybe common/btrfs is a good place for them?)

At least this should save some lines.

Thanks,
Qu

Quoted 33 lines
tests/btrfs/057 new file +15 -0
+
+	$BTRFS_UTIL_PROG filesystem sync $SCRATCH_MNT >/dev/null 2>&1
+	# in case the subvolume is still mounted
+	$UMOUNT_PROG $subvol_mnt >/dev/null 2>&1
+	_scratch_unmount
+	_check_scratch_fs
+}
 
+
+echo "Silence is golden"
+for t in "${tcs[@]}"; do
+	run_test "$t"
+done
+
+status=0
+exit
tests/btrfs/057.out new file +2 -0
new file mode 100644
index 0000000..185023c
@@ -0,0 +1,2 @@
+QA output created by 057
+Silence is golden
tests/btrfs/group +1 -0
index 2da7127..08fd54a 100644
@@ -59,3 +59,4 @@
  054 auto quick
  055 auto quick
  056 auto quick
+057 auto stress balance subvol
author
#24 lore raw
In reply to Zach Brown
Quoted 35 lines · Zach Brown
Quoted 4 lines · Eryu Guan

This patchset add new stress test cases for btrfs by running two different btrfs operations simultaneously under fsstress to ensure btrfs doesn't hang or oops in such situations. btrfs scrub and btrfs check will be run after each test.

Cool.

Quoted 11 lines

The test matrix is the combination of 6 btrfs operations:

balance
create/mount/umount/delete subvolume replace device
scrub
defrag
remount with different compress algorithms

Short descriptions:

Quoted 15 lines
	057: balance-subvolume
	058: balance-scrub
	059: balance-defrag
	060: balance-remount
	061: balance-replace
	062: subvolume-replace
	063: subvolume-scrub
	064: subvolume-defrag
	065: subvolume-remount
	066: replace-scrub
	067: replace-defrag
	068: replace-remount
	069: scrub-defrag
	070: scrub-remount
	071: defrag-remount
Quoted 4 lines

But I'm not sure it should be built this way.

At the very least each operation's implementation should be in a shared function somewhere instead of being duplicated in each test.

I was thinking about it too, my concern is that my test cases might be the only user of these shared functions, so I'm just not sure if it's good idea to share these functions just for my test cases.

I'll share them in v2.

Quoted 4 lines

But I don't think there should be a seperate test for each combination. With a bit of fiddly bash you can automate generating unique combinations of operations that are defined as functions in one test.

Yes, that's just how it works in Red Hat internal test case, one test to generate all the combinations using shared functions.

But I think that test time will be too long for a xfstests test case, and seperated and targeted test cases might be good idea for xfstests.

Thanks for the review!

Eryu

Quoted 28 lines

btrfs_op_balance()
{
echo hi
}

btrfs_op_scrub()
{
echo hi
}

btrfs_op_defrag()
{
echo hi
}

ops=($(declare -F | awk '/-f btrfs_op_/ {print $3}')) nr=${#ops[@]}

for i in $(seq 0 $((nr - 2))); do
for j in $(seq $((i + 1)) $((nr - 1))); do

	echo ${ops[i]} ${ops[j]}

done
done

Something like that.

- z

author
#4 lore raw

Re: [PATCH 01/15] btrfs: new test to run btrfs balance and subvolume test simultaneously

In reply to Qu Wenruo
Quoted 84 lines · Qu Wenruo

-------- Original Message --------
Subject: [PATCH 01/15] btrfs: new test to run btrfs balance and subvolume test simultaneously
From: Eryu Guan <[email protected]>
To: <[email protected]>
Date: 2014年08月21日 01:33

Quoted 77 lines

Run btrfs balance and subvolume create/mount/umount/delete simultaneously, with fsstress running in background.

---
 tests/btrfs/057     | 147 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/057.out |   2 +
 tests/btrfs/group   |   1 +
 3 files changed, 150 insertions(+)
 create mode 100755 tests/btrfs/057
 create mode 100644 tests/btrfs/057.out
tests/btrfs/057 new file +59 -0
new file mode 100755
index 0000000..2f507a7
@@ -0,0 +1,147 @@
+#! /bin/bash
+# FSQA Test No. btrfs/057
+#
+# Run btrfs balance and subvolume create/mount/umount/delete simultaneously,
+# with fsstress running in background.
+#
+#-----------------------------------------------------------------------
+# Copyright (C) 2014 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
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	rm -fr $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_fs btrfs
+_supported_os Linux
+_require_scratch
+_require_scratch_dev_pool 4
+
+rm -f $seqres.full
+
+# test case array
+tcs=(
+	"-m single -d single"
+	"-m dup -d single"
+	"-m raid0 -d raid0"
+	"-m raid1 -d raid0"
+	"-m raid1 -d raid1"
Quoted 8 lines

tests/btrfs/057 line 63

Quoted 4 lines
tests/btrfs/057 new file +4 -0
+	"-m raid10 -d raid10"
+	"-m raid5 -d raid5"
+	"-m raid6 -d raid6"
+)

I wonder should we add the mkfs options there.
Since xfstests already use environment MKFS_OPTIONS to do mkfs, if really need to test all mkfs options, IMO it is better to change MKFS_OPTIONS on each test round.

Most of the data/metadata profiles tested here require multiple devices, so if you set MKFS_OPTIONS to, say "-m raid10 -d raid10", other tests that only require a single scratch device will fail at mkfs time. Unlike other mkfs options, these options are not working for every test.

And btrfs/011 and btrfs/023 do the test in a similar way, so I just followed this way :)

Quoted 65 lines
Quoted 46 lines
tests/btrfs/057 new file +45 -0
+
+run_test()
+{
+	local mkfs_opts=$1
+	local saved_mkfs_opts=$MKFS_OPTIONS
+	local subvol_mnt=$tmp.mnt
+
+	echo "Test $mkfs_opts" >>$seqres.full
+
+	MKFS_OPTIONS="$MKFS_OPTIONS $mkfs_opts"
+	# dup only works on single device
+	if [[ "$mkfs_opts" =~ dup ]]; then
+		_scratch_mkfs >>$seqres.full 2>&1
+	else
+		_scratch_pool_mkfs >>$seqres.full 2>&1
+	fi
+	ret=$?
+	MKFS_OPTIONS=$saved_mkfs_opts
+	# make sure we created btrfs with desired options
+	if [ $ret -ne 0 ]; then
+		echo "mkfs $mkfs_opts failed"
+		return
+	fi
+
+	_scratch_mount >>$seqres.full 2>&1
+
+	args=`_scale_fsstress_args -p 20 -n 100 $FSSTRESS_AVOID -d $SCRATCH_MNT/stressdir`
+	echo "Run fsstress $args" >>$seqres.full
+	$FSSTRESS_PROG $args >/dev/null 2>&1 &
+	fsstress_pid=$!
+
+	echo -n "Start balance worker: " >>$seqres.full
+	(
+		while true; do
+			$BTRFS_UTIL_PROG balance start $SCRATCH_MNT
+		done
+	) >/dev/null 2>&1 &
+	balance_pid=$!
+	echo "$balance_pid" >>$seqres.full
+
+	echo -n "Start subvolume worker: " >>$seqres.full
+	mkdir -p $subvol_mnt
+	(
+		while true; do
+			$BTRFS_UTIL_PROG subvolume create $SCRATCH_MNT/subvol_$$

tests/btrfs/057 line 118

Quoted 10 lines
tests/btrfs/057 new file +10 -0
+			$MOUNT_PROG -o subvol=subvol_$$ $SCRATCH_DEV $subvol_mnt
+			$UMOUNT_PROG $subvol_mnt
+			$BTRFS_UTIL_PROG subvolume delete $SCRATCH_MNT/subvol_$$
+		done
+	) >/dev/null 2>&1 &
+	subvol_pid=$!
+	echo "$subvol_pid" >>$seqres.full
+
+	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
+	wait $fsstress_pid

What about integrate this 'run in background; record PID; wait; kill' thing into one function or two?
and then thing would be like this:
add_test_background TEST_FUNC1 PID_RET1
add_test_background TEST_FUNC2 PID_RET2
...
stop_test_backgroupd PID_RET1
stop_test_backgroupd PID_RET2

Quoted 1 line

Which will be much cleaner.

Yes, that's a good idea, thanks!

Quoted 11 lines
Quoted 11 lines
tests/btrfs/057 new file +11 -0
+
+	kill $balance_pid $subvol_pid
+	wait
+	# the balance process might be still in D state and cannot be killed
+	# which could block umount, wait for it to finish
+	while ps aux | grep "balance start" | grep -qv grep; do
+		sleep 1
+	done
+
+	echo "Scrub the filesystem" >>$seqres.full
+	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
Quoted 8 lines

tests/btrfs/057 line 132

Quoted 3 lines
tests/btrfs/057 new file +3 -0
+	if [ $? -ne 0 ]; then
+		echo "Scrub find errors in \"$mkfs_opts\" test" | tee -a $seqres.full
+	fi

All your testcases uses almost same scrub/replace/subvolume operations, it would be better move them to common operations in common/ like _scratch_mount in common/rc.
(since all these are btrfs only operations, maybe common/btrfs is a good place for them?)

I'll share the functions in v2. There're already some btrfs specific helper functions in common/rc, I'll just add my functions there too. We can take them all out to commom/btrfs in a seperate patch if in need, and update all affected test cases.

Thanks for the review!

Eryu

Quoted 39 lines

At least this should save some lines.

Thanks,
Qu

Quoted 33 lines
tests/btrfs/057 new file +15 -0
+
+	$BTRFS_UTIL_PROG filesystem sync $SCRATCH_MNT >/dev/null 2>&1
+	# in case the subvolume is still mounted
+	$UMOUNT_PROG $subvol_mnt >/dev/null 2>&1
+	_scratch_unmount
+	_check_scratch_fs
+}
 
+
+echo "Silence is golden"
+for t in "${tcs[@]}"; do
+	run_test "$t"
+done
+
+status=0
+exit
tests/btrfs/057.out new file +2 -0
new file mode 100644
index 0000000..185023c
@@ -0,0 +1,2 @@
+QA output created by 057
+Silence is golden
tests/btrfs/group +1 -0
index 2da7127..08fd54a 100644
@@ -59,3 +59,4 @@
 054 auto quick
 055 auto quick
 056 auto quick
+057 auto stress balance subvol
#5 lore raw

Re: [PATCH 01/15] btrfs: new test to run btrfs balance and subvolume test simultaneously

In reply to Qu Wenruo
Quoted 84 lines · Qu Wenruo

-------- Original Message --------
Subject: [PATCH 01/15] btrfs: new test to run btrfs balance and subvolume test simultaneously
From: Eryu Guan <[email protected]>
To: <[email protected]>
Date: 2014年08月21日 01:33

Quoted 77 lines

Run btrfs balance and subvolume create/mount/umount/delete simultaneously, with fsstress running in background.

---
 tests/btrfs/057     | 147 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/057.out |   2 +
 tests/btrfs/group   |   1 +
 3 files changed, 150 insertions(+)
 create mode 100755 tests/btrfs/057
 create mode 100644 tests/btrfs/057.out
tests/btrfs/057 new file +59 -0
new file mode 100755
index 0000000..2f507a7
@@ -0,0 +1,147 @@
+#! /bin/bash
+# FSQA Test No. btrfs/057
+#
+# Run btrfs balance and subvolume create/mount/umount/delete simultaneously,
+# with fsstress running in background.
+#
+#-----------------------------------------------------------------------
+# Copyright (C) 2014 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
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	rm -fr $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_fs btrfs
+_supported_os Linux
+_require_scratch
+_require_scratch_dev_pool 4
+
+rm -f $seqres.full
+
+# test case array
+tcs=(
+	"-m single -d single"
+	"-m dup -d single"
+	"-m raid0 -d raid0"
+	"-m raid1 -d raid0"
+	"-m raid1 -d raid1"
Quoted 8 lines

tests/btrfs/057 line 63

Quoted 4 lines
tests/btrfs/057 new file +4 -0
+	"-m raid10 -d raid10"
+	"-m raid5 -d raid5"
+	"-m raid6 -d raid6"
+)

I wonder should we add the mkfs options there.
Since xfstests already use environment MKFS_OPTIONS to do mkfs, if really need to test all mkfs options, IMO it is better to change MKFS_OPTIONS on each test round.

Hmmm - I you didn't read the code, because:

Quoted 10 lines

tests/btrfs/057 line 74

Quoted 10 lines
tests/btrfs/057 new file +10 -0
+run_test()
+{
+	local mkfs_opts=$1
+	local saved_mkfs_opts=$MKFS_OPTIONS
+	local subvol_mnt=$tmp.mnt
+
+	echo "Test $mkfs_opts" >>$seqres.full
+
+	MKFS_OPTIONS="$MKFS_OPTIONS $mkfs_opts"
+	# dup only works on single device

it's doing exactly what you suggest.

And it's wrong. This:

_scratch_mkfs $mkfs_opts

is all that is needed. This wheel does not need reinventing. ;)

Cheers,

Dave.

Signature · 2 lines
Dave Chinner
[email protected]
#6 lore raw

Re: [PATCH 01/15] btrfs: new test to run btrfs balance and subvolume test simultaneously

-------- Original Message --------
Subject: Re: [PATCH 01/15] btrfs: new test to run btrfs balance and subvolume test simultaneously
From: Dave Chinner <[email protected]>
To: Qu Wenruo <[email protected]>
Date: 2014年08月21日 17:01

Quoted 94 lines · Qu Wenruo
Quoted 83 lines

-------- Original Message --------
Subject: [PATCH 01/15] btrfs: new test to run btrfs balance and subvolume test simultaneously
From: Eryu Guan <[email protected]>
To: <[email protected]>
Date: 2014年08月21日 01:33

Quoted 77 lines

Run btrfs balance and subvolume create/mount/umount/delete simultaneously, with fsstress running in background.

---
  tests/btrfs/057     | 147 ++++++++++++++++++++++++++++++++++++++++++++++++++++
  tests/btrfs/057.out |   2 +
  tests/btrfs/group   |   1 +
  3 files changed, 150 insertions(+)

create mode 100755 tests/btrfs/057
create mode 100644 tests/btrfs/057.out

tests/btrfs/057 new file +59 -0
new file mode 100755
index 0000000..2f507a7
@@ -0,0 +1,147 @@
+#! /bin/bash
+# FSQA Test No. btrfs/057
+#
+# Run btrfs balance and subvolume create/mount/umount/delete simultaneously,
+# with fsstress running in background.
+#
+#-----------------------------------------------------------------------
+# Copyright (C) 2014 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
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	rm -fr $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_fs btrfs
+_supported_os Linux
+_require_scratch
+_require_scratch_dev_pool 4
+
+rm -f $seqres.full
+
+# test case array
+tcs=(
+	"-m single -d single"
+	"-m dup -d single"
+	"-m raid0 -d raid0"
+	"-m raid1 -d raid0"
+	"-m raid1 -d raid1"
Quoted 8 lines

tests/btrfs/057 line 63

Quoted 4 lines
tests/btrfs/057 new file +4 -0
+	"-m raid10 -d raid10"
+	"-m raid5 -d raid5"
+	"-m raid6 -d raid6"
+)

I wonder should we add the mkfs options there.
Since xfstests already use environment MKFS_OPTIONS to do mkfs, if really need to test all mkfs options, IMO it is better to change MKFS_OPTIONS on each test round.

Hmmm - I you didn't read the code, because:

Quoted 11 lines
Quoted 10 lines

tests/btrfs/057 line 74

Quoted 10 lines
tests/btrfs/057 new file +10 -0
+run_test()
+{
+	local mkfs_opts=$1
+	local saved_mkfs_opts=$MKFS_OPTIONS
+	local subvol_mnt=$tmp.mnt
+
+	echo "Test $mkfs_opts" >>$seqres.full
+
+	MKFS_OPTIONS="$MKFS_OPTIONS $mkfs_opts"
+	# dup only works on single device

it's doing exactly what you suggest.

I am afraid that you misunderstand what I mean...
I just mean these mount option should be done by setting environment before runing check or set in local.conf.

Although Eryu Guan has already explaines this and it is still needed.

Thanks,
Qu

Quoted 10 lines

And it's wrong. This:

_scratch_mkfs $mkfs_opts

is all that is needed. This wheel does not need reinventing. ;)

Cheers,

Dave.

#7 lore raw

Re: [PATCH 01/15] btrfs: new test to run btrfs balance and subvolume test simultaneously

Quoted 16 lines · Qu Wenruo

-------- Original Message --------
Subject: Re: [PATCH 01/15] btrfs: new test to run btrfs balance and subvolume test simultaneously
From: Dave Chinner <[email protected]>
To: Qu Wenruo <[email protected]>
Date: 2014年08月21日 17:01

Quoted 9 lines · Qu Wenruo
Quoted 8 lines

-------- Original Message --------
Subject: [PATCH 01/15] btrfs: new test to run btrfs balance and subvolume test simultaneously
From: Eryu Guan <[email protected]>
To: <[email protected]>
Date: 2014年08月21日 01:33

Quoted 2 lines

Run btrfs balance and subvolume create/mount/umount/delete simultaneously, with fsstress running in background.

....

Quoted 28 lines
Quoted 17 lines
Quoted 7 lines
Quoted 7 lines
tests/btrfs/057 new file +7 -0
+# test case array
+tcs=(
+	"-m single -d single"
+	"-m dup -d single"
+	"-m raid0 -d raid0"
+	"-m raid1 -d raid0"
+	"-m raid1 -d raid1"
Quoted 8 lines

tests/btrfs/057 line 63

Quoted 4 lines
tests/btrfs/057 new file +4 -0
+	"-m raid10 -d raid10"
+	"-m raid5 -d raid5"
+	"-m raid6 -d raid6"
+)

I wonder should we add the mkfs options there.
Since xfstests already use environment MKFS_OPTIONS to do mkfs, if really need to test all mkfs options, IMO it is better to change MKFS_OPTIONS on each test round.

Hmmm - I you didn't read the code, because:

Quoted 11 lines
Quoted 10 lines

tests/btrfs/057 line 74

Quoted 10 lines
tests/btrfs/057 new file +10 -0
+run_test()
+{
+	local mkfs_opts=$1
+	local saved_mkfs_opts=$MKFS_OPTIONS
+	local subvol_mnt=$tmp.mnt
+
+	echo "Test $mkfs_opts" >>$seqres.full
+
+	MKFS_OPTIONS="$MKFS_OPTIONS $mkfs_opts"
+	# dup only works on single device

it's doing exactly what you suggest.

Quoted 3 lines

I am afraid that you misunderstand what I mean...
I just mean these mount option should be done by setting environment before runing check or set in local.conf.

You can override or append to MKFS_OPTIONS and MOUNT_OPTIONS in tests if required - lots of tests do exactly that (e.g. any quota test your care to name). That modification, however, is only valid for the specific test being run because the modification is to the environment of the test process, not the environment of check process that is running the tests....

i.e. Running custom mkfs or mount options like this is perfectly acceptable and I'm just commenting that the implementation of those custom options could be a lot better.

Cheers,

Dave.

Signature · 2 lines
Dave Chinner
[email protected]
#25 lore raw
In reply to Zach Brown
Quoted 59 lines · Zach Brown
Quoted 4 lines · Eryu Guan

This patchset add new stress test cases for btrfs by running two different btrfs operations simultaneously under fsstress to ensure btrfs doesn't hang or oops in such situations. btrfs scrub and btrfs check will be run after each test.

Cool.

Quoted 11 lines

The test matrix is the combination of 6 btrfs operations:

balance
create/mount/umount/delete subvolume replace device
scrub
defrag
remount with different compress algorithms

Short descriptions:

Quoted 15 lines
	057: balance-subvolume
	058: balance-scrub
	059: balance-defrag
	060: balance-remount
	061: balance-replace
	062: subvolume-replace
	063: subvolume-scrub
	064: subvolume-defrag
	065: subvolume-remount
	066: replace-scrub
	067: replace-defrag
	068: replace-remount
	069: scrub-defrag
	070: scrub-remount
	071: defrag-remount

But I'm not sure it should be built this way.

At the very least each operation's implementation should be in a shared function somewhere instead of being duplicated in each test.

But I don't think there should be a seperate test for each combination. With a bit of fiddly bash you can automate generating unique combinations of operations that are defined as functions in one test.

btrfs_op_balance()
{
echo hi
}

btrfs_op_scrub()
{
echo hi
}

btrfs_op_defrag()
{
echo hi
}

Quoted 8 lines

ops=($(declare -F | awk '/-f btrfs_op_/ {print $3}')) nr=${#ops[@]}

for i in $(seq 0 $((nr - 2))); do
for j in $(seq $((i + 1)) $((nr - 1))); do

	echo ${ops[i]} ${ops[j]}

done
done

Yes, it could be done like that, but historically that has proven to be a bad idea. Multiplexing tens of tests within a single test is just makes it hard to determine what failed. It might fail one combination in 3.16, a different combo in 3.17 and yet another in 3.18. But from a reporting point of view, all we see is that a single test failed, rather than being able to see that there were three separate problems and that btrfs_op_scrub() was the common factor in all three failures.

It's trivial to write this as a bunch of helper functions and then boiler-plate the actual tests themselves. There will be little difference in terms of run time, but we get much more fine-grained control of execution and reporting....

Cheers,

Dave.

Signature · 2 lines
Dave Chinner
[email protected]
author
#8 lore raw

Re: [PATCH 01/15] btrfs: new test to run btrfs balance and subvolume test simultaneously

In reply to Dave Chinner
Quoted 12 lines · Dave Chinner
Quoted 11 lines · Qu Wenruo

-------- Original Message --------
Subject: [PATCH 01/15] btrfs: new test to run btrfs balance and subvolume test simultaneously
From: Eryu Guan <[email protected]>
To: <[email protected]>
Date: 2014年08月21日 01:33

Quoted 4 lines

Run btrfs balance and subvolume create/mount/umount/delete simultaneously, with fsstress running in background.

[snip]

Quoted 39 lines
Quoted 15 lines
Quoted 15 lines
tests/btrfs/057 new file +15 -0
+# real QA test starts here
+_supported_fs btrfs
+_supported_os Linux
+_require_scratch
+_require_scratch_dev_pool 4
+
+rm -f $seqres.full
+
+# test case array
+tcs=(
+	"-m single -d single"
+	"-m dup -d single"
+	"-m raid0 -d raid0"
+	"-m raid1 -d raid0"
+	"-m raid1 -d raid1"
Quoted 8 lines

tests/btrfs/057 line 63

Quoted 4 lines
tests/btrfs/057 new file +4 -0
+	"-m raid10 -d raid10"
+	"-m raid5 -d raid5"
+	"-m raid6 -d raid6"
+)

I wonder should we add the mkfs options there.
Since xfstests already use environment MKFS_OPTIONS to do mkfs, if really need to test all mkfs options, IMO it is better to change MKFS_OPTIONS on each test round.

Hmmm - I you didn't read the code, because:

Quoted 10 lines

tests/btrfs/057 line 74

Quoted 10 lines
tests/btrfs/057 new file +10 -0
+run_test()
+{
+	local mkfs_opts=$1
+	local saved_mkfs_opts=$MKFS_OPTIONS
+	local subvol_mnt=$tmp.mnt
+
+	echo "Test $mkfs_opts" >>$seqres.full
+
+	MKFS_OPTIONS="$MKFS_OPTIONS $mkfs_opts"
+	# dup only works on single device

it's doing exactly what you suggest.

Quoted 5 lines

And it's wrong. This:

_scratch_mkfs $mkfs_opts

is all that is needed. This wheel does not need reinventing. ;)

I just noticed _scratch_pool_mkfs could do the same, thanks for the reminder!

Thanks,
Eryu

Quoted 7 lines

Cheers,

Dave.

Signature · 2 lines
Dave Chinner
[email protected]
#26 lore raw
In reply to Dave Chinner
Quoted 4 lines

It's trivial to write this as a bunch of helper functions and then boiler-plate the actual tests themselves. There will be little difference in terms of run time, but we get much more fine-grained control of execution and reporting....

Sure, that's reasonable, given the xfstests infrastructure.

- z