Lines Matching refs:bs
268 static void vmdk_free_extents(BlockDriverState *bs) in vmdk_free_extents() argument
271 BDRVVmdkState *s = bs->opaque; in vmdk_free_extents()
281 if (e->file != bs->file) { in vmdk_free_extents()
282 bdrv_unref_child(bs, e->file); in vmdk_free_extents()
290 static void vmdk_free_last_extent(BlockDriverState *bs) in vmdk_free_last_extent() argument
292 BDRVVmdkState *s = bs->opaque; in vmdk_free_last_extent()
303 vmdk_read_cid(BlockDriverState *bs, int parent, uint32_t *pcid) in vmdk_read_cid() argument
309 BDRVVmdkState *s = bs->opaque; in vmdk_read_cid()
313 ret = bdrv_pread(bs->file, s->desc_offset, DESC_SIZE, desc, 0); in vmdk_read_cid()
346 vmdk_write_cid(BlockDriverState *bs, uint32_t cid) in vmdk_write_cid() argument
350 BDRVVmdkState *s = bs->opaque; in vmdk_write_cid()
356 desc_buf_size = bdrv_getlength(bs->file->bs); in vmdk_write_cid()
367 ret = bdrv_co_pread(bs->file, s->desc_offset, desc_buf_size, desc, 0); in vmdk_write_cid()
387 ret = bdrv_co_pwrite_sync(bs->file, s->desc_offset, desc_buf_size, desc, 0); in vmdk_write_cid()
395 static int coroutine_fn GRAPH_RDLOCK vmdk_is_cid_valid(BlockDriverState *bs) in vmdk_is_cid_valid() argument
397 BDRVVmdkState *s = bs->opaque; in vmdk_is_cid_valid()
400 if (!s->cid_checked && bs->backing) { in vmdk_is_cid_valid()
401 BlockDriverState *p_bs = bs->backing->bs; in vmdk_is_cid_valid()
434 assert(state->bs != NULL); in vmdk_reopen_prepare()
437 s = state->bs->opaque; in vmdk_reopen_prepare()
448 rs->extents_using_bs_file[i] = s->extents[i].file == state->bs->file; in vmdk_reopen_prepare()
465 BDRVVmdkState *s = state->bs->opaque; in vmdk_reopen_commit()
474 s->extents[i].file = state->bs->file; in vmdk_reopen_commit()
486 static int GRAPH_RDLOCK vmdk_parent_open(BlockDriverState *bs) in vmdk_parent_open() argument
490 BDRVVmdkState *s = bs->opaque; in vmdk_parent_open()
494 ret = bdrv_pread(bs->file, s->desc_offset, DESC_SIZE, desc, 0); in vmdk_parent_open()
509 if ((end_name - p_name) > sizeof(bs->auto_backing_file) - 1) { in vmdk_parent_open()
514 pstrcpy(bs->auto_backing_file, end_name - p_name + 1, p_name); in vmdk_parent_open()
515 pstrcpy(bs->backing_file, sizeof(bs->backing_file), in vmdk_parent_open()
516 bs->auto_backing_file); in vmdk_parent_open()
517 pstrcpy(bs->backing_format, sizeof(bs->backing_format), in vmdk_parent_open()
528 static int vmdk_add_extent(BlockDriverState *bs, in vmdk_add_extent() argument
537 BDRVVmdkState *s = bs->opaque; in vmdk_add_extent()
565 nb_sectors = bdrv_nb_sectors(file->bs); in vmdk_add_extent()
592 bs->total_sectors = extent->end_sector; in vmdk_add_extent()
600 vmdk_init_tables(BlockDriverState *bs, VmdkExtent *extent, Error **errp) in vmdk_init_tables() argument
616 bdrv_refresh_filename(extent->file->bs); in vmdk_init_tables()
619 extent->file->bs->filename); in vmdk_init_tables()
641 bdrv_refresh_filename(extent->file->bs); in vmdk_init_tables()
644 extent->file->bs->filename); in vmdk_init_tables()
663 vmdk_open_vmfs_sparse(BlockDriverState *bs, BdrvChild *file, int flags, in vmdk_open_vmfs_sparse() argument
673 bdrv_refresh_filename(file->bs); in vmdk_open_vmfs_sparse()
676 file->bs->filename); in vmdk_open_vmfs_sparse()
679 ret = vmdk_add_extent(bs, file, false, in vmdk_open_vmfs_sparse()
691 ret = vmdk_init_tables(bs, extent, errp); in vmdk_open_vmfs_sparse()
694 vmdk_free_last_extent(bs); in vmdk_open_vmfs_sparse()
819 vmdk_open_se_sparse(BlockDriverState *bs, BdrvChild *file, int flags, in vmdk_open_se_sparse() argument
827 ret = bdrv_apply_auto_read_only(bs, in vmdk_open_se_sparse()
837 bdrv_refresh_filename(file->bs); in vmdk_open_se_sparse()
840 file->bs->filename); in vmdk_open_se_sparse()
855 bdrv_refresh_filename(file->bs); in vmdk_open_se_sparse()
858 file->bs->filename); in vmdk_open_se_sparse()
868 ret = vmdk_add_extent(bs, file, false, in vmdk_open_se_sparse()
888 ret = vmdk_init_tables(bs, extent, errp); in vmdk_open_se_sparse()
891 vmdk_free_last_extent(bs); in vmdk_open_se_sparse()
897 static int vmdk_open_desc_file(BlockDriverState *bs, int flags, char *buf,
906 size = bdrv_getlength(file->bs); in vmdk_read_desc()
935 vmdk_open_vmdk4(BlockDriverState *bs, BdrvChild *file, int flags, in vmdk_open_vmdk4() argument
943 BDRVVmdkState *s = bs->opaque; in vmdk_open_vmdk4()
949 bdrv_refresh_filename(file->bs); in vmdk_open_vmdk4()
952 file->bs->filename); in vmdk_open_vmdk4()
962 ret = vmdk_open_desc_file(bs, flags, buf, options, errp); in vmdk_open_vmdk4()
998 ret = bdrv_pread(file, bs->file->bs->total_sectors * 512 - 1536, in vmdk_open_vmdk4()
1052 if (bdrv_nb_sectors(file->bs) < le64_to_cpu(header.grain_offset)) { in vmdk_open_vmdk4()
1059 ret = vmdk_add_extent(bs, file, false, in vmdk_open_vmdk4()
1080 ret = vmdk_init_tables(bs, extent, errp); in vmdk_open_vmdk4()
1083 vmdk_free_last_extent(bs); in vmdk_open_vmdk4()
1117 vmdk_open_sparse(BlockDriverState *bs, BdrvChild *file, int flags, in vmdk_open_sparse() argument
1125 return vmdk_open_vmfs_sparse(bs, file, flags, errp); in vmdk_open_sparse()
1127 return vmdk_open_vmdk4(bs, file, flags, options, errp); in vmdk_open_sparse()
1146 vmdk_parse_extents(const char *desc, BlockDriverState *bs, QDict *options, in vmdk_parse_extents() argument
1162 BDRVVmdkState *s = bs->opaque; in vmdk_parse_extents()
1209 desc_file_dir = bdrv_dirname(bs->file->bs, errp); in vmdk_parse_extents()
1211 bdrv_refresh_filename(bs->file->bs); in vmdk_parse_extents()
1214 bs->file->bs->filename); in vmdk_parse_extents()
1233 bs, &child_of_bds, extent_role, false, in vmdk_parse_extents()
1246 ret = vmdk_add_extent(bs, extent_file, true, sectors, in vmdk_parse_extents()
1251 bdrv_unref_child(bs, extent_file); in vmdk_parse_extents()
1263 ret = vmdk_open_sparse(bs, extent_file, bs->open_flags, buf, in vmdk_parse_extents()
1270 bdrv_unref_child(bs, extent_file); in vmdk_parse_extents()
1277 ret = vmdk_open_se_sparse(bs, extent_file, bs->open_flags, errp); in vmdk_parse_extents()
1281 bdrv_unref_child(bs, extent_file); in vmdk_parse_extents()
1291 bdrv_unref_child(bs, extent_file); in vmdk_parse_extents()
1318 vmdk_open_desc_file(BlockDriverState *bs, int flags, char *buf, QDict *options, in vmdk_open_desc_file() argument
1323 BDRVVmdkState *s = bs->opaque; in vmdk_open_desc_file()
1342 ret = vmdk_parse_extents(buf, bs, options, errp); in vmdk_open_desc_file()
1347 static int vmdk_open(BlockDriverState *bs, QDict *options, int flags, in vmdk_open() argument
1352 BDRVVmdkState *s = bs->opaque; in vmdk_open()
1357 ret = bdrv_open_file_child(NULL, options, "file", bs, errp); in vmdk_open()
1362 buf = vmdk_read_desc(bs->file, 0, errp); in vmdk_open()
1371 ret = vmdk_open_sparse(bs, bs->file, flags, buf, options, in vmdk_open()
1377 bs->file->role &= ~BDRV_CHILD_DATA; in vmdk_open()
1380 bdrv_child_refresh_perms(bs, bs->file, &error_abort); in vmdk_open()
1382 ret = vmdk_open_desc_file(bs, flags, buf, options, errp); in vmdk_open()
1390 ret = vmdk_parent_open(bs); in vmdk_open()
1394 ret = vmdk_read_cid(bs, 0, &s->cid); in vmdk_open()
1398 ret = vmdk_read_cid(bs, 1, &s->parent_cid); in vmdk_open()
1407 bdrv_get_device_or_node_name(bs)); in vmdk_open()
1420 vmdk_free_extents(bs); in vmdk_open()
1425 static void vmdk_refresh_limits(BlockDriverState *bs, Error **errp) in vmdk_refresh_limits() argument
1427 BDRVVmdkState *s = bs->opaque; in vmdk_refresh_limits()
1432 bs->bl.pwrite_zeroes_alignment = in vmdk_refresh_limits()
1433 MAX(bs->bl.pwrite_zeroes_alignment, in vmdk_refresh_limits()
1452 get_whole_cluster(BlockDriverState *bs, VmdkExtent *extent, in get_whole_cluster() argument
1465 whole_grain = qemu_blockalign(bs, cluster_bytes); in get_whole_cluster()
1466 copy_from_backing = bs->backing && !zeroed; in get_whole_cluster()
1476 if (bs->backing && !vmdk_is_cid_valid(bs)) { in get_whole_cluster()
1486 ret = bdrv_co_pread(bs->backing, offset, skip_start_bytes, in get_whole_cluster()
1506 ret = bdrv_co_pread(bs->backing, offset + skip_end_bytes, in get_whole_cluster()
1552 if (bdrv_co_flush(extent->file->bs) < 0) { in vmdk_L2update()
1583 get_cluster_offset(BlockDriverState *bs, VmdkExtent *extent, in get_cluster_offset() argument
1736 ret = get_whole_cluster(bs, extent, cluster_sector * BDRV_SECTOR_SIZE, in get_cluster_offset()
1780 vmdk_co_block_status(BlockDriverState *bs, bool want_zero, in vmdk_co_block_status() argument
1784 BDRVVmdkState *s = bs->opaque; in vmdk_co_block_status()
1794 ret = get_cluster_offset(bs, extent, NULL, offset, false, &cluster_offset, in vmdk_co_block_status()
1820 *file = extent->file->bs; in vmdk_co_block_status()
1978 vmdk_co_preadv(BlockDriverState *bs, int64_t offset, int64_t bytes, in vmdk_co_preadv() argument
1981 BDRVVmdkState *s = bs->opaque; in vmdk_co_preadv()
1998 ret = get_cluster_offset(bs, extent, NULL, in vmdk_co_preadv()
2007 if (bs->backing && ret != VMDK_ZEROED) { in vmdk_co_preadv()
2008 if (!vmdk_is_cid_valid(bs)) { in vmdk_co_preadv()
2017 BLKDBG_CO_EVENT(bs->file, BLKDBG_READ_BACKING_AIO); in vmdk_co_preadv()
2018 ret = bdrv_co_preadv(bs->backing, offset, n_bytes, in vmdk_co_preadv()
2060 vmdk_pwritev(BlockDriverState *bs, uint64_t offset, uint64_t bytes, in vmdk_pwritev() argument
2063 BDRVVmdkState *s = bs->opaque; in vmdk_pwritev()
2071 if (DIV_ROUND_UP(offset, BDRV_SECTOR_SIZE) > bs->total_sectors) { in vmdk_pwritev()
2074 offset, bs->total_sectors); in vmdk_pwritev()
2090 ret = get_cluster_offset(bs, extent, &m_data, offset, in vmdk_pwritev()
2102 ret = get_cluster_offset(bs, extent, &m_data, offset, in vmdk_pwritev()
2147 ret = vmdk_write_cid(bs, g_random_int()); in vmdk_pwritev()
2158 vmdk_co_pwritev(BlockDriverState *bs, int64_t offset, int64_t bytes, in vmdk_co_pwritev() argument
2162 BDRVVmdkState *s = bs->opaque; in vmdk_co_pwritev()
2164 ret = vmdk_pwritev(bs, offset, bytes, qiov, false, false); in vmdk_co_pwritev()
2170 vmdk_co_pwritev_compressed(BlockDriverState *bs, int64_t offset, int64_t bytes, in vmdk_co_pwritev_compressed() argument
2176 BDRVVmdkState *s = bs->opaque; in vmdk_co_pwritev_compressed()
2181 length = bdrv_co_getlength(s->extents[i].file->bs); in vmdk_co_pwritev_compressed()
2194 return vmdk_co_pwritev(bs, offset, bytes, qiov, 0); in vmdk_co_pwritev_compressed()
2198 vmdk_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, int64_t bytes, in vmdk_co_pwrite_zeroes() argument
2202 BDRVVmdkState *s = bs->opaque; in vmdk_co_pwrite_zeroes()
2207 ret = vmdk_pwritev(bs, offset, bytes, NULL, true, true); in vmdk_co_pwrite_zeroes()
2209 ret = vmdk_pwritev(bs, offset, bytes, NULL, true, false); in vmdk_co_pwrite_zeroes()
2664 BlockDriverState *bs = NULL; in vmdk_co_create_opts_cb() local
2694 bdrv_co_unref(bs); in vmdk_co_create_opts_cb()
2814 BlockDriverState *bs; in vmdk_co_create_cb() local
2819 bs = bdrv_co_open_blockdev_ref(opts->file, errp); in vmdk_co_create_cb()
2834 bs = bdrv_co_open_blockdev_ref(list->value, errp); in vmdk_co_create_cb()
2836 if (!bs) { in vmdk_co_create_cb()
2839 blk = blk_co_new_with_bs(bs, in vmdk_co_create_cb()
2848 bdrv_co_unref(bs); in vmdk_co_create_cb()
2885 static void vmdk_close(BlockDriverState *bs) in vmdk_close() argument
2887 BDRVVmdkState *s = bs->opaque; in vmdk_close()
2889 vmdk_free_extents(bs); in vmdk_close()
2896 vmdk_co_get_allocated_file_size(BlockDriverState *bs) in vmdk_co_get_allocated_file_size() argument
2901 BDRVVmdkState *s = bs->opaque; in vmdk_co_get_allocated_file_size()
2903 ret = bdrv_co_get_allocated_file_size(bs->file->bs); in vmdk_co_get_allocated_file_size()
2908 if (s->extents[i].file == bs->file) { in vmdk_co_get_allocated_file_size()
2911 r = bdrv_co_get_allocated_file_size(s->extents[i].file->bs); in vmdk_co_get_allocated_file_size()
2920 static int GRAPH_RDLOCK vmdk_has_zero_init(BlockDriverState *bs) in vmdk_has_zero_init() argument
2923 BDRVVmdkState *s = bs->opaque; in vmdk_has_zero_init()
2929 if (!bdrv_has_zero_init(s->extents[i].file->bs)) { in vmdk_has_zero_init()
2941 bdrv_refresh_filename(extent->file->bs); in vmdk_get_extent_info()
2943 .filename = g_strdup(extent->file->bs->filename), in vmdk_get_extent_info()
2956 vmdk_co_check(BlockDriverState *bs, BdrvCheckResult *result, BdrvCheckMode fix) in vmdk_co_check() argument
2958 BDRVVmdkState *s = bs->opaque; in vmdk_co_check()
2961 int64_t total_sectors = bdrv_co_nb_sectors(bs); in vmdk_co_check()
2981 ret = get_cluster_offset(bs, extent, NULL, in vmdk_co_check()
2991 int64_t extent_len = bdrv_co_getlength(extent->file->bs); in vmdk_co_check()
3015 vmdk_get_specific_info(BlockDriverState *bs, Error **errp) in vmdk_get_specific_info() argument
3018 BDRVVmdkState *s = bs->opaque; in vmdk_get_specific_info()
3051 vmdk_co_get_info(BlockDriverState *bs, BlockDriverInfo *bdi) in vmdk_co_get_info() argument
3054 BDRVVmdkState *s = bs->opaque; in vmdk_co_get_info()
3071 vmdk_gather_child_options(BlockDriverState *bs, QDict *target, in vmdk_gather_child_options() argument
3076 qobject_ref(bs->file->bs->full_open_options)); in vmdk_gather_child_options()
3079 if (bs->backing) { in vmdk_gather_child_options()
3081 qobject_ref(bs->backing->bs->full_open_options)); in vmdk_gather_child_options()