Subject: Re: mount_mfs (with mount_null) won't reclaim space
To: enami tsugutomo <enami@sm.sony.co.jp>
From: Bill Studenmund <wrstuden@netbsd.org>
List: tech-kern
Date: 03/18/2002 18:40:41
On 19 Mar 2002, enami tsugutomo wrote:

> Bill Studenmund <wrstuden@netbsd.org> writes:
>
> > Two file descriptors referencing the upper node, which in turn references
> > the lower node. The lower node will have one reference, so the hardware
> > close routine will get called when either one of the upper references'
> > close routine is called. And then it will get called again when the other
> > file descriptor is closed.
>
> The lower vnode has one reference but upper (layer fs) vnode has two
> references.  Closing one of those file descriptor just decrease
> the reference count of upper vnode.

Does it? Last time I looked, the code which checks usage count (and does
nothing if the usage count is > 1) is in miscfs/specfs/spec_vnops.c in the
close routine, specifically spec_close(). With a vcount() that ignores
upper-layered vnodes (like the ones we have now), this count will be only
that of the lower node, which in this case only has the one reference from
the upper node.

So the close of each of those upper file descriptors will turn into
VOP_CLOSE() calls that will result in calls to the device's close routine.
Also, usage of one file descriptor after the other has been closed will
result in calls (read(), write(), ioctl()) to the lower device after its
close routine has been called. That won't do what we want.

Take care,

Bill