diff mbox

[v2,3/3] btrfs-progs: tests: Introduce misc-tests/008-leaf-across-stripes

Message ID 2b9521b025a849e20411d5390d176bd3664291bf.1442992715.git.zhaolei@cn.fujitsu.com (mailing list archive)
State Accepted
Headers show

Commit Message

Zhaolei Sept. 23, 2015, 7:19 a.m. UTC
To check is btrfs-convert create bad filesystem with
leaf across stripes.

It is happened in progs version <=v4.1.2, and fixed by patch titled:
btrfs: convert: Avoid allocating metadata extent crossing stripe boundary
which was merged in v4.2.

Notice thar this testcase can not report error in old version of
btrfs-progs, because "btrfs check" can't check this type of error
in those version, but we have another testcase in fsck-tests, to
check is "btrfs check" support this check.

So, use above 2 testcase together can check out leaf-across-stripes
bug in all version.

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
---
 tests/misc-tests/008-leaf-across-stripes/test.sh | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
 create mode 100755 tests/misc-tests/008-leaf-across-stripes/test.sh
diff mbox

Patch

diff --git a/tests/misc-tests/008-leaf-across-stripes/test.sh b/tests/misc-tests/008-leaf-across-stripes/test.sh
new file mode 100755
index 0000000..cd426a9
--- /dev/null
+++ b/tests/misc-tests/008-leaf-across-stripes/test.sh
@@ -0,0 +1,23 @@ 
+#!/bin/bash
+# test btrfs-convert create filesystem without leaf across stripes
+
+source $TOP/tests/common
+
+check_prereq btrfs-convert
+check_prereq btrfs
+
+# In my test, it happened in 514M~560M, 737M~769M, 929M~917M,
+# and HAVE_ERROR=((size + 1) / 2) % 2 if size >= 970
+#
+SIZE_FROM=514
+SIZE_END=560
+A_PRIME_NUM=17
+for ((size = SIZE_FROM; size <= SIZE_END; size += A_PRIME_NUM)); do
+	run_check truncate -s "$size"M "$IMAGE"
+	run_check mkfs.ext4 -F "$IMAGE"
+	run_check $TOP/btrfs-convert "$IMAGE"
+	$TOP/btrfs check "$IMAGE" 2>&1 | grep "crossing stripe boundary" &&
+		_fail "leaf across stripes in btrfs-convert"
+done
+
+exit 0