[PATCH] nvme-multipath: fix possible hang in live ns resize with ANA access
Christoph Hellwig
hch at lst.de
Thu Sep 29 23:40:03 PDT 2022
On Fri, Sep 30, 2022 at 08:29:54AM +0200, Hannes Reinecke wrote:
>> void nvme_mpath_revalidate_paths(struct nvme_ns *ns)
>> {
>> struct nvme_ns_head *head = ns->head;
>> + struct nvme_ns *n;
>> sector_t capacity = get_capacity(head->disk);
>> int node;
>> - list_for_each_entry_rcu(ns, &head->list, siblings) {
>> - if (capacity != get_capacity(ns->disk))
>> - clear_bit(NVME_NS_READY, &ns->flags);
>> + list_for_each_entry_rcu(n, &head->list, siblings) {
>> + if (capacity != get_capacity(n->disk))
>> + clear_bit(NVME_NS_READY, &n->flags);
>> }
>> for_each_node(node)
>> rcu_assign_pointer(head->current_path[node], NULL);
>> + nvme_kick_requeue_lists(ns->ctrl);
>> }
>> static bool nvme_path_is_disabled(struct nvme_ns *ns)
>
> Hmm. I guess the real issue is that we use 'ns' as both function argument
> _and_ iterator, so that after 'list_for_each_rcu()' 'ns' is pointing to a
> _different_ namespace, such that we end up kicking that namespace and not
> the one used as argument.
> But in either case, patch is fine.
BEfore this patch that wasn't an actual problem as the ns pass as
argument was only used to derived the ns_head but not used after
the loop. It was a bit of a landmine, though.
More information about the Linux-nvme
mailing list