ext2/3: document conditions when reliable operation is possible
Re: [patch] document flash/RAID dangers
In reply to Theodore TsoQuoted 13 lines · Theodore Tso
Quoted 11 lines · Ric Wheeler
Quoted 8 lines
Drive in raid 5 failed; hot spare was available (no idea about UPS). System apparently locked up trying to talk to the failed drive, or maybe admin just was not patient enough, so he just powercycled the array. He lost the array.
So while most people will not agressively powercycle the RAID array, drive failure still provokes little tested error paths, and getting unclean shutdown is quite easy in such case.
Then what we need to document is do not power cycle an array during a rebuild, right?
Quoted 6 lines
Well, the softwar raid layer could be improved so that it implements scrubbing by default (i.e., have the md package install a cron job to implement a periodict scrub pass automatically). The MD code could also regularly check to make sure the hot spare is OK; the other possibility is that hot spare, which hadn't been used in a long time, had silently failed.
Actually, MD does this scan already (not automatically, but you can set up a simple cron job to kick off a periodic "check"). It is a delicate balance to get the frequency of the scrubbing correct.
On one hand, you want to make sure that you detect errors in a timely fashion, certainly detection of single sector errors before you might develop a second sector level error on another drive.
On the other hand, running scans/scrubs continually impacts the performance of your real workload and can potentially impact your components' life span by subjecting them to a heavy workload.
Rule of thumb seems from my experience is that most people settle in with a scan once a week or two (done at a throttled rate).
Quoted 7 lines
Quoted 6 lines
In the end, there are cascading failures that will defeat any data protection scheme, but that does not mean that the value of that scheme is zero. We need to be get more people to use RAID (including MD5) and try to enhance it as we go. Just using a single disk is not a good thing...
Quoted 6 lines
Yep; the solution is to improve the storage devices. It is *not* to encourage people to think RAID is not worth it, or that somehow ext2 is better than ext3 because it runs fsck's all the time at boot up. That's just crazy talk.
- Ted
Agreed....
ric
Re: [patch] document flash/RAID dangers
In reply to Theodore TsoQuoted 13 lines · Theodore Tso
Quoted 11 lines · Ric Wheeler
Quoted 8 lines
Drive in raid 5 failed; hot spare was available (no idea about UPS). System apparently locked up trying to talk to the failed drive, or maybe admin just was not patient enough, so he just powercycled the array. He lost the array.
So while most people will not agressively powercycle the RAID array, drive failure still provokes little tested error paths, and getting unclean shutdown is quite easy in such case.
Then what we need to document is do not power cycle an array during a rebuild, right?
Quoted 6 lines
Well, the softwar raid layer could be improved so that it implements scrubbing by default (i.e., have the md package install a cron job to implement a periodict scrub pass automatically). The MD code could also regularly check to make sure the hot spare is OK; the other possibility is that hot spare, which hadn't been used in a long time, had silently failed.
Actually, MD does this scan already (not automatically, but you can set up a simple cron job to kick off a periodic "check"). It is a delicate balance to get the frequency of the scrubbing correct.
On one hand, you want to make sure that you detect errors in a timely fashion, certainly detection of single sector errors before you might develop a second sector level error on another drive.
On the other hand, running scans/scrubs continually impacts the performance of your real workload and can potentially impact your components' life span by subjecting them to a heavy workload.
Rule of thumb seems from my experience is that most people settle in with a scan once a week or two (done at a throttled rate).
Quoted 7 lines
Quoted 6 lines
In the end, there are cascading failures that will defeat any data protection scheme, but that does not mean that the value of that scheme is zero. We need to be get more people to use RAID (including MD5) and try to enhance it as we go. Just using a single disk is not a good thing...
Quoted 6 lines
Yep; the solution is to improve the storage devices. It is *not* to encourage people to think RAID is not worth it, or that somehow ext2 is better than ext3 because it runs fsck's all the time at boot up. That's just crazy talk.
- Ted
Agreed....
ric
Re: [patch] document flash/RAID dangers
Quoted 14 lines · Ric Wheeler
Quoted 13 lines · Theodore Tso
Quoted 11 lines · Ric Wheeler
Quoted 8 lines
Drive in raid 5 failed; hot spare was available (no idea about UPS). System apparently locked up trying to talk to the failed drive, or maybe admin just was not patient enough, so he just powercycled the array. He lost the array.
So while most people will not agressively powercycle the RAID array, drive failure still provokes little tested error paths, and getting unclean shutdown is quite easy in such case.
Then what we need to document is do not power cycle an array during a rebuild, right?
Quoted 8 lines
Quoted 6 lines
Well, the softwar raid layer could be improved so that it implements scrubbing by default (i.e., have the md package install a cron job to implement a periodict scrub pass automatically). The MD code could also regularly check to make sure the hot spare is OK; the other possibility is that hot spare, which hadn't been used in a long time, had silently failed.
Actually, MD does this scan already (not automatically, but you can set up a simple cron job to kick off a periodic "check"). It is a delicate balance to get the frequency of the scrubbing correct.
debian defaults to doing this once a month (first sunday of each month), on some of my systems this scrub takes almost a week to complete.
David Lang
Re: [patch] document flash/RAID dangers
In reply to Theodore TsoQuoted 3 lines · Theodore Tso
Well, the softwar raid layer could be improved so that it implements scrubbing by default (i.e., have the md package install a cron job to implement a periodict scrub pass automatically).
Fedora 11 added a cron job to kick off a RAID check for each Linux MD RAID array every week. Combined with running mdmonitor, root will get an email on any failure.
The other thing about this thread is that the only RAID implementation that is being discussed here is the MD RAID stack. There are a lot of RAID implementations that have the same issues:
- motherboard (aka "fake") RAID - In Linux this is typically mapped with device mapper via dmraid; AFAIK there is not a tool to scrub (or even monitor the status of and notify on failure) a Linux DM RAID setup.
- hardware RAID cards without battery backup - these have the exact same issues because they cannot guarantee all writes complete, nor can they keep track of incomplete writes across power failures
- hardware RAID cards _with_ battery backup but that don't periodically test the battery and have a way to notify you of battery failure while Linux is running
The issues being raised here are not specific to extX, MD RAID, or Linux at all; they are problems with non-"enterprise-class" RAID setups. There's a reason enterprise-class RAID costs a lot more money than the card you can pick up at Fry's.
There's no reason to document the design issues of general RAID implementations in the Linux kernel.
Signature · 3 lines
Chris Adams <[email protected]> Systems and Network Administrator - HiWAAY Internet Services I don't speak for anybody but myself - that's enough trouble.
Re: [patch] document flash/RAID dangers
Quoted 4 lines
The issues being raised here are not specific to extX, MD RAID, or Linux at all; they are problems with non-"enterprise-class" RAID setups. There's a reason enterprise-class RAID costs a lot more money than the card you can pick up at Fry's.
And you will still need backups ;)
A long time ago I worked on a fault tolerant news server with dual alphaserver boxes and a shared disk array. A power system failure took out both the alpha boxes and the disk controllers and all the disks.
Fortunately it was a news server so you just had to wait a week ..
Alan
Re: [patch] document flash/RAID dangers
Quoted 6 lines · Alan Cox
Quoted 4 lines
The issues being raised here are not specific to extX, MD RAID, or Linux at all; they are problems with non-"enterprise-class" RAID setups. There's a reason enterprise-class RAID costs a lot more money than the card you can pick up at Fry's.
And you will still need backups ;)
Yep. RAID (of any class) != fail safe.
Quoted 3 lines
A long time ago I worked on a fault tolerant news server with dual alphaserver boxes and a shared disk array. A power system failure took out both the alpha boxes and the disk controllers and all the disks.
Hey, that's not funny! I'm typing this on a dual AlphaServer cluster with a shared disk array (with dual battery backup even), and we had a power failure at the NOC yesterday (that then tripped a breaker, although it was between the generator and the UPS, so nothing went down).
No matter how redundant you make things, a "no single point of failure" setup still can fail, often in "interesting" ways that nobody anticipated.
Signature · 3 lines
Chris Adams <[email protected]> Systems and Network Administrator - HiWAAY Internet Services I don't speak for anybody but myself - that's enough trouble.
Re: [patch] document flash/RAID dangers
In reply to Chris AdamsHi!
Quoted 16 lines
The other thing about this thread is that the only RAID implementation that is being discussed here is the MD RAID stack. There are a lot of RAID implementations that have the same issues:
- motherboard (aka "fake") RAID - In Linux this is typically mapped with device mapper via dmraid; AFAIK there is not a tool to scrub (or even monitor the status of and notify on failure) a Linux DM RAID setup.
- hardware RAID cards without battery backup - these have the exact same issues because they cannot guarantee all writes complete, nor can they keep track of incomplete writes across power failures
- hardware RAID cards _with_ battery backup but that don't periodically test the battery and have a way to notify you of battery failure while Linux is running
Quoted 7 lines
The issues being raised here are not specific to extX, MD RAID, or Linux at all; they are problems with non-"enterprise-class" RAID setups. There's a reason enterprise-class RAID costs a lot more money than the card you can pick up at Fry's.
There's no reason to document the design issues of general RAID implementations in the Linux kernel.
Even when we carry one of those misdesigned implementations in-tree? (Note that fixed implementations do exist -- AIX? -- just add journal).
'I wont't tell you that this pony bites, because many ponies do bite'?
WTF? I thought we had higher moral standard than this.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [patch] document flash/RAID dangers
In reply to Ric WheelerQuoted 7 lines
Quoted 7 lines
Example I seen went like this:
Drive in raid 5 failed; hot spare was available (no idea about UPS). System apparently locked up trying to talk to the failed drive, or maybe admin just was not patient enough, so he just powercycled the array. He lost the array.
Quoted 6 lines
Quoted 3 lines
So while most people will not agressively powercycle the RAID array, drive failure still provokes little tested error paths, and getting unclean shutdown is quite easy in such case.
Then what we need to document is do not power cycle an array during a rebuild, right?
Yep, that and the fact that you should fsck if you do.
Quoted 3 lines
If it wasn't the admin that timed out and the box really was hung (no drive activity lights, etc), you will need to power cycle/reboot but then you should not have this active rebuild issuing writes either...
Ok, I guess you are right here.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [patch] document flash/RAID dangers
In reply to Pavel MachekQuoted 7 lines · Pavel Machek
Look, I don't need full drive failure for this to happen. I can just remove one disk from array. I don't need power failure, I can just press the power button. I don't even need to rebuild anything, I can just write to degraded array.
Given that all events are under my control, statistics make little sense here.
I recommend a sledgehammer.
If you want to lose your data, you might as well have some fun.
No need to bore yourself to tears by simulating events that are unlikely to happen simultaneously to careful system administrators.
Signature · 1 line
All rights reversed.
Re: [patch] document flash/RAID dangers
Quoted 10 lines · Rik van Riel
Quoted 7 lines · Pavel Machek
Look, I don't need full drive failure for this to happen. I can just remove one disk from array. I don't need power failure, I can just press the power button. I don't even need to rebuild anything, I can just write to degraded array.
Given that all events are under my control, statistics make little sense here.
Quoted 6 lines
I recommend a sledgehammer.
If you want to lose your data, you might as well have some fun.
No need to bore yourself to tears by simulating events that are unlikely to happen simultaneously to careful system administrators.
Sledgehammer is hardware problem, and I'm demonstrating software/documentation problem we have here.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [patch] document flash/RAID dangers
Quoted 2 lines · Pavel Machek
Sledgehammer is hardware problem, and I'm demonstrating software/documentation problem we have here.
So your argument is that a sledgehammer is a hardware problem, while a broken hard disk and a power failure are software/documentation issues?
I'd argue that the broken hard disk and power failure are hardware issues, too.
Signature · 1 line
All rights reversed.
Re: [patch] document flash/RAID dangers
Quoted 11 lines · Rik van Riel
Quoted 2 lines · Pavel Machek
Sledgehammer is hardware problem, and I'm demonstrating software/documentation problem we have here.
So your argument is that a sledgehammer is a hardware problem, while a broken hard disk and a power failure are software/documentation issues?
I'd argue that the broken hard disk and power failure are hardware issues, too.
Noone told me that degraded md raid5 is dangerous. Thats documentation issue #1. Maybe I just pulled the disk for fun.
ext3 docs told me that journal protects me against fs corruption during power fails. It does not in this particular case. Seems like docs issue #2. Maybe I just hit the reset button because it was there.
Randomly hitting power button may be stupid, but should not result in filesystem corruption on reasonably working filesystem/storage stack.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [patch] document flash/RAID dangers
Quoted 9 lines · Pavel Machek
Quoted 8 lines · Rik van Riel
Quoted 2 lines · Pavel Machek
Sledgehammer is hardware problem, and I'm demonstrating software/documentation problem we have here.
So your argument is that a sledgehammer is a hardware problem, while a broken hard disk and a power failure are software/documentation issues?
Quoted 5 lines
Quoted 2 lines
I'd argue that the broken hard disk and power failure are hardware issues, too.
Noone told me that degraded md raid5 is dangerous. Thats documentation issue #1. Maybe I just pulled the disk for fun.
You're kidding, right?
Or are you being too effectively sarcastic?
Signature · 2 lines
Obsession with "preserving cultural heritage" is a racist impediment to moral, physical and intellectual progress.
Re: [patch] document flash/RAID dangers
Quoted 5 lines · Ron Johnson
Quoted 2 lines · Pavel Machek
Noone told me that degraded md raid5 is dangerous. Thats documentation issue #1. Maybe I just pulled the disk for fun.
You're kidding, right?
No he is not... and that is exactly why Ted and Ric have been fighting so hard against his scare the children documentation.
In 20 years, I have not found a way to educate those who think "I know computers so it must work the way I want and expect."
Tremendous amounts of information and recommendations are out there on the web, in books, classes, etc. But people don't research before using or understand before they have a problem.
Quoted 2 lines · Pavel Machek
It is not only for system administrators; I was trying to find out if kernel is buggy, and that should be in kernel tree.
Pavel, *THE KERNEL IS NOT BUGGY* end of story!
Everyone experienced in storage understands the "in the edge case that Pavel hit, you will loose your data", and we take our responsibility to tell people what works and does not work very seriously. And we try very hard to reduce the amount of edge case data losses.
But as Ric and Ted and many others keep trying to explain:
- There is no such thing as "never fails" data storage.
- The goal of journal file systems is not what you thing.
- The goal of raid is not what you think.
- We do not want the vast majority of computer users who are not kernel engineers to stop using the technology that in 99.99 percent of the use cases keeps their data as safe as we can reasonably make it, just because they read Pavel's 0.01 percent scary and inaccurate case.
And the worst part is this 0.01 percent case problem is really "I did not know what I was doing".
jim
Re: [patch] document flash/RAID dangers
In reply to Pavel MachekQuoted 4 lines · Pavel Machek
There are storage devices that high highly undesirable properties when they are disconnected or suffer power failures while writes are in progress; such devices include flash devices and MD RAID 4/5/6 arrays.
change this to say 'degraded MD RAID 4/5/6 arrays'
also find out if DM RAID 4/5/6 arrays suffer the same problem (I strongly suspect that they do)
then you need to add a note that if the array becomes degraded before a scrub cycle happens previously hidden damage (that would have been repaired by the scrub) can surface.
Quoted 1 line
These devices have the property of potentially corrupting blocks being written at the time of the power failure,
this is true of all devices
Quoted 1 line
and worse yet, amplifying the region where blocks are corrupted such that additional sectors are also damaged during the power failure.
re-word this something like
In addition to the standard risk of corrupting the blocks being written at the time of the power failure, additonal blocks (in the same flash eraseblock or raid stripe) may also be corrupted.
Quoted 10 lines
Users who use such storage devices are well advised take countermeasures, such as the use of Uninterruptible Power Supplies, and making sure the flash device is not hot-unplugged while the device is being used. Regular backups when using these devices is also a Very Good Idea.
Otherwise, file systems placed on these devices can suffer silent data and file system corruption. An forced use of fsck may detect metadata corruption resulting in file system corruption, but will not suffice to detect data corruption.
David Lang
Re: [patch] document flash/RAID dangers
Quoted 11 lines · On Tue 2009-08-25 16:56:40, [email protected] wrote:
Quoted 4 lines · Pavel Machek
There are storage devices that high highly undesirable properties when they are disconnected or suffer power failures while writes are in progress; such devices include flash devices and MD RAID 4/5/6 arrays.
change this to say 'degraded MD RAID 4/5/6 arrays'
also find out if DM RAID 4/5/6 arrays suffer the same problem (I strongly suspect that they do)
I changed it to say MD/DM.
Quoted 3 lines
then you need to add a note that if the array becomes degraded before a scrub cycle happens previously hidden damage (that would have been repaired by the scrub) can surface.
I'd prefer not to talk about scrubing and such details here. Better leave warning here and point to MD documentation.
Quoted 4 lines
Quoted 2 lines
THESE devices have the property of potentially corrupting blocks being written at the time of the power failure,
this is true of all devices
Actually I don't think so. I believe SATA disks do not corrupt even the sector they are writing to -- they just have big enough capacitors. And yes I believe ext3 depends on that.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [patch] document flash/RAID dangers
Quoted 13 lines · Pavel Machek
Quoted 11 lines · On Tue 2009-08-25 16:56:40, [email protected] wrote:
Quoted 4 lines · Pavel Machek
There are storage devices that high highly undesirable properties when they are disconnected or suffer power failures while writes are in progress; such devices include flash devices and MD RAID 4/5/6 arrays.
change this to say 'degraded MD RAID 4/5/6 arrays'
also find out if DM RAID 4/5/6 arrays suffer the same problem (I strongly suspect that they do)
Quoted 8 lines
I changed it to say MD/DM.
Quoted 3 lines
then you need to add a note that if the array becomes degraded before a scrub cycle happens previously hidden damage (that would have been repaired by the scrub) can surface.
I'd prefer not to talk about scrubing and such details here. Better leave warning here and point to MD documentation.
I disagree with that, the way you are wording this makes it sound as if raid isn't worth it. if you are going to say that raid is risky you need to properly specify when it is risky
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
THESE devices have the property of potentially corrupting blocks being written at the time of the power failure,
this is true of all devices
Actually I don't think so. I believe SATA disks do not corrupt even the sector they are writing to -- they just have big enough capacitors. And yes I believe ext3 depends on that.
you are incorrect on this.
ext3 (like every other filesystem) just accepts the risk (zfs makes some attempt to detect such corruption)
David Lang
Re: [patch] document flash/RAID dangers
Quoted 21 lines · On Tue 2009-08-25 17:20:13, [email protected] wrote:
Quoted 19 lines · Pavel Machek
Quoted 11 lines · On Tue 2009-08-25 16:56:40, [email protected] wrote:
Quoted 4 lines · Pavel Machek
There are storage devices that high highly undesirable properties when they are disconnected or suffer power failures while writes are in progress; such devices include flash devices and MD RAID 4/5/6 arrays.
change this to say 'degraded MD RAID 4/5/6 arrays'
also find out if DM RAID 4/5/6 arrays suffer the same problem (I strongly suspect that they do)
I changed it to say MD/DM.
Quoted 3 lines
then you need to add a note that if the array becomes degraded before a scrub cycle happens previously hidden damage (that would have been repaired by the scrub) can surface.
Quoted 6 lines
Quoted 2 lines
I'd prefer not to talk about scrubing and such details here. Better leave warning here and point to MD documentation.
I disagree with that, the way you are wording this makes it sound as if raid isn't worth it. if you are going to say that raid is risky you need to properly specify when it is risky
Ok, would this help? I don't really want to go to scrubbing details.
(*) Degraded array or single disk failure "near" the powerfail is neccessary for this property of RAID arrays to bite.
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 2 lines
THESE devices have the property of potentially corrupting blocks being written at the time of the power failure,
this is true of all devices
Quoted 8 lines
Quoted 3 lines
Actually I don't think so. I believe SATA disks do not corrupt even the sector they are writing to -- they just have big enough capacitors. And yes I believe ext3 depends on that.
you are incorrect on this.
ext3 (like every other filesystem) just accepts the risk (zfs makes some attempt to detect such corruption)
I'd like Ted to comment on this. He wrote the original document, and I'd prefer not to introduce mistakes.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [patch] document flash/RAID dangers
Quoted 25 lines · Pavel Machek
Quoted 24 lines · On Tue 2009-08-25 17:20:13, [email protected] wrote:
Quoted 21 lines · Pavel Machek
Quoted 11 lines · On Tue 2009-08-25 16:56:40, [email protected] wrote:
Quoted 4 lines · Pavel Machek
There are storage devices that high highly undesirable properties when they are disconnected or suffer power failures while writes are in progress; such devices include flash devices and MD RAID 4/5/6 arrays.
change this to say 'degraded MD RAID 4/5/6 arrays'
also find out if DM RAID 4/5/6 arrays suffer the same problem (I strongly suspect that they do)
I changed it to say MD/DM.
Quoted 3 lines
then you need to add a note that if the array becomes degraded before a scrub cycle happens previously hidden damage (that would have been repaired by the scrub) can surface.
I'd prefer not to talk about scrubing and such details here. Better leave warning here and point to MD documentation.
Quoted 8 lines
Quoted 3 lines
I disagree with that, the way you are wording this makes it sound as if raid isn't worth it. if you are going to say that raid is risky you need to properly specify when it is risky
Ok, would this help? I don't really want to go to scrubbing details.
(*) Degraded array or single disk failure "near" the powerfail is neccessary for this property of RAID arrays to bite.
that sounds reasonable
David Lang
Re: [patch] document flash/RAID dangers
In reply to Pavel MachekQuoted 13 lines · Pavel Machek
Quoted 11 lines · On Tue 2009-08-25 16:56:40, [email protected] wrote:
Quoted 4 lines · Pavel Machek
There are storage devices that high highly undesirable properties when they are disconnected or suffer power failures while writes are in progress; such devices include flash devices and MD RAID 4/5/6 arrays.
change this to say 'degraded MD RAID 4/5/6 arrays'
also find out if DM RAID 4/5/6 arrays suffer the same problem (I strongly suspect that they do)
Quoted 8 lines
I changed it to say MD/DM.
Quoted 3 lines
then you need to add a note that if the array becomes degraded before a scrub cycle happens previously hidden damage (that would have been repaired by the scrub) can surface.
I'd prefer not to talk about scrubing and such details here. Better leave warning here and point to MD documentation.
Than you should punt the MD discussion to the MD documentation entirely.
I would suggest:
"Users of any file system that have a single media (SSD, flash or normal disk) can suffer from catastrophic and complete data loss if that single media fails. To reduce your exposure to data loss after a single point of failure, consider using either hardware or properly configured software RAID. See the documentation on MD RAID for how to configure it.
To insure proper fsync() semantics, you will need to have a storage device that supports write barriers or have a non-volatile write cache. If not, best practices dictate disabling the write cache on the storage device."
Quoted 10 lines
Quoted 5 lines
Quoted 3 lines
THESE devices have the property of potentially corrupting blocks being written at the time of the power failure,
this is true of all devices
Actually I don't think so. I believe SATA disks do not corrupt even the sector they are writing to -- they just have big enough capacitors. And yes I believe ext3 depends on that.
Pavel
Pavel, no S-ATA drive has capacitors to hold up during a power failure (or even enough power to destage their write cache). I know this from direct, personal knowledge having built RAID boxes at EMC for years. In fact, almost all RAID boxes require that the write cache be hardwired to off when used in their arrays.
Drives fail partially on a very common basis - look at your remapped sector count with smartctl.
RAID (including MD RAID5) will protect you from this most common error as it will protect you from complete drive failure which is also an extremely common event.
Your scenario is really, really rare - doing a full rebuild after a complete drive failure (takes a matter of hours, depends on the size of the disk) and having a power failure during that rebuild.
Of course adding a UPS to any storage system (including MD RAID system) helps make it more reliable, specifically in your scenario.
The more important point is that having any RAID (MD1, MD5 or MD6) will greatly reduce your chance of data loss if configured correctly. With ext3, ext2 or zfs.
Ric
Re: [patch] document flash/RAID dangers
Quoted 10 lines
Quoted 9 lines
Quoted 5 lines
Quoted 3 lines
THESE devices have the property of potentially corrupting blocks being written at the time of the power failure,
this is true of all devices
Actually I don't think so. I believe SATA disks do not corrupt even the sector they are writing to -- they just have big enough capacitors. And yes I believe ext3 depends on that.
Quoted 5 lines
Pavel, no S-ATA drive has capacitors to hold up during a power failure (or even enough power to destage their write cache). I know this from direct, personal knowledge having built RAID boxes at EMC for years. In fact, almost all RAID boxes require that the write cache be hardwired to off when used in their arrays.
I never claimed they have enough power to flush entire cache -- read the paragraph again. I do believe the disks have enough capacitors to finish writing single sector, and I do believe ext3 depends on that.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [patch] document flash/RAID dangers
Quoted 16 lines · Pavel Machek
Quoted 10 lines
Quoted 9 lines
Quoted 5 lines
Quoted 3 lines
THESE devices have the property of potentially corrupting blocks being written at the time of the power failure,
this is true of all devices
Actually I don't think so. I believe SATA disks do not corrupt even the sector they are writing to -- they just have big enough capacitors. And yes I believe ext3 depends on that.
Quoted 5 lines
Pavel, no S-ATA drive has capacitors to hold up during a power failure (or even enough power to destage their write cache). I know this from direct, personal knowledge having built RAID boxes at EMC for years. In fact, almost all RAID boxes require that the write cache be hardwired to off when used in their arrays.
Quoted 5 lines
I never claimed they have enough power to flush entire cache -- read the paragraph again. I do believe the disks have enough capacitors to finish writing single sector, and I do believe ext3 depends on that.
Pavel
Some scary terms that drive people mention (and measure):
"high fly writes"
"over powered seeks"
"adjacent tack erasure"
If you do get a partial track written, the data integrity bits that the data is embedded in will flag it as invalid and give you and IO error on the next read. Note that the damage is not persistent, it will get repaired (in place) on the next write to that sector.
Also it is worth noting that ext2/3/4 write file system "blocks" not single sectors. Each ext3 IO is 8 distinct disk sector writes and those can span tracks on a drive which require a seek which all consume power.
On power loss, a disk will immediately park the heads...
ric
Re: [patch] document flash/RAID dangers
In reply to Pavel MachekQuoted 15 lines · Pavel Machek
Quoted 9 lines
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
THESE devices have the property of potentially corrupting blocks being written at the time of the power failure,
this is true of all devices
Actually I don't think so. I believe SATA disks do not corrupt even the sector they are writing to -- they just have big enough capacitors. And yes I believe ext3 depends on that.
Quoted 5 lines
Pavel, no S-ATA drive has capacitors to hold up during a power failure (or even enough power to destage their write cache). I know this from direct, personal knowledge having built RAID boxes at EMC for years. In fact, almost all RAID boxes require that the write cache be hardwired to off when used in their arrays.
Quoted 3 lines
I never claimed they have enough power to flush entire cache -- read the paragraph again. I do believe the disks have enough capacitors to finish writing single sector, and I do believe ext3 depends on that.
keep in mind that in a powerfail situation the data being sent to the drive may be corrupt (the ram gets flaky while a DMA to the drive copies the bad data to the drive, which writes it before the power loss gets bad enough for the drive to decide there is a problem and shutdown)
you just plain cannot count on writes that are in flight when a powerfail happens to do predictable things, let alone what you consider sane or proper.
David Lang
Re: [patch] document flash/RAID dangers
Quoted 26 lines · On Tue 2009-08-25 18:19:40, [email protected] wrote:
Quoted 15 lines · Pavel Machek
Quoted 9 lines
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
THESE devices have the property of potentially corrupting blocks being written at the time of the power failure,
this is true of all devices
Actually I don't think so. I believe SATA disks do not corrupt even the sector they are writing to -- they just have big enough capacitors. And yes I believe ext3 depends on that.
Quoted 5 lines
Pavel, no S-ATA drive has capacitors to hold up during a power failure (or even enough power to destage their write cache). I know this from direct, personal knowledge having built RAID boxes at EMC for years. In fact, almost all RAID boxes require that the write cache be hardwired to off when used in their arrays.
Quoted 3 lines
I never claimed they have enough power to flush entire cache -- read the paragraph again. I do believe the disks have enough capacitors to finish writing single sector, and I do believe ext3 depends on that.
keep in mind that in a powerfail situation the data being sent to the drive may be corrupt (the ram gets flaky while a DMA to the drive copies the bad data to the drive, which writes it before the power loss gets bad enough for the drive to decide there is a problem and shutdown)
Quoted 5 lines
you just plain cannot count on writes that are in flight when a powerfail happens to do predictable things, let alone what you consider sane or proper.
From what I see, this kind of failure is rather harder to reproduce
than the software problems. And at least SGI machines were designed to avoid this...
Anyway, I'd like to hear from ext3 people... what happens on read errors in journal? That's what you'd expect to see in situation above.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [patch] document flash/RAID dangers
Quoted 10 lines · Pavel Machek
Quoted 3 lines
you just plain cannot count on writes that are in flight when a powerfail happens to do predictable things, let alone what you consider sane or proper.
From what I see, this kind of failure is rather harder to reproduce than the software problems. And at least SGI machines were designed to avoid this...
Anyway, I'd like to hear from ext3 people... what happens on read errors in journal? That's what you'd expect to see in situation above.
On a power failure, what normally happens is that the random garbage gets written into the disk drive's last dying gasp, since the memory starts going insane and sends garbage to the disk. So the disk successfully completes the write, but the sector contains garbage. Since HDD's tend to be last thing to die, being less sensitive to voltage drops than the memory or DMA controller, my experience is that you don't get a read error after the system comes up, you just get garbage written into the journal.
The ext3 journalling code waits until all of the journal code is written, and only then writes the commit block. On restart, we look for the last valid commit block. So if the power failure is before we write the commit block, we replay the journal up until the previous commit block. If the power failure is while we are writing the commit block, garbage will be written out instead of the commit block, and so it falls back to the previous case.
We do not allow any updates to the filesystem metadata to take place until the commit block has been written; therefore the filesystem stays consistent.
If there the journal *does* develop read errors, then fsck will require a manual fsck, and so the boot operation will get stopped so a system administrator can provide manual intervention. The best bet for the sysadmin is to replay as much of the journal she can, and then let fsck fix any resulting filesystem inconsistencies. In practice, though, I've not experienced or seen any reports of this happening from a power failure; usually it happens if the laptop gets dropped or the hard drive suffers or suffers some other kind of hardware failure.
- Ted
Re: [patch] document flash/RAID dangers
Quoted 29 lines · Theodore Tso
Quoted 10 lines · Pavel Machek
Quoted 3 lines
you just plain cannot count on writes that are in flight when a powerfail happens to do predictable things, let alone what you consider sane or proper.
From what I see, this kind of failure is rather harder to reproduce than the software problems. And at least SGI machines were designed to avoid this...
Anyway, I'd like to hear from ext3 people... what happens on read errors in journal? That's what you'd expect to see in situation above.
On a power failure, what normally happens is that the random garbage gets written into the disk drive's last dying gasp, since the memory starts going insane and sends garbage to the disk. So the disk successfully completes the write, but the sector contains garbage. Since HDD's tend to be last thing to die, being less sensitive to voltage drops than the memory or DMA controller, my experience is that you don't get a read error after the system comes up, you just get garbage written into the journal.
The ext3 journalling code waits until all of the journal code is written, and only then writes the commit block. On restart, we look for the last valid commit block. So if the power failure is before we write the commit block, we replay the journal up until the previous commit block. If the power failure is while we are writing the commit block, garbage will be written out instead of the commit block, and so it falls back to the previous case.
Quoted 3 lines
We do not allow any updates to the filesystem metadata to take place until the commit block has been written; therefore the filesystem stays consistent.
Ok, cool.
Quoted 5 lines
If there the journal *does* develop read errors, then fsck will require a manual fsck, and so the boot operation will get stopped so a system administrator can provide manual intervention. The best bet for the sysadmin is to replay as much of the journal she can, and then let fsck fix any resulting filesystem inconsistencies. In practice,
...and that should result in consistent fs with no data loss, because read error is essentialy the same as garbage given back, right?
...plus, this is significant difference from logical-logging filesystems, no?
Should this go to Documentation/, somewhere?
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [patch] document flash/RAID dangers
In reply to Theodore TsoQuoted 29 lines · Theodore Tso
Quoted 10 lines · Pavel Machek
Quoted 3 lines
you just plain cannot count on writes that are in flight when a powerfail happens to do predictable things, let alone what you consider sane or proper.
From what I see, this kind of failure is rather harder to reproduce than the software problems. And at least SGI machines were designed to avoid this...
Anyway, I'd like to hear from ext3 people... what happens on read errors in journal? That's what you'd expect to see in situation above.
On a power failure, what normally happens is that the random garbage gets written into the disk drive's last dying gasp, since the memory starts going insane and sends garbage to the disk. So the disk successfully completes the write, but the sector contains garbage. Since HDD's tend to be last thing to die, being less sensitive to voltage drops than the memory or DMA controller, my experience is that you don't get a read error after the system comes up, you just get garbage written into the journal.
The ext3 journalling code waits until all of the journal code is written, and only then writes the commit block. On restart, we look for the last valid commit block. So if the power failure is before we write the commit block, we replay the journal up until the previous commit block. If the power failure is while we are writing the commit block, garbage will be written out instead of the commit block, and so it falls back to the previous case.
Quoted 3 lines
We do not allow any updates to the filesystem metadata to take place until the commit block has been written; therefore the filesystem stays consistent.
Ok, cool.
Quoted 5 lines
If there the journal *does* develop read errors, then fsck will require a manual fsck, and so the boot operation will get stopped so a system administrator can provide manual intervention. The best bet for the sysadmin is to replay as much of the journal she can, and then let fsck fix any resulting filesystem inconsistencies. In practice,
...and that should result in consistent fs with no data loss, because read error is essentialy the same as garbage given back, right?
...plus, this is significant difference from logical-logging filesystems, no?
Should this go to Documentation/, somewhere?
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [patch] document flash/RAID dangers
In reply to Pavel MachekQuoted 6 lines · Pavel Machek
Lets say you are writing to the (healthy) RAID5 and have a powerfail.
So now data blocks do not correspond to the parity block. You don't yet have the corruption, but you already have a problem.
If you get a disk failing at this point, you'll get corruption.
Not necessarily. Say you wrote out the entire stripe in a 5 disk RAID 5 array, but only 3 data blocks and the parity block got written out before power failure.
If the disk with the 4th (unwritten) data block were to fail and get taken out of the RAID 5 array, the degradation of the array could actually undo your data corruption.
With RAID 5 and incomplete writes, you just don't know.
This kind of thing could go wrong at any level in the system, with any kind of RAID 5 setup.
Of course, on a single disk system without RAID you can still get incomplete writes, for the exact same reasons.
RAID 5 does not make things worse. It will protect your data against certain failure modes, but not against others.
With or without RAID, you still need to make backups.
Signature · 1 line
All rights reversed.
PATCH 1/1 document that ext2 can't handle barriers
In reply to Theodore TsoDocument things ext2 expects from storage filesystems, and the fact that it can not handle barriers. Also remove jounaling description, as that's really ext3 material.
Documentation/filesystems/ext2.txt +9 -10
@@ -338,27 +339,17 @@ enough 4-character names to make up unique directory entries, so they have to be 8 character filenames, even then we are fairly close to running out of unique filenames. +Requirements +============ + +Ext2 expects disk/storage subsystem not to return write errors. + +It also needs write caching to be disabled for reliable fsync +operation; ext2 does not know how to issue barriers as of +2.6.31. hdparm -W0 disables it on SATA disks. + Journaling ----------- - -A journaling extension to the ext2 code has been developed by Stephen -Tweedie. It avoids the risks of metadata corruption and the need to -wait for e2fsck to complete after a crash, without requiring a change -to the on-disk ext2 layout. In a nutshell, the journal is a regular -file which stores whole metadata (and optionally data) blocks that have -been modified, prior to writing them into the filesystem. This means -it is possible to add a journal to an existing ext2 filesystem without -the need for data conversion.
PATCH 1/1 document that ext2 can't handle barriers
In reply to Theodore TsoDocument things ext2 expects from storage filesystems, and the fact that it can not handle barriers. Also remove jounaling description, as that's really ext3 material.
Documentation/filesystems/ext2.txt +10 -20
@@ -338,27 +339,17 @@ enough 4-character names to make up unique directory entries, so they have to be 8 character filenames, even then we are fairly close to running out of unique filenames. +Requirements +============ + +Ext2 expects disk/storage subsystem not to return write errors. + +It also needs write caching to be disabled for reliable fsync +operation; ext2 does not know how to issue barriers as of +2.6.31. hdparm -W0 disables it on SATA disks. + Journaling ----------- - -A journaling extension to the ext2 code has been developed by Stephen -Tweedie. It avoids the risks of metadata corruption and the need to -wait for e2fsck to complete after a crash, without requiring a change -to the on-disk ext2 layout. In a nutshell, the journal is a regular -file which stores whole metadata (and optionally data) blocks that have -been modified, prior to writing them into the filesystem. This means -it is possible to add a journal to an existing ext2 filesystem without -the need for data conversion. - -When changes to the filesystem (e.g. a file is renamed) they are stored in -a transaction in the journal and can either be complete or incomplete at -the time of a crash. If a transaction is complete at the time of a crash -(or in the normal case where the system does not crash), then any blocks -in that transaction are guaranteed to represent a valid filesystem state, -and are copied into the filesystem. If a transaction is incomplete at -the time of the crash, then there is no guarantee of consistency for -the blocks in that transaction so they are discarded (which means any -filesystem changes they represent are also lost). +========== Check Documentation/filesystems/ext3.txt if you want to read more about ext3 and journaling.
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Quoted 4 lines · On Monday 24 August 2009 19:08:42 Theodore Tso wrote:
And if your
claim is that several hundred lines of fsck output detailing the filesystem's destruction somehow makes things all better, I suspect most users would disagree with you.
Suppose a small office makes nightly backups to an offsite server via rsync. If a thunderstorm goes by causing their system to reboot twice in a 15 minute period, would they rather notice the filesystem corruption immediately upon reboot, or notice after the next rsync?
Quoted 2 lines
In any case, depending on where the flash was writing at the time of the unplug, the data corruption could be silent anyway.
Yup. Hopefully btrfs will cope less badly? They keep talking about checksumming extents...
Quoted 3 lines
Maybe this came as a surprise to you, but anyone who has used a compact flash in a digital camera knows that you ***have*** to wait until the led has gone out before trying to eject the flash card.
I doubt the cupholder crowd is going to stop treating USB sticks as magical any time soon, but I also wonder how many of them even remember Linux _exists_ anymore.
Quoted 6 lines
I
remember seeing all sorts of horror stories from professional photographers about how they lost an important wedding's day worth of pictures with the attendant commercial loss, on various digital photography forums. It tends to be the sort of mistake that digital photographers only make once.
Professionals have horror stories about this issue, therefore documenting it is _less_ important?
Ok...
Rob
Signature · 1 line
Latency is more important than throughput. It's that simple. - Linus Torvalds
Quoted 9 lines · Theodore Tso
(It's worse with people using Digital SLR's shooting in raw mode, since it can take upwards of 30 seconds or more to write out a 12-30MB raw image, and if you eject at the wrong time, you can trash the contents of the entire CF card; in the worst case, the Flash Translation Layer data can get corrupted, and the card is completely ruined; you can't even reformat it at the filesystem level, but have to get a special Windows program from the CF manufacturer to --maybe-- reset the FTL layer.
This just goes to show why having this "translation layer" done in firmware on the device itself is a _bad_ idea. We're much better off when we have full access to the underlying flash and the OS can actually see what's going on. That way, we can actually debug, fix and recover from such problems.
Quoted 3 lines
Early CF cards were especially vulnerable to
this; more recent CF cards are better, but it's a known failure mode of CF cards.)
It's a known failure mode of _everything_ that uses flash to pretend to be a block device. As I see it, there are no SSD devices which don't lose data; there are only SSD devices which haven't lost your data _yet_.
There's no fundamental reason why it should be this way; it just is.
(I'm kind of hoping that the shiny new expensive ones that everyone's talking about right now, that I shouldn't really be slagging off, are actually OK. But they're still new, and I'm certainly not trusting them with my own data _quite_ yet.)
Signature · 1 line
dwmw2
Quoted 26 lines · David Woodhouse
Quoted 9 lines · Theodore Tso
(It's worse with people using Digital SLR's shooting in raw mode, since it can take upwards of 30 seconds or more to write out a 12-30MB raw image, and if you eject at the wrong time, you can trash the contents of the entire CF card; in the worst case, the Flash Translation Layer data can get corrupted, and the card is completely ruined; you can't even reformat it at the filesystem level, but have to get a special Windows program from the CF manufacturer to --maybe-- reset the FTL layer.
This just goes to show why having this "translation layer" done in firmware on the device itself is a _bad_ idea. We're much better off when we have full access to the underlying flash and the OS can actually see what's going on. That way, we can actually debug, fix and recover from such problems.
Quoted 3 lines
Early CF cards were especially vulnerable to
this; more recent CF cards are better, but it's a known failure mode of CF cards.)It's a known failure mode of _everything_ that uses flash to pretend to be a block device. As I see it, there are no SSD devices which don't lose data; there are only SSD devices which haven't lost your data _yet_.
Quoted 6 lines
There's no fundamental reason why it should be this way; it just is.
(I'm kind of hoping that the shiny new expensive ones that everyone's talking about right now, that I shouldn't really be slagging off, are actually OK. But they're still new, and I'm certainly not trusting them with my own data _quite_ yet.)
so what sort of test would be needed to identify if a device has this problem?
people can do ad-hoc tests by pulling the devices in use and then checking the entire device, but something better should be available.
it seems to me that there are two things needed to define the tests.
1. a predictable write load so that it's easy to detect data getting lose
2. some statistical analysis to decide how many device pulls are needed (under the write load defined in #1) to make the odds high that the problem will be revealed.
with this we could have people test various devices and report if the test detects unrelated data being lost (or businesses, and I think the tech hardware sites would jump into this given some sort of accepted test)
for USB devices there may be a way to use the power management functions to cut power to the device without requiring it to physically be pulled, if this is the case (even if this only works on some specific chipsets), it would drasticly speed up the testing
David Lang
Quoted 41 lines · On Fri 2009-08-28 07:46:42, [email protected] wrote:
Quoted 26 lines · David Woodhouse
Quoted 9 lines · Theodore Tso
(It's worse with people using Digital SLR's shooting in raw mode, since it can take upwards of 30 seconds or more to write out a 12-30MB raw image, and if you eject at the wrong time, you can trash the contents of the entire CF card; in the worst case, the Flash Translation Layer data can get corrupted, and the card is completely ruined; you can't even reformat it at the filesystem level, but have to get a special Windows program from the CF manufacturer to --maybe-- reset the FTL layer.
This just goes to show why having this "translation layer" done in firmware on the device itself is a _bad_ idea. We're much better off when we have full access to the underlying flash and the OS can actually see what's going on. That way, we can actually debug, fix and recover from such problems.
Quoted 3 lines
Early CF cards were especially vulnerable to
this; more recent CF cards are better, but it's a known failure mode of CF cards.)It's a known failure mode of _everything_ that uses flash to pretend to be a block device. As I see it, there are no SSD devices which don't lose data; there are only SSD devices which haven't lost your data _yet_.
Quoted 6 lines
There's no fundamental reason why it should be this way; it just is.
(I'm kind of hoping that the shiny new expensive ones that everyone's talking about right now, that I shouldn't really be slagging off, are actually OK. But they're still new, and I'm certainly not trusting them with my own data _quite_ yet.)
so what sort of test would be needed to identify if a device has this problem?
people can do ad-hoc tests by pulling the devices in use and then checking the entire device, but something better should be available.
Quoted 7 lines
it seems to me that there are two things needed to define the tests.
1. a predictable write load so that it's easy to detect data getting lose
2. some statistical analysis to decide how many device pulls are needed (under the write load defined in #1) to make the odds high that the problem will be revealed.
Its simpler than that. It usually breaks after third unplug or so.
Quoted 4 lines
for USB devices there may be a way to use the power management functions to cut power to the device without requiring it to physically be pulled, if this is the case (even if this only works on some specific chipsets), it would drasticly speed up the testing
This is really so easy to reproduce, that such speedup is not neccessary. Just try the scripts :-).
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Quoted 19 lines · Pavel Machek
Quoted 8 lines · On Fri 2009-08-28 07:46:42, [email protected] wrote:
so what sort of test would be needed to identify if a device has this problem?
people can do ad-hoc tests by pulling the devices in use and then checking the entire device, but something better should be available.
Quoted 7 lines
it seems to me that there are two things needed to define the tests.
1. a predictable write load so that it's easy to detect data getting lose
2. some statistical analysis to decide how many device pulls are needed (under the write load defined in #1) to make the odds high that the problem will be revealed.
Its simpler than that. It usually breaks after third unplug or so.
Quoted 7 lines
Quoted 4 lines
for USB devices there may be a way to use the power management functions to cut power to the device without requiring it to physically be pulled, if this is the case (even if this only works on some specific chipsets), it would drasticly speed up the testing
This is really so easy to reproduce, that such speedup is not neccessary. Just try the scripts :-).
so if it doesn't get corrupted after 5 unplugs does that mean that that particular device doesn't have a problem? or does it just mean you got lucky?
would 10 sucessful unplugs mean that it's safe?
what about 20?
we need to get this beyond anecdotal evidence mode, to something that (even if not perfect, as you can get 100 'heads' in a row with an honest coin) gives you pretty good assurances that a particular device is either good or bad.
David Lang
Hi!
Quoted 10 lines
Quoted 2 lines
This is really so easy to reproduce, that such speedup is not neccessary. Just try the scripts :-).
so if it doesn't get corrupted after 5 unplugs does that mean that that particular device doesn't have a problem? or does it just mean you got lucky?
would 10 sucessful unplugs mean that it's safe?
what about 20?
I'd say 20 means its safe.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Quoted 6 lines · Theodore Tso
I'll note, BTW, that AIX uses a journal to protect against these sorts of problems with software raid; this also means that with AIX, you also don't have to rebuild a RAID 1 device after an unclean shutdown, like you have do with Linux MD. This was on the EVMS's team development list to implement for Linux, but it got canned after LVM won out, lo those many years ago.
See mdadm(8) and look for "--bitmap". It has a few issues (can't reshape an array with a bitmap for example; you have to remove the bitmap, reshape, and re-add the bitmap), but it is available.
Signature · 3 lines
Chris Adams <[email protected]> Systems and Network Administrator - HiWAAY Internet Services I don't speak for anybody but myself - that's enough trouble.
Quoted 11 lines · On Monday August 24, [email protected] wrote:
Quoted 6 lines · Pavel Machek
Quoted 3 lines
I have to admit that I have not paid enough attention to this specifics of your ext3 + flash card issue - is it the ftl stuff doing out of order IO's?
The problem is that flash cards destroy whole erase block on unplug, and ext3 can't cope with that.
Sure --- but name **any** filesystem that can deal with the fact that 128k or 256k worth of data might disappear when you pull out the flash card while it is writing a single sector?
A Log structured filesystem could certainly be written to deal with such a situation, providing by 'deal with' you mean 'only loses data that has not yet been acknowledged to the application'. Of course the filesystem would need clear visibility into exactly how these blocks are positioned.
I've been playing with just such a filesystem for some time (never really finding enough time) with the goal of making it work over RAID5 with no data risk due to power loss. One day it will be functional enough for others to try....
It is entirely possible that NILFS could be made to meet that requirement, but I haven't made time to explore NILFS so I cannot be sure.
NeilBrown
Quoted 24 lines · Neil Brown
Quoted 11 lines · On Monday August 24, [email protected] wrote:
Quoted 6 lines · Pavel Machek
Quoted 3 lines
I have to admit that I have not paid enough attention to this specifics of your ext3 + flash card issue - is it the ftl stuff doing out of order IO's?
The problem is that flash cards destroy whole erase block on unplug, and ext3 can't cope with that.
Sure --- but name **any** filesystem that can deal with the fact that 128k or 256k worth of data might disappear when you pull out the flash card while it is writing a single sector?
A Log structured filesystem could certainly be written to deal with such a situation, providing by 'deal with' you mean 'only loses data that has not yet been acknowledged to the application'. Of course the filesystem would need clear visibility into exactly how these blocks are positioned.
I've been playing with just such a filesystem for some time (never really finding enough time) with the goal of making it work over RAID5 with no data risk due to power loss. One day it will be functional enough for others to try....
Quoted 6 lines
It is entirely possible that NILFS could be made to meet that requirement, but I haven't made time to explore NILFS so I cannot be sure.
NeilBrown
I am not sure that log structure will protect you from this scenario since once you clean the log, the non-logged data is assumed to be correct.
If your cheap flash storage device can nuke random regions of that clean storage, you will lose data....
ric
Quoted 34 lines · Ric Wheeler
Quoted 26 lines · Neil Brown
Quoted 7 lines · On Monday August 24, [email protected] wrote:
Quoted 6 lines · Pavel Machek
Quoted 5 lines
I have to admit that I have not paid enough attention to this specifics
of your ext3 + flash card issue - is it the ftl stuff doing out of order
IO's?Quoted 6 lines
Quoted 2 lines
The problem is that flash cards destroy whole erase block on unplug, and ext3 can't cope with that.
Sure --- but name **any** filesystem that can deal with the fact that 128k or 256k worth of data might disappear when you pull out the flash card while it is writing a single sector?
A Log structured filesystem could certainly be written to deal with such a situation, providing by 'deal with' you mean 'only loses data that has not yet been acknowledged to the application'. Of course the filesystem would need clear visibility into exactly how these blocks are positioned.
I've been playing with just such a filesystem for some time (never really finding enough time) with the goal of making it work over RAID5 with no data risk due to power loss. One day it will be functional enough for others to try....
Quoted 6 lines
It is entirely possible that NILFS could be made to meet that requirement, but I haven't made time to explore NILFS so I cannot be sure.
NeilBrown
Quoted 6 lines
I am not sure that log structure will protect you from this scenario since once
you clean the log, the non-logged data is assumed to be correct.If your cheap flash storage device can nuke random regions of that clean storage, you will lose data....
Hence my observation that "the filesystem would need clear visibility into exactly how these blocks are positioned".
If there is an FTL in the way that randomly relocates blocks, and a power fail during write could corrupt data that appears to be megabytes away in some unpredictable location, then yes: a log structure won't help.
However I would like to imagine that even a cheep flash device, if it only ever got writes that were exactly the size of the erase-block, would not break those writes over multiple erase blocks, so some degree of integrity and predictability could be preserved. Even more so, I would love to be able to disable the FTL, or at least have clear and correct documentation about how it works.
So yes, not a panacea. But an avenue with real possibilities.
NeilBrown
Quoted 6 lines
The papers show failures in "once a year" range. I have "twice a minute" failure scenario with flashdisks.
Not sure how often "degraded raid5 breaks ext3 atomicity" would bite, but I bet it would be on "once a day" scale.
I agree it should be documented, but the ext3 atomicity issue is only an issue on unexpected shutdown while the array is degraded. I surely hope most people running raid5 are not seeing that level of unexpected shutdown, let along in a degraded array,
If they are, the atomicity issue pretty strongly says they should not be using raid5 in that environment. At least not for any filesystem I know. Having writes to LBA n corrupt LBA n+128 as an example is pretty hard to design around from a fs perspective.
Greg
Quoted 11 lines · On Monday 24 August 2009 16:11:56 Greg Freemyer wrote:
Quoted 5 lines
The papers show failures in "once a year" range. I have "twice a minute" failure scenario with flashdisks.
Not sure how often "degraded raid5 breaks ext3 atomicity" would bite, but I bet it would be on "once a day" scale.
I agree it should be documented, but the ext3 atomicity issue is only an issue on unexpected shutdown while the array is degraded. I surely hope most people running raid5 are not seeing that level of unexpected shutdown, let along in a degraded array,
Quoted 4 lines
If they are, the atomicity issue pretty strongly says they should not be using raid5 in that environment. At least not for any filesystem I know. Having writes to LBA n corrupt LBA n+128 as an example is pretty hard to design around from a fs perspective.
Right now, people think that a degraded raid 5 is equivalent to raid 0. As this thread demonstrates, in the power failure case it's _worse_, due to write granularity being larger than the filesystem sector size. (Just like flash.)
Knowing that, some people might choose to suspend writes to their raid until it's finished recovery. Perhaps they'll set up a system where a degraded raid 5 gets remounted read only until recovery completes, and then writes go to a new blank hot spare disk using all that volume snapshoting or unionfs stuff people have been working on. (The big boys already have hot spare disks standing by on a lot of these systems, ready to power up and go without human intervention. Needing two for actual reliability isn't that big a deal.)
Or maybe the raid guys might want to tweak the recovery logic so it's not entirely linear, but instead prioritizes dirty pages over clean ones. So if somebody dirties a page halfway through a degraded raid 5, skip ahead to recover that chunk first to the new disk first (yes leaving holes, it's not that hard to track), and _then_ let the write go through.
But unless people know the issue exists, they won't even start thinking about ways to address it.
Quoted 1 line
Greg
Rob
Signature · 1 line
Latency is more important than throughput. It's that simple. - Linus Torvalds
Quoted 29 lines · Rob Landley
Quoted 11 lines · On Monday 24 August 2009 16:11:56 Greg Freemyer wrote:
Quoted 5 lines
The papers show failures in "once a year" range. I have "twice a minute" failure scenario with flashdisks.
Not sure how often "degraded raid5 breaks ext3 atomicity" would bite, but I bet it would be on "once a day" scale.
I agree it should be documented, but the ext3 atomicity issue is only an issue on unexpected shutdown while the array is degraded. I surely hope most people running raid5 are not seeing that level of unexpected shutdown, let along in a degraded array,
Quoted 4 lines
If they are, the atomicity issue pretty strongly says they should not be using raid5 in that environment. At least not for any filesystem I know. Having writes to LBA n corrupt LBA n+128 as an example is pretty hard to design around from a fs perspective.
Right now, people think that a degraded raid 5 is equivalent to raid 0. As this thread demonstrates, in the power failure case it's _worse_, due to write granularity being larger than the filesystem sector size. (Just like flash.)
Knowing that, some people might choose to suspend writes to their raid until it's finished recovery. Perhaps they'll set up a system where a degraded raid 5 gets remounted read only until recovery completes, and then writes go to a new blank hot spare disk using all that volume snapshoting or unionfs stuff people have been working on. (The big boys already have hot spare disks standing by on a lot of these systems, ready to power up and go without human intervention. Needing two for actual reliability isn't that big a deal.)
Quoted 8 lines
Or maybe the raid guys might want to tweak the recovery logic so it's not entirely linear, but instead prioritizes dirty pages over clean ones. So if somebody dirties a page halfway through a degraded raid 5, skip ahead to recover that chunk first to the new disk first (yes leaving holes, it's not that hard to track), and _then_ let the write go through.
But unless people know the issue exists, they won't even start thinking about ways to address it.
if you've got the drives available you should be running raid 6 not raid 5 so that you have to loose two drives before you loose your error checking.
in my opinion that's a far better use of a drive than a hot spare.
David Lang
Quoted 8 lines · On Monday 24 August 2009 15:24:28 Ric Wheeler wrote:
Quoted 2 lines · Pavel Machek
Actually, ext2 should be able to survive that, no? Error writing -> remount ro -> fsck on next boot -> drive relocates the sectors.
I think that the example and the response are both off base. If your head ever touches the platter, you won't be reading from a huge part of your drive ever again
It's not quite that simple anymore.
These days, most modern drives add an "overcoat", which is a vapor deposition layer of carbon (I.E. diamond) on top of the magnetic media, and then add a nanolayer of some kind of nonmagnetic lubricant on top of that. That protects the magnetic layer from physical contact with the head; it takes a pretty solid whack to chip through diamond and actually gouge your disk:
http://www.datarecoverylink.com/understanding_magnetic_media.html
You can also do fun things with various nitridies (carbon nitride, silicon nitride, titanium nitride) which are pretty darn tough too, although I dunno about their suitability to hard drives:
http://www.physical-vapor-deposition.com/
So while it _is_ possible to whack your drive and scratch the platter, merely "touching" won't do it. (Laptops wouldn't be feasible if they couldn't cope with a little jostling while running.) In the case of repeated small whacks, your heads may actually go first. (I vaguely recall the little aerofoil wing thingy holding up the disk touches first, and can get ground down by repeated contact with the diamond layer (despite the lubricant, that just buys time) so it gets shorter and shorter and can't reliably keep the head above the disk rather than in contact with it. But I'm kind of stale myself here, not sure that's still current.)
Here's a nice youtube video of a 2007 defcon talk from a hard drive recovery professional, "What's that Clicking Noise", series starts here:
http://www.youtube.com/watch?v=vCapEFNZAJ0
And here's that guy's web page:
http://www.myharddrivedied.com/presentations/index.html
Rob
Signature · 1 line
Latency is more important than throughput. It's that simple. - Linus Torvalds
* Theodore Tso:
Quoted 2 lines
The only one that falls into that category is the one about not being able to handle failed writes, and the way most failures take place,
Hmm. What does "not being able to handle failed writes" actually mean? AFAICS, there are two possible answers: "all bets are off", or "we'll tell you about the problem, and all bets are off".
Quoted 8 lines
Quoted 2 lines
Isn't this by design? In other words, if the metadata doesn't survive non-atomic writes, wouldn't it be an ext3 bug?
Part of the problem here is that "atomic-writes" is confusing; it doesn't mean what many people think it means. The assumption which many naive filesystem designers make is that writes succeed or they don't. If they don't succeed, they don't change the previously existing data in any way.
Right. And a lot of database systems make the same assumption. Oracle Berkeley DB cannot deal with partial page writes at all, and PostgreSQL assumes that it's safe to flip a few bits in a sector without proper WAL (it doesn't care if the changes actually hit the disk, but the write shouldn't make the sector unreadable or put random bytes there).
Quoted 9 lines
Is that a file system "bug"? Well, it's better to call that a mismatch between the assumptions made of physical devices, and of the file system code. On Irix, SGI hardware had a powerfail interrupt, and the power supply and extra-big capacitors, so that when a power fail interrupt came in, the Irix would run around frantically shutting down pending DMA transfers to prevent this failure mode from causing problems. PC class hardware (according to Ted's law), is cr*p, and doesn't have a powerfail interrupt, so it's not something that we have.
The DMA transaction should fail due to ECC errors, though.
Quoted 8 lines
Ext3, ext4, and ocfs2 does physical block journalling, so as long as journal truncate hasn't taken place right before the failure, the replay of the physical block journal tends to repair this most (but not necessarily all) cases of "garbage is written right before power failure". People who care about this should really use a UPS, and wire up the USB and/or serial cable from the UPS to the system, so that the OS can do a controlled shutdown if the UPS is close to shutting down due to an extended power failure.
I think the general idea is to protect valuable data with WAL. You overwrite pages on disk only after you've made a backup copy into WAL. After a power loss event, you replay the log and overwrite all garbage that might be there. For the WAL, you rely on checksum and sequence numbers. This still doesn't help against write failures where the system continues running (because the fsync() during checkpointing isn't guaranteed to report errors), but it should deal with the power failure case. But this assumes that the file system protects its own data structure in a similar way. Is this really too much to demand?
Partial failures are extremely difficult to deal with because of their asynchronous nature. I've come to accept that, but it's still disappointing.
Signature · 4 lines
Florian Weimer <[email protected]> BFK edv-consulting GmbH http://www.bfk.de/ Kriegsstraße 100 tel: +49-721-96201-1 D-76133 Karlsruhe fax: +49-721-96201-99
Quoted 10 lines · Florian Weimer
Documentation/filesystems/ext3.txt debugfs: ext2 and ext3 file system debugger. · line 220
Quoted 7 lines
Documentation/filesystems/ext3.txt +7
-0+* don't damage the old data on a failed write (ATOMIC-WRITES) + + (Thrash may get written into sectors during powerfail. And + ext3 handles this surprisingly well at least in the + catastrophic case of garbage getting written into the inode + table, since the journal replay often will "repair" the + garbage that was written into the filesystem metadata blocks.Isn't this by design? In other words, if the metadata doesn't survive non-atomic writes, wouldn't it be an ext3 bug?
So I got confused when I quoted your note, which I had assumed was exactly what Pavel had written in his documentation. In fact, what he had written was this:
+Don't damage the old data on a failed write (ATOMIC-WRITES)
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Either whole sector is correctly written or nothing is written during +powerfail.
+
+....
So he had explicitly stated that he only cared about the whole sector being written (or not written) in the power fail case, and not any other. I'd suggest changing ATOMIC-WRITES to ATOMIC-WRITE-ON-POWERFAIL, since the one-line summary, "Don't damage the old data on a failed write", is also singularly misleading.
- Ted
Hi!
Quoted 23 lines
Quoted 10 lines
Documentation/filesystems/ext3.txt debugfs: ext2 and ext3 file system debugger. · line 220
Quoted 7 lines
Documentation/filesystems/ext3.txt +7
-0+* don't damage the old data on a failed write (ATOMIC-WRITES) + + (Thrash may get written into sectors during powerfail. And + ext3 handles this surprisingly well at least in the + catastrophic case of garbage getting written into the inode + table, since the journal replay often will "repair" the + garbage that was written into the filesystem metadata blocks.Isn't this by design? In other words, if the metadata doesn't survive non-atomic writes, wouldn't it be an ext3 bug?
So I got confused when I quoted your note, which I had assumed was exactly what Pavel had written in his documentation. In fact, what he had written was this:
Documentation/filesystems/expectations.txt new file +7
-0+Don't damage the old data on a failed write (ATOMIC-WRITES) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Either whole sector is correctly written or nothing is written during +powerfail. + +....
Quoted 5 lines
So he had explicitly stated that he only cared about the whole sector being written (or not written) in the power fail case, and not any other. I'd suggest changing ATOMIC-WRITES to ATOMIC-WRITE-ON-POWERFAIL, since the one-line summary, "Don't damage the old data on a failed write", is also singularly misleading.
Ok, something like this?
Don't damage the old data on a powerfail (ATOMIC-WRITES-ON-POWERFAIL)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Either whole sector is correctly written or nothing is written during powerfail.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Hi!
Quoted 23 lines
Quoted 10 lines
Documentation/filesystems/ext3.txt debugfs: ext2 and ext3 file system debugger. · line 220
Quoted 7 lines
Documentation/filesystems/ext3.txt +7
-0+* don't damage the old data on a failed write (ATOMIC-WRITES) + + (Thrash may get written into sectors during powerfail. And + ext3 handles this surprisingly well at least in the + catastrophic case of garbage getting written into the inode + table, since the journal replay often will "repair" the + garbage that was written into the filesystem metadata blocks.Isn't this by design? In other words, if the metadata doesn't survive non-atomic writes, wouldn't it be an ext3 bug?
So I got confused when I quoted your note, which I had assumed was exactly what Pavel had written in his documentation. In fact, what he had written was this:
Documentation/filesystems/expectations.txt new file +7
-0+Don't damage the old data on a failed write (ATOMIC-WRITES) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Either whole sector is correctly written or nothing is written during +powerfail. + +....
Quoted 5 lines
So he had explicitly stated that he only cared about the whole sector being written (or not written) in the power fail case, and not any other. I'd suggest changing ATOMIC-WRITES to ATOMIC-WRITE-ON-POWERFAIL, since the one-line summary, "Don't damage the old data on a failed write", is also singularly misleading.
Ok, something like this?
Don't damage the old data on a powerfail (ATOMIC-WRITES-ON-POWERFAIL)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Either whole sector is correctly written or nothing is written during powerfail.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Hi!
Quoted 7 lines
Documentation/filesystems/expectations.txt line 4
Quoted 4 lines
Documentation/filesystems/expectations.txt new file +4
-0+Linux block-backed filesystems can only work correctly when several +conditions are met in the block layer and below (disks, flash +cards). Some of them are obvious ("data on media should not change +randomly"), some are less so.You should make clear that the file lists per-file-system rules and that some file sytems can recover from some of the error conditions.
Ok, I added "Not all filesystems require all of these
to be satisfied for safe operation" sentence there.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Quoted 55 lines · Pavel Machek
Running journaling filesystem such as ext3 over flashdisk or degraded RAID array is a bad idea: journaling guarantees no longer apply and you will get data corruption on powerfail.
We can't solve it easily, but we should certainly warn the users. I actually lost data because I did not understand these limitations...
Signed-off-by Pavel Machek <[email protected]>Documentation/filesystems/expectations.txt new file +39
-0@@ -0,0 +1,52 @@ +Linux block-backed filesystems can only work correctly when several +conditions are met in the block layer and below (disks, flash +cards). Some of them are obvious ("data on media should not change +randomly"), some are less so. + +Write errors not allowed (NO-WRITE-ERRORS) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Writes to media never fail. Even if disk returns error condition +during write, filesystems can't handle that correctly. + + Fortunately writes failing are very uncommon on traditional + spinning disks, as they have spare sectors they use when write + fails. + +Don't cause collateral damage to adjacent sectors on a failed write (NO-COLLATERALS) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Unfortunately, cheap USB/SD flash cards I've seen do have this bug, +and are thus unsuitable for all filesystems I know. + + An inherent problem with using flash as a normal block device + is that the flash erase size is bigger than most filesystem + sector sizes. So when you request a write, it may erase and + rewrite some 64k, 128k, or even a couple megabytes on the + really _big_ ones. + + If you lose power in the middle of that, filesystem won't + notice that data in the "sectors" _around_ the one your were + trying to write to got trashed. + + RAID-4/5/6 in degraded mode has same problem. + + +Don't damage the old data on a failed write (ATOMIC-WRITES) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Either whole sector is correctly written or nothing is written during +powerfail.
Documentation/filesystems/expectations.txt line 49
Quoted 10 lines
Documentation/filesystems/expectations.txt new file +10
-0+ + Because RAM tends to fail faster than rest of system during + powerfail, special hw killing DMA transfers may be necessary; + otherwise, disks may write garbage during powerfail. + This may be quite common on generic PC machines. + + Note that atomic write is very hard to guarantee for RAID-4/5/6, + because it needs to write both changed data, and parity, to + different disks. (But it will only really show up in degraded mode). + UPS for RAID array should help.
Can someone clarify if this is true in raid-6 with just a single disk failure? I don't see why it would be.
And if not can the above text be changed to reflect raid 4/5 with a single disk failure and raid 6 with a double disk failure are the modes that have atomicity problems.
Greg
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 17 lines
Documentation/filesystems/expectations.txt line 49
Quoted 13 lines
Documentation/filesystems/expectations.txt new file +12
-0+Either whole sector is correctly written or nothing is written during +powerfail. + + Because RAM tends to fail faster than rest of system during + powerfail, special hw killing DMA transfers may be necessary; + otherwise, disks may write garbage during powerfail. + This may be quite common on generic PC machines. + + Note that atomic write is very hard to guarantee for RAID-4/5/6, + because it needs to write both changed data, and parity, to + different disks. (But it will only really show up in degraded mode). + UPS for RAID array should help.Can someone clarify if this is true in raid-6 with just a single disk failure? I don't see why it would be.
Quoted 3 lines
And if not can the above text be changed to reflect raid 4/5 with a single disk failure and raid 6 with a double disk failure are the modes that have atomicity problems.
I don't know enough about raid-6, but... I said "degraded mode" above, and you can read it as double failure in raid-6 case ;-). I'll prefer to avoid too many details here.
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Quoted 10 lines · On Monday August 24, [email protected] wrote:
Quoted 10 lines
Documentation/filesystems/expectations.txt new file +10
-0+Don't damage the old data on a failed write (ATOMIC-WRITES) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Either whole sector is correctly written or nothing is written during +powerfail. + + Because RAM tends to fail faster than rest of system during + powerfail, special hw killing DMA transfers may be necessary; + otherwise, disks may write garbage during powerfail. + This may be quite common on generic PC machines.
Quoted 8 lines
Quoted 5 lines
+
+ Note that atomic write is very hard to guarantee for RAID-4/5/6,
+ because it needs to write both changed data, and parity, to
+ different disks. (But it will only really show up in degraded mode).
+ UPS for RAID array should help.Can someone clarify if this is true in raid-6 with just a single disk failure? I don't see why it would be.
It does affect raid6 with a single drive missing.
After an unclean shutdown you cannot trust any Parity block as it is possible that some of the blocks in the stripe have been updated, but others have not. So you must assume that all parity blocks are wrong and update them. If you have a missing disk you cannot do that.
To take a more concrete example, imagine a 5 device RAID6 with 3 data blocks D0 D1 D2 as well a P and Q on some stripe. Suppose that we crashed while updating D0, which would have involved writing out D0, P and Q.
On restart, suppose D2 is missing. It is possible that 0, 1, 2, or 3 of D0, P and Q have been updated and the others not.
We can try to recompute D2 from D0 D1 and P, from
D0 P and Q or from D1, P and Q.
We could conceivably try each of those and if they all produce the same result we might be confident of it.
If two produced the same result and the other was different we could use a voting process to choose the 'best'. And in this particular case I think that would work. If 0 or 3 had been updates, all would be the same. If only 1 was updated, then the combinations that exclude it will match. If 2 were updated, then the combinations that exclude the non-updated block will match.
But if both D0 and D1 were being updated I think there would be too many combinations and it would be very possibly that all three computed values for D2 would be different.
So yes: a singly degraded RAID6 cannot promise no data corruption after an unclean shutdown. That is why "mdadm" will not assemble such an array unless you use "--force" to acknowledge that there has been a problem.
NeilBrown
Quoted 45 lines · Neil Brown
Quoted 10 lines · On Monday August 24, [email protected] wrote:
Quoted 10 lines
Documentation/filesystems/expectations.txt new file +10
-0+Don't damage the old data on a failed write (ATOMIC-WRITES) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Either whole sector is correctly written or nothing is written during +powerfail. + + Because RAM tends to fail faster than rest of system during + powerfail, special hw killing DMA transfers may be necessary; + otherwise, disks may write garbage during powerfail. + This may be quite common on generic PC machines.Quoted 8 lines
Quoted 5 lines
+
+ Note that atomic write is very hard to guarantee for RAID-4/5/6,
+ because it needs to write both changed data, and parity, to
+ different disks. (But it will only really show up in degraded mode).
+ UPS for RAID array should help.Can someone clarify if this is true in raid-6 with just a single disk failure? I don't see why it would be.
It does affect raid6 with a single drive missing.
After an unclean shutdown you cannot trust any Parity block as it is possible that some of the blocks in the stripe have been updated, but others have not. So you must assume that all parity blocks are wrong and update them. If you have a missing disk you cannot do that.
To take a more concrete example, imagine a 5 device RAID6 with 3 data blocks D0 D1 D2 as well a P and Q on some stripe. Suppose that we crashed while updating D0, which would have involved writing out D0, P and Q.
On restart, suppose D2 is missing. It is possible that 0, 1, 2, or 3 of D0, P and Q have been updated and the others not.
We can try to recompute D2 from D0 D1 and P, from
D0 P and Q or from D1, P and Q.We could conceivably try each of those and if they all produce the same result we might be confident of it.
If two produced the same result and the other was different we could use a voting process to choose the 'best'. And in this particular case I think that would work. If 0 or 3 had been updates, all would be the same. If only 1 was updated, then the combinations that exclude it will match. If 2 were updated, then the combinations that exclude the non-updated block will match.
Quoted 8 lines
But if both D0 and D1 were being updated I think there would be too many combinations and it would be very possibly that all three computed values for D2 would be different.
So yes: a singly degraded RAID6 cannot promise no data corruption after an unclean shutdown. That is why "mdadm" will not assemble such an array unless you use "--force" to acknowledge that there has been a problem.
thanks for this detail, I would not have expected a partially degraded raid 6 array to be this sensitive to problems.
assuming that the degradation happens prior to the power failure, what could be done to make this safer and more predictable.
off the top of my head (and possibly an extreme performance hit, not nessasarily suitable for everyone) is there something that could be done with ordering the writes to the various drives?
David Lang
Quoted 8 lines · On Monday 24 August 2009 04:31:43 Pavel Machek wrote:
Running journaling filesystem such as ext3 over flashdisk or degraded RAID array is a bad idea: journaling guarantees no longer apply and you will get data corruption on powerfail.
We can't solve it easily, but we should certainly warn the users. I actually lost data because I did not understand these limitations...
Signed-off-by Pavel Machek <[email protected]>
With a couple comments:
Documentation/filesystems/ext2.txt enough 4-character names to make up unique directory entries, so they · line 362
Quoted 2 lines
Documentation/filesystems/ext2.txt +2
-0+* write caching is disabled. ext2 does not know how to issue barriers + as of 2.6.28. hdparm -W0 disables it on SATA disks.
It's coming up on 2.6.31, has it learned anything since or should that version number be bumped?
Documentation/filesystems/ext3.txt debugfs: ext2 and ext3 file system debugger. · line 226
Quoted 11 lines
Documentation/filesystems/ext3.txt +11
-0+ (Thrash may get written into sectors during powerfail. And + ext3 handles this surprisingly well at least in the + catastrophic case of garbage getting written into the inode + table, since the journal replay often will "repair" the + garbage that was written into the filesystem metadata blocks. + It won't do a bit of good for the data blocks, of course + (unless you are using data=journal mode). But this means that + in fact, ext3 is more resistant to suriving failures to the + first problem (powerfail while writing can damage old data on + a failed write) but fortunately, hard drives generally don't + cause collateral damage on a failed write.
Possible rewording of this paragraph:
Ext3 handles trash getting written into sectors during powerfail surprisingly well. It's not foolproof, but it is resilient. Incomplete journal entries are ignored, and journal replay of complete entries will often "repair" garbage written into the inode table. The data=journal option extends this behavior to file and directory data blocks as well (without which your dentries can still be badly corrupted by a power fail during a write).
(I'm not entirely sure about that last bit, but clarifying it one way or the other would be nice because I can't tell from reading it which it is. My _guess_ is that directories are just treated as files with an attitude and an extra cacheing layer...?)
Rob
Signature · 1 line
Latency is more important than throughput. It's that simple. - Linus Torvalds
Pavel Machek
AppliedQuoted 12 lines · Rob Landley
Quoted 8 lines · On Monday 24 August 2009 04:31:43 Pavel Machek wrote:
Running journaling filesystem such as ext3 over flashdisk or degraded RAID array is a bad idea: journaling guarantees no longer apply and you will get data corruption on powerfail.
We can't solve it easily, but we should certainly warn the users. I actually lost data because I did not understand these limitations...
Signed-off-by Pavel Machek <[email protected]>Acked-by Rob Landley <[email protected]>
Quoted 7 lines
With a couple comments:
Documentation/filesystems/ext2.txt enough 4-character names to make up unique directory entries, so they · line 362
Quoted 2 lines
Documentation/filesystems/ext2.txt +2
-0+* write caching is disabled. ext2 does not know how to issue barriers + as of 2.6.28. hdparm -W0 disables it on SATA disks.It's coming up on 2.6.31, has it learned anything since or should that version number be bumped?
Jan, did those "barrier for ext2" patches get merged?
Quoted 22 lines
Documentation/filesystems/ext3.txt debugfs: ext2 and ext3 file system debugger. · line 226
Quoted 11 lines
Documentation/filesystems/ext3.txt +11
-0+ (Thrash may get written into sectors during powerfail. And + ext3 handles this surprisingly well at least in the + catastrophic case of garbage getting written into the inode + table, since the journal replay often will "repair" the + garbage that was written into the filesystem metadata blocks. + It won't do a bit of good for the data blocks, of course + (unless you are using data=journal mode). But this means that + in fact, ext3 is more resistant to suriving failures to the + first problem (powerfail while writing can damage old data on + a failed write) but fortunately, hard drives generally don't + cause collateral damage on a failed write.Possible rewording of this paragraph:
Ext3 handles trash getting written into sectors during powerfail surprisingly well. It's not foolproof, but it is resilient. Incomplete journal entries are ignored, and journal replay of complete entries will often "repair" garbage written into the inode table. The data=journal option extends this behavior to file and directory data blocks as well (without which your dentries can still be badly corrupted by a power fail during a write).
Quoted 4 lines
(I'm not entirely sure about that last bit, but clarifying it one way or the other would be nice because I can't tell from reading it which it is. My _guess_ is that directories are just treated as files with an attitude and an extra cacheing layer...?)
Thanks, applied, it looks better than what I wrote. I removed the () part, as I'm not sure about it...
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Quoted 15 lines · Pavel Machek
Quoted 14 lines · Rob Landley
Quoted 8 lines · On Monday 24 August 2009 04:31:43 Pavel Machek wrote:
Running journaling filesystem such as ext3 over flashdisk or degraded RAID array is a bad idea: journaling guarantees no longer apply and you will get data corruption on powerfail.
We can't solve it easily, but we should certainly warn the users. I actually lost data because I did not understand these limitations...
Signed-off-by Pavel Machek <[email protected]>Acked-by Rob Landley <[email protected]>With a couple comments:
Quoted 7 lines
Quoted 5 lines
Documentation/filesystems/ext2.txt enough 4-character names to make up unique directory entries, so they · line 362
Quoted 2 lines
Documentation/filesystems/ext2.txt +2
-0+* write caching is disabled. ext2 does not know how to issue barriers + as of 2.6.28. hdparm -W0 disables it on SATA disks.It's coming up on 2.6.31, has it learned anything since or should that version number be bumped?
Jan, did those "barrier for ext2" patches get merged?
No, they did not. We were discussing how to be able to enable / disable
sending barriers, someone told he'd implement it but it somehow never got beyond an initial attempt.
Actually, after recent sync cleanups (and when my O_SYNC cleanups get
merged) it should be pretty easy because every filesystem now has ->fsync() and ->sync_fs() callback so we just have to add sending barriers to these two functions and implement possibility to set via sysfs that barriers on the block device should be ignored.
I've put it to my todo list but if someone else has time for this, I
certainly would not mind :). It would be a nice beginner project...
Honza
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Updated version here.
Quoted 6 lines · Rob Landley
Quoted 5 lines · On Thursday 12 March 2009 04:21:14 Pavel Machek wrote:
Not all block devices are suitable for all filesystems. In fact, some block devices are so broken that reliable operation is pretty much impossible. Document stuff ext2/ext3 needs for reliable operation.
Signed-off-by Pavel Machek <[email protected]>
Documentation/filesystems/expectations.txt new file +47 -0
@@ -0,0 +1,47 @@ +Linux block-backed filesystems can only work correctly when several +conditions are met in the block layer and below (disks, flash +cards). Some of them are obvious ("data on media should not change +randomly"), some are less so. + +Write errors not allowed (NO-WRITE-ERRORS) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Writes to media never fail. Even if disk returns error condition +during write, filesystems can't handle that correctly, because success +on fsync was already returned when data hit the journal. + + Fortunately writes failing are very uncommon on traditional + spinning disks, as they have spare sectors they use when write + fails. + +Sector writes are atomic (ATOMIC-SECTORS) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Either whole sector is correctly written or nothing is written during +powerfail. + + Unfortunately, none of the cheap USB/SD flash cards I've seen + do behave like this, and are thus unsuitable for all Linux + filesystems I know. + + An inherent problem with using flash as a normal block + device is that the flash erase size is bigger than + most filesystem sector sizes. So when you request a + write, it may erase and rewrite some 64k, 128k, or + even a couple megabytes on the really _big_ ones. + + If you lose power in the middle of that, filesystem + won't notice that data in the "sectors" _around_ the + one your were trying to write to got trashed. + + Because RAM tends to fail faster than rest of system during + powerfail, special hw killing DMA transfers may be necessary; + otherwise, disks may write garbage during powerfail. + Not sure how common that problem is on generic PC machines. + + Note that atomic write is very hard to guarantee for RAID-4/5/6, + because it needs to write both changed data, and parity, to + different disks. UPS for RAID array should help. + + +
Documentation/filesystems/ext2.txt +18 -20
@@ -338,27 +339,25 @@ enough 4-character names to make up unique directory entries, so they have to be 8 character filenames, even then we are fairly close to running out of unique filenames. +Requirements +============ + +Ext2 expects disk/storage subsystem to behave sanely. On sanely +behaving disk subsystem, data that have been successfully synced will +stay on the disk. Sane means: + +* write errors not allowed + +* sector writes are atomic + +(see expectations.txt; note that most/all linux block-based +filesystems have similar expectations) + +* write caching is disabled. ext2 does not know how to issue barriers + as of 2.6.28. hdparm -W0 disables it on SATA disks. + Journaling ----------- - -A journaling extension to the ext2 code has been developed by Stephen -Tweedie. It avoids the risks of metadata corruption and the need to -wait for e2fsck to complete after a crash, without requiring a change -to the on-disk ext2 layout. In a nutshell, the journal is a regular -file which stores whole metadata (and optionally data) blocks that have -been modified, prior to writing them into the filesystem. This means -it is possible to add a journal to an existing ext2 filesystem without -the need for data conversion. - -When changes to the filesystem (e.g. a file is renamed) they are stored in -a transaction in the journal and can either be complete or incomplete at -the time of a crash. If a transaction is complete at the time of a crash -(or in the normal case where the system does not crash), then any blocks -in that transaction are guaranteed to represent a valid filesystem state, -and are copied into the filesystem. If a transaction is incomplete at -the time of the crash, then there is no guarantee of consistency for -the blocks in that transaction so they are discarded (which means any -filesystem changes they represent are also lost). +========== Check Documentation/filesystems/ext3.txt if you want to read more about ext3 and journaling.
Documentation/filesystems/ext3.txt +21 -0
@@ -188,6 +200,27 @@ mke2fs: create a ext3 partition with the -j flag. debugfs: ext2 and ext3 file system debugger. ext2online: online (mounted) ext2 and ext3 filesystem resizer +Requirements +============ + +Ext3 expects disk/storage subsystem to behave sanely. On sanely +behaving disk subsystem, data that have been successfully synced will +stay on the disk. Sane means: + +* write errors not allowed + +* sector writes are atomic + +(see expectations.txt; note that most/all linux block-based +filesystems have similar expectations) + +* either write caching is disabled, or hw can do barriers and they are enabled. + + (Note that barriers are disabled by default, use "barrier=1" + mount option after making sure hw can support them). + + hdparm -I reports disk features. If you have "Native + Command Queueing" is the feature you are looking for. References ==========
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Quoted 7 lines · Pavel Machek
Updated version here.
Quoted 4 lines · Rob Landley
Quoted 3 lines · On Thursday 12 March 2009 04:21:14 Pavel Machek wrote:
Not all block devices are suitable for all filesystems. In fact, some block devices are so broken that reliable operation is pretty much impossible. Document stuff ext2/ext3 needs for reliable operation.
Some of what is here are bugs, and some are legitimate long-term interfaces (for example, the question of losing I/O errors when two processes are writing to the same file, or to a directory entry, and errors aren't or in some cases, can't, be reflected back to userspace).
I'm a little concerned that some of this reads a bit too much like a rant (and I know Pavel was very frustrated when he tried to use a flash card with a sucky flash card socket) and it will get used the wrong way by apoligists, because it mixes areas where "we suck, we should do better", which a re bug reports, and "Posix or the underlying block device layer makes it hard", and simply states them as fundamental design requirements, when that's probably not true.
There's a lot of work that we could do to make I/O errors get better reflected to userspace by fsync(). So state things as bald requirements I think goes a little too far IMHO. We can surely do better.
Documentation/filesystems/expectations.txt line 11
Quoted 12 lines
Documentation/filesystems/expectations.txt new file +7
-0+ +Write errors not allowed (NO-WRITE-ERRORS) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Writes to media never fail. Even if disk returns error condition +during write, filesystems can't handle that correctly, because success +on fsync was already returned when data hit the journal.
The last half of this sentence "because success on fsync was already returned when data hit the journal", obviously doesn't apply to all filesystems, since some filesystems, like ext2, don't journal data. Even for ext3, it only applies in the case of data=journal mode.
There are other issues here, such as fsync() only reports an I/O problem to one caller, and in some cases I/O errors aren't propagated up the storage stack. The latter is clearly just a bug that should be fixed; the former is more of an interface limitation. But you don't talk about in this section, and I think it would be good to have a more extended discussion about I/O errors when writing data blocks, and I/O errors writing metadata blocks, etc.
Documentation/filesystems/expectations.txt line 21
Quoted 6 lines
Documentation/filesystems/expectations.txt new file +6
-0+ +Sector writes are atomic (ATOMIC-SECTORS) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Either whole sector is correctly written or nothing is written during +powerfail.
This requirement is not quite the same as what you discuss below.
Quoted 4 lines
Documentation/filesystems/expectations.txt new file +4
-0+ + Unfortunately, none of the cheap USB/SD flash cards I've seen + do behave like this, and are thus unsuitable for all Linux + filesystems I know.
Documentation/filesystems/expectations.txt line 35
Quoted 10 lines
Documentation/filesystems/expectations.txt new file +10
-0+ + An inherent problem with using flash as a normal block + device is that the flash erase size is bigger than + most filesystem sector sizes. So when you request a + write, it may erase and rewrite some 64k, 128k, or + even a couple megabytes on the really _big_ ones. + + If you lose power in the middle of that, filesystem + won't notice that data in the "sectors" _around_ the + one your were trying to write to got trashed.
The characteristic you descrive here is not an issue about whether the whole sector is either written or nothing happens to the data --- but rather, or at least in addition to that, there is also the issue that when a there is a flash card failure --- particularly one caused by a sucky flash card reader design causing the SD card to disconnect from the laptop in the middle of a write --- there may be "collateral damange"; that is, in addition to corrupting sector being writen, adjacent sectors might also end up getting list as an unfortunate side effect.
So there are actually two desirable properties for a storage system to have; one is "don't damage the old data on a failed write"; and the other is "don't cause collateral damage to adjacent sectors on a failed write".
Documentation/filesystems/expectations.txt line 40
Quoted 4 lines
Documentation/filesystems/expectations.txt new file +4
-0+ Because RAM tends to fail faster than rest of system during + powerfail, special hw killing DMA transfers may be necessary; + otherwise, disks may write garbage during powerfail. + Not sure how common that problem is on generic PC machines.
This problem is still relatively common, from what I can tell. And ext3 handles this surprisingly well at least in the catastrophic case of garbage getting written into the inode table, since the journal replay often will "repair" the garbage that was written into the filesystem metadata blocks. It won't do a bit of good for the data blocks, of course (unless you are using data=journal mode). But this means that in fact, ext3 is more resistant to suriving failures to the first problem (powerfail while writing can damage old data on a failed write) but fortunately, hard drives generally don't cause collateral damage on a failed write. Of course, there are some spectaular exemption to this rule --- a physical shock which causes the head to slam into a surface moving at 7200rpm can throw a lot of debris into the hard drive enclosure, causing loss to adjacent sectors.
- Ted
Hi!
Quoted 9 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Not all block devices are suitable for all filesystems. In fact, some block devices are so broken that reliable operation is pretty much impossible. Document stuff ext2/ext3 needs for reliable operation.
Some of what is here are bugs, and some are legitimate long-term interfaces (for example, the question of losing I/O errors when two processes are writing to the same file, or to a directory entry, and errors aren't or in some cases, can't, be reflected back to userspace).
Well, I guess there's thin line between error and "legitimate long-term interfaces". I still believe that fsync() is broken by design.
Quoted 3 lines
I'm a little concerned that some of this reads a bit too much like a rant (and I know Pavel was very frustrated when he tried to use a flash card with a sucky flash card socket) and it will get used the
It started as a rant, obviously I'd like to get away from that and get it into suitable format for inclusion. (Not being native speaker does not help here).
But I do believe that we should get this documented; many common storage subsystems are broken, and can cause data loss. We should at least tell to the users.
Quoted 4 lines
wrong way by apoligists, because it mixes areas where "we suck, we should do better", which a re bug reports, and "Posix or the underlying block device layer makes it hard", and simply states them as fundamental design requirements, when that's probably not true.
Well, I guess that can be refined later. Heck, I'm not able to tell which are simple bugs likely to be fixed soon, and which are fundamental issues that are unlikely to be fixed sooner than 2030. I guess it is fair to document them ASAP, and then fix those that can be fixed...
Quoted 4 lines
There's a lot of work that we could do to make I/O errors get better reflected to userspace by
fsync(). So state things as bald requirements I think goes a little too far IMHO. We can surely do better.
If the fsync() can be fixed... that would be great. But I'm not sure how easy that will be.
Quoted 11 lines
Review
Quoted 6 lines
(quoted diff) +6
-0+Write errors not allowed (NO-WRITE-ERRORS) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Writes to media never fail. Even if disk returns error condition +during write, filesystems can't handle that correctly, because success +on fsync was already returned when data hit the journal.The last half of this sentence "because success on fsync was already returned when data hit the journal", obviously doesn't apply to all filesystems, since some filesystems, like ext2, don't journal data. Even for ext3, it only applies in the case of data=journal mode.
Ok, I removed the explanation.
Quoted 7 lines
There are other issues here, such as
fsync()only reports an I/O problem to one caller, and in some cases I/O errors aren't propagated up the storage stack. The latter is clearly just a bug that should be fixed; the former is more of an interface limitation. But you don't talk about in this section, and I think it would be good to have a more extended discussion about I/O errors when writing data blocks, and I/O errors writing metadata blocks, etc.
Could you write a paragraph or two?
Quoted 8 lines
Review
Quoted 6 lines
(quoted diff) +6
-0+ +Sector writes are atomic (ATOMIC-SECTORS) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Either whole sector is correctly written or nothing is written during +powerfail.This requirement is not quite the same as what you discuss below.
Ok, you are right. Fixed.
Quoted 4 lines
So there are actually two desirable properties for a storage system to have; one is "don't damage the old data on a failed write"; and the other is "don't cause collateral damage to adjacent sectors on a failed write".
Thanks, its indeed clearer that way. I split those in two.
Quoted 9 lines
Review
Quoted 4 lines
(quoted diff) +4
-0+ Because RAM tends to fail faster than rest of system during + powerfail, special hw killing DMA transfers may be necessary; + otherwise, disks may write garbage during powerfail. + Not sure how common that problem is on generic PC machines.This problem is still relatively common, from what I can tell. And ext3 handles this surprisingly well at least in the catastrophic case of garbage getting written into the inode table, since the journal replay often will "repair" the garbage that was written into the
...
Ok, added to ext3 specific section. New version is attached. Feel free to help here; my goal is to get this documented, I'm not particulary attached to wording etc...
Pavel
Documentation/filesystems/expectations.txt new file +49 -0
@@ -0,0 +1,49 @@ +Linux block-backed filesystems can only work correctly when several +conditions are met in the block layer and below (disks, flash +cards). Some of them are obvious ("data on media should not change +randomly"), some are less so. + +Write errors not allowed (NO-WRITE-ERRORS) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Writes to media never fail. Even if disk returns error condition +during write, filesystems can't handle that correctly. + + Fortunately writes failing are very uncommon on traditional + spinning disks, as they have spare sectors they use when write + fails. + +Don't cause collateral damage to adjacent sectors on a failed write (NO-COLLATERALS) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Unfortunately, cheap USB/SD flash cards I've seen do have this bug, +and are thus unsuitable for all filesystems I know. + + An inherent problem with using flash as a normal block device + is that the flash erase size is bigger than most filesystem + sector sizes. So when you request a write, it may erase and + rewrite some 64k, 128k, or even a couple megabytes on the + really _big_ ones. + + If you lose power in the middle of that, filesystem won't + notice that data in the "sectors" _around_ the one your were + trying to write to got trashed. + + +Don't damage the old data on a failed write (ATOMIC-WRITES) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Either whole sector is correctly written or nothing is written during +powerfail. + + Because RAM tends to fail faster than rest of system during + powerfail, special hw killing DMA transfers may be necessary; + otherwise, disks may write garbage during powerfail. + This may be quite common on generic PC machines. + + Note that atomic write is very hard to guarantee for RAID-4/5/6, + because it needs to write both changed data, and parity, to + different disks. UPS for RAID array should help. + + +
Documentation/filesystems/ext2.txt +23 -20
50 lines not on this page · raw message
Documentation/filesystems/ext3.txt +39 -0
@@ -188,6 +200,45 @@ mke2fs: create a ext3 partition with the -j flag. debugfs: ext2 and ext3 file system debugger. ext2online: online (mounted) ext2 and ext3 filesystem resizer +Requirements +============ + +Ext3 expects disk/storage subsystem to behave sanely. On sanely +behaving disk subsystem, data that have been successfully synced will +stay on the disk. Sane means: + +* write errors not allowed (NO-WRITE-ERRORS) + +* don't damage the old data on a failed write (ATOMIC-WRITES) + + (Thrash may get written into sectors during powerfail. And + ext3 handles this surprisingly well at least in the + catastrophic case of garbage getting written into the inode + table, since the journal replay often will "repair" the + garbage that was written into the filesystem metadata blocks. + It won't do a bit of good for the data blocks, of course + (unless you are using data=journal mode). But this means that + in fact, ext3 is more resistant to suriving failures to the + first problem (powerfail while writing can damage old data on + a failed write) but fortunately, hard drives generally don't + cause collateral damage on a failed write. + +and obviously: + +* don't cause collateral damage to adjacent sectors on a failed write + (NO-COLLATERALS) + + +(see expectations.txt; note that most/all linux block-based +filesystems have similar expectations) + +* either write caching is disabled, or hw can do barriers and they are enabled. + + (Note that barriers are disabled by default, use "barrier=1" + mount option after making sure hw can support them). + + hdparm -I reports disk features. If you have "Native + Command Queueing" is the feature you are looking for. References ==========
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Documentation/filesystems/expectations.txt line 25
Quoted 3 lines · Pavel Machek
Documentation/filesystems/expectations.txt new file +3
-0+ Unfortunately, none of the cheap USB/SD flash cards I've seen + do behave like this, and are thus unsuitable for all Linux + filesystems I know.
When you say Linux filesystems do you mean "filesystems originally designed on Linux" or do you mean "filesystems that Linux supports"? Additionally whatever the answer, people are going to need help answering the "which is the least bad?" question and saying what's not good without offering alternatives is only half helpful... People need to put SOMETHING on these cheap (and not quite so cheap) devices... The last recommendation I heard was that until btrfs/logfs/nilfs arrive people are best off sticking with FAT -
http://marc.info/?l=linux-kernel&m=122398315223323&w=2 . Perhaps that should be mentioned?
Documentation/filesystems/ext3.txt mke2fs: create a ext3 partition with the -j flag. · line 223
Quoted 7 lines
Documentation/filesystems/ext3.txt +7
-0+* either write caching is disabled, or hw can do barriers and they are enabled. + + (Note that barriers are disabled by default, use "barrier=1" + mount option after making sure hw can support them). + + hdparm -I reports disk features. If you have "Native + Command Queueing" is the feature you are looking for.
The document makes it sound like nearly everything bar battery backed hardware RAIDed SCSI disks (with perfect firmware) is bad - is this the intent?
Signature · 1 line
Sitsofe | http://sucs.org/~sits/
Quoted 15 lines · On Monday 16 March 2009 14:40:57 Sitsofe Wheeler wrote:
Documentation/filesystems/expectations.txt line 25
Quoted 3 lines · Pavel Machek
Documentation/filesystems/expectations.txt new file +3
-0+ Unfortunately, none of the cheap USB/SD flash cards I've seen + do behave like this, and are thus unsuitable for all Linux + filesystems I know.When you say Linux filesystems do you mean "filesystems originally designed on Linux" or do you mean "filesystems that Linux supports"? Additionally whatever the answer, people are going to need help answering the "which is the least bad?" question and saying what's not good without offering alternatives is only half helpful... People need to put SOMETHING on these cheap (and not quite so cheap) devices... The last recommendation I heard was that until btrfs/logfs/nilfs arrive people are best off sticking with FAT -
http://marc.info/?l=linux-kernel&m=122398315223323&w=2 . Perhaps that should be mentioned?
Actually, the best filesystem for USB flash devices is probably UDF. (Yes, the DVD filesystem turns out to be writeable if you put it on a writeable media. The ISO spec requires write support, so any OS that supports DVDs also supports this.)
The reasons for this are:
A) It's the only filesystem other than FAT that's supported out of the box by windows, mac, _and_ Linux for hotpluggable media.
B) It doesn't have the horrible limitations of FAT (such as a max filesize of 2 gigabytes).
C) Microsoft doesn't claim to own it, and thus hasn't sued anybody over patents on it.
However, when it comes to cutting the power on a mounted filesystem (either by yanking the device or powering off the machine) without losing your data, without warning, they all suck horribly.
If you yank a USB flash disk in the middle of a write, and the device has decided to wipe a 2 megabyte erase sector that's behind a layer of wear levelling and thus consists of a series of random sectors scattered all over the disk, you're screwed no matter what filesystem you use. You know the vinyl "record scratch" sound? Imagine that, on a digital level. Bad Things Happen to the hardware, cannot compensate in software.
Quoted 11 lines
Documentation/filesystems/ext3.txt mke2fs: create a ext3 partition with the -j flag. · line 223
Quoted 7 lines
+* either write caching is disabled, or hw can do barriers and they are enabled. +
Documentation/filesystems/ext3.txt +5
-0+ (Note that barriers are disabled by default, use "barrier=1" + mount option after making sure hw can support them). + + hdparm -I reports disk features. If you have "Native + Command Queueing" is the feature you are looking for.The document makes it sound like nearly everything bar battery backed hardware RAIDed SCSI disks (with perfect firmware) is bad - is this the intent?
SCSI disks? They still make those?
Everything fails, it's just a question of how. Rotational media combined with journaling at least fails in fairly understandable ways, so ext3 on sata is reasonable.
Flash gets into trouble when it presents the _interface_ of rotational media (a USB block device with normal 512 byte read/write sectors, which never wear out) which doesn't match what the hardware's actually doing (erase block sizes of up to several megabytes at a time, hidden behind a block remapping layer for wear leveling).
For devices that have built in flash that DON'T pretend to be a conventional block device, but instead expose their flash erase granularity and let the OS do the wear levelling itself, we have special flash filesystems that can be reasonably reliable. It's just that ext3 isn't one of them, jffs2 and ubifs and logfs are. The problem with these flash filesystems is they ONLY work on flash, if you want to mount them on something other than flash you need something like a loopback interface to make a normal block device pretend to be flash. (We've got a ramdisk driver called "mtdram" that does this, but nobody's bothered to write a generic wrapper for a normal block device you can wrap over the loopback driver.)
Unfortunately, when it comes to USB flash (the most common type), the USB standard defines a way for a USB device to provide a normal block disk interface as if it was rotational media. It does NOT provide a way to expose the flash erase granularity, or a way for the operating system to disable any built-in wear levelling (which is needed because windows doesn't _do_ wear levelling, and thus burns out the administrative sectors of the disk really fast while the rest of the disk is still fine unless the hardware wear-levels for it).
So every USB flash disk pretends to be a normal disk, which it isn't, and Linux can't _disable_ this emulation. Which brings us back to UDF as the least sucky alternative. (Although the UDF tools kind of suck. If you reformat a FAT disk as UDF with mkudffs, it'll still be autodetected as FAT because it won't overwrite the FAT root directory. You have to blank the first 64k by hand with dd. Sad, isn't it?)
Rob
Quoted 6 lines · Rob Landley
Flash gets into trouble when it presents the _interface_ of rotational media (a USB block device with normal 512 byte read/write sectors, which never wear out) which doesn't match what the hardware's actually doing (erase block sizes of up to several megabytes at a time, hidden behind a block remapping layer for wear leveling).
Quoted 10 lines
For devices that have built in flash that DON'T pretend to be a conventional block device, but instead expose their flash erase granularity and let the OS do the wear levelling itself, we have special flash filesystems that can be reasonably reliable. It's just that ext3 isn't one of them, jffs2 and ubifs and logfs are. The problem with these flash filesystems is they ONLY work on flash, if you want to mount them on something other than flash you need something like a loopback interface to make a normal block device pretend to be flash. (We've got a ramdisk driver called "mtdram" that does this, but nobody's bothered to write a generic wrapper for a normal block device you can wrap over the loopback driver.)
The really nice SSDs actually reserve ~15-30% of their internal block-level storage and actually run their own log-structured virtual disk in hardware. From what I understand the Intel SSDs are that way.
Real-time garbage collection is tricky, but if you require (for
example) a max of ~80% utilization then you can provide good latency and bandwidth guarantees. There's usually something like a log-structured virtual-to-physical sector map as well. If designed properly with automatic hardware checksumming, such a system can actually provide atomic writes and barriers with virtually no impact on performance.
With firmware-level hardware knowledge and the ability to perform extremely efficient parallel reads of flash blocks, such a log-structured virtual block device can be many times more efficient than a general purpose OS running a log-structured filesystem. The result is that for an ordinary ext3-esque filesystem with 4k blocks you can treat the SSD as though it is an atomic-write seek-less block device.
Now if only I had the spare cash to go out and buy one of the shiny Intel ones for my laptop... :-)
Cheers,
Kyle Moffett
Quoted 7 lines · Sitsofe Wheeler
Documentation/filesystems/expectations.txt line 25
Quoted 3 lines · Pavel Machek
Documentation/filesystems/expectations.txt new file +3
-0+ Unfortunately, none of the cheap USB/SD flash cards I've seen + do behave like this, and are thus unsuitable for all Linux + filesystems I know.When you say Linux filesystems do you mean "filesystems originally designed on Linux" or do you mean "filesystems that Linux supports"?
"Linux filesystems I know" :-). No filesystem that Linux supports, AFAICT.
Quoted 5 lines
Additionally whatever the answer, people are going to need help answering the "which is the least bad?" question and saying what's not good without offering alternatives is only half helpful... People need to put SOMETHING on these cheap (and not quite so cheap) devices... The
According to me, people should just AVOID those devices. I don't plan to point the "least bad"; its still bad.
Quoted 6 lines
Documentation/filesystems/ext3.txt mke2fs: create a ext3 partition with the -j flag. · line 223
Quoted 2 lines
Documentation/filesystems/ext3.txt +2
-0+ hdparm -I reports disk features. If you have "Native + Command Queueing" is the feature you are looking for.The document makes it sound like nearly everything bar battery backed hardware RAIDed SCSI disks (with perfect firmware) is bad - is this the intent?
Battery backed RAID should be ok, as should be plain single SATA drive.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Quoted 9 lines · Rob Landley
Documentation/filesystems/ext2.txt enough 4-character names to make up unique directory entries, so they · line 357
Quoted 2 lines
Documentation/filesystems/ext2.txt +2
-0+* write caching is disabled. ext2 does not know how to issue barriers + as of 2.6.28. hdparm -W0 disables it on SATA disks.And here we're talking about ext2. Does neither one know about write barriers, or does this just apply to ext2? (What about ext4?)
Also I remember a historical problem that not all disks honor write barriers, because actual data integrity makes for horrible benchmark numbers. Dunno how current that is with SATA, Alan Cox would probably know.
I've heard rumors of disks that claim to support cache flushes but really just ignore them, but have never heard any specifics of model numbers, etc. which are known to do this, so it may just be legend. If we do have such knowledge then we should really be blacklisting those drives and warning the user that we can't ensure data integrity. (Even powering down the system would be unsafe in this case.)
Quoted 6 lines
I've heard rumors of disks that claim to support cache flushes but really just ignore them, but have never heard any specifics of model numbers, etc. which are known to do this, so it may just be legend. If we do have such knowledge then we should really be blacklisting those drives and warning the user that we can't ensure data integrity. (Even powering down the system would be unsafe in this case.)
This should not be the case for any vaguely modern drive. The standard requires the drive flushes the cache if sent the command and the size of caches on modern drives rather require it.
Alan
On Thu, Mar 12, 2009 at 5:21 AM, Pavel Machek <[email protected]> wrote:
<snip>
Quoted 9 lines
Documentation/filesystems/expectations.txt new file +9
-0+Sector writes are atomic (ATOMIC-SECTORS) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Either whole sector is correctly written or nothing is written during +powerfail. + + Unfortuantely, none of the cheap USB/SD flash cards I seen do + behave like this, and are unsuitable for all linux filesystems + I know.
Documentation/filesystems/expectations.txt line 35
Quoted 10 lines
Documentation/filesystems/expectations.txt new file +10
-0+ + An inherent problem with using flash as a normal block + device is that the flash erase size is bigger than + most filesystem sector sizes. So when you request a + write, it may erase and rewrite the next 64k, 128k, or + even a couple megabytes on the really _big_ ones. + + If you lose power in the middle of that, filesystem + won't notice that data in the "sectors" _around_ the + one your were trying to write to got trashed.
I had *assumed* that SSDs worked like:
1) write request comes in
2) new unused erase block area marked to hold the new data
3) updated data written to the previously unused erase block
4) mapping updated to replace the old erase block with the new one
If it were done that way, a failure in the middle would just leave the SSD with the old data in it.
If it is not done that way, then I can see your issue. (I love the potential performance of SSDs, but I'm beginning to hate the implementations and spec writing.)
Greg
Signature · 14 lines
Greg Freemyer Head of EDD Tape Extraction and Processing team Litigation Triage Solutions Specialist http://www.linkedin.com/in/gregfreemyer First 99 Days Litigation White Paper - http://www.norcrossgroup.com/forms/whitepapers/99%20Days%20whitepaper.pdf The Norcross Group The Intersection of Evidence & Technology http://www.norcrossgroup.com -- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 24 lines · Greg Freemyer
On Thu, Mar 12, 2009 at 5:21 AM, Pavel Machek <[email protected]> wrote:
<snip>Quoted 9 lines
Documentation/filesystems/expectations.txt new file +9
-0+Sector writes are atomic (ATOMIC-SECTORS) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Either whole sector is correctly written or nothing is written during +powerfail. + + Unfortuantely, none of the cheap USB/SD flash cards I seen do + behave like this, and are unsuitable for all linux filesystems + I know.Documentation/filesystems/expectations.txt line 35
Quoted 10 lines
Documentation/filesystems/expectations.txt new file +10
-0+ + An inherent problem with using flash as a normal block + device is that the flash erase size is bigger than + most filesystem sector sizes. So when you request a + write, it may erase and rewrite the next 64k, 128k, or + even a couple megabytes on the really _big_ ones. + + If you lose power in the middle of that, filesystem + won't notice that data in the "sectors" _around_ the + one your were trying to write to got trashed.I had *assumed* that SSDs worked like:
Quoted 7 lines
1) write request comes in
2) new unused erase block area marked to hold the new data
3) updated data written to the previously unused erase block
4) mapping updated to replace the old erase block with the new oneIf it were done that way, a failure in the middle would just leave the SSD with the old data in it.
The really expensive ones (Intel SSD) apparently work like that, but I never seen one of those. USB sticks and SD cards I tried behave like I described above.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html