@@ -90,12 +90,12 @@ xfs_rtbuf_get(
9090 if (issum ) {
9191 cbpp = & args -> sumbp ;
9292 coffp = & args -> sumoff ;
93- ip = mp -> m_rsumip ;
93+ ip = args -> rtg -> rtg_inodes [ XFS_RTGI_SUMMARY ] ;
9494 type = XFS_BLFT_RTSUMMARY_BUF ;
9595 } else {
9696 cbpp = & args -> rbmbp ;
9797 coffp = & args -> rbmoff ;
98- ip = mp -> m_rbmip ;
98+ ip = args -> rtg -> rtg_inodes [ XFS_RTGI_BITMAP ] ;
9999 type = XFS_BLFT_RTBITMAP_BUF ;
100100 }
101101
@@ -503,6 +503,7 @@ xfs_rtmodify_summary(
503503{
504504 struct xfs_mount * mp = args -> mp ;
505505 xfs_rtsumoff_t so = xfs_rtsumoffs (mp , log , bbno );
506+ uint8_t * rsum_cache = args -> rtg -> rtg_rsum_cache ;
506507 unsigned int infoword ;
507508 xfs_suminfo_t val ;
508509 int error ;
@@ -514,11 +515,11 @@ xfs_rtmodify_summary(
514515 infoword = xfs_rtsumoffs_to_infoword (mp , so );
515516 val = xfs_suminfo_add (args , infoword , delta );
516517
517- if (mp -> m_rsum_cache ) {
518- if (val == 0 && log + 1 == mp -> m_rsum_cache [bbno ])
519- mp -> m_rsum_cache [bbno ] = log ;
520- if (val != 0 && log >= mp -> m_rsum_cache [bbno ])
521- mp -> m_rsum_cache [bbno ] = log + 1 ;
518+ if (rsum_cache ) {
519+ if (val == 0 && log + 1 == rsum_cache [bbno ])
520+ rsum_cache [bbno ] = log ;
521+ if (val != 0 && log >= rsum_cache [bbno ])
522+ rsum_cache [bbno ] = log + 1 ;
522523 }
523524
524525 xfs_trans_log_rtsummary (args , infoword );
@@ -737,7 +738,7 @@ xfs_rtfree_range(
737738 /*
738739 * Find the next allocated block (end of allocated extent).
739740 */
740- error = xfs_rtfind_forw (args , end , mp -> m_sb . sb_rextents - 1 ,
741+ error = xfs_rtfind_forw (args , end , args -> rtg -> rtg_extents - 1 ,
741742 & postblock );
742743 if (error )
743744 return error ;
@@ -961,19 +962,22 @@ xfs_rtcheck_alloc_range(
961962int
962963xfs_rtfree_extent (
963964 struct xfs_trans * tp , /* transaction pointer */
965+ struct xfs_rtgroup * rtg ,
964966 xfs_rtxnum_t start , /* starting rtext number to free */
965967 xfs_rtxlen_t len ) /* length of extent freed */
966968{
967969 struct xfs_mount * mp = tp -> t_mountp ;
970+ struct xfs_inode * rbmip = rtg -> rtg_inodes [XFS_RTGI_BITMAP ];
968971 struct xfs_rtalloc_args args = {
969972 .mp = mp ,
970973 .tp = tp ,
974+ .rtg = rtg ,
971975 };
972976 int error ;
973977 struct timespec64 atime ;
974978
975- ASSERT (mp -> m_rbmip -> i_itemp != NULL );
976- xfs_assert_ilocked (mp -> m_rbmip , XFS_ILOCK_EXCL );
979+ ASSERT (rbmip -> i_itemp != NULL );
980+ xfs_assert_ilocked (rbmip , XFS_ILOCK_EXCL );
977981
978982 error = xfs_rtcheck_alloc_range (& args , start , len );
979983 if (error )
@@ -996,13 +1000,13 @@ xfs_rtfree_extent(
9961000 */
9971001 if (tp -> t_frextents_delta + mp -> m_sb .sb_frextents ==
9981002 mp -> m_sb .sb_rextents ) {
999- if (!(mp -> m_rbmip -> i_diflags & XFS_DIFLAG_NEWRTBM ))
1000- mp -> m_rbmip -> i_diflags |= XFS_DIFLAG_NEWRTBM ;
1003+ if (!(rbmip -> i_diflags & XFS_DIFLAG_NEWRTBM ))
1004+ rbmip -> i_diflags |= XFS_DIFLAG_NEWRTBM ;
10011005
1002- atime = inode_get_atime (VFS_I (mp -> m_rbmip ));
1006+ atime = inode_get_atime (VFS_I (rbmip ));
10031007 atime .tv_sec = 0 ;
1004- inode_set_atime_to_ts (VFS_I (mp -> m_rbmip ), atime );
1005- xfs_trans_log_inode (tp , mp -> m_rbmip , XFS_ILOG_CORE );
1008+ inode_set_atime_to_ts (VFS_I (rbmip ), atime );
1009+ xfs_trans_log_inode (tp , rbmip , XFS_ILOG_CORE );
10061010 }
10071011 error = 0 ;
10081012out :
@@ -1018,6 +1022,7 @@ xfs_rtfree_extent(
10181022int
10191023xfs_rtfree_blocks (
10201024 struct xfs_trans * tp ,
1025+ struct xfs_rtgroup * rtg ,
10211026 xfs_fsblock_t rtbno ,
10221027 xfs_filblks_t rtlen )
10231028{
@@ -1038,32 +1043,34 @@ xfs_rtfree_blocks(
10381043 return - EIO ;
10391044 }
10401045
1041- return xfs_rtfree_extent (tp , xfs_rtb_to_rtx (mp , rtbno ),
1042- xfs_rtb_to_rtx (mp , rtlen ));
1046+ return xfs_rtfree_extent (tp , rtg , xfs_rtb_to_rtx (mp , rtbno ),
1047+ xfs_extlen_to_rtxlen (mp , rtlen ));
10431048}
10441049
10451050/* Find all the free records within a given range. */
10461051int
10471052xfs_rtalloc_query_range (
1048- struct xfs_mount * mp ,
1053+ struct xfs_rtgroup * rtg ,
10491054 struct xfs_trans * tp ,
10501055 xfs_rtxnum_t start ,
10511056 xfs_rtxnum_t end ,
10521057 xfs_rtalloc_query_range_fn fn ,
10531058 void * priv )
10541059{
1060+ struct xfs_mount * mp = rtg_mount (rtg );
10551061 struct xfs_rtalloc_args args = {
1062+ .rtg = rtg ,
10561063 .mp = mp ,
10571064 .tp = tp ,
10581065 };
10591066 int error = 0 ;
10601067
10611068 if (start > end )
10621069 return - EINVAL ;
1063- if (start == end || start >= mp -> m_sb . sb_rextents )
1070+ if (start == end || start >= rtg -> rtg_extents )
10641071 return 0 ;
10651072
1066- end = min (end , mp -> m_sb . sb_rextents - 1 );
1073+ end = min (end , rtg -> rtg_extents - 1 );
10671074
10681075 /* Iterate the bitmap, looking for discrepancies. */
10691076 while (start <= end ) {
@@ -1086,7 +1093,7 @@ xfs_rtalloc_query_range(
10861093 rec .ar_startext = start ;
10871094 rec .ar_extcount = rtend - start + 1 ;
10881095
1089- error = fn (mp , tp , & rec , priv );
1096+ error = fn (rtg , tp , & rec , priv );
10901097 if (error )
10911098 break ;
10921099 }
@@ -1101,26 +1108,27 @@ xfs_rtalloc_query_range(
11011108/* Find all the free records. */
11021109int
11031110xfs_rtalloc_query_all (
1104- struct xfs_mount * mp ,
1111+ struct xfs_rtgroup * rtg ,
11051112 struct xfs_trans * tp ,
11061113 xfs_rtalloc_query_range_fn fn ,
11071114 void * priv )
11081115{
1109- return xfs_rtalloc_query_range (mp , tp , 0 , mp -> m_sb . sb_rextents - 1 , fn ,
1116+ return xfs_rtalloc_query_range (rtg , tp , 0 , rtg -> rtg_extents - 1 , fn ,
11101117 priv );
11111118}
11121119
11131120/* Is the given extent all free? */
11141121int
11151122xfs_rtalloc_extent_is_free (
1116- struct xfs_mount * mp ,
1123+ struct xfs_rtgroup * rtg ,
11171124 struct xfs_trans * tp ,
11181125 xfs_rtxnum_t start ,
11191126 xfs_rtxlen_t len ,
11201127 bool * is_free )
11211128{
11221129 struct xfs_rtalloc_args args = {
1123- .mp = mp ,
1130+ .mp = rtg_mount (rtg ),
1131+ .rtg = rtg ,
11241132 .tp = tp ,
11251133 };
11261134 xfs_rtxnum_t end ;
@@ -1161,65 +1169,6 @@ xfs_rtsummary_blockcount(
11611169 return XFS_B_TO_FSB (mp , rsumwords << XFS_WORDLOG );
11621170}
11631171
1164- /* Lock both realtime free space metadata inodes for a freespace update. */
1165- void
1166- xfs_rtbitmap_lock (
1167- struct xfs_mount * mp )
1168- {
1169- xfs_ilock (mp -> m_rbmip , XFS_ILOCK_EXCL | XFS_ILOCK_RTBITMAP );
1170- xfs_ilock (mp -> m_rsumip , XFS_ILOCK_EXCL | XFS_ILOCK_RTSUM );
1171- }
1172-
1173- /*
1174- * Join both realtime free space metadata inodes to the transaction. The
1175- * ILOCKs will be released on transaction commit.
1176- */
1177- void
1178- xfs_rtbitmap_trans_join (
1179- struct xfs_trans * tp )
1180- {
1181- xfs_trans_ijoin (tp , tp -> t_mountp -> m_rbmip , XFS_ILOCK_EXCL );
1182- xfs_trans_ijoin (tp , tp -> t_mountp -> m_rsumip , XFS_ILOCK_EXCL );
1183- }
1184-
1185- /* Unlock both realtime free space metadata inodes after a freespace update. */
1186- void
1187- xfs_rtbitmap_unlock (
1188- struct xfs_mount * mp )
1189- {
1190- xfs_iunlock (mp -> m_rsumip , XFS_ILOCK_EXCL | XFS_ILOCK_RTSUM );
1191- xfs_iunlock (mp -> m_rbmip , XFS_ILOCK_EXCL | XFS_ILOCK_RTBITMAP );
1192- }
1193-
1194- /*
1195- * Lock the realtime free space metadata inodes for a freespace scan. Callers
1196- * must walk metadata blocks in order of increasing file offset.
1197- */
1198- void
1199- xfs_rtbitmap_lock_shared (
1200- struct xfs_mount * mp ,
1201- unsigned int rbmlock_flags )
1202- {
1203- if (rbmlock_flags & XFS_RBMLOCK_BITMAP )
1204- xfs_ilock (mp -> m_rbmip , XFS_ILOCK_SHARED | XFS_ILOCK_RTBITMAP );
1205-
1206- if (rbmlock_flags & XFS_RBMLOCK_SUMMARY )
1207- xfs_ilock (mp -> m_rsumip , XFS_ILOCK_SHARED | XFS_ILOCK_RTSUM );
1208- }
1209-
1210- /* Unlock the realtime free space metadata inodes after a freespace scan. */
1211- void
1212- xfs_rtbitmap_unlock_shared (
1213- struct xfs_mount * mp ,
1214- unsigned int rbmlock_flags )
1215- {
1216- if (rbmlock_flags & XFS_RBMLOCK_SUMMARY )
1217- xfs_iunlock (mp -> m_rsumip , XFS_ILOCK_SHARED | XFS_ILOCK_RTSUM );
1218-
1219- if (rbmlock_flags & XFS_RBMLOCK_BITMAP )
1220- xfs_iunlock (mp -> m_rbmip , XFS_ILOCK_SHARED | XFS_ILOCK_RTBITMAP );
1221- }
1222-
12231172static int
12241173xfs_rtfile_alloc_blocks (
12251174 struct xfs_inode * ip ,
@@ -1260,21 +1209,25 @@ xfs_rtfile_alloc_blocks(
12601209/* Get a buffer for the block. */
12611210static int
12621211xfs_rtfile_initialize_block (
1263- struct xfs_inode * ip ,
1212+ struct xfs_rtgroup * rtg ,
1213+ enum xfs_rtg_inodes type ,
12641214 xfs_fsblock_t fsbno ,
12651215 void * data )
12661216{
1267- struct xfs_mount * mp = ip -> i_mount ;
1217+ struct xfs_mount * mp = rtg_mount (rtg );
1218+ struct xfs_inode * ip = rtg -> rtg_inodes [type ];
12681219 struct xfs_trans * tp ;
12691220 struct xfs_buf * bp ;
12701221 const size_t copylen = mp -> m_blockwsize << XFS_WORDLOG ;
12711222 enum xfs_blft buf_type ;
12721223 int error ;
12731224
1274- if (ip == mp -> m_rsumip )
1225+ if (type == XFS_RTGI_BITMAP )
1226+ buf_type = XFS_BLFT_RTBITMAP_BUF ;
1227+ else if (type == XFS_RTGI_SUMMARY )
12751228 buf_type = XFS_BLFT_RTSUMMARY_BUF ;
12761229 else
1277- buf_type = XFS_BLFT_RTBITMAP_BUF ;
1230+ return - EINVAL ;
12781231
12791232 error = xfs_trans_alloc (mp , & M_RES (mp )-> tr_growrtzero , 0 , 0 , 0 , & tp );
12801233 if (error )
@@ -1306,21 +1259,22 @@ xfs_rtfile_initialize_block(
13061259 */
13071260int
13081261xfs_rtfile_initialize_blocks (
1309- struct xfs_inode * ip , /* inode (bitmap/summary) */
1262+ struct xfs_rtgroup * rtg ,
1263+ enum xfs_rtg_inodes type ,
13101264 xfs_fileoff_t offset_fsb , /* offset to start from */
13111265 xfs_fileoff_t end_fsb , /* offset to allocate to */
13121266 void * data ) /* data to fill the blocks */
13131267{
1314- struct xfs_mount * mp = ip -> i_mount ;
1268+ struct xfs_mount * mp = rtg_mount ( rtg ) ;
13151269 const size_t copylen = mp -> m_blockwsize << XFS_WORDLOG ;
13161270
13171271 while (offset_fsb < end_fsb ) {
13181272 struct xfs_bmbt_irec map ;
13191273 xfs_filblks_t i ;
13201274 int error ;
13211275
1322- error = xfs_rtfile_alloc_blocks (ip , offset_fsb ,
1323- end_fsb - offset_fsb , & map );
1276+ error = xfs_rtfile_alloc_blocks (rtg -> rtg_inodes [ type ] ,
1277+ offset_fsb , end_fsb - offset_fsb , & map );
13241278 if (error )
13251279 return error ;
13261280
@@ -1330,7 +1284,7 @@ xfs_rtfile_initialize_blocks(
13301284 * Do this one block per transaction, to keep it simple.
13311285 */
13321286 for (i = 0 ; i < map .br_blockcount ; i ++ ) {
1333- error = xfs_rtfile_initialize_block (ip ,
1287+ error = xfs_rtfile_initialize_block (rtg , type ,
13341288 map .br_startblock + i , data );
13351289 if (error )
13361290 return error ;
0 commit comments