Skip to content

Commit

Permalink
dm vdo indexer: update ASSERT and ASSERT_LOG_ONLY usage
Browse files Browse the repository at this point in the history
Update indexer uses of ASSERT and ASSERT_LOG_ONLY to
VDO_ASSERT and VDO_ASSERT_LOG_ONLY, respectively. Remove
ASSERT and ASSERT_LOG_ONLY. Also rename uds_assertion_failed
to vdo_assertion_failed.

Signed-off-by: Matthew Sakai <[email protected]>
  • Loading branch information
lorelei-sakai committed Feb 28, 2024
1 parent b3eece5 commit 69b67eb
Show file tree
Hide file tree
Showing 10 changed files with 107 additions and 110 deletions.
16 changes: 8 additions & 8 deletions drivers/md/dm-vdo/indexer/chapter-index.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ int uds_put_open_chapter_index_record(struct open_chapter_index *chapter_index,
u64 chapter_number = chapter_index->virtual_chapter_number;
u32 record_pages = geometry->record_pages_per_chapter;

result = ASSERT(page_number < record_pages,
"Page number within chapter (%u) exceeds the maximum value %u",
page_number, record_pages);
if (result != UDS_SUCCESS)
result = VDO_ASSERT(page_number < record_pages,
"Page number within chapter (%u) exceeds the maximum value %u",
page_number, record_pages);
if (result != VDO_SUCCESS)
return UDS_INVALID_ARGUMENT;

address = uds_hash_to_chapter_delta_address(name, geometry);
Expand All @@ -97,10 +97,10 @@ int uds_put_open_chapter_index_record(struct open_chapter_index *chapter_index,
return result;

found = was_entry_found(&entry, address);
result = ASSERT(!(found && entry.is_collision),
"Chunk appears more than once in chapter %llu",
(unsigned long long) chapter_number);
if (result != UDS_SUCCESS)
result = VDO_ASSERT(!(found && entry.is_collision),
"Chunk appears more than once in chapter %llu",
(unsigned long long) chapter_number);
if (result != VDO_SUCCESS)
return UDS_BAD_STATE;

found_name = (found ? name->name : NULL);
Expand Down
16 changes: 8 additions & 8 deletions drivers/md/dm-vdo/indexer/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,10 @@ int uds_validate_config_contents(struct buffered_reader *reader,
decode_u32_le(buffer, &offset, &config.sparse_sample_rate);
decode_u64_le(buffer, &offset, &config.nonce);

result = ASSERT(offset == sizeof(struct uds_configuration_6_02),
"%zu bytes read but not decoded",
sizeof(struct uds_configuration_6_02) - offset);
if (result != UDS_SUCCESS)
result = VDO_ASSERT(offset == sizeof(struct uds_configuration_6_02),
"%zu bytes read but not decoded",
sizeof(struct uds_configuration_6_02) - offset);
if (result != VDO_SUCCESS)
return UDS_CORRUPT_DATA;

if (is_version(INDEX_CONFIG_VERSION_6_02, version_buffer)) {
Expand Down Expand Up @@ -210,10 +210,10 @@ int uds_write_config_contents(struct buffered_writer *writer,
encode_u32_le(buffer, &offset, config->sparse_sample_rate);
encode_u64_le(buffer, &offset, config->nonce);

result = ASSERT(offset == sizeof(struct uds_configuration_6_02),
"%zu bytes encoded, of %zu expected", offset,
sizeof(struct uds_configuration_6_02));
if (result != UDS_SUCCESS)
result = VDO_ASSERT(offset == sizeof(struct uds_configuration_6_02),
"%zu bytes encoded, of %zu expected", offset,
sizeof(struct uds_configuration_6_02));
if (result != VDO_SUCCESS)
return result;

if (version >= 4) {
Expand Down
90 changes: 45 additions & 45 deletions drivers/md/dm-vdo/indexer/delta-index.c
Original file line number Diff line number Diff line change
Expand Up @@ -856,10 +856,10 @@ int uds_start_restoring_delta_index(struct delta_index *delta_index,
decode_u64_le(buffer, &offset, &header.record_count);
decode_u64_le(buffer, &offset, &header.collision_count);

result = ASSERT(offset == sizeof(struct delta_index_header),
"%zu bytes decoded of %zu expected", offset,
sizeof(struct delta_index_header));
if (result != UDS_SUCCESS) {
result = VDO_ASSERT(offset == sizeof(struct delta_index_header),
"%zu bytes decoded of %zu expected", offset,
sizeof(struct delta_index_header));
if (result != VDO_SUCCESS) {
return uds_log_warning_strerror(result,
"failed to read delta index header");
}
Expand Down Expand Up @@ -1136,10 +1136,10 @@ int uds_start_saving_delta_index(const struct delta_index *delta_index,
encode_u64_le(buffer, &offset, delta_zone->record_count);
encode_u64_le(buffer, &offset, delta_zone->collision_count);

result = ASSERT(offset == sizeof(struct delta_index_header),
"%zu bytes encoded of %zu expected", offset,
sizeof(struct delta_index_header));
if (result != UDS_SUCCESS)
result = VDO_ASSERT(offset == sizeof(struct delta_index_header),
"%zu bytes encoded of %zu expected", offset,
sizeof(struct delta_index_header));
if (result != VDO_SUCCESS)
return result;

result = uds_write_to_buffered_writer(buffered_writer, buffer, offset);
Expand Down Expand Up @@ -1212,9 +1212,9 @@ size_t uds_compute_delta_index_save_bytes(u32 list_count, size_t memory_size)

static int assert_not_at_end(const struct delta_index_entry *delta_entry)
{
int result = ASSERT(!delta_entry->at_end,
"operation is invalid because the list entry is at the end of the delta list");
if (result != UDS_SUCCESS)
int result = VDO_ASSERT(!delta_entry->at_end,
"operation is invalid because the list entry is at the end of the delta list");
if (result != VDO_SUCCESS)
result = UDS_BAD_STATE;

return result;
Expand All @@ -1236,19 +1236,19 @@ int uds_start_delta_index_search(const struct delta_index *delta_index, u32 list
struct delta_zone *delta_zone;
struct delta_list *delta_list;

result = ASSERT((list_number < delta_index->list_count),
"Delta list number (%u) is out of range (%u)", list_number,
delta_index->list_count);
if (result != UDS_SUCCESS)
result = VDO_ASSERT((list_number < delta_index->list_count),
"Delta list number (%u) is out of range (%u)", list_number,
delta_index->list_count);
if (result != VDO_SUCCESS)
return UDS_CORRUPT_DATA;

zone_number = list_number / delta_index->lists_per_zone;
delta_zone = &delta_index->delta_zones[zone_number];
list_number -= delta_zone->first_list;
result = ASSERT((list_number < delta_zone->list_count),
"Delta list number (%u) is out of range (%u) for zone (%u)",
list_number, delta_zone->list_count, zone_number);
if (result != UDS_SUCCESS)
result = VDO_ASSERT((list_number < delta_zone->list_count),
"Delta list number (%u) is out of range (%u) for zone (%u)",
list_number, delta_zone->list_count, zone_number);
if (result != VDO_SUCCESS)
return UDS_CORRUPT_DATA;

if (delta_index->mutable) {
Expand Down Expand Up @@ -1362,9 +1362,9 @@ noinline int uds_next_delta_index_entry(struct delta_index_entry *delta_entry)
delta_entry->at_end = true;
delta_entry->delta = 0;
delta_entry->is_collision = false;
result = ASSERT((delta_entry->offset == size),
"next offset past end of delta list");
if (result != UDS_SUCCESS)
result = VDO_ASSERT((delta_entry->offset == size),
"next offset past end of delta list");
if (result != VDO_SUCCESS)
result = UDS_CORRUPT_DATA;

return result;
Expand All @@ -1390,8 +1390,8 @@ int uds_remember_delta_index_offset(const struct delta_index_entry *delta_entry)
int result;
struct delta_list *delta_list = delta_entry->delta_list;

result = ASSERT(!delta_entry->is_collision, "entry is not a collision");
if (result != UDS_SUCCESS)
result = VDO_ASSERT(!delta_entry->is_collision, "entry is not a collision");
if (result != VDO_SUCCESS)
return result;

delta_list->save_key = delta_entry->key - delta_entry->delta;
Expand Down Expand Up @@ -1489,9 +1489,9 @@ int uds_get_delta_entry_collision(const struct delta_index_entry *delta_entry, u
if (result != UDS_SUCCESS)
return result;

result = ASSERT(delta_entry->is_collision,
"Cannot get full block name from a non-collision delta index entry");
if (result != UDS_SUCCESS)
result = VDO_ASSERT(delta_entry->is_collision,
"Cannot get full block name from a non-collision delta index entry");
if (result != VDO_SUCCESS)
return UDS_BAD_STATE;

get_collision_name(delta_entry, name);
Expand All @@ -1506,9 +1506,9 @@ u32 uds_get_delta_entry_value(const struct delta_index_entry *delta_entry)

static int assert_mutable_entry(const struct delta_index_entry *delta_entry)
{
int result = ASSERT((delta_entry->delta_list != &delta_entry->temp_delta_list),
"delta index is mutable");
if (result != UDS_SUCCESS)
int result = VDO_ASSERT((delta_entry->delta_list != &delta_entry->temp_delta_list),
"delta index is mutable");
if (result != VDO_SUCCESS)
result = UDS_BAD_STATE;

return result;
Expand All @@ -1527,10 +1527,10 @@ int uds_set_delta_entry_value(const struct delta_index_entry *delta_entry, u32 v
if (result != UDS_SUCCESS)
return result;

result = ASSERT((value & value_mask) == value,
"Value (%u) being set in a delta index is too large (must fit in %u bits)",
value, delta_entry->value_bits);
if (result != UDS_SUCCESS)
result = VDO_ASSERT((value & value_mask) == value,
"Value (%u) being set in a delta index is too large (must fit in %u bits)",
value, delta_entry->value_bits);
if (result != VDO_SUCCESS)
return UDS_INVALID_ARGUMENT;

set_field(value, delta_entry->delta_zone->memory,
Expand Down Expand Up @@ -1730,9 +1730,9 @@ int uds_put_delta_index_entry(struct delta_index_entry *delta_entry, u32 key, u3
if (result != UDS_SUCCESS)
return result;

result = ASSERT((key == delta_entry->key),
"incorrect key for collision entry");
if (result != UDS_SUCCESS)
result = VDO_ASSERT((key == delta_entry->key),
"incorrect key for collision entry");
if (result != VDO_SUCCESS)
return result;

delta_entry->offset += delta_entry->entry_bits;
Expand All @@ -1742,8 +1742,8 @@ int uds_put_delta_index_entry(struct delta_index_entry *delta_entry, u32 key, u3
result = insert_bits(delta_entry, delta_entry->entry_bits);
} else if (delta_entry->at_end) {
/* Insert a new entry at the end of the delta list. */
result = ASSERT((key >= delta_entry->key), "key past end of list");
if (result != UDS_SUCCESS)
result = VDO_ASSERT((key >= delta_entry->key), "key past end of list");
if (result != VDO_SUCCESS)
return result;

set_delta(delta_entry, key - delta_entry->key);
Expand All @@ -1760,14 +1760,14 @@ int uds_put_delta_index_entry(struct delta_index_entry *delta_entry, u32 key, u3
* Insert a new entry which requires the delta in the following entry to be
* updated.
*/
result = ASSERT((key < delta_entry->key),
"key precedes following entry");
if (result != UDS_SUCCESS)
result = VDO_ASSERT((key < delta_entry->key),
"key precedes following entry");
if (result != VDO_SUCCESS)
return result;

result = ASSERT((key >= delta_entry->key - delta_entry->delta),
"key effects following entry's delta");
if (result != UDS_SUCCESS)
result = VDO_ASSERT((key >= delta_entry->key - delta_entry->delta),
"key effects following entry's delta");
if (result != VDO_SUCCESS)
return result;

old_entry_size = delta_entry->entry_bits;
Expand Down
5 changes: 3 additions & 2 deletions drivers/md/dm-vdo/indexer/index-layout.c
Original file line number Diff line number Diff line change
Expand Up @@ -837,8 +837,9 @@ static u64 generate_index_save_nonce(u64 volume_nonce, struct index_save_layout
encode_u32_le(buffer, &offset, isl->save_data.version);
encode_u32_le(buffer, &offset, 0U);
encode_u64_le(buffer, &offset, isl->index_save.start_block);
ASSERT_LOG_ONLY(offset == sizeof(nonce_data),
"%zu bytes encoded of %zu expected", offset, sizeof(nonce_data));
VDO_ASSERT_LOG_ONLY(offset == sizeof(nonce_data),
"%zu bytes encoded of %zu expected",
offset, sizeof(nonce_data));
return generate_secondary_nonce(volume_nonce, buffer, sizeof(buffer));
}

Expand Down
12 changes: 6 additions & 6 deletions drivers/md/dm-vdo/indexer/index-session.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ static void update_session_stats(struct uds_request *request)
break;

default:
request->status = ASSERT(false, "unknown request type: %d",
request->type);
request->status = VDO_ASSERT(false, "unknown request type: %d",
request->type);
}
}

Expand Down Expand Up @@ -402,8 +402,8 @@ static void suspend_rebuild(struct uds_index_session *session)
case INDEX_FREEING:
default:
/* These cases should not happen. */
ASSERT_LOG_ONLY(false, "Bad load context state %u",
session->load_context.status);
VDO_ASSERT_LOG_ONLY(false, "Bad load context state %u",
session->load_context.status);
break;
}
mutex_unlock(&session->load_context.mutex);
Expand Down Expand Up @@ -531,8 +531,8 @@ int uds_resume_index_session(struct uds_index_session *session,
case INDEX_FREEING:
default:
/* These cases should not happen; do nothing. */
ASSERT_LOG_ONLY(false, "Bad load context state %u",
session->load_context.status);
VDO_ASSERT_LOG_ONLY(false, "Bad load context state %u",
session->load_context.status);
break;
}
mutex_unlock(&session->load_context.mutex);
Expand Down
4 changes: 2 additions & 2 deletions drivers/md/dm-vdo/indexer/index.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ static void enqueue_barrier_messages(struct uds_index *index, u64 virtual_chapte
for (zone = 0; zone < index->zone_count; zone++) {
int result = launch_zone_message(message, zone, index);

ASSERT_LOG_ONLY((result == UDS_SUCCESS), "barrier message allocation");
VDO_ASSERT_LOG_ONLY((result == UDS_SUCCESS), "barrier message allocation");
}
}

Expand Down Expand Up @@ -1380,7 +1380,7 @@ void uds_enqueue_request(struct uds_request *request, enum request_stage stage)
break;

default:
ASSERT_LOG_ONLY(false, "invalid index stage: %d", stage);
VDO_ASSERT_LOG_ONLY(false, "invalid index stage: %d", stage);
return;
}

Expand Down
32 changes: 16 additions & 16 deletions drivers/md/dm-vdo/indexer/volume-index.c
Original file line number Diff line number Diff line change
Expand Up @@ -832,10 +832,10 @@ static int start_restoring_volume_sub_index(struct volume_sub_index *sub_index,
decode_u32_le(buffer, &offset, &header.first_list);
decode_u32_le(buffer, &offset, &header.list_count);

result = ASSERT(offset == sizeof(buffer),
"%zu bytes decoded of %zu expected", offset,
sizeof(buffer));
if (result != UDS_SUCCESS)
result = VDO_ASSERT(offset == sizeof(buffer),
"%zu bytes decoded of %zu expected", offset,
sizeof(buffer));
if (result != VDO_SUCCESS)
result = UDS_CORRUPT_DATA;

if (memcmp(header.magic, MAGIC_START_5, MAGIC_SIZE) != 0) {
Expand Down Expand Up @@ -924,10 +924,10 @@ static int start_restoring_volume_index(struct volume_index *volume_index,
offset += MAGIC_SIZE;
decode_u32_le(buffer, &offset, &header.sparse_sample_rate);

result = ASSERT(offset == sizeof(buffer),
"%zu bytes decoded of %zu expected", offset,
sizeof(buffer));
if (result != UDS_SUCCESS)
result = VDO_ASSERT(offset == sizeof(buffer),
"%zu bytes decoded of %zu expected", offset,
sizeof(buffer));
if (result != VDO_SUCCESS)
result = UDS_CORRUPT_DATA;

if (memcmp(header.magic, MAGIC_START_6, MAGIC_SIZE) != 0)
Expand Down Expand Up @@ -1023,10 +1023,10 @@ static int start_saving_volume_sub_index(const struct volume_sub_index *sub_inde
encode_u32_le(buffer, &offset, first_list);
encode_u32_le(buffer, &offset, list_count);

result = ASSERT(offset == sizeof(struct sub_index_data),
"%zu bytes of config written, of %zu expected", offset,
sizeof(struct sub_index_data));
if (result != UDS_SUCCESS)
result = VDO_ASSERT(offset == sizeof(struct sub_index_data),
"%zu bytes of config written, of %zu expected", offset,
sizeof(struct sub_index_data));
if (result != VDO_SUCCESS)
return result;

result = uds_write_to_buffered_writer(buffered_writer, buffer, offset);
Expand Down Expand Up @@ -1066,10 +1066,10 @@ static int start_saving_volume_index(const struct volume_index *volume_index,
memcpy(buffer, MAGIC_START_6, MAGIC_SIZE);
offset += MAGIC_SIZE;
encode_u32_le(buffer, &offset, volume_index->sparse_sample_rate);
result = ASSERT(offset == sizeof(struct volume_index_data),
"%zu bytes of header written, of %zu expected", offset,
sizeof(struct volume_index_data));
if (result != UDS_SUCCESS)
result = VDO_ASSERT(offset == sizeof(struct volume_index_data),
"%zu bytes of header written, of %zu expected", offset,
sizeof(struct volume_index_data));
if (result != VDO_SUCCESS)
return result;

result = uds_write_to_buffered_writer(writer, buffer, offset);
Expand Down
Loading

0 comments on commit 69b67eb

Please sign in to comment.