Skip to contentSkip to conversation

iscsi: fix assertion in is_sector_request_lun_aligned

PATCH In review Peter Lieven 3 participants 4 messages Jun 20, 2016 – Jun 23, 2016 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iscsi: fix assertion in is_sector_request_lun_aligned

Commit 94d047a added an assertion the the request alignment check. This introduced 2 issues:
a) A off-by-one error since a request of BDRV_REQUEST_MAX_SECTORS is actually allowed.
b) The bdrv_get_block_status call in the read path to check the allocation status requests up to INT_MAX sectors which triggers the assertion.

Fixes 94d047a35bf663e28f8fef137544d8ea78165add
---
 block/iscsi.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
block/iscsi.c +3 -2
index 7e78ade..9bb5ff6 100644
@@ -417,7 +417,7 @@ static bool is_byte_request_lun_aligned(int64_t offset, int count,
 static bool is_sector_request_lun_aligned(int64_t sector_num, int nb_sectors,
                                           IscsiLun *iscsilun)
 {
-    assert(nb_sectors < BDRV_REQUEST_MAX_SECTORS);
+    assert(nb_sectors <= BDRV_REQUEST_MAX_SECTORS);
     return is_byte_request_lun_aligned(sector_num << BDRV_SECTOR_BITS,
                                        nb_sectors << BDRV_SECTOR_BITS,
                                        iscsilun);
@@ -661,7 +661,8 @@ static int coroutine_fn iscsi_co_readv(BlockDriverState *bs,
         int64_t ret;
         int pnum;
         BlockDriverState *file;
-        ret = iscsi_co_get_block_status(bs, sector_num, INT_MAX, &pnum, &file);
+        ret = iscsi_co_get_block_status(bs, sector_num,
+                                        BDRV_REQUEST_MAX_SECTORS, &pnum, &file);
         if (ret < 0) {
             return ret;
         }
Signature · 1 line
1.9.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Peter Lieven

Commit 94d047a added an assertion the the request alignment check. This introduced 2 issues:
a) A off-by-one error since a request of BDRV_REQUEST_MAX_SECTORS is actually allowed.
b) The bdrv_get_block_status call in the read path to check the allocation status requests up to INT_MAX sectors which triggers the assertion.

Quoted 6 lines
Fixes 94d047a35bf663e28f8fef137544d8ea78165add
---
 block/iscsi.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
Quoted 24 lines
block/iscsi.c +3 -2
index 7e78ade..9bb5ff6 100644
@@ -417,7 +417,7 @@ static bool is_byte_request_lun_aligned(int64_t offset, int count,
 static bool is_sector_request_lun_aligned(int64_t sector_num, int nb_sectors,
                                           IscsiLun *iscsilun)
 {
-    assert(nb_sectors < BDRV_REQUEST_MAX_SECTORS);
+    assert(nb_sectors <= BDRV_REQUEST_MAX_SECTORS);
     return is_byte_request_lun_aligned(sector_num << BDRV_SECTOR_BITS,
                                        nb_sectors << BDRV_SECTOR_BITS,
                                        iscsilun);
@@ -661,7 +661,8 @@ static int coroutine_fn iscsi_co_readv(BlockDriverState *bs,
         int64_t ret;
         int pnum;
         BlockDriverState *file;
-        ret = iscsi_co_get_block_status(bs, sector_num, INT_MAX, &pnum, &file);
+        ret = iscsi_co_get_block_status(bs, sector_num,
+                                        BDRV_REQUEST_MAX_SECTORS, &pnum, &file);
         if (ret < 0) {
             return ret;
         }
Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#2 lore raw
In reply to Peter Lieven
Quoted 28 lines · Peter Lieven

Commit 94d047a added an assertion the the request alignment check. This introduced 2 issues:
a) A off-by-one error since a request of BDRV_REQUEST_MAX_SECTORS is actually allowed.
b) The bdrv_get_block_status call in the read path to check the allocation status requests up to INT_MAX sectors which triggers the assertion.

Fixes 94d047a35bf663e28f8fef137544d8ea78165add
---
 block/iscsi.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
block/iscsi.c +1 -1
index 7e78ade..9bb5ff6 100644
@@ -417,7 +417,7 @@ static bool is_byte_request_lun_aligned(int64_t offset, int count,
 static bool is_sector_request_lun_aligned(int64_t sector_num, int nb_sectors,
                                           IscsiLun *iscsilun)
 {
-    assert(nb_sectors < BDRV_REQUEST_MAX_SECTORS);
+    assert(nb_sectors <= BDRV_REQUEST_MAX_SECTORS);
     return is_byte_request_lun_aligned(sector_num << BDRV_SECTOR_BITS,
                                        nb_sectors << BDRV_SECTOR_BITS,
                                        iscsilun);

block/iscsi.c static int coroutine_fn iscsi_co_readv(BlockDriverState *bs, · line 668

Quoted 9 lines
block/iscsi.c +2 -1
@@ -661,7 +661,8 @@ static int coroutine_fn iscsi_co_readv(BlockDriverState *bs,
         int64_t ret;
         int pnum;
         BlockDriverState *file;
-        ret = iscsi_co_get_block_status(bs, sector_num, INT_MAX, &pnum, &file);
+        ret = iscsi_co_get_block_status(bs, sector_num,
+                                        BDRV_REQUEST_MAX_SECTORS, &pnum, &file);
         if (ret < 0) {
             return ret;
         }

Hi, I've queued this patch. Can you rebase the allocation map patch on top of master + this one?

Thanks,

Paolo

#3 lore raw

Am 23.06.2016 um 17:50 schrieb Paolo Bonzini:

Quoted 32 lines · Peter Lieven
Quoted 31 lines

Commit 94d047a added an assertion the the request alignment check. This introduced 2 issues:
a) A off-by-one error since a request of BDRV_REQUEST_MAX_SECTORS is actually allowed.
b) The bdrv_get_block_status call in the read path to check the allocation status requests up to INT_MAX sectors which triggers the assertion.

Fixes 94d047a35bf663e28f8fef137544d8ea78165add
---
  block/iscsi.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
block/iscsi.c +1 -2
index 7e78ade..9bb5ff6 100644
@@ -417,7 +417,7 @@ static bool is_byte_request_lun_aligned(int64_t offset, int count,
  static bool is_sector_request_lun_aligned(int64_t sector_num, int nb_sectors,
                                            IscsiLun *iscsilun)
  {
-    assert(nb_sectors < BDRV_REQUEST_MAX_SECTORS);
+    assert(nb_sectors <= BDRV_REQUEST_MAX_SECTORS);
      return is_byte_request_lun_aligned(sector_num << BDRV_SECTOR_BITS,
                                         nb_sectors << BDRV_SECTOR_BITS,
                                         iscsilun);
@@ -661,7 +661,8 @@ static int coroutine_fn iscsi_co_readv(BlockDriverState *bs,
          int64_t ret;
          int pnum;
          BlockDriverState *file;
-        ret = iscsi_co_get_block_status(bs, sector_num, INT_MAX, &pnum, &file);
Quoted 8 lines

block/iscsi.c static int coroutine_fn iscsi_co_readv(BlockDriverState *bs, · line 668

Quoted 6 lines
block/iscsi.c +2 -0
+        ret = iscsi_co_get_block_status(bs, sector_num,
+                                        BDRV_REQUEST_MAX_SECTORS, &pnum, &file);
          if (ret < 0) {
              return ret;
          }

Hi, I've queued this patch. Can you rebase the allocation map patch on top of master + this one?

will do.

Peter