socsvn commit: r224268 - soc2011/oleksandr/oleksandr-head/head/sys/cam

oleksandr at FreeBSD.org oleksandr at FreeBSD.org
Fri Jul 15 11:21:18 UTC 2011


Author: oleksandr
Date: Fri Jul 15 11:21:16 2011
New Revision: 224268
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=224268

Log:
  Add new type of error: read and write

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

Modified: soc2011/oleksandr/oleksandr-head/head/sys/cam/cam_xpt.c
==============================================================================
--- soc2011/oleksandr/oleksandr-head/head/sys/cam/cam_xpt.c	Fri Jul 15 11:15:57 2011	(r224267)
+++ soc2011/oleksandr/oleksandr-head/head/sys/cam/cam_xpt.c	Fri Jul 15 11:21:16 2011	(r224268)
@@ -4142,8 +4142,9 @@
 {
 	struct cam_sim *sim;
         int	first;
+        int     i,num_error=0;
         struct devstat *device_error;
-	devstat_error_flags error_flag=0;
+	devstat_error_flags error_flag[NUMBER_TYPE_ERRORS];
         /*
          * If the error is fatal refer it to the type of non retry able. 
          */
@@ -4152,7 +4153,8 @@
             (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=DEVSTAT_ERROR_NON_RETRIABLE;
+                error_flag[num_error]=DEVSTAT_ERROR_NON_RETRIABLE;
+                num_error++;
         }
         /*
          * If the error is not fatal refer it to the type of retry able. 
@@ -4163,23 +4165,38 @@
             (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=DEVSTAT_ERROR_RETRIABLE;
+                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 an error is present, search for an appropriate structure 
          * in devstat and increase the corresponding counter of errors.
          */
-        if (error_flag) {
-             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_start_transaction(device_error, NULL);
-               devstat_add_error(device_error, error_flag);
-               devstat_end_transaction(device_error,done_ccb->csio.dxfer_len,
-                   DEVSTAT_TAG_ORDERED,DEVSTAT_WRITE, NULL, NULL);
-            }
-        }
+        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) {
 		/*


More information about the svn-soc-all mailing list