Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

dm vdo indexer: update ASSERT and ASSERT_LOG_ONLY usage

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 <msakai@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>

authored by

Matthew Sakai and committed by
Mike Snitzer
e6016736 fc03f737

+107 -110
+8 -8
drivers/md/dm-vdo/indexer/chapter-index.c
··· 83 83 u64 chapter_number = chapter_index->virtual_chapter_number; 84 84 u32 record_pages = geometry->record_pages_per_chapter; 85 85 86 - result = ASSERT(page_number < record_pages, 87 - "Page number within chapter (%u) exceeds the maximum value %u", 88 - page_number, record_pages); 89 - if (result != UDS_SUCCESS) 86 + result = VDO_ASSERT(page_number < record_pages, 87 + "Page number within chapter (%u) exceeds the maximum value %u", 88 + page_number, record_pages); 89 + if (result != VDO_SUCCESS) 90 90 return UDS_INVALID_ARGUMENT; 91 91 92 92 address = uds_hash_to_chapter_delta_address(name, geometry); ··· 97 97 return result; 98 98 99 99 found = was_entry_found(&entry, address); 100 - result = ASSERT(!(found && entry.is_collision), 101 - "Chunk appears more than once in chapter %llu", 102 - (unsigned long long) chapter_number); 103 - if (result != UDS_SUCCESS) 100 + result = VDO_ASSERT(!(found && entry.is_collision), 101 + "Chunk appears more than once in chapter %llu", 102 + (unsigned long long) chapter_number); 103 + if (result != VDO_SUCCESS) 104 104 return UDS_BAD_STATE; 105 105 106 106 found_name = (found ? name->name : NULL);
+8 -8
drivers/md/dm-vdo/indexer/config.c
··· 134 134 decode_u32_le(buffer, &offset, &config.sparse_sample_rate); 135 135 decode_u64_le(buffer, &offset, &config.nonce); 136 136 137 - result = ASSERT(offset == sizeof(struct uds_configuration_6_02), 138 - "%zu bytes read but not decoded", 139 - sizeof(struct uds_configuration_6_02) - offset); 140 - if (result != UDS_SUCCESS) 137 + result = VDO_ASSERT(offset == sizeof(struct uds_configuration_6_02), 138 + "%zu bytes read but not decoded", 139 + sizeof(struct uds_configuration_6_02) - offset); 140 + if (result != VDO_SUCCESS) 141 141 return UDS_CORRUPT_DATA; 142 142 143 143 if (is_version(INDEX_CONFIG_VERSION_6_02, version_buffer)) { ··· 210 210 encode_u32_le(buffer, &offset, config->sparse_sample_rate); 211 211 encode_u64_le(buffer, &offset, config->nonce); 212 212 213 - result = ASSERT(offset == sizeof(struct uds_configuration_6_02), 214 - "%zu bytes encoded, of %zu expected", offset, 215 - sizeof(struct uds_configuration_6_02)); 216 - if (result != UDS_SUCCESS) 213 + result = VDO_ASSERT(offset == sizeof(struct uds_configuration_6_02), 214 + "%zu bytes encoded, of %zu expected", offset, 215 + sizeof(struct uds_configuration_6_02)); 216 + if (result != VDO_SUCCESS) 217 217 return result; 218 218 219 219 if (version >= 4) {
+45 -45
drivers/md/dm-vdo/indexer/delta-index.c
··· 856 856 decode_u64_le(buffer, &offset, &header.record_count); 857 857 decode_u64_le(buffer, &offset, &header.collision_count); 858 858 859 - result = ASSERT(offset == sizeof(struct delta_index_header), 860 - "%zu bytes decoded of %zu expected", offset, 861 - sizeof(struct delta_index_header)); 862 - if (result != UDS_SUCCESS) { 859 + result = VDO_ASSERT(offset == sizeof(struct delta_index_header), 860 + "%zu bytes decoded of %zu expected", offset, 861 + sizeof(struct delta_index_header)); 862 + if (result != VDO_SUCCESS) { 863 863 return uds_log_warning_strerror(result, 864 864 "failed to read delta index header"); 865 865 } ··· 1136 1136 encode_u64_le(buffer, &offset, delta_zone->record_count); 1137 1137 encode_u64_le(buffer, &offset, delta_zone->collision_count); 1138 1138 1139 - result = ASSERT(offset == sizeof(struct delta_index_header), 1140 - "%zu bytes encoded of %zu expected", offset, 1141 - sizeof(struct delta_index_header)); 1142 - if (result != UDS_SUCCESS) 1139 + result = VDO_ASSERT(offset == sizeof(struct delta_index_header), 1140 + "%zu bytes encoded of %zu expected", offset, 1141 + sizeof(struct delta_index_header)); 1142 + if (result != VDO_SUCCESS) 1143 1143 return result; 1144 1144 1145 1145 result = uds_write_to_buffered_writer(buffered_writer, buffer, offset); ··· 1212 1212 1213 1213 static int assert_not_at_end(const struct delta_index_entry *delta_entry) 1214 1214 { 1215 - int result = ASSERT(!delta_entry->at_end, 1216 - "operation is invalid because the list entry is at the end of the delta list"); 1217 - if (result != UDS_SUCCESS) 1215 + int result = VDO_ASSERT(!delta_entry->at_end, 1216 + "operation is invalid because the list entry is at the end of the delta list"); 1217 + if (result != VDO_SUCCESS) 1218 1218 result = UDS_BAD_STATE; 1219 1219 1220 1220 return result; ··· 1236 1236 struct delta_zone *delta_zone; 1237 1237 struct delta_list *delta_list; 1238 1238 1239 - result = ASSERT((list_number < delta_index->list_count), 1240 - "Delta list number (%u) is out of range (%u)", list_number, 1241 - delta_index->list_count); 1242 - if (result != UDS_SUCCESS) 1239 + result = VDO_ASSERT((list_number < delta_index->list_count), 1240 + "Delta list number (%u) is out of range (%u)", list_number, 1241 + delta_index->list_count); 1242 + if (result != VDO_SUCCESS) 1243 1243 return UDS_CORRUPT_DATA; 1244 1244 1245 1245 zone_number = list_number / delta_index->lists_per_zone; 1246 1246 delta_zone = &delta_index->delta_zones[zone_number]; 1247 1247 list_number -= delta_zone->first_list; 1248 - result = ASSERT((list_number < delta_zone->list_count), 1249 - "Delta list number (%u) is out of range (%u) for zone (%u)", 1250 - list_number, delta_zone->list_count, zone_number); 1251 - if (result != UDS_SUCCESS) 1248 + result = VDO_ASSERT((list_number < delta_zone->list_count), 1249 + "Delta list number (%u) is out of range (%u) for zone (%u)", 1250 + list_number, delta_zone->list_count, zone_number); 1251 + if (result != VDO_SUCCESS) 1252 1252 return UDS_CORRUPT_DATA; 1253 1253 1254 1254 if (delta_index->mutable) { ··· 1362 1362 delta_entry->at_end = true; 1363 1363 delta_entry->delta = 0; 1364 1364 delta_entry->is_collision = false; 1365 - result = ASSERT((delta_entry->offset == size), 1366 - "next offset past end of delta list"); 1367 - if (result != UDS_SUCCESS) 1365 + result = VDO_ASSERT((delta_entry->offset == size), 1366 + "next offset past end of delta list"); 1367 + if (result != VDO_SUCCESS) 1368 1368 result = UDS_CORRUPT_DATA; 1369 1369 1370 1370 return result; ··· 1390 1390 int result; 1391 1391 struct delta_list *delta_list = delta_entry->delta_list; 1392 1392 1393 - result = ASSERT(!delta_entry->is_collision, "entry is not a collision"); 1394 - if (result != UDS_SUCCESS) 1393 + result = VDO_ASSERT(!delta_entry->is_collision, "entry is not a collision"); 1394 + if (result != VDO_SUCCESS) 1395 1395 return result; 1396 1396 1397 1397 delta_list->save_key = delta_entry->key - delta_entry->delta; ··· 1489 1489 if (result != UDS_SUCCESS) 1490 1490 return result; 1491 1491 1492 - result = ASSERT(delta_entry->is_collision, 1493 - "Cannot get full block name from a non-collision delta index entry"); 1494 - if (result != UDS_SUCCESS) 1492 + result = VDO_ASSERT(delta_entry->is_collision, 1493 + "Cannot get full block name from a non-collision delta index entry"); 1494 + if (result != VDO_SUCCESS) 1495 1495 return UDS_BAD_STATE; 1496 1496 1497 1497 get_collision_name(delta_entry, name); ··· 1506 1506 1507 1507 static int assert_mutable_entry(const struct delta_index_entry *delta_entry) 1508 1508 { 1509 - int result = ASSERT((delta_entry->delta_list != &delta_entry->temp_delta_list), 1510 - "delta index is mutable"); 1511 - if (result != UDS_SUCCESS) 1509 + int result = VDO_ASSERT((delta_entry->delta_list != &delta_entry->temp_delta_list), 1510 + "delta index is mutable"); 1511 + if (result != VDO_SUCCESS) 1512 1512 result = UDS_BAD_STATE; 1513 1513 1514 1514 return result; ··· 1527 1527 if (result != UDS_SUCCESS) 1528 1528 return result; 1529 1529 1530 - result = ASSERT((value & value_mask) == value, 1531 - "Value (%u) being set in a delta index is too large (must fit in %u bits)", 1532 - value, delta_entry->value_bits); 1533 - if (result != UDS_SUCCESS) 1530 + result = VDO_ASSERT((value & value_mask) == value, 1531 + "Value (%u) being set in a delta index is too large (must fit in %u bits)", 1532 + value, delta_entry->value_bits); 1533 + if (result != VDO_SUCCESS) 1534 1534 return UDS_INVALID_ARGUMENT; 1535 1535 1536 1536 set_field(value, delta_entry->delta_zone->memory, ··· 1730 1730 if (result != UDS_SUCCESS) 1731 1731 return result; 1732 1732 1733 - result = ASSERT((key == delta_entry->key), 1734 - "incorrect key for collision entry"); 1735 - if (result != UDS_SUCCESS) 1733 + result = VDO_ASSERT((key == delta_entry->key), 1734 + "incorrect key for collision entry"); 1735 + if (result != VDO_SUCCESS) 1736 1736 return result; 1737 1737 1738 1738 delta_entry->offset += delta_entry->entry_bits; ··· 1742 1742 result = insert_bits(delta_entry, delta_entry->entry_bits); 1743 1743 } else if (delta_entry->at_end) { 1744 1744 /* Insert a new entry at the end of the delta list. */ 1745 - result = ASSERT((key >= delta_entry->key), "key past end of list"); 1746 - if (result != UDS_SUCCESS) 1745 + result = VDO_ASSERT((key >= delta_entry->key), "key past end of list"); 1746 + if (result != VDO_SUCCESS) 1747 1747 return result; 1748 1748 1749 1749 set_delta(delta_entry, key - delta_entry->key); ··· 1760 1760 * Insert a new entry which requires the delta in the following entry to be 1761 1761 * updated. 1762 1762 */ 1763 - result = ASSERT((key < delta_entry->key), 1764 - "key precedes following entry"); 1765 - if (result != UDS_SUCCESS) 1763 + result = VDO_ASSERT((key < delta_entry->key), 1764 + "key precedes following entry"); 1765 + if (result != VDO_SUCCESS) 1766 1766 return result; 1767 1767 1768 - result = ASSERT((key >= delta_entry->key - delta_entry->delta), 1769 - "key effects following entry's delta"); 1770 - if (result != UDS_SUCCESS) 1768 + result = VDO_ASSERT((key >= delta_entry->key - delta_entry->delta), 1769 + "key effects following entry's delta"); 1770 + if (result != VDO_SUCCESS) 1771 1771 return result; 1772 1772 1773 1773 old_entry_size = delta_entry->entry_bits;
+3 -2
drivers/md/dm-vdo/indexer/index-layout.c
··· 837 837 encode_u32_le(buffer, &offset, isl->save_data.version); 838 838 encode_u32_le(buffer, &offset, 0U); 839 839 encode_u64_le(buffer, &offset, isl->index_save.start_block); 840 - ASSERT_LOG_ONLY(offset == sizeof(nonce_data), 841 - "%zu bytes encoded of %zu expected", offset, sizeof(nonce_data)); 840 + VDO_ASSERT_LOG_ONLY(offset == sizeof(nonce_data), 841 + "%zu bytes encoded of %zu expected", 842 + offset, sizeof(nonce_data)); 842 843 return generate_secondary_nonce(volume_nonce, buffer, sizeof(buffer)); 843 844 } 844 845
+6 -6
drivers/md/dm-vdo/indexer/index-session.c
··· 199 199 break; 200 200 201 201 default: 202 - request->status = ASSERT(false, "unknown request type: %d", 203 - request->type); 202 + request->status = VDO_ASSERT(false, "unknown request type: %d", 203 + request->type); 204 204 } 205 205 } 206 206 ··· 402 402 case INDEX_FREEING: 403 403 default: 404 404 /* These cases should not happen. */ 405 - ASSERT_LOG_ONLY(false, "Bad load context state %u", 406 - session->load_context.status); 405 + VDO_ASSERT_LOG_ONLY(false, "Bad load context state %u", 406 + session->load_context.status); 407 407 break; 408 408 } 409 409 mutex_unlock(&session->load_context.mutex); ··· 531 531 case INDEX_FREEING: 532 532 default: 533 533 /* These cases should not happen; do nothing. */ 534 - ASSERT_LOG_ONLY(false, "Bad load context state %u", 535 - session->load_context.status); 534 + VDO_ASSERT_LOG_ONLY(false, "Bad load context state %u", 535 + session->load_context.status); 536 536 break; 537 537 } 538 538 mutex_unlock(&session->load_context.mutex);
+2 -2
drivers/md/dm-vdo/indexer/index.c
··· 112 112 for (zone = 0; zone < index->zone_count; zone++) { 113 113 int result = launch_zone_message(message, zone, index); 114 114 115 - ASSERT_LOG_ONLY((result == UDS_SUCCESS), "barrier message allocation"); 115 + VDO_ASSERT_LOG_ONLY((result == UDS_SUCCESS), "barrier message allocation"); 116 116 } 117 117 } 118 118 ··· 1380 1380 break; 1381 1381 1382 1382 default: 1383 - ASSERT_LOG_ONLY(false, "invalid index stage: %d", stage); 1383 + VDO_ASSERT_LOG_ONLY(false, "invalid index stage: %d", stage); 1384 1384 return; 1385 1385 } 1386 1386
+16 -16
drivers/md/dm-vdo/indexer/volume-index.c
··· 832 832 decode_u32_le(buffer, &offset, &header.first_list); 833 833 decode_u32_le(buffer, &offset, &header.list_count); 834 834 835 - result = ASSERT(offset == sizeof(buffer), 836 - "%zu bytes decoded of %zu expected", offset, 837 - sizeof(buffer)); 838 - if (result != UDS_SUCCESS) 835 + result = VDO_ASSERT(offset == sizeof(buffer), 836 + "%zu bytes decoded of %zu expected", offset, 837 + sizeof(buffer)); 838 + if (result != VDO_SUCCESS) 839 839 result = UDS_CORRUPT_DATA; 840 840 841 841 if (memcmp(header.magic, MAGIC_START_5, MAGIC_SIZE) != 0) { ··· 924 924 offset += MAGIC_SIZE; 925 925 decode_u32_le(buffer, &offset, &header.sparse_sample_rate); 926 926 927 - result = ASSERT(offset == sizeof(buffer), 928 - "%zu bytes decoded of %zu expected", offset, 929 - sizeof(buffer)); 930 - if (result != UDS_SUCCESS) 927 + result = VDO_ASSERT(offset == sizeof(buffer), 928 + "%zu bytes decoded of %zu expected", offset, 929 + sizeof(buffer)); 930 + if (result != VDO_SUCCESS) 931 931 result = UDS_CORRUPT_DATA; 932 932 933 933 if (memcmp(header.magic, MAGIC_START_6, MAGIC_SIZE) != 0) ··· 1023 1023 encode_u32_le(buffer, &offset, first_list); 1024 1024 encode_u32_le(buffer, &offset, list_count); 1025 1025 1026 - result = ASSERT(offset == sizeof(struct sub_index_data), 1027 - "%zu bytes of config written, of %zu expected", offset, 1028 - sizeof(struct sub_index_data)); 1029 - if (result != UDS_SUCCESS) 1026 + result = VDO_ASSERT(offset == sizeof(struct sub_index_data), 1027 + "%zu bytes of config written, of %zu expected", offset, 1028 + sizeof(struct sub_index_data)); 1029 + if (result != VDO_SUCCESS) 1030 1030 return result; 1031 1031 1032 1032 result = uds_write_to_buffered_writer(buffered_writer, buffer, offset); ··· 1066 1066 memcpy(buffer, MAGIC_START_6, MAGIC_SIZE); 1067 1067 offset += MAGIC_SIZE; 1068 1068 encode_u32_le(buffer, &offset, volume_index->sparse_sample_rate); 1069 - result = ASSERT(offset == sizeof(struct volume_index_data), 1070 - "%zu bytes of header written, of %zu expected", offset, 1071 - sizeof(struct volume_index_data)); 1072 - if (result != UDS_SUCCESS) 1069 + result = VDO_ASSERT(offset == sizeof(struct volume_index_data), 1070 + "%zu bytes of header written, of %zu expected", offset, 1071 + sizeof(struct volume_index_data)); 1072 + if (result != VDO_SUCCESS) 1073 1073 return result; 1074 1074 1075 1075 result = uds_write_to_buffered_writer(writer, buffer, offset);
+16 -16
drivers/md/dm-vdo/indexer/volume.c
··· 135 135 invalidate_counter.page = physical_page; 136 136 invalidate_counter.counter++; 137 137 set_invalidate_counter(cache, zone_number, invalidate_counter); 138 - ASSERT_LOG_ONLY(search_pending(invalidate_counter), 139 - "Search is pending for zone %u", zone_number); 138 + VDO_ASSERT_LOG_ONLY(search_pending(invalidate_counter), 139 + "Search is pending for zone %u", zone_number); 140 140 /* 141 141 * This memory barrier ensures that the write to the invalidate counter is seen by other 142 142 * threads before this thread accesses the cached page. The corresponding read memory ··· 158 158 smp_mb(); 159 159 160 160 invalidate_counter = get_invalidate_counter(cache, zone_number); 161 - ASSERT_LOG_ONLY(search_pending(invalidate_counter), 162 - "Search is pending for zone %u", zone_number); 161 + VDO_ASSERT_LOG_ONLY(search_pending(invalidate_counter), 162 + "Search is pending for zone %u", zone_number); 163 163 invalidate_counter.counter++; 164 164 set_invalidate_counter(cache, zone_number, invalidate_counter); 165 165 } ··· 259 259 int result; 260 260 261 261 /* We hold the read_threads_mutex. */ 262 - result = ASSERT((page->read_pending), "page to install has a pending read"); 263 - if (result != UDS_SUCCESS) 262 + result = VDO_ASSERT((page->read_pending), "page to install has a pending read"); 263 + if (result != VDO_SUCCESS) 264 264 return result; 265 265 266 266 page->physical_page = physical_page; ··· 285 285 int result; 286 286 287 287 /* We hold the read_threads_mutex. */ 288 - result = ASSERT((page->read_pending), "page to install has a pending read"); 289 - if (result != UDS_SUCCESS) 288 + result = VDO_ASSERT((page->read_pending), "page to install has a pending read"); 289 + if (result != VDO_SUCCESS) 290 290 return; 291 291 292 292 clear_cache_page(cache, page); ··· 889 889 if (record_page_number == NO_CHAPTER_INDEX_ENTRY) 890 890 return UDS_SUCCESS; 891 891 892 - result = ASSERT(record_page_number < geometry->record_pages_per_chapter, 893 - "0 <= %d < %u", record_page_number, 894 - geometry->record_pages_per_chapter); 895 - if (result != UDS_SUCCESS) 892 + result = VDO_ASSERT(record_page_number < geometry->record_pages_per_chapter, 893 + "0 <= %d < %u", record_page_number, 894 + geometry->record_pages_per_chapter); 895 + if (result != VDO_SUCCESS) 896 896 return result; 897 897 898 898 page_number = geometry->index_pages_per_chapter + record_page_number; ··· 1501 1501 cache->zone_count = zone_count; 1502 1502 atomic64_set(&cache->clock, 1); 1503 1503 1504 - result = ASSERT((cache->cache_slots <= VOLUME_CACHE_MAX_ENTRIES), 1505 - "requested cache size, %u, within limit %u", 1506 - cache->cache_slots, VOLUME_CACHE_MAX_ENTRIES); 1507 - if (result != UDS_SUCCESS) 1504 + result = VDO_ASSERT((cache->cache_slots <= VOLUME_CACHE_MAX_ENTRIES), 1505 + "requested cache size, %u, within limit %u", 1506 + cache->cache_slots, VOLUME_CACHE_MAX_ENTRIES); 1507 + if (result != VDO_SUCCESS) 1508 1508 return result; 1509 1509 1510 1510 result = vdo_allocate(VOLUME_CACHE_MAX_QUEUED_READS, struct queued_read,
+1 -1
drivers/md/dm-vdo/permassert.c
··· 8 8 #include "errors.h" 9 9 #include "logger.h" 10 10 11 - int uds_assertion_failed(const char *expression_string, const char *file_name, 11 + int vdo_assertion_failed(const char *expression_string, const char *file_name, 12 12 int line_number, const char *format, ...) 13 13 { 14 14 va_list args;
+2 -6
drivers/md/dm-vdo/permassert.h
··· 33 33 /* Log a message if the expression is not true. */ 34 34 #define VDO_ASSERT_LOG_ONLY(expr, ...) __VDO_ASSERT(expr, __VA_ARGS__) 35 35 36 - /* For use by UDS */ 37 - #define ASSERT(expr, ...) VDO_ASSERT(expr, __VA_ARGS__) 38 - #define ASSERT_LOG_ONLY(expr, ...) __VDO_ASSERT(expr, __VA_ARGS__) 39 - 40 36 #define __VDO_ASSERT(expr, ...) \ 41 37 (likely(expr) ? VDO_SUCCESS \ 42 - : uds_assertion_failed(STRINGIFY(expr), __FILE__, __LINE__, __VA_ARGS__)) 38 + : vdo_assertion_failed(STRINGIFY(expr), __FILE__, __LINE__, __VA_ARGS__)) 43 39 44 40 /* Log an assertion failure message. */ 45 - int uds_assertion_failed(const char *expression_string, const char *file_name, 41 + int vdo_assertion_failed(const char *expression_string, const char *file_name, 46 42 int line_number, const char *format, ...) 47 43 __printf(4, 5); 48 44