]> www.infradead.org Git - users/hch/xfs.git/commit
xfs: fix buffer lookup vs release race
authorChristoph Hellwig <hch@lst.de>
Sun, 12 Jan 2025 05:55:07 +0000 (06:55 +0100)
committerChristoph Hellwig <hch@lst.de>
Mon, 13 Jan 2025 04:17:35 +0000 (05:17 +0100)
commit38002adfa58e90793d846e450d6adf9bfb21c4e3
tree5c8945688a51dbd0cadbc227f073ec757e325976
parent760d1991a9fccd43fb2e21181340171181231298
xfs: fix buffer lookup vs release race

Since commit 298f34224506 ("xfs: lockless buffer lookup") the buffer
lookup fastpath is done without a hash-wide lock (then pag_buf_lock, now
bc_lock) and only under RCU protection.  But this means that nothing
serializes lookups against the temporary 0 reference count for buffers
that are added to the LRU after dropping the last regular reference,
and a concurrent lookup would fail to find them.

Fix this by doing all b_hold modifications under b_lock.  We're already
doing this for release so this "only" ~ doubles the b_lock round trips.
We'll later look into the lockref infrastructure to optimize the number
of lock round trips again.

Signed-off-by: Christoph Hellwig <hch@lst.de>
fs/xfs/xfs_buf.c
fs/xfs/xfs_buf.h
fs/xfs/xfs_trace.h