Lines Matching refs:e4b
426 struct ext4_buddy *e4b, ext4_grpblk_t start,
526 static void *mb_find_buddy(struct ext4_buddy *e4b, int order, int *max) in mb_find_buddy() argument
530 BUG_ON(e4b->bd_bitmap == e4b->bd_buddy); in mb_find_buddy()
533 if (order > e4b->bd_blkbits + 1) { in mb_find_buddy()
540 *max = 1 << (e4b->bd_blkbits + 3); in mb_find_buddy()
541 return e4b->bd_bitmap; in mb_find_buddy()
544 bb = e4b->bd_buddy + EXT4_SB(e4b->bd_sb)->s_mb_offsets[order]; in mb_find_buddy()
545 *max = EXT4_SB(e4b->bd_sb)->s_mb_maxs[order]; in mb_find_buddy()
551 static void mb_free_blocks_double(struct inode *inode, struct ext4_buddy *e4b, in mb_free_blocks_double() argument
555 struct super_block *sb = e4b->bd_sb; in mb_free_blocks_double()
557 if (unlikely(e4b->bd_info->bb_bitmap == NULL)) in mb_free_blocks_double()
559 assert_spin_locked(ext4_group_lock_ptr(sb, e4b->bd_group)); in mb_free_blocks_double()
561 if (!mb_test_bit(first + i, e4b->bd_info->bb_bitmap)) { in mb_free_blocks_double()
564 blocknr = ext4_group_first_block_no(sb, e4b->bd_group); in mb_free_blocks_double()
566 ext4_grp_locked_error(sb, e4b->bd_group, in mb_free_blocks_double()
572 ext4_mark_group_bitmap_corrupted(sb, e4b->bd_group, in mb_free_blocks_double()
575 mb_clear_bit(first + i, e4b->bd_info->bb_bitmap); in mb_free_blocks_double()
579 static void mb_mark_used_double(struct ext4_buddy *e4b, int first, int count) in mb_mark_used_double() argument
583 if (unlikely(e4b->bd_info->bb_bitmap == NULL)) in mb_mark_used_double()
585 assert_spin_locked(ext4_group_lock_ptr(e4b->bd_sb, e4b->bd_group)); in mb_mark_used_double()
587 BUG_ON(mb_test_bit(first + i, e4b->bd_info->bb_bitmap)); in mb_mark_used_double()
588 mb_set_bit(first + i, e4b->bd_info->bb_bitmap); in mb_mark_used_double()
592 static void mb_cmp_bitmaps(struct ext4_buddy *e4b, void *bitmap) in mb_cmp_bitmaps() argument
594 if (unlikely(e4b->bd_info->bb_bitmap == NULL)) in mb_cmp_bitmaps()
596 if (memcmp(e4b->bd_info->bb_bitmap, bitmap, e4b->bd_sb->s_blocksize)) { in mb_cmp_bitmaps()
599 b1 = (unsigned char *) e4b->bd_info->bb_bitmap; in mb_cmp_bitmaps()
601 for (i = 0; i < e4b->bd_sb->s_blocksize; i++) { in mb_cmp_bitmaps()
603 ext4_msg(e4b->bd_sb, KERN_ERR, in mb_cmp_bitmaps()
607 e4b->bd_group, i, i * 8, b1[i], b2[i]); in mb_cmp_bitmaps()
641 struct ext4_buddy *e4b, int first, int count) in mb_free_blocks_double() argument
645 static inline void mb_mark_used_double(struct ext4_buddy *e4b, in mb_mark_used_double() argument
650 static inline void mb_cmp_bitmaps(struct ext4_buddy *e4b, void *bitmap) in mb_cmp_bitmaps() argument
679 static int __mb_check_buddy(struct ext4_buddy *e4b, char *file, in __mb_check_buddy() argument
682 struct super_block *sb = e4b->bd_sb; in __mb_check_buddy()
683 int order = e4b->bd_blkbits + 1; in __mb_check_buddy()
697 if (e4b->bd_info->bb_check_counter++ % 10) in __mb_check_buddy()
701 buddy = mb_find_buddy(e4b, order, &max); in __mb_check_buddy()
703 buddy2 = mb_find_buddy(e4b, order - 1, &max2); in __mb_check_buddy()
727 !mb_test_bit(k, e4b->bd_bitmap)); in __mb_check_buddy()
731 MB_CHECK_ASSERT(e4b->bd_info->bb_counters[order] == count); in __mb_check_buddy()
736 buddy = mb_find_buddy(e4b, 0, &max); in __mb_check_buddy()
739 MB_CHECK_ASSERT(i >= e4b->bd_info->bb_first_free); in __mb_check_buddy()
748 for (j = 0; j < e4b->bd_blkbits + 1; j++) { in __mb_check_buddy()
749 buddy2 = mb_find_buddy(e4b, j, &max2); in __mb_check_buddy()
755 MB_CHECK_ASSERT(!EXT4_MB_GRP_NEED_INIT(e4b->bd_info)); in __mb_check_buddy()
756 MB_CHECK_ASSERT(e4b->bd_info->bb_fragments == fragments); in __mb_check_buddy()
758 grp = ext4_get_group_info(sb, e4b->bd_group); in __mb_check_buddy()
766 MB_CHECK_ASSERT(groupnr == e4b->bd_group); in __mb_check_buddy()
773 #define mb_check_buddy(e4b) __mb_check_buddy(e4b, \ argument
776 #define mb_check_buddy(e4b) argument
1235 static void mb_regenerate_buddy(struct ext4_buddy *e4b) in mb_regenerate_buddy() argument
1241 while ((buddy = mb_find_buddy(e4b, order++, &count))) in mb_regenerate_buddy()
1244 e4b->bd_info->bb_fragments = 0; in mb_regenerate_buddy()
1245 memset(e4b->bd_info->bb_counters, 0, in mb_regenerate_buddy()
1246 sizeof(*e4b->bd_info->bb_counters) * in mb_regenerate_buddy()
1247 (e4b->bd_sb->s_blocksize_bits + 2)); in mb_regenerate_buddy()
1249 ext4_mb_generate_buddy(e4b->bd_sb, e4b->bd_buddy, in mb_regenerate_buddy()
1250 e4b->bd_bitmap, e4b->bd_group, e4b->bd_info); in mb_regenerate_buddy()
1445 ext4_group_t group, struct ext4_buddy *e4b, gfp_t gfp) in ext4_mb_get_buddy_page_lock() argument
1452 e4b->bd_buddy_page = NULL; in ext4_mb_get_buddy_page_lock()
1453 e4b->bd_bitmap_page = NULL; in ext4_mb_get_buddy_page_lock()
1468 e4b->bd_bitmap_page = page; in ext4_mb_get_buddy_page_lock()
1469 e4b->bd_bitmap = page_address(page) + (poff * sb->s_blocksize); in ext4_mb_get_buddy_page_lock()
1482 e4b->bd_buddy_page = page; in ext4_mb_get_buddy_page_lock()
1486 static void ext4_mb_put_buddy_page_lock(struct ext4_buddy *e4b) in ext4_mb_put_buddy_page_lock() argument
1488 if (e4b->bd_bitmap_page) { in ext4_mb_put_buddy_page_lock()
1489 unlock_page(e4b->bd_bitmap_page); in ext4_mb_put_buddy_page_lock()
1490 put_page(e4b->bd_bitmap_page); in ext4_mb_put_buddy_page_lock()
1492 if (e4b->bd_buddy_page) { in ext4_mb_put_buddy_page_lock()
1493 unlock_page(e4b->bd_buddy_page); in ext4_mb_put_buddy_page_lock()
1494 put_page(e4b->bd_buddy_page); in ext4_mb_put_buddy_page_lock()
1508 struct ext4_buddy e4b; in ext4_mb_init_group() local
1527 ret = ext4_mb_get_buddy_page_lock(sb, group, &e4b, gfp); in ext4_mb_init_group()
1536 page = e4b.bd_bitmap_page; in ext4_mb_init_group()
1545 if (e4b.bd_buddy_page == NULL) { in ext4_mb_init_group()
1555 page = e4b.bd_buddy_page; in ext4_mb_init_group()
1556 ret = ext4_mb_init_cache(page, e4b.bd_bitmap, gfp); in ext4_mb_init_group()
1564 ext4_mb_put_buddy_page_lock(&e4b); in ext4_mb_init_group()
1575 struct ext4_buddy *e4b, gfp_t gfp) in ext4_mb_load_buddy_gfp() argument
1595 e4b->bd_blkbits = sb->s_blocksize_bits; in ext4_mb_load_buddy_gfp()
1596 e4b->bd_info = grp; in ext4_mb_load_buddy_gfp()
1597 e4b->bd_sb = sb; in ext4_mb_load_buddy_gfp()
1598 e4b->bd_group = group; in ext4_mb_load_buddy_gfp()
1599 e4b->bd_buddy_page = NULL; in ext4_mb_load_buddy_gfp()
1600 e4b->bd_bitmap_page = NULL; in ext4_mb_load_buddy_gfp()
1650 mb_cmp_bitmaps(e4b, page_address(page) + in ext4_mb_load_buddy_gfp()
1666 e4b->bd_bitmap_page = page; in ext4_mb_load_buddy_gfp()
1667 e4b->bd_bitmap = page_address(page) + (poff * sb->s_blocksize); in ext4_mb_load_buddy_gfp()
1687 ret = ext4_mb_init_cache(page, e4b->bd_bitmap, in ext4_mb_load_buddy_gfp()
1707 e4b->bd_buddy_page = page; in ext4_mb_load_buddy_gfp()
1708 e4b->bd_buddy = page_address(page) + (poff * sb->s_blocksize); in ext4_mb_load_buddy_gfp()
1715 if (e4b->bd_bitmap_page) in ext4_mb_load_buddy_gfp()
1716 put_page(e4b->bd_bitmap_page); in ext4_mb_load_buddy_gfp()
1718 e4b->bd_buddy = NULL; in ext4_mb_load_buddy_gfp()
1719 e4b->bd_bitmap = NULL; in ext4_mb_load_buddy_gfp()
1724 struct ext4_buddy *e4b) in ext4_mb_load_buddy() argument
1726 return ext4_mb_load_buddy_gfp(sb, group, e4b, GFP_NOFS); in ext4_mb_load_buddy()
1729 static void ext4_mb_unload_buddy(struct ext4_buddy *e4b) in ext4_mb_unload_buddy() argument
1731 if (e4b->bd_bitmap_page) in ext4_mb_unload_buddy()
1732 put_page(e4b->bd_bitmap_page); in ext4_mb_unload_buddy()
1733 if (e4b->bd_buddy_page) in ext4_mb_unload_buddy()
1734 put_page(e4b->bd_buddy_page); in ext4_mb_unload_buddy()
1738 static int mb_find_order_for_block(struct ext4_buddy *e4b, int block) in mb_find_order_for_block() argument
1743 BUG_ON(e4b->bd_bitmap == e4b->bd_buddy); in mb_find_order_for_block()
1744 BUG_ON(block >= (1 << (e4b->bd_blkbits + 3))); in mb_find_order_for_block()
1746 while (order <= e4b->bd_blkbits + 1) { in mb_find_order_for_block()
1747 bb = mb_find_buddy(e4b, order, &max); in mb_find_order_for_block()
1834 static void mb_buddy_mark_free(struct ext4_buddy *e4b, int first, int last) in mb_buddy_mark_free() argument
1838 void *buddy = mb_find_buddy(e4b, order, &max); in mb_buddy_mark_free()
1873 e4b->bd_info->bb_counters[order] += mb_buddy_adjust_border(&first, buddy, -1); in mb_buddy_mark_free()
1875 e4b->bd_info->bb_counters[order] += mb_buddy_adjust_border(&last, buddy, 1); in mb_buddy_mark_free()
1880 buddy2 = mb_find_buddy(e4b, order, &max); in mb_buddy_mark_free()
1883 e4b->bd_info->bb_counters[order - 1] += last - first + 1; in mb_buddy_mark_free()
1892 static void mb_free_blocks(struct inode *inode, struct ext4_buddy *e4b, in mb_free_blocks() argument
1899 struct super_block *sb = e4b->bd_sb; in mb_free_blocks()
1904 assert_spin_locked(ext4_group_lock_ptr(sb, e4b->bd_group)); in mb_free_blocks()
1906 if (unlikely(EXT4_MB_GRP_BBITMAP_CORRUPT(e4b->bd_info))) in mb_free_blocks()
1909 mb_check_buddy(e4b); in mb_free_blocks()
1910 mb_free_blocks_double(inode, e4b, first, count); in mb_free_blocks()
1916 left_is_free = !mb_test_bit(first - 1, e4b->bd_bitmap); in mb_free_blocks()
1917 block = mb_test_and_clear_bits(e4b->bd_bitmap, first, count); in mb_free_blocks()
1919 right_is_free = !mb_test_bit(last + 1, e4b->bd_bitmap); in mb_free_blocks()
1930 mb_regenerate_buddy(e4b); in mb_free_blocks()
1934 blocknr = ext4_group_first_block_no(sb, e4b->bd_group); in mb_free_blocks()
1936 ext4_grp_locked_error(sb, e4b->bd_group, in mb_free_blocks()
1940 ext4_mark_group_bitmap_corrupted(sb, e4b->bd_group, in mb_free_blocks()
1946 e4b->bd_info->bb_free += count; in mb_free_blocks()
1947 if (first < e4b->bd_info->bb_first_free) in mb_free_blocks()
1948 e4b->bd_info->bb_first_free = first; in mb_free_blocks()
1952 e4b->bd_info->bb_fragments--; in mb_free_blocks()
1954 e4b->bd_info->bb_fragments++; in mb_free_blocks()
1964 e4b->bd_info->bb_counters[0] += left_is_free ? -1 : 1; in mb_free_blocks()
1968 e4b->bd_info->bb_counters[0] += right_is_free ? -1 : 1; in mb_free_blocks()
1972 mb_buddy_mark_free(e4b, first >> 1, last >> 1); in mb_free_blocks()
1974 mb_set_largest_free_order(sb, e4b->bd_info); in mb_free_blocks()
1975 mb_update_avg_fragment_size(sb, e4b->bd_info); in mb_free_blocks()
1977 mb_check_buddy(e4b); in mb_free_blocks()
1980 static int mb_find_extent(struct ext4_buddy *e4b, int block, in mb_find_extent() argument
1987 assert_spin_locked(ext4_group_lock_ptr(e4b->bd_sb, e4b->bd_group)); in mb_find_extent()
1990 buddy = mb_find_buddy(e4b, 0, &max); in mb_find_extent()
2001 order = mb_find_order_for_block(e4b, block); in mb_find_extent()
2006 ex->fe_group = e4b->bd_group; in mb_find_extent()
2014 mb_find_buddy(e4b, order, &max)) { in mb_find_extent()
2020 if (mb_test_bit(next, e4b->bd_bitmap)) in mb_find_extent()
2023 order = mb_find_order_for_block(e4b, next); in mb_find_extent()
2029 if (ex->fe_start + ex->fe_len > EXT4_CLUSTERS_PER_GROUP(e4b->bd_sb)) { in mb_find_extent()
2032 ext4_grp_locked_error(e4b->bd_sb, e4b->bd_group, 0, 0, in mb_find_extent()
2044 static int mb_mark_used(struct ext4_buddy *e4b, struct ext4_free_extent *ex) in mb_mark_used() argument
2057 BUG_ON(start + len > (e4b->bd_sb->s_blocksize << 3)); in mb_mark_used()
2058 BUG_ON(e4b->bd_group != ex->fe_group); in mb_mark_used()
2059 assert_spin_locked(ext4_group_lock_ptr(e4b->bd_sb, e4b->bd_group)); in mb_mark_used()
2060 mb_check_buddy(e4b); in mb_mark_used()
2061 mb_mark_used_double(e4b, start, len); in mb_mark_used()
2064 e4b->bd_info->bb_free -= len; in mb_mark_used()
2065 if (e4b->bd_info->bb_first_free == start) in mb_mark_used()
2066 e4b->bd_info->bb_first_free += len; in mb_mark_used()
2070 mlen = !mb_test_bit(start - 1, e4b->bd_bitmap); in mb_mark_used()
2071 if (start + len < EXT4_SB(e4b->bd_sb)->s_mb_maxs[0]) in mb_mark_used()
2072 max = !mb_test_bit(start + len, e4b->bd_bitmap); in mb_mark_used()
2074 e4b->bd_info->bb_fragments++; in mb_mark_used()
2076 e4b->bd_info->bb_fragments--; in mb_mark_used()
2081 ord = mb_find_order_for_block(e4b, start); in mb_mark_used()
2087 buddy = mb_find_buddy(e4b, ord, &max); in mb_mark_used()
2092 e4b->bd_info->bb_counters[ord]--; in mb_mark_used()
2105 buddy = mb_find_buddy(e4b, ord, &max); in mb_mark_used()
2107 e4b->bd_info->bb_counters[ord]--; in mb_mark_used()
2111 buddy = mb_find_buddy(e4b, ord, &max); in mb_mark_used()
2114 e4b->bd_info->bb_counters[ord]++; in mb_mark_used()
2115 e4b->bd_info->bb_counters[ord]++; in mb_mark_used()
2118 mb_set_largest_free_order(e4b->bd_sb, e4b->bd_info); in mb_mark_used()
2120 mb_update_avg_fragment_size(e4b->bd_sb, e4b->bd_info); in mb_mark_used()
2121 mb_set_bits(e4b->bd_bitmap, ex->fe_start, len0); in mb_mark_used()
2122 mb_check_buddy(e4b); in mb_mark_used()
2131 struct ext4_buddy *e4b) in ext4_mb_use_best_found() argument
2136 BUG_ON(ac->ac_b_ex.fe_group != e4b->bd_group); in ext4_mb_use_best_found()
2141 ret = mb_mark_used(e4b, &ac->ac_b_ex); in ext4_mb_use_best_found()
2158 ac->ac_bitmap_page = e4b->bd_bitmap_page; in ext4_mb_use_best_found()
2160 ac->ac_buddy_page = e4b->bd_buddy_page; in ext4_mb_use_best_found()
2180 struct ext4_buddy *e4b, in ext4_mb_check_limits() argument
2205 ext4_mb_use_best_found(ac, e4b); in ext4_mb_check_limits()
2234 struct ext4_buddy *e4b) in ext4_mb_measure_extent() argument
2252 ext4_mb_use_best_found(ac, e4b); in ext4_mb_measure_extent()
2261 ext4_mb_use_best_found(ac, e4b); in ext4_mb_measure_extent()
2289 ext4_mb_check_limits(ac, e4b, 0); in ext4_mb_measure_extent()
2294 struct ext4_buddy *e4b) in ext4_mb_try_best_found() argument
2302 err = ext4_mb_load_buddy(ac->ac_sb, group, e4b); in ext4_mb_try_best_found()
2307 if (unlikely(EXT4_MB_GRP_BBITMAP_CORRUPT(e4b->bd_info))) in ext4_mb_try_best_found()
2310 max = mb_find_extent(e4b, ex.fe_start, ex.fe_len, &ex); in ext4_mb_try_best_found()
2314 ext4_mb_use_best_found(ac, e4b); in ext4_mb_try_best_found()
2319 ext4_mb_unload_buddy(e4b); in ext4_mb_try_best_found()
2324 struct ext4_buddy *e4b) in ext4_mb_find_by_goal() argument
2340 err = ext4_mb_load_buddy(ac->ac_sb, group, e4b); in ext4_mb_find_by_goal()
2345 if (unlikely(EXT4_MB_GRP_BBITMAP_CORRUPT(e4b->bd_info))) in ext4_mb_find_by_goal()
2348 max = mb_find_extent(e4b, ac->ac_g_ex.fe_start, in ext4_mb_find_by_goal()
2361 ext4_mb_use_best_found(ac, e4b); in ext4_mb_find_by_goal()
2369 ext4_mb_use_best_found(ac, e4b); in ext4_mb_find_by_goal()
2378 ext4_mb_use_best_found(ac, e4b); in ext4_mb_find_by_goal()
2382 ext4_mb_unload_buddy(e4b); in ext4_mb_find_by_goal()
2393 struct ext4_buddy *e4b) in ext4_mb_simple_scan_group() argument
2396 struct ext4_group_info *grp = e4b->bd_info; in ext4_mb_simple_scan_group()
2407 buddy = mb_find_buddy(e4b, i, &max); in ext4_mb_simple_scan_group()
2414 ext4_grp_locked_error(ac->ac_sb, e4b->bd_group, 0, 0, in ext4_mb_simple_scan_group()
2418 e4b->bd_group, in ext4_mb_simple_scan_group()
2427 ac->ac_b_ex.fe_group = e4b->bd_group; in ext4_mb_simple_scan_group()
2429 ext4_mb_use_best_found(ac, e4b); in ext4_mb_simple_scan_group()
2447 struct ext4_buddy *e4b) in ext4_mb_complex_scan_group() argument
2450 void *bitmap = e4b->bd_bitmap; in ext4_mb_complex_scan_group()
2455 free = e4b->bd_info->bb_free; in ext4_mb_complex_scan_group()
2459 i = e4b->bd_info->bb_first_free; in ext4_mb_complex_scan_group()
2470 ext4_grp_locked_error(sb, e4b->bd_group, 0, 0, in ext4_mb_complex_scan_group()
2474 ext4_mark_group_bitmap_corrupted(sb, e4b->bd_group, in ext4_mb_complex_scan_group()
2497 mb_find_extent(e4b, i, ac->ac_g_ex.fe_len, &ex); in ext4_mb_complex_scan_group()
2501 ext4_grp_locked_error(sb, e4b->bd_group, 0, 0, in ext4_mb_complex_scan_group()
2505 ext4_mark_group_bitmap_corrupted(sb, e4b->bd_group, in ext4_mb_complex_scan_group()
2515 ext4_mb_measure_extent(ac, &ex, e4b); in ext4_mb_complex_scan_group()
2521 ext4_mb_check_limits(ac, e4b, 1); in ext4_mb_complex_scan_group()
2530 struct ext4_buddy *e4b) in ext4_mb_scan_aligned() argument
2534 void *bitmap = e4b->bd_bitmap; in ext4_mb_scan_aligned()
2544 first_group_block = ext4_group_first_block_no(sb, e4b->bd_group); in ext4_mb_scan_aligned()
2554 max = mb_find_extent(e4b, i, stripe, &ex); in ext4_mb_scan_aligned()
2560 ext4_mb_use_best_found(ac, e4b); in ext4_mb_scan_aligned()
2799 struct ext4_buddy e4b; in ext4_mb_regular_allocator() local
2812 err = ext4_mb_find_by_goal(ac, &e4b); in ext4_mb_regular_allocator()
2903 err = ext4_mb_load_buddy(sb, group, &e4b); in ext4_mb_regular_allocator()
2916 ext4_mb_unload_buddy(&e4b); in ext4_mb_regular_allocator()
2922 ext4_mb_simple_scan_group(ac, &e4b); in ext4_mb_regular_allocator()
2928 ext4_mb_scan_aligned(ac, &e4b); in ext4_mb_regular_allocator()
2930 ext4_mb_complex_scan_group(ac, &e4b); in ext4_mb_regular_allocator()
2933 ext4_mb_unload_buddy(&e4b); in ext4_mb_regular_allocator()
2954 ext4_mb_try_best_found(ac, &e4b); in ext4_mb_regular_allocator()
3021 struct ext4_buddy e4b; in ext4_mb_seq_groups_show() local
3045 err = ext4_mb_load_buddy(sb, group, &e4b); in ext4_mb_seq_groups_show()
3056 ext4_mb_unload_buddy(&e4b); in ext4_mb_seq_groups_show()
3531 struct ext4_buddy e4b; in ext4_discard_work() local
3551 ext4_mb_unload_buddy(&e4b); in ext4_discard_work()
3553 err = ext4_mb_load_buddy(sb, grp, &e4b); in ext4_discard_work()
3564 ext4_try_to_trim_range(sb, &e4b, fd->efd_start_cluster, in ext4_discard_work()
3572 ext4_mb_unload_buddy(&e4b); in ext4_discard_work()
3856 struct ext4_buddy e4b; in ext4_free_data_in_buddy() local
3863 err = ext4_mb_load_buddy(sb, entry->efd_group, &e4b); in ext4_free_data_in_buddy()
3871 db = e4b.bd_info; in ext4_free_data_in_buddy()
3877 mb_free_blocks(NULL, &e4b, entry->efd_start_cluster, entry->efd_count); in ext4_free_data_in_buddy()
3892 put_page(e4b.bd_buddy_page); in ext4_free_data_in_buddy()
3893 put_page(e4b.bd_bitmap_page); in ext4_free_data_in_buddy()
3896 ext4_mb_unload_buddy(&e4b); in ext4_free_data_in_buddy()
4641 struct ext4_buddy e4b; in ext4_discard_allocated_blocks() local
4647 err = ext4_mb_load_buddy(ac->ac_sb, ac->ac_f_ex.fe_group, &e4b); in ext4_discard_allocated_blocks()
4657 mb_free_blocks(ac->ac_inode, &e4b, ac->ac_f_ex.fe_start, in ext4_discard_allocated_blocks()
4660 ext4_mb_unload_buddy(&e4b); in ext4_discard_allocated_blocks()
5326 ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh, in ext4_mb_release_inode_pa() argument
5329 struct super_block *sb = e4b->bd_sb; in ext4_mb_release_inode_pa()
5341 BUG_ON(group != e4b->bd_group && pa->pa_len != 0); in ext4_mb_release_inode_pa()
5358 mb_free_blocks(pa->pa_inode, e4b, bit, next - bit); in ext4_mb_release_inode_pa()
5362 ext4_msg(e4b->bd_sb, KERN_CRIT, in ext4_mb_release_inode_pa()
5380 ext4_mb_release_group_pa(struct ext4_buddy *e4b, in ext4_mb_release_group_pa() argument
5383 struct super_block *sb = e4b->bd_sb; in ext4_mb_release_group_pa()
5390 if (unlikely(group != e4b->bd_group && pa->pa_len != 0)) { in ext4_mb_release_group_pa()
5392 e4b->bd_group, group, pa->pa_pstart); in ext4_mb_release_group_pa()
5395 mb_free_blocks(pa->pa_inode, e4b, bit, pa->pa_len); in ext4_mb_release_group_pa()
5419 struct ext4_buddy e4b; in ext4_mb_discard_group_preallocations() local
5439 err = ext4_mb_load_buddy(sb, group, &e4b); in ext4_mb_discard_group_preallocations()
5494 ext4_mb_release_group_pa(&e4b, pa); in ext4_mb_discard_group_preallocations()
5497 ext4_mb_release_inode_pa(&e4b, bitmap_bh, pa); in ext4_mb_discard_group_preallocations()
5503 ext4_mb_unload_buddy(&e4b); in ext4_mb_discard_group_preallocations()
5528 struct ext4_buddy e4b; in ext4_discard_preallocations() local
5603 err = ext4_mb_load_buddy_gfp(sb, group, &e4b, in ext4_discard_preallocations()
5616 ext4_mb_unload_buddy(&e4b); in ext4_discard_preallocations()
5622 ext4_mb_release_inode_pa(&e4b, bitmap_bh, pa); in ext4_discard_preallocations()
5625 ext4_mb_unload_buddy(&e4b); in ext4_discard_preallocations()
5858 struct ext4_buddy e4b; in ext4_mb_discard_lg_preallocations() local
5909 err = ext4_mb_load_buddy_gfp(sb, group, &e4b, in ext4_mb_discard_lg_preallocations()
5918 ext4_mb_release_group_pa(&e4b, pa); in ext4_mb_discard_lg_preallocations()
5921 ext4_mb_unload_buddy(&e4b); in ext4_mb_discard_lg_preallocations()
6319 ext4_mb_free_metadata(handle_t *handle, struct ext4_buddy *e4b, in ext4_mb_free_metadata() argument
6322 ext4_group_t group = e4b->bd_group; in ext4_mb_free_metadata()
6326 struct ext4_group_info *db = e4b->bd_info; in ext4_mb_free_metadata()
6327 struct super_block *sb = e4b->bd_sb; in ext4_mb_free_metadata()
6333 BUG_ON(e4b->bd_bitmap_page == NULL); in ext4_mb_free_metadata()
6334 BUG_ON(e4b->bd_buddy_page == NULL); in ext4_mb_free_metadata()
6345 get_page(e4b->bd_buddy_page); in ext4_mb_free_metadata()
6346 get_page(e4b->bd_bitmap_page); in ext4_mb_free_metadata()
6453 struct ext4_buddy e4b; in ext4_mb_clear_bb() local
6534 err = ext4_mb_load_buddy_gfp(sb, block_group, &e4b, in ext4_mb_clear_bb()
6562 ext4_mb_free_metadata(handle, &e4b, new_entry); in ext4_mb_clear_bb()
6577 EXT4_MB_GRP_CLEAR_TRIMMED(e4b.bd_info); in ext4_mb_clear_bb()
6581 mb_free_blocks(inode, &e4b, bit, count_clusters); in ext4_mb_clear_bb()
6609 ext4_mb_unload_buddy(&e4b); in ext4_mb_clear_bb()
6755 struct ext4_buddy e4b; in ext4_group_add_blocks() local
6827 err = ext4_mb_load_buddy(sb, block_group, &e4b); in ext4_group_add_blocks()
6838 mb_free_blocks(NULL, &e4b, bit, cluster_count); in ext4_group_add_blocks()
6855 ext4_mb_unload_buddy(&e4b); in ext4_group_add_blocks()
6885 int start, int count, struct ext4_buddy *e4b) in ext4_trim_extent() argument
6890 ext4_group_t group = e4b->bd_group; in ext4_trim_extent()
6905 mb_mark_used(e4b, &ex); in ext4_trim_extent()
6909 mb_free_blocks(NULL, e4b, start, ex.fe_len); in ext4_trim_extent()
6934 struct ext4_buddy *e4b, ext4_grpblk_t start, in ext4_try_to_trim_range() argument
6936 __acquires(ext4_group_lock_ptr(sb, e4b->bd_group)) in ext4_try_to_trim_range()
6937 __releases(ext4_group_lock_ptr(sb, e4b->bd_group)) in ext4_try_to_trim_range()
6943 last = ext4_last_grp_cluster(sb, e4b->bd_group); in ext4_try_to_trim_range()
6944 bitmap = e4b->bd_bitmap; in ext4_try_to_trim_range()
6948 start = max(e4b->bd_info->bb_first_free, start); in ext4_try_to_trim_range()
6962 int ret = ext4_trim_extent(sb, start, next - start, e4b); in ext4_try_to_trim_range()
6975 ext4_unlock_group(sb, e4b->bd_group); in ext4_try_to_trim_range()
6977 ext4_lock_group(sb, e4b->bd_group); in ext4_try_to_trim_range()
6980 if ((e4b->bd_info->bb_free - free_count) < minblocks) in ext4_try_to_trim_range()
6985 EXT4_MB_GRP_SET_TRIMMED(e4b->bd_info); in ext4_try_to_trim_range()
7008 struct ext4_buddy e4b; in ext4_trim_all_free() local
7013 ret = ext4_mb_load_buddy(sb, group, &e4b); in ext4_trim_all_free()
7022 if (!EXT4_MB_GRP_WAS_TRIMMED(e4b.bd_info) || in ext4_trim_all_free()
7024 ret = ext4_try_to_trim_range(sb, &e4b, start, max, minblocks); in ext4_trim_all_free()
7029 ext4_mb_unload_buddy(&e4b); in ext4_trim_all_free()
7151 struct ext4_buddy e4b; in ext4_mballoc_query_range() local
7154 error = ext4_mb_load_buddy(sb, group, &e4b); in ext4_mballoc_query_range()
7157 bitmap = e4b.bd_bitmap; in ext4_mballoc_query_range()
7161 start = max(e4b.bd_info->bb_first_free, start); in ext4_mballoc_query_range()
7182 ext4_mb_unload_buddy(&e4b); in ext4_mballoc_query_range()