[PATCH 1/1] nvme/fc: add 'discovery' sysfs attribute to fc transport device

Christoph Hellwig hch at infradead.org
Wed Nov 8 10:16:38 PST 2017


On Wed, Nov 08, 2017 at 05:31:23PM +0100, Hannes Reinecke wrote:
> On 11/07/2017 08:25 PM, Christoph Hellwig wrote:
> >> +	list_for_each_entry(lport, &nvme_fc_lport_list, port_list) {
> >> +		list_for_each_entry_safe(rport, tmp_rport,
> >> +					 &lport->endp_list, endp_list) {
> >> +			if (!nvme_fc_rport_get(rport))
> >> +				continue;
> >> +			spin_unlock_irqrestore(&nvme_fc_lock, flags);
> >> +			nvme_fc_signal_discovery_scan(lport, rport);
> >> +			nvme_fc_rport_put(rport);
> >> +			spin_lock_irqsave(&nvme_fc_lock, flags);
> >> +		}
> >> +	}
> >> +	spin_unlock_irqrestore(&nvme_fc_lock, flags);
> > 
> > What guarantees the list next pointers are still valid after
> > you dropped nvme_fc_lock?
> > 
> You know, I wondered about that, too.
> But then I cannot hold the lock when calling nvme_fc_rport_put().
> And I'm somewhat reluctant to use list_for_each_entry_safe() in the
> outer loop.

list_for_each_entry_safe isn't going to help you with races - it
only helps you when you delete the current node.



More information about the Linux-nvme mailing list