xemu/block
Emanuele Giuseppe Esposito be8da05b5e block/block-backend: blk_set_enable_write_cache is IO_CODE
blk_set_enable_write_cache() is defined as GLOBAL_STATE_CODE
but can be invoked from iothreads when handling scsi requests.
This triggers an assertion failure:

 0x00007fd6c3515ce1 in raise () from /lib/x86_64-linux-gnu/libc.so.6
 0x00007fd6c34ff537 in abort () from /lib/x86_64-linux-gnu/libc.so.6
 0x00007fd6c34ff40f in ?? () from /lib/x86_64-linux-gnu/libc.so.6
 0x00007fd6c350e662 in __assert_fail () from /lib/x86_64-linux-gnu/libc.so.6
 0x000056149e2cea03 in blk_set_enable_write_cache (wce=true, blk=0x5614a01c27f0)
   at ../src/block/block-backend.c:1949
 0x000056149e2d0a67 in blk_set_enable_write_cache (blk=0x5614a01c27f0,
   wce=<optimized out>) at ../src/block/block-backend.c:1951
 0x000056149dfe9c59 in scsi_disk_apply_mode_select (p=0x7fd6b400c00e "\004",
   page=<optimized out>, s=<optimized out>) at ../src/hw/scsi/scsi-disk.c:1520
 mode_select_pages (change=true, len=18, p=0x7fd6b400c00e "\004", r=0x7fd6b4001ff0)
   at ../src/hw/scsi/scsi-disk.c:1570
 scsi_disk_emulate_mode_select (inbuf=<optimized out>, r=0x7fd6b4001ff0) at
   ../src/hw/scsi/scsi-disk.c:1640
 scsi_disk_emulate_write_data (req=0x7fd6b4001ff0) at ../src/hw/scsi/scsi-disk.c:1934
 0x000056149e18ff16 in virtio_scsi_handle_cmd_req_submit (req=<optimized out>,
   req=<optimized out>, s=0x5614a12f16b0) at ../src/hw/scsi/virtio-scsi.c:719
 virtio_scsi_handle_cmd_vq (vq=0x7fd6bab92140, s=0x5614a12f16b0) at
   ../src/hw/scsi/virtio-scsi.c:761
 virtio_scsi_handle_cmd (vq=<optimized out>, vdev=<optimized out>) at
   ../src/hw/scsi/virtio-scsi.c:775
 virtio_scsi_handle_cmd (vdev=0x5614a12f16b0, vq=0x7fd6bab92140) at
   ../src/hw/scsi/virtio-scsi.c:765
 0x000056149e1a8aa6 in virtio_queue_notify_vq (vq=0x7fd6bab92140) at
   ../src/hw/virtio/virtio.c:2365
 0x000056149e3ccea5 in aio_dispatch_handler (ctx=ctx@entry=0x5614a01babe0,
   node=<optimized out>) at ../src/util/aio-posix.c:369
 0x000056149e3cd868 in aio_dispatch_ready_handlers (ready_list=0x7fd6c09b2680,
   ctx=0x5614a01babe0) at ../src/util/aio-posix.c:399
 aio_poll (ctx=0x5614a01babe0, blocking=blocking@entry=true) at
   ../src/util/aio-posix.c:713
 0x000056149e2a7796 in iothread_run (opaque=opaque@entry=0x56149ffde500) at
   ../src/iothread.c:67
 0x000056149e3d0859 in qemu_thread_start (args=0x7fd6c09b26f0) at
   ../src/util/qemu-thread-posix.c:504
 0x00007fd6c36b9ea7 in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0
 0x00007fd6c35d9aef in clone () from /lib/x86_64-linux-gnu/libc.so.6

Changing GLOBAL_STATE_CODE in IO_CODE is allowed, since GSC callers are
allowed to call IO_CODE.

Resolves: #1272

Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
Message-Id: <20221027072726.2681500-1-eesposit@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
Tested-by: Antoine Damhet <antoine.damhet@shadow.tech>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2022-10-27 20:27:37 +02:00
..
export block: remove bdrv_try_set_aio_context and replace it with bdrv_try_change_aio_context 2022-10-27 20:14:11 +02:00
monitor monitor: add missing coroutine_fn annotation 2022-10-27 20:14:11 +02: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 block/aio_task: assert max_busy_tasks is greater than 0 2021-10-05 18:56:41 +02:00
amend.c block/amend: Keep strong reference to BDS 2022-03-04 18:18:26 +01:00
backup.c backup: remove incorrect coroutine_fn annotation 2022-10-27 20:14:11 +02:00
blkdebug.c blkdebug: add missing coroutine_fn annotation for indirect-called functions 2022-10-27 20:14:11 +02:00
blklogwrites.c block/blklogwrites: don't care to remove bs->file child on failure 2022-10-27 20:14:11 +02:00
blkreplay.c block: introduce bdrv_open_file_child() helper 2022-10-27 20:14:11 +02:00
blkverify.c block: introduce bdrv_open_file_child() helper 2022-10-27 20:14:11 +02:00
block-backend.c block/block-backend: blk_set_enable_write_cache is IO_CODE 2022-10-27 20:27:37 +02:00
block-copy.c block/block-copy: block_copy(): add timeout_ns parameter 2022-06-29 10:56:12 +03:00
block-gen.h scripts: add block-coroutine-wrapper.py 2020-10-05 10:59:06 +01:00
bochs.c block: introduce bdrv_open_file_child() helper 2022-10-27 20:14:11 +02:00
cloop.c block: introduce bdrv_open_file_child() helper 2022-10-27 20:14:11 +02:00
commit.c commit: switch to *_co_* functions 2022-10-27 20:14:11 +02:00
copy-before-write.c block: introduce bdrv_open_file_child() helper 2022-10-27 20:14:11 +02:00
copy-before-write.h block/copy-before-write.h: global state API + assertions 2022-03-04 18:18:25 +01:00
copy-on-read.c block: introduce bdrv_open_file_child() helper 2022-10-27 20:14:11 +02:00
copy-on-read.h Clean up ill-advised or unusual header guards 2022-05-11 16:50:01 +02:00
coroutines.h block: Remove remaining unused symbols in coroutines.h 2022-07-12 12:14:56 +02:00
create.c block_int-common.h: assertions in the callers of BlockDriver function pointers 2022-03-04 18:18:25 +01:00
crypto.c block: introduce bdrv_open_file_child() helper 2022-10-27 20:14:11 +02:00
crypto.h nomaintainer: Fix Lesser GPL version number 2020-11-15 17:04:40 +01:00
curl.c curl: add missing coroutine_fn annotations 2022-10-07 12:11:41 +02:00
dirty-bitmap.c block: simplify handling of try to merge different sized bitmaps 2022-06-24 17:07:06 +02:00
dmg-bz2.c Include qemu-common.h exactly where needed 2019-06-12 13:20:20 +02:00
dmg-lzfse.c block: Remove unused include 2020-11-09 15:44:21 +01:00
dmg.c block: introduce bdrv_open_file_child() helper 2022-10-27 20:14:11 +02:00
dmg.h Include qemu-common.h exactly where needed 2019-06-12 13:20:20 +02:00
file-posix.c file-posix: Remove unused s->discard_zeroes 2022-10-07 12:11:41 +02:00
file-win32.c block: use int64_t instead of uint64_t in driver write handlers 2021-09-29 13:46:31 -05:00
filter-compress.c block: introduce bdrv_open_file_child() helper 2022-10-27 20:14:11 +02:00
gluster.c gluster: stop using .bdrv_needs_filename 2022-09-30 18:43:44 +02:00
io.c block: switch to *_co_* functions 2022-10-27 20:14:11 +02: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
iscsi-opts.c modules: add block module annotations 2021-07-09 18:20:27 +02:00
iscsi.c iscsi: add missing coroutine_fn annotations 2022-10-07 12:11:40 +02:00
linux-aio.c misc: fix commonly doubled up words 2022-08-01 11:58:02 +02:00
meson.build block: Implement blk_{pread,pwrite}() using generated_co_wrapper 2022-07-12 12:14:56 +02:00
mirror.c mirror: switch to *_co_* functions 2022-10-27 20:14:11 +02:00
nbd.c nbd: add missing coroutine_fn annotations 2022-10-07 12:11:40 +02:00
nfs.c block/nfs: Fix 32-bit Windows build 2022-10-27 20:14:11 +02:00
null.c block: use int64_t instead of uint64_t in driver write handlers 2021-09-29 13:46:31 -05:00
nvme.c nvme: add missing coroutine_fn annotations 2022-10-07 12:11:40 +02:00
parallels-ext.c block: Change bdrv_{pread,pwrite,pwrite_sync}() param order 2022-07-12 12:14:55 +02:00
parallels.c parallels: switch to *_co_* functions 2022-10-27 20:14:11 +02:00
parallels.h parallels: support bitmap extension for read-only mode 2021-03-08 14:56:55 +01:00
preallocate.c block: introduce bdrv_open_file_child() helper 2022-10-27 20:14:11 +02:00
progress_meter.c progressmeter: protect with a mutex 2021-06-25 14:24:24 +03:00
qapi-sysemu.c block: add 'force' parameter to 'blockdev-change-medium' command 2022-04-25 12:02:36 +02:00
qapi.c block: use GDateTime for formatting timestamp when dumping snapshot info 2021-06-14 13:28:50 +01:00
qcow.c qcow: switch to *_co_* functions 2022-10-27 20:14:11 +02:00
qcow2-bitmap.c qcow2: manually add more coroutine_fn annotations 2022-10-27 20:14:11 +02:00
qcow2-cache.c block: Change bdrv_{pread,pwrite,pwrite_sync}() param order 2022-07-12 12:14:55 +02:00
qcow2-cluster.c qcow2: switch to *_co_* functions 2022-10-27 20:14:11 +02:00
qcow2-refcount.c qcow2: switch to *_co_* functions 2022-10-27 20:14:11 +02:00
qcow2-snapshot.c qcow2: switch to *_co_* functions 2022-10-27 20:14:11 +02:00
qcow2-threads.c qcow2: add zstd cluster compression 2020-05-13 14:20:31 +02:00
qcow2.c qcow2: switch to *_co_* functions 2022-10-27 20:14:11 +02:00
qcow2.h qcow2: manually add more coroutine_fn annotations 2022-10-27 20:14:11 +02:00
qed-check.c block/qed: add missed coroutine_fn markers 2019-04-30 15:29:00 +02:00
qed-cluster.c qed: protect table cache with CoMutex 2017-07-17 11:34:11 +08:00
qed-l2-cache.c osdep: Move memalign-related functions to their own header 2022-03-07 13:16:49 +00:00
qed-table.c qed: switch to *_co_* functions 2022-10-27 20:14:11 +02:00
qed.c qed: switch to *_co_* functions 2022-10-27 20:14:11 +02:00
qed.h qed: Simplify backing reads 2020-07-06 10:34:14 +02:00
quorum.c quorum: Remove unnecessary forward declaration 2022-10-07 12:11:41 +02:00
raw-format.c block: Manipulate bs->file / bs->backing pointers in .attach/.detach 2022-10-27 20:14:11 +02:00
rbd.c block/rbd: report a better error when namespace does not exist 2022-06-24 17:07:06 +02:00
replication.c block: introduce bdrv_open_file_child() helper 2022-10-27 20:14:11 +02:00
reqlist.c block/reqlist: add reqlist_wait_all() 2022-03-07 09:33:30 +01:00
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 ssh: add missing coroutine_fn annotation 2022-10-27 20:14:11 +02:00
stream.c block/stream: Drain subtree around graph change 2022-03-29 16:30:55 +02:00
throttle-groups.c block/throttle-groups: throttle_group_co_io_limits_intercept(): 64bit bytes 2021-02-03 08:14:00 -06:00
throttle.c block: introduce bdrv_open_file_child() helper 2022-10-27 20:14:11 +02:00
trace-events nbd: trace long NBD operations 2022-06-29 10:57:02 +03:00
trace.h trace: switch position of headers to what Meson requires 2020-08-21 06:18:24 -04:00
vdi.c vdi: switch to *_co_* functions 2022-10-27 20:14:11 +02:00
vhdx-endian.c Include qemu-common.h exactly where needed 2019-06-12 13:20:20 +02:00
vhdx-log.c block: Change bdrv_{pread,pwrite,pwrite_sync}() param order 2022-07-12 12:14:55 +02:00
vhdx.c vhdx: switch to *_co_* functions 2022-10-27 20:14:11 +02:00
vhdx.h block/vhdx: Use IEC binary prefixes for size constants 2019-04-30 15:29:00 +02:00
vmdk.c vmdk: switch to *_co_* functions 2022-10-27 20:14:11 +02:00
vpc.c block: introduce bdrv_open_file_child() helper 2022-10-27 20:14:11 +02:00
vvfat.c vvfat: allow spaces in file names 2022-10-27 20:14:11 +02:00
win32-aio.c osdep: Move memalign-related functions to their own header 2022-03-07 13:16:49 +00:00
write-threshold.c write-threshold: deal with includes 2021-05-14 16:14:10 +02:00