* Re: [PATCH v3] block/gluster: correctly set max_pdiscard
2022-05-20 7:59 [PATCH v3] block/gluster: correctly set max_pdiscard Fabian Ebner
@ 2022-05-24 21:14 ` Eric Blake
2022-05-25 9:12 ` Stefano Garzarella
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Eric Blake @ 2022-05-24 21:14 UTC (permalink / raw)
To: Fabian Ebner
Cc: qemu-devel, kwolf, hreitz, qemu-block, integration, qemu-stable,
vsementsov, sgarzare
On Fri, May 20, 2022 at 09:59:22AM +0200, Fabian Ebner wrote:
> On 64-bit platforms, assigning SIZE_MAX to the int64_t max_pdiscard
> results in a negative value, and the following assertion would trigger
> down the line (it's not the same max_pdiscard, but computed from the
> other one):
> qemu-system-x86_64: ../block/io.c:3166: bdrv_co_pdiscard: Assertion
> `max_pdiscard >= bs->bl.request_alignment' failed.
>
> On 32-bit platforms, it's fine to keep using SIZE_MAX.
>
> The assertion in qemu_gluster_co_pdiscard() is checking that the value
> of 'bytes' can safely be passed to glfs_discard_async(), which takes a
> size_t for the argument in question, so it is kept as is. And since
> max_pdiscard is still <= SIZE_MAX, relying on max_pdiscard is still
> fine.
>
> Fixes: 0c8022876f ("block: use int64_t instead of int in driver discard handlers")
> Cc: qemu-stable@nongnu.org
> Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
> ---
Reviewed-by: Eric Blake <eblake@redhat.com>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v3] block/gluster: correctly set max_pdiscard
2022-05-20 7:59 [PATCH v3] block/gluster: correctly set max_pdiscard Fabian Ebner
2022-05-24 21:14 ` Eric Blake
@ 2022-05-25 9:12 ` Stefano Garzarella
2022-05-27 16:45 ` Vladimir Sementsov-Ogievskiy
2022-05-30 13:15 ` Kevin Wolf
3 siblings, 0 replies; 5+ messages in thread
From: Stefano Garzarella @ 2022-05-25 9:12 UTC (permalink / raw)
To: Fabian Ebner
Cc: qemu-devel, kwolf, hreitz, qemu-block, integration, qemu-stable,
eblake, vsementsov
On Fri, May 20, 2022 at 09:59:22AM +0200, Fabian Ebner wrote:
>On 64-bit platforms, assigning SIZE_MAX to the int64_t max_pdiscard
>results in a negative value, and the following assertion would trigger
>down the line (it's not the same max_pdiscard, but computed from the
>other one):
>qemu-system-x86_64: ../block/io.c:3166: bdrv_co_pdiscard: Assertion
>`max_pdiscard >= bs->bl.request_alignment' failed.
>
>On 32-bit platforms, it's fine to keep using SIZE_MAX.
>
>The assertion in qemu_gluster_co_pdiscard() is checking that the value
>of 'bytes' can safely be passed to glfs_discard_async(), which takes a
>size_t for the argument in question, so it is kept as is. And since
>max_pdiscard is still <= SIZE_MAX, relying on max_pdiscard is still
>fine.
>
>Fixes: 0c8022876f ("block: use int64_t instead of int in driver discard handlers")
>Cc: qemu-stable@nongnu.org
>Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
>---
>
>v2 -> v3:
> * Keep assertion in qemu_gluster_co_pdiscard() as is.
> * Improve commit message.
>
>v1 -> v2:
> * Use an expression that works for both 64-bit and 32-bit platforms.
>
> block/gluster.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
>
>diff --git a/block/gluster.c b/block/gluster.c
>index 398976bc66..b60213ab80 100644
>--- a/block/gluster.c
>+++ b/block/gluster.c
>@@ -891,7 +891,7 @@ out:
> static void qemu_gluster_refresh_limits(BlockDriverState *bs, Error **errp)
> {
> bs->bl.max_transfer = GLUSTER_MAX_TRANSFER;
>- bs->bl.max_pdiscard = SIZE_MAX;
>+ bs->bl.max_pdiscard = MIN(SIZE_MAX, INT64_MAX);
> }
>
> static int qemu_gluster_reopen_prepare(BDRVReopenState *state,
>--
>2.30.2
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v3] block/gluster: correctly set max_pdiscard
2022-05-20 7:59 [PATCH v3] block/gluster: correctly set max_pdiscard Fabian Ebner
2022-05-24 21:14 ` Eric Blake
2022-05-25 9:12 ` Stefano Garzarella
@ 2022-05-27 16:45 ` Vladimir Sementsov-Ogievskiy
2022-05-30 13:15 ` Kevin Wolf
3 siblings, 0 replies; 5+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2022-05-27 16:45 UTC (permalink / raw)
To: Fabian Ebner, qemu-devel
Cc: kwolf, hreitz, qemu-block, integration, qemu-stable, eblake,
vsementsov, sgarzare
On 5/20/22 10:59, Fabian Ebner wrote:
> On 64-bit platforms, assigning SIZE_MAX to the int64_t max_pdiscard
> results in a negative value, and the following assertion would trigger
Oops. Good catch!
> down the line (it's not the same max_pdiscard, but computed from the
> other one):
> qemu-system-x86_64: ../block/io.c:3166: bdrv_co_pdiscard: Assertion
> `max_pdiscard >= bs->bl.request_alignment' failed.
>
> On 32-bit platforms, it's fine to keep using SIZE_MAX.
>
> The assertion in qemu_gluster_co_pdiscard() is checking that the value
> of 'bytes' can safely be passed to glfs_discard_async(), which takes a
> size_t for the argument in question, so it is kept as is. And since
> max_pdiscard is still <= SIZE_MAX, relying on max_pdiscard is still
> fine.
>
> Fixes: 0c8022876f ("block: use int64_t instead of int in driver discard handlers")
> Cc: qemu-stable@nongnu.org
> Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
--
Best regards,
Vladimir
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v3] block/gluster: correctly set max_pdiscard
2022-05-20 7:59 [PATCH v3] block/gluster: correctly set max_pdiscard Fabian Ebner
` (2 preceding siblings ...)
2022-05-27 16:45 ` Vladimir Sementsov-Ogievskiy
@ 2022-05-30 13:15 ` Kevin Wolf
3 siblings, 0 replies; 5+ messages in thread
From: Kevin Wolf @ 2022-05-30 13:15 UTC (permalink / raw)
To: Fabian Ebner
Cc: qemu-devel, hreitz, qemu-block, integration, qemu-stable, eblake,
vsementsov, sgarzare
Am 20.05.2022 um 09:59 hat Fabian Ebner geschrieben:
> On 64-bit platforms, assigning SIZE_MAX to the int64_t max_pdiscard
> results in a negative value, and the following assertion would trigger
> down the line (it's not the same max_pdiscard, but computed from the
> other one):
> qemu-system-x86_64: ../block/io.c:3166: bdrv_co_pdiscard: Assertion
> `max_pdiscard >= bs->bl.request_alignment' failed.
>
> On 32-bit platforms, it's fine to keep using SIZE_MAX.
>
> The assertion in qemu_gluster_co_pdiscard() is checking that the value
> of 'bytes' can safely be passed to glfs_discard_async(), which takes a
> size_t for the argument in question, so it is kept as is. And since
> max_pdiscard is still <= SIZE_MAX, relying on max_pdiscard is still
> fine.
>
> Fixes: 0c8022876f ("block: use int64_t instead of int in driver discard handlers")
> Cc: qemu-stable@nongnu.org
> Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
Thanks, applied to the block branch.
Kevin
^ permalink raw reply [flat|nested] 5+ messages in thread