Skip to content

Commit 090eb6c

Browse files
Chris LeechJames Bottomley
authored andcommitted
[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>
1 parent 2e70e24 commit 090eb6c

1 file changed

Lines changed: 11 additions & 26 deletions

File tree

‎drivers/scsi/fcoe/fcoe.c‎

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ MODULE_PARM_DESC(ddp_min, "Minimum I/O size in bytes for " \
5858
DEFINE_MUTEX(fcoe_config_mutex);
5959

6060
/* fcoe host list */
61+
/* must only by accessed under the RTNL mutex */
6162
LIST_HEAD(fcoe_hostlist);
62-
DEFINE_RWLOCK(fcoe_hostlist_lock);
6363
DEFINE_PER_CPU(struct fcoe_percpu_s, fcoe_percpu);
6464

6565
/* Function Prototypes */
@@ -527,8 +527,6 @@ bool fcoe_oem_match(struct fc_frame *fp)
527527
* fcoe_em_config() - allocates em for this lport
528528
* @lp: the fcoe that em is to allocated for
529529
*
530-
* Called with write fcoe_hostlist_lock held.
531-
*
532530
* Returns : 0 on success
533531
*/
534532
static inline int fcoe_em_config(struct fc_lport *lp)
@@ -1539,7 +1537,6 @@ static int fcoe_device_notification(struct notifier_block *notifier,
15391537
u32 mfs;
15401538
int rc = NOTIFY_OK;
15411539

1542-
write_lock(&fcoe_hostlist_lock);
15431540
list_for_each_entry(fcoe, &fcoe_hostlist, list) {
15441541
if (fcoe->netdev == netdev) {
15451542
lp = fcoe->ctlr.lp;
@@ -1586,7 +1583,6 @@ static int fcoe_device_notification(struct notifier_block *notifier,
15861583
fcoe_clean_pending_queue(lp);
15871584
}
15881585
out:
1589-
write_unlock(&fcoe_hostlist_lock);
15901586
return rc;
15911587
}
15921588

@@ -1643,16 +1639,14 @@ static int fcoe_destroy(const char *buffer, struct kernel_param *kp)
16431639
goto out_nodev;
16441640
}
16451641

1646-
write_lock(&fcoe_hostlist_lock);
1642+
rtnl_lock();
16471643
fcoe = fcoe_hostlist_lookup_port(netdev);
16481644
if (!fcoe) {
1649-
write_unlock(&fcoe_hostlist_lock);
1645+
rtnl_unlock();
16501646
rc = -ENODEV;
16511647
goto out_putdev;
16521648
}
16531649
list_del(&fcoe->list);
1654-
write_unlock(&fcoe_hostlist_lock);
1655-
rtnl_lock();
16561650
fcoe_interface_cleanup(fcoe);
16571651
rtnl_unlock();
16581652
fcoe_if_destroy(fcoe->ctlr.lp);
@@ -1870,9 +1864,8 @@ int fcoe_reset(struct Scsi_Host *shost)
18701864
* fcoe_hostlist_lookup_port() - find the corresponding lport by a given device
18711865
* @dev: this is currently ptr to net_device
18721866
*
1873-
* Called with fcoe_hostlist_lock held.
1874-
*
18751867
* Returns: NULL or the located fcoe_port
1868+
* Locking: must be called with the RNL mutex held
18761869
*/
18771870
static struct fcoe_interface *
18781871
fcoe_hostlist_lookup_port(const struct net_device *dev)
@@ -1891,15 +1884,13 @@ fcoe_hostlist_lookup_port(const struct net_device *dev)
18911884
* @netdev: ptr to net_device
18921885
*
18931886
* Returns: 0 for success
1887+
* Locking: must be called with the RTNL mutex held
18941888
*/
1895-
struct fc_lport *fcoe_hostlist_lookup(const struct net_device *netdev)
1889+
static struct fc_lport *fcoe_hostlist_lookup(const struct net_device *netdev)
18961890
{
18971891
struct fcoe_interface *fcoe;
18981892

1899-
read_lock(&fcoe_hostlist_lock);
19001893
fcoe = fcoe_hostlist_lookup_port(netdev);
1901-
read_unlock(&fcoe_hostlist_lock);
1902-
19031894
return (fcoe) ? fcoe->ctlr.lp : NULL;
19041895
}
19051896

@@ -1908,20 +1899,19 @@ struct fc_lport *fcoe_hostlist_lookup(const struct net_device *netdev)
19081899
* @lp: ptr to the fc_lport to be added
19091900
*
19101901
* Returns: 0 for success
1902+
* Locking: must be called with the RTNL mutex held
19111903
*/
1912-
int fcoe_hostlist_add(const struct fc_lport *lport)
1904+
static int fcoe_hostlist_add(const struct fc_lport *lport)
19131905
{
19141906
struct fcoe_interface *fcoe;
19151907
struct fcoe_port *port;
19161908

1917-
write_lock_bh(&fcoe_hostlist_lock);
19181909
fcoe = fcoe_hostlist_lookup_port(fcoe_netdev(lport));
19191910
if (!fcoe) {
19201911
port = lport_priv(lport);
19211912
fcoe = port->fcoe;
19221913
list_add_tail(&fcoe->list, &fcoe_hostlist);
19231914
}
1924-
write_unlock_bh(&fcoe_hostlist_lock);
19251915
return 0;
19261916
}
19271917

@@ -1979,26 +1969,21 @@ static void __exit fcoe_exit(void)
19791969
{
19801970
unsigned int cpu;
19811971
struct fcoe_interface *fcoe, *tmp;
1982-
LIST_HEAD(local_list);
19831972
struct fcoe_port *port;
19841973

19851974
mutex_lock(&fcoe_config_mutex);
19861975

19871976
fcoe_dev_cleanup();
19881977

19891978
/* releases the associated fcoe hosts */
1990-
write_lock_bh(&fcoe_hostlist_lock);
1991-
list_splice_init(&fcoe_hostlist, &local_list);
1992-
write_unlock_bh(&fcoe_hostlist_lock);
1993-
1994-
list_for_each_entry_safe(fcoe, tmp, &local_list, list) {
1979+
rtnl_lock();
1980+
list_for_each_entry_safe(fcoe, tmp, &fcoe_hostlist, list) {
19951981
list_del(&fcoe->list);
19961982
port = lport_priv(fcoe->ctlr.lp);
1997-
rtnl_lock();
19981983
fcoe_interface_cleanup(fcoe);
1999-
rtnl_unlock();
20001984
schedule_work(&port->destroy_work);
20011985
}
1986+
rtnl_unlock();
20021987

20031988
unregister_hotcpu_notifier(&fcoe_cpu_notifier);
20041989

0 commit comments

Comments
 (0)