diff options
author | Qu Wenruo <wqu@suse.com> | 2018-03-28 12:40:23 +0800 |
---|---|---|
committer | Eryu Guan <guaneryu@gmail.com> | 2018-04-08 15:47:22 +0800 |
commit | 4cabd42a78d242650b1053520af308011061343e (patch) | |
tree | 60e53302ff3f485fe8032f490aa9feff45c3d98b | |
parent | 5311ba16c6e80a52797831ecfdcb1348b56896d3 (diff) | |
download | xfstests-dev-4cabd42a78d242650b1053520af308011061343e.tar.gz |
generic: Check the fs after each FUA writes
Basic test case which triggers fsstress with dm-log-writes, and then
check the fs after each FUA writes.
With needed infrastructure and special handlers for journal based fs.
[Eryu: cap $nr_cpu to 8 to avoid wasting time on hosts with many cpus]
Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
-rw-r--r-- | common/dmlogwrites | 56 | ||||
-rwxr-xr-x | tests/generic/482 | 108 | ||||
-rw-r--r-- | tests/generic/482.out | 2 | ||||
-rw-r--r-- | tests/generic/group | 1 |
4 files changed, 167 insertions, 0 deletions
diff --git a/common/dmlogwrites b/common/dmlogwrites index 467b872e24..bf643a77ad 100644 --- a/common/dmlogwrites +++ b/common/dmlogwrites @@ -126,3 +126,59 @@ _log_writes_cleanup() $UDEV_SETTLE_PROG >/dev/null 2>&1 _log_writes_remove } + +# Convert log writes mark to entry number +# Result entry number is output to stdout, could be empty if not found +_log_writes_mark_to_entry_number() +{ + local mark=$1 + local ret + + [ -z "$mark" ] && _fatal \ + "mark must be given for _log_writes_mark_to_entry_number" + + ret=$($here/src/log-writes/replay-log --find --log $LOGWRITES_DEV \ + --end-mark $mark 2> /dev/null) + [ -z "$ret" ] && return + ret=$(echo "$ret" | cut -f1 -d\@) + echo "mark $mark has entry number $ret" >> $seqres.full + echo "$ret" +} + +# Find next fua write entry number +# Result entry number is output to stdout, could be empty if not found +_log_writes_find_next_fua() +{ + local start_entry=$1 + local ret + + [ -z "$start_entry" ] && start_entry=0 + ret=$($here/src/log-writes/replay-log --find --log $LOGWRITES_DEV \ + --next-fua --start-entry $start_entry 2> /dev/null) + [ -z "$ret" ] && return + + # Result should be something like "1024@offset" where 1024 is the + # entry number we need + ret=$(echo "$ret" | cut -f1 -d\@) + echo "next fua is entry number $ret" >> $seqres.full + echo "$ret" +} + +# Replay log range to specified entry +# $1: End entry. The entry with this number *WILL* be replayed +_log_writes_replay_log_range() +{ + local end=$1 + + [ -z "$end" ] && _fail \ + "end entry must be specified for _log_writes_replay_log_range" + + # To ensure we replay the last entry, + # we need to manually increase the end entry number to ensure + # it's played + echo "=== replay to $end ===" >> $seqres.full + $here/src/log-writes/replay-log --log $LOGWRITES_DEV \ + --replay $SCRATCH_DEV --limit $(($end + 1)) \ + >> $seqres.full 2>&1 + [ $? -ne 0 ] && _fail "replay failed" +} diff --git a/tests/generic/482 b/tests/generic/482 new file mode 100755 index 0000000000..1fc2636641 --- /dev/null +++ b/tests/generic/482 @@ -0,0 +1,108 @@ +#! /bin/bash +# FS QA Test 482 +# +# Test filesystem consistency after each FUA operation +# +# Will do log replay and check the filesystem. +# +#----------------------------------------------------------------------- +# Copyright (c) 2018 SUSE Linux Products GmbH. All Rights Reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it would be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +#----------------------------------------------------------------------- +# + +seq=`basename $0` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + $KILLALL_PROG -KILL -q $FSSTRESS_PROG &> /dev/null + _log_writes_cleanup &> /dev/null + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/dmlogwrites + +# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here + +# Modify as appropriate. +_supported_fs generic +_supported_os Linux + +_require_command "$KILLALL_PROG" killall +# Use $SCRATCH_DEV as replay device +_require_scratch +# and we need extra device as log device +_require_log_writes + + +nr_cpus=$("$here/src/feature" -o) +# cap nr_cpus to 8 to avoid spending too much time on hosts with many cpus +if [ $nr_cpus -gt 8 ]; then + nr_cpus=8 +fi +fsstress_args=$(_scale_fsstress_args -w -d $SCRATCH_MNT -n 512 -p $nr_cpus \ + $FSSTRESS_AVOID) + +_test_unmount +_log_writes_init +_log_writes_mkfs >> $seqres.full 2>&1 +_log_writes_mark mkfs + +_log_writes_mount +run_check $FSSTRESS_PROG $fsstress_args > /dev/null 2>&1 +_log_writes_unmount + +_log_writes_remove +prev=$(_log_writes_mark_to_entry_number mkfs) +[ -z "$prev" ] && _fail "failed to locate entry mark 'mkfs'" +cur=$(_log_writes_find_next_fua $prev) +[ -z "$cur" ] && _fail "failed to locate next FUA write" + +while [ ! -z "$cur" ]; do + _log_writes_replay_log_range $cur >> $seqres.full + + # Here we need extra mount to replay the log, mainly for journal based + # fs, as their fsck will report dirty log as error. + # We don't care to preserve any data on $SCRATCH_DEV, as we can replay + # back to the point we need, and in fact sometimes creating/deleting + # snapshots repeatedly can be slower than replaying the log. + _scratch_mount + _scratch_unmount + _check_scratch_fs + + prev=$cur + cur=$(_log_writes_find_next_fua $(($cur + 1))) + [ -z "$cur" ] && break +done + +echo "Silence is golden" + +# success, all done +status=0 +exit diff --git a/tests/generic/482.out b/tests/generic/482.out new file mode 100644 index 0000000000..f5e17c8bc9 --- /dev/null +++ b/tests/generic/482.out @@ -0,0 +1,2 @@ +QA output created by 482 +Silence is golden diff --git a/tests/generic/group b/tests/generic/group index e8676062dc..2667388537 100644 --- a/tests/generic/group +++ b/tests/generic/group @@ -484,3 +484,4 @@ 479 auto quick metadata 480 auto quick metadata 481 auto quick log metadata +482 auto metadata replay |