mirror of
https://github.com/kdave/btrfs-progs
synced 2025-04-11 03:31:17 +00:00
[BUG] When using `btrfs check --init-extent-tree`, there is a pretty high chance that the result fs can't pass tree-checker: BTRFS critical (device dm-3): corrupt leaf: block=5390336 slot=149 extent bytenr=20115456 len=4096 invalid generation, have 16384 expect (0, 360] BTRFS error (device dm-3): block=5390336 read time tree block corruption detected BTRFS error (device dm-3): failed to read block groups: -5 BTRFS error (device dm-3): open_ctree failed [CAUSE] The result fs has a pretty screwed up EXTENT_ITEMs for data extents: item 148 key (20111360 EXTENT_ITEM 4096) itemoff 8777 itemsize 53 refs 1 gen 0 flags DATA extent data backref root FS_TREE objectid 841 offset 0 count 1 item 149 key (20115456 EXTENT_ITEM 4096) itemoff 8724 itemsize 53 refs 1 gen 16384 flags DATA extent data backref root FS_TREE objectid 906 offset 0 count 1 Kernel tree-checker will accept 0 generation, but that 16384 generation is definitely going to trigger the alarm. Looking into the code, it's add_extent_rec_nolookup() allocating a new extent_rec, but not copying all members from parameter @tmpl, resulting generation not properly initialized. [FIX] Just copy tmpl->generation in add_extent_rec_nolookup(). And since all call sites have set all members of @tmpl to 0 before add_extent_rec_nolookup(), we shouldn't get garbage values. For the 0 generation problem, it will be solved in another patch. Issue: #225 (Not the initial report, but extent tree rebuild result) Reviewed-by: Su Yue <Damenly_Su@gmx.com> Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com> |
||
---|---|---|
.. | ||
common.h | ||
main.c | ||
mode-common.c | ||
mode-common.h | ||
mode-lowmem.c | ||
mode-lowmem.h | ||
mode-original.h | ||
qgroup-verify.c | ||
qgroup-verify.h |