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

Bruce Evans brde at optusnet.com.au
Wed Mar 19 15:39:56 UTC 2008


On Wed, 19 Mar 2008, Ed Schouten wrote:

> I just changed my TTY code to perform some garbage collecting on TTY's.
> It now only performs a device cleanup when si_threadcount == 1 and
> TF_OPENED is unset. Unfortunately, I'm checking for these conditions in
> all the cdev ops, which is quite expensive.
>
> It does the trick, but if someone has a better idea, I'm willing to
> implement it.

When does si_threadcount go to 0 -- can it be 1 due to something other
than a cdev op holding a reference?

If revoke() is the only problem, and if non-cdev ops can hold a
reference, then it might work to acquire a reference at the time of
the revoke.  Hold this reference in some process (could even be in
userland), and consider releasing it some time later (and later again
if the synchronization hasn't completed).  While this reference is
held, si_refcount cannot go to 0, so it is only necessary to check
si_threadcount == 1 when considering releasing this reference.  New
opens on the device probably need to be blocked while the state is
unsynchronized -- otherwise too many states are possible.

Bruce


More information about the freebsd-arch mailing list