From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44748) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WTB82-00055P-7P for qemu-devel@nongnu.org; Thu, 27 Mar 2014 10:18:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WTB7u-00023k-Pl for qemu-devel@nongnu.org; Thu, 27 Mar 2014 10:17:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36368) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WTB7u-00023Q-IK for qemu-devel@nongnu.org; Thu, 27 Mar 2014 10:17:50 -0400 Message-ID: <53343305.7000800@redhat.com> Date: Thu, 27 Mar 2014 15:17:41 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <1395927818-26431-1-git-send-email-pl@kamp.de> In-Reply-To: <1395927818-26431-1-git-send-email-pl@kamp.de> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] block/iscsi: speed up read for unallocated sectors List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Lieven , qemu-devel@nongnu.org Cc: kwolf@redhat.com, ronniesahlberg@gmail.com, stefanha@redhat.com Il 27/03/2014 14:43, Peter Lieven ha scritto: > > +static void iscsi_allocationmap_set(IscsiLun *iscsilun, int64_t sector_num, > + int nb_sectors) > +{ > + if (!iscsilun->cluster_sectors) { > + return; > + } > + bitmap_set(iscsilun->allocationmap, > + sector_num / iscsilun->cluster_sectors, > + DIV_ROUND_UP(nb_sectors, iscsilun->cluster_sectors)); > +} > + > +static void iscsi_allocationmap_clear(IscsiLun *iscsilun, int64_t sector_num, > + int nb_sectors) > +{ > + if (!iscsilun->cluster_sectors) { > + return; > + } > + bitmap_clear(iscsilun->allocationmap, > + sector_num / iscsilun->cluster_sectors, > + DIV_ROUND_UP(nb_sectors, iscsilun->cluster_sectors)); > +} > + Here you need to round the other way, because partial clusters are not unmapped: cluster_num = DIV_ROUND_UP(sector_num, iscsi->cluster_sectors); nb_clusters = (sector_num + nb_sectors) / iscsi->cluster_sectors - cluster_num; bitmap_clear(iscsilun->allocationmap, cluster_num, nb_clusters); Paolo