Lines Matching refs:l2_table
161 uint64_t **l2_table) in l2_load() argument
169 *l2_table = seek_l2_table(s, l2_offset); in l2_load()
170 if (*l2_table != NULL) { in l2_load()
177 *l2_table = s->l2_cache + (min_index << s->l2_bits); in l2_load()
180 ret = bdrv_pread(bs->file, l2_offset, *l2_table, in l2_load()
234 uint64_t *l2_table; in l2_allocate() local
250 l2_table = s->l2_cache + (min_index << s->l2_bits); in l2_allocate()
254 memset(l2_table, 0, s->l2_size * sizeof(uint64_t)); in l2_allocate()
258 ret = bdrv_pread(bs->file, old_l2_offset, l2_table, in l2_allocate()
266 ret = bdrv_pwrite_sync(bs->file, l2_offset, l2_table, in l2_allocate()
284 *table = l2_table; in l2_allocate()
294 uint64_t *l2_table, uint64_t start, uint64_t mask) in count_contiguous_clusters() argument
297 uint64_t offset = be64_to_cpu(l2_table[0]) & ~mask; in count_contiguous_clusters()
303 if (offset + (uint64_t) i * cluster_size != (be64_to_cpu(l2_table[i]) & ~mask)) in count_contiguous_clusters()
309 static int count_contiguous_free_clusters(uint64_t nb_clusters, uint64_t *l2_table) in count_contiguous_free_clusters() argument
313 while(nb_clusters-- && l2_table[i] == 0) in count_contiguous_free_clusters()
445 uint64_t l2_offset, *l2_table; in qcow2_get_cluster_offset() local
488 ret = l2_load(bs, l2_offset, &l2_table); in qcow2_get_cluster_offset()
496 *cluster_offset = be64_to_cpu(l2_table[l2_index]); in qcow2_get_cluster_offset()
501 c = count_contiguous_free_clusters(nb_clusters, &l2_table[l2_index]); in qcow2_get_cluster_offset()
505 &l2_table[l2_index], 0, QCOW_OFLAG_COPIED); in qcow2_get_cluster_offset()
538 uint64_t *l2_table = NULL; in get_cluster_table() local
557 ret = l2_load(bs, l2_offset, &l2_table); in get_cluster_table()
564 ret = l2_allocate(bs, l1_index, &l2_table); in get_cluster_table()
575 *new_l2_table = l2_table; in get_cluster_table()
601 uint64_t l2_offset, *l2_table; in qcow2_alloc_compressed_cluster_offset() local
605 ret = get_cluster_table(bs, offset, &l2_table, &l2_offset, &l2_index); in qcow2_alloc_compressed_cluster_offset()
610 cluster_offset = be64_to_cpu(l2_table[l2_index]); in qcow2_alloc_compressed_cluster_offset()
633 l2_table[l2_index] = cpu_to_be64(cluster_offset); in qcow2_alloc_compressed_cluster_offset()
636 l2_table + l2_index, in qcow2_alloc_compressed_cluster_offset()
648 static int write_l2_entries(BlockDriverState *bs, uint64_t *l2_table, in write_l2_entries() argument
659 &l2_table[l2_start_index], len); in write_l2_entries()
671 uint64_t *old_cluster, start_sect, l2_offset, *l2_table; in qcow2_alloc_cluster_link_l2() local
696 ret = get_cluster_table(bs, m->offset, &l2_table, &l2_offset, &l2_index); in qcow2_alloc_cluster_link_l2()
708 if(l2_table[l2_index + i] != 0) in qcow2_alloc_cluster_link_l2()
709 old_cluster[j++] = l2_table[l2_index + i]; in qcow2_alloc_cluster_link_l2()
711 l2_table[l2_index + i] = cpu_to_be64((cluster_offset + in qcow2_alloc_cluster_link_l2()
715 ret = write_l2_entries(bs, l2_table, l2_offset, l2_index, m->nb_clusters); in qcow2_alloc_cluster_link_l2()
755 uint64_t l2_offset, *l2_table; in qcow2_alloc_cluster_offset() local
760 ret = get_cluster_table(bs, offset, &l2_table, &l2_offset, &l2_index); in qcow2_alloc_cluster_offset()
769 cluster_offset = be64_to_cpu(l2_table[l2_index]); in qcow2_alloc_cluster_offset()
775 &l2_table[l2_index], 0, 0); in qcow2_alloc_cluster_offset()
793 &l2_table[l2_index], i, 0); in qcow2_alloc_cluster_offset()
794 if ((i >= nb_clusters) || be64_to_cpu(l2_table[l2_index + i])) { in qcow2_alloc_cluster_offset()
799 &l2_table[l2_index + i]); in qcow2_alloc_cluster_offset()
804 cluster_offset = be64_to_cpu(l2_table[l2_index + i]); in qcow2_alloc_cluster_offset()