PERFORCE change 173457 for review
Alexander Motin
mav at FreeBSD.org
Thu Jan 21 14:18:12 UTC 2010
http://p4web.freebsd.org/chv.cgi?CH=173457
Change 173457 by mav at mav_mavtest on 2010/01/21 14:18:04
Make error messages (especially SCSI) more readable.
Affected files ...
.. //depot/projects/scottl-camlock/src/sys/cam/ata/ata_all.c#35 edit
.. //depot/projects/scottl-camlock/src/sys/cam/cam.c#15 edit
.. //depot/projects/scottl-camlock/src/sys/cam/cam_periph.c#50 edit
.. //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_all.c#13 edit
Differences ...
==== //depot/projects/scottl-camlock/src/sys/cam/ata/ata_all.c#35 (text+ko) ====
@@ -198,7 +198,7 @@
{
char cmd_str[(12 * 3) + 1];
- sbuf_printf(sb, "CMD: %s: %s",
+ sbuf_printf(sb, "%s. ACB: %s",
ata_op_string(&ataio->cmd),
ata_cmd_string(&ataio->cmd, cmd_str, sizeof(cmd_str)));
@@ -212,7 +212,7 @@
ata_status_sbuf(struct ccb_ataio *ataio, struct sbuf *sb)
{
- sbuf_printf(sb, "ATA Status: %02x (%s%s%s%s%s%s%s%s)",
+ sbuf_printf(sb, "ATA status: %02x (%s%s%s%s%s%s%s%s)",
ataio->res.status,
(ataio->res.status & 0x80) ? "BSY " : "",
(ataio->res.status & 0x40) ? "DRDY " : "",
@@ -223,7 +223,7 @@
(ataio->res.status & 0x02) ? "IDX " : "",
(ataio->res.status & 0x01) ? "ERR" : "");
if (ataio->res.status & 1) {
- sbuf_printf(sb, ", Error: %02x (%s%s%s%s%s%s%s%s)",
+ sbuf_printf(sb, ", error: %02x (%s%s%s%s%s%s%s%s)",
ataio->res.error,
(ataio->res.error & 0x80) ? "ICRC " : "",
(ataio->res.error & 0x40) ? "UNC " : "",
==== //depot/projects/scottl-camlock/src/sys/cam/cam.c#15 (text+ko) ====
@@ -305,10 +305,10 @@
entry = cam_fetch_status_entry(status);
if (entry == NULL)
- sbuf_printf(&sb, "CAM Status: Unknown (%#x)\n",
+ sbuf_printf(&sb, "CAM status: Unknown (%#x)\n",
ccb->ccb_h.status);
else
- sbuf_printf(&sb, "CAM Status: %s\n",
+ sbuf_printf(&sb, "CAM status: %s\n",
entry->status_text);
}
@@ -338,7 +338,7 @@
if (proto_flags & CAM_ESF_PRINT_STATUS) {
sbuf_cat(&sb, path_str);
- sbuf_printf(&sb, "SCSI Status: %s\n",
+ sbuf_printf(&sb, "SCSI status: %s\n",
scsi_status_string(&ccb->csio));
}
==== //depot/projects/scottl-camlock/src/sys/cam/cam_periph.c#50 (text+ko) ====
@@ -74,14 +74,16 @@
union ccb *save_ccb,
int *openings,
u_int32_t *relsim_flags,
- u_int32_t *timeout);
+ u_int32_t *timeout,
+ const char **action_string);
static int camperiphscsisenseerror(union ccb *ccb,
cam_flags camflags,
u_int32_t sense_flags,
union ccb *save_ccb,
int *openings,
u_int32_t *relsim_flags,
- u_int32_t *timeout);
+ u_int32_t *timeout,
+ const char **action_string);
static int nperiph_drivers;
static int initialized = 0;
@@ -1066,7 +1068,6 @@
#if 0
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);
#endif
@@ -1297,7 +1298,7 @@
camperiphscsistatuserror(union ccb *ccb, cam_flags camflags,
u_int32_t sense_flags, union ccb *save_ccb,
int *openings, u_int32_t *relsim_flags,
- u_int32_t *timeout)
+ u_int32_t *timeout, const char **action_string)
{
int error;
@@ -1310,13 +1311,16 @@
break;
case SCSI_STATUS_CMD_TERMINATED:
case SCSI_STATUS_CHECK_COND:
+ if (bootverbose)
+ xpt_print(ccb->ccb_h.path, "SCSI status error\n");
error = camperiphscsisenseerror(ccb,
camflags,
sense_flags,
save_ccb,
openings,
relsim_flags,
- timeout);
+ timeout,
+ action_string);
break;
case SCSI_STATUS_QUEUE_FULL:
{
@@ -1371,7 +1375,7 @@
*timeout = 0;
error = ERESTART;
if (bootverbose) {
- xpt_print(ccb->ccb_h.path, "Queue Full\n");
+ xpt_print(ccb->ccb_h.path, "Queue full\n");
}
break;
}
@@ -1383,7 +1387,7 @@
* command completes or a 1 second timeout.
*/
if (bootverbose) {
- xpt_print(ccb->ccb_h.path, "Device Busy\n");
+ xpt_print(ccb->ccb_h.path, "Device busy\n");
}
if (ccb->ccb_h.retry_count > 0) {
ccb->ccb_h.retry_count--;
@@ -1396,11 +1400,11 @@
}
break;
case SCSI_STATUS_RESERV_CONFLICT:
- xpt_print(ccb->ccb_h.path, "Reservation Conflict\n");
+ xpt_print(ccb->ccb_h.path, "Reservation conflict\n");
error = EIO;
break;
default:
- xpt_print(ccb->ccb_h.path, "SCSI Status 0x%x\n",
+ xpt_print(ccb->ccb_h.path, "SCSI status 0x%x\n",
ccb->csio.scsi_status);
error = EIO;
break;
@@ -1412,7 +1416,7 @@
camperiphscsisenseerror(union ccb *ccb, cam_flags camflags,
u_int32_t sense_flags, union ccb *save_ccb,
int *openings, u_int32_t *relsim_flags,
- u_int32_t *timeout)
+ u_int32_t *timeout, const char **action_string)
{
struct cam_periph *periph;
int error;
@@ -1437,12 +1441,8 @@
} else {
scsi_sense_action err_action;
struct ccb_getdev cgd;
- const char *action_string;
union ccb* print_ccb;
- /* A description of the error recovery action performed */
- action_string = NULL;
-
/*
* The location of the orignal ccb
* for sense printing purposes.
@@ -1475,7 +1475,7 @@
if (ccb->ccb_h.retry_count > 0)
ccb->ccb_h.retry_count--;
else {
- action_string = "Retries Exhausted";
+ *action_string = "Retries exhausted";
goto sense_error_done;
}
}
@@ -1486,7 +1486,7 @@
* use recovery CCBs.
*/
if (save_ccb == NULL) {
- action_string = "No recovery CCB supplied";
+ *action_string = "No recovery CCB supplied";
goto sense_error_done;
}
/*
@@ -1501,15 +1501,15 @@
switch (err_action & SS_MASK) {
case SS_NOP:
- action_string = "No Recovery Action Needed";
+ *action_string = "No recovery action needed";
error = 0;
break;
case SS_RETRY:
- action_string = "Retrying Command (per Sense Data)";
+ *action_string = "Retrying command (per sense data)";
error = ERESTART;
break;
case SS_FAIL:
- action_string = "Unretryable error";
+ *action_string = "Unretryable error";
break;
case SS_START:
{
@@ -1519,7 +1519,7 @@
* Send a start unit command to the device, and
* then retry the command.
*/
- action_string = "Attempting to Start Unit";
+ *action_string = "Attempting to start unit";
/*
* Check for removable media and set
@@ -1554,10 +1554,10 @@
int retries;
if ((err_action & SSQ_MANY) != 0) {
- action_string = "Polling device for readiness";
+ *action_string = "Polling device for readiness";
retries = 120;
} else {
- action_string = "Testing device for readiness";
+ *action_string = "Testing device for readiness";
retries = 1;
}
scsi_test_unit_ready(&ccb->csio,
@@ -1577,6 +1577,7 @@
}
case SS_REQSENSE:
{
+ *action_string = "Requesting SCSI sense data";
/*
* Send a Request Sense to the device. We
* assume that we are in a contingent allegiance
@@ -1612,11 +1613,8 @@
sense_error_done:
if ((err_action & SSQ_PRINT_SENSE) != 0
- && (ccb->ccb_h.status & CAM_AUTOSNS_VALID) != 0) {
+ && (ccb->ccb_h.status & CAM_AUTOSNS_VALID) != 0)
cam_error_print(print_ccb, CAM_ESF_ALL, CAM_EPF_ALL);
- xpt_print_path(ccb->ccb_h.path);
- printf("%s\n", action_string);
- }
}
return (error);
}
@@ -1655,16 +1653,16 @@
save_ccb,
&openings,
&relsim_flags,
- &timeout);
+ &timeout,
+ &action_string);
break;
case CAM_AUTOSENSE_FAIL:
- xpt_print(ccb->ccb_h.path, "AutoSense Failed\n");
+ xpt_print(ccb->ccb_h.path, "AutoSense failed\n");
error = EIO; /* we have to kill the command */
break;
case CAM_ATA_STATUS_ERROR:
if (bootverbose && printed == 0) {
- xpt_print(ccb->ccb_h.path,
- "Request completed with CAM_ATA_STATUS_ERROR\n");
+ xpt_print(ccb->ccb_h.path, "ATA status error\n");
cam_error_print(ccb, CAM_ESF_ALL, CAM_EPF_ALL);
printed++;
}
@@ -1691,13 +1689,13 @@
case CAM_UNCOR_PARITY:
if (bootverbose && printed == 0) {
xpt_print(ccb->ccb_h.path,
- "Uncorrected Parity Error\n");
+ "Uncorrected parity error\n");
printed++;
}
/* FALLTHROUGH */
case CAM_DATA_RUN_ERR:
if (bootverbose && printed == 0) {
- xpt_print(ccb->ccb_h.path, "Data Overrun\n");
+ xpt_print(ccb->ccb_h.path, "Data overrun\n");
printed++;
}
error = EIO; /* we have to kill the command */
@@ -1706,7 +1704,7 @@
ccb->ccb_h.retry_count--;
error = ERESTART;
} else {
- action_string = "Retries Exhausted";
+ action_string = "Retries exhausted";
error = EIO;
}
break;
@@ -1727,7 +1725,7 @@
error = ERESTART;
if (bootverbose && printed == 0) {
xpt_print(ccb->ccb_h.path,
- "Selection Timeout\n");
+ "Selection timeout\n");
printed++;
}
@@ -1789,7 +1787,7 @@
/* Unconditional requeue */
error = ERESTART;
if (bootverbose && printed == 0) {
- xpt_print(ccb->ccb_h.path, "Request Requeued\n");
+ xpt_print(ccb->ccb_h.path, "Request requeued\n");
printed++;
}
break;
@@ -1810,13 +1808,13 @@
ccb->ccb_h.retry_count--;
error = ERESTART;
if (bootverbose && printed == 0) {
- xpt_print(ccb->ccb_h.path, "CAM Status 0x%x\n",
+ xpt_print(ccb->ccb_h.path, "CAM status 0x%x\n",
status);
printed++;
}
} else {
error = EIO;
- action_string = "Retries Exhausted";
+ action_string = "Retries exhausted";
}
break;
}
@@ -1829,11 +1827,13 @@
!(status == CAM_SEL_TIMEOUT && (camflags & CAM_RETRY_SELTO) == 0)) {
if (error != ERESTART) {
if (action_string == NULL)
- action_string = "Unretryable Error";
- xpt_print(ccb->ccb_h.path, "error %d\n", error);
+ action_string = "Unretryable error";
+ xpt_print(ccb->ccb_h.path, "Error %d, %s\n",
+ error, action_string);
+ } else if (action_string != NULL)
xpt_print(ccb->ccb_h.path, "%s\n", action_string);
- } else
- xpt_print(ccb->ccb_h.path, "Retrying Command\n");
+ else
+ xpt_print(ccb->ccb_h.path, "Retrying command\n");
}
/* Attempt a retry */
==== //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_all.c#13 (text+ko) ====
@@ -3130,7 +3130,9 @@
*/
if (csio->ccb_h.flags & CAM_SENSE_PTR) {
if (csio->ccb_h.flags & CAM_SENSE_PHYS) {
+#ifdef _KERNEL
xpt_free_ccb((union ccb*)cgd);
+#endif /* _KERNEL/!_KERNEL */
return(-1);
} else {
/*
@@ -3151,7 +3153,9 @@
* already.)
*/
if (csio->ccb_h.flags & CAM_SENSE_PHYS) {
+#ifdef _KERNEL
xpt_free_ccb((union ccb*)cgd);
+#endif /* _KERNEL/!_KERNEL */
return(-1);
} else
sense = &csio->sense_data;
@@ -3163,9 +3167,10 @@
error_code = sense->error_code & SSD_ERRCODE;
sense_key = sense->flags & SSD_KEY;
+ sbuf_printf(sb, "SCSI sense: ");
switch (error_code) {
case SSD_DEFERRED_ERROR:
- sbuf_printf(sb, "Deferred Error: ");
+ sbuf_printf(sb, "Deferred error: ");
/* FALLTHROUGH */
case SSD_CURRENT_ERROR:
@@ -3218,8 +3223,7 @@
}
}
- sbuf_printf(sb, " asc:%x,%x\n%s%s", asc, ascq,
- path_str, asc_desc);
+ sbuf_printf(sb, " asc:%x,%x (%s)", asc, ascq, asc_desc);
if (sense->extra_len >= 7 && sense->fru) {
sbuf_printf(sb, " field replaceable unit: %x",
@@ -3271,7 +3275,7 @@
}
default:
- sbuf_printf(sb, "Sense Error Code 0x%x", sense->error_code);
+ sbuf_printf(sb, "Error code 0x%x", sense->error_code);
if (sense->error_code & SSD_ERRCODE_VALID) {
sbuf_printf(sb, " at block no. %d (decimal)",
info = scsi_4btoul(sense->info));
@@ -3280,7 +3284,9 @@
sbuf_printf(sb, "\n");
+#ifdef _KERNEL
xpt_free_ccb((union ccb*)cgd);
+#endif /* _KERNEL/!_KERNEL */
return(0);
}
More information about the p4-projects
mailing list