aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/fcoe/fcoe.c
diff options
context:
space:
mode:
authorChris Leech <christopher.leech@intel.com>2009-08-25 17:00:28 -0400
committerJames Bottomley <James.Bottomley@suse.de>2009-09-10 13:07:38 -0400
commit090eb6c41aa74273d3f0721637cff738cfd80669 (patch)
tree5789214aa7d85e67901b619bee48429db1009aae /drivers/scsi/fcoe/fcoe.c
parent2e70e2415193b84c1b79ec373af15c3f280ad7c4 (diff)
[SCSI] fcoe: use rtnl mutex in place of hostlist lock
This just cuts down on the number of locks we're dealing with, and eliminates the need to take another lock in the netdev notifier. Signed-off-by: Chris Leech <christopher.leech@intel.com> Signed-off-by: Robert Love <robert.w.love@intel.com> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Diffstat (limited to 'drivers/scsi/fcoe/fcoe.c')
-rw-r--r--drivers/scsi/fcoe/fcoe.c37
1 files changed, 11 insertions, 26 deletions
diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c
index c0264a984394..ac481ad112ad 100644
--- a/drivers/scsi/fcoe/fcoe.c
+++ b/drivers/scsi/fcoe/fcoe.c
@@ -58,8 +58,8 @@ MODULE_PARM_DESC(ddp_min, "Minimum I/O size in bytes for " \
58DEFINE_MUTEX(fcoe_config_mutex); 58DEFINE_MUTEX(fcoe_config_mutex);
59 59
60/* fcoe host list */ 60/* fcoe host list */
61/* must only by accessed under the RTNL mutex */
61LIST_HEAD(fcoe_hostlist); 62LIST_HEAD(fcoe_hostlist);
62DEFINE_RWLOCK(fcoe_hostlist_lock);
63DEFINE_PER_CPU(struct fcoe_percpu_s, fcoe_percpu); 63DEFINE_PER_CPU(struct fcoe_percpu_s, fcoe_percpu);
64 64
65/* Function Prototypes */ 65/* Function Prototypes */
@@ -527,8 +527,6 @@ bool fcoe_oem_match(struct fc_frame *fp)
527 * fcoe_em_config() - allocates em for this lport 527 * fcoe_em_config() - allocates em for this lport
528 * @lp: the fcoe that em is to allocated for 528 * @lp: the fcoe that em is to allocated for
529 * 529 *
530 * Called with write fcoe_hostlist_lock held.
531 *
532 * Returns : 0 on success 530 * Returns : 0 on success
533 */ 531 */
534static inline int fcoe_em_config(struct fc_lport *lp) 532static inline int fcoe_em_config(struct fc_lport *lp)
@@ -1539,7 +1537,6 @@ static int fcoe_device_notification(struct notifier_block *notifier,
1539 u32 mfs; 1537 u32 mfs;
1540 int rc = NOTIFY_OK; 1538 int rc = NOTIFY_OK;
1541 1539
1542 write_lock(&fcoe_hostlist_lock);
1543 list_for_each_entry(fcoe, &fcoe_hostlist, list) { 1540 list_for_each_entry(fcoe, &fcoe_hostlist, list) {
1544 if (fcoe->netdev == netdev) { 1541 if (fcoe->netdev == netdev) {
1545 lp = fcoe->ctlr.lp; 1542 lp = fcoe->ctlr.lp;
@@ -1586,7 +1583,6 @@ static int fcoe_device_notification(struct notifier_block *notifier,
1586 fcoe_clean_pending_queue(lp); 1583 fcoe_clean_pending_queue(lp);
1587 } 1584 }
1588out: 1585out:
1589 write_unlock(&fcoe_hostlist_lock);
1590 return rc; 1586 return rc;
1591} 1587}
1592 1588
@@ -1643,16 +1639,14 @@ static int fcoe_destroy(const char *buffer, struct kernel_param *kp)
1643 goto out_nodev; 1639 goto out_nodev;
1644 } 1640 }
1645 1641
1646 write_lock(&fcoe_hostlist_lock); 1642 rtnl_lock();
1647 fcoe = fcoe_hostlist_lookup_port(netdev); 1643 fcoe = fcoe_hostlist_lookup_port(netdev);
1648 if (!fcoe) { 1644 if (!fcoe) {
1649 write_unlock(&fcoe_hostlist_lock); 1645 rtnl_unlock();
1650 rc = -ENODEV; 1646 rc = -ENODEV;
1651 goto out_putdev; 1647 goto out_putdev;
1652 } 1648 }
1653 list_del(&fcoe->list); 1649 list_del(&fcoe->list);
1654 write_unlock(&fcoe_hostlist_lock);
1655 rtnl_lock();
1656 fcoe_interface_cleanup(fcoe); 1650 fcoe_interface_cleanup(fcoe);
1657 rtnl_unlock(); 1651 rtnl_unlock();
1658 fcoe_if_destroy(fcoe->ctlr.lp); 1652 fcoe_if_destroy(fcoe->ctlr.lp);
@@ -1870,9 +1864,8 @@ int fcoe_reset(struct Scsi_Host *shost)
1870 * fcoe_hostlist_lookup_port() - find the corresponding lport by a given device 1864 * fcoe_hostlist_lookup_port() - find the corresponding lport by a given device
1871 * @dev: this is currently ptr to net_device 1865 * @dev: this is currently ptr to net_device
1872 * 1866 *
1873 * Called with fcoe_hostlist_lock held.
1874 *
1875 * Returns: NULL or the located fcoe_port 1867 * Returns: NULL or the located fcoe_port
1868 * Locking: must be called with the RNL mutex held
1876 */ 1869 */
1877static struct fcoe_interface * 1870static struct fcoe_interface *
1878fcoe_hostlist_lookup_port(const struct net_device *dev) 1871fcoe_hostlist_lookup_port(const struct net_device *dev)
@@ -1891,15 +1884,13 @@ fcoe_hostlist_lookup_port(const struct net_device *dev)
1891 * @netdev: ptr to net_device 1884 * @netdev: ptr to net_device
1892 * 1885 *
1893 * Returns: 0 for success 1886 * Returns: 0 for success
1887 * Locking: must be called with the RTNL mutex held
1894 */ 1888 */
1895struct fc_lport *fcoe_hostlist_lookup(const struct net_device *netdev) 1889static struct fc_lport *fcoe_hostlist_lookup(const struct net_device *netdev)
1896{ 1890{
1897 struct fcoe_interface *fcoe; 1891 struct fcoe_interface *fcoe;
1898 1892
1899 read_lock(&fcoe_hostlist_lock);
1900 fcoe = fcoe_hostlist_lookup_port(netdev); 1893 fcoe = fcoe_hostlist_lookup_port(netdev);
1901 read_unlock(&fcoe_hostlist_lock);
1902
1903 return (fcoe) ? fcoe->ctlr.lp : NULL; 1894 return (fcoe) ? fcoe->ctlr.lp : NULL;
1904} 1895}
1905 1896
@@ -1908,20 +1899,19 @@ struct fc_lport *fcoe_hostlist_lookup(const struct net_device *netdev)
1908 * @lp: ptr to the fc_lport to be added 1899 * @lp: ptr to the fc_lport to be added
1909 * 1900 *
1910 * Returns: 0 for success 1901 * Returns: 0 for success
1902 * Locking: must be called with the RTNL mutex held
1911 */ 1903 */
1912int fcoe_hostlist_add(const struct fc_lport *lport) 1904static int fcoe_hostlist_add(const struct fc_lport *lport)
1913{ 1905{
1914 struct fcoe_interface *fcoe; 1906 struct fcoe_interface *fcoe;
1915 struct fcoe_port *port; 1907 struct fcoe_port *port;
1916 1908
1917 write_lock_bh(&fcoe_hostlist_lock);
1918 fcoe = fcoe_hostlist_lookup_port(fcoe_netdev(lport)); 1909 fcoe = fcoe_hostlist_lookup_port(fcoe_netdev(lport));
1919 if (!fcoe) { 1910 if (!fcoe) {
1920 port = lport_priv(lport); 1911 port = lport_priv(lport);
1921 fcoe = port->fcoe; 1912 fcoe = port->fcoe;
1922 list_add_tail(&fcoe->list, &fcoe_hostlist); 1913 list_add_tail(&fcoe->list, &fcoe_hostlist);
1923 } 1914 }
1924 write_unlock_bh(&fcoe_hostlist_lock);
1925 return 0; 1915 return 0;
1926} 1916}
1927 1917
@@ -1979,7 +1969,6 @@ static void __exit fcoe_exit(void)
1979{ 1969{
1980 unsigned int cpu; 1970 unsigned int cpu;
1981 struct fcoe_interface *fcoe, *tmp; 1971 struct fcoe_interface *fcoe, *tmp;
1982 LIST_HEAD(local_list);
1983 struct fcoe_port *port; 1972 struct fcoe_port *port;
1984 1973
1985 mutex_lock(&fcoe_config_mutex); 1974 mutex_lock(&fcoe_config_mutex);
@@ -1987,18 +1976,14 @@ static void __exit fcoe_exit(void)
1987 fcoe_dev_cleanup(); 1976 fcoe_dev_cleanup();
1988 1977
1989 /* releases the associated fcoe hosts */ 1978 /* releases the associated fcoe hosts */
1990 write_lock_bh(&fcoe_hostlist_lock); 1979 rtnl_lock();
1991 list_splice_init(&fcoe_hostlist, &local_list); 1980 list_for_each_entry_safe(fcoe, tmp, &fcoe_hostlist, list) {
1992 write_unlock_bh(&fcoe_hostlist_lock);
1993
1994 list_for_each_entry_safe(fcoe, tmp, &local_list, list) {
1995 list_del(&fcoe->list); 1981 list_del(&fcoe->list);
1996 port = lport_priv(fcoe->ctlr.lp); 1982 port = lport_priv(fcoe->ctlr.lp);
1997 rtnl_lock();
1998 fcoe_interface_cleanup(fcoe); 1983 fcoe_interface_cleanup(fcoe);
1999 rtnl_unlock();
2000 schedule_work(&port->destroy_work); 1984 schedule_work(&port->destroy_work);
2001 } 1985 }
1986 rtnl_unlock();
2002 1987
2003 unregister_hotcpu_notifier(&fcoe_cpu_notifier); 1988 unregister_hotcpu_notifier(&fcoe_cpu_notifier);
2004 1989