@@ -101,6 +101,24 @@ xfs_discard_endio(
101
101
bio_put (bio );
102
102
}
103
103
104
+ static inline struct block_device *
105
+ xfs_group_bdev (
106
+ const struct xfs_group * xg )
107
+ {
108
+ struct xfs_mount * mp = xg -> xg_mount ;
109
+
110
+ switch (xg -> xg_type ) {
111
+ case XG_TYPE_AG :
112
+ return mp -> m_ddev_targp -> bt_bdev ;
113
+ case XG_TYPE_RTG :
114
+ return mp -> m_rtdev_targp -> bt_bdev ;
115
+ default :
116
+ ASSERT (0 );
117
+ break ;
118
+ }
119
+ return NULL ;
120
+ }
121
+
104
122
/*
105
123
* Walk the discard list and issue discards on all the busy extents in the
106
124
* list. We plug and chain the bios so that we only need a single completion
@@ -118,12 +136,11 @@ xfs_discard_extents(
118
136
119
137
blk_start_plug (& plug );
120
138
list_for_each_entry (busyp , & extents -> extent_list , list ) {
121
- struct xfs_perag * pag = to_perag (busyp -> group );
122
-
123
- trace_xfs_discard_extent (pag , busyp -> bno , busyp -> length );
139
+ trace_xfs_discard_extent (busyp -> group , busyp -> bno ,
140
+ busyp -> length );
124
141
125
- error = __blkdev_issue_discard (mp -> m_ddev_targp -> bt_bdev ,
126
- xfs_agbno_to_daddr ( pag , busyp -> bno ),
142
+ error = __blkdev_issue_discard (xfs_group_bdev ( busyp -> group ) ,
143
+ xfs_gbno_to_daddr ( busyp -> group , busyp -> bno ),
127
144
XFS_FSB_TO_BB (mp , busyp -> length ),
128
145
GFP_KERNEL , & bio );
129
146
if (error && error != - EOPNOTSUPP ) {
@@ -241,11 +258,11 @@ xfs_trim_gather_extents(
241
258
* overlapping ranges for now.
242
259
*/
243
260
if (fbno + flen < tcur -> start ) {
244
- trace_xfs_discard_exclude (pag , fbno , flen );
261
+ trace_xfs_discard_exclude (pag_group ( pag ) , fbno , flen );
245
262
goto next_extent ;
246
263
}
247
264
if (fbno > tcur -> end ) {
248
- trace_xfs_discard_exclude (pag , fbno , flen );
265
+ trace_xfs_discard_exclude (pag_group ( pag ) , fbno , flen );
249
266
if (tcur -> by_bno ) {
250
267
tcur -> count = 0 ;
251
268
break ;
@@ -263,7 +280,7 @@ xfs_trim_gather_extents(
263
280
264
281
/* Too small? Give up. */
265
282
if (flen < tcur -> minlen ) {
266
- trace_xfs_discard_toosmall (pag , fbno , flen );
283
+ trace_xfs_discard_toosmall (pag_group ( pag ) , fbno , flen );
267
284
if (tcur -> by_bno )
268
285
goto next_extent ;
269
286
tcur -> count = 0 ;
@@ -275,7 +292,7 @@ xfs_trim_gather_extents(
275
292
* discard and try again the next time.
276
293
*/
277
294
if (xfs_extent_busy_search (pag_group (pag ), fbno , flen )) {
278
- trace_xfs_discard_busy (pag , fbno , flen );
295
+ trace_xfs_discard_busy (pag_group ( pag ) , fbno , flen );
279
296
goto next_extent ;
280
297
}
281
298
0 commit comments