diff options
author | Jay Vosburgh <fubar@us.ibm.com> | 2007-10-17 20:37:47 -0400 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2007-10-23 20:32:00 -0400 |
commit | cf5f9044934658dd3ffc628a60cd37c70f8168b1 (patch) | |
tree | 406baa95870c3e86858fd9ff98bc145c53dfa6ac /drivers/net/bonding/bond_main.c | |
parent | 1b76b31693d4a6088dec104ff6a6ead54081a3c2 (diff) |
bonding: Convert balance-rr transmit to new locking
Change locking in balance-rr transmit processing to use a free
running counter to determine which slave to transmit on. Instead, a
free-running counter is maintained, and modulo arithmetic used to select
a slave for transmit.
This removes lock operations from the TX path, and eliminates
a deadlock introduced by the conversion to work queues.
Signed-off-by: Andy Gospodarek <andy@greyhouse.net>
Signed-off-by: Jay Vosburgh <fubar@us.ibm.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/net/bonding/bond_main.c')
-rw-r--r-- | drivers/net/bonding/bond_main.c | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index ed361d62d702..862ed8ece14e 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c | |||
@@ -4057,8 +4057,7 @@ static int bond_xmit_roundrobin(struct sk_buff *skb, struct net_device *bond_dev | |||
4057 | { | 4057 | { |
4058 | struct bonding *bond = bond_dev->priv; | 4058 | struct bonding *bond = bond_dev->priv; |
4059 | struct slave *slave, *start_at; | 4059 | struct slave *slave, *start_at; |
4060 | int i; | 4060 | int i, slave_no, res = 1; |
4061 | int res = 1; | ||
4062 | 4061 | ||
4063 | read_lock(&bond->lock); | 4062 | read_lock(&bond->lock); |
4064 | 4063 | ||
@@ -4066,29 +4065,29 @@ static int bond_xmit_roundrobin(struct sk_buff *skb, struct net_device *bond_dev | |||
4066 | goto out; | 4065 | goto out; |
4067 | } | 4066 | } |
4068 | 4067 | ||
4069 | read_lock(&bond->curr_slave_lock); | 4068 | /* |
4070 | slave = start_at = bond->curr_active_slave; | 4069 | * Concurrent TX may collide on rr_tx_counter; we accept that |
4071 | read_unlock(&bond->curr_slave_lock); | 4070 | * as being rare enough not to justify using an atomic op here |
4071 | */ | ||
4072 | slave_no = bond->rr_tx_counter++ % bond->slave_cnt; | ||
4072 | 4073 | ||
4073 | if (!slave) { | 4074 | bond_for_each_slave(bond, slave, i) { |
4074 | goto out; | 4075 | slave_no--; |
4076 | if (slave_no < 0) { | ||
4077 | break; | ||
4078 | } | ||
4075 | } | 4079 | } |
4076 | 4080 | ||
4081 | start_at = slave; | ||
4077 | bond_for_each_slave_from(bond, slave, i, start_at) { | 4082 | bond_for_each_slave_from(bond, slave, i, start_at) { |
4078 | if (IS_UP(slave->dev) && | 4083 | if (IS_UP(slave->dev) && |
4079 | (slave->link == BOND_LINK_UP) && | 4084 | (slave->link == BOND_LINK_UP) && |
4080 | (slave->state == BOND_STATE_ACTIVE)) { | 4085 | (slave->state == BOND_STATE_ACTIVE)) { |
4081 | res = bond_dev_queue_xmit(bond, skb, slave->dev); | 4086 | res = bond_dev_queue_xmit(bond, skb, slave->dev); |
4082 | |||
4083 | write_lock(&bond->curr_slave_lock); | ||
4084 | bond->curr_active_slave = slave->next; | ||
4085 | write_unlock(&bond->curr_slave_lock); | ||
4086 | |||
4087 | break; | 4087 | break; |
4088 | } | 4088 | } |
4089 | } | 4089 | } |
4090 | 4090 | ||
4091 | |||
4092 | out: | 4091 | out: |
4093 | if (res) { | 4092 | if (res) { |
4094 | /* no suitable interface, frame not sent */ | 4093 | /* no suitable interface, frame not sent */ |