From patchwork Tue Sep 21 10:20:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12507525 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,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 C3D86C433EF for ; Tue, 21 Sep 2021 10:29:41 +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 15CC260F6B for ; Tue, 21 Sep 2021 10:29:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 15CC260F6B Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:51022 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mSd1v-0002ds-4s for qemu-devel@archiver.kernel.org; Tue, 21 Sep 2021 06:29:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32962) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mSctg-0001fs-UG; Tue, 21 Sep 2021 06:21:09 -0400 Received: from mail-eopbgr140125.outbound.protection.outlook.com ([40.107.14.125]:6053 helo=EUR01-VE1-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 1mSctR-0002LA-4z; Tue, 21 Sep 2021 06:21:08 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JQOSv9tsjmSAOyvjZ8Gpg6etOnt6j/xDj5xqIPXyuGg74r/VoowEGf+98YiBQ+oFUWMDg7DcYbutY8pS5Kd3Wv26UqQesmMA7crw48cXmKMbFjm93q4+nWRE9QqkRG7Fihxp2FzQS8AIfuLSXt/H2ekHvxVYuqiQDa0pSdHRgGhmZwHjSdNW3UWNFRjL6QiSbTUU2SEJur2J3apr+cDWQvbt1WDs0xOxNQnN0bjEnBH91q3Ty1e2ySUjRH3lhYj3h54apAfM422S10fmxM4QfnYpm/oFNUUk3Ym3FsJ39hFRlRxSM2R6IvHnB9S7W2NEfBn8u/8dmWXPkekLhhYfgg== 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; bh=XQNFKGXBvAZbVAEPBOJke/CZRitq4Ze9hYU8Tucj3PA=; b=n5y8YclADkAm8yDdt+JRFdW5qe+KkJNNt/3WUKpeA0huRqwjt1fOOGIPTQh4jtGK8wnRvdxd+8BkB+bptH6MEbsx6o8ssbQlW7dIpNu4gnGc/xKmo1S2VRvqQx0it6gRBf2Hhhtju1sBXoV5Y+Q8nTut8L1yU2BQUizcZgPsXDTJKxRW3fcLUPw8AmdwmWtCVDR3qHxWwQSyj9Zbg/UEm7Aij31BTcnKqhVhHQ44k5LJ5xBQLBN3Fp0JVpVhEP5jKMVg3rDQ2DnlPt2T5KZIQYGxKjVRTx5QWSoWRhMuzFPoz2vkntquVbaKtq7DLSUs8scouLZDhhnVFO84Rv3xYw== 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=XQNFKGXBvAZbVAEPBOJke/CZRitq4Ze9hYU8Tucj3PA=; b=JAl5q3DCZ49Z6E8ir0cfZMAOL+io5+9AOzAkZoJ5chIj1MwmlzDPjG1+BC2xqwfiKnf8rkzmPm3UV/hW/WRGMeNCqhJPF/jE1TpUFCwVmVEf6+yFnekNDOj6OMmOkggdUhPGJbkV61xQYdTe48CgOUoGofRg5LnrFb4UUxdG8E4= 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 AS8PR08MB6631.eurprd08.prod.outlook.com (2603:10a6:20b:339::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.16; Tue, 21 Sep 2021 10:20:37 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22%9]) with mapi id 15.20.4544.013; Tue, 21 Sep 2021 10:20:37 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, peter.maydell@linaro.org, kwolf@redhat.com, hreitz@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com, Eric Blake Subject: [PULL 03/12] mirror: Drop s->synced Date: Tue, 21 Sep 2021 13:20:08 +0300 Message-Id: <20210921102017.273679-4-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210921102017.273679-1-vsementsov@virtuozzo.com> References: <20210921102017.273679-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: HE1PR06CA0127.eurprd06.prod.outlook.com (2603:10a6:7:16::14) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 Received: from localhost.localdomain (185.215.60.205) by HE1PR06CA0127.eurprd06.prod.outlook.com (2603:10a6:7:16::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.16 via Frontend Transport; Tue, 21 Sep 2021 10:20:36 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 98f7d7ba-a543-48d8-aa52-08d97ce9748c X-MS-TrafficTypeDiagnostic: AS8PR08MB6631: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:475; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YMufcraZepNbiEqcA/aGbdBHR3r4DHF99Myyw9y8MiVqzWKRlmnPqHMS8FUWYj2A7XiWlKOawUqmeO4sXT4q6aZJhR4zyYe9jWg6gQuLfYpyajbpCAoYeo0ux+zNjxn8zkgUhNy6BB9ux+s8Htk0MBs6nyNTKKF0eutcbmVgGX9izcI+Nsh7pTPQKkO8oS2okMWyepXJ6AFFjzOfibu50BM9WOyh79zkMFPr+xwur0PWdYJBPucxV2PwG1x5hAwdUgKNJj/y055W32Sd5YUekaWYLjfFQwixP5iw8WqHjfW/odF7mk6h/C4BxA/za1dswU2cExxYpTaXDB4MhGfwjngLK8ZLy1uBtUSX3aFIOpX66LOGyAXFnItxf5xPlRyKOQEvsJ03DT7QNl6MQJynqhENqokYB7T/n8OTUZhssmTH/qyaJYXqxnoweDxv/4UAXrCG4zRxcFHGBSVnQCwNksn+uWgP/Z1s9WYK/9un7F60sYBt820SOPrA9BUVIZFBKAHL7s4u3EBv1/Stdr5TJUzPV8GOMUodyznjhvUKgJfndWORdoQ9vxFMJQMD20Q7xOu88Wrm2ZdvTa991JAY8fhnnM66PEVtA1HAekKTtnu66ilIvwZAFVyfiDsyp3GHM8CBUsIBxdGOPxMMu/qVB3U1AFgIoFltIh7sKYv718SaJVd54ljOd52Lk65z8GZOCRf5xV3F/KFvQGHPTUlXzg== 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)(366004)(1076003)(38350700002)(38100700002)(186003)(86362001)(8676002)(316002)(4326008)(6916009)(8936002)(6512007)(6666004)(2906002)(26005)(52116002)(5660300002)(6506007)(83380400001)(6486002)(956004)(2616005)(66476007)(36756003)(66556008)(508600001)(66946007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 9IqYirsTfPFoanwe71V3AznI6fGToidU+Wn4d+MyqT4OjOIEJ373GpJaDvbzGxQG5S9V+uxfnBB2Dx5Y60JMhOJCWtX2LjR1E/zGQl60tj41moflFYCHYbC5rL7qVoCODl59iZsDIvyrLJRW1H7lYDKApHpex/IWC+bWJBCdUxnP0W3rzqG+JGYJLW2xQWEK/lXHB490jD8q6/IkAjaKPmUfJEms7EkbI5zpRhLwK5x+eQctB62SGW4jryyrEuhNMyhRxsQApNP99RBo7AUkhJIx4bZmT9kQkUtppn3PhxxlQ3ZS3ZKa5vLyPY09mzHsd0TdM25LV2VadAVkK3WjIzc+Rssv2HJPtiQUcPQRUQJTX6dWnG3DjG4nl+T76riN9px8hYAJE98OVcfrPMo79e6qe1dPW8gZ+fpsO2xQTcv8keRgGcyB07P0+uaAxj8womhNeORhSNXxJm3YQpU6BzMZLZfapacffeLOEh8PCawiUBJlYXlu96ZIVT9j19AudErztWXG2y2y8EnDn3SPpjmDiSF/06wPAc83fdT8KPKcPFHofLrMeniNBSIGMdSwARVSGkrY1fyjL3yBWgWFE18+57l2r4MCHBIILzoF8rAecEYO5nwazwn4H5lmgtF4yjgQfacr7ejAwWV1/xuHIpRJQxQIyoKmM+zks2JCbDsJJ4/KyDL0nx15qKz9V+S2MLHjTqJLSLDlqkdMS3IswmqvSr7WhfyGNThmvd6kfGQxqdSFdqdgkgKaR5DjXHS6lJatCN5Cnl3zcmzqhcjrOBPVB0qoaJtjRJS94r1sLm6VMuN8A9udtHnDXb4yznKJqOGklxt/OXz4Wj+6U5twTaz1VIbW+CHFiyNqQmgX5uokxdMQd2fzxraY0bE0jNWfVtSXg3a/Q2L6rN65Xcyvc8ohvP94hxznCRxd2MCDQH5/zfouVrP2PzVtWED1lML2jQz1nJjNq6pAHt7jbSlbFf/sjdFtu5bBEITDPz3F5KflZ0HTsOeIQ1isWOXlyqqmoFeMkF4OwSmeU+bHm6Lmq3Sm0LY3ADWPq4LTMLLznWxZPiKAUUYXHmKXPHRlz1tKhr5M1P1vBa7BjmJiG5skooWa/yqDs/+OzjKNlNOKT5GG8e3lTMhGolHBJN/xvyt+5x/5zueVdSwZuic8mILFF1Pj/VVl8XPHHnZW8lAnvxAO2FdP3kSMoWXDOG/tFcj2cx/EXibIwF75MIv7NnloE5j8dkO7AvVnP/qgLpK+3mz21yaPlok5kiUTU/655IhwHmaqxzSu5MiTVcen24PeV1zR5wmcmYG+KylOXVXxUH0ht+9OXZYhT4+DiQS145/L X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 98f7d7ba-a543-48d8-aa52-08d97ce9748c X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Sep 2021 10:20:37.5410 (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: n3SsOJd6f1h0NwoJB1MYxKNKrqS4kdZrv1BdwyMm0wwX+hcgIi3iXJNQBR70iCBGjm0mY9WuAoHHJTMxSvt4ae+zbgts0K4ISa0hfH8s9g8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6631 Received-SPF: pass client-ip=40.107.14.125; envelope-from=vsementsov@virtuozzo.com; helo=EUR01-VE1-obe.outbound.protection.outlook.com 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, 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" From: Hanna Reitz As of HEAD^, there is no meaning to s->synced other than whether the job is READY or not. job_is_ready() gives us that information, too. Suggested-by: Vladimir Sementsov-Ogievskiy Signed-off-by: Hanna Reitz Reviewed-by: Eric Blake Reviewed-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Kevin Wolf Message-Id: <20210907124245.143492-4-hreitz@redhat.com> Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/mirror.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/block/mirror.c b/block/mirror.c index cad61496c2..86ddecb86b 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -56,7 +56,6 @@ typedef struct MirrorBlockJob { bool zero_target; MirrorCopyMode copy_mode; BlockdevOnError on_source_error, on_target_error; - bool synced; /* Set when the target is synced (dirty bitmap is clean, nothing * in flight) and the job is running in active mode */ bool actively_synced; @@ -943,7 +942,6 @@ static int coroutine_fn mirror_run(Job *job, Error **errp) if (s->bdev_length == 0) { /* Transition to the READY state and wait for complete. */ job_transition_to_ready(&s->common.job); - s->synced = true; s->actively_synced = true; while (!job_is_cancelled(&s->common.job) && !s->should_complete) { job_yield(&s->common.job); @@ -1035,7 +1033,7 @@ static int coroutine_fn mirror_run(Job *job, Error **errp) should_complete = false; if (s->in_flight == 0 && cnt == 0) { trace_mirror_before_flush(s); - if (!s->synced) { + if (!job_is_ready(&s->common.job)) { if (mirror_flush(s) < 0) { /* Go check s->ret. */ continue; @@ -1046,7 +1044,6 @@ static int coroutine_fn mirror_run(Job *job, Error **errp) * the target in a consistent state. */ job_transition_to_ready(&s->common.job); - s->synced = true; if (s->copy_mode != MIRROR_COPY_MODE_BACKGROUND) { s->actively_synced = true; } @@ -1090,14 +1087,15 @@ static int coroutine_fn mirror_run(Job *job, Error **errp) ret = 0; - if (s->synced && !should_complete) { + if (job_is_ready(&s->common.job) && !should_complete) { delay_ns = (s->in_flight == 0 && cnt == 0 ? BLOCK_JOB_SLICE_TIME : 0); } - trace_mirror_before_sleep(s, cnt, s->synced, delay_ns); + trace_mirror_before_sleep(s, cnt, job_is_ready(&s->common.job), + delay_ns); job_sleep_ns(&s->common.job, delay_ns); if (job_is_cancelled(&s->common.job) && - (!s->synced || s->common.job.force_cancel)) + (!job_is_ready(&s->common.job) || s->common.job.force_cancel)) { break; } @@ -1110,8 +1108,9 @@ immediate_exit: * or it was cancelled prematurely so that we do not guarantee that * the target is a copy of the source. */ - assert(ret < 0 || ((s->common.job.force_cancel || !s->synced) && - job_is_cancelled(&s->common.job))); + assert(ret < 0 || + ((s->common.job.force_cancel || !job_is_ready(&s->common.job)) && + job_is_cancelled(&s->common.job))); assert(need_drain); mirror_wait_for_all_io(s); } @@ -1134,7 +1133,7 @@ static void mirror_complete(Job *job, Error **errp) { MirrorBlockJob *s = container_of(job, MirrorBlockJob, common.job); - if (!s->synced) { + if (!job_is_ready(job)) { error_setg(errp, "The active block job '%s' cannot be completed", job->id); return;