diff options
author | Christof Schmitt <christof.schmitt@de.ibm.com> | 2008-01-11 04:09:43 -0500 |
---|---|---|
committer | Jens Axboe <jens.axboe@oracle.com> | 2008-01-28 04:04:46 -0500 |
commit | 6da127ad0918f93ea93678dad62ce15ffed18797 (patch) | |
tree | b2bf9ad228f18c643342ad376136d2f6b4be4137 /block | |
parent | 91525300baf162e83e923b09ca286f9205e21522 (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')
-rw-r--r-- | block/blktrace.c | 24 | ||||
-rw-r--r-- | block/compat_ioctl.c | 5 |
2 files changed, 18 insertions, 11 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 | ||
238 | static int blk_trace_remove(struct request_queue *q) | 238 | int 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 | } |
252 | EXPORT_SYMBOL_GPL(blk_trace_remove); | ||
252 | 253 | ||
253 | static int blk_dropped_open(struct inode *inode, struct file *filp) | 254 | static 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 | */ |
319 | int do_blk_trace_setup(struct request_queue *q, struct block_device *bdev, | 320 | int 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 | ||
402 | static int blk_trace_setup(struct request_queue *q, struct block_device *bdev, | 402 | int 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 | } |
421 | EXPORT_SYMBOL_GPL(blk_trace_setup); | ||
421 | 422 | ||
422 | static int blk_trace_startstop(struct request_queue *q, int start) | 423 | int 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 | } |
456 | EXPORT_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; |
diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c index cae0a852619e..b73373216b0e 100644 --- a/block/compat_ioctl.c +++ b/block/compat_ioctl.c | |||
@@ -545,6 +545,7 @@ static int compat_blk_trace_setup(struct block_device *bdev, char __user *arg) | |||
545 | struct blk_user_trace_setup buts; | 545 | struct blk_user_trace_setup buts; |
546 | struct compat_blk_user_trace_setup cbuts; | 546 | struct compat_blk_user_trace_setup cbuts; |
547 | struct request_queue *q; | 547 | struct request_queue *q; |
548 | char b[BDEVNAME_SIZE]; | ||
548 | int ret; | 549 | int ret; |
549 | 550 | ||
550 | q = bdev_get_queue(bdev); | 551 | q = bdev_get_queue(bdev); |
@@ -554,6 +555,8 @@ static int compat_blk_trace_setup(struct block_device *bdev, char __user *arg) | |||
554 | if (copy_from_user(&cbuts, arg, sizeof(cbuts))) | 555 | if (copy_from_user(&cbuts, arg, sizeof(cbuts))) |
555 | return -EFAULT; | 556 | return -EFAULT; |
556 | 557 | ||
558 | strcpy(b, bdevname(bdev, b)); | ||
559 | |||
557 | buts = (struct blk_user_trace_setup) { | 560 | buts = (struct blk_user_trace_setup) { |
558 | .act_mask = cbuts.act_mask, | 561 | .act_mask = cbuts.act_mask, |
559 | .buf_size = cbuts.buf_size, | 562 | .buf_size = cbuts.buf_size, |
@@ -565,7 +568,7 @@ static int compat_blk_trace_setup(struct block_device *bdev, char __user *arg) | |||
565 | memcpy(&buts.name, &cbuts.name, 32); | 568 | memcpy(&buts.name, &cbuts.name, 32); |
566 | 569 | ||
567 | mutex_lock(&bdev->bd_mutex); | 570 | mutex_lock(&bdev->bd_mutex); |
568 | ret = do_blk_trace_setup(q, bdev, &buts); | 571 | ret = do_blk_trace_setup(q, b, bdev->bd_dev, &buts); |
569 | mutex_unlock(&bdev->bd_mutex); | 572 | mutex_unlock(&bdev->bd_mutex); |
570 | if (ret) | 573 | if (ret) |
571 | return ret; | 574 | return ret; |