|
|
9ae3a8 |
From dba21483b097900b47ba5e1e597ba4a4150b1aa1 Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
Message-Id: <dba21483b097900b47ba5e1e597ba4a4150b1aa1.1389014116.git.minovotn@redhat.com>
|
|
|
9ae3a8 |
In-Reply-To: <c8cc35838d42aa286242772d97e3a9be7bb786ba.1389014116.git.minovotn@redhat.com>
|
|
|
9ae3a8 |
References: <c8cc35838d42aa286242772d97e3a9be7bb786ba.1389014116.git.minovotn@redhat.com>
|
|
|
9ae3a8 |
From: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9ae3a8 |
Date: Mon, 9 Dec 2013 14:08:50 +0100
|
|
|
9ae3a8 |
Subject: [PATCH 02/50] iscsi: factor out sector conversions
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9ae3a8 |
Message-id: <1386598178-11845-5-git-send-email-pbonzini@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 56041
|
|
|
9ae3a8 |
O-Subject: [RHEL 7.0 qemu-kvm PATCH 04/52] iscsi: factor out sector conversions
|
|
|
9ae3a8 |
Bugzilla: 1007815
|
|
|
9ae3a8 |
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Fam Zheng <famz@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
From: Peter Lieven <pl@kamp.de>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Peter Lieven <pl@kamp.de>
|
|
|
9ae3a8 |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9ae3a8 |
(cherry picked from commit 0777b5dde42f4f453abc8bb2c4e145fb8749415d)
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
block/iscsi.c | 10 +++++++---
|
|
|
9ae3a8 |
1 file changed, 7 insertions(+), 3 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Michal Novotny <minovotn@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
block/iscsi.c | 10 +++++++---
|
|
|
9ae3a8 |
1 file changed, 7 insertions(+), 3 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/block/iscsi.c b/block/iscsi.c
|
|
|
9ae3a8 |
index ac35caa..8086957 100644
|
|
|
9ae3a8 |
--- a/block/iscsi.c
|
|
|
9ae3a8 |
+++ b/block/iscsi.c
|
|
|
9ae3a8 |
@@ -234,6 +234,11 @@ iscsi_aio_write16_cb(struct iscsi_context *iscsi, int status,
|
|
|
9ae3a8 |
iscsi_schedule_bh(acb);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+static int64_t sector_lun2qemu(int64_t sector, IscsiLun *iscsilun)
|
|
|
9ae3a8 |
+{
|
|
|
9ae3a8 |
+ return sector * iscsilun->block_size / BDRV_SECTOR_SIZE;
|
|
|
9ae3a8 |
+}
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
static int64_t sector_qemu2lun(int64_t sector, IscsiLun *iscsilun)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
return sector * BDRV_SECTOR_SIZE / iscsilun->block_size;
|
|
|
9ae3a8 |
@@ -298,7 +303,7 @@ iscsi_aio_writev_acb(IscsiAIOCB *acb)
|
|
|
9ae3a8 |
lba = sector_qemu2lun(acb->sector_num, acb->iscsilun);
|
|
|
9ae3a8 |
*(uint32_t *)&acb->task->cdb[2] = htonl(lba >> 32);
|
|
|
9ae3a8 |
*(uint32_t *)&acb->task->cdb[6] = htonl(lba & 0xffffffff);
|
|
|
9ae3a8 |
- num_sectors = size / acb->iscsilun->block_size;
|
|
|
9ae3a8 |
+ num_sectors = sector_qemu2lun(acb->nb_sectors, acb->iscsilun);
|
|
|
9ae3a8 |
*(uint32_t *)&acb->task->cdb[10] = htonl(num_sectors);
|
|
|
9ae3a8 |
acb->task->expxferlen = size;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
@@ -1171,8 +1176,7 @@ static int iscsi_open(BlockDriverState *bs, QDict *options, int flags,
|
|
|
9ae3a8 |
if ((ret = iscsi_readcapacity_sync(iscsilun)) != 0) {
|
|
|
9ae3a8 |
goto out;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
- bs->total_sectors = iscsilun->num_blocks *
|
|
|
9ae3a8 |
- iscsilun->block_size / BDRV_SECTOR_SIZE ;
|
|
|
9ae3a8 |
+ bs->total_sectors = sector_lun2qemu(iscsilun->num_blocks, iscsilun);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
/* Medium changer or tape. We dont have any emulation for this so this must
|
|
|
9ae3a8 |
* be sg ioctl compatible. We force it to be sg, otherwise qemu will try
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.7.11.7
|
|
|
9ae3a8 |
|