aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNikolay Aleksandrov <nikolay@redhat.com>2014-09-09 17:17:01 -0400
committerDavid S. Miller <davem@davemloft.net>2014-09-09 20:31:35 -0400
commite9fe8efeeae11f19bb6fafd6153ec77deaeb4b83 (patch)
tree14e56ca371b6c631118ebec2c42b32b06bb7d82a
parent059b47e8aaf997245bc531e980581de492315fe6 (diff)
bonding: procfs: clean bond->lock usage and use RCU
Use RCU to protect against slave release, the proc show function will sync with the bond destruction by the proc locks and the fact that the bond is released after NETDEV_UNREGISTER which causes the bonding to remove the proc entry. Signed-off-by: Nikolay Aleksandrov <nikolay@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/bonding/bond_procfs.c16
1 files changed, 3 insertions, 13 deletions
diff --git a/drivers/net/bonding/bond_procfs.c b/drivers/net/bonding/bond_procfs.c
index 1a9fe1ba4c60..bb09d0442aa8 100644
--- a/drivers/net/bonding/bond_procfs.c
+++ b/drivers/net/bonding/bond_procfs.c
@@ -7,21 +7,18 @@
7 7
8static void *bond_info_seq_start(struct seq_file *seq, loff_t *pos) 8static void *bond_info_seq_start(struct seq_file *seq, loff_t *pos)
9 __acquires(RCU) 9 __acquires(RCU)
10 __acquires(&bond->lock)
11{ 10{
12 struct bonding *bond = seq->private; 11 struct bonding *bond = seq->private;
13 struct list_head *iter; 12 struct list_head *iter;
14 struct slave *slave; 13 struct slave *slave;
15 loff_t off = 0; 14 loff_t off = 0;
16 15
17 /* make sure the bond won't be taken away */
18 rcu_read_lock(); 16 rcu_read_lock();
19 read_lock(&bond->lock);
20 17
21 if (*pos == 0) 18 if (*pos == 0)
22 return SEQ_START_TOKEN; 19 return SEQ_START_TOKEN;
23 20
24 bond_for_each_slave(bond, slave, iter) 21 bond_for_each_slave_rcu(bond, slave, iter)
25 if (++off == *pos) 22 if (++off == *pos)
26 return slave; 23 return slave;
27 24
@@ -37,12 +34,9 @@ static void *bond_info_seq_next(struct seq_file *seq, void *v, loff_t *pos)
37 34
38 ++*pos; 35 ++*pos;
39 if (v == SEQ_START_TOKEN) 36 if (v == SEQ_START_TOKEN)
40 return bond_first_slave(bond); 37 return bond_first_slave_rcu(bond);
41 38
42 if (bond_is_last_slave(bond, v)) 39 bond_for_each_slave_rcu(bond, slave, iter) {
43 return NULL;
44
45 bond_for_each_slave(bond, slave, iter) {
46 if (found) 40 if (found)
47 return slave; 41 return slave;
48 if (slave == v) 42 if (slave == v)
@@ -53,12 +47,8 @@ static void *bond_info_seq_next(struct seq_file *seq, void *v, loff_t *pos)
53} 47}
54 48
55static void bond_info_seq_stop(struct seq_file *seq, void *v) 49static void bond_info_seq_stop(struct seq_file *seq, void *v)
56 __releases(&bond->lock)
57 __releases(RCU) 50 __releases(RCU)
58{ 51{
59 struct bonding *bond = seq->private;
60
61 read_unlock(&bond->lock);
62 rcu_read_unlock(); 52 rcu_read_unlock();
63} 53}
64 54