aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/bonding/bond_sysfs.c
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/bond_sysfs.c
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/bond_sysfs.c')
-rw-r--r--drivers/net/bonding/bond_sysfs.c23
1 files changed, 3 insertions, 20 deletions
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}