xfstest: Add test case to test multiple collapse range call
PATCH RESEND 6/7 xfstest: Add test case to test multiple collapse range call
From: Namjae Jeon <[email protected]>
We execute collapse range multiple times on same file. Each collapse range call collapses a single alternate block. After the test execution, file will be left with 80 blocks and as much number of extents.
We also check for file system consistency after the completion.
--- tests/shared/317 | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++ tests/shared/317.out | 85 ++++++++++++++++++++++++++++++++++++++++++++ tests/shared/group | 1 + 3 files changed, 182 insertions(+) create mode 100644 tests/shared/317 create mode 100644 tests/shared/317.out
tests/shared/317 new file +96 -0
@@ -0,0 +1,96 @@ +#! /bin/bash +# FS QA Test No. 317 +# +# Test multiple fallocate collapse range calls +# +#----------------------------------------------------------------------- +# Copyright (c) 2013 Samsung Electronics. 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 "rm -f $tmp.*; exit \$status" 0 1 2 3 15 + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +# real QA test starts here +_supported_fs xfs ext4 +_supported_os Linux + +_require_scratch +_require_xfs_io_fiemap +_require_xfs_io_falloc_collapse +_do_die_on_error=y +test=$SCRATCH_MNT/test +testfile=$SCRATCH_MNT/317.$$ +BSIZE=4096 +BLOCKS=10240 + +# Filters fiemap output +_filter_fiemap() +{ + awk --posix ' + $3 ~ /hole/ { + print $1, $2, $3; + next; + } + $5 ~ /0x[[:xdigit:]]+/ { + print $1, $2, "extent"; + }' +} + +case $FSTYP in + ext4) + export MKFS_OPTIONS="-F -b $BSIZE" + ;; + xfs) + export MKFS_OPTIONS="-f -b size=$BSIZE" + ;; +esac + +# make filesystem on scratch with 4KB blocksize +_do 'make filesystem on $SCRATCH_DEV' '_scratch_mkfs' +_do 'mount filesytem' '_scratch_mount' + +# Write file +length=$(($BLOCKS*$BSIZE)) +$XFS_IO_PROG -f -c "pwrite 0 $length" -c fsync $testfile > /dev/null + +# Collapse alternate blocks +for (( i = 1; i <= 7; i++ )); do + for(( j=0 ; j < $(($BLOCKS/(2**$i))) ; j++ )); do + offset=$(($j*$BSIZE)) + $XFS_IO_PROG -c "fcollapse $offset $BSIZE" $testfile > /dev/null + done +done + +# Check if 80 extents are present +$XFS_IO_PROG -c "fiemap -v" $testfile | _filter_fiemap + +_do 'unmount $SCRATCH_DEV' 'umount $SCRATCH_DEV' +_do 'repair filesystem' '_check_scratch_fs' + +# success, all done +status=0; exit
tests/shared/317.out new file +85 -0
85 lines not on this page · raw message
tests/shared/group +1 -0
@@ -12,3 +12,4 @@ 298 auto trim 305 aio dangerous enospc rw stress 316 auto quick collapse +317 auto collapse
Signature · 6 lines
1.7.9.5 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Quoted 7 lines · Namjae Jeon
From: Namjae Jeon <[email protected]>
We execute collapse range multiple times on same file. Each collapse range call collapses a single alternate block. After the test execution, file will be left with 80 blocks and as much number of extents.
We also check for file system consistency after the completion.
.....
tests/shared/317 line 46
Quoted 12 lines
+. ./common/rc
+. ./common/filtertests/shared/317 new file +10
-0+ +# real QA test starts here +_supported_fs xfs ext4 +_supported_os Linux + +_require_scratch +_require_xfs_io_fiemap +_require_xfs_io_falloc_collapse +_do_die_on_error=y +test=$SCRATCH_MNT/test
Not used.
Quoted 6 lines
tests/shared/317 new file +6
-0+testfile=$SCRATCH_MNT/317.$$ +BSIZE=4096 +BLOCKS=10240 + +# Filters fiemap output +_filter_fiemap()
tests/shared/317 line 62
Quoted 10 lines
tests/shared/317 new file +10
-0+{ + awk --posix ' + $3 ~ /hole/ { + print $1, $2, $3; + next; + } + $5 ~ /0x[[:xdigit:]]+/ { + print $1, $2, "extent"; + }' +}
There's already a function in common/punch of this name, and it does pretty much the same thing. Why not use that?
tests/shared/317 line 71
Quoted 9 lines
tests/shared/317 new file +9
-0+ +case $FSTYP in + ext4) + export MKFS_OPTIONS="-F -b $BSIZE" + ;; + xfs) + export MKFS_OPTIONS="-f -b size=$BSIZE" + ;; +esac
_scratch_mkfs takes options on the command line - there is no need to do this.
In fact, this test needs to run on all block sizes that filesystems are capable of using, not just 4k and different architectures exercise different code paths and so we must be able to test the case where block size is smaller than page size on x86-64 so when the code is run on an ia64 or ppc64 box with a 64k page size we know that it's not completely broken...
Anyway, if you really need to make a 4k block size filesystem, then _scratch_mkfs_sized() is the generic way of doing this.
tests/shared/317 line 75
Quoted 3 lines
tests/shared/317 new file +3
-0+# make filesystem on scratch with 4KB blocksize +_do 'make filesystem on $SCRATCH_DEV' '_scratch_mkfs' +_do 'mount filesytem' '_scratch_mount'
I really dislike this "_do" wrapper. The text does not add anything to the test, and it makes it hard to see the command being run and harder to modify it when necessary. It is used only by a couple of old tests, and we'd do better to remove it than to propagate it further. This:
_scratch_mkfs >> $seqres.full 2>&1 || _fail "scratch_mkfs failed." _scratch_mount >> $seqres.full 2>&1 || _fail "scratch_mount failed."
does everything that the _do wrapper does.
Quoted 5 lines
tests/shared/317 new file +5
-0+ +# Write file +length=$(($BLOCKS*$BSIZE)) +$XFS_IO_PROG -f -c "pwrite 0 $length" -c fsync $testfile > /dev/null +
tests/shared/317 line 90
Quoted 10 lines
tests/shared/317 new file +10
-0+# Collapse alternate blocks +for (( i = 1; i <= 7; i++ )); do + for(( j=0 ; j < $(($BLOCKS/(2**$i))) ; j++ )); do + offset=$(($j*$BSIZE)) + $XFS_IO_PROG -c "fcollapse $offset $BSIZE" $testfile > /dev/null + done +done + +# Check if 80 extents are present +$XFS_IO_PROG -c "fiemap -v" $testfile | _filter_fiemap
If all you care about is that there are 80 extents, then why not just something like:
$XFS_IO_PROG -c "fiemap -v" $testfile |grep "^ *[0-9]*:" |wc -l
tests/shared/317 line 93
Quoted 3 lines
tests/shared/317 new file +3
-0+ +_do 'unmount $SCRATCH_DEV' 'umount $SCRATCH_DEV' +_do 'repair filesystem' '_check_scratch_fs'
_check_scratch_fs is all you need to call here.
tests/shared/group line 15
Quoted 8 lines
index 3a69294..80ff7ec 100644
tests/shared/group +1
-0@@ -12,3 +12,4 @@ 298 auto trim 305 aio dangerous enospc rw stress 316 auto quick collapse +317 auto collapse
Again, I think the prealloc group is better for this.
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Quoted 6 lines
Quoted 6 lines
+. ./common/rc
+. ./common/filtertests/shared/317 new file +4
-0+ +# real QA test starts here +_supported_fs xfs ext4 +_supported_os Linux
Quoted 8 lines
tests/shared/317 line 46
Quoted 6 lines
tests/shared/317 new file +6
-0+ +_require_scratch +_require_xfs_io_fiemap +_require_xfs_io_falloc_collapse +_do_die_on_error=y +test=$SCRATCH_MNT/testNot used.
Okay.
Quoted 12 lines
Quoted 12 lines
tests/shared/317 new file +11
-0+testfile=$SCRATCH_MNT/317.$$ +BSIZE=4096 +BLOCKS=10240 + +# Filters fiemap output +_filter_fiemap() +{ + awk --posix ' + $3 ~ /hole/ { + print $1, $2, $3; + next;
Quoted 8 lines
tests/shared/317 line 62
Quoted 5 lines
tests/shared/317 new file +5
-0+ } + $5 ~ /0x[[:xdigit:]]+/ { + print $1, $2, "extent"; + }' +}There's already a function in common/punch of this name, and it does pretty much the same thing. Why not use that?
Ah, Okay, I will check.
Quoted 13 lines
tests/shared/317 line 71
Quoted 10 lines
tests/shared/317 new file +9
-0+ +case $FSTYP in + ext4) + export MKFS_OPTIONS="-F -b $BSIZE" + ;; + xfs) + export MKFS_OPTIONS="-f -b size=$BSIZE" + ;; +esac
_scratch_mkfstakes options on the command line - there is no need to do this.
Okay.
Quoted 7 lines
In fact, this test needs to run on all block sizes that filesystems are capable of using, not just 4k and different architectures exercise different code paths and so we must be able to test the case where block size is smaller than page size on x86-64 so when the code is run on an ia64 or ppc64 box with a 64k page size we know that it's not completely broken...
Okay, I will update to test block size is smaller than page size.
Quoted 14 lines
Anyway, if you really need to make a 4k block size filesystem, then
_scratch_mkfs_sized()is the generic way of doing this.tests/shared/317 line 75
Quoted 3 lines
tests/shared/317 new file +3
-0+# make filesystem on scratch with 4KB blocksize +_do 'make filesystem on $SCRATCH_DEV' '_scratch_mkfs' +_do 'mount filesytem' '_scratch_mount'I really dislike this "
_do" wrapper. The text does not add anything to the test, and it makes it hard to see the command being run and harder to modify it when necessary. It is used only by a couple of old tests, and we'd do better to remove it than to propagate it further. This:
Quoted 4 lines
_scratch_mkfs>> $seqres.full 2>&1 ||_fail"scratch_mkfsfailed."_scratch_mount>> $seqres.full 2>&1 ||_fail"scratch_mountfailed."does everything that the
_dowrapper does.
Okay.
Quoted 20 lines
Quoted 6 lines
tests/shared/317 new file +5
-0+ +# Write file +length=$(($BLOCKS*$BSIZE)) +$XFS_IO_PROG -f -c "pwrite 0 $length" -c fsync $testfile > /dev/null +tests/shared/317 line 90
Quoted 10 lines
tests/shared/317 new file +10
-0+# Collapse alternate blocks +for (( i = 1; i <= 7; i++ )); do + for(( j=0 ; j < $(($BLOCKS/(2**$i))) ; j++ )); do + offset=$(($j*$BSIZE)) + $XFS_IO_PROG -c "fcollapse $offset $BSIZE" $testfile > /dev/null + done +done + +# Check if 80 extents are present +$XFS_IO_PROG -c "fiemap -v" $testfile | _filter_fiemapIf all you care about is that there are 80 extents, then why not just something like:
Quoted 1 line
$XFS_IO_PROG -c "fiemap -v" $testfile |grep "^ *[0-9]*:" |wc -l
Okay, I will check.
Quoted 6 lines
tests/shared/317 line 93
Quoted 4 lines
tests/shared/317 new file +3
-0+ +_do 'unmount $SCRATCH_DEV' 'umount $SCRATCH_DEV' +_do 'repair filesystem' '_check_scratch_fs'
_check_scratch_fsis all you need to call here.
Yes, right. I will update.
Quoted 11 lines
tests/shared/group line 15
Quoted 9 lines
index 3a69294..80ff7ec 100644
tests/shared/group +1
-0@@ -12,3 +12,4 @@ 298 auto trim 305 aio dangerous enospc rw stress 316 auto quick collapse +317 auto collapseAgain, I think the prealloc group is better for this.
Okay, I will add collpase range cases to prealloc group.
Thanks for review.
I will post patches included your all review points soon.
Quoted 7 lines
Cheers,
Dave.
--
Dave Chinner
[email protected]
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs