block: use bdrv_co_debug_event in coroutine context
bdrv_co_debug_event was recently introduced, with bdrv_debug_event becoming a wrapper for use in unknown context. Because most of the time bdrv_debug_event is used on a BdrvChild via the wrapper macro BLKDBG_EVENT, introduce a similar macro BLKDBG_CO_EVENT that calls bdrv_co_debug_event, and switch whenever possible. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Message-ID: <20230601115145.196465-13-pbonzini@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
0af02bd107
commit
17362398ee
@ -3011,7 +3011,7 @@ int coroutine_fn bdrv_co_flush(BlockDriverState *bs)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Write back cached data to the OS even with cache=unsafe */
|
/* Write back cached data to the OS even with cache=unsafe */
|
||||||
BLKDBG_EVENT(primary_child, BLKDBG_FLUSH_TO_OS);
|
BLKDBG_CO_EVENT(primary_child, BLKDBG_FLUSH_TO_OS);
|
||||||
if (bs->drv->bdrv_co_flush_to_os) {
|
if (bs->drv->bdrv_co_flush_to_os) {
|
||||||
ret = bs->drv->bdrv_co_flush_to_os(bs);
|
ret = bs->drv->bdrv_co_flush_to_os(bs);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
@ -3029,7 +3029,7 @@ int coroutine_fn bdrv_co_flush(BlockDriverState *bs)
|
|||||||
goto flush_children;
|
goto flush_children;
|
||||||
}
|
}
|
||||||
|
|
||||||
BLKDBG_EVENT(primary_child, BLKDBG_FLUSH_TO_DISK);
|
BLKDBG_CO_EVENT(primary_child, BLKDBG_FLUSH_TO_DISK);
|
||||||
if (!bs->drv) {
|
if (!bs->drv) {
|
||||||
/* bs->drv->bdrv_co_flush() might have ejected the BDS
|
/* bs->drv->bdrv_co_flush() might have ejected the BDS
|
||||||
* (even in case of apparent success) */
|
* (even in case of apparent success) */
|
||||||
|
24
block/qcow.c
24
block/qcow.c
@ -379,7 +379,7 @@ get_cluster_offset(BlockDriverState *bs, uint64_t offset, int allocate,
|
|||||||
/* update the L1 entry */
|
/* update the L1 entry */
|
||||||
s->l1_table[l1_index] = l2_offset;
|
s->l1_table[l1_index] = l2_offset;
|
||||||
tmp = cpu_to_be64(l2_offset);
|
tmp = cpu_to_be64(l2_offset);
|
||||||
BLKDBG_EVENT(bs->file, BLKDBG_L1_UPDATE);
|
BLKDBG_CO_EVENT(bs->file, BLKDBG_L1_UPDATE);
|
||||||
ret = bdrv_co_pwrite_sync(bs->file,
|
ret = bdrv_co_pwrite_sync(bs->file,
|
||||||
s->l1_table_offset + l1_index * sizeof(tmp),
|
s->l1_table_offset + l1_index * sizeof(tmp),
|
||||||
sizeof(tmp), &tmp, 0);
|
sizeof(tmp), &tmp, 0);
|
||||||
@ -410,7 +410,7 @@ get_cluster_offset(BlockDriverState *bs, uint64_t offset, int allocate,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
l2_table = s->l2_cache + (min_index << s->l2_bits);
|
l2_table = s->l2_cache + (min_index << s->l2_bits);
|
||||||
BLKDBG_EVENT(bs->file, BLKDBG_L2_LOAD);
|
BLKDBG_CO_EVENT(bs->file, BLKDBG_L2_LOAD);
|
||||||
if (new_l2_table) {
|
if (new_l2_table) {
|
||||||
memset(l2_table, 0, s->l2_size * sizeof(uint64_t));
|
memset(l2_table, 0, s->l2_size * sizeof(uint64_t));
|
||||||
ret = bdrv_co_pwrite_sync(bs->file, l2_offset,
|
ret = bdrv_co_pwrite_sync(bs->file, l2_offset,
|
||||||
@ -434,7 +434,7 @@ get_cluster_offset(BlockDriverState *bs, uint64_t offset, int allocate,
|
|||||||
((cluster_offset & QCOW_OFLAG_COMPRESSED) && allocate == 1)) {
|
((cluster_offset & QCOW_OFLAG_COMPRESSED) && allocate == 1)) {
|
||||||
if (!allocate)
|
if (!allocate)
|
||||||
return 0;
|
return 0;
|
||||||
BLKDBG_EVENT(bs->file, BLKDBG_CLUSTER_ALLOC);
|
BLKDBG_CO_EVENT(bs->file, BLKDBG_CLUSTER_ALLOC);
|
||||||
assert(QEMU_IS_ALIGNED(n_start | n_end, BDRV_SECTOR_SIZE));
|
assert(QEMU_IS_ALIGNED(n_start | n_end, BDRV_SECTOR_SIZE));
|
||||||
/* allocate a new cluster */
|
/* allocate a new cluster */
|
||||||
if ((cluster_offset & QCOW_OFLAG_COMPRESSED) &&
|
if ((cluster_offset & QCOW_OFLAG_COMPRESSED) &&
|
||||||
@ -451,7 +451,7 @@ get_cluster_offset(BlockDriverState *bs, uint64_t offset, int allocate,
|
|||||||
}
|
}
|
||||||
cluster_offset = QEMU_ALIGN_UP(cluster_offset, s->cluster_size);
|
cluster_offset = QEMU_ALIGN_UP(cluster_offset, s->cluster_size);
|
||||||
/* write the cluster content */
|
/* write the cluster content */
|
||||||
BLKDBG_EVENT(bs->file, BLKDBG_WRITE_AIO);
|
BLKDBG_CO_EVENT(bs->file, BLKDBG_WRITE_AIO);
|
||||||
ret = bdrv_co_pwrite(bs->file, cluster_offset, s->cluster_size,
|
ret = bdrv_co_pwrite(bs->file, cluster_offset, s->cluster_size,
|
||||||
s->cluster_cache, 0);
|
s->cluster_cache, 0);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
@ -491,7 +491,7 @@ get_cluster_offset(BlockDriverState *bs, uint64_t offset, int allocate,
|
|||||||
NULL) < 0) {
|
NULL) < 0) {
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
BLKDBG_EVENT(bs->file, BLKDBG_WRITE_AIO);
|
BLKDBG_CO_EVENT(bs->file, BLKDBG_WRITE_AIO);
|
||||||
ret = bdrv_co_pwrite(bs->file, cluster_offset + i,
|
ret = bdrv_co_pwrite(bs->file, cluster_offset + i,
|
||||||
BDRV_SECTOR_SIZE,
|
BDRV_SECTOR_SIZE,
|
||||||
s->cluster_data, 0);
|
s->cluster_data, 0);
|
||||||
@ -510,9 +510,9 @@ get_cluster_offset(BlockDriverState *bs, uint64_t offset, int allocate,
|
|||||||
tmp = cpu_to_be64(cluster_offset);
|
tmp = cpu_to_be64(cluster_offset);
|
||||||
l2_table[l2_index] = tmp;
|
l2_table[l2_index] = tmp;
|
||||||
if (allocate == 2) {
|
if (allocate == 2) {
|
||||||
BLKDBG_EVENT(bs->file, BLKDBG_L2_UPDATE_COMPRESSED);
|
BLKDBG_CO_EVENT(bs->file, BLKDBG_L2_UPDATE_COMPRESSED);
|
||||||
} else {
|
} else {
|
||||||
BLKDBG_EVENT(bs->file, BLKDBG_L2_UPDATE);
|
BLKDBG_CO_EVENT(bs->file, BLKDBG_L2_UPDATE);
|
||||||
}
|
}
|
||||||
ret = bdrv_co_pwrite_sync(bs->file, l2_offset + l2_index * sizeof(tmp),
|
ret = bdrv_co_pwrite_sync(bs->file, l2_offset + l2_index * sizeof(tmp),
|
||||||
sizeof(tmp), &tmp, 0);
|
sizeof(tmp), &tmp, 0);
|
||||||
@ -595,7 +595,7 @@ decompress_cluster(BlockDriverState *bs, uint64_t cluster_offset)
|
|||||||
if (s->cluster_cache_offset != coffset) {
|
if (s->cluster_cache_offset != coffset) {
|
||||||
csize = cluster_offset >> (63 - s->cluster_bits);
|
csize = cluster_offset >> (63 - s->cluster_bits);
|
||||||
csize &= (s->cluster_size - 1);
|
csize &= (s->cluster_size - 1);
|
||||||
BLKDBG_EVENT(bs->file, BLKDBG_READ_COMPRESSED);
|
BLKDBG_CO_EVENT(bs->file, BLKDBG_READ_COMPRESSED);
|
||||||
ret = bdrv_co_pread(bs->file, coffset, csize, s->cluster_data, 0);
|
ret = bdrv_co_pread(bs->file, coffset, csize, s->cluster_data, 0);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return -1;
|
return -1;
|
||||||
@ -657,7 +657,7 @@ qcow_co_preadv(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
|||||||
/* read from the base image */
|
/* read from the base image */
|
||||||
qemu_co_mutex_unlock(&s->lock);
|
qemu_co_mutex_unlock(&s->lock);
|
||||||
/* qcow2 emits this on bs->file instead of bs->backing */
|
/* qcow2 emits this on bs->file instead of bs->backing */
|
||||||
BLKDBG_EVENT(bs->file, BLKDBG_READ_BACKING_AIO);
|
BLKDBG_CO_EVENT(bs->file, BLKDBG_READ_BACKING_AIO);
|
||||||
ret = bdrv_co_pread(bs->backing, offset, n, buf, 0);
|
ret = bdrv_co_pread(bs->backing, offset, n, buf, 0);
|
||||||
qemu_co_mutex_lock(&s->lock);
|
qemu_co_mutex_lock(&s->lock);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
@ -680,7 +680,7 @@ qcow_co_preadv(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
qemu_co_mutex_unlock(&s->lock);
|
qemu_co_mutex_unlock(&s->lock);
|
||||||
BLKDBG_EVENT(bs->file, BLKDBG_READ_AIO);
|
BLKDBG_CO_EVENT(bs->file, BLKDBG_READ_AIO);
|
||||||
ret = bdrv_co_pread(bs->file, cluster_offset + offset_in_cluster,
|
ret = bdrv_co_pread(bs->file, cluster_offset + offset_in_cluster,
|
||||||
n, buf, 0);
|
n, buf, 0);
|
||||||
qemu_co_mutex_lock(&s->lock);
|
qemu_co_mutex_lock(&s->lock);
|
||||||
@ -765,7 +765,7 @@ qcow_co_pwritev(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
|||||||
}
|
}
|
||||||
|
|
||||||
qemu_co_mutex_unlock(&s->lock);
|
qemu_co_mutex_unlock(&s->lock);
|
||||||
BLKDBG_EVENT(bs->file, BLKDBG_WRITE_AIO);
|
BLKDBG_CO_EVENT(bs->file, BLKDBG_WRITE_AIO);
|
||||||
ret = bdrv_co_pwrite(bs->file, cluster_offset + offset_in_cluster,
|
ret = bdrv_co_pwrite(bs->file, cluster_offset + offset_in_cluster,
|
||||||
n, buf, 0);
|
n, buf, 0);
|
||||||
qemu_co_mutex_lock(&s->lock);
|
qemu_co_mutex_lock(&s->lock);
|
||||||
@ -1114,7 +1114,7 @@ qcow_co_pwritev_compressed(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
|||||||
}
|
}
|
||||||
cluster_offset &= s->cluster_offset_mask;
|
cluster_offset &= s->cluster_offset_mask;
|
||||||
|
|
||||||
BLKDBG_EVENT(bs->file, BLKDBG_WRITE_COMPRESSED);
|
BLKDBG_CO_EVENT(bs->file, BLKDBG_WRITE_COMPRESSED);
|
||||||
ret = bdrv_co_pwrite(bs->file, cluster_offset, out_len, out_buf, 0);
|
ret = bdrv_co_pwrite(bs->file, cluster_offset, out_len, out_buf, 0);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
goto fail;
|
goto fail;
|
||||||
|
@ -48,7 +48,7 @@ int coroutine_fn qcow2_shrink_l1_table(BlockDriverState *bs,
|
|||||||
fprintf(stderr, "shrink l1_table from %d to %d\n", s->l1_size, new_l1_size);
|
fprintf(stderr, "shrink l1_table from %d to %d\n", s->l1_size, new_l1_size);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
BLKDBG_EVENT(bs->file, BLKDBG_L1_SHRINK_WRITE_TABLE);
|
BLKDBG_CO_EVENT(bs->file, BLKDBG_L1_SHRINK_WRITE_TABLE);
|
||||||
ret = bdrv_co_pwrite_zeroes(bs->file,
|
ret = bdrv_co_pwrite_zeroes(bs->file,
|
||||||
s->l1_table_offset + new_l1_size * L1E_SIZE,
|
s->l1_table_offset + new_l1_size * L1E_SIZE,
|
||||||
(s->l1_size - new_l1_size) * L1E_SIZE, 0);
|
(s->l1_size - new_l1_size) * L1E_SIZE, 0);
|
||||||
@ -61,7 +61,7 @@ int coroutine_fn qcow2_shrink_l1_table(BlockDriverState *bs,
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
BLKDBG_EVENT(bs->file, BLKDBG_L1_SHRINK_FREE_L2_CLUSTERS);
|
BLKDBG_CO_EVENT(bs->file, BLKDBG_L1_SHRINK_FREE_L2_CLUSTERS);
|
||||||
for (i = s->l1_size - 1; i > new_l1_size - 1; i--) {
|
for (i = s->l1_size - 1; i > new_l1_size - 1; i--) {
|
||||||
if ((s->l1_table[i] & L1E_OFFSET_MASK) == 0) {
|
if ((s->l1_table[i] & L1E_OFFSET_MASK) == 0) {
|
||||||
continue;
|
continue;
|
||||||
@ -501,7 +501,7 @@ do_perform_cow_read(BlockDriverState *bs, uint64_t src_cluster_offset,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
BLKDBG_EVENT(bs->file, BLKDBG_COW_READ);
|
BLKDBG_CO_EVENT(bs->file, BLKDBG_COW_READ);
|
||||||
|
|
||||||
if (!bs->drv) {
|
if (!bs->drv) {
|
||||||
return -ENOMEDIUM;
|
return -ENOMEDIUM;
|
||||||
@ -551,7 +551,7 @@ do_perform_cow_write(BlockDriverState *bs, uint64_t cluster_offset,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
BLKDBG_EVENT(bs->file, BLKDBG_COW_WRITE);
|
BLKDBG_CO_EVENT(bs->file, BLKDBG_COW_WRITE);
|
||||||
ret = bdrv_co_pwritev(s->data_file, cluster_offset + offset_in_cluster,
|
ret = bdrv_co_pwritev(s->data_file, cluster_offset + offset_in_cluster,
|
||||||
qiov->size, qiov, 0);
|
qiov->size, qiov, 0);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
@ -871,7 +871,7 @@ qcow2_alloc_compressed_cluster_offset(BlockDriverState *bs, uint64_t offset,
|
|||||||
|
|
||||||
/* compressed clusters never have the copied flag */
|
/* compressed clusters never have the copied flag */
|
||||||
|
|
||||||
BLKDBG_EVENT(bs->file, BLKDBG_L2_UPDATE_COMPRESSED);
|
BLKDBG_CO_EVENT(bs->file, BLKDBG_L2_UPDATE_COMPRESSED);
|
||||||
qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_slice);
|
qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_slice);
|
||||||
set_l2_entry(s, l2_slice, l2_index, cluster_offset);
|
set_l2_entry(s, l2_slice, l2_index, cluster_offset);
|
||||||
if (has_subclusters(s)) {
|
if (has_subclusters(s)) {
|
||||||
@ -991,7 +991,7 @@ perform_cow(BlockDriverState *bs, QCowL2Meta *m)
|
|||||||
/* NOTE: we have a write_aio blkdebug event here followed by
|
/* NOTE: we have a write_aio blkdebug event here followed by
|
||||||
* a cow_write one in do_perform_cow_write(), but there's only
|
* a cow_write one in do_perform_cow_write(), but there's only
|
||||||
* one single I/O operation */
|
* one single I/O operation */
|
||||||
BLKDBG_EVENT(bs->file, BLKDBG_WRITE_AIO);
|
BLKDBG_CO_EVENT(bs->file, BLKDBG_WRITE_AIO);
|
||||||
ret = do_perform_cow_write(bs, m->alloc_offset, start->offset, &qiov);
|
ret = do_perform_cow_write(bs, m->alloc_offset, start->offset, &qiov);
|
||||||
} else {
|
} else {
|
||||||
/* If there's no guest data then write both COW regions separately */
|
/* If there's no guest data then write both COW regions separately */
|
||||||
|
@ -118,7 +118,7 @@ int coroutine_fn qcow2_refcount_init(BlockDriverState *bs)
|
|||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
BLKDBG_EVENT(bs->file, BLKDBG_REFTABLE_LOAD);
|
BLKDBG_CO_EVENT(bs->file, BLKDBG_REFTABLE_LOAD);
|
||||||
ret = bdrv_co_pread(bs->file, s->refcount_table_offset,
|
ret = bdrv_co_pread(bs->file, s->refcount_table_offset,
|
||||||
refcount_table_size2, s->refcount_table, 0);
|
refcount_table_size2, s->refcount_table, 0);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
@ -1076,7 +1076,7 @@ int64_t coroutine_fn GRAPH_RDLOCK qcow2_alloc_bytes(BlockDriverState *bs, int si
|
|||||||
size_t free_in_cluster;
|
size_t free_in_cluster;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
BLKDBG_EVENT(bs->file, BLKDBG_CLUSTER_ALLOC_BYTES);
|
BLKDBG_CO_EVENT(bs->file, BLKDBG_CLUSTER_ALLOC_BYTES);
|
||||||
assert(size > 0 && size <= s->cluster_size);
|
assert(size > 0 && size <= s->cluster_size);
|
||||||
assert(!s->free_byte_offset || offset_into_cluster(s, s->free_byte_offset));
|
assert(!s->free_byte_offset || offset_into_cluster(s, s->free_byte_offset));
|
||||||
|
|
||||||
|
@ -2225,7 +2225,7 @@ qcow2_co_preadv_encrypted(BlockDriverState *bs,
|
|||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
BLKDBG_EVENT(bs->file, BLKDBG_READ_AIO);
|
BLKDBG_CO_EVENT(bs->file, BLKDBG_READ_AIO);
|
||||||
ret = bdrv_co_pread(s->data_file, host_offset, bytes, buf, 0);
|
ret = bdrv_co_pread(s->data_file, host_offset, bytes, buf, 0);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
goto fail;
|
goto fail;
|
||||||
@ -2315,7 +2315,7 @@ qcow2_co_preadv_task(BlockDriverState *bs, QCow2SubclusterType subc_type,
|
|||||||
case QCOW2_SUBCLUSTER_UNALLOCATED_ALLOC:
|
case QCOW2_SUBCLUSTER_UNALLOCATED_ALLOC:
|
||||||
assert(bs->backing); /* otherwise handled in qcow2_co_preadv_part */
|
assert(bs->backing); /* otherwise handled in qcow2_co_preadv_part */
|
||||||
|
|
||||||
BLKDBG_EVENT(bs->file, BLKDBG_READ_BACKING_AIO);
|
BLKDBG_CO_EVENT(bs->file, BLKDBG_READ_BACKING_AIO);
|
||||||
return bdrv_co_preadv_part(bs->backing, offset, bytes,
|
return bdrv_co_preadv_part(bs->backing, offset, bytes,
|
||||||
qiov, qiov_offset, 0);
|
qiov, qiov_offset, 0);
|
||||||
|
|
||||||
@ -2329,7 +2329,7 @@ qcow2_co_preadv_task(BlockDriverState *bs, QCow2SubclusterType subc_type,
|
|||||||
offset, bytes, qiov, qiov_offset);
|
offset, bytes, qiov, qiov_offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
BLKDBG_EVENT(bs->file, BLKDBG_READ_AIO);
|
BLKDBG_CO_EVENT(bs->file, BLKDBG_READ_AIO);
|
||||||
return bdrv_co_preadv_part(s->data_file, host_offset,
|
return bdrv_co_preadv_part(s->data_file, host_offset,
|
||||||
bytes, qiov, qiov_offset, 0);
|
bytes, qiov, qiov_offset, 0);
|
||||||
|
|
||||||
@ -2539,7 +2539,7 @@ handle_alloc_space(BlockDriverState *bs, QCowL2Meta *l2meta)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
BLKDBG_EVENT(bs->file, BLKDBG_CLUSTER_ALLOC_SPACE);
|
BLKDBG_CO_EVENT(bs->file, BLKDBG_CLUSTER_ALLOC_SPACE);
|
||||||
ret = bdrv_co_pwrite_zeroes(s->data_file, start_offset, nb_bytes,
|
ret = bdrv_co_pwrite_zeroes(s->data_file, start_offset, nb_bytes,
|
||||||
BDRV_REQ_NO_FALLBACK);
|
BDRV_REQ_NO_FALLBACK);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
@ -2604,7 +2604,7 @@ int qcow2_co_pwritev_task(BlockDriverState *bs, uint64_t host_offset,
|
|||||||
* guest data now.
|
* guest data now.
|
||||||
*/
|
*/
|
||||||
if (!merge_cow(offset, bytes, qiov, qiov_offset, l2meta)) {
|
if (!merge_cow(offset, bytes, qiov, qiov_offset, l2meta)) {
|
||||||
BLKDBG_EVENT(bs->file, BLKDBG_WRITE_AIO);
|
BLKDBG_CO_EVENT(bs->file, BLKDBG_WRITE_AIO);
|
||||||
trace_qcow2_writev_data(qemu_coroutine_self(), host_offset);
|
trace_qcow2_writev_data(qemu_coroutine_self(), host_offset);
|
||||||
ret = bdrv_co_pwritev_part(s->data_file, host_offset,
|
ret = bdrv_co_pwritev_part(s->data_file, host_offset,
|
||||||
bytes, qiov, qiov_offset, 0);
|
bytes, qiov, qiov_offset, 0);
|
||||||
@ -4678,7 +4678,7 @@ qcow2_co_pwritev_compressed_task(BlockDriverState *bs,
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
BLKDBG_EVENT(s->data_file, BLKDBG_WRITE_COMPRESSED);
|
BLKDBG_CO_EVENT(s->data_file, BLKDBG_WRITE_COMPRESSED);
|
||||||
ret = bdrv_co_pwrite(s->data_file, cluster_offset, out_len, out_buf, 0);
|
ret = bdrv_co_pwrite(s->data_file, cluster_offset, out_len, out_buf, 0);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
goto fail;
|
goto fail;
|
||||||
@ -4797,7 +4797,7 @@ qcow2_co_preadv_compressed(BlockDriverState *bs,
|
|||||||
|
|
||||||
out_buf = qemu_blockalign(bs, s->cluster_size);
|
out_buf = qemu_blockalign(bs, s->cluster_size);
|
||||||
|
|
||||||
BLKDBG_EVENT(bs->file, BLKDBG_READ_COMPRESSED);
|
BLKDBG_CO_EVENT(bs->file, BLKDBG_READ_COMPRESSED);
|
||||||
ret = bdrv_co_pread(bs->file, coffset, csize, buf, 0);
|
ret = bdrv_co_pread(bs->file, coffset, csize, buf, 0);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
goto fail;
|
goto fail;
|
||||||
@ -5344,7 +5344,7 @@ qcow2_co_save_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos)
|
|||||||
return offset;
|
return offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
BLKDBG_EVENT(bs->file, BLKDBG_VMSTATE_SAVE);
|
BLKDBG_CO_EVENT(bs->file, BLKDBG_VMSTATE_SAVE);
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5356,7 +5356,7 @@ qcow2_co_load_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos)
|
|||||||
return offset;
|
return offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
BLKDBG_EVENT(bs->file, BLKDBG_VMSTATE_LOAD);
|
BLKDBG_CO_EVENT(bs->file, BLKDBG_VMSTATE_LOAD);
|
||||||
return bs->drv->bdrv_co_preadv_part(bs, offset, qiov->size, qiov, 0, 0);
|
return bs->drv->bdrv_co_preadv_part(bs, offset, qiov->size, qiov, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ int coroutine_fn qed_read_l1_table_sync(BDRVQEDState *s)
|
|||||||
int coroutine_fn qed_write_l1_table(BDRVQEDState *s, unsigned int index,
|
int coroutine_fn qed_write_l1_table(BDRVQEDState *s, unsigned int index,
|
||||||
unsigned int n)
|
unsigned int n)
|
||||||
{
|
{
|
||||||
BLKDBG_EVENT(s->bs->file, BLKDBG_L1_UPDATE);
|
BLKDBG_CO_EVENT(s->bs->file, BLKDBG_L1_UPDATE);
|
||||||
return qed_write_table(s, s->header.l1_table_offset,
|
return qed_write_table(s, s->header.l1_table_offset,
|
||||||
s->l1_table, index, n, false);
|
s->l1_table, index, n, false);
|
||||||
}
|
}
|
||||||
@ -150,7 +150,7 @@ int coroutine_fn qed_read_l2_table(BDRVQEDState *s, QEDRequest *request,
|
|||||||
request->l2_table = qed_alloc_l2_cache_entry(&s->l2_cache);
|
request->l2_table = qed_alloc_l2_cache_entry(&s->l2_cache);
|
||||||
request->l2_table->table = qed_alloc_table(s);
|
request->l2_table->table = qed_alloc_table(s);
|
||||||
|
|
||||||
BLKDBG_EVENT(s->bs->file, BLKDBG_L2_LOAD);
|
BLKDBG_CO_EVENT(s->bs->file, BLKDBG_L2_LOAD);
|
||||||
ret = qed_read_table(s, offset, request->l2_table->table);
|
ret = qed_read_table(s, offset, request->l2_table->table);
|
||||||
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
@ -183,7 +183,7 @@ int coroutine_fn qed_write_l2_table(BDRVQEDState *s, QEDRequest *request,
|
|||||||
unsigned int index, unsigned int n,
|
unsigned int index, unsigned int n,
|
||||||
bool flush)
|
bool flush)
|
||||||
{
|
{
|
||||||
BLKDBG_EVENT(s->bs->file, BLKDBG_L2_UPDATE);
|
BLKDBG_CO_EVENT(s->bs->file, BLKDBG_L2_UPDATE);
|
||||||
return qed_write_table(s, request->l2_table->offset,
|
return qed_write_table(s, request->l2_table->offset,
|
||||||
request->l2_table->table, index, n, flush);
|
request->l2_table->table, index, n, flush);
|
||||||
}
|
}
|
||||||
|
@ -883,7 +883,7 @@ static int coroutine_fn GRAPH_RDLOCK
|
|||||||
qed_read_backing_file(BDRVQEDState *s, uint64_t pos, QEMUIOVector *qiov)
|
qed_read_backing_file(BDRVQEDState *s, uint64_t pos, QEMUIOVector *qiov)
|
||||||
{
|
{
|
||||||
if (s->bs->backing) {
|
if (s->bs->backing) {
|
||||||
BLKDBG_EVENT(s->bs->file, BLKDBG_READ_BACKING_AIO);
|
BLKDBG_CO_EVENT(s->bs->file, BLKDBG_READ_BACKING_AIO);
|
||||||
return bdrv_co_preadv(s->bs->backing, pos, qiov->size, qiov, 0);
|
return bdrv_co_preadv(s->bs->backing, pos, qiov->size, qiov, 0);
|
||||||
}
|
}
|
||||||
qemu_iovec_memset(qiov, 0, 0, qiov->size);
|
qemu_iovec_memset(qiov, 0, 0, qiov->size);
|
||||||
@ -918,7 +918,7 @@ qed_copy_from_backing_file(BDRVQEDState *s, uint64_t pos, uint64_t len,
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
BLKDBG_EVENT(s->bs->file, BLKDBG_COW_WRITE);
|
BLKDBG_CO_EVENT(s->bs->file, BLKDBG_COW_WRITE);
|
||||||
ret = bdrv_co_pwritev(s->bs->file, offset, qiov.size, &qiov, 0);
|
ret = bdrv_co_pwritev(s->bs->file, offset, qiov.size, &qiov, 0);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
goto out;
|
goto out;
|
||||||
@ -1070,7 +1070,7 @@ static int coroutine_fn GRAPH_RDLOCK qed_aio_write_main(QEDAIOCB *acb)
|
|||||||
|
|
||||||
trace_qed_aio_write_main(s, acb, 0, offset, acb->cur_qiov.size);
|
trace_qed_aio_write_main(s, acb, 0, offset, acb->cur_qiov.size);
|
||||||
|
|
||||||
BLKDBG_EVENT(s->bs->file, BLKDBG_WRITE_AIO);
|
BLKDBG_CO_EVENT(s->bs->file, BLKDBG_WRITE_AIO);
|
||||||
return bdrv_co_pwritev(s->bs->file, offset, acb->cur_qiov.size,
|
return bdrv_co_pwritev(s->bs->file, offset, acb->cur_qiov.size,
|
||||||
&acb->cur_qiov, 0);
|
&acb->cur_qiov, 0);
|
||||||
}
|
}
|
||||||
@ -1324,7 +1324,7 @@ qed_aio_read_data(void *opaque, int ret, uint64_t offset, size_t len)
|
|||||||
} else if (ret != QED_CLUSTER_FOUND) {
|
} else if (ret != QED_CLUSTER_FOUND) {
|
||||||
r = qed_read_backing_file(s, acb->cur_pos, &acb->cur_qiov);
|
r = qed_read_backing_file(s, acb->cur_pos, &acb->cur_qiov);
|
||||||
} else {
|
} else {
|
||||||
BLKDBG_EVENT(bs->file, BLKDBG_READ_AIO);
|
BLKDBG_CO_EVENT(bs->file, BLKDBG_READ_AIO);
|
||||||
r = bdrv_co_preadv(bs->file, offset, acb->cur_qiov.size,
|
r = bdrv_co_preadv(bs->file, offset, acb->cur_qiov.size,
|
||||||
&acb->cur_qiov, 0);
|
&acb->cur_qiov, 0);
|
||||||
}
|
}
|
||||||
|
@ -214,7 +214,7 @@ raw_co_preadv(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
BLKDBG_EVENT(bs->file, BLKDBG_READ_AIO);
|
BLKDBG_CO_EVENT(bs->file, BLKDBG_READ_AIO);
|
||||||
return bdrv_co_preadv(bs->file, offset, bytes, qiov, flags);
|
return bdrv_co_preadv(bs->file, offset, bytes, qiov, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -268,7 +268,7 @@ raw_co_pwritev(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
BLKDBG_EVENT(bs->file, BLKDBG_WRITE_AIO);
|
BLKDBG_CO_EVENT(bs->file, BLKDBG_WRITE_AIO);
|
||||||
ret = bdrv_co_pwritev(bs->file, offset, bytes, qiov, flags);
|
ret = bdrv_co_pwritev(bs->file, offset, bytes, qiov, flags);
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
|
24
block/vmdk.c
24
block/vmdk.c
@ -1438,7 +1438,7 @@ get_whole_cluster(BlockDriverState *bs, VmdkExtent *extent,
|
|||||||
if (skip_start_bytes > 0) {
|
if (skip_start_bytes > 0) {
|
||||||
if (copy_from_backing) {
|
if (copy_from_backing) {
|
||||||
/* qcow2 emits this on bs->file instead of bs->backing */
|
/* qcow2 emits this on bs->file instead of bs->backing */
|
||||||
BLKDBG_EVENT(extent->file, BLKDBG_COW_READ);
|
BLKDBG_CO_EVENT(extent->file, BLKDBG_COW_READ);
|
||||||
ret = bdrv_co_pread(bs->backing, offset, skip_start_bytes,
|
ret = bdrv_co_pread(bs->backing, offset, skip_start_bytes,
|
||||||
whole_grain, 0);
|
whole_grain, 0);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
@ -1446,7 +1446,7 @@ get_whole_cluster(BlockDriverState *bs, VmdkExtent *extent,
|
|||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BLKDBG_EVENT(extent->file, BLKDBG_COW_WRITE);
|
BLKDBG_CO_EVENT(extent->file, BLKDBG_COW_WRITE);
|
||||||
ret = bdrv_co_pwrite(extent->file, cluster_offset, skip_start_bytes,
|
ret = bdrv_co_pwrite(extent->file, cluster_offset, skip_start_bytes,
|
||||||
whole_grain, 0);
|
whole_grain, 0);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
@ -1458,7 +1458,7 @@ get_whole_cluster(BlockDriverState *bs, VmdkExtent *extent,
|
|||||||
if (skip_end_bytes < cluster_bytes) {
|
if (skip_end_bytes < cluster_bytes) {
|
||||||
if (copy_from_backing) {
|
if (copy_from_backing) {
|
||||||
/* qcow2 emits this on bs->file instead of bs->backing */
|
/* qcow2 emits this on bs->file instead of bs->backing */
|
||||||
BLKDBG_EVENT(extent->file, BLKDBG_COW_READ);
|
BLKDBG_CO_EVENT(extent->file, BLKDBG_COW_READ);
|
||||||
ret = bdrv_co_pread(bs->backing, offset + skip_end_bytes,
|
ret = bdrv_co_pread(bs->backing, offset + skip_end_bytes,
|
||||||
cluster_bytes - skip_end_bytes,
|
cluster_bytes - skip_end_bytes,
|
||||||
whole_grain + skip_end_bytes, 0);
|
whole_grain + skip_end_bytes, 0);
|
||||||
@ -1467,7 +1467,7 @@ get_whole_cluster(BlockDriverState *bs, VmdkExtent *extent,
|
|||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BLKDBG_EVENT(extent->file, BLKDBG_COW_WRITE);
|
BLKDBG_CO_EVENT(extent->file, BLKDBG_COW_WRITE);
|
||||||
ret = bdrv_co_pwrite(extent->file, cluster_offset + skip_end_bytes,
|
ret = bdrv_co_pwrite(extent->file, cluster_offset + skip_end_bytes,
|
||||||
cluster_bytes - skip_end_bytes,
|
cluster_bytes - skip_end_bytes,
|
||||||
whole_grain + skip_end_bytes, 0);
|
whole_grain + skip_end_bytes, 0);
|
||||||
@ -1488,7 +1488,7 @@ vmdk_L2update(VmdkExtent *extent, VmdkMetaData *m_data, uint32_t offset)
|
|||||||
{
|
{
|
||||||
offset = cpu_to_le32(offset);
|
offset = cpu_to_le32(offset);
|
||||||
/* update L2 table */
|
/* update L2 table */
|
||||||
BLKDBG_EVENT(extent->file, BLKDBG_L2_UPDATE);
|
BLKDBG_CO_EVENT(extent->file, BLKDBG_L2_UPDATE);
|
||||||
if (bdrv_co_pwrite(extent->file,
|
if (bdrv_co_pwrite(extent->file,
|
||||||
((int64_t)m_data->l2_offset * 512)
|
((int64_t)m_data->l2_offset * 512)
|
||||||
+ (m_data->l2_index * sizeof(offset)),
|
+ (m_data->l2_index * sizeof(offset)),
|
||||||
@ -1618,7 +1618,7 @@ get_cluster_offset(BlockDriverState *bs, VmdkExtent *extent,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
l2_table = (char *)extent->l2_cache + (min_index * l2_size_bytes);
|
l2_table = (char *)extent->l2_cache + (min_index * l2_size_bytes);
|
||||||
BLKDBG_EVENT(extent->file, BLKDBG_L2_LOAD);
|
BLKDBG_CO_EVENT(extent->file, BLKDBG_L2_LOAD);
|
||||||
if (bdrv_co_pread(extent->file,
|
if (bdrv_co_pread(extent->file,
|
||||||
(int64_t)l2_offset * 512,
|
(int64_t)l2_offset * 512,
|
||||||
l2_size_bytes,
|
l2_size_bytes,
|
||||||
@ -1829,12 +1829,12 @@ vmdk_write_extent(VmdkExtent *extent, int64_t cluster_offset,
|
|||||||
n_bytes = buf_len + sizeof(VmdkGrainMarker);
|
n_bytes = buf_len + sizeof(VmdkGrainMarker);
|
||||||
qemu_iovec_init_buf(&local_qiov, data, n_bytes);
|
qemu_iovec_init_buf(&local_qiov, data, n_bytes);
|
||||||
|
|
||||||
BLKDBG_EVENT(extent->file, BLKDBG_WRITE_COMPRESSED);
|
BLKDBG_CO_EVENT(extent->file, BLKDBG_WRITE_COMPRESSED);
|
||||||
} else {
|
} else {
|
||||||
qemu_iovec_init(&local_qiov, qiov->niov);
|
qemu_iovec_init(&local_qiov, qiov->niov);
|
||||||
qemu_iovec_concat(&local_qiov, qiov, qiov_offset, n_bytes);
|
qemu_iovec_concat(&local_qiov, qiov, qiov_offset, n_bytes);
|
||||||
|
|
||||||
BLKDBG_EVENT(extent->file, BLKDBG_WRITE_AIO);
|
BLKDBG_CO_EVENT(extent->file, BLKDBG_WRITE_AIO);
|
||||||
}
|
}
|
||||||
|
|
||||||
write_offset = cluster_offset + offset_in_cluster;
|
write_offset = cluster_offset + offset_in_cluster;
|
||||||
@ -1876,7 +1876,7 @@ vmdk_read_extent(VmdkExtent *extent, int64_t cluster_offset,
|
|||||||
|
|
||||||
|
|
||||||
if (!extent->compressed) {
|
if (!extent->compressed) {
|
||||||
BLKDBG_EVENT(extent->file, BLKDBG_READ_AIO);
|
BLKDBG_CO_EVENT(extent->file, BLKDBG_READ_AIO);
|
||||||
ret = bdrv_co_preadv(extent->file,
|
ret = bdrv_co_preadv(extent->file,
|
||||||
cluster_offset + offset_in_cluster, bytes,
|
cluster_offset + offset_in_cluster, bytes,
|
||||||
qiov, 0);
|
qiov, 0);
|
||||||
@ -1890,7 +1890,7 @@ vmdk_read_extent(VmdkExtent *extent, int64_t cluster_offset,
|
|||||||
buf_bytes = cluster_bytes * 2;
|
buf_bytes = cluster_bytes * 2;
|
||||||
cluster_buf = g_malloc(buf_bytes);
|
cluster_buf = g_malloc(buf_bytes);
|
||||||
uncomp_buf = g_malloc(cluster_bytes);
|
uncomp_buf = g_malloc(cluster_bytes);
|
||||||
BLKDBG_EVENT(extent->file, BLKDBG_READ_COMPRESSED);
|
BLKDBG_CO_EVENT(extent->file, BLKDBG_READ_COMPRESSED);
|
||||||
ret = bdrv_co_pread(extent->file, cluster_offset, buf_bytes, cluster_buf,
|
ret = bdrv_co_pread(extent->file, cluster_offset, buf_bytes, cluster_buf,
|
||||||
0);
|
0);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
@ -1968,7 +1968,7 @@ vmdk_co_preadv(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
|||||||
qemu_iovec_concat(&local_qiov, qiov, bytes_done, n_bytes);
|
qemu_iovec_concat(&local_qiov, qiov, bytes_done, n_bytes);
|
||||||
|
|
||||||
/* qcow2 emits this on bs->file instead of bs->backing */
|
/* qcow2 emits this on bs->file instead of bs->backing */
|
||||||
BLKDBG_EVENT(bs->file, BLKDBG_READ_BACKING_AIO);
|
BLKDBG_CO_EVENT(bs->file, BLKDBG_READ_BACKING_AIO);
|
||||||
ret = bdrv_co_preadv(bs->backing, offset, n_bytes,
|
ret = bdrv_co_preadv(bs->backing, offset, n_bytes,
|
||||||
&local_qiov, 0);
|
&local_qiov, 0);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
@ -2909,7 +2909,7 @@ vmdk_co_check(BlockDriverState *bs, BdrvCheckResult *result, BdrvCheckMode fix)
|
|||||||
BDRVVmdkState *s = bs->opaque;
|
BDRVVmdkState *s = bs->opaque;
|
||||||
VmdkExtent *extent = NULL;
|
VmdkExtent *extent = NULL;
|
||||||
int64_t sector_num = 0;
|
int64_t sector_num = 0;
|
||||||
int64_t total_sectors = bdrv_nb_sectors(bs);
|
int64_t total_sectors = bdrv_co_nb_sectors(bs);
|
||||||
int ret;
|
int ret;
|
||||||
uint64_t cluster_offset;
|
uint64_t cluster_offset;
|
||||||
|
|
||||||
|
@ -224,6 +224,13 @@ bdrv_co_debug_event(BlockDriverState *bs, BlkdebugEvent event);
|
|||||||
void co_wrapper_mixed_bdrv_rdlock
|
void co_wrapper_mixed_bdrv_rdlock
|
||||||
bdrv_debug_event(BlockDriverState *bs, BlkdebugEvent event);
|
bdrv_debug_event(BlockDriverState *bs, BlkdebugEvent event);
|
||||||
|
|
||||||
|
#define BLKDBG_CO_EVENT(child, evt) \
|
||||||
|
do { \
|
||||||
|
if (child) { \
|
||||||
|
bdrv_co_debug_event(child->bs, evt); \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define BLKDBG_EVENT(child, evt) \
|
#define BLKDBG_EVENT(child, evt) \
|
||||||
do { \
|
do { \
|
||||||
if (child) { \
|
if (child) { \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user