Created attachment 129491 [details] dmesg and strace btrfs check logs Hello! My file system was corrupted after the power cycle."Btrfs check" utility crashes during recovery. > uname -a Linux sysresccd 3.13.5-alt410-amd64 #2 SMP Mon Mar 10 21:31:36 UTC 2014 x86_64 AMD A8-3850 APU with Radeon(tm) HD Graphics AuthenticAMD GNU/Linux > btrfs version Btrfs v3.12 > mount -t btrfs /dev/sda1 /mnt/custom [ 9426.596084] btrfs: device fsid 77de157d-afb1-4774-b944-6cd086b42a7c devid 1 transid 41709 /dev/sda1 [ 9426.597675] btrfs: disk space caching is enabled [ 9426.624554] Btrfs detected SSD devices, enabling SSD mode [ 9426.624733] btrfs bad tree block start 18446744073709551615 54231040 [ 9426.624921] btrfs bad tree block start 18446744073709551615 54231040 [ 9426.624951] btrfs: failed to read log tree [ 9426.638889] btrfs: open_ctree failed > btrfs check /dev/sda1 Check tree block failed, want=54231040, have=18446744073709551615 Check tree block failed, want=54231040, have=18446744073709551615 Check tree block failed, want=54231040, have=18446744073709551615 Check tree block failed, want=54231040, have=18446744073709551615 Check tree block failed, want=54231040, have=18446744073709551615 read block failed check_tree_block Couldn't setup log root tree Checking filesystem on /dev/sda1 UUID: 77de157d-afb1-4774-b944-6cd086b42a7c checking extents zsh: segmentation fault btrfs check /dev/sda1 > btrfs-zero-log /dev/sda1 Check tree block failed, want=54231040, have=18446744073709551615 Check tree block failed, want=54231040, have=18446744073709551615 Check tree block failed, want=54231040, have=18446744073709551615 Check tree block failed, want=54231040, have=18446744073709551615 Check tree block failed, want=54231040, have=18446744073709551615 read block failed check_tree_block Couldn't setup log root tree
Created attachment 129501 [details] btrfs rescue chunk-recover -v /dev/sda1
btrfsck --repair --init-extent-tree --init-csum-tree /dev/sda1 enabling repair mode Creating a new CRC tree Check tree block failed, want=54231040, have=18446744073709551615 Check tree block failed, want=54231040, have=18446744073709551615 Check tree block failed, want=54231040, have=18446744073709551615 Check tree block failed, want=54231040, have=18446744073709551615 Check tree block failed, want=54231040, have=18446744073709551615 read block failed check_tree_block Couldn't setup log root tree Checking filesystem on /dev/sda1 UUID: 77de157d-afb1-4774-b944-6cd086b42a7c Creating a new extent tree btrfsck: ctree.c:297: __btrfs_cow_block: Assertion `!(!(buf->flags & (1 << 10)) && btrfs_header_generation(buf) > trans->transid)' failed. zsh: abort btrfsck --repair --init-extent-tree --init-csum-tree /dev/sda1
I had that exact same behaviour yesterday after a powerloss. Nearly every rescue method in described in the btrfs wiki failed (either errord out, segfaulted or failed an assertion) with either btrfs-progs 3.14, 3.16 or git. The only thing that helped was following this post: http://www.spinics.net/lists/linux-btrfs/msg36714.html Shouldn't that "patch" be made into some sort of option to btrfs-zero-log?
Oh and, I wasn't able to btrfs image the filesystem because that also segfaulted. Sorry...
(In reply to Max Liebkies from comment #4) > Oh and, I wasn't able to btrfs image the filesystem because that also > segfaulted. Sorry... @Max I've got exacly same thing but didn't try patching yet, will try now. I created https://bugzilla.kernel.org/show_bug.cgi?id=88181 bug but seems it can be closed as duplicate of this one. Also found another one that seems exactly same issue: https://bugzilla.kernel.org/show_bug.cgi?id=87021
*** Bug 88181 has been marked as a duplicate of this bug. ***
(In reply to Max Liebkies from comment #3) > I had that exact same behaviour yesterday after a powerloss. Nearly every > rescue method in described in the btrfs wiki failed (either errord out, > segfaulted or failed an assertion) with either btrfs-progs 3.14, 3.16 or > git. > > The only thing that helped was following this post: > http://www.spinics.net/lists/linux-btrfs/msg36714.html > > Shouldn't that "patch" be made into some sort of option to btrfs-zero-log? I absolutely agree, it also solved my problem. That needs to be runtime option or better just delete relevant code path...
That's effectively what these patches do (enhance zero-log to fix broken log tree pointer): https://patchwork.kernel.org/patch/5206241/ https://patchwork.kernel.org/patch/5206221/ I'm going to add them to btrfs-progs 3.17.2 release. The bug 87021 is a bit different and the patches will not help (it's not the log tree), though the underlying bug seems to be the same.
Fixed in progs 3.17.2