diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c index e4b65d0c9ef0..ee8c3944015a 100644 --- a/fs/xfs/xfs_buf.c +++ b/fs/xfs/xfs_buf.c @@ -1523,6 +1523,18 @@ xfs_buftarg_isolate( if (!spin_trylock(&bp->b_lockref.lock)) return LRU_SKIP; + /* + * If the buffer is in use, remove it from the LRU for now. We can't + * free it while someone is using it, and we should also not count + * eviction passed for it, just as if it hadn't been added to the LRU + * yet. + */ + if (bp->b_lockref.count > 0) { + list_lru_isolate(lru, &bp->b_lru); + spin_unlock(&bp->b_lockref.lock); + return LRU_REMOVED; + } + /* * Decrement the b_lru_ref count unless the value is already * zero. If the value is already zero, we need to reclaim the @@ -1533,16 +1545,6 @@ xfs_buftarg_isolate( return LRU_ROTATE; } - /* - * If the buffer is in use, remove it from the LRU for now as we can't - * free it. It will be freed when the last reference drops. - */ - if (bp->b_lockref.count > 0) { - list_lru_isolate(lru, &bp->b_lru); - spin_unlock(&bp->b_lockref.lock); - return LRU_REMOVED; - } - lockref_mark_dead(&bp->b_lockref); list_lru_isolate_move(lru, item, dispose); spin_unlock(&bp->b_lockref.lock);