Dtrace snippets for gathering information from SD driver
dtrace -qn '
BEGIN {
state[0] = "SD_READY_VALID"; /* normal case, we ignore it */
state[1] = "SD_NOT_READY_VALID"; /* no label, but valid device? */
state[2] = "SD_RESERVED_BY_OTHERS"; /* reservation conflict */
}
::sd_ready_and_valid:entry {
self->un = args[0]->ssc_un;
}
/*
* If this is a case where function returns a non-zero value, we are dealing
* with a device which is not ready in some form. This could be a device which
* was removed from the system physically, or had power cut to the bay, or is
* in some faulted state and .
*/
::sd_ready_and_valid:return /args[1] != 0/ {
this->devptr =
(struct dev_info *)self->un->un_sd->sd_dev; /* dev_info structure */
this->inq = self->un->un_sd->sd_inq; /* device inquiry structure */
this->pid = stringof(this->inq->inq_pid); /* no printed atm */
this->vid = stringof(this->inq->inq_vid);
this->serial = stringof(this->inq->inq_serial);
this->devn = stringof(this->devptr->devi_devid_str);
this->rc = state[args[1]];
printf("%s %s %s %s\n",
this->devn, this->vid, this->serial, this->rc);
}'
dtrace -qn '
/*
* All Reads and Writes go through this function, so it is a convenient
* place to measure how much of the data resulted in an error being raised.
*/
BEGIN { start = timestamp ; }
::bioerror:entry /args[0]->b_flags&B_READ
&& (args[0]->b_flags&B_ERROR || args[0]->b_error != NULL)/ {
printf("[R] Offset: %d Device: %d Error: %d\n",
args[0]->b_offset, args[0]->b_edev, args[0]->b_error) ;
@rerrkb = sum(args[0]->b_bcount >> 10) ;
}
::bioerror:entry /args[0]->b_flags&B_WRITE
&& (args[0]->b_flags&B_ERROR || args[0]->b_error != NULL)/ {
printf("[W] Offset: %d Device: %d Error: %d\n",
args[0]->b_offset, args[0]->b_edev, args[0]->b_error) ;
@werrkb = sum(args[0]->b_bcount >> 10) ;
}
END {
printa("RerrKB: %@d WerrKB: %@d\n", @rerrkb, @werrkb) ;
exit(0) ;
}'