aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/bonding
diff options
context:
space:
mode:
authornikolay@redhat.com <nikolay@redhat.com>2013-08-01 10:54:48 -0400
committerDavid S. Miller <davem@davemloft.net>2013-08-01 19:42:02 -0400
commit71bc3b2dc5d02566afe1b23a7b72bfc8acdd04e1 (patch)
treea52f4d6130847f9089a5f02bec46750fec926725 /drivers/net/bonding
parentdec1e90e8c7157a527faad95023d96dbc114fbac (diff)
bonding: remove unnecessary read_locks of curr_slave_lock
In all the cases we already hold bond->lock for reading, so the slave can't get away and the check != NULL is sufficient. curr_active_slave can still change after the read_lock is unlocked prior to use of the dereferenced value, so there's no need for it. It either contains a valid slave which we use (and can't get away), or it is NULL which is checked. In some places the read_lock of curr_slave_lock was left because we need it not to change while performing some action (e.g. syncing current active slave's addresses, sending ARP requests through the active slave) such cases will be dealt with individually while converting to RCU. Signed-off-by: Nikolay Aleksandrov <nikolay@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/bonding')
-rw-r--r--drivers/net/bonding/bond_main.c33
1 files changed, 8 insertions, 25 deletions
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 2e8ec8b79f05..ac60b697ab7e 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -2092,23 +2092,19 @@ static int bond_ioctl_change_active(struct net_device *bond_dev, struct net_devi
2092 2092
2093 read_lock(&bond->lock); 2093 read_lock(&bond->lock);
2094 2094
2095 read_lock(&bond->curr_slave_lock);
2096 old_active = bond->curr_active_slave; 2095 old_active = bond->curr_active_slave;
2097 read_unlock(&bond->curr_slave_lock);
2098
2099 new_active = bond_get_slave_by_dev(bond, slave_dev); 2096 new_active = bond_get_slave_by_dev(bond, slave_dev);
2100
2101 /* 2097 /*
2102 * Changing to the current active: do nothing; return success. 2098 * Changing to the current active: do nothing; return success.
2103 */ 2099 */
2104 if (new_active && (new_active == old_active)) { 2100 if (new_active && new_active == old_active) {
2105 read_unlock(&bond->lock); 2101 read_unlock(&bond->lock);
2106 return 0; 2102 return 0;
2107 } 2103 }
2108 2104
2109 if ((new_active) && 2105 if (new_active &&
2110 (old_active) && 2106 old_active &&
2111 (new_active->link == BOND_LINK_UP) && 2107 new_active->link == BOND_LINK_UP &&
2112 IS_UP(new_active->dev)) { 2108 IS_UP(new_active->dev)) {
2113 block_netpoll_tx(); 2109 block_netpoll_tx();
2114 write_lock_bh(&bond->curr_slave_lock); 2110 write_lock_bh(&bond->curr_slave_lock);
@@ -2660,10 +2656,7 @@ void bond_loadbalance_arp_mon(struct work_struct *work)
2660 if (list_empty(&bond->slave_list)) 2656 if (list_empty(&bond->slave_list))
2661 goto re_arm; 2657 goto re_arm;
2662 2658
2663 read_lock(&bond->curr_slave_lock);
2664 oldcurrent = bond->curr_active_slave; 2659 oldcurrent = bond->curr_active_slave;
2665 read_unlock(&bond->curr_slave_lock);
2666
2667 /* see if any of the previous devices are up now (i.e. they have 2660 /* see if any of the previous devices are up now (i.e. they have
2668 * xmt and rcv traffic). the curr_active_slave does not come into 2661 * xmt and rcv traffic). the curr_active_slave does not come into
2669 * the picture unless it is null. also, slave->jiffies is not needed 2662 * the picture unless it is null. also, slave->jiffies is not needed
@@ -3818,11 +3811,7 @@ static int bond_xmit_roundrobin(struct sk_buff *skb, struct net_device *bond_dev
3818 */ 3811 */
3819 if ((iph->protocol == IPPROTO_IGMP) && 3812 if ((iph->protocol == IPPROTO_IGMP) &&
3820 (skb->protocol == htons(ETH_P_IP))) { 3813 (skb->protocol == htons(ETH_P_IP))) {
3821
3822 read_lock(&bond->curr_slave_lock);
3823 slave = bond->curr_active_slave; 3814 slave = bond->curr_active_slave;
3824 read_unlock(&bond->curr_slave_lock);
3825
3826 if (!slave) 3815 if (!slave)
3827 goto out; 3816 goto out;
3828 } else { 3817 } else {
@@ -3867,15 +3856,12 @@ out:
3867static int bond_xmit_activebackup(struct sk_buff *skb, struct net_device *bond_dev) 3856static int bond_xmit_activebackup(struct sk_buff *skb, struct net_device *bond_dev)
3868{ 3857{
3869 struct bonding *bond = netdev_priv(bond_dev); 3858 struct bonding *bond = netdev_priv(bond_dev);
3859 struct slave *slave;
3870 int res = 1; 3860 int res = 1;
3871 3861
3872 read_lock(&bond->curr_slave_lock); 3862 slave = bond->curr_active_slave;
3873 3863 if (slave)
3874 if (bond->curr_active_slave) 3864 res = bond_dev_queue_xmit(bond, skb, slave->dev);
3875 res = bond_dev_queue_xmit(bond, skb,
3876 bond->curr_active_slave->dev);
3877
3878 read_unlock(&bond->curr_slave_lock);
3879 3865
3880 if (res) 3866 if (res)
3881 /* no suitable interface, frame not sent */ 3867 /* no suitable interface, frame not sent */
@@ -3935,10 +3921,7 @@ static int bond_xmit_broadcast(struct sk_buff *skb, struct net_device *bond_dev)
3935 int i; 3921 int i;
3936 int res = 1; 3922 int res = 1;
3937 3923
3938 read_lock(&bond->curr_slave_lock);
3939 start_at = bond->curr_active_slave; 3924 start_at = bond->curr_active_slave;
3940 read_unlock(&bond->curr_slave_lock);
3941
3942 if (!start_at) 3925 if (!start_at)
3943 goto out; 3926 goto out;
3944 3927