Re: [RFC v2 2/3] nvme: move ns id info to struct nvme_ns_head

From: Daniel Wagner
Date: Mon Dec 04 2023 - 05:56:57 EST


On Mon, Dec 04, 2023 at 10:30:52AM +0200, Sagi Grimberg wrote:
> > -bool nvme_mpath_clear_current_path(struct nvme_ns *ns)
> > +bool nvme_mpath_clear_current_path(struct nvme_ns_head *head)
> > {
> > - struct nvme_ns_head *head = ns->head;
> > bool changed = false;
> > int node;
> > @@ -181,7 +183,7 @@ bool nvme_mpath_clear_current_path(struct nvme_ns *ns)
> > goto out;
> > for_each_node(node) {
> > - if (ns == rcu_access_pointer(head->current_path[node])) {
> > + if (head == rcu_access_pointer(head->current_path[node])->head) {
> > rcu_assign_pointer(head->current_path[node], NULL);
> > changed = true;
> > }
>
> I'm not sure about this one.
>
> This is changing the behavior of the function. Previously it only
> cleared the current_path if it was directed to ns, now it will if the
> current_path has the same head, which is always the case isn't it?
>
> I'm unsure to why this change is needed?

As Christoph pointed out we really need to check the ns pointer. I tried
to workaound not to use nvme_ctrl_find_ns. Anyway, I'll drop this hunk
here.

Thanks,
Daniel