• Dave Chinner's avatar
    xfs: don't retry xfs_buf_find on XBF_TRYLOCK failure · b027d4c9
    Dave Chinner authored
    When looking at an event trace recently, I noticed that non-blocking
    buffer lookup attempts would fail on cached locked buffers and then
    run the slow cache-miss path. This means we are doing an xfs_buf
    allocation, lookup and free unnecessarily every time we avoid
    blocking on a locked buffer.
    
    Fix this by changing _xfs_buf_find() to return an error status to
    the caller to indicate that we failed the lock attempt rather than
    just returning a NULL. This allows the higher level code to
    discriminate between a cache miss and an cache hit that we failed to
    lock.
    
    This also allows us to return a -EFSCORRUPTED state if we are asked
    to look up a block number outside the range of the filesystem in
    _xfs_buf_find(), which moves us one step closer to being able to
    handle such errors in a more graceful manner at the higher levels.
    Signed-Off-By: default avatarDave Chinner <dchinner@redhat.com>
    Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
    Reviewed-by: default avatarCarlos Maiolino <cmaiolino@redhat.com>
    Reviewed-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
    Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
    b027d4c9
xfs_buf.c 52.5 KB