All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: guaneryu@gmail.com, darrick.wong@oracle.com
Cc: linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	fstests@vger.kernel.org
Subject: [PATCH 2/6] xfs: test mount time summary counter check and fix
Date: Thu, 04 Oct 2018 17:19:20 -0700	[thread overview]
Message-ID: <153869876040.26648.11302951509500617148.stgit@magnolia> (raw)
In-Reply-To: <153869874763.26648.516233620615833277.stgit@magnolia>

From: Darrick J. Wong <darrick.wong@oracle.com>

Tests to ensure that the xfs mount code can detect obviously bad fs
summary counters at mount time and fix them.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/xfs/722     |   58 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/722.out |    4 +++
 tests/xfs/723     |   58 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/723.out |    4 +++
 tests/xfs/724     |   66 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/724.out |    4 +++
 tests/xfs/group   |    3 ++
 7 files changed, 197 insertions(+)
 create mode 100755 tests/xfs/722
 create mode 100644 tests/xfs/722.out
 create mode 100755 tests/xfs/723
 create mode 100644 tests/xfs/723.out
 create mode 100755 tests/xfs/724
 create mode 100644 tests/xfs/724.out


diff --git a/tests/xfs/722 b/tests/xfs/722
new file mode 100755
index 00000000..1012bd58
--- /dev/null
+++ b/tests/xfs/722
@@ -0,0 +1,58 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2018 Oracle.  All Rights Reserved.
+#
+# FS QA Test 722
+#
+# Test detection & fixing of bad summary block counts at mount time.
+#
+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
+
+# remove previous $seqres.full before test
+rm -f $seqres.full
+
+# real QA test starts here
+
+# Modify as appropriate.
+_supported_fs xfs
+_supported_os Linux
+_require_scratch
+
+echo "Format and mount"
+_scratch_mkfs > $seqres.full 2>&1
+_scratch_mount >> $seqres.full 2>&1
+echo "test file" > $SCRATCH_MNT/testfile
+
+echo "Fuzz fdblocks"
+_scratch_unmount
+dblocks=$(_scratch_xfs_get_metadata_field dblocks 'sb 0')
+_scratch_xfs_set_metadata_field fdblocks $((dblocks * 2)) 'sb 0' > $seqres.full 2>&1
+
+echo "Detection and Correction"
+_scratch_mount >> $seqres.full 2>&1
+avail=$(stat -c '%a' -f $SCRATCH_MNT)
+total=$(stat -c '%b' -f $SCRATCH_MNT)
+echo "avail: $avail" >> $seqres.full
+echo "total: $total" >> $seqres.full
+test "$avail" -gt "$total" && echo "free space bad: $avail > $total"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/722.out b/tests/xfs/722.out
new file mode 100644
index 00000000..8d1327b7
--- /dev/null
+++ b/tests/xfs/722.out
@@ -0,0 +1,4 @@
+QA output created by 722
+Format and mount
+Fuzz fdblocks
+Detection and Correction
diff --git a/tests/xfs/723 b/tests/xfs/723
new file mode 100755
index 00000000..c068e496
--- /dev/null
+++ b/tests/xfs/723
@@ -0,0 +1,58 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2018 Oracle.  All Rights Reserved.
+#
+# FS QA Test 723
+#
+# Test detection & fixing of bad summary inode counts at mount time.
+#
+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
+
+# remove previous $seqres.full before test
+rm -f $seqres.full
+
+# real QA test starts here
+
+# Modify as appropriate.
+_supported_fs xfs
+_supported_os Linux
+_require_scratch
+
+echo "Format and mount"
+_scratch_mkfs > $seqres.full 2>&1
+_scratch_mount >> $seqres.full 2>&1
+echo "test file" > $SCRATCH_MNT/testfile
+
+echo "Fuzz ifree"
+_scratch_unmount
+icount=$(_scratch_xfs_get_metadata_field icount 'sb 0')
+_scratch_xfs_set_metadata_field ifree $((icount * 2)) 'sb 0' > $seqres.full 2>&1
+
+echo "Detection and Correction"
+_scratch_mount >> $seqres.full 2>&1
+avail=$(stat -c '%d' -f $SCRATCH_MNT)
+total=$(stat -c '%c' -f $SCRATCH_MNT)
+echo "avail: $avail" >> $seqres.full
+echo "total: $total" >> $seqres.full
+test "$avail" -gt "$total" && echo "free inodes bad: $avail > $total"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/723.out b/tests/xfs/723.out
new file mode 100644
index 00000000..e825855a
--- /dev/null
+++ b/tests/xfs/723.out
@@ -0,0 +1,4 @@
+QA output created by 723
+Format and mount
+Fuzz ifree
+Detection and Correction
diff --git a/tests/xfs/724 b/tests/xfs/724
new file mode 100755
index 00000000..f5e44fb6
--- /dev/null
+++ b/tests/xfs/724
@@ -0,0 +1,66 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2018 Oracle.  All Rights Reserved.
+#
+# FS QA Test 724
+#
+# Test detection & fixing of bad summary block counts at mount time.
+# Corrupt the AGFs to test mount failure when mount-fixing fails.
+#
+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
+
+# remove previous $seqres.full before test
+rm -f $seqres.full
+
+# real QA test starts here
+
+# Modify as appropriate.
+_supported_fs xfs
+_supported_os Linux
+_require_scratch_nocheck
+
+echo "Format and mount"
+_scratch_mkfs > $seqres.full 2>&1
+_scratch_mount >> $seqres.full 2>&1
+echo "test file" > $SCRATCH_MNT/testfile
+
+echo "Fuzz fdblocks and btreeblks"
+_scratch_unmount
+dblocks=$(_scratch_xfs_get_metadata_field dblocks 'sb 0')
+_scratch_xfs_set_metadata_field fdblocks $((dblocks * 2)) 'sb 0' > $seqres.full 2>&1
+
+aglen=$(_scratch_xfs_get_metadata_field length 'agf 0')
+_scratch_xfs_set_metadata_field btreeblks $aglen 'agf 0' > $seqres.full 2>&1
+
+echo "Detection and Correction"
+if _try_scratch_mount >> $seqres.full 2>&1; then
+	echo "mount should have failed"
+	avail=$(stat -c '%a' -f $SCRATCH_MNT)
+	total=$(stat -c '%b' -f $SCRATCH_MNT)
+	echo "avail: $avail" >> $seqres.full
+	echo "total: $total" >> $seqres.full
+	test "$avail" -gt "$total" && echo "free space bad: $avail > $total"
+	_scratch_unmount
+fi
+_scratch_xfs_repair -n >> $seqres.full 2>&1 && echo "repair didn't find fuzz?"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/724.out b/tests/xfs/724.out
new file mode 100644
index 00000000..6571f9ed
--- /dev/null
+++ b/tests/xfs/724.out
@@ -0,0 +1,4 @@
+QA output created by 724
+Format and mount
+Fuzz fdblocks and btreeblks
+Detection and Correction
diff --git a/tests/xfs/group b/tests/xfs/group
index 821bf2ac..28074f07 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -488,3 +488,6 @@
 488 dangerous_fuzzers dangerous_norepair
 489 dangerous_fuzzers dangerous_norepair
 490 auto quick
+722 auto quick fuzz
+723 auto quick fuzz
+724 auto quick fuzz

  parent reply	other threads:[~2018-10-05  7:15 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-05  0:19 [PATCH 0/6] fstests: fixes and new tests Darrick J. Wong
2018-10-05  0:19 ` [PATCH 1/6] generic: add bfoster's alternate reproducer Darrick J. Wong
2018-10-05  0:19 ` Darrick J. Wong [this message]
2018-10-05  0:19 ` [PATCH 3/6] xfs/189: skip 'barrier' mount option test on newer kernels Darrick J. Wong
2018-10-05  0:19 ` [PATCH 4/6] xfs/270: use _scratch_xfs_set_metadata_field to fuzz rocompat bits Darrick J. Wong
2018-10-05  6:54   ` Xiao Yang
2018-10-05  6:54     ` Xiao Yang
2018-10-05  0:19 ` [PATCH 5/6] xfs/288: shut up verifier error Darrick J. Wong
2018-10-05  0:19 ` [PATCH 6/6] generic: test reflink side effects Darrick J. Wong
2018-10-14 15:40   ` Eryu Guan
2018-10-15 18:57     ` 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=153869876040.26648.11302951509500617148.stgit@magnolia \
    --to=darrick.wong@oracle.com \
    --cc=fstests@vger.kernel.org \
    --cc=guaneryu@gmail.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.