From 18d530eed9ea334b2235a1a7ae5801ee23c57290 Mon Sep 17 00:00:00 2001 From: Stefan Hajnoczi Date: Fri, 17 Nov 2017 11:19:03 +0100 Subject: [PATCH 04/15] block: all I/O should be completed before removing throttle timers. RH-Author: Stefan Hajnoczi Message-id: <20171117111908.8815-5-stefanha@redhat.com> Patchwork-id: 77738 O-Subject: [RHV7.5 qemu-kvm-rhev PATCH 4/9] block: all I/O should be completed before removing throttle timers. Bugzilla: 1492295 RH-Acked-by: John Snow RH-Acked-by: Laurent Vivier RH-Acked-by: Thomas Huth From: Zhengui In blk_remove_bs, all I/O should be completed before removing throttle timers. If there has inflight I/O, removing throttle timers here will cause the inflight I/O never return. This patch add bdrv_drained_begin before throttle_timers_detach_aio_context to let all I/O completed before removing throttle timers. [Moved declaration of bs as suggested by Alberto Garcia . --Stefan] Signed-off-by: Zhengui Reviewed-by: Stefan Hajnoczi Reviewed-by: Alberto Garcia Message-id: 1508564040-120700-1-git-send-email-lizhengui@huawei.com Signed-off-by: Stefan Hajnoczi (cherry picked from commit 632a77354317df32c7ff2d23424f0559c23fee51) Signed-off-by: Stefan Hajnoczi Signed-off-by: Miroslav Rezanina --- block/block-backend.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/block/block-backend.c b/block/block-backend.c index 6826476..bfb3e84 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -655,12 +655,16 @@ BlockBackend *blk_by_public(BlockBackendPublic *public) */ void blk_remove_bs(BlockBackend *blk) { + BlockDriverState *bs; ThrottleTimers *tt; notifier_list_notify(&blk->remove_bs_notifiers, blk); if (blk->public.throttle_group_member.throttle_state) { tt = &blk->public.throttle_group_member.throttle_timers; + bs = blk_bs(blk); + bdrv_drained_begin(bs); throttle_timers_detach_aio_context(tt); + bdrv_drained_end(bs); } blk_update_root_state(blk); -- 1.8.3.1