On Wed, Mar 15, 2006 at 02:29:48PM -0500, Alan Stern wrote:
> On Wed, 15 Mar 2006, Paul Fulghum wrote:
> 
> > On Wed, 2006-03-15 at 11:56 -0500, Alan Stern wrote:
> > > > Should driver core defer sysfs_remove_file until
> > > > last dev->kobj reference is dropped?
> > > 
> > > No.  The files should be deleted.  James Bottomley refers to this as 
> > > "removing from visibility".  There's no point leaving the symlink visible 
> > > once it can no longer be used.
> > > 
> > > Instead, the code should be fixed so that the attempt to remove the 
> > > already-deleted symlink by class_device_del() doesn't cause an oops.
> > 
> > So dev->kobj->dentry should be set to NULL in
> > device_remove_file() and other code should be
> > fixed to check for dev->kobj->dentry == NULL ?
> 
> I don't know.  I'm not familiar with the details of how sysfs is supposed 
> to work.  Maybe the existence of the symlink should prevent the dentry 
> from being freed during sysfs_remove_dir.  Or maybe sysfs_remove_dir 
> should modify the symlink data structure so that the other code would not 
> even try to look at dev->kobj->dentry.
> 
> (It wouldn't be a bad idea to set dev->kobj->dentry to NULL as soon as the
> dentry is deallocated anyway.  Doing that would make bugs a little easier
> to spot.)

Due to the way that sysfs rebuilds dentrys and inodes on the fly after
memory pressure pushes them out of the cache, it might be tougher to do
this than you might originally think :)

> You know, another possibility is that cdc_acm should call
> tty_unregister_device as soon as the USB device is disconnected.  It would
> make sense; no point leaving a tty visible in sysfs if it's no longer
> accessible (except through already-opened file descriptors). However I
> don't know whether the tty subsystem is designed to work that way.

No, do that on the last close, the disconnect should call hangup which
will allow the userspace code to properly drop the device and then the
tty layer can be shutdown easily.

The tty layer is _not_ very good at handling dynamic devices, so you
need to be very careful with this.

I still think it's easier to reference count the whole object, but then
hey, what do I know... :)

thanks,

greg k-h


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to