linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Anand Jain <anand.jain@oracle.com>
To: linux-btrfs@vger.kernel.org
Cc: jthumshirn@suse.de, dsterba@suse.cz
Subject: [PATCH Fix-title-prefix] btrfs-progs: misc-tests-021 fix restore overlapped on disk's stale data
Date: Wed,  4 Sep 2019 21:29:47 +0800	[thread overview]
Message-ID: <20190904132947.1232-1-anand.jain@oracle.com> (raw)
In-Reply-To: <23f82b13-5050-0acd-49fb-1ecd06811b8d@suse.de>

As misc-tests/021 image dump is restored on the same original loop
device, this overlaps with the stale data and makes the test pass
falsely.

Fix this by using a new device for restore.

And also, the btrfs-image dump and restore doesn't not collect the data,
so any read on the files should be avoided. So instead of file data use
file stat data for the md5sum.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reported-by: Johannes Thumshirn <jthumshirn@suse.de>
---
 tests/misc-tests/021-image-multi-devices/test.sh | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/tests/misc-tests/021-image-multi-devices/test.sh b/tests/misc-tests/021-image-multi-devices/test.sh
index b1013b5d2596..5ed8f4b01457 100755
--- a/tests/misc-tests/021-image-multi-devices/test.sh
+++ b/tests/misc-tests/021-image-multi-devices/test.sh
@@ -10,17 +10,18 @@ check_prereq btrfs
 
 setup_root_helper
 
-setup_loopdevs 2
+setup_loopdevs 3
 prepare_loopdevs
 loop1=${loopdevs[1]}
 loop2=${loopdevs[2]}
+loop3=${loopdevs[3]}
 
 # Create the test file system.
 
 run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f "$loop1" "$loop2"
 run_check $SUDO_HELPER mount "$loop1" "$TEST_MNT"
 run_check $SUDO_HELPER dd bs=1M count=1 if=/dev/zero of="$TEST_MNT/foobar"
-orig_md5=$(run_check_stdout md5sum "$TEST_MNT/foobar" | cut -d ' ' -f 1)
+orig_md5=$(run_check_stdout stat "$TEST_MNT/foobar" | md5sum | cut -d ' ' -f 1)
 run_check $SUDO_HELPER umount "$TEST_MNT"
 
 # Create the image to restore later.
@@ -32,13 +33,13 @@ run_check $SUDO_HELPER "$TOP/btrfs-image" "$loop1" "$IMAGE"
 run_check $SUDO_HELPER wipefs -a "$loop1"
 run_check $SUDO_HELPER wipefs -a "$loop2"
 
-run_check $SUDO_HELPER "$TOP/btrfs-image" -r "$IMAGE" "$loop1"
+run_check $SUDO_HELPER "$TOP/btrfs-image" -r "$IMAGE" "$loop3"
 
 # Run check to make sure there is nothing wrong for the recovered image
-run_check $SUDO_HELPER "$TOP/btrfs" check "$loop1"
+run_check $SUDO_HELPER "$TOP/btrfs" check "$loop3"
 
-run_check $SUDO_HELPER mount "$loop1" "$TEST_MNT"
-new_md5=$(run_check_stdout md5sum "$TEST_MNT/foobar" | cut -d ' ' -f 1)
+run_check $SUDO_HELPER mount "$loop3" "$TEST_MNT"
+new_md5=$(run_check_stdout stat "$TEST_MNT/foobar" | md5sum | cut -d ' ' -f 1)
 run_check $SUDO_HELPER umount "$TEST_MNT"
 
 cleanup_loopdevs
-- 
1.8.3.1


  parent reply	other threads:[~2019-09-04 13:30 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-28  2:26 [PATCH] btrfs_progs: mkfs: match devid order to the stripe index Anand Jain
2019-06-28  2:44 ` Qu Wenruo
2019-06-28  3:28   ` Anand Jain
2019-06-28  6:01     ` Qu Wenruo
2019-07-03 13:21 ` David Sterba
2019-08-27  2:02   ` Anand Jain
2019-09-02  8:01     ` Anand Jain
2019-09-02 16:22       ` David Sterba
2019-09-03 12:06         ` David Sterba
2019-09-04 11:10           ` Anand Jain
2019-09-12 17:54           ` David Sterba
2019-12-10 15:42             ` Filipe Manana
2019-12-11  1:45               ` Qu Wenruo
2019-12-11  8:58                 ` Filipe Manana
2019-09-03 10:46 ` Johannes Thumshirn
2019-09-04 12:54   ` [PATCH] btrfs: misc-tests-021 fix restore overlapped on disk's stale data Anand Jain
2019-09-04 13:29   ` Anand Jain [this message]
2019-09-04 14:05     ` [PATCH Fix-title-prefix] btrfs-progs: " Johannes Thumshirn
2019-09-04 14:06     ` Nikolay Borisov
2019-09-10  7:43     ` Anand Jain
2019-09-12 17:49     ` David Sterba
2019-09-10  7:37 ` [PATCH] btrfs_progs: mkfs: match devid order to the stripe index Anand Jain

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=20190904132947.1232-1-anand.jain@oracle.com \
    --to=anand.jain@oracle.com \
    --cc=dsterba@suse.cz \
    --cc=jthumshirn@suse.de \
    --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;
as well as URLs for NNTP newsgroup(s).