Subject: Re: v_interlock/splbio protocol violations
To: Darrin B. Jewell <dbj@netbsd.org>
From: Jason Thorpe <thorpej@wasabisystems.com>
List: tech-kern
Date: 03/03/2004 21:43:54
--Apple-Mail-36--859896898
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset=US-ASCII; format=flowed


On Mar 3, 2004, at 1:12 PM, Darrin B. Jewell wrote:

>  4. Care is taken to avoid taking struct vnode's v_interlock
>     from inside biodone() so that all locks of v_interlock
>     do not have to be protected by splbio(9).

Yes, this is especially important, since the v_interlock of struct 
vnode is actually the associated uvm_object's vmobjlock.  Requiring 
splbio() for each v_interlock would require extensive (and, I think, 
totally unreasonable) changes to UVM.

>  5. Therefore, fields protected by v_interlock must not be
>     accessed from inside biodone()
>
> If you see a misunderstanding represented in the above list, please
> correct me.
>
> Unfortunately, these rules are violated in several places,
> some new, some old.
>   - biodone calls vwakeup for writes which accesses v_flag
>   - asynchronous buffer i/o without a callback will invoke brelse
>     from biodone.  This is used for many filesystem metadata writes.
>     However, on an i/o error it may call brelvp and reassignbuf.
>     - brelvp and reassignbuf access v_uobj.memq and v_flag

Yow.  It's totally bogus to access memq from interrupt context.  I also 
notice that brelvp also *modifies* v_flag without taking v_interlock 
(simply testing a flag, I could understand, if the test didn't have to 
be totally precise...)

         -- Jason R. Thorpe <thorpej@wasabisystems.com>


--Apple-Mail-36--859896898
content-type: application/pgp-signature; x-mac-type=70674453;
	name=PGP.sig
content-description: This is a digitally signed message part
content-disposition: inline; filename=PGP.sig
content-transfer-encoding: 7bit

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (Darwin)

iD8DBQFARsIbOpVKkaBm8XkRAqiPAJ9aSJXoxaFIHGrjTJuA7JNMYWqodACgw8gx
wJrVjbUq+GeSXyn0eI1H0w0=
=8v/Y
-----END PGP SIGNATURE-----

--Apple-Mail-36--859896898--