[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v5 31/31] block.c: assertions to the block layer permissions API
From: |
Emanuele Giuseppe Esposito |
Subject: |
[PATCH v5 31/31] block.c: assertions to the block layer permissions API |
Date: |
Wed, 24 Nov 2021 01:44:18 -0500 |
Now that we "covered" the three main cases where the
permission API was being used under BQL (fuse,
amend and invalidate_cache), we can safely assert for
the permission functions implemented in block.c
Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
---
block.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/block.c b/block.c
index 805974676b..6056ec4bc5 100644
--- a/block.c
+++ b/block.c
@@ -2138,6 +2138,7 @@ static bool bdrv_a_allow_b(BdrvChild *a, BdrvChild *b,
Error **errp)
assert(a->bs);
assert(a->bs == b->bs);
+ assert(qemu_in_main_thread());
if ((b->perm & a->shared_perm) == b->perm) {
return true;
@@ -2161,6 +2162,7 @@ static bool bdrv_a_allow_b(BdrvChild *a, BdrvChild *b,
Error **errp)
static bool bdrv_parent_perms_conflict(BlockDriverState *bs, Error **errp)
{
BdrvChild *a, *b;
+ assert(qemu_in_main_thread());
/*
* During the loop we'll look at each pair twice. That's correct because
@@ -2245,6 +2247,8 @@ static void bdrv_child_set_perm_abort(void *opaque)
{
BdrvChildSetPermState *s = opaque;
+ assert(qemu_in_main_thread());
+
s->child->perm = s->old_perm;
s->child->shared_perm = s->old_shared_perm;
}
@@ -2258,6 +2262,7 @@ static void bdrv_child_set_perm(BdrvChild *c, uint64_t
perm,
uint64_t shared, Transaction *tran)
{
BdrvChildSetPermState *s = g_new(BdrvChildSetPermState, 1);
+ assert(qemu_in_main_thread());
*s = (BdrvChildSetPermState) {
.child = c,
@@ -2442,6 +2447,7 @@ static int bdrv_node_refresh_perm(BlockDriverState *bs,
BlockReopenQueue *q,
BdrvChild *c;
int ret;
uint64_t cumulative_perms, cumulative_shared_perms;
+ assert(qemu_in_main_thread());
bdrv_get_cumulative_perm(bs, &cumulative_perms, &cumulative_shared_perms);
@@ -2510,6 +2516,7 @@ static int bdrv_list_refresh_perms(GSList *list,
BlockReopenQueue *q,
{
int ret;
BlockDriverState *bs;
+ assert(qemu_in_main_thread());
for ( ; list; list = list->next) {
bs = list->data;
@@ -2582,6 +2589,7 @@ static int bdrv_refresh_perms(BlockDriverState *bs, Error
**errp)
int ret;
Transaction *tran = tran_new();
g_autoptr(GSList) list = bdrv_topological_dfs(NULL, NULL, bs);
+ assert(qemu_in_main_thread());
ret = bdrv_list_refresh_perms(list, NULL, tran, errp);
tran_finalize(tran, ret);
@@ -2648,6 +2656,7 @@ static void bdrv_filter_default_perms(BlockDriverState
*bs, BdrvChild *c,
uint64_t perm, uint64_t shared,
uint64_t *nperm, uint64_t *nshared)
{
+ assert(qemu_in_main_thread());
*nperm = perm & DEFAULT_PERM_PASSTHROUGH;
*nshared = (shared & DEFAULT_PERM_PASSTHROUGH) | DEFAULT_PERM_UNCHANGED;
}
@@ -2659,6 +2668,7 @@ static void bdrv_default_perms_for_cow(BlockDriverState
*bs, BdrvChild *c,
uint64_t *nperm, uint64_t *nshared)
{
assert(role & BDRV_CHILD_COW);
+ assert(qemu_in_main_thread());
/*
* We want consistent read from backing files if the parent needs it.
@@ -2696,6 +2706,7 @@ static void
bdrv_default_perms_for_storage(BlockDriverState *bs, BdrvChild *c,
{
int flags;
+ assert(qemu_in_main_thread());
assert(role & (BDRV_CHILD_METADATA | BDRV_CHILD_DATA));
flags = bdrv_reopen_get_flags(reopen_queue, bs);
@@ -6094,6 +6105,7 @@ static void xdbg_graph_add_edge(XDbgBlockGraphConstructor
*gr, void *parent,
{
BlockPermission qapi_perm;
XDbgBlockGraphEdge *edge;
+ assert(qemu_in_main_thread());
edge = g_new0(XDbgBlockGraphEdge, 1);
--
2.27.0
- [PATCH v5 22/31] block_int-common.h: assertion in the callers of BlockDriver function pointers, (continued)
- [PATCH v5 22/31] block_int-common.h: assertion in the callers of BlockDriver function pointers, Emanuele Giuseppe Esposito, 2021/11/24
- [PATCH v5 24/31] block_int-common.h: assertions in the callers of BdrvChildClass function pointers, Emanuele Giuseppe Esposito, 2021/11/24
- [PATCH v5 23/31] block_int-common.h: split function pointers in BdrvChildClass, Emanuele Giuseppe Esposito, 2021/11/24
- [PATCH v5 20/31] block/coroutines: I/O API, Emanuele Giuseppe Esposito, 2021/11/24
- [PATCH v5 26/31] job.h: split function pointers in JobDriver, Emanuele Giuseppe Esposito, 2021/11/24
- [PATCH v5 21/31] block_int-common.h: split function pointers in BlockDriver, Emanuele Giuseppe Esposito, 2021/11/24
- [PATCH v5 25/31] block-backend-common.h: split function pointers in BlockDevOps, Emanuele Giuseppe Esposito, 2021/11/24
- [PATCH v5 27/31] job.h: assertions in the callers of JobDriver funcion pointers, Emanuele Giuseppe Esposito, 2021/11/24
- [PATCH v5 28/31] block.c: assert BQL lock held in bdrv_co_invalidate_cache, Emanuele Giuseppe Esposito, 2021/11/24
- [PATCH v5 30/31] crypto: delegate permission functions to JobDriver .pre_run, Emanuele Giuseppe Esposito, 2021/11/24
- [PATCH v5 31/31] block.c: assertions to the block layer permissions API,
Emanuele Giuseppe Esposito <=
- [PATCH v5 29/31] jobs: introduce pre_run function in JobDriver, Emanuele Giuseppe Esposito, 2021/11/24
- Re: [PATCH v5 00/31] block layer: split block APIs in global state and I/O, Stefan Hajnoczi, 2021/11/29