diff mbox series

[3/9] btrfs/141: use common read repair helpers

Message ID 20220524071838.715013-4-hch@lst.de (mailing list archive)
State New, archived
Headers show
Series [1/9] btrfs: add a helpers for read repair testing | expand

Commit Message

Christoph Hellwig May 24, 2022, 7:18 a.m. UTC
Use the common helpers to find the btrfs logical address and to read from
a specific mirror.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 tests/btrfs/141 | 15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)

Comments

Qu Wenruo May 24, 2022, 1:21 p.m. UTC | #1
On 2022/5/24 15:18, Christoph Hellwig wrote:
> Use the common helpers to find the btrfs logical address and to read from
> a specific mirror.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Reviewed-by: Qu Wenruo <wqu@suse.com>

Thanks,
Qu

> ---
>   tests/btrfs/141 | 15 ++-------------
>   1 file changed, 2 insertions(+), 13 deletions(-)
>
> diff --git a/tests/btrfs/141 b/tests/btrfs/141
> index 9fdcb2ab..90a90d00 100755
> --- a/tests/btrfs/141
> +++ b/tests/btrfs/141
> @@ -25,7 +25,6 @@ _supported_fs btrfs
>   _require_scratch_dev_pool 2
>
>   _require_btrfs_command inspect-internal dump-tree
> -_require_command "$FILEFRAG_PROG" filefrag
>
>   get_physical()
>   {
> @@ -69,8 +68,7 @@ $XFS_IO_PROG -f -d -c "pwrite -S 0xaa -b 128K 0 128K" "$SCRATCH_MNT/foobar" |\
>   # one in $SCRATCH_DEV_POOL
>   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`
> +logical_in_btrfs=$(_btrfs_get_first_logical $SCRATCH_MNT/foobar)
>   physical=$(get_physical ${logical_in_btrfs} 1)
>   devid=$(get_devid ${logical_in_btrfs} 1)
>   devpath=$(get_device_path ${devid})
> @@ -85,16 +83,7 @@ _scratch_mount
>   # step 3, 128k buffered read (this read can repair bad copy)
>   echo "step 3......repair the bad copy" >>$seqres.full
>
> -# since raid1 consists of two copies, and the bad copy was put on stripe #1
> -# while the good copy lies on stripe #0, the bad copy only gets access when the
> -# reader's pid % 2 == 1 is true
> -while true; do
> -	echo 3 > /proc/sys/vm/drop_caches
> -	$XFS_IO_PROG -c "pread -b 128K 0 128K" "$SCRATCH_MNT/foobar" > /dev/null &
> -	pid=$!
> -	wait
> -	[ $((pid % 2)) == 1 ] && break
> -done
> +_btrfs_buffered_read_on_mirror 1 2 "$SCRATCH_MNT/foobar" 0 128K
>
>   _scratch_unmount
>
diff mbox series

Patch

diff --git a/tests/btrfs/141 b/tests/btrfs/141
index 9fdcb2ab..90a90d00 100755
--- a/tests/btrfs/141
+++ b/tests/btrfs/141
@@ -25,7 +25,6 @@  _supported_fs btrfs
 _require_scratch_dev_pool 2
 
 _require_btrfs_command inspect-internal dump-tree
-_require_command "$FILEFRAG_PROG" filefrag
 
 get_physical()
 {
@@ -69,8 +68,7 @@  $XFS_IO_PROG -f -d -c "pwrite -S 0xaa -b 128K 0 128K" "$SCRATCH_MNT/foobar" |\
 # one in $SCRATCH_DEV_POOL
 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`
+logical_in_btrfs=$(_btrfs_get_first_logical $SCRATCH_MNT/foobar)
 physical=$(get_physical ${logical_in_btrfs} 1)
 devid=$(get_devid ${logical_in_btrfs} 1)
 devpath=$(get_device_path ${devid})
@@ -85,16 +83,7 @@  _scratch_mount
 # step 3, 128k buffered read (this read can repair bad copy)
 echo "step 3......repair the bad copy" >>$seqres.full
 
-# since raid1 consists of two copies, and the bad copy was put on stripe #1
-# while the good copy lies on stripe #0, the bad copy only gets access when the
-# reader's pid % 2 == 1 is true
-while true; do
-	echo 3 > /proc/sys/vm/drop_caches
-	$XFS_IO_PROG -c "pread -b 128K 0 128K" "$SCRATCH_MNT/foobar" > /dev/null &
-	pid=$!
-	wait
-	[ $((pid % 2)) == 1 ] && break
-done
+_btrfs_buffered_read_on_mirror 1 2 "$SCRATCH_MNT/foobar" 0 128K
 
 _scratch_unmount