Commit 1b76b316 authored by Jay Vosburgh's avatar Jay Vosburgh Committed by Jeff Garzik

Convert bonding timers to workqueues

	Convert bonding timers to workqueues.  This converts the various
monitor functions to run in periodic work queues instead of timers.  This
patch introduces the framework and convers the calls, but does not resolve
various locking issues, and does not stand alone.
Signed-off-by: default avatarAndy Gospodarek <andy@greyhouse.net>
Signed-off-by: default avatarJay Vosburgh <fubar@us.ibm.com>
Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
parent 15df5806
...@@ -2076,8 +2076,10 @@ void bond_3ad_unbind_slave(struct slave *slave) ...@@ -2076,8 +2076,10 @@ void bond_3ad_unbind_slave(struct slave *slave)
* times out, and it selects an aggregator for the ports that are yet not * times out, and it selects an aggregator for the ports that are yet not
* related to any aggregator, and selects the active aggregator for a bond. * related to any aggregator, and selects the active aggregator for a bond.
*/ */
void bond_3ad_state_machine_handler(struct bonding *bond) void bond_3ad_state_machine_handler(struct work_struct *work)
{ {
struct bonding *bond = container_of(work, struct bonding,
ad_work.work);
struct port *port; struct port *port;
struct aggregator *aggregator; struct aggregator *aggregator;
...@@ -2128,7 +2130,7 @@ void bond_3ad_state_machine_handler(struct bonding *bond) ...@@ -2128,7 +2130,7 @@ void bond_3ad_state_machine_handler(struct bonding *bond)
} }
re_arm: re_arm:
mod_timer(&(BOND_AD_INFO(bond).ad_timer), jiffies + ad_delta_in_ticks); queue_delayed_work(bond->wq, &bond->ad_work, ad_delta_in_ticks);
out: out:
read_unlock(&bond->lock); read_unlock(&bond->lock);
} }
......
...@@ -276,7 +276,7 @@ struct ad_slave_info { ...@@ -276,7 +276,7 @@ struct ad_slave_info {
void bond_3ad_initialize(struct bonding *bond, u16 tick_resolution, int lacp_fast); void bond_3ad_initialize(struct bonding *bond, u16 tick_resolution, int lacp_fast);
int bond_3ad_bind_slave(struct slave *slave); int bond_3ad_bind_slave(struct slave *slave);
void bond_3ad_unbind_slave(struct slave *slave); void bond_3ad_unbind_slave(struct slave *slave);
void bond_3ad_state_machine_handler(struct bonding *bond); void bond_3ad_state_machine_handler(struct work_struct *);
void bond_3ad_adapter_speed_changed(struct slave *slave); void bond_3ad_adapter_speed_changed(struct slave *slave);
void bond_3ad_adapter_duplex_changed(struct slave *slave); void bond_3ad_adapter_duplex_changed(struct slave *slave);
void bond_3ad_handle_link_change(struct slave *slave, char link); void bond_3ad_handle_link_change(struct slave *slave, char link);
......
...@@ -1375,8 +1375,10 @@ out: ...@@ -1375,8 +1375,10 @@ out:
return 0; return 0;
} }
void bond_alb_monitor(struct bonding *bond) void bond_alb_monitor(struct work_struct *work)
{ {
struct bonding *bond = container_of(work, struct bonding,
alb_work.work);
struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond)); struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
struct slave *slave; struct slave *slave;
int i; int i;
...@@ -1479,7 +1481,7 @@ void bond_alb_monitor(struct bonding *bond) ...@@ -1479,7 +1481,7 @@ void bond_alb_monitor(struct bonding *bond)
} }
re_arm: re_arm:
mod_timer(&(bond_info->alb_timer), jiffies + alb_delta_in_ticks); queue_delayed_work(bond->wq, &bond->alb_work, alb_delta_in_ticks);
out: out:
read_unlock(&bond->lock); read_unlock(&bond->lock);
} }
......
...@@ -125,7 +125,7 @@ void bond_alb_deinit_slave(struct bonding *bond, struct slave *slave); ...@@ -125,7 +125,7 @@ void bond_alb_deinit_slave(struct bonding *bond, struct slave *slave);
void bond_alb_handle_link_change(struct bonding *bond, struct slave *slave, char link); void bond_alb_handle_link_change(struct bonding *bond, struct slave *slave, char link);
void bond_alb_handle_active_change(struct bonding *bond, struct slave *new_slave); void bond_alb_handle_active_change(struct bonding *bond, struct slave *new_slave);
int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev); int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev);
void bond_alb_monitor(struct bonding *bond); void bond_alb_monitor(struct work_struct *);
int bond_alb_set_mac_address(struct net_device *bond_dev, void *addr); int bond_alb_set_mac_address(struct net_device *bond_dev, void *addr);
void bond_alb_clear_vlan(struct bonding *bond, unsigned short vlan_id); void bond_alb_clear_vlan(struct bonding *bond, unsigned short vlan_id);
#endif /* __BOND_ALB_H__ */ #endif /* __BOND_ALB_H__ */
......
This diff is collapsed.
...@@ -662,12 +662,9 @@ static ssize_t bonding_store_arp_interval(struct device *d, ...@@ -662,12 +662,9 @@ static ssize_t bonding_store_arp_interval(struct device *d,
"%s Disabling MII monitoring.\n", "%s Disabling MII monitoring.\n",
bond->dev->name, bond->dev->name); bond->dev->name, bond->dev->name);
bond->params.miimon = 0; bond->params.miimon = 0;
/* Kill MII timer, else it brings bond's link down */ if (delayed_work_pending(&bond->mii_work)) {
if (bond->arp_timer.function) { cancel_delayed_work(&bond->mii_work);
printk(KERN_INFO DRV_NAME flush_workqueue(bond->wq);
": %s: Kill MII timer, else it brings bond's link down...\n",
bond->dev->name);
del_timer_sync(&bond->mii_timer);
} }
} }
if (!bond->params.arp_targets[0]) { if (!bond->params.arp_targets[0]) {
...@@ -682,25 +679,15 @@ static ssize_t bonding_store_arp_interval(struct device *d, ...@@ -682,25 +679,15 @@ static ssize_t bonding_store_arp_interval(struct device *d,
* timer will get fired off when the open function * timer will get fired off when the open function
* is called. * is called.
*/ */
if (bond->arp_timer.function) { if (!delayed_work_pending(&bond->arp_work)) {
/* The timer's already set up, so fire it off */ if (bond->params.mode == BOND_MODE_ACTIVEBACKUP)
mod_timer(&bond->arp_timer, jiffies + 1); INIT_DELAYED_WORK(&bond->arp_work,
} else { bond_activebackup_arp_mon);
/* Set up the timer. */ else
init_timer(&bond->arp_timer); INIT_DELAYED_WORK(&bond->arp_work,
bond->arp_timer.expires = jiffies + 1; bond_loadbalance_arp_mon);
bond->arp_timer.data =
(unsigned long) bond->dev; queue_delayed_work(bond->wq, &bond->arp_work, 0);
if (bond->params.mode == BOND_MODE_ACTIVEBACKUP) {
bond->arp_timer.function =
(void *)
&bond_activebackup_arp_mon;
} else {
bond->arp_timer.function =
(void *)
&bond_loadbalance_arp_mon;
}
add_timer(&bond->arp_timer);
} }
} }
...@@ -1056,12 +1043,9 @@ static ssize_t bonding_store_miimon(struct device *d, ...@@ -1056,12 +1043,9 @@ static ssize_t bonding_store_miimon(struct device *d,
bond->params.arp_validate = bond->params.arp_validate =
BOND_ARP_VALIDATE_NONE; BOND_ARP_VALIDATE_NONE;
} }
/* Kill ARP timer, else it brings bond's link down */ if (delayed_work_pending(&bond->arp_work)) {
if (bond->mii_timer.function) { cancel_delayed_work(&bond->arp_work);
printk(KERN_INFO DRV_NAME flush_workqueue(bond->wq);
": %s: Kill ARP timer, else it brings bond's link down...\n",
bond->dev->name);
del_timer_sync(&bond->arp_timer);
} }
} }
...@@ -1071,18 +1055,11 @@ static ssize_t bonding_store_miimon(struct device *d, ...@@ -1071,18 +1055,11 @@ static ssize_t bonding_store_miimon(struct device *d,
* timer will get fired off when the open function * timer will get fired off when the open function
* is called. * is called.
*/ */
if (bond->mii_timer.function) { if (!delayed_work_pending(&bond->mii_work)) {
/* The timer's already set up, so fire it off */ INIT_DELAYED_WORK(&bond->mii_work,
mod_timer(&bond->mii_timer, jiffies + 1); bond_mii_monitor);
} else { queue_delayed_work(bond->wq,
/* Set up the timer. */ &bond->mii_work, 0);
init_timer(&bond->mii_timer);
bond->mii_timer.expires = jiffies + 1;
bond->mii_timer.data =
(unsigned long) bond->dev;
bond->mii_timer.function =
(void *) &bond_mii_monitor;
add_timer(&bond->mii_timer);
} }
} }
} }
......
...@@ -184,8 +184,6 @@ struct bonding { ...@@ -184,8 +184,6 @@ struct bonding {
s32 slave_cnt; /* never change this value outside the attach/detach wrappers */ s32 slave_cnt; /* never change this value outside the attach/detach wrappers */
rwlock_t lock; rwlock_t lock;
rwlock_t curr_slave_lock; rwlock_t curr_slave_lock;
struct timer_list mii_timer;
struct timer_list arp_timer;
s8 kill_timers; s8 kill_timers;
s8 send_grat_arp; s8 send_grat_arp;
s8 setup_by_slave; s8 setup_by_slave;
...@@ -205,6 +203,11 @@ struct bonding { ...@@ -205,6 +203,11 @@ struct bonding {
struct list_head vlan_list; struct list_head vlan_list;
struct vlan_group *vlgrp; struct vlan_group *vlgrp;
struct packet_type arp_mon_pt; struct packet_type arp_mon_pt;
struct workqueue_struct *wq;
struct delayed_work mii_work;
struct delayed_work arp_work;
struct delayed_work alb_work;
struct delayed_work ad_work;
}; };
/** /**
...@@ -307,9 +310,9 @@ int bond_create_slave_symlinks(struct net_device *master, struct net_device *sla ...@@ -307,9 +310,9 @@ int bond_create_slave_symlinks(struct net_device *master, struct net_device *sla
void bond_destroy_slave_symlinks(struct net_device *master, struct net_device *slave); void bond_destroy_slave_symlinks(struct net_device *master, struct net_device *slave);
int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev); int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev);
int bond_release(struct net_device *bond_dev, struct net_device *slave_dev); int bond_release(struct net_device *bond_dev, struct net_device *slave_dev);
void bond_mii_monitor(struct net_device *bond_dev); void bond_mii_monitor(struct work_struct *);
void bond_loadbalance_arp_mon(struct net_device *bond_dev); void bond_loadbalance_arp_mon(struct work_struct *);
void bond_activebackup_arp_mon(struct net_device *bond_dev); void bond_activebackup_arp_mon(struct work_struct *);
void bond_set_mode_ops(struct bonding *bond, int mode); void bond_set_mode_ops(struct bonding *bond, int mode);
int bond_parse_parm(char *mode_arg, struct bond_parm_tbl *tbl); int bond_parse_parm(char *mode_arg, struct bond_parm_tbl *tbl);
void bond_select_active_slave(struct bonding *bond); void bond_select_active_slave(struct bonding *bond);
......
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