Skip to contentSkip to conversation

xfs: test inobt/on disk free state mismatches

PATCH Superseded Dave Chinner 3 participants 7 messages May 6, 2018 – May 11, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs: test inobt/on disk free state mismatches

From: Dave Chinner <[email protected]>

Fuzzing has recently uncovered a couple of conditions where we don't detect corruptions that reallocate already allocated inodes. This test exercises those cases, and checks that we shut down the filesystem appropriately when such a corruption occurs.

---
 tests/xfs/450     | 73 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/450.out | 26 +++++++++++++++++
 tests/xfs/group   |  1 +
 3 files changed, 100 insertions(+)
 create mode 100755 tests/xfs/450
 create mode 100644 tests/xfs/450.out
tests/xfs/450 new file +73 -0
new file mode 100755
index 000000000000..bac001690d60
@@ -0,0 +1,73 @@
+#! /bin/bash
+# FS QA Test 450
+#
+# Catch inobt/on disk inode free state mismatches on V4 filesystems
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2018 Red Hat, Inc.  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 /
+	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
+
+_supported_fs xfs
+_supported_os Linux
+
+# we intentionally corrupt the filesystem, so don't check it after the test
+_require_scratch_nocheck
+
+# on success, we'll get a shutdown filesystem with a really noisy log message
+# due to transaction cancellation.  Hence we don't want to check dmesg here.
+_disable_dmesg_check
+
+_require_xfs_mkfs_crc
+_scratch_mkfs -m crc=0 > $seqres.full 2>&1
+
+# corrupt an inode in the root inode chunk
+root_ino=`$XFS_DB_PROG -c "sb 0" -c "p rootino" $SCRATCH_DEV`
+corrupt_ino=$((root_ino + 15))
+$XFS_DB_PROG -x -c "inode $corrupt_ino" -c "write core.mode 0100644" $SCRATCH_DEV
+
+_scratch_mount
+
+# The corrupt inode should be tripped over during these initial file creates.
+touch $SCRATCH_MNT/file{0,1,2,3,4,5}{0,1,2,3,4,5} 2>&1 | _filter_scratch
+
+# success, all done
+status=0
+exit
tests/xfs/450.out new file +26 -0
new file mode 100644
index 000000000000..379a8d6f6ec9
@@ -0,0 +1,26 @@
+QA output created by 450
+core.mode = 0100644
+touch: cannot touch 'SCRATCH_MNT/file20': Structure needs cleaning
+touch: cannot touch 'SCRATCH_MNT/file21': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file22': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file23': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file24': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file25': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file30': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file31': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file32': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file33': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file34': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file35': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file40': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file41': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file42': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file43': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file44': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file45': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file50': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file51': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file52': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file53': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file54': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file55': Input/output error
tests/xfs/group +1 -0
index d62345fc8f96..aeb8ba963ade 100644
@@ -440,5 +440,6 @@
 441 auto quick clone quota
 442 auto stress clone quota
 443 auto quick ioctl fsr
+450 auto quick 
 444 auto quick
 445 auto quick filestreams
Signature · 1 line
2.17.0
#1 lore raw
Quoted 71 lines · Dave Chinner

From: Dave Chinner <[email protected]>

Fuzzing has recently uncovered a couple of conditions where we don't detect corruptions that reallocate already allocated inodes. This test exercises those cases, and checks that we shut down the filesystem appropriately when such a corruption occurs.

---
 tests/xfs/450     | 73 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/450.out | 26 +++++++++++++++++
 tests/xfs/group   |  1 +
 3 files changed, 100 insertions(+)
 create mode 100755 tests/xfs/450
 create mode 100644 tests/xfs/450.out
tests/xfs/450 new file +49 -0
new file mode 100755
index 000000000000..bac001690d60
@@ -0,0 +1,73 @@
+#! /bin/bash
+# FS QA Test 450
+#
+# Catch inobt/on disk inode free state mismatches on V4 filesystems
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2018 Red Hat, Inc.  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 /
+	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
+
+_supported_fs xfs
+_supported_os Linux

tests/xfs/450 line 59

Quoted 10 lines
tests/xfs/450 new file +10 -0
+
+# we intentionally corrupt the filesystem, so don't check it after the test
+_require_scratch_nocheck
+
+# on success, we'll get a shutdown filesystem with a really noisy log message
+# due to transaction cancellation.  Hence we don't want to check dmesg here.
+_disable_dmesg_check
+
+_require_xfs_mkfs_crc
+_scratch_mkfs -m crc=0 > $seqres.full 2>&1

We require mkfs to support crc but then turn it off? Seeing as this is a v4 test I'd have expected this also to run on old xfsprogs that only supports v4. <confused>

tests/xfs/450 line 62

Quoted 3 lines
tests/xfs/450 new file +3 -0
+
+# corrupt an inode in the root inode chunk
+root_ino=`$XFS_DB_PROG -c "sb 0" -c "p rootino" $SCRATCH_DEV`

root_ino=$(_scratch_xfs_get_metadata_field 'rootino' 'sb 0')

(xfs_db gets cranky if you don't feed it the external log device)

tests/xfs/450 line 64

Quoted 2 lines
tests/xfs/450 new file +2 -0
+corrupt_ino=$((root_ino + 15))
+$XFS_DB_PROG -x -c "inode $corrupt_ino" -c "write core.mode 0100644" $SCRATCH_DEV

_scratch_xfs_set_metadata_field 'core.mode' 0100644 "inode $corrupt_ino"

--D

Quoted 59 lines
tests/xfs/450 new file +9 -0
+
+_scratch_mount
+
+# The corrupt inode should be tripped over during these initial file creates.
+touch $SCRATCH_MNT/file{0,1,2,3,4,5}{0,1,2,3,4,5} 2>&1 | _filter_scratch
+
+# success, all done
+status=0
+exit
tests/xfs/450.out new file +26 -0
new file mode 100644
index 000000000000..379a8d6f6ec9
@@ -0,0 +1,26 @@
+QA output created by 450
+core.mode = 0100644
+touch: cannot touch 'SCRATCH_MNT/file20': Structure needs cleaning
+touch: cannot touch 'SCRATCH_MNT/file21': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file22': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file23': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file24': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file25': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file30': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file31': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file32': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file33': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file34': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file35': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file40': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file41': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file42': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file43': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file44': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file45': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file50': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file51': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file52': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file53': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file54': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file55': Input/output error
tests/xfs/group +1 -0
index d62345fc8f96..aeb8ba963ade 100644
@@ -440,5 +440,6 @@
 441 auto quick clone quota
 442 auto stress clone quota
 443 auto quick ioctl fsr
+450 auto quick 
 444 auto quick
 445 auto quick filestreams
Signature · 6 lines
2.17.0

--
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
#2 lore raw
Quoted 78 lines · Darrick J. Wong
Quoted 77 lines · Dave Chinner

From: Dave Chinner <[email protected]>

Fuzzing has recently uncovered a couple of conditions where we don't detect corruptions that reallocate already allocated inodes. This test exercises those cases, and checks that we shut down the filesystem appropriately when such a corruption occurs.

---
 tests/xfs/450     | 73 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/450.out | 26 +++++++++++++++++
 tests/xfs/group   |  1 +
 3 files changed, 100 insertions(+)
 create mode 100755 tests/xfs/450
 create mode 100644 tests/xfs/450.out
tests/xfs/450 new file +55 -0
new file mode 100755
index 000000000000..bac001690d60
@@ -0,0 +1,73 @@
+#! /bin/bash
+# FS QA Test 450
+#
+# Catch inobt/on disk inode free state mismatches on V4 filesystems
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2018 Red Hat, Inc.  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 /
+	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
+
+_supported_fs xfs
+_supported_os Linux
+
+# we intentionally corrupt the filesystem, so don't check it after the test
+_require_scratch_nocheck
+
+# on success, we'll get a shutdown filesystem with a really noisy log message
+# due to transaction cancellation.  Hence we don't want to check dmesg here.
Quoted 8 lines

tests/xfs/450 line 59

Quoted 4 lines
tests/xfs/450 new file +4 -0
+_disable_dmesg_check
+
+_require_xfs_mkfs_crc
+_scratch_mkfs -m crc=0 > $seqres.full 2>&1

We require mkfs to support crc but then turn it off? Seeing as this is a v4 test I'd have expected this also to run on old xfsprogs that only supports v4. <confused>

Yup, copied that from another test that does exactly the same thing. We have to do that to build v4 filesystems on modern xfsprogs that default to v5, but using -m crc without a check for that functionality will break the test on older xfsprogs....

Quoted 5 lines

tests/xfs/450 line 62

Quoted 3 lines
tests/xfs/450 new file +3 -0
+
+# corrupt an inode in the root inode chunk
+root_ino=`$XFS_DB_PROG -c "sb 0" -c "p rootino" $SCRATCH_DEV`

root_ino=$(_scratch_xfs_get_metadata_field 'rootino' 'sb 0')

Oh, didn't know that existed.

Quoted 4 lines

tests/xfs/450 line 64

Quoted 2 lines
tests/xfs/450 new file +2 -0
+corrupt_ino=$((root_ino + 15))
+$XFS_DB_PROG -x -c "inode $corrupt_ino" -c "write core.mode 0100644" $SCRATCH_DEV

_scratch_xfs_set_metadata_field 'core.mode' 0100644 "inode $corrupt_ino"

ditto. Will fix.

Cheers,

dave.

Signature · 2 lines
Dave Chinner
[email protected]
#3 lore raw

PATCH v2 1/1 xfs: test inobt/on disk free state mismatches

In reply to Dave Chinner

From: Dave Chinner <[email protected]>

Fuzzing has recently uncovered a couple of conditions where we don't detect corruptions that reallocate already allocated inodes. This test exercises those cases, and checks that we shut down the filesystem appropriately when such a corruption occurs.

---
V2:
- fix method of calling xfs_db to use correct helpers.

 tests/{shared/003 => xfs/450} | 41 ++++++++++++++++++++++-------------------
 tests/xfs/450.out             | 26 ++++++++++++++++++++++++++
 tests/xfs/group               |  1 +
 3 files changed, 49 insertions(+), 19 deletions(-)
tests/xfs/450 renamed from tests/shared/003 +22 -19
similarity index 59%
copy from tests/shared/003
copy to tests/xfs/450
index 9a9956cf44de..267089738574 100755
@@ -1,15 +1,10 @@
 #! /bin/bash
-# FS QA Test 003
+# FS QA Test 450
 #
-# Test mount a needs_recovery partition with noload option.
-# ext4 used to Oops until part of this commit:
-#
-# 744692d ext4: use ext4_get_block_write in buffer write
-#
-# Also test on ext2/3.
+# Catch inobt/on disk inode free state mismatches on V4 filesystems
 #
 #-----------------------------------------------------------------------
-# Copyright (c) 2015 Red Hat Inc.  All Rights Reserved.
+# Copyright (c) 2018 Red Hat, Inc.  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
@@ -45,25 +40,33 @@ _cleanup()
 . ./common/rc
 . ./common/filter
 
+# remove previous $seqres.full before test
+rm -f $seqres.full
+
 # real QA test starts here
-_supported_fs ext2 ext3 ext4
+
+_supported_fs xfs
 _supported_os Linux
 
-# nofsck as we modify sb via debugfs
+# we intentionally corrupt the filesystem, so don't check it after the test
 _require_scratch_nocheck
 
-# remove previous $seqres.full before test
-rm -f $seqres.full
-echo "Silence is golden"
+# on success, we'll get a shutdown filesystem with a really noisy log message
+# due to transaction cancellation.  Hence we don't want to check dmesg here.
+_disable_dmesg_check
+
+_require_xfs_mkfs_crc
+_scratch_mkfs -m crc=0 > $seqres.full 2>&1
 
-_scratch_mkfs >>$seqres.full 2>&1
+# corrupt an inode in the root inode chunk
+root_ino=$(_scratch_xfs_get_metadata_field 'rootino' 'sb 0')
+corrupt_ino=$((root_ino + 15))
+_scratch_xfs_set_metadata_field 'core.mode' 0100644 "inode $corrupt_ino"
 
-# set needs_recovery feature bit
-debugfs -w -R "feature +needs_recovery" $SCRATCH_DEV \
-	>>$seqres.full 2>&1
+_scratch_mount
 
-# mount with noload option
-_try_scratch_mount "-o noload" >>$seqres.full 2>&1
+# The corrupt inode should be tripped over during these initial file creates.
+touch $SCRATCH_MNT/file{0,1,2,3,4,5}{0,1,2,3,4,5} 2>&1 | _filter_scratch
 
 # success, all done
 status=0
tests/xfs/450.out new file +26 -0
new file mode 100644
index 000000000000..379a8d6f6ec9
@@ -0,0 +1,26 @@
+QA output created by 450
+core.mode = 0100644
+touch: cannot touch 'SCRATCH_MNT/file20': Structure needs cleaning
+touch: cannot touch 'SCRATCH_MNT/file21': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file22': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file23': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file24': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file25': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file30': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file31': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file32': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file33': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file34': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file35': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file40': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file41': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file42': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file43': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file44': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file45': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file50': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file51': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file52': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file53': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file54': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file55': Input/output error
tests/xfs/group +1 -0
index d62345fc8f96..2a7f5eb68e82 100644
@@ -442,3 +442,4 @@
 443 auto quick ioctl fsr
 444 auto quick
 445 auto quick filestreams
+450 auto quick
#4 lore raw
Quoted 8 lines · Dave Chinner

From: Dave Chinner <[email protected]>

Fuzzing has recently uncovered a couple of conditions where we don't detect corruptions that reallocate already allocated inodes. This test exercises those cases, and checks that we shut down the filesystem appropriately when such a corruption occurs.

Quoted 8 lines

---
V2:
- fix method of calling xfs_db to use correct helpers.

 tests/{shared/003 => xfs/450} | 41 ++++++++++++++++++++++-------------------
 tests/xfs/450.out             | 26 ++++++++++++++++++++++++++
 tests/xfs/group               |  1 +

Messed up with shared/003?

Quoted 44 lines
 3 files changed, 49 insertions(+), 19 deletions(-)
tests/xfs/450 renamed from tests/shared/003 +9 -10
similarity index 59%
copy from tests/shared/003
copy to tests/xfs/450
index 9a9956cf44de..267089738574 100755
@@ -1,15 +1,10 @@
 #! /bin/bash
-# FS QA Test 003
+# FS QA Test 450
 #
-# Test mount a needs_recovery partition with noload option.
-# ext4 used to Oops until part of this commit:
-#
-# 744692d ext4: use ext4_get_block_write in buffer write
-#
-# Also test on ext2/3.
+# Catch inobt/on disk inode free state mismatches on V4 filesystems
 #
 #-----------------------------------------------------------------------
-# Copyright (c) 2015 Red Hat Inc.  All Rights Reserved.
+# Copyright (c) 2018 Red Hat, Inc.  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
@@ -45,25 +40,33 @@ _cleanup()
 . ./common/rc
 . ./common/filter
 
+# remove previous $seqres.full before test
+rm -f $seqres.full
+
 # real QA test starts here
-_supported_fs ext2 ext3 ext4
+
+_supported_fs xfs
 _supported_os Linux
 
-# nofsck as we modify sb via debugfs
+# we intentionally corrupt the filesystem, so don't check it after the test
 _require_scratch_nocheck

tests/xfs/450 _cleanup() · line 59

Quoted 10 lines
tests/xfs/450 renamed from tests/shared/003 +6 -3
 
-# remove previous $seqres.full before test
-rm -f $seqres.full
-echo "Silence is golden"
+# on success, we'll get a shutdown filesystem with a really noisy log message
+# due to transaction cancellation.  Hence we don't want to check dmesg here.
+_disable_dmesg_check
+
+_require_xfs_mkfs_crc
+_scratch_mkfs -m crc=0 > $seqres.full 2>&1

Looks like we can drop _require_xfs_mkfs_crc anyway, as _scratch_mkfs_xfs will remove any metadata options if the mkfs.xfs binary doesn't support it (done by _scratch_mkfs_xfs_opts).

Thanks,
Eryu

Quoted 64 lines
tests/xfs/450 renamed from tests/shared/003 +7 -6
-_scratch_mkfs >>$seqres.full 2>&1
+# corrupt an inode in the root inode chunk
+root_ino=$(_scratch_xfs_get_metadata_field 'rootino' 'sb 0')
+corrupt_ino=$((root_ino + 15))
+_scratch_xfs_set_metadata_field 'core.mode' 0100644 "inode $corrupt_ino"
 
-# set needs_recovery feature bit
-debugfs -w -R "feature +needs_recovery" $SCRATCH_DEV \
-	>>$seqres.full 2>&1
+_scratch_mount
 
-# mount with noload option
-_try_scratch_mount "-o noload" >>$seqres.full 2>&1
+# The corrupt inode should be tripped over during these initial file creates.
+touch $SCRATCH_MNT/file{0,1,2,3,4,5}{0,1,2,3,4,5} 2>&1 | _filter_scratch
 
 # success, all done
 status=0
tests/xfs/450.out new file +26 -0
new file mode 100644
index 000000000000..379a8d6f6ec9
@@ -0,0 +1,26 @@
+QA output created by 450
+core.mode = 0100644
+touch: cannot touch 'SCRATCH_MNT/file20': Structure needs cleaning
+touch: cannot touch 'SCRATCH_MNT/file21': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file22': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file23': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file24': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file25': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file30': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file31': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file32': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file33': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file34': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file35': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file40': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file41': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file42': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file43': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file44': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file45': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file50': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file51': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file52': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file53': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file54': Input/output error
+touch: cannot touch 'SCRATCH_MNT/file55': Input/output error
tests/xfs/group +1 -1
index d62345fc8f96..2a7f5eb68e82 100644
@@ -442,3 +442,4 @@
 443 auto quick ioctl fsr
 444 auto quick
 445 auto quick filestreams
+450 auto quick
--

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

#5 lore raw
Quoted 14 lines · Eryu Guan
Quoted 13 lines · Dave Chinner

From: Dave Chinner <[email protected]>

Fuzzing has recently uncovered a couple of conditions where we don't detect corruptions that reallocate already allocated inodes. This test exercises those cases, and checks that we shut down the filesystem appropriately when such a corruption occurs.

---
V2:
- fix method of calling xfs_db to use correct helpers.

Quoted 5 lines
Quoted 3 lines
 tests/{shared/003 => xfs/450} | 41 ++++++++++++++++++++++-------------------
 tests/xfs/450.out             | 26 ++++++++++++++++++++++++++
 tests/xfs/group               |  1 +

Messed up with shared/003?

No. That's just git being smart with it's diffs:

Quoted 6 lines

tests/xfs/450

Quoted 6 lines
 3 files changed, 49 insertions(+), 19 deletions(-)
tests/xfs/450 renamed from tests/shared/003 +0 -0
similarity index 59%
copy from tests/shared/003
copy to tests/xfs/450

It's copying and then patching, rather than just creating a whole new file.

Quoted 39 lines
Quoted 39 lines

index 9a9956cf44de..267089738574 100755

tests/xfs/450 renamed from tests/shared/003 +9 -10
@@ -1,15 +1,10 @@
 #! /bin/bash
-# FS QA Test 003
+# FS QA Test 450
 #
-# Test mount a needs_recovery partition with noload option.
-# ext4 used to Oops until part of this commit:
-#
-# 744692d ext4: use ext4_get_block_write in buffer write
-#
-# Also test on ext2/3.
+# Catch inobt/on disk inode free state mismatches on V4 filesystems
 #
 #-----------------------------------------------------------------------
-# Copyright (c) 2015 Red Hat Inc.  All Rights Reserved.
+# Copyright (c) 2018 Red Hat, Inc.  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
@@ -45,25 +40,33 @@ _cleanup()
 . ./common/rc
 . ./common/filter
 
+# remove previous $seqres.full before test
+rm -f $seqres.full
+
 # real QA test starts here
-_supported_fs ext2 ext3 ext4
+
+_supported_fs xfs
 _supported_os Linux
 
-# nofsck as we modify sb via debugfs
+# we intentionally corrupt the filesystem, so don't check it after the test
 _require_scratch_nocheck
 
Quoted 13 lines

tests/xfs/450 _cleanup() · line 59

Quoted 9 lines
tests/xfs/450 renamed from tests/shared/003 +6 -3
-# remove previous $seqres.full before test
-rm -f $seqres.full
-echo "Silence is golden"
+# on success, we'll get a shutdown filesystem with a really noisy log message
+# due to transaction cancellation.  Hence we don't want to check dmesg here.
+_disable_dmesg_check
+
+_require_xfs_mkfs_crc
+_scratch_mkfs -m crc=0 > $seqres.full 2>&1

Looks like we can drop _require_xfs_mkfs_crc anyway, as _scratch_mkfs_xfs will remove any metadata options if the mkfs.xfs binary doesn't support it (done by _scratch_mkfs_xfs_opts).

/me wonders how _scratch_mkfs_xfs_opts() gets user mkfs parameters passed to it to filter as _scratch_mkfs_xfs() doesn't pass any user parameters to it....

Cheers,

Dave.

Signature · 2 lines
Dave Chinner
[email protected]
#6 lore raw
Quoted 25 lines · Dave Chinner
Quoted 14 lines · Eryu Guan
Quoted 13 lines · Dave Chinner

From: Dave Chinner <[email protected]>

Fuzzing has recently uncovered a couple of conditions where we don't detect corruptions that reallocate already allocated inodes. This test exercises those cases, and checks that we shut down the filesystem appropriately when such a corruption occurs.

---
V2:
- fix method of calling xfs_db to use correct helpers.

Quoted 5 lines
Quoted 3 lines
 tests/{shared/003 => xfs/450} | 41 ++++++++++++++++++++++-------------------
 tests/xfs/450.out             | 26 ++++++++++++++++++++++++++
 tests/xfs/group               |  1 +

Messed up with shared/003?

No. That's just git being smart with it's diffs:

Quoted 2 lines
Quoted 2 lines
 3 files changed, 49 insertions(+), 19 deletions(-)
Quoted 7 lines
Quoted 4 lines

tests/xfs/450

Quoted 4 lines
tests/xfs/450 renamed from tests/shared/003 +0 -0
similarity index 59%
copy from tests/shared/003
copy to tests/xfs/450

It's copying and then patching, rather than just creating a whole new file.

Ah, right.

Quoted 55 lines
Quoted 41 lines
Quoted 41 lines

index 9a9956cf44de..267089738574 100755

tests/xfs/450 renamed from tests/shared/003 +9 -10
@@ -1,15 +1,10 @@
 #! /bin/bash
-# FS QA Test 003
+# FS QA Test 450
 #
-# Test mount a needs_recovery partition with noload option.
-# ext4 used to Oops until part of this commit:
-#
-# 744692d ext4: use ext4_get_block_write in buffer write
-#
-# Also test on ext2/3.
+# Catch inobt/on disk inode free state mismatches on V4 filesystems
 #
 #-----------------------------------------------------------------------
-# Copyright (c) 2015 Red Hat Inc.  All Rights Reserved.
+# Copyright (c) 2018 Red Hat, Inc.  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
@@ -45,25 +40,33 @@ _cleanup()
 . ./common/rc
 . ./common/filter
 
+# remove previous $seqres.full before test
+rm -f $seqres.full
+
 # real QA test starts here
-_supported_fs ext2 ext3 ext4
+
+_supported_fs xfs
 _supported_os Linux
 
-# nofsck as we modify sb via debugfs
+# we intentionally corrupt the filesystem, so don't check it after the test
 _require_scratch_nocheck
 
Quoted 13 lines

tests/xfs/450 _cleanup() · line 59

Quoted 9 lines
tests/xfs/450 renamed from tests/shared/003 +6 -3
-# remove previous $seqres.full before test
-rm -f $seqres.full
-echo "Silence is golden"
+# on success, we'll get a shutdown filesystem with a really noisy log message
+# due to transaction cancellation.  Hence we don't want to check dmesg here.
+_disable_dmesg_check
+
+_require_xfs_mkfs_crc
+_scratch_mkfs -m crc=0 > $seqres.full 2>&1

Looks like we can drop _require_xfs_mkfs_crc anyway, as _scratch_mkfs_xfs will remove any metadata options if the mkfs.xfs binary doesn't support it (done by _scratch_mkfs_xfs_opts).

Quoted 3 lines

/me wonders how _scratch_mkfs_xfs_opts() gets user mkfs parameters passed to it to filter as _scratch_mkfs_xfs() doesn't pass any user parameters to it....

I turns out that I broke it in commit 596a068bf130 ("fstests: teach _scratch_mkfs to handle mkfs option conflicts"), I forgot to pass extra mkfs parameters to _scratch_mkfs_xfs_opts(). I'll send a fix soon.

Thanks,
Eryu

Quoted 7 lines

Cheers,

Dave.

Signature · 2 lines
Dave Chinner
[email protected]