fstests.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fstests: btrfs/14[01]: Use proper helper to get both devid and physical for corruption
@ 2019-12-12  8:31 Qu Wenruo
  2019-12-17 17:43 ` Filipe Manana
  0 siblings, 1 reply; 3+ messages in thread
From: Qu Wenruo @ 2019-12-12  8:31 UTC (permalink / raw)
  To: fstests, linux-btrfs

[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>
---
 tests/btrfs/140     | 36 ++++++++++++++++++++++++++++--------
 tests/btrfs/140.out |  2 --
 tests/btrfs/141     | 33 ++++++++++++++++++++++++++-------
 tests/btrfs/141.out |  2 --
 4 files changed, 54 insertions(+), 19 deletions(-)

diff --git a/tests/btrfs/140 b/tests/btrfs/140
index 1c5aa679..5c6de733 100755
--- a/tests/btrfs/140
+++ b/tests/btrfs/140
@@ -46,10 +46,26 @@ _require_odirect
 
 get_physical()
 {
-	# $1 is logical address
-	# print chunk tree and find devid 2 which is $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 }'
+	local logical=$1
+	local stripe=$2
+        $BTRFS_UTIL_PROG inspect-internal dump-tree -t 3 $SCRATCH_DEV | \
+		grep $logical -A 6 | \
+		awk "(\$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 "(\$1 ~ /stripe/ && \$3 ~ /devid/ && \$2 ~ /$stripe/) { print \$4 }"
+}
+
+get_device_path()
+{
+	local devid=$1
+	echo "$SCRATCH_DEV_POOL" | awk "{print \$$devid}"
 }
 
 _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
 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
-$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
 
@@ -96,7 +116,7 @@ done
 _scratch_unmount
 
 # 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
 
 _scratch_dev_pool_put
diff --git a/tests/btrfs/140.out b/tests/btrfs/140.out
index f3fdf174..fb5aa108 100644
--- a/tests/btrfs/140.out
+++ b/tests/btrfs/140.out
@@ -1,8 +1,6 @@
 QA output created by 140
 wrote 131072/131072 bytes
 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  ................
diff --git a/tests/btrfs/141 b/tests/btrfs/141
index 186d18c8..2f5ad1a2 100755
--- a/tests/btrfs/141
+++ b/tests/btrfs/141
@@ -46,10 +46,26 @@ _require_command "$FILEFRAG_PROG" filefrag
 
 get_physical()
 {
-        # $1 is logical address
-        # print chunk tree and find devid 2 which is $SCRATCH_DEV
+	local logical=$1
+	local stripe=$2
         $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 "(\$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 "(\$1 ~ /stripe/ && \$3 ~ /devid/ && \$2 ~ /$stripe/) { print \$4 }"
+}
+
+get_device_path()
+{
+	local devid=$1
+	echo "$SCRATCH_DEV_POOL" | awk "{print \$$devid}"
 }
 
 _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
 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
-$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
 
@@ -97,7 +116,7 @@ done
 _scratch_unmount
 
 # 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
 
 _scratch_dev_pool_put
diff --git a/tests/btrfs/141.out b/tests/btrfs/141.out
index 116f98a2..4b8be189 100644
--- a/tests/btrfs/141.out
+++ b/tests/btrfs/141.out
@@ -1,8 +1,6 @@
 QA output created by 141
 wrote 131072/131072 bytes
 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  ................
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] fstests: btrfs/14[01]: Use proper helper to get both devid and physical for corruption
  2019-12-12  8:31 [PATCH] fstests: btrfs/14[01]: Use proper helper to get both devid and physical for corruption Qu Wenruo
@ 2019-12-17 17:43 ` Filipe Manana
  2019-12-18  0:20   ` Qu Wenruo
  0 siblings, 1 reply; 3+ messages in thread
From: Filipe Manana @ 2019-12-17 17:43 UTC (permalink / raw)
  To: Qu Wenruo; +Cc: fstests, linux-btrfs

On Thu, Dec 12, 2019 at 8:31 AM Qu Wenruo <wqu@suse.com> wrote:
>
> [BUG]
> With btrfs-progs v5.4, btrfs/140 and btrfs/141 will fail.

Oddly, it doesn't fail for me. Only 142, 143, 157 and 158.

However this seems correct.

>
> [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

more flex -> more flexible

> corruption.
>
> Signed-off-by: Qu Wenruo <wqu@suse.com>
> ---
>  tests/btrfs/140     | 36 ++++++++++++++++++++++++++++--------
>  tests/btrfs/140.out |  2 --
>  tests/btrfs/141     | 33 ++++++++++++++++++++++++++-------
>  tests/btrfs/141.out |  2 --
>  4 files changed, 54 insertions(+), 19 deletions(-)
>
> diff --git a/tests/btrfs/140 b/tests/btrfs/140
> index 1c5aa679..5c6de733 100755
> --- a/tests/btrfs/140
> +++ b/tests/btrfs/140
> @@ -46,10 +46,26 @@ _require_odirect
>
>  get_physical()
>  {
> -       # $1 is logical address
> -       # print chunk tree and find devid 2 which is $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 }'
> +       local logical=$1
> +       local stripe=$2
> +        $BTRFS_UTIL_PROG inspect-internal dump-tree -t 3 $SCRATCH_DEV | \
> +               grep $logical -A 6 | \
> +               awk "(\$1 ~ /stripe/ && \$3 ~ /devid/ && \$2 ~ /$stripe/) { print \$6 }"
> +}

Same as before, $AWK_PROG.

These helpers seems the same as in 142 and 143 (and 141, updated later
in this patch).
I know this patch isn't introducing them, but we should move them into
helpers at common/btrfs one day.

Thanks.

> +
> +get_devid()
> +{
> +       local logical=$1
> +       local stripe=$2
> +        $BTRFS_UTIL_PROG inspect-internal dump-tree -t 3 $SCRATCH_DEV | \
> +               grep $logical -A 6 | \
> +               awk "(\$1 ~ /stripe/ && \$3 ~ /devid/ && \$2 ~ /$stripe/) { print \$4 }"
> +}
> +
> +get_device_path()
> +{
> +       local devid=$1
> +       echo "$SCRATCH_DEV_POOL" | awk "{print \$$devid}"
>  }
>
>  _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
>  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
> -$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
>
> @@ -96,7 +116,7 @@ done
>  _scratch_unmount
>
>  # 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
>
>  _scratch_dev_pool_put
> diff --git a/tests/btrfs/140.out b/tests/btrfs/140.out
> index f3fdf174..fb5aa108 100644
> --- a/tests/btrfs/140.out
> +++ b/tests/btrfs/140.out
> @@ -1,8 +1,6 @@
>  QA output created by 140
>  wrote 131072/131072 bytes
>  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  ................
> diff --git a/tests/btrfs/141 b/tests/btrfs/141
> index 186d18c8..2f5ad1a2 100755
> --- a/tests/btrfs/141
> +++ b/tests/btrfs/141
> @@ -46,10 +46,26 @@ _require_command "$FILEFRAG_PROG" filefrag
>
>  get_physical()
>  {
> -        # $1 is logical address
> -        # print chunk tree and find devid 2 which is $SCRATCH_DEV
> +       local logical=$1
> +       local stripe=$2
>          $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 "(\$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 "(\$1 ~ /stripe/ && \$3 ~ /devid/ && \$2 ~ /$stripe/) { print \$4 }"
> +}
> +
> +get_device_path()
> +{
> +       local devid=$1
> +       echo "$SCRATCH_DEV_POOL" | awk "{print \$$devid}"
>  }
>
>  _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
>  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
> -$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
>
> @@ -97,7 +116,7 @@ done
>  _scratch_unmount
>
>  # 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
>
>  _scratch_dev_pool_put
> diff --git a/tests/btrfs/141.out b/tests/btrfs/141.out
> index 116f98a2..4b8be189 100644
> --- a/tests/btrfs/141.out
> +++ b/tests/btrfs/141.out
> @@ -1,8 +1,6 @@
>  QA output created by 141
>  wrote 131072/131072 bytes
>  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  ................
> --
> 2.23.0
>


-- 
Filipe David Manana,

“Whether you think you can, or you think you can't — you're right.”

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] fstests: btrfs/14[01]: Use proper helper to get both devid and physical for corruption
  2019-12-17 17:43 ` Filipe Manana
@ 2019-12-18  0:20   ` Qu Wenruo
  0 siblings, 0 replies; 3+ messages in thread
From: Qu Wenruo @ 2019-12-18  0:20 UTC (permalink / raw)
  To: fdmanana, Qu Wenruo; +Cc: fstests, linux-btrfs


[-- Attachment #1.1: Type: text/plain, Size: 8355 bytes --]



On 2019/12/18 上午1:43, Filipe Manana wrote:
> On Thu, Dec 12, 2019 at 8:31 AM Qu Wenruo <wqu@suse.com> wrote:
>>
>> [BUG]
>> With btrfs-progs v5.4, btrfs/140 and btrfs/141 will fail.
> 
> Oddly, it doesn't fail for me. Only 142, 143, 157 and 158.
> 
> However this seems correct.
> 
>>
>> [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
> 
> more flex -> more flexible
> 
>> corruption.
>>
>> Signed-off-by: Qu Wenruo <wqu@suse.com>
>> ---
>>  tests/btrfs/140     | 36 ++++++++++++++++++++++++++++--------
>>  tests/btrfs/140.out |  2 --
>>  tests/btrfs/141     | 33 ++++++++++++++++++++++++++-------
>>  tests/btrfs/141.out |  2 --
>>  4 files changed, 54 insertions(+), 19 deletions(-)
>>
>> diff --git a/tests/btrfs/140 b/tests/btrfs/140
>> index 1c5aa679..5c6de733 100755
>> --- a/tests/btrfs/140
>> +++ b/tests/btrfs/140
>> @@ -46,10 +46,26 @@ _require_odirect
>>
>>  get_physical()
>>  {
>> -       # $1 is logical address
>> -       # print chunk tree and find devid 2 which is $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 }'
>> +       local logical=$1
>> +       local stripe=$2
>> +        $BTRFS_UTIL_PROG inspect-internal dump-tree -t 3 $SCRATCH_DEV | \
>> +               grep $logical -A 6 | \
>> +               awk "(\$1 ~ /stripe/ && \$3 ~ /devid/ && \$2 ~ /$stripe/) { print \$6 }"
>> +}
> 
> Same as before, $AWK_PROG.
> 
> These helpers seems the same as in 142 and 143 (and 141, updated later
> in this patch).
> I know this patch isn't introducing them, but we should move them into
> helpers at common/btrfs one day.

This is also recommended by Nikolay.

However there is a problem, mostly on the `grep` line.
- The target
  Some caller uses logical address like this, but some uses chunk type.
  This difference also affects the "-A" option, as logical matches the
chunk key, while
  the type matches the chunk type, causing a small difference in "-A"
number.

- The "-A" number for different chunk type
  The "-A" number depends mostly on the number of stripes.
  It needs to cover all stripes, while doesn't catch the stripes of the
next chunk.

  Currently we all use immediate number, as that number matches current
dump-tree
  output, but there is no guarantee for it at all as that dump-tree
output can also change.

  The best pattern should be something to only grab the first continuous
hunk of stripes.

But unfortunately I don't have enough experience in awk/grep, thus have
no choice but use the current immediate way, and not extracting them
into a generic helper.

Any advice would be highly appreciated.

Thanks,
Qu
> 
> Thanks.
> 
>> +
>> +get_devid()
>> +{
>> +       local logical=$1
>> +       local stripe=$2
>> +        $BTRFS_UTIL_PROG inspect-internal dump-tree -t 3 $SCRATCH_DEV | \
>> +               grep $logical -A 6 | \
>> +               awk "(\$1 ~ /stripe/ && \$3 ~ /devid/ && \$2 ~ /$stripe/) { print \$4 }"
>> +}
>> +
>> +get_device_path()
>> +{
>> +       local devid=$1
>> +       echo "$SCRATCH_DEV_POOL" | awk "{print \$$devid}"
>>  }
>>
>>  _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
>>  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
>> -$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
>>
>> @@ -96,7 +116,7 @@ done
>>  _scratch_unmount
>>
>>  # 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
>>
>>  _scratch_dev_pool_put
>> diff --git a/tests/btrfs/140.out b/tests/btrfs/140.out
>> index f3fdf174..fb5aa108 100644
>> --- a/tests/btrfs/140.out
>> +++ b/tests/btrfs/140.out
>> @@ -1,8 +1,6 @@
>>  QA output created by 140
>>  wrote 131072/131072 bytes
>>  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  ................
>> diff --git a/tests/btrfs/141 b/tests/btrfs/141
>> index 186d18c8..2f5ad1a2 100755
>> --- a/tests/btrfs/141
>> +++ b/tests/btrfs/141
>> @@ -46,10 +46,26 @@ _require_command "$FILEFRAG_PROG" filefrag
>>
>>  get_physical()
>>  {
>> -        # $1 is logical address
>> -        # print chunk tree and find devid 2 which is $SCRATCH_DEV
>> +       local logical=$1
>> +       local stripe=$2
>>          $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 "(\$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 "(\$1 ~ /stripe/ && \$3 ~ /devid/ && \$2 ~ /$stripe/) { print \$4 }"
>> +}
>> +
>> +get_device_path()
>> +{
>> +       local devid=$1
>> +       echo "$SCRATCH_DEV_POOL" | awk "{print \$$devid}"
>>  }
>>
>>  _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
>>  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
>> -$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
>>
>> @@ -97,7 +116,7 @@ done
>>  _scratch_unmount
>>
>>  # 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
>>
>>  _scratch_dev_pool_put
>> diff --git a/tests/btrfs/141.out b/tests/btrfs/141.out
>> index 116f98a2..4b8be189 100644
>> --- a/tests/btrfs/141.out
>> +++ b/tests/btrfs/141.out
>> @@ -1,8 +1,6 @@
>>  QA output created by 141
>>  wrote 131072/131072 bytes
>>  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  ................
>> --
>> 2.23.0
>>
> 
> 


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 520 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-12-18  0:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-12  8:31 [PATCH] fstests: btrfs/14[01]: Use proper helper to get both devid and physical for corruption Qu Wenruo
2019-12-17 17:43 ` Filipe Manana
2019-12-18  0:20   ` Qu Wenruo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).