From: Masami Hiramatsu <mhiramat@kernel.org>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Ingo Molnar <mingo@redhat.com>,
Masami Hiramatsu <mhiramat@kernel.org>,
linux-kernel@vger.kernel.org, Jens Axboe <axboe@kernel.dk>,
linux-block@vger.kernel.org
Subject: [PATCH 2/2] tracing/blktrace: Fix to allow setting same value
Date: Thu, 16 Aug 2018 18:51:15 +0900 [thread overview]
Message-ID: <153441307534.6024.2684721209411781531.stgit@devbox> (raw)
In-Reply-To: <153441301698.6024.1680500212551396320.stgit@devbox>
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
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org
---
kernel/trace/blktrace.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
index 987d9a9ae283..e67db1e8a000 100644
--- a/kernel/trace/blktrace.c
+++ b/kernel/trace/blktrace.c
@@ -1602,11 +1602,11 @@ static int blk_trace_remove_queue(struct request_queue *q)
struct blk_trace *bt;
bt = xchg(&q->blk_trace, NULL);
- if (bt == NULL)
- return -EINVAL;
+ if (bt != NULL) {
+ put_probe_ref();
+ blk_trace_free(bt);
+ }
- put_probe_ref();
- blk_trace_free(bt);
return 0;
}
@@ -1619,6 +1619,9 @@ static int blk_trace_setup_queue(struct request_queue *q,
struct blk_trace *bt = NULL;
int ret = -ENOMEM;
+ if (q->blk_trace)
+ return 0;
+
bt = kzalloc(sizeof(*bt), GFP_KERNEL);
if (!bt)
return -ENOMEM;
next prev parent reply other threads:[~2018-08-16 9:51 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-16 9:50 [PATCH 0/2] tracing: Fix document and blktrace Masami Hiramatsu
2018-08-16 9:50 ` [PATCH 1/2] docs: tracing: Add stacktrace filter command Masami Hiramatsu
2018-08-16 12:50 ` Steven Rostedt
2018-08-31 22:35 ` Jonathan Corbet
2018-08-16 9:51 ` Masami Hiramatsu [this message]
2018-08-16 14:38 ` [PATCH 2/2] tracing/blktrace: Fix to allow setting same value Steven Rostedt
2018-08-16 16:38 ` Masami Hiramatsu
2018-08-16 16:49 ` Steven Rostedt
2018-08-16 17:07 ` Masami Hiramatsu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=153441307534.6024.2684721209411781531.stgit@devbox \
--to=mhiramat@kernel.org \
--cc=axboe@kernel.dk \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=rostedt@goodmis.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox