Hugo Mills wrote:> You can check whether it''s likely to be of use by running
"btrfsck
> -s 1" on your filesystem. If it passes OK, then btrfs-select-super
> should be useful.
Inspired by this I cloned latest btrfs-progs-unstable and tried it on
my broken 60-something GB btrfs, but no luck:
$ btrfsck -s 0 /dev/sdb2
using SB copy 0, bytenr 65536
btrfsck: disk-io.c:739: open_ctree_fd: Assertion
`!(!tree_root->node)'' failed.
Aborted
$ btrfsck -s 1 /dev/sdb2
using SB copy 1, bytenr 67108864
btrfsck: disk-io.c:739: open_ctree_fd: Assertion
`!(!tree_root->node)'' failed.
Aborted
$ btrfsck -s 2 /dev/sdb2
using SB copy 2, bytenr 274877906944
No valid Btrfs found on /dev/sdb2
$
I created an empty 384 MB btrfs:
$ dd if=/dev/zero of=/tmp/test_fs bs=1024k count=384
$ mkfs.btrfs /tmp/test_fs
$
And then I compare output from btrfs-debug-tree between test_fs and
my broken one:
$ strace -e pread64 btrfs-debug-tree /tmp/test_fs 2>&1 | sed
''s-,"\(.\{5\}\).*"-, "\1"-''
pread64(3, "\351\"..., 2859, 65536) = 2859
pread64(3, "I\227"..., 2859, 67108864) = 2859
pread64(3, ""..., 2859, 274877906944) = 0
pread64(5, "\351\"..., 2859, 65536) = 2859
pread64(5, "I\227"..., 2859, 67108864) = 2859
pread64(5, ""..., 2859, 274877906944) = 0
pread64(5, "\37\2"..., 4096, 20971520) = 4096
pread64(5, "\311\"..., 4096, 37752832) = 4096
pread64(5, "\247C"..., 4096, 37756928) = 4096
pread64(5, "\225\"..., 4096, 37761024) = 4096
pread64(5, "\210z"..., 4096, 37765120) = 4096
pread64(5, "\3\34"..., 4096, 37748736) = 4096
root tree
leaf 29364224 items 9 free space 2349 generation 7 owner 1
fs uuid d29c2f7a-0a4e-4a1d-8458-2d241f6f29de
chunk uuid fb34ff75-1cb6-4974-af37-e0a464135216
item 0 key (EXTENT_TREE ROOT_ITEM 0) itemoff 3756 itemsize 239
root data bytenr 29368320 level 0 dirid 0 refs 1
item 1 key (DEV_TREE ROOT_ITEM 0) itemoff 3517 itemsize 239
root data bytenr 29372416 level 0 dirid 0 refs 1
...
$ strace -e pread64 btrfs-debug-tree /dev/sdb2 2>&1 | sed ''s-,
"\(.\{5\}\).*"-, "\1"-''
pread64(3, "p\23{"..., 2859, 65536) = 2859
pread64(3, "\320r"..., 2859, 67108864) = 2859
pread64(3, ""..., 2859, 274877906944) = 0
pread64(5, "p\23{"..., 2859, 65536) = 2859
pread64(5, "\320r"..., 2859, 67108864) = 2859
pread64(5, ""..., 2859, 274877906944) = 0
pread64(5, "\353$"..., 4096, 20971520) = 4096
pread64(5, "\275\"..., 4096, 20987904) = 4096
pread64(5, "\253\"..., 4096, 20983808) = 4096
pread64(5, "\0\0\"..., 4096, 36675878912) = 4096
pread64(5, "\0\0\"..., 4096, 36675878912) = 4096
pread64(5, "\0\0\"..., 4096, 36944314368) = 4096
btrfs-debug-tree: disk-io.c:739: open_ctree_fd: Assertion
`!(!tree_root->node)'' failed.
--- SIGABRT (Aborted) @ 0 (0) ---
+++ killed by SIGABRT +++
I also tried the btrfsck again:
$ strace -e pread64 btrfsck -s 0 /dev/sdb2 2>&1 | sed ''s-,
"\(.\?.\?.\?\).*"-, "\1"-''
pread64(3, "p\2"..., 2859, 65536) = 2859
pread64(3, "\32"..., 2859, 67108864) = 2859
pread64(3, ""..., 2859, 274877906944) = 0
pread64(3, "p\2"..., 2859, 65536) = 2859
pread64(3, "\32"..., 2859, 67108864) = 2859
pread64(3, ""..., 2859, 274877906944) = 0
pread64(5, "p\2"..., 2859, 65536) = 2859
pread64(5, "\32"..., 2859, 67108864) = 2859
pread64(5, ""..., 2859, 274877906944) = 0
pread64(5, "\35"..., 4096, 20971520) = 4096
pread64(5, "\27"..., 4096, 20987904) = 4096
pread64(5, "\25"..., 4096, 20983808) = 4096
pread64(5, "\0\"..., 4096, 36675878912) = 4096
pread64(5, "\0\"..., 4096, 36675878912) = 4096
pread64(5, "\0\"..., 4096, 36944314368) = 4096
btrfsck: disk-io.c:739: open_ctree_fd: Assertion
`!(!tree_root->node)'' failed.
using SB copy 0, bytenr 65536
--- SIGABRT (Aborted) @ 0 (0) ---
+++ killed by SIGABRT +++
$ strace -e pread64 btrfsck -s 1 /dev/sdb2 2>&1 | sed ''s-,
"\(.\?.\?.\?\).*"-, "\1"-''
pread64(3, "p\2"..., 2859, 65536) = 2859
pread64(3, "\32"..., 2859, 67108864) = 2859
pread64(3, ""..., 2859, 274877906944) = 0
pread64(3, "\32"..., 2859, 67108864) = 2859
pread64(5, "\32"..., 2859, 67108864) = 2859
pread64(5, "\35"..., 4096, 20971520) = 4096
pread64(5, "\27"..., 4096, 20987904) = 4096
pread64(5, "\25"..., 4096, 20983808) = 4096
pread64(5, "\0\"..., 4096, 36675878912) = 4096
pread64(5, "\0\"..., 4096, 36675878912) = 4096
pread64(5, "\0\"..., 4096, 36944314368) = 4096
btrfsck: disk-io.c:739: open_ctree_fd: Assertion
`!(!tree_root->node)'' failed.
using SB copy 1, bytenr 67108864
--- SIGABRT (Aborted) @ 0 (0) ---
+++ killed by SIGABRT +++
$ strace -e pread64 btrfsck -s 2 /dev/sdb2 2>&1 | sed ''s-,
"\(.\?.\?.\?\).*"-, "\1"-''
pread64(3, "p\2"..., 2859, 65536) = 2859
pread64(3, "\32"..., 2859, 67108864) = 2859
pread64(3, ""..., 2859, 274877906944) = 0
pread64(3, ""..., 2859, 274877906944) = 0
No valid Btrfs found on /dev/sdb2
using SB copy 2, bytenr 274877906944
$
Does this give any hint about how the tree has been broken?
//Peter