From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35184) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V7RDx-0003tk-0M for qemu-devel@nongnu.org; Thu, 08 Aug 2013 10:30:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V7RDr-0004Mq-U8 for qemu-devel@nongnu.org; Thu, 08 Aug 2013 10:29:56 -0400 Received: from nodalink.pck.nerim.net ([62.212.105.220]:54886 helo=paradis.irqsave.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V7RDr-0004Mk-7v for qemu-devel@nongnu.org; Thu, 08 Aug 2013 10:29:51 -0400 From: =?UTF-8?q?Beno=C3=AEt=20Canet?= Date: Thu, 8 Aug 2013 16:29:53 +0200 Message-Id: <1375972194-3090-6-git-send-email-benoit@irqsave.net> In-Reply-To: <1375972194-3090-1-git-send-email-benoit@irqsave.net> References: <1375972194-3090-1-git-send-email-benoit@irqsave.net> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] =?utf-8?q?=5BPATCH_V4_5/5=5D_block=3A_Add_iops=5Fsec?= =?utf-8?q?tor=5Fcount_to_do_the_iops_accounting_for_a_given_io_siz?= =?utf-8?q?e=2E?= List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, pbonzini@redhat.com, =?UTF-8?q?Beno=C3=AEt=20Canet?= , stefanha@redhat.com 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 | 22 +++++++++++++++++++--- hmp.c | 8 ++++++-- qapi-schema.json | 10 ++++++++-- qemu-options.hx | 2 +- qmp-commands.hx | 8 ++++++-- 6 files changed, 43 insertions(+), 10 deletions(-) diff --git a/block/qapi.c b/block/qapi.c index 5ba10f4..f98ff64 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 =3D cfg.buckets[THROTTLE_OPS_WRITE].max; + + info->inserted->has_iops_sector_count =3D cfg.op_size; + info->inserted->iops_sector_count =3D cfg.op_size; } =20 bs0 =3D bs; diff --git a/blockdev.c b/blockdev.c index 22016a2..e2b0ee0 100644 --- a/blockdev.c +++ b/blockdev.c @@ -500,7 +500,7 @@ static DriveInfo *blockdev_init(QemuOpts *all_opts, qemu_opt_get_number(opts, "throttling.iops-write-max", 0); =20 cfg.unit_size =3D BDRV_SECTOR_SIZE; - cfg.op_size =3D 0; + cfg.op_size =3D qemu_opt_get_number(opts, "throttling.iops-sector-co= unt", 0); =20 if (!check_throttle_config(&cfg, &error)) { error_report("%s", error_get_pretty(error)); @@ -786,6 +786,9 @@ DriveInfo *drive_init(QemuOpts *all_opts, BlockInterf= aceType 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"); =20 + qemu_opt_rename(all_opts, + "iops_sector_count", "throttling.iops-sector-count")= ; + qemu_opt_rename(all_opts, "readonly", "read-only"); =20 value =3D qemu_opt_get(all_opts, "cache"); @@ -1285,7 +1288,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_sector_count, + int64_t iops_sector_count, Error **errp) { ThrottleConfig cfg; BlockDriverState *bs; @@ -1325,7 +1330,10 @@ void qmp_block_set_io_throttle(const char *device,= int64_t bps, int64_t bps_rd, } =20 cfg.unit_size =3D BDRV_SECTOR_SIZE; - cfg.op_size =3D 0; + + if (has_iops_sector_count) { + cfg.op_size =3D iops_sector_count; + } =20 if (!check_throttle_config(&cfg, errp)) { return; @@ -2051,6 +2059,10 @@ QemuOptsList qemu_common_drive_opts =3D { .type =3D QEMU_OPT_NUMBER, .help =3D "total bytes write burst", },{ + .name =3D "throttling.iops-sector-count", + .type =3D QEMU_OPT_NUMBER, + .help =3D "when limiting by iops max size of an I/O in secto= r", + },{ .name =3D "copy-on-read", .type =3D QEMU_OPT_BOOL, .help =3D "copy read data from backing file into image file"= , @@ -2197,6 +2209,10 @@ QemuOptsList qemu_old_drive_opts =3D { .type =3D QEMU_OPT_NUMBER, .help =3D "total bytes write burst", },{ + .name =3D "iops_sector_count", + .type =3D QEMU_OPT_NUMBER, + .help =3D "when limiting by iops max size of an I/O in secto= r", + },{ .name =3D "copy-on-read", .type =3D QEMU_OPT_BOOL, .help =3D "copy read data from backing file into image file"= , diff --git a/hmp.c b/hmp.c index e0c387c..01f7685 100644 --- a/hmp.c +++ b/hmp.c @@ -351,7 +351,8 @@ void hmp_info_block(Monitor *mon, const QDict *qdict) " iops_wr=3D%" PRId64 " iops_max=3D%" PRId64 " iops_rd_max=3D%" PRId64 - " iops_wr_max=3D%" PRId64 "\n", + " iops_wr_max=3D%" PRId64 + " iops_sector_count=3D%" 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_sector_count); } 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..c7b1d5e 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_sector_count: #optional an I/O size in sector (Since 1.6) +# # 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_sector_count': 'int' } } =20 ## # @BlockDeviceIoStatus: @@ -2201,6 +2204,8 @@ # # @iops_wr_max: #optional write I/O operations max (Since 1.7) # +# @iops_sector_count: #optional an I/O size in sector (Since 1.6) +# # 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_sector_count': 'int' }} =20 ## # @block-stream: diff --git a/qemu-options.hx b/qemu-options.hx index 3aa8f9e..c539dd0 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -411,7 +411,7 @@ DEF("drive", HAS_ARG, QEMU_OPTION_drive, " [,readonly=3Don|off][,copy-on-read=3Don|off]\n" " [[,bps=3Db]|[[,bps_rd=3Dr][,bps_wr=3Dw]]][[,iops=3Di]|[[,iop= s_rd=3Dr]" " [,iops_wr=3Dw][,bps_max=3Dbt]|[[,bps_rd_max=3Drt][,bps_wr_m= ax=3Dwt]]]" - " [[,iops_max=3Dit]|[[,iops_rd_max=3Drt][,iops_wr_max=3Dwt]]\n= " + " [[,iops_max=3Dit]|[[,iops_rd_max=3Drt][,iops_wr_max=3Dwt][,i= ops_sector_count=3Dcnt]]\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 1610831..bcd255f 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -1389,7 +1389,7 @@ EQMP =20 { .name =3D "block_set_io_throttle", - .args_type =3D "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_m= ax:l?,iops_wr_max:l?", + .args_type =3D "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_m= ax:l?,iops_wr_max:l?,iops_sector_count:l?", .mhandler.cmd_new =3D qmp_marshal_input_block_set_io_throttle, }, =20 @@ -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_sector_count": I/O sector count when limiting(json-int) =20 Example: =20 @@ -1429,7 +1430,8 @@ Example: "bps_wr_max": "0", "iops_max": "0", "iops_rd_max": "0", - "iops_wr_max": "0" }=C2=A0= } + "iops_wr_max": "0", + "iops_sector_count": "0" = } } <- { "return": {} } =20 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_sector_count": I/O sector count when limiting(json-int= ) - "image": the detail of the image, it is a json-object contain= ing 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_sector_count": "0", "image":{ "filename":"disks/test.qcow2", "format":"qcow2", --=20 1.7.10.4