Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=e934dd7862e7f613b2ce9730d548a0a70913c8f7
Commit:     e934dd7862e7f613b2ce9730d548a0a70913c8f7
Parent:     03bbe082cffc4533f6557bf23f0c672307067246
Author:     Jay Vosburgh <[EMAIL PROTECTED]>
AuthorDate: Thu Jan 17 16:24:57 2008 -0800
Committer:  Jeff Garzik <[EMAIL PROTECTED]>
CommitDate: Fri Jan 18 14:38:38 2008 -0500

    bonding: fix locking in sysfs primary/active selection
    
        Fix the functions that store the primary and active slave
    options via sysfs to hold the correct locks in the correct order.
    
        The bond_change_active_slave and bond_select_active_slave
    functions both require rtnl, bond->lock for read and curr_slave_lock for
    write_bh, and no other locks.  This is so that the lower level
    mode-specific functions (notably for balance-alb mode) can release locks
    down to just rtnl in order to call, e.g., dev_set_mac_address with the
    locks it expects (rtnl only).
    
    Signed-off-by: Jay Vosburgh <[EMAIL PROTECTED]>
    Signed-off-by: Andy Gospodarek <[EMAIL PROTECTED]>
    Signed-off-by: Jeff Garzik <[EMAIL PROTECTED]>
---
 drivers/net/bonding/bond_sysfs.c |   15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index 11b76b3..28a2d80 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -1075,7 +1075,10 @@ static ssize_t bonding_store_primary(struct device *d,
        struct slave *slave;
        struct bonding *bond = to_bond(d);
 
-       write_lock_bh(&bond->lock);
+       rtnl_lock();
+       read_lock(&bond->lock);
+       write_lock_bh(&bond->curr_slave_lock);
+
        if (!USES_PRIMARY(bond->params.mode)) {
                printk(KERN_INFO DRV_NAME
                       ": %s: Unable to set primary slave; %s is in mode %d\n",
@@ -1109,8 +1112,8 @@ static ssize_t bonding_store_primary(struct device *d,
                }
        }
 out:
-       write_unlock_bh(&bond->lock);
-
+       write_unlock_bh(&bond->curr_slave_lock);
+       read_unlock(&bond->lock);
        rtnl_unlock();
 
        return count;
@@ -1190,7 +1193,8 @@ static ssize_t bonding_store_active_slave(struct device 
*d,
        struct bonding *bond = to_bond(d);
 
        rtnl_lock();
-       write_lock_bh(&bond->lock);
+       read_lock(&bond->lock);
+       write_lock_bh(&bond->curr_slave_lock);
 
        if (!USES_PRIMARY(bond->params.mode)) {
                printk(KERN_INFO DRV_NAME
@@ -1247,7 +1251,8 @@ static ssize_t bonding_store_active_slave(struct device 
*d,
                }
        }
 out:
-       write_unlock_bh(&bond->lock);
+       write_unlock_bh(&bond->curr_slave_lock);
+       read_unlock(&bond->lock);
        rtnl_unlock();
 
        return count;
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to