]> git.proxmox.com Git - mirror_qemu.git/commitdiff
Merge tag 'for-upstream' of https://repo.or.cz/qemu/kevin into staging
authorStefan Hajnoczi <stefanha@redhat.com>
Thu, 21 Sep 2023 13:31:27 +0000 (09:31 -0400)
committerStefan Hajnoczi <stefanha@redhat.com>
Thu, 21 Sep 2023 13:31:28 +0000 (09:31 -0400)
Block layer patches

- Graph locking part 4 (node management)
- qemu-img map: report compressed data blocks
- block-backend: process I/O in the current AioContext

# -----BEGIN PGP SIGNATURE-----
#
# iQJFBAABCAAvFiEE3D3rFZqa+V09dFb+fwmycsiPL9YFAmULHnURHGt3b2xmQHJl
# ZGhhdC5jb20ACgkQfwmycsiPL9aB5hAAqH8To7WIUtg1rj1PY809ck78ghm18PKg
# TNdN7IbrXQghX5foh2VgPwVVl+JaW2CSrJYWQcAO6AbvFduNIi9iKzI6RT0xKXpb
# b8oQXS7zntFzwBv8ohOU5NSVJOgVmNP4h5qJIMmXgB9ZcLFG40zggVH2qQT7guUf
# 9MAc81kI/d5vvSHY0ZjdHjNOgwG4q1j8yytL7OFqWUfB8sXloUCA9lT7w4jIYD8L
# v2StUOLWB01Zts2o8SCNaFxuajs6wUee8b/DM1cyPyLy4KtOdXvLKhq2NlXpLo2i
# aZFr4PtizTVwrQZIJttA9jqM+QCsDOsiSat3BLNNsKUaCWHZB0rOGLCzMCtisyOo
# 4PzuL4UI21ik2zieO1qVM+Thqvw16kHtp6dD9pGk4X4ogGreGYEIxzBl79luR+AV
# NCRizoeFWTHKymS1tSoKrWT9ZNHcLmwemO6Tt1rMYk9jV3T4uY5e1NwxaUavEfsX
# f8dLfQjhNiySOoDknT1OSerBOVdTXURS2ri5H3GZxrxvJ4jOeFkn52C8r3YlZ3Wp
# Cr9LCUJZeXgwY+Q1JQ3D4VLY8aZ83txpw6XKEy0eTEv5wxkBj5LWhXx7hNb5F3lg
# bqaRYijVJn+P82wVxlftIzMfNeVBFHzFE90taPV5grJjr8lgrGBFmD7Puc97kfDX
# oTDBwRxJeew=
# =qTNA
# -----END PGP SIGNATURE-----
# gpg: Signature made Wed 20 Sep 2023 12:31:49 EDT
# gpg:                using RSA key DC3DEB159A9AF95D3D7456FE7F09B272C88F2FD6
# gpg:                issuer "kwolf@redhat.com"
# gpg: Good signature from "Kevin Wolf <kwolf@redhat.com>" [full]
# Primary key fingerprint: DC3D EB15 9A9A F95D 3D74  56FE 7F09 B272 C88F 2FD6

* tag 'for-upstream' of https://repo.or.cz/qemu/kevin: (28 commits)
  block: mark aio_poll as non-coroutine
  block-backend: process zoned requests in the current AioContext
  block-backend: process I/O in the current AioContext
  test-bdrv-drain: avoid race with BH in IOThread drain test
  block: remove AIOCBInfo->get_aio_context()
  qemu-img: map: report compressed data blocks
  block: add BDRV_BLOCK_COMPRESSED flag for bdrv_block_status()
  block: Mark bdrv_add/del_child() and caller GRAPH_WRLOCK
  block: Mark bdrv_unref_child() GRAPH_WRLOCK
  block: Mark bdrv_root_unref_child() GRAPH_WRLOCK
  block: Take graph rdlock in bdrv_change_aio_context()
  block: Take graph rdlock in bdrv_drop_intermediate()
  block: Mark bdrv_parent_cb_change_media() GRAPH_RDLOCK
  block: Mark bdrv_child_perm() GRAPH_RDLOCK
  block: Mark bdrv_get_cumulative_perm() and callers GRAPH_RDLOCK
  block: Mark bdrv_parent_perms_conflict() and callers GRAPH_RDLOCK
  block: Mark bdrv_attach_child() GRAPH_WRLOCK
  block: Call transaction callbacks with lock held
  block: Mark bdrv_attach_child_common() GRAPH_WRLOCK
  block: Mark bdrv_replace_child_tran() GRAPH_WRLOCK
  ...

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
1  2 
block/block-backend.c

diff --combined block/block-backend.c
index 47d360c97a3426f4fef5a4b6cb47e7a758db3295,9dbdbe55458dfb4d82d8679dc13b836eb1aa2cc3..efe2e7cbf848f09144cd38d50cbe8cfca30ed61a
@@@ -33,8 -33,6 +33,6 @@@
  
  #define NOT_DONE 0x7fffffff /* used while emulated sync operation in progress */
  
- static AioContext *blk_aiocb_get_aio_context(BlockAIOCB *acb);
  typedef struct BlockBackendAioNotifier {
      void (*attached_aio_context)(AioContext *new_context, void *opaque);
      void (*detach_aio_context)(void *opaque);
@@@ -103,7 -101,6 +101,6 @@@ typedef struct BlockBackendAIOCB 
  } BlockBackendAIOCB;
  
  static const AIOCBInfo block_backend_aiocb_info = {
-     .get_aio_context = blk_aiocb_get_aio_context,
      .aiocb_size = sizeof(BlockBackendAIOCB),
  };
  
@@@ -121,6 -118,10 +118,10 @@@ static QTAILQ_HEAD(, BlockBackend) bloc
  static QTAILQ_HEAD(, BlockBackend) monitor_block_backends =
      QTAILQ_HEAD_INITIALIZER(monitor_block_backends);
  
+ static int coroutine_mixed_fn GRAPH_RDLOCK
+ blk_set_perm_locked(BlockBackend *blk, uint64_t perm, uint64_t shared_perm,
+                     Error **errp);
  static void blk_root_inherit_options(BdrvChildRole role, bool parent_is_format,
                                       int *child_flags, QDict *child_options,
                                       int parent_flags, QDict *parent_options)
@@@ -186,7 -187,7 +187,7 @@@ static void blk_vm_state_changed(void *
   *
   * If an error is returned, the VM cannot be allowed to be resumed.
   */
- static void blk_root_activate(BdrvChild *child, Error **errp)
+ static void GRAPH_RDLOCK blk_root_activate(BdrvChild *child, Error **errp)
  {
      BlockBackend *blk = child->opaque;
      Error *local_err = NULL;
       */
      saved_shared_perm = blk->shared_perm;
  
-     blk_set_perm(blk, blk->perm, BLK_PERM_ALL, &local_err);
+     blk_set_perm_locked(blk, blk->perm, BLK_PERM_ALL, &local_err);
      if (local_err) {
          error_propagate(errp, local_err);
          blk->disable_perm = true;
          return;
      }
  
-     blk_set_perm(blk, blk->perm, blk->shared_perm, &local_err);
+     blk_set_perm_locked(blk, blk->perm, blk->shared_perm, &local_err);
      if (local_err) {
          error_propagate(errp, local_err);
          blk->disable_perm = true;
@@@ -259,7 -260,7 +260,7 @@@ static bool blk_can_inactivate(BlockBac
      return blk->force_allow_inactivate;
  }
  
- static int blk_root_inactivate(BdrvChild *child)
+ static int GRAPH_RDLOCK blk_root_inactivate(BdrvChild *child)
  {
      BlockBackend *blk = child->opaque;
  
@@@ -911,7 -912,10 +912,10 @@@ void blk_remove_bs(BlockBackend *blk
      blk_drain(blk);
      root = blk->root;
      blk->root = NULL;
+     bdrv_graph_wrlock(NULL);
      bdrv_root_unref_child(root);
+     bdrv_graph_wrunlock();
  }
  
  /*
@@@ -953,8 -957,9 +957,9 @@@ int blk_replace_bs(BlockBackend *blk, B
  /*
   * Sets the permission bitmasks that the user of the BlockBackend needs.
   */
- int blk_set_perm(BlockBackend *blk, uint64_t perm, uint64_t shared_perm,
-                  Error **errp)
+ static int coroutine_mixed_fn GRAPH_RDLOCK
+ blk_set_perm_locked(BlockBackend *blk, uint64_t perm, uint64_t shared_perm,
+                     Error **errp)
  {
      int ret;
      GLOBAL_STATE_CODE();
      return 0;
  }
  
+ int blk_set_perm(BlockBackend *blk, uint64_t perm, uint64_t shared_perm,
+                  Error **errp)
+ {
+     GLOBAL_STATE_CODE();
+     GRAPH_RDLOCK_GUARD_MAINLOOP();
+     return blk_set_perm_locked(blk, perm, shared_perm, errp);
+ }
  void blk_get_perm(BlockBackend *blk, uint64_t *perm, uint64_t *shared_perm)
  {
      GLOBAL_STATE_CODE();
@@@ -1341,7 -1355,7 +1355,7 @@@ blk_co_do_preadv_part(BlockBackend *blk
      /* throttling disk I/O */
      if (blk->public.throttle_group_member.throttle_state) {
          throttle_group_co_io_limits_intercept(&blk->public.throttle_group_member,
 -                bytes, false);
 +                bytes, THROTTLE_READ);
      }
  
      ret = bdrv_co_preadv_part(blk->root, offset, bytes, qiov, qiov_offset,
@@@ -1415,7 -1429,7 +1429,7 @@@ blk_co_do_pwritev_part(BlockBackend *bl
      /* throttling disk I/O */
      if (blk->public.throttle_group_member.throttle_state) {
          throttle_group_co_io_limits_intercept(&blk->public.throttle_group_member,
 -                bytes, true);
 +                bytes, THROTTLE_WRITE);
      }
  
      if (!blk->enable_write_cache) {
@@@ -1533,7 -1547,7 +1547,7 @@@ BlockAIOCB *blk_abort_aio_request(Block
      acb->blk = blk;
      acb->ret = ret;
  
-     replay_bh_schedule_oneshot_event(blk_get_aio_context(blk),
+     replay_bh_schedule_oneshot_event(qemu_get_current_aio_context(),
                                       error_callback_bh, acb);
      return &acb->common;
  }
@@@ -1545,16 -1559,8 +1559,8 @@@ typedef struct BlkAioEmAIOCB 
      bool has_returned;
  } BlkAioEmAIOCB;
  
- static AioContext *blk_aio_em_aiocb_get_aio_context(BlockAIOCB *acb_)
- {
-     BlkAioEmAIOCB *acb = container_of(acb_, BlkAioEmAIOCB, common);
-     return blk_get_aio_context(acb->rwco.blk);
- }
  static const AIOCBInfo blk_aio_em_aiocb_info = {
      .aiocb_size         = sizeof(BlkAioEmAIOCB),
-     .get_aio_context    = blk_aio_em_aiocb_get_aio_context,
  };
  
  static void blk_aio_complete(BlkAioEmAIOCB *acb)
@@@ -1595,11 -1601,11 +1601,11 @@@ static BlockAIOCB *blk_aio_prwv(BlockBa
      acb->has_returned = false;
  
      co = qemu_coroutine_create(co_entry, acb);
-     aio_co_enter(blk_get_aio_context(blk), co);
+     aio_co_enter(qemu_get_current_aio_context(), co);
  
      acb->has_returned = true;
      if (acb->rwco.ret != NOT_DONE) {
-         replay_bh_schedule_oneshot_event(blk_get_aio_context(blk),
+         replay_bh_schedule_oneshot_event(qemu_get_current_aio_context(),
                                           blk_aio_complete_bh, acb);
      }
  
@@@ -1901,11 -1907,11 +1907,11 @@@ BlockAIOCB *blk_aio_zone_report(BlockBa
      acb->has_returned = false;
  
      co = qemu_coroutine_create(blk_aio_zone_report_entry, acb);
-     aio_co_enter(blk_get_aio_context(blk), co);
+     aio_co_enter(qemu_get_current_aio_context(), co);
  
      acb->has_returned = true;
      if (acb->rwco.ret != NOT_DONE) {
-         replay_bh_schedule_oneshot_event(blk_get_aio_context(blk),
+         replay_bh_schedule_oneshot_event(qemu_get_current_aio_context(),
                                           blk_aio_complete_bh, acb);
      }
  
@@@ -1942,11 -1948,11 +1948,11 @@@ BlockAIOCB *blk_aio_zone_mgmt(BlockBack
      acb->has_returned = false;
  
      co = qemu_coroutine_create(blk_aio_zone_mgmt_entry, acb);
-     aio_co_enter(blk_get_aio_context(blk), co);
+     aio_co_enter(qemu_get_current_aio_context(), co);
  
      acb->has_returned = true;
      if (acb->rwco.ret != NOT_DONE) {
-         replay_bh_schedule_oneshot_event(blk_get_aio_context(blk),
+         replay_bh_schedule_oneshot_event(qemu_get_current_aio_context(),
                                           blk_aio_complete_bh, acb);
      }
  
@@@ -1982,10 -1988,10 +1988,10 @@@ BlockAIOCB *blk_aio_zone_append(BlockBa
      acb->has_returned = false;
  
      co = qemu_coroutine_create(blk_aio_zone_append_entry, acb);
-     aio_co_enter(blk_get_aio_context(blk), co);
+     aio_co_enter(qemu_get_current_aio_context(), co);
      acb->has_returned = true;
      if (acb->rwco.ret != NOT_DONE) {
-         replay_bh_schedule_oneshot_event(blk_get_aio_context(blk),
+         replay_bh_schedule_oneshot_event(qemu_get_current_aio_context(),
                                           blk_aio_complete_bh, acb);
      }
  
@@@ -2434,12 -2440,6 +2440,6 @@@ AioContext *blk_get_aio_context(BlockBa
      return blk->ctx;
  }
  
- static AioContext *blk_aiocb_get_aio_context(BlockAIOCB *acb)
- {
-     BlockBackendAIOCB *blk_acb = DO_UPCAST(BlockBackendAIOCB, common, acb);
-     return blk_get_aio_context(blk_acb->blk);
- }
  int blk_set_aio_context(BlockBackend *blk, AioContext *new_context,
                          Error **errp)
  {