aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/bonding
diff options
context:
space:
mode:
authordingtianhong <dingtianhong@huawei.com>2013-10-23 23:09:25 -0400
committerDavid S. Miller <davem@davemloft.net>2013-10-27 16:36:29 -0400
commit80b9d236ec56ecc18da4a43bd79e8ec9ac5036ff (patch)
tree8bcd60a4486a458bad82b39f65ad4e251af7fba9 /drivers/net/bonding
parent7f1bb571b753ac75b6548f0b7c932dfc0bb1f970 (diff)
bonding: remove bond read lock for bond_activebackup_arp_mon()
The bond slave list may change when the monitor is running, the slave list is no longer protected by bond->lock, only protected by rtnl lock(), so we have 3 ways to modify it: 1.add bond_master_upper_dev_link() and bond_upper_dev_unlink() in bond->lock, but it is unsafe to call call_netdevice_notifiers() in write lock. 2.remove unused bond->lock for monitor function, only use the existing rtnl lock(). 3.use rcu_read_lock() to protect it, of course, it will transform bond_for_each_slave to bond_for_each_slave_rcu() and performance is better, but in slow path, it is ignored. so I remove the bond->lock and move the rtnl lock to protect the whole monitor function. Signed-off-by: Ding Tianhong <dingtianhong@huawei.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/bonding')
-rw-r--r--drivers/net/bonding/bond_main.c46
1 files changed, 13 insertions, 33 deletions
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index a620dfae1c82..535570ea8bbc 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -2726,51 +2726,31 @@ void bond_activebackup_arp_mon(struct work_struct *work)
2726 struct bonding *bond = container_of(work, struct bonding, 2726 struct bonding *bond = container_of(work, struct bonding,
2727 arp_work.work); 2727 arp_work.work);
2728 bool should_notify_peers = false; 2728 bool should_notify_peers = false;
2729 int delta_in_ticks;
2730 2729
2731 read_lock(&bond->lock); 2730 if (!rtnl_trylock())
2732 2731 goto re_arm;
2733 delta_in_ticks = msecs_to_jiffies(bond->params.arp_interval);
2734 2732
2735 if (!bond_has_slaves(bond)) 2733 if (!bond_has_slaves(bond)) {
2734 rtnl_unlock();
2736 goto re_arm; 2735 goto re_arm;
2736 }
2737 2737
2738 should_notify_peers = bond_should_notify_peers(bond); 2738 should_notify_peers = bond_should_notify_peers(bond);
2739 2739
2740 if (bond_ab_arp_inspect(bond)) { 2740 if (bond_ab_arp_inspect(bond))
2741 read_unlock(&bond->lock);
2742
2743 /* Race avoidance with bond_close flush of workqueue */
2744 if (!rtnl_trylock()) {
2745 read_lock(&bond->lock);
2746 delta_in_ticks = 1;
2747 should_notify_peers = false;
2748 goto re_arm;
2749 }
2750
2751 read_lock(&bond->lock);
2752
2753 bond_ab_arp_commit(bond); 2741 bond_ab_arp_commit(bond);
2754 2742
2755 read_unlock(&bond->lock);
2756 rtnl_unlock();
2757 read_lock(&bond->lock);
2758 }
2759
2760 bond_ab_arp_probe(bond); 2743 bond_ab_arp_probe(bond);
2761 2744
2762re_arm: 2745 if (should_notify_peers)
2763 if (bond->params.arp_interval) 2746 call_netdevice_notifiers(NETDEV_NOTIFY_PEERS, bond->dev);
2764 queue_delayed_work(bond->wq, &bond->arp_work, delta_in_ticks);
2765 2747
2766 read_unlock(&bond->lock); 2748 rtnl_unlock();
2767 2749
2768 if (should_notify_peers) { 2750re_arm:
2769 if (!rtnl_trylock()) 2751 if (bond->params.arp_interval)
2770 return; 2752 queue_delayed_work(bond->wq, &bond->arp_work,
2771 call_netdevice_notifiers(NETDEV_NOTIFY_PEERS, bond->dev); 2753 msecs_to_jiffies(bond->params.arp_interval));
2772 rtnl_unlock();
2773 }
2774} 2754}
2775 2755
2776/*-------------------------- netdev event handling --------------------------*/ 2756/*-------------------------- netdev event handling --------------------------*/