aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/persistent-data/dm-array.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/md/persistent-data/dm-array.c')
-rw-r--r--drivers/md/persistent-data/dm-array.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/drivers/md/persistent-data/dm-array.c b/drivers/md/persistent-data/dm-array.c
index 172147eb1d40..1d75b1dc1e2e 100644
--- a/drivers/md/persistent-data/dm-array.c
+++ b/drivers/md/persistent-data/dm-array.c
@@ -317,8 +317,16 @@ static int shadow_ablock(struct dm_array_info *info, dm_block_t *root,
317 * The shadow op will often be a noop. Only insert if it really 317 * The shadow op will often be a noop. Only insert if it really
318 * copied data. 318 * copied data.
319 */ 319 */
320 if (dm_block_location(*block) != b) 320 if (dm_block_location(*block) != b) {
321 /*
322 * dm_tm_shadow_block will have already decremented the old
323 * block, but it is still referenced by the btree. We
324 * increment to stop the insert decrementing it below zero
325 * when overwriting the old value.
326 */
327 dm_tm_inc(info->btree_info.tm, b);
321 r = insert_ablock(info, index, *block, root); 328 r = insert_ablock(info, index, *block, root);
329 }
322 330
323 return r; 331 return r;
324} 332}
@@ -509,15 +517,18 @@ static int grow_add_tail_block(struct resize *resize)
509static int grow_needs_more_blocks(struct resize *resize) 517static int grow_needs_more_blocks(struct resize *resize)
510{ 518{
511 int r; 519 int r;
520 unsigned old_nr_blocks = resize->old_nr_full_blocks;
512 521
513 if (resize->old_nr_entries_in_last_block > 0) { 522 if (resize->old_nr_entries_in_last_block > 0) {
523 old_nr_blocks++;
524
514 r = grow_extend_tail_block(resize, resize->max_entries); 525 r = grow_extend_tail_block(resize, resize->max_entries);
515 if (r) 526 if (r)
516 return r; 527 return r;
517 } 528 }
518 529
519 r = insert_full_ablocks(resize->info, resize->size_of_block, 530 r = insert_full_ablocks(resize->info, resize->size_of_block,
520 resize->old_nr_full_blocks, 531 old_nr_blocks,
521 resize->new_nr_full_blocks, 532 resize->new_nr_full_blocks,
522 resize->max_entries, resize->value, 533 resize->max_entries, resize->value,
523 &resize->root); 534 &resize->root);