mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-23 07:12:09 +00:00
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>
This commit is contained in:
parent
b88efd43f9
commit
dd6a77d998
2 changed files with 130 additions and 31 deletions
|
@ -111,6 +111,25 @@ int dm_array_resize(struct dm_array_info *info, dm_block_t root,
|
|||
const void *value, dm_block_t *new_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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue