nvme-multipath: relax ANA state check
PATCH 1/1 nvme-multipath: relax ANA state check
From: Martin George <[email protected]>
The current nvme multipath code prevents access to a namespace through a controller that has transitioned from ANA Optimized to Non-Optimized and vice versa. As per the NVMe 1.3 TP4004 spec, "The change from one asymmetric namespace access state to another asymmetric namespace access state is called a transition". The emphasis here is on the change itself, whatever the change may be. So a change from ANA Optimized to Non-Optimized and vice versa, are actually valid transition scenarios. In fact, if one were to exit and reenter the same state, that too is a change i.e. a change to the same state is also a valid transition scenario.
So remove the "old" state check during ANA state update, so that transition from ANA Optimized to Non-Optimized and vice versa, along with transition to the same state, are all permitted.
--- drivers/nvme/host/multipath.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/nvme/host/multipath.c +1 -4
@@ -366,15 +366,12 @@ static inline bool nvme_state_is_live(enum nvme_ana_state state)static void nvme_update_ns_ana_state (struct nvme_ana_group_desc *desc,struct nvme_ns *ns) { -enum nvme_ana_state old; -mutex_lock (&ns->head->lock); - old = ns->ana_state; ns->ana_grpid =le32_to_cpu (desc->grpid); ns->ana_state = desc->state;clear_bit (NVME_NS_ANA_PENDING , &ns->flags); -if (nvme_state_is_live (ns->ana_state) && !nvme_state_is_live (old)) +if (nvme_state_is_live (ns->ana_state))nvme_mpath_set_live (ns);mutex_unlock (&ns->head->lock); }
Signature · 1 line
2.17.1
PATCH 1/1 nvme-multipath: relax ANA state check
Quoted 37 lines · On 1/25/19 12:12 PM, [email protected] wrote:
From: Martin George <marting at netapp.com>
The current nvme multipath code prevents access to a namespace through a controller that has transitioned from ANA Optimized to Non-Optimized and vice versa. As per the NVMe 1.3 TP4004 spec, "The change from one asymmetric namespace access state to another asymmetric namespace access state is called a transition". The emphasis here is on the change itself, whatever the change may be. So a change from ANA Optimized to Non-Optimized and vice versa, are actually valid transition scenarios. In fact, if one were to exit and reenter the same state, that too is a change i.e. a change to the same state is also a valid transition scenario.
So remove the "old" state check during ANA state update, so that transition from ANA Optimized to Non-Optimized and vice versa, along with transition to the same state, are all permitted.
Signed-off-by Martin George <marting at netapp.com>Signed-off-by Gargi Srinivas <sring at netapp.com>--- drivers/nvme/host/multipath.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)drivers/nvme/host/multipath.c +0
-2@@ -366,15 +366,12 @@ static inline bool nvme_state_is_live(enum nvme_ana_state state)static void nvme_update_ns_ana_state (struct nvme_ana_group_desc *desc,struct nvme_ns *ns) { -enum nvme_ana_state old; -mutex_lock (&ns->head->lock);
drivers/nvme/host/multipath.c static inline bool nvme_state_is_live(enum nvme_ana_state state) · line 377
Quoted 10 lines
drivers/nvme/host/multipath.c +1
-2- old = ns->ana_state; ns->ana_grpid =le32_to_cpu (desc->grpid); ns->ana_state = desc->state;clear_bit (NVME_NS_ANA_PENDING , &ns->flags); -if (nvme_state_is_live (ns->ana_state) && !nvme_state_is_live (old)) +if (nvme_state_is_live (ns->ana_state))nvme_mpath_set_live (ns);mutex_unlock (&ns->head->lock); }
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke Teamlead Storage & Networking hare at suse.de +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N?rnberg GF: F. Imend?rffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG N?rnberg)
Christoph Hellwig
maintainerPATCH 1/1 nvme-multipath: relax ANA state check
In reply to [email protected]Quoted 5 lines · On Fri, Jan 25, 2019@04:42:36PM +0530, [email protected] wrote:
From: Martin George <marting at netapp.com>
The current nvme multipath code prevents access to a namespace through a controller that has transitioned from ANA Optimized to Non-Optimized and vice versa.
Note: controllers do not have ANA states, ANA groups and thus namespaces have states.
Quoted 10 lines
As per the NVMe 1.3 TP4004
spec, "The change from one asymmetric namespace access state to another asymmetric namespace access state is called a transition". The emphasis here is on the change itself, whatever the change may be. So a change from ANA Optimized to Non-Optimized and vice versa, are actually valid transition scenarios. In fact, if one were to exit and reenter the same state, that too is a change i.e. a change to the same state is also a valid transition scenario.
Quoted 4 lines
So remove the "old" state check during ANA state update, so that transition from ANA Optimized to Non-Optimized and vice versa, along with transition to the same state, are all permitted.
This description does not seem to match the patch:
Quoted 4 lines
static void nvme_update_ns_ana_state(struct
nvme_ana_group_desc*desc,drivers/nvme/host/multipath.c +0
-1struct nvme_ns *ns) { -enum nvme_ana_state old;
drivers/nvme/host/multipath.c static inline bool nvme_state_is_live(enum nvme_ana_state state) · line 375
Quoted 10 lines
drivers/nvme/host/multipath.c +1
-3-mutex_lock (&ns->head->lock); - old = ns->ana_state; ns->ana_grpid =le32_to_cpu (desc->grpid); ns->ana_state = desc->state;clear_bit (NVME_NS_ANA_PENDING , &ns->flags); -if (nvme_state_is_live (ns->ana_state) && !nvme_state_is_live (old)) +if (nvme_state_is_live (ns->ana_state))nvme_mpath_set_live (ns);
What the patch does is to always call nvme_mpath_set_live when transitioning to a live state, where live is defined as optimized or non-optimized, instead of limiting that call to transitions from states that were not considered live.
PATCH 1/1 nvme-multipath: relax ANA state check
Quoted 20 lines · Christoph Hellwig
This description does not seem to match the patch:
Quoted 15 lines
static void nvme_update_ns_ana_state(struct
nvme_ana_group_desc
*desc,
structnvme_ns*ns)
{drivers/nvme/host/multipath.c +0
-4-enum nvme_ana_state old; -mutex_lock (&ns->head->lock); - old = ns->ana_state; ns->ana_grpid =le32_to_cpu (desc->grpid); ns->ana_state = desc->state;clear_bit (NVME_NS_ANA_PENDING , &ns->flags); - if (nvme_state_is_live(ns->ana_state) &&!nvme_state_is_live(old))
+ if (nvme_state_is_live(ns->ana_state))Quoted 1 line
nvme_mpath_set_live(ns);
Quoted 4 lines
What the patch does is to always call
nvme_mpath_set_livewhen transitioning to a live state, where live is defined as optimized or non-optimized, instead of limiting that call to transitions from states that were not considered live.
Ok. Will modify the description accordingly and resend the patch. Thank you.
-Martin George