block: buffer-based io
cover block: buffer-based io
Hi all!
We often need to do read/write with buffer, not qiov. Instead of creating qiov in such cases, let's introduce corresponding helpers.
Vladimir Sementsov-Ogievskiy (9):
block: introduce byte-based io helpers
block/qcow2: use buffer-based io
block/qcow: use buffer-based io
block/qed: use buffer-based io
block/parallels: use buffer-based io
block/backup: use buffer-based io
block/commit: use buffer-based io
block/stream: use buffer-based io
qemu-img: use buffer-based io
include/block/block_int.h | 16 ++++++++++++++++ include/sysemu/block-backend.h | 19 +++++++++++++++++++ block/backup.c | 14 ++++++-------- block/commit.c | 5 ++--- block/parallels.c | 14 ++++++-------- block/qcow.c | 19 ++++++------------- block/qcow2.c | 9 ++------- block/qed-table.c | 12 +++++------- block/qed.c | 6 ++---- block/stream.c | 4 +--- qemu-img.c | 13 ++++--------- 11 files changed, 69 insertions(+), 62 deletions(-)
Signature · 1 line
2.18.0
PATCH 1/9 block: introduce byte-based io helpers
--- include/block/block_int.h | 16 ++++++++++++++++ include/sysemu/block-backend.h | 19 +++++++++++++++++++ 2 files changed, 35 insertions(+)
include/block/block_int.h +16 -0
@@ -925,6 +925,22 @@ int coroutine_fn bdrv_co_pwritev(BdrvChild *child, int64_t offset, unsigned int bytes, QEMUIOVector *qiov, BdrvRequestFlags flags); +static inline int coroutine_fn bdrv_co_pread(BdrvChild *child, +int64_t offset,unsigned int bytes,void *buf,BdrvRequestFlags flags) +{ +QEMUIOVector qiov =QEMU_IOVEC_INIT_BUF (qiov, buf, bytes); + +return bdrv_co_preadv (child, offset, bytes, &qiov, flags); +} + +static inline int coroutine_fn bdrv_co_pwrite(BdrvChild *child, +int64_t offset,unsigned int bytes,void *buf,BdrvRequestFlags flags) +{ +QEMUIOVector qiov =QEMU_IOVEC_INIT_BUF (qiov, buf, bytes); + +return bdrv_co_pwritev (child, offset, bytes, &qiov, flags); +} +extern unsigned int bdrv_drain_all_count;void bdrv_apply_subtree_drain (BdrvChild *child,BlockDriverState *new_parent);void bdrv_unapply_subtree_drain (BdrvChild *child,BlockDriverState *old_parent);
include/sysemu/block-backend.h +19 -0
@@ -124,6 +124,25 @@ int coroutine_fn blk_co_preadv(BlockBackend *blk, int64_t offset, int coroutine_fn blk_co_pwritev(BlockBackend *blk, int64_t offset,unsigned int bytes,QEMUIOVector *qiov,BdrvRequestFlags flags); + +static inline int coroutine_fn blk_co_pread(BlockBackend *blk, int64_t offset, +unsigned int bytes,void *buf, +BdrvRequestFlags flags) +{ +QEMUIOVector qiov =QEMU_IOVEC_INIT_BUF (qiov, buf, bytes); + +return blk_co_preadv (blk, offset, bytes, &qiov, flags); +} + +static inline int coroutine_fn blk_co_pwrite(BlockBackend *blk, int64_t offset, +unsigned int bytes,void *buf, +BdrvRequestFlags flags) +{ +QEMUIOVector qiov =QEMU_IOVEC_INIT_BUF (qiov, buf, bytes); + +return blk_co_pwritev (blk, offset, bytes, &qiov, flags); +} +int blk_pwrite_zeroes (BlockBackend *blk,int64_t offset,int bytes,BdrvRequestFlags flags); BlockAIOCB *blk_aio_pwrite_zeroes(BlockBackend *blk, int64_t offset,
Signature · 1 line
2.18.0
PATCH 2/9 block/qcow2: use buffer-based io
In reply to Vladimir Sementsov-Ogievskiy--- block/qcow2.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
block/qcow2.c +2 -7
@@ -4088,7 +4088,6 @@ qcow2_co_pwritev_compressed(BlockDriverState *bs, uint64_t offset, uint64_t bytes, QEMUIOVector *qiov) { BDRVQcow2State *s = bs->opaque; -QEMUIOVector hd_qiov;int ret;size_t out_len;uint8_t *buf, *out_buf;
@@ -4155,10 +4154,8 @@ qcow2_co_pwritev_compressed(BlockDriverState *bs, uint64_t offset, goto fail; } -qemu_iovec_init_buf (&hd_qiov, out_buf, out_len); -BLKDBG_EVENT (s->data_file,BLKDBG_WRITE_COMPRESSED ); - ret =bdrv_co_pwritev (s->data_file, cluster_offset, out_len, &hd_qiov,0 ); + ret =bdrv_co_pwrite (s->data_file, cluster_offset, out_len, out_buf,0 );if (ret <0 ) { goto fail; }
@@ -4181,7 +4178,6 @@ qcow2_co_preadv_compressed(BlockDriverState *bs,int ret =0 , csize, nb_csectors;uint64_t coffset;uint8_t *buf, *out_buf; -QEMUIOVector local_qiov;int offset_in_cluster =offset_into_cluster (s, offset); coffset = file_cluster_offset & s->cluster_offset_mask;
@@ -4192,12 +4188,11 @@ qcow2_co_preadv_compressed(BlockDriverState *bs,if (!buf) {return -ENOMEM ; } -qemu_iovec_init_buf (&local_qiov, buf, csize); out_buf =qemu_blockalign (bs, s->cluster_size);BLKDBG_EVENT (bs->file,BLKDBG_READ_COMPRESSED ); - ret =bdrv_co_preadv (bs->file, coffset, csize, &local_qiov,0 ); + ret =bdrv_co_pread (bs->file, coffset, csize, buf,0 );if (ret <0 ) { goto fail; }
Signature · 1 line
2.18.0
PATCH 3/9 block/qcow: use buffer-based io
In reply to Vladimir Sementsov-Ogievskiy--- block/qcow.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-)
block/qcow.c +6 -13
@@ -631,7 +631,6 @@ static coroutine_fn int qcow_co_preadv(BlockDriverState *bs, uint64_t offset,int offset_in_cluster;int ret =0 , n;uint64_t cluster_offset; -QEMUIOVector hd_qiov;uint8_t *buf;void *orig_buf;
@@ -663,11 +662,10 @@ static coroutine_fn int qcow_co_preadv(BlockDriverState *bs, uint64_t offset,if (!cluster_offset) {if (bs->backing) {/* read from the base image */ -qemu_iovec_init_buf (&hd_qiov, buf, n);qemu_co_mutex_unlock (&s->lock);/* qcow2 emits this on bs->file instead of bs->backing */ BLKDBG_EVENT (bs->file,BLKDBG_READ_BACKING_AIO ); - ret =bdrv_co_preadv (bs->backing, offset, n, &hd_qiov,0 ); + ret =bdrv_co_pread (bs->backing, offset, n, buf,0 );qemu_co_mutex_lock (&s->lock);if (ret <0 ) {break ;
@@ -688,11 +686,10 @@ static coroutine_fn int qcow_co_preadv(BlockDriverState *bs, uint64_t offset, ret = -EIO ;break ; } -qemu_iovec_init_buf (&hd_qiov, buf, n);qemu_co_mutex_unlock (&s->lock);BLKDBG_EVENT (bs->file,BLKDBG_READ_AIO ); - ret =bdrv_co_preadv (bs->file, cluster_offset + offset_in_cluster, - n, &hd_qiov,0 ); + ret =bdrv_co_pread (bs->file, cluster_offset + offset_in_cluster, + n, buf,0 );qemu_co_mutex_lock (&s->lock);if (ret <0 ) {break ;
@@ -731,7 +728,6 @@ static coroutine_fn int qcow_co_pwritev(BlockDriverState *bs, uint64_t offset,int offset_in_cluster;uint64_t cluster_offset;int ret =0 , n; -QEMUIOVector hd_qiov;uint8_t *buf;void *orig_buf;
@@ -776,11 +772,10 @@ static coroutine_fn int qcow_co_pwritev(BlockDriverState *bs, uint64_t offset, } } -qemu_iovec_init_buf (&hd_qiov, buf, n);qemu_co_mutex_unlock (&s->lock);BLKDBG_EVENT (bs->file,BLKDBG_WRITE_AIO ); - ret =bdrv_co_pwritev (bs->file, cluster_offset + offset_in_cluster, - n, &hd_qiov,0 ); + ret =bdrv_co_pwrite (bs->file, cluster_offset + offset_in_cluster, + n, buf,0 );qemu_co_mutex_lock (&s->lock);if (ret <0 ) {break ;
@@ -1056,7 +1051,6 @@ qcow_co_pwritev_compressed(BlockDriverState *bs, uint64_t offset, uint64_t bytes, QEMUIOVector *qiov) { BDRVQcowState *s = bs->opaque; -QEMUIOVector hd_qiov;z_stream strm;int ret, out_len;uint8_t *buf, *out_buf;
@@ -1122,9 +1116,8 @@ qcow_co_pwritev_compressed(BlockDriverState *bs, uint64_t offset, } cluster_offset &= s->cluster_offset_mask; -qemu_iovec_init_buf (&hd_qiov, out_buf, out_len);BLKDBG_EVENT (bs->file,BLKDBG_WRITE_COMPRESSED ); - ret =bdrv_co_pwritev (bs->file, cluster_offset, out_len, &hd_qiov,0 ); + ret =bdrv_co_pwrite (bs->file, cluster_offset, out_len, out_buf,0 );if (ret <0 ) { goto fail; }
Signature · 1 line
2.18.0
PATCH 4/9 block/qed: use buffer-based io
In reply to Vladimir Sementsov-OgievskiyMove to _co_ versions of io functions qed_read_table() and qed_write_table(), as we use qemu_co_mutex_unlock() anyway.
--- block/qed-table.c | 12 +++++------- block/qed.c | 6 ++---- 2 files changed, 7 insertions(+), 11 deletions(-)
block/qed-table.c +5 -7
@@ -21,22 +21,22 @@/* Called with table_lock held. */ static int qed_read_table (BDRVQEDState *s,uint64_t offset,QEDTable *table) { -QEMUIOVector qiov =QEMU_IOVEC_INIT_BUF ( - qiov, table->offsets, s->header.cluster_size * s->header.table_size); +unsigned int bytes = s->header.cluster_size * s->header.table_size; +int noffsets;int i, ret;trace_qed_read_table (s, offset, table);qemu_co_mutex_unlock (&s->table_lock); - ret =bdrv_preadv (s->bs->file, offset, &qiov); + ret =bdrv_co_pread (s->bs->file, offset, bytes, table->offsets,0 );qemu_co_mutex_lock (&s->table_lock);if (ret <0 ) { goto out; }/* Byteswap offsets */ - noffsets = qiov.size /sizeof (uint64_t ); + noffsets = bytes /sizeof (uint64_t );for (i =0 ; i < noffsets; i++) { table->offsets[i] =le64_to_cpu (table->offsets[i]); }
@@ -66,7 +66,6 @@ static int qed_write_table(BDRVQEDState *s, uint64_t offset, QEDTable *table,unsigned int sector_mask =BDRV_SECTOR_SIZE /sizeof (uint64_t ) -1 ;unsigned int start, end, i;QEDTable *new_table; -QEMUIOVector qiov;size_t len_bytes;int ret;
@@ -79,7 +78,6 @@ static int qed_write_table(BDRVQEDState *s, uint64_t offset, QEDTable *table, len_bytes = (end - start) *sizeof (uint64_t ); new_table =qemu_blockalign (s->bs, len_bytes); -qemu_iovec_init_buf (&qiov, new_table->offsets, len_bytes);/* Byteswap table */ for (i = start; i < end; i++) {
@@ -91,7 +89,7 @@ static int qed_write_table(BDRVQEDState *s, uint64_t offset, QEDTable *table, offset += start *sizeof (uint64_t );qemu_co_mutex_unlock (&s->table_lock); - ret =bdrv_pwritev (s->bs->file, offset, &qiov); + ret =bdrv_co_pwrite (s->bs->file, offset, len_bytes, new_table->offsets,0 );qemu_co_mutex_lock (&s->table_lock);trace_qed_write_table_cb (s, table, flush, ret);if (ret <0 ) {
block/qed.c +2 -4
@@ -113,15 +113,13 @@ static int coroutine_fn qed_write_header(BDRVQEDState *s)int nsectors =DIV_ROUND_UP (sizeof (QEDHeader),BDRV_SECTOR_SIZE );size_t len = nsectors *BDRV_SECTOR_SIZE ;uint8_t *buf; -QEMUIOVector qiov;int ret;assert (s->allocating_acb || s->allocating_write_reqs_plugged); buf =qemu_blockalign (s->bs, len); -qemu_iovec_init_buf (&qiov, buf, len); - ret =bdrv_co_preadv (s->bs->file,0 , qiov.size, &qiov,0 ); + ret =bdrv_co_pread (s->bs->file,0 , len, buf,0 );if (ret <0 ) { goto out; }
@@ -129,7 +127,7 @@ static int coroutine_fn qed_write_header(BDRVQEDState *s)/* Update header */ qed_header_cpu_to_le (&s->header, (QEDHeader *) buf); - ret =bdrv_co_pwritev (s->bs->file,0 , qiov.size, &qiov,0 ); + ret =bdrv_co_pwrite (s->bs->file,0 , len, buf,0 );if (ret <0 ) { goto out; }
Signature · 1 line
2.18.0
Re: [Qemu-devel] [PATCH 4/9] block/qed: use buffer-based io
Am 22.04.2019 um 16:58 hat Vladimir Sementsov-Ogievskiy geschrieben:
Quoted 20 lines
Move to _co_ versions of io functions
qed_read_table()andqed_write_table(), as we useqemu_co_mutex_unlock()anyway.Signed-off-by Vladimir Sementsov-Ogievskiy <[email protected]>--- block/qed-table.c | 12 +++++------- block/qed.c | 6 ++---- 2 files changed, 7 insertions(+), 11 deletions(-)block/qed-table.c +0
-2@@ -21,22 +21,22 @@/* Called with table_lock held. */ static int qed_read_table (BDRVQEDState *s,uint64_t offset,QEDTable *table) { -QEMUIOVector qiov =QEMU_IOVEC_INIT_BUF ( - qiov, table->offsets, s->header.cluster_size * s->header.table_size);
block/qed-table.c line 32
Quoted 10 lines
block/qed-table.c +3
-1+unsigned int bytes = s->header.cluster_size * s->header.table_size; +int noffsets;int i, ret;trace_qed_read_table (s, offset, table);qemu_co_mutex_unlock (&s->table_lock); - ret =bdrv_preadv (s->bs->file, offset, &qiov); + ret =bdrv_co_pread (s->bs->file, offset, bytes, table->offsets,0 );
Careful! This function is not marked as coroutine_fn, and I remember that there were some non-coroutine callers when I converted qed to coroutines.
It looks like we're lucky and all callers have been converted to coroutines meanwhile, but I would prefer if we added the coroutine_fn marker everywhere where we rely on it now to document this fact.
Quoted 28 lines
block/qed-table.c +1
-3qemu_co_mutex_lock (&s->table_lock);if (ret <0 ) { goto out; }/* Byteswap offsets */ - noffsets = qiov.size /sizeof (uint64_t ); + noffsets = bytes /sizeof (uint64_t );for (i =0 ; i < noffsets; i++) { table->offsets[i] =le64_to_cpu (table->offsets[i]); }@@ -66,7 +66,6 @@ static int qed_write_table(BDRVQEDState *s, uint64_t offset, QEDTable *table,unsigned int sector_mask =BDRV_SECTOR_SIZE /sizeof (uint64_t ) -1 ;unsigned int start, end, i;QEDTable *new_table; -QEMUIOVector qiov;size_t len_bytes;int ret;@@ -79,7 +78,6 @@ static int qed_write_table(BDRVQEDState *s, uint64_t offset, QEDTable *table, len_bytes = (end - start) *sizeof (uint64_t ); new_table =qemu_blockalign (s->bs, len_bytes); -qemu_iovec_init_buf (&qiov, new_table->offsets, len_bytes);/* Byteswap table */ for (i = start; i < end; i++) {
block/qed-table.c static int qed_write_table(BDRVQEDState *s, uint64_t offset, QEDTable *table, · line 95
Quoted 8 lines
block/qed-table.c +1
-1@@ -91,7 +89,7 @@ static int qed_write_table(BDRVQEDState *s, uint64_t offset, QEDTable *table, offset += start *sizeof (uint64_t );qemu_co_mutex_unlock (&s->table_lock); - ret =bdrv_pwritev (s->bs->file, offset, &qiov); + ret =bdrv_co_pwrite (s->bs->file, offset, len_bytes, new_table->offsets,0 );qemu_co_mutex_lock (&s->table_lock);trace_qed_write_table_cb (s, table, flush, ret);if (ret <0 ) {
Same for the callers of this function.
Kevin
PATCH 5/9 block/parallels: use buffer-based io
In reply to Vladimir Sementsov-Ogievskiy--- block/parallels.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
block/parallels.c +6 -8
@@ -220,20 +220,18 @@ static int64_t allocate_clusters(BlockDriverState *bs, int64_t sector_num,if (bs->backing) {int64_t nb_cow_sectors = to_allocate * s->tracks;int64_t nb_cow_bytes = nb_cow_sectors <<BDRV_SECTOR_BITS ; -QEMUIOVector qiov = -QEMU_IOVEC_INIT_BUF (qiov,qemu_blockalign (bs, nb_cow_bytes), - nb_cow_bytes); +void *buf =qemu_blockalign (bs, nb_cow_bytes); - ret =bdrv_co_preadv (bs->backing, idx * s->tracks *BDRV_SECTOR_SIZE , - nb_cow_bytes, &qiov,0 ); + ret =bdrv_co_pread (bs->backing, idx * s->tracks *BDRV_SECTOR_SIZE , + nb_cow_bytes, buf,0 );if (ret <0 ) { -qemu_vfree (qemu_iovec_buf (&qiov)); +qemu_vfree (buf);return ret; } ret =bdrv_co_pwritev (bs->file, s->data_end *BDRV_SECTOR_SIZE , - nb_cow_bytes, &qiov,0 ); -qemu_vfree (qemu_iovec_buf (&qiov)); + nb_cow_bytes, buf,0 ); +qemu_vfree (buf);if (ret <0 ) {return ret; }
Signature · 1 line
2.18.0
PATCH 6/9 block/backup: use buffer-based io
In reply to Vladimir Sementsov-Ogievskiy--- block/backup.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
block/backup.c +6 -8
@@ -107,7 +107,6 @@ static int coroutine_fn backup_cow_with_bounce_buffer(BackupBlockJob *job, void **bounce_buffer) {int ret; -QEMUIOVector qiov;BlockBackend *blk = job->common.blk;int nbytes;int read_flags = is_write_notifier ?BDRV_REQ_NO_SERIALISING :0 ;
@@ -118,9 +117,8 @@ static int coroutine_fn backup_cow_with_bounce_buffer(BackupBlockJob *job,if (!*bounce_buffer) { *bounce_buffer =blk_blockalign (blk, job->cluster_size); } -qemu_iovec_init_buf (&qiov, *bounce_buffer, nbytes); - ret =blk_co_preadv (blk, start, qiov.size, &qiov, read_flags); + ret =blk_co_pread (blk, start, nbytes, *bounce_buffer, read_flags);if (ret <0 ) {trace_backup_do_cow_read_fail (job, start, ret);if (error_is_read) {
@@ -129,13 +127,13 @@ static int coroutine_fn backup_cow_with_bounce_buffer(BackupBlockJob *job, goto fail; } -if (qemu_iovec_is_zero (&qiov)) { +if (buffer_is_zero (*bounce_buffer, nbytes)) { ret =blk_co_pwrite_zeroes (job->target, start, - qiov.size, write_flags |BDRV_REQ_MAY_UNMAP ); + nbytes, write_flags |BDRV_REQ_MAY_UNMAP ); }else { - ret =blk_co_pwritev (job->target, start, - qiov.size, &qiov, write_flags | - (job->compress ?BDRV_REQ_WRITE_COMPRESSED :0 )); + ret =blk_co_pwrite (job->target, start, + nbytes, *bounce_buffer, write_flags | + (job->compress ?BDRV_REQ_WRITE_COMPRESSED :0 )); }if (ret <0 ) {trace_backup_do_cow_write_fail (job, start, ret);
Signature · 1 line
2.18.0
PATCH 7/9 block/commit: use buffer-based io
In reply to Vladimir Sementsov-Ogievskiy--- block/commit.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
block/commit.c +2 -3
@@ -48,16 +48,15 @@ static int coroutine_fn commit_populate(BlockBackend *bs, BlockBackend *base, void *buf) {int ret =0 ; -QEMUIOVector qiov =QEMU_IOVEC_INIT_BUF (qiov, buf, bytes);assert (bytes <SIZE_MAX ); - ret =blk_co_preadv (bs, offset, qiov.size, &qiov,0 ); + ret =blk_co_pread (bs, offset, bytes, buf,0 );if (ret <0 ) {return ret; } - ret =blk_co_pwritev (base, offset, qiov.size, &qiov,0 ); + ret =blk_co_pwrite (base, offset, bytes, buf,0 );if (ret <0 ) {return ret; }
Signature · 1 line
2.18.0
PATCH 8/9 block/stream: use buffer-based io
In reply to Vladimir Sementsov-Ogievskiy--- block/stream.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
block/stream.c +1 -3
@@ -42,12 +42,10 @@ static int coroutine_fn stream_populate(BlockBackend *blk, int64_t offset, uint64_t bytes, void *buf) { - QEMUIOVector qiov = QEMU_IOVEC_INIT_BUF(qiov, buf, bytes); - assert(bytes < SIZE_MAX);/* Copy-on-read the unallocated clusters */ -return blk_co_preadv (blk, offset, qiov.size, &qiov,BDRV_REQ_COPY_ON_READ ); +return blk_co_pread (blk, offset, bytes, buf,BDRV_REQ_COPY_ON_READ ); }static void stream_abort (Job *job)
Signature · 1 line
2.18.0
PATCH 9/9 qemu-img: use buffer-based io
In reply to Vladimir Sementsov-Ogievskiy--- qemu-img.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
qemu-img.c +4 -9
@@ -1671,7 +1671,6 @@ static int coroutine_fn convert_co_read(ImgConvertState *s, int64_t sector_num, int nb_sectors, uint8_t *buf) { int n, ret; -QEMUIOVector qiov;assert (nb_sectors <= s->buf_sectors);while (nb_sectors >0 ) {
@@ -1687,11 +1686,10 @@ static int coroutine_fn convert_co_read(ImgConvertState *s, int64_t sector_num, bs_sectors = s->src_sectors[src_cur]; n =MIN (nb_sectors, bs_sectors - (sector_num - src_cur_offset)); -qemu_iovec_init_buf (&qiov, buf, n <<BDRV_SECTOR_BITS ); - ret =blk_co_preadv ( + ret =blk_co_pread ( blk, (sector_num - src_cur_offset) <<BDRV_SECTOR_BITS , - n <<BDRV_SECTOR_BITS , &qiov,0 ); + n <<BDRV_SECTOR_BITS , buf,0 );if (ret <0 ) {return ret; }
@@ -1710,7 +1708,6 @@ static int coroutine_fn convert_co_write(ImgConvertState *s, int64_t sector_num, enum ImgConvertBlockStatus status) {int ret; -QEMUIOVector qiov;while (nb_sectors >0 ) {int n = nb_sectors;
@@ -1738,10 +1735,8 @@ static int coroutine_fn convert_co_write(ImgConvertState *s, int64_t sector_num, (s->compressed && !buffer_is_zero(buf, n * BDRV_SECTOR_SIZE))) { -qemu_iovec_init_buf (&qiov, buf, n <<BDRV_SECTOR_BITS ); - - ret =blk_co_pwritev (s->target, sector_num <<BDRV_SECTOR_BITS , - n <<BDRV_SECTOR_BITS , &qiov, flags); + ret =blk_co_pwrite (s->target, sector_num <<BDRV_SECTOR_BITS , + n <<BDRV_SECTOR_BITS , buf, flags);if (ret <0 ) {return ret; }
Signature · 1 line
2.18.0
Quoted 16 lines · Vladimir Sementsov-Ogievskiy
Hi all!
We often need to do read/write with buffer, not qiov. Instead of creating qiov in such cases, let's introduce corresponding helpers.
Vladimir Sementsov-Ogievskiy (9):
block: introduce byte-based io helpers
block/qcow2: use buffer-based io
block/qcow: use buffer-based io
block/qed: use buffer-based io
block/parallels: use buffer-based io
block/backup: use buffer-based io
block/commit: use buffer-based io
block/stream: use buffer-based io
qemu-img: use buffer-based io
Quoted 16 lines
include/block/block_int.h | 16 ++++++++++++++++ include/sysemu/block-backend.h | 19 +++++++++++++++++++ block/backup.c | 14 ++++++-------- block/commit.c | 5 ++--- block/parallels.c | 14 ++++++-------- block/qcow.c | 19 ++++++------------- block/qcow2.c | 9 ++------- block/qed-table.c | 12 +++++------- block/qed.c | 6 ++---- block/stream.c | 4 +--- qemu-img.c | 13 ++++--------- 11 files changed, 69 insertions(+), 62 deletions(-)Signature · 1 line
2.18.0
Quoted 30 lines · Stefan Hajnoczi
Quoted 29 lines · Vladimir Sementsov-Ogievskiy
Hi all!
We often need to do read/write with buffer, not qiov. Instead of creating qiov in such cases, let's introduce corresponding helpers.
Vladimir Sementsov-Ogievskiy (9):
block: introduce byte-based io helpers
block/qcow2: use buffer-based io
block/qcow: use buffer-based io
block/qed: use buffer-based io
block/parallels: use buffer-based io
block/backup: use buffer-based io
block/commit: use buffer-based io
block/stream: use buffer-based io
qemu-img: use buffer-based ioinclude/block/block_int.h | 16 ++++++++++++++++ include/sysemu/block-backend.h | 19 +++++++++++++++++++ block/backup.c | 14 ++++++-------- block/commit.c | 5 ++--- block/parallels.c | 14 ++++++-------- block/qcow.c | 19 ++++++------------- block/qcow2.c | 9 ++------- block/qed-table.c | 12 +++++------- block/qed.c | 6 ++---- block/stream.c | 4 +--- qemu-img.c | 13 ++++--------- 11 files changed, 69 insertions(+), 62 deletions(-)
Quoted 6 lines
Quoted 3 lines
Signature · 1 line
2.18.0Reviewed-by Stefan Hajnoczi <[email protected]>
Thanks!
Signature · 2 lines
Best regards, Vladimir
Quoted 16 lines · Vladimir Sementsov-Ogievskiy
Hi all!
We often need to do read/write with buffer, not qiov. Instead of creating qiov in such cases, let's introduce corresponding helpers.
Vladimir Sementsov-Ogievskiy (9):
block: introduce byte-based io helpers
block/qcow2: use buffer-based io
block/qcow: use buffer-based io
block/qed: use buffer-based io
block/parallels: use buffer-based io
block/backup: use buffer-based io
block/commit: use buffer-based io
block/stream: use buffer-based io
qemu-img: use buffer-based io
Quoted 16 lines
include/block/block_int.h | 16 ++++++++++++++++ include/sysemu/block-backend.h | 19 +++++++++++++++++++ block/backup.c | 14 ++++++-------- block/commit.c | 5 ++--- block/parallels.c | 14 ++++++-------- block/qcow.c | 19 ++++++------------- block/qcow2.c | 9 ++------- block/qed-table.c | 12 +++++------- block/qed.c | 6 ++---- block/stream.c | 4 +--- qemu-img.c | 13 ++++--------- 11 files changed, 69 insertions(+), 62 deletions(-)Signature · 1 line
2.18.0
The series LGTM and new helpers could be very useful!
Thanks,
Stefano
Quoted 30 lines · Stefano Garzarella
Quoted 29 lines · Vladimir Sementsov-Ogievskiy
Hi all!
We often need to do read/write with buffer, not qiov. Instead of creating qiov in such cases, let's introduce corresponding helpers.
Vladimir Sementsov-Ogievskiy (9):
block: introduce byte-based io helpers
block/qcow2: use buffer-based io
block/qcow: use buffer-based io
block/qed: use buffer-based io
block/parallels: use buffer-based io
block/backup: use buffer-based io
block/commit: use buffer-based io
block/stream: use buffer-based io
qemu-img: use buffer-based ioinclude/block/block_int.h | 16 ++++++++++++++++ include/sysemu/block-backend.h | 19 +++++++++++++++++++ block/backup.c | 14 ++++++-------- block/commit.c | 5 ++--- block/parallels.c | 14 ++++++-------- block/qcow.c | 19 ++++++------------- block/qcow2.c | 9 ++------- block/qed-table.c | 12 +++++------- block/qed.c | 6 ++---- block/stream.c | 4 +--- qemu-img.c | 13 ++++--------- 11 files changed, 69 insertions(+), 62 deletions(-)
Quoted 8 lines
Quoted 3 lines
Signature · 1 line
2.18.0The series LGTM and new helpers could be very useful!
Reviewed-by Stefano Garzarella <[email protected]>
Thanks!
Signature · 2 lines
Best regards, Vladimir
Kevin Wolf
AppliedAm 22.04.2019 um 16:58 hat Vladimir Sementsov-Ogievskiy geschrieben:
Quoted 4 lines
Hi all!
We often need to do read/write with buffer, not qiov. Instead of creating qiov in such cases, let's introduce corresponding helpers.
Thanks, applied to the block branch.
As I wrote in patch 4, a follow-up that adds coroutine_fn markers where we rely on being in coroutine context now would be nice.
Kevin