Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 16 Aug 2011 22:13:07 +0000
From:      oleksandr@FreeBSD.org
To:        svn-soc-all@FreeBSD.org
Subject:   socsvn commit: r225169 - in soc2011/oleksandr/oleksandr-head/head/sys: cam kern sys
Message-ID:  <20110816221307.E8693106564A@hub.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: oleksandr
Date: Tue Aug 16 22:13:07 2011
New Revision: 225169
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=225169

Log:
  Review the type of errors

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	Tue Aug 16 21:51:29 2011	(r225168)
+++ soc2011/oleksandr/oleksandr-head/head/sys/cam/cam_periph.c	Tue Aug 16 22:13:07 2011	(r225169)
@@ -1701,7 +1701,8 @@
 	openings = relsim_flags = 0;
         
         struct devstat *device_error = NULL;
-	devstat_error_flags error_flag_ret = 0, error_flag_type = 0;
+	devstat_error_flags error_flag_ret = 0, error_flag_type = 0,
+                            error_flag_sense = 0;
         /*
          * If the error is not critical refer it to the type of retry able. 
          */
@@ -1732,17 +1733,30 @@
          */
         if ((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_NONE && 
             error_flag_ret != 0) 
-                error_flag_type=DEVSTAT_ERROR_OTHER_ERROR;
+                error_flag_type = DEVSTAT_ERROR_OTHER_ERROR;
         /*
          * 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,
         	            ccb->ccb_h.path->periph->unit_number)) != NULL) {
-                       devstat_add_error(device_error, 
-                                         error_flag_ret | error_flag_type); 
+                       devstat_add_error(device_error, error_flag_ret | 
+                                         error_flag_type | error_flag_sense); 
                }
         } 
 	switch (status) {

Modified: soc2011/oleksandr/oleksandr-head/head/sys/kern/subr_devstat.c
==============================================================================
--- soc2011/oleksandr/oleksandr-head/head/sys/kern/subr_devstat.c	Tue Aug 16 21:51:29 2011	(r225168)
+++ soc2011/oleksandr/oleksandr-head/head/sys/kern/subr_devstat.c	Tue Aug 16 22:13:07 2011	(r225169)
@@ -385,6 +385,16 @@
                 ds->dev_error.read_error++;
         if ((error_flag | DEVSTAT_ERROR_OTHER_ERROR) == error_flag) 
                 ds->dev_error.other_error++;
+        if ((error_flag | DEVSTAT_ERROR_RECOVERED) == error_flag)
+                ds->dev_error.recovered++;
+        if ((error_flag | DEVSTAT_ERROR_NOT_READY) == error_flag)
+                ds->dev_error.not_ready++;
+        if ((error_flag | DEVSTAT_ERROR_MEDIUM_ERROR) == error_flag)
+                ds->dev_error.medium_error++;
+        if ((error_flag | DEVSTAT_ERROR_HARDWARE) == error_flag)
+                ds->dev_error.hardware++;
+        if ((error_flag | DEVSTAT_ERROR_ILLEGAL_REQ) == error_flag)
+                ds->dev_error.illegal_req++;
 }
 /*
  * 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	Tue Aug 16 21:51:29 2011	(r225168)
+++ soc2011/oleksandr/oleksandr-head/head/sys/sys/devicestat.h	Tue Aug 16 22:13:07 2011	(r225169)
@@ -98,11 +98,16 @@
  * These flags indicates the type of disk error.
  */
 typedef enum {
-        DEVSTAT_ERROR_RETRIABLE     = 0x01,
-        DEVSTAT_ERROR_NON_RETRIABLE = 0x02,
-        DEVSTAT_ERROR_READ_ERROR    = 0x04, 
-        DEVSTAT_ERROR_WRITE_ERROR   = 0x08,
-        DEVSTAT_ERROR_OTHER_ERROR   = 0x10
+        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_RECOVERED     = 0x020,
+        DEVSTAT_ERROR_NOT_READY     = 0x040,
+        DEVSTAT_ERROR_MEDIUM_ERROR  = 0x080,
+        DEVSTAT_ERROR_HARDWARE      = 0x100,
+        DEVSTAT_ERROR_ILLEGAL_REQ   = 0x200
 } devstat_error_flags;
 /*
  * These types are intended to aid statistics gathering/display programs.
@@ -146,6 +151,11 @@
         int         read_error;
         int         write_error;
         int         other_error;
+        int         recovered;
+        int         not_ready;
+        int         medium_error;
+        int         hardware;
+        int         illegal_req;
 } devstat_device_error;
 /*
  * XXX: Next revision should add
@@ -209,7 +219,7 @@
 				  devstat_support_flags flags,
 				  devstat_type_flags device_type,
 				  devstat_priority priority);
-struct devstat *devstat_search(const char *dev_name, u_int32_t unit_namber);
+struct devstat *devstat_search(const char *dev_name, u_int32_t unit_number);
 void devstat_remove_entry(struct devstat *ds);
 void devstat_start_transaction(struct devstat *ds, struct bintime *now);
 void devstat_start_transaction_bio(struct devstat *ds, struct bio *bp);



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