From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56780) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XigTM-0008NV-R6 for qemu-devel@nongnu.org; Mon, 27 Oct 2014 05:20:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XigTH-0005Du-4o for qemu-devel@nongnu.org; Mon, 27 Oct 2014 05:20:20 -0400 Received: from mx-v6.kamp.de ([2a02:248:0:51::16]:58054 helo=mx01.kamp.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XigTG-0005Dj-RG for qemu-devel@nongnu.org; Mon, 27 Oct 2014 05:20:15 -0400 From: Peter Lieven Date: Mon, 27 Oct 2014 10:18:45 +0100 Message-Id: <1414401528-21884-4-git-send-email-pl@kamp.de> In-Reply-To: <1414401528-21884-1-git-send-email-pl@kamp.de> References: <1414401528-21884-1-git-send-email-pl@kamp.de> Subject: [Qemu-devel] [PATCHv6 3/6] block/iscsi: set max_transfer_length List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, famz@redhat.com, benoit@irqsave.net, ronniesahlberg@gmail.com, Peter Lieven , armbru@redhat.com, mreitz@redhat.com, stefanha@redhat.com Copy the max_xfer_len from the BlockLimits VPD or use the maximum value fitting in the CDB. The helper function sector_limits_lun2qemu is introduced to convert and cap the limits from the VPD to the maximum power of two fitting in an integer; integer is the range for nb_sectors throughout the block layer. Signed-off-by: Peter Lieven --- block/iscsi.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/block/iscsi.c b/block/iscsi.c index 233f462..6b229b1 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -1447,12 +1447,25 @@ static void iscsi_close(BlockDriverState *bs) memset(iscsilun, 0, sizeof(IscsiLun)); } -static void iscsi_refresh_limits(BlockDriverState *bs, Error **errp) +static int sector_limits_lun2qemu(int64_t sector, IscsiLun *iscsilun) { - IscsiLun *iscsilun = bs->opaque; + return MIN(sector_lun2qemu(sector, iscsilun), INT_MAX / 2 + 1); +} +static void iscsi_refresh_limits(BlockDriverState *bs, Error **errp) +{ /* 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 ? 0xffffffff : 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_limits_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, -- 1.7.9.5