Skip to content

Commit 410e8a1

Browse files
Darrick J. WongChandan Babu R
authored andcommitted
xfs: don't bother reporting blocks trimmed via FITRIM
Don't bother reporting the number of bytes that we "trimmed" because the underlying storage isn't required to do anything(!) and failed discard IOs aren't reported to the caller anyway. It's not like userspace can use the reported value for anything useful like adjusting the offset parameter of the next call, and it's not like anyone ever wrote a manpage about FITRIM's out parameters. Signed-off-by: Darrick J. Wong <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Tested-by: Christoph Hellwig <[email protected]> Signed-off-by: Chandan Babu R <[email protected]>
1 parent 9517993 commit 410e8a1

File tree

1 file changed

+11
-25
lines changed

1 file changed

+11
-25
lines changed

fs/xfs/xfs_discard.c

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,7 @@ static int
158158
xfs_trim_gather_extents(
159159
struct xfs_perag *pag,
160160
struct xfs_trim_cur *tcur,
161-
struct xfs_busy_extents *extents,
162-
uint64_t *blocks_trimmed)
161+
struct xfs_busy_extents *extents)
163162
{
164163
struct xfs_mount *mp = pag->pag_mount;
165164
struct xfs_trans *tp;
@@ -280,7 +279,6 @@ xfs_trim_gather_extents(
280279

281280
xfs_extent_busy_insert_discard(pag, fbno, flen,
282281
&extents->extent_list);
283-
*blocks_trimmed += flen;
284282
next_extent:
285283
if (tcur->by_bno)
286284
error = xfs_btree_increment(cur, 0, &i);
@@ -327,8 +325,7 @@ xfs_trim_perag_extents(
327325
struct xfs_perag *pag,
328326
xfs_agblock_t start,
329327
xfs_agblock_t end,
330-
xfs_extlen_t minlen,
331-
uint64_t *blocks_trimmed)
328+
xfs_extlen_t minlen)
332329
{
333330
struct xfs_trim_cur tcur = {
334331
.start = start,
@@ -354,8 +351,7 @@ xfs_trim_perag_extents(
354351
extents->owner = extents;
355352
INIT_LIST_HEAD(&extents->extent_list);
356353

357-
error = xfs_trim_gather_extents(pag, &tcur, extents,
358-
blocks_trimmed);
354+
error = xfs_trim_gather_extents(pag, &tcur, extents);
359355
if (error) {
360356
kfree(extents);
361357
break;
@@ -389,8 +385,7 @@ xfs_trim_datadev_extents(
389385
struct xfs_mount *mp,
390386
xfs_daddr_t start,
391387
xfs_daddr_t end,
392-
xfs_extlen_t minlen,
393-
uint64_t *blocks_trimmed)
388+
xfs_extlen_t minlen)
394389
{
395390
xfs_agnumber_t start_agno, end_agno;
396391
xfs_agblock_t start_agbno, end_agbno;
@@ -411,8 +406,7 @@ xfs_trim_datadev_extents(
411406

412407
if (start_agno == end_agno)
413408
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);
416410
if (error)
417411
last_error = error;
418412

@@ -431,9 +425,6 @@ struct xfs_trim_rtdev {
431425
/* list of rt extents to free */
432426
struct list_head extent_list;
433427

434-
/* pointer to count of blocks trimmed */
435-
uint64_t *blocks_trimmed;
436-
437428
/* minimum length that caller allows us to trim */
438429
xfs_rtblock_t minlen_fsb;
439430

@@ -551,7 +542,6 @@ xfs_trim_gather_rtextent(
551542
busyp->length = rlen;
552543
INIT_LIST_HEAD(&busyp->list);
553544
list_add_tail(&busyp->list, &tr->extent_list);
554-
*tr->blocks_trimmed += rlen;
555545

556546
tr->restart_rtx = rec->ar_startext + rec->ar_extcount;
557547
return 0;
@@ -562,13 +552,11 @@ xfs_trim_rtdev_extents(
562552
struct xfs_mount *mp,
563553
xfs_daddr_t start,
564554
xfs_daddr_t end,
565-
xfs_daddr_t minlen,
566-
uint64_t *blocks_trimmed)
555+
xfs_daddr_t minlen)
567556
{
568557
struct xfs_rtalloc_rec low = { };
569558
struct xfs_rtalloc_rec high = { };
570559
struct xfs_trim_rtdev tr = {
571-
.blocks_trimmed = blocks_trimmed,
572560
.minlen_fsb = XFS_BB_TO_FSB(mp, minlen),
573561
};
574562
struct xfs_trans *tp;
@@ -634,7 +622,7 @@ xfs_trim_rtdev_extents(
634622
return error;
635623
}
636624
#else
637-
# define xfs_trim_rtdev_extents(m,s,e,n,b) (-EOPNOTSUPP)
625+
# define xfs_trim_rtdev_extents(...) (-EOPNOTSUPP)
638626
#endif /* CONFIG_XFS_RT */
639627

640628
/*
@@ -661,7 +649,6 @@ xfs_ioc_trim(
661649
xfs_daddr_t start, end;
662650
xfs_extlen_t minlen;
663651
xfs_rfsblock_t max_blocks;
664-
uint64_t blocks_trimmed = 0;
665652
int error, last_error = 0;
666653

667654
if (!capable(CAP_SYS_ADMIN))
@@ -706,23 +693,22 @@ xfs_ioc_trim(
706693
end = start + BTOBBT(range.len) - 1;
707694

708695
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);
711697
if (error)
712698
last_error = error;
713699
}
714700

715701
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);
718703
if (error)
719704
last_error = error;
720705
}
721706

722707
if (last_error)
723708
return last_error;
724709

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));
726712
if (copy_to_user(urange, &range, sizeof(range)))
727713
return -EFAULT;
728714
return 0;

0 commit comments

Comments
 (0)