From: Stephen Hemminger <shemminger@linux-foundation.org>
To: David Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org
Subject: [IPV4 3/5] fib_trie: dump doesnt use RCU
Date: Wed, 23 Jan 2008 14:48:47 -0800 [thread overview]
Message-ID: <20080123224858.918669715@linux-foundation.org> (raw)
In-Reply-To: 20080123224844.610730277@linux-foundation.org
[-- Attachment #1: fib-dump-rtnl.patch --]
[-- Type: text/plain, Size: 3261 bytes --]
Since fib dump (via netlink) holds the RTNL mutex, it is unnecessary
to use RCU, and it is impossible to get truncated (-EBUSY) result.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
--- a/net/ipv4/fib_trie.c 2008-01-23 13:55:12.000000000 -0800
+++ b/net/ipv4/fib_trie.c 2008-01-23 14:00:35.000000000 -0800
@@ -1684,7 +1684,7 @@ static int trie_flush_leaf(struct trie *
* Scan for the next right leaf starting at node p->child[idx]
* Since we have back pointer, no recursion necessary.
*/
-static struct leaf *leaf_walk_rcu(struct tnode *p, struct node *c)
+static struct leaf *leaf_walk(struct tnode *p, struct node *c)
{
do {
t_key idx;
@@ -1695,7 +1695,7 @@ static struct leaf *leaf_walk_rcu(struct
idx = 0;
while (idx < 1u << p->bits) {
- c = tnode_get_child_rcu(p, idx++);
+ c = tnode_get_child(p, idx++);
if (!c)
continue;
@@ -1711,14 +1711,14 @@ static struct leaf *leaf_walk_rcu(struct
/* Node empty, walk back up to parent */
c = (struct node *) p;
- } while ( (p = node_parent_rcu(c)) != NULL);
+ } while ( (p = node_parent(c)) != NULL);
return NULL; /* Root of trie */
}
static struct leaf *trie_firstleaf(struct trie *t)
{
- struct tnode *n = (struct tnode *) rcu_dereference(t->trie);
+ struct tnode *n = (struct tnode *) t->trie;
if (!n)
return NULL;
@@ -1726,7 +1726,7 @@ static struct leaf *trie_firstleaf(struc
if (IS_LEAF(n)) /* trie is just a leaf */
return (struct leaf *) n;
- return leaf_walk_rcu(n, NULL);
+ return leaf_walk(n, NULL);
}
static struct leaf *trie_nextleaf(struct leaf *l)
@@ -1737,7 +1737,7 @@ static struct leaf *trie_nextleaf(struct
if (!p)
return NULL; /* trie with just one leaf */
- return leaf_walk_rcu(p, c);
+ return leaf_walk(p, c);
}
/*
@@ -1848,9 +1848,7 @@ static int fn_trie_dump_fa(t_key key, in
s_i = cb->args[4];
i = 0;
- /* rcu_read_lock is hold by caller */
-
- list_for_each_entry_rcu(fa, fah, fa_list) {
+ list_for_each_entry(fa, fah, fa_list) {
if (i < s_i) {
i++;
continue;
@@ -1885,8 +1883,7 @@ static int fn_trie_dump_leaf(struct leaf
s_i = cb->args[3];
i = 0;
- /* rcu_read_lock is hold by caller */
- hlist_for_each_entry_rcu(li, node, &l->list, hlist) {
+ hlist_for_each_entry(li, node, &l->list, hlist) {
if (i < s_i) {
i++;
continue;
@@ -1916,35 +1913,25 @@ static int fn_trie_dump(struct fib_table
struct trie *t = (struct trie *) tb->tb_data;
t_key key = cb->args[2];
- rcu_read_lock();
+ ASSERT_RTNL();
+
/* Dump starting at last key.
* Note: 0.0.0.0/0 (ie default) is first key.
*/
if (!key)
l = trie_firstleaf(t);
- else {
+ else
l = fib_find_node(t, key);
- if (!l) {
- /* The table changed during the dump, rather than
- * giving partial data, just make application retry.
- */
- rcu_read_unlock();
- return -EBUSY;
- }
- }
while (l) {
cb->args[2] = l->key;
- if (fn_trie_dump_leaf(l, tb, skb, cb) < 0) {
- rcu_read_unlock();
+ if (fn_trie_dump_leaf(l, tb, skb, cb) < 0)
return -1;
- }
l = trie_nextleaf(l);
memset(&cb->args[3], 0,
sizeof(cb->args) - 3*sizeof(cb->args[0]));
}
- rcu_read_unlock();
return skb->len;
}
--
Stephen Hemminger <stephen.hemminger@vyatta.com>
next prev parent reply other threads:[~2008-01-23 23:00 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20080123224844.610730277@linux-foundation.org>
2008-01-23 22:48 ` [IPV4 1/5] fib_trie: more whitespace cleanup Stephen Hemminger
2008-01-24 4:37 ` David Miller
2008-01-23 22:48 ` [IPV4 2/5] fib_trie: remove unneeded NULL check Stephen Hemminger
2008-01-24 4:38 ` David Miller
2008-01-23 22:48 ` Stephen Hemminger [this message]
2008-01-24 4:50 ` [IPV4 3/5] fib_trie: dump doesnt use RCU David Miller
2008-01-24 6:41 ` Patrick McHardy
2008-01-24 6:43 ` David Miller
2008-01-24 6:47 ` Patrick McHardy
2008-01-24 7:26 ` David Miller
2008-01-24 6:45 ` Stephen Hemminger
2008-01-24 7:27 ` David Miller
2008-01-24 21:51 ` [PATCH] fib_trie: rescan if key is lost during dump Stephen Hemminger
2008-01-25 8:23 ` Jarek Poplawski
2008-01-25 16:13 ` Stephen Hemminger
2008-01-25 19:01 ` Jarek Poplawski
2008-02-01 0:45 ` David Miller
2008-01-23 22:48 ` [IPV4 4/5] fib_trie: version 0.410 Stephen Hemminger
2008-01-24 4:50 ` David Miller
2008-01-23 22:48 ` [IPV4 5/5] fib_semantics: sparse warnings Stephen Hemminger
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=20080123224858.918669715@linux-foundation.org \
--to=shemminger@linux-foundation.org \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
/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).