Lines Matching refs:bs
96 decompress_cluster(BlockDriverState *bs, uint64_t cluster_offset);
110 static int qcow_open(BlockDriverState *bs, QDict *options, int flags, in qcow_open() argument
113 BDRVQcowState *s = bs->opaque; in qcow_open()
125 ret = bdrv_open_file_child(NULL, options, "file", bs, errp); in qcow_open()
132 ret = bdrv_pread(bs->file, 0, sizeof(header), &header, 0); in qcow_open()
224 bs->encrypted = true; in qcow_open()
237 bs->total_sectors = header.size / 512; in qcow_open()
264 ret = bdrv_pread(bs->file, s->l1_table_offset, in qcow_open()
276 qemu_try_blockalign(bs->file->bs, in qcow_open()
290 if (len > 1023 || len >= sizeof(bs->backing_file)) { in qcow_open()
295 ret = bdrv_pread(bs->file, header.backing_file_offset, len, in qcow_open()
296 bs->auto_backing_file, 0); in qcow_open()
300 bs->auto_backing_file[len] = '\0'; in qcow_open()
301 pstrcpy(bs->backing_file, sizeof(bs->backing_file), in qcow_open()
302 bs->auto_backing_file); in qcow_open()
308 bdrv_get_device_or_node_name(bs)); in qcow_open()
359 get_cluster_offset(BlockDriverState *bs, uint64_t offset, int allocate, in get_cluster_offset() argument
363 BDRVQcowState *s = bs->opaque; in get_cluster_offset()
378 l2_offset = bdrv_co_getlength(bs->file->bs); in get_cluster_offset()
387 BLKDBG_CO_EVENT(bs->file, BLKDBG_L1_UPDATE); in get_cluster_offset()
388 ret = bdrv_co_pwrite_sync(bs->file, in get_cluster_offset()
418 BLKDBG_CO_EVENT(bs->file, BLKDBG_L2_LOAD); in get_cluster_offset()
421 ret = bdrv_co_pwrite_sync(bs->file, l2_offset, in get_cluster_offset()
427 ret = bdrv_co_pread(bs->file, l2_offset, in get_cluster_offset()
442 BLKDBG_CO_EVENT(bs->file, BLKDBG_CLUSTER_ALLOC); in get_cluster_offset()
450 if (decompress_cluster(bs, cluster_offset) < 0) { in get_cluster_offset()
453 cluster_offset = bdrv_co_getlength(bs->file->bs); in get_cluster_offset()
459 BLKDBG_CO_EVENT(bs->file, BLKDBG_WRITE_AIO); in get_cluster_offset()
460 ret = bdrv_co_pwrite(bs->file, cluster_offset, s->cluster_size, in get_cluster_offset()
466 cluster_offset = bdrv_co_getlength(bs->file->bs); in get_cluster_offset()
476 ret = bdrv_co_truncate(bs->file, in get_cluster_offset()
484 if (bs->encrypted && in get_cluster_offset()
499 BLKDBG_CO_EVENT(bs->file, BLKDBG_WRITE_AIO); in get_cluster_offset()
500 ret = bdrv_co_pwrite(bs->file, cluster_offset + i, in get_cluster_offset()
518 BLKDBG_CO_EVENT(bs->file, BLKDBG_L2_UPDATE_COMPRESSED); in get_cluster_offset()
520 BLKDBG_CO_EVENT(bs->file, BLKDBG_L2_UPDATE); in get_cluster_offset()
522 ret = bdrv_co_pwrite_sync(bs->file, l2_offset + l2_index * sizeof(tmp), in get_cluster_offset()
533 qcow_co_block_status(BlockDriverState *bs, bool want_zero, in qcow_co_block_status() argument
537 BDRVQcowState *s = bs->opaque; in qcow_co_block_status()
543 ret = get_cluster_offset(bs, offset, 0, 0, 0, 0, &cluster_offset); in qcow_co_block_status()
564 *file = bs->file->bs; in qcow_co_block_status()
596 decompress_cluster(BlockDriverState *bs, uint64_t cluster_offset) in decompress_cluster() argument
598 BDRVQcowState *s = bs->opaque; in decompress_cluster()
606 BLKDBG_CO_EVENT(bs->file, BLKDBG_READ_COMPRESSED); in decompress_cluster()
607 ret = bdrv_co_pread(bs->file, coffset, csize, s->cluster_data, 0); in decompress_cluster()
619 static void qcow_refresh_limits(BlockDriverState *bs, Error **errp) in qcow_refresh_limits() argument
625 bs->bl.request_alignment = BDRV_SECTOR_SIZE; in qcow_refresh_limits()
629 qcow_co_preadv(BlockDriverState *bs, int64_t offset, int64_t bytes, in qcow_co_preadv() argument
632 BDRVQcowState *s = bs->opaque; in qcow_co_preadv()
640 buf = orig_buf = qemu_try_blockalign(bs, qiov->size); in qcow_co_preadv()
653 ret = get_cluster_offset(bs, offset, 0, 0, 0, 0, &cluster_offset); in qcow_co_preadv()
664 if (bs->backing) { in qcow_co_preadv()
668 BLKDBG_CO_EVENT(bs->file, BLKDBG_READ_BACKING_AIO); in qcow_co_preadv()
669 ret = bdrv_co_pread(bs->backing, offset, n, buf, 0); in qcow_co_preadv()
680 if (decompress_cluster(bs, cluster_offset) < 0) { in qcow_co_preadv()
691 BLKDBG_CO_EVENT(bs->file, BLKDBG_READ_AIO); in qcow_co_preadv()
692 ret = bdrv_co_pread(bs->file, cluster_offset + offset_in_cluster, in qcow_co_preadv()
698 if (bs->encrypted) { in qcow_co_preadv()
725 qcow_co_pwritev(BlockDriverState *bs, int64_t offset, int64_t bytes, in qcow_co_pwritev() argument
728 BDRVQcowState *s = bs->opaque; in qcow_co_pwritev()
739 if (bs->encrypted || qiov->niov > 1) { in qcow_co_pwritev()
740 buf = orig_buf = qemu_try_blockalign(bs, qiov->size); in qcow_co_pwritev()
758 ret = get_cluster_offset(bs, offset, 1, 0, offset_in_cluster, in qcow_co_pwritev()
767 if (bs->encrypted) { in qcow_co_pwritev()
776 BLKDBG_CO_EVENT(bs->file, BLKDBG_WRITE_AIO); in qcow_co_pwritev()
777 ret = bdrv_co_pwrite(bs->file, cluster_offset + offset_in_cluster, in qcow_co_pwritev()
796 static void qcow_close(BlockDriverState *bs) in qcow_close() argument
798 BDRVQcowState *s = bs->opaque; in qcow_close()
819 BlockDriverState *bs; in qcow_co_create() local
841 bs = bdrv_co_open_blockdev_ref(qcow_opts->file, errp); in qcow_co_create()
842 if (bs == NULL) { in qcow_co_create()
846 qcow_blk = blk_co_new_with_bs(bs, BLK_PERM_WRITE | BLK_PERM_RESIZE, in qcow_co_create()
926 bdrv_co_unref(bs); in qcow_co_create()
936 BlockDriverState *bs = NULL; in qcow_co_create_opts() local
986 bs = bdrv_co_open(filename, NULL, NULL, in qcow_co_create_opts()
988 if (bs == NULL) { in qcow_co_create_opts()
995 qdict_put_str(qdict, "file", bs->node_name); in qcow_co_create_opts()
1025 bdrv_co_unref(bs); in qcow_co_create_opts()
1030 static int GRAPH_RDLOCK qcow_make_empty(BlockDriverState *bs) in qcow_make_empty() argument
1032 BDRVQcowState *s = bs->opaque; in qcow_make_empty()
1037 if (bdrv_pwrite_sync(bs->file, s->l1_table_offset, l1_length, s->l1_table, in qcow_make_empty()
1040 ret = bdrv_truncate(bs->file, s->l1_table_offset + l1_length, false, in qcow_make_empty()
1055 qcow_co_pwritev_compressed(BlockDriverState *bs, int64_t offset, int64_t bytes, in qcow_co_pwritev_compressed() argument
1058 BDRVQcowState *s = bs->opaque; in qcow_co_pwritev_compressed()
1064 buf = qemu_blockalign(bs, s->cluster_size); in qcow_co_pwritev_compressed()
1067 offset + bytes != bs->total_sectors << BDRV_SECTOR_BITS) in qcow_co_pwritev_compressed()
1106 ret = qcow_co_pwritev(bs, offset, bytes, qiov, 0); in qcow_co_pwritev_compressed()
1113 ret = get_cluster_offset(bs, offset, 2, out_len, 0, 0, &cluster_offset); in qcow_co_pwritev_compressed()
1124 BLKDBG_CO_EVENT(bs->file, BLKDBG_WRITE_COMPRESSED); in qcow_co_pwritev_compressed()
1125 ret = bdrv_co_pwrite(bs->file, cluster_offset, out_len, out_buf, 0); in qcow_co_pwritev_compressed()
1138 qcow_co_get_info(BlockDriverState *bs, BlockDriverInfo *bdi) in qcow_co_get_info() argument
1140 BDRVQcowState *s = bs->opaque; in qcow_co_get_info()