linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Cc: dsterba@suse.cz, nborisov@suse.com
Subject: [PATCH 2/2] btrfs-progs: mkfs-tests: Add test case to check if the first device extent is occupying reserved 0~1M range
Date: Wed, 10 Jan 2018 12:56:48 +0800	[thread overview]
Message-ID: <20180110045648.3239-2-wqu@suse.com> (raw)
In-Reply-To: <20180110045648.3239-1-wqu@suse.com>

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 .../mkfs-tests/010-reserved-1M-for-single/test.sh  | 37 ++++++++++++++++++++++
 1 file changed, 37 insertions(+)
 create mode 100755 tests/mkfs-tests/010-reserved-1M-for-single/test.sh

diff --git a/tests/mkfs-tests/010-reserved-1M-for-single/test.sh b/tests/mkfs-tests/010-reserved-1M-for-single/test.sh
new file mode 100755
index 000000000000..1a4936eaf72e
--- /dev/null
+++ b/tests/mkfs-tests/010-reserved-1M-for-single/test.sh
@@ -0,0 +1,37 @@
+#!/bin/bash
+# Test if "-m single" or "-M" can cause dev extent to use reserved 1M range
+#
+# Other profiles will cause mkfs.btrfs to allocate new meta/sys chunks
+# using btrfs_alloc_chunk() which won't use 0~1M range, so other profiles
+# are safe.
+
+source "$TOP/tests/common"
+
+check_prereq mkfs.btrfs
+check_prereq btrfs
+
+prepare_test_dev
+
+do_one_test ()
+{
+	run_check "$TOP/mkfs.btrfs" -f $@ "$TEST_DEV"
+
+	# Use dev-extent tree to find first device extent
+	first_dev_extent=$(run_check_stdout "$TOP/btrfs" inspect-internal \
+		dump-tree -t device "$TEST_DEV" | \
+		grep -oP '(?<=DEV_EXTENT )[[:digit:]]*' | head -n1)
+
+	if [ -z $first_dev_extent ]; then
+		_fail "Failed to get first device extent"
+	fi
+
+	echo "First dev extent starts at $first_dev_extent" >> "$RESULTS"
+	echo "Reserved range is [0, $(( 1024 * 1024)))" >> "$RESULTS"
+	# First device extent should not start below 1M
+	if [ $first_dev_extent -lt $(( 1024 * 1024 )) ]; then
+		_fail "First device extent occupies reserved 0~1M range"
+	fi
+}
+
+do_one_test "-M"
+do_one_test "-m single"
-- 
2.15.1


  reply	other threads:[~2018-01-10  4:57 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-10  4:56 [PATCH 1/2] btrfs-progs: mkfs: Prevent temporary system chunk to use space in reserved 1M range Qu Wenruo
2018-01-10  4:56 ` Qu Wenruo [this message]
2018-01-10  8:57   ` [PATCH 2/2] btrfs-progs: mkfs-tests: Add test case to check if the first device extent is occupying reserved 0~1M range Nikolay Borisov
2018-01-10  8:37 ` [PATCH 1/2] btrfs-progs: mkfs: Prevent temporary system chunk to use space in reserved 1M range Nikolay Borisov
2018-01-10 14:14 ` Nikolay Borisov
2018-01-10 14:27   ` Qu Wenruo
2018-01-23 16:42 ` David Sterba
2018-01-24  0:42   ` Qu Wenruo

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=20180110045648.3239-2-wqu@suse.com \
    --to=wqu@suse.com \
    --cc=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).