xfs
[Top] [All Lists]

Re: [PATCH 3/5] xfs: reduce ilock hold times in xfs_setattr_size

To: Christoph Hellwig <hch@xxxxxxxxxxxxx>
Subject: Re: [PATCH 3/5] xfs: reduce ilock hold times in xfs_setattr_size
From: Ben Myers <bpm@xxxxxxx>
Date: Thu, 19 Apr 2012 16:00:44 -0500
Cc: xfs@xxxxxxxxxxx
In-reply-to: <20120327143826.615954651@xxxxxxxxxxxxxxxxxxxxxx>
References: <20120327143445.196524266@xxxxxxxxxxxxxxxxxxxxxx> <20120327143826.615954651@xxxxxxxxxxxxxxxxxxxxxx>
User-agent: Mutt/1.5.20 (2009-06-14)
On Tue, Mar 27, 2012 at 10:34:48AM -0400, Christoph Hellwig wrote:
> We do not need the ilock for most checks done in the beginning of
> xfs_setattr_size.  Replace the long critical section before starting the
> transaction with a smaller one around xfs_zero_eof and an optional one
> inside xfs_qm_dqattach that isn't entered unless using quotas.  While
> this isn't a big optimization for xfs_setattr_size itself it will allow
> pushing the ilock into xfs_zero_eof itself later.
> 
> Signed-off-by: Christoph Hellwig <hch@xxxxxx>
> 
> ---
>  fs/xfs/xfs_iops.c |   14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> Index: xfs/fs/xfs/xfs_iops.c
> ===================================================================
> --- xfs.orig/fs/xfs/xfs_iops.c        2012-03-26 15:17:47.088854526 +0200
> +++ xfs/fs/xfs/xfs_iops.c     2012-03-26 15:17:57.265521382 +0200
> @@ -700,7 +700,7 @@ xfs_setattr_size(
>       xfs_off_t               oldsize, newsize;
>       struct xfs_trans        *tp;
>       int                     error;
> -     uint                    lock_flags;
> +     uint                    lock_flags = 0;
>       uint                    commit_flags = 0;
>  
>       trace_xfs_setattr(ip);
> @@ -720,10 +720,10 @@ xfs_setattr_size(
>                       ATTR_MTIME_SET|ATTR_KILL_SUID|ATTR_KILL_SGID|
>                       ATTR_KILL_PRIV|ATTR_TIMES_SET)) == 0);
>  
> -     lock_flags = XFS_ILOCK_EXCL;
> -     if (!(flags & XFS_ATTR_NOLOCK))
> +     if (!(flags & XFS_ATTR_NOLOCK)) {
>               lock_flags |= XFS_IOLOCK_EXCL;
> -     xfs_ilock(ip, lock_flags);
> +             xfs_ilock(ip, lock_flags);
> +     }
>  
>       oldsize = inode->i_size;
>       newsize = iattr->ia_size;

Usually the ilock is taken to protect i_d.di_nextents.

-Ben

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