block: drop useless checks for NULL
cover block: drop useless checks for NULL
After the coroutinization of the block layer, immediate failures of an AIO operation will still return an AIOCB and only report failure with a bottom half. This lets us remove a lot of dead NULL checks (patches 1-5).
Patch 6 is on a similar theme, but a bit different.
Most "added" lines are actually just reindented.
Paolo Bonzini (6):
block: bdrv_aio_* do not return NULL
block: simplify failure handling for bdrv_aio_multiwrite
block: qemu_aio_get does not return NULL
dma: the passed io_func does not return NULL
block: dma_bdrv_* does not return NULL
block: avoid useless checks on acb->bh
block-migration.c | 13 ---------- block.c | 56 +++----------------------------------------- block/blkverify.c | 24 ++++++------------ block/curl.c | 4 --- block/qed-table.c | 22 +++++----------- block/qed.c | 60 ++++++++++++---------------------------------- block/rbd.c | 3 -- block/vdi.c | 66 ++++++++++++++------------------------------------- dma-helpers.c | 4 +-- hw/ide/atapi.c | 8 +----- hw/ide/core.c | 13 +--------- hw/ide/macio.c | 11 +-------- hw/scsi-disk.c | 9 ------- hw/scsi-generic.c | 4 --- hw/virtio-blk.c | 19 +++----------- linux-aio.c | 2 - posix-aio-compat.c | 4 --- qemu-io.c | 39 ++++++------------------------ trace-events | 2 - 19 files changed, 69 insertions(+), 294 deletions(-)
Signature · 1 line
1.7.7.1
PATCH 1/6 block: bdrv_aio_* do not return NULL
Initially done with the following semantic patch:
@ rule1 @
expression E;
statement S;
@@
E =
(
bdrv_aio_readv
| bdrv_aio_writev
| bdrv_aio_flush
| bdrv_aio_discard
| bdrv_aio_ioctl
)
(...);(
- if (E == NULL) { ... }
|
- if (E)
{ <... S ...> })
which however missed the occurrence in block/blkverify.c (as it should have done) and required further cleanup of dead code and unused variables.
--- block-migration.c | 13 ----------- block.c | 24 +-------------------- block/blkverify.c | 24 +++++++-------------- block/qed-table.c | 22 ++++++------------- block/qed.c | 60 ++++++++++++++-------------------------------------- block/vdi.c | 20 ----------------- hw/ide/atapi.c | 8 +------ hw/ide/core.c | 7 +----- hw/ide/macio.c | 7 ------ hw/scsi-disk.c | 9 -------- hw/scsi-generic.c | 4 --- hw/virtio-blk.c | 19 +++------------- qemu-io.c | 39 +++++++--------------------------- trace-events | 2 - 14 files changed, 46 insertions(+), 212 deletions(-)
block-migration.c +0 -13
@@ -251,22 +251,12 @@ static int mig_save_device_bulk(Monitor *mon, QEMUFile *f, blk->aiocb =bdrv_aio_readv (bs, cur_sector, &blk->qiov, nr_sectors, blk_mig_read_cb, blk); -if (!blk->aiocb) { - goto error; - } block_mig_state.submitted++;bdrv_reset_dirty (bs, cur_sector, nr_sectors); bmds->cur_sector = cur_sector + nr_sectors;return (bmds->cur_sector >= total_sectors); - -error: -monitor_printf (mon,"Error reading sector %" PRId64"\n" , cur_sector); -qemu_file_set_error (f, -EIO ); -g_free (blk->buf); -g_free (blk); -return 0 ; }static void set_dirty_tracking (int enable)
@@ -413,9 +403,6 @@ static int mig_save_device_dirty(Monitor *mon, QEMUFile *f, blk->aiocb =bdrv_aio_readv (bmds->bs, sector, &blk->qiov, nr_sectors, blk_mig_read_cb, blk); -if (!blk->aiocb) { - goto error; - } block_mig_state.submitted++;bmds_set_aio_inflight (bmds, sector, nr_sectors,1 ); }else {
block.c +1 -23
@@ -2389,7 +2389,6 @@ static int multiwrite_merge(BlockDriverState *bs, BlockRequest *reqs,*/ int bdrv_aio_multiwrite (BlockDriverState *bs,BlockRequest *reqs,int num_reqs) { -BlockDriverAIOCB *acb;MultiwriteCB *mcb;int i;
@@ -2444,35 +2443,14 @@ int bdrv_aio_multiwrite(BlockDriverState *bs, BlockRequest *reqs, int num_reqs)// Run the aio requests for (i =0 ; i < num_reqs; i++) { mcb->num_requests++; - acb =bdrv_aio_writev (bs, reqs[i].sector, reqs[i].qiov, +bdrv_aio_writev (bs, reqs[i].sector, reqs[i].qiov, reqs[i].nb_sectors, multiwrite_cb, mcb); - -if (acb ==NULL ) { -// We can only fail the whole thing if no request has been -// submitted yet. Otherwise we'll wait for the submitted AIOs to -// complete and report the error in the callback. -if (i ==0 ) { -trace_bdrv_aio_multiwrite_earlyfail (mcb); - goto fail; - }else { -trace_bdrv_aio_multiwrite_latefail (mcb, i); -multiwrite_cb (mcb, -EIO ); -break ; - } - } }/* Complete the dummy request */ multiwrite_cb (mcb,0 );return 0 ; - -fail: -for (i =0 ; i < mcb->num_callbacks; i++) { - reqs[i].error = -EIO ; - } -g_free (mcb); -return -1 ; }void bdrv_aio_cancel (BlockDriverAIOCB *acb)
block/blkverify.c +8 -16
@@ -310,14 +310,10 @@ static BlockDriverAIOCB *blkverify_aio_readv(BlockDriverState *bs,qemu_iovec_init (&acb->raw_qiov, acb->qiov->niov);blkverify_iovec_clone (&acb->raw_qiov, qiov, acb->buf); -if (!bdrv_aio_readv (s->test_file, sector_num, qiov, nb_sectors, - blkverify_aio_cb, acb)) { -blkverify_aio_cb (acb, -EIO ); - } -if (!bdrv_aio_readv (bs->file, sector_num, &acb->raw_qiov, nb_sectors, - blkverify_aio_cb, acb)) { -blkverify_aio_cb (acb, -EIO ); - } +bdrv_aio_readv (s->test_file, sector_num, qiov, nb_sectors, + blkverify_aio_cb, acb); +bdrv_aio_readv (bs->file, sector_num, &acb->raw_qiov, nb_sectors, + blkverify_aio_cb, acb);return &acb->common; }
@@ -329,14 +325,10 @@ static BlockDriverAIOCB *blkverify_aio_writev(BlockDriverState *bs,BlkverifyAIOCB *acb =blkverify_aio_get (bs, true, sector_num, qiov, nb_sectors, cb, opaque); -if (!bdrv_aio_writev (s->test_file, sector_num, qiov, nb_sectors, - blkverify_aio_cb, acb)) { -blkverify_aio_cb (acb, -EIO ); - } -if (!bdrv_aio_writev (bs->file, sector_num, qiov, nb_sectors, - blkverify_aio_cb, acb)) { -blkverify_aio_cb (acb, -EIO ); - } +bdrv_aio_writev (s->test_file, sector_num, qiov, nb_sectors, + blkverify_aio_cb, acb); +bdrv_aio_writev (bs->file, sector_num, qiov, nb_sectors, + blkverify_aio_cb, acb);return &acb->common; }
block/qed-table.c +7 -15
@@ -54,7 +54,6 @@ static void qed_read_table(BDRVQEDState *s, uint64_t offset, QEDTable *table,QEDReadTableCB *read_table_cb =gencb_alloc (sizeof (*read_table_cb), cb, opaque);QEMUIOVector *qiov = &read_table_cb->qiov; -BlockDriverAIOCB *aiocb;trace_qed_read_table (s, offset, table);
@@ -64,12 +63,9 @@ static void qed_read_table(BDRVQEDState *s, uint64_t offset, QEDTable *table, read_table_cb->iov.iov_len = s->header.cluster_size * s->header.table_size,qemu_iovec_init_external (qiov, &read_table_cb->iov,1 ); - aiocb =bdrv_aio_readv (s->bs->file, offset /BDRV_SECTOR_SIZE , qiov, - read_table_cb->iov.iov_len /BDRV_SECTOR_SIZE , - qed_read_table_cb, read_table_cb); -if (!aiocb) { -qed_read_table_cb (read_table_cb, -EIO ); - } +bdrv_aio_readv (s->bs->file, offset /BDRV_SECTOR_SIZE , qiov, + read_table_cb->iov.iov_len /BDRV_SECTOR_SIZE , + qed_read_table_cb, read_table_cb); } typedef struct {
@@ -127,7 +123,6 @@ static void qed_write_table(BDRVQEDState *s, uint64_t offset, QEDTable *table, BlockDriverCompletionFunc *cb, void *opaque) {QEDWriteTableCB *write_table_cb; -BlockDriverAIOCB *aiocb;unsigned int sector_mask =BDRV_SECTOR_SIZE /sizeof (uint64_t ) -1 ;unsigned int start, end, i;size_t len_bytes;
@@ -158,13 +153,10 @@ static void qed_write_table(BDRVQEDState *s, uint64_t offset, QEDTable *table,/* Adjust for offset into table */ offset += start *sizeof (uint64_t ); - aiocb =bdrv_aio_writev (s->bs->file, offset /BDRV_SECTOR_SIZE , - &write_table_cb->qiov, - write_table_cb->iov.iov_len /BDRV_SECTOR_SIZE , - qed_write_table_cb, write_table_cb); -if (!aiocb) { -qed_write_table_cb (write_table_cb, -EIO ); - } +bdrv_aio_writev (s->bs->file, offset /BDRV_SECTOR_SIZE , + &write_table_cb->qiov, + write_table_cb->iov.iov_len /BDRV_SECTOR_SIZE , + qed_write_table_cb, write_table_cb); }/**
block/qed.c +16 -44
132 lines not on this page · raw message
block/vdi.c +0 -20
@@ -624,10 +624,6 @@ static void vdi_aio_read_cb(void *opaque, int ret)qemu_iovec_init_external (&acb->hd_qiov, &acb->hd_iov,1 ); acb->hd_aiocb =bdrv_aio_readv (bs->file, offset, &acb->hd_qiov, n_sectors, vdi_aio_read_cb, acb); -if (acb->hd_aiocb ==NULL ) { - ret = -EIO ; - goto done; - } }return ; done:
@@ -699,10 +695,6 @@ static void vdi_aio_write_cb(void *opaque, int ret)qemu_iovec_init_external (&acb->hd_qiov, &acb->hd_iov,1 ); acb->hd_aiocb =bdrv_aio_writev (bs->file,0 , &acb->hd_qiov,1 , vdi_aio_write_cb, acb); -if (acb->hd_aiocb ==NULL ) { - ret = -EIO ; - goto done; - }return ; }else if (VDI_IS_ALLOCATED (acb->bmap_first)) {/* One or more new blocks were allocated. */
@@ -729,10 +721,6 @@ static void vdi_aio_write_cb(void *opaque, int ret) n_sectors, bmap_first); acb->hd_aiocb =bdrv_aio_writev (bs->file, offset, &acb->hd_qiov, n_sectors, vdi_aio_write_cb, acb); -if (acb->hd_aiocb ==NULL ) { - ret = -EIO ; - goto done; - }return ; } ret =0 ;
@@ -780,10 +768,6 @@ static void vdi_aio_write_cb(void *opaque, int ret) acb->hd_aiocb =bdrv_aio_writev (bs->file, offset, &acb->hd_qiov, s->block_sectors, vdi_aio_write_cb, acb); -if (acb->hd_aiocb ==NULL ) { - ret = -EIO ; - goto done; - } }else {uint64_t offset = s->header.offset_data /SECTOR_SIZE + (uint64_t)bmap_entry * s->block_sectors +
@@ -793,10 +777,6 @@ static void vdi_aio_write_cb(void *opaque, int ret)qemu_iovec_init_external (&acb->hd_qiov, &acb->hd_iov,1 ); acb->hd_aiocb =bdrv_aio_writev (bs->file, offset, &acb->hd_qiov, n_sectors, vdi_aio_write_cb, acb); -if (acb->hd_aiocb ==NULL ) { - ret = -EIO ; - goto done; - } }return ;
hw/ide/atapi.c +1 -7
@@ -352,14 +352,8 @@ static void ide_atapi_cmd_read_dma_cb(void *opaque, int ret) s->bus->dma->aiocb =bdrv_aio_readv (s->bs, (int64_t )s->lba <<2 , &s->bus->dma->qiov, n *4 , ide_atapi_cmd_read_dma_cb, s); -if (!s->bus->dma->aiocb) { -/* Note: media not present is the most likely case */ -ide_atapi_cmd_error (s,NOT_READY , -ASC_MEDIUM_NOT_PRESENT ); - goto eot; - } -return ; + eot:bdrv_acct_done (s->bs, &s->acct); s->bus->dma->ops->add_status (s->bus->dma,BM_STATUS_INT );
hw/ide/core.c +1 -6
@@ -718,18 +718,13 @@ static void ide_flush_cb(void *opaque, int ret)void ide_flush_cache (IDEState *s) { -BlockDriverAIOCB *acb; -if (s->bs ==NULL ) {ide_flush_cb (s,0 );return ; }bdrv_acct_start (s->bs, &s->acct,0 ,BDRV_ACCT_FLUSH ); - acb =bdrv_aio_flush (s->bs, ide_flush_cb, s); -if (acb ==NULL ) { -ide_flush_cb (s, -EIO ); - } +bdrv_aio_flush (s->bs, ide_flush_cb, s); }static void ide_cfata_metadata_inquiry (IDEState *s)
hw/ide/macio.c +0 -7
@@ -84,13 +84,6 @@ static void pmac_ide_atapi_transfer_cb(void *opaque, int ret) m->aiocb =dma_bdrv_read (s->bs, &s->sg, (int64_t )(s->lba <<2 ) + (s->io_buffer_index >>9 ), pmac_ide_atapi_transfer_cb, io); -if (!m->aiocb) { -qemu_sglist_destroy (&s->sg); -/* Note: media not present is the most likely case */ -ide_atapi_cmd_error (s,NOT_READY , -ASC_MEDIUM_NOT_PRESENT ); - goto done; - }return ; done:
hw/scsi-disk.c +0 -9
@@ -217,9 +217,6 @@ static void scsi_read_data(SCSIRequest *req)bdrv_acct_start (s->qdev.conf.bs, &r->acct, n *BDRV_SECTOR_SIZE ,BDRV_ACCT_READ ); r->req.aiocb =bdrv_aio_readv (s->qdev.conf.bs, r->sector, &r->qiov, n, scsi_read_complete, r); -if (r->req.aiocb ==NULL ) { -scsi_read_complete (r, -EIO ); - } }/*
@@ -327,9 +324,6 @@ static void scsi_write_data(SCSIRequest *req)bdrv_acct_start (s->qdev.conf.bs, &r->acct, n *BDRV_SECTOR_SIZE ,BDRV_ACCT_WRITE ); r->req.aiocb =bdrv_aio_writev (s->qdev.conf.bs, r->sector, &r->qiov, n, scsi_write_complete, r); -if (r->req.aiocb ==NULL ) { -scsi_write_complete (r, -ENOMEM ); - } }else {/* Called for the first time. Ask the driver to send us more data. */ scsi_write_complete (r,0 );
@@ -1326,9 +1320,6 @@ static int32_t scsi_send_command(SCSIRequest *req, uint8_t *buf)scsi_req_ref (&r->req);bdrv_acct_start (s->qdev.conf.bs, &r->acct,0 ,BDRV_ACCT_FLUSH ); r->req.aiocb =bdrv_aio_flush (s->qdev.conf.bs, scsi_flush_complete, r); -if (r->req.aiocb ==NULL ) { -scsi_flush_complete (r, -EIO ); - }return 0 ;case READ_6 :case READ_10 :
hw/scsi-generic.c +0 -4
@@ -152,10 +152,6 @@ static int execute_command(BlockDriverState *bdrv, r->io_header.flags |=SG_FLAG_DIRECT_IO ; r->req.aiocb =bdrv_aio_ioctl (bdrv,SG_IO , &r->io_header, complete, r); -if (r->req.aiocb ==NULL ) { -BADF ("execute_command: read failed !\n" ); -return -ENOMEM ; - }return 0 ; }
hw/virtio-blk.c +4 -15
@@ -288,19 +288,13 @@ static void virtio_submit_multiwrite(BlockDriverState *bs, MultiReqBuffer *mrb)static void virtio_blk_handle_flush (VirtIOBlockReq *req,MultiReqBuffer *mrb) { -BlockDriverAIOCB *acb; -bdrv_acct_start (req->dev->bs, &req->acct,0 ,BDRV_ACCT_FLUSH );/* * Make sure all outstanding writes are posted to the backing device. */ virtio_submit_multiwrite (req->dev->bs, mrb); - - acb =bdrv_aio_flush (req->dev->bs, virtio_blk_flush_complete, req); -if (!acb) { -virtio_blk_flush_complete (req, -EIO ); - } +bdrv_aio_flush (req->dev->bs, virtio_blk_flush_complete, req); }static void virtio_blk_handle_write (VirtIOBlockReq *req,MultiReqBuffer *mrb)
@@ -340,7 +334,6 @@ static void virtio_blk_handle_write(VirtIOBlockReq *req, MultiReqBuffer *mrb)static void virtio_blk_handle_read (VirtIOBlockReq *req) { -BlockDriverAIOCB *acb;uint64_t sector; sector =ldq_p (&req->out->sector);
@@ -355,13 +348,9 @@ static void virtio_blk_handle_read(VirtIOBlockReq *req)virtio_blk_rw_complete (req, -EIO );return ; } - - acb =bdrv_aio_readv (req->dev->bs, sector, &req->qiov, - req->qiov.size /BDRV_SECTOR_SIZE , - virtio_blk_rw_complete, req); -if (!acb) { -virtio_blk_rw_complete (req, -EIO ); - } +bdrv_aio_readv (req->dev->bs, sector, &req->qiov, + req->qiov.size /BDRV_SECTOR_SIZE , + virtio_blk_rw_complete, req); } static void virtio_blk_handle_request(VirtIOBlockReq *req,
qemu-io.c +8 -31
@@ -244,14 +244,10 @@ static void aio_rw_done(void *opaque, int ret)static int do_aio_readv (QEMUIOVector *qiov,int64_t offset,int *total) { -BlockDriverAIOCB *acb;int async_ret =NOT_DONE ; - acb =bdrv_aio_readv (bs, offset >>9 , qiov, qiov->size >>9 , - aio_rw_done, &async_ret); -if (!acb) { -return -EIO ; - } +bdrv_aio_readv (bs, offset >>9 , qiov, qiov->size >>9 , + aio_rw_done, &async_ret);while (async_ret ==NOT_DONE ) {qemu_aio_wait (); }
@@ -262,15 +258,10 @@ static int do_aio_readv(QEMUIOVector *qiov, int64_t offset, int *total)static int do_aio_writev (QEMUIOVector *qiov,int64_t offset,int *total) { -BlockDriverAIOCB *acb;int async_ret =NOT_DONE ; - acb =bdrv_aio_writev (bs, offset >>9 , qiov, qiov->size >>9 , - aio_rw_done, &async_ret); -if (!acb) { -return -EIO ; - } - +bdrv_aio_writev (bs, offset >>9 , qiov, qiov->size >>9 , + aio_rw_done, &async_ret);while (async_ret ==NOT_DONE ) {qemu_aio_wait (); }
@@ -1151,7 +1142,6 @@ static int aio_read_f(int argc, char **argv) {int nr_iov, c;struct aio_ctx *ctx =calloc (1 ,sizeof (struct aio_ctx )); -BlockDriverAIOCB *acb;while ((c =getopt (argc, argv,"CP:qv" )) !=EOF ) {switch (c) {
@@ -1206,14 +1196,8 @@ static int aio_read_f(int argc, char **argv) }gettimeofday (&ctx->t1,NULL ); - acb =bdrv_aio_readv (bs, ctx->offset >>9 , &ctx->qiov, - ctx->qiov.size >>9 , aio_read_done, ctx); -if (!acb) { -free (ctx->buf); -free (ctx); -return -EIO ; - } - +bdrv_aio_readv (bs, ctx->offset >>9 , &ctx->qiov, + ctx->qiov.size >>9 , aio_read_done, ctx);return 0 ; }
@@ -1254,7 +1238,6 @@ static int aio_write_f(int argc, char **argv)int nr_iov, c;int pattern =0xcd ;struct aio_ctx *ctx =calloc (1 ,sizeof (struct aio_ctx )); -BlockDriverAIOCB *acb;while ((c =getopt (argc, argv,"CqP:" )) !=EOF ) {switch (c) {
@@ -1305,14 +1288,8 @@ static int aio_write_f(int argc, char **argv) }gettimeofday (&ctx->t1,NULL ); - acb =bdrv_aio_writev (bs, ctx->offset >>9 , &ctx->qiov, - ctx->qiov.size >>9 , aio_write_done, ctx); -if (!acb) { -free (ctx->buf); -free (ctx); -return -EIO ; - } - +bdrv_aio_writev (bs, ctx->offset >>9 , &ctx->qiov, + ctx->qiov.size >>9 , aio_write_done, ctx);return 0 ; }
trace-events +0 -2
@@ -59,8 +59,6 @@ virtio_console_chr_event(unsigned int port, int event) "port %u, event %d" bdrv_open_common(void *bs, const char *filename, int flags, const char *format_name) "bs %p filename \"%s\" flags %#x format_name \"%s\"" multiwrite_cb(void *mcb, int ret) "mcb %p ret %d" bdrv_aio_multiwrite(void *mcb, int num_callbacks, int num_reqs) "mcb %p num_callbacks %d num_reqs %d" -bdrv_aio_multiwrite_earlyfail(void *mcb) "mcb %p" -bdrv_aio_multiwrite_latefail(void *mcb, int i) "mcb %p i %d" bdrv_aio_discard(void *bs, int64_t sector_num, int nb_sectors, void *opaque) "bs %p sector_num %"PRId64" nb_sectors %d opaque %p" bdrv_aio_flush(void *bs, void *opaque) "bs %p opaque %p" bdrv_aio_readv(void *bs, int64_t sector_num, int nb_sectors, void *opaque) "bs %p sector_num %"PRId64" nb_sectors %d opaque %p"
Signature · 1 line
1.7.7.1
PATCH 2/6 block: simplify failure handling for bdrv_aio_multiwrite
In reply to Paolo BonziniNow that early failure of bdrv_aio_writev is not possible anymore, mcb->num_requests can be set before the loop starts.
--- block.c | 28 ++-------------------------- 1 files changed, 2 insertions(+), 26 deletions(-)
block.c +2 -26
@@ -2419,37 +2419,13 @@ int bdrv_aio_multiwrite(BlockDriverState *bs, BlockRequest *reqs, int num_reqs)trace_bdrv_aio_multiwrite (mcb, mcb->num_callbacks, num_reqs); -/* -* Run the aio requests. As soon as one request can't be submitted -* successfully, fail all requests that are not yet submitted (we must -* return failure for all requests anyway) -* -* num_requests cannot be set to the right value immediately: If -* bdrv_aio_writev fails for some request, num_requests would be too high -* and therefore multiwrite_cb() would never recognize the multiwrite -* request as completed. We also cannot use the loop variable i to set it -* when the first request fails because the callback may already have been -* called for previously submitted requests. Thus, num_requests must be -* incremented for each request that is submitted. -* -* The problem that callbacks may be called early also means that we need -* to take care that num_requests doesn't become 0 before all requests are -* submitted - multiwrite_cb() would consider the multiwrite request -* completed. A dummy request that is "completed" by a manual call to -* multiwrite_cb() takes care of this. -*/ - mcb->num_requests =1 ; - -// Run the aio requests +/* Run the aio requests. */ + mcb->num_requests = num_reqs;for (i =0 ; i < num_reqs; i++) { - mcb->num_requests++;bdrv_aio_writev (bs, reqs[i].sector, reqs[i].qiov, reqs[i].nb_sectors, multiwrite_cb, mcb); } -/* Complete the dummy request */ -multiwrite_cb (mcb,0 ); -return 0 ; }
Signature · 1 line
1.7.7.1
PATCH 3/6 block: qemu_aio_get does not return NULL
In reply to Paolo BonziniInitially done with the following semantic patch:
@ rule1 @
expression E;
statement S;
@@
E = qemu_aio_get (...);
(
- if (E == NULL) { ... }
|
- if (E)
{ <... S ...> })
which however missed occurrences in linux-aio.c and posix-aio-compat.c. Those were done by hand.
The change in vdi_aio_setup's caller was also done by hand.
--- block/curl.c | 4 ---- block/rbd.c | 3 --- block/vdi.c | 46 ++++++++++++++++++---------------------------- linux-aio.c | 2 -- posix-aio-compat.c | 4 ---- 5 files changed, 18 insertions(+), 41 deletions(-)
block/curl.c +0 -4
@@ -509,10 +509,6 @@ static BlockDriverAIOCB *curl_aio_readv(BlockDriverState *bs, acb =qemu_aio_get (&curl_aio_pool, bs, cb, opaque); -if (!acb) { -return NULL ; - } - acb->qiov = qiov; acb->sector_num = sector_num; acb->nb_sectors = nb_sectors;
block/rbd.c +0 -3
@@ -632,9 +632,6 @@ static BlockDriverAIOCB *rbd_aio_rw_vector(BlockDriverState *bs,BDRVRBDState *s = bs->opaque; acb =qemu_aio_get (&rbd_aio_pool, bs, cb, opaque); -if (!acb) { -return NULL ; - } acb->write = write; acb->qiov = qiov; acb->bounce =qemu_blockalign (bs, qiov->size);
block/vdi.c +19 -29
67 lines not on this page · raw message
linux-aio.c +0 -2
@@ -166,8 +166,6 @@ BlockDriverAIOCB *laio_submit(BlockDriverState *bs, void *aio_ctx, int fd,off_t offset = sector_num *512 ; laiocb =qemu_aio_get (&laio_pool, bs, cb, opaque); -if (!laiocb) -return NULL ; laiocb->nbytes = nb_sectors *512 ; laiocb->ctx = s; laiocb->ret = -EINPROGRESS ;
posix-aio-compat.c +0 -4
@@ -611,8 +611,6 @@ BlockDriverAIOCB *paio_submit(BlockDriverState *bs, int fd,struct qemu_paiocb *acb; acb =qemu_aio_get (&raw_aio_pool, bs, cb, opaque); -if (!acb) -return NULL ; acb->aio_type = type; acb->aio_fildes = fd;
@@ -638,8 +636,6 @@ BlockDriverAIOCB *paio_ioctl(BlockDriverState *bs, int fd,struct qemu_paiocb *acb; acb =qemu_aio_get (&raw_aio_pool, bs, cb, opaque); -if (!acb) -return NULL ; acb->aio_type =QEMU_AIO_IOCTL ; acb->aio_fildes = fd; acb->aio_offset =0 ;
Signature · 1 line
1.7.7.1
PATCH 4/6 dma: the passed io_func does not return NULL
In reply to Paolo BonziniInitially found with the following semantic patch:
@ type @
BlockDriverAIOCB *x;
expression E;
@@
x = E;
- if (x == NULL) { ... }
@ acb1 @
expression E, E1;
@@
E1->acb = E;
- if (E1->acb == NULL) { ... }
@ aiocb1 @
expression E, E1;
@@
E1->aiocb = E;
- if (E1->aiocb == NULL) { ... }
@ acb @
expression E, E1;
@@
E1.acb = E;
- if (E1.acb == NULL) { ... }
@ aiocb @
expression E, E1;
@@
E1.aiocb = E;
- if (E1.aiocb == NULL) { ... }
but changed manually to include an assert.
--- dma-helpers.c | 4 +--- 1 files changed, 1 insertions(+), 3 deletions(-)
dma-helpers.c +1 -3
@@ -136,9 +136,7 @@ static void dma_bdrv_cb(void *opaque, int ret) dbs->acb = dbs->io_func (dbs->bs, dbs->sector_num, &dbs->iov, dbs->iov.size /512 , dma_bdrv_cb, dbs); -if (!dbs->acb) { -dma_complete (dbs, -EIO ); - } +assert (dbs->acb); }static void dma_aio_cancel (BlockDriverAIOCB *acb)
Signature · 1 line
1.7.7.1
PATCH 5/6 block: dma_bdrv_* does not return NULL
In reply to Paolo BonziniInitially attempted with the following semantic patch:
@ rule1 @
expression E;
statement S;
@@
E =
(
dma_bdrv_io
| dma_bdrv_read
| dma_bdrv_write
)
(...);(
- if (E == NULL) { ... }
|
- if (E)
{ <... S ...> })
which however did not match anything.
--- hw/ide/core.c | 6 ------ hw/ide/macio.c | 4 +--- 2 files changed, 1 insertions(+), 9 deletions(-)
hw/ide/core.c +0 -6
@@ -549,7 +549,6 @@ void ide_dma_cb(void *opaque, int ret)int n;int64_t sector_num; -handle_rw_error:if (ret <0 ) {int op =BM_STATUS_DMA_RETRY ;
@@ -608,11 +607,6 @@ handle_rw_error: ide_issue_trim, ide_dma_cb, s, true);break ; } - -if (!s->bus->dma->aiocb) { - ret =-1 ; - goto handle_rw_error; - }return ; eot:
hw/ide/macio.c +1 -3
@@ -152,10 +152,8 @@ static void pmac_ide_transfer_cb(void *opaque, int ret) ide_issue_trim, pmac_ide_transfer_cb, s, true);break ; } - -if (!m->aiocb) -pmac_ide_transfer_cb (io,-1 );return ; + done:if (s->dma_cmd ==IDE_DMA_READ || s->dma_cmd ==IDE_DMA_WRITE ) {bdrv_acct_done (s->bs, &s->acct);
Signature · 1 line
1.7.7.1
PATCH 6/6 block: avoid useless checks on acb->bh
In reply to Paolo BonziniCoverity is confused by this "if" and reports leaks on acb->bh. The bottom half is always deleted before releasing the AIOCB, in either bdrv_aio_cancel_em or bdrv_aio_bh_cb.
--- block.c | 4 +--- 1 files changed, 1 insertions(+), 3 deletions(-)
block.c +1 -3
@@ -2490,9 +2490,7 @@ static BlockDriverAIOCB *bdrv_aio_rw_vector(BlockDriverState *bs, acb->is_write = is_write; acb->qiov = qiov; acb->bounce =qemu_blockalign (bs, qiov->size); - -if (!acb->bh) - acb->bh =qemu_bh_new (bdrv_aio_bh_cb, acb); + acb->bh =qemu_bh_new (bdrv_aio_bh_cb, acb);if (is_write) {qemu_iovec_to_buffer (acb->qiov, acb->bounce);
Signature · 1 line
1.7.7.1
PATCH v2 1/1 block: bdrv_aio_* do not return NULL
In reply to Paolo BonziniInitially done with the following semantic patch:
@ rule1 @
expression E;
statement S;
@@
E =
(
bdrv_aio_readv
| bdrv_aio_writev
| bdrv_aio_flush
| bdrv_aio_discard
| bdrv_aio_ioctl
)
(...);(
- if (E == NULL) { ... }
|
- if (E)
{ <... S ...> })
which however missed the occurrence in block/blkverify.c (as it should have done), and left behind some unused variables.
---
This is the only patch in the series that needs to be rebased to apply to kwolf/block.
block-migration.c | 13 ----------- block.c | 24 +-------------------- block/blkverify.c | 24 +++++++-------------- block/qed-table.c | 22 ++++++------------- block/qed.c | 60 ++++++++++++++-------------------------------------- block/vdi.c | 20 ----------------- hw/ide/atapi.c | 8 +------ hw/ide/core.c | 7 +----- hw/ide/macio.c | 7 ------ hw/scsi-disk.c | 9 -------- hw/scsi-generic.c | 4 --- hw/virtio-blk.c | 19 +++------------- qemu-io.c | 39 +++++++--------------------------- trace-events | 2 - 14 files changed, 46 insertions(+), 212 deletions(-)
block-migration.c +0 -13
@@ -251,22 +251,12 @@ static int mig_save_device_bulk(Monitor *mon, QEMUFile *f, blk->aiocb =bdrv_aio_readv (bs, cur_sector, &blk->qiov, nr_sectors, blk_mig_read_cb, blk); -if (!blk->aiocb) { - goto error; - } block_mig_state.submitted++;bdrv_reset_dirty (bs, cur_sector, nr_sectors); bmds->cur_sector = cur_sector + nr_sectors;return (bmds->cur_sector >= total_sectors); - -error: -monitor_printf (mon,"Error reading sector %" PRId64"\n" , cur_sector); -qemu_file_set_error (f, -EIO ); -g_free (blk->buf); -g_free (blk); -return 0 ; }static void set_dirty_tracking (int enable)
@@ -413,9 +403,6 @@ static int mig_save_device_dirty(Monitor *mon, QEMUFile *f, blk->aiocb =bdrv_aio_readv (bmds->bs, sector, &blk->qiov, nr_sectors, blk_mig_read_cb, blk); -if (!blk->aiocb) { - goto error; - } block_mig_state.submitted++;bmds_set_aio_inflight (bmds, sector, nr_sectors,1 ); }else {
block.c +1 -23
@@ -2775,7 +2775,6 @@ static int multiwrite_merge(BlockDriverState *bs, BlockRequest *reqs,*/ int bdrv_aio_multiwrite (BlockDriverState *bs,BlockRequest *reqs,int num_reqs) { -BlockDriverAIOCB *acb;MultiwriteCB *mcb;int i;
@@ -2830,35 +2829,14 @@ int bdrv_aio_multiwrite(BlockDriverState *bs, BlockRequest *reqs, int num_reqs)// Run the aio requests for (i =0 ; i < num_reqs; i++) { mcb->num_requests++; - acb =bdrv_aio_writev (bs, reqs[i].sector, reqs[i].qiov, +bdrv_aio_writev (bs, reqs[i].sector, reqs[i].qiov, reqs[i].nb_sectors, multiwrite_cb, mcb); - -if (acb ==NULL ) { -// We can only fail the whole thing if no request has been -// submitted yet. Otherwise we'll wait for the submitted AIOs to -// complete and report the error in the callback. -if (i ==0 ) { -trace_bdrv_aio_multiwrite_earlyfail (mcb); - goto fail; - }else { -trace_bdrv_aio_multiwrite_latefail (mcb, i); -multiwrite_cb (mcb, -EIO ); -break ; - } - } }/* Complete the dummy request */ multiwrite_cb (mcb,0 );return 0 ; - -fail: -for (i =0 ; i < mcb->num_callbacks; i++) { - reqs[i].error = -EIO ; - } -g_free (mcb); -return -1 ; }void bdrv_aio_cancel (BlockDriverAIOCB *acb)
block/blkverify.c +8 -16
@@ -310,14 +310,10 @@ static BlockDriverAIOCB *blkverify_aio_readv(BlockDriverState *bs,qemu_iovec_init (&acb->raw_qiov, acb->qiov->niov);blkverify_iovec_clone (&acb->raw_qiov, qiov, acb->buf); -if (!bdrv_aio_readv (s->test_file, sector_num, qiov, nb_sectors, - blkverify_aio_cb, acb)) { -blkverify_aio_cb (acb, -EIO ); - } -if (!bdrv_aio_readv (bs->file, sector_num, &acb->raw_qiov, nb_sectors, - blkverify_aio_cb, acb)) { -blkverify_aio_cb (acb, -EIO ); - } +bdrv_aio_readv (s->test_file, sector_num, qiov, nb_sectors, + blkverify_aio_cb, acb); +bdrv_aio_readv (bs->file, sector_num, &acb->raw_qiov, nb_sectors, + blkverify_aio_cb, acb);return &acb->common; }
@@ -329,14 +325,10 @@ static BlockDriverAIOCB *blkverify_aio_writev(BlockDriverState *bs,BlkverifyAIOCB *acb =blkverify_aio_get (bs, true, sector_num, qiov, nb_sectors, cb, opaque); -if (!bdrv_aio_writev (s->test_file, sector_num, qiov, nb_sectors, - blkverify_aio_cb, acb)) { -blkverify_aio_cb (acb, -EIO ); - } -if (!bdrv_aio_writev (bs->file, sector_num, qiov, nb_sectors, - blkverify_aio_cb, acb)) { -blkverify_aio_cb (acb, -EIO ); - } +bdrv_aio_writev (s->test_file, sector_num, qiov, nb_sectors, + blkverify_aio_cb, acb); +bdrv_aio_writev (bs->file, sector_num, qiov, nb_sectors, + blkverify_aio_cb, acb);return &acb->common; }
block/qed-table.c +7 -15
@@ -54,7 +54,6 @@ static void qed_read_table(BDRVQEDState *s, uint64_t offset, QEDTable *table,QEDReadTableCB *read_table_cb =gencb_alloc (sizeof (*read_table_cb), cb, opaque);QEMUIOVector *qiov = &read_table_cb->qiov; -BlockDriverAIOCB *aiocb;trace_qed_read_table (s, offset, table);
@@ -64,12 +63,9 @@ static void qed_read_table(BDRVQEDState *s, uint64_t offset, QEDTable *table, read_table_cb->iov.iov_len = s->header.cluster_size * s->header.table_size,qemu_iovec_init_external (qiov, &read_table_cb->iov,1 ); - aiocb =bdrv_aio_readv (s->bs->file, offset /BDRV_SECTOR_SIZE , qiov, - qiov->size /BDRV_SECTOR_SIZE , - qed_read_table_cb, read_table_cb); -if (!aiocb) { -qed_read_table_cb (read_table_cb, -EIO ); - } +bdrv_aio_readv (s->bs->file, offset /BDRV_SECTOR_SIZE , qiov, + qiov->size /BDRV_SECTOR_SIZE , + qed_read_table_cb, read_table_cb); } typedef struct {
@@ -127,7 +123,6 @@ static void qed_write_table(BDRVQEDState *s, uint64_t offset, QEDTable *table, BlockDriverCompletionFunc *cb, void *opaque) {QEDWriteTableCB *write_table_cb; -BlockDriverAIOCB *aiocb;unsigned int sector_mask =BDRV_SECTOR_SIZE /sizeof (uint64_t ) -1 ;unsigned int start, end, i;size_t len_bytes;
@@ -158,13 +153,10 @@ static void qed_write_table(BDRVQEDState *s, uint64_t offset, QEDTable *table,/* Adjust for offset into table */ offset += start *sizeof (uint64_t ); - aiocb =bdrv_aio_writev (s->bs->file, offset /BDRV_SECTOR_SIZE , - &write_table_cb->qiov, - write_table_cb->qiov.size /BDRV_SECTOR_SIZE , - qed_write_table_cb, write_table_cb); -if (!aiocb) { -qed_write_table_cb (write_table_cb, -EIO ); - } +bdrv_aio_writev (s->bs->file, offset /BDRV_SECTOR_SIZE , + &write_table_cb->qiov, + write_table_cb->qiov.size /BDRV_SECTOR_SIZE , + qed_write_table_cb, write_table_cb); }/**
block/qed.c +16 -44
132 lines not on this page · raw message
block/vdi.c +0 -20
@@ -633,10 +633,6 @@ static void vdi_aio_read_cb(void *opaque, int ret)qemu_iovec_init_external (&acb->hd_qiov, &acb->hd_iov,1 ); acb->hd_aiocb =bdrv_aio_readv (bs->file, offset, &acb->hd_qiov, n_sectors, vdi_aio_read_cb, acb); -if (acb->hd_aiocb ==NULL ) { - ret = -EIO ; - goto done; - } }return ; done:
@@ -708,10 +704,6 @@ static void vdi_aio_write_cb(void *opaque, int ret)qemu_iovec_init_external (&acb->hd_qiov, &acb->hd_iov,1 ); acb->hd_aiocb =bdrv_aio_writev (bs->file,0 , &acb->hd_qiov,1 , vdi_aio_write_cb, acb); -if (acb->hd_aiocb ==NULL ) { - ret = -EIO ; - goto done; - }return ; }else if (VDI_IS_ALLOCATED (acb->bmap_first)) {/* One or more new blocks were allocated. */
@@ -738,10 +730,6 @@ static void vdi_aio_write_cb(void *opaque, int ret) n_sectors, bmap_first); acb->hd_aiocb =bdrv_aio_writev (bs->file, offset, &acb->hd_qiov, n_sectors, vdi_aio_write_cb, acb); -if (acb->hd_aiocb ==NULL ) { - ret = -EIO ; - goto done; - }return ; } ret =0 ;
@@ -789,10 +777,6 @@ static void vdi_aio_write_cb(void *opaque, int ret) acb->hd_aiocb =bdrv_aio_writev (bs->file, offset, &acb->hd_qiov, s->block_sectors, vdi_aio_write_cb, acb); -if (acb->hd_aiocb ==NULL ) { - ret = -EIO ; - goto done; - } }else {uint64_t offset = s->header.offset_data /SECTOR_SIZE + (uint64_t)bmap_entry * s->block_sectors +
@@ -802,10 +786,6 @@ static void vdi_aio_write_cb(void *opaque, int ret)qemu_iovec_init_external (&acb->hd_qiov, &acb->hd_iov,1 ); acb->hd_aiocb =bdrv_aio_writev (bs->file, offset, &acb->hd_qiov, n_sectors, vdi_aio_write_cb, acb); -if (acb->hd_aiocb ==NULL ) { - ret = -EIO ; - goto done; - } }return ;
hw/ide/atapi.c +1 -7
@@ -352,14 +352,8 @@ static void ide_atapi_cmd_read_dma_cb(void *opaque, int ret) s->bus->dma->aiocb =bdrv_aio_readv (s->bs, (int64_t )s->lba <<2 , &s->bus->dma->qiov, n *4 , ide_atapi_cmd_read_dma_cb, s); -if (!s->bus->dma->aiocb) { -/* Note: media not present is the most likely case */ -ide_atapi_cmd_error (s,NOT_READY , -ASC_MEDIUM_NOT_PRESENT ); - goto eot; - } -return ; + eot:bdrv_acct_done (s->bs, &s->acct); s->bus->dma->ops->add_status (s->bus->dma,BM_STATUS_INT );
hw/ide/core.c +1 -6
@@ -718,18 +718,13 @@ static void ide_flush_cb(void *opaque, int ret)void ide_flush_cache (IDEState *s) { -BlockDriverAIOCB *acb; -if (s->bs ==NULL ) {ide_flush_cb (s,0 );return ; }bdrv_acct_start (s->bs, &s->acct,0 ,BDRV_ACCT_FLUSH ); - acb =bdrv_aio_flush (s->bs, ide_flush_cb, s); -if (acb ==NULL ) { -ide_flush_cb (s, -EIO ); - } +bdrv_aio_flush (s->bs, ide_flush_cb, s); }static void ide_cfata_metadata_inquiry (IDEState *s)
hw/ide/macio.c +0 -7
@@ -84,13 +84,6 @@ static void pmac_ide_atapi_transfer_cb(void *opaque, int ret) m->aiocb =dma_bdrv_read (s->bs, &s->sg, (int64_t )(s->lba <<2 ) + (s->io_buffer_index >>9 ), pmac_ide_atapi_transfer_cb, io); -if (!m->aiocb) { -qemu_sglist_destroy (&s->sg); -/* Note: media not present is the most likely case */ -ide_atapi_cmd_error (s,NOT_READY , -ASC_MEDIUM_NOT_PRESENT ); - goto done; - }return ; done:
hw/scsi-disk.c +0 -9
@@ -217,9 +217,6 @@ static void scsi_read_data(SCSIRequest *req)bdrv_acct_start (s->qdev.conf.bs, &r->acct, n *BDRV_SECTOR_SIZE ,BDRV_ACCT_READ ); r->req.aiocb =bdrv_aio_readv (s->qdev.conf.bs, r->sector, &r->qiov, n, scsi_read_complete, r); -if (r->req.aiocb ==NULL ) { -scsi_read_complete (r, -EIO ); - } }/*
@@ -327,9 +324,6 @@ static void scsi_write_data(SCSIRequest *req)bdrv_acct_start (s->qdev.conf.bs, &r->acct, n *BDRV_SECTOR_SIZE ,BDRV_ACCT_WRITE ); r->req.aiocb =bdrv_aio_writev (s->qdev.conf.bs, r->sector, &r->qiov, n, scsi_write_complete, r); -if (r->req.aiocb ==NULL ) { -scsi_write_complete (r, -ENOMEM ); - } }else {/* Called for the first time. Ask the driver to send us more data. */ scsi_write_complete (r,0 );
@@ -1332,9 +1326,6 @@ static int32_t scsi_send_command(SCSIRequest *req, uint8_t *buf)scsi_req_ref (&r->req);bdrv_acct_start (s->qdev.conf.bs, &r->acct,0 ,BDRV_ACCT_FLUSH ); r->req.aiocb =bdrv_aio_flush (s->qdev.conf.bs, scsi_flush_complete, r); -if (r->req.aiocb ==NULL ) { -scsi_flush_complete (r, -EIO ); - }return 0 ;case READ_6 :case READ_10 :
hw/scsi-generic.c +0 -4
@@ -152,10 +152,6 @@ static int execute_command(BlockDriverState *bdrv, r->io_header.flags |=SG_FLAG_DIRECT_IO ; r->req.aiocb =bdrv_aio_ioctl (bdrv,SG_IO , &r->io_header, complete, r); -if (r->req.aiocb ==NULL ) { -BADF ("execute_command: read failed !\n" ); -return -ENOMEM ; - }return 0 ; }
hw/virtio-blk.c +4 -15
@@ -288,19 +288,13 @@ static void virtio_submit_multiwrite(BlockDriverState *bs, MultiReqBuffer *mrb)static void virtio_blk_handle_flush (VirtIOBlockReq *req,MultiReqBuffer *mrb) { -BlockDriverAIOCB *acb; -bdrv_acct_start (req->dev->bs, &req->acct,0 ,BDRV_ACCT_FLUSH );/* * Make sure all outstanding writes are posted to the backing device. */ virtio_submit_multiwrite (req->dev->bs, mrb); - - acb =bdrv_aio_flush (req->dev->bs, virtio_blk_flush_complete, req); -if (!acb) { -virtio_blk_flush_complete (req, -EIO ); - } +bdrv_aio_flush (req->dev->bs, virtio_blk_flush_complete, req); }static void virtio_blk_handle_write (VirtIOBlockReq *req,MultiReqBuffer *mrb)
@@ -340,7 +334,6 @@ static void virtio_blk_handle_write(VirtIOBlockReq *req, MultiReqBuffer *mrb)static void virtio_blk_handle_read (VirtIOBlockReq *req) { -BlockDriverAIOCB *acb;uint64_t sector; sector =ldq_p (&req->out->sector);
@@ -355,13 +348,9 @@ static void virtio_blk_handle_read(VirtIOBlockReq *req)virtio_blk_rw_complete (req, -EIO );return ; } - - acb =bdrv_aio_readv (req->dev->bs, sector, &req->qiov, - req->qiov.size /BDRV_SECTOR_SIZE , - virtio_blk_rw_complete, req); -if (!acb) { -virtio_blk_rw_complete (req, -EIO ); - } +bdrv_aio_readv (req->dev->bs, sector, &req->qiov, + req->qiov.size /BDRV_SECTOR_SIZE , + virtio_blk_rw_complete, req); } static void virtio_blk_handle_request(VirtIOBlockReq *req,
qemu-io.c +8 -31
@@ -244,14 +244,10 @@ static void aio_rw_done(void *opaque, int ret)static int do_aio_readv (QEMUIOVector *qiov,int64_t offset,int *total) { -BlockDriverAIOCB *acb;int async_ret =NOT_DONE ; - acb =bdrv_aio_readv (bs, offset >>9 , qiov, qiov->size >>9 , - aio_rw_done, &async_ret); -if (!acb) { -return -EIO ; - } +bdrv_aio_readv (bs, offset >>9 , qiov, qiov->size >>9 , + aio_rw_done, &async_ret);while (async_ret ==NOT_DONE ) {qemu_aio_wait (); }
@@ -262,15 +258,10 @@ static int do_aio_readv(QEMUIOVector *qiov, int64_t offset, int *total)static int do_aio_writev (QEMUIOVector *qiov,int64_t offset,int *total) { -BlockDriverAIOCB *acb;int async_ret =NOT_DONE ; - acb =bdrv_aio_writev (bs, offset >>9 , qiov, qiov->size >>9 , - aio_rw_done, &async_ret); -if (!acb) { -return -EIO ; - } - +bdrv_aio_writev (bs, offset >>9 , qiov, qiov->size >>9 , + aio_rw_done, &async_ret);while (async_ret ==NOT_DONE ) {qemu_aio_wait (); }
@@ -1151,7 +1142,6 @@ static int aio_read_f(int argc, char **argv) {int nr_iov, c;struct aio_ctx *ctx =calloc (1 ,sizeof (struct aio_ctx )); -BlockDriverAIOCB *acb;while ((c =getopt (argc, argv,"CP:qv" )) !=EOF ) {switch (c) {
@@ -1206,14 +1196,8 @@ static int aio_read_f(int argc, char **argv) }gettimeofday (&ctx->t1,NULL ); - acb =bdrv_aio_readv (bs, ctx->offset >>9 , &ctx->qiov, - ctx->qiov.size >>9 , aio_read_done, ctx); -if (!acb) { -free (ctx->buf); -free (ctx); -return -EIO ; - } - +bdrv_aio_readv (bs, ctx->offset >>9 , &ctx->qiov, + ctx->qiov.size >>9 , aio_read_done, ctx);return 0 ; }
@@ -1254,7 +1238,6 @@ static int aio_write_f(int argc, char **argv)int nr_iov, c;int pattern =0xcd ;struct aio_ctx *ctx =calloc (1 ,sizeof (struct aio_ctx )); -BlockDriverAIOCB *acb;while ((c =getopt (argc, argv,"CqP:" )) !=EOF ) {switch (c) {
@@ -1305,14 +1288,8 @@ static int aio_write_f(int argc, char **argv) }gettimeofday (&ctx->t1,NULL ); - acb =bdrv_aio_writev (bs, ctx->offset >>9 , &ctx->qiov, - ctx->qiov.size >>9 , aio_write_done, ctx); -if (!acb) { -free (ctx->buf); -free (ctx); -return -EIO ; - } - +bdrv_aio_writev (bs, ctx->offset >>9 , &ctx->qiov, + ctx->qiov.size >>9 , aio_write_done, ctx);return 0 ; }
trace-events +0 -2
@@ -59,8 +59,6 @@ virtio_console_chr_event(unsigned int port, int event) "port %u, event %d" bdrv_open_common(void *bs, const char *filename, int flags, const char *format_name) "bs %p filename \"%s\" flags %#x format_name \"%s\"" multiwrite_cb(void *mcb, int ret) "mcb %p ret %d" bdrv_aio_multiwrite(void *mcb, int num_callbacks, int num_reqs) "mcb %p num_callbacks %d num_reqs %d" -bdrv_aio_multiwrite_earlyfail(void *mcb) "mcb %p" -bdrv_aio_multiwrite_latefail(void *mcb, int i) "mcb %p i %d" bdrv_aio_discard(void *bs, int64_t sector_num, int nb_sectors, void *opaque) "bs %p sector_num %"PRId64" nb_sectors %d opaque %p" bdrv_aio_flush(void *bs, void *opaque) "bs %p opaque %p" bdrv_aio_readv(void *bs, int64_t sector_num, int nb_sectors, void *opaque) "bs %p sector_num %"PRId64" nb_sectors %d opaque %p"
Signature · 1 line
1.7.7.1
Quoted 9 lines · Paolo Bonzini
After the coroutinization of the block layer, immediate failures of an AIO operation will still return an AIOCB and only report failure with a bottom half. This lets us remove a lot of dead NULL checks (patches 1-5).
Patch 6 is on a similar theme, but a bit different.
Most "added" lines are actually just reindented.
Quoted 7 lines
Paolo Bonzini (6):
block: bdrv_aio_* do not return NULL
block: simplify failure handling forbdrv_aio_multiwrite
block:qemu_aio_getdoes not return NULL
dma: the passedio_funcdoes not return NULL
block: dma_bdrv_* does not return NULL
block: avoid useless checks onacb->bh
Ping.
Paolo
Kevin Wolf
AppliedAm 14.11.2011 17:50, schrieb Paolo Bonzini:
Quoted 9 lines
After the coroutinization of the block layer, immediate failures of an AIO operation will still return an AIOCB and only report failure with a bottom half. This lets us remove a lot of dead NULL checks (patches 1-5).
Patch 6 is on a similar theme, but a bit different.
Most "added" lines are actually just reindented.
Quoted 7 lines
Paolo Bonzini (6):
block: bdrv_aio_* do not return NULL
block: simplify failure handling forbdrv_aio_multiwrite
block:qemu_aio_getdoes not return NULL
dma: the passedio_funcdoes not return NULL
block: dma_bdrv_* does not return NULL
block: avoid useless checks onacb->bh
Thanks, applied all to the block branch.
Kevin