Lines Matching refs:mblk

135 	struct dmz_mblock	*mblk;  member
409 struct dmz_mblock *mblk = NULL; in dmz_alloc_mblock() local
414 mblk = list_first_entry_or_null(&zmd->mblk_lru_list, in dmz_alloc_mblock()
416 if (mblk) { in dmz_alloc_mblock()
417 list_del_init(&mblk->link); in dmz_alloc_mblock()
418 rb_erase(&mblk->node, &zmd->mblk_rbtree); in dmz_alloc_mblock()
419 mblk->no = mblk_no; in dmz_alloc_mblock()
422 if (mblk) in dmz_alloc_mblock()
423 return mblk; in dmz_alloc_mblock()
427 mblk = kmalloc(sizeof(struct dmz_mblock), GFP_NOIO); in dmz_alloc_mblock()
428 if (!mblk) in dmz_alloc_mblock()
431 mblk->page = alloc_page(GFP_NOIO); in dmz_alloc_mblock()
432 if (!mblk->page) { in dmz_alloc_mblock()
433 kfree(mblk); in dmz_alloc_mblock()
437 RB_CLEAR_NODE(&mblk->node); in dmz_alloc_mblock()
438 INIT_LIST_HEAD(&mblk->link); in dmz_alloc_mblock()
439 mblk->ref = 0; in dmz_alloc_mblock()
440 mblk->state = 0; in dmz_alloc_mblock()
441 mblk->no = mblk_no; in dmz_alloc_mblock()
442 mblk->data = page_address(mblk->page); in dmz_alloc_mblock()
446 return mblk; in dmz_alloc_mblock()
452 static void dmz_free_mblock(struct dmz_metadata *zmd, struct dmz_mblock *mblk) in dmz_free_mblock() argument
454 __free_pages(mblk->page, 0); in dmz_free_mblock()
455 kfree(mblk); in dmz_free_mblock()
463 static void dmz_insert_mblock(struct dmz_metadata *zmd, struct dmz_mblock *mblk) in dmz_insert_mblock() argument
473 new = (b->no < mblk->no) ? &((*new)->rb_left) : &((*new)->rb_right); in dmz_insert_mblock()
477 rb_link_node(&mblk->node, parent, new); in dmz_insert_mblock()
478 rb_insert_color(&mblk->node, root); in dmz_insert_mblock()
490 struct dmz_mblock *mblk; in dmz_get_mblock_fast() local
493 mblk = container_of(node, struct dmz_mblock, node); in dmz_get_mblock_fast()
494 if (mblk->no == mblk_no) { in dmz_get_mblock_fast()
499 mblk->ref++; in dmz_get_mblock_fast()
500 if (mblk->ref == 1 && in dmz_get_mblock_fast()
501 !test_bit(DMZ_META_DIRTY, &mblk->state)) in dmz_get_mblock_fast()
502 list_del_init(&mblk->link); in dmz_get_mblock_fast()
503 return mblk; in dmz_get_mblock_fast()
505 node = (mblk->no < mblk_no) ? node->rb_left : node->rb_right; in dmz_get_mblock_fast()
516 struct dmz_mblock *mblk = bio->bi_private; in dmz_mblock_bio_end_io() local
520 set_bit(DMZ_META_ERROR, &mblk->state); in dmz_mblock_bio_end_io()
527 clear_bit_unlock(flag, &mblk->state); in dmz_mblock_bio_end_io()
529 wake_up_bit(&mblk->state, flag); in dmz_mblock_bio_end_io()
540 struct dmz_mblock *mblk, *m; in dmz_get_mblock_slow() local
549 mblk = dmz_alloc_mblock(zmd, mblk_no); in dmz_get_mblock_slow()
550 if (!mblk) in dmz_get_mblock_slow()
565 dmz_free_mblock(zmd, mblk); in dmz_get_mblock_slow()
570 mblk->ref++; in dmz_get_mblock_slow()
571 set_bit(DMZ_META_READING, &mblk->state); in dmz_get_mblock_slow()
572 dmz_insert_mblock(zmd, mblk); in dmz_get_mblock_slow()
578 bio->bi_private = mblk; in dmz_get_mblock_slow()
580 __bio_add_page(bio, mblk->page, DMZ_BLOCK_SIZE, 0); in dmz_get_mblock_slow()
583 return mblk; in dmz_get_mblock_slow()
592 struct dmz_mblock *mblk; in dmz_shrink_mblock_cache() local
601 mblk = list_first_entry(&zmd->mblk_lru_list, in dmz_shrink_mblock_cache()
603 list_del_init(&mblk->link); in dmz_shrink_mblock_cache()
604 rb_erase(&mblk->node, &zmd->mblk_rbtree); in dmz_shrink_mblock_cache()
605 dmz_free_mblock(zmd, mblk); in dmz_shrink_mblock_cache()
643 struct dmz_mblock *mblk) in dmz_release_mblock() argument
646 if (!mblk) in dmz_release_mblock()
651 mblk->ref--; in dmz_release_mblock()
652 if (mblk->ref == 0) { in dmz_release_mblock()
653 if (test_bit(DMZ_META_ERROR, &mblk->state)) { in dmz_release_mblock()
654 rb_erase(&mblk->node, &zmd->mblk_rbtree); in dmz_release_mblock()
655 dmz_free_mblock(zmd, mblk); in dmz_release_mblock()
656 } else if (!test_bit(DMZ_META_DIRTY, &mblk->state)) { in dmz_release_mblock()
657 list_add_tail(&mblk->link, &zmd->mblk_lru_list); in dmz_release_mblock()
672 struct dmz_mblock *mblk; in dmz_get_mblock() local
677 mblk = dmz_get_mblock_fast(zmd, mblk_no); in dmz_get_mblock()
680 if (!mblk) { in dmz_get_mblock()
682 mblk = dmz_get_mblock_slow(zmd, mblk_no); in dmz_get_mblock()
683 if (IS_ERR(mblk)) in dmz_get_mblock()
684 return mblk; in dmz_get_mblock()
688 wait_on_bit_io(&mblk->state, DMZ_META_READING, in dmz_get_mblock()
690 if (test_bit(DMZ_META_ERROR, &mblk->state)) { in dmz_get_mblock()
691 dmz_release_mblock(zmd, mblk); in dmz_get_mblock()
696 return mblk; in dmz_get_mblock()
702 static void dmz_dirty_mblock(struct dmz_metadata *zmd, struct dmz_mblock *mblk) in dmz_dirty_mblock() argument
705 if (!test_and_set_bit(DMZ_META_DIRTY, &mblk->state)) in dmz_dirty_mblock()
706 list_add_tail(&mblk->link, &zmd->mblk_dirty_list); in dmz_dirty_mblock()
713 static int dmz_write_mblock(struct dmz_metadata *zmd, struct dmz_mblock *mblk, in dmz_write_mblock() argument
717 sector_t block = zmd->sb[set].block + mblk->no; in dmz_write_mblock()
726 set_bit(DMZ_META_WRITING, &mblk->state); in dmz_write_mblock()
729 bio->bi_private = mblk; in dmz_write_mblock()
731 __bio_add_page(bio, mblk->page, DMZ_BLOCK_SIZE, 0); in dmz_write_mblock()
769 struct dmz_mblock *mblk = zmd->sb[set].mblk; in dmz_write_sb() local
806 mblk->page); in dmz_write_sb()
820 struct dmz_mblock *mblk; in dmz_write_dirty_mblocks() local
827 list_for_each_entry(mblk, write_list, link) { in dmz_write_dirty_mblocks()
828 ret = dmz_write_mblock(zmd, mblk, set); in dmz_write_dirty_mblocks()
836 list_for_each_entry(mblk, write_list, link) { in dmz_write_dirty_mblocks()
839 wait_on_bit_io(&mblk->state, DMZ_META_WRITING, in dmz_write_dirty_mblocks()
841 if (test_bit(DMZ_META_ERROR, &mblk->state)) { in dmz_write_dirty_mblocks()
842 clear_bit(DMZ_META_ERROR, &mblk->state); in dmz_write_dirty_mblocks()
886 struct dmz_mblock *mblk; in dmz_flush_metadata() local
948 mblk = list_first_entry(&write_list, struct dmz_mblock, link); in dmz_flush_metadata()
949 list_del_init(&mblk->link); in dmz_flush_metadata()
952 clear_bit(DMZ_META_DIRTY, &mblk->state); in dmz_flush_metadata()
953 if (mblk->ref == 0) in dmz_flush_metadata()
954 list_add_tail(&mblk->link, &zmd->mblk_lru_list); in dmz_flush_metadata()
1104 sb->block, sb->mblk->page); in dmz_read_sb()
1115 struct dmz_mblock *mblk; in dmz_lookup_secondary_sb() local
1120 mblk = dmz_alloc_mblock(zmd, 0); in dmz_lookup_secondary_sb()
1121 if (!mblk) in dmz_lookup_secondary_sb()
1124 zmd->sb[1].mblk = mblk; in dmz_lookup_secondary_sb()
1125 zmd->sb[1].sb = mblk->data; in dmz_lookup_secondary_sb()
1140 dmz_free_mblock(zmd, mblk); in dmz_lookup_secondary_sb()
1141 zmd->sb[1].mblk = NULL; in dmz_lookup_secondary_sb()
1153 struct dmz_mblock *mblk; in dmz_get_sb() local
1157 mblk = dmz_alloc_mblock(zmd, 0); in dmz_get_sb()
1158 if (!mblk) in dmz_get_sb()
1161 sb->mblk = mblk; in dmz_get_sb()
1162 sb->sb = mblk->data; in dmz_get_sb()
1167 dmz_free_mblock(zmd, mblk); in dmz_get_sb()
1168 sb->mblk = NULL; in dmz_get_sb()
1209 if (!zmd->sb[dst_set].mblk) { in dmz_recover_mblocks()
1210 zmd->sb[dst_set].mblk = dmz_alloc_mblock(zmd, 0); in dmz_recover_mblocks()
1211 if (!zmd->sb[dst_set].mblk) { in dmz_recover_mblocks()
1215 zmd->sb[dst_set].sb = zmd->sb[dst_set].mblk->data; in dmz_recover_mblocks()
1337 dmz_free_mblock(zmd, sb->mblk); in dmz_load_sb()
1341 dmz_free_mblock(zmd, sb->mblk); in dmz_load_sb()
2484 struct dmz_mblock *mblk; in dmz_validate_blocks() local
2495 mblk = dmz_get_bitmap(zmd, zone, chunk_block); in dmz_validate_blocks()
2496 if (IS_ERR(mblk)) in dmz_validate_blocks()
2497 return PTR_ERR(mblk); in dmz_validate_blocks()
2503 count = dmz_set_bits((unsigned long *)mblk->data, bit, nr_bits); in dmz_validate_blocks()
2505 dmz_dirty_mblock(zmd, mblk); in dmz_validate_blocks()
2508 dmz_release_mblock(zmd, mblk); in dmz_validate_blocks()
2564 struct dmz_mblock *mblk; in dmz_invalidate_blocks() local
2574 mblk = dmz_get_bitmap(zmd, zone, chunk_block); in dmz_invalidate_blocks()
2575 if (IS_ERR(mblk)) in dmz_invalidate_blocks()
2576 return PTR_ERR(mblk); in dmz_invalidate_blocks()
2582 count = dmz_clear_bits((unsigned long *)mblk->data, in dmz_invalidate_blocks()
2585 dmz_dirty_mblock(zmd, mblk); in dmz_invalidate_blocks()
2588 dmz_release_mblock(zmd, mblk); in dmz_invalidate_blocks()
2611 struct dmz_mblock *mblk; in dmz_test_block() local
2617 mblk = dmz_get_bitmap(zmd, zone, chunk_block); in dmz_test_block()
2618 if (IS_ERR(mblk)) in dmz_test_block()
2619 return PTR_ERR(mblk); in dmz_test_block()
2623 (unsigned long *) mblk->data) != 0; in dmz_test_block()
2625 dmz_release_mblock(zmd, mblk); in dmz_test_block()
2638 struct dmz_mblock *mblk; in dmz_to_next_set_block() local
2648 mblk = dmz_get_bitmap(zmd, zone, chunk_block); in dmz_to_next_set_block()
2649 if (IS_ERR(mblk)) in dmz_to_next_set_block()
2650 return PTR_ERR(mblk); in dmz_to_next_set_block()
2653 bitmap = (unsigned long *) mblk->data; in dmz_to_next_set_block()
2660 dmz_release_mblock(zmd, mblk); in dmz_to_next_set_block()
2748 struct dmz_mblock *mblk; in dmz_get_zone_weight() local
2757 mblk = dmz_get_bitmap(zmd, zone, chunk_block); in dmz_get_zone_weight()
2758 if (IS_ERR(mblk)) { in dmz_get_zone_weight()
2764 bitmap = mblk->data; in dmz_get_zone_weight()
2769 dmz_release_mblock(zmd, mblk); in dmz_get_zone_weight()
2784 struct dmz_mblock *mblk, *next; in dmz_cleanup_metadata() local
2797 if (zmd->sb[i].mblk) { in dmz_cleanup_metadata()
2798 dmz_free_mblock(zmd, zmd->sb[i].mblk); in dmz_cleanup_metadata()
2799 zmd->sb[i].mblk = NULL; in dmz_cleanup_metadata()
2805 mblk = list_first_entry(&zmd->mblk_dirty_list, in dmz_cleanup_metadata()
2808 (u64)mblk->no, mblk->ref); in dmz_cleanup_metadata()
2809 list_del_init(&mblk->link); in dmz_cleanup_metadata()
2810 rb_erase(&mblk->node, &zmd->mblk_rbtree); in dmz_cleanup_metadata()
2811 dmz_free_mblock(zmd, mblk); in dmz_cleanup_metadata()
2815 mblk = list_first_entry(&zmd->mblk_lru_list, in dmz_cleanup_metadata()
2817 list_del_init(&mblk->link); in dmz_cleanup_metadata()
2818 rb_erase(&mblk->node, &zmd->mblk_rbtree); in dmz_cleanup_metadata()
2819 dmz_free_mblock(zmd, mblk); in dmz_cleanup_metadata()
2824 rbtree_postorder_for_each_entry_safe(mblk, next, root, node) { in dmz_cleanup_metadata()
2826 (u64)mblk->no, mblk->ref); in dmz_cleanup_metadata()
2827 mblk->ref = 0; in dmz_cleanup_metadata()
2828 dmz_free_mblock(zmd, mblk); in dmz_cleanup_metadata()