[PATCH v2] nvme: remove namespaces in parallel

Daniel Wagner dwagner at suse.de
Tue Nov 3 08:19:42 PST 2026


On Tue, Nov 03, 2026 at 01:28:02AM -0500, Qiliang Yuan wrote:
> +static void nvme_ns_remove_async(void *data, async_cookie_t cookie)
> +{
> +	nvme_ns_remove(data);
> +}
> +
>  /*
>   * This function iterates the namespace list unlocked to allow recovery from
>   * controller failure. It is up to the caller to ensure the namespace list is
> @@ -4725,6 +4730,7 @@ void nvme_remove_namespaces(struct nvme_ctrl *ctrl)
>  {
>  	struct nvme_ns *ns, *next;
>  	LIST_HEAD(ns_list);
> +	ASYNC_DOMAIN(domain);
>  
>  	/*
>  	 * make sure to requeue I/O to all namespaces as these
> @@ -4759,8 +4765,13 @@ void nvme_remove_namespaces(struct nvme_ctrl *ctrl)
>  	mutex_unlock(&ctrl->namespaces_lock);
>  	synchronize_srcu(&ctrl->srcu);
>  
> +	/*
> +	 * Remove the namespaces in parallel, as each removal waits for several
> +	 * RCU grace periods.
> +	 */
>  	list_for_each_entry_safe(ns, next, &ns_list, list)
> -		nvme_ns_remove(ns);
> +		async_schedule_domain(nvme_ns_remove_async, ns, &domain);
> +	async_synchronize_full_domain(&domain);

Nice! 

Reviewed-by: Daniel Wagner <dwagner at suse.de>



More information about the Linux-nvme mailing list