per-entity statistics
Martin Peschke
mp3@de.ibm.com
Thu Jan 12 16:46:00 GMT 2006
Jose R. Santos wrote:
> Unless you only have a single SCSI card with just one channel, just
> getting the LUN is not enough. You need the SCSI host number, channel,
> lun, and ID. Here is a bit of code from the trace tool that shows how to
> get that information using SystemTap.
>
> function log_scsi_iodone_extra(var:long)
> %{
> struct scsi_cmnd *cmd = (struct scsi_cmnd *)((long)THIS->var);
> long long scsi_info;
>
> scsi_info = ((cmd->device->host->host_no & 0xFF) << 24) |
> ((cmd->device->channel & 0xFF) << 16) |
> ((cmd->device->lun & 0xFF) << 8) |
> (cmd->device->id & 0xFF);
Well, it is obvious why you have masked, shifted and or'ed
thoses numbers. But one might get easily in trouble doing this.
Think about storage area networks and lots of devices being
attached to a single Linux. For now this code works in
most environments because the Linux SCSI stack does its
own compact LUN enumeration. But it's not airtight.
Martin
More information about the Systemtap
mailing list