struct action_manager **manager_ptr)
{
struct action_manager *manager;
- int result = vdo_allocate(1, struct action_manager, __func__, &manager);
+ int result = vdo_allocate(1, __func__, &manager);
if (result != VDO_SUCCESS)
return result;
u64 size = cache->page_count * (u64) VDO_BLOCK_SIZE;
int result;
- result = vdo_allocate(cache->page_count, struct page_info, "page infos",
- &cache->infos);
+ result = vdo_allocate(cache->page_count, "page infos", &cache->infos);
if (result != VDO_SUCCESS)
return result;
forest->segments = index + 1;
- result = vdo_allocate(forest->segments, struct boundary,
- "forest boundary array", &forest->boundaries);
+ result = vdo_allocate(forest->segments, "forest boundary array", &forest->boundaries);
if (result != VDO_SUCCESS)
return result;
- result = vdo_allocate(forest->segments, struct tree_page *,
- "forest page pointers", &forest->pages);
+ result = vdo_allocate(forest->segments, "forest page pointers", &forest->pages);
if (result != VDO_SUCCESS)
return result;
- result = vdo_allocate(new_pages, struct tree_page,
- "new forest pages", &forest->pages[index]);
+ result = vdo_allocate(new_pages, "new forest pages", &forest->pages[index]);
if (result != VDO_SUCCESS)
return result;
struct block_map_tree *tree = &(forest->trees[root]);
height_t height;
- int result = vdo_allocate(forest->segments,
- struct block_map_tree_segment,
- "tree root segments", &tree->segments);
+ result = vdo_allocate(forest->segments, "tree root segments", &tree->segments);
if (result != VDO_SUCCESS)
return result;
vdo_set_completion_callback(&zone->completion, timeout_index_operations_callback,
zone->thread_id);
INIT_LIST_HEAD(&zone->lock_pool);
- result = vdo_allocate(LOCK_POOL_CAPACITY, struct hash_lock, "hash_lock array",
- &zone->lock_array);
+ result = vdo_allocate(LOCK_POOL_CAPACITY, "hash_lock array", &zone->lock_array);
if (result != VDO_SUCCESS)
return result;
substring_count++;
}
- result = vdo_allocate(substring_count + 1, char *, "string-splitting array",
- &substrings);
+ result = vdo_allocate(substring_count + 1, "string-splitting array", &substrings);
if (result != VDO_SUCCESS)
return result;
if (*s == separator) {
ptrdiff_t length = s - string;
- result = vdo_allocate(length + 1, char, "split string",
+ result = vdo_allocate(length + 1, "split string",
&substrings[current_substring]);
if (result != VDO_SUCCESS) {
free_string_array(substrings);
BUG_ON(current_substring != (substring_count - 1));
length = strlen(string);
- result = vdo_allocate(length + 1, char, "split string",
- &substrings[current_substring]);
+ result = vdo_allocate(length + 1, "split string", &substrings[current_substring]);
if (result != VDO_SUCCESS) {
free_string_array(substrings);
return result;
for (i = 0; (i < array_length) && (substring_array[i] != NULL); i++)
string_length += strlen(substring_array[i]) + 1;
- result = vdo_allocate(string_length, char, __func__, &output);
+ result = vdo_allocate(string_length, __func__, &output);
if (result != VDO_SUCCESS)
return result;
return VDO_BAD_CONFIGURATION;
}
- result = vdo_allocate(1, struct device_config, "device_config", &config);
+ result = vdo_allocate(1, "device_config", &config);
if (result != VDO_SUCCESS) {
handle_parse_error(config, error_ptr,
"Could not allocate config structure");
struct partition *partition;
int result;
- result = vdo_allocate(1, struct partition, __func__, &partition);
+ result = vdo_allocate(1, __func__, &partition);
if (result != VDO_SUCCESS)
return result;
if ((gfp_mask & GFP_NOWAIT) == GFP_NOWAIT) {
flush = vdo_allocate_memory_nowait(sizeof(struct vdo_flush), __func__);
} else {
- int result = vdo_allocate(1, struct vdo_flush, __func__, &flush);
+ int result = vdo_allocate(1, __func__, &flush);
if (result != VDO_SUCCESS)
vdo_log_error_strerror(result, "failed to allocate spare flush");
*/
int vdo_make_flusher(struct vdo *vdo)
{
- int result = vdo_allocate(1, struct flusher, __func__, &vdo->flusher);
+ int result = vdo_allocate(1, __func__, &vdo->flusher);
if (result != VDO_SUCCESS)
return result;
int result;
struct funnel_queue *queue;
- result = vdo_allocate(1, struct funnel_queue, "funnel queue", &queue);
+ result = vdo_allocate(1, "funnel queue", &queue);
if (result != VDO_SUCCESS)
return result;
"queue priority count %u within limit %u", type->max_priority,
VDO_WORK_Q_MAX_PRIORITY);
- result = vdo_allocate(1, struct simple_work_queue, "simple work queue", &queue);
+ result = vdo_allocate(1, "simple work queue", &queue);
if (result != VDO_SUCCESS)
return result;
return result;
}
- result = vdo_allocate(1, struct round_robin_work_queue, "round-robin work queue",
- &queue);
+ result = vdo_allocate(1, "round-robin work queue", &queue);
if (result != VDO_SUCCESS)
return result;
- result = vdo_allocate(thread_count, struct simple_work_queue *,
- "subordinate work queues", &queue->service_queues);
+ result = vdo_allocate(thread_count, "subordinate work queues", &queue->service_queues);
if (result != VDO_SUCCESS) {
vdo_free(queue);
return result;
size_t memory_size;
struct open_chapter_index *index;
- result = vdo_allocate(1, struct open_chapter_index, "open chapter index", &index);
+ result = vdo_allocate(1, "open chapter index", &index);
if (result != VDO_SUCCESS)
return result;
if (result != UDS_SUCCESS)
return result;
- result = vdo_allocate(1, struct uds_configuration, __func__, &config);
+ result = vdo_allocate(1, __func__, &config);
if (result != VDO_SUCCESS)
return result;
{
int result;
- result = vdo_allocate(size, u8, "delta list", &delta_zone->memory);
+ result = vdo_allocate(size, "delta list", &delta_zone->memory);
if (result != VDO_SUCCESS)
return result;
- result = vdo_allocate(list_count + 2, u64, "delta list temp",
- &delta_zone->new_offsets);
+ result = vdo_allocate(list_count + 2, "delta list temp", &delta_zone->new_offsets);
if (result != VDO_SUCCESS)
return result;
/* Allocate the delta lists. */
- result = vdo_allocate(list_count + 2, struct delta_list, "delta lists",
- &delta_zone->delta_lists);
+ result = vdo_allocate(list_count + 2, "delta lists", &delta_zone->delta_lists);
if (result != VDO_SUCCESS)
return result;
unsigned int z;
size_t zone_memory;
- result = vdo_allocate(zone_count, struct delta_zone, "Delta Index Zones",
- &delta_index->delta_zones);
+ result = vdo_allocate(zone_count, "Delta Index Zones", &delta_index->delta_zones);
if (result != VDO_SUCCESS)
return result;
unsigned int z;
u8 *data;
- result = vdo_allocate(DELTA_LIST_MAX_BYTE_COUNT, u8, __func__, &data);
+ result = vdo_allocate(DELTA_LIST_MAX_BYTE_COUNT, __func__, &data);
if (result != VDO_SUCCESS)
return result;
int result;
struct uds_request_queue *queue;
- result = vdo_allocate(1, struct uds_request_queue, __func__, &queue);
+ result = vdo_allocate(1, __func__, &queue);
if (result != VDO_SUCCESS)
return result;
int result;
struct index_geometry *geometry;
- result = vdo_allocate(1, struct index_geometry, "geometry", &geometry);
+ result = vdo_allocate(1, "geometry", &geometry);
if (result != VDO_SUCCESS)
return result;
u8 *buffer;
size_t offset = 0;
- result = vdo_allocate(table->encoded_size, u8, "index save data", &buffer);
+ result = vdo_allocate(table->encoded_size, "index save data", &buffer);
if (result != VDO_SUCCESS)
return result;
u8 *buffer;
size_t offset = 0;
- result = vdo_allocate(table->encoded_size, u8, "layout data", &buffer);
+ result = vdo_allocate(table->encoded_size, "layout data", &buffer);
if (result != VDO_SUCCESS)
return result;
if (result != UDS_SUCCESS)
return result;
- result = vdo_allocate(sizes.save_count, struct index_save_layout, __func__,
- &layout->index.saves);
+ result = vdo_allocate(sizes.save_count, __func__, &layout->index.saves);
if (result != VDO_SUCCESS)
return result;
u8 *buffer;
size_t offset = 0;
- result = vdo_allocate(saved_size, u8, "super block data", &buffer);
+ result = vdo_allocate(saved_size, "super block data", &buffer);
if (result != VDO_SUCCESS)
return result;
int result;
u64 next_block = first_block;
- result = vdo_allocate(layout->super.max_saves, struct index_save_layout,
- __func__, &layout->index.saves);
+ result = vdo_allocate(layout->super.max_saves, __func__, &layout->index.saves);
if (result != VDO_SUCCESS)
return result;
if (result != UDS_SUCCESS)
return result;
- result = vdo_allocate(1, struct index_layout, __func__, &layout);
+ result = vdo_allocate(1, __func__, &layout);
if (result != VDO_SUCCESS)
return result;
int result;
struct index_page_map *map;
- result = vdo_allocate(1, struct index_page_map, "page map", &map);
+ result = vdo_allocate(1, "page map", &map);
if (result != VDO_SUCCESS)
return result;
map->geometry = geometry;
map->entries_per_chapter = geometry->index_pages_per_chapter - 1;
- result = vdo_allocate(get_entry_count(geometry), u16, "Index Page Map Entries",
+ result = vdo_allocate(get_entry_count(geometry), "Index Page Map Entries",
&map->entries);
if (result != VDO_SUCCESS) {
uds_free_index_page_map(map);
u64 saved_size = uds_compute_index_page_map_save_size(map->geometry);
u32 i;
- result = vdo_allocate(saved_size, u8, "page map data", &buffer);
+ result = vdo_allocate(saved_size, "page map data", &buffer);
if (result != VDO_SUCCESS)
return result;
u64 saved_size = uds_compute_index_page_map_save_size(map->geometry);
u32 i;
- result = vdo_allocate(saved_size, u8, "page map data", &buffer);
+ result = vdo_allocate(saved_size, "page map data", &buffer);
if (result != VDO_SUCCESS)
return result;
int result;
struct uds_index_session *session;
- result = vdo_allocate(1, struct uds_index_session, __func__, &session);
+ result = vdo_allocate(1, __func__, &session);
if (result != VDO_SUCCESS)
return result;
int result;
struct uds_request *request;
- result = vdo_allocate(1, struct uds_request, __func__, &request);
+ result = vdo_allocate(1, __func__, &request);
if (result != VDO_SUCCESS)
return result;
int result;
struct index_zone *zone;
- result = vdo_allocate(1, struct index_zone, "index zone", &zone);
+ result = vdo_allocate(1, "index zone", &zone);
if (result != VDO_SUCCESS)
return result;
return result;
}
- result = vdo_allocate(index->zone_count, struct index_zone *, "zones",
- &index->zones);
+ result = vdo_allocate(index->zone_count, "zones", &index->zones);
if (result != VDO_SUCCESS) {
uds_free_index(index);
return result;
int result;
struct io_factory *factory;
- result = vdo_allocate(1, struct io_factory, __func__, &factory);
+ result = vdo_allocate(1, __func__, &factory);
if (result != VDO_SUCCESS)
return result;
if (result != UDS_SUCCESS)
return result;
- result = vdo_allocate(1, struct buffered_reader, "buffered reader", &reader);
+ result = vdo_allocate(1, "buffered reader", &reader);
if (result != VDO_SUCCESS) {
dm_bufio_client_destroy(client);
return result;
if (result != UDS_SUCCESS)
return result;
- result = vdo_allocate(1, struct buffered_writer, "buffered writer", &writer);
+ result = vdo_allocate(1, "buffered writer", &writer);
if (result != VDO_SUCCESS) {
dm_bufio_client_destroy(client);
return result;
chapter->virtual_chapter = NO_CHAPTER;
chapter->index_pages_count = geometry->index_pages_per_chapter;
- result = vdo_allocate(chapter->index_pages_count, struct delta_index_page,
- __func__, &chapter->index_pages);
+ result = vdo_allocate(chapter->index_pages_count, __func__, &chapter->index_pages);
if (result != VDO_SUCCESS)
return result;
- return vdo_allocate(chapter->index_pages_count, struct dm_buffer *,
- "sparse index volume pages", &chapter->page_buffers);
+ return vdo_allocate(chapter->index_pages_count, "sparse index volume pages",
+ &chapter->page_buffers);
}
static int __must_check make_search_list(struct sparse_cache *cache,
}
/* purge_search_list() needs some temporary lists for sorting. */
- result = vdo_allocate(capacity * 2, struct cached_chapter_index *,
- "scratch entries", &cache->scratch_entries);
+ result = vdo_allocate(capacity * 2, "scratch entries", &cache->scratch_entries);
if (result != VDO_SUCCESS)
goto out;
(zone_count * sizeof(struct volume_sub_index_zone)));
/* The following arrays are initialized to all zeros. */
- result = vdo_allocate(params.list_count, u64, "first chapter to flush",
+ result = vdo_allocate(params.list_count, "first chapter to flush",
&sub_index->flush_chapters);
if (result != VDO_SUCCESS)
return result;
- return vdo_allocate(zone_count, struct volume_sub_index_zone,
- "volume index zones", &sub_index->zones);
+ return vdo_allocate(zone_count, "volume index zones", &sub_index->zones);
}
int uds_make_volume_index(const struct uds_configuration *config, u64 volume_nonce,
struct volume_index *volume_index;
int result;
- result = vdo_allocate(1, struct volume_index, "volume index", &volume_index);
+ result = vdo_allocate(1, "volume index", &volume_index);
if (result != VDO_SUCCESS)
return result;
volume_index->sparse_sample_rate = config->sparse_sample_rate;
- result = vdo_allocate(config->zone_count, struct volume_index_zone,
- "volume index zones", &volume_index->zones);
+ result = vdo_allocate(config->zone_count, "volume index zones", &volume_index->zones);
if (result != VDO_SUCCESS) {
uds_free_volume_index(volume_index);
return result;
if (result != VDO_SUCCESS)
return result;
- result = vdo_allocate(VOLUME_CACHE_MAX_QUEUED_READS, struct queued_read,
- "volume read queue", &cache->read_queue);
+ result = vdo_allocate(VOLUME_CACHE_MAX_QUEUED_READS, "volume read queue",
+ &cache->read_queue);
if (result != VDO_SUCCESS)
return result;
- result = vdo_allocate(cache->zone_count, struct search_pending_counter,
- "Volume Cache Zones", &cache->search_pending_counters);
+ result = vdo_allocate(cache->zone_count, "Volume Cache Zones",
+ &cache->search_pending_counters);
if (result != VDO_SUCCESS)
return result;
- result = vdo_allocate(cache->indexable_pages, u16, "page cache index",
- &cache->index);
+ result = vdo_allocate(cache->indexable_pages, "page cache index", &cache->index);
if (result != VDO_SUCCESS)
return result;
- result = vdo_allocate(cache->cache_slots, struct cached_page, "page cache cache",
- &cache->cache);
+ result = vdo_allocate(cache->cache_slots, "page cache cache", &cache->cache);
if (result != VDO_SUCCESS)
return result;
unsigned int reserved_buffers;
int result;
- result = vdo_allocate(1, struct volume, "volume", &volume);
+ result = vdo_allocate(1, "volume", &volume);
if (result != VDO_SUCCESS)
return result;
return result;
}
- result = vdo_allocate(geometry->records_per_page,
- const struct uds_volume_record *, "record pointers",
+ result = vdo_allocate(geometry->records_per_page, "record pointers",
&volume->record_pointers);
if (result != VDO_SUCCESS) {
uds_free_volume(volume);
uds_init_cond(&volume->read_threads_read_done_cond);
uds_init_cond(&volume->read_threads_cond);
- result = vdo_allocate(config->read_threads, struct thread *, "reader threads",
- &volume->reader_threads);
+ result = vdo_allocate(config->read_threads, "reader threads", &volume->reader_threads);
if (result != VDO_SUCCESS) {
uds_free_volume(volume);
return result;
* without have to wrap back around to element zero.
*/
map->bucket_count = capacity + (NEIGHBORHOOD - 1);
- return vdo_allocate(map->bucket_count, struct bucket,
- "struct int_map buckets", &map->buckets);
+ return vdo_allocate(map->bucket_count, "struct int_map buckets", &map->buckets);
}
/**
int result;
size_t capacity;
- result = vdo_allocate(1, struct int_map, "struct int_map", &map);
+ result = vdo_allocate(1, "struct int_map", &map);
if (result != VDO_SUCCESS)
return result;
} else {
struct vmalloc_block_info *block;
- if (vdo_allocate(1, struct vmalloc_block_info, __func__, &block) == VDO_SUCCESS) {
+ if (vdo_allocate(1, __func__, &block) == VDO_SUCCESS) {
/*
* It is possible for __vmalloc to fail to allocate memory because there
* are no pages available. A short sleep may allow the page reclaimer
void *new_ptr)
{
int result;
+ char *temp_ptr;
if (size == 0) {
vdo_free(ptr);
return VDO_SUCCESS;
}
- result = vdo_allocate(size, char, what, new_ptr);
+ result = vdo_allocate(size, what, &temp_ptr);
if (result != VDO_SUCCESS)
return result;
+ *(void **) new_ptr = temp_ptr;
if (ptr != NULL) {
if (old_size < size)
int result;
u8 *dup;
- result = vdo_allocate(strlen(string) + 1, u8, what, &dup);
+ result = vdo_allocate(strlen(string) + 1, what, &dup);
if (result != VDO_SUCCESS)
return result;
/* Custom memory allocation function that tracks memory usage */
int __must_check vdo_allocate_memory(size_t size, size_t align, const char *what, void *ptr);
-/*
- * Allocate storage based on element counts, sizes, and alignment.
- *
- * This is a generalized form of our allocation use case: It allocates an array of objects,
- * optionally preceded by one object of another type (i.e., a struct with trailing variable-length
- * array), with the alignment indicated.
- *
- * Why is this inline? The sizes and alignment will always be constant, when invoked through the
- * macros below, and often the count will be a compile-time constant 1 or the number of extra bytes
- * will be a compile-time constant 0. So at least some of the arithmetic can usually be optimized
- * away, and the run-time selection between allocation functions always can. In many cases, it'll
- * boil down to just a function call with a constant size.
- *
- * @count: The number of objects to allocate
- * @size: The size of an object
- * @extra: The number of additional bytes to allocate
- * @align: The required alignment
- * @what: What is being allocated (for error logging)
- * @ptr: A pointer to hold the allocated memory
- *
- * Return: VDO_SUCCESS or an error code
- */
-static inline int __vdo_do_allocation(size_t count, size_t size, size_t extra,
- size_t align, const char *what, void *ptr)
-{
- size_t total_size = count * size + extra;
-
- /* Overflow check: */
- if ((size > 0) && (count > ((SIZE_MAX - extra) / size))) {
- /*
- * This is kind of a hack: We rely on the fact that SIZE_MAX would cover the entire
- * address space (minus one byte) and thus the system can never allocate that much
- * and the call will always fail. So we can report an overflow as "out of memory"
- * by asking for "merely" SIZE_MAX bytes.
- */
- total_size = SIZE_MAX;
- }
-
- return vdo_allocate_memory(total_size, align, what, ptr);
-}
-
/*
* Allocate one or more elements of the indicated type, logging an error if the allocation fails.
* The memory will be zeroed.
*
* @COUNT: The number of objects to allocate
- * @TYPE: The type of objects to allocate. This type determines the alignment of the allocation.
* @WHAT: What is being allocated (for error logging)
* @PTR: A pointer to hold the allocated memory
*
* Return: VDO_SUCCESS or an error code
*/
-#define vdo_allocate(COUNT, TYPE, WHAT, PTR) \
- __vdo_do_allocation(COUNT, sizeof(TYPE), 0, __alignof__(TYPE), WHAT, PTR)
+#define vdo_allocate(COUNT, WHAT, PTR) \
+ vdo_allocate_memory(size_mul((COUNT), sizeof(typeof(**(PTR)))), \
+ __alignof__(typeof(**(PTR))), WHAT, PTR)
/*
* Allocate a structure with a flexible array member, with a specified number of elements, logging
struct vdo_statistics *stats;
int result;
- result = vdo_allocate(1, struct vdo_statistics, __func__, &stats);
+ result = vdo_allocate(1, __func__, &stats);
if (result != VDO_SUCCESS) {
vdo_log_error("Cannot allocate memory to write VDO statistics");
return result;
block_count_t i;
int result;
- result = vdo_allocate(1, struct packer, __func__, &packer);
+ result = vdo_allocate(1, __func__, &packer);
if (result != VDO_SUCCESS)
return result;
struct thread_config *config = &vdo->thread_config;
struct lock_counter *counter = &journal->lock_counter;
- result = vdo_allocate(journal->size, u16, __func__, &counter->journal_counters);
+ result = vdo_allocate(journal->size, __func__, &counter->journal_counters);
if (result != VDO_SUCCESS)
return result;
- result = vdo_allocate(journal->size, atomic_t, __func__,
- &counter->journal_decrement_counts);
+ result = vdo_allocate(journal->size, __func__, &counter->journal_decrement_counts);
if (result != VDO_SUCCESS)
return result;
- result = vdo_allocate(journal->size * config->logical_zone_count, u16, __func__,
+ result = vdo_allocate(journal->size * config->logical_zone_count, __func__,
&counter->logical_counters);
if (result != VDO_SUCCESS)
return result;
- result = vdo_allocate(journal->size, atomic_t, __func__,
- &counter->logical_zone_counts);
+ result = vdo_allocate(journal->size, __func__, &counter->logical_zone_counts);
if (result != VDO_SUCCESS)
return result;
- result = vdo_allocate(journal->size * config->physical_zone_count, u16, __func__,
+ result = vdo_allocate(journal->size * config->physical_zone_count, __func__,
&counter->physical_counters);
if (result != VDO_SUCCESS)
return result;
- result = vdo_allocate(journal->size, atomic_t, __func__,
- &counter->physical_zone_counts);
+ result = vdo_allocate(journal->size, __func__, &counter->physical_zone_counts);
if (result != VDO_SUCCESS)
return result;
* Allocate a full block for the journal block even though not all of the space is used
* since the VIO needs to write a full disk block.
*/
- result = vdo_allocate(VDO_BLOCK_SIZE, char, __func__, &data);
+ result = vdo_allocate(VDO_BLOCK_SIZE, __func__, &data);
if (result != VDO_SUCCESS)
return result;
* packed_recovery_journal_entry from every valid journal block.
*/
count = ((repair->highest_tail - repair->block_map_head + 1) * entries_per_block);
- result = vdo_allocate(count, struct numbered_block_mapping, __func__,
- &repair->entries);
+ result = vdo_allocate(count, __func__, &repair->entries);
if (result != VDO_SUCCESS)
return result;
* Allocate an array of numbered_block_mapping structs just large enough to transcribe
* every packed_recovery_journal_entry from every valid journal block.
*/
- result = vdo_allocate(repair->entry_count, struct numbered_block_mapping,
- __func__, &repair->entries);
+ result = vdo_allocate(repair->entry_count, __func__, &repair->entries);
if (result != VDO_SUCCESS)
return result;
prepare_repair_completion(repair, finish_repair, VDO_ZONE_TYPE_ADMIN);
repair->page_count = page_count;
- result = vdo_allocate(remaining * VDO_BLOCK_SIZE, char, __func__,
- &repair->journal_data);
+ result = vdo_allocate(remaining * VDO_BLOCK_SIZE, __func__, &repair->journal_data);
if (abort_on_error(result, repair))
return;
- result = vdo_allocate(vio_count, struct vio, __func__, &repair->vios);
+ result = vdo_allocate(vio_count, __func__, &repair->vios);
if (abort_on_error(result, repair))
return;
if (result != VDO_SUCCESS)
return result;
- result = vdo_allocate(slab->reference_block_count, struct reference_block,
- __func__, &slab->reference_blocks);
+ result = vdo_allocate(slab->reference_block_count, __func__, &slab->reference_blocks);
if (result != VDO_SUCCESS)
return result;
* so we can word-search even at the very end.
*/
bytes = (slab->reference_block_count * COUNTS_PER_BLOCK) + (2 * BYTES_PER_WORD);
- result = vdo_allocate(bytes, vdo_refcount_t, "ref counts array",
- &slab->counters);
+ result = vdo_allocate(bytes, "ref counts array", &slab->counters);
if (result != VDO_SUCCESS) {
vdo_free(vdo_forget(slab->reference_blocks));
return result;
struct slab_status *statuses;
struct slab_iterator iterator = get_slab_iterator(allocator);
- result = vdo_allocate(allocator->slab_count, struct slab_status, __func__,
- &statuses);
+ result = vdo_allocate(allocator->slab_count, __func__, &statuses);
if (result != VDO_SUCCESS)
return result;
const struct slab_config *slab_config = &slab->allocator->depot->slab_config;
int result;
- result = vdo_allocate(slab_config->slab_journal_blocks, struct journal_lock,
- __func__, &journal->locks);
+ result = vdo_allocate(slab_config->slab_journal_blocks, __func__, &journal->locks);
if (result != VDO_SUCCESS)
return result;
- result = vdo_allocate(VDO_BLOCK_SIZE, char, "struct packed_slab_journal_block",
- (char **) &journal->block);
+ BUILD_BUG_ON(sizeof(*journal->block) != VDO_BLOCK_SIZE);
+ result = vdo_allocate(1, "struct packed_slab_journal_block", &journal->block);
if (result != VDO_SUCCESS)
return result;
struct vdo_slab *slab;
int result;
- result = vdo_allocate(1, struct vdo_slab, __func__, &slab);
+ result = vdo_allocate(1, __func__, &slab);
if (result != VDO_SUCCESS)
return result;
physical_block_number_t slab_origin;
int result;
- result = vdo_allocate(slab_count, struct vdo_slab *,
- "slab pointer array", &depot->new_slabs);
+ result = vdo_allocate(slab_count, "slab pointer array", &depot->new_slabs);
if (result != VDO_SUCCESS)
return result;
char *journal_data;
int result;
- result = vdo_allocate(VDO_BLOCK_SIZE * slab_journal_size,
- char, __func__, &journal_data);
+ result = vdo_allocate(VDO_BLOCK_SIZE * slab_journal_size, __func__, &journal_data);
if (result != VDO_SUCCESS)
return result;
struct slab_summary_block *block = &allocator->summary_blocks[index];
int result;
- result = vdo_allocate(VDO_BLOCK_SIZE, char, __func__, &block->outgoing_entries);
+ result = vdo_allocate(VDO_BLOCK_SIZE, __func__, &block->outgoing_entries);
if (result != VDO_SUCCESS)
return result;
if (result != VDO_SUCCESS)
return result;
- result = vdo_allocate(VDO_SLAB_SUMMARY_BLOCKS_PER_ZONE,
- struct slab_summary_block, __func__,
+ result = vdo_allocate(VDO_SLAB_SUMMARY_BLOCKS_PER_ZONE, __func__,
&allocator->summary_blocks);
if (result != VDO_SUCCESS)
return result;
depot->summary_origin = summary_partition->offset;
depot->hint_shift = vdo_get_slab_summary_hint_shift(depot->slab_size_shift);
- result = vdo_allocate(MAXIMUM_VDO_SLAB_SUMMARY_ENTRIES,
- struct slab_summary_entry, __func__,
+ result = vdo_allocate(MAXIMUM_VDO_SLAB_SUMMARY_ENTRIES, __func__,
&depot->summary_entries);
if (result != VDO_SUCCESS)
return result;
struct thread *thread;
int result;
- result = vdo_allocate(1, struct thread, __func__, &thread);
+ result = vdo_allocate(1, __func__, &thread);
if (result != VDO_SUCCESS) {
vdo_log_warning("Error allocating memory for %s", name);
return result;
config->hash_zone_count = counts.hash_zones;
}
- result = vdo_allocate(config->logical_zone_count, thread_id_t,
- "logical thread array", &config->logical_threads);
+ result = vdo_allocate(config->logical_zone_count, "logical thread array",
+ &config->logical_threads);
if (result != VDO_SUCCESS) {
uninitialize_thread_config(config);
return result;
}
- result = vdo_allocate(config->physical_zone_count, thread_id_t,
- "physical thread array", &config->physical_threads);
+ result = vdo_allocate(config->physical_zone_count, "physical thread array",
+ &config->physical_threads);
if (result != VDO_SUCCESS) {
uninitialize_thread_config(config);
return result;
}
- result = vdo_allocate(config->hash_zone_count, thread_id_t,
- "hash thread array", &config->hash_zone_threads);
+ result = vdo_allocate(config->hash_zone_count, "hash thread array",
+ &config->hash_zone_threads);
if (result != VDO_SUCCESS) {
uninitialize_thread_config(config);
return result;
}
- result = vdo_allocate(config->bio_thread_count, thread_id_t,
- "bio thread array", &config->bio_threads);
+ result = vdo_allocate(config->bio_thread_count, "bio thread array", &config->bio_threads);
if (result != VDO_SUCCESS) {
uninitialize_thread_config(config);
return result;
char *block;
int result;
- result = vdo_allocate(VDO_BLOCK_SIZE, u8, __func__, &block);
+ result = vdo_allocate(VDO_BLOCK_SIZE, __func__, &block);
if (result != VDO_SUCCESS)
return result;
config->thread_counts.hash_zones, vdo->thread_config.thread_count);
/* Compression context storage */
- result = vdo_allocate(config->thread_counts.cpu_threads, char *, "LZ4 context",
+ result = vdo_allocate(config->thread_counts.cpu_threads, "LZ4 context",
&vdo->compression_context);
if (result != VDO_SUCCESS) {
*reason = "cannot allocate LZ4 context";
}
for (i = 0; i < config->thread_counts.cpu_threads; i++) {
- result = vdo_allocate(LZ4_MEM_COMPRESS, char, "LZ4 context",
+ result = vdo_allocate(LZ4_MEM_COMPRESS, "LZ4 context",
&vdo->compression_context[i]);
if (result != VDO_SUCCESS) {
*reason = "cannot allocate LZ4 context";
/* Initialize with a generic failure reason to prevent returning garbage. */
*reason = "Unspecified error";
- result = vdo_allocate(1, struct vdo, __func__, &vdo);
+ result = vdo_allocate(1, __func__, &vdo);
if (result != VDO_SUCCESS) {
*reason = "Cannot allocate VDO";
return result;
snprintf(vdo->thread_name_prefix, sizeof(vdo->thread_name_prefix),
"vdo%u", instance);
- result = vdo_allocate(vdo->thread_config.thread_count,
- struct vdo_thread, __func__, &vdo->threads);
+ result = vdo_allocate(vdo->thread_config.thread_count, __func__, &vdo->threads);
if (result != VDO_SUCCESS) {
*reason = "Cannot allocate thread structures";
return result;
{
int result;
- result = vdo_allocate(VDO_BLOCK_SIZE, char, "encoded super block",
- (char **) &vdo->super_block.buffer);
+ result = vdo_allocate(VDO_BLOCK_SIZE, "encoded super block", &vdo->super_block.buffer);
if (result != VDO_SUCCESS)
return result;
if (result != VDO_SUCCESS)
return result;
- result = vdo_allocate(1, struct read_only_listener, __func__,
- &read_only_listener);
+ result = vdo_allocate(1, __func__, &read_only_listener);
if (result != VDO_SUCCESS)
return result;
* Metadata vios should use direct allocation and not use the buffer pool, which is
* reserved for submissions from the linux block layer.
*/
- result = vdo_allocate(1, struct vio, __func__, &vio);
+ result = vdo_allocate(1, __func__, &vio);
if (result != VDO_SUCCESS) {
vdo_log_error("metadata vio allocation failure %d", result);
return result;
INIT_LIST_HEAD(&pool->available);
INIT_LIST_HEAD(&pool->busy);
- result = vdo_allocate(pool_size * per_vio_size, char,
- "VIO pool buffer", &pool->buffer);
+ result = vdo_allocate(pool_size * per_vio_size, "VIO pool buffer", &pool->buffer);
if (result != VDO_SUCCESS) {
free_vio_pool(pool);
return result;