@@ -90,12 +90,12 @@ xfs_rtbuf_get(
90
90
if (issum ) {
91
91
cbpp = & args -> sumbp ;
92
92
coffp = & args -> sumoff ;
93
- ip = mp -> m_rsumip ;
93
+ ip = args -> rtg -> rtg_inodes [ XFS_RTGI_SUMMARY ] ;
94
94
type = XFS_BLFT_RTSUMMARY_BUF ;
95
95
} else {
96
96
cbpp = & args -> rbmbp ;
97
97
coffp = & args -> rbmoff ;
98
- ip = mp -> m_rbmip ;
98
+ ip = args -> rtg -> rtg_inodes [ XFS_RTGI_BITMAP ] ;
99
99
type = XFS_BLFT_RTBITMAP_BUF ;
100
100
}
101
101
@@ -503,6 +503,7 @@ xfs_rtmodify_summary(
503
503
{
504
504
struct xfs_mount * mp = args -> mp ;
505
505
xfs_rtsumoff_t so = xfs_rtsumoffs (mp , log , bbno );
506
+ uint8_t * rsum_cache = args -> rtg -> rtg_rsum_cache ;
506
507
unsigned int infoword ;
507
508
xfs_suminfo_t val ;
508
509
int error ;
@@ -514,11 +515,11 @@ xfs_rtmodify_summary(
514
515
infoword = xfs_rtsumoffs_to_infoword (mp , so );
515
516
val = xfs_suminfo_add (args , infoword , delta );
516
517
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 ;
522
523
}
523
524
524
525
xfs_trans_log_rtsummary (args , infoword );
@@ -737,7 +738,7 @@ xfs_rtfree_range(
737
738
/*
738
739
* Find the next allocated block (end of allocated extent).
739
740
*/
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 ,
741
742
& postblock );
742
743
if (error )
743
744
return error ;
@@ -961,19 +962,22 @@ xfs_rtcheck_alloc_range(
961
962
int
962
963
xfs_rtfree_extent (
963
964
struct xfs_trans * tp , /* transaction pointer */
965
+ struct xfs_rtgroup * rtg ,
964
966
xfs_rtxnum_t start , /* starting rtext number to free */
965
967
xfs_rtxlen_t len ) /* length of extent freed */
966
968
{
967
969
struct xfs_mount * mp = tp -> t_mountp ;
970
+ struct xfs_inode * rbmip = rtg -> rtg_inodes [XFS_RTGI_BITMAP ];
968
971
struct xfs_rtalloc_args args = {
969
972
.mp = mp ,
970
973
.tp = tp ,
974
+ .rtg = rtg ,
971
975
};
972
976
int error ;
973
977
struct timespec64 atime ;
974
978
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 );
977
981
978
982
error = xfs_rtcheck_alloc_range (& args , start , len );
979
983
if (error )
@@ -996,13 +1000,13 @@ xfs_rtfree_extent(
996
1000
*/
997
1001
if (tp -> t_frextents_delta + mp -> m_sb .sb_frextents ==
998
1002
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 ;
1001
1005
1002
- atime = inode_get_atime (VFS_I (mp -> m_rbmip ));
1006
+ atime = inode_get_atime (VFS_I (rbmip ));
1003
1007
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 );
1006
1010
}
1007
1011
error = 0 ;
1008
1012
out :
@@ -1018,6 +1022,7 @@ xfs_rtfree_extent(
1018
1022
int
1019
1023
xfs_rtfree_blocks (
1020
1024
struct xfs_trans * tp ,
1025
+ struct xfs_rtgroup * rtg ,
1021
1026
xfs_fsblock_t rtbno ,
1022
1027
xfs_filblks_t rtlen )
1023
1028
{
@@ -1038,32 +1043,34 @@ xfs_rtfree_blocks(
1038
1043
return - EIO ;
1039
1044
}
1040
1045
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 ));
1043
1048
}
1044
1049
1045
1050
/* Find all the free records within a given range. */
1046
1051
int
1047
1052
xfs_rtalloc_query_range (
1048
- struct xfs_mount * mp ,
1053
+ struct xfs_rtgroup * rtg ,
1049
1054
struct xfs_trans * tp ,
1050
1055
xfs_rtxnum_t start ,
1051
1056
xfs_rtxnum_t end ,
1052
1057
xfs_rtalloc_query_range_fn fn ,
1053
1058
void * priv )
1054
1059
{
1060
+ struct xfs_mount * mp = rtg_mount (rtg );
1055
1061
struct xfs_rtalloc_args args = {
1062
+ .rtg = rtg ,
1056
1063
.mp = mp ,
1057
1064
.tp = tp ,
1058
1065
};
1059
1066
int error = 0 ;
1060
1067
1061
1068
if (start > end )
1062
1069
return - EINVAL ;
1063
- if (start == end || start >= mp -> m_sb . sb_rextents )
1070
+ if (start == end || start >= rtg -> rtg_extents )
1064
1071
return 0 ;
1065
1072
1066
- end = min (end , mp -> m_sb . sb_rextents - 1 );
1073
+ end = min (end , rtg -> rtg_extents - 1 );
1067
1074
1068
1075
/* Iterate the bitmap, looking for discrepancies. */
1069
1076
while (start <= end ) {
@@ -1086,7 +1093,7 @@ xfs_rtalloc_query_range(
1086
1093
rec .ar_startext = start ;
1087
1094
rec .ar_extcount = rtend - start + 1 ;
1088
1095
1089
- error = fn (mp , tp , & rec , priv );
1096
+ error = fn (rtg , tp , & rec , priv );
1090
1097
if (error )
1091
1098
break ;
1092
1099
}
@@ -1101,26 +1108,27 @@ xfs_rtalloc_query_range(
1101
1108
/* Find all the free records. */
1102
1109
int
1103
1110
xfs_rtalloc_query_all (
1104
- struct xfs_mount * mp ,
1111
+ struct xfs_rtgroup * rtg ,
1105
1112
struct xfs_trans * tp ,
1106
1113
xfs_rtalloc_query_range_fn fn ,
1107
1114
void * priv )
1108
1115
{
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 ,
1110
1117
priv );
1111
1118
}
1112
1119
1113
1120
/* Is the given extent all free? */
1114
1121
int
1115
1122
xfs_rtalloc_extent_is_free (
1116
- struct xfs_mount * mp ,
1123
+ struct xfs_rtgroup * rtg ,
1117
1124
struct xfs_trans * tp ,
1118
1125
xfs_rtxnum_t start ,
1119
1126
xfs_rtxlen_t len ,
1120
1127
bool * is_free )
1121
1128
{
1122
1129
struct xfs_rtalloc_args args = {
1123
- .mp = mp ,
1130
+ .mp = rtg_mount (rtg ),
1131
+ .rtg = rtg ,
1124
1132
.tp = tp ,
1125
1133
};
1126
1134
xfs_rtxnum_t end ;
@@ -1161,65 +1169,6 @@ xfs_rtsummary_blockcount(
1161
1169
return XFS_B_TO_FSB (mp , rsumwords << XFS_WORDLOG );
1162
1170
}
1163
1171
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
-
1223
1172
static int
1224
1173
xfs_rtfile_alloc_blocks (
1225
1174
struct xfs_inode * ip ,
@@ -1260,21 +1209,25 @@ xfs_rtfile_alloc_blocks(
1260
1209
/* Get a buffer for the block. */
1261
1210
static int
1262
1211
xfs_rtfile_initialize_block (
1263
- struct xfs_inode * ip ,
1212
+ struct xfs_rtgroup * rtg ,
1213
+ enum xfs_rtg_inodes type ,
1264
1214
xfs_fsblock_t fsbno ,
1265
1215
void * data )
1266
1216
{
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 ];
1268
1219
struct xfs_trans * tp ;
1269
1220
struct xfs_buf * bp ;
1270
1221
const size_t copylen = mp -> m_blockwsize << XFS_WORDLOG ;
1271
1222
enum xfs_blft buf_type ;
1272
1223
int error ;
1273
1224
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 )
1275
1228
buf_type = XFS_BLFT_RTSUMMARY_BUF ;
1276
1229
else
1277
- buf_type = XFS_BLFT_RTBITMAP_BUF ;
1230
+ return - EINVAL ;
1278
1231
1279
1232
error = xfs_trans_alloc (mp , & M_RES (mp )-> tr_growrtzero , 0 , 0 , 0 , & tp );
1280
1233
if (error )
@@ -1306,21 +1259,22 @@ xfs_rtfile_initialize_block(
1306
1259
*/
1307
1260
int
1308
1261
xfs_rtfile_initialize_blocks (
1309
- struct xfs_inode * ip , /* inode (bitmap/summary) */
1262
+ struct xfs_rtgroup * rtg ,
1263
+ enum xfs_rtg_inodes type ,
1310
1264
xfs_fileoff_t offset_fsb , /* offset to start from */
1311
1265
xfs_fileoff_t end_fsb , /* offset to allocate to */
1312
1266
void * data ) /* data to fill the blocks */
1313
1267
{
1314
- struct xfs_mount * mp = ip -> i_mount ;
1268
+ struct xfs_mount * mp = rtg_mount ( rtg ) ;
1315
1269
const size_t copylen = mp -> m_blockwsize << XFS_WORDLOG ;
1316
1270
1317
1271
while (offset_fsb < end_fsb ) {
1318
1272
struct xfs_bmbt_irec map ;
1319
1273
xfs_filblks_t i ;
1320
1274
int error ;
1321
1275
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 );
1324
1278
if (error )
1325
1279
return error ;
1326
1280
@@ -1330,7 +1284,7 @@ xfs_rtfile_initialize_blocks(
1330
1284
* Do this one block per transaction, to keep it simple.
1331
1285
*/
1332
1286
for (i = 0 ; i < map .br_blockcount ; i ++ ) {
1333
- error = xfs_rtfile_initialize_block (ip ,
1287
+ error = xfs_rtfile_initialize_block (rtg , type ,
1334
1288
map .br_startblock + i , data );
1335
1289
if (error )
1336
1290
return error ;
0 commit comments