From patchwork Mon Oct 20 14:35:19 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Lieven X-Patchwork-Id: 401179 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 C5D0114003E for ; Tue, 21 Oct 2014 01:44:23 +1100 (AEDT) Received: from localhost ([::1]:45239 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XgEC5-00035g-LL for incoming@patchwork.ozlabs.org; Mon, 20 Oct 2014 10:44:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47147) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XgE4Z-0002Wz-MG for qemu-devel@nongnu.org; Mon, 20 Oct 2014 10:36:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XgE4O-0005zn-U0 for qemu-devel@nongnu.org; Mon, 20 Oct 2014 10:36:35 -0400 Received: from mx-v6.kamp.de ([2a02:248:0:51::16]:52643 helo=mx01.kamp.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XgE4O-0005zE-JX for qemu-devel@nongnu.org; Mon, 20 Oct 2014 10:36:24 -0400 Received: (qmail 32395 invoked by uid 89); 20 Oct 2014 14:36:23 -0000 Received: from [82.141.1.145] by client-16-kamp (envelope-from , uid 89) with qmail-scanner-2010/03/19-MF (clamdscan: 0.98.4/19522. hbedv: 8.3.24.38/7.11.179.192. spamassassin: 3.4.0. Clear:RC:1(82.141.1.145):SA:0(-1.2/5.0):. Processed in 1.47779 secs); 20 Oct 2014 14:36:23 -0000 Received: from ns.kamp-intra.net (HELO dns.kamp-intra.net) ([82.141.1.145]) by mx01.kamp.de with SMTP; 20 Oct 2014 14:36:21 -0000 X-GL_Whitelist: yes Received: from lieven-pc.kamp-intra.net (lieven-pc.kamp-intra.net [172.21.12.60]) by dns.kamp-intra.net (Postfix) with ESMTP id DDF28206A6; Mon, 20 Oct 2014 16:35:20 +0200 (CEST) Received: by lieven-pc.kamp-intra.net (Postfix, from userid 1000) id D6F40619D7; Mon, 20 Oct 2014 16:35:20 +0200 (CEST) From: Peter Lieven To: qemu-devel@nongnu.org Date: Mon, 20 Oct 2014 16:35:19 +0200 Message-Id: <1413815720-29976-4-git-send-email-pl@kamp.de> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1413815720-29976-1-git-send-email-pl@kamp.de> References: <1413815720-29976-1-git-send-email-pl@kamp.de> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a02:248:0:51::16 Cc: kwolf@redhat.com, famz@redhat.com, benoit@irqsave.net, jcody@redhat.com, Peter Lieven , mreitz@redhat.com, stefanha@redhat.com Subject: [Qemu-devel] [PATCH 3/4] block: add a knob to disable multiwrite_merge 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 the block layer silently merges write requests since commit 40b4f539. This patch adds a knob to disable this feature as there has been some discussion lately if multiwrite is a good idea at all and as it falsifies benchmarks. Signed-off-by: Peter Lieven Reviewed-by: Max Reitz --- block.c | 9 +++++++++ block/qapi.c | 1 + hmp.c | 4 ++++ include/block/block_int.h | 1 + qapi/block-core.json | 10 +++++++++- qemu-options.hx | 1 + qmp-commands.hx | 2 ++ 7 files changed, 27 insertions(+), 1 deletion(-) diff --git a/block.c b/block.c index 3b4a59a..ffb2b47 100644 --- a/block.c +++ b/block.c @@ -884,6 +884,10 @@ static QemuOptsList bdrv_runtime_opts = { .name = "node-name", .type = QEMU_OPT_STRING, .help = "Node name of the block device node", + },{ + .name = "write-merging", + .type = QEMU_OPT_BOOL, + .help = "enable write merging (default: true)", }, { /* end of list */ } }, @@ -985,6 +989,7 @@ static int bdrv_open_common(BlockDriverState *bs, BlockDriverState *file, bs->drv = drv; bs->opaque = g_malloc0(drv->instance_size); bs->enable_write_cache = !!(flags & BDRV_O_CACHE_WB); + bs->write_merging = qemu_opt_get_bool(opts, "write-merging", true); /* Open the image, either directly or using a protocol */ if (drv->bdrv_file_open) { @@ -4439,6 +4444,10 @@ static int multiwrite_merge(BlockDriverState *bs, BlockRequest *reqs, { int i, outidx; + if (!bs->write_merging) { + return num_reqs; + } + // Sort requests by start sector qsort(reqs, num_reqs, sizeof(*reqs), &multiwrite_req_compare); diff --git a/block/qapi.c b/block/qapi.c index a0f26e9..5f09967 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -59,6 +59,7 @@ BlockDeviceInfo *bdrv_block_device_info(BlockDriverState *bs) info->backing_file_depth = bdrv_get_backing_file_depth(bs); info->detect_zeroes = bs->detect_zeroes; + info->write_merging = bs->write_merging; if (bs->io_limits_enabled) { ThrottleConfig cfg; diff --git a/hmp.c b/hmp.c index baaa9e5..5762444 100644 --- a/hmp.c +++ b/hmp.c @@ -348,6 +348,10 @@ void hmp_info_block(Monitor *mon, const QDict *qdict) BlockdevDetectZeroesOptions_lookup[info->value->inserted->detect_zeroes]); } + if (!info->value->inserted->write_merging) { + monitor_printf(mon, " Write Merging: off\n"); + } + if (info->value->inserted->bps || info->value->inserted->bps_rd || info->value->inserted->bps_wr diff --git a/include/block/block_int.h b/include/block/block_int.h index 8898c6c..e3d382f 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -402,6 +402,7 @@ struct BlockDriverState { QDict *options; BlockdevDetectZeroesOptions detect_zeroes; + bool write_merging; /* The error object in use for blocking operations on backing_hd */ Error *backing_blocker; diff --git a/qapi/block-core.json b/qapi/block-core.json index 952d50e..9ac9085 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -214,6 +214,8 @@ # # @detect_zeroes: detect and optimize zero writes (Since 2.1) # +# @write_merging: true if write merging is enabled (Since 2.2) +# # @bps: total throughput limit in bytes per second is specified # # @bps_rd: read throughput limit in bytes per second is specified @@ -250,6 +252,7 @@ '*backing_file': 'str', 'backing_file_depth': 'int', 'encrypted': 'bool', 'encryption_key_missing': 'bool', 'detect_zeroes': 'BlockdevDetectZeroesOptions', + 'write_merging': 'bool', 'bps': 'int', 'bps_rd': 'int', 'bps_wr': 'int', 'iops': 'int', 'iops_rd': 'int', 'iops_wr': 'int', 'image': 'ImageInfo', @@ -1187,6 +1190,10 @@ # (default: false) # @detect-zeroes: #optional detect and optimize zero writes (Since 2.1) # (default: off) +# @write-merging: #optional enable the merging of write requests +# also known as multiwrite_merge (Since 2.2) +# (default: true, but this might change in the future +# depending on format/protocol/features used) # # Since: 1.7 ## @@ -1200,7 +1207,8 @@ '*rerror': 'BlockdevOnError', '*werror': 'BlockdevOnError', '*read-only': 'bool', - '*detect-zeroes': 'BlockdevDetectZeroesOptions' } } + '*detect-zeroes': 'BlockdevDetectZeroesOptions', + '*write-merging': 'bool' } } ## # @BlockdevOptionsFile diff --git a/qemu-options.hx b/qemu-options.hx index 22cf3b9..d2f756f 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -432,6 +432,7 @@ DEF("drive", HAS_ARG, QEMU_OPTION_drive, " [,werror=ignore|stop|report|enospc][,id=name][,aio=threads|native]\n" " [,readonly=on|off][,copy-on-read=on|off]\n" " [,discard=ignore|unmap][,detect-zeroes=on|off|unmap]\n" + " [,write-merging=on|off]\n" " [[,bps=b]|[[,bps_rd=r][,bps_wr=w]]]\n" " [[,iops=i]|[[,iops_rd=r][,iops_wr=w]]]\n" " [[,bps_max=bm]|[[,bps_rd_max=rm][,bps_wr_max=wm]]]\n" diff --git a/qmp-commands.hx b/qmp-commands.hx index 1abd619..2c20207 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -2104,6 +2104,7 @@ Each json-object contain the following: - "iops_size": I/O size when limiting by iops (json-int) - "detect_zeroes": detect and optimize zero writing (json-string) - Possible values: "off", "on", "unmap" + - "write_merging": enable merging of write requests (json-bool) - "image": the detail of the image, it is a json-object containing the following: - "filename": image file name (json-string) @@ -2181,6 +2182,7 @@ Example: "iops_wr_max": 0, "iops_size": 0, "detect_zeroes": "on", + "write_merging": "true", "image":{ "filename":"disks/test.qcow2", "format":"qcow2",