All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Ronnie Sahlberg <ronniesahlberg@gmail.com>
Cc: kwolf@redhat.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 1/2] ISCSI: Set number of blocks to 0 for blank CDROM devices
Date: Sat, 18 Aug 2012 23:57:16 +0200	[thread overview]
Message-ID: <50300FBC.4010206@redhat.com> (raw)
In-Reply-To: <1345170981-7738-2-git-send-email-ronniesahlberg@gmail.com>

Il 17/08/2012 04:36, Ronnie Sahlberg ha scritto:
> The number of blocks of the device is used to compute the device size
> in bdrv_getlength()/iscsi_getlength().
> For MMC devices, the ReturnedLogicalBlockAddress in the READCAPACITY10
> has a special meaning when it is 0.
> In this case it does not mean that LBA 0 is the last accessible LBA,
> and thus the device has 1 readable block, but instead it means that the
> disc is blank and there are no readable blocks.
> 
> This change ensures that when the iSCSI LUN is loaded with a blank
> DVD-R disk or similar that bdrv_getlength() will return the correct
> size of the device as 0 bytes.
> 
> Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
> ---
>  block/iscsi.c |    7 ++++++-
>  1 files changed, 6 insertions(+), 1 deletions(-)
> 
> diff --git a/block/iscsi.c b/block/iscsi.c
> index bb9cf82..fb420ea 100644
> --- a/block/iscsi.c
> +++ b/block/iscsi.c
> @@ -717,7 +717,12 @@ iscsi_readcapacity10_cb(struct iscsi_context *iscsi, int status,
>      }
>  
>      itask->iscsilun->block_size = rc10->block_size;
> -    itask->iscsilun->num_blocks = rc10->lba + 1;
> +    if (rc10->lba == 0) {
> +        /* blank disk loaded */
> +        itask->iscsilun->num_blocks = 0;
> +    } else {
> +        itask->iscsilun->num_blocks = rc10->lba + 1;
> +    }
>      itask->bs->total_sectors    = itask->iscsilun->num_blocks *
>                                 itask->iscsilun->block_size / BDRV_SECTOR_SIZE ;
>  
> 

Thanks, applied to SCSI branch.  We'll see whether this hits 1.2.

Paolo

  reply	other threads:[~2012-08-18 21:57 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-17  2:36 [Qemu-devel] [PATCH] Two trivial patches for iSCSI and blank DVDs Ronnie Sahlberg
2012-08-17  2:36 ` [Qemu-devel] [PATCH 1/2] ISCSI: Set number of blocks to 0 for blank CDROM devices Ronnie Sahlberg
2012-08-18 21:57   ` Paolo Bonzini [this message]
2012-08-18 22:06     ` ronnie sahlberg
2012-08-17  2:36 ` [Qemu-devel] [PATCH 2/2] ISCSI: Force scsi-generic for MMC with blank disks Ronnie Sahlberg
2012-08-18 14:23   ` Blue Swirl
2012-08-18 21:58   ` Paolo Bonzini
2012-08-18 22:02     ` ronnie sahlberg
2012-08-18 22:04       ` ronnie sahlberg
2012-08-18 22:16       ` Paolo Bonzini
2012-08-18 22:19         ` ronnie sahlberg
2012-08-18 22:41           ` Paolo Bonzini
2012-08-18 22:20       ` Paolo Bonzini
2012-08-18 23:44         ` ronnie sahlberg
2012-08-19 10:16           ` Paolo Bonzini

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=50300FBC.4010206@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=ronniesahlberg@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.