Subject: MFS/VFS problem in 1.3?
To: None <tech-kern@netbsd.org>
From: Aaro J Koskinen <akoskine@cc.helsinki.fi>
List: tech-kern
Date: 01/25/1999 17:13:07
Hello all,

I wonder if someone could help explaining the odd behavior of our BSD
kernel. It has all the file system stuff taken straight from NetBSD
1.3.

We have set up the MFS as a root file system, and after doing some file
operations (e.g. stat()) in the /dev directory we are getting "bad dev"
panic, thanks to the following check in mfs_strategy():

   if (!vfinddev(bp->b_dev, VBLK, &vp) || vp->v_usecount == 0)
                panic("mfs_strategy: bad dev");

The latter condition is true when the next strategy/transfer is done after
the MD device has been stat():ed. Here's what, I think, happens:

   - It the boot, when the file system is mounted, a vnode with tag
     VT_NON for the the MD device is inserted in the speclist.

   - When /dev/md0a is looked up by stat(), its vnode is
     checkalias():ed through ufs_vinit(). The vnode will be aliased and
     gets also inserted to speclist.

   - When stat() returns, the vnode is released and reference count
     drops to zero.

   - The next mfs_strategy() does vfinddev(), which returns the vnode
     just released by stat() (because it's the first in the speclist)
     ==> panic, although a proper vnode for the device still exists
     further on the list...

Should vfinddev() garbage collect the vnodes with the zero reference
count, like the other routines handling speclist do?
-- 
Aaro Koskinen .......................................... http://www.iki.fi/aaro
nowhere .................................................... mailto:aaro@iki.fi