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

Keith Busch kbusch at kernel.org
Mon Jun 21 10:26:53 PDT 2021


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.



More information about the Linux-nvme mailing list