[PATCHv7] nvme: fix refcounting imbalance when all paths are down

Sagi Grimberg sagi at grimberg.me
Wed Jun 23 14:41:31 PDT 2021


>>> +void nvme_mpath_check_last_path(struct nvme_ns_head *head)
>>>    {
>>> +    bool last_path = false;
>>>        if (!head->disk)
>>>            return;
>>> -    if (head->disk->flags & GENHD_FL_UP) {
>>> -        nvme_cdev_del(&head->cdev, &head->cdev_device);
>>> -        del_gendisk(head->disk); > +
>>> +    /* Synchronize with nvme_init_ns_head() */
>>> +    mutex_lock(&head->subsys->lock);
>>> +    if (list_empty(&head->list)) {
>>> +        list_del_init(&head->entry);
>>> +        last_path = true;
>>>        }
>>
>> What happens now if CONFIG_NVME_MULTIPATH is not set? I'm not sure this
>> should be done here...
> 
> I don't mind _where_ this code ends up.
> As long as we can agree that we should do both, list_del_init() and
> del_gendisk() at the same time when we find that the last path is dead.
> Do we?

Yes, and independently from user/fs references...



More information about the Linux-nvme mailing list