[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 13/20] block-gen: assert that bdrv_co_pwrite_{zeros/sync} is alwa
From: |
Emanuele Giuseppe Esposito |
Subject: |
[PATCH 13/20] block-gen: assert that bdrv_co_pwrite_{zeros/sync} is always called with graph rdlock taken |
Date: |
Wed, 16 Nov 2022 08:48:43 -0500 |
Already protected by bdrv_co_pwrite callers.
Protecting bdrv_co_do_pwrite_zeroes() implies that
BlockDriver->bdrv_co_pwrite_zeroes() is always called with
graph rdlock taken.
Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
---
block/io.c | 3 +++
include/block/block_int-common.h | 2 ++
2 files changed, 5 insertions(+)
diff --git a/block/io.c b/block/io.c
index 9280fb9f38..92c74648fb 100644
--- a/block/io.c
+++ b/block/io.c
@@ -904,6 +904,7 @@ int coroutine_fn bdrv_co_pwrite_sync(BdrvChild *child,
int64_t offset,
{
int ret;
IO_CODE();
+ assert_bdrv_graph_readable();
ret = bdrv_co_pwrite(child, offset, bytes, buf, flags);
if (ret < 0) {
@@ -1660,6 +1661,7 @@ static int coroutine_fn
bdrv_co_do_pwrite_zeroes(BlockDriverState *bs,
bs->bl.request_alignment);
int max_transfer = MIN_NON_ZERO(bs->bl.max_transfer, MAX_BOUNCE_BUFFER);
+ assert_bdrv_graph_readable();
bdrv_check_request(offset, bytes, &error_abort);
if (!drv) {
@@ -2124,6 +2126,7 @@ int coroutine_fn bdrv_co_pwrite_zeroes(BdrvChild *child,
int64_t offset,
{
IO_CODE();
trace_bdrv_co_pwrite_zeroes(child->bs, offset, bytes, flags);
+ assert_bdrv_graph_readable();
if (!(child->bs->open_flags & BDRV_O_UNMAP)) {
flags &= ~BDRV_REQ_MAY_UNMAP;
diff --git a/include/block/block_int-common.h b/include/block/block_int-common.h
index d44f825d95..e8d2e4b6c7 100644
--- a/include/block/block_int-common.h
+++ b/include/block/block_int-common.h
@@ -549,6 +549,8 @@ struct BlockDriver {
* would use a compact metadata representation to implement this. This
* function pointer may be NULL or return -ENOSUP and .bdrv_co_writev()
* will be called instead.
+ *
+ * Called with graph rdlock taken.
*/
int coroutine_fn (*bdrv_co_pwrite_zeroes)(BlockDriverState *bs,
int64_t offset, int64_t bytes, BdrvRequestFlags flags);
--
2.31.1
- [PATCH 00/20] Protect the block layer with a rwlock: part 1, Emanuele Giuseppe Esposito, 2022/11/16
- [PATCH 00/20] Protect the block layer with a rwlock: part 1, Emanuele Giuseppe Esposito, 2022/11/16
- [PATCH 00/20] Protect the block layer with a rwlock: part 1, Emanuele Giuseppe Esposito, 2022/11/16
- [PATCH 13/20] block-gen: assert that bdrv_co_pwrite_{zeros/sync} is always called with graph rdlock taken,
Emanuele Giuseppe Esposito <=
- [PATCH 05/20] block: remove unnecessary assert_bdrv_graph_writable(), Emanuele Giuseppe Esposito, 2022/11/16
- [PATCH 02/20] graph-lock: introduce BdrvGraphRWlock structure, Emanuele Giuseppe Esposito, 2022/11/16
- [PATCH 01/20] block: introduce a lock to protect graph operations, Emanuele Giuseppe Esposito, 2022/11/16
- [PATCH 11/20] block-gen: assert that bdrv_co_{check/invalidate_cache} are always called with graph rdlock taken, Emanuele Giuseppe Esposito, 2022/11/16
- [PATCH 10/20] block-gen: assert that {bdrv/blk}_co_truncate is always called with graph rdlock taken, Emanuele Giuseppe Esposito, 2022/11/16
- [PATCH 15/20] block-gen: assert that {bdrv/blk}_co_flush is always called with graph rdlock taken, Emanuele Giuseppe Esposito, 2022/11/16
- [PATCH 19/20] block-gen: assert that bdrv_co_ioctl is always called with graph rdlock taken, Emanuele Giuseppe Esposito, 2022/11/16
- [PATCH 12/20] block-gen: assert that bdrv_co_pwrite is always called with graph rdlock taken, Emanuele Giuseppe Esposito, 2022/11/16
- [PATCH 03/20] async: register/unregister aiocontext in graph lock list, Emanuele Giuseppe Esposito, 2022/11/16
- [PATCH 04/20] block.c: wrlock in bdrv_replace_child_noperm, Emanuele Giuseppe Esposito, 2022/11/16