clone_cleanup() doesn't
Andrew Gallatin
gallatin at cs.duke.edu
Fri Aug 14 19:24:04 UTC 2009
Robert Watson wrote:
> On Fri, 14 Aug 2009, Andrew Gallatin wrote:
>
>> I've been porting a closed-source driver to FreeBSD 8 from FreeBSD
>> 5/6/7. It use the dev_clone() eventhandler to mimic linux-like open
>> semantics (for linux binary compat).
>
> No particular experience with unloading cloning stuff, but have you
> noticed that in 8.x we now have per-file descriptor device state? This
> is often the semantics people actually want, rather than cloning. See
> devfs_set_cdevpriv(9) for details -- there are several synthetic devices
> in the tree that use it now (although some of them do too much
> error-checking, and should assert rather than return errors, I think).
Unfortunately, I think I still need device cloning. The linux semantics
are to open /dev/mx0, then call an ioctl to set the device private
state. This gets set (in linux) in the "struct file *" ->private_data
field. So multiple processes can open /dev/mx0, and they all have
different private data.
FWIW:
>> I'm assuming these files are lingering because clone_cleanup()
>> (called at device detach) is not cleaning up these lingering
>> device nodes. I've tried writing a dtrace script to trace
>> clone_cleanup. But since that happens from device detach,
>> dtrace doesn't work (blocks driver unload). I've also tried
>> setting a breakpoint in ddb(), but the breakpoint seems to
>> be ignored (other breakpoints work fine, which is odd).
I think ddb wasn't working because my kernel sources didn't quite
match my running kernel. After a kernel & module rebuild, I can watch
clone_cleanup(), and I see destroy_devl() get called.
It calls devfs_destroy(), as well.
The interesting thing is that if I run devd -D -d, and watch the
events scroll by, I see the destruction of a device with a
null name. Eg:
Processing event '!system=DEVFS subsystem=CDEV type=DESTROY cdev='
Pushing table
setting system=DEVFS
setting subsystem=CDEV
setting type=DESTROY
setting cdev=
Processing notify event
<...>
If I do the same thing on 7.2, I see:
Processing event '!system=DEVFS subsystem=CDEV type=DESTROY cdev=mx_fake.0'
Pushing table
setting system=DEVFS
setting subsystem=CDEV
setting type=DESTROY
setting cdev=mx_fake.0
Processing notify event
So I wonder if the node is not getting removed because its
name has gotten mangled somehow...
Drew
More information about the freebsd-current
mailing list