Re: refcounting drivers' data structures used in sysfs buffers

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Alan Stern
Date: Friday, March 9, 2007 - 1:08 pm

On Fri, 9 Mar 2007, Alan Stern wrote:


I take this back.  Redirecting stdin to the attribute file would increase 
the module's refcount and cause rmmod to exit immediately with an error.

After some more thought, I basically agree with what Oliver wrote
originally.  sysfs_dirent is indeed the logical place to store the kref
pointer.  However it needs to be used during open and release, not during
read, write, and poll.  Another point, which Oliver didn't think of, is
that the kref pointer needs to be passed to the driver as an argument in
the show() and store() method calls.

Implementing this will be difficult.  One possibility is to change the 
definition of sysfs_ops, adding the new struct kref * argument to the 
prototypes.  This will involve changing _lots_ of source files, adding an 
unused argument to many functions, which isn't attractive.

The other possibility is to test at runtime whether the kref pointer is 
NULL, and if it is, don't pass it.  This would work, but it isn't 
type-safe.

Finally, there's added complexity in each driver which wants to use the 
new facility.  The module_exit routine will need to be smart enough to 
block until all the private data structures have been released.  
usb-storage does something like that now; it's kind of ugly (although it 
could be improved if appropriate support were added to the core kernel).

Alan Stern

-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: refcounting drivers' data structures used in sysfs buffers, Alan Stern, (Fri Mar 9, 1:08 pm)
Re: 2.6.21-rc suspend regression: sysfs deadlock, Alan Stern, (Tue Mar 13, 8:00 am)
Re: 2.6.21-rc suspend regression: sysfs deadlock, Cornelia Huck, (Tue Mar 13, 11:42 am)
Re: 2.6.21-rc suspend regression: sysfs deadlock, Hugh Dickins, (Tue Mar 13, 12:00 pm)
Re: 2.6.21-rc suspend regression: sysfs deadlock, Alan Stern, (Tue Mar 13, 1:09 pm)
Re: 2.6.21-rc suspend regression: sysfs deadlock, Hugh Dickins, (Tue Mar 13, 1:55 pm)
Re: 2.6.21-rc suspend regression: sysfs deadlock, Dmitry Torokhov, (Tue Mar 13, 2:08 pm)
Re: 2.6.21-rc suspend regression: sysfs deadlock, Linus Torvalds, (Tue Mar 13, 2:20 pm)
Re: 2.6.21-rc suspend regression: sysfs deadlock, Alan Stern, (Tue Mar 13, 2:20 pm)
Re: 2.6.21-rc suspend regression: sysfs deadlock, Alan Stern, (Wed Mar 14, 9:12 am)
Re: 2.6.21-rc suspend regression: sysfs deadlock, Cornelia Huck, (Wed Mar 14, 11:43 am)
Re: 2.6.21-rc suspend regression: sysfs deadlock, Alan Stern, (Wed Mar 14, 12:23 pm)
Re: 2.6.21-rc suspend regression: sysfs deadlock, Cornelia Huck, (Thu Mar 15, 3:27 am)
Re: 2.6.21-rc suspend regression: sysfs deadlock, Hugh Dickins, (Thu Mar 15, 5:31 am)
Re: 2.6.21-rc suspend regression: sysfs deadlock, Oliver Neukum, (Thu Mar 15, 6:02 am)
Re: 2.6.21-rc suspend regression: sysfs deadlock, Dmitry Torokhov, (Thu Mar 15, 6:22 am)
Re: 2.6.21-rc suspend regression: sysfs deadlock, Hugh Dickins, (Thu Mar 15, 6:59 am)
Re: 2.6.21-rc suspend regression: sysfs deadlock, Alan Stern, (Thu Mar 15, 7:27 am)
Re: 2.6.21-rc suspend regression: sysfs deadlock, Cornelia Huck, (Thu Mar 15, 8:32 am)
Re: 2.6.21-rc suspend regression: sysfs deadlock, Hugh Dickins, (Thu Mar 15, 9:29 am)
Re: 2.6.21-rc suspend regression: sysfs deadlock, Linus Torvalds, (Thu Mar 15, 9:51 am)