All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, pbonzini@redhat.com, stefanha@redhat.com,
	eesposit@redhat.com, qemu-devel@nongnu.org
Subject: [PATCH 12/23] block: Mark bdrv_co_pwrite_sync() and callers GRAPH_RDLOCK
Date: Fri,  3 Feb 2023 16:21:51 +0100	[thread overview]
Message-ID: <20230203152202.49054-13-kwolf@redhat.com> (raw)
In-Reply-To: <20230203152202.49054-1-kwolf@redhat.com>

This adds GRAPH_RDLOCK annotations to declare that callers of
bdrv_co_pwrite_sync() need to hold a reader lock for the graph.

For some places, we know that they will hold the lock, but we don't have
the GRAPH_RDLOCK annotations yet. In this case, add assume_graph_lock()
with a FIXME comment. These places will be removed once everything is
properly annotated.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block/qcow2.h            | 2 +-
 include/block/block-io.h | 7 ++++---
 block/io.c               | 3 +--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/block/qcow2.h b/block/qcow2.h
index 7487bcfcf9..c59e33c01c 100644
--- a/block/qcow2.h
+++ b/block/qcow2.h
@@ -893,7 +893,7 @@ int qcow2_inc_refcounts_imrt(BlockDriverState *bs, BdrvCheckResult *res,
 int qcow2_change_refcount_order(BlockDriverState *bs, int refcount_order,
                                 BlockDriverAmendStatusCB *status_cb,
                                 void *cb_opaque, Error **errp);
-int coroutine_fn qcow2_shrink_reftable(BlockDriverState *bs);
+int coroutine_fn GRAPH_RDLOCK qcow2_shrink_reftable(BlockDriverState *bs);
 int64_t qcow2_get_last_cluster(BlockDriverState *bs, int64_t size);
 int coroutine_fn qcow2_detect_metadata_preallocation(BlockDriverState *bs);
 
diff --git a/include/block/block-io.h b/include/block/block-io.h
index ec26f07d60..bbe8a5659a 100644
--- a/include/block/block-io.h
+++ b/include/block/block-io.h
@@ -60,9 +60,10 @@ int co_wrapper_mixed_bdrv_rdlock
 bdrv_pwrite_sync(BdrvChild *child, int64_t offset, int64_t bytes,
                  const void *buf, BdrvRequestFlags flags);
 
-int coroutine_fn bdrv_co_pwrite_sync(BdrvChild *child, int64_t offset,
-                                     int64_t bytes, const void *buf,
-                                     BdrvRequestFlags flags);
+int coroutine_fn GRAPH_RDLOCK
+bdrv_co_pwrite_sync(BdrvChild *child, int64_t offset, int64_t bytes,
+                    const void *buf, BdrvRequestFlags flags);
+
 /*
  * Efficiently zero a region of the disk image.  Note that this is a regular
  * I/O request like read or write and should have a reasonable size.  This
diff --git a/block/io.c b/block/io.c
index 6f168a9a40..4ea19a37e6 100644
--- a/block/io.c
+++ b/block/io.c
@@ -933,8 +933,7 @@ int coroutine_fn bdrv_co_pwrite_sync(BdrvChild *child, int64_t offset,
 {
     int ret;
     IO_CODE();
-
-    assume_graph_lock(); /* FIXME */
+    assert_bdrv_graph_readable();
 
     ret = bdrv_co_pwrite(child, offset, bytes, buf, flags);
     if (ret < 0) {
-- 
2.38.1



  parent reply	other threads:[~2023-02-03 15:24 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-03 15:21 [PATCH 00/23] block: Lock the graph, part 2 (BlockDriver callbacks) Kevin Wolf
2023-02-03 15:21 ` [PATCH 01/23] block: Make bdrv_can_set_read_only() static Kevin Wolf
2023-02-22 16:27   ` Vladimir Sementsov-Ogievskiy
2023-02-03 15:21 ` [PATCH 02/23] mirror: Fix access of uninitialised fields during start Kevin Wolf
2023-02-22 16:32   ` Vladimir Sementsov-Ogievskiy
2023-02-03 15:21 ` [PATCH 03/23] block: Mark bdrv_co_truncate() and callers GRAPH_RDLOCK Kevin Wolf
2023-02-03 15:21 ` [PATCH 04/23] block: Mark bdrv_co_block_status() " Kevin Wolf
2023-02-03 15:21 ` [PATCH 05/23] block: Mark bdrv_co_ioctl() " Kevin Wolf
2023-02-03 15:21 ` [PATCH 06/23] block/qed: add missing graph rdlock in qed_need_check_timer_entry Kevin Wolf
2023-02-03 15:21 ` [PATCH 07/23] block: Mark bdrv_co_flush() and callers GRAPH_RDLOCK Kevin Wolf
2023-02-03 15:21 ` [PATCH 08/23] block: Mark bdrv_co_pdiscard() " Kevin Wolf
2023-02-03 15:21 ` [PATCH 09/23] block: Mark bdrv_co_pwrite_zeroes() " Kevin Wolf
2023-02-03 15:21 ` [PATCH 10/23] block: Mark read/write in block/io.c GRAPH_RDLOCK Kevin Wolf
2023-02-03 15:21 ` [PATCH 11/23] block: Mark public read/write functions GRAPH_RDLOCK Kevin Wolf
2023-02-03 15:21 ` Kevin Wolf [this message]
2023-02-03 15:21 ` [PATCH 13/23] block: Mark bdrv_co_do_pwrite_zeroes() GRAPH_RDLOCK Kevin Wolf
2023-02-03 15:21 ` [PATCH 14/23] block: Mark bdrv_co_copy_range() GRAPH_RDLOCK Kevin Wolf
2023-02-03 15:21 ` [PATCH 15/23] block: Mark preadv_snapshot/snapshot_block_status GRAPH_RDLOCK Kevin Wolf
2023-02-03 15:21 ` [PATCH 16/23] block: Mark bdrv_co_create() and callers GRAPH_RDLOCK Kevin Wolf
2023-02-03 15:21 ` [PATCH 17/23] block: Mark bdrv_co_io_(un)plug() " Kevin Wolf
2023-02-03 15:21 ` [PATCH 18/23] block: Mark bdrv_co_is_inserted() " Kevin Wolf
2023-02-03 15:21 ` [PATCH 19/23] block: Mark bdrv_co_eject/lock_medium() " Kevin Wolf
2023-02-03 15:21 ` [PATCH 20/23] block: Mark bdrv_(un)register_buf() GRAPH_RDLOCK Kevin Wolf
2023-02-03 15:22 ` [PATCH 21/23] block: Mark bdrv_co_delete_file() and callers GRAPH_RDLOCK Kevin Wolf
2023-02-03 15:22 ` [PATCH 22/23] block: Mark bdrv_*_dirty_bitmap() " Kevin Wolf
2023-02-03 15:22 ` [PATCH 23/23] block: Mark bdrv_co_refresh_total_sectors() " Kevin Wolf
2023-02-17 10:12 ` [PATCH 00/23] block: Lock the graph, part 2 (BlockDriver callbacks) Emanuele Giuseppe Esposito
2023-02-21 22:13 ` Stefan Hajnoczi
2023-02-23 11:48   ` Kevin Wolf
2023-02-23 12:46     ` Stefan Hajnoczi
2023-02-23 20:33     ` Stefan Hajnoczi

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=20230203152202.49054-13-kwolf@redhat.com \
    --to=kwolf@redhat.com \
    --cc=eesposit@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.