Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
ext4: Preventing corruption on power loss/crash
View unanswered posts
View posts from last 24 hours

Goto page 1, 2  Next  
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
haarp
Guru
Guru


Joined: 31 Oct 2007
Posts: 366

PostPosted: Thu Oct 17, 2013 9:09 pm    Post subject: ext4: Preventing corruption on power loss/crash Reply with quote

Hey,

my main Gentoo machines recently had some problems with power management and switched off suddenly. One might assume that modern journaling fs could handle this, but nooo. On the next boot, I am greeted by funny messages such as:
Code:
ext4_orphan_cleanup: deleting unreferenced inode 123456

and indeed, some files are now missing or got emptied. Another machine of mine, Debian this time, experienced uncorrectable RAM ECC errors which triggered an instant reset. Ok, gotta replace the memory module soon, but at least my data is fine. Ooh wait, ext4 screwed up, leaving me with nuked files.

In both cases, standard mount options were used. Kernels were 3.5 and 3.2 series.

Since it is apparently impossible to recover the filenames involved, I have to live with the fact that ext4's suckiness corrupted random files on the system with no way whatsoever for me to restore them from backups (which do exist), because it never told me the name of the files, only the inode number.

However, I would like to prevent this from happening in the future. ext4 has a ton of different mount options, with many unclear explanations, hundreds of sites on the Internet providing outdated or conflicting information and different recommendations. It is impossible for me to determine what to do. I just want my fs to be power-loss-proof without having to go to extreme measures (such as mounting sync; 2MB/s write speed is not acceptable)

And please, don't recommend xfs/jfs/zfs/reiser4/btrfs or other experiments. I'd like to stay with the stable ext-series (despite recent events having disproven ext4's stableness for me)

Thanks!


Last edited by haarp on Thu Oct 17, 2013 9:35 pm; edited 1 time in total
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 31716
Location: 56N 3W

PostPosted: Thu Oct 17, 2013 9:30 pm    Post subject: Reply with quote

haarp,

No filesystem will maintain your data in the face of a loss of power.
You need a UPS.

You also need backups. ECC errors are hardware related. the drive can no longer read its own writing, at least, for the ECC affected sectors.

If its really impossible to recover your files from your backups, your backups are not worth the time you spent creating and validating them.
You did validate them so you know they are good didn't you?
You may not want to put the effort in to identify and restore affected files but thats a value judgement only you can make.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
haarp
Guru
Guru


Joined: 31 Oct 2007
Posts: 366

PostPosted: Thu Oct 17, 2013 9:33 pm    Post subject: Reply with quote

NeddySeagoon wrote:
haarp,

No filesystem will maintain your data in the face of a loss of power.
You need a UPS.

You also need backups. ECC errors are hardware related. the drive can no longer read its own writing, at least, for the ECC affected sectors.

If its really impossible to recover your files from your backups, your backups are not worth the time you spent creating and validating them.
You did validate them so you know they are good didn't you?
You may not want to put the effort in to identify and restore affected files but thats a value judgement only you can make.

Thanks for your answer, but sorry Ned, you seem to misunderstand a few things ;)

- An UPS will not prevent my laptop from failing to suspend properly, which has been one cause of power loss for me.

- I am referring to memory ECC errors, which happened due to a faulty DIMM which has been replaced.

- I can restore anything from backup, but I need to know WHAT I need to restore first! Just an inode number is useless to me.
Back to top
View user's profile Send private message
Hu
Watchman
Watchman


Joined: 06 Mar 2007
Posts: 8848

PostPosted: Thu Oct 17, 2013 9:44 pm    Post subject: Reply with quote

Your laptop will fail to resume from suspend properly if:
  • The BIOS is buggy. Bug your vendor.
  • The kernel is buggy. This is usually fixed in short order.
  • You run out of power. See: UPS.
  • You hold down the powerbutton and force an unclean halt. Do not do this.
More generally, your suspend process should leave the filesystem in a recoverable state even in the event of power failure. As far as I know, all the major techniques force a filesystem sync before halting. You will need an fsck afterward to clean up orphans, but no valid files should go missing. If they do, I would consider that a kernel-related filesystem bug.

As regards backups, I suggest you begin by restoring files that are present in the backup and absent on disk. This may restore files that were intentionally removed after the backup was created, but you can redo the deletion of those later.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 31716
Location: 56N 3W

PostPosted: Thu Oct 17, 2013 9:51 pm    Post subject: Reply with quote

haarp,

You have a laptop with ECC RAM?
Thats rare.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
haarp
Guru
Guru


Joined: 31 Oct 2007
Posts: 366

PostPosted: Thu Oct 17, 2013 9:59 pm    Post subject: Reply with quote

Come on guys, I know that fixing the cause of unclean shutdowns would be preferable. But as we all know, shit happens. ;) Making ext4 as durable as possible remains the best realistic option.

NeddySeagoon wrote:
haarp,

You have a laptop with ECC RAM?
Thats rare.

No, I have a separate Microserver which uses ECC RAM. Both it and the laptop recently experienced filesystem corruption due to sudden reboots/shutdowns
Back to top
View user's profile Send private message
Jaglover
Advocate
Advocate


Joined: 29 May 2005
Posts: 4613
Location: Saint Amant, Acadiana

PostPosted: Thu Oct 17, 2013 10:01 pm    Post subject: Reply with quote

haarp,

when it comes to reliability in case of power loss and performance these things are mutually exclusive.
_________________
Please learn how to denote units correctly!
Back to top
View user's profile Send private message
Hu
Watchman
Watchman


Joined: 06 Mar 2007
Posts: 8848

PostPosted: Thu Oct 17, 2013 11:00 pm    Post subject: Reply with quote

Negative external events cannot be completely prevented, but modern consumer-level equipment can arrange for you to have a clean shutdown in the vast majority of cases. A battery backup that warns the system of imminent power failure, well tested code, and a mollyguard should prevent all but the worst scenarios. If you more clearly articulate the nature of the power problems you experienced, we may be able to provide better advice about how to protect against it.
Back to top
View user's profile Send private message
zeronullity
Tux's lil' helper
Tux's lil' helper


Joined: 16 Oct 2010
Posts: 94

PostPosted: Thu Oct 17, 2013 11:22 pm    Post subject: Reply with quote

Resume on suspend S3 is hard one to troubleshoot and is what I'm currently working on myself.
You can try a pm_trace which might copy useful information to your rtc memory during a kernel panic on resume.
Also disabling HDD write cache will help prevent loss of information.. and I know it's a laptop but if you have a extra drive in the system.
software raid might not hurt either. Of course disable hibernate/suspend until you can get it correctly resolved.. just make sure
you backup your data. A raid/file system rebuild is normal after any power loss.. it doesn't mean you lost any data.. You could keep a file
list with check sums for verification and compare it to backed up data.. if your paranoid.
Back to top
View user's profile Send private message
nlsa8z6zoz7lyih3ap
Guru
Guru


Joined: 25 Sep 2007
Posts: 328
Location: Canada

PostPosted: Fri Oct 18, 2013 12:09 am    Post subject: Reply with quote

Quote:
However, I would like to prevent this from happening in the future. ext4 has a ton of different mount options, with many unclear explanations, hundreds of sites on the Internet providing outdated or conflicting information and different recommendations. It is impossible for me to determine what to do. I just want my fs to be power-loss-proof without having to go to extreme measures (such as mounting sync; 2MB/s write speed is not acceptable)


Although I have not suffered loss such as you have, the questions of mount options has intrigued me for some time. Here is a line from my /etc/fstab
Code:
/dev/root       /               ext4         noatime,noauto_da_alloc,barrier=1,commit=10        0 1


My hope is that this is safer than the default options, but I have no idea if this is true. I would appreciate it if anyone has any comments.

DATA LOSS Once when on holidays We lost (perhaps I accidentally deleted them) all of our digital photo files on my wife's laptop. I immediately unmounted the partition in question
and used sys-fs/ext4magic and sys-fs/extundelete to attempt to get them back. We got about 80% of them back, 'tho the sorting into folders was mostly lost.
I think that at least one of these programs read as much of the journal logfile as it still has, to find the deleted files. Of course this will not likely work on files deleted in the distant past.
Time is of the essence.
COMMENT I always have 2 working Gentoo root partitions, (just before any emerge -uvDN @world) I sync the second root partition from he first.
That way if I break anything or have problems, I can easily restore from the 2nd to the first or boot to the 2nd to repair the first. This is like having a built in live recovery cd, in fact it is even better because of the high compatibility of the 2 root partitions.
Back to top
View user's profile Send private message
kernelOfTruth
Watchman
Watchman


Joined: 20 Dec 2005
Posts: 5675
Location: Vienna, Austria; Germany; hello world :)

PostPosted: Sun Oct 20, 2013 7:37 pm    Post subject: Reply with quote

*subscribes*

might run into this in the future, too / again

so I have a marker / post to look for



afaik with newer kernel versions ext4 is in much better shape,

but corruption/data loss can still happen



@haarp:

you're another fellow HP MicroServer user ? :)

(I still have to set up/fully install that beast ^^ )
_________________
Unofficial minimal livecd x86/amd64 w/reiser4+truecrypt (by Neo2)
2.6.37.2_plus_v1: BFS, CFS,THP,compaction, zcache or TOI
Hardcore Linux user since 2004 :D
Back to top
View user's profile Send private message
haarp
Guru
Guru


Joined: 31 Oct 2007
Posts: 366

PostPosted: Mon Oct 21, 2013 4:05 pm    Post subject: Reply with quote

kernelOfTruth wrote:
*subscribes*
@haarp:

you're another fellow HP MicroServer user ? :)

(I still have to set up/fully install that beast ^^ )

Oh, yeah! N40L here. 16GB ECC RAM and 2x 3TB in RAID0. Not that impressive, but it's a cool machine. Of course a year later the N54L came out :roll:. Wish I'd gotten that, the N40L is quite slow with encryption. And I get to RMA the memory modules now, which is a pita
Back to top
View user's profile Send private message
ryao
Developer
Developer


Joined: 27 Feb 2012
Posts: 122

PostPosted: Thu Oct 24, 2013 2:15 pm    Post subject: Re: ext4: Preventing corruption on power loss/crash Reply with quote

haarp wrote:
Hey,

my main Gentoo machines recently had some problems with power management and switched off suddenly. One might assume that modern journaling fs could handle this, but nooo. On the next boot, I am greeted by funny messages such as:
Code:
ext4_orphan_cleanup: deleting unreferenced inode 123456

and indeed, some files are now missing or got emptied. Another machine of mine, Debian this time, experienced uncorrectable RAM ECC errors which triggered an instant reset. Ok, gotta replace the memory module soon, but at least my data is fine. Ooh wait, ext4 screwed up, leaving me with nuked files.

In both cases, standard mount options were used. Kernels were 3.5 and 3.2 series.

Since it is apparently impossible to recover the filenames involved, I have to live with the fact that ext4's suckiness corrupted random files on the system with no way whatsoever for me to restore them from backups (which do exist), because it never told me the name of the files, only the inode number.

However, I would like to prevent this from happening in the future. ext4 has a ton of different mount options, with many unclear explanations, hundreds of sites on the Internet providing outdated or conflicting information and different recommendations. It is impossible for me to determine what to do. I just want my fs to be power-loss-proof without having to go to extreme measures (such as mounting sync; 2MB/s write speed is not acceptable)

And please, don't recommend xfs/jfs/zfs/reiser4/btrfs or other experiments. I'd like to stay with the stable ext-series (despite recent events having disproven ext4's stableness for me)

Thanks!


What you want is not possible with the current ext4 code. Let me give you a brief explanation of file systems. They typically consists of 4 primary things:


  1. The superblock, which describes the filesystem itself. It contains things like the free block list, free inode list, information about filesystem features, etcetera.
  2. The inode, which describes a file's contents and metadata.
  3. The dentry, which is a list of names and inode numbers.
  4. Direct blocks, which store data; indirect blocks, which store pointers to direct blockers; 2nd level indirect blocks, which store pointers to indirect blocks; etcetera.


This basically describes UFS and ext2. ext3 added journalling and ext4 added extents, but for our purposes, we can think about filesystems in terms of this. When you create a file, several things need to be done. Specifically, the following:


  1. You need to allocate an inode by removing an entry from the free inode list.
  2. You need to write to the block containing the inode.
  3. You need to link that inode to a directory by updating the dentry for the directory in which the file was created. The dentry itself is a file, which has its own inode. Therefore we need to modify that file.


This is just one operation, but for the purposes of an example, this should suffice. Ideally, these changes are done in both memory and on disk. However, updating disk structures is slow, so what we can do is just update the memory structures and then do all of the changes needed to perform the file creation asynchronously. Lets imagine doing this with many different files in parallel and suddenly have a kernel panic. Well, things are in varying states of completion. To make matters worse, the directory entries can span multiple blocks and we could have updated that spanned multiple blocks, especially if we were trying to keep things approximately sorted.

If we are clever, we can make this better by implementing a journal. That way, we can record everything we did as part of a journal transaction and replay it to figure out how to make things sane. Unfortunately, doing journalling correctly is slow, so we cut corners by only journalling metadata. That means that we journal changes to inodes and dentries, but not to the direct or indirect blocks. Lets assume that we can implement that perfectly (even though we likely won't). That is great, but the hardware manufacturer wanted things to go fast, so they decided to start doing write buffering and write reordering stuff on us. Therefore, while we think we just wrote something (we got back completion from the underlying device; yay!), we really only moved the information about the change from the system memory to the disk's microcontroller's memory. Since we think we just successfully did a write, the data blocks used to store the journal entries in our perfect journal can now be recycled and we do the next journal transaction. To make things even more fun, the next journal transaction can be written before the previous one. The hardware can also do other neat things, like suffer from bit flips that cause the write that you thought was going to sector X to instead go to sector Y. That is not mentioning uncorrectable errors that SMART detects, in which case, a sector suddenly disappears.

Are you beginning to see how things can go wrong? In reality, filesystems have become far more complicated than what I described, making it much harder to get things right. We have ACLs, extended attributes, extents, etcetera. At the same time, demands for performance have increased. We have highly concurrent systems and even more VFS APIs for trying to get the most concurrency that we can out of storage (e.g. asynchronous IO). Filesystem designers are employed primarily to address business concerns. Specifically, those are getting more stuff done in less time. This can explains design decisions made in the ext2/ext3/ext4 series of file systems. To cite specific examples, the use of metadata journalling and according the the Linux kernel documentation, the failure to implement performance tweaks for full journalling (data + metadata) make sense given the demand for performance.

To provide an answer that is more useful to your question, I will say that you can get a little better reliability from ext4 by enabling full journalling, but this will come at the cost of a significant performance penalty that is even greater than the theoretical penalty because tweaks to implement full journalling efficiently have not been done in ext3/ext4. This will not eliminate all potential ills, but it should be better than what you have now. That being said, there is room for further improvement in the area of reliability, even without designing a new filesystem. Specifically, it is possible to implement ext4 in such a way that unclean shutdowns will always produce a filesystem that can be immediately mounted, where the only problem is a space leak and any instance of such a leak could be fixed with an online consistency check. This was done with UFS in FreeBSD. It is called UFS Soft Updates:

http://jeffr-tech.livejournal.com/22716.html

The same could be done in Linux with ext4. However, there are multiple reasons why kernel developers would not work on this. To name some:


  1. Implementing soft updates is hard.
  2. Anyone trying to improve ext2/ext3/ext4 will constrained by filesystem design decisions of the 1970s that have been shown to be flawed.
  3. There are newer filesystems that started from a clean slate, avoided many of the problems that 1970s filesystem designs had and today are better than any hypothetical improvement to ext2/ext3/ext4. ZFS being the prime example.
  4. It is difficult to convince a corporation to fund such changes to a legacy code base when replacements exist that are superior to what you expect to obtain after the improvements.


With that said, the orphan clean up does not necessarily mean that something was damaged, but that largely depends on how it became an orphan. If it became an orphan because the only directory entry linked to it was damaged by a misdirected write or sudden power failure event, then you just lost data (and you would likely have a directory that looks like it has garbage. If it became an orphan because the last directory reference to it was unlinked and it was not returned to the free list (which is permissible because open file handles count as links), then that is okay.
Back to top
View user's profile Send private message
mv
Advocate
Advocate


Joined: 20 Apr 2005
Posts: 4009

PostPosted: Thu Oct 24, 2013 5:14 pm    Post subject: Re: ext4: Preventing corruption on power loss/crash Reply with quote

ryao wrote:
That is great, but the hardware manufacturer wanted things to go fast, so they decided to start doing write buffering and write reordering stuff on us.

That's why barriers exist which solve this problem if neither software nor hardware is buggy.
Back to top
View user's profile Send private message
ryao
Developer
Developer


Joined: 27 Feb 2012
Posts: 122

PostPosted: Thu Oct 24, 2013 5:40 pm    Post subject: Re: ext4: Preventing corruption on power loss/crash Reply with quote

mv wrote:
ryao wrote:
That is great, but the hardware manufacturer wanted things to go fast, so they decided to start doing write buffering and write reordering stuff on us.

That's why barriers exist which solve this problem if neither software nor hardware is buggy.


I suggest that you read this:

https://queue.acm.org/detail.cfm?id=2367378
Back to top
View user's profile Send private message
Gentree
Watchman
Watchman


Joined: 01 Jul 2003
Posts: 5227
Location: France, Old Europe

PostPosted: Thu Oct 24, 2013 11:10 pm    Post subject: Reply with quote

I used reiser4 for many years precisely because of power unreliability. Currently get one or two brown-outs per day. The R4 atomic write strategy seems quite effective.

Unfortunately it never got integrated into mainline and is now history. I had to buy a UPS.
_________________
Linux, because I'd rather own a free OS than steal one that's not worth paying for.

AthlonXP-M on A7N8X @ 2.6/2.4GHz (winter/summer)
2.6.32-hh1 : portage ~x86
Back to top
View user's profile Send private message
ryao
Developer
Developer


Joined: 27 Feb 2012
Posts: 122

PostPosted: Thu Oct 24, 2013 11:23 pm    Post subject: Reply with quote

Gentree wrote:
I used reiser4 for many years precisely because of power unreliability. Currently get one or two brown-outs per day. The R4 atomic write strategy seems quite effective.

Unfortunately it never got integrated into mainline and is now history. I had to buy a UPS.


Reiser4 is still maintained:

http://sourceforge.net/projects/reiser4/files/reiser4-for-linux-3.x/
Back to top
View user's profile Send private message
Gentree
Watchman
Watchman


Joined: 01 Jul 2003
Posts: 5227
Location: France, Old Europe

PostPosted: Thu Oct 24, 2013 11:43 pm    Post subject: Reply with quote

Hey, Shishkin is still active on that , great. I thought he'd had to drop it since being bought up by RH.

Thanks for the info. Having just converted all my partitions to ext4 in anticipation of this kernel up date, I can now change them back again! LOL.

thanks 8)
_________________
Linux, because I'd rather own a free OS than steal one that's not worth paying for.

AthlonXP-M on A7N8X @ 2.6/2.4GHz (winter/summer)
2.6.32-hh1 : portage ~x86
Back to top
View user's profile Send private message
mv
Advocate
Advocate


Joined: 20 Apr 2005
Posts: 4009

PostPosted: Fri Oct 25, 2013 4:50 pm    Post subject: Re: ext4: Preventing corruption on power loss/crash Reply with quote

ryao wrote:
mv wrote:
ryao wrote:
That is great, but the hardware manufacturer wanted things to go fast, so they decided to start doing write buffering and write reordering stuff on us.

That's why barriers exist which solve this problem if neither software nor hardware is buggy.


I suggest that you read this:

https://queue.acm.org/detail.cfm?id=2367378

I talked about barriers, not about syncing. Barriers avoid the reorder problems (if software and hardware correctly follows them) and thus avoids all the problems you mentioned which are only implicit consequences of this.
Back to top
View user's profile Send private message
CkoTuHa
n00b
n00b


Joined: 27 Mar 2009
Posts: 74

PostPosted: Sat Oct 26, 2013 4:09 pm    Post subject: Re: ext4: Preventing corruption on power loss/crash Reply with quote

mv wrote:
ryao wrote:
mv wrote:
ryao wrote:
That is great, but the hardware manufacturer wanted things to go fast, so they decided to start doing write buffering and write reordering stuff on us.

That's why barriers exist which solve this problem if neither software nor hardware is buggy.


I suggest that you read this:

https://queue.acm.org/detail.cfm?id=2367378

I talked about barriers, not about syncing. Barriers avoid the reorder problems (if software and hardware correctly follows them) and thus avoids all the problems you mentioned which are only implicit consequences of this.


ffs, can you come down from the radical fundamentalist-dualist point of view of yours to something more practical.

Barriers, two-phase commit, etc are all fine techniques to alleviate the issues that you have heard of.

But what ryao is implying is that you can't really trust your disk controller. Read this: if, for instance, you can't trust your hardware when it says "commit done" how are you going to implement something reliable on top of that ? The answer is that you can't.
Back to top
View user's profile Send private message
Hu
Watchman
Watchman


Joined: 06 Mar 2007
Posts: 8848

PostPosted: Sat Oct 26, 2013 4:41 pm    Post subject: Reply with quote

The optimizations that ryao described are useful and there is no serious harm in having the hardware report completion as soon as it is ready for the OS to move on. As I read mv's post, hardware which claims to implement barriers and reports completion before it is truly done is not implementing barriers properly. I do not believe ryao was asserting that you can never trust the disk controller to get anything right. Rather, he was describing that if you want the hardware to take an action, you need to be sure to request that action explicitly, rather than relying on the implementation taking that action as a side effect of doing what you requested. In this case, if you want a strong guarantee that data has been written, ask for it by issuing a barrier. If you just need the data to be scheduled for eventual write, then you can assume a completion report means the disk will get to it if power does not fail first.
Back to top
View user's profile Send private message
ryao
Developer
Developer


Joined: 27 Feb 2012
Posts: 122

PostPosted: Sun Oct 27, 2013 7:44 pm    Post subject: Reply with quote

Hu wrote:
The optimizations that ryao described are useful and there is no serious harm in having the hardware report completion as soon as it is ready for the OS to move on. As I read mv's post, hardware which claims to implement barriers and reports completion before it is truly done is not implementing barriers properly. I do not believe ryao was asserting that you can never trust the disk controller to get anything right. Rather, he was describing that if you want the hardware to take an action, you need to be sure to request that action explicitly, rather than relying on the implementation taking that action as a side effect of doing what you requested. In this case, if you want a strong guarantee that data has been written, ask for it by issuing a barrier. If you just need the data to be scheduled for eventual write, then you can assume a completion report means the disk will get to it if power does not fail first.


The tricks done by hardware make it very easy for changes made by file system developers to introduce subtle reliability problems that are not easily realized until something goes wrong in front of the developers. The competing demands to produce something that performs as well as possible and does not immediately eat all of the data given to it make this more likely to happen than you would expect. Even if they do everything right, the hardware can still mess up by reading/writing to the wrong sectors or failing to return what was written due to an uncorrectable error caused by the ECC calculations on the low level formatting. ZFS is one of the few filesystems that implements the redundancy and checksums required to handle that.

That is why the original poster's request for mount options that prevent things from going wrong is impossible satisfy, which was my point.
Back to top
View user's profile Send private message
mv
Advocate
Advocate


Joined: 20 Apr 2005
Posts: 4009

PostPosted: Mon Oct 28, 2013 8:44 am    Post subject: Reply with quote

Hu wrote:
if you want a strong guarantee that data has been written, ask for it by issuing a barrier.

AFAIK barriers do not guarantee a write - this probably cannot be guaranteed with current hardware.
What barriers do guarantee is that actions coming after a barrier are not reordered before any action before the barrier.
In particular, if you write to a journal, then commit a barrier, then write the actual data, and then commit a second barrier, you can be sure that the journal is written before committing to disk, i.e. in case of a powerloss then, depending whether this happens before or after the barrier, either you have a broken journal, or the journal has not yet been played back completely, respectively.
Back to top
View user's profile Send private message
mv
Advocate
Advocate


Joined: 20 Apr 2005
Posts: 4009

PostPosted: Mon Oct 28, 2013 8:50 am    Post subject: Reply with quote

ryao wrote:
Even if they do everything right, the hardware can still mess up by reading/writing to the wrong sectors or failing to return what was written due to an uncorrectable error caused by the ECC calculations on the low level formatting

Indeed, I have here sometimes a powerloss of about 1 second: Whenever this happens, it is usually not enough that the system halts immediately, but there is enough rubbish in ram which is then written to disk, so that afterwards usually my ext4 filesystem is completely broken and can at most be repaired with tricks like using the second copy of the superblock etc. I enabled all possibilities like journal_cecksum etc, but nothing helped.
Back to top
View user's profile Send private message
ryao
Developer
Developer


Joined: 27 Feb 2012
Posts: 122

PostPosted: Mon Oct 28, 2013 6:52 pm    Post subject: Reply with quote

mv wrote:
Hu wrote:
if you want a strong guarantee that data has been written, ask for it by issuing a barrier.

AFAIK barriers do not guarantee a write - this probably cannot be guaranteed with current hardware.
What barriers do guarantee is that actions coming after a barrier are not reordered before any action before the barrier.
In particular, if you write to a journal, then commit a barrier, then write the actual data, and then commit a second barrier, you can be sure that the journal is written before committing to disk, i.e. in case of a powerloss then, depending whether this happens before or after the barrier, either you have a broken journal, or the journal has not yet been played back completely, respectively.


For what it is worth, Linux's block subsystem does not do barriers anymore:

http://lwn.net/Articles/399715/
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum