mirror of
https://github.com/torvalds/linux.git
synced 2026-04-18 14:53:58 -04:00
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>
This commit is contained in:
committed by
Mike Snitzer
parent
683bb1a374
commit
9b696229aa
@@ -273,6 +273,41 @@ int dm_bitset_cursor_next(struct dm_bitset_cursor *c)
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(dm_bitset_cursor_next);
|
||||
|
||||
int dm_bitset_cursor_skip(struct dm_bitset_cursor *c, uint32_t count)
|
||||
{
|
||||
int r;
|
||||
__le64 *value;
|
||||
uint32_t nr_array_skip;
|
||||
uint32_t remaining_in_word = 64 - c->bit_index;
|
||||
|
||||
if (c->entries_remaining < count)
|
||||
return -ENODATA;
|
||||
|
||||
if (count < remaining_in_word) {
|
||||
c->bit_index += count;
|
||||
c->entries_remaining -= count;
|
||||
return 0;
|
||||
|
||||
} else {
|
||||
c->entries_remaining -= remaining_in_word;
|
||||
count -= remaining_in_word;
|
||||
}
|
||||
|
||||
nr_array_skip = (count / 64) + 1;
|
||||
r = dm_array_cursor_skip(&c->cursor, nr_array_skip);
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
dm_array_cursor_get_value(&c->cursor, (void **) &value);
|
||||
c->entries_remaining -= count;
|
||||
c->array_index += nr_array_skip;
|
||||
c->bit_index = count & 63;
|
||||
c->current_bits = le64_to_cpu(*value);
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(dm_bitset_cursor_skip);
|
||||
|
||||
bool dm_bitset_cursor_get_value(struct dm_bitset_cursor *c)
|
||||
{
|
||||
return test_bit(c->bit_index, (unsigned long *) &c->current_bits);
|
||||
|
||||
Reference in New Issue
Block a user