diff options
author | nikolay@redhat.com <nikolay@redhat.com> | 2013-09-02 07:51:40 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-09-04 00:27:24 -0400 |
commit | c509316b5b33664b08b2a40d09534e0bd3c6b648 (patch) | |
tree | 3769e355a452894b9eaa4694f0486670c8adde64 /drivers/net/bonding | |
parent | ee8487c0e1aed52b534f9bf31d3934af4c50bf33 (diff) |
bonding: simplify bond_3ad_update_lacp_rate and use RTNL for sync
We can drop the use of bond->lock for mutual exclusion in
bond_3ad_update_lacp_rate and use RTNL in the sysfs store function
instead. This way we'll prevent races with mode change and interface
up/down as well as simplify update_lacp_rate by removing the check for
port->slave because it'll always be initialized (done while enslaving
with RTNL). This change will also help in the future removal of reader
bond->lock from bond_enslave.
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_3ad.c | 8 | ||||
-rw-r--r-- | drivers/net/bonding/bond_sysfs.c | 7 |
2 files changed, 7 insertions, 8 deletions
diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c index 90102652c82a..0d8f427ade93 100644 --- a/drivers/net/bonding/bond_3ad.c +++ b/drivers/net/bonding/bond_3ad.c | |||
@@ -2514,17 +2514,13 @@ int bond_3ad_lacpdu_recv(const struct sk_buff *skb, struct bonding *bond, | |||
2514 | */ | 2514 | */ |
2515 | void bond_3ad_update_lacp_rate(struct bonding *bond) | 2515 | void bond_3ad_update_lacp_rate(struct bonding *bond) |
2516 | { | 2516 | { |
2517 | struct slave *slave; | ||
2518 | struct port *port = NULL; | 2517 | struct port *port = NULL; |
2518 | struct slave *slave; | ||
2519 | int lacp_fast; | 2519 | int lacp_fast; |
2520 | 2520 | ||
2521 | write_lock_bh(&bond->lock); | ||
2522 | lacp_fast = bond->params.lacp_fast; | 2521 | lacp_fast = bond->params.lacp_fast; |
2523 | |||
2524 | bond_for_each_slave(bond, slave) { | 2522 | bond_for_each_slave(bond, slave) { |
2525 | port = &(SLAVE_AD_INFO(slave).port); | 2523 | port = &(SLAVE_AD_INFO(slave).port); |
2526 | if (port->slave == NULL) | ||
2527 | continue; | ||
2528 | __get_state_machine_lock(port); | 2524 | __get_state_machine_lock(port); |
2529 | if (lacp_fast) | 2525 | if (lacp_fast) |
2530 | port->actor_oper_port_state |= AD_STATE_LACP_TIMEOUT; | 2526 | port->actor_oper_port_state |= AD_STATE_LACP_TIMEOUT; |
@@ -2532,6 +2528,4 @@ void bond_3ad_update_lacp_rate(struct bonding *bond) | |||
2532 | port->actor_oper_port_state &= ~AD_STATE_LACP_TIMEOUT; | 2528 | port->actor_oper_port_state &= ~AD_STATE_LACP_TIMEOUT; |
2533 | __release_state_machine_lock(port); | 2529 | __release_state_machine_lock(port); |
2534 | } | 2530 | } |
2535 | |||
2536 | write_unlock_bh(&bond->lock); | ||
2537 | } | 2531 | } |
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c index 0f539de640dc..ce4677668e2c 100644 --- a/drivers/net/bonding/bond_sysfs.c +++ b/drivers/net/bonding/bond_sysfs.c | |||
@@ -852,8 +852,11 @@ static ssize_t bonding_store_lacp(struct device *d, | |||
852 | struct device_attribute *attr, | 852 | struct device_attribute *attr, |
853 | const char *buf, size_t count) | 853 | const char *buf, size_t count) |
854 | { | 854 | { |
855 | int new_value, ret = count; | ||
856 | struct bonding *bond = to_bond(d); | 855 | struct bonding *bond = to_bond(d); |
856 | int new_value, ret = count; | ||
857 | |||
858 | if (!rtnl_trylock()) | ||
859 | return restart_syscall(); | ||
857 | 860 | ||
858 | if (bond->dev->flags & IFF_UP) { | 861 | if (bond->dev->flags & IFF_UP) { |
859 | pr_err("%s: Unable to update LACP rate because interface is up.\n", | 862 | pr_err("%s: Unable to update LACP rate because interface is up.\n", |
@@ -883,6 +886,8 @@ static ssize_t bonding_store_lacp(struct device *d, | |||
883 | ret = -EINVAL; | 886 | ret = -EINVAL; |
884 | } | 887 | } |
885 | out: | 888 | out: |
889 | rtnl_unlock(); | ||
890 | |||
886 | return ret; | 891 | return ret; |
887 | } | 892 | } |
888 | static DEVICE_ATTR(lacp_rate, S_IRUGO | S_IWUSR, | 893 | static DEVICE_ATTR(lacp_rate, S_IRUGO | S_IWUSR, |