From patchwork Wed Jul 18 15:07:49 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 171714 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 680432C0371 for ; Thu, 19 Jul 2012 01:12:07 +1000 (EST) Received: from localhost ([::1]:46128 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SrVv3-00046S-Dt for incoming@patchwork.ozlabs.org; Wed, 18 Jul 2012 11:12:05 -0400 Received: from eggs.gnu.org ([208.118.235.92]:53412) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SrVsW-0007GH-Um for qemu-devel@nongnu.org; Wed, 18 Jul 2012 11:09:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SrVsR-0000yK-3t for qemu-devel@nongnu.org; Wed, 18 Jul 2012 11:09:28 -0400 Received: from e06smtp18.uk.ibm.com ([195.75.94.114]:41478) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SrVsQ-0000yG-QA for qemu-devel@nongnu.org; Wed, 18 Jul 2012 11:09:23 -0400 Received: from /spool/local by e06smtp18.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 18 Jul 2012 16:09:22 +0100 Received: from d06nrmr1507.portsmouth.uk.ibm.com (9.149.38.233) by e06smtp18.uk.ibm.com (192.168.101.148) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 18 Jul 2012 16:08:44 +0100 Received: from d06av01.portsmouth.uk.ibm.com (d06av01.portsmouth.uk.ibm.com [9.149.37.212]) by d06nrmr1507.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q6IF8ihB2453534 for ; Wed, 18 Jul 2012 16:08:44 +0100 Received: from d06av01.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av01.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q6IF8gIV015640 for ; Wed, 18 Jul 2012 09:08:43 -0600 Received: from localhost (sig-9-145-185-169.de.ibm.com [9.145.185.169]) by d06av01.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q6IF8gfX015619; Wed, 18 Jul 2012 09:08:42 -0600 From: Stefan Hajnoczi To: Date: Wed, 18 Jul 2012 16:07:49 +0100 Message-Id: <1342624074-24650-23-git-send-email-stefanha@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1342624074-24650-1-git-send-email-stefanha@linux.vnet.ibm.com> References: <1342624074-24650-1-git-send-email-stefanha@linux.vnet.ibm.com> x-cbid: 12071815-6892-0000-0000-000002788E5A X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 195.75.94.114 Cc: Kevin Wolf , Anthony Liguori , Stefan Hajnoczi , kvm@vger.kernel.org, "Michael S. Tsirkin" , Khoa Huynh , Paolo Bonzini , Asias He Subject: [Qemu-devel] [RFC v9 22/27] virtio-blk: Fix request merging X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Khoa Huynh discovered that request merging is broken. The merged iocb is not updated to reflect the total number of iovecs and the offset is also outdated. This patch fixes request merging. Signed-off-by: Stefan Hajnoczi --- hw/virtio-blk.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c index 9131a7a..51807b5 100644 --- a/hw/virtio-blk.c +++ b/hw/virtio-blk.c @@ -178,13 +178,17 @@ static void merge_request(struct iocb *iocb_a, struct iocb *iocb_b) req_a->len = iocb_nbytes(iocb_a); } - iocb_b->u.v.vec = iovec; - req_b->len = iocb_nbytes(iocb_b); - req_b->next_merged = req_a; /* fprintf(stderr, "merged %p (%u) and %p (%u), %u iovecs in total\n", req_a, iocb_a->u.v.nr, req_b, iocb_b->u.v.nr, iocb_a->u.v.nr + iocb_b->u.v.nr); */ + + iocb_b->u.v.vec = iovec; + iocb_b->u.v.nr += iocb_a->u.v.nr; + iocb_b->u.v.offset = iocb_a->u.v.offset; + + req_b->len = iocb_nbytes(iocb_b); + req_b->next_merged = req_a; } static void process_request(IOQueue *ioq, struct iovec iov[], unsigned int out_num, unsigned int in_num, unsigned int head)