diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2011-11-30 09:12:30 +0100 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2011-12-15 12:40:07 +0100 |
commit | ad54ae80c73f486cf39b4b38a04b76dd971cdbf6 (patch) | |
tree | 68c7bc557d325ed840ae11332b69c1ecb63e32fd /block/qed.c | |
parent | 222f23f508a8d778f56eddef14752dfd26d225b4 (diff) |
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 left behind some unused
variables.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block/qed.c')
-rw-r--r-- | block/qed.c | 60 |
1 files changed, 16 insertions, 44 deletions
diff --git a/block/qed.c b/block/qed.c index 22e467202f..8da3ebe9d4 100644 --- a/block/qed.c +++ b/block/qed.c @@ -123,7 +123,6 @@ static void qed_write_header_read_cb(void *opaque, int ret) { QEDWriteHeaderCB *write_header_cb = opaque; BDRVQEDState *s = write_header_cb->s; - BlockDriverAIOCB *acb; if (ret) { qed_write_header_cb(write_header_cb, ret); @@ -133,12 +132,9 @@ static void qed_write_header_read_cb(void *opaque, int ret) /* Update header */ qed_header_cpu_to_le(&s->header, (QEDHeader *)write_header_cb->buf); - acb = bdrv_aio_writev(s->bs->file, 0, &write_header_cb->qiov, - write_header_cb->nsectors, qed_write_header_cb, - write_header_cb); - if (!acb) { - qed_write_header_cb(write_header_cb, -EIO); - } + bdrv_aio_writev(s->bs->file, 0, &write_header_cb->qiov, + write_header_cb->nsectors, qed_write_header_cb, + write_header_cb); } /** @@ -156,7 +152,6 @@ static void qed_write_header(BDRVQEDState *s, BlockDriverCompletionFunc cb, * them, and write back. */ - BlockDriverAIOCB *acb; int nsectors = (sizeof(QEDHeader) + BDRV_SECTOR_SIZE - 1) / BDRV_SECTOR_SIZE; size_t len = nsectors * BDRV_SECTOR_SIZE; @@ -170,11 +165,8 @@ static void qed_write_header(BDRVQEDState *s, BlockDriverCompletionFunc cb, write_header_cb->iov.iov_len = len; qemu_iovec_init_external(&write_header_cb->qiov, &write_header_cb->iov, 1); - acb = bdrv_aio_readv(s->bs->file, 0, &write_header_cb->qiov, nsectors, - qed_write_header_read_cb, write_header_cb); - if (!acb) { - qed_write_header_cb(write_header_cb, -EIO); - } + bdrv_aio_readv(s->bs->file, 0, &write_header_cb->qiov, nsectors, + qed_write_header_read_cb, write_header_cb); } static uint64_t qed_max_image_size(uint32_t cluster_size, uint32_t table_size) @@ -728,7 +720,6 @@ static void qed_read_backing_file(BDRVQEDState *s, uint64_t pos, QEMUIOVector *qiov, BlockDriverCompletionFunc *cb, void *opaque) { - BlockDriverAIOCB *aiocb; uint64_t backing_length = 0; size_t size; @@ -760,11 +751,8 @@ static void qed_read_backing_file(BDRVQEDState *s, uint64_t pos, size = MIN((uint64_t)backing_length - pos, qiov->size); BLKDBG_EVENT(s->bs->file, BLKDBG_READ_BACKING); - aiocb = bdrv_aio_readv(s->bs->backing_hd, pos / BDRV_SECTOR_SIZE, - qiov, size / BDRV_SECTOR_SIZE, cb, opaque); - if (!aiocb) { - cb(opaque, -EIO); - } + bdrv_aio_readv(s->bs->backing_hd, pos / BDRV_SECTOR_SIZE, + qiov, size / BDRV_SECTOR_SIZE, cb, opaque); } typedef struct { @@ -786,7 +774,6 @@ static void qed_copy_from_backing_file_write(void *opaque, int ret) { CopyFromBackingFileCB *copy_cb = opaque; BDRVQEDState *s = copy_cb->s; - BlockDriverAIOCB *aiocb; if (ret) { qed_copy_from_backing_file_cb(copy_cb, ret); @@ -794,13 +781,9 @@ static void qed_copy_from_backing_file_write(void *opaque, int ret) } BLKDBG_EVENT(s->bs->file, BLKDBG_COW_WRITE); - aiocb = bdrv_aio_writev(s->bs->file, copy_cb->offset / BDRV_SECTOR_SIZE, - ©_cb->qiov, - copy_cb->qiov.size / BDRV_SECTOR_SIZE, - qed_copy_from_backing_file_cb, copy_cb); - if (!aiocb) { - qed_copy_from_backing_file_cb(copy_cb, -EIO); - } + bdrv_aio_writev(s->bs->file, copy_cb->offset / BDRV_SECTOR_SIZE, + ©_cb->qiov, copy_cb->qiov.size / BDRV_SECTOR_SIZE, + qed_copy_from_backing_file_cb, copy_cb); } /** @@ -1022,7 +1005,6 @@ static void qed_aio_write_main(void *opaque, int ret) uint64_t offset = acb->cur_cluster + qed_offset_into_cluster(s, acb->cur_pos); BlockDriverCompletionFunc *next_fn; - BlockDriverAIOCB *file_acb; trace_qed_aio_write_main(s, acb, ret, offset, acb->cur_qiov.size); @@ -1042,13 +1024,9 @@ static void qed_aio_write_main(void *opaque, int ret) } BLKDBG_EVENT(s->bs->file, BLKDBG_WRITE_AIO); - file_acb = bdrv_aio_writev(s->bs->file, offset / BDRV_SECTOR_SIZE, - &acb->cur_qiov, - acb->cur_qiov.size / BDRV_SECTOR_SIZE, - next_fn, acb); - if (!file_acb) { - qed_aio_complete(acb, -EIO); - } + bdrv_aio_writev(s->bs->file, offset / BDRV_SECTOR_SIZE, + &acb->cur_qiov, acb->cur_qiov.size / BDRV_SECTOR_SIZE, + next_fn, acb); } /** @@ -1215,7 +1193,6 @@ static void qed_aio_read_data(void *opaque, int ret, QEDAIOCB *acb = opaque; BDRVQEDState *s = acb_to_s(acb); BlockDriverState *bs = acb->common.bs; - BlockDriverAIOCB *file_acb; /* Adjust offset into cluster */ offset += qed_offset_into_cluster(s, acb->cur_pos); @@ -1240,14 +1217,9 @@ static void qed_aio_read_data(void *opaque, int ret, } BLKDBG_EVENT(bs->file, BLKDBG_READ_AIO); - file_acb = bdrv_aio_readv(bs->file, offset / BDRV_SECTOR_SIZE, - &acb->cur_qiov, - acb->cur_qiov.size / BDRV_SECTOR_SIZE, - qed_aio_next_io, acb); - if (!file_acb) { - ret = -EIO; - goto err; - } + bdrv_aio_readv(bs->file, offset / BDRV_SECTOR_SIZE, + &acb->cur_qiov, acb->cur_qiov.size / BDRV_SECTOR_SIZE, + qed_aio_next_io, acb); return; err: |