RFC: O_TMPFILE tests
cover RFC: O_TMPFILE tests
This series adds a generic and one xfs-specific test for the O_TMPFILE functionality. For now it's purely RFC as there is no infrastructure to test the filesystem and xfs_io supports O_TMPFILE yet, as I plan to implement that ontop of Lukas' refactoring of the related feature checks.
Even with these tests not going in ASAP having them out and waiting to be merged is enough that I'd be fine with merging the tmpfile branch into for-next so that it can go into the 3.15 merge window.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 1/2 generic: add a basic O_TMPFILE test
tests/generic/004 new file +70 -0
@@ -0,0 +1,70 @@ +#! /bin/bash +# FS QA Test No. 004 +# +# Test O_TMPFILE opens +# +#----------------------------------------------------------------------- +# Copyright (c) 2014 Christoph Hellwig. 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 ${testfile} +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +# real QA test starts here +_supported_fs generic +_supported_os Linux + +#_require_xfs_io_falloc_flink + +testfile="${TEST_DIR}/tst-tmpfile-flink" + +# test creating a r/w tmpfile, do I/O and link it into the namespace +$XFS_IO_PROG -T \ + -c "pwrite 0 4096" \ + -c "pread 0 4096" \ + -c "flink ${testfile}" \ + ${TEST_DIR} | _filter_xfs_io + +if [ ! -f "${testfile}" ]; then + echo "failed to link testfile into place" + exit 1 +fi + +rm -f ${tmpfile} + +# test creating a r/o tmpfile. Should fail +$XFS_IO_PROG -Tr ${TEST_DIR} -c "close" | _filter_test_dir + +# success, all done +status=0 +exit
tests/generic/004.out new file +6 -0
@@ -0,0 +1,6 @@ +QA output created by 004 +wrote 4096/4096 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 4096/4096 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +/mnt/test: Invalid argument
tests/generic/group +1 -0
@@ -6,6 +6,7 @@ 001 rw dir udf auto quick 002 metadata udf auto quick 003 atime auto quick +004 auto quick 005 dir udf auto quick 006 dir udf auto quick 007 dir udf auto quick
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 2/2 xfs: add a test for unlinked inodes due to O_TMPFILE
In reply to Christoph HellwigMake sure that we see unlinked inodes when shutting a filesystem down that has an open O_TMPFILE descriptor, and make sure that it has been deleted after a mount/umount cycle.
tests/xfs/006 new file +86 -0
@@ -0,0 +1,86 @@ +#! /bin/bash +# XFS QA Test No. 006 +# +# Test O_TMPFILE interaction with log recovery and repair. +# +#----------------------------------------------------------------------- +# Copyright (c) 2014 Christoph Hellwig. 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.* + rm -f ${testfile} +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/repair + +# real QA test starts here +_supported_fs generic +_supported_os Linux + +_require_scratch +#_require_xfs_io_falloc_flink + +testfile="${SCRATCH_MNT}/tst-tmpfile-flink" + +_scratch_mount + +# test creating a r/w tmpfile, do I/O and link it into the namespace +$XFS_IO_PROG -x -T \ + -c "pwrite 0 4096" \ + -c "pread 0 4096" \ + -c "freeze" \ + -c "thaw" \ + -c "shutdown" \ + ${SCRATCH_MNT} | _filter_xfs_io + +_scratch_unmount + +# repair should find an unlinked inode and an incorrect icount +_scratch_xfs_repair -n 2>&1 | \ + _filter_repair > $tmp.repair + +ino=`grep 'disconnected inode ' $tmp.repair | \ + head -1 | \ + awk '{print $3}' | \ + sed 's/,//'` + +cat $tmp.repair | sed "s/$ino/XXX/g" + +# filesystem should be clean after an unmount/mount cycle +_scratch_mount +_scratch_unmount + +_scratch_xfs_repair -n 2>&1 | _filter_repair + +# success, all done +status=0 +exit
tests/xfs/006.out new file +43 -0
43 lines not on this page · raw message
tests/xfs/group +1 -0
@@ -3,6 +3,7 @@ 003 db auto quick 004 db auto quick 005 auto quick +006 auto quick 008 rw ioctl auto quick 009 rw ioctl auto prealloc quick 012 rw auto quick
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 2/2] xfs: add a test for unlinked inodes due to O_TMPFILE
Quoted 48 lines · Christoph Hellwig
Make sure that we see unlinked inodes when shutting a filesystem down that has an open
O_TMPFILEdescriptor, and make sure that it has been deleted after a mount/umount cycle.Signed-off-by Christoph Hellwig <[email protected]>tests/xfs/006 new file +36
-0@@ -0,0 +1,86 @@ +#! /bin/bash +# XFS QA Test No. 006 +# +# Test O_TMPFILE interaction with log recovery and repair. +# +#----------------------------------------------------------------------- +# Copyright (c) 2014 Christoph Hellwig. 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.*
tests/xfs/006 line 46
Quoted 10 lines
tests/xfs/006 new file +10
-0+ rm -f ${testfile} +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/repair + +# real QA test starts here +_supported_fs generic
XFS only.
Quoted 7 lines
tests/xfs/006 new file +7
-0+_supported_os Linux + +_require_scratch +#_require_xfs_io_falloc_flink + +testfile="${SCRATCH_MNT}/tst-tmpfile-flink" +
tests/xfs/006 line 63
Quoted 10 lines
tests/xfs/006 new file +10
-0+_scratch_mount + +# test creating a r/w tmpfile, do I/O and link it into the namespace +$XFS_IO_PROG -x -T \ + -c "pwrite 0 4096" \ + -c "pread 0 4096" \ + -c "freeze" \ + -c "thaw" \ + -c "shutdown" \ + ${SCRATCH_MNT} | _filter_xfs_io
$testfile?
Also, I don't see the file being linked into the namespace, so the comment is probably wrong. Also, please add a comment as to why the freeze/thaw is necessary.
tests/xfs/006 line 76
Quoted 10 lines
tests/xfs/006 new file +10
-0+# repair should find an unlinked inode and an incorrect icount +_scratch_xfs_repair -n 2>&1 | \ + _filter_repair > $tmp.repair + +ino=`grep 'disconnected inode ' $tmp.repair | \ + head -1 | \ + awk '{print $3}' | \ + sed 's/,//'` + +cat $tmp.repair | sed "s/$ino/XXX/g"
Ok, so we should see that line in the golden output...
....
Quoted 18 lines
tests/xfs/006.out new file +12
-0@@ -0,0 +1,43 @@ +QA output created by 006 +wrote 4096/4096 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 4096/4096 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +Phase 1 - find and verify superblock... +Phase 2 - using <TYPEOF> log + - scan filesystem freespace and inode maps... + - found root inode chunk +Phase 3 - for each AG... + - scan (but don't clear) agi unlinked lists... + - process known inodes and perform inode discovery...
tests/xfs/006.out line 22
Quoted 10 lines
tests/xfs/006.out new file +10
-0+ - process newly discovered inodes... +Phase 4 - check for duplicate blocks... + - setting up duplicate extent list... + - check for inodes claiming duplicate blocks... +No modify flag set, skipping phase 5 +Phase 6 - check inode connectivity... + - traversing filesystem ... + - traversal finished ... + - moving disconnected inodes to lost+found ... +disconnected inode XXX, would move to lost+found
There it is, but is moving it to lost+found the right thing to do, given that it was on the unlinked list and should have had a zero link count? i.e. aren't we supposed to free unlinked inodes with a zero link count, not recover them to lost+found?
tests/xfs/006.out line 24
Quoted 2 lines
tests/xfs/006.out new file +2
-0+Phase 7 - verify link counts... +would have reset inode XXX nlinks from 0 to 1
Yeah, that seems like the wrong behaviour to have for an anonymous O_TMPFILE file - it's making it visible because we moved it to lost+found in phase 6....
Also, I don't see any icount mismatch, so the comment above in the test is probably wrong.
tests/xfs/group line 6
Quoted 9 lines
tests/xfs/group +1
-0@@ -3,6 +3,7 @@ 003 db auto quick 004 db auto quick 005 auto quick +006 auto quick
and repair.
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 2/2] xfs: add a test for unlinked inodes due to O_TMPFILE
Quoted 3 lines · Dave Chinner
Quoted 1 line
+_supported_fs generic
XFS only.
Hmm. I remember fixing this up, but for some reason it didn't make it into the final patch.
Quoted 10 lines
tests/xfs/006 line 63
Quoted 8 lines
tests/xfs/006 new file +8
-0+# test creating a r/w tmpfile, do I/O and link it into the namespace +$XFS_IO_PROG -x -T \ + -c "pwrite 0 4096" \ + -c "pread 0 4096" \ + -c "freeze" \ + -c "thaw" \ + -c "shutdown" \ + ${SCRATCH_MNT} | _filter_xfs_io$testfile?
No, O_TMPFILE doesn't take an actual file name but a "virtual" parent directory. It's a reall creative abuse of the open ABI..
Quoted 3 lines
Also, I don't see the file being linked into the namespace, so the comment is probably wrong. Also, please add a comment as to why the freeze/thaw is necessary.
Yes, we don't want to link it so that we have it on the unlinke dinode list. The freeze/thaw is to make sure the log has been cleaned, I'll add a comment explaining it.
Quoted 8 lines
There it is, but is moving it to lost+found the right thing to do, given that it was on the unlinked list and should have had a zero link count? i.e. aren't we supposed to free unlinked inodes with a zero link count, not recover them to lost+found?
Yeah, that seems like the wrong behaviour to have for an anonymous
O_TMPFILEfile - it's making it visible because we moved it to lost+found in phase 6....
Good question. I thought about this a little and decided that it wasn't worth special casing O_TMPFILE inodes in repair, but thinking about it a bit more this also happens for normal unlinked but open files. I can look into this if you want, and would create another test for that case.
Quoted 3 lines
Also, I don't see any icount mismatch, so the comment above in the test is probably wrong.
We do have an icount mismatch, but _filter_repair filters it away.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs