aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--block/blktrace.c14
-rw-r--r--include/linux/blktrace_api.h25
2 files changed, 39 insertions, 0 deletions
diff --git a/block/blktrace.c b/block/blktrace.c
index b2cbb4e5d767..20e11f354f11 100644
--- a/block/blktrace.c
+++ b/block/blktrace.c
@@ -75,6 +75,20 @@ static void trace_note_time(struct blk_trace *bt)
75 local_irq_restore(flags); 75 local_irq_restore(flags);
76} 76}
77 77
78void __trace_note_message(struct blk_trace *bt, const char *fmt, ...)
79{
80 int n;
81 va_list args;
82 static char bt_msg_buf[BLK_TN_MAX_MSG];
83
84 va_start(args, fmt);
85 n = vscnprintf(bt_msg_buf, BLK_TN_MAX_MSG, fmt, args);
86 va_end(args);
87
88 trace_note(bt, 0, BLK_TN_MESSAGE, bt_msg_buf, n);
89}
90EXPORT_SYMBOL_GPL(__trace_note_message);
91
78static int act_log_check(struct blk_trace *bt, u32 what, sector_t sector, 92static int act_log_check(struct blk_trace *bt, u32 what, sector_t sector,
79 pid_t pid) 93 pid_t pid)
80{ 94{
diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
index cfc3147e5cf9..b7cd8f1eedbe 100644
--- a/include/linux/blktrace_api.h
+++ b/include/linux/blktrace_api.h
@@ -55,6 +55,7 @@ enum blktrace_act {
55enum blktrace_notify { 55enum blktrace_notify {
56 __BLK_TN_PROCESS = 0, /* establish pid/name mapping */ 56 __BLK_TN_PROCESS = 0, /* establish pid/name mapping */
57 __BLK_TN_TIMESTAMP, /* include system clock */ 57 __BLK_TN_TIMESTAMP, /* include system clock */
58 __BLK_TN_MESSAGE, /* Character string message */
58}; 59};
59 60
60 61
@@ -79,6 +80,7 @@ enum blktrace_notify {
79 80
80#define BLK_TN_PROCESS (__BLK_TN_PROCESS | BLK_TC_ACT(BLK_TC_NOTIFY)) 81#define BLK_TN_PROCESS (__BLK_TN_PROCESS | BLK_TC_ACT(BLK_TC_NOTIFY))
81#define BLK_TN_TIMESTAMP (__BLK_TN_TIMESTAMP | BLK_TC_ACT(BLK_TC_NOTIFY)) 82#define BLK_TN_TIMESTAMP (__BLK_TN_TIMESTAMP | BLK_TC_ACT(BLK_TC_NOTIFY))
83#define BLK_TN_MESSAGE (__BLK_TN_MESSAGE | BLK_TC_ACT(BLK_TC_NOTIFY))
82 84
83#define BLK_IO_TRACE_MAGIC 0x65617400 85#define BLK_IO_TRACE_MAGIC 0x65617400
84#define BLK_IO_TRACE_VERSION 0x07 86#define BLK_IO_TRACE_VERSION 0x07
@@ -149,7 +151,28 @@ extern void blk_trace_shutdown(struct request_queue *);
149extern void __blk_add_trace(struct blk_trace *, sector_t, int, int, u32, int, int, void *); 151extern void __blk_add_trace(struct blk_trace *, sector_t, int, int, u32, int, int, void *);
150extern int do_blk_trace_setup(struct request_queue *q, 152extern int do_blk_trace_setup(struct request_queue *q,
151 char *name, dev_t dev, struct blk_user_trace_setup *buts); 153 char *name, dev_t dev, struct blk_user_trace_setup *buts);
154extern void __trace_note_message(struct blk_trace *, const char *fmt, ...);
152 155
156/**
157 * blk_add_trace_msg - Add a (simple) message to the blktrace stream
158 * @q: queue the io is for
159 * @fmt: format to print message in
160 * args... Variable argument list for format
161 *
162 * Description:
163 * Records a (simple) message onto the blktrace stream.
164 *
165 * NOTE: BLK_TN_MAX_MSG characters are output at most.
166 * NOTE: Can not use 'static inline' due to presence of var args...
167 *
168 **/
169#define blk_add_trace_msg(q, fmt, ...) \
170 do { \
171 struct blk_trace *bt = (q)->blk_trace; \
172 if (unlikely(bt)) \
173 __trace_note_message(bt, fmt, ##__VA_ARGS__); \
174 } while (0)
175#define BLK_TN_MAX_MSG 1024
153 176
154/** 177/**
155 * blk_add_trace_rq - Add a trace for a request oriented action 178 * blk_add_trace_rq - Add a trace for a request oriented action
@@ -299,6 +322,8 @@ extern int blk_trace_remove(struct request_queue *q);
299#define blk_trace_setup(q, name, dev, arg) (-ENOTTY) 322#define blk_trace_setup(q, name, dev, arg) (-ENOTTY)
300#define blk_trace_startstop(q, start) (-ENOTTY) 323#define blk_trace_startstop(q, start) (-ENOTTY)
301#define blk_trace_remove(q) (-ENOTTY) 324#define blk_trace_remove(q) (-ENOTTY)
325#define blk_add_trace_msg(q, fmt, ...) do { } while (0)
326
302#endif /* CONFIG_BLK_DEV_IO_TRACE */ 327#endif /* CONFIG_BLK_DEV_IO_TRACE */
303#endif /* __KERNEL__ */ 328#endif /* __KERNEL__ */
304#endif 329#endif