From owner-svn-soc-all@FreeBSD.ORG Wed Aug 17 12:32:29 2011 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 50C3C1065672 for ; Wed, 17 Aug 2011 12:32:27 +0000 (UTC) (envelope-from oleksandr@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Wed, 17 Aug 2011 12:32:27 +0000 Date: Wed, 17 Aug 2011 12:32:27 +0000 From: oleksandr@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20110817123227.50C3C1065672@hub.freebsd.org> Cc: Subject: socsvn commit: r225189 - soc2011/oleksandr/oleksandr-head/head/sys/cam X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Aug 2011 12:32:29 -0000 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,