Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: keith.busch@intel.com (Keith Busch)
Subject: [PATCH 2/2] nvme: protect against race condition in nvme_validate_ns()
Date: Tue, 19 Feb 2019 12:54:33 -0700	[thread overview]
Message-ID: <20190219195433.GE16341@localhost.localdomain> (raw)
In-Reply-To: <5f600cbc-eab7-0c72-5ecf-50a12180082c@grimberg.me>

On Tue, Feb 19, 2019@11:44:41AM -0800, Sagi Grimberg wrote:
> On 2/19/19 4:13 AM, Hannes Reinecke wrote:
> > When subsystems are rapidly reconfigured (or sending out several AENs)
> > we might end up in a situation where several instances of nvme_scan_work()
> > are running. Each of which might be trying to register the same nsid,
> > so nvme_find_get_ns() in nvme_validate_ns() will return 0 for both,
> > resulting in a crash in nvme_alloc_ns() as both are registering a
> > gendisk with the same name.
> 
> Wouldn't it be better to serialize nvme_scan_work such that it doesn't
> run multiple times in parallel?

Doesn't the work queue already serialize individual ctrl's scan_work?

There is also a recently added mutex to synchronize scan work with
command effects handling, which would force an nvme_ctrl's scan_work to
be serialized:

  https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e7ad43c3eda6a1690c4c3c341f95dc1c6898da83

  reply	other threads:[~2019-02-19 19:54 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-19 12:13 [PATCH 0/2] nvme: fixup crash in device_add_disk() Hannes Reinecke
2019-02-19 12:13 ` [PATCH 1/2] nvme: return error from nvme_alloc_ns() Hannes Reinecke
2019-02-19 19:42   ` Sagi Grimberg
2019-02-20 14:21   ` Christoph Hellwig
2019-02-19 12:13 ` [PATCH 2/2] nvme: protect against race condition in nvme_validate_ns() Hannes Reinecke
2019-02-19 19:44   ` Sagi Grimberg
2019-02-19 19:54     ` Keith Busch [this message]
2019-02-20  6:52       ` Hannes Reinecke

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=20190219195433.GE16341@localhost.localdomain \
    --to=keith.busch@intel.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