From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Aneesh Kumar K.V" Subject: Re: correct use of vmtruncate()? Date: Wed, 30 Apr 2008 12:54:57 +0530 Message-ID: <20080430072457.GB7791@skywalker> References: <20080429100601.GO108924158@sgi.com> <481756A3.20601@oracle.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: David Chinner , linux-fsdevel , linux-mm , xfs-oss To: Zach Brown Return-path: Received: from e28smtp04.in.ibm.com ([59.145.155.4]:42055 "EHLO e28smtp04.in.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752186AbYD3HZ2 (ORCPT ); Wed, 30 Apr 2008 03:25:28 -0400 Received: from d28relay04.in.ibm.com (d28relay04.in.ibm.com [9.184.220.61]) by e28smtp04.in.ibm.com (8.13.1/8.13.1) with ESMTP id m3U7PAFo028829 for ; Wed, 30 Apr 2008 12:55:10 +0530 Received: from d28av04.in.ibm.com (d28av04.in.ibm.com [9.184.220.66]) by d28relay04.in.ibm.com (8.13.8/8.13.8/NCO v8.7) with ESMTP id m3U7P1hO1384450 for ; Wed, 30 Apr 2008 12:55:03 +0530 Received: from d28av04.in.ibm.com (loopback [127.0.0.1]) by d28av04.in.ibm.com (8.13.1/8.13.3) with ESMTP id m3U7P7gL020839 for ; Wed, 30 Apr 2008 07:25:07 GMT Content-Disposition: inline In-Reply-To: <481756A3.20601@oracle.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Tue, Apr 29, 2008 at 10:10:59AM -0700, Zach Brown wrote: > > > The obvious fix for this is that block_write_begin() and > > friends should be calling ->setattr to do the truncation and hence > > follow normal convention for truncating blocks off an inode. > > However, even that appears to have thorns. e.g. in XFS we hold the > > iolock exclusively when we call block_write_begin(), but it is not > > held in all cases where ->setattr is currently called. Hence calling > > ->setattr from block_write_begin in this failure case will deadlock > > unless we also pass a "nolock" flag as well. XFS already > > supports this (e.g. see the XFS fallocate implementation) but no other > > filesystem does (some probably don't need to). > > This paragraph in particular reminds me of an outstanding bug with > O_DIRECT and ext*. It isn't truncating partial allocations when a dio > fails with ENOSPC. This was noticed by a user who saw that fsck found > bocks outside i_size in the file that saw ENOSPC if they tried to > unmount and check the volume after the failed write. This patch should be the fix I guess http://lkml.org/lkml/2006/12/18/103 -aneesh