Skip to contentSkip to conversation

dm vdo: clean up hash maps

PATCH New Matthew Sakai 1 participant 4 messages Nov 20, 2023

Subsystems (2)
lore
Share & tools
lore

Matthew Sakai

author maintainer
#0 lore raw

cover dm vdo: clean up hash maps

Remove duplicate pointer-map code and clean up int-map interface.

Bruce Johnston (3):
dm vdo: remove pointer-map
dm vdo int-map: rename functions to match device-mapper name style dm vdo int-map: remove unused parameter from vdo_int_map_create

 drivers/md/dm-vdo/block-map.c     |  12 +-
 drivers/md/dm-vdo/dedupe.c        |  50 ++-
 drivers/md/dm-vdo/dedupe.h        |   2 +-
 drivers/md/dm-vdo/int-map.c       |  29 +-
 drivers/md/dm-vdo/int-map.h       |   9 +-
 drivers/md/dm-vdo/io-submitter.c  |   8 +-
 drivers/md/dm-vdo/logical-zone.c  |   4 +-
 drivers/md/dm-vdo/physical-zone.c |   8 +-
 drivers/md/dm-vdo/pointer-map.c   | 696 ------------------------------
 drivers/md/dm-vdo/pointer-map.h   |  81 ----
 10 files changed, 57 insertions(+), 842 deletions(-)
 delete mode 100644 drivers/md/dm-vdo/pointer-map.c
 delete mode 100644 drivers/md/dm-vdo/pointer-map.h
Signature · 1 line
2.42.0
author maintainer
#2 lore raw

PATCH 2/3 dm vdo int-map: rename functions to match device-mapper name style

From: Bruce Johnston <[email protected]>

---
 drivers/md/dm-vdo/block-map.c     | 12 ++++++------
 drivers/md/dm-vdo/dedupe.c        |  6 +++---
 drivers/md/dm-vdo/int-map.c       | 20 ++++++++++++--------
 drivers/md/dm-vdo/int-map.h       | 10 +++++-----
 drivers/md/dm-vdo/io-submitter.c  |  8 ++++----
 drivers/md/dm-vdo/logical-zone.c  |  4 ++--
 drivers/md/dm-vdo/physical-zone.c |  8 ++++----
 7 files changed, 36 insertions(+), 32 deletions(-)
drivers/md/dm-vdo/block-map.c +6 -6
index c5cb9da5d33e..953819943cd3 100644
@@ -232,7 +232,7 @@ static int __must_check allocate_cache_components(struct vdo_page_cache *cache)
 	if (result != UDS_SUCCESS)
 		return result;
 
-	result = vdo_make_int_map(cache->page_count, 0, &cache->page_map);
+	result = vdo_int_map_create(cache->page_count, 0, &cache->page_map);
 	if (result != UDS_SUCCESS)
 		return result;
 
@@ -1346,8 +1346,8 @@ int vdo_invalidate_page_cache(struct vdo_page_cache *cache)
 	}
 
 	/* Reset the page map by re-allocating it. */
-	vdo_free_int_map(uds_forget(cache->page_map));
-	return vdo_make_int_map(cache->page_count, 0, &cache->page_map);
+	vdo_int_map_free(uds_forget(cache->page_map));
+	return vdo_int_map_create(cache->page_count, 0, &cache->page_map);
 }
 
 /**
@@ -2751,7 +2751,7 @@ static int __must_check initialize_block_map_zone(struct block_map *map,
 		INIT_LIST_HEAD(&zone->dirty_lists->eras[i][VDO_CACHE_PAGE]);
 	}
 
-	result = vdo_make_int_map(VDO_LOCK_MAP_CAPACITY, 0, &zone->loading_pages);
+	result = vdo_int_map_create(VDO_LOCK_MAP_CAPACITY, 0, &zone->loading_pages);
 	if (result != VDO_SUCCESS)
 		return result;
 
@@ -2831,7 +2831,7 @@ static void uninitialize_block_map_zone(struct block_map_zone *zone)
 
 	uds_free(uds_forget(zone->dirty_lists));
 	free_vio_pool(uds_forget(zone->vio_pool));
-	vdo_free_int_map(uds_forget(zone->loading_pages));
+	vdo_int_map_free(uds_forget(zone->loading_pages));
 	if (cache->infos != NULL) {
 		struct page_info *info;
 
@@ -2839,7 +2839,7 @@ static void uninitialize_block_map_zone(struct block_map_zone *zone)
 			free_vio(uds_forget(info->vio));
 	}
 
-	vdo_free_int_map(uds_forget(cache->page_map));
+	vdo_int_map_free(uds_forget(cache->page_map));
 	uds_free(uds_forget(cache->infos));
 	uds_free(uds_forget(cache->pages));
 }
drivers/md/dm-vdo/dedupe.c +3 -3
index 00ad2e66872d..b40ba499303f 100644
@@ -2405,8 +2405,8 @@ static int __must_check initialize_zone(struct vdo *vdo, struct hash_zones *zone
 	data_vio_count_t i;
 	struct hash_zone *zone = &zones->zones[zone_number];
 
-	result = vdo_make_int_map(VDO_LOCK_MAP_CAPACITY, 0,
-				  &zone->hash_lock_map);
+	result = vdo_int_map_create(VDO_LOCK_MAP_CAPACITY, 0,
+				    &zone->hash_lock_map);
 	if (result != VDO_SUCCESS)
 		return result;
 
@@ -2530,7 +2530,7 @@ void vdo_free_hash_zones(struct hash_zones *zones)
 		struct hash_zone *zone = &zones->zones[i];
 
 		uds_free_funnel_queue(uds_forget(zone->timed_out_complete));
-		vdo_free_int_map(uds_forget(zone->hash_lock_map));
+		vdo_int_map_free(uds_forget(zone->hash_lock_map));
 		uds_free(uds_forget(zone->lock_array));
 	}
 
drivers/md/dm-vdo/int-map.c +12 -8
index 463a4951e0d1..94f13df7a2e1 100644
@@ -171,7 +171,7 @@ static int allocate_buckets(struct int_map *map, size_t capacity)
 }
 
 /**
- * vdo_make_int_map() - Allocate and initialize an int_map.
+ * vdo_int_map_create() - Allocate and initialize an int_map.
  * @initial_capacity: The number of entries the map should initially be capable of holding (zero
  *                    tells the map to use its own small default).
  * @initial_load: The load factor of the map, expressed as an integer percentage (typically in the
@@ -180,7 +180,8 @@ static int allocate_buckets(struct int_map *map, size_t capacity)
  *
  * Return: UDS_SUCCESS or an error code.
  */
-int vdo_make_int_map(size_t initial_capacity, unsigned int initial_load, struct int_map **map_ptr)
+int vdo_int_map_create(size_t initial_capacity, unsigned int initial_load,
+		       struct int_map **map_ptr)
 {
 	struct int_map *map;
 	int result;
@@ -207,7 +208,7 @@ int vdo_make_int_map(size_t initial_capacity, unsigned int initial_load, struct
 
 	result = allocate_buckets(map, capacity);
 	if (result != UDS_SUCCESS) {
-		vdo_free_int_map(uds_forget(map));
+		vdo_int_map_free(uds_forget(map));
 		return result;
 	}
 
@@ -216,13 +217,13 @@ int vdo_make_int_map(size_t initial_capacity, unsigned int initial_load, struct
 }
 
 /**
- * vdo_free_int_map() - Free an int_map.
+ * vdo_int_map_free() - Free an int_map.
  * @map: The int_map to free.
  *
  * NOTE: The map does not own the pointer values stored in the map and they are not freed by this
  * call.
  */
-void vdo_free_int_map(struct int_map *map)
+void vdo_int_map_free(struct int_map *map)
 {
 	if (map == NULL)
 		return;
@@ -464,7 +465,8 @@ find_empty_bucket(struct int_map *map, struct bucket *bucket, unsigned int max_p
  * Return: The bucket that was vacated by moving its entry to the provided hole, or NULL if no
  *         entry could be moved.
  */
-static struct bucket *move_empty_bucket(struct int_map *map __always_unused, struct bucket *hole)
+static struct bucket *move_empty_bucket(struct int_map *map __always_unused,
+					struct bucket *hole)
 {
 	/*
 	 * Examine every neighborhood that the empty bucket is part of, starting with the one in
@@ -572,7 +574,8 @@ static bool update_mapping(struct int_map *map,
  * Return: a pointer to an empty bucket in the desired neighborhood, or NULL if a vacancy could not
  *         be found or arranged.
  */
-static struct bucket *find_or_make_vacancy(struct int_map *map, struct bucket *neighborhood)
+static struct bucket *find_or_make_vacancy(struct int_map *map,
+					   struct bucket *neighborhood)
 {
 	/* Probe within and beyond the neighborhood for the first empty bucket. */
 	struct bucket *hole = find_empty_bucket(map, neighborhood, MAX_PROBES);
@@ -619,7 +622,8 @@ static struct bucket *find_or_make_vacancy(struct int_map *map, struct bucket *n
  *
  * Return: UDS_SUCCESS or an error code.
  */
-int vdo_int_map_put(struct int_map *map, u64 key, void *new_value, bool update, void **old_value_ptr)
+int vdo_int_map_put(struct int_map *map, u64 key, void *new_value, bool update,
+		    void **old_value_ptr)
 {
 	struct bucket *neighborhood, *bucket;
 
drivers/md/dm-vdo/int-map.h +5 -5
index e85f12b30edc..edafb7569f51 100644
@@ -23,17 +23,17 @@
 
 struct int_map;
 
-int __must_check
-vdo_make_int_map(size_t initial_capacity, unsigned int initial_load, struct int_map **map_ptr);
+int __must_check vdo_int_map_create(size_t initial_capacity, unsigned int initial_load,
+				    struct int_map **map_ptr);
 
-void vdo_free_int_map(struct int_map *map);
+void vdo_int_map_free(struct int_map *map);
 
 size_t vdo_int_map_size(const struct int_map *map);
 
 void *vdo_int_map_get(struct int_map *map, u64 key);
 
-int __must_check
-vdo_int_map_put(struct int_map *map, u64 key, void *new_value, bool update, void **old_value_ptr);
+int __must_check vdo_int_map_put(struct int_map *map, u64 key, void *new_value,
+				 bool update, void **old_value_ptr);
 
 void *vdo_int_map_remove(struct int_map *map, u64 key);
 
drivers/md/dm-vdo/io-submitter.c +4 -4
index 39f5f202d69d..9471b6caabe6 100644
@@ -401,8 +401,8 @@ int vdo_make_io_submitter(unsigned int thread_count, unsigned int rotation_inter
 		 * uneven. So for now, we'll assume that all requests *may* wind up on one thread,
 		 * and thus all in the same map.
 		 */
-		result = vdo_make_int_map(max_requests_active * 2, 0,
-					  &bio_queue_data->map);
+		result = vdo_int_map_create(max_requests_active * 2, 0,
+					    &bio_queue_data->map);
 		if (result != 0) {
 			/*
 			 * Clean up the partially initialized bio-queue entirely and indicate that
@@ -422,7 +422,7 @@ int vdo_make_io_submitter(unsigned int thread_count, unsigned int rotation_inter
 			 * Clean up the partially initialized bio-queue entirely and indicate that
 			 * initialization failed.
 			 */
-			vdo_free_int_map(uds_forget(bio_queue_data->map));
+			vdo_int_map_free(uds_forget(bio_queue_data->map));
 			uds_log_error("bio queue initialization failed %d", result);
 			vdo_cleanup_io_submitter(io_submitter);
 			vdo_free_io_submitter(io_submitter);
@@ -471,7 +471,7 @@ void vdo_free_io_submitter(struct io_submitter *io_submitter)
 		io_submitter->num_bio_queues_used--;
 		/* vdo_destroy() will free the work queue, so just give up our reference to it. */
 		uds_forget(io_submitter->bio_queue_data[i].queue);
-		vdo_free_int_map(uds_forget(io_submitter->bio_queue_data[i].map));
+		vdo_int_map_free(uds_forget(io_submitter->bio_queue_data[i].map));
 	}
 	uds_free(io_submitter);
 }
drivers/md/dm-vdo/logical-zone.c +2 -2
index 7140e202798f..df69fb68db3d 100644
@@ -57,7 +57,7 @@ static int initialize_zone(struct logical_zones *zones, zone_count_t zone_number
 	struct logical_zone *zone = &zones->zones[zone_number];
 	zone_count_t allocation_zone_number;
 
-	result = vdo_make_int_map(VDO_LOCK_MAP_CAPACITY, 0, &zone->lbn_operations);
+	result = vdo_int_map_create(VDO_LOCK_MAP_CAPACITY, 0, &zone->lbn_operations);
 	if (result != VDO_SUCCESS)
 		return result;
 
@@ -137,7 +137,7 @@ void vdo_free_logical_zones(struct logical_zones *zones)
 	uds_free(uds_forget(zones->manager));
 
 	for (index = 0; index < zones->zone_count; index++)
-		vdo_free_int_map(uds_forget(zones->zones[index].lbn_operations));
+		vdo_int_map_free(uds_forget(zones->zones[index].lbn_operations));
 
 	uds_free(zones);
 }
drivers/md/dm-vdo/physical-zone.c +4 -4
index 9b99c9a820a3..8ecc80ecbb53 100644
@@ -330,13 +330,13 @@ static int initialize_zone(struct vdo *vdo, struct physical_zones *zones)
 	zone_count_t zone_number = zones->zone_count;
 	struct physical_zone *zone = &zones->zones[zone_number];
 
-	result = vdo_make_int_map(VDO_LOCK_MAP_CAPACITY, 0, &zone->pbn_operations);
+	result = vdo_int_map_create(VDO_LOCK_MAP_CAPACITY, 0, &zone->pbn_operations);
 	if (result != VDO_SUCCESS)
 		return result;
 
 	result = make_pbn_lock_pool(LOCK_POOL_CAPACITY, &zone->lock_pool);
 	if (result != VDO_SUCCESS) {
-		vdo_free_int_map(zone->pbn_operations);
+		vdo_int_map_free(zone->pbn_operations);
 		return result;
 	}
 
@@ -347,7 +347,7 @@ static int initialize_zone(struct vdo *vdo, struct physical_zones *zones)
 	result = vdo_make_default_thread(vdo, zone->thread_id);
 	if (result != VDO_SUCCESS) {
 		free_pbn_lock_pool(uds_forget(zone->lock_pool));
-		vdo_free_int_map(zone->pbn_operations);
+		vdo_int_map_free(zone->pbn_operations);
 		return result;
 	}
 	return result;
@@ -401,7 +401,7 @@ void vdo_free_physical_zones(struct physical_zones *zones)
 		struct physical_zone *zone = &zones->zones[index];
 
 		free_pbn_lock_pool(uds_forget(zone->lock_pool));
-		vdo_free_int_map(uds_forget(zone->pbn_operations));
+		vdo_int_map_free(uds_forget(zone->pbn_operations));
 	}
 
 	uds_free(zones);
Signature · 1 line
2.42.0
author maintainer
#3 lore raw

PATCH 3/3 dm vdo int-map: remove unused parameter from vdo_int_map_create

In reply to Matthew Sakai

From: Bruce Johnston <[email protected]>

---
 drivers/md/dm-vdo/block-map.c     |  6 +++---
 drivers/md/dm-vdo/dedupe.c        |  2 +-
 drivers/md/dm-vdo/int-map.c       | 13 ++-----------
 drivers/md/dm-vdo/int-map.h       |  3 +--
 drivers/md/dm-vdo/io-submitter.c  |  2 +-
 drivers/md/dm-vdo/logical-zone.c  |  2 +-
 drivers/md/dm-vdo/physical-zone.c |  2 +-
 7 files changed, 10 insertions(+), 20 deletions(-)
drivers/md/dm-vdo/block-map.c +3 -3
index 953819943cd3..f9f68e8d4b0c 100644
@@ -232,7 +232,7 @@ static int __must_check allocate_cache_components(struct vdo_page_cache *cache)
 	if (result != UDS_SUCCESS)
 		return result;
 
-	result = vdo_int_map_create(cache->page_count, 0, &cache->page_map);
+	result = vdo_int_map_create(cache->page_count, &cache->page_map);
 	if (result != UDS_SUCCESS)
 		return result;
 
@@ -1347,7 +1347,7 @@ int vdo_invalidate_page_cache(struct vdo_page_cache *cache)
 
 	/* Reset the page map by re-allocating it. */
 	vdo_int_map_free(uds_forget(cache->page_map));
-	return vdo_int_map_create(cache->page_count, 0, &cache->page_map);
+	return vdo_int_map_create(cache->page_count, &cache->page_map);
 }
 
 /**
@@ -2751,7 +2751,7 @@ static int __must_check initialize_block_map_zone(struct block_map *map,
 		INIT_LIST_HEAD(&zone->dirty_lists->eras[i][VDO_CACHE_PAGE]);
 	}
 
-	result = vdo_int_map_create(VDO_LOCK_MAP_CAPACITY, 0, &zone->loading_pages);
+	result = vdo_int_map_create(VDO_LOCK_MAP_CAPACITY, &zone->loading_pages);
 	if (result != VDO_SUCCESS)
 		return result;
 
drivers/md/dm-vdo/dedupe.c +1 -1
index b40ba499303f..dd3ee8e46b61 100644
@@ -2405,7 +2405,7 @@ static int __must_check initialize_zone(struct vdo *vdo, struct hash_zones *zone
 	data_vio_count_t i;
 	struct hash_zone *zone = &zones->zones[zone_number];
 
-	result = vdo_int_map_create(VDO_LOCK_MAP_CAPACITY, 0,
+	result = vdo_int_map_create(VDO_LOCK_MAP_CAPACITY,
 				    &zone->hash_lock_map);
 	if (result != VDO_SUCCESS)
 		return result;
drivers/md/dm-vdo/int-map.c +2 -11
index 94f13df7a2e1..99ccbb1339c6 100644
@@ -174,25 +174,16 @@ static int allocate_buckets(struct int_map *map, size_t capacity)
  * vdo_int_map_create() - Allocate and initialize an int_map.
  * @initial_capacity: The number of entries the map should initially be capable of holding (zero
  *                    tells the map to use its own small default).
- * @initial_load: The load factor of the map, expressed as an integer percentage (typically in the
- *                range 50 to 90, with zero telling the map to use its own default).
  * @map_ptr: Output, a pointer to hold the new int_map.
  *
  * Return: UDS_SUCCESS or an error code.
  */
-int vdo_int_map_create(size_t initial_capacity, unsigned int initial_load,
-		       struct int_map **map_ptr)
+int vdo_int_map_create(size_t initial_capacity, struct int_map **map_ptr)
 {
 	struct int_map *map;
 	int result;
 	size_t capacity;
 
-	/* Use the default initial load if the caller did not specify one. */
-	if (initial_load == 0)
-		initial_load = DEFAULT_LOAD;
-	if (initial_load > 100)
-		return UDS_INVALID_ARGUMENT;
-
 	result = uds_allocate(1, struct int_map, "struct int_map", &map);
 	if (result != UDS_SUCCESS)
 		return result;
@@ -204,7 +195,7 @@ int vdo_int_map_create(size_t initial_capacity, unsigned int initial_load,
 	 * Scale up the capacity by the specified initial load factor. (i.e to hold 1000 entries at
 	 * 80% load we need a capacity of 1250)
 	 */
-	capacity = capacity * 100 / initial_load;
+	capacity = capacity * 100 / DEFAULT_LOAD;
 
 	result = allocate_buckets(map, capacity);
 	if (result != UDS_SUCCESS) {
drivers/md/dm-vdo/int-map.h +1 -2
index edafb7569f51..1858ad799887 100644
@@ -23,8 +23,7 @@
 
 struct int_map;
 
-int __must_check vdo_int_map_create(size_t initial_capacity, unsigned int initial_load,
-				    struct int_map **map_ptr);
+int __must_check vdo_int_map_create(size_t initial_capacity, struct int_map **map_ptr);
 
 void vdo_int_map_free(struct int_map *map);
 
drivers/md/dm-vdo/io-submitter.c +1 -1
index 9471b6caabe6..74f33a3ddce5 100644
@@ -401,7 +401,7 @@ int vdo_make_io_submitter(unsigned int thread_count, unsigned int rotation_inter
 		 * uneven. So for now, we'll assume that all requests *may* wind up on one thread,
 		 * and thus all in the same map.
 		 */
-		result = vdo_int_map_create(max_requests_active * 2, 0,
+		result = vdo_int_map_create(max_requests_active * 2,
 					    &bio_queue_data->map);
 		if (result != 0) {
 			/*
drivers/md/dm-vdo/logical-zone.c +1 -1
index df69fb68db3d..cfbf1701ca84 100644
@@ -57,7 +57,7 @@ static int initialize_zone(struct logical_zones *zones, zone_count_t zone_number
 	struct logical_zone *zone = &zones->zones[zone_number];
 	zone_count_t allocation_zone_number;
 
-	result = vdo_int_map_create(VDO_LOCK_MAP_CAPACITY, 0, &zone->lbn_operations);
+	result = vdo_int_map_create(VDO_LOCK_MAP_CAPACITY, &zone->lbn_operations);
 	if (result != VDO_SUCCESS)
 		return result;
 
drivers/md/dm-vdo/physical-zone.c +1 -1
index 8ecc80ecbb53..3bcf6f1ba77f 100644
@@ -330,7 +330,7 @@ static int initialize_zone(struct vdo *vdo, struct physical_zones *zones)
 	zone_count_t zone_number = zones->zone_count;
 	struct physical_zone *zone = &zones->zones[zone_number];
 
-	result = vdo_int_map_create(VDO_LOCK_MAP_CAPACITY, 0, &zone->pbn_operations);
+	result = vdo_int_map_create(VDO_LOCK_MAP_CAPACITY, &zone->pbn_operations);
 	if (result != VDO_SUCCESS)
 		return result;
 
Signature · 1 line
2.42.0
author maintainer
#1 lore raw

PATCH 1/3 dm vdo: remove pointer-map

In reply to Matthew Sakai

From: Bruce Johnston <[email protected]>

---
 drivers/md/dm-vdo/dedupe.c      |  50 ++-
 drivers/md/dm-vdo/dedupe.h      |   2 +-
 drivers/md/dm-vdo/pointer-map.c | 696 --------------------------------
 drivers/md/dm-vdo/pointer-map.h |  81 ----
 4 files changed, 25 insertions(+), 804 deletions(-)
 delete mode 100644 drivers/md/dm-vdo/pointer-map.c
 delete mode 100644 drivers/md/dm-vdo/pointer-map.h
drivers/md/dm-vdo/dedupe.c +24 -26
index f882d56581dc..00ad2e66872d 100644
@@ -133,10 +133,10 @@
 #include "completion.h"
 #include "constants.h"
 #include "data-vio.h"
+#include "int-map.h"
 #include "io-submitter.h"
 #include "packer.h"
 #include "physical-zone.h"
-#include "pointer-map.h"
 #include "slab-depot.h"
 #include "statistics.h"
 #include "types.h"
@@ -370,6 +370,17 @@ struct pbn_lock *vdo_get_duplicate_lock(struct data_vio *data_vio)
 	return data_vio->hash_lock->duplicate_lock;
 }
 
+/**
+ * get_hash_lock_key() - Get the hash lock key to use in int-map.
+ * @lock: The hash lock.
+ *
+ * Return: The key to use for the int map.
+ */
+static u64 get_hash_lock_key(struct hash_lock *lock)
+{
+	return get_unaligned_le64(&lock->hash.name);
+}
+
 /**
  * get_hash_lock_state_name() - Get the string representation of a hash lock state.
  * @state: The hash lock state.
@@ -865,7 +876,7 @@ static int __must_check acquire_lock(struct hash_zone *zone,
 	int result;
 
 	/*
-	 * Borrow and prepare a lock from the pool so we don't have to do two pointer_map accesses
+	 * Borrow and prepare a lock from the pool so we don't have to do two int_map accesses
 	 * in the common case of no lock contention.
 	 */
 	result = ASSERT(!list_empty(&zone->lock_pool),
@@ -882,8 +893,9 @@ static int __must_check acquire_lock(struct hash_zone *zone,
 	 */
 	new_lock->hash = *hash;
 
-	result = vdo_pointer_map_put(zone->hash_lock_map, &new_lock->hash, new_lock,
-				     (replace_lock != NULL), (void **) &lock);
+	result = vdo_int_map_put(zone->hash_lock_map, get_hash_lock_key(new_lock),
+				 new_lock, (replace_lock != NULL),
+				 (void **) &lock);
 	if (result != VDO_SUCCESS) {
 		return_hash_lock_to_pool(zone, uds_forget(new_lock));
 		return result;
@@ -1904,6 +1916,7 @@ void vdo_acquire_hash_lock(struct vdo_completion *completion)
  */
 void vdo_release_hash_lock(struct data_vio *data_vio)
 {
+	u64 lock_key;
 	struct hash_lock *lock = data_vio->hash_lock;
 	struct hash_zone *zone = data_vio->hash_zone;
 
@@ -1917,14 +1930,15 @@ void vdo_release_hash_lock(struct data_vio *data_vio)
 		return;
 	}
 
+	lock_key = get_hash_lock_key(lock);
 	if (lock->registered) {
 		struct hash_lock *removed;
 
-		removed = vdo_pointer_map_remove(zone->hash_lock_map, &lock->hash);
+		removed = vdo_int_map_remove(zone->hash_lock_map, lock_key);
 		ASSERT_LOG_ONLY(lock == removed,
 				"hash lock being released must have been mapped");
 	} else {
-		ASSERT_LOG_ONLY(lock != vdo_pointer_map_get(zone->hash_lock_map, &lock->hash),
+		ASSERT_LOG_ONLY(lock != vdo_int_map_get(zone->hash_lock_map, lock_key),
 				"unregistered hash lock must not be in the lock map");
 	}
 
@@ -2011,22 +2025,6 @@ void vdo_share_compressed_write_lock(struct data_vio *data_vio,
 	ASSERT_LOG_ONLY(claimed, "impossible to fail to claim an initial increment");
 }
 
-/** compare_keys() - Implements pointer_key_comparator_fn. */
-static bool compare_keys(const void *this_key, const void *that_key)
-{
-	/* Null keys are not supported. */
-	return (memcmp(this_key, that_key, sizeof(struct uds_record_name)) == 0);
-}
-
-/** hash_key() - Implements pointer_key_comparator_fn. */
-static u32 hash_key(const void *key)
-{
-	const struct uds_record_name *name = key;
-
-	/* Use a fragment of the record name as a hash code. */
-	return get_unaligned_le32(&name->name[4]);
-}
-
 static void dedupe_kobj_release(struct kobject *directory)
 {
 	uds_free(container_of(directory, struct hash_zones, dedupe_directory));
@@ -2407,8 +2405,8 @@ static int __must_check initialize_zone(struct vdo *vdo, struct hash_zones *zone
 	data_vio_count_t i;
 	struct hash_zone *zone = &zones->zones[zone_number];
 
-	result = vdo_make_pointer_map(VDO_LOCK_MAP_CAPACITY, 0, compare_keys,
-				      hash_key, &zone->hash_lock_map);
+	result = vdo_make_int_map(VDO_LOCK_MAP_CAPACITY, 0,
+				  &zone->hash_lock_map);
 	if (result != VDO_SUCCESS)
 		return result;
 
@@ -2532,7 +2530,7 @@ void vdo_free_hash_zones(struct hash_zones *zones)
 		struct hash_zone *zone = &zones->zones[i];
 
 		uds_free_funnel_queue(uds_forget(zone->timed_out_complete));
-		vdo_free_pointer_map(uds_forget(zone->hash_lock_map));
+		vdo_free_int_map(uds_forget(zone->hash_lock_map));
 		uds_free(uds_forget(zone->lock_array));
 	}
 
@@ -2847,7 +2845,7 @@ static void dump_hash_zone(const struct hash_zone *zone)
 	}
 
 	uds_log_info("struct hash_zone %u: mapSize=%zu",
-		     zone->zone_number, vdo_pointer_map_size(zone->hash_lock_map));
+		     zone->zone_number, vdo_int_map_size(zone->hash_lock_map));
 	for (i = 0; i < LOCK_POOL_CAPACITY; i++)
 		dump_hash_lock(&zone->lock_array[i]);
 }
drivers/md/dm-vdo/dedupe.h +1 -1
index 90c5779bfe70..773dde5f9365 100644
@@ -40,7 +40,7 @@ struct hash_zone {
 	thread_id_t thread_id;
 
 	/* Mapping from record name fields to hash_locks */
-	struct pointer_map *hash_lock_map;
+	struct int_map *hash_lock_map;
 
 	/* List containing all unused hash_locks */
 	struct list_head lock_pool;
drivers/md/dm-vdo/pointer-map.c deleted +0 -696

696 lines not on this page · raw message

drivers/md/dm-vdo/pointer-map.h deleted +0 -81

81 lines not on this page · raw message

Signature · 1 line
2.42.0