Commit b9f60253 authored by Jiri Pirko's avatar Jiri Pirko Committed by David S. Miller

bonding: make ab_arp select active slaves as other modes

When I was implementing primary_passive option (formely named primary_lazy) I've
run into troubles with ab_arp. This is the only mode which is not using
bond_select_active_slave() function to select active slave and instead it
selects it itself. This seems to be not the right behaviour and it would be
better to do it in bond_select_active_slave() for all cases. This patch makes
this happen. Please review.
Signed-off-by: default avatarJiri Pirko <jpirko@redhat.com>
Signed-off-by: default avatarJay Vosburgh <fubar@us.ibm.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c127bdf9
...@@ -1093,15 +1093,8 @@ static struct slave *bond_find_best_slave(struct bonding *bond) ...@@ -1093,15 +1093,8 @@ static struct slave *bond_find_best_slave(struct bonding *bond)
return NULL; /* still no slave, return NULL */ return NULL; /* still no slave, return NULL */
} }
/*
* first try the primary link; if arping, a link must tx/rx
* traffic before it can be considered the curr_active_slave.
* also, we would skip slaves between the curr_active_slave
* and primary_slave that may be up and able to arp
*/
if ((bond->primary_slave) && if ((bond->primary_slave) &&
(!bond->params.arp_interval) && bond->primary_slave->link == BOND_LINK_UP) {
(IS_UP(bond->primary_slave->dev))) {
new_active = bond->primary_slave; new_active = bond->primary_slave;
} }
...@@ -1109,15 +1102,14 @@ static struct slave *bond_find_best_slave(struct bonding *bond) ...@@ -1109,15 +1102,14 @@ static struct slave *bond_find_best_slave(struct bonding *bond)
old_active = new_active; old_active = new_active;
bond_for_each_slave_from(bond, new_active, i, old_active) { bond_for_each_slave_from(bond, new_active, i, old_active) {
if (IS_UP(new_active->dev)) { if (new_active->link == BOND_LINK_UP) {
if (new_active->link == BOND_LINK_UP) { return new_active;
return new_active; } else if (new_active->link == BOND_LINK_BACK &&
} else if (new_active->link == BOND_LINK_BACK) { IS_UP(new_active->dev)) {
/* link up, but waiting for stabilization */ /* link up, but waiting for stabilization */
if (new_active->delay < mintime) { if (new_active->delay < mintime) {
mintime = new_active->delay; mintime = new_active->delay;
bestslave = new_active; bestslave = new_active;
}
} }
} }
} }
...@@ -2932,18 +2924,6 @@ static int bond_ab_arp_inspect(struct bonding *bond, int delta_in_ticks) ...@@ -2932,18 +2924,6 @@ static int bond_ab_arp_inspect(struct bonding *bond, int delta_in_ticks)
} }
} }
read_lock(&bond->curr_slave_lock);
/*
* Trigger a commit if the primary option setting has changed.
*/
if (bond->primary_slave &&
(bond->primary_slave != bond->curr_active_slave) &&
(bond->primary_slave->link == BOND_LINK_UP))
commit++;
read_unlock(&bond->curr_slave_lock);
return commit; return commit;
} }
...@@ -2964,90 +2944,58 @@ static void bond_ab_arp_commit(struct bonding *bond, int delta_in_ticks) ...@@ -2964,90 +2944,58 @@ static void bond_ab_arp_commit(struct bonding *bond, int delta_in_ticks)
continue; continue;
case BOND_LINK_UP: case BOND_LINK_UP:
write_lock_bh(&bond->curr_slave_lock); if ((!bond->curr_active_slave &&
time_before_eq(jiffies,
if (!bond->curr_active_slave && dev_trans_start(slave->dev) +
time_before_eq(jiffies, dev_trans_start(slave->dev) + delta_in_ticks)) ||
delta_in_ticks)) { bond->curr_active_slave != slave) {
slave->link = BOND_LINK_UP; slave->link = BOND_LINK_UP;
bond_change_active_slave(bond, slave);
bond->current_arp_slave = NULL; bond->current_arp_slave = NULL;
pr_info(DRV_NAME pr_info(DRV_NAME
": %s: %s is up and now the " ": %s: link status definitely "
"active interface\n", "up for interface %s.\n",
bond->dev->name, slave->dev->name); bond->dev->name, slave->dev->name);
} else if (bond->curr_active_slave != slave) {
/* this slave has just come up but we
* already have a current slave; this can
* also happen if bond_enslave adds a new
* slave that is up while we are searching
* for a new slave
*/
slave->link = BOND_LINK_UP;
bond_set_slave_inactive_flags(slave);
bond->current_arp_slave = NULL;
pr_info(DRV_NAME if (!bond->curr_active_slave ||
": %s: backup interface %s is now up\n", (slave == bond->primary_slave))
bond->dev->name, slave->dev->name); goto do_failover;
}
write_unlock_bh(&bond->curr_slave_lock); }
break; continue;
case BOND_LINK_DOWN: case BOND_LINK_DOWN:
if (slave->link_failure_count < UINT_MAX) if (slave->link_failure_count < UINT_MAX)
slave->link_failure_count++; slave->link_failure_count++;
slave->link = BOND_LINK_DOWN; slave->link = BOND_LINK_DOWN;
bond_set_slave_inactive_flags(slave);
if (slave == bond->curr_active_slave) { pr_info(DRV_NAME
pr_info(DRV_NAME ": %s: link status definitely down for "
": %s: link status down for active " "interface %s, disabling it\n",
"interface %s, disabling it\n", bond->dev->name, slave->dev->name);
bond->dev->name, slave->dev->name);
bond_set_slave_inactive_flags(slave);
write_lock_bh(&bond->curr_slave_lock);
bond_select_active_slave(bond);
if (bond->curr_active_slave)
bond->curr_active_slave->jiffies =
jiffies;
write_unlock_bh(&bond->curr_slave_lock);
if (slave == bond->curr_active_slave) {
bond->current_arp_slave = NULL; bond->current_arp_slave = NULL;
goto do_failover;
} else if (slave->state == BOND_STATE_BACKUP) {
pr_info(DRV_NAME
": %s: backup interface %s is now down\n",
bond->dev->name, slave->dev->name);
bond_set_slave_inactive_flags(slave);
} }
break;
continue;
default: default:
pr_err(DRV_NAME pr_err(DRV_NAME
": %s: impossible: new_link %d on slave %s\n", ": %s: impossible: new_link %d on slave %s\n",
bond->dev->name, slave->new_link, bond->dev->name, slave->new_link,
slave->dev->name); slave->dev->name);
continue;
} }
}
/* do_failover:
* No race with changes to primary via sysfs, as we hold rtnl. ASSERT_RTNL();
*/
if (bond->primary_slave &&
(bond->primary_slave != bond->curr_active_slave) &&
(bond->primary_slave->link == BOND_LINK_UP)) {
write_lock_bh(&bond->curr_slave_lock); write_lock_bh(&bond->curr_slave_lock);
bond_change_active_slave(bond, bond->primary_slave); bond_select_active_slave(bond);
write_unlock_bh(&bond->curr_slave_lock); write_unlock_bh(&bond->curr_slave_lock);
} }
......
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