« Return to Thread: [PATCH 0/5] reduce exclusive ilock hold times V2

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

by Dave Chinner :: Rate this Message:

| View in Thread

On Thu, Apr 19, 2012 at 04:00:44PM -0500, Ben Myers wrote:

> 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@...>
> >
> > ---
> >  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.

I don't think it matters here - we hold the IO lock exclusive and
the inode size is 0 so there can be no writes in progress nor dirty
data to write back. Hence no allocation can occur, so the extent
count cannot change, either.

Cheers,

Dave.
--
Dave Chinner
david@...

_______________________________________________
xfs mailing list
xfs@...
http://oss.sgi.com/mailman/listinfo/xfs

 « Return to Thread: [PATCH 0/5] reduce exclusive ilock hold times V2