qemu-e2k/block
Emanuele Giuseppe Esposito 005ee3cdc7 block/file-posix: don't use functions calling AIO_WAIT_WHILE in worker threads
When calling bdrv_getlength() in handle_aiocb_write_zeroes(), the
function creates a new coroutine and then waits that it finishes using
AIO_WAIT_WHILE.
The problem is that this function could also run in a worker thread,
that has a different AioContext from main loop and iothreads, therefore
in AIO_WAIT_WHILE we will have in_aio_context_home_thread(ctx) == false
and therefore
assert(qemu_get_current_aio_context() == qemu_get_aio_context());
in the else branch will fail, crashing QEMU.

Aside from that, bdrv_getlength() is wrong also conceptually, because
it reads the BDS graph from another thread and is not protected by
any lock.

Replace it with raw_co_getlength, that doesn't create a coroutine and
doesn't read the BDS graph.

Reported-by: Ninad Palsule <ninad@linux.vnet.ibm.com>
Suggested-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
Message-Id: <20230209154522.1164401-1-eesposit@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2023-02-17 14:33:58 +01:00
..
export Fix non-first inclusions of qemu/osdep.h 2023-02-08 07:28:05 +01:00
monitor Monitor patches for 2023-02-03 2023-02-04 10:19:55 +00:00
accounting.c block: add missed block_acct_setup with new block device init procedure 2022-09-30 18:42:34 +02:00
aio_task.c
amend.c include/block: Untangle inclusion loops 2023-01-20 07:24:28 +01:00
backup.c include/block: Untangle inclusion loops 2023-01-20 07:24:28 +01:00
blkdebug.c block: Convert bdrv_debug_event() to co_wrapper_mixed 2023-02-01 16:52:32 +01:00
blkio.c block: Convert bdrv_get_info() to co_wrapper_mixed 2023-02-01 16:52:32 +01:00
blklogwrites.c block: Convert bdrv_refresh_total_sectors() to co_wrapper_mixed 2023-02-01 16:52:32 +01:00
blkreplay.c block: Convert bdrv_refresh_total_sectors() to co_wrapper_mixed 2023-02-01 16:52:32 +01:00
blkverify.c block: Convert bdrv_refresh_total_sectors() to co_wrapper_mixed 2023-02-01 16:52:32 +01:00
block-backend.c block: Convert bdrv_lock_medium() to co_wrapper 2023-02-01 16:52:32 +01:00
block-copy.c include/block: Untangle inclusion loops 2023-01-20 07:24:28 +01:00
block-gen.h block-coroutine-wrapper.py: support also basic return types 2022-12-15 16:07:43 +01:00
block-ram-registrar.c block: add BlockRAMRegistrar 2022-10-26 14:56:42 -04:00
bochs.c include/block: Untangle inclusion loops 2023-01-20 07:24:28 +01:00
cloop.c include/block: Untangle inclusion loops 2023-01-20 07:24:28 +01:00
commit.c block: Convert bdrv_refresh_total_sectors() to co_wrapper_mixed 2023-02-01 16:52:32 +01:00
copy-before-write.c include/block: Untangle inclusion loops 2023-01-20 07:24:28 +01:00
copy-before-write.h
copy-on-read.c block: Convert bdrv_lock_medium() to co_wrapper 2023-02-01 16:52:32 +01:00
copy-on-read.h Clean up ill-advised or unusual header guards 2022-05-11 16:50:01 +02:00
coroutines.h block: GRAPH_RDLOCK for functions only called by co_wrappers 2022-12-15 16:08:23 +01:00
create.c
crypto.c luks: Fix .bdrv_co_create(_opts) to open images with no_co_wrapper 2023-02-17 11:22:19 +01:00
crypto.h
curl.c block: Handle curl 7.55.0, 7.85.0 version changes 2023-02-17 14:33:52 +01:00
dirty-bitmap.c include/block: Untangle inclusion loops 2023-01-20 07:24:28 +01:00
dmg-bz2.c
dmg-lzfse.c
dmg.c include/block: Untangle inclusion loops 2023-01-20 07:24:28 +01:00
dmg.h
file-posix.c block/file-posix: don't use functions calling AIO_WAIT_WHILE in worker threads 2023-02-17 14:33:58 +01:00
file-win32.c block: Convert bdrv_get_allocated_file_size() to co_wrapper 2023-02-01 16:52:32 +01:00
filter-compress.c block: Convert bdrv_lock_medium() to co_wrapper 2023-02-01 16:52:32 +01:00
gluster.c block: Convert bdrv_get_allocated_file_size() to co_wrapper 2023-02-01 16:52:32 +01:00
graph-lock.c graph-lock: TSA annotations for lock/unlock functions 2022-12-15 16:08:23 +01:00
io_uring.c block/io_uring: revert "Use io_uring_register_ring_fd() to skip fd operations" 2022-10-27 20:14:11 +02:00
io.c block: fix detect-zeroes= with BDRV_REQ_REGISTERED_BUF 2023-02-09 10:22:30 -05:00
iscsi-opts.c
iscsi.c * block/iscsi: fix double-free on BUSY or similar statuses 2023-02-16 11:16:39 +00:00
linux-aio.c misc: fix commonly doubled up words 2022-08-01 11:58:02 +02:00
meson.build block: Create no_co_wrappers for open functions 2023-02-17 11:22:19 +01:00
mirror.c block: Convert bdrv_get_info() to co_wrapper_mixed 2023-02-01 16:52:32 +01:00
nbd.c block: Convert bdrv_refresh_total_sectors() to co_wrapper_mixed 2023-02-01 16:52:32 +01:00
nfs.c block: Convert bdrv_get_allocated_file_size() to co_wrapper 2023-02-01 16:52:32 +01:00
null.c block: Convert bdrv_get_allocated_file_size() to co_wrapper 2023-02-01 16:52:32 +01:00
nvme.c block: Convert bdrv_refresh_total_sectors() to co_wrapper_mixed 2023-02-01 16:52:32 +01:00
parallels-ext.c include/block: Untangle inclusion loops 2023-01-20 07:24:28 +01:00
parallels.c parallels: Fix .bdrv_co_create(_opts) to open images with no_co_wrapper 2023-02-17 11:22:19 +01:00
parallels.h
preallocate.c block: use bdrv_co_refresh_total_sectors when possible 2023-02-01 16:52:32 +01:00
progress_meter.c coroutine: Clean up superfluous inclusion of qemu/lockable.h 2023-01-19 10:18:28 +01:00
qapi-sysemu.c include/block: Untangle inclusion loops 2023-01-20 07:24:28 +01:00
qapi.c block: Clean up includes 2023-02-08 07:28:05 +01:00
qcow2-bitmap.c qcow2: Fix theoretical corruption in store_bitmap() error path 2023-01-24 18:26:41 +01:00
qcow2-cache.c include/block: Untangle inclusion loops 2023-01-20 07:24:28 +01:00
qcow2-cluster.c include/block: Untangle inclusion loops 2023-01-20 07:24:28 +01:00
qcow2-refcount.c block: Convert bdrv_get_allocated_file_size() to co_wrapper 2023-02-01 16:52:32 +01:00
qcow2-snapshot.c qcow2: switch to *_co_* functions 2022-10-27 20:14:11 +02:00
qcow2-threads.c include/block: Untangle inclusion loops 2023-01-20 07:24:28 +01:00
qcow2.c qcow2: Fix open/create to open images with no_co_wrapper 2023-02-17 11:22:19 +01:00
qcow2.h qcow2: manually add more coroutine_fn annotations 2022-10-27 20:14:11 +02:00
qcow.c qcow: Fix .bdrv_co_create(_opts) to open images with no_co_wrapper 2023-02-17 11:22:19 +01:00
qed-check.c include/block: Untangle inclusion loops 2023-01-20 07:24:28 +01:00
qed-cluster.c
qed-l2-cache.c
qed-table.c include/block: Untangle inclusion loops 2023-01-20 07:24:28 +01:00
qed.c qed: Fix .bdrv_co_create(_opts) to open images with no_co_wrapper 2023-02-17 11:22:19 +01:00
qed.h
quorum.c block: Convert bdrv_refresh_total_sectors() to co_wrapper_mixed 2023-02-01 16:52:32 +01:00
raw-format.c block: Convert bdrv_lock_medium() to co_wrapper 2023-02-01 16:52:32 +01:00
rbd.c block: Convert bdrv_get_info() to co_wrapper_mixed 2023-02-01 16:52:32 +01:00
replication.c block: Convert bdrv_refresh_total_sectors() to co_wrapper_mixed 2023-02-01 16:52:32 +01:00
reqlist.c
snapshot-access.c block: Manipulate bs->file / bs->backing pointers in .attach/.detach 2022-10-27 20:14:11 +02:00
snapshot.c block/snapshot: drop indirection around bdrv_snapshot_fallback_ptr 2022-10-27 20:14:11 +02:00
ssh.c block: Convert bdrv_refresh_total_sectors() to co_wrapper_mixed 2023-02-01 16:52:32 +01:00
stream.c stream: Replace subtree drain with a single node drain 2022-12-15 16:07:42 +01:00
throttle-groups.c
throttle.c block: Convert bdrv_refresh_total_sectors() to co_wrapper_mixed 2023-02-01 16:52:32 +01:00
trace-events nbd: trace long NBD operations 2022-06-29 10:57:02 +03:00
trace.h
vdi.c vdi: Fix .bdrv_co_create(_opts) to open images with no_co_wrapper 2023-02-17 11:22:19 +01:00
vhdx-endian.c
vhdx-log.c include/block: Untangle inclusion loops 2023-01-20 07:24:28 +01:00
vhdx.c vhdx: Fix .bdrv_co_create(_opts) to open images with no_co_wrapper 2023-02-17 11:22:19 +01:00
vhdx.h
vmdk.c vmdk: Fix .bdrv_co_create(_opts) to open images with no_co_wrapper 2023-02-17 11:22:19 +01:00
vpc.c vpc: Fix .bdrv_co_create(_opts) to open images with no_co_wrapper 2023-02-17 11:22:19 +01:00
vvfat.c include/block: Untangle inclusion loops 2023-01-20 07:24:28 +01:00
win32-aio.c include/block: Untangle inclusion loops 2023-01-20 07:24:28 +01:00
write-threshold.c include/block: Untangle inclusion loops 2023-01-20 07:24:28 +01:00