qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 5/8] scsi-disk: don't call scsi_req_complete twi


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCH 5/8] scsi-disk: don't call scsi_req_complete twice.
Date: Mon, 21 Nov 2011 14:49:57 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:7.0.1) Gecko/20110930 Thunderbird/7.0.1

On 11/21/2011 02:39 PM, Gerd Hoffmann wrote:
> In case the guest sends a SYNCHRONIZE_CACHE command scsi_req_complete()
> is called twice:  Once because there is no data to transfer and
> scsi-disk thinks it is done with the command, and once when the flush is
> actually finished ...
> 
> Signed-off-by: Gerd Hoffmann<address@hidden>
> ---
>   hw/scsi-disk.c |    5 +++--
>   1 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
> index 62f538f..f3c75b3 100644
> --- a/hw/scsi-disk.c
> +++ b/hw/scsi-disk.c
> @@ -291,7 +291,7 @@ static void scsi_write_complete(void * opaque, int ret)
>           scsi_req_complete(&r->req, GOOD);
>       } else {
>           scsi_init_iovec(r);
> -        DPRINTF("Write complete tag=0x%x more=%d\n", r->req.tag, 
> r->qiov.size);
> +        DPRINTF("Write complete tag=0x%x more=%zd\n", r->req.tag, 
> r->qiov.size);
>           scsi_req_data(&r->req, r->qiov.size);
>       }
> 
> @@ -1421,7 +1421,8 @@ static int32_t scsi_send_command(SCSIRequest *req, 
> uint8_t *buf)
>           scsi_check_condition(r, SENSE_CODE(LBA_OUT_OF_RANGE));
>           return 0;
>       }
> -    if (r->sector_count == 0&&  r->iov.iov_len == 0) {
> +    if (r->sector_count == 0&&  r->iov.iov_len == 0&&
> +        command != SYNCHRONIZE_CACHE) {
>           scsi_req_complete(&r->req, GOOD);
>       }
>       len = r->sector_count * 512 + r->iov.iov_len;

/me is confused :)

    case SYNCHRONIZE_CACHE:
        /* The request is used as the AIO opaque value, so add a ref.  */
        scsi_req_ref(&r->req);
        bdrv_acct_start(s->qdev.conf.bs, &r->acct, 0, BDRV_ACCT_FLUSH);
        r->req.aiocb = bdrv_aio_flush(s->qdev.conf.bs, scsi_flush_complete, r);
        if (r->req.aiocb == NULL) {
            scsi_flush_complete(r, -EIO);
        }
        return 0;

Paolo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]