Received: with ECARTIS (v1.0.0; list xfs); Thu, 01 Nov 2007 15:47:53 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.3.0-r574664 (2007-09-11) on oss.sgi.com X-Spam-Level: X-Spam-Status: No, score=-1.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.3.0-r574664 Received: from larry.melbourne.sgi.com (larry.melbourne.sgi.com [134.14.52.130]) by oss.sgi.com (8.12.11.20060308/8.12.10/SuSE Linux 0.7) with SMTP id lA1MlkaL017277 for ; Thu, 1 Nov 2007 15:47:48 -0700 Received: from snort.melbourne.sgi.com (snort.melbourne.sgi.com [134.14.54.149]) by larry.melbourne.sgi.com (950413.SGI.8.6.12/950213.SGI.AUTOCF) via ESMTP id JAA29284; Fri, 2 Nov 2007 09:47:46 +1100 Received: from snort.melbourne.sgi.com (localhost [127.0.0.1]) by snort.melbourne.sgi.com (SGI-8.12.5/8.12.5) with ESMTP id lA1MljdD90344303; Fri, 2 Nov 2007 09:47:45 +1100 (AEDT) Received: (from dgc@localhost) by snort.melbourne.sgi.com (SGI-8.12.5/8.12.5/Submit) id lA1MliWs89544045; Fri, 2 Nov 2007 09:47:44 +1100 (AEDT) X-Authentication-Warning: snort.melbourne.sgi.com: dgc set sender to dgc@sgi.com using -f Date: Fri, 2 Nov 2007 09:47:44 +1100 From: David Chinner To: Lachlan McIlroy Cc: David Chinner , xfs@oss.sgi.com, xfs-dev@sgi.com Subject: Re: [PATCH] Implement fallocate Message-ID: <20071101224744.GE995458@sgi.com> References: <20071029233841.GT995458@sgi.com> <472928C1.5080707@sgi.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <472928C1.5080707@sgi.com> User-Agent: Mutt/1.4.2.1i X-Virus-Scanned: ClamAV 0.91.2/4659/Thu Nov 1 09:24:40 2007 on oss.sgi.com X-Virus-Status: Clean X-archive-position: 13517 X-ecartis-version: Ecartis v1.0.0 Sender: xfs-bounce@oss.sgi.com Errors-to: xfs-bounce@oss.sgi.com X-original-sender: dgc@sgi.com Precedence: bulk X-list: xfs On Thu, Nov 01, 2007 at 12:15:45PM +1100, Lachlan McIlroy wrote: > >+ xfs_ilock(XFS_I(inode), XFS_IOLOCK_EXCL); > >+ error = xfs_change_file_space(XFS_I(inode), XFS_IOC_RESVSP, &bf, > >+ 0, NULL, ATTR_NOLOCK); > >+ if (!error && !(mode & FALLOC_FL_KEEP_SIZE) && > >+ offset + len > i_size_read(inode)) > >+ new_size = offset + len; > >+ > >+ /* Change file size if needed */ > >+ if (new_size) { > >+ bhv_vattr_t va; > >+ > >+ va.va_mask = XFS_AT_SIZE; > >+ va.va_size = new_size; > >+ error = xfs_setattr(XFS_I(inode), &va, ATTR_NOLOCK, NULL); > >+ } > > Is it necessary to call xfs_setattr() here? Could we just do an explicit > call to xfs_zero_eof(), set the new size, set i_update_core/size and mark > the inode dirty? Hmmm, then again, that approach wouldn't be as clean as > above. And it also violates the atomicity that posix_fallocate is supposed to provide. i.e. if it returns success, the change of file size must be permanent. i.e. the change of size needs to be recorded in a transaction. Hence we need to call xfs_setattr.... Cheers, Dave. -- Dave Chinner Principal Engineer SGI Australian Software Group