Skip to content

Commit

Permalink
xfs: preallocation transactions do not need to be synchronous
Browse files Browse the repository at this point in the history
Preallocation and hole punch transactions are currently synchronous
and this is causing performance problems in some cases. The
transactions don't need to be synchronous as we don't need to
guarantee the preallocation is persistent on disk until a
fdatasync, fsync, sync operation occurs. If the file is opened
O_SYNC or O_DATASYNC, only then should the transaction be issued
synchronously.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Alex Elder <aelder@sgi.com>
  • Loading branch information
Dave Chinner authored and Dave Chinner committed Mar 25, 2011
1 parent 0c9ba97 commit 8287889
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
6 changes: 5 additions & 1 deletion fs/xfs/linux-2.6/xfs_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,7 @@ xfs_file_fallocate(
xfs_flock64_t bf;
xfs_inode_t *ip = XFS_I(inode);
int cmd = XFS_IOC_RESVSP;
int attr_flags = XFS_ATTR_NOLOCK;

if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE))
return -EOPNOTSUPP;
Expand All @@ -918,7 +919,10 @@ xfs_file_fallocate(
goto out_unlock;
}

error = -xfs_change_file_space(ip, cmd, &bf, 0, XFS_ATTR_NOLOCK);
if (file->f_flags & O_DSYNC)
attr_flags |= XFS_ATTR_SYNC;

error = -xfs_change_file_space(ip, cmd, &bf, 0, attr_flags);
if (error)
goto out_unlock;

Expand Down
4 changes: 4 additions & 0 deletions fs/xfs/linux-2.6/xfs_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,10 @@ xfs_ioc_space(

if (filp->f_flags & (O_NDELAY|O_NONBLOCK))
attr_flags |= XFS_ATTR_NONBLOCK;

if (filp->f_flags & O_DSYNC)
attr_flags |= XFS_ATTR_SYNC;

if (ioflags & IO_INVIS)
attr_flags |= XFS_ATTR_DMI;

Expand Down
3 changes: 2 additions & 1 deletion fs/xfs/xfs_vnodeops.c
Original file line number Diff line number Diff line change
Expand Up @@ -2831,7 +2831,8 @@ xfs_change_file_space(
ip->i_d.di_flags &= ~XFS_DIFLAG_PREALLOC;

xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
xfs_trans_set_sync(tp);
if (attr_flags & XFS_ATTR_SYNC)
xfs_trans_set_sync(tp);

error = xfs_trans_commit(tp, 0);

Expand Down
1 change: 1 addition & 0 deletions fs/xfs/xfs_vnodeops.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ int xfs_setattr(struct xfs_inode *ip, struct iattr *vap, int flags);
#define XFS_ATTR_NONBLOCK 0x02 /* return EAGAIN if operation would block */
#define XFS_ATTR_NOLOCK 0x04 /* Don't grab any conflicting locks */
#define XFS_ATTR_NOACL 0x08 /* Don't call xfs_acl_chmod */
#define XFS_ATTR_SYNC 0x10 /* synchronous operation required */

int xfs_readlink(struct xfs_inode *ip, char *link);
int xfs_release(struct xfs_inode *ip);
Expand Down

0 comments on commit 8287889

Please sign in to comment.