From patchwork Thu May 20 13:10:38 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 53064 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 85611B7D29 for ; Thu, 20 May 2010 23:15:12 +1000 (EST) Received: from localhost ([127.0.0.1]:48163 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OF5af-0002Ns-6K for incoming@patchwork.ozlabs.org; Thu, 20 May 2010 09:15:09 -0400 Received: from [140.186.70.92] (port=33254 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OF5Ww-0000f2-VC for qemu-devel@nongnu.org; Thu, 20 May 2010 09:11:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OF5Wo-00071g-76 for qemu-devel@nongnu.org; Thu, 20 May 2010 09:11:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:7838) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OF5Wn-00071Z-UX for qemu-devel@nongnu.org; Thu, 20 May 2010 09:11:10 -0400 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o4KDB8R8014982 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 20 May 2010 09:11:08 -0400 Received: from localhost.localdomain (dhcp-5-217.str.redhat.com [10.32.5.217]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o4KDB1NY004450; Thu, 20 May 2010 09:11:06 -0400 From: Kevin Wolf To: anthony@codemonkey.ws Date: Thu, 20 May 2010 15:10:38 +0200 Message-Id: <1274361043-25862-4-git-send-email-kwolf@redhat.com> In-Reply-To: <1274361043-25862-1-git-send-email-kwolf@redhat.com> References: <1274361043-25862-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.21 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 3/8] virtio-blk: fix barrier support X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Christoph Hellwig Before issuing the barrier to the block driver we need to flush our oustanding queue of write requests, as the flush is supposed to be issued after them. Signed-off-by: Christoph Hellwig Signed-off-by: Kevin Wolf --- hw/virtio-blk.c | 15 +++++++++++++-- 1 files changed, 13 insertions(+), 2 deletions(-) diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c index d270225..5d7f1a2 100644 --- a/hw/virtio-blk.c +++ b/hw/virtio-blk.c @@ -240,10 +240,20 @@ static void do_multiwrite(BlockDriverState *bs, BlockRequest *blkreq, } } -static void virtio_blk_handle_flush(VirtIOBlockReq *req) +static void virtio_blk_handle_flush(BlockRequest *blkreq, int *num_writes, + VirtIOBlockReq *req, BlockDriverState **old_bs) { BlockDriverAIOCB *acb; + /* + * Make sure all outstanding writes are posted to the backing device. + */ + if (*old_bs != NULL) { + do_multiwrite(*old_bs, blkreq, *num_writes); + } + *num_writes = 0; + *old_bs = req->dev->bs; + acb = bdrv_aio_flush(req->dev->bs, virtio_blk_flush_complete, req); if (!acb) { virtio_blk_req_complete(req, VIRTIO_BLK_S_IOERR); @@ -316,7 +326,8 @@ static void virtio_blk_handle_request(VirtIOBlockReq *req, req->in = (void *)req->elem.in_sg[req->elem.in_num - 1].iov_base; if (req->out->type & VIRTIO_BLK_T_FLUSH) { - virtio_blk_handle_flush(req); + virtio_blk_handle_flush(mrb->blkreq, &mrb->num_writes, + req, &mrb->old_bs); } else if (req->out->type & VIRTIO_BLK_T_SCSI_CMD) { virtio_blk_handle_scsi(req); } else if (req->out->type & VIRTIO_BLK_T_OUT) {