Lines Matching refs:smm

181 static int add_bop(struct sm_metadata *smm, enum block_op_type type, dm_block_t b)
183 int r = brb_push(&smm->uncommitted, type, b);
193 static int commit_bop(struct sm_metadata *smm, struct block_op *op)
200 r = sm_ll_inc(&smm->ll, op->block, &ev);
204 r = sm_ll_dec(&smm->ll, op->block, &ev);
211 static void in(struct sm_metadata *smm)
213 smm->recursion_count++;
216 static int apply_bops(struct sm_metadata *smm)
220 while (!brb_empty(&smm->uncommitted)) {
223 r = brb_peek(&smm->uncommitted, &bop);
229 r = commit_bop(smm, &bop);
233 brb_pop(&smm->uncommitted);
239 static int out(struct sm_metadata *smm)
246 if (!smm->recursion_count) {
251 if (smm->recursion_count == 1)
252 r = apply_bops(smm);
254 smm->recursion_count--;
269 static int recursing(struct sm_metadata *smm)
271 return smm->recursion_count;
276 struct sm_metadata *smm = container_of(sm, struct sm_metadata, sm);
278 kfree(smm);
283 struct sm_metadata *smm = container_of(sm, struct sm_metadata, sm);
285 *count = smm->ll.nr_blocks;
292 struct sm_metadata *smm = container_of(sm, struct sm_metadata, sm);
294 *count = smm->old_ll.nr_blocks - smm->old_ll.nr_allocated -
295 smm->allocated_this_transaction;
305 struct sm_metadata *smm = container_of(sm, struct sm_metadata, sm);
312 for (i = smm->uncommitted.begin;
313 i != smm->uncommitted.end;
314 i = brb_next(&smm->uncommitted, i)) {
315 struct block_op *op = smm->uncommitted.bops + i;
331 r = sm_ll_lookup(&smm->ll, b, result);
345 struct sm_metadata *smm = container_of(sm, struct sm_metadata, sm);
352 for (i = smm->uncommitted.begin;
353 i != smm->uncommitted.end;
354 i = brb_next(&smm->uncommitted, i)) {
356 struct block_op *op = smm->uncommitted.bops + i;
377 r = sm_ll_lookup_bitmap(&smm->ll, b, &rc);
397 struct sm_metadata *smm = container_of(sm, struct sm_metadata, sm);
399 if (smm->recursion_count) {
404 in(smm);
405 r = sm_ll_insert(&smm->ll, b, count, &ev);
406 r2 = out(smm);
415 struct sm_metadata *smm = container_of(sm, struct sm_metadata, sm);
417 if (recursing(smm))
418 r = add_bop(smm, BOP_INC, b);
420 in(smm);
421 r = sm_ll_inc(&smm->ll, b, &ev);
422 r2 = out(smm);
432 struct sm_metadata *smm = container_of(sm, struct sm_metadata, sm);
434 if (recursing(smm))
435 r = add_bop(smm, BOP_DEC, b);
437 in(smm);
438 r = sm_ll_dec(&smm->ll, b, &ev);
439 r2 = out(smm);
449 struct sm_metadata *smm = container_of(sm, struct sm_metadata, sm);
454 r = sm_ll_find_common_free_block(&smm->old_ll, &smm->ll, smm->begin, smm->ll.nr_blocks, b);
457 * There's no free block between smm->begin and the end of the metadata device.
458 * We search before smm->begin in case something has been freed.
460 r = sm_ll_find_common_free_block(&smm->old_ll, &smm->ll, 0, smm->begin, b);
466 smm->begin = *b + 1;
468 if (recursing(smm))
469 r = add_bop(smm, BOP_INC, *b);
471 in(smm);
472 r = sm_ll_inc(&smm->ll, *b, &ev);
473 r2 = out(smm);
477 smm->allocated_this_transaction++;
485 struct sm_metadata *smm = container_of(sm, struct sm_metadata, sm);
499 check_threshold(&smm->threshold, count);
507 struct sm_metadata *smm = container_of(sm, struct sm_metadata, sm);
509 r = sm_ll_commit(&smm->ll);
513 memcpy(&smm->old_ll, &smm->ll, sizeof(smm->old_ll));
514 smm->allocated_this_transaction = 0;
524 struct sm_metadata *smm = container_of(sm, struct sm_metadata, sm);
526 set_threshold(&smm->threshold, threshold, fn, context);
540 struct sm_metadata *smm = container_of(sm, struct sm_metadata, sm);
543 root_le.nr_blocks = cpu_to_le64(smm->ll.nr_blocks);
544 root_le.nr_allocated = cpu_to_le64(smm->ll.nr_allocated);
545 root_le.bitmap_root = cpu_to_le64(smm->ll.bitmap_root);
546 root_le.ref_count_root = cpu_to_le64(smm->ll.ref_count_root);
594 struct sm_metadata *smm = container_of(sm, struct sm_metadata, sm);
596 *count = smm->ll.nr_blocks;
603 struct sm_metadata *smm = container_of(sm, struct sm_metadata, sm);
605 *count = smm->ll.nr_blocks - smm->begin;
613 struct sm_metadata *smm = container_of(sm, struct sm_metadata, sm);
615 *result = (b < smm->begin) ? 1 : 0;
638 struct sm_metadata *smm = container_of(sm, struct sm_metadata, sm);
643 if (smm->begin == smm->ll.nr_blocks)
646 *b = smm->begin++;
653 struct sm_metadata *smm = container_of(sm, struct sm_metadata, sm);
655 return add_bop(smm, BOP_INC, b);
660 struct sm_metadata *smm = container_of(sm, struct sm_metadata, sm);
662 return add_bop(smm, BOP_DEC, b);
707 struct sm_metadata *smm = container_of(sm, struct sm_metadata, sm);
708 dm_block_t old_len = smm->ll.nr_blocks;
713 smm->begin = old_len;
719 r = sm_ll_extend(&smm->ll, extra_blocks);
728 for (i = old_len; !r && i < smm->begin; i++)
729 r = add_bop(smm, BOP_INC, i);
734 old_len = smm->begin;
736 r = apply_bops(smm);
742 r = sm_ll_commit(&smm->ll);
746 } while (old_len != smm->begin);
760 struct sm_metadata *smm;
762 smm = kmalloc(sizeof(*smm), GFP_KERNEL);
763 if (!smm)
766 memcpy(&smm->sm, &ops, sizeof(smm->sm));
768 return &smm->sm;
778 struct sm_metadata *smm = container_of(sm, struct sm_metadata, sm);
780 smm->begin = superblock + 1;
781 smm->recursion_count = 0;
782 smm->allocated_this_transaction = 0;
783 brb_init(&smm->uncommitted);
784 threshold_init(&smm->threshold);
786 memcpy(&smm->sm, &bootstrap_ops, sizeof(smm->sm));
788 r = sm_ll_new_metadata(&smm->ll, tm);
792 r = sm_ll_extend(&smm->ll, nr_blocks);
794 memcpy(&smm->sm, &ops, sizeof(smm->sm));
802 for (i = superblock; !r && i < smm->begin; i++)
803 r = add_bop(smm, BOP_INC, i);
808 r = apply_bops(smm);
822 struct sm_metadata *smm = container_of(sm, struct sm_metadata, sm);
824 r = sm_ll_open_metadata(&smm->ll, tm, root_le, len);
828 smm->begin = 0;
829 smm->recursion_count = 0;
830 smm->allocated_this_transaction = 0;
831 brb_init(&smm->uncommitted);
832 threshold_init(&smm->threshold);
834 memcpy(&smm->old_ll, &smm->ll, sizeof(smm->old_ll));