From patchwork Tue Nov 1 12:51:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Cody X-Patchwork-Id: 9407373 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2BED660721 for ; Tue, 1 Nov 2016 13:08:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 14CC92987D for ; Tue, 1 Nov 2016 13:08:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 07FED2987F; Tue, 1 Nov 2016 13:08:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 45AD72987D for ; Tue, 1 Nov 2016 13:08:52 +0000 (UTC) Received: from localhost ([::1]:47761 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c1Yo7-0001Dz-CI for patchwork-qemu-devel@patchwork.kernel.org; Tue, 01 Nov 2016 09:08:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34104) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c1YXV-0004XL-H6 for qemu-devel@nongnu.org; Tue, 01 Nov 2016 08:51:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c1YXU-0003os-6r for qemu-devel@nongnu.org; Tue, 01 Nov 2016 08:51:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50416) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c1YXO-0003mU-MR; Tue, 01 Nov 2016 08:51:34 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D640161B95; Tue, 1 Nov 2016 12:51:33 +0000 (UTC) Received: from localhost (ovpn-112-28.phx2.redhat.com [10.3.112.28]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id uA1CpWBA012030 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 1 Nov 2016 08:51:33 -0400 From: Jeff Cody To: qemu-block@nongnu.org Date: Tue, 1 Nov 2016 08:51:07 -0400 Message-Id: <1478004671-19154-11-git-send-email-jcody@redhat.com> In-Reply-To: <1478004671-19154-1-git-send-email-jcody@redhat.com> References: <1478004671-19154-1-git-send-email-jcody@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 01 Nov 2016 12:51:33 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v2 10/14] Replication/Blockjobs: Create replication jobs as internal X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, jcody@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: John Snow Bubble up the internal interface to commit and backup jobs, then switch replication tasks over to using this methodology. Signed-off-by: John Snow Reviewed-by: Kevin Wolf Reviewed-by: Jeff Cody Message-id: 1477584421-1399-4-git-send-email-jsnow@redhat.com Signed-off-by: Jeff Cody --- block/backup.c | 3 ++- block/mirror.c | 21 ++++++++++----------- block/replication.c | 14 +++++++------- blockdev.c | 11 +++++++---- include/block/block_int.h | 9 +++++++-- qemu-img.c | 5 +++-- 6 files changed, 36 insertions(+), 27 deletions(-) diff --git a/block/backup.c b/block/backup.c index 3877d93..2a369e6 100644 --- a/block/backup.c +++ b/block/backup.c @@ -543,6 +543,7 @@ void backup_start(const char *job_id, BlockDriverState *bs, bool compress, BlockdevOnError on_source_error, BlockdevOnError on_target_error, + int creation_flags, BlockCompletionFunc *cb, void *opaque, BlockJobTxn *txn, Error **errp) { @@ -612,7 +613,7 @@ void backup_start(const char *job_id, BlockDriverState *bs, } job = block_job_create(job_id, &backup_job_driver, bs, speed, - BLOCK_JOB_DEFAULT, cb, opaque, errp); + creation_flags, cb, opaque, errp); if (!job) { goto error; } diff --git a/block/mirror.c b/block/mirror.c index e9fba9b..fa41849 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -937,9 +937,9 @@ static const BlockJobDriver commit_active_job_driver = { }; static void mirror_start_job(const char *job_id, BlockDriverState *bs, - BlockDriverState *target, const char *replaces, - int64_t speed, uint32_t granularity, - int64_t buf_size, + int creation_flags, BlockDriverState *target, + const char *replaces, int64_t speed, + uint32_t granularity, int64_t buf_size, BlockMirrorBackingMode backing_mode, BlockdevOnError on_source_error, BlockdevOnError on_target_error, @@ -967,8 +967,8 @@ static void mirror_start_job(const char *job_id, BlockDriverState *bs, buf_size = DEFAULT_MIRROR_BUF_SIZE; } - s = block_job_create(job_id, driver, bs, speed, - BLOCK_JOB_DEFAULT, cb, opaque, errp); + s = block_job_create(job_id, driver, bs, speed, creation_flags, + cb, opaque, errp); if (!s) { return; } @@ -1031,17 +1031,16 @@ void mirror_start(const char *job_id, BlockDriverState *bs, } is_none_mode = mode == MIRROR_SYNC_MODE_NONE; base = mode == MIRROR_SYNC_MODE_TOP ? backing_bs(bs) : NULL; - mirror_start_job(job_id, bs, target, replaces, + mirror_start_job(job_id, bs, BLOCK_JOB_DEFAULT, target, replaces, speed, granularity, buf_size, backing_mode, on_source_error, on_target_error, unmap, cb, opaque, errp, &mirror_job_driver, is_none_mode, base, false); } void commit_active_start(const char *job_id, BlockDriverState *bs, - BlockDriverState *base, int64_t speed, - BlockdevOnError on_error, - BlockCompletionFunc *cb, - void *opaque, Error **errp, + BlockDriverState *base, int creation_flags, + int64_t speed, BlockdevOnError on_error, + BlockCompletionFunc *cb, void *opaque, Error **errp, bool auto_complete) { int64_t length, base_length; @@ -1080,7 +1079,7 @@ void commit_active_start(const char *job_id, BlockDriverState *bs, } } - mirror_start_job(job_id, bs, base, NULL, speed, 0, 0, + mirror_start_job(job_id, bs, creation_flags, base, NULL, speed, 0, 0, MIRROR_LEAVE_BACKING_CHAIN, on_error, on_error, true, cb, opaque, &local_err, &commit_active_job_driver, false, base, auto_complete); diff --git a/block/replication.c b/block/replication.c index 02aeaaf..d5e2b0f 100644 --- a/block/replication.c +++ b/block/replication.c @@ -508,10 +508,11 @@ static void replication_start(ReplicationState *rs, ReplicationMode mode, bdrv_op_block_all(top_bs, s->blocker); bdrv_op_unblock(top_bs, BLOCK_OP_TYPE_DATAPLANE, s->blocker); - backup_start("replication-backup", s->secondary_disk->bs, - s->hidden_disk->bs, 0, MIRROR_SYNC_MODE_NONE, NULL, false, + backup_start(NULL, s->secondary_disk->bs, s->hidden_disk->bs, 0, + MIRROR_SYNC_MODE_NONE, NULL, false, BLOCKDEV_ON_ERROR_REPORT, BLOCKDEV_ON_ERROR_REPORT, - backup_job_completed, bs, NULL, &local_err); + BLOCK_JOB_INTERNAL, backup_job_completed, bs, + NULL, &local_err); if (local_err) { error_propagate(errp, local_err); backup_job_cleanup(bs); @@ -633,10 +634,9 @@ static void replication_stop(ReplicationState *rs, bool failover, Error **errp) } s->replication_state = BLOCK_REPLICATION_FAILOVER; - commit_active_start("replication-commit", s->active_disk->bs, - s->secondary_disk->bs, 0, BLOCKDEV_ON_ERROR_REPORT, - replication_done, - bs, errp, true); + commit_active_start(NULL, s->active_disk->bs, s->secondary_disk->bs, + BLOCK_JOB_INTERNAL, 0, BLOCKDEV_ON_ERROR_REPORT, + replication_done, bs, errp, true); break; default: aio_context_release(aio_context); diff --git a/blockdev.c b/blockdev.c index d57cb0c..9c483bd 100644 --- a/blockdev.c +++ b/blockdev.c @@ -3110,8 +3110,9 @@ void qmp_block_commit(bool has_job_id, const char *job_id, const char *device, " but 'top' is the active layer"); goto out; } - commit_active_start(has_job_id ? job_id : NULL, bs, base_bs, speed, - on_error, block_job_cb, bs, &local_err, false); + commit_active_start(has_job_id ? job_id : NULL, bs, base_bs, + BLOCK_JOB_DEFAULT, speed, on_error, block_job_cb, + bs, &local_err, false); } else { BlockDriverState *overlay_bs = bdrv_find_overlay(bs, top_bs); if (bdrv_op_is_blocked(overlay_bs, BLOCK_OP_TYPE_COMMIT_TARGET, errp)) { @@ -3239,7 +3240,8 @@ static void do_drive_backup(DriveBackup *backup, BlockJobTxn *txn, Error **errp) backup_start(backup->job_id, bs, target_bs, backup->speed, backup->sync, bmap, backup->compress, backup->on_source_error, - backup->on_target_error, block_job_cb, bs, txn, &local_err); + backup->on_target_error, BLOCK_JOB_DEFAULT, + block_job_cb, bs, txn, &local_err); bdrv_unref(target_bs); if (local_err != NULL) { error_propagate(errp, local_err); @@ -3309,7 +3311,8 @@ void do_blockdev_backup(BlockdevBackup *backup, BlockJobTxn *txn, Error **errp) } backup_start(backup->job_id, bs, target_bs, backup->speed, backup->sync, NULL, backup->compress, backup->on_source_error, - backup->on_target_error, block_job_cb, bs, txn, &local_err); + backup->on_target_error, BLOCK_JOB_DEFAULT, + block_job_cb, bs, txn, &local_err); if (local_err != NULL) { error_propagate(errp, local_err); } diff --git a/include/block/block_int.h b/include/block/block_int.h index e7ff584..348d457 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -706,6 +706,8 @@ void commit_start(const char *job_id, BlockDriverState *bs, * device name of @bs. * @bs: Active block device to be committed. * @base: Block device that will be written into, and become the new top. + * @creation_flags: Flags that control the behavior of the Job lifetime. + * See @BlockJobCreateFlags * @speed: The maximum speed, in bytes per second, or 0 for unlimited. * @on_error: The action to take upon error. * @cb: Completion function for the job. @@ -715,8 +717,8 @@ void commit_start(const char *job_id, BlockDriverState *bs, * */ void commit_active_start(const char *job_id, BlockDriverState *bs, - BlockDriverState *base, int64_t speed, - BlockdevOnError on_error, + BlockDriverState *base, int creation_flags, + int64_t speed, BlockdevOnError on_error, BlockCompletionFunc *cb, void *opaque, Error **errp, bool auto_complete); /* @@ -765,6 +767,8 @@ void mirror_start(const char *job_id, BlockDriverState *bs, * @sync_bitmap: The dirty bitmap if sync_mode is MIRROR_SYNC_MODE_INCREMENTAL. * @on_source_error: The action to take upon error reading from the source. * @on_target_error: The action to take upon error writing to the target. + * @creation_flags: Flags that control the behavior of the Job lifetime. + * See @BlockJobCreateFlags * @cb: Completion function for the job. * @opaque: Opaque pointer value passed to @cb. * @txn: Transaction that this job is part of (may be NULL). @@ -778,6 +782,7 @@ void backup_start(const char *job_id, BlockDriverState *bs, bool compress, BlockdevOnError on_source_error, BlockdevOnError on_target_error, + int creation_flags, BlockCompletionFunc *cb, void *opaque, BlockJobTxn *txn, Error **errp); diff --git a/qemu-img.c b/qemu-img.c index ac7f40d..6949b73 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -933,8 +933,9 @@ static int img_commit(int argc, char **argv) aio_context = bdrv_get_aio_context(bs); aio_context_acquire(aio_context); - commit_active_start("commit", bs, base_bs, 0, BLOCKDEV_ON_ERROR_REPORT, - common_block_job_cb, &cbi, &local_err, false); + commit_active_start("commit", bs, base_bs, BLOCK_JOB_DEFAULT, 0, + BLOCKDEV_ON_ERROR_REPORT, common_block_job_cb, &cbi, + &local_err, false); aio_context_release(aio_context); if (local_err) { goto done;