aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/blktrace.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/trace/blktrace.c')
-rw-r--r--kernel/trace/blktrace.c88
1 files changed, 80 insertions, 8 deletions
diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
index e45e1af13563..2b98195b338b 100644
--- a/kernel/trace/blktrace.c
+++ b/kernel/trace/blktrace.c
@@ -971,6 +971,16 @@ static inline const void *pdu_start(const struct trace_entry *ent)
971 return te_blk_io_trace(ent) + 1; 971 return te_blk_io_trace(ent) + 1;
972} 972}
973 973
974static inline u32 t_action(const struct trace_entry *ent)
975{
976 return te_blk_io_trace(ent)->action;
977}
978
979static inline u32 t_bytes(const struct trace_entry *ent)
980{
981 return te_blk_io_trace(ent)->bytes;
982}
983
974static inline u32 t_sec(const struct trace_entry *ent) 984static inline u32 t_sec(const struct trace_entry *ent)
975{ 985{
976 return te_blk_io_trace(ent)->bytes >> 9; 986 return te_blk_io_trace(ent)->bytes >> 9;
@@ -1031,25 +1041,87 @@ static int blk_log_action(struct trace_iterator *iter, const char *act)
1031 MAJOR(t->device), MINOR(t->device), act, rwbs); 1041 MAJOR(t->device), MINOR(t->device), act, rwbs);
1032} 1042}
1033 1043
1044static int blk_log_dump_pdu(struct trace_seq *s, const struct trace_entry *ent)
1045{
1046 const char *pdu_buf;
1047 int pdu_len;
1048 int i, end, ret;
1049
1050 pdu_buf = pdu_start(ent);
1051 pdu_len = te_blk_io_trace(ent)->pdu_len;
1052
1053 if (!pdu_len)
1054 return 1;
1055
1056 /* find the last zero that needs to be printed */
1057 for (end = pdu_len - 1; end >= 0; end--)
1058 if (pdu_buf[end])
1059 break;
1060 end++;
1061
1062 if (!trace_seq_putc(s, '('))
1063 return 0;
1064
1065 for (i = 0; i < pdu_len; i++) {
1066
1067 ret = trace_seq_printf(s, "%s%02x",
1068 i == 0 ? "" : " ", pdu_buf[i]);
1069 if (!ret)
1070 return ret;
1071
1072 /*
1073 * stop when the rest is just zeroes and indicate so
1074 * with a ".." appended
1075 */
1076 if (i == end && end != pdu_len - 1)
1077 return trace_seq_puts(s, " ..) ");
1078 }
1079
1080 return trace_seq_puts(s, ") ");
1081}
1082
1034static int blk_log_generic(struct trace_seq *s, const struct trace_entry *ent) 1083static int blk_log_generic(struct trace_seq *s, const struct trace_entry *ent)
1035{ 1084{
1036 char cmd[TASK_COMM_LEN]; 1085 char cmd[TASK_COMM_LEN];
1037 1086
1038 trace_find_cmdline(ent->pid, cmd); 1087 trace_find_cmdline(ent->pid, cmd);
1039 1088
1040 if (t_sec(ent)) 1089 if (t_action(ent) & BLK_TC_ACT(BLK_TC_PC)) {
1041 return trace_seq_printf(s, "%llu + %u [%s]\n", 1090 int ret;
1042 t_sector(ent), t_sec(ent), cmd); 1091
1043 return trace_seq_printf(s, "[%s]\n", cmd); 1092 ret = trace_seq_printf(s, "%u ", t_bytes(ent));
1093 if (!ret)
1094 return 0;
1095 ret = blk_log_dump_pdu(s, ent);
1096 if (!ret)
1097 return 0;
1098 return trace_seq_printf(s, "[%s]\n", cmd);
1099 } else {
1100 if (t_sec(ent))
1101 return trace_seq_printf(s, "%llu + %u [%s]\n",
1102 t_sector(ent), t_sec(ent), cmd);
1103 return trace_seq_printf(s, "[%s]\n", cmd);
1104 }
1044} 1105}
1045 1106
1046static int blk_log_with_error(struct trace_seq *s, 1107static int blk_log_with_error(struct trace_seq *s,
1047 const struct trace_entry *ent) 1108 const struct trace_entry *ent)
1048{ 1109{
1049 if (t_sec(ent)) 1110 if (t_action(ent) & BLK_TC_ACT(BLK_TC_PC)) {
1050 return trace_seq_printf(s, "%llu + %u [%d]\n", t_sector(ent), 1111 int ret;
1051 t_sec(ent), t_error(ent)); 1112
1052 return trace_seq_printf(s, "%llu [%d]\n", t_sector(ent), t_error(ent)); 1113 ret = blk_log_dump_pdu(s, ent);
1114 if (ret)
1115 return trace_seq_printf(s, "[%d]\n", t_error(ent));
1116 return 0;
1117 } else {
1118 if (t_sec(ent))
1119 return trace_seq_printf(s, "%llu + %u [%d]\n",
1120 t_sector(ent),
1121 t_sec(ent), t_error(ent));
1122 return trace_seq_printf(s, "%llu [%d]\n",
1123 t_sector(ent), t_error(ent));
1124 }
1053} 1125}
1054 1126
1055static int blk_log_remap(struct trace_seq *s, const struct trace_entry *ent) 1127static int blk_log_remap(struct trace_seq *s, const struct trace_entry *ent)