diff options
Diffstat (limited to 'systemtap/discard/test.stap')
-rw-r--r-- | systemtap/discard/test.stap | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/systemtap/discard/test.stap b/systemtap/discard/test.stap new file mode 100644 index 0000000..2202ba5 --- /dev/null +++ b/systemtap/discard/test.stap @@ -0,0 +1,54 @@ + +function timestamp:string() { + printf("[%012ld]\t", jiffies()); +} + +// Filesystem level (ext4) +probe module("ext4").function("ext4_issue_discard") { + timestamp(); + printf("ext4_issue_discard dev=%s block_group=%u cluster=%d count=%d (=> *8 nr_sects=%d)\n", + bdevname($sb->s_bdev), + $block_group, $cluster, $count, $count * 8); +} + +// Block-Device level (disk-mapper) +probe kernel.function("blkdev_issue_discard") { + timestamp(); + printf("blkdev_issue_discard dev=%s sector=%u nr_sects=%u\n", + bdevname($bdev), $sector, $nr_sects); +} + +// SCSI-Command +probe scsi.iodispatching { + // drivers/scsi/sd.c:scsi_setup_discard_cmnd() + if ($cmd->cmd_len >= 16 + && $cmd->cmnd[0] == 0x93 /* WRITE_SAME_16 */ + && $cmd->cmnd[1] == 0x08 /* UNMAP */) { + + timestamp(); + printf("SCSI [WRITE_SAME_16, UNMAP, sector, count] "); + + sector = ( ($cmd->cmnd[2] << 56) + + ($cmd->cmnd[3] << 48) + + ($cmd->cmnd[4] << 40) + + ($cmd->cmnd[5] << 32) + + ($cmd->cmnd[6] << 24) + + ($cmd->cmnd[7] << 16) + + ($cmd->cmnd[8] << 8) + + ($cmd->cmnd[9]) ); + + // Substract partition start position (fdisk: 22464512) + Crypto overhead (4096 sectors) + sector = sector - 22468608; + + // Number of sectors (count) + nr_sects = ( ($cmd->cmnd[10] << 24) + + ($cmd->cmnd[11] << 16) + + ($cmd->cmnd[12] << 8) + + ($cmd->cmnd[13]) ); + + printf("state=%s direction=%s dev=%u:%u:%u:%u sector=%u nr_sects=%u\n", + device_state_str, data_direction_str, host_no, channel, lun, dev_id, + sector, nr_sects); + } +} + |