nvme-mpath: fix last path removal during traffic

In case our last path is removed during traffic, we can end up requeueing
the bio(s) but never schedule the actual requeue work as upper layers
still have open handles on the mpath device node.

Fix this by scheduling requeue work if the namespace being removed is
the last path in the ns_head path list.

Fixes: 32acab3181c7 ("nvme: implement multipath access to nvme subsystems")
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Christoph Hellwig <hch@lst.de>

authored by Sagi Grimberg and committed by Christoph Hellwig 479a322f d5bf4b7f

+13
+1
drivers/nvme/host/core.c
··· 2991 2991 mutex_unlock(&ns->ctrl->namespaces_mutex); 2992 2992 2993 2993 synchronize_srcu(&ns->head->srcu); 2994 + nvme_mpath_check_last_path(ns); 2994 2995 nvme_put_ns(ns); 2995 2996 } 2996 2997
+12
drivers/nvme/host/nvme.h
··· 417 417 rcu_assign_pointer(head->current_path, NULL); 418 418 } 419 419 struct nvme_ns *nvme_find_path(struct nvme_ns_head *head); 420 + 421 + static inline void nvme_mpath_check_last_path(struct nvme_ns *ns) 422 + { 423 + struct nvme_ns_head *head = ns->head; 424 + 425 + if (head->disk && list_empty(&head->list)) 426 + kblockd_schedule_work(&head->requeue_work); 427 + } 428 + 420 429 #else 421 430 static inline void nvme_failover_req(struct request *req) 422 431 { ··· 455 446 { 456 447 } 457 448 static inline void nvme_mpath_clear_current_path(struct nvme_ns *ns) 449 + { 450 + } 451 + static inline void nvme_mpath_check_last_path(struct nvme_ns *ns) 458 452 { 459 453 } 460 454 #endif /* CONFIG_NVME_MULTIPATH */