OSDN Git Service

block: drain from main loop thread in bdrv_co_yield_to_drain()
authorStefan Hajnoczi <stefanha@redhat.com>
Tue, 16 May 2023 19:02:28 +0000 (15:02 -0400)
committerKevin Wolf <kwolf@redhat.com>
Tue, 30 May 2023 15:32:02 +0000 (17:32 +0200)
commitab61335025b1274bd7042219203524045b23e0d3
tree209b7456df64d36079bc4eb6a43b8287a2436e33
parentff82b7835b2fbbd0a17d616f6929601a97a6497d
block: drain from main loop thread in bdrv_co_yield_to_drain()

For simplicity, always run BlockDevOps .drained_begin/end/poll()
callbacks in the main loop thread. This makes it easier to implement the
callbacks and avoids extra locks.

Move the function pointer declarations from the I/O Code section to the
Global State section for BlockDevOps, BdrvChildClass, and BlockDriver.

Narrow IO_OR_GS_CODE() to GLOBAL_STATE_CODE() where appropriate.

The test-bdrv-drain test case calls bdrv_drain() from an IOThread. This
is now only allowed from coroutine context, so update the test case to
run in a coroutine.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-Id: <20230516190238.8401-11-stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block/io.c
include/block/block_int-common.h
include/sysemu/block-backend-common.h
tests/unit/test-bdrv-drain.c