diff options
author | Christoph Hellwig <hch@lst.de> | 2016-09-18 21:09:48 -0400 |
---|---|---|
committer | Dave Chinner <david@fromorbit.com> | 2016-09-18 21:09:48 -0400 |
commit | 85a6e764ff5485dfe1edf5e47290e4d32ea866d5 (patch) | |
tree | 904f32368131bdff904563606ac31952ddc08d1a | |
parent | f8e3a8257538af8dbdd15d098c0cfba6ccbabe7a (diff) |
xfs: make xfs_inode_set_eofblocks_tag cheaper for the common case
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>
-rw-r--r-- | fs/xfs/xfs_icache.c | 14 | ||||
-rw-r--r-- | fs/xfs/xfs_inode.h | 1 |
2 files changed, 15 insertions, 0 deletions
diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c index fb39a66914dd..65b2e3f85f52 100644 --- a/fs/xfs/xfs_icache.c +++ b/fs/xfs/xfs_icache.c | |||
@@ -1414,6 +1414,16 @@ xfs_inode_set_eofblocks_tag( | |||
1414 | struct xfs_perag *pag; | 1414 | struct xfs_perag *pag; |
1415 | int tagged; | 1415 | int tagged; |
1416 | 1416 | ||
1417 | /* | ||
1418 | * Don't bother locking the AG and looking up in the radix trees | ||
1419 | * if we already know that we have the tag set. | ||
1420 | */ | ||
1421 | if (ip->i_flags & XFS_IEOFBLOCKS) | ||
1422 | return; | ||
1423 | spin_lock(&ip->i_flags_lock); | ||
1424 | ip->i_flags |= XFS_IEOFBLOCKS; | ||
1425 | spin_unlock(&ip->i_flags_lock); | ||
1426 | |||
1417 | pag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, ip->i_ino)); | 1427 | pag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, ip->i_ino)); |
1418 | spin_lock(&pag->pag_ici_lock); | 1428 | spin_lock(&pag->pag_ici_lock); |
1419 | trace_xfs_inode_set_eofblocks_tag(ip); | 1429 | trace_xfs_inode_set_eofblocks_tag(ip); |
@@ -1449,6 +1459,10 @@ xfs_inode_clear_eofblocks_tag( | |||
1449 | struct xfs_mount *mp = ip->i_mount; | 1459 | struct xfs_mount *mp = ip->i_mount; |
1450 | struct xfs_perag *pag; | 1460 | struct xfs_perag *pag; |
1451 | 1461 | ||
1462 | spin_lock(&ip->i_flags_lock); | ||
1463 | ip->i_flags &= ~XFS_IEOFBLOCKS; | ||
1464 | spin_unlock(&ip->i_flags_lock); | ||
1465 | |||
1452 | pag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, ip->i_ino)); | 1466 | pag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, ip->i_ino)); |
1453 | spin_lock(&pag->pag_ici_lock); | 1467 | spin_lock(&pag->pag_ici_lock); |
1454 | trace_xfs_inode_clear_eofblocks_tag(ip); | 1468 | trace_xfs_inode_clear_eofblocks_tag(ip); |
diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h index e1a411e08f00..8f30d2533b48 100644 --- a/fs/xfs/xfs_inode.h +++ b/fs/xfs/xfs_inode.h | |||
@@ -216,6 +216,7 @@ xfs_get_initial_prid(struct xfs_inode *dp) | |||
216 | #define __XFS_IPINNED_BIT 8 /* wakeup key for zero pin count */ | 216 | #define __XFS_IPINNED_BIT 8 /* wakeup key for zero pin count */ |
217 | #define XFS_IPINNED (1 << __XFS_IPINNED_BIT) | 217 | #define XFS_IPINNED (1 << __XFS_IPINNED_BIT) |
218 | #define XFS_IDONTCACHE (1 << 9) /* don't cache the inode long term */ | 218 | #define XFS_IDONTCACHE (1 << 9) /* don't cache the inode long term */ |
219 | #define XFS_IEOFBLOCKS (1 << 10)/* has the preallocblocks tag set */ | ||
219 | 220 | ||
220 | /* | 221 | /* |
221 | * Per-lifetime flags need to be reset when re-using a reclaimable inode during | 222 | * Per-lifetime flags need to be reset when re-using a reclaimable inode during |