xfs: make xfs_inode_set_eofblocks_tag cheaper for the common case
authorChristoph Hellwig <hch@lst.de>
Mon, 19 Sep 2016 01:09:48 +0000 (11:09 +1000)
committerDave Chinner <david@fromorbit.com>
Mon, 19 Sep 2016 01:09:48 +0000 (11:09 +1000)
For long growing file writes we will usually already have the
eofblocks tag set when adding more speculative preallocations.  Add
a flag in the inode to allow us to skip the the fairly expensive
AG-wide spinlocks and multiple radix tree operations in that case.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
fs/xfs/xfs_icache.c
fs/xfs/xfs_inode.h

index fb39a66914dd897251f952eece789f971ea31ab8..65b2e3f85f52ac0b0851b63525afa8a6386bf80e 100644 (file)
@@ -1414,6 +1414,16 @@ xfs_inode_set_eofblocks_tag(
        struct xfs_perag *pag;
        int tagged;
 
+       /*
+        * Don't bother locking the AG and looking up in the radix trees
+        * if we already know that we have the tag set.
+        */
+       if (ip->i_flags & XFS_IEOFBLOCKS)
+               return;
+       spin_lock(&ip->i_flags_lock);
+       ip->i_flags |= XFS_IEOFBLOCKS;
+       spin_unlock(&ip->i_flags_lock);
+
        pag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, ip->i_ino));
        spin_lock(&pag->pag_ici_lock);
        trace_xfs_inode_set_eofblocks_tag(ip);
@@ -1449,6 +1459,10 @@ xfs_inode_clear_eofblocks_tag(
        struct xfs_mount *mp = ip->i_mount;
        struct xfs_perag *pag;
 
+       spin_lock(&ip->i_flags_lock);
+       ip->i_flags &= ~XFS_IEOFBLOCKS;
+       spin_unlock(&ip->i_flags_lock);
+
        pag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, ip->i_ino));
        spin_lock(&pag->pag_ici_lock);
        trace_xfs_inode_clear_eofblocks_tag(ip);
index e1a411e08f00f6b6e0815b6f7af3a58aed746db2..8f30d2533b48995fd15d15bd23c1fd393e5c96f9 100644 (file)
@@ -216,6 +216,7 @@ xfs_get_initial_prid(struct xfs_inode *dp)
 #define __XFS_IPINNED_BIT      8        /* wakeup key for zero pin count */
 #define XFS_IPINNED            (1 << __XFS_IPINNED_BIT)
 #define XFS_IDONTCACHE         (1 << 9) /* don't cache the inode long term */
+#define XFS_IEOFBLOCKS         (1 << 10)/* has the preallocblocks tag set */
 
 /*
  * Per-lifetime flags need to be reset when re-using a reclaimable inode during