From patchwork Wed Jun 22 04:58:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 12890132 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 7E612C43334 for ; Wed, 22 Jun 2022 04:59:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356985AbiFVE7E (ORCPT ); Wed, 22 Jun 2022 00:59:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356974AbiFVE7A (ORCPT ); Wed, 22 Jun 2022 00:59:00 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70C8931500; Tue, 21 Jun 2022 21:58:51 -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=96mh2sV8EWV8H1TFT3lVYjLYQMPC2oQnKMcaC3/41J0=; b=DBNMYkdi0n/4ln6nIEpBEgyLUF DVP1ccks0ItkMeFd4/REhRMp1fQV9yYQBA82nVUeIT+/+wUq62TFKlwdacSclfYkhqZsOjXrvYVXV umSvFp268ij2d45tgrpmCdFO3ctQ7uhurKUSYQszwC681UAPeUTQBIpcCcCSz4qqZRniRbhj+4ejx GgLHX3H3hrgzlH8brkr0iDEnGOiq9llL+PW6mrbSouzsefkTe/CAN4XhcEUwQd8QghB1mHgklTwMy DRFSpZ4Jxf2zH/xxMRIdO17Fzmzq/k/lIVzzNIKhrRnSI45KThlbZL/Q1/eiTWnZ00miBvxQ2HVcK pcO4cT2g==; Received: from 213-225-1-25.nat.highway.a1.net ([213.225.1.25] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1o3sS2-008WjV-CU; Wed, 22 Jun 2022 04:58:50 +0000 From: Christoph Hellwig To: fstests@vger.kernel.org Cc: linux-btrfs@vger.kernel.org Subject: [PATCH 1/4] btrfs: fix the_btrfs_get_physical invocation in btrfs-map-logical Date: Wed, 22 Jun 2022 06:58:41 +0200 Message-Id: <20220622045844.3219390-2-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220622045844.3219390-1-hch@lst.de> References: <20220622045844.3219390-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 The -b flag without an argument is not supported, so remove it. Signed-off-by: Christoph Hellwig --- common/btrfs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/btrfs b/common/btrfs index c7058918..14ad890e 100644 --- a/common/btrfs +++ b/common/btrfs @@ -537,7 +537,7 @@ _btrfs_get_physical() _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 >> $seqres.full 2>&1 $BTRFS_MAP_LOGICAL_PROG -l $logical $SCRATCH_DEV | \ $AWK_PROG "(\$1 ~ /mirror/ && \$2 ~ /$stripe/) { print \$6 }" } From patchwork Wed Jun 22 04:58:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 12890133 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 BC02CC433EF for ; Wed, 22 Jun 2022 04:59:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356755AbiFVE7I (ORCPT ); Wed, 22 Jun 2022 00:59:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357005AbiFVE7D (ORCPT ); Wed, 22 Jun 2022 00:59:03 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6FE1B35858; Tue, 21 Jun 2022 21:58:54 -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=5Pq1L/fAWak8/gN0+y+r3SK/kler+Labzc9dCwUab+c=; b=OmKXIlY7Tpw32+qAoXstAIFMds PPtorIKg1XN2nrQ0IdmmTy9/9n7yZciQx8zRfi0FLthF1trj+vne4R0Nm/s/yVVZ8HJlTsjaA3Nqt AV+GMBY1zp8k6l6dmyOgzQ/ytqbP4MUVIPhKAawukT4vvS2xqan2fSJJ6hpfiG296WIepRyQOUiDA lyysdg7DEzMQ973t+762CUFbf+gzSp/b4pI2ASogHe1//1cJl0S+NpZypPTtfwcPHUb7PdHxlBrBg SdA9frGdvxRv4nnvxZ1DyPFDeo0MPzlGsrLHvEYRU/5evqHN1cF6SRBMwVQGZsh68RPjpxu7H/AET t0g87BQw==; Received: from 213-225-1-25.nat.highway.a1.net ([213.225.1.25] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1o3sS5-008WkP-LZ; Wed, 22 Jun 2022 04:58:54 +0000 From: Christoph Hellwig To: fstests@vger.kernel.org Cc: linux-btrfs@vger.kernel.org Subject: [PATCH 2/4] btrfs; add a test for impossible repair cases Date: Wed, 22 Jun 2022 06:58:42 +0200 Message-Id: <20220622045844.3219390-3-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220622045844.3219390-1-hch@lst.de> References: <20220622045844.3219390-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 Verify that a repair attempt that can't succeed because all copies are bad returns a proper I/O error and doesn't cause any deadlocks. Signed-off-by: Christoph Hellwig --- tests/btrfs/268 | 62 +++++++++++++++++++++++++++++++++++++++++++++ tests/btrfs/268.out | 7 +++++ 2 files changed, 69 insertions(+) create mode 100755 tests/btrfs/268 create mode 100644 tests/btrfs/268.out diff --git a/tests/btrfs/268 b/tests/btrfs/268 new file mode 100755 index 00000000..5043bb02 --- /dev/null +++ b/tests/btrfs/268 @@ -0,0 +1,62 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2022 Christoph Hellwig. +# +# FS QA Test 268 +# +# Test that btrfs read repair on a raid1 profile won't loop forever if data +# is corrupted on both mirrors and can't be recovered. +# + +. ./common/preamble +_begin_fstest auto quick read_repair + +. ./common/filter + +_supported_fs btrfs +_require_odirect +_require_non_zoned_device "${SCRATCH_DEV}" # no overwrites on zoned devices +_require_scratch_dev_pool 2 +_scratch_dev_pool_get 2 + +echo "step 1......mkfs.btrfs" + +_scratch_pool_mkfs "-d raid1 -b 1G" >>$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 + +# 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 + +echo "step 2......corrupt file extent" +$XFS_IO_PROG -d -c "pwrite -S 0xba -b 4K $physical1 4K" \ + $devpath1 > /dev/null +$XFS_IO_PROG -d -c "pwrite -S 0xba -b 4K $physical2 4K" \ + $devpath2 > /dev/null + +_scratch_mount + +echo "step 3......try to repair" +$XFS_IO_PROG -d -c "pread -b 4K 0 4K" $SCRATCH_MNT/foobar + +_scratch_unmount +_scratch_dev_pool_put +# success, all done +status=0 +exit diff --git a/tests/btrfs/268.out b/tests/btrfs/268.out new file mode 100644 index 00000000..d28b37b3 --- /dev/null +++ b/tests/btrfs/268.out @@ -0,0 +1,7 @@ +QA output created by 268 +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......try to repair +pread: Input/output error From patchwork Wed Jun 22 04:58:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 12890134 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 8A6B7C43334 for ; Wed, 22 Jun 2022 04:59:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356974AbiFVE7J (ORCPT ); Wed, 22 Jun 2022 00:59:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357008AbiFVE7D (ORCPT ); Wed, 22 Jun 2022 00:59:03 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE98535861; Tue, 21 Jun 2022 21:58:57 -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=xf881ymmHgZZ9GBnXHqAh+UxVhriB0OZ+2fjdoLSoUM=; b=jZB/o0wDEgM8f1bop9zywIAngr JPqPOLcO4bXVzX/BbsDnGP397bOFB7kmeN7dblkkgA5KGtjPQcDE96/hn9N6f8rXzT3lnrsj71lmi S710JHWYmE1J+RirKZGSTjWD/lfM5fi6JXO/lIceLij5VC359+HAJryzrJ58xIles/E4MO8nXSnkb D5hyUCY6dT+lGvpDzJL4VDZ8Mh+KcB17hAb+wOqpq4iV83KPKvq5CXK096N+qyIkiaKcLL16YI0y8 K9QfF2QvrXHmKUL/PZBzHb0HhdslM9j212Qg8Cq/bOxkLdZdzMhQ9dhRm2q3kqeE3vNqGWBuoavbl npPDkaJA==; Received: from 213-225-1-25.nat.highway.a1.net ([213.225.1.25] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1o3sS8-008Wl0-Rh; Wed, 22 Jun 2022 04:58:57 +0000 From: Christoph Hellwig To: fstests@vger.kernel.org Cc: linux-btrfs@vger.kernel.org Subject: [PATCH 3/4] btrfs: test checker pattern corruption on raid10 Date: Wed, 22 Jun 2022 06:58:43 +0200 Message-Id: <20220622045844.3219390-4-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220622045844.3219390-1-hch@lst.de> References: <20220622045844.3219390-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 Check read repair for the case where the corruption is spread over the different legs of a raid10 set. Signed-off-by: Christoph Hellwig --- tests/btrfs/269 | 73 +++++++++++++++++++++++++++++++++++++++++++++ tests/btrfs/269.out | 41 +++++++++++++++++++++++++ 2 files changed, 114 insertions(+) create mode 100755 tests/btrfs/269 create mode 100644 tests/btrfs/269.out diff --git a/tests/btrfs/269 b/tests/btrfs/269 new file mode 100755 index 00000000..3c11da3f --- /dev/null +++ b/tests/btrfs/269 @@ -0,0 +1,73 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2022 Christoph Hellwig. +# +# FS QA Test 269 +# +# Test btrfs read repair over tricky stripe boundaries on the raid10 profile: +# +# | stripe 0 | stripe 2 +# -------------------------------- +# mirror 1 | I/O FAIL | GOOD +# mirror 2 | GOOD | CSUM FAIL +# + +. ./common/preamble +_begin_fstest auto quick read_repair + +. ./common/filter + +_supported_fs btrfs +_require_odirect +_require_non_zoned_device "${SCRATCH_DEV}" # no overwrites on zoned devices +_require_scratch_dev_pool 4 +_scratch_dev_pool_get 4 + +echo "step 1......mkfs.btrfs" + +_scratch_pool_mkfs "-d raid10 -b 1G" >>$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 + +# 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) + +physical4=$(_btrfs_get_physical ${logical} 3) +devpath4=$(_btrfs_get_device_path ${logical} 3) + +_scratch_unmount + +echo "step 2......corrupt file extent" + +$XFS_IO_PROG -d -c "pwrite -S 0xbd -b 64K $physical1 64K" \ + $devpath1 > /dev/null +$XFS_IO_PROG -d -c "pwrite -S 0xbb -b 64K $((physical4 + 65536)) 64K" \ + $devpath4 > /dev/null + +_scratch_mount + +echo "step 3......repair the bad copy" + +_btrfs_direct_read_on_mirror 0 2 "$SCRATCH_MNT/foobar" 0 128K +_btrfs_direct_read_on_mirror 1 2 "$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 $((physical4 + 65536)) 512" $devpath4 |\ + _filter_xfs_io_offset + +_scratch_dev_pool_put +# success, all done +status=0 +exit diff --git a/tests/btrfs/269.out b/tests/btrfs/269.out new file mode 100644 index 00000000..d3ad7f07 --- /dev/null +++ b/tests/btrfs/269.out @@ -0,0 +1,41 @@ +QA output created by 269 +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) From patchwork Wed Jun 22 04:58:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 12890135 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 6B03BCCA485 for ; Wed, 22 Jun 2022 04:59:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357005AbiFVE7K (ORCPT ); Wed, 22 Jun 2022 00:59:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357010AbiFVE7D (ORCPT ); Wed, 22 Jun 2022 00:59:03 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0FAD2981B; Tue, 21 Jun 2022 21:59:00 -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=GyCCPoZj3PX6jdclZjF9+An2q71g86u7wcDPTJBoSnY=; b=Oht0ZuvNKZ+sS6OqK+hxBvoeCw iuLsoUrXw8UKOIV8q/f1Zr/xR5aPoHHJpeP6jfGa9TFZ5znu3C9FcsdL4NQIc1ZMX2aAoBr7hi0eX 9JJpXPI9QD7IZpbHf0Jw+izyWwlM3CtpUQ9xAVU9MWOqmhlS2n8qpK4qTFLT2CxvKcRpV7gQd3sOM f9w2qmS+yRDLB3kyiW2kOhLGbcoIfsJmpFcGHZ0SQviEXOy7TLfw2PYWiBvMpqAy9vs0fh849uL0n XRhbOTxjN9eK3rop2vZ5y2HD8/CpmpsWAMQzGEPAkT+rprud6kYjcpxzRBVw6sXpjNUQykwFu0P9H H2kF4AFQ==; Received: from 213-225-1-25.nat.highway.a1.net ([213.225.1.25] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1o3sSB-008WmL-Nz; Wed, 22 Jun 2022 04:59:00 +0000 From: Christoph Hellwig To: fstests@vger.kernel.org Cc: linux-btrfs@vger.kernel.org Subject: [PATCH 4/4] btrfs: test read repair on a corrupted compressed extent Date: Wed, 22 Jun 2022 06:58:44 +0200 Message-Id: <20220622045844.3219390-5-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220622045844.3219390-1-hch@lst.de> References: <20220622045844.3219390-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 Exercise read repair on a corrupted compressed sector. Signed-off-by: Christoph Hellwig Signed-off-by: Christoph Hellwig --- tests/btrfs/270 | 79 +++++++++++++++++++++++++++++++++++++++++++++ tests/btrfs/270.out | 41 +++++++++++++++++++++++ 2 files changed, 120 insertions(+) create mode 100755 tests/btrfs/270 create mode 100644 tests/btrfs/270.out diff --git a/tests/btrfs/270 b/tests/btrfs/270 new file mode 100755 index 00000000..4229a02c --- /dev/null +++ b/tests/btrfs/270 @@ -0,0 +1,79 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2017 Liu Bo. All Rights Reserved. +# +# FS QA Test 270 +# +# Regression test for btrfs buffered read repair of compressed data. +# +. ./common/preamble +_begin_fstest auto quick read_repair + +. ./common/filter + +_supported_fs btrfs +_require_btrfs_command inspect-internal dump-tree +_require_non_zoned_device "${SCRATCH_DEV}" # no overwrites on zoned devices +_require_scratch_dev_pool 2 +_scratch_dev_pool_get 2 + +get_physical() +{ + 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 \$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}" +} + + +echo "step 1......mkfs.btrfs" +_check_minimal_fs_size $(( 1024 * 1024 * 1024 )) +_scratch_pool_mkfs "-d raid1 -b 1G" >>$seqres.full 2>&1 +_scratch_mount -ocompress + +# Create a file with all data being compressed +$XFS_IO_PROG -f -c "pwrite -S 0xaa -W -b 128K 0 128K" \ + "$SCRATCH_MNT/foobar" | _filter_xfs_io_offset + +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}) + +_scratch_unmount +echo "step 2......corrupt file extent" +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 + +echo "step 3......repair the bad copy" +_btrfs_buffered_read_on_mirror 1 2 "$SCRATCH_MNT/foobar" 0 128K + +_scratch_unmount + +echo "step 4......check if the repair worked" +$XFS_IO_PROG -c "pread -v -b 512 $physical 512" $devpath |\ + _filter_xfs_io_offset + +_scratch_dev_pool_put +# success, all done +status=0 +exit diff --git a/tests/btrfs/270.out b/tests/btrfs/270.out new file mode 100644 index 00000000..53a80692 --- /dev/null +++ b/tests/btrfs/270.out @@ -0,0 +1,41 @@ +QA output created by 270 +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)