On Fri, May 02, 2014 at 03:19:52PM +0200, Jan Kara wrote: > Struct inode has an i_devices list head which is used when inode > represents a block device or a character device for tracking all inodes > referencing that device. The only use of that tracking is to remove > references to the device from inodes when the device is released. > However both block device and character device code take reference to > the device together with referencing it from an inode (block device > code takes inode reference, character device code kobj reference) thus > device cannot be released while there are any inodes referencing it. > > Remove the useless code and i_devices from struct inode. While I like the change I don't think it's quite correct. i_cdev starts out NULL and the inode is not added to the list for character devices. Then chrdev_open comes in and sets up i_cdev, as well as grabbing one reference per open, and __fput drops this reference. So far, so good - but for a char device node that was opened before but isn't open anymore we have the inode pointing to a struct cdev which doesn't have a reference. When we now unregister the char I think this can be easily solved by changing the cdev_put call in __fput into something that will clear i_cdev if it dropped the last references. In addition to that I would suggest to split this into 3 patches for bdev, cdev and final removal so that the steps are better documented. The block device side has similar problems because we only hold references on the block device inode, not the device inode. -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html