diff options
Diffstat (limited to 'fs/ext4/mballoc.c')
-rw-r--r-- | fs/ext4/mballoc.c | 120 |
1 files changed, 85 insertions, 35 deletions
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index b423a364dca3..12b3bc026a68 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c | |||
@@ -658,6 +658,27 @@ static void ext4_mb_mark_free_simple(struct super_block *sb, | |||
658 | } | 658 | } |
659 | } | 659 | } |
660 | 660 | ||
661 | /* | ||
662 | * Cache the order of the largest free extent we have available in this block | ||
663 | * group. | ||
664 | */ | ||
665 | static void | ||
666 | mb_set_largest_free_order(struct super_block *sb, struct ext4_group_info *grp) | ||
667 | { | ||
668 | int i; | ||
669 | int bits; | ||
670 | |||
671 | grp->bb_largest_free_order = -1; /* uninit */ | ||
672 | |||
673 | bits = sb->s_blocksize_bits + 1; | ||
674 | for (i = bits; i >= 0; i--) { | ||
675 | if (grp->bb_counters[i] > 0) { | ||
676 | grp->bb_largest_free_order = i; | ||
677 | break; | ||
678 | } | ||
679 | } | ||
680 | } | ||
681 | |||
661 | static noinline_for_stack | 682 | static noinline_for_stack |
662 | void ext4_mb_generate_buddy(struct super_block *sb, | 683 | void ext4_mb_generate_buddy(struct super_block *sb, |
663 | void *buddy, void *bitmap, ext4_group_t group) | 684 | void *buddy, void *bitmap, ext4_group_t group) |
@@ -700,6 +721,7 @@ void ext4_mb_generate_buddy(struct super_block *sb, | |||
700 | */ | 721 | */ |
701 | grp->bb_free = free; | 722 | grp->bb_free = free; |
702 | } | 723 | } |
724 | mb_set_largest_free_order(sb, grp); | ||
703 | 725 | ||
704 | clear_bit(EXT4_GROUP_INFO_NEED_INIT_BIT, &(grp->bb_state)); | 726 | clear_bit(EXT4_GROUP_INFO_NEED_INIT_BIT, &(grp->bb_state)); |
705 | 727 | ||
@@ -725,6 +747,9 @@ void ext4_mb_generate_buddy(struct super_block *sb, | |||
725 | * contain blocks_per_page (PAGE_CACHE_SIZE / blocksize) blocks. | 747 | * contain blocks_per_page (PAGE_CACHE_SIZE / blocksize) blocks. |
726 | * So it can have information regarding groups_per_page which | 748 | * So it can have information regarding groups_per_page which |
727 | * is blocks_per_page/2 | 749 | * is blocks_per_page/2 |
750 | * | ||
751 | * Locking note: This routine takes the block group lock of all groups | ||
752 | * for this page; do not hold this lock when calling this routine! | ||
728 | */ | 753 | */ |
729 | 754 | ||
730 | static int ext4_mb_init_cache(struct page *page, char *incore) | 755 | static int ext4_mb_init_cache(struct page *page, char *incore) |
@@ -865,6 +890,7 @@ static int ext4_mb_init_cache(struct page *page, char *incore) | |||
865 | BUG_ON(incore == NULL); | 890 | BUG_ON(incore == NULL); |
866 | mb_debug(1, "put buddy for group %u in page %lu/%x\n", | 891 | mb_debug(1, "put buddy for group %u in page %lu/%x\n", |
867 | group, page->index, i * blocksize); | 892 | group, page->index, i * blocksize); |
893 | trace_ext4_mb_buddy_bitmap_load(sb, group); | ||
868 | grinfo = ext4_get_group_info(sb, group); | 894 | grinfo = ext4_get_group_info(sb, group); |
869 | grinfo->bb_fragments = 0; | 895 | grinfo->bb_fragments = 0; |
870 | memset(grinfo->bb_counters, 0, | 896 | memset(grinfo->bb_counters, 0, |
@@ -882,6 +908,7 @@ static int ext4_mb_init_cache(struct page *page, char *incore) | |||
882 | BUG_ON(incore != NULL); | 908 | BUG_ON(incore != NULL); |
883 | mb_debug(1, "put bitmap for group %u in page %lu/%x\n", | 909 | mb_debug(1, "put bitmap for group %u in page %lu/%x\n", |
884 | group, page->index, i * blocksize); | 910 | group, page->index, i * blocksize); |
911 | trace_ext4_mb_bitmap_load(sb, group); | ||
885 | 912 | ||
886 | /* see comments in ext4_mb_put_pa() */ | 913 | /* see comments in ext4_mb_put_pa() */ |
887 | ext4_lock_group(sb, group); | 914 | ext4_lock_group(sb, group); |
@@ -910,6 +937,11 @@ out: | |||
910 | return err; | 937 | return err; |
911 | } | 938 | } |
912 | 939 | ||
940 | /* | ||
941 | * Locking note: This routine calls ext4_mb_init_cache(), which takes the | ||
942 | * block group lock of all groups for this page; do not hold the BG lock when | ||
943 | * calling this routine! | ||
944 | */ | ||
913 | static noinline_for_stack | 945 | static noinline_for_stack |
914 | int ext4_mb_init_group(struct super_block *sb, ext4_group_t group) | 946 | int ext4_mb_init_group(struct super_block *sb, ext4_group_t group) |
915 | { | 947 | { |
@@ -1004,6 +1036,11 @@ err: | |||
1004 | return ret; | 1036 | return ret; |
1005 | } | 1037 | } |
1006 | 1038 | ||
1039 | /* | ||
1040 | * Locking note: This routine calls ext4_mb_init_cache(), which takes the | ||
1041 | * block group lock of all groups for this page; do not hold the BG lock when | ||
1042 | * calling this routine! | ||
1043 | */ | ||
1007 | static noinline_for_stack int | 1044 | static noinline_for_stack int |
1008 | ext4_mb_load_buddy(struct super_block *sb, ext4_group_t group, | 1045 | ext4_mb_load_buddy(struct super_block *sb, ext4_group_t group, |
1009 | struct ext4_buddy *e4b) | 1046 | struct ext4_buddy *e4b) |
@@ -1150,7 +1187,7 @@ err: | |||
1150 | return ret; | 1187 | return ret; |
1151 | } | 1188 | } |
1152 | 1189 | ||
1153 | static void ext4_mb_release_desc(struct ext4_buddy *e4b) | 1190 | static void ext4_mb_unload_buddy(struct ext4_buddy *e4b) |
1154 | { | 1191 | { |
1155 | if (e4b->bd_bitmap_page) | 1192 | if (e4b->bd_bitmap_page) |
1156 | page_cache_release(e4b->bd_bitmap_page); | 1193 | page_cache_release(e4b->bd_bitmap_page); |
@@ -1299,6 +1336,7 @@ static void mb_free_blocks(struct inode *inode, struct ext4_buddy *e4b, | |||
1299 | buddy = buddy2; | 1336 | buddy = buddy2; |
1300 | } while (1); | 1337 | } while (1); |
1301 | } | 1338 | } |
1339 | mb_set_largest_free_order(sb, e4b->bd_info); | ||
1302 | mb_check_buddy(e4b); | 1340 | mb_check_buddy(e4b); |
1303 | } | 1341 | } |
1304 | 1342 | ||
@@ -1427,6 +1465,7 @@ static int mb_mark_used(struct ext4_buddy *e4b, struct ext4_free_extent *ex) | |||
1427 | e4b->bd_info->bb_counters[ord]++; | 1465 | e4b->bd_info->bb_counters[ord]++; |
1428 | e4b->bd_info->bb_counters[ord]++; | 1466 | e4b->bd_info->bb_counters[ord]++; |
1429 | } | 1467 | } |
1468 | mb_set_largest_free_order(e4b->bd_sb, e4b->bd_info); | ||
1430 | 1469 | ||
1431 | mb_set_bits(EXT4_MB_BITMAP(e4b), ex->fe_start, len0); | 1470 | mb_set_bits(EXT4_MB_BITMAP(e4b), ex->fe_start, len0); |
1432 | mb_check_buddy(e4b); | 1471 | mb_check_buddy(e4b); |
@@ -1617,7 +1656,7 @@ int ext4_mb_try_best_found(struct ext4_allocation_context *ac, | |||
1617 | } | 1656 | } |
1618 | 1657 | ||
1619 | ext4_unlock_group(ac->ac_sb, group); | 1658 | ext4_unlock_group(ac->ac_sb, group); |
1620 | ext4_mb_release_desc(e4b); | 1659 | ext4_mb_unload_buddy(e4b); |
1621 | 1660 | ||
1622 | return 0; | 1661 | return 0; |
1623 | } | 1662 | } |
@@ -1672,7 +1711,7 @@ int ext4_mb_find_by_goal(struct ext4_allocation_context *ac, | |||
1672 | ext4_mb_use_best_found(ac, e4b); | 1711 | ext4_mb_use_best_found(ac, e4b); |
1673 | } | 1712 | } |
1674 | ext4_unlock_group(ac->ac_sb, group); | 1713 | ext4_unlock_group(ac->ac_sb, group); |
1675 | ext4_mb_release_desc(e4b); | 1714 | ext4_mb_unload_buddy(e4b); |
1676 | 1715 | ||
1677 | return 0; | 1716 | return 0; |
1678 | } | 1717 | } |
@@ -1821,16 +1860,22 @@ void ext4_mb_scan_aligned(struct ext4_allocation_context *ac, | |||
1821 | } | 1860 | } |
1822 | } | 1861 | } |
1823 | 1862 | ||
1863 | /* This is now called BEFORE we load the buddy bitmap. */ | ||
1824 | static int ext4_mb_good_group(struct ext4_allocation_context *ac, | 1864 | static int ext4_mb_good_group(struct ext4_allocation_context *ac, |
1825 | ext4_group_t group, int cr) | 1865 | ext4_group_t group, int cr) |
1826 | { | 1866 | { |
1827 | unsigned free, fragments; | 1867 | unsigned free, fragments; |
1828 | unsigned i, bits; | ||
1829 | int flex_size = ext4_flex_bg_size(EXT4_SB(ac->ac_sb)); | 1868 | int flex_size = ext4_flex_bg_size(EXT4_SB(ac->ac_sb)); |
1830 | struct ext4_group_info *grp = ext4_get_group_info(ac->ac_sb, group); | 1869 | struct ext4_group_info *grp = ext4_get_group_info(ac->ac_sb, group); |
1831 | 1870 | ||
1832 | BUG_ON(cr < 0 || cr >= 4); | 1871 | BUG_ON(cr < 0 || cr >= 4); |
1833 | BUG_ON(EXT4_MB_GRP_NEED_INIT(grp)); | 1872 | |
1873 | /* We only do this if the grp has never been initialized */ | ||
1874 | if (unlikely(EXT4_MB_GRP_NEED_INIT(grp))) { | ||
1875 | int ret = ext4_mb_init_group(ac->ac_sb, group); | ||
1876 | if (ret) | ||
1877 | return 0; | ||
1878 | } | ||
1834 | 1879 | ||
1835 | free = grp->bb_free; | 1880 | free = grp->bb_free; |
1836 | fragments = grp->bb_fragments; | 1881 | fragments = grp->bb_fragments; |
@@ -1843,17 +1888,16 @@ static int ext4_mb_good_group(struct ext4_allocation_context *ac, | |||
1843 | case 0: | 1888 | case 0: |
1844 | BUG_ON(ac->ac_2order == 0); | 1889 | BUG_ON(ac->ac_2order == 0); |
1845 | 1890 | ||
1891 | if (grp->bb_largest_free_order < ac->ac_2order) | ||
1892 | return 0; | ||
1893 | |||
1846 | /* Avoid using the first bg of a flexgroup for data files */ | 1894 | /* Avoid using the first bg of a flexgroup for data files */ |
1847 | if ((ac->ac_flags & EXT4_MB_HINT_DATA) && | 1895 | if ((ac->ac_flags & EXT4_MB_HINT_DATA) && |
1848 | (flex_size >= EXT4_FLEX_SIZE_DIR_ALLOC_SCHEME) && | 1896 | (flex_size >= EXT4_FLEX_SIZE_DIR_ALLOC_SCHEME) && |
1849 | ((group % flex_size) == 0)) | 1897 | ((group % flex_size) == 0)) |
1850 | return 0; | 1898 | return 0; |
1851 | 1899 | ||
1852 | bits = ac->ac_sb->s_blocksize_bits + 1; | 1900 | return 1; |
1853 | for (i = ac->ac_2order; i <= bits; i++) | ||
1854 | if (grp->bb_counters[i] > 0) | ||
1855 | return 1; | ||
1856 | break; | ||
1857 | case 1: | 1901 | case 1: |
1858 | if ((free / fragments) >= ac->ac_g_ex.fe_len) | 1902 | if ((free / fragments) >= ac->ac_g_ex.fe_len) |
1859 | return 1; | 1903 | return 1; |
@@ -1964,7 +2008,7 @@ ext4_mb_regular_allocator(struct ext4_allocation_context *ac) | |||
1964 | sbi = EXT4_SB(sb); | 2008 | sbi = EXT4_SB(sb); |
1965 | ngroups = ext4_get_groups_count(sb); | 2009 | ngroups = ext4_get_groups_count(sb); |
1966 | /* non-extent files are limited to low blocks/groups */ | 2010 | /* non-extent files are limited to low blocks/groups */ |
1967 | if (!(EXT4_I(ac->ac_inode)->i_flags & EXT4_EXTENTS_FL)) | 2011 | if (!(ext4_test_inode_flag(ac->ac_inode, EXT4_INODE_EXTENTS))) |
1968 | ngroups = sbi->s_blockfile_groups; | 2012 | ngroups = sbi->s_blockfile_groups; |
1969 | 2013 | ||
1970 | BUG_ON(ac->ac_status == AC_STATUS_FOUND); | 2014 | BUG_ON(ac->ac_status == AC_STATUS_FOUND); |
@@ -2024,15 +2068,11 @@ repeat: | |||
2024 | group = ac->ac_g_ex.fe_group; | 2068 | group = ac->ac_g_ex.fe_group; |
2025 | 2069 | ||
2026 | for (i = 0; i < ngroups; group++, i++) { | 2070 | for (i = 0; i < ngroups; group++, i++) { |
2027 | struct ext4_group_info *grp; | ||
2028 | struct ext4_group_desc *desc; | ||
2029 | |||
2030 | if (group == ngroups) | 2071 | if (group == ngroups) |
2031 | group = 0; | 2072 | group = 0; |
2032 | 2073 | ||
2033 | /* quick check to skip empty groups */ | 2074 | /* This now checks without needing the buddy page */ |
2034 | grp = ext4_get_group_info(sb, group); | 2075 | if (!ext4_mb_good_group(ac, group, cr)) |
2035 | if (grp->bb_free == 0) | ||
2036 | continue; | 2076 | continue; |
2037 | 2077 | ||
2038 | err = ext4_mb_load_buddy(sb, group, &e4b); | 2078 | err = ext4_mb_load_buddy(sb, group, &e4b); |
@@ -2040,15 +2080,18 @@ repeat: | |||
2040 | goto out; | 2080 | goto out; |
2041 | 2081 | ||
2042 | ext4_lock_group(sb, group); | 2082 | ext4_lock_group(sb, group); |
2083 | |||
2084 | /* | ||
2085 | * We need to check again after locking the | ||
2086 | * block group | ||
2087 | */ | ||
2043 | if (!ext4_mb_good_group(ac, group, cr)) { | 2088 | if (!ext4_mb_good_group(ac, group, cr)) { |
2044 | /* someone did allocation from this group */ | ||
2045 | ext4_unlock_group(sb, group); | 2089 | ext4_unlock_group(sb, group); |
2046 | ext4_mb_release_desc(&e4b); | 2090 | ext4_mb_unload_buddy(&e4b); |
2047 | continue; | 2091 | continue; |
2048 | } | 2092 | } |
2049 | 2093 | ||
2050 | ac->ac_groups_scanned++; | 2094 | ac->ac_groups_scanned++; |
2051 | desc = ext4_get_group_desc(sb, group, NULL); | ||
2052 | if (cr == 0) | 2095 | if (cr == 0) |
2053 | ext4_mb_simple_scan_group(ac, &e4b); | 2096 | ext4_mb_simple_scan_group(ac, &e4b); |
2054 | else if (cr == 1 && | 2097 | else if (cr == 1 && |
@@ -2058,7 +2101,7 @@ repeat: | |||
2058 | ext4_mb_complex_scan_group(ac, &e4b); | 2101 | ext4_mb_complex_scan_group(ac, &e4b); |
2059 | 2102 | ||
2060 | ext4_unlock_group(sb, group); | 2103 | ext4_unlock_group(sb, group); |
2061 | ext4_mb_release_desc(&e4b); | 2104 | ext4_mb_unload_buddy(&e4b); |
2062 | 2105 | ||
2063 | if (ac->ac_status != AC_STATUS_CONTINUE) | 2106 | if (ac->ac_status != AC_STATUS_CONTINUE) |
2064 | break; | 2107 | break; |
@@ -2148,7 +2191,7 @@ static int ext4_mb_seq_groups_show(struct seq_file *seq, void *v) | |||
2148 | ext4_lock_group(sb, group); | 2191 | ext4_lock_group(sb, group); |
2149 | memcpy(&sg, ext4_get_group_info(sb, group), i); | 2192 | memcpy(&sg, ext4_get_group_info(sb, group), i); |
2150 | ext4_unlock_group(sb, group); | 2193 | ext4_unlock_group(sb, group); |
2151 | ext4_mb_release_desc(&e4b); | 2194 | ext4_mb_unload_buddy(&e4b); |
2152 | 2195 | ||
2153 | seq_printf(seq, "#%-5u: %-5u %-5u %-5u [", group, sg.info.bb_free, | 2196 | seq_printf(seq, "#%-5u: %-5u %-5u %-5u [", group, sg.info.bb_free, |
2154 | sg.info.bb_fragments, sg.info.bb_first_free); | 2197 | sg.info.bb_fragments, sg.info.bb_first_free); |
@@ -2255,6 +2298,7 @@ int ext4_mb_add_groupinfo(struct super_block *sb, ext4_group_t group, | |||
2255 | INIT_LIST_HEAD(&meta_group_info[i]->bb_prealloc_list); | 2298 | INIT_LIST_HEAD(&meta_group_info[i]->bb_prealloc_list); |
2256 | init_rwsem(&meta_group_info[i]->alloc_sem); | 2299 | init_rwsem(&meta_group_info[i]->alloc_sem); |
2257 | meta_group_info[i]->bb_free_root = RB_ROOT; | 2300 | meta_group_info[i]->bb_free_root = RB_ROOT; |
2301 | meta_group_info[i]->bb_largest_free_order = -1; /* uninit */ | ||
2258 | 2302 | ||
2259 | #ifdef DOUBLE_CHECK | 2303 | #ifdef DOUBLE_CHECK |
2260 | { | 2304 | { |
@@ -2536,6 +2580,7 @@ static void release_blocks_on_commit(journal_t *journal, transaction_t *txn) | |||
2536 | entry->count, entry->group, entry); | 2580 | entry->count, entry->group, entry); |
2537 | 2581 | ||
2538 | if (test_opt(sb, DISCARD)) { | 2582 | if (test_opt(sb, DISCARD)) { |
2583 | int ret; | ||
2539 | ext4_fsblk_t discard_block; | 2584 | ext4_fsblk_t discard_block; |
2540 | 2585 | ||
2541 | discard_block = entry->start_blk + | 2586 | discard_block = entry->start_blk + |
@@ -2543,7 +2588,12 @@ static void release_blocks_on_commit(journal_t *journal, transaction_t *txn) | |||
2543 | trace_ext4_discard_blocks(sb, | 2588 | trace_ext4_discard_blocks(sb, |
2544 | (unsigned long long)discard_block, | 2589 | (unsigned long long)discard_block, |
2545 | entry->count); | 2590 | entry->count); |
2546 | sb_issue_discard(sb, discard_block, entry->count); | 2591 | ret = sb_issue_discard(sb, discard_block, entry->count); |
2592 | if (ret == EOPNOTSUPP) { | ||
2593 | ext4_warning(sb, | ||
2594 | "discard not supported, disabling"); | ||
2595 | clear_opt(EXT4_SB(sb)->s_mount_opt, DISCARD); | ||
2596 | } | ||
2547 | } | 2597 | } |
2548 | 2598 | ||
2549 | err = ext4_mb_load_buddy(sb, entry->group, &e4b); | 2599 | err = ext4_mb_load_buddy(sb, entry->group, &e4b); |
@@ -2568,7 +2618,7 @@ static void release_blocks_on_commit(journal_t *journal, transaction_t *txn) | |||
2568 | } | 2618 | } |
2569 | ext4_unlock_group(sb, entry->group); | 2619 | ext4_unlock_group(sb, entry->group); |
2570 | kmem_cache_free(ext4_free_ext_cachep, entry); | 2620 | kmem_cache_free(ext4_free_ext_cachep, entry); |
2571 | ext4_mb_release_desc(&e4b); | 2621 | ext4_mb_unload_buddy(&e4b); |
2572 | } | 2622 | } |
2573 | 2623 | ||
2574 | mb_debug(1, "freed %u blocks in %u structures\n", count, count2); | 2624 | mb_debug(1, "freed %u blocks in %u structures\n", count, count2); |
@@ -2641,7 +2691,7 @@ int __init init_ext4_mballoc(void) | |||
2641 | 2691 | ||
2642 | void exit_ext4_mballoc(void) | 2692 | void exit_ext4_mballoc(void) |
2643 | { | 2693 | { |
2644 | /* | 2694 | /* |
2645 | * Wait for completion of call_rcu()'s on ext4_pspace_cachep | 2695 | * Wait for completion of call_rcu()'s on ext4_pspace_cachep |
2646 | * before destroying the slab cache. | 2696 | * before destroying the slab cache. |
2647 | */ | 2697 | */ |
@@ -2981,7 +3031,7 @@ static void ext4_mb_collect_stats(struct ext4_allocation_context *ac) | |||
2981 | if (sbi->s_mb_stats && ac->ac_g_ex.fe_len > 1) { | 3031 | if (sbi->s_mb_stats && ac->ac_g_ex.fe_len > 1) { |
2982 | atomic_inc(&sbi->s_bal_reqs); | 3032 | atomic_inc(&sbi->s_bal_reqs); |
2983 | atomic_add(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated); | 3033 | atomic_add(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated); |
2984 | if (ac->ac_o_ex.fe_len >= ac->ac_g_ex.fe_len) | 3034 | if (ac->ac_b_ex.fe_len >= ac->ac_o_ex.fe_len) |
2985 | atomic_inc(&sbi->s_bal_success); | 3035 | atomic_inc(&sbi->s_bal_success); |
2986 | atomic_add(ac->ac_found, &sbi->s_bal_ex_scanned); | 3036 | atomic_add(ac->ac_found, &sbi->s_bal_ex_scanned); |
2987 | if (ac->ac_g_ex.fe_start == ac->ac_b_ex.fe_start && | 3037 | if (ac->ac_g_ex.fe_start == ac->ac_b_ex.fe_start && |
@@ -3123,7 +3173,7 @@ ext4_mb_use_preallocated(struct ext4_allocation_context *ac) | |||
3123 | continue; | 3173 | continue; |
3124 | 3174 | ||
3125 | /* non-extent files can't have physical blocks past 2^32 */ | 3175 | /* non-extent files can't have physical blocks past 2^32 */ |
3126 | if (!(EXT4_I(ac->ac_inode)->i_flags & EXT4_EXTENTS_FL) && | 3176 | if (!(ext4_test_inode_flag(ac->ac_inode, EXT4_INODE_EXTENTS)) && |
3127 | pa->pa_pstart + pa->pa_len > EXT4_MAX_BLOCK_FILE_PHYS) | 3177 | pa->pa_pstart + pa->pa_len > EXT4_MAX_BLOCK_FILE_PHYS) |
3128 | continue; | 3178 | continue; |
3129 | 3179 | ||
@@ -3280,7 +3330,7 @@ static void ext4_mb_put_pa(struct ext4_allocation_context *ac, | |||
3280 | spin_unlock(&pa->pa_lock); | 3330 | spin_unlock(&pa->pa_lock); |
3281 | 3331 | ||
3282 | grp_blk = pa->pa_pstart; | 3332 | grp_blk = pa->pa_pstart; |
3283 | /* | 3333 | /* |
3284 | * If doing group-based preallocation, pa_pstart may be in the | 3334 | * If doing group-based preallocation, pa_pstart may be in the |
3285 | * next group when pa is used up | 3335 | * next group when pa is used up |
3286 | */ | 3336 | */ |
@@ -3697,7 +3747,7 @@ out: | |||
3697 | ext4_unlock_group(sb, group); | 3747 | ext4_unlock_group(sb, group); |
3698 | if (ac) | 3748 | if (ac) |
3699 | kmem_cache_free(ext4_ac_cachep, ac); | 3749 | kmem_cache_free(ext4_ac_cachep, ac); |
3700 | ext4_mb_release_desc(&e4b); | 3750 | ext4_mb_unload_buddy(&e4b); |
3701 | put_bh(bitmap_bh); | 3751 | put_bh(bitmap_bh); |
3702 | return free; | 3752 | return free; |
3703 | } | 3753 | } |
@@ -3801,7 +3851,7 @@ repeat: | |||
3801 | if (bitmap_bh == NULL) { | 3851 | if (bitmap_bh == NULL) { |
3802 | ext4_error(sb, "Error reading block bitmap for %u", | 3852 | ext4_error(sb, "Error reading block bitmap for %u", |
3803 | group); | 3853 | group); |
3804 | ext4_mb_release_desc(&e4b); | 3854 | ext4_mb_unload_buddy(&e4b); |
3805 | continue; | 3855 | continue; |
3806 | } | 3856 | } |
3807 | 3857 | ||
@@ -3810,7 +3860,7 @@ repeat: | |||
3810 | ext4_mb_release_inode_pa(&e4b, bitmap_bh, pa, ac); | 3860 | ext4_mb_release_inode_pa(&e4b, bitmap_bh, pa, ac); |
3811 | ext4_unlock_group(sb, group); | 3861 | ext4_unlock_group(sb, group); |
3812 | 3862 | ||
3813 | ext4_mb_release_desc(&e4b); | 3863 | ext4_mb_unload_buddy(&e4b); |
3814 | put_bh(bitmap_bh); | 3864 | put_bh(bitmap_bh); |
3815 | 3865 | ||
3816 | list_del(&pa->u.pa_tmp_list); | 3866 | list_del(&pa->u.pa_tmp_list); |
@@ -4074,7 +4124,7 @@ ext4_mb_discard_lg_preallocations(struct super_block *sb, | |||
4074 | ext4_mb_release_group_pa(&e4b, pa, ac); | 4124 | ext4_mb_release_group_pa(&e4b, pa, ac); |
4075 | ext4_unlock_group(sb, group); | 4125 | ext4_unlock_group(sb, group); |
4076 | 4126 | ||
4077 | ext4_mb_release_desc(&e4b); | 4127 | ext4_mb_unload_buddy(&e4b); |
4078 | list_del(&pa->u.pa_tmp_list); | 4128 | list_del(&pa->u.pa_tmp_list); |
4079 | call_rcu(&(pa)->u.pa_rcu, ext4_mb_pa_callback); | 4129 | call_rcu(&(pa)->u.pa_rcu, ext4_mb_pa_callback); |
4080 | } | 4130 | } |
@@ -4484,12 +4534,12 @@ void ext4_free_blocks(handle_t *handle, struct inode *inode, | |||
4484 | if (!bh) | 4534 | if (!bh) |
4485 | tbh = sb_find_get_block(inode->i_sb, | 4535 | tbh = sb_find_get_block(inode->i_sb, |
4486 | block + i); | 4536 | block + i); |
4487 | ext4_forget(handle, flags & EXT4_FREE_BLOCKS_METADATA, | 4537 | ext4_forget(handle, flags & EXT4_FREE_BLOCKS_METADATA, |
4488 | inode, tbh, block + i); | 4538 | inode, tbh, block + i); |
4489 | } | 4539 | } |
4490 | } | 4540 | } |
4491 | 4541 | ||
4492 | /* | 4542 | /* |
4493 | * We need to make sure we don't reuse the freed block until | 4543 | * We need to make sure we don't reuse the freed block until |
4494 | * after the transaction is committed, which we can do by | 4544 | * after the transaction is committed, which we can do by |
4495 | * treating the block as metadata, below. We make an | 4545 | * treating the block as metadata, below. We make an |
@@ -4610,7 +4660,7 @@ do_more: | |||
4610 | atomic_add(count, &sbi->s_flex_groups[flex_group].free_blocks); | 4660 | atomic_add(count, &sbi->s_flex_groups[flex_group].free_blocks); |
4611 | } | 4661 | } |
4612 | 4662 | ||
4613 | ext4_mb_release_desc(&e4b); | 4663 | ext4_mb_unload_buddy(&e4b); |
4614 | 4664 | ||
4615 | freed += count; | 4665 | freed += count; |
4616 | 4666 | ||