public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: David Chinner <dgc@sgi.com>
To: Lachlan McIlroy <lachlan@sgi.com>
Cc: David Chinner <dgc@sgi.com>, xfs@oss.sgi.com, xfs-dev@sgi.com
Subject: Re: [PATCH] Implement fallocate
Date: Fri, 2 Nov 2007 09:47:44 +1100	[thread overview]
Message-ID: <20071101224744.GE995458@sgi.com> (raw)
In-Reply-To: <472928C1.5080707@sgi.com>

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

      reply	other threads:[~2007-11-01 22:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-29 23:38 [PATCH] Implement fallocate David Chinner
2007-10-30 10:09 ` Christoph Hellwig
2007-11-01  1:15 ` Lachlan McIlroy
2007-11-01 22:47   ` David Chinner [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20071101224744.GE995458@sgi.com \
    --to=dgc@sgi.com \
    --cc=lachlan@sgi.com \
    --cc=xfs-dev@sgi.com \
    --cc=xfs@oss.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox