Reviewed-by: Kevin Wolf <kw...@redhat.com> Signed-off-by: Peter Lieven <p...@kamp.de> --- block/iscsi.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/block/iscsi.c b/block/iscsi.c index 6cdd182..bc62a7e 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -289,6 +289,11 @@ static int64_t sector_qemu2lun(int64_t sector, IscsiLun *iscsilun) return sector * BDRV_SECTOR_SIZE / iscsilun->block_size; } +static int64_t sector_lun2qemu(int64_t sector, IscsiLun *iscsilun) +{ + return sector * iscsilun->block_size / BDRV_SECTOR_SIZE; +} + static int iscsi_aio_writev_acb(IscsiAIOCB *acb) { @@ -336,7 +341,7 @@ iscsi_aio_writev_acb(IscsiAIOCB *acb) lba = sector_qemu2lun(acb->sector_num, acb->iscsilun); *(uint32_t *)&acb->task->cdb[2] = htonl(lba >> 32); *(uint32_t *)&acb->task->cdb[6] = htonl(lba & 0xffffffff); - num_sectors = size / acb->iscsilun->block_size; + num_sectors = sector_qemu2lun(acb->nb_sectors, acb->iscsilun); *(uint32_t *)&acb->task->cdb[10] = htonl(num_sectors); acb->task->expxferlen = size; @@ -836,7 +841,7 @@ retry: goto out; } - *pnum = lbasd->num_blocks * (iscsilun->block_size / BDRV_SECTOR_SIZE); + *pnum = sector_lun2qemu(lbasd->num_blocks, iscsilun); if (*pnum > nb_sectors) { *pnum = nb_sectors; } @@ -1272,8 +1277,7 @@ static int iscsi_open(BlockDriverState *bs, QDict *options, int flags) if ((ret = iscsi_readcapacity_sync(iscsilun)) != 0) { goto out; } - bs->total_sectors = iscsilun->num_blocks * - iscsilun->block_size / BDRV_SECTOR_SIZE ; + bs->total_sectors = sector_lun2qemu(iscsilun->num_blocks, iscsilun); /* Medium changer or tape. We dont have any emulation for this so this must * be sg ioctl compatible. We force it to be sg, otherwise qemu will try -- 1.7.9.5