From patchwork Mon Oct 26 17:17:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 301989 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1904CC4363A for ; Mon, 26 Oct 2020 17:27:43 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 83132207F7 for ; Mon, 26 Oct 2020 17:27:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="qXjez5gh" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 83132207F7 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:56420 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kX6HV-0002lg-CL for qemu-devel@archiver.kernel.org; Mon, 26 Oct 2020 13:27:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49374) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kX68m-0007Kk-Ag; Mon, 26 Oct 2020 13:18:40 -0400 Received: from mail-eopbgr60108.outbound.protection.outlook.com ([40.107.6.108]:26030 helo=EUR04-DB3-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kX68j-0008Ma-Of; Mon, 26 Oct 2020 13:18:39 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VphG3vcWBQNkYUxExP4vY7VhSWFLlClMQyHDDpoAnMjBhkSuBh5NaZb1N6Vld0YnkgVBdzM+5Y9vDn0eNWVtMhxl7Kk/Fv5ktCBxomTaR+dynKVtU4K1nEfS7NdlCBvWltyUMN3HXUUdMvX8bwm98P63OY3UMCX3xOPIZUatvYLrJEyw13Mi/3stPFwnB6KANYuHHV8dqK+M+F79vfg4+dd5AX2GQyiMVAJ7nPMMeIEewnd5/UnO/GILZ9bonbgaCDKHDe5hIpq+ZseUlummqa82hAXSYOtlwwRATFOlicVMHMDRreuK4gpASei7+u+ed8+w4Of6fx++Nxv/p9p/3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=88hyOsjzyQ4zATbbMpV2IBFUipKVkBuxs8teh8Zkj4I=; b=nbv//gCAvDtx768k28zAfDfV1E22Q7pNe0DqTgjA6N6SEw94sj48qYRxj2xFibJnvQv8wZAqC2mxb/0DDWnTd2WY8/pWQIIhyVP9HyCEKmtsgtvBVAmGdkzeQhN/C/SecwCyUiJh201Pwk7v98IzK+h2mLnii8WPLH2/blicH+R4i0pvWL00cwWZ+2wPQSaSSkwM0Y3xGKLIwm0b7XQ4gSlBtbwegllFLylAN9CN+ty+N3ZKpzNu8MJo2ciAM9zGaZOyN88nfcxCAG2rhKY/stIhdBVO9B63uLD8fc2Ou7RVL0oQJ5O4gcVAV7aufvap+mC/Zem+E8TQprcRK3byIQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=88hyOsjzyQ4zATbbMpV2IBFUipKVkBuxs8teh8Zkj4I=; b=qXjez5ghIXk2YXlpbvuftSABfgASEROuryetwvWQRdJ0DOcMSeEHZnTK9IsjrKcUsthifow7BZkO0KaQGzDMwgzMRqP/w9JofRGJ4URuZ51qPIdUS5IrgI4CsqqEdaH4Ri8Xa4+iXnqWIn6KtMUPU5SzQjouL2BBoUn/7Ic4NYM= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB5031.eurprd08.prod.outlook.com (2603:10a6:20b:ed::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18; Mon, 26 Oct 2020 17:18:31 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243%9]) with mapi id 15.20.3499.018; Mon, 26 Oct 2020 17:18:31 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, vsementsov@virtuozzo.com, eblake@redhat.com, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, jsnow@redhat.com, mreitz@redhat.com, kwolf@redhat.com, den@openvz.org Subject: [PATCH v3 02/25] qapi: backup: add perf.use-copy-range parameter Date: Mon, 26 Oct 2020 20:17:52 +0300 Message-Id: <20201026171815.13233-3-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201026171815.13233-1-vsementsov@virtuozzo.com> References: <20201026171815.13233-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.99] X-ClientProxiedBy: AM0PR02CA0101.eurprd02.prod.outlook.com (2603:10a6:208:154::42) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.99) by AM0PR02CA0101.eurprd02.prod.outlook.com (2603:10a6:208:154::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Mon, 26 Oct 2020 17:18:30 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 26bb347e-a04a-46df-0549-08d879d32981 X-MS-TrafficTypeDiagnostic: AM6PR08MB5031: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3044; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VIoGTeGZjtQ3zx+2g+E1634mdVoiocuRD8Y/W1QBwdVAbxecJ4004FTMZZuhXqb47BZPZ8xcdsqZTEn0MYJIhDQxi373tK0ndNM9Cz4x8h+sq3yM/dbBhYkH/pCIbbdnvjIJsyxF1NRLYWLMtF3UcVkDL0usClAXvJEqkreODphC0hGB1b1xUsyTUHskb1pCkzTXbA3dvqnUcyYF+xTRRP2UwnV9BSCciXYE+t4H/X4xhKIHxG7joAPqllRgMkUrLEPnM57AITQrKFA7CmCJDurn8U53+QJ42N9DYy1xeqUM3xZ94xTfyJl9mDC+tAHS X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(136003)(366004)(39840400004)(346002)(376002)(396003)(83380400001)(5660300002)(1076003)(316002)(2616005)(478600001)(6506007)(4326008)(6666004)(66946007)(26005)(66556008)(956004)(36756003)(6486002)(6512007)(186003)(66476007)(8936002)(52116002)(2906002)(16526019)(107886003)(8676002)(6916009)(86362001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: me/3NgBFlBpGYJgGPzKD6NpR+Vu6849OfJf7BcMVGPsnPfjREXKG/hiJV01tkD8m4/UMU4PPacMTr3zzRUigKKhvHmaisxop0WIcRQPadnkGd3KglxQhSvyij54h9yGW/8qyQWeWOct38TN7GiuuK9DK5IMk+/+fJ1fXsPjImcf+/yRgUGKgldVJV5F1UcrlpK2XTm6c2UppUZm6RBM5azsAFLRus6WK7e9PUT3FQTLD4FVVIAQ0VDtnNXL43QWXZEGX+UFc1186Kow1/b/mkHAfuhkuXlzE/FfXBVYEA0CPqTDhHG5tDWU1KRs12shlsrKcGv1e0qKcecnhoI38T7xAw+GCaIpSAtISrOMnCpDDyMA+fvRyfoXstaBfLroYpgk+J7pSUihHtZeZbo6otRLpv4GH/vz242tjKh0v1l92KDlhYOTfmyF4kje7Sok2u9wlhbhjtaZoiGFJpXZEoHK2tra+iqr5nVMC+Fth5sro+zfXNoy8CLamFa1mRPcx+UISBDAqidYml1cyF/n/c0i8m3serPWwr6o42PnAmRapEn9pLD1FkElLFC5xIxC2T7QkDon4Cxp9xShj7OZVLEuFqgypHZDf8TG/ZANm4wWxFtnyAFT4lfcVV9NqM5osJi9IV403OcRw0clKmmiaqg== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 26bb347e-a04a-46df-0549-08d879d32981 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Oct 2020 17:18:31.6089 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ijt3rtlLuQgEkczIeaJTroSjay25j0Nh5RlheS0eYbzf19CJ3f/VaHi51jZ46TH0BUcxZEdd7EY8LO9ckgj7/HkV8y0tdii7W18Vwmr4FbA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB5031 Received-SPF: pass client-ip=40.107.6.108; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-DB3-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/26 13:18:30 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Experiments show, that copy_range is not always making things faster. So, to make experimentation simpler, let's add a parameter. Some more perf parameters will be added soon, so here is a new struct. For now, add new backup qmp parameter with x- prefix for the following reasons: - We are going to add more performance parameters, some will be related to the whole block-copy process, some only to background copying in backup (ignored for copy-before-write operations). - On the other hand, we are going to use block-copy interface in other block jobs, which will need performance options as well.. And it should be the same structure or at least somehow related. So, there are too much unclean things about how the interface and now we need the new options mostly for testing. Let's keep them experimental for a while. In do_backup_common() new x-perf parameter handled in a way to make further options addition simpler. We add use-copy-range with default=true, and we'll change the default in further patch, after moving backup to use block-copy. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Max Reitz --- qapi/block-core.json | 17 ++++++++++++++++- block/backup-top.h | 1 + include/block/block-copy.h | 2 +- include/block/block_int.h | 3 +++ block/backup-top.c | 4 +++- block/backup.c | 6 +++++- block/block-copy.c | 4 ++-- block/replication.c | 2 ++ blockdev.c | 8 ++++++++ 9 files changed, 41 insertions(+), 6 deletions(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index e74669159c..71e6faa15c 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -1370,6 +1370,19 @@ { 'struct': 'BlockdevSnapshot', 'data': { 'node': 'str', 'overlay': 'str' } } +## +# @BackupPerf: +# +# Optional parameters for backup. These parameters don't affect +# functionality, but may significantly affect performance. +# +# @use-copy-range: Use copy offloading. Default true. +# +# Since: 5.2 +## +{ 'struct': 'BackupPerf', + 'data': { '*use-copy-range': 'bool' }} + ## # @BackupCommon: # @@ -1425,6 +1438,8 @@ # above node specified by @drive. If this option is not given, # a node name is autogenerated. (Since: 4.2) # +# @x-perf: Performance options. (Since 5.2) +# # Note: @on-source-error and @on-target-error only affect background # I/O. If an error occurs during a guest write request, the device's # rerror/werror actions will be used. @@ -1439,7 +1454,7 @@ '*on-source-error': 'BlockdevOnError', '*on-target-error': 'BlockdevOnError', '*auto-finalize': 'bool', '*auto-dismiss': 'bool', - '*filter-node-name': 'str' } } + '*filter-node-name': 'str', '*x-perf': 'BackupPerf' } } ## # @DriveBackup: diff --git a/block/backup-top.h b/block/backup-top.h index e5cabfa197..b28b0031c4 100644 --- a/block/backup-top.h +++ b/block/backup-top.h @@ -33,6 +33,7 @@ BlockDriverState *bdrv_backup_top_append(BlockDriverState *source, BlockDriverState *target, const char *filter_node_name, uint64_t cluster_size, + BackupPerf *perf, BdrvRequestFlags write_flags, BlockCopyState **bcs, Error **errp); diff --git a/include/block/block-copy.h b/include/block/block-copy.h index aac85e1488..6397505f30 100644 --- a/include/block/block-copy.h +++ b/include/block/block-copy.h @@ -22,7 +22,7 @@ typedef void (*ProgressBytesCallbackFunc)(int64_t bytes, void *opaque); typedef struct BlockCopyState BlockCopyState; BlockCopyState *block_copy_state_new(BdrvChild *source, BdrvChild *target, - int64_t cluster_size, + int64_t cluster_size, bool use_copy_range, BdrvRequestFlags write_flags, Error **errp); diff --git a/include/block/block_int.h b/include/block/block_int.h index 887b0668d8..dc1ed349df 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -1248,6 +1248,8 @@ void mirror_start(const char *job_id, BlockDriverState *bs, * @sync_mode: What parts of the disk image should be copied to the destination. * @sync_bitmap: The dirty bitmap if sync_mode is 'bitmap' or 'incremental' * @bitmap_mode: The bitmap synchronization policy to use. + * @perf: Performance options. All actual fields assumed to be present, + * all ".has_*" fields are ignored. * @on_source_error: The action to take upon error reading from the source. * @on_target_error: The action to take upon error writing to the target. * @creation_flags: Flags that control the behavior of the Job lifetime. @@ -1266,6 +1268,7 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs, BitmapSyncMode bitmap_mode, bool compress, const char *filter_node_name, + BackupPerf *perf, BlockdevOnError on_source_error, BlockdevOnError on_target_error, int creation_flags, diff --git a/block/backup-top.c b/block/backup-top.c index fe6883cc97..789acf6965 100644 --- a/block/backup-top.c +++ b/block/backup-top.c @@ -186,6 +186,7 @@ BlockDriverState *bdrv_backup_top_append(BlockDriverState *source, BlockDriverState *target, const char *filter_node_name, uint64_t cluster_size, + BackupPerf *perf, BdrvRequestFlags write_flags, BlockCopyState **bcs, Error **errp) @@ -244,7 +245,8 @@ BlockDriverState *bdrv_backup_top_append(BlockDriverState *source, state->cluster_size = cluster_size; state->bcs = block_copy_state_new(top->backing, state->target, - cluster_size, write_flags, &local_err); + cluster_size, perf->use_copy_range, + write_flags, &local_err); if (local_err) { error_prepend(&local_err, "Cannot create block-copy-state: "); goto fail; diff --git a/block/backup.c b/block/backup.c index 9afa0bf3b4..4b07e9115d 100644 --- a/block/backup.c +++ b/block/backup.c @@ -46,6 +46,7 @@ typedef struct BackupBlockJob { uint64_t len; uint64_t bytes_read; int64_t cluster_size; + BackupPerf perf; BlockCopyState *bcs; } BackupBlockJob; @@ -335,6 +336,7 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs, BitmapSyncMode bitmap_mode, bool compress, const char *filter_node_name, + BackupPerf *perf, BlockdevOnError on_source_error, BlockdevOnError on_target_error, int creation_flags, @@ -441,7 +443,8 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs, (compress ? BDRV_REQ_WRITE_COMPRESSED : 0), backup_top = bdrv_backup_top_append(bs, target, filter_node_name, - cluster_size, write_flags, &bcs, errp); + cluster_size, perf, + write_flags, &bcs, errp); if (!backup_top) { goto error; } @@ -464,6 +467,7 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs, job->bcs = bcs; job->cluster_size = cluster_size; job->len = len; + job->perf = *perf; block_copy_set_progress_callback(bcs, backup_progress_bytes_callback, job); block_copy_set_progress_meter(bcs, &job->common.job.progress); diff --git a/block/block-copy.c b/block/block-copy.c index cd9bc47c8f..63398a171c 100644 --- a/block/block-copy.c +++ b/block/block-copy.c @@ -218,7 +218,7 @@ static uint32_t block_copy_max_transfer(BdrvChild *source, BdrvChild *target) } BlockCopyState *block_copy_state_new(BdrvChild *source, BdrvChild *target, - int64_t cluster_size, + int64_t cluster_size, bool use_copy_range, BdrvRequestFlags write_flags, Error **errp) { BlockCopyState *s; @@ -260,7 +260,7 @@ BlockCopyState *block_copy_state_new(BdrvChild *source, BdrvChild *target, * We enable copy-range, but keep small copy_size, until first * successful copy_range (look at block_copy_do_copy). */ - s->use_copy_range = true; + s->use_copy_range = use_copy_range; s->copy_size = MAX(s->cluster_size, BLOCK_COPY_MAX_BUFFER); } diff --git a/block/replication.c b/block/replication.c index 0c70215784..22ffc811ee 100644 --- a/block/replication.c +++ b/block/replication.c @@ -454,6 +454,7 @@ static void replication_start(ReplicationState *rs, ReplicationMode mode, int64_t active_length, hidden_length, disk_length; AioContext *aio_context; Error *local_err = NULL; + BackupPerf perf = { .use_copy_range = true }; aio_context = bdrv_get_aio_context(bs); aio_context_acquire(aio_context); @@ -558,6 +559,7 @@ static void replication_start(ReplicationState *rs, ReplicationMode mode, s->backup_job = backup_job_create( NULL, s->secondary_disk->bs, s->hidden_disk->bs, 0, MIRROR_SYNC_MODE_NONE, NULL, 0, false, NULL, + &perf, BLOCKDEV_ON_ERROR_REPORT, BLOCKDEV_ON_ERROR_REPORT, JOB_INTERNAL, backup_job_completed, bs, NULL, &local_err); diff --git a/blockdev.c b/blockdev.c index fe6fb5dc1d..b71ed08a3b 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2788,6 +2788,7 @@ static BlockJob *do_backup_common(BackupCommon *backup, { BlockJob *job = NULL; BdrvDirtyBitmap *bmap = NULL; + BackupPerf perf = { .use_copy_range = true }; int job_flags = JOB_DEFAULT; if (!backup->has_speed) { @@ -2812,6 +2813,12 @@ static BlockJob *do_backup_common(BackupCommon *backup, backup->compress = false; } + if (backup->x_perf) { + if (backup->x_perf->has_use_copy_range) { + perf.use_copy_range = backup->x_perf->use_copy_range; + } + } + if ((backup->sync == MIRROR_SYNC_MODE_BITMAP) || (backup->sync == MIRROR_SYNC_MODE_INCREMENTAL)) { /* done before desugaring 'incremental' to print the right message */ @@ -2885,6 +2892,7 @@ static BlockJob *do_backup_common(BackupCommon *backup, backup->sync, bmap, backup->bitmap_mode, backup->compress, backup->filter_node_name, + &perf, backup->on_source_error, backup->on_target_error, job_flags, NULL, NULL, txn, errp); From patchwork Mon Oct 26 17:17:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 301986 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 60692C4363A for ; Mon, 26 Oct 2020 17:33:45 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D62F321D42 for ; Mon, 26 Oct 2020 17:33:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="Pkhsw0uf" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D62F321D42 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:44938 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kX6NL-0001Ur-Ni for qemu-devel@archiver.kernel.org; Mon, 26 Oct 2020 13:33:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49428) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kX68p-0007RI-D9; Mon, 26 Oct 2020 13:18:43 -0400 Received: from mail-eopbgr60108.outbound.protection.outlook.com ([40.107.6.108]:26030 helo=EUR04-DB3-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kX68m-0008Ma-Vg; Mon, 26 Oct 2020 13:18:43 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ezzLgUSG4vBvP0L/mtLG0K0DX5lMqqtVj7p44sgUa2ff8Ts8nNI7ZEnWbHkcNNPyP1hZhWK2XQvtByKzD/q1efo3/Tq26X+XHYFtOTkQNL4LRMRFqQWbL+ywIvXV7zg65sMH3r7k8sJXNxcH8FVoPVM35c86D1cWPVU170IpanZZWWxfN0J0O3XADEdsHTjIR9pZXEOhqpSkiaFw8vvX/eTW5yWYS29b6M5mSh4wE2gJL/qTH6VuLWUsx/QJTc0QIwoOR6mdfQoMa6VnVU952IL6VppThaqxT/mqxvHE8C88nEhnDutQd/TYHpyKjA4+lPTyvbP8YaZCvUKs2mKUVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=cpYxAJXMQcy3DpfbwLzmcNtDOhEpYjcfz+nUWm3o3xM=; b=MXtjiZWQpZcYy1YDsoJytStrp4gH218HT7BtS1ItKZVjmslsDbGrb8ELsgWvR2yX8yviNHujj5qD7vzmTG62D370huBvDYXlIa3Nm3GUI6wYUXMeN6Jx+OdBgCyWRfp+EgHrr9WxMoPpicdkpTl062w4qmE9Y2ZZbny5rc4m/34my7PNjvj/lj+RbfTX9XbsKwMk1AEjZTi0+JvzJuYPh+52Kjch5tCK/BijsswPrMPlNn8cptoSDvPT6i/fx1lO/9A96e2N88wCwiWJE7ox/fGgOlAgMhK7XigE+586sX+X++nYaeV7LRx/7KqJ2J3JG3VFgxy6ubZ92C6r1AYJuQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=cpYxAJXMQcy3DpfbwLzmcNtDOhEpYjcfz+nUWm3o3xM=; b=Pkhsw0ufA4EHAXVWDN4GI+Yt6dA5OZMfcbPQFdkU98CpMFdOXruRSNSH/GTz//2nuWdkYP+jORhqgixR1F08s0fZ8819oitW85D7+naQRFWTgOLZBA1hCK88UXnSgNJzt66amLPQDueclOSN/wAGx9FKJonOkDvcdT62J0aC92U= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB5031.eurprd08.prod.outlook.com (2603:10a6:20b:ed::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18; Mon, 26 Oct 2020 17:18:32 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243%9]) with mapi id 15.20.3499.018; Mon, 26 Oct 2020 17:18:32 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, vsementsov@virtuozzo.com, eblake@redhat.com, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, jsnow@redhat.com, mreitz@redhat.com, kwolf@redhat.com, den@openvz.org Subject: [PATCH v3 03/25] block/block-copy: More explicit call_state Date: Mon, 26 Oct 2020 20:17:53 +0300 Message-Id: <20201026171815.13233-4-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201026171815.13233-1-vsementsov@virtuozzo.com> References: <20201026171815.13233-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.99] X-ClientProxiedBy: AM0PR02CA0101.eurprd02.prod.outlook.com (2603:10a6:208:154::42) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.99) by AM0PR02CA0101.eurprd02.prod.outlook.com (2603:10a6:208:154::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Mon, 26 Oct 2020 17:18:31 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 24470c34-b60e-495e-27e2-08d879d32a0e X-MS-TrafficTypeDiagnostic: AM6PR08MB5031: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:751; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FXEtJ38JcKn58Eo5IHRE6lYYdxCPCT1jxZn4iHdeADxBFqB3ujkZqjByll7Q8TOqlmQXU5FS5s8esqLjUyTayNr4xzJWcF3wn32wxBKLL5fPt0Wq0Qcq+XHPF747shRkKxmyKYDKczPziKxC6o+Lcc4YmpVrOtviGMrIev2X0Z0QdwVf6SKtR+MhS6/ZBVJ0oDvUy7nd1SMSEuI+jmB8rynb/bYgQ3lXRfpnQS9Cui4IhJVXRiTPCiRXkhFEyyoIhs9luiMsClzlDPOsf5D2IJ2JiojXnAwIUa7vbtTdY5aloXVVXyhFrkUtf8VLz21tntQVaV6FbsFlXJ07Hp6lBg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(136003)(366004)(39840400004)(346002)(376002)(396003)(83380400001)(5660300002)(1076003)(316002)(2616005)(478600001)(6506007)(4326008)(6666004)(66946007)(26005)(66556008)(956004)(36756003)(6486002)(6512007)(186003)(66476007)(8936002)(52116002)(2906002)(16526019)(107886003)(8676002)(6916009)(86362001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: 13NGWWeUYSkw49EQoNJwP8jwFnOT0SuytZbv3Eo6Sig9YT2Js3QpdNm5I7NvN9oEKN++t3hz2bKjiB3HYaK3fgep/hCpV3zY3iQuAag5VDgPAEkumXW55AT/HzY40z7WOTRv1TTrIxv/ns+zFM7ZSaPrNpMpXwSL6XtGIhf8+0VwsF0V1LKbWyGD8Jgm6W2slZj5TvmNQhUqrmXUFr/U+cwWDU4qjR9ACjv6OvkCVohr2Cx1OMgAoSb9y7t26D5x5Fj9vMYKzZxpEqghhv3zLN48mXkH4ns2NnTZfedKvLu/jaGMxxHsMPSEfLuKlsQz+Vm5MQ5IkdfFFXYw/fsL6ON4e8KfznQUO/JenoHy3jTgwH1/ygH+OZF+3ynvz0akgxNHGx070zecGcH8XKCWAjOL63OOTRobNn7VUr+9MHbUHhLYdKFxPxXtMYQoRiGBetxe/hwZwQc/V79OCsY5BEj1ryz7jAtEUOCSnbkDxaUDaqiwlRY/P0OZ2NggcZGWuarnnBeI/+eviuG+K8L++T/czGyV3LUrJZq5+REBfNjl++YxcVAp68rOtM1J7OBpe5KJhrPxuQGXYiyaJ27c8a/OAiGz/QNE1lHOjp75IrXM303xQe1AClRRTldJsmzSi6ExP5Jx9NBUVqvihcmbfw== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 24470c34-b60e-495e-27e2-08d879d32a0e X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Oct 2020 17:18:32.4731 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: VkxuMOM4O4tsqtG8N2ahaSaDC50UgFbEmlh7x1O5OpyJMx/xmBpyWwMsq/SN9PQSgWQKKxVxf9ZNyZ9y9Pq0jc9ZN+B+XFzMMVvopkGv2qI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB5031 Received-SPF: pass client-ip=40.107.6.108; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-DB3-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/26 13:18:30 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Refactor common path to use BlockCopyCallState pointer as parameter, to prepare it for use in asynchronous block-copy (at least, we'll need to run block-copy in a coroutine, passing the whole parameters as one pointer). Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Max Reitz --- block/block-copy.c | 51 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 13 deletions(-) diff --git a/block/block-copy.c b/block/block-copy.c index 63398a171c..6ea55f1f9a 100644 --- a/block/block-copy.c +++ b/block/block-copy.c @@ -30,7 +30,15 @@ static coroutine_fn int block_copy_task_entry(AioTask *task); typedef struct BlockCopyCallState { + /* IN parameters */ + BlockCopyState *s; + int64_t offset; + int64_t bytes; + + /* State */ bool failed; + + /* OUT parameters */ bool error_is_read; } BlockCopyCallState; @@ -544,15 +552,17 @@ int64_t block_copy_reset_unallocated(BlockCopyState *s, * Returns 1 if dirty clusters found and successfully copied, 0 if no dirty * clusters found and -errno on failure. */ -static int coroutine_fn block_copy_dirty_clusters(BlockCopyState *s, - int64_t offset, int64_t bytes, - bool *error_is_read) +static int coroutine_fn +block_copy_dirty_clusters(BlockCopyCallState *call_state) { + BlockCopyState *s = call_state->s; + int64_t offset = call_state->offset; + int64_t bytes = call_state->bytes; + int ret = 0; bool found_dirty = false; int64_t end = offset + bytes; AioTaskPool *aio = NULL; - BlockCopyCallState call_state = {false, false}; /* * block_copy() user is responsible for keeping source and target in same @@ -568,7 +578,7 @@ static int coroutine_fn block_copy_dirty_clusters(BlockCopyState *s, BlockCopyTask *task; int64_t status_bytes; - task = block_copy_task_create(s, &call_state, offset, bytes); + task = block_copy_task_create(s, call_state, offset, bytes); if (!task) { /* No more dirty bits in the bitmap */ trace_block_copy_skip_range(s, offset, bytes); @@ -633,15 +643,12 @@ out: aio_task_pool_free(aio); } - if (error_is_read && ret < 0) { - *error_is_read = call_state.error_is_read; - } return ret < 0 ? ret : found_dirty; } /* - * block_copy + * block_copy_common * * Copy requested region, accordingly to dirty bitmap. * Collaborate with parallel block_copy requests: if they succeed it will help @@ -649,16 +656,16 @@ out: * it means that some I/O operation failed in context of _this_ block_copy call, * not some parallel operation. */ -int coroutine_fn block_copy(BlockCopyState *s, int64_t offset, int64_t bytes, - bool *error_is_read) +static int coroutine_fn block_copy_common(BlockCopyCallState *call_state) { int ret; do { - ret = block_copy_dirty_clusters(s, offset, bytes, error_is_read); + ret = block_copy_dirty_clusters(call_state); if (ret == 0) { - ret = block_copy_wait_one(s, offset, bytes); + ret = block_copy_wait_one(call_state->s, call_state->offset, + call_state->bytes); } /* @@ -675,6 +682,24 @@ int coroutine_fn block_copy(BlockCopyState *s, int64_t offset, int64_t bytes, return ret; } +int coroutine_fn block_copy(BlockCopyState *s, int64_t start, int64_t bytes, + bool *error_is_read) +{ + BlockCopyCallState call_state = { + .s = s, + .offset = start, + .bytes = bytes, + }; + + int ret = block_copy_common(&call_state); + + if (error_is_read && ret < 0) { + *error_is_read = call_state.error_is_read; + } + + return ret; +} + BdrvDirtyBitmap *block_copy_dirty_bitmap(BlockCopyState *s) { return s->copy_bitmap; From patchwork Mon Oct 26 17:17:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 301982 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7E3B8C4363A for ; Mon, 26 Oct 2020 17:40:05 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C90FA22242 for ; Mon, 26 Oct 2020 17:40:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="FvuD3d7b" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C90FA22242 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:33618 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kX6TS-0000IB-0e for qemu-devel@archiver.kernel.org; Mon, 26 Oct 2020 13:40:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49456) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kX68s-0007WN-3r; Mon, 26 Oct 2020 13:18:46 -0400 Received: from mail-eopbgr60108.outbound.protection.outlook.com ([40.107.6.108]:26030 helo=EUR04-DB3-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kX68p-0008Ma-W3; Mon, 26 Oct 2020 13:18:45 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MXwa0y4QPcyo8IAswtTKH+RYn+LyRdoZe9d+zPWxqCAVAHKTTld2i2tFO+vMCIAYTXzHlYHuLyDkuAdvwsxXsGa843doHVq+l9HaKDvmd3+0v2Qfd+9QUSPRllYEy2cyalbRiQn/JctwqNEXWB2RfmkQk8NtFow65fmUr5pBMkvRzBuw2mGY1eDMwmBMrOemI0NGzVcbhgyOCuIsq6zLadO++U1mjANEntO+doubmqRP6WIkXTiuqGUCR3rtfDWdG3epTpxHEnFT2CyxxIXiWsgApJWMkVt+R7cNX4C+sA0UghJUyzZnf3hVmRnNqSxbi7ex2qCr4J/p8GKzEpiesQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MAr7Nve6ddL6t2DWtKipHvOZSMXnELBA6nhnqL+MIKY=; b=KRqthOxrhG9y1qcNd8I/52UBrGRqJgTxA3VBzxBMDuqM/86NfF1jZVxZ35EF+6MUs9tbHBwAvGPNApJ1gXQZiv85+KM+ReMpU79eQ6tXrjmj8lmBNMzC7z3irBfr8i1A6SA3sTq0u979yrWxXcCxyLMZR5hyJrGhjISHZoiwmn/Z6Nv8BEvG4NAfJibwTfFumgGx+WEH4uX3F5npHrE1dQAM78ETtVGsep/CbWtqqpQLvYGgpAxRfXNMgVu+tcVXqmW26rgmUNWB9lRGtoy/vXLEmO/+j7uDkIpMmAbk2nYSrpPm2pVZbU+cnaLDiqCybEewuh0o5Nw/Gr/bUZn+DA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MAr7Nve6ddL6t2DWtKipHvOZSMXnELBA6nhnqL+MIKY=; b=FvuD3d7bFJzxn8p4ArhRQotamaAnuYg6e0o/BeIXr1dmNiwGe88TtAzVLVxiJdSm+f46KJoFTSnrraJHKJYagT3/p34NSYzQA05OCp1ZokCoBEU4YnL9fjT6E4OscXF6z8PeH2w9nPKu9I67++TGYbv2mcb4UgEgc8Vbv/IV694= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB5031.eurprd08.prod.outlook.com (2603:10a6:20b:ed::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18; Mon, 26 Oct 2020 17:18:33 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243%9]) with mapi id 15.20.3499.018; Mon, 26 Oct 2020 17:18:33 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, vsementsov@virtuozzo.com, eblake@redhat.com, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, jsnow@redhat.com, mreitz@redhat.com, kwolf@redhat.com, den@openvz.org Subject: [PATCH v3 04/25] block/block-copy: implement block_copy_async Date: Mon, 26 Oct 2020 20:17:54 +0300 Message-Id: <20201026171815.13233-5-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201026171815.13233-1-vsementsov@virtuozzo.com> References: <20201026171815.13233-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.99] X-ClientProxiedBy: AM0PR02CA0101.eurprd02.prod.outlook.com (2603:10a6:208:154::42) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.99) by AM0PR02CA0101.eurprd02.prod.outlook.com (2603:10a6:208:154::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Mon, 26 Oct 2020 17:18:32 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2efa9a13-b780-4a3b-e597-08d879d32a8f X-MS-TrafficTypeDiagnostic: AM6PR08MB5031: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:50; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XwmjUyQajTRmIbun3YHZsQyuNgBNzbT2RV4apoJM4SJzKZX3EikCW81ujeKyMK3ifRQOF7mjxSkIsvHb4WeoaEkSdJrc92ZZx3DjggMXndgsEC+YO60hFn6rEn9+jnRclx/HZ+kNGvmmtL5I7ncU3u0fm4TBH+zaKnj4f7kfbwnA6VkUyKswMyXC4HxEd3cmoWkwpLAH3eQYvUJJa2wUCEg+wNzmW2yJzxgpn2mpwAp+9YdZ460RBq1E2uoAUF+/N/nEGYlJ5vYhW+qGTk3g9kUXfhxLd9gqNhOFoYOm9xjXlcTiuAAtjD0OEm7ZzBwaU2aeYpQF2O38TU8rqGNNQg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(136003)(366004)(39840400004)(346002)(376002)(396003)(83380400001)(5660300002)(1076003)(316002)(2616005)(478600001)(6506007)(4326008)(6666004)(66946007)(26005)(66556008)(956004)(36756003)(6486002)(6512007)(186003)(66476007)(8936002)(52116002)(2906002)(16526019)(107886003)(8676002)(6916009)(86362001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: aH2H+5vi1xuTa6nIhaVL2Ts90omd6ZwmmD/VWqePCHKKYGDyTw0p3vhTmSXKA/Sp833KjcnScR3rfL/hRVkTuDv4+IMhsvDpBH7WMTknVgKZSlyBZSkdGzH4GZ5magUJeeKgl8+pPyB2DMb43sBG5+ZKbrXAxjGdduDRJXt0fxoOJtqTyBG8keHyXLvTtfq9SX4xPjMl3gO61zPoMUVx4NsYlp3HtQtrjIrk8vr9IjkIFyrTcUgDazt8vvIzx956I2zzp23AhWI/DH7OScwWyjIrburCeXWPe6JgA8YeYUG6RXPV51GDoAWWQRv4H1pQA5yJYREoCB7y2EySYOw8QOnRoY3P6WjxaWgurreFkkh5og4vyu6PQOzOaPfGdOb7aF1JRx4A5pTREQbZiZawOqaMptEDSVSVoKxNnMXDmelY5XbBzHxWnSLfqvJHdcfoKxvdviJE23CdnW6f3XmPKyrSvgBnfgx6/8bXAPjExZgJqk7Yk5YhFuR3kTgASWWQ1gQjHKmrjflEiKNjgJx2+HL2cYO6g11zxPF7kUYtikmXWa/RhomlHVOS4qpFaMJee1WPmue0oLqxyzbckd636ciyJyhfsCwQS3uugiG3TbBtwSIHd4PzjMtBqk84zVUSBJa9KUY7xCMhO12AbBb2uw== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2efa9a13-b780-4a3b-e597-08d879d32a8f X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Oct 2020 17:18:33.3432 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: iPYYghx2s97FEovIhRQmvYU3hoCdVE0DsE5spe/sAxExhLiFUeJZ+FojuytiHEb4jkbPVoX1HQTrC8ZdkyMLLSjJEZ37gYWhQCcQaVebgqI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB5031 Received-SPF: pass client-ip=40.107.6.108; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-DB3-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/26 13:18:30 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" We'll need async block-copy invocation to use in backup directly. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Max Reitz --- include/block/block-copy.h | 26 ++++++++++++ block/block-copy.c | 81 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 103 insertions(+), 4 deletions(-) diff --git a/include/block/block-copy.h b/include/block/block-copy.h index 6397505f30..3566827599 100644 --- a/include/block/block-copy.h +++ b/include/block/block-copy.h @@ -19,7 +19,9 @@ #include "qemu/co-shared-resource.h" typedef void (*ProgressBytesCallbackFunc)(int64_t bytes, void *opaque); +typedef void (*BlockCopyAsyncCallbackFunc)(void *opaque); typedef struct BlockCopyState BlockCopyState; +typedef struct BlockCopyCallState BlockCopyCallState; BlockCopyState *block_copy_state_new(BdrvChild *source, BdrvChild *target, int64_t cluster_size, bool use_copy_range, @@ -41,6 +43,30 @@ int64_t block_copy_reset_unallocated(BlockCopyState *s, int coroutine_fn block_copy(BlockCopyState *s, int64_t offset, int64_t bytes, bool *error_is_read); +/* + * Run block-copy in a coroutine, create corresponding BlockCopyCallState + * object and return pointer to it. Never returns NULL. + * + * Caller is responsible to call block_copy_call_free() to free + * BlockCopyCallState object. + */ +BlockCopyCallState *block_copy_async(BlockCopyState *s, + int64_t offset, int64_t bytes, + BlockCopyAsyncCallbackFunc cb, + void *cb_opaque); + +/* + * Free finished BlockCopyCallState. Trying to free running + * block-copy will crash. + */ +void block_copy_call_free(BlockCopyCallState *call_state); + +/* Note, that block-copy call is marked finished prior to calling the callback. */ +bool block_copy_call_finished(BlockCopyCallState *call_state); +bool block_copy_call_succeeded(BlockCopyCallState *call_state); +bool block_copy_call_failed(BlockCopyCallState *call_state); +int block_copy_call_status(BlockCopyCallState *call_state, bool *error_is_read); + BdrvDirtyBitmap *block_copy_dirty_bitmap(BlockCopyState *s); void block_copy_set_skip_unallocated(BlockCopyState *s, bool skip); diff --git a/block/block-copy.c b/block/block-copy.c index 6ea55f1f9a..74655b86f8 100644 --- a/block/block-copy.c +++ b/block/block-copy.c @@ -30,13 +30,19 @@ static coroutine_fn int block_copy_task_entry(AioTask *task); typedef struct BlockCopyCallState { - /* IN parameters */ + /* IN parameters. Initialized in block_copy_async() and never changed. */ BlockCopyState *s; int64_t offset; int64_t bytes; + BlockCopyAsyncCallbackFunc cb; + void *cb_opaque; + + /* Coroutine where async block-copy is running */ + Coroutine *co; /* State */ - bool failed; + int ret; + bool finished; /* OUT parameters */ bool error_is_read; @@ -428,8 +434,8 @@ static coroutine_fn int block_copy_task_entry(AioTask *task) ret = block_copy_do_copy(t->s, t->offset, t->bytes, t->zeroes, &error_is_read); - if (ret < 0 && !t->call_state->failed) { - t->call_state->failed = true; + if (ret < 0 && !t->call_state->ret) { + t->call_state->ret = ret; t->call_state->error_is_read = error_is_read; } else { progress_work_done(t->s->progress, t->bytes); @@ -679,6 +685,12 @@ static int coroutine_fn block_copy_common(BlockCopyCallState *call_state) */ } while (ret > 0); + call_state->finished = true; + + if (call_state->cb) { + call_state->cb(call_state->cb_opaque); + } + return ret; } @@ -700,6 +712,67 @@ int coroutine_fn block_copy(BlockCopyState *s, int64_t start, int64_t bytes, return ret; } +static void coroutine_fn block_copy_async_co_entry(void *opaque) +{ + block_copy_common(opaque); +} + +BlockCopyCallState *block_copy_async(BlockCopyState *s, + int64_t offset, int64_t bytes, + BlockCopyAsyncCallbackFunc cb, + void *cb_opaque) +{ + BlockCopyCallState *call_state = g_new(BlockCopyCallState, 1); + + *call_state = (BlockCopyCallState) { + .s = s, + .offset = offset, + .bytes = bytes, + .cb = cb, + .cb_opaque = cb_opaque, + + .co = qemu_coroutine_create(block_copy_async_co_entry, call_state), + }; + + qemu_coroutine_enter(call_state->co); + + return call_state; +} + +void block_copy_call_free(BlockCopyCallState *call_state) +{ + if (!call_state) { + return; + } + + assert(call_state->finished); + g_free(call_state); +} + +bool block_copy_call_finished(BlockCopyCallState *call_state) +{ + return call_state->finished; +} + +bool block_copy_call_succeeded(BlockCopyCallState *call_state) +{ + return call_state->finished && call_state->ret == 0; +} + +bool block_copy_call_failed(BlockCopyCallState *call_state) +{ + return call_state->finished && call_state->ret < 0; +} + +int block_copy_call_status(BlockCopyCallState *call_state, bool *error_is_read) +{ + assert(call_state->finished); + if (error_is_read) { + *error_is_read = call_state->error_is_read; + } + return call_state->ret; +} + BdrvDirtyBitmap *block_copy_dirty_bitmap(BlockCopyState *s) { return s->copy_bitmap; From patchwork Mon Oct 26 17:17:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 301990 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 986BFC388F9 for ; Mon, 26 Oct 2020 17:26:15 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1801021D7B for ; Mon, 26 Oct 2020 17:26:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="R0AbUTHK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1801021D7B Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:51244 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kX6G6-0000f5-25 for qemu-devel@archiver.kernel.org; Mon, 26 Oct 2020 13:26:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49356) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kX68l-0007I8-5K; Mon, 26 Oct 2020 13:18:39 -0400 Received: from mail-eopbgr60093.outbound.protection.outlook.com ([40.107.6.93]:39555 helo=EUR04-DB3-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kX68i-0008NC-Vm; Mon, 26 Oct 2020 13:18:38 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gMhxrdPvujfjiZaYdwbKkefekSKi/Ew1z9N4WqtYgEk7X1PVurcp28DJWrM3ze1MwEWr8HjZkZTOulEpQUBtrIkF6RsyDdODns5mD9QW9xzO2SEQV8oOmWi3kL4qlOQ0Wbnbgi/Ou2IVSLp9J1tdzzb/UG7nFBxSvS/Pp5caYzZNzkDwJc40fqo6clR6cD8BSCTV8ovP0IByAZZ5o9WfORvA/O5uzbeGhfZQbv92u1mghuvHawiFt4bbleTqV2JDQXd1B3mBtMp3CNdVQ/9f0nRbcq5qlz8HMAGxhtkCmaCh9bgqTn6Tpyh2JPRUSpuVz/h0meXBCTqPtRhmSVEQLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=X0vSNibjRCeh5JNFCyq96MD/O+hOQ5PexFF/sHwk8Lg=; b=fCi9oVygzdKtPR+iUA7QxAHqngqQOE2odr780V9raoJphDSNOQufigaaJT3vV/I7R9nAWaPu4Q2F6upVpt1ecqU1OLT6/KCd23O+tAczO37Fkq2OItxAn5YxR5p9ezGoUO07hoMLO18TmcHA6R0rlbSWsqJnGxZnI1Tjh0mkTcHppRY/7keTTxLLiBb8vm/H1fUI73EqP1KY/6d3LiR12N1pMhwJk6cnZMiTaJYyFb6yNr6Jq1P/xsBcwYzpB8vgpGQLHy78aEBBhG2EAMmWCV2fFLiXcrg4kIIoxCpa8+jAW7xhW6/dYyJeimjAIoIB71AtNPTqBcSmpsPsrrNZoQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=X0vSNibjRCeh5JNFCyq96MD/O+hOQ5PexFF/sHwk8Lg=; b=R0AbUTHKbjT4eqNU7q47+PbqvzrF4F3bMo1y61eolVQRAkdEz7T18cvDo3HeYywa/VorX/xI2mJTnQZ1AIzF8QlNYIbRgDpJRqUPFlzUGXwab2FJkgCBK9fcoZnNvBxHBc4A/6UOeX3qXM7W888qQUknNH50363XQ937soelpR4= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB3032.eurprd08.prod.outlook.com (2603:10a6:209:43::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18; Mon, 26 Oct 2020 17:18:34 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243%9]) with mapi id 15.20.3499.018; Mon, 26 Oct 2020 17:18:34 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, vsementsov@virtuozzo.com, eblake@redhat.com, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, jsnow@redhat.com, mreitz@redhat.com, kwolf@redhat.com, den@openvz.org Subject: [PATCH v3 05/25] block/block-copy: add max_chunk and max_workers parameters Date: Mon, 26 Oct 2020 20:17:55 +0300 Message-Id: <20201026171815.13233-6-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201026171815.13233-1-vsementsov@virtuozzo.com> References: <20201026171815.13233-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.99] X-ClientProxiedBy: AM0PR02CA0101.eurprd02.prod.outlook.com (2603:10a6:208:154::42) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.99) by AM0PR02CA0101.eurprd02.prod.outlook.com (2603:10a6:208:154::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Mon, 26 Oct 2020 17:18:33 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a73cb93d-1238-40b6-9007-08d879d32b17 X-MS-TrafficTypeDiagnostic: AM6PR08MB3032: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:22; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VufAhORBK24usxJe0nHEkfai0cHaJ7Dq8BClCFNJRf4wmC8fvooe0IyhWMD7BW9OIQTBTLrKGdXsC0+tO0FsrLn2SO9QXlJwvsTPip6zNCMd6TQwEWCAbmSPr3SJwZT/un4PZ/yibwWj7ZS+PvItva9ZPvSi3ZUH/nQnW4M0mkY2T1JN4oF5KK59iYk9nTYokzKEbbVwn5Za4yPMyQCfdNhVa/Hn9GcS4i8RM50f2OzvhHvE13CLsCkRrXZG1HJ3yyl+OkGwM0zKO0YbEKz315JQJXZ2cb/DTXw2fMhA9du8Ek/QrtQOXeIlo3VQk61J/DUDgV3sewtQpQlzhofPmQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(136003)(366004)(376002)(346002)(396003)(39840400004)(66476007)(8936002)(5660300002)(316002)(6506007)(6512007)(2616005)(66946007)(956004)(66556008)(6666004)(26005)(4326008)(36756003)(478600001)(52116002)(1076003)(16526019)(83380400001)(2906002)(186003)(6916009)(8676002)(107886003)(86362001)(6486002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: sCEnxzpZKo2IcHjXB02aOzjQoCNBZYhmLGLQh19mtd4O0IS8jgX+IESjHB7xAQylOMersSZsy1zQEr3SAt/hQ1x3OKNXxw5B8h/Ny4swdG7btRxOEWfBTeuaQtLtmQWwTr42s+4e62m/0rpFd8zOhAw+k55iq7LvjaL2/EK652wMbAI1Ju8aV9F7mREjHwt3wKwpo6ONTYN9GUeaGH+Ma5okSpVOx45ovT6N1KBmxz2Mlp9qrt/05NZFSqf906unbpiLHjO9y6KXpU/B+i3hZZGyfO50YJtyDqeK6M8zN0Wj08PzUqcLq7YEx4qiGLNKDU4FeHMG9VJHo7+Pcp4S8/nKHnJymhLW8ZyBV5r9hUy/7kzEMbSBUV/F4NwTNqez4cPskLHyg4oVmEYqCQdZYw7MIRfYhzGsm/lHSLAC+t+FZskInkrpL1cDGe1XYR5lmMBxuJoG8hoeoUPJsYpVTCSzr4xOteWGhmJsnUY//FLypdZ4F89efI4jfCvkH/OB+xn+NCNPKMWNbsGpra2fjJIkIdPJFInylzIaHdOAVih1SSSZQ3l9xSTnLCk3GHOuXuSPL4fDLRRN0BSJoeoTF/kbqlCdERn90Ny+c6eBycWfaIUQ+ONhMLn+6AivMUB5t7VRq2t/pMxFkNQ8/meGtQ== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: a73cb93d-1238-40b6-9007-08d879d32b17 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Oct 2020 17:18:34.2204 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: aIJG2nuwLm7pHYFzr9loFA3ak3rMQXJSQw1erVQCng6N1QbFNPB3TsKO4KM6h4raTWcFXy3EPhU8ud3ZJL/Ao6Z2zcN9d7Ir/D/DTu0LKLo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3032 Received-SPF: pass client-ip=40.107.6.93; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-DB3-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/26 13:18:35 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" They will be used for backup. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Max Reitz --- include/block/block-copy.h | 6 ++++++ block/block-copy.c | 11 +++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/include/block/block-copy.h b/include/block/block-copy.h index 3566827599..57806e8a49 100644 --- a/include/block/block-copy.h +++ b/include/block/block-copy.h @@ -49,9 +49,15 @@ int coroutine_fn block_copy(BlockCopyState *s, int64_t offset, int64_t bytes, * * Caller is responsible to call block_copy_call_free() to free * BlockCopyCallState object. + * + * @max_workers means maximum of parallel coroutines to execute sub-requests, + * must be > 0. + * + * @max_chunk means maximum length for one IO operation. Zero means unlimited. */ BlockCopyCallState *block_copy_async(BlockCopyState *s, int64_t offset, int64_t bytes, + int max_workers, int64_t max_chunk, BlockCopyAsyncCallbackFunc cb, void *cb_opaque); diff --git a/block/block-copy.c b/block/block-copy.c index 74655b86f8..35213bd832 100644 --- a/block/block-copy.c +++ b/block/block-copy.c @@ -34,6 +34,8 @@ typedef struct BlockCopyCallState { BlockCopyState *s; int64_t offset; int64_t bytes; + int max_workers; + int64_t max_chunk; BlockCopyAsyncCallbackFunc cb; void *cb_opaque; @@ -148,10 +150,11 @@ static BlockCopyTask *block_copy_task_create(BlockCopyState *s, int64_t offset, int64_t bytes) { BlockCopyTask *task; + int64_t max_chunk = MIN_NON_ZERO(s->copy_size, call_state->max_chunk); if (!bdrv_dirty_bitmap_next_dirty_area(s->copy_bitmap, offset, offset + bytes, - s->copy_size, &offset, &bytes)) + max_chunk, &offset, &bytes)) { return NULL; } @@ -623,7 +626,7 @@ block_copy_dirty_clusters(BlockCopyCallState *call_state) bytes = end - offset; if (!aio && bytes) { - aio = aio_task_pool_new(BLOCK_COPY_MAX_WORKERS); + aio = aio_task_pool_new(call_state->max_workers); } ret = block_copy_task_run(aio, task); @@ -701,6 +704,7 @@ int coroutine_fn block_copy(BlockCopyState *s, int64_t start, int64_t bytes, .s = s, .offset = start, .bytes = bytes, + .max_workers = BLOCK_COPY_MAX_WORKERS, }; int ret = block_copy_common(&call_state); @@ -719,6 +723,7 @@ static void coroutine_fn block_copy_async_co_entry(void *opaque) BlockCopyCallState *block_copy_async(BlockCopyState *s, int64_t offset, int64_t bytes, + int max_workers, int64_t max_chunk, BlockCopyAsyncCallbackFunc cb, void *cb_opaque) { @@ -728,6 +733,8 @@ BlockCopyCallState *block_copy_async(BlockCopyState *s, .s = s, .offset = offset, .bytes = bytes, + .max_workers = max_workers, + .max_chunk = max_chunk, .cb = cb, .cb_opaque = cb_opaque, From patchwork Mon Oct 26 17:17:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 301984 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D7679C4363A for ; Mon, 26 Oct 2020 17:36:57 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5141921D42 for ; Mon, 26 Oct 2020 17:36:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="Q6kHrkCk" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5141921D42 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:53174 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kX6QS-00058f-Ay for qemu-devel@archiver.kernel.org; Mon, 26 Oct 2020 13:36:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49430) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kX68p-0007S4-MC; Mon, 26 Oct 2020 13:18:43 -0400 Received: from mail-eopbgr60093.outbound.protection.outlook.com ([40.107.6.93]:39555 helo=EUR04-DB3-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kX68l-0008NC-QE; Mon, 26 Oct 2020 13:18:43 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ILqDE0rGROTCU3D78huYBLykIM2HLeiW9YsFR+ELXpfTxi4f574vi0ZzBUScR5CY3Oh6zoMA7YXxJFNfdhIuYic0BZIqQCwX9nsFUzgF7PJT/9rIkiShPFItVPeYg1m2qwI+mZtOQOThq6P8A+NzTHn06dItpY1w/iVwmuJPP6V3qIA+GxbhTNIXpkGhGyHSptcnQYIQRo/fvIBsRaefluIVCkcUl2cSjRc3bzX1GSp9UEDMUNIbWfk5tAxcmay2KOco6j2/jVRESyxqVP+VCcjQTjbHdqTKf4PMVf3iRHxACBBMxyBBXaQH3KYSFyC00gSyBOMm9J6EP+YMzqa6Eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AHGHPR5jS1zihkhcfonrcWsWS7tIO8SZQ43cO2jc6nc=; b=BDkJVaxEzYRWT/DmcISmhTZ14ffXzVYDqE1SIrMLQFVxt/O/0OnlvX9CUuYHHZSrmjP4In3ARuZ5FeiUits01gAEX+ifB5Nxpe2QbpvcEUz9CeQL2PjiOYNcrnJqYtibOMxcE7OsRCvgrhk4O3nJoH8RSjqGdt2CrSPVOgOvDmt1OtuSzBFlOC4oNdgl0RfJAu9snp7Z+WEip6w1BbSW2ZSXV0FCq0izVWw96xEs1Mki+5urCOn1zQ58ppXspPeg1r3Tsyat1p9UmdwmcvY+Y3YOCz0TK02Bw9kpGnI7jMdAZ1FzbgNMUa3dXfo3MLz8aNl0//ou5Y9z4Xaf6jpqvg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AHGHPR5jS1zihkhcfonrcWsWS7tIO8SZQ43cO2jc6nc=; b=Q6kHrkCkKGWV7Xyk5L2ph7xbofEc6cg2gp5QjKgTI901ncavoUgXVozwDktWL7YHWRmrpgUSJlnQCNs8lPa+R93h0Ui3FK7XK8gQ1jNZlOkYWhC+ZeyZ+OUbXq4k6nyAEDHcbB3ZqhNkFbwyHGoiEpQ0Syo2wEUT8MdV1j+HqtA= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB3032.eurprd08.prod.outlook.com (2603:10a6:209:43::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18; Mon, 26 Oct 2020 17:18:35 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243%9]) with mapi id 15.20.3499.018; Mon, 26 Oct 2020 17:18:35 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, vsementsov@virtuozzo.com, eblake@redhat.com, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, jsnow@redhat.com, mreitz@redhat.com, kwolf@redhat.com, den@openvz.org Subject: [PATCH v3 06/25] block/block-copy: add list of all call-states Date: Mon, 26 Oct 2020 20:17:56 +0300 Message-Id: <20201026171815.13233-7-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201026171815.13233-1-vsementsov@virtuozzo.com> References: <20201026171815.13233-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.99] X-ClientProxiedBy: AM0PR02CA0101.eurprd02.prod.outlook.com (2603:10a6:208:154::42) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.99) by AM0PR02CA0101.eurprd02.prod.outlook.com (2603:10a6:208:154::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Mon, 26 Oct 2020 17:18:34 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8c420c41-9b21-4300-f691-08d879d32ba1 X-MS-TrafficTypeDiagnostic: AM6PR08MB3032: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: W2zudI+nVpUkthG6f0ApuGsJWyNrCu+NBTObjctvNCt9FtVYpFTADdwPfJmDPIs0KSRJvd6x9CWxdXdY41F9mIuC+ZjN0xjizsI82RbXGhXXq50Y0L/Sf4TTLV3knXfORFNFxxARiLp4EOCYPFy2WhXekPQGEYRv1HaAA+yGpxpM8PiEZgae+8YqMY8C8iEpDqaGHW9bjVoagKmbiKMUW2akrxvAUeknrJNroXve5bMnKh++bTP5fnlUtbLGN9/eUM2nIQzQm+HIcWcxs3dOe7nTTkpZKePeCcsJU0R0+OXH4LRP24oCsK4iGwLKG07JHge4s67uv0h6JMbMjIKe2w== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(136003)(366004)(376002)(346002)(396003)(39840400004)(66476007)(8936002)(5660300002)(316002)(6506007)(6512007)(2616005)(66946007)(956004)(66556008)(6666004)(26005)(4326008)(36756003)(478600001)(52116002)(1076003)(16526019)(83380400001)(2906002)(186003)(6916009)(8676002)(107886003)(86362001)(6486002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: UQaSU24oRKrA58Pl01o0DXh6yUVIAK3/n9KuKVz8P04rj7DihGdzeWOIxUUkIpkbdWemQJWDWrveXMZG7F+gWlxoHqZi2QU2mLmAwI8TRTxrD7Pf79XyYIzGX44ClvDJ9cW+j5O94gP240Ofmqm5RYEbBq3ihVDUTBvC7xssXCoUqOgQ+ZQ2tw9kfcJILPtMYfMldYJ8yGuFDYQwH73eJzD+OZD3yaj4pxKeWu5yz9T+Vo8BB0vFae8xW3C1ZgO++XikeLC87DEYzdYO1FQ9orqdJFGep8TQaA1+CIkkCmAH/AjmRQoIykiRtHBIUvm7a4X2ZC+7UF0yls9LztR0800u1mVEg5PgvQ9nSLPFPyiC1NqeY47Lf9Wwns7crpWARPTPHsW8OpkMpuD+bFMxIKyLFqRFdFE1oJGcAOUgpj0rzwhLXoGjGSz/241CtvyNNSLKtxm0QELdeSADS9kk9GkMXOC0KZ78RQcLL+phECnWw957tlCnDVDNbyFKQA1ypDCFZptQhLHzLOTAz8dK07+MOsHLN8TW23Ez8r9Ul3S4lQVeJeMlDduvLMI73d77u1O2Hk7TidVdNeuGhJyAg6eLrlwi+EhRYJ+S98uR8CykjPOzY+X3x6MMCjVC3WFvzSKvHmh6hhUSe7ra7zq+yw== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8c420c41-9b21-4300-f691-08d879d32ba1 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Oct 2020 17:18:35.1503 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: BWAoiGIqSGwcr7WonqkuHZa4A5OwnVOn57FfiaEo5OEWlxvIlp+JMkyBwd6ecSBvjVWk6SBklqFP7BQC9nOKGt/uACN1pLD0NC52x6YmZwA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3032 Received-SPF: pass client-ip=40.107.6.93; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-DB3-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/26 13:18:35 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" It simplifies debugging. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Max Reitz --- block/block-copy.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/block/block-copy.c b/block/block-copy.c index 35213bd832..6bf1735b93 100644 --- a/block/block-copy.c +++ b/block/block-copy.c @@ -42,6 +42,9 @@ typedef struct BlockCopyCallState { /* Coroutine where async block-copy is running */ Coroutine *co; + /* To reference all call states from BlockCopyState */ + QLIST_ENTRY(BlockCopyCallState) list; + /* State */ int ret; bool finished; @@ -81,7 +84,8 @@ typedef struct BlockCopyState { bool use_copy_range; int64_t copy_size; uint64_t len; - QLIST_HEAD(, BlockCopyTask) tasks; + QLIST_HEAD(, BlockCopyTask) tasks; /* All tasks from all block-copy calls */ + QLIST_HEAD(, BlockCopyCallState) calls; BdrvRequestFlags write_flags; @@ -282,6 +286,7 @@ BlockCopyState *block_copy_state_new(BdrvChild *source, BdrvChild *target, } QLIST_INIT(&s->tasks); + QLIST_INIT(&s->calls); return s; } @@ -669,6 +674,8 @@ static int coroutine_fn block_copy_common(BlockCopyCallState *call_state) { int ret; + QLIST_INSERT_HEAD(&call_state->s->calls, call_state, list); + do { ret = block_copy_dirty_clusters(call_state); @@ -694,6 +701,8 @@ static int coroutine_fn block_copy_common(BlockCopyCallState *call_state) call_state->cb(call_state->cb_opaque); } + QLIST_REMOVE(call_state, list); + return ret; } From patchwork Mon Oct 26 17:17:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 301988 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ABFE8C4363A for ; Mon, 26 Oct 2020 17:29:12 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 21A792223C for ; Mon, 26 Oct 2020 17:29:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="i4MGdT6T" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 21A792223C Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:32970 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kX6Ix-0004mM-3g for qemu-devel@archiver.kernel.org; Mon, 26 Oct 2020 13:29:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49492) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kX68w-0007ba-2o; Mon, 26 Oct 2020 13:18:50 -0400 Received: from mail-vi1eur05on2123.outbound.protection.outlook.com ([40.107.21.123]:17409 helo=EUR05-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kX68r-0008Ou-NT; Mon, 26 Oct 2020 13:18:49 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XglJM9E9Y+MXEYcTRVrpc298MFCurQuq3xKyORpz95l36hO8t6CvBIONSRiAbhSus38VVEOehEwdy9mnVvZE9QLPJ1Em8Kk1M5xVa85A6FwHmZJgSuIcn8iWMLRvEAqDZWpYkJ6KxDN1xstFNd8RsJLRwZPCmzpbaa26FBwQdgDh4pa4cLCzinBCVN8zuUNJpJzCdM4z731rc959MUPcTE4Gjxz1IL7mcuWUM99gIPDb4zlsacjsjfAd2sonSjQ+YFT679LbW3dyCGZ3XLfkY5FB09/FSbBUlq7iBliB0XB51+QQIMT4G2/Fy8SOBE5b636AJo7Y5BvQol8ebdGaDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/FJxWFu0ssGxkP4CBqP5rlHBIdGZcS9/F1/50aGq6yM=; b=Kr9hZE7SmlUnMoSppKd/sae7AlSH748Ehyu9QhfnFkvq3XsxfTbHCQneHPbXUXQn+bDBbLHFXaJO9epkk/GpTzJ5hgCvDKl7VXqe5rQXwqCwfCgi7c0gaAoejiO2EtExZfuFxsWlJv8k/8xXK/IXDOzZjvUwvVOzjg/HjfinNEf20zdXLT+dXrmffuGLQYNCsEmPeOPTtQeyClkpm0QAo6Sa5USHX3wMt4nYod5bZgpubO2oA0+X3MdrjELhew1x1vQ1pwxHqXA23bLF+kJeOfqITB8I0ufyVxSjo3UADdnGPZENtNivl1VXm0Fh2ncFME/f8FyorrSNC4dnwbAEMA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/FJxWFu0ssGxkP4CBqP5rlHBIdGZcS9/F1/50aGq6yM=; b=i4MGdT6TmrwBG9ZjgqkXfwxtyDJyQJne6BVWfEzdRnLegBqMTHIFFt4LmF86ru9iHi3zqrWhXhB6e6TiXg8lT1d1VB8Kljnu/tfUMZRpswoCx7aHINQhlma/6xNY4XVrCxbp43Fskj4jPODUL6jLNvIva9WEgRrrDMRxnG3eGn0= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB3032.eurprd08.prod.outlook.com (2603:10a6:209:43::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18; Mon, 26 Oct 2020 17:18:36 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243%9]) with mapi id 15.20.3499.018; Mon, 26 Oct 2020 17:18:36 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, vsementsov@virtuozzo.com, eblake@redhat.com, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, jsnow@redhat.com, mreitz@redhat.com, kwolf@redhat.com, den@openvz.org Subject: [PATCH v3 07/25] block/block-copy: add ratelimit to block-copy Date: Mon, 26 Oct 2020 20:17:57 +0300 Message-Id: <20201026171815.13233-8-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201026171815.13233-1-vsementsov@virtuozzo.com> References: <20201026171815.13233-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.99] X-ClientProxiedBy: AM0PR02CA0101.eurprd02.prod.outlook.com (2603:10a6:208:154::42) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.99) by AM0PR02CA0101.eurprd02.prod.outlook.com (2603:10a6:208:154::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Mon, 26 Oct 2020 17:18:35 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f6e2d5f7-edc0-4e79-7a35-08d879d32c29 X-MS-TrafficTypeDiagnostic: AM6PR08MB3032: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:372; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xVNK34rQsHfbIuuajnVTtp/BEJZZPReC43VLo5piUUmm+SeeddBJKKyEY6IjAcz9M3BNySCOg5wLS3xEu3vBzLP0gIPIcxKaebvXpmA8xbPia84PMZQod6JxjQXIGVHvYCgGKuhz+RqtH4EHxH6TZh8G1QH0X7c2ctZDT3EmW9tybzGJLEmEl3sZwzqyWzsbq2H2fTpc5Q+un88cprAYauMVhbxMRbvoA6X6T8D6ZvZPcYg226SuU6WYBUNCp5ClU4qJfkTkUl1IcEfAZZeZnA087jBhLECuaLKyLwweqlsXIJzYi5ZLPJCeBPwstkT2s2IrzZc7wursFikdDBLDMA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(136003)(366004)(376002)(346002)(396003)(39840400004)(66476007)(8936002)(5660300002)(316002)(6506007)(6512007)(2616005)(66946007)(956004)(66556008)(6666004)(26005)(4326008)(36756003)(478600001)(52116002)(1076003)(16526019)(83380400001)(2906002)(186003)(6916009)(8676002)(107886003)(86362001)(6486002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: EXyZx3B58n1Nv23a1uv2w2gSGIBKEuX4cUX/unzo1ufd8O8f2r+BdyVkgnueagOg7qQbA+PMUrQkmb8iK5cJu93maSUUJDo9VudIqPu/w2OqALfrNvnf0vEe8WyHXEdQ9GorCS4zkLs0PbAyddgf5UbeSOfSpYpQWj8OWdNXT2K4Ie/2DWIEDIlSvUlAEtW3BJCwwUvuWEnxsN9G737CZ0yzn/lIdfXOqYc6q0JOhvIpmGN4MSaVsWO0X5JqRPYRL71c4tvVTfwyN9ZhOh25tSp7Hd3zXUZ4nqF73Lp4xkosESQNKWBhWdHIkcPtQQx8CflgO0bPVrrY24xSISAPLk18tpC/1bmu1oJT/kVnLRTIGtgN2XWafDVfDeg8NQ/+V8hmaYgS02HN4kiYsTqZ6f/ciq4TwjCYIK1kQy4wpckbg6gSvD44SdGFfYYokBFx2N1mjHHEM2eHVUYCLcwuwYgdEfHQ8giUaHaQOAuvck1sl7JKlHVDP2CqsS4J/cFhPqfZG0csjdsKiG2UvK5WRWZG3uxGFZPVtCSfcGAKyNWArjabOmPQCS6Hb398U+bbzGoCdcvL36treianT9d4+81mcVIzVfuo2UMFeNSm+xEJXVwTmj9RNzjWitbKsxyRolkakWMV1gglprlFevIz1A== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: f6e2d5f7-edc0-4e79-7a35-08d879d32c29 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Oct 2020 17:18:36.0096 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: JJxHjt/+Q6ZzahQqvpzfWYnnwsC9HHdyzRXDQ1S9Q+Io2GBNLbpg1qbkarNe4oiY4ggVPIHDr4jxXGmrUsv75f6RR6c4ns07SZ0F5wkgMFI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3032 Received-SPF: pass client-ip=40.107.21.123; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/26 13:18:43 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" We are going to directly use one async block-copy operation for backup job, so we need rate limiter. We want to maintain current backup behavior: only background copying is limited and copy-before-write operations only participate in limit calculation. Therefore we need one rate limiter for block-copy state and boolean flag for block-copy call state for actual limitation. Note, that we can't just calculate each chunk in limiter after successful copying: it will not save us from starting a lot of async sub-requests which will exceed limit too much. Instead let's use the following scheme on sub-request creation: 1. If at the moment limit is not exceeded, create the request and account it immediately. 2. If at the moment limit is already exceeded, drop create sub-request and handle limit instead (by sleep). With this approach we'll never exceed the limit more than by one sub-request (which pretty much matches current backup behavior). Note also, that if there is in-flight block-copy async call, block_copy_kick() should be used after set-speed to apply new setup faster. For that block_copy_kick() published in this patch. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Max Reitz --- include/block/block-copy.h | 5 ++++- block/backup-top.c | 2 +- block/backup.c | 2 +- block/block-copy.c | 46 +++++++++++++++++++++++++++++++++++++- 4 files changed, 51 insertions(+), 4 deletions(-) diff --git a/include/block/block-copy.h b/include/block/block-copy.h index 57806e8a49..0fab64e12a 100644 --- a/include/block/block-copy.h +++ b/include/block/block-copy.h @@ -41,7 +41,7 @@ int64_t block_copy_reset_unallocated(BlockCopyState *s, int64_t offset, int64_t *count); int coroutine_fn block_copy(BlockCopyState *s, int64_t offset, int64_t bytes, - bool *error_is_read); + bool ignore_ratelimit, bool *error_is_read); /* * Run block-copy in a coroutine, create corresponding BlockCopyCallState @@ -73,6 +73,9 @@ bool block_copy_call_succeeded(BlockCopyCallState *call_state); bool block_copy_call_failed(BlockCopyCallState *call_state); int block_copy_call_status(BlockCopyCallState *call_state, bool *error_is_read); +void block_copy_set_speed(BlockCopyState *s, uint64_t speed); +void block_copy_kick(BlockCopyCallState *call_state); + BdrvDirtyBitmap *block_copy_dirty_bitmap(BlockCopyState *s); void block_copy_set_skip_unallocated(BlockCopyState *s, bool skip); diff --git a/block/backup-top.c b/block/backup-top.c index 789acf6965..779956ddc2 100644 --- a/block/backup-top.c +++ b/block/backup-top.c @@ -61,7 +61,7 @@ static coroutine_fn int backup_top_cbw(BlockDriverState *bs, uint64_t offset, off = QEMU_ALIGN_DOWN(offset, s->cluster_size); end = QEMU_ALIGN_UP(offset + bytes, s->cluster_size); - return block_copy(s->bcs, off, end - off, NULL); + return block_copy(s->bcs, off, end - off, true, NULL); } static int coroutine_fn backup_top_co_pdiscard(BlockDriverState *bs, diff --git a/block/backup.c b/block/backup.c index 4b07e9115d..09ff5a92ef 100644 --- a/block/backup.c +++ b/block/backup.c @@ -72,7 +72,7 @@ static int coroutine_fn backup_do_cow(BackupBlockJob *job, trace_backup_do_cow_enter(job, start, offset, bytes); - ret = block_copy(job->bcs, start, end - start, error_is_read); + ret = block_copy(job->bcs, start, end - start, true, error_is_read); trace_backup_do_cow_return(job, offset, bytes, ret); diff --git a/block/block-copy.c b/block/block-copy.c index 6bf1735b93..fa27450b14 100644 --- a/block/block-copy.c +++ b/block/block-copy.c @@ -26,6 +26,7 @@ #define BLOCK_COPY_MAX_BUFFER (1 * MiB) #define BLOCK_COPY_MAX_MEM (128 * MiB) #define BLOCK_COPY_MAX_WORKERS 64 +#define BLOCK_COPY_SLICE_TIME 100000000ULL /* ns */ static coroutine_fn int block_copy_task_entry(AioTask *task); @@ -36,6 +37,7 @@ typedef struct BlockCopyCallState { int64_t bytes; int max_workers; int64_t max_chunk; + bool ignore_ratelimit; BlockCopyAsyncCallbackFunc cb; void *cb_opaque; @@ -48,6 +50,7 @@ typedef struct BlockCopyCallState { /* State */ int ret; bool finished; + QemuCoSleepState *sleep_state; /* OUT parameters */ bool error_is_read; @@ -111,6 +114,9 @@ typedef struct BlockCopyState { void *progress_opaque; SharedResource *mem; + + uint64_t speed; + RateLimit rate_limit; } BlockCopyState; static BlockCopyTask *find_conflicting_task(BlockCopyState *s, @@ -623,6 +629,21 @@ block_copy_dirty_clusters(BlockCopyCallState *call_state) } task->zeroes = ret & BDRV_BLOCK_ZERO; + if (s->speed) { + if (!call_state->ignore_ratelimit) { + uint64_t ns = ratelimit_calculate_delay(&s->rate_limit, 0); + if (ns > 0) { + block_copy_task_end(task, -EAGAIN); + g_free(task); + qemu_co_sleep_ns_wakeable(QEMU_CLOCK_REALTIME, ns, + &call_state->sleep_state); + continue; + } + } + + ratelimit_calculate_delay(&s->rate_limit, task->bytes); + } + trace_block_copy_process(s, task->offset); co_get_from_shres(s->mem, task->bytes); @@ -661,6 +682,13 @@ out: return ret < 0 ? ret : found_dirty; } +void block_copy_kick(BlockCopyCallState *call_state) +{ + if (call_state->sleep_state) { + qemu_co_sleep_wake(call_state->sleep_state); + } +} + /* * block_copy_common * @@ -707,12 +735,13 @@ static int coroutine_fn block_copy_common(BlockCopyCallState *call_state) } int coroutine_fn block_copy(BlockCopyState *s, int64_t start, int64_t bytes, - bool *error_is_read) + bool ignore_ratelimit, bool *error_is_read) { BlockCopyCallState call_state = { .s = s, .offset = start, .bytes = bytes, + .ignore_ratelimit = ignore_ratelimit, .max_workers = BLOCK_COPY_MAX_WORKERS, }; @@ -798,3 +827,18 @@ void block_copy_set_skip_unallocated(BlockCopyState *s, bool skip) { s->skip_unallocated = skip; } + +void block_copy_set_speed(BlockCopyState *s, uint64_t speed) +{ + s->speed = speed; + if (speed > 0) { + ratelimit_set_speed(&s->rate_limit, speed, BLOCK_COPY_SLICE_TIME); + } + + /* + * Note: it's good to kick all call states from here, but it should be done + * only from a coroutine, to not crash if s->calls list changed while + * entering one call. So for now, the only user of this function kicks its + * only one call_state by hand. + */ +} From patchwork Mon Oct 26 17:17:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 301981 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8B472C56202 for ; Mon, 26 Oct 2020 17:44:03 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E3C7722281 for ; Mon, 26 Oct 2020 17:44:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="ctZ4Idxg" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E3C7722281 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:42176 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kX6XJ-0004Fk-W2 for qemu-devel@archiver.kernel.org; Mon, 26 Oct 2020 13:44:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49474) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kX68t-0007Y8-D2; Mon, 26 Oct 2020 13:18:48 -0400 Received: from mail-eopbgr60093.outbound.protection.outlook.com ([40.107.6.93]:39555 helo=EUR04-DB3-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kX68q-0008NC-9O; Mon, 26 Oct 2020 13:18:47 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PkhlOYgKWN27fypWiWZ2+trKNaRgUrbBWpMihgd/018jZpDJOppuTdtKuI5dCW58qUA+HJlwqIItYc54AOpmVtuRvyNioXsyslXL5WBNxFbGGnd0hWc0iyZi1LYllTTX6TPJ9W0gpveHwmyxY66UFxa4ByHaH91N1LPMZUQbwe+S4R2YsKOE4CqJBS+ObSjiBpEnerWMQpTkzL+qSYYYfoi9CoVLcoI2nnLdrXLAMkjCk8PAvASytQ0gAnsnlCnC+UxUbYxzjZk9wOoqCSozq8hrBIQAOs2VAh4gCDhdpIKRt3T2ITk4wSYKtbevEypBgay83myjkjtHv+TavIX64A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Uo3lPvSWoICg4mWpyysOfZpppQDoSRAWD6WvkMvBuGY=; b=BJ/LsUhgWuTz9Y8OAbeuBj5GBhwuRUasHAPdbS5AbSNAfZWTEmCLEvfuBO1sSVZKZuB8ToPiD6wbts7uck1InXJ5/NJEi9yRlR2+nub6EQRpTm8CV/WU5wurADTniirvSOHMqNFoy4uJoQ6Y+orqKha1GTXp9ffYIYJpqiHoUD84be5su4a04EeYw5rin4fS9nZ12BlJPxe2NMA0K0B2hKTrzYZPwbVp1A12MUcRY/57a2VtDUkZ5T+K+TNj53VfSQANPzkEa0zpX5l7cfZqhzCqs2X++kEexUv1hsLoGD23QUHB4Q4rdWSwRsZN8dOxn+t8RaLtUDHbaODt4vwrmw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Uo3lPvSWoICg4mWpyysOfZpppQDoSRAWD6WvkMvBuGY=; b=ctZ4IdxgKLUsFlQbv8KKGt7Ueap53Ny1krMstEGPpb/4PgB2Kt9UKOJ0T9DjUYLcFeg0WszIENcwoerRUkCbmYBmTjk+JGiu0lddeLK5k57b/5TkXatl+cj0UONtV5G75gkiQMvKXqx6ryfXybjH4YrGrdNx0Futnscyo3LVaWo= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB3032.eurprd08.prod.outlook.com (2603:10a6:209:43::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18; Mon, 26 Oct 2020 17:18:36 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243%9]) with mapi id 15.20.3499.018; Mon, 26 Oct 2020 17:18:36 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, vsementsov@virtuozzo.com, eblake@redhat.com, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, jsnow@redhat.com, mreitz@redhat.com, kwolf@redhat.com, den@openvz.org Subject: [PATCH v3 08/25] block/block-copy: add block_copy_cancel Date: Mon, 26 Oct 2020 20:17:58 +0300 Message-Id: <20201026171815.13233-9-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201026171815.13233-1-vsementsov@virtuozzo.com> References: <20201026171815.13233-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.99] X-ClientProxiedBy: AM0PR02CA0101.eurprd02.prod.outlook.com (2603:10a6:208:154::42) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.99) by AM0PR02CA0101.eurprd02.prod.outlook.com (2603:10a6:208:154::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Mon, 26 Oct 2020 17:18:36 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c686fb0d-1c80-4cb5-0433-08d879d32caf X-MS-TrafficTypeDiagnostic: AM6PR08MB3032: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:233; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: f4SmKdTtipe1RXg6P+8icZso/isgi2DvzGRV5WS8ELG6oGEWDuryvX8E6/YgkPhVbxNClC+aFw74+3IlfViCk7OAPxA5l2wYEDMs+D9xx/TWELKKhE8Vl3IK8Y3BvOyUp7f10l9qDXy6sOTNfGgWlhK2Qmi6wt+xkFPTsthi1qYIqoWcpN2BXtpQjBaFNLahTpRMhwj6saAu6jtetewMyYuWbcW9PTe5l70DrakRo6CQGM1EW+bo2HktCOa4rYNmyi5Erjcs6XOl0mh3PP3AX4rTiEECJ1mqV7skQx1gIQFMPX+hSqKSTVH57RG09UahTwv34m/gdHPg4VJGGO3Elw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(136003)(366004)(376002)(346002)(396003)(39840400004)(66476007)(8936002)(5660300002)(316002)(6506007)(6512007)(2616005)(66946007)(956004)(66556008)(6666004)(26005)(4326008)(36756003)(478600001)(52116002)(1076003)(16526019)(83380400001)(2906002)(186003)(6916009)(8676002)(107886003)(86362001)(6486002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: yroLyZ4w2bWwN8aBsBPEK+GhFl4rMOXICigRM60lbybXw3O/sEQTEAjjdzODueqP9obqMfNKo4B1f+5aLQiFh4AxUBaZ0/DA2AWtbZ/+ZtMDvqONG84fzk3+JrReiST+Qp0BcHtx7mYDOvYNAteRuDw4oUfgVm87e+3u2mnLIBmskU7qt3uthtiWdfLVZWhEehmAVFiRTtBq513e3Y3MzADNELLEqBj4oXSKXa6iTdNMG8x50yvyyol1Q7bzMmSFFQQIzF8jXwKqIXGUUOP1JaVTvcMmR/6T4PFwACYo9gIY4K9AtwwTPPUvS+659GeLkaSEnrRJmYEztdjqbSgavmC1Z/41LCFJDFcsUSsuDJY9CK0ay3MR7Mkx0rlJjYMtpCyZ/a7RS+q6PV5D7sjJgYbrMNUMkjBb0n2TqezhS/dF+15pkGJ8yo3FPqj59NB/Zmu1NPo07Cxrl17SQTrjaqMC4++OcVW11VkTi/eYjdSGroxjl0ANHMROxrs3aPKijO2uWpJT+QJB+eKcl8ltJ/thTRtF1eT4JX/TIEZPH7AkL5IyXkoTU278dg/RTvONo7O6KDZO79arjPmiP+iBYlFcZjYPb77FAxZLBM+ebo1GAr9VIAe1Vhp7M6mwC26cklz46BwydC/Pp5ydVai2PA== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: c686fb0d-1c80-4cb5-0433-08d879d32caf X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Oct 2020 17:18:36.9006 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Dmlg6BoPa1Dxq3303oR4rDWaXLdE/Muom2x7rsldU8iq+N6RdcfiyNOs/PwsxduEoU4DbKP2hHu5ud9qqgG9RxHday+rjx598IqaMvr2hJI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3032 Received-SPF: pass client-ip=40.107.6.93; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-DB3-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/26 13:18:35 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Add function to cancel running async block-copy call. It will be used in backup. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Max Reitz --- include/block/block-copy.h | 13 +++++++++++++ block/block-copy.c | 24 +++++++++++++++++++----- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/include/block/block-copy.h b/include/block/block-copy.h index 0fab64e12a..8f5013d0aa 100644 --- a/include/block/block-copy.h +++ b/include/block/block-copy.h @@ -71,11 +71,24 @@ void block_copy_call_free(BlockCopyCallState *call_state); bool block_copy_call_finished(BlockCopyCallState *call_state); bool block_copy_call_succeeded(BlockCopyCallState *call_state); bool block_copy_call_failed(BlockCopyCallState *call_state); +bool block_copy_call_cancelled(BlockCopyCallState *call_state); int block_copy_call_status(BlockCopyCallState *call_state, bool *error_is_read); void block_copy_set_speed(BlockCopyState *s, uint64_t speed); void block_copy_kick(BlockCopyCallState *call_state); +/* + * Cancel running block-copy call. + * + * Cancel leaves block-copy state valid: dirty bits are correct and you may use + * cancel + to emulate pause/resume. + * + * Note also, that the cancel is async: it only marks block-copy call to be + * cancelled. So, the call may be cancelled (block_copy_call_cancelled() reports + * true) but not yet finished (block_copy_call_finished() reports false). + */ +void block_copy_call_cancel(BlockCopyCallState *call_state); + BdrvDirtyBitmap *block_copy_dirty_bitmap(BlockCopyState *s); void block_copy_set_skip_unallocated(BlockCopyState *s, bool skip); diff --git a/block/block-copy.c b/block/block-copy.c index fa27450b14..82cf945693 100644 --- a/block/block-copy.c +++ b/block/block-copy.c @@ -51,6 +51,7 @@ typedef struct BlockCopyCallState { int ret; bool finished; QemuCoSleepState *sleep_state; + bool cancelled; /* OUT parameters */ bool error_is_read; @@ -594,7 +595,7 @@ block_copy_dirty_clusters(BlockCopyCallState *call_state) assert(QEMU_IS_ALIGNED(offset, s->cluster_size)); assert(QEMU_IS_ALIGNED(bytes, s->cluster_size)); - while (bytes && aio_task_pool_status(aio) == 0) { + while (bytes && aio_task_pool_status(aio) == 0 && !call_state->cancelled) { BlockCopyTask *task; int64_t status_bytes; @@ -707,7 +708,7 @@ static int coroutine_fn block_copy_common(BlockCopyCallState *call_state) do { ret = block_copy_dirty_clusters(call_state); - if (ret == 0) { + if (ret == 0 && !call_state->cancelled) { ret = block_copy_wait_one(call_state->s, call_state->offset, call_state->bytes); } @@ -721,7 +722,7 @@ static int coroutine_fn block_copy_common(BlockCopyCallState *call_state) * 2. We have waited for some intersecting block-copy request * It may have failed and produced new dirty bits. */ - } while (ret > 0); + } while (ret > 0 && !call_state->cancelled); call_state->finished = true; @@ -801,12 +802,19 @@ bool block_copy_call_finished(BlockCopyCallState *call_state) bool block_copy_call_succeeded(BlockCopyCallState *call_state) { - return call_state->finished && call_state->ret == 0; + return call_state->finished && !call_state->cancelled && + call_state->ret == 0; } bool block_copy_call_failed(BlockCopyCallState *call_state) { - return call_state->finished && call_state->ret < 0; + return call_state->finished && !call_state->cancelled && + call_state->ret < 0; +} + +bool block_copy_call_cancelled(BlockCopyCallState *call_state) +{ + return call_state->cancelled; } int block_copy_call_status(BlockCopyCallState *call_state, bool *error_is_read) @@ -818,6 +826,12 @@ int block_copy_call_status(BlockCopyCallState *call_state, bool *error_is_read) return call_state->ret; } +void block_copy_call_cancel(BlockCopyCallState *call_state) +{ + call_state->cancelled = true; + block_copy_kick(call_state); +} + BdrvDirtyBitmap *block_copy_dirty_bitmap(BlockCopyState *s) { return s->copy_bitmap; From patchwork Mon Oct 26 17:18:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 301987 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 195ADC4363A for ; Mon, 26 Oct 2020 17:32:30 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9A63F2071A for ; Mon, 26 Oct 2020 17:32:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="q+vmqlEU" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9A63F2071A Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:41546 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kX6M8-0008SJ-Gh for qemu-devel@archiver.kernel.org; Mon, 26 Oct 2020 13:32:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49580) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kX693-0007qJ-Jg; Mon, 26 Oct 2020 13:18:57 -0400 Received: from mail-vi1eur05on2092.outbound.protection.outlook.com ([40.107.21.92]:44161 helo=EUR05-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kX691-0008QM-SV; Mon, 26 Oct 2020 13:18:57 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BNsCApa3vhe0rGtjBsXuhe3tBytyYcB7Ke8DAkvY2jSoBPmLFBJlj2eoq4UIW7FUrAhDDRxF+PcAwfpxw2tL2BO/CXs20xy+FKaUUeJJfE/y1ZZwCuvKAmPMKyoy2MTvmoPgbn8mkwBliPfoIu9iwOS9qIYA24bzj5wRQnExkuh5OiM3iPrM1KHY4MDhgwiiLpSqrmmEeGetTQ+12FIAzpdiZd9t5Vh33cjnAn+Y9RpICWUTI+AdIrWZeOXfnVXKyME4v/yMGr1ybNqWXU1h4ci6J/QJueNUWAXVN5VFg4ql5HBsCwOQ2vb3PDC+ClAiCPfhxokEZwBwXi6PS9G48A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=USpBnH0YGGjaFPx580wvgDTym9L2LgIDWFDQzHKJyzQ=; b=Wwg+1ewHrBiAcVfMLElxWV6pl5njWO8U5uu8RPkSgGH96Yw9DaBx9Kg0zmkmBFt9pfxPVz9S4YrCEA50322KRsoAhK0kn+UgXYEw1+lgKnwFxKiaK4JIgnkTz6rehgP3F92nunexS0yxSeLYk9ei/hpIG7CHz+l8fPj2RY+aXSQ1NHQ/Cvn53JYUQvCqJpA+9I4k3PQfht7P+L3VTpJh4Tlu+XK7RjbzVnDxznsQzQKI3J74DPXu07QIaUXfCRCZFFny5i3FID3XOpJ6xbVQTP24XrkhkOL08/4Khxwa+IFFAjt+3mgHWLE5Sqe4r4oYSmnqwADtsoLW86j8pYsGAA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=USpBnH0YGGjaFPx580wvgDTym9L2LgIDWFDQzHKJyzQ=; b=q+vmqlEUOaPpmNGpmgodzcYXjxPkqmgIFTaGh9+vU1j+SxUN04JQxIy7m3qiHdKlm0E0+s2w1wNhHMTKHiB4qfBwK+Q2NII22Plm/m34ZwIrJEUzNtnetgINuC3KoFw8yBTV4k8jQzis4bmHKaVZAd2ws9V8aH/MRKLUMJJS5dM= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB3032.eurprd08.prod.outlook.com (2603:10a6:209:43::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18; Mon, 26 Oct 2020 17:18:41 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243%9]) with mapi id 15.20.3499.018; Mon, 26 Oct 2020 17:18:41 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, vsementsov@virtuozzo.com, eblake@redhat.com, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, jsnow@redhat.com, mreitz@redhat.com, kwolf@redhat.com, den@openvz.org Subject: [PATCH v3 13/25] iotests: 129: prepare for backup over block-copy Date: Mon, 26 Oct 2020 20:18:03 +0300 Message-Id: <20201026171815.13233-14-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201026171815.13233-1-vsementsov@virtuozzo.com> References: <20201026171815.13233-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.99] X-ClientProxiedBy: AM0PR02CA0101.eurprd02.prod.outlook.com (2603:10a6:208:154::42) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.99) by AM0PR02CA0101.eurprd02.prod.outlook.com (2603:10a6:208:154::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Mon, 26 Oct 2020 17:18:40 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fd16f407-f256-41d4-6269-08d879d32f58 X-MS-TrafficTypeDiagnostic: AM6PR08MB3032: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:88; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Ygo+S5468hW/V3KHeSDQtaeS3Xedppex+WpmmObYJ7sXOWgAprJN/CwL621v5QHq3gEGIgZji7+WJA+3tkP83iYDQykeEjk24ryrOkGr0hjzUxjzksEqTUw90c5cCn7MGwFPQloxQRRT711OOXJw0kj8erTDeXwydpKjI0sauVzdMm8lLrWsagAASBe4U7vqnY/pVK3YY1fc3rZMmoWVJtNJPv93h3L/sIM8uGH6QDNCPIFOk/EWjVILGW2VVOZJqnTujm9NMkSS0ZeCJThyJX0ey7GTGiRDu5z+C+Yup++Qxf+ijkiJf8LPt/65yx/mmXBUKx0XUeyyirGZYZ7FPQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(136003)(366004)(376002)(346002)(396003)(39840400004)(66476007)(8936002)(5660300002)(316002)(6506007)(6512007)(2616005)(66946007)(956004)(66556008)(6666004)(26005)(4326008)(36756003)(478600001)(52116002)(1076003)(16526019)(83380400001)(2906002)(186003)(6916009)(8676002)(107886003)(86362001)(6486002)(4744005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: ko8DY2oDSB43GDKnEdmB7ZpilMwm6DMFN0Cmfr1y4F80oNDCYga3Qe9lfVbQT+DWbKbHcDyGc84M3g8LAufx42UHUcEYEjHZah++NJa4PIOXla59nHlbB8tJrSu0aGAabnuoxjMRoSJcE4Sm821KQCGPAHz11KQGM0SKCyeguvw1mizH40+oLteXWSROS9AnhA+viVf0rJrRm1kplWds0aMGTNN4TTkmlTzr3JXDrQc+ucoEYuxMeo7WyFsc++DSjSVgPh+mg6r5KYv3NWvgeafDsoJxGE5dFTiZqsSTfYG7k+v9FXFpE3xvE9eXYu9T3cUxjzioAMZ9kIfEBw5DiN4vpSQEzCA6RisWofLhrnZHBPV2/c2lJJV9ueFvOi5wSCsea1jBImJCOsO3pggiCvvOAGU9vPAy7i/fe4dCzytIHSlqIEatofDQG9Tzj/ybctaiXnW1H4oHjJ5PNSpr/1JyRyIg7tf0/zNvC0tAsRD4pYNoij+yBIqPU+94CyFUTAYFnhrJHHCEDP7XgrIJJvqEgOJ7X2sbRLckXE1jRufxa56DSLxNSEV5b45dP6eUsjzm3j/dsWDUgZXlNksSDoEke9K7bwYY7Zqp26qLqJKsEUlwAMJaBhXflcozNjQsVeNAU0MnBzjuylKQI6JLOQ== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: fd16f407-f256-41d4-6269-08d879d32f58 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Oct 2020 17:18:41.3939 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: J/8tY/0chAYrkQVtWKNbrZYFbGX6FAFXuz8NgloNGpXVaJVukC01UkcQaGP727UfoKCXEEYCiJMbZjzem2yejnogxT6QQ+YmI3EWqWvMC/M= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3032 Received-SPF: pass client-ip=40.107.21.92; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/26 13:18:53 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" After introducing parallel async copy requests instead of plain cluster-by-cluster copying loop, backup job may finish earlier than final assertion in do_test_stop. Let's require slow backup explicitly by specifying speed parameter. Signed-off-by: Vladimir Sementsov-Ogievskiy Acked-by: Max Reitz --- tests/qemu-iotests/129 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/qemu-iotests/129 b/tests/qemu-iotests/129 index 3c22f6448c..e9da0208c4 100755 --- a/tests/qemu-iotests/129 +++ b/tests/qemu-iotests/129 @@ -77,7 +77,7 @@ class TestStopWithBlockJob(iotests.QMPTestCase): def test_drive_backup(self): self.do_test_stop("drive-backup", device="drive0", target=self.target_img, - sync="full") + sync="full", speed=1024) def test_block_commit(self): self.do_test_stop("block-commit", device="drive0") From patchwork Mon Oct 26 17:18:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 301980 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2E5A3C4363A for ; Mon, 26 Oct 2020 17:46:11 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 963DB2225C for ; Mon, 26 Oct 2020 17:46:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="vjkjUEzY" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 963DB2225C Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:48800 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kX6ZN-00075F-KQ for qemu-devel@archiver.kernel.org; Mon, 26 Oct 2020 13:46:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49584) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kX694-0007rM-0y; Mon, 26 Oct 2020 13:18:58 -0400 Received: from mail-vi1eur05on2123.outbound.protection.outlook.com ([40.107.21.123]:17409 helo=EUR05-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kX692-0008Ou-3X; Mon, 26 Oct 2020 13:18:57 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lCAqR1l/v2nVXGxXDJGqxzO71wYuUm0bk7ap+R70pgNzhLXwUmGqrmoZB82aT3F/T7yvpfFQDXynwdx/0AFj8xugekZhWDrC7lvM/mqYqm+op6enJ9Ui+w2pW8AKDzSXNmmNF6yhAjxL4uyHJPXIoU7uT0E0P1b3apiY6AY7v7xY2LHj1eZrqbl6cBp0P0ouslTWABFs6bhhMFek1ThjXhLy3DzW3QzgNK5vtiP2VxQXHxBp9ACtdOw54pXoLMIpq+kFQxEwnpzrYcuOOZSGgB9cqW9tbHqvKHZjJy3Am64lo999agnwYIPNWy8n685ld35MEFzweQegAcO/trbH4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LpYN+l2AfTKEbgTJ0TxBN5MZZEqrVqBPTG59eQShWXA=; b=GSi7G5pOwFspCs6r6BjgmRgusiBKFOIgH9d/H3RW86RvOM8/xLax8OYomjRDd59qUS94iS3Kcyp8Hj8m44XhoVPsAVwN8LpcAiqfh4wrYjz4PnYXPF3TVfwCi2i+15CCD6ZfrOguTDU7R5+uZs+NpsqFoF4+8WlxJD8Ex+YCfYT4PIuoOkxk8DTpQ9gIxplYN99/z/iU0QeMssIRN7EgbeyT18kARPnPFRb8GmkKhN8K/fwEaoU3LKgFs0cOQN4hgZJzsktI8E+0Hj8ZOxWL8VO/4IcTZMT8tFyq4U3pwSNU6MLqP8L+TSKUr0lfR4qMYFEKlkyNzEb8bmWbA/RejA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LpYN+l2AfTKEbgTJ0TxBN5MZZEqrVqBPTG59eQShWXA=; b=vjkjUEzY77YbnAIN6OH/7VAml16krASQoVx2s9IY+VS9q/gmKjGd3Stmvv/1V4cagnHfSl6F/X2OlCoxzBryHPV7JiVtEh6LIr906Xi/NvYeL8xW8ST1zMp1RLXV5/V1l+lSAcMtWiM3wexvA9LpGXMnvd46DRNSE+jpF/Irxjc= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB3032.eurprd08.prod.outlook.com (2603:10a6:209:43::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18; Mon, 26 Oct 2020 17:18:43 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243%9]) with mapi id 15.20.3499.018; Mon, 26 Oct 2020 17:18:43 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, vsementsov@virtuozzo.com, eblake@redhat.com, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, jsnow@redhat.com, mreitz@redhat.com, kwolf@redhat.com, den@openvz.org Subject: [PATCH v3 15/25] iotests: 219: prepare for backup over block-copy Date: Mon, 26 Oct 2020 20:18:05 +0300 Message-Id: <20201026171815.13233-16-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201026171815.13233-1-vsementsov@virtuozzo.com> References: <20201026171815.13233-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.99] X-ClientProxiedBy: AM0PR02CA0101.eurprd02.prod.outlook.com (2603:10a6:208:154::42) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.99) by AM0PR02CA0101.eurprd02.prod.outlook.com (2603:10a6:208:154::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Mon, 26 Oct 2020 17:18:42 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3af09277-ed1f-4e9c-1f3c-08d879d3306c X-MS-TrafficTypeDiagnostic: AM6PR08MB3032: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9wnUTMUNrXbwJsAFE6j/RDjz51n/3xbZ4aOQPFWwo3zkixNLlhCKSgW/aLczYc1b2++qujFvSB9vAhLT0CdtZCbmDoSAk4g2ze90q0xsPDBQBcGFYKOvkiIGy51UOe72uW9TibWiD+Jh+6hf/dcT50B8Ff6TLONtgAy35UDBx4Eau49Gmd3Ci7wrT5ET5LuweKFGjb1EU4YR8LQoKBYr6j/BLQn99asbLEKmYJ+ep6V30TF1noMc9+UF12M3UQcya/e/Gp/eHHR+z9Uf+MBsnc2kYDK5pF0UmZ362ilHdUqPKTsXJdSypAhVWAWovoNT18rW6laA3vSQx4PUGFE2TQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(136003)(366004)(376002)(346002)(396003)(39840400004)(66476007)(8936002)(5660300002)(316002)(6506007)(6512007)(2616005)(66946007)(956004)(66556008)(6666004)(26005)(4326008)(36756003)(478600001)(52116002)(1076003)(16526019)(83380400001)(2906002)(186003)(6916009)(8676002)(107886003)(86362001)(6486002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: wnmGV8F4QFBuiJky4h4wU06I9tTkO3eUJ8A8z9zlcf8XnqBWWNpvpEr6ebbibb5ebyK6Y+6RP0Ec7W9qZQ1ZYQOdVm6Bh9fspDG3oiRRSjiQ4NHd7F1BiiaqEmM1YiApBFMLEz8NPUYDoiMgRBH+c4bNlNzpPxdf2QBJ6w781RRVIWfUOW0IpEQz4757pnB3iTkyjs1IGxgd3F5y6S8rUAfPKXa3MEAixgUgL75Vjfcmv1vFZ7J32r8WtSI21U8YTRMhqZic70Zwhr0SBheiq8Hw9zpdjBjjbVDdEoZZT0uVo7Ash8SwPX4u8DPlw5aZZ0w0+AhXTdFUeuzU3mulIMQL1RvcnmfB0aEVYYHz0Ww63Irdp3Xy4LXoqqgamBP9gGxluy+RMddTW6+pAGRrAAIBjgrD9f2CUkil0j1sXetoSdqivMxNcnVZer0/QCOcENY24k7eMZpsYquoKtouMvjHyNMN/rKvvsNZwnv/rzQczq0xk+OmwByuqtO444IP99p05kmM2Z8rRlO7RNbTA81kllrkNEgi3RssMVySkSvYUaDPY0st+HSO1fs1TnaEQncpK0fHDMaelSDr3Jatd6j370KEYPzvkYkdWUuNPpwe3LTFc8/EANzmV06GYxReJFR59STlXFPhxsPJKCpBjg== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3af09277-ed1f-4e9c-1f3c-08d879d3306c X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Oct 2020 17:18:43.1692 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: moEkj23HqfjhdCGGGWJ2huTeoy2UtCR1Wlg2tTabZnQ8ZdZKyAO0z2Tnj7f2sD1GbycF5IqHbXaU/hPsTxCLwLfqklWKxzM6kJ7OQ/615MQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3032 Received-SPF: pass client-ip=40.107.21.123; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/26 13:18:43 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The further change of moving backup to be a one block-copy call will make copying chunk-size and cluster-size two separate things. So, even with 64k cluster sized qcow2 image, default chunk would be 1M. Test 219 depends on specified chunk-size. Update it for explicit chunk-size for backup as for mirror. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Max Reitz --- tests/qemu-iotests/219 | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/qemu-iotests/219 b/tests/qemu-iotests/219 index db272c5249..d7b177bf09 100755 --- a/tests/qemu-iotests/219 +++ b/tests/qemu-iotests/219 @@ -203,13 +203,13 @@ with iotests.FilePath('disk.img') as disk_path, \ # but related to this also automatic state transitions like job # completion), but still get pause points often enough to avoid making this # test very slow, it's important to have the right ratio between speed and - # buf_size. + # copy-chunk-size. # - # For backup, buf_size is hard-coded to the source image cluster size (64k), - # so we'll pick the same for mirror. The slice time, i.e. the granularity - # of the rate limiting is 100ms. With a speed of 256k per second, we can - # get four pause points per second. This gives us 250ms per iteration, - # which should be enough to stay deterministic. + # Chose 64k copy-chunk-size both for mirror (by buf_size) and backup (by + # x-max-chunk). The slice time, i.e. the granularity of the rate limiting + # is 100ms. With a speed of 256k per second, we can get four pause points + # per second. This gives us 250ms per iteration, which should be enough to + # stay deterministic. test_job_lifecycle(vm, 'drive-mirror', has_ready=True, job_args={ 'device': 'drive0-node', @@ -226,6 +226,7 @@ with iotests.FilePath('disk.img') as disk_path, \ 'target': copy_path, 'sync': 'full', 'speed': 262144, + 'x-perf': {'max-chunk': 65536}, 'auto-finalize': auto_finalize, 'auto-dismiss': auto_dismiss, }) From patchwork Mon Oct 26 17:18:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 301976 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2191CC4363A for ; Mon, 26 Oct 2020 17:52:25 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 892A82072D for ; Mon, 26 Oct 2020 17:52:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="wUaoopI0" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 892A82072D Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:36526 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kX6fP-0005iZ-Js for qemu-devel@archiver.kernel.org; Mon, 26 Oct 2020 13:52:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49614) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kX695-0007vl-SB; Mon, 26 Oct 2020 13:18:59 -0400 Received: from mail-vi1eur05on2092.outbound.protection.outlook.com ([40.107.21.92]:44161 helo=EUR05-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kX694-0008QM-7D; Mon, 26 Oct 2020 13:18:59 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QUjBxTAT5HeNYt/UsB2kBgmX7mlQv0T9NCnG1kXJknriHJUabuS5e5sQX2x9jw7cJPpEygmYcIJwLfusnNbPDPzD2jH/I9evfec30JQIDK8ApbUg4VMn0Bn5V7uoKkut7RlZXWxu+lThecFDN5BBpLcNexGVDjfrlUJ9J8K1ia21xZkNxgXVK2j/qNeeRIRE4zA0LIshHfqXFbS2LYKiUzh7dJI/7TErY4Bnqta6ro8+yD+sp38i5+rky5EK+BM9eoJOvmZtFACR2jGiIiXfGDCYuj6VPJIp8M55Su1xaS/ZVWFHoj6UQsBnALDQJZMVXKGh2dBzd+GDaX7TQ1vPbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PrLj5bDWnH24UiJtSpC15ErMgQPVauwci30aWo3RncQ=; b=Ze2AEA0aQ6NsHfdXWketvtGA8mGeefriTYlinQGUNBQt80sQoR2wMI1pcTqUqOmsJ1oqfvYxLn0N2q6VWemS8GEBiczQdyFZHlGEJ1RLKCG4GzkXZfnExRgV87FTy+e3MTZTw3NcxFRMW2+XNh/td0CaA0RVulITeCobfdtsZXDcSWhej5dStiIYFSJsFiZmqSaqhPYBFL/+QiCsexlQxR6D/QVl27n4uR7OOJiMKV8W0uMINvRQ0e2tUChKqUZLovJZ1bqD4sASvDtcSPxw6gPOtAv0JPPfAv47JpFJKXCIHDlCW/hdqFm2hSMhoYEHaiMPFmjFwAiEZCEk04BUvQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PrLj5bDWnH24UiJtSpC15ErMgQPVauwci30aWo3RncQ=; b=wUaoopI0ptDW+EmGq+ljx4tkX9mYKZWxM0Lstc+ep07TzHm7+dIqo57uU3k8uIKCXwNAYS5b85ytR0GqQPwb+hXdR3ZmSLwa/4qRQvBX8jr4R0+HqqE4vJUEbVVQYgCJNA+2ZFd49SL46SOl+SGi5cIPJ6IeJgBV+h/igdUeW9g= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB3032.eurprd08.prod.outlook.com (2603:10a6:209:43::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18; Mon, 26 Oct 2020 17:18:46 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243%9]) with mapi id 15.20.3499.018; Mon, 26 Oct 2020 17:18:46 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, vsementsov@virtuozzo.com, eblake@redhat.com, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, jsnow@redhat.com, mreitz@redhat.com, kwolf@redhat.com, den@openvz.org Subject: [PATCH v3 18/25] block/backup: drop extra gotos from backup_run() Date: Mon, 26 Oct 2020 20:18:08 +0300 Message-Id: <20201026171815.13233-19-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201026171815.13233-1-vsementsov@virtuozzo.com> References: <20201026171815.13233-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.99] X-ClientProxiedBy: AM0PR02CA0101.eurprd02.prod.outlook.com (2603:10a6:208:154::42) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.99) by AM0PR02CA0101.eurprd02.prod.outlook.com (2603:10a6:208:154::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Mon, 26 Oct 2020 17:18:45 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 105f281f-95c2-480e-d4c9-08d879d33213 X-MS-TrafficTypeDiagnostic: AM6PR08MB3032: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:160; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: B08tSOWqZLlKV9fnV/8sq+UmLJgHqt6QxUfczkkAAwHHX/F8EwhZXI+NmI0XzmdK+4n7Tu01AVxiaIadNu6CraLk2wUrcXBjPErz7ENMUzSbBFWr6VkZcIT94phUk0I+8an92B8zk863HGSjzLgPD74dflFAWLu1uCYvgn3MXhz3f6wrqrVU3XFLGvKjbOg81YoGB5LOfv4kikV5CVavO1Fp7oluXVEOH+GO6QwF3dSzzUAgXbF8a0wqnQzorgzVGR/jn2YJ8lQsxlQYmvdq2ccCh2UuMzDQJZChtkPQtZOfY3JPY1im5WWxfL8VBARuxUKFX6jRu1Lb/loKzloRAg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(136003)(366004)(39850400004)(376002)(346002)(396003)(66476007)(8936002)(5660300002)(316002)(6506007)(6512007)(2616005)(66946007)(956004)(66556008)(6666004)(26005)(4326008)(36756003)(478600001)(52116002)(1076003)(16526019)(83380400001)(2906002)(186003)(6916009)(8676002)(107886003)(86362001)(6486002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: vUVL3erhDXnYW9rg3sDawnqiRgo5QvsivZMgNJ35mspPt6+rRGtMhk9SysJlhjFNQ7p69esQcWFoxjJ/2H8cLwU6RKG2G+SLLbeEomAtqjclvd9yUddY70UUn0QzXPGF9uAdK0UFGBDJTGGBc6INo8nK7/S5E08WOpdM8yMoNHVKJPN1nonaMF+ZJZXSPIJ2aQBfs7qqWL/cJazWERpMJHtC+xeBf2aKshj3bD/vSeSFeNY9nK/ir2l0Lj4xv9BJNriY/syLmmAlh02ik2Y0vt7p2HAIwIqHL1HK/L38jWiQjtMQg7J17l3xMzThWDqGCGeosBTCtuIGI/dTj/aYBbu9gQyTwYN489pmXFDNUQ7cBtj6HBp7vhihytWBz2oeUHxb/ZNnU2rZZaUBK9mpRcs54CGrPtZr3psih60N6AfRzDR33A2ZNzQR0QWSIr4aTHHSRjhTWCLwjk82wGd6WN/ox85fHyUARnmVyxerMzI5KN3ARPuEvdwALKdkU9TTpvLDalYB2D+mzJypnjUJfbkQdKlhAoW7j/hl6+h40b5ItjjfTKKiXOY21QdlbgwboYv8Fj6D63cnyqAFmEdvpI3P1xdyiw6afAM8cdGvfNmrIgtQCT4+V6iEbm5pFywbyM9QTDIqvYqpBnFTV3zSHg== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 105f281f-95c2-480e-d4c9-08d879d33213 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Oct 2020 17:18:45.9589 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: pgl2kHkgvozQzNTDbi0yRKSjPURYo4GI52inwp/cto4y3XVmj4DA/eeDXmBp4d7vru/+LPDqRt9l8B9JkNSsIZIeIt49QmRcPWTnPjNTDck= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3032 Received-SPF: pass client-ip=40.107.21.92; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/26 13:18:53 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Max Reitz --- block/backup.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/block/backup.c b/block/backup.c index 8c67d77504..449b763ce4 100644 --- a/block/backup.c +++ b/block/backup.c @@ -236,7 +236,7 @@ static void backup_init_bcs_bitmap(BackupBlockJob *job) static int coroutine_fn backup_run(Job *job, Error **errp) { BackupBlockJob *s = container_of(job, BackupBlockJob, common.job); - int ret = 0; + int ret; backup_init_bcs_bitmap(s); @@ -246,13 +246,12 @@ static int coroutine_fn backup_run(Job *job, Error **errp) for (offset = 0; offset < s->len; ) { if (yield_and_check(s)) { - ret = -ECANCELED; - goto out; + return -ECANCELED; } ret = block_copy_reset_unallocated(s->bcs, offset, &count); if (ret < 0) { - goto out; + return ret; } offset += count; @@ -273,11 +272,10 @@ static int coroutine_fn backup_run(Job *job, Error **errp) job_yield(job); } } else { - ret = backup_loop(s); + return backup_loop(s); } - out: - return ret; + return 0; } static const BlockJobDriver backup_job_driver = { From patchwork Mon Oct 26 17:18:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 301985 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 665F4C4363A for ; Mon, 26 Oct 2020 17:36:24 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AE98F21D42 for ; Mon, 26 Oct 2020 17:36:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="X8HDFQRc" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AE98F21D42 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:50462 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kX6Pu-0003wC-LS for qemu-devel@archiver.kernel.org; Mon, 26 Oct 2020 13:36:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49642) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kX697-0007ye-Vp; Mon, 26 Oct 2020 13:19:03 -0400 Received: from mail-eopbgr60093.outbound.protection.outlook.com ([40.107.6.93]:39555 helo=EUR04-DB3-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kX695-0008NC-MV; Mon, 26 Oct 2020 13:19:01 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KBsZna23t4+Ikiv4gbhtXWeFW8I/Tq5tTh8+pRppdGqpIgVVGsOYEZn/JfbCOinl9UmoKD1sWxbVejG088/Ukjy4ItOI8fvQnutLMvNL0wmzKKAB8Xjc6xdkTqmqjHRLDbbXguIOfZ3UJENjFRJdch3UtncFKjSNDXC1gdQA7NzfCcWhgbMQvcKfN+zfy/ZXywF5LJpQha5SQynJZUNGkVoUHuJ+PcH3MtOM+1U1QPo+8dDMfBl3VgsWH3RwueRTZlh27hFIB+rI5Jd3Ygc8eH+zgzbX+eRjKem0bi5U+shu0L0T5f+P5ZMmhJ0XM9S9q/cDvg+y+Dkk2pKra2Amlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kx0AD2nDalj+UZZ19oaai0BKjf82AaY2SFIzo6HfKxQ=; b=SuMGO4nMg5NZyWDHYhhxDDEu6stNXWKWj2bJSZjYnPp7DbKrrQxhPPB5iDDrJnC/D1Ph2cZiJ0pQlZwfGYOsrh0iCqyFxLn3+yGjeUVqWhNOyhoA3c4F6zyjFnwHErp5lvym2lanHfelozkJTjtBiGTSFSnkvdKkM0HfASZlrerMmEP9KMdTV8qzQsHontzZJIL8DFJDmc3Be8h75ovxk4PWQ5eu1mk233jNk7SXeSKDvlWinRVXA2d95vtbLtmKF58uXPhhCGBJc8e8rl2f6WYghba2a5d7a70U4nEUHWL2o5/h6Y+dxdutXNprHo46AZKKM5mPTCrcM006yjJRLg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kx0AD2nDalj+UZZ19oaai0BKjf82AaY2SFIzo6HfKxQ=; b=X8HDFQRcFDJ0a6ngphMHE4+EJZvy0Q9PCdDZolJ6Ipfiw10jahyReuTGTD0/4FI7X1Do1lp3sg6h1/9yK6lwDTcjvOkXjb/McMwNSv32SLjFoUkcALKzHxyLjYlL3A4Qfz/HNpXG8G8b+2zKBgV+U5wu/nAVd/5UDU5K8FGDN2c= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB3032.eurprd08.prod.outlook.com (2603:10a6:209:43::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18; Mon, 26 Oct 2020 17:18:46 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243%9]) with mapi id 15.20.3499.018; Mon, 26 Oct 2020 17:18:46 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, vsementsov@virtuozzo.com, eblake@redhat.com, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, jsnow@redhat.com, mreitz@redhat.com, kwolf@redhat.com, den@openvz.org Subject: [PATCH v3 19/25] backup: move to block-copy Date: Mon, 26 Oct 2020 20:18:09 +0300 Message-Id: <20201026171815.13233-20-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201026171815.13233-1-vsementsov@virtuozzo.com> References: <20201026171815.13233-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.99] X-ClientProxiedBy: AM0PR02CA0101.eurprd02.prod.outlook.com (2603:10a6:208:154::42) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.99) by AM0PR02CA0101.eurprd02.prod.outlook.com (2603:10a6:208:154::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Mon, 26 Oct 2020 17:18:46 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: df76a4a4-04a5-473d-82b8-08d879d332a0 X-MS-TrafficTypeDiagnostic: AM6PR08MB3032: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:94; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GDx60VLWNz8ycDZvDhMJ1rCRQJbqv+Lkug2Y0Sf5paeh2mRtLH8c6hogeTrBDuPvdDcYVxL5FOeEipys8jiEFfIP+JvI1+kRNDrrUfNvpN+102gZiUpO/IXlVfV/stM4eIQ1biP3acCsWGn5YbXNjeEsA1fVrEwD6yl8UuUug9Y/TBWXK29xZcbdqKSFmVLRm61TCr6DJ/fRLgAw71eyyc/8cQvz0izxQubnLMmsVmhU6MphiR+idzr4N6PuJT6PW6pk1qd5kWe72XOFa9IU6+6rStr+U9LJQd10M9wzvRPDj4N1LwKCvK+v4HwVga4UW8lcXq4XWwM3xETfpTp7ZA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(136003)(366004)(39850400004)(376002)(346002)(396003)(66476007)(8936002)(5660300002)(316002)(6506007)(6512007)(2616005)(66946007)(956004)(66556008)(6666004)(26005)(4326008)(36756003)(478600001)(52116002)(1076003)(16526019)(83380400001)(2906002)(186003)(6916009)(8676002)(107886003)(86362001)(6486002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: us6NFxr2t64a7r6iZe9vCH/T60rGLxe7DwbsIsMiDZS+tKRuYVDPl0jbq0xeAZZdywtIWysKqU6/3UWGUAklxVkM4dN4ACHp/gSNzBcyd+pO5MFAtj98ywjXfV6PrdlXxXytWXtM/Oj2e9NRfGn1QGXd/nDDf1wOTU7RYXG4vKzTQuVrPpVbTQqpg83tAP1oD6u1LAs+TIpKrmkrffvXY734lhG9lP9KKS6/ndnK/NR6zih9bPHRC3ynXM1788eQ2p1bewTcRHcAENM+bkNF/1h64PutLo7/VK5pm/1oLo+owZ6i89hk+PXdzlk0RBH9IhJ/tveWceAixfQeNvGCrIH0A8tIaGLyhBa96JCl5z+2LFrjci3cllxh7DmVuKJEoUVp3z5cpl+uYITEW/Mdn3Hby53WOcqkGc2XBQMoEblziEPHsEUTWdEaiMVJlHe1oQZdo1mDS2RqzOQA0AGH/jKAaPK1dsYk3DX0iT7TpUrZY2IaSlR6Oz3pmKAeDArFUwJFdqzziY2YPRIwUnoBtnTmGZ4fIAroRd1u8hhxaRG452hYXyrR9N1nIilDv0HYws/7YhKSAyJZgOPdmYlThdbJzX3CM4/N7OtGHv9VxO8OqLTRAdgd+8Ph/D1sKiejUyxDOLrzTQciLI3xAJuFhw== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: df76a4a4-04a5-473d-82b8-08d879d332a0 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Oct 2020 17:18:46.8620 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: r10bo6+EmLbNnX/F/i9QD6YTwSsihpJcfoFdZAzVG1pGvBH+DuGUxZeAkMkGv/ZgZL154JQNXc+IaQbb6xkoD/U4ZAKdZlVuSjHNnwuqiYc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3032 Received-SPF: pass client-ip=40.107.6.93; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-DB3-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/26 13:18:35 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" This brings async request handling and block-status driven chunk sizes to backup out of the box, which improves backup performance. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Max Reitz --- block/backup.c | 187 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 121 insertions(+), 66 deletions(-) diff --git a/block/backup.c b/block/backup.c index 449b763ce4..0d1cd64eab 100644 --- a/block/backup.c +++ b/block/backup.c @@ -44,41 +44,17 @@ typedef struct BackupBlockJob { BlockdevOnError on_source_error; BlockdevOnError on_target_error; uint64_t len; - uint64_t bytes_read; int64_t cluster_size; BackupPerf perf; BlockCopyState *bcs; + + bool wait; + BlockCopyCallState *bg_bcs_call; } BackupBlockJob; static const BlockJobDriver backup_job_driver; -static void backup_progress_bytes_callback(int64_t bytes, void *opaque) -{ - BackupBlockJob *s = opaque; - - s->bytes_read += bytes; -} - -static int coroutine_fn backup_do_cow(BackupBlockJob *job, - int64_t offset, uint64_t bytes, - bool *error_is_read) -{ - int ret = 0; - int64_t start, end; /* bytes */ - - start = QEMU_ALIGN_DOWN(offset, job->cluster_size); - end = QEMU_ALIGN_UP(bytes + offset, job->cluster_size); - - trace_backup_do_cow_enter(job, start, offset, bytes); - - ret = block_copy(job->bcs, start, end - start, true, error_is_read); - - trace_backup_do_cow_return(job, offset, bytes, ret); - - return ret; -} - static void backup_cleanup_sync_bitmap(BackupBlockJob *job, int ret) { BdrvDirtyBitmap *bm; @@ -158,53 +134,97 @@ static BlockErrorAction backup_error_action(BackupBlockJob *job, } } -static bool coroutine_fn yield_and_check(BackupBlockJob *job) +static void coroutine_fn backup_block_copy_callback(void *opaque) { - uint64_t delay_ns; - - if (job_is_cancelled(&job->common.job)) { - return true; - } - - /* - * We need to yield even for delay_ns = 0 so that bdrv_drain_all() can - * return. Without a yield, the VM would not reboot. - */ - delay_ns = block_job_ratelimit_get_delay(&job->common, job->bytes_read); - job->bytes_read = 0; - job_sleep_ns(&job->common.job, delay_ns); + BackupBlockJob *s = opaque; - if (job_is_cancelled(&job->common.job)) { - return true; + if (s->wait) { + s->wait = false; + aio_co_wake(s->common.job.co); + } else { + job_enter(&s->common.job); } - - return false; } static int coroutine_fn backup_loop(BackupBlockJob *job) { - bool error_is_read; - int64_t offset; - BdrvDirtyBitmapIter *bdbi; + BlockCopyCallState *s = NULL; int ret = 0; + bool error_is_read; + BlockErrorAction act; + + while (true) { /* retry loop */ + job->bg_bcs_call = s = block_copy_async(job->bcs, 0, + QEMU_ALIGN_UP(job->len, job->cluster_size), + job->perf.max_workers, job->perf.max_chunk, + backup_block_copy_callback, job); + + while (!block_copy_call_finished(s) && + !job_is_cancelled(&job->common.job)) + { + job_yield(&job->common.job); + } - bdbi = bdrv_dirty_iter_new(block_copy_dirty_bitmap(job->bcs)); - while ((offset = bdrv_dirty_iter_next(bdbi)) != -1) { - do { - if (yield_and_check(job)) { - goto out; - } - ret = backup_do_cow(job, offset, job->cluster_size, &error_is_read); - if (ret < 0 && backup_error_action(job, error_is_read, -ret) == - BLOCK_ERROR_ACTION_REPORT) - { - goto out; - } - } while (ret < 0); + if (!block_copy_call_finished(s) && + job_is_cancelled(&job->common.job)) + { + /* + * Note that we can't use job_yield() here, as it doesn't work for + * cancelled job. + */ + block_copy_call_cancel(s); + job->wait = true; + qemu_coroutine_yield(); + assert(block_copy_call_finished(s)); + ret = 0; + goto out; + } + + if (job_is_cancelled(&job->common.job) || + block_copy_call_succeeded(s)) + { + ret = 0; + goto out; + } + + if (block_copy_call_cancelled(s)) { + /* + * Job is not cancelled but only block-copy call. This is possible + * after job pause. Now the pause is finished, start new block-copy + * iteration. + */ + block_copy_call_free(s); + continue; + } + + /* The only remaining case is failed block-copy call. */ + assert(block_copy_call_failed(s)); + + ret = block_copy_call_status(s, &error_is_read); + act = backup_error_action(job, error_is_read, -ret); + switch (act) { + case BLOCK_ERROR_ACTION_REPORT: + goto out; + case BLOCK_ERROR_ACTION_STOP: + /* + * Go to pause prior to starting new block-copy call on the next + * iteration. + */ + job_pause_point(&job->common.job); + break; + case BLOCK_ERROR_ACTION_IGNORE: + /* Proceed to new block-copy call to retry. */ + break; + default: + abort(); + } + + block_copy_call_free(s); } - out: - bdrv_dirty_iter_free(bdbi); +out: + block_copy_call_free(s); + job->bg_bcs_call = NULL; return ret; } @@ -245,7 +265,13 @@ static int coroutine_fn backup_run(Job *job, Error **errp) int64_t count; for (offset = 0; offset < s->len; ) { - if (yield_and_check(s)) { + if (job_is_cancelled(job)) { + return -ECANCELED; + } + + job_pause_point(job); + + if (job_is_cancelled(job)) { return -ECANCELED; } @@ -278,6 +304,33 @@ static int coroutine_fn backup_run(Job *job, Error **errp) return 0; } +static void coroutine_fn backup_pause(Job *job) +{ + BackupBlockJob *s = container_of(job, BackupBlockJob, common.job); + + if (s->bg_bcs_call && !block_copy_call_finished(s->bg_bcs_call)) { + block_copy_call_cancel(s->bg_bcs_call); + s->wait = true; + qemu_coroutine_yield(); + } +} + +static void coroutine_fn backup_set_speed(BlockJob *job, int64_t speed) +{ + BackupBlockJob *s = container_of(job, BackupBlockJob, common); + + /* + * block_job_set_speed() is called first from block_job_create(), when we + * don't yet have s->bcs. + */ + if (s->bcs) { + block_copy_set_speed(s->bcs, speed); + if (s->bg_bcs_call) { + block_copy_kick(s->bg_bcs_call); + } + } +} + static const BlockJobDriver backup_job_driver = { .job_driver = { .instance_size = sizeof(BackupBlockJob), @@ -288,7 +341,9 @@ static const BlockJobDriver backup_job_driver = { .commit = backup_commit, .abort = backup_abort, .clean = backup_clean, - } + .pause = backup_pause, + }, + .set_speed = backup_set_speed, }; static int64_t backup_calculate_cluster_size(BlockDriverState *target, @@ -485,8 +540,8 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs, job->len = len; job->perf = *perf; - block_copy_set_progress_callback(bcs, backup_progress_bytes_callback, job); block_copy_set_progress_meter(bcs, &job->common.job.progress); + block_copy_set_speed(bcs, speed); /* Required permissions are already taken by backup-top target */ block_job_add_bdrv(&job->common, "target", target, 0, BLK_PERM_ALL, From patchwork Mon Oct 26 17:18:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 301983 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 462F9C4363A for ; Mon, 26 Oct 2020 17:38:19 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B5B2E22242 for ; Mon, 26 Oct 2020 17:38:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="OCp0LLaW" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B5B2E22242 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:59774 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kX6Rl-0007qk-Rz for qemu-devel@archiver.kernel.org; Mon, 26 Oct 2020 13:38:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49726) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kX69N-00080V-Q3; Mon, 26 Oct 2020 13:19:19 -0400 Received: from mail-eopbgr60093.outbound.protection.outlook.com ([40.107.6.93]:39555 helo=EUR04-DB3-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kX69A-0008NC-3R; Mon, 26 Oct 2020 13:19:14 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WUHOOoKIehEgyMEioVb+nxn6QpMHbpm/bqLE2JGPpshSaPLP1K5zNp7pGqIyBv9U3WYNPhUK9OJGIEHwRn/7Er1h6Ewiv0m+SSXMoIm9EdFCiScKvTGw+5A97f8BC9rAl+0S8XtdX3s77Vu8EtJOAvlubzu4/xi+wrsO5HrubIcyBymYXdkCPHfGe0Qa/pPbEf6GX4ykVaeRmQA8mBQlNSZVXR+df13LKEREC64ikH21x9WcGeMcBSXQRnirNGuLAAFZBp3/0I9D3PMao2NVNpZoyNF1N9A8HXTkzbGa3lMaPu4OE54MfAKF4YL7uMEtl/yY4+vgnOx7ZMcsp8xACQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7blNLfYfmsle4Ppu6DqQyUTOJ5oaBW+g3DdYSYApssA=; b=MBYflykjZXU11OI6/5tYEVsY3M/8IxRaCqeWuY3HVbIAQ6ULFEEC4xU6/OEb3VQAayGiQj6ctl30A1YYUEP9f8PUqUrLbKdJsYsRASPukXfAMnUeAjJAH8AVTqkJh/NlDFmheUFDNJ9WYyVDgQys9D3N58j0v7CSO64lh4+q+X0PHm4/i7oVxFpLgLKS+hi5RTKKGy3X5fwYuytPWICawRlRv6yZsBvGE+b9jmXH/FcbnLe9zadMqn1FxO1wu72dE5wk6fP9fOXcbeGGucPGvzoT3R3jLIpqGe60h79Cf0LC+GK9KGjbz8DJaeusT+7jc873Rkb0gGQntbC6ktmoXg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7blNLfYfmsle4Ppu6DqQyUTOJ5oaBW+g3DdYSYApssA=; b=OCp0LLaW7vu3hqlgedJbF+ntSbutLPaE6NatzjujTr3kpzZeBbphb6ERcLybUTr10YT5coM8adP88u8X9krOVEKn4fouFv9LxQtXFeFDvSw2KmYzIb0JChQa2bTDRQmbRRqcc4aZmFh0Iq/IBs7uNXKV5ZiI/aZh9obQRVBJ6LA= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB3032.eurprd08.prod.outlook.com (2603:10a6:209:43::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18; Mon, 26 Oct 2020 17:18:48 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243%9]) with mapi id 15.20.3499.018; Mon, 26 Oct 2020 17:18:48 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, vsementsov@virtuozzo.com, eblake@redhat.com, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, jsnow@redhat.com, mreitz@redhat.com, kwolf@redhat.com, den@openvz.org Subject: [PATCH v3 21/25] block/block-copy: drop unused block_copy_set_progress_callback() Date: Mon, 26 Oct 2020 20:18:11 +0300 Message-Id: <20201026171815.13233-22-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201026171815.13233-1-vsementsov@virtuozzo.com> References: <20201026171815.13233-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.99] X-ClientProxiedBy: AM0PR02CA0101.eurprd02.prod.outlook.com (2603:10a6:208:154::42) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.99) by AM0PR02CA0101.eurprd02.prod.outlook.com (2603:10a6:208:154::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Mon, 26 Oct 2020 17:18:47 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a3e7cc94-b870-4196-c762-08d879d333ae X-MS-TrafficTypeDiagnostic: AM6PR08MB3032: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:52; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XShwB12DL7JOIJ5F/GPizucIMvTew0bSals62B9ZHhGv0+HwiS37AE21IF6rKd9i7m6yRnVJNImxK8ZTNv/zu5EbxNWsnPh/Ywcw9QINZKKyFrpEqwETUaguaewGxc+31NfqHOXXcqFGuUHTocef/xJkXBNB7f1Rqh9kf1QYG5n3XQ/94r8WEmjz27ArpAlrpq936o0KbrtC5k4IaaAztEqlRZuFoN4Yx9pP+w+4xziZWuSf+fpCDiqmQjHPU+SfRdP80wWkzDp33ChWHnqjDhGlgk6yfmijJZ5yj8bpjsI1KzmxT/dYNSDXZkpIrjIKGE9T6bdA1+5DQZKNwx0U+g== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(136003)(366004)(39850400004)(376002)(346002)(396003)(66476007)(8936002)(5660300002)(316002)(6506007)(6512007)(2616005)(66946007)(956004)(66556008)(6666004)(26005)(4326008)(36756003)(478600001)(52116002)(1076003)(16526019)(83380400001)(2906002)(186003)(6916009)(8676002)(107886003)(86362001)(6486002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: pOxxpAiL7t/5mu4ssrHYgwnlaihiJTJSrHY8jyr8c4RASF7mPzDuHXhjKlzGYjgDSPSMKSgdZBD5ZW5Pnr3p26aM5Vs0Hj+bcRB6i8OptPYhnJA3x57YKt0zOojiQaGVS040QMdShbvJyCmKxb7g1ejKeH8TsLycNB4kW7mph2QjDJF0Nczks14sAcjd8gXC5lARn4KFw4b0/s+JzJi0ZhdE3JYYExV97O1QgMrA6vrTAKWi9yRtbVQd5Gvr21hW0UitJjFIj0CkbQkGTq/YvcW2NY2i4CsCDiwB6qSQmXEVsGHBKyjx0UIpimJnPP0SlaXaz80wBVGI5Nb/EAi6mYsUjoUrWIKD2FpIxOtpjqqQxaf2HckJ2EcieeKdA2bBWjP6VD3G40TV98/L+TdOwDF9PRbWBiJfrlMgZtDJiz7/GZPBaPjpHT6LbpNqWlpV9Y7/w+ZC3/PJZcC7kwkxAwzO97Obgejqr6J8vXvFdeXMx0NUKNF4B5JjLf2aNGk3VR6C2SYop/mmyA0DCOFNGOKNylt8uU0qS+PiDjbxdsrK7Fcosg9Gs6D930+d8sQ+RU6skt97bfVSOncvDtXuCQrqfiaPWlSI7yKiJtybZucneRtEwkbAkwYRAUVEUteJBJcHLSQILv30+q55tM+QdQ== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: a3e7cc94-b870-4196-c762-08d879d333ae X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Oct 2020 17:18:48.6441 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: dhk52LXDAxTZTpk3qE74G1E40N0trVZuuuExLo03+9r8Dq5XDV7XrGkv1YBHvqamOtUuUCzCsm6hatq0cwHHdbWygDE9nnBZlo/sG0gHWO8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3032 Received-SPF: pass client-ip=40.107.6.93; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-DB3-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/26 13:18:35 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Drop unused code. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Max Reitz --- include/block/block-copy.h | 6 ------ block/block-copy.c | 15 --------------- 2 files changed, 21 deletions(-) diff --git a/include/block/block-copy.h b/include/block/block-copy.h index 8f5013d0aa..7b77abf70b 100644 --- a/include/block/block-copy.h +++ b/include/block/block-copy.h @@ -18,7 +18,6 @@ #include "block/block.h" #include "qemu/co-shared-resource.h" -typedef void (*ProgressBytesCallbackFunc)(int64_t bytes, void *opaque); typedef void (*BlockCopyAsyncCallbackFunc)(void *opaque); typedef struct BlockCopyState BlockCopyState; typedef struct BlockCopyCallState BlockCopyCallState; @@ -28,11 +27,6 @@ BlockCopyState *block_copy_state_new(BdrvChild *source, BdrvChild *target, BdrvRequestFlags write_flags, Error **errp); -void block_copy_set_progress_callback( - BlockCopyState *s, - ProgressBytesCallbackFunc progress_bytes_callback, - void *progress_opaque); - void block_copy_set_progress_meter(BlockCopyState *s, ProgressMeter *pm); void block_copy_state_free(BlockCopyState *s); diff --git a/block/block-copy.c b/block/block-copy.c index 61d82d9a1c..2ea8b28684 100644 --- a/block/block-copy.c +++ b/block/block-copy.c @@ -110,9 +110,6 @@ typedef struct BlockCopyState { bool skip_unallocated; ProgressMeter *progress; - /* progress_bytes_callback: called when some copying progress is done. */ - ProgressBytesCallbackFunc progress_bytes_callback; - void *progress_opaque; SharedResource *mem; @@ -298,15 +295,6 @@ BlockCopyState *block_copy_state_new(BdrvChild *source, BdrvChild *target, return s; } -void block_copy_set_progress_callback( - BlockCopyState *s, - ProgressBytesCallbackFunc progress_bytes_callback, - void *progress_opaque) -{ - s->progress_bytes_callback = progress_bytes_callback; - s->progress_opaque = progress_opaque; -} - void block_copy_set_progress_meter(BlockCopyState *s, ProgressMeter *pm) { s->progress = pm; @@ -454,9 +442,6 @@ static coroutine_fn int block_copy_task_entry(AioTask *task) t->call_state->error_is_read = error_is_read; } else { progress_work_done(t->s->progress, t->bytes); - if (t->s->progress_bytes_callback) { - t->s->progress_bytes_callback(t->bytes, t->s->progress_opaque); - } } co_put_to_shres(t->s->mem, t->bytes); block_copy_task_end(t, ret); From patchwork Mon Oct 26 17:18:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 301978 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2F1BBC4363A for ; Mon, 26 Oct 2020 17:49:32 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 93B212225C for ; Mon, 26 Oct 2020 17:49:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="wHVe3I/n" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 93B212225C Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:56836 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kX6cc-0002Cn-EL for qemu-devel@archiver.kernel.org; Mon, 26 Oct 2020 13:49:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49786) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kX69S-00082a-6r; Mon, 26 Oct 2020 13:19:22 -0400 Received: from mail-eopbgr60093.outbound.protection.outlook.com ([40.107.6.93]:39555 helo=EUR04-DB3-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kX69O-0008NC-Il; Mon, 26 Oct 2020 13:19:21 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mO4Ca5z+yYxTofWw3phmcUV5esYEJaujReKg6fKCE0M3RXxbTKh3T5PMgcZS24onWrNvwXw6r2DzxHAsAa7xji4TQYdhjM+HUelVHuxmf0fovjmppGamYWM5P/FR0ESwkUWS0X+HmyOzBKHPq7Igmx6rdLD0UnHWcMO246v2nqcH5OyRZVDjl48ukVI5HpWZOrJOEOnMRZa9XKzayBeKxazZgt0YhhTQ9pwzEk4PzIaCMGTlPwLfXVU2Spw3BOuRf/OHjYVHbILdDHzDzYvCXjmqA2/ML3dYZekUh5m4PkdVvDNXP/ME8L5Jkwg0muobK7kQQRwAg2zhAiECyIGY0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AErZ3RdwPEOUJ3rw8vC0Ui0sD27QI7CmRbQPHluOZ/Q=; b=FPy+LUyeiH44cNtHIqpRcKe5WlnXj5ZKrqNrPiaCGJsxWL2wQeSaiP7PnXpTpc0EkFBdqJtL1U6dtJo92xDpRgkL5tLSGPCpBvKexn87ShWfOE3Qoa4utao8IFYir4Vf7EFnFY2MV1CT9bfFip3T83hZrKLT+2PXcpvOuHO9GgCDky+ylzec0sEBR/XuofJeniiTEkAqaEqIo18KLDB+xF/H1Tb1aYkEG0ePYkP5BMJubkWbpzdAvpMd4ZxVf4jk/sIzPfSSOKNdeELoNaqKC9CQrjjCNnlxal+GAxGzkL0qTfbVPfVyRrtwlEuwXgpaYvBjj16CY4P45EFJRL4Mmw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AErZ3RdwPEOUJ3rw8vC0Ui0sD27QI7CmRbQPHluOZ/Q=; b=wHVe3I/nk7yBAzJ/uiF6OgNeM9N/seXsO2bfkZ6RkqJ/P80sLbXRMNYn2XqJYQNofGLPr1xW0sUF+wKNlB+DiWfCXU9CYY4VMpwyGBlzQ0M2WfnSV4QDADDi2hsOI6jf+mOsDMeL08vdVJRxun3UK2KbY5oCkDdLqRNesHeQDQU= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB3032.eurprd08.prod.outlook.com (2603:10a6:209:43::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18; Mon, 26 Oct 2020 17:18:52 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243%9]) with mapi id 15.20.3499.018; Mon, 26 Oct 2020 17:18:52 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, vsementsov@virtuozzo.com, eblake@redhat.com, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, jsnow@redhat.com, mreitz@redhat.com, kwolf@redhat.com, den@openvz.org Subject: [PATCH v3 24/25] simplebench: bench_block_job: add cmd_options argument Date: Mon, 26 Oct 2020 20:18:14 +0300 Message-Id: <20201026171815.13233-25-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201026171815.13233-1-vsementsov@virtuozzo.com> References: <20201026171815.13233-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.99] X-ClientProxiedBy: AM0PR02CA0101.eurprd02.prod.outlook.com (2603:10a6:208:154::42) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.99) by AM0PR02CA0101.eurprd02.prod.outlook.com (2603:10a6:208:154::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Mon, 26 Oct 2020 17:18:50 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3ed2d0af-80d5-472c-795b-08d879d335a0 X-MS-TrafficTypeDiagnostic: AM6PR08MB3032: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1751; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mcNpROan3IHAlWhxXBVFRn9Kty2Mj2heN5MnF3PPhloP+M6mv36d7zOdf7f9xfFywNlYovt5M2tWkWvrQW3ck+nRREMivm+KVUwfmQeprPbEpFMifLy9Zt1p3ZfYBPpyY0iUetWd8fbvK+dUOPRBVzvoZeBnEyErdp9PYoakMFJ2fzRBPzOCbuDKsPKx0gM54XXHPaqHBJg5n0jHvdHirMa8HGRYBewJbSUM4SvNNbAOO2hrYyR1eJ4O8XWCWXaqn6hpjSvFtF3Ue4LIIDXRZKOsIF5boYRFiTNFAfUixDbvkd0o0N3H5NZapNnYOEWyG/PTDpHCl5grjwlICiW4FQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(136003)(366004)(39850400004)(376002)(346002)(396003)(66476007)(8936002)(5660300002)(316002)(6506007)(6512007)(2616005)(66946007)(956004)(66556008)(6666004)(26005)(4326008)(36756003)(478600001)(52116002)(1076003)(16526019)(83380400001)(2906002)(186003)(6916009)(8676002)(107886003)(86362001)(6486002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: ebpC7ORjkM7Pt6Eb3FeZAfmbNvCYddtB4c+W8VwYeGC1wZLL4MHJtRl/YpHrj6Ai6UKJcKuYhIQRRfiIAyq4/2Hvmn8Uk6YcHyCJGXNmnTRGCw1+1hdzbnkGiIyqJlMPq98McfxYgNv8Z4431VHy5pri9eBS92I4f8lhldBPaV/7vofSGNkJxb2hpfZeA8H61fTTH+6L+SXrZyKJAStKOq5ftoHXCqeGMTZz2RfcKFfPNt18OgYKT4Xn5GRXQfZ8K8uvg0xAMELqvTKSnPVn9FWDsxyuLBffcpZUJ5C8E+mnFoyL65ZWu1sXblX0ic1gOFqNCMIiWCi6zU0J7rQftSP7+uBBM+SrsuyWVoU/85tA8ihyO7pCvuxK2b1y9qCUPfl2h326yd9gxbKLY79ZpFf3ucb3639vWpNEHI1TYNO55ld0b8kXBKmw9SK0sJ/Do+l2qgLcf1ZDqaTks7BuSTE6nrhkldS3k3xC1xkO8ZZ0b2NnZ5vrxA47Ehhg5Vg3S+oVKaR816GrYMm/bykDTOEF+/Vu1wL6B50fR04m8+zPDNYHR503/hUxERN3RqMfyPcj+ujz3WL2PuMQjuHOQbBjZ7s1IlqITQvAPx7dyyQUU/BMwfs5roBz2dS1gHqkKqgDflR5LRZk4ryRA1gB3w== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3ed2d0af-80d5-472c-795b-08d879d335a0 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Oct 2020 17:18:52.0253 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: pXqtKZBgf+yW3F2NXiMCU962XGirnhYpBqmDEgqVpgk2ismZYqwPeB/ze/XZKqv0Yg1DnwIpEr9rmgY2JqPGfEe8lkV07YVL8vLQV0OFDww= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3032 Received-SPF: pass client-ip=40.107.6.93; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-DB3-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/26 13:18:35 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Add argument to allow additional block-job options. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Max Reitz --- scripts/simplebench/bench-example.py | 2 +- scripts/simplebench/bench_block_job.py | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/scripts/simplebench/bench-example.py b/scripts/simplebench/bench-example.py index d9c7f7bc17..4864435f39 100644 --- a/scripts/simplebench/bench-example.py +++ b/scripts/simplebench/bench-example.py @@ -25,7 +25,7 @@ from bench_block_job import bench_block_copy, drv_file, drv_nbd def bench_func(env, case): """ Handle one "cell" of benchmarking table. """ - return bench_block_copy(env['qemu_binary'], env['cmd'], + return bench_block_copy(env['qemu_binary'], env['cmd'], {} case['source'], case['target']) diff --git a/scripts/simplebench/bench_block_job.py b/scripts/simplebench/bench_block_job.py index a0dda1dc4e..7332845c1c 100755 --- a/scripts/simplebench/bench_block_job.py +++ b/scripts/simplebench/bench_block_job.py @@ -78,16 +78,19 @@ def bench_block_job(cmd, cmd_args, qemu_args): # Bench backup or mirror -def bench_block_copy(qemu_binary, cmd, source, target): +def bench_block_copy(qemu_binary, cmd, cmd_options, source, target): """Helper to run bench_block_job() for mirror or backup""" assert cmd in ('blockdev-backup', 'blockdev-mirror') source['node-name'] = 'source' target['node-name'] = 'target' - return bench_block_job(cmd, - {'job-id': 'job0', 'device': 'source', - 'target': 'target', 'sync': 'full'}, + cmd_options['job-id'] = 'job0' + cmd_options['device'] = 'source' + cmd_options['target'] = 'target' + cmd_options['sync'] = 'full' + + return bench_block_job(cmd, cmd_options, [qemu_binary, '-blockdev', json.dumps(source), '-blockdev', json.dumps(target)])