[Open-FCoE] [PATCH V5 16/16] fcoe: use rtnl mutex in place of hostlist lock

Chris Leech christopher.leech at intel.com
Mon Jul 27 16:29:31 UTC 2009


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 at intel.com>
---

 drivers/scsi/fcoe/fcoe.c |   22 ++++++++++------------
 1 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c
index 290baaa..499e57d 100644
--- a/drivers/scsi/fcoe/fcoe.c
+++ b/drivers/scsi/fcoe/fcoe.c
@@ -58,8 +58,8 @@ MODULE_PARM_DESC(fcoe_ddp_min, "Minimum I/O size in bytes for "	\
 DEFINE_MUTEX(fcoe_config_mutex);
 
 /* fcoe host list */
+/* must only by accessed under the RTNL mutex */
 LIST_HEAD(fcoe_hostlist);
-DEFINE_RWLOCK(fcoe_hostlist_lock);
 DEFINE_PER_CPU(struct fcoe_percpu_s, fcoe_percpu);
 
 /* Function Prototypes */
@@ -1544,7 +1544,6 @@ static int fcoe_device_notification(struct notifier_block *notifier,
 	u32 mfs;
 	int rc = NOTIFY_OK;
 
-	write_lock(&fcoe_hostlist_lock);
 	list_for_each_entry(fcoe, &fcoe_hostlist, list) {
 		if (fcoe->netdev == netdev) {
 			lp = fcoe->ctlr.lp;
@@ -1590,7 +1589,6 @@ static int fcoe_device_notification(struct notifier_block *notifier,
 		fcoe_clean_pending_queue(lp);
 	}
 out:
-	write_unlock(&fcoe_hostlist_lock);
 	return rc;
 }
 
@@ -1647,15 +1645,15 @@ static int fcoe_destroy(const char *buffer, struct kernel_param *kp)
 		goto out_nodev;
 	}
 
-	write_lock(&fcoe_hostlist_lock);
+	rtnl_lock();
 	fcoe = fcoe_hostlist_lookup_port(netdev);
 	if (!fcoe) {
-		write_unlock(&fcoe_hostlist_lock);
+		rtnl_unlock();
 		rc = -ENODEV;
 		goto out_nodev;
 	}
 	list_del(&fcoe->list);
-	write_unlock(&fcoe_hostlist_lock);
+	rtnl_unlock();
 	fcoe_if_destroy(fcoe->ctlr.lp);
 	dev_put(netdev);
 out_nodev:
@@ -1893,9 +1891,9 @@ struct fc_lport *fcoe_hostlist_lookup(const struct net_device *netdev)
 {
 	struct fcoe_interface *fcoe;
 
-	read_lock(&fcoe_hostlist_lock);
+	rtnl_lock();
 	fcoe = fcoe_hostlist_lookup_port(netdev);
-	read_unlock(&fcoe_hostlist_lock);
+	rtnl_unlock();
 
 	return (fcoe) ? fcoe->ctlr.lp : NULL;
 }
@@ -1911,14 +1909,14 @@ int fcoe_hostlist_add(const struct fc_lport *lport)
 	struct fcoe_interface *fcoe;
 	struct fcoe_port *port;
 
-	write_lock_bh(&fcoe_hostlist_lock);
+	rtnl_lock();
 	fcoe = fcoe_hostlist_lookup_port(fcoe_netdev(lport));
 	if (!fcoe) {
 		port = lport_priv(lport);
 		fcoe = port->fcoe;
 		list_add_tail(&fcoe->list, &fcoe_hostlist);
 	}
-	write_unlock_bh(&fcoe_hostlist_lock);
+	rtnl_unlock();
 	return 0;
 }
 
@@ -1983,13 +1981,13 @@ static void __exit fcoe_exit(void)
 	fcoe_dev_cleanup();
 
 	/* releases the associated fcoe hosts */
-	write_lock_bh(&fcoe_hostlist_lock);
+	rtnl_lock();
 	list_for_each_entry_safe(fcoe, tmp, &fcoe_hostlist, list) {
 		list_del(&fcoe->list);
 		port = lport_priv(fcoe->ctlr.lp);
 		schedule_work(&port->destroy_work);
 	}
-	write_unlock_bh(&fcoe_hostlist_lock);
+	rtnl_unlock();
 
 	unregister_hotcpu_notifier(&fcoe_cpu_notifier);
 




More information about the devel mailing list