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

Configure Feed

Select the types of activity you want to include in your feed.

dm vdo: remove redundant TYPE argument from vdo_allocate macro

We can infer the type needed from the supplied pointer argument. A
couple invocation sites needed fixing to supply the proper type of
pointer.

Use overflow.h's size_mul, and we can remove the __vdo_do_allocation
wrapper which did the same overflow check.

Signed-off-by: Ken Raeburn <raeburn@redhat.com>
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>

authored by

Ken Raeburn and committed by
Mikulas Patocka
9bb388b1 6af58aa3

+114 -198
+1 -1
drivers/md/dm-vdo/action-manager.c
··· 107 107 struct action_manager **manager_ptr) 108 108 { 109 109 struct action_manager *manager; 110 - int result = vdo_allocate(1, struct action_manager, __func__, &manager); 110 + int result = vdo_allocate(1, __func__, &manager); 111 111 112 112 if (result != VDO_SUCCESS) 113 113 return result;
+5 -11
drivers/md/dm-vdo/block-map.c
··· 221 221 u64 size = cache->page_count * (u64) VDO_BLOCK_SIZE; 222 222 int result; 223 223 224 - result = vdo_allocate(cache->page_count, struct page_info, "page infos", 225 - &cache->infos); 224 + result = vdo_allocate(cache->page_count, "page infos", &cache->infos); 226 225 if (result != VDO_SUCCESS) 227 226 return result; 228 227 ··· 2363 2364 2364 2365 forest->segments = index + 1; 2365 2366 2366 - result = vdo_allocate(forest->segments, struct boundary, 2367 - "forest boundary array", &forest->boundaries); 2367 + result = vdo_allocate(forest->segments, "forest boundary array", &forest->boundaries); 2368 2368 if (result != VDO_SUCCESS) 2369 2369 return result; 2370 2370 2371 - result = vdo_allocate(forest->segments, struct tree_page *, 2372 - "forest page pointers", &forest->pages); 2371 + result = vdo_allocate(forest->segments, "forest page pointers", &forest->pages); 2373 2372 if (result != VDO_SUCCESS) 2374 2373 return result; 2375 2374 2376 - result = vdo_allocate(new_pages, struct tree_page, 2377 - "new forest pages", &forest->pages[index]); 2375 + result = vdo_allocate(new_pages, "new forest pages", &forest->pages[index]); 2378 2376 if (result != VDO_SUCCESS) 2379 2377 return result; 2380 2378 ··· 2396 2400 struct block_map_tree *tree = &(forest->trees[root]); 2397 2401 height_t height; 2398 2402 2399 - int result = vdo_allocate(forest->segments, 2400 - struct block_map_tree_segment, 2401 - "tree root segments", &tree->segments); 2403 + result = vdo_allocate(forest->segments, "tree root segments", &tree->segments); 2402 2404 if (result != VDO_SUCCESS) 2403 2405 return result; 2404 2406
+1 -2
drivers/md/dm-vdo/dedupe.c
··· 2364 2364 vdo_set_completion_callback(&zone->completion, timeout_index_operations_callback, 2365 2365 zone->thread_id); 2366 2366 INIT_LIST_HEAD(&zone->lock_pool); 2367 - result = vdo_allocate(LOCK_POOL_CAPACITY, struct hash_lock, "hash_lock array", 2368 - &zone->lock_array); 2367 + result = vdo_allocate(LOCK_POOL_CAPACITY, "hash_lock array", &zone->lock_array); 2369 2368 if (result != VDO_SUCCESS) 2370 2369 return result; 2371 2370
+5 -7
drivers/md/dm-vdo/dm-vdo-target.c
··· 273 273 substring_count++; 274 274 } 275 275 276 - result = vdo_allocate(substring_count + 1, char *, "string-splitting array", 277 - &substrings); 276 + result = vdo_allocate(substring_count + 1, "string-splitting array", &substrings); 278 277 if (result != VDO_SUCCESS) 279 278 return result; 280 279 ··· 281 282 if (*s == separator) { 282 283 ptrdiff_t length = s - string; 283 284 284 - result = vdo_allocate(length + 1, char, "split string", 285 + result = vdo_allocate(length + 1, "split string", 285 286 &substrings[current_substring]); 286 287 if (result != VDO_SUCCESS) { 287 288 free_string_array(substrings); ··· 302 303 BUG_ON(current_substring != (substring_count - 1)); 303 304 length = strlen(string); 304 305 305 - result = vdo_allocate(length + 1, char, "split string", 306 - &substrings[current_substring]); 306 + result = vdo_allocate(length + 1, "split string", &substrings[current_substring]); 307 307 if (result != VDO_SUCCESS) { 308 308 free_string_array(substrings); 309 309 return result; ··· 330 332 for (i = 0; (i < array_length) && (substring_array[i] != NULL); i++) 331 333 string_length += strlen(substring_array[i]) + 1; 332 334 333 - result = vdo_allocate(string_length, char, __func__, &output); 335 + result = vdo_allocate(string_length, __func__, &output); 334 336 if (result != VDO_SUCCESS) 335 337 return result; 336 338 ··· 724 726 return VDO_BAD_CONFIGURATION; 725 727 } 726 728 727 - result = vdo_allocate(1, struct device_config, "device_config", &config); 729 + result = vdo_allocate(1, "device_config", &config); 728 730 if (result != VDO_SUCCESS) { 729 731 handle_parse_error(config, error_ptr, 730 732 "Could not allocate config structure");
+1 -1
drivers/md/dm-vdo/encodings.c
··· 798 798 struct partition *partition; 799 799 int result; 800 800 801 - result = vdo_allocate(1, struct partition, __func__, &partition); 801 + result = vdo_allocate(1, __func__, &partition); 802 802 if (result != VDO_SUCCESS) 803 803 return result; 804 804
+2 -2
drivers/md/dm-vdo/flush.c
··· 105 105 if ((gfp_mask & GFP_NOWAIT) == GFP_NOWAIT) { 106 106 flush = vdo_allocate_memory_nowait(sizeof(struct vdo_flush), __func__); 107 107 } else { 108 - int result = vdo_allocate(1, struct vdo_flush, __func__, &flush); 108 + int result = vdo_allocate(1, __func__, &flush); 109 109 110 110 if (result != VDO_SUCCESS) 111 111 vdo_log_error_strerror(result, "failed to allocate spare flush"); ··· 134 134 */ 135 135 int vdo_make_flusher(struct vdo *vdo) 136 136 { 137 - int result = vdo_allocate(1, struct flusher, __func__, &vdo->flusher); 137 + int result = vdo_allocate(1, __func__, &vdo->flusher); 138 138 139 139 if (result != VDO_SUCCESS) 140 140 return result;
+1 -1
drivers/md/dm-vdo/funnel-queue.c
··· 14 14 int result; 15 15 struct funnel_queue *queue; 16 16 17 - result = vdo_allocate(1, struct funnel_queue, "funnel queue", &queue); 17 + result = vdo_allocate(1, "funnel queue", &queue); 18 18 if (result != VDO_SUCCESS) 19 19 return result; 20 20
+3 -5
drivers/md/dm-vdo/funnel-workqueue.c
··· 322 322 "queue priority count %u within limit %u", type->max_priority, 323 323 VDO_WORK_Q_MAX_PRIORITY); 324 324 325 - result = vdo_allocate(1, struct simple_work_queue, "simple work queue", &queue); 325 + result = vdo_allocate(1, "simple work queue", &queue); 326 326 if (result != VDO_SUCCESS) 327 327 return result; 328 328 ··· 405 405 return result; 406 406 } 407 407 408 - result = vdo_allocate(1, struct round_robin_work_queue, "round-robin work queue", 409 - &queue); 408 + result = vdo_allocate(1, "round-robin work queue", &queue); 410 409 if (result != VDO_SUCCESS) 411 410 return result; 412 411 413 - result = vdo_allocate(thread_count, struct simple_work_queue *, 414 - "subordinate work queues", &queue->service_queues); 412 + result = vdo_allocate(thread_count, "subordinate work queues", &queue->service_queues); 415 413 if (result != VDO_SUCCESS) { 416 414 vdo_free(queue); 417 415 return result;
+1 -1
drivers/md/dm-vdo/indexer/chapter-index.c
··· 20 20 size_t memory_size; 21 21 struct open_chapter_index *index; 22 22 23 - result = vdo_allocate(1, struct open_chapter_index, "open chapter index", &index); 23 + result = vdo_allocate(1, "open chapter index", &index); 24 24 if (result != VDO_SUCCESS) 25 25 return result; 26 26
+1 -1
drivers/md/dm-vdo/indexer/config.c
··· 325 325 if (result != UDS_SUCCESS) 326 326 return result; 327 327 328 - result = vdo_allocate(1, struct uds_configuration, __func__, &config); 328 + result = vdo_allocate(1, __func__, &config); 329 329 if (result != VDO_SUCCESS) 330 330 return result; 331 331
+5 -8
drivers/md/dm-vdo/indexer/delta-index.c
··· 311 311 { 312 312 int result; 313 313 314 - result = vdo_allocate(size, u8, "delta list", &delta_zone->memory); 314 + result = vdo_allocate(size, "delta list", &delta_zone->memory); 315 315 if (result != VDO_SUCCESS) 316 316 return result; 317 317 318 - result = vdo_allocate(list_count + 2, u64, "delta list temp", 319 - &delta_zone->new_offsets); 318 + result = vdo_allocate(list_count + 2, "delta list temp", &delta_zone->new_offsets); 320 319 if (result != VDO_SUCCESS) 321 320 return result; 322 321 323 322 /* Allocate the delta lists. */ 324 - result = vdo_allocate(list_count + 2, struct delta_list, "delta lists", 325 - &delta_zone->delta_lists); 323 + result = vdo_allocate(list_count + 2, "delta lists", &delta_zone->delta_lists); 326 324 if (result != VDO_SUCCESS) 327 325 return result; 328 326 ··· 350 352 unsigned int z; 351 353 size_t zone_memory; 352 354 353 - result = vdo_allocate(zone_count, struct delta_zone, "Delta Index Zones", 354 - &delta_index->delta_zones); 355 + result = vdo_allocate(zone_count, "Delta Index Zones", &delta_index->delta_zones); 355 356 if (result != VDO_SUCCESS) 356 357 return result; 357 358 ··· 1044 1047 unsigned int z; 1045 1048 u8 *data; 1046 1049 1047 - result = vdo_allocate(DELTA_LIST_MAX_BYTE_COUNT, u8, __func__, &data); 1050 + result = vdo_allocate(DELTA_LIST_MAX_BYTE_COUNT, __func__, &data); 1048 1051 if (result != VDO_SUCCESS) 1049 1052 return result; 1050 1053
+1 -1
drivers/md/dm-vdo/indexer/funnel-requestqueue.c
··· 198 198 int result; 199 199 struct uds_request_queue *queue; 200 200 201 - result = vdo_allocate(1, struct uds_request_queue, __func__, &queue); 201 + result = vdo_allocate(1, __func__, &queue); 202 202 if (result != VDO_SUCCESS) 203 203 return result; 204 204
+1 -1
drivers/md/dm-vdo/indexer/geometry.c
··· 61 61 int result; 62 62 struct index_geometry *geometry; 63 63 64 - result = vdo_allocate(1, struct index_geometry, "geometry", &geometry); 64 + result = vdo_allocate(1, "geometry", &geometry); 65 65 if (result != VDO_SUCCESS) 66 66 return result; 67 67
+6 -8
drivers/md/dm-vdo/indexer/index-layout.c
··· 519 519 u8 *buffer; 520 520 size_t offset = 0; 521 521 522 - result = vdo_allocate(table->encoded_size, u8, "index save data", &buffer); 522 + result = vdo_allocate(table->encoded_size, "index save data", &buffer); 523 523 if (result != VDO_SUCCESS) 524 524 return result; 525 525 ··· 688 688 u8 *buffer; 689 689 size_t offset = 0; 690 690 691 - result = vdo_allocate(table->encoded_size, u8, "layout data", &buffer); 691 + result = vdo_allocate(table->encoded_size, "layout data", &buffer); 692 692 if (result != VDO_SUCCESS) 693 693 return result; 694 694 ··· 778 778 if (result != UDS_SUCCESS) 779 779 return result; 780 780 781 - result = vdo_allocate(sizes.save_count, struct index_save_layout, __func__, 782 - &layout->index.saves); 781 + result = vdo_allocate(sizes.save_count, __func__, &layout->index.saves); 783 782 if (result != VDO_SUCCESS) 784 783 return result; 785 784 ··· 1173 1174 u8 *buffer; 1174 1175 size_t offset = 0; 1175 1176 1176 - result = vdo_allocate(saved_size, u8, "super block data", &buffer); 1177 + result = vdo_allocate(saved_size, "super block data", &buffer); 1177 1178 if (result != VDO_SUCCESS) 1178 1179 return result; 1179 1180 ··· 1307 1308 int result; 1308 1309 u64 next_block = first_block; 1309 1310 1310 - result = vdo_allocate(layout->super.max_saves, struct index_save_layout, 1311 - __func__, &layout->index.saves); 1311 + result = vdo_allocate(layout->super.max_saves, __func__, &layout->index.saves); 1312 1312 if (result != VDO_SUCCESS) 1313 1313 return result; 1314 1314 ··· 1670 1672 if (result != UDS_SUCCESS) 1671 1673 return result; 1672 1674 1673 - result = vdo_allocate(1, struct index_layout, __func__, &layout); 1675 + result = vdo_allocate(1, __func__, &layout); 1674 1676 if (result != VDO_SUCCESS) 1675 1677 return result; 1676 1678
+4 -4
drivers/md/dm-vdo/indexer/index-page-map.c
··· 38 38 int result; 39 39 struct index_page_map *map; 40 40 41 - result = vdo_allocate(1, struct index_page_map, "page map", &map); 41 + result = vdo_allocate(1, "page map", &map); 42 42 if (result != VDO_SUCCESS) 43 43 return result; 44 44 45 45 map->geometry = geometry; 46 46 map->entries_per_chapter = geometry->index_pages_per_chapter - 1; 47 - result = vdo_allocate(get_entry_count(geometry), u16, "Index Page Map Entries", 47 + result = vdo_allocate(get_entry_count(geometry), "Index Page Map Entries", 48 48 &map->entries); 49 49 if (result != VDO_SUCCESS) { 50 50 uds_free_index_page_map(map); ··· 118 118 u64 saved_size = uds_compute_index_page_map_save_size(map->geometry); 119 119 u32 i; 120 120 121 - result = vdo_allocate(saved_size, u8, "page map data", &buffer); 121 + result = vdo_allocate(saved_size, "page map data", &buffer); 122 122 if (result != VDO_SUCCESS) 123 123 return result; 124 124 ··· 145 145 u64 saved_size = uds_compute_index_page_map_save_size(map->geometry); 146 146 u32 i; 147 147 148 - result = vdo_allocate(saved_size, u8, "page map data", &buffer); 148 + result = vdo_allocate(saved_size, "page map data", &buffer); 149 149 if (result != VDO_SUCCESS) 150 150 return result; 151 151
+1 -1
drivers/md/dm-vdo/indexer/index-session.c
··· 217 217 int result; 218 218 struct uds_index_session *session; 219 219 220 - result = vdo_allocate(1, struct uds_index_session, __func__, &session); 220 + result = vdo_allocate(1, __func__, &session); 221 221 if (result != VDO_SUCCESS) 222 222 return result; 223 223
+3 -4
drivers/md/dm-vdo/indexer/index.c
··· 88 88 int result; 89 89 struct uds_request *request; 90 90 91 - result = vdo_allocate(1, struct uds_request, __func__, &request); 91 + result = vdo_allocate(1, __func__, &request); 92 92 if (result != VDO_SUCCESS) 93 93 return result; 94 94 ··· 1121 1121 int result; 1122 1122 struct index_zone *zone; 1123 1123 1124 - result = vdo_allocate(1, struct index_zone, "index zone", &zone); 1124 + result = vdo_allocate(1, "index zone", &zone); 1125 1125 if (result != VDO_SUCCESS) 1126 1126 return result; 1127 1127 ··· 1170 1170 return result; 1171 1171 } 1172 1172 1173 - result = vdo_allocate(index->zone_count, struct index_zone *, "zones", 1174 - &index->zones); 1173 + result = vdo_allocate(index->zone_count, "zones", &index->zones); 1175 1174 if (result != VDO_SUCCESS) { 1176 1175 uds_free_index(index); 1177 1176 return result;
+3 -3
drivers/md/dm-vdo/indexer/io-factory.c
··· 64 64 int result; 65 65 struct io_factory *factory; 66 66 67 - result = vdo_allocate(1, struct io_factory, __func__, &factory); 67 + result = vdo_allocate(1, __func__, &factory); 68 68 if (result != VDO_SUCCESS) 69 69 return result; 70 70 ··· 144 144 if (result != UDS_SUCCESS) 145 145 return result; 146 146 147 - result = vdo_allocate(1, struct buffered_reader, "buffered reader", &reader); 147 + result = vdo_allocate(1, "buffered reader", &reader); 148 148 if (result != VDO_SUCCESS) { 149 149 dm_bufio_client_destroy(client); 150 150 return result; ··· 282 282 if (result != UDS_SUCCESS) 283 283 return result; 284 284 285 - result = vdo_allocate(1, struct buffered_writer, "buffered writer", &writer); 285 + result = vdo_allocate(1, "buffered writer", &writer); 286 286 if (result != VDO_SUCCESS) { 287 287 dm_bufio_client_destroy(client); 288 288 return result;
+4 -6
drivers/md/dm-vdo/indexer/sparse-cache.c
··· 222 222 chapter->virtual_chapter = NO_CHAPTER; 223 223 chapter->index_pages_count = geometry->index_pages_per_chapter; 224 224 225 - result = vdo_allocate(chapter->index_pages_count, struct delta_index_page, 226 - __func__, &chapter->index_pages); 225 + result = vdo_allocate(chapter->index_pages_count, __func__, &chapter->index_pages); 227 226 if (result != VDO_SUCCESS) 228 227 return result; 229 228 230 - return vdo_allocate(chapter->index_pages_count, struct dm_buffer *, 231 - "sparse index volume pages", &chapter->page_buffers); 229 + return vdo_allocate(chapter->index_pages_count, "sparse index volume pages", 230 + &chapter->page_buffers); 232 231 } 233 232 234 233 static int __must_check make_search_list(struct sparse_cache *cache, ··· 293 294 } 294 295 295 296 /* purge_search_list() needs some temporary lists for sorting. */ 296 - result = vdo_allocate(capacity * 2, struct cached_chapter_index *, 297 - "scratch entries", &cache->scratch_entries); 297 + result = vdo_allocate(capacity * 2, "scratch entries", &cache->scratch_entries); 298 298 if (result != VDO_SUCCESS) 299 299 goto out; 300 300
+4 -6
drivers/md/dm-vdo/indexer/volume-index.c
··· 1211 1211 (zone_count * sizeof(struct volume_sub_index_zone))); 1212 1212 1213 1213 /* The following arrays are initialized to all zeros. */ 1214 - result = vdo_allocate(params.list_count, u64, "first chapter to flush", 1214 + result = vdo_allocate(params.list_count, "first chapter to flush", 1215 1215 &sub_index->flush_chapters); 1216 1216 if (result != VDO_SUCCESS) 1217 1217 return result; 1218 1218 1219 - return vdo_allocate(zone_count, struct volume_sub_index_zone, 1220 - "volume index zones", &sub_index->zones); 1219 + return vdo_allocate(zone_count, "volume index zones", &sub_index->zones); 1221 1220 } 1222 1221 1223 1222 int uds_make_volume_index(const struct uds_configuration *config, u64 volume_nonce, ··· 1227 1228 struct volume_index *volume_index; 1228 1229 int result; 1229 1230 1230 - result = vdo_allocate(1, struct volume_index, "volume index", &volume_index); 1231 + result = vdo_allocate(1, "volume index", &volume_index); 1231 1232 if (result != VDO_SUCCESS) 1232 1233 return result; 1233 1234 ··· 1248 1249 1249 1250 volume_index->sparse_sample_rate = config->sparse_sample_rate; 1250 1251 1251 - result = vdo_allocate(config->zone_count, struct volume_index_zone, 1252 - "volume index zones", &volume_index->zones); 1252 + result = vdo_allocate(config->zone_count, "volume index zones", &volume_index->zones); 1253 1253 if (result != VDO_SUCCESS) { 1254 1254 uds_free_volume_index(volume_index); 1255 1255 return result;
+9 -13
drivers/md/dm-vdo/indexer/volume.c
··· 1509 1509 if (result != VDO_SUCCESS) 1510 1510 return result; 1511 1511 1512 - result = vdo_allocate(VOLUME_CACHE_MAX_QUEUED_READS, struct queued_read, 1513 - "volume read queue", &cache->read_queue); 1512 + result = vdo_allocate(VOLUME_CACHE_MAX_QUEUED_READS, "volume read queue", 1513 + &cache->read_queue); 1514 1514 if (result != VDO_SUCCESS) 1515 1515 return result; 1516 1516 1517 - result = vdo_allocate(cache->zone_count, struct search_pending_counter, 1518 - "Volume Cache Zones", &cache->search_pending_counters); 1517 + result = vdo_allocate(cache->zone_count, "Volume Cache Zones", 1518 + &cache->search_pending_counters); 1519 1519 if (result != VDO_SUCCESS) 1520 1520 return result; 1521 1521 1522 - result = vdo_allocate(cache->indexable_pages, u16, "page cache index", 1523 - &cache->index); 1522 + result = vdo_allocate(cache->indexable_pages, "page cache index", &cache->index); 1524 1523 if (result != VDO_SUCCESS) 1525 1524 return result; 1526 1525 1527 - result = vdo_allocate(cache->cache_slots, struct cached_page, "page cache cache", 1528 - &cache->cache); 1526 + result = vdo_allocate(cache->cache_slots, "page cache cache", &cache->cache); 1529 1527 if (result != VDO_SUCCESS) 1530 1528 return result; 1531 1529 ··· 1546 1548 unsigned int reserved_buffers; 1547 1549 int result; 1548 1550 1549 - result = vdo_allocate(1, struct volume, "volume", &volume); 1551 + result = vdo_allocate(1, "volume", &volume); 1550 1552 if (result != VDO_SUCCESS) 1551 1553 return result; 1552 1554 ··· 1583 1585 return result; 1584 1586 } 1585 1587 1586 - result = vdo_allocate(geometry->records_per_page, 1587 - const struct uds_volume_record *, "record pointers", 1588 + result = vdo_allocate(geometry->records_per_page, "record pointers", 1588 1589 &volume->record_pointers); 1589 1590 if (result != VDO_SUCCESS) { 1590 1591 uds_free_volume(volume); ··· 1623 1626 uds_init_cond(&volume->read_threads_read_done_cond); 1624 1627 uds_init_cond(&volume->read_threads_cond); 1625 1628 1626 - result = vdo_allocate(config->read_threads, struct thread *, "reader threads", 1627 - &volume->reader_threads); 1629 + result = vdo_allocate(config->read_threads, "reader threads", &volume->reader_threads); 1628 1630 if (result != VDO_SUCCESS) { 1629 1631 uds_free_volume(volume); 1630 1632 return result;
+2 -3
drivers/md/dm-vdo/int-map.c
··· 164 164 * without have to wrap back around to element zero. 165 165 */ 166 166 map->bucket_count = capacity + (NEIGHBORHOOD - 1); 167 - return vdo_allocate(map->bucket_count, struct bucket, 168 - "struct int_map buckets", &map->buckets); 167 + return vdo_allocate(map->bucket_count, "struct int_map buckets", &map->buckets); 169 168 } 170 169 171 170 /** ··· 181 182 int result; 182 183 size_t capacity; 183 184 184 - result = vdo_allocate(1, struct int_map, "struct int_map", &map); 185 + result = vdo_allocate(1, "struct int_map", &map); 185 186 if (result != VDO_SUCCESS) 186 187 return result; 187 188
+5 -3
drivers/md/dm-vdo/memory-alloc.c
··· 245 245 } else { 246 246 struct vmalloc_block_info *block; 247 247 248 - if (vdo_allocate(1, struct vmalloc_block_info, __func__, &block) == VDO_SUCCESS) { 248 + if (vdo_allocate(1, __func__, &block) == VDO_SUCCESS) { 249 249 /* 250 250 * It is possible for __vmalloc to fail to allocate memory because there 251 251 * are no pages available. A short sleep may allow the page reclaimer ··· 341 341 void *new_ptr) 342 342 { 343 343 int result; 344 + char *temp_ptr; 344 345 345 346 if (size == 0) { 346 347 vdo_free(ptr); ··· 349 348 return VDO_SUCCESS; 350 349 } 351 350 352 - result = vdo_allocate(size, char, what, new_ptr); 351 + result = vdo_allocate(size, what, &temp_ptr); 353 352 if (result != VDO_SUCCESS) 354 353 return result; 354 + *(void **) new_ptr = temp_ptr; 355 355 356 356 if (ptr != NULL) { 357 357 if (old_size < size) ··· 370 368 int result; 371 369 u8 *dup; 372 370 373 - result = vdo_allocate(strlen(string) + 1, u8, what, &dup); 371 + result = vdo_allocate(strlen(string) + 1, what, &dup); 374 372 if (result != VDO_SUCCESS) 375 373 return result; 376 374
+3 -44
drivers/md/dm-vdo/memory-alloc.h
··· 17 17 int __must_check vdo_allocate_memory(size_t size, size_t align, const char *what, void *ptr); 18 18 19 19 /* 20 - * Allocate storage based on element counts, sizes, and alignment. 21 - * 22 - * This is a generalized form of our allocation use case: It allocates an array of objects, 23 - * optionally preceded by one object of another type (i.e., a struct with trailing variable-length 24 - * array), with the alignment indicated. 25 - * 26 - * Why is this inline? The sizes and alignment will always be constant, when invoked through the 27 - * macros below, and often the count will be a compile-time constant 1 or the number of extra bytes 28 - * will be a compile-time constant 0. So at least some of the arithmetic can usually be optimized 29 - * away, and the run-time selection between allocation functions always can. In many cases, it'll 30 - * boil down to just a function call with a constant size. 31 - * 32 - * @count: The number of objects to allocate 33 - * @size: The size of an object 34 - * @extra: The number of additional bytes to allocate 35 - * @align: The required alignment 36 - * @what: What is being allocated (for error logging) 37 - * @ptr: A pointer to hold the allocated memory 38 - * 39 - * Return: VDO_SUCCESS or an error code 40 - */ 41 - static inline int __vdo_do_allocation(size_t count, size_t size, size_t extra, 42 - size_t align, const char *what, void *ptr) 43 - { 44 - size_t total_size = count * size + extra; 45 - 46 - /* Overflow check: */ 47 - if ((size > 0) && (count > ((SIZE_MAX - extra) / size))) { 48 - /* 49 - * This is kind of a hack: We rely on the fact that SIZE_MAX would cover the entire 50 - * address space (minus one byte) and thus the system can never allocate that much 51 - * and the call will always fail. So we can report an overflow as "out of memory" 52 - * by asking for "merely" SIZE_MAX bytes. 53 - */ 54 - total_size = SIZE_MAX; 55 - } 56 - 57 - return vdo_allocate_memory(total_size, align, what, ptr); 58 - } 59 - 60 - /* 61 20 * Allocate one or more elements of the indicated type, logging an error if the allocation fails. 62 21 * The memory will be zeroed. 63 22 * 64 23 * @COUNT: The number of objects to allocate 65 - * @TYPE: The type of objects to allocate. This type determines the alignment of the allocation. 66 24 * @WHAT: What is being allocated (for error logging) 67 25 * @PTR: A pointer to hold the allocated memory 68 26 * 69 27 * Return: VDO_SUCCESS or an error code 70 28 */ 71 - #define vdo_allocate(COUNT, TYPE, WHAT, PTR) \ 72 - __vdo_do_allocation(COUNT, sizeof(TYPE), 0, __alignof__(TYPE), WHAT, PTR) 29 + #define vdo_allocate(COUNT, WHAT, PTR) \ 30 + vdo_allocate_memory(size_mul((COUNT), sizeof(typeof(**(PTR)))), \ 31 + __alignof__(typeof(**(PTR))), WHAT, PTR) 73 32 74 33 /* 75 34 * Allocate a structure with a flexible array member, with a specified number of elements, logging
+1 -1
drivers/md/dm-vdo/message-stats.c
··· 420 420 struct vdo_statistics *stats; 421 421 int result; 422 422 423 - result = vdo_allocate(1, struct vdo_statistics, __func__, &stats); 423 + result = vdo_allocate(1, __func__, &stats); 424 424 if (result != VDO_SUCCESS) { 425 425 vdo_log_error("Cannot allocate memory to write VDO statistics"); 426 426 return result;
+1 -1
drivers/md/dm-vdo/packer.c
··· 145 145 block_count_t i; 146 146 int result; 147 147 148 - result = vdo_allocate(1, struct packer, __func__, &packer); 148 + result = vdo_allocate(1, __func__, &packer); 149 149 if (result != VDO_SUCCESS) 150 150 return result; 151 151
+7 -10
drivers/md/dm-vdo/recovery-journal.c
··· 593 593 struct thread_config *config = &vdo->thread_config; 594 594 struct lock_counter *counter = &journal->lock_counter; 595 595 596 - result = vdo_allocate(journal->size, u16, __func__, &counter->journal_counters); 596 + result = vdo_allocate(journal->size, __func__, &counter->journal_counters); 597 597 if (result != VDO_SUCCESS) 598 598 return result; 599 599 600 - result = vdo_allocate(journal->size, atomic_t, __func__, 601 - &counter->journal_decrement_counts); 600 + result = vdo_allocate(journal->size, __func__, &counter->journal_decrement_counts); 602 601 if (result != VDO_SUCCESS) 603 602 return result; 604 603 605 - result = vdo_allocate(journal->size * config->logical_zone_count, u16, __func__, 604 + result = vdo_allocate(journal->size * config->logical_zone_count, __func__, 606 605 &counter->logical_counters); 607 606 if (result != VDO_SUCCESS) 608 607 return result; 609 608 610 - result = vdo_allocate(journal->size, atomic_t, __func__, 611 - &counter->logical_zone_counts); 609 + result = vdo_allocate(journal->size, __func__, &counter->logical_zone_counts); 612 610 if (result != VDO_SUCCESS) 613 611 return result; 614 612 615 - result = vdo_allocate(journal->size * config->physical_zone_count, u16, __func__, 613 + result = vdo_allocate(journal->size * config->physical_zone_count, __func__, 616 614 &counter->physical_counters); 617 615 if (result != VDO_SUCCESS) 618 616 return result; 619 617 620 - result = vdo_allocate(journal->size, atomic_t, __func__, 621 - &counter->physical_zone_counts); 618 + result = vdo_allocate(journal->size, __func__, &counter->physical_zone_counts); 622 619 if (result != VDO_SUCCESS) 623 620 return result; 624 621 ··· 669 672 * Allocate a full block for the journal block even though not all of the space is used 670 673 * since the VIO needs to write a full disk block. 671 674 */ 672 - result = vdo_allocate(VDO_BLOCK_SIZE, char, __func__, &data); 675 + result = vdo_allocate(VDO_BLOCK_SIZE, __func__, &data); 673 676 if (result != VDO_SUCCESS) 674 677 return result; 675 678
+4 -7
drivers/md/dm-vdo/repair.c
··· 1417 1417 * packed_recovery_journal_entry from every valid journal block. 1418 1418 */ 1419 1419 count = ((repair->highest_tail - repair->block_map_head + 1) * entries_per_block); 1420 - result = vdo_allocate(count, struct numbered_block_mapping, __func__, 1421 - &repair->entries); 1420 + result = vdo_allocate(count, __func__, &repair->entries); 1422 1421 if (result != VDO_SUCCESS) 1423 1422 return result; 1424 1423 ··· 1463 1464 * Allocate an array of numbered_block_mapping structs just large enough to transcribe 1464 1465 * every packed_recovery_journal_entry from every valid journal block. 1465 1466 */ 1466 - result = vdo_allocate(repair->entry_count, struct numbered_block_mapping, 1467 - __func__, &repair->entries); 1467 + result = vdo_allocate(repair->entry_count, __func__, &repair->entries); 1468 1468 if (result != VDO_SUCCESS) 1469 1469 return result; 1470 1470 ··· 1725 1727 prepare_repair_completion(repair, finish_repair, VDO_ZONE_TYPE_ADMIN); 1726 1728 repair->page_count = page_count; 1727 1729 1728 - result = vdo_allocate(remaining * VDO_BLOCK_SIZE, char, __func__, 1729 - &repair->journal_data); 1730 + result = vdo_allocate(remaining * VDO_BLOCK_SIZE, __func__, &repair->journal_data); 1730 1731 if (abort_on_error(result, repair)) 1731 1732 return; 1732 1733 1733 - result = vdo_allocate(vio_count, struct vio, __func__, &repair->vios); 1734 + result = vdo_allocate(vio_count, __func__, &repair->vios); 1734 1735 if (abort_on_error(result, repair)) 1735 1736 return; 1736 1737
+12 -20
drivers/md/dm-vdo/slab-depot.c
··· 2453 2453 if (result != VDO_SUCCESS) 2454 2454 return result; 2455 2455 2456 - result = vdo_allocate(slab->reference_block_count, struct reference_block, 2457 - __func__, &slab->reference_blocks); 2456 + result = vdo_allocate(slab->reference_block_count, __func__, &slab->reference_blocks); 2458 2457 if (result != VDO_SUCCESS) 2459 2458 return result; 2460 2459 ··· 2462 2463 * so we can word-search even at the very end. 2463 2464 */ 2464 2465 bytes = (slab->reference_block_count * COUNTS_PER_BLOCK) + (2 * BYTES_PER_WORD); 2465 - result = vdo_allocate(bytes, vdo_refcount_t, "ref counts array", 2466 - &slab->counters); 2466 + result = vdo_allocate(bytes, "ref counts array", &slab->counters); 2467 2467 if (result != VDO_SUCCESS) { 2468 2468 vdo_free(vdo_forget(slab->reference_blocks)); 2469 2469 return result; ··· 3561 3563 struct slab_status *statuses; 3562 3564 struct slab_iterator iterator = get_slab_iterator(allocator); 3563 3565 3564 - result = vdo_allocate(allocator->slab_count, struct slab_status, __func__, 3565 - &statuses); 3566 + result = vdo_allocate(allocator->slab_count, __func__, &statuses); 3566 3567 if (result != VDO_SUCCESS) 3567 3568 return result; 3568 3569 ··· 3736 3739 const struct slab_config *slab_config = &slab->allocator->depot->slab_config; 3737 3740 int result; 3738 3741 3739 - result = vdo_allocate(slab_config->slab_journal_blocks, struct journal_lock, 3740 - __func__, &journal->locks); 3742 + result = vdo_allocate(slab_config->slab_journal_blocks, __func__, &journal->locks); 3741 3743 if (result != VDO_SUCCESS) 3742 3744 return result; 3743 3745 3744 - result = vdo_allocate(VDO_BLOCK_SIZE, char, "struct packed_slab_journal_block", 3745 - (char **) &journal->block); 3746 + BUILD_BUG_ON(sizeof(*journal->block) != VDO_BLOCK_SIZE); 3747 + result = vdo_allocate(1, "struct packed_slab_journal_block", &journal->block); 3746 3748 if (result != VDO_SUCCESS) 3747 3749 return result; 3748 3750 ··· 3796 3800 struct vdo_slab *slab; 3797 3801 int result; 3798 3802 3799 - result = vdo_allocate(1, struct vdo_slab, __func__, &slab); 3803 + result = vdo_allocate(1, __func__, &slab); 3800 3804 if (result != VDO_SUCCESS) 3801 3805 return result; 3802 3806 ··· 3853 3857 physical_block_number_t slab_origin; 3854 3858 int result; 3855 3859 3856 - result = vdo_allocate(slab_count, struct vdo_slab *, 3857 - "slab pointer array", &depot->new_slabs); 3860 + result = vdo_allocate(slab_count, "slab pointer array", &depot->new_slabs); 3858 3861 if (result != VDO_SUCCESS) 3859 3862 return result; 3860 3863 ··· 4006 4011 char *journal_data; 4007 4012 int result; 4008 4013 4009 - result = vdo_allocate(VDO_BLOCK_SIZE * slab_journal_size, 4010 - char, __func__, &journal_data); 4014 + result = vdo_allocate(VDO_BLOCK_SIZE * slab_journal_size, __func__, &journal_data); 4011 4015 if (result != VDO_SUCCESS) 4012 4016 return result; 4013 4017 ··· 4039 4045 struct slab_summary_block *block = &allocator->summary_blocks[index]; 4040 4046 int result; 4041 4047 4042 - result = vdo_allocate(VDO_BLOCK_SIZE, char, __func__, &block->outgoing_entries); 4048 + result = vdo_allocate(VDO_BLOCK_SIZE, __func__, &block->outgoing_entries); 4043 4049 if (result != VDO_SUCCESS) 4044 4050 return result; 4045 4051 ··· 4108 4114 if (result != VDO_SUCCESS) 4109 4115 return result; 4110 4116 4111 - result = vdo_allocate(VDO_SLAB_SUMMARY_BLOCKS_PER_ZONE, 4112 - struct slab_summary_block, __func__, 4117 + result = vdo_allocate(VDO_SLAB_SUMMARY_BLOCKS_PER_ZONE, __func__, 4113 4118 &allocator->summary_blocks); 4114 4119 if (result != VDO_SUCCESS) 4115 4120 return result; ··· 4167 4174 4168 4175 depot->summary_origin = summary_partition->offset; 4169 4176 depot->hint_shift = vdo_get_slab_summary_hint_shift(depot->slab_size_shift); 4170 - result = vdo_allocate(MAXIMUM_VDO_SLAB_SUMMARY_ENTRIES, 4171 - struct slab_summary_entry, __func__, 4177 + result = vdo_allocate(MAXIMUM_VDO_SLAB_SUMMARY_ENTRIES, __func__, 4172 4178 &depot->summary_entries); 4173 4179 if (result != VDO_SUCCESS) 4174 4180 return result;
+1 -1
drivers/md/dm-vdo/thread-utils.c
··· 56 56 struct thread *thread; 57 57 int result; 58 58 59 - result = vdo_allocate(1, struct thread, __func__, &thread); 59 + result = vdo_allocate(1, __func__, &thread); 60 60 if (result != VDO_SUCCESS) { 61 61 vdo_log_warning("Error allocating memory for %s", name); 62 62 return result;
+14 -18
drivers/md/dm-vdo/vdo.c
··· 207 207 config->hash_zone_count = counts.hash_zones; 208 208 } 209 209 210 - result = vdo_allocate(config->logical_zone_count, thread_id_t, 211 - "logical thread array", &config->logical_threads); 210 + result = vdo_allocate(config->logical_zone_count, "logical thread array", 211 + &config->logical_threads); 212 212 if (result != VDO_SUCCESS) { 213 213 uninitialize_thread_config(config); 214 214 return result; 215 215 } 216 216 217 - result = vdo_allocate(config->physical_zone_count, thread_id_t, 218 - "physical thread array", &config->physical_threads); 217 + result = vdo_allocate(config->physical_zone_count, "physical thread array", 218 + &config->physical_threads); 219 219 if (result != VDO_SUCCESS) { 220 220 uninitialize_thread_config(config); 221 221 return result; 222 222 } 223 223 224 - result = vdo_allocate(config->hash_zone_count, thread_id_t, 225 - "hash thread array", &config->hash_zone_threads); 224 + result = vdo_allocate(config->hash_zone_count, "hash thread array", 225 + &config->hash_zone_threads); 226 226 if (result != VDO_SUCCESS) { 227 227 uninitialize_thread_config(config); 228 228 return result; 229 229 } 230 230 231 - result = vdo_allocate(config->bio_thread_count, thread_id_t, 232 - "bio thread array", &config->bio_threads); 231 + result = vdo_allocate(config->bio_thread_count, "bio thread array", &config->bio_threads); 233 232 if (result != VDO_SUCCESS) { 234 233 uninitialize_thread_config(config); 235 234 return result; ··· 268 269 char *block; 269 270 int result; 270 271 271 - result = vdo_allocate(VDO_BLOCK_SIZE, u8, __func__, &block); 272 + result = vdo_allocate(VDO_BLOCK_SIZE, __func__, &block); 272 273 if (result != VDO_SUCCESS) 273 274 return result; 274 275 ··· 492 493 config->thread_counts.hash_zones, vdo->thread_config.thread_count); 493 494 494 495 /* Compression context storage */ 495 - result = vdo_allocate(config->thread_counts.cpu_threads, char *, "LZ4 context", 496 + result = vdo_allocate(config->thread_counts.cpu_threads, "LZ4 context", 496 497 &vdo->compression_context); 497 498 if (result != VDO_SUCCESS) { 498 499 *reason = "cannot allocate LZ4 context"; ··· 500 501 } 501 502 502 503 for (i = 0; i < config->thread_counts.cpu_threads; i++) { 503 - result = vdo_allocate(LZ4_MEM_COMPRESS, char, "LZ4 context", 504 + result = vdo_allocate(LZ4_MEM_COMPRESS, "LZ4 context", 504 505 &vdo->compression_context[i]); 505 506 if (result != VDO_SUCCESS) { 506 507 *reason = "cannot allocate LZ4 context"; ··· 536 537 /* Initialize with a generic failure reason to prevent returning garbage. */ 537 538 *reason = "Unspecified error"; 538 539 539 - result = vdo_allocate(1, struct vdo, __func__, &vdo); 540 + result = vdo_allocate(1, __func__, &vdo); 540 541 if (result != VDO_SUCCESS) { 541 542 *reason = "Cannot allocate VDO"; 542 543 return result; ··· 553 554 554 555 snprintf(vdo->thread_name_prefix, sizeof(vdo->thread_name_prefix), 555 556 "vdo%u", instance); 556 - result = vdo_allocate(vdo->thread_config.thread_count, 557 - struct vdo_thread, __func__, &vdo->threads); 557 + result = vdo_allocate(vdo->thread_config.thread_count, __func__, &vdo->threads); 558 558 if (result != VDO_SUCCESS) { 559 559 *reason = "Cannot allocate thread structures"; 560 560 return result; ··· 722 724 { 723 725 int result; 724 726 725 - result = vdo_allocate(VDO_BLOCK_SIZE, char, "encoded super block", 726 - (char **) &vdo->super_block.buffer); 727 + result = vdo_allocate(VDO_BLOCK_SIZE, "encoded super block", &vdo->super_block.buffer); 727 728 if (result != VDO_SUCCESS) 728 729 return result; 729 730 ··· 994 997 if (result != VDO_SUCCESS) 995 998 return result; 996 999 997 - result = vdo_allocate(1, struct read_only_listener, __func__, 998 - &read_only_listener); 1000 + result = vdo_allocate(1, __func__, &read_only_listener); 999 1001 if (result != VDO_SUCCESS) 1000 1002 return result; 1001 1003
+2 -3
drivers/md/dm-vdo/vio.c
··· 129 129 * Metadata vios should use direct allocation and not use the buffer pool, which is 130 130 * reserved for submissions from the linux block layer. 131 131 */ 132 - result = vdo_allocate(1, struct vio, __func__, &vio); 132 + result = vdo_allocate(1, __func__, &vio); 133 133 if (result != VDO_SUCCESS) { 134 134 vdo_log_error("metadata vio allocation failure %d", result); 135 135 return result; ··· 335 335 INIT_LIST_HEAD(&pool->available); 336 336 INIT_LIST_HEAD(&pool->busy); 337 337 338 - result = vdo_allocate(pool_size * per_vio_size, char, 339 - "VIO pool buffer", &pool->buffer); 338 + result = vdo_allocate(pool_size * per_vio_size, "VIO pool buffer", &pool->buffer); 340 339 if (result != VDO_SUCCESS) { 341 340 free_vio_pool(pool); 342 341 return result;