diff options
Diffstat (limited to 'drivers/md/persistent-data/dm-btree-spine.c')
-rw-r--r-- | drivers/md/persistent-data/dm-btree-spine.c | 44 |
1 files changed, 14 insertions, 30 deletions
diff --git a/drivers/md/persistent-data/dm-btree-spine.c b/drivers/md/persistent-data/dm-btree-spine.c index b27b8091a1ca..e653458888a7 100644 --- a/drivers/md/persistent-data/dm-btree-spine.c +++ b/drivers/md/persistent-data/dm-btree-spine.c @@ -15,10 +15,6 @@ #define BTREE_CSUM_XOR 121107 -static int node_check(struct dm_block_validator *v, - struct dm_block *b, - size_t block_size); - static void node_prepare_for_write(struct dm_block_validator *v, struct dm_block *b, size_t block_size) @@ -30,8 +26,6 @@ static void node_prepare_for_write(struct dm_block_validator *v, h->csum = cpu_to_le32(dm_bm_checksum(&h->flags, block_size - sizeof(__le32), BTREE_CSUM_XOR)); - - BUG_ON(node_check(v, b, 4096)); } static int node_check(struct dm_block_validator *v, @@ -42,7 +36,7 @@ static int node_check(struct dm_block_validator *v, struct node_header *h = &n->header; size_t value_size; __le32 csum_disk; - uint32_t flags; + uint32_t flags, nr_entries, max_entries; if (dm_block_location(b) != le64_to_cpu(h->blocknr)) { DMERR_LIMIT("node_check failed: blocknr %llu != wanted %llu", @@ -59,15 +53,17 @@ static int node_check(struct dm_block_validator *v, return -EILSEQ; } + nr_entries = le32_to_cpu(h->nr_entries); + max_entries = le32_to_cpu(h->max_entries); value_size = le32_to_cpu(h->value_size); if (sizeof(struct node_header) + - (sizeof(__le64) + value_size) * le32_to_cpu(h->max_entries) > block_size) { + (sizeof(__le64) + value_size) * max_entries > block_size) { DMERR_LIMIT("node_check failed: max_entries too large"); return -EILSEQ; } - if (le32_to_cpu(h->nr_entries) > le32_to_cpu(h->max_entries)) { + if (nr_entries > max_entries) { DMERR_LIMIT("node_check failed: too many entries"); return -EILSEQ; } @@ -132,15 +128,13 @@ void init_ro_spine(struct ro_spine *s, struct dm_btree_info *info) s->nodes[1] = NULL; } -int exit_ro_spine(struct ro_spine *s) +void exit_ro_spine(struct ro_spine *s) { - int r = 0, i; + int i; for (i = 0; i < s->count; i++) { unlock_block(s->info, s->nodes[i]); } - - return r; } int ro_step(struct ro_spine *s, dm_block_t new_child) @@ -185,15 +179,13 @@ void init_shadow_spine(struct shadow_spine *s, struct dm_btree_info *info) s->count = 0; } -int exit_shadow_spine(struct shadow_spine *s) +void exit_shadow_spine(struct shadow_spine *s) { - int r = 0, i; + int i; for (i = 0; i < s->count; i++) { unlock_block(s->info, s->nodes[i]); } - - return r; } int shadow_step(struct shadow_spine *s, dm_block_t b, @@ -237,27 +229,19 @@ int shadow_has_parent(struct shadow_spine *s) return s->count >= 2; } -int shadow_root(struct shadow_spine *s) +dm_block_t shadow_root(struct shadow_spine *s) { return s->root; } -static void le64_inc(void *context, const void *value_le) +static void le64_inc(void *context, const void *value_le, unsigned count) { - struct dm_transaction_manager *tm = context; - __le64 v_le; - - memcpy(&v_le, value_le, sizeof(v_le)); - dm_tm_inc(tm, le64_to_cpu(v_le)); + dm_tm_with_runs(context, value_le, count, dm_tm_inc_range); } -static void le64_dec(void *context, const void *value_le) +static void le64_dec(void *context, const void *value_le, unsigned count) { - struct dm_transaction_manager *tm = context; - __le64 v_le; - - memcpy(&v_le, value_le, sizeof(v_le)); - dm_tm_dec(tm, le64_to_cpu(v_le)); + dm_tm_with_runs(context, value_le, count, dm_tm_dec_range); } static int le64_equal(void *context, const void *value1_le, const void *value2_le) |