From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Luis Chamberlain <mcgrof@kernel.org>, Jan Kara <jack@suse.cz>,
Bart Van Assche <bvanassche@acm.org>,
Christoph Hellwig <hch@lst.de>, Jens Axboe <axboe@kernel.dk>,
Sasha Levin <sashal@kernel.org>,
linux-block@vger.kernel.org
Subject: [PATCH AUTOSEL 4.19 14/15] blktrace: break out of blktrace setup on concurrent calls
Date: Tue, 23 Jun 2020 13:36:29 -0400 [thread overview]
Message-ID: <20200623173630.1355971-14-sashal@kernel.org> (raw)
In-Reply-To: <20200623173630.1355971-1-sashal@kernel.org>
From: Luis Chamberlain <mcgrof@kernel.org>
[ Upstream commit 1b0b283648163dae2a214ca28ed5a99f62a77319 ]
We use one blktrace per request_queue, that means one per the entire
disk. So we cannot run one blktrace on say /dev/vda and then /dev/vda1,
or just two calls on /dev/vda.
We check for concurrent setup only at the very end of the blktrace setup though.
If we try to run two concurrent blktraces on the same block device the
second one will fail, and the first one seems to go on. However when
one tries to kill the first one one will see things like this:
The kernel will show these:
```
debugfs: File 'dropped' in directory 'nvme1n1' already present!
debugfs: File 'msg' in directory 'nvme1n1' already present!
debugfs: File 'trace0' in directory 'nvme1n1' already present!
``
And userspace just sees this error message for the second call:
```
blktrace /dev/nvme1n1
BLKTRACESETUP(2) /dev/nvme1n1 failed: 5/Input/output error
```
The first userspace process #1 will also claim that the files
were taken underneath their nose as well. The files are taken
away form the first process given that when the second blktrace
fails, it will follow up with a BLKTRACESTOP and BLKTRACETEARDOWN.
This means that even if go-happy process #1 is waiting for blktrace
data, we *have* been asked to take teardown the blktrace.
This can easily be reproduced with break-blktrace [0] run_0005.sh test.
Just break out early if we know we're already going to fail, this will
prevent trying to create the files all over again, which we know still
exist.
[0] https://github.com/mcgrof/break-blktrace
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
Signed-off-by: Jan Kara <jack@suse.cz>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
kernel/trace/blktrace.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
index 6cea8bbca03cb..c774b0ad0525b 100644
--- a/kernel/trace/blktrace.c
+++ b/kernel/trace/blktrace.c
@@ -3,6 +3,9 @@
* Copyright (C) 2006 Jens Axboe <axboe@kernel.dk>
*
*/
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
#include <linux/kernel.h>
#include <linux/blkdev.h>
#include <linux/blktrace_api.h>
@@ -495,6 +498,16 @@ static int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
*/
strreplace(buts->name, '/', '_');
+ /*
+ * bdev can be NULL, as with scsi-generic, this is a helpful as
+ * we can be.
+ */
+ if (q->blk_trace) {
+ pr_warn("Concurrent blktraces are not allowed on %s\n",
+ buts->name);
+ return -EBUSY;
+ }
+
bt = kzalloc(sizeof(*bt), GFP_KERNEL);
if (!bt)
return -ENOMEM;
--
2.25.1
next prev parent reply other threads:[~2020-06-23 17:38 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-23 17:36 [PATCH AUTOSEL 4.19 01/15] sata_rcar: handle pm_runtime_get_sync failure cases Sasha Levin
2020-06-23 17:36 ` [PATCH AUTOSEL 4.19 02/15] ata/libata: Fix usage of page address by page_address in ata_scsi_mode_select_xlat function Sasha Levin
2020-06-23 17:36 ` [PATCH AUTOSEL 4.19 03/15] drm/amd/display: Use kfree() to free rgb_user in calculate_user_regamma_ramp() Sasha Levin
2020-06-23 17:36 ` [PATCH AUTOSEL 4.19 04/15] riscv/atomic: Fix sign extension for RV64I Sasha Levin
2020-06-23 17:36 ` [PATCH AUTOSEL 4.19 05/15] hwrng: ks-sa - Fix runtime PM imbalance on error Sasha Levin
2020-06-23 17:36 ` [PATCH AUTOSEL 4.19 06/15] arm64/sve: Eliminate data races on sve_default_vl Sasha Levin
2020-06-23 17:36 ` [PATCH AUTOSEL 4.19 07/15] ibmvnic: Harden device login requests Sasha Levin
2020-06-23 17:36 ` [PATCH AUTOSEL 4.19 08/15] net: alx: fix race condition in alx_remove Sasha Levin
2020-06-23 17:36 ` [PATCH AUTOSEL 4.19 09/15] rocker: fix incorrect error handling in dma_rings_init Sasha Levin
2020-06-23 17:36 ` [PATCH AUTOSEL 4.19 10/15] s390/ptrace: fix setting syscall number Sasha Levin
2020-06-23 17:36 ` [PATCH AUTOSEL 4.19 11/15] s390/vdso: fix vDSO clock_getres() Sasha Levin
2020-06-23 17:36 ` [PATCH AUTOSEL 4.19 12/15] arm64: sve: Fix build failure when ARM64_SVE=y and SYSCTL=n Sasha Levin
2020-06-23 17:36 ` [PATCH AUTOSEL 4.19 13/15] kbuild: improve cc-option to clean up all temporary files Sasha Levin
2020-06-23 17:36 ` Sasha Levin [this message]
2020-06-23 17:36 ` [PATCH AUTOSEL 4.19 15/15] RISC-V: Don't allow write+exec only page mapping request in mmap Sasha Levin
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=20200623173630.1355971-14-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=axboe@kernel.dk \
--cc=bvanassche@acm.org \
--cc=hch@lst.de \
--cc=jack@suse.cz \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mcgrof@kernel.org \
--cc=stable@vger.kernel.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