diff options
-rw-r--r-- | drivers/target/target_core_transport.c | 16 | ||||
-rw-r--r-- | include/trace/events/target.h | 214 |
2 files changed, 229 insertions, 1 deletions
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index ae40addd4ce0..7172d005d063 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c | |||
@@ -52,6 +52,9 @@ | |||
52 | #include "target_core_pr.h" | 52 | #include "target_core_pr.h" |
53 | #include "target_core_ua.h" | 53 | #include "target_core_ua.h" |
54 | 54 | ||
55 | #define CREATE_TRACE_POINTS | ||
56 | #include <trace/events/target.h> | ||
57 | |||
55 | static struct workqueue_struct *target_completion_wq; | 58 | static struct workqueue_struct *target_completion_wq; |
56 | static struct kmem_cache *se_sess_cache; | 59 | static struct kmem_cache *se_sess_cache; |
57 | struct kmem_cache *se_ua_cache; | 60 | struct kmem_cache *se_ua_cache; |
@@ -1123,6 +1126,8 @@ target_setup_cmd_from_cdb(struct se_cmd *cmd, unsigned char *cdb) | |||
1123 | */ | 1126 | */ |
1124 | memcpy(cmd->t_task_cdb, cdb, scsi_command_size(cdb)); | 1127 | memcpy(cmd->t_task_cdb, cdb, scsi_command_size(cdb)); |
1125 | 1128 | ||
1129 | trace_target_sequencer_start(cmd); | ||
1130 | |||
1126 | /* | 1131 | /* |
1127 | * Check for an existing UNIT ATTENTION condition | 1132 | * Check for an existing UNIT ATTENTION condition |
1128 | */ | 1133 | */ |
@@ -1546,7 +1551,8 @@ void transport_generic_request_failure(struct se_cmd *cmd, | |||
1546 | cmd->orig_fe_lun, 0x2C, | 1551 | cmd->orig_fe_lun, 0x2C, |
1547 | ASCQ_2CH_PREVIOUS_RESERVATION_CONFLICT_STATUS); | 1552 | ASCQ_2CH_PREVIOUS_RESERVATION_CONFLICT_STATUS); |
1548 | 1553 | ||
1549 | ret = cmd->se_tfo->queue_status(cmd); | 1554 | trace_target_cmd_complete(cmd); |
1555 | ret = cmd->se_tfo-> queue_status(cmd); | ||
1550 | if (ret == -EAGAIN || ret == -ENOMEM) | 1556 | if (ret == -EAGAIN || ret == -ENOMEM) |
1551 | goto queue_full; | 1557 | goto queue_full; |
1552 | goto check_stop; | 1558 | goto check_stop; |
@@ -1766,6 +1772,7 @@ static void transport_complete_qf(struct se_cmd *cmd) | |||
1766 | transport_complete_task_attr(cmd); | 1772 | transport_complete_task_attr(cmd); |
1767 | 1773 | ||
1768 | if (cmd->se_cmd_flags & SCF_TRANSPORT_TASK_SENSE) { | 1774 | if (cmd->se_cmd_flags & SCF_TRANSPORT_TASK_SENSE) { |
1775 | trace_target_cmd_complete(cmd); | ||
1769 | ret = cmd->se_tfo->queue_status(cmd); | 1776 | ret = cmd->se_tfo->queue_status(cmd); |
1770 | if (ret) | 1777 | if (ret) |
1771 | goto out; | 1778 | goto out; |
@@ -1773,6 +1780,7 @@ static void transport_complete_qf(struct se_cmd *cmd) | |||
1773 | 1780 | ||
1774 | switch (cmd->data_direction) { | 1781 | switch (cmd->data_direction) { |
1775 | case DMA_FROM_DEVICE: | 1782 | case DMA_FROM_DEVICE: |
1783 | trace_target_cmd_complete(cmd); | ||
1776 | ret = cmd->se_tfo->queue_data_in(cmd); | 1784 | ret = cmd->se_tfo->queue_data_in(cmd); |
1777 | break; | 1785 | break; |
1778 | case DMA_TO_DEVICE: | 1786 | case DMA_TO_DEVICE: |
@@ -1783,6 +1791,7 @@ static void transport_complete_qf(struct se_cmd *cmd) | |||
1783 | } | 1791 | } |
1784 | /* Fall through for DMA_TO_DEVICE */ | 1792 | /* Fall through for DMA_TO_DEVICE */ |
1785 | case DMA_NONE: | 1793 | case DMA_NONE: |
1794 | trace_target_cmd_complete(cmd); | ||
1786 | ret = cmd->se_tfo->queue_status(cmd); | 1795 | ret = cmd->se_tfo->queue_status(cmd); |
1787 | break; | 1796 | break; |
1788 | default: | 1797 | default: |
@@ -1861,6 +1870,7 @@ static void target_complete_ok_work(struct work_struct *work) | |||
1861 | } | 1870 | } |
1862 | spin_unlock(&cmd->se_lun->lun_sep_lock); | 1871 | spin_unlock(&cmd->se_lun->lun_sep_lock); |
1863 | 1872 | ||
1873 | trace_target_cmd_complete(cmd); | ||
1864 | ret = cmd->se_tfo->queue_data_in(cmd); | 1874 | ret = cmd->se_tfo->queue_data_in(cmd); |
1865 | if (ret == -EAGAIN || ret == -ENOMEM) | 1875 | if (ret == -EAGAIN || ret == -ENOMEM) |
1866 | goto queue_full; | 1876 | goto queue_full; |
@@ -1889,6 +1899,7 @@ static void target_complete_ok_work(struct work_struct *work) | |||
1889 | } | 1899 | } |
1890 | /* Fall through for DMA_TO_DEVICE */ | 1900 | /* Fall through for DMA_TO_DEVICE */ |
1891 | case DMA_NONE: | 1901 | case DMA_NONE: |
1902 | trace_target_cmd_complete(cmd); | ||
1892 | ret = cmd->se_tfo->queue_status(cmd); | 1903 | ret = cmd->se_tfo->queue_status(cmd); |
1893 | if (ret == -EAGAIN || ret == -ENOMEM) | 1904 | if (ret == -EAGAIN || ret == -ENOMEM) |
1894 | goto queue_full; | 1905 | goto queue_full; |
@@ -2745,6 +2756,7 @@ transport_send_check_condition_and_sense(struct se_cmd *cmd, | |||
2745 | cmd->scsi_sense_length = TRANSPORT_SENSE_BUFFER; | 2756 | cmd->scsi_sense_length = TRANSPORT_SENSE_BUFFER; |
2746 | 2757 | ||
2747 | after_reason: | 2758 | after_reason: |
2759 | trace_target_cmd_complete(cmd); | ||
2748 | return cmd->se_tfo->queue_status(cmd); | 2760 | return cmd->se_tfo->queue_status(cmd); |
2749 | } | 2761 | } |
2750 | EXPORT_SYMBOL(transport_send_check_condition_and_sense); | 2762 | EXPORT_SYMBOL(transport_send_check_condition_and_sense); |
@@ -2761,6 +2773,7 @@ int transport_check_aborted_status(struct se_cmd *cmd, int send_status) | |||
2761 | cmd->t_task_cdb[0], cmd->se_tfo->get_task_tag(cmd)); | 2773 | cmd->t_task_cdb[0], cmd->se_tfo->get_task_tag(cmd)); |
2762 | 2774 | ||
2763 | cmd->se_cmd_flags |= SCF_SENT_DELAYED_TAS; | 2775 | cmd->se_cmd_flags |= SCF_SENT_DELAYED_TAS; |
2776 | trace_target_cmd_complete(cmd); | ||
2764 | cmd->se_tfo->queue_status(cmd); | 2777 | cmd->se_tfo->queue_status(cmd); |
2765 | 2778 | ||
2766 | return 1; | 2779 | return 1; |
@@ -2798,6 +2811,7 @@ void transport_send_task_abort(struct se_cmd *cmd) | |||
2798 | " ITT: 0x%08x\n", cmd->t_task_cdb[0], | 2811 | " ITT: 0x%08x\n", cmd->t_task_cdb[0], |
2799 | cmd->se_tfo->get_task_tag(cmd)); | 2812 | cmd->se_tfo->get_task_tag(cmd)); |
2800 | 2813 | ||
2814 | trace_target_cmd_complete(cmd); | ||
2801 | cmd->se_tfo->queue_status(cmd); | 2815 | cmd->se_tfo->queue_status(cmd); |
2802 | } | 2816 | } |
2803 | 2817 | ||
diff --git a/include/trace/events/target.h b/include/trace/events/target.h new file mode 100644 index 000000000000..aef8fc354025 --- /dev/null +++ b/include/trace/events/target.h | |||
@@ -0,0 +1,214 @@ | |||
1 | #undef TRACE_SYSTEM | ||
2 | #define TRACE_SYSTEM target | ||
3 | |||
4 | #if !defined(_TRACE_TARGET_H) || defined(TRACE_HEADER_MULTI_READ) | ||
5 | #define _TRACE_TARGET_H | ||
6 | |||
7 | #include <linux/tracepoint.h> | ||
8 | #include <linux/trace_seq.h> | ||
9 | #include <scsi/scsi.h> | ||
10 | #include <scsi/scsi_tcq.h> | ||
11 | #include <target/target_core_base.h> | ||
12 | |||
13 | /* cribbed verbatim from <trace/event/scsi.h> */ | ||
14 | #define scsi_opcode_name(opcode) { opcode, #opcode } | ||
15 | #define show_opcode_name(val) \ | ||
16 | __print_symbolic(val, \ | ||
17 | scsi_opcode_name(TEST_UNIT_READY), \ | ||
18 | scsi_opcode_name(REZERO_UNIT), \ | ||
19 | scsi_opcode_name(REQUEST_SENSE), \ | ||
20 | scsi_opcode_name(FORMAT_UNIT), \ | ||
21 | scsi_opcode_name(READ_BLOCK_LIMITS), \ | ||
22 | scsi_opcode_name(REASSIGN_BLOCKS), \ | ||
23 | scsi_opcode_name(INITIALIZE_ELEMENT_STATUS), \ | ||
24 | scsi_opcode_name(READ_6), \ | ||
25 | scsi_opcode_name(WRITE_6), \ | ||
26 | scsi_opcode_name(SEEK_6), \ | ||
27 | scsi_opcode_name(READ_REVERSE), \ | ||
28 | scsi_opcode_name(WRITE_FILEMARKS), \ | ||
29 | scsi_opcode_name(SPACE), \ | ||
30 | scsi_opcode_name(INQUIRY), \ | ||
31 | scsi_opcode_name(RECOVER_BUFFERED_DATA), \ | ||
32 | scsi_opcode_name(MODE_SELECT), \ | ||
33 | scsi_opcode_name(RESERVE), \ | ||
34 | scsi_opcode_name(RELEASE), \ | ||
35 | scsi_opcode_name(COPY), \ | ||
36 | scsi_opcode_name(ERASE), \ | ||
37 | scsi_opcode_name(MODE_SENSE), \ | ||
38 | scsi_opcode_name(START_STOP), \ | ||
39 | scsi_opcode_name(RECEIVE_DIAGNOSTIC), \ | ||
40 | scsi_opcode_name(SEND_DIAGNOSTIC), \ | ||
41 | scsi_opcode_name(ALLOW_MEDIUM_REMOVAL), \ | ||
42 | scsi_opcode_name(SET_WINDOW), \ | ||
43 | scsi_opcode_name(READ_CAPACITY), \ | ||
44 | scsi_opcode_name(READ_10), \ | ||
45 | scsi_opcode_name(WRITE_10), \ | ||
46 | scsi_opcode_name(SEEK_10), \ | ||
47 | scsi_opcode_name(POSITION_TO_ELEMENT), \ | ||
48 | scsi_opcode_name(WRITE_VERIFY), \ | ||
49 | scsi_opcode_name(VERIFY), \ | ||
50 | scsi_opcode_name(SEARCH_HIGH), \ | ||
51 | scsi_opcode_name(SEARCH_EQUAL), \ | ||
52 | scsi_opcode_name(SEARCH_LOW), \ | ||
53 | scsi_opcode_name(SET_LIMITS), \ | ||
54 | scsi_opcode_name(PRE_FETCH), \ | ||
55 | scsi_opcode_name(READ_POSITION), \ | ||
56 | scsi_opcode_name(SYNCHRONIZE_CACHE), \ | ||
57 | scsi_opcode_name(LOCK_UNLOCK_CACHE), \ | ||
58 | scsi_opcode_name(READ_DEFECT_DATA), \ | ||
59 | scsi_opcode_name(MEDIUM_SCAN), \ | ||
60 | scsi_opcode_name(COMPARE), \ | ||
61 | scsi_opcode_name(COPY_VERIFY), \ | ||
62 | scsi_opcode_name(WRITE_BUFFER), \ | ||
63 | scsi_opcode_name(READ_BUFFER), \ | ||
64 | scsi_opcode_name(UPDATE_BLOCK), \ | ||
65 | scsi_opcode_name(READ_LONG), \ | ||
66 | scsi_opcode_name(WRITE_LONG), \ | ||
67 | scsi_opcode_name(CHANGE_DEFINITION), \ | ||
68 | scsi_opcode_name(WRITE_SAME), \ | ||
69 | scsi_opcode_name(UNMAP), \ | ||
70 | scsi_opcode_name(READ_TOC), \ | ||
71 | scsi_opcode_name(LOG_SELECT), \ | ||
72 | scsi_opcode_name(LOG_SENSE), \ | ||
73 | scsi_opcode_name(XDWRITEREAD_10), \ | ||
74 | scsi_opcode_name(MODE_SELECT_10), \ | ||
75 | scsi_opcode_name(RESERVE_10), \ | ||
76 | scsi_opcode_name(RELEASE_10), \ | ||
77 | scsi_opcode_name(MODE_SENSE_10), \ | ||
78 | scsi_opcode_name(PERSISTENT_RESERVE_IN), \ | ||
79 | scsi_opcode_name(PERSISTENT_RESERVE_OUT), \ | ||
80 | scsi_opcode_name(VARIABLE_LENGTH_CMD), \ | ||
81 | scsi_opcode_name(REPORT_LUNS), \ | ||
82 | scsi_opcode_name(MAINTENANCE_IN), \ | ||
83 | scsi_opcode_name(MAINTENANCE_OUT), \ | ||
84 | scsi_opcode_name(MOVE_MEDIUM), \ | ||
85 | scsi_opcode_name(EXCHANGE_MEDIUM), \ | ||
86 | scsi_opcode_name(READ_12), \ | ||
87 | scsi_opcode_name(WRITE_12), \ | ||
88 | scsi_opcode_name(WRITE_VERIFY_12), \ | ||
89 | scsi_opcode_name(SEARCH_HIGH_12), \ | ||
90 | scsi_opcode_name(SEARCH_EQUAL_12), \ | ||
91 | scsi_opcode_name(SEARCH_LOW_12), \ | ||
92 | scsi_opcode_name(READ_ELEMENT_STATUS), \ | ||
93 | scsi_opcode_name(SEND_VOLUME_TAG), \ | ||
94 | scsi_opcode_name(WRITE_LONG_2), \ | ||
95 | scsi_opcode_name(READ_16), \ | ||
96 | scsi_opcode_name(WRITE_16), \ | ||
97 | scsi_opcode_name(VERIFY_16), \ | ||
98 | scsi_opcode_name(WRITE_SAME_16), \ | ||
99 | scsi_opcode_name(SERVICE_ACTION_IN), \ | ||
100 | scsi_opcode_name(SAI_READ_CAPACITY_16), \ | ||
101 | scsi_opcode_name(SAI_GET_LBA_STATUS), \ | ||
102 | scsi_opcode_name(MI_REPORT_TARGET_PGS), \ | ||
103 | scsi_opcode_name(MO_SET_TARGET_PGS), \ | ||
104 | scsi_opcode_name(READ_32), \ | ||
105 | scsi_opcode_name(WRITE_32), \ | ||
106 | scsi_opcode_name(WRITE_SAME_32), \ | ||
107 | scsi_opcode_name(ATA_16), \ | ||
108 | scsi_opcode_name(ATA_12)) | ||
109 | |||
110 | #define show_task_attribute_name(val) \ | ||
111 | __print_symbolic(val, \ | ||
112 | { MSG_SIMPLE_TAG, "SIMPLE" }, \ | ||
113 | { MSG_HEAD_TAG, "HEAD" }, \ | ||
114 | { MSG_ORDERED_TAG, "ORDERED" }, \ | ||
115 | { MSG_ACA_TAG, "ACA" } ) | ||
116 | |||
117 | #define show_scsi_status_name(val) \ | ||
118 | __print_symbolic(val, \ | ||
119 | { SAM_STAT_GOOD, "GOOD" }, \ | ||
120 | { SAM_STAT_CHECK_CONDITION, "CHECK CONDITION" }, \ | ||
121 | { SAM_STAT_CONDITION_MET, "CONDITION MET" }, \ | ||
122 | { SAM_STAT_BUSY, "BUSY" }, \ | ||
123 | { SAM_STAT_INTERMEDIATE, "INTERMEDIATE" }, \ | ||
124 | { SAM_STAT_INTERMEDIATE_CONDITION_MET, "INTERMEDIATE CONDITION MET" }, \ | ||
125 | { SAM_STAT_RESERVATION_CONFLICT, "RESERVATION CONFLICT" }, \ | ||
126 | { SAM_STAT_COMMAND_TERMINATED, "COMMAND TERMINATED" }, \ | ||
127 | { SAM_STAT_TASK_SET_FULL, "TASK SET FULL" }, \ | ||
128 | { SAM_STAT_ACA_ACTIVE, "ACA ACTIVE" }, \ | ||
129 | { SAM_STAT_TASK_ABORTED, "TASK ABORTED" } ) | ||
130 | |||
131 | TRACE_EVENT(target_sequencer_start, | ||
132 | |||
133 | TP_PROTO(struct se_cmd *cmd), | ||
134 | |||
135 | TP_ARGS(cmd), | ||
136 | |||
137 | TP_STRUCT__entry( | ||
138 | __field( unsigned int, unpacked_lun ) | ||
139 | __field( unsigned int, opcode ) | ||
140 | __field( unsigned int, data_length ) | ||
141 | __field( unsigned int, task_attribute ) | ||
142 | __array( unsigned char, cdb, TCM_MAX_COMMAND_SIZE ) | ||
143 | __string( initiator, cmd->se_sess->se_node_acl->initiatorname ) | ||
144 | ), | ||
145 | |||
146 | TP_fast_assign( | ||
147 | __entry->unpacked_lun = cmd->se_lun->unpacked_lun; | ||
148 | __entry->opcode = cmd->t_task_cdb[0]; | ||
149 | __entry->data_length = cmd->data_length; | ||
150 | __entry->task_attribute = cmd->sam_task_attr; | ||
151 | memcpy(__entry->cdb, cmd->t_task_cdb, TCM_MAX_COMMAND_SIZE); | ||
152 | __assign_str(initiator, cmd->se_sess->se_node_acl->initiatorname); | ||
153 | ), | ||
154 | |||
155 | TP_printk("%s -> LUN %03u %s data_length %6u CDB %s (TA:%s C:%02x)", | ||
156 | __get_str(initiator), __entry->unpacked_lun, | ||
157 | show_opcode_name(__entry->opcode), | ||
158 | __entry->data_length, __print_hex(__entry->cdb, 16), | ||
159 | show_task_attribute_name(__entry->task_attribute), | ||
160 | scsi_command_size(__entry->cdb) <= 16 ? | ||
161 | __entry->cdb[scsi_command_size(__entry->cdb) - 1] : | ||
162 | __entry->cdb[1] | ||
163 | ) | ||
164 | ); | ||
165 | |||
166 | TRACE_EVENT(target_cmd_complete, | ||
167 | |||
168 | TP_PROTO(struct se_cmd *cmd), | ||
169 | |||
170 | TP_ARGS(cmd), | ||
171 | |||
172 | TP_STRUCT__entry( | ||
173 | __field( unsigned int, unpacked_lun ) | ||
174 | __field( unsigned int, opcode ) | ||
175 | __field( unsigned int, data_length ) | ||
176 | __field( unsigned int, task_attribute ) | ||
177 | __field( unsigned char, scsi_status ) | ||
178 | __field( unsigned char, sense_length ) | ||
179 | __array( unsigned char, cdb, TCM_MAX_COMMAND_SIZE ) | ||
180 | __array( unsigned char, sense_data, 18 ) | ||
181 | __string(initiator, cmd->se_sess->se_node_acl->initiatorname) | ||
182 | ), | ||
183 | |||
184 | TP_fast_assign( | ||
185 | __entry->unpacked_lun = cmd->se_lun->unpacked_lun; | ||
186 | __entry->opcode = cmd->t_task_cdb[0]; | ||
187 | __entry->data_length = cmd->data_length; | ||
188 | __entry->task_attribute = cmd->sam_task_attr; | ||
189 | __entry->scsi_status = cmd->scsi_status; | ||
190 | __entry->sense_length = cmd->scsi_status == SAM_STAT_CHECK_CONDITION ? | ||
191 | min(18, ((u8 *) cmd->sense_buffer)[SPC_ADD_SENSE_LEN_OFFSET] + 8) : 0; | ||
192 | memcpy(__entry->cdb, cmd->t_task_cdb, TCM_MAX_COMMAND_SIZE); | ||
193 | memcpy(__entry->sense_data, cmd->sense_buffer, __entry->sense_length); | ||
194 | __assign_str(initiator, cmd->se_sess->se_node_acl->initiatorname); | ||
195 | ), | ||
196 | |||
197 | TP_printk("%s <- LUN %03u status %s (sense len %d%s%s) %s data_length %6u CDB %s (TA:%s C:%02x)", | ||
198 | __get_str(initiator), __entry->unpacked_lun, | ||
199 | show_scsi_status_name(__entry->scsi_status), | ||
200 | __entry->sense_length, __entry->sense_length ? " / " : "", | ||
201 | __print_hex(__entry->sense_data, __entry->sense_length), | ||
202 | show_opcode_name(__entry->opcode), | ||
203 | __entry->data_length, __print_hex(__entry->cdb, 16), | ||
204 | show_task_attribute_name(__entry->task_attribute), | ||
205 | scsi_command_size(__entry->cdb) <= 16 ? | ||
206 | __entry->cdb[scsi_command_size(__entry->cdb) - 1] : | ||
207 | __entry->cdb[1] | ||
208 | ) | ||
209 | ); | ||
210 | |||
211 | #endif /* _TRACE_TARGET_H */ | ||
212 | |||
213 | /* This part must be outside protection */ | ||
214 | #include <trace/define_trace.h> | ||