linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Luis Chamberlain <mcgrof@kernel.org>
Cc: axboe@kernel.dk, viro@zeniv.linux.org.uk, bvanassche@acm.org,
	rostedt@goodmis.org, mingo@redhat.com, jack@suse.cz,
	ming.lei@redhat.com, nstange@suse.de, akpm@linux-foundation.org,
	mhocko@suse.com, yukuai3@huawei.com, linux-block@vger.kernel.org,
	linux-fsdevel@vger.kernel.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 5/6] blktrace: break out of blktrace setup on concurrent calls
Date: Wed, 29 Apr 2020 11:49:37 +0200	[thread overview]
Message-ID: <20200429094937.GB2081185@kroah.com> (raw)
In-Reply-To: <20200429074627.5955-6-mcgrof@kernel.org>

On Wed, Apr 29, 2020 at 07:46:26AM +0000, Luis Chamberlain wrote:
> 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>
> ---
>  kernel/trace/blktrace.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
> index 5c52976bd762..383045f67cb8 100644
> --- a/kernel/trace/blktrace.c
> +++ b/kernel/trace/blktrace.c
> @@ -4,6 +4,8 @@
>   *
>   */
>  
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +
>  #include <linux/kernel.h>
>  #include <linux/blkdev.h>
>  #include <linux/blktrace_api.h>
> @@ -516,6 +518,11 @@ static int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
>  	 */
>  	strreplace(buts->name, '/', '_');
>  
> +	if (q->blk_trace) {
> +		pr_warn("Concurrent blktraces are not allowed\n");
> +		return -EBUSY;

You have access to a block device here, please use dev_warn() instead
here for that, that makes it obvious as to what device a "concurrent
blktrace" was attempted for.

thanks,

greg k-h

  reply	other threads:[~2020-04-29  9:49 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-29  7:46 [PATCH v3 0/6] block: fix blktrace debugfs use after free Luis Chamberlain
2020-04-29  7:46 ` [PATCH v3 1/6] block: revert back to synchronous request_queue removal Luis Chamberlain
2020-04-29 11:15   ` Christoph Hellwig
2020-05-02  0:22   ` Bart Van Assche
2020-05-03 10:32     ` Matthew Wilcox
2020-05-04 16:18       ` Luis Chamberlain
2020-05-04 16:16     ` Luis Chamberlain
2020-04-29  7:46 ` [PATCH v3 2/6] block: move main block debugfs initialization to its own file Luis Chamberlain
2020-04-29 11:15   ` Christoph Hellwig
2020-04-29  7:46 ` [PATCH v3 3/6] blktrace: move blktrace debugfs creation to helper function Luis Chamberlain
2020-04-29 11:20   ` Christoph Hellwig
2020-05-02  0:25   ` Bart Van Assche
2020-04-29  7:46 ` [PATCH v3 4/6] blktrace: fix debugfs use after free Luis Chamberlain
2020-04-29  9:47   ` Greg KH
2020-04-29 11:26   ` Christoph Hellwig
2020-04-29 11:45     ` Luis Chamberlain
2020-04-29 11:50       ` Christoph Hellwig
2020-04-29 12:02         ` Luis Chamberlain
2020-04-29 12:04           ` Christoph Hellwig
2020-04-29 12:21             ` Luis Chamberlain
2020-04-29 12:57               ` Greg KH
2020-05-01 15:24                 ` Luis Chamberlain
2020-04-29  7:46 ` [PATCH v3 5/6] blktrace: break out of blktrace setup on concurrent calls Luis Chamberlain
2020-04-29  9:49   ` Greg KH [this message]
2020-05-01 15:06     ` Luis Chamberlain
2020-05-01 15:34       ` Christoph Hellwig
2020-05-01 15:40         ` Luis Chamberlain
2020-05-01 15:50           ` Luis Chamberlain
2020-05-01 16:51       ` Greg KH
2020-04-29  7:46 ` [PATCH v3 6/6] loop: be paranoid on exit and prevent new additions / removals Luis Chamberlain
2020-04-29  9:50   ` Greg KH
2020-05-03  9:09     ` Luis Chamberlain
2020-04-29 14:05   ` Ming Lei

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=20200429094937.GB2081185@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=akpm@linux-foundation.org \
    --cc=axboe@kernel.dk \
    --cc=bvanassche@acm.org \
    --cc=jack@suse.cz \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mcgrof@kernel.org \
    --cc=mhocko@suse.com \
    --cc=ming.lei@redhat.com \
    --cc=mingo@redhat.com \
    --cc=nstange@suse.de \
    --cc=rostedt@goodmis.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=yukuai3@huawei.com \
    /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;
as well as URLs for NNTP newsgroup(s).