Commit 2de70388 authored by Mike Snitzer's avatar Mike Snitzer

dm vdo: check for VDO_SUCCESS return value from memory-alloc functions

VDO_SUCCESS and UDS_SUCCESS were used interchangably, update all
callers of VDO's memory-alloc functions to consistently check for
VDO_SUCCESS.
Signed-off-by: default avatarMike Snitzer <snitzer@kernel.org>
Signed-off-by: default avatarMatthew Sakai <msakai@redhat.com>
parent 97d33803
...@@ -223,11 +223,11 @@ static int __must_check allocate_cache_components(struct vdo_page_cache *cache) ...@@ -223,11 +223,11 @@ static int __must_check allocate_cache_components(struct vdo_page_cache *cache)
result = vdo_allocate(cache->page_count, struct page_info, "page infos", result = vdo_allocate(cache->page_count, struct page_info, "page infos",
&cache->infos); &cache->infos);
if (result != UDS_SUCCESS) if (result != VDO_SUCCESS)
return result; return result;
result = vdo_allocate_memory(size, VDO_BLOCK_SIZE, "cache pages", &cache->pages); result = vdo_allocate_memory(size, VDO_BLOCK_SIZE, "cache pages", &cache->pages);
if (result != UDS_SUCCESS) if (result != VDO_SUCCESS)
return result; return result;
result = vdo_int_map_create(cache->page_count, &cache->page_map); result = vdo_int_map_create(cache->page_count, &cache->page_map);
...@@ -2874,7 +2874,7 @@ int vdo_decode_block_map(struct block_map_state_2_0 state, block_count_t logical ...@@ -2874,7 +2874,7 @@ int vdo_decode_block_map(struct block_map_state_2_0 state, block_count_t logical
result = vdo_allocate_extended(struct block_map, result = vdo_allocate_extended(struct block_map,
vdo->thread_config.logical_zone_count, vdo->thread_config.logical_zone_count,
struct block_map_zone, __func__, &map); struct block_map_zone, __func__, &map);
if (result != UDS_SUCCESS) if (result != VDO_SUCCESS)
return result; return result;
map->vdo = vdo; map->vdo = vdo;
......
...@@ -847,7 +847,7 @@ int make_data_vio_pool(struct vdo *vdo, data_vio_count_t pool_size, ...@@ -847,7 +847,7 @@ int make_data_vio_pool(struct vdo *vdo, data_vio_count_t pool_size,
result = vdo_allocate_extended(struct data_vio_pool, pool_size, struct data_vio, result = vdo_allocate_extended(struct data_vio_pool, pool_size, struct data_vio,
__func__, &pool); __func__, &pool);
if (result != UDS_SUCCESS) if (result != VDO_SUCCESS)
return result; return result;
ASSERT_LOG_ONLY((discard_limit <= pool_size), ASSERT_LOG_ONLY((discard_limit <= pool_size),
......
...@@ -280,7 +280,7 @@ static int split_string(const char *string, char separator, char ***substring_ar ...@@ -280,7 +280,7 @@ static int split_string(const char *string, char separator, char ***substring_ar
result = vdo_allocate(substring_count + 1, char *, "string-splitting array", result = vdo_allocate(substring_count + 1, char *, "string-splitting array",
&substrings); &substrings);
if (result != UDS_SUCCESS) if (result != VDO_SUCCESS)
return result; return result;
for (s = string; *s != 0; s++) { for (s = string; *s != 0; s++) {
...@@ -289,7 +289,7 @@ static int split_string(const char *string, char separator, char ***substring_ar ...@@ -289,7 +289,7 @@ static int split_string(const char *string, char separator, char ***substring_ar
result = vdo_allocate(length + 1, char, "split string", result = vdo_allocate(length + 1, char, "split string",
&substrings[current_substring]); &substrings[current_substring]);
if (result != UDS_SUCCESS) { if (result != VDO_SUCCESS) {
free_string_array(substrings); free_string_array(substrings);
return result; return result;
} }
...@@ -310,7 +310,7 @@ static int split_string(const char *string, char separator, char ***substring_ar ...@@ -310,7 +310,7 @@ static int split_string(const char *string, char separator, char ***substring_ar
result = vdo_allocate(length + 1, char, "split string", result = vdo_allocate(length + 1, char, "split string",
&substrings[current_substring]); &substrings[current_substring]);
if (result != UDS_SUCCESS) { if (result != VDO_SUCCESS) {
free_string_array(substrings); free_string_array(substrings);
return result; return result;
} }
...@@ -1527,7 +1527,7 @@ static size_t get_bit_array_size(unsigned int bit_count) ...@@ -1527,7 +1527,7 @@ static size_t get_bit_array_size(unsigned int bit_count)
* Since the array is initially NULL, this also initializes the array the first time we allocate an * Since the array is initially NULL, this also initializes the array the first time we allocate an
* instance number. * instance number.
* *
* Return: UDS_SUCCESS or an error code from the allocation * Return: VDO_SUCCESS or an error code from the allocation
*/ */
static int grow_bit_array(void) static int grow_bit_array(void)
{ {
...@@ -1540,19 +1540,19 @@ static int grow_bit_array(void) ...@@ -1540,19 +1540,19 @@ static int grow_bit_array(void)
get_bit_array_size(instances.bit_count), get_bit_array_size(instances.bit_count),
get_bit_array_size(new_count), get_bit_array_size(new_count),
"instance number bit array", &new_words); "instance number bit array", &new_words);
if (result != UDS_SUCCESS) if (result != VDO_SUCCESS)
return result; return result;
instances.bit_count = new_count; instances.bit_count = new_count;
instances.words = new_words; instances.words = new_words;
return UDS_SUCCESS; return VDO_SUCCESS;
} }
/** /**
* allocate_instance() - Allocate an instance number. * allocate_instance() - Allocate an instance number.
* @instance_ptr: A point to hold the instance number * @instance_ptr: A point to hold the instance number
* *
* Return: UDS_SUCCESS or an error code * Return: VDO_SUCCESS or an error code
* *
* This function must be called while holding the instances lock. * This function must be called while holding the instances lock.
*/ */
...@@ -1564,7 +1564,7 @@ static int allocate_instance(unsigned int *instance_ptr) ...@@ -1564,7 +1564,7 @@ static int allocate_instance(unsigned int *instance_ptr)
/* If there are no unallocated instances, grow the bit array. */ /* If there are no unallocated instances, grow the bit array. */
if (instances.count >= instances.bit_count) { if (instances.count >= instances.bit_count) {
result = grow_bit_array(); result = grow_bit_array();
if (result != UDS_SUCCESS) if (result != VDO_SUCCESS)
return result; return result;
} }
...@@ -1587,7 +1587,7 @@ static int allocate_instance(unsigned int *instance_ptr) ...@@ -1587,7 +1587,7 @@ static int allocate_instance(unsigned int *instance_ptr)
instances.count++; instances.count++;
instances.next = instance + 1; instances.next = instance + 1;
*instance_ptr = instance; *instance_ptr = instance;
return UDS_SUCCESS; return VDO_SUCCESS;
} }
static int construct_new_vdo_registered(struct dm_target *ti, unsigned int argc, static int construct_new_vdo_registered(struct dm_target *ti, unsigned int argc,
......
...@@ -800,7 +800,7 @@ static int allocate_partition(struct layout *layout, u8 id, ...@@ -800,7 +800,7 @@ static int allocate_partition(struct layout *layout, u8 id,
int result; int result;
result = vdo_allocate(1, struct partition, __func__, &partition); result = vdo_allocate(1, struct partition, __func__, &partition);
if (result != UDS_SUCCESS) if (result != VDO_SUCCESS)
return result; return result;
partition->id = id; partition->id = id;
......
...@@ -15,7 +15,7 @@ int uds_make_funnel_queue(struct funnel_queue **queue_ptr) ...@@ -15,7 +15,7 @@ int uds_make_funnel_queue(struct funnel_queue **queue_ptr)
struct funnel_queue *queue; struct funnel_queue *queue;
result = vdo_allocate(1, struct funnel_queue, "funnel queue", &queue); result = vdo_allocate(1, struct funnel_queue, "funnel queue", &queue);
if (result != UDS_SUCCESS) if (result != VDO_SUCCESS)
return result; return result;
/* /*
......
...@@ -324,7 +324,7 @@ static int make_simple_work_queue(const char *thread_name_prefix, const char *na ...@@ -324,7 +324,7 @@ static int make_simple_work_queue(const char *thread_name_prefix, const char *na
VDO_WORK_Q_MAX_PRIORITY); VDO_WORK_Q_MAX_PRIORITY);
result = vdo_allocate(1, struct simple_work_queue, "simple work queue", &queue); result = vdo_allocate(1, struct simple_work_queue, "simple work queue", &queue);
if (result != UDS_SUCCESS) if (result != VDO_SUCCESS)
return result; return result;
queue->private = private; queue->private = private;
...@@ -401,12 +401,12 @@ int vdo_make_work_queue(const char *thread_name_prefix, const char *name, ...@@ -401,12 +401,12 @@ int vdo_make_work_queue(const char *thread_name_prefix, const char *name,
result = vdo_allocate(1, struct round_robin_work_queue, "round-robin work queue", result = vdo_allocate(1, struct round_robin_work_queue, "round-robin work queue",
&queue); &queue);
if (result != UDS_SUCCESS) if (result != VDO_SUCCESS)
return result; return result;
result = vdo_allocate(thread_count, struct simple_work_queue *, result = vdo_allocate(thread_count, struct simple_work_queue *,
"subordinate work queues", &queue->service_queues); "subordinate work queues", &queue->service_queues);
if (result != UDS_SUCCESS) { if (result != VDO_SUCCESS) {
vdo_free(queue); vdo_free(queue);
return result; return result;
} }
......
...@@ -21,7 +21,7 @@ int uds_make_open_chapter_index(struct open_chapter_index **chapter_index, ...@@ -21,7 +21,7 @@ int uds_make_open_chapter_index(struct open_chapter_index **chapter_index,
struct open_chapter_index *index; struct open_chapter_index *index;
result = vdo_allocate(1, struct open_chapter_index, "open chapter index", &index); result = vdo_allocate(1, struct open_chapter_index, "open chapter index", &index);
if (result != UDS_SUCCESS) if (result != VDO_SUCCESS)
return result; return result;
/* /*
......
...@@ -326,7 +326,7 @@ int uds_make_configuration(const struct uds_parameters *params, ...@@ -326,7 +326,7 @@ int uds_make_configuration(const struct uds_parameters *params,
return result; return result;
result = vdo_allocate(1, struct uds_configuration, __func__, &config); result = vdo_allocate(1, struct uds_configuration, __func__, &config);
if (result != UDS_SUCCESS) if (result != VDO_SUCCESS)
return result; return result;
result = uds_make_index_geometry(DEFAULT_BYTES_PER_PAGE, record_pages_per_chapter, result = uds_make_index_geometry(DEFAULT_BYTES_PER_PAGE, record_pages_per_chapter,
......
...@@ -312,18 +312,18 @@ static int initialize_delta_zone(struct delta_zone *delta_zone, size_t size, ...@@ -312,18 +312,18 @@ static int initialize_delta_zone(struct delta_zone *delta_zone, size_t size,
int result; int result;
result = vdo_allocate(size, u8, "delta list", &delta_zone->memory); result = vdo_allocate(size, u8, "delta list", &delta_zone->memory);
if (result != UDS_SUCCESS) if (result != VDO_SUCCESS)
return result; return result;
result = vdo_allocate(list_count + 2, u64, "delta list temp", result = vdo_allocate(list_count + 2, u64, "delta list temp",
&delta_zone->new_offsets); &delta_zone->new_offsets);
if (result != UDS_SUCCESS) if (result != VDO_SUCCESS)
return result; return result;
/* Allocate the delta lists. */ /* Allocate the delta lists. */
result = vdo_allocate(list_count + 2, struct delta_list, "delta lists", result = vdo_allocate(list_count + 2, struct delta_list, "delta lists",
&delta_zone->delta_lists); &delta_zone->delta_lists);
if (result != UDS_SUCCESS) if (result != VDO_SUCCESS)
return result; return result;
compute_coding_constants(mean_delta, &delta_zone->min_bits, compute_coding_constants(mean_delta, &delta_zone->min_bits,
...@@ -354,7 +354,7 @@ int uds_initialize_delta_index(struct delta_index *delta_index, unsigned int zon ...@@ -354,7 +354,7 @@ int uds_initialize_delta_index(struct delta_index *delta_index, unsigned int zon
result = vdo_allocate(zone_count, struct delta_zone, "Delta Index Zones", result = vdo_allocate(zone_count, struct delta_zone, "Delta Index Zones",
&delta_index->delta_zones); &delta_index->delta_zones);
if (result != UDS_SUCCESS) if (result != VDO_SUCCESS)
return result; return result;
delta_index->zone_count = zone_count; delta_index->zone_count = zone_count;
...@@ -1048,7 +1048,7 @@ int uds_finish_restoring_delta_index(struct delta_index *delta_index, ...@@ -1048,7 +1048,7 @@ int uds_finish_restoring_delta_index(struct delta_index *delta_index,
u8 *data; u8 *data;
result = vdo_allocate(DELTA_LIST_MAX_BYTE_COUNT, u8, __func__, &data); result = vdo_allocate(DELTA_LIST_MAX_BYTE_COUNT, u8, __func__, &data);
if (result != UDS_SUCCESS) if (result != VDO_SUCCESS)
return result; return result;
for (z = 0; z < reader_count; z++) { for (z = 0; z < reader_count; z++) {
......
...@@ -199,7 +199,7 @@ int uds_make_request_queue(const char *queue_name, ...@@ -199,7 +199,7 @@ int uds_make_request_queue(const char *queue_name,
struct uds_request_queue *queue; struct uds_request_queue *queue;
result = vdo_allocate(1, struct uds_request_queue, __func__, &queue); result = vdo_allocate(1, struct uds_request_queue, __func__, &queue);
if (result != UDS_SUCCESS) if (result != VDO_SUCCESS)
return result; return result;
queue->processor = processor; queue->processor = processor;
......
...@@ -62,7 +62,7 @@ int uds_make_index_geometry(size_t bytes_per_page, u32 record_pages_per_chapter, ...@@ -62,7 +62,7 @@ int uds_make_index_geometry(size_t bytes_per_page, u32 record_pages_per_chapter,
struct index_geometry *geometry; struct index_geometry *geometry;
result = vdo_allocate(1, struct index_geometry, "geometry", &geometry); result = vdo_allocate(1, struct index_geometry, "geometry", &geometry);
if (result != UDS_SUCCESS) if (result != VDO_SUCCESS)
return result; return result;
geometry->bytes_per_page = bytes_per_page; geometry->bytes_per_page = bytes_per_page;
......
...@@ -487,7 +487,7 @@ static int __must_check make_index_save_region_table(struct index_save_layout *i ...@@ -487,7 +487,7 @@ static int __must_check make_index_save_region_table(struct index_save_layout *i
result = vdo_allocate_extended(struct region_table, region_count, result = vdo_allocate_extended(struct region_table, region_count,
struct layout_region, struct layout_region,
"layout region table for ISL", &table); "layout region table for ISL", &table);
if (result != UDS_SUCCESS) if (result != VDO_SUCCESS)
return result; return result;
lr = &table->regions[0]; lr = &table->regions[0];
...@@ -546,7 +546,7 @@ static int __must_check write_index_save_header(struct index_save_layout *isl, ...@@ -546,7 +546,7 @@ static int __must_check write_index_save_header(struct index_save_layout *isl,
size_t offset = 0; size_t offset = 0;
result = vdo_allocate(table->encoded_size, u8, "index save data", &buffer); result = vdo_allocate(table->encoded_size, u8, "index save data", &buffer);
if (result != UDS_SUCCESS) if (result != VDO_SUCCESS)
return result; return result;
encode_region_table(buffer, &offset, table); encode_region_table(buffer, &offset, table);
...@@ -670,7 +670,7 @@ static int __must_check make_layout_region_table(struct index_layout *layout, ...@@ -670,7 +670,7 @@ static int __must_check make_layout_region_table(struct index_layout *layout,
result = vdo_allocate_extended(struct region_table, region_count, result = vdo_allocate_extended(struct region_table, region_count,
struct layout_region, "layout region table", struct layout_region, "layout region table",
&table); &table);
if (result != UDS_SUCCESS) if (result != VDO_SUCCESS)
return result; return result;
lr = &table->regions[0]; lr = &table->regions[0];
...@@ -716,7 +716,7 @@ static int __must_check write_layout_header(struct index_layout *layout, ...@@ -716,7 +716,7 @@ static int __must_check write_layout_header(struct index_layout *layout,
size_t offset = 0; size_t offset = 0;
result = vdo_allocate(table->encoded_size, u8, "layout data", &buffer); result = vdo_allocate(table->encoded_size, u8, "layout data", &buffer);
if (result != UDS_SUCCESS) if (result != VDO_SUCCESS)
return result; return result;
encode_region_table(buffer, &offset, table); encode_region_table(buffer, &offset, table);
...@@ -807,7 +807,7 @@ static int create_index_layout(struct index_layout *layout, struct uds_configura ...@@ -807,7 +807,7 @@ static int create_index_layout(struct index_layout *layout, struct uds_configura
result = vdo_allocate(sizes.save_count, struct index_save_layout, __func__, result = vdo_allocate(sizes.save_count, struct index_save_layout, __func__,
&layout->index.saves); &layout->index.saves);
if (result != UDS_SUCCESS) if (result != VDO_SUCCESS)
return result; return result;
initialize_layout(layout, &sizes); initialize_layout(layout, &sizes);
...@@ -1165,7 +1165,7 @@ static int __must_check load_region_table(struct buffered_reader *reader, ...@@ -1165,7 +1165,7 @@ static int __must_check load_region_table(struct buffered_reader *reader,
result = vdo_allocate_extended(struct region_table, header.region_count, result = vdo_allocate_extended(struct region_table, header.region_count,
struct layout_region, struct layout_region,
"single file layout region table", &table); "single file layout region table", &table);
if (result != UDS_SUCCESS) if (result != VDO_SUCCESS)
return result; return result;
table->header = header; table->header = header;
...@@ -1202,7 +1202,7 @@ static int __must_check read_super_block_data(struct buffered_reader *reader, ...@@ -1202,7 +1202,7 @@ static int __must_check read_super_block_data(struct buffered_reader *reader,
size_t offset = 0; size_t offset = 0;
result = vdo_allocate(saved_size, u8, "super block data", &buffer); result = vdo_allocate(saved_size, u8, "super block data", &buffer);
if (result != UDS_SUCCESS) if (result != VDO_SUCCESS)
return result; return result;
result = uds_read_from_buffered_reader(reader, buffer, saved_size); result = uds_read_from_buffered_reader(reader, buffer, saved_size);
...@@ -1337,7 +1337,7 @@ static int __must_check reconstitute_layout(struct index_layout *layout, ...@@ -1337,7 +1337,7 @@ static int __must_check reconstitute_layout(struct index_layout *layout,
result = vdo_allocate(layout->super.max_saves, struct index_save_layout, result = vdo_allocate(layout->super.max_saves, struct index_save_layout,
__func__, &layout->index.saves); __func__, &layout->index.saves);
if (result != UDS_SUCCESS) if (result != VDO_SUCCESS)
return result; return result;
layout->total_blocks = table->header.region_blocks; layout->total_blocks = table->header.region_blocks;
...@@ -1696,7 +1696,7 @@ int uds_make_index_layout(struct uds_configuration *config, bool new_layout, ...@@ -1696,7 +1696,7 @@ int uds_make_index_layout(struct uds_configuration *config, bool new_layout,
return result; return result;
result = vdo_allocate(1, struct index_layout, __func__, &layout); result = vdo_allocate(1, struct index_layout, __func__, &layout);
if (result != UDS_SUCCESS) if (result != VDO_SUCCESS)
return result; return result;
result = create_layout_factory(layout, config); result = create_layout_factory(layout, config);
......
...@@ -39,14 +39,14 @@ int uds_make_index_page_map(const struct index_geometry *geometry, ...@@ -39,14 +39,14 @@ int uds_make_index_page_map(const struct index_geometry *geometry,
struct index_page_map *map; struct index_page_map *map;
result = vdo_allocate(1, struct index_page_map, "page map", &map); result = vdo_allocate(1, struct index_page_map, "page map", &map);
if (result != UDS_SUCCESS) if (result != VDO_SUCCESS)
return result; return result;
map->geometry = geometry; map->geometry = geometry;
map->entries_per_chapter = geometry->index_pages_per_chapter - 1; 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), u16, "Index Page Map Entries",
&map->entries); &map->entries);
if (result != UDS_SUCCESS) { if (result != VDO_SUCCESS) {
uds_free_index_page_map(map); uds_free_index_page_map(map);
return result; return result;
} }
...@@ -119,7 +119,7 @@ int uds_write_index_page_map(struct index_page_map *map, struct buffered_writer ...@@ -119,7 +119,7 @@ int uds_write_index_page_map(struct index_page_map *map, struct buffered_writer
u32 i; u32 i;
result = vdo_allocate(saved_size, u8, "page map data", &buffer); result = vdo_allocate(saved_size, u8, "page map data", &buffer);
if (result != UDS_SUCCESS) if (result != VDO_SUCCESS)
return result; return result;
memcpy(buffer, PAGE_MAP_MAGIC, PAGE_MAP_MAGIC_LENGTH); memcpy(buffer, PAGE_MAP_MAGIC, PAGE_MAP_MAGIC_LENGTH);
...@@ -146,7 +146,7 @@ int uds_read_index_page_map(struct index_page_map *map, struct buffered_reader * ...@@ -146,7 +146,7 @@ int uds_read_index_page_map(struct index_page_map *map, struct buffered_reader *
u32 i; u32 i;
result = vdo_allocate(saved_size, u8, "page map data", &buffer); result = vdo_allocate(saved_size, u8, "page map data", &buffer);
if (result != UDS_SUCCESS) if (result != VDO_SUCCESS)
return result; return result;
result = uds_read_from_buffered_reader(reader, buffer, saved_size); result = uds_read_from_buffered_reader(reader, buffer, saved_size);
......
...@@ -222,7 +222,7 @@ static int __must_check make_empty_index_session(struct uds_index_session **inde ...@@ -222,7 +222,7 @@ static int __must_check make_empty_index_session(struct uds_index_session **inde
struct uds_index_session *session; struct uds_index_session *session;
result = vdo_allocate(1, struct uds_index_session, __func__, &session); result = vdo_allocate(1, struct uds_index_session, __func__, &session);
if (result != UDS_SUCCESS) if (result != VDO_SUCCESS)
return result; return result;
mutex_init(&session->request_mutex); mutex_init(&session->request_mutex);
......
...@@ -89,7 +89,7 @@ static int launch_zone_message(struct uds_zone_message message, unsigned int zon ...@@ -89,7 +89,7 @@ static int launch_zone_message(struct uds_zone_message message, unsigned int zon
struct uds_request *request; struct uds_request *request;
result = vdo_allocate(1, struct uds_request, __func__, &request); result = vdo_allocate(1, struct uds_request, __func__, &request);
if (result != UDS_SUCCESS) if (result != VDO_SUCCESS)
return result; return result;
request->index = index; request->index = index;
...@@ -770,7 +770,7 @@ static int make_chapter_writer(struct uds_index *index, ...@@ -770,7 +770,7 @@ static int make_chapter_writer(struct uds_index *index,
result = vdo_allocate_extended(struct chapter_writer, index->zone_count, result = vdo_allocate_extended(struct chapter_writer, index->zone_count,
struct open_chapter_zone *, "Chapter Writer", struct open_chapter_zone *, "Chapter Writer",
&writer); &writer);
if (result != UDS_SUCCESS) if (result != VDO_SUCCESS)
return result; return result;
writer->index = index; writer->index = index;
...@@ -779,7 +779,7 @@ static int make_chapter_writer(struct uds_index *index, ...@@ -779,7 +779,7 @@ static int make_chapter_writer(struct uds_index *index,
result = vdo_allocate_cache_aligned(collated_records_size, "collated records", result = vdo_allocate_cache_aligned(collated_records_size, "collated records",
&writer->collated_records); &writer->collated_records);
if (result != UDS_SUCCESS) { if (result != VDO_SUCCESS) {
free_chapter_writer(writer); free_chapter_writer(writer);
return result; return result;
} }
...@@ -1127,7 +1127,7 @@ static int make_index_zone(struct uds_index *index, unsigned int zone_number) ...@@ -1127,7 +1127,7 @@ static int make_index_zone(struct uds_index *index, unsigned int zone_number)
struct index_zone *zone; struct index_zone *zone;
result = vdo_allocate(1, struct index_zone, "index zone", &zone); result = vdo_allocate(1, struct index_zone, "index zone", &zone);
if (result != UDS_SUCCESS) if (result != VDO_SUCCESS)
return result; return result;
result = uds_make_open_chapter(index->volume->geometry, index->zone_count, result = uds_make_open_chapter(index->volume->geometry, index->zone_count,
...@@ -1165,7 +1165,7 @@ int uds_make_index(struct uds_configuration *config, enum uds_open_index_type op ...@@ -1165,7 +1165,7 @@ int uds_make_index(struct uds_configuration *config, enum uds_open_index_type op
result = vdo_allocate_extended(struct uds_index, config->zone_count, result = vdo_allocate_extended(struct uds_index, config->zone_count,
struct uds_request_queue *, "index", &index); struct uds_request_queue *, "index", &index);
if (result != UDS_SUCCESS) if (result != VDO_SUCCESS)
return result; return result;
index->zone_count = config->zone_count; index->zone_count = config->zone_count;
...@@ -1178,7 +1178,7 @@ int uds_make_index(struct uds_configuration *config, enum uds_open_index_type op ...@@ -1178,7 +1178,7 @@ int uds_make_index(struct uds_configuration *config, enum uds_open_index_type op
result = vdo_allocate(index->zone_count, struct index_zone *, "zones", result = vdo_allocate(index->zone_count, struct index_zone *, "zones",
&index->zones); &index->zones);
if (result != UDS_SUCCESS) { if (result != VDO_SUCCESS) {
uds_free_index(index); uds_free_index(index);
return result; return result;
} }
......
...@@ -65,7 +65,7 @@ int uds_make_io_factory(struct block_device *bdev, struct io_factory **factory_p ...@@ -65,7 +65,7 @@ int uds_make_io_factory(struct block_device *bdev, struct io_factory **factory_p
struct io_factory *factory; struct io_factory *factory;
result = vdo_allocate(1, struct io_factory, __func__, &factory); result = vdo_allocate(1, struct io_factory, __func__, &factory);
if (result != UDS_SUCCESS) if (result != VDO_SUCCESS)
return result; return result;
factory->bdev = bdev; factory->bdev = bdev;
...@@ -145,7 +145,7 @@ int uds_make_buffered_reader(struct io_factory *factory, off_t offset, u64 block ...@@ -145,7 +145,7 @@ int uds_make_buffered_reader(struct io_factory *factory, off_t offset, u64 block
return result; return result;
result = vdo_allocate(1, struct buffered_reader, "buffered reader", &reader); result = vdo_allocate(1, struct buffered_reader, "buffered reader", &reader);
if (result != UDS_SUCCESS) { if (result != VDO_SUCCESS) {
dm_bufio_client_destroy(client); dm_bufio_client_destroy(client);
return result; return result;
} }
...@@ -283,7 +283,7 @@ int uds_make_buffered_writer(struct io_factory *factory, off_t offset, u64 block ...@@ -283,7 +283,7 @@ int uds_make_buffered_writer(struct io_factory *factory, off_t offset, u64 block
return result; return result;
result = vdo_allocate(1, struct buffered_writer, "buffered writer", &writer); result = vdo_allocate(1, struct buffered_writer, "buffered writer", &writer);
if (result != UDS_SUCCESS) { if (result != VDO_SUCCESS) {
dm_bufio_client_destroy(client); dm_bufio_client_destroy(client);
return result; return result;
} }
......
...@@ -71,14 +71,14 @@ int uds_make_open_chapter(const struct index_geometry *geometry, unsigned int zo ...@@ -71,14 +71,14 @@ int uds_make_open_chapter(const struct index_geometry *geometry, unsigned int zo
result = vdo_allocate_extended(struct open_chapter_zone, slot_count, result = vdo_allocate_extended(struct open_chapter_zone, slot_count,
struct open_chapter_zone_slot, "open chapter", struct open_chapter_zone_slot, "open chapter",
&open_chapter); &open_chapter);
if (result != UDS_SUCCESS) if (result != VDO_SUCCESS)
return result; return result;
open_chapter->slot_count = slot_count; open_chapter->slot_count = slot_count;
open_chapter->capacity = capacity; open_chapter->capacity = capacity;
result = vdo_allocate_cache_aligned(records_size(open_chapter), "record pages", result = vdo_allocate_cache_aligned(records_size(open_chapter), "record pages",
&open_chapter->records); &open_chapter->records);
if (result != UDS_SUCCESS) { if (result != VDO_SUCCESS) {
uds_free_open_chapter(open_chapter); uds_free_open_chapter(open_chapter);
return result; return result;
} }
......
...@@ -213,7 +213,7 @@ int uds_make_radix_sorter(unsigned int count, struct radix_sorter **sorter) ...@@ -213,7 +213,7 @@ int uds_make_radix_sorter(unsigned int count, struct radix_sorter **sorter)
result = vdo_allocate_extended(struct radix_sorter, stack_size, struct task, result = vdo_allocate_extended(struct radix_sorter, stack_size, struct task,
__func__, &radix_sorter); __func__, &radix_sorter);
if (result != UDS_SUCCESS) if (result != VDO_SUCCESS)
return result; return result;
radix_sorter->count = count; radix_sorter->count = count;
......
...@@ -224,7 +224,7 @@ static int __must_check initialize_cached_chapter_index(struct cached_chapter_in ...@@ -224,7 +224,7 @@ static int __must_check initialize_cached_chapter_index(struct cached_chapter_in
result = vdo_allocate(chapter->index_pages_count, struct delta_index_page, result = vdo_allocate(chapter->index_pages_count, struct delta_index_page,
__func__, &chapter->index_pages); __func__, &chapter->index_pages);
if (result != UDS_SUCCESS) if (result != VDO_SUCCESS)
return result; return result;
return vdo_allocate(chapter->index_pages_count, struct dm_buffer *, return vdo_allocate(chapter->index_pages_count, struct dm_buffer *,
...@@ -242,7 +242,7 @@ static int __must_check make_search_list(struct sparse_cache *cache, ...@@ -242,7 +242,7 @@ static int __must_check make_search_list(struct sparse_cache *cache,
bytes = (sizeof(struct search_list) + bytes = (sizeof(struct search_list) +
(cache->capacity * sizeof(struct cached_chapter_index *))); (cache->capacity * sizeof(struct cached_chapter_index *)));
result = vdo_allocate_cache_aligned(bytes, "search list", &list); result = vdo_allocate_cache_aligned(bytes, "search list", &list);
if (result != UDS_SUCCESS) if (result != VDO_SUCCESS)
return result; return result;
list->capacity = cache->capacity; list->capacity = cache->capacity;
...@@ -265,7 +265,7 @@ int uds_make_sparse_cache(const struct index_geometry *geometry, unsigned int ca ...@@ -265,7 +265,7 @@ int uds_make_sparse_cache(const struct index_geometry *geometry, unsigned int ca
bytes = (sizeof(struct sparse_cache) + (capacity * sizeof(struct cached_chapter_index))); bytes = (sizeof(struct sparse_cache) + (capacity * sizeof(struct cached_chapter_index)));
result = vdo_allocate_cache_aligned(bytes, "sparse cache", &cache); result = vdo_allocate_cache_aligned(bytes, "sparse cache", &cache);
if (result != UDS_SUCCESS) if (result != VDO_SUCCESS)
return result; return result;
cache->geometry = geometry; cache->geometry = geometry;
...@@ -296,7 +296,7 @@ int uds_make_sparse_cache(const struct index_geometry *geometry, unsigned int ca ...@@ -296,7 +296,7 @@ int uds_make_sparse_cache(const struct index_geometry *geometry, unsigned int ca
/* purge_search_list() needs some temporary lists for sorting. */ /* purge_search_list() needs some temporary lists for sorting. */
result = vdo_allocate(capacity * 2, struct cached_chapter_index *, result = vdo_allocate(capacity * 2, struct cached_chapter_index *,
"scratch entries", &cache->scratch_entries); "scratch entries", &cache->scratch_entries);
if (result != UDS_SUCCESS) if (result != VDO_SUCCESS)
goto out; goto out;
*cache_ptr = cache; *cache_ptr = cache;
......
...@@ -1213,7 +1213,7 @@ static int initialize_volume_sub_index(const struct uds_configuration *config, ...@@ -1213,7 +1213,7 @@ static int initialize_volume_sub_index(const struct uds_configuration *config,
/* The following arrays are initialized to all zeros. */ /* 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, u64, "first chapter to flush",
&sub_index->flush_chapters); &sub_index->flush_chapters);
if (result != UDS_SUCCESS) if (result != VDO_SUCCESS)
return result; return result;
return vdo_allocate(zone_count, struct volume_sub_index_zone, return vdo_allocate(zone_count, struct volume_sub_index_zone,
...@@ -1229,7 +1229,7 @@ int uds_make_volume_index(const struct uds_configuration *config, u64 volume_non ...@@ -1229,7 +1229,7 @@ int uds_make_volume_index(const struct uds_configuration *config, u64 volume_non
int result; int result;
result = vdo_allocate(1, struct volume_index, "volume index", &volume_index); result = vdo_allocate(1, struct volume_index, "volume index", &volume_index);
if (result != UDS_SUCCESS) if (result != VDO_SUCCESS)
return result; return result;
volume_index->zone_count = config->zone_count; volume_index->zone_count = config->zone_count;
...@@ -1251,7 +1251,7 @@ int uds_make_volume_index(const struct uds_configuration *config, u64 volume_non ...@@ -1251,7 +1251,7 @@ int uds_make_volume_index(const struct uds_configuration *config, u64 volume_non
result = vdo_allocate(config->zone_count, struct volume_index_zone, result = vdo_allocate(config->zone_count, struct volume_index_zone,
"volume index zones", &volume_index->zones); "volume index zones", &volume_index->zones);
if (result != UDS_SUCCESS) { if (result != VDO_SUCCESS) {
uds_free_volume_index(volume_index); uds_free_volume_index(volume_index);
return result; return result;
} }
......
...@@ -1509,22 +1509,22 @@ static int __must_check initialize_page_cache(struct page_cache *cache, ...@@ -1509,22 +1509,22 @@ static int __must_check initialize_page_cache(struct page_cache *cache,
result = vdo_allocate(VOLUME_CACHE_MAX_QUEUED_READS, struct queued_read, result = vdo_allocate(VOLUME_CACHE_MAX_QUEUED_READS, struct queued_read,
"volume read queue", &cache->read_queue); "volume read queue", &cache->read_queue);
if (result != UDS_SUCCESS) if (result != VDO_SUCCESS)
return result; return result;
result = vdo_allocate(cache->zone_count, struct search_pending_counter, result = vdo_allocate(cache->zone_count, struct search_pending_counter,
"Volume Cache Zones", &cache->search_pending_counters); "Volume Cache Zones", &cache->search_pending_counters);
if (result != UDS_SUCCESS) if (result != VDO_SUCCESS)
return result; return result;
result = vdo_allocate(cache->indexable_pages, u16, "page cache index", result = vdo_allocate(cache->indexable_pages, u16, "page cache index",
&cache->index); &cache->index);
if (result != UDS_SUCCESS) if (result != VDO_SUCCESS)
return result; return result;
result = vdo_allocate(cache->cache_slots, struct cached_page, "page cache cache", result = vdo_allocate(cache->cache_slots, struct cached_page, "page cache cache",
&cache->cache); &cache->cache);
if (result != UDS_SUCCESS) if (result != VDO_SUCCESS)
return result; return result;
/* Initialize index values to invalid values. */ /* Initialize index values to invalid values. */
...@@ -1547,7 +1547,7 @@ int uds_make_volume(const struct uds_configuration *config, struct index_layout ...@@ -1547,7 +1547,7 @@ int uds_make_volume(const struct uds_configuration *config, struct index_layout
int result; int result;
result = vdo_allocate(1, struct volume, "volume", &volume); result = vdo_allocate(1, struct volume, "volume", &volume);
if (result != UDS_SUCCESS) if (result != VDO_SUCCESS)
return result; return result;
volume->nonce = uds_get_volume_nonce(layout); volume->nonce = uds_get_volume_nonce(layout);
...@@ -1586,7 +1586,7 @@ int uds_make_volume(const struct uds_configuration *config, struct index_layout ...@@ -1586,7 +1586,7 @@ int uds_make_volume(const struct uds_configuration *config, struct index_layout
result = vdo_allocate(geometry->records_per_page, result = vdo_allocate(geometry->records_per_page,
const struct uds_volume_record *, "record pointers", const struct uds_volume_record *, "record pointers",
&volume->record_pointers); &volume->record_pointers);
if (result != UDS_SUCCESS) { if (result != VDO_SUCCESS) {
uds_free_volume(volume); uds_free_volume(volume);
return result; return result;
} }
...@@ -1626,7 +1626,7 @@ int uds_make_volume(const struct uds_configuration *config, struct index_layout ...@@ -1626,7 +1626,7 @@ int uds_make_volume(const struct uds_configuration *config, struct index_layout
result = vdo_allocate(config->read_threads, struct thread *, "reader threads", result = vdo_allocate(config->read_threads, struct thread *, "reader threads",
&volume->reader_threads); &volume->reader_threads);
if (result != UDS_SUCCESS) { if (result != VDO_SUCCESS) {
uds_free_volume(volume); uds_free_volume(volume);
return result; return result;
} }
......
...@@ -152,7 +152,7 @@ static u64 hash_key(u64 key) ...@@ -152,7 +152,7 @@ static u64 hash_key(u64 key)
* @map: The map to initialize. * @map: The map to initialize.
* @capacity: The initial capacity of the map. * @capacity: The initial capacity of the map.
* *
* Return: UDS_SUCCESS or an error code. * Return: VDO_SUCCESS or an error code.
*/ */
static int allocate_buckets(struct int_map *map, size_t capacity) static int allocate_buckets(struct int_map *map, size_t capacity)
{ {
...@@ -174,7 +174,7 @@ static int allocate_buckets(struct int_map *map, size_t capacity) ...@@ -174,7 +174,7 @@ static int allocate_buckets(struct int_map *map, size_t capacity)
* tells the map to use its own small default). * tells the map to use its own small default).
* @map_ptr: Output, a pointer to hold the new int_map. * @map_ptr: Output, a pointer to hold the new int_map.
* *
* Return: UDS_SUCCESS or an error code. * Return: VDO_SUCCESS or an error code.
*/ */
int vdo_int_map_create(size_t initial_capacity, struct int_map **map_ptr) int vdo_int_map_create(size_t initial_capacity, struct int_map **map_ptr)
{ {
...@@ -183,7 +183,7 @@ int vdo_int_map_create(size_t initial_capacity, struct int_map **map_ptr) ...@@ -183,7 +183,7 @@ int vdo_int_map_create(size_t initial_capacity, struct int_map **map_ptr)
size_t capacity; size_t capacity;
result = vdo_allocate(1, struct int_map, "struct int_map", &map); result = vdo_allocate(1, struct int_map, "struct int_map", &map);
if (result != UDS_SUCCESS) if (result != VDO_SUCCESS)
return result; return result;
/* Use the default capacity if the caller did not specify one. */ /* Use the default capacity if the caller did not specify one. */
...@@ -196,13 +196,13 @@ int vdo_int_map_create(size_t initial_capacity, struct int_map **map_ptr) ...@@ -196,13 +196,13 @@ int vdo_int_map_create(size_t initial_capacity, struct int_map **map_ptr)
capacity = capacity * 100 / DEFAULT_LOAD; capacity = capacity * 100 / DEFAULT_LOAD;
result = allocate_buckets(map, capacity); result = allocate_buckets(map, capacity);
if (result != UDS_SUCCESS) { if (result != VDO_SUCCESS) {
vdo_int_map_free(vdo_forget(map)); vdo_int_map_free(vdo_forget(map));
return result; return result;
} }
*map_ptr = map; *map_ptr = map;
return UDS_SUCCESS; return VDO_SUCCESS;
} }
/** /**
...@@ -368,7 +368,7 @@ void *vdo_int_map_get(struct int_map *map, u64 key) ...@@ -368,7 +368,7 @@ void *vdo_int_map_get(struct int_map *map, u64 key)
* *
* Resizes and rehashes all the existing entries, storing them in the new buckets. * Resizes and rehashes all the existing entries, storing them in the new buckets.
* *
* Return: UDS_SUCCESS or an error code. * Return: VDO_SUCCESS or an error code.
*/ */
static int resize_buckets(struct int_map *map) static int resize_buckets(struct int_map *map)
{ {
...@@ -384,7 +384,7 @@ static int resize_buckets(struct int_map *map) ...@@ -384,7 +384,7 @@ static int resize_buckets(struct int_map *map)
uds_log_info("%s: attempting resize from %zu to %zu, current size=%zu", uds_log_info("%s: attempting resize from %zu to %zu, current size=%zu",
__func__, map->capacity, new_capacity, map->size); __func__, map->capacity, new_capacity, map->size);
result = allocate_buckets(map, new_capacity); result = allocate_buckets(map, new_capacity);
if (result != UDS_SUCCESS) { if (result != VDO_SUCCESS) {
*map = old_map; *map = old_map;
return result; return result;
} }
...@@ -407,7 +407,7 @@ static int resize_buckets(struct int_map *map) ...@@ -407,7 +407,7 @@ static int resize_buckets(struct int_map *map)
/* Destroy the old bucket array. */ /* Destroy the old bucket array. */
vdo_free(vdo_forget(old_map.buckets)); vdo_free(vdo_forget(old_map.buckets));
return UDS_SUCCESS; return VDO_SUCCESS;
} }
/** /**
...@@ -647,7 +647,7 @@ int vdo_int_map_put(struct int_map *map, u64 key, void *new_value, bool update, ...@@ -647,7 +647,7 @@ int vdo_int_map_put(struct int_map *map, u64 key, void *new_value, bool update,
* large maps). * large maps).
*/ */
result = resize_buckets(map); result = resize_buckets(map);
if (result != UDS_SUCCESS) if (result != VDO_SUCCESS)
return result; return result;
/* /*
......
...@@ -383,7 +383,7 @@ int vdo_make_io_submitter(unsigned int thread_count, unsigned int rotation_inter ...@@ -383,7 +383,7 @@ int vdo_make_io_submitter(unsigned int thread_count, unsigned int rotation_inter
result = vdo_allocate_extended(struct io_submitter, thread_count, result = vdo_allocate_extended(struct io_submitter, thread_count,
struct bio_queue_data, "bio submission data", struct bio_queue_data, "bio submission data",
&io_submitter); &io_submitter);
if (result != UDS_SUCCESS) if (result != VDO_SUCCESS)
return result; return result;
io_submitter->bio_queue_rotation_interval = rotation_interval; io_submitter->bio_queue_rotation_interval = rotation_interval;
......
...@@ -420,7 +420,7 @@ int vdo_write_stats(struct vdo *vdo, char *buf, unsigned int maxlen) ...@@ -420,7 +420,7 @@ int vdo_write_stats(struct vdo *vdo, char *buf, unsigned int maxlen)
int result; int result;
result = vdo_allocate(1, struct vdo_statistics, __func__, &stats); result = vdo_allocate(1, struct vdo_statistics, __func__, &stats);
if (result != UDS_SUCCESS) { if (result != VDO_SUCCESS) {
uds_log_error("Cannot allocate memory to write VDO statistics"); uds_log_error("Cannot allocate memory to write VDO statistics");
return result; return result;
} }
......
...@@ -2379,7 +2379,7 @@ static int allocate_slab_counters(struct vdo_slab *slab) ...@@ -2379,7 +2379,7 @@ static int allocate_slab_counters(struct vdo_slab *slab)
bytes = (slab->reference_block_count * COUNTS_PER_BLOCK) + (2 * BYTES_PER_WORD); bytes = (slab->reference_block_count * COUNTS_PER_BLOCK) + (2 * BYTES_PER_WORD);
result = vdo_allocate(bytes, vdo_refcount_t, "ref counts array", result = vdo_allocate(bytes, vdo_refcount_t, "ref counts array",
&slab->counters); &slab->counters);
if (result != UDS_SUCCESS) { if (result != VDO_SUCCESS) {
vdo_free(vdo_forget(slab->reference_blocks)); vdo_free(vdo_forget(slab->reference_blocks));
return result; return result;
} }
......
...@@ -83,7 +83,7 @@ int vdo_create_thread(void (*thread_function)(void *), void *thread_data, ...@@ -83,7 +83,7 @@ int vdo_create_thread(void (*thread_function)(void *), void *thread_data,
int result; int result;
result = vdo_allocate(1, struct thread, __func__, &thread); result = vdo_allocate(1, struct thread, __func__, &thread);
if (result != UDS_SUCCESS) { if (result != VDO_SUCCESS) {
uds_log_warning("Error allocating memory for %s", name); uds_log_warning("Error allocating memory for %s", name);
return result; return result;
} }
......
...@@ -35,7 +35,7 @@ static char *buffer_to_string(const char *buf, size_t length) ...@@ -35,7 +35,7 @@ static char *buffer_to_string(const char *buf, size_t length)
{ {
char *string; char *string;
if (vdo_allocate(length + 1, char, __func__, &string) != UDS_SUCCESS) if (vdo_allocate(length + 1, char, __func__, &string) != VDO_SUCCESS)
return NULL; return NULL;
memcpy(string, buf, length); memcpy(string, buf, length);
......
...@@ -545,7 +545,7 @@ int vdo_make(unsigned int instance, struct device_config *config, char **reason, ...@@ -545,7 +545,7 @@ int vdo_make(unsigned int instance, struct device_config *config, char **reason,
*reason = "Unspecified error"; *reason = "Unspecified error";
result = vdo_allocate(1, struct vdo, __func__, &vdo); result = vdo_allocate(1, struct vdo, __func__, &vdo);
if (result != UDS_SUCCESS) { if (result != VDO_SUCCESS) {
*reason = "Cannot allocate VDO"; *reason = "Cannot allocate VDO";
return result; return result;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment