xfs/001: update to handle v5 filesystems
authorDarrick J. Wong <darrick.wong@oracle.com>
Wed, 4 Jul 2018 04:51:06 +0000 (21:51 -0700)
committerEryu Guan <guaneryu@gmail.com>
Sat, 14 Jul 2018 10:24:11 +0000 (18:24 +0800)
xfs/001 fuzzes various extent fields using xfs_db.  There's nothing
in it that's specific to v4 filesystems, so upgrade the test to be
able to handle v5 filesystems.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
common/xfs
tests/xfs/001

index 61a3c2d93d434c663eab9dadfca60c28d5933679..d971b4a8406980ba0bf27d594e993dd9cf7228aa 100644 (file)
@@ -774,3 +774,18 @@ _scratch_get_sfdir_prefix() {
        _scratch_xfs_db -c "inode ${dir_ino}" -c 'p' >> $seqres.full
        return 1
 }
+
+_scratch_get_bmx_prefix() {
+       local ino="$1"
+
+       for prefix in "u3.bmx" "u.bmx"; do
+               if [ -n "$(_scratch_xfs_get_metadata_field \
+                               "${prefix}[0].startblock" \
+                               "inode ${ino}")" ]; then
+                       echo "${prefix}"
+                       return 0
+               fi
+       done
+       _scratch_xfs_db -c "inode ${ino}" -c 'p' >> $seqres.full
+       return 1
+}
index ac86c3b1e4842c458ef91d730546578630bdab82..6ad3aba8454bc15c7c18e65b939ff431c23800be 100755 (executable)
@@ -49,9 +49,8 @@ _do_bit_test()
 _supported_fs xfs
 _supported_os Linux
 _require_scratch_nocheck
-_require_xfs_mkfs_crc
 
-_scratch_mkfs -m crc=0 >/dev/null 2>&1
+_scratch_mkfs >/dev/null 2>&1
 _scratch_mount
 
 # create the test file
@@ -68,11 +67,18 @@ BMBT_STARTOFF_BITLEN=54
 BMBT_STARTBLOCK_BITLEN=52
 BMBT_BLOCKCOUNT_BITLEN=21
 
+prefix=$(_scratch_get_bmx_prefix $FILE_INO)
+test -n "$prefix" || _fail "could not find bmx prefix from inode $FILE_INO"
+
+filter_output() {
+       sed -e "s/${prefix}/u.bmx/g"
+}
+
 # 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
+_do_bit_test "${prefix}[0].extentflag" $BMBT_EXNTFLAG_BITLEN | filter_output
+_do_bit_test "${prefix}[0].startoff" $BMBT_STARTOFF_BITLEN | filter_output
+_do_bit_test "${prefix}[0].startblock" $BMBT_STARTBLOCK_BITLEN | filter_output
+_do_bit_test "${prefix}[0].blockcount" $BMBT_BLOCKCOUNT_BITLEN | filter_output
 # test setting the 32 bit generation number
 _scratch_xfs_db -x -c "inode $FILE_INO" -c "write core.gen 0x5a"
 _scratch_xfs_db -x -c "inode $FILE_INO" -c "write core.gen 0xa5"