On 06/11/2013 05:56 AM, Steve Bergman wrote:
4. From the time I write() a bit of data, what's the maximum time before the
data is actually committed to disk?
5. Ext4 provides some automatic fsync'ing to avoid the zero-length file
issue for some common cases via the auto_da_alloc feature added in kernel
2.6.30. Does XFS have similar behavior?
I think that here you are talking more about ext3 than ext4.
The answer to both of these - even for ext4 or ext3 - is that unless your
application and storage is all properly configured, you are effectively at risk
indefinitely. Chris Mason did a study years ago where he was able to demonstrate
that dirty data could get pinned in a disk cache effectively indefinitely. Only
an fsync() would push that out.
Applications need to use the data integrity hooks in order to have a reliable
promise that application data is crash safe. Jeff Moyer wrote up a really nice
overview of this for lwn which you can find here:
That said, if you have applications that do not do any of this, you can roll the
dice and use a file system like ext3 that will periodically push data out of the
page cache for you.
Note that without the barrier mount option, that is not sufficient to push data
to platter, just moves it down the line to the next potentially volatile cache
:) Even then, 4 out of every 5 seconds, your application will be certain to
lose data if the box crashes while it is writing data. Lots of applications
don't actually use the file system much (or write much), so ext3's sync
behaviour helped mask poorly written applications pretty effectively for quite a
There really is no short cut to doing the job right - your applications need to
use the correct calls and we all need to configure the file and storage stack