]> Git Repo - qemu.git/commit - block/io.c
block: fix deadlock in bdrv_co_flush
authorEvgeny Yakovlev <[email protected]>
Wed, 17 Aug 2016 18:06:53 +0000 (21:06 +0300)
committerStefan Hajnoczi <[email protected]>
Thu, 18 Aug 2016 13:36:49 +0000 (14:36 +0100)
commitce83ee57f6fa69280a0330f1b49ef75b0ef0742a
treef88d10fc7bee32449e22c7b092d316c337535c53
parent5844365fe8e5e4598222d276d2af54fd45c7e3d3
block: fix deadlock in bdrv_co_flush

The following commit
    commit 3ff2f67a7c24183fcbcfe1332e5223ac6f96438c
    Author: Evgeny Yakovlev <[email protected]>
    Date:   Mon Jul 18 22:39:52 2016 +0300
    block: ignore flush requests when storage is clean
has introduced a regression.

There is a problem that it is still possible for 2 requests to execute
in non sequential fashion and sometimes this results in a deadlock
when bdrv_drain_one/all are called for BDS with such stalled requests.

1. Current flushed_gen and flush_started_gen is 1.
2. Request 1 enters bdrv_co_flush to with write_gen 1 (i.e. the same
   as flushed_gen). It gets past flushed_gen != flush_started_gen and
   sets flush_started_gen to 1 (again, the same it was before).
3. Request 1 yields somewhere before exiting bdrv_co_flush
4. Request 2 enters bdrv_co_flush with write_gen 2. It gets past
   flushed_gen != flush_started_gen and sets flush_started_gen to 2.
5. Request 2 runs to completion and sets flushed_gen to 2
6. Request 1 is resumed, runs to completion and sets flushed_gen to 1.
   However flush_started_gen is now 2.

From here on out flushed_gen is always != to flush_started_gen and all
further requests will wait on flush_queue. This change replaces
flush_started_gen with an explicitly tracked active flush request.

Signed-off-by: Evgeny Yakovlev <[email protected]>
Signed-off-by: Denis V. Lunev <[email protected]>
Message-id: 1471457214[email protected]
CC: Stefan Hajnoczi <[email protected]>
CC: Fam Zheng <[email protected]>
CC: Kevin Wolf <[email protected]>
CC: Max Reitz <[email protected]>
Signed-off-by: Stefan Hajnoczi <[email protected]>
block/io.c
include/block/block_int.h
This page took 0.025158 seconds and 4 git commands to generate.