From patchwork Thu Jun 1 15:14:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Nefedov X-Patchwork-Id: 9759811 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 30275602BF for ; Thu, 1 Jun 2017 15:16:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1FB782849A for ; Thu, 1 Jun 2017 15:16:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1460D284F8; Thu, 1 Jun 2017 15:16:24 +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=-6.8 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 02D3D2849A for ; Thu, 1 Jun 2017 15:16:22 +0000 (UTC) Received: from localhost ([::1]:45180 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dGRpl-0000AR-TE for patchwork-qemu-devel@patchwork.kernel.org; Thu, 01 Jun 2017 11:16:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51515) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dGRoW-00007x-BM for qemu-devel@nongnu.org; Thu, 01 Jun 2017 11:15:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dGRoT-0004dx-MO for qemu-devel@nongnu.org; Thu, 01 Jun 2017 11:15:04 -0400 Received: from mail-eopbgr40133.outbound.protection.outlook.com ([40.107.4.133]:34349 helo=EUR03-DB5-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 1dGRoT-0004d9-Ez for qemu-devel@nongnu.org; Thu, 01 Jun 2017 11:15:01 -0400 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; bh=R6OsZaFn3fMyP2vGisTaaNuZkn08zGXonnG1vwAk5Nk=; b=ExQ1MY0k/6056XQi5yva6o34BjIkZ65xCi3Q90vEcyDhTzg3IkYlVFNbICFUuZJbFGAmYpwf3eDeqM+h1ii7ttUeDXtaOoGiDtYUH0aJ+zETPkfC02sotVBPsnw3lexfzgyKPd1ETBCYD6E2Am0wa93fNI9UueWza4OXMLyvmb4= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from xantnef-ws.sw.ru (195.214.232.6) by VI1PR0801MB1999.eurprd08.prod.outlook.com (2603:10a6:800:8a::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1124.9; Thu, 1 Jun 2017 15:14:57 +0000 From: Anton Nefedov To: Date: Thu, 1 Jun 2017 18:14:19 +0300 Message-ID: <1496330073-51338-2-git-send-email-anton.nefedov@virtuozzo.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1496330073-51338-1-git-send-email-anton.nefedov@virtuozzo.com> References: <1496330073-51338-1-git-send-email-anton.nefedov@virtuozzo.com> MIME-Version: 1.0 X-Originating-IP: [195.214.232.6] X-ClientProxiedBy: DB6PR1001CA0005.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:4:b7::15) To VI1PR0801MB1999.eurprd08.prod.outlook.com (2603:10a6:800:8a::20) X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR0801MB1999: X-MS-Office365-Filtering-Correlation-Id: 7b864e92-c93d-43eb-774b-08d4a900f792 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(201703131423075)(201703031133081); SRVR:VI1PR0801MB1999; X-Microsoft-Exchange-Diagnostics: 1; VI1PR0801MB1999; 3:5mkBa71V4t71rsyLhArYYbs1hGYPXMhShve9xwWoI0YEBLXhd3I/uY/vZc5WGRiNq7lk1w7UMyAcMAk4h9yBabvqP48HoFyFrmXLbDkBZqfg6tXlcnmzt+jAXvec0iB8PFj4eBQTXr86eu+sur6WZ8uFE5VknGkYGf50XByxqCYG5jJnaFp135H+AkEVIkBQj3Pw1lJ2GJgH0rVgiNYC1bZNkFzoiYweIaf/gNZyZ/KtSeegWbfhozBcYGCei6u6QYo5IkEpXhRRW+5/opkCOdMrJfOShK6DjPoTxFq5O0AmsqCYLWVrApO1lriqAIJJUX7tDsKTpxAyDXPDuLiEDg==; 25:88Ak7KHaeo9rn51lDGKWGMJPCPvgHt9DV8Ud2neLWvosJylrA2NAXIvMFHooYW4339lZKxAi1wLqQuGiGNrzpN9uYb81JqZ8PWnya6KI2elgqxFNS8AghhID4AqSXKm7HjlLptpCHMu3s3i2fL47pTiMhYN0h26QcxgcAcWb6CIbk9vzoFHC5FIKhS40teBfuNZnUxJInRGL8N0KUpFhfg1jJnQ+8jtCvza55f3sla09yyzUPsvFWfbibMMY+6sZwlAkwPpLwcMhEvzEz8YqkCXfq69UJw9Y3xWT0E1RO8tFX/KX948nXelMw6jdqh/+5+5RSPrsPJH3pTB5K4onC3FbBufK2dknr8vB58sLTZLk8pt2t07iAQKm4cMAbrU2DcB7OItArGm0i2yY4y7yHKiirgmy4EixE6fENMTtPS01e/EfyljQ0yL+bwS8DalTI8adEUYIDiDabeEE17+8eaGXTmrjN7cY1ww7HjU5usI= X-Microsoft-Exchange-Diagnostics: 1; VI1PR0801MB1999; 31:8UC+SXSeES71DnTIfMQ6UXA88hIEr87x1nyuCIis80YjOrj1Vp79INkE5411rZPHD8h+j28bHtlW/K1vJn4cqJTGcGD3u75OE+hI26qkERPxSgqYgrIg1Uu5iUUeTJacAJ26JIH17UKEurMjeg7Bgvd0FIpiP5y+5S0Vcp4yhV6kPkq/ZXoU8YdcC+J0Netj50otdGfSm9DBxO9uTuRGvqAmptdB0ySYC/3QVT31D8Sh9as7jz4zpQhJInonBcQuCgzl9EVDQtHCdNaUepAG8w==; 20:i0JMO8jedvU1uhWQE4q0pYXe0dJ+Kqwioo79jchtByQ+H+6uJuBwrld0uhGVTpQrNkLUqks+paw1bwXAlauAtuAa66R26gYb41/zZl9KRGWx/U5RtTcEZZAJ+V2YvT7mUnv6bCbRJXeJpnvs3Y+sheTCI/KMn7c7ltcEVXjZfBm896Yad6Q4azs1SqZpAIa2O4M4diShnjrTeMSlay1NxSUnC/9qfHRwnYnedKtLQkF1sjAhD5mb7QNtakKO3cvYj2/6JdPYkPwyuUcCMW7L79EGwJYcU3lS+7IhAyKlzpG9HciQdpw15sLWVjBvThnKa74yIbQ0i0G/OgH+ZIEoQDUdxVE8kmopdZiO6Te39QM0hmxDMEHyN7Z1ayspUxq2Zs3XnvkUC09+Gexnb2vZUUJTWKTf2xx/VrLiRGIdYMs= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(93006095)(93001095)(10201501046)(100000703101)(100105400095)(3002001)(6041248)(20161123560025)(20161123558100)(20161123555025)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:VI1PR0801MB1999; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:VI1PR0801MB1999; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR0801MB1999; 4:NQq1RYPFhBrs1nDuJ1y9hOqzDzjD2Pk0vrIzr+WN?= =?us-ascii?Q?3Ogj15bpqwSVbdPoIbk7I1+kOCxSh88AKfwq3NzUB/P0/bLSGCRdjbraM5ke?= =?us-ascii?Q?CTJIqLmRp8yRcLXafAU4/I+ztL4qIIA3tSheHnS20OnGr4mIuO0TfOvLbZeo?= =?us-ascii?Q?DYkobxr/OPMu7Dx4G6iBGHfvdbv7oqay9Nnt127VmiEYfVUwq3l+HHOXqMda?= =?us-ascii?Q?vQWIWAyMwtJDltdtmX0agzYWg+X9R4anWu307P2bFSfOVtJ4+pna8CN/5oF9?= =?us-ascii?Q?aEoRdbiFmtQAtcZunhy6nk6nPWhaeX4YfEJPO/ty9g2ZrCH6JZOw7/HS4DZr?= =?us-ascii?Q?0rllOA6yU8h8ddGcW5eHREGMri8ZwB4R1cAbA6Y831bsZ+cSRTZtF4lRLr0k?= =?us-ascii?Q?xFAEDZ75HzNJPDxRKhPmoy0wNzSN2/ilAPpRqNIoSnXFYHttj5a1Oz7eX2mj?= =?us-ascii?Q?IzKFz/yj9X2eAHB5T+SoaT6Y3Dz7qjJJ4EHRunHkJxB3sTB/kQie2baXJGwk?= =?us-ascii?Q?XQcbtoc3PaC5UPNpdgdUvxJVUVGQwGK7etjvXX7M2htvSBNbH+KKpwCoJ4iu?= =?us-ascii?Q?ZBQZxvCV8sNH8auzwo1NeKIC62oSv3sWN8fqRx3470EleJxDlnxYko533+As?= =?us-ascii?Q?2f1S3xA2s4Q1yZnjhx75jjVOqcfbZ+kIqzuzEAO5kOnBhDkTnm6bzlOyzCVt?= =?us-ascii?Q?ITDF4O+2MrgCSf3KXghIcqBD+t/JquJQ9dG8hdcp3/dxSJf5dkZFARyUtGbW?= =?us-ascii?Q?WCyhchpupS6E1UOGmodWcM1HSdCoej0IF+ae8i8Azp03WU5MumilS454DaKt?= =?us-ascii?Q?YDVI5QocEUVXXTVZ3tbTvFnxYhDkCMtGlyoUFKNFK9TS9ZeeiLQ00w2OQyK9?= =?us-ascii?Q?7Ye+6IpT4TLMxVKroa5zW0mQA2t/U+5Jgr8xAvLzLtwCGSsA6gMQZtrsp1EU?= =?us-ascii?Q?mUpec3uVmXFuETh7fYPQ5UyOj9DareWimQkMr7iBXPOn5SIyLYmgZLQuSaKH?= =?us-ascii?Q?u3iad4feUbICRMZRRhCvRXMlm/4NWXvFTDvmBB1FKmr4kXN/V7IjiR3Wd6cK?= =?us-ascii?Q?3+dqWSuXlYV2t9cfraCuOKs9vqlsiKMv98uUytdUPOIc08ocQQ7Bz4O2ndMq?= =?us-ascii?Q?ctbcUx+AU/zay2u+WIsS62gZVUyyR5OQ?= X-Forefront-PRVS: 0325F6C77B X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(39830400002)(39450400003)(39400400002)(6916009)(6666003)(6486002)(7736002)(478600001)(5660300001)(305945005)(54906002)(53936002)(4326008)(6512007)(6506006)(2950100002)(110136004)(107886003)(3846002)(50226002)(8676002)(66066001)(42186005)(81166006)(38730400002)(25786009)(6116002)(76176999)(50986999)(47776003)(86362001)(5003940100001)(2906002)(2351001)(36756003)(48376002)(50466002)(33646002)(53416004)(189998001); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR0801MB1999; H:xantnef-ws.sw.ru; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR0801MB1999; 23:ZmVmLIHNA82oUQM1ECtCnmZhUKpGLbk8tj5v4mF?= =?us-ascii?Q?FYU2In41wuASSMtnL0HTcmtl0MWdo7QyER9zIVZMeoJau5O9W+/k4IebjgFR?= =?us-ascii?Q?LS8EI0K1pt77GMfG9OWfe9avhhaTNC96uawTQgZSa1UwlOsFrOdwqTBAQoaQ?= =?us-ascii?Q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GOjDq9Tjx2MsY0dEi4G6qAdZsXRVz+M7v72uy3GQALU2txZFWf+YOoyODDNTZf7dB9mjs8mxUBJ5aWcs+lm1gkkVSNvPxvL4QwFVFufVb; 24:xT4Lg62XTOa7hzLtgzpjCuP/LA+b2T9hwpPziK/UNaIOZ0JnnmULjWldVaKN3/TlZx/g0qf7Kd/yfqxub3QJMyjh+3PtOkwOkIPGE3S0nP8= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; VI1PR0801MB1999; 7:sHw+XDkxYh6DtMCVymt6XUW4Zv9jVmhrISipoeLTverROqzgiLVzQghAmxHtMoVjILh49IpVBQ1xAAP4EfNAUNE14vsP6q0z0gmASNLlbhSDgcm70ul7rxhLPZcc8Mc37xXgpoyuHpeGx4ZZp1QgSknmyYdcR7/XfDgSwyBN6DVCmgq77jrN187YciXSoGMOoWvSOsWoEtdqtPGkFF6CqYUBxBOh+Ep2EVai3ylIrNxO2DpRZgb7xaOhiiIYZmVr9waveTxA4kE9pK2SEF2LzXWwnVa4FAYpOwC8tQjlqI4Si5Vdppc08RfOREcPxGfYAvBfHbKZfDd8CyDDTSbFjQ==; 20:WTjhU+MOBAI254e+17yiWYBD/IRn+zVj1Ub+Md3rzw6t3Y5LxDrlBD/v3rfNOu2ThPFMIcxcd7zL4Gsm8tjMFVj+U8bGSZGTndbdpxkeEyWxPo/FzTf2tIxVW+DIvjxXr4t+yBXHwdFz97yvfeTVGAsIvtqm76Vi6PsINT2/jc0= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jun 2017 15:14:57.6778 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0801MB1999 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.4.133 Subject: [Qemu-devel] [PATCH v2 01/15] block: introduce BDRV_REQ_ALLOCATE flag 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, Anton Nefedov , den@virtuozzo.com, mreitz@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The flag is supposed to indicate that the region of the disk image has to be sufficiently allocated so it reads as zeroes. The call with the flag set has to return -ENOTSUP if allocation cannot be done efficiently (i.e. without falling back to writing actual buffers) Signed-off-by: Anton Nefedov --- block/io.c | 19 ++++++++++++++++--- block/trace-events | 1 + include/block/block.h | 6 +++++- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/block/io.c b/block/io.c index ed31810..d47efa9 100644 --- a/block/io.c +++ b/block/io.c @@ -1272,7 +1272,7 @@ static int coroutine_fn bdrv_co_do_pwrite_zeroes(BlockDriverState *bs, assert(!bs->supported_zero_flags); } - if (ret == -ENOTSUP) { + if (ret == -ENOTSUP && !(flags & BDRV_REQ_ALLOCATE)) { /* Fall back to bounce buffer if write zeroes is unsupported */ BdrvRequestFlags write_flags = flags & ~BDRV_REQ_ZERO_WRITE; @@ -1355,8 +1355,8 @@ static int coroutine_fn bdrv_aligned_pwritev(BdrvChild *child, ret = notifier_with_return_list_notify(&bs->before_write_notifiers, req); if (!ret && bs->detect_zeroes != BLOCKDEV_DETECT_ZEROES_OPTIONS_OFF && - !(flags & BDRV_REQ_ZERO_WRITE) && drv->bdrv_co_pwrite_zeroes && - qemu_iovec_is_zero(qiov)) { + !(flags & BDRV_REQ_ZERO_WRITE) && !(flags & BDRV_REQ_ALLOCATE) && + drv->bdrv_co_pwrite_zeroes && qemu_iovec_is_zero(qiov)) { flags |= BDRV_REQ_ZERO_WRITE; if (bs->detect_zeroes == BLOCKDEV_DETECT_ZEROES_OPTIONS_UNMAP) { flags |= BDRV_REQ_MAY_UNMAP; @@ -1436,6 +1436,9 @@ static int coroutine_fn bdrv_co_do_zero_pwritev(BdrvChild *child, assert(flags & BDRV_REQ_ZERO_WRITE); if (head_padding_bytes || tail_padding_bytes) { + if (flags & BDRV_REQ_ALLOCATE) { + return -ENOTSUP; + } buf = qemu_blockalign(bs, align); iov = (struct iovec) { .iov_base = buf, @@ -1534,6 +1537,11 @@ int coroutine_fn bdrv_co_pwritev(BdrvChild *child, return ret; } + if (qiov && flags & BDRV_REQ_ALLOCATE) { + /* allocation request with qiov provided doesn't make much sense */ + return -ENOTSUP; + } + bdrv_inc_in_flight(bs); /* * Align write if necessary by performing a read-modify-write cycle. @@ -1665,6 +1673,11 @@ int coroutine_fn bdrv_co_pwrite_zeroes(BdrvChild *child, int64_t offset, { trace_bdrv_co_pwrite_zeroes(child->bs, offset, count, flags); + if (flags & BDRV_REQ_MAY_UNMAP && flags & BDRV_REQ_ALLOCATE) { + /* nonsense */ + return -ENOTSUP; + } + if (!(child->bs->open_flags & BDRV_O_UNMAP)) { flags &= ~BDRV_REQ_MAY_UNMAP; } diff --git a/block/trace-events b/block/trace-events index 9a71c7f..a15c2cc 100644 --- a/block/trace-events +++ b/block/trace-events @@ -15,6 +15,7 @@ bdrv_aio_writev(void *bs, int64_t sector_num, int nb_sectors, void *opaque) "bs bdrv_co_readv(void *bs, int64_t sector_num, int nb_sector) "bs %p sector_num %"PRId64" nb_sectors %d" bdrv_co_writev(void *bs, int64_t sector_num, int nb_sector) "bs %p sector_num %"PRId64" nb_sectors %d" bdrv_co_pwrite_zeroes(void *bs, int64_t offset, int count, int flags) "bs %p offset %"PRId64" count %d flags %#x" +bdrv_co_allocate(void *bs, int64_t offset, int count) "bs %p offset %"PRId64" count %d" bdrv_co_do_copy_on_readv(void *bs, int64_t offset, unsigned int bytes, int64_t cluster_offset, unsigned int cluster_bytes) "bs %p offset %"PRId64" bytes %u cluster_offset %"PRId64" cluster_bytes %u" # block/stream.c diff --git a/include/block/block.h b/include/block/block.h index 9b355e9..53a357c 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -65,9 +65,13 @@ typedef enum { BDRV_REQ_NO_SERIALISING = 0x8, BDRV_REQ_FUA = 0x10, BDRV_REQ_WRITE_COMPRESSED = 0x20, + /* BDRV_REQ_ALLOCATE is used to indicate that the driver is to + * efficiently allocate the space so it reads as zeroes or return an error + */ + BDRV_REQ_ALLOCATE = 0x40, /* Mask of valid flags */ - BDRV_REQ_MASK = 0x3f, + BDRV_REQ_MASK = 0x7f, } BdrvRequestFlags; typedef struct BlockSizes {