Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

btrfs-convert: source-ext2.c:845: ext2_copy_inodes: BUG_ON ret triggered, value -5 #187

Closed
klemens opened this issue Jun 24, 2019 · 7 comments
Labels

Comments

@klemens
Copy link

klemens commented Jun 24, 2019

Possibly continuing from #123, I am hitting the same issue trying to convert a 4 TiB ext4 filesystem with version 5.1.1 on linux 4.19.53. The fs has around 800 GiB free space and was defragmented using e4defrag.

@adam900710: It seems the output already contains the additional debug output you mentioned in #123.

# btrfs-convert -p -l name1 /dev/sdf1
create btrfs filesystem:
        blocksize: 4096
        nodesize:  16384
        features:  extref, skinny-metadata (default)
creating ext2 image file
creating btrfs metadata
Failed to find [4003911303168, 168, 16384]
btrfs unable to find ref byte nr 4003911319552 parent 0 root 2  owner 0 offset 0
*snip, details see below*
convert/source-ext2.c:845: ext2_copy_inodes: BUG_ON `ret` triggered, value -5
btrfs-convert(+0x113c7)[0x55e2bbb933c7]
btrfs-convert(+0x123d1)[0x55e2bbb943d1]
btrfs-convert(main+0xfb1)[0x55e2bbb8efd1]
/usr/lib/libc.so.6(__libc_start_main+0xf3)[0x7f6994b8eee3]
btrfs-convert(_start+0x2e)[0x55e2bbb9028e]
create btrfs filesystem:
        blocksize: 4096
        nodesize:  16384
        features:  extref, skinny-metadata (default)
creating ext2 image file
creating btrfs metadata
Failed to find [4003911303168, 168, 16384]
btrfs unable to find ref byte nr 4003911319552 parent 0 root 2  owner 0 offset 0
path->slots[0]: 126 path->nodes[0]:
leaf 4003913662464 items 137 free space 8445 generation 5 owner EXTENT_TREE
leaf 4003913662464 flags 0x0() backref revision 1
fs uuid f5e23782-3ed9-45cb-bc8e-b8f4ba6c8e36
chunk uuid cf8562a1-a9a2-4f5e-a8ca-0ed7e88a218e
        item 0 key (4003907108864 METADATA_ITEM 0) itemoff 16250 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 1 key (4003907125248 METADATA_ITEM 0) itemoff 16217 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 2 key (4003907141632 METADATA_ITEM 0) itemoff 16184 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 3 key (4003907158016 METADATA_ITEM 0) itemoff 16151 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 4 key (4003907207168 METADATA_ITEM 0) itemoff 16118 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 5 key (4003907223552 METADATA_ITEM 0) itemoff 16085 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 6 key (4003907239936 METADATA_ITEM 0) itemoff 16052 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 7 key (4003907256320 METADATA_ITEM 0) itemoff 16019 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 8 key (4003907272704 METADATA_ITEM 0) itemoff 15986 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 9 key (4003907289088 METADATA_ITEM 0) itemoff 15953 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 10 key (4003907305472 METADATA_ITEM 0) itemoff 15920 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 11 key (4003907371008 METADATA_ITEM 0) itemoff 15887 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 12 key (4003907387392 METADATA_ITEM 0) itemoff 15854 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 13 key (4003907420160 METADATA_ITEM 0) itemoff 15821 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 14 key (4003907436544 METADATA_ITEM 0) itemoff 15788 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 15 key (4003907452928 METADATA_ITEM 0) itemoff 15755 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 16 key (4003907502080 METADATA_ITEM 0) itemoff 15722 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 17 key (4003907534848 METADATA_ITEM 0) itemoff 15689 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 18 key (4003907551232 METADATA_ITEM 0) itemoff 15656 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 19 key (4003907584000 METADATA_ITEM 0) itemoff 15623 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 20 key (4003907633152 METADATA_ITEM 0) itemoff 15590 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 21 key (4003907649536 METADATA_ITEM 0) itemoff 15557 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 22 key (4003907665920 METADATA_ITEM 0) itemoff 15524 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 23 key (4003907682304 METADATA_ITEM 0) itemoff 15491 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 24 key (4003907698688 METADATA_ITEM 0) itemoff 15458 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 25 key (4003907715072 METADATA_ITEM 0) itemoff 15425 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 26 key (4003907764224 METADATA_ITEM 0) itemoff 15392 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 27 key (4003907764224 BLOCK_GROUP_ITEM 8388608) itemoff 15368 itemsize 24
                block group used 3555328 chunk_objectid 256 flags METADATA
        item 28 key (4003907796992 METADATA_ITEM 0) itemoff 15335 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 29 key (4003907813376 METADATA_ITEM 0) itemoff 15302 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 30 key (4003907829760 METADATA_ITEM 0) itemoff 15269 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 31 key (4003907878912 METADATA_ITEM 0) itemoff 15236 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 32 key (4003907895296 METADATA_ITEM 0) itemoff 15203 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 33 key (4003907911680 METADATA_ITEM 0) itemoff 15170 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 34 key (4003907928064 METADATA_ITEM 0) itemoff 15137 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 35 key (4003907944448 METADATA_ITEM 0) itemoff 15104 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 36 key (4003907993600 METADATA_ITEM 0) itemoff 15071 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 37 key (4003908009984 METADATA_ITEM 0) itemoff 15038 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 38 key (4003908042752 METADATA_ITEM 0) itemoff 15005 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 39 key (4003908059136 METADATA_ITEM 0) itemoff 14972 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 40 key (4003908124672 METADATA_ITEM 0) itemoff 14939 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 41 key (4003908141056 METADATA_ITEM 0) itemoff 14906 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 42 key (4003908173824 METADATA_ITEM 0) itemoff 14873 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 43 key (4003908222976 METADATA_ITEM 0) itemoff 14840 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 44 key (4003908239360 METADATA_ITEM 0) itemoff 14807 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 45 key (4003908272128 METADATA_ITEM 0) itemoff 14774 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 46 key (4003908288512 METADATA_ITEM 0) itemoff 14741 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 47 key (4003908337664 METADATA_ITEM 0) itemoff 14708 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 48 key (4003908354048 METADATA_ITEM 0) itemoff 14675 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 49 key (4003908370432 METADATA_ITEM 0) itemoff 14642 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 50 key (4003908386816 METADATA_ITEM 0) itemoff 14609 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 51 key (4003908403200 METADATA_ITEM 0) itemoff 14576 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 52 key (4003908452352 METADATA_ITEM 0) itemoff 14543 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 53 key (4003908485120 METADATA_ITEM 0) itemoff 14510 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 54 key (4003908501504 METADATA_ITEM 0) itemoff 14477 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 55 key (4003908517888 METADATA_ITEM 0) itemoff 14444 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 56 key (4003908567040 METADATA_ITEM 0) itemoff 14411 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 57 key (4003908583424 METADATA_ITEM 0) itemoff 14378 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 58 key (4003908599808 METADATA_ITEM 0) itemoff 14345 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 59 key (4003908616192 METADATA_ITEM 0) itemoff 14312 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 60 key (4003908632576 METADATA_ITEM 0) itemoff 14279 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 61 key (4003908681728 METADATA_ITEM 0) itemoff 14246 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 62 key (4003908698112 METADATA_ITEM 0) itemoff 14213 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 63 key (4003908730880 METADATA_ITEM 0) itemoff 14180 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 64 key (4003908747264 METADATA_ITEM 0) itemoff 14147 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 65 key (4003908845568 METADATA_ITEM 0) itemoff 14114 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 66 key (4003908894720 METADATA_ITEM 0) itemoff 14081 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 67 key (4003908911104 METADATA_ITEM 0) itemoff 14048 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 68 key (4003908943872 METADATA_ITEM 0) itemoff 14015 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 69 key (4003908993024 METADATA_ITEM 0) itemoff 13982 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 70 key (4003909009408 METADATA_ITEM 0) itemoff 13949 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 71 key (4003909042176 METADATA_ITEM 0) itemoff 13916 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 72 key (4003909091328 METADATA_ITEM 0) itemoff 13883 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 73 key (4003909140480 METADATA_ITEM 0) itemoff 13850 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 74 key (4003909189632 METADATA_ITEM 0) itemoff 13817 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 75 key (4003909206016 METADATA_ITEM 0) itemoff 13784 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 76 key (4003909238784 METADATA_ITEM 0) itemoff 13751 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 77 key (4003909287936 METADATA_ITEM 0) itemoff 13718 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 78 key (4003909304320 METADATA_ITEM 0) itemoff 13685 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 79 key (4003909337088 METADATA_ITEM 0) itemoff 13652 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 80 key (4003909402624 METADATA_ITEM 0) itemoff 13619 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 81 key (4003909435392 METADATA_ITEM 0) itemoff 13586 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 82 key (4003909484544 METADATA_ITEM 0) itemoff 13553 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 83 key (4003909500928 METADATA_ITEM 0) itemoff 13520 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 84 key (4003909517312 METADATA_ITEM 0) itemoff 13487 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 85 key (4003909550080 METADATA_ITEM 0) itemoff 13454 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 86 key (4003909599232 METADATA_ITEM 0) itemoff 13421 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 87 key (4003909615616 METADATA_ITEM 0) itemoff 13388 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 88 key (4003909648384 METADATA_ITEM 0) itemoff 13355 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 89 key (4003909697536 METADATA_ITEM 0) itemoff 13322 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 90 key (4003909746688 METADATA_ITEM 0) itemoff 13289 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 91 key (4003909795840 METADATA_ITEM 0) itemoff 13256 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 92 key (4003909812224 METADATA_ITEM 0) itemoff 13223 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 93 key (4003909844992 METADATA_ITEM 0) itemoff 13190 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 94 key (4003909894144 METADATA_ITEM 0) itemoff 13157 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 95 key (4003909910528 METADATA_ITEM 0) itemoff 13124 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 96 key (4003909926912 METADATA_ITEM 0) itemoff 13091 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 97 key (4003909959680 METADATA_ITEM 0) itemoff 13058 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 98 key (4003909976064 METADATA_ITEM 0) itemoff 13025 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 99 key (4003910008832 METADATA_ITEM 0) itemoff 12992 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 100 key (4003910025216 METADATA_ITEM 0) itemoff 12959 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 101 key (4003910057984 METADATA_ITEM 0) itemoff 12926 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 102 key (4003910074368 METADATA_ITEM 0) itemoff 12893 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 103 key (4003910107136 METADATA_ITEM 0) itemoff 12860 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 104 key (4003910123520 METADATA_ITEM 0) itemoff 12827 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 105 key (4003910156288 METADATA_ITEM 0) itemoff 12794 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 106 key (4003910172672 METADATA_ITEM 0) itemoff 12761 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 107 key (4003910205440 METADATA_ITEM 0) itemoff 12728 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 108 key (4003910221824 METADATA_ITEM 0) itemoff 12695 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 109 key (4003910254592 METADATA_ITEM 0) itemoff 12662 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 110 key (4003910270976 METADATA_ITEM 0) itemoff 12629 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 111 key (4003910303744 METADATA_ITEM 0) itemoff 12596 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 112 key (4003910320128 METADATA_ITEM 0) itemoff 12563 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 113 key (4003910352896 METADATA_ITEM 0) itemoff 12530 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 114 key (4003910385664 METADATA_ITEM 0) itemoff 12497 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 115 key (4003910418432 METADATA_ITEM 0) itemoff 12464 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 116 key (4003910451200 METADATA_ITEM 0) itemoff 12431 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 117 key (4003911024640 METADATA_ITEM 0) itemoff 12398 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root ROOT_TREE
        item 118 key (4003911057408 METADATA_ITEM 0) itemoff 12365 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 119 key (4003911106560 METADATA_ITEM 0) itemoff 12332 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 120 key (4003911122944 METADATA_ITEM 0) itemoff 12299 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 121 key (4003911139328 METADATA_ITEM 0) itemoff 12266 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 122 key (4003911204864 METADATA_ITEM 0) itemoff 12233 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 123 key (4003911254016 METADATA_ITEM 0) itemoff 12200 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 124 key (4003911286784 METADATA_ITEM 0) itemoff 12167 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 125 key (4003911303168 METADATA_ITEM 0) itemoff 12134 itemsize 33
                refs 1 gen 4 flags TREE_BLOCK
                tree block skinny level 0
                tree block backref root EXTENT_TREE
        item 126 key (4003916152832 BLOCK_GROUP_ITEM 8388608) itemoff 12110 itemsize 24
                block group used 0 chunk_objectid 256 flags METADATA
        item 127 key (4003924541440 BLOCK_GROUP_ITEM 8388608) itemoff 12086 itemsize 24
                block group used 0 chunk_objectid 256 flags METADATA
        item 128 key (4003932930048 BLOCK_GROUP_ITEM 8388608) itemoff 12062 itemsize 24
                block group used 0 chunk_objectid 256 flags METADATA
        item 129 key (4003941318656 BLOCK_GROUP_ITEM 8388608) itemoff 12038 itemsize 24
                block group used 0 chunk_objectid 256 flags METADATA
        item 130 key (4003949707264 BLOCK_GROUP_ITEM 8388608) itemoff 12014 itemsize 24
                block group used 0 chunk_objectid 256 flags METADATA
        item 131 key (4003958095872 BLOCK_GROUP_ITEM 8388608) itemoff 11990 itemsize 24
                block group used 0 chunk_objectid 256 flags METADATA
        item 132 key (4003966484480 BLOCK_GROUP_ITEM 8388608) itemoff 11966 itemsize 24
                block group used 0 chunk_objectid 256 flags METADATA
        item 133 key (4003974873088 BLOCK_GROUP_ITEM 8388608) itemoff 11942 itemsize 24
                block group used 0 chunk_objectid 256 flags METADATA
        item 134 key (4003983261696 BLOCK_GROUP_ITEM 8388608) itemoff 11918 itemsize 24
                block group used 0 chunk_objectid 256 flags METADATA
        item 135 key (4003991650304 BLOCK_GROUP_ITEM 8388608) itemoff 11894 itemsize 24
                block group used 0 chunk_objectid 256 flags METADATA
        item 136 key (4004000038912 BLOCK_GROUP_ITEM 8388608) itemoff 11870 itemsize 24
                block group used 0 chunk_objectid 256 flags METADATA
convert/source-ext2.c:845: ext2_copy_inodes: BUG_ON `ret` triggered, value -5
btrfs-convert(+0x113c7)[0x55e2bbb933c7]
btrfs-convert(+0x123d1)[0x55e2bbb943d1]
btrfs-convert(main+0xfb1)[0x55e2bbb8efd1]
/usr/lib/libc.so.6(__libc_start_main+0xf3)[0x7f6994b8eee3]
btrfs-convert(_start+0x2e)[0x55e2bbb9028e]

PS: Sorry for accidentally opening #186, I hit enter while entering the title…

@adam900710
Copy link
Collaborator

Thank you for the report and detailed debug output.

It shows that we have the correct METADATA_ITEM key, but delayed tree still failed to locate it.
Has some clue for it, will update when has some extra progress.

@adam900710
Copy link
Collaborator

Please try this debug branch:
https://github.com/adam900710/btrfs-progs/tree/debug

Although I'm pretty sure it's lookup_inline_extent_backref() failed to locate valid METADATA_ITEM.
It's still uncertain why this could happen.

That debug branch would output needed debug info.
As usual, the output would be pretty long.

Thanks.

@klemens
Copy link
Author

klemens commented Jul 7, 2019

Thanks for the reply!

Here is the log from the same command as above using your debug branch (dfa4977), this time also including the progress output (as I didn't have to copy it from my terminal buffer 😉):

btrfs-convert-dfa4977b40-20190706T133750.log

(Attached as a file, because it contains some invalid utf-8 in the leaf flags debug output.

@adam900710
Copy link
Collaborator

adam900710 commented Jul 8, 2019

Thanks for your log!

Unfortunately (or fortunately) I could finally reproduce the bug itself, by running fsck-tests/013 on a 64K page size system.
It turns out that, we need several gdb breakpoints/runs to pin it down (thus pretty hard and time consuming to debug without stable reproducer)

And since it's reproduced reliably, it's quite easy to debug, and here comes the fix:
https://github.com/adam900710/btrfs-progs/tree/delayed_ref_fix

It's based on devel branch, which includes other delayed ref fixes.
Please give it a try. (I believe the fix is correct and it works for my reproducer, just to make sure)

Thanks.

@ernsteiswuerfel
Copy link

ernsteiswuerfel commented Jul 9, 2019

I had the same problem on my PowerMac G4, trying to convert 48 GiB ext4 to btrfs on my SSD. I reported the bug on bugzilla.

Luckily I found this report here later! I can confirm the fix (adam900710's delayed_ref_fix tree) works for me. Thanks @adam900710 !

@klemens
Copy link
Author

klemens commented Jul 9, 2019

I can also confirm that the conversion was successful. (I was using only aaafe6f following the discussion on the mailing list) I guess you don't need anything else and I can start using the converted fs?

Thank you for your quick fix!

kdave pushed a commit that referenced this issue Jul 22, 2019
…elayed refs lost

[BUG]
Btrfs-progs sometimes fails to find certain extent backref when
committing transaction.
The most reliable way to reproduce it is fsck-test/013 on 64K page sized
system:

  [...]
  adding new data backref on 315859712 root 287 owner 292 offset 0 found 1
  btrfs unable to find ref byte nr 31850496 parent 0 root 2  owner 0 offset 0
  Failed to find [30867456, 168, 65536]

Also there are some github bug reports related to this problem.

[CAUSE]
Commit 909357e ("btrfs-progs: Wire up delayed refs") introduced
delayed refs in btrfs-progs.

However in that commit, delayed refs are not run at correct timing.
That commit calls btrfs_run_delayed_refs() before
btrfs_write_dirty_block_groups(), which needs to update
BLOCK_GROUP_ITEMs in extent tree, thus could cause new delayed refs.

This means each time we commit a transaction, we may screw up the extent
tree by dropping some pending delayed refs, like:

Transaction 711:
btrfs_commit_transaction()
|- btrfs_run_delayed_refs()
|  Now all delayed refs are written to extent tree
|
|- btrfs_write_dirty_block_groups()
|  Needs to update extent tree root
|  ADD_DELAYED_REF to 315859712.
|  Delayed refs are attached to current trans handle.
|
|- __commit_transaction()
|- write_ctree_super()
|- btrfs_finish_extent_commit()
|- kfree(trans)
   Now delayed ref for 315859712 are lost

Transaction 712:
Tree block 315859712 get dropped
btrfs_commit_transaction()
|- btrfs_run_delayed_refs()
   |- run_one_delayed_ref()
      |- __free_extent()
         As previous ADD_DELAYED_REF to 315859712 is lost, extent tree
         doesn't have any backref for 315859712, causing the bug

In fact, commit c31edf6 ("btrfs-progs: Fix false ENOSPC alert by
tracking used space correctly") detects the tree block leakage, but in
the reproducer we have too much noise, thus nobody notices the leakage
warning.

[FIX]
We can't just move btrfs_run_delayed_refs() after
btrfs_write_dirty_block_groups(), as during btrfs_run_delayed_refs(), we
can re-dirty block groups.
Thus we need to exhaust both delayed refs and dirty blocks.

This patch will call btrfs_write_dirty_block_groups() and
btrfs_run_delayed_refs() in a loop until both delayed refs and dirty
blocks are exhausted. Much like what we do in commit_cowonly_roots() in
kernel.

Also, to prevent such problem from happening again (and not to debug
such problem again), add extra check on delayed refs before freeing the
transaction handle.

Reported-by: Klemens Schölhorn <klemens@schoelhorn.eu>
Issue: #187
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
kdave pushed a commit that referenced this issue Jul 26, 2019
…elayed refs lost

[BUG]
Btrfs-progs sometimes fails to find certain extent backref when
committing transaction.
The most reliable way to reproduce it is fsck-test/013 on 64K page sized
system:

  [...]
  adding new data backref on 315859712 root 287 owner 292 offset 0 found 1
  btrfs unable to find ref byte nr 31850496 parent 0 root 2  owner 0 offset 0
  Failed to find [30867456, 168, 65536]

Also there are some github bug reports related to this problem.

[CAUSE]
Commit 909357e ("btrfs-progs: Wire up delayed refs") introduced
delayed refs in btrfs-progs.

However in that commit, delayed refs are not run at correct timing.
That commit calls btrfs_run_delayed_refs() before
btrfs_write_dirty_block_groups(), which needs to update
BLOCK_GROUP_ITEMs in extent tree, thus could cause new delayed refs.

This means each time we commit a transaction, we may screw up the extent
tree by dropping some pending delayed refs, like:

Transaction 711:
btrfs_commit_transaction()
|- btrfs_run_delayed_refs()
|  Now all delayed refs are written to extent tree
|
|- btrfs_write_dirty_block_groups()
|  Needs to update extent tree root
|  ADD_DELAYED_REF to 315859712.
|  Delayed refs are attached to current trans handle.
|
|- __commit_transaction()
|- write_ctree_super()
|- btrfs_finish_extent_commit()
|- kfree(trans)
   Now delayed ref for 315859712 are lost

Transaction 712:
Tree block 315859712 get dropped
btrfs_commit_transaction()
|- btrfs_run_delayed_refs()
   |- run_one_delayed_ref()
      |- __free_extent()
         As previous ADD_DELAYED_REF to 315859712 is lost, extent tree
         doesn't have any backref for 315859712, causing the bug

In fact, commit c31edf6 ("btrfs-progs: Fix false ENOSPC alert by
tracking used space correctly") detects the tree block leakage, but in
the reproducer we have too much noise, thus nobody notices the leakage
warning.

[FIX]
We can't just move btrfs_run_delayed_refs() after
btrfs_write_dirty_block_groups(), as during btrfs_run_delayed_refs(), we
can re-dirty block groups.
Thus we need to exhaust both delayed refs and dirty blocks.

This patch will call btrfs_write_dirty_block_groups() and
btrfs_run_delayed_refs() in a loop until both delayed refs and dirty
blocks are exhausted. Much like what we do in commit_cowonly_roots() in
kernel.

Also, to prevent such problem from happening again (and not to debug
such problem again), add extra check on delayed refs before freeing the
transaction handle.

Reported-by: Klemens Schölhorn <klemens@schoelhorn.eu>
Issue: #187
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
@kdave kdave added the bug label Aug 20, 2019
@ernsteiswuerfel
Copy link

I guess this can be closed?

@klemens klemens closed this as completed Dec 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants