Skip to contentSkip to conversation

xfstests: dedupe a single big file and verify integrity

PATCH In review Zorro Lang 2 participants 4 messages Jun 23, 2018 – Jun 28, 2018

lore
Share & tools
lore

Zorro Lang

author
#0 lore raw

PATCH v3 1/3 xfstests: dedupe a single big file and verify integrity

Duperemove is a tool for finding duplicated extents and submitting them for deduplication, and it supports XFS. This case trys to verify the integrity of XFS after running duperemove.

---

V3 update description about SPDX-License.

Thanks,
Zorro

 common/config        |  1 +
 tests/shared/008     | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/shared/008.out |  3 +++
 tests/shared/group   |  1 +
 4 files changed, 69 insertions(+)
 create mode 100755 tests/shared/008
 create mode 100644 tests/shared/008.out
common/config +1 -0
index 09e7ffee..d02d6ed5 100644
@@ -192,6 +192,7 @@ export SETCAP_PROG="$(type -P setcap)"
 export GETCAP_PROG="$(type -P getcap)"
 export CHECKBASHISMS_PROG="$(type -P checkbashisms)"
 export XFS_INFO_PROG="$(type -P xfs_info)"
+export DUPEREMOVE_PROG="$(type -P duperemove)"
 
 # use 'udevadm settle' or 'udevsettle' to wait for lv to be settled.
 # newer systems have udevadm command but older systems like RHEL5 don't.
tests/shared/008 new file +64 -0

64 lines not on this page · raw message

tests/shared/008.out new file +3 -0
new file mode 100644
index 00000000..f29d478f
@@ -0,0 +1,3 @@
+QA output created by 008
+= before cycle mount =
+= after cycle mount =
tests/shared/group +1 -0
index b3663a03..49ffa8dd 100644
@@ -10,6 +10,7 @@
 005 dangerous_fuzzers
 006 auto enospc
 007 dangerous_fuzzers
+008 auto stress dedupe
 032 mkfs auto quick
 272 auto enospc rw
 289 auto quick
Signature · 1 line
2.14.4
author
#1 lore raw

PATCH v3 2/3 xfstests: iterate dedupe integrity test

This case does dedupe on a dir, then copy the dir to next dir. Dedupe the next dir again, then copy this dir to next again, and dedupe again ... At the end, verify the data in the last dir is still same with the first one.

---

V3 update description about SPDX-License

Thanks,
Zorro

 tests/shared/009     | 104 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/shared/009.out |   4 ++
 tests/shared/group   |   1 +
 3 files changed, 109 insertions(+)
 create mode 100755 tests/shared/009
 create mode 100644 tests/shared/009.out
tests/shared/009 new file +104 -0
new file mode 100755
index 00000000..933d3098
@@ -0,0 +1,104 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2018 Red Hat Inc.  All Rights Reserved.
+#
+# FS QA Test 009
+#
+# Iterate dedupe integrity test. Copy an original data0 several
+# times (d0 -> d1, d1 -> d2, ... dn-1 -> dn), dedupe dataN everytime
+# before copy. At last, verify dataN same with data0.
+#
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1	# failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# remove previous $seqres.full before test
+rm -f $seqres.full
+
+# real QA test starts here
+
+# duperemove only supports btrfs and xfs (with reflink feature).
+# Add other filesystems if it supports more later.
+_supported_fs xfs btrfs
+_supported_os Linux
+_require_scratch_dedupe
+_require_command "$DUPEREMOVE_PROG" duperemove
+
+_scratch_mkfs > $seqres.full 2>&1
+_scratch_mount >> $seqres.full 2>&1
+
+function iterate_dedup_verify()
+{
+	local src=$srcdir
+	local dest=$dupdir/1
+
+	for ((index = 1; index <= times; index++)); do
+		cp -a $src $dest
+		find $dest -type f -exec md5sum {} \; \
+			> $md5file$index
+		# Make some noise
+		$FSSTRESS_PROG $fsstress_opts -d $noisedir \
+			       -n 200 -p $((5 * LOAD_FACTOR)) >/dev/null 2>&1
+		# Too many output, so only save error output
+		$DUPEREMOVE_PROG -dr --dedupe-options=same $dupdir \
+			>/dev/null 2>$seqres.full
+		md5sum -c --quiet $md5file$index
+		src=$dest
+		dest=$dupdir/$((index + 1))
+	done
+}
+
+srcdir=$SCRATCH_MNT/src
+dupdir=$SCRATCH_MNT/dup
+noisedir=$dupdir/noise
+mkdir $srcdir $dupdir
+mkdir $dupdir/noise
+
+md5file=${tmp}.md5sum
+
+fsstress_opts="-w -r"
+# Create some files to be original data
+$FSSTRESS_PROG $fsstress_opts -d $srcdir \
+	       -n 500 -p $((5 * LOAD_FACTOR)) >/dev/null 2>&1
+
+# Calculate how many test cycles will be run
+src_size=`du -ks $srcdir | awk '{print $1}'`
+free_size=`df -kP $SCRATCH_MNT | grep -v Filesystem | awk '{print $4}'`
+times=$((free_size / src_size))
+if [ $times -gt $((4 * TIME_FACTOR)) ]; then
+	times=$((4 * TIME_FACTOR))
+fi
+
+echo "= Do dedup and verify ="
+iterate_dedup_verify
+
+# Use the last checksum file to verify the original data
+sed -e s#dup/$times#src#g $md5file$times > $md5file
+echo "= Backwords verify ="
+md5sum -c --quiet $md5file
+
+# read from the disk also doesn't show mutations.
+_scratch_cycle_mount
+echo "= Verify after cycle mount ="
+for ((index = 1; index <= times; index++)); do
+	md5sum -c --quiet $md5file$index
+done
+
+status=0
+exit
tests/shared/009.out new file +4 -0
new file mode 100644
index 00000000..44a78ba3
@@ -0,0 +1,4 @@
+QA output created by 009
+= Do dedup and verify =
+= Backwords verify =
+= Verify after cycle mount =
tests/shared/group +1 -0
index 49ffa8dd..9c484794 100644
@@ -11,6 +11,7 @@
 006 auto enospc
 007 dangerous_fuzzers
 008 auto stress dedupe
+009 auto stress dedupe
 032 mkfs auto quick
 272 auto enospc rw
 289 auto quick
Signature · 1 line
2.14.4
author
#2 lore raw

PATCH v3 3/3 xfstests: dedupe with random io race test

In reply to Zorro Lang

Run several duperemove processes with fsstress on same directory at same time. Make sure the race won't break the fs or kernel.

---

V3 did below changes:
1) Use $TEST_DIR/${seq}-running file to loop run duperemove.
2) Change kill_all_stress function
3) Change $TEST_DIR/${seq}md5.sum to ${tmp}.md5sum

Thanks,
Zorro

 tests/shared/010     | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/shared/010.out |  2 ++
 tests/shared/group   |  1 +
 3 files changed, 97 insertions(+)
 create mode 100755 tests/shared/010
 create mode 100644 tests/shared/010.out
tests/shared/010 new file +94 -0
new file mode 100755
index 00000000..3cf50ddd
@@ -0,0 +1,94 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2018 Red Hat Inc.  All Rights Reserved.
+#
+# FS QA Test 010
+#
+# Dedup & random I/O race test, do multi-threads fsstress and dedupe on
+# same directory/files
+#
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1	# failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+	end_test
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# remove previous $seqres.full before test
+rm -f $seqres.full
+
+# real QA test starts here
+
+# duperemove only supports btrfs and xfs (with reflink feature).
+# Add other filesystems if it supports more later.
+_supported_fs xfs btrfs
+_supported_os Linux
+_require_scratch_dedupe
+_require_command "$DUPEREMOVE_PROG" duperemove
+_require_command "$KILLALL_PROG" killall
+
+_scratch_mkfs > $seqres.full 2>&1
+_scratch_mount >> $seqres.full 2>&1
+
+function end_test()
+{
+	local f=1
+
+	# stop duperemove running
+	if [ -e $dupe_run ]; then
+		rm -f $dupe_run
+		wait $dedup_pids
+	fi
+
+	# Make sure all fsstress get killed
+	while [ $f -ne 0 ]; do
+		$KILLALL_PROG -q $FSSTRESS_PROG > /dev/null 2>&1
+		sleep 1
+		f=`ps -eLf | grep $FSSTRESS_PROG | grep -v "grep" | wc -l`
+	done
+}
+
+sleep_time=$((50 * TIME_FACTOR))
+
+# Start fsstress
+fsstress_opts="-r -n 1000 -p $((5 * LOAD_FACTOR))"
+$FSSTRESS_PROG $fsstress_opts -d $SCRATCH_MNT -l 0 >> $seqres.full 2>&1 &
+dedup_pids=""
+dupe_run=$TEST_DIR/${seq}-running
+# Start several dedupe processes on same directory
+touch $dupe_run
+for ((i = 0; i < $((2 * LOAD_FACTOR)); i++)); do
+	while [ -e $dupe_run ]; do
+		$DUPEREMOVE_PROG -dr --dedupe-options=same $SCRATCH_MNT/
+			>>$seqres.full 2>&1
+	done &
+	dedup_pids="$! $dedup_pids"
+done
+
+# End the test after $sleep_time seconds
+sleep $sleep_time
+end_test
+
+# umount and mount again, verify pagecache contents don't mutate and a fresh
+# read from the disk also doesn't show mutations.
+find $testdir -type f -exec md5sum {} \; > ${tmp}.md5sum
+_scratch_cycle_mount
+md5sum -c --quiet ${tmp}.md5sum
+
+echo "Silence is golden"
+status=0
+exit
tests/shared/010.out new file +2 -0
new file mode 100644
index 00000000..1d83a8d6
@@ -0,0 +1,2 @@
+QA output created by 010
+Silence is golden
tests/shared/group +1 -0
index 9c484794..094da27d 100644
@@ -12,6 +12,7 @@
 007 dangerous_fuzzers
 008 auto stress dedupe
 009 auto stress dedupe
+010 auto stress dedupe
 032 mkfs auto quick
 272 auto enospc rw
 289 auto quick
Signature · 1 line
2.14.4
#3 lore raw

Re: [PATCH v3 3/3] xfstests: dedupe with random io race test

Quoted 93 lines · Zorro Lang

Run several duperemove processes with fsstress on same directory at same time. Make sure the race won't break the fs or kernel.

---

V3 did below changes:
1) Use $TEST_DIR/${seq}-running file to loop run duperemove.
2) Change kill_all_stress function
3) Change $TEST_DIR/${seq}md5.sum to ${tmp}.md5sum

Thanks,
Zorro

 tests/shared/010     | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/shared/010.out |  2 ++
 tests/shared/group   |  1 +
 3 files changed, 97 insertions(+)
 create mode 100755 tests/shared/010
 create mode 100644 tests/shared/010.out
tests/shared/010 new file +66 -0
new file mode 100755
index 00000000..3cf50ddd
@@ -0,0 +1,94 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2018 Red Hat Inc.  All Rights Reserved.
+#
+# FS QA Test 010
+#
+# Dedup & random I/O race test, do multi-threads fsstress and dedupe on
+# same directory/files
+#
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1	# failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+	end_test
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# remove previous $seqres.full before test
+rm -f $seqres.full
+
+# real QA test starts here
+
+# duperemove only supports btrfs and xfs (with reflink feature).
+# Add other filesystems if it supports more later.
+_supported_fs xfs btrfs
+_supported_os Linux
+_require_scratch_dedupe
+_require_command "$DUPEREMOVE_PROG" duperemove
+_require_command "$KILLALL_PROG" killall
+
+_scratch_mkfs > $seqres.full 2>&1
+_scratch_mount >> $seqres.full 2>&1
+
+function end_test()
+{
+	local f=1
+
+	# stop duperemove running
+	if [ -e $dupe_run ]; then
+		rm -f $dupe_run
+		wait $dedup_pids
+	fi
+
+	# Make sure all fsstress get killed
+	while [ $f -ne 0 ]; do
+		$KILLALL_PROG -q $FSSTRESS_PROG > /dev/null 2>&1
+		sleep 1
+		f=`ps -eLf | grep $FSSTRESS_PROG | grep -v "grep" | wc -l`
+	done
+}
+
+sleep_time=$((50 * TIME_FACTOR))
+

tests/shared/010 line 76

Quoted 10 lines
tests/shared/010 new file +10 -0
+# Start fsstress
+fsstress_opts="-r -n 1000 -p $((5 * LOAD_FACTOR))"
+$FSSTRESS_PROG $fsstress_opts -d $SCRATCH_MNT -l 0 >> $seqres.full 2>&1 &
+dedup_pids=""
+dupe_run=$TEST_DIR/${seq}-running
+# Start several dedupe processes on same directory
+touch $dupe_run
+for ((i = 0; i < $((2 * LOAD_FACTOR)); i++)); do
+	while [ -e $dupe_run ]; do
+		$DUPEREMOVE_PROG -dr --dedupe-options=same $SCRATCH_MNT/

This needs a "\" at the end of line, otherwise the output all go to stdout then breaks golden image. I fixed it on commit.

Thanks,
Eryu

Quoted 45 lines
tests/shared/010 new file +18 -0
+			>>$seqres.full 2>&1
+	done &
+	dedup_pids="$! $dedup_pids"
+done
+
+# End the test after $sleep_time seconds
+sleep $sleep_time
+end_test
+
+# umount and mount again, verify pagecache contents don't mutate and a fresh
+# read from the disk also doesn't show mutations.
+find $testdir -type f -exec md5sum {} \; > ${tmp}.md5sum
+_scratch_cycle_mount
+md5sum -c --quiet ${tmp}.md5sum
+
+echo "Silence is golden"
+status=0
+exit
tests/shared/010.out new file +2 -0
new file mode 100644
index 00000000..1d83a8d6
@@ -0,0 +1,2 @@
+QA output created by 010
+Silence is golden
tests/shared/group +1 -0
index 9c484794..094da27d 100644
@@ -12,6 +12,7 @@
 007 dangerous_fuzzers
 008 auto stress dedupe
 009 auto stress dedupe
+010 auto stress dedupe
 032 mkfs auto quick
 272 auto enospc rw
 289 auto quick
Signature · 6 lines
2.14.4

--
To unsubscribe from this list: send the line "unsubscribe fstests" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html