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.c39
1 files changed, 25 insertions, 14 deletions
diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
index e932654cf590..d10989880520 100644
--- a/kernel/trace/blktrace.c
+++ b/kernel/trace/blktrace.c
@@ -403,6 +403,23 @@ static struct rchan_callbacks blk_relay_callbacks = {
403 .remove_buf_file = blk_remove_buf_file_callback, 403 .remove_buf_file = blk_remove_buf_file_callback,
404}; 404};
405 405
406static void blk_trace_setup_lba(struct blk_trace *bt,
407 struct block_device *bdev)
408{
409 struct hd_struct *part = NULL;
410
411 if (bdev)
412 part = bdev->bd_part;
413
414 if (part) {
415 bt->start_lba = part->start_sect;
416 bt->end_lba = part->start_sect + part->nr_sects;
417 } else {
418 bt->start_lba = 0;
419 bt->end_lba = -1ULL;
420 }
421}
422
406/* 423/*
407 * Setup everything required to start tracing 424 * Setup everything required to start tracing
408 */ 425 */
@@ -413,7 +430,6 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
413 struct blk_trace *old_bt, *bt = NULL; 430 struct blk_trace *old_bt, *bt = NULL;
414 struct dentry *dir = NULL; 431 struct dentry *dir = NULL;
415 int ret, i; 432 int ret, i;
416 struct hd_struct *part = NULL;
417 433
418 if (!buts->buf_size || !buts->buf_nr) 434 if (!buts->buf_size || !buts->buf_nr)
419 return -EINVAL; 435 return -EINVAL;
@@ -482,14 +498,7 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
482 if (!bt->act_mask) 498 if (!bt->act_mask)
483 bt->act_mask = (u16) -1; 499 bt->act_mask = (u16) -1;
484 500
485 if (bdev) 501 blk_trace_setup_lba(bt, bdev);
486 part = bdev->bd_part;
487
488 if (part) {
489 bt->start_lba = part->start_sect;
490 bt->end_lba = part->start_sect + part->nr_sects;
491 } else
492 bt->end_lba = -1ULL;
493 502
494 /* overwrite with user settings */ 503 /* overwrite with user settings */
495 if (buts->start_lba) 504 if (buts->start_lba)
@@ -1370,7 +1379,8 @@ static int blk_trace_remove_queue(struct request_queue *q)
1370/* 1379/*
1371 * Setup everything required to start tracing 1380 * Setup everything required to start tracing
1372 */ 1381 */
1373static int blk_trace_setup_queue(struct request_queue *q, dev_t dev) 1382static int blk_trace_setup_queue(struct request_queue *q,
1383 struct block_device *bdev)
1374{ 1384{
1375 struct blk_trace *old_bt, *bt = NULL; 1385 struct blk_trace *old_bt, *bt = NULL;
1376 int ret = -ENOMEM; 1386 int ret = -ENOMEM;
@@ -1383,9 +1393,10 @@ static int blk_trace_setup_queue(struct request_queue *q, dev_t dev)
1383 if (!bt->msg_data) 1393 if (!bt->msg_data)
1384 goto free_bt; 1394 goto free_bt;
1385 1395
1386 bt->dev = dev; 1396 bt->dev = bdev->bd_dev;
1387 bt->act_mask = (u16)-1; 1397 bt->act_mask = (u16)-1;
1388 bt->end_lba = -1ULL; 1398
1399 blk_trace_setup_lba(bt, bdev);
1389 1400
1390 old_bt = xchg(&q->blk_trace, bt); 1401 old_bt = xchg(&q->blk_trace, bt);
1391 if (old_bt != NULL) { 1402 if (old_bt != NULL) {
@@ -1602,7 +1613,7 @@ static ssize_t sysfs_blk_trace_attr_store(struct device *dev,
1602 1613
1603 if (attr == &dev_attr_enable) { 1614 if (attr == &dev_attr_enable) {
1604 if (value) 1615 if (value)
1605 ret = blk_trace_setup_queue(q, bdev->bd_dev); 1616 ret = blk_trace_setup_queue(q, bdev);
1606 else 1617 else
1607 ret = blk_trace_remove_queue(q); 1618 ret = blk_trace_remove_queue(q);
1608 goto out_unlock_bdev; 1619 goto out_unlock_bdev;
@@ -1610,7 +1621,7 @@ static ssize_t sysfs_blk_trace_attr_store(struct device *dev,
1610 1621
1611 ret = 0; 1622 ret = 0;
1612 if (q->blk_trace == NULL) 1623 if (q->blk_trace == NULL)
1613 ret = blk_trace_setup_queue(q, bdev->bd_dev); 1624 ret = blk_trace_setup_queue(q, bdev);
1614 1625
1615 if (ret == 0) { 1626 if (ret == 0) {
1616 if (attr == &dev_attr_act_mask) 1627 if (attr == &dev_attr_act_mask)