[PATCH v2 16/20] block: Mark BlockDriver callbacks for amend job GRAPH_RDLOCK

2023-05-04 Thread Kevin Wolf
From: Emanuele Giuseppe Esposito This adds GRAPH_RDLOCK annotations to declare that callers of amend callbacks in BlockDriver need to hold a reader lock for the graph. Signed-off-by: Emanuele Giuseppe Esposito Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Reviewed-by: Stefan Hajnoczi

[PATCH v2 17/20] block: Mark bdrv_query_bds_stats() and callers GRAPH_RDLOCK

2023-05-04 Thread Kevin Wolf
This adds GRAPH_RDLOCK annotations to declare that callers of bdrv_query_bds_stats() need to hold a reader lock for the graph because it accesses the children list of a node. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Reviewed-by: Stefan Hajnoczi --- block/qapi.c | 6 -- 1 file

[PATCH v2 11/20] vhdx: Require GRAPH_RDLOCK for accessing a node's parent list

2023-05-04 Thread Kevin Wolf
This adds GRAPH_RDLOCK annotations to declare that functions accessing the parent list of a node need to hold a reader lock for the graph. As it happens, they already do. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Reviewed-by: Stefan Hajnoczi --- block/vhdx.c | 9 + 1 file

[PATCH v2 08/20] block: .bdrv_open is non-coroutine and unlocked

2023-05-04 Thread Kevin Wolf
and qed to work with the correct assumptions: The graph lock needs to be taken internally instead of just assuming it's already there, and the coroutine path is dead code that can be removed. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Reviewed-by: Stefan Hajnoczi --- include/block/block_int

[PATCH v2 20/20] block: Mark bdrv_refresh_limits() and callers GRAPH_RDLOCK

2023-05-04 Thread Kevin Wolf
This adds GRAPH_RDLOCK annotations to declare that callers of bdrv_refresh_limits() need to hold a reader lock for the graph because it accesses the children list of a node. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Reviewed-by: Stefan Hajnoczi --- include/block/block-global-state.h

[PATCH v2 15/20] block: Mark bdrv_co_debug_event() GRAPH_RDLOCK

2023-05-04 Thread Kevin Wolf
(using the BLKDBG_EVENT macro) by mixed functions that run both in coroutine and non-coroutine context (for example many of the functions in qcow2-cluster.c and qcow2-refcount.c). Signed-off-by: Emanuele Giuseppe Esposito Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Reviewed-by: Stefan

[PATCH v2 07/20] graph-lock: Fix GRAPH_RDLOCK_GUARD*() to be reader lock

2023-05-04 Thread Kevin Wolf
GRAPH_RDLOCK_GUARD() and GRAPH_RDLOCK_GUARD_MAINLOOP() only take a reader lock for the graph, so the correct annotation for them to use is TSA_ASSERT_SHARED rather than TSA_ASSERT. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake --- include/block/graph-lock.h | 16 1 file

[PATCH v2 01/20] qcow2: Don't call bdrv_getlength() in coroutine_fns

2023-05-04 Thread Kevin Wolf
There is a bdrv_co_getlength() now, which should be used in coroutine context. This requires adding GRAPH_RDLOCK to some functions so that this still compiles with TSA because bdrv_co_getlength() is GRAPH_RDLOCK. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Reviewed-by: Stefan Hajnoczi

[PATCH v2 19/20] block: Mark bdrv_recurse_can_replace() and callers GRAPH_RDLOCK

2023-05-04 Thread Kevin Wolf
This adds GRAPH_RDLOCK annotations to declare that callers of bdrv_recurse_can_replace() need to hold a reader lock for the graph because it accesses the children list of a node. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Reviewed-by: Stefan Hajnoczi --- include/block/block-global

[PATCH v2 06/20] graph-lock: Add GRAPH_UNLOCKED(_PTR)

2023-05-04 Thread Kevin Wolf
pointers can't be checked at all. Therefore, its primary purpose is documentation. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Reviewed-by: Stefan Hajnoczi --- include/block/graph-lock.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/block/graph-lock.h b/include/block/graph

[PATCH v2 18/20] block: Mark bdrv_query_block_graph_info() and callers GRAPH_RDLOCK

2023-05-04 Thread Kevin Wolf
This adds GRAPH_RDLOCK annotations to declare that callers of bdrv_query_block_graph_info() need to hold a reader lock for the graph because it accesses the children list of a node. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Reviewed-by: Stefan Hajnoczi --- include/block/qapi.h | 7

[PATCH v2 14/20] block: Mark bdrv_co_get_info() and callers GRAPH_RDLOCK

2023-05-04 Thread Kevin Wolf
From: Emanuele Giuseppe Esposito This adds GRAPH_RDLOCK annotations to declare that callers of bdrv_co_get_info() need to hold a reader lock for the graph. Signed-off-by: Emanuele Giuseppe Esposito Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Reviewed-by: Stefan Hajnoczi --- include

[PATCH v2 04/20] block: Don't call no_coroutine_fns in qmp_block_resize()

2023-05-04 Thread Kevin Wolf
This QMP handler runs in a coroutine, so it must use the corresponding no_co_wrappers instead. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Reviewed-by: Stefan Hajnoczi --- blockdev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/blockdev.c b/blockdev.c index

[PATCH v2 12/20] mirror: Require GRAPH_RDLOCK for accessing a node's parent list

2023-05-04 Thread Kevin Wolf
This adds GRAPH_RDLOCK annotations to declare that functions accessing the parent list of a node need to hold a reader lock for the graph. As it happens, they already do. Signed-off-by: Kevin Wolf --- block/mirror.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block

[PATCH v2 10/20] nbd: Mark nbd_co_do_establish_connection() and callers GRAPH_RDLOCK

2023-05-04 Thread Kevin Wolf
From: Emanuele Giuseppe Esposito This adds GRAPH_RDLOCK annotations to declare that callers of nbd_co_do_establish_connection() need to hold a reader lock for the graph. Signed-off-by: Emanuele Giuseppe Esposito Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Reviewed-by: Stefan Hajnoczi

[PATCH v2 05/20] test-bdrv-drain: Don't modify the graph in coroutines

2023-05-04 Thread Kevin Wolf
and destroying the test nodes and BlockBackends always happens outside of coroutine context. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake --- tests/unit/test-bdrv-drain.c | 112 +++ 1 file changed, 75 insertions(+), 37 deletions(-) diff --git a/tests/unit/test-bdrv

[PATCH v2 09/20] nbd: Remove nbd_co_flush() wrapper function

2023-05-04 Thread Kevin Wolf
The only thing nbd_co_flush() does is call nbd_client_co_flush(). Just use that function directly in the BlockDriver definitions and remove the wrapper. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Reviewed-by: Stefan Hajnoczi --- block/nbd.c | 11 +++ 1 file changed, 3

[PATCH v2 00/20] Graph locking, part 3 (more block drivers)

2023-05-04 Thread Kevin Wolf
bdrv_co_get_allocated_file_size() and callers GRAPH_RDLOCK block: Mark bdrv_co_get_info() and callers GRAPH_RDLOCK block: Mark bdrv_co_debug_event() GRAPH_RDLOCK block: Mark BlockDriver callbacks for amend job GRAPH_RDLOCK Kevin Wolf (15): qcow2: Don't call bdrv_getlength() in coroutine_fns block

[PATCH v2 02/20] block: Consistently call bdrv_activate() outside coroutine

2023-05-04 Thread Kevin Wolf
bdrv_activate(). Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Reviewed-by: Stefan Hajnoczi --- include/block/block-global-state.h | 6 +- block/block-backend.c | 10 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/include/block/block-global

[PATCH v2 03/20] block: bdrv/blk_co_unref() for calls in coroutine context

2023-05-04 Thread Kevin Wolf
These functions must not be called in coroutine context, because they need write access to the graph. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Reviewed-by: Stefan Hajnoczi --- include/block/block-global-state.h | 3 ++- include/sysemu/block-backend-global-state.h | 5

Re: [PATCH 03/20] block: bdrv/blk_co_unref() for calls in coroutine context

2023-05-04 Thread Kevin Wolf
Am 27.04.2023 um 22:49 hat Paolo Bonzini geschrieben: > Il gio 27 apr 2023, 19:00 Kevin Wolf ha scritto: > > > By the way, and slightly unrelated, can vrc somehow help with finding > > places that call coroutine wrappers without holding the AioContext lock? > > (This re

Re: [PATCH 15/20] block: Mark bdrv_co_debug_event() GRAPH_RDLOCK

2023-05-04 Thread Kevin Wolf
Am 25.04.2023 um 23:14 hat Eric Blake geschrieben: > On Tue, Apr 25, 2023 at 07:31:53PM +0200, Kevin Wolf wrote: > > From: Emanuele Giuseppe Esposito > > > > This adds GRAPH_RDLOCK annotations to declare that callers of > > bdrv_co_debug_event() need to hold

Re: [PATCH 13/20] block: Mark bdrv_co_get_allocated_file_size() and callers GRAPH_RDLOCK

2023-05-04 Thread Kevin Wolf
Am 01.05.2023 um 21:03 hat Stefan Hajnoczi geschrieben: > On Tue, Apr 25, 2023 at 07:31:51PM +0200, Kevin Wolf wrote: > > @@ -5778,6 +5779,7 @@ int64_t coroutine_fn > > bdrv_co_get_allocated_file_size(BlockDriverState *bs) > > { > > BlockDriver *drv

Re: [PATCH] migration: Fix block_bitmap_mapping migration

2023-05-04 Thread Kevin Wolf
are fixed. > > Fixes: b804b35b1c8a0edfd127ac20819c234be55ac7fc >migration: Create migrate_block_bitmap_mapping() function > > Reported-by: Kevin Wolf > Signed-off-by: Juan Quintela Thanks, applied to the block branch. Kevin

Re: [PULL 11/18] migration: Create migrate_block_bitmap_mapping() function

2023-05-04 Thread Kevin Wolf
Am 03.05.2023 um 19:15 hat Juan Quintela geschrieben: > Kevin Wolf wrote: > > Am 27.04.2023 um 17:22 hat Juan Quintela geschrieben: > >> Notice that we changed the test of ->has_block_bitmap_mapping > >> for the test that block_bitmap_mapping is not NULL. > >

Re: [PULL 11/18] migration: Create migrate_block_bitmap_mapping() function

2023-05-03 Thread Kevin Wolf
Am 03.05.2023 um 16:53 hat Juan Quintela geschrieben: > Kevin Wolf wrote: > > Am 27.04.2023 um 17:22 hat Juan Quintela geschrieben: > >> Notice that we changed the test of ->has_block_bitmap_mapping > >> for the test that block_bitmap_mapping is not NULL. > >

[PATCH] iotests/nbd-reconnect-on-open: Fix NBD socket path

2023-05-03 Thread Kevin Wolf
Socket paths need to be short to avoid failures. This is why there is a iotests.sock_dir (defaulting to /tmp) separate from the disk image base directory. Make use of it to fix failures in too deeply nested test directories. Fixes: ab7f7e67a7e7b49964109501dfcde4ec29bae60e Signed-off-by: Kevin

Re: [PULL 11/18] migration: Create migrate_block_bitmap_mapping() function

2023-05-03 Thread Kevin Wolf
Am 27.04.2023 um 17:22 hat Juan Quintela geschrieben: > Notice that we changed the test of ->has_block_bitmap_mapping > for the test that block_bitmap_mapping is not NULL. > > Signed-off-by: Juan Quintela > Reviewed-by: Vladimir Sementsov-Ogievskiy > > --- > > Make it return const (vladimir)

[PATCH] block: Fix use after free in blockdev_mark_auto_del()

2023-05-03 Thread Kevin Wolf
can't just continue at block_job_next_locked(job). Instead, start at the head of the list again after job_cancel_locked() and skip those jobs that we already cancelled (or that are completing anyway). Signed-off-by: Kevin Wolf --- blockdev.c | 18 ++ 1 file changed, 14 insertions

Re: [PATCH v4 07/20] block/export: stop using is_external in vhost-user-blk server

2023-05-03 Thread Kevin Wolf
Am 03.05.2023 um 15:11 hat Stefan Hajnoczi geschrieben: > On Wed, May 03, 2023 at 10:08:46AM +0200, Kevin Wolf wrote: > > Am 02.05.2023 um 22:06 hat Stefan Hajnoczi geschrieben: > > > On Tue, May 02, 2023 at 06:04:24PM +0200, Kevin Wolf wrote: > > > > Am 25.04.202

Re: [PATCH v4 04/20] virtio-scsi: stop using aio_disable_external() during unplug

2023-05-03 Thread Kevin Wolf
Am 02.05.2023 um 22:02 hat Stefan Hajnoczi geschrieben: > On Tue, May 02, 2023 at 03:19:52PM +0200, Kevin Wolf wrote: > > Am 01.05.2023 um 17:09 hat Stefan Hajnoczi geschrieben: > > > On Fri, Apr 28, 2023 at 04:22:55PM +0200, Kevin Wolf wrote: > > > > Am 25.04.202

Re: [PATCH v4 07/20] block/export: stop using is_external in vhost-user-blk server

2023-05-03 Thread Kevin Wolf
Am 02.05.2023 um 22:06 hat Stefan Hajnoczi geschrieben: > On Tue, May 02, 2023 at 06:04:24PM +0200, Kevin Wolf wrote: > > Am 25.04.2023 um 19:27 hat Stefan Hajnoczi geschrieben: > > > vhost-user activity must be suspended during bdrv_drained_begin/end(). > > > This

Re: [PATCH v4 03/20] virtio-scsi: avoid race between unplug and transport event

2023-05-03 Thread Kevin Wolf
Am 02.05.2023 um 20:56 hat Stefan Hajnoczi geschrieben: > On Tue, May 02, 2023 at 05:19:46PM +0200, Kevin Wolf wrote: > > Am 25.04.2023 um 19:26 hat Stefan Hajnoczi geschrieben: > > > Only report a transport reset event to the guest after the SCSIDevice > &g

Re: [PATCH v4 10/20] block: drain from main loop thread in bdrv_co_yield_to_drain()

2023-05-02 Thread Kevin Wolf
Am 25.04.2023 um 19:27 hat Stefan Hajnoczi geschrieben: > For simplicity, always run BlockDevOps .drained_begin/end/poll() > callbacks in the main loop thread. This makes it easier to implement the > callbacks and avoids extra locks. > > Move the function pointer declarations from the I/O Code

Re: [PATCH v4 07/20] block/export: stop using is_external in vhost-user-blk server

2023-05-02 Thread Kevin Wolf
Am 25.04.2023 um 19:27 hat Stefan Hajnoczi geschrieben: > vhost-user activity must be suspended during bdrv_drained_begin/end(). > This prevents new requests from interfering with whatever is happening > in the drained section. > > Previously this was done using aio_set_fd_handler()'s is_external

Re: [PATCH v4 06/20] block/export: wait for vhost-user-blk requests when draining

2023-05-02 Thread Kevin Wolf
Am 25.04.2023 um 19:27 hat Stefan Hajnoczi geschrieben: > Each vhost-user-blk request runs in a coroutine. When the BlockBackend > enters a drained section we need to enter a quiescent state. Currently > any in-flight requests race with bdrv_drained_begin() because it is > unaware of

Re: [PATCH v4 03/20] virtio-scsi: avoid race between unplug and transport event

2023-05-02 Thread Kevin Wolf
Am 25.04.2023 um 19:26 hat Stefan Hajnoczi geschrieben: > Only report a transport reset event to the guest after the SCSIDevice > has been unrealized by qdev_simple_device_unplug_cb(). > > qdev_simple_device_unplug_cb() sets the SCSIDevice's qdev.realized field > to false so that

Re: [PATCH v4 04/20] virtio-scsi: stop using aio_disable_external() during unplug

2023-05-02 Thread Kevin Wolf
Am 01.05.2023 um 17:09 hat Stefan Hajnoczi geschrieben: > On Fri, Apr 28, 2023 at 04:22:55PM +0200, Kevin Wolf wrote: > > Am 25.04.2023 um 19:27 hat Stefan Hajnoczi geschrieben: > > > This patch is part of an effort to remove the aio_disable_external() > > > API because

Re: [PATCH v4 04/20] virtio-scsi: stop using aio_disable_external() during unplug

2023-04-28 Thread Kevin Wolf
Am 25.04.2023 um 19:27 hat Stefan Hajnoczi geschrieben: > This patch is part of an effort to remove the aio_disable_external() > API because it does not fit in a multi-queue block layer world where > many AioContexts may be submitting requests to the same disk. > > The SCSI emulation code is

Re: QMP (without OOB) function running in thread different from the main thread as part of aio_poll

2023-04-28 Thread Kevin Wolf
Am 28.04.2023 um 10:38 hat Juan Quintela geschrieben: > Kevin Wolf wrote: > >> I am perhaps a bit ingenuous here, but it is there a way to convince > >> qemu that snapshot_save_job_bh *HAS* to run on the main thread? > > > > I believe we're talking about a techni

Re: [PATCH] block/file-posix.c: No need to sync data when aio + dio is enabled

2023-04-28 Thread Kevin Wolf
Am 28.04.2023 um 11:39 hat zhoushl geschrieben: > > On Apr 27, 2023, at 22:02, Kevin Wolf wrote: > > Am 27.04.2023 um 15:22 hat zhoushl geschrieben: > >> Hi Kevin: > >> I’m sorry for missing commit message, next time I will be careful. When > >> the appl

Re: QMP (without OOB) function running in thread different from the main thread as part of aio_poll

2023-04-28 Thread Kevin Wolf
Am 28.04.2023 um 09:47 hat Juan Quintela geschrieben: > Fiona Ebner wrote: > > Am 27.04.23 um 16:36 schrieb Juan Quintela: > >> Fiona Ebner wrote: > >>> Am 27.04.23 um 13:03 schrieb Kevin Wolf: > >>>> Am 26.04.2023 um 16:31 hat Fiona Ebner geschriebe

Re: [PATCH 03/20] block: bdrv/blk_co_unref() for calls in coroutine context

2023-04-27 Thread Kevin Wolf
Am 27.04.2023 um 16:30 hat Paolo Bonzini geschrieben: > Il mar 25 apr 2023, 19:32 Kevin Wolf ha scritto: > > > These functions must not be called in coroutine context, because they > > need write access to the graph. > > > > With these patches applied vrc is

Re: [PATCH] block/file-posix.c: No need to sync data when aio + dio is enabled

2023-04-27 Thread Kevin Wolf
Am 27.04.2023 um 15:22 hat zhoushl geschrieben: > Hi Kevin: > I’m sorry for missing commit message, next time I will be careful. When > the application in guest vm execute fsync, qemu will execute fsync too. > But when aio + dio is enabled, pagecache is bypassed As far as I can tell, you don't

Re: [PATCH] block/nfs: avoid BDRV_POLL_WHILE() in nfs_co_get_allocated_file_size()

2023-04-27 Thread Kevin Wolf
Am 04.04.2023 um 01:30 hat Stefan Hajnoczi geschrieben: > Commit 82618d7bc341 ("block: Convert bdrv_get_allocated_file_size() to > co_wrapper") made nfs_get_allocated_file_size() a coroutine. The > coroutine still uses BDRV_POLL_WHILE() to wait for the NFS RPC to > complete. > > Take it a step

Re: [PATCH] block/nvme: use AIO_WAIT_WHILE_UNLOCKED()

2023-04-27 Thread Kevin Wolf
Am 04.04.2023 um 13:20 hat Stefan Hajnoczi geschrieben: > A few Admin Queue commands are submitted during nvme_file_open(). They > are synchronous since device initialization cannot continue until the > commands complete. > > AIO_WAIT_WHILE() is currently used, but the block/nvme.c code actually

Re: [PATCH] aio-wait: avoid AioContext lock in aio_wait_bh_oneshot()

2023-04-27 Thread Kevin Wolf
Am 04.04.2023 um 17:33 hat Stefan Hajnoczi geschrieben: > There is no need for the AioContext lock in aio_wait_bh_oneshot(). > It's easy to remove the lock from existing callers and then switch from > AIO_WAIT_WHILE() to AIO_WAIT_WHILE_UNLOCKED() in aio_wait_bh_oneshot(). > > Document that the

Re: [PATCH] block: add missing coroutine_fn annotations

2023-04-27 Thread Kevin Wolf
Am 06.04.2023 um 12:17 hat Paolo Bonzini geschrieben: > After the recent introduction of many new coroutine callbacks, > a couple calls from non-coroutine_fn to coroutine_fn have sneaked > in; fix them. > > Signed-off-by: Paolo Bonzini Thanks, applied to the block branch. Kevin

Re: [PATCH] block/file-posix.c: No need to sync data when aio + dio is enabled

2023-04-27 Thread Kevin Wolf
Am 18.04.2023 um 08:05 hat zhous...@163.com geschrieben: > From: zhoushl > > Signed-off-by: zhoushl > > block/file-posix.c | 6 ++ > 1 file changed, 6 insertions(+) > > diff --git a/block/file-posix.c b/block/file-posix.c > index 5760cf22d1..fe9568947c 100644 > --- a/block/file-posix.c >

Re: [PATCH v2] block: add configure options for excluding vmdk, vhdx and vpc

2023-04-27 Thread Kevin Wolf
Am 21.04.2023 um 11:27 hat Vladimir Sementsov-Ogievskiy geschrieben: > Let's add --enable / --disable configure options for these formats, > so that those who don't need them may not build them. > > Signed-off-by: Vladimir Sementsov-Ogievskiy Thanks, applied to the block branch. Kevin

Re: [PATCH 07/20] graph-lock: Fix GRAPH_RDLOCK_GUARD*() to be reader lock

2023-04-27 Thread Kevin Wolf
Am 25.04.2023 um 22:36 hat Eric Blake geschrieben: > On Tue, Apr 25, 2023 at 07:31:45PM +0200, Kevin Wolf wrote: > > GRAPH_RDLOCK_GUARD() and GRAPH_RDLOCK_GUARD_MAINLOOP() only take a > > reader lock for the graph, so the correct annotation for them to use is > > TSA_ASSE

Re: [PATCH 04/20] block: Don't call no_coroutine_fns in qmp_block_resize()

2023-04-27 Thread Kevin Wolf
Am 25.04.2023 um 22:08 hat Eric Blake geschrieben: > On Tue, Apr 25, 2023 at 07:31:42PM +0200, Kevin Wolf wrote: > > This QMP handler runs in a coroutine, so it must use the corresponding > > no_co_wrappers instead. > > > > Signed-off-by: Kevin Wolf > > --- >

Re: [PATCH 01/20] qcow2: Don't call bdrv_getlength() in coroutine_fns

2023-04-27 Thread Kevin Wolf
Am 25.04.2023 um 20:37 hat Eric Blake geschrieben: > On Tue, Apr 25, 2023 at 07:31:39PM +0200, Kevin Wolf wrote: > > There is a bdrv_co_getlength() now, which should be used in coroutine > > context. > > > > Signed-off-by: Kevin Wolf > > --- > > block/qcow

Re: QMP (without OOB) function running in thread different from the main thread as part of aio_poll

2023-04-27 Thread Kevin Wolf
Am 26.04.2023 um 16:31 hat Fiona Ebner geschrieben: > Am 20.04.23 um 08:55 schrieb Paolo Bonzini: > > > > > > Il gio 20 apr 2023, 08:11 Markus Armbruster > > ha scritto: > > > > So, splicing in a bottom half unmoored monitor commands from the main > > loop. 

[PATCH 10/20] nbd: Mark nbd_co_do_establish_connection() and callers GRAPH_RDLOCK

2023-04-25 Thread Kevin Wolf
From: Emanuele Giuseppe Esposito This adds GRAPH_RDLOCK annotations to declare that callers of nbd_co_do_establish_connection() need to hold a reader lock for the graph. Signed-off-by: Emanuele Giuseppe Esposito Signed-off-by: Kevin Wolf --- block/coroutines.h | 5 +++-- block/nbd.c

[PATCH 04/20] block: Don't call no_coroutine_fns in qmp_block_resize()

2023-04-25 Thread Kevin Wolf
This QMP handler runs in a coroutine, so it must use the corresponding no_co_wrappers instead. Signed-off-by: Kevin Wolf --- blockdev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/blockdev.c b/blockdev.c index d7b5c18f0a..eb509cf964 100644 --- a/blockdev.c +++ b

[PATCH 12/20] mirror: Take graph lock for accessing a node's parent list

2023-04-25 Thread Kevin Wolf
This adds GRAPH_RDLOCK annotations to declare that functions accessing the parent list of a node need to hold a reader lock for the graph. As it happens, they already do. Signed-off-by: Kevin Wolf --- block/mirror.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block

[PATCH 19/20] block: Mark bdrv_recurse_can_replace() and callers GRAPH_RDLOCK

2023-04-25 Thread Kevin Wolf
This adds GRAPH_RDLOCK annotations to declare that callers of bdrv_recurse_can_replace() need to hold a reader lock for the graph because it accesses the children list of a node. Signed-off-by: Kevin Wolf --- include/block/block-global-state.h | 5 +++-- include/block/block_int-common.h

[PATCH 02/20] block: Consistently call bdrv_activate() outside coroutine

2023-04-25 Thread Kevin Wolf
bdrv_activate(). Signed-off-by: Kevin Wolf --- include/block/block-global-state.h | 6 +- block/block-backend.c | 10 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/include/block/block-global-state.h b/include/block/block-global-state.h index

[PATCH 16/20] block: Mark BlockDriver callbacks for amend job GRAPH_RDLOCK

2023-04-25 Thread Kevin Wolf
From: Emanuele Giuseppe Esposito This adds GRAPH_RDLOCK annotations to declare that callers of amend callbacks in BlockDriver need to hold a reader lock for the graph. Signed-off-by: Emanuele Giuseppe Esposito Signed-off-by: Kevin Wolf --- include/block/block_int-common.h | 12

[PATCH 01/20] qcow2: Don't call bdrv_getlength() in coroutine_fns

2023-04-25 Thread Kevin Wolf
There is a bdrv_co_getlength() now, which should be used in coroutine context. Signed-off-by: Kevin Wolf --- block/qcow2.h | 4 +++- block/qcow2-refcount.c | 2 +- block/qcow2.c | 19 +-- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/block

[PATCH 03/20] block: bdrv/blk_co_unref() for calls in coroutine context

2023-04-25 Thread Kevin Wolf
These functions must not be called in coroutine context, because they need write access to the graph. Signed-off-by: Kevin Wolf --- include/block/block-global-state.h | 3 ++- include/sysemu/block-backend-global-state.h | 5 - block.c | 2

[PATCH 06/20] graph-lock: Add GRAPH_UNLOCKED(_PTR)

2023-04-25 Thread Kevin Wolf
pointers can't be checked at all. Therefore, its primary purpose is documentation. Signed-off-by: Kevin Wolf --- include/block/graph-lock.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/block/graph-lock.h b/include/block/graph-lock.h index 18cc14de22..7ef391fab3 100644 --- a/include

[PATCH 15/20] block: Mark bdrv_co_debug_event() GRAPH_RDLOCK

2023-04-25 Thread Kevin Wolf
and non-coroutine context (for example blkdebug_open). Signed-off-by: Emanuele Giuseppe Esposito Signed-off-by: Kevin Wolf --- include/block/block-io.h | 9 + include/block/block_int-common.h | 4 ++-- block.c | 2 ++ 3 files changed, 9 insertions(+), 6

[PATCH 14/20] block: Mark bdrv_co_get_info() and callers GRAPH_RDLOCK

2023-04-25 Thread Kevin Wolf
From: Emanuele Giuseppe Esposito This adds GRAPH_RDLOCK annotations to declare that callers of bdrv_co_get_info() need to hold a reader lock for the graph. Signed-off-by: Emanuele Giuseppe Esposito Signed-off-by: Kevin Wolf --- include/block/block-io.h | 7 +-- include/block

[PATCH 18/20] block: Mark bdrv_query_block_graph_info() and callers GRAPH_RDLOCK

2023-04-25 Thread Kevin Wolf
This adds GRAPH_RDLOCK annotations to declare that callers of bdrv_query_block_graph_info() need to hold a reader lock for the graph because it accesses the children list of a node. Signed-off-by: Kevin Wolf --- include/block/qapi.h | 7 --- qemu-img.c | 2 ++ 2 files changed, 6

[PATCH 09/20] nbd: Remove nbd_co_flush() wrapper function

2023-04-25 Thread Kevin Wolf
The only thing nbd_co_flush() does is calling nbd_client_co_flush(). Just use that function directly in the BlockDriver definitions and remove the wrapper. Signed-off-by: Kevin Wolf --- block/nbd.c | 11 +++ 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/block/nbd.c b

[PATCH 13/20] block: Mark bdrv_co_get_allocated_file_size() and callers GRAPH_RDLOCK

2023-04-25 Thread Kevin Wolf
From: Emanuele Giuseppe Esposito This adds GRAPH_RDLOCK annotations to declare that callers of bdrv_co_get_allocated_file_size() need to hold a reader lock for the graph. Signed-off-by: Emanuele Giuseppe Esposito Signed-off-by: Kevin Wolf --- include/block/block-io.h | 7

[PATCH 11/20] vhdx: Take graph lock for accessing a node's parent list

2023-04-25 Thread Kevin Wolf
This adds GRAPH_RDLOCK annotations to declare that functions accessing the parent list of a node need to hold a reader lock for the graph. As it happens, they already do. Signed-off-by: Kevin Wolf --- block/vhdx.c | 9 + 1 file changed, 5 insertions(+), 4 deletions(-) diff --git

[PATCH 17/20] block: Mark bdrv_query_bds_stats() and callers GRAPH_RDLOCK

2023-04-25 Thread Kevin Wolf
This adds GRAPH_RDLOCK annotations to declare that callers of bdrv_query_bds_stats() need to hold a reader lock for the graph because it accesses the children list of a node. Signed-off-by: Kevin Wolf --- block/qapi.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git

[PATCH 08/20] block: .bdrv_open is non-coroutine and unlocked

2023-04-25 Thread Kevin Wolf
and qed to work with the correct assumptions: The graph lock needs to be taken internally instead of just assuming it's already there, and the coroutine path is dead code that can be removed. Signed-off-by: Kevin Wolf --- include/block/block_int-common.h | 8 block.c

[PATCH 20/20] block: Mark bdrv_refresh_limits() and callers GRAPH_RDLOCK

2023-04-25 Thread Kevin Wolf
This adds GRAPH_RDLOCK annotations to declare that callers of bdrv_refresh_limits() need to hold a reader lock for the graph because it accesses the children list of a node. Signed-off-by: Kevin Wolf --- include/block/block-global-state.h | 5 - include/block/block_int-common.h | 3

[PATCH 05/20] test-bdrv-drain: Don't modify the graph in coroutines

2023-04-25 Thread Kevin Wolf
and destroying the test nodes and BlockBackends always happens outside of coroutine context. Signed-off-by: Kevin Wolf --- tests/unit/test-bdrv-drain.c | 112 +++ 1 file changed, 75 insertions(+), 37 deletions(-) diff --git a/tests/unit/test-bdrv-drain.c b/tests/unit/test

[PATCH 07/20] graph-lock: Fix GRAPH_RDLOCK_GUARD*() to be reader lock

2023-04-25 Thread Kevin Wolf
GRAPH_RDLOCK_GUARD() and GRAPH_RDLOCK_GUARD_MAINLOOP() only take a reader lock for the graph, so the correct annotation for them to use is TSA_ASSERT_SHARED rather than TSA_ASSERT. Signed-off-by: Kevin Wolf --- include/block/graph-lock.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions

[PATCH 00/20] Graph locking, part 3 (more block drivers)

2023-04-25 Thread Kevin Wolf
() and callers GRAPH_RDLOCK block: Mark bdrv_co_get_info() and callers GRAPH_RDLOCK block: Mark bdrv_co_debug_event() GRAPH_RDLOCK block: Mark BlockDriver callbacks for amend job GRAPH_RDLOCK Kevin Wolf (15): qcow2: Don't call bdrv_getlength() in coroutine_fns block: Consistently call

[PULL 24/25] vmdk: make vmdk_is_cid_valid a coroutine_fn

2023-04-25 Thread Kevin Wolf
the same treatment. Signed-off-by: Paolo Bonzini Message-Id: <20230309084456.304669-10-pbonz...@redhat.com> Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- block/vmdk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/vmdk.c b/block/vmdk.c index f5f49018fe..3f8c

[PULL 13/25] io_uring: use LuringState from the running thread

2023-04-25 Thread Kevin Wolf
the functions to make clear that they work in the current thread's AioContext. Signed-off-by: Emanuele Giuseppe Esposito Message-Id: <20230203131731.851116-3-eespo...@redhat.com> Reviewed-by: Kevin Wolf Reviewed-by: Stefan Hajnoczi Signed-off-by: Kevin Wolf --- include/block/aio.h | 4 i

[PULL 17/25] blkdebug: add missing coroutine_fn annotation

2023-04-25 Thread Kevin Wolf
From: Paolo Bonzini Signed-off-by: Paolo Bonzini Message-Id: <20230309084456.304669-3-pbonz...@redhat.com> Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- block/blkdebug.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/block/blkdebug.c b/block/blkdebug.c

[PULL 07/25] block: convert bdrv_drain_all_begin() to AIO_WAIT_WHILE_UNLOCKED()

2023-04-25 Thread Kevin Wolf
-by: Kevin Wolf Signed-off-by: Stefan Hajnoczi Message-Id: <20230309190855.414275-5-stefa...@redhat.com> Reviewed-by: Wilfred Mallawa Signed-off-by: Kevin Wolf --- block/io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/io.c b/block/io.c index 2e267a85ab..6fa1

[PULL 01/25] block: make BlockBackend->quiesce_counter atomic

2023-04-25 Thread Kevin Wolf
edhat.com> Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- block/block-backend.c | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/block/block-backend.c b/block/block-backend.c index 5566ea059d..2ae768f24d 100644 --- a

[PULL 20/25] 9pfs: mark more coroutine_fns

2023-04-25 Thread Kevin Wolf
From: Paolo Bonzini Signed-off-by: Paolo Bonzini Message-Id: <20230309084456.304669-6-pbonz...@redhat.com> Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- hw/9pfs/9p.h| 4 ++-- hw/9pfs/codir.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/hw/9pfs/

[PULL 08/25] hmp: convert handle_hmp_command() to AIO_WAIT_WHILE_UNLOCKED()

2023-04-25 Thread Kevin Wolf
succeeds. Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé Reviewed-by: Markus Armbruster Reviewed-by: Kevin Wolf Signed-off-by: Stefan Hajnoczi Message-Id: <20230309190855.414275-6-stefa...@redhat.com> Reviewed-by: Wilfred Mallawa Signed-off-by: Kevin Wolf --- m

[PULL 15/25] thread-pool: avoid passing the pool parameter every time

2023-04-25 Thread Kevin Wolf
the thread_pool_submit* API and remove the ThreadPool function parameter. Signed-off-by: Emanuele Giuseppe Esposito Message-Id: <20230203131731.851116-5-eespo...@redhat.com> Reviewed-by: Kevin Wolf Reviewed-by: Stefan Hajnoczi Signed-off-by: Kevin Wolf --- include/block/thread-pool.h

[PULL 16/25] vvfat: mark various functions as coroutine_fn

2023-04-25 Thread Kevin Wolf
graph lock. So also nnotate functions on the I/O path with TSA attributes, making it possible to switch them to use bdrv_co_*() functions. Signed-off-by: Paolo Bonzini Message-Id: <20230309084456.304669-2-pbonz...@redhat.com> Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- block/v

[PULL 25/25] block/monitor/block-hmp-cmds.c: Fix crash when execute hmp_commit

2023-04-25 Thread Kevin Wolf
. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1615 Signed-off-by: Wang Liang Message-Id: <20230424103902.45265-1-wanglian...@126.com> Reviewed-by: Emanuele Giuseppe Esposito Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- block/monitor/block-hmp-cmds.c | 10 ++ 1 file c

[PULL 18/25] mirror: make mirror_flush a coroutine_fn, do not use co_wrappers

2023-04-25 Thread Kevin Wolf
From: Paolo Bonzini mirror_flush calls a mixed function blk_flush but it is only called from mirror_run; so call the coroutine version and make mirror_flush a coroutine_fn too. Signed-off-by: Paolo Bonzini Message-Id: <20230309084456.304669-4-pbonz...@redhat.com> Reviewed-by: Kevi

[PULL 14/25] thread-pool: use ThreadPool from the running thread

2023-04-25 Thread Kevin Wolf
. Signed-off-by: Emanuele Giuseppe Esposito Message-Id: <20230203131731.851116-4-eespo...@redhat.com> Reviewed-by: Kevin Wolf Reviewed-by: Stefan Hajnoczi Signed-off-by: Kevin Wolf --- include/block/thread-pool.h | 5 + block/file-posix.c | 21 ++--- bloc

[PULL 09/25] monitor: convert monitor_cleanup() to AIO_WAIT_WHILE_UNLOCKED()

2023-04-25 Thread Kevin Wolf
loop succeeds. Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé Reviewed-by: Markus Armbruster Reviewed-by: Kevin Wolf Signed-off-by: Stefan Hajnoczi Message-Id: <20230309190855.414275-7-stefa...@redhat.com> Reviewed-by: Wilfred Mallawa Signed-off-by: Kevi

[PULL 19/25] nbd: mark more coroutine_fns, do not use co_wrappers

2023-04-25 Thread Kevin Wolf
From: Paolo Bonzini Signed-off-by: Paolo Bonzini Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- nbd/server.c | 48 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/nbd/server.c b/nbd/server.c index 4f5c42f84d..e239c2890f

[PULL 21/25] qemu-pr-helper: mark more coroutine_fns

2023-04-25 Thread Kevin Wolf
viewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- scsi/qemu-pr-helper.c | 22 +++--- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/scsi/qemu-pr-helper.c b/scsi/qemu-pr-helper.c index e9b3ad259a..a857e80c03 100644 --- a/scsi/qemu-pr-helper.c +++ b/scsi/qemu-pr-he

[PULL 06/25] block: convert bdrv_graph_wrlock() to AIO_WAIT_WHILE_UNLOCKED()

2023-04-25 Thread Kevin Wolf
_ = true;\ } \ And that means AIO_WAIT_WHILE_UNLOCKED(NULL, ...) can be substituted. Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé Reviewed-by: Kevin Wolf Signed-off-by: Stefan

[PULL 23/25] qcow2: mark various functions as coroutine_fn and GRAPH_RDLOCK

2023-04-25 Thread Kevin Wolf
rdlock taken, thus allowing them to call bdrv_co_*() functions for I/O. Signed-off-by: Paolo Bonzini Message-Id: <20230309084456.304669-9-pbonz...@redhat.com> Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- block/qcow2.h | 15 --- block/qcow2-bitmap.c | 2 +-

[PULL 05/25] block: convert blk_exp_close_all_type() to AIO_WAIT_WHILE_UNLOCKED()

2023-04-25 Thread Kevin Wolf
Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé Reviewed-by: Kevin Wolf Signed-off-by: Stefan Hajnoczi Message-Id: <20230309190855.414275-3-stefa...@redhat.com> Reviewed-by: Wilfred Mallawa Signed-off-by: Kevin Wolf --- block/export/export.c | 2 +- 1 file changed, 1 insertion(+), 1 de

[PULL 12/25] linux-aio: use LinuxAioState from the running thread

2023-04-25 Thread Kevin Wolf
the functions to make clear that they work in the current thread's AioContext. Signed-off-by: Emanuele Giuseppe Esposito Message-Id: <20230203131731.851116-2-eespo...@redhat.com> Reviewed-by: Kevin Wolf Reviewed-by: Stefan Hajnoczi Signed-off-by: Kevin Wolf --- include/block/aio.h

[PULL 11/25] block: add missing coroutine_fn to bdrv_sum_allocated_file_size()

2023-04-25 Thread Kevin Wolf
i Message-Id: <20230308211435.346375-1-stefa...@redhat.com> Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- block.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block.c b/block.c index d79a52ca74..5ec1a3897e 100644 --- a/block.c +++ b/block.c @@ -5750,7 +5750,

[PULL 22/25] tests: mark more coroutine_fns

2023-04-25 Thread Kevin Wolf
From: Paolo Bonzini Signed-off-by: Paolo Bonzini Message-Id: <20230309084456.304669-8-pbonz...@redhat.com> Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- tests/unit/test-thread-pool.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/test-thread-po

[PULL 10/25] include/block: fixup typos

2023-04-25 Thread Kevin Wolf
From: Wilfred Mallawa Fixup a few minor typos Signed-off-by: Wilfred Mallawa Message-Id: <20230313003744.55476-1-wilfred.mall...@opensource.wdc.com> Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- include/block/aio-wait.h | 2 +- i

[PULL 02/25] block: make BlockBackend->disable_request_queuing atomic

2023-04-25 Thread Kevin Wolf
and not when there is I/O in flight). Signed-off-by: Stefan Hajnoczi Reviewed-by: Hanna Czenczek Message-Id: <20230307210427.269214-3-stefa...@redhat.com> Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- block/block-backend.c | 7 --- 1 file c

[PULL 04/25] block: don't acquire AioContext lock in bdrv_drain_all()

2023-04-25 Thread Kevin Wolf
by the GLOBAL_STATE_CODE()/IO_CODE() macros. Set the ctx argument to NULL here to help us keep track of all converted callers. Eventually all callers will have been converted and then the argument can be dropped entirely. Reviewed-by: Kevin Wolf Signed-off-by: Stefan Hajnoczi Message-Id

[PULL 00/25] Block layer patches

2023-04-25 Thread Kevin Wolf
The following changes since commit ac5f7bf8e208cd7893dbb1a9520559e569a4677c: Merge tag 'migration-20230424-pull-request' of https://gitlab.com/juan.quintela/qemu into staging (2023-04-24 15:00:39 +0100) are available in the Git repository at: https://repo.or.cz/qemu/kevin.git

<    4   5   6   7   8   9   10   11   12   13   >