From: Caleb Sander <csander@purestorage.com>
To: Keith Busch <kbusch@kernel.org>, Jens Axboe <axboe@fb.com>,
Christoph Hellwig <hch@lst.de>, Sagi Grimberg <sagi@grimberg.me>,
linux-nvme@lists.infradead.org
Cc: Uday Shankar <ushankar@purestorage.com>,
Caleb Sander <csander@purestorage.com>
Subject: [PATCH] nvme: fix (S)RCU protection of nvme_ns_head list (alternate)
Date: Wed, 23 Nov 2022 17:24:32 -0700 [thread overview]
Message-ID: <20221124002432.3715594-1-csander@purestorage.com> (raw)
In-Reply-To: <20221118232756.1457075-1-csander@purestorage.com>
This is an alternate fix, protecting the nvme_ns_head siblings list
with both RCU and SRCU.
Use RCU in nvme_mpath_revalidate_paths(), which doesn't sleep.
And add synchronize_srcu() in nvme_ns_remove(),
since nvme_ns_head_submit_bio() protects the list with SRCU.
Signed-off-by: Caleb Sander <csander@purestorage.com>
---
drivers/nvme/host/core.c | 1 +
drivers/nvme/host/multipath.c | 2 ++
2 files changed, 3 insertions(+)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index da55ce45ac70..9b26d4781b32 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -4305,6 +4305,7 @@ static void nvme_ns_remove(struct nvme_ns *ns)
/* guarantee not available in head->list */
synchronize_rcu();
+ synchronize_srcu(&ns->head->srcu);
if (!nvme_ns_head_multipath(ns->head))
nvme_cdev_del(&ns->cdev, &ns->cdev_device);
diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
index 93e2138a8b42..6d0aea477253 100644
--- a/drivers/nvme/host/multipath.c
+++ b/drivers/nvme/host/multipath.c
@@ -175,10 +175,12 @@ void nvme_mpath_revalidate_paths(struct nvme_ns *ns)
sector_t capacity = get_capacity(head->disk);
int node;
+ rcu_read_lock();
list_for_each_entry_rcu(ns, &head->list, siblings) {
if (capacity != get_capacity(ns->disk))
clear_bit(NVME_NS_READY, &ns->flags);
}
+ rcu_read_unlock();
for_each_node(node)
rcu_assign_pointer(head->current_path[node], NULL);
--
2.25.1
next prev parent reply other threads:[~2022-11-24 0:24 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-18 23:27 [PATCH] nvme: fix SRCU protection of nvme_ns_head list Caleb Sander
2022-11-20 11:24 ` Sagi Grimberg
2022-11-21 7:40 ` Christoph Hellwig
2022-11-21 9:43 ` Sagi Grimberg
2022-11-21 14:57 ` Paul E. McKenney
2022-11-21 17:48 ` Caleb Sander
2022-11-21 17:59 ` Paul E. McKenney
2022-11-21 19:58 ` Caleb Sander
2022-11-22 0:25 ` Paul E. McKenney
2022-11-22 10:06 ` Sagi Grimberg
2022-11-22 12:14 ` Christoph Hellwig
2022-11-22 15:08 ` Sagi Grimberg
2022-11-24 0:12 ` Caleb Sander
2022-11-24 3:08 ` Chao Leng
2022-11-24 14:17 ` Sagi Grimberg
2022-12-01 21:27 ` Caleb Sander
2022-12-01 23:18 ` Paul E. McKenney
2022-11-24 0:24 ` Caleb Sander [this message]
2022-11-24 14:19 ` [PATCH] nvme: fix (S)RCU protection of nvme_ns_head list (alternate) Sagi Grimberg
2022-11-29 8:39 ` Christoph Hellwig
2022-11-30 8:25 ` Sagi Grimberg
2022-11-30 8:35 ` Christoph Hellwig
2022-11-30 8:40 ` Sagi Grimberg
2022-12-01 21:17 ` Caleb Sander
2022-12-02 1:21 ` Chao Leng
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=20221124002432.3715594-1-csander@purestorage.com \
--to=csander@purestorage.com \
--cc=axboe@fb.com \
--cc=hch@lst.de \
--cc=kbusch@kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=sagi@grimberg.me \
--cc=ushankar@purestorage.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