@@ -158,8 +158,7 @@ static int
158
158
xfs_trim_gather_extents (
159
159
struct xfs_perag * pag ,
160
160
struct xfs_trim_cur * tcur ,
161
- struct xfs_busy_extents * extents ,
162
- uint64_t * blocks_trimmed )
161
+ struct xfs_busy_extents * extents )
163
162
{
164
163
struct xfs_mount * mp = pag -> pag_mount ;
165
164
struct xfs_trans * tp ;
@@ -280,7 +279,6 @@ xfs_trim_gather_extents(
280
279
281
280
xfs_extent_busy_insert_discard (pag , fbno , flen ,
282
281
& extents -> extent_list );
283
- * blocks_trimmed += flen ;
284
282
next_extent :
285
283
if (tcur -> by_bno )
286
284
error = xfs_btree_increment (cur , 0 , & i );
@@ -327,8 +325,7 @@ xfs_trim_perag_extents(
327
325
struct xfs_perag * pag ,
328
326
xfs_agblock_t start ,
329
327
xfs_agblock_t end ,
330
- xfs_extlen_t minlen ,
331
- uint64_t * blocks_trimmed )
328
+ xfs_extlen_t minlen )
332
329
{
333
330
struct xfs_trim_cur tcur = {
334
331
.start = start ,
@@ -354,8 +351,7 @@ xfs_trim_perag_extents(
354
351
extents -> owner = extents ;
355
352
INIT_LIST_HEAD (& extents -> extent_list );
356
353
357
- error = xfs_trim_gather_extents (pag , & tcur , extents ,
358
- blocks_trimmed );
354
+ error = xfs_trim_gather_extents (pag , & tcur , extents );
359
355
if (error ) {
360
356
kfree (extents );
361
357
break ;
@@ -389,8 +385,7 @@ xfs_trim_datadev_extents(
389
385
struct xfs_mount * mp ,
390
386
xfs_daddr_t start ,
391
387
xfs_daddr_t end ,
392
- xfs_extlen_t minlen ,
393
- uint64_t * blocks_trimmed )
388
+ xfs_extlen_t minlen )
394
389
{
395
390
xfs_agnumber_t start_agno , end_agno ;
396
391
xfs_agblock_t start_agbno , end_agbno ;
@@ -411,8 +406,7 @@ xfs_trim_datadev_extents(
411
406
412
407
if (start_agno == end_agno )
413
408
agend = end_agbno ;
414
- error = xfs_trim_perag_extents (pag , start_agbno , agend , minlen ,
415
- blocks_trimmed );
409
+ error = xfs_trim_perag_extents (pag , start_agbno , agend , minlen );
416
410
if (error )
417
411
last_error = error ;
418
412
@@ -431,9 +425,6 @@ struct xfs_trim_rtdev {
431
425
/* list of rt extents to free */
432
426
struct list_head extent_list ;
433
427
434
- /* pointer to count of blocks trimmed */
435
- uint64_t * blocks_trimmed ;
436
-
437
428
/* minimum length that caller allows us to trim */
438
429
xfs_rtblock_t minlen_fsb ;
439
430
@@ -551,7 +542,6 @@ xfs_trim_gather_rtextent(
551
542
busyp -> length = rlen ;
552
543
INIT_LIST_HEAD (& busyp -> list );
553
544
list_add_tail (& busyp -> list , & tr -> extent_list );
554
- * tr -> blocks_trimmed += rlen ;
555
545
556
546
tr -> restart_rtx = rec -> ar_startext + rec -> ar_extcount ;
557
547
return 0 ;
@@ -562,13 +552,11 @@ xfs_trim_rtdev_extents(
562
552
struct xfs_mount * mp ,
563
553
xfs_daddr_t start ,
564
554
xfs_daddr_t end ,
565
- xfs_daddr_t minlen ,
566
- uint64_t * blocks_trimmed )
555
+ xfs_daddr_t minlen )
567
556
{
568
557
struct xfs_rtalloc_rec low = { };
569
558
struct xfs_rtalloc_rec high = { };
570
559
struct xfs_trim_rtdev tr = {
571
- .blocks_trimmed = blocks_trimmed ,
572
560
.minlen_fsb = XFS_BB_TO_FSB (mp , minlen ),
573
561
};
574
562
struct xfs_trans * tp ;
@@ -634,7 +622,7 @@ xfs_trim_rtdev_extents(
634
622
return error ;
635
623
}
636
624
#else
637
- # define xfs_trim_rtdev_extents (m , s , e , n , b ) (-EOPNOTSUPP)
625
+ # define xfs_trim_rtdev_extents (... ) (-EOPNOTSUPP)
638
626
#endif /* CONFIG_XFS_RT */
639
627
640
628
/*
@@ -661,7 +649,6 @@ xfs_ioc_trim(
661
649
xfs_daddr_t start , end ;
662
650
xfs_extlen_t minlen ;
663
651
xfs_rfsblock_t max_blocks ;
664
- uint64_t blocks_trimmed = 0 ;
665
652
int error , last_error = 0 ;
666
653
667
654
if (!capable (CAP_SYS_ADMIN ))
@@ -706,23 +693,22 @@ xfs_ioc_trim(
706
693
end = start + BTOBBT (range .len ) - 1 ;
707
694
708
695
if (bdev_max_discard_sectors (mp -> m_ddev_targp -> bt_bdev )) {
709
- error = xfs_trim_datadev_extents (mp , start , end , minlen ,
710
- & blocks_trimmed );
696
+ error = xfs_trim_datadev_extents (mp , start , end , minlen );
711
697
if (error )
712
698
last_error = error ;
713
699
}
714
700
715
701
if (rt_bdev && !xfs_trim_should_stop ()) {
716
- error = xfs_trim_rtdev_extents (mp , start , end , minlen ,
717
- & blocks_trimmed );
702
+ error = xfs_trim_rtdev_extents (mp , start , end , minlen );
718
703
if (error )
719
704
last_error = error ;
720
705
}
721
706
722
707
if (last_error )
723
708
return last_error ;
724
709
725
- range .len = XFS_FSB_TO_B (mp , blocks_trimmed );
710
+ range .len = min_t (unsigned long long, range .len ,
711
+ XFS_FSB_TO_B (mp , max_blocks ));
726
712
if (copy_to_user (urange , & range , sizeof (range )))
727
713
return - EFAULT ;
728
714
return 0 ;
0 commit comments