Subject: Buffers and vnodes
To: None <tech-kern@netbsd.org>
From: Andrew Doran <ad@netbsd.org>
List: tech-kern
Date: 06/25/2007 14:13:51
Hi,

One of the remaining problem areas in vfs wrt locking is the buffer cache.
With vfs & ffs run without the kernel lock, eventually the system will
deadlock with one or more threads stuck in in biowait. So I guess that
somewhere the necessary locks are not being taken, and it's losing state.

I've been looking into simplifying the locking, as it's unclear what's
covered by the long term lock (B_BUSY) and the short term lock
(b_interlock). One thing I'd like to do is replace b_interlock with a
pointer to the interlock for the vnode that the buffer is currently
associated with.

That would simplify things, but the catch is that buffers don't have to be
associated with vnodes. Rather than handle that as a seperate case, would it
make sense to dictate that buffers must always be associated with a vnode?
That would also simplify reference counting around character / block
devices, meaning that we could reliably prevent unloading an LKM device
that's in use.

Andrew