Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 17 Aug 2011 12:32:27 +0000
From:      oleksandr@FreeBSD.org
To:        svn-soc-all@FreeBSD.org
Subject:   socsvn commit: r225189 - soc2011/oleksandr/oleksandr-head/head/sys/cam
Message-ID:  <20110817123227.50C3C1065672@hub.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: oleksandr
Date: Wed Aug 17 12:32:27 2011
New Revision: 225189
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=225189

Log:
  Review the format of errors

Modified:
  soc2011/oleksandr/oleksandr-head/head/sys/cam/cam_periph.c

Modified: soc2011/oleksandr/oleksandr-head/head/sys/cam/cam_periph.c
==============================================================================
--- soc2011/oleksandr/oleksandr-head/head/sys/cam/cam_periph.c	Wed Aug 17 09:52:34 2011	(r225188)
+++ soc2011/oleksandr/oleksandr-head/head/sys/cam/cam_periph.c	Wed Aug 17 12:32:27 2011	(r225189)
@@ -1735,22 +1735,35 @@
             error_flag_ret != 0) 
                 error_flag_type = DEVSTAT_ERROR_OTHER_ERROR;
         /*
+         * If function code is equal to XPT_SCSI_IO it means that the  
+         * error information can be found in the structure sense_data.
+         */
+        if (ccb->ccb_h.func_code == XPT_SCSI_IO && error_flag_ret != 0) {
+                int sense_key, error_code, asc, ascq;
+                scsi_extract_sense(&ccb->csio.sense_data, 
+                                   &error_code, &sense_key, &asc, &ascq);
+                switch(sense_key) {
+                case SSD_KEY_RECOVERED_ERROR:
+                        error_flag_sense = DEVSTAT_ERROR_RECOVERED;
+                        break;
+                case SSD_KEY_NOT_READY: 
+                        error_flag_sense = DEVSTAT_ERROR_NOT_READY;
+                        break;
+                case SSD_KEY_MEDIUM_ERROR:
+                        error_flag_sense = DEVSTAT_ERROR_MEDIUM_ERROR;
+                        break;
+                case SSD_KEY_HARDWARE_ERROR: 
+                        error_flag_sense = DEVSTAT_ERROR_HARDWARE;
+                        break;
+                case SSD_KEY_ILLEGAL_REQUEST: 
+                        error_flag_sense = DEVSTAT_ERROR_ILLEGAL_REQ;
+                        break;
+                }
+        }
+        /*
          * If an error is present, search for an appropriate structure 
          * in devstat and increase the corresponding counter of errors.
          */
-        int sense_key, error_code, asc, ascq;
-        scsi_extract_sense(&ccb->csio.sense_data, 
-                           &error_code, &sense_key, &asc, &ascq);
-        if (sense_key == SSD_KEY_RECOVERED_ERROR && error_flag_ret != 0)
-                error_flag_sense = DEVSTAT_ERROR_RECOVERED;
-        if (sense_key == SSD_KEY_NOT_READY && error_flag_ret != 0)
-                error_flag_sense = DEVSTAT_ERROR_NOT_READY;
-        if (sense_key == SSD_KEY_MEDIUM_ERROR && error_flag_ret != 0)
-                error_flag_sense = DEVSTAT_ERROR_MEDIUM_ERROR;
-        if (sense_key == SSD_KEY_HARDWARE_ERROR && error_flag_ret != 0)
-                error_flag_sense = DEVSTAT_ERROR_HARDWARE;
-        if (sense_key == SSD_KEY_ILLEGAL_REQUEST && error_flag_ret != 0)
-                error_flag_sense = DEVSTAT_ERROR_ILLEGAL_REQ;
         if (error_flag_ret) {
                if ((device_error = devstat_search(
                             ccb->ccb_h.path->periph->periph_name,



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20110817123227.50C3C1065672>