Bug 221952

Summary: cam iosched: Fix trim statistics
Product: Base System Reporter: Fabian Keil <fk>
Component: kernAssignee: freebsd-scsi (Nobody) <scsi>
Status: Open ---    
Severity: Affects Some People CC: emaste, imp
Priority: --- Keywords: patch
Version: CURRENTFlags: fk: mfc-stable11?
Hardware: Any   
OS: Any   
Attachments:
Description Flags
cam iosched: Fix trim statistics none

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.