Lines Matching refs:smm

183 static int add_bop(struct sm_metadata *smm, enum block_op_type type, dm_block_t b, dm_block_t e)  in add_bop()  argument
185 int r = brb_push(&smm->uncommitted, type, b, e); in add_bop()
195 static int commit_bop(struct sm_metadata *smm, struct block_op *op) in commit_bop() argument
202 r = sm_ll_inc(&smm->ll, op->b, op->e, &nr_allocations); in commit_bop()
206 r = sm_ll_dec(&smm->ll, op->b, op->e, &nr_allocations); in commit_bop()
213 static void in(struct sm_metadata *smm) in in() argument
215 smm->recursion_count++; in in()
218 static int apply_bops(struct sm_metadata *smm) in apply_bops() argument
222 while (!brb_empty(&smm->uncommitted)) { in apply_bops()
225 r = brb_peek(&smm->uncommitted, &bop); in apply_bops()
231 r = commit_bop(smm, &bop); in apply_bops()
235 brb_pop(&smm->uncommitted); in apply_bops()
241 static int out(struct sm_metadata *smm) in out() argument
248 if (!smm->recursion_count) { in out()
253 if (smm->recursion_count == 1) in out()
254 r = apply_bops(smm); in out()
256 smm->recursion_count--; in out()
271 static int recursing(struct sm_metadata *smm) in recursing() argument
273 return smm->recursion_count; in recursing()
278 struct sm_metadata *smm = container_of(sm, struct sm_metadata, sm); in sm_metadata_destroy() local
280 kvfree(smm); in sm_metadata_destroy()
285 struct sm_metadata *smm = container_of(sm, struct sm_metadata, sm); in sm_metadata_get_nr_blocks() local
287 *count = smm->ll.nr_blocks; in sm_metadata_get_nr_blocks()
294 struct sm_metadata *smm = container_of(sm, struct sm_metadata, sm); in sm_metadata_get_nr_free() local
296 *count = smm->old_ll.nr_blocks - smm->old_ll.nr_allocated - in sm_metadata_get_nr_free()
297 smm->allocated_this_transaction; in sm_metadata_get_nr_free()
307 struct sm_metadata *smm = container_of(sm, struct sm_metadata, sm); in sm_metadata_get_count() local
314 for (i = smm->uncommitted.begin; in sm_metadata_get_count()
315 i != smm->uncommitted.end; in sm_metadata_get_count()
316 i = brb_next(&smm->uncommitted, i)) { in sm_metadata_get_count()
317 struct block_op *op = smm->uncommitted.bops + i; in sm_metadata_get_count()
333 r = sm_ll_lookup(&smm->ll, b, result); in sm_metadata_get_count()
347 struct sm_metadata *smm = container_of(sm, struct sm_metadata, sm); in sm_metadata_count_is_more_than_one() local
354 for (i = smm->uncommitted.begin; in sm_metadata_count_is_more_than_one()
355 i != smm->uncommitted.end; in sm_metadata_count_is_more_than_one()
356 i = brb_next(&smm->uncommitted, i)) { in sm_metadata_count_is_more_than_one()
358 struct block_op *op = smm->uncommitted.bops + i; in sm_metadata_count_is_more_than_one()
379 r = sm_ll_lookup_bitmap(&smm->ll, b, &rc); in sm_metadata_count_is_more_than_one()
399 struct sm_metadata *smm = container_of(sm, struct sm_metadata, sm); in sm_metadata_set_count() local
401 if (smm->recursion_count) { in sm_metadata_set_count()
406 in(smm); in sm_metadata_set_count()
407 r = sm_ll_insert(&smm->ll, b, count, &nr_allocations); in sm_metadata_set_count()
408 r2 = out(smm); in sm_metadata_set_count()
417 struct sm_metadata *smm = container_of(sm, struct sm_metadata, sm); in sm_metadata_inc_blocks() local
419 if (recursing(smm)) { in sm_metadata_inc_blocks()
420 r = add_bop(smm, BOP_INC, b, e); in sm_metadata_inc_blocks()
424 in(smm); in sm_metadata_inc_blocks()
425 r = sm_ll_inc(&smm->ll, b, e, &nr_allocations); in sm_metadata_inc_blocks()
426 r2 = out(smm); in sm_metadata_inc_blocks()
436 struct sm_metadata *smm = container_of(sm, struct sm_metadata, sm); in sm_metadata_dec_blocks() local
438 if (recursing(smm)) in sm_metadata_dec_blocks()
439 r = add_bop(smm, BOP_DEC, b, e); in sm_metadata_dec_blocks()
441 in(smm); in sm_metadata_dec_blocks()
442 r = sm_ll_dec(&smm->ll, b, e, &nr_allocations); in sm_metadata_dec_blocks()
443 r2 = out(smm); in sm_metadata_dec_blocks()
453 struct sm_metadata *smm = container_of(sm, struct sm_metadata, sm); in sm_metadata_new_block_() local
458 r = sm_ll_find_common_free_block(&smm->old_ll, &smm->ll, smm->begin, smm->ll.nr_blocks, b); in sm_metadata_new_block_()
464 r = sm_ll_find_common_free_block(&smm->old_ll, &smm->ll, 0, smm->begin, b); in sm_metadata_new_block_()
470 smm->begin = *b + 1; in sm_metadata_new_block_()
472 if (recursing(smm)) in sm_metadata_new_block_()
473 r = add_bop(smm, BOP_INC, *b, *b + 1); in sm_metadata_new_block_()
475 in(smm); in sm_metadata_new_block_()
476 r = sm_ll_inc(&smm->ll, *b, *b + 1, &nr_allocations); in sm_metadata_new_block_()
477 r2 = out(smm); in sm_metadata_new_block_()
481 smm->allocated_this_transaction++; in sm_metadata_new_block_()
489 struct sm_metadata *smm = container_of(sm, struct sm_metadata, sm); in sm_metadata_new_block() local
504 check_threshold(&smm->threshold, count); in sm_metadata_new_block()
512 struct sm_metadata *smm = container_of(sm, struct sm_metadata, sm); in sm_metadata_commit() local
514 r = sm_ll_commit(&smm->ll); in sm_metadata_commit()
518 memcpy(&smm->old_ll, &smm->ll, sizeof(smm->old_ll)); in sm_metadata_commit()
519 smm->allocated_this_transaction = 0; in sm_metadata_commit()
529 struct sm_metadata *smm = container_of(sm, struct sm_metadata, sm); in sm_metadata_register_threshold_callback() local
531 set_threshold(&smm->threshold, threshold, fn, context); in sm_metadata_register_threshold_callback()
545 struct sm_metadata *smm = container_of(sm, struct sm_metadata, sm); in sm_metadata_copy_root() local
548 root_le.nr_blocks = cpu_to_le64(smm->ll.nr_blocks); in sm_metadata_copy_root()
549 root_le.nr_allocated = cpu_to_le64(smm->ll.nr_allocated); in sm_metadata_copy_root()
550 root_le.bitmap_root = cpu_to_le64(smm->ll.bitmap_root); in sm_metadata_copy_root()
551 root_le.ref_count_root = cpu_to_le64(smm->ll.ref_count_root); in sm_metadata_copy_root()
599 struct sm_metadata *smm = container_of(sm, struct sm_metadata, sm); in sm_bootstrap_get_nr_blocks() local
601 *count = smm->ll.nr_blocks; in sm_bootstrap_get_nr_blocks()
608 struct sm_metadata *smm = container_of(sm, struct sm_metadata, sm); in sm_bootstrap_get_nr_free() local
610 *count = smm->ll.nr_blocks - smm->begin; in sm_bootstrap_get_nr_free()
618 struct sm_metadata *smm = container_of(sm, struct sm_metadata, sm); in sm_bootstrap_get_count() local
620 *result = (b < smm->begin) ? 1 : 0; in sm_bootstrap_get_count()
643 struct sm_metadata *smm = container_of(sm, struct sm_metadata, sm); in sm_bootstrap_new_block() local
648 if (smm->begin == smm->ll.nr_blocks) in sm_bootstrap_new_block()
651 *b = smm->begin++; in sm_bootstrap_new_block()
659 struct sm_metadata *smm = container_of(sm, struct sm_metadata, sm); in sm_bootstrap_inc_blocks() local
661 r = add_bop(smm, BOP_INC, b, e); in sm_bootstrap_inc_blocks()
671 struct sm_metadata *smm = container_of(sm, struct sm_metadata, sm); in sm_bootstrap_dec_blocks() local
673 r = add_bop(smm, BOP_DEC, b, e); in sm_bootstrap_dec_blocks()
722 struct sm_metadata *smm = container_of(sm, struct sm_metadata, sm); in sm_metadata_extend() local
723 dm_block_t old_len = smm->ll.nr_blocks; in sm_metadata_extend()
728 smm->begin = old_len; in sm_metadata_extend()
734 r = sm_ll_extend(&smm->ll, extra_blocks); in sm_metadata_extend()
743 r = add_bop(smm, BOP_INC, old_len, smm->begin); in sm_metadata_extend()
747 old_len = smm->begin; in sm_metadata_extend()
749 r = apply_bops(smm); in sm_metadata_extend()
755 r = sm_ll_commit(&smm->ll); in sm_metadata_extend()
759 } while (old_len != smm->begin); in sm_metadata_extend()
773 struct sm_metadata *smm; in dm_sm_metadata_init() local
775 smm = kvmalloc(sizeof(*smm), GFP_KERNEL); in dm_sm_metadata_init()
776 if (!smm) in dm_sm_metadata_init()
779 memcpy(&smm->sm, &ops, sizeof(smm->sm)); in dm_sm_metadata_init()
781 return &smm->sm; in dm_sm_metadata_init()
790 struct sm_metadata *smm = container_of(sm, struct sm_metadata, sm); in dm_sm_metadata_create() local
792 smm->begin = superblock + 1; in dm_sm_metadata_create()
793 smm->recursion_count = 0; in dm_sm_metadata_create()
794 smm->allocated_this_transaction = 0; in dm_sm_metadata_create()
795 brb_init(&smm->uncommitted); in dm_sm_metadata_create()
796 threshold_init(&smm->threshold); in dm_sm_metadata_create()
798 memcpy(&smm->sm, &bootstrap_ops, sizeof(smm->sm)); in dm_sm_metadata_create()
800 r = sm_ll_new_metadata(&smm->ll, tm); in dm_sm_metadata_create()
804 r = sm_ll_extend(&smm->ll, nr_blocks); in dm_sm_metadata_create()
806 memcpy(&smm->sm, &ops, sizeof(smm->sm)); in dm_sm_metadata_create()
814 r = add_bop(smm, BOP_INC, superblock, smm->begin); in dm_sm_metadata_create()
818 r = apply_bops(smm); in dm_sm_metadata_create()
832 struct sm_metadata *smm = container_of(sm, struct sm_metadata, sm); in dm_sm_metadata_open() local
834 r = sm_ll_open_metadata(&smm->ll, tm, root_le, len); in dm_sm_metadata_open()
838 smm->begin = 0; in dm_sm_metadata_open()
839 smm->recursion_count = 0; in dm_sm_metadata_open()
840 smm->allocated_this_transaction = 0; in dm_sm_metadata_open()
841 brb_init(&smm->uncommitted); in dm_sm_metadata_open()
842 threshold_init(&smm->threshold); in dm_sm_metadata_open()
844 memcpy(&smm->old_ll, &smm->ll, sizeof(smm->old_ll)); in dm_sm_metadata_open()