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)