Subject: Re: LK_DRAIN vs the interlock vs VOP_INACTIVE, was Re: reboot problems unmounting root
To: Bill Stouder-Studenmund <wrstuden@netbsd.org>
From: Antti Kantee <pooka@cs.hut.fi>
List: tech-kern
Date: 07/07/2007 23:02:20
On Sat Jul 07 2007 at 11:30:55 -0700, Bill Stouder-Studenmund wrote:
> > diff -p -u -r1.288 vfs_subr.c
> > --- vfs_subr.c	5 Jun 2007 12:31:31 -0000	1.288
> > +++ vfs_subr.c	7 Jul 2007 14:27:01 -0000
> > @@ -1522,12 +1522,11 @@ vclean(struct vnode *vp, int flags, stru
> >  
> >  	/*
> >  	 * Even if the count is zero, the VOP_INACTIVE routine may still
> > -	 * have the object locked while it cleans it out. The VOP_LOCK
> > -	 * ensures that the VOP_INACTIVE routine is done with its work.
> > -	 * For active vnodes, it ensures that no other activity can
> > +	 * have the object locked while it cleans it out.  For
> > +	 * active vnodes, it ensures that no other activity can
> >  	 * occur while the underlying object is being cleaned out.
> >  	 */
> > -	VOP_LOCK(vp, LK_DRAIN | LK_INTERLOCK);
> > +	VOP_LOCK(vp, LK_EXCLUSIVE | LK_INTERLOCK);
> >  
> >  	/*
> >  	 * Clean out any cached data associated with the vnode.
> 
> Ok. How much testing did you do? I like this idea the best, now.

Tested all the things that were wrong, like revoke upper/foo, revoke
lower/foo while holding upper/foo, unmount -f /lower while having open
files in upper, forced reclamation of vnodes through ls -lR etc stuff.
But in qemu, I'm not running it on my desktop yet.

> > @@ -1649,6 +1648,7 @@ vclean(struct vnode *vp, int flags, stru
> >  	 */
> >  	vp->v_op = dead_vnodeop_p;
> >  	vp->v_tag = VT_NON;
> > +	vp->v_vnlock = NULL;
> >  	simple_lock(&vp->v_interlock);
> >  	VN_KNOTE(vp, NOTE_REVOKE);	/* FreeBSD has this in vn_pollgone() */
> >  	vp->v_flag &= ~(VXLOCK|VLOCKSWORK);
> 
> Do we really need this?

No, but it was hanging around from a previous patch and it's the right
thing to do even though not necessary: the lock is dead from an exporting
point-of-view.

-- 
Antti Kantee <pooka@iki.fi>                     Of course he runs NetBSD
http://www.iki.fi/pooka/                          http://www.NetBSD.org/
    "la qualité la plus indispensable du cuisinier est l'exactitude"