From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Berthier, Emmanuel" Subject: fsync() does not flush all the file Date: Thu, 1 Sep 2011 18:12:51 +0000 Message-ID: <65CD3FC07F3BF942ABE211646D72D77001C00C@IRSMSX102.ger.corp.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT To: "linux-fsdevel@vger.kernel.org" Return-path: Received: from mga11.intel.com ([192.55.52.93]:26969 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756190Ab1IASMx convert rfc822-to-8bit (ORCPT ); Thu, 1 Sep 2011 14:12:53 -0400 Content-Language: en-US Sender: linux-fsdevel-owner@vger.kernel.org List-ID: Hi, I work on Android platform and get a strange issue: sometimes the Sqlite journal is corrupted. I've reproduced the issue by a simple C test program which mimics Sqlite behavior: Create a file Write around 40KB of data on it Flush it using fsync() or fdatasync() Close it Then I power-cut the system within a couple of seconds: result: the end of the file is missing on disk. I've reproduced the issue on different handsets (x86|arm) and different FS (ext3|ext4/barrier=1/data=write_back|ordered|journal) with Android 2.3.2 and kernel 2.6.35. These handset use eMMC memory. I've checked with traces that the issue is upper eMMC block driver. Some infos: - the end of the file is flushed on eMMC only after around 5s. - I can force the complete flush using the shell "sync" command. - Laptop_mode is not enabled. - dirty_write_back_centisecs has an impact on the flushing delay. - ext3/commit option has not impact What's wrong with fsync()? Thanks, Emmanuel BERTHIER. Intel --------------------------------------------------------------------- Intel Corporation SAS (French simplified joint stock company) Registered headquarters: "Les Montalets"- 2, rue de Paris, 92196 Meudon Cedex, France Registration Number: 302 456 199 R.C.S. NANTERRE Capital: 4,572,000 Euros This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.