From: sochin jiang <sochin.jiang@huawei.com>
To: berto@igalia.com, kwolf@redhat.com, jcody@redhat.com,
pbonzini@redhat.com, mreitz@redhat.com
Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org,
sochin.jiang@huawei.com, eric.fangyi@huawei.com,
subo7@huawei.com, xieyingtai@huawei.com, lina.lulina@huawei.com,
zhangshuai13@huawei.com, lizhengui@huawei.com
Subject: [Qemu-devel] [PATCH v2] throttle: fix a qemu crash problem when calling blk_delete
Date: Tue, 24 Oct 2017 11:33:51 +0800 [thread overview]
Message-ID: <1508816031-82709-1-git-send-email-sochin.jiang@huawei.com> (raw)
commit 7ca7f0 moves the throttling related part of the BDS life cycle
management to BlockBackend, adds call to
throttle_timers_detach_aio_context in blk_remove_bs. commit 1606e
remove a block device from its throttle group in blk_delete by calling
blk_io_limits_disable, this fix an easily reproducible qemu crash. But
delete a BB without a BDS inserted could easily cause a qemu crash too
by calling bdrv_drained_begin in blk_io_limits_disable. Say, a simply
drive_add and then a drive_del command.
This patch removes draining BDS by calling throttle_group_unregister_tgm
directly instead of blk_io_limits_disable, leaves draining operation to
blk_remove_bs in case that there is no BDS inserted. Futhermore, make sure
throttle timers are initialized or attached before throttle_timers_destroy
is called in throttle_group_unregister_tgm.
Signed-off-by: sochin jiang <sochin.jiang@huawei.com>
---
block/block-backend.c | 2 +-
block/throttle-groups.c | 4 +++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/block/block-backend.c b/block/block-backend.c
index 45d9101..39c7cca 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -341,7 +341,7 @@ static void blk_delete(BlockBackend *blk)
assert(!blk->name);
assert(!blk->dev);
if (blk->public.throttle_group_member.throttle_state) {
- blk_io_limits_disable(blk);
+ throttle_group_unregister_tgm(&blk->public.throttle_group_member);
}
if (blk->root) {
blk_remove_bs(blk);
diff --git a/block/throttle-groups.c b/block/throttle-groups.c
index b291a88..c5f9af3 100644
--- a/block/throttle-groups.c
+++ b/block/throttle-groups.c
@@ -576,7 +576,9 @@ void throttle_group_unregister_tgm(ThrottleGroupMember *tgm)
/* remove the current tgm from the list */
QLIST_REMOVE(tgm, round_robin);
- throttle_timers_destroy(&tgm->throttle_timers);
+ if (throttle_timers_are_initialized(&tgm->throttle_timers)) {
+ throttle_timers_destroy(&tgm->throttle_timers);
+ }
qemu_mutex_unlock(&tg->lock);
throttle_group_unref(&tg->ts);
--
1.8.3.1
next reply other threads:[~2017-10-24 4:21 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-24 3:33 sochin jiang [this message]
2017-10-25 8:40 ` [Qemu-devel] [PATCH v2] throttle: fix a qemu crash problem when calling blk_delete Alberto Garcia
2017-11-03 14:26 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2017-11-07 20:11 ` Manos Pitsidianakis
2017-11-09 17:12 ` Stefan Hajnoczi
2017-11-10 13:42 ` Alberto Garcia
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=1508816031-82709-1-git-send-email-sochin.jiang@huawei.com \
--to=sochin.jiang@huawei.com \
--cc=berto@igalia.com \
--cc=eric.fangyi@huawei.com \
--cc=jcody@redhat.com \
--cc=kwolf@redhat.com \
--cc=lina.lulina@huawei.com \
--cc=lizhengui@huawei.com \
--cc=mreitz@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=subo7@huawei.com \
--cc=xieyingtai@huawei.com \
--cc=zhangshuai13@huawei.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).