diff mbox series

[3/3] btrfs-progs: fsck-tests: add test image of out-of-order inline backref items

Message ID e260e8432e3ae5e09d012dce6bd6f96ff0569649.1697945679.git.wqu@suse.com (mailing list archive)
State New, archived
Headers show
Series btrfs-progs: follow-ups for issue #622 | expand

Commit Message

Qu Wenruo Oct. 22, 2023, 3:40 a.m. UTC
Issue #622 reported a case where ntfs2btrfs can generate out-of-order
inline backref items, which can lead to kernel transaction abort, but
not detected by btrfs-check.

This patch would add such image, whose extent tree looks like this for
the only data extent:

        item 0 key (13631488 EXTENT_ITEM 4096) itemoff 16172 itemsize 111
                refs 3 gen 7 flags DATA
                (178 0xdfb591fa80d95ea) extent data backref root FS_TREE objectid 257 offset 0 count 1
                (178 0xdfb591fbbf5f519) extent data backref root FS_TREE objectid 258 offset 0 count 1
                (178 0xdfb591f49f9f8e7) extent data backref root FS_TREE objectid 259 offset 0 count 1

While the original good base image has the following backrefs for the
same data extent:

        item 0 key (13631488 EXTENT_ITEM 4096) itemoff 16172 itemsize 111
                refs 3 gen 7 flags DATA
                (178 0xdfb591fbbf5f519) extent data backref root FS_TREE objectid 258 offset 0 count 1
                (178 0xdfb591fa80d95ea) extent data backref root FS_TREE objectid 257 offset 0 count 1
                (178 0xdfb591f49f9f8e7) extent data backref root FS_TREE objectid 259 offset 0 count 1

Notice the sequence (the 2nd number in the round brackets) should be
descending.
(Meanwhie type should be ascending, but it's way harder to create)

For now we don't have a way to fix it, but at least we should detect it.

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 .../btrfs_image.xz                            | Bin 0 -> 2264 bytes
 .../061-out-of-order-inline-backref/test.sh   |  19 ++++++++++++++++++
 2 files changed, 19 insertions(+)
 create mode 100644 tests/fsck-tests/061-out-of-order-inline-backref/btrfs_image.xz
 create mode 100755 tests/fsck-tests/061-out-of-order-inline-backref/test.sh

Comments

Anand Jain Oct. 24, 2023, 5:28 a.m. UTC | #1
>   .../btrfs_image.xz                            | Bin 0 -> 2264 bytes

check_all_images() won't find  btrfs_image.xz image.


         for image in $(find "$dir" \( -iname '*.img' -o \
                                 -iname '*.img.xz' -o    \
                                 -iname '*.raw' -o       \
                                 -iname '*.raw.xz' \) | sort)





What's your plan to test lomem mode?



Thanks, Anand
Qu Wenruo Oct. 24, 2023, 5:47 a.m. UTC | #2
On 2023/10/24 15:58, Anand Jain wrote:
> 
> 
> 
>>   .../btrfs_image.xz                            | Bin 0 -> 2264 bytes
> 
> check_all_images() won't find  btrfs_image.xz image.

My bad, the filename should be default.img.xz.

David, mind to change that?
> 
> 
>          for image in $(find "$dir" \( -iname '*.img' -o \
>                                  -iname '*.img.xz' -o    \
>                                  -iname '*.raw' -o       \
>                                  -iname '*.raw.xz' \) | sort)
> 
> 
> 
> 
> 
> What's your plan to test lomem mode?

The usual way, you can check tests/common.local to see how lowmem mode 
should be utilized.

Thanks,
Qu
> 
> 
> 
> Thanks, Anand
>
David Sterba Oct. 24, 2023, 11:15 a.m. UTC | #3
On Tue, Oct 24, 2023 at 04:17:14PM +1030, Qu Wenruo wrote:
> 
> 
> On 2023/10/24 15:58, Anand Jain wrote:
> > 
> > 
> > 
> >>   .../btrfs_image.xz                            | Bin 0 -> 2264 bytes
> > 
> > check_all_images() won't find  btrfs_image.xz image.
> 
> My bad, the filename should be default.img.xz.
> 
> David, mind to change that?

Renamed and pushed.

> > 
> > 
> >          for image in $(find "$dir" \( -iname '*.img' -o \
> >                                  -iname '*.img.xz' -o    \
> >                                  -iname '*.raw' -o       \
> >                                  -iname '*.raw.xz' \) | sort)
> > 
> > 
> > 
> > 
> > 
> > What's your plan to test lomem mode?
> 
> The usual way, you can check tests/common.local to see how lowmem mode 
> should be utilized.

There are more ways how to run the lowmem mode tests, e.g.
'make test-check-lowmem' that sets up the variables s needed.
diff mbox series

Patch

diff --git a/tests/fsck-tests/061-out-of-order-inline-backref/btrfs_image.xz b/tests/fsck-tests/061-out-of-order-inline-backref/btrfs_image.xz
new file mode 100644
index 0000000000000000000000000000000000000000..65c10617bc250edce2affb3ed91c359041119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IQ=86+^q=hR1pK63`0}1AIou(C
z`rKd%Ni&gRf}?4<kEoyq-&w&#uvkFA3)pZsUT*M4+0976^}^idE`M*60=ztyJfGxp
zi!KNajhR=VdsCBJ(yV9Ax5>l3KN4V>;<X#;8q=2S;}f8P_*2ko@DS%FPWG@sM%1Y>
zjSuCZQ6D*dxemFsucgi?s*wy)8bDxm*6M<LI9&ar>T*UJFsTsdE3NqtqQIImzP|*%
zteC9i`^XvP4esR#q53gW;ayfa6y<}enU@x&GUh8?=X}b^HMoe?qIJS00M@L}uJVEY
zbz)EAuqdyrr@)iuk{AAv8V_EL&sI^(`|CG?BNJ1=MG%H$i6By7UD5{P1d-zNE{QD}
z5q^aqWy7#PzZrqKE72thI~Owi#p5D?@@aXX3Ox?2SxnK(m}j*9vH=QEyb}$1H*?m6
zNOsp5*O_yteiZ7BIiMCn!5JJ6iL+TXB2v6!j>+$l@TzZBjHHh2#FklJCBOt45M7*=
z?Jf>Ub|O(c|BOkXh1nl6wvh`xkKm!?61jYG-oSS`^vH`zVJ2P6`i>MvfT9UYI@)gu
ztKT};o&$LJJd>HY8fJ>gPjh6Qinb(svJFeDagU1vGdafKT3QO`*8SoJba!C3rimp6
zX?o402q{VtY}oJTFvpxKT6&25@H6@j=QNW6l@9@J9WTqq1Ixzqoa}*=f!dO&p|gNF
z@%2>k+xs=J#i2iaEap!Q^Lk?y^4}Fn^E=aj9X}hp=v&Kt<jU>}JqflP9ExJn8Io)|
zE?#x?PWc6%<}NRL;5Qu=us?;N3NDAPaCsRr8+nVNoY@;2zl3N_MBn}4jg7I7Ind+)
m0002EWz9KhnPQ&+0kRQ*AOHYLD8n4F#Ao{g000001X)@%f>$&E

literal 0
HcmV?d00001

diff --git a/tests/fsck-tests/061-out-of-order-inline-backref/test.sh b/tests/fsck-tests/061-out-of-order-inline-backref/test.sh
new file mode 100755
index 000000000000..f80d58f416f0
--- /dev/null
+++ b/tests/fsck-tests/061-out-of-order-inline-backref/test.sh
@@ -0,0 +1,19 @@ 
+#!/bin/bash
+#
+# Verify that check can detect out-of-order inline backref items.
+#
+# There is a report that one ntfs2btrfs generated some out-of-order inline
+# backref items, while btrfs-check failed to detect it at all.
+#
+# Make sure btrfs check can at least detect such error.
+
+source "$TEST_TOP/common"
+
+check_prereq btrfs
+
+check_image() {
+	run_mustfail "out-of-order inline backref items not detected" \
+		"$TOP/btrfs" check "$1"
+}
+
+check_all_images