linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] virtio_blk: corrent types for status handling
@ 2021-10-25  7:58 Michael S. Tsirkin
  2021-10-25  8:22 ` Stefan Hajnoczi
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Michael S. Tsirkin @ 2021-10-25  7:58 UTC (permalink / raw)
  To: linux-kernel
  Cc: kernel test robot, Max Gurtovoy, Jason Wang, Paolo Bonzini,
	Stefan Hajnoczi, Jens Axboe, Feng Li, Israel Rukshin,
	virtualization, linux-block

virtblk_setup_cmd returns blk_status_t in an int, callers then assign it
back to a blk_status_t variable. blk_status_t is either u32 or (more
typically) u8 so it works, but is inelegant and causes sparse warnings.

Pass the status in blk_status_t in a consistent way.

Reported-by: kernel test robot <lkp@intel.com>
Fixes: b2c5221fd074 ("virtio-blk: avoid preallocating big SGL for data")
Cc: Max Gurtovoy <mgurtovoy@nvidia.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 drivers/block/virtio_blk.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
index c336d9bb9105..c7d05ff24084 100644
--- a/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c
@@ -208,8 +208,9 @@ static void virtblk_cleanup_cmd(struct request *req)
 		kfree(bvec_virt(&req->special_vec));
 }
 
-static int virtblk_setup_cmd(struct virtio_device *vdev, struct request *req,
-		struct virtblk_req *vbr)
+static blk_status_t virtblk_setup_cmd(struct virtio_device *vdev,
+				      struct request *req,
+				      struct virtblk_req *vbr)
 {
 	bool unmap = false;
 	u32 type;
@@ -317,14 +318,15 @@ static blk_status_t virtio_queue_rq(struct blk_mq_hw_ctx *hctx,
 	unsigned long flags;
 	unsigned int num;
 	int qid = hctx->queue_num;
-	int err;
 	bool notify = false;
+	blk_status_t status;
+	int err;
 
 	BUG_ON(req->nr_phys_segments + 2 > vblk->sg_elems);
 
-	err = virtblk_setup_cmd(vblk->vdev, req, vbr);
-	if (unlikely(err))
-		return err;
+	status = virtblk_setup_cmd(vblk->vdev, req, vbr);
+	if (unlikely(status))
+		return status;
 
 	blk_mq_start_request(req);
 
-- 
MST


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

* Re: [PATCH] virtio_blk: corrent types for status handling
  2021-10-25  7:58 [PATCH] virtio_blk: corrent types for status handling Michael S. Tsirkin
@ 2021-10-25  8:22 ` Stefan Hajnoczi
  2021-10-25  8:24 ` Max Gurtovoy
  2021-10-26  4:41 ` Jason Wang
  2 siblings, 0 replies; 5+ messages in thread
From: Stefan Hajnoczi @ 2021-10-25  8:22 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: linux-kernel, kernel test robot, Max Gurtovoy, Jason Wang,
	Paolo Bonzini, Jens Axboe, Feng Li, Israel Rukshin,
	virtualization, linux-block

[-- Attachment #1: Type: text/plain, Size: 743 bytes --]

On Mon, Oct 25, 2021 at 03:58:54AM -0400, Michael S. Tsirkin wrote:
> virtblk_setup_cmd returns blk_status_t in an int, callers then assign it
> back to a blk_status_t variable. blk_status_t is either u32 or (more
> typically) u8 so it works, but is inelegant and causes sparse warnings.
> 
> Pass the status in blk_status_t in a consistent way.
> 
> Reported-by: kernel test robot <lkp@intel.com>
> Fixes: b2c5221fd074 ("virtio-blk: avoid preallocating big SGL for data")
> Cc: Max Gurtovoy <mgurtovoy@nvidia.com>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
>  drivers/block/virtio_blk.c | 14 ++++++++------
>  1 file changed, 8 insertions(+), 6 deletions(-)

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH] virtio_blk: corrent types for status handling
  2021-10-25  7:58 [PATCH] virtio_blk: corrent types for status handling Michael S. Tsirkin
  2021-10-25  8:22 ` Stefan Hajnoczi
@ 2021-10-25  8:24 ` Max Gurtovoy
  2021-10-25  8:41   ` Christoph Hellwig
  2021-10-26  4:41 ` Jason Wang
  2 siblings, 1 reply; 5+ messages in thread
From: Max Gurtovoy @ 2021-10-25  8:24 UTC (permalink / raw)
  To: Michael S. Tsirkin, linux-kernel, Jens Axboe, Christoph Hellwig
  Cc: kernel test robot, Jason Wang, Paolo Bonzini, Stefan Hajnoczi,
	Feng Li, Israel Rukshin, virtualization, linux-block


On 10/25/2021 10:58 AM, Michael S. Tsirkin wrote:
> virtblk_setup_cmd returns blk_status_t in an int, callers then assign it
> back to a blk_status_t variable. blk_status_t is either u32 or (more
> typically) u8 so it works, but is inelegant and causes sparse warnings.
>
> Pass the status in blk_status_t in a consistent way.
>
> Reported-by: kernel test robot <lkp@intel.com>
> Fixes: b2c5221fd074 ("virtio-blk: avoid preallocating big SGL for data")
> Cc: Max Gurtovoy <mgurtovoy@nvidia.com>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
>   drivers/block/virtio_blk.c | 14 ++++++++------
>   1 file changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
> index c336d9bb9105..c7d05ff24084 100644
> --- a/drivers/block/virtio_blk.c
> +++ b/drivers/block/virtio_blk.c
> @@ -208,8 +208,9 @@ static void virtblk_cleanup_cmd(struct request *req)
>   		kfree(bvec_virt(&req->special_vec));
>   }
>   
> -static int virtblk_setup_cmd(struct virtio_device *vdev, struct request *req,
> -		struct virtblk_req *vbr)
> +static blk_status_t virtblk_setup_cmd(struct virtio_device *vdev,
> +				      struct request *req,
> +				      struct virtblk_req *vbr)
>   {
>   	bool unmap = false;
>   	u32 type;
> @@ -317,14 +318,15 @@ static blk_status_t virtio_queue_rq(struct blk_mq_hw_ctx *hctx,
>   	unsigned long flags;
>   	unsigned int num;
>   	int qid = hctx->queue_num;
> -	int err;
>   	bool notify = false;
> +	blk_status_t status;
> +	int err;
>   
>   	BUG_ON(req->nr_phys_segments + 2 > vblk->sg_elems);
>   
> -	err = virtblk_setup_cmd(vblk->vdev, req, vbr);
> -	if (unlikely(err))
> -		return err;
> +	status = virtblk_setup_cmd(vblk->vdev, req, vbr);
> +	if (unlikely(status))
> +		return status;
>   

Maybe we can compare the returned status to BLK_STS_OK. But I see we 
don't do it also in NVMe subsystem so I guess we can assume BLK_STS_OK 
== 0 forever.

Jens/Christoph, any thoughts on that ?


Anyway Looks good.

Thanks for the fix,

Reviewed-by: Max Gurtovoy <mgurtovoy@nvidia.com>

>   	blk_mq_start_request(req);
>   

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

* Re: [PATCH] virtio_blk: corrent types for status handling
  2021-10-25  8:24 ` Max Gurtovoy
@ 2021-10-25  8:41   ` Christoph Hellwig
  0 siblings, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2021-10-25  8:41 UTC (permalink / raw)
  To: Max Gurtovoy
  Cc: Michael S. Tsirkin, linux-kernel, Jens Axboe, Christoph Hellwig,
	kernel test robot, Jason Wang, Paolo Bonzini, Stefan Hajnoczi,
	Feng Li, Israel Rukshin, virtualization, linux-block

On Mon, Oct 25, 2021 at 11:24:57AM +0300, Max Gurtovoy wrote:
> Maybe we can compare the returned status to BLK_STS_OK. But I see we don't 
> do it also in NVMe subsystem so I guess we can assume BLK_STS_OK == 0 
> forever.

Jes,  BLK_STS_OK == 0 is an intentional allowed short cut.  It is not
just a block layer design, but part of how the sparse __bitwise__
annotations work.

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

* Re: [PATCH] virtio_blk: corrent types for status handling
  2021-10-25  7:58 [PATCH] virtio_blk: corrent types for status handling Michael S. Tsirkin
  2021-10-25  8:22 ` Stefan Hajnoczi
  2021-10-25  8:24 ` Max Gurtovoy
@ 2021-10-26  4:41 ` Jason Wang
  2 siblings, 0 replies; 5+ messages in thread
From: Jason Wang @ 2021-10-26  4:41 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: linux-kernel, kernel test robot, Max Gurtovoy, Paolo Bonzini,
	Stefan Hajnoczi, Jens Axboe, Feng Li, Israel Rukshin,
	virtualization, linux-block

On Mon, Oct 25, 2021 at 3:59 PM Michael S. Tsirkin <mst@redhat.com> wrote:
>
> virtblk_setup_cmd returns blk_status_t in an int, callers then assign it
> back to a blk_status_t variable. blk_status_t is either u32 or (more
> typically) u8 so it works, but is inelegant and causes sparse warnings.
>
> Pass the status in blk_status_t in a consistent way.
>
> Reported-by: kernel test robot <lkp@intel.com>
> Fixes: b2c5221fd074 ("virtio-blk: avoid preallocating big SGL for data")
> Cc: Max Gurtovoy <mgurtovoy@nvidia.com>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>

Acked-by: Jason Wang <jasowang@redhat.com>

> ---
>  drivers/block/virtio_blk.c | 14 ++++++++------
>  1 file changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
> index c336d9bb9105..c7d05ff24084 100644
> --- a/drivers/block/virtio_blk.c
> +++ b/drivers/block/virtio_blk.c
> @@ -208,8 +208,9 @@ static void virtblk_cleanup_cmd(struct request *req)
>                 kfree(bvec_virt(&req->special_vec));
>  }
>
> -static int virtblk_setup_cmd(struct virtio_device *vdev, struct request *req,
> -               struct virtblk_req *vbr)
> +static blk_status_t virtblk_setup_cmd(struct virtio_device *vdev,
> +                                     struct request *req,
> +                                     struct virtblk_req *vbr)
>  {
>         bool unmap = false;
>         u32 type;
> @@ -317,14 +318,15 @@ static blk_status_t virtio_queue_rq(struct blk_mq_hw_ctx *hctx,
>         unsigned long flags;
>         unsigned int num;
>         int qid = hctx->queue_num;
> -       int err;
>         bool notify = false;
> +       blk_status_t status;
> +       int err;
>
>         BUG_ON(req->nr_phys_segments + 2 > vblk->sg_elems);
>
> -       err = virtblk_setup_cmd(vblk->vdev, req, vbr);
> -       if (unlikely(err))
> -               return err;
> +       status = virtblk_setup_cmd(vblk->vdev, req, vbr);
> +       if (unlikely(status))
> +               return status;
>
>         blk_mq_start_request(req);
>
> --
> MST
>


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

end of thread, other threads:[~2021-10-26  4:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-25  7:58 [PATCH] virtio_blk: corrent types for status handling Michael S. Tsirkin
2021-10-25  8:22 ` Stefan Hajnoczi
2021-10-25  8:24 ` Max Gurtovoy
2021-10-25  8:41   ` Christoph Hellwig
2021-10-26  4:41 ` Jason Wang

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).