From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60980) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bGDFr-00041G-Nr for qemu-devel@nongnu.org; Thu, 23 Jun 2016 18:37:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bGDFi-0005s4-0Z for qemu-devel@nongnu.org; Thu, 23 Jun 2016 18:37:46 -0400 From: Eric Blake Date: Thu, 23 Jun 2016 16:37:10 -0600 Message-Id: <1466721446-27737-7-git-send-email-eblake@redhat.com> In-Reply-To: <1466721446-27737-1-git-send-email-eblake@redhat.com> References: <1466721446-27737-1-git-send-email-eblake@redhat.com> Subject: [Qemu-devel] [PATCH v3 06/22] iscsi: Advertise realistic limits to block layer List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, kwolf@redhat.com, famz@redhat.com, stefanha@redhat.com, Ronnie Sahlberg , Paolo Bonzini , Peter Lieven , Max Reitz The function sector_limits_lun2qemu() returns a value in units of the block layer's 512-byte sector, and can be as large as 0x40000000, which is much larger than the block layer's inherent limit of BDRV_REQUEST_MAX_SECTORS. The block layer already handles '0' as a synonym to the inherent limit, and it is nicer to return this value than it is to calculate an arbitrary maximum, for two reasons: we want to ensure that the block layer continues to special-case '0' as 'no limit beyond the inherent limits'; and we want to be able to someday expand the block layer to allow 64-bit limits, where auditing for uses of BDRV_REQUEST_MAX_SECTORS will help us make sure we aren't artificially constraining iscsi to old block layer limits. Signed-off-by: Eric Blake Reviewed-by: Kevin Wolf Reviewed-by: Fam Zheng Reviewed-by: Stefan Hajnoczi --- v3: no change v2: new patch --- block/iscsi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/block/iscsi.c b/block/iscsi.c index 7e78ade..4290e41 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -1697,7 +1697,9 @@ static void iscsi_close(BlockDriverState *bs) static int sector_limits_lun2qemu(int64_t sector, IscsiLun *iscsilun) { - return MIN(sector_lun2qemu(sector, iscsilun), INT_MAX / 2 + 1); + int limit = MIN(sector_lun2qemu(sector, iscsilun), INT_MAX / 2 + 1); + + return limit < BDRV_REQUEST_MAX_SECTORS ? limit : 0; } static void iscsi_refresh_limits(BlockDriverState *bs, Error **errp) -- 2.5.5