aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@aristanetworks.com>2009-10-29 10:18:22 -0400
committerDavid S. Miller <davem@davemloft.net>2009-10-30 15:41:19 -0400
commit6151b3d435feeeae7487032fcd5c8c7f281ba05c (patch)
tree0fa59fbfc8c7afb246870308dc742de931d926b3 /drivers
parent0c509a6c9393b27a8c5a01acd4a72616206cfc24 (diff)
bond: Simply bond sysfs group creation
This patch delegates the work of creating the sysfs groups to the netdev layer and ultimately to the device layer. This closes races between uevents. Signed-off-by: Eric W. Biederman <ebiederm@aristanetworks.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/bonding/bond_main.c11
-rw-r--r--drivers/net/bonding/bond_sysfs.c20
-rw-r--r--drivers/net/bonding/bonding.h3
3 files changed, 4 insertions, 30 deletions
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index db82876ceb28..a58a60859da9 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -2011,7 +2011,6 @@ static void bond_uninit(struct net_device *bond_dev)
2011 struct bonding *bond = netdev_priv(bond_dev); 2011 struct bonding *bond = netdev_priv(bond_dev);
2012 2012
2013 bond_deinit(bond_dev); 2013 bond_deinit(bond_dev);
2014 bond_destroy_sysfs_entry(bond);
2015 2014
2016 if (bond->wq) 2015 if (bond->wq)
2017 destroy_workqueue(bond->wq); 2016 destroy_workqueue(bond->wq);
@@ -3457,9 +3456,6 @@ static int bond_event_changename(struct bonding *bond)
3457 bond_remove_proc_entry(bond); 3456 bond_remove_proc_entry(bond);
3458 bond_create_proc_entry(bond); 3457 bond_create_proc_entry(bond);
3459 3458
3460 bond_destroy_sysfs_entry(bond);
3461 bond_create_sysfs_entry(bond);
3462
3463 return NOTIFY_DONE; 3459 return NOTIFY_DONE;
3464} 3460}
3465 3461
@@ -5078,6 +5074,7 @@ static int bond_init(struct net_device *bond_dev)
5078 bond_create_proc_entry(bond); 5074 bond_create_proc_entry(bond);
5079 list_add_tail(&bond->bond_list, &bond_dev_list); 5075 list_add_tail(&bond->bond_list, &bond_dev_list);
5080 5076
5077 bond_prepare_sysfs_group(bond);
5081 return 0; 5078 return 0;
5082} 5079}
5083 5080
@@ -5120,15 +5117,9 @@ int bond_create(const char *name)
5120 if (res < 0) 5117 if (res < 0)
5121 goto out_bond; 5118 goto out_bond;
5122 5119
5123 res = bond_create_sysfs_entry(netdev_priv(bond_dev));
5124 if (res < 0)
5125 goto out_unreg;
5126
5127 rtnl_unlock(); 5120 rtnl_unlock();
5128 return 0; 5121 return 0;
5129 5122
5130out_unreg:
5131 unregister_netdevice(bond_dev);
5132out_bond: 5123out_bond:
5133 bond_deinit(bond_dev); 5124 bond_deinit(bond_dev);
5134out_netdev: 5125out_netdev:
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index dca7d82f7b97..f924a0bcf8da 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -1616,24 +1616,8 @@ void bond_destroy_sysfs(void)
1616 * Initialize sysfs for each bond. This sets up and registers 1616 * Initialize sysfs for each bond. This sets up and registers
1617 * the 'bondctl' directory for each individual bond under /sys/class/net. 1617 * the 'bondctl' directory for each individual bond under /sys/class/net.
1618 */ 1618 */
1619int bond_create_sysfs_entry(struct bonding *bond) 1619void bond_prepare_sysfs_group(struct bonding *bond)
1620{ 1620{
1621 struct net_device *dev = bond->dev; 1621 bond->dev->sysfs_groups[0] = &bonding_group;
1622 int err;
1623
1624 err = sysfs_create_group(&(dev->dev.kobj), &bonding_group);
1625 if (err)
1626 pr_emerg("eek! didn't create group!\n");
1627
1628 return err;
1629}
1630/*
1631 * Remove sysfs entries for each bond.
1632 */
1633void bond_destroy_sysfs_entry(struct bonding *bond)
1634{
1635 struct net_device *dev = bond->dev;
1636
1637 sysfs_remove_group(&(dev->dev.kobj), &bonding_group);
1638} 1622}
1639 1623
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
index 9b520b05fbac..013be296f0da 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -331,8 +331,7 @@ int bond_create(const char *name);
331int bond_release_and_destroy(struct net_device *bond_dev, struct net_device *slave_dev); 331int bond_release_and_destroy(struct net_device *bond_dev, struct net_device *slave_dev);
332int bond_create_sysfs(void); 332int bond_create_sysfs(void);
333void bond_destroy_sysfs(void); 333void bond_destroy_sysfs(void);
334void bond_destroy_sysfs_entry(struct bonding *bond); 334void bond_prepare_sysfs_group(struct bonding *bond);
335int bond_create_sysfs_entry(struct bonding *bond);
336int bond_create_slave_symlinks(struct net_device *master, struct net_device *slave); 335int bond_create_slave_symlinks(struct net_device *master, struct net_device *slave);
337void bond_destroy_slave_symlinks(struct net_device *master, struct net_device *slave); 336void bond_destroy_slave_symlinks(struct net_device *master, struct net_device *slave);
338int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev); 337int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev);