szaydel
3/9/2015 - 1:21 PM

sd and mptsas mdb snippets

sd and mptsas mdb snippets

# Basic example for setting values vi /etc/system on Solaris and related OSs.
set sd:sd_component_mask=0x7e0e13
set sd:sd_level_mask=0x18

# Specific to bsros...
# Verbose logging, should be basically trace logging, set these with mdb.
sd_logging_enabled=1
sd_component_mask=0x4f0e1f
sd_level_mask=0x1f

mdb -kw -e 'sd_logging_enabled/W0x1'
mdb -kw -e 'sd_component_mask/W0x4f0e1f'
mdb -kw -e 'sd_level_mask/W0x1f'

# Try to only catch events which might be associated with faults.
mdb -kw -e 'sd_component_mask/W0x20202'
mdb -kw -e 'sd_level_mask/W0x1f'
To modify bitmasks for power-management support and other settings via mdb in members of sd_lun structures we need to do this.

Locate all the addresses where changes are required

This is for pm supported bits
> ::walk sd_state | ::grep '. != 0' |::print -ta struct sd_lun un_f_pm_supported

This is for pm enabled bits
> ::walk sd_state | ::grep '. != 0' |::print -ta struct sd_lun un_f_pm_is_enabled

For each address, print out value stored at the address
> 0xffffff4320483bef/X
0xffffff4320483bef:             800c904c

Convert the hex value to binary and flip the bits that should be flipped, counting from right to left, right bit is least significant.

Convert resulting binary back to hex. This is a simple python function to do it.

def bin2hex(n): # n should be a binary number with the `0b` prefix removed.
    return hex(int(n, 2))

Next, set the value with mdb. Mdb must be in write-enabled mode to do this, otherwise you will receive an error.

> 0xffffff4320483bef/W0x800c904c

It is possible to do this without being in mdb, directly from command line.
# echo 0xffffff4320483bef/W0x800c904c | mdb -kw
# Walk the sd_state and extract output of scsi inquiry for each vid/pid.
echo "::walk sd_state | ::grep '.!=0' | ::print struct sd_lun un_sd | \
        ::print struct scsi_device sd_inq | ::print struct scsi_inquiry \
        inq_vid inq_pid" | mdb -k

# Same as above, but directly from mdb.
::walk sd_state | ::grep '. != 0' | ::print -ta struct sd_lun un_sd | ::print -ta struct scsi_device | ::print -ta struct scsi_inquiry inq_pid inq_vid

# Per device dev_info structs.
::walk sd_state | ::grep '.!=0' | ::print struct sd_lun un_sd | ::print struct scsi_device sd_dev | ::print struct dev_info

# Get key tunables like command timeouts, limits on queue size, etc.
::walk sd_state | ::grep ".!=0" | ::print -ta struct sd_lun un_max_xfer_size un_f_disksort_disabled un_f_write_cache_enabled un_saved_throttle un_throttle un_reset_retry_count un_retry_count un_busy_retry_count un_notready_retry_count un_busy_timeout un_cmd_timeout un_uscsi_timeout

# Power-management related bits from command line, instead of invoking mdb.
echo "::walk sd_state | ::grep '. != 0'|::print -ta struct sd_lun un_f_pm_log_sense_smart un_f_pm_is_enabled un_f_pm_supported un_f_power_condition_disabled un_f_power_condition_supported" | mdb -k

# How busy devices are, i.e. queue size
::walk sd_state | ::grep ".!=0" | ::print -ta struct sd_lun un_ncmds_in_driver un_ncmds_in_transport

# Get device instance numbers and other information about devices
::walk sd_state | ::grep '.!=0' | ::print struct sd_lun un_sd | ::print struct scsi_device sd_dev | ::devinfo -s

# Get detailed device information for particular SCSI device, like STEC in this example. The address is of the sd_lun struct.
fffffea3574c5700::print struct sd_lun un_sd|::print struct scsi_device sd_dev|::devinfo

# Get devinfo addresses for associated devinfo nodes
0xfffffea38756a340::print struct sd_lun un_sd|::print struct scsi_device sd_dev|::walk devinfo

# Get information about open(s) for each sd_lun
::walk sd_state|::grep '. != 0'|::print -ta struct sd_lun un_ocmap | ::print -ta union ocmap rinfo|::print -ta struct ocinfo reg_open
::walk sd_state|::grep '. != 0'|::print -ta struct sd_lun un_ocmap.rinfo.reg_open
# For all sd instances obtain snode(s) and convert to vnode_t(s) and obtain v_count, which tells us how many holds there are.
0x53::major2snode|::print struct snode s_vnode | ::print -ta vnode_t v_count