Commit 2d19629
block-backend: split blk_do_set_aio_context()
blk_set_aio_context() is not fully transactional because
blk_do_set_aio_context() updates blk->ctx outside the transaction. Most
of the time this goes unnoticed but a BlockDevOps.drained_end() callback
that invokes blk_get_aio_context() fails assert(ctx == blk->ctx). This
happens because blk->ctx is only assigned after
BlockDevOps.drained_end() is called and we're in an intermediate state
where BlockDrvierState nodes already have the new context and the
BlockBackend still has the old context.
Making blk_set_aio_context() fully transactional solves this assertion
failure because the BlockBackend's context is updated as part of the
transaction (before BlockDevOps.drained_end() is called).
Split blk_do_set_aio_context() in order to solve this assertion failure.
This helper function actually serves two different purposes:
1. It drives blk_set_aio_context().
2. It responds to BdrvChildClass->change_aio_ctx().
Get rid of the helper function. Do #1 inside blk_set_aio_context() and
do qemu#2 inside blk_root_set_aio_ctx_commit(). This simplifies the code.
The only drawback of the fully transactional approach is that
blk_set_aio_context() must contend with blk_root_set_aio_ctx_commit()
being invoked as part of the AioContext change propagation. This can be
solved by temporarily setting blk->allow_aio_context_change to true.
Future patches call blk_get_aio_context() from
BlockDevOps->drained_end(), so this patch will become necessary.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-Id: <20230516190238.8401-2-stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>1 parent 80e7faa commit 2d19629
1 file changed
+23
-38
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2433 | 2433 | | |
2434 | 2434 | | |
2435 | 2435 | | |
2436 | | - | |
2437 | | - | |
| 2436 | + | |
| 2437 | + | |
2438 | 2438 | | |
| 2439 | + | |
2439 | 2440 | | |
2440 | | - | |
2441 | 2441 | | |
2442 | 2442 | | |
2443 | | - | |
2444 | | - | |
2445 | | - | |
2446 | | - | |
2447 | | - | |
2448 | | - | |
2449 | | - | |
2450 | | - | |
2451 | | - | |
2452 | | - | |
2453 | | - | |
2454 | | - | |
2455 | | - | |
2456 | | - | |
2457 | | - | |
2458 | | - | |
2459 | | - | |
2460 | | - | |
2461 | | - | |
2462 | | - | |
2463 | | - | |
2464 | | - | |
2465 | | - | |
2466 | | - | |
2467 | | - | |
| 2443 | + | |
2468 | 2444 | | |
2469 | | - | |
2470 | | - | |
| 2445 | + | |
2471 | 2446 | | |
| 2447 | + | |
2472 | 2448 | | |
2473 | 2449 | | |
2474 | | - | |
2475 | | - | |
| 2450 | + | |
2476 | 2451 | | |
2477 | | - | |
2478 | | - | |
2479 | | - | |
2480 | | - | |
2481 | | - | |
| 2452 | + | |
| 2453 | + | |
| 2454 | + | |
| 2455 | + | |
| 2456 | + | |
| 2457 | + | |
| 2458 | + | |
| 2459 | + | |
| 2460 | + | |
2482 | 2461 | | |
2483 | 2462 | | |
2484 | 2463 | | |
| |||
2490 | 2469 | | |
2491 | 2470 | | |
2492 | 2471 | | |
| 2472 | + | |
| 2473 | + | |
2493 | 2474 | | |
2494 | | - | |
| 2475 | + | |
| 2476 | + | |
| 2477 | + | |
| 2478 | + | |
| 2479 | + | |
2495 | 2480 | | |
2496 | 2481 | | |
2497 | 2482 | | |
| |||
0 commit comments