From patchwork Tue Sep 21 10:20:06 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: 12507493 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 39CF7C433F5 for ; Tue, 21 Sep 2021 10:22:52 +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 6BBE961038 for ; Tue, 21 Sep 2021 10:22:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 6BBE961038 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]:41080 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mScvK-0004At-9L for qemu-devel@archiver.kernel.org; Tue, 21 Sep 2021 06:22:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32780) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mSctK-0001HN-KO; Tue, 21 Sep 2021 06:20:46 -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 1mSctI-0002LA-6i; Tue, 21 Sep 2021 06:20:46 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NkNWQU4TlEBGigeF44y3FH8s/wmw+nH2BcY9b6lTmTD4nny9Uonj1uexMgqdW/EA/G6zuUsL7ygP5CA7IDKwvbSy/U/nz+OlIh5LdsnKsQfIhcyhYOjXZfmsirL494C6Cjmn+ZlPzS4zK/BkcCCwtk+r57JA86h3vn2aRB+9fmkUGESt0GhPgd/NntCvlA+IBG/hitvkVcZvVJCwAsFEUd3Hfz9JlYzjEIYHoa4wFDqRtdhj2FjVVopLCyHrP4QgZcLVReYAixOv9tB5JygGWbvWkSxOSlNw5/+tLjqcWcNYjBgpDBLvtL1Gt4Nn2JBDrecJkyyfDnIOJ6YIoqe0Yw== 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=GGGyH9opW9gsNAVl9bR0Y/OZG7Q/NAepFfY7PMujBE4=; b=jGU9iVtdMMnEb2gJq62/i/bOxkGftoMzosHvM59EWSUlIez9tb0B8B76+IsmQKHDKwixVR7UYz7cmjIPi1D2dR62z6fGgqsS5ng82DBg2i0Jya6E/gfAgjZrY5FyPc6hpmc04qvCY03ti/KN+FDYLbRbBWw+QGnpwApP/5RHEbVwbJKP/oZRiRWZF3ut6s5yOZcZNjF3rLjCIriE2G2yHKd+wv8tLZiXAZIGoGenhbiOFxRGRNT/e7AqKRdDfsIreb4krC8ab1USfugB4FXb8LnOwvkZCZircpGmMMHZyilbUAAjY2f1OPE9SlWnyQukb54c07/Pj4iv/KbgrsD19Q== 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=GGGyH9opW9gsNAVl9bR0Y/OZG7Q/NAepFfY7PMujBE4=; b=neMJvoE3X6h6vG6djinLjDZDsVAoRznOluKKx9QPKE8LmnkdDAD4KmQ/IpOfB5dTim9Z1VCJ3yJAlhAguMbt9PVehRQyuEr3AGhdTAH8SgICulDeWk9my6yDrsDoUCAfGN2+pebjR/J0oo07RcXdjGvrP4WL/gizHp1+RCPMtno= 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:35 +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:35 +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 Subject: [PULL 01/12] job: Context changes in job_completed_txn_abort() Date: Tue, 21 Sep 2021 13:20:06 +0300 Message-Id: <20210921102017.273679-2-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:34 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f4127a5c-17a9-47ee-afc8-08d97ce97355 X-MS-TrafficTypeDiagnostic: AS8PR08MB6631: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mN1dIpE6CYDFV2EmdKzKXYpplX771H9RFNLHC5Tk4m6hfjZ5VqQUO6BV4uneOQrVUgSOxSdVQmGle9Qal8c+LxV4zS0V6bk0xYfnHCEb4woNfgplu31MhIoZuGruRMF+QOORWVNAvFIMTDCcD0yAddlyZZpnyhNota6n2XwuUuXcHLNKNAyDhNycjsiUrIPqWwFHs5JhjKE0b7I9tHchrZ2NfbiKGhBG/MH/sAJWPkJyBVgcjbJyuKynpAvDdRewgq6Sfd8+K1s0mW1amN/YFLQcbZhBhBc1++tVWTGE91It7tgQaHIQYbBjdWncmdSNaJPhKrIPHJx/69wubvNEDXp74ajUBG/oQSpKo1B59Zg5oEpGh/xeHLKEO2mQ4qCTrWdjIhRLYs3bHpA03OePJ4OCsHeUy2Ww21xhPGAOlk6ZVFVzumiJ6KZwXKus58HrqdbXgOzGnI0Qs4vtAjmpi0jYOBRJOGr8NQQmBKLoC2m3PNK5i1AnawQ2WQ4sx3LvARDCUnilg/+SgS2mNSIuAFZVy5uOYk8oSVr9zWqekNq5PzQ8WU3YbDES9e5MuAUvugTul6fhtQVj/Dnx1bGr6yieA9sNT0wUtp2ZtgS1r0rBkLLHVts7FbG3GOidtrwJ/2KM0YAYUt+M6b9MAhgG0o4kFYImLYSamDe2nEtF+TaNLzjCUFAQ4iWE6HQutUVHO7HrQT8l3C26yWNqhubgKQ== 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: 0l7H53E8/qZEWWzsZ425Ry17n5Yn+MhmluyE8f+Hojz3zYt+TawRdLBPoJ4rU94YW9/YWH+CQQaE+67Z1Eg92B9XbRDREoHiX1NQwMyWcLqAZinEpowoupH86aVP5QE8tn7IBzsjRSsB+WtvSu0GEmjkhB7XK2Trl8kdoa0eOy1TOfxd4ymClOKKrl+JWJoF2QOCWUX2Rc8AfQJUt0ygGywWZhzfn61D3/dmsjhX0dFSQ2pqVPwKLCzf2BjSlXRPEFJPnqY/I9nIl5iCGvGTp/A6m0Rus3wCbGXE1YbSgli8LGIjJE55icLZtbw/k33L8QD/e4FVeDxvV9jo50iD1iIJCmky20rEoF+jfYRd3yBmJ2Nkc20ESILNrdzwgmv9ve7peAezJ1e3PGvAh7uvmB7P3eahFhkDLNWsjiaPahzCTKZHcUTaAkwAv2UrwqoH47Dy09DZQuuqCYRUl6X1D+szayNSbi6Ow5yc0mVDnDGsvYAKI1SMWaRTXKH7c6nIDYBdnjEqrBT1nMhAvcRRVPWU1CuDSEDLgB/5mZjphSDCwzgH0LztkqpXnVqMcvHPAVHaCetgd/VYeS0/IFeMhfAn7v+yOeAouLKgQ+SFYHZO3L70muu1ipM0BRdE3DVIiAp1kY5KD91MpXfRUF7pC7Pq8iW2x3OHaN+Njrx5RQZfhAVGHQPK+0cbNZgXT8O7D5urBuMiDYpflTG6u6SnRq/AuoMs+qBDwcB5Q7S+yza/Vqd2sXb+MQ9eexyTVPlVoAdIKV8U/oPmEH1Pej+IGVeKRnJ9ydqpg256XoH5RXMbZuuQ2oxf0Gp8D5TmwOxn+LGtkqTwJyjCDnnVJynNOPVgdIa3DjuZSerbjzOBwOVjtPRgt2Wf67ibBFbcxLLl2ZSRrzdyt5oC+IDEURDV1i5upk4unW/U9DZtT8VFhfpQSbXhaevz01ytrgFdjX0NXWUm3fqzUfXgNBStCmJHSROEol6OuFWO6ylzgHebnXxMbg8NgGcvMHUMzTnY2MibWw3sWNze8sST4MnINdPxc0r7oeWq0eAVlzyGrhZOjSu2sI2AdYsfR2/+L0ekXUPJXRr4t9eSRnIG1BS4gj0WHLB57o0dYBmDgULEWxT+z2qH2UnGRKAAdcs0sgB18+5gVa0snyYZinNztMUcBQoiwB3proWR+qi5GUHnUXrgelfdOwPaGWZvcHeQWMVmq6wYeabMrnhwv4uHOhJH6gHZ+/Z1qVLPPK6gqPh651xTS/JCgG4SMTNrZRSTBxinGsZf9eh6yfjTLxZmEVwst+19Ch8/Ygghb9iJdn3wV0rWeebLsqR/nurn2AWgypr5+Jfu X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: f4127a5c-17a9-47ee-afc8-08d97ce97355 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:35.4970 (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: 7u3NdD67FZVyFZblHkL4iBl/a4IV0rHgO1hf+GaZEumo3Gnb/zMUHi6jPd99NdP+ZXbo3V3kRSognmLtlpBbAa2lh3k6AqaDbavspgixNQI= 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, 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" From: Hanna Reitz Finalizing the job may cause its AioContext to change. This is noted by job_exit(), which points at job_txn_apply() to take this fact into account. However, job_completed() does not necessarily invoke job_txn_apply() (through job_completed_txn_success()), but potentially also job_completed_txn_abort(). The latter stores the context in a local variable, and so always acquires the same context at its end that it has released in the beginning -- which may be a different context from the one that job_exit() releases at its end. If it is different, qemu aborts ("qemu_mutex_unlock_impl: Operation not permitted"). Drop the local @outer_ctx variable from job_completed_txn_abort(), and instead re-acquire the actual job's context at the end of the function, so job_exit() will release the same. Signed-off-by: Hanna Reitz Reviewed-by: Vladimir Sementsov-Ogievskiy Message-Id: <20210907124245.143492-2-hreitz@redhat.com> Signed-off-by: Vladimir Sementsov-Ogievskiy --- job.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/job.c b/job.c index e7a5d28854..810e6a2065 100644 --- a/job.c +++ b/job.c @@ -737,7 +737,6 @@ static void job_cancel_async(Job *job, bool force) static void job_completed_txn_abort(Job *job) { - AioContext *outer_ctx = job->aio_context; AioContext *ctx; JobTxn *txn = job->txn; Job *other_job; @@ -751,10 +750,14 @@ static void job_completed_txn_abort(Job *job) txn->aborting = true; job_txn_ref(txn); - /* We can only hold the single job's AioContext lock while calling + /* + * We can only hold the single job's AioContext lock while calling * job_finalize_single() because the finalization callbacks can involve - * calls of AIO_WAIT_WHILE(), which could deadlock otherwise. */ - aio_context_release(outer_ctx); + * calls of AIO_WAIT_WHILE(), which could deadlock otherwise. + * Note that the job's AioContext may change when it is finalized. + */ + job_ref(job); + aio_context_release(job->aio_context); /* Other jobs are effectively cancelled by us, set the status for * them; this job, however, may or may not be cancelled, depending @@ -769,6 +772,10 @@ static void job_completed_txn_abort(Job *job) } while (!QLIST_EMPTY(&txn->jobs)) { other_job = QLIST_FIRST(&txn->jobs); + /* + * The job's AioContext may change, so store it in @ctx so we + * release the same context that we have acquired before. + */ ctx = other_job->aio_context; aio_context_acquire(ctx); if (!job_is_completed(other_job)) { @@ -779,7 +786,12 @@ static void job_completed_txn_abort(Job *job) aio_context_release(ctx); } - aio_context_acquire(outer_ctx); + /* + * Use job_ref()/job_unref() so we can read the AioContext here + * even if the job went away during job_finalize_single(). + */ + aio_context_acquire(job->aio_context); + job_unref(job); job_txn_unref(txn); } From patchwork Tue Sep 21 10:20:07 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: 12507529 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 34590C433EF for ; Tue, 21 Sep 2021 10:30:16 +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 AABD660F6B for ; Tue, 21 Sep 2021 10:30:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org AABD660F6B 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]:52830 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mSd2U-0003sz-IU for qemu-devel@archiver.kernel.org; Tue, 21 Sep 2021 06:30:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32818) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mSctQ-0001Lb-Au; Tue, 21 Sep 2021 06:20:52 -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 1mSctL-0002LA-OC; Tue, 21 Sep 2021 06:20:52 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=K4RStMT8Hmm/eJSEM9f22TWBass5SGjwge2rirj2xgX5dJ1oCEqHuudtk0ZVquaun7I+Y0/0P6q0NJovy0pUpvpYkJuY9SWaP6a98jPzTkJrTLk0YhhlZJkTeNBUJp3NR0HZCumB4/AMkqwfhchyWS7nwIYp7EA+gtvr63HkA4NAspukb4YHRpSO3uFoaDiqc+3Zy2+4bdDdS4crziTlncxRNzVxFNuoIXflNPK/PV7KKr0vl7gXEA1y/XlY+4VVsjOhSYJOMWQwLh5IsNHlGjAufOQ3Zn3ltODlSz3J2mgotYoiwTX3XndVCINt6M3h0OwUng6mp5dg1D4r4NAg6g== 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=3jteeIChXzd7qIMt4sHcJhkX6YxeHpAUU/Vkpcy7ylM=; b=VPuj3Y0tEzJI36fr/PRf4kAdLROh0hS1HQpZdv4CnjnNBiWwHDn4vEpcHe2Z9BC2g+Q0LJ9Rq3+s1ikukjI8xZup8y8rkkLPub9iujMRZYoP+Z2BlHMWcT2l+Csym76NBZ774eNgiio2feTBj93slSPHq0DH7dsh0Tslix6fg6RccZqq6qpMJriSq8Ou/CIjeW11Bg5mFkX3CyrIqse1+6cp6FZ3qN6y6bk7FBRyRFYSznN8t+k6/b1f8Vi8t+SMd7zCi1WsFYJ8MI5PwBxHk0Xve8xtBy2QsKSulRHFPxmb/Kh2xD0BPinTGt+TEt+OVSbpSOXal8XY6aBA6lCQxw== 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=3jteeIChXzd7qIMt4sHcJhkX6YxeHpAUU/Vkpcy7ylM=; b=myD54ct92zXvBzDQXa5iOWTvXXub5N2iYmhAB55MMJnCRELyH+agH6NT5bm7SwrzU+WZwyErAmHEIdu/PjVtop/ADnSkNbpZrQSoAkgt+SwANH9+3xEJ7tDVT2PlHgx6N5KUUaWnbeS+JluvPJquWAquCX+V6Kay9cinGw3FSSI= 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:36 +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:36 +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 Subject: [PULL 02/12] mirror: Keep s->synced on error Date: Tue, 21 Sep 2021 13:20:07 +0300 Message-Id: <20210921102017.273679-3-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:35 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 151722f6-0eb9-4f1d-8122-08d97ce973e9 X-MS-TrafficTypeDiagnostic: AS8PR08MB6631: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3826; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: y2xrJae+vAEzUmB9BdyACtYctp1wUSnyGduUldV7bVyFysgRj30WvmutsT53G5RlvHiHXiCcnQLBGW4HJo3cY9mOEsVIPsAHzDS4ApXukscEq7jyxHpT4rywcmRbbqCCEi9B2MeyI+Y64kP6OSMSwQ5gZseV8jDp+4aQripovPnrRBQz2KnsZH8o4wAa1uzHywIHlOc7UbsfmebbDJhPXatf9P9mHtg1nCaesXvLILyTMvxy2p+qO+Qf8oLO43xGcKxQrlh9TmIhpNDUAwJnsNDe7ZmoaGBN1/NQbr5bhDa5ME9vJ3v/s8TU71zC2GCPIKXGAYj78G/aa34UeTouwMVUsrPNmmqe4X07rDN5Jbu/qPEOrjZS0dBTMUguTobyFLjy8MZexZPkV+dNGjJM+bPrrgWatLHlF9+pbL/JQK1+RZqcK8nAGtpqrs7t0TrLfPlM1KfEJzqvEbrAIIZiyJ/A4nZPzfVJHqLHwt2xBXJgpmjKH2rwzIi8i59TKL5ut8OtdxFceVv0MkI4lNITpoi8Qrk2j9pVHAD/y3iULwdutOa8nJcQVgyB1wwT+uNYAtCT6YQSbhES9RylizBmDtN+zWsmbr3SYBIrPUplahFLbNFR0ylHxx7KLLBQznqvBkkPxSPTGV52yOLKFlcBlGDHcJfd4rzpzm5YyHoIx4OYKV+KcqUomVLVzePM5vXjrYQ5lLyXkzf7FV1GYqTZEQ== 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: ZQWV7A8XsAp0xcChlskpGImG0/fO3QjArRZ5Z88vC9fT49VROpBxboBoU+2sNMS0Q4EqlsB2GwyB4criYpvIgCloC+QA5A8tiIW1MvPrwJrNXyuyZuIayAx/Ra9PUXvYJzK82ZytjAuamNl8v0IPJHZxg5WhiQ9Nsr2JGRl670RIGDgQpW0PytDbYIx/ShtbB4nk+cCmpSmoc8Nr1LVlf+uP5CPpDDklFP4caQtR31SKz8mRmlJTYvViTOga1VUXQMwL9K9KsissoJGiaOLigy+XzouHddVJ3RXnRka5xlqbg4ijDPtSG3rbKNA+9oP1mcNXJVie0303+kY8sGCQaLaERvpktFvR+3rG8gqLHesyoCpLFgedAr1gcb3UyV6jjyydSgMl2a+MzQOSVBvvy0mi7Pf7aGZIjzSOSBUPN4BXF1CRYdxYI5xjgwaJPt7Na15djNjwuYKMlxF22Yc2EhJ/0VD6RUCucYwI9TVIZ/mHPcGywQ2CB6DrEkK/Q56q86I48EeATWDG1tFm8W6UetN774FPhmA2Zsdm7FNzTeTPXa/wwlllr0H2zWCBX5cTK127m0kNdU/pOiUK4IczfZwvjiInEHUZC+XS0ed8gtNDnXoP42j06VdngZwZv0t+iQxeUMOYUWWAKmFPEvwl3GGNHbRMsljodUv85lQOZmev6bqdMyZzpFDfDzXLkmm+evOvJrFRKRacXgNX3NTWYT4579hUfR+5aePVHR3OLHlmVQq5Tyb2xVaREjI93UH1VPvHuLpGnCSd2KSM5fGdi1eNlKpZBm0LzdqgZuH6jA380cq61aNp38GTstlaGWfzSalyWQD1dq+jhbF49Su4WAgz7woKGbKIGR7dTWLNleEOnN5kX/8b0WQ10JGELwJHIs1cQNLoSprPEdedcSSw9YLyKlVmLeOV5ruaAENrnfcQSfNawJoT75xrTL0ipFhjF8hqKgBCLGBOWf7R8CWwBdxx75/wpqoefs9ce5EO/dVogdkcFE0PJ2K0hR1fLCSU+QSoYlj3/GPDAMgtwSbTTmW14BT7ZkOGF7wX0KxlvRgy3N15ehVxlB5bPaLVEtwqRmdRErLfwZ8hJRmGzmw3Vi3hEi0FmEohldJcgQevBD5tKbTEqY+2a4ErmLMURkToSq6PJcHCLgyOXRVfnOuIEYZzxmB/cUPfDmqs/UVh1rujGST5Uh+l7SchpcUrN+WL+F73kuigoXGChof2kE0W8mrctRZ1GWhhdHQaZXtEATKbIlVIlAe12IuiDzK/65PhdPQzEVDy6j0BsvosApG0B0GBC21aiC6jsXLZqrIvbMfL7EXgeWEJmZN/36gPdWsv X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 151722f6-0eb9-4f1d-8122-08d97ce973e9 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:36.4757 (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: U/3VqmCaFitLzLXmuclPe7wrseO23iI3ZbOIqG/5AJNOfXMZmBJOWd3Ken+de+es68aj228BI/WrMgzqxUtYGEz4tBd0HRgPX6W8F1vCO2U= 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, 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" From: Hanna Reitz An error does not take us out of the READY phase, which is what s->synced signifies. It does of course mean that source and target are no longer in sync, but that is what s->actively_sync is for -- s->synced never meant that source and target are in sync, only that they were at some point (and at that point we transitioned into the READY phase). The tangible problem is that we transition to READY once we are in sync and s->synced is false. By resetting s->synced here, we will transition from READY to READY once the error is resolved (if the job keeps running), and that transition is not allowed. Signed-off-by: Hanna Reitz Reviewed-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Kevin Wolf Message-Id: <20210907124245.143492-3-hreitz@redhat.com> Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/mirror.c | 1 - 1 file changed, 1 deletion(-) diff --git a/block/mirror.c b/block/mirror.c index 85b781bc21..cad61496c2 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -121,7 +121,6 @@ typedef enum MirrorMethod { static BlockErrorAction mirror_error_action(MirrorBlockJob *s, bool read, int error) { - s->synced = false; s->actively_synced = false; if (read) { return block_job_error_action(&s->common, s->on_source_error, 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; From patchwork Tue Sep 21 10:20:09 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: 12507521 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 3158DC433EF for ; Tue, 21 Sep 2021 10:26:27 +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 BB94161038 for ; Tue, 21 Sep 2021 10:26:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org BB94161038 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]:46804 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mScyn-0007xu-Lz for qemu-devel@archiver.kernel.org; Tue, 21 Sep 2021 06:26:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32768) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mSctI-0001GU-Mq; Tue, 21 Sep 2021 06:20:44 -0400 Received: from mail-eopbgr150090.outbound.protection.outlook.com ([40.107.15.90]:45198 helo=EUR01-DB5-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 1mSctF-0002Rp-MF; Tue, 21 Sep 2021 06:20:43 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IfPU6tfLKbiGJlJzSC75KDU2yle0NR5kcBlkHmBe9RhmFf5C13+NbsxfteaiXzRZ2SzA5dRgXU2E+uPeiwGtN8IarrZb508kpZC3Dpu0aGLDrgnNXKHTBh82kFUfKyi5hD5ihFy9fRi5bw5nfA840NwUPLbp7s715FQiu3lbKJG2cG8H+ZHIh6MVtpO2LkIY8u4dMxfhPxDrsLbr7FpLwUySx0cw9XEU+aZWjlegzItfglvFKVd4CkXxvEqZNV6Bln1pBOrn2mHJDGJWYPQf0A1eJjjWKc7bYhRX+hPw1dF7XX+SRZGZ0SUhb4MhxcbgpOtO1d5+0Ll5ZDoY7siA0A== 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=sxm6wNINJAMInjyY1j3HNs187mlCkDXEIXD01+CIunU=; b=Kde0p64KDSHfBNxaNS+ZMbNjhzGJxgYX6Lp5tpmEby/HbpQhdylFXod5fIraLc0VISyvdJpEDpQWw0FiM/tP5Gwo+pjVgG2NaNk1WGGRxS4qGnzAHU5VEJoAKj1/9sMV7ZbWZ2RBkIrci0vgNScx++GMKQgzfJ7onCRyB1WufTSinafTyEGe0jb5TKB4o/MDrm+ZRrANvlfGBV+s+/UnCAC8MtM6XjlY6k7kzt6o0irZYHRIoA5xW4b9i73MThF1rCvRtGOZmgyogyVLsLd8ZgjTWuNbguq1QOsoS9fy1tt5/rUbV0uWLrfcfL6+OUKt9zSxlmZ5mxN1gfh5XRQEzg== 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=sxm6wNINJAMInjyY1j3HNs187mlCkDXEIXD01+CIunU=; b=nelafYezrSpA+VT3pyH4yZXDi+9seD21/2rosFCm98fH3wFImaIYyUwHPNf+KB3uwb+YoZLL3uP3KXjSB78BO8VUKfsVfq8Jr4jXcqfVgubKBHTQxlclXWpmnVSaQXCfzL4ASVzU3S9WuF+QkJ6iVsIrmxNbY3K7gSVvZRePcO0= 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 AS8PR08MB5944.eurprd08.prod.outlook.com (2603:10a6:20b:297::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14; Tue, 21 Sep 2021 10:20:38 +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:38 +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 04/12] job: Force-cancel jobs in a failed transaction Date: Tue, 21 Sep 2021 13:20:09 +0300 Message-Id: <20210921102017.273679-5-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:37 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 15a52fe6-0bf9-438d-fddd-08d97ce97534 X-MS-TrafficTypeDiagnostic: AS8PR08MB5944: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:612; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GKNNFMjj/nG3d35KFjFeVKi5xnSoNAT8Ls6W05i6O3Rw6PnMiINKY7AtO4TrJ7bsZ+bPdVj+ocvG1i4+AapnlSneGeTTMZmwZcB7UCn3NdbBt+ys/AHhWntf7zcXMB0+sxBkq2LQQofOAv2GmBt8STjZeimKPCkKbjVXZL9y98t278osvsJrXihBjlE9Yb8hOuKuVexzQJQ18ahrfuk6Gn0bgwkKso0GQYkLDfllKON9QDMC/B1ka81i/W6Qm4vsOB8qkUwsMsx8/XF/Wr2gANNWS6YvLqD7cGtPHh+Zr9cSu+SHyADWuOqtsdkz/EEOzV2trB9X7zKMl25fMaMO3I0ly43h0Xfy6WO0QyBRRDZnx+L2pRJC39Kj0+KOTypgx1i1KT6jU77273R3dudImwei+5MN8TlKvzMrcGJRPjG6roJe7iSxeGoz/1cMkxoPBU/w1dbxlp9KW3XEeSG0B25bjZFmBHHelOoL/Xy6iKT7tNH0+eU31Y3PxHwYBIE2tzVXfnshWCd9fnt9ryiPoSYWJ2HnBkOlpbBFklo4HN8J5/mafI0JTuGXpd9vkm1feUZIQSst+iaO+QBPVE2ktztcZjEkaZwtTnhV6RI4brqIXd8Jyh0/Q2144KoRftAWbZYhYQN0VBYo3nP7i5QU1xNolTPB3opH/TQmr4yTfUnrYM7Dyok4OoZULFPrdF662Nb/q/SH0lWo4Ib7ZMNTkA== 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)(8676002)(6512007)(83380400001)(86362001)(1076003)(8936002)(6916009)(186003)(38350700002)(316002)(52116002)(508600001)(66476007)(6666004)(66556008)(6506007)(2906002)(26005)(36756003)(66946007)(4326008)(6486002)(2616005)(956004)(38100700002)(5660300002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: bT12ls6Kn3A31vFGILjB0e1xfBsk9+BGnfDLqH3wDdz1RZT6xMlXb9FoIgmvlQMLGjk5dpMB/0UMBKuF3aY7lah28wqqdFfjAmMbxqnkw/gALfLGuBcvqWsMh70xy2PY3ite4aVLe6pN1stHurjV+gBhOg8/27gh20ysE3t34Jz6rCxYRbzqVCQZyikoGul1skuYk/oCGUdtzI9ISdLRT2cFuQb8Vkh5tsEGPkeS0JafHuhDgAqMl0lZ+JTQkVE12IsoMpsZhefeLBQszmkz+Ju6KdKUV2BT37X0Uy7ZJk29W6mk64T+TgzNNiM+xm2Pq/eeauVLY4VacGq/AdA5H4lLFVsLa+DiU6qXjpmfctZQo0sRwpUXceDJGfaQDjQ/Pkxth9n1A7B6Xm2BWMKQuR76+zosYjChLGUFa8GngxDLkOacRFOjLjuR6gDiejK0rQU+zaMeFpEKGF3DOtNQuXnf8MYbQj8W34MKBJY9r+CNdAKp9WSTH0O30H6pBULF1h/DAButTCwM8iukkNzRhuwEBl4Fb16UAVkAe5TgLk+suhYwf6UFz4nhwa0cXCKQN+IWOe1MqJ844sXg351K5paAsr+blryivZLj5nPdAEB3bZ7/oafOKkiwKngTbv6/38bLpKgo0z8+Itk+TQoY/q+9FycZMCusnzs4lqnIQTa4r67d4mzm2Oj/LrPnZnTZPBgFGACRTlBJNsfMhtRn8I+GNIKDCEI4Q1vhZ2UXRtsYRT3rjX+qPqYtw/Ss+ZTqjUHfsI9+4QSZjwESMkVkzsZyJER6KnssoWWWBjkGBbKVosbVLue88JMUZWY+Xuojo6dtS4C9BjYJdB0jByOUTDJN7vwU7U5LLE5HLzB3JsYj7vgJHZDlom2cWVlDmDZlNTJ/dz98IcnKo3fduZpv2frPWMedM8D07AHP/63sNMgfmT6yN8OZIBV5cl0DnpBSz3p2+ExET/89JAhW7kc6EjaUl/DLGSa5+8wXbBTIL6yGqtVAuDAvbuQc43q3pJ3JjDEvxCJn8vSw5Z0qa9IVmwZrqDjujjXIGwEbdJanMlfNSJbdrBKGp78rooxS8gR1oXZ7pYDJdO8w70Cv5Z4t/a0CQ2wbeA7QooguGQdgHB4QNe1AGwAVWzz2DCpn0Cpmq6NRdXgU8sGcWoMB0kbTURPo0MV+tkgUvJGQgmIcDqZGr654QTLDo35ghxXL4UcFtPywtXEjMZr+Cd+Q7jMLA9rbIeigBObTb1iZBhapFRImH4142GOR9ZSh+EiMsbEDvHDEbzbtLCI5P1jF8qx+K7+Wzpf4lfXfZv0P3PTyj7Y1L+WTfMwpigV1JUpkV7He X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 15a52fe6-0bf9-438d-fddd-08d97ce97534 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:38.6750 (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: fceLTJTrjE3CUcXhv7iTpvFJtReSGmeO3lvPunBnpG9v5MADQzauIXohJSW5JanV9jZido+dZSQ9VjEStczoAZAnzQyI+1VWI44HPe5Ury8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB5944 Received-SPF: pass client-ip=40.107.15.90; envelope-from=vsementsov@virtuozzo.com; helo=EUR01-DB5-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, 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" From: Hanna Reitz When a transaction is aborted, no result matters, and so all jobs within should be force-cancelled. Signed-off-by: Hanna Reitz Reviewed-by: Eric Blake Reviewed-by: Vladimir Sementsov-Ogievskiy Message-Id: <20210907124245.143492-5-hreitz@redhat.com> Signed-off-by: Vladimir Sementsov-Ogievskiy --- job.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/job.c b/job.c index 810e6a2065..e74d81928d 100644 --- a/job.c +++ b/job.c @@ -766,7 +766,12 @@ static void job_completed_txn_abort(Job *job) if (other_job != job) { ctx = other_job->aio_context; aio_context_acquire(ctx); - job_cancel_async(other_job, false); + /* + * This is a transaction: If one job failed, no result will matter. + * Therefore, pass force=true to terminate all other jobs as quickly + * as possible. + */ + job_cancel_async(other_job, true); aio_context_release(ctx); } } From patchwork Tue Sep 21 10:20:10 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: 12507549 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=-23.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,MENTIONS_GIT_HOSTING,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 D00C5C433F5 for ; Tue, 21 Sep 2021 10:35:58 +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 296D0610A1 for ; Tue, 21 Sep 2021 10:35:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 296D0610A1 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]:35014 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mSd81-0002i7-B3 for qemu-devel@archiver.kernel.org; Tue, 21 Sep 2021 06:35:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32802) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mSctO-0001Ib-C7; Tue, 21 Sep 2021 06:20:51 -0400 Received: from mail-eopbgr150090.outbound.protection.outlook.com ([40.107.15.90]:45198 helo=EUR01-DB5-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 1mSctJ-0002Rp-CA; Tue, 21 Sep 2021 06:20:49 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=I+SbpVc3N/zzwF7SSiGoqCdG1x6+JA1ZP0xKepDAx72bWTQgL5ZQTnQgQ0wmJKiF1WGqBy0XlhJ+hAPwdXeIayqhfjtHDhbtHyAcpd2fm1NppfTe45setwkn0EPcWkKZB/xAO45qO9+HV8LkQDrhgkf307qgQ/VQ1S28IVb3AQ1eVhNKBuvyhFCQUsqVVT2WUN04uXbjWEQYZgz82FA9nUr0aZU1W2CyMl+1fOulAvaVyOpyQa+YMdcU+pGXKRaqeNMFmKLYWuReSKD+jQ47jB6QYJkEDFfmV8V3qLWi1KAp19jkFFYu4woPEpA2kANPSWxbIDLRmfoQGUeLPigJXA== 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=dqy02NT2r4w9wctXTGxIMEOqTvjdAWhTtj5dSgeWovY=; b=VMTzOftnGvJ6sWlDtWIQ0/XmqtNIOwvPAjk1+vE66nPET+zSQ1tOvK79CDwzbv4cIdmK2HlB/gVumRvaQVgEVeVVNlDsSsFsuKnetWTIEhK5pcTrGMH5QdQT1VskUQFiq1l/XfvukHYIGKzWWozZmLxSmMr2tGhQSXA2TMRM6kImpc229WmyTv8kREWGYF/P9L3KHGW2NTYCkrQHPstvUxIVEidEvA6/lDX121S+PQbuQlgWXd+yOPlRKWRF/vbbOiFNkUuI80NzXqktLwTfpGMjr7Fcnv22w025UmAy5o0CWnX9MFEmchm2fkJvK9p9X04BTzk/6W71oqnO79QGTw== 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=dqy02NT2r4w9wctXTGxIMEOqTvjdAWhTtj5dSgeWovY=; b=YGBbDC9FAXtpmSNDtJUeaOw2iwRunT3feAzU1scuFJleExvR1xHLO3nn02rm7Qca8cr2qNElEB8LdLVafJrS+pr2SIiaSomU736hyTj96jvmhLo2+HWB1C2aj2gACYPc4aJJVW+P7jd50di0VbJ2+JxK3yh1FHn5F+FcvQDMkq8= 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 AS8PR08MB5944.eurprd08.prod.outlook.com (2603:10a6:20b:297::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14; Tue, 21 Sep 2021 10:20:40 +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:39 +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 05/12] job: @force parameter for job_cancel_sync() Date: Tue, 21 Sep 2021 13:20:10 +0300 Message-Id: <20210921102017.273679-6-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:38 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c6048b64-ca05-4eaa-7bbe-08d97ce975e2 X-MS-TrafficTypeDiagnostic: AS8PR08MB5944: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:160; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: l0O1K6qS91ZkIYK+FdNKl02lO/Fm5fivmjMgEz9r3WyPePAz97byysFsqhiQ4Zwp4bIgqC0jZtJy32N0EgbTHM4k6/xj7eT98KaPfrE5yco1/V4j4JP1EiMcpREzfRTnnKoNQQz1GIDro7ue3IHCqTDFJpgmfRSzAKC4pwdG0Pii40UeORd03gEG5BHFZ8wGWe9Dmmnh3AgqucTmF9emVrqPpRLi4CmVxL5u5ItasO/YG5OtL3OlO8VuX5DCsosZ1AwoOruHKp8umzOXVO4qhhYgGVcAH12sIZ3vdzPAwqRg4vVWjXromKa17m/bIhOISSCkKtJkBXBti2g4vTMJnPnXwmuBV1qUytv6bbV05V7RCSegW4ycAqfxoaH6HM7Ml/O+GXwFD9t1svAUJr/HkcL8IgQr9FA+H6iX8a8k/GK8n5Hrd9G9BHh5C7cgqW/D9ZwyOi+tWNV4QsAQQuMDULGWyavaMghkXpE3sjTpPFz6F8ieb3GFCpO/8TQ9oGs4vGCXcpkIjqSZAYWZeKpzP3TRw1+pSUEDnuLiEVSWoEhPWKRodQQ5vMFFCwsa6VmmGR8GKW495RlGTzhMA6fwnJ9P57krtr6HbLf0wlWPAVsi+/YpTGMqmK6krLzkvD9m7DDx4cZeDDHmJvoLbe/q8Rx9D8I1Fi27ktO2+LMYiULxRu/LcWZrYuIWIzPPfFMTiaVBESXPaF7MhEVXEj4L+cL/MZgyxQGxuavmvvE9MtdbYdqhtohGgE0nGYfEllFSuygEuhvNDrkxp6kIZ8EWtGBAqIkjtGnYVuek2skdfrA= 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)(8676002)(6512007)(83380400001)(86362001)(30864003)(1076003)(8936002)(6916009)(186003)(38350700002)(316002)(52116002)(508600001)(66476007)(6666004)(66556008)(6506007)(2906002)(26005)(36756003)(66946007)(966005)(4326008)(6486002)(2616005)(956004)(38100700002)(5660300002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: U+E7D4/GocNOtJm9n5HISgOLyvkxNqMA8m63lByqKRP7Fybr1SbcF1lPDXc90BkyEmguKcsI9GYoiaqVqy7oTNIoICn9i1pITPnZr0yN0c4CwGV2cKk0xYTaLyd2GLcGT+VJoL4oK8T209HyMIp6sc+JJZZ2PaFXmeVduEDWuTvFOf3hSrmcypjjlLQH6EKx0hCzhdXIwqVlvnEGZSQLMyVxCrzimOUSgleRHqX9q11rATO9T+9o1OgwcSTCKD6Ybb0dQmcFo4RAfr4FxOE5nu6UIPYOrpEWDOsGFThjub9u6Wib34VrT8xD7gixHT1u2UCudMDkNF0kNO0tm0Fu32TUYnOyNJc8JInFw558ys6jTlD/ovJPpGxOLdsautD49RQtzqcdqwI2Om7iVvM4oonNXQ66/jpuTL4zt/ZSkZ1rBd4KI4xsLPArzYp35T99SGPvuNaS/tqdGUwKrPCZ0AitIWwkRr1/g49o7NZcFyaVrPaGQ0RommUcIlTDkwjIjBiCyx5ddPtRtf6eVv1UmHkHjUE3FyWYxuaxUTRNb5PGBOA/yIpV6IjuygcWMWIr3tH4B7rgWZvAPe9MXzpmPxSyi5Q2CE5PW9D0ZdqKL8y7my9Lu73WMgBtLWqrkx6g6+xjyS7jCXEZ6RavbyuYd87WehVjxKJfah2hRfivK0AdYT0zI1+zxDNyterDLMiH4vOSGcBGfgEytUlB9jhXlo3ifH7yovFLRHrY+BRkWkNMCptppimkS/sd2RaVJ6GcPMPgeU2wFqygQt33pya5uDreSEudNJAQoPEFkUnTzvZ+RGAyjKlanWhoPEU0DUcin+124G0ND1eE9YBuhavsMtqTL2PzgoLy7lUVp0OG17lSj+TqdWvlGsaH6mA3PVx4foxHX3PGTP5XM+AnXYps1l5Pj/Wi9wpBAmzpYFU3nCmUxMAgsyo8bwdEdaLHK86DYG2OVgSpZyrXxsMAVxDSzZXB8zyDJKpgXi3WMqCh7GiAe2bfW0RuNvz1NIwVbeNS0BmjseTdEpjxIvqX2nwk43cvMlf996I5R60RbSM8RB02FRy7qQydBzbJeu3vORAcCjOvOvmBEVA+uWkA2uoI82EwNynyWUN/KAH4Ayzx882TG9JI/znqGEgXXI+lA/fMhE9afhx+B4bvC4ukcfW0JBinKXezujFFVhM2bVM4AMt6F+eYJhYI8U/R81UWshL5uXqMgU1Al6YnENfokAXYfu2M4JPIo/v2FKkNYKgRbjO4YvDvcGiYlyMkV2NEHc9+N7YtIzwxwjg6R5PKV/6/POQHMk5JsWeqHVQYUZzTtMhpIqTMke3AbCibdtLOVINT X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: c6048b64-ca05-4eaa-7bbe-08d97ce975e2 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:39.8747 (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: bOrT1x8Jsd+y2q8fsX6kPo/yx2o7Klfdsk+zeLQwoSbeUvF7RBIkZiDrWqTc7ksMKs1kkvQguu38av8tGJQOPOuWWHBiHMwbbb22zA7jLOc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB5944 Received-SPF: pass client-ip=40.107.15.90; envelope-from=vsementsov@virtuozzo.com; helo=EUR01-DB5-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, 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" From: Hanna Reitz Callers should be able to specify whether they want job_cancel_sync() to force-cancel the job or not. In fact, almost all invocations do not care about consistency of the result and just want the job to terminate as soon as possible, so they should pass force=true. The replication block driver is the exception, specifically the active commit job it runs. As for job_cancel_sync_all(), all callers want it to force-cancel all jobs, because that is the point of it: To cancel all remaining jobs as quickly as possible (generally on process termination). So make it invoke job_cancel_sync() with force=true. This changes some iotest outputs, because quitting qemu while a mirror job is active will now lead to it being cancelled instead of completed, which is what we want. (Cancelling a READY mirror job with force=false may take an indefinite amount of time, which we do not want when quitting. If users want consistent results, they must have all jobs be done before they quit qemu.) Buglink: https://gitlab.com/qemu-project/qemu/-/issues/462 Signed-off-by: Hanna Reitz Message-Id: <20210907124245.143492-6-hreitz@redhat.com> Reviewed-by: Eric Blake Reviewed-by: Vladimir Sementsov-Ogievskiy Signed-off-by: Vladimir Sementsov-Ogievskiy --- include/qemu/job.h | 10 ++--- block/replication.c | 4 +- blockdev.c | 4 +- job.c | 18 ++++++-- tests/unit/test-blockjob.c | 2 +- tests/qemu-iotests/109.out | 60 +++++++++++---------------- tests/qemu-iotests/tests/qsd-jobs.out | 2 +- 7 files changed, 50 insertions(+), 50 deletions(-) diff --git a/include/qemu/job.h b/include/qemu/job.h index 41162ed494..2eddf3b536 100644 --- a/include/qemu/job.h +++ b/include/qemu/job.h @@ -506,18 +506,18 @@ void job_user_cancel(Job *job, bool force, Error **errp); /** * Synchronously cancel the @job. The completion callback is called - * before the function returns. The job may actually complete - * instead of canceling itself; the circumstances under which this - * happens depend on the kind of job that is active. + * before the function returns. If @force is false, the job may + * actually complete instead of canceling itself; the circumstances + * under which this happens depend on the kind of job that is active. * * Returns the return value from the job if the job actually completed * during the call, or -ECANCELED if it was canceled. * * Callers must hold the AioContext lock of job->aio_context. */ -int job_cancel_sync(Job *job); +int job_cancel_sync(Job *job, bool force); -/** Synchronously cancels all jobs using job_cancel_sync(). */ +/** Synchronously force-cancels all jobs using job_cancel_sync(). */ void job_cancel_sync_all(void); /** diff --git a/block/replication.c b/block/replication.c index 32444b9a8f..55c8f894aa 100644 --- a/block/replication.c +++ b/block/replication.c @@ -149,7 +149,7 @@ static void replication_close(BlockDriverState *bs) if (s->stage == BLOCK_REPLICATION_FAILOVER) { commit_job = &s->commit_job->job; assert(commit_job->aio_context == qemu_get_current_aio_context()); - job_cancel_sync(commit_job); + job_cancel_sync(commit_job, false); } if (s->mode == REPLICATION_MODE_SECONDARY) { @@ -726,7 +726,7 @@ static void replication_stop(ReplicationState *rs, bool failover, Error **errp) * disk, secondary disk in backup_job_completed(). */ if (s->backup_job) { - job_cancel_sync(&s->backup_job->job); + job_cancel_sync(&s->backup_job->job, true); } if (!failover) { diff --git a/blockdev.c b/blockdev.c index e79c5f3b5e..b35072644e 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1847,7 +1847,7 @@ static void drive_backup_abort(BlkActionState *common) aio_context = bdrv_get_aio_context(state->bs); aio_context_acquire(aio_context); - job_cancel_sync(&state->job->job); + job_cancel_sync(&state->job->job, true); aio_context_release(aio_context); } @@ -1948,7 +1948,7 @@ static void blockdev_backup_abort(BlkActionState *common) aio_context = bdrv_get_aio_context(state->bs); aio_context_acquire(aio_context); - job_cancel_sync(&state->job->job); + job_cancel_sync(&state->job->job, true); aio_context_release(aio_context); } diff --git a/job.c b/job.c index e74d81928d..dfac35d553 100644 --- a/job.c +++ b/job.c @@ -981,9 +981,21 @@ static void job_cancel_err(Job *job, Error **errp) job_cancel(job, false); } -int job_cancel_sync(Job *job) +/** + * Same as job_cancel_err(), but force-cancel. + */ +static void job_force_cancel_err(Job *job, Error **errp) { - return job_finish_sync(job, &job_cancel_err, NULL); + job_cancel(job, true); +} + +int job_cancel_sync(Job *job, bool force) +{ + if (force) { + return job_finish_sync(job, &job_force_cancel_err, NULL); + } else { + return job_finish_sync(job, &job_cancel_err, NULL); + } } void job_cancel_sync_all(void) @@ -994,7 +1006,7 @@ void job_cancel_sync_all(void) while ((job = job_next(NULL))) { aio_context = job->aio_context; aio_context_acquire(aio_context); - job_cancel_sync(job); + job_cancel_sync(job, true); aio_context_release(aio_context); } } diff --git a/tests/unit/test-blockjob.c b/tests/unit/test-blockjob.c index dcacfa6c7c..4c9e1bf1e5 100644 --- a/tests/unit/test-blockjob.c +++ b/tests/unit/test-blockjob.c @@ -230,7 +230,7 @@ static void cancel_common(CancelJob *s) ctx = job->job.aio_context; aio_context_acquire(ctx); - job_cancel_sync(&job->job); + job_cancel_sync(&job->job, true); if (sts != JOB_STATUS_CREATED && sts != JOB_STATUS_CONCLUDED) { Job *dummy = &job->job; job_dismiss(&dummy, &error_abort); diff --git a/tests/qemu-iotests/109.out b/tests/qemu-iotests/109.out index 8f839b4b7f..e29280015e 100644 --- a/tests/qemu-iotests/109.out +++ b/tests/qemu-iotests/109.out @@ -44,9 +44,8 @@ read 512/512 bytes at offset 0 {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "standby", "id": "src"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "ready", "id": "src"}} -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "waiting", "id": "src"}} -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "pending", "id": "src"}} -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 1024, "offset": 1024, "speed": 0, "type": "mirror"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "aborting", "id": "src"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_CANCELLED", "data": {"device": "src", "len": 1024, "offset": 1024, "speed": 0, "type": "mirror"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "concluded", "id": "src"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "null", "id": "src"}} Images are identical. @@ -95,9 +94,8 @@ read 512/512 bytes at offset 0 {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "standby", "id": "src"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "ready", "id": "src"}} -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "waiting", "id": "src"}} -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "pending", "id": "src"}} -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 197120, "offset": 197120, "speed": 0, "type": "mirror"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "aborting", "id": "src"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_CANCELLED", "data": {"device": "src", "len": 197120, "offset": 197120, "speed": 0, "type": "mirror"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "concluded", "id": "src"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "null", "id": "src"}} Images are identical. @@ -146,9 +144,8 @@ read 512/512 bytes at offset 0 {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "standby", "id": "src"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "ready", "id": "src"}} -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "waiting", "id": "src"}} -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "pending", "id": "src"}} -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 327680, "offset": 327680, "speed": 0, "type": "mirror"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "aborting", "id": "src"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_CANCELLED", "data": {"device": "src", "len": 327680, "offset": 327680, "speed": 0, "type": "mirror"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "concluded", "id": "src"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "null", "id": "src"}} Images are identical. @@ -197,9 +194,8 @@ read 512/512 bytes at offset 0 {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "standby", "id": "src"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "ready", "id": "src"}} -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "waiting", "id": "src"}} -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "pending", "id": "src"}} -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 1024, "offset": 1024, "speed": 0, "type": "mirror"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "aborting", "id": "src"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_CANCELLED", "data": {"device": "src", "len": 1024, "offset": 1024, "speed": 0, "type": "mirror"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "concluded", "id": "src"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "null", "id": "src"}} Images are identical. @@ -248,9 +244,8 @@ read 512/512 bytes at offset 0 {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "standby", "id": "src"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "ready", "id": "src"}} -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "waiting", "id": "src"}} -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "pending", "id": "src"}} -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 65536, "offset": 65536, "speed": 0, "type": "mirror"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "aborting", "id": "src"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_CANCELLED", "data": {"device": "src", "len": 65536, "offset": 65536, "speed": 0, "type": "mirror"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "concluded", "id": "src"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "null", "id": "src"}} Images are identical. @@ -299,9 +294,8 @@ read 512/512 bytes at offset 0 {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "standby", "id": "src"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "ready", "id": "src"}} -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "waiting", "id": "src"}} -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "pending", "id": "src"}} -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 2560, "offset": 2560, "speed": 0, "type": "mirror"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "aborting", "id": "src"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_CANCELLED", "data": {"device": "src", "len": 2560, "offset": 2560, "speed": 0, "type": "mirror"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "concluded", "id": "src"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "null", "id": "src"}} Images are identical. @@ -349,9 +343,8 @@ read 512/512 bytes at offset 0 {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "standby", "id": "src"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "ready", "id": "src"}} -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "waiting", "id": "src"}} -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "pending", "id": "src"}} -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 2560, "offset": 2560, "speed": 0, "type": "mirror"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "aborting", "id": "src"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_CANCELLED", "data": {"device": "src", "len": 2560, "offset": 2560, "speed": 0, "type": "mirror"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "concluded", "id": "src"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "null", "id": "src"}} Images are identical. @@ -399,9 +392,8 @@ read 512/512 bytes at offset 0 {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "standby", "id": "src"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "ready", "id": "src"}} -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "waiting", "id": "src"}} -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "pending", "id": "src"}} -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 31457280, "offset": 31457280, "speed": 0, "type": "mirror"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "aborting", "id": "src"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_CANCELLED", "data": {"device": "src", "len": 31457280, "offset": 31457280, "speed": 0, "type": "mirror"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "concluded", "id": "src"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "null", "id": "src"}} Images are identical. @@ -449,9 +441,8 @@ read 512/512 bytes at offset 0 {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "standby", "id": "src"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "ready", "id": "src"}} -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "waiting", "id": "src"}} -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "pending", "id": "src"}} -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 327680, "offset": 327680, "speed": 0, "type": "mirror"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "aborting", "id": "src"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_CANCELLED", "data": {"device": "src", "len": 327680, "offset": 327680, "speed": 0, "type": "mirror"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "concluded", "id": "src"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "null", "id": "src"}} Images are identical. @@ -499,9 +490,8 @@ read 512/512 bytes at offset 0 {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "standby", "id": "src"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "ready", "id": "src"}} -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "waiting", "id": "src"}} -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "pending", "id": "src"}} -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 2048, "offset": 2048, "speed": 0, "type": "mirror"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "aborting", "id": "src"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_CANCELLED", "data": {"device": "src", "len": 2048, "offset": 2048, "speed": 0, "type": "mirror"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "concluded", "id": "src"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "null", "id": "src"}} Images are identical. @@ -529,9 +519,8 @@ WARNING: Image format was not specified for 'TEST_DIR/t.raw' and probing guessed {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "standby", "id": "src"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "ready", "id": "src"}} -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "waiting", "id": "src"}} -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "pending", "id": "src"}} -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 512, "offset": 512, "speed": 0, "type": "mirror"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "aborting", "id": "src"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_CANCELLED", "data": {"device": "src", "len": 512, "offset": 512, "speed": 0, "type": "mirror"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "concluded", "id": "src"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "null", "id": "src"}} Images are identical. @@ -552,9 +541,8 @@ Images are identical. {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "standby", "id": "src"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "ready", "id": "src"}} -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "waiting", "id": "src"}} -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "pending", "id": "src"}} -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 512, "offset": 512, "speed": 0, "type": "mirror"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "aborting", "id": "src"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_CANCELLED", "data": {"device": "src", "len": 512, "offset": 512, "speed": 0, "type": "mirror"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "concluded", "id": "src"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "null", "id": "src"}} Images are identical. diff --git a/tests/qemu-iotests/tests/qsd-jobs.out b/tests/qemu-iotests/tests/qsd-jobs.out index 189423354b..c1bc9b8356 100644 --- a/tests/qemu-iotests/tests/qsd-jobs.out +++ b/tests/qemu-iotests/tests/qsd-jobs.out @@ -8,7 +8,7 @@ QMP_VERSION {"return": {}} {"return": {}} {"return": {}} -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "job0", "len": 0, "offset": 0, "speed": 0, "type": "commit"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_CANCELLED", "data": {"device": "job0", "len": 0, "offset": 0, "speed": 0, "type": "commit"}} === Streaming can't get permission on base node === From patchwork Tue Sep 21 10:20:11 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: 12507495 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 77FE6C433F5 for ; Tue, 21 Sep 2021 10:22:59 +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 B51AD61038 for ; Tue, 21 Sep 2021 10:22:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B51AD61038 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]:41610 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mScvR-0004WV-SW for qemu-devel@archiver.kernel.org; Tue, 21 Sep 2021 06:22:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32858) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mSctS-0001Ot-EL; Tue, 21 Sep 2021 06:20:54 -0400 Received: from mail-eopbgr150090.outbound.protection.outlook.com ([40.107.15.90]:45198 helo=EUR01-DB5-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 1mSctP-0002Rp-1p; Tue, 21 Sep 2021 06:20:54 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DYaRjAe7TtsVpY/77CUXzSg/Jip1Kso2nGv5wZoHqEtOpESMLAA0/G5myDahqWtA9vP67zyXhGJ8VocTL8QKcWLG0Ql8SGb28ej9JNmM9sazsN49AQSOrmdiaj2QHy99cxMB1h3WhSzIm6rXSlDl6m6lzQM4W/WSHyEjoCNOj238Or9VRfjHf/sIDkCs7OijXYe0Hxie62utfNRZC5Dkz6doVhotlzX8EbzdVm0ac7vbAWRzUfhXgbUeXEX4H9Wj/G5ivetTlt0zvt5YFGY1VrDb6Ek+txLzQAAfvrzYPN0rz25mEkQ7aDL1pocERs5GPLp79I4nS5vyCCr/QKHwIg== 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=a4pk0zXyfELarXEGWwbJZ3kfBq4sF8EEDFdqWmXHJlM=; b=Ibo/tCb6RUglKbg6BTmBZdUZp+5Rx9KjJOjChV1dzUwNPxCYVhoaCEuEprxWl1Tk1fzuC1I2dTzlh7geER/wH/FoVDLOl9d7htGYemb56787/cV9Rf+gvMUlBZtjP2UxLKrVNS/CNrDH2xY+bLSI08Bx1UTKvq3HFyBMiXcPBzuuAd1erx2q3I0vkajY9ygAE99I7aNI/qeYpJ89MKDrDr3IAFL7Vi57Peem9c/IVFWjmhKve5XTcts9bDFGfg7NK3QaWPO0iM6x3KFMOiPzR7wRdNkmshj5ycjk9ugNBxNz4doZHgz3aVqXUqRidgtCMm2LNAYq8Orq5eQlHFyFuQ== 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=a4pk0zXyfELarXEGWwbJZ3kfBq4sF8EEDFdqWmXHJlM=; b=avnKyl/VN4EB6aykhOry9g10lwcv5c4ZdP3PqN2+Oqawvk5QEV282/skApolghr3EyYAs4AiOhVDGfrRx3/holHHd8frexlsKo2wOom95WTvoA4oQ5+sjo7tPqUMDxlHvGnMBoA4RZz1JyzzXSZ+81RnmzAKgpLn26HGC3A7a/A= 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 AS8PR08MB5944.eurprd08.prod.outlook.com (2603:10a6:20b:297::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14; Tue, 21 Sep 2021 10:20:41 +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:40 +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 06/12] jobs: Give Job.force_cancel more meaning Date: Tue, 21 Sep 2021 13:20:11 +0300 Message-Id: <20210921102017.273679-7-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:40 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5ca94f3a-78d1-42b7-cc5a-08d97ce97691 X-MS-TrafficTypeDiagnostic: AS8PR08MB5944: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:612; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TUyNIoq+42M+t9EXzoqPDer015mqnh4nosswf0Y3phhWyF3kmEWyor5DPbv5w0J6RbxIZHZ9XEKDxUpl2798Rlb0vYnn7OrkMJVsfo9gf2IUzw1DiXiVjRZqyvBCb/UOkRkW1MpkN7KM4q2iY7/TgncNoSDozp26bjAXemr5fsfMum2o8TCzkbBXUlatTDpLqgjHcmakp3M4+rJ1iuzfZqZGk+/JV7EQzDJtXxRJIe5LcVk6wbz0zw6MF52BQuixKRo7j4x1ViY7lO8G1Iihcv/CfIO5Ml/Sf1QlxuRlAYEVJCDqbKdx+fy7w8/X4pQJdc3kHxWau0LucB5VWf3MxMBsrWBCG1C38n9NUNfBBam6Pw7e0oa47+vOAfbll1NulxN3mqsOubK1b+5UvNm+CUk9PKbuRbYiWsFxMI7uAe61tZ+GBJshLC95k4mcKU3b/W8CTCDg/SpWpM4IOTcTLnMUQpEPn1Hc2B8UVR/0X0lUhGMwP0/KnzgKZfea1xOTKB3frdCw/tmKtIx4nFBnRKN6MghKdf241jUnc2OMX7ox0vn7NaNaH2ndD9/9GvgTC5a0dz8rE+L2s3DbG/ewArKGVhA4TbsDi4VtZV/V1Zfz/ooTR6Ib+bNn7DE4OKtYGBl0g5/CDm7rXJgpr65n+Ow94/wzbaECpvv9+gICJnLgvGoRcSR4/7F84jhrVqg8wIaBtFR+HDuIi91LpInfgMJITvRtqWROVb8CoE4/62o= 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)(8676002)(6512007)(83380400001)(86362001)(1076003)(8936002)(6916009)(186003)(38350700002)(316002)(52116002)(508600001)(66476007)(6666004)(66556008)(6506007)(2906002)(26005)(36756003)(66946007)(4326008)(6486002)(2616005)(956004)(38100700002)(5660300002)(309714004); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: LRJqG4yJ2o+wEU5xG6E00rasMub1c4aAbGhNd7+OIlBFebJMlJ7QvpI9wEsKtRwnFOP9L/zfxNQA6Zi3IU66CiCbxmiPh8v9MrS3h4sQG4Rr7sTJMwtqyCpbwXUQVIOsD+KK9EfK4M+UXHHrNFM48LOFW+sydQe8wZZ7wsxpg5RERO8SIB2Gv3nr88O/9ElSAM/nAx3fjc2wNHrDq6ZfFHfz7/fvf6LNxIh4/T8CBfeJSq/fcuSWm7AWHvuK3h0rHcE6Zxvdl69P/ZEXkT6FRQfEUo6f0bGcPNWCjD9DoWlb+qMNBZRFIrcQ5LWvwD0jEoGRQpkryD9xo8reLWvjQvDa1OQvEr8bhvdRtggcnLwlslO5NkJlSG5rs9YnijcrQQqEn5uyRXFlAGIII0a+aFKY3HNnA87HWcK9b1LkXFmwkmA2HfnIdloF3SOzSiOvMMype8Ba7OKf7SQtqTvFFkEcIu0EKEKVdHG9x/vWbuHU/f2IxFkQWtcVc+MdDI+lrSUZhFvCEMhboWlasmU5eXFDMtMtUzYL+PjaMSOM8JfASulgzPzuNK+OP1qPZ9DyVW/fcln4dlW+Gp7A+wqPHXeHF5e0aKTGdQDHVFYOY0sX98hQ1ubkc0IDS3mShGoJ43WPQ444Ut6zcPued9FSda3EQQ3TBAG26WypZpWc22DbMp01JJth44R7vJmilFcTP3zjAd+q5hhzBz0ff/FQNuTvejBmqlSdPWCbdbMo6NKH7l1C1Tewx9CRt07xmiO3PfgK2pVOZIOzYBjgQT7P8DTHh7RuUHNPFrT6dkckf1KJV/qtMO6RMznxverefWB9gU87waqViO1I6C6BjwkOIpFRzZdaNqbzuiRMWzNDuPBoMUFZVS6qVbhANleY2bDsPHX+x31h53d9OGGEAbr3naoUn0N/5ntS8c7EP5K/AXRPdTYLVT3yy6CxQwSGSt1doN/7cYrYq3P2uGSX7WyRqYtvZDtRSCz9ZCFKX81Z95Onme9lyUmVA0tD1ti+9kEDmV78tSnKtzUrvqInufRmdrRiq2ilYOJSmIg2rMYL560V25EuLXhRB1MC3tPX1s1OmaOi4XTMNCsBNecYBxMYZhg69Vl2Wsh4wVXfmBeBYg21lMhBElhCmYNKbYZLbVZkyZlx4EZkwKcpDwUtbrYSAnXfMCXPpGyx7F5fGDXA47H3CIk3q62COHHomPL4XCMCA7MLwU97NhiPFHzXG0DYj9CA4eg7ld1zC192hdEiIGfA2Cv9+WD+WbeNkoRcENbp7rYAmnOTU77xP+AlRujUiE3jXrOKX15T2Vj9RO9i1zdQOTmrZilN7dR8j4d5k8Wv X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5ca94f3a-78d1-42b7-cc5a-08d97ce97691 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:40.9291 (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: mxB6wgbo0mCqOWEex1PrIAEqhm1u5e4ekX4PjcluocEpVdl4C4tP/vSGT+fkVauKN6Pimj4LTD1I5JfOrv9pmYFLf9w/woazRCw2uiZAopw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB5944 Received-SPF: pass client-ip=40.107.15.90; envelope-from=vsementsov@virtuozzo.com; helo=EUR01-DB5-obe.outbound.protection.outlook.com X-Spam_score_int: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 5.0 requ) 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" From: Hanna Reitz We largely have two cancel modes for jobs: First, there is actual cancelling. The job is terminated as soon as possible, without trying to reach a consistent result. Second, we have mirror in the READY state. Technically, the job is not really cancelled, but it just is a different completion mode. The job can still run for an indefinite amount of time while it tries to reach a consistent result. We want to be able to clearly distinguish which cancel mode a job is in (when it has been cancelled). We can use Job.force_cancel for this, but right now it only reflects cancel requests from the user with force=true, but clearly, jobs that do not even distinguish between force=false and force=true are effectively always force-cancelled. So this patch has Job.force_cancel signify whether the job will terminate as soon as possible (force_cancel=true) or whether it will effectively remain running despite being "cancelled" (force_cancel=false). To this end, we let jobs that provide JobDriver.cancel() tell the generic job code whether they will terminate as soon as possible or not, and for jobs that do not provide that method we assume they will. Signed-off-by: Hanna Reitz Reviewed-by: Eric Blake Reviewed-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Kevin Wolf Message-Id: <20210907124245.143492-7-hreitz@redhat.com> Signed-off-by: Vladimir Sementsov-Ogievskiy --- include/qemu/job.h | 11 ++++++++++- block/backup.c | 3 ++- block/mirror.c | 24 ++++++++++++++++++------ job.c | 6 +++++- 4 files changed, 35 insertions(+), 9 deletions(-) diff --git a/include/qemu/job.h b/include/qemu/job.h index 2eddf3b536..90f6abbd6a 100644 --- a/include/qemu/job.h +++ b/include/qemu/job.h @@ -253,8 +253,17 @@ struct JobDriver { /** * If the callback is not NULL, it will be invoked in job_cancel_async + * + * This function must return true if the job will be cancelled + * immediately without any further I/O (mandatory if @force is + * true), and false otherwise. This lets the generic job layer + * know whether a job has been truly (force-)cancelled, or whether + * it is just in a special completion mode (like mirror after + * READY). + * (If the callback is NULL, the job is assumed to terminate + * without I/O.) */ - void (*cancel)(Job *job, bool force); + bool (*cancel)(Job *job, bool force); /** Called when the job is freed */ diff --git a/block/backup.c b/block/backup.c index 687d2882bc..e8a13f9178 100644 --- a/block/backup.c +++ b/block/backup.c @@ -327,11 +327,12 @@ static void coroutine_fn backup_set_speed(BlockJob *job, int64_t speed) } } -static void backup_cancel(Job *job, bool force) +static bool backup_cancel(Job *job, bool force) { BackupBlockJob *s = container_of(job, BackupBlockJob, common.job); bdrv_cancel_in_flight(s->target_bs); + return true; } static const BlockJobDriver backup_job_driver = { diff --git a/block/mirror.c b/block/mirror.c index 86ddecb86b..7022d8011b 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1094,9 +1094,7 @@ static int coroutine_fn mirror_run(Job *job, Error **errp) 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) && - (!job_is_ready(&s->common.job) || s->common.job.force_cancel)) - { + if (job_is_cancelled(&s->common.job) && s->common.job.force_cancel) { break; } s->last_pause_ns = qemu_clock_get_ns(QEMU_CLOCK_REALTIME); @@ -1109,7 +1107,7 @@ immediate_exit: * the target is a copy of the source. */ assert(ret < 0 || - ((s->common.job.force_cancel || !job_is_ready(&s->common.job)) && + (s->common.job.force_cancel && job_is_cancelled(&s->common.job))); assert(need_drain); mirror_wait_for_all_io(s); @@ -1195,14 +1193,27 @@ static bool mirror_drained_poll(BlockJob *job) return !!s->in_flight; } -static void mirror_cancel(Job *job, bool force) +static bool mirror_cancel(Job *job, bool force) { MirrorBlockJob *s = container_of(job, MirrorBlockJob, common.job); BlockDriverState *target = blk_bs(s->target); - if (force || !job_is_ready(job)) { + /* + * Before the job is READY, we treat any cancellation like a + * force-cancellation. + */ + force = force || !job_is_ready(job); + + if (force) { bdrv_cancel_in_flight(target); } + return force; +} + +static bool commit_active_cancel(Job *job, bool force) +{ + /* Same as above in mirror_cancel() */ + return force || !job_is_ready(job); } static const BlockJobDriver mirror_job_driver = { @@ -1232,6 +1243,7 @@ static const BlockJobDriver commit_active_job_driver = { .abort = mirror_abort, .pause = mirror_pause, .complete = mirror_complete, + .cancel = commit_active_cancel, }, .drained_poll = mirror_drained_poll, }; diff --git a/job.c b/job.c index dfac35d553..81c016eb10 100644 --- a/job.c +++ b/job.c @@ -719,8 +719,12 @@ static int job_finalize_single(Job *job) static void job_cancel_async(Job *job, bool force) { if (job->driver->cancel) { - job->driver->cancel(job, force); + force = job->driver->cancel(job, force); + } else { + /* No .cancel() means the job will behave as if force-cancelled */ + force = true; } + if (job->user_paused) { /* Do not call job_enter here, the caller will handle it. */ if (job->driver->user_resume) { From patchwork Tue Sep 21 10:20:12 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: 12507497 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=-23.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,MENTIONS_GIT_HOSTING,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 AF4A3C433FE for ; Tue, 21 Sep 2021 10:23:00 +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 2515461038 for ; Tue, 21 Sep 2021 10:23:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 2515461038 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]:41740 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mScvT-0004bG-AA for qemu-devel@archiver.kernel.org; Tue, 21 Sep 2021 06:22:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32886) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mSctV-0001WW-5z; Tue, 21 Sep 2021 06:20:58 -0400 Received: from mail-eopbgr150090.outbound.protection.outlook.com ([40.107.15.90]:45198 helo=EUR01-DB5-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 1mSctT-0002Rp-3L; Tue, 21 Sep 2021 06:20:56 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UcCIQFBbj5h/wBiCYrTIUpCZbk91LMWtlMU5PtqQWtbeyMANI9GTqBhX6bWXjIiId7sKTYvVz9y7x8g7SfDbHvfnruQc/QUNjUvzxptBS1WKnthac3Mg6vFl3LFZleITyEtd5Hi18K4OxQNo+43YhpOo4oiLv1VSc77RF/1YPkPhJqfEyqkg/IjVG08xL1HSfKwreniTrHBxlGTZpB8C6lHf2VvyCAQh4womGmfPyslC2MdPH7oKaxrz/X7OhIKeU9+dO74r4cSxtjthDJBDrACZI878GGhZkbE8wlzaZ/pCD4b1eVkMNj/ki2S9m6vQe6lo+54aUAXxhu2JJXU5bw== 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=rns1FGsVBG+kjBLO0HOv+Jt4tgxThqbikZ8hdKBrfSg=; b=hTqFtp6xDlKD5iuaI2vLWIfCFwVuzvBlkB2V35O85+ZLnQrsis/ktZAKV3h+7wl5ihxUzLUHT4gIA3eQ9sQZa8av59z2pAoi4JS/laaej4KvmfzyzqoY3h8YptQToxVmJ/ArdELe3jYjFfoKgqqacWXtiASzYr21m+ZbvHpBLFGbSfl/0fqn1vQRJGTkBFVl6Zxft1xCkfLiXm+JQQqvCCtPFH4+JAXd6y+x+WNwTGFoshk1lu2QgFMwRNnaBlqydf0CMTA09ud3fVMbPpldupR+XDmDDGLw7OvNW60pBZgUB0mAvehHgomXRrIwWvAnxGDG1Snm/rE9dnm/eyTFZA== 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=rns1FGsVBG+kjBLO0HOv+Jt4tgxThqbikZ8hdKBrfSg=; b=khiTNqUvPMkwR8zE7WGgniFZ0LtKYHgoXjTmPxpVpiUuxQJN6tK4B+QwR0scgY2PjDGrxNOZCQ/95hMvttN3ARrGvCmz9McAKdQAP7aJ8tox5RZubjmWlOAFEK6RkL0ZLCEEzWmy2hFeF/z8JnQKabrVoDeEZI7QVnOuqmJu9kE= 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 AS8PR08MB5944.eurprd08.prod.outlook.com (2603:10a6:20b:297::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14; Tue, 21 Sep 2021 10:20:42 +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:42 +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 07/12] job: Add job_cancel_requested() Date: Tue, 21 Sep 2021 13:20:12 +0300 Message-Id: <20210921102017.273679-8-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:41 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3fcd62ea-4820-4007-435d-08d97ce97735 X-MS-TrafficTypeDiagnostic: AS8PR08MB5944: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:800; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pXSL6f4QD/W8ooYz4YJCg8p8U9mzSoyQrq/2eYtrBfq446gzbg1JRkGjEJ1T5qfKk4E1SVG/ke6mQOL+H2iXfEOtUO3UFl1EtzpfwxTuEBv4sSnBTQ0Q9kGDNev/hXCIkr25wv4BLi5hVTS+IgpxQFyF1jBYfzVk4NEJ/1mYsBzArS1y23JPHr/MqTfRBWJMKzl30xa1yiAcz6mN+j+bDX1pTB31o3dF5W1RRpx3T3zF9K8CZfRIIjC2f93qiUA5z1Nyp04+kTqZO3csSW4c9f44yyd4nRWiN1KRnh78g2rqIcbqFeUFg0ULU9eSCyKgizKcGlCmOkUWjt5VcvoMoysmJYLLAU+VyltyxZUc09mdulalHSJ2+jHVgDIQkwCRVxINr3G4oMkJCEMGMtoFbYm8JadBpWHybXw3sfXzUzkS0lUSNNXVX8feX9IH+iflfr1gomFArSdlh3FnFCcPoLzYZy02SU/mNuRlI1xjBgTO95wZp93HveHN5GUSINYQ487WZZ61F6M5gjVd90N2Ynd4k9x/szDWtHJ3rCOzsSS1qCOZrQYD2GjfbE4jY9Rb5Hpag7/8KCpLiqVXAcjEZcNm0hy2vo4g5zqPE8uGgGksEsrjVLZmfxLgEVMIgfcrJmYmMiCVBDCxxgebBtAa7O//hTQGktmuJkQ5QVuriC4D68eBOqa2dX4oDKNbMT8x1tv3XG5b1xlgd9mf9YhdmnaTtuXR1xVMrKIdbvoe7Tg+fJw55PPGPU0+f9Q4ETYeNiJIPeD0PrGGYo20gSItQnHfhFNCO+o1b/ZIuZYfvqM= 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)(8676002)(6512007)(83380400001)(86362001)(1076003)(8936002)(6916009)(186003)(38350700002)(316002)(52116002)(508600001)(66476007)(6666004)(66556008)(6506007)(2906002)(26005)(36756003)(66946007)(966005)(4326008)(6486002)(2616005)(956004)(38100700002)(5660300002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: LBHieJbMOjl1yzt+rTeP097GVIhFQoAVtiXtoXxhgtxv8cAmYfFW5QFqtfJ/Cwdz/dulg0JWyV1qEst57KOa9Ot9TR2ViW6wBIplwTVb5uIyhpWplLfagRYZq4bxJuZnKMdgXPhAFl0anUmqECdt7bOt62+d9F/UXmze1ozml4VFpLHEPxaNJ48v0gV92GtYRXCXWhYL38rvWL/fly4moOljw2lTK3TIvbjNV9bMssx5iXdpAsdkrW7fLLi8AWNJglTTKB501YpYpzElmOIAx+yJ2wUCCxteMDQb3M5vgIOzsqe2/IBOcbMeQssVW20370+Fb7GiEd7/ptcWTMs1Cqm9vXXyf7uDbuten4LfgZSeNO/qRxbcgqxEz2ZnoCGufTEX1oy983CFguQ3/yV0nklHo0t9VvhdE9Lwq7OCbHNYKRIQQNUqoyR2N4KxW4DnWX4o21H+/ylQ61b54v830iaeLEE2Wygo/O0FuWHH3+cStZ4t1M39Smc9IyCO7/yLJkVVR1h3ygPJL60rbsBtK2u//y7vxGK9l4st21JeX6hUDlZ3havp7ym1farQ96Ey6ZZduqkuQRllqtEnlr1pBrmJAW/eAJV//IyrVTvSmkrJK3q/zRRPDYNXmUxb64YiyXAoMDa6gYJLrDPpSl3+nObAxoXl44ZD5bM9ig0PlmI+CBPF8AXer1qp4agKU0VvbszHYlTdMQ/doo8ETKnyCIuDOylyS6sONAkwvDlms/XcEk9v6QKrrHMW0Py7pUqz/qKjmm47jn74X7DDBO2gI/Jh5PnSLO8BEfojmAXCBaP5Wl8i6Ne3Q41bkBpAtDhtxIiCuE2E9nW8/g463cWe5NyZF1IWCpj+TMelU7pJ898dcpfmrvrkv/b4nHLQnD5UByTWSTIxz0v4rPOSgRcz/nNFDShyFceMF0o57zLLjskO25RiQFORzrNGdTLkwoeQE9QUZaXoFLQB0CLDKicIYQ3Tplh5gKdHCk9ermq73tTp0nBt+1IUJ1NxWhyYXuCq4jsKXm4vnbkwQt6J1OnNBasdFENnQ9TtQT6ZZ7cbNgU2YKWKaiWEgkcEEa4GlCmLCv3Y58U1g5e4RwZC9gpBabzSF1/Jm+yt3OVBWX60THpzFed3MdekyTJ+cK8gcny9WG+f1+MdQOpiYRrM+Me16VObknooAwWRechr2bXM/sBEXe2wf3KOdmhill0Vd6PKTyrmCJ1Lxk2UYYFGMMzaB2fOHyfbsMNG7K7zaq2ywZrZS3eJuCv4IvdqCBB+CYyRyRR9o4FrcMS3UfT4yi0QPFI71+G2HWsgZbeg/ly1s2yODPGvIrn7v5QQr2ZcOiCb X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3fcd62ea-4820-4007-435d-08d97ce97735 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:42.0691 (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: KYdgim+VNLttNX3141lcryGmlRN8Z4qxhtHSHS/cyCDtUCbLpgLFwq6ZcIjMeHCBkiX7RNhbY8VsgmCLLdk/qOUFM1DxR4OyYy4HX8ZEE/M= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB5944 Received-SPF: pass client-ip=40.107.15.90; envelope-from=vsementsov@virtuozzo.com; helo=EUR01-DB5-obe.outbound.protection.outlook.com X-Spam_score_int: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 5.0 requ) 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" From: Hanna Reitz Most callers of job_is_cancelled() actually want to know whether the job is on its way to immediate termination. For example, we refuse to pause jobs that are cancelled; but this only makes sense for jobs that are really actually cancelled. A mirror job that is cancelled during READY with force=false should absolutely be allowed to pause. This "cancellation" (which is actually a kind of completion) may take an indefinite amount of time, and so should behave like any job during normal operation. For example, with on-target-error=stop, the job should stop on write errors. (In contrast, force-cancelled jobs should not get write errors, as they should just terminate and not do further I/O.) Therefore, redefine job_is_cancelled() to only return true for jobs that are force-cancelled (which as of HEAD^ means any job that interprets the cancellation request as a request for immediate termination), and add job_cancel_requested() as the general variant, which returns true for any jobs which have been requested to be cancelled, whether it be immediately or after an arbitrarily long completion phase. Finally, here is a justification for how different job_is_cancelled() invocations are treated by this patch: - block/mirror.c (mirror_run()): - The first invocation is a while loop that should loop until the job has been cancelled or scheduled for completion. What kind of cancel does not matter, only the fact that the job is supposed to end. - The second invocation wants to know whether the job has been soft-cancelled. Calling job_cancel_requested() is a bit too broad, but if the job were force-cancelled, we should leave the main loop as soon as possible anyway, so this should not matter here. - The last two invocations already check force_cancel, so they should continue to use job_is_cancelled(). - block/backup.c, block/commit.c, block/stream.c, anything in tests/: These jobs know only force-cancel, so there is no difference between job_is_cancelled() and job_cancel_requested(). We can continue using job_is_cancelled(). - job.c: - job_pause_point(), job_yield(), job_sleep_ns(): Only force-cancelled jobs should be prevented from being paused. Continue using job_is_cancelled(). - job_update_rc(), job_finalize_single(), job_finish_sync(): These functions are all called after the job has left its main loop. The mirror job (the only job that can be soft-cancelled) will clear .cancelled before leaving the main loop if it has been soft-cancelled. Therefore, these functions will observe .cancelled to be true only if the job has been force-cancelled. We can continue to use job_is_cancelled(). (Furthermore, conceptually, a soft-cancelled mirror job should not report to have been cancelled. It should report completion (see also the block-job-cancel QAPI documentation). Therefore, it makes sense for these functions not to distinguish between a soft-cancelled mirror job and a job that has completed as normal.) - job_completed_txn_abort(): All jobs other than @job have been force-cancelled. job_is_cancelled() must be true for them. Regarding @job itself: job_completed_txn_abort() is mostly called when the job's return value is not 0. A soft-cancelled mirror has a return value of 0, and so will not end up here then. However, job_cancel() invokes job_completed_txn_abort() if the job has been deferred to the main loop, which is mostly the case for completed jobs (which skip the assertion), but not for sure. To be safe, use job_cancel_requested() in this assertion. - job_complete(): This is function eventually invoked by the user (through qmp_block_job_complete() or qmp_job_complete(), or job_complete_sync(), which comes from qemu-img). The intention here is to prevent a user from invoking job-complete after the job has been cancelled. This should also apply to soft cancelling: After a mirror job has been soft-cancelled, the user should not be able to decide otherwise and have it complete as normal (i.e. pivoting to the target). Buglink: https://gitlab.com/qemu-project/qemu/-/issues/462 Signed-off-by: Hanna Reitz Reviewed-by: Eric Blake Reviewed-by: Vladimir Sementsov-Ogievskiy Message-Id: <20210907124245.143492-8-hreitz@redhat.com> Signed-off-by: Vladimir Sementsov-Ogievskiy --- include/qemu/job.h | 8 +++++++- block/mirror.c | 10 ++++------ job.c | 9 +++++++-- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/include/qemu/job.h b/include/qemu/job.h index 90f6abbd6a..6e67b6977f 100644 --- a/include/qemu/job.h +++ b/include/qemu/job.h @@ -436,9 +436,15 @@ const char *job_type_str(const Job *job); /** Returns true if the job should not be visible to the management layer. */ bool job_is_internal(Job *job); -/** Returns whether the job is scheduled for cancellation. */ +/** Returns whether the job is being cancelled. */ bool job_is_cancelled(Job *job); +/** + * Returns whether the job is scheduled for cancellation (at an + * indefinite point). + */ +bool job_cancel_requested(Job *job); + /** Returns whether the job is in a completed state. */ bool job_is_completed(Job *job); diff --git a/block/mirror.c b/block/mirror.c index 7022d8011b..6c3d8379f8 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -943,7 +943,7 @@ static int coroutine_fn mirror_run(Job *job, Error **errp) /* Transition to the READY state and wait for complete. */ job_transition_to_ready(&s->common.job); s->actively_synced = true; - while (!job_is_cancelled(&s->common.job) && !s->should_complete) { + while (!job_cancel_requested(&s->common.job) && !s->should_complete) { job_yield(&s->common.job); } s->common.job.cancelled = false; @@ -1050,7 +1050,7 @@ static int coroutine_fn mirror_run(Job *job, Error **errp) } should_complete = s->should_complete || - job_is_cancelled(&s->common.job); + job_cancel_requested(&s->common.job); cnt = bdrv_get_dirty_count(s->dirty_bitmap); } @@ -1094,7 +1094,7 @@ static int coroutine_fn mirror_run(Job *job, Error **errp) 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->common.job.force_cancel) { + if (job_is_cancelled(&s->common.job)) { break; } s->last_pause_ns = qemu_clock_get_ns(QEMU_CLOCK_REALTIME); @@ -1106,9 +1106,7 @@ 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 && - job_is_cancelled(&s->common.job))); + assert(ret < 0 || job_is_cancelled(&s->common.job)); assert(need_drain); mirror_wait_for_all_io(s); } diff --git a/job.c b/job.c index 81c016eb10..be878ca5fc 100644 --- a/job.c +++ b/job.c @@ -216,6 +216,11 @@ const char *job_type_str(const Job *job) } bool job_is_cancelled(Job *job) +{ + return job->cancelled && job->force_cancel; +} + +bool job_cancel_requested(Job *job) { return job->cancelled; } @@ -788,7 +793,7 @@ static void job_completed_txn_abort(Job *job) ctx = other_job->aio_context; aio_context_acquire(ctx); if (!job_is_completed(other_job)) { - assert(job_is_cancelled(other_job)); + assert(job_cancel_requested(other_job)); job_finish_sync(other_job, NULL, NULL); } job_finalize_single(other_job); @@ -1027,7 +1032,7 @@ void job_complete(Job *job, Error **errp) if (job_apply_verb(job, JOB_VERB_COMPLETE, errp)) { return; } - if (job_is_cancelled(job) || !job->driver->complete) { + if (job_cancel_requested(job) || !job->driver->complete) { error_setg(errp, "The active block job '%s' cannot be completed", job->id); return; From patchwork Tue Sep 21 10:20:13 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: 12507553 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 35531C433F5 for ; Tue, 21 Sep 2021 10:38:22 +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 B9DE360FE8 for ; Tue, 21 Sep 2021 10:38:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B9DE360FE8 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]:42388 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mSdAI-0007ml-VY for qemu-devel@archiver.kernel.org; Tue, 21 Sep 2021 06:38:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32918) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mSctY-0001Y7-1L; Tue, 21 Sep 2021 06:21:00 -0400 Received: from mail-eopbgr150090.outbound.protection.outlook.com ([40.107.15.90]:45198 helo=EUR01-DB5-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 1mSctV-0002Rp-RJ; Tue, 21 Sep 2021 06:20:59 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=U4w1OZKMrpXCmk0QXUaptm9mx7OaEjmZBlcBmMHNI/LNFV3140Z3sDW1tNbzRLT9q6c/HUGZWiDtTYHrGgrss1pF6UOA27leTVLYoMWNU5x19A/xjGX3X7Lmxkl7W0YPlnoyYkkxA6FdILxKBdqSlM7eG/kxUoJ6YsH45b/dB0xNrEMsF70miY3BJAqJ54h0aCip5kiUdluaRlpBlg0qUekGe/q6gGdUbVMceWPC9k7LtgjhAlU2Ub2MGlqmA6D6VkSEAtNnSitT82O6XnqFBdsvxfQuZ5+TjVnxaldZ+ulketu7glEheHFSSJVM9inHaLa4uniK5d2NhNnUpc2jEA== 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=yMlHwE4hBTnh9KPOMXc/DRBB9UYTvR7FJguw5SZSMto=; b=PpDolLY/iWS1oXXgzdBs/up9Rp5jXErh/feO83kq4DpsAxmXFFs5w0kTjHTWE0fOCvJQFKA07ZbKyhEMOYtW6fX5OhpR3jHZth7V6J3AEirqRVPz3kRAUNQ/XRiD3qPV10lign9VlKsl5zwhhbLEZV85lnb9xxReyoEXCcKrwbSmB/r9upfX7iS6apCO/IBJ5GiKtorf56GHWmxoSe8sA5y+nCu09wCzOaRCfFdnFG8F4J4sp9tXGToPG4PcvbMCaMnsfnbbuyJYSf2clN4m33mnyABNGYFfXyWKY6bgWKsYqA00uc4+4WicQB4XCkUZvdxg+07ldGvXS/mAZI0IDA== 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=yMlHwE4hBTnh9KPOMXc/DRBB9UYTvR7FJguw5SZSMto=; b=Pz2hIwL09Zy13/sKSykJ1PLNk0XK8/YDC4W42domrEsExxxvmFdLTIoLtnez4+tMeaF8JqzZQZdqiFFJGWb7FJBkTfj6NmRxEKnpKDIHW3TQSxYQagsr6ST3zoQRR399QucOQCQQy2QLmtU2Bv4fa05Zf/pwdVPfdWVLMN6Kwhk= 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 AS8PR08MB5944.eurprd08.prod.outlook.com (2603:10a6:20b:297::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14; Tue, 21 Sep 2021 10:20:43 +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:43 +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 08/12] mirror: Use job_is_cancelled() Date: Tue, 21 Sep 2021 13:20:13 +0300 Message-Id: <20210921102017.273679-9-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:42 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 55a384b5-63c2-4c2f-d1ec-08d97ce977ef X-MS-TrafficTypeDiagnostic: AS8PR08MB5944: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:862; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: F6lJy4nF2WjfsihAERS5YEefMrjdx5nQhMbJcf0UHz71TLO36uWIXIY+9HRNp0ZjcqC9p+jI4KlCaZ2SWN+GZUrBx+49eWCkRJ3yqaMXhpDf11m6iCQWyMoS7bgMxd8qJI3CS+HNGS+fe+qipKQDvXBO6w4Na+wI+V8oMohOkcZIwT7w/c6V5AcbJM80HeA/cQyxUWrs0Z6qwDrDDvzlNb4xvP1nJWuFTHeotE2asaKlp5Ghfvh6pPE5L2WZCqwEYwgLskd6gBi3gB3VAZJu9ud/wmM5zUjd4N2C3IrMbSrCGKAyZ9k7mQG+fP37GT4w/Q3VEgXpKJ3eLHizMi1ZURSPUEkoBGlMNXgk2tzKdc4V/WP/uK4OaATN/vtZgcEQ0UDNJey88O81I2bEHnT9H0UF69szYoI9g8REKCIWkvVwe/lS5QhStzy0nybPsRqTLChmz8xezX1sEuP+OTHxWcZ/5/a3l0HACl6M/5SkRFauKp3QLLqeQyZS4U6FYJtO6f6m6je3w/YBeUx9yQ4ART5QY0RM8ILsEAPqCMGHQVxHh5MJ1rsTwOYg6/ObFOpcsmmhX42roB9a6w0tLZgZnIpk/tkKDmA8nuwIr7dHD0Xda4YdA0Ua4G4s+cC0DSHTOzgOgb3KzVfwfAn9y5yINhB0ESardRYYaJemeofbZRSmVGn7AXOkU/DI0qFXN4jzZ3r+1zA7FdZaDO/dNp+Zvg== 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)(8676002)(6512007)(83380400001)(86362001)(1076003)(8936002)(6916009)(186003)(38350700002)(316002)(52116002)(508600001)(66476007)(6666004)(66556008)(6506007)(2906002)(26005)(36756003)(66946007)(4326008)(6486002)(2616005)(956004)(38100700002)(5660300002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: UeZ+uZGfCQbhDOOh9N5yzATGLanX9sk2u7xhHnKgxXjj6NNose2lHc24A4TFQ37kJg0SkTeeN4ikdYmi2BFho4XOo8zRkQlfVG5HJLKqAqB2KV92Z7n73bhxJfr8Xl69sJC9lolkgUHAIE5SxEuPMFONkTb9XvlO9B1BiCJ1tAWvCHWHFpUePHQ+p6aNfDmylexvBY0HflcwZQJ8EmEuJ9uV1fv4PyeSSpcUS8HTjE1ngrx+ahwNKPZnnUUyDZz4ZS5YzGyCNhxck/1nRBSkPr18z0NE8jRL9sACFdl5BFlrRyvRqiQHM3Xehg8vKWZgQj10i4spPTNUTYBmaYHFpCq2Wv6eQP48KUbJEQmSek5INA3p7fBQFhRCOMrMU6Kiqv3Y3vO45xYkuN5N9SCv8LEzRsSbOmYj3xMu+PkeXct6+rM7NPtgpqLnuoJXiatERtbyP32+ST49LM+hxBmW/IobviOfpHdKn+K99JUs3wyD781nFJp8pmq9QAZSafhAuaoBTo1lp5BmHeCAP/87bUHLQfg6WrIhfm2aaeSNy7bvvFHd7CGnNrOhnZbBD/MCwpJaQaAQ7JH6tV8MvstnFFnYfv4cjZHg9+4hRLDoMCtkro+d5/LMjEciL7GSJRXrW9GQUROgGJQAj1raSW5NztUhHla2VKlk8lgVL/oErugYLe0Uba64CpJrWpI0NCpqEfoMnt8vGypnNxu9mF3Zbu9FipAJjIX+h3nBC+0xbwIL7lSeV77gRtz3QmfHSC9guMP79tQE/iNoru9ZSXGtmNDf2ox0+ddx+Ai4INxeyhzRub/DIAkvrlYv/tnWSKt6fxVlTGCa+H5pWmTCBBdWN7hk9oSH/9mBFGhOnUi7p+PD9fJGJB6YYOd1hBrPEugxCAo4IOiwgj7HoffYI6tiuKrLf3W5dEqjxgSci9UtZRNVtinbfx5B7Qw7lj23Xq8eRiDpvtwlgXetCsMYnwcyZYkFqEbfu7Yt8LnNldMNL6lIu/nXPqJcmlHGNVHarMINh1jufkFy1GLGDGpITyy3U+ONy6C95i8ajyG4vYKcI2OyZD6AsiHtTzh+24otXLvFp9EwWWQEGJSWDgpvkSvzB8SY3engPkD3PhcUn1XBddzHyzpGE8G4SuLS7i7D5bHxOB1U9vD0yPlM1JcyzVxXDoPcKxnr9vLtTMDoTit0GrEc0nBfXfeihv6eyBEIhkmN57JuLuKgjit0AFnGNbKHLEQQvMk/RAlh/QTZsYpLaIGNyTavn8pqosnIUtvx7LTYzhLHPscwxXlhKJcvw6HSJDrQiJHQ9wpeWj9tX1vCTYjm7ki2u9+m30bz7rJjbqcC X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 55a384b5-63c2-4c2f-d1ec-08d97ce977ef 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:43.2499 (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: B5fB5M7gtqehd9FaICgbPfuTsJXDLJv0RaSH+Fsw6zB5q2LPNNgb77rQZDZISkbRBuuyUbffh4YK6o/XSc5WDlgnunOe/qtlsIg7fZziD/g= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB5944 Received-SPF: pass client-ip=40.107.15.90; envelope-from=vsementsov@virtuozzo.com; helo=EUR01-DB5-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, 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" From: Hanna Reitz mirror_drained_poll() returns true whenever the job is cancelled, because "we [can] be sure that it won't issue more requests". However, this is only true for force-cancelled jobs, so use job_is_cancelled(). Signed-off-by: Hanna Reitz Reviewed-by: Eric Blake Reviewed-by: Vladimir Sementsov-Ogievskiy Message-Id: <20210907124245.143492-9-hreitz@redhat.com> Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/mirror.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/mirror.c b/block/mirror.c index 6c3d8379f8..cfebe50845 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1184,7 +1184,7 @@ static bool mirror_drained_poll(BlockJob *job) * from one of our own drain sections, to avoid a deadlock waiting for * ourselves. */ - if (!s->common.job.paused && !s->common.job.cancelled && !s->in_drain) { + if (!s->common.job.paused && !job_is_cancelled(&job->job) && !s->in_drain) { return true; } From patchwork Tue Sep 21 10:20:14 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: 12507575 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=-23.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,MENTIONS_GIT_HOSTING,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 172F1C433F5 for ; Tue, 21 Sep 2021 10:41:20 +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 760EE61100 for ; Tue, 21 Sep 2021 10:41:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 760EE61100 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]:47732 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mSdDC-00039K-FE for qemu-devel@archiver.kernel.org; Tue, 21 Sep 2021 06:41:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32936) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mScta-0001Z7-N6; Tue, 21 Sep 2021 06:21:02 -0400 Received: from mail-eopbgr150090.outbound.protection.outlook.com ([40.107.15.90]:45198 helo=EUR01-DB5-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 1mSctY-0002Rp-MQ; Tue, 21 Sep 2021 06:21:02 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OVPUL1L2hM6BIPsL9YGib2uhnuJGy1m/HnHyujW2hLB+1j2T8SmUmSc+l0u0PpEXFtth1l8UzOG+t4fMHAZI1r4N0ANDI6YmiABgZeMfTnToXpWmSflYm4KfKHDwZiULu3WyxqYkZlGn31u3tbsEdTjeEp1BpMeh2SCbhidYNTi+3GOT6KhsUYZJ1YheCct2aja39STKHsfBa/+UcFLOjeXoMD6J4sKLpHHMYIhA94YnMgQoACGkBe/ah3k1eFhjKEztbPcOqxknDU/aQ9G6caYN3C3w5lUf0zrcgHHrROBWjMHDePY8KcJXuNZx1XzWqiu2PUC5epz1amWClE8T0g== 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=Q8sBAJiPB3seyvv/kNpVsfzY0FjTRbwCyERWd1+yC+0=; b=KaLa29TGbM4qkuHBc0nmXIPnpZzph61zqtZcXL3svC4e6hnteKTkhIB4YXNSSOvVD3GSUmaE4iDD0m9aCyeSFBwilEbK7e/dSss9+7ZuzG2TbuWp4Xi632SiDisnv0oC4otUjLMHOrpJ1FRgVHmPIdpG3KwzvJ7mW9Dl62HSHOT4WGIPtEl1n/4HVojePiWIU0DwGAbfcphpntosPf5083XnECq/UwbRh01boJClw+ZhY68OPiD/so66eTewzb+Lw9FfjNC9qIHqGUttG8dxSPVG6LbkbDIajgoxR/FKZ0k4Q+EsJo6cZwtNbduaAR5DaGJhPQ4oiv6I166Jugdjhw== 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=Q8sBAJiPB3seyvv/kNpVsfzY0FjTRbwCyERWd1+yC+0=; b=fvHbamnT00hlLbTgVA1/J8VoT9N5orAh+RzLbNjhxB1ET4lZDFINWI/Im7ka4WxnpDCR2m0ZW/+VQQ0zxXT0kwTE3MUmtJC0jA/wMUCAQjQu8lcj1dUzOLZHgtbHRkm8+3AbEEB6D0jajWk6giozOlHBRU/JkoHAcK2P4fwmrE8= 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 AS8PR08MB5944.eurprd08.prod.outlook.com (2603:10a6:20b:297::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14; Tue, 21 Sep 2021 10:20:44 +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:44 +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 09/12] mirror: Check job_is_cancelled() earlier Date: Tue, 21 Sep 2021 13:20:14 +0300 Message-Id: <20210921102017.273679-10-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:43 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c7639a2f-fb96-41a3-6676-08d97ce9789c X-MS-TrafficTypeDiagnostic: AS8PR08MB5944: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:660; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FkBw20Un9ytTM3nlqgHw3c86ib4IFPMQnEQNkCGz39NmbRbJ5pLhSmTdPzkFVaO84dVeBxdREkhlM1RyJGUiDHHKyJhaAmeRQd8B1ixM2Ro2B97PbAEdpbx7JnlpLK9Tq8t6kY+mzXTHu5cMl3YuZSUAIBDBavauPbxGZMDG9itSq28ZabchzWb3eZYCh+1IcLUX1A8lB7LC9dV8wlCzEIXayvKebBq4D9RMfhiEA+MgSf/VVk3uL58NmnJXM3xrEU09MPnjq+o7MuGDlTcJ+vwI9I9JJ3a/EdZLiM2kmeJL7xcgpUxwZbMG0lrWLqG9/IoKamMgP5WJ2jsZAvQKCMPM+6/b4DTAUi5t9eNjspHC6gteA3qSoDSFo6P38zSX4Uc4e+gMbf078Fv5pFhc0uU+LhrSY3+Q3Il+i6gyfeuE/UZjV4jru4u0kWuGosNZBrfv3Uv9fYjh8mvZaxPZVhi0fIqSrBR9WiLyaSDJXeKgJRPKXHIBVhWcLXswpdTFXpc57eG1b8D2POwjpDpifAaAmVe/blU2mjhtgsFEIi4XAJL013liQzAaEFWzHHzKE2ZESeY86wvE4ECBQGKWgz4TI5alrTeVDAF+9EOxO5Xvib5nQ+ICk+Kgr7A4OsAlecMf55ZbtEferaqX4ocFxFWcgHwASfuLZtPxx9sum6KyutALfKo4Mp/W7Xsh0rIcbcj3vj2A4QloZTG3w3tqK/N4DQYMCWifKutfoOJ00M29S5omqemM2m3/5rOvYCS7kwvsyeodd5pptRmMd2+PVrZpzTFWuHiU5wHozGzCKzU= 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)(8676002)(6512007)(83380400001)(86362001)(1076003)(8936002)(6916009)(186003)(38350700002)(316002)(52116002)(508600001)(66476007)(6666004)(66556008)(6506007)(2906002)(26005)(36756003)(66946007)(966005)(4326008)(6486002)(2616005)(956004)(38100700002)(5660300002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: MOlEbrfXr43TIcu/DCmvtsjvaeaw5HXkeyVnDoL+cO9pNuGuFoiUZ9uNuZlIJKZghFfFV884dtYNzgE0/Ai92IkP5LpcQ+jg/1Cz25S+rcLctTjqRlBsVQ6ZSMg2Jv2df9KjT2y4At6cb9bFekudFvtkN/6Q+MfV/fLR4Ri4hsGW5W/7jKfiQdis7Df/O2kzRwOwQMm3ZXrp9+TCYXbXVoUa4uAEqcgcTTlsGYXTYP840sL0gDmGiHdYHQ6q9/aw7n0ef1LqFqDLrr61NPfqr+/aKMFi1R4zY/qaY7Djfjh/440fTvXROEhH9oHtEnhkOwzZiHq3MJvy9dE6MOD7ATPkG1NFq+7r2GO3xGf/AN81ZxhGPzAOGmTZsJfFKLtcb77N2kMz+pQXWta30QSMMVodozaprvJmi1eIVYj1xbYxoZdmNVhC17pAGj3JFNWBanFiN9AD2oMjJYvHOCxQ4GZSpCdD9bdCDiSvhLML4EtKUu4vRRPOpAXP9pUKBihmHMjdgu0KLO86ELnZgvZqQ5LcmntljtoAmPe5oKOBPDRV/Ca9q6FvSLQxI383mRQ+PVrskcd65HaiOEDAF7Bmq/CVDzkU1/64zD4M90HoYqNKzi/dp7RFp7TGAQxeAt/U4N7CnwL40OEzWDB4qUDfZ+ijEF/l+l9wIBVBYKbNN4NW/NYoB4FhMUST75uK5uz5fwA4GfuR/i0B83Ms4QQ8nLmFmj+vFsSg4878p6vIMM45UqIkpNefhmbciKo+lmc+3ippGNtqrbrJejB4k2dQQ1Uzb1z7FCJi0No5ZEgyDiDf8x3KW/4eTRULt4BUNAX2DepV0ZjgCtjPaCHFnWluFUbCoVY4rJSLwSXpED2obHmCn6kNpo2ygsylUyYRtrmxpOUTxEdWP4MAFScnDmJTRACG/Ah4kMDmrXYfIsA6ijzJqfxr85fHGqYitotBopQzivysI4VEC5915N6mnRmNq+6LhEgHKMSar7TBm8YJn0ezMIMVZg5a7NfPq35sjIKCBtP0hZ0HdJvOQrlSG5FlNy7ZWQb2/cSULd9uvxQa8bfj8ZHWWeVNEu42nrslpT6PyUgEvrVGekBI57K+z624TrvFMnO+bKdEwR8mczwElXxKczY1QrftjjdBF8edSWAvmoj7VKIKeWpV8/iQ1GpzWq9aP/dKe/SavMnRyXtC/T7YpqaVQXMZdWTNLj9ee4ZGfAIM155P4RHeBwVIkL7Hhg0kyNybA+/AVWNFyX/Fd7e/JamJDz7a247BiP4Qm15vox8IcJN/B8xvNCwbfJ9HWxX892lSSu8l8womEFPQfTRbWoI7lgoJDabTFcV61tc6 X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: c7639a2f-fb96-41a3-6676-08d97ce9789c 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:44.5014 (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: ryN3uKzL8HTIETuBCtPoLvA39zq2e9H8Qq9O398J5jO4DTGiaAQPyx/YdSQWStmYtoKQUAzS2IKzCMAoeM7m5rSNwd0GUONkGM+YMmOLLDU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB5944 Received-SPF: pass client-ip=40.107.15.90; envelope-from=vsementsov@virtuozzo.com; helo=EUR01-DB5-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, 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" From: Hanna Reitz We must check whether the job is force-cancelled early in our main loop, most importantly before any `continue` statement. For example, we used to have `continue`s before our current checking location that are triggered by `mirror_flush()` failing. So, if `mirror_flush()` kept failing, force-cancelling the job would not terminate it. Jobs can be cancelled while they yield, and once they are (force-cancelled), they should not generate new I/O requests. Therefore, we should put the check after the last yield before mirror_iteration() is invoked. Buglink: https://gitlab.com/qemu-project/qemu/-/issues/462 Signed-off-by: Hanna Reitz Reviewed-by: Eric Blake Reviewed-by: Vladimir Sementsov-Ogievskiy Message-Id: <20210907124245.143492-10-hreitz@redhat.com> Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/mirror.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/block/mirror.c b/block/mirror.c index cfebe50845..1dbf648311 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1007,6 +1007,11 @@ static int coroutine_fn mirror_run(Job *job, Error **errp) job_pause_point(&s->common.job); + if (job_is_cancelled(&s->common.job)) { + ret = 0; + goto immediate_exit; + } + cnt = bdrv_get_dirty_count(s->dirty_bitmap); /* cnt is the number of dirty bytes remaining and s->bytes_in_flight is * the number of bytes currently being processed; together those are @@ -1085,8 +1090,6 @@ static int coroutine_fn mirror_run(Job *job, Error **errp) break; } - ret = 0; - if (job_is_ready(&s->common.job) && !should_complete) { delay_ns = (s->in_flight == 0 && cnt == 0 ? BLOCK_JOB_SLICE_TIME : 0); @@ -1094,9 +1097,6 @@ static int coroutine_fn mirror_run(Job *job, Error **errp) 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)) { - break; - } s->last_pause_ns = qemu_clock_get_ns(QEMU_CLOCK_REALTIME); } From patchwork Tue Sep 21 10:20:15 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: 12507527 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 259F9C433FE for ; Tue, 21 Sep 2021 10:29:42 +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 8A8A761242 for ; Tue, 21 Sep 2021 10:29:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 8A8A761242 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]:51024 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mSd1w-0002dv-9U for qemu-devel@archiver.kernel.org; Tue, 21 Sep 2021 06:29:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32978) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mSctj-0001iV-Ef; Tue, 21 Sep 2021 06:21:11 -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 1mScth-0002LA-NY; Tue, 21 Sep 2021 06:21:11 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Sj8TkRhZDtlBIQ6Wt2Q2SzexBR7fayoMbViuJ0sLthmtFqhZNeEzjEATO+YXRPDZ8zAsdEx8xKjp3VrrlOw45QNcwuowlUsaZlqGtlQdaI0VH5KjYmA/NPh+uzHIHj2UvMCfJYNfhyBDDqL9T8BP7cgn6PxnIr/KZMygRKYm4hEoTnNJNWIyrsvscGIzYQ6sgp3daRN8pBDTBE1FAJKOoaqeV5spbsZZwvFrZErwBPIZ51bSsG2Ur8cJkWUYo818eBdIchxWpzVizAkedZE0aiGKg81D4Qfw7ZfJ3BXVVBOJAFHRxqNtDOccDaPbVSOdA8VAiSHGL3EvWEvOTV52mg== 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=u9lySSfMpZdn6DCAK7M2drBdaju30zyu0LdPb9dS29I=; b=GBBdVN+XioyKSyfgwBqHPrlsVUHEL+3SJMH1YQ/nIPLoZaTZMPklQmfh3bRu5EEfL5cd7iC7Rbn6c0pOeLNLV6Hslu8yFOWU66FQMTKGh5yLGy7ELjCBWvKzlZyBzwh8mc2FWfqsiNu21v0gPXSFzRJf6vxFnt/0qstra0N1R0iC0P7T31XIK8r7GY8UP1avU0PurjK7m4yOgIEJJttRubMbVOEfmQr9qmtVo5xB+dHsX/1bo8QIM83pxrwt+PXJr9t07M5BDszzSohlg2rJQT/B2dC0MHhXukPIgp96i+XjGoNgwrnVLKif00IgbgkcoZ6g1T95vy6FmjpXNJvQlg== 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=u9lySSfMpZdn6DCAK7M2drBdaju30zyu0LdPb9dS29I=; b=gtWWyWrJU7MWE4RfLthfS1rfQZoDSDvrAummU8Hg3lpkAsz0zRJUb1VkV2naITaUCs4sB1dSwFP2Nfu6YZX4J8/Xit7dZsb6nHTjetpxcXby4eCcJVJ3AVOQ6H+cCq7ca30Lt4hBD8TkqKWpZS8eiV+1VPGlcpZ4pxQNrMjLcdI= 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:45 +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:45 +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 10/12] mirror: Stop active mirroring after force-cancel Date: Tue, 21 Sep 2021 13:20:15 +0300 Message-Id: <20210921102017.273679-11-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:44 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5d9fdcf5-bd1f-43a1-5cd6-08d97ce9795b X-MS-TrafficTypeDiagnostic: AS8PR08MB6631: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:404; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cTXO660xMbSaP0tUUkp5ofK/Ap7tmWg1IbKDE46f0oMNyM2fZy9kRY+TGrMm/LXjrzV1zgg233iwjbifrDv7ZeO3WlTtu0kc3ZK0HKcxhnofkd+fDcgZO4ZoXTNu+RH4S4qAa2NblVIIiRqU/sPvPT7zoLjpKEa6GjxYPOQpWpUUVPL8LfFK1HSUST2vknPj2800HbrMa9EvKYZh2b3TGrpZdixyqA1C9IN2wCLwKieGAf8PAwBihHTWTKwf4WSFE4zE032Fcc3xkMsF4KoeHeZCrX8lLS0sdSINSAsf+gR1vFQ7RRHEmq4+T2Y8z8h01ZBwyVeNRLg2QQ/TcuH4PpvygGioGTtuwiex7i2aH5opF8CzVa1xET1yXD3dLOfThwj13BbctjgjJCFajWyrzbPF68XmLTzgtKe3xIWTbZGZRxfk2vomkIVW4JnNeuT76ga5yFcTe+Ie7KBZvmnIBpyYxopvaSYPhHeCRzJ545gz2V5rila+O9t/CN+jilxNNPB9iEEScOSKckhI1cEZfkgkSvlD8W1nbOqzBh1oIEKkjBfFLDt3A30KQHEBRobQv+bBxBnk4AQOAgpaEZ7eIBn/9qJMmS9YkCvCbroa9eoozQ66lud2mo7kVE8Fo8Pcfwrv8sn9XNH4eYJVl1r27yHmvTzZvBx5jGyC04TeBWi+wP75TVADHvsKfVb//uLRqxAJYfzVD+oM0zzWzakM8w== 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: QNRaBO0asHuG5XaDFBxwH52Syxx9dJkC0jkp/DehS9EYxiMZPD2dDz4OoqNT5FaClZrdMRP716t4NlZoSMaY7PanB9BIYDfL19Knld/KaewWAF0sZPfZmCaI/ZkWDkPchDlfmVla0cconGiFr1A3soJHVExB7rTpt4dYqItSgP806ffrrEL0X674JtoWy9OjvXaHyhnENP2fg92bEa9q51Eafjy1D6n0JJ2Ce5gT0j2JoS1mFwDqiiQBbcbAIFTq+KnfIo1lhshH45MXLBqTDBj1ZacLMSW9FFQ97e7svfRV0ZweGnCP1Zy7h0Wer5wWETdUPUVp8QDn+CRnqlMcTWjapEh42jDYKUHo+mKwF6F+yc7Kx7YIghezJk7R+EDiWzvYeryiabIk0pL4cN67G9YQk7b1ImYfJCGJG89ijGk9ghq1WDTrAGmM4G0sI40G2ACBuLzrLgQR8YtAVRccKCsGkkfZjGgoT4IIkgub7QY8j/2kpE5JJHe98Rbzay4ltTQvWES3UgxgW+It+24H4607p0d8d5MM1inu7KuOzykT34B3SI1ZOYHnsGZDT3BkWjhbneCfbjgbXuOX+WYE1dsGjhY4FQB7itOyGKfQl1REUl8l1BFutk4gfkv4GNIpnHBoD4VOLN2h6wUbDq3TcN7+NBesJPPo9upmHiaSJ7NuYkrZZGSAjJXiAhItjCoSAEDErrG5h2WUvI8ENXIyMCvrpHJ892plkO17zKm0LeQp9JI/XNy7NexNxoc5CfVeTj383KyD7jPqlzI/6aFKy7pD/3DBiKNG2bcGyF1YirkOcjpsAMR/i2mfpg3My73M9pKzcJhFzAZ62e1weeIlbwTBmaTFkDIESy3/ET/rRaxCmhkRZxlkDWDCZWU6xV0vAW0gm54LqotqQG0fPNSC5chWCcpiPDB6bt7cIC88Ja7/jdokiSdI3bf2sOqwIBWAKYfh3oxpel94PUg4Fg7/QnYW20lYOn3EXtVzQ6AyFFY4fLLwjSXfcBhlckNFfEKin5VDycaJuIewOKumnK7ctS6Z5XVcZcKvt8Zd43vgypEJnQ2hdwmNOVnNEXz3JlqTJlt+ncIbcQIcZL2B0fz3BrXKO45pOK+axffR8BMmTRWI//GiEQep+FJyuhHg0REY3XuLKxsfTld1yVNBkRmUeV0FSjNSD8MiHNMxESnH4yEcZYm+8Ip3vFiEg7vpXIx6nkRMxJmf7sf2Dp5pSzqfRKAH6QDgkq7P/G6/QGDiKD9zPzy+HZOQjqTqze9WAb01C0K8l8Z1ZPAWoDtW4xhEgH3AK9hgNKfYm3S2ry5eRShJN1dlOSoEAHZtepjQFuJe X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5d9fdcf5-bd1f-43a1-5cd6-08d97ce9795b 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:45.6264 (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: QYjqTd+bGA1ZvFzLx7a7aJqC1WWIbYlC7vtQinkQgesceV0EmLsFPqmWZkOdSR0ldGVY3EHkOqRNtiT2wKtnK7HcBZ4INfRnyvq9g/Ib1Eo= 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, 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" From: Hanna Reitz Once the mirror job is force-cancelled (job_is_cancelled() is true), we should not generate new I/O requests. This applies to active mirroring, too, so stop it once the job is cancelled. (We must still forward all I/O requests to the source, though, of course, but those are not really I/O requests generated by the job, so this is fine.) Signed-off-by: Hanna Reitz Reviewed-by: Eric Blake Reviewed-by: Vladimir Sementsov-Ogievskiy Message-Id: <20210907124245.143492-11-hreitz@redhat.com> Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/mirror.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/block/mirror.c b/block/mirror.c index 1dbf648311..bbf5815fd7 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1425,6 +1425,7 @@ static int coroutine_fn bdrv_mirror_top_do_write(BlockDriverState *bs, bool copy_to_target; copy_to_target = s->job->ret >= 0 && + !job_is_cancelled(&s->job->common.job) && s->job->copy_mode == MIRROR_COPY_MODE_WRITE_BLOCKING; if (copy_to_target) { @@ -1473,6 +1474,7 @@ static int coroutine_fn bdrv_mirror_top_pwritev(BlockDriverState *bs, bool copy_to_target; copy_to_target = s->job->ret >= 0 && + !job_is_cancelled(&s->job->common.job) && s->job->copy_mode == MIRROR_COPY_MODE_WRITE_BLOCKING; if (copy_to_target) { From patchwork Tue Sep 21 10:20:16 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: 12507533 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 B0905C433EF for ; Tue, 21 Sep 2021 10:33:46 +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 1859761038 for ; Tue, 21 Sep 2021 10:33:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 1859761038 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]:58856 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mSd5t-0008AM-3O for qemu-devel@archiver.kernel.org; Tue, 21 Sep 2021 06:33:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32990) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mSctm-0001lW-DA; Tue, 21 Sep 2021 06:21:14 -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 1mSctk-0002LA-Sp; Tue, 21 Sep 2021 06:21:14 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ae61FhVJYwzt1OLaaK+f0r7bSD7y97ny+2wzTzI0Pi7VpPzzwn7dhxGahRwdvhEXkZ2TLuWwVY+BjZmyWTd4BOa7c4zXWf+d9HskEwFLXEk+5oa39OqZkLDGNximnnjBY4ylbee4nCZ3zdRn+XBtafhSr0lI7SgpIHr5OpAym5ozFIOtWCwZ0pOgXHsKBw2PWHqfMXrT2vQDbAmI2XS2iEQWHRjHgWzgolJz44hzutMPBjsZY+FFXTO/HhnF2UPVJQ7cq06E8j615I2vEqLJrYXXcUHEP3nbZkM44lDqq35XQv6DyfUhF1d0/ZvWfR7l15LQH4/zOtl78PTvYx6C4w== 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=2xvaZssygm8Bh7rOi1eUrBCnt039W0hM5xTn0rgu0DI=; b=Cl6wr0eHtzGW5egPgPqXoU/EFpNl4CcPPpHkvoRubSKigl0JvWCL/kwzuKnoTiUI44ehaeU9Jfg5/o7O8UyEXhgQ4qnhRdccA7Uxx48o/o2kvdFhu021//J3YFn5N0IlJ4eTVlceRHTiB0hWyNoUhM2TeoqYB9QqN4ho4MrffJnhajRrrFN2d81e0lWI663KrQ2j2DqysjVT4TqWi9pxWNzVvE0xhoN8kq/L7UY6hjFb9hUWcVsPNF6ZTUOmAFNF4MiUu28WwpLqJiXygI05r7UX9E30QN8EHw3glOby/g1hjxVLyAARlictJXnXNhAg1FGm957pHfhm3X0LDZZA3g== 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=2xvaZssygm8Bh7rOi1eUrBCnt039W0hM5xTn0rgu0DI=; b=PYA/Do3xR/zVL8MA4voUO0iZoRqNokVjNAshaAHZg4tTMO+3Iwe3gAeHX0kw5dqTuVBq4k8TXqv9lj4g30oiPtVswOMlwrfQo/IDKnyf6YXRuSdmSl7ststStpz4f0DZnngVch7fRhFLybLAa0RPS4rgeJd79PE6q3+coS9Z/hs= 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:46 +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:46 +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 11/12] mirror: Do not clear .cancelled Date: Tue, 21 Sep 2021 13:20:16 +0300 Message-Id: <20210921102017.273679-12-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:45 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e855656d-4212-49d3-91f1-08d97ce97a01 X-MS-TrafficTypeDiagnostic: AS8PR08MB6631: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4714; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CPZa5l9sUxkdWc1fzF1oyvqnnUiZ4mTDBN/I/k7Ue1yw1pYB6zCZd/Mvpwp/ykYVPfhLPoZ70xNTNGKFpH6f8t5c74g/dhdn+krBI7fIaK7fy9JphEKaUlc9G3Nme1gKzkMo0JuUAQGX5d1hQ+qMB97EB4TzgdvH5WfQyhNPDwEemHrQwYbqsK10YyoysYkxaJSNzUSW+SjhZl8JS3pUepuVGAtL6PniOX4v7zWgOJn7b8ZF++fstx0VuarOE3RzRCOCLzggXxLjFA/xK0/rVbYInerC0Zr8qKFuGrwV98NtMA3Sfe4lF6Smetk9q6PZ0YsV8+T+GWKzsImrraHbGVR44r1hy5ytS6GZcCnBF+cmn0kAlbFlpCWmGd9yfkSD01Tcr/dI//c23mnVYgoNpR8Y71n71uGfODjIAxaW3aahmgH/ogNVeeAaVcXHSS94f8MJ/uYelRxfAqUQurEiT0Bu+KJnH+51iT//O8PIP6LNQYQ8vXqJOFTJOHoqsoMVR4bSxjmPKXJJIIga+09tvQUWiUNaFnFnlANbLcL1oksRlhCgrN/zP0mrC0Ql2CG3XOmUvVqMXhAUo0fZYI+Pq7dWl4IhdmBk+DcI8R9T82x60hFo8UmJLJqwRe+565F2hgeL3IvRs6DaENT6Mqk4TNfqLSfHWAyJbw/kFyq/kV4xx9ENWS/4x4eFaH8E6u1Nc3mYVgEHTXsTB+s0AhjRgE++WC5UlL6WJcenFHSl1NA= 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)(142923001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: HQ+OYrpHCp4zugiglH/1uCDVZKW7RQHM2c07PnX1flxpeUhYqt/lIHWanSd3XHWpmbS7pQATvoGeacvM2uRbeMSpWwVdC4Kl+JfU6y3T1KJw/rTpHnSXMZ35RuxDiofwlyoXn04Vd63fDbgsyTHDr2pTOrBs4uNs47dEhyefHP8NI/3lFvKBZVWteZ7ap8RG24N5p8bk00V+XcAuRb+8XCIEpXK/E14mPXzLAyggsXUdKIAxsltllM7DIe47CYD1tCw/aIxZCD6J+GBy51xe5H+NYaJW/Z8fpk9eBc/pM0WBOSuQ6YlNOKPlol7hCoATMZPoxGPjIHlTfSoo6tQpfNpi4cf5AwjUArQjutdMPU/ZYNWxo4oJEk0BB9X0QrlhtGlw0sPANHg6ns4oagshJtAf6TEqi9tkhUgOe771GapRU3Y5MI5Hu3794w7OrA4mB7h4Q++HWi5SFyVR3BHM8HskoDy/Fi4s6tOQ9zT3Dukjo6ENaAl/ncQTG8OI/JHVCvDHi2k7OyxOgy+HuUJzXMKUEU5O6F5VVYKqFPSyN2UWV1qd311Mbd37u/kFA7Hvde9X2XMhCrd74LUS0VYUItgaHjWRePTfKDvdG9bX2idI9sYHkb4vpl8z2W70usJgQSSGQObByw9x8mxcgdaX1d396qxNpyROW8hyNTBxC83VtygpI9BcQuI12On8gCQMzIFlCsHBCV0BK5h2nOwEmdcxOc5l38K20o6wRc74ZHeGv6+Dchq/ooTEDq1VkMiHvn1RP2xNVBh6AYsqjVIwrsLm7tiIf4tlLXV5Q7o+J7Yr0WPIpdqsWL5+pTKQOYpQCf9e/oOF19itX0zPiftIqwEHs1hrlyhYepFOKJghj7nWTZ6pMUfJa2+4qprZ5tb8rX81jk2zqQ8UOhFteZNovUt+hFvzIBV7zCpm6KvO+uiIo1iy20hT18zYHkZ+1gceQzYMxjEVdtzNHSxd2Liy6FObF/ps3suo9HRNC1/BI0SLksfeEQH9mpx4MPq0Kve45n4+Td6h324CJuayURBB9SyTSAz94K5MITsF/+hAzGK6yab1VTp5oyL/weqPgFP28o61ItR8jMOlg4XPScCsnSpdFBqitcpYgvmHLEou2zRYaYZoSEPg7G11NLPdqVcrCPoEr/opRVqZ1ccbnxO81B0Gi/tcbvMxUjTU9J0kOCUKmoxJtPpEQi75AFR3+KAOCa+muE8YAtsaOpaxn8+gI75eB12QeEvNuy3GuHRBYqDqIvVCcm54XGYEbbMIvOTh0ijgGEoQkx4PgrLW+r49SEYvTr/782Lq1pCSY/JC8Xu0J/S07Cm+iDE+zO6ZBpPt X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: e855656d-4212-49d3-91f1-08d97ce97a01 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:46.7177 (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: WUVuEJQcr9lh0awEkWej/LoWfUISdF3MLcIiyxmEK4JLW4IjGeo3n6dgSDYjmoKsXC+GDzVtCPfQNarbKDmmezqO7GZEToOQPt96E9O9tms= 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, 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" From: Hanna Reitz Clearing .cancelled before leaving the main loop when the job has been soft-cancelled is no longer necessary since job_is_cancelled() only returns true for jobs that have been force-cancelled. Therefore, this only makes a differences in places that call job_cancel_requested(). In block/mirror.c, this is done only before .cancelled was cleared. In job.c, there are two callers: - job_completed_txn_abort() asserts that .cancelled is true, so keeping it true will not affect this place. - job_complete() refuses to let a job complete that has .cancelled set. It is correct to refuse to let the user invoke job-complete on mirror jobs that have already been soft-cancelled. With this change, there are no places that reset .cancelled to false and so we can be sure that .force_cancel can only be true if .cancelled is true as well. Assert this in job_is_cancelled(). Signed-off-by: Hanna Reitz Reviewed-by: Eric Blake Reviewed-by: Vladimir Sementsov-Ogievskiy Message-Id: <20210907124245.143492-12-hreitz@redhat.com> Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/mirror.c | 2 -- job.c | 4 +++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/block/mirror.c b/block/mirror.c index bbf5815fd7..bb837db46e 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -946,7 +946,6 @@ static int coroutine_fn mirror_run(Job *job, Error **errp) while (!job_cancel_requested(&s->common.job) && !s->should_complete) { job_yield(&s->common.job); } - s->common.job.cancelled = false; goto immediate_exit; } @@ -1085,7 +1084,6 @@ static int coroutine_fn mirror_run(Job *job, Error **errp) * completion. */ assert(QLIST_EMPTY(&bs->tracked_requests)); - s->common.job.cancelled = false; need_drain = false; break; } diff --git a/job.c b/job.c index be878ca5fc..85c0216734 100644 --- a/job.c +++ b/job.c @@ -217,7 +217,9 @@ const char *job_type_str(const Job *job) bool job_is_cancelled(Job *job) { - return job->cancelled && job->force_cancel; + /* force_cancel may be true only if cancelled is true, too */ + assert(job->cancelled || !job->force_cancel); + return job->force_cancel; } bool job_cancel_requested(Job *job) From patchwork Tue Sep 21 10:20:17 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: 12507547 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 B826CC433EF for ; Tue, 21 Sep 2021 10:35:02 +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 2EBE561100 for ; Tue, 21 Sep 2021 10:35:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 2EBE561100 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]:33710 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mSd77-0001rs-5d for qemu-devel@archiver.kernel.org; Tue, 21 Sep 2021 06:35:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33016) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mSctp-0001rn-Rd; Tue, 21 Sep 2021 06:21:17 -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 1mSctn-0002LA-4F; Tue, 21 Sep 2021 06:21:17 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cakLbVwLOIeF1gyEV2gPc97nKITRAjLudbZBjmT68tKE7xJLmkzURilnlLmAa1UMf3JJHFnETjunuJe5J/mg+fdYgwWWtSWfy3QQk/KvOlN1rNjEHLJpwUyptmjhxugIgxP3DboVamKQgBx+QnYT1wmFO0d3TdZ7E6e7su73coQJCUJwVxfQKQKcV1pYPd9A+r1EbmeD8M2IW+x4P7QgNUV80i2Ju2xAvYuVUYPCaLJLAyJirlcV4k/o/PNzcZjMzT5i2ak2ndsu7J9MU3Ti370WnXKeyc9ZQdcxIphQbljPtk65h9FnmjP9rUcTRfEw2GqYBx6hI12/u+MZVczo8w== 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=VIXJutVACpokyHPbm1tWI3UYIF9w7tCcMxrb0wrbD2Q=; b=hXG1Bk5YiC8GSjLxdTM3+pAF6gx2UlsygqHxqU7K4zsBQcgRJQqUSyGwn9O+pyabyC56D+lpCScrWwjbElOI9ZpdxMnPiX1aRX1DaAaA9xPB+xFv1nLHxL/DHgnuyZoQVhmUlkEQ1PdLSEDNcUOcQ5BllQYOs7zsIlLijoOv9uAToThsjc1gDVuJjwDLaNQqZxyJH1KLgVLvaW8WLbV5BIDUT1212lF1wO/esNGqIIgAQFKm3BhgKQvn+N9BXo4orqf8B8nr+LDA5sBABWObUkK3Ho5FP6/XOcCjM/XoMa3EbqI0e+yYmdbU8plIVpnE1ZGm7/D2MRV/RajJllPHhA== 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=VIXJutVACpokyHPbm1tWI3UYIF9w7tCcMxrb0wrbD2Q=; b=kdfsQlDOrKfPRn1xNH01wCzZLbvG0Nvkw8hQBf6oAGIVPGhptV2IiACsQ1GTEjaVU5/7tMi48s305fOigHGq99x+SzpWxUmGZBhCVO/fsNRVjCwkosmrDbuA+iXG7sW9zZNaMZruKoAFguo4+wei4lfQVtDJLQRkNCQdIVSjfnY= 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:47 +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:47 +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 Subject: [PULL 12/12] iotests: Add mirror-ready-cancel-error test Date: Tue, 21 Sep 2021 13:20:17 +0300 Message-Id: <20210921102017.273679-13-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:46 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 745d1ddf-c427-4c44-24de-08d97ce97a9d X-MS-TrafficTypeDiagnostic: AS8PR08MB6631: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AyK/kWpFDWFCHVO8ng4nFPX7FoUB4if5+g0PONO5pKRQixeASLxd04+TrqRNWjcIov3Tn6+wpSkmRK1hL+RW+37F7BcRQRWpvMlS4pP44nr62HM9PICeGUfq5oJJN2GdWudVOVHq8KNRFH2akdt3+hJsVsP7Pl5zUL3G9I4myLkqqIgH62OI66poETCAEUNvvMWcMRGOy+vGo2F1f7iymTlKChKDfnn1CWtS2mjrHQOq1KajYXQ45H60vqW8B0CMO0Gbatcg1clOhwByPUvof9+EMmagrSPwjgOTNkgmKe+o62SyvQlpslSSp/y1vXl568SUdUgH4cWwVLm7gPYjzhyuk9WMg7AWGWLE4GcMT9CnatfdgAzeCwf/lSHKWfOeAsnBAsUeDEs3p0MDNgPL1F3sYyZrWIS8wo7iwMIASgWTCG1zPUutuRXLQOU11IdEzf8Hi2CgLqmaEAWsUBkrNMuQQ9yOTS29qilhJ5EKFEqkFu78451DNItNe7BoN27T2vMDYUKCeYXO2ht3OWx55+Oh9JmimSCEVJdluwz/WHuJe/5cHQkiygDKhxTvliZd4bKDwcZUWs6ta30TWMFjpLhPPfGOy0VSq46asyC4fsSak5TBH0hEhhQ6WTUBdRXFTXSRBDJzQuL1le23md/zv5uzHdyrMqjuqJ9sPCtWHQ+P1zqHbCqGOcSgO2hXq/YZhjaZ5S6m3azWDZSk5O6FYD6p3gdc3cVQNqg0FfTgNFWBI+Uv6zea6AU19vUoWxBgn+zJGDjL0VTrmjWUfB0zbberekWdKbnUfFsNFRd3fnhjsME4LnOP3t9N4Ajh/WAJ 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)(2004002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 2caC+qn5ds8/Dj1MUzKVCVxvmN0jC1Pd0GVX5XylHzOteakDBUjHvBJyJ+rklolG06tfRxECfd+OH3v94VzI7OzwwV8gHQKLtZDXVjdQSbOk244j1R6uhKV764tReO1fUMdw2FuTiZtGZsPNA8eRzLOtVWMAYBJiL4SZ3A9IX4CYKl/mEYCJ/2xuy8Mbi6Zud7gecoO2JKHpKeBgbUt7/UquplmJaO7JOFFndxWDfiRj5mfMtQt/41X8qrbMa+grsV5MczLYX+WCymZVpMIuEpKBsc8iLXfcjOpBDHfTzMmmpKTHqgpspdbuHmdkr/iK/Gk6W5DixLM8TCxyzPQl36W3Nb3theH/Mw8xCN6WZUqYxrDznJifY7Suieuu+gTdo1CAT5wXU+FfgJAbjsr+yasuhuIDLEMehruRxTXW39V5KWMs1sQCg9b7MGuwxbov7J6GPPvpW3pV4WeC1by3zzFgjej4QmPWwMVKyx9JUAXrLKL0CxKH9YvIOVuz1TGqhNpRp9kPIlPJVidBLVm6zKjqKjMrx9tU+jtb8FmtSNF8z/2sVXMjFNCK41q6oVr4lSii9tyqG34BJ7OSHA4j5Y2bkecykWsQWkENujpv+nyUWrVqoCaRPwJNbL3+S4h7kCfHvUgNiyB+aJSs5PuG2H3uu27N+0ZU/prwC9KPbMBTDNJO4fIhsgbGBm9nz1yDz8cajXXh9OW4AkveX9+X8mZAlzJk/i+R/twZBH9Zy1xIFTmScAcL8U2NUX/lMFywKvcSbVoKeLjgs4ZzBimdEGSUdFjIU8oFxU9VWKrwQoSRz9eTm7NyaLkskZPOIhskAbG1YxOuA3xHhIJBfFbQ1U4itSayBDK5qYlvQjsa+aDP7qLaf/tVIlUsQ+rDw6tpSPuYRZAjJmbIWMVwphVfAXpvZ0DdygnbukoQF8jM1Oi5mvVUeD1z23XwwJEyt6sh61thqY+HcaJxJfVGjojTbYNmawn2PLD9aYfHRVvUmwZc+CFtj/kuSxGY3n5poS7/soLCLYlnup/X7R7jhW2DSGvpw8ZY5R5SAKf3IVnsWFk+ZZXQ568AEKY0sVZbnxSscb/LAhf2SZeSYVFPpL5lGP44bWI+ELKa+Yx1CNkq35t/1RyJQA2HdHqlaMntOmkjCMSjo9lmjfjB7M1+rws22WZwyIwbqdqHw13x2sGnNHy/SW/8Fv8KV6GoiQH2eKybnbcd44Rn7ezcLjOCumvlI8AHJvbB5rZpf7qc+R1hyYzHCADSkHxsxHfCbJvIf80/f5rxg8hvwciSS7/bXGcglvspOf6CRpGbkCBwwW/56eRA5VlV7y4GwZCwAjWAjeGc X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 745d1ddf-c427-4c44-24de-08d97ce97a9d 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:47.7183 (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: +RlQoKE2BKXnxD5LayYQKkvpJb693vJkpkbcA6/bkiepvv2jOA2WXcXx/X53eWrLHgRC10yblrN474t8vxqia49sKjahvZS1jLVqslBh5t0= 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, 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" From: Hanna Reitz Test what happens when there is an I/O error after a mirror job in the READY phase has been cancelled. Signed-off-by: Hanna Reitz Reviewed-by: Vladimir Sementsov-Ogievskiy Tested-by: Vladimir Sementsov-Ogievskiy Message-Id: <20210907124245.143492-13-hreitz@redhat.com> Signed-off-by: Vladimir Sementsov-Ogievskiy --- .../tests/mirror-ready-cancel-error | 143 ++++++++++++++++++ .../tests/mirror-ready-cancel-error.out | 5 + 2 files changed, 148 insertions(+) create mode 100755 tests/qemu-iotests/tests/mirror-ready-cancel-error create mode 100644 tests/qemu-iotests/tests/mirror-ready-cancel-error.out diff --git a/tests/qemu-iotests/tests/mirror-ready-cancel-error b/tests/qemu-iotests/tests/mirror-ready-cancel-error new file mode 100755 index 0000000000..f2dc88881f --- /dev/null +++ b/tests/qemu-iotests/tests/mirror-ready-cancel-error @@ -0,0 +1,143 @@ +#!/usr/bin/env python3 +# group: rw quick +# +# Test what happens when errors occur to a mirror job after it has +# been cancelled in the READY phase +# +# Copyright (C) 2021 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +import os +import iotests + + +image_size = 1 * 1024 * 1024 +source = os.path.join(iotests.test_dir, 'source.img') +target = os.path.join(iotests.test_dir, 'target.img') + + +class TestMirrorReadyCancelError(iotests.QMPTestCase): + def setUp(self) -> None: + assert iotests.qemu_img_create('-f', iotests.imgfmt, source, + str(image_size)) == 0 + assert iotests.qemu_img_create('-f', iotests.imgfmt, target, + str(image_size)) == 0 + + self.vm = iotests.VM() + self.vm.launch() + + def tearDown(self) -> None: + self.vm.shutdown() + os.remove(source) + os.remove(target) + + def add_blockdevs(self, once: bool) -> None: + res = self.vm.qmp('blockdev-add', + **{'node-name': 'source', + 'driver': iotests.imgfmt, + 'file': { + 'driver': 'file', + 'filename': source + }}) + self.assert_qmp(res, 'return', {}) + + # blkdebug notes: + # Enter state 2 on the first flush, which happens before the + # job enters the READY state. The second flush will happen + # when the job is about to complete, and we want that one to + # fail. + res = self.vm.qmp('blockdev-add', + **{'node-name': 'target', + 'driver': iotests.imgfmt, + 'file': { + 'driver': 'blkdebug', + 'image': { + 'driver': 'file', + 'filename': target + }, + 'set-state': [{ + 'event': 'flush_to_disk', + 'state': 1, + 'new_state': 2 + }], + 'inject-error': [{ + 'event': 'flush_to_disk', + 'once': once, + 'immediately': True, + 'state': 2 + }]}}) + self.assert_qmp(res, 'return', {}) + + def start_mirror(self) -> None: + res = self.vm.qmp('blockdev-mirror', + job_id='mirror', + device='source', + target='target', + filter_node_name='mirror-top', + sync='full', + on_target_error='stop') + self.assert_qmp(res, 'return', {}) + + def cancel_mirror_with_error(self) -> None: + self.vm.event_wait('BLOCK_JOB_READY') + + # Write something so will not leave the job immediately, but + # flush first (which will fail, thanks to blkdebug) + res = self.vm.qmp('human-monitor-command', + command_line='qemu-io mirror-top "write 0 64k"') + self.assert_qmp(res, 'return', '') + + # Drain status change events + while self.vm.event_wait('JOB_STATUS_CHANGE', timeout=0.0) is not None: + pass + + res = self.vm.qmp('block-job-cancel', device='mirror') + self.assert_qmp(res, 'return', {}) + + self.vm.event_wait('BLOCK_JOB_ERROR') + + def test_transient_error(self) -> None: + self.add_blockdevs(True) + self.start_mirror() + self.cancel_mirror_with_error() + + while True: + e = self.vm.event_wait('JOB_STATUS_CHANGE') + if e['data']['status'] == 'standby': + # Transient error, try again + self.vm.qmp('block-job-resume', device='mirror') + elif e['data']['status'] == 'null': + break + + def test_persistent_error(self) -> None: + self.add_blockdevs(False) + self.start_mirror() + self.cancel_mirror_with_error() + + while True: + e = self.vm.event_wait('JOB_STATUS_CHANGE') + if e['data']['status'] == 'standby': + # Persistent error, no point in continuing + self.vm.qmp('block-job-cancel', device='mirror', force=True) + elif e['data']['status'] == 'null': + break + + +if __name__ == '__main__': + # LUKS would require special key-secret handling in add_blockdevs() + iotests.main(supported_fmts=['generic'], + unsupported_fmts=['luks'], + supported_protocols=['file']) diff --git a/tests/qemu-iotests/tests/mirror-ready-cancel-error.out b/tests/qemu-iotests/tests/mirror-ready-cancel-error.out new file mode 100644 index 0000000000..fbc63e62f8 --- /dev/null +++ b/tests/qemu-iotests/tests/mirror-ready-cancel-error.out @@ -0,0 +1,5 @@ +.. +---------------------------------------------------------------------- +Ran 2 tests + +OK