Re: [PATCH] device-dax: don't set kobj parent during cdev init
From: Dan Williams
Date: Sat Feb 11 2017 - 13:27:54 EST
On Sat, Feb 11, 2017 at 9:59 AM, Logan Gunthorpe <logang@xxxxxxxxxxxx> wrote:
> On 11/02/17 01:56 AM, Dan Williams wrote:
>>
>> When the device is unregistered it invalidates all existing mappings,
>> but the driver may continue to service vm fault requests until the
>> final put of the cdev. Until that time the fault handler needs to be
>> able to check dax_dev->alive. Since the final cdev put is handled by
>> the vfs I use the cdev's kobject to keep the struct dax_dev instance
>> alive.
>
>
> I'm just taking a wild stab at this, but would it not make sense to just
> take a reference to the dax_dev device in dax_open and put it back it in
> dax_release? (Or perhaps, in the open/close of the vm_ops.) That way the
> structure won't be free'd until there are no users and alive will always be
> accessible.
>
> It would also be a bit more clear as to what's going on because you are
> actually making a reference in filp->private_data.
>
Why, when the lifetime of the cdev is already correct?
See commit ba09c01d2fa8 "dax: convert to the cdev api". I used to take
explicit references like you suggest, but cdev made it cleaner.