Lines Matching refs:bs
92 return bdrv_pwrite(s->bs->file, 0, sizeof(le), &le, 0); in qed_write_header_sync()
118 buf = qemu_blockalign(s->bs, len); in qed_write_header()
120 ret = bdrv_co_pread(s->bs->file, 0, len, buf, 0); in qed_write_header()
128 ret = bdrv_co_pwrite(s->bs->file, 0, len, buf, 0); in qed_write_header()
237 return qemu_blockalign(s->bs, in qed_alloc_table()
298 ret = bdrv_co_flush(s->bs->file->bs); in qed_need_check_timer()
310 ret = bdrv_co_flush(s->bs); in qed_need_check_timer()
320 bdrv_dec_in_flight(s->bs); in qed_need_check_timer_entry()
328 bdrv_inc_in_flight(s->bs); in qed_need_check_timer_cb()
350 static void bdrv_qed_detach_aio_context(BlockDriverState *bs) in bdrv_qed_detach_aio_context() argument
352 BDRVQEDState *s = bs->opaque; in bdrv_qed_detach_aio_context()
358 static void bdrv_qed_attach_aio_context(BlockDriverState *bs, in bdrv_qed_attach_aio_context() argument
361 BDRVQEDState *s = bs->opaque; in bdrv_qed_attach_aio_context()
371 static void bdrv_qed_drain_begin(BlockDriverState *bs) in bdrv_qed_drain_begin() argument
373 BDRVQEDState *s = bs->opaque; in bdrv_qed_drain_begin()
383 bdrv_inc_in_flight(bs); in bdrv_qed_drain_begin()
384 aio_co_enter(bdrv_get_aio_context(bs), co); in bdrv_qed_drain_begin()
388 static void bdrv_qed_init_state(BlockDriverState *bs) in bdrv_qed_init_state() argument
390 BDRVQEDState *s = bs->opaque; in bdrv_qed_init_state()
393 s->bs = bs; in bdrv_qed_init_state()
400 bdrv_qed_do_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) in bdrv_qed_do_open() argument
402 BDRVQEDState *s = bs->opaque; in bdrv_qed_do_open()
407 ret = bdrv_co_pread(bs->file, 0, sizeof(le_header), &le_header, 0); in bdrv_qed_do_open()
430 file_size = bdrv_co_getlength(bs->file->bs); in bdrv_qed_do_open()
474 backing_file_str = g_malloc(sizeof(bs->backing_file)); in bdrv_qed_do_open()
475 ret = qed_read_string(bs->file, s->header.backing_filename_offset, in bdrv_qed_do_open()
477 backing_file_str, sizeof(bs->backing_file)); in bdrv_qed_do_open()
483 if (!g_str_equal(backing_file_str, bs->backing_file)) { in bdrv_qed_do_open()
484 pstrcpy(bs->backing_file, sizeof(bs->backing_file), in bdrv_qed_do_open()
486 pstrcpy(bs->auto_backing_file, sizeof(bs->auto_backing_file), in bdrv_qed_do_open()
491 pstrcpy(bs->backing_format, sizeof(bs->backing_format), "raw"); in bdrv_qed_do_open()
502 !bdrv_is_read_only(bs->file->bs) && !(flags & BDRV_O_INACTIVE)) { in bdrv_qed_do_open()
512 bdrv_co_flush(bs->file->bs); in bdrv_qed_do_open()
531 if (!bdrv_is_read_only(bs->file->bs) && in bdrv_qed_do_open()
543 bdrv_qed_attach_aio_context(bs, bdrv_get_aio_context(bs)); in bdrv_qed_do_open()
554 BlockDriverState *bs; member
564 BDRVQEDState *s = qoc->bs->opaque; in bdrv_qed_open_entry()
569 qoc->ret = bdrv_qed_do_open(qoc->bs, qoc->options, qoc->flags, qoc->errp); in bdrv_qed_open_entry()
573 static int coroutine_mixed_fn bdrv_qed_open(BlockDriverState *bs, QDict *options, in bdrv_qed_open() argument
577 .bs = bs, in bdrv_qed_open()
585 ret = bdrv_open_file_child(NULL, options, "file", bs, errp); in bdrv_qed_open()
590 bdrv_qed_init_state(bs); in bdrv_qed_open()
594 BDRV_POLL_WHILE(bs, qoc.ret == -EINPROGRESS); in bdrv_qed_open()
599 static void bdrv_qed_refresh_limits(BlockDriverState *bs, Error **errp) in bdrv_qed_refresh_limits() argument
601 BDRVQEDState *s = bs->opaque; in bdrv_qed_refresh_limits()
603 bs->bl.pwrite_zeroes_alignment = s->header.cluster_size; in bdrv_qed_refresh_limits()
604 bs->bl.max_pwrite_zeroes = QEMU_ALIGN_DOWN(INT_MAX, s->header.cluster_size); in bdrv_qed_refresh_limits()
615 static void GRAPH_RDLOCK bdrv_qed_do_close(BlockDriverState *bs) in bdrv_qed_do_close() argument
617 BDRVQEDState *s = bs->opaque; in bdrv_qed_do_close()
619 bdrv_qed_detach_aio_context(bs); in bdrv_qed_do_close()
622 bdrv_flush(bs->file->bs); in bdrv_qed_do_close()
634 static void GRAPH_UNLOCKED bdrv_qed_close(BlockDriverState *bs) in bdrv_qed_close() argument
639 bdrv_qed_do_close(bs); in bdrv_qed_close()
647 BlockDriverState *bs = NULL; in bdrv_qed_co_create() local
689 bs = bdrv_co_open_blockdev_ref(qed_opts->file, errp); in bdrv_qed_co_create()
690 if (bs == NULL) { in bdrv_qed_co_create()
694 blk = blk_co_new_with_bs(bs, BLK_PERM_WRITE | BLK_PERM_RESIZE, BLK_PERM_ALL, in bdrv_qed_co_create()
759 bdrv_co_unref(bs); in bdrv_qed_co_create()
770 BlockDriverState *bs = NULL; in bdrv_qed_co_create_opts() local
795 bs = bdrv_co_open(filename, NULL, NULL, in bdrv_qed_co_create_opts()
797 if (bs == NULL) { in bdrv_qed_co_create_opts()
804 qdict_put_str(qdict, "file", bs->node_name); in bdrv_qed_co_create_opts()
829 bdrv_co_unref(bs); in bdrv_qed_co_create_opts()
835 bdrv_qed_co_block_status(BlockDriverState *bs, bool want_zero, int64_t pos, in bdrv_qed_co_block_status() argument
839 BDRVQEDState *s = bs->opaque; in bdrv_qed_co_block_status()
854 *file = bs->file->bs; in bdrv_qed_co_block_status()
877 return acb->bs->opaque; in acb_to_s()
893 if (s->bs->backing) { in qed_read_backing_file()
894 BLKDBG_CO_EVENT(s->bs->file, BLKDBG_READ_BACKING_AIO); in qed_read_backing_file()
895 return bdrv_co_preadv(s->bs->backing, pos, qiov->size, qiov, 0); in qed_read_backing_file()
921 qemu_iovec_init_buf(&qiov, qemu_blockalign(s->bs, len), len); in qed_copy_from_backing_file()
929 BLKDBG_CO_EVENT(s->bs->file, BLKDBG_COW_WRITE); in qed_copy_from_backing_file()
930 ret = bdrv_co_pwritev(s->bs->file, offset, qiov.size, &qiov, 0); in qed_copy_from_backing_file()
1081 BLKDBG_CO_EVENT(s->bs->file, BLKDBG_WRITE_AIO); in qed_aio_write_main()
1082 return bdrv_co_pwritev(s->bs->file, offset, acb->cur_qiov.size, in qed_aio_write_main()
1127 if (s->bs->backing) { in qed_aio_write_cow()
1138 ret = bdrv_co_flush(s->bs->file->bs); in qed_aio_write_cow()
1152 if (s->bs->backing) { in qed_should_set_need_check()
1246 iov->iov_base = qemu_try_blockalign(acb->bs, iov->iov_len); in qed_aio_write_inplace()
1314 BlockDriverState *bs = acb->bs; in qed_aio_read_data() local
1335 BLKDBG_CO_EVENT(bs->file, BLKDBG_READ_AIO); in qed_aio_read_data()
1336 r = bdrv_co_preadv(bs->file, offset, acb->cur_qiov.size, in qed_aio_read_data()
1393 qed_co_request(BlockDriverState *bs, int64_t sector_num, QEMUIOVector *qiov, in qed_co_request() argument
1397 .bs = bs, in qed_co_request()
1405 trace_qed_aio_setup(bs->opaque, &acb, sector_num, nb_sectors, NULL, flags); in qed_co_request()
1412 bdrv_qed_co_readv(BlockDriverState *bs, int64_t sector_num, int nb_sectors, in bdrv_qed_co_readv() argument
1415 return qed_co_request(bs, sector_num, qiov, nb_sectors, 0); in bdrv_qed_co_readv()
1419 bdrv_qed_co_writev(BlockDriverState *bs, int64_t sector_num, int nb_sectors, in bdrv_qed_co_writev() argument
1422 return qed_co_request(bs, sector_num, qiov, nb_sectors, QED_AIOCB_WRITE); in bdrv_qed_co_writev()
1426 bdrv_qed_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, int64_t bytes, in bdrv_qed_co_pwrite_zeroes() argument
1429 BDRVQEDState *s = bs->opaque; in bdrv_qed_co_pwrite_zeroes()
1449 return qed_co_request(bs, offset >> BDRV_SECTOR_BITS, &qiov, in bdrv_qed_co_pwrite_zeroes()
1455 bdrv_qed_co_truncate(BlockDriverState *bs, int64_t offset, bool exact, in bdrv_qed_co_truncate() argument
1459 BDRVQEDState *s = bs->opaque; in bdrv_qed_co_truncate()
1490 static int64_t coroutine_fn bdrv_qed_co_getlength(BlockDriverState *bs) in bdrv_qed_co_getlength() argument
1492 BDRVQEDState *s = bs->opaque; in bdrv_qed_co_getlength()
1497 bdrv_qed_co_get_info(BlockDriverState *bs, BlockDriverInfo *bdi) in bdrv_qed_co_get_info() argument
1499 BDRVQEDState *s = bs->opaque; in bdrv_qed_co_get_info()
1508 bdrv_qed_co_change_backing_file(BlockDriverState *bs, const char *backing_file, in bdrv_qed_co_change_backing_file() argument
1511 BDRVQEDState *s = bs->opaque; in bdrv_qed_co_change_backing_file()
1571 ret = bdrv_co_pwrite_sync(bs->file, 0, buffer_len, buffer, 0); in bdrv_qed_co_change_backing_file()
1580 bdrv_qed_co_invalidate_cache(BlockDriverState *bs, Error **errp) in bdrv_qed_co_invalidate_cache() argument
1583 BDRVQEDState *s = bs->opaque; in bdrv_qed_co_invalidate_cache()
1586 bdrv_qed_do_close(bs); in bdrv_qed_co_invalidate_cache()
1588 bdrv_qed_init_state(bs); in bdrv_qed_co_invalidate_cache()
1590 ret = bdrv_qed_do_open(bs, NULL, bs->open_flags, errp); in bdrv_qed_co_invalidate_cache()
1598 bdrv_qed_co_check(BlockDriverState *bs, BdrvCheckResult *result, in bdrv_qed_co_check() argument
1601 BDRVQEDState *s = bs->opaque; in bdrv_qed_co_check()