aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/bearer.c
diff options
context:
space:
mode:
authorYing Xue <ying.xue@windriver.com>2014-02-13 17:29:17 -0500
committerDavid S. Miller <davem@davemloft.net>2014-02-13 17:57:07 -0500
commita83045292daf9f07d0b103e5715ef527123d2fcc (patch)
treeea983884e77ae82b1f099713a7d11834b95e84a9 /net/tipc/bearer.c
parent7d33939f475d403e79124e3143d7951dcfe8629f (diff)
tipc: remove bearer_lock from tipc_bearer struct
After the earlier commits ("tipc: remove 'links' list from tipc_bearer struct") and ("tipc: introduce new spinlock to protect struct link_req"), there is no longer any need to protect struct link_req or or any link list by use of bearer_lock. Furthermore, we have eliminated the need for using bearer_lock during downcalls (send) from the link to the bearer, since we have ensured that bearers always have a longer life cycle that their associated links, and always contain valid data. So, the only need now for a lock protecting bearers is for guaranteeing consistency of the bearer list itself. For this, it is sufficient, at least for the time being, to continue applying 'net_lock“ in write mode. By removing bearer_lock we also pre-empt introduction of issue b) descibed in the previous commit "tipc: remove 'links' list from tipc_bearer struct": "b) When the outer protection from net_lock is gone, taking bearer_lock and node_lock in opposite order of method 1) and 2) will become an obvious deadlock hazard". Therefore, we now eliminate the bearer_lock spinlock. Signed-off-by: Ying Xue <ying.xue@windriver.com> Reviewed-by: Paul Gortmaker <paul.gortmaker@windriver.com> Signed-off-by: Jon Maloy <jon.maloy@ericsson.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc/bearer.c')
-rw-r--r--net/tipc/bearer.c16
1 files changed, 3 insertions, 13 deletions
diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c
index 60caa45e5a41..242cddd35a47 100644
--- a/net/tipc/bearer.c
+++ b/net/tipc/bearer.c
@@ -327,7 +327,6 @@ restart:
327 b_ptr->net_plane = bearer_id + 'A'; 327 b_ptr->net_plane = bearer_id + 'A';
328 b_ptr->active = 1; 328 b_ptr->active = 1;
329 b_ptr->priority = priority; 329 b_ptr->priority = priority;
330 spin_lock_init(&b_ptr->lock);
331 330
332 res = tipc_disc_create(b_ptr, &b_ptr->bcast_addr, disc_domain); 331 res = tipc_disc_create(b_ptr, &b_ptr->bcast_addr, disc_domain);
333 if (res) { 332 if (res) {
@@ -351,9 +350,7 @@ static int tipc_reset_bearer(struct tipc_bearer *b_ptr)
351{ 350{
352 read_lock_bh(&tipc_net_lock); 351 read_lock_bh(&tipc_net_lock);
353 pr_info("Resetting bearer <%s>\n", b_ptr->name); 352 pr_info("Resetting bearer <%s>\n", b_ptr->name);
354 spin_lock_bh(&b_ptr->lock);
355 tipc_link_reset_list(b_ptr->identity); 353 tipc_link_reset_list(b_ptr->identity);
356 spin_unlock_bh(&b_ptr->lock);
357 read_unlock_bh(&tipc_net_lock); 354 read_unlock_bh(&tipc_net_lock);
358 return 0; 355 return 0;
359} 356}
@@ -365,19 +362,12 @@ static int tipc_reset_bearer(struct tipc_bearer *b_ptr)
365 */ 362 */
366static void bearer_disable(struct tipc_bearer *b_ptr, bool shutting_down) 363static void bearer_disable(struct tipc_bearer *b_ptr, bool shutting_down)
367{ 364{
368 struct tipc_link_req *temp_req;
369
370 pr_info("Disabling bearer <%s>\n", b_ptr->name); 365 pr_info("Disabling bearer <%s>\n", b_ptr->name);
371 spin_lock_bh(&b_ptr->lock);
372 b_ptr->media->disable_media(b_ptr); 366 b_ptr->media->disable_media(b_ptr);
373 tipc_link_delete_list(b_ptr->identity, shutting_down);
374 temp_req = b_ptr->link_req;
375 b_ptr->link_req = NULL;
376 spin_unlock_bh(&b_ptr->lock);
377
378 if (temp_req)
379 tipc_disc_delete(temp_req);
380 367
368 tipc_link_delete_list(b_ptr->identity, shutting_down);
369 if (b_ptr->link_req)
370 tipc_disc_delete(b_ptr->link_req);
381 memset(b_ptr, 0, sizeof(struct tipc_bearer)); 371 memset(b_ptr, 0, sizeof(struct tipc_bearer));
382} 372}
383 373