Skip to contentSkip to conversation

xfstests/xfs: xfs_repair secondary sb verification regression test

PATCH Superseded Brian Foster 2 participants 2 messages Jan 19, 2015 – Jan 21, 2015

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfstests/xfs: xfs_repair secondary sb verification regression test

The secondary superblock verification in xfs_repair was subject to a bug that unnecessarily leads to a brute force superblock scan if the last superblock in the fs happens to be corrupt. Normally, xfs_repair handles one-off superblock corruption gracefully using a heuristic that finds the most consistent superblock content across the set of secondary superblocks.

Create a regression test for xfs_repair that corrupts the last superblock in the fs. Verify the superblock is updated from the previously verified sb content and a brute force scan is not initiated. In the event of failure, detect that a brute force scan has started and abort the repair in order to fail the test quickly.

To support the test, extend the xfs_repair filter to handle corrupted superblock repair output and provide generic test output for arbitrary AG counts.

---

Hi all,

This is an xfs_repair regression test to trigger the problem fixed by the following previously posted fix:

http://oss.sgi.com/archives/xfs/2015-01/msg00244.html

Thoughts appreciated, thanks.

Brian

 common/repair     |   4 ++
 tests/xfs/069     | 110 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/069.out |  27 ++++++++++++++
 tests/xfs/group   |   1 +
 4 files changed, 142 insertions(+)
 create mode 100755 tests/xfs/069
 create mode 100644 tests/xfs/069.out
common/repair +4 -0
index a157580..7a99546 100644
@@ -88,6 +88,10 @@ s/(inode chunk) (\d+)\/(\d+)/AGNO\/INO/;
 # sunit/swidth reset messages
 s/^(Note - .*) were copied.*/\1 fields have been reset./;
 s/^(Please) reset (with .*) if necessary/\1 set \2/;
+# corrupt sb messages
+s/(superblock) (\d+)/\1 AGNO/;
+s/(AG \#)(\d+)/\1AGNO/;
+s/(reset bad sb for ag) (\d+)/\1 AGNO/;
 	print;'
 }
 
tests/xfs/069 new file +110 -0

110 lines not on this page · raw message

tests/xfs/069.out new file +27 -0
new file mode 100644
index 0000000..c6b11d1
@@ -0,0 +1,27 @@
+QA output created by 069
+Phase 1 - find and verify superblock...
+Phase 2 - using <TYPEOF> log
+        - zero log...
+        - scan filesystem freespace and inode maps...
+bad magic number
+bad on-disk superblock AGNO - bad magic number
+primary/secondary superblock AGNO conflict - AG superblock geometry info conflicts with filesystem geometry
+zeroing unused portion of secondary superblock (AG #AGNO)
+reset bad sb for ag AGNO
+        - found root inode chunk
+Phase 3 - for each AG...
+        - scan and clear agi unlinked lists...
+        - process known inodes and perform inode discovery...
+        - process newly discovered inodes...
+Phase 4 - check for duplicate blocks...
+        - setting up duplicate extent list...
+        - check for inodes claiming duplicate blocks...
+Phase 5 - rebuild AG headers and trees...
+        - reset superblock...
+Phase 6 - check inode connectivity...
+        - resetting contents of realtime bitmap and summary inodes
+        - traversing filesystem ...
+        - traversal finished ...
+        - moving disconnected inodes to lost+found ...
+Phase 7 - verify and correct link counts...
+done
tests/xfs/group +1 -0
index 496630d..9394703 100644
@@ -66,6 +66,7 @@
 066 dump ioctl auto quick
 067 acl attr auto quick
 068 auto stress dump
+069 auto quick repair
 071 rw auto
 072 rw auto prealloc quick
 073 copy auto
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 28 lines · Brian Foster

The secondary superblock verification in xfs_repair was subject to a bug that unnecessarily leads to a brute force superblock scan if the last superblock in the fs happens to be corrupt. Normally, xfs_repair handles one-off superblock corruption gracefully using a heuristic that finds the most consistent superblock content across the set of secondary superblocks.

Create a regression test for xfs_repair that corrupts the last superblock in the fs. Verify the superblock is updated from the previously verified sb content and a brute force scan is not initiated. In the event of failure, detect that a brute force scan has started and abort the repair in order to fail the test quickly.

To support the test, extend the xfs_repair filter to handle corrupted superblock repair output and provide generic test output for arbitrary AG counts.

---

Hi all,

This is an xfs_repair regression test to trigger the problem fixed by the following previously posted fix:

http://oss.sgi.com/archives/xfs/2015-01/msg00244.html

Thoughts appreciated, thanks.

...

tests/xfs/069 line 63

Quoted 11 lines
tests/xfs/069 new file +11 -0
+# Start and monitor an xfs_repair of the scratch device. This test can induce a
+# time consuming brute force superblock scan. Since a brute force scan means
+# test failure, detect it and end the repair.
+_xfs_repair_noscan()
+{
+	# invoke repair directly so we can kill the process if need be
+	$XFS_REPAIR_PROG $SCRATCH_DEV 2>&1 | tee -a $seqres.full > $tmp.repair &
+	repair_pid=$!
+
+	# monitor progress for as long as it is running
+	while [ `ps -q $repair_pid > /dev/null; echo $?` == 0 ]; do

while [ pgrep xfs_repair -eq 0 ]; do

Quoted 27 lines
tests/xfs/069 new file +27 -0
+		grep "couldn't verify primary superblock" $tmp.repair \
+			> /dev/null 2>&1
+		if [ $? == 0 ]; then
+			# we've started a brute force scan. kill repair and
+			# fail the test
+			kill -9 $repair_pid >> $seqres.full 2>&1
+			wait >> $seqres.full 2>&1
+
+			_fail "xfs_repair resorted to brute force scan"
+		fi
+
+		sleep 1
+	done
+
+	wait
+
+	cat $tmp.repair | _filter_repair
+}
+
+rm -f $seqres.full
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/repair
+
+# real QA test starts here

tests/xfs/069 line 100

Quoted 10 lines
tests/xfs/069 new file +10 -0
+
+# Modify as appropriate.
+_supported_fs xfs
+_supported_os Linux
+_require_scratch_nocheck
+
+_scratch_mkfs >> $seqres.full 2>&1 || _fail "mkfs failed"
+
+# corrupt the last secondary sb in the fs
+agcount=`$XFS_DB_PROG -c "sb" -c "p agcount" $SCRATCH_DEV | awk '{ print $3 }'`

scratch_mkfs | _filter_mkfs 2> $tmp.mkfs
. $tmp.mkfs

And now you have the agcount variable already set up (and most other fs geometry variables that mkfs outputs).

Quoted 2 lines

+last_secondary=$((agcount - 1))
+$XFS_DB_PROG -x -c "sb $last_secondary" -c "type data" \

you can just use "sb $((agcount - 1))" directly. The comment above tells us that it's the last secondary sb we are corrupting....

Otherwise look sok.

Cheers,

Dave.

Signature · 2 lines
Dave Chinner
[email protected]