On Mon, 27 Nov 2006, Oliver Neukum wrote: > > In sysfs_remove_file(), kobj->dentry is the dentry for the device, not for > > Therefore I got no ENODEV!
Exactly. > > the attribute. The place where you need to call orphan_all_buffers() is > > in inode.c:sysfs_drop_dentry(). I'm not sure exactly where in that > > routine is the correct spot to do it. Possibly just before the call to > > simple_unlink(), but I don't know enough about how the filesystem code > > works. > > _before_? IMHO the core of the problem is that you may have open > fds for which there is no dentry. The existing code drops the dentry, > thus preventing further open() calls, but the open files must be dissociated > from the buffers to free the buffers. Therefore the correct position > is _after_ the drop. Okay, yes. But it's still problematic... > > Logically there must be a race between sysfs_remove_file() and > > deallocating the inode (when there are no open file references). I > > don't know how this race is resolved; maybe in __d_drop(dentry). > > IMHO by a previous dropping all dentries, you make sure the usage count of > an inode will monotonically decrease. Sure. However suppose there used to be open file references and they have all been closed. The inode exists, but its usage count is 0 so it may be deallocated at any time. (I believe inodes remain for a while in some sort of cache even when they aren't in use.) Now the driver calls device_remove_file(). How does your new code in sysfs_drop_entry() prevent the inode from being deallocated while you are trying to call orphan_all_buffers()? Or even worse: Suppose the last open file reference gets closed and the inode gets deallocated precisely while the driver calls device_remove_file() and is running inside orphan_all_buffers(). How do you prevent the deallocation from happening before you release the inode's lock? Alan Stern ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel