diff options
author | nikolay@redhat.com <nikolay@redhat.com> | 2013-09-02 07:51:38 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-09-04 00:27:24 -0400 |
commit | 6c8d23f78646b20bdbdad476d015b6594ac8ff1c (patch) | |
tree | f3bc75b01a5871be54c022a303e0eac8c791cc98 /drivers/net/bonding | |
parent | f7c6be404d8fa52c54ff931390aab01e5c7654d6 (diff) |
bonding: simplify and fix peer notification
This patch aims to remove a use of the bond->lock for mutual exclusion
which will later allow easier migration to RCU of the users of this
functionality. We use RTNL as a synchronizing mechanism since it's
always held when send_peer_notif is set, and when it is decremented from
the notifier function. We can also drop some locking, and fix the
leakage of the send_peer_notif counter.
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.c | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index c50679f0a6b6..05e638b8ea25 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c | |||
@@ -828,7 +828,6 @@ static bool bond_should_notify_peers(struct bonding *bond) | |||
828 | test_bit(__LINK_STATE_LINKWATCH_PENDING, &slave->dev->state)) | 828 | test_bit(__LINK_STATE_LINKWATCH_PENDING, &slave->dev->state)) |
829 | return false; | 829 | return false; |
830 | 830 | ||
831 | bond->send_peer_notif--; | ||
832 | return true; | 831 | return true; |
833 | } | 832 | } |
834 | 833 | ||
@@ -2259,12 +2258,8 @@ re_arm: | |||
2259 | read_unlock(&bond->lock); | 2258 | read_unlock(&bond->lock); |
2260 | 2259 | ||
2261 | if (should_notify_peers) { | 2260 | if (should_notify_peers) { |
2262 | if (!rtnl_trylock()) { | 2261 | if (!rtnl_trylock()) |
2263 | read_lock(&bond->lock); | ||
2264 | bond->send_peer_notif++; | ||
2265 | read_unlock(&bond->lock); | ||
2266 | return; | 2262 | return; |
2267 | } | ||
2268 | call_netdevice_notifiers(NETDEV_NOTIFY_PEERS, bond->dev); | 2263 | call_netdevice_notifiers(NETDEV_NOTIFY_PEERS, bond->dev); |
2269 | rtnl_unlock(); | 2264 | rtnl_unlock(); |
2270 | } | 2265 | } |
@@ -2876,12 +2871,8 @@ re_arm: | |||
2876 | read_unlock(&bond->lock); | 2871 | read_unlock(&bond->lock); |
2877 | 2872 | ||
2878 | if (should_notify_peers) { | 2873 | if (should_notify_peers) { |
2879 | if (!rtnl_trylock()) { | 2874 | if (!rtnl_trylock()) |
2880 | read_lock(&bond->lock); | ||
2881 | bond->send_peer_notif++; | ||
2882 | read_unlock(&bond->lock); | ||
2883 | return; | 2875 | return; |
2884 | } | ||
2885 | call_netdevice_notifiers(NETDEV_NOTIFY_PEERS, bond->dev); | 2876 | call_netdevice_notifiers(NETDEV_NOTIFY_PEERS, bond->dev); |
2886 | rtnl_unlock(); | 2877 | rtnl_unlock(); |
2887 | } | 2878 | } |
@@ -2916,6 +2907,10 @@ static int bond_master_netdev_event(unsigned long event, | |||
2916 | case NETDEV_REGISTER: | 2907 | case NETDEV_REGISTER: |
2917 | bond_create_proc_entry(event_bond); | 2908 | bond_create_proc_entry(event_bond); |
2918 | break; | 2909 | break; |
2910 | case NETDEV_NOTIFY_PEERS: | ||
2911 | if (event_bond->send_peer_notif) | ||
2912 | event_bond->send_peer_notif--; | ||
2913 | break; | ||
2919 | default: | 2914 | default: |
2920 | break; | 2915 | break; |
2921 | } | 2916 | } |
@@ -3213,11 +3208,8 @@ static int bond_close(struct net_device *bond_dev) | |||
3213 | { | 3208 | { |
3214 | struct bonding *bond = netdev_priv(bond_dev); | 3209 | struct bonding *bond = netdev_priv(bond_dev); |
3215 | 3210 | ||
3216 | write_lock_bh(&bond->lock); | ||
3217 | bond->send_peer_notif = 0; | ||
3218 | write_unlock_bh(&bond->lock); | ||
3219 | |||
3220 | bond_work_cancel_all(bond); | 3211 | bond_work_cancel_all(bond); |
3212 | bond->send_peer_notif = 0; | ||
3221 | if (bond_is_lb(bond)) { | 3213 | if (bond_is_lb(bond)) { |
3222 | /* Must be called only after all | 3214 | /* Must be called only after all |
3223 | * slaves have been released | 3215 | * slaves have been released |