[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCHv4 3/4] block/iscsi: set max_transfer_length
From: |
Peter Lieven |
Subject: |
Re: [Qemu-devel] [PATCHv4 3/4] block/iscsi: set max_transfer_length |
Date: |
Sat, 25 Oct 2014 17:16:05 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.0 |
Am 23.10.2014 um 13:18 schrieb Max Reitz:
> On 2014-10-16 at 09:54, Peter Lieven wrote:
>> the limit of 0xffffff for 16 byte CDBs is intentional to
>> avoid overflows on 32-bit architectures.
>
> How is it related to 32 bit? I somehow feel like it has to do something with
> the result of sector_lun2qemu() which involves block_size...
iscsilun->bl.max_xfer_len is 32-bit unsigned while nb_sectors is usually
signed. Furthermore as you suspected nb_sectors is always 512Byte sectors
while iscsilun->block_size can be 4k or even more.
I will change the code to set max_xfer_len to 0xffffffff and limit the output
of sector_lun2qemu() to INT_MAX in the bs->bl.max_transfer_length case.
However, in real life you will never want to have a transfer of 0x3fffffff
blocks, won't you?
Peter
>
>> Signed-off-by: Peter Lieven <address@hidden>
>> Reviewed-by: Ronnie Sahlberg <address@hidden>
>> ---
>> block/iscsi.c | 12 ++++++++++--
>> 1 file changed, 10 insertions(+), 2 deletions(-)
>>
>> diff --git a/block/iscsi.c b/block/iscsi.c
>> index 3a01de0..c873d13 100644
>> --- a/block/iscsi.c
>> +++ b/block/iscsi.c
>> @@ -1449,10 +1449,18 @@ static void iscsi_close(BlockDriverState *bs)
>> static void iscsi_refresh_limits(BlockDriverState *bs, Error **errp)
>> {
>> - IscsiLun *iscsilun = bs->opaque;
>> -
>> /* We don't actually refresh here, but just return data queried in
>> * iscsi_open(): iscsi targets don't change their limits. */
>> +
>> + IscsiLun *iscsilun = bs->opaque;
>> + uint32_t max_xfer_len = iscsilun->use_16_for_rw ? 0xffffff : 0xffff;
>> +
>> + if (iscsilun->bl.max_xfer_len) {
>> + max_xfer_len = MIN(max_xfer_len, iscsilun->bl.max_xfer_len);
>> + }
>> +
>> + bs->bl.max_transfer_length = sector_lun2qemu(max_xfer_len, iscsilun);
>> +
>> if (iscsilun->lbp.lbpu) {
>> if (iscsilun->bl.max_unmap < 0xffffffff) {
>> bs->bl.max_discard = sector_lun2qemu(iscsilun->bl.max_unmap,
>
- [Qemu-devel] [PATCHv4 2/4] BlockLimits: introduce max_transfer_length, (continued)