Lines Matching refs:acb
356 QCowAIOCB *acb = (QCowAIOCB *)blockacb; in qcow_aio_cancel() local
357 if (acb->hd_aiocb) in qcow_aio_cancel()
358 bdrv_aio_cancel(acb->hd_aiocb); in qcow_aio_cancel()
359 qemu_aio_release(acb); in qcow_aio_cancel()
370 QCowAIOCB *acb = opaque; in qcow_aio_read_bh() local
371 qemu_bh_delete(acb->bh); in qcow_aio_read_bh()
372 acb->bh = NULL; in qcow_aio_read_bh()
376 static int qcow_schedule_bh(QEMUBHFunc *cb, QCowAIOCB *acb) in qcow_schedule_bh() argument
378 if (acb->bh) in qcow_schedule_bh()
381 acb->bh = qemu_bh_new(cb, acb); in qcow_schedule_bh()
382 if (!acb->bh) in qcow_schedule_bh()
385 qemu_bh_schedule(acb->bh); in qcow_schedule_bh()
392 QCowAIOCB *acb = opaque; in qcow_aio_read_cb() local
393 BlockDriverState *bs = acb->common.bs; in qcow_aio_read_cb()
397 acb->hd_aiocb = NULL; in qcow_aio_read_cb()
402 if (!acb->cluster_offset) { in qcow_aio_read_cb()
404 } else if (acb->cluster_offset & QCOW_OFLAG_COMPRESSED) { in qcow_aio_read_cb()
408 qcow2_encrypt_sectors(s, acb->sector_num, acb->buf, acb->buf, in qcow_aio_read_cb()
409 acb->n, 0, in qcow_aio_read_cb()
414 acb->nb_sectors -= acb->n; in qcow_aio_read_cb()
415 acb->sector_num += acb->n; in qcow_aio_read_cb()
416 acb->buf += acb->n * 512; in qcow_aio_read_cb()
418 if (acb->nb_sectors == 0) { in qcow_aio_read_cb()
425 acb->n = acb->nb_sectors; in qcow_aio_read_cb()
426 acb->cluster_offset = in qcow_aio_read_cb()
427 qcow2_get_cluster_offset(bs, acb->sector_num << 9, &acb->n); in qcow_aio_read_cb()
428 index_in_cluster = acb->sector_num & (s->cluster_sectors - 1); in qcow_aio_read_cb()
430 if (!acb->cluster_offset) { in qcow_aio_read_cb()
433 n1 = qcow2_backing_read1(bs->backing_hd, acb->sector_num, in qcow_aio_read_cb()
434 acb->buf, acb->n); in qcow_aio_read_cb()
436 acb->hd_iov.iov_base = (void *)acb->buf; in qcow_aio_read_cb()
437 acb->hd_iov.iov_len = acb->n * 512; in qcow_aio_read_cb()
438 qemu_iovec_init_external(&acb->hd_qiov, &acb->hd_iov, 1); in qcow_aio_read_cb()
439 acb->hd_aiocb = bdrv_aio_readv(bs->backing_hd, acb->sector_num, in qcow_aio_read_cb()
440 &acb->hd_qiov, acb->n, in qcow_aio_read_cb()
441 qcow_aio_read_cb, acb); in qcow_aio_read_cb()
442 if (acb->hd_aiocb == NULL) in qcow_aio_read_cb()
445 ret = qcow_schedule_bh(qcow_aio_read_bh, acb); in qcow_aio_read_cb()
451 memset(acb->buf, 0, 512 * acb->n); in qcow_aio_read_cb()
452 ret = qcow_schedule_bh(qcow_aio_read_bh, acb); in qcow_aio_read_cb()
456 } else if (acb->cluster_offset & QCOW_OFLAG_COMPRESSED) { in qcow_aio_read_cb()
458 if (qcow2_decompress_cluster(s, acb->cluster_offset) < 0) in qcow_aio_read_cb()
460 memcpy(acb->buf, in qcow_aio_read_cb()
461 s->cluster_cache + index_in_cluster * 512, 512 * acb->n); in qcow_aio_read_cb()
462 ret = qcow_schedule_bh(qcow_aio_read_bh, acb); in qcow_aio_read_cb()
466 if ((acb->cluster_offset & 511) != 0) { in qcow_aio_read_cb()
471 acb->hd_iov.iov_base = (void *)acb->buf; in qcow_aio_read_cb()
472 acb->hd_iov.iov_len = acb->n * 512; in qcow_aio_read_cb()
473 qemu_iovec_init_external(&acb->hd_qiov, &acb->hd_iov, 1); in qcow_aio_read_cb()
474 acb->hd_aiocb = bdrv_aio_readv(s->hd, in qcow_aio_read_cb()
475 (acb->cluster_offset >> 9) + index_in_cluster, in qcow_aio_read_cb()
476 &acb->hd_qiov, acb->n, qcow_aio_read_cb, acb); in qcow_aio_read_cb()
477 if (acb->hd_aiocb == NULL) in qcow_aio_read_cb()
483 if (acb->qiov->niov > 1) { in qcow_aio_read_cb()
484 qemu_iovec_from_buffer(acb->qiov, acb->orig_buf, acb->qiov->size); in qcow_aio_read_cb()
485 qemu_vfree(acb->orig_buf); in qcow_aio_read_cb()
487 acb->common.cb(acb->common.opaque, ret); in qcow_aio_read_cb()
488 qemu_aio_release(acb); in qcow_aio_read_cb()
495 QCowAIOCB *acb; in qcow_aio_setup() local
497 acb = qemu_aio_get(&qcow_aio_pool, bs, cb, opaque); in qcow_aio_setup()
498 if (!acb) in qcow_aio_setup()
500 acb->hd_aiocb = NULL; in qcow_aio_setup()
501 acb->sector_num = sector_num; in qcow_aio_setup()
502 acb->qiov = qiov; in qcow_aio_setup()
504 acb->buf = acb->orig_buf = qemu_blockalign(bs, qiov->size); in qcow_aio_setup()
506 qemu_iovec_to_buffer(qiov, acb->buf); in qcow_aio_setup()
508 acb->buf = (uint8_t *)qiov->iov->iov_base; in qcow_aio_setup()
510 acb->nb_sectors = nb_sectors; in qcow_aio_setup()
511 acb->n = 0; in qcow_aio_setup()
512 acb->cluster_offset = 0; in qcow_aio_setup()
513 acb->l2meta.nb_clusters = 0; in qcow_aio_setup()
514 return acb; in qcow_aio_setup()
521 QCowAIOCB *acb; in qcow_aio_readv() local
523 acb = qcow_aio_setup(bs, sector_num, qiov, nb_sectors, cb, opaque, 0); in qcow_aio_readv()
524 if (!acb) in qcow_aio_readv()
527 qcow_aio_read_cb(acb, 0); in qcow_aio_readv()
528 return &acb->common; in qcow_aio_readv()
533 QCowAIOCB *acb = opaque; in qcow_aio_write_cb() local
534 BlockDriverState *bs = acb->common.bs; in qcow_aio_write_cb()
540 acb->hd_aiocb = NULL; in qcow_aio_write_cb()
545 if (qcow2_alloc_cluster_link_l2(bs, acb->cluster_offset, &acb->l2meta) < 0) { in qcow_aio_write_cb()
546 qcow2_free_any_clusters(bs, acb->cluster_offset, acb->l2meta.nb_clusters); in qcow_aio_write_cb()
550 acb->nb_sectors -= acb->n; in qcow_aio_write_cb()
551 acb->sector_num += acb->n; in qcow_aio_write_cb()
552 acb->buf += acb->n * 512; in qcow_aio_write_cb()
554 if (acb->nb_sectors == 0) { in qcow_aio_write_cb()
560 index_in_cluster = acb->sector_num & (s->cluster_sectors - 1); in qcow_aio_write_cb()
561 n_end = index_in_cluster + acb->nb_sectors; in qcow_aio_write_cb()
566 acb->cluster_offset = qcow2_alloc_cluster_offset(bs, acb->sector_num << 9, in qcow_aio_write_cb()
568 n_end, &acb->n, &acb->l2meta); in qcow_aio_write_cb()
569 if (!acb->cluster_offset || (acb->cluster_offset & 511) != 0) { in qcow_aio_write_cb()
574 if (!acb->cluster_data) { in qcow_aio_write_cb()
575 acb->cluster_data = qemu_mallocz(QCOW_MAX_CRYPT_CLUSTERS * in qcow_aio_write_cb()
578 qcow2_encrypt_sectors(s, acb->sector_num, acb->cluster_data, acb->buf, in qcow_aio_write_cb()
579 acb->n, 1, &s->aes_encrypt_key); in qcow_aio_write_cb()
580 src_buf = acb->cluster_data; in qcow_aio_write_cb()
582 src_buf = acb->buf; in qcow_aio_write_cb()
584 acb->hd_iov.iov_base = (void *)src_buf; in qcow_aio_write_cb()
585 acb->hd_iov.iov_len = acb->n * 512; in qcow_aio_write_cb()
586 qemu_iovec_init_external(&acb->hd_qiov, &acb->hd_iov, 1); in qcow_aio_write_cb()
587 acb->hd_aiocb = bdrv_aio_writev(s->hd, in qcow_aio_write_cb()
588 (acb->cluster_offset >> 9) + index_in_cluster, in qcow_aio_write_cb()
589 &acb->hd_qiov, acb->n, in qcow_aio_write_cb()
590 qcow_aio_write_cb, acb); in qcow_aio_write_cb()
591 if (acb->hd_aiocb == NULL) in qcow_aio_write_cb()
597 if (acb->qiov->niov > 1) in qcow_aio_write_cb()
598 qemu_vfree(acb->orig_buf); in qcow_aio_write_cb()
599 acb->common.cb(acb->common.opaque, ret); in qcow_aio_write_cb()
600 qemu_aio_release(acb); in qcow_aio_write_cb()
608 QCowAIOCB *acb; in qcow_aio_writev() local
612 acb = qcow_aio_setup(bs, sector_num, qiov, nb_sectors, cb, opaque, 1); in qcow_aio_writev()
613 if (!acb) in qcow_aio_writev()
616 qcow_aio_write_cb(acb, 0); in qcow_aio_writev()
617 return &acb->common; in qcow_aio_writev()