mirror of
https://gitlab.com/qemu-project/qemu
synced 2024-09-06 18:05:37 +00:00
![Paolo Bonzini](/assets/img/avatar_default.png)
Block layer graph operations are always run under BQL in the main loop. This is proved by the assertion qemu_in_main_thread() and its wrapper macro GLOBAL_STATE_CODE. However, there are also concurrent coroutines running in other iothreads that always try to traverse the graph. Currently this is protected (among various other things) by the AioContext lock, but once this is removed, we need to make sure that reads do not happen while modifying the graph. We distinguish between writer (main loop, under BQL) that modifies the graph, and readers (all other coroutines running in various AioContext), that go through the graph edges, reading ->parents and->children. The writer (main loop) has "exclusive" access, so it first waits for any current read to finish, and then prevents incoming ones from entering while it has the exclusive access. The readers (coroutines in multiple AioContext) are free to access the graph as long the writer is not modifying the graph. In case it is, they go in a CoQueue and sleep until the writer is done. If a coroutine changes AioContext, the counter in the original and new AioContext are left intact, since the writer does not care where the reader is, but only if there is one. As a result, some AioContexts might have a negative reader count, to balance the positive count of the AioContext that took the lock. This also means that when an AioContext is deleted it may have a nonzero reader count. In that case we transfer the count to a global shared counter so that the writer is always aware of all readers. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com> Message-Id: <20221207131838.239125-3-kwolf@redhat.com> Reviewed-by: Emanuele Giuseppe Esposito <eesposit@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
157 lines
4.1 KiB
Meson
157 lines
4.1 KiB
Meson
block_ss.add(genh)
|
|
block_ss.add(files(
|
|
'accounting.c',
|
|
'aio_task.c',
|
|
'amend.c',
|
|
'backup.c',
|
|
'copy-before-write.c',
|
|
'blkdebug.c',
|
|
'blklogwrites.c',
|
|
'blkverify.c',
|
|
'block-backend.c',
|
|
'block-copy.c',
|
|
'graph-lock.c',
|
|
'commit.c',
|
|
'copy-on-read.c',
|
|
'preallocate.c',
|
|
'progress_meter.c',
|
|
'create.c',
|
|
'crypto.c',
|
|
'dirty-bitmap.c',
|
|
'filter-compress.c',
|
|
'io.c',
|
|
'mirror.c',
|
|
'nbd.c',
|
|
'null.c',
|
|
'qapi.c',
|
|
'qcow2-bitmap.c',
|
|
'qcow2-cache.c',
|
|
'qcow2-cluster.c',
|
|
'qcow2-refcount.c',
|
|
'qcow2-snapshot.c',
|
|
'qcow2-threads.c',
|
|
'qcow2.c',
|
|
'quorum.c',
|
|
'raw-format.c',
|
|
'reqlist.c',
|
|
'snapshot.c',
|
|
'snapshot-access.c',
|
|
'throttle-groups.c',
|
|
'throttle.c',
|
|
'vhdx-endian.c',
|
|
'vhdx-log.c',
|
|
'vhdx.c',
|
|
'vmdk.c',
|
|
'vpc.c',
|
|
'write-threshold.c',
|
|
), zstd, zlib, gnutls)
|
|
|
|
softmmu_ss.add(when: 'CONFIG_TCG', if_true: files('blkreplay.c'))
|
|
softmmu_ss.add(files('block-ram-registrar.c'))
|
|
|
|
if get_option('qcow1').allowed()
|
|
block_ss.add(files('qcow.c'))
|
|
endif
|
|
if get_option('vdi').allowed()
|
|
block_ss.add(files('vdi.c'))
|
|
endif
|
|
if get_option('cloop').allowed()
|
|
block_ss.add(files('cloop.c'))
|
|
endif
|
|
if get_option('bochs').allowed()
|
|
block_ss.add(files('bochs.c'))
|
|
endif
|
|
if get_option('vvfat').allowed()
|
|
block_ss.add(files('vvfat.c'))
|
|
endif
|
|
if get_option('dmg').allowed()
|
|
block_ss.add(files('dmg.c'))
|
|
endif
|
|
if get_option('qed').allowed()
|
|
block_ss.add(files(
|
|
'qed-check.c',
|
|
'qed-cluster.c',
|
|
'qed-l2-cache.c',
|
|
'qed-table.c',
|
|
'qed.c',
|
|
))
|
|
endif
|
|
if get_option('parallels').allowed()
|
|
block_ss.add(files('parallels.c', 'parallels-ext.c'))
|
|
endif
|
|
|
|
block_ss.add(when: 'CONFIG_WIN32', if_true: files('file-win32.c', 'win32-aio.c'))
|
|
block_ss.add(when: 'CONFIG_POSIX', if_true: [files('file-posix.c'), coref, iokit])
|
|
block_ss.add(when: libiscsi, if_true: files('iscsi-opts.c'))
|
|
block_ss.add(when: 'CONFIG_LINUX', if_true: files('nvme.c'))
|
|
if not get_option('replication').disabled()
|
|
block_ss.add(files('replication.c'))
|
|
endif
|
|
block_ss.add(when: libaio, if_true: files('linux-aio.c'))
|
|
block_ss.add(when: linux_io_uring, if_true: files('io_uring.c'))
|
|
|
|
block_modules = {}
|
|
|
|
modsrc = []
|
|
foreach m : [
|
|
[blkio, 'blkio', files('blkio.c')],
|
|
[curl, 'curl', files('curl.c')],
|
|
[glusterfs, 'gluster', files('gluster.c')],
|
|
[libiscsi, 'iscsi', [files('iscsi.c'), libm]],
|
|
[libnfs, 'nfs', files('nfs.c')],
|
|
[libssh, 'ssh', files('ssh.c')],
|
|
[rbd, 'rbd', files('rbd.c')],
|
|
]
|
|
if m[0].found()
|
|
module_ss = ss.source_set()
|
|
module_ss.add(when: m[0], if_true: m[2])
|
|
if enable_modules
|
|
modsrc += module_ss.all_sources()
|
|
endif
|
|
block_modules += {m[1] : module_ss}
|
|
endif
|
|
endforeach
|
|
|
|
# those are not exactly regular block modules, so treat them apart
|
|
if get_option('dmg').allowed()
|
|
foreach m : [
|
|
[liblzfse, 'dmg-lzfse', liblzfse, 'dmg-lzfse.c'],
|
|
[libbzip2, 'dmg-bz2', [glib, libbzip2], 'dmg-bz2.c']
|
|
]
|
|
if m[0].found()
|
|
module_ss = ss.source_set()
|
|
module_ss.add(when: m[2], if_true: files(m[3]))
|
|
block_modules += {m[1] : module_ss}
|
|
endif
|
|
endforeach
|
|
endif
|
|
|
|
module_block_py = find_program('../scripts/modules/module_block.py')
|
|
module_block_h = custom_target('module_block.h',
|
|
output: 'module_block.h',
|
|
input: modsrc,
|
|
command: [module_block_py, '@OUTPUT0@', modsrc])
|
|
block_ss.add(module_block_h)
|
|
|
|
wrapper_py = find_program('../scripts/block-coroutine-wrapper.py')
|
|
block_gen_c = custom_target('block-gen.c',
|
|
output: 'block-gen.c',
|
|
input: files(
|
|
'../include/block/block-io.h',
|
|
'../include/block/dirty-bitmap.h',
|
|
'../include/block/block-global-state.h',
|
|
'../include/sysemu/block-backend-io.h',
|
|
'coroutines.h'
|
|
),
|
|
command: [wrapper_py, '@OUTPUT@', '@INPUT@'])
|
|
block_ss.add(block_gen_c)
|
|
|
|
block_ss.add(files('stream.c'))
|
|
|
|
softmmu_ss.add(files('qapi-sysemu.c'))
|
|
|
|
subdir('export')
|
|
subdir('monitor')
|
|
|
|
modules += {'block': block_modules}
|