Skip to content

Commit 757d914

Browse files
rostedtaxboe
authored andcommitted
tracing/blktrace: Fix to allow setting same value
Masami Hiramatsu reported: Current trace-enable attribute in sysfs returns an error if user writes the same setting value as current one, e.g. # cat /sys/block/sda/trace/enable 0 # echo 0 > /sys/block/sda/trace/enable bash: echo: write error: Invalid argument # echo 1 > /sys/block/sda/trace/enable # echo 1 > /sys/block/sda/trace/enable bash: echo: write error: Device or resource busy But this is not a preferred behavior, it should ignore if new setting is same as current one. This fixes the problem as below. # cat /sys/block/sda/trace/enable 0 # echo 0 > /sys/block/sda/trace/enable # echo 1 > /sys/block/sda/trace/enable # echo 1 > /sys/block/sda/trace/enable Link: http://lkml.kernel.org/r/[email protected] Cc: Ingo Molnar <[email protected]> Cc: Jens Axboe <[email protected]> Cc: [email protected] Cc: [email protected] Fixes: cd649b8 ("blktrace: remove sysfs_blk_trace_enable_show/store()") Reported-by: Masami Hiramatsu <[email protected]> Tested-by: Masami Hiramatsu <[email protected]> Signed-off-by: Steven Rostedt (VMware) <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 566484a commit 757d914

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

kernel/trace/blktrace.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1841,6 +1841,10 @@ static ssize_t sysfs_blk_trace_attr_store(struct device *dev,
18411841
mutex_lock(&q->blk_trace_mutex);
18421842

18431843
if (attr == &dev_attr_enable) {
1844+
if (!!value == !!q->blk_trace) {
1845+
ret = 0;
1846+
goto out_unlock_bdev;
1847+
}
18441848
if (value)
18451849
ret = blk_trace_setup_queue(q, bdev);
18461850
else

0 commit comments

Comments
 (0)