[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 09/11] block-backend: Update ctx immediately after root
From: |
Kevin Wolf |
Subject: |
[PULL 09/11] block-backend: Update ctx immediately after root |
Date: |
Fri, 11 Nov 2022 16:27:42 +0100 |
From: Hanna Reitz <hreitz@redhat.com>
blk_get_aio_context() asserts that blk->ctx is always equal to the root
BDS's context (if there is a root BDS). Therefore,
blk_do_set_aio_context() must update blk->ctx immediately after the root
BDS's context has changed.
Without this patch, the next patch would break iotest 238, because
bdrv_drained_begin() (called by blk_do_set_aio_context()) may then
invoke bdrv_child_get_parent_aio_context() on the root child, i.e.
blk_get_aio_context(). However, by this point, blk->ctx would not have
been updated and thus differ from the root node's context. This patch
fixes that.
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
Message-Id: <20221107151321.211175-3-hreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
block/block-backend.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/block/block-backend.c b/block/block-backend.c
index ed2f4b67a2..b48c91f4e1 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -2158,6 +2158,11 @@ static int blk_do_set_aio_context(BlockBackend *blk,
AioContext *new_context,
return ret;
}
}
+ /*
+ * Make blk->ctx consistent with the root node before we invoke any
+ * other operations like drain that might inquire blk->ctx
+ */
+ blk->ctx = new_context;
if (tgm->throttle_state) {
bdrv_drained_begin(bs);
throttle_group_detach_aio_context(tgm);
@@ -2166,9 +2171,10 @@ static int blk_do_set_aio_context(BlockBackend *blk,
AioContext *new_context,
}
bdrv_unref(bs);
+ } else {
+ blk->ctx = new_context;
}
- blk->ctx = new_context;
return 0;
}
--
2.38.1
- [PULL 00/11] Block layer patches, Kevin Wolf, 2022/11/11
- [PULL 01/11] block/mirror: Do not wait for active writes, Kevin Wolf, 2022/11/11
- [PULL 02/11] block/mirror: Drop mirror_wait_for_any_operation(), Kevin Wolf, 2022/11/11
- [PULL 03/11] block/mirror: Fix NULL s->job in active writes, Kevin Wolf, 2022/11/11
- [PULL 05/11] iotests/151: Test active requests on mirror start, Kevin Wolf, 2022/11/11
- [PULL 04/11] iotests/151: Test that active mirror progresses, Kevin Wolf, 2022/11/11
- [PULL 06/11] qapi/block-core: Fix BlockdevOptionsNvmeIoUring @path description, Kevin Wolf, 2022/11/11
- [PULL 08/11] block: Make bdrv_child_get_parent_aio_context I/O, Kevin Wolf, 2022/11/11
- [PULL 07/11] block/blkio: Set BlockDriver::has_variable_length to false, Kevin Wolf, 2022/11/11
- [PULL 10/11] block: Start/end drain on correct AioContext, Kevin Wolf, 2022/11/11
- [PULL 09/11] block-backend: Update ctx immediately after root,
Kevin Wolf <=
- [PULL 11/11] tests/stream-under-throttle: New test, Kevin Wolf, 2022/11/11
- Re: [PULL 00/11] Block layer patches, Stefan Hajnoczi, 2022/11/11