[5/5] btrfs-progs: fsck-tests: Make sure btrfs check can detect bad extent item generation
diff mbox series

Message ID 20191231071220.32935-6-wqu@suse.com
State New
Headers show
Series
  • btrfs-progs: Bad extent item generation related bug fixes
Related show

Commit Message

Qu Wenruo Dec. 31, 2019, 7:12 a.m. UTC
The new image has a bad data extent item generation:

        item 0 key (13631488 EXTENT_ITEM 4096) itemoff 16230 itemsize 53
                refs 1 gen 16384 flags DATA
                extent data backref root FS_TREE objectid 257 offset 0 count 1

Just like what older `btrfs check --init-extent-tree` could cause.

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 .../bad_extent_item_gen.img.xz                | Bin 0 -> 1916 bytes
 .../test.sh                                   |  19 ++++++++++++++++++
 2 files changed, 19 insertions(+)
 create mode 100644 tests/fsck-tests/044-invalid-extent-item-generation/bad_extent_item_gen.img.xz
 create mode 100755 tests/fsck-tests/044-invalid-extent-item-generation/test.sh

Patch
diff mbox series

diff --git a/tests/fsck-tests/044-invalid-extent-item-generation/bad_extent_item_gen.img.xz b/tests/fsck-tests/044-invalid-extent-item-generation/bad_extent_item_gen.img.xz
new file mode 100644
index 0000000000000000000000000000000000000000..c3e30313538558384352d4987acef69f56acea2d
GIT binary patch
literal 1916
zcmV-?2ZQ+iH+ooF000E$*0e?f03iV!0000G&sfah3;zc?T>wRyj;C3^v%$$4d1r37
zhA1?_LT>Wbx+L2{5ct*#2hYYGZ$^%K*7}6#@?zh(OKyt!ovg(ZXD3s(w#SpNSsRep
zn;&Hxy|d8!Hi<RRaJ(=+T!Nf*Grt0$9YKM_uNCH&f@?oOPNUPM#dHBgutu$*YH7Sd
z;8vxqgB?;P8%c$1w4ktrsMRs{rq$7d%o`v|q>*o#PdRXN)B+ivWj$v1%hPZx8E=T<
zIFi++(r$u*0A%YuW7aB1tv#h~la(SW&<75ZbX{2HpaX7<+lhn{3MIgh{Z)k&XH7!-
z$i?+3e{kf1rujr8NoiytrfWvbj+^erx%LwZ6`4?RpV8Uj2%8PN6}TKB72stHk=erF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ytl$(QZev#Ao{g000001X)_c
C2dftV

literal 0
HcmV?d00001

diff --git a/tests/fsck-tests/044-invalid-extent-item-generation/test.sh b/tests/fsck-tests/044-invalid-extent-item-generation/test.sh
new file mode 100755
index 00000000..2b88a3c7
--- /dev/null
+++ b/tests/fsck-tests/044-invalid-extent-item-generation/test.sh
@@ -0,0 +1,19 @@ 
+#!/bin/bash
+#
+# Due to a bug in --init-extent-tree option, we may create bad generation
+# number for data extents.
+#
+# This test case will ensure btrfs check can at least detect such problem,
+# just like kernel tree-checker.
+
+source "$TEST_TOP/common"
+
+check_prereq btrfs
+
+check_image() {
+	run_mustfail \
+		"btrfs check failed to detect invalid extent item generation" \
+		"$TOP/btrfs" check "$1"
+}
+
+check_all_images