[PATCH v5 12/12] nvmet-fc: use RCU list iterator for assoc_list

Keith Busch kbusch at kernel.org
Tue Feb 6 11:22:49 PST 2024


On Tue, Feb 06, 2024 at 02:51:24PM +0900, Hannes Reinecke wrote:
> On 1/31/24 16:51, Daniel Wagner wrote:
> > +		rcu_read_lock();
> > +		if (!nvmet_fc_assoc_exits(tgtport, ran)) {
> >   			assoc->association_id = ran;
> >   			list_add_tail_rcu(&assoc->a_list, &tgtport->assoc_list);
> > +			done = true;
> >   		}
> > +		rcu_read_unlock();
> >   		spin_unlock_irqrestore(&tgtport->lock, flags);
> 
> Odd. You already take the tgtport lock, so there really is no point in using
> rcu_read_lock() here.

That's a interesting point, but I think it's harmless since there's no
rcu sync within the read section.

  https://www.kernel.org/doc/Documentation/RCU/Design/Requirements/Requirements.html#Guaranteed%20Read-to-Write%20Upgrade

That said, the rcu_read_lock() seems like it should be moved to
nvmet_fc_assoc_exits() since that's the only part reading rcu protected
structures.



More information about the Linux-nvme mailing list