From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, berto@igalia.com, qemu-devel@nongnu.org,
jcody@redhat.com, armbru@redhat.com, mreitz@redhat.com,
stefanha@redhat.com
Subject: [Qemu-devel] [PATCH v2 16/16] block: Remove bdrv_swap()
Date: Thu, 1 Oct 2015 15:13:34 +0200 [thread overview]
Message-ID: <1443705214-9304-17-git-send-email-kwolf@redhat.com> (raw)
In-Reply-To: <1443705214-9304-1-git-send-email-kwolf@redhat.com>
bdrv_swap() is unused now. Remove it and all functions that have
no other users than bdrv_swap(). In particular, this removes the
.bdrv_rebind callbacks from block drivers.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Alberto Garcia <berto@igalia.com>
---
block.c | 155 +---------------------------------------------
block/qed.c | 7 ---
block/vvfat.c | 7 ---
include/block/block_int.h | 1 -
include/qemu/queue.h | 6 --
5 files changed, 1 insertion(+), 175 deletions(-)
diff --git a/block.c b/block.c
index 5e0ad24..62848ca 100644
--- a/block.c
+++ b/block.c
@@ -1981,15 +1981,7 @@ void bdrv_make_anon(BlockDriverState *bs)
bs->node_name[0] = '\0';
}
-static void bdrv_rebind(BlockDriverState *bs)
-{
- if (bs->drv && bs->drv->bdrv_rebind) {
- bs->drv->bdrv_rebind(bs);
- }
-}
-
-/* Fields that need to stay with the top-level BDS, no matter whether the
- * address of the top-level BDS stays the same or not. */
+/* Fields that need to stay with the top-level BDS */
static void bdrv_move_feature_fields(BlockDriverState *bs_dest,
BlockDriverState *bs_src)
{
@@ -2013,151 +2005,6 @@ static void bdrv_move_feature_fields(BlockDriverState *bs_dest,
bs_dest->dirty_bitmaps = bs_src->dirty_bitmaps;
}
-/* Fields that only need to be swapped if the contents of BDSes is swapped
- * rather than pointers being changed in the parents, and throttling fields
- * because only bdrv_swap() messes with internals of throttling. */
-static void bdrv_move_reference_fields(BlockDriverState *bs_dest,
- BlockDriverState *bs_src)
-{
- /* i/o throttled req */
- bs_dest->throttle_state = bs_src->throttle_state,
- bs_dest->io_limits_enabled = bs_src->io_limits_enabled;
- bs_dest->pending_reqs[0] = bs_src->pending_reqs[0];
- bs_dest->pending_reqs[1] = bs_src->pending_reqs[1];
- bs_dest->throttled_reqs[0] = bs_src->throttled_reqs[0];
- bs_dest->throttled_reqs[1] = bs_src->throttled_reqs[1];
- memcpy(&bs_dest->round_robin,
- &bs_src->round_robin,
- sizeof(bs_dest->round_robin));
- memcpy(&bs_dest->throttle_timers,
- &bs_src->throttle_timers,
- sizeof(ThrottleTimers));
-
- /* reference count */
- bs_dest->refcnt = bs_src->refcnt;
-
- /* job */
- bs_dest->job = bs_src->job;
-
- /* keep the same entry in bdrv_states */
- bs_dest->device_list = bs_src->device_list;
- bs_dest->blk = bs_src->blk;
- bs_dest->parents = bs_src->parents;
-
- memcpy(bs_dest->op_blockers, bs_src->op_blockers,
- sizeof(bs_dest->op_blockers));
-}
-
-/*
- * Swap bs contents for two image chains while they are live,
- * while keeping required fields on the BlockDriverState that is
- * actually attached to a device.
- *
- * This will modify the BlockDriverState fields, and swap contents
- * between bs_new and bs_old. Both bs_new and bs_old are modified.
- *
- * bs_new must not be attached to a BlockBackend.
- *
- * This function does not create any image files.
- */
-void bdrv_swap(BlockDriverState *bs_new, BlockDriverState *bs_old)
-{
- BlockDriverState tmp;
- BdrvChild *child;
-
- bdrv_drain(bs_new);
- bdrv_drain(bs_old);
-
- /* The code needs to swap the node_name but simply swapping node_list won't
- * work so first remove the nodes from the graph list, do the swap then
- * insert them back if needed.
- */
- if (bs_new->node_name[0] != '\0') {
- QTAILQ_REMOVE(&graph_bdrv_states, bs_new, node_list);
- }
- if (bs_old->node_name[0] != '\0') {
- QTAILQ_REMOVE(&graph_bdrv_states, bs_old, node_list);
- }
-
- /* If the BlockDriverState is part of a throttling group acquire
- * its lock since we're going to mess with the protected fields.
- * Otherwise there's no need to worry since no one else can touch
- * them. */
- if (bs_old->throttle_state) {
- throttle_group_lock(bs_old);
- }
-
- /* bs_new must be unattached and shouldn't have anything fancy enabled */
- assert(!bs_new->blk);
- assert(QLIST_EMPTY(&bs_new->dirty_bitmaps));
- assert(bs_new->job == NULL);
- assert(bs_new->io_limits_enabled == false);
- assert(bs_new->throttle_state == NULL);
- assert(!throttle_timers_are_initialized(&bs_new->throttle_timers));
-
- tmp = *bs_new;
- *bs_new = *bs_old;
- *bs_old = tmp;
-
- /* there are some fields that should not be swapped, move them back */
- bdrv_move_feature_fields(&tmp, bs_old);
- bdrv_move_feature_fields(bs_old, bs_new);
- bdrv_move_feature_fields(bs_new, &tmp);
-
- bdrv_move_reference_fields(&tmp, bs_old);
- bdrv_move_reference_fields(bs_old, bs_new);
- bdrv_move_reference_fields(bs_new, &tmp);
-
- /* bs_new must remain unattached */
- assert(!bs_new->blk);
-
- /* Check a few fields that should remain attached to the device */
- assert(bs_new->job == NULL);
- assert(bs_new->io_limits_enabled == false);
- assert(bs_new->throttle_state == NULL);
- assert(!throttle_timers_are_initialized(&bs_new->throttle_timers));
-
- /* Release the ThrottleGroup lock */
- if (bs_old->throttle_state) {
- throttle_group_unlock(bs_old);
- }
-
- /* insert the nodes back into the graph node list if needed */
- if (bs_new->node_name[0] != '\0') {
- QTAILQ_INSERT_TAIL(&graph_bdrv_states, bs_new, node_list);
- }
- if (bs_old->node_name[0] != '\0') {
- QTAILQ_INSERT_TAIL(&graph_bdrv_states, bs_old, node_list);
- }
-
- /*
- * Update lh_first.le_prev for non-empty lists.
- *
- * The head of the op blocker list doesn't change because it is moved back
- * in bdrv_move_feature_fields().
- */
- assert(QLIST_EMPTY(&bs_old->tracked_requests));
- assert(QLIST_EMPTY(&bs_new->tracked_requests));
-
- QLIST_FIX_HEAD_PTR(&bs_new->children, next);
- QLIST_FIX_HEAD_PTR(&bs_old->children, next);
-
- /* Update references in bs->opaque and children */
- QLIST_FOREACH(child, &bs_old->children, next) {
- if (child->bs->inherits_from == bs_new) {
- child->bs->inherits_from = bs_old;
- }
- }
- QLIST_FOREACH(child, &bs_new->children, next) {
- if (child->bs->inherits_from == bs_old) {
- child->bs->inherits_from = bs_new;
- }
- }
-
- bdrv_rebind(bs_new);
- bdrv_rebind(bs_old);
-}
-
static void change_parent_backing_link(BlockDriverState *from,
BlockDriverState *to)
{
diff --git a/block/qed.c b/block/qed.c
index 0af81dc..5ea05d4 100644
--- a/block/qed.c
+++ b/block/qed.c
@@ -354,12 +354,6 @@ static void qed_cancel_need_check_timer(BDRVQEDState *s)
timer_del(s->need_check_timer);
}
-static void bdrv_qed_rebind(BlockDriverState *bs)
-{
- BDRVQEDState *s = bs->opaque;
- s->bs = bs;
-}
-
static void bdrv_qed_detach_aio_context(BlockDriverState *bs)
{
BDRVQEDState *s = bs->opaque;
@@ -1664,7 +1658,6 @@ static BlockDriver bdrv_qed = {
.supports_backing = true,
.bdrv_probe = bdrv_qed_probe,
- .bdrv_rebind = bdrv_qed_rebind,
.bdrv_open = bdrv_qed_open,
.bdrv_close = bdrv_qed_close,
.bdrv_reopen_prepare = bdrv_qed_reopen_prepare,
diff --git a/block/vvfat.c b/block/vvfat.c
index b41055a..b184eca 100644
--- a/block/vvfat.c
+++ b/block/vvfat.c
@@ -985,12 +985,6 @@ static BDRVVVFATState *vvv = NULL;
static int enable_write_target(BDRVVVFATState *s, Error **errp);
static int is_consistent(BDRVVVFATState *s);
-static void vvfat_rebind(BlockDriverState *bs)
-{
- BDRVVVFATState *s = bs->opaque;
- s->bs = bs;
-}
-
static QemuOptsList runtime_opts = {
.name = "vvfat",
.head = QTAILQ_HEAD_INITIALIZER(runtime_opts.head),
@@ -3012,7 +3006,6 @@ static BlockDriver bdrv_vvfat = {
.bdrv_parse_filename = vvfat_parse_filename,
.bdrv_file_open = vvfat_open,
.bdrv_close = vvfat_close,
- .bdrv_rebind = vvfat_rebind,
.bdrv_read = vvfat_co_read,
.bdrv_write = vvfat_co_write,
diff --git a/include/block/block_int.h b/include/block/block_int.h
index 52ea7c0..c0e6513 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -122,7 +122,6 @@ struct BlockDriver {
int (*bdrv_write)(BlockDriverState *bs, int64_t sector_num,
const uint8_t *buf, int nb_sectors);
void (*bdrv_close)(BlockDriverState *bs);
- void (*bdrv_rebind)(BlockDriverState *bs);
int (*bdrv_create)(const char *filename, QemuOpts *opts, Error **errp);
int (*bdrv_set_key)(BlockDriverState *bs, const char *key);
int (*bdrv_make_empty)(BlockDriverState *bs);
diff --git a/include/qemu/queue.h b/include/qemu/queue.h
index a8d3cb8..f781aa2 100644
--- a/include/qemu/queue.h
+++ b/include/qemu/queue.h
@@ -117,12 +117,6 @@ struct { \
} \
} while (/*CONSTCOND*/0)
-#define QLIST_FIX_HEAD_PTR(head, field) do { \
- if ((head)->lh_first != NULL) { \
- (head)->lh_first->field.le_prev = &(head)->lh_first; \
- } \
-} while (/*CONSTCOND*/0)
-
#define QLIST_INSERT_AFTER(listelm, elm, field) do { \
if (((elm)->field.le_next = (listelm)->field.le_next) != NULL) \
(listelm)->field.le_next->field.le_prev = \
--
1.8.3.1
next prev parent reply other threads:[~2015-10-01 13:14 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-01 13:13 [Qemu-devel] [PATCH v2 00/16] block: Get rid of bdrv_swap() Kevin Wolf
2015-10-01 13:13 ` [Qemu-devel] [PATCH v2 01/16] block: Introduce BDS.file_child Kevin Wolf
2015-10-01 13:13 ` [Qemu-devel] [PATCH v2 02/16] vmdk: Use BdrvChild instead of BDS for references to extents Kevin Wolf
2015-10-01 13:13 ` [Qemu-devel] [PATCH v2 03/16] blkverify: Convert s->test_file to BdrvChild Kevin Wolf
2015-10-05 12:07 ` Alberto Garcia
2015-10-01 13:13 ` [Qemu-devel] [PATCH v2 04/16] quorum: Convert " Kevin Wolf
2015-10-07 18:16 ` Max Reitz
2015-10-01 13:13 ` [Qemu-devel] [PATCH v2 05/16] block: Convert bs->file " Kevin Wolf
2015-10-02 17:06 ` Max Reitz
2015-10-05 12:31 ` Alberto Garcia
2015-10-08 10:23 ` Fam Zheng
2015-10-09 11:34 ` Kevin Wolf
2015-10-01 13:13 ` [Qemu-devel] [PATCH v2 06/16] block: Remove bdrv_open_image() Kevin Wolf
2015-10-01 13:13 ` [Qemu-devel] [PATCH v2 07/16] block: Convert bs->backing_hd to BdrvChild Kevin Wolf
2015-10-02 17:14 ` Max Reitz
2015-10-05 12:59 ` Alberto Garcia
2015-10-09 1:39 ` Fam Zheng
2015-10-09 11:36 ` Kevin Wolf
2015-10-01 13:13 ` [Qemu-devel] [PATCH v2 08/16] block: Manage backing file references in bdrv_set_backing_hd() Kevin Wolf
2015-10-02 17:18 ` Max Reitz
2015-10-05 13:31 ` Alberto Garcia
2015-10-09 1:49 ` Fam Zheng
2015-10-01 13:13 ` [Qemu-devel] [PATCH v2 09/16] block: Split bdrv_move_feature_fields() Kevin Wolf
2015-10-01 13:13 ` [Qemu-devel] [PATCH v2 10/16] block/io: Make bdrv_requests_pending() public Kevin Wolf
2015-10-01 13:13 ` [Qemu-devel] [PATCH v2 11/16] block-backend: Add blk_set_bs() Kevin Wolf
2015-10-02 17:21 ` Max Reitz
2015-10-05 13:33 ` Alberto Garcia
2015-10-01 13:13 ` [Qemu-devel] [PATCH v2 12/16] block: Introduce parents list Kevin Wolf
2015-10-01 13:13 ` [Qemu-devel] [PATCH v2 13/16] block: Implement bdrv_append() without bdrv_swap() Kevin Wolf
2015-10-02 17:32 ` Max Reitz
2015-10-09 14:54 ` Stefan Hajnoczi
2015-10-01 13:13 ` [Qemu-devel] [PATCH v2 14/16] blockjob: Store device name at job creation Kevin Wolf
2015-10-02 17:44 ` Max Reitz
2015-10-06 13:10 ` Alberto Garcia
2015-10-01 13:13 ` [Qemu-devel] [PATCH v2 15/16] block: Add and use bdrv_replace_in_backing_chain() Kevin Wolf
2015-10-01 13:13 ` Kevin Wolf [this message]
2015-10-09 2:10 ` [Qemu-devel] [PATCH v2 00/16] block: Get rid of bdrv_swap() Fam Zheng
2015-10-09 14:56 ` Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1443705214-9304-17-git-send-email-kwolf@redhat.com \
--to=kwolf@redhat.com \
--cc=armbru@redhat.com \
--cc=berto@igalia.com \
--cc=jcody@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).