* Re: [PATCH V2 2/2] nvme: retry commands based on ACRE result
2021-01-13 14:35 ` [PATCH V2 2/2] nvme: retry commands based on ACRE result Minwoo Im
@ 2021-01-13 22:20 ` Sagi Grimberg
2021-01-13 22:43 ` Minwoo Im
2021-01-14 2:47 ` Chao Leng
2021-01-14 3:11 ` Keith Busch
2 siblings, 1 reply; 9+ messages in thread
From: Sagi Grimberg @ 2021-01-13 22:20 UTC (permalink / raw)
To: Minwoo Im, linux-nvme
Cc: Keith Busch, Jens Axboe, Christoph Hellwig, Chao Leng
> Introduce acre flag for Advanced Command Retry Enable to controller
> instance to decide whether to retry or not in error cases. This flag is
> set if Set Features for Host Behavior Support with ACRE bit set is
> successfully done during reset_work.
>
> This patch also fixes nvme_decide_disposition() because all the nvme
> requests are initialized with REQ_FAILFAST_DRIVER to req->cmd_flags
You mean for passthru commands, nvme doesn't control this for other
commands.
> so
> that blk_noretry_request(req) is always true. Check ctrl->acre first
> and if it's not host path error, then it will be retried.
I suggest to split out this part to its own patch.
>
> Cc: Chao Leng <lengchao@huawei.com>
> Signed-off-by: Minwoo Im <minwoo.im.dev@gmail.com>
> ---
> drivers/nvme/host/core.c | 16 ++++++++++++++--
> drivers/nvme/host/nvme.h | 1 +
> 2 files changed, 15 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index a8cee380b3c0..391bb2d08d0f 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -303,8 +303,7 @@ static inline enum nvme_disposition nvme_decide_disposition(struct request *req)
> if (likely(nvme_req(req)->status == 0))
> return COMPLETE;
>
> - if (blk_noretry_request(req) ||
> - (nvme_req(req)->status & NVME_SC_DNR) ||
> + if ((nvme_req(req)->status & NVME_SC_DNR) ||
> nvme_req(req)->retries >= nvme_max_retries)
> return COMPLETE;
>
> @@ -317,6 +316,13 @@ static inline enum nvme_disposition nvme_decide_disposition(struct request *req)
> return COMPLETE;
> }
>
> + if (nvme_req(req)->ctrl->acre) {
> + if (!nvme_is_path_error(nvme_req(req)->status) &&
> + !blk_queue_dying(req->q))
> + return RETRY;
> + } else if (blk_noretry_request(req))
> + return COMPLETE;
> +
> return RETRY;
> }
>
> @@ -2498,6 +2504,8 @@ static int nvme_configure_acre(struct nvme_ctrl *ctrl)
> struct nvme_feat_host_behavior *host;
> int ret;
>
> + ctrl->acre = false;
> +
> /* Don't bother enabling the feature if retry delay is not reported */
> if (!ctrl->crdt[0] && !ctrl->crdt[1] && !ctrl->crdt[2])
> return 0;
> @@ -2509,6 +2517,10 @@ static int nvme_configure_acre(struct nvme_ctrl *ctrl)
> host->acre = NVME_ENABLE_ACRE;
> ret = nvme_set_features(ctrl, NVME_FEAT_HOST_BEHAVIOR, 0,
> host, sizeof(*host), NULL);
> +
> + if (!ret)
> + ctrl->acre = true;
> +
> kfree(host);
> return ret;
> }
> diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
> index 88a6b97247f5..db8b45e8ffde 100644
> --- a/drivers/nvme/host/nvme.h
> +++ b/drivers/nvme/host/nvme.h
> @@ -270,6 +270,7 @@ struct nvme_ctrl {
> #ifdef CONFIG_BLK_DEV_ZONED
> u32 max_zone_append;
> #endif
> + bool acre;
> u16 crdt[3];
> u16 oncs;
> u16 oacs;
>
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH V2 2/2] nvme: retry commands based on ACRE result
2021-01-13 22:20 ` Sagi Grimberg
@ 2021-01-13 22:43 ` Minwoo Im
0 siblings, 0 replies; 9+ messages in thread
From: Minwoo Im @ 2021-01-13 22:43 UTC (permalink / raw)
To: Sagi Grimberg
Cc: Keith Busch, Jens Axboe, Christoph Hellwig, linux-nvme, Chao Leng
Hello,
Thanks for your time!
On 21-01-13 14:20:34, Sagi Grimberg wrote:
> > Introduce acre flag for Advanced Command Retry Enable to controller
> > instance to decide whether to retry or not in error cases. This flag is
> > set if Set Features for Host Behavior Support with ACRE bit set is
> > successfully done during reset_work.
> >
> > This patch also fixes nvme_decide_disposition() because all the nvme
> > requests are initialized with REQ_FAILFAST_DRIVER to req->cmd_flags
>
> You mean for passthru commands, nvme doesn't control this for other
> commands.
>
Oh, I forgot to mention... Thanks for catching this.
> > so
> > that blk_noretry_request(req) is always true. Check ctrl->acre first
> > and if it's not host path error, then it will be retried.
>
> I suggest to split out this part to its own patch.
>
Okay. I will split it up to two patches:
- Introducing ACRE flag to controller
- Check ACRE flag in nvme_decide_disposition()
Thanks!
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH V2 2/2] nvme: retry commands based on ACRE result
2021-01-13 14:35 ` [PATCH V2 2/2] nvme: retry commands based on ACRE result Minwoo Im
2021-01-13 22:20 ` Sagi Grimberg
@ 2021-01-14 2:47 ` Chao Leng
2021-01-14 3:27 ` Minwoo Im
2021-01-14 3:11 ` Keith Busch
2 siblings, 1 reply; 9+ messages in thread
From: Chao Leng @ 2021-01-14 2:47 UTC (permalink / raw)
To: Minwoo Im, linux-nvme
Cc: Keith Busch, Jens Axboe, Christoph Hellwig, Sagi Grimberg
On 2021/1/13 22:35, Minwoo Im wrote:
> Introduce acre flag for Advanced Command Retry Enable to controller
> instance to decide whether to retry or not in error cases. This flag is
> set if Set Features for Host Behavior Support with ACRE bit set is
> successfully done during reset_work.
>
> This patch also fixes nvme_decide_disposition() because all the nvme
> requests are initialized with REQ_FAILFAST_DRIVER to req->cmd_flags so
> that blk_noretry_request(req) is always true. Check ctrl->acre first
> and if it's not host path error, then it will be retried.
>
> Cc: Chao Leng <lengchao@huawei.com>
> Signed-off-by: Minwoo Im <minwoo.im.dev@gmail.com>
> ---
> drivers/nvme/host/core.c | 16 ++++++++++++++--
> drivers/nvme/host/nvme.h | 1 +
> 2 files changed, 15 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index a8cee380b3c0..391bb2d08d0f 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -303,8 +303,7 @@ static inline enum nvme_disposition nvme_decide_disposition(struct request *req)
> if (likely(nvme_req(req)->status == 0))
> return COMPLETE;
>
> - if (blk_noretry_request(req) ||
> - (nvme_req(req)->status & NVME_SC_DNR) ||
> + if ((nvme_req(req)->status & NVME_SC_DNR) ||
> nvme_req(req)->retries >= nvme_max_retries)
> return COMPLETE;
>
> @@ -317,6 +316,13 @@ static inline enum nvme_disposition nvme_decide_disposition(struct request *req)
> return COMPLETE;
> }
>
> + if (nvme_req(req)->ctrl->acre) {
> + if (!nvme_is_path_error(nvme_req(req)->status) &&
> + !blk_queue_dying(req->q))
> + return RETRY;
> + } else if (blk_noretry_request(req))
> + return COMPLETE;
If acre is true and nvme_req(req)->status is nvme path error and
blk_noretry_request(req) is true, we need return complete for REQ_FAILFAST_XX.
Otherwise, connection process may takes long time in abnormal scenarios.
We can do like this:
+ if (nvme_req(req)->ctrl->acre &&
+ !nvme_is_path_error(nvme_req(req)->status) &&
+ !blk_queue_dying(req->q))
+ return RETRY;
+
+ if (blk_noretry_request(req))
+ return COMPLETE;
> +
> return RETRY;
> }
>
> @@ -2498,6 +2504,8 @@ static int nvme_configure_acre(struct nvme_ctrl *ctrl)
> struct nvme_feat_host_behavior *host;
> int ret;
>
> + ctrl->acre = false;
> +
> /* Don't bother enabling the feature if retry delay is not reported */
> if (!ctrl->crdt[0] && !ctrl->crdt[1] && !ctrl->crdt[2])
> return 0;
> @@ -2509,6 +2517,10 @@ static int nvme_configure_acre(struct nvme_ctrl *ctrl)
> host->acre = NVME_ENABLE_ACRE;
> ret = nvme_set_features(ctrl, NVME_FEAT_HOST_BEHAVIOR, 0,
> host, sizeof(*host), NULL);
> +
> + if (!ret)
> + ctrl->acre = true;
> +
> kfree(host);
> return ret;
> }
> diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
> index 88a6b97247f5..db8b45e8ffde 100644
> --- a/drivers/nvme/host/nvme.h
> +++ b/drivers/nvme/host/nvme.h
> @@ -270,6 +270,7 @@ struct nvme_ctrl {
> #ifdef CONFIG_BLK_DEV_ZONED
> u32 max_zone_append;
> #endif
> + bool acre;
> u16 crdt[3];
> u16 oncs;
> u16 oacs;
>
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH V2 2/2] nvme: retry commands based on ACRE result
2021-01-14 2:47 ` Chao Leng
@ 2021-01-14 3:27 ` Minwoo Im
0 siblings, 0 replies; 9+ messages in thread
From: Minwoo Im @ 2021-01-14 3:27 UTC (permalink / raw)
To: Chao Leng
Cc: Keith Busch, Jens Axboe, Christoph Hellwig, linux-nvme,
Sagi Grimberg
Hello,
> If acre is true and nvme_req(req)->status is nvme path error and
> blk_noretry_request(req) is true, we need return complete for REQ_FAILFAST_XX.
> Otherwise, connection process may takes long time in abnormal scenarios.
> We can do like this:
>
> + if (nvme_req(req)->ctrl->acre &&
> + !nvme_is_path_error(nvme_req(req)->status) &&
> + !blk_queue_dying(req->q))
> + return RETRY;
> +
> + if (blk_noretry_request(req))
> + return COMPLETE;
Ah.. You're right.. I really appreciate for your review!
I will prepare the next patches.
Thank you!
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH V2 2/2] nvme: retry commands based on ACRE result
2021-01-13 14:35 ` [PATCH V2 2/2] nvme: retry commands based on ACRE result Minwoo Im
2021-01-13 22:20 ` Sagi Grimberg
2021-01-14 2:47 ` Chao Leng
@ 2021-01-14 3:11 ` Keith Busch
2021-01-14 3:28 ` Minwoo Im
2 siblings, 1 reply; 9+ messages in thread
From: Keith Busch @ 2021-01-14 3:11 UTC (permalink / raw)
To: Minwoo Im
Cc: Jens Axboe, Chao Leng, Christoph Hellwig, linux-nvme,
Sagi Grimberg
On Wed, Jan 13, 2021 at 11:35:38PM +0900, Minwoo Im wrote:
> @@ -317,6 +316,13 @@ static inline enum nvme_disposition nvme_decide_disposition(struct request *req)
> return COMPLETE;
> }
>
> + if (nvme_req(req)->ctrl->acre) {
> + if (!nvme_is_path_error(nvme_req(req)->status) &&
> + !blk_queue_dying(req->q))
> + return RETRY;
> + } else if (blk_noretry_request(req))
> + return COMPLETE;
> +
> return RETRY;
> }
This is returning RETRY for path related errors when blk_notry_request()
is true. That will deadlock initialization on a command timeout. The
check should be something like this:
if (nvme_req(req)->ctrl->acre &&
!nvme_is_path_error(nvme_req(req)->status) &&
!blk_queue_dying(req->q))
return RETRY;
else if (blk_noretry_request(req))
return COMPLETE;
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH V2 2/2] nvme: retry commands based on ACRE result
2021-01-14 3:11 ` Keith Busch
@ 2021-01-14 3:28 ` Minwoo Im
0 siblings, 0 replies; 9+ messages in thread
From: Minwoo Im @ 2021-01-14 3:28 UTC (permalink / raw)
To: Keith Busch
Cc: Jens Axboe, Chao Leng, Christoph Hellwig, linux-nvme,
Sagi Grimberg
Hello Keith,
On 21-01-13 19:11:02, Keith Busch wrote:
> On Wed, Jan 13, 2021 at 11:35:38PM +0900, Minwoo Im wrote:
> > @@ -317,6 +316,13 @@ static inline enum nvme_disposition nvme_decide_disposition(struct request *req)
> > return COMPLETE;
> > }
> >
> > + if (nvme_req(req)->ctrl->acre) {
> > + if (!nvme_is_path_error(nvme_req(req)->status) &&
> > + !blk_queue_dying(req->q))
> > + return RETRY;
> > + } else if (blk_noretry_request(req))
> > + return COMPLETE;
> > +
> > return RETRY;
> > }
>
> This is returning RETRY for path related errors when blk_notry_request()
> is true. That will deadlock initialization on a command timeout. The
> check should be something like this:
>
> if (nvme_req(req)->ctrl->acre &&
> !nvme_is_path_error(nvme_req(req)->status) &&
> !blk_queue_dying(req->q))
> return RETRY;
> else if (blk_noretry_request(req))
> return COMPLETE;
>
>
Thank you for chatching this! As Chao pointed it out, I will prepare
the next version of this patch. I really appreciate it.
Thanks!
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply [flat|nested] 9+ messages in thread