Commit cbde057a authored by Steven Rostedt (VMware)'s avatar Steven Rostedt (VMware) Committed by Greg Kroah-Hartman

tracing/blktrace: Fix to allow setting same value

commit 757d9140 upstream.

Masami Hiramatsu reported:

  Current trace-enable attribute in sysfs returns an error
  if user writes the same setting value as current one,

    # cat /sys/block/sda/trace/enable
    # 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
    # echo 0 > /sys/block/sda/trace/enable
    # echo 1 > /sys/block/sda/trace/enable
    # echo 1 > /sys/block/sda/trace/enable


Cc: Ingo Molnar <>
Cc: Jens Axboe <>
Fixes: cd649b8b ("blktrace: remove sysfs_blk_trace_enable_show/store()")
Reported-by: default avatarMasami Hiramatsu <>
Tested-by: default avatarMasami Hiramatsu <>
Signed-off-by: default avatarSteven Rostedt (VMware) <>
Signed-off-by: default avatarJens Axboe <>
Signed-off-by: default avatarGreg Kroah-Hartman <>
parent 4c901675
......@@ -1809,6 +1809,10 @@ static ssize_t sysfs_blk_trace_attr_store(struct device *dev,
if (attr == &dev_attr_enable) {
if (!!value == !!q->blk_trace) {
ret = 0;
goto out_unlock_bdev;
if (value)
ret = blk_trace_setup_queue(q, bdev);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment