nvme-multipath: path selection fixes
v2 cover nvme-multipath: path selection fixes
Hi all,
during analysing a mysterious failure due to blk_queue_split() (again) I've found that the multipath path selection might return invalid namespaces under certain circumstances.
This patchset fixes those scenarios.
As usual, reviews and comments are welcome.
Changes to v1:
- Use common helper nvme_path_is_disabled()
Hannes Reinecke (2):
nvme-multipath: check singular list in vme_round_robin_path()
nvme-multipath: do not select namespaces which are about to be removed
drivers/nvme/host/multipath.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
Signature · 1 line
2.16.4
PATCH v2 1/2 nvme-multipath: check singular list in vme_round_robin_path()
When we have a singular list in nvme_round_robin_path() we still need to check its validity.
--- drivers/nvme/host/multipath.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
drivers/nvme/host/multipath.c +12 -5
@@ -123,14 +123,19 @@ void nvme_mpath_clear_current_path(struct nvme_ns *ns) } } +static bool nvme_path_is_disabled (struct nvme_ns *ns) +{ +return ns->ctrl->state !=NVME_CTRL_LIVE || +test_bit (NVME_NS_ANA_PENDING , &ns->flags); +} +static struct nvme_ns *__nvme_find_path (struct nvme_ns_head *head,int node) {int found_distance =INT_MAX , fallback_distance =INT_MAX , distance;struct nvme_ns *found =NULL , *fallback =NULL , *ns;list_for_each_entry_rcu (ns, &head->list, siblings) { -if (ns->ctrl->state !=NVME_CTRL_LIVE || -test_bit (NVME_NS_ANA_PENDING , &ns->flags)) +if (nvme_path_is_disabled (ns))continue ;if (READ_ONCE (head->subsys->iopolicy) ==NVME_IOPOLICY_NUMA )
@@ -178,14 +183,16 @@ static struct nvme_ns *nvme_round_robin_path(struct nvme_ns_head *head, {struct nvme_ns *ns, *found, *fallback =NULL ; -if (list_is_singular (&head->list)) +if (list_is_singular (&head->list)) { +if (nvme_path_is_disabled (old)) +return NULL ;return old; + }for (ns =nvme_next_ns (head, old); ns != old; ns =nvme_next_ns (head, ns)) { -if (ns->ctrl->state !=NVME_CTRL_LIVE || -test_bit (NVME_NS_ANA_PENDING , &ns->flags)) +if (nvme_path_is_disabled (ns))continue ;if (ns->ana_state ==NVME_ANA_OPTIMIZED ) {
Signature · 1 line
2.16.4
PATCH v2 2/2 nvme-multipath: do not select namespaces which are about to be removed
In reply to Hannes Reineckenvme_ns_remove() will first set the NVME_NS_REMOVING flag before removing it from the list at the very last step.
So to avoid selecting a namespace in nvme_find_path() which is about to be removed check the NVME_NS_REMOVING flag, too, when selecting a new path.
--- drivers/nvme/host/multipath.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/nvme/host/multipath.c +2 -1
@@ -126,7 +126,8 @@ void nvme_mpath_clear_current_path(struct nvme_ns *ns)static bool nvme_path_is_disabled (struct nvme_ns *ns) {return ns->ctrl->state !=NVME_CTRL_LIVE || -test_bit (NVME_NS_ANA_PENDING , &ns->flags); +test_bit (NVME_NS_ANA_PENDING , &ns->flags) || +test_bit (NVME_NS_REMOVING , &ns->flags); }static struct nvme_ns *__nvme_find_path (struct nvme_ns_head *head,int node)
Signature · 1 line
2.16.4
Christoph Hellwig
maintainerv2 cover nvme-multipath: path selection fixes
In reply to Hannes ReineckeThanks,
I've split out the addition of the new nvme_path_is_disabled helper into a separate patch and then applied there series to the nvme-5.3 branch.