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
|