mirror of
https://github.com/torvalds/linux.git
synced 2026-09-22 12:44:03 +02:00
xfs: add lockless xfs_buf_readahead_map fast path
Readahead currently always locks the buffer, which can cause contention with actual users of the buffer. Add a fast path without taking any locks if the buffer is uptodate and not stale. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Carlos Maiolino <cem@kernel.org>
This commit is contained in:
parent
2aedf844be
commit
00f40876f4
|
|
@ -756,13 +756,23 @@ xfs_buf_readahead_map(
|
|||
|
||||
if (xfs_find_get_buf(target, map, nmaps, flags, &bp))
|
||||
return;
|
||||
if (xfs_buf_find_lock(bp, XBF_TRYLOCK))
|
||||
|
||||
/*
|
||||
* Do a lockless fast path check for a valid uptodate buffer and avoid
|
||||
* locking entirely in this case.
|
||||
*/
|
||||
if ((READ_ONCE(bp->b_flags) & (XBF_DONE | XBF_STALE)) == XBF_DONE)
|
||||
goto out_rele;
|
||||
|
||||
trace_xfs_buf_readahead(bp, 0, _RET_IP_);
|
||||
if (bp->b_flags & XBF_DONE)
|
||||
/* Otherwise lock the buffer to stabilize the state */
|
||||
if (!xfs_buf_trylock(bp))
|
||||
goto out_rele;
|
||||
|
||||
/* Let the actual reader deal with stale buffers. */
|
||||
if (bp->b_flags & (XBF_STALE | XBF_DONE))
|
||||
goto out_unlock;
|
||||
|
||||
trace_xfs_buf_readahead(bp, 0, _RET_IP_);
|
||||
XFS_STATS_INC(target->bt_mount, xb_get_read);
|
||||
bp->b_ops = ops;
|
||||
xfs_buf_clear_flags(bp, XBF_WRITE | XBF_DONE);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user