qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Emanuele Giuseppe Esposito <eesposit@redhat.com>
To: qemu-block@nongnu.org
Cc: "Kevin Wolf" <kwolf@redhat.com>, "Fam Zheng" <fam@euphon.net>,
	"Vladimir Sementsov-Ogievskiy" <vsementsov@virtuozzo.com>,
	"Daniel P. Berrangé" <berrange@redhat.com>,
	"Juan Quintela" <quintela@redhat.com>,
	qemu-devel@nongnu.org, "John Snow" <jsnow@redhat.com>,
	"Emanuele Giuseppe Esposito" <eesposit@redhat.com>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"Markus Armbruster" <armbru@redhat.com>,
	"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
	"Eduardo Habkost" <eduardo@habkost.net>,
	"Hanna Reitz" <hreitz@redhat.com>,
	"Stefan Hajnoczi" <stefanha@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Eric Blake" <eblake@redhat.com>
Subject: [PATCH v7 10/31] block.c: assertions to the block layer permissions API
Date: Fri, 11 Feb 2022 09:51:32 -0500	[thread overview]
Message-ID: <20220211145153.2861415-11-eesposit@redhat.com> (raw)
In-Reply-To: <20220211145153.2861415-1-eesposit@redhat.com>

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 aa04a38457..2540ce3534 100644
--- a/block.c
+++ b/block.c
@@ -2109,6 +2109,7 @@ static bool bdrv_a_allow_b(BdrvChild *a, BdrvChild *b, Error **errp)
 
     assert(a->bs);
     assert(a->bs == b->bs);
+    GLOBAL_STATE_CODE();
 
     if ((b->perm & a->shared_perm) == b->perm) {
         return true;
@@ -2132,6 +2133,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;
+    GLOBAL_STATE_CODE();
 
     /*
      * During the loop we'll look at each pair twice. That's correct because
@@ -2213,6 +2215,8 @@ static void bdrv_child_set_perm_abort(void *opaque)
 {
     BdrvChildSetPermState *s = opaque;
 
+    GLOBAL_STATE_CODE();
+
     s->child->perm = s->old_perm;
     s->child->shared_perm = s->old_shared_perm;
 }
@@ -2226,6 +2230,7 @@ static void bdrv_child_set_perm(BdrvChild *c, uint64_t perm,
                                 uint64_t shared, Transaction *tran)
 {
     BdrvChildSetPermState *s = g_new(BdrvChildSetPermState, 1);
+    GLOBAL_STATE_CODE();
 
     *s = (BdrvChildSetPermState) {
         .child = c,
@@ -2405,6 +2410,7 @@ static int bdrv_node_refresh_perm(BlockDriverState *bs, BlockReopenQueue *q,
     BdrvChild *c;
     int ret;
     uint64_t cumulative_perms, cumulative_shared_perms;
+    GLOBAL_STATE_CODE();
 
     bdrv_get_cumulative_perm(bs, &cumulative_perms, &cumulative_shared_perms);
 
@@ -2473,6 +2479,7 @@ static int bdrv_list_refresh_perms(GSList *list, BlockReopenQueue *q,
 {
     int ret;
     BlockDriverState *bs;
+    GLOBAL_STATE_CODE();
 
     for ( ; list; list = list->next) {
         bs = list->data;
@@ -2540,6 +2547,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);
+    GLOBAL_STATE_CODE();
 
     ret = bdrv_list_refresh_perms(list, NULL, tran, errp);
     tran_finalize(tran, ret);
@@ -2602,6 +2610,7 @@ static void bdrv_filter_default_perms(BlockDriverState *bs, BdrvChild *c,
                                       uint64_t perm, uint64_t shared,
                                       uint64_t *nperm, uint64_t *nshared)
 {
+    GLOBAL_STATE_CODE();
     *nperm = perm & DEFAULT_PERM_PASSTHROUGH;
     *nshared = (shared & DEFAULT_PERM_PASSTHROUGH) | DEFAULT_PERM_UNCHANGED;
 }
@@ -2613,6 +2622,7 @@ static void bdrv_default_perms_for_cow(BlockDriverState *bs, BdrvChild *c,
                                        uint64_t *nperm, uint64_t *nshared)
 {
     assert(role & BDRV_CHILD_COW);
+    GLOBAL_STATE_CODE();
 
     /*
      * We want consistent read from backing files if the parent needs it.
@@ -2649,6 +2659,7 @@ static void bdrv_default_perms_for_storage(BlockDriverState *bs, BdrvChild *c,
 {
     int flags;
 
+    GLOBAL_STATE_CODE();
     assert(role & (BDRV_CHILD_METADATA | BDRV_CHILD_DATA));
 
     flags = bdrv_reopen_get_flags(reopen_queue, bs);
@@ -6026,6 +6037,7 @@ static void xdbg_graph_add_edge(XDbgBlockGraphConstructor *gr, void *parent,
 {
     BlockPermission qapi_perm;
     XDbgBlockGraphEdge *edge;
+    GLOBAL_STATE_CODE();
 
     edge = g_new0(XDbgBlockGraphEdge, 1);
 
-- 
2.31.1



  parent reply	other threads:[~2022-02-11 14:55 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-11 14:51 [PATCH v7 00/31] block layer: split block APIs in global state and I/O Emanuele Giuseppe Esposito
2022-02-11 14:51 ` [PATCH v7 01/31] main-loop.h: introduce qemu_in_main_thread() Emanuele Giuseppe Esposito
2022-02-11 14:51 ` [PATCH v7 02/31] main loop: macros to mark GS and I/O functions Emanuele Giuseppe Esposito
2022-03-01 11:29   ` Kevin Wolf
2022-02-11 14:51 ` [PATCH v7 03/31] include/block/block: split header into I/O and global state API Emanuele Giuseppe Esposito
2022-02-11 14:51 ` [PATCH v7 04/31] assertions for block " Emanuele Giuseppe Esposito
2022-02-11 14:51 ` [PATCH v7 05/31] IO_CODE and IO_OR_GS_CODE for block I/O API Emanuele Giuseppe Esposito
2022-02-11 14:51 ` [PATCH v7 06/31] block/export/fuse.c: allow writable exports to take RESIZE permission Emanuele Giuseppe Esposito
2022-02-11 14:51 ` [PATCH v7 07/31] include/sysemu/block-backend: split header into I/O and global state (GS) API Emanuele Giuseppe Esposito
2022-02-11 14:51 ` [PATCH v7 08/31] block/block-backend.c: assertions for block-backend Emanuele Giuseppe Esposito
2022-02-11 14:51 ` [PATCH v7 09/31] IO_CODE and IO_OR_GS_CODE for block-backend I/O API Emanuele Giuseppe Esposito
2022-02-11 14:51 ` Emanuele Giuseppe Esposito [this message]
2022-02-11 14:51 ` [PATCH v7 11/31] include/block/block_int: split header into I/O and global state API Emanuele Giuseppe Esposito
2022-02-11 14:51 ` [PATCH v7 12/31] assertions for block_int " Emanuele Giuseppe Esposito
2022-02-11 14:51 ` [PATCH v7 13/31] IO_CODE and IO_OR_GS_CODE for block_int I/O API Emanuele Giuseppe Esposito
2022-02-11 14:51 ` [PATCH v7 14/31] block: introduce assert_bdrv_graph_writable Emanuele Giuseppe Esposito
2022-02-11 14:51 ` [PATCH v7 15/31] include/block/blockjob_int.h: split header into I/O and GS API Emanuele Giuseppe Esposito
2022-02-11 14:51 ` [PATCH v7 16/31] GS and IO CODE macros for blockjob_int.h Emanuele Giuseppe Esposito
2022-02-11 14:51 ` [PATCH v7 17/31] block.c: add assertions to static functions Emanuele Giuseppe Esposito
2022-02-11 14:51 ` [PATCH v7 18/31] include/block/blockjob.h: global state API Emanuele Giuseppe Esposito
2022-02-11 14:51 ` [PATCH v7 19/31] assertions for blockjob.h " Emanuele Giuseppe Esposito
2022-02-11 14:51 ` [PATCH v7 20/31] include/sysemu/blockdev.h: " Emanuele Giuseppe Esposito
2022-02-11 14:51 ` [PATCH v7 21/31] assertions for blockdev.h " Emanuele Giuseppe Esposito
2022-02-11 14:51 ` [PATCH v7 22/31] include/block/snapshot: global state API + assertions Emanuele Giuseppe Esposito
2022-02-11 14:51 ` [PATCH v7 23/31] block/copy-before-write.h: " Emanuele Giuseppe Esposito
2022-02-11 14:51 ` [PATCH v7 24/31] block/coroutines: I/O and "I/O or GS" API Emanuele Giuseppe Esposito
2022-02-11 14:51 ` [PATCH v7 25/31] block_int-common.h: split function pointers in BlockDriver Emanuele Giuseppe Esposito
2022-02-11 14:51 ` [PATCH v7 26/31] block_int-common.h: assertions in the callers of BlockDriver function pointers Emanuele Giuseppe Esposito
2022-02-11 14:51 ` [PATCH v7 27/31] block_int-common.h: split function pointers in BdrvChildClass Emanuele Giuseppe Esposito
2022-02-11 14:51 ` [PATCH v7 28/31] block_int-common.h: assertions in the callers of BdrvChildClass function pointers Emanuele Giuseppe Esposito
2022-02-11 14:51 ` [PATCH v7 29/31] block-backend-common.h: split function pointers in BlockDevOps Emanuele Giuseppe Esposito
2022-02-11 14:51 ` [PATCH v7 30/31] job.h: split function pointers in JobDriver Emanuele Giuseppe Esposito
2022-02-11 14:51 ` [PATCH v7 31/31] job.h: assertions in the callers of JobDriver function pointers Emanuele Giuseppe Esposito
2022-03-01 16:08 ` [PATCH v7 00/31] block layer: split block APIs in global state and I/O Kevin Wolf
2022-03-03 12:06   ` Emanuele Giuseppe Esposito

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220211145153.2861415-11-eesposit@redhat.com \
    --to=eesposit@redhat.com \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=eblake@redhat.com \
    --cc=eduardo@habkost.net \
    --cc=fam@euphon.net \
    --cc=hreitz@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    --cc=richard.henderson@linaro.org \
    --cc=stefanha@redhat.com \
    --cc=vsementsov@virtuozzo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).