aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLi Zefan <lizf@cn.fujitsu.com>2009-04-14 02:00:05 -0400
committerIngo Molnar <mingo@elte.hu>2009-04-16 04:10:59 -0400
commit1d54ad6da9192fed5dd3b60224d9f2dfea0dcd82 (patch)
treefd5917f144ec820b933795bedd7eddea96bee374
parent9908c30997b8a73c95f836170b9998dae9aa3f4a (diff)
blktrace: add trace/ to /sys/block/sda
Impact: allow ftrace-plugin blktrace to trace device-mapper devices To trace a single partition: # echo 1 > /sys/block/sda/sda1/enable To trace the whole sda instead: # echo 1 > /sys/block/sda/enable Thus we also fix an issue reported by Ted, that ftrace-plugin blktrace can't be used to trace device-mapper devices. Now: # echo 1 > /sys/block/dm-0/trace/enable echo: write error: No such device or address # mount -t ext4 /dev/dm-0 /mnt # echo 1 > /sys/block/dm-0/trace/enable # echo blk > /debug/tracing/current_tracer Reported-by: Theodore Tso <tytso@mit.edu> Signed-off-by: Li Zefan <lizf@cn.fujitsu.com> Acked-by: "Theodore Ts'o" <tytso@mit.edu> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Shawn Du <duyuyang@gmail.com> Cc: Jens Axboe <jens.axboe@oracle.com> LKML-Reference: <49E42665.6020506@cn.fujitsu.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r--block/blk-sysfs.c7
-rw-r--r--include/linux/blktrace_api.h6
-rw-r--r--kernel/trace/blktrace.c5
3 files changed, 17 insertions, 1 deletions
diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index 73f36beff5cd..8653d710b39e 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -387,16 +387,21 @@ struct kobj_type blk_queue_ktype = {
387int blk_register_queue(struct gendisk *disk) 387int blk_register_queue(struct gendisk *disk)
388{ 388{
389 int ret; 389 int ret;
390 struct device *dev = disk_to_dev(disk);
390 391
391 struct request_queue *q = disk->queue; 392 struct request_queue *q = disk->queue;
392 393
393 if (WARN_ON(!q)) 394 if (WARN_ON(!q))
394 return -ENXIO; 395 return -ENXIO;
395 396
397 ret = blk_trace_init_sysfs(dev);
398 if (ret)
399 return ret;
400
396 if (!q->request_fn) 401 if (!q->request_fn)
397 return 0; 402 return 0;
398 403
399 ret = kobject_add(&q->kobj, kobject_get(&disk_to_dev(disk)->kobj), 404 ret = kobject_add(&q->kobj, kobject_get(&dev->kobj),
400 "%s", "queue"); 405 "%s", "queue");
401 if (ret < 0) 406 if (ret < 0)
402 return ret; 407 return ret;
diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
index 267edc4017ee..62763c952854 100644
--- a/include/linux/blktrace_api.h
+++ b/include/linux/blktrace_api.h
@@ -198,6 +198,7 @@ extern int blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
198 char __user *arg); 198 char __user *arg);
199extern int blk_trace_startstop(struct request_queue *q, int start); 199extern int blk_trace_startstop(struct request_queue *q, int start);
200extern int blk_trace_remove(struct request_queue *q); 200extern int blk_trace_remove(struct request_queue *q);
201extern int blk_trace_init_sysfs(struct device *dev);
201 202
202extern struct attribute_group blk_trace_attr_group; 203extern struct attribute_group blk_trace_attr_group;
203 204
@@ -210,6 +211,11 @@ extern struct attribute_group blk_trace_attr_group;
210# define blk_trace_startstop(q, start) (-ENOTTY) 211# define blk_trace_startstop(q, start) (-ENOTTY)
211# define blk_trace_remove(q) (-ENOTTY) 212# define blk_trace_remove(q) (-ENOTTY)
212# define blk_add_trace_msg(q, fmt, ...) do { } while (0) 213# define blk_add_trace_msg(q, fmt, ...) do { } while (0)
214static inline int blk_trace_init_sysfs(struct device *dev)
215{
216 return 0;
217}
218
213#endif /* CONFIG_BLK_DEV_IO_TRACE */ 219#endif /* CONFIG_BLK_DEV_IO_TRACE */
214 220
215#endif /* __KERNEL__ */ 221#endif /* __KERNEL__ */
diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
index d10989880520..8e7c5da3a3e6 100644
--- a/kernel/trace/blktrace.c
+++ b/kernel/trace/blktrace.c
@@ -1644,3 +1644,8 @@ out:
1644 return ret ? ret : count; 1644 return ret ? ret : count;
1645} 1645}
1646 1646
1647int blk_trace_init_sysfs(struct device *dev)
1648{
1649 return sysfs_create_group(&dev->kobj, &blk_trace_attr_group);
1650}
1651