aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/fcoe
diff options
context:
space:
mode:
authorVasu Dev <vasu.dev@intel.com>2009-07-29 20:05:15 -0400
committerJames Bottomley <James.Bottomley@suse.de>2009-08-22 18:52:09 -0400
commite8af4d4380babc89d193c16163f070a6418f033b (patch)
treeea32ede76e22dd02694a53030ea7776170c4166c /drivers/scsi/fcoe
parent52ff878c912215210f53c0a080552dd6ba3055a2 (diff)
[SCSI] fcoe: modifies fcoe_hostlist_lock uses as prep work to add shared offload EM
Modifies fcoe_hostlist_lock uses such that a new EM allocation in fcoe_em_config and adding new fcoe_softc using fcoe_hostlist_add are atomic, this is to ensure that a shared offload EM gets allocated only once per eth device for its all lports. Signed-off-by: Vasu Dev <vasu.dev@intel.com> Signed-off-by: Robert Love <robert.w.love@intel.com> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Diffstat (limited to 'drivers/scsi/fcoe')
-rw-r--r--drivers/scsi/fcoe/fcoe.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c
index ebf2e20370d7..86410b9a30c3 100644
--- a/drivers/scsi/fcoe/fcoe.c
+++ b/drivers/scsi/fcoe/fcoe.c
@@ -419,6 +419,8 @@ static int fcoe_shost_config(struct fc_lport *lp, struct Scsi_Host *shost,
419 * fcoe_em_config() - allocates em for this lport 419 * fcoe_em_config() - allocates em for this lport
420 * @lp: the port that em is to allocated for 420 * @lp: the port that em is to allocated for
421 * 421 *
422 * Called with write fcoe_hostlist_lock held.
423 *
422 * Returns : 0 on success 424 * Returns : 0 on success
423 */ 425 */
424static inline int fcoe_em_config(struct fc_lport *lp) 426static inline int fcoe_em_config(struct fc_lport *lp)
@@ -607,6 +609,13 @@ static int fcoe_if_create(struct net_device *netdev)
607 goto out_lp_destroy; 609 goto out_lp_destroy;
608 } 610 }
609 611
612 /*
613 * fcoe_em_alloc() and fcoe_hostlist_add() both
614 * need to be atomic under fcoe_hostlist_lock
615 * since fcoe_em_alloc() looks for an existing EM
616 * instance on host list updated by fcoe_hostlist_add().
617 */
618 write_lock(&fcoe_hostlist_lock);
610 /* lport exch manager allocation */ 619 /* lport exch manager allocation */
611 rc = fcoe_em_config(lp); 620 rc = fcoe_em_config(lp);
612 if (rc) { 621 if (rc) {
@@ -617,6 +626,7 @@ static int fcoe_if_create(struct net_device *netdev)
617 626
618 /* add to lports list */ 627 /* add to lports list */
619 fcoe_hostlist_add(lp); 628 fcoe_hostlist_add(lp);
629 write_unlock(&fcoe_hostlist_lock);
620 630
621 lp->boot_time = jiffies; 631 lp->boot_time = jiffies;
622 632
@@ -1720,6 +1730,8 @@ int fcoe_reset(struct Scsi_Host *shost)
1720 * fcoe_hostlist_lookup_softc() - find the corresponding lport by a given device 1730 * fcoe_hostlist_lookup_softc() - find the corresponding lport by a given device
1721 * @dev: this is currently ptr to net_device 1731 * @dev: this is currently ptr to net_device
1722 * 1732 *
1733 * Called with fcoe_hostlist_lock held.
1734 *
1723 * Returns: NULL or the located fcoe_softc 1735 * Returns: NULL or the located fcoe_softc
1724 */ 1736 */
1725static struct fcoe_softc * 1737static struct fcoe_softc *
@@ -1727,14 +1739,10 @@ fcoe_hostlist_lookup_softc(const struct net_device *dev)
1727{ 1739{
1728 struct fcoe_softc *fc; 1740 struct fcoe_softc *fc;
1729 1741
1730 read_lock(&fcoe_hostlist_lock);
1731 list_for_each_entry(fc, &fcoe_hostlist, list) { 1742 list_for_each_entry(fc, &fcoe_hostlist, list) {
1732 if (fc->real_dev == dev) { 1743 if (fc->real_dev == dev)
1733 read_unlock(&fcoe_hostlist_lock);
1734 return fc; 1744 return fc;
1735 }
1736 } 1745 }
1737 read_unlock(&fcoe_hostlist_lock);
1738 return NULL; 1746 return NULL;
1739} 1747}
1740 1748
@@ -1748,7 +1756,9 @@ struct fc_lport *fcoe_hostlist_lookup(const struct net_device *netdev)
1748{ 1756{
1749 struct fcoe_softc *fc; 1757 struct fcoe_softc *fc;
1750 1758
1759 read_lock(&fcoe_hostlist_lock);
1751 fc = fcoe_hostlist_lookup_softc(netdev); 1760 fc = fcoe_hostlist_lookup_softc(netdev);
1761 read_unlock(&fcoe_hostlist_lock);
1752 1762
1753 return (fc) ? fc->ctlr.lp : NULL; 1763 return (fc) ? fc->ctlr.lp : NULL;
1754} 1764}
@@ -1757,6 +1767,8 @@ struct fc_lport *fcoe_hostlist_lookup(const struct net_device *netdev)
1757 * fcoe_hostlist_add() - Add a lport to lports list 1767 * fcoe_hostlist_add() - Add a lport to lports list
1758 * @lp: ptr to the fc_lport to be added 1768 * @lp: ptr to the fc_lport to be added
1759 * 1769 *
1770 * Called with write fcoe_hostlist_lock held.
1771 *
1760 * Returns: 0 for success 1772 * Returns: 0 for success
1761 */ 1773 */
1762int fcoe_hostlist_add(const struct fc_lport *lp) 1774int fcoe_hostlist_add(const struct fc_lport *lp)
@@ -1766,9 +1778,7 @@ int fcoe_hostlist_add(const struct fc_lport *lp)
1766 fc = fcoe_hostlist_lookup_softc(fcoe_netdev(lp)); 1778 fc = fcoe_hostlist_lookup_softc(fcoe_netdev(lp));
1767 if (!fc) { 1779 if (!fc) {
1768 fc = lport_priv(lp); 1780 fc = lport_priv(lp);
1769 write_lock_bh(&fcoe_hostlist_lock);
1770 list_add_tail(&fc->list, &fcoe_hostlist); 1781 list_add_tail(&fc->list, &fcoe_hostlist);
1771 write_unlock_bh(&fcoe_hostlist_lock);
1772 } 1782 }
1773 return 0; 1783 return 0;
1774} 1784}
@@ -1783,9 +1793,9 @@ int fcoe_hostlist_remove(const struct fc_lport *lp)
1783{ 1793{
1784 struct fcoe_softc *fc; 1794 struct fcoe_softc *fc;
1785 1795
1796 write_lock_bh(&fcoe_hostlist_lock);
1786 fc = fcoe_hostlist_lookup_softc(fcoe_netdev(lp)); 1797 fc = fcoe_hostlist_lookup_softc(fcoe_netdev(lp));
1787 BUG_ON(!fc); 1798 BUG_ON(!fc);
1788 write_lock_bh(&fcoe_hostlist_lock);
1789 list_del(&fc->list); 1799 list_del(&fc->list);
1790 write_unlock_bh(&fcoe_hostlist_lock); 1800 write_unlock_bh(&fcoe_hostlist_lock);
1791 1801