public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Anand Jain <anand.jain@oracle.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH] fstests: btrfs test read from disks of different generation
Date: Tue, 19 Mar 2019 19:35:30 +0800	[thread overview]
Message-ID: <1552995330-28927-2-git-send-email-anand.jain@oracle.com> (raw)
In-Reply-To: <1552995330-28927-1-git-send-email-anand.jain@oracle.com>

Verify file read from disks assembled with different generations.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 tests/btrfs/184     | 132 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/184.out |   9 ++++
 tests/btrfs/group   |   1 +
 3 files changed, 142 insertions(+)
 create mode 100755 tests/btrfs/184
 create mode 100644 tests/btrfs/184.out

diff --git a/tests/btrfs/184 b/tests/btrfs/184
new file mode 100755
index 000000000000..1791fdb079b7
--- /dev/null
+++ b/tests/btrfs/184
@@ -0,0 +1,132 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2019 YOUR NAME HERE.  All Rights Reserved.
+#
+# FS QA Test 184
+#
+# Test read on raid1 assembled with disks of different generations.
+#  Steps:
+#   . Use btrfs snapshot on the test_dir to create disk images of
+#     different generations (lets say generation a and generation b).
+#   . Mount one disk from generation a and another disk from generation
+#     b, and verify the file md5sum.
+#  Note: readmirror feature (in the btrfs ml) helps to reproduce the
+#     problem consistently.
+#  Fix-by: kernel patch
+#   [PATCH] btrfs: fix read corrpution on disks of different generation
+
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1	# failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+	_scratch_unmount > /dev/null 2>&1
+	_destroy_loop_device $dev1
+	_destroy_loop_device $dev2
+	btrfs subvolume delete $img_subvol > /dev/null 2>&1
+	btrfs subvolume delete $img_subvol_at_gen_a > /dev/null 2>&1
+	[[ -z $scratch_dev_pool_saved ]] || \
+			SCRATCH_DEV_POOL="$scratch_dev_pool_saved"
+	_scratch_dev_pool_put
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# remove previous $seqres.full before test
+rm -f $seqres.full
+
+# real QA test starts here
+
+# Modify as appropriate.
+_supported_fs generic
+_supported_os Linux
+_require_test
+_require_scratch_dev_pool 2
+
+_test_unmount
+_require_btrfs_forget_if_not_fs_loadable
+_test_mount
+
+_scratch_dev_pool_get 2
+scratch_dev_pool_saved=""
+
+img_subvol=$TEST_DIR/img_subvol
+img_subvol_at_gen_a=$TEST_DIR/img_subvol_at_gen_a
+dev1_img=$img_subvol/d1
+dev2_img=$img_subvol/d2
+dev1_img_at_gen_a=$img_subvol_at_gen_a/d1
+dev2_img_at_gen_a=$img_subvol_at_gen_a/d2
+
+$BTRFS_UTIL_PROG subvolume create $img_subvol >> /dev/null 2>&1 || \
+					_fail "subvol create failed"
+
+$XFS_IO_PROG -f -c "pwrite -S 0xdd 0 256m" $dev1_img >> /dev/null 2>&1
+$XFS_IO_PROG -f -c "pwrite -S 0xdd 0 256m" $dev2_img >> /dev/null 2>&1
+
+dev1=$(_create_loop_device $dev1_img)
+dev2=$(_create_loop_device $dev2_img)
+
+scratch_dev_pool_saved="$SCRATCH_DEV_POOL"
+SCRATCH_DEV_POOL="$dev1 $dev2"
+_scratch_pool_mkfs -d raid1 -m raid1 >> $seqres.full 2>&1 || \
+			_fail  "mkfs failed on $SCRATCH_DEV_POOL"
+
+
+_mount "-o max_inline=0,nodatacow,device=$dev1" $dev2 $SCRATCH_MNT || \
+					_fail "mount for gen a failed"
+
+$XFS_IO_PROG -f -c "pwrite -S 0xaa 0 4K" $SCRATCH_MNT/foobar >> /dev/null 2>&1
+
+echo md5sum at generation aa
+md5sum $SCRATCH_MNT/foobar | _filter_scratch
+echo
+_scratch_unmount
+
+$BTRFS_UTIL_PROG subvolume snapshot $img_subvol $img_subvol_at_gen_a \
+		>> /dev/null 2>&1 || _fail "subvol create failed"
+
+_mount "-o max_inline=0,nodatacow,device=$dev1" $dev2 $SCRATCH_MNT || \
+					_fail "mount for gen b failed"
+
+$XFS_IO_PROG -f -c "pwrite -S 0xbb 0 4K" $SCRATCH_MNT/foobar >> /dev/null 2>&1
+
+echo md5sum at generation bb
+md5sum $SCRATCH_MNT/foobar | _filter_scratch
+echo
+
+_scratch_unmount
+
+_destroy_loop_device $dev1
+_destroy_loop_device $dev2
+
+_test_unmount
+_btrfs_forget_if_not_fs_reload
+_test_mount
+
+dev1=$(_create_loop_device $dev1_img_at_gen_a)
+dev2=$(_create_loop_device $dev2_img)
+
+# mount with readmirror option, if it fails try without but the
+# problem may or may not be reproduced without the readmirror option.
+_mount "-o ro,device=$dev1,readmirror=devid$dev1_devid" $dev2 $SCRATCH_MNT > \
+								/dev/null 2>&1
+[[ $? != 0 ]] && (echo "readmirror option notfound" >> $seqres.full;
+		  _mount "-o ro,device=$dev1" $dev2 $SCRATCH_MNT || \
+					_fail "mount at gen ab failed";)
+echo md5sum at generation ab
+md5sum $SCRATCH_MNT/foobar | _filter_scratch
+
+# success, all done
+status=0
+exit
diff --git a/tests/btrfs/184.out b/tests/btrfs/184.out
new file mode 100644
index 000000000000..cc71898920ec
--- /dev/null
+++ b/tests/btrfs/184.out
@@ -0,0 +1,9 @@
+QA output created by 184
+md5sum at generation aa
+3e4309c7cc81f23d45e260a8f13ca860  SCRATCH_MNT/foobar
+
+md5sum at generation bb
+055a2a7342c0528969e1b6e32aadeee3  SCRATCH_MNT/foobar
+
+md5sum at generation ab
+055a2a7342c0528969e1b6e32aadeee3  SCRATCH_MNT/foobar
diff --git a/tests/btrfs/group b/tests/btrfs/group
index f3227c1708d9..a4f8fe1eb5ce 100644
--- a/tests/btrfs/group
+++ b/tests/btrfs/group
@@ -186,3 +186,4 @@
 181 auto quick balance
 182 auto quick balance
 183 auto quick clone compress punch
+184 other
-- 
1.8.3.1


  reply	other threads:[~2019-03-19 11:35 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-19 11:35 [PATCH RFC] btrfs: fix read corrpution from disks of different generation Anand Jain
2019-03-19 11:35 ` Anand Jain [this message]
2020-04-06 12:00   ` [PATCH v2] fstests: btrfs test read " Anand Jain
2019-03-19 12:07 ` [PATCH RFC] btrfs: fix read corrpution " Qu Wenruo
2019-03-19 23:41   ` Anand Jain
2019-03-20  1:02     ` Qu Wenruo
2019-03-20  5:47       ` Anand Jain
2019-03-20  6:19         ` Qu Wenruo
2019-03-20 14:00           ` Anand Jain
2019-03-20 14:40             ` Qu Wenruo
2019-03-20 15:40               ` Zygo Blaxell
2019-03-21  6:37                 ` Anand Jain
2019-03-20  6:27         ` Qu Wenruo
2019-03-20 13:54           ` Anand Jain
2019-03-20 15:46             ` Zygo Blaxell

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=1552995330-28927-2-git-send-email-anand.jain@oracle.com \
    --to=anand.jain@oracle.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox