All of lore.kernel.org
 help / color / mirror / Atom feed
From: Fam Zheng <famz@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 5/7] scsi-disk: add need_fua_emulation to SCSIDiskClass
Date: Tue, 24 May 2016 11:04:22 +0800	[thread overview]
Message-ID: <20160524030422.GG14601@ad.usersys.redhat.com> (raw)
In-Reply-To: <1464008051-6429-6-git-send-email-pbonzini@redhat.com>

On Mon, 05/23 14:54, Paolo Bonzini wrote:
> scsi-block will be able to do FUA just by passing the request through
> to the LUN (which is also more efficient); there is no need to emulate
> it like we do for scsi-disk.

Even for scsi-disk, shall we just use the block layer FUA fallback already by
passing BDRV_REQ_FUA in blk_aio_pwritev and simply the code in this series?

> 
> Add a new method to distinguish this.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  hw/scsi/scsi-disk.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
> index 4b5db59..f9870e9 100644
> --- a/hw/scsi/scsi-disk.c
> +++ b/hw/scsi/scsi-disk.c
> @@ -69,6 +69,7 @@ typedef struct SCSIDiskClass {
>      SCSIDeviceClass parent_class;
>      DMAIOFunc       *dma_readv;
>      DMAIOFunc       *dma_writev;
> +    bool            (*need_fua_emulation)(SCSICommand *cmd);
>  } SCSIDiskClass;
>  
>  typedef struct SCSIDiskReq {
> @@ -78,6 +79,7 @@ typedef struct SCSIDiskReq {
>      uint32_t sector_count;
>      uint32_t buflen;
>      bool started;
> +    bool need_fua_emulation;
>      struct iovec iov;
>      QEMUIOVector qiov;
>      BlockAcctCookie acct;
> @@ -239,7 +241,7 @@ static void scsi_write_do_fua(SCSIDiskReq *r)
>          goto done;
>      }
>  
> -    if (scsi_is_cmd_fua(&r->req.cmd)) {
> +    if (r->need_fua_emulation) {

Should this evaluate a call to r->need_fua_emulation() instead of the function
pointer itself?

>          block_acct_start(blk_get_stats(s->qdev.conf.blk), &r->acct, 0,
>                           BLOCK_ACCT_FLUSH);
>          r->req.aiocb = blk_aio_flush(s->qdev.conf.blk, scsi_aio_complete, r);
> @@ -416,7 +418,7 @@ static void scsi_read_data(SCSIRequest *req)
>  
>      first = !r->started;
>      r->started = true;
> -    if (first && scsi_is_cmd_fua(&r->req.cmd)) {
> +    if (first && r->need_fua_emulation) {
>          block_acct_start(blk_get_stats(s->qdev.conf.blk), &r->acct, 0,
>                           BLOCK_ACCT_FLUSH);
>          r->req.aiocb = blk_aio_flush(s->qdev.conf.blk, scsi_do_read_cb, r);
> @@ -2157,6 +2159,7 @@ static int32_t scsi_disk_dma_command(SCSIRequest *req, uint8_t *buf)
>  {
>      SCSIDiskReq *r = DO_UPCAST(SCSIDiskReq, req, req);
>      SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, req->dev);
> +    SCSIDiskClass *sdc = (SCSIDiskClass *) object_get_class(OBJECT(s));
>      uint32_t len;
>      uint8_t command;
>  
> @@ -2215,6 +2218,7 @@ static int32_t scsi_disk_dma_command(SCSIRequest *req, uint8_t *buf)
>          scsi_check_condition(r, SENSE_CODE(LBA_OUT_OF_RANGE));
>          return 0;
>      }
> +    r->need_fua_emulation = sdc->need_fua_emulation(&r->req.cmd);
>      if (r->sector_count == 0) {
>          scsi_req_complete(&r->req, GOOD);
>      }
> @@ -2704,6 +2708,7 @@ static void scsi_disk_base_class_initfn(ObjectClass *klass, void *data)
>      dc->reset = scsi_disk_reset;
>      sdc->dma_readv = scsi_dma_readv;
>      sdc->dma_writev = scsi_dma_writev;
> +    sdc->need_fua_emulation = scsi_is_cmd_fua;
>  }
>  
>  static const TypeInfo scsi_disk_base_info = {
> -- 
> 2.5.5
> 
> 
> 

  parent reply	other threads:[~2016-05-24  3:04 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-23 12:54 [Qemu-devel] [PATCH v2 0/7] dma-helpers, scsi-block: use SG_IO for all I/O on scsi-block Paolo Bonzini
2016-05-23 12:54 ` [Qemu-devel] [PATCH 1/7] dma-helpers: change interface to byte-based Paolo Bonzini
2016-05-23 15:06   ` Eric Blake
2016-05-23 12:54 ` [Qemu-devel] [PATCH 2/7] dma-helpers: change BlockBackend to opaque value in DMAIOFunc Paolo Bonzini
2016-05-23 15:43   ` Eric Blake
2016-05-24  2:47   ` Fam Zheng
2016-05-24  7:05     ` Paolo Bonzini
2016-05-23 12:54 ` [Qemu-devel] [PATCH 3/7] scsi-disk: introduce a common base class Paolo Bonzini
2016-05-23 15:53   ` Eric Blake
2016-05-23 12:54 ` [Qemu-devel] [PATCH 4/7] scsi-disk: introduce dma_readv and dma_writev Paolo Bonzini
2016-05-23 16:09   ` Eric Blake
2016-06-01 19:07   ` Mark Cave-Ayland
2016-06-03  2:56     ` xiaoqiang zhao
2016-06-03  5:22       ` Mark Cave-Ayland
2016-06-03  6:07         ` xiaoqiang zhao
2016-05-23 12:54 ` [Qemu-devel] [PATCH 5/7] scsi-disk: add need_fua_emulation to SCSIDiskClass Paolo Bonzini
2016-05-23 16:34   ` Eric Blake
2016-05-24  3:04   ` Fam Zheng [this message]
2016-05-24  7:02     ` Paolo Bonzini
2016-05-23 12:54 ` [Qemu-devel] [PATCH 6/7] scsi-disk: introduce scsi_disk_req_check_error Paolo Bonzini
2016-05-23 19:16   ` Eric Blake
2016-05-23 12:54 ` [Qemu-devel] [PATCH 7/7] scsi-block: always use SG_IO Paolo Bonzini
2016-05-23 19:49   ` Eric Blake
2016-05-23 19:36 ` [Qemu-devel] [PATCH v2 0/7] dma-helpers, scsi-block: use SG_IO for all I/O on scsi-block Mark Cave-Ayland
2016-05-24 22:59   ` Mark Cave-Ayland
2016-05-25  8:45     ` Paolo Bonzini
2016-05-25  9:13       ` Mark Cave-Ayland
2016-05-25 10:11         ` Paolo Bonzini
2016-05-25 16:38 ` [Qemu-devel] [Qemu-block] " Kevin Wolf

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=20160524030422.GG14601@ad.usersys.redhat.com \
    --to=famz@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-block@nongnu.org \
    --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 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.