* [PATCHv3] nvme: fix namespace removal list
@ 2024-06-13 16:42 Keith Busch
2024-06-13 17:11 ` Christoph Hellwig
2024-06-19 10:54 ` Sagi Grimberg
0 siblings, 2 replies; 3+ messages in thread
From: Keith Busch @ 2024-06-13 16:42 UTC (permalink / raw)
To: linux-nvme; +Cc: hch, sagi, Keith Busch, Venkat Rao Bagalkote
From: Keith Busch <kbusch@kernel.org>
This function wants to move a subset of a list from one element to the
tail into another list. It also needs to use the srcu synchronize
instead of the regular rcu version. Do this one element at a time
because that's the only to do it.
Fixes: be647e2c76b27f4 ("nvme: use srcu for iterating namespace list")
Reported-by: Venkat Rao Bagalkote <venkat88@linux.vnet.ibm.com>
Tested-by: Venkat Rao Bagalkote <venkat88@linux.vnet.ibm.com>
Signed-off-by: Keith Busch <kbusch@kernel.org>
---
It would be neat to have a more elegant helper that we've been messing
with, and be able to use a single srcu synchronize, but in the interest
of time, this patch will fix the regression.
I was hoping to not have per-ns srcu sync's, but this path pretty
much only gets called on the last namespace anyway, so it should
functionally work out to be a single sync without to optimizations.
drivers/nvme/host/core.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index c40930d10bd34..782090ce0bc10 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -3960,12 +3960,13 @@ static void nvme_remove_invalid_namespaces(struct nvme_ctrl *ctrl,
mutex_lock(&ctrl->namespaces_lock);
list_for_each_entry_safe(ns, next, &ctrl->namespaces, list) {
- if (ns->head->ns_id > nsid)
- list_splice_init_rcu(&ns->list, &rm_list,
- synchronize_rcu);
+ if (ns->head->ns_id > nsid) {
+ list_del_rcu(&ns->list);
+ synchronize_srcu(&ctrl->srcu);
+ list_add_tail_rcu(&ns->list, &rm_list);
+ }
}
mutex_unlock(&ctrl->namespaces_lock);
- synchronize_srcu(&ctrl->srcu);
list_for_each_entry_safe(ns, next, &rm_list, list)
nvme_ns_remove(ns);
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCHv3] nvme: fix namespace removal list
2024-06-13 16:42 [PATCHv3] nvme: fix namespace removal list Keith Busch
@ 2024-06-13 17:11 ` Christoph Hellwig
2024-06-19 10:54 ` Sagi Grimberg
1 sibling, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2024-06-13 17:11 UTC (permalink / raw)
To: Keith Busch; +Cc: linux-nvme, hch, sagi, Keith Busch, Venkat Rao Bagalkote
On Thu, Jun 13, 2024 at 09:42:46AM -0700, Keith Busch wrote:
> It would be neat to have a more elegant helper that we've been messing
> with, and be able to use a single srcu synchronize, but in the interest
> of time, this patch will fix the regression.
>
> I was hoping to not have per-ns srcu sync's, but this path pretty
> much only gets called on the last namespace anyway, so it should
> functionally work out to be a single sync without to optimizations.
Yeah, compared to the 2-3 synchronize_srcu calls in nvme_ns_remove
one more probably doesn't matter right now..
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCHv3] nvme: fix namespace removal list
2024-06-13 16:42 [PATCHv3] nvme: fix namespace removal list Keith Busch
2024-06-13 17:11 ` Christoph Hellwig
@ 2024-06-19 10:54 ` Sagi Grimberg
1 sibling, 0 replies; 3+ messages in thread
From: Sagi Grimberg @ 2024-06-19 10:54 UTC (permalink / raw)
To: Keith Busch, linux-nvme; +Cc: hch, Keith Busch, Venkat Rao Bagalkote
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-06-19 10:54 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-13 16:42 [PATCHv3] nvme: fix namespace removal list Keith Busch
2024-06-13 17:11 ` Christoph Hellwig
2024-06-19 10:54 ` Sagi Grimberg
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).