From: Ming Lei <ming.lei@redhat.com>
To: Hannes Reinecke <hare@suse.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Jens Axboe <axboe@kernel.dk>,
linux-block@vger.kernel.org, Christoph Hellwig <hch@lst.de>,
Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>,
Dan Williams <dan.j.williams@intel.com>,
yukuai <yukuai3@huawei.com>
Subject: Re: [PATCH V2 2/2] block: fix "Directory XXXXX with parent 'block' already present!"
Date: Tue, 26 Apr 2022 11:07:43 +0800 [thread overview]
Message-ID: <Ymdh/0MpsjxUV48z@T590> (raw)
In-Reply-To: <186f4002-0359-95e7-889f-af065210cd74@suse.de>
On Mon, Apr 25, 2022 at 11:32:15AM +0200, Hannes Reinecke wrote:
> On 4/25/22 11:07, Ming Lei wrote:
> > On Mon, Apr 25, 2022 at 07:10:46AM +0200, Greg Kroah-Hartman wrote:
> > > On Mon, Apr 25, 2022 at 09:28:27AM +0800, Ming Lei wrote:
> > > > On Sun, Apr 24, 2022 at 03:45:59PM +0200, Greg Kroah-Hartman wrote:
> > > > > On Sun, Apr 24, 2022 at 08:04:59PM +0800, Ming Lei wrote:
> > > > > > On Sun, Apr 24, 2022 at 01:51:45PM +0200, Hannes Reinecke wrote:
> > > > > > > On 4/24/22 11:28, Ming Lei wrote:
> > > > > > > > On Sun, Apr 24, 2022 at 10:53:29AM +0200, Hannes Reinecke wrote:
> > > > > > > > > On 4/23/22 16:39, Ming Lei wrote:
> > > > > > > > > > q->debugfs_dir is used by blk-mq debugfs and blktrace. The dentry is
> > > > > > > > > > created when adding disk, and removed when releasing request queue.
> > > > > > > > > >
> > > > > > > > > > There is small window between releasing disk and releasing request
> > > > > > > > > > queue, and during the period, one disk with same name may be created
> > > > > > > > > > and added, so debugfs_create_dir() may complain with "Directory XXXXX
> > > > > > > > > > with parent 'block' already present!"
> > > > > > > > > >
> > > > > > > > > > Fixes the issue by moving debugfs_create_dir() into blk_alloc_queue(),
> > > > > > > > > > and the dir name is named with q->id from beginning, and switched to
> > > > > > > > > > disk name when adding disk, and finally changed to q->id in disk_release().
> > > > > > > > > >
> > > > > > > > > > Tested-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
> > > > > > > > > > Reported-by: Dan Williams <dan.j.williams@intel.com>
> > > > > > > > > > Cc: yukuai (C) <yukuai3@huawei.com>
> > > > > > > > > > Cc: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
> > > > > > > > > > Signed-off-by: Ming Lei <ming.lei@redhat.com>
> > > > > > > > > > ---
> > > > > > > > > > block/blk-core.c | 4 ++++
> > > > > > > > > > block/blk-sysfs.c | 4 ++--
> > > > > > > > > > block/genhd.c | 8 ++++++++
> > > > > > > > > > 3 files changed, 14 insertions(+), 2 deletions(-)
> > > > > > > > > >
> > > > > > > > > Errm.
> > > > > > > > >
> > > > > > > > > Isn't this superfluous now that Jens merged Yu Kuais patch?
> > > > > > > >
> > > > > > > > Jens has dropped Yu Kuai's patch which caused kernel panic.
> > > > > > > >
> > > > > > > Right.
> > > > > > > But still, this patch looks really odd.
> > > > > > > How is userspace supposed to use the directories prior to the renaming?
> > > > > >
> > > > > > That doesn't make any difference for current uses, but we may extend it
> > > > > > to support debugfs for non-blk request queue in future by exporting q->id
> > > > > > somewhere. Even though now the interested q->id can be figured out
> > > > > > easily by very simple ebpf trace prog.
> > > > > >
> > > > > > >
> > > > > > > And as you already have identified the places where we can safely create
> > > > > > > (and remove) the debugfs directories, why can't we move the call to create
> > > > > > > and remove the debugfs directories to those locations and do away with the
> > > > > > > renaming?
> > > > > >
> > > > > > First it needs more change to fix the kernel panic.
> > > > > >
> > > > > > Second removing debugfs dir in del_gendisk will break blktests block/002.
> > > > >
> > > > > Then fix the test? debugfs interactions that cause kernel bugs should
> > > > > be ok to change the functionality of. Remember, this is for
> > > > > debugging...
> > > >
> > > > But what is wrong with the test? Isn't it reasonable to keep debugfs dir
> > > > when blktrace is collecting log?
> > >
> > > How can you collect something from a device that is gone?
> >
> > Here the 'gone' may be just in logical/soft viewpoint, such as, one disk
> > is removed by sysfs, and the driver still may send sync cache command
> > to make sure the cache inside drive is flushed, such as scsi's
> > SYNCHRONIZE_CACHE.
> >
> And that is my argument: what does this buy us?
Isn't the posted patch simple enough for fixing the whole issue?
Not only in lines of code, but also in principle.
So far q->debugfs_dir is used by elevator, rq_qos, blktrace and blk-mq
debugfs.
The 1st three can have same lifetime with gendisk, but blk-mq debugfs
more share same lifetime with request_queue.
That is why I make ->debugfs_dir sharing same lifetime with request
queue since request queue has longer lifetime than gendisk.
With this way, we can clean the mess for delaying to add blk-mq debugfs.
Not mention this approach can allow us to add debugfs support for
non-disk request queue.
> Is is relevant (for blktrace) to have the SYNCHRONIZE_CACHE to be present in
> the logs?
SYNCHRONIZE_CACHE is just one example, and there can be more from
/dev/sg or kernel. As one user of trace tool, it is important to get
intact request trace.
> From my POV, blktrace is there to analyze I/O flow; device shutdown is not
> really relevant for that as the results of that operation depend on other
> factors which won't show up in blktrace at all.
>
> So we're not losing much by (maybe) missing shutdown commands in blktrace;
> if needs be device shutdown can be traced by other means.
>
> I'd rather keep the code simple, and not having an operation in the core
> block layer which requires quite some explanation.
Please write one workable patch following your idea, then compare yours
and this patch, then you will see which one is simpler.
Thanks,
Ming
next prev parent reply other threads:[~2022-04-26 3:08 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-23 14:39 [PATCH V2 0/2] block: fix "Directory XXXXX with parent 'block' already present!" Ming Lei
2022-04-23 14:39 ` [PATCH V2 1/2] debugfs: fix declaration of debugfs_rename Ming Lei
2022-04-23 14:39 ` [PATCH V2 2/2] block: fix "Directory XXXXX with parent 'block' already present!" Ming Lei
2022-04-23 16:29 ` Christoph Hellwig
2022-04-24 9:24 ` Ming Lei
2022-04-25 7:49 ` Christoph Hellwig
2022-04-25 9:18 ` Ming Lei
2022-04-24 8:53 ` Hannes Reinecke
2022-04-24 9:28 ` Ming Lei
2022-04-24 11:51 ` Hannes Reinecke
2022-04-24 12:04 ` Ming Lei
2022-04-24 13:45 ` Greg Kroah-Hartman
2022-04-25 1:28 ` Ming Lei
2022-04-25 5:10 ` Greg Kroah-Hartman
2022-04-25 7:48 ` Christoph Hellwig
2022-04-25 7:53 ` Hannes Reinecke
2022-04-25 9:07 ` Ming Lei
2022-04-25 9:32 ` Hannes Reinecke
2022-04-26 3:07 ` Ming Lei [this message]
2022-05-23 13:11 ` Yu Kuai
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=Ymdh/0MpsjxUV48z@T590 \
--to=ming.lei@redhat.com \
--cc=axboe@kernel.dk \
--cc=dan.j.williams@intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=hare@suse.de \
--cc=hch@lst.de \
--cc=linux-block@vger.kernel.org \
--cc=shinichiro.kawasaki@wdc.com \
--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