Open cmurf opened 2 years ago
OK doing only --force --repair
on a new but empty btrfs on /dev/loop0, it didn't actually make changes so it didn't corrupt the file system. But adding --init-extent-tree
did:
# df
Filesystem 1K-blocks Used Available Use% Mounted on
[snip]
/dev/loop0 104857600 3872 102743040 1% /mnt
# btrfs check --repair --force --init-extent-tree /dev/loop0
enabling repair mode
Opening filesystem to check...
WARNING: filesystem mounted, continuing because of --force
Checking filesystem on /dev/loop0
UUID: 68b27e42-4391-4a14-b44b-ba28b4e31805
Creating a new extent tree
Failed to find [30572544, 168, 16384]
btrfs unable to find ref byte nr 30605312 parent 0 root 1 owner 0 offset 0
path->slots[0]: 7 path->nodes[0]:
leaf 30408704 items 7 free space 15886 generation 9 owner EXTENT_TREE
leaf 30408704 flags 0x0() backref revision 1
fs uuid 68b27e42-4391-4a14-b44b-ba28b4e31805
chunk uuid 8e478a70-9bb5-4ae9-9670-92306b4ec691
item 0 key (13631488 BLOCK_GROUP_ITEM 8388608) itemoff 16259 itemsize 24
block group used 0 chunk_objectid 256 flags DATA|single
item 1 key (30408704 METADATA_ITEM 0) itemoff 16226 itemsize 33
refs 1 gen 9 flags TREE_BLOCK
tree block skinny level 0
tree block backref root EXTENT_TREE
item 2 key (30441472 METADATA_ITEM 0) itemoff 16193 itemsize 33
refs 1 gen 9 flags TREE_BLOCK
tree block skinny level 0
tree block backref root ROOT_TREE
item 3 key (30474240 METADATA_ITEM 0) itemoff 16160 itemsize 33
refs 1 gen 9 flags TREE_BLOCK
tree block skinny level 0
tree block backref root FREE_SPACE_TREE
item 4 key (30507008 METADATA_ITEM 1) itemoff 16127 itemsize 33
refs 1 gen 9 flags TREE_BLOCK
tree block skinny level 1
tree block backref root FREE_SPACE_TREE
item 5 key (30556160 METADATA_ITEM 0) itemoff 16094 itemsize 33
refs 1 gen 9 flags TREE_BLOCK
tree block skinny level 0
tree block backref root FREE_SPACE_TREE
item 6 key (30572544 METADATA_ITEM 0) itemoff 16061 itemsize 33
refs 1 gen 9 flags TREE_BLOCK
tree block skinny level 0
tree block backref root FREE_SPACE_TREE
Failed to find [30572544, 168, 16384]
btrfs unable to find ref byte nr 30638080 parent 0 root 10 owner 0 offset 0
path->slots[0]: 7 path->nodes[0]:
leaf 30408704 items 7 free space 15886 generation 9 owner EXTENT_TREE
leaf 30408704 flags 0x0() backref revision 1
fs uuid 68b27e42-4391-4a14-b44b-ba28b4e31805
chunk uuid 8e478a70-9bb5-4ae9-9670-92306b4ec691
item 0 key (13631488 BLOCK_GROUP_ITEM 8388608) itemoff 16259 itemsize 24
block group used 0 chunk_objectid 256 flags DATA|single
item 1 key (30408704 METADATA_ITEM 0) itemoff 16226 itemsize 33
refs 1 gen 9 flags TREE_BLOCK
tree block skinny level 0
tree block backref root EXTENT_TREE
item 2 key (30441472 METADATA_ITEM 0) itemoff 16193 itemsize 33
refs 1 gen 9 flags TREE_BLOCK
tree block skinny level 0
tree block backref root ROOT_TREE
item 3 key (30474240 METADATA_ITEM 0) itemoff 16160 itemsize 33
refs 1 gen 9 flags TREE_BLOCK
tree block skinny level 0
tree block backref root FREE_SPACE_TREE
item 4 key (30507008 METADATA_ITEM 1) itemoff 16127 itemsize 33
refs 1 gen 9 flags TREE_BLOCK
tree block skinny level 1
tree block backref root FREE_SPACE_TREE
item 5 key (30556160 METADATA_ITEM 0) itemoff 16094 itemsize 33
refs 1 gen 9 flags TREE_BLOCK
tree block skinny level 0
tree block backref root FREE_SPACE_TREE
item 6 key (30572544 METADATA_ITEM 0) itemoff 16061 itemsize 33
refs 1 gen 9 flags TREE_BLOCK
tree block skinny level 0
tree block backref root FREE_SPACE_TREE
[1/7] checking root items... skipped
[2/7] checking extents
ref mismatch on [22036480 16384] extent item 0, found 1
tree backref 22036480 root 3 not found in extent tree
backpointer mismatch on [22036480 16384]
adding new tree backref on start 22036480 len 16384 parent 0 root 3
Repaired extent references for 22036480
ref mismatch on [30425088 16384] extent item 0, found 1
tree backref 30425088 root 5 not found in extent tree
backpointer mismatch on [30425088 16384]
adding new tree backref on start 30425088 len 16384 parent 0 root 5
Repaired extent references for 30425088
ref mismatch on [30457856 16384] extent item 0, found 1
tree backref 30457856 root 4 not found in extent tree
backpointer mismatch on [30457856 16384]
adding new tree backref on start 30457856 len 16384 parent 0 root 4
Repaired extent references for 30457856
ref mismatch on [30490624 16384] extent item 0, found 1
tree backref 30490624 root 7 not found in extent tree
backpointer mismatch on [30490624 16384]
adding new tree backref on start 30490624 len 16384 parent 0 root 7
Repaired extent references for 30490624
ref mismatch on [30539776 16384] extent item 0, found 1
tree backref 30539776 root 9 not found in extent tree
backpointer mismatch on [30539776 16384]
adding new tree backref on start 30539776 len 16384 parent 0 root 9
Repaired extent references for 30539776
super bytes used 196608 mismatches actual used 114688
No device size related problem found
[3/7] checking free space tree
free space info recorded 0 extents, counted 2
Clear free space cache v2
free space cache v2 cleared
[4/7] checking fs roots
[5/7] checking only csums items (without verifying data)
[6/7] checking root refs
[7/7] checking quota groups skipped (not enabled on this FS)
found 393216 bytes used, no error found
total csum bytes: 0
total tree bytes: 393216
total fs tree bytes: 65536
total extent tree bytes: 32768
btree space waste bytes: 306598
file data blocks allocated: 0
referenced 0
[root@fovo ~]# umount /mnt
[root@fovo ~]# btrfs check /dev/loop0
Opening filesystem to check...
Checking filesystem on /dev/loop0
UUID: 68b27e42-4391-4a14-b44b-ba28b4e31805
[1/7] checking root items
[2/7] checking extents
ERROR: invalid generation for extent 30523392, have 19 expect (0, 10]
owner ref check failed [30523392 16384]
ERROR: errors found in extent allocation tree or chunk allocation
[3/7] checking free space tree
[4/7] checking fs roots
parent transid verify failed on 30523392 wanted 5 found 19
Ignoring transid failure
root 18446744073709551607 root dir 256 not found
root 18446744073709551607 inode 735051776 errors 1, no inode item
root 18446744073709551607 inode 743440384 errors 1, no inode item
root 18446744073709551607 inode 751828992 errors 1, no inode item
root 18446744073709551607 inode 760217600 errors 1, no inode item
root 18446744073709551607 inode 768606208 errors 1, no inode item
root 18446744073709551607 inode 776994816 errors 1, no inode item
root 18446744073709551607 inode 785383424 errors 1, no inode item
root 18446744073709551607 inode 793772032 errors 1, no inode item
root 18446744073709551607 inode 802160640 errors 1, no inode item
root 18446744073709551607 inode 810549248 errors 1, no inode item
root 18446744073709551607 inode 818937856 errors 1, no inode item
root 18446744073709551607 inode 827326464 errors 1, no inode item
root 18446744073709551607 inode 835715072 errors 1, no inode item
root 18446744073709551607 inode 844103680 errors 1, no inode item
root 18446744073709551607 inode 852492288 errors 1, no inode item
root 18446744073709551607 inode 860880896 errors 1, no inode item
root 18446744073709551607 inode 869269504 errors 1, no inode item
root 18446744073709551607 inode 877658112 errors 1, no inode item
root 18446744073709551607 inode 886046720 errors 1, no inode item
root 18446744073709551607 inode 894435328 errors 1, no inode item
root 18446744073709551607 inode 902823936 errors 1, no inode item
root 18446744073709551607 inode 911212544 errors 1, no inode item
root 18446744073709551607 inode 919601152 errors 1, no inode item
root 18446744073709551607 inode 927989760 errors 1, no inode item
root 18446744073709551607 inode 936378368 errors 1, no inode item
root 18446744073709551607 inode 944766976 errors 1, no inode item
root 18446744073709551607 inode 953155584 errors 1, no inode item
root 18446744073709551607 inode 961544192 errors 1, no inode item
root 18446744073709551607 inode 969932800 errors 1, no inode item
root 18446744073709551607 inode 978321408 errors 1, no inode item
root 18446744073709551607 inode 986710016 errors 1, no inode item
root 18446744073709551607 inode 995098624 errors 1, no inode item
root 18446744073709551607 inode 1003487232 errors 1, no inode item
root 18446744073709551607 inode 1011875840 errors 1, no inode item
root 18446744073709551607 inode 1020264448 errors 1, no inode item
root 18446744073709551607 inode 1028653056 errors 1, no inode item
root 18446744073709551607 inode 1037041664 errors 1, no inode item
root 18446744073709551607 inode 1045430272 errors 1, no inode item
root 18446744073709551607 inode 1053818880 errors 1, no inode item
root 18446744073709551607 inode 1062207488 errors 1, no inode item
root 18446744073709551607 inode 1070596096 errors 1, no inode item
root 18446744073709551607 inode 1078984704 errors 1, no inode item
root 18446744073709551607 inode 1087373312 errors 1, no inode item
root 18446744073709551607 inode 1095761920 errors 1, no inode item
ERROR: errors found in fs roots
found 147456 bytes used, error(s) found
total csum bytes: 0
total tree bytes: 131072
total fs tree bytes: 16384
total extent tree bytes: 16384
btree space waste bytes: 124494
file data blocks allocated: 0
referenced 0
# mount /dev/loop0 /mnt
mount: /mnt: wrong fs type, bad option, bad superblock on /dev/loop0, missing codepage or helper program, or other error.
dmesg(1) may have more information after failed mount system call.
#
dmesg excerpt from that:
[ 5606.747131] BTRFS info (device loop0): flagging fs with big metadata feature
[ 5606.747155] BTRFS info (device loop0): using free space tree
[ 5606.747159] BTRFS info (device loop0): has skinny extents
[ 5606.751011] BTRFS error (device loop0): parent transid verify failed on 30523392 wanted 5 found 19
[ 5606.751141] BTRFS error (device loop0): parent transid verify failed on 30523392 wanted 5 found 19
[ 5606.751159] BTRFS warning (device loop0): failed to read root (objectid=4): -5
[ 5606.752480] BTRFS error (device loop0): open_ctree failed
Isn't this expected since --force
is used to run check on mounted filesystems?
Expected results: should refuse to run and warn
It warns WARNING: filesystem mounted, continuing because of --force
, the --force arugment does what it says, should we add more force for the rw repair on mounted filesystem?
The help text says --force skip mount checks, repair is not possible
but the force + repair combination works so that is wrong, one way or the other.
I've updated the documentation, but I still need to reevaluate if we should add another option or force the delay in case its repair + force + mounted fs.
What about --force
only working on RO mounted file systems?
I'm not understanding the benefit/need for running the command on RW mounted file systems, which have a pretty good chance of being active and therefore the command will produce bogus results whether --readonly
or --repair
I'm seeing users do both on root file systems. If we give users a hurt me button, they will push it.
Alternatively:
--repair
+ --force
only works on RO mounted file systems.
--readonly
+ --force
works on RO and RW mounted file systems, but report the mounted state (RO or RW) to STDOUT so we know if the results might be questionable.
btrfs-progs 5.18.1, not sure when the regression occurred
btrfs check --force --repair
on itbtrfs check --readonly
Actual results: busted fs
Expected results: should refuse to run and warn