Commit 2fe8c1c0 authored by Dave Chinner's avatar Dave Chinner Committed by Ben Myers

xfs: open code inc_inode_iversion when logging an inode

Michael L Semon reported that generic/069 runtime increased on v5
superblocks by 100% compared to v4 superblocks. his perf-based
analysis pointed directly at the timestamp updates being done by the
write path in this workload. The append writers are doing 4-byte
writes, so there are lots of timestamp updates occurring.

The thing is, they aren't being triggered by timestamp changes -
they are being triggered by the inode change counter needing to be
updated. That is, every write(2) system call needs to bump the inode
version count, and it does that through the timestamp update
mechanism. Hence for v5 filesystems, test generic/069 is running 3
orders of magnitude more timestmap update transactions on v5
filesystems due to the fact it does a huge number of *4 byte*
write(2) calls.

This isn't a real world scenario we really need to address - anyone
doing such sequential IO should be using fwrite(3), not write(2).
i.e. fwrite(3) buffers the writes in userspace to minimise the
number of write(2) syscalls, and the problem goes away.

However, there is a small change we can make to improve the
situation - removing the expensive lock operation on the change
counter update.  All inode version counter changes in XFS occur
under the ip->i_ilock during a transaction, and therefore we
don't actually need the spin lock that provides exclusive access to
it through inc_inode_iversion().

Hence avoid the lock and just open code the increment ourselves when
logging the inode.
Reported-by: default avatarMichael L. Semon <mlsemon35@gmail.com>
Signed-off-by: default avatarDave Chinner <dchinner@redhat.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarBen Myers <bpm@sgi.com>
parent 8f80587b
...@@ -111,12 +111,14 @@ xfs_trans_log_inode( ...@@ -111,12 +111,14 @@ xfs_trans_log_inode(
/* /*
* First time we log the inode in a transaction, bump the inode change * First time we log the inode in a transaction, bump the inode change
* counter if it is configured for this to occur. * counter if it is configured for this to occur. We don't use
* inode_inc_version() because there is no need for extra locking around
* i_version as we already hold the inode locked exclusively for
* metadata modification.
*/ */
if (!(ip->i_itemp->ili_item.li_desc->lid_flags & XFS_LID_DIRTY) && if (!(ip->i_itemp->ili_item.li_desc->lid_flags & XFS_LID_DIRTY) &&
IS_I_VERSION(VFS_I(ip))) { IS_I_VERSION(VFS_I(ip))) {
inode_inc_iversion(VFS_I(ip)); ip->i_d.di_changecount = ++VFS_I(ip)->i_version;
ip->i_d.di_changecount = VFS_I(ip)->i_version;
flags |= XFS_ILOG_CORE; flags |= XFS_ILOG_CORE;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment