diff options
author | Joe Thornber <ejt@redhat.com> | 2016-09-15 17:11:42 +0200 |
---|---|---|
committer | Mike Snitzer <snitzer@redhat.com> | 2016-09-22 17:15:04 +0200 |
commit | fdd1315aa5f022fe6574efdc2d9535f75a0ee255 (patch) | |
tree | 769113eca5f6a1594247d62410dbd829e74d8fd3 /drivers/md/persistent-data/dm-array.h | |
parent | dm btree: introduce cursor api (diff) | |
download | linux-fdd1315aa5f022fe6574efdc2d9535f75a0ee255.tar.xz linux-fdd1315aa5f022fe6574efdc2d9535f75a0ee255.zip |
dm array: introduce cursor api
More efficient way to iterate an array due to prefetching (makes use of
the new dm_btree_cursor_* api).
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.h | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/drivers/md/persistent-data/dm-array.h b/drivers/md/persistent-data/dm-array.h index 45ea3f6e1ded..27ee49a55473 100644 --- a/drivers/md/persistent-data/dm-array.h +++ b/drivers/md/persistent-data/dm-array.h @@ -182,4 +182,37 @@ int dm_array_walk(struct dm_array_info *info, dm_block_t root, /*----------------------------------------------------------------*/ +/* + * Cursor api. + * + * This lets you iterate through all the entries in an array efficiently + * (it will preload metadata). + * + * I'm using a cursor, rather than a walk function with a callback because + * the cache target needs to iterate both the mapping and hint arrays in + * unison. + */ +struct dm_array_cursor { + struct dm_array_info *info; + struct dm_btree_cursor cursor; + + struct dm_block *block; + struct array_block *ab; + unsigned index; +}; + +int dm_array_cursor_begin(struct dm_array_info *info, + dm_block_t root, struct dm_array_cursor *c); +void dm_array_cursor_end(struct dm_array_cursor *c); + +uint32_t dm_array_cursor_index(struct dm_array_cursor *c); +int dm_array_cursor_next(struct dm_array_cursor *c); + +/* + * value_le is only valid while the cursor points at the current value. + */ +void dm_array_cursor_get_value(struct dm_array_cursor *c, void **value_le); + +/*----------------------------------------------------------------*/ + #endif /* _LINUX_DM_ARRAY_H */ |