From patchwork Fri Jan 30 02:49:42 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fam Zheng X-Patchwork-Id: 434715 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 552BA140082 for ; Fri, 30 Jan 2015 13:52:42 +1100 (AEDT) Received: from localhost ([::1]:34552 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YH1hI-0007nj-KW for incoming@patchwork.ozlabs.org; Thu, 29 Jan 2015 21:52:40 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41604) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YH1eo-0003S0-KM for qemu-devel@nongnu.org; Thu, 29 Jan 2015 21:50:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YH1ei-00066Z-DS for qemu-devel@nongnu.org; Thu, 29 Jan 2015 21:50:06 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60515) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YH1ei-00066S-4q for qemu-devel@nongnu.org; Thu, 29 Jan 2015 21:50:00 -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 t0U2nxpd017824 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 29 Jan 2015 21:49:59 -0500 Received: from ad.nay.redhat.com (dhcp-14-137.nay.redhat.com [10.66.14.137]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t0U2nroi025508; Thu, 29 Jan 2015 21:49:57 -0500 From: Fam Zheng To: qemu-devel@nongnu.org Date: Fri, 30 Jan 2015 10:49:42 +0800 Message-Id: <1422586186-9925-2-git-send-email-famz@redhat.com> In-Reply-To: <1422586186-9925-1-git-send-email-famz@redhat.com> References: <1422586186-9925-1-git-send-email-famz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Stefan Hajnoczi , Max Reitz Subject: [Qemu-devel] [PATCH v7 1/5] qemu-io: Account IO by aio_read and aio_write 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 This will enable accounting of aio requests issued from qemu-io aio read/write commands. Signed-off-by: Fam Zheng Reviewed-by: Max Reitz --- qemu-io-cmds.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c index e708552..29377cd 100644 --- a/qemu-io-cmds.c +++ b/qemu-io-cmds.c @@ -13,6 +13,7 @@ #include "block/qapi.h" #include "qemu/main-loop.h" #include "qemu/timer.h" +#include "sysemu/block-backend.h" #define CMD_NOFILE_OK 0x01 @@ -1337,6 +1338,7 @@ out: } struct aio_ctx { + BlockDriverState *bs; QEMUIOVector qiov; int64_t offset; char *buf; @@ -1344,6 +1346,7 @@ struct aio_ctx { int vflag; int Cflag; int Pflag; + BlockAcctCookie acct; int pattern; struct timeval t1; }; @@ -1361,6 +1364,8 @@ static void aio_write_done(void *opaque, int ret) goto out; } + block_acct_done(&ctx->bs->stats, &ctx->acct); + if (ctx->qflag) { goto out; } @@ -1398,6 +1403,8 @@ static void aio_read_done(void *opaque, int ret) g_free(cmp_buf); } + block_acct_done(&ctx->bs->stats, &ctx->acct); + if (ctx->qflag) { goto out; } @@ -1453,6 +1460,7 @@ static int aio_read_f(BlockDriverState *bs, int argc, char **argv) int nr_iov, c; struct aio_ctx *ctx = g_new0(struct aio_ctx, 1); + ctx->bs = bs; while ((c = getopt(argc, argv, "CP:qv")) != EOF) { switch (c) { case 'C': @@ -1506,6 +1514,7 @@ static int aio_read_f(BlockDriverState *bs, int argc, char **argv) } gettimeofday(&ctx->t1, NULL); + block_acct_start(&bs->stats, &ctx->acct, ctx->qiov.size, BLOCK_ACCT_READ); bdrv_aio_readv(bs, ctx->offset >> 9, &ctx->qiov, ctx->qiov.size >> 9, aio_read_done, ctx); return 0; @@ -1549,6 +1558,7 @@ static int aio_write_f(BlockDriverState *bs, int argc, char **argv) int pattern = 0xcd; struct aio_ctx *ctx = g_new0(struct aio_ctx, 1); + ctx->bs = bs; while ((c = getopt(argc, argv, "CqP:")) != EOF) { switch (c) { case 'C': @@ -1598,6 +1608,7 @@ static int aio_write_f(BlockDriverState *bs, int argc, char **argv) } gettimeofday(&ctx->t1, NULL); + block_acct_start(&bs->stats, &ctx->acct, ctx->qiov.size, BLOCK_ACCT_WRITE); bdrv_aio_writev(bs, ctx->offset >> 9, &ctx->qiov, ctx->qiov.size >> 9, aio_write_done, ctx); return 0;