From patchwork Mon Dec 3 10:14:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Nefedov X-Patchwork-Id: 10709135 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 3B0D61731 for ; Mon, 3 Dec 2018 10:19:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2B6352AFED for ; Mon, 3 Dec 2018 10:19:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1FD5A2AFF2; Mon, 3 Dec 2018 10:19:53 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 705B52AFF1 for ; Mon, 3 Dec 2018 10:19:52 +0000 (UTC) Received: from localhost ([::1]:47772 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gTlKR-0005qg-5i for patchwork-qemu-devel@patchwork.kernel.org; Mon, 03 Dec 2018 05:19:51 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39178) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gTlFq-0002H6-0y for qemu-devel@nongnu.org; Mon, 03 Dec 2018 05:15:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gTlFk-0004sQ-7c for qemu-devel@nongnu.org; Mon, 03 Dec 2018 05:15:05 -0500 Received: from mail-eopbgr60112.outbound.protection.outlook.com ([40.107.6.112]:44323 helo=EUR04-DB3-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 1gTlFh-0004nY-2i; Mon, 03 Dec 2018 05:14:58 -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=z70tMG6mxHL0LhbYKT5CtLtLH46fY63MnnshcICEAE8=; b=bI6Rs4LZUY0Wi5lAIHKJy2AqFLmFsPp/4RlcpELwserzbIyULMm66KiR1/GbH4SkMmIHnBZHVbQxWNAATVbmsEWPxAyuW9FB8bEkNj/9OavwfDuFZfYHLqzUaMAJprOF3hFu4DlRg47S2Bt1RVdZDcdm5uCyFLNsMTJ2LNyT9tI= Received: from AM0PR08MB3347.eurprd08.prod.outlook.com (52.134.94.148) by AM0PR08MB3922.eurprd08.prod.outlook.com (20.178.118.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1382.18; Mon, 3 Dec 2018 10:14:52 +0000 Received: from AM0PR08MB3347.eurprd08.prod.outlook.com ([fe80::a0bd:dda4:d9e4:1d01]) by AM0PR08MB3347.eurprd08.prod.outlook.com ([fe80::a0bd:dda4:d9e4:1d01%2]) with mapi id 15.20.1382.020; Mon, 3 Dec 2018 10:14:52 +0000 From: Anton Nefedov To: "qemu-devel@nongnu.org" Thread-Topic: [PATCH v10 0/9] qcow2: cluster space preallocation Thread-Index: AQHUivEHrKYLv0PWa0WJmnR+nphTxw== Date: Mon, 3 Dec 2018 10:14:52 +0000 Message-ID: <20181203101429.88735-1-anton.nefedov@virtuozzo.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HE1PR0301CA0004.eurprd03.prod.outlook.com (2603:10a6:3:76::14) To AM0PR08MB3347.eurprd08.prod.outlook.com (2603:10a6:208:5f::20) x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [185.231.240.5] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; AM0PR08MB3922; 20:25gyzHk9g4c2BCWX3cCeZPikEvUf/oHSWi+DmG7XCE+fZgRA4BqqAI/OAm7hZm1pVpKXfm8gM7rhUUUyAFQRWotlHVsq3cYCDUwX9TFsHsjC00B+ArCNptY3f5vXj8GbP7NqlpSFzLEomRtdJuOgzphXf4qDia7yCxWYlgp+SaI= x-ms-office365-filtering-correlation-id: 348bab04-e15e-4c52-226d-08d6590829f5 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:AM0PR08MB3922; x-ms-traffictypediagnostic: AM0PR08MB3922: authentication-results: spf=none (sender IP is ) smtp.mailfrom=anton.nefedov@virtuozzo.com; x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(8121501046)(5005006)(10201501046)(93006095)(93001095)(3231455)(999002)(944501493)(4982022)(52105112)(3002001)(148016)(149066)(150057)(6041310)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051)(76991095); SRVR:AM0PR08MB3922; BCL:0; PCL:0; RULEID:; SRVR:AM0PR08MB3922; x-forefront-prvs: 08756AC3C8 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(136003)(366004)(39840400004)(376002)(346002)(396003)(189003)(199004)(6306002)(476003)(107886003)(5660300001)(54906003)(14454004)(2906002)(52116002)(386003)(7736002)(1076002)(99286004)(6506007)(316002)(3846002)(6116002)(305945005)(68736007)(25786009)(478600001)(97736004)(86362001)(66066001)(36756003)(8676002)(14444005)(44832011)(6486002)(8936002)(966005)(2501003)(81156014)(81166006)(256004)(26005)(2351001)(4326008)(102836004)(106356001)(105586002)(5640700003)(186003)(6436002)(71200400001)(71190400001)(6512007)(486006)(53936002)(6916009)(2616005); DIR:OUT; SFP:1102; SCL:1; SRVR:AM0PR08MB3922; H:AM0PR08MB3347.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: virtuozzo.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: gccQZT9PxJ0DRrv5w3LcFy4Zau0Wsvu0+ViuNSpirrO9eVW+d1yU5MO4slP6uFLzrSXyAJbJxSQKGnqblX1/9UuQk5Y1LhnvIg7/UspVWI5ZsXcloNUa9QlD5ThK/sL/KMBniLIASQxxth/leKBDvq56jvoUYfYo1vumLoybr1llErvJ0u29XrrSq6mn+NCpdVwDHbU/dZVqZ4XWDJ2Wytwvb730XRljXDJ6B8fkG4od2cMVdrPMg4ZzbI3dIWBE2ZY5j2Q3/aGqlrfpSR52DuqZmXJeQbWbuLUl2wvxulJzt5UviuMkW525tExPSVPaoGzV6OQGr/7p59y6BoCOFeOa/X65lOBjRBhF7DD8VH4= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 348bab04-e15e-4c52-226d-08d6590829f5 X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Dec 2018 10:14:52.2958 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3922 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.6.112 Subject: [Qemu-devel] [PATCH v10 0/9] 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 v10: - 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. v9: http://lists.nongnu.org/archive/html/qemu-devel/2018-05/msg01667.html - fixed commentary wording in patches 4, 8 - rebased (no conflicts) v8: http://lists.nongnu.org/archive/html/qemu-devel/2018-03/msg03291.html ---- 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 (9): 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: 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 | 9 ++++- include/block/block_int.h | 2 +- block/blkdebug.c | 2 +- block/blkverify.c | 10 ++++- block/copy-on-read.c | 4 +- block/file-posix.c | 8 +++- block/io.c | 49 ++++++++++++++++++----- block/mirror.c | 8 +++- block/qcow2-cluster.c | 2 +- block/qcow2.c | 80 +++++++++++++++++++++++++++++++++++++- block/quorum.c | 19 ++++++++- block/raw-format.c | 2 +- block/trace-events | 1 + tests/qemu-iotests/060 | 26 ++++++++----- tests/qemu-iotests/060.out | 5 ++- tests/qemu-iotests/134 | 9 +++++ tests/qemu-iotests/134.out | 10 +++++ 19 files changed, 220 insertions(+), 36 deletions(-)