diff options
author | Allan Stephens <Allan.Stephens@windriver.com> | 2010-12-31 13:59:23 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-01-01 16:57:51 -0500 |
commit | 5af5479296fba0ace5d5cab84045de5b19bde3fe (patch) | |
tree | d23a71887cafdac19a3e4da54e225c7d9c15ada5 /net | |
parent | b0c1e928c85023c73780b5d9873406ccf1cd8019 (diff) |
tipc: Remove internal linked list of node objects
Eliminates a sorted list TIPC uses to keep track of the neighboring
nodes it has links to, since this duplicates information already present
in the internal array of node object pointers.
Signed-off-by: Allan Stephens <Allan.Stephens@windriver.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/tipc/node.c | 43 |
1 files changed, 16 insertions, 27 deletions
diff --git a/net/tipc/node.c b/net/tipc/node.c index 58e189bf5c96..31dcca98201a 100644 --- a/net/tipc/node.c +++ b/net/tipc/node.c | |||
@@ -43,9 +43,6 @@ | |||
43 | static void node_lost_contact(struct tipc_node *n_ptr); | 43 | static void node_lost_contact(struct tipc_node *n_ptr); |
44 | static void node_established_contact(struct tipc_node *n_ptr); | 44 | static void node_established_contact(struct tipc_node *n_ptr); |
45 | 45 | ||
46 | /* sorted list of nodes within cluster */ | ||
47 | static struct tipc_node *tipc_nodes = NULL; | ||
48 | |||
49 | static DEFINE_SPINLOCK(node_create_lock); | 46 | static DEFINE_SPINLOCK(node_create_lock); |
50 | 47 | ||
51 | u32 tipc_own_tag = 0; | 48 | u32 tipc_own_tag = 0; |
@@ -63,21 +60,17 @@ u32 tipc_own_tag = 0; | |||
63 | struct tipc_node *tipc_node_create(u32 addr) | 60 | struct tipc_node *tipc_node_create(u32 addr) |
64 | { | 61 | { |
65 | struct tipc_node *n_ptr; | 62 | struct tipc_node *n_ptr; |
66 | struct tipc_node **curr_node; | ||
67 | u32 n_num; | 63 | u32 n_num; |
68 | 64 | ||
69 | spin_lock_bh(&node_create_lock); | 65 | spin_lock_bh(&node_create_lock); |
70 | 66 | ||
71 | for (n_ptr = tipc_nodes; n_ptr; n_ptr = n_ptr->next) { | 67 | n_ptr = tipc_node_find(addr); |
72 | if (addr < n_ptr->addr) | 68 | if (n_ptr) { |
73 | break; | 69 | spin_unlock_bh(&node_create_lock); |
74 | if (addr == n_ptr->addr) { | 70 | return n_ptr; |
75 | spin_unlock_bh(&node_create_lock); | ||
76 | return n_ptr; | ||
77 | } | ||
78 | } | 71 | } |
79 | 72 | ||
80 | n_ptr = kzalloc(sizeof(*n_ptr),GFP_ATOMIC); | 73 | n_ptr = kzalloc(sizeof(*n_ptr), GFP_ATOMIC); |
81 | if (!n_ptr) { | 74 | if (!n_ptr) { |
82 | spin_unlock_bh(&node_create_lock); | 75 | spin_unlock_bh(&node_create_lock); |
83 | warn("Node creation failed, no memory\n"); | 76 | warn("Node creation failed, no memory\n"); |
@@ -93,15 +86,6 @@ struct tipc_node *tipc_node_create(u32 addr) | |||
93 | if (n_num > tipc_net.highest_node) | 86 | if (n_num > tipc_net.highest_node) |
94 | tipc_net.highest_node = n_num; | 87 | tipc_net.highest_node = n_num; |
95 | 88 | ||
96 | /* Insert node into ordered list */ | ||
97 | for (curr_node = &tipc_nodes; *curr_node; | ||
98 | curr_node = &(*curr_node)->next) { | ||
99 | if (addr < (*curr_node)->addr) { | ||
100 | n_ptr->next = *curr_node; | ||
101 | break; | ||
102 | } | ||
103 | } | ||
104 | (*curr_node) = n_ptr; | ||
105 | spin_unlock_bh(&node_create_lock); | 89 | spin_unlock_bh(&node_create_lock); |
106 | return n_ptr; | 90 | return n_ptr; |
107 | } | 91 | } |
@@ -405,6 +389,7 @@ struct sk_buff *tipc_node_get_nodes(const void *req_tlv_area, int req_tlv_space) | |||
405 | struct tipc_node *n_ptr; | 389 | struct tipc_node *n_ptr; |
406 | struct tipc_node_info node_info; | 390 | struct tipc_node_info node_info; |
407 | u32 payload_size; | 391 | u32 payload_size; |
392 | u32 n_num; | ||
408 | 393 | ||
409 | if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_NET_ADDR)) | 394 | if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_NET_ADDR)) |
410 | return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR); | 395 | return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR); |
@@ -415,14 +400,15 @@ struct sk_buff *tipc_node_get_nodes(const void *req_tlv_area, int req_tlv_space) | |||
415 | " (network address)"); | 400 | " (network address)"); |
416 | 401 | ||
417 | read_lock_bh(&tipc_net_lock); | 402 | read_lock_bh(&tipc_net_lock); |
418 | if (!tipc_nodes) { | 403 | if (!tipc_net.nodes) { |
419 | read_unlock_bh(&tipc_net_lock); | 404 | read_unlock_bh(&tipc_net_lock); |
420 | return tipc_cfg_reply_none(); | 405 | return tipc_cfg_reply_none(); |
421 | } | 406 | } |
422 | 407 | ||
423 | /* For now, get space for all other nodes */ | 408 | /* For now, get space for all other nodes */ |
424 | 409 | ||
425 | payload_size = TLV_SPACE(sizeof(node_info)) * (tipc_max_nodes - 1); | 410 | payload_size = TLV_SPACE(sizeof(node_info)) * |
411 | (tipc_net.highest_node - 1); | ||
426 | if (payload_size > 32768u) { | 412 | if (payload_size > 32768u) { |
427 | read_unlock_bh(&tipc_net_lock); | 413 | read_unlock_bh(&tipc_net_lock); |
428 | return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED | 414 | return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED |
@@ -436,8 +422,9 @@ struct sk_buff *tipc_node_get_nodes(const void *req_tlv_area, int req_tlv_space) | |||
436 | 422 | ||
437 | /* Add TLVs for all nodes in scope */ | 423 | /* Add TLVs for all nodes in scope */ |
438 | 424 | ||
439 | for (n_ptr = tipc_nodes; n_ptr; n_ptr = n_ptr->next) { | 425 | for (n_num = 1; n_num <= tipc_net.highest_node; n_num++) { |
440 | if (!tipc_in_scope(domain, n_ptr->addr)) | 426 | n_ptr = tipc_net.nodes[n_num]; |
427 | if (!n_ptr || !tipc_in_scope(domain, n_ptr->addr)) | ||
441 | continue; | 428 | continue; |
442 | node_info.addr = htonl(n_ptr->addr); | 429 | node_info.addr = htonl(n_ptr->addr); |
443 | node_info.up = htonl(tipc_node_is_up(n_ptr)); | 430 | node_info.up = htonl(tipc_node_is_up(n_ptr)); |
@@ -456,6 +443,7 @@ struct sk_buff *tipc_node_get_links(const void *req_tlv_area, int req_tlv_space) | |||
456 | struct tipc_node *n_ptr; | 443 | struct tipc_node *n_ptr; |
457 | struct tipc_link_info link_info; | 444 | struct tipc_link_info link_info; |
458 | u32 payload_size; | 445 | u32 payload_size; |
446 | u32 n_num; | ||
459 | 447 | ||
460 | if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_NET_ADDR)) | 448 | if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_NET_ADDR)) |
461 | return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR); | 449 | return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR); |
@@ -493,10 +481,11 @@ struct sk_buff *tipc_node_get_links(const void *req_tlv_area, int req_tlv_space) | |||
493 | 481 | ||
494 | /* Add TLVs for any other links in scope */ | 482 | /* Add TLVs for any other links in scope */ |
495 | 483 | ||
496 | for (n_ptr = tipc_nodes; n_ptr; n_ptr = n_ptr->next) { | 484 | for (n_num = 1; n_num <= tipc_net.highest_node; n_num++) { |
497 | u32 i; | 485 | u32 i; |
498 | 486 | ||
499 | if (!tipc_in_scope(domain, n_ptr->addr)) | 487 | n_ptr = tipc_net.nodes[n_num]; |
488 | if (!n_ptr || !tipc_in_scope(domain, n_ptr->addr)) | ||
500 | continue; | 489 | continue; |
501 | tipc_node_lock(n_ptr); | 490 | tipc_node_lock(n_ptr); |
502 | for (i = 0; i < MAX_BEARERS; i++) { | 491 | for (i = 0; i < MAX_BEARERS; i++) { |