diff options
author | Allan Stephens <allan.stephens@windriver.com> | 2010-10-14 09:58:26 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-10-18 04:50:49 -0400 |
commit | ccc901ee58cfb090a31216a6eda0f1e9dfc572fa (patch) | |
tree | 84ef5ceb36f6b44c2ba66830c20ebb1fd3b85dcd /net/tipc/bearer.c | |
parent | 724829b3ad8e8aeb0aec46de383d35bfa1ad3875 (diff) |
tipc: Simplify bearer shutdown logic
Optimize processing in TIPC's bearer shutdown code, including:
1. Remove an unnecessary check to see if TIPC bearer's can exist.
2. Don't release spinlocks before calling a media-specific disabling
routine, since the routine can't sleep.
3. Make bearer_disable() operate directly on a struct bearer, instead
of needlessly taking a name and then mapping that to the struct.
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Reviewed-by: Neil Horman <nhorman@tuxdriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc/bearer.c')
-rw-r--r-- | net/tipc/bearer.c | 38 |
1 files changed, 11 insertions, 27 deletions
diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c index 9c10c6b7c12b..fd9c06c68281 100644 --- a/net/tipc/bearer.c +++ b/net/tipc/bearer.c | |||
@@ -288,9 +288,6 @@ static struct bearer *bearer_find(const char *name) | |||
288 | struct bearer *b_ptr; | 288 | struct bearer *b_ptr; |
289 | u32 i; | 289 | u32 i; |
290 | 290 | ||
291 | if (tipc_mode != TIPC_NET_MODE) | ||
292 | return NULL; | ||
293 | |||
294 | for (i = 0, b_ptr = tipc_bearers; i < MAX_BEARERS; i++, b_ptr++) { | 291 | for (i = 0, b_ptr = tipc_bearers; i < MAX_BEARERS; i++, b_ptr++) { |
295 | if (b_ptr->active && (!strcmp(b_ptr->publ.name, name))) | 292 | if (b_ptr->active && (!strcmp(b_ptr->publ.name, name))) |
296 | return b_ptr; | 293 | return b_ptr; |
@@ -630,30 +627,17 @@ int tipc_block_bearer(const char *name) | |||
630 | * Note: This routine assumes caller holds tipc_net_lock. | 627 | * Note: This routine assumes caller holds tipc_net_lock. |
631 | */ | 628 | */ |
632 | 629 | ||
633 | static int bearer_disable(const char *name) | 630 | static int bearer_disable(struct bearer *b_ptr) |
634 | { | 631 | { |
635 | struct bearer *b_ptr; | ||
636 | struct link *l_ptr; | 632 | struct link *l_ptr; |
637 | struct link *temp_l_ptr; | 633 | struct link *temp_l_ptr; |
638 | 634 | ||
639 | b_ptr = bearer_find(name); | 635 | info("Disabling bearer <%s>\n", b_ptr->publ.name); |
640 | if (!b_ptr) { | ||
641 | warn("Attempt to disable unknown bearer <%s>\n", name); | ||
642 | return -EINVAL; | ||
643 | } | ||
644 | |||
645 | info("Disabling bearer <%s>\n", name); | ||
646 | tipc_disc_stop_link_req(b_ptr->link_req); | 636 | tipc_disc_stop_link_req(b_ptr->link_req); |
647 | spin_lock_bh(&b_ptr->publ.lock); | 637 | spin_lock_bh(&b_ptr->publ.lock); |
648 | b_ptr->link_req = NULL; | 638 | b_ptr->link_req = NULL; |
649 | b_ptr->publ.blocked = 1; | 639 | b_ptr->publ.blocked = 1; |
650 | if (b_ptr->media->disable_bearer) { | 640 | b_ptr->media->disable_bearer(&b_ptr->publ); |
651 | spin_unlock_bh(&b_ptr->publ.lock); | ||
652 | write_unlock_bh(&tipc_net_lock); | ||
653 | b_ptr->media->disable_bearer(&b_ptr->publ); | ||
654 | write_lock_bh(&tipc_net_lock); | ||
655 | spin_lock_bh(&b_ptr->publ.lock); | ||
656 | } | ||
657 | list_for_each_entry_safe(l_ptr, temp_l_ptr, &b_ptr->links, link_list) { | 641 | list_for_each_entry_safe(l_ptr, temp_l_ptr, &b_ptr->links, link_list) { |
658 | tipc_link_delete(l_ptr); | 642 | tipc_link_delete(l_ptr); |
659 | } | 643 | } |
@@ -664,10 +648,16 @@ static int bearer_disable(const char *name) | |||
664 | 648 | ||
665 | int tipc_disable_bearer(const char *name) | 649 | int tipc_disable_bearer(const char *name) |
666 | { | 650 | { |
651 | struct bearer *b_ptr; | ||
667 | int res; | 652 | int res; |
668 | 653 | ||
669 | write_lock_bh(&tipc_net_lock); | 654 | write_lock_bh(&tipc_net_lock); |
670 | res = bearer_disable(name); | 655 | b_ptr = bearer_find(name); |
656 | if (b_ptr == NULL) { | ||
657 | warn("Attempt to disable unknown bearer <%s>\n", name); | ||
658 | res = -EINVAL; | ||
659 | } else | ||
660 | res = bearer_disable(b_ptr); | ||
671 | write_unlock_bh(&tipc_net_lock); | 661 | write_unlock_bh(&tipc_net_lock); |
672 | return res; | 662 | return res; |
673 | } | 663 | } |
@@ -680,13 +670,7 @@ void tipc_bearer_stop(void) | |||
680 | 670 | ||
681 | for (i = 0; i < MAX_BEARERS; i++) { | 671 | for (i = 0; i < MAX_BEARERS; i++) { |
682 | if (tipc_bearers[i].active) | 672 | if (tipc_bearers[i].active) |
683 | tipc_bearers[i].publ.blocked = 1; | 673 | bearer_disable(&tipc_bearers[i]); |
684 | } | ||
685 | for (i = 0; i < MAX_BEARERS; i++) { | ||
686 | if (tipc_bearers[i].active) | ||
687 | bearer_disable(tipc_bearers[i].publ.name); | ||
688 | } | 674 | } |
689 | media_count = 0; | 675 | media_count = 0; |
690 | } | 676 | } |
691 | |||
692 | |||