From patchwork Tue Nov 12 11:30:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergio Lopez X-Patchwork-Id: 11239125 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A53A713B1 for ; Tue, 12 Nov 2019 11:39:37 +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 7ABB921783 for ; Tue, 12 Nov 2019 11:39:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="H0x5pcnp" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7ABB921783 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:33728 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iUUWG-00062i-Mw for patchwork-qemu-devel@patchwork.kernel.org; Tue, 12 Nov 2019 06:39:36 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35643) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iUUP9-0007Hx-80 for qemu-devel@nongnu.org; Tue, 12 Nov 2019 06:32:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iUUP2-0001BU-53 for qemu-devel@nongnu.org; Tue, 12 Nov 2019 06:32:11 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:51846 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iUUOy-00018T-9N for qemu-devel@nongnu.org; Tue, 12 Nov 2019 06:32:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573558321; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fw8sl+1CgmcCR7p4mfbvS51RM3jOkynBnHJ/+9qXwQQ=; b=H0x5pcnpTbDfHqk4PBBdbvm5gLrg+GrphHj8uzo6s71xodjs4tBT0ZtsWBYOsXL+YgRf0r W1x2hmggIT6XHOqejXyepvVr3ZzGVUiVv9LQ5iy0nw3DbSGD43qDSQicF+ECTZu4sRReoi AfkvcjlG3W9Ho5MpOEajPMw7D4SSO28= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-257-Mxi0ETbjP_qVFDJrNjeibg-1; Tue, 12 Nov 2019 06:30:30 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7BF78800EB3; Tue, 12 Nov 2019 11:30:29 +0000 (UTC) Received: from dritchie.redhat.com (unknown [10.33.36.176]) by smtp.corp.redhat.com (Postfix) with ESMTP id DE40C60A89; Tue, 12 Nov 2019 11:30:27 +0000 (UTC) From: Sergio Lopez To: qemu-devel@nongnu.org Subject: [PATCH v3 5/8] blockdev: merge blockdev_backup_prepare with do_blockdev_backup Date: Tue, 12 Nov 2019 12:30:09 +0100 Message-Id: <20191112113012.71136-6-slp@redhat.com> In-Reply-To: <20191112113012.71136-1-slp@redhat.com> References: <20191112113012.71136-1-slp@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: Mxi0ETbjP_qVFDJrNjeibg-1 X-Mimecast-Spam-Score: 0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.120 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: Kevin Wolf , Sergio Lopez , Markus Armbruster , qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Consolidate blockdev_backup_prepare() with do_blockdev_backup() as a first step towards streamlining all functionality through transactions. Signed-off-by: Sergio Lopez --- blockdev.c | 64 +++++++++++++----------------------------------------- 1 file changed, 15 insertions(+), 49 deletions(-) diff --git a/blockdev.c b/blockdev.c index 5e85fc042e..128707cdc6 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1940,47 +1940,6 @@ typedef struct BlockdevBackupState { BlockJob *job; } BlockdevBackupState; -static BlockJob *do_blockdev_backup(BlockdevBackup *backup, JobTxn *txn, - Error **errp); - -static void blockdev_backup_prepare(BlkActionState *common, Error **errp) -{ - BlockdevBackupState *state = DO_UPCAST(BlockdevBackupState, common, common); - BlockdevBackup *backup; - BlockDriverState *bs, *target; - AioContext *aio_context; - Error *local_err = NULL; - - assert(common->action->type == TRANSACTION_ACTION_KIND_BLOCKDEV_BACKUP); - backup = common->action->u.blockdev_backup.data; - - bs = bdrv_lookup_bs(backup->device, backup->device, errp); - if (!bs) { - return; - } - - target = bdrv_lookup_bs(backup->target, backup->target, errp); - if (!target) { - return; - } - - aio_context = bdrv_get_aio_context(bs); - aio_context_acquire(aio_context); - state->bs = bs; - - /* Paired with .clean() */ - bdrv_drained_begin(state->bs); - - state->job = do_blockdev_backup(backup, common->block_job_txn, &local_err); - if (local_err) { - error_propagate(errp, local_err); - goto out; - } - -out: - aio_context_release(aio_context); -} - static void blockdev_backup_commit(BlkActionState *common) { BlockdevBackupState *state = DO_UPCAST(BlockdevBackupState, common, common); @@ -3695,32 +3654,39 @@ XDbgBlockGraph *qmp_x_debug_query_block_graph(Error **errp) return bdrv_get_xdbg_block_graph(errp); } -BlockJob *do_blockdev_backup(BlockdevBackup *backup, JobTxn *txn, - Error **errp) +static void blockdev_backup_prepare(BlkActionState *common, Error **errp) { + BlockdevBackupState *state = DO_UPCAST(BlockdevBackupState, common, common); + BlockdevBackup *backup; BlockDriverState *bs; BlockDriverState *target_bs; AioContext *aio_context; - BlockJob *job; + + assert(common->action->type == TRANSACTION_ACTION_KIND_BLOCKDEV_BACKUP); + backup = common->action->u.blockdev_backup.data; bs = bdrv_lookup_bs(backup->device, backup->device, errp); if (!bs) { - return NULL; + return; } target_bs = bdrv_lookup_bs(backup->target, backup->target, errp); if (!target_bs) { - return NULL; + return; } aio_context = bdrv_get_aio_context(bs); aio_context_acquire(aio_context); + state->bs = bs; - job = do_backup_common(qapi_BlockdevBackup_base(backup), - bs, target_bs, aio_context, txn, errp); + /* Paired with .clean() */ + bdrv_drained_begin(state->bs); + + state->job = do_backup_common(qapi_BlockdevBackup_base(backup), + bs, target_bs, aio_context, + common->block_job_txn, errp); aio_context_release(aio_context); - return job; } void qmp_blockdev_backup(BlockdevBackup *arg, Error **errp)