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