From patchwork Mon Aug 26 14:42:52 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Beno=C3=AEt_Canet?= X-Patchwork-Id: 269905 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)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id E54D82C00CD for ; Tue, 27 Aug 2013 00:45:05 +1000 (EST) Received: from localhost ([::1]:51758 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VDy2R-0001hN-V9 for incoming@patchwork.ozlabs.org; Mon, 26 Aug 2013 10:45:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57304) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VDy09-0006YB-Fd for qemu-devel@nongnu.org; Mon, 26 Aug 2013 10:42:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VDy04-0003Mq-1X for qemu-devel@nongnu.org; Mon, 26 Aug 2013 10:42:41 -0400 Received: from nodalink.pck.nerim.net ([62.212.105.220]:32803 helo=paradis.irqsave.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VDy03-0003MK-F6 for qemu-devel@nongnu.org; Mon, 26 Aug 2013 10:42:35 -0400 Received: by paradis.irqsave.net (Postfix, from userid 1002) id C9B978746B1; Mon, 26 Aug 2013 16:42:34 +0200 (CEST) Received: from localhost.localdomain (unknown [192.168.77.1]) by paradis.irqsave.net (Postfix) with ESMTP id 1D5858746AF; Mon, 26 Aug 2013 16:40:54 +0200 (CEST) From: =?UTF-8?q?Beno=C3=AEt=20Canet?= To: qemu-devel@nongnu.org Date: Mon, 26 Aug 2013 16:42:52 +0200 Message-Id: <1377528172-11137-6-git-send-email-benoit@irqsave.net> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1377528172-11137-1-git-send-email-benoit@irqsave.net> References: <1377528172-11137-1-git-send-email-benoit@irqsave.net> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 62.212.105.220 Cc: kwolf@redhat.com, pbonzini@redhat.com, =?UTF-8?q?Beno=C3=AEt=20Canet?= , stefanha@redhat.com Subject: [Qemu-devel] =?utf-8?q?=5BPATCH_V6_5/5=5D_block=3A_Add_iops=5Fsiz?= =?utf-8?q?e_to_do_the_iops_accounting_for_a_given_io_size=2E?= 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 feature can be used in case where users are avoiding the iops limit by doing jumbo I/Os hammering the storage backend. Signed-off-by: Benoit Canet --- block/qapi.c | 3 +++ blockdev.c | 21 ++++++++++++++++++--- hmp.c | 8 ++++++-- qapi-schema.json | 10 ++++++++-- qemu-options.hx | 2 +- qmp-commands.hx | 8 ++++++-- 6 files changed, 42 insertions(+), 10 deletions(-) diff --git a/block/qapi.c b/block/qapi.c index 812c7ab..a2d3827 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -258,6 +258,9 @@ void bdrv_query_info(BlockDriverState *bs, cfg->buckets[THROTTLE_OPS_WRITE].max; info->inserted->iops_wr_max = cfg->buckets[THROTTLE_OPS_WRITE].max; + + info->inserted->has_iops_size = cfg->op_size; + info->inserted->iops_size = cfg->op_size; } bs0 = bs; diff --git a/blockdev.c b/blockdev.c index dc0637d..eccff63 100644 --- a/blockdev.c +++ b/blockdev.c @@ -508,7 +508,7 @@ static DriveInfo *blockdev_init(QemuOpts *all_opts, cfg.buckets[THROTTLE_OPS_WRITE].max = qemu_opt_get_number(opts, "throttling.iops-write-max", 0); - cfg.op_size = 0; + cfg.op_size = qemu_opt_get_number(opts, "throttling.iops-size", 0); if (!check_throttle_config(&cfg, &error)) { error_report("%s", error_get_pretty(error)); @@ -795,6 +795,9 @@ DriveInfo *drive_init(QemuOpts *all_opts, BlockInterfaceType block_default_type) qemu_opt_rename(all_opts, "bps_rd_max", "throttling.bps-read-max"); qemu_opt_rename(all_opts, "bps_wr_max", "throttling.bps-write-max"); + qemu_opt_rename(all_opts, + "iops_size", "throttling.iops-size"); + qemu_opt_rename(all_opts, "readonly", "read-only"); value = qemu_opt_get(all_opts, "cache"); @@ -1294,7 +1297,9 @@ void qmp_block_set_io_throttle(const char *device, int64_t bps, int64_t bps_rd, bool has_iops_rd_max, int64_t iops_rd_max, bool has_iops_wr_max, - int64_t iops_wr_max, Error **errp) + int64_t iops_wr_max, + bool has_iops_size, + int64_t iops_size, Error **errp) { ThrottleConfig cfg; BlockDriverState *bs; @@ -1333,7 +1338,9 @@ void qmp_block_set_io_throttle(const char *device, int64_t bps, int64_t bps_rd, cfg.buckets[THROTTLE_OPS_WRITE].max = iops_wr_max; } - cfg.op_size = 0; + if (has_iops_size) { + cfg.op_size = iops_size; + } if (!check_throttle_config(&cfg, errp)) { return; @@ -2059,6 +2066,10 @@ QemuOptsList qemu_common_drive_opts = { .type = QEMU_OPT_NUMBER, .help = "total bytes write burst", },{ + .name = "throttling.iops-size", + .type = QEMU_OPT_NUMBER, + .help = "when limiting by iops max size of an I/O in bytes", + },{ .name = "copy-on-read", .type = QEMU_OPT_BOOL, .help = "copy read data from backing file into image file", @@ -2205,6 +2216,10 @@ QemuOptsList qemu_old_drive_opts = { .type = QEMU_OPT_NUMBER, .help = "total bytes write burst", },{ + .name = "iops_size", + .type = QEMU_OPT_NUMBER, + .help = "when limiting by iops max size of an I/O in bytes", + },{ .name = "copy-on-read", .type = QEMU_OPT_BOOL, .help = "copy read data from backing file into image file", diff --git a/hmp.c b/hmp.c index 85a6c16..2bd31d1 100644 --- a/hmp.c +++ b/hmp.c @@ -351,7 +351,8 @@ void hmp_info_block(Monitor *mon, const QDict *qdict) " iops_wr=%" PRId64 " iops_max=%" PRId64 " iops_rd_max=%" PRId64 - " iops_wr_max=%" PRId64 "\n", + " iops_wr_max=%" PRId64 + " iops_size=%" PRId64 "\n", info->value->inserted->bps, info->value->inserted->bps_rd, info->value->inserted->bps_wr, @@ -363,7 +364,8 @@ void hmp_info_block(Monitor *mon, const QDict *qdict) info->value->inserted->iops_wr, info->value->inserted->iops_max, info->value->inserted->iops_rd_max, - info->value->inserted->iops_wr_max); + info->value->inserted->iops_wr_max, + info->value->inserted->iops_size); } else { monitor_printf(mon, " [not inserted]"); } @@ -1124,6 +1126,8 @@ void hmp_block_set_io_throttle(Monitor *mon, const QDict *qdict) false, 0, false, + 0, + false, /* No default I/O size */ 0, &err); hmp_handle_error(mon, &err); } diff --git a/qapi-schema.json b/qapi-schema.json index 5e5461e..cd4effa 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -797,6 +797,8 @@ # # @iops_wr_max: #optional write I/O operations max (Since 1.7) # +# @iops_size: #optional an I/O size in bytes (Since 1.7) +# # Since: 0.14.0 # # Notes: This interface is only found in @BlockInfo. @@ -810,7 +812,8 @@ 'image': 'ImageInfo', '*bps_max': 'int', '*bps_rd_max': 'int', '*bps_wr_max': 'int', '*iops_max': 'int', - '*iops_rd_max': 'int', '*iops_wr_max': 'int' }} + '*iops_rd_max': 'int', '*iops_wr_max': 'int', + '*iops_size': 'int' } } ## # @BlockDeviceIoStatus: @@ -2201,6 +2204,8 @@ # # @iops_wr_max: #optional write I/O operations max (Since 1.7) # +# @iops_size: #optional an I/O size in bytes (Since 1.7) +# # Returns: Nothing on success # If @device is not a valid block device, DeviceNotFound # @@ -2211,7 +2216,8 @@ 'iops': 'int', 'iops_rd': 'int', 'iops_wr': 'int', '*bps_max': 'int', '*bps_rd_max': 'int', '*bps_wr_max': 'int', '*iops_max': 'int', - '*iops_rd_max': 'int', '*iops_wr_max': 'int' }} + '*iops_rd_max': 'int', '*iops_wr_max': 'int', + '*iops_size': 'int' }} ## # @block-stream: diff --git a/qemu-options.hx b/qemu-options.hx index 8df7f1f..05495d6 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -411,7 +411,7 @@ DEF("drive", HAS_ARG, QEMU_OPTION_drive, " [,readonly=on|off][,copy-on-read=on|off]\n" " [[,bps=b]|[[,bps_rd=r][,bps_wr=w]]][[,iops=i]|[[,iops_rd=r]\n" " [,iops_wr=w][,bps_max=bm]|[[,bps_rd_max=rm][,bps_wr_max=wm]]]\n" - " [[,iops_max=im]|[[,iops_rd_max=irm][,iops_wr_max=iwm]]\n" + " [[,iops_max=im]|[[,iops_rd_max=irm][,iops_wr_max=iwm][,iops_size=is]]\n" " use 'file' as a drive image\n", QEMU_ARCH_ALL) STEXI @item -drive @var{option}[,@var{option}[,@var{option}[,...]]] diff --git a/qmp-commands.hx b/qmp-commands.hx index 08b2fb6..ff81f2b 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -1389,7 +1389,7 @@ EQMP { .name = "block_set_io_throttle", - .args_type = "device:B,bps:l,bps_rd:l,bps_wr:l,iops:l,iops_rd:l,iops_wr:l,bps_max:l?,bps_rd_max:l?,bps_wr_max:l?,iops_max:l?,iops_rd_max:l?,iops_wr_max:l?", + .args_type = "device:B,bps:l,bps_rd:l,bps_wr:l,iops:l,iops_rd:l,iops_wr:l,bps_max:l?,bps_rd_max:l?,bps_wr_max:l?,iops_max:l?,iops_rd_max:l?,iops_wr_max:l?,iops_size:l?", .mhandler.cmd_new = qmp_marshal_input_block_set_io_throttle, }, @@ -1414,6 +1414,7 @@ Arguments: - "iops_max": total I/O operations max(json-int) - "iops_rd_max": read I/O operations max(json-int) - "iops_wr_max": write I/O operations max(json-int) +- "iops_size": I/O size in bytes when limiting(json-int) Example: @@ -1429,7 +1430,8 @@ Example: "bps_wr_max": "0", "iops_max": "0", "iops_rd_max": "0", - "iops_wr_max": "0" } } + "iops_wr_max": "0", + "iops_size": "0" } } <- { "return": {} } EQMP @@ -1776,6 +1778,7 @@ Each json-object contain the following: - "iops_max": total I/O operations max (json-int) - "iops_rd_max": read I/O operations max (json-int) - "iops_wr_max": write I/O operations max (json-int) + - "iops_size": I/O size when limiting by iops (json-int) - "image": the detail of the image, it is a json-object containing the following: - "filename": image file name (json-string) @@ -1851,6 +1854,7 @@ Example: "iops_max": "0", "iops_rd_max": "0", "iops_wr_max": "0", + "iops_size": "0", "image":{ "filename":"disks/test.qcow2", "format":"qcow2",