* [PATCH] bonding: fix locking in enslave failure path
@ 2013-04-22 18:12 Nikolay Aleksandrov
2013-04-25 8:04 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Nikolay Aleksandrov @ 2013-04-22 18:12 UTC (permalink / raw)
To: netdev; +Cc: andy, fubar, davem
In commit 3c5913b53fefc9d9e15a2d0f93042766658d9f3f ("bonding:
primary_slave & curr_active_slave are not cleaned on enslave failure")
I didn't account for the use of curr_active_slave without curr_slave_lock
and since there are such users, we should hold bond->lock for writing while
setting it to NULL (in the NULL case we don't need the curr_slave_lock).
Keeping the bond lock as to avoid the extra release/acquire cycle.
Signed-off-by: Nikolay Aleksandrov <nikolay@redhat.com>
---
drivers/net/bonding/bond_main.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index dbbea0e..7db40de1 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -1915,14 +1915,16 @@ err_detach:
bond_detach_slave(bond, new_slave);
if (bond->primary_slave == new_slave)
bond->primary_slave = NULL;
- write_unlock_bh(&bond->lock);
if (bond->curr_active_slave == new_slave) {
+ bond_change_active_slave(bond, NULL);
+ write_unlock_bh(&bond->lock);
read_lock(&bond->lock);
write_lock_bh(&bond->curr_slave_lock);
- bond_change_active_slave(bond, NULL);
bond_select_active_slave(bond);
write_unlock_bh(&bond->curr_slave_lock);
read_unlock(&bond->lock);
+ } else {
+ write_unlock_bh(&bond->lock);
}
slave_disable_netpoll(new_slave);
--
1.8.1.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] bonding: fix locking in enslave failure path
2013-04-22 18:12 [PATCH] bonding: fix locking in enslave failure path Nikolay Aleksandrov
@ 2013-04-25 8:04 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2013-04-25 8:04 UTC (permalink / raw)
To: nikolay; +Cc: netdev, andy, fubar
From: Nikolay Aleksandrov <nikolay@redhat.com>
Date: Mon, 22 Apr 2013 20:12:22 +0200
> In commit 3c5913b53fefc9d9e15a2d0f93042766658d9f3f ("bonding:
> primary_slave & curr_active_slave are not cleaned on enslave failure")
> I didn't account for the use of curr_active_slave without curr_slave_lock
> and since there are such users, we should hold bond->lock for writing while
> setting it to NULL (in the NULL case we don't need the curr_slave_lock).
> Keeping the bond lock as to avoid the extra release/acquire cycle.
>
> Signed-off-by: Nikolay Aleksandrov <nikolay@redhat.com>
Applied, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-04-25 8:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-22 18:12 [PATCH] bonding: fix locking in enslave failure path Nikolay Aleksandrov
2013-04-25 8:04 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).