Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 15 Oct 2013 07:30:48 +0200
From:      Polytropon <freebsd@edvax.de>
To:        Charles Swiger <cswiger@mac.com>
Cc:        FreeBSD Questions <freebsd-questions@freebsd.org>
Subject:   Re: SU+J Lost files after a power failure
Message-ID:  <20131015073048.83d7bca4.freebsd@edvax.de>
In-Reply-To: <2351E8C5-4FC0-4AE9-AC21-312DA46C0EE8@mac.com>
References:  <525A6831.5070402@gmail.com> <l3gc7e$c91$1@ger.gmane.org> <20131014133953.58f74659@gumby.homeunix.com> <525C1D1C.9050708@gmail.com> <CA+tpaK2Pr2po2cQ1yanQK9+wLp77SYqYHjxiXaU5FfXwHrkGow@mail.gmail.com> <CAFYkXjn-1wTJcQ4a_fyXCvwh9ukt3+djM2qsMeaH1HhVJNvhiA@mail.gmail.com> <525C2554.7080203@pchotshots.com> <CAFYkXjm8y0Br31_pqRZc0sNFbqCNtKHhjeQuiLXkGT2zxSu0GA@mail.gmail.com> <525C2FBC.4080808@cran.org.uk> <alpine.LRH.2.03.1310141447520.16969@nber.org> <2351E8C5-4FC0-4AE9-AC21-312DA46C0EE8@mac.com>

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
noticed...

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
belief.



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



Want to link to this message? Use this URL: <http://docs.FreeBSD.org/cgi/mid.cgi?20131015073048.83d7bca4.freebsd>