socsvn commit: r225711 - in
soc2011/oleksandr/oleksandr-head/head/sys: cam dev/ata
dev/usb/storage kern sys
oleksandr at FreeBSD.org
oleksandr at FreeBSD.org
Wed Sep 7 13:44:59 UTC 2011
Author: oleksandr
Date: Wed Sep 7 13:44:57 2011
New Revision: 225711
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=225711
Log:
Edit code in the kernel
Modified:
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/dev/ata/ata-all.c
soc2011/oleksandr/oleksandr-head/head/sys/dev/usb/storage/umass.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 Wed Sep 7 12:53:18 2011 (r225710)
+++ soc2011/oleksandr/oleksandr-head/head/sys/cam/cam_periph.c Wed Sep 7 13:44:57 2011 (r225711)
@@ -1699,109 +1699,109 @@
frozen = (status & CAM_DEV_QFRZN) != 0;
status &= CAM_STATUS_MASK;
openings = relsim_flags = 0;
-
- struct devstat *device_error = NULL;
+
+ struct devstat *device_error = NULL;
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.
- */
- if (status == CAM_SEL_TIMEOUT || status == CAM_SCSI_BUSY ||
- status == CAM_SIM_QUEUED || status == CAM_FUNC_NOTAVAIL ||
- status == CAM_REQ_INVALID || status == CAM_CMD_TIMEOUT)
- error_flag_ret = DEVSTAT_ERROR_RETRIABLE;
- /*
- * If the error is critical 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 || 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.
- */
- if (ccb->ccb_h.flags == CAM_DIR_OUT && 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 && 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 &&
- error_flag_ret != 0)
- error_flag_type = DEVSTAT_ERROR_OTHER_ERROR;
- /*
- * If function code is equal to XPT_SCSI_IO it means that the
- * 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;
- 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_ERROR;
- 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_ERROR;
- break;
- case SSD_KEY_ILLEGAL_REQUEST:
- error_flag_sense = DEVSTAT_ERROR_ILLEGAL_REQUEST;
- 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_ERROR;
- 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_MEDIUM_ERROR;
- if (ccb->ataio.res.error && 0x04)
- error_flag_sense = DEVSTAT_ERROR_ILLEGAL_REQUEST;
- 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 the error is present, search for appropriate structure
- * in devstat and increase the corresponding counters of errors.
- */
- 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 | error_flag_sense);
- }
- }
+ /*
+ * If the error is not critical 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 || status == CAM_CMD_TIMEOUT)
+ error_flag_ret = DEVSTAT_ERROR_RETRIABLE;
+ /*
+ * If the error is critical 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 || 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.
+ */
+ if (ccb->ccb_h.flags == CAM_DIR_OUT && 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 && 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 &&
+ error_flag_ret != 0)
+ error_flag_type = DEVSTAT_ERROR_OTHER_ERROR;
+ /*
+ * If function code is equal to XPT_SCSI_IO it means that the
+ * 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;
+ 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_ERROR;
+ 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_ERROR;
+ break;
+ case SSD_KEY_ILLEGAL_REQUEST:
+ error_flag_sense = DEVSTAT_ERROR_ILLEGAL_REQUEST;
+ 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_ERROR;
+ 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_MEDIUM_ERROR;
+ if (ccb->ataio.res.error && 0x04)
+ error_flag_sense = DEVSTAT_ERROR_ILLEGAL_REQUEST;
+ 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 the error is present, search for appropriate structure
+ * in devstat and increase the corresponding counters of errors.
+ */
+ 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 | error_flag_sense);
+ }
+ }
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 Wed Sep 7 12:53:18 2011 (r225710)
+++ soc2011/oleksandr/oleksandr-head/head/sys/cam/cam_xpt.c Wed Sep 7 13:44:57 2011 (r225711)
@@ -4140,7 +4140,7 @@
xpt_done(union ccb *done_ccb)
{
struct cam_sim *sim;
- int first;
+ int first;
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/dev/ata/ata-all.c
==============================================================================
--- soc2011/oleksandr/oleksandr-head/head/sys/dev/ata/ata-all.c Wed Sep 7 12:53:18 2011 (r225710)
+++ soc2011/oleksandr/oleksandr-head/head/sys/dev/ata/ata-all.c Wed Sep 7 13:44:57 2011 (r225711)
@@ -50,7 +50,6 @@
#include <dev/ata/ata-all.h>
#include <dev/pci/pcivar.h>
#include <ata_if.h>
-#include <sys/fail.h>
#ifdef ATA_CAM
#include <cam/cam.h>
@@ -1554,6 +1553,7 @@
struct ata_channel *ch = device_get_softc(dev);
union ccb *ccb = request->ccb;
int fatalerr = 0;
+
if (ch->requestsense) {
ata_cam_process_sense(dev, request);
return;
Modified: soc2011/oleksandr/oleksandr-head/head/sys/dev/usb/storage/umass.c
==============================================================================
--- soc2011/oleksandr/oleksandr-head/head/sys/dev/usb/storage/umass.c Wed Sep 7 12:53:18 2011 (r225710)
+++ soc2011/oleksandr/oleksandr-head/head/sys/dev/usb/storage/umass.c Wed Sep 7 13:44:57 2011 (r225711)
@@ -120,7 +120,6 @@
#include <sys/callout.h>
#include <sys/malloc.h>
#include <sys/priv.h>
-#include <sys/fail.h>
#include <dev/usb/usb.h>
#include <dev/usb/usbdi.h>
@@ -2551,6 +2550,7 @@
uint8_t status)
{
ccb->csio.resid = residue;
+
switch (status) {
case STATUS_CMD_OK:
ccb->ccb_h.status = CAM_REQ_CMP;
Modified: soc2011/oleksandr/oleksandr-head/head/sys/kern/subr_devstat.c
==============================================================================
--- soc2011/oleksandr/oleksandr-head/head/sys/kern/subr_devstat.c Wed Sep 7 12:53:18 2011 (r225710)
+++ soc2011/oleksandr/oleksandr-head/head/sys/kern/subr_devstat.c Wed Sep 7 13:44:57 2011 (r225711)
@@ -103,7 +103,7 @@
devstat_support_flags flags,
devstat_type_flags device_type,
devstat_priority priority)
-{
+{
struct devstatlist *devstat_head;
struct devstat *ds_tmp;
@@ -201,6 +201,7 @@
devstat_generation++;
mtx_unlock(&devstat_mutex);
}
+
/*
* Search in the devstat desired structure.
*/
@@ -231,6 +232,7 @@
return NULL;
}
}
+
/*
* Record a transaction start.
*
@@ -369,40 +371,41 @@
devstat_end_transaction(ds, bp->bio_bcount - bp->bio_resid,
DEVSTAT_TAG_SIMPLE, flg, NULL, &bp->bio_t0);
}
+
/*
* Increase corresponding counter by unit.
*/
void
devstat_add_error(struct devstat *ds, devstat_error_flags error_flag)
{
- if ((error_flag | DEVSTAT_ERROR_RETRIABLE) == error_flag)
+ if ((error_flag & DEVSTAT_ERROR_RETRIABLE) != 0)
ds->dev_error.retriable++;
- if ((error_flag | DEVSTAT_ERROR_NON_RETRIABLE) == error_flag)
+ if ((error_flag & DEVSTAT_ERROR_NON_RETRIABLE) != 0)
ds->dev_error.non_retriable++;
- if ((error_flag | DEVSTAT_ERROR_WRITE_ERROR) == error_flag)
+ if ((error_flag & DEVSTAT_ERROR_WRITE_ERROR) != 0)
ds->dev_error.write_error++;
- if ((error_flag | DEVSTAT_ERROR_READ_ERROR) == error_flag)
+ if ((error_flag & DEVSTAT_ERROR_READ_ERROR) != 0)
ds->dev_error.read_error++;
- if ((error_flag | DEVSTAT_ERROR_OTHER_ERROR) == error_flag)
+ if ((error_flag & DEVSTAT_ERROR_OTHER_ERROR) != 0)
ds->dev_error.other_error++;
- if ((error_flag | DEVSTAT_ERROR_RECOVERED_ERROR) == error_flag)
+ if ((error_flag & DEVSTAT_ERROR_RECOVERED_ERROR) != 0)
ds->dev_error.recovered++;
- if ((error_flag | DEVSTAT_ERROR_NOT_READY) == error_flag)
+ if ((error_flag & DEVSTAT_ERROR_NOT_READY) != 0)
ds->dev_error.not_ready++;
- if ((error_flag | DEVSTAT_ERROR_MEDIUM_ERROR) == error_flag)
+ if ((error_flag & DEVSTAT_ERROR_MEDIUM_ERROR) != 0)
ds->dev_error.medium_error++;
- if ((error_flag | DEVSTAT_ERROR_HARDWARE_ERROR) == error_flag)
+ if ((error_flag & DEVSTAT_ERROR_HARDWARE_ERROR) != 0)
ds->dev_error.hardware++;
- if ((error_flag | DEVSTAT_ERROR_ILLEGAL_REQUEST) == error_flag)
+ if ((error_flag & DEVSTAT_ERROR_ILLEGAL_REQUEST) != 0)
ds->dev_error.illegal_request++;
- if ((error_flag | DEVSTAT_ERROR_UNIT_ATTENTION) == error_flag)
+ if ((error_flag & DEVSTAT_ERROR_UNIT_ATTENTION) != 0)
ds->dev_error.unit_attention++;
- if ((error_flag | DEVSTAT_ERROR_ABORTED_COMMAND) == error_flag)
+ if ((error_flag & DEVSTAT_ERROR_ABORTED_COMMAND) != 0)
ds->dev_error.aborted_command++;
}
+
/*
* This is the sysctl handler for the devstat package. The data pushed out
-
* on the kern.devstat.all sysctl variable consists of the current devstat
* generation number, and then an array of devstat structures, one for each
* device in the system.
Modified: soc2011/oleksandr/oleksandr-head/head/sys/sys/devicestat.h
==============================================================================
--- soc2011/oleksandr/oleksandr-head/head/sys/sys/devicestat.h Wed Sep 7 12:53:18 2011 (r225710)
+++ soc2011/oleksandr/oleksandr-head/head/sys/sys/devicestat.h Wed Sep 7 13:44:57 2011 (r225711)
@@ -53,7 +53,7 @@
* userland utilities to determine whether or not they are in sync with the
* kernel.
*/
-#define DEVSTAT_VERSION 6
+#define DEVSTAT_VERSION 6
/*
* These flags specify which statistics features are supported or not
@@ -94,23 +94,25 @@
DEVSTAT_PRIORITY_ARRAY = 0x120,
DEVSTAT_PRIORITY_MAX = 0xfff
} devstat_priority;
+
/*
* 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_RECOVERED_ERROR = 0x020,
- DEVSTAT_ERROR_NOT_READY = 0x040,
- DEVSTAT_ERROR_MEDIUM_ERROR = 0x080,
- DEVSTAT_ERROR_HARDWARE_ERROR = 0x100,
- DEVSTAT_ERROR_ILLEGAL_REQUEST = 0x200,
- DEVSTAT_ERROR_UNIT_ATTENTION = 0x400,
- DEVSTAT_ERROR_ABORTED_COMMAND = 0x800
+ 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_ERROR = 0x020,
+ DEVSTAT_ERROR_NOT_READY = 0x040,
+ DEVSTAT_ERROR_MEDIUM_ERROR = 0x080,
+ DEVSTAT_ERROR_HARDWARE_ERROR = 0x100,
+ DEVSTAT_ERROR_ILLEGAL_REQUEST = 0x200,
+ DEVSTAT_ERROR_UNIT_ATTENTION = 0x400,
+ DEVSTAT_ERROR_ABORTED_COMMAND = 0x800
} devstat_error_flags;
+
/*
* These types are intended to aid statistics gathering/display programs.
* The first 13 types (up to the 'target' flag) are identical numerically
@@ -144,23 +146,25 @@
DEVSTAT_TYPE_IF_MASK = 0x0f0,
DEVSTAT_TYPE_PASS = 0x100
} devstat_type_flags;
+
/*
* The structure that contains the disk errors counter.
*/
typedef struct {
- int retriable;
- int non_retriable;
- int read_error;
- int write_error;
- int other_error;
- int recovered;
- int not_ready;
- int medium_error;
- int hardware;
- int illegal_request;
- int unit_attention;
- int aborted_command;
+ int retriable;
+ int non_retriable;
+ int read_error;
+ int write_error;
+ int other_error;
+ int recovered;
+ int not_ready;
+ int medium_error;
+ int hardware;
+ int illegal_request;
+ int unit_attention;
+ int aborted_command;
} devstat_device_error;
+
/*
* XXX: Next revision should add
* off_t offset[DEVSTAT_N_TRANS_FLAGS];
@@ -191,7 +195,7 @@
* Time the device was
* created.
*/
- devstat_device_error dev_error; /* Disk error structure*/
+ devstat_device_error dev_error; /* Disk error structure*/
u_int32_t block_size; /* Block size, bytes */
u_int64_t tag_types[3]; /*
* The number of
@@ -223,6 +227,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_number);
void devstat_remove_entry(struct devstat *ds);
void devstat_start_transaction(struct devstat *ds, struct bintime *now);
More information about the svn-soc-all
mailing list