qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] iscsi: fix assertion in is_sector_request_lun_aligned
@ 2016-06-20  9:24 Peter Lieven
  2016-06-20 16:47 ` Eric Blake
  2016-06-23 15:50 ` Paolo Bonzini
  0 siblings, 2 replies; 4+ messages in thread
From: Peter Lieven @ 2016-06-20  9:24 UTC (permalink / raw)
  To: qemu-block
  Cc: qemu-devel, kwolf, mreitz, pbonzini, ronniesahlberg, eblake,
	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
Signed-off-by: Peter Lieven <pl@kamp.de>
---
 block/iscsi.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/block/iscsi.c b/block/iscsi.c
index 7e78ade..9bb5ff6 100644
--- a/block/iscsi.c
+++ b/block/iscsi.c
@@ -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;
         }
-- 
1.9.1

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

* Re: [Qemu-devel] [PATCH] iscsi: fix assertion in is_sector_request_lun_aligned
  2016-06-20  9:24 [Qemu-devel] [PATCH] iscsi: fix assertion in is_sector_request_lun_aligned Peter Lieven
@ 2016-06-20 16:47 ` Eric Blake
  2016-06-23 15:50 ` Paolo Bonzini
  1 sibling, 0 replies; 4+ messages in thread
From: Eric Blake @ 2016-06-20 16:47 UTC (permalink / raw)
  To: Peter Lieven, qemu-block
  Cc: qemu-devel, kwolf, mreitz, pbonzini, ronniesahlberg

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

On 06/20/2016 03:24 AM, Peter Lieven wrote:
> 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
> Signed-off-by: Peter Lieven <pl@kamp.de>
> ---
>  block/iscsi.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 

Reviewed-by: Eric Blake <eblake@redhat.com>

> diff --git a/block/iscsi.c b/block/iscsi.c
> index 7e78ade..9bb5ff6 100644
> --- a/block/iscsi.c
> +++ b/block/iscsi.c
> @@ -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;
>          }
> 

-- 
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] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] iscsi: fix assertion in is_sector_request_lun_aligned
  2016-06-20  9:24 [Qemu-devel] [PATCH] iscsi: fix assertion in is_sector_request_lun_aligned Peter Lieven
  2016-06-20 16:47 ` Eric Blake
@ 2016-06-23 15:50 ` Paolo Bonzini
  2016-06-23 16:19   ` Peter Lieven
  1 sibling, 1 reply; 4+ messages in thread
From: Paolo Bonzini @ 2016-06-23 15:50 UTC (permalink / raw)
  To: Peter Lieven, qemu-block
  Cc: qemu-devel, kwolf, mreitz, ronniesahlberg, eblake

On 20/06/2016 11:24, Peter Lieven wrote:
> 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
> Signed-off-by: Peter Lieven <pl@kamp.de>
> ---
>  block/iscsi.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/block/iscsi.c b/block/iscsi.c
> index 7e78ade..9bb5ff6 100644
> --- a/block/iscsi.c
> +++ b/block/iscsi.c
> @@ -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;
>          }
> 

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

Thanks,

Paolo

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

* Re: [Qemu-devel] [PATCH] iscsi: fix assertion in is_sector_request_lun_aligned
  2016-06-23 15:50 ` Paolo Bonzini
@ 2016-06-23 16:19   ` Peter Lieven
  0 siblings, 0 replies; 4+ messages in thread
From: Peter Lieven @ 2016-06-23 16:19 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-block
  Cc: qemu-devel, kwolf, mreitz, ronniesahlberg, eblake

Am 23.06.2016 um 17:50 schrieb Paolo Bonzini:
> On 20/06/2016 11:24, Peter Lieven wrote:
>> 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
>> Signed-off-by: Peter Lieven <pl@kamp.de>
>> ---
>>   block/iscsi.c | 5 +++--
>>   1 file changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/block/iscsi.c b/block/iscsi.c
>> index 7e78ade..9bb5ff6 100644
>> --- a/block/iscsi.c
>> +++ b/block/iscsi.c
>> @@ -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;
>>           }
>>
> Hi, I've queued this patch.  Can you rebase the allocation map patch on
> top of master + this one?

will do.

Peter

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

end of thread, other threads:[~2016-06-23 16:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-20  9:24 [Qemu-devel] [PATCH] iscsi: fix assertion in is_sector_request_lun_aligned Peter Lieven
2016-06-20 16:47 ` Eric Blake
2016-06-23 15:50 ` Paolo Bonzini
2016-06-23 16:19   ` Peter Lieven

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).