From: Nikolay Aleksandrov <nikolay@redhat.com>
To: netdev@vger.kernel.org
Cc: hariprasad@chelsio.com, vfalico@gmail.com, j.vosburgh@gmail.com,
andy@greyhouse.net, davem@davemloft.net,
Nikolay Aleksandrov <nikolay@redhat.com>
Subject: [PATCH net-next v2 5/7] bonding: procfs: clean bond->lock usage and use RCU
Date: Tue, 9 Sep 2014 23:17:01 +0200 [thread overview]
Message-ID: <1410297423-26624-6-git-send-email-nikolay@redhat.com> (raw)
In-Reply-To: <1410297423-26624-1-git-send-email-nikolay@redhat.com>
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>
---
drivers/net/bonding/bond_procfs.c | 16 +++-------------
1 file 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 @@
static void *bond_info_seq_start(struct seq_file *seq, loff_t *pos)
__acquires(RCU)
- __acquires(&bond->lock)
{
struct bonding *bond = seq->private;
struct list_head *iter;
struct slave *slave;
loff_t off = 0;
- /* make sure the bond won't be taken away */
rcu_read_lock();
- read_lock(&bond->lock);
if (*pos == 0)
return SEQ_START_TOKEN;
- bond_for_each_slave(bond, slave, iter)
+ bond_for_each_slave_rcu(bond, slave, iter)
if (++off == *pos)
return slave;
@@ -37,12 +34,9 @@ static void *bond_info_seq_next(struct seq_file *seq, void *v, loff_t *pos)
++*pos;
if (v == SEQ_START_TOKEN)
- return bond_first_slave(bond);
+ return bond_first_slave_rcu(bond);
- if (bond_is_last_slave(bond, v))
- return NULL;
-
- bond_for_each_slave(bond, slave, iter) {
+ bond_for_each_slave_rcu(bond, slave, iter) {
if (found)
return slave;
if (slave == v)
@@ -53,12 +47,8 @@ static void *bond_info_seq_next(struct seq_file *seq, void *v, loff_t *pos)
}
static void bond_info_seq_stop(struct seq_file *seq, void *v)
- __releases(&bond->lock)
__releases(RCU)
{
- struct bonding *bond = seq->private;
-
- read_unlock(&bond->lock);
rcu_read_unlock();
}
--
1.9.3
next prev parent reply other threads:[~2014-09-09 21:17 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-09 21:16 [PATCH net-next v2 0/7] bonding: get rid of bond->lock Nikolay Aleksandrov
2014-09-09 21:16 ` [PATCH net-next v2 1/7] cxgb4: remove bond->lock Nikolay Aleksandrov
2014-09-09 21:16 ` [PATCH net-next v2 2/7] bonding: 3ad: use curr_slave_lock instead of bond->lock Nikolay Aleksandrov
2014-09-09 21:16 ` [PATCH net-next v2 3/7] bonding: alb: clean bond->lock Nikolay Aleksandrov
2014-09-09 21:17 ` [PATCH net-next v2 4/7] bonding: convert primary_slave to use RCU Nikolay Aleksandrov
2014-09-09 21:17 ` Nikolay Aleksandrov [this message]
2014-09-09 21:17 ` [PATCH net-next v2 6/7] bonding: options: remove bond->lock usage Nikolay Aleksandrov
2014-09-09 21:17 ` [PATCH net-next v2 7/7] bonding: remove last users of bond->lock and bond->lock itself Nikolay Aleksandrov
2014-09-10 0:32 ` [PATCH net-next v2 0/7] bonding: get rid of bond->lock David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1410297423-26624-6-git-send-email-nikolay@redhat.com \
--to=nikolay@redhat.com \
--cc=andy@greyhouse.net \
--cc=davem@davemloft.net \
--cc=hariprasad@chelsio.com \
--cc=j.vosburgh@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=vfalico@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).