From patchwork Thu Nov 16 16:54:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Nefedov X-Patchwork-Id: 10061521 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 6808D60230 for ; Thu, 16 Nov 2017 16:59:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5801A2A6D0 for ; Thu, 16 Nov 2017 16:59:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4CE372ABD0; Thu, 16 Nov 2017 16:59:14 +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 C09102A6D0 for ; Thu, 16 Nov 2017 16:59:13 +0000 (UTC) Received: from localhost ([::1]:41826 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eFNVR-00040v-1y for patchwork-qemu-devel@patchwork.kernel.org; Thu, 16 Nov 2017 11:59:13 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40181) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eFNRm-0001R4-4b for qemu-devel@nongnu.org; Thu, 16 Nov 2017 11:55:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eFNRj-0007QK-Bm for qemu-devel@nongnu.org; Thu, 16 Nov 2017 11:55:25 -0500 Received: from mail-he1eur01on0120.outbound.protection.outlook.com ([104.47.0.120]:43088 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 1eFNRi-0007Fo-Uj; Thu, 16 Nov 2017 11:55:23 -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; bh=58TOI4R9GHQ5bOgm6vTvqqdDeh+VFS5JmOL1dICbKtA=; b=PXW+ws7KVo6oDdvOVRG2V7Ctp1DufsDC2OhpVdiCm2eDzzwuQnOrz/38FIx3vB2ykLJ3mptmzV1THm8WQEYFFDf71uYoDPBYTs0TeJ+UmlqBI3gHusXFw3Mz9n/emggfDjguvmXlNCjxYp/mQHUCJKdN3Jes5/O6x3srJuT8eiw= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=anton.nefedov@virtuozzo.com; Received: from xantnef-ws.sw.ru (195.214.232.6) by DB6PR0801MB1992.eurprd08.prod.outlook.com (2603:10a6:4:76::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.239.5; Thu, 16 Nov 2017 16:55:17 +0000 From: Anton Nefedov To: qemu-devel@nongnu.org Date: Thu, 16 Nov 2017 19:54:56 +0300 Message-Id: <1510851298-59922-3-git-send-email-anton.nefedov@virtuozzo.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510851298-59922-1-git-send-email-anton.nefedov@virtuozzo.com> References: <1510851298-59922-1-git-send-email-anton.nefedov@virtuozzo.com> MIME-Version: 1.0 X-Originating-IP: [195.214.232.6] X-ClientProxiedBy: DB3PR0202CA0008.eurprd02.prod.outlook.com (2603:10a6:8:1::21) To DB6PR0801MB1992.eurprd08.prod.outlook.com (2603:10a6:4:76::9) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7663d880-063a-439c-625b-08d52d12d14b X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(4534020)(4602075)(7168017)(4627115)(201703031133081)(201702281549075)(2017052603258); SRVR:DB6PR0801MB1992; X-Microsoft-Exchange-Diagnostics: 1; DB6PR0801MB1992; 3:lb2L1mJwLNNUMtZxTUcZF+91gl9QrJS4eijieYsHz+fMuczbEDRiWxhd6aMDnbX0brZNKwdHqIjM/ZBOxs4hxDbxnc7wnFgDCbU5bQup8snjSsfJun6ApiDYADcIRGC536jbuKb3EX3/MKq9LneeZC/YwRr+7DDEbDWZelyCrYvym7YsVtdhZQ+pvpZLdYrHAAobWUwxybfxosyMMnA7D6Ey5i33sVOeGZ1Jl+uPheqv2CUjXaPF51IyaVvrdlPw; 25:DV42jYLqJjTk8VOOxAQ28WrIykq/VgVpi/lDovkgobO+H7FUV7TwEGgTj46FCxf4N2wz1wgn5TRZ0QeVOvHrpkl5i2aUmSW5dQlBI8CfxOKSal3mhC05ljYmJMQJ+sLsPLZ0404dQ1txVp98VR9ow4sC1P7Bxmoe+SWg7pJV0aVWw5MfaKOaf0e8hvts6/bw3ajoN4Ivfd1HMUX/c5MedU9LiwBkbukvX6DS2KKCQUHQIYSexa8IQB1XO02naQszBAyxh5rypcH11AcOnob3N0IljCRIlAsDtZ6V/dqiu/gGFKlBWRXQFshfKWAunE/DpMIL+6EurLsa3MSyqPE9PQ==; 31:S7EPl3hNBeJ2HPKVWYDKsBbhoKEYImN3H28xGlKpMp7iUmru6RubX+gf0thDQN+o4/Go28kR564k24Y223ESr15KpwIw0sZ1M3VHss674M0FRUMhw9BZ6YHGkoSiFryMcSoAyuzPgjxUOpA349dI+RINq+JeBUFkhJj7xJGHpvmaPiZ+mNSvVU+COoiMpM8UgZtLNEYtBTef5RIwSh/fjWrnxTzON7jHj+n/J6QqKSs= X-MS-TrafficTypeDiagnostic: DB6PR0801MB1992: X-Microsoft-Exchange-Diagnostics: 1; DB6PR0801MB1992; 20:Luq2o9K+zxICjqyMom83MrZyD8SHjExHvZzuSvbtRIf8FDItptx1ejZx3l4b/gFqU+eVBUoqfP5Fg1LuorIYWIbT5l/dN9O8CeZcjycIFDFtOEJLX5tSlr7JDOUYxlcKU8zuw/3zst5mk37sQQ8CCwiEclYGIWr1oPuc51G86TZl8YOjjs/odEwgq31qUlXRfZot/BfGkMgtT2GGeeitjESUSgWdQUk0FyVjCgLTsklWHhz76z+PtjhQyofuFDBNkgICyvCRJi+72ZIVOBd7X9tcqf3CqzbOVMIjengpaH3LvkOYJic3aezATZOHHhPbsU/nr3aA4dZA4yJaMZP4PKksGRkXuMFYJagy1rnaIgg/jMkXLrDGZtYVhW+1IswRiLGjWLCsUWoxoGatiHxQPD6SEXwnzLER8ebtZOv1lZs=; 4:jbM0mF/pAMaw1TmBGBXjOMzOzluDl44z4eudlaXOIK5kTCrspGaerUxigBHuPXpDKIrJLagNsMmYtFtu3v/VNz0dvsFaR1l6zuyb+FlNo5jM0plA76osgyZHj69rPtdykCDZXwSJESl14j2BeSSNNb2DRiiSuqVgi+Ker+s5yWZPVhTZPTOVc+wnS/B3ioqWPckCrBrXdGKPkDkyXRYFkawaddSRuCNkq6wCQMYiMYMS5rQQhnKpSctjAFmA1a5X0ANHq1LZ4BZkHMxMqfKEDg== 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)(2401047)(8121501046)(5005006)(3002001)(10201501046)(3231022)(100000703101)(100105400095)(93006095)(93001095)(6041248)(20161123562025)(20161123560025)(20161123564025)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:DB6PR0801MB1992; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:DB6PR0801MB1992; X-Forefront-PRVS: 0493852DA9 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6009001)(376002)(346002)(189002)(199003)(189998001)(69596002)(97736004)(2950100002)(6916009)(6666003)(47776003)(50466002)(230783001)(66066001)(3846002)(48376002)(5660300001)(316002)(6116002)(16586007)(86362001)(5003940100001)(16526018)(33646002)(6512007)(478600001)(2361001)(106356001)(53936002)(105586002)(2351001)(36756003)(7736002)(76176999)(50986999)(107886003)(305945005)(50226002)(68736007)(53416004)(8676002)(81156014)(81166006)(25786009)(4326008)(8936002)(6506006)(101416001)(6486002)(2906002); DIR:OUT; SFP:1102; SCL:1; SRVR:DB6PR0801MB1992; H:xantnef-ws.sw.ru; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: virtuozzo.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DB6PR0801MB1992; 23:1QKpucK9gw47trcTZvxBlwUW/P4pCUF0YvFYGZ2?= =?us-ascii?Q?BdzH78/b83mvHepCS34t7De+Cb+CM9kBzRyhpkbTVRNcLKIoxVEb19nGx3fN?= =?us-ascii?Q?UQEyr/4xY+H7xsqyGw/HLB1oIgTHylJ1ODmoncYWdVkUZ90N1ccYmEvBdALa?= =?us-ascii?Q?WztwqXfohgKCj/P4DYXqsEjgULFSo1bWpVST4jbuSCEvVvJp868WwS2GWnsV?= =?us-ascii?Q?vHjVyRake6NqM1VYV4+l9ZeXtUk8O652HXu+hmUkQBeJu3MiJJLlwR6ICAai?= =?us-ascii?Q?UNqeO2dNnH3u9uBIJgTft9Bn+2oWwZVeg+L7+smWGw4sKycto5Uc5anu38A6?= =?us-ascii?Q?qzR5JkTPDo41idBu2vNI/mhT4WUD/vX3Ws1M8hOsyJ6jRgZFED9ZqoXa0nX2?= =?us-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ZJ1gxeVKGqaZAzA9oNhS6Og1ptpek9N+BGJuBCVxvox7WK148r+WRXUUUo= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Nov 2017 16:55:17.8864 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7663d880-063a-439c-625b-08d52d12d14b X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0801MB1992 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.0.120 Subject: [Qemu-devel] [PATCH v2 2/4] block: support compressed write for copy-on-read 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 , famz@redhat.com, den@virtuozzo.com, qemu-block@nongnu.org, mreitz@redhat.com, stefanha@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Anton Nefedov Reviewed-by: Max Reitz Reviewed-by: Stefan Hajnoczi --- block/io.c | 23 +++++++++++++++++------ block/trace-events | 2 +- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/block/io.c b/block/io.c index 3d5ef2c..2ba62a3 100644 --- a/block/io.c +++ b/block/io.c @@ -953,7 +953,7 @@ bdrv_driver_pwritev_compressed(BlockDriverState *bs, uint64_t offset, } static int coroutine_fn bdrv_co_do_copy_on_readv(BdrvChild *child, - int64_t offset, unsigned int bytes, QEMUIOVector *qiov) + int64_t offset, unsigned int bytes, QEMUIOVector *qiov, int flags) { BlockDriverState *bs = child->bs; @@ -988,12 +988,13 @@ static int coroutine_fn bdrv_co_do_copy_on_readv(BdrvChild *child, * allocating cluster in the image file. Note that this value may exceed * BDRV_REQUEST_MAX_BYTES (even when the original read did not), which * is one reason we loop rather than doing it all at once. + * Also this is crucial for compressed copy-on-read. */ bdrv_round_to_clusters(bs, offset, bytes, &cluster_offset, &cluster_bytes); skip_bytes = offset - cluster_offset; trace_bdrv_co_do_copy_on_readv(bs, offset, bytes, - cluster_offset, cluster_bytes); + cluster_offset, cluster_bytes, flags); bounce_buffer = qemu_try_blockalign(bs, MIN(MIN(max_transfer, cluster_bytes), @@ -1041,8 +1042,13 @@ static int coroutine_fn bdrv_co_do_copy_on_readv(BdrvChild *child, /* This does not change the data on the disk, it is not * necessary to flush even in cache=writethrough mode. */ - ret = bdrv_driver_pwritev(bs, cluster_offset, pnum, - &local_qiov, 0); + if (flags & BDRV_REQ_WRITE_COMPRESSED) { + ret = bdrv_driver_pwritev_compressed(bs, cluster_offset, + pnum, &local_qiov); + } else { + ret = bdrv_driver_pwritev(bs, cluster_offset, pnum, + &local_qiov, 0); + } } if (ret < 0) { @@ -1107,7 +1113,12 @@ static int coroutine_fn bdrv_aligned_preadv(BdrvChild *child, * potential fallback support, if we ever implement any read flags * to pass through to drivers. For now, there aren't any * passthrough flags. */ - assert(!(flags & ~(BDRV_REQ_NO_SERIALISING | BDRV_REQ_COPY_ON_READ))); + assert(!(flags & ~(BDRV_REQ_NO_SERIALISING | BDRV_REQ_COPY_ON_READ | + BDRV_REQ_WRITE_COMPRESSED))); + + /* write compressed only makes sense with copy on read */ + assert(!(flags & BDRV_REQ_WRITE_COMPRESSED) || + (flags & BDRV_REQ_COPY_ON_READ)); /* Handle Copy on Read and associated serialisation */ if (flags & BDRV_REQ_COPY_ON_READ) { @@ -1132,7 +1143,7 @@ static int coroutine_fn bdrv_aligned_preadv(BdrvChild *child, } if (!ret || pnum != bytes) { - ret = bdrv_co_do_copy_on_readv(child, offset, bytes, qiov); + ret = bdrv_co_do_copy_on_readv(child, offset, bytes, qiov, flags); goto out; } } diff --git a/block/trace-events b/block/trace-events index 11c8d5f..12fe188 100644 --- a/block/trace-events +++ b/block/trace-events @@ -12,7 +12,7 @@ blk_co_pwritev(void *blk, void *bs, int64_t offset, unsigned int bytes, int flag bdrv_co_preadv(void *bs, int64_t offset, int64_t nbytes, unsigned int flags) "bs %p offset %"PRId64" nbytes %"PRId64" flags 0x%x" bdrv_co_pwritev(void *bs, int64_t offset, int64_t nbytes, unsigned int flags) "bs %p offset %"PRId64" nbytes %"PRId64" flags 0x%x" bdrv_co_pwrite_zeroes(void *bs, int64_t offset, int count, int flags) "bs %p offset %"PRId64" count %d flags 0x%x" -bdrv_co_do_copy_on_readv(void *bs, int64_t offset, unsigned int bytes, int64_t cluster_offset, int64_t cluster_bytes) "bs %p offset %"PRId64" bytes %u cluster_offset %"PRId64" cluster_bytes %"PRId64 +bdrv_co_do_copy_on_readv(void *bs, int64_t offset, unsigned int bytes, int64_t cluster_offset, int64_t cluster_bytes, int flags) "bs %p offset %"PRId64" bytes %u cluster_offset %"PRId64" cluster_bytes %"PRId64" flags 0x%x" # block/stream.c stream_one_iteration(void *s, int64_t offset, uint64_t bytes, int is_allocated) "s %p offset %" PRId64 " bytes %" PRIu64 " is_allocated %d"