summaryrefslogtreecommitdiff
path: root/drivers/md/persistent-data/dm-array.h
diff options
context:
space:
mode:
authorJoe Thornber <ejt@redhat.com>2016-09-15 08:45:44 -0400
committerMike Snitzer <snitzer@redhat.com>2016-09-22 11:12:23 -0400
commitdd6a77d99859ab963503e67372ed278fe8ceab26 (patch)
tree8cf6068e462644ecb1cbbd91c5abf3fd570fa887 /drivers/md/persistent-data/dm-array.h
parentb88efd43f900d608560211a18a38d450f8192948 (diff)
dm array: add dm_array_new()
dm_array_new() creates a new, populated array more efficiently than starting with an empty one and resizing. Signed-off-by: Joe Thornber <ejt@redhat.com> Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Diffstat (limited to 'drivers/md/persistent-data/dm-array.h')
-rw-r--r--drivers/md/persistent-data/dm-array.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/drivers/md/persistent-data/dm-array.h b/drivers/md/persistent-data/dm-array.h
index ea177d6fa58f..45ea3f6e1ded 100644
--- a/drivers/md/persistent-data/dm-array.h
+++ b/drivers/md/persistent-data/dm-array.h
@@ -112,6 +112,25 @@ int dm_array_resize(struct dm_array_info *info, dm_block_t root,
__dm_written_to_disk(value);
/*
+ * Creates a new array populated with values provided by a callback
+ * function. This is more efficient than creating an empty array,
+ * resizing, and then setting values since that process incurs a lot of
+ * copying.
+ *
+ * Assumes 32bit values for now since it's only used by the cache hint
+ * array.
+ *
+ * info - describes the array
+ * root - the root block of the array on disk
+ * size - the number of entries in the array
+ * fn - the callback
+ * context - passed to the callback
+ */
+typedef int (*value_fn)(uint32_t index, void *value_le, void *context);
+int dm_array_new(struct dm_array_info *info, dm_block_t *root,
+ uint32_t size, value_fn fn, void *context);
+
+/*
* Frees a whole array. The value_type's decrement operation will be called
* for all values in the array
*/