diff options
Diffstat (limited to 'drivers/md/persistent-data/dm-btree-remove.c')
-rw-r--r-- | drivers/md/persistent-data/dm-btree-remove.c | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/drivers/md/persistent-data/dm-btree-remove.c b/drivers/md/persistent-data/dm-btree-remove.c index aa71e2359a07..c4f28133ef82 100644 --- a/drivers/md/persistent-data/dm-btree-remove.c +++ b/drivers/md/persistent-data/dm-btree-remove.c | |||
@@ -53,7 +53,7 @@ | |||
53 | /* | 53 | /* |
54 | * Some little utilities for moving node data around. | 54 | * Some little utilities for moving node data around. |
55 | */ | 55 | */ |
56 | static void node_shift(struct node *n, int shift) | 56 | static void node_shift(struct btree_node *n, int shift) |
57 | { | 57 | { |
58 | uint32_t nr_entries = le32_to_cpu(n->header.nr_entries); | 58 | uint32_t nr_entries = le32_to_cpu(n->header.nr_entries); |
59 | uint32_t value_size = le32_to_cpu(n->header.value_size); | 59 | uint32_t value_size = le32_to_cpu(n->header.value_size); |
@@ -79,7 +79,7 @@ static void node_shift(struct node *n, int shift) | |||
79 | } | 79 | } |
80 | } | 80 | } |
81 | 81 | ||
82 | static void node_copy(struct node *left, struct node *right, int shift) | 82 | static void node_copy(struct btree_node *left, struct btree_node *right, int shift) |
83 | { | 83 | { |
84 | uint32_t nr_left = le32_to_cpu(left->header.nr_entries); | 84 | uint32_t nr_left = le32_to_cpu(left->header.nr_entries); |
85 | uint32_t value_size = le32_to_cpu(left->header.value_size); | 85 | uint32_t value_size = le32_to_cpu(left->header.value_size); |
@@ -108,7 +108,7 @@ static void node_copy(struct node *left, struct node *right, int shift) | |||
108 | /* | 108 | /* |
109 | * Delete a specific entry from a leaf node. | 109 | * Delete a specific entry from a leaf node. |
110 | */ | 110 | */ |
111 | static void delete_at(struct node *n, unsigned index) | 111 | static void delete_at(struct btree_node *n, unsigned index) |
112 | { | 112 | { |
113 | unsigned nr_entries = le32_to_cpu(n->header.nr_entries); | 113 | unsigned nr_entries = le32_to_cpu(n->header.nr_entries); |
114 | unsigned nr_to_copy = nr_entries - (index + 1); | 114 | unsigned nr_to_copy = nr_entries - (index + 1); |
@@ -128,7 +128,7 @@ static void delete_at(struct node *n, unsigned index) | |||
128 | n->header.nr_entries = cpu_to_le32(nr_entries - 1); | 128 | n->header.nr_entries = cpu_to_le32(nr_entries - 1); |
129 | } | 129 | } |
130 | 130 | ||
131 | static unsigned merge_threshold(struct node *n) | 131 | static unsigned merge_threshold(struct btree_node *n) |
132 | { | 132 | { |
133 | return le32_to_cpu(n->header.max_entries) / 3; | 133 | return le32_to_cpu(n->header.max_entries) / 3; |
134 | } | 134 | } |
@@ -136,7 +136,7 @@ static unsigned merge_threshold(struct node *n) | |||
136 | struct child { | 136 | struct child { |
137 | unsigned index; | 137 | unsigned index; |
138 | struct dm_block *block; | 138 | struct dm_block *block; |
139 | struct node *n; | 139 | struct btree_node *n; |
140 | }; | 140 | }; |
141 | 141 | ||
142 | static struct dm_btree_value_type le64_type = { | 142 | static struct dm_btree_value_type le64_type = { |
@@ -147,7 +147,7 @@ static struct dm_btree_value_type le64_type = { | |||
147 | .equal = NULL | 147 | .equal = NULL |
148 | }; | 148 | }; |
149 | 149 | ||
150 | static int init_child(struct dm_btree_info *info, struct node *parent, | 150 | static int init_child(struct dm_btree_info *info, struct btree_node *parent, |
151 | unsigned index, struct child *result) | 151 | unsigned index, struct child *result) |
152 | { | 152 | { |
153 | int r, inc; | 153 | int r, inc; |
@@ -177,7 +177,7 @@ static int exit_child(struct dm_btree_info *info, struct child *c) | |||
177 | return dm_tm_unlock(info->tm, c->block); | 177 | return dm_tm_unlock(info->tm, c->block); |
178 | } | 178 | } |
179 | 179 | ||
180 | static void shift(struct node *left, struct node *right, int count) | 180 | static void shift(struct btree_node *left, struct btree_node *right, int count) |
181 | { | 181 | { |
182 | uint32_t nr_left = le32_to_cpu(left->header.nr_entries); | 182 | uint32_t nr_left = le32_to_cpu(left->header.nr_entries); |
183 | uint32_t nr_right = le32_to_cpu(right->header.nr_entries); | 183 | uint32_t nr_right = le32_to_cpu(right->header.nr_entries); |
@@ -203,11 +203,11 @@ static void shift(struct node *left, struct node *right, int count) | |||
203 | right->header.nr_entries = cpu_to_le32(nr_right + count); | 203 | right->header.nr_entries = cpu_to_le32(nr_right + count); |
204 | } | 204 | } |
205 | 205 | ||
206 | static void __rebalance2(struct dm_btree_info *info, struct node *parent, | 206 | static void __rebalance2(struct dm_btree_info *info, struct btree_node *parent, |
207 | struct child *l, struct child *r) | 207 | struct child *l, struct child *r) |
208 | { | 208 | { |
209 | struct node *left = l->n; | 209 | struct btree_node *left = l->n; |
210 | struct node *right = r->n; | 210 | struct btree_node *right = r->n; |
211 | uint32_t nr_left = le32_to_cpu(left->header.nr_entries); | 211 | uint32_t nr_left = le32_to_cpu(left->header.nr_entries); |
212 | uint32_t nr_right = le32_to_cpu(right->header.nr_entries); | 212 | uint32_t nr_right = le32_to_cpu(right->header.nr_entries); |
213 | unsigned threshold = 2 * merge_threshold(left) + 1; | 213 | unsigned threshold = 2 * merge_threshold(left) + 1; |
@@ -239,7 +239,7 @@ static int rebalance2(struct shadow_spine *s, struct dm_btree_info *info, | |||
239 | unsigned left_index) | 239 | unsigned left_index) |
240 | { | 240 | { |
241 | int r; | 241 | int r; |
242 | struct node *parent; | 242 | struct btree_node *parent; |
243 | struct child left, right; | 243 | struct child left, right; |
244 | 244 | ||
245 | parent = dm_block_data(shadow_current(s)); | 245 | parent = dm_block_data(shadow_current(s)); |
@@ -270,9 +270,9 @@ static int rebalance2(struct shadow_spine *s, struct dm_btree_info *info, | |||
270 | * in right, then rebalance2. This wastes some cpu, but I want something | 270 | * in right, then rebalance2. This wastes some cpu, but I want something |
271 | * simple atm. | 271 | * simple atm. |
272 | */ | 272 | */ |
273 | static void delete_center_node(struct dm_btree_info *info, struct node *parent, | 273 | static void delete_center_node(struct dm_btree_info *info, struct btree_node *parent, |
274 | struct child *l, struct child *c, struct child *r, | 274 | struct child *l, struct child *c, struct child *r, |
275 | struct node *left, struct node *center, struct node *right, | 275 | struct btree_node *left, struct btree_node *center, struct btree_node *right, |
276 | uint32_t nr_left, uint32_t nr_center, uint32_t nr_right) | 276 | uint32_t nr_left, uint32_t nr_center, uint32_t nr_right) |
277 | { | 277 | { |
278 | uint32_t max_entries = le32_to_cpu(left->header.max_entries); | 278 | uint32_t max_entries = le32_to_cpu(left->header.max_entries); |
@@ -301,9 +301,9 @@ static void delete_center_node(struct dm_btree_info *info, struct node *parent, | |||
301 | /* | 301 | /* |
302 | * Redistributes entries among 3 sibling nodes. | 302 | * Redistributes entries among 3 sibling nodes. |
303 | */ | 303 | */ |
304 | static void redistribute3(struct dm_btree_info *info, struct node *parent, | 304 | static void redistribute3(struct dm_btree_info *info, struct btree_node *parent, |
305 | struct child *l, struct child *c, struct child *r, | 305 | struct child *l, struct child *c, struct child *r, |
306 | struct node *left, struct node *center, struct node *right, | 306 | struct btree_node *left, struct btree_node *center, struct btree_node *right, |
307 | uint32_t nr_left, uint32_t nr_center, uint32_t nr_right) | 307 | uint32_t nr_left, uint32_t nr_center, uint32_t nr_right) |
308 | { | 308 | { |
309 | int s; | 309 | int s; |
@@ -343,12 +343,12 @@ static void redistribute3(struct dm_btree_info *info, struct node *parent, | |||
343 | *key_ptr(parent, r->index) = right->keys[0]; | 343 | *key_ptr(parent, r->index) = right->keys[0]; |
344 | } | 344 | } |
345 | 345 | ||
346 | static void __rebalance3(struct dm_btree_info *info, struct node *parent, | 346 | static void __rebalance3(struct dm_btree_info *info, struct btree_node *parent, |
347 | struct child *l, struct child *c, struct child *r) | 347 | struct child *l, struct child *c, struct child *r) |
348 | { | 348 | { |
349 | struct node *left = l->n; | 349 | struct btree_node *left = l->n; |
350 | struct node *center = c->n; | 350 | struct btree_node *center = c->n; |
351 | struct node *right = r->n; | 351 | struct btree_node *right = r->n; |
352 | 352 | ||
353 | uint32_t nr_left = le32_to_cpu(left->header.nr_entries); | 353 | uint32_t nr_left = le32_to_cpu(left->header.nr_entries); |
354 | uint32_t nr_center = le32_to_cpu(center->header.nr_entries); | 354 | uint32_t nr_center = le32_to_cpu(center->header.nr_entries); |
@@ -371,7 +371,7 @@ static int rebalance3(struct shadow_spine *s, struct dm_btree_info *info, | |||
371 | unsigned left_index) | 371 | unsigned left_index) |
372 | { | 372 | { |
373 | int r; | 373 | int r; |
374 | struct node *parent = dm_block_data(shadow_current(s)); | 374 | struct btree_node *parent = dm_block_data(shadow_current(s)); |
375 | struct child left, center, right; | 375 | struct child left, center, right; |
376 | 376 | ||
377 | /* | 377 | /* |
@@ -421,7 +421,7 @@ static int get_nr_entries(struct dm_transaction_manager *tm, | |||
421 | { | 421 | { |
422 | int r; | 422 | int r; |
423 | struct dm_block *block; | 423 | struct dm_block *block; |
424 | struct node *n; | 424 | struct btree_node *n; |
425 | 425 | ||
426 | r = dm_tm_read_lock(tm, b, &btree_node_validator, &block); | 426 | r = dm_tm_read_lock(tm, b, &btree_node_validator, &block); |
427 | if (r) | 427 | if (r) |
@@ -438,7 +438,7 @@ static int rebalance_children(struct shadow_spine *s, | |||
438 | { | 438 | { |
439 | int i, r, has_left_sibling, has_right_sibling; | 439 | int i, r, has_left_sibling, has_right_sibling; |
440 | uint32_t child_entries; | 440 | uint32_t child_entries; |
441 | struct node *n; | 441 | struct btree_node *n; |
442 | 442 | ||
443 | n = dm_block_data(shadow_current(s)); | 443 | n = dm_block_data(shadow_current(s)); |
444 | 444 | ||
@@ -483,7 +483,7 @@ static int rebalance_children(struct shadow_spine *s, | |||
483 | return r; | 483 | return r; |
484 | } | 484 | } |
485 | 485 | ||
486 | static int do_leaf(struct node *n, uint64_t key, unsigned *index) | 486 | static int do_leaf(struct btree_node *n, uint64_t key, unsigned *index) |
487 | { | 487 | { |
488 | int i = lower_bound(n, key); | 488 | int i = lower_bound(n, key); |
489 | 489 | ||
@@ -506,7 +506,7 @@ static int remove_raw(struct shadow_spine *s, struct dm_btree_info *info, | |||
506 | uint64_t key, unsigned *index) | 506 | uint64_t key, unsigned *index) |
507 | { | 507 | { |
508 | int i = *index, r; | 508 | int i = *index, r; |
509 | struct node *n; | 509 | struct btree_node *n; |
510 | 510 | ||
511 | for (;;) { | 511 | for (;;) { |
512 | r = shadow_step(s, root, vt); | 512 | r = shadow_step(s, root, vt); |
@@ -556,7 +556,7 @@ int dm_btree_remove(struct dm_btree_info *info, dm_block_t root, | |||
556 | unsigned level, last_level = info->levels - 1; | 556 | unsigned level, last_level = info->levels - 1; |
557 | int index = 0, r = 0; | 557 | int index = 0, r = 0; |
558 | struct shadow_spine spine; | 558 | struct shadow_spine spine; |
559 | struct node *n; | 559 | struct btree_node *n; |
560 | 560 | ||
561 | init_shadow_spine(&spine, info); | 561 | init_shadow_spine(&spine, info); |
562 | for (level = 0; level < info->levels; level++) { | 562 | for (level = 0; level < info->levels; level++) { |