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 <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Tested-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Chandan Babu R <chandanbabu@kernel.org>

authored by Darrick J. Wong and committed by Chandan Babu R 410e8a18 95179935

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