yeahuh / rpms / qemu-kvm

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