Re: [PATCH RESEND] char_dev: add cdev->release() and convert cdev_alloc()to use it

From: Tejun Heo
Date: Thu Aug 28 2008 - 13:57:32 EST


Greg KH wrote:
>> The problem is not the device to talk to CUSE (/dev/cuse as in
>> /dev/fuse), for which module refcount and device refcount match fine.
>> But the whole point of CUSE is allowing CUSE clients to create arbitrary
>> character devices, so in addition to /dev/cuse which clients use to talk
>> to CUSE, CUSE hosts character devices for its clients and they come and
>> go dynamically and thus requires proper lifetime management.
>
> That's fine, it's just like a USB device that uses a cdev, right? Or a
> PCI device, or any other type of device that can come and go independant
> of the cdev or module lifespan.
>
> So, you tie the cdev lifespan to the module lifespan with the
> MODULE_OWNER in the file operations. As the cuse.ko module will own the
> cdev, it can handle that reference, and it can not be removed as long as
> userspace has the cdev open, right?
>
> It really isn't any different from any other type of removable device
> (i.e. any type of device...)

Ah.. right, but taking cdev refcount out of the picture requires adding
'severing' operation on cdev f_ops, which certainly is doable but isn't
it just cleaner to make cdev follow the usual lifetime management rules?
An object which is referenced counted requires ->release if it's gonna
be used in any non-simplistic way.

Thanks.

--
tejun
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/