xfstests: test setting XFS BMBT fields
PATCH 1/1 xfstests: test setting XFS BMBT fields
Test the setting of the XFS BMBT fields. Runs through the valid bit values for each field. Also test the value past the last legal value.
Additionally, ensures setting a core entry (core.gen is used) is still correct. Test that the hex (#HH) input on a BMBT field and a core entry are also correct.
--- tests/xfs/307 | 112 +++++++++++++++++++++++++++++++++++++++ tests/xfs/307.out | 152 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/group | 1 3 files changed, 265 insertions(+)
tests/xfs/307 new file +112 -0
@@ -0,0 +1,112 @@ +#! /bin/bash +# FS QA Test No. 307 +# +# Test the xfs_db write of the XFS BMBT entries. For each XFS BMBT field, +# write the value 0, each bit and finally the entry beyond the maximum legal +# value. Also makes sure a core write and hex input still work. +# +#----------------------------------------------------------------------- +# Copyright (c) 2014 SGI. 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.* +} + +_do_bit_test() +{ + _field="$1" + _bits="$2" + + echo "testing ${_field} ${_bits} bits" | sed 's/u3/u/' + $XFS_DB_PROG -x -c "inode $FILE_INO" -c "write ${_field} 0" \ + $SCRATCH_DEV | sed 's/u3/u/' + num=1 + for n in `seq 0 1 ${_bits}`; do + $XFS_DB_PROG -x -c "inode $FILE_INO" \ + -c "write ${_field} ${num}" \ + $SCRATCH_DEV | sed 's/u3/u/' + let num=$num*2 + done + echo +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +# real QA test starts here + +# Modify as appropriate. +_supported_fs xfs +_supported_os Linux + +_scratch_unmount +_scratch_mkfs >/dev/null 2>&1 +_scratch_mount + +# create the test file +echo "test file" > $SCRATCH_MNT/testfile + +# find the inode for the test file +FILE_INO=`ls -i $SCRATCH_MNT |awk '{print $1}'` + +_scratch_unmount + +# test bit length constants +BMBT_EXNTFLAG_BITLEN=1 +BMBT_STARTOFF_BITLEN=54 +BMBT_STARTBLOCK_BITLEN=52 +BMBT_BLOCKCOUNT_BITLEN=21 + +# Which version of the filesystem? +echo $XFS_MKFS_OPTIONS | grep "crc=1" > /dev/null +if [ $? == 1 ]; then + prefix="u" +else + prefix="u3" +fi + +# test setting the BMBT entries from 0 to past the valid number. +_do_bit_test "$prefix.bmx[0].extentflag" $BMBT_EXNTFLAG_BITLEN +_do_bit_test "$prefix.bmx[0].startoff" $BMBT_STARTOFF_BITLEN +_do_bit_test "$prefix.bmx[0].startblock" $BMBT_STARTBLOCK_BITLEN +_do_bit_test "$prefix.bmx[0].blockcount" $BMBT_BLOCKCOUNT_BITLEN +# test setting the 32 bit generation number +$XFS_DB_PROG -x -c "inode $FILE_INO" -c "write core.gen 0x5a" $SCRATCH_DEV +$XFS_DB_PROG -x -c "inode $FILE_INO" -c "write core.gen 0xa5" $SCRATCH_DEV +$XFS_DB_PROG -x -c "inode $FILE_INO" -c "write core.gen 0" $SCRATCH_DEV +# test setting the entry using #HH hex +$XFS_DB_PROG -x -c "inode $FILE_INO" -c "write $prefix.bmx[0].startoff #573a" \ + $SCRATCH_DEV | sed 's/u3/u/' +$XFS_DB_PROG -x -c "inode $FILE_INO" -c "write $prefix.bmx[0].startoff #a573" \ + $SCRATCH_DEV | sed 's/u3/u/' +$XFS_DB_PROG -x -c "inode $FILE_INO" -c "write core.gen #185a" $SCRATCH_DEV +$XFS_DB_PROG -x -c "inode $FILE_INO" -c "write core.gen #a518" $SCRATCH_DEV +status=0 +exit
tests/xfs/307.out new file +152 -0
152 lines not on this page · raw message
tests/xfs/group +1 -0
@@ -186,3 +186,4 @@ 304 auto quick quota 305 auto quota 306 auto stress log metadata repair +307 auto db
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 7 lines · Mark Tinguely
Test the setting of the XFS BMBT fields. Runs through the valid bit values for each field. Also test the value past the last legal value.
Additionally, ensures setting a core entry (core.gen is used) is still correct. Test that the hex (#HH) input on a BMBT field and a core entry are also correct.
A couple of comments below.
...
Quoted 9 lines
tests/xfs/307 new file +9
-0+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 +
tests/xfs/307 line 44
Quoted 10 lines
tests/xfs/307 new file +10
-0+_cleanup() +{ + cd / + rm -f $tmp.* +} + +_do_bit_test() +{ + _field="$1" + _bits="$2"
The leading "_" is reserved for library functions and variables, not local test variables.
tests/xfs/307 line 53
Quoted 9 lines
tests/xfs/307 new file +9
-0+ + echo "testing ${_field} ${_bits} bits" | sed 's/u3/u/' + $XFS_DB_PROG -x -c "inode $FILE_INO" -c "write ${_field} 0" \ + $SCRATCH_DEV | sed 's/u3/u/' + num=1 + for n in `seq 0 1 ${_bits}`; do + $XFS_DB_PROG -x -c "inode $FILE_INO" \ + -c "write ${_field} ${num}" \ + $SCRATCH_DEV | sed 's/u3/u/'
On the third time, a local filter_xfs_db function is appropriate. ;)
....
tests/xfs/307 line 77
Quoted 9 lines
tests/xfs/307 new file +9
-0+_scratch_unmount +_scratch_mkfs >/dev/null 2>&1 +_scratch_mount + +# create the test file +echo "test file" > $SCRATCH_MNT/testfile + +# find the inode for the test file +FILE_INO=`ls -i $SCRATCH_MNT |awk '{print $1}'`
$SCRATCH_MNT/testfile?
Quoted 6 lines
tests/xfs/307 new file +6
-0+ +_scratch_unmount + +# test bit length constants +BMBT_EXNTFLAG_BITLEN=1 +BMBT_STARTOFF_BITLEN=54
tests/xfs/307 line 93
Quoted 10 lines
tests/xfs/307 new file +10
-0+BMBT_STARTBLOCK_BITLEN=52 +BMBT_BLOCKCOUNT_BITLEN=21 + +# Which version of the filesystem? +echo $XFS_MKFS_OPTIONS | grep "crc=1" > /dev/null +if [ $? == 1 ]; then + prefix="u" +else + prefix="u3" +fi
Urk. That's messy. And it points out that xfs/278 has this same problem. There's no reason that we need to test CRC enabled filesystems here, and testing XFS_MKFS_OPTIONS is not reliable, either as it will break if we change mkfs default behaviour. Perhaps we'd do best simply to change the xfs_db prefix here to be consistent for both v4 and v5 filesystesms ("u")? i.e. do this before we release 3.2.0 and we can just ignore the problem....
.....
tests/xfs/group line 189
Quoted 9 lines
Index: b/tests/xfs/group
===================================================================tests/xfs/group +1
-0@@ -186,3 +186,4 @@ 304 auto quick quota 305 auto quota 306 auto stress log metadata repair +307 auto db
Definitely a quick test, too. ;)
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH v2 1/1 xfstests: test setting XFS BMBT fields
In reply to Mark TinguelyTest the setting of the XFS BMBT fields. Runs through the valid bit values for each field and tests an illegal value.
---
v2:
Removed the test for CRC filesystems which also removes need for the nasty
prefixes and filtering output.
Remove the hex input as an integer test because it aint a number. Remove "__" from function variable names.
Add to quick test group.
tests/xfs/307 | 95 ++++++++++++++++++++++++++++++++++ tests/xfs/307.out | 148 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/group | 1 3 files changed, 244 insertions(+)
tests/xfs/307 new file +95 -0
@@ -0,0 +1,95 @@ +#! /bin/bash +# FS QA Test No. 307 +# +# Test the xfs_db write of the XFS BMBT entries. For each XFS BMBT field, +# write the value 0, each bit and finally the entry beyond the maximum legal +# value. Also makes sure a core write and hex input still work. +# +#----------------------------------------------------------------------- +# Copyright (c) 2014 SGI. 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.* +} + +_do_bit_test() +{ + field="$1" + bits="$2" + + echo "testing $field with $bits bits" + $XFS_DB_PROG -x -c "inode $FILE_INO" -c "write $field 0" $SCRATCH_DEV + num=1 + for n in `seq 0 1 $bits`; do + $XFS_DB_PROG -x -c "inode $FILE_INO" \ + -c "write $field $num" $SCRATCH_DEV + let num=$num*2 + done + echo +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +# real QA test starts here + +# Modify as appropriate. +_supported_fs xfs +_supported_os Linux + +_scratch_unmount +_scratch_mkfs >/dev/null 2>&1 +_scratch_mount + +# create the test file +echo "make a file with data so it has an extent" > $SCRATCH_MNT/file + +# find the inode for the test file +FILE_INO=`ls -i $SCRATCH_MNT |awk '{print $1}'` + +_scratch_unmount + +# test bit length constants +BMBT_EXNTFLAG_BITLEN=1 +BMBT_STARTOFF_BITLEN=54 +BMBT_STARTBLOCK_BITLEN=52 +BMBT_BLOCKCOUNT_BITLEN=21 + +# test setting the BMBT entries from 0 to past the valid number. +_do_bit_test "u.bmx[0].extentflag" $BMBT_EXNTFLAG_BITLEN +_do_bit_test "u.bmx[0].startoff" $BMBT_STARTOFF_BITLEN +_do_bit_test "u.bmx[0].startblock" $BMBT_STARTBLOCK_BITLEN +_do_bit_test "u.bmx[0].blockcount" $BMBT_BLOCKCOUNT_BITLEN +# test setting the 32 bit generation number +$XFS_DB_PROG -x -c "inode $FILE_INO" -c "write core.gen 0x5a" $SCRATCH_DEV +$XFS_DB_PROG -x -c "inode $FILE_INO" -c "write core.gen 0xa5" $SCRATCH_DEV +$XFS_DB_PROG -x -c "inode $FILE_INO" -c "write core.gen 0" $SCRATCH_DEV +status=0 +exit
tests/xfs/307.out new file +148 -0
148 lines not on this page · raw message
tests/xfs/group +1 -0
@@ -186,3 +186,4 @@ 304 auto quick quota 305 auto quota 306 auto stress log metadata repair +307 auto db quick
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 8 lines · Mark Tinguely
Test the setting of the XFS BMBT fields. Runs through the valid bit values for each field and tests an illegal value.
Signed-off-by Mark Tinguely <[email protected]>---
v2:
Removed the test for CRC filesystems which also removes need for the nasty
prefixes and filtering output.
Breaking CRC filesystem testing isn't the best approach, IMO. Using Eric's approach of turning off CRCs - as the bug fix will be in xfs_db binaries that support CRCs - is a much better idea.
It's also missing _require_scratch.
Quoted 1 line
Remove the hex input as an integer test because it aint a number.
And so we should be testing that it isn't endian converted.
So rather than go around again, here's an updated patch below that fixes all these issues.
Cheers,
Dave.
Signature · 26 lines
Dave Chinner [email protected] xfs: test setting XFS BMBT fields in xfs_db From: Mark Tinguely <[email protected]> Test the setting of the XFS BMBT fields via xfs_db. Runs through the valid bit values for each field and tests an illegal value. [dchinner: added _require_xfs_mkfs_crc and turned off crcs so that the test doesn't just fail on CRC enabled test runs.] [dchinner: added hex block values to check they don't get endian swapped.] Signed-off-by: Mark Tinguely <[email protected]> Reviewed-by: Dave Chinner <[email protected]> Signed-off-by: Dave Chinner <[email protected]> --- tests/xfs/001 | 98 +++++++++++++++++++++++++++++++++++ tests/xfs/001.out | 150 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/group | 1 + 3 files changed, 249 insertions(+)
tests/xfs/001 new file +98 -0
@@ -0,0 +1,98 @@ +#! /bin/bash +# FS QA Test No. 001 +# +# Test the xfs_db write of the XFS BMBT entries. For each XFS BMBT field, +# write the value 0, each bit and finally the entry beyond the maximum legal +# value. Also makes sure a core write and hex input still work. +# +#----------------------------------------------------------------------- +# Copyright (c) 2014 SGI. 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.* +} + +_do_bit_test() +{ + field="$1" + bits="$2" + + echo "testing $field with $bits bits" + $XFS_DB_PROG -x -c "inode $FILE_INO" -c "write $field 0" $SCRATCH_DEV + num=1 + for n in `seq 0 1 $bits`; do + $XFS_DB_PROG -x -c "inode $FILE_INO" \ + -c "write $field $num" $SCRATCH_DEV + let num=$num*2 + done + echo +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +# real QA test starts here + +# Modify as appropriate. +_supported_fs xfs +_supported_os Linux +_require_scratch +_require_xfs_mkfs_crc + +_scratch_mkfs -m crc=0 >/dev/null 2>&1 +_scratch_mount + +# create the test file +echo "make a file with data so it has an extent" > $SCRATCH_MNT/file + +# find the inode for the test file +FILE_INO=`ls -i $SCRATCH_MNT |awk '{print $1}'` + +_scratch_unmount + +# test bit length constants +BMBT_EXNTFLAG_BITLEN=1 +BMBT_STARTOFF_BITLEN=54 +BMBT_STARTBLOCK_BITLEN=52 +BMBT_BLOCKCOUNT_BITLEN=21 + +# test setting the BMBT entries from 0 to past the valid number. +_do_bit_test "u.bmx[0].extentflag" $BMBT_EXNTFLAG_BITLEN +_do_bit_test "u.bmx[0].startoff" $BMBT_STARTOFF_BITLEN +_do_bit_test "u.bmx[0].startblock" $BMBT_STARTBLOCK_BITLEN +_do_bit_test "u.bmx[0].blockcount" $BMBT_BLOCKCOUNT_BITLEN +# test setting the 32 bit generation number +$XFS_DB_PROG -x -c "inode $FILE_INO" -c "write core.gen 0x5a" $SCRATCH_DEV +$XFS_DB_PROG -x -c "inode $FILE_INO" -c "write core.gen 0xa5" $SCRATCH_DEV +$XFS_DB_PROG -x -c "inode $FILE_INO" -c "write core.gen 0" $SCRATCH_DEV +$XFS_DB_PROG -x -c "inode $FILE_INO" -c "write core.gen #5a5a" $SCRATCH_DEV +$XFS_DB_PROG -x -c "inode $FILE_INO" -c "write core.gen #a5a5" $SCRATCH_DEV +status=0 +exit
tests/xfs/001.out new file +150 -0
150 lines not on this page · raw message
tests/xfs/group +1 -0
@@ -1,3 +1,4 @@ +001 db auto quick 003 db auto quick 004 db auto quick 008 rw ioctl auto quick
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs