* [PATCH v3 0/3] xfs: test malformed inode mode
@ 2017-01-09 13:30 Amir Goldstein
2017-01-09 13:30 ` [PATCH v3 1/3] xfs: test handling of invalid inode modes Amir Goldstein
` (3 more replies)
0 siblings, 4 replies; 9+ messages in thread
From: Amir Goldstein @ 2017-01-09 13:30 UTC (permalink / raw)
To: Eryu Guan; +Cc: Brian Foster, Darrick J . Wong, fstests, linux-xfs
Eryu,
This is the 3rd revision of the malformed inode mode test.
Like with v2, patch 1 is safe and it passes on kernel 4.9.
Like with v2, patch 2 is safe, but unlike v2, it fails on
kernel 4.9, because I added a stronger expectation for the
test to fails on stat of directory with inode size 0.
Like with v2, patch 3 triggers an XFS assert and I removed
the "safety pin" that was there in v2.
I already sent the fix patch to Darick, which addresses the
failures in both patch 2 and 3.
You could merge patch 1 now and defer merging patches 2-3
or you could wait with merging the entire test. up to you.
Amir.
v3:
- added empty and non empty regular file cases (patch 1)
- expect to detect directory with size 0 as an error (patch 2)
- removed the "safety pin" from patch 3
v2:
- test fstat with malformed inode mode
- test readlink/readdir with malformed inode mode
v1:
- test xfs_repair with malformed inode mode
Amir Goldstein (3):
xfs: test handling of invalid inode modes
xfs: test fstat with malformed inode mode
xfs: test readlink/readdir with malformed inode mode
tests/xfs/348 | 154 +++++++++++++++++++++++
tests/xfs/348.out | 360 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/xfs/group | 1 +
3 files changed, 515 insertions(+)
create mode 100755 tests/xfs/348
create mode 100644 tests/xfs/348.out
--
2.7.4
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v3 1/3] xfs: test handling of invalid inode modes
2017-01-09 13:30 [PATCH v3 0/3] xfs: test malformed inode mode Amir Goldstein
@ 2017-01-09 13:30 ` Amir Goldstein
2017-01-09 13:36 ` Amir Goldstein
2017-01-09 13:39 ` Amir Goldstein
2017-01-09 13:30 ` [PATCH v3 2/3] xfs: test fstat with malformed inode mode Amir Goldstein
` (2 subsequent siblings)
3 siblings, 2 replies; 9+ messages in thread
From: Amir Goldstein @ 2017-01-09 13:30 UTC (permalink / raw)
To: Eryu Guan; +Cc: Brian Foster, Darrick J . Wong, fstests, linux-xfs
Set all possible file type values for different types of files
and verify that xfs_repair detects the correct errors.
When setting invalid file type values (e.g. core.mode = 0170644),
all files are expected to have been junked by xfs_repair.
When setting valid file type values to non matching file types,
xfs_repair would either detect wrong format and junk the file, e.g.:
would have junked entry "DATA" in directory PARENT_INO
or detect a ftype mismatch error, e.g.:
would fix ftype mismatch (5/3) in directory/child PARENT_INO/FIFO_INO
If ftype feature is enabled, when setting file type to one of the
special types (i.e. FIFO(1), CHRDEV(2),BLKDEV(6),SOCKET(14)),
xfs_repair is expected to detect ftype mismatch error. Otherwise,
xfs_repair is not expected to detect ftype mismatch error.
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
tests/xfs/348 | 129 ++++++++++++++++++++++++++++
tests/xfs/348.out | 248 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/xfs/group | 1 +
3 files changed, 378 insertions(+)
create mode 100755 tests/xfs/348
create mode 100644 tests/xfs/348.out
diff --git a/tests/xfs/348 b/tests/xfs/348
new file mode 100755
index 0000000..c5249eb
--- /dev/null
+++ b/tests/xfs/348
@@ -0,0 +1,129 @@
+#! /bin/bash
+# FSQA Test No. 348
+#
+# Test handling of invalid inode modes
+#
+# Set all possible file type values for different types of files
+# and verify that xfs_repair detects the correct errors.
+#
+#-----------------------------------------------------------------------
+#
+# Copyright (C) 2016 CTERA Networks. All Rights Reserved.
+# Author: Amir Goldstein <amir73il@gmail.com>
+#
+# 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"
+
+tmp=/tmp/$$
+status=1 # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+ rm -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/repair
+
+# real QA test starts here
+_supported_fs xfs
+_supported_os Linux
+_require_scratch
+
+rm -f $seqres.full
+
+_scratch_mkfs >>$seqres.full 2>&1
+
+_scratch_mount
+
+# Create our test files.
+testdir=$SCRATCH_MNT/test
+mkdir -p $testdir
+mkdir $testdir/DIR
+echo 123 > $testdir/DATA
+touch $testdir/EMPTY
+ln -s $testdir/DATA $testdir/SYMLINK
+mknod $testdir/CHRDEV c 1 1
+mknod $testdir/BLKDEV b 1 1
+mknod $testdir/FIFO p
+
+xfs_info $SCRATCH_MNT | grep -q "ftype=1" && FTYPE_FEATURE=1
+
+# Record test dir inode for xfs_repair filter
+inode_filter=$tmp.sed
+rm -f $inode_filter
+pino=$(ls -id $testdir | awk '{print $1}')
+echo "s/inode $pino/PARENT_INO/" >> $inode_filter
+echo "s/directory $pino/directory PARENT_INO/" >> $inode_filter
+
+inodes=""
+# Record inode numbers for xfs_db commands and xfs_repair filter
+for f in DIR DATA EMPTY SYMLINK CHRDEV BLKDEV FIFO; do
+ ino=$(ls -id $testdir/$f | awk '{print $1}')
+ inodes="$inodes $ino"
+ echo "s/inode $ino/${f}_INO/" >> $inode_filter
+done
+
+_scratch_unmount
+
+# Possible mode file type values (mode & S_IFMT) >> 12
+dtypes="0 1 2 3 4 5 6 7 10 11 12 13 14 15 16 17"
+echo "===== Find inode by file type:"
+for dt in $dtypes; do
+ # Set all our test files to dt value
+ for ino in $inodes; do
+ _scratch_xfs_db -c "inode $ino" -c "print core.mode" | \
+ grep -q "0${dt}0...$" && \
+ (echo "dt=$dt => inode $ino" | sed -f $inode_filter)
+ done
+done
+for dt in $dtypes; do
+ echo
+ echo "===== Setting dt=$dt to all files:"
+ # Set all our test files to dt value
+ for ino in $inodes; do
+ _scratch_xfs_db -x -c "inode $ino" -c "write core.mode 0${dt}0644"
+ done
+ # Repair should detect the inconsistencies
+ # For invalid dt values, all files would have been junked.
+ # For valid dt values, one test file is expected to be valid.
+ # The rest would either have wrong format or non matching dir ftype.
+ _scratch_xfs_repair -n 2>&1 | tee -a $seqres.full | \
+ _filter_repair | grep "^would have junked" | sed -f $inode_filter | sort -u
+ # If ftype feature is enabled, when setting file type to one of the
+ # special types (i.e. FIFO(1), CHRDEV(2),BLKDEV(6),SOCKET(14)),
+ # xfs_repair is expected to detect ftype mismatch error. Otherewise,
+ # xfs_repair is not expected to detect ftype mismatch error.
+ if [ "$FTYPE_FEATURE" = 1 ] && (echo ':1:2:6:14:' | grep -q ":$dt:"); then
+ _scratch_xfs_repair -n 2>&1 | grep -q "^would fix ftype mismatch" || \
+ _fail "xfs_repair should fix ftype mismatch"
+ else
+ _scratch_xfs_repair -n 2>&1 | grep -q -v "^would fix ftype mismatch" || \
+ _fail "xfs_repair should not fix ftype mismatch"
+ fi
+done
+
+# Repair should detect and junk all test files
+_scratch_xfs_repair 2>&1 >> $seqres.full 2>&1 || _fail "xfs_repair should not fail"
+
+status=0
+exit
diff --git a/tests/xfs/348.out b/tests/xfs/348.out
new file mode 100644
index 0000000..31cf415
--- /dev/null
+++ b/tests/xfs/348.out
@@ -0,0 +1,248 @@
+QA output created by 348
+===== Find inode by file type:
+dt=1 => FIFO_INO
+dt=2 => CHRDEV_INO
+dt=4 => DIR_INO
+dt=6 => BLKDEV_INO
+dt=10 => DATA_INO
+dt=10 => EMPTY_INO
+dt=12 => SYMLINK_INO
+
+===== Setting dt=0 to all files:
+core.mode = 0644
+core.mode = 0644
+core.mode = 0644
+core.mode = 0644
+core.mode = 0644
+core.mode = 0644
+core.mode = 0644
+would have junked entry "BLKDEV" in directory PARENT_INO
+would have junked entry "CHRDEV" in directory PARENT_INO
+would have junked entry "DATA" in directory PARENT_INO
+would have junked entry "DIR" in directory PARENT_INO
+would have junked entry "EMPTY" in directory PARENT_INO
+would have junked entry "FIFO" in directory PARENT_INO
+would have junked entry "SYMLINK" in directory PARENT_INO
+
+===== Setting dt=1 to all files:
+core.mode = 010644
+core.mode = 010644
+core.mode = 010644
+core.mode = 010644
+core.mode = 010644
+core.mode = 010644
+core.mode = 010644
+would have junked entry "DATA" in directory PARENT_INO
+would have junked entry "DIR" in directory PARENT_INO
+would have junked entry "EMPTY" in directory PARENT_INO
+would have junked entry "SYMLINK" in directory PARENT_INO
+
+===== Setting dt=2 to all files:
+core.mode = 020644
+core.mode = 020644
+core.mode = 020644
+core.mode = 020644
+core.mode = 020644
+core.mode = 020644
+core.mode = 020644
+would have junked entry "DATA" in directory PARENT_INO
+would have junked entry "DIR" in directory PARENT_INO
+would have junked entry "EMPTY" in directory PARENT_INO
+would have junked entry "SYMLINK" in directory PARENT_INO
+
+===== Setting dt=3 to all files:
+core.mode = 030644
+core.mode = 030644
+core.mode = 030644
+core.mode = 030644
+core.mode = 030644
+core.mode = 030644
+core.mode = 030644
+would have junked entry "BLKDEV" in directory PARENT_INO
+would have junked entry "CHRDEV" in directory PARENT_INO
+would have junked entry "DATA" in directory PARENT_INO
+would have junked entry "DIR" in directory PARENT_INO
+would have junked entry "EMPTY" in directory PARENT_INO
+would have junked entry "FIFO" in directory PARENT_INO
+would have junked entry "SYMLINK" in directory PARENT_INO
+
+===== Setting dt=4 to all files:
+core.mode = 040644
+core.mode = 040644
+core.mode = 040644
+core.mode = 040644
+core.mode = 040644
+core.mode = 040644
+core.mode = 040644
+would have junked entry "BLKDEV" in directory PARENT_INO
+would have junked entry "CHRDEV" in directory PARENT_INO
+would have junked entry "DATA" in directory PARENT_INO
+would have junked entry "EMPTY" in directory PARENT_INO
+would have junked entry "FIFO" in directory PARENT_INO
+
+===== Setting dt=5 to all files:
+core.mode = 050644
+core.mode = 050644
+core.mode = 050644
+core.mode = 050644
+core.mode = 050644
+core.mode = 050644
+core.mode = 050644
+would have junked entry "BLKDEV" in directory PARENT_INO
+would have junked entry "CHRDEV" in directory PARENT_INO
+would have junked entry "DATA" in directory PARENT_INO
+would have junked entry "DIR" in directory PARENT_INO
+would have junked entry "EMPTY" in directory PARENT_INO
+would have junked entry "FIFO" in directory PARENT_INO
+would have junked entry "SYMLINK" in directory PARENT_INO
+
+===== Setting dt=6 to all files:
+core.mode = 060644
+core.mode = 060644
+core.mode = 060644
+core.mode = 060644
+core.mode = 060644
+core.mode = 060644
+core.mode = 060644
+would have junked entry "DATA" in directory PARENT_INO
+would have junked entry "DIR" in directory PARENT_INO
+would have junked entry "EMPTY" in directory PARENT_INO
+would have junked entry "SYMLINK" in directory PARENT_INO
+
+===== Setting dt=7 to all files:
+core.mode = 070644
+core.mode = 070644
+core.mode = 070644
+core.mode = 070644
+core.mode = 070644
+core.mode = 070644
+core.mode = 070644
+would have junked entry "BLKDEV" in directory PARENT_INO
+would have junked entry "CHRDEV" in directory PARENT_INO
+would have junked entry "DATA" in directory PARENT_INO
+would have junked entry "DIR" in directory PARENT_INO
+would have junked entry "EMPTY" in directory PARENT_INO
+would have junked entry "FIFO" in directory PARENT_INO
+would have junked entry "SYMLINK" in directory PARENT_INO
+
+===== Setting dt=10 to all files:
+core.mode = 0100644
+core.mode = 0100644
+core.mode = 0100644
+core.mode = 0100644
+core.mode = 0100644
+core.mode = 0100644
+core.mode = 0100644
+would have junked entry "BLKDEV" in directory PARENT_INO
+would have junked entry "CHRDEV" in directory PARENT_INO
+would have junked entry "DIR" in directory PARENT_INO
+would have junked entry "FIFO" in directory PARENT_INO
+would have junked entry "SYMLINK" in directory PARENT_INO
+
+===== Setting dt=11 to all files:
+core.mode = 0110644
+core.mode = 0110644
+core.mode = 0110644
+core.mode = 0110644
+core.mode = 0110644
+core.mode = 0110644
+core.mode = 0110644
+would have junked entry "BLKDEV" in directory PARENT_INO
+would have junked entry "CHRDEV" in directory PARENT_INO
+would have junked entry "DATA" in directory PARENT_INO
+would have junked entry "DIR" in directory PARENT_INO
+would have junked entry "EMPTY" in directory PARENT_INO
+would have junked entry "FIFO" in directory PARENT_INO
+would have junked entry "SYMLINK" in directory PARENT_INO
+
+===== Setting dt=12 to all files:
+core.mode = 0120644
+core.mode = 0120644
+core.mode = 0120644
+core.mode = 0120644
+core.mode = 0120644
+core.mode = 0120644
+core.mode = 0120644
+would have junked entry "BLKDEV" in directory PARENT_INO
+would have junked entry "CHRDEV" in directory PARENT_INO
+would have junked entry "DATA" in directory PARENT_INO
+would have junked entry "DIR" in directory PARENT_INO
+would have junked entry "EMPTY" in directory PARENT_INO
+would have junked entry "FIFO" in directory PARENT_INO
+
+===== Setting dt=13 to all files:
+core.mode = 0130644
+core.mode = 0130644
+core.mode = 0130644
+core.mode = 0130644
+core.mode = 0130644
+core.mode = 0130644
+core.mode = 0130644
+would have junked entry "BLKDEV" in directory PARENT_INO
+would have junked entry "CHRDEV" in directory PARENT_INO
+would have junked entry "DATA" in directory PARENT_INO
+would have junked entry "DIR" in directory PARENT_INO
+would have junked entry "EMPTY" in directory PARENT_INO
+would have junked entry "FIFO" in directory PARENT_INO
+would have junked entry "SYMLINK" in directory PARENT_INO
+
+===== Setting dt=14 to all files:
+core.mode = 0140644
+core.mode = 0140644
+core.mode = 0140644
+core.mode = 0140644
+core.mode = 0140644
+core.mode = 0140644
+core.mode = 0140644
+would have junked entry "DATA" in directory PARENT_INO
+would have junked entry "DIR" in directory PARENT_INO
+would have junked entry "EMPTY" in directory PARENT_INO
+would have junked entry "SYMLINK" in directory PARENT_INO
+
+===== Setting dt=15 to all files:
+core.mode = 0150644
+core.mode = 0150644
+core.mode = 0150644
+core.mode = 0150644
+core.mode = 0150644
+core.mode = 0150644
+core.mode = 0150644
+would have junked entry "BLKDEV" in directory PARENT_INO
+would have junked entry "CHRDEV" in directory PARENT_INO
+would have junked entry "DATA" in directory PARENT_INO
+would have junked entry "DIR" in directory PARENT_INO
+would have junked entry "EMPTY" in directory PARENT_INO
+would have junked entry "FIFO" in directory PARENT_INO
+would have junked entry "SYMLINK" in directory PARENT_INO
+
+===== Setting dt=16 to all files:
+core.mode = 0160644
+core.mode = 0160644
+core.mode = 0160644
+core.mode = 0160644
+core.mode = 0160644
+core.mode = 0160644
+core.mode = 0160644
+would have junked entry "BLKDEV" in directory PARENT_INO
+would have junked entry "CHRDEV" in directory PARENT_INO
+would have junked entry "DATA" in directory PARENT_INO
+would have junked entry "DIR" in directory PARENT_INO
+would have junked entry "EMPTY" in directory PARENT_INO
+would have junked entry "FIFO" in directory PARENT_INO
+would have junked entry "SYMLINK" in directory PARENT_INO
+
+===== Setting dt=17 to all files:
+core.mode = 0170644
+core.mode = 0170644
+core.mode = 0170644
+core.mode = 0170644
+core.mode = 0170644
+core.mode = 0170644
+core.mode = 0170644
+would have junked entry "BLKDEV" in directory PARENT_INO
+would have junked entry "CHRDEV" in directory PARENT_INO
+would have junked entry "DATA" in directory PARENT_INO
+would have junked entry "DIR" in directory PARENT_INO
+would have junked entry "EMPTY" in directory PARENT_INO
+would have junked entry "FIFO" in directory PARENT_INO
+would have junked entry "SYMLINK" in directory PARENT_INO
diff --git a/tests/xfs/group b/tests/xfs/group
index c237b50..68c2bb6 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -334,3 +334,4 @@
345 auto quick clone
346 auto quick clone
347 auto quick clone
+348 auto quick repair
--
2.7.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v3 2/3] xfs: test fstat with malformed inode mode
2017-01-09 13:30 [PATCH v3 0/3] xfs: test malformed inode mode Amir Goldstein
2017-01-09 13:30 ` [PATCH v3 1/3] xfs: test handling of invalid inode modes Amir Goldstein
@ 2017-01-09 13:30 ` Amir Goldstein
2017-01-09 13:30 ` [PATCH v3 3/3] xfs: test readlink/readdir " Amir Goldstein
2017-01-20 5:25 ` [PATCH v3 0/3] xfs: test " Eryu Guan
3 siblings, 0 replies; 9+ messages in thread
From: Amir Goldstein @ 2017-01-09 13:30 UTC (permalink / raw)
To: Eryu Guan; +Cc: Brian Foster, Darrick J . Wong, fstests, linux-xfs
In addition to testing xfs_repair on inodes with malformed mode,
also test fstat of those inodes on a mounted fs.
This additional test is quite noisy with dmesg warnings, so
check dmesg has been disabled.
This test fails on kernel 4.9 because a zero size inode is not
identified as malformed dir. A patch has been sent to fix this
("xfs: sanity check directory inode di_size").
This test may be merged before the fix patch.
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
tests/xfs/348 | 16 ++++++++
tests/xfs/348.out | 112 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 128 insertions(+)
diff --git a/tests/xfs/348 b/tests/xfs/348
index c5249eb..30825a4 100755
--- a/tests/xfs/348
+++ b/tests/xfs/348
@@ -49,6 +49,10 @@ _supported_fs xfs
_supported_os Linux
_require_scratch
+# This test will corrupt fs intentionally, so there will be WARNINGs
+# in dmesg as expected
+_disable_dmesg_check
+
rm -f $seqres.full
_scratch_mkfs >>$seqres.full 2>&1
@@ -120,6 +124,18 @@ for dt in $dtypes; do
_scratch_xfs_repair -n 2>&1 | grep -q -v "^would fix ftype mismatch" || \
_fail "xfs_repair should not fix ftype mismatch"
fi
+
+ _scratch_mount
+ for file in DIR DATA EMPTY SYMLINK CHRDEV BLKDEV FIFO; do
+ rm -f $tmp.stat.err
+ ftype=$(stat --printf=%F $testdir/$file 2>$tmp.stat.err)
+ if [ -s $tmp.stat.err ]; then
+ cat $tmp.stat.err
+ else
+ echo "stat: '$testdir/$file' is a $ftype"
+ fi | _filter_scratch
+ done
+ _scratch_unmount
done
# Repair should detect and junk all test files
diff --git a/tests/xfs/348.out b/tests/xfs/348.out
index 31cf415..805d530 100644
--- a/tests/xfs/348.out
+++ b/tests/xfs/348.out
@@ -23,6 +23,13 @@ would have junked entry "DIR" in directory PARENT_INO
would have junked entry "EMPTY" in directory PARENT_INO
would have junked entry "FIFO" in directory PARENT_INO
would have junked entry "SYMLINK" in directory PARENT_INO
+stat: cannot stat 'SCRATCH_MNT/test/DIR': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/DATA': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/EMPTY': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/SYMLINK': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/CHRDEV': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/BLKDEV': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/FIFO': Structure needs cleaning
===== Setting dt=1 to all files:
core.mode = 010644
@@ -36,6 +43,13 @@ would have junked entry "DATA" in directory PARENT_INO
would have junked entry "DIR" in directory PARENT_INO
would have junked entry "EMPTY" in directory PARENT_INO
would have junked entry "SYMLINK" in directory PARENT_INO
+stat: cannot stat 'SCRATCH_MNT/test/DIR': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/DATA': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/EMPTY': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/SYMLINK': Structure needs cleaning
+stat: 'SCRATCH_MNT/test/CHRDEV' is a fifo
+stat: 'SCRATCH_MNT/test/BLKDEV' is a fifo
+stat: 'SCRATCH_MNT/test/FIFO' is a fifo
===== Setting dt=2 to all files:
core.mode = 020644
@@ -49,6 +63,13 @@ would have junked entry "DATA" in directory PARENT_INO
would have junked entry "DIR" in directory PARENT_INO
would have junked entry "EMPTY" in directory PARENT_INO
would have junked entry "SYMLINK" in directory PARENT_INO
+stat: cannot stat 'SCRATCH_MNT/test/DIR': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/DATA': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/EMPTY': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/SYMLINK': Structure needs cleaning
+stat: 'SCRATCH_MNT/test/CHRDEV' is a character special file
+stat: 'SCRATCH_MNT/test/BLKDEV' is a character special file
+stat: 'SCRATCH_MNT/test/FIFO' is a character special file
===== Setting dt=3 to all files:
core.mode = 030644
@@ -65,6 +86,13 @@ would have junked entry "DIR" in directory PARENT_INO
would have junked entry "EMPTY" in directory PARENT_INO
would have junked entry "FIFO" in directory PARENT_INO
would have junked entry "SYMLINK" in directory PARENT_INO
+stat: cannot stat 'SCRATCH_MNT/test/DIR': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/DATA': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/EMPTY': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/SYMLINK': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/CHRDEV': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/BLKDEV': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/FIFO': Structure needs cleaning
===== Setting dt=4 to all files:
core.mode = 040644
@@ -79,6 +107,13 @@ would have junked entry "CHRDEV" in directory PARENT_INO
would have junked entry "DATA" in directory PARENT_INO
would have junked entry "EMPTY" in directory PARENT_INO
would have junked entry "FIFO" in directory PARENT_INO
+stat: 'SCRATCH_MNT/test/DIR' is a directory
+stat: 'SCRATCH_MNT/test/DATA' is a directory
+stat: cannot stat 'SCRATCH_MNT/test/EMPTY': Structure needs cleaning
+stat: 'SCRATCH_MNT/test/SYMLINK' is a directory
+stat: cannot stat 'SCRATCH_MNT/test/CHRDEV': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/BLKDEV': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/FIFO': Structure needs cleaning
===== Setting dt=5 to all files:
core.mode = 050644
@@ -95,6 +130,13 @@ would have junked entry "DIR" in directory PARENT_INO
would have junked entry "EMPTY" in directory PARENT_INO
would have junked entry "FIFO" in directory PARENT_INO
would have junked entry "SYMLINK" in directory PARENT_INO
+stat: cannot stat 'SCRATCH_MNT/test/DIR': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/DATA': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/EMPTY': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/SYMLINK': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/CHRDEV': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/BLKDEV': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/FIFO': Structure needs cleaning
===== Setting dt=6 to all files:
core.mode = 060644
@@ -108,6 +150,13 @@ would have junked entry "DATA" in directory PARENT_INO
would have junked entry "DIR" in directory PARENT_INO
would have junked entry "EMPTY" in directory PARENT_INO
would have junked entry "SYMLINK" in directory PARENT_INO
+stat: cannot stat 'SCRATCH_MNT/test/DIR': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/DATA': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/EMPTY': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/SYMLINK': Structure needs cleaning
+stat: 'SCRATCH_MNT/test/CHRDEV' is a block special file
+stat: 'SCRATCH_MNT/test/BLKDEV' is a block special file
+stat: 'SCRATCH_MNT/test/FIFO' is a block special file
===== Setting dt=7 to all files:
core.mode = 070644
@@ -124,6 +173,13 @@ would have junked entry "DIR" in directory PARENT_INO
would have junked entry "EMPTY" in directory PARENT_INO
would have junked entry "FIFO" in directory PARENT_INO
would have junked entry "SYMLINK" in directory PARENT_INO
+stat: cannot stat 'SCRATCH_MNT/test/DIR': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/DATA': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/EMPTY': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/SYMLINK': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/CHRDEV': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/BLKDEV': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/FIFO': Structure needs cleaning
===== Setting dt=10 to all files:
core.mode = 0100644
@@ -138,6 +194,13 @@ would have junked entry "CHRDEV" in directory PARENT_INO
would have junked entry "DIR" in directory PARENT_INO
would have junked entry "FIFO" in directory PARENT_INO
would have junked entry "SYMLINK" in directory PARENT_INO
+stat: cannot stat 'SCRATCH_MNT/test/DIR': Structure needs cleaning
+stat: 'SCRATCH_MNT/test/DATA' is a regular file
+stat: 'SCRATCH_MNT/test/EMPTY' is a regular empty file
+stat: cannot stat 'SCRATCH_MNT/test/SYMLINK': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/CHRDEV': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/BLKDEV': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/FIFO': Structure needs cleaning
===== Setting dt=11 to all files:
core.mode = 0110644
@@ -154,6 +217,13 @@ would have junked entry "DIR" in directory PARENT_INO
would have junked entry "EMPTY" in directory PARENT_INO
would have junked entry "FIFO" in directory PARENT_INO
would have junked entry "SYMLINK" in directory PARENT_INO
+stat: cannot stat 'SCRATCH_MNT/test/DIR': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/DATA': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/EMPTY': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/SYMLINK': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/CHRDEV': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/BLKDEV': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/FIFO': Structure needs cleaning
===== Setting dt=12 to all files:
core.mode = 0120644
@@ -169,6 +239,13 @@ would have junked entry "DATA" in directory PARENT_INO
would have junked entry "DIR" in directory PARENT_INO
would have junked entry "EMPTY" in directory PARENT_INO
would have junked entry "FIFO" in directory PARENT_INO
+stat: 'SCRATCH_MNT/test/DIR' is a symbolic link
+stat: 'SCRATCH_MNT/test/DATA' is a symbolic link
+stat: cannot stat 'SCRATCH_MNT/test/EMPTY': Structure needs cleaning
+stat: 'SCRATCH_MNT/test/SYMLINK' is a symbolic link
+stat: cannot stat 'SCRATCH_MNT/test/CHRDEV': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/BLKDEV': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/FIFO': Structure needs cleaning
===== Setting dt=13 to all files:
core.mode = 0130644
@@ -185,6 +262,13 @@ would have junked entry "DIR" in directory PARENT_INO
would have junked entry "EMPTY" in directory PARENT_INO
would have junked entry "FIFO" in directory PARENT_INO
would have junked entry "SYMLINK" in directory PARENT_INO
+stat: cannot stat 'SCRATCH_MNT/test/DIR': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/DATA': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/EMPTY': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/SYMLINK': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/CHRDEV': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/BLKDEV': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/FIFO': Structure needs cleaning
===== Setting dt=14 to all files:
core.mode = 0140644
@@ -198,6 +282,13 @@ would have junked entry "DATA" in directory PARENT_INO
would have junked entry "DIR" in directory PARENT_INO
would have junked entry "EMPTY" in directory PARENT_INO
would have junked entry "SYMLINK" in directory PARENT_INO
+stat: cannot stat 'SCRATCH_MNT/test/DIR': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/DATA': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/EMPTY': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/SYMLINK': Structure needs cleaning
+stat: 'SCRATCH_MNT/test/CHRDEV' is a socket
+stat: 'SCRATCH_MNT/test/BLKDEV' is a socket
+stat: 'SCRATCH_MNT/test/FIFO' is a socket
===== Setting dt=15 to all files:
core.mode = 0150644
@@ -214,6 +305,13 @@ would have junked entry "DIR" in directory PARENT_INO
would have junked entry "EMPTY" in directory PARENT_INO
would have junked entry "FIFO" in directory PARENT_INO
would have junked entry "SYMLINK" in directory PARENT_INO
+stat: cannot stat 'SCRATCH_MNT/test/DIR': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/DATA': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/EMPTY': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/SYMLINK': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/CHRDEV': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/BLKDEV': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/FIFO': Structure needs cleaning
===== Setting dt=16 to all files:
core.mode = 0160644
@@ -230,6 +328,13 @@ would have junked entry "DIR" in directory PARENT_INO
would have junked entry "EMPTY" in directory PARENT_INO
would have junked entry "FIFO" in directory PARENT_INO
would have junked entry "SYMLINK" in directory PARENT_INO
+stat: cannot stat 'SCRATCH_MNT/test/DIR': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/DATA': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/EMPTY': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/SYMLINK': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/CHRDEV': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/BLKDEV': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/FIFO': Structure needs cleaning
===== Setting dt=17 to all files:
core.mode = 0170644
@@ -246,3 +351,10 @@ would have junked entry "DIR" in directory PARENT_INO
would have junked entry "EMPTY" in directory PARENT_INO
would have junked entry "FIFO" in directory PARENT_INO
would have junked entry "SYMLINK" in directory PARENT_INO
+stat: cannot stat 'SCRATCH_MNT/test/DIR': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/DATA': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/EMPTY': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/SYMLINK': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/CHRDEV': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/BLKDEV': Structure needs cleaning
+stat: cannot stat 'SCRATCH_MNT/test/FIFO': Structure needs cleaning
--
2.7.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v3 3/3] xfs: test readlink/readdir with malformed inode mode
2017-01-09 13:30 [PATCH v3 0/3] xfs: test malformed inode mode Amir Goldstein
2017-01-09 13:30 ` [PATCH v3 1/3] xfs: test handling of invalid inode modes Amir Goldstein
2017-01-09 13:30 ` [PATCH v3 2/3] xfs: test fstat with malformed inode mode Amir Goldstein
@ 2017-01-09 13:30 ` Amir Goldstein
2017-01-11 6:38 ` Amir Goldstein
2017-01-11 6:41 ` Amir Goldstein
2017-01-20 5:25 ` [PATCH v3 0/3] xfs: test " Eryu Guan
3 siblings, 2 replies; 9+ messages in thread
From: Amir Goldstein @ 2017-01-09 13:30 UTC (permalink / raw)
To: Eryu Guan; +Cc: Brian Foster, Darrick J . Wong, fstests, linux-xfs
In addition to testing xfs_repair on inodes with malformed mode,
and fstat of those inodes on a mounted fs, try to also list content
of mock directory and readlink of mock symlink.
Readdir of mock directory triggers XFS assertion on kernel 4.9 with
XFS_DEBUG=y
XFS: Assertion failed:
rval == 0 || args->dp->i_d.di_size == args->geo->blksize,
file: /home/amir/build/src/linux/fs/xfs/libxfs/xfs_dir2.c, line: 634
A fix patch, as suggested by Darrick, changes this ASSERT() to
return -EFSCORRUPTED ("xfs: sanity check directory inode di_size").
Merging this test should be deferred to after fix patch is merged.
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
tests/xfs/348 | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/tests/xfs/348 b/tests/xfs/348
index 30825a4..20d5d7e 100755
--- a/tests/xfs/348
+++ b/tests/xfs/348
@@ -133,6 +133,15 @@ for dt in $dtypes; do
cat $tmp.stat.err
else
echo "stat: '$testdir/$file' is a $ftype"
+ # Verify that readlink of a file posing as a symlink
+ # and ls of a file posing as a directory does not blow up.
+ # NOTE that ls DOES ASSERT with kernel 4.9 and XFS_DEBUG=y
+ # on malformed directory
+ if [ -d $testdir/$file ]; then
+ ls "$safety" $testdir/$file &> /dev/null
+ elif [ -h $testdir/$file ]; then
+ readlink $testdir/$file &> /dev/null
+ fi
fi | _filter_scratch
done
_scratch_unmount
--
2.7.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v3 1/3] xfs: test handling of invalid inode modes
2017-01-09 13:30 ` [PATCH v3 1/3] xfs: test handling of invalid inode modes Amir Goldstein
@ 2017-01-09 13:36 ` Amir Goldstein
2017-01-09 13:39 ` Amir Goldstein
1 sibling, 0 replies; 9+ messages in thread
From: Amir Goldstein @ 2017-01-09 13:36 UTC (permalink / raw)
To: Eryu Guan; +Cc: Brian Foster, Darrick J . Wong, fstests, linux-xfs
On Mon, Jan 9, 2017 at 3:30 PM, Amir Goldstein <amir73il@gmail.com> wrote:
> Set all possible file type values for different types of files
> and verify that xfs_repair detects the correct errors.
>
> When setting invalid file type values (e.g. core.mode = 0170644),
> all files are expected to have been junked by xfs_repair.
>
> When setting valid file type values to non matching file types,
> xfs_repair would either detect wrong format and junk the file, e.g.:
> would have junked entry "DATA" in directory PARENT_INO
> or detect a ftype mismatch error, e.g.:
> would fix ftype mismatch (5/3) in directory/child PARENT_INO/FIFO_INO
>
> If ftype feature is enabled, when setting file type to one of the
> special types (i.e. FIFO(1), CHRDEV(2),BLKDEV(6),SOCKET(14)),
> xfs_repair is expected to detect ftype mismatch error. Otherwise,
> xfs_repair is not expected to detect ftype mismatch error.
>
> Signed-off-by: Amir Goldstein <amir73il@gmail.com>
> ---
> tests/xfs/348 | 129 ++++++++++++++++++++++++++++
> tests/xfs/348.out | 248 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
> tests/xfs/group | 1 +
> 3 files changed, 378 insertions(+)
> create mode 100755 tests/xfs/348
> create mode 100644 tests/xfs/348.out
>
> diff --git a/tests/xfs/348 b/tests/xfs/348
> new file mode 100755
> index 0000000..c5249eb
> --- /dev/null
> +++ b/tests/xfs/348
> @@ -0,0 +1,129 @@
> +#! /bin/bash
> +# FSQA Test No. 348
> +#
> +# Test handling of invalid inode modes
> +#
> +# Set all possible file type values for different types of files
> +# and verify that xfs_repair detects the correct errors.
> +#
> +#-----------------------------------------------------------------------
> +#
> +# Copyright (C) 2016 CTERA Networks. All Rights Reserved.
> +# Author: Amir Goldstein <amir73il@gmail.com>
> +#
> +# 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"
> +
> +tmp=/tmp/$$
> +status=1 # failure is the default!
> +trap "_cleanup; exit \$status" 0 1 2 3 15
> +
> +_cleanup()
> +{
> + rm -f $tmp.*
> +}
> +
> +# get standard environment, filters and checks
> +. ./common/rc
> +. ./common/filter
> +. ./common/repair
> +
> +# real QA test starts here
> +_supported_fs xfs
> +_supported_os Linux
> +_require_scratch
> +
> +rm -f $seqres.full
> +
> +_scratch_mkfs >>$seqres.full 2>&1
> +
> +_scratch_mount
> +
> +# Create our test files.
> +testdir=$SCRATCH_MNT/test
> +mkdir -p $testdir
> +mkdir $testdir/DIR
> +echo 123 > $testdir/DATA
> +touch $testdir/EMPTY
> +ln -s $testdir/DATA $testdir/SYMLINK
> +mknod $testdir/CHRDEV c 1 1
> +mknod $testdir/BLKDEV b 1 1
> +mknod $testdir/FIFO p
> +
> +xfs_info $SCRATCH_MNT | grep -q "ftype=1" && FTYPE_FEATURE=1
> +
> +# Record test dir inode for xfs_repair filter
> +inode_filter=$tmp.sed
> +rm -f $inode_filter
> +pino=$(ls -id $testdir | awk '{print $1}')
> +echo "s/inode $pino/PARENT_INO/" >> $inode_filter
> +echo "s/directory $pino/directory PARENT_INO/" >> $inode_filter
> +
> +inodes=""
> +# Record inode numbers for xfs_db commands and xfs_repair filter
> +for f in DIR DATA EMPTY SYMLINK CHRDEV BLKDEV FIFO; do
> + ino=$(ls -id $testdir/$f | awk '{print $1}')
> + inodes="$inodes $ino"
> + echo "s/inode $ino/${f}_INO/" >> $inode_filter
> +done
> +
> +_scratch_unmount
> +
> +# Possible mode file type values (mode & S_IFMT) >> 12
> +dtypes="0 1 2 3 4 5 6 7 10 11 12 13 14 15 16 17"
> +echo "===== Find inode by file type:"
> +for dt in $dtypes; do
> + # Set all our test files to dt value
> + for ino in $inodes; do
> + _scratch_xfs_db -c "inode $ino" -c "print core.mode" | \
> + grep -q "0${dt}0...$" && \
> + (echo "dt=$dt => inode $ino" | sed -f $inode_filter)
> + done
> +done
> +for dt in $dtypes; do
> + echo
> + echo "===== Setting dt=$dt to all files:"
> + # Set all our test files to dt value
> + for ino in $inodes; do
> + _scratch_xfs_db -x -c "inode $ino" -c "write core.mode 0${dt}0644"
> + done
> + # Repair should detect the inconsistencies
> + # For invalid dt values, all files would have been junked.
> + # For valid dt values, one test file is expected to be valid.
> + # The rest would either have wrong format or non matching dir ftype.
> + _scratch_xfs_repair -n 2>&1 | tee -a $seqres.full | \
> + _filter_repair | grep "^would have junked" | sed -f $inode_filter | sort -u
> + # If ftype feature is enabled, when setting file type to one of the
> + # special types (i.e. FIFO(1), CHRDEV(2),BLKDEV(6),SOCKET(14)),
> + # xfs_repair is expected to detect ftype mismatch error. Otherewise,
> + # xfs_repair is not expected to detect ftype mismatch error.
> + if [ "$FTYPE_FEATURE" = 1 ] && (echo ':1:2:6:14:' | grep -q ":$dt:"); then
> + _scratch_xfs_repair -n 2>&1 | grep -q "^would fix ftype mismatch" || \
> + _fail "xfs_repair should fix ftype mismatch"
oops forgot to replace _fail with echo
re-sending...
> + else
> + _scratch_xfs_repair -n 2>&1 | grep -q -v "^would fix ftype mismatch" || \
> + _fail "xfs_repair should not fix ftype mismatch"
> + fi
> +done
> +
> +# Repair should detect and junk all test files
> +_scratch_xfs_repair 2>&1 >> $seqres.full 2>&1 || _fail "xfs_repair should not fail"
> +
> +status=0
> +exit
> diff --git a/tests/xfs/348.out b/tests/xfs/348.out
> new file mode 100644
> index 0000000..31cf415
> --- /dev/null
> +++ b/tests/xfs/348.out
> @@ -0,0 +1,248 @@
> +QA output created by 348
> +===== Find inode by file type:
> +dt=1 => FIFO_INO
> +dt=2 => CHRDEV_INO
> +dt=4 => DIR_INO
> +dt=6 => BLKDEV_INO
> +dt=10 => DATA_INO
> +dt=10 => EMPTY_INO
> +dt=12 => SYMLINK_INO
> +
> +===== Setting dt=0 to all files:
> +core.mode = 0644
> +core.mode = 0644
> +core.mode = 0644
> +core.mode = 0644
> +core.mode = 0644
> +core.mode = 0644
> +core.mode = 0644
> +would have junked entry "BLKDEV" in directory PARENT_INO
> +would have junked entry "CHRDEV" in directory PARENT_INO
> +would have junked entry "DATA" in directory PARENT_INO
> +would have junked entry "DIR" in directory PARENT_INO
> +would have junked entry "EMPTY" in directory PARENT_INO
> +would have junked entry "FIFO" in directory PARENT_INO
> +would have junked entry "SYMLINK" in directory PARENT_INO
> +
> +===== Setting dt=1 to all files:
> +core.mode = 010644
> +core.mode = 010644
> +core.mode = 010644
> +core.mode = 010644
> +core.mode = 010644
> +core.mode = 010644
> +core.mode = 010644
> +would have junked entry "DATA" in directory PARENT_INO
> +would have junked entry "DIR" in directory PARENT_INO
> +would have junked entry "EMPTY" in directory PARENT_INO
> +would have junked entry "SYMLINK" in directory PARENT_INO
> +
> +===== Setting dt=2 to all files:
> +core.mode = 020644
> +core.mode = 020644
> +core.mode = 020644
> +core.mode = 020644
> +core.mode = 020644
> +core.mode = 020644
> +core.mode = 020644
> +would have junked entry "DATA" in directory PARENT_INO
> +would have junked entry "DIR" in directory PARENT_INO
> +would have junked entry "EMPTY" in directory PARENT_INO
> +would have junked entry "SYMLINK" in directory PARENT_INO
> +
> +===== Setting dt=3 to all files:
> +core.mode = 030644
> +core.mode = 030644
> +core.mode = 030644
> +core.mode = 030644
> +core.mode = 030644
> +core.mode = 030644
> +core.mode = 030644
> +would have junked entry "BLKDEV" in directory PARENT_INO
> +would have junked entry "CHRDEV" in directory PARENT_INO
> +would have junked entry "DATA" in directory PARENT_INO
> +would have junked entry "DIR" in directory PARENT_INO
> +would have junked entry "EMPTY" in directory PARENT_INO
> +would have junked entry "FIFO" in directory PARENT_INO
> +would have junked entry "SYMLINK" in directory PARENT_INO
> +
> +===== Setting dt=4 to all files:
> +core.mode = 040644
> +core.mode = 040644
> +core.mode = 040644
> +core.mode = 040644
> +core.mode = 040644
> +core.mode = 040644
> +core.mode = 040644
> +would have junked entry "BLKDEV" in directory PARENT_INO
> +would have junked entry "CHRDEV" in directory PARENT_INO
> +would have junked entry "DATA" in directory PARENT_INO
> +would have junked entry "EMPTY" in directory PARENT_INO
> +would have junked entry "FIFO" in directory PARENT_INO
> +
> +===== Setting dt=5 to all files:
> +core.mode = 050644
> +core.mode = 050644
> +core.mode = 050644
> +core.mode = 050644
> +core.mode = 050644
> +core.mode = 050644
> +core.mode = 050644
> +would have junked entry "BLKDEV" in directory PARENT_INO
> +would have junked entry "CHRDEV" in directory PARENT_INO
> +would have junked entry "DATA" in directory PARENT_INO
> +would have junked entry "DIR" in directory PARENT_INO
> +would have junked entry "EMPTY" in directory PARENT_INO
> +would have junked entry "FIFO" in directory PARENT_INO
> +would have junked entry "SYMLINK" in directory PARENT_INO
> +
> +===== Setting dt=6 to all files:
> +core.mode = 060644
> +core.mode = 060644
> +core.mode = 060644
> +core.mode = 060644
> +core.mode = 060644
> +core.mode = 060644
> +core.mode = 060644
> +would have junked entry "DATA" in directory PARENT_INO
> +would have junked entry "DIR" in directory PARENT_INO
> +would have junked entry "EMPTY" in directory PARENT_INO
> +would have junked entry "SYMLINK" in directory PARENT_INO
> +
> +===== Setting dt=7 to all files:
> +core.mode = 070644
> +core.mode = 070644
> +core.mode = 070644
> +core.mode = 070644
> +core.mode = 070644
> +core.mode = 070644
> +core.mode = 070644
> +would have junked entry "BLKDEV" in directory PARENT_INO
> +would have junked entry "CHRDEV" in directory PARENT_INO
> +would have junked entry "DATA" in directory PARENT_INO
> +would have junked entry "DIR" in directory PARENT_INO
> +would have junked entry "EMPTY" in directory PARENT_INO
> +would have junked entry "FIFO" in directory PARENT_INO
> +would have junked entry "SYMLINK" in directory PARENT_INO
> +
> +===== Setting dt=10 to all files:
> +core.mode = 0100644
> +core.mode = 0100644
> +core.mode = 0100644
> +core.mode = 0100644
> +core.mode = 0100644
> +core.mode = 0100644
> +core.mode = 0100644
> +would have junked entry "BLKDEV" in directory PARENT_INO
> +would have junked entry "CHRDEV" in directory PARENT_INO
> +would have junked entry "DIR" in directory PARENT_INO
> +would have junked entry "FIFO" in directory PARENT_INO
> +would have junked entry "SYMLINK" in directory PARENT_INO
> +
> +===== Setting dt=11 to all files:
> +core.mode = 0110644
> +core.mode = 0110644
> +core.mode = 0110644
> +core.mode = 0110644
> +core.mode = 0110644
> +core.mode = 0110644
> +core.mode = 0110644
> +would have junked entry "BLKDEV" in directory PARENT_INO
> +would have junked entry "CHRDEV" in directory PARENT_INO
> +would have junked entry "DATA" in directory PARENT_INO
> +would have junked entry "DIR" in directory PARENT_INO
> +would have junked entry "EMPTY" in directory PARENT_INO
> +would have junked entry "FIFO" in directory PARENT_INO
> +would have junked entry "SYMLINK" in directory PARENT_INO
> +
> +===== Setting dt=12 to all files:
> +core.mode = 0120644
> +core.mode = 0120644
> +core.mode = 0120644
> +core.mode = 0120644
> +core.mode = 0120644
> +core.mode = 0120644
> +core.mode = 0120644
> +would have junked entry "BLKDEV" in directory PARENT_INO
> +would have junked entry "CHRDEV" in directory PARENT_INO
> +would have junked entry "DATA" in directory PARENT_INO
> +would have junked entry "DIR" in directory PARENT_INO
> +would have junked entry "EMPTY" in directory PARENT_INO
> +would have junked entry "FIFO" in directory PARENT_INO
> +
> +===== Setting dt=13 to all files:
> +core.mode = 0130644
> +core.mode = 0130644
> +core.mode = 0130644
> +core.mode = 0130644
> +core.mode = 0130644
> +core.mode = 0130644
> +core.mode = 0130644
> +would have junked entry "BLKDEV" in directory PARENT_INO
> +would have junked entry "CHRDEV" in directory PARENT_INO
> +would have junked entry "DATA" in directory PARENT_INO
> +would have junked entry "DIR" in directory PARENT_INO
> +would have junked entry "EMPTY" in directory PARENT_INO
> +would have junked entry "FIFO" in directory PARENT_INO
> +would have junked entry "SYMLINK" in directory PARENT_INO
> +
> +===== Setting dt=14 to all files:
> +core.mode = 0140644
> +core.mode = 0140644
> +core.mode = 0140644
> +core.mode = 0140644
> +core.mode = 0140644
> +core.mode = 0140644
> +core.mode = 0140644
> +would have junked entry "DATA" in directory PARENT_INO
> +would have junked entry "DIR" in directory PARENT_INO
> +would have junked entry "EMPTY" in directory PARENT_INO
> +would have junked entry "SYMLINK" in directory PARENT_INO
> +
> +===== Setting dt=15 to all files:
> +core.mode = 0150644
> +core.mode = 0150644
> +core.mode = 0150644
> +core.mode = 0150644
> +core.mode = 0150644
> +core.mode = 0150644
> +core.mode = 0150644
> +would have junked entry "BLKDEV" in directory PARENT_INO
> +would have junked entry "CHRDEV" in directory PARENT_INO
> +would have junked entry "DATA" in directory PARENT_INO
> +would have junked entry "DIR" in directory PARENT_INO
> +would have junked entry "EMPTY" in directory PARENT_INO
> +would have junked entry "FIFO" in directory PARENT_INO
> +would have junked entry "SYMLINK" in directory PARENT_INO
> +
> +===== Setting dt=16 to all files:
> +core.mode = 0160644
> +core.mode = 0160644
> +core.mode = 0160644
> +core.mode = 0160644
> +core.mode = 0160644
> +core.mode = 0160644
> +core.mode = 0160644
> +would have junked entry "BLKDEV" in directory PARENT_INO
> +would have junked entry "CHRDEV" in directory PARENT_INO
> +would have junked entry "DATA" in directory PARENT_INO
> +would have junked entry "DIR" in directory PARENT_INO
> +would have junked entry "EMPTY" in directory PARENT_INO
> +would have junked entry "FIFO" in directory PARENT_INO
> +would have junked entry "SYMLINK" in directory PARENT_INO
> +
> +===== Setting dt=17 to all files:
> +core.mode = 0170644
> +core.mode = 0170644
> +core.mode = 0170644
> +core.mode = 0170644
> +core.mode = 0170644
> +core.mode = 0170644
> +core.mode = 0170644
> +would have junked entry "BLKDEV" in directory PARENT_INO
> +would have junked entry "CHRDEV" in directory PARENT_INO
> +would have junked entry "DATA" in directory PARENT_INO
> +would have junked entry "DIR" in directory PARENT_INO
> +would have junked entry "EMPTY" in directory PARENT_INO
> +would have junked entry "FIFO" in directory PARENT_INO
> +would have junked entry "SYMLINK" in directory PARENT_INO
> diff --git a/tests/xfs/group b/tests/xfs/group
> index c237b50..68c2bb6 100644
> --- a/tests/xfs/group
> +++ b/tests/xfs/group
> @@ -334,3 +334,4 @@
> 345 auto quick clone
> 346 auto quick clone
> 347 auto quick clone
> +348 auto quick repair
> --
> 2.7.4
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v3 1/3] xfs: test handling of invalid inode modes
2017-01-09 13:30 ` [PATCH v3 1/3] xfs: test handling of invalid inode modes Amir Goldstein
2017-01-09 13:36 ` Amir Goldstein
@ 2017-01-09 13:39 ` Amir Goldstein
1 sibling, 0 replies; 9+ messages in thread
From: Amir Goldstein @ 2017-01-09 13:39 UTC (permalink / raw)
To: Eryu Guan; +Cc: Brian Foster, Darrick J . Wong, fstests, linux-xfs
Set all possible file type values for different types of files
and verify that xfs_repair detects the correct errors.
When setting invalid file type values (e.g. core.mode = 0170644),
all files are expected to have been junked by xfs_repair.
When setting valid file type values to non matching file types,
xfs_repair would either detect wrong format and junk the file, e.g.:
would have junked entry "DATA" in directory PARENT_INO
or detect a ftype mismatch error, e.g.:
would fix ftype mismatch (5/3) in directory/child PARENT_INO/FIFO_INO
If ftype feature is enabled, when setting file type to one of the
special types (i.e. FIFO(1), CHRDEV(2),BLKDEV(6),SOCKET(14)),
xfs_repair is expected to detect ftype mismatch error. Otherwise,
xfs_repair is not expected to detect ftype mismatch error.
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
tests/xfs/348 | 129 ++++++++++++++++++++++++++++
tests/xfs/348.out | 248 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/xfs/group | 1 +
3 files changed, 378 insertions(+)
create mode 100755 tests/xfs/348
create mode 100644 tests/xfs/348.out
diff --git a/tests/xfs/348 b/tests/xfs/348
new file mode 100755
index 0000000..c5249eb
--- /dev/null
+++ b/tests/xfs/348
@@ -0,0 +1,129 @@
+#! /bin/bash
+# FSQA Test No. 348
+#
+# Test handling of invalid inode modes
+#
+# Set all possible file type values for different types of files
+# and verify that xfs_repair detects the correct errors.
+#
+#-----------------------------------------------------------------------
+#
+# Copyright (C) 2016 CTERA Networks. All Rights Reserved.
+# Author: Amir Goldstein <amir73il@gmail.com>
+#
+# 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"
+
+tmp=/tmp/$$
+status=1 # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+ rm -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/repair
+
+# real QA test starts here
+_supported_fs xfs
+_supported_os Linux
+_require_scratch
+
+rm -f $seqres.full
+
+_scratch_mkfs >>$seqres.full 2>&1
+
+_scratch_mount
+
+# Create our test files.
+testdir=$SCRATCH_MNT/test
+mkdir -p $testdir
+mkdir $testdir/DIR
+echo 123 > $testdir/DATA
+touch $testdir/EMPTY
+ln -s $testdir/DATA $testdir/SYMLINK
+mknod $testdir/CHRDEV c 1 1
+mknod $testdir/BLKDEV b 1 1
+mknod $testdir/FIFO p
+
+xfs_info $SCRATCH_MNT | grep -q "ftype=1" && FTYPE_FEATURE=1
+
+# Record test dir inode for xfs_repair filter
+inode_filter=$tmp.sed
+rm -f $inode_filter
+pino=$(ls -id $testdir | awk '{print $1}')
+echo "s/inode $pino/PARENT_INO/" >> $inode_filter
+echo "s/directory $pino/directory PARENT_INO/" >> $inode_filter
+
+inodes=""
+# Record inode numbers for xfs_db commands and xfs_repair filter
+for f in DIR DATA EMPTY SYMLINK CHRDEV BLKDEV FIFO; do
+ ino=$(ls -id $testdir/$f | awk '{print $1}')
+ inodes="$inodes $ino"
+ echo "s/inode $ino/${f}_INO/" >> $inode_filter
+done
+
+_scratch_unmount
+
+# Possible mode file type values (mode & S_IFMT) >> 12
+dtypes="0 1 2 3 4 5 6 7 10 11 12 13 14 15 16 17"
+echo "===== Find inode by file type:"
+for dt in $dtypes; do
+ # Set all our test files to dt value
+ for ino in $inodes; do
+ _scratch_xfs_db -c "inode $ino" -c "print core.mode" | \
+ grep -q "0${dt}0...$" && \
+ (echo "dt=$dt => inode $ino" | sed -f $inode_filter)
+ done
+done
+for dt in $dtypes; do
+ echo
+ echo "===== Setting dt=$dt to all files:"
+ # Set all our test files to dt value
+ for ino in $inodes; do
+ _scratch_xfs_db -x -c "inode $ino" -c "write core.mode 0${dt}0644"
+ done
+ # Repair should detect the inconsistencies
+ # For invalid dt values, all files would have been junked.
+ # For valid dt values, one test file is expected to be valid.
+ # The rest would either have wrong format or non matching dir ftype.
+ _scratch_xfs_repair -n 2>&1 | tee -a $seqres.full | \
+ _filter_repair | grep "^would have junked" | sed -f $inode_filter | sort -u
+ # If ftype feature is enabled, when setting file type to one of the
+ # special types (i.e. FIFO(1), CHRDEV(2),BLKDEV(6),SOCKET(14)),
+ # xfs_repair is expected to detect ftype mismatch error. Otherewise,
+ # xfs_repair is not expected to detect ftype mismatch error.
+ if [ "$FTYPE_FEATURE" = 1 ] && (echo ':1:2:6:14:' | grep -q ":$dt:"); then
+ _scratch_xfs_repair -n 2>&1 | grep -q "^would fix ftype mismatch" || \
+ echo "xfs_repair should fix ftype mismatch"
+ else
+ _scratch_xfs_repair -n 2>&1 | grep -q -v "^would fix ftype mismatch" || \
+ echo "xfs_repair should not fix ftype mismatch"
+ fi
+done
+
+# Repair should detect and junk all test files
+_scratch_xfs_repair 2>&1 >> $seqres.full 2>&1 || _fail "xfs_repair should not fail"
+
+status=0
+exit
diff --git a/tests/xfs/348.out b/tests/xfs/348.out
new file mode 100644
index 0000000..31cf415
--- /dev/null
+++ b/tests/xfs/348.out
@@ -0,0 +1,248 @@
+QA output created by 348
+===== Find inode by file type:
+dt=1 => FIFO_INO
+dt=2 => CHRDEV_INO
+dt=4 => DIR_INO
+dt=6 => BLKDEV_INO
+dt=10 => DATA_INO
+dt=10 => EMPTY_INO
+dt=12 => SYMLINK_INO
+
+===== Setting dt=0 to all files:
+core.mode = 0644
+core.mode = 0644
+core.mode = 0644
+core.mode = 0644
+core.mode = 0644
+core.mode = 0644
+core.mode = 0644
+would have junked entry "BLKDEV" in directory PARENT_INO
+would have junked entry "CHRDEV" in directory PARENT_INO
+would have junked entry "DATA" in directory PARENT_INO
+would have junked entry "DIR" in directory PARENT_INO
+would have junked entry "EMPTY" in directory PARENT_INO
+would have junked entry "FIFO" in directory PARENT_INO
+would have junked entry "SYMLINK" in directory PARENT_INO
+
+===== Setting dt=1 to all files:
+core.mode = 010644
+core.mode = 010644
+core.mode = 010644
+core.mode = 010644
+core.mode = 010644
+core.mode = 010644
+core.mode = 010644
+would have junked entry "DATA" in directory PARENT_INO
+would have junked entry "DIR" in directory PARENT_INO
+would have junked entry "EMPTY" in directory PARENT_INO
+would have junked entry "SYMLINK" in directory PARENT_INO
+
+===== Setting dt=2 to all files:
+core.mode = 020644
+core.mode = 020644
+core.mode = 020644
+core.mode = 020644
+core.mode = 020644
+core.mode = 020644
+core.mode = 020644
+would have junked entry "DATA" in directory PARENT_INO
+would have junked entry "DIR" in directory PARENT_INO
+would have junked entry "EMPTY" in directory PARENT_INO
+would have junked entry "SYMLINK" in directory PARENT_INO
+
+===== Setting dt=3 to all files:
+core.mode = 030644
+core.mode = 030644
+core.mode = 030644
+core.mode = 030644
+core.mode = 030644
+core.mode = 030644
+core.mode = 030644
+would have junked entry "BLKDEV" in directory PARENT_INO
+would have junked entry "CHRDEV" in directory PARENT_INO
+would have junked entry "DATA" in directory PARENT_INO
+would have junked entry "DIR" in directory PARENT_INO
+would have junked entry "EMPTY" in directory PARENT_INO
+would have junked entry "FIFO" in directory PARENT_INO
+would have junked entry "SYMLINK" in directory PARENT_INO
+
+===== Setting dt=4 to all files:
+core.mode = 040644
+core.mode = 040644
+core.mode = 040644
+core.mode = 040644
+core.mode = 040644
+core.mode = 040644
+core.mode = 040644
+would have junked entry "BLKDEV" in directory PARENT_INO
+would have junked entry "CHRDEV" in directory PARENT_INO
+would have junked entry "DATA" in directory PARENT_INO
+would have junked entry "EMPTY" in directory PARENT_INO
+would have junked entry "FIFO" in directory PARENT_INO
+
+===== Setting dt=5 to all files:
+core.mode = 050644
+core.mode = 050644
+core.mode = 050644
+core.mode = 050644
+core.mode = 050644
+core.mode = 050644
+core.mode = 050644
+would have junked entry "BLKDEV" in directory PARENT_INO
+would have junked entry "CHRDEV" in directory PARENT_INO
+would have junked entry "DATA" in directory PARENT_INO
+would have junked entry "DIR" in directory PARENT_INO
+would have junked entry "EMPTY" in directory PARENT_INO
+would have junked entry "FIFO" in directory PARENT_INO
+would have junked entry "SYMLINK" in directory PARENT_INO
+
+===== Setting dt=6 to all files:
+core.mode = 060644
+core.mode = 060644
+core.mode = 060644
+core.mode = 060644
+core.mode = 060644
+core.mode = 060644
+core.mode = 060644
+would have junked entry "DATA" in directory PARENT_INO
+would have junked entry "DIR" in directory PARENT_INO
+would have junked entry "EMPTY" in directory PARENT_INO
+would have junked entry "SYMLINK" in directory PARENT_INO
+
+===== Setting dt=7 to all files:
+core.mode = 070644
+core.mode = 070644
+core.mode = 070644
+core.mode = 070644
+core.mode = 070644
+core.mode = 070644
+core.mode = 070644
+would have junked entry "BLKDEV" in directory PARENT_INO
+would have junked entry "CHRDEV" in directory PARENT_INO
+would have junked entry "DATA" in directory PARENT_INO
+would have junked entry "DIR" in directory PARENT_INO
+would have junked entry "EMPTY" in directory PARENT_INO
+would have junked entry "FIFO" in directory PARENT_INO
+would have junked entry "SYMLINK" in directory PARENT_INO
+
+===== Setting dt=10 to all files:
+core.mode = 0100644
+core.mode = 0100644
+core.mode = 0100644
+core.mode = 0100644
+core.mode = 0100644
+core.mode = 0100644
+core.mode = 0100644
+would have junked entry "BLKDEV" in directory PARENT_INO
+would have junked entry "CHRDEV" in directory PARENT_INO
+would have junked entry "DIR" in directory PARENT_INO
+would have junked entry "FIFO" in directory PARENT_INO
+would have junked entry "SYMLINK" in directory PARENT_INO
+
+===== Setting dt=11 to all files:
+core.mode = 0110644
+core.mode = 0110644
+core.mode = 0110644
+core.mode = 0110644
+core.mode = 0110644
+core.mode = 0110644
+core.mode = 0110644
+would have junked entry "BLKDEV" in directory PARENT_INO
+would have junked entry "CHRDEV" in directory PARENT_INO
+would have junked entry "DATA" in directory PARENT_INO
+would have junked entry "DIR" in directory PARENT_INO
+would have junked entry "EMPTY" in directory PARENT_INO
+would have junked entry "FIFO" in directory PARENT_INO
+would have junked entry "SYMLINK" in directory PARENT_INO
+
+===== Setting dt=12 to all files:
+core.mode = 0120644
+core.mode = 0120644
+core.mode = 0120644
+core.mode = 0120644
+core.mode = 0120644
+core.mode = 0120644
+core.mode = 0120644
+would have junked entry "BLKDEV" in directory PARENT_INO
+would have junked entry "CHRDEV" in directory PARENT_INO
+would have junked entry "DATA" in directory PARENT_INO
+would have junked entry "DIR" in directory PARENT_INO
+would have junked entry "EMPTY" in directory PARENT_INO
+would have junked entry "FIFO" in directory PARENT_INO
+
+===== Setting dt=13 to all files:
+core.mode = 0130644
+core.mode = 0130644
+core.mode = 0130644
+core.mode = 0130644
+core.mode = 0130644
+core.mode = 0130644
+core.mode = 0130644
+would have junked entry "BLKDEV" in directory PARENT_INO
+would have junked entry "CHRDEV" in directory PARENT_INO
+would have junked entry "DATA" in directory PARENT_INO
+would have junked entry "DIR" in directory PARENT_INO
+would have junked entry "EMPTY" in directory PARENT_INO
+would have junked entry "FIFO" in directory PARENT_INO
+would have junked entry "SYMLINK" in directory PARENT_INO
+
+===== Setting dt=14 to all files:
+core.mode = 0140644
+core.mode = 0140644
+core.mode = 0140644
+core.mode = 0140644
+core.mode = 0140644
+core.mode = 0140644
+core.mode = 0140644
+would have junked entry "DATA" in directory PARENT_INO
+would have junked entry "DIR" in directory PARENT_INO
+would have junked entry "EMPTY" in directory PARENT_INO
+would have junked entry "SYMLINK" in directory PARENT_INO
+
+===== Setting dt=15 to all files:
+core.mode = 0150644
+core.mode = 0150644
+core.mode = 0150644
+core.mode = 0150644
+core.mode = 0150644
+core.mode = 0150644
+core.mode = 0150644
+would have junked entry "BLKDEV" in directory PARENT_INO
+would have junked entry "CHRDEV" in directory PARENT_INO
+would have junked entry "DATA" in directory PARENT_INO
+would have junked entry "DIR" in directory PARENT_INO
+would have junked entry "EMPTY" in directory PARENT_INO
+would have junked entry "FIFO" in directory PARENT_INO
+would have junked entry "SYMLINK" in directory PARENT_INO
+
+===== Setting dt=16 to all files:
+core.mode = 0160644
+core.mode = 0160644
+core.mode = 0160644
+core.mode = 0160644
+core.mode = 0160644
+core.mode = 0160644
+core.mode = 0160644
+would have junked entry "BLKDEV" in directory PARENT_INO
+would have junked entry "CHRDEV" in directory PARENT_INO
+would have junked entry "DATA" in directory PARENT_INO
+would have junked entry "DIR" in directory PARENT_INO
+would have junked entry "EMPTY" in directory PARENT_INO
+would have junked entry "FIFO" in directory PARENT_INO
+would have junked entry "SYMLINK" in directory PARENT_INO
+
+===== Setting dt=17 to all files:
+core.mode = 0170644
+core.mode = 0170644
+core.mode = 0170644
+core.mode = 0170644
+core.mode = 0170644
+core.mode = 0170644
+core.mode = 0170644
+would have junked entry "BLKDEV" in directory PARENT_INO
+would have junked entry "CHRDEV" in directory PARENT_INO
+would have junked entry "DATA" in directory PARENT_INO
+would have junked entry "DIR" in directory PARENT_INO
+would have junked entry "EMPTY" in directory PARENT_INO
+would have junked entry "FIFO" in directory PARENT_INO
+would have junked entry "SYMLINK" in directory PARENT_INO
diff --git a/tests/xfs/group b/tests/xfs/group
index c237b50..68c2bb6 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -334,3 +334,4 @@
345 auto quick clone
346 auto quick clone
347 auto quick clone
+348 auto quick repair
--
2.7.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v3 3/3] xfs: test readlink/readdir with malformed inode mode
2017-01-09 13:30 ` [PATCH v3 3/3] xfs: test readlink/readdir " Amir Goldstein
@ 2017-01-11 6:38 ` Amir Goldstein
2017-01-11 6:41 ` Amir Goldstein
1 sibling, 0 replies; 9+ messages in thread
From: Amir Goldstein @ 2017-01-11 6:38 UTC (permalink / raw)
To: Eryu Guan; +Cc: Brian Foster, Darrick J . Wong, fstests, linux-xfs
On Mon, Jan 9, 2017 at 3:30 PM, Amir Goldstein <amir73il@gmail.com> wrote:
> In addition to testing xfs_repair on inodes with malformed mode,
> and fstat of those inodes on a mounted fs, try to also list content
> of mock directory and readlink of mock symlink.
>
> Readdir of mock directory triggers XFS assertion on kernel 4.9 with
> XFS_DEBUG=y
>
> XFS: Assertion failed:
> rval == 0 || args->dp->i_d.di_size == args->geo->blksize,
> file: /home/amir/build/src/linux/fs/xfs/libxfs/xfs_dir2.c, line: 634
>
> A fix patch, as suggested by Darrick, changes this ASSERT() to
> return -EFSCORRUPTED ("xfs: sanity check directory inode di_size").
>
> Merging this test should be deferred to after fix patch is merged.
>
> Signed-off-by: Amir Goldstein <amir73il@gmail.com>
> ---
> tests/xfs/348 | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/tests/xfs/348 b/tests/xfs/348
> index 30825a4..20d5d7e 100755
> --- a/tests/xfs/348
> +++ b/tests/xfs/348
> @@ -133,6 +133,15 @@ for dt in $dtypes; do
> cat $tmp.stat.err
> else
> echo "stat: '$testdir/$file' is a $ftype"
> + # Verify that readlink of a file posing as a symlink
> + # and ls of a file posing as a directory does not blow up.
> + # NOTE that ls DOES ASSERT with kernel 4.9 and XFS_DEBUG=y
> + # on malformed directory
> + if [ -d $testdir/$file ]; then
> + ls "$safety" $testdir/$file &> /dev/null
leftover: "$safety"
> + elif [ -h $testdir/$file ]; then
> + readlink $testdir/$file &> /dev/null
> + fi
> fi | _filter_scratch
> done
> _scratch_unmount
> --
> 2.7.4
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v3 3/3] xfs: test readlink/readdir with malformed inode mode
2017-01-09 13:30 ` [PATCH v3 3/3] xfs: test readlink/readdir " Amir Goldstein
2017-01-11 6:38 ` Amir Goldstein
@ 2017-01-11 6:41 ` Amir Goldstein
1 sibling, 0 replies; 9+ messages in thread
From: Amir Goldstein @ 2017-01-11 6:41 UTC (permalink / raw)
To: Eryu Guan; +Cc: Brian Foster, Darrick J . Wong, fstests, linux-xfs
In addition to testing xfs_repair on inodes with malformed mode,
and fstat of those inodes on a mounted fs, try to also list content
of mock directory and readlink of mock symlink.
Readdir of mock directory triggers XFS assertion on kernel 4.9 with
XFS_DEBUG=y
XFS: Assertion failed:
rval == 0 || args->dp->i_d.di_size == args->geo->blksize,
file: /home/amir/build/src/linux/fs/xfs/libxfs/xfs_dir2.c, line: 634
A fix patch, as suggested by Darrick, changes this ASSERT() to
return -EFSCORRUPTED ("xfs: sanity check directory inode di_size").
Merging this test should be deferred to after fix patch is merged.
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
tests/xfs/348 | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/tests/xfs/348 b/tests/xfs/348
index 30825a4..20d5d7e 100755
--- a/tests/xfs/348
+++ b/tests/xfs/348
@@ -133,6 +133,15 @@ for dt in $dtypes; do
cat $tmp.stat.err
else
echo "stat: '$testdir/$file' is a $ftype"
+ # Verify that readlink of a file posing as a symlink
+ # and ls of a file posing as a directory does not blow up.
+ # NOTE that ls DOES ASSERT with kernel 4.9 and XFS_DEBUG=y
+ # on malformed directory
+ if [ -d $testdir/$file ]; then
+ ls $testdir/$file &> /dev/null
+ elif [ -h $testdir/$file ]; then
+ readlink $testdir/$file &> /dev/null
+ fi
fi | _filter_scratch
done
_scratch_unmount
--
2.7.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v3 0/3] xfs: test malformed inode mode
2017-01-09 13:30 [PATCH v3 0/3] xfs: test malformed inode mode Amir Goldstein
` (2 preceding siblings ...)
2017-01-09 13:30 ` [PATCH v3 3/3] xfs: test readlink/readdir " Amir Goldstein
@ 2017-01-20 5:25 ` Eryu Guan
3 siblings, 0 replies; 9+ messages in thread
From: Eryu Guan @ 2017-01-20 5:25 UTC (permalink / raw)
To: Amir Goldstein; +Cc: Brian Foster, Darrick J . Wong, fstests, linux-xfs
Hi,
On Mon, Jan 09, 2017 at 03:30:22PM +0200, Amir Goldstein wrote:
> Eryu,
>
> This is the 3rd revision of the malformed inode mode test.
>
> Like with v2, patch 1 is safe and it passes on kernel 4.9.
>
> Like with v2, patch 2 is safe, but unlike v2, it fails on
> kernel 4.9, because I added a stronger expectation for the
> test to fails on stat of directory with inode size 0.
>
> Like with v2, patch 3 triggers an XFS assert and I removed
> the "safety pin" that was there in v2.
>
> I already sent the fix patch to Darick, which addresses the
> failures in both patch 2 and 3.
>
> You could merge patch 1 now and defer merging patches 2-3
> or you could wait with merging the entire test. up to you.
I'll merge patch 2-3 in this week update, Darrick has sent the fixes to
Linus, hopefully they'll be in rc5 next week.
Thanks,
Eryu
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2017-01-20 5:25 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-09 13:30 [PATCH v3 0/3] xfs: test malformed inode mode Amir Goldstein
2017-01-09 13:30 ` [PATCH v3 1/3] xfs: test handling of invalid inode modes Amir Goldstein
2017-01-09 13:36 ` Amir Goldstein
2017-01-09 13:39 ` Amir Goldstein
2017-01-09 13:30 ` [PATCH v3 2/3] xfs: test fstat with malformed inode mode Amir Goldstein
2017-01-09 13:30 ` [PATCH v3 3/3] xfs: test readlink/readdir " Amir Goldstein
2017-01-11 6:38 ` Amir Goldstein
2017-01-11 6:41 ` Amir Goldstein
2017-01-20 5:25 ` [PATCH v3 0/3] xfs: test " Eryu Guan
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.