mirror of
https://github.com/linux-apfs/apfstests.git
synced 2026-05-01 15:01:44 -07:00
btrfs/14[01]: Use proper helper to get both devid and physical for corruption
[BUG] With btrfs-progs v5.4, btrfs/140 and btrfs/141 will fail. [CAUSE] Both tests are testing re-silvering of RAID1, thus they need to corrupt on-disk data. This requires to do manual logical -> physical bytes mapping in the test case. However the test case itself uses too many hard coded helper to grab physical offset, which will change with mkfs.btrfs. [FIX] Use more flex helper, to get both devid and physical for such corruption. Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Eryu Guan <guaneryu@gmail.com> Signed-off-by: Eryu Guan <guaneryu@gmail.com>
This commit is contained in:
+27
-7
@@ -46,10 +46,26 @@ _require_odirect
|
|||||||
|
|
||||||
get_physical()
|
get_physical()
|
||||||
{
|
{
|
||||||
# $1 is logical address
|
local logical=$1
|
||||||
# print chunk tree and find devid 2 which is $SCRATCH_DEV
|
local stripe=$2
|
||||||
$BTRFS_UTIL_PROG inspect-internal dump-tree -t 3 $SCRATCH_DEV | \
|
$BTRFS_UTIL_PROG inspect-internal dump-tree -t 3 $SCRATCH_DEV | \
|
||||||
grep $1 -A 6 | awk '($1 ~ /stripe/ && $3 ~ /devid/ && $4 ~ /1/) { print $6 }'
|
grep $logical -A 6 | \
|
||||||
|
$AWK_PROG "(\$1 ~ /stripe/ && \$3 ~ /devid/ && \$2 ~ /$stripe/) { print \$6 }"
|
||||||
|
}
|
||||||
|
|
||||||
|
get_devid()
|
||||||
|
{
|
||||||
|
local logical=$1
|
||||||
|
local stripe=$2
|
||||||
|
$BTRFS_UTIL_PROG inspect-internal dump-tree -t 3 $SCRATCH_DEV | \
|
||||||
|
grep $logical -A 6 | \
|
||||||
|
$AWK_PROG "(\$1 ~ /stripe/ && \$3 ~ /devid/ && \$2 ~ /$stripe/) { print \$4 }"
|
||||||
|
}
|
||||||
|
|
||||||
|
get_device_path()
|
||||||
|
{
|
||||||
|
local devid=$1
|
||||||
|
echo "$SCRATCH_DEV_POOL" | $AWK_PROG "{print \$$devid}"
|
||||||
}
|
}
|
||||||
|
|
||||||
_scratch_dev_pool_get 2
|
_scratch_dev_pool_get 2
|
||||||
@@ -72,11 +88,15 @@ echo "step 2......corrupt file extent" >>$seqres.full
|
|||||||
|
|
||||||
${FILEFRAG_PROG} -v $SCRATCH_MNT/foobar >> $seqres.full
|
${FILEFRAG_PROG} -v $SCRATCH_MNT/foobar >> $seqres.full
|
||||||
logical_in_btrfs=`${FILEFRAG_PROG} -v $SCRATCH_MNT/foobar | _filter_filefrag | cut -d '#' -f 1`
|
logical_in_btrfs=`${FILEFRAG_PROG} -v $SCRATCH_MNT/foobar | _filter_filefrag | cut -d '#' -f 1`
|
||||||
physical_on_scratch=`get_physical ${logical_in_btrfs}`
|
physical=$(get_physical ${logical_in_btrfs} 1)
|
||||||
|
devid=$(get_devid ${logical_in_btrfs} 1)
|
||||||
|
devpath=$(get_device_path ${devid})
|
||||||
|
|
||||||
_scratch_unmount
|
_scratch_unmount
|
||||||
$XFS_IO_PROG -d -c "pwrite -S 0xbb -b 64K $physical_on_scratch 64K" $SCRATCH_DEV |\
|
|
||||||
_filter_xfs_io_offset
|
echo " corrupt stripe #1, devid $devid devpath $devpath physical $physical" \
|
||||||
|
>> $seqres.full
|
||||||
|
$XFS_IO_PROG -d -c "pwrite -S 0xbb -b 64K $physical 64K" $devpath > /dev/null
|
||||||
|
|
||||||
_scratch_mount
|
_scratch_mount
|
||||||
|
|
||||||
@@ -96,7 +116,7 @@ done
|
|||||||
_scratch_unmount
|
_scratch_unmount
|
||||||
|
|
||||||
# check if the repair works
|
# check if the repair works
|
||||||
$XFS_IO_PROG -d -c "pread -v -b 512 $physical_on_scratch 512" $SCRATCH_DEV |\
|
$XFS_IO_PROG -d -c "pread -v -b 512 $physical 512" $devpath |\
|
||||||
_filter_xfs_io_offset
|
_filter_xfs_io_offset
|
||||||
|
|
||||||
_scratch_dev_pool_put
|
_scratch_dev_pool_put
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
QA output created by 140
|
QA output created by 140
|
||||||
wrote 131072/131072 bytes
|
wrote 131072/131072 bytes
|
||||||
XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
||||||
wrote 65536/65536 bytes
|
|
||||||
XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
||||||
XXXXXXXX: aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa ................
|
XXXXXXXX: aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa ................
|
||||||
XXXXXXXX: aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa ................
|
XXXXXXXX: aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa ................
|
||||||
XXXXXXXX: aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa ................
|
XXXXXXXX: aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa ................
|
||||||
|
|||||||
+26
-7
@@ -46,10 +46,26 @@ _require_command "$FILEFRAG_PROG" filefrag
|
|||||||
|
|
||||||
get_physical()
|
get_physical()
|
||||||
{
|
{
|
||||||
# $1 is logical address
|
local logical=$1
|
||||||
# print chunk tree and find devid 2 which is $SCRATCH_DEV
|
local stripe=$2
|
||||||
$BTRFS_UTIL_PROG inspect-internal dump-tree -t 3 $SCRATCH_DEV | \
|
$BTRFS_UTIL_PROG inspect-internal dump-tree -t 3 $SCRATCH_DEV | \
|
||||||
grep $1 -A 6 | awk '($1 ~ /stripe/ && $3 ~ /devid/ && $4 ~ /1/) { print $6 }'
|
grep $logical -A 6 | \
|
||||||
|
$AWK_PROG "(\$1 ~ /stripe/ && \$3 ~ /devid/ && \$2 ~ /$stripe/) { print \$6 }"
|
||||||
|
}
|
||||||
|
|
||||||
|
get_devid()
|
||||||
|
{
|
||||||
|
local logical=$1
|
||||||
|
local stripe=$2
|
||||||
|
$BTRFS_UTIL_PROG inspect-internal dump-tree -t 3 $SCRATCH_DEV | \
|
||||||
|
grep $logical -A 6 | \
|
||||||
|
$AWK_PROG "(\$1 ~ /stripe/ && \$3 ~ /devid/ && \$2 ~ /$stripe/) { print \$4 }"
|
||||||
|
}
|
||||||
|
|
||||||
|
get_device_path()
|
||||||
|
{
|
||||||
|
local devid=$1
|
||||||
|
echo "$SCRATCH_DEV_POOL" | $AWK_PROG "{print \$$devid}"
|
||||||
}
|
}
|
||||||
|
|
||||||
_scratch_dev_pool_get 2
|
_scratch_dev_pool_get 2
|
||||||
@@ -72,11 +88,14 @@ echo "step 2......corrupt file extent" >>$seqres.full
|
|||||||
|
|
||||||
${FILEFRAG_PROG} -v $SCRATCH_MNT/foobar >> $seqres.full
|
${FILEFRAG_PROG} -v $SCRATCH_MNT/foobar >> $seqres.full
|
||||||
logical_in_btrfs=`${FILEFRAG_PROG} -v $SCRATCH_MNT/foobar | _filter_filefrag | cut -d '#' -f 1`
|
logical_in_btrfs=`${FILEFRAG_PROG} -v $SCRATCH_MNT/foobar | _filter_filefrag | cut -d '#' -f 1`
|
||||||
physical_on_scratch=`get_physical ${logical_in_btrfs}`
|
physical=$(get_physical ${logical_in_btrfs} 1)
|
||||||
|
devid=$(get_devid ${logical_in_btrfs} 1)
|
||||||
|
devpath=$(get_device_path ${devid})
|
||||||
|
|
||||||
_scratch_unmount
|
_scratch_unmount
|
||||||
$XFS_IO_PROG -d -c "pwrite -S 0xbb -b 64K $physical_on_scratch 64K" $SCRATCH_DEV |\
|
echo " corrupt stripe #1, devid $devid devpath $devpath physical $physical" \
|
||||||
_filter_xfs_io_offset
|
>> $seqres.full
|
||||||
|
$XFS_IO_PROG -d -c "pwrite -S 0xbb -b 64K $physical 64K" $devpath > /dev/null
|
||||||
|
|
||||||
_scratch_mount
|
_scratch_mount
|
||||||
|
|
||||||
@@ -97,7 +116,7 @@ done
|
|||||||
_scratch_unmount
|
_scratch_unmount
|
||||||
|
|
||||||
# check if the repair works
|
# check if the repair works
|
||||||
$XFS_IO_PROG -c "pread -v -b 512 $physical_on_scratch 512" $SCRATCH_DEV |\
|
$XFS_IO_PROG -c "pread -v -b 512 $physical 512" $devpath |\
|
||||||
_filter_xfs_io_offset
|
_filter_xfs_io_offset
|
||||||
|
|
||||||
_scratch_dev_pool_put
|
_scratch_dev_pool_put
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
QA output created by 141
|
QA output created by 141
|
||||||
wrote 131072/131072 bytes
|
wrote 131072/131072 bytes
|
||||||
XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
||||||
wrote 65536/65536 bytes
|
|
||||||
XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
||||||
XXXXXXXX: aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa ................
|
XXXXXXXX: aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa ................
|
||||||
XXXXXXXX: aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa ................
|
XXXXXXXX: aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa ................
|
||||||
XXXXXXXX: aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa ................
|
XXXXXXXX: aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa ................
|
||||||
|
|||||||
Reference in New Issue
Block a user