More coroutine_fn fixes
cover More coroutine_fn fixes
Most of these were extracted from Alberto's static analysis series. After this series, the only errors reported by the analyzer are:
- a call to bs->drv->bdrv_co_drain_begin from bdrv_open_driver. This relies on bdrv_co_drain_begin not having to yield, which is indeed the case right after opening but is iffy
- assigning coroutine_fn to non-coroutine_fn in the human monitor for the two coroutine commands screendump and block_resize.
Paolo
Alberto Faria (20):
backup: remove incorrect coroutine_fn annotation
block: remove incorrect coroutine_fn annotation
monitor: add missing coroutine_fn annotation
ssh: add missing coroutine_fn annotation
block: add missing coroutine_fn annotation to prototypes
coroutine-lock: add missing coroutine_fn annotation to prototypes
coroutine-io: add missing coroutine_fn annotation to prototypes
block: add missing coroutine_fn annotation to BlockDriverState
callbacks
qcow2: add coroutine_fn annotation for indirect-called functions
commit: switch to *_co_* functions
block: switch to *_co_* functions
mirror: switch to *_co_* functions
parallels: switch to *_co_* functions
qcow: switch to *_co_* functions
qcow2: switch to *_co_* functions
qed: switch to *_co_* functions
vdi: switch to *_co_* functions
vhdx: switch to *_co_* functions
vmdk: switch to *_co_* functions
monitor: switch to *_co_* functions
Paolo Bonzini (4):
blkdebug: add missing coroutine_fn annotation for indirect-called
functions
qcow: manually add more coroutine_fn annotations
qcow2: manually add more coroutine_fn annotations
vmdk: manually add more coroutine_fn annotations
block.c | 2 +- block/backup.c | 2 +- block/blkdebug.c | 2 +- block/commit.c | 2 +- block/io.c | 8 +-- block/mirror.c | 4 +- block/monitor/block-hmp-cmds.c | 2 +- block/parallels.c | 28 +++++----- block/qcow.c | 56 ++++++++++---------- block/qcow2-bitmap.c | 4 +- block/qcow2-cluster.c | 26 ++++----- block/qcow2-refcount.c | 18 +++---- block/qcow2-snapshot.c | 6 +-- block/qcow2.c | 32 ++++++------ block/qcow2.h | 32 ++++++------ block/qed-table.c | 2 +- block/qed.c | 12 ++--- block/ssh.c | 6 +-- block/vdi.c | 17 +++--- block/vhdx.c | 8 +-- block/vmdk.c | 90 ++++++++++++++++---------------- blockdev.c | 2 +- include/block/block-hmp-cmds.h | 2 +- include/block/block-io.h | 5 +- include/block/block_int-common.h | 12 ++--- include/monitor/hmp.h | 3 +- include/qemu/coroutine.h | 18 ++++--- 27 files changed, 202 insertions(+), 199 deletions(-)
Signature · 1 line
2.37.3
PATCH 1/24 backup: remove incorrect coroutine_fn annotation
From: Alberto Faria <[email protected]>
The .set_speed callback is not called from coroutine.
--- block/backup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
block/backup.c +1 -1
@@ -309,7 +309,7 @@ static void coroutine_fn backup_pause(Job *job) } } -static void coroutine_fn backup_set_speed(BlockJob *job, int64_t speed) +static void backup_set_speed (BlockJob *job,int64_t speed) {BackupBlockJob *s =container_of (job, BackupBlockJob, common);
Signature · 1 line
2.37.3
PATCH 2/24 block: remove incorrect coroutine_fn annotation
In reply to Paolo BonziniFrom: Alberto Faria <[email protected]>
--- block/io.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
block/io.c +2 -2
@@ -2739,8 +2739,8 @@ int coroutine_fn bdrv_co_is_zero_fast(BlockDriverState *bs, int64_t offset,return (pnum == bytes) && (ret &BDRV_BLOCK_ZERO ); } -int coroutine_fn bdrv_is_allocated(BlockDriverState *bs, int64_t offset, -int64_t bytes,int64_t *pnum) +int bdrv_is_allocated (BlockDriverState *bs,int64_t offset,int64_t bytes, +int64_t *pnum) {int ret;int64_t dummy;
Signature · 1 line
2.37.3
PATCH 3/24 monitor: add missing coroutine_fn annotation
In reply to Paolo BonziniFrom: Alberto Faria <[email protected]>
hmp_block_resize and hmp_screendump are defined as a ".coroutine = true" command, so they must be coroutine_fn.
--- block/monitor/block-hmp-cmds.c | 2 +- include/block/block-hmp-cmds.h | 2 +- include/monitor/hmp.h | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-)
block/monitor/block-hmp-cmds.c +1 -1
@@ -489,7 +489,7 @@ void hmp_nbd_server_stop(Monitor *mon, const QDict *qdict)hmp_handle_error (mon, err); } -void hmp_block_resize (Monitor *mon,const QDict *qdict) +void coroutine_fn hmp_block_resize(Monitor *mon, const QDict *qdict) {const char *device =qdict_get_str (qdict,"device" );int64_t size =qdict_get_int (qdict,"size" );
include/block/block-hmp-cmds.h +1 -1
@@ -38,7 +38,7 @@ void hmp_nbd_server_add(Monitor *mon, const QDict *qdict);void hmp_nbd_server_remove (Monitor *mon,const QDict *qdict);void hmp_nbd_server_stop (Monitor *mon,const QDict *qdict); -void hmp_block_resize (Monitor *mon,const QDict *qdict); +void coroutine_fn hmp_block_resize(Monitor *mon, const QDict *qdict);void hmp_block_stream (Monitor *mon,const QDict *qdict);void hmp_block_passwd (Monitor *mon,const QDict *qdict);void hmp_block_set_io_throttle (Monitor *mon,const QDict *qdict);
include/monitor/hmp.h +2 -1
@@ -15,6 +15,7 @@#define HMP_H #include "qemu/readline.h" +#include "qemu/coroutine.h" #include "qapi/qapi-types-common.h" bool hmp_handle_error (Monitor *mon,Error *err);
@@ -81,7 +82,7 @@ void hmp_netdev_del(Monitor *mon, const QDict *qdict);void hmp_getfd (Monitor *mon,const QDict *qdict);void hmp_closefd (Monitor *mon,const QDict *qdict);void hmp_sendkey (Monitor *mon,const QDict *qdict); -void hmp_screendump (Monitor *mon,const QDict *qdict); +void coroutine_fn hmp_screendump(Monitor *mon, const QDict *qdict);void hmp_chardev_add (Monitor *mon,const QDict *qdict);void hmp_chardev_change (Monitor *mon,const QDict *qdict);void hmp_chardev_remove (Monitor *mon,const QDict *qdict);
Signature · 1 line
2.37.3
PATCH 4/24 ssh: add missing coroutine_fn annotation
In reply to Paolo BonziniFrom: Alberto Faria <[email protected]>
ssh_write is only called from ssh_co_writev.
--- block/ssh.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
block/ssh.c +3 -3
@@ -1129,9 +1129,9 @@ static coroutine_fn int ssh_co_readv(BlockDriverState *bs,return ret; } -static int ssh_write (BDRVSSHState *s,BlockDriverState *bs, -int64_t offset,size_t size, -QEMUIOVector *qiov) +static coroutine_fn int ssh_write(BDRVSSHState *s, BlockDriverState *bs, +int64_t offset,size_t size, +QEMUIOVector *qiov) {ssize_t r;size_t written;
Signature · 1 line
2.37.3
PATCH 5/24 block: add missing coroutine_fn annotation to prototypes
In reply to Paolo BonziniFrom: Alberto Faria <[email protected]>
The functions are marked coroutine_fn in the definition.
--- include/block/block-io.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
include/block/block-io.h +3 -2
@@ -83,12 +83,13 @@ void bdrv_aio_cancel(BlockAIOCB *acb);void bdrv_aio_cancel_async (BlockAIOCB *acb);/* sg packet commands */ -int bdrv_co_ioctl (BlockDriverState *bs,int req,void *buf); +int coroutine_fn bdrv_co_ioctl(BlockDriverState *bs, int req, void *buf);/* Ensure contents are flushed to disk. */ int coroutine_fn bdrv_co_flush(BlockDriverState *bs); -int bdrv_co_pdiscard (BdrvChild *child,int64_t offset,int64_t bytes); +int coroutine_fn bdrv_co_pdiscard(BdrvChild *child, int64_t offset, +int64_t bytes);bool bdrv_can_write_zeroes_with_unmap (BlockDriverState *bs); int bdrv_block_status(BlockDriverState *bs, int64_t offset, int64_t bytes, int64_t *pnum, int64_t *map,
Signature · 1 line
2.37.3
PATCH 6/24 coroutine-lock: add missing coroutine_fn annotation to prototypes
In reply to Paolo BonziniFrom: Alberto Faria <[email protected]>
The functions are marked coroutine_fn in the definition.
--- include/qemu/coroutine.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
include/qemu/coroutine.h +5 -5
@@ -276,7 +276,7 @@ void qemu_co_rwlock_init(CoRwlock *lock);* of a parallel writer, control is transferred to the caller of the current * coroutine. */ -void qemu_co_rwlock_rdlock (CoRwlock *lock); +void coroutine_fn qemu_co_rwlock_rdlock(CoRwlock *lock);/** * Write Locks the CoRwlock from a reader. This is a bit more efficient than
@@ -285,7 +285,7 @@ void qemu_co_rwlock_rdlock(CoRwlock *lock);* to the caller of the current coroutine; another writer might run while * @qemu_co_rwlock_upgrade blocks. */ -void qemu_co_rwlock_upgrade (CoRwlock *lock); +void coroutine_fn qemu_co_rwlock_upgrade(CoRwlock *lock);/** * Downgrades a write-side critical section to a reader. Downgrading with
@@ -293,20 +293,20 @@ void qemu_co_rwlock_upgrade(CoRwlock *lock);* followed by @qemu_co_rwlock_rdlock. This makes it more efficient, but * may also sometimes be necessary for correctness. */ -void qemu_co_rwlock_downgrade (CoRwlock *lock); +void coroutine_fn qemu_co_rwlock_downgrade(CoRwlock *lock);/** * Write Locks the mutex. If the lock cannot be taken immediately because * of a parallel reader, control is transferred to the caller of the current * coroutine. */ -void qemu_co_rwlock_wrlock (CoRwlock *lock); +void coroutine_fn qemu_co_rwlock_wrlock(CoRwlock *lock);/** * Unlocks the read/write lock and schedules the next coroutine that was * waiting for this lock to be run. */ -void qemu_co_rwlock_unlock (CoRwlock *lock); +void coroutine_fn qemu_co_rwlock_unlock(CoRwlock *lock); typedef struct QemuCoSleep { Coroutine *to_wake;
Signature · 1 line
2.37.3
PATCH 7/24 coroutine-io: add missing coroutine_fn annotation to prototypes
In reply to Paolo BonziniFrom: Alberto Faria <[email protected]>
--- include/qemu/coroutine.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
include/qemu/coroutine.h +5 -3
@@ -378,8 +378,9 @@ void qemu_coroutine_dec_pool_size(unsigned int additional_pool_size);* The same interface as qemu_sendv_recvv(), with added yielding. * XXX should mark these as coroutine_fn */ -ssize_t qemu_co_sendv_recvv (int sockfd,struct iovec *iov,unsigned iov_cnt, -size_t offset,size_t bytes,bool do_send); +ssize_t coroutine_fn qemu_co_sendv_recvv(int sockfd, struct iovec *iov, +unsigned iov_cnt,size_t offset, +size_t bytes,bool do_send);#define qemu_co_recvv (sockfd, iov, iov_cnt, offset, bytes) \ qemu_co_sendv_recvv(sockfd, iov, iov_cnt, offset, bytes, false)#define qemu_co_sendv (sockfd, iov, iov_cnt, offset, bytes) \
@@ -388,7 +389,8 @@ ssize_t qemu_co_sendv_recvv(int sockfd, struct iovec *iov, unsigned iov_cnt,/** * The same as above, but with just a single buffer */ -ssize_t qemu_co_send_recv (int sockfd,void *buf,size_t bytes,bool do_send); +ssize_t coroutine_fn qemu_co_send_recv(int sockfd, void *buf, size_t bytes, +bool do_send);#define qemu_co_recv (sockfd, buf, bytes) \ qemu_co_send_recv(sockfd, buf, bytes, false)#define qemu_co_send (sockfd, buf, bytes) \
Signature · 1 line
2.37.3
PATCH 8/24 block: add missing coroutine_fn annotation to BlockDriverState callbacks
In reply to Paolo BonziniFrom: Alberto Faria <[email protected]>
--- block/qcow2.h | 14 +++++++------- include/block/block_int-common.h | 12 +++++------- 2 files changed, 12 insertions(+), 14 deletions(-)
block/qcow2.h +7 -7
@@ -991,13 +991,13 @@ int qcow2_truncate_bitmaps_check(BlockDriverState *bs, Error **errp);bool qcow2_store_persistent_dirty_bitmaps (BlockDriverState *bs,bool release_stored,Error **errp);int qcow2_reopen_bitmaps_ro (BlockDriverState *bs,Error **errp); -bool qcow2_co_can_store_new_dirty_bitmap (BlockDriverState *bs, -const char *name, -uint32_t granularity, -Error **errp); -int qcow2_co_remove_persistent_dirty_bitmap (BlockDriverState *bs, -const char *name, -Error **errp); +bool coroutine_fn qcow2_co_can_store_new_dirty_bitmap(BlockDriverState *bs, +const char *name, +uint32_t granularity, +Error **errp); +int coroutine_fn qcow2_co_remove_persistent_dirty_bitmap(BlockDriverState *bs, +const char *name, +Error **errp);bool qcow2_supports_persistent_dirty_bitmap (BlockDriverState *bs);uint64_t qcow2_get_persistent_dirty_bitmap_size (BlockDriverState *bs,uint32_t cluster_size);
include/block/block_int-common.h +5 -7
@@ -731,13 +731,11 @@ struct BlockDriver { void coroutine_fn (*bdrv_co_drain_end)(BlockDriverState *bs);bool (*bdrv_supports_persistent_dirty_bitmap)(BlockDriverState *bs); -bool (*bdrv_co_can_store_new_dirty_bitmap)(BlockDriverState *bs, -const char *name, -uint32_t granularity, -Error **errp); -int (*bdrv_co_remove_persistent_dirty_bitmap)(BlockDriverState *bs, -const char *name, -Error **errp); + bool coroutine_fn (*bdrv_co_can_store_new_dirty_bitmap)( +BlockDriverState *bs,const char *name,uint32_t granularity, +Error **errp); + int coroutine_fn (*bdrv_co_remove_persistent_dirty_bitmap)( +BlockDriverState *bs,const char *name,Error **errp); };static inline bool block_driver_can_compress (BlockDriver *drv)
Signature · 1 line
2.37.3
PATCH 9/24 qcow2: add coroutine_fn annotation for indirect-called functions
In reply to Paolo BonziniFrom: Alberto Faria <[email protected]>
--- block/qcow2.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
block/qcow2.c +4 -4
@@ -5287,8 +5287,8 @@ static int64_t qcow2_check_vmstate_request(BlockDriverState *bs,return pos; } -static int qcow2_save_vmstate (BlockDriverState *bs,QEMUIOVector *qiov, -int64_t pos) +static coroutine_fn int qcow2_save_vmstate(BlockDriverState *bs, +QEMUIOVector *qiov,int64_t pos) {int64_t offset =qcow2_check_vmstate_request (bs, qiov, pos);if (offset <0 ) {
@@ -5299,8 +5299,8 @@ static int qcow2_save_vmstate(BlockDriverState *bs, QEMUIOVector *qiov,return bs->drv->bdrv_co_pwritev_part (bs, offset, qiov->size, qiov,0 ,0 ); } -static int qcow2_load_vmstate (BlockDriverState *bs,QEMUIOVector *qiov, -int64_t pos) +static coroutine_fn int qcow2_load_vmstate(BlockDriverState *bs, +QEMUIOVector *qiov,int64_t pos) {int64_t offset =qcow2_check_vmstate_request (bs, qiov, pos);if (offset <0 ) {
Signature · 1 line
2.37.3
PATCH 10/24 blkdebug: add missing coroutine_fn annotation for indirect-called functions
In reply to Paolo Bonzini--- block/blkdebug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
block/blkdebug.c +1 -1
@@ -672,7 +672,7 @@ blkdebug_co_pwritev(BlockDriverState *bs, int64_t offset, int64_t bytes,return bdrv_co_pwritev (bs->file, offset, bytes, qiov, flags); } -static int blkdebug_co_flush (BlockDriverState *bs) +static int coroutine_fn blkdebug_co_flush(BlockDriverState *bs) {int err =rule_check (bs,0 ,0 ,BLKDEBUG_IO_TYPE_FLUSH );
Signature · 1 line
2.37.3
PATCH 11/24 qcow: manually add more coroutine_fn annotations
In reply to Paolo Bonziniget_cluster_offset() and decompress_cluster() are only called from the read and write paths.
The validity of these was double-checked with Alberto Faria's static analyzer.
--- block/qcow.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
block/qcow.c +6 -6
@@ -92,7 +92,7 @@ typedef struct BDRVQcowState {static QemuOptsList qcow_create_opts; -static int decompress_cluster (BlockDriverState *bs,uint64_t cluster_offset); +static int coroutine_fn decompress_cluster(BlockDriverState *bs, uint64_t cluster_offset);static int qcow_probe (const uint8_t *buf,int buf_size,const char *filename) {
@@ -351,10 +351,10 @@ static int qcow_reopen_prepare(BDRVReopenState *state,* return 0 if not allocated, 1 if *result is assigned, and negative * errno on failure. */ -static int get_cluster_offset (BlockDriverState *bs, -uint64_t offset,int allocate, -int compressed_size, -int n_start,int n_end,uint64_t *result) +static int coroutine_fn get_cluster_offset(BlockDriverState *bs, +uint64_t offset,int allocate, +int compressed_size, +int n_start,int n_end,uint64_t *result) {BDRVQcowState *s = bs->opaque;int min_index, i, j, l1_index, l2_index, ret;
@@ -585,7 +585,7 @@ static int decompress_buffer(uint8_t *out_buf, int out_buf_size,return 0 ; } -static int decompress_cluster (BlockDriverState *bs,uint64_t cluster_offset) +static int coroutine_fn decompress_cluster(BlockDriverState *bs, uint64_t cluster_offset) {BDRVQcowState *s = bs->opaque;int ret, csize;
Signature · 1 line
2.37.3
PATCH 12/24 qcow2: manually add more coroutine_fn annotations
In reply to Paolo BonziniThe validity of these was double-checked with Alberto Faria's static analyzer.
--- block/qcow2-bitmap.c | 4 ++-- block/qcow2-cluster.c | 18 +++++++++--------- block/qcow2-refcount.c | 8 ++++---- block/qcow2.h | 18 +++++++++--------- 4 files changed, 24 insertions(+), 24 deletions(-)
block/qcow2-bitmap.c +2 -2
@@ -955,8 +955,8 @@ static void set_readonly_helper(gpointer bitmap, gpointer value)* If header_updated is not NULL then it is set appropriately regardless of * the return value. */ -bool qcow2_load_dirty_bitmaps (BlockDriverState *bs,bool *header_updated, -Error **errp) +bool coroutine_fn qcow2_load_dirty_bitmaps(BlockDriverState *bs, bool *header_updated, +Error **errp) {BDRVQcow2State *s = bs->opaque;Qcow2BitmapList *bm_list;
block/qcow2-cluster.c +7 -7
@@ -31,7 +31,7 @@#include "qemu/memalign.h" #include "trace.h" -int qcow2_shrink_l1_table (BlockDriverState *bs,uint64_t exact_size) +int coroutine_fn qcow2_shrink_l1_table(BlockDriverState *bs, uint64_t exact_size) {BDRVQcow2State *s = bs->opaque;int new_l1_size, i, ret;
@@ -823,10 +823,10 @@ static int get_cluster_table(BlockDriverState *bs, uint64_t offset,* * Return 0 on success and -errno in error cases */ -int qcow2_alloc_compressed_cluster_offset (BlockDriverState *bs, -uint64_t offset, -int compressed_size, -uint64_t *host_offset) +int coroutine_fn qcow2_alloc_compressed_cluster_offset(BlockDriverState *bs, +uint64_t offset, +int compressed_size, +uint64_t *host_offset) {BDRVQcow2State *s = bs->opaque;int l2_index, ret;
@@ -1488,7 +1488,7 @@ static int coroutine_fn handle_dependencies(BlockDriverState *bs,* * -errno: in error cases */ -static int handle_copied (BlockDriverState *bs,uint64_t guest_offset, +static int coroutine_fn handle_copied(BlockDriverState *bs, uint64_t guest_offset,uint64_t *host_offset,uint64_t *bytes,QCowL2Meta **m) {BDRVQcow2State *s = bs->opaque;
@@ -1653,7 +1653,7 @@ static int do_alloc_cluster_offset(BlockDriverState *bs, uint64_t guest_offset,* * -errno: in error cases */ -static int handle_alloc (BlockDriverState *bs,uint64_t guest_offset, +static int coroutine_fn handle_alloc(BlockDriverState *bs, uint64_t guest_offset,uint64_t *host_offset,uint64_t *bytes,QCowL2Meta **m) {BDRVQcow2State *s = bs->opaque;
block/qcow2-refcount.c +4 -4
@@ -97,7 +97,7 @@ static void update_max_refcount_table_index(BDRVQcow2State *s) s->max_refcount_table_index = i; } -int qcow2_refcount_init (BlockDriverState *bs) +int coroutine_fn qcow2_refcount_init(BlockDriverState *bs) {BDRVQcow2State *s = bs->opaque;unsigned int refcount_table_size2, i;
@@ -3559,8 +3559,8 @@ static int64_t get_refblock_offset(BlockDriverState *bs, uint64_t offset)return covering_refblock_offset; } -static int qcow2_discard_refcount_block (BlockDriverState *bs, -uint64_t discard_block_offs) +static int coroutine_fn qcow2_discard_refcount_block(BlockDriverState *bs, +uint64_t discard_block_offs) {BDRVQcow2State *s = bs->opaque;int64_t refblock_offs;
@@ -3616,7 +3616,7 @@ static int qcow2_discard_refcount_block(BlockDriverState *bs,return 0 ; } -int qcow2_shrink_reftable (BlockDriverState *bs) +int coroutine_fn qcow2_shrink_reftable(BlockDriverState *bs) {BDRVQcow2State *s = bs->opaque; uint64_t *reftable_tmp =
block/qcow2.h +9 -9
@@ -846,7 +846,7 @@ int qcow2_validate_table(BlockDriverState *bs, uint64_t offset, Error **errp);/* qcow2-refcount.c functions */ -int qcow2_refcount_init (BlockDriverState *bs); +int coroutine_fn qcow2_refcount_init(BlockDriverState *bs);void qcow2_refcount_close (BlockDriverState *bs); int qcow2_get_refcount(BlockDriverState *bs, int64_t cluster_index,
@@ -893,14 +893,14 @@ int qcow2_inc_refcounts_imrt(BlockDriverState *bs, BdrvCheckResult *res,int qcow2_change_refcount_order (BlockDriverState *bs,int refcount_order,BlockDriverAmendStatusCB *status_cb,void *cb_opaque,Error **errp); -int qcow2_shrink_reftable (BlockDriverState *bs); +int coroutine_fn qcow2_shrink_reftable(BlockDriverState *bs);int64_t qcow2_get_last_cluster (BlockDriverState *bs,int64_t size); int coroutine_fn qcow2_detect_metadata_preallocation(BlockDriverState *bs);/* qcow2-cluster.c functions */ int qcow2_grow_l1_table (BlockDriverState *bs,uint64_t min_size,bool exact_size); -int qcow2_shrink_l1_table (BlockDriverState *bs,uint64_t max_size); +int coroutine_fn qcow2_shrink_l1_table(BlockDriverState *bs, uint64_t max_size);int qcow2_write_l1_entry (BlockDriverState *bs,int l1_index);int qcow2_encrypt_sectors (BDRVQcow2State *s,int64_t sector_num,uint8_t *buf,int nb_sectors,bool enc,Error **errp);
@@ -911,10 +911,10 @@ int qcow2_get_host_offset(BlockDriverState *bs, uint64_t offset, int coroutine_fn qcow2_alloc_host_offset(BlockDriverState *bs, uint64_t offset,unsigned int *bytes,uint64_t *host_offset,QCowL2Meta **m); -int qcow2_alloc_compressed_cluster_offset (BlockDriverState *bs, -uint64_t offset, -int compressed_size, -uint64_t *host_offset); +int coroutine_fn qcow2_alloc_compressed_cluster_offset(BlockDriverState *bs, +uint64_t offset, +int compressed_size, +uint64_t *host_offset);void qcow2_parse_compressed_l2_entry (BlockDriverState *bs,uint64_t l2_entry,uint64_t *coffset,int *csize);
@@ -982,8 +982,8 @@ void qcow2_cache_discard(Qcow2Cache *c, void *table);int qcow2_check_bitmaps_refcounts (BlockDriverState *bs,BdrvCheckResult *res,void **refcount_table,int64_t *refcount_table_size); -bool qcow2_load_dirty_bitmaps (BlockDriverState *bs,bool *header_updated, -Error **errp); +bool coroutine_fn qcow2_load_dirty_bitmaps(BlockDriverState *bs, bool *header_updated, + Error **errp);bool qcow2_get_bitmap_info_list (BlockDriverState *bs,Qcow2BitmapInfoList **info_list,Error **errp);int qcow2_reopen_bitmaps_rw (BlockDriverState *bs,Error **errp);
Signature · 1 line
2.37.3
PATCH 13/24 vmdk: manually add more coroutine_fn annotations
In reply to Paolo BonziniThe validity of these was double-checked with Alberto Faria's static analyzer.
--- block/vmdk.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-)
block/vmdk.c +17 -17
@@ -1404,13 +1404,13 @@ static void vmdk_refresh_limits(BlockDriverState *bs, Error **errp)* [@skip_start_sector, @skip_end_sector) is not copied or written, and leave * it for call to write user data in the request. */ -static int get_whole_cluster (BlockDriverState *bs, -VmdkExtent *extent, -uint64_t cluster_offset, -uint64_t offset, -uint64_t skip_start_bytes, -uint64_t skip_end_bytes, -bool zeroed) +static int coroutine_fn get_whole_cluster(BlockDriverState *bs, +VmdkExtent *extent, +uint64_t cluster_offset, +uint64_t offset, +uint64_t skip_start_bytes, +uint64_t skip_end_bytes, +bool zeroed) {int ret =VMDK_OK ;int64_t cluster_bytes;
@@ -1485,8 +1485,8 @@ exit:return ret; } -static int vmdk_L2update (VmdkExtent *extent,VmdkMetaData *m_data, -uint32_t offset) +static int coroutine_fn vmdk_L2update(VmdkExtent *extent, VmdkMetaData *m_data, +uint32_t offset) { offset =cpu_to_le32 (offset);/* update L2 table */
@@ -1537,14 +1537,14 @@ static int vmdk_L2update(VmdkExtent *extent, VmdkMetaData *m_data,* VMDK_UNALLOC if cluster is not mapped and @allocate is false. * VMDK_ERROR if failed. */ -static int get_cluster_offset (BlockDriverState *bs, -VmdkExtent *extent, -VmdkMetaData *m_data, -uint64_t offset, -bool allocate, -uint64_t *cluster_offset, -uint64_t skip_start_bytes, -uint64_t skip_end_bytes) +static int coroutine_fn get_cluster_offset(BlockDriverState *bs, +VmdkExtent *extent, +VmdkMetaData *m_data, +uint64_t offset, +bool allocate, +uint64_t *cluster_offset, +uint64_t skip_start_bytes, +uint64_t skip_end_bytes) {unsigned int l1_index, l2_offset, l2_index;int min_index, i, j;
Signature · 1 line
2.37.3
PATCH 14/24 commit: switch to *_co_* functions
In reply to Paolo BonziniFrom: Alberto Faria <[email protected]>
--- block/commit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
block/commit.c +1 -1
@@ -135,7 +135,7 @@ static int coroutine_fn commit_run(Job *job, Error **errp) }if (base_len < len) { - ret =blk_truncate (s->base, len, false,PREALLOC_MODE_OFF ,0 ,NULL ); + ret =blk_co_truncate (s->base, len, false,PREALLOC_MODE_OFF ,0 ,NULL );if (ret) {return ret; }
Signature · 1 line
2.37.3
PATCH 15/24 block: switch to *_co_* functions
In reply to Paolo BonziniFrom: Alberto Faria <[email protected]>
--- block.c | 2 +- block/io.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
block.c +1 -1
@@ -643,7 +643,7 @@ create_file_fallback_zero_first_sector(BlockBackend *blk, bytes_to_clear =MIN (current_size,BDRV_SECTOR_SIZE );if (bytes_to_clear) { - ret =blk_pwrite_zeroes (blk,0 , bytes_to_clear,BDRV_REQ_MAY_UNMAP ); + ret =blk_co_pwrite_zeroes (blk,0 , bytes_to_clear,BDRV_REQ_MAY_UNMAP );if (ret <0 ) {error_setg_errno (errp, -ret,"Failed to clear the new image's first sector" );
block/io.c +2 -2
@@ -2729,8 +2729,8 @@ int coroutine_fn bdrv_co_is_zero_fast(BlockDriverState *bs, int64_t offset,return 1 ; } - ret =bdrv_common_block_status_above (bs,NULL , false, false, offset, - bytes, &pnum,NULL ,NULL ,NULL ); + ret =bdrv_co_common_block_status_above (bs,NULL , false, false, offset, + bytes, &pnum,NULL ,NULL ,NULL );if (ret <0 ) {return ret;
Signature · 1 line
2.37.3
PATCH 16/24 mirror: switch to *_co_* functions
In reply to Paolo BonziniFrom: Alberto Faria <[email protected]>
--- block/mirror.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
block/mirror.c +2 -2
@@ -922,8 +922,8 @@ static int coroutine_fn mirror_run(Job *job, Error **errp)* active layer. */ if (s->base ==blk_bs (s->target)) {if (s->bdev_length > target_length) { - ret =blk_truncate (s->target, s->bdev_length, false, -PREALLOC_MODE_OFF ,0 ,NULL ); + ret =blk_co_truncate (s->target, s->bdev_length, false, +PREALLOC_MODE_OFF ,0 ,NULL );if (ret <0 ) { goto immediate_exit; }
Signature · 1 line
2.37.3
PATCH 17/24 parallels: switch to *_co_* functions
In reply to Paolo BonziniFrom: Alberto Faria <[email protected]>
--- block/parallels.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-)
block/parallels.c +14 -14
@@ -205,18 +205,18 @@ static coroutine_fn int64_t allocate_clusters(BlockDriverState *bs,* force the safer-but-slower fallocate. */ if (s->prealloc_mode ==PRL_PREALLOC_MODE_TRUNCATE ) { - ret =bdrv_truncate (bs->file, - (s->data_end + space) <<BDRV_SECTOR_BITS , - false,PREALLOC_MODE_OFF ,BDRV_REQ_ZERO_WRITE , -NULL ); + ret =bdrv_co_truncate (bs->file, + (s->data_end + space) <<BDRV_SECTOR_BITS , + false,PREALLOC_MODE_OFF , +BDRV_REQ_ZERO_WRITE ,NULL );if (ret == -ENOTSUP ) { s->prealloc_mode =PRL_PREALLOC_MODE_FALLOCATE ; } }if (s->prealloc_mode ==PRL_PREALLOC_MODE_FALLOCATE ) { - ret =bdrv_pwrite_zeroes (bs->file, - s->data_end <<BDRV_SECTOR_BITS , - space <<BDRV_SECTOR_BITS ,0 ); + ret =bdrv_co_pwrite_zeroes (bs->file, + s->data_end <<BDRV_SECTOR_BITS , + space <<BDRV_SECTOR_BITS ,0 ); }if (ret <0 ) {return ret;
@@ -278,8 +278,8 @@ static coroutine_fn int parallels_co_flush_to_os(BlockDriverState *bs)if (off + to_write > s->header_size) { to_write = s->header_size - off; } - ret =bdrv_pwrite (bs->file, off, to_write, (uint8_t *)s->header + off, -0 ); + ret =bdrv_co_pwrite (bs->file, off, to_write, + (uint8_t *)s->header + off,0 );if (ret <0 ) {qemu_co_mutex_unlock (&s->lock);return ret;
@@ -504,8 +504,8 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs,* In order to really repair the image, we must shrink it. * That means we have to pass exact=true. */ - ret =bdrv_truncate (bs->file, res->image_end_offset, true, -PREALLOC_MODE_OFF ,0 , &local_err); + ret =bdrv_co_truncate (bs->file, res->image_end_offset, true, +PREALLOC_MODE_OFF ,0 , &local_err);if (ret <0 ) {error_report_err (local_err); res->check_errors++;
@@ -600,12 +600,12 @@ static int coroutine_fn parallels_co_create(BlockdevCreateOptions* opts,memset (tmp,0 ,sizeof (tmp));memcpy (tmp, &header,sizeof (header)); - ret =blk_pwrite (blk,0 ,BDRV_SECTOR_SIZE , tmp,0 ); + ret =blk_co_pwrite (blk,0 ,BDRV_SECTOR_SIZE , tmp,0 );if (ret <0 ) { goto exit; } - ret =blk_pwrite_zeroes (blk,BDRV_SECTOR_SIZE , - (bat_sectors -1 ) <<BDRV_SECTOR_BITS ,0 ); + ret =blk_co_pwrite_zeroes (blk,BDRV_SECTOR_SIZE , + (bat_sectors -1 ) <<BDRV_SECTOR_BITS ,0 );if (ret <0 ) { goto exit; }
Signature · 1 line
2.37.3
PATCH 18/24 qcow: switch to *_co_* functions
In reply to Paolo BonziniFrom: Alberto Faria <[email protected]>
--- block/qcow.c | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-)
block/qcow.c +22 -22
@@ -381,9 +381,9 @@ static int coroutine_fn get_cluster_offset(BlockDriverState *bs, s->l1_table[l1_index] = l2_offset; tmp =cpu_to_be64 (l2_offset);BLKDBG_EVENT (bs->file,BLKDBG_L1_UPDATE ); - ret =bdrv_pwrite_sync (bs->file, - s->l1_table_offset + l1_index *sizeof (tmp), -sizeof (tmp), &tmp,0 ); + ret =bdrv_co_pwrite_sync (bs->file, + s->l1_table_offset + l1_index *sizeof (tmp), +sizeof (tmp), &tmp,0 );if (ret <0 ) {return ret; }
@@ -414,14 +414,14 @@ static int coroutine_fn get_cluster_offset(BlockDriverState *bs,BLKDBG_EVENT (bs->file,BLKDBG_L2_LOAD );if (new_l2_table) {memset (l2_table,0 , s->l2_size *sizeof (uint64_t )); - ret =bdrv_pwrite_sync (bs->file, l2_offset, - s->l2_size *sizeof (uint64_t ), l2_table,0 ); + ret =bdrv_co_pwrite_sync (bs->file, l2_offset, + s->l2_size *sizeof (uint64_t ), l2_table,0 );if (ret <0 ) {return ret; } }else { - ret =bdrv_pread (bs->file, l2_offset, s->l2_size *sizeof (uint64_t ), - l2_table,0 ); + ret =bdrv_co_pread (bs->file, l2_offset, + s->l2_size *sizeof (uint64_t ), l2_table,0 );if (ret <0 ) {return ret; }
@@ -453,8 +453,8 @@ static int coroutine_fn get_cluster_offset(BlockDriverState *bs, cluster_offset =QEMU_ALIGN_UP (cluster_offset, s->cluster_size);/* write the cluster content */ BLKDBG_EVENT (bs->file,BLKDBG_WRITE_AIO ); - ret =bdrv_pwrite (bs->file, cluster_offset, s->cluster_size, - s->cluster_cache,0 ); + ret =bdrv_co_pwrite (bs->file, cluster_offset, s->cluster_size, + s->cluster_cache,0 );if (ret <0 ) {return ret; }
@@ -469,8 +469,8 @@ static int coroutine_fn get_cluster_offset(BlockDriverState *bs,if (cluster_offset + s->cluster_size >INT64_MAX ) {return -E2BIG ; } - ret =bdrv_truncate (bs->file, cluster_offset + s->cluster_size, - false,PREALLOC_MODE_OFF ,0 ,NULL ); + ret =bdrv_co_truncate (bs->file, cluster_offset + s->cluster_size, + false,PREALLOC_MODE_OFF ,0 ,NULL );if (ret <0 ) {return ret; }
@@ -492,9 +492,9 @@ static int coroutine_fn get_cluster_offset(BlockDriverState *bs,return -EIO ; }BLKDBG_EVENT (bs->file,BLKDBG_WRITE_AIO ); - ret =bdrv_pwrite (bs->file, cluster_offset + i, -BDRV_SECTOR_SIZE , - s->cluster_data,0 ); + ret =bdrv_co_pwrite (bs->file, cluster_offset + i, +BDRV_SECTOR_SIZE , + s->cluster_data,0 );if (ret <0 ) {return ret; }
@@ -514,8 +514,8 @@ static int coroutine_fn get_cluster_offset(BlockDriverState *bs, }else {BLKDBG_EVENT (bs->file,BLKDBG_L2_UPDATE ); } - ret =bdrv_pwrite_sync (bs->file, l2_offset + l2_index *sizeof (tmp), -sizeof (tmp), &tmp,0 ); + ret =bdrv_co_pwrite_sync (bs->file, l2_offset + l2_index *sizeof (tmp), +sizeof (tmp), &tmp,0 );if (ret <0 ) {return ret; }
@@ -596,7 +596,7 @@ static int coroutine_fn decompress_cluster(BlockDriverState *bs, uint64_t cluste csize = cluster_offset >> (63 - s->cluster_bits); csize &= (s->cluster_size -1 );BLKDBG_EVENT (bs->file,BLKDBG_READ_COMPRESSED ); - ret =bdrv_pread (bs->file, coffset, csize, s->cluster_data,0 ); + ret =bdrv_co_pread (bs->file, coffset, csize, s->cluster_data,0 );if (ret <0 )return -1 ; if (decompress_buffer(s->cluster_cache, s->cluster_size,
@@ -890,14 +890,14 @@ static int coroutine_fn qcow_co_create(BlockdevCreateOptions *opts, }/* write all the data */ - ret =blk_pwrite (qcow_blk,0 ,sizeof (header), &header,0 ); + ret =blk_co_pwrite (qcow_blk,0 ,sizeof (header), &header,0 );if (ret <0 ) { goto exit; }if (qcow_opts->has_backing_file) { - ret =blk_pwrite (qcow_blk,sizeof (header), backing_filename_len, - qcow_opts->backing_file,0 ); + ret =blk_co_pwrite (qcow_blk,sizeof (header), backing_filename_len, + qcow_opts->backing_file,0 );if (ret <0 ) { goto exit; }
@@ -906,8 +906,8 @@ static int coroutine_fn qcow_co_create(BlockdevCreateOptions *opts, tmp =g_malloc0 (BDRV_SECTOR_SIZE );for (i =0 ; i <DIV_ROUND_UP (sizeof (uint64_t ) * l1_size,BDRV_SECTOR_SIZE ); i++) { - ret =blk_pwrite (qcow_blk, header_size +BDRV_SECTOR_SIZE * i, -BDRV_SECTOR_SIZE , tmp,0 ); + ret =blk_co_pwrite (qcow_blk, header_size +BDRV_SECTOR_SIZE * i, +BDRV_SECTOR_SIZE , tmp,0 );if (ret <0 ) {g_free (tmp); goto exit;
Signature · 1 line
2.37.3
PATCH 19/24 qcow2: switch to *_co_* functions
In reply to Paolo BonziniFrom: Alberto Faria <[email protected]>
--- block/qcow2-cluster.c | 8 ++++---- block/qcow2-refcount.c | 10 +++++----- block/qcow2-snapshot.c | 6 +++--- block/qcow2.c | 24 ++++++++++++------------ 4 files changed, 24 insertions(+), 24 deletions(-)
block/qcow2-cluster.c +4 -4
@@ -47,14 +47,14 @@ int coroutine_fn qcow2_shrink_l1_table(BlockDriverState *bs, uint64_t exact_size#endif BLKDBG_EVENT (bs->file,BLKDBG_L1_SHRINK_WRITE_TABLE ); - ret =bdrv_pwrite_zeroes (bs->file, s->l1_table_offset + - new_l1_size *L1E_SIZE , - (s->l1_size - new_l1_size) *L1E_SIZE ,0 ); + ret =bdrv_co_pwrite_zeroes (bs->file, s->l1_table_offset + + new_l1_size *L1E_SIZE , + (s->l1_size - new_l1_size) *L1E_SIZE ,0 );if (ret <0 ) { goto fail; } - ret =bdrv_flush (bs->file->bs); + ret =bdrv_co_flush (bs->file->bs);if (ret <0 ) { goto fail; }
block/qcow2-refcount.c +5 -5
@@ -118,8 +118,8 @@ int coroutine_fn qcow2_refcount_init(BlockDriverState *bs) goto fail; }BLKDBG_EVENT (bs->file,BLKDBG_REFTABLE_LOAD ); - ret =bdrv_pread (bs->file, s->refcount_table_offset, - refcount_table_size2, s->refcount_table,0 ); + ret =bdrv_co_pread (bs->file, s->refcount_table_offset, + refcount_table_size2, s->refcount_table,0 );if (ret <0 ) { goto fail; }
@@ -3657,9 +3657,9 @@ int coroutine_fn qcow2_shrink_reftable(BlockDriverState *bs) reftable_tmp[i] = unused_block ?0 :cpu_to_be64 (s->refcount_table[i]); } - ret =bdrv_pwrite_sync (bs->file, s->refcount_table_offset, - s->refcount_table_size *REFTABLE_ENTRY_SIZE , - reftable_tmp,0 ); + ret =bdrv_co_pwrite_sync (bs->file, s->refcount_table_offset, + s->refcount_table_size *REFTABLE_ENTRY_SIZE , + reftable_tmp,0 );/* * If the write in the reftable failed the image may contain a partially * overwritten reftable. In this case it would be better to clear the
block/qcow2-snapshot.c +3 -3
@@ -441,9 +441,9 @@ int coroutine_fn qcow2_check_read_snapshot_table(BlockDriverState *bs, }QEMU_PACKED snapshot_table_pointer;/* qcow2_do_open() discards this information in check mode */ - ret =bdrv_pread (bs->file, offsetof(QCowHeader , nb_snapshots), -sizeof (snapshot_table_pointer), &snapshot_table_pointer, -0 ); + ret =bdrv_co_pread (bs->file, offsetof(QCowHeader , nb_snapshots), +sizeof (snapshot_table_pointer), &snapshot_table_pointer, +0 );if (ret <0 ) { result->check_errors++; fprintf(stderr, "ERROR failed to read the snapshot table pointer from "
block/qcow2.c +12 -12
@@ -1306,7 +1306,7 @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options,uint64_t l1_vm_state_index;bool update_header = false; - ret =bdrv_pread (bs->file,0 ,sizeof (header), &header,0 ); + ret =bdrv_co_pread (bs->file,0 ,sizeof (header), &header,0 );if (ret <0 ) {error_setg_errno (errp, -ret,"Could not read qcow2 header" ); goto fail;
@@ -1382,9 +1382,9 @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options,if (header.header_length >sizeof (header)) { s->unknown_header_fields_size = header.header_length -sizeof (header); s->unknown_header_fields =g_malloc (s->unknown_header_fields_size); - ret =bdrv_pread (bs->file,sizeof (header), - s->unknown_header_fields_size, - s->unknown_header_fields,0 ); + ret =bdrv_co_pread (bs->file,sizeof (header), + s->unknown_header_fields_size, + s->unknown_header_fields,0 );if (ret <0 ) {error_setg_errno (errp, -ret,"Could not read unknown qcow2 header " "fields" );
@@ -1579,8 +1579,8 @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options, ret = -ENOMEM ; goto fail; } - ret =bdrv_pread (bs->file, s->l1_table_offset, s->l1_size *L1E_SIZE , - s->l1_table,0 ); + ret =bdrv_co_pread (bs->file, s->l1_table_offset, s->l1_size *L1E_SIZE , + s->l1_table,0 );if (ret <0 ) {error_setg_errno (errp, -ret,"Could not read L1 table" ); goto fail;
@@ -1699,8 +1699,8 @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options, } s->image_backing_file =g_malloc (len +1 ); - ret =bdrv_pread (bs->file, header.backing_file_offset, len, - s->image_backing_file,0 ); + ret =bdrv_co_pread (bs->file, header.backing_file_offset, len, + bs->auto_backing_file,0 );if (ret <0 ) {error_setg_errno (errp, -ret,"Could not read backing file name" ); goto fail;
@@ -3679,7 +3679,7 @@ qcow2_co_create(BlockdevCreateOptions *create_options, Error **errp)cpu_to_be64 (QCOW2_INCOMPAT_EXTL2 ); } - ret =blk_pwrite (blk,0 , cluster_size, header,0 ); + ret =blk_co_pwrite (blk,0 , cluster_size, header,0 );g_free (header);if (ret <0 ) {error_setg_errno (errp, -ret,"Could not write qcow2 header" );
@@ -3689,7 +3689,7 @@ qcow2_co_create(BlockdevCreateOptions *create_options, Error **errp)/* Write a refcount table with one refcount block */ refcount_table =g_malloc0 (2 * cluster_size); refcount_table[0 ] =cpu_to_be64 (2 * cluster_size); - ret =blk_pwrite (blk, cluster_size,2 * cluster_size, refcount_table,0 ); + ret =blk_co_pwrite (blk, cluster_size,2 * cluster_size, refcount_table,0 );g_free (refcount_table);if (ret <0 ) {
@@ -3744,8 +3744,8 @@ qcow2_co_create(BlockdevCreateOptions *create_options, Error **errp) }/* Okay, now that we have a valid image, let's give it the right size */ - ret =blk_truncate (blk, qcow2_opts->size, false, qcow2_opts->preallocation, -0 , errp); + ret =blk_co_truncate (blk, qcow2_opts->size, false, + qcow2_opts->preallocation,0 , errp);if (ret <0 ) {error_prepend (errp,"Could not resize image: " ); goto out;
Signature · 1 line
2.37.3
Re: [PATCH 19/24] qcow2: switch to *_co_* functions
Am 13.10.2022 um 14:37 hat Paolo Bonzini geschrieben:
block/qcow2.c static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options, · line 1703
Quoted 13 lines
From: Alberto Faria <[email protected]>
Signed-off-by Alberto Faria <[email protected]>Signed-off-by Paolo Bonzini <[email protected]>block/qcow2.c +2
-2@@ -1699,8 +1699,8 @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options, } s->image_backing_file =g_malloc (len +1 ); - ret =bdrv_pread (bs->file, header.backing_file_offset, len, - s->image_backing_file,0 ); + ret =bdrv_co_pread (bs->file, header.backing_file_offset, len, + bs->auto_backing_file,0 );
This was an incorrect conflict resolution, it reverts part of commit ec64b1ca081 (s->image_backing_file vs. bs->auto_backing_file).
I'll fix this while applying.
Kevin
PATCH 20/24 qed: switch to *_co_* functions
In reply to Paolo BonziniFrom: Alberto Faria <[email protected]>
--- block/qed-table.c | 2 +- block/qed.c | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-)
block/qed-table.c +1 -1
@@ -100,7 +100,7 @@ static int coroutine_fn qed_write_table(BDRVQEDState *s, uint64_t offset, }if (flush) { - ret =bdrv_flush (s->bs); + ret =bdrv_co_flush (s->bs);if (ret <0 ) { goto out; }
block/qed.c +6 -6
@@ -387,7 +387,7 @@ static int coroutine_fn bdrv_qed_do_open(BlockDriverState *bs, QDict *options,int64_t file_size;int ret; - ret =bdrv_pread (bs->file,0 ,sizeof (le_header), &le_header,0 ); + ret =bdrv_co_pread (bs->file,0 ,sizeof (le_header), &le_header,0 );if (ret <0 ) {error_setg (errp,"Failed to read QED header" );return ret;
@@ -492,7 +492,7 @@ static int coroutine_fn bdrv_qed_do_open(BlockDriverState *bs, QDict *options, }/* From here on only known autoclear feature bits are valid */ -bdrv_flush (bs->file->bs); +bdrv_co_flush (bs->file->bs); } s->l1_table =qed_alloc_table (s);
@@ -693,7 +693,7 @@ static int coroutine_fn bdrv_qed_co_create(BlockdevCreateOptions *opts,* The QED format associates file length with allocation status, * so a new file (which is empty) must have a length of 0. */ - ret =blk_truncate (blk,0 , true,PREALLOC_MODE_OFF ,0 , errp); + ret =blk_co_truncate (blk,0 , true,PREALLOC_MODE_OFF ,0 , errp);if (ret <0 ) { goto out; }
@@ -712,18 +712,18 @@ static int coroutine_fn bdrv_qed_co_create(BlockdevCreateOptions *opts, }qed_header_cpu_to_le (&header, &le_header); - ret =blk_pwrite (blk,0 ,sizeof (le_header), &le_header,0 ); + ret =blk_co_pwrite (blk,0 ,sizeof (le_header), &le_header,0 );if (ret <0 ) { goto out; } - ret =blk_pwrite (blk,sizeof (le_header), header.backing_filename_size, + ret =blk_co_pwrite (blk,sizeof (le_header), header.backing_filename_size, qed_opts->backing_file,0 );if (ret <0 ) { goto out; } l1_table =g_malloc0 (l1_size); - ret =blk_pwrite (blk, header.l1_table_offset, l1_size, l1_table,0 ); + ret =blk_co_pwrite (blk, header.l1_table_offset, l1_size, l1_table,0 );if (ret <0 ) { goto out; }
Signature · 1 line
2.37.3
PATCH 21/24 vdi: switch to *_co_* functions
In reply to Paolo BonziniFrom: Alberto Faria <[email protected]>
--- block/vdi.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
block/vdi.c +9 -8
@@ -664,7 +664,8 @@ vdi_co_pwritev(BlockDriverState *bs, int64_t offset, int64_t bytes,* so this full-cluster write does not overlap a partial write * of the same cluster, issued from the "else" branch. */ - ret =bdrv_pwrite (bs->file, data_offset, s->block_size, block,0 ); + ret =bdrv_co_pwrite (bs->file, data_offset, s->block_size, block, +0 );qemu_co_rwlock_unlock (&s->bmap_lock); }else { nonallocating_write:
@@ -709,7 +710,7 @@ nonallocating_write:assert (VDI_IS_ALLOCATED (bmap_first)); *header = s->header;vdi_header_to_le (header); - ret =bdrv_pwrite (bs->file,0 ,sizeof (*header), header,0 ); + ret =bdrv_co_pwrite (bs->file,0 ,sizeof (*header), header,0 );g_free (header);if (ret <0 ) {
@@ -726,8 +727,8 @@ nonallocating_write: base = ((uint8_t *)&s->bmap[0 ]) + bmap_first *SECTOR_SIZE ;logout ("will write %u block map sectors starting from entry %u\n" , n_sectors, bmap_first); - ret =bdrv_pwrite (bs->file, offset *SECTOR_SIZE , - n_sectors *SECTOR_SIZE , base,0 ); + ret =bdrv_co_pwrite (bs->file, offset *SECTOR_SIZE , + n_sectors *SECTOR_SIZE , base,0 ); }return ret;
@@ -845,7 +846,7 @@ static int coroutine_fn vdi_co_do_create(BlockdevCreateOptions *create_options,vdi_header_print (&header); }vdi_header_to_le (&header); - ret =blk_pwrite (blk, offset,sizeof (header), &header,0 ); + ret =blk_co_pwrite (blk, offset,sizeof (header), &header,0 );if (ret <0 ) {error_setg (errp,"Error writing header" ); goto exit;
@@ -866,7 +867,7 @@ static int coroutine_fn vdi_co_do_create(BlockdevCreateOptions *create_options, bmap[i] =VDI_UNALLOCATED ; } } - ret =blk_pwrite (blk, offset, bmap_size, bmap,0 ); + ret =blk_co_pwrite (blk, offset, bmap_size, bmap,0 );if (ret <0 ) {error_setg (errp,"Error writing bmap" ); goto exit;
@@ -875,8 +876,8 @@ static int coroutine_fn vdi_co_do_create(BlockdevCreateOptions *create_options, }if (image_type ==VDI_TYPE_STATIC ) { - ret =blk_truncate (blk, offset + blocks * block_size, false, -PREALLOC_MODE_OFF ,0 , errp); + ret =blk_co_truncate (blk, offset + blocks * block_size, false, +PREALLOC_MODE_OFF ,0 , errp);if (ret <0 ) {error_prepend (errp,"Failed to statically allocate file" ); goto exit;
Signature · 1 line
2.37.3
PATCH 22/24 vhdx: switch to *_co_* functions
In reply to Paolo BonziniFrom: Alberto Faria <[email protected]>
--- block/vhdx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
block/vhdx.c +4 -4
@@ -2012,15 +2012,15 @@ static int coroutine_fn vhdx_co_create(BlockdevCreateOptions *opts, creator =g_utf8_to_utf16 ("QEMU v" QEMU_VERSION ,-1 ,NULL , &creator_items,NULL ); signature =cpu_to_le64 (VHDX_FILE_SIGNATURE ); - ret =blk_pwrite (blk,VHDX_FILE_ID_OFFSET ,sizeof (signature), &signature, -0 ); + ret =blk_co_pwrite (blk,VHDX_FILE_ID_OFFSET ,sizeof (signature), &signature, +0 );if (ret <0 ) {error_setg_errno (errp, -ret,"Failed to write file signature" ); goto delete_and_exit; }if (creator) { - ret =blk_pwrite (blk,VHDX_FILE_ID_OFFSET +sizeof (signature), - creator_items *sizeof (gunichar2), creator,0 ); + ret =blk_co_pwrite (blk,VHDX_FILE_ID_OFFSET +sizeof (signature), + creator_items *sizeof (gunichar2), creator,0 );if (ret <0 ) {error_setg_errno (errp, -ret,"Failed to write creator field" ); goto delete_and_exit;
Signature · 1 line
2.37.3
PATCH 23/24 vmdk: switch to *_co_* functions
In reply to Paolo BonziniFrom: Alberto Faria <[email protected]>
--- block/vmdk.c | 56 ++++++++++++++++++++++++++-------------------------- 1 file changed, 28 insertions(+), 28 deletions(-)
block/vmdk.c +28 -28
@@ -1441,16 +1441,16 @@ static int coroutine_fn get_whole_cluster(BlockDriverState *bs,if (copy_from_backing) {/* qcow2 emits this on bs->file instead of bs->backing */ BLKDBG_EVENT (extent->file,BLKDBG_COW_READ ); - ret =bdrv_pread (bs->backing, offset, skip_start_bytes, - whole_grain,0 ); + ret =bdrv_co_pread (bs->backing, offset, skip_start_bytes, + whole_grain,0 );if (ret <0 ) { ret =VMDK_ERROR ; goto exit; } }BLKDBG_EVENT (extent->file,BLKDBG_COW_WRITE ); - ret =bdrv_pwrite (extent->file, cluster_offset, skip_start_bytes, - whole_grain,0 ); + ret =bdrv_co_pwrite (extent->file, cluster_offset, skip_start_bytes, + whole_grain,0 );if (ret <0 ) { ret =VMDK_ERROR ; goto exit;
@@ -1461,18 +1461,18 @@ static int coroutine_fn get_whole_cluster(BlockDriverState *bs,if (copy_from_backing) {/* qcow2 emits this on bs->file instead of bs->backing */ BLKDBG_EVENT (extent->file,BLKDBG_COW_READ ); - ret =bdrv_pread (bs->backing, offset + skip_end_bytes, - cluster_bytes - skip_end_bytes, - whole_grain + skip_end_bytes,0 ); + ret =bdrv_co_pread (bs->backing, offset + skip_end_bytes, + cluster_bytes - skip_end_bytes, + whole_grain + skip_end_bytes,0 );if (ret <0 ) { ret =VMDK_ERROR ; goto exit; } }BLKDBG_EVENT (extent->file,BLKDBG_COW_WRITE ); - ret =bdrv_pwrite (extent->file, cluster_offset + skip_end_bytes, - cluster_bytes - skip_end_bytes, - whole_grain + skip_end_bytes,0 ); + ret =bdrv_co_pwrite (extent->file, cluster_offset + skip_end_bytes, + cluster_bytes - skip_end_bytes, + whole_grain + skip_end_bytes,0 );if (ret <0 ) { ret =VMDK_ERROR ; goto exit;
@@ -1491,23 +1491,23 @@ static int coroutine_fn vmdk_L2update(VmdkExtent *extent, VmdkMetaData *m_data, offset =cpu_to_le32 (offset);/* update L2 table */ BLKDBG_EVENT (extent->file,BLKDBG_L2_UPDATE ); -if (bdrv_pwrite (extent->file, - ((int64_t )m_data->l2_offset *512 ) - + (m_data->l2_index *sizeof (offset)), -sizeof (offset), &offset,0 ) <0 ) { +if (bdrv_co_pwrite (extent->file, + ((int64_t )m_data->l2_offset *512 ) + + (m_data->l2_index *sizeof (offset)), +sizeof (offset), &offset,0 ) <0 ) {return VMDK_ERROR ; }/* update backup L2 table */ if (extent->l1_backup_table_offset !=0 ) { m_data->l2_offset = extent->l1_backup_table[m_data->l1_index]; -if (bdrv_pwrite (extent->file, - ((int64_t )m_data->l2_offset *512 ) - + (m_data->l2_index *sizeof (offset)), -sizeof (offset), &offset,0 ) <0 ) { +if (bdrv_co_pwrite (extent->file, + ((int64_t )m_data->l2_offset *512 ) + + (m_data->l2_index *sizeof (offset)), +sizeof (offset), &offset,0 ) <0 ) {return VMDK_ERROR ; } } -if (bdrv_flush (extent->file->bs) <0 ) { +if (bdrv_co_flush (extent->file->bs) <0 ) {return VMDK_ERROR ; }if (m_data->l2_cache_entry) {
@@ -1624,12 +1624,11 @@ static int coroutine_fn get_cluster_offset(BlockDriverState *bs, } l2_table = (char *)extent->l2_cache + (min_index * l2_size_bytes);BLKDBG_EVENT (extent->file,BLKDBG_L2_LOAD ); -if (bdrv_pread (extent->file, +if (bdrv_co_pread (extent->file, (int64_t )l2_offset *512 , l2_size_bytes, - l2_table, -0 - ) <0 ) { + l2_table,0 + ) != l2_size_bytes) {return VMDK_ERROR ; }
@@ -1899,7 +1898,8 @@ vmdk_read_extent(VmdkExtent *extent, int64_t cluster_offset, cluster_buf =g_malloc (buf_bytes); uncomp_buf =g_malloc (cluster_bytes);BLKDBG_EVENT (extent->file,BLKDBG_READ_COMPRESSED ); - ret =bdrv_pread (extent->file, cluster_offset, buf_bytes, cluster_buf,0 ); + ret =bdrv_co_pread (extent->file, cluster_offset, buf_bytes, cluster_buf, +0 );if (ret <0 ) { goto out; }
@@ -2144,8 +2144,8 @@ vmdk_co_pwritev_compressed(BlockDriverState *bs, int64_t offset, int64_t bytes,return length; } length =QEMU_ALIGN_UP (length,BDRV_SECTOR_SIZE ); - ret =bdrv_truncate (s->extents[i].file, length, false, -PREALLOC_MODE_OFF ,0 ,NULL ); + ret =bdrv_co_truncate (s->extents[i].file, length, false, +PREALLOC_MODE_OFF ,0 ,NULL );if (ret <0 ) {return ret; }
@@ -2586,7 +2586,7 @@ static int coroutine_fn vmdk_co_do_create(int64_t size, desc_offset =0x200 ; } - ret =blk_pwrite (blk, desc_offset, desc_len, desc,0 ); + ret =blk_co_pwrite (blk, desc_offset, desc_len, desc,0 );if (ret <0 ) {error_setg_errno (errp, -ret,"Could not write description" ); goto exit;
@@ -2594,7 +2594,7 @@ static int coroutine_fn vmdk_co_do_create(int64_t size,/* bdrv_pwrite write padding zeros to align to sector, we don't need that * for description file */ if (desc_offset ==0 ) { - ret =blk_truncate (blk, desc_len, false,PREALLOC_MODE_OFF ,0 , errp); + ret =blk_co_truncate (blk, desc_len, false,PREALLOC_MODE_OFF ,0 , errp);if (ret <0 ) { goto exit; }
Signature · 1 line
2.37.3
Re: [PATCH 23/24] vmdk: switch to *_co_* functions
Am 13.10.2022 um 14:37 hat Paolo Bonzini geschrieben:
Quoted 8 lines
From: Alberto Faria <[email protected]>
Signed-off-by Alberto Faria <[email protected]>Signed-off-by Paolo Bonzini <[email protected]>block/vmdk.c +0
-0@@ -1624,12 +1624,11 @@ static int coroutine_fn get_cluster_offset(BlockDriverState *bs, } l2_table = (char *)extent->l2_cache + (min_index * l2_size_bytes);
block/vmdk.c static int coroutine_fn get_cluster_offset(BlockDriverState *bs, · line 1631
Quoted 10 lines
block/vmdk.c +3
-4BLKDBG_EVENT (extent->file,BLKDBG_L2_LOAD ); -if (bdrv_pread (extent->file, +if (bdrv_co_pread (extent->file, (int64_t )l2_offset *512 , l2_size_bytes, - l2_table, -0 - ) <0 ) { + l2_table,0 + ) != l2_size_bytes) {
Another incorrect conflict resolution, this would revert part of commit 353a5d84b25. Fixing it up as well.
Kevin
PATCH 24/24 monitor: switch to *_co_* functions
In reply to Paolo BonziniFrom: Alberto Faria <[email protected]>
--- blockdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
blockdev.c +1 -1
@@ -2448,7 +2448,7 @@ void coroutine_fn qmp_block_resize(bool has_device, const char *device,bdrv_co_unlock (bs); old_ctx =bdrv_co_enter (bs); -blk_truncate (blk, size, false,PREALLOC_MODE_OFF ,0 , errp); +blk_co_truncate (blk, size, false,PREALLOC_MODE_OFF ,0 , errp);bdrv_co_leave (bs, old_ctx);bdrv_co_lock (bs);
Signature · 1 line
2.37.3
Am 13.10.2022 um 14:36 hat Paolo Bonzini geschrieben:
Quoted 9 lines
Most of these were extracted from Alberto's static analysis series. After this series, the only errors reported by the analyzer are:
- a call to
bs->drv->bdrv_co_drain_beginfrombdrv_open_driver. This relies onbdrv_co_drain_beginnot having to yield, which is indeed the case right after opening but is iffy- assigning
coroutine_fnto non-coroutine_fn in the human monitor for the two coroutine commands screendump andblock_resize.
Thanks, fixed up coding style warnings in checkpatch and the mismerges in patches 19 and 23, and applied to the block branch.
Kevin