summaryrefslogtreecommitdiffstats
path: root/net/tipc/link.c
diff options
context:
space:
mode:
authorYing Xue <ying.xue@windriver.com>2014-03-27 05:54:37 +0100
committerDavid S. Miller <davem@davemloft.net>2014-03-27 18:08:37 +0100
commit6c7a762e70637a256229f9dc9ca793908e8bd01b (patch)
treead8c61e1fa48fdc36e799be6f8f67d257ee080b1 /net/tipc/link.c
parenttipc: rename node create lock to protect node list and hlist (diff)
downloadlinux-6c7a762e70637a256229f9dc9ca793908e8bd01b.tar.xz
linux-6c7a762e70637a256229f9dc9ca793908e8bd01b.zip
tipc: tipc: convert node list and node hlist to RCU lists
Convert tipc_node_list list and node_htable hash list to RCU lists. On read side, the two lists are protected with RCU read lock, and on update side, node_list_lock is applied to them. Signed-off-by: Ying Xue <ying.xue@windriver.com> Reviewed-by: Erik Hugne <erik.hugne@ericsson.com> Reviewed-by: Jon Maloy <jon.maloy@ericsson.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc/link.c')
-rw-r--r--net/tipc/link.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/net/tipc/link.c b/net/tipc/link.c
index 882c5c9c52f9..c5190ab75290 100644
--- a/net/tipc/link.c
+++ b/net/tipc/link.c
@@ -280,13 +280,13 @@ struct tipc_link *tipc_link_create(struct tipc_node *n_ptr,
return l_ptr;
}
-
void tipc_link_delete_list(unsigned int bearer_id, bool shutting_down)
{
struct tipc_link *l_ptr;
struct tipc_node *n_ptr;
- list_for_each_entry(n_ptr, &tipc_node_list, list) {
+ rcu_read_lock();
+ list_for_each_entry_rcu(n_ptr, &tipc_node_list, list) {
spin_lock_bh(&n_ptr->lock);
l_ptr = n_ptr->links[bearer_id];
if (l_ptr) {
@@ -309,6 +309,7 @@ void tipc_link_delete_list(unsigned int bearer_id, bool shutting_down)
}
spin_unlock_bh(&n_ptr->lock);
}
+ rcu_read_unlock();
}
/**
@@ -461,13 +462,15 @@ void tipc_link_reset_list(unsigned int bearer_id)
struct tipc_link *l_ptr;
struct tipc_node *n_ptr;
- list_for_each_entry(n_ptr, &tipc_node_list, list) {
+ rcu_read_lock();
+ list_for_each_entry_rcu(n_ptr, &tipc_node_list, list) {
spin_lock_bh(&n_ptr->lock);
l_ptr = n_ptr->links[bearer_id];
if (l_ptr)
tipc_link_reset(l_ptr);
spin_unlock_bh(&n_ptr->lock);
}
+ rcu_read_unlock();
}
static void link_activate(struct tipc_link *l_ptr)
@@ -2404,13 +2407,12 @@ static struct tipc_node *tipc_link_find_owner(const char *link_name,
{
struct tipc_link *l_ptr;
struct tipc_node *n_ptr;
- struct tipc_node *tmp_n_ptr;
struct tipc_node *found_node = 0;
-
int i;
*bearer_id = 0;
- list_for_each_entry_safe(n_ptr, tmp_n_ptr, &tipc_node_list, list) {
+ rcu_read_lock();
+ list_for_each_entry_rcu(n_ptr, &tipc_node_list, list) {
tipc_node_lock(n_ptr);
for (i = 0; i < MAX_BEARERS; i++) {
l_ptr = n_ptr->links[i];
@@ -2424,6 +2426,8 @@ static struct tipc_node *tipc_link_find_owner(const char *link_name,
if (found_node)
break;
}
+ rcu_read_unlock();
+
return found_node;
}