aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorKei Tokunaga <tokunaga.keiich@jp.fujitsu.com>2010-04-01 07:41:40 -0400
committerJames Bottomley <James.Bottomley@suse.de>2010-04-30 13:51:10 -0400
commitbf81623542332bc2cedf3db49cbb2edb724780d2 (patch)
tree47e4b784fefd533251b58ae1c2d8c8d280242bcf /drivers
parent5a2e3995951176e1aaa63d17ae2e1d26ac99003d (diff)
[SCSI] add scsi trace core functions and put trace points
Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com> Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@jp.fujitsu.com> Signed-off-by: Kei Tokunaga <tokunaga.keiich@jp.fujitsu.com> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/scsi/Makefile1
-rw-r--r--drivers/scsi/scsi.c6
-rw-r--r--drivers/scsi/scsi_error.c4
-rw-r--r--drivers/scsi/scsi_trace.c185
4 files changed, 196 insertions, 0 deletions
diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile
index 92a8c500b23d..1c7ac49be649 100644
--- a/drivers/scsi/Makefile
+++ b/drivers/scsi/Makefile
@@ -162,6 +162,7 @@ scsi_mod-y += scsi_scan.o scsi_sysfs.o scsi_devinfo.o
162scsi_mod-$(CONFIG_SCSI_NETLINK) += scsi_netlink.o 162scsi_mod-$(CONFIG_SCSI_NETLINK) += scsi_netlink.o
163scsi_mod-$(CONFIG_SYSCTL) += scsi_sysctl.o 163scsi_mod-$(CONFIG_SYSCTL) += scsi_sysctl.o
164scsi_mod-$(CONFIG_SCSI_PROC_FS) += scsi_proc.o 164scsi_mod-$(CONFIG_SCSI_PROC_FS) += scsi_proc.o
165scsi_mod-y += scsi_trace.o
165 166
166scsi_tgt-y += scsi_tgt_lib.o scsi_tgt_if.o 167scsi_tgt-y += scsi_tgt_lib.o scsi_tgt_if.o
167 168
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index 1c08f6164658..ad0ed212db4a 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -67,6 +67,9 @@
67#include "scsi_priv.h" 67#include "scsi_priv.h"
68#include "scsi_logging.h" 68#include "scsi_logging.h"
69 69
70#define CREATE_TRACE_POINTS
71#include <trace/events/scsi.h>
72
70static void scsi_done(struct scsi_cmnd *cmd); 73static void scsi_done(struct scsi_cmnd *cmd);
71 74
72/* 75/*
@@ -747,10 +750,12 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
747 cmd->result = (DID_NO_CONNECT << 16); 750 cmd->result = (DID_NO_CONNECT << 16);
748 scsi_done(cmd); 751 scsi_done(cmd);
749 } else { 752 } else {
753 trace_scsi_dispatch_cmd_start(cmd);
750 rtn = host->hostt->queuecommand(cmd, scsi_done); 754 rtn = host->hostt->queuecommand(cmd, scsi_done);
751 } 755 }
752 spin_unlock_irqrestore(host->host_lock, flags); 756 spin_unlock_irqrestore(host->host_lock, flags);
753 if (rtn) { 757 if (rtn) {
758 trace_scsi_dispatch_cmd_error(cmd, rtn);
754 if (rtn != SCSI_MLQUEUE_DEVICE_BUSY && 759 if (rtn != SCSI_MLQUEUE_DEVICE_BUSY &&
755 rtn != SCSI_MLQUEUE_TARGET_BUSY) 760 rtn != SCSI_MLQUEUE_TARGET_BUSY)
756 rtn = SCSI_MLQUEUE_HOST_BUSY; 761 rtn = SCSI_MLQUEUE_HOST_BUSY;
@@ -781,6 +786,7 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
781 */ 786 */
782static void scsi_done(struct scsi_cmnd *cmd) 787static void scsi_done(struct scsi_cmnd *cmd)
783{ 788{
789 trace_scsi_dispatch_cmd_done(cmd);
784 blk_complete_request(cmd->request); 790 blk_complete_request(cmd->request);
785} 791}
786 792
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index 33175974b55a..f31d868f9362 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -39,6 +39,8 @@
39#include "scsi_logging.h" 39#include "scsi_logging.h"
40#include "scsi_transport_api.h" 40#include "scsi_transport_api.h"
41 41
42#include <trace/events/scsi.h>
43
42#define SENSE_TIMEOUT (10*HZ) 44#define SENSE_TIMEOUT (10*HZ)
43 45
44/* 46/*
@@ -52,6 +54,7 @@
52void scsi_eh_wakeup(struct Scsi_Host *shost) 54void scsi_eh_wakeup(struct Scsi_Host *shost)
53{ 55{
54 if (shost->host_busy == shost->host_failed) { 56 if (shost->host_busy == shost->host_failed) {
57 trace_scsi_eh_wakeup(shost);
55 wake_up_process(shost->ehandler); 58 wake_up_process(shost->ehandler);
56 SCSI_LOG_ERROR_RECOVERY(5, 59 SCSI_LOG_ERROR_RECOVERY(5,
57 printk("Waking error handler thread\n")); 60 printk("Waking error handler thread\n"));
@@ -127,6 +130,7 @@ enum blk_eh_timer_return scsi_times_out(struct request *req)
127 struct scsi_cmnd *scmd = req->special; 130 struct scsi_cmnd *scmd = req->special;
128 enum blk_eh_timer_return rtn = BLK_EH_NOT_HANDLED; 131 enum blk_eh_timer_return rtn = BLK_EH_NOT_HANDLED;
129 132
133 trace_scsi_dispatch_cmd_timeout(scmd);
130 scsi_log_completion(scmd, TIMEOUT_ERROR); 134 scsi_log_completion(scmd, TIMEOUT_ERROR);
131 135
132 if (scmd->device->host->transportt->eh_timed_out) 136 if (scmd->device->host->transportt->eh_timed_out)
diff --git a/drivers/scsi/scsi_trace.c b/drivers/scsi/scsi_trace.c
new file mode 100644
index 000000000000..9a3342a2fa36
--- /dev/null
+++ b/drivers/scsi/scsi_trace.c
@@ -0,0 +1,185 @@
1/*
2 * Copyright (C) 2010 FUJITSU LIMITED
3 * Copyright (C) 2010 Tomohiro Kusumi <kusumi.tomohiro@jp.fujitsu.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18#include <linux/kernel.h>
19#include <linux/trace_seq.h>
20#include <trace/events/scsi.h>
21
22#define SERVICE_ACTION(cdb) ((cdb[8] << 8) | cdb[9])
23
24static const char *
25scsi_trace_misc(struct trace_seq *, unsigned char *, int);
26
27static const char *
28scsi_trace_rw6(struct trace_seq *p, unsigned char *cdb, int len)
29{
30 const char *ret = p->buffer + p->len;
31 sector_t lba = 0, txlen = 0;
32
33 lba |= ((cdb[1] & 0x1F) << 16);
34 lba |= (cdb[2] << 8);
35 lba |= cdb[3];
36 txlen = cdb[4];
37
38 trace_seq_printf(p, "lba=%llu txlen=%llu",
39 (unsigned long long)lba, (unsigned long long)txlen);
40 trace_seq_putc(p, 0);
41
42 return ret;
43}
44
45static const char *
46scsi_trace_rw10(struct trace_seq *p, unsigned char *cdb, int len)
47{
48 const char *ret = p->buffer + p->len;
49 sector_t lba = 0, txlen = 0;
50
51 lba |= (cdb[2] << 24);
52 lba |= (cdb[3] << 16);
53 lba |= (cdb[4] << 8);
54 lba |= cdb[5];
55 txlen |= (cdb[7] << 8);
56 txlen |= cdb[8];
57
58 trace_seq_printf(p, "lba=%llu txlen=%llu",
59 (unsigned long long)lba, (unsigned long long)txlen);
60 trace_seq_putc(p, 0);
61
62 return ret;
63}
64
65static const char *
66scsi_trace_rw12(struct trace_seq *p, unsigned char *cdb, int len)
67{
68 const char *ret = p->buffer + p->len;
69 sector_t lba = 0, txlen = 0;
70
71 lba |= (cdb[2] << 24);
72 lba |= (cdb[3] << 16);
73 lba |= (cdb[4] << 8);
74 lba |= cdb[5];
75 txlen |= (cdb[6] << 24);
76 txlen |= (cdb[7] << 16);
77 txlen |= (cdb[8] << 8);
78 txlen |= cdb[9];
79
80 trace_seq_printf(p, "lba=%llu txlen=%llu",
81 (unsigned long long)lba, (unsigned long long)txlen);
82 trace_seq_putc(p, 0);
83
84 return ret;
85}
86
87static const char *
88scsi_trace_rw16(struct trace_seq *p, unsigned char *cdb, int len)
89{
90 const char *ret = p->buffer + p->len;
91 sector_t lba = 0, txlen = 0;
92
93 lba |= ((u64)cdb[2] << 56);
94 lba |= ((u64)cdb[3] << 48);
95 lba |= ((u64)cdb[4] << 40);
96 lba |= ((u64)cdb[5] << 32);
97 lba |= (cdb[6] << 24);
98 lba |= (cdb[7] << 16);
99 lba |= (cdb[8] << 8);
100 lba |= cdb[9];
101 txlen |= (cdb[10] << 24);
102 txlen |= (cdb[11] << 16);
103 txlen |= (cdb[12] << 8);
104 txlen |= cdb[13];
105
106 trace_seq_printf(p, "lba=%llu txlen=%llu",
107 (unsigned long long)lba, (unsigned long long)txlen);
108 trace_seq_putc(p, 0);
109
110 return ret;
111}
112
113static const char *
114scsi_trace_rw32(struct trace_seq *p, unsigned char *cdb, int len)
115{
116 const char *ret = p->buffer + p->len;
117 sector_t lba = 0, txlen = 0;
118
119 lba |= ((u64)cdb[12] << 56);
120 lba |= ((u64)cdb[13] << 48);
121 lba |= ((u64)cdb[14] << 40);
122 lba |= ((u64)cdb[15] << 32);
123 lba |= (cdb[16] << 24);
124 lba |= (cdb[17] << 16);
125 lba |= (cdb[18] << 8);
126 lba |= cdb[19];
127 txlen |= (cdb[28] << 24);
128 txlen |= (cdb[29] << 16);
129 txlen |= (cdb[30] << 8);
130 txlen |= cdb[31];
131
132 trace_seq_printf(p, "%s_32 lba=%llu txlen=%llu",
133 (SERVICE_ACTION(cdb) == READ_32 ? "READ" : "WRITE"),
134 (unsigned long long)lba, (unsigned long long)txlen);
135
136 trace_seq_putc(p, 0);
137
138 return ret;
139}
140
141static const char *
142scsi_trace_varlen(struct trace_seq *p, unsigned char *cdb, int len)
143{
144 switch (SERVICE_ACTION(cdb)) {
145 case READ_32:
146 case WRITE_32:
147 return scsi_trace_rw32(p, cdb, len);
148 default:
149 return scsi_trace_misc(p, cdb, len);
150 }
151}
152
153static const char *
154scsi_trace_misc(struct trace_seq *p, unsigned char *cdb, int len)
155{
156 const char *ret = p->buffer + p->len;
157
158 trace_seq_printf(p, "-");
159 trace_seq_putc(p, 0);
160
161 return ret;
162}
163
164const char *
165scsi_trace_parse_cdb(struct trace_seq *p, unsigned char *cdb, int len)
166{
167 switch (cdb[0]) {
168 case READ_6:
169 case WRITE_6:
170 return scsi_trace_rw6(p, cdb, len);
171 case READ_10:
172 case WRITE_10:
173 return scsi_trace_rw10(p, cdb, len);
174 case READ_12:
175 case WRITE_12:
176 return scsi_trace_rw12(p, cdb, len);
177 case READ_16:
178 case WRITE_16:
179 return scsi_trace_rw16(p, cdb, len);
180 case VARIABLE_LENGTH_CMD:
181 return scsi_trace_varlen(p, cdb, len);
182 default:
183 return scsi_trace_misc(p, cdb, len);
184 }
185}