2022-12-20 11:52:37

by Michael S. Tsirkin

[permalink] [raw]
Subject: [PATCH] virtio-blk: fix probe without CONFIG_BLK_DEV_ZONED

When building without CONFIG_BLK_DEV_ZONED, VIRTIO_BLK_F_ZONED
is excluded from array of driver features.
As a result virtio_has_feature panics in virtio_check_driver_offered_feature
since that by design verifies that a feature we are checking for
is listed in the feature array.

To fix, replace the call to virtio_has_feature with a stub.

Tested-by: Anders Roxell <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
---
drivers/block/virtio_blk.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
index 88b3639f8536..5ea1dc882a80 100644
--- a/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c
@@ -760,6 +760,10 @@ static int virtblk_probe_zoned_device(struct virtio_device *vdev,
return ret;
}

+static inline bool virtblk_has_zoned_feature(struct virtio_device *vdev)
+{
+ return virtio_has_feature(vdev, VIRTIO_BLK_F_ZONED);
+}
#else

/*
@@ -775,6 +779,11 @@ static inline int virtblk_probe_zoned_device(struct virtio_device *vdev,
{
return -EOPNOTSUPP;
}
+
+static inline bool virtblk_has_zoned_feature(struct virtio_device *vdev)
+{
+ return false;
+}
#endif /* CONFIG_BLK_DEV_ZONED */

/* return id (s/n) string for *disk to *id_str
@@ -1480,7 +1489,7 @@ static int virtblk_probe(struct virtio_device *vdev)
virtblk_update_capacity(vblk, false);
virtio_device_ready(vdev);

- if (virtio_has_feature(vdev, VIRTIO_BLK_F_ZONED)) {
+ if (virtblk_has_zoned_feature(vdev)) {
err = virtblk_probe_zoned_device(vdev, vblk, q);
if (err)
goto out_cleanup_disk;
--
MST


2022-12-20 20:12:58

by Stefan Hajnoczi

[permalink] [raw]
Subject: Re: [PATCH] virtio-blk: fix probe without CONFIG_BLK_DEV_ZONED

On Tue, Dec 20, 2022 at 06:23:44AM -0500, Michael S. Tsirkin wrote:
> When building without CONFIG_BLK_DEV_ZONED, VIRTIO_BLK_F_ZONED
> is excluded from array of driver features.
> As a result virtio_has_feature panics in virtio_check_driver_offered_feature
> since that by design verifies that a feature we are checking for
> is listed in the feature array.
>
> To fix, replace the call to virtio_has_feature with a stub.
>
> Tested-by: Anders Roxell <[email protected]>
> Signed-off-by: Michael S. Tsirkin <[email protected]>
> ---
> drivers/block/virtio_blk.c | 11 ++++++++++-
> 1 file changed, 10 insertions(+), 1 deletion(-)

Reviewed-by: Stefan Hajnoczi <[email protected]>


Attachments:
(No filename) (705.00 B)
signature.asc (499.00 B)
Download all attachments

2022-12-20 23:04:58

by Chaitanya Kulkarni

[permalink] [raw]
Subject: Re: [PATCH] virtio-blk: fix probe without CONFIG_BLK_DEV_ZONED

On 12/20/22 03:23, Michael S. Tsirkin wrote:
> When building without CONFIG_BLK_DEV_ZONED, VIRTIO_BLK_F_ZONED
> is excluded from array of driver features.
> As a result virtio_has_feature panics in virtio_check_driver_offered_feature
> since that by design verifies that a feature we are checking for
> is listed in the feature array.
>
> To fix, replace the call to virtio_has_feature with a stub.
>
> Tested-by: Anders Roxell <[email protected]>
> Signed-off-by: Michael S. Tsirkin <[email protected]>
> ---

Reviewed-by: Chaitanya Kulkarni <[email protected]>

-ck


2022-12-21 03:46:38

by Jason Wang

[permalink] [raw]
Subject: Re: [PATCH] virtio-blk: fix probe without CONFIG_BLK_DEV_ZONED

On Tue, Dec 20, 2022 at 7:23 PM Michael S. Tsirkin <[email protected]> wrote:
>
> When building without CONFIG_BLK_DEV_ZONED, VIRTIO_BLK_F_ZONED
> is excluded from array of driver features.
> As a result virtio_has_feature panics in virtio_check_driver_offered_feature
> since that by design verifies that a feature we are checking for
> is listed in the feature array.
>
> To fix, replace the call to virtio_has_feature with a stub.
>
> Tested-by: Anders Roxell <[email protected]>
> Signed-off-by: Michael S. Tsirkin <[email protected]>

Acked-by: Jason Wang <[email protected]>

Thanks

> ---
> drivers/block/virtio_blk.c | 11 ++++++++++-
> 1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
> index 88b3639f8536..5ea1dc882a80 100644
> --- a/drivers/block/virtio_blk.c
> +++ b/drivers/block/virtio_blk.c
> @@ -760,6 +760,10 @@ static int virtblk_probe_zoned_device(struct virtio_device *vdev,
> return ret;
> }
>
> +static inline bool virtblk_has_zoned_feature(struct virtio_device *vdev)
> +{
> + return virtio_has_feature(vdev, VIRTIO_BLK_F_ZONED);
> +}
> #else
>
> /*
> @@ -775,6 +779,11 @@ static inline int virtblk_probe_zoned_device(struct virtio_device *vdev,
> {
> return -EOPNOTSUPP;
> }
> +
> +static inline bool virtblk_has_zoned_feature(struct virtio_device *vdev)
> +{
> + return false;
> +}
> #endif /* CONFIG_BLK_DEV_ZONED */
>
> /* return id (s/n) string for *disk to *id_str
> @@ -1480,7 +1489,7 @@ static int virtblk_probe(struct virtio_device *vdev)
> virtblk_update_capacity(vblk, false);
> virtio_device_ready(vdev);
>
> - if (virtio_has_feature(vdev, VIRTIO_BLK_F_ZONED)) {
> + if (virtblk_has_zoned_feature(vdev)) {
> err = virtblk_probe_zoned_device(vdev, vblk, q);
> if (err)
> goto out_cleanup_disk;
> --
> MST
>

2022-12-21 20:09:35

by Lorenzo Stoakes

[permalink] [raw]
Subject: Re: [PATCH] virtio-blk: fix probe without CONFIG_BLK_DEV_ZONED

On Tue, Dec 20, 2022 at 06:23:44AM -0500, Michael S. Tsirkin wrote:
> When building without CONFIG_BLK_DEV_ZONED, VIRTIO_BLK_F_ZONED
> is excluded from array of driver features.
> As a result virtio_has_feature panics in virtio_check_driver_offered_feature
> since that by design verifies that a feature we are checking for
> is listed in the feature array.
>
> To fix, replace the call to virtio_has_feature with a stub.
>
> Tested-by: Anders Roxell <[email protected]>
> Signed-off-by: Michael S. Tsirkin <[email protected]>
> ---
> drivers/block/virtio_blk.c | 11 ++++++++++-
> 1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
> index 88b3639f8536..5ea1dc882a80 100644
> --- a/drivers/block/virtio_blk.c
> +++ b/drivers/block/virtio_blk.c
> @@ -760,6 +760,10 @@ static int virtblk_probe_zoned_device(struct virtio_device *vdev,
> return ret;
> }
>
> +static inline bool virtblk_has_zoned_feature(struct virtio_device *vdev)
> +{
> + return virtio_has_feature(vdev, VIRTIO_BLK_F_ZONED);
> +}
> #else
>
> /*
> @@ -775,6 +779,11 @@ static inline int virtblk_probe_zoned_device(struct virtio_device *vdev,
> {
> return -EOPNOTSUPP;
> }
> +
> +static inline bool virtblk_has_zoned_feature(struct virtio_device *vdev)
> +{
> + return false;
> +}
> #endif /* CONFIG_BLK_DEV_ZONED */
>
> /* return id (s/n) string for *disk to *id_str
> @@ -1480,7 +1489,7 @@ static int virtblk_probe(struct virtio_device *vdev)
> virtblk_update_capacity(vblk, false);
> virtio_device_ready(vdev);
>
> - if (virtio_has_feature(vdev, VIRTIO_BLK_F_ZONED)) {
> + if (virtblk_has_zoned_feature(vdev)) {
> err = virtblk_probe_zoned_device(vdev, vblk, q);
> if (err)
> goto out_cleanup_disk;
> --
> MST
>
> _______________________________________________
> Virtualization mailing list
> [email protected]
> https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Tested-by: Lorenzo Stoakes <[email protected]>