Lines Matching refs:ab

96 static void *element_at(struct dm_array_info *info, struct array_block *ab,  in element_at()  argument
99 unsigned char *entry = (unsigned char *) (ab + 1); in element_at()
110 static void on_entries(struct dm_array_info *info, struct array_block *ab, in on_entries() argument
113 unsigned nr_entries = le32_to_cpu(ab->nr_entries); in on_entries()
114 fn(info->value_type.context, element_at(info, ab, 0), nr_entries); in on_entries()
120 static void inc_ablock_entries(struct dm_array_info *info, struct array_block *ab) in inc_ablock_entries() argument
125 on_entries(info, ab, vt->inc); in inc_ablock_entries()
131 static void dec_ablock_entries(struct dm_array_info *info, struct array_block *ab) in dec_ablock_entries() argument
136 on_entries(info, ab, vt->dec); in dec_ablock_entries()
152 struct dm_block **block, struct array_block **ab) in alloc_ablock() argument
160 (*ab) = dm_block_data(*block); in alloc_ablock()
161 (*ab)->max_entries = cpu_to_le32(max_entries); in alloc_ablock()
162 (*ab)->nr_entries = cpu_to_le32(0); in alloc_ablock()
163 (*ab)->value_size = cpu_to_le32(info->value_type.size); in alloc_ablock()
173 static void fill_ablock(struct dm_array_info *info, struct array_block *ab, in fill_ablock() argument
179 BUG_ON(new_nr > le32_to_cpu(ab->max_entries)); in fill_ablock()
180 BUG_ON(new_nr < le32_to_cpu(ab->nr_entries)); in fill_ablock()
182 nr_entries = le32_to_cpu(ab->nr_entries); in fill_ablock()
187 memcpy(element_at(info, ab, i), value, vt->size); in fill_ablock()
188 ab->nr_entries = cpu_to_le32(new_nr); in fill_ablock()
196 static void trim_ablock(struct dm_array_info *info, struct array_block *ab, in trim_ablock() argument
202 BUG_ON(new_nr > le32_to_cpu(ab->max_entries)); in trim_ablock()
203 BUG_ON(new_nr > le32_to_cpu(ab->nr_entries)); in trim_ablock()
205 nr_entries = le32_to_cpu(ab->nr_entries); in trim_ablock()
208 vt->dec(vt->context, element_at(info, ab, new_nr - 1), delta); in trim_ablock()
209 ab->nr_entries = cpu_to_le32(new_nr); in trim_ablock()
217 struct dm_block **block, struct array_block **ab) in get_ablock() argument
225 *ab = dm_block_data(*block); in get_ablock()
251 struct array_block **ab) in lookup_ablock() argument
261 return get_ablock(info, le64_to_cpu(block_le), block, ab); in lookup_ablock()
279 struct dm_block **block, struct array_block **ab) in __shadow_ablock() argument
287 *ab = dm_block_data(*block); in __shadow_ablock()
289 inc_ablock_entries(info, *ab); in __shadow_ablock()
325 struct array_block **ab) in shadow_ablock() argument
337 r = __shadow_ablock(info, b, block, ab); in shadow_ablock()
354 struct array_block *ab; in insert_new_ablock() local
356 r = alloc_ablock(info, size_of_block, max_entries, &block, &ab); in insert_new_ablock()
360 fill_ablock(info, ab, value, nr); in insert_new_ablock()
466 struct array_block *ab; in shrink() local
487 resize->new_nr_full_blocks, &block, &ab); in shrink()
491 trim_ablock(resize->info, ab, resize->new_nr_entries_in_last_block); in shrink()
505 struct array_block *ab; in grow_extend_tail_block() local
508 resize->old_nr_full_blocks, &block, &ab); in grow_extend_tail_block()
512 fill_ablock(resize->info, ab, resize->value, new_nr_entries); in grow_extend_tail_block()
589 struct array_block *ab; in __block_dec() local
607 r = get_ablock(info, b, &block, &ab); in __block_dec()
614 dec_ablock_entries(info, ab); in __block_dec()
702 static int populate_ablock_with_values(struct dm_array_info *info, struct array_block *ab, in populate_ablock_with_values() argument
709 BUG_ON(le32_to_cpu(ab->nr_entries)); in populate_ablock_with_values()
710 BUG_ON(new_nr > le32_to_cpu(ab->max_entries)); in populate_ablock_with_values()
713 r = fn(base + i, element_at(info, ab, i), context); in populate_ablock_with_values()
718 vt->inc(vt->context, element_at(info, ab, i), 1); in populate_ablock_with_values()
721 ab->nr_entries = cpu_to_le32(new_nr); in populate_ablock_with_values()
730 struct array_block *ab; in dm_array_new() local
742 r = alloc_ablock(info, size_of_block, max_entries, &block, &ab); in dm_array_new()
746 r = populate_ablock_with_values(info, ab, fn, context, in dm_array_new()
777 struct array_block *ab; in dm_array_get_value() local
784 r = lookup_ablock(info, root, index / max_entries, &block, &ab); in dm_array_get_value()
789 if (entry >= le32_to_cpu(ab->nr_entries)) in dm_array_get_value()
792 memcpy(value_le, element_at(info, ab, entry), in dm_array_get_value()
805 struct array_block *ab; in array_set_value() local
815 r = shadow_ablock(info, &root, index / max_entries, &block, &ab); in array_set_value()
821 if (entry >= le32_to_cpu(ab->nr_entries)) { in array_set_value()
826 old_value = element_at(info, ab, entry); in array_set_value()
868 struct array_block *ab; in walk_ablock() local
871 r = get_ablock(wi->info, le64_to_cpu(block_le), &block, &ab); in walk_ablock()
875 max_entries = le32_to_cpu(ab->max_entries); in walk_ablock()
876 nr_entries = le32_to_cpu(ab->nr_entries); in walk_ablock()
879 element_at(wi->info, ab, i)); in walk_ablock()
915 c->ab = NULL; in load_ablock()
924 r = get_ablock(c->info, le64_to_cpu(value_le), &c->block, &c->ab); in load_ablock()
969 if (c->index >= le32_to_cpu(c->ab->nr_entries)) { in dm_array_cursor_next()
988 uint32_t remaining = le32_to_cpu(c->ab->nr_entries) - c->index; in dm_array_cursor_skip()
1006 *value_le = element_at(c->info, c->ab, c->index); in dm_array_cursor_get_value()