qemu-e2k/hw
Emanuele Giuseppe Esposito c86422c554 block: Convert bdrv_refresh_total_sectors() to co_wrapper_mixed
BlockDriver->bdrv_getlength is categorized as IO callback, and it
currently doesn't run in a coroutine. We should let it take a graph
rdlock since the callback traverses the block nodes graph, which however
is only possible in a coroutine.

Therefore turn it into a co_wrapper to move the actual function into a
coroutine where the lock can be taken.

Because now this function creates a new coroutine and polls, we need to
take the AioContext lock where it is missing, for the only reason that
internally co_wrapper calls AIO_WAIT_WHILE and it expects to release the
AioContext lock.

This is especially messy when a co_wrapper creates a coroutine and polls
in bdrv_open_driver, because this function has so many callers in so
many context that it can easily lead to deadlocks. Therefore the new
rule for bdrv_open_driver is that the caller must always hold the
AioContext lock of the given bs (except if it is a coroutine), because
the function calls bdrv_refresh_total_sectors() which is now a
co_wrapper.

Once the rwlock is ultimated and placed in every place it needs to be,
we will poll using AIO_WAIT_WHILE_UNLOCKED and remove the AioContext
lock.

Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-Id: <20230113204212.359076-7-kwolf@redhat.com>
Reviewed-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2023-02-01 16:52:32 +01:00
..
9pfs coroutine: Split qemu/coroutine-core.h off qemu/coroutine.h 2023-01-20 07:21:46 +01:00
acpi acpi: cpuhp: fix guest-visible maximum access size to the legacy reg block 2023-01-08 01:54:23 -05:00
adc
alpha
arm hw/i2c/versatile_i2c: Rename versatile_i2c -> arm_sbcon_i2c 2023-01-23 13:32:38 +00:00
audio include/hw/pci: Split pci_device.h off pci.h 2023-01-08 01:54:22 -05:00
avr
block pflash: Only read non-zero parts of backend image 2023-01-24 18:26:41 +01:00
char hw/riscv: spike: Decouple create_fdt() dependency to ELF loading 2023-01-20 10:14:13 +10:00
core bulk: Rename TARGET_FMT_plx -> HWADDR_FMT_plx 2023-01-18 11:14:34 +01:00
cpu hw/cpu: Mark arm11 and realview mpcore as target-independent code 2023-01-16 17:51:20 +01:00
cris
cxl hw/cxl/cxl-host: Fix an error message typo 2023-01-17 10:02:37 +01:00
display Monitor patches for 2023-01-19 2023-01-19 18:58:03 +00:00
dma bulk: Rename TARGET_FMT_plx -> HWADDR_FMT_plx 2023-01-18 11:14:34 +01:00
gpio hw/gpio/omap_gpio: Use CamelCase for TYPE_OMAP2_GPIO type name 2023-01-12 17:15:09 +00:00
hppa
hyperv
i2c hw/i2c/versatile_i2c: Rename versatile_i2c -> arm_sbcon_i2c 2023-01-23 13:32:38 +00:00
i386 trivial branch pull request 20230118 2023-01-19 15:05:29 +00:00
ide virtio,pc,pci: features, cleanups, fixes 2023-01-09 10:07:12 +00:00
input
intc Header cleanup patches for 2023-01-20 2023-01-20 13:17:55 +00:00
ipack include/hw/pci: Split pci_device.h off pci.h 2023-01-08 01:54:22 -05:00
ipmi include/hw/pci: Split pci_device.h off pci.h 2023-01-08 01:54:22 -05:00
isa hw/usb/hcd-uhci: Introduce TYPE_ defines for device models 2023-01-13 16:22:57 +01:00
loongarch
m68k
mem
microblaze
mips hw/mips/boston: Rename MachineState 'mc' pointer to 'ms' 2023-01-13 16:22:57 +01:00
misc bulk: Rename TARGET_FMT_plx -> HWADDR_FMT_plx 2023-01-18 11:14:34 +01:00
net bulk: Rename TARGET_FMT_plx -> HWADDR_FMT_plx 2023-01-18 11:14:34 +01:00
nios2
nubus
nvme hw/nvme updates 2023-01-11 16:41:13 +00:00
nvram
openrisc
pci bulk: Rename TARGET_FMT_plx -> HWADDR_FMT_plx 2023-01-18 11:14:34 +01:00
pci-bridge bulk: Rename TARGET_FMT_plx -> HWADDR_FMT_plx 2023-01-18 11:14:34 +01:00
pci-host Header cleanup patches for 2023-01-20 2023-01-20 13:17:55 +00:00
pcmcia
ppc Header cleanup patches for 2023-01-20 2023-01-20 13:17:55 +00:00
rdma hw/pvrdma: Protect against buggy or malicious guest driver 2023-01-16 18:49:38 +01:00
remote hw/pci/pci: Factor out pci_bus_map_irqs() from pci_bus_irqs() 2023-01-13 16:22:57 +01:00
riscv hw/riscv/virt.c: move create_fw_cfg() back to virt_machine_init() 2023-01-20 10:14:14 +10:00
rtc bulk: Rename TARGET_FMT_plx -> HWADDR_FMT_plx 2023-01-18 11:14:34 +01:00
rx
s390x s390x/pv: Implement a CGS check helper 2023-01-18 12:27:21 +01:00
scsi block: Convert bdrv_refresh_total_sectors() to co_wrapper_mixed 2023-02-01 16:52:32 +01:00
sd hw/arm/omap: Drop useless casts from void * to pointer 2023-01-12 17:15:09 +00:00
sensor
sh4 bulk: Rename TARGET_FMT_plx -> HWADDR_FMT_plx 2023-01-18 11:14:34 +01:00
smbios include/hw/pci: Split pci_device.h off pci.h 2023-01-08 01:54:22 -05:00
sparc
sparc64 hw/sparc64/niagara: Use blk_name() instead of open-coding it 2023-01-20 07:25:01 +01:00
ssi trivial branch pull request 20230118 2023-01-19 15:05:29 +00:00
timer bulk: Rename TARGET_FMT_plx -> HWADDR_FMT_plx 2023-01-18 11:14:34 +01:00
tpm hw/tpm: Move tpm_ppi.c out of target-specific source set 2023-01-16 17:51:20 +01:00
tricore
usb ccid-card-emulated: fix cast warning/error 2023-01-16 18:46:03 +01:00
vfio include/hw/pci: Split pci_device.h off pci.h 2023-01-08 01:54:22 -05:00
virtio Header cleanup patches for 2023-01-20 2023-01-20 13:17:55 +00:00
watchdog include/hw/pci: Split pci_device.h off pci.h 2023-01-08 01:54:22 -05:00
xen bulk: Rename TARGET_FMT_plx -> HWADDR_FMT_plx 2023-01-18 11:14:34 +01:00
xenpv
xtensa
Kconfig
meson.build