aboutsummaryrefslogtreecommitdiffstats
path: root/block/blktrace.c
diff options
context:
space:
mode:
authorChristof Schmitt <christof.schmitt@de.ibm.com>2008-01-11 04:09:43 -0500
committerJens Axboe <jens.axboe@oracle.com>2008-01-28 04:04:46 -0500
commit6da127ad0918f93ea93678dad62ce15ffed18797 (patch)
treeb2bf9ad228f18c643342ad376136d2f6b4be4137 /block/blktrace.c
parent91525300baf162e83e923b09ca286f9205e21522 (diff)
blktrace: Add blktrace ioctls to SCSI generic devices
Since the SCSI layer uses the request queues from the block layer, blktrace can also be used to trace the requests to all SCSI devices (like SCSI tape drives), not only disks. The only missing part is the ioctl interface to start and stop tracing. This patch adds the SETUP, START, STOP and TEARDOWN ioctls from blktrace to the sg device files. With this change, blktrace can be used for SCSI devices like for disks, e.g.: blktrace -d /dev/sg1 -o - | blkparse -i - Signed-off-by: Christof Schmitt <christof.schmitt@de.ibm.com> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'block/blktrace.c')
-rw-r--r--block/blktrace.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/block/blktrace.c b/block/blktrace.c
index 9b4da4ae3c7d..568588cd16b2 100644
--- a/block/blktrace.c
+++ b/block/blktrace.c
@@ -235,7 +235,7 @@ static void blk_trace_cleanup(struct blk_trace *bt)
235 kfree(bt); 235 kfree(bt);
236} 236}
237 237
238static int blk_trace_remove(struct request_queue *q) 238int blk_trace_remove(struct request_queue *q)
239{ 239{
240 struct blk_trace *bt; 240 struct blk_trace *bt;
241 241
@@ -249,6 +249,7 @@ static int blk_trace_remove(struct request_queue *q)
249 249
250 return 0; 250 return 0;
251} 251}
252EXPORT_SYMBOL_GPL(blk_trace_remove);
252 253
253static int blk_dropped_open(struct inode *inode, struct file *filp) 254static int blk_dropped_open(struct inode *inode, struct file *filp)
254{ 255{
@@ -316,18 +317,17 @@ static struct rchan_callbacks blk_relay_callbacks = {
316/* 317/*
317 * Setup everything required to start tracing 318 * Setup everything required to start tracing
318 */ 319 */
319int do_blk_trace_setup(struct request_queue *q, struct block_device *bdev, 320int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
320 struct blk_user_trace_setup *buts) 321 struct blk_user_trace_setup *buts)
321{ 322{
322 struct blk_trace *old_bt, *bt = NULL; 323 struct blk_trace *old_bt, *bt = NULL;
323 struct dentry *dir = NULL; 324 struct dentry *dir = NULL;
324 char b[BDEVNAME_SIZE];
325 int ret, i; 325 int ret, i;
326 326
327 if (!buts->buf_size || !buts->buf_nr) 327 if (!buts->buf_size || !buts->buf_nr)
328 return -EINVAL; 328 return -EINVAL;
329 329
330 strcpy(buts->name, bdevname(bdev, b)); 330 strcpy(buts->name, name);
331 331
332 /* 332 /*
333 * some device names have larger paths - convert the slashes 333 * some device names have larger paths - convert the slashes
@@ -352,7 +352,7 @@ int do_blk_trace_setup(struct request_queue *q, struct block_device *bdev,
352 goto err; 352 goto err;
353 353
354 bt->dir = dir; 354 bt->dir = dir;
355 bt->dev = bdev->bd_dev; 355 bt->dev = dev;
356 atomic_set(&bt->dropped, 0); 356 atomic_set(&bt->dropped, 0);
357 357
358 ret = -EIO; 358 ret = -EIO;
@@ -399,8 +399,8 @@ err:
399 return ret; 399 return ret;
400} 400}
401 401
402static int blk_trace_setup(struct request_queue *q, struct block_device *bdev, 402int blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
403 char __user *arg) 403 char __user *arg)
404{ 404{
405 struct blk_user_trace_setup buts; 405 struct blk_user_trace_setup buts;
406 int ret; 406 int ret;
@@ -409,7 +409,7 @@ static int blk_trace_setup(struct request_queue *q, struct block_device *bdev,
409 if (ret) 409 if (ret)
410 return -EFAULT; 410 return -EFAULT;
411 411
412 ret = do_blk_trace_setup(q, bdev, &buts); 412 ret = do_blk_trace_setup(q, name, dev, &buts);
413 if (ret) 413 if (ret)
414 return ret; 414 return ret;
415 415
@@ -418,8 +418,9 @@ static int blk_trace_setup(struct request_queue *q, struct block_device *bdev,
418 418
419 return 0; 419 return 0;
420} 420}
421EXPORT_SYMBOL_GPL(blk_trace_setup);
421 422
422static int blk_trace_startstop(struct request_queue *q, int start) 423int blk_trace_startstop(struct request_queue *q, int start)
423{ 424{
424 struct blk_trace *bt; 425 struct blk_trace *bt;
425 int ret; 426 int ret;
@@ -452,6 +453,7 @@ static int blk_trace_startstop(struct request_queue *q, int start)
452 453
453 return ret; 454 return ret;
454} 455}
456EXPORT_SYMBOL_GPL(blk_trace_startstop);
455 457
456/** 458/**
457 * blk_trace_ioctl: - handle the ioctls associated with tracing 459 * blk_trace_ioctl: - handle the ioctls associated with tracing
@@ -464,6 +466,7 @@ int blk_trace_ioctl(struct block_device *bdev, unsigned cmd, char __user *arg)
464{ 466{
465 struct request_queue *q; 467 struct request_queue *q;
466 int ret, start = 0; 468 int ret, start = 0;
469 char b[BDEVNAME_SIZE];
467 470
468 q = bdev_get_queue(bdev); 471 q = bdev_get_queue(bdev);
469 if (!q) 472 if (!q)
@@ -473,7 +476,8 @@ int blk_trace_ioctl(struct block_device *bdev, unsigned cmd, char __user *arg)
473 476
474 switch (cmd) { 477 switch (cmd) {
475 case BLKTRACESETUP: 478 case BLKTRACESETUP:
476 ret = blk_trace_setup(q, bdev, arg); 479 strcpy(b, bdevname(bdev, b));
480 ret = blk_trace_setup(q, b, bdev->bd_dev, arg);
477 break; 481 break;
478 case BLKTRACESTART: 482 case BLKTRACESTART:
479 start = 1; 483 start = 1;