linux-btrace.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] blktrace: fix to trace a partition, instead of only disk
@ 2008-12-17  6:02 Shawn Du
  2008-12-17  8:01 ` Jens Axboe
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Shawn Du @ 2008-12-17  6:02 UTC (permalink / raw)
  To: linux-btrace

I made some changes to block/blktrace.c to make it able to trace a partition as the -d option specified.
Doing so by simply using start_lba and end_lba, these two parameters are not passed in from user space,but figured out by do_blk_trace_setup() in kernel. 

From: Shawn Du <duyuyang@gmail.com>
Date: Wed, 17 Dec 2008 11:57:46 +0800
Subject: [PATCH] Trace a partition
Signed-off-by: Shawn Du <duyuyang@gmail.com>
---
 block/blktrace.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/block/blktrace.c b/block/blktrace.c
index 85049a7..b8ea04c 100644
--- a/block/blktrace.c
+++ b/block/blktrace.c
@@ -420,10 +420,13 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
 	if (!bt->act_mask)
 		bt->act_mask = (u16) -1;
 
-	bt->start_lba = buts->start_lba;
-	bt->end_lba = buts->end_lba;
-	if (!bt->end_lba)
+	if (bdev->bd_part) {
+		bt->start_lba = bdev->bd_part->start_sect;
+		bt->end_lba = bt->start_lba + bdev->bd_part->nr_sects;
+	} else {
+		bt->start_lba = 0;
 		bt->end_lba = -1ULL;
+	}
 
 	bt->pid = buts->pid;
 	bt->trace_state = Blktrace_setup;
-- 
1.5.2.5


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] blktrace: fix to trace a partition, instead of only disk
  2008-12-17  6:02 [PATCH] blktrace: fix to trace a partition, instead of only disk Shawn Du
@ 2008-12-17  8:01 ` Jens Axboe
  2008-12-31  2:21 ` Re: Re: [PATCH] blktrace: fix to trace a partition, instead of Shawn Du
  2009-01-05  9:18 ` Re: Re: [PATCH] blktrace: fix to trace a partition, instead of only disk Jens Axboe
  2 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2008-12-17  8:01 UTC (permalink / raw)
  To: linux-btrace

On Wed, Dec 17 2008, Shawn Du wrote:
> I made some changes to block/blktrace.c to make it able to trace a partition as the -d option specified.
> Doing so by simply using start_lba and end_lba, these two parameters are not passed in from user space,but figured out by do_blk_trace_setup() in kernel. 
> 
> From: Shawn Du <duyuyang@gmail.com>
> Date: Wed, 17 Dec 2008 11:57:46 +0800
> Subject: [PATCH] Trace a partition
> Signed-off-by: Shawn Du <duyuyang@gmail.com>
> ---
>  block/blktrace.c |    9 ++++++---
>  1 files changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/block/blktrace.c b/block/blktrace.c
> index 85049a7..b8ea04c 100644
> --- a/block/blktrace.c
> +++ b/block/blktrace.c
> @@ -420,10 +420,13 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
>  	if (!bt->act_mask)
>  		bt->act_mask = (u16) -1;
>  
> -	bt->start_lba = buts->start_lba;
> -	bt->end_lba = buts->end_lba;
> -	if (!bt->end_lba)
> +	if (bdev->bd_part) {
> +		bt->start_lba = bdev->bd_part->start_sect;
> +		bt->end_lba = bt->start_lba + bdev->bd_part->nr_sects;
> +	} else {
> +		bt->start_lba = 0;
>  		bt->end_lba = -1ULL;
> +	}
>  
>  	bt->pid = buts->pid;
>  	bt->trace_state = Blktrace_setup;
> -- 
> 1.5.2.5

Very nice! The only problem with this is that we have actions that are,
by definition, per device. So we probably want to include any sector
that is within the range of the partition, AND a zero sector. So that
means changing act_log_check() to something ala:

-       if (sector < bt->start_lba || sector > bt->end_lba)
+       if (!sector || sector < bt->start_lba || sector > bt->end_lba)
                return 1;

in pseudo patch form.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Re: Re: [PATCH] blktrace: fix to trace a partition, instead of
  2008-12-17  6:02 [PATCH] blktrace: fix to trace a partition, instead of only disk Shawn Du
  2008-12-17  8:01 ` Jens Axboe
@ 2008-12-31  2:21 ` Shawn Du
  2009-01-05  9:18 ` Re: Re: [PATCH] blktrace: fix to trace a partition, instead of only disk Jens Axboe
  2 siblings, 0 replies; 4+ messages in thread
From: Shawn Du @ 2008-12-31  2:21 UTC (permalink / raw)
  To: linux-btrace

>Very nice! The only problem with this is that we have actions that are,
>by definition, per device. So we probably want to include any sector
>that is within the range of the partition, AND a zero sector. So that
>means changing act_log_check() to something ala:
>
>-       if (sector < bt->start_lba || sector > bt->end_lba)
>+       if (!sector || sector < bt->start_lba || sector > bt->end_lba)
>                return 1;
>
>in pseudo patch form.

Thank you sir. And perhaps, we change in __blk_add_trace():

-	if (unlikely(act_log_check(bt, what, sector, pid)))
+	if (act_log_check(bt, what, sector, pid))

Sorry for the lateness.

Happy New Year.

Shawn


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Re: Re: [PATCH] blktrace: fix to trace a partition, instead of only disk
  2008-12-17  6:02 [PATCH] blktrace: fix to trace a partition, instead of only disk Shawn Du
  2008-12-17  8:01 ` Jens Axboe
  2008-12-31  2:21 ` Re: Re: [PATCH] blktrace: fix to trace a partition, instead of Shawn Du
@ 2009-01-05  9:18 ` Jens Axboe
  2 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2009-01-05  9:18 UTC (permalink / raw)
  To: linux-btrace

On Wed, Dec 31 2008, Shawn Du wrote:
> >Very nice! The only problem with this is that we have actions that are,
> >by definition, per device. So we probably want to include any sector
> >that is within the range of the partition, AND a zero sector. So that
> >means changing act_log_check() to something ala:
> >
> >-       if (sector < bt->start_lba || sector > bt->end_lba)
> >+       if (!sector || sector < bt->start_lba || sector > bt->end_lba)
> >                return 1;
> >
> >in pseudo patch form.
> 
> Thank you sir. And perhaps, we change in __blk_add_trace():
> 
> -	if (unlikely(act_log_check(bt, what, sector, pid)))
> +	if (act_log_check(bt, what, sector, pid))

Sure, lets get rid of it.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-01-05  9:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-17  6:02 [PATCH] blktrace: fix to trace a partition, instead of only disk Shawn Du
2008-12-17  8:01 ` Jens Axboe
2008-12-31  2:21 ` Re: Re: [PATCH] blktrace: fix to trace a partition, instead of Shawn Du
2009-01-05  9:18 ` Re: Re: [PATCH] blktrace: fix to trace a partition, instead of only disk Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).