List of known BTRFS Raid 5/6 Bugs?
Write hole:
Quoted 5 lines
The data will be readable until one of the data blocks becomes inaccessible (bad sector or failed disk). This is because it is only the parity block that is corrupted (old data blocks are still not modified due to btrfs CoW), and the parity block is only required when recovering from a disk failure.
I am unsure about your meaning.
Assuming you perform an unclean shutdown (eg. crash), and after restart perform a scrub, with no additional error (bad sector, bit-rot) before or after the crash:
will you loose data? Will you be able to mount the filesystem like normal? Additionaly, will the crash create additional errors like bad sectors and or bit-rot aside from the parity-block corruption? Its actually part of my first mail, where the btrfs Raid5/6 page assumes no data damage while the spinics comment implies the opposite.
The write hole does not seem as dangerous if you could simply scrub to repair damage (On smaller discs that is, where scrub doesnt take enough time for additional errors to occur)
Quoted 5 lines
Put another way: if all disks are online then RAID5/6 behaves like a slow RAID0, and RAID0 does not have the partial stripe update problem because all of the data blocks in RAID0 are independent. It is only when a disk fails in RAID5/6 that the parity block is combined with data blocks, so it is only in this case that the write hole bug can result in lost data.
So data will not be lost if no drive has failed?
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
If the filesystem is -draid5 -mraid1 then the metadata is not vulnerable to the write hole, but data is. In this configuration you can determine with high confidence which files you need to restore from backup, and the filesystem will remain writable to replace the restored data, because raid1 does not have the write hole bug.
In regards to my earlier questions, what would change if i do -draid5 -mraid1?
Lost Writes:
Quoted 2 lines
Hotplugging causes an effect (lost writes) which can behave similarly to the write hole bug in some instances. The similarity ends there.
Are we speaking about the same problem that is causing transid mismatch?
Quoted 4 lines
They are really two distinct categories of problem. Temporary connection loss can do bad things to all RAID profiles on btrfs (not just RAID5/6) and the btrfs requirements for handling connection loss and write holes are very different.
What kind of bad things? Will scrub (1/10, 5/6) detect and repair it?
Quoted 8 lines
Quoted 2 lines
Quoted 2 lines
Hot-unplugging a device can cause many lost write events at once, and each lost write event is very bad.
Transid mismatch is btrfs detecting data
that was previously silently corrupted by some component outside of btrfs.btrfs can't prevent disks from silently corrupting data. It can only try to detect and repair the damage after the damage has occurred.
Aside from the chance that all copies of data are corrupted, is there any way scrubbing could fail?
Quoted 6 lines
Normally RAID1/5/6/10 or DUP profiles are used for btrfs metadata, so any transid mismatches can be recovered by reading up-to-date data from the other mirror copy of the metadata, or by reconstructing the data with parity blocks in the RAID 5/6 case. It is only after this recovery mechanism fails (i.e. too many disks have a failure or corruption at the same time on the same sectors) that the filesystem is ended.
Does this mean that transid mismatch is harmless unless both copys are hit at once (And in case of Raid 6 all three)?
Old hardware:
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
It's fun and/or scary to put known good and bad hardware in the same RAID1 array and watch btrfs autocorrecting the bad data after every other power failure; however, the bad hardware is clearly not sufficient to implement any sort of reliable data persistence, and arrays with bad hardware in them will eventually fail.
I am having a hard time wrapping my head around this statement.
If Btrfs can repair corrupted data and Raid 6 allows two disc failures at once without data loss, is using old discs even with high average error count not still pretty much safe? You would simply have to repeat the scrubbing process more often to make sure that not enough data is corrupted to break redundancy.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
I have one test case where I write millions of errors into a raid5/6 and the filesystem recovers every single one transparently while verifying SHA1 hashes of test data. After years of rebuilding busted ext3 on mdadm-raid5 filesystems, watching btrfs do it all automatically is just...beautiful.
Once again, if Btrfs is THIS good at repairing data, then is old hardware, hotplugging and maybe even (depending on whether i understood your point) write hole really dangerous? Are there bugs that could destroy the data or filesystem whitout corrupting all copies of data (Or all copies at once)? Assuming Raid 6, corrupted data would not break redundancy and repeated scrubbing would fix any upcoming issue.
-------------------------------------------------------------------------------------------------
FreeMail powered by mail.de - MEHR SICHERHEIT, SERIOSITÄT UND KOMFORT
Quoted 9 lines · On Sat, Aug 11, 2018 at 04:18:35AM +0200, [email protected] wrote:
Write hole:
Quoted 5 lines
The data will be readable until one of the data blocks becomes inaccessible (bad sector or failed disk). This is because it is only the parity block that is corrupted (old data blocks are still not modified due to btrfs CoW), and the parity block is only required when recovering from a disk failure.
Quoted 5 lines
I am unsure about your meaning.
Assuming you perform an unclean shutdown (eg. crash), and after restart perform a scrub, with no additional error (bad sector, bit-rot) before or after the crash:
will you loose data?
No, the parity blocks will be ignored and RAID5 will act like slow RAID0 if no other errors occur.
Quoted 1 line
Will you be able to mount the filesystem like normal?
Yes.
Quoted 2 lines
Additionaly, will the crash create additional errors like bad sectors and or bit-rot aside from the parity-block corruption?
No, only parity-block corruptions should occur.
Quoted 2 lines
Its actually part of my first mail, where the btrfs Raid5/6 page assumes no data damage while the spinics comment implies the opposite.
The above assumes no drive failures or data corruption; however, if this were the case, you could use RAID0 instead of RAID5.
The only reason to use RAID5 is to handle cases where at least one block (or an entire disk) fails, so the behavior of RAID5 when all disks are working is almost irrelevant.
A drive failure could occur at any time, so even if you mount successfully, if a disk fails immediately after, any stripes affected by write hole will be unrecoverably corrupted.
Quoted 3 lines
The write hole does not seem as dangerous if you could simply scrub to repair damage (On smaller discs that is, where scrub doesnt take enough time for additional errors to occur)
Scrub can repair parity damage on normal data and metadata--it recomputes parity from data if the data passes a CRC check.
No repair is possible for data in nodatasum files--the parity can be recomputed, but there is no way to determine if the result is correct.
Metadata is always checksummed and transid verified; alas, there isn't an easy way to get btrfs to perform an urgent scrub on metadata only.
Quoted 7 lines
Quoted 5 lines
Put another way: if all disks are online then RAID5/6 behaves like a slow RAID0, and RAID0 does not have the partial stripe update problem because all of the data blocks in RAID0 are independent. It is only when a disk fails in RAID5/6 that the parity block is combined with data blocks, so it is only in this case that the write hole bug can result in lost data.
So data will not be lost if no drive has failed?
Correct, but the array will have reduced failure tolerance, and RAID5 only matters when a drive has failed. It is effectively operating in degraded mode on parts of the array affected by write hole, and no single disk failure can be tolerated there.
It is possible to recover the parity by performing an immediate scrub after reboot, but this cannot be as effective as a proper RAID5 update journal which avoids making the parity bad in the first place.
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
If the filesystem is -draid5 -mraid1 then the metadata is not vulnerable to the write hole, but data is. In this configuration you can determine with high confidence which files you need to restore from backup, and the filesystem will remain writable to replace the restored data, because raid1 does not have the write hole bug.
In regards to my earlier questions, what would change if i do -draid5 -mraid1?
Metadata would be using RAID1 which is not subject to the RAID5 write hole issue. It is much more tolerant of unclean shutdowns especially in degraded mode.
Data in RAID5 may be damaged when the array is in degraded mode and a write hole occurs (in either order as long as both occur). Due to RAID1 metadata, the filesystem will continue to operate properly, allowing the damaged data to be overwritten or deleted.
Quoted 6 lines
Lost Writes:
Quoted 2 lines
Hotplugging causes an effect (lost writes) which can behave similarly to the write hole bug in some instances. The similarity ends there.
Are we speaking about the same problem that is causing transid mismatch?
Transid mismatch is usually caused by lost writes, by any mechanism that prevents a write from being completed after the disk reports that it was completed.
Drives may report that data is "in stable storage", i.e. the drive believes it can complete the write in the future even if power is lost now because the drive or controller has capacitors or NVRAM or similar. If the drive is reset by the SATA host because of a cable disconnect event, the drive may forget that it has promised to do writes in the future. Drives may simply lie, and claim that data has been written to disk when the data is actually in volatile RAM and will disappear in a power failure.
btrfs uses a transaction mechanism and CoW metadata to handle lost writes within an interrupted transaction. Incomplete data is simply discarded on next mount. A transid mismatch is caused by a write that was lost _after_ the transaction commit write is reported completed by the disk firmware.
Transid mismatch is a serious problem as it means that disks or other lower layers of the storage stack are injecting errors and violating the data integrity requirements of the filesystem. It is worse than a csum error as csum errors are usually caused by random media faults (with low correlated failure probability) while transid mismatches are usually caused by firmware or controller problems (with high correlated failure probability). If you have multiple identical disks and the transid mismatches are caused by a firmware bug, then each identical disk may inject an identical error causing unrecoverable filesystem errors.
Quoted 6 lines
Quoted 4 lines
They are really two distinct categories of problem. Temporary connection loss can do bad things to all RAID profiles on btrfs (not just RAID5/6) and the btrfs requirements for handling connection loss and write holes are very different.
What kind of bad things? Will scrub (1/10, 5/6) detect and repair it?
Scrub does not handle all the cases. Scrub relies on CRC to detect data errors, which causes two problems: scrub cannot handle nodatasum files because those have no CRC, and CRC32 has a non-zero false acceptance rate.
Lost writes should be fixed by performing a replace operation on the disconnected disk (i.e. it should be treated like the drive failed and was replaced with a new blank disk). The replace operation informs btrfs which version of a nodatasum file it can consider to be correct (i.e. the one stored on disks that did not disconnect). Scrub can only detect that two copies of a nodatasum file are different, it has no way to choose one.
Mature RAID implementations like mdadm have optimizations for this case that rebuild only areas of the disk that were modified just before disconnection. btrfs has no such optimization so it can only replace the entire disk at once.
Quoted 10 lines
Quoted 8 lines
Quoted 2 lines
Quoted 2 lines
Hot-unplugging a device can cause many lost write events at once, and each lost write event is very bad.
Transid mismatch is btrfs detecting data
that was previously silently corrupted by some component outside of btrfs.btrfs can't prevent disks from silently corrupting data. It can only try to detect and repair the damage after the damage has occurred.
Aside from the chance that all copies of data are corrupted, is there any way scrubbing could fail?
There is a small chance of undetected errors due to the limitations of CRC32.
Quoted 9 lines
Quoted 6 lines
Normally RAID1/5/6/10 or DUP profiles are used for btrfs metadata, so any transid mismatches can be recovered by reading up-to-date data from the other mirror copy of the metadata, or by reconstructing the data with parity blocks in the RAID 5/6 case. It is only after this recovery mechanism fails (i.e. too many disks have a failure or corruption at the same time on the same sectors) that the filesystem is ended.
Does this mean that transid mismatch is harmless unless both copys are hit at once (And in case of Raid 6 all three)?
It's not entirely harmless because it is a form of data corruption error. A disk failure could occur before the corrupted data is recovered, and should that occur it would be a multiple failure that breaks the filesystem.
If you find that a disk in your array produces multiple transid failures, you should treat it like any other failing disk, and replace it immediately to avoid risk of future data loss.
Quoted 8 lines
Old hardware:
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
It's fun and/or scary to put known good and bad hardware in the same RAID1 array and watch btrfs autocorrecting the bad data after every other power failure; however, the bad hardware is clearly not sufficient to implement any sort of reliable data persistence, and arrays with bad hardware in them will eventually fail.
Quoted 6 lines
I am having a hard time wrapping my head around this statement. If Btrfs can repair corrupted data and Raid 6 allows two disc failures at once without data loss, is using old discs even with high average error count not still pretty much safe?
You would simply have to repeat the scrubbing process more often to make sure that not enough data is corrupted to break redundancy.
Old disks and disks that have bad firmware behave differently. An old disk fails in multiple random and unpredictable ways, while a disk with bad firwmare always fails the same way every time (until it eventually becomes an old disk, and starts failing in random ways as well).
This kind of array has an elevated probability of failure and is not "safe". A small error rate is enough to make the probability of concurrent failure so high that you would not be able to scrub often enough even if you were running scrubs continuously.
Such devices should only be used for development and testing of failure recovery algorithms.
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
I have one test case where I write millions of errors into a raid5/6 and the filesystem recovers every single one transparently while verifying SHA1 hashes of test data. After years of rebuilding busted ext3 on mdadm-raid5 filesystems, watching btrfs do it all automatically is just...beautiful.
Once again, if Btrfs is THIS good at repairing data, then is old hardware,
I make arrays that combine hardware of different ages. The failure rates increase as hardware ages, so you don't want an array of all old drives. e.g. in a 5-disk array replace the oldest disk every year.
Once disks have been in service for many years, they become very fragile and can be broken by simply turning them sideways. You can have at most one such disk in a RAID5 array (or two in RAID6, but that seems unnecessarily risky).
Quoted 4 lines
hotplugging and maybe even (depending on whether i understood your point) write hole really dangerous? Are there bugs that could destroy the data or filesystem whitout corrupting all copies of data (Or all copies at once)?
There are always bugs, but they get harder and harder to trigger over time. At some point the probability of hitting a kernel bug becomes lower than the probability of failures due to other causes, at which point improving the reliability of the software has no further impact on the reliability of the overall system.
Are there still bugs? Probably, but except for write hole they are getting harder to hit. Which will happen first: you hit one of of the bugs, or you get a bad batch of drives that all fail in the same hour, or your RAM goes bad and corrupts everything your CPU touches?
Quoted 2 lines
Assuming Raid 6, corrupted data would not
break redundancy and repeated scrubbing would fix any upcoming issue.
If a drive is allowed to continually inject small errors into the array, it introduces a higher risk of data loss over time than if that drive is immediately replaced with a properly functioning unit. You can never make the failure rate zero, but you can keep it as low as possible by proactively eliminating misbehaving hardware.
If a drive is replaced with all disks online and reasonably healthy then btrfs can recover data from read errors that occur during replacement. If you wait for a drive to fail completely before replacement, the replaced disk will be reconstructed while the array is in degraded mode, and any other errors that occur during that process are not recoverable.
Old disks can also do nasty things, e.g. run 99% slower than normal, or lock up the IO bus during read errors. These events may not corrupt any data, but an unexpected watchdog reboot or random performance issues can still ruin your day.
Quoted 3 lines
-------------------------------------------------------------------------------------------------
FreeMail powered by mail.de - MEHR SICHERHEIT, SERIOSITÄT UND KOMFORT
I guess that covers most topics, two last questions:
Will the write hole behave differently on Raid 6 compared to Raid 5 ? Is there any benefit of running Raid 5 Metadata compared to Raid 1 ?
-------------------------------------------------------------------------------------------------
FreeMail powered by mail.de - MEHR SICHERHEIT, SERIOSITÄT UND KOMFORT
Quoted 3 lines · On Sat, Aug 11, 2018 at 08:27:04AM +0200, [email protected] wrote:
I guess that covers most topics, two last questions:
Will the write hole behave differently on Raid 6 compared to Raid 5 ?
Not really. It changes the probability distribution (you get an extra chance to recover using a parity block in some cases), but there are still cases where data gets lost that didn't need to be.
Quoted 1 line
Is there any benefit of running Raid 5 Metadata compared to Raid 1 ?
There may be benefits of raid5 metadata, but they are small compared to the risks.
In some configurations it may not be possible to allocate the last gigabyte of space. raid1 will allocate 1GB chunks from 2 disks at a time while raid5 will allocate 1GB chunks from N disks at a time, and if N is an odd number there could be one chunk left over in the array that is unusable. Most users will find this irrelevant because a large disk array that is filled to the last GB will become quite slow due to long free space search and seek times--you really want to keep usage below 95%, maybe 98% at most, and that means the last GB will never be needed.
Reading raid5 metadata could theoretically be faster than raid1, but that depends on a lot of variables, so you can't assume it as a rule of thumb.
Raid6 metadata is more interesting because it's the only currently supported way to get 2-disk failure tolerance in btrfs. Unfortunately that benefit is rather limited due to the write hole bug.
There are patches floating around that implement multi-disk raid1 (i.e. 3 or 4 mirror copies instead of just 2). This would be much better for metadata than raid6--more flexible, more robust, and my guess is that it will be faster as well (no need for RMW updates or journal seeks).
Quoted 3 lines
-------------------------------------------------------------------------------------------------
FreeMail powered by mail.de - MEHR SICHERHEIT, SERIOSITÄT UND KOMFORT
Hi
I have a BTRFS RAID5 array built on 5x8TB HDD filled with, well :), there are contradicting opinions by the, well, "several" ways to check the used space on a BTRFS RAID5 array, but I should be aroud 8TB of data.
This array is running on kernel 4.17.3 and it definitely experienced power loss while data was being written.
I can say that it wen through at least a dozen of unclear shutdown So following this thread I started my first scrub on the array. and this is the outcome (after having resumed it 4 times, two after a power loss...):
menion@Menionubuntu:~$ sudo btrfs scrub status /media/storage/das1/
scrub status for 931d40c6-7cd7-46f3-a4bf-61f3a53844bc
scrub resumed at Sun Aug 12 18:43:31 2018 and finished after 55:06:35
total bytes scrubbed: 2.59TiB with 0 errorsSo, there are 0 errors, but I don't understand why it says 2.59TiB of scrubbed data. Is it possible that also this values is crap, as the non zero counters for RAID5 array?
Il giorno sab 11 ago 2018 alle ore 17:29 Zygo Blaxell <[email protected]> ha scritto:
Quoted 39 lines · On Sat, Aug 11, 2018 at 08:27:04AM +0200, [email protected] wrote:
Quoted 3 lines
I guess that covers most topics, two last questions:
Will the write hole behave differently on Raid 6 compared to Raid 5 ?
Not really. It changes the probability distribution (you get an extra chance to recover using a parity block in some cases), but there are still cases where data gets lost that didn't need to be.
Quoted 1 line
Is there any benefit of running Raid 5 Metadata compared to Raid 1 ?
There may be benefits of raid5 metadata, but they are small compared to the risks.
In some configurations it may not be possible to allocate the last gigabyte of space. raid1 will allocate 1GB chunks from 2 disks at a time while raid5 will allocate 1GB chunks from N disks at a time, and if N is an odd number there could be one chunk left over in the array that is unusable. Most users will find this irrelevant because a large disk array that is filled to the last GB will become quite slow due to long free space search and seek times--you really want to keep usage below 95%, maybe 98% at most, and that means the last GB will never be needed.
Reading raid5 metadata could theoretically be faster than raid1, but that depends on a lot of variables, so you can't assume it as a rule of thumb.
Raid6 metadata is more interesting because it's the only currently supported way to get 2-disk failure tolerance in btrfs. Unfortunately that benefit is rather limited due to the write hole bug.
There are patches floating around that implement multi-disk raid1 (i.e. 3 or 4 mirror copies instead of just 2). This would be much better for metadata than raid6--more flexible, more robust, and my guess is that it will be faster as well (no need for RMW updates or journal seeks).
Quoted 3 lines
-------------------------------------------------------------------------------------------------
FreeMail powered by mail.de - MEHR SICHERHEIT, SERIOSITÄT UND KOMFORT
Quoted 12 lines · Menion
Hi
I have a BTRFS RAID5 array built on 5x8TB HDD filled with, well :), there are contradicting opinions by the, well, "several" ways to check the used space on a BTRFS RAID5 array, but I should be aroud 8TB of data.
This array is running on kernel 4.17.3 and it definitely experienced power loss while data was being written.
I can say that it wen through at least a dozen of unclear shutdown So following this thread I started my first scrub on the array. and this is the outcome (after having resumed it 4 times, two after a power loss...):
Quoted 8 lines
menion@Menionubuntu:~$ sudo btrfs scrub status /media/storage/das1/ scrub status for 931d40c6-7cd7-46f3-a4bf-61f3a53844bc scrub resumed at Sun Aug 12 18:43:31 2018 and finished after 55:06:35 total bytes scrubbed: 2.59TiB with 0 errorsSo, there are 0 errors, but I don't understand why it says 2.59TiB of scrubbed data. Is it possible that also this values is crap, as the non zero counters for RAID5 array?
I just tested a quick scrub with injected errors on 4.18.0 and it looks like the garbage values are finally fixed (yay!).
I never saw invalid values for 'total bytes' from raid5; however, scrub has (had?) trouble resuming, especially if the system was rebooted between cancel and resume, but sometimes just if the scrub had just been suspended too long (maybe if there are changes to the chunk tree...?).
55 hours for 2600 GB is just under 50GB per hour, which doesn't sound too unreasonable for btrfs, though it is known to be a bit slow compared to other raid5 implementations.
Quoted 42 lines
Il giorno sab 11 ago 2018 alle ore 17:29 Zygo Blaxell <[email protected]> ha scritto:
Quoted 39 lines · On Sat, Aug 11, 2018 at 08:27:04AM +0200, [email protected] wrote:
Quoted 3 lines
I guess that covers most topics, two last questions:
Will the write hole behave differently on Raid 6 compared to Raid 5 ?
Not really. It changes the probability distribution (you get an extra chance to recover using a parity block in some cases), but there are still cases where data gets lost that didn't need to be.
Quoted 1 line
Is there any benefit of running Raid 5 Metadata compared to Raid 1 ?
There may be benefits of raid5 metadata, but they are small compared to the risks.
In some configurations it may not be possible to allocate the last gigabyte of space. raid1 will allocate 1GB chunks from 2 disks at a time while raid5 will allocate 1GB chunks from N disks at a time, and if N is an odd number there could be one chunk left over in the array that is unusable. Most users will find this irrelevant because a large disk array that is filled to the last GB will become quite slow due to long free space search and seek times--you really want to keep usage below 95%, maybe 98% at most, and that means the last GB will never be needed.
Reading raid5 metadata could theoretically be faster than raid1, but that depends on a lot of variables, so you can't assume it as a rule of thumb.
Raid6 metadata is more interesting because it's the only currently supported way to get 2-disk failure tolerance in btrfs. Unfortunately that benefit is rather limited due to the write hole bug.
There are patches floating around that implement multi-disk raid1 (i.e. 3 or 4 mirror copies instead of just 2). This would be much better for metadata than raid6--more flexible, more robust, and my guess is that it will be faster as well (no need for RMW updates or journal seeks).
Quoted 3 lines
-------------------------------------------------------------------------------------------------
FreeMail powered by mail.de - MEHR SICHERHEIT, SERIOSITÄT UND KOMFORT