mirror of
https://github.com/linux-apfs/apfstests.git
synced 2026-05-01 15:01:44 -07:00
xfs: fix $XFS_DB_PROG usage
xfs_db requires us to pass in the log device, if any; this can be accomplished via _scratch_xfs_db_options (if we're operating on the scratch device, anyway). However, many of the tests/xfs/ scripts pass only $SCRATCH_DEV directly, so they'll fail if we test with an external log. Fix that by adding a new _scratch_xfs_db helper. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Eryu Guan <eguan@redhat.com>
This commit is contained in:
committed by
Eryu Guan
parent
fff869cb9c
commit
c08ebd092d
+8
-8
@@ -44,11 +44,11 @@ _do_bit_test()
|
||||
bits="$2"
|
||||
|
||||
echo "testing $field with $bits bits"
|
||||
$XFS_DB_PROG -x -c "inode $FILE_INO" -c "write $field 0" $SCRATCH_DEV
|
||||
_scratch_xfs_db -x -c "inode $FILE_INO" -c "write $field 0"
|
||||
num=1
|
||||
for n in `seq 0 1 $bits`; do
|
||||
$XFS_DB_PROG -x -c "inode $FILE_INO" \
|
||||
-c "write $field $num" $SCRATCH_DEV
|
||||
_scratch_xfs_db -x -c "inode $FILE_INO" \
|
||||
-c "write $field $num"
|
||||
let num=$num*2
|
||||
done
|
||||
echo
|
||||
@@ -89,10 +89,10 @@ _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
|
||||
_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"
|
||||
_scratch_xfs_db -x -c "inode $FILE_INO" -c "write core.gen 0"
|
||||
_scratch_xfs_db -x -c "inode $FILE_INO" -c "write core.gen #5a5a"
|
||||
_scratch_xfs_db -x -c "inode $FILE_INO" -c "write core.gen #a5a5"
|
||||
status=0
|
||||
exit
|
||||
|
||||
+2
-2
@@ -62,8 +62,8 @@ _scratch_mkfs_xfs -m crc=0 -d size=128m >> $seqres.full 2>&1 || _fail "mkfs fail
|
||||
# Scribble past a couple V4 secondary superblocks to populate sb_crc
|
||||
# (We can't write to the structure member because it doesn't exist
|
||||
# on a v4 superblock, so we use the data type & "write fill")
|
||||
$XFS_DB_PROG -x -c "sb 1" -c "type data" -c "write fill 0xff 224 4" $SCRATCH_DEV
|
||||
$XFS_DB_PROG -x -c "sb 2" -c "type data" -c "write fill 0xff 224 4" $SCRATCH_DEV
|
||||
_scratch_xfs_db -x -c "sb 1" -c "type data" -c "write fill 0xff 224 4"
|
||||
_scratch_xfs_db -x -c "sb 2" -c "type data" -c "write fill 0xff 224 4"
|
||||
|
||||
_scratch_mount
|
||||
|
||||
|
||||
+2
-2
@@ -100,8 +100,8 @@ _scratch_mkfs | _filter_mkfs > /dev/null 2> $tmp.mkfs || _fail "mkfs failed"
|
||||
. $tmp.mkfs # import agcount
|
||||
|
||||
# corrupt the last secondary sb in the fs
|
||||
$XFS_DB_PROG -x -c "sb $((agcount - 1))" -c "type data" \
|
||||
-c "write fill 0xff 0 512" $SCRATCH_DEV
|
||||
_scratch_xfs_db -x -c "sb $((agcount - 1))" -c "type data" \
|
||||
-c "write fill 0xff 0 512"
|
||||
|
||||
# attempt to repair
|
||||
_xfs_repair_noscan
|
||||
|
||||
+3
-3
@@ -64,9 +64,9 @@ _test_uuid()
|
||||
ACTION=$1
|
||||
EXPECTED_UUID=$2
|
||||
|
||||
$XFS_DB_PROG -x -c "uuid $ACTION" $SCRATCH_DEV \
|
||||
_scratch_xfs_db -x -c "uuid $ACTION" \
|
||||
| _filter_uuid $EXPECTED_UUID
|
||||
NEW_UUID=`$XFS_DB_PROG -c "uuid" $SCRATCH_DEV | awk '{print $NF}'`
|
||||
NEW_UUID=`_scratch_xfs_db -c "uuid" | awk '{print $NF}'`
|
||||
_check_scratch_fs
|
||||
_scratch_mount || _fail "Mount failed after UUID $ACTION"
|
||||
_scratch_unmount
|
||||
@@ -83,7 +83,7 @@ rm -f $seqres.full
|
||||
|
||||
_scratch_mkfs_xfs -m crc=1 >> $seqres.full 2>&1 || _fail "mkfs failed"
|
||||
|
||||
ORIG_UUID=`$XFS_DB_PROG -c "uuid" $SCRATCH_DEV | awk '{print $NF}'`
|
||||
ORIG_UUID=`_scratch_xfs_db -c "uuid" | awk '{print $NF}'`
|
||||
|
||||
_scratch_mount
|
||||
# Put some stuff on the fs
|
||||
|
||||
+1
-1
@@ -87,7 +87,7 @@ _scratch_xfs_repair -n >> $seqres.full 2>&1 || _fail "xfs_repair should not fail
|
||||
|
||||
echo "+ corrupt image"
|
||||
for ag in $(seq 1 $((agcount - 1))) 0; do
|
||||
$XFS_DB_PROG -x -c "agf ${ag}" -c "agf ${ag}" -c "stack" -c "blocktrash -x 32 -o +64 -y 4096 -z ${FUZZ_ARGS}" "${SCRATCH_DEV}" >> $seqres.full 2>&1
|
||||
_scratch_xfs_db -x -c "agf ${ag}" -c "agf ${ag}" -c "stack" -c "blocktrash -x 32 -o +64 -y 4096 -z ${FUZZ_ARGS}" >> $seqres.full 2>&1
|
||||
done
|
||||
|
||||
# Try to append to files; this should fail
|
||||
|
||||
+1
-1
@@ -86,7 +86,7 @@ _scratch_xfs_repair -n >> $seqres.full 2>&1 || _fail "xfs_repair should not fail
|
||||
|
||||
echo "+ corrupt image"
|
||||
for ag in $(seq 1 $((agcount - 1))) 0; do
|
||||
$XFS_DB_PROG -x -c "agi ${ag}" -c "agi ${ag}" -c "stack" -c "blocktrash -x 32 -o +64 -y 4096 -z ${FUZZ_ARGS}" "${SCRATCH_DEV}" >> $seqres.full 2>&1
|
||||
_scratch_xfs_db -x -c "agi ${ag}" -c "agi ${ag}" -c "stack" -c "blocktrash -x 32 -o +64 -y 4096 -z ${FUZZ_ARGS}" >> $seqres.full 2>&1
|
||||
done
|
||||
|
||||
echo "+ mount image"
|
||||
|
||||
+1
-1
@@ -86,7 +86,7 @@ _scratch_xfs_repair -n >> $seqres.full 2>&1 || _fail "xfs_repair should not fail
|
||||
|
||||
echo "+ corrupt image"
|
||||
for ag in $(seq 1 $((agcount - 1))) 0; do
|
||||
$XFS_DB_PROG -x -c "agfl ${ag}" -c "agfl ${ag}" -c "stack" -c "blocktrash -x 32 -o +64 -y 4096 -z ${FUZZ_ARGS}" "${SCRATCH_DEV}" >> $seqres.full 2>&1
|
||||
_scratch_xfs_db -x -c "agfl ${ag}" -c "agfl ${ag}" -c "stack" -c "blocktrash -x 32 -o +64 -y 4096 -z ${FUZZ_ARGS}" >> $seqres.full 2>&1
|
||||
done
|
||||
|
||||
# Try to append to files; this should fail
|
||||
|
||||
+1
-1
@@ -86,7 +86,7 @@ _scratch_xfs_repair -n >> $seqres.full 2>&1 || _fail "xfs_repair should not fail
|
||||
|
||||
echo "+ corrupt image"
|
||||
for ag in $(seq 1 $((agcount - 1))) 0; do
|
||||
$XFS_DB_PROG -x -c "agf ${ag}" -c "agf ${ag}" -c "addr bnoroot" -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" "${SCRATCH_DEV}" >> $seqres.full 2>&1
|
||||
_scratch_xfs_db -x -c "agf ${ag}" -c "agf ${ag}" -c "addr bnoroot" -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" >> $seqres.full 2>&1
|
||||
done
|
||||
|
||||
# Try to append to files; this should fail
|
||||
|
||||
+1
-1
@@ -86,7 +86,7 @@ _scratch_xfs_repair -n >> $seqres.full 2>&1 || _fail "xfs_repair should not fail
|
||||
|
||||
echo "+ corrupt image"
|
||||
for ag in $(seq 1 $((agcount - 1))) 0; do
|
||||
$XFS_DB_PROG -x -c "agf ${ag}" -c "agf ${ag}" -c "addr cntroot" -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" "${SCRATCH_DEV}" >> $seqres.full 2>&1
|
||||
_scratch_xfs_db -x -c "agf ${ag}" -c "agf ${ag}" -c "addr cntroot" -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" >> $seqres.full 2>&1
|
||||
done
|
||||
|
||||
# Try to append to files; this should fail
|
||||
|
||||
+1
-1
@@ -86,7 +86,7 @@ _scratch_xfs_repair -n >> $seqres.full 2>&1 || _fail "xfs_repair should not fail
|
||||
|
||||
echo "+ corrupt image"
|
||||
for ag in $(seq 1 $((agcount - 1))) 0; do
|
||||
$XFS_DB_PROG -x -c "agi ${ag}" -c "agi ${ag}" -c "addr root" -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" "${SCRATCH_DEV}" >> $seqres.full 2>&1
|
||||
_scratch_xfs_db -x -c "agi ${ag}" -c "agi ${ag}" -c "addr root" -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" >> $seqres.full 2>&1
|
||||
done
|
||||
|
||||
echo "+ mount image"
|
||||
|
||||
+1
-1
@@ -89,7 +89,7 @@ _scratch_xfs_repair -n >> $seqres.full 2>&1 || _fail "xfs_repair should not fail
|
||||
|
||||
echo "+ corrupt image"
|
||||
for ag in $(seq 1 $((agcount - 1))) 0; do
|
||||
$XFS_DB_PROG -x -c "agi ${ag}" -c "agi ${ag}" -c "addr free_root" -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" "${SCRATCH_DEV}" >> $seqres.full 2>&1
|
||||
_scratch_xfs_db -x -c "agi ${ag}" -c "agi ${ag}" -c "addr free_root" -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" >> $seqres.full 2>&1
|
||||
done
|
||||
|
||||
echo "+ mount image"
|
||||
|
||||
+2
-2
@@ -95,8 +95,8 @@ echo "+ check fs"
|
||||
_scratch_xfs_repair -n >> $seqres.full 2>&1 || _fail "xfs_repair should not fail"
|
||||
|
||||
echo "+ corrupt image"
|
||||
logstart="$($XFS_DB_PROG -c 'sb 0' -c 'p' "${SCRATCH_DEV}" | grep '^logstart =' | cut -d ' ' -f 3)"
|
||||
logstart="$($XFS_DB_PROG -c "convert fsblock ${logstart} byte" "${SCRATCH_DEV}" | sed -e 's/^.*(\([0-9]*\).*$/\1/g')"
|
||||
logstart="$(_scratch_xfs_db -c 'sb 0' -c 'p' | grep '^logstart =' | cut -d ' ' -f 3)"
|
||||
logstart="$(_scratch_xfs_db -c "convert fsblock ${logstart} byte" | sed -e 's/^.*(\([0-9]*\).*$/\1/g')"
|
||||
logblocks="$(xfs_db -c 'sb 0' -c 'p' "${SCRATCH_DEV}" | grep '^logblocks =' | cut -d ' ' -f 3)"
|
||||
$XFS_IO_PROG -f -c "pwrite -S 0x62 ${logstart} $((logblocks * blksz))" "${SCRATCH_DEV}" >> $seqres.full
|
||||
|
||||
|
||||
+1
-1
@@ -78,7 +78,7 @@ echo "+ check dir"
|
||||
__populate_check_xfs_dir "${SCRATCH_DEV}" "${inode}" block
|
||||
|
||||
echo "+ corrupt dir"
|
||||
$XFS_DB_PROG -x -c "inode ${inode}" -c 'dblock 0' -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" "${SCRATCH_DEV}" >> $seqres.full
|
||||
_scratch_xfs_db -x -c "inode ${inode}" -c 'dblock 0' -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" >> $seqres.full
|
||||
|
||||
echo "+ mount image"
|
||||
_scratch_mount
|
||||
|
||||
+2
-2
@@ -80,8 +80,8 @@ __populate_check_xfs_dir "${SCRATCH_DEV}" "${inode}" leaf
|
||||
echo "+ corrupt dir"
|
||||
loff=0
|
||||
while true; do
|
||||
$XFS_DB_PROG -x -c "inode ${inode}" -c "dblock ${loff}" -c "stack" "${SCRATCH_DEV}" | grep -q 'file data block is unmapped' && break
|
||||
$XFS_DB_PROG -x -c "inode ${inode}" -c "dblock ${loff}" -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" "${SCRATCH_DEV}" >> $seqres.full
|
||||
_scratch_xfs_db -x -c "inode ${inode}" -c "dblock ${loff}" -c "stack" | grep -q 'file data block is unmapped' && break
|
||||
_scratch_xfs_db -x -c "inode ${inode}" -c "dblock ${loff}" -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" >> $seqres.full
|
||||
loff="$((loff + 1))"
|
||||
done
|
||||
|
||||
|
||||
+1
-1
@@ -78,7 +78,7 @@ echo "+ check dir"
|
||||
__populate_check_xfs_dir "${SCRATCH_DEV}" "${inode}" leaf
|
||||
|
||||
echo "+ corrupt dir"
|
||||
$XFS_DB_PROG -x -c "inode ${inode}" -c "dblock ${leaf_lblk}" -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" "${SCRATCH_DEV}" >> $seqres.full
|
||||
_scratch_xfs_db -x -c "inode ${inode}" -c "dblock ${leaf_lblk}" -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" >> $seqres.full
|
||||
|
||||
echo "+ mount image"
|
||||
_scratch_mount
|
||||
|
||||
+2
-2
@@ -80,8 +80,8 @@ __populate_check_xfs_dir "${SCRATCH_DEV}" "${inode}" node
|
||||
echo "+ corrupt dir"
|
||||
loff=0
|
||||
while true; do
|
||||
$XFS_DB_PROG -x -c "inode ${inode}" -c "dblock ${loff}" -c "stack" "${SCRATCH_DEV}" | grep -q 'file data block is unmapped' && break
|
||||
$XFS_DB_PROG -x -c "inode ${inode}" -c "dblock ${loff}" -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" "${SCRATCH_DEV}" >> $seqres.full
|
||||
_scratch_xfs_db -x -c "inode ${inode}" -c "dblock ${loff}" -c "stack" | grep -q 'file data block is unmapped' && break
|
||||
_scratch_xfs_db -x -c "inode ${inode}" -c "dblock ${loff}" -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" >> $seqres.full
|
||||
loff="$((loff + 1))"
|
||||
done
|
||||
|
||||
|
||||
+2
-2
@@ -80,8 +80,8 @@ __populate_check_xfs_dir "${SCRATCH_DEV}" "${inode}" node
|
||||
echo "+ corrupt dir"
|
||||
loff="${leaf_lblk}"
|
||||
while true; do
|
||||
$XFS_DB_PROG -x -c "inode ${inode}" -c "dblock ${loff}" -c "stack" "${SCRATCH_DEV}" | grep -q 'file data block is unmapped' && break
|
||||
$XFS_DB_PROG -x -c "inode ${inode}" -c "dblock ${loff}" -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" "${SCRATCH_DEV}" >> $seqres.full
|
||||
_scratch_xfs_db -x -c "inode ${inode}" -c "dblock ${loff}" -c "stack" | grep -q 'file data block is unmapped' && break
|
||||
_scratch_xfs_db -x -c "inode ${inode}" -c "dblock ${loff}" -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" >> $seqres.full
|
||||
loff="$((loff + 1))"
|
||||
done
|
||||
|
||||
|
||||
+1
-1
@@ -64,7 +64,7 @@ INO=`ls -i $SCRATCH_MNT/512 | awk '{print $1}'`
|
||||
_scratch_unmount
|
||||
|
||||
# Figure out where that middle inode starts
|
||||
BYTE=`$XFS_DB_PROG -c "convert inode $INO byte" $SCRATCH_DEV \
|
||||
BYTE=`_scratch_xfs_db -c "convert inode $INO byte" \
|
||||
| awk '{print $2}' | sed s/[\(\)]//g`
|
||||
|
||||
echo Blat inode clusters
|
||||
|
||||
+2
-2
@@ -80,8 +80,8 @@ __populate_check_xfs_dir "${SCRATCH_DEV}" "${inode}" node
|
||||
echo "+ corrupt dir"
|
||||
loff="${node_lblk}"
|
||||
while true; do
|
||||
$XFS_DB_PROG -x -c "inode ${inode}" -c "dblock ${loff}" -c "stack" "${SCRATCH_DEV}" | grep -q 'file data block is unmapped' && break
|
||||
$XFS_DB_PROG -x -c "inode ${inode}" -c "dblock ${loff}" -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" "${SCRATCH_DEV}" >> $seqres.full
|
||||
_scratch_xfs_db -x -c "inode ${inode}" -c "dblock ${loff}" -c "stack" | grep -q 'file data block is unmapped' && break
|
||||
_scratch_xfs_db -x -c "inode ${inode}" -c "dblock ${loff}" -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" >> $seqres.full
|
||||
loff="$((loff + 1))"
|
||||
done
|
||||
|
||||
|
||||
+2
-2
@@ -80,8 +80,8 @@ __populate_check_xfs_dir "${SCRATCH_DEV}" "${inode}" btree
|
||||
echo "+ corrupt dir"
|
||||
loff=0
|
||||
while true; do
|
||||
$XFS_DB_PROG -x -c "inode ${inode}" -c "dblock ${loff}" -c "stack" "${SCRATCH_DEV}" | grep -q 'file data block is unmapped' && break
|
||||
$XFS_DB_PROG -x -c "inode ${inode}" -c "dblock ${loff}" -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" "${SCRATCH_DEV}" >> $seqres.full
|
||||
_scratch_xfs_db -x -c "inode ${inode}" -c "dblock ${loff}" -c "stack" | grep -q 'file data block is unmapped' && break
|
||||
_scratch_xfs_db -x -c "inode ${inode}" -c "dblock ${loff}" -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" >> $seqres.full
|
||||
loff="$((loff + 1))"
|
||||
done
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user