From: "Darrick J. Wong" <djwong@kernel.org>
To: djwong@kernel.org, guaneryu@gmail.com
Cc: linux-xfs@vger.kernel.org, fstests@vger.kernel.org, guan@eryu.me
Subject: [PATCH 2/3] generic: test shutdowns of a nested filesystem
Date: Tue, 27 Jul 2021 17:10:30 -0700 [thread overview]
Message-ID: <162743103024.3428896.8525632218517299015.stgit@magnolia> (raw)
In-Reply-To: <162743101932.3428896.8510279402246446036.stgit@magnolia>
From: Darrick J. Wong <djwong@kernel.org>
generic/475, but we're running fsstress on a disk image inside the
scratch filesystem
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
tests/generic/725 | 136 +++++++++++++++++++++++++++++++++++++++++++++++++
tests/generic/725.out | 2 +
2 files changed, 138 insertions(+)
create mode 100755 tests/generic/725
create mode 100644 tests/generic/725.out
diff --git a/tests/generic/725 b/tests/generic/725
new file mode 100755
index 00000000..f43bcb37
--- /dev/null
+++ b/tests/generic/725
@@ -0,0 +1,136 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2021 Oracle, Inc. All Rights Reserved.
+#
+# FS QA Test No. 725
+#
+# Test nested log recovery with repeated (simulated) disk failures. We kick
+# off fsstress on a loopback filesystem mounted on the scratch fs, then switch
+# out the underlying scratch device with dm-error to see what happens when the
+# disk goes down. Having taken down both fses in this manner, remount them and
+# repeat. This test simulates VM hosts crashing to try to shake out CoW bugs
+# in writeback on the host that cause VM guests to fail to recover.
+#
+. ./common/preamble
+_begin_fstest shutdown auto log metadata eio
+
+_cleanup()
+{
+ cd /
+ $KILLALL_PROG -9 fsstress > /dev/null 2>&1
+ wait
+ if [ -n "$loopmnt" ]; then
+ umount $loopmnt 2>/dev/null
+ rm -r -f $loopmnt
+ fi
+ rm -f $tmp.*
+ _dmerror_unmount
+ _dmerror_cleanup
+}
+
+# Import common functions.
+. ./common/dmerror
+. ./common/reflink
+
+# Modify as appropriate.
+_supported_fs generic
+
+_require_scratch_reflink
+_require_cp_reflink
+_require_dm_target error
+_require_command "$KILLALL_PROG" "killall"
+
+echo "Silence is golden."
+
+_scratch_mkfs >> $seqres.full 2>&1
+_require_metadata_journaling $SCRATCH_DEV
+_dmerror_init
+_dmerror_mount
+
+# Create a fs image consuming 1/3 of the scratch fs
+scratch_freesp_bytes=$(stat -f -c '%a * %S' $SCRATCH_MNT | bc)
+loopimg_bytes=$((scratch_freesp_bytes / 3))
+
+loopimg=$SCRATCH_MNT/testfs
+truncate -s $loopimg_bytes $loopimg
+_mkfs_dev $loopimg
+
+loopmnt=$tmp.mount
+mkdir -p $loopmnt
+
+scratch_aliveflag=$tmp.runsnap
+snap_aliveflag=$tmp.snapping
+
+snap_loop_fs() {
+ touch "$snap_aliveflag"
+ while [ -e "$scratch_aliveflag" ]; do
+ rm -f $loopimg.a
+ _cp_reflink $loopimg $loopimg.a
+ sleep 1
+ done
+ rm -f "$snap_aliveflag"
+}
+
+fsstress=($FSSTRESS_PROG $FSSTRESS_AVOID -d "$loopmnt" -n 999999 -p "$((LOAD_FACTOR * 4))")
+
+for i in $(seq 1 $((25 * TIME_FACTOR)) ); do
+ touch $scratch_aliveflag
+ snap_loop_fs >> $seqres.full 2>&1 &
+
+ if ! _mount $loopimg $loopmnt -o loop; then
+ rm -f $scratch_aliveflag
+ _fail "loop mount failed"
+ break
+ fi
+
+ ("${fsstress[@]}" >> $seqres.full &) > /dev/null 2>&1
+
+ # purposely include 0 second sleeps to test shutdown immediately after
+ # recovery
+ sleep $((RANDOM % (3 * TIME_FACTOR) ))
+ rm -f $scratch_aliveflag
+
+ # This test aims to simulate sudden disk failure, which means that we
+ # do not want to quiesce the filesystem or otherwise give it a chance
+ # to flush its logs. Therefore we want to call dmsetup with the
+ # --nolockfs parameter; to make this happen we must call the load
+ # error table helper *without* 'lockfs'.
+ _dmerror_load_error_table
+
+ ps -e | grep fsstress > /dev/null 2>&1
+ while [ $? -eq 0 ]; do
+ $KILLALL_PROG -9 fsstress > /dev/null 2>&1
+ wait > /dev/null 2>&1
+ ps -e | grep fsstress > /dev/null 2>&1
+ done
+ for ((i = 0; i < 10; i++)); do
+ test -e "$snap_aliveflag" || break
+ sleep 1
+ done
+
+ # Mount again to replay log after loading working table, so we have a
+ # consistent XFS after test.
+ $UMOUNT_PROG $loopmnt
+ _dmerror_unmount || _fail "unmount failed"
+ _dmerror_load_working_table
+ if ! _dmerror_mount; then
+ dmsetup table | tee -a /dev/ttyprintk
+ lsblk | tee -a /dev/ttyprintk
+ $XFS_METADUMP_PROG -a -g -o $DMERROR_DEV $seqres.dmfail.md
+ _fail "mount failed"
+ fi
+done
+
+# Make sure the fs image file is ok
+if [ -f "$loopimg" ]; then
+ if _mount $loopimg $loopmnt -o loop; then
+ $UMOUNT_PROG $loopmnt &> /dev/null
+ else
+ echo "final loop mount failed"
+ fi
+ _check_xfs_filesystem $loopimg none none
+fi
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/725.out b/tests/generic/725.out
new file mode 100644
index 00000000..ed73a9fc
--- /dev/null
+++ b/tests/generic/725.out
@@ -0,0 +1,2 @@
+QA output created by 725
+Silence is golden.
next prev parent reply other threads:[~2021-07-28 0:10 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-28 0:10 [PATCHSET 0/3] fstests: exercise code refactored in 5.14 Darrick J. Wong
2021-07-28 0:10 ` [PATCH 1/3] generic: test xattr operations only Darrick J. Wong
2021-08-12 5:34 ` Zorro Lang
2021-08-12 17:04 ` Darrick J. Wong
2021-08-15 15:46 ` Eryu Guan
2021-07-28 0:10 ` Darrick J. Wong [this message]
2021-08-12 5:44 ` [PATCH 2/3] generic: test shutdowns of a nested filesystem Zorro Lang
2021-08-12 17:07 ` Darrick J. Wong
2021-08-13 14:52 ` Zorro Lang
2021-08-15 16:28 ` Eryu Guan
2021-08-16 16:35 ` Darrick J. Wong
2021-08-17 3:16 ` Eryu Guan
2021-08-17 4:16 ` Darrick J. Wong
2021-08-17 15:54 ` Darrick J. Wong
2021-07-28 0:10 ` [PATCH 3/3] xfs: test regression in shrink when the new EOFS splits a sparse inode cluster Darrick J. Wong
2021-08-12 6:01 ` Zorro Lang
2021-09-01 0:11 [PATCHSET v2 0/3] fstests: exercise code refactored in 5.14 Darrick J. Wong
2021-09-01 0:11 ` [PATCH 2/3] generic: test shutdowns of a nested filesystem Darrick J. Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=162743103024.3428896.8525632218517299015.stgit@magnolia \
--to=djwong@kernel.org \
--cc=fstests@vger.kernel.org \
--cc=guan@eryu.me \
--cc=guaneryu@gmail.com \
--cc=linux-xfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).