Received: from eggs.gnu.org ([2001:4830:134:3::10]:38576) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bIeNK-0001CI-E1 for qemu-devel@nongnu.org; Thu, 30 Jun 2016 11:59:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bIeNI-0008Lx-LG for qemu-devel@nongnu.org; Thu, 30 Jun 2016 11:59:33 -0400 References: <1467284899-22575-1-git-send-email-pl@kamp.de> From: Paolo Bonzini Message-ID: <0bdc5c9b-e565-d63d-c82c-acee433c036d@redhat.com> Date: Thu, 30 Jun 2016 17:59:01 +0200 MIME-Version: 1.0 In-Reply-To: <1467284899-22575-1-git-send-email-pl@kamp.de> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [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: Peter Lieven , qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, kwolf@redhat.com, mreitz@redhat.com, ronniesahlberg@gmail.com, famz@redhat.com On 30/06/2016 13:08, Peter Lieven wrote: > 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; > + } > + } > } > } > > This can take a long time and the disks may not even be ever used. I don't think it's a good idea. Paolo