Add NVME as a known device type for devstat processing.

Also, reduce the amount of cut and pasted code a little since only two
args are different in the devstat_end_transaction calls.

Sponsored by: Netflix
This commit is contained in:
Warner Losh 2017-12-06 00:29:43 +00:00
parent 965f7130a9
commit d2f3208dda

View File

@ -1171,8 +1171,10 @@ cam_periph_runccb(union ccb *ccb,
* If the user has supplied a stats structure, and if we understand
* this particular type of ccb, record the transaction start.
*/
if ((ds != NULL) && (ccb->ccb_h.func_code == XPT_SCSI_IO ||
ccb->ccb_h.func_code == XPT_ATA_IO)) {
if (ds != NULL &&
(ccb->ccb_h.func_code == XPT_SCSI_IO ||
ccb->ccb_h.func_code == XPT_ATA_IO ||
ccb->ccb_h.func_code == XPT_NVME_IO)) {
starttime = &ltime;
binuptime(starttime);
devstat_start_transaction(ds, starttime);
@ -1203,25 +1205,27 @@ cam_periph_runccb(union ccb *ccb,
}
if (ds != NULL) {
uint32_t bytes;
devstat_tag_type tag;
bool valid = true;
if (ccb->ccb_h.func_code == XPT_SCSI_IO) {
devstat_end_transaction(ds,
ccb->csio.dxfer_len - ccb->csio.resid,
ccb->csio.tag_action & 0x3,
((ccb->ccb_h.flags & CAM_DIR_MASK) ==
CAM_DIR_NONE) ? DEVSTAT_NO_DATA :
(ccb->ccb_h.flags & CAM_DIR_OUT) ?
DEVSTAT_WRITE :
DEVSTAT_READ, NULL, starttime);
bytes = ccb->csio.dxfer_len - ccb->csio.resid;
tag = (devstat_tag_type)(ccb->csio.tag_action & 0x3);
} else if (ccb->ccb_h.func_code == XPT_ATA_IO) {
devstat_end_transaction(ds,
ccb->ataio.dxfer_len - ccb->ataio.resid,
0, /* Not used in ATA */
((ccb->ccb_h.flags & CAM_DIR_MASK) ==
CAM_DIR_NONE) ? DEVSTAT_NO_DATA :
(ccb->ccb_h.flags & CAM_DIR_OUT) ?
DEVSTAT_WRITE :
DEVSTAT_READ, NULL, starttime);
bytes = ccb->ataio.dxfer_len - ccb->ataio.resid;
tag = (devstat_tag_type)0;
} else if (ccb->ccb_h.func_code == XPT_NVME_IO) {
bytes = ccb->nvmeio.dxfer_len; /* NB: resid no possible */
tag = (devstat_tag_type)0;
} else {
valid = false;
}
if (valid)
devstat_end_transaction(ds, bytes, tag,
((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_NONE) ?
DEVSTAT_NO_DATA : (ccb->ccb_h.flags & CAM_DIR_OUT) ?
DEVSTAT_WRITE : DEVSTAT_READ, NULL, starttime);
}
return(error);