Re: vgone() calling VOP_CLOSE() -> blocked threads?



On Sat, 15 Mar 2008, Kostik Belousov wrote:

On Sun, Mar 16, 2008 at 03:55:18AM +1100, Bruce Evans wrote:
Other problems near here:
- neither vfs nor drivers currently know how many threads are in a
driver. vfs uses vp->v_rdev->si_usecount, but this doesn't quite work
This is provided by si_threadcount.
See the dev(vn)_refthread and it usage in the devfs vnops and fops.

So why doesn't reovoke() use it? :-). All uses of si_usecount, which
normally happen via vcount() and count_dev(), are suspect, especially
the latter.

vcount() is only used in revoke(), in svr4_fcntl.c to handle another
revoke(), and for FreeBSD < 6 in reiserfs for an old multiple-mount
check.

count_dev() is only used in ata-tape.c (to decide in the same broken
way as vfs if a close is the last one -- this driver uses D_TRACKCLOSE
to get d_close() called on all closes. This gives it the burden of
deciding whether the close is the last one, and it can't do this any
better than vfs. D_TRACKCLOSE is used in a few other drivers which
don't call count_dev()), in devfs_close() (to decide whether to release
the controlling terminal and to decide when to call d_close()).

Hmm, it seems to be not vfs but only devfs which handles last-close
specially. devfs is closer to devices, so it should know how to use
si_threadcount here. Hopefully si_threadcount counts threads sleeping
in open or close, although si_usecount doesn't. d_close (or something)
should be called to wake up these threads even if si_usecount is 0.
Drivers which support sleeping in open or close must support d_close
(or something) being called to forcibly end such sleeps. revoke()
should forcibly end such sleeps, so it needs to check si_threadcount
too. si_usecount in its current form might end up being unused, so
si_threadcount could be renamed back to it.

Bruce
_______________________________________________
freebsd-arch@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-arch
To unsubscribe, send any mail to "freebsd-arch-unsubscribe@xxxxxxxxxxx"



Relevant Pages

  • Re: vgone() calling VOP_CLOSE() -> blocked threads?
    ... See the dev_refthread and it usage in the devfs vnops and fops. ... vcountis only used in revoke(), ... way as vfs if a close is the last one -- this driver uses D_TRACKCLOSE ... D_TRACKCLOSE is used in a few other drivers which ...
    (freebsd-arch)
  • Re: "modularized" 2.4.34.4 -> ide-core "unresolved symbols"
    ... This "sanscrit-like" language is an oops (in fact a kernel panic, ... I see that you're using devfs. ... lower number of hard-linked drivers. ... set a max of IDE options to YES instead of MODULE. ...
    (Linux-Kernel)
  • Simplifying devfs: minor == unit
    ... Right before I left to BSDCan I was looking at the devfs code. ... happen if I would completely remove minor numbers from device drivers. ... struct cdev *dev; ...
    (freebsd-arch)
  • Re: Simplifying devfs: minor == unit
    ... Right before I left to BSDCan I was looking at the devfs code. ... happen if I would completely remove minor numbers from device drivers. ... etc. routines to make minor numbers equal to unit ... I've seen most drivers only use the device cloner, ...
    (freebsd-arch)
  • Re: Simplifying devfs: minor == unit
    ... Right before I left to BSDCan I was looking at the devfs code. ... happen if I would completely remove minor numbers from device drivers. ... The patch was committed ~ a week ago. ... I was thinking about discussing this patch with my mentor + committing ...
    (freebsd-arch)