Skip to content

btrfs progs check/repair improvements #463

Open
@axet

Description

@axet

Hello!

I'm using btrfs for a few months (year+ maybe?) and it is crashing a lot. In additional looks like btrfs check does not have enough checks to keep filesystem integrity.

All my laptops has crashed btrfs at least once and I had to reformat the drive. Two laptops filesystem has been converted from ext4->btrfs using brfs convert. But other external hdd had clean filesystem installed and also crashed.

Right now I have a external drive with only 1 directory left, which I unable to delete. I'm trying to delete all files from hdd and unable to do so, with 'directory not empty' message.

check

axet@axet-laptop:~$ sudo btrfs check  /dev/sdb1
Opening filesystem to check...
Checking filesystem on /dev/sdb1
UUID: 168915d7-6e67-463d-8b02-870b4aa3f741
[1/7] checking root items
[2/7] checking extents
super bytes used 344440832 mismatches actual used 2818048
ERROR: errors found in extent allocation tree or chunk allocation
[3/7] checking free space cache
[4/7] checking fs roots
	unresolved ref dir 248147 index 0 namelen 23 name GameuxInstallHelper.dll filetype 1 errors 6, no dir index, no inode ref
ERROR: errors found in fs roots
found 2818048 bytes used, error(s) found
total csum bytes: 1762836
total tree bytes: 2293760
total fs tree bytes: 32768
total extent tree bytes: 16384
btree space waste bytes: 489549
file data blocks allocated: 524288
 referenced 524288

repair

axet@axet-laptop:~$ sudo btrfs check --repair /dev/sdb1
enabling repair mode
WARNING:

	Do not use --repair unless you are advised to do so by a developer
	or an experienced user, and then only after having accepted that no
	fsck can successfully repair all types of filesystem corruption. Eg.
	some software or hardware bugs can fatally damage a volume.
	The operation will start in 10 seconds.
	Use Ctrl-C to stop it.
10 9 8 7 6 5 4 3 2 1
Starting repair.
Opening filesystem to check...
Checking filesystem on /dev/sdb1
UUID: 168915d7-6e67-463d-8b02-870b4aa3f741
[1/7] checking root items
Fixed 0 roots.
[2/7] checking extents
No device size related problem found
[3/7] checking free space cache
cache and super generation don't match, space cache will be invalidated
[4/7] checking fs roots
	unresolved ref dir 248147 index 0 namelen 23 name GameuxInstallHelper.dll filetype 1 errors 6, no dir index, no inode ref
[5/7] checking only csums items (without verifying data)
there are no extents for csum range 28351565824-28372439040
csum exists for 28351565824-28372439040 but there is no extent record
there are no extents for csum range 28499345408-28513566720
csum exists for 28499345408-28513566720 but there is no extent record
there are no extents for csum range 96229019648-96261623808
csum exists for 96229019648-96261623808 but there is no extent record
there are no extents for csum range 96334622720-96341573632
csum exists for 96334622720-96341573632 but there is no extent record
there are no extents for csum range 96342097920-96468942848
csum exists for 96342097920-96468942848 but there is no extent record
there are no extents for csum range 96496582656-96640073728
csum exists for 96496582656-96640073728 but there is no extent record
there are no extents for csum range 96667172864-96799457280
csum exists for 96667172864-96799457280 but there is no extent record
there are no extents for csum range 96933675008-96933707776
csum exists for 96933675008-96933707776 but there is no extent record
there are no extents for csum range 97278468096-97291657216
csum exists for 97278468096-97291657216 but there is no extent record
there are no extents for csum range 97313767424-97326399488
csum exists for 97313767424-97326399488 but there is no extent record
there are no extents for csum range 97369628672-97713807360
csum exists for 97369628672-97713807360 but there is no extent record
ERROR: errors found in csum tree
[6/7] checking root refs
[7/7] checking quota groups skipped (not enabled on this FS)
found 2818048 bytes used, error(s) found
total csum bytes: 1762836
total tree bytes: 2293760
total fs tree bytes: 32768
total extent tree bytes: 16384
btree space waste bytes: 489549
file data blocks allocated: 524288
 referenced 524288

check

axet@axet-laptop:~$
axet@axet-laptop:~$ sudo btrfs check  /dev/sdb1
Opening filesystem to check...
Checking filesystem on /dev/sdb1
UUID: 168915d7-6e67-463d-8b02-870b4aa3f741
[1/7] checking root items
[2/7] checking extents
[3/7] checking free space cache
cache and super generation don't match, space cache will be invalidated
[4/7] checking fs roots
	unresolved ref dir 248147 index 0 namelen 23 name GameuxInstallHelper.dll filetype 1 errors 6, no dir index, no inode ref
ERROR: errors found in fs roots
found 2818048 bytes used, error(s) found
total csum bytes: 1762836
total tree bytes: 2293760
total fs tree bytes: 32768
total extent tree bytes: 16384
btree space waste bytes: 489549
file data blocks allocated: 524288
 referenced 524288

remove files

axet@axet-laptop:/media/axet/120GB$ find .
.
./.Trash-1000
./.Trash-1000/files
./.Trash-1000/files/Games
./.Trash-1000/files/Games/Unreal Tournament GOTY
./.Trash-1000/info
axet@axet-laptop:/media/axet/120GB$ rm -rf .Trash-1000/
rm: cannot remove '.Trash-1000/files/Games/Unreal Tournament GOTY': Directory not empty
axet@axet-laptop:/media/axet/120GB$ 

btfs info

axet@axet-laptop:/media/axet/120GB$ sudo btrfs fi show .
Label: '120GB'  uuid: 168915d7-6e67-463d-8b02-870b4aa3f741
	Total devices 1 FS bytes used 2.69MiB
	devid    1 size 111.79GiB used 3.02GiB path /dev/sdb1
axet@axet-laptop:/media/axet/120GB$ btrfs fi df .
Data, single: total=1.00GiB, used=512.00KiB
System, DUP: total=8.00MiB, used=16.00KiB
Metadata, DUP: total=1.00GiB, used=2.17MiB
GlobalReserve, single: total=3.25MiB, used=0.00B

btrfs-progs 5.16.2-1
debian bookworm

Do you need more details about current sate of the filesystem?

EDIT: I upload filesystem 4gb as gz archive (6mb gz size): https://disk.yandex.ru/d/CXsVdIle086ABA

Description: filesystem has a single folder on entier filesystem called "Unreal Tournament GOTY' which is not possible to delete. btrfs check reports no problems.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions