From: "Markus Blöchl" <Markus.Bloechl@ipetronik.com>
To: Christoph Hellwig <hch@lst.de>, Hannes Reinecke <hare@suse.de>
Cc: Keith Busch <kbusch@kernel.org>, Jens Axboe <axboe@kernel.dk>,
Sagi Grimberg <sagi@grimberg.me>,
linux-nvme@lists.infradead.org, linux-block@vger.kernel.org,
linux-kernel@vger.kernel.org, Stefan Roese <sr@denx.de>
Subject: Re: [RFC PATCH] nvme: prevent hang on surprise removal of NVMe disk
Date: Wed, 16 Feb 2022 13:59:37 +0100 [thread overview]
Message-ID: <20220216125937.d6brzu7labgywxcg@ipetronik.com> (raw)
In-Reply-To: <20220215201738.GA26945@lst.de>
On Tue, Feb 15, 2022 at 09:17:38PM +0100, Christoph Hellwig wrote:
> So, I think in th short run setting GD_DEAD is the right thing as a
> non-invasive fix, but I'd rather do it in blk_set_queue_dying to also
> cover the other drivers with a similar pattern. blk_set_queue_dying
> is never used for cases where q->disk isn't valid so that should be
> fine.
blk_set_queue_dying() is called from blk_cleanup_queue(), which in turn
is called for all kinds of queues without associated disk, even ones
with failed allocations.
But according to disk_release() a disk which was once associated should
always outlive its queue, thus q->disk should indeed always be safe.
It's a little unfortunate that the existing doc on request queues was
so outdated that it had to be removed.
So I was trying to figure out if blk_queue_dying(q) should always imply
(!q->disk || test_bit(GD_DEAD, &q->disk->state)).
Assuming that there is a 1:1 relationship between q and q->disk and that
blk_queue_dying(q) was previously used where GD_DEAD is now, I do hope
so, since GD_DEAD should just be a weaker form of QUEUE_FLAG_DYING to
allow killing the disk way before the queue.
>
> In the long run I think we just need to remove the fsync_bdev in
> del_gendisk or at least make it conditional.
But wouldn't that require you to pass a flag like SURPRISE_REMOVAL into
del_gendisk and passing it along through delete_partition()?
You would still need GD_DEAD since someone might remove the disk while
you are syncing, so this only sounds like an error-prone optimization to
me. After all, syncing on graceful removal seems to be a sensible thing
to do.
Fiddling with qemu will probably take me too long unless Hannes already
has something up his sleeves.
So I'll submit V2 after I regained access to the test setup.
It will probably just look something like this:
```
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -286,6 +286,8 @@ void blk_queue_start_drain(struct request_queue *q)
void blk_set_queue_dying(struct request_queue *q)
{
+ if (q->disk)
+ set_bit(GD_DEAD, &q->disk->state);
blk_queue_flag_set(QUEUE_FLAG_DYING, q);
blk_queue_start_drain(q);
}
```
Thanks for all your input,
Markus
next prev parent reply other threads:[~2022-02-16 12:59 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-14 9:51 [RFC PATCH] nvme: prevent hang on surprise removal of NVMe disk Markus Blöchl
2022-02-15 15:22 ` Keith Busch
2022-02-15 18:47 ` Christoph Hellwig
2022-02-15 19:14 ` Keith Busch
2022-02-15 19:17 ` Christoph Hellwig
2022-02-15 19:37 ` Keith Busch
2022-02-16 6:39 ` Hannes Reinecke
2022-02-16 11:18 ` Markus Blöchl
2022-02-16 11:32 ` Hannes Reinecke
2022-02-15 20:17 ` Christoph Hellwig
2022-02-16 12:59 ` Markus Blöchl [this message]
2022-02-16 13:33 ` Christoph Hellwig
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=20220216125937.d6brzu7labgywxcg@ipetronik.com \
--to=markus.bloechl@ipetronik.com \
--cc=axboe@kernel.dk \
--cc=hare@suse.de \
--cc=hch@lst.de \
--cc=kbusch@kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=sagi@grimberg.me \
--cc=sr@denx.de \
/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