diff options
author | Michał Mirosław <mirq-linux@rere.qmqm.pl> | 2011-05-06 21:48:02 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-05-09 15:05:59 -0400 |
commit | 0693e88e6ccf615d9674548d8b924cdd9a1c976c (patch) | |
tree | c77546505f150e1e6c8a9a8390e7dc01a292d13d /drivers | |
parent | 48752e1b1802231ef2a076f34d861918b7d571c3 (diff) |
net: bonding: factor out rlock(bond->lock) in xmit path
Pull read_lock(&bond->lock) and BOND_IS_OK() to bond_start_xmit() from
mode-dependent xmit functions.
netif_running() is always true in hard_start_xmit.
Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/bonding/bond_3ad.c | 10 | ||||
-rw-r--r-- | drivers/net/bonding/bond_alb.c | 11 | ||||
-rw-r--r-- | drivers/net/bonding/bond_main.c | 74 |
3 files changed, 35 insertions, 60 deletions
diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c index d4160f87e910..c7537abca4f2 100644 --- a/drivers/net/bonding/bond_3ad.c +++ b/drivers/net/bonding/bond_3ad.c | |||
@@ -2403,14 +2403,6 @@ int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev) | |||
2403 | struct ad_info ad_info; | 2403 | struct ad_info ad_info; |
2404 | int res = 1; | 2404 | int res = 1; |
2405 | 2405 | ||
2406 | /* make sure that the slaves list will | ||
2407 | * not change during tx | ||
2408 | */ | ||
2409 | read_lock(&bond->lock); | ||
2410 | |||
2411 | if (!BOND_IS_OK(bond)) | ||
2412 | goto out; | ||
2413 | |||
2414 | if (bond_3ad_get_active_agg_info(bond, &ad_info)) { | 2406 | if (bond_3ad_get_active_agg_info(bond, &ad_info)) { |
2415 | pr_debug("%s: Error: bond_3ad_get_active_agg_info failed\n", | 2407 | pr_debug("%s: Error: bond_3ad_get_active_agg_info failed\n", |
2416 | dev->name); | 2408 | dev->name); |
@@ -2464,7 +2456,7 @@ out: | |||
2464 | /* no suitable interface, frame not sent */ | 2456 | /* no suitable interface, frame not sent */ |
2465 | dev_kfree_skb(skb); | 2457 | dev_kfree_skb(skb); |
2466 | } | 2458 | } |
2467 | read_unlock(&bond->lock); | 2459 | |
2468 | return NETDEV_TX_OK; | 2460 | return NETDEV_TX_OK; |
2469 | } | 2461 | } |
2470 | 2462 | ||
diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c index 3b7b0409406f..8f2d2e7c70e5 100644 --- a/drivers/net/bonding/bond_alb.c +++ b/drivers/net/bonding/bond_alb.c | |||
@@ -1225,16 +1225,10 @@ int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev) | |||
1225 | skb_reset_mac_header(skb); | 1225 | skb_reset_mac_header(skb); |
1226 | eth_data = eth_hdr(skb); | 1226 | eth_data = eth_hdr(skb); |
1227 | 1227 | ||
1228 | /* make sure that the curr_active_slave and the slaves list do | 1228 | /* make sure that the curr_active_slave do not change during tx |
1229 | * not change during tx | ||
1230 | */ | 1229 | */ |
1231 | read_lock(&bond->lock); | ||
1232 | read_lock(&bond->curr_slave_lock); | 1230 | read_lock(&bond->curr_slave_lock); |
1233 | 1231 | ||
1234 | if (!BOND_IS_OK(bond)) { | ||
1235 | goto out; | ||
1236 | } | ||
1237 | |||
1238 | switch (ntohs(skb->protocol)) { | 1232 | switch (ntohs(skb->protocol)) { |
1239 | case ETH_P_IP: { | 1233 | case ETH_P_IP: { |
1240 | const struct iphdr *iph = ip_hdr(skb); | 1234 | const struct iphdr *iph = ip_hdr(skb); |
@@ -1334,13 +1328,12 @@ int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev) | |||
1334 | } | 1328 | } |
1335 | } | 1329 | } |
1336 | 1330 | ||
1337 | out: | ||
1338 | if (res) { | 1331 | if (res) { |
1339 | /* no suitable interface, frame not sent */ | 1332 | /* no suitable interface, frame not sent */ |
1340 | dev_kfree_skb(skb); | 1333 | dev_kfree_skb(skb); |
1341 | } | 1334 | } |
1342 | read_unlock(&bond->curr_slave_lock); | 1335 | read_unlock(&bond->curr_slave_lock); |
1343 | read_unlock(&bond->lock); | 1336 | |
1344 | return NETDEV_TX_OK; | 1337 | return NETDEV_TX_OK; |
1345 | } | 1338 | } |
1346 | 1339 | ||
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 9a5feaf4bab9..6312db1f7838 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c | |||
@@ -4004,10 +4004,6 @@ static int bond_xmit_roundrobin(struct sk_buff *skb, struct net_device *bond_dev | |||
4004 | int i, slave_no, res = 1; | 4004 | int i, slave_no, res = 1; |
4005 | struct iphdr *iph = ip_hdr(skb); | 4005 | struct iphdr *iph = ip_hdr(skb); |
4006 | 4006 | ||
4007 | read_lock(&bond->lock); | ||
4008 | |||
4009 | if (!BOND_IS_OK(bond)) | ||
4010 | goto out; | ||
4011 | /* | 4007 | /* |
4012 | * Start with the curr_active_slave that joined the bond as the | 4008 | * Start with the curr_active_slave that joined the bond as the |
4013 | * default for sending IGMP traffic. For failover purposes one | 4009 | * default for sending IGMP traffic. For failover purposes one |
@@ -4054,7 +4050,7 @@ out: | |||
4054 | /* no suitable interface, frame not sent */ | 4050 | /* no suitable interface, frame not sent */ |
4055 | dev_kfree_skb(skb); | 4051 | dev_kfree_skb(skb); |
4056 | } | 4052 | } |
4057 | read_unlock(&bond->lock); | 4053 | |
4058 | return NETDEV_TX_OK; | 4054 | return NETDEV_TX_OK; |
4059 | } | 4055 | } |
4060 | 4056 | ||
@@ -4068,24 +4064,18 @@ static int bond_xmit_activebackup(struct sk_buff *skb, struct net_device *bond_d | |||
4068 | struct bonding *bond = netdev_priv(bond_dev); | 4064 | struct bonding *bond = netdev_priv(bond_dev); |
4069 | int res = 1; | 4065 | int res = 1; |
4070 | 4066 | ||
4071 | read_lock(&bond->lock); | ||
4072 | read_lock(&bond->curr_slave_lock); | 4067 | read_lock(&bond->curr_slave_lock); |
4073 | 4068 | ||
4074 | if (!BOND_IS_OK(bond)) | 4069 | if (bond->curr_active_slave) |
4075 | goto out; | 4070 | res = bond_dev_queue_xmit(bond, skb, |
4071 | bond->curr_active_slave->dev); | ||
4076 | 4072 | ||
4077 | if (!bond->curr_active_slave) | ||
4078 | goto out; | ||
4079 | |||
4080 | res = bond_dev_queue_xmit(bond, skb, bond->curr_active_slave->dev); | ||
4081 | |||
4082 | out: | ||
4083 | if (res) | 4073 | if (res) |
4084 | /* no suitable interface, frame not sent */ | 4074 | /* no suitable interface, frame not sent */ |
4085 | dev_kfree_skb(skb); | 4075 | dev_kfree_skb(skb); |
4086 | 4076 | ||
4087 | read_unlock(&bond->curr_slave_lock); | 4077 | read_unlock(&bond->curr_slave_lock); |
4088 | read_unlock(&bond->lock); | 4078 | |
4089 | return NETDEV_TX_OK; | 4079 | return NETDEV_TX_OK; |
4090 | } | 4080 | } |
4091 | 4081 | ||
@@ -4102,11 +4092,6 @@ static int bond_xmit_xor(struct sk_buff *skb, struct net_device *bond_dev) | |||
4102 | int i; | 4092 | int i; |
4103 | int res = 1; | 4093 | int res = 1; |
4104 | 4094 | ||
4105 | read_lock(&bond->lock); | ||
4106 | |||
4107 | if (!BOND_IS_OK(bond)) | ||
4108 | goto out; | ||
4109 | |||
4110 | slave_no = bond->xmit_hash_policy(skb, bond->slave_cnt); | 4095 | slave_no = bond->xmit_hash_policy(skb, bond->slave_cnt); |
4111 | 4096 | ||
4112 | bond_for_each_slave(bond, slave, i) { | 4097 | bond_for_each_slave(bond, slave, i) { |
@@ -4126,12 +4111,11 @@ static int bond_xmit_xor(struct sk_buff *skb, struct net_device *bond_dev) | |||
4126 | } | 4111 | } |
4127 | } | 4112 | } |
4128 | 4113 | ||
4129 | out: | ||
4130 | if (res) { | 4114 | if (res) { |
4131 | /* no suitable interface, frame not sent */ | 4115 | /* no suitable interface, frame not sent */ |
4132 | dev_kfree_skb(skb); | 4116 | dev_kfree_skb(skb); |
4133 | } | 4117 | } |
4134 | read_unlock(&bond->lock); | 4118 | |
4135 | return NETDEV_TX_OK; | 4119 | return NETDEV_TX_OK; |
4136 | } | 4120 | } |
4137 | 4121 | ||
@@ -4146,11 +4130,6 @@ static int bond_xmit_broadcast(struct sk_buff *skb, struct net_device *bond_dev) | |||
4146 | int i; | 4130 | int i; |
4147 | int res = 1; | 4131 | int res = 1; |
4148 | 4132 | ||
4149 | read_lock(&bond->lock); | ||
4150 | |||
4151 | if (!BOND_IS_OK(bond)) | ||
4152 | goto out; | ||
4153 | |||
4154 | read_lock(&bond->curr_slave_lock); | 4133 | read_lock(&bond->curr_slave_lock); |
4155 | start_at = bond->curr_active_slave; | 4134 | start_at = bond->curr_active_slave; |
4156 | read_unlock(&bond->curr_slave_lock); | 4135 | read_unlock(&bond->curr_slave_lock); |
@@ -4189,7 +4168,6 @@ out: | |||
4189 | dev_kfree_skb(skb); | 4168 | dev_kfree_skb(skb); |
4190 | 4169 | ||
4191 | /* frame sent to all suitable interfaces */ | 4170 | /* frame sent to all suitable interfaces */ |
4192 | read_unlock(&bond->lock); | ||
4193 | return NETDEV_TX_OK; | 4171 | return NETDEV_TX_OK; |
4194 | } | 4172 | } |
4195 | 4173 | ||
@@ -4221,10 +4199,8 @@ static inline int bond_slave_override(struct bonding *bond, | |||
4221 | struct slave *slave = NULL; | 4199 | struct slave *slave = NULL; |
4222 | struct slave *check_slave; | 4200 | struct slave *check_slave; |
4223 | 4201 | ||
4224 | read_lock(&bond->lock); | 4202 | if (!skb->queue_mapping) |
4225 | 4203 | return 1; | |
4226 | if (!BOND_IS_OK(bond) || !skb->queue_mapping) | ||
4227 | goto out; | ||
4228 | 4204 | ||
4229 | /* Find out if any slaves have the same mapping as this skb. */ | 4205 | /* Find out if any slaves have the same mapping as this skb. */ |
4230 | bond_for_each_slave(bond, check_slave, i) { | 4206 | bond_for_each_slave(bond, check_slave, i) { |
@@ -4240,8 +4216,6 @@ static inline int bond_slave_override(struct bonding *bond, | |||
4240 | res = bond_dev_queue_xmit(bond, skb, slave->dev); | 4216 | res = bond_dev_queue_xmit(bond, skb, slave->dev); |
4241 | } | 4217 | } |
4242 | 4218 | ||
4243 | out: | ||
4244 | read_unlock(&bond->lock); | ||
4245 | return res; | 4219 | return res; |
4246 | } | 4220 | } |
4247 | 4221 | ||
@@ -4263,17 +4237,10 @@ static u16 bond_select_queue(struct net_device *dev, struct sk_buff *skb) | |||
4263 | return txq; | 4237 | return txq; |
4264 | } | 4238 | } |
4265 | 4239 | ||
4266 | static netdev_tx_t bond_start_xmit(struct sk_buff *skb, struct net_device *dev) | 4240 | static netdev_tx_t __bond_start_xmit(struct sk_buff *skb, struct net_device *dev) |
4267 | { | 4241 | { |
4268 | struct bonding *bond = netdev_priv(dev); | 4242 | struct bonding *bond = netdev_priv(dev); |
4269 | 4243 | ||
4270 | /* | ||
4271 | * If we risk deadlock from transmitting this in the | ||
4272 | * netpoll path, tell netpoll to queue the frame for later tx | ||
4273 | */ | ||
4274 | if (is_netpoll_tx_blocked(dev)) | ||
4275 | return NETDEV_TX_BUSY; | ||
4276 | |||
4277 | if (TX_QUEUE_OVERRIDE(bond->params.mode)) { | 4244 | if (TX_QUEUE_OVERRIDE(bond->params.mode)) { |
4278 | if (!bond_slave_override(bond, skb)) | 4245 | if (!bond_slave_override(bond, skb)) |
4279 | return NETDEV_TX_OK; | 4246 | return NETDEV_TX_OK; |
@@ -4303,6 +4270,29 @@ static netdev_tx_t bond_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
4303 | } | 4270 | } |
4304 | } | 4271 | } |
4305 | 4272 | ||
4273 | static netdev_tx_t bond_start_xmit(struct sk_buff *skb, struct net_device *dev) | ||
4274 | { | ||
4275 | struct bonding *bond = netdev_priv(dev); | ||
4276 | netdev_tx_t ret = NETDEV_TX_OK; | ||
4277 | |||
4278 | /* | ||
4279 | * If we risk deadlock from transmitting this in the | ||
4280 | * netpoll path, tell netpoll to queue the frame for later tx | ||
4281 | */ | ||
4282 | if (is_netpoll_tx_blocked(dev)) | ||
4283 | return NETDEV_TX_BUSY; | ||
4284 | |||
4285 | read_lock(&bond->lock); | ||
4286 | |||
4287 | if (bond->slave_cnt) | ||
4288 | ret = __bond_start_xmit(skb, dev); | ||
4289 | else | ||
4290 | dev_kfree_skb(skb); | ||
4291 | |||
4292 | read_unlock(&bond->lock); | ||
4293 | |||
4294 | return ret; | ||
4295 | } | ||
4306 | 4296 | ||
4307 | /* | 4297 | /* |
4308 | * set bond mode specific net device operations | 4298 | * set bond mode specific net device operations |