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>,
	Ming Lei <ming.lei@redhat.com>
Subject: Re: [PATCHv3 4/4] nvme: use return value from blk_execute_rq()
Date: Mon, 24 May 2021 10:04:28 +0200	[thread overview]
Message-ID: <20210524080428.GA24488@lst.de> (raw)
In-Reply-To: <20210521202145.3674904-5-kbusch@kernel.org>

> +/*
> + * Return values:
> + * 0:  success
> + * >0: nvme controller's cqe status response
> + * <0: kernel error in lieu of controller response
> + */

For better reading flow I'd reformat this as:

/*
 * Return value:
 *   0:	success
 * > 0:	nvme controller's cqe status response
 * < 0: kernel error in lieu of controller response
 */

> +static int nvme_passthrough_status(struct request *rq, blk_status_t status)
> +{
> +	if (nvme_req(rq)->flags & NVME_REQ_CANCELLED)
> +		return -EINTR;
> +	else if (nvme_req(rq)->status)
> +		return nvme_req(rq)->status;
> +	return blk_status_to_errno(status);
> +}

I find this a little odd disconnected from the actual execure call.
What about a helper like this instead:

static int nvme_execute_rq(struct gendisk *disk, struct request *rq,
		bool at_head)
{
	blk_status_t status;

	status = blk_execute_rq(disk, req, at_head);
	if (nvme_req(rq)->flags & NVME_REQ_CANCELLED)
		return -EINTR;
	if (nvme_req(rq)->status)
		return nvme_req(rq)->status;
	return blk_status_to_errno(status);
}

> -	nvme_execute_passthru_rq(rq);
> +	status = nvme_execute_passthru_rq(rq);
>  
> -	status = nvme_req(rq)->status;
>  	if (status == NVME_SC_SUCCESS &&
>  	    req->cmd->common.opcode == nvme_admin_identify) {
>  		switch (req->cmd->identify.cns) {
> @@ -168,7 +167,8 @@ static void nvmet_passthru_execute_cmd_work(struct work_struct *w)
>  			nvmet_passthru_override_id_ns(req);
>  			break;
>  		}
> -	}
> +	} else if (status < 0)
> +		status = NVME_SC_INTERNAL;

Don't we need a better translation here?

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>,
	Ming Lei <ming.lei@redhat.com>
Subject: Re: [PATCHv3 4/4] nvme: use return value from blk_execute_rq()
Date: Mon, 24 May 2021 10:04:28 +0200	[thread overview]
Message-ID: <20210524080428.GA24488@lst.de> (raw)
In-Reply-To: <20210521202145.3674904-5-kbusch@kernel.org>

> +/*
> + * Return values:
> + * 0:  success
> + * >0: nvme controller's cqe status response
> + * <0: kernel error in lieu of controller response
> + */

For better reading flow I'd reformat this as:

/*
 * Return value:
 *   0:	success
 * > 0:	nvme controller's cqe status response
 * < 0: kernel error in lieu of controller response
 */

> +static int nvme_passthrough_status(struct request *rq, blk_status_t status)
> +{
> +	if (nvme_req(rq)->flags & NVME_REQ_CANCELLED)
> +		return -EINTR;
> +	else if (nvme_req(rq)->status)
> +		return nvme_req(rq)->status;
> +	return blk_status_to_errno(status);
> +}

I find this a little odd disconnected from the actual execure call.
What about a helper like this instead:

static int nvme_execute_rq(struct gendisk *disk, struct request *rq,
		bool at_head)
{
	blk_status_t status;

	status = blk_execute_rq(disk, req, at_head);
	if (nvme_req(rq)->flags & NVME_REQ_CANCELLED)
		return -EINTR;
	if (nvme_req(rq)->status)
		return nvme_req(rq)->status;
	return blk_status_to_errno(status);
}

> -	nvme_execute_passthru_rq(rq);
> +	status = nvme_execute_passthru_rq(rq);
>  
> -	status = nvme_req(rq)->status;
>  	if (status == NVME_SC_SUCCESS &&
>  	    req->cmd->common.opcode == nvme_admin_identify) {
>  		switch (req->cmd->identify.cns) {
> @@ -168,7 +167,8 @@ static void nvmet_passthru_execute_cmd_work(struct work_struct *w)
>  			nvmet_passthru_override_id_ns(req);
>  			break;
>  		}
> -	}
> +	} else if (status < 0)
> +		status = NVME_SC_INTERNAL;

Don't we need a better translation here?

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

  reply	other threads:[~2021-05-24  8:04 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-21 20:21 [PATCHv3 0/4] block and nvme passthrough error handling Keith Busch
2021-05-21 20:21 ` Keith Busch
2021-05-21 20:21 ` [PATCHv3 1/4] block: support polling through blk_execute_rq Keith Busch
2021-05-21 20:21   ` Keith Busch
2021-05-24  7:38   ` Christoph Hellwig
2021-05-24  7:38     ` Christoph Hellwig
2021-05-26  8:16   ` Ming Lei
2021-05-26  8:16     ` Ming Lei
2021-05-21 20:21 ` [PATCHv3 2/4] nvme: use blk_execute_rq() for passthrough commands Keith Busch
2021-05-21 20:21   ` Keith Busch
2021-05-24  7:38   ` Christoph Hellwig
2021-05-24  7:38     ` Christoph Hellwig
2021-05-26  8:24   ` Ming Lei
2021-05-26  8:24     ` Ming Lei
2021-05-26  8:47   ` Kanchan Joshi
2021-05-26  8:47     ` Kanchan Joshi
2021-06-07 16:15     ` Keith Busch
2021-06-07 16:15       ` Keith Busch
2021-06-08  5:26       ` Christoph Hellwig
2021-06-08  5:26         ` Christoph Hellwig
2021-05-21 20:21 ` [PATCHv3 3/4] block: return errors from blk_execute_rq() Keith Busch
2021-05-21 20:21   ` Keith Busch
2021-05-24  7:39   ` Christoph Hellwig
2021-05-24  7:39     ` Christoph Hellwig
2021-05-26  8:26   ` Ming Lei
2021-05-26  8:26     ` Ming Lei
2021-05-21 20:21 ` [PATCHv3 4/4] nvme: use return value " Keith Busch
2021-05-21 20:21   ` Keith Busch
2021-05-24  8:04   ` Christoph Hellwig [this message]
2021-05-24  8:04     ` Christoph Hellwig
2021-06-07 16:58     ` Keith Busch
2021-06-07 16:58       ` Keith Busch
2021-06-08  5:26       ` Christoph Hellwig
2021-06-08  5:26         ` Christoph Hellwig

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=20210524080428.GA24488@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=ming.lei@redhat.com \
    --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.