/usr/share/systemtap/tapset/scsi.stp is in systemtap-common 1.6-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 | // scsi tapset
// Copyright (C) 2005, 2006, 2009 IBM Corp.
// Copyright (C) 2010 Red Hat
//
// This file is part of systemtap, and is free software. You can
// redistribute it and/or modify it under the terms of the GNU General
// Public License (GPL); either version 2, or (at your option) any
// later version.
// <tapsetdescription>
// This family of probe points is used to probe SCSI activities.
// </tapsetdescription>
%{
#include <linux/types.h>
#include <scsi/scsi_cmnd.h>
#include <scsi/scsi_device.h>
#include <scsi/scsi_host.h>
#include <linux/timer.h>
#include <linux/blkdev.h>
%}
function describe_data_direction:string(state:long)
%{ /* pure */
switch ((long)THIS->state) {
case DMA_BIDIRECTIONAL: strlcpy(THIS->__retvalue, "BIDIRECTIONAL", MAXSTRINGLEN); break;
case DMA_TO_DEVICE: strlcpy(THIS->__retvalue, "TO_DEVICE", MAXSTRINGLEN); break;
case DMA_FROM_DEVICE: strlcpy(THIS->__retvalue, "FROM_DEVICE", MAXSTRINGLEN); break;
case DMA_NONE: strlcpy(THIS->__retvalue, "NONE", MAXSTRINGLEN); break;
default: strlcpy(THIS->__retvalue, "[INVALID]", MAXSTRINGLEN);
}
%}
function describe_device_state:string(state:long)
%{ /* pure */
switch ((long)THIS->state) {
case SDEV_CREATED: strlcpy(THIS->__retvalue, "CREATED", MAXSTRINGLEN); break;
case SDEV_RUNNING: strlcpy(THIS->__retvalue, "RUNNING", MAXSTRINGLEN); break;
case SDEV_CANCEL: strlcpy(THIS->__retvalue, "CANCEL", MAXSTRINGLEN); break;
case SDEV_DEL: strlcpy(THIS->__retvalue, "DEL", MAXSTRINGLEN); break;
case SDEV_QUIESCE: strlcpy(THIS->__retvalue, "QUIESCE", MAXSTRINGLEN); break;
case SDEV_OFFLINE: strlcpy(THIS->__retvalue, "OFFLINE", MAXSTRINGLEN); break;
#ifdef SDEV_BLOCK
case SDEV_BLOCK: strlcpy(THIS->__retvalue, "BLOCK", MAXSTRINGLEN); break;
#endif
#ifdef SDEV_CREATED_BLOCK
case SDEV_CREATED_BLOCK: strlcpy(THIS->__retvalue, "CREATED_BLOCK", MAXSTRINGLEN); break;
#endif
default: strlcpy(THIS->__retvalue, "[INVALID]", MAXSTRINGLEN);
}
%}
/**
* probe scsi.ioentry - Prepares a SCSI mid-layer request
* @disk_major: The major number of the disk (-1 if no information)
* @disk_minor: The minor number of the disk (-1 if no information)
* @device_state: The current state of the device
* @device_state_str: The current state of the device, as a string
* @req_addr: The current struct request pointer, as a number
*/
probe scsi.ioentry.scsilib =
module("scsi_mod").function("scsi_prep_fn")!, kernel.function("scsi_prep_fn") { }
probe scsi.ioentry.sd =
module("sd_mod").function("sd_prep_fn")!, kernel.function("sd_prep_fn") { }
probe scsi.ioentry.sr =
module("sr_mod").function("sr_prep_fn")!, kernel.function("sr_prep_fn") { }
probe scsi.ioentry = scsi.ioentry.* ?
{
req_addr = @defined($req) ? $req : $rq;
if(@cast(req_addr,"request")->rq_disk == 0) {
disk_major = -1
disk_minor = -1
} else {
disk_major = @cast(req_addr,"request")->rq_disk->major
disk_minor = @cast(req_addr,"request")->rq_disk->first_minor
}
device_state = get_devstate_from_req($q)
device_state_str = describe_device_state(device_state)
}
/**
* probe scsi.iodispatching - SCSI mid-layer dispatched low-level SCSI command
* @host_no: The host number
* @channel: The channel number
* @lun: The lun number
* @dev_id: The scsi device id
* @device_state: The current state of the device
* @device_state_str: The current state of the device, as a string
* @data_direction: The data_direction specifies whether this command is from/to the device
* 0 (DMA_BIDIRECTIONAL), 1 (DMA_TO_DEVICE),
* 2 (DMA_FROM_DEVICE), 3 (DMA_NONE)
* @data_direction_str: Data direction, as a string
* @request_buffer: The request buffer address
* @request_bufflen: The request buffer length
* @req_addr: The current struct request pointer, as a number
*/
probe scsi.iodispatching
= module("scsi_mod").function("scsi_dispatch_cmd@drivers/scsi/scsi.c")!,
kernel.function("scsi_dispatch_cmd@drivers/scsi/scsi.c")?
{
host_no = $cmd->device->host->host_no
channel = $cmd->device->channel
lun = $cmd->device->lun
dev_id = $cmd->device->id
device_state = $cmd->device->sdev_state
device_state_str = describe_device_state(device_state)
data_direction = $cmd->sc_data_direction
data_direction_str = describe_data_direction(data_direction)
request_buffer = (@defined($cmd->sdb->table->sgl)
? $cmd->sdb->table->sgl : $cmd->request_buffer)
request_bufflen = (@defined($cmd->sdb->length)
? $cmd->sdb->length : $cmd->request_bufflen)
req_addr = $cmd->request
}
/**
* probe scsi.iodone - SCSI command completed by low level driver and enqueued into the done queue.
* @host_no: The host number
* @channel: The channel number
* @lun: The lun number
* @dev_id: The scsi device id
* @device_state: The current state of the device
* @device_state_str: The current state of the device, as a string
* @data_direction: The data_direction specifies whether this command is
* from/to the device.
* @data_direction_str: Data direction, as a string
* @req_addr: The current struct request pointer, as a number
* @scsi_timer_pending: 1 if a timer is pending on this request
*/
probe scsi.iodone
= module("scsi_mod").function("scsi_done@drivers/scsi/scsi.c")!,
kernel.function("scsi_done@drivers/scsi/scsi.c")?
{
host_no = $cmd->device->host->host_no
channel = $cmd->device->channel
lun = $cmd->device->lun
dev_id = $cmd->device->id
device_state = $cmd->device->sdev_state
device_state_str = describe_device_state(device_state)
data_direction = $cmd->sc_data_direction
data_direction_str = describe_data_direction(data_direction)
req_addr = $cmd->request
scsi_timer_pending = scsi_timer_pending($cmd);
}
/**
* probe scsi.iocompleted - SCSI mid-layer running the completion processing for block device I/O requests
* @host_no: The host number
* @channel: The channel number
* @lun: The lun number
* @dev_id: The scsi device id
* @device_state: The current state of the device
* @device_state_str: The current state of the device, as a string
* @data_direction: The data_direction specifies whether this command is from/to
* the device
* @data_direction_str: Data direction, as a string
* @goodbytes: The bytes completed
* @req_addr: The current struct request pointer, as a number
*/
// mid-layer processes the completed IO
probe scsi.iocompleted
= module("scsi_mod").function("scsi_io_completion@drivers/scsi/scsi_lib.c")!,
kernel.function("scsi_io_completion@drivers/scsi/scsi_lib.c")?
{
host_no = $cmd->device->host->host_no
channel = $cmd->device->channel
lun = $cmd->device->lun
dev_id = $cmd->device->id
device_state = $cmd->device->sdev_state
device_state_str = describe_device_state(device_state)
data_direction = $cmd->sc_data_direction
data_direction_str = describe_data_direction(data_direction)
req_addr = $cmd->request
goodbytes = $good_bytes
}
function timer_pending:long(timer:long)
{
return (@defined(@cast(timer, "timer_list")->entry->next)
? (@cast(timer, "timer_list")->entry->next != 0)
: (@cast(timer, "timer_list")->base != 0))
}
function scsi_timer_pending:long(cmd:long)
{
%( kernel_v >= "2.6.28" %?
return timer_pending(&@cast(cmd, "scsi_cmnd", "kernel:scsi_mod")->request->q->timeout)
%:
return timer_pending(&@cast(cmd, "scsi_cmnd", "kernel:scsi_mod")->eh_timeout)
%)
}
function get_devstate_from_req:long(var:long)
{
sdev = @cast(var, "request_queue", "kernel:scsi_mod")->queuedata
return @cast(sdev, "scsi_device", "kernel:scsi_mod")->sdev_state
}
/**
* probe scsi.ioexecute - Create mid-layer SCSI request and wait for the result
* @host_no: The host number
* @channel: The channel number
* @lun: The lun number
* @dev_id: The scsi device id
* @device_state: The current state of the device
* @device_state_str: The current state of the device, as a string
* @data_direction: The data_direction specifies whether this command is
* from/to the device.
* @data_direction_str: Data direction, as a string
* @request_buffer: The data buffer address
* @request_bufflen: The data buffer buffer length
* @timeout: Request timeout in seconds
* @retries: Number of times to retry request
*/
probe scsi.ioexecute
= module("scsi_mod").function("scsi_execute@drivers/scsi/scsi_lib.c")!,
kernel.function("scsi_execute@drivers/scsi/scsi_lib.c")?
{
host_no = $sdev->host->host_no
channel = $sdev->channel
lun = $sdev->lun
dev_id = $sdev->id
device_state = $sdev->sdev_state
device_state_str = describe_device_state(device_state)
data_direction = $data_direction
data_direction_str = describe_data_direction(data_direction)
request_buffer = $buffer
request_bufflen = $bufflen
timeout = $timeout
retries = $retries
}
/**
* probe scsi.set_state - Order SCSI device state change
* @host_no: The host number
* @channel: The channel number
* @lun: The lun number
* @dev_id: The scsi device id
* @old_state: The current state of the device
* @old_state_str: The current state of the device, as a string
* @state: The new state of the device
* @state_str: The new state of the device, as a string
*/
probe scsi.set_state
= module("scsi_mod").function("scsi_device_set_state@drivers/scsi/scsi_lib.c")!,
kernel.function("scsi_device_set_state@drivers/scsi/scsi_lib.c")?
{
state = $state
state_str = describe_device_state(state)
host_no = $sdev->host->host_no
channel = $sdev->channel
lun = $sdev->lun
dev_id = $sdev->id
old_state = $sdev->sdev_state
old_state_str = describe_device_state(old_state)
}
|