Skip to contentSkip to conversation

fixup! iscsi: Fix divide-by-zero regression on raw SG devices

PATCH In review Eric Blake 2 participants 3 messages Sep 22, 2016 Block layer

lore
Share & tools
lore

Eric Blake

author
#0 lore raw

PATCH v3 1/1 fixup! iscsi: Fix divide-by-zero regression on raw SG devices

[keep original commit message]

---

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(-)
block/iscsi.c +7 -3
index c01e955..7bb6e5d 100644
@@ -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;
 
Signature · 1 line
2.7.4
#1 lore raw
Quoted 4 lines

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

Quoted 28 lines

v3: preserve 4k iscsilun->block_size
v2: avoid second assertion failure

---
 block/iscsi.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
block/iscsi.c +7 -3
index c01e955..7bb6e5d 100644
@@ -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;
 
author
#2 lore raw
Quoted 7 lines · Paolo Bonzini
Quoted 4 lines

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.

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