xfs
[Top] [All Lists]

Re: [PATCH 4/5] xfs: simplify the fallocate path

To: Christoph Hellwig <hch@xxxxxxxxxxxxx>
Subject: Re: [PATCH 4/5] xfs: simplify the fallocate path
From: Dave Chinner <david@xxxxxxxxxxxxx>
Date: Mon, 14 Oct 2013 16:04:24 +1100
Cc: xfs@xxxxxxxxxxx
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <20131012075640.467511096@xxxxxxxxxxxxxxxxxxxxxx>
References: <20131012075503.370510641@xxxxxxxxxxxxxxxxxxxxxx> <20131012075640.467511096@xxxxxxxxxxxxxxxxxxxxxx>
User-agent: Mutt/1.5.21 (2010-09-15)
On Sat, Oct 12, 2013 at 12:55:07AM -0700, Christoph Hellwig wrote:
> Call xfs_alloc_file_space or xfs_free_file_space directly from
> xfs_file_fallocate instead of going through xfs_change_file_space.
> 
> This simplified the code by removing the unessecary marshalling of the
> arguments into an xfs_flock64_t structure and allows removing checks that
> are already done in the VFS code.
> 
> Signed-off-by: Christoph Hellwig <hch@xxxxxx>
> 
> ---
>  fs/xfs/xfs_bmap_util.c |   39 ++-----------------------
>  fs/xfs/xfs_bmap_util.h |    4 ++
>  fs/xfs/xfs_file.c      |   76 
> ++++++++++++++++++++++++++++++-------------------
>  3 files changed, 56 insertions(+), 63 deletions(-)
> 
> Index: xfs/fs/xfs/xfs_file.c
> ===================================================================
> --- xfs.orig/fs/xfs/xfs_file.c        2013-10-01 21:06:23.000000000 +0200
> +++ xfs/fs/xfs/xfs_file.c     2013-10-01 21:12:47.552218689 +0200
> @@ -805,44 +805,64 @@ out:
>  
>  STATIC long
>  xfs_file_fallocate(
.....
> +     tp = xfs_trans_alloc(ip->i_mount, XFS_TRANS_WRITEID);
> +     error = xfs_trans_reserve(tp, &M_RES(ip->i_mount)->tr_writeid, 0, 0);
> +     if (error) {
> +             xfs_trans_cancel(tp, 0);
> +             goto out_unlock;
> +     }
> +
> +     xfs_ilock(ip, XFS_ILOCK_EXCL);
> +     xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
> +     ip->i_d.di_mode &= ~S_ISUID;
> +     if (ip->i_d.di_mode & S_IXGRP)
> +             ip->i_d.di_mode &= ~S_ISGID;
> +
> +     if (!(mode & FALLOC_FL_PUNCH_HOLE))
> +             ip->i_d.di_flags |= XFS_DIFLAG_PREALLOC;
>  
> -     error = -xfs_change_file_space(ip, cmd, &bf, 0, attr_flags);
> +     xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
> +     xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
> +
> +     if (file->f_flags & O_DSYNC)
> +             xfs_trans_set_sync(tp);
> +     error = xfs_trans_commit(tp, 0);
>       if (error)
>               goto out_unlock;

Seems a bit clunky to do all this work when we've got to repeat most
of it when when we call xfs_setattr_size() if the size has changed.
Any thoughts on how we might reduce to a single transaction?

Otherwise it looks ok.

Cheers,

Dave.
-- 
Dave Chinner
david@xxxxxxxxxxxxx

<Prev in Thread] Current Thread [Next in Thread>