SU+J Lost files after a power failure
freebsd at edvax.de
Tue Oct 15 05:31:04 UTC 2013
On Mon, 14 Oct 2013 14:04:45 -0700, Charles Swiger wrote:
> First, unless you call fsync() before close() and your OS
> and/or drive hardware isn't being deceptive when fsync()
> returns about whether the bits have made it to permanent
> storage, then you might be surprised at just how long the
> unwritten buffers containing the last updates to the file
> data take to get properly flushed to disk.
The problem here is that it's hard to _predict_ the time
needed to actually finish the desired writing operation.
The library function will interact with the kernel, the
kernel with the file system driver, which in turn will
address the storage subsystem, which will address the
hard disk driver to tell the disk what to do. Then the
disk will also take some time to perform that operation.
I assume unless you have a system in place that explcitely
expects a "receipt" from the disk up through all those
layers that the data has been stored, you can't fully be
sure. So even if you call fsync() and immediately after
this a power outage occurs, the disk might not have been
Unmounting a disk will usually make sure all remaining
buffers have been written. Given the previously described
stack of involved layers, it might still be good to be a
little bit paranoid regarding this assumption. :-)
Your characterization of the inner workings of a SSD (and
how efficient its firmware is implemented) stengthens this
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...
More information about the freebsd-questions