From patchwork Wed Apr 1 08:15:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Reiter X-Patchwork-Id: 1265064 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=proxmox.com 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 ozlabs.org (Postfix) with ESMTPS id 48sfCW2Qqxz9sRf for ; Wed, 1 Apr 2020 19:15:49 +1100 (AEDT) Received: from localhost ([::1]:48796 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jJYXJ-0001uT-Bm for incoming@patchwork.ozlabs.org; Wed, 01 Apr 2020 04:15:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35272) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jJYWs-0001rT-0w for qemu-devel@nongnu.org; Wed, 01 Apr 2020 04:15:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jJYWr-00070d-2L for qemu-devel@nongnu.org; Wed, 01 Apr 2020 04:15:17 -0400 Received: from proxmox-new.maurer-it.com ([212.186.127.180]:34521) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jJYWo-0006hw-L2; Wed, 01 Apr 2020 04:15:14 -0400 Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id A66F845930; Wed, 1 Apr 2020 10:15:10 +0200 (CEST) From: Stefan Reiter To: qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: [PATCH v4 2/3] replication: acquire aio context before calling job_cancel_sync Date: Wed, 1 Apr 2020 10:15:03 +0200 Message-Id: <20200401081504.200017-3-s.reiter@proxmox.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200401081504.200017-1-s.reiter@proxmox.com> References: <20200401081504.200017-1-s.reiter@proxmox.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 212.186.127.180 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: , Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, slp@redhat.com, mreitz@redhat.com, stefanha@redhat.com, jsnow@redhat.com, dietmar@proxmox.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" job_cancel_sync requires the job's lock to be held, all other callers already do this (replication_stop, drive_backup_abort, blockdev_backup_abort, job_cancel_sync_all, cancel_common). Signed-off-by: Stefan Reiter --- block/replication.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/block/replication.c b/block/replication.c index 413d95407d..17ddc31569 100644 --- a/block/replication.c +++ b/block/replication.c @@ -144,12 +144,18 @@ fail: static void replication_close(BlockDriverState *bs) { BDRVReplicationState *s = bs->opaque; + Job *commit_job; + AioContext *commit_ctx; if (s->stage == BLOCK_REPLICATION_RUNNING) { replication_stop(s->rs, false, NULL); } if (s->stage == BLOCK_REPLICATION_FAILOVER) { - job_cancel_sync(&s->commit_job->job); + commit_job = &s->commit_job->job; + commit_ctx = commit_job->aio_context; + aio_context_acquire(commit_ctx); + job_cancel_sync(commit_job); + aio_context_release(commit_ctx); } if (s->mode == REPLICATION_MODE_SECONDARY) {