From patchwork Thu May 21 06:42:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fam Zheng X-Patchwork-Id: 474820 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 7058314077C for ; Thu, 21 May 2015 16:51:09 +1000 (AEST) Received: from localhost ([::1]:55552 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YvKJv-0007tO-KV for incoming@patchwork.ozlabs.org; Thu, 21 May 2015 02:51:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36674) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YvKCU-0002m2-8Z for qemu-devel@nongnu.org; Thu, 21 May 2015 02:43:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YvKCR-0004U9-KP for qemu-devel@nongnu.org; Thu, 21 May 2015 02:43:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53273) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YvKCM-0004Rv-0r; Thu, 21 May 2015 02:43:18 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 85D5F3C225; Thu, 21 May 2015 06:43:16 +0000 (UTC) Received: from ad.nay.redhat.com (dhcp-14-155.nay.redhat.com [10.66.14.155]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t4L6h4V7007303; Thu, 21 May 2015 02:43:11 -0400 From: Fam Zheng To: qemu-devel@nongnu.org Date: Thu, 21 May 2015 14:42:51 +0800 Message-Id: <1432190583-10518-2-git-send-email-famz@redhat.com> In-Reply-To: <1432190583-10518-1-git-send-email-famz@redhat.com> References: <1432190583-10518-1-git-send-email-famz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , qemu-block@nongnu.org, jcody@redhat.com, armbru@redhat.com, mreitz@redhat.com, Stefan Hajnoczi , amit.shah@redhat.com, pbonzini@redhat.com Subject: [Qemu-devel] [PATCH v6 01/13] block: Add op blocker type "device IO" X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org It blocks device IO. All bdrv_op_block_all/blk_op_block_all callers are taken care of: - virtio_blk_data_plane_create - virtio_scsi_hotplug Device creation, unblock it. - bdrv_set_backing_hd Backing hd is not used by device, so blocking is OK. - backup_start Blocking target when backup is running, unblock it. - mirror_complete Blocking s->to_replace until mirror_exit, OK. - block_job_complete The block job may be long running. Unblock it. - init_blk_migration The block migration may be long running, Unblock it. Signed-off-by: Fam Zheng --- blockjob.c | 1 + hw/block/dataplane/virtio-blk.c | 1 + hw/scsi/virtio-scsi.c | 1 + include/block/block.h | 1 + migration/block.c | 1 + 5 files changed, 5 insertions(+) diff --git a/blockjob.c b/blockjob.c index 2755465..e39bdde 100644 --- a/blockjob.c +++ b/blockjob.c @@ -51,6 +51,7 @@ void *block_job_create(const BlockJobDriver *driver, BlockDriverState *bs, BlockJobType_lookup[driver->job_type]); bdrv_op_block_all(bs, job->blocker); bdrv_op_unblock(bs, BLOCK_OP_TYPE_DATAPLANE, job->blocker); + bdrv_op_unblock(bs, BLOCK_OP_TYPE_DEVICE_IO, job->blocker); job->driver = driver; job->bs = bs; diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-blk.c index 3db139b..3ecc8bd 100644 --- a/hw/block/dataplane/virtio-blk.c +++ b/hw/block/dataplane/virtio-blk.c @@ -209,6 +209,7 @@ void virtio_blk_data_plane_create(VirtIODevice *vdev, VirtIOBlkConf *conf, blk_op_unblock(conf->conf.blk, BLOCK_OP_TYPE_MIRROR, s->blocker); blk_op_unblock(conf->conf.blk, BLOCK_OP_TYPE_STREAM, s->blocker); blk_op_unblock(conf->conf.blk, BLOCK_OP_TYPE_REPLACE, s->blocker); + blk_op_unblock(conf->conf.blk, BLOCK_OP_TYPE_DEVICE_IO, s->blocker); *dataplane = s; } diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c index e242fef..5e15fa6 100644 --- a/hw/scsi/virtio-scsi.c +++ b/hw/scsi/virtio-scsi.c @@ -772,6 +772,7 @@ static void virtio_scsi_hotplug(HotplugHandler *hotplug_dev, DeviceState *dev, return; } blk_op_block_all(sd->conf.blk, s->blocker); + blk_op_unblock(sd->conf.blk, BLOCK_OP_TYPE_DEVICE_IO, s->blocker); aio_context_acquire(s->ctx); blk_set_aio_context(sd->conf.blk, s->ctx); aio_context_release(s->ctx); diff --git a/include/block/block.h b/include/block/block.h index 7d1a717..906fb31 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -159,6 +159,7 @@ typedef enum BlockOpType { BLOCK_OP_TYPE_RESIZE, BLOCK_OP_TYPE_STREAM, BLOCK_OP_TYPE_REPLACE, + BLOCK_OP_TYPE_DEVICE_IO, BLOCK_OP_TYPE_MAX, } BlockOpType; diff --git a/migration/block.c b/migration/block.c index ddb59cc..b833bac 100644 --- a/migration/block.c +++ b/migration/block.c @@ -379,6 +379,7 @@ static void init_blk_migration(QEMUFile *f) alloc_aio_bitmap(bmds); error_setg(&bmds->blocker, "block device is in use by migration"); bdrv_op_block_all(bs, bmds->blocker); + bdrv_op_unblock(bs, BLOCK_OP_TYPE_DEVICE_IO, bmds->blocker); bdrv_ref(bs); block_mig_state.total_sector_sum += sectors;