From owner-freebsd-questions@FreeBSD.ORG Tue Oct 15 05:31:03 2013 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id E8EB5C3C for ; Tue, 15 Oct 2013 05:31:03 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from mx01.qsc.de (mx01.qsc.de [213.148.129.14]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id A8E5A226C for ; Tue, 15 Oct 2013 05:31:03 +0000 (UTC) Received: from r56.edvax.de (port-92-195-74-65.dynamic.qsc.de [92.195.74.65]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx01.qsc.de (Postfix) with ESMTPS id 883153CA45; Tue, 15 Oct 2013 07:30:55 +0200 (CEST) Received: from r56.edvax.de (localhost [127.0.0.1]) by r56.edvax.de (8.14.5/8.14.5) with SMTP id r9F5UmeH001969; Tue, 15 Oct 2013 07:30:48 +0200 (CEST) (envelope-from freebsd@edvax.de) Date: Tue, 15 Oct 2013 07:30:48 +0200 From: Polytropon To: Charles Swiger 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> <20131014133953.58f74659@gumby.homeunix.com> <525C1D1C.9050708@gmail.com> <525C2554.7080203@pchotshots.com> <525C2FBC.4080808@cran.org.uk> <2351E8C5-4FC0-4AE9-AC21-312DA46C0EE8@mac.com> Organization: EDVAX X-Mailer: Sylpheed 3.1.1 (GTK+ 2.24.5; i386-portbld-freebsd8.2) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: FreeBSD Questions X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: Polytropon List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Oct 2013 05:31:04 -0000 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, ...