Bug 221952 - cam iosched: Fix trim statistics
Summary: cam iosched: Fix trim statistics
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-scsi (Nobody)
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2017-08-31 10:11 UTC by Fabian Keil
Modified: 2018-12-04 14:13 UTC (History)
2 users (show)

See Also:
fk: mfc-stable11?


Attachments
cam iosched: Fix trim statistics (1.42 KB, patch)
2017-08-31 10:11 UTC, Fabian Keil
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Fabian Keil 2017-08-31 10:11:10 UTC
Created attachment 185944 [details]
cam iosched: Fix trim statistics

The attached patch fixes the cam iosched trim statistics.

When cam_iosched_bio_complete() gets called, all pending
BIO_DELETEs are done.

Previously only one of them was accounted for, as a result
the "pending" counter got higher and higher and the "out"
count was off as well. An ElectroBSD release build in a vm
resulted in ~60k "leaked" pending trims.

cam_iosched_ticker() has a note that seems to refer to this
bug but I didn't adjust it.

Obtained from: ElectroBSD
Comment 1 Warner Losh freebsd_committer freebsd_triage 2017-09-01 00:55:35 UTC
This isn't true for nvme drives.

We should decrease the numbers by the number of bios completed.
Comment 2 Fabian Keil 2017-09-01 09:33:32 UTC
Interesting.

Do you mean that the trim statistics currently work for nvme drives and
the patch would break them, or that they are broken as well but the patch
wouldn't fix them?

I don't have access to nvme drives and only tested the patch with ada drives.
While I also use iosched with da drives, they don't have trim support.
Comment 3 Warner Losh freebsd_committer freebsd_triage 2017-09-01 15:24:54 UTC
Setting the pending counter to zero is not valid because there could be more than one trim active.