[PATCH] nvme: fix SRCU protection of nvme_ns_head list
Sagi Grimberg
sagi at grimberg.me
Mon Nov 21 01:43:33 PST 2022
>>> sector_t capacity = get_capacity(head->disk);
>>> int node;
>>> + int srcu_idx;
>>> + srcu_idx = srcu_read_lock(&head->srcu);
>>> list_for_each_entry_rcu(ns, &head->list, siblings) {
>>> if (capacity != get_capacity(ns->disk))
>>> clear_bit(NVME_NS_READY, &ns->flags);
>>> }
>>> + srcu_read_unlock(&head->srcu, srcu_idx);
>>
>> I don't think you need srcu here, rcu_read_lock/unlock is sufficient.
>
> So the code obviously does not sleep. But I wonder if anything speaks
> against mixing SRCU and RCU protection for the same list?
I am not an expert, but the point of (s)rcu_synchronize to fence the
reader critical section isn't it? so if the reader doesn't sleep, the
existing rcu_synchronize should be sufficient.
More information about the Linux-nvme
mailing list