Skip to contentSkip to conversation

Will BTRFS repair or restore data if corrupted?

DISCUSSION Waxhead 6 participants 7 messages Jan 25, 2012 – Jan 26, 2012 Btrfs file system

lore
Share & tools
lore

Waxhead

author
#0 lore raw

Hi,

From what I have read BTRFS does replace a bad copy of data with a known good copy (if it has one). Will BTRFS try to repair the corrupt data or will it simply silently restore the data without the user knowing that a file has been "fixed"?

#1 lore raw
Quoted 3 lines · Waxhead

Hi,

From what I have read BTRFS does replace a bad copy of data with a kn=

own

Quoted 1 line

good copy (if it has one). Will BTRFS try to repair the corrupt data =

or will

Quoted 1 line

it simply silently restore the data without the user knowing that a f=

ile has

Quoted 1 line

been "fixed"?

=46rom what I've seen, it'll quietly restore the data without the user knowing. The only indication would be in dmesg where there should be a message about incorrect checksums and btrfs fixing it automatically.

Quoted 3 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs=

" in

Quoted 2 lines

the body of a message to [email protected]
More majordomo info at =A0http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" = in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#2 lore raw
In reply to Waxhead
Quoted 4 lines · Waxhead

Hi,

From what I have read BTRFS does replace a bad copy of data with a known good copy (if it has one).

Correct.

Quoted 3 lines

Will BTRFS try to repair the corrupt data or will it simply silently restore the data without the user knowing that a file has been "fixed"?

No, it'll just return the good copy and report the failure in the
system logs. If you want to fix the corrupt data, you need to use scrub, which will check everything and fix blocks with failed checksums.

Hugo.

Signature · 4 lines
=== Hugo Mills: hugo@... carfax.org.uk | darksatanic.net | lug.org.uk ===
  PGP key: 515C238D from wwwkeys.eu.pgp.net or http://www.carfax.org.uk
          --- ...  one ping(1) to rule them all, and in the ---          
                         darkness bind(2) them.                          
#3 lore raw
Quoted 1 line · Hugo Mills

On Thu, Jan 26, 2012 at 12:27:57AM +0100, Waxhead wrote:

[...]

Quoted 8 lines
Quoted 3 lines

Will BTRFS try to repair the corrupt data or will it simply silently restore the data without the user knowing that a file has been "fixed"?

No, it'll just return the good copy and report the failure in the
system logs. If you want to fix the corrupt data, you need to use scrub, which will check everything and fix blocks with failed checksums.

Since 3.2, btrfs rewrites the corrupt disk block (commit 4a54c8c and f4a8e65 from Jan Schmidt), even without scrub.

#4 lore raw
Quoted 10 lines · Stefan Behrens
Quoted 1 line · Hugo Mills

On Thu, Jan 26, 2012 at 12:27:57AM +0100, Waxhead wrote:

[...]

Quoted 7 lines
Quoted 3 lines

Will BTRFS try to repair the corrupt data or will it simply silently restore the data without the user knowing that a file has been "fixed"?

No, it'll just return the good copy and report the failure in the
system logs. If you want to fix the corrupt data, you need to use scrub, which will check everything and fix blocks with failed checksums.

Quoted 9 lines

Since 3.2, btrfs rewrites the corrupt disk block (commit 4a54c8c and f4a8e65 from Jan Schmidt), even without scrub.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

So if I for example edit a text file three times and store it I can get the following.
Version1: I currently like cheese
Version2: I currently like onions
Version3: I currently like apples
As far as I understand a disk corruption might result in me suddenly liking onions (or even cheese) instead of apples without any warning except in syslog.?! I really hope I have misunderstood the concept and that there is some error correction codes somewhere.

#5 lore raw
Quoted 9 lines

So if I for example edit a text file three times and store it I can get the following.
Version1: I currently like cheese
Version2: I currently like onions
Version3: I currently like apples
As far as I understand a disk corruption might result in me suddenly liking onions (or even cheese) instead of apples without any warning except in syslog.?! I really hope I have misunderstood the concept and that there is some error correction codes somewhere.

Yes, you've completely misunderstood the concept :p

There are crc's on each 4k block of data; if one copy fails the checksum, and a second copy is available, and that copy does match, then the good data will be returned and btrfs will overwrite the corrupted copy with the good copy. If there isn't another copy, then an io error will be returned instead.

#6 lore raw
Quoted 11 lines · cwillu
Quoted 9 lines

So if I for example edit a text file three times and store it I can get the following.
Version1: I currently like cheese
Version2: I currently like onions
Version3: I currently like apples
As far as I understand a disk corruption might result in me suddenly liking onions (or even cheese) instead of apples without any warning except in syslog.?! I really hope I have misunderstood the concept and that there is some error correction codes somewhere.

Yes, you've completely misunderstood the concept :p

Quoted 12 lines

There are crc's on each 4k block of data; if one copy fails the checksum, and a second copy is available, and that copy does match, then the good data will be returned and btrfs will overwrite the corrupted copy with the good copy. If there isn't another copy, then an io error will be returned instead.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Phew... that sounds better :)