Skip to contentSkip to conversation

Ask a question

DISCUSSION majianpeng 2 participants 2 messages Jun 29, 2011

lore
Share & tools
lore

majianpeng

author
#0 lore raw

Hi all:
At present,I wanted to use blktrace.So I readed source and founded the problem. Following is my step:
1:mount -t debugfs debugfs /sys/kernel/debug
2:blktrace -d /dev/sdb &
$pid
3:kill -9 $pid
I found some file in /sys/kernel/debug/block.

If a btrace is ruing,but I call ioctl(BLKTRACETEARDOWN)
case BLKTRACETEARDOWN:
ret = blk_trace_remove(q);
int blk_trace_remove(struct request_queue *q)
297 {
298 struct blk_trace *bt;
299
300 bt = xchg(&q->blk_trace, NULL);
301 if (!bt)
302 return -EINVAL;
303
304 if (bt->trace_state != Blktrace_running)
305 blk_trace_cleanup(bt);
306
307 return 0;
308 }
But the btrace is in blktrace_running, so bt did not cleanup. When and Who cleanup btrace?

--------------
majianpeng
2011-06-29

#1 lore raw
Quoted 8 lines · majianpeng

Hi all:
At present,I wanted to use blktrace.So I readed source and founded the problem. Following is my step:
1:mount -t debugfs debugfs /sys/kernel/debug
2:blktrace -d /dev/sdb &
$pid
3:kill -9 $pid
I found some file in /sys/kernel/debug/block.

You shouldn't use -9 to kill it directly. use -2 so that blktrace can capture the signal and exit as expected.

Having said that, blktrace -k /dev/sdb should help in this case.

Thanks
Tao

Quoted 19 lines

If a btrace is ruing,but I call ioctl(BLKTRACETEARDOWN)
case BLKTRACETEARDOWN:
ret = blk_trace_remove(q);
int blk_trace_remove(struct request_queue *q)
297 {
298 struct blk_trace *bt;
299
300 bt = xchg(&q->blk_trace, NULL);
301 if (!bt)
302 return -EINVAL;
303
304 if (bt->trace_state != Blktrace_running)
305 blk_trace_cleanup(bt);
306
307 return 0;
308 }
But the btrace is in blktrace_running, so bt did not cleanup. When and Who cleanup btrace?