From patchwork Fri May 27 08:19:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 12863119 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EBD70C433FE for ; Fri, 27 May 2022 08:19:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347657AbiE0ITW (ORCPT ); Fri, 27 May 2022 04:19:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347019AbiE0ITV (ORCPT ); Fri, 27 May 2022 04:19:21 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7AD4ED8FC; Fri, 27 May 2022 01:19:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=tGyY2wVDyAuJxuihe3FeTBKyvFue7JDkkgMl8TI3lyI=; b=vY7D0E9grRJHIsO6vwOm6jirry wdKtMsCxlg3KYn15a1D55qUANkqf0Lkb8TTvTx2BcrDw+cpxrs2Hq6gfresjXvX4QtDQJF2b+Ev5k FWF4ojuC26RCKd7bE5b9SqtrD736fqaStWEXfMaUEdzJAT+wkmj4UWIm2jGd4pg2j0DeQGEWRz2/X 3gctgFTJr9JtyCHD2SOvwRFIw+EJ5gEuGXtooXzFliJnO6imtN1OUjc2bXaNF9U+Hv1/SB/m4U3a1 CAehOSksSAMe0090mQWGkgjGW+zPSkzRg56WpRVY3/vnbCJDUfKypG3g5yZ/OTsvyNEPyY0yblfxf ZGJoJmLg==; Received: from [2001:4bb8:18c:7298:b5ab:7d49:c6be:2011] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1nuVBo-00GzuN-0m; Fri, 27 May 2022 08:19:20 +0000 From: Christoph Hellwig To: fstests@vger.kernel.org Cc: linux-btrfs@vger.kernel.org, Qu Wenruo Subject: [PATCH 01/10] btrfs: add a helpers for read repair testing Date: Fri, 27 May 2022 10:19:06 +0200 Message-Id: <20220527081915.2024853-2-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220527081915.2024853-1-hch@lst.de> References: <20220527081915.2024853-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org Add a few helpers to consolidate code for btrfs read repair testing: - _btrfs_get_first_logical() gets the btrfs logical address for the first extent in a file - _btrfs_get_device_path and _btrfs_get_physical use the btrfs-map-logical tool to find the device path and physical address for btrfs logical address for a specific mirror - _btrfs_direct_read_on_mirror and _btrfs_buffered_read_on_mirror read the data from a specific mirror These will be used to consolidate the read repair tests and avoid duplication for new tests. Signed-off-by: Christoph Hellwig Reviewed-by: Qu Wenruo Signed-off-by: Christoph Hellwig Reviewed-by: Qu Wenruo --- common/btrfs | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++ common/config | 1 + 2 files changed, 76 insertions(+) diff --git a/common/btrfs b/common/btrfs index ac597ca4..b69feeee 100644 --- a/common/btrfs +++ b/common/btrfs @@ -505,3 +505,78 @@ _btrfs_metadump() $BTRFS_IMAGE_PROG "$device" "$dumpfile" [ -n "$DUMP_COMPRESSOR" ] && $DUMP_COMPRESSOR -f "$dumpfile" &> /dev/null } + +# Return the btrfs logical address for the first block in a file +_btrfs_get_first_logical() +{ + local file=$1 + _require_command "$FILEFRAG_PROG" filefrag + + ${FILEFRAG_PROG} -v $SCRATCH_MNT/foobar >> $seqres.full + ${FILEFRAG_PROG} -v $file | _filter_filefrag | cut -d '#' -f 1 +} + +# Find the device path for a btrfs logical offset +_btrfs_get_device_path() +{ + local logical=$1 + local stripe=$2 + + _require_command "$BTRFS_MAP_LOGICAL_PROG" btrfs-map-logical + + $BTRFS_MAP_LOGICAL_PROG -l $logical $SCRATCH_DEV | \ + $AWK_PROG "(\$1 ~ /mirror/ && \$2 ~ /$stripe/) { print \$8 }" +} + + +# Find the device physical sector for a btrfs logical offset +_btrfs_get_physical() +{ + local logical=$1 + local stripe=$2 + + _require_command "$BTRFS_MAP_LOGICAL_PROG" btrfs-map-logical + + $BTRFS_MAP_LOGICAL_PROG -b -l $logical $SCRATCH_DEV >> $seqres.full 2>&1 + $BTRFS_MAP_LOGICAL_PROG -l $logical $SCRATCH_DEV | \ + $AWK_PROG "(\$1 ~ /mirror/ && \$2 ~ /$stripe/) { print \$6 }" +} + +# Read from a specific stripe to test read recovery that corrupted a specific +# stripe. Btrfs uses the PID to select the mirror, so keep reading until the +# xfs_io process that performed the read was executed with a PID that ends up +# on the intended mirror. +_btrfs_direct_read_on_mirror() +{ + local mirror=$1 + local nr_mirrors=$2 + local file=$3 + local offset=$4 + local size=$5 + + while [[ -z $( (( BASHPID % nr_mirrors == mirror )) && + exec $XFS_IO_PROG -d \ + -c "pread -b $size $offset $size" $file) ]]; do + : + done +} + +# Read from a specific stripe to test read recovery that corrupted a specific +# stripe. Btrfs uses the PID to select the mirror, so keep reading until the +# xfs_io process that performed the read was executed with a PID that ends up +# on the intended mirror. +_btrfs_buffered_read_on_mirror() +{ + local mirror=$1 + local nr_mirrors=$2 + local file=$3 + local offset=$4 + local size=$5 + + echo 3 > /proc/sys/vm/drop_caches + while [[ -z $( (( BASHPID % nr_mirrors == mirror )) && + exec $XFS_IO_PROG \ + -c "pread -b $size $offset $size" $file) ]]; do + : + done +} diff --git a/common/config b/common/config index c6428f90..df20afc1 100644 --- a/common/config +++ b/common/config @@ -228,6 +228,7 @@ export E2IMAGE_PROG="$(type -P e2image)" export BLKZONE_PROG="$(type -P blkzone)" export GZIP_PROG="$(type -P gzip)" export BTRFS_IMAGE_PROG="$(type -P btrfs-image)" +export BTRFS_MAP_LOGICAL_PROG=$(type -P btrfs-map-logical) # use 'udevadm settle' or 'udevsettle' to wait for lv to be settled. # newer systems have udevadm command but older systems like RHEL5 don't. From patchwork Fri May 27 08:19:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 12863118 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C838C43217 for ; Fri, 27 May 2022 08:19:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348906AbiE0ITY (ORCPT ); Fri, 27 May 2022 04:19:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347019AbiE0ITY (ORCPT ); Fri, 27 May 2022 04:19:24 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 748BCED8FE; Fri, 27 May 2022 01:19:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=69hh06W+NdNVRer1I/ZMAn8KvaSQ+j0g8ghU4xRn5aw=; b=S3YRwp4IX4TpD0CeooERyaDqMk BH3Ls31Ie1J0DoWR0Ndh5zJdGFsdYUj23Nsv+kj7Ix6XY8JhuOExUDMLmNeX4b0qNnBxatwjC1ugx fC8+AsEHn1CxhGdb5XOjs0HxPjitdSuA+KfoRBLGp2+6+pl6RlA4xWM2kVx6TafL4XAhifOZqVmdW 00ZYoRPvzsQ/w6IIMcENJ/Uh/eYWhuCc6njsOwRtl5c1YoCuLYEVv8gLlEe0/3IPpLARIUkRIAwmy tYitIfAOKNqeku673vKX2OQHVX8jNu3Jxw6zqZKaFQ+r7mu4CaPi8rFsJHmhTTb6o++1o/m1+8hsQ bDkzMXnA==; Received: from [2001:4bb8:18c:7298:b5ab:7d49:c6be:2011] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1nuVBq-00GzvF-KX; Fri, 27 May 2022 08:19:23 +0000 From: Christoph Hellwig To: fstests@vger.kernel.org Cc: linux-btrfs@vger.kernel.org, Qu Wenruo Subject: [PATCH 02/10] btrfs/140: use common read repair helpers Date: Fri, 27 May 2022 10:19:07 +0200 Message-Id: <20220527081915.2024853-3-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220527081915.2024853-1-hch@lst.de> References: <20220527081915.2024853-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org Use the common helpers to find the btrfs logical address and to read from a specific mirror. Signed-off-by: Christoph Hellwig Reviewed-by: Qu Wenruo Reviewed-by: Anand Jain --- tests/btrfs/140 | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/tests/btrfs/140 b/tests/btrfs/140 index c680fe0a..fdff6eb2 100755 --- a/tests/btrfs/140 +++ b/tests/btrfs/140 @@ -24,7 +24,6 @@ _supported_fs btrfs _require_scratch_dev_pool 2 _require_btrfs_command inspect-internal dump-tree -_require_command "$FILEFRAG_PROG" filefrag _require_odirect # Overwriting data is forbidden on a zoned block device _require_non_zoned_device "${SCRATCH_DEV}" @@ -71,7 +70,7 @@ $XFS_IO_PROG -f -d -c "pwrite -S 0xaa -b 128K 0 128K" "$SCRATCH_MNT/foobar" |\ 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}) @@ -87,15 +86,7 @@ _scratch_mount # step 3, 128k dio 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 - $XFS_IO_PROG -d -c "pread -b 128K 0 128K" "$SCRATCH_MNT/foobar" > /dev/null & - pid=$! - wait - [ $((pid % 2)) == 1 ] && break -done +_btrfs_direct_read_on_mirror 1 2 "$SCRATCH_MNT/foobar" 0 128K _scratch_unmount From patchwork Fri May 27 08:19:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 12863120 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1DB98C433EF for ; Fri, 27 May 2022 08:19:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347019AbiE0IT2 (ORCPT ); Fri, 27 May 2022 04:19:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238347AbiE0IT1 (ORCPT ); Fri, 27 May 2022 04:19:27 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11826ED8FE; Fri, 27 May 2022 01:19:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=Zt4GUk0+M7yBUtGVMgiUd70j/wVP6RRywXvMddiZIeY=; b=0KJnP3wR9bhrUvWNuKb/P3k2/C YHHwIfXJKct082ikFLeIBd5UX7m+7sSNsprP9K+DtLn2kONkWn4+kzCBWdiL83zkBvff+e5xYZuFx cwcJyzhR/3U6CKolrf1fgZTQu1OrqbRjQRcHhJQi/Q1mqdE8FmwQobvx8q3lEgdhZr5iCKErhQy+N 69mBASquMcQijSXkrNwUMAUWfxgu4O/XiIEzZUGoPOPclXZYRaP9QbPyj1z5UPLZQkfRELgLGQCIb 3yFolQeN13WizL2Y4QfNLPHBf3YwvggAALi9HpPI9qKfElJxeKpuKgVqG5634NJftZoLCuOWVDxBf y8xgpYkQ==; Received: from [2001:4bb8:18c:7298:b5ab:7d49:c6be:2011] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1nuVBt-00Gzws-8u; Fri, 27 May 2022 08:19:25 +0000 From: Christoph Hellwig To: fstests@vger.kernel.org Cc: linux-btrfs@vger.kernel.org, Qu Wenruo Subject: [PATCH 03/10] btrfs/141: use common read repair helpers Date: Fri, 27 May 2022 10:19:08 +0200 Message-Id: <20220527081915.2024853-4-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220527081915.2024853-1-hch@lst.de> References: <20220527081915.2024853-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org Use the common helpers to find the btrfs logical address and to read from a specific mirror. Signed-off-by: Christoph Hellwig Reviewed-by: Qu Wenruo Reviewed-by: Anand Jain --- 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 From patchwork Fri May 27 08:19:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 12863121 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C541EC4332F for ; Fri, 27 May 2022 08:19:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245285AbiE0IT3 (ORCPT ); Fri, 27 May 2022 04:19:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238347AbiE0IT3 (ORCPT ); Fri, 27 May 2022 04:19:29 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF277F1373; Fri, 27 May 2022 01:19:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=+hiFrIsAM9uZ02jYOz3NSMxqE01U6htfJ3t3La+ffc4=; b=RBSbWtXNqlkkxd/Ne2zrCQF/pq LZpmwQajN7na4wOv0tuE7Avg8abdHGpYq9wxfXSmTFg3rMulaPro4BUu/wldqNO1m+StGmrVOYHK4 nntKDOlCvFrNjRHYUAD0lo9/9c4VFDO1P9yL+Pb1mczyiYeZpTy2Qi26JNMNbsIDJvSE4CYqVgYDK umLG3SMLX04QOTzC+KVPa2pLrfL0yqrVZPgS6T0YrpTDGi68Ytc50g1k5u/VDmJTvBsJ7G6AejmFY bZMWDiQdOOhMDmigj+Q9BvUrQLUVyFpCj60P2pZiRdrIuOHDC+8UTRujKfBYKkIAQvECmBFndf2mU IpdlnnbQ==; Received: from [2001:4bb8:18c:7298:b5ab:7d49:c6be:2011] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1nuVBv-00GzyG-Tn; Fri, 27 May 2022 08:19:28 +0000 From: Christoph Hellwig To: fstests@vger.kernel.org Cc: linux-btrfs@vger.kernel.org, Qu Wenruo Subject: [PATCH 04/10] btrfs/142: use common read repair helpers Date: Fri, 27 May 2022 10:19:09 +0200 Message-Id: <20220527081915.2024853-5-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220527081915.2024853-1-hch@lst.de> References: <20220527081915.2024853-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org Use the common helpers to find the btrfs logical address and to read from a specific mirror. Signed-off-by: Christoph Hellwig Reviewed-by: Qu Wenruo Reviewed-by: Anand Jain --- tests/btrfs/142 | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/tests/btrfs/142 b/tests/btrfs/142 index 58d01add..7a63fb83 100755 --- a/tests/btrfs/142 +++ b/tests/btrfs/142 @@ -27,7 +27,6 @@ _require_scratch_dev_pool 2 _require_dm_target dust _require_btrfs_command inspect-internal dump-tree -_require_command "$FILEFRAG_PROG" filefrag _scratch_dev_pool_get 2 # step 1, create a raid1 btrfs which contains one 128k file. @@ -46,8 +45,7 @@ $XFS_IO_PROG -f -d -c "pwrite -S 0xaa -b 128K 0 128K" "$SCRATCH_MNT/foobar" |\ # step 2, corrupt the first 64k of stripe #1 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) echo "Logical offset is $logical_in_btrfs" >>$seqres.full _scratch_unmount @@ -67,10 +65,8 @@ echo "step 3......repair the bad copy" >>$seqres.full $DMSETUP_PROG message dust-test 0 addbadblock $((physical / 512)) $DMSETUP_PROG message dust-test 0 enable -while [[ -z $( (( BASHPID % 2 == stripe )) && - exec $XFS_IO_PROG -d -c "pread -b 128K 0 128K" "$SCRATCH_MNT/foobar") ]]; do - : -done + +_btrfs_direct_read_on_mirror $stripe 2 "$SCRATCH_MNT/foobar" 0 128K _cleanup_dust From patchwork Fri May 27 08:19:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 12863122 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9C1B7C433EF for ; Fri, 27 May 2022 08:19:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349003AbiE0ITc (ORCPT ); Fri, 27 May 2022 04:19:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238347AbiE0ITc (ORCPT ); Fri, 27 May 2022 04:19:32 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C502ED8FE; Fri, 27 May 2022 01:19:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=rvAXoC5D7NbJKN/rkulBSzflMHUOEAI6TV/paGXXM4o=; b=RsqZr4WgmcXCfoaDd9c11Uo1X5 7cZQOWDWrTY9V2kdbJPMWGeUpSfqJ+kGbdufskfnn7ompN8mkX7ER4G04+hbA8OpYVDKFXBKiSEMz zMOfu/NgR03NN8HFvtKqjkqx/htDpsTvYn+QqcuJLxRv6fYuwQj58k3eTO+SDcDwRIZIItR46K5rw o5qBSRrK5uzPPNZO0rvxVB4EPchKTvce4d3uPL+uv1Ex5mBB3mgTTJouUFUh6hcS8UqaJ7hYI05Be zxWSC0OP4bPCbuS2JvZnKjZOeLtam5uiXpifI+QvNjNQSFONlQ0+c1X/7Kz7e6VpbWNqkbbLWbUOq k4cAN4ew==; Received: from [2001:4bb8:18c:7298:b5ab:7d49:c6be:2011] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1nuVBy-00GzzT-H0; Fri, 27 May 2022 08:19:30 +0000 From: Christoph Hellwig To: fstests@vger.kernel.org Cc: linux-btrfs@vger.kernel.org, Qu Wenruo Subject: [PATCH 05/10] btrfs/143: use common read repair helpers Date: Fri, 27 May 2022 10:19:10 +0200 Message-Id: <20220527081915.2024853-6-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220527081915.2024853-1-hch@lst.de> References: <20220527081915.2024853-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org Use the common helpers to find the btrfs logical address and to read from a specific mirror. Signed-off-by: Christoph Hellwig Reviewed-by: Qu Wenruo Reviewed-by: Anand Jain --- tests/btrfs/143 | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/tests/btrfs/143 b/tests/btrfs/143 index 71db861d..b6ff2a42 100755 --- a/tests/btrfs/143 +++ b/tests/btrfs/143 @@ -34,7 +34,6 @@ _require_scratch_dev_pool 2 _require_dm_target dust _require_btrfs_command inspect-internal dump-tree -_require_command "$FILEFRAG_PROG" filefrag _scratch_dev_pool_get 2 # step 1, create a raid1 btrfs which contains one 128k file. @@ -53,8 +52,7 @@ $XFS_IO_PROG -f -d -c "pwrite -S 0xaa -b 128K 0 128K" "$SCRATCH_MNT/foobar" |\ # step 2, corrupt the first 64k of stripe #1 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) echo "Logical offset is $logical_in_btrfs" >>$seqres.full _scratch_unmount @@ -74,10 +72,8 @@ echo "step 3......repair the bad copy" >>$seqres.full $DMSETUP_PROG message dust-test 0 addbadblock $((physical / 512)) $DMSETUP_PROG message dust-test 0 enable -while [[ -z $( (( BASHPID % 2 == stripe )) && - exec $XFS_IO_PROG -c "pread -b 128K 0 128K" "$SCRATCH_MNT/foobar") ]]; do - : -done + +_btrfs_buffered_read_on_mirror $stripe 2 "$SCRATCH_MNT/foobar" 0 128K _cleanup_dust From patchwork Fri May 27 08:19:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 12863123 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 38358C433F5 for ; Fri, 27 May 2022 08:19:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236117AbiE0ITf (ORCPT ); Fri, 27 May 2022 04:19:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349221AbiE0ITe (ORCPT ); Fri, 27 May 2022 04:19:34 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C39F110274F; Fri, 27 May 2022 01:19:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=CwInLtVp+3Thz3l/OI6ZKlNkVBFXXF3UwVeNaE5cyvQ=; b=3o0t5dN5PNTq3n3Cx1Gb+vJCQE I4pyk3/nYpAa2GfsWhA9GbmflGT+ZX5l/LGM0LDnDXG/nomHssqJSdJjJtBRZoPM7fs4PJu+caw46 h6TOIP70nfeNLEDRcxmbo2+7RehHRUBnXZrnWehyPCYqWi7JeM3BmssqFO2HyBzRyfUhUUv8ewbth GjKl+BaU9mAPLt+5T4M837NNPV4yBLvMv9Kjm4KlOQ47qNHsfBSn8RyYb8No6BCV0LgA83S6XueLt Eai0TX+tPev37TSMnqjxiMzLtNk/tIaX7Wx7Zpy87Sd7SeW27uB1qiKbxBwtKRF3DeZstOE9PcGiC VoHk5pJw==; Received: from [2001:4bb8:18c:7298:b5ab:7d49:c6be:2011] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1nuVC1-00H00p-2O; Fri, 27 May 2022 08:19:33 +0000 From: Christoph Hellwig To: fstests@vger.kernel.org Cc: linux-btrfs@vger.kernel.org, Qu Wenruo Subject: [PATCH 06/10] btrfs/157: use _btrfs_get_first_logical Date: Fri, 27 May 2022 10:19:11 +0200 Message-Id: <20220527081915.2024853-7-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220527081915.2024853-1-hch@lst.de> References: <20220527081915.2024853-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org Use the _btrfs_get_first_logical helper instead of open coding it. Signed-off-by: Christoph Hellwig Reviewed-by: Qu Wenruo Reviewed-by: Anand Jain --- tests/btrfs/157 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/btrfs/157 b/tests/btrfs/157 index 343178b7..022db511 100755 --- a/tests/btrfs/157 +++ b/tests/btrfs/157 @@ -71,7 +71,7 @@ _scratch_mount $(_btrfs_no_v1_cache_opt) $XFS_IO_PROG -f -d -c "pwrite -S 0xaa 0 128K" -c "fsync" \ "$SCRATCH_MNT/foobar" | _filter_xfs_io -logical=`${FILEFRAG_PROG} -v $SCRATCH_MNT/foobar | _filter_filefrag | cut -d '#' -f 1` +logical=$(_btrfs_get_first_logical $SCRATCH_MNT/foobar) _scratch_unmount phy0=$(get_physical 0) From patchwork Fri May 27 08:19:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 12863124 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 424ECC433EF for ; Fri, 27 May 2022 08:19:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345114AbiE0ITj (ORCPT ); Fri, 27 May 2022 04:19:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238619AbiE0ITh (ORCPT ); Fri, 27 May 2022 04:19:37 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61BDC10274C; Fri, 27 May 2022 01:19:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=i+o277We/VFbOQbVtvZKV/B+F9wiZ0t2qsBJ6kKUBd4=; b=MhU6YwCtUzcOOKvZFMaBrhKCIp QipH5QeNoqwfLOn7dmo2HJdUGStybzil6Og7NAPx/E8xvLkf/cfpQ9eei1laQSoucmsK09U77eiKT u3ymyOx1wylnIuuXwVtWlCKlfI6yl6s5+7+VgKmXdkRMOBbYlsq/qwb2JYv14OY5hBFi5T+pY1M4b OQ7GLkQxAPvpR3ecL+sVtym6EkETha5Q16819cH4kNmehmdBvfVyq6iQU3GONYiiiUnOh2GRA+RtJ w1Uzt7JRte2PcEETZJ+5aYJ46zCoPDmdUzT+pHmzxGSCXQWEkjjjb9aT4IBGNk5q4NzAA25E9MFH1 ZBWq/gpg==; Received: from [2001:4bb8:18c:7298:b5ab:7d49:c6be:2011] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1nuVC3-00H023-Js; Fri, 27 May 2022 08:19:36 +0000 From: Christoph Hellwig To: fstests@vger.kernel.org Cc: linux-btrfs@vger.kernel.org, Qu Wenruo Subject: [PATCH 07/10] btrfs/215: use _btrfs_get_first_logical Date: Fri, 27 May 2022 10:19:12 +0200 Message-Id: <20220527081915.2024853-8-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220527081915.2024853-1-hch@lst.de> References: <20220527081915.2024853-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org Use the _btrfs_get_first_logical helper instead of open coding it. Signed-off-by: Christoph Hellwig Reviewed-by: Qu Wenruo Reviewed-by: Anand Jain --- tests/btrfs/215 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/btrfs/215 b/tests/btrfs/215 index 0dcbce2a..928f365c 100755 --- a/tests/btrfs/215 +++ b/tests/btrfs/215 @@ -56,7 +56,7 @@ fi #create an 8 block file $XFS_IO_PROG -d -f -c "pwrite -S 0xbb -b $filesize 0 $filesize" "$SCRATCH_MNT/foobar" > /dev/null -logical_extent=$($FILEFRAG_PROG -v "$SCRATCH_MNT/foobar" | _filter_filefrag | cut -d '#' -f 1) +logical_extent=$(_btrfs_get_first_logical $SCRATCH_MNT/foobar) physical_extent=$(get_physical $logical_extent) echo "logical = $logical_extent physical=$physical_extent" >> $seqres.full From patchwork Fri May 27 08:19:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 12863125 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 046BAC433FE for ; Fri, 27 May 2022 08:19:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349272AbiE0ITl (ORCPT ); Fri, 27 May 2022 04:19:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349235AbiE0ITk (ORCPT ); Fri, 27 May 2022 04:19:40 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EADD610274F; Fri, 27 May 2022 01:19:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=/9YZ39GMOeGnw0Kwz/NQiIVfdKmZy+TTX4Sa4dG4XOs=; b=lIct6k1g+j3p2MYEvoZ/9AMkM3 R/41uKWKUTnyc6oFSSuswpY6PbzJbIRnowT5xa/9vR4bNlRqHesjiXFdMdEg5xRj6wlKbQ+lD9btp fk9hk0Jh3VCJUa1RutroeRY7pU44GuRBSUdrDZVQJceKnNbfh5zuF3Lduf+ptAE8KRfcciNIy8O3P H47HIdgaevoqBVaJEErzBUR1mKgVzFLp+U2hX1Eaiw1jAOqFV6m5yt7oBCBWoLSsEe/0/a63W+oYm UafB6sAQbfipilfjSqhg6QWtXKDk0m7iB9lTcTkG2l+UWwi9Dr2i7Il2hY1Tctrq8K8PDToHbucrJ js13asuA==; Received: from [2001:4bb8:18c:7298:b5ab:7d49:c6be:2011] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1nuVC6-00H030-5x; Fri, 27 May 2022 08:19:38 +0000 From: Christoph Hellwig To: fstests@vger.kernel.org Cc: linux-btrfs@vger.kernel.org, Qu Wenruo Subject: [PATCH 08/10] btrfs: test repair with sectors corrupted in multiple mirrors Date: Fri, 27 May 2022 10:19:13 +0200 Message-Id: <20220527081915.2024853-9-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220527081915.2024853-1-hch@lst.de> References: <20220527081915.2024853-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org Test that repair handles the case where it needs to read from more than a single mirror on the raid1c3 profile. Signed-off-by: Christoph Hellwig Reviewed-by: Qu Wenruo Reviewed-by: Anand Jain --- tests/btrfs/265 | 85 +++++++++++++++++++++++++++++++++++++++++++++ tests/btrfs/265.out | 75 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 160 insertions(+) create mode 100755 tests/btrfs/265 create mode 100644 tests/btrfs/265.out diff --git a/tests/btrfs/265 b/tests/btrfs/265 new file mode 100755 index 00000000..b75d9c84 --- /dev/null +++ b/tests/btrfs/265 @@ -0,0 +1,85 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2017 Liu Bo. All Rights Reserved. +# Copyright (c) 2022 Christoph Hellwig. +# +# FS QA Test 265 +# +# Test that btrfs raid repair on a raid1c3 profile can repair corruption on two +# mirrors for the same logical offset. +# +. ./common/preamble +_begin_fstest auto quick read_repair + +# Import common functions. +. ./common/filter + +# real QA test starts here + +_supported_fs btrfs +_require_scratch_dev_pool 3 + +_require_odirect +# Overwriting data is forbidden on a zoned block device +_require_non_zoned_device "${SCRATCH_DEV}" + +_scratch_dev_pool_get 3 +# step 1, create a raid1 btrfs which contains one 128k file. +echo "step 1......mkfs.btrfs" + +mkfs_opts="-d raid1c3 -b 1G" +_scratch_pool_mkfs $mkfs_opts >>$seqres.full 2>&1 + +_scratch_mount + +$XFS_IO_PROG -f -d -c "pwrite -S 0xaa -b 128K 0 128K" \ + "$SCRATCH_MNT/foobar" | \ + _filter_xfs_io_offset + +# step 2, corrupt the first 64k of one copy (on SCRATCH_DEV which is the first +# one in $SCRATCH_DEV_POOL +echo "step 2......corrupt file extent" + +# ensure btrfs-map-logical sees the tree updates +sync + +logical=$(_btrfs_get_first_logical $SCRATCH_MNT/foobar) + +physical1=$(_btrfs_get_physical ${logical} 1) +devpath1=$(_btrfs_get_device_path ${logical} 1) + +physical2=$(_btrfs_get_physical ${logical} 2) +devpath2=$(_btrfs_get_device_path ${logical} 2) + +_scratch_unmount + +echo " corrupt stripe #1, devpath $devpath1 physical $physical1" \ + >> $seqres.full +$XFS_IO_PROG -d -c "pwrite -S 0xbf -b 64K $physical1 64K" $devpath1 \ + > /dev/null + +echo " corrupt stripe #2, devpath $devpath2 physical $physical2" \ + >> $seqres.full +$XFS_IO_PROG -d -c "pwrite -S 0xbf -b 64K $physical2 64K" $devpath2 \ + > /dev/null + +_scratch_mount + +# step 3, 128k dio read (this read can repair bad copy) +echo "step 3......repair the bad copy" + +_btrfs_direct_read_on_mirror 0 3 "$SCRATCH_MNT/foobar" 0 128K +_btrfs_direct_read_on_mirror 1 3 "$SCRATCH_MNT/foobar" 0 128K + +_scratch_unmount + +echo "step 4......check if the repair worked" +$XFS_IO_PROG -d -c "pread -v -b 512 $physical1 512" $devpath1 |\ + _filter_xfs_io_offset +$XFS_IO_PROG -d -c "pread -v -b 512 $physical2 512" $devpath2 |\ + _filter_xfs_io_offset + +_scratch_dev_pool_put +# success, all done +status=0 +exit diff --git a/tests/btrfs/265.out b/tests/btrfs/265.out new file mode 100644 index 00000000..c62c7a39 --- /dev/null +++ b/tests/btrfs/265.out @@ -0,0 +1,75 @@ +QA output created by 265 +step 1......mkfs.btrfs +wrote 131072/131072 bytes +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +step 2......corrupt file extent +step 3......repair the bad copy +step 4......check if the repair worked +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 ................ +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 ................ +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 ................ +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 ................ +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 ................ +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 ................ +read 512/512 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 ................ +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 ................ +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 ................ +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 ................ +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 ................ +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 ................ +read 512/512 bytes +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) From patchwork Fri May 27 08:19:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 12863126 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 92BB3C433FE for ; Fri, 27 May 2022 08:19:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238619AbiE0ITo (ORCPT ); Fri, 27 May 2022 04:19:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349235AbiE0ITn (ORCPT ); Fri, 27 May 2022 04:19:43 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 890EF10275F; Fri, 27 May 2022 01:19:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=QpHkmoIzOceoktT2k1JNOry3OQ+UDiFzBcJTBQdMTag=; b=YZMrR+74PxTnkIiLlO1gQQuSgX uRaHFreeIAcUyebsBQIQCec6NvFMswA6Hq2AYoNLp2q+t2VAdkWXVGOcDDeaw86yf/9MmtCEY8KM4 ANgrzy9+hdjZEZOmNTPLzQbal+0YLqr2a8lY986yUPvJvhjrh10oSTHboHGLggzoFWED+pQdBYYbK MTDMI2ZEcNvN1EY/9LOXrQ8QXjKNNkrn4sGxmS8LO96qfddZ/Nn3wQDM6IbveMUQxPIFEK7QAhUNo V3vSD3sarnXKy8zAPM4HNTnbaGLtVBhGpSJLjY6Ul53wfn8RNNCKerw3yprx64Jx/MTdGDdKVW95b 11Zx4T5A==; Received: from [2001:4bb8:18c:7298:b5ab:7d49:c6be:2011] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1nuVC8-00H03r-Pe; Fri, 27 May 2022 08:19:41 +0000 From: Christoph Hellwig To: fstests@vger.kernel.org Cc: linux-btrfs@vger.kernel.org, Qu Wenruo Subject: [PATCH 09/10] btrfs: test buffered I/O read repair with interleaved corrupted sectors Date: Fri, 27 May 2022 10:19:14 +0200 Message-Id: <20220527081915.2024853-10-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220527081915.2024853-1-hch@lst.de> References: <20220527081915.2024853-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org Test that repair handles the case where it needs to read from more than a single mirror on the raid1c3 profile and needs to take turns over the mirrors to recover data for the whole read. Signed-off-by: Christoph Hellwig Reviewed-by: Qu Wenruo Reviewed-by: Anand Jain --- tests/btrfs/266 | 93 +++++++++++++++++++++++++++++++++++++ tests/btrfs/266.out | 109 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 202 insertions(+) create mode 100755 tests/btrfs/266 create mode 100644 tests/btrfs/266.out diff --git a/tests/btrfs/266 b/tests/btrfs/266 new file mode 100755 index 00000000..c70e4b2e --- /dev/null +++ b/tests/btrfs/266 @@ -0,0 +1,93 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2017 Liu Bo. All Rights Reserved. +# Copyright (c) 2022 Christoph Hellwig. +# +# FS QA Test 266 +# +# Test that btrfs raid repair on a raid1c3 profile can repair interleaving +# errors on all mirrors. +# + +. ./common/preamble +_begin_fstest auto quick read_repair + +# Import common functions. +. ./common/filter + +# real QA test starts here + +_supported_fs btrfs +_require_scratch_dev_pool 3 + +_require_odirect +# Overwriting data is forbidden on a zoned block device +_require_non_zoned_device "${SCRATCH_DEV}" + +_scratch_dev_pool_get 3 +# step 1, create a raid1 btrfs which contains one 128k file. +echo "step 1......mkfs.btrfs" + +mkfs_opts="-d raid1c3 -b 1G" +_scratch_pool_mkfs $mkfs_opts >>$seqres.full 2>&1 + +_scratch_mount + +$XFS_IO_PROG -f -d -c "pwrite -S 0xaa -b 256K 0 256K" \ + "$SCRATCH_MNT/foobar" | \ + _filter_xfs_io_offset + +# step 2, corrupt 4k in each copy +echo "step 2......corrupt file extent" + +# ensure btrfs-map-logical sees the tree updates +sync + +logical=$(_btrfs_get_first_logical $SCRATCH_MNT/foobar) + +physical1=$(_btrfs_get_physical ${logical} 1) +devpath1=$(_btrfs_get_device_path ${logical} 1) + +physical2=$(_btrfs_get_physical ${logical} 2) +devpath2=$(_btrfs_get_device_path ${logical} 2) + +physical3=$(_btrfs_get_physical ${logical} 3) +devpath3=$(_btrfs_get_device_path ${logical} 3) + +_scratch_unmount + +$XFS_IO_PROG -d -c "pwrite -S 0xbd -b 64K $physical3 64K" \ + $devpath3 > /dev/null + +$XFS_IO_PROG -d -c "pwrite -S 0xba -b 64K $physical1 128K" \ + $devpath1 > /dev/null + +$XFS_IO_PROG -d -c "pwrite -S 0xbb -b 64K $((physical2 + 65536)) 128K" \ + $devpath2 > /dev/null + +$XFS_IO_PROG -d -c "pwrite -S 0xbc -b 64K $((physical3 + (2 * 65536))) 128K" \ + $devpath3 > /dev/null + +_scratch_mount + +# step 3, 128k dio read (this read can repair bad copy) +echo "step 3......repair the bad copy" + +_btrfs_buffered_read_on_mirror 0 3 "$SCRATCH_MNT/foobar" 0 256K +_btrfs_buffered_read_on_mirror 1 3 "$SCRATCH_MNT/foobar" 0 256K +_btrfs_buffered_read_on_mirror 2 3 "$SCRATCH_MNT/foobar" 0 256K + +_scratch_unmount + +echo "step 4......check if the repair worked" +$XFS_IO_PROG -d -c "pread -v -b 512 $physical1 512" $devpath1 |\ + _filter_xfs_io_offset +$XFS_IO_PROG -d -c "pread -v -b 512 $physical2 512" $devpath2 |\ + _filter_xfs_io_offset +$XFS_IO_PROG -d -c "pread -v -b 512 $physical3 512" $devpath3 |\ + _filter_xfs_io_offset + +_scratch_dev_pool_put +# success, all done +status=0 +exit diff --git a/tests/btrfs/266.out b/tests/btrfs/266.out new file mode 100644 index 00000000..fcf2f5b8 --- /dev/null +++ b/tests/btrfs/266.out @@ -0,0 +1,109 @@ +QA output created by 266 +step 1......mkfs.btrfs +wrote 262144/262144 bytes +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +step 2......corrupt file extent +step 3......repair the bad copy +step 4......check if the repair worked +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 ................ +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 ................ +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 ................ +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 ................ +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 ................ +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 ................ +read 512/512 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 ................ +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 ................ +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 ................ +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 ................ +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 ................ +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 ................ +read 512/512 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 ................ +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 ................ +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 ................ +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 ................ +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 ................ +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 ................ +read 512/512 bytes +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) From patchwork Fri May 27 08:19:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 12863127 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E4B46C43217 for ; Fri, 27 May 2022 08:19:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349257AbiE0ITq (ORCPT ); Fri, 27 May 2022 04:19:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349284AbiE0ITp (ORCPT ); Fri, 27 May 2022 04:19:45 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28FE410275F; Fri, 27 May 2022 01:19:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=OKtvuGgEIUMk04SUrRdhIG+w4dH+tQypQORLIUZ01YI=; b=czijI7G/NYPycVnrEeyNd4LuKs NCmj/PqK8KHEOjHEJQU+pUIHclxThIgRWG7ranFRbxF39XI4Az0FVh0RorMIpy7GkSsp/leNaS3ZB sXy0H2NXzLStNftlaM8HsNZy7p7UI4y4Hn5FpmgzOIOElbumCvg2+YLWPyApKJU+KA7+NieVO/oHO NDekzoktuZYFr7b8xtcY4NuprpdVnl38g2PBrPIXzM/WiBbX5COvd1KmByJbbl4nX4a+aLbga5tJM 3Ii300qjPF8fNd49ATY7+YbAM3sz61qozR5TamqoZG5NmVs2ilCDX3px4sljdc2x8ILjmSBz5UCFJ QHYem5GA==; Received: from [2001:4bb8:18c:7298:b5ab:7d49:c6be:2011] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1nuVCB-00H04h-Bq; Fri, 27 May 2022 08:19:43 +0000 From: Christoph Hellwig To: fstests@vger.kernel.org Cc: linux-btrfs@vger.kernel.org Subject: [PATCH 10/10] btrfs: test direct I/O read repair with interleaved corrupted sectors Date: Fri, 27 May 2022 10:19:15 +0200 Message-Id: <20220527081915.2024853-11-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220527081915.2024853-1-hch@lst.de> References: <20220527081915.2024853-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org Test that repair handles the case where it needs to read from more than a single mirror on the raid1c3 profile and needs to take turns over the mirrors to recover data for the whole read. Signed-off-by: Christoph Hellwig Reviewed-by: Qu Wenruo Reviewed-by: Anand Jain --- tests/btrfs/267 | 93 +++++++++++++++++++++++++++++++++++++ tests/btrfs/267.out | 109 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 202 insertions(+) create mode 100755 tests/btrfs/267 create mode 100644 tests/btrfs/267.out diff --git a/tests/btrfs/267 b/tests/btrfs/267 new file mode 100755 index 00000000..cf19fdc8 --- /dev/null +++ b/tests/btrfs/267 @@ -0,0 +1,93 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2017 Liu Bo. All Rights Reserved. +# Copyright (c) 2022 Christoph Hellwig. +# +# FS QA Test 267 +# +# Test that btrfs buffered read repair on a raid1c3 profile can repair +# interleaving errors on all mirrors. +# + +. ./common/preamble +_begin_fstest auto quick read_repair + +# Import common functions. +. ./common/filter + +# real QA test starts here + +_supported_fs btrfs +_require_scratch_dev_pool 3 + +_require_odirect +# Overwriting data is forbidden on a zoned block device +_require_non_zoned_device "${SCRATCH_DEV}" + +_scratch_dev_pool_get 3 +# step 1, create a raid1 btrfs which contains one 128k file. +echo "step 1......mkfs.btrfs" + +mkfs_opts="-d raid1c3 -b 1G" +_scratch_pool_mkfs $mkfs_opts >>$seqres.full 2>&1 + +_scratch_mount + +$XFS_IO_PROG -f -d -c "pwrite -S 0xaa -b 256K 0 256K" \ + "$SCRATCH_MNT/foobar" | \ + _filter_xfs_io_offset + +# step 2, corrupt 4k in each copy +echo "step 2......corrupt file extent" + +# ensure btrfs-map-logical sees the tree updates +sync + +logical=$(_btrfs_get_first_logical $SCRATCH_MNT/foobar) + +physical1=$(_btrfs_get_physical ${logical} 1) +devpath1=$(_btrfs_get_device_path ${logical} 1) + +physical2=$(_btrfs_get_physical ${logical} 2) +devpath2=$(_btrfs_get_device_path ${logical} 2) + +physical3=$(_btrfs_get_physical ${logical} 3) +devpath3=$(_btrfs_get_device_path ${logical} 3) + +_scratch_unmount + +$XFS_IO_PROG -d -c "pwrite -S 0xbd -b 64K $physical3 64K" \ + $devpath3 > /dev/null + +$XFS_IO_PROG -d -c "pwrite -S 0xba -b 64K $physical1 128K" \ + $devpath1 > /dev/null + +$XFS_IO_PROG -d -c "pwrite -S 0xbb -b 64K $((physical2 + 65536)) 128K" \ + $devpath2 > /dev/null + +$XFS_IO_PROG -d -c "pwrite -S 0xbc -b 64K $((physical3 + (2 * 65536))) 128K" \ + $devpath3 > /dev/null + +_scratch_mount + +# step 3, 128k dio read (this read can repair bad copy) +echo "step 3......repair the bad copy" + +_btrfs_direct_read_on_mirror 0 3 "$SCRATCH_MNT/foobar" 0 256K +_btrfs_direct_read_on_mirror 1 3 "$SCRATCH_MNT/foobar" 0 256K +_btrfs_direct_read_on_mirror 2 3 "$SCRATCH_MNT/foobar" 0 256K + +_scratch_unmount + +echo "step 4......check if the repair worked" +$XFS_IO_PROG -d -c "pread -v -b 512 $physical1 512" $devpath1 |\ + _filter_xfs_io_offset +$XFS_IO_PROG -d -c "pread -v -b 512 $physical2 512" $devpath2 |\ + _filter_xfs_io_offset +$XFS_IO_PROG -d -c "pread -v -b 512 $physical3 512" $devpath3 |\ + _filter_xfs_io_offset + +_scratch_dev_pool_put +# success, all done +status=0 +exit diff --git a/tests/btrfs/267.out b/tests/btrfs/267.out new file mode 100644 index 00000000..2bdd32ea --- /dev/null +++ b/tests/btrfs/267.out @@ -0,0 +1,109 @@ +QA output created by 267 +step 1......mkfs.btrfs +wrote 262144/262144 bytes +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +step 2......corrupt file extent +step 3......repair the bad copy +step 4......check if the repair worked +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 ................ +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 ................ +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 ................ +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 ................ +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 ................ +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 ................ +read 512/512 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 ................ +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 ................ +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 ................ +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 ................ +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 ................ +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 ................ +read 512/512 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 ................ +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 ................ +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 ................ +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 ................ +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 ................ +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 ................ +read 512/512 bytes +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)