Received: from eggs.gnu.org ([2001:4830:134:3::10]:44076) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bIZpg-0008WD-Rg for qemu-devel@nongnu.org; Thu, 30 Jun 2016 07:08:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bIZpb-0004k5-Sb for qemu-devel@nongnu.org; Thu, 30 Jun 2016 07:08:31 -0400 Received: from mx-v6.kamp.de ([2a02:248:0:51::16]:53336 helo=mx01.kamp.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bIZpb-0004j4-JM for qemu-devel@nongnu.org; Thu, 30 Jun 2016 07:08:27 -0400 From: Peter Lieven Date: Thu, 30 Jun 2016 13:08:19 +0200 Message-Id: <1467284899-22575-1-git-send-email-pl@kamp.de> Subject: [Qemu-devel] [PATCH] block/iscsi: precache the allocation status of a target List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, pbonzini@redhat.com, kwolf@redhat.com, mreitz@redhat.com, ronniesahlberg@gmail.com, famz@redhat.com, Peter Lieven this fills up the allocationmap at iscsi_open. This helps to reduce the number of get_block_status requests during runtime significantly. Signed-off-by: Peter Lieven --- block/iscsi.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/block/iscsi.c b/block/iscsi.c index 0cdcedb..04fb0a3 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -1774,6 +1774,22 @@ static int iscsi_open(BlockDriverState *bs, QDict *options, int flags, iscsilun->block_size) >> BDRV_SECTOR_BITS; if (iscsilun->lbprz) { ret = iscsi_allocmap_init(iscsilun, bs->open_flags); + if (ret == 0) { + unsigned int max_reqs = 64; + int64_t sector_num = 0; + while (max_reqs-- && sector_num < bs->total_sectors) { + int n; + BlockDriverState *file; + ret = bdrv_get_block_status(bs, sector_num, + BDRV_REQUEST_MAX_SECTORS, + &n, &file); + if (ret < 0) { + break; + } + sector_num += n; + ret = 0; + } + } } } -- 1.9.1