block: Mark read/write in block/io.c GRAPH_RDLOCK

This adds GRAPH_RDLOCK annotations to declare that callers of
bdrv_driver_*() need to hold a reader lock for the graph. It doesn't add
the annotation to public functions yet.

For some places, we know that they will hold the lock, but we don't have
the GRAPH_RDLOCK annotations yet. In this case, add assume_graph_lock()
with a FIXME comment. These places will be removed once everything is
properly annotated.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-Id: <20230203152202.49054-11-kwolf@redhat.com>
Reviewed-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
Kevin Wolf 2023-02-03 16:21:49 +01:00
parent abaf8b750b
commit 7b1fb72e2c
10 changed files with 101 additions and 111 deletions

View File

@ -160,6 +160,7 @@ void bdrv_refresh_limits(BlockDriverState *bs, Transaction *tran, Error **errp)
bool have_limits; bool have_limits;
GLOBAL_STATE_CODE(); GLOBAL_STATE_CODE();
assume_graph_lock(); /* FIXME */
if (tran) { if (tran) {
BdrvRefreshLimitsState *s = g_new(BdrvRefreshLimitsState, 1); BdrvRefreshLimitsState *s = g_new(BdrvRefreshLimitsState, 1);
@ -961,10 +962,9 @@ static void bdrv_co_io_em_complete(void *opaque, int ret)
aio_co_wake(co->coroutine); aio_co_wake(co->coroutine);
} }
static int coroutine_fn bdrv_driver_preadv(BlockDriverState *bs, static int coroutine_fn GRAPH_RDLOCK
int64_t offset, int64_t bytes, bdrv_driver_preadv(BlockDriverState *bs, int64_t offset, int64_t bytes,
QEMUIOVector *qiov, QEMUIOVector *qiov, size_t qiov_offset, int flags)
size_t qiov_offset, int flags)
{ {
BlockDriver *drv = bs->drv; BlockDriver *drv = bs->drv;
int64_t sector_num; int64_t sector_num;
@ -1030,10 +1030,9 @@ out:
return ret; return ret;
} }
static int coroutine_fn bdrv_driver_pwritev(BlockDriverState *bs, static int coroutine_fn GRAPH_RDLOCK
int64_t offset, int64_t bytes, bdrv_driver_pwritev(BlockDriverState *bs, int64_t offset, int64_t bytes,
QEMUIOVector *qiov, QEMUIOVector *qiov, size_t qiov_offset,
size_t qiov_offset,
BdrvRequestFlags flags) BdrvRequestFlags flags)
{ {
BlockDriver *drv = bs->drv; BlockDriver *drv = bs->drv;
@ -1043,8 +1042,6 @@ static int coroutine_fn bdrv_driver_pwritev(BlockDriverState *bs,
QEMUIOVector local_qiov; QEMUIOVector local_qiov;
int ret; int ret;
assume_graph_lock(); /* FIXME */
bdrv_check_qiov_request(offset, bytes, qiov, qiov_offset, &error_abort); bdrv_check_qiov_request(offset, bytes, qiov, qiov_offset, &error_abort);
if (!drv) { if (!drv) {
@ -1114,7 +1111,7 @@ emulate_flags:
return ret; return ret;
} }
static int coroutine_fn static int coroutine_fn GRAPH_RDLOCK
bdrv_driver_pwritev_compressed(BlockDriverState *bs, int64_t offset, bdrv_driver_pwritev_compressed(BlockDriverState *bs, int64_t offset,
int64_t bytes, QEMUIOVector *qiov, int64_t bytes, QEMUIOVector *qiov,
size_t qiov_offset) size_t qiov_offset)
@ -1149,9 +1146,9 @@ bdrv_driver_pwritev_compressed(BlockDriverState *bs, int64_t offset,
return ret; return ret;
} }
static int coroutine_fn bdrv_co_do_copy_on_readv(BdrvChild *child, static int coroutine_fn GRAPH_RDLOCK
int64_t offset, int64_t bytes, QEMUIOVector *qiov, bdrv_co_do_copy_on_readv(BdrvChild *child, int64_t offset, int64_t bytes,
size_t qiov_offset, int flags) QEMUIOVector *qiov, size_t qiov_offset, int flags)
{ {
BlockDriverState *bs = child->bs; BlockDriverState *bs = child->bs;
@ -1172,8 +1169,6 @@ static int coroutine_fn bdrv_co_do_copy_on_readv(BdrvChild *child,
int64_t progress = 0; int64_t progress = 0;
bool skip_write; bool skip_write;
assume_graph_lock(); /* FIXME */
bdrv_check_qiov_request(offset, bytes, qiov, qiov_offset, &error_abort); bdrv_check_qiov_request(offset, bytes, qiov, qiov_offset, &error_abort);
if (!drv) { if (!drv) {
@ -1315,9 +1310,10 @@ err:
* handles copy on read, zeroing after EOF, and fragmentation of large * handles copy on read, zeroing after EOF, and fragmentation of large
* reads; any other features must be implemented by the caller. * reads; any other features must be implemented by the caller.
*/ */
static int coroutine_fn bdrv_aligned_preadv(BdrvChild *child, static int coroutine_fn GRAPH_RDLOCK
BdrvTrackedRequest *req, int64_t offset, int64_t bytes, bdrv_aligned_preadv(BdrvChild *child, BdrvTrackedRequest *req,
int64_t align, QEMUIOVector *qiov, size_t qiov_offset, int flags) int64_t offset, int64_t bytes, int64_t align,
QEMUIOVector *qiov, size_t qiov_offset, int flags)
{ {
BlockDriverState *bs = child->bs; BlockDriverState *bs = child->bs;
int64_t total_bytes, max_bytes; int64_t total_bytes, max_bytes;
@ -1484,10 +1480,9 @@ static bool bdrv_init_padding(BlockDriverState *bs,
return true; return true;
} }
static coroutine_fn int bdrv_padding_rmw_read(BdrvChild *child, static int coroutine_fn GRAPH_RDLOCK
BdrvTrackedRequest *req, bdrv_padding_rmw_read(BdrvChild *child, BdrvTrackedRequest *req,
BdrvRequestPadding *pad, BdrvRequestPadding *pad, bool zero_middle)
bool zero_middle)
{ {
QEMUIOVector local_qiov; QEMUIOVector local_qiov;
BlockDriverState *bs = child->bs; BlockDriverState *bs = child->bs;
@ -1626,6 +1621,8 @@ int coroutine_fn bdrv_co_preadv_part(BdrvChild *child,
int ret; int ret;
IO_CODE(); IO_CODE();
assume_graph_lock(); /* FIXME */
trace_bdrv_co_preadv_part(bs, offset, bytes, flags); trace_bdrv_co_preadv_part(bs, offset, bytes, flags);
if (!bdrv_co_is_inserted(bs)) { if (!bdrv_co_is_inserted(bs)) {
@ -1898,9 +1895,10 @@ bdrv_co_write_req_finish(BdrvChild *child, int64_t offset, int64_t bytes,
* Forwards an already correctly aligned write request to the BlockDriver, * Forwards an already correctly aligned write request to the BlockDriver,
* after possibly fragmenting it. * after possibly fragmenting it.
*/ */
static int coroutine_fn bdrv_aligned_pwritev(BdrvChild *child, static int coroutine_fn GRAPH_RDLOCK
BdrvTrackedRequest *req, int64_t offset, int64_t bytes, bdrv_aligned_pwritev(BdrvChild *child, BdrvTrackedRequest *req,
int64_t align, QEMUIOVector *qiov, size_t qiov_offset, int64_t offset, int64_t bytes, int64_t align,
QEMUIOVector *qiov, size_t qiov_offset,
BdrvRequestFlags flags) BdrvRequestFlags flags)
{ {
BlockDriverState *bs = child->bs; BlockDriverState *bs = child->bs;
@ -1910,8 +1908,6 @@ static int coroutine_fn bdrv_aligned_pwritev(BdrvChild *child,
int64_t bytes_remaining = bytes; int64_t bytes_remaining = bytes;
int max_transfer; int max_transfer;
assume_graph_lock(); /* FIXME */
bdrv_check_qiov_request(offset, bytes, qiov, qiov_offset, &error_abort); bdrv_check_qiov_request(offset, bytes, qiov, qiov_offset, &error_abort);
if (!drv) { if (!drv) {
@ -1987,11 +1983,9 @@ static int coroutine_fn bdrv_aligned_pwritev(BdrvChild *child,
return ret; return ret;
} }
static int coroutine_fn bdrv_co_do_zero_pwritev(BdrvChild *child, static int coroutine_fn GRAPH_RDLOCK
int64_t offset, bdrv_co_do_zero_pwritev(BdrvChild *child, int64_t offset, int64_t bytes,
int64_t bytes, BdrvRequestFlags flags, BdrvTrackedRequest *req)
BdrvRequestFlags flags,
BdrvTrackedRequest *req)
{ {
BlockDriverState *bs = child->bs; BlockDriverState *bs = child->bs;
QEMUIOVector local_qiov; QEMUIOVector local_qiov;
@ -2079,6 +2073,8 @@ int coroutine_fn bdrv_co_pwritev_part(BdrvChild *child,
bool padded = false; bool padded = false;
IO_CODE(); IO_CODE();
assume_graph_lock(); /* FIXME */
trace_bdrv_co_pwritev_part(child->bs, offset, bytes, flags); trace_bdrv_co_pwritev_part(child->bs, offset, bytes, flags);
if (!bdrv_co_is_inserted(bs)) { if (!bdrv_co_is_inserted(bs)) {

View File

@ -320,8 +320,8 @@ static int coroutine_fn parallels_co_block_status(BlockDriverState *bs,
return BDRV_BLOCK_DATA | BDRV_BLOCK_OFFSET_VALID; return BDRV_BLOCK_DATA | BDRV_BLOCK_OFFSET_VALID;
} }
static coroutine_fn int parallels_co_writev(BlockDriverState *bs, static int coroutine_fn GRAPH_RDLOCK
int64_t sector_num, int nb_sectors, parallels_co_writev(BlockDriverState *bs, int64_t sector_num, int nb_sectors,
QEMUIOVector *qiov, int flags) QEMUIOVector *qiov, int flags)
{ {
BDRVParallelsState *s = bs->opaque; BDRVParallelsState *s = bs->opaque;
@ -329,8 +329,6 @@ static coroutine_fn int parallels_co_writev(BlockDriverState *bs,
QEMUIOVector hd_qiov; QEMUIOVector hd_qiov;
int ret = 0; int ret = 0;
assume_graph_lock(); /* FIXME */
qemu_iovec_init(&hd_qiov, qiov->niov); qemu_iovec_init(&hd_qiov, qiov->niov);
while (nb_sectors > 0) { while (nb_sectors > 0) {

View File

@ -617,9 +617,9 @@ static void qcow_refresh_limits(BlockDriverState *bs, Error **errp)
bs->bl.request_alignment = BDRV_SECTOR_SIZE; bs->bl.request_alignment = BDRV_SECTOR_SIZE;
} }
static coroutine_fn int qcow_co_preadv(BlockDriverState *bs, int64_t offset, static int coroutine_fn GRAPH_RDLOCK
int64_t bytes, QEMUIOVector *qiov, qcow_co_preadv(BlockDriverState *bs, int64_t offset, int64_t bytes,
BdrvRequestFlags flags) QEMUIOVector *qiov, BdrvRequestFlags flags)
{ {
BDRVQcowState *s = bs->opaque; BDRVQcowState *s = bs->opaque;
int offset_in_cluster; int offset_in_cluster;
@ -628,8 +628,6 @@ static coroutine_fn int qcow_co_preadv(BlockDriverState *bs, int64_t offset,
uint8_t *buf; uint8_t *buf;
void *orig_buf; void *orig_buf;
assume_graph_lock(); /* FIXME */
if (qiov->niov > 1) { if (qiov->niov > 1) {
buf = orig_buf = qemu_try_blockalign(bs, qiov->size); buf = orig_buf = qemu_try_blockalign(bs, qiov->size);
if (buf == NULL) { if (buf == NULL) {
@ -715,9 +713,9 @@ static coroutine_fn int qcow_co_preadv(BlockDriverState *bs, int64_t offset,
return ret; return ret;
} }
static coroutine_fn int qcow_co_pwritev(BlockDriverState *bs, int64_t offset, static int coroutine_fn GRAPH_RDLOCK
int64_t bytes, QEMUIOVector *qiov, qcow_co_pwritev(BlockDriverState *bs, int64_t offset, int64_t bytes,
BdrvRequestFlags flags) QEMUIOVector *qiov, BdrvRequestFlags flags)
{ {
BDRVQcowState *s = bs->opaque; BDRVQcowState *s = bs->opaque;
int offset_in_cluster; int offset_in_cluster;
@ -726,8 +724,6 @@ static coroutine_fn int qcow_co_pwritev(BlockDriverState *bs, int64_t offset,
uint8_t *buf; uint8_t *buf;
void *orig_buf; void *orig_buf;
assume_graph_lock(); /* FIXME */
s->cluster_cache_offset = -1; /* disable compressed cache */ s->cluster_cache_offset = -1; /* disable compressed cache */
/* We must always copy the iov when encrypting, so we /* We must always copy the iov when encrypting, so we
@ -1048,7 +1044,7 @@ static int qcow_make_empty(BlockDriverState *bs)
/* XXX: put compressed sectors first, then all the cluster aligned /* XXX: put compressed sectors first, then all the cluster aligned
tables to avoid losing bytes in alignment */ tables to avoid losing bytes in alignment */
static coroutine_fn int static int coroutine_fn GRAPH_RDLOCK
qcow_co_pwritev_compressed(BlockDriverState *bs, int64_t offset, int64_t bytes, qcow_co_pwritev_compressed(BlockDriverState *bs, int64_t offset, int64_t bytes,
QEMUIOVector *qiov) QEMUIOVector *qiov)
{ {
@ -1058,8 +1054,6 @@ qcow_co_pwritev_compressed(BlockDriverState *bs, int64_t offset, int64_t bytes,
uint8_t *buf, *out_buf; uint8_t *buf, *out_buf;
uint64_t cluster_offset; uint64_t cluster_offset;
assume_graph_lock(); /* FIXME */
buf = qemu_blockalign(bs, s->cluster_size); buf = qemu_blockalign(bs, s->cluster_size);
if (bytes != s->cluster_size) { if (bytes != s->cluster_size) {
if (bytes > s->cluster_size || if (bytes > s->cluster_size ||

View File

@ -491,10 +491,9 @@ static int count_contiguous_subclusters(BlockDriverState *bs, int nb_clusters,
return count; return count;
} }
static int coroutine_fn do_perform_cow_read(BlockDriverState *bs, static int coroutine_fn GRAPH_RDLOCK
uint64_t src_cluster_offset, do_perform_cow_read(BlockDriverState *bs, uint64_t src_cluster_offset,
unsigned offset_in_cluster, unsigned offset_in_cluster, QEMUIOVector *qiov)
QEMUIOVector *qiov)
{ {
int ret; int ret;
@ -886,7 +885,8 @@ int coroutine_fn qcow2_alloc_compressed_cluster_offset(BlockDriverState *bs,
return 0; return 0;
} }
static int coroutine_fn perform_cow(BlockDriverState *bs, QCowL2Meta *m) static int coroutine_fn GRAPH_RDLOCK
perform_cow(BlockDriverState *bs, QCowL2Meta *m)
{ {
BDRVQcow2State *s = bs->opaque; BDRVQcow2State *s = bs->opaque;
Qcow2COWRegion *start = &m->cow_start; Qcow2COWRegion *start = &m->cow_start;

View File

@ -2137,9 +2137,8 @@ static int coroutine_fn qcow2_co_block_status(BlockDriverState *bs,
return status; return status;
} }
static coroutine_fn int qcow2_handle_l2meta(BlockDriverState *bs, static int coroutine_fn GRAPH_RDLOCK
QCowL2Meta **pl2meta, qcow2_handle_l2meta(BlockDriverState *bs, QCowL2Meta **pl2meta, bool link_l2)
bool link_l2)
{ {
int ret = 0; int ret = 0;
QCowL2Meta *l2meta = *pl2meta; QCowL2Meta *l2meta = *pl2meta;
@ -2617,9 +2616,10 @@ static coroutine_fn GRAPH_RDLOCK int qcow2_co_pwritev_task_entry(AioTask *task)
t->l2meta); t->l2meta);
} }
static coroutine_fn int qcow2_co_pwritev_part( static int coroutine_fn GRAPH_RDLOCK
BlockDriverState *bs, int64_t offset, int64_t bytes, qcow2_co_pwritev_part(BlockDriverState *bs, int64_t offset, int64_t bytes,
QEMUIOVector *qiov, size_t qiov_offset, BdrvRequestFlags flags) QEMUIOVector *qiov, size_t qiov_offset,
BdrvRequestFlags flags)
{ {
BDRVQcow2State *s = bs->opaque; BDRVQcow2State *s = bs->opaque;
int offset_in_cluster; int offset_in_cluster;
@ -2629,8 +2629,6 @@ static coroutine_fn int qcow2_co_pwritev_part(
QCowL2Meta *l2meta = NULL; QCowL2Meta *l2meta = NULL;
AioTaskPool *aio = NULL; AioTaskPool *aio = NULL;
assume_graph_lock(); /* FIXME */
trace_qcow2_writev_start_req(qemu_coroutine_self(), offset, bytes); trace_qcow2_writev_start_req(qemu_coroutine_self(), offset, bytes);
while (bytes != 0 && aio_task_pool_status(aio) == 0) { while (bytes != 0 && aio_task_pool_status(aio) == 0) {
@ -4160,6 +4158,7 @@ qcow2_co_copy_range_to(BlockDriverState *bs,
uint64_t host_offset; uint64_t host_offset;
QCowL2Meta *l2meta = NULL; QCowL2Meta *l2meta = NULL;
assume_graph_lock(); /* FIXME */
assert(!bs->encrypted); assert(!bs->encrypted);
qemu_co_mutex_lock(&s->lock); qemu_co_mutex_lock(&s->lock);
@ -4591,7 +4590,7 @@ fail:
return ret; return ret;
} }
static coroutine_fn int static int coroutine_fn GRAPH_RDLOCK
qcow2_co_pwritev_compressed_task(BlockDriverState *bs, qcow2_co_pwritev_compressed_task(BlockDriverState *bs,
uint64_t offset, uint64_t bytes, uint64_t offset, uint64_t bytes,
QEMUIOVector *qiov, size_t qiov_offset) QEMUIOVector *qiov, size_t qiov_offset)
@ -4655,7 +4654,13 @@ fail:
return ret; return ret;
} }
static coroutine_fn int qcow2_co_pwritev_compressed_task_entry(AioTask *task) /*
* This function can count as GRAPH_RDLOCK because
* qcow2_co_pwritev_compressed_part() holds the graph lock and keeps it until
* this coroutine has terminated.
*/
static int coroutine_fn GRAPH_RDLOCK
qcow2_co_pwritev_compressed_task_entry(AioTask *task)
{ {
Qcow2AioTask *t = container_of(task, Qcow2AioTask, task); Qcow2AioTask *t = container_of(task, Qcow2AioTask, task);
@ -4669,7 +4674,7 @@ static coroutine_fn int qcow2_co_pwritev_compressed_task_entry(AioTask *task)
* XXX: put compressed sectors first, then all the cluster aligned * XXX: put compressed sectors first, then all the cluster aligned
* tables to avoid losing bytes in alignment * tables to avoid losing bytes in alignment
*/ */
static coroutine_fn int static int coroutine_fn GRAPH_RDLOCK
qcow2_co_pwritev_compressed_part(BlockDriverState *bs, qcow2_co_pwritev_compressed_part(BlockDriverState *bs,
int64_t offset, int64_t bytes, int64_t offset, int64_t bytes,
QEMUIOVector *qiov, size_t qiov_offset) QEMUIOVector *qiov, size_t qiov_offset)
@ -4678,8 +4683,6 @@ qcow2_co_pwritev_compressed_part(BlockDriverState *bs,
AioTaskPool *aio = NULL; AioTaskPool *aio = NULL;
int ret = 0; int ret = 0;
assume_graph_lock(); /* FIXME */
if (has_data_file(bs)) { if (has_data_file(bs)) {
return -ENOTSUP; return -ENOTSUP;
} }
@ -5296,8 +5299,8 @@ static int64_t qcow2_check_vmstate_request(BlockDriverState *bs,
return pos; return pos;
} }
static coroutine_fn int qcow2_co_save_vmstate(BlockDriverState *bs, static int coroutine_fn GRAPH_RDLOCK
QEMUIOVector *qiov, int64_t pos) qcow2_co_save_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos)
{ {
int64_t offset = qcow2_check_vmstate_request(bs, qiov, pos); int64_t offset = qcow2_check_vmstate_request(bs, qiov, pos);
if (offset < 0) { if (offset < 0) {
@ -5308,8 +5311,8 @@ static coroutine_fn int qcow2_co_save_vmstate(BlockDriverState *bs,
return bs->drv->bdrv_co_pwritev_part(bs, offset, qiov->size, qiov, 0, 0); return bs->drv->bdrv_co_pwritev_part(bs, offset, qiov->size, qiov, 0, 0);
} }
static coroutine_fn int qcow2_co_load_vmstate(BlockDriverState *bs, static int coroutine_fn GRAPH_RDLOCK
QEMUIOVector *qiov, int64_t pos) qcow2_co_load_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos)
{ {
int64_t offset = qcow2_check_vmstate_request(bs, qiov, pos); int64_t offset = qcow2_check_vmstate_request(bs, qiov, pos);
if (offset < 0) { if (offset < 0) {

View File

@ -921,8 +921,9 @@ int coroutine_fn qcow2_alloc_compressed_cluster_offset(BlockDriverState *bs,
void qcow2_parse_compressed_l2_entry(BlockDriverState *bs, uint64_t l2_entry, void qcow2_parse_compressed_l2_entry(BlockDriverState *bs, uint64_t l2_entry,
uint64_t *coffset, int *csize); uint64_t *coffset, int *csize);
int coroutine_fn qcow2_alloc_cluster_link_l2(BlockDriverState *bs, int coroutine_fn GRAPH_RDLOCK
QCowL2Meta *m); qcow2_alloc_cluster_link_l2(BlockDriverState *bs, QCowL2Meta *m);
void qcow2_alloc_cluster_abort(BlockDriverState *bs, QCowL2Meta *m); void qcow2_alloc_cluster_abort(BlockDriverState *bs, QCowL2Meta *m);
int qcow2_cluster_discard(BlockDriverState *bs, uint64_t offset, int qcow2_cluster_discard(BlockDriverState *bs, uint64_t offset,
uint64_t bytes, enum qcow2_discard_type type, uint64_t bytes, enum qcow2_discard_type type,

View File

@ -1404,19 +1404,17 @@ qed_co_request(BlockDriverState *bs, int64_t sector_num, QEMUIOVector *qiov,
return qed_aio_next_io(&acb); return qed_aio_next_io(&acb);
} }
static int coroutine_fn bdrv_qed_co_readv(BlockDriverState *bs, static int coroutine_fn GRAPH_RDLOCK
int64_t sector_num, int nb_sectors, bdrv_qed_co_readv(BlockDriverState *bs, int64_t sector_num, int nb_sectors,
QEMUIOVector *qiov) QEMUIOVector *qiov)
{ {
assume_graph_lock(); /* FIXME */
return qed_co_request(bs, sector_num, qiov, nb_sectors, 0); return qed_co_request(bs, sector_num, qiov, nb_sectors, 0);
} }
static int coroutine_fn bdrv_qed_co_writev(BlockDriverState *bs, static int coroutine_fn GRAPH_RDLOCK
int64_t sector_num, int nb_sectors, bdrv_qed_co_writev(BlockDriverState *bs, int64_t sector_num, int nb_sectors,
QEMUIOVector *qiov, int flags) QEMUIOVector *qiov, int flags)
{ {
assume_graph_lock(); /* FIXME */
return qed_co_request(bs, sector_num, qiov, nb_sectors, QED_AIOCB_WRITE); return qed_co_request(bs, sector_num, qiov, nb_sectors, QED_AIOCB_WRITE);
} }

View File

@ -718,16 +718,14 @@ static void coroutine_fn GRAPH_RDLOCK write_quorum_entry(void *opaque)
} }
} }
static int coroutine_fn quorum_co_pwritev(BlockDriverState *bs, int64_t offset, static int coroutine_fn GRAPH_RDLOCK
int64_t bytes, QEMUIOVector *qiov, quorum_co_pwritev(BlockDriverState *bs, int64_t offset, int64_t bytes,
BdrvRequestFlags flags) QEMUIOVector *qiov, BdrvRequestFlags flags)
{ {
BDRVQuorumState *s = bs->opaque; BDRVQuorumState *s = bs->opaque;
QuorumAIOCB *acb = quorum_aio_get(bs, qiov, offset, bytes, flags); QuorumAIOCB *acb = quorum_aio_get(bs, qiov, offset, bytes, flags);
int i, ret; int i, ret;
assume_graph_lock(); /* FIXME */
for (i = 0; i < s->num_children; i++) { for (i = 0; i < s->num_children; i++) {
Coroutine *co; Coroutine *co;
QuorumCo data = { QuorumCo data = {

View File

@ -2128,12 +2128,10 @@ vmdk_co_pwritev(BlockDriverState *bs, int64_t offset, int64_t bytes,
return ret; return ret;
} }
static int coroutine_fn static int coroutine_fn GRAPH_RDLOCK
vmdk_co_pwritev_compressed(BlockDriverState *bs, int64_t offset, int64_t bytes, vmdk_co_pwritev_compressed(BlockDriverState *bs, int64_t offset, int64_t bytes,
QEMUIOVector *qiov) QEMUIOVector *qiov)
{ {
assume_graph_lock(); /* FIXME */
if (bytes == 0) { if (bytes == 0) {
/* The caller will write bytes 0 to signal EOF. /* The caller will write bytes 0 to signal EOF.
* When receive it, we align EOF to a sector boundary. */ * When receive it, we align EOF to a sector boundary. */

View File

@ -471,12 +471,14 @@ struct BlockDriver {
Error **errp); Error **errp);
/* aio */ /* aio */
BlockAIOCB *(*bdrv_aio_preadv)(BlockDriverState *bs, BlockAIOCB * GRAPH_RDLOCK_PTR (*bdrv_aio_preadv)(BlockDriverState *bs,
int64_t offset, int64_t bytes, QEMUIOVector *qiov, int64_t offset, int64_t bytes, QEMUIOVector *qiov,
BdrvRequestFlags flags, BlockCompletionFunc *cb, void *opaque); BdrvRequestFlags flags, BlockCompletionFunc *cb, void *opaque);
BlockAIOCB *(*bdrv_aio_pwritev)(BlockDriverState *bs,
BlockAIOCB * GRAPH_RDLOCK_PTR (*bdrv_aio_pwritev)(BlockDriverState *bs,
int64_t offset, int64_t bytes, QEMUIOVector *qiov, int64_t offset, int64_t bytes, QEMUIOVector *qiov,
BdrvRequestFlags flags, BlockCompletionFunc *cb, void *opaque); BdrvRequestFlags flags, BlockCompletionFunc *cb, void *opaque);
BlockAIOCB * GRAPH_RDLOCK_PTR (*bdrv_aio_flush)( BlockAIOCB * GRAPH_RDLOCK_PTR (*bdrv_aio_flush)(
BlockDriverState *bs, BlockCompletionFunc *cb, void *opaque); BlockDriverState *bs, BlockCompletionFunc *cb, void *opaque);
@ -484,7 +486,7 @@ struct BlockDriver {
BlockDriverState *bs, int64_t offset, int bytes, BlockDriverState *bs, int64_t offset, int bytes,
BlockCompletionFunc *cb, void *opaque); BlockCompletionFunc *cb, void *opaque);
int coroutine_fn (*bdrv_co_readv)(BlockDriverState *bs, int coroutine_fn GRAPH_RDLOCK_PTR (*bdrv_co_readv)(BlockDriverState *bs,
int64_t sector_num, int nb_sectors, QEMUIOVector *qiov); int64_t sector_num, int nb_sectors, QEMUIOVector *qiov);
/** /**
@ -502,16 +504,16 @@ struct BlockDriver {
* *
* The buffer in @qiov may point directly to guest memory. * The buffer in @qiov may point directly to guest memory.
*/ */
int coroutine_fn (*bdrv_co_preadv)(BlockDriverState *bs, int coroutine_fn GRAPH_RDLOCK_PTR (*bdrv_co_preadv)(BlockDriverState *bs,
int64_t offset, int64_t bytes, QEMUIOVector *qiov, int64_t offset, int64_t bytes, QEMUIOVector *qiov,
BdrvRequestFlags flags); BdrvRequestFlags flags);
int coroutine_fn (*bdrv_co_preadv_part)(BlockDriverState *bs, int coroutine_fn GRAPH_RDLOCK_PTR (*bdrv_co_preadv_part)(
int64_t offset, int64_t bytes, BlockDriverState *bs, int64_t offset, int64_t bytes,
QEMUIOVector *qiov, size_t qiov_offset, QEMUIOVector *qiov, size_t qiov_offset,
BdrvRequestFlags flags); BdrvRequestFlags flags);
int coroutine_fn (*bdrv_co_writev)(BlockDriverState *bs, int coroutine_fn GRAPH_RDLOCK_PTR (*bdrv_co_writev)(BlockDriverState *bs,
int64_t sector_num, int nb_sectors, QEMUIOVector *qiov, int64_t sector_num, int nb_sectors, QEMUIOVector *qiov,
int flags); int flags);
/** /**
@ -529,12 +531,12 @@ struct BlockDriver {
* *
* The buffer in @qiov may point directly to guest memory. * The buffer in @qiov may point directly to guest memory.
*/ */
int coroutine_fn (*bdrv_co_pwritev)(BlockDriverState *bs, int coroutine_fn GRAPH_RDLOCK_PTR (*bdrv_co_pwritev)(
int64_t offset, int64_t bytes, QEMUIOVector *qiov, BlockDriverState *bs, int64_t offset, int64_t bytes, QEMUIOVector *qiov,
BdrvRequestFlags flags);
int coroutine_fn (*bdrv_co_pwritev_part)(BlockDriverState *bs,
int64_t offset, int64_t bytes, QEMUIOVector *qiov, size_t qiov_offset,
BdrvRequestFlags flags); BdrvRequestFlags flags);
int coroutine_fn GRAPH_RDLOCK_PTR (*bdrv_co_pwritev_part)(
BlockDriverState *bs, int64_t offset, int64_t bytes, QEMUIOVector *qiov,
size_t qiov_offset, BdrvRequestFlags flags);
/* /*
* Efficiently zero a region of the disk image. Typically an image format * Efficiently zero a region of the disk image. Typically an image format
@ -695,11 +697,13 @@ struct BlockDriver {
BlockMeasureInfo *(*bdrv_measure)(QemuOpts *opts, BlockDriverState *in_bs, BlockMeasureInfo *(*bdrv_measure)(QemuOpts *opts, BlockDriverState *in_bs,
Error **errp); Error **errp);
int coroutine_fn (*bdrv_co_pwritev_compressed)(BlockDriverState *bs, int coroutine_fn GRAPH_RDLOCK_PTR (*bdrv_co_pwritev_compressed)(
int64_t offset, int64_t bytes, QEMUIOVector *qiov); BlockDriverState *bs, int64_t offset, int64_t bytes,
int coroutine_fn (*bdrv_co_pwritev_compressed_part)(BlockDriverState *bs, QEMUIOVector *qiov);
int64_t offset, int64_t bytes, QEMUIOVector *qiov,
size_t qiov_offset); int coroutine_fn GRAPH_RDLOCK_PTR (*bdrv_co_pwritev_compressed_part)(
BlockDriverState *bs, int64_t offset, int64_t bytes,
QEMUIOVector *qiov, size_t qiov_offset);
int coroutine_fn (*bdrv_co_get_info)(BlockDriverState *bs, int coroutine_fn (*bdrv_co_get_info)(BlockDriverState *bs,
BlockDriverInfo *bdi); BlockDriverInfo *bdi);
@ -764,7 +768,7 @@ struct BlockDriver {
BlockDriverState *bs, const char *name, Error **errp); BlockDriverState *bs, const char *name, Error **errp);
}; };
static inline bool block_driver_can_compress(BlockDriver *drv) static inline bool TSA_NO_TSA block_driver_can_compress(BlockDriver *drv)
{ {
return drv->bdrv_co_pwritev_compressed || return drv->bdrv_co_pwritev_compressed ||
drv->bdrv_co_pwritev_compressed_part; drv->bdrv_co_pwritev_compressed_part;