diff options
author | Joe Thornber <ejt@redhat.com> | 2016-10-05 16:40:39 +0200 |
---|---|---|
committer | Mike Snitzer <snitzer@redhat.com> | 2017-02-16 19:12:50 +0100 |
commit | 9b696229aa7de356675a938c6c8a70b46085ed66 (patch) | |
tree | 19ab9da696f91ed4987a091854d8a8cd8dd6a5bb /drivers/md/persistent-data/dm-array.c | |
parent | dm cache metadata: use dm_bitset_new() to create the dirty bitset in format 2 (diff) | |
download | linux-9b696229aa7de356675a938c6c8a70b46085ed66.tar.xz linux-9b696229aa7de356675a938c6c8a70b46085ed66.zip |
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) } EXPORT_SYMBOL_GPL(dm_array_cursor_next); +int dm_array_cursor_skip(struct dm_array_cursor *c, uint32_t count) +{ + int r; + + do { + uint32_t remaining = le32_to_cpu(c->ab->nr_entries) - c->index; + + if (count < remaining) { + c->index += count; + return 0; + } + + count -= remaining; + r = dm_array_cursor_next(c); + + } while (!r); + + return r; +} +EXPORT_SYMBOL_GPL(dm_array_cursor_skip); + void dm_array_cursor_get_value(struct dm_array_cursor *c, void **value_le) { *value_le = element_at(c->info, c->ab, c->index); |