From patchwork Mon Jan 14 11:18:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Nefedov X-Patchwork-Id: 10762259 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5D7966C2 for ; Mon, 14 Jan 2019 11:32:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4D5CE21BED for ; Mon, 14 Jan 2019 11:32:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 416E028AE7; Mon, 14 Jan 2019 11:32:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id AB95921BED for ; Mon, 14 Jan 2019 11:32:56 +0000 (UTC) Received: from localhost ([127.0.0.1]:51811 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gj0UB-0003B5-Ns for patchwork-qemu-devel@patchwork.kernel.org; Mon, 14 Jan 2019 06:32:55 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37282) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gj0GW-0000Q3-Kc for qemu-devel@nongnu.org; Mon, 14 Jan 2019 06:18:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gj0GS-0000vk-G2 for qemu-devel@nongnu.org; Mon, 14 Jan 2019 06:18:46 -0500 Received: from mail-eopbgr130115.outbound.protection.outlook.com ([40.107.13.115]:51232 helo=EUR01-HE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gj0GP-0000hM-Ol; Mon, 14 Jan 2019 06:18:42 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sgLh1XWovi23oJvrB7zVpLelGD0Ihi4DOl5kBcvKFzo=; b=hsjVPwKwMXv+f/uYiMfWyX29fMShMjUIhFMDT3FmvbyF/wrQJak6dJgerzkxzuithwF/S2Vz773A9qpFhTVZc4RMyiy6Q9fMIy+1RPlFDfO/PSUdyTH39GCSRYqjiu0PZewGosOxcr4Ox4YrwBHe4SDwo6bn7etlWQ7vGnpr82s= Received: from AM0PR08MB4292.eurprd08.prod.outlook.com (20.179.33.17) by AM0PR08MB2977.eurprd08.prod.outlook.com (52.134.92.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1516.14; Mon, 14 Jan 2019 11:18:22 +0000 Received: from AM0PR08MB4292.eurprd08.prod.outlook.com ([fe80::d13a:1305:bb54:1916]) by AM0PR08MB4292.eurprd08.prod.outlook.com ([fe80::d13a:1305:bb54:1916%6]) with mapi id 15.20.1516.019; Mon, 14 Jan 2019 11:18:22 +0000 From: Anton Nefedov To: "qemu-devel@nongnu.org" Thread-Topic: [PATCH v12 00/10] qcow2: cluster space preallocation Thread-Index: AQHUq/rb+6JbY3AdSEmC6LWsNlYWlg== Date: Mon, 14 Jan 2019 11:18:22 +0000 Message-ID: <20190114111744.113188-1-anton.nefedov@virtuozzo.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HE1PR0701CA0065.eurprd07.prod.outlook.com (2603:10a6:3:9e::33) To AM0PR08MB4292.eurprd08.prod.outlook.com (2603:10a6:208:13b::17) x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.17.1 x-originating-ip: [185.231.240.5] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; AM0PR08MB2977; 20:2EhFTtVgLyxfnC1NnZ8AlAJ6nZkbHuIf3OZXT26HHtoLdAbP1uQqsi6pAfRUBqBbI3jTKcCfpzm0bYSJne+N8Matf2nBgtV8xKvgmRCBK/SmY3S17dgnNTkhHHh4ysZc/z6kckXPu4rzCWTsqLY7gfTpGZcDpcR3x3ce2aejDYA= x-ms-office365-filtering-correlation-id: be5be3cf-f31d-45ef-bf30-08d67a11fe38 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600109)(711020)(2017052603328)(7153060)(7193020); SRVR:AM0PR08MB2977; x-ms-traffictypediagnostic: AM0PR08MB2977: x-microsoft-antispam-prvs: x-forefront-prvs: 0917DFAC67 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(39840400004)(396003)(136003)(366004)(346002)(376002)(199004)(189003)(6346003)(256004)(14454004)(5640700003)(6486002)(6916009)(8936002)(1076003)(36756003)(14444005)(97736004)(53936002)(305945005)(476003)(107886003)(478600001)(186003)(2906002)(486006)(6116002)(50226002)(3846002)(26005)(2501003)(2616005)(99286004)(8676002)(66066001)(4326008)(5660300001)(52116002)(71200400001)(81156014)(25786009)(81166006)(71190400001)(966005)(2351001)(7736002)(316002)(105586002)(106356001)(68736007)(102836004)(44832011)(6436002)(6306002)(54906003)(6512007)(86362001)(6506007)(386003); DIR:OUT; SFP:1102; SCL:1; SRVR:AM0PR08MB2977; H:AM0PR08MB4292.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: virtuozzo.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=anton.nefedov@virtuozzo.com; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: wtMeWuuI0Bhd+4rjsmzrBRkbPMTwuW8wyjF+j0cDwWxlPq2vuhl0HCMuzeaA2tiOU9iyfT92C4v/E7B2Gw4WIrxKYFMyiN1BpnFOZKayw0AS4zTmKgjTtqvstEW+rKuWM+dUKlBXYR/xjN+fI2ZifDYH34V0gN6PqXGoBzj0YEoJlCbL+CLi5EvUBpRme/YKl2ZXKUj9ySCDIXTyM1sk15aahYTjzcjKem+PGFdeOY0XB3jsksJsz7pa41sO+vE+fGta/veESzECwLLcpJc5EnjqrtmcPnMyjwuxq3fVe3wikbtNFacKXQjKeOJceMu7l8aNASCjy+y/NJvld10SsdALhm7GIocUDhxeu/2AyBEhorsxhT8JNbwdGwnDxJ9oHnMnTFlgb5HVeHbuGVlk2Sc7P5xmWjuFW0/QVQ1tCkw= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: be5be3cf-f31d-45ef-bf30-08d67a11fe38 X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Jan 2019 11:18:21.1824 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB2977 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.13.115 Subject: [Qemu-devel] [PATCH v12 00/10] qcow2: cluster space preallocation X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "kwolf@redhat.com" , Vladimir Sementsov-Ogievskiy , "berto@igalia.com" , Denis Lunev , "qemu-block@nongnu.org" , "mreitz@redhat.com" , Anton Nefedov Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP new in v12: - patch 9: pre-write overlap check added v11: http://lists.nongnu.org/archive/html/qemu-devel/2018-12/msg04342.html - patch 4, 9: fixed commentary format - patch 4: removed one hunk with a dead check - patch 5: added commentary to BDRV_REQ_ALLOCATE definition - new auxiliary patch 6 for the following patch-7 change: - patch 7: reset BDRV_REQ_ALLOCATE from supported flag if CONFIG_FALLOCATE is false - patch 9: add commentary about missing qcow2_pre_write_overlap_check(). Omit redundant changes in the test 060. v10: http://lists.nongnu.org/archive/html/qemu-devel/2018-12/msg00121.html - patches 1-3,6,7: rebase after REQ_WRITE_UNCHANGED - patch 3: drop supported_zero_flags. My bad, no write_zeroes in quorum. - patch 4: almost trivial rebase. RB-tags not stripped. Choose another constant for BDRV_REQ_ALLOCATE - patch 5: rebase. Instead of marking REQ_ALLOCATE serialising, accompany it with REQ_SERIALISING. - patch 7: add symmetric copy-on-read change - patch 8: trivial rebase. RB-tags not stripped. ---- This pull request is to start to improve a few performance points of qcow2 format: 1. non cluster-aligned write requests (to unallocated clusters) explicitly pad data with zeroes if there is no backing data. Resulting increase in ops number and potential cluster fragmentation (on the host file) is already solved by: ee22a9d qcow2: Merge the writing of the COW regions with the guest data However, in case of zero COW regions, that can be avoided at all but the whole clusters are preallocated and zeroed in a single efficient write_zeroes() operation 2. moreover, efficient write_zeroes() operation can be used to preallocate space megabytes (*configurable number) ahead which gives noticeable improvement on some storage types (e.g. distributed storage) where the space allocation operation might be expensive) (Not included in this patchset since v6). 3. this will also allow to enable simultaneous writes to the same unallocated cluster after the space has been allocated & zeroed but before the first data is written and the cluster is linked to L2. (Not included in this patchset). Efficient write_zeroes usually implies that the blocks are not actually written to but only reserved and marked as zeroed by the storage. In this patchset, file-posix driver is marked as supporting this operation if it supports (/configured to support) fallocate() operation. Existing bdrv_write_zeroes() falls back to writing zero buffers if write_zeroes is not supported by the driver. A new flag (BDRV_REQ_ALLOCATE) is introduced to avoid that but return ENOTSUP. Such allocate requests are also implemented to possibly overlap with the other requests. No wait is performed but an error returned in such case as well. So the operation should be considered advisory and a fallback scenario still handled by the caller (in this case, qcow2 driver). simple perf test: qemu-img create -f qcow2 test.img 4G && \ qemu-img bench -c $((1024*1024)) -f qcow2 -n -s 4k -t none -w test.img test results (seconds): +-----------+-------+------+-------+------+------+ | file | before | after | gain | +-----------+-------+------+-------+------+------+ | ssd | 61.153 | 36.313 | 41% | | hdd | 112.676 | 122.056 | -8% | +-----------+--------------+--------------+------+ Anton Nefedov (10): mirror: inherit supported write/zero flags blkverify: set supported write/zero flags quorum: set supported write flags block: introduce BDRV_REQ_ALLOCATE flag block: treat BDRV_REQ_ALLOCATE as serialising file-posix: reset fallocate-related flags without CONFIG_FALLOCATE* file-posix: support BDRV_REQ_ALLOCATE block: support BDRV_REQ_ALLOCATE in passthrough drivers qcow2: skip writing zero buffers to empty COW areas iotest 134: test cluster-misaligned encrypted write qapi/block-core.json | 4 +- block/qcow2.h | 6 +++ include/block/block.h | 13 +++++- include/block/block_int.h | 3 +- block/blkdebug.c | 2 +- block/blkverify.c | 10 ++++- block/copy-on-read.c | 4 +- block/file-posix.c | 16 +++++-- block/io.c | 45 +++++++++++++++---- block/mirror.c | 8 +++- block/qcow2-cluster.c | 2 +- block/qcow2.c | 91 +++++++++++++++++++++++++++++++++++++- block/quorum.c | 19 +++++++- block/raw-format.c | 2 +- block/trace-events | 1 + tests/qemu-iotests/060 | 7 ++- tests/qemu-iotests/060.out | 5 ++- tests/qemu-iotests/134 | 9 ++++ tests/qemu-iotests/134.out | 10 +++++ 19 files changed, 229 insertions(+), 28 deletions(-)