[PATCHv6] nvme: allow to re-attach namespaces after all paths are down

Hannes Reinecke hare at suse.de
Mon Jun 21 23:21:53 PDT 2021


On 6/21/21 7:26 PM, Keith Busch wrote:
> On Wed, Jun 09, 2021 at 05:01:18PM +0200, Hannes Reinecke wrote:
>> -void nvme_mpath_remove_disk(struct nvme_ns_head *head)
>> +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))
>> +		last_path = true;
>> +	mutex_unlock(&head->subsys->lock);
>> +	if (last_path) {
>> +		kblockd_schedule_work(&head->requeue_work);
>> +		if (head->disk->flags & GENHD_FL_UP) {
>> +			nvme_cdev_del(&head->cdev, &head->cdev_device);
>> +			del_gendisk(head->disk);
>> +		}
>>   	}
>> +}
> 
> This is being called when a path is removed. If it is the last path, the
> head's block device is being deleted. If a live head reference is held,
> and the a path reconnects, the code will find the previous head, but the
> disk is gone and it's not coming back, so the new connection can't be
> used.
> 
Good point. But that can be fixed by removing the ns_head from the 
subsystem list at this check rather than in nvme_free_ns_head().
Will be sending an updated version.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke                Kernel Storage Architect
hare at suse.de                              +49 911 74053 688
SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer



More information about the Linux-nvme mailing list