From 18ed122eede36bb9f67ea05ce9fdf22674da2365 Mon Sep 17 00:00:00 2001 From: mjacob Date: Tue, 5 Dec 2006 07:45:28 +0000 Subject: Add an xpt_print function to reduce most of the xpt_print_path/printf pairs. Convert the core code to use it. Reviewed by: scsi (various folks weighing in with good advice) MFC after: 2 weeks --- sys/cam/cam_periph.c | 66 +++++++++++++------------------ sys/cam/cam_xpt.c | 88 ++++++++++++++++++++--------------------- sys/cam/cam_xpt.h | 1 + sys/cam/scsi/scsi_cd.c | 54 +++++++++++-------------- sys/cam/scsi/scsi_ch.c | 33 +++++++--------- sys/cam/scsi/scsi_da.c | 65 ++++++++++++++---------------- sys/cam/scsi/scsi_pass.c | 18 ++++----- sys/cam/scsi/scsi_pt.c | 10 ++--- sys/cam/scsi/scsi_sa.c | 96 +++++++++++++++++++++------------------------ sys/cam/scsi/scsi_ses.c | 6 +-- sys/cam/scsi/scsi_targ_bh.c | 18 ++++----- sys/cam/scsi/scsi_target.c | 20 +++++----- 12 files changed, 216 insertions(+), 259 deletions(-) (limited to 'sys/cam') diff --git a/sys/cam/cam_periph.c b/sys/cam/cam_periph.c index fcc80b8..925e2a7 100644 --- a/sys/cam/cam_periph.c +++ b/sys/cam/cam_periph.c @@ -334,12 +334,12 @@ camperiphnextunit(struct periph_driver *p_drv, u_int newunit, int wired, if (periph != NULL && periph->unit_number == newunit) { if (wired != 0) { - xpt_print_path(periph->path); - printf("Duplicate Wired Device entry!\n"); - xpt_print_path(periph->path); - printf("Second device (%s device at scbus%d " - "target %d lun %d) will not be wired\n", - periph_name, pathid, target, lun); + xpt_print(periph->path, "Duplicate Wired " + "Device entry!\n"); + xpt_print(periph->path, "Second device (%s " + "device at scbus%d target %d lun %d) will " + "not be wired\n", periph_name, pathid, + target, lun); wired = 0; } continue; @@ -995,8 +995,8 @@ camperiphdone(struct cam_periph *periph, union ccb *done_ccb) saved_ccb->ccb_h.status |= CAM_AUTOSNS_VALID; #if 0 - xpt_print_path(saved_ccb->ccb_h.path); - printf("Recovered Sense\n"); + xpt_print(saved_ccb->ccb_h.path, + "Recovered Sense\n"); scsi_sense_print(&saved_ccb->csio); cam_error_print(saved_ccb, CAM_ESF_ALL, CAM_EPF_ALL); @@ -1287,8 +1287,7 @@ camperiphscsistatuserror(union ccb *ccb, cam_flags camflags, *timeout = 0; error = ERESTART; if (bootverbose) { - xpt_print_path(ccb->ccb_h.path); - printf("Queue Full\n"); + xpt_print(ccb->ccb_h.path, "Queue Full\n"); } break; } @@ -1300,8 +1299,7 @@ camperiphscsistatuserror(union ccb *ccb, cam_flags camflags, * command completes or a 1 second timeout. */ if (bootverbose) { - xpt_print_path(ccb->ccb_h.path); - printf("Device Busy\n"); + xpt_print(ccb->ccb_h.path, "Device Busy\n"); } if (ccb->ccb_h.retry_count > 0) { ccb->ccb_h.retry_count--; @@ -1314,13 +1312,12 @@ camperiphscsistatuserror(union ccb *ccb, cam_flags camflags, } break; case SCSI_STATUS_RESERV_CONFLICT: - xpt_print_path(ccb->ccb_h.path); - printf("Reservation Conflict\n"); + xpt_print(ccb->ccb_h.path, "Reservation Conflict\n"); error = EIO; break; default: - xpt_print_path(ccb->ccb_h.path); - printf("SCSI Status 0x%x\n", ccb->csio.scsi_status); + xpt_print(ccb->ccb_h.path, "SCSI Status 0x%x\n", + ccb->csio.scsi_status); error = EIO; break; } @@ -1574,42 +1571,38 @@ cam_periph_error(union ccb *ccb, cam_flags camflags, &timeout); break; case CAM_AUTOSENSE_FAIL: - xpt_print_path(ccb->ccb_h.path); - printf("AutoSense Failed\n"); + xpt_print(ccb->ccb_h.path, "AutoSense Failed\n"); error = EIO; /* we have to kill the command */ break; case CAM_REQ_CMP_ERR: if (bootverbose && printed == 0) { - xpt_print_path(ccb->ccb_h.path); - printf("Request completed with CAM_REQ_CMP_ERR\n"); + xpt_print(ccb->ccb_h.path, + "Request completed with CAM_REQ_CMP_ERR\n"); printed++; } /* FALLTHROUGH */ case CAM_CMD_TIMEOUT: if (bootverbose && printed == 0) { - xpt_print_path(ccb->ccb_h.path); - printf("Command timed out\n"); + xpt_print(ccb->ccb_h.path, "Command timed out\n"); printed++; } /* FALLTHROUGH */ case CAM_UNEXP_BUSFREE: if (bootverbose && printed == 0) { - xpt_print_path(ccb->ccb_h.path); - printf("Unexpected Bus Free\n"); + xpt_print(ccb->ccb_h.path, "Unexpected Bus Free\n"); printed++; } /* FALLTHROUGH */ case CAM_UNCOR_PARITY: if (bootverbose && printed == 0) { - xpt_print_path(ccb->ccb_h.path); - printf("Uncorrected Parity Error\n"); + xpt_print(ccb->ccb_h.path, + "Uncorrected Parity Error\n"); printed++; } /* FALLTHROUGH */ case CAM_DATA_RUN_ERR: if (bootverbose && printed == 0) { - xpt_print_path(ccb->ccb_h.path); - printf("Data Overrun\n"); + xpt_print(ccb->ccb_h.path, "Data Overrun\n"); printed++; } error = EIO; /* we have to kill the command */ @@ -1638,8 +1631,8 @@ cam_periph_error(union ccb *ccb, cam_flags camflags, ccb->ccb_h.retry_count--; error = ERESTART; if (bootverbose && printed == 0) { - xpt_print_path(ccb->ccb_h.path); - printf("Selection Timeout\n"); + xpt_print(ccb->ccb_h.path, + "Selection Timeout\n"); printed++; } @@ -1701,8 +1694,7 @@ cam_periph_error(union ccb *ccb, cam_flags camflags, /* Unconditional requeue */ error = ERESTART; if (bootverbose && printed == 0) { - xpt_print_path(ccb->ccb_h.path); - printf("Request Requeued\n"); + xpt_print(ccb->ccb_h.path, "Request Requeued\n"); printed++; } break; @@ -1723,8 +1715,8 @@ cam_periph_error(union ccb *ccb, cam_flags camflags, ccb->ccb_h.retry_count--; error = ERESTART; if (bootverbose && printed == 0) { - xpt_print_path(ccb->ccb_h.path); - printf("CAM Status 0x%x\n", status); + xpt_print(ccb->ccb_h.path, "CAM Status 0x%x\n", + status); printed++; } } else { @@ -1763,11 +1755,9 @@ cam_periph_error(union ccb *ccb, cam_flags camflags, if (action_string == NULL) action_string = "Unretryable Error"; if (error != ERESTART) { - xpt_print_path(ccb->ccb_h.path); - printf("error %d\n", error); + xpt_print(ccb->ccb_h.path, "error %d\n", error); } - xpt_print_path(ccb->ccb_h.path); - printf("%s\n", action_string); + xpt_print(ccb->ccb_h.path, "%s\n", action_string); } return (error); diff --git a/sys/cam/cam_xpt.c b/sys/cam/cam_xpt.c index fe3e252..e8aa1be 100644 --- a/sys/cam/cam_xpt.c +++ b/sys/cam/cam_xpt.c @@ -63,6 +63,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include /* for xpt_print below */ #include "opt_cam.h" /* Datastructures internal to the xpt layer */ @@ -3407,10 +3408,9 @@ xpt_action(union ccb *start_ccb) crs->openings); if (bootverbose) { - xpt_print_path(crs->ccb_h.path); - printf("tagged openings " - "now %d\n", - crs->openings); + xpt_print(crs->ccb_h.path, + "tagged openings now %d\n", + crs->openings); } } } @@ -3513,8 +3513,8 @@ xpt_action(union ccb *start_ccb) cam_dflags = CAM_DEBUG_NONE; } else { start_ccb->ccb_h.status = CAM_REQ_CMP; - xpt_print_path(cam_dpath); - printf("debugging flags now %x\n", cam_dflags); + xpt_print(cam_dpath, "debugging flags now %x\n", + cam_dflags); } } else { cam_dpath = NULL; @@ -4160,6 +4160,16 @@ xpt_print_path(struct cam_path *path) } } +void +xpt_print(struct cam_path *path, const char *fmt, ...) +{ + va_list ap; + xpt_print_path(path); + va_start(ap, fmt); + vprintf(fmt, ap); + va_end(ap); +} + int xpt_path_string(struct cam_path *path, char *str, size_t str_len) { @@ -5529,16 +5539,14 @@ xpt_scan_lun(struct cam_periph *periph, struct cam_path *path, if (request_ccb == NULL) { request_ccb = malloc(sizeof(union ccb), M_TEMP, M_NOWAIT); if (request_ccb == NULL) { - xpt_print_path(path); - printf("xpt_scan_lun: can't allocate CCB, can't " - "continue\n"); + xpt_print(path, "xpt_scan_lun: can't allocate CCB, " + "can't continue\n"); return; } new_path = malloc(sizeof(*new_path), M_TEMP, M_NOWAIT); if (new_path == NULL) { - xpt_print_path(path); - printf("xpt_scan_lun: can't allocate path, can't " - "continue\n"); + xpt_print(path, "xpt_scan_lun: can't allocate path, " + "can't continue\n"); free(request_ccb, M_TEMP); return; } @@ -5548,9 +5556,8 @@ xpt_scan_lun(struct cam_periph *periph, struct cam_path *path, path->device->lun_id); if (status != CAM_REQ_CMP) { - xpt_print_path(path); - printf("xpt_scan_lun: can't compile path, can't " - "continue\n"); + xpt_print(path, "xpt_scan_lun: can't compile path, " + "can't continue\n"); free(request_ccb, M_TEMP); free(new_path, M_TEMP); return; @@ -5576,9 +5583,8 @@ xpt_scan_lun(struct cam_periph *periph, struct cam_path *path, request_ccb); if (status != CAM_REQ_CMP) { - xpt_print_path(path); - printf("xpt_scan_lun: cam_alloc_periph returned an " - "error, can't continue probe\n"); + xpt_print(path, "xpt_scan_lun: cam_alloc_periph " + "returned an error, can't continue probe\n"); request_ccb->ccb_h.status = status; xpt_done(request_ccb); } @@ -5763,8 +5769,8 @@ probestart(struct cam_periph *periph, union ccb *start_ccb) inq_buf = malloc(inquiry_len, M_TEMP, M_NOWAIT); } if (inq_buf == NULL) { - xpt_print_path(periph->path); - printf("malloc failure- skipping Basic Domain Validation\n"); + xpt_print(periph->path, "malloc failure- skipping Basic" + "Domain Validation\n"); softc->action = PROBE_DV_EXIT; scsi_test_unit_ready(csio, /*retries*/4, @@ -5809,8 +5815,8 @@ probestart(struct cam_periph *periph, union ccb *start_ccb) /*timeout*/60000); break; } - xpt_print_path(periph->path); - printf("Unable to mode sense control page - malloc failure\n"); + xpt_print(periph->path, "Unable to mode sense control page - " + "malloc failure\n"); softc->action = PROBE_SERIAL_NUM; } /* FALLTHROUGH */ @@ -5887,15 +5893,14 @@ proberequestbackoff(struct cam_periph *periph, struct cam_ed *device) xpt_action((union ccb *)&cts); if ((cts.ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) { if (bootverbose) { - xpt_print_path(periph->path); - printf("failed to get current settings\n"); + xpt_print(periph->path, + "failed to get current device settings\n"); } return (0); } if (cts.transport != XPORT_SPI) { if (bootverbose) { - xpt_print_path(periph->path); - printf("not SPI transport\n"); + xpt_print(periph->path, "not SPI transport\n"); } return (0); } @@ -5906,8 +5911,7 @@ proberequestbackoff(struct cam_periph *periph, struct cam_ed *device) */ if ((spi->valid & CTS_SPI_VALID_SYNC_RATE) == 0) { if (bootverbose) { - xpt_print_path(periph->path); - printf("no sync rate known\n"); + xpt_print(periph->path, "no sync rate known\n"); } return (0); } @@ -5925,8 +5929,7 @@ proberequestbackoff(struct cam_periph *periph, struct cam_ed *device) if ((spi->valid & CTS_SPI_VALID_SYNC_OFFSET) == 0 || spi->sync_offset == 0 || spi->sync_period == 0) { if (bootverbose) { - xpt_print_path(periph->path); - printf("no sync rate available\n"); + xpt_print(periph->path, "no sync rate available\n"); } return (0); } @@ -6285,8 +6288,8 @@ probedone(struct cam_periph *periph, union ccb *done_ccb) csio = &done_ccb->csio; nbuf = (struct scsi_inquiry_data *)csio->data_ptr; if (bcmp(nbuf, &path->device->inq_data, SHORT_INQUIRY_LENGTH)) { - xpt_print_path(path); - printf("inquiry fails comparison at DV%d step\n", + xpt_print(path, + "inquiry data fails comparison at DV%d step\n", softc->action == PROBE_INQUIRY_BASIC_DV1? 1 : 2); if (proberequestbackoff(periph, path->device)) { path->device->flags &= ~CAM_DEV_IN_DV; @@ -6484,17 +6487,16 @@ xpt_set_transfer_settings(struct ccb_trans_settings *cts, struct cam_ed *device, cts->protocol_version = device->protocol_version; if (cts->protocol != device->protocol) { - xpt_print_path(cts->ccb_h.path); - printf("Uninitialized Protocol %x:%x?\n", + xpt_print(cts->ccb_h.path, "Uninitialized Protocol %x:%x?\n", cts->protocol, device->protocol); cts->protocol = device->protocol; } if (cts->protocol_version > device->protocol_version) { if (bootverbose) { - xpt_print_path(cts->ccb_h.path); - printf("Down reving Protocol Version from %d to %d?\n", - cts->protocol_version, device->protocol_version); + xpt_print(cts->ccb_h.path, "Down reving Protocol " + "Version from %d to %d?\n", cts->protocol_version, + device->protocol_version); } cts->protocol_version = device->protocol_version; } @@ -6510,18 +6512,16 @@ xpt_set_transfer_settings(struct ccb_trans_settings *cts, struct cam_ed *device, cts->transport_version = device->transport_version; if (cts->transport != device->transport) { - xpt_print_path(cts->ccb_h.path); - printf("Uninitialized Transport %x:%x?\n", - cts->transport, device->transport); + xpt_print(cts->ccb_h.path, "Uninitialized Transport %x:%x?\n", + cts->transport, device->transport); cts->transport = device->transport; } if (cts->transport_version > device->transport_version) { if (bootverbose) { - xpt_print_path(cts->ccb_h.path); - printf("Down reving Transport Version from %d to %d?\n", - cts->transport_version, - device->transport_version); + xpt_print(cts->ccb_h.path, "Down reving Transport " + "Version from %d to %d?\n", cts->transport_version, + device->transport_version); } cts->transport_version = device->transport_version; } diff --git a/sys/cam/cam_xpt.h b/sys/cam/cam_xpt.h index 1b982c7..a84feae 100644 --- a/sys/cam/cam_xpt.h +++ b/sys/cam/cam_xpt.h @@ -62,6 +62,7 @@ void xpt_free_path(struct cam_path *path); int xpt_path_comp(struct cam_path *path1, struct cam_path *path2); void xpt_print_path(struct cam_path *path); +void xpt_print(struct cam_path *path, const char *fmt, ...); int xpt_path_string(struct cam_path *path, char *str, size_t str_len); path_id_t xpt_path_path_id(struct cam_path *path); diff --git a/sys/cam/scsi/scsi_cd.c b/sys/cam/scsi/scsi_cd.c index a64d93e..07782ba 100644 --- a/sys/cam/scsi/scsi_cd.c +++ b/sys/cam/scsi/scsi_cd.c @@ -408,8 +408,7 @@ cdoninvalidate(struct cam_periph *periph) camq_remove(&softc->changer->devq, softc->pinfo.index); disk_gone(softc->disk); - xpt_print_path(periph->path); - printf("lost device\n"); + xpt_print(periph->path, "lost device\n"); } static void @@ -420,13 +419,11 @@ cdcleanup(struct cam_periph *periph) softc = (struct cd_softc *)periph->softc; - xpt_print_path(periph->path); - printf("removing device entry\n"); + xpt_print(periph->path, "removing device entry\n"); if ((softc->flags & CD_FLAG_SCTX_INIT) != 0 && sysctl_ctx_free(&softc->sysctl_ctx) != 0) { - xpt_print_path(periph->path); - printf("can't remove sysctl context\n"); + xpt_print(periph->path, "can't remove sysctl context\n"); } s = splsoftcam(); @@ -494,8 +491,7 @@ cdcleanup(struct cam_periph *periph) STAILQ_REMOVE(&changerq, softc->changer, cdchanger, changer_links); - xpt_print_path(periph->path); - printf("removing changer entry\n"); + xpt_print(periph->path, "removing changer entry\n"); free(softc->changer, M_DEVBUF); num_changers--; } @@ -1568,8 +1564,8 @@ cdstart(struct cam_periph *periph, union ccb *start_ccb) M_TEMP, M_NOWAIT); if (rcap == NULL) { - xpt_print_path(periph->path); - printf("cdstart: Couldn't malloc read_capacity data\n"); + xpt_print(periph->path, + "cdstart: Couldn't malloc read_capacity data\n"); /* cd_free_periph??? */ break; } @@ -1631,8 +1627,8 @@ cddone(struct cam_periph *periph, union ccb *done_ccb) if (error != 0) { int s; - xpt_print_path(periph->path); - printf("cddone: got error %#x back\n", error); + xpt_print(periph->path, + "cddone: got error %#x back\n", error); s = splbio(); bioq_flush(&softc->bio_queue, NULL, EIO); splx(s); @@ -1813,14 +1809,12 @@ cddone(struct cam_periph *periph, union ccb *done_ccb) scsi_sense_print( &done_ccb->csio); else { - xpt_print_path(periph->path); - printf("got CAM status %#x\n", - done_ccb->ccb_h.status); + xpt_print(periph->path, + "got CAM status %#x\n", + done_ccb->ccb_h.status); } - xpt_print_path(periph->path); - printf("fatal error, failed" - " to attach to device\n"); - + xpt_print(periph->path, "fatal error, " + "failed to attach to device\n"); /* * Invalidate this peripheral. */ @@ -2955,16 +2949,16 @@ cd6byteworkaround(union ccb *ccb) * cdsetmode()! */ if (found == 0) { - xpt_print_path(periph->path); - printf("mode buffer not found in mode queue!\n"); + xpt_print(periph->path, + "mode buffer not found in mode queue!\n"); return (0); } params->cdb_size = 10; softc->minimum_command_size = 10; - xpt_print_path(ccb->ccb_h.path); - printf("%s(6) failed, increasing minimum CDB size to 10 bytes\n", - (cdb[0] == MODE_SENSE_6) ? "MODE_SENSE" : "MODE_SELECT"); + xpt_print(ccb->ccb_h.path, + "%s(6) failed, increasing minimum CDB size to 10 bytes\n", + (cdb[0] == MODE_SENSE_6) ? "MODE_SENSE" : "MODE_SELECT"); if (cdb[0] == MODE_SENSE_6) { struct scsi_mode_sense_10 ms10; @@ -3296,10 +3290,9 @@ cdgetmode(struct cam_periph *periph, struct cd_mode_params *data, * the data length incorrectly. */ if (data_len > data->alloc_len) { - xpt_print_path(periph->path); - printf("allocated modepage %d length %d < returned " - "length %d\n", page, data->alloc_len, data_len); - + xpt_print(periph->path, "allocated modepage %d length " + "%d < returned length %d\n", page, data->alloc_len, + data_len); error = ENOSPC; } } @@ -3757,9 +3750,8 @@ cdreportkey(struct cam_periph *periph, struct dvd_authinfo *authinfo) goto bailout; if (ccb->csio.resid != 0) { - xpt_print_path(periph->path); - printf("warning, residual for report key command is %d\n", - ccb->csio.resid); + xpt_print(periph->path, "warning, residual for report key " + "command is %d\n", ccb->csio.resid); } switch(authinfo->format) { diff --git a/sys/cam/scsi/scsi_ch.c b/sys/cam/scsi/scsi_ch.c index c79dd99..7ca7391 100644 --- a/sys/cam/scsi/scsi_ch.c +++ b/sys/cam/scsi/scsi_ch.c @@ -273,8 +273,7 @@ choninvalidate(struct cam_periph *periph) softc->flags |= CH_FLAG_INVALID; - xpt_print_path(periph->path); - printf("lost device\n"); + xpt_print(periph->path, "lost device\n"); } @@ -287,8 +286,7 @@ chcleanup(struct cam_periph *periph) devstat_remove_entry(softc->device_stats); destroy_dev(softc->dev); - xpt_print_path(periph->path); - printf("removing device entry\n"); + xpt_print(periph->path, "removing device entry\n"); free(softc, M_DEVBUF); } @@ -647,13 +645,12 @@ chdone(struct cam_periph *periph, union ccb *done_ccb) == CAM_SCSI_STATUS_ERROR) scsi_sense_print(&done_ccb->csio); else { - xpt_print_path(periph->path); - printf("got CAM status %#x\n", - done_ccb->ccb_h.status); + xpt_print(periph->path, + "got CAM status %#x\n", + done_ccb->ccb_h.status); } - xpt_print_path(periph->path); - printf("fatal error, failed to attach to" - " device\n"); + xpt_print(periph->path, "fatal error, failed " + "to attach to device\n"); cam_periph_invalidate(periph); @@ -1162,8 +1159,8 @@ chgetelemstatus(struct cam_periph *periph, avail = scsi_2btoul(st_hdr->count); if (avail != cesr->cesr_element_count) { - xpt_print_path(periph->path); - printf("warning, READ ELEMENT STATUS avail != count\n"); + xpt_print(periph->path, + "warning, READ ELEMENT STATUS avail != count\n"); } user_data = (struct changer_element_status *) @@ -1403,9 +1400,9 @@ chgetparams(struct cam_periph *periph) } if (error) { - xpt_print_path(periph->path); - printf("chgetparams: error getting element " - "address page\n"); + xpt_print(periph->path, + "chgetparams: error getting element " + "address page\n"); xpt_release_ccb(ccb); free(mode_buffer, M_TEMP); return(error); @@ -1466,9 +1463,9 @@ chgetparams(struct cam_periph *periph) } if (error) { - xpt_print_path(periph->path); - printf("chgetparams: error getting device " - "capabilities page\n"); + xpt_print(periph->path, + "chgetparams: error getting device " + "capabilities page\n"); xpt_release_ccb(ccb); free(mode_buffer, M_TEMP); return(error); diff --git a/sys/cam/scsi/scsi_da.c b/sys/cam/scsi/scsi_da.c index 6778054..262ca43 100644 --- a/sys/cam/scsi/scsi_da.c +++ b/sys/cam/scsi/scsi_da.c @@ -654,11 +654,10 @@ daclose(struct disk *dp) if (sense_key != SSD_KEY_ILLEGAL_REQUEST) scsi_sense_print(&ccb->csio); } else { - xpt_print_path(periph->path); - printf("Synchronize cache failed, status " - "== 0x%x, scsi status == 0x%x\n", - ccb->csio.ccb_h.status, - ccb->csio.scsi_status); + xpt_print(periph->path, "Synchronize cache " + "failed, status == 0x%x, scsi status == " + "0x%x\n", ccb->csio.ccb_h.status, + ccb->csio.scsi_status); } } @@ -826,10 +825,10 @@ dadump(void *arg, void *virtual, vm_offset_t physical, off_t offset, size_t leng if (sense_key != SSD_KEY_ILLEGAL_REQUEST) scsi_sense_print(&csio); } else { - xpt_print_path(periph->path); - printf("Synchronize cache failed, status " - "== 0x%x, scsi status == 0x%x\n", - csio.ccb_h.status, csio.scsi_status); + xpt_print(periph->path, "Synchronize cache " + "failed, status == 0x%x, scsi status == " + "0x%x\n", csio.ccb_h.status, + csio.scsi_status); } } } @@ -923,8 +922,7 @@ daoninvalidate(struct cam_periph *periph) SLIST_REMOVE(&softc_list, softc, da_softc, links); disk_gone(softc->disk); - xpt_print_path(periph->path); - printf("lost device\n"); + xpt_print(periph->path, "lost device\n"); } static void @@ -934,15 +932,13 @@ dacleanup(struct cam_periph *periph) softc = (struct da_softc *)periph->softc; - xpt_print_path(periph->path); - printf("removing device entry\n"); + xpt_print(periph->path, "removing device entry\n"); /* * If we can't free the sysctl tree, oh well... */ if ((softc->flags & DA_FLAG_SCTX_INIT) != 0 && sysctl_ctx_free(&softc->sysctl_ctx) != 0) { - xpt_print_path(periph->path); - printf("can't remove sysctl context\n"); + xpt_print(periph->path, "can't remove sysctl context\n"); } disk_destroy(softc->disk); free(softc, M_DEVBUF); @@ -1401,9 +1397,8 @@ cmd6workaround(union ccb *ccb) (*cdb != READ_6 && *cdb != WRITE_6)) return 0; - xpt_print_path(ccb->ccb_h.path); - printf("READ(6)/WRITE(6) not supported, " - "increasing minimum_cmd_size to 10.\n"); + xpt_print(ccb->ccb_h.path, "READ(6)/WRITE(6) not supported, " + "increasing minimum_cmd_size to 10.\n"); softc = (struct da_softc *)xpt_path_periph(ccb->ccb_h.path)->softc; softc->minimum_cmd_size = 10; @@ -1473,11 +1468,12 @@ dadone(struct cam_periph *periph, union ccb *done_ccb) * Catastrophic error. Mark our pack as * invalid. */ - /* XXX See if this is really a media - * change first. + /* + * XXX See if this is really a media + * XXX change first? */ - xpt_print_path(periph->path); - printf("Invalidating pack\n"); + xpt_print(periph->path, + "Invalidating pack\n"); softc->flags |= DA_FLAG_PACK_INVALID; } @@ -1575,9 +1571,9 @@ dadone(struct cam_periph *periph, union ccb *done_ccb) * here. */ if (block_size >= MAXPHYS || block_size == 0) { - xpt_print_path(periph->path); - printf("unsupportable block size %ju\n", - (uintmax_t) block_size); + xpt_print(periph->path, + "unsupportable block size %ju\n", + (uintmax_t) block_size); announce_buf[0] = '\0'; cam_periph_invalidate(periph); } else { @@ -1672,14 +1668,13 @@ dadone(struct cam_periph *periph, union ccb *done_ccb) scsi_sense_print( &done_ccb->csio); else { - xpt_print_path(periph->path); - printf("got CAM status %#x\n", - done_ccb->ccb_h.status); + xpt_print(periph->path, + "got CAM status %#x\n", + done_ccb->ccb_h.status); } - xpt_print_path(periph->path); - printf("fatal error, failed" - " to attach to device\n"); + xpt_print(periph->path, "fatal error, " + "failed to attach to device\n"); /* * Free up resources. @@ -2024,10 +2019,10 @@ dashutdown(void * arg, int howto) if (sense_key != SSD_KEY_ILLEGAL_REQUEST) scsi_sense_print(&ccb.csio); } else { - xpt_print_path(periph->path); - printf("Synchronize cache failed, status " - "== 0x%x, scsi status == 0x%x\n", - ccb.ccb_h.status, ccb.csio.scsi_status); + xpt_print(periph->path, "Synchronize " + "cache failed, status == 0x%x, scsi status " + "== 0x%x\n", ccb.ccb_h.status, + ccb.csio.scsi_status); } } diff --git a/sys/cam/scsi/scsi_pass.c b/sys/cam/scsi/scsi_pass.c index aab0c7d..f08a7ed 100644 --- a/sys/cam/scsi/scsi_pass.c +++ b/sys/cam/scsi/scsi_pass.c @@ -174,8 +174,7 @@ passoninvalidate(struct cam_periph *periph) */ if (bootverbose) { - xpt_print_path(periph->path); - printf("lost device\n"); + xpt_print(periph->path, "lost device\n"); } } @@ -192,8 +191,7 @@ passcleanup(struct cam_periph *periph) destroy_dev(softc->dev); if (bootverbose) { - xpt_print_path(periph->path); - printf("removing device entry\n"); + xpt_print(periph->path, "removing device entry\n"); } free(softc, M_DEVBUF); } @@ -360,8 +358,7 @@ passopen(struct cdev *dev, int flags, int fmt, struct thread *td) * We don't allow nonblocking access. */ if ((flags & O_NONBLOCK) != 0) { - xpt_print_path(periph->path); - printf("can't do nonblocking access\n"); + xpt_print(periph->path, "can't do nonblocking access\n"); splx(s); return(EINVAL); } @@ -476,9 +473,9 @@ passioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, struct thread *t * through the transport layer device. */ if (inccb->ccb_h.func_code & XPT_FC_XPT_ONLY) { - xpt_print_path(periph->path); - printf("CCB function code %#x is restricted to the " - "XPT device\n", inccb->ccb_h.func_code); + xpt_print(periph->path, "CCB function code %#x is " + "restricted to the XPT device\n", + inccb->ccb_h.func_code); error = ENODEV; break; } @@ -504,8 +501,7 @@ passioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, struct thread *t } if (ccb == NULL) { - xpt_print_path(periph->path); - printf("unable to allocate CCB\n"); + xpt_print(periph->path, "unable to allocate CCB\n"); error = ENOMEM; break; } diff --git a/sys/cam/scsi/scsi_pt.c b/sys/cam/scsi/scsi_pt.c index 412155a..752ddbd 100644 --- a/sys/cam/scsi/scsi_pt.c +++ b/sys/cam/scsi/scsi_pt.c @@ -387,8 +387,7 @@ ptoninvalidate(struct cam_periph *periph) splx(s); - xpt_print_path(periph->path); - printf("lost device\n"); + xpt_print(periph->path, "lost device\n"); } static void @@ -402,8 +401,7 @@ ptdtor(struct cam_periph *periph) destroy_dev(softc->dev); - xpt_print_path(periph->path); - printf("removing device entry\n"); + xpt_print(periph->path, "removing device entry\n"); free(softc, M_DEVBUF); } @@ -577,8 +575,8 @@ ptdone(struct cam_periph *periph, union ccb *done_ccb) * Catastrophic error. Mark our device * as invalid. */ - xpt_print_path(periph->path); - printf("Invalidating device\n"); + xpt_print(periph->path, + "Invalidating device\n"); softc->flags |= PT_FLAG_DEVICE_INVALID; } diff --git a/sys/cam/scsi/scsi_sa.c b/sys/cam/scsi/scsi_sa.c index d3260b6..013e421 100644 --- a/sys/cam/scsi/scsi_sa.c +++ b/sys/cam/scsi/scsi_sa.c @@ -566,8 +566,8 @@ saclose(struct cdev *dev, int flag, int fmt, struct thread *td) */ error = sacheckeod(periph); if (error) { - xpt_print_path(periph->path); - printf("failed to write terminating filemark(s)\n"); + xpt_print(periph->path, + "failed to write terminating filemark(s)\n"); softc->flags |= SA_FLAG_TAPE_FROZEN; } @@ -622,19 +622,18 @@ saclose(struct cdev *dev, int flag, int fmt, struct thread *td) if (error == 0 && writing && (softc->quirks & SA_QUIRK_2FM)) { tmp = saspace(periph, -1, SS_FILEMARKS); if (tmp) { - xpt_print_path(periph->path); - printf("unable to backspace over one of double" - " filemarks at end of tape\n"); - xpt_print_path(periph->path); - printf("it is possible that this device" - " needs a SA_QUIRK_1FM quirk set for it\n"); + xpt_print(periph->path, "unable to backspace " + "over one of double filemarks at end of " + "tape\n"); + xpt_print(periph->path, "it is possible that " + "this device needs a SA_QUIRK_1FM quirk set" + "for it\n"); softc->flags |= SA_FLAG_TAPE_FROZEN; } } break; default: - xpt_print_path(periph->path); - panic("unknown mode 0x%x in saclose", mode); + xpt_print(periph->path, "unknown mode 0x%x in saclose\n", mode); /* NOTREACHED */ break; } @@ -654,9 +653,8 @@ saclose(struct cdev *dev, int flag, int fmt, struct thread *td) * Inform users if tape state if frozen.... */ if (softc->flags & SA_FLAG_TAPE_FROZEN) { - xpt_print_path(periph->path); - printf("tape is now frozen- use an OFFLINE, REWIND or MTEOM " - "command to clear this state.\n"); + xpt_print(periph->path, "tape is now frozen- use an OFFLINE, " + "REWIND or MTEOM command to clear this state.\n"); } /* release the device if it is no longer mounted */ @@ -749,10 +747,9 @@ sastrategy(struct bio *bp) ((bp->bio_bcount & softc->blk_mask) != 0)) || ((softc->blk_mask == ~0) && ((bp->bio_bcount % softc->min_blk) != 0))) { - xpt_print_path(periph->path); - printf("Invalid request. Fixed block device " - "requests must be a multiple " - "of %d bytes\n", softc->min_blk); + xpt_print(periph->path, "Invalid request. Fixed block " + "device requests must be a multiple of %d bytes\n", + softc->min_blk); biofinish(bp, NULL, EINVAL); return; } @@ -761,8 +758,8 @@ sastrategy(struct bio *bp) (bp->bio_bcount & softc->blk_mask) != 0) { xpt_print_path(periph->path); - printf("Invalid request. Variable block device " - "requests must be "); + printf("Invalid request. Variable block " + "device requests must be "); if (softc->blk_mask != 0) { printf("a multiple of %d ", (0x1 << softc->blk_gran)); } @@ -1070,8 +1067,8 @@ saioctl(struct cdev *dev, u_long cmd, caddr_t arg, int flag, struct thread *td) nmarks = softc->filemarks; error = sacheckeod(periph); if (error) { - xpt_print_path(periph->path); - printf("EOD check prior to spacing failed\n"); + xpt_print(periph->path, + "EOD check prior to spacing failed\n"); softc->flags |= SA_FLAG_EIO_PENDING; break; } @@ -1322,8 +1319,8 @@ saioctl(struct cdev *dev, u_long cmd, caddr_t arg, int flag, struct thread *td) softc->fileno = (daddr_t) -1; softc->blkno = (daddr_t) -1; softc->flags &= ~SA_FLAG_TAPE_FROZEN; - xpt_print_path(periph->path); - printf("tape state now unfrozen.\n"); + xpt_print(periph->path, + "tape state now unfrozen.\n"); break; default: break; @@ -1407,8 +1404,7 @@ saoninvalidate(struct cam_periph *periph) softc->queue_count = 0; splx(s); - xpt_print_path(periph->path); - printf("lost device\n"); + xpt_print(periph->path, "lost device\n"); } @@ -1430,8 +1426,7 @@ sacleanup(struct cam_periph *periph) destroy_dev(softc->devs.mode_devs[i].er_dev); } - xpt_print_path(periph->path); - printf("removing device entry\n"); + xpt_print(periph->path, "removing device entry\n"); free(softc, M_SCSISA); } @@ -1525,9 +1520,8 @@ saregister(struct cam_periph *periph, void *arg) softc->last_media_blksize = ((struct sa_quirk_entry *)match)->prefblk; #ifdef CAMDEBUG - xpt_print_path(periph->path); - printf("found quirk entry %d\n", (int) - (((struct sa_quirk_entry *) match) - sa_quirk_table)); + xpt_print(periph->path, "found quirk entry %d\n", + (int) (((struct sa_quirk_entry *) match) - sa_quirk_table)); #endif } else softc->quirks = SA_QUIRK_NONE; @@ -1693,9 +1687,8 @@ again: softc->media_blksize; } else { bp->bio_error = EIO; - xpt_print_path(periph->path); - printf("zero blocksize for " - "FIXED length writes?\n"); + xpt_print(periph->path, "zero blocksize" + " for FIXED length writes?\n"); splx(s); biodone(bp); break; @@ -1920,8 +1913,8 @@ samount(struct cam_periph *periph, int oflags, struct cdev *dev) */ softc->flags &= ~SA_FLAG_TAPE_MOUNTED; if (CAM_DEBUGGED(periph->path, CAM_DEBUG_INFO)) { - xpt_print_path(periph->path); - printf("error %d on TUR in samount\n", error); + xpt_print(periph->path, + "error %d on TUR in samount\n", error); } } } else { @@ -1984,8 +1977,7 @@ samount(struct cam_periph *periph, int oflags, struct cdev *dev) rblim = (struct scsi_read_block_limits_data *) malloc(8192, M_TEMP, M_WAITOK); if (rblim == NULL) { - xpt_print_path(periph->path); - printf("no memory for test read\n"); + xpt_print(periph->path, "no memory for test read\n"); xpt_release_ccb(ccb); error = ENOMEM; goto exit; @@ -2006,8 +1998,8 @@ samount(struct cam_periph *periph, int oflags, struct cdev *dev) softc->device_stats); QFRLS(ccb); if (error) { - xpt_print_path(periph->path); - printf("unable to rewind after test read\n"); + xpt_print(periph->path, + "unable to rewind after test read\n"); xpt_release_ccb(ccb); goto exit; } @@ -2171,8 +2163,8 @@ samount(struct cam_periph *periph, int oflags, struct cdev *dev) if ((softc->max_blk < softc->media_blksize) || (softc->min_blk > softc->media_blksize && softc->media_blksize)) { - xpt_print_path(periph->path); - printf("BLOCK LIMITS (%d..%d) could not match current " + xpt_print(periph->path, + "BLOCK LIMITS (%d..%d) could not match current " "block settings (%d)- adjusting\n", softc->min_blk, softc->max_blk, softc->media_blksize); softc->max_blk = softc->min_blk = @@ -2206,9 +2198,9 @@ tryagain: error = sasetparams(periph, SA_PARAM_BLOCKSIZE, softc->media_blksize, 0, 0, SF_NO_PRINT); if (error) { - xpt_print_path(periph->path); - printf("unable to set fixed blocksize to %d\n", - softc->media_blksize); + xpt_print(periph->path, + "unable to set fixed blocksize to %d\n", + softc->media_blksize); goto exit; } } @@ -2233,8 +2225,8 @@ tryagain: softc->last_media_blksize = 512; goto tryagain; } - xpt_print_path(periph->path); - printf("unable to set variable blocksize\n"); + xpt_print(periph->path, + "unable to set variable blocksize\n"); goto exit; } } @@ -2291,8 +2283,8 @@ tryagain: if (error == 0) { softc->buffer_mode = SMH_SA_BUF_MODE_SIBUF; } else { - xpt_print_path(periph->path); - printf("unable to set buffered mode\n"); + xpt_print(periph->path, + "unable to set buffered mode\n"); } error = 0; /* not an error */ } @@ -2534,8 +2526,8 @@ saerror(union ccb *ccb, u_int32_t cflgs, u_int32_t sflgs) */ if (error == 0 && (sense->flags & SSD_ILI)) { if (info < 0) { - xpt_print_path(csio->ccb_h.path); - printf(toobig, csio->dxfer_len - info); + xpt_print(csio->ccb_h.path, toobig, + csio->dxfer_len - info); csio->resid = csio->dxfer_len; error = EIO; } else { @@ -2956,8 +2948,8 @@ retry: * so turn off the set compression bit. */ params_to_set &= ~SA_PARAM_COMPRESSION; - xpt_print_path(periph->path); - printf("device does not seem to support compression\n"); + xpt_print(periph->path, + "device does not seem to support compression\n"); /* * If that was the only thing the user wanted us to set, diff --git a/sys/cam/scsi/scsi_ses.c b/sys/cam/scsi/scsi_ses.c index 608290d..2af83ce 100644 --- a/sys/cam/scsi/scsi_ses.c +++ b/sys/cam/scsi/scsi_ses.c @@ -237,8 +237,7 @@ sesoninvalidate(struct cam_periph *periph) softc->ses_flags |= SES_FLAG_INVALID; - xpt_print_path(periph->path); - printf("lost device\n"); + xpt_print(periph->path, "lost device\n"); } static void @@ -250,8 +249,7 @@ sescleanup(struct cam_periph *periph) destroy_dev(softc->ses_dev); - xpt_print_path(periph->path); - printf("removing device entry\n"); + xpt_print(periph->path, "removing device entry\n"); free(softc, M_SCSISES); } diff --git a/sys/cam/scsi/scsi_targ_bh.c b/sys/cam/scsi/scsi_targ_bh.c index e755f2f..b61152e 100644 --- a/sys/cam/scsi/scsi_targ_bh.c +++ b/sys/cam/scsi/scsi_targ_bh.c @@ -263,9 +263,9 @@ targbhenlun(struct cam_periph *periph) xpt_action(&immed_ccb); status = immed_ccb.ccb_h.status; if (status != CAM_REQ_CMP) { - xpt_print_path(periph->path); - printf("targbhenlun - Enable Lun Rejected with status 0x%x\n", - status); + xpt_print(periph->path, + "targbhenlun - Enable Lun Rejected with status 0x%x\n", + status); return (status); } @@ -309,9 +309,9 @@ targbhenlun(struct cam_periph *periph) } if (i == 0) { - xpt_print_path(periph->path); - printf("targbhenlun - Could not allocate accept tio CCBs: " - "status = 0x%x\n", status); + xpt_print(periph->path, + "targbhenlun - Could not allocate accept tio CCBs: status " + "= 0x%x\n", status); targbhdislun(periph); return (CAM_REQ_CMP_ERR); } @@ -345,9 +345,9 @@ targbhenlun(struct cam_periph *periph) } if (i == 0) { - xpt_print_path(periph->path); - printf("targbhenlun - Could not allocate immediate notify " - "CCBs: status = 0x%x\n", status); + xpt_print(periph->path, + "targbhenlun - Could not allocate immediate notify " + "CCBs: status = 0x%x\n", status); targbhdislun(periph); return (CAM_REQ_CMP_ERR); } diff --git a/sys/cam/scsi/scsi_target.c b/sys/cam/scsi/scsi_target.c index db0df75..aea6922 100644 --- a/sys/cam/scsi/scsi_target.c +++ b/sys/cam/scsi/scsi_target.c @@ -357,9 +357,8 @@ targendislun(struct cam_path *path, int enable, int grp6_len, int grp7_len) xpt_action((union ccb *)&en_ccb); status = en_ccb.ccb_h.status & CAM_STATUS_MASK; if (status != CAM_REQ_CMP) { - xpt_print_path(path); - printf("%sable lun CCB rejected, status %#x\n", - enable ? "en" : "dis", status); + xpt_print(path, "%sable lun CCB rejected, status %#x\n", + enable ? "en" : "dis", status); } return (status); } @@ -611,8 +610,8 @@ targstart(struct cam_periph *periph, union ccb *start_ccb) if (error == 0) error = targsendccb(softc, start_ccb, descr); if (error != 0) { - xpt_print_path(periph->path); - printf("targsendccb failed, err %d\n", error); + xpt_print(periph->path, + "targsendccb failed, err %d\n", error); xpt_release_ccb(start_ccb); suword(&descr->user_ccb->ccb_h.status, CAM_REQ_CMP_ERR); @@ -905,9 +904,8 @@ targreturnccb(struct targ_softc *softc, union ccb *ccb) cam_periph_unmapmem(ccb, &descr->mapinfo); error = copyout(&ccb->ccb_h + 1, u_ccbh + 1, ccb_len); if (error != 0) { - xpt_print_path(softc->path); - printf("targreturnccb - CCB copyout failed (%d)\n", - error); + xpt_print(softc->path, + "targreturnccb - CCB copyout failed (%d)\n", error); } /* Free CCB or send back to devq. */ targfreeccb(softc, ccb); @@ -1031,9 +1029,9 @@ abort_all_pending(struct targ_softc *softc) cab.abort_ccb = (union ccb *)ccb_h; xpt_action((union ccb *)&cab); if (cab.ccb_h.status != CAM_REQ_CMP) { - xpt_print_path(cab.ccb_h.path); - printf("Unable to abort CCB, status %#x\n", - cab.ccb_h.status); + xpt_print(cab.ccb_h.path, + "Unable to abort CCB, status %#x\n", + cab.ccb_h.status); } } -- cgit v1.1