public inbox for linux-nvme@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] nvme: fix error-handling for io_uring nvme-passthrough
       [not found] <CGME20231018140334epcas5p128c55c56fb9203a19479cbf86175a1d6@epcas5p1.samsung.com>
@ 2023-10-18 13:57 ` Kanchan Joshi
  2023-10-18 15:50   ` Christoph Hellwig
  2023-10-18 18:05   ` Niklas Cassel
  0 siblings, 2 replies; 5+ messages in thread
From: Kanchan Joshi @ 2023-10-18 13:57 UTC (permalink / raw)
  To: hch, kbusch, axboe, sagi; +Cc: linux-nvme, joshiiitr, Anuj Gupta, Kanchan Joshi

From: Anuj Gupta <anuj20.g@samsung.com>

Driver may return an error before submitting the command to the device.
Ensure that such error is propagated up.

Fixes: 456cba386e94 ("nvme: wire-up uring-cmd support for io-passthru on char-device.")

Signed-off-by: Anuj Gupta <anuj20.g@samsung.com>
Signed-off-by: Kanchan Joshi <joshi.k@samsung.com>
---
 drivers/nvme/host/ioctl.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/nvme/host/ioctl.c b/drivers/nvme/host/ioctl.c
index d8ff796fd5f2..53987df6ea7c 100644
--- a/drivers/nvme/host/ioctl.c
+++ b/drivers/nvme/host/ioctl.c
@@ -508,8 +508,11 @@ static enum rq_end_io_ret nvme_uring_cmd_end_io(struct request *req,
 	req->bio = pdu->bio;
 	if (nvme_req(req)->flags & NVME_REQ_CANCELLED)
 		pdu->nvme_status = -EINTR;
-	else
+	else {
 		pdu->nvme_status = nvme_req(req)->status;
+		if (!pdu->nvme_status)
+			pdu->nvme_status = blk_status_to_errno(err);
+	}
 	pdu->u.result = le64_to_cpu(nvme_req(req)->result.u64);
 
 	/*
-- 
2.25.1



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

* Re: [PATCH] nvme: fix error-handling for io_uring nvme-passthrough
  2023-10-18 13:57 ` [PATCH] nvme: fix error-handling for io_uring nvme-passthrough Kanchan Joshi
@ 2023-10-18 15:50   ` Christoph Hellwig
  2023-10-18 16:50     ` Kanchan Joshi
  2023-10-18 18:05   ` Niklas Cassel
  1 sibling, 1 reply; 5+ messages in thread
From: Christoph Hellwig @ 2023-10-18 15:50 UTC (permalink / raw)
  To: Kanchan Joshi; +Cc: hch, kbusch, axboe, sagi, linux-nvme, joshiiitr, Anuj Gupta

On Wed, Oct 18, 2023 at 07:27:18PM +0530, Kanchan Joshi wrote:
> @@ -508,8 +508,11 @@ static enum rq_end_io_ret nvme_uring_cmd_end_io(struct request *req,
>  	req->bio = pdu->bio;
>  	if (nvme_req(req)->flags & NVME_REQ_CANCELLED)
>  		pdu->nvme_status = -EINTR;
> -	else
> +	else {
>  		pdu->nvme_status = nvme_req(req)->status;
> +		if (!pdu->nvme_status)
> +			pdu->nvme_status = blk_status_to_errno(err);
> +	}

Hmm, shoudn't err take precedence over the nvme status?



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

* Re: [PATCH] nvme: fix error-handling for io_uring nvme-passthrough
  2023-10-18 15:50   ` Christoph Hellwig
@ 2023-10-18 16:50     ` Kanchan Joshi
  2023-10-18 16:59       ` Keith Busch
  0 siblings, 1 reply; 5+ messages in thread
From: Kanchan Joshi @ 2023-10-18 16:50 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Kanchan Joshi, kbusch, axboe, sagi, linux-nvme, Anuj Gupta

On Wed, Oct 18, 2023 at 9:20 PM Christoph Hellwig <hch@lst.de> wrote:
>
> On Wed, Oct 18, 2023 at 07:27:18PM +0530, Kanchan Joshi wrote:
> > @@ -508,8 +508,11 @@ static enum rq_end_io_ret nvme_uring_cmd_end_io(struct request *req,
> >       req->bio = pdu->bio;
> >       if (nvme_req(req)->flags & NVME_REQ_CANCELLED)
> >               pdu->nvme_status = -EINTR;
> > -     else
> > +     else {
> >               pdu->nvme_status = nvme_req(req)->status;
> > +             if (!pdu->nvme_status)
> > +                     pdu->nvme_status = blk_status_to_errno(err);
> > +     }
>
> Hmm, shoudn't err take precedence over the nvme status?

Since this is for passthrough interface, nvme status should get the
precedence since that is what we want the users to see.
Same happens for sync passthrough too (in nvme_execute_rq).


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

* Re: [PATCH] nvme: fix error-handling for io_uring nvme-passthrough
  2023-10-18 16:50     ` Kanchan Joshi
@ 2023-10-18 16:59       ` Keith Busch
  0 siblings, 0 replies; 5+ messages in thread
From: Keith Busch @ 2023-10-18 16:59 UTC (permalink / raw)
  To: Kanchan Joshi
  Cc: Christoph Hellwig, Kanchan Joshi, axboe, sagi, linux-nvme,
	Anuj Gupta

On Wed, Oct 18, 2023 at 10:20:10PM +0530, Kanchan Joshi wrote:
> On Wed, Oct 18, 2023 at 9:20 PM Christoph Hellwig <hch@lst.de> wrote:
> >
> > On Wed, Oct 18, 2023 at 07:27:18PM +0530, Kanchan Joshi wrote:
> > > @@ -508,8 +508,11 @@ static enum rq_end_io_ret nvme_uring_cmd_end_io(struct request *req,
> > >       req->bio = pdu->bio;
> > >       if (nvme_req(req)->flags & NVME_REQ_CANCELLED)
> > >               pdu->nvme_status = -EINTR;
> > > -     else
> > > +     else {
> > >               pdu->nvme_status = nvme_req(req)->status;
> > > +             if (!pdu->nvme_status)
> > > +                     pdu->nvme_status = blk_status_to_errno(err);
> > > +     }
> >
> > Hmm, shoudn't err take precedence over the nvme status?
> 
> Since this is for passthrough interface, nvme status should get the
> precedence since that is what we want the users to see.
> Same happens for sync passthrough too (in nvme_execute_rq).

Right, blk_sts_t 'err' will be non-zero on any nvme error status, but we
want to report nvme error status if we have one.


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

* Re: [PATCH] nvme: fix error-handling for io_uring nvme-passthrough
  2023-10-18 13:57 ` [PATCH] nvme: fix error-handling for io_uring nvme-passthrough Kanchan Joshi
  2023-10-18 15:50   ` Christoph Hellwig
@ 2023-10-18 18:05   ` Niklas Cassel
  1 sibling, 0 replies; 5+ messages in thread
From: Niklas Cassel @ 2023-10-18 18:05 UTC (permalink / raw)
  To: Kanchan Joshi
  Cc: hch@lst.de, kbusch@kernel.org, axboe@kernel.dk, sagi@grimberg.me,
	linux-nvme@lists.infradead.org, joshiiitr@gmail.com, Anuj Gupta

Hello Kanchan,

On Wed, Oct 18, 2023 at 07:27:18PM +0530, Kanchan Joshi wrote:
> From: Anuj Gupta <anuj20.g@samsung.com>
> 
> Driver may return an error before submitting the command to the device.
> Ensure that such error is propagated up.
> 
> Fixes: 456cba386e94 ("nvme: wire-up uring-cmd support for io-passthru on char-device.")
>

Why do you have an empty line between the Fixes and the Signed-off-by ?
(I noticed this on some of your other patches as well.)

I don't think there is supposed to be any empty lines between the tags.

> Signed-off-by: Anuj Gupta <anuj20.g@samsung.com>
> Signed-off-by: Kanchan Joshi <joshi.k@samsung.com>
> ---
>  drivers/nvme/host/ioctl.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/nvme/host/ioctl.c b/drivers/nvme/host/ioctl.c
> index d8ff796fd5f2..53987df6ea7c 100644
> --- a/drivers/nvme/host/ioctl.c
> +++ b/drivers/nvme/host/ioctl.c
> @@ -508,8 +508,11 @@ static enum rq_end_io_ret nvme_uring_cmd_end_io(struct request *req,
>  	req->bio = pdu->bio;
>  	if (nvme_req(req)->flags & NVME_REQ_CANCELLED)
>  		pdu->nvme_status = -EINTR;
> -	else
> +	else {
>  		pdu->nvme_status = nvme_req(req)->status;
> +		if (!pdu->nvme_status)
> +			pdu->nvme_status = blk_status_to_errno(err);
> +	}

The kernel coding standard says that you should have braces on the if,
even if it is a single line statement, when you have brances on the else:
https://www.kernel.org/doc/html/latest/process/coding-style.html#placing-braces-and-spaces


Kind regards,
Niklas

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

end of thread, other threads:[~2023-10-18 18:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <CGME20231018140334epcas5p128c55c56fb9203a19479cbf86175a1d6@epcas5p1.samsung.com>
2023-10-18 13:57 ` [PATCH] nvme: fix error-handling for io_uring nvme-passthrough Kanchan Joshi
2023-10-18 15:50   ` Christoph Hellwig
2023-10-18 16:50     ` Kanchan Joshi
2023-10-18 16:59       ` Keith Busch
2023-10-18 18:05   ` Niklas Cassel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox