qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Fam Zheng <famz@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 3/5] scsi-block: extract scsi_block_is_passthrough
Date: Tue, 29 Jul 2014 14:28:56 +0800	[thread overview]
Message-ID: <20140729062856.GA16854@T430.nay.redhat.com> (raw)
In-Reply-To: <1406560119-22362-4-git-send-email-pbonzini@redhat.com>

On Mon, 07/28 17:08, Paolo Bonzini wrote:
> This will be used for both scsi_block_new_request and the scsi-block
> implementation of parse_cdb.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  hw/scsi/scsi-disk.c | 38 ++++++++++++++++++++++++++------------
>  1 file changed, 26 insertions(+), 12 deletions(-)
> 
> diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
> index d47ecd6..81b7276 100644
> --- a/hw/scsi/scsi-disk.c
> +++ b/hw/scsi/scsi-disk.c
> @@ -2501,12 +2501,8 @@ static int scsi_block_initfn(SCSIDevice *dev)
>      return scsi_initfn(&s->qdev);
>  }
>  
> -static SCSIRequest *scsi_block_new_request(SCSIDevice *d, uint32_t tag,
> -                                           uint32_t lun, uint8_t *buf,
> -                                           void *hba_private)
> +static bool scsi_block_is_passthrough(SCSIDiskState *s, uint8_t *buf)
>  {
> -    SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, d);
> -
>      switch (buf[0]) {
>      case READ_6:
>      case READ_10:
> @@ -2523,9 +2519,9 @@ static SCSIRequest *scsi_block_new_request(SCSIDevice *d, uint32_t tag,
>      case WRITE_VERIFY_12:
>      case WRITE_VERIFY_16:
>          /* If we are not using O_DIRECT, we might read stale data from the
> -	 * host cache if writes were made using other commands than these
> -	 * ones (such as WRITE SAME or EXTENDED COPY, etc.).  So, without
> -	 * O_DIRECT everything must go through SG_IO.
> +         * host cache if writes were made using other commands than these
> +         * ones (such as WRITE SAME or EXTENDED COPY, etc.).  So, without
> +         * O_DIRECT everything must go through SG_IO.
>           */
>          if (!(bdrv_get_flags(s->qdev.conf.bs) & BDRV_O_NOCACHE)) {
>              break;
> @@ -2542,13 +2538,31 @@ static SCSIRequest *scsi_block_new_request(SCSIDevice *d, uint32_t tag,
>           * just make scsi-block operate the same as scsi-generic for them.
>           */
>          if (s->qdev.type != TYPE_ROM) {
> -            return scsi_req_alloc(&scsi_disk_dma_reqops, &s->qdev, tag, lun,
> -                                  hba_private);
> +            return false;
>          }
> +        break;
> +
> +    default:
> +        break;

Out of curiosity, why add this default branch?

Fam

>      }
>  
> -    return scsi_req_alloc(&scsi_generic_req_ops, &s->qdev, tag, lun,
> -                          hba_private);
> +    return true;
> +}
> +
> +
> +static SCSIRequest *scsi_block_new_request(SCSIDevice *d, uint32_t tag,
> +                                           uint32_t lun, uint8_t *buf,
> +                                           void *hba_private)
> +{
> +    SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, d);
> +
> +    if (scsi_block_is_passthrough(s, buf)) {
> +        return scsi_req_alloc(&scsi_generic_req_ops, &s->qdev, tag, lun,
> +                              hba_private);
> +    } else {
> +        return scsi_req_alloc(&scsi_disk_dma_reqops, &s->qdev, tag, lun,
> +                              hba_private);
> +    }
>  }
>  #endif
>  
> -- 
> 1.9.3
> 
> 
> 

  reply	other threads:[~2014-07-29  6:28 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-28 15:08 [Qemu-devel] [PATCH for-2.2 v2 0/5] scsi: enable passthrough of vendor-specific commands Paolo Bonzini
2014-07-28 15:08 ` [Qemu-devel] [PATCH 1/5] scsi-bus: prepare scsi_req_new for introduction of parse_cdb Paolo Bonzini
2014-07-28 15:08 ` [Qemu-devel] [PATCH 2/5] scsi-bus: introduce parse_cdb in SCSIDeviceClass and SCSIBusInfo Paolo Bonzini
2014-07-28 15:08 ` [Qemu-devel] [PATCH 3/5] scsi-block: extract scsi_block_is_passthrough Paolo Bonzini
2014-07-29  6:28   ` Fam Zheng [this message]
2014-07-29  7:45     ` Paolo Bonzini
2014-07-28 15:08 ` [Qemu-devel] [PATCH 4/5] scsi-block, scsi-generic: implement parse_cdb Paolo Bonzini
2014-07-28 15:08 ` [Qemu-devel] [PATCH 5/5] virtio-scsi: " Paolo Bonzini
2014-07-29  7:17 ` [Qemu-devel] [PATCH for-2.2 v2 0/5] scsi: enable passthrough of vendor-specific commands Fam Zheng
  -- strict thread matches above, loose matches on Subject: below --
2014-07-16 12:54 [Qemu-devel] [PATCH for-2.2 " Paolo Bonzini
2014-07-16 12:54 ` [Qemu-devel] [PATCH 3/5] scsi-block: extract scsi_block_is_passthrough 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=20140729062856.GA16854@T430.nay.redhat.com \
    --to=famz@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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).