Commit 71bc3b2d authored by nikolay@redhat.com's avatar nikolay@redhat.com Committed by David S. Miller

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: default avatarNikolay Aleksandrov <nikolay@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent dec1e90e
...@@ -2092,23 +2092,19 @@ static int bond_ioctl_change_active(struct net_device *bond_dev, struct net_devi ...@@ -2092,23 +2092,19 @@ static int bond_ioctl_change_active(struct net_device *bond_dev, struct net_devi
read_lock(&bond->lock); read_lock(&bond->lock);
read_lock(&bond->curr_slave_lock);
old_active = bond->curr_active_slave; old_active = bond->curr_active_slave;
read_unlock(&bond->curr_slave_lock);
new_active = bond_get_slave_by_dev(bond, slave_dev); new_active = bond_get_slave_by_dev(bond, slave_dev);
/* /*
* Changing to the current active: do nothing; return success. * Changing to the current active: do nothing; return success.
*/ */
if (new_active && (new_active == old_active)) { if (new_active && new_active == old_active) {
read_unlock(&bond->lock); read_unlock(&bond->lock);
return 0; return 0;
} }
if ((new_active) && if (new_active &&
(old_active) && old_active &&
(new_active->link == BOND_LINK_UP) && new_active->link == BOND_LINK_UP &&
IS_UP(new_active->dev)) { IS_UP(new_active->dev)) {
block_netpoll_tx(); block_netpoll_tx();
write_lock_bh(&bond->curr_slave_lock); write_lock_bh(&bond->curr_slave_lock);
...@@ -2660,10 +2656,7 @@ void bond_loadbalance_arp_mon(struct work_struct *work) ...@@ -2660,10 +2656,7 @@ void bond_loadbalance_arp_mon(struct work_struct *work)
if (list_empty(&bond->slave_list)) if (list_empty(&bond->slave_list))
goto re_arm; goto re_arm;
read_lock(&bond->curr_slave_lock);
oldcurrent = bond->curr_active_slave; oldcurrent = bond->curr_active_slave;
read_unlock(&bond->curr_slave_lock);
/* see if any of the previous devices are up now (i.e. they have /* see if any of the previous devices are up now (i.e. they have
* xmt and rcv traffic). the curr_active_slave does not come into * xmt and rcv traffic). the curr_active_slave does not come into
* the picture unless it is null. also, slave->jiffies is not needed * 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,11 +3811,7 @@ static int bond_xmit_roundrobin(struct sk_buff *skb, struct net_device *bond_dev
*/ */
if ((iph->protocol == IPPROTO_IGMP) && if ((iph->protocol == IPPROTO_IGMP) &&
(skb->protocol == htons(ETH_P_IP))) { (skb->protocol == htons(ETH_P_IP))) {
read_lock(&bond->curr_slave_lock);
slave = bond->curr_active_slave; slave = bond->curr_active_slave;
read_unlock(&bond->curr_slave_lock);
if (!slave) if (!slave)
goto out; goto out;
} else { } else {
...@@ -3867,15 +3856,12 @@ static int bond_xmit_roundrobin(struct sk_buff *skb, struct net_device *bond_dev ...@@ -3867,15 +3856,12 @@ static int bond_xmit_roundrobin(struct sk_buff *skb, struct net_device *bond_dev
static int bond_xmit_activebackup(struct sk_buff *skb, struct net_device *bond_dev) static int bond_xmit_activebackup(struct sk_buff *skb, struct net_device *bond_dev)
{ {
struct bonding *bond = netdev_priv(bond_dev); struct bonding *bond = netdev_priv(bond_dev);
struct slave *slave;
int res = 1; int res = 1;
read_lock(&bond->curr_slave_lock); slave = bond->curr_active_slave;
if (slave)
if (bond->curr_active_slave) res = bond_dev_queue_xmit(bond, skb, slave->dev);
res = bond_dev_queue_xmit(bond, skb,
bond->curr_active_slave->dev);
read_unlock(&bond->curr_slave_lock);
if (res) if (res)
/* no suitable interface, frame not sent */ /* 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,10 +3921,7 @@ static int bond_xmit_broadcast(struct sk_buff *skb, struct net_device *bond_dev)
int i; int i;
int res = 1; int res = 1;
read_lock(&bond->curr_slave_lock);
start_at = bond->curr_active_slave; start_at = bond->curr_active_slave;
read_unlock(&bond->curr_slave_lock);
if (!start_at) if (!start_at)
goto out; goto out;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment