From: Stefan Hajnoczi <stefanha@gmail.com>
To: sochin jiang <sochin.jiang@huawei.com>
Cc: berto@igalia.com, kwolf@redhat.com, jcody@redhat.com,
pbonzini@redhat.com, mreitz@redhat.com, lina.lulina@huawei.com,
lizhengui@huawei.com, qemu-block@nongnu.org, subo7@huawei.com,
eric.fangyi@huawei.com, zhangshuai13@huawei.com,
qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [Qemu-block] [PATCH v2] throttle: fix a qemu crash problem when calling blk_delete
Date: Thu, 9 Nov 2017 17:12:10 +0000 [thread overview]
Message-ID: <20171109171210.GD25162@stefanha-x1.localdomain> (raw)
In-Reply-To: <1508816031-82709-1-git-send-email-sochin.jiang@huawei.com>
[-- Attachment #1: Type: text/plain, Size: 2398 bytes --]
On Tue, Oct 24, 2017 at 11:33:51AM +0800, sochin jiang wrote:
> 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);
The following assertions fail without the drain when there are pending
requests:
void throttle_group_unregister_tgm(ThrottleGroupMember *tgm)
{
ThrottleState *ts = tgm->throttle_state;
ThrottleGroup *tg = container_of(ts, ThrottleGroup, ts);
ThrottleGroupMember *token;
int i;
if (!ts) {
/* Discard already unregistered tgm */
return;
}
assert(tgm->pending_reqs[0] == 0 && tgm->pending_reqs[1] == 0);
assert(qemu_co_queue_empty(&tgm->throttled_reqs[0]));
assert(qemu_co_queue_empty(&tgm->throttled_reqs[1]));
A safer approach is making blk_io_limits_disable(blk) skip the draining
when blk_bs(blk) == NULL. That is the only case where we are 100% sure
that there are no pending requests.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]
next prev parent reply other threads:[~2017-11-09 17:12 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-24 3:33 [Qemu-devel] [PATCH v2] throttle: fix a qemu crash problem when calling blk_delete sochin jiang
2017-10-25 8:40 ` 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 [this message]
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=20171109171210.GD25162@stefanha-x1.localdomain \
--to=stefanha@gmail.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=sochin.jiang@huawei.com \
--cc=subo7@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).