qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Peter Lieven <pl@kamp.de>
Cc: Kevin Wolf <kwolf@redhat.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	qemu-devel@nongnu.org, ronniesahlberg@gmail.com
Subject: Re: [Qemu-devel] [PATCH 2/2] iscsi: add intelligent has_zero_init check
Date: Fri, 21 Jun 2013 22:00:00 +0200	[thread overview]
Message-ID: <51C4B0C0.5020503@redhat.com> (raw)
In-Reply-To: <1371752409-16313-3-git-send-email-pl@kamp.de>

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

  reply	other threads:[~2013-06-21 20:00 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-20 18:20 [Qemu-devel] [PATCH 0/2] iscsi: support for is_allocated and inproved has_zero_init Peter Lieven
2013-06-20 18:20 ` [Qemu-devel] [PATCH 1/2] iscsi: add support for bdrv_co_is_allocated() Peter Lieven
2013-06-21  9:18   ` Kevin Wolf
2013-06-21  9:45     ` Peter Lieven
2013-06-21 11:07       ` Kevin Wolf
2013-06-21 11:42         ` Peter Lieven
2013-06-21 13:14           ` Kevin Wolf
2013-06-21 13:23             ` Peter Lieven
2013-06-21 16:31         ` Paolo Bonzini
2013-06-21 17:06           ` Peter Lieven
2013-06-21 17:13             ` ronnie sahlberg
2013-06-21 17:18               ` Peter Lieven
2013-06-21 16:06     ` ronnie sahlberg
2013-06-21 20:01       ` Paolo Bonzini
2013-06-24  8:13     ` Stefan Hajnoczi
2013-06-24 13:49       ` Paolo Bonzini
2013-06-24 16:11         ` Peter Lieven
2013-06-20 18:20 ` [Qemu-devel] [PATCH 2/2] iscsi: add intelligent has_zero_init check Peter Lieven
2013-06-21 20:00   ` Paolo Bonzini [this message]
2013-06-21 20:25     ` Peter Lieven
  -- strict thread matches above, loose matches on Subject: below --
2013-06-20 18:08 [Qemu-devel] [PATCH 0/2] iscsi: support for is_allocated and inproved has_zero_init Peter Lieven
2013-06-20 18:08 ` [Qemu-devel] [PATCH 2/2] iscsi: add intelligent has_zero_init check Peter Lieven

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=51C4B0C0.5020503@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=pl@kamp.de \
    --cc=qemu-devel@nongnu.org \
    --cc=ronniesahlberg@gmail.com \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).