@@ -273,9 +273,8 @@ xfs_alloc_complain_bad_rec(
273273 struct xfs_mount * mp = cur -> bc_mp ;
274274
275275 xfs_warn (mp ,
276- "%s Freespace BTree record corruption in AG %d detected at %pS!" ,
277- cur -> bc_btnum == XFS_BTNUM_BNO ? "Block" : "Size" ,
278- cur -> bc_ag .pag -> pag_agno , fa );
276+ "%sbt record corruption in AG %d detected at %pS!" ,
277+ cur -> bc_ops -> name , cur -> bc_ag .pag -> pag_agno , fa );
279278 xfs_warn (mp ,
280279 "start block 0x%x block count 0x%x" , irec -> ar_startblock ,
281280 irec -> ar_blockcount );
@@ -863,8 +862,8 @@ xfs_alloc_cur_setup(
863862 * attempt a small allocation.
864863 */
865864 if (!acur -> cnt )
866- acur -> cnt = xfs_allocbt_init_cursor (args -> mp , args -> tp ,
867- args -> agbp , args -> pag , XFS_BTNUM_CNT );
865+ acur -> cnt = xfs_cntbt_init_cursor (args -> mp , args -> tp ,
866+ args -> agbp , args -> pag );
868867 error = xfs_alloc_lookup_ge (acur -> cnt , 0 , args -> maxlen , & i );
869868 if (error )
870869 return error ;
@@ -873,11 +872,11 @@ xfs_alloc_cur_setup(
873872 * Allocate the bnobt left and right search cursors.
874873 */
875874 if (!acur -> bnolt )
876- acur -> bnolt = xfs_allocbt_init_cursor (args -> mp , args -> tp ,
877- args -> agbp , args -> pag , XFS_BTNUM_BNO );
875+ acur -> bnolt = xfs_bnobt_init_cursor (args -> mp , args -> tp ,
876+ args -> agbp , args -> pag );
878877 if (!acur -> bnogt )
879- acur -> bnogt = xfs_allocbt_init_cursor (args -> mp , args -> tp ,
880- args -> agbp , args -> pag , XFS_BTNUM_BNO );
878+ acur -> bnogt = xfs_bnobt_init_cursor (args -> mp , args -> tp ,
879+ args -> agbp , args -> pag );
881880 return i == 1 ? 0 : - ENOSPC ;
882881}
883882
@@ -919,7 +918,7 @@ xfs_alloc_cur_check(
919918 bool busy ;
920919 unsigned busy_gen = 0 ;
921920 bool deactivate = false;
922- bool isbnobt = cur -> bc_btnum == XFS_BTNUM_BNO ;
921+ bool isbnobt = xfs_btree_is_bno ( cur -> bc_ops ) ;
923922
924923 * new = 0 ;
925924
@@ -996,8 +995,7 @@ xfs_alloc_cur_check(
996995out :
997996 if (deactivate )
998997 cur -> bc_flags &= ~XFS_BTREE_ALLOCBT_ACTIVE ;
999- trace_xfs_alloc_cur_check (args -> mp , cur -> bc_btnum , bno , len , diff ,
1000- * new );
998+ trace_xfs_alloc_cur_check (cur , bno , len , diff , * new );
1001999 return 0 ;
10021000}
10031001
@@ -1236,8 +1234,8 @@ xfs_alloc_ag_vextent_exact(
12361234 /*
12371235 * Allocate/initialize a cursor for the by-number freespace btree.
12381236 */
1239- bno_cur = xfs_allocbt_init_cursor (args -> mp , args -> tp , args -> agbp ,
1240- args -> pag , XFS_BTNUM_BNO );
1237+ bno_cur = xfs_bnobt_init_cursor (args -> mp , args -> tp , args -> agbp ,
1238+ args -> pag );
12411239
12421240 /*
12431241 * Lookup bno and minlen in the btree (minlen is irrelevant, really).
@@ -1297,8 +1295,8 @@ xfs_alloc_ag_vextent_exact(
12971295 * We are allocating agbno for args->len
12981296 * Allocate/initialize a cursor for the by-size btree.
12991297 */
1300- cnt_cur = xfs_allocbt_init_cursor (args -> mp , args -> tp , args -> agbp ,
1301- args -> pag , XFS_BTNUM_CNT );
1298+ cnt_cur = xfs_cntbt_init_cursor (args -> mp , args -> tp , args -> agbp ,
1299+ args -> pag );
13021300 ASSERT (args -> agbno + args -> len <= be32_to_cpu (agf -> agf_length ));
13031301 error = xfs_alloc_fixup_trees (cnt_cur , bno_cur , fbno , flen , args -> agbno ,
13041302 args -> len , XFSA_FIXUP_BNO_OK );
@@ -1712,8 +1710,8 @@ xfs_alloc_ag_vextent_size(
17121710 /*
17131711 * Allocate and initialize a cursor for the by-size btree.
17141712 */
1715- cnt_cur = xfs_allocbt_init_cursor (args -> mp , args -> tp , args -> agbp ,
1716- args -> pag , XFS_BTNUM_CNT );
1713+ cnt_cur = xfs_cntbt_init_cursor (args -> mp , args -> tp , args -> agbp ,
1714+ args -> pag );
17171715 bno_cur = NULL ;
17181716
17191717 /*
@@ -1898,8 +1896,8 @@ xfs_alloc_ag_vextent_size(
18981896 /*
18991897 * Allocate and initialize a cursor for the by-block tree.
19001898 */
1901- bno_cur = xfs_allocbt_init_cursor (args -> mp , args -> tp , args -> agbp ,
1902- args -> pag , XFS_BTNUM_BNO );
1899+ bno_cur = xfs_bnobt_init_cursor (args -> mp , args -> tp , args -> agbp ,
1900+ args -> pag );
19031901 if ((error = xfs_alloc_fixup_trees (cnt_cur , bno_cur , fbno , flen ,
19041902 rbno , rlen , XFSA_FIXUP_CNT_OK )))
19051903 goto error0 ;
@@ -1973,7 +1971,7 @@ xfs_free_ag_extent(
19731971 /*
19741972 * Allocate and initialize a cursor for the by-block btree.
19751973 */
1976- bno_cur = xfs_allocbt_init_cursor (mp , tp , agbp , pag , XFS_BTNUM_BNO );
1974+ bno_cur = xfs_bnobt_init_cursor (mp , tp , agbp , pag );
19771975 /*
19781976 * Look for a neighboring block on the left (lower block numbers)
19791977 * that is contiguous with this space.
@@ -2047,7 +2045,7 @@ xfs_free_ag_extent(
20472045 /*
20482046 * Now allocate and initialize a cursor for the by-size tree.
20492047 */
2050- cnt_cur = xfs_allocbt_init_cursor (mp , tp , agbp , pag , XFS_BTNUM_CNT );
2048+ cnt_cur = xfs_cntbt_init_cursor (mp , tp , agbp , pag );
20512049 /*
20522050 * Have both left and right contiguous neighbors.
20532051 * Merge all three into a single free block.
@@ -2335,8 +2333,9 @@ xfs_alloc_min_freelist(
23352333 struct xfs_perag * pag )
23362334{
23372335 /* AG btrees have at least 1 level. */
2338- static const uint8_t fake_levels [XFS_BTNUM_AGF ] = {1 , 1 , 1 };
2339- const uint8_t * levels = pag ? pag -> pagf_levels : fake_levels ;
2336+ const unsigned int bno_level = pag ? pag -> pagf_bno_level : 1 ;
2337+ const unsigned int cnt_level = pag ? pag -> pagf_cnt_level : 1 ;
2338+ const unsigned int rmap_level = pag ? pag -> pagf_rmap_level : 1 ;
23402339 unsigned int min_free ;
23412340
23422341 ASSERT (mp -> m_alloc_maxlevels > 0 );
@@ -2363,16 +2362,12 @@ xfs_alloc_min_freelist(
23632362 */
23642363
23652364 /* space needed by-bno freespace btree */
2366- min_free = min_t (unsigned int , levels [XFS_BTNUM_BNOi ] + 1 ,
2367- mp -> m_alloc_maxlevels ) * 2 - 2 ;
2365+ min_free = min (bno_level + 1 , mp -> m_alloc_maxlevels ) * 2 - 2 ;
23682366 /* space needed by-size freespace btree */
2369- min_free += min_t (unsigned int , levels [XFS_BTNUM_CNTi ] + 1 ,
2370- mp -> m_alloc_maxlevels ) * 2 - 2 ;
2367+ min_free += min (cnt_level + 1 , mp -> m_alloc_maxlevels ) * 2 - 2 ;
23712368 /* space needed reverse mapping used space btree */
23722369 if (xfs_has_rmapbt (mp ))
2373- min_free += min_t (unsigned int , levels [XFS_BTNUM_RMAPi ] + 1 ,
2374- mp -> m_rmap_maxlevels ) * 2 - 2 ;
2375-
2370+ min_free += min (rmap_level + 1 , mp -> m_rmap_maxlevels ) * 2 - 2 ;
23762371 return min_free ;
23772372}
23782373
@@ -2759,8 +2754,8 @@ xfs_exact_minlen_extent_available(
27592754 xfs_extlen_t flen ;
27602755 int error = 0 ;
27612756
2762- cnt_cur = xfs_allocbt_init_cursor (args -> mp , args -> tp , agbp ,
2763- args -> pag , XFS_BTNUM_CNT );
2757+ cnt_cur = xfs_cntbt_init_cursor (args -> mp , args -> tp , agbp ,
2758+ args -> pag );
27642759 error = xfs_alloc_lookup_ge (cnt_cur , 0 , args -> minlen , stat );
27652760 if (error )
27662761 goto out ;
@@ -3056,8 +3051,8 @@ xfs_alloc_log_agf(
30563051 offsetof(xfs_agf_t , agf_versionnum ),
30573052 offsetof(xfs_agf_t , agf_seqno ),
30583053 offsetof(xfs_agf_t , agf_length ),
3059- offsetof(xfs_agf_t , agf_roots [ 0 ]),
3060- offsetof(xfs_agf_t , agf_levels [ 0 ]),
3054+ offsetof(xfs_agf_t , agf_bno_root ), /* also cnt/rmap root */
3055+ offsetof(xfs_agf_t , agf_bno_level ), /* also cnt/rmap levels */
30613056 offsetof(xfs_agf_t , agf_flfirst ),
30623057 offsetof(xfs_agf_t , agf_fllast ),
30633058 offsetof(xfs_agf_t , agf_flcount ),
@@ -3236,12 +3231,10 @@ xfs_agf_verify(
32363231 be32_to_cpu (agf -> agf_freeblks ) > agf_length )
32373232 return __this_address ;
32383233
3239- if (be32_to_cpu (agf -> agf_levels [XFS_BTNUM_BNO ]) < 1 ||
3240- be32_to_cpu (agf -> agf_levels [XFS_BTNUM_CNT ]) < 1 ||
3241- be32_to_cpu (agf -> agf_levels [XFS_BTNUM_BNO ]) >
3242- mp -> m_alloc_maxlevels ||
3243- be32_to_cpu (agf -> agf_levels [XFS_BTNUM_CNT ]) >
3244- mp -> m_alloc_maxlevels )
3234+ if (be32_to_cpu (agf -> agf_bno_level ) < 1 ||
3235+ be32_to_cpu (agf -> agf_cnt_level ) < 1 ||
3236+ be32_to_cpu (agf -> agf_bno_level ) > mp -> m_alloc_maxlevels ||
3237+ be32_to_cpu (agf -> agf_cnt_level ) > mp -> m_alloc_maxlevels )
32453238 return __this_address ;
32463239
32473240 if (xfs_has_lazysbcount (mp ) &&
@@ -3252,9 +3245,8 @@ xfs_agf_verify(
32523245 if (be32_to_cpu (agf -> agf_rmap_blocks ) > agf_length )
32533246 return __this_address ;
32543247
3255- if (be32_to_cpu (agf -> agf_levels [XFS_BTNUM_RMAP ]) < 1 ||
3256- be32_to_cpu (agf -> agf_levels [XFS_BTNUM_RMAP ]) >
3257- mp -> m_rmap_maxlevels )
3248+ if (be32_to_cpu (agf -> agf_rmap_level ) < 1 ||
3249+ be32_to_cpu (agf -> agf_rmap_level ) > mp -> m_rmap_maxlevels )
32583250 return __this_address ;
32593251 }
32603252
@@ -3380,12 +3372,9 @@ xfs_alloc_read_agf(
33803372 pag -> pagf_btreeblks = be32_to_cpu (agf -> agf_btreeblks );
33813373 pag -> pagf_flcount = be32_to_cpu (agf -> agf_flcount );
33823374 pag -> pagf_longest = be32_to_cpu (agf -> agf_longest );
3383- pag -> pagf_levels [XFS_BTNUM_BNOi ] =
3384- be32_to_cpu (agf -> agf_levels [XFS_BTNUM_BNOi ]);
3385- pag -> pagf_levels [XFS_BTNUM_CNTi ] =
3386- be32_to_cpu (agf -> agf_levels [XFS_BTNUM_CNTi ]);
3387- pag -> pagf_levels [XFS_BTNUM_RMAPi ] =
3388- be32_to_cpu (agf -> agf_levels [XFS_BTNUM_RMAPi ]);
3375+ pag -> pagf_bno_level = be32_to_cpu (agf -> agf_bno_level );
3376+ pag -> pagf_cnt_level = be32_to_cpu (agf -> agf_cnt_level );
3377+ pag -> pagf_rmap_level = be32_to_cpu (agf -> agf_rmap_level );
33893378 pag -> pagf_refcount_level = be32_to_cpu (agf -> agf_refcount_level );
33903379 if (xfs_agfl_needs_reset (pag -> pag_mount , agf ))
33913380 set_bit (XFS_AGSTATE_AGFL_NEEDS_RESET , & pag -> pag_opstate );
@@ -3414,10 +3403,8 @@ xfs_alloc_read_agf(
34143403 ASSERT (pag -> pagf_btreeblks == be32_to_cpu (agf -> agf_btreeblks ));
34153404 ASSERT (pag -> pagf_flcount == be32_to_cpu (agf -> agf_flcount ));
34163405 ASSERT (pag -> pagf_longest == be32_to_cpu (agf -> agf_longest ));
3417- ASSERT (pag -> pagf_levels [XFS_BTNUM_BNOi ] ==
3418- be32_to_cpu (agf -> agf_levels [XFS_BTNUM_BNOi ]));
3419- ASSERT (pag -> pagf_levels [XFS_BTNUM_CNTi ] ==
3420- be32_to_cpu (agf -> agf_levels [XFS_BTNUM_CNTi ]));
3406+ ASSERT (pag -> pagf_bno_level == be32_to_cpu (agf -> agf_bno_level ));
3407+ ASSERT (pag -> pagf_cnt_level == be32_to_cpu (agf -> agf_cnt_level ));
34213408 }
34223409#endif
34233410 if (agfbpp )
@@ -4039,7 +4026,7 @@ xfs_alloc_query_range(
40394026 union xfs_btree_irec high_brec = { .a = * high_rec };
40404027 struct xfs_alloc_query_range_info query = { .priv = priv , .fn = fn };
40414028
4042- ASSERT (cur -> bc_btnum == XFS_BTNUM_BNO );
4029+ ASSERT (xfs_btree_is_bno ( cur -> bc_ops ) );
40434030 return xfs_btree_query_range (cur , & low_brec , & high_brec ,
40444031 xfs_alloc_query_range_helper , & query );
40454032}
@@ -4053,7 +4040,7 @@ xfs_alloc_query_all(
40534040{
40544041 struct xfs_alloc_query_range_info query ;
40554042
4056- ASSERT (cur -> bc_btnum == XFS_BTNUM_BNO );
4043+ ASSERT (xfs_btree_is_bno ( cur -> bc_ops ) );
40574044 query .priv = priv ;
40584045 query .fn = fn ;
40594046 return xfs_btree_query_all (cur , xfs_alloc_query_range_helper , & query );
0 commit comments