* BTRFS Metadata Corruption Prevents Scrub and btrfs check
@ 2017-03-17 12:22 John Marrett
2017-03-17 13:51 ` Peter Grandi
0 siblings, 1 reply; 5+ messages in thread
From: John Marrett @ 2017-03-17 12:22 UTC (permalink / raw)
To: linux-btrfs
I have a filesystem with uncorrectable errors in metadata. In the past
when I've experienced corruption due to drive failures it affected the
data and not metadata. I was able to delete the files and restored
their content from backup. Unfortunately I can't do this this time as
I have no way to directly affect the metadata. I encounter stale file
handle errors when I try to access the impacted files:
tar: home/johnf/personal/projects/openwrt/trunk/build_dir/target-mips_r2_uClibc-0.9.32/hostapd-wpad-mini/hostapd-20110117/hostapd/hostapd.eap_user:
Read error at byte 0, while reading 3975 bytes: Input/output error
tar: home/johnf/personal/projects/openwrt/trunk/build_dir/target-mips_r2_uClibc-0.9.32/hostapd-wpad-mini/hostapd-20110117/hostapd/hostapd.radius_clients:
Cannot stat: Stale file handle
tar: home/johnf/personal/projects/openwrt/trunk/build_dir/target-mips_r2_uClibc-0.9.32/hostapd-wpad-mini/hostapd-20110117/hostapd/hostapd.sim_db:
Cannot stat: Stale file handle
When I attempt a scrub the system fails with the following messages:
Thu Mar 9 20:41:20 EST 2017
scrub status for 67b4821f-16e0-436d-b521-e4ab2c7d3ab7
scrub started at Thu Mar 9 13:04:52 2017 and finished after 07:05:41
total bytes scrubbed: 12.56TiB with 2 errors
error details: csum=2
corrected errors: 0, uncorrectable errors: 2, unverified errors: 0
The following messages are emitted by the kernel:
[43022.286418] BTRFS warning (device sda4): sda4 checksum verify
failed on 9626194001920 wanted 26FCCA1 found 6EB184F1 level 0
[43022.305795] BTRFS warning (device sda4): sda4 checksum verify
failed on 9626194001920 wanted 26FCCA1 found 6EB184F1 level 0
[76606.731223] BTRFS warning (device sda4): checksum error at logical
9626194001920 on dev /dev/sdh1, sector 5016524768: metadata leaf
(level 0) in tree 4804958584832
[76606.731233] BTRFS warning (device sda4): checksum error at logical
9626194001920 on dev /dev/sdh1, sector 5016524768: metadata leaf
(level 0) in tree 4804958584832
[76606.731240] BTRFS error (device sda4): bdev /dev/sdh1 errs: wr 0,
rd 0, flush 0, corrupt 2, gen 0
[76606.734185] BTRFS warning (device sda4): checksum error at logical
9626194001920 on dev /dev/sdg1, sector 5016524768: metadata leaf
(level 0) in tree 4804958584832
[76606.734192] BTRFS warning (device sda4): checksum error at logical
9626194001920 on dev /dev/sdg1, sector 5016524768: metadata leaf
(level 0) in tree 4804958584832
[76606.734196] BTRFS error (device sda4): bdev /dev/sdg1 errs: wr 0,
rd 0, flush 0, corrupt 2, gen 0
[76606.735122] BTRFS error (device sda4): unable to fixup (regular)
error at logical 9626194001920 on dev /dev/sdh1
[76609.735650] BTRFS error (device sda4): unable to fixup (regular)
error at logical 9626194001920 on dev /dev/sdg1
I then shut the system down and performed a btrfs check using the
lastest btrfs-progs from master:
ubuntu@ubuntu:~/tmp/btrfs-progs$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean
ubuntu@ubuntu:~/tmp/btrfs-progs$ ./btrfs --version
btrfs-progs v4.10
ubuntu@ubuntu:~/tmp/btrfs-progs$ sudo ./btrfs check -p --repair /dev/sda4
enabling repair mode
Checking filesystem on /dev/sda4
UUID: 67b4821f-16e0-436d-b521-e4ab2c7d3ab7
checksum verify failed on 9626194001920 found 6EB184F1 wanted 026FCCA1
checksum verify failed on 9626194001920 found 6EB184F1 wanted 026FCCA1
checksum verify failed on 9626194001920 found 6EB184F1 wanted 026FCCA1
checksum verify failed on 9626194001920 found 6EB184F1 wanted 026FCCA1
Csum didn't match
ref mismatch on [5165855678464 28672] extent item 1, found 0
checksum verify failed on 9626194001920 found 6EB184F1 wanted 026FCCA1
checksum verify failed on 9626194001920 found 6EB184F1 wanted 026FCCA1
checksum verify failed on 9626194001920 found 6EB184F1 wanted 026FCCA1
checksum verify failed on 9626194001920 found 6EB184F1 wanted 026FCCA1
Csum didn't match
Incorrect local backref count on 5165855678464 root 259 owner 1732872
offset 0 found 0 wanted 1 back 0x3ba80f40
Backref disk bytenr does not match extent record,
bytenr=5165855678464, ref bytenr=7880454922968236032
backpointer mismatch on [5165855678464 28672]
owner ref check failed [5165855678464 28672]
checksum verify failed on 9626194001920 found 6EB184F1 wanted 026FCCA1
checksum verify failed on 9626194001920 found 6EB184F1 wanted 026FCCA1
checksum verify failed on 9626194001920 found 6EB184F1 wanted 026FCCA1
checksum verify failed on 9626194001920 found 6EB184F1 wanted 026FCCA1
Csum didn't match
failed to repair damaged filesystem, aborting
I have backups of the affected files, I simply want to restore them
and return the filesystem to a stable state. Is there a way I can do
this without erasing the entire filesystem and restoring it?
Thanks in advance for your help and guidance,
-JohnF
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: BTRFS Metadata Corruption Prevents Scrub and btrfs check
2017-03-17 12:22 BTRFS Metadata Corruption Prevents Scrub and btrfs check John Marrett
@ 2017-03-17 13:51 ` Peter Grandi
2017-03-17 19:25 ` John Marrett
0 siblings, 1 reply; 5+ messages in thread
From: Peter Grandi @ 2017-03-17 13:51 UTC (permalink / raw)
To: Linux fs Btrfs
> Read error at byte 0, while reading 3975 bytes: Input/output error
Bad news. That means that probably the disk is damaged and
further issues may happen.
> corrected errors: 0, uncorrectable errors: 2, unverified errors: 0
Even worse news.
> Incorrect local backref count on 5165855678464 root 259 owner 1732872
> offset 0 found 0 wanted 1 back 0x3ba80f40
> Backref disk bytenr does not match extent record,
> bytenr=5165855678464, ref bytenr=7880454922968236032
> backpointer mismatch on [5165855678464 28672]
"Better" news. In practice a single metadata leaf node is
corrupted in back references. You might be lucky and that might
be rebuildable, but I don't know enough about the somewhat
intricate Btrfs metadata trees to figure that out. Some metadata
is rebuildable from other metadata with a tree scan, some not.
In general metadata in Btrfs is fairly intricate and metadata
block loss is pretty fatal, that's why metadata should most
times be redundant as in 'dup' or 'raid1' or similar:
http://www.sabi.co.uk/blog/16-two.html?160817#160817
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: BTRFS Metadata Corruption Prevents Scrub and btrfs check
2017-03-17 13:51 ` Peter Grandi
@ 2017-03-17 19:25 ` John Marrett
2017-03-17 19:35 ` Austin S. Hemmelgarn
2017-03-18 0:48 ` Peter Grandi
0 siblings, 2 replies; 5+ messages in thread
From: John Marrett @ 2017-03-17 19:25 UTC (permalink / raw)
To: Peter Grandi; +Cc: Linux fs Btrfs
Peter,
> Bad news. That means that probably the disk is damaged and
> further issues may happen.
This system has a long history, I have had a dual drive failure in the
past, I managed to recover from that with ddrescue. I've subsequently
copied the contents of the drives to new disks and expanded them. This
corruption probably stems from issues in the past and not from issues
with the current drives.
>> Incorrect local backref count on 5165855678464 root 259 owner 1732872
>> offset 0 found 0 wanted 1 back 0x3ba80f40
>> Backref disk bytenr does not match extent record,
>> bytenr=5165855678464, ref bytenr=7880454922968236032
>> backpointer mismatch on [5165855678464 28672]
>
> "Better" news. In practice a single metadata leaf node is
> corrupted in back references. You might be lucky and that might
> be rebuildable, but I don't know enough about the somewhat
> intricate Btrfs metadata trees to figure that out. Some metadata
> is rebuildable from other metadata with a tree scan, some not.
How can I attempt to rebuild the metadata, with a treescan or otherwise?
> In general metadata in Btrfs is fairly intricate and metadata
> block loss is pretty fatal, that's why metadata should most
> times be redundant as in 'dup' or 'raid1' or similar:
All the data and metadata on this system is in raid1 or raid10, in
fact I discovered this issue while trying to change my balance form
raid1 to raid10.
johnf@carbon:~$ sudo btrfs fi df /
Data, RAID10: total=1.13TiB, used=1.12TiB
Data, RAID1: total=5.17TiB, used=5.16TiB
System, RAID1: total=32.00MiB, used=864.00KiB
Metadata, RAID10: total=3.09GiB, used=3.08GiB
Metadata, RAID1: total=13.00GiB, used=10.16GiB
GlobalReserve, single: total=512.00MiB, used=0.00B
Thanks for your help, much appreciated,
-JohnF
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: BTRFS Metadata Corruption Prevents Scrub and btrfs check
2017-03-17 19:25 ` John Marrett
@ 2017-03-17 19:35 ` Austin S. Hemmelgarn
2017-03-18 0:48 ` Peter Grandi
1 sibling, 0 replies; 5+ messages in thread
From: Austin S. Hemmelgarn @ 2017-03-17 19:35 UTC (permalink / raw)
To: John Marrett, Peter Grandi; +Cc: Linux fs Btrfs
On 2017-03-17 15:25, John Marrett wrote:
> Peter,
>
>> Bad news. That means that probably the disk is damaged and
>> further issues may happen.
>
> This system has a long history, I have had a dual drive failure in the
> past, I managed to recover from that with ddrescue. I've subsequently
> copied the contents of the drives to new disks and expanded them. This
> corruption probably stems from issues in the past and not from issues
> with the current drives.
One quick tip on this particular note, when you replace a drive (or copy
to new larger drives), run:
btrfs device stats -z
To reset the error counters. This way, you can be sure that the
counters count errors for the filesystem as it currently exists without
leftover counts from any previous drive configuration.
Ideally, the tools would reset them when replacing a device on only that
device, but even if they did, that wouldn't help with simply copying the
filesystem to a new disk.
The other aspect to this is scrubbing regularly and monitoring both the
output of scrub and the error counters, so you know _when_ an error
happened, not just that it happened at some point in the past.
Personally, I would suggest checking the error counters at least daily,
possibly more frequently (it's not an expensive operation, and the
sooner you know about issues the better) and scrubbing at least monthly
(I scrub daily on most of my systems, but I don't store a large enough
amount of data for that to have a significant impact on performance).
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: BTRFS Metadata Corruption Prevents Scrub and btrfs check
2017-03-17 19:25 ` John Marrett
2017-03-17 19:35 ` Austin S. Hemmelgarn
@ 2017-03-18 0:48 ` Peter Grandi
1 sibling, 0 replies; 5+ messages in thread
From: Peter Grandi @ 2017-03-18 0:48 UTC (permalink / raw)
To: Linux fs Btrfs
> How can I attempt to rebuild the metadata, with a treescan or
> otherwise?
I don't know unfortunately for backrefs.
>> In general metadata in Btrfs is fairly intricate and metadata
>> block loss is pretty fatal, that's why metadata should most
>> times be redundant as in 'dup' or 'raid1' or similar:
> All the data and metadata on this system is in raid1 or
> raid10, in fact I discovered this issue while trying to change
> my balance form raid1 to raid10.
> johnf@carbon:~$ sudo btrfs fi df /
> Data, RAID10: total=1.13TiB, used=1.12TiB
> Data, RAID1: total=5.17TiB, used=5.16TiB
> System, RAID1: total=32.00MiB, used=864.00KiB
> Metadata, RAID10: total=3.09GiB, used=3.08GiB
> Metadata, RAID1: total=13.00GiB, used=10.16GiB
> GlobalReserve, single: total=512.00MiB, used=0.00B
That's weird because as a rule when there is a checksum error
it is automatically corrected on read if there is a "good copy".
Also because you have both RAID1 and RAID10 data and metadata.
You should have just RAID1 metadata and RAID10 data or both
RAID10. There is probably an "interrupted" 'balance'.
Just had a look at your previous message and it reports out of
12.56TB 2 uncorrectable errors. But you have got everything
redundant ('raid1' or 'raid10', so it looks like somehow those
two blocks are supposed to be copies of each other and are bad:
* 'sdg1' at physical sector 5016524768 volume byte offset 9626194001920
* 'sdh1' at physical sector 5016524768 volume byte offset 9626194001920
* both sectors belong to the tree at byte offset 4804958584832.
Note: BTW I remember someone wrote a guide to decoding Btrfs
'dmesg' lines, but I can't find it anymore, so not sure that
interpretation is entirely correct.
It is a bit "strange" that it is the same sector, as Btrfs
'raid1' profile is not necessarily block-for-block, mirrored
chunks can be in different offsets.
The "strange" symptoms hint not just at disk issues, but also
some past attempts at conversion (I remember a previous message
from you) or recovery have messed up things a bit.
Someone mentioned in some mailing list articles various tools to
print out trees and subtrees and in general inspect. 'Knorrie'
has written a Python library (and a few inspection tools) with
which it is possible to traverse various Btrfs trees, but I
haven't used it:
https://github.com/knorrie/python-btrfs/
I'd suggest searching the mailing list for related information.
Also the relevant tree is described here (the one on kernel.org
probably is more up-to-date):
https://oss.oracle.com/projects/btrfs/dist/documentation/btrfs-backrefs.html
https://btrfs.wiki.kernel.org/index.php/Btrfs_design#Explicit_Back_References
https://btrfs.wiki.kernel.org/index.php/Data_Structures
https://btrfs.wiki.kernel.org/index.php/Trees
You might want to use 'btrfs inspect-internal'.
Conceivably as the issue seems related to an extent backref
'btrfsck --repair' with '--init-extent-tree' might help, but I
cannot recommend that as I don't know if they are relevant to
your problem and/or safe in your situation. Consider this:
http://www.mail-archive.com/linux-btrfs@vger.kernel.org/msg26816.html
I would use the very most recent version of 'btrfsprogs'.
One possibility I would consider is to move a sufficiently large
subtree of:
/home/johnf/personal/projects/openwrt/trunk/build_dir/target-mips_r2_uClibc-0.9.32/hostapd-wpad-mini/hostapd-20110117/hostapd/hostapd.eap_user
into its own directory, create a new subvolume, 'cp --reflink'
everything except that directory into the new subvolume, and
then *perhaps* work on the new subvolume will not access the
damaged metadata block.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-03-18 1:06 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-17 12:22 BTRFS Metadata Corruption Prevents Scrub and btrfs check John Marrett
2017-03-17 13:51 ` Peter Grandi
2017-03-17 19:25 ` John Marrett
2017-03-17 19:35 ` Austin S. Hemmelgarn
2017-03-18 0:48 ` Peter Grandi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox