Commit 2024c1df authored by Benoît Canet's avatar Benoît Canet Committed by Stefan Hajnoczi
Browse files

block: Add iops_size to do the iops accounting for a given io size.



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: default avatarBenoit Canet <benoit@irqsave.net>
Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
parent 3e9fab69
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -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;
+14 −3
Original line number Diff line number Diff line
@@ -507,7 +507,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));
@@ -774,6 +774,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");
@@ -1273,7 +1276,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;
@@ -1312,7 +1317,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;
@@ -2037,6 +2044,10 @@ QemuOptsList qemu_common_drive_opts = {
            .name = "throttling.bps-write-max",
            .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,
+6 −2
Original line number Diff line number Diff line
@@ -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);
}
+8 −2
Original line number Diff line number Diff line
@@ -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:
+1 −0
Original line number Diff line number Diff line
@@ -413,6 +413,7 @@ DEF("drive", HAS_ARG, QEMU_OPTION_drive,
    "       [[,iops=i]|[[,iops_rd=r][,iops_wr=w]]]\n"
    "       [[,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_size=is]]\n"
    "                use 'file' as a drive image\n", QEMU_ARCH_ALL)
STEXI
@item -drive @var{option}[,@var{option}[,@var{option}[,...]]]
Loading