@@ -756,7 +756,7 @@ mb_set_largest_free_order(struct super_block *sb, struct ext4_group_info *grp)
756
756
757
757
grp -> bb_largest_free_order = -1 ; /* uninit */
758
758
759
- bits = sb -> s_blocksize_bits + 1 ;
759
+ bits = MB_NUM_ORDERS ( sb ) - 1 ;
760
760
for (i = bits ; i >= 0 ; i -- ) {
761
761
if (grp -> bb_counters [i ] > 0 ) {
762
762
grp -> bb_largest_free_order = i ;
@@ -957,7 +957,7 @@ static int ext4_mb_init_cache(struct page *page, char *incore, gfp_t gfp)
957
957
grinfo -> bb_fragments = 0 ;
958
958
memset (grinfo -> bb_counters , 0 ,
959
959
sizeof (* grinfo -> bb_counters ) *
960
- ( sb -> s_blocksize_bits + 2 ));
960
+ ( MB_NUM_ORDERS ( sb ) ));
961
961
/*
962
962
* incore got set to the group block bitmap below
963
963
*/
@@ -1928,7 +1928,7 @@ void ext4_mb_simple_scan_group(struct ext4_allocation_context *ac,
1928
1928
int max ;
1929
1929
1930
1930
BUG_ON (ac -> ac_2order <= 0 );
1931
- for (i = ac -> ac_2order ; i <= sb -> s_blocksize_bits + 1 ; i ++ ) {
1931
+ for (i = ac -> ac_2order ; i < MB_NUM_ORDERS ( sb ) ; i ++ ) {
1932
1932
if (grp -> bb_counters [i ] == 0 )
1933
1933
continue ;
1934
1934
@@ -2107,7 +2107,7 @@ static bool ext4_mb_good_group(struct ext4_allocation_context *ac,
2107
2107
if (free < ac -> ac_g_ex .fe_len )
2108
2108
return false;
2109
2109
2110
- if (ac -> ac_2order > ac -> ac_sb -> s_blocksize_bits + 1 )
2110
+ if (ac -> ac_2order >= MB_NUM_ORDERS ( ac -> ac_sb ) )
2111
2111
return true;
2112
2112
2113
2113
if (grp -> bb_largest_free_order < ac -> ac_2order )
@@ -2315,13 +2315,13 @@ ext4_mb_regular_allocator(struct ext4_allocation_context *ac)
2315
2315
* We also support searching for power-of-two requests only for
2316
2316
* requests upto maximum buddy size we have constructed.
2317
2317
*/
2318
- if (i >= sbi -> s_mb_order2_reqs && i <= sb -> s_blocksize_bits + 2 ) {
2318
+ if (i >= sbi -> s_mb_order2_reqs && i <= MB_NUM_ORDERS ( sb ) ) {
2319
2319
/*
2320
2320
* This should tell if fe_len is exactly power of 2
2321
2321
*/
2322
2322
if ((ac -> ac_g_ex .fe_len & (~(1 << (i - 1 )))) == 0 )
2323
2323
ac -> ac_2order = array_index_nospec (i - 1 ,
2324
- sb -> s_blocksize_bits + 2 );
2324
+ MB_NUM_ORDERS ( sb ) );
2325
2325
}
2326
2326
2327
2327
/* if stream allocation is enabled, use global goal */
@@ -2880,15 +2880,15 @@ int ext4_mb_init(struct super_block *sb)
2880
2880
unsigned max ;
2881
2881
int ret ;
2882
2882
2883
- i = (sb -> s_blocksize_bits + 2 ) * sizeof (* sbi -> s_mb_offsets );
2883
+ i = MB_NUM_ORDERS (sb ) * sizeof (* sbi -> s_mb_offsets );
2884
2884
2885
2885
sbi -> s_mb_offsets = kmalloc (i , GFP_KERNEL );
2886
2886
if (sbi -> s_mb_offsets == NULL ) {
2887
2887
ret = - ENOMEM ;
2888
2888
goto out ;
2889
2889
}
2890
2890
2891
- i = (sb -> s_blocksize_bits + 2 ) * sizeof (* sbi -> s_mb_maxs );
2891
+ i = MB_NUM_ORDERS (sb ) * sizeof (* sbi -> s_mb_maxs );
2892
2892
sbi -> s_mb_maxs = kmalloc (i , GFP_KERNEL );
2893
2893
if (sbi -> s_mb_maxs == NULL ) {
2894
2894
ret = - ENOMEM ;
@@ -2914,7 +2914,8 @@ int ext4_mb_init(struct super_block *sb)
2914
2914
offset_incr = offset_incr >> 1 ;
2915
2915
max = max >> 1 ;
2916
2916
i ++ ;
2917
- } while (i <= sb -> s_blocksize_bits + 1 );
2917
+ } while (i < MB_NUM_ORDERS (sb ));
2918
+
2918
2919
2919
2920
spin_lock_init (& sbi -> s_md_lock );
2920
2921
sbi -> s_mb_free_pending = 0 ;
0 commit comments