Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 18 Aug 2011 14:33:44 +0000
From:      oleksandr@FreeBSD.org
To:        svn-soc-all@FreeBSD.org
Subject:   socsvn commit: r225226 - in soc2011/oleksandr/oleksandr-head/head/sys: cam kern sys
Message-ID:  <20110818143344.28A751065679@hub.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: oleksandr
Date: Thu Aug 18 14:33:43 2011
New Revision: 225226
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=225226

Log:
  Errors associated with status func_code= XPT_ATA_IO

Modified:
  soc2011/oleksandr/oleksandr-head/head/sys/cam/cam_periph.c
  soc2011/oleksandr/oleksandr-head/head/sys/kern/subr_devstat.c
  soc2011/oleksandr/oleksandr-head/head/sys/sys/devicestat.h

Modified: soc2011/oleksandr/oleksandr-head/head/sys/cam/cam_periph.c
==============================================================================
--- soc2011/oleksandr/oleksandr-head/head/sys/cam/cam_periph.c	Thu Aug 18 13:33:34 2011	(r225225)
+++ soc2011/oleksandr/oleksandr-head/head/sys/cam/cam_periph.c	Thu Aug 18 14:33:43 2011	(r225226)
@@ -1715,7 +1715,8 @@
          */
         if (status == CAM_REQ_CMP_ERR || status == CAM_TID_INVALID ||
             status == CAM_SCSI_STATUS_ERROR || status == CAM_AUTOSENSE_FAIL ||
-            status == CAM_LUN_INVALID || status == CAM_AUTOSNS_VALID) 
+            status == CAM_LUN_INVALID || status == CAM_AUTOSNS_VALID ||
+            status == CAM_ATA_STATUS_ERROR) 
                 error_flag_ret = DEVSTAT_ERROR_NON_RETRIABLE;
         /*
          * If the error is write error refer it to the type of write error.
@@ -1736,7 +1737,7 @@
                 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.
+         * information about error 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;
@@ -1758,9 +1759,38 @@
                 case SSD_KEY_ILLEGAL_REQUEST: 
                         error_flag_sense = DEVSTAT_ERROR_ILLEGAL_REQ;
                         break;
+                case SSD_KEY_UNIT_ATTENTION: 
+                        error_flag_sense = DEVSTAT_ERROR_UNIT_ATTENTION;
+                        break;
+                case SSD_KEY_ABORTED_COMMAND: 
+                        error_flag_sense = DEVSTAT_ERROR_ABORTED_COMMAND;
+                        break;
                 }
         }
         /*
+         * If function code is equal to XPT_ATA_IO it means that the  
+         * information about error can be found in the structure ataio.res.
+         */
+        if (ccb->ccb_h.func_code == XPT_ATA_IO && error_flag_ret != 0) {
+               if ((ccb->ataio.res.status & 0x20) && (!ccb->ataio.res.error))  
+                       error_flag_sense = DEVSTAT_ERROR_HARDWARE;
+               if (ccb->ataio.res.status & 0x10) {
+                       if (ccb->ataio.res.error && 0x02)
+                               error_flag_sense = DEVSTAT_ERROR_NOT_READY;
+                       if ((ccb->ataio.res.error && 0x40) ||
+                           (ccb->ataio.res.error && 0x01) ||
+                           (ccb->ataio.res.error && 0x10)) 
+                               error_flag_sense = DEVSTAT_ERROR_MEDIA_ERROR;
+                       if (ccb->ataio.res.error && 0x04) 
+                               error_flag_sense = DEVSTAT_ERROR_ILLEGAL_REQ;
+                       if ((ccb->ataio.res.error && 0x20) ||
+                           (ccb->ataio.res.error && 0x08))
+                               error_flag_sense = DEVSTAT_ERROR_UNIT_ATTENTION;
+                       if (ccb->ataio.res.error && 0x80)
+                               error_flag_sense = DEVSTAT_ERROR_ABORTED_COMMAND;
+               }
+        }
+        /*
          * If an error is present, search for an appropriate structure 
          * in devstat and increase the corresponding counter of errors.
          */

Modified: soc2011/oleksandr/oleksandr-head/head/sys/kern/subr_devstat.c
==============================================================================
--- soc2011/oleksandr/oleksandr-head/head/sys/kern/subr_devstat.c	Thu Aug 18 13:33:34 2011	(r225225)
+++ soc2011/oleksandr/oleksandr-head/head/sys/kern/subr_devstat.c	Thu Aug 18 14:33:43 2011	(r225226)
@@ -395,6 +395,10 @@
                 ds->dev_error.hardware++;
         if ((error_flag | DEVSTAT_ERROR_ILLEGAL_REQ) == error_flag)
                 ds->dev_error.illegal_req++;
+        if ((error_flag | DEVSTAT_ERROR_UNIT_ATTENTION) == error_flag)
+                ds->dev_error.illegal_req++;
+        if ((error_flag | DEVSTAT_ERROR_ABORTED_COMMAND) == error_flag)
+                ds->dev_error.aborted_command++;
 }
 /*
  * This is the sysctl handler for the devstat package.  The data pushed out

Modified: soc2011/oleksandr/oleksandr-head/head/sys/sys/devicestat.h
==============================================================================
--- soc2011/oleksandr/oleksandr-head/head/sys/sys/devicestat.h	Thu Aug 18 13:33:34 2011	(r225225)
+++ soc2011/oleksandr/oleksandr-head/head/sys/sys/devicestat.h	Thu Aug 18 14:33:43 2011	(r225226)
@@ -98,16 +98,18 @@
  * These flags indicates the type of disk error.
  */
 typedef enum {
-        DEVSTAT_ERROR_RETRIABLE     = 0x001,
-        DEVSTAT_ERROR_NON_RETRIABLE = 0x002,
-        DEVSTAT_ERROR_READ_ERROR    = 0x004, 
-        DEVSTAT_ERROR_WRITE_ERROR   = 0x008,
-        DEVSTAT_ERROR_OTHER_ERROR   = 0x010,
-        DEVSTAT_ERROR_RECOVERABLE   = 0x020,
-        DEVSTAT_ERROR_NOT_READY     = 0x040,
-        DEVSTAT_ERROR_MEDIA_ERROR   = 0x080,
-        DEVSTAT_ERROR_HARDWARE      = 0x100,
-        DEVSTAT_ERROR_ILLEGAL_REQ   = 0x200
+        DEVSTAT_ERROR_RETRIABLE       = 0x001,
+        DEVSTAT_ERROR_NON_RETRIABLE   = 0x002,
+        DEVSTAT_ERROR_READ_ERROR      = 0x004, 
+        DEVSTAT_ERROR_WRITE_ERROR     = 0x008,
+        DEVSTAT_ERROR_OTHER_ERROR     = 0x010,
+        DEVSTAT_ERROR_RECOVERABLE     = 0x020,
+        DEVSTAT_ERROR_NOT_READY       = 0x040,
+        DEVSTAT_ERROR_MEDIA_ERROR     = 0x080,
+        DEVSTAT_ERROR_HARDWARE        = 0x100,
+        DEVSTAT_ERROR_ILLEGAL_REQ     = 0x200,
+        DEVSTAT_ERROR_UNIT_ATTENTION  = 0x400,
+        DEVSTAT_ERROR_ABORTED_COMMAND = 0x800
 } devstat_error_flags;
 /*
  * These types are intended to aid statistics gathering/display programs.
@@ -156,6 +158,8 @@
         int         media_error;
         int         hardware;
         int         illegal_req;
+        int         unit_attention;
+        int         aborted_command;
 } devstat_device_error;
 /*
  * XXX: Next revision should add



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