Re: [PATCH] device-dax: don't set kobj parent during cdev init

Logan Gunthorpe
2017-02-11T17:59:20Z

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.

Logan