kdave / btrfs-progs

Development of userspace BTRFS tools
GNU General Public License v2.0
550 stars 241 forks source link

Cannot automatically delete dangling dir and recover from "no inode item, link count wrong" #682

Open tribbloid opened 1 year ago

tribbloid commented 1 year ago

This is my attempt to fix previous errors (see https://github.com/kdave/btrfs-progs/issues/680 and https://github.com/kdave/btrfs-progs/issues/681):

$ sudo btrfs check --check-data-csum --repair /dev/nvme0n1p7

...
root 5 inode 2554096 errors 2001, no inode item, link count wrong
    unresolved ref dir 7298 index 0 namelen 23 name no-need-mtime-check.txt filetype 1 errors 6, no dir index, no inode ref
Trying to rebuild inode:2554097
root 5 inode 2554097 errors 2001, no inode item, link count wrong
    unresolved ref dir 7298 index 0 namelen 25 name locale-for-miner-apps.txt filetype 1 errors 6, no dir index, no inode ref
Trying to rebuild inode:2554098
root 5 inode 2554098 errors 2001, no inode item, link count wrong
    unresolved ref dir 16791 index 0 namelen 15 name 1-4383-6508b320 filetype 1 errors 6, no dir index, no inode ref
Trying to rebuild inode:2554099
root 5 inode 2554099 errors 2001, no inode item, link count wrong
    unresolved ref dir 7355 index 0 namelen 14 name default-routes filetype 1 errors 6, no dir index, no inode ref
Trying to rebuild inode:2554100
root 5 inode 2554100 errors 2001, no inode item, link count wrong
    unresolved ref dir 7355 index 0 namelen 14 name restore-stream filetype 1 errors 6, no dir index, no inode ref
ERROR: errors found in fs roots
found 428755345408 bytes used, error(s) found
total csum bytes: 331715616
total tree bytes: 3109339136
total fs tree bytes: 2513338368
total extent tree bytes: 146030592
btree space waste bytes: 562543348
file data blocks allocated: 622549237760
 referenced 426182934528

The attempt to rebuild every inode ends up with the same error message, with no action performed. This resulted in the file system not being able to be reverted to a usable state.

There should be an option to delete the dir or file if its inode is broken

tribbloid commented 1 year ago

BTW, the CoW is enabled in this case, if not, there will be few information to recover each file and directory