All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
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	[thread overview]
Message-ID: <20220622045844.3219390-3-hch@lst.de> (raw)
In-Reply-To: <20220622045844.3219390-1-hch@lst.de>

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 <hch@lst.de>
---
 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
-- 
2.30.2


  parent reply	other threads:[~2022-06-22  4:59 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-22  4:58 btrfs read repair: more tests Christoph Hellwig
2022-06-22  4:58 ` [PATCH 1/4] btrfs: fix the_btrfs_get_physical invocation in btrfs-map-logical Christoph Hellwig
2022-06-22  4:58 ` Christoph Hellwig [this message]
2022-06-22  4:58 ` [PATCH 3/4] btrfs: test checker pattern corruption on raid10 Christoph Hellwig
2022-06-22  4:58 ` [PATCH 4/4] btrfs: test read repair on a corrupted compressed extent Christoph Hellwig
2022-06-22  9:21   ` Christoph Hellwig
2022-06-22 12:41     ` Zorro Lang
2022-06-22 13:07       ` Christoph Hellwig
2022-06-24  2:25         ` Zorro Lang
2022-06-29 14:00 ` btrfs read repair: more tests Zorro Lang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220622045844.3219390-3-hch@lst.de \
    --to=hch@lst.de \
    --cc=fstests@vger.kernel.org \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.