Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 15 Oct 2013 07:30:48 +0200
From:      Polytropon <>
To:        Charles Swiger <>
Cc:        FreeBSD Questions <>
Subject:   Re: SU+J Lost files after a power failure
Message-ID:  <>
In-Reply-To: <>
References:  <> <l3gc7e$c91$> <> <> <> <> <> <> <> <> <>

Next in thread | Previous in thread | Raw E-Mail | Index | Archive | Help
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

Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...

Want to link to this message? Use this URL: <>