diff options
author | Joe Thornber <ejt@redhat.com> | 2016-10-05 10:40:39 -0400 |
---|---|---|
committer | Mike Snitzer <snitzer@redhat.com> | 2017-02-16 13:12:50 -0500 |
commit | 9b696229aa7de356675a938c6c8a70b46085ed66 (patch) | |
tree | 19ab9da696f91ed4987a091854d8a8cd8dd6a5bb /drivers/md/persistent-data/dm-array.c | |
parent | 683bb1a3742bb0c8768711aa5ff1034d92e447f2 (diff) |
dm persistent data: add cursor skip functions to the cursor APIs
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.c')
-rw-r--r-- | drivers/md/persistent-data/dm-array.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/drivers/md/persistent-data/dm-array.c b/drivers/md/persistent-data/dm-array.c index 7938cd21fa4c..185dc60360b5 100644 --- a/drivers/md/persistent-data/dm-array.c +++ b/drivers/md/persistent-data/dm-array.c | |||
@@ -976,6 +976,27 @@ int dm_array_cursor_next(struct dm_array_cursor *c) | |||
976 | } | 976 | } |
977 | EXPORT_SYMBOL_GPL(dm_array_cursor_next); | 977 | EXPORT_SYMBOL_GPL(dm_array_cursor_next); |
978 | 978 | ||
979 | int dm_array_cursor_skip(struct dm_array_cursor *c, uint32_t count) | ||
980 | { | ||
981 | int r; | ||
982 | |||
983 | do { | ||
984 | uint32_t remaining = le32_to_cpu(c->ab->nr_entries) - c->index; | ||
985 | |||
986 | if (count < remaining) { | ||
987 | c->index += count; | ||
988 | return 0; | ||
989 | } | ||
990 | |||
991 | count -= remaining; | ||
992 | r = dm_array_cursor_next(c); | ||
993 | |||
994 | } while (!r); | ||
995 | |||
996 | return r; | ||
997 | } | ||
998 | EXPORT_SYMBOL_GPL(dm_array_cursor_skip); | ||
999 | |||
979 | void dm_array_cursor_get_value(struct dm_array_cursor *c, void **value_le) | 1000 | void dm_array_cursor_get_value(struct dm_array_cursor *c, void **value_le) |
980 | { | 1001 | { |
981 | *value_le = element_at(c->info, c->ab, c->index); | 1002 | *value_le = element_at(c->info, c->ab, c->index); |