Skip to contentSkip to conversation

xfstests: new btrfs stress test cases

PATCH Superseded Eryu Guan 2 participants 22 messages Sep 26, 2014 – Sep 30, 2014 Btrfs file system

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Eryu Guan

author
#0 lore raw

v4 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:

	059: balance-subvolume
	060: balance-scrub
	061: balance-defrag
	062: balance-remount
	063: balance-replace
	064: subvolume-replace
	065: subvolume-scrub
	066: subvolume-defrag
	067: subvolume-remount
	068: replace-scrub
	069: replace-defrag
	070: replace-remount
	071: scrub-defrag
	072: scrub-remount
	073: 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
http://www.spinics.net/lists/linux-btrfs/msg36779.html

2. btrfs replace operation always returns ENOENT if balance is running So in 063.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+ and 3.17-rc2+) with fsstress running So case 064/068/069/070 will hang

4. scrub finds both correctable and uncorrectable errors in 070

I applied the patch manually which fixes the replace hang issue and 070 exposed this bug. RAID1 and RAID10 profile fail this test. single and RAID0 seem fine.

070.full shows:

Scrub find errors in "-m raid1 -d raid0" test
scrub done for f4a0dd71-f738-454a-bcec-7f137927fda0
scrub started at Fri Sep 26 11:25:36 2014 and finished after 1 seconds total bytes scrubbed: 56.00MiB with 2 errors
error details: csum=2
corrected errors: 0, uncorrectable errors: 2, unverified errors: 0

Scrub find errors in "-m raid1 -d raid1" test
scrub done for 2c6ee91f-926b-462b-a790-72c043ea260f
scrub started at Fri Sep 26 11:26:24 2014 and finished after 2 seconds total bytes scrubbed: 114.58MiB with 8 errors
error details: csum=8
corrected errors: 8, uncorrectable errors: 0, unverified errors: 0

Scrub find errors in "-m raid10 -d raid10" test
scrub done for f3038bbd-5b0e-4651-9e0f-b9b7703fdf84
scrub started at Fri Sep 26 11:26:52 2014 and finished after 2 seconds total bytes scrubbed: 104.90MiB with 7 errors
error details: csum=7
corrected errors: 7, uncorrectable errors: 0, unverified errors: 0

v4:
- do sanity check in _btrfs_stress_replace to check if the last device is free
- wait for replace operation to finish in 070 not defrag operation

v3: http://www.spinics.net/lists/linux-btrfs/msg37619.html
- mount subvolume at $TEST_DIR/$seq.mnt not $tmp.mnt
- don't rm -rf $tmp.* which is dangerous
- remove unnecessary btrfs filesystem sync operation
- update _scratch_pool_mkfs to deal with dup profile
- add more comments for each stress operation
- rename _btrfs_stress_remount to _btrfs_stress_remount_compress (hope it's better...)
- add _btrfs_get_profile_configs to remove duplicated test case array in each case
- use _require_scratch_nocheck and _check_scratch_fs after each loop

v2: http://www.spinics.net/lists/linux-btrfs/msg37071.html
- put common operations in common/rc as functions and share them across these tests
- append mkfs options to _scratch_mkfs and _scratch_pool_mkfs instead of updating $MKFS_OPTIONS
- rebase on top of master and re-number starting from btrfs/059

v1: http://www.spinics.net/lists/linux-btrfs/msg36859.html

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 simultaneously
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 operations 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 defferent 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           | 226 +++++++++++++++++++++++++++++++++++++++++++++++++++-
 tests/btrfs/059     | 115 ++++++++++++++++++++++++++
 tests/btrfs/059.out |   2 +
 tests/btrfs/060     | 114 ++++++++++++++++++++++++++
 tests/btrfs/060.out |   2 +
 tests/btrfs/061     | 116 +++++++++++++++++++++++++++
 tests/btrfs/061.out |   2 +
 tests/btrfs/062     | 114 ++++++++++++++++++++++++++
 tests/btrfs/062.out |   2 +
 tests/btrfs/063     | 122 ++++++++++++++++++++++++++++
 tests/btrfs/063.out |   2 +
 tests/btrfs/064     | 123 ++++++++++++++++++++++++++++
 tests/btrfs/064.out |   2 +
 tests/btrfs/065     | 115 ++++++++++++++++++++++++++
 tests/btrfs/065.out |   2 +
 tests/btrfs/066     | 117 +++++++++++++++++++++++++++
 tests/btrfs/066.out |   2 +
 tests/btrfs/067     | 116 +++++++++++++++++++++++++++
 tests/btrfs/067.out |   2 +
 tests/btrfs/068     | 123 ++++++++++++++++++++++++++++
 tests/btrfs/068.out |   2 +
 tests/btrfs/069     | 125 +++++++++++++++++++++++++++++
 tests/btrfs/069.out |   2 +
 tests/btrfs/070     | 123 ++++++++++++++++++++++++++++
 tests/btrfs/070.out |   2 +
 tests/btrfs/071     | 116 +++++++++++++++++++++++++++
 tests/btrfs/071.out |   2 +
 tests/btrfs/072     | 114 ++++++++++++++++++++++++++
 tests/btrfs/072.out |   2 +
 tests/btrfs/073     | 116 +++++++++++++++++++++++++++
 tests/btrfs/073.out |   2 +
 tests/btrfs/group   |  15 ++++
 32 files changed, 2036 insertions(+), 4 deletions(-)
 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
 create mode 100755 tests/btrfs/072
 create mode 100644 tests/btrfs/072.out
 create mode 100755 tests/btrfs/073
 create mode 100644 tests/btrfs/073.out
Signature · 1 line
1.8.3.1
author
#1 lore raw

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

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

---
 common/rc           | 110 +++++++++++++++++++++++++++++++++++++++++++++++--
 tests/btrfs/059     | 115 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/059.out |   2 +
 tests/btrfs/group   |   1 +
 4 files changed, 224 insertions(+), 4 deletions(-)
 create mode 100755 tests/btrfs/059
 create mode 100644 tests/btrfs/059.out
common/rc +106 -4
index 4dab101..2393c4b 100644
@@ -582,11 +582,17 @@ _scratch_pool_mkfs()
 {
     case $FSTYP in
     btrfs)
-	$MKFS_BTRFS_PROG $MKFS_OPTIONS $* $SCRATCH_DEV_POOL > /dev/null
-	;;
+        # if dup profile is in mkfs options call _scratch_mkfs instead
+        # because dup profile only works with single device
+        if [[ "$*" =~ dup ]]; then
+            _scratch_mkfs $*
+        else
+            $MKFS_BTRFS_PROG $MKFS_OPTIONS $* $SCRATCH_DEV_POOL > /dev/null
+        fi
+        ;;
     *)
-	echo "_scratch_pool_mkfs is not implemented for $FSTYP" 1>&2
-	;;
+        echo "_scratch_pool_mkfs is not implemented for $FSTYP" 1>&2
+        ;;
     esac
 }
 
@@ -2489,6 +2495,102 @@ _get_free_inode()
 	echo $nr_inode
 }
 
+# get btrfs profile configs being tested
+#
+# A set of pre-set profile configs are exported via _btrfs_profile_configs
+# array. Default configs can be overridden by setting BTRFS_PROFILE_CONFIGS
+# var in the format "metadata_profile:data_profile", multiple configs can be
+# seperated by space, e.g.
+# export BTRFS_PROFILE_CONFIGS="raid0:raid0 raid1:raid1 dup:single"
+_btrfs_get_profile_configs()
+{
+	if [ "$FSTYP" != "btrfs" ]; then
+		return
+	fi
+
+	# no user specified btrfs profile configs, export the default configs
+	if [ -z "$BTRFS_PROFILE_CONFIGS" ]; then
+		# default configs
+		_btrfs_profile_configs=(
+			"-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"
+		)
+
+		# remove dup/raid5/raid6 profiles if we're doing device replace
+		# dup profile indicates only one device being used (SCRATCH_DEV),
+		# but we don't want to replace SCRATCH_DEV, which will be used in
+		# _scratch_mount/_check_scratch_fs etc.
+		# and raid5/raid6 doesn't support replace yet
+		if [ "$1" == "replace" ]; then
+			_btrfs_profile_configs=(
+				"-m single -d single"
+				"-m raid0 -d raid0"
+				"-m raid1 -d raid0"
+				"-m raid1 -d raid1"
+				"-m raid10 -d raid10"
+				# add these back when raid5/6 is working with replace
+				#"-m raid5 -d raid5"
+				#"-m raid6 -d raid6"
+			)
+		fi
+		export _btrfs_profile_configs
+		return
+	fi
+
+	# parse user specified btrfs profile configs
+	local i=0
+	local cfg=""
+	for cfg in $BTRFS_PROFILE_CONFIGS; do
+		# turn "metadata:data" format to "-m metadata -d data"
+		# and assign it to _btrfs_profile_configs array
+		cfg=`echo "$cfg" | sed -e 's/^/-m /' -e 's/:/ -d /'`
+		_btrfs_profile_configs[$i]="$cfg"
+		let i=i+1
+	done
+
+	if [ "$1" == "replace" ]; then
+		if echo ${_btrfs_profile_configs[*]} | grep -q raid[56]; then
+			_notrun "RAID5/6 doesn't support btrfs device replace yet"
+		fi
+	   	if echo ${_btrfs_profile_configs[*]} | grep -q dup; then
+			_notrun "Do not set dup profile in btrfs device replace test"
+		fi
+	fi
+	export _btrfs_profile_configs
+}
+
+# stress btrfs by running balance operation in a loop
+_btrfs_stress_balance()
+{
+	local btrfs_mnt=$1
+	while true; do
+		$BTRFS_UTIL_PROG balance start $btrfs_mnt
+	done
+}
+
+# stress btrfs by creating/mounting/umounting/deleting subvolume in a loop
+_btrfs_stress_subvolume()
+{
+	local btrfs_dev=$1
+	local btrfs_mnt=$2
+	local subvol_name=$3
+	local subvol_mnt=$4
+
+	mkdir -p $subvol_mnt
+	while true; do
+		$BTRFS_UTIL_PROG subvolume create $btrfs_mnt/$subvol_name
+		$MOUNT_PROG -o subvol=$subvol_name $btrfs_dev $subvol_mnt
+		$UMOUNT_PROG $subvol_mnt
+		$BTRFS_UTIL_PROG subvolume delete $btrfs_mnt/$subvol_name
+	done
+}
+
 init_rc()
 {
 	if [ "$iam" == new ]
tests/btrfs/059 new file +115 -0

115 lines not on this page · raw message

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 3fa9778..c66c42c 100644
@@ -61,3 +61,4 @@
 056 auto quick
 057 auto quick
 058 auto quick
+059 auto balance subvol
Signature · 1 line
1.8.3.1
#2 lore raw

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

Quoted 231 lines · Eryu Guan

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

---
  common/rc           | 110 +++++++++++++++++++++++++++++++++++++++++++++++--
  tests/btrfs/059     | 115 ++++++++++++++++++++++++++++++++++++++++++++++++++++
  tests/btrfs/059.out |   2 +
  tests/btrfs/group   |   1 +
  4 files changed, 224 insertions(+), 4 deletions(-)

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

common/rc +106 -4
index 4dab101..2393c4b 100644
@@ -582,11 +582,17 @@ _scratch_pool_mkfs()
  {
      case $FSTYP in
      btrfs)
-	$MKFS_BTRFS_PROG $MKFS_OPTIONS $* $SCRATCH_DEV_POOL > /dev/null
-	;;
+        # if dup profile is in mkfs options call _scratch_mkfs instead
+        # because dup profile only works with single device
+        if [[ "$*" =~ dup ]]; then
+            _scratch_mkfs $*
+        else
+            $MKFS_BTRFS_PROG $MKFS_OPTIONS $* $SCRATCH_DEV_POOL > /dev/null
+        fi
+        ;;
      *)
-	echo "_scratch_pool_mkfs is not implemented for $FSTYP" 1>&2
-	;;
+        echo "_scratch_pool_mkfs is not implemented for $FSTYP" 1>&2
+        ;;
      esac
  }
 
@@ -2489,6 +2495,102 @@ _get_free_inode()
  	echo $nr_inode
  }
 
+# get btrfs profile configs being tested
+#
+# A set of pre-set profile configs are exported via _btrfs_profile_configs
+# array. Default configs can be overridden by setting BTRFS_PROFILE_CONFIGS
+# var in the format "metadata_profile:data_profile", multiple configs can be
+# seperated by space, e.g.
+# export BTRFS_PROFILE_CONFIGS="raid0:raid0 raid1:raid1 dup:single"
+_btrfs_get_profile_configs()
+{
+	if [ "$FSTYP" != "btrfs" ]; then
+		return
+	fi
+
+	# no user specified btrfs profile configs, export the default configs
+	if [ -z "$BTRFS_PROFILE_CONFIGS" ]; then
+		# default configs
+		_btrfs_profile_configs=(
+			"-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"
+		)
+
+		# remove dup/raid5/raid6 profiles if we're doing device replace
+		# dup profile indicates only one device being used (SCRATCH_DEV),
+		# but we don't want to replace SCRATCH_DEV, which will be used in
+		# _scratch_mount/_check_scratch_fs etc.
+		# and raid5/raid6 doesn't support replace yet
+		if [ "$1" == "replace" ]; then
+			_btrfs_profile_configs=(
+				"-m single -d single"
+				"-m raid0 -d raid0"
+				"-m raid1 -d raid0"
+				"-m raid1 -d raid1"
+				"-m raid10 -d raid10"
+				# add these back when raid5/6 is working with replace
+				#"-m raid5 -d raid5"
+				#"-m raid6 -d raid6"
+			)
+		fi
+		export _btrfs_profile_configs
+		return
+	fi
+
+	# parse user specified btrfs profile configs
+	local i=0
+	local cfg=""
+	for cfg in $BTRFS_PROFILE_CONFIGS; do
+		# turn "metadata:data" format to "-m metadata -d data"
+		# and assign it to _btrfs_profile_configs array
+		cfg=`echo "$cfg" | sed -e 's/^/-m /' -e 's/:/ -d /'`
+		_btrfs_profile_configs[$i]="$cfg"
+		let i=i+1
+	done
+
+	if [ "$1" == "replace" ]; then
+		if echo ${_btrfs_profile_configs[*]} | grep -q raid[56]; then
+			_notrun "RAID5/6 doesn't support btrfs device replace yet"
+		fi
+	   	if echo ${_btrfs_profile_configs[*]} | grep -q dup; then
+			_notrun "Do not set dup profile in btrfs device replace test"
+		fi
+	fi
+	export _btrfs_profile_configs
+}
+
+# stress btrfs by running balance operation in a loop
+_btrfs_stress_balance()
+{
+	local btrfs_mnt=$1
+	while true; do
+		$BTRFS_UTIL_PROG balance start $btrfs_mnt
+	done
+}
+
+# stress btrfs by creating/mounting/umounting/deleting subvolume in a loop
+_btrfs_stress_subvolume()
+{
+	local btrfs_dev=$1
+	local btrfs_mnt=$2
+	local subvol_name=$3
+	local subvol_mnt=$4
+
+	mkdir -p $subvol_mnt
+	while true; do
+		$BTRFS_UTIL_PROG subvolume create $btrfs_mnt/$subvol_name
+		$MOUNT_PROG -o subvol=$subvol_name $btrfs_dev $subvol_mnt
+		$UMOUNT_PROG $subvol_mnt
+		$BTRFS_UTIL_PROG subvolume delete $btrfs_mnt/$subvol_name
+	done
+}
+
  init_rc()
  {
  	if [ "$iam" == new ]
tests/btrfs/059 new file +83 -0
new file mode 100755
index 0000000..5017299
@@ -0,0 +1,115 @@
+#! /bin/bash
+# FSQA Test No. btrfs/059
+#
+# 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 -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_fs btrfs
+_supported_os Linux
+# we check scratch dev after each loop
+_require_scratch_nocheck
+_require_scratch_dev_pool 4
+_btrfs_get_profile_configs
+
+rm -f $seqres.full
+
+run_test()
+{
+	local mkfs_opts=$1
+	local subvol_mnt=$TEST_DIR/$seq.mnt
+
+	echo "Test $mkfs_opts" >>$seqres.full
+
+	_scratch_pool_mkfs $mkfs_opts >>$seqres.full 2>&1
+	# make sure we created btrfs with desired options
+	if [ $? -ne 0 ]; then
+		echo "mkfs $mkfs_opts failed" | tee -a $seqres.full
+		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
+	_btrfs_stress_balance $SCRATCH_MNT >/dev/null 2>&1 &
+	balance_pid=$!
+	echo "$balance_pid" >>$seqres.full
+
+	echo -n "Start subvolume worker: " >>$seqres.full
+	_btrfs_stress_subvolume $SCRATCH_DEV $SCRATCH_MNT subvol_$$ $subvol_mnt >/dev/null 2>&1 &
+	subvol_pid=$!
+	echo "$subvol_pid" >>$seqres.full

tests/btrfs/059 line 93

Quoted 10 lines
tests/btrfs/059 new file +10 -0
+
+	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
+	wait $fsstress_pid
+
+	kill $balance_pid $subvol_pid
+	wait
+	# wait for the balance operation to finish
+	while ps aux | grep "balance start" | grep -qv grep; do
+		sleep 1
+	done

This bit isn't needed, killing the balance pid also won't do anything, just waiting is enough, it'll only exit once the balance is finished. If you really want to stop the balance you can use

btrfs ba cancel

and then just wait for the pid to exit, that is good enough. Thanks,

Josef

author
#3 lore raw

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

Quoted 6 lines · Josef Bacik
Quoted 5 lines · Eryu Guan

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

---

[snip]

Quoted 20 lines
Quoted 20 lines
(quoted diff) +20 -0
+	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
+	_btrfs_stress_balance $SCRATCH_MNT >/dev/null 2>&1 &
+	balance_pid=$!
+	echo "$balance_pid" >>$seqres.full
+
+	echo -n "Start subvolume worker: " >>$seqres.full
+	_btrfs_stress_subvolume $SCRATCH_DEV $SCRATCH_MNT subvol_$$ $subvol_mnt >/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
Quoted 8 lines

Review

Quoted 4 lines
(quoted diff) +4 -0
+	# wait for the balance operation to finish
+	while ps aux | grep "balance start" | grep -qv grep; do
+		sleep 1
+	done

This bit isn't needed, killing the balance pid also won't do anything, just waiting is enough, it'll only exit once the balance is finished. If you really want to stop the balance you can use

I think it's still needed, or the balance process would block the later umount and test fails like

root/xfstests/results//btrfs/059.out.bad 2014-09-30 23:29:47.538310375 +0800 renamed from btrfs/059.out 2014-09-26 11:35:43.932850826 +0800 +7 -0
@@ -1,2 +1,9 @@
 QA output created by 059
 Silence is golden
+umount: /mnt/testarea/scratch: target is busy.
+        (In some cases useful info about processes that use
+         the device is found by lsof(8) or fuser(1))
+umount: /mnt/testarea/scratch: target is busy.
+        (In some cases useful info about processes that use
+         the device is found by lsof(8) or fuser(1))
+_check_btrfs_filesystem: filesystem on /dev/mapper/rhel_hp--dl388eg8--01-testlv2 is inconsistent (see /root/xfstests/results//btrfs/059.full)

Adding debug output of "lsof $SCRATCH_MNT" and "ps aux | grep btrfs" before umount shows it's the balance process is still running and blocks the umount.

lsof /mnt/testarea/scratch
btrfs 13491 root 3r DIR 0,40 42 256 /mnt/testarea/scratch
ps aux | grep btrfs
....
root 13491 7.0 0.0 18660 1312 pts/1 D+ 23:29 0:00 /usr/sbin/btrfs balance start /mnt/testarea/scratch

Killing the balance pid is to stop any further balance operation, wait is waiting for the child process (_btrfs_stress_balance), not the child's child process (balance process). So only wait is not enough, we should wait for the balance to finish explicitly.

This is also true for the rest of the test cases in this series. This is kind of ugly, but I cannot figure out a better solution right now..

Thanks,
Eryu

Reviewed-by
#4 lore raw

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

Quoted 63 lines · Eryu Guan
Quoted 6 lines · Josef Bacik
Quoted 5 lines · Eryu Guan

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

---

[snip]

Quoted 20 lines
Quoted 20 lines
(quoted diff) +20 -0
+	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
+	_btrfs_stress_balance $SCRATCH_MNT >/dev/null 2>&1 &
+	balance_pid=$!
+	echo "$balance_pid" >>$seqres.full
+
+	echo -n "Start subvolume worker: " >>$seqres.full
+	_btrfs_stress_subvolume $SCRATCH_DEV $SCRATCH_MNT subvol_$$ $subvol_mnt >/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
Quoted 8 lines

Review

Quoted 4 lines
(quoted diff) +4 -0
+	# wait for the balance operation to finish
+	while ps aux | grep "balance start" | grep -qv grep; do
+		sleep 1
+	done

This bit isn't needed, killing the balance pid also won't do anything, just waiting is enough, it'll only exit once the balance is finished. If you really want to stop the balance you can use

I think it's still needed, or the balance process would block the later umount and test fails like

root/xfstests/results//btrfs/059.out.bad 2014-09-30 23:29:47.538310375 +0800 renamed from btrfs/059.out 2014-09-26 11:35:43.932850826 +0800 +7 -0
@@ -1,2 +1,9 @@
  QA output created by 059
  Silence is golden
+umount: /mnt/testarea/scratch: target is busy.
+        (In some cases useful info about processes that use
+         the device is found by lsof(8) or fuser(1))
+umount: /mnt/testarea/scratch: target is busy.
+        (In some cases useful info about processes that use
+         the device is found by lsof(8) or fuser(1))
+_check_btrfs_filesystem: filesystem on /dev/mapper/rhel_hp--dl388eg8--01-testlv2 is inconsistent (see /root/xfstests/results//btrfs/059.full)

Adding debug output of "lsof $SCRATCH_MNT" and "ps aux | grep btrfs" before umount shows it's the balance process is still running and blocks the umount.

lsof /mnt/testarea/scratch
btrfs 13491 root 3r DIR 0,40 42 256 /mnt/testarea/scratch
ps aux | grep btrfs
....
root 13491 7.0 0.0 18660 1312 pts/1 D+ 23:29 0:00 /usr/sbin/btrfs balance start /mnt/testarea/scratch

Quoted 8 lines

Killing the balance pid is to stop any further balance operation, wait is waiting for the child process (_btrfs_stress_balance), not the child's child process (balance process). So only wait is not enough, we should wait for the balance to finish explicitly.

This is also true for the rest of the test cases in this series. This is kind of ugly, but I cannot figure out a better solution right now..

Oh duh sorry, I missed that it was a loop of btrfs balance start, not just btrfs balance start &. Ok in that case instead use

btrfs balance status

and loop on that until it is done and then exit, that way it is clear what we are waiting on, but really I'm not married to the idea either so if it ends up being too much trouble just skip it. You can add

Whenever you re-roll with your whitespace changes and whatever other cleanups you add. Thanks,

Josef

author
#5 lore raw

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

Quoted 78 lines · Josef Bacik
Quoted 63 lines · Eryu Guan
Quoted 6 lines · Josef Bacik
Quoted 5 lines · Eryu Guan

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

---

[snip]

Quoted 20 lines
Quoted 20 lines
(quoted diff) +20 -0
+	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
+	_btrfs_stress_balance $SCRATCH_MNT >/dev/null 2>&1 &
+	balance_pid=$!
+	echo "$balance_pid" >>$seqres.full
+
+	echo -n "Start subvolume worker: " >>$seqres.full
+	_btrfs_stress_subvolume $SCRATCH_DEV $SCRATCH_MNT subvol_$$ $subvol_mnt >/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
Quoted 8 lines

Review

Quoted 4 lines
(quoted diff) +4 -0
+	# wait for the balance operation to finish
+	while ps aux | grep "balance start" | grep -qv grep; do
+		sleep 1
+	done

This bit isn't needed, killing the balance pid also won't do anything, just waiting is enough, it'll only exit once the balance is finished. If you really want to stop the balance you can use

I think it's still needed, or the balance process would block the later umount and test fails like

root/xfstests/results//btrfs/059.out.bad 2014-09-30 23:29:47.538310375 +0800 renamed from btrfs/059.out 2014-09-26 11:35:43.932850826 +0800 +7 -0
@@ -1,2 +1,9 @@
 QA output created by 059
 Silence is golden
+umount: /mnt/testarea/scratch: target is busy.
+        (In some cases useful info about processes that use
+         the device is found by lsof(8) or fuser(1))
+umount: /mnt/testarea/scratch: target is busy.
+        (In some cases useful info about processes that use
+         the device is found by lsof(8) or fuser(1))
+_check_btrfs_filesystem: filesystem on /dev/mapper/rhel_hp--dl388eg8--01-testlv2 is inconsistent (see /root/xfstests/results//btrfs/059.full)

Adding debug output of "lsof $SCRATCH_MNT" and "ps aux | grep btrfs" before umount shows it's the balance process is still running and blocks the umount.

lsof /mnt/testarea/scratch
btrfs 13491 root 3r DIR 0,40 42 256 /mnt/testarea/scratch
ps aux | grep btrfs
....
root 13491 7.0 0.0 18660 1312 pts/1 D+ 23:29 0:00 /usr/sbin/btrfs balance start /mnt/testarea/scratch

Quoted 8 lines

Killing the balance pid is to stop any further balance operation, wait is waiting for the child process (_btrfs_stress_balance), not the child's child process (balance process). So only wait is not enough, we should wait for the balance to finish explicitly.

This is also true for the rest of the test cases in this series. This is kind of ugly, but I cannot figure out a better solution right now..

Oh duh sorry, I missed that it was a loop of btrfs balance start, not just btrfs balance start &. Ok in that case instead use

btrfs balance status

Quoted 8 lines

and loop on that until it is done and then exit, that way it is clear what we are waiting on, but really I'm not married to the idea either so if it ends up being too much trouble just skip it. You can add

Whenever you re-roll with your whitespace changes and whatever other cleanups you add. Thanks,

Thanks for your review!

Just want to confirm with you, do you mean I can add your reviewed-by for the whole patchset or just the first one?

Thanks,
Eryu

#6 lore raw

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

Quoted 85 lines · Eryu Guan
Quoted 84 lines · Josef Bacik
Quoted 63 lines · Eryu Guan
Quoted 6 lines · Josef Bacik
Quoted 5 lines · Eryu Guan

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

---

[snip]

Quoted 20 lines
Quoted 20 lines
(quoted diff) +20 -0
+	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
+	_btrfs_stress_balance $SCRATCH_MNT >/dev/null 2>&1 &
+	balance_pid=$!
+	echo "$balance_pid" >>$seqres.full
+
+	echo -n "Start subvolume worker: " >>$seqres.full
+	_btrfs_stress_subvolume $SCRATCH_DEV $SCRATCH_MNT subvol_$$ $subvol_mnt >/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
Quoted 8 lines

Review

Quoted 4 lines
(quoted diff) +4 -0
+	# wait for the balance operation to finish
+	while ps aux | grep "balance start" | grep -qv grep; do
+		sleep 1
+	done

This bit isn't needed, killing the balance pid also won't do anything, just waiting is enough, it'll only exit once the balance is finished. If you really want to stop the balance you can use

I think it's still needed, or the balance process would block the later umount and test fails like

root/xfstests/results//btrfs/059.out.bad 2014-09-30 23:29:47.538310375 +0800 renamed from btrfs/059.out 2014-09-26 11:35:43.932850826 +0800 +7 -0
@@ -1,2 +1,9 @@
  QA output created by 059
  Silence is golden
+umount: /mnt/testarea/scratch: target is busy.
+        (In some cases useful info about processes that use
+         the device is found by lsof(8) or fuser(1))
+umount: /mnt/testarea/scratch: target is busy.
+        (In some cases useful info about processes that use
+         the device is found by lsof(8) or fuser(1))
+_check_btrfs_filesystem: filesystem on /dev/mapper/rhel_hp--dl388eg8--01-testlv2 is inconsistent (see /root/xfstests/results//btrfs/059.full)

Adding debug output of "lsof $SCRATCH_MNT" and "ps aux | grep btrfs" before umount shows it's the balance process is still running and blocks the umount.

lsof /mnt/testarea/scratch
btrfs 13491 root 3r DIR 0,40 42 256 /mnt/testarea/scratch
ps aux | grep btrfs
....
root 13491 7.0 0.0 18660 1312 pts/1 D+ 23:29 0:00 /usr/sbin/btrfs balance start /mnt/testarea/scratch

Quoted 8 lines

Killing the balance pid is to stop any further balance operation, wait is waiting for the child process (_btrfs_stress_balance), not the child's child process (balance process). So only wait is not enough, we should wait for the balance to finish explicitly.

This is also true for the rest of the test cases in this series. This is kind of ugly, but I cannot figure out a better solution right now..

Oh duh sorry, I missed that it was a loop of btrfs balance start, not just btrfs balance start &. Ok in that case instead use

btrfs balance status

and loop on that until it is done and then exit, that way it is clear what we are waiting on, but really I'm not married to the idea either so if it ends up being too much trouble just skip it. You can add

Quoted 7 lines
Quoted 2 lines

Whenever you re-roll with your whitespace changes and whatever other cleanups you add. Thanks,

Thanks for your review!

Just want to confirm with you, do you mean I can add your reviewed-by for the whole patchset or just the first one?

Oh sorry, the whole patchset. Thanks,

Josef

author
#7 lore raw

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

In reply to Eryu Guan

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

---
 common/rc           |   9 +++++
 tests/btrfs/060     | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/060.out |   2 +
 tests/btrfs/group   |   1 +
 4 files changed, 126 insertions(+)
 create mode 100755 tests/btrfs/060
 create mode 100644 tests/btrfs/060.out
common/rc +9 -0
index 2393c4b..d1dec8a 100644
@@ -2591,6 +2591,15 @@ _btrfs_stress_subvolume()
 	done
 }
 
+# stress btrfs by running scrub in a loop
+_btrfs_stress_scrub()
+{
+	local btrfs_mnt=$1
+	while true; do
+		$BTRFS_UTIL_PROG scrub start -B $btrfs_mnt
+	done
+}
+
 init_rc()
 {
 	if [ "$iam" == new ]
tests/btrfs/060 new file +114 -0

114 lines not on this page · raw message

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 c66c42c..1c60c8f 100644
@@ -62,3 +62,4 @@
 057 auto quick
 058 auto quick
 059 auto balance subvol
+060 auto balance scrub
Signature · 1 line
1.8.3.1
#8 lore raw

Re: [PATCH v4 02/15] btrfs: new test to run btrfs balance and scrub simultaneously

Quoted 123 lines · Eryu Guan

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

---
  common/rc           |   9 +++++
  tests/btrfs/060     | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++++
  tests/btrfs/060.out |   2 +
  tests/btrfs/group   |   1 +
  4 files changed, 126 insertions(+)

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

common/rc +9 -0
index 2393c4b..d1dec8a 100644
@@ -2591,6 +2591,15 @@ _btrfs_stress_subvolume()
  	done
  }
 
+# stress btrfs by running scrub in a loop
+_btrfs_stress_scrub()
+{
+	local btrfs_mnt=$1
+	while true; do
+		$BTRFS_UTIL_PROG scrub start -B $btrfs_mnt
+	done
+}
+
  init_rc()
  {
  	if [ "$iam" == new ]
tests/btrfs/060 new file +84 -0
new file mode 100755
index 0000000..b270c7b
@@ -0,0 +1,114 @@
+#! /bin/bash
+# FSQA Test No. btrfs/060
+#
+# 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 -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_fs btrfs
+_supported_os Linux
+# we check scratch dev after each loop
+_require_scratch_nocheck
+_require_scratch_dev_pool 4
+_btrfs_get_profile_configs
+
+rm -f $seqres.full
+
+run_test()
+{
+	local mkfs_opts=$1
+
+	echo "Test $mkfs_opts" >>$seqres.full
+
+	_scratch_pool_mkfs $mkfs_opts >>$seqres.full 2>&1
+	# 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 balance worker: " >>$seqres.full
+	_btrfs_stress_balance $SCRATCH_MNT >/dev/null 2>&1 &
+	balance_pid=$!
+	echo "$balance_pid" >>$seqres.full
+
+	echo -n "Start scrub worker: " >>$seqres.full
+	_btrfs_stress_scrub $SCRATCH_MNT >/dev/null 2>&1 &
+	scrub_pid=$!
+	echo "$scrub_pid" >>$seqres.full
+
+	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full

tests/btrfs/060 line 94

Quoted 10 lines
tests/btrfs/060 new file +10 -0
+	wait $fsstress_pid
+	kill $balance_pid $scrub_pid
+	wait
+	# wait for the balance and scrub operations 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

I'm just going to point this out here again and assume that it applies for every other patch in this series. Thanks,

Josef

author
#9 lore raw

PATCH v4 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.

---
 common/rc           |  20 +++++++++
 tests/btrfs/061     | 116 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/061.out |   2 +
 tests/btrfs/group   |   1 +
 4 files changed, 139 insertions(+)
 create mode 100755 tests/btrfs/061
 create mode 100644 tests/btrfs/061.out
common/rc +20 -0
index d1dec8a..b66fa79 100644
@@ -2600,6 +2600,26 @@ _btrfs_stress_scrub()
 	done
 }
 
+# stress btrfs by defragmenting every file/dir in a loop and compress file
+# contents while defragmenting if second argument is not "nocompress"
+_btrfs_stress_defrag()
+{
+	local btrfs_mnt=$1
+	local compress=$2
+
+	while true; do
+		if [ "$compress" == "nocompress" ]; then
+			find $btrfs_mnt \( -type f -o -type d \) -exec \
+			$BTRFS_UTIL_PROG filesystem defrag {} \;
+		else
+			find $btrfs_mnt \( -type f -o -type d \) -exec \
+			$BTRFS_UTIL_PROG filesystem defrag -clzo {} \;
+			find $btrfs_mnt \( -type f -o -type d \) -exec \
+			$BTRFS_UTIL_PROG filesystem defrag -czlib {} \;
+		fi
+	done
+}
+
 init_rc()
 {
 	if [ "$iam" == new ]
tests/btrfs/061 new file +116 -0

116 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 1c60c8f..85d30b3 100644
@@ -63,3 +63,4 @@
 058 auto quick
 059 auto balance subvol
 060 auto balance scrub
+061 auto balance defrag compress
Signature · 1 line
1.8.3.1
author
#10 lore raw

PATCH v4 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.

---
 common/rc           |  14 +++++++
 tests/btrfs/062     | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/062.out |   2 +
 tests/btrfs/group   |   1 +
 4 files changed, 131 insertions(+)
 create mode 100755 tests/btrfs/062
 create mode 100644 tests/btrfs/062.out
common/rc +14 -0
index b66fa79..b19533f 100644
@@ -2620,6 +2620,20 @@ _btrfs_stress_defrag()
 	done
 }
 
+# stress btrfs by remounting it with different compression algorithms in a loop
+# run this with fsstress running at background could exercise the compression
+# code path and ensure no race when switching compression algorithm with constant
+# I/O activity.
+_btrfs_stress_remount_compress()
+{
+	local btrfs_mnt=$1
+	while true; do
+		for algo in no zlib lzo; do
+			$MOUNT_PROG -o remount,compress=$algo $btrfs_mnt
+		done
+	done
+}
+
 init_rc()
 {
 	if [ "$iam" == new ]
tests/btrfs/062 new file +114 -0

114 lines not on this page · raw message

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 85d30b3..7aa9bf3 100644
@@ -64,3 +64,4 @@
 059 auto balance subvol
 060 auto balance scrub
 061 auto balance defrag compress
+062 auto balance remount compress
Signature · 1 line
1.8.3.1
author
#11 lore raw

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

In reply to Eryu Guan

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

---
 common/rc           |  73 +++++++++++++++++++++++++++++++
 tests/btrfs/063     | 122 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/063.out |   2 +
 tests/btrfs/group   |   1 +
 4 files changed, 198 insertions(+)
 create mode 100755 tests/btrfs/063
 create mode 100644 tests/btrfs/063.out
common/rc +73 -0
index b19533f..28c07f6 100644
@@ -2163,6 +2163,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()
 {
@@ -2634,6 +2652,61 @@ _btrfs_stress_remount_compress()
 	done
 }
 
+# stress btrfs by replacing devices in a loop
+# Note that at least 3 devices are needed in SCRATCH_DEV_POOL and the last
+# device should be free(not used by btrfs)
+_btrfs_stress_replace()
+{
+	local btrfs_mnt=$1
+
+	# The device number in SCRATCH_DEV_POOL should be at least 3,
+	# one is SCRATCH_DEV, one is to be replaced, one is free device
+	# we won't replace SCRATCH_DEV, see below for reason
+	if [ "`echo $SCRATCH_DEV_POOL | wc -w`" -lt 3 ]; then
+		echo "_btrfs_stress_replace requires at least 3 devices in SCRATCH_DEV_POOL"
+		return
+	fi
+
+	# take the last device as the first free_dev
+	local free_dev="`echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $NF}'`"
+
+	# free_dev should be really free
+	if $BTRFS_UTIL_PROG filesystem show $btrfs_mnt | grep -q "$free_dev"; then
+		echo "_btrfs_stress_replace: $free_dev is used by btrfs"
+		return
+	fi
+
+	# dev_pool is device list being currently used by btrfs (excluding SCRATCH_DEV)
+	# and can be replaced. We don't replace SCRATCH_DEV because it will be used in
+	# _scratch_mount and _check_scratch_fs etc.
+	local dev_pool=`echo $SCRATCH_DEV_POOL | sed -e "s# *$SCRATCH_DEV *##" \
+			-e "s# *$free_dev *##"`
+
+	# set the first device in dev_pool as the first src_dev to be replaced
+	local src_dev=`echo $dev_pool | $AWK_PROG '{print $1}'`
+
+	echo "dev_pool=$dev_pool"
+	echo "free_dev=$free_dev, src_dev=$src_dev"
+	while true; do
+		echo "Replacing $src_dev with $free_dev"
+		$BTRFS_UTIL_PROG replace start -fB $src_dev $free_dev $btrfs_mnt
+		if [ $? -ne 0 ]; then
+			# don't update src_dev and free_dev if replace failed
+			continue
+		fi
+		dev_pool="$dev_pool $free_dev"
+		dev_pool=`echo $dev_pool | sed -e "s# *$src_dev *##"`
+		free_dev=$src_dev
+		src_dev=`echo $dev_pool | $AWK_PROG '{print $1}'`
+	done
+}
+
+# return device size in kb
+_get_device_size()
+{
+	grep `_short_dev $1` /proc/partitions | awk '{print $3}'
+}
+
 init_rc()
 {
 	if [ "$iam" == new ]
tests/btrfs/063 new file +122 -0

122 lines not on this page · raw message

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 7aa9bf3..e234bc2 100644
@@ -65,3 +65,4 @@
 060 auto balance scrub
 061 auto balance defrag compress
 062 auto balance remount compress
+063 auto balance replace
Signature · 1 line
1.8.3.1
author
#12 lore raw

PATCH v4 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/064     | 123 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/064.out |   2 +
 tests/btrfs/group   |   1 +
 3 files changed, 126 insertions(+)
 create mode 100755 tests/btrfs/064
 create mode 100644 tests/btrfs/064.out
tests/btrfs/064 new file +123 -0
new file mode 100755
index 0000000..319e480
@@ -0,0 +1,123 @@
+#! /bin/bash
+# FSQA Test No. btrfs/064
+#
+# 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 -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_fs btrfs
+_supported_os Linux
+# we check scratch dev after each loop
+_require_scratch_nocheck
+_require_scratch_dev_pool 5
+_require_scratch_dev_pool_equal_size
+_btrfs_get_profile_configs replace
+
+rm -f $seqres.full
+
+run_test()
+{
+	local mkfs_opts=$1
+	local saved_scratch_dev_pool=$SCRATCH_DEV_POOL
+	local subvol_mnt=$TEST_DIR/$seq.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 *##"`
+	_scratch_pool_mkfs $mkfs_opts >>$seqres.full 2>&1
+	# make sure we created btrfs with desired options
+	if [ $? -ne 0 ]; then
+		echo "mkfs $mkfs_opts failed"
+		SCRATCH_DEV_POOL=$saved_scratch_dev_pool
+		return
+	fi
+	_scratch_mount >>$seqres.full 2>&1
+	SCRATCH_DEV_POOL=$saved_scratch_dev_pool
+
+	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
+	_btrfs_stress_subvolume $SCRATCH_DEV $SCRATCH_MNT subvol_$$ $subvol_mnt >/dev/null 2>&1 &
+	subvol_pid=$!
+	echo "$subvol_pid" >>$seqres.full
+
+	echo -n "Start replace worker: " >>$seqres.full
+	_btrfs_stress_replace $SCRATCH_MNT >>$seqres.full 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
+	# wait for the replace operation 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
+
+	# in case the subvolume is still mounted
+	$UMOUNT_PROG $subvol_mnt >/dev/null 2>&1
+	_scratch_unmount
+	# we called _require_scratch_nocheck instead of _require_scratch
+	# do check after test for each profile config
+	_check_scratch_fs
+}
+
+echo "Silence is golden"
+for t in "${_btrfs_profile_configs[@]}"; do
+	run_test "$t"
+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 e234bc2..a214920 100644
@@ -66,3 +66,4 @@
 061 auto balance defrag compress
 062 auto balance remount compress
 063 auto balance replace
+064 auto subvol replace
Signature · 1 line
1.8.3.1
author
#13 lore raw

PATCH v4 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/065     | 115 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/065.out |   2 +
 tests/btrfs/group   |   1 +
 3 files changed, 118 insertions(+)
 create mode 100755 tests/btrfs/065
 create mode 100644 tests/btrfs/065.out
tests/btrfs/065 new file +115 -0
new file mode 100755
index 0000000..14fee63
@@ -0,0 +1,115 @@
+#! /bin/bash
+# FSQA Test No. btrfs/065
+#
+# 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 -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_fs btrfs
+_supported_os Linux
+# we check scratch dev after each loop
+_require_scratch_nocheck
+_require_scratch_dev_pool 4
+_btrfs_get_profile_configs
+
+rm -f $seqres.full
+
+run_test()
+{
+	local mkfs_opts=$1
+	local subvol_mnt=$TEST_DIR/$seq.mnt
+
+	echo "Test $mkfs_opts" >>$seqres.full
+
+	_scratch_pool_mkfs $mkfs_opts >>$seqres.full 2>&1
+	# 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
+	_btrfs_stress_subvolume $SCRATCH_DEV $SCRATCH_MNT subvol_$$ $subvol_mnt >/dev/null 2>&1 &
+	subvol_pid=$!
+	echo "$subvol_pid" >>$seqres.full
+
+	echo -n "Start scrub worker: " >>$seqres.full
+	_btrfs_stress_scrub $SCRATCH_MNT >/dev/null 2>&1 &
+	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
+	# wait for the scrub operation 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
+
+	# in case the subvolume is still mounted
+	$UMOUNT_PROG $subvol_mnt >/dev/null 2>&1
+	_scratch_unmount
+	# we called _require_scratch_nocheck instead of _require_scratch
+	# do check after test for each profile config
+	_check_scratch_fs
+}
+
+echo "Silence is golden"
+for t in "${_btrfs_profile_configs[@]}"; 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 a214920..4685970 100644
@@ -67,3 +67,4 @@
 062 auto balance remount compress
 063 auto balance replace
 064 auto subvol replace
+065 auto subvol scrub
Signature · 1 line
1.8.3.1
author
#14 lore raw

PATCH v4 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 operations simultaneously, with fsstress running in backgound.

---
 tests/btrfs/066     | 117 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/066.out |   2 +
 tests/btrfs/group   |   1 +
 3 files changed, 120 insertions(+)
 create mode 100755 tests/btrfs/066
 create mode 100644 tests/btrfs/066.out
tests/btrfs/066 new file +117 -0
new file mode 100755
index 0000000..d8e165d
@@ -0,0 +1,117 @@
+#! /bin/bash
+# FSQA Test No. btrfs/066
+#
+# 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 -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_fs btrfs
+_supported_os Linux
+# we check scratch dev after each loop
+_require_scratch_nocheck
+_require_scratch_dev_pool 4
+_btrfs_get_profile_configs
+
+rm -f $seqres.full
+
+run_test()
+{
+	local mkfs_opts=$1
+	local with_compress=$2
+	local subvol_mnt=$TEST_DIR/$seq.mnt
+
+	echo "Test $mkfs_opts with $with_compress" >>$seqres.full
+
+	_scratch_pool_mkfs $mkfs_opts >>$seqres.full 2>&1
+	# 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
+	_btrfs_stress_subvolume $SCRATCH_DEV $SCRATCH_MNT subvol_$$ $subvol_mnt >/dev/null 2>&1 &
+	subvol_pid=$!
+	echo "$subvol_pid" >>$seqres.full
+
+	echo -n "Start defrag worker: " >>$seqres.full
+	_btrfs_stress_defrag $SCRATCH_MNT $with_compress >/dev/null 2>&1 &
+	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
+
+	# in case the subvolume is still mounted
+	$UMOUNT_PROG $subvol_mnt >/dev/null 2>&1
+	_scratch_unmount
+	# we called _require_scratch_nocheck instead of _require_scratch
+	# do check after test for each profile config
+	_check_scratch_fs
+}
+
+echo "Silence is golden"
+for t in "${_btrfs_profile_configs[@]}"; do
+	run_test "$t" nocompress
+	run_test "$t" compress
+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 4685970..bbfbb6a 100644
@@ -68,3 +68,4 @@
 063 auto balance replace
 064 auto subvol replace
 065 auto subvol scrub
+066 auto subvol defrag compress
Signature · 1 line
1.8.3.1
author
#15 lore raw

PATCH v4 9/15 btrfs: new case to run subvolume create/delete and remount with defferent 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/067     | 116 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/067.out |   2 +
 tests/btrfs/group   |   1 +
 3 files changed, 119 insertions(+)
 create mode 100755 tests/btrfs/067
 create mode 100644 tests/btrfs/067.out
tests/btrfs/067 new file +116 -0
new file mode 100755
index 0000000..033f3a5
@@ -0,0 +1,116 @@
+#! /bin/bash
+# FSQA Test No. btrfs/067
+#
+# 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 -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_fs btrfs
+_supported_os Linux
+# we check scratch dev after each loop
+_require_scratch_nocheck
+_require_scratch_dev_pool 4
+_btrfs_get_profile_configs
+
+rm -f $seqres.full
+
+run_test()
+{
+	local mkfs_opts=$1
+	local subvol_mnt=$TEST_DIR/$seq.mnt
+
+	echo "Test $mkfs_opts with $with_compress" >>$seqres.full
+
+	_scratch_pool_mkfs $mkfs_opts >>$seqres.full 2>&1
+	# 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
+	_btrfs_stress_subvolume $SCRATCH_DEV $SCRATCH_MNT subvol_$$ $subvol_mnt >/dev/null 2>&1 &
+	subvol_pid=$!
+	echo "$subvol_pid" >>$seqres.full
+
+	echo -n "Start remount worker: " >>$seqres.full
+	_btrfs_stress_remount_compress $SCRATCH_MNT >/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
+
+	# in case the subvolume is still mounted
+	$UMOUNT_PROG $subvol_mnt >/dev/null 2>&1
+	_scratch_unmount
+	# we called _require_scratch_nocheck instead of _require_scratch
+	# do check after test for each profile config
+	_check_scratch_fs
+}
+
+echo "Silence is golden"
+for t in "${_btrfs_profile_configs[@]}"; do
+	run_test "$t"
+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 bbfbb6a..d515ff5 100644
@@ -69,3 +69,4 @@
 064 auto subvol replace
 065 auto subvol scrub
 066 auto subvol defrag compress
+067 auto subvol remount compress
Signature · 1 line
1.8.3.1
author
#16 lore raw

PATCH v4 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/068     | 123 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/068.out |   2 +
 tests/btrfs/group   |   1 +
 3 files changed, 126 insertions(+)
 create mode 100755 tests/btrfs/068
 create mode 100644 tests/btrfs/068.out
tests/btrfs/068 new file +123 -0
new file mode 100755
index 0000000..220e608
@@ -0,0 +1,123 @@
+#! /bin/bash
+# FSQA Test No. btrfs/068
+#
+# 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 -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_fs btrfs
+_supported_os Linux
+# we check scratch dev after each loop
+_require_scratch_nocheck
+_require_scratch_dev_pool 5
+_require_scratch_dev_pool_equal_size
+_btrfs_get_profile_configs replace
+
+rm -f $seqres.full
+
+run_test()
+{
+	local mkfs_opts=$1
+	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 *##"`
+	_scratch_pool_mkfs $mkfs_opts >>$seqres.full 2>&1
+	# make sure we created btrfs with desired options
+	if [ $? -ne 0 ]; then
+		echo "mkfs $mkfs_opts failed"
+		SCRATCH_DEV_POOL=$saved_scratch_dev_pool
+		return
+	fi
+	_scratch_mount >>$seqres.full 2>&1
+	SCRATCH_DEV_POOL=$saved_scratch_dev_pool
+
+	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
+	_btrfs_stress_replace $SCRATCH_MNT >>$seqres.full 2>&1 &
+	replace_pid=$!
+	echo "$replace_pid" >>$seqres.full
+
+	echo -n "Start scrub worker: " >>$seqres.full
+	_btrfs_stress_scrub $SCRATCH_MNT >/dev/null 2>&1 &
+	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
+
+	_scratch_unmount
+	# we called _require_scratch_nocheck instead of _require_scratch
+	# do check after test for each profile config
+	_check_scratch_fs
+}
+
+echo "Silence is golden"
+for t in "${_btrfs_profile_configs[@]}"; 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 d515ff5..1e83505 100644
@@ -70,3 +70,4 @@
 065 auto subvol scrub
 066 auto subvol defrag compress
 067 auto subvol remount compress
+068 auto replace scrub
Signature · 1 line
1.8.3.1
author
#17 lore raw

PATCH v4 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/069     | 125 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/069.out |   2 +
 tests/btrfs/group   |   1 +
 3 files changed, 128 insertions(+)
 create mode 100755 tests/btrfs/069
 create mode 100644 tests/btrfs/069.out
tests/btrfs/069 new file +125 -0
new file mode 100755
index 0000000..882b34b
@@ -0,0 +1,125 @@
+#! /bin/bash
+# FSQA Test No. btrfs/069
+#
+# 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 -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_fs btrfs
+_supported_os Linux
+# we check scratch dev after each loop
+_require_scratch_nocheck
+_require_scratch_dev_pool 5
+_require_scratch_dev_pool_equal_size
+_btrfs_get_profile_configs replace
+
+rm -f $seqres.full
+
+run_test()
+{
+	local mkfs_opts=$1
+	local with_compress=$2
+	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 *##"`
+	_scratch_pool_mkfs $mkfs_opts >>$seqres.full 2>&1
+	# make sure we created btrfs with desired options
+	if [ $? -ne 0 ]; then
+		echo "mkfs $mkfs_opts failed"
+		SCRATCH_DEV_POOL=$saved_scratch_dev_pool
+		return
+	fi
+	_scratch_mount >>$seqres.full 2>&1
+	SCRATCH_DEV_POOL=$saved_scratch_dev_pool
+
+	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
+	_btrfs_stress_replace $SCRATCH_MNT >>$seqres.full 2>&1 &
+	replace_pid=$!
+	echo "$replace_pid" >>$seqres.full
+
+	echo -n "Start defrag worker: " >>$seqres.full
+	_btrfs_stress_defrag $SCRATCH_MNT $with_compress >/dev/null 2>&1 &
+	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
+
+	_scratch_unmount
+	# we called _require_scratch_nocheck instead of _require_scratch
+	# do check after test for each profile config
+	_check_scratch_fs
+}
+
+echo "Silence is golden"
+for t in "${_btrfs_profile_configs[@]}"; 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 1e83505..53f5f4b 100644
@@ -71,3 +71,4 @@
 066 auto subvol defrag compress
 067 auto subvol remount compress
 068 auto replace scrub
+069 auto replace defrag compress
Signature · 1 line
1.8.3.1
author
#18 lore raw

PATCH v4 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/070     | 123 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/070.out |   2 +
 tests/btrfs/group   |   1 +
 3 files changed, 126 insertions(+)
 create mode 100755 tests/btrfs/070
 create mode 100644 tests/btrfs/070.out
tests/btrfs/070 new file +123 -0
new file mode 100755
index 0000000..f7fd8bd
@@ -0,0 +1,123 @@
+#! /bin/bash
+# FSQA Test No. btrfs/070
+#
+# 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 -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_fs btrfs
+_supported_os Linux
+# we check scratch dev after each loop
+_require_scratch_nocheck
+_require_scratch_dev_pool 5
+_require_scratch_dev_pool_equal_size
+_btrfs_get_profile_configs replace
+
+rm -f $seqres.full
+
+run_test()
+{
+	local mkfs_opts=$1
+	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 *##"`
+	_scratch_pool_mkfs $mkfs_opts >>$seqres.full 2>&1
+	# make sure we created btrfs with desired options
+	if [ $? -ne 0 ]; then
+		echo "mkfs $mkfs_opts failed"
+		SCRATCH_DEV_POOL=$saved_scratch_dev_pool
+		return
+	fi
+	_scratch_mount >>$seqres.full 2>&1
+	SCRATCH_DEV_POOL=$saved_scratch_dev_pool
+
+	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
+	_btrfs_stress_replace $SCRATCH_MNT >>$seqres.full 2>&1 &
+	replace_pid=$!
+	echo "$replace_pid" >>$seqres.full
+
+	echo -n "Start remount worker: " >>$seqres.full
+	_btrfs_stress_remount_compress $SCRATCH_MNT >/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 "replace 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
+
+	_scratch_unmount
+	# we called _require_scratch_nocheck instead of _require_scratch
+	# do check after test for each profile config
+	_check_scratch_fs
+}
+
+echo "Silence is golden"
+for t in "${_btrfs_profile_configs[@]}"; 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 53f5f4b..f68370d 100644
@@ -72,3 +72,4 @@
 067 auto subvol remount compress
 068 auto replace scrub
 069 auto replace defrag compress
+070 auto replace remount compress
Signature · 1 line
1.8.3.1
author
#19 lore raw

PATCH v4 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/071     | 116 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/071.out |   2 +
 tests/btrfs/group   |   1 +
 3 files changed, 119 insertions(+)
 create mode 100755 tests/btrfs/071
 create mode 100644 tests/btrfs/071.out
tests/btrfs/071 new file +116 -0
new file mode 100755
index 0000000..643b489
@@ -0,0 +1,116 @@
+#! /bin/bash
+# FSQA Test No. btrfs/071
+#
+# 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 -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_fs btrfs
+_supported_os Linux
+# we check scratch dev after each loop
+_require_scratch_nocheck
+_require_scratch_dev_pool 4
+_btrfs_get_profile_configs
+
+rm -f $seqres.full
+
+run_test()
+{
+	local mkfs_opts=$1
+	local with_compress=$2
+
+	echo "Test $mkfs_opts with $with_compress" >>$seqres.full
+
+	_scratch_pool_mkfs $mkfs_opts >>$seqres.full 2>&1
+	# 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 scrub worker: " >>$seqres.full
+	_btrfs_stress_scrub $SCRATCH_MNT >/dev/null 2>&1 &
+	scrub_pid=$!
+	echo "$scrub_pid" >>$seqres.full
+
+	echo -n "Start defrag worker: " >>$seqres.full
+	_btrfs_stress_defrag $SCRATCH_MNT $with_compress >/dev/null 2>&1 &
+	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
+
+	_scratch_unmount
+	# we called _require_scratch_nocheck instead of _require_scratch
+	# do check after test for each profile config
+	_check_scratch_fs
+}
+
+echo "Silence is golden"
+for t in "${_btrfs_profile_configs[@]}"; 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 f68370d..5377acf 100644
@@ -73,3 +73,4 @@
 068 auto replace scrub
 069 auto replace defrag compress
 070 auto replace remount compress
+071 auto scrub defrag compress
Signature · 1 line
1.8.3.1
author
#20 lore raw

PATCH v4 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/072     | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/072.out |   2 +
 tests/btrfs/group   |   1 +
 3 files changed, 117 insertions(+)
 create mode 100755 tests/btrfs/072
 create mode 100644 tests/btrfs/072.out
tests/btrfs/072 new file +114 -0
new file mode 100755
index 0000000..b185f85
@@ -0,0 +1,114 @@
+#! /bin/bash
+# FSQA Test No. btrfs/072
+#
+# 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 -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_fs btrfs
+_supported_os Linux
+# we check scratch dev after each loop
+_require_scratch_nocheck
+_require_scratch_dev_pool 4
+_btrfs_get_profile_configs
+
+rm -f $seqres.full
+
+run_test()
+{
+	local mkfs_opts=$1
+
+	echo "Test $mkfs_opts" >>$seqres.full
+
+	_scratch_pool_mkfs $mkfs_opts >>$seqres.full 2>&1
+	# 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 scrub worker: " >>$seqres.full
+	_btrfs_stress_scrub $SCRATCH_MNT >/dev/null 2>&1 &
+	scrub_pid=$!
+	echo "$scrub_pid" >>$seqres.full
+
+	echo -n "Start remount worker: " >>$seqres.full
+	_btrfs_stress_remount_compress $SCRATCH_MNT >/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
+
+	_scratch_unmount
+	# we called _require_scratch_nocheck instead of _require_scratch
+	# do check after test for each profile config
+	_check_scratch_fs
+}
+
+echo "Silence is golden"
+for t in "${_btrfs_profile_configs[@]}"; do
+	run_test "$t"
+done
+
+status=0
+exit
tests/btrfs/072.out new file +2 -0
new file mode 100644
index 0000000..590bbc6
@@ -0,0 +1,2 @@
+QA output created by 072
+Silence is golden
tests/btrfs/group +1 -0
index 5377acf..e631d5b 100644
@@ -74,3 +74,4 @@
 069 auto replace defrag compress
 070 auto replace remount compress
 071 auto scrub defrag compress
+072 auto scrub remount compress
Signature · 1 line
1.8.3.1
author
#21 lore raw

PATCH v4 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/073     | 116 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/073.out |   2 +
 tests/btrfs/group   |   1 +
 3 files changed, 119 insertions(+)
 create mode 100755 tests/btrfs/073
 create mode 100644 tests/btrfs/073.out
tests/btrfs/073 new file +116 -0
new file mode 100755
index 0000000..38c8356
@@ -0,0 +1,116 @@
+#! /bin/bash
+# FSQA Test No. btrfs/073
+#
+# 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 -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_fs btrfs
+_supported_os Linux
+# we check scratch dev after each loop
+_require_scratch_nocheck
+_require_scratch_dev_pool 4
+_btrfs_get_profile_configs
+
+rm -f $seqres.full
+
+run_test()
+{
+	local mkfs_opts=$1
+	local with_compress=$2
+
+	echo "Test $mkfs_opts with $with_compress" >>$seqres.full
+
+	_scratch_pool_mkfs $mkfs_opts >>$seqres.full 2>&1
+	# 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 defrag worker: " >>$seqres.full
+	_btrfs_stress_defrag $SCRATCH_MNT $with_compress >/dev/null 2>&1 &
+	defrag_pid=$!
+	echo "$defrag_pid" >>$seqres.full
+
+	echo -n "Start remount worker: " >>$seqres.full
+	_btrfs_stress_remount_compress $SCRATCH_MNT >/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
+
+	_scratch_unmount
+	# we called _require_scratch_nocheck instead of _require_scratch
+	# do check after test for each profile config
+	_check_scratch_fs
+}
+
+echo "Silence is golden"
+for t in "${_btrfs_profile_configs[@]}"; do
+	run_test "$t" nocompress
+	run_test "$t" compress
+done
+
+status=0
+exit
tests/btrfs/073.out new file +2 -0
new file mode 100644
index 0000000..d107704
@@ -0,0 +1,2 @@
+QA output created by 073
+Silence is golden
tests/btrfs/group +1 -0
index e631d5b..2e3fb6a 100644
@@ -75,3 +75,4 @@
 070 auto replace remount compress
 071 auto scrub defrag compress
 072 auto scrub remount compress
+073 auto defrag remount compress
Signature · 1 line
1.8.3.1