All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v3] fixup! iscsi: Fix divide-by-zero regression on raw SG devices
@ 2016-09-22 17:38 Eric Blake
  2016-09-22 18:30 ` Paolo Bonzini
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Blake @ 2016-09-22 17:38 UTC (permalink / raw
  To: qemu-devel
  Cc: qemu-stable, pbonzini, Ronnie Sahlberg, Peter Lieven, Kevin Wolf,
	Max Reitz, open list:iSCSI

[keep original commit message]

Reported-by: Holger Schranz <holger@fam-schranz.de>
Signed-off-by: Eric Blake <eblake@redhat.com>
CC: qemu-stable@nongnu.org

---

Paolo just sent a pull request, but if I'm not too late, this should
be squashed in. If I am too late, then we can rework the commit
message to make it this is an obvious followup.

v3: preserve 4k iscsilun->block_size
v2: avoid second assertion failure
---
 block/iscsi.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/block/iscsi.c b/block/iscsi.c
index c01e955..7bb6e5d 100644
--- a/block/iscsi.c
+++ b/block/iscsi.c
@@ -1813,10 +1813,14 @@ static void iscsi_refresh_limits(BlockDriverState *bs, Error **errp)

     IscsiLun *iscsilun = bs->opaque;
     uint64_t max_xfer_len = iscsilun->use_16_for_rw ? 0xffffffff : 0xffff;
-    unsigned int block_size = MIN_NON_ZERO(BDRV_SECTOR_SIZE,
-                                           iscsilun->block_size);
+    unsigned int block_size = iscsilun->block_size;

-    assert(iscsilun->block_size >= BDRV_SECTOR_SIZE || bs->sg);
+    if (!block_size) {
+        assert(bs->sg);
+        block_size = BDRV_SECTOR_SIZE;
+    } else {
+        assert(block_size >= BDRV_SECTOR_SIZE);
+    }

     bs->bl.request_alignment = block_size;

-- 
2.7.4

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

* Re: [Qemu-devel] [PATCH v3] fixup! iscsi: Fix divide-by-zero regression on raw SG devices
  2016-09-22 17:38 [Qemu-devel] [PATCH v3] fixup! iscsi: Fix divide-by-zero regression on raw SG devices Eric Blake
@ 2016-09-22 18:30 ` Paolo Bonzini
  2016-09-22 19:03   ` Eric Blake
  0 siblings, 1 reply; 3+ messages in thread
From: Paolo Bonzini @ 2016-09-22 18:30 UTC (permalink / raw
  To: Eric Blake, qemu-devel
  Cc: qemu-stable, Ronnie Sahlberg, Peter Lieven, Kevin Wolf, Max Reitz,
	open list:iSCSI


> Paolo just sent a pull request, but if I'm not too late, this should
> be squashed in. If I am too late, then we can rework the commit
> message to make it this is an obvious followup.

I just replaced MIN_NON_ZERO with MAX.

Paolo

> v3: preserve 4k iscsilun->block_size
> v2: avoid second assertion failure
> ---
>  block/iscsi.c | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/block/iscsi.c b/block/iscsi.c
> index c01e955..7bb6e5d 100644
> --- a/block/iscsi.c
> +++ b/block/iscsi.c
> @@ -1813,10 +1813,14 @@ static void iscsi_refresh_limits(BlockDriverState *bs, Error **errp)
> 
>      IscsiLun *iscsilun = bs->opaque;
>      uint64_t max_xfer_len = iscsilun->use_16_for_rw ? 0xffffffff : 0xffff;
> -    unsigned int block_size = MIN_NON_ZERO(BDRV_SECTOR_SIZE,
> -                                           iscsilun->block_size);
> +    unsigned int block_size = iscsilun->block_size;
> 
> -    assert(iscsilun->block_size >= BDRV_SECTOR_SIZE || bs->sg);
> +    if (!block_size) {
> +        assert(bs->sg);
> +        block_size = BDRV_SECTOR_SIZE;
> +    } else {
> +        assert(block_size >= BDRV_SECTOR_SIZE);
> +    }
> 
>      bs->bl.request_alignment = block_size;
> 

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

* Re: [Qemu-devel] [PATCH v3] fixup! iscsi: Fix divide-by-zero regression on raw SG devices
  2016-09-22 18:30 ` Paolo Bonzini
@ 2016-09-22 19:03   ` Eric Blake
  0 siblings, 0 replies; 3+ messages in thread
From: Eric Blake @ 2016-09-22 19:03 UTC (permalink / raw
  To: Paolo Bonzini, qemu-devel
  Cc: qemu-stable, Ronnie Sahlberg, Peter Lieven, Kevin Wolf, Max Reitz,
	open list:iSCSI

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

On 09/22/2016 01:30 PM, Paolo Bonzini wrote:
> 
>> Paolo just sent a pull request, but if I'm not too late, this should
>> be squashed in. If I am too late, then we can rework the commit
>> message to make it this is an obvious followup.
> 
> I just replaced MIN_NON_ZERO with MAX.
> 

Works for me, and a bit more elegant.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

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

end of thread, other threads:[~2016-09-22 19:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-22 17:38 [Qemu-devel] [PATCH v3] fixup! iscsi: Fix divide-by-zero regression on raw SG devices Eric Blake
2016-09-22 18:30 ` Paolo Bonzini
2016-09-22 19:03   ` Eric Blake

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.