socsvn commit: r224846 - in soc2011/oleksandr/oleksandr-head/head/sys: cam kern sys

oleksandr at FreeBSD.org oleksandr at FreeBSD.org
Tue Aug 2 16:17:51 UTC 2011


Author: oleksandr
Date: Tue Aug  2 16:17:49 2011
New Revision: 224846
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=224846

Log:
  Change the place where error br detected

Modified:
  soc2011/oleksandr/oleksandr-head/head/sys/cam/cam_ccb.h
  soc2011/oleksandr/oleksandr-head/head/sys/cam/cam_periph.c
  soc2011/oleksandr/oleksandr-head/head/sys/cam/cam_xpt.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_ccb.h
==============================================================================
--- soc2011/oleksandr/oleksandr-head/head/sys/cam/cam_ccb.h	Tue Aug  2 15:35:43 2011	(r224845)
+++ soc2011/oleksandr/oleksandr-head/head/sys/cam/cam_ccb.h	Tue Aug  2 16:17:49 2011	(r224846)
@@ -304,7 +304,6 @@
 					/* Callback on completion function */
 	xpt_opcode	func_code;	/* XPT function code */
 	u_int32_t	status;		/* Status returned by CAM subsystem */
-        u_int32_t       status_test;    /* CAM status for test disk error */
 	struct		cam_path *path;	/* Compiled path for this ccb */
 	path_id_t	path_id;	/* Path ID for the request */
 	target_id_t	target_id;	/* Target device ID */

Modified: soc2011/oleksandr/oleksandr-head/head/sys/cam/cam_periph.c
==============================================================================
--- soc2011/oleksandr/oleksandr-head/head/sys/cam/cam_periph.c	Tue Aug  2 15:35:43 2011	(r224845)
+++ soc2011/oleksandr/oleksandr-head/head/sys/cam/cam_periph.c	Tue Aug  2 16:17:49 2011	(r224846)
@@ -49,6 +49,7 @@
 #include <cam/cam_ccb.h>
 #include <cam/cam_queue.h>
 #include <cam/cam_xpt_periph.h>
+#include <cam/cam_xpt_internal.h>
 #include <cam/cam_periph.h>
 #include <cam/cam_debug.h>
 #include <cam/cam_sim.h>
@@ -1698,7 +1699,54 @@
 	frozen = (status & CAM_DEV_QFRZN) != 0;
 	status &= CAM_STATUS_MASK;
 	openings = relsim_flags = 0;
-
+        
+        struct devstat *device_error = NULL;
+	devstat_error_flags error_flag_ret = 0, error_flag_type = 0;
+        /*
+         * If the error is not fatal refer it to the type of retry able. 
+         */
+        if (status == CAM_SEL_TIMEOUT || status == CAM_SCSI_BUSY ||
+            status == CAM_SIM_QUEUED || status == CAM_FUNC_NOTAVAIL ||
+            status == CAM_REQ_INVALID)
+                error_flag_ret = DEVSTAT_ERROR_RETRIABLE;
+        /*
+         * If the error is fatal refer it to the type of non retry able. 
+         */
+        if (status == CAM_REQ_CMP_ERR || status == CAM_TID_INVALID ||
+            status == CAM_SCSI_STATUS_ERROR || status == CAM_AUTOSENSE_FAIL ||
+            status == CAM_LUN_INVALID) 
+                error_flag_ret = DEVSTAT_ERROR_NON_RETRIABLE;
+        /*
+         * If the error is write error refer it to the type of write error.
+         */
+        if (ccb->ccb_h.flags == CAM_DIR_OUT && status != CAM_REQ_CMP &&
+            error_flag_ret != 0) 
+                error_flag_type = DEVSTAT_ERROR_WRITE_ERROR;
+        /*
+         * If the error is read error refer it to the type of read error
+         */
+        if (ccb->ccb_h.flags == CAM_DIR_IN && status != CAM_REQ_CMP &&
+            error_flag_ret != 0) 
+                error_flag_type = DEVSTAT_ERROR_READ_ERROR;
+        /*
+         * If the request is countrol and there is no action with data                   * refer it to the type of other error.
+         */
+        if ((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_NONE && 
+            status != CAM_REQ_CMP && error_flag_ret != 0) 
+                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.
+         */
+        if (error_flag_ret) {
+               device_error = devstat_search(
+                            ccb->ccb_h.path->periph->periph_name,
+        	            ccb->ccb_h.path->periph->unit_number);
+               if (device_error != NULL) {
+                       devstat_add_error(device_error, 
+                                         error_flag_ret | error_flag_type); 
+               }
+        } 
 	switch (status) {
 	case CAM_REQ_CMP:
 		error = 0;

Modified: soc2011/oleksandr/oleksandr-head/head/sys/cam/cam_xpt.c
==============================================================================
--- soc2011/oleksandr/oleksandr-head/head/sys/cam/cam_xpt.c	Tue Aug  2 15:35:43 2011	(r224845)
+++ soc2011/oleksandr/oleksandr-head/head/sys/cam/cam_xpt.c	Tue Aug  2 16:17:49 2011	(r224846)
@@ -38,7 +38,6 @@
 #include <sys/kernel.h>
 #include <sys/time.h>
 #include <sys/conf.h>
-#include <sys/devicestat.h>
 #include <sys/fcntl.h>
 #include <sys/interrupt.h>
 #include <sys/sbuf.h>
@@ -4142,69 +4141,7 @@
 {
 	struct cam_sim *sim;
         int	first;
-        int     i, num_error = 0;
-        struct devstat *device_error;
-	devstat_error_flags error_flag[NUMBER_TYPE_ERRORS];
-        /*
-         * If the error is fatal refer it to the type of non retry able. 
-         */
-        if (done_ccb->ccb_h.status_test == CAM_REQ_CMP_ERR ||
-            done_ccb->ccb_h.status_test == CAM_TID_INVALID ||
-            done_ccb->ccb_h.status_test == CAM_SCSI_STATUS_ERROR ||
-            done_ccb->ccb_h.status_test == CAM_AUTOSENSE_FAIL ||
-            done_ccb->ccb_h.status_test == CAM_LUN_INVALID) {
-                error_flag[num_error] = DEVSTAT_ERROR_NON_RETRIABLE;
-                num_error++;
-        }
-        /*
-         * If the error is not fatal refer it to the type of retry able. 
-         */
-        if (done_ccb->ccb_h.status_test == CAM_SEL_TIMEOUT ||
-            done_ccb->ccb_h.status_test == CAM_SCSI_BUSY ||
-            done_ccb->ccb_h.status_test == CAM_SIM_QUEUED ||
-            done_ccb->ccb_h.status_test == CAM_FUNC_NOTAVAIL ||
-            done_ccb->ccb_h.status_test == CAM_REQ_INVALID ||
-            done_ccb->ccb_h.status_test == CAM_REQUEUE_REQ) {
-                error_flag[num_error] = DEVSTAT_ERROR_RETRIABLE;
-                num_error++;
-        }
-        /*
-         * If the error is write error refer it to the type of write error.
-         */
-        if (done_ccb->ccb_h.flags == CAM_DIR_OUT &&
-            done_ccb->ccb_h.status_test != CAM_REQ_CMP) {
-                error_flag[num_error] = DEVSTAT_ERROR_WRITE_ERROR;
-                num_error++;
-        }
-        /*
-         * If the error is read error refer it to the type of read error
-         */
-        if (done_ccb->ccb_h.flags == CAM_DIR_IN &&
-            done_ccb->ccb_h.status_test != CAM_REQ_CMP) {
-                error_flag[num_error] = DEVSTAT_ERROR_READ_ERROR;
-                num_error++;
-        }
-        /*
-         * If the request is countrol and there is no action with data                   * refer it to the type of other error.
-         */
-        if (((done_ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_NONE) && 
-             done_ccb->ccb_h.status_test != CAM_REQ_CMP) {
-                error_flag[num_error]=DEVSTAT_ERROR_OTHER_ERROR;
-                num_error++;
-        }
-        /*
-         * If an error is present, search for an appropriate structure 
-         * in devstat and increase the corresponding counter of errors.
-         */
-        for (i = 0 ;i < num_error; i++) {  
-                if (error_flag[i]) { 
-                        device_error = devstat_search(
-                            done_ccb->ccb_h.path->periph->periph_name,
-        	            done_ccb->ccb_h.path->periph->unit_number);
-                        if (device_error != NULL) 
-                                devstat_add_error(device_error, error_flag[i]);
-                }
-        } 
+
 	CAM_DEBUG(done_ccb->ccb_h.path, CAM_DEBUG_TRACE, ("xpt_done\n"));
 	if ((done_ccb->ccb_h.func_code & XPT_FC_QUEUED) != 0) {
 		/*

Modified: soc2011/oleksandr/oleksandr-head/head/sys/kern/subr_devstat.c
==============================================================================
--- soc2011/oleksandr/oleksandr-head/head/sys/kern/subr_devstat.c	Tue Aug  2 15:35:43 2011	(r224845)
+++ soc2011/oleksandr/oleksandr-head/head/sys/kern/subr_devstat.c	Tue Aug  2 16:17:49 2011	(r224846)
@@ -375,15 +375,15 @@
 void 
 devstat_add_error(struct devstat *ds, devstat_error_flags error_flag)
 {
-        if (error_flag == DEVSTAT_ERROR_RETRIABLE) 
+        if ((error_flag | DEVSTAT_ERROR_RETRIABLE) == error_flag) 
                 ds->dev_error.retriable++; 
-        if (error_flag == DEVSTAT_ERROR_NON_RETRIABLE) 
+        if ((error_flag | DEVSTAT_ERROR_NON_RETRIABLE) == error_flag) 
                 ds->dev_error.non_retriable++; 
-        if (error_flag == DEVSTAT_ERROR_WRITE_ERROR) 
+        if ((error_flag | DEVSTAT_ERROR_WRITE_ERROR) == error_flag) 
                 ds->dev_error.write_error++;  
-        if (error_flag == DEVSTAT_ERROR_READ_ERROR) 
+        if ((error_flag | DEVSTAT_ERROR_READ_ERROR) == error_flag) 
                 ds->dev_error.read_error++;
-        if (error_flag == DEVSTAT_ERROR_OTHER_ERROR) 
+        if ((error_flag | DEVSTAT_ERROR_OTHER_ERROR) == error_flag) 
                 ds->dev_error.other_error++;
 }
 /*

Modified: soc2011/oleksandr/oleksandr-head/head/sys/sys/devicestat.h
==============================================================================
--- soc2011/oleksandr/oleksandr-head/head/sys/sys/devicestat.h	Tue Aug  2 15:35:43 2011	(r224845)
+++ soc2011/oleksandr/oleksandr-head/head/sys/sys/devicestat.h	Tue Aug  2 16:17:49 2011	(r224846)
@@ -54,7 +54,6 @@
  * kernel.
  */
 #define DEVSTAT_VERSION	     6
-#define NUMBER_TYPE_ERRORS   2
 
 /*
  * These flags specify which statistics features are supported or not
@@ -101,9 +100,9 @@
 typedef enum {
         DEVSTAT_ERROR_RETRIABLE     = 0x01,
         DEVSTAT_ERROR_NON_RETRIABLE = 0x02,
-        DEVSTAT_ERROR_READ_ERROR    = 0x03, 
-        DEVSTAT_ERROR_WRITE_ERROR   = 0x04,
-        DEVSTAT_ERROR_OTHER_ERROR   = 0x05
+        DEVSTAT_ERROR_READ_ERROR    = 0x04, 
+        DEVSTAT_ERROR_WRITE_ERROR   = 0x08,
+        DEVSTAT_ERROR_OTHER_ERROR   = 0x10
 } devstat_error_flags;
 /*
  * These types are intended to aid statistics gathering/display programs.


More information about the svn-soc-all mailing list