All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Keith Busch <kbusch@kernel.org>
Cc: linux-nvme@lists.infradead.org, sagi@grimberg.me, hch@lst.de,
	axboe@kernel.dk, linux-block@vger.kernel.org,
	Yuanyuan Zhong <yzhong@purestorage.com>,
	Casey Chen <cachen@purestorage.com>
Subject: Re: [PATCHv2 4/5] nvme: use return value from blk_execute_rq()
Date: Mon, 26 Apr 2021 16:42:16 +0200	[thread overview]
Message-ID: <20210426144216.GD20668@lst.de> (raw)
In-Reply-To: <20210423220558.40764-5-kbusch@kernel.org>

On Fri, Apr 23, 2021 at 03:05:57PM -0700, Keith Busch wrote:
> We don't have an nvme status to report if the driver's .queue_rq()
> returns an error without dispatching the requested nvme command. Use the
> return value from blk_execute_rq() for all passthrough commands so the
> caller may know their command was not successful.
> 
> If the command is from the target passthrough interface and fails to
> dispatch, synthesize the response back to the host as a internal target
> error.
> 
> Signed-off-by: Keith Busch <kbusch@kernel.org>
> ---
>  drivers/nvme/host/core.c       | 16 ++++++++++++----
>  drivers/nvme/host/ioctl.c      |  6 +-----
>  drivers/nvme/host/nvme.h       |  2 +-
>  drivers/nvme/target/passthru.c |  8 ++++----
>  4 files changed, 18 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index 10bb8406e067..62af5fe7a0ce 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -972,12 +972,12 @@ int __nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd,
>  			goto out;
>  	}
>  
> -	blk_execute_rq(NULL, req, at_head);
> +	ret = blk_execute_rq(NULL, req, at_head);
>  	if (result)
>  		*result = nvme_req(req)->result;
>  	if (nvme_req(req)->flags & NVME_REQ_CANCELLED)
>  		ret = -EINTR;
> -	else
> +	else if (nvme_req(req)->status)
>  		ret = nvme_req(req)->status;

Just cosmetic, and already in the existing code, but I'd prefer if we
could keep the ret assignments together, something like:

	status = blk_execute_rq(NULL, req, at_head);
  	if (nvme_req(req)->flags & NVME_REQ_CANCELLED)
 		ret = -EINTR;
	else if (nvme_req(req)->status)
		ret = nvme_req(req)->status;
	else
		ret = blk_status_to_errno(status);

 	if (result)
 		*result = nvme_req(req)->result;

> +	ret = blk_execute_rq(disk, rq, 0);
>  	if (effects) /* nothing to be done for zero cmd effects */
>  		nvme_passthru_end(ctrl, effects);
> +
> +	if (nvme_req(rq)->flags & NVME_REQ_CANCELLED)
> +		ret = -EINTR;
> +	else if (nvme_req(rq)->status)
> +		ret = nvme_req(rq)->status;
> +

I think we want a helper for all this return value magic instead of
duplicating it.

WARNING: multiple messages have this Message-ID (diff)
From: Christoph Hellwig <hch@lst.de>
To: Keith Busch <kbusch@kernel.org>
Cc: linux-nvme@lists.infradead.org, sagi@grimberg.me, hch@lst.de,
	axboe@kernel.dk, linux-block@vger.kernel.org,
	Yuanyuan Zhong <yzhong@purestorage.com>,
	Casey Chen <cachen@purestorage.com>
Subject: Re: [PATCHv2 4/5] nvme: use return value from blk_execute_rq()
Date: Mon, 26 Apr 2021 16:42:16 +0200	[thread overview]
Message-ID: <20210426144216.GD20668@lst.de> (raw)
In-Reply-To: <20210423220558.40764-5-kbusch@kernel.org>

On Fri, Apr 23, 2021 at 03:05:57PM -0700, Keith Busch wrote:
> We don't have an nvme status to report if the driver's .queue_rq()
> returns an error without dispatching the requested nvme command. Use the
> return value from blk_execute_rq() for all passthrough commands so the
> caller may know their command was not successful.
> 
> If the command is from the target passthrough interface and fails to
> dispatch, synthesize the response back to the host as a internal target
> error.
> 
> Signed-off-by: Keith Busch <kbusch@kernel.org>
> ---
>  drivers/nvme/host/core.c       | 16 ++++++++++++----
>  drivers/nvme/host/ioctl.c      |  6 +-----
>  drivers/nvme/host/nvme.h       |  2 +-
>  drivers/nvme/target/passthru.c |  8 ++++----
>  4 files changed, 18 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index 10bb8406e067..62af5fe7a0ce 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -972,12 +972,12 @@ int __nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd,
>  			goto out;
>  	}
>  
> -	blk_execute_rq(NULL, req, at_head);
> +	ret = blk_execute_rq(NULL, req, at_head);
>  	if (result)
>  		*result = nvme_req(req)->result;
>  	if (nvme_req(req)->flags & NVME_REQ_CANCELLED)
>  		ret = -EINTR;
> -	else
> +	else if (nvme_req(req)->status)
>  		ret = nvme_req(req)->status;

Just cosmetic, and already in the existing code, but I'd prefer if we
could keep the ret assignments together, something like:

	status = blk_execute_rq(NULL, req, at_head);
  	if (nvme_req(req)->flags & NVME_REQ_CANCELLED)
 		ret = -EINTR;
	else if (nvme_req(req)->status)
		ret = nvme_req(req)->status;
	else
		ret = blk_status_to_errno(status);

 	if (result)
 		*result = nvme_req(req)->result;

> +	ret = blk_execute_rq(disk, rq, 0);
>  	if (effects) /* nothing to be done for zero cmd effects */
>  		nvme_passthru_end(ctrl, effects);
> +
> +	if (nvme_req(rq)->flags & NVME_REQ_CANCELLED)
> +		ret = -EINTR;
> +	else if (nvme_req(rq)->status)
> +		ret = nvme_req(rq)->status;
> +

I think we want a helper for all this return value magic instead of
duplicating it.

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

  reply	other threads:[~2021-04-26 14:42 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-23 22:05 [PATCHv2 0/5] block and nvme passthrough error handling Keith Busch
2021-04-23 22:05 ` Keith Busch
2021-04-23 22:05 ` [PATCHv2 1/5] block: support polling through blk_execute_rq Keith Busch
2021-04-23 22:05   ` Keith Busch
2021-04-26  6:34   ` Ming Lei
2021-04-26  6:34     ` Ming Lei
2021-04-26 14:35   ` Christoph Hellwig
2021-04-26 14:35     ` Christoph Hellwig
2021-05-17 16:43   ` Kanchan Joshi
2021-05-17 16:43     ` Kanchan Joshi
2021-04-23 22:05 ` [PATCHv2 2/5] nvme: use blk_execute_rq() for passthrough commands Keith Busch
2021-04-23 22:05   ` Keith Busch
2021-04-26 14:35   ` Christoph Hellwig
2021-04-26 14:35     ` Christoph Hellwig
2021-04-23 22:05 ` [PATCHv2 3/5] block: return errors from blk_execute_rq() Keith Busch
2021-04-23 22:05   ` Keith Busch
2021-04-26  6:42   ` Ming Lei
2021-04-26  6:42     ` Ming Lei
2021-04-26 14:36   ` Christoph Hellwig
2021-04-26 14:36     ` Christoph Hellwig
2021-04-23 22:05 ` [PATCHv2 4/5] nvme: use return value " Keith Busch
2021-04-23 22:05   ` Keith Busch
2021-04-26 14:42   ` Christoph Hellwig [this message]
2021-04-26 14:42     ` Christoph Hellwig
2021-04-26 17:10   ` Yuanyuan Zhong
2021-04-26 17:10     ` Yuanyuan Zhong
2021-04-26 17:15     ` Keith Busch
2021-04-26 17:15       ` Keith Busch
2021-04-26 17:39       ` Yuanyuan Zhong
2021-04-26 17:39         ` Yuanyuan Zhong
2021-04-23 22:05 ` [PATCHv2 5/5] nvme: allow user passthrough commands to poll Keith Busch
2021-04-23 22:05   ` Keith Busch
2021-04-26 14:43   ` Christoph Hellwig
2021-04-26 14:43     ` Christoph Hellwig
2021-04-26 15:15     ` Keith Busch
2021-04-26 15:15       ` Keith Busch
2021-05-17 16:55       ` Kanchan Joshi
2021-05-17 16:55         ` Kanchan Joshi
2021-05-17 17:14         ` Keith Busch
2021-05-17 17:14           ` Keith Busch

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210426144216.GD20668@lst.de \
    --to=hch@lst.de \
    --cc=axboe@kernel.dk \
    --cc=cachen@purestorage.com \
    --cc=kbusch@kernel.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=sagi@grimberg.me \
    --cc=yzhong@purestorage.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.