From: NeilBrown <neilb@suse.de>
To: Christoph Hellwig <hch@lst.de>
Cc: Azat Khuzhin <a3at.mail@gmail.com>,
"Kernel.org-Linux-RAID" <linux-raid@vger.kernel.org>,
Guoqing Jiang <GQJiang@suse.com>, Tejun Heo <tj@kernel.org>,
Jan Kara <jack@suse.cz>, Jens Axboe <axboe@fb.com>,
dm-devel@redhat.com
Subject: Re: Bisected, with rfc/patch - was Re: BUG: unable to handle kernel NULL pointer dereference at sysfs_do_create_link_sd (after mdadm)
Date: Fri, 24 Apr 2015 12:09:32 +1000 [thread overview]
Message-ID: <20150424120932.3d554638@notabene.brown> (raw)
In-Reply-To: <20150423161051.GA18971@lst.de>
[-- Attachment #1: Type: text/plain, Size: 3201 bytes --]
On Thu, 23 Apr 2015 18:10:51 +0200 Christoph Hellwig <hch@lst.de> wrote:
> On Thu, Apr 23, 2015 at 06:03:14PM +1000, NeilBrown wrote:
> > On Thu, 23 Apr 2015 09:37:24 +0200 Christoph Hellwig <hch@lst.de> wrote:
> >
> > > Plase fix your device name lifetimes.
> >
> > Any chance you could be more explicit?
> >
> > The commit you identified doesn't seem to help much - md and dm are quite
> > different in this area.
> >
> > It seems that it is no longer safe to call 'add_disk' between calling
> > 'del_gendisk' and bdi_destroy being called. How can I find out if I am in
> > that window, or wait for bdi_destroy to be called?
>
> The bdi is only around if the device is open, either through a device
> node, or through a blkdev_get from a file system. If you get duplicate
> names that means you're trying to allocate a new gendisk while the old
> one is still around.
>
> In theory you're fine once the device gets ->release called.
In practice .... the put_disk() shortly after the ->release call in
__blkdev_put() is what ultimately releases the name of the bdi - at least in
the cases where I get a crash.
>
> Except that we can hold sysfs reference to the qeue, eww. So for now
> try to follow the dm model, but I'll need to add a callback to the
> queue called once the request_queue actually is released for this.
I'm pretty sure that the md code is already as close to the "dm model" as it
meaningfully can be.
If I move bdi_destroy out of blk_release_queue (which really think is too
later) and place it in blk_cleanup_queue (which seems a credible place for
it), and then move the blk_cleanup_queue call in md_free up before the
del_gendisk() call (which is probably the right thing to do anyway, though dm
has the same order that md currently has) then I don't get any crashes and
I'm almost convince it is correct...
Thoughts?
Thanks,
NeilBrown
diff --git a/block/blk-core.c b/block/blk-core.c
index 794c3e7f01cf..66406474f0c4 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -552,6 +552,8 @@ void blk_cleanup_queue(struct request_queue *q)
q->queue_lock = &q->__queue_lock;
spin_unlock_irq(lock);
+ bdi_destroy(&q->backing_dev_info);
+
/* @q is and will stay empty, shutdown and put */
blk_put_queue(q);
}
diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index faaf36ade7eb..2b8fd302f677 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -522,8 +522,6 @@ static void blk_release_queue(struct kobject *kobj)
blk_trace_shutdown(q);
- bdi_destroy(&q->backing_dev_info);
-
ida_simple_remove(&blk_queue_ida, q->id);
call_rcu(&q->rcu_head, blk_free_queue_rcu);
}
diff --git a/drivers/md/md.c b/drivers/md/md.c
index d4f31e195e26..593a02476c78 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -4818,12 +4818,12 @@ static void md_free(struct kobject *ko)
if (mddev->sysfs_state)
sysfs_put(mddev->sysfs_state);
+ if (mddev->queue)
+ blk_cleanup_queue(mddev->queue);
if (mddev->gendisk) {
del_gendisk(mddev->gendisk);
put_disk(mddev->gendisk);
}
- if (mddev->queue)
- blk_cleanup_queue(mddev->queue);
kfree(mddev);
}
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 811 bytes --]
next prev parent reply other threads:[~2015-04-24 2:09 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-14 17:15 BUG: unable to handle kernel NULL pointer dereference at sysfs_do_create_link_sd (after mdadm) Azat Khuzhin
2015-04-15 2:44 ` Guoqing Jiang
2015-04-15 8:47 ` Azat Khuzhin
2015-04-23 6:05 ` Bisected, with rfc/patch - was " NeilBrown
2015-04-23 7:37 ` Christoph Hellwig
2015-04-23 8:03 ` NeilBrown
2015-04-23 16:10 ` Christoph Hellwig
2015-04-24 2:09 ` NeilBrown [this message]
2015-04-24 8:27 ` Christoph Hellwig
2015-04-27 4:12 ` [PATCH -stable] block: destroy bdi before blockdev is unregistered NeilBrown
2015-04-27 13:03 ` Christoph Hellwig
2015-04-27 16:27 ` Jens Axboe
2015-04-28 16:41 ` Mike Snitzer
2015-04-28 21:25 ` NeilBrown
2015-04-29 13:35 ` Christoph Hellwig
2015-04-29 16:02 ` Peter Zijlstra
2015-04-30 0:06 ` NeilBrown
2015-04-30 0:32 ` [PATCH stable] block: discard bdi_unregister() in favour of bdi_destroy() NeilBrown
2015-04-30 8:35 ` Peter Zijlstra
2015-05-06 16:11 ` [dm-devel] " Dan Williams
2015-05-08 5:09 ` [PATCH v2] " NeilBrown
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=20150424120932.3d554638@notabene.brown \
--to=neilb@suse.de \
--cc=GQJiang@suse.com \
--cc=a3at.mail@gmail.com \
--cc=axboe@fb.com \
--cc=dm-devel@redhat.com \
--cc=hch@lst.de \
--cc=jack@suse.cz \
--cc=linux-raid@vger.kernel.org \
--cc=tj@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;
as well as URLs for NNTP newsgroup(s).