* fcoe_em_config() - allocates em for this lport
* @lp: the port that em is to allocated for
*
+ * Called with write fcoe_hostlist_lock held.
+ *
* Returns : 0 on success
*/
static inline int fcoe_em_config(struct fc_lport *lp)
goto out_lp_destroy;
}
+ /*
+ * fcoe_em_alloc() and fcoe_hostlist_add() both
+ * need to be atomic under fcoe_hostlist_lock
+ * since fcoe_em_alloc() looks for an existing EM
+ * instance on host list updated by fcoe_hostlist_add().
+ */
+ write_lock(&fcoe_hostlist_lock);
/* lport exch manager allocation */
rc = fcoe_em_config(lp);
if (rc) {
/* add to lports list */
fcoe_hostlist_add(lp);
+ write_unlock(&fcoe_hostlist_lock);
lp->boot_time = jiffies;
* fcoe_hostlist_lookup_softc() - find the corresponding lport by a given device
* @dev: this is currently ptr to net_device
*
+ * Called with fcoe_hostlist_lock held.
+ *
* Returns: NULL or the located fcoe_softc
*/
static struct fcoe_softc *
{
struct fcoe_softc *fc;
- read_lock(&fcoe_hostlist_lock);
list_for_each_entry(fc, &fcoe_hostlist, list) {
- if (fc->real_dev == dev) {
- read_unlock(&fcoe_hostlist_lock);
+ if (fc->real_dev == dev)
return fc;
- }
}
- read_unlock(&fcoe_hostlist_lock);
return NULL;
}
{
struct fcoe_softc *fc;
+ read_lock(&fcoe_hostlist_lock);
fc = fcoe_hostlist_lookup_softc(netdev);
+ read_unlock(&fcoe_hostlist_lock);
return (fc) ? fc->ctlr.lp : NULL;
}
* fcoe_hostlist_add() - Add a lport to lports list
* @lp: ptr to the fc_lport to be added
*
+ * Called with write fcoe_hostlist_lock held.
+ *
* Returns: 0 for success
*/
int fcoe_hostlist_add(const struct fc_lport *lp)
fc = fcoe_hostlist_lookup_softc(fcoe_netdev(lp));
if (!fc) {
fc = lport_priv(lp);
- write_lock_bh(&fcoe_hostlist_lock);
list_add_tail(&fc->list, &fcoe_hostlist);
- write_unlock_bh(&fcoe_hostlist_lock);
}
return 0;
}
{
struct fcoe_softc *fc;
+ write_lock_bh(&fcoe_hostlist_lock);
fc = fcoe_hostlist_lookup_softc(fcoe_netdev(lp));
BUG_ON(!fc);
- write_lock_bh(&fcoe_hostlist_lock);
list_del(&fc->list);
write_unlock_bh(&fcoe_hostlist_lock);