From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48152) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uq7VA-0002br-Me for qemu-devel@nongnu.org; Fri, 21 Jun 2013 16:00:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uq7V8-0004gL-A4 for qemu-devel@nongnu.org; Fri, 21 Jun 2013 16:00:08 -0400 Received: from mail-ea0-x22a.google.com ([2a00:1450:4013:c01::22a]:50311) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uq7V8-0004fS-59 for qemu-devel@nongnu.org; Fri, 21 Jun 2013 16:00:06 -0400 Received: by mail-ea0-f170.google.com with SMTP id h10so4841378eaj.15 for ; Fri, 21 Jun 2013 13:00:05 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <51C4B0C0.5020503@redhat.com> Date: Fri, 21 Jun 2013 22:00:00 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1371752409-16313-1-git-send-email-pl@kamp.de> <1371752409-16313-3-git-send-email-pl@kamp.de> In-Reply-To: <1371752409-16313-3-git-send-email-pl@kamp.de> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 2/2] iscsi: add intelligent has_zero_init check List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Lieven Cc: Kevin Wolf , Stefan Hajnoczi , qemu-devel@nongnu.org, ronniesahlberg@gmail.com Il 20/06/2013 20:20, Peter Lieven ha scritto: > + for (lba = 0; lba < iscsilun->num_blocks; lba += 1 << 26) { > + nb_sectors = 1 << 26; > + if (lba + nb_sectors > iscsilun->num_blocks) { > + nb_sectors = iscsilun->num_blocks - lba; > + } > + nb_sectors *= (iscsilun->block_size / BDRV_SECTOR_SIZE); > + n = 0; > + ret = iscsi_co_is_allocated(bs, lba, nb_sectors, &n); > + if (ret || n != nb_sectors) { > + return 0; > + } I would just do lba += n in the for loop, and only exit if n == 0. The SCSI spec does not forbid splitting a single allocated area into multiple descriptors, or only returning part of an allocated area into the last descriptor. Otherwise looks good, but you may want to cache the result. It would not be 1 anymore after the first write. Paolo