From patchwork Wed Nov 16 11:28:16 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zheng Liu X-Patchwork-Id: 125973 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 59E83B6F9B for ; Wed, 16 Nov 2011 22:27:58 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755990Ab1KPL1s (ORCPT ); Wed, 16 Nov 2011 06:27:48 -0500 Received: from mail-yx0-f174.google.com ([209.85.213.174]:53110 "EHLO mail-yx0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756090Ab1KPL0g (ORCPT ); Wed, 16 Nov 2011 06:26:36 -0500 Received: by yenq3 with SMTP id q3so1809888yen.19 for ; Wed, 16 Nov 2011 03:26:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=upFSwKDmt/4JffIi8NS0sk/irA2E+0+bEIGs0ZzHGHU=; b=AKim/dbfq8zt3DtrqbZ+n+9bNtlrvaRVmaEYdnwU6lcFry+b88ELxmxqN1Zapr4YEA TY9HwtD18MulCBiSwsELozihuh+QAy7vKkCwNXeL70BL5E3rj8IOC27m48qXSbhPoq3f M/YNrhq2oSNRRWUfxqsvcMkyMPJIeqivEuPxw= Received: by 10.50.189.231 with SMTP id gl7mr33711132igc.44.1321442795285; Wed, 16 Nov 2011 03:26:35 -0800 (PST) Received: from gmail.com ([182.92.247.2]) by mx.google.com with ESMTPS id mb4sm3863363igc.1.2011.11.16.03.26.31 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 16 Nov 2011 03:26:34 -0800 (PST) Date: Wed, 16 Nov 2011 19:28:16 +0800 From: Zheng Liu To: Christoph Hellwig Cc: linux-btrfs@vger.kernel.org, linux-ext4@vger.kernel.org, mfasheh@suse.com, jlbec@evilplan.org, cluster-devel@redhat.com, jack@suse.cz, swhiteho@redhat.com, tytso@mit.edu Subject: Re: fallocate vs O_(D)SYNC Message-ID: <20111116112816.GA23218@gmail.com> Mail-Followup-To: Christoph Hellwig , linux-btrfs@vger.kernel.org, linux-ext4@vger.kernel.org, mfasheh@suse.com, jlbec@evilplan.org, cluster-devel@redhat.com, jack@suse.cz, swhiteho@redhat.com, tytso@mit.edu References: <20111116084256.GA22963@infradead.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20111116084256.GA22963@infradead.org> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Wed, Nov 16, 2011 at 03:42:56AM -0500, Christoph Hellwig wrote: > It seems all filesystems but XFS ignore O_SYNC for fallocate, and never > make sure the size update transaction made it to disk. > > Given that a fallocate without FALLOC_FL_KEEP_SIZE very much is a data > operation (it adds new blocks that return zeroes) that seems like a > fairly nasty surprise for O_SYNC users. Hi all, This patch should be fix this problem in ext4. From: Zheng Liu Make sure the transaction to be commited if O_(D)SYNC flag is set in ext4_fallocate(). Signed-off-by: Zheng Liu --- fs/ext4/extents.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index 61fa9e1..f47e3ad 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -4356,6 +4356,8 @@ retry: ret = PTR_ERR(handle); break; } + if (file->f_flags & O_SYNC) + ext4_handle_sync(handle); ret = ext4_map_blocks(handle, inode, &map, flags); if (ret <= 0) { #ifdef EXT4FS_DEBUG