From: David Sterba <dsterba@suse.cz>
To: Nikolay Borisov <nborisov@suse.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 2/2] btrfs-progs: tests: Test backup root retention logic
Date: Fri, 1 Nov 2019 12:48:16 +0100 [thread overview]
Message-ID: <20191101114815.GO3001@twin.jikos.cz> (raw)
In-Reply-To: <20191015154249.21615-3-nborisov@suse.com>
On Tue, Oct 15, 2019 at 06:42:49PM +0300, Nikolay Borisov wrote:
> This tests ensures that the kernel correctly persists backup roots in
> case the filesystem has been mounted from a backup root.
The test does not work very well under a non-root user.
> Signed-off-by: Nikolay Borisov <nborisov@suse.com>
> ---
> .../misc-tests/038-backup-root-corruption/test.sh | 50 ++++++++++++++++++++++
> 1 file changed, 50 insertions(+)
> create mode 100755 tests/misc-tests/038-backup-root-corruption/test.sh
>
> diff --git a/tests/misc-tests/038-backup-root-corruption/test.sh b/tests/misc-tests/038-backup-root-corruption/test.sh
> new file mode 100755
> index 000000000000..2fb117b3a928
> --- /dev/null
> +++ b/tests/misc-tests/038-backup-root-corruption/test.sh
> @@ -0,0 +1,50 @@
> +#!/bin/bash
> +# Test that a corrupted filesystem will correctly handle writing of
> +# backup root
> +
> +source "$TEST_TOP/common"
> +
> +check_prereq mkfs.btrfs
> +check_prereq btrfs
> +check_prereq btrfs-corrupt-block
> +
setup_root_helper
> +setup_loopdevs 1
> +prepare_loopdevs
> +dev=${loopdevs[1]}
You can use TEST_DEV and then all the common mkfs/mount/umount helpers
will work
> +run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f "$dev"
> +
> +# Create a file and unmount to commit some backup roots
> +run_check $SUDO_HELPER mount "$dev" "$TEST_MNT"
> +run_check touch "$TEST_MNT/file" && sync
'touch' is on the mounted fs, so it needs $SUDO_HELPER too
> +run_check $SUDO_HELPER umount "$TEST_MNT"
> +
> +# Ensure currently active backup slot is the expected one (slot 3)
> +backup2_root_ptr=$($SUDO_HELPER "$TOP/btrfs" inspect-internal dump-super -f "$dev" \
> + | grep -A1 "backup 2" | grep backup_tree_root | awk '{print $2}')
> +
> +main_root_ptr=$($SUDO_HELPER "$TOP/btrfs" inspect-internal dump-super -f "$dev" \
> + | grep root | head -n1 | awk '{print $2}')
> +
> +[[ "$backup2_root_ptr" -eq "$main_root_ptr" ]] || _fail "Backup slot 2 is not in use"
> +
> +run_check "$TOP/btrfs-corrupt-block" -m $main_root_ptr -f generation "$dev"
> +
> +## should fail because the root is corrupted
double ##
> +run_mustfail "Unexpected successful mount" $SUDO_HELPER mount "$dev" "$TEST_MNT"
> +
> +# Cycle mount with the backup to force rewrite of slot 3
> +run_check $SUDO_HELPER mount -ousebackuproot "$dev" "$TEST_MNT"
run_check_mount_test_dev -o usebackuproot
> +run_check $SUDO_HELPER umount "$TEST_MNT"
run_check_umount_test_dev
> +
> +
two empty lines
> +# Since we've used backup 1 as the usable root, then backup 2 should have been
> +# overwritten
trailing whitespace (here and in several above as well)
> +main_root_ptr=$($SUDO_HELPER "$TOP/btrfs" inspect-internal dump-super -f "$dev" \
> + | grep root | head -n1 | awk '{print $2}')
> +backup2_new_root_ptr=$($SUDO_HELPER "$TOP/btrfs" inspect-internal dump-super -f "$dev" \
> + | grep -A1 "backup 2" | grep backup_tree_root | awk '{print $2}')
> +
> +[[ "$backup2_root_ptr" -ne "$backup2_new_root_ptr" ]] || _fail "Backup 2 not overwritten"
> +
> +cleanup_loopdevs
> --
> 2.7.4
next prev parent reply other threads:[~2019-11-01 11:48 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-15 15:42 [PATCH 0/2] Support patches for btrfs backup root rework Nikolay Borisov
2019-10-15 15:42 ` [PATCH 1/2] btrfs-progs: corrupt-block: Refactor tree block corruption code Nikolay Borisov
2019-10-15 15:42 ` [PATCH 2/2] btrfs-progs: tests: Test backup root retention logic Nikolay Borisov
2019-11-01 11:48 ` David Sterba [this message]
2019-11-01 12:21 ` David Sterba
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=20191101114815.GO3001@twin.jikos.cz \
--to=dsterba@suse.cz \
--cc=linux-btrfs@vger.kernel.org \
--cc=nborisov@suse.com \
/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).