From patchwork Wed Mar 16 18:54:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 8603391 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id F208AC0553 for ; Wed, 16 Mar 2016 18:59:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4246B20219 for ; Wed, 16 Mar 2016 18:59:29 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id 6E6FD2020F for ; Wed, 16 Mar 2016 18:59:28 +0000 (UTC) Received: from localhost ([::1]:58260 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1agGfH-0002aC-UN for patchwork-qemu-devel@patchwork.kernel.org; Wed, 16 Mar 2016 14:59:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37446) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1agGbU-0001f3-UA for qemu-devel@nongnu.org; Wed, 16 Mar 2016 14:55:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1agGbT-0005jn-QW for qemu-devel@nongnu.org; Wed, 16 Mar 2016 14:55:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42194) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1agGbR-0005iU-Fo; Wed, 16 Mar 2016 14:55:29 -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 0F77F64D08; Wed, 16 Mar 2016 18:55:29 +0000 (UTC) Received: from localhost (ovpn-116-135.ams2.redhat.com [10.36.116.135]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u2GItRYa004416 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 16 Mar 2016 14:55:28 -0400 From: Max Reitz To: qemu-block@nongnu.org Date: Wed, 16 Mar 2016 19:54:45 +0100 Message-Id: <1458154485-32536-18-git-send-email-mreitz@redhat.com> In-Reply-To: <1458154485-32536-1-git-send-email-mreitz@redhat.com> References: <1458154485-32536-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 16 Mar 2016 18:55:29 +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 Cc: Kevin Wolf , Markus Armbruster , qemu-devel@nongnu.org, Stefan Hajnoczi , Max Reitz Subject: [Qemu-devel] [PATCH v4 17/17] block: Remove bdrv_states list 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Max Reitz Reviewed-by: Kevin Wolf --- block.c | 31 +++---------------------------- blockdev.c | 7 ------- include/block/block.h | 1 - include/block/block_int.h | 4 ---- 4 files changed, 3 insertions(+), 40 deletions(-) diff --git a/block.c b/block.c index 5d848fb..c47f99d 100644 --- a/block.c +++ b/block.c @@ -55,8 +55,6 @@ #define NOT_DONE 0x7fffffff /* used while emulated sync operation in progress */ -struct BdrvStates bdrv_states = QTAILQ_HEAD_INITIALIZER(bdrv_states); - static QTAILQ_HEAD(, BlockDriverState) graph_bdrv_states = QTAILQ_HEAD_INITIALIZER(graph_bdrv_states); @@ -226,10 +224,7 @@ void bdrv_register(BlockDriver *bdrv) BlockDriverState *bdrv_new_root(void) { - BlockDriverState *bs = bdrv_new(); - - QTAILQ_INSERT_TAIL(&bdrv_states, bs, device_list); - return bs; + return bdrv_new(); } BlockDriverState *bdrv_new(void) @@ -2230,26 +2225,10 @@ void bdrv_close_all(void) } } -/* Note that bs->device_list.tqe_prev is initially null, - * and gets set to non-null by QTAILQ_INSERT_TAIL(). Establish - * the useful invariant "bs in bdrv_states iff bs->tqe_prev" by - * resetting it to null on remove. */ -void bdrv_device_remove(BlockDriverState *bs) -{ - QTAILQ_REMOVE(&bdrv_states, bs, device_list); - bs->device_list.tqe_prev = NULL; -} - -/* make a BlockDriverState anonymous by removing from bdrv_state and - * graph_bdrv_state list. - Also, NULL terminate the device_name to prevent double remove */ +/* make a BlockDriverState anonymous by removing from graph_bdrv_state list. + * Also, NULL terminate the device_name to prevent double remove */ void bdrv_make_anon(BlockDriverState *bs) { - /* Take care to remove bs from bdrv_states only when it's actually - * in it. */ - if (bs->device_list.tqe_prev) { - bdrv_device_remove(bs); - } if (bs->node_name[0] != '\0') { QTAILQ_REMOVE(&graph_bdrv_states, bs, node_list); } @@ -2286,10 +2265,6 @@ static void change_parent_backing_link(BlockDriverState *from, } if (from->blk) { blk_set_bs(from->blk, to); - if (!to->device_list.tqe_prev) { - QTAILQ_INSERT_BEFORE(from, to, device_list); - } - bdrv_device_remove(from); } } diff --git a/blockdev.c b/blockdev.c index a5df7e7..85dee57 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2426,11 +2426,6 @@ void qmp_x_blockdev_remove_medium(const char *device, Error **errp) goto out; } - /* This follows the convention established by bdrv_make_anon() */ - if (bs->device_list.tqe_prev) { - bdrv_device_remove(bs); - } - blk_remove_bs(blk); if (!blk_dev_has_tray(blk)) { @@ -2478,8 +2473,6 @@ static void qmp_blockdev_insert_anon_medium(const char *device, blk_insert_bs(blk, bs); - QTAILQ_INSERT_TAIL(&bdrv_states, bs, device_list); - if (!blk_dev_has_tray(blk)) { /* For tray-less devices, blockdev-close-tray is a no-op (or may not be * called at all); therefore, the medium needs to be pushed into the diff --git a/include/block/block.h b/include/block/block.h index 09272c3..ea8ed04 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -201,7 +201,6 @@ int bdrv_create(BlockDriver *drv, const char* filename, int bdrv_create_file(const char *filename, QemuOpts *opts, Error **errp); BlockDriverState *bdrv_new_root(void); BlockDriverState *bdrv_new(void); -void bdrv_device_remove(BlockDriverState *bs); void bdrv_make_anon(BlockDriverState *bs); void bdrv_append(BlockDriverState *bs_new, BlockDriverState *bs_top); void bdrv_replace_in_backing_chain(BlockDriverState *old, diff --git a/include/block/block_int.h b/include/block/block_int.h index dda5ba0..bbf617a 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -442,8 +442,6 @@ struct BlockDriverState { char node_name[32]; /* element of the list of named nodes building the graph */ QTAILQ_ENTRY(BlockDriverState) node_list; - /* element of the list of "drives" the guest sees */ - QTAILQ_ENTRY(BlockDriverState) device_list; /* element of the list of all BlockDriverStates (all_bdrv_states) */ QTAILQ_ENTRY(BlockDriverState) bs_list; /* element of the list of monitor-owned BDS */ @@ -501,8 +499,6 @@ extern BlockDriver bdrv_file; extern BlockDriver bdrv_raw; extern BlockDriver bdrv_qcow2; -extern QTAILQ_HEAD(BdrvStates, BlockDriverState) bdrv_states; - /** * bdrv_setup_io_funcs: *