From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:48340) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RSUGE-00085L-5R for qemu-devel@nongnu.org; Mon, 21 Nov 2011 08:50:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RSUG1-0002IA-T1 for qemu-devel@nongnu.org; Mon, 21 Nov 2011 08:50:14 -0500 Received: from mx1.redhat.com ([209.132.183.28]:53124) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RSUG1-0002Hm-Cw for qemu-devel@nongnu.org; Mon, 21 Nov 2011 08:50:01 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id pALDo094000337 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 21 Nov 2011 08:50:00 -0500 Message-ID: <4ECA5705.4080105@redhat.com> Date: Mon, 21 Nov 2011 14:49:57 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <1321882802-3337-1-git-send-email-kraxel@redhat.com> <1321882802-3337-6-git-send-email-kraxel@redhat.com> In-Reply-To: <1321882802-3337-6-git-send-email-kraxel@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 5/8] scsi-disk: don't call scsi_req_complete twice. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gerd Hoffmann Cc: qemu-devel@nongnu.org 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 > --- > 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