aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/bonding
diff options
context:
space:
mode:
authorStephen Hemminger <shemminger@vyatta.com>2009-06-12 15:02:46 -0400
committerDavid S. Miller <davem@davemloft.net>2009-06-14 02:28:54 -0400
commit7e0838404541d2758bee089632690aabd82f3d5d (patch)
tree08625e067250aab61a621cdae5aeb21f579bde3f /drivers/net/bonding
parentd93216051ae60995736518ca9ebb58a0e6ade212 (diff)
bonding: remove bonding read/write semaphore
The whole read/write semaphore locking can be removed. It doesn't add any protection that isn't already done by using the RTNL mutex properly. Signed-off-by: Stephen Hemminger <shemminger@vyatta.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/bonding')
-rw-r--r--drivers/net/bonding/bond_main.c16
-rw-r--r--drivers/net/bonding/bond_sysfs.c23
-rw-r--r--drivers/net/bonding/bonding.h3
3 files changed, 6 insertions, 36 deletions
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 99ddd283e15e..23b832ffe7a9 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -3489,10 +3489,10 @@ static int bond_event_changename(struct bonding *bond)
3489{ 3489{
3490 bond_remove_proc_entry(bond); 3490 bond_remove_proc_entry(bond);
3491 bond_create_proc_entry(bond); 3491 bond_create_proc_entry(bond);
3492 down_write(&(bonding_rwsem)); 3492
3493 bond_destroy_sysfs_entry(bond); 3493 bond_destroy_sysfs_entry(bond);
3494 bond_create_sysfs_entry(bond); 3494 bond_create_sysfs_entry(bond);
3495 up_write(&(bonding_rwsem)); 3495
3496 return NOTIFY_DONE; 3496 return NOTIFY_DONE;
3497} 3497}
3498 3498
@@ -4015,7 +4015,6 @@ static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd
4015 return -EPERM; 4015 return -EPERM;
4016 } 4016 }
4017 4017
4018 down_write(&(bonding_rwsem));
4019 slave_dev = dev_get_by_name(&init_net, ifr->ifr_slave); 4018 slave_dev = dev_get_by_name(&init_net, ifr->ifr_slave);
4020 4019
4021 pr_debug("slave_dev=%p: \n", slave_dev); 4020 pr_debug("slave_dev=%p: \n", slave_dev);
@@ -4048,7 +4047,6 @@ static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd
4048 dev_put(slave_dev); 4047 dev_put(slave_dev);
4049 } 4048 }
4050 4049
4051 up_write(&(bonding_rwsem));
4052 return res; 4050 return res;
4053} 4051}
4054 4052
@@ -5123,8 +5121,6 @@ int bond_create(const char *name)
5123 int res; 5121 int res;
5124 5122
5125 rtnl_lock(); 5123 rtnl_lock();
5126 down_write(&bonding_rwsem);
5127
5128 /* Check to see if the bond already exists. */ 5124 /* Check to see if the bond already exists. */
5129 if (name) { 5125 if (name) {
5130 list_for_each_entry(bond, &bond_dev_list, bond_list) 5126 list_for_each_entry(bond, &bond_dev_list, bond_list)
@@ -5173,24 +5169,20 @@ int bond_create(const char *name)
5173 goto out_bond; 5169 goto out_bond;
5174 } 5170 }
5175 5171
5176 up_write(&bonding_rwsem);
5177 rtnl_unlock(); /* allows sysfs registration of net device */
5178 res = bond_create_sysfs_entry(netdev_priv(bond_dev)); 5172 res = bond_create_sysfs_entry(netdev_priv(bond_dev));
5179 if (res < 0) 5173 if (res < 0)
5180 goto out_unreg; 5174 goto out_unreg;
5181 5175
5176 rtnl_unlock();
5182 return 0; 5177 return 0;
5183 5178
5184out_unreg: 5179out_unreg:
5185 rtnl_lock();
5186 down_write(&bonding_rwsem);
5187 unregister_netdevice(bond_dev); 5180 unregister_netdevice(bond_dev);
5188out_bond: 5181out_bond:
5189 bond_deinit(bond_dev); 5182 bond_deinit(bond_dev);
5190out_netdev: 5183out_netdev:
5191 free_netdev(bond_dev); 5184 free_netdev(bond_dev);
5192out_rtnl: 5185out_rtnl:
5193 up_write(&bonding_rwsem);
5194 rtnl_unlock(); 5186 rtnl_unlock();
5195 return res; 5187 return res;
5196} 5188}
@@ -5209,8 +5201,6 @@ static int __init bonding_init(void)
5209 5201
5210 bond_create_proc_dir(); 5202 bond_create_proc_dir();
5211 5203
5212 init_rwsem(&bonding_rwsem);
5213
5214 for (i = 0; i < max_bonds; i++) { 5204 for (i = 0; i < max_bonds; i++) {
5215 res = bond_create(NULL); 5205 res = bond_create(NULL);
5216 if (res) 5206 if (res)
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index 1172fe649352..8041b6793532 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -44,20 +44,6 @@
44/*---------------------------- Declarations -------------------------------*/ 44/*---------------------------- Declarations -------------------------------*/
45 45
46static int expected_refcount = -1; 46static int expected_refcount = -1;
47/*--------------------------- Data Structures -----------------------------*/
48
49/* Bonding sysfs lock. Why can't we just use the subsystem lock?
50 * Because kobject_register tries to acquire the subsystem lock. If
51 * we already hold the lock (which we would if the user was creating
52 * a new bond through the sysfs interface), we deadlock.
53 * This lock is only needed when deleting a bond - we need to make sure
54 * that we don't collide with an ongoing ioctl.
55 */
56
57struct rw_semaphore bonding_rwsem;
58
59
60
61 47
62/*------------------------------ Functions --------------------------------*/ 48/*------------------------------ Functions --------------------------------*/
63 49
@@ -70,7 +56,7 @@ static ssize_t bonding_show_bonds(struct class *cls, char *buf)
70 int res = 0; 56 int res = 0;
71 struct bonding *bond; 57 struct bonding *bond;
72 58
73 down_read(&(bonding_rwsem)); 59 rtnl_lock();
74 60
75 list_for_each_entry(bond, &bond_dev_list, bond_list) { 61 list_for_each_entry(bond, &bond_dev_list, bond_list) {
76 if (res > (PAGE_SIZE - IFNAMSIZ)) { 62 if (res > (PAGE_SIZE - IFNAMSIZ)) {
@@ -84,7 +70,8 @@ static ssize_t bonding_show_bonds(struct class *cls, char *buf)
84 } 70 }
85 if (res) 71 if (res)
86 buf[res-1] = '\n'; /* eat the leftover space */ 72 buf[res-1] = '\n'; /* eat the leftover space */
87 up_read(&(bonding_rwsem)); 73
74 rtnl_unlock();
88 return res; 75 return res;
89} 76}
90 77
@@ -122,7 +109,6 @@ static ssize_t bonding_store_bonds(struct class *cls, const char *buffer, size_t
122 109
123 if (command[0] == '-') { 110 if (command[0] == '-') {
124 rtnl_lock(); 111 rtnl_lock();
125 down_write(&bonding_rwsem);
126 112
127 list_for_each_entry(bond, &bond_dev_list, bond_list) 113 list_for_each_entry(bond, &bond_dev_list, bond_list)
128 if (strnicmp(bond->dev->name, ifname, IFNAMSIZ) == 0) { 114 if (strnicmp(bond->dev->name, ifname, IFNAMSIZ) == 0) {
@@ -157,7 +143,6 @@ err_no_cmd:
157 return -EPERM; 143 return -EPERM;
158 144
159out_unlock: 145out_unlock:
160 up_write(&bonding_rwsem);
161 rtnl_unlock(); 146 rtnl_unlock();
162 147
163 /* Always return either count or an error. If you return 0, you'll 148 /* Always return either count or an error. If you return 0, you'll
@@ -253,7 +238,6 @@ static ssize_t bonding_store_slaves(struct device *d,
253 238
254 if (!rtnl_trylock()) 239 if (!rtnl_trylock())
255 return restart_syscall(); 240 return restart_syscall();
256 down_write(&(bonding_rwsem));
257 241
258 sscanf(buffer, "%16s", command); /* IFNAMSIZ*/ 242 sscanf(buffer, "%16s", command); /* IFNAMSIZ*/
259 ifname = command + 1; 243 ifname = command + 1;
@@ -357,7 +341,6 @@ err_no_cmd:
357 ret = -EPERM; 341 ret = -EPERM;
358 342
359out: 343out:
360 up_write(&(bonding_rwsem));
361 rtnl_unlock(); 344 rtnl_unlock();
362 return ret; 345 return ret;
363} 346}
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
index a6efa0963717..af81e9b7fe34 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -351,9 +351,6 @@ extern const struct bond_parm_tbl arp_validate_tbl[];
351extern const struct bond_parm_tbl fail_over_mac_tbl[]; 351extern const struct bond_parm_tbl fail_over_mac_tbl[];
352extern struct bond_parm_tbl ad_select_tbl[]; 352extern struct bond_parm_tbl ad_select_tbl[];
353 353
354/* exported from bond_sysfs.c */
355extern struct rw_semaphore bonding_rwsem;
356
357#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) 354#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
358void bond_send_unsolicited_na(struct bonding *bond); 355void bond_send_unsolicited_na(struct bonding *bond);
359void bond_register_ipv6_notifier(void); 356void bond_register_ipv6_notifier(void);