Home | History | Annotate | Download | only in block

Lines Matching refs:bs

31 int qcow2_grow_l1_table(BlockDriverState *bs, int min_size)
33 BDRVQcowState *s = bs->opaque;
54 new_l1_table_offset = qcow2_alloc_clusters(bs, new_l1_size2);
71 qcow2_free_clusters(bs, s->l1_table_offset, s->l1_size * sizeof(uint64_t));
81 void qcow2_l2_cache_reset(BlockDriverState *bs)
83 BDRVQcowState *s = bs->opaque;
90 static inline int l2_cache_new_entry(BlockDriverState *bs)
92 BDRVQcowState *s = bs->opaque;
148 static uint64_t *l2_load(BlockDriverState *bs, uint64_t l2_offset)
150 BDRVQcowState *s = bs->opaque;
162 min_index = l2_cache_new_entry(bs);
208 static uint64_t *l2_allocate(BlockDriverState *bs, int l1_index)
210 BDRVQcowState *s = bs->opaque;
219 l2_offset = qcow2_alloc_clusters(bs, s->l2_size * sizeof(uint64_t));
230 min_index = l2_cache_new_entry(bs);
309 static int qcow_read(BlockDriverState *bs, int64_t sector_num,
312 BDRVQcowState *s = bs->opaque;
318 cluster_offset = qcow2_get_cluster_offset(bs, sector_num << 9, &n);
321 if (bs->backing_hd) {
323 n1 = qcow2_backing_read1(bs->backing_hd, sector_num, buf, n);
325 ret = bdrv_read(bs->backing_hd, sector_num, buf, n1);
352 static int copy_sectors(BlockDriverState *bs, uint64_t start_sect,
355 BDRVQcowState *s = bs->opaque;
361 ret = qcow_read(bs, start_sect + n_start, s->cluster_data, n);
394 uint64_t qcow2_get_cluster_offset(BlockDriverState *bs, uint64_t offset,
397 BDRVQcowState *s = bs->opaque;
440 l2_table = l2_load(bs, l2_offset);
480 static int get_cluster_table(BlockDriverState *bs, uint64_t offset,
485 BDRVQcowState *s = bs->opaque;
493 ret = qcow2_grow_l1_table(bs, l1_index + 1);
504 l2_table = l2_load(bs, l2_offset);
509 qcow2_free_clusters(bs, l2_offset, s->l2_size * sizeof(uint64_t));
510 l2_table = l2_allocate(bs, l1_index);
540 uint64_t qcow2_alloc_compressed_cluster_offset(BlockDriverState *bs,
544 BDRVQcowState *s = bs->opaque;
549 ret = get_cluster_table(bs, offset, &l2_table, &l2_offset, &l2_index);
558 qcow2_free_any_clusters(bs, cluster_offset, 1);
560 bs, compressed_size);
603 int qcow2_alloc_cluster_link_l2(BlockDriverState *bs, uint64_t cluster_offset,
606 BDRVQcowState *s = bs->opaque;
618 ret = copy_sectors(bs, start_sect, cluster_offset, 0, m->n_start);
625 ret = copy_sectors(bs, start_sect + end, cluster_offset + (end << 9),
633 if (!get_cluster_table(bs, m->offset, &l2_table, &l2_offset, &l2_index))
656 qcow2_free_any_clusters(bs,
678 uint64_t qcow2_alloc_cluster_offset(BlockDriverState *bs,
683 BDRVQcowState *s = bs->opaque;
688 ret = get_cluster_table(bs, offset, &l2_table, &l2_offset, &l2_index);
737 cluster_offset = qcow2_alloc_clusters(bs, nb_clusters * s->cluster_size);