linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCHv4 0/4] Fixup return value for nvme_submit_sync_cmd()
@ 2021-02-26  7:17 Hannes Reinecke
  2021-02-26  7:17 ` [PATCH 1/4] nvme: simplify error logic in nvme_validate_ns() Hannes Reinecke
                   ` (5 more replies)
  0 siblings, 6 replies; 18+ messages in thread
From: Hannes Reinecke @ 2021-02-26  7:17 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-nvme, Sagi Grimberg, Keith Busch, Hannes Reinecke

Hi all,

here are some small patches for fixing up the return value of
nvme_submit_sync_cmd().
As Keith correctly noted, nvme_submit_sync_cmd() should be returning
an error if the command could not be performed; however, currently
only pci does that.
So we need to fix up nvme_cancel_request() to return an -EINTR
on any pending sync commands during reset.
And modify nvme-fc to return the same nvme status after timing out
or cancelling requests.

As usual, comments and reviews are welcome.

Changes to v3:
- Dropped patch to change the status code for aborted commands
- Dropped patch to set -ETIMEDOUT on timed out commands
- Include reviews from Chao Leng

Changes to v2:
- Include reviews from Sagi
- Simplify error logic from nvme_validate_ns()

Changes to v1:
- Include reviews from Daniel
- Include changes for nvme-fc to return the same status as the
  other transports

Hannes Reinecke (4):
  nvme: simplify error logic in nvme_validate_ns()
  nvme: add NVME_REQ_CANCELLED flag in nvme_cancel_request()
  nvme-fc: set NVME_REQ_CANCELLED in nvme_fc_terminate_exchange()
  nvme-fc: return NVME_SC_HOST_ABORTED_CMD when a command has been
    aborted

 drivers/nvme/host/core.c | 9 +++++----
 drivers/nvme/host/fc.c   | 3 ++-
 2 files changed, 7 insertions(+), 5 deletions(-)

-- 
2.29.2


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 1/4] nvme: simplify error logic in nvme_validate_ns()
  2021-02-26  7:17 [PATCHv4 0/4] Fixup return value for nvme_submit_sync_cmd() Hannes Reinecke
@ 2021-02-26  7:17 ` Hannes Reinecke
  2021-02-26  9:10   ` Daniel Wagner
  2021-03-05 21:59   ` Sagi Grimberg
  2021-02-26  7:17 ` [PATCH 2/4] nvme: add NVME_REQ_CANCELLED flag in nvme_cancel_request() Hannes Reinecke
                   ` (4 subsequent siblings)
  5 siblings, 2 replies; 18+ messages in thread
From: Hannes Reinecke @ 2021-02-26  7:17 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Keith Busch, linux-nvme, Sagi Grimberg, Keith Busch, Hannes Reinecke

We only should remove namespaces when we get fatal error back from
the device or when the namespace IDs have changed.
So instead of painfully masking out error numbers which might indicate
that the error should be ignored we could use an NVME status code
to indicated when the namespace should be removed.
That simplifies the final logic and makes it less error-prone.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Keith Busch <kbusch@kernel.org>
---
 drivers/nvme/host/core.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index d77f3f26d8d3..bde1b22ca7f2 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -1439,7 +1439,7 @@ static int nvme_identify_ns(struct nvme_ctrl *ctrl, unsigned nsid,
 		goto out_free_id;
 	}
 
-	error = -ENODEV;
+	error = NVME_SC_INVALID_NS | NVME_SC_DNR;
 	if ((*id)->ncap == 0) /* namespace not allocated or attached */
 		goto out_free_id;
 
@@ -4036,7 +4036,7 @@ static void nvme_ns_remove_by_nsid(struct nvme_ctrl *ctrl, u32 nsid)
 static void nvme_validate_ns(struct nvme_ns *ns, struct nvme_ns_ids *ids)
 {
 	struct nvme_id_ns *id;
-	int ret = -ENODEV;
+	int ret = NVME_SC_INVALID_NS | NVME_SC_DNR;
 
 	if (test_bit(NVME_NS_DEAD, &ns->flags))
 		goto out;
@@ -4045,7 +4045,7 @@ static void nvme_validate_ns(struct nvme_ns *ns, struct nvme_ns_ids *ids)
 	if (ret)
 		goto out;
 
-	ret = -ENODEV;
+	ret = NVME_SC_INVALID_NS | NVME_SC_DNR;
 	if (!nvme_ns_ids_equal(&ns->head->ids, ids)) {
 		dev_err(ns->ctrl->device,
 			"identifiers changed for nsid %d\n", ns->head->ns_id);
@@ -4063,7 +4063,7 @@ static void nvme_validate_ns(struct nvme_ns *ns, struct nvme_ns_ids *ids)
 	 *
 	 * TODO: we should probably schedule a delayed retry here.
 	 */
-	if (ret && ret != -ENOMEM && !(ret > 0 && !(ret & NVME_SC_DNR)))
+	if (ret > 0 && (ret & NVME_SC_DNR))
 		nvme_ns_remove(ns);
 }
 
-- 
2.29.2


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 2/4] nvme: add NVME_REQ_CANCELLED flag in nvme_cancel_request()
  2021-02-26  7:17 [PATCHv4 0/4] Fixup return value for nvme_submit_sync_cmd() Hannes Reinecke
  2021-02-26  7:17 ` [PATCH 1/4] nvme: simplify error logic in nvme_validate_ns() Hannes Reinecke
@ 2021-02-26  7:17 ` Hannes Reinecke
  2021-03-05 21:59   ` Sagi Grimberg
  2021-02-26  7:17 ` [PATCH 3/4] nvme-fc: set NVME_REQ_CANCELLED in nvme_fc_terminate_exchange() Hannes Reinecke
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 18+ messages in thread
From: Hannes Reinecke @ 2021-02-26  7:17 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Keith Busch, Sagi Grimberg, Daniel Wagner, linux-nvme,
	Hannes Reinecke, Chao Leng, Keith Busch

NVME_REQ_CANCELLED is translated into -EINTR in nvme_submit_sync_cmd(),
so we should be setting this flags during nvme_cancel_request() to
ensure that the callers to nvme_submit_sync_cmd() will get the correct
error code when the controller is reset.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Reviewed-by: Keith Busch <kbusch@kernel.org>
Reviewed-by: Chao Leng <lengchao@huawei.com>
---
 drivers/nvme/host/core.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index bde1b22ca7f2..bf32460c180a 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -380,6 +380,7 @@ bool nvme_cancel_request(struct request *req, void *data, bool reserved)
 		return true;
 
 	nvme_req(req)->status = NVME_SC_HOST_ABORTED_CMD;
+	nvme_req(req)->flags |= NVME_REQ_CANCELLED;
 	blk_mq_complete_request(req);
 	return true;
 }
-- 
2.29.2


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 3/4] nvme-fc: set NVME_REQ_CANCELLED in nvme_fc_terminate_exchange()
  2021-02-26  7:17 [PATCHv4 0/4] Fixup return value for nvme_submit_sync_cmd() Hannes Reinecke
  2021-02-26  7:17 ` [PATCH 1/4] nvme: simplify error logic in nvme_validate_ns() Hannes Reinecke
  2021-02-26  7:17 ` [PATCH 2/4] nvme: add NVME_REQ_CANCELLED flag in nvme_cancel_request() Hannes Reinecke
@ 2021-02-26  7:17 ` Hannes Reinecke
  2021-03-05 21:59   ` Sagi Grimberg
  2021-03-06 19:16   ` James Smart
  2021-02-26  7:17 ` [PATCH 4/4] nvme-fc: return NVME_SC_HOST_ABORTED_CMD when a command has been aborted Hannes Reinecke
                   ` (2 subsequent siblings)
  5 siblings, 2 replies; 18+ messages in thread
From: Hannes Reinecke @ 2021-02-26  7:17 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Keith Busch, Sagi Grimberg, Daniel Wagner, James Smart,
	linux-nvme, Hannes Reinecke, Keith Busch

nvme_fc_terminate_exchange() is being called when exchanges are
being deleted, and as such we should be setting the NVME_REQ_CANCELLED
flag to have identical behaviour on all transports.

Cc: James Smart <james.smart@broadcom.com>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Reviewed-by: Keith Busch <kbusch@kernel.org>
---
 drivers/nvme/host/fc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c
index 20dadd86e981..ef12a619daec 100644
--- a/drivers/nvme/host/fc.c
+++ b/drivers/nvme/host/fc.c
@@ -2443,6 +2443,7 @@ nvme_fc_terminate_exchange(struct request *req, void *data, bool reserved)
 	struct nvme_fc_ctrl *ctrl = to_fc_ctrl(nctrl);
 	struct nvme_fc_fcp_op *op = blk_mq_rq_to_pdu(req);
 
+	op->nreq.flags |= NVME_REQ_CANCELLED;
 	__nvme_fc_abort_op(ctrl, op);
 	return true;
 }
-- 
2.29.2


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 4/4] nvme-fc: return NVME_SC_HOST_ABORTED_CMD when a command has been aborted
  2021-02-26  7:17 [PATCHv4 0/4] Fixup return value for nvme_submit_sync_cmd() Hannes Reinecke
                   ` (2 preceding siblings ...)
  2021-02-26  7:17 ` [PATCH 3/4] nvme-fc: set NVME_REQ_CANCELLED in nvme_fc_terminate_exchange() Hannes Reinecke
@ 2021-02-26  7:17 ` Hannes Reinecke
  2021-03-01 19:07   ` James Smart
                     ` (2 more replies)
  2021-02-26  9:21 ` [PATCHv4 0/4] Fixup return value for nvme_submit_sync_cmd() Chao Leng
  2021-03-09 10:05 ` Christoph Hellwig
  5 siblings, 3 replies; 18+ messages in thread
From: Hannes Reinecke @ 2021-02-26  7:17 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Keith Busch, Sagi Grimberg, Daniel Wagner, James Smart,
	linux-nvme, Hannes Reinecke

When a command has been aborted we should return NVME_SC_HOST_ABORTED_CMD
to be consistent with the other transports.

Cc: James Smart <james.smart@broadcom.com>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Daniel Wagner <dwagner@suse.de>
---
 drivers/nvme/host/fc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c
index ef12a619daec..97e3424c7b03 100644
--- a/drivers/nvme/host/fc.c
+++ b/drivers/nvme/host/fc.c
@@ -1956,7 +1956,7 @@ nvme_fc_fcpio_done(struct nvmefc_fcp_req *req)
 				sizeof(op->rsp_iu), DMA_FROM_DEVICE);
 
 	if (opstate == FCPOP_STATE_ABORTED)
-		status = cpu_to_le16(NVME_SC_HOST_PATH_ERROR << 1);
+		status = cpu_to_le16(NVME_SC_HOST_ABORTED_CMD << 1);
 	else if (freq->status) {
 		status = cpu_to_le16(NVME_SC_HOST_PATH_ERROR << 1);
 		dev_info(ctrl->ctrl.device,
-- 
2.29.2


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [PATCH 1/4] nvme: simplify error logic in nvme_validate_ns()
  2021-02-26  7:17 ` [PATCH 1/4] nvme: simplify error logic in nvme_validate_ns() Hannes Reinecke
@ 2021-02-26  9:10   ` Daniel Wagner
  2021-02-26  9:24     ` Hannes Reinecke
  2021-03-05 21:59   ` Sagi Grimberg
  1 sibling, 1 reply; 18+ messages in thread
From: Daniel Wagner @ 2021-02-26  9:10 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: Keith Busch, Keith Busch, Christoph Hellwig, linux-nvme, Sagi Grimberg

Hi Hannes,

On Fri, Feb 26, 2021 at 08:17:25AM +0100, Hannes Reinecke wrote:
> @@ -4045,7 +4045,7 @@ static void nvme_validate_ns(struct nvme_ns *ns, struct nvme_ns_ids *ids)
>  	if (ret)
>  		goto out;
>  
> -	ret = -ENODEV;
> +	ret = NVME_SC_INVALID_NS | NVME_SC_DNR;
>  	if (!nvme_ns_ids_equal(&ns->head->ids, ids)) {
>  		dev_err(ns->ctrl->device,
>  			"identifiers changed for nsid %d\n", ns->head->ns_id);
> @@ -4063,7 +4063,7 @@ static void nvme_validate_ns(struct nvme_ns *ns, struct nvme_ns_ids *ids)
>  	 *
>  	 * TODO: we should probably schedule a delayed retry here.
>  	 */
> -	if (ret && ret != -ENOMEM && !(ret > 0 && !(ret & NVME_SC_DNR)))
> +	if (ret > 0 && (ret & NVME_SC_DNR))
>  		nvme_ns_remove(ns);

I think Chao's comment still holds, nvme_update_ns_info() can return
-EINVAL, -IEO or -ENODEV. Don't we have to remove the NS in these
cases?

Thanks,
Daniel

_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCHv4 0/4] Fixup return value for nvme_submit_sync_cmd()
  2021-02-26  7:17 [PATCHv4 0/4] Fixup return value for nvme_submit_sync_cmd() Hannes Reinecke
                   ` (3 preceding siblings ...)
  2021-02-26  7:17 ` [PATCH 4/4] nvme-fc: return NVME_SC_HOST_ABORTED_CMD when a command has been aborted Hannes Reinecke
@ 2021-02-26  9:21 ` Chao Leng
  2021-03-09 10:05 ` Christoph Hellwig
  5 siblings, 0 replies; 18+ messages in thread
From: Chao Leng @ 2021-02-26  9:21 UTC (permalink / raw)
  To: Hannes Reinecke, Christoph Hellwig; +Cc: Keith Busch, Sagi Grimberg, linux-nvme



On 2021/2/26 15:17, Hannes Reinecke wrote:
> Hi all,
> 
> here are some small patches for fixing up the return value of
> nvme_submit_sync_cmd().
> As Keith correctly noted, nvme_submit_sync_cmd() should be returning
> an error if the command could not be performed; however, currently
> only pci does that.
> So we need to fix up nvme_cancel_request() to return an -EINTR
> on any pending sync commands during reset.
> And modify nvme-fc to return the same nvme status after timing out
> or cancelling requests.
> 
> As usual, comments and reviews are welcome.
> 
> Changes to v3:
> - Dropped patch to change the status code for aborted commands
> - Dropped patch to set -ETIMEDOUT on timed out commands
->timeout() also need to consider, maybe can add the flag:NVME_REQ_CANCELLED
like nvme_cancel_request.
> - Include reviews from Chao Leng
> 
> Changes to v2:
> - Include reviews from Sagi
> - Simplify error logic from nvme_validate_ns()
> 
> Changes to v1:
> - Include reviews from Daniel
> - Include changes for nvme-fc to return the same status as the
>    other transports
> 
> Hannes Reinecke (4):
>    nvme: simplify error logic in nvme_validate_ns()
>    nvme: add NVME_REQ_CANCELLED flag in nvme_cancel_request()
>    nvme-fc: set NVME_REQ_CANCELLED in nvme_fc_terminate_exchange()
>    nvme-fc: return NVME_SC_HOST_ABORTED_CMD when a command has been
>      aborted
> 
>   drivers/nvme/host/core.c | 9 +++++----
>   drivers/nvme/host/fc.c   | 3 ++-
>   2 files changed, 7 insertions(+), 5 deletions(-)
> 

_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 1/4] nvme: simplify error logic in nvme_validate_ns()
  2021-02-26  9:10   ` Daniel Wagner
@ 2021-02-26  9:24     ` Hannes Reinecke
  2021-02-26  9:55       ` Daniel Wagner
  0 siblings, 1 reply; 18+ messages in thread
From: Hannes Reinecke @ 2021-02-26  9:24 UTC (permalink / raw)
  To: Daniel Wagner
  Cc: Keith Busch, Keith Busch, Christoph Hellwig, linux-nvme, Sagi Grimberg

On 2/26/21 10:10 AM, Daniel Wagner wrote:
> Hi Hannes,
> 
> On Fri, Feb 26, 2021 at 08:17:25AM +0100, Hannes Reinecke wrote:
>> @@ -4045,7 +4045,7 @@ static void nvme_validate_ns(struct nvme_ns *ns, struct nvme_ns_ids *ids)
>>   	if (ret)
>>   		goto out;
>>   
>> -	ret = -ENODEV;
>> +	ret = NVME_SC_INVALID_NS | NVME_SC_DNR;
>>   	if (!nvme_ns_ids_equal(&ns->head->ids, ids)) {
>>   		dev_err(ns->ctrl->device,
>>   			"identifiers changed for nsid %d\n", ns->head->ns_id);
>> @@ -4063,7 +4063,7 @@ static void nvme_validate_ns(struct nvme_ns *ns, struct nvme_ns_ids *ids)
>>   	 *
>>   	 * TODO: we should probably schedule a delayed retry here.
>>   	 */
>> -	if (ret && ret != -ENOMEM && !(ret > 0 && !(ret & NVME_SC_DNR)))
>> +	if (ret > 0 && (ret & NVME_SC_DNR))
>>   		nvme_ns_remove(ns);
> 
> I think Chao's comment still holds, nvme_update_ns_info() can return
> -EINVAL, -IEO or -ENODEV. Don't we have to remove the NS in these
> cases?
> 
I thought I had fixed up all instances where we can return -ENODEV; and 
all others are indeed transport or transient error which should not 
result in a namespace removal.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke                Kernel Storage Architect
hare@suse.de                              +49 911 74053 688
SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer

_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 1/4] nvme: simplify error logic in nvme_validate_ns()
  2021-02-26  9:24     ` Hannes Reinecke
@ 2021-02-26  9:55       ` Daniel Wagner
  0 siblings, 0 replies; 18+ messages in thread
From: Daniel Wagner @ 2021-02-26  9:55 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: Keith Busch, Keith Busch, Christoph Hellwig, linux-nvme, Sagi Grimberg

On Fri, Feb 26, 2021 at 10:24:46AM +0100, Hannes Reinecke wrote:
> I thought I had fixed up all instances where we can return -ENODEV; and all
> others are indeed transport or transient error which should not result in a
> namespace removal.

I think I was digging through the wrong tree. There is indeed no ENODEV
in nvme/nvme-5.12. Sorry about the noise.

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



_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 4/4] nvme-fc: return NVME_SC_HOST_ABORTED_CMD when a command has been aborted
  2021-02-26  7:17 ` [PATCH 4/4] nvme-fc: return NVME_SC_HOST_ABORTED_CMD when a command has been aborted Hannes Reinecke
@ 2021-03-01 19:07   ` James Smart
  2021-03-02  7:09     ` Hannes Reinecke
  2021-03-05 22:00   ` Sagi Grimberg
  2021-03-06 19:17   ` James Smart
  2 siblings, 1 reply; 18+ messages in thread
From: James Smart @ 2021-03-01 19:07 UTC (permalink / raw)
  To: Hannes Reinecke, Christoph Hellwig
  Cc: linux-nvme, Daniel Wagner, Sagi Grimberg, Keith Busch

On 2/25/2021 11:17 PM, Hannes Reinecke wrote:
> When a command has been aborted we should return NVME_SC_HOST_ABORTED_CMD
> to be consistent with the other transports.
>
> Cc: James Smart <james.smart@broadcom.com>
> Signed-off-by: Hannes Reinecke <hare@suse.de>
> Reviewed-by: Daniel Wagner <dwagner@suse.de>
> ---
>   drivers/nvme/host/fc.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c
> index ef12a619daec..97e3424c7b03 100644
> --- a/drivers/nvme/host/fc.c
> +++ b/drivers/nvme/host/fc.c
> @@ -1956,7 +1956,7 @@ nvme_fc_fcpio_done(struct nvmefc_fcp_req *req)
>   				sizeof(op->rsp_iu), DMA_FROM_DEVICE);
>   
>   	if (opstate == FCPOP_STATE_ABORTED)
> -		status = cpu_to_le16(NVME_SC_HOST_PATH_ERROR << 1);
> +		status = cpu_to_le16(NVME_SC_HOST_ABORTED_CMD << 1);
>   	else if (freq->status) {
>   		status = cpu_to_le16(NVME_SC_HOST_PATH_ERROR << 1);
>   		dev_info(ctrl->ctrl.device,

Is there a difference between an I/O aborted by a NVME ABORT cmd vs a 
transport-cancelled io ?   This line is more the transport-cancelled io.

-- james


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 4/4] nvme-fc: return NVME_SC_HOST_ABORTED_CMD when a command has been aborted
  2021-03-01 19:07   ` James Smart
@ 2021-03-02  7:09     ` Hannes Reinecke
  0 siblings, 0 replies; 18+ messages in thread
From: Hannes Reinecke @ 2021-03-02  7:09 UTC (permalink / raw)
  To: James Smart, Christoph Hellwig
  Cc: linux-nvme, Daniel Wagner, Sagi Grimberg, Keith Busch

On 3/1/21 8:07 PM, James Smart wrote:
> On 2/25/2021 11:17 PM, Hannes Reinecke wrote:
>> When a command has been aborted we should return NVME_SC_HOST_ABORTED_CMD
>> to be consistent with the other transports.
>>
>> Cc: James Smart <james.smart@broadcom.com>
>> Signed-off-by: Hannes Reinecke <hare@suse.de>
>> Reviewed-by: Daniel Wagner <dwagner@suse.de>
>> ---
>>   drivers/nvme/host/fc.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c
>> index ef12a619daec..97e3424c7b03 100644
>> --- a/drivers/nvme/host/fc.c
>> +++ b/drivers/nvme/host/fc.c
>> @@ -1956,7 +1956,7 @@ nvme_fc_fcpio_done(struct nvmefc_fcp_req *req)
>>                   sizeof(op->rsp_iu), DMA_FROM_DEVICE);
>>         if (opstate == FCPOP_STATE_ABORTED)
>> -        status = cpu_to_le16(NVME_SC_HOST_PATH_ERROR << 1);
>> +        status = cpu_to_le16(NVME_SC_HOST_ABORTED_CMD << 1);
>>       else if (freq->status) {
>>           status = cpu_to_le16(NVME_SC_HOST_PATH_ERROR << 1);
>>           dev_info(ctrl->ctrl.device,
> 
> Is there a difference between an I/O aborted by a NVME ABORT cmd vs a
> transport-cancelled io ?   This line is more the transport-cancelled io.
> 
Well, as we have several distinct error codes for that:

0x07 (Command abort requested) is for commands terminated by NVME Abort
0x08 (Command aborted due to SQ deletion) is for commands terminated due
to an explicit 'Delete I/O submission queue' command
0x370 (Host pathing error) is for any random host pathing error
0x371 (Command aborted by host) is for commands being aborted 'as a
result of a host action'

arguably both (0x370 and 0x371) can be used when failing I/O on path
loss, but all other transports are using 0x371 here, so FC really should
be using the same convention to have consistent error handling.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		           Kernel Storage Architect
hare@suse.de			                  +49 911 74053 688
SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), GF: Felix Imendörffer

_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 1/4] nvme: simplify error logic in nvme_validate_ns()
  2021-02-26  7:17 ` [PATCH 1/4] nvme: simplify error logic in nvme_validate_ns() Hannes Reinecke
  2021-02-26  9:10   ` Daniel Wagner
@ 2021-03-05 21:59   ` Sagi Grimberg
  1 sibling, 0 replies; 18+ messages in thread
From: Sagi Grimberg @ 2021-03-05 21:59 UTC (permalink / raw)
  To: Hannes Reinecke, Christoph Hellwig; +Cc: Keith Busch, linux-nvme, Keith Busch



On 2/25/21 11:17 PM, Hannes Reinecke wrote:
> We only should remove namespaces when we get fatal error back from
> the device or when the namespace IDs have changed.
> So instead of painfully masking out error numbers which might indicate
> that the error should be ignored we could use an NVME status code
> to indicated when the namespace should be removed.
> That simplifies the final logic and makes it less error-prone.
> 
> Signed-off-by: Hannes Reinecke <hare@suse.de>
> Reviewed-by: Keith Busch <kbusch@kernel.org>
> ---
>   drivers/nvme/host/core.c | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index d77f3f26d8d3..bde1b22ca7f2 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -1439,7 +1439,7 @@ static int nvme_identify_ns(struct nvme_ctrl *ctrl, unsigned nsid,
>   		goto out_free_id;
>   	}
>   
> -	error = -ENODEV;
> +	error = NVME_SC_INVALID_NS | NVME_SC_DNR;
>   	if ((*id)->ncap == 0) /* namespace not allocated or attached */
>   		goto out_free_id;
>   
> @@ -4036,7 +4036,7 @@ static void nvme_ns_remove_by_nsid(struct nvme_ctrl *ctrl, u32 nsid)
>   static void nvme_validate_ns(struct nvme_ns *ns, struct nvme_ns_ids *ids)
>   {
>   	struct nvme_id_ns *id;
> -	int ret = -ENODEV;
> +	int ret = NVME_SC_INVALID_NS | NVME_SC_DNR;
>   
>   	if (test_bit(NVME_NS_DEAD, &ns->flags))
>   		goto out;
> @@ -4045,7 +4045,7 @@ static void nvme_validate_ns(struct nvme_ns *ns, struct nvme_ns_ids *ids)
>   	if (ret)
>   		goto out;
>   
> -	ret = -ENODEV;
> +	ret = NVME_SC_INVALID_NS | NVME_SC_DNR;
>   	if (!nvme_ns_ids_equal(&ns->head->ids, ids)) {
>   		dev_err(ns->ctrl->device,
>   			"identifiers changed for nsid %d\n", ns->head->ns_id);
> @@ -4063,7 +4063,7 @@ static void nvme_validate_ns(struct nvme_ns *ns, struct nvme_ns_ids *ids)
>   	 *
>   	 * TODO: we should probably schedule a delayed retry here.
>   	 */
> -	if (ret && ret != -ENOMEM && !(ret > 0 && !(ret & NVME_SC_DNR)))
> +	if (ret > 0 && (ret & NVME_SC_DNR))
>   		nvme_ns_remove(ns);
>   }

This looks ok to me,

Reviewed-by: Sagi Grimberg <sagi@grimberg.me>

_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 2/4] nvme: add NVME_REQ_CANCELLED flag in nvme_cancel_request()
  2021-02-26  7:17 ` [PATCH 2/4] nvme: add NVME_REQ_CANCELLED flag in nvme_cancel_request() Hannes Reinecke
@ 2021-03-05 21:59   ` Sagi Grimberg
  0 siblings, 0 replies; 18+ messages in thread
From: Sagi Grimberg @ 2021-03-05 21:59 UTC (permalink / raw)
  To: Hannes Reinecke, Christoph Hellwig
  Cc: Keith Busch, linux-nvme, Daniel Wagner, Keith Busch, Chao Leng

Reviewed-by: Sagi Grimberg <sagi@grimberg.me>

_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 3/4] nvme-fc: set NVME_REQ_CANCELLED in nvme_fc_terminate_exchange()
  2021-02-26  7:17 ` [PATCH 3/4] nvme-fc: set NVME_REQ_CANCELLED in nvme_fc_terminate_exchange() Hannes Reinecke
@ 2021-03-05 21:59   ` Sagi Grimberg
  2021-03-06 19:16   ` James Smart
  1 sibling, 0 replies; 18+ messages in thread
From: Sagi Grimberg @ 2021-03-05 21:59 UTC (permalink / raw)
  To: Hannes Reinecke, Christoph Hellwig
  Cc: Keith Busch, linux-nvme, James Smart, Daniel Wagner, Keith Busch

Reviewed-by: Sagi Grimberg <sagi@grimberg.me>

_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 4/4] nvme-fc: return NVME_SC_HOST_ABORTED_CMD when a command has been aborted
  2021-02-26  7:17 ` [PATCH 4/4] nvme-fc: return NVME_SC_HOST_ABORTED_CMD when a command has been aborted Hannes Reinecke
  2021-03-01 19:07   ` James Smart
@ 2021-03-05 22:00   ` Sagi Grimberg
  2021-03-06 19:17   ` James Smart
  2 siblings, 0 replies; 18+ messages in thread
From: Sagi Grimberg @ 2021-03-05 22:00 UTC (permalink / raw)
  To: Hannes Reinecke, Christoph Hellwig
  Cc: Keith Busch, linux-nvme, James Smart, Daniel Wagner

Reviewed-by: Sagi Grimberg <sagi@grimberg.me>

_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 3/4] nvme-fc: set NVME_REQ_CANCELLED in nvme_fc_terminate_exchange()
  2021-02-26  7:17 ` [PATCH 3/4] nvme-fc: set NVME_REQ_CANCELLED in nvme_fc_terminate_exchange() Hannes Reinecke
  2021-03-05 21:59   ` Sagi Grimberg
@ 2021-03-06 19:16   ` James Smart
  1 sibling, 0 replies; 18+ messages in thread
From: James Smart @ 2021-03-06 19:16 UTC (permalink / raw)
  To: Hannes Reinecke, Christoph Hellwig
  Cc: Keith Busch, Sagi Grimberg, Daniel Wagner, James Smart,
	linux-nvme, Keith Busch

On 2/25/2021 11:17 PM, Hannes Reinecke wrote:
> nvme_fc_terminate_exchange() is being called when exchanges are
> being deleted, and as such we should be setting the NVME_REQ_CANCELLED
> flag to have identical behaviour on all transports.
> 
> Cc: James Smart <james.smart@broadcom.com>
> Signed-off-by: Hannes Reinecke <hare@suse.de>
> Reviewed-by: Daniel Wagner <dwagner@suse.de>
> Reviewed-by: Keith Busch <kbusch@kernel.org>
> ---

Reviewed-by: James Smart <jsmart2021@gmail.com>

Looks good.

-- james


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 4/4] nvme-fc: return NVME_SC_HOST_ABORTED_CMD when a command has been aborted
  2021-02-26  7:17 ` [PATCH 4/4] nvme-fc: return NVME_SC_HOST_ABORTED_CMD when a command has been aborted Hannes Reinecke
  2021-03-01 19:07   ` James Smart
  2021-03-05 22:00   ` Sagi Grimberg
@ 2021-03-06 19:17   ` James Smart
  2 siblings, 0 replies; 18+ messages in thread
From: James Smart @ 2021-03-06 19:17 UTC (permalink / raw)
  To: Hannes Reinecke, Christoph Hellwig
  Cc: Keith Busch, Sagi Grimberg, Daniel Wagner, James Smart, linux-nvme

On 2/25/2021 11:17 PM, Hannes Reinecke wrote:
> When a command has been aborted we should return NVME_SC_HOST_ABORTED_CMD
> to be consistent with the other transports.
> 
> Cc: James Smart <james.smart@broadcom.com>
> Signed-off-by: Hannes Reinecke <hare@suse.de>
> Reviewed-by: Daniel Wagner <dwagner@suse.de>
> ---
>   drivers/nvme/host/fc.c | 2 +-

Reviewed-by: James Smart <jsmart2021@gmail.com>

Looks good.

-- james



_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCHv4 0/4] Fixup return value for nvme_submit_sync_cmd()
  2021-02-26  7:17 [PATCHv4 0/4] Fixup return value for nvme_submit_sync_cmd() Hannes Reinecke
                   ` (4 preceding siblings ...)
  2021-02-26  9:21 ` [PATCHv4 0/4] Fixup return value for nvme_submit_sync_cmd() Chao Leng
@ 2021-03-09 10:05 ` Christoph Hellwig
  5 siblings, 0 replies; 18+ messages in thread
From: Christoph Hellwig @ 2021-03-09 10:05 UTC (permalink / raw)
  To: Hannes Reinecke; +Cc: Christoph Hellwig, Sagi Grimberg, Keith Busch, linux-nvme

Thanks,

applied to nvme-5.12.

_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2021-03-09 10:05 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-26  7:17 [PATCHv4 0/4] Fixup return value for nvme_submit_sync_cmd() Hannes Reinecke
2021-02-26  7:17 ` [PATCH 1/4] nvme: simplify error logic in nvme_validate_ns() Hannes Reinecke
2021-02-26  9:10   ` Daniel Wagner
2021-02-26  9:24     ` Hannes Reinecke
2021-02-26  9:55       ` Daniel Wagner
2021-03-05 21:59   ` Sagi Grimberg
2021-02-26  7:17 ` [PATCH 2/4] nvme: add NVME_REQ_CANCELLED flag in nvme_cancel_request() Hannes Reinecke
2021-03-05 21:59   ` Sagi Grimberg
2021-02-26  7:17 ` [PATCH 3/4] nvme-fc: set NVME_REQ_CANCELLED in nvme_fc_terminate_exchange() Hannes Reinecke
2021-03-05 21:59   ` Sagi Grimberg
2021-03-06 19:16   ` James Smart
2021-02-26  7:17 ` [PATCH 4/4] nvme-fc: return NVME_SC_HOST_ABORTED_CMD when a command has been aborted Hannes Reinecke
2021-03-01 19:07   ` James Smart
2021-03-02  7:09     ` Hannes Reinecke
2021-03-05 22:00   ` Sagi Grimberg
2021-03-06 19:17   ` James Smart
2021-02-26  9:21 ` [PATCHv4 0/4] Fixup return value for nvme_submit_sync_cmd() Chao Leng
2021-03-09 10:05 ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).