From patchwork Mon Aug 13 02:20:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 956776 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41pflt3szxz9ryt for ; Mon, 13 Aug 2018 12:28:10 +1000 (AEST) Received: from localhost ([::1]:37201 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fp2aW-0001Dz-3L for incoming@patchwork.ozlabs.org; Sun, 12 Aug 2018 22:28:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53338) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fp2TO-0003iI-II for qemu-devel@nongnu.org; Sun, 12 Aug 2018 22:20:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fp2TN-0008Iu-BE for qemu-devel@nongnu.org; Sun, 12 Aug 2018 22:20:46 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:41578 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fp2TK-0008HI-Pi; Sun, 12 Aug 2018 22:20:42 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5B8EE87A50; Mon, 13 Aug 2018 02:20:42 +0000 (UTC) Received: from localhost (ovpn-204-21.brq.redhat.com [10.40.204.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E29802156712; Mon, 13 Aug 2018 02:20:41 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 13 Aug 2018 04:20:01 +0200 Message-Id: <20180813022006.7216-13-mreitz@redhat.com> In-Reply-To: <20180813022006.7216-1-mreitz@redhat.com> References: <20180813022006.7216-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Mon, 13 Aug 2018 02:20:42 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Mon, 13 Aug 2018 02:20:42 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'mreitz@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 12/17] mirror: Put QIOV locally into mirror_co_read X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Jeff Cody , Fam Zheng , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" We only need the I/O vector for data copying operations, so we do not need to put it into the MirrorOp structure and can keep it locally in mirror_co_read(). Signed-off-by: Max Reitz --- block/mirror.c | 43 +++++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/block/mirror.c b/block/mirror.c index 66746cf075..f3df7dd984 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -95,7 +95,6 @@ struct MirrorOp { MirrorBlockJob *s; MirrorMethod mirror_method; - QEMUIOVector qiov; int64_t offset; int64_t bytes; @@ -155,7 +154,8 @@ static void coroutine_fn mirror_wait_on_conflicts(MirrorOp *self, } } -static void coroutine_fn mirror_iteration_done(MirrorOp *op, int ret) +static void coroutine_fn mirror_iteration_done(MirrorOp *op, int ret, + QEMUIOVector *qiov) { MirrorBlockJob *s = op->s; struct iovec *iov; @@ -166,11 +166,13 @@ static void coroutine_fn mirror_iteration_done(MirrorOp *op, int ret) s->in_flight--; s->bytes_in_flight -= op->bytes; - iov = op->qiov.iov; - for (i = 0; i < op->qiov.niov; i++) { - MirrorBuffer *buf = (MirrorBuffer *) iov[i].iov_base; - QSIMPLEQ_INSERT_TAIL(&s->buf_free, buf, next); - s->buf_free_count++; + if (qiov) { + iov = qiov->iov; + for (i = 0; i < qiov->niov; i++) { + MirrorBuffer *buf = (MirrorBuffer *) iov[i].iov_base; + QSIMPLEQ_INSERT_TAIL(&s->buf_free, buf, next); + s->buf_free_count++; + } } chunk_num = op->offset / s->granularity; @@ -186,13 +188,16 @@ static void coroutine_fn mirror_iteration_done(MirrorOp *op, int ret) job_progress_update(&s->common.job, op->bytes); } } - qemu_iovec_destroy(&op->qiov); + if (qiov) { + qemu_iovec_destroy(qiov); + } qemu_co_queue_restart_all(&op->waiting_requests); g_free(op); } -static void coroutine_fn mirror_write_complete(MirrorOp *op, int ret) +static void coroutine_fn mirror_write_complete(MirrorOp *op, int ret, + QEMUIOVector *qiov) { MirrorBlockJob *s = op->s; @@ -205,10 +210,11 @@ static void coroutine_fn mirror_write_complete(MirrorOp *op, int ret) s->ret = ret; } } - mirror_iteration_done(op, ret); + mirror_iteration_done(op, ret, qiov); } -static void coroutine_fn mirror_read_complete(MirrorOp *op, int ret) +static void coroutine_fn mirror_read_complete(MirrorOp *op, int ret, + QEMUIOVector *qiov) { MirrorBlockJob *s = op->s; @@ -221,11 +227,11 @@ static void coroutine_fn mirror_read_complete(MirrorOp *op, int ret) s->ret = ret; } - mirror_iteration_done(op, ret); + mirror_iteration_done(op, ret, qiov); } else { ret = blk_co_pwritev(s->target, op->offset, - op->qiov.size, &op->qiov, 0); - mirror_write_complete(op, ret); + qiov->size, qiov, 0); + mirror_write_complete(op, ret, qiov); } } @@ -350,9 +356,10 @@ static void coroutine_fn mirror_co_read(void *opaque) { MirrorOp *op = opaque; MirrorBlockJob *s = op->s; + QEMUIOVector qiov; uint64_t ret; - mirror_co_alloc_qiov(s, &op->qiov, op->offset, op->bytes); + mirror_co_alloc_qiov(s, &qiov, op->offset, op->bytes); /* Copy the dirty cluster. */ s->in_flight++; @@ -360,8 +367,8 @@ static void coroutine_fn mirror_co_read(void *opaque) trace_mirror_one_iteration(s, op->offset, op->bytes); ret = bdrv_co_preadv(s->mirror_top_bs->backing, op->offset, op->bytes, - &op->qiov, 0); - mirror_read_complete(op, ret); + &qiov, 0); + mirror_read_complete(op, ret, &qiov); } static int coroutine_fn mirror_co_zero(MirrorBlockJob *s, @@ -417,7 +424,7 @@ static void coroutine_fn mirror_co_perform(void *opaque) } } - mirror_iteration_done(op, ret); + mirror_iteration_done(op, ret, NULL); done: aio_context_release(aio_context);