* [PATCH] btrfs/140: use proper helpers to get devid and physical offset for corruption
@ 2020-01-03 11:18 Johannes Thumshirn
2020-01-03 15:42 ` Josef Bacik
2020-01-06 8:16 ` Eryu Guan
0 siblings, 2 replies; 5+ messages in thread
From: Johannes Thumshirn @ 2020-01-03 11:18 UTC (permalink / raw)
To: Eryu Guan
Cc: Qu Wenruo, linux-btrfs, fstests, Damien Le Moal, Johannes Thumshirn
Similar to fstests commit 1a27bf14ef8b "btrfs/14[23]: Use proper help to
get both devid and physical offset for corruption." btrfs/140 needs the
same treatment to pass with updated btrfs-progs.
Signed-off-by: Johannes Thumshirn <jth@kernel.org>
---
tests/btrfs/140 | 35 +++++++++++++++++++++++++++++------
1 file changed, 29 insertions(+), 6 deletions(-)
diff --git a/tests/btrfs/140 b/tests/btrfs/140
index 1c5aa679..2517263b 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
+ 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_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
@@ -72,10 +88,16 @@ 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)
+target_dev=$(get_device_path $devid)
_scratch_unmount
-$XFS_IO_PROG -d -c "pwrite -S 0xbb -b 64K $physical_on_scratch 64K" $SCRATCH_DEV |\
+$BTRFS_UTIL_PROG ins dump-tree -t 3 $SCRATCH_DEV | \
+ grep $logical_in_btrfs -A 6 >> $seqres.full
+echo "Corrupt stripe 1 devid $devid devpath $target_dev physical $physical" \
+ >> $seqres.full
+$XFS_IO_PROG -d -c "pwrite -S 0xbb -b 64K $physical 64K" $target_dev |\
_filter_xfs_io_offset
_scratch_mount
@@ -96,7 +118,8 @@ done
_scratch_unmount
# check if the repair works
-$XFS_IO_PROG -d -c "pread -v -b 512 $physical_on_scratch 512" $SCRATCH_DEV |\
+echo "Reading from physical $physical device $target_dev" >> $seqres.full
+$XFS_IO_PROG -c "pread -v -b 512 $physical 512" $target_dev | \
_filter_xfs_io_offset
_scratch_dev_pool_put
--
2.16.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] btrfs/140: use proper helpers to get devid and physical offset for corruption
2020-01-03 11:18 [PATCH] btrfs/140: use proper helpers to get devid and physical offset for corruption Johannes Thumshirn
@ 2020-01-03 15:42 ` Josef Bacik
2020-01-06 8:16 ` Eryu Guan
1 sibling, 0 replies; 5+ messages in thread
From: Josef Bacik @ 2020-01-03 15:42 UTC (permalink / raw)
To: Johannes Thumshirn, Eryu Guan
Cc: Qu Wenruo, linux-btrfs, fstests, Damien Le Moal
On 1/3/20 6:18 AM, Johannes Thumshirn wrote:
> Similar to fstests commit 1a27bf14ef8b "btrfs/14[23]: Use proper help to
> get both devid and physical offset for corruption." btrfs/140 needs the
> same treatment to pass with updated btrfs-progs.
>
> Signed-off-by: Johannes Thumshirn <jth@kernel.org>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Thanks,
Josef
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] btrfs/140: use proper helpers to get devid and physical offset for corruption
2020-01-03 11:18 [PATCH] btrfs/140: use proper helpers to get devid and physical offset for corruption Johannes Thumshirn
2020-01-03 15:42 ` Josef Bacik
@ 2020-01-06 8:16 ` Eryu Guan
2020-01-06 8:56 ` Qu Wenruo
1 sibling, 1 reply; 5+ messages in thread
From: Eryu Guan @ 2020-01-06 8:16 UTC (permalink / raw)
To: Johannes Thumshirn; +Cc: Qu Wenruo, linux-btrfs, fstests, Damien Le Moal
On Fri, Jan 03, 2020 at 12:18:10PM +0100, Johannes Thumshirn wrote:
> Similar to fstests commit 1a27bf14ef8b "btrfs/14[23]: Use proper help to
> get both devid and physical offset for corruption." btrfs/140 needs the
> same treatment to pass with updated btrfs-progs.
>
> Signed-off-by: Johannes Thumshirn <jth@kernel.org>
> ---
Qu Wenruo has posted "fstests: btrfs/14[01]: Use proper helper to get
both devid and physical for corruption" earlier, and I'll apply his
patch instead.
Thanks,
Eryu
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] btrfs/140: use proper helpers to get devid and physical offset for corruption
2020-01-06 8:16 ` Eryu Guan
@ 2020-01-06 8:56 ` Qu Wenruo
2020-01-07 7:14 ` Johannes Thumshirn
0 siblings, 1 reply; 5+ messages in thread
From: Qu Wenruo @ 2020-01-06 8:56 UTC (permalink / raw)
To: Eryu Guan, Johannes Thumshirn
Cc: Qu Wenruo, linux-btrfs, fstests, Damien Le Moal
[-- Attachment #1.1: Type: text/plain, Size: 677 bytes --]
On 2020/1/6 下午4:16, Eryu Guan wrote:
> On Fri, Jan 03, 2020 at 12:18:10PM +0100, Johannes Thumshirn wrote:
>> Similar to fstests commit 1a27bf14ef8b "btrfs/14[23]: Use proper help to
>> get both devid and physical offset for corruption." btrfs/140 needs the
>> same treatment to pass with updated btrfs-progs.
>>
>> Signed-off-by: Johannes Thumshirn <jth@kernel.org>
>> ---
>
> Qu Wenruo has posted "fstests: btrfs/14[01]: Use proper helper to get
> both devid and physical for corruption" earlier, and I'll apply his
> patch instead.
Thanks.
The timing is great since I was just going to ping that patch.
Thanks,
Qu
>
> Thanks,
> Eryu
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 520 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] btrfs/140: use proper helpers to get devid and physical offset for corruption
2020-01-06 8:56 ` Qu Wenruo
@ 2020-01-07 7:14 ` Johannes Thumshirn
0 siblings, 0 replies; 5+ messages in thread
From: Johannes Thumshirn @ 2020-01-07 7:14 UTC (permalink / raw)
To: Qu Wenruo, Eryu Guan; +Cc: Qu Wenruo, linux-btrfs, fstests, Damien Le Moal
Am 06.01.20 um 09:56 schrieb Qu Wenruo:
>
> On 2020/1/6 下午4:16, Eryu Guan wrote:
>> On Fri, Jan 03, 2020 at 12:18:10PM +0100, Johannes Thumshirn wrote:
>>> Similar to fstests commit 1a27bf14ef8b "btrfs/14[23]: Use proper help to
>>> get both devid and physical offset for corruption." btrfs/140 needs the
>>> same treatment to pass with updated btrfs-progs.
>>>
>>> Signed-off-by: Johannes Thumshirn <jth@kernel.org>
>>> ---
>> Qu Wenruo has posted "fstests: btrfs/14[01]: Use proper helper to get
>> both devid and physical for corruption" earlier, and I'll apply his
>> patch instead.
> Thanks.
>
> The timing is great since I was just going to ping that patch.
Thanks as well,
Johannes
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-01-07 7:15 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-03 11:18 [PATCH] btrfs/140: use proper helpers to get devid and physical offset for corruption Johannes Thumshirn
2020-01-03 15:42 ` Josef Bacik
2020-01-06 8:16 ` Eryu Guan
2020-01-06 8:56 ` Qu Wenruo
2020-01-07 7:14 ` Johannes Thumshirn
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).