diff options
Diffstat (limited to 'net/tipc/name_table.c')
-rw-r--r-- | net/tipc/name_table.c | 60 |
1 files changed, 12 insertions, 48 deletions
diff --git a/net/tipc/name_table.c b/net/tipc/name_table.c index 3a8de4334da1..205ed4a4e186 100644 --- a/net/tipc/name_table.c +++ b/net/tipc/name_table.c | |||
@@ -36,15 +36,10 @@ | |||
36 | 36 | ||
37 | #include "core.h" | 37 | #include "core.h" |
38 | #include "config.h" | 38 | #include "config.h" |
39 | #include "dbg.h" | ||
40 | #include "name_table.h" | 39 | #include "name_table.h" |
41 | #include "name_distr.h" | 40 | #include "name_distr.h" |
42 | #include "addr.h" | ||
43 | #include "node_subscr.h" | ||
44 | #include "subscr.h" | 41 | #include "subscr.h" |
45 | #include "port.h" | 42 | #include "port.h" |
46 | #include "cluster.h" | ||
47 | #include "bcast.h" | ||
48 | 43 | ||
49 | static int tipc_nametbl_size = 1024; /* must be a power of 2 */ | 44 | static int tipc_nametbl_size = 1024; /* must be a power of 2 */ |
50 | 45 | ||
@@ -109,7 +104,7 @@ struct name_table { | |||
109 | u32 local_publ_count; | 104 | u32 local_publ_count; |
110 | }; | 105 | }; |
111 | 106 | ||
112 | static struct name_table table = { NULL } ; | 107 | static struct name_table table; |
113 | static atomic_t rsv_publ_ok = ATOMIC_INIT(0); | 108 | static atomic_t rsv_publ_ok = ATOMIC_INIT(0); |
114 | DEFINE_RWLOCK(tipc_nametbl_lock); | 109 | DEFINE_RWLOCK(tipc_nametbl_lock); |
115 | 110 | ||
@@ -177,8 +172,6 @@ static struct name_seq *tipc_nameseq_create(u32 type, struct hlist_head *seq_hea | |||
177 | spin_lock_init(&nseq->lock); | 172 | spin_lock_init(&nseq->lock); |
178 | nseq->type = type; | 173 | nseq->type = type; |
179 | nseq->sseqs = sseq; | 174 | nseq->sseqs = sseq; |
180 | dbg("tipc_nameseq_create(): nseq = %p, type %u, ssseqs %p, ff: %u\n", | ||
181 | nseq, type, nseq->sseqs, nseq->first_free); | ||
182 | nseq->alloc = 1; | 175 | nseq->alloc = 1; |
183 | INIT_HLIST_NODE(&nseq->ns_list); | 176 | INIT_HLIST_NODE(&nseq->ns_list); |
184 | INIT_LIST_HEAD(&nseq->subscriptions); | 177 | INIT_LIST_HEAD(&nseq->subscriptions); |
@@ -256,8 +249,6 @@ static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq, | |||
256 | int created_subseq = 0; | 249 | int created_subseq = 0; |
257 | 250 | ||
258 | sseq = nameseq_find_subseq(nseq, lower); | 251 | sseq = nameseq_find_subseq(nseq, lower); |
259 | dbg("nameseq_ins: for seq %p, {%u,%u}, found sseq %p\n", | ||
260 | nseq, type, lower, sseq); | ||
261 | if (sseq) { | 252 | if (sseq) { |
262 | 253 | ||
263 | /* Lower end overlaps existing entry => need an exact match */ | 254 | /* Lower end overlaps existing entry => need an exact match */ |
@@ -294,38 +285,30 @@ static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq, | |||
294 | type, lower, upper); | 285 | type, lower, upper); |
295 | return NULL; | 286 | return NULL; |
296 | } | 287 | } |
297 | dbg("Allocated %u more sseqs\n", nseq->alloc); | ||
298 | memcpy(sseqs, nseq->sseqs, | 288 | memcpy(sseqs, nseq->sseqs, |
299 | nseq->alloc * sizeof(struct sub_seq)); | 289 | nseq->alloc * sizeof(struct sub_seq)); |
300 | kfree(nseq->sseqs); | 290 | kfree(nseq->sseqs); |
301 | nseq->sseqs = sseqs; | 291 | nseq->sseqs = sseqs; |
302 | nseq->alloc *= 2; | 292 | nseq->alloc *= 2; |
303 | } | 293 | } |
304 | dbg("Have %u sseqs for type %u\n", nseq->alloc, type); | ||
305 | 294 | ||
306 | /* Insert new sub-sequence */ | 295 | /* Insert new sub-sequence */ |
307 | 296 | ||
308 | dbg("ins in pos %u, ff = %u\n", inspos, nseq->first_free); | ||
309 | sseq = &nseq->sseqs[inspos]; | 297 | sseq = &nseq->sseqs[inspos]; |
310 | freesseq = &nseq->sseqs[nseq->first_free]; | 298 | freesseq = &nseq->sseqs[nseq->first_free]; |
311 | memmove(sseq + 1, sseq, (freesseq - sseq) * sizeof (*sseq)); | 299 | memmove(sseq + 1, sseq, (freesseq - sseq) * sizeof(*sseq)); |
312 | memset(sseq, 0, sizeof (*sseq)); | 300 | memset(sseq, 0, sizeof(*sseq)); |
313 | nseq->first_free++; | 301 | nseq->first_free++; |
314 | sseq->lower = lower; | 302 | sseq->lower = lower; |
315 | sseq->upper = upper; | 303 | sseq->upper = upper; |
316 | created_subseq = 1; | 304 | created_subseq = 1; |
317 | } | 305 | } |
318 | dbg("inserting {%u,%u,%u} from <0x%x:%u> into sseq %p(%u,%u) of seq %p\n", | ||
319 | type, lower, upper, node, port, sseq, | ||
320 | sseq->lower, sseq->upper, nseq); | ||
321 | 306 | ||
322 | /* Insert a publication: */ | 307 | /* Insert a publication: */ |
323 | 308 | ||
324 | publ = publ_create(type, lower, upper, scope, node, port, key); | 309 | publ = publ_create(type, lower, upper, scope, node, port, key); |
325 | if (!publ) | 310 | if (!publ) |
326 | return NULL; | 311 | return NULL; |
327 | dbg("inserting publ %p, node=0x%x publ->node=0x%x, subscr->node=%p\n", | ||
328 | publ, node, publ->node, publ->subscr.node); | ||
329 | 312 | ||
330 | sseq->zone_list_size++; | 313 | sseq->zone_list_size++; |
331 | if (!sseq->zone_list) | 314 | if (!sseq->zone_list) |
@@ -360,7 +343,6 @@ static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq, | |||
360 | * Any subscriptions waiting for notification? | 343 | * Any subscriptions waiting for notification? |
361 | */ | 344 | */ |
362 | list_for_each_entry_safe(s, st, &nseq->subscriptions, nameseq_list) { | 345 | list_for_each_entry_safe(s, st, &nseq->subscriptions, nameseq_list) { |
363 | dbg("calling report_overlap()\n"); | ||
364 | tipc_subscr_report_overlap(s, | 346 | tipc_subscr_report_overlap(s, |
365 | publ->lower, | 347 | publ->lower, |
366 | publ->upper, | 348 | publ->upper, |
@@ -398,9 +380,6 @@ static struct publication *tipc_nameseq_remove_publ(struct name_seq *nseq, u32 i | |||
398 | if (!sseq) | 380 | if (!sseq) |
399 | return NULL; | 381 | return NULL; |
400 | 382 | ||
401 | dbg("tipc_nameseq_remove_publ: seq: %p, sseq %p, {%u,%u}, key %u\n", | ||
402 | nseq, sseq, nseq->type, inst, key); | ||
403 | |||
404 | /* Remove publication from zone scope list */ | 383 | /* Remove publication from zone scope list */ |
405 | 384 | ||
406 | prev = sseq->zone_list; | 385 | prev = sseq->zone_list; |
@@ -492,7 +471,7 @@ end_node: | |||
492 | 471 | ||
493 | if (!sseq->zone_list) { | 472 | if (!sseq->zone_list) { |
494 | free = &nseq->sseqs[nseq->first_free--]; | 473 | free = &nseq->sseqs[nseq->first_free--]; |
495 | memmove(sseq, sseq + 1, (free - (sseq + 1)) * sizeof (*sseq)); | 474 | memmove(sseq, sseq + 1, (free - (sseq + 1)) * sizeof(*sseq)); |
496 | removed_subseq = 1; | 475 | removed_subseq = 1; |
497 | } | 476 | } |
498 | 477 | ||
@@ -528,7 +507,7 @@ static void tipc_nameseq_subscribe(struct name_seq *nseq, struct subscription *s | |||
528 | 507 | ||
529 | while (sseq != &nseq->sseqs[nseq->first_free]) { | 508 | while (sseq != &nseq->sseqs[nseq->first_free]) { |
530 | struct publication *zl = sseq->zone_list; | 509 | struct publication *zl = sseq->zone_list; |
531 | if (zl && tipc_subscr_overlap(s,sseq->lower,sseq->upper)) { | 510 | if (zl && tipc_subscr_overlap(s, sseq->lower, sseq->upper)) { |
532 | struct publication *crs = zl; | 511 | struct publication *crs = zl; |
533 | int must_report = 1; | 512 | int must_report = 1; |
534 | 513 | ||
@@ -554,15 +533,10 @@ static struct name_seq *nametbl_find_seq(u32 type) | |||
554 | struct hlist_node *seq_node; | 533 | struct hlist_node *seq_node; |
555 | struct name_seq *ns; | 534 | struct name_seq *ns; |
556 | 535 | ||
557 | dbg("find_seq %u,(%u,0x%x) table = %p, hash[type] = %u\n", | ||
558 | type, htonl(type), type, table.types, hash(type)); | ||
559 | |||
560 | seq_head = &table.types[hash(type)]; | 536 | seq_head = &table.types[hash(type)]; |
561 | hlist_for_each_entry(ns, seq_node, seq_head, ns_list) { | 537 | hlist_for_each_entry(ns, seq_node, seq_head, ns_list) { |
562 | if (ns->type == type) { | 538 | if (ns->type == type) |
563 | dbg("found %p\n", ns); | ||
564 | return ns; | 539 | return ns; |
565 | } | ||
566 | } | 540 | } |
567 | 541 | ||
568 | return NULL; | 542 | return NULL; |
@@ -573,18 +547,14 @@ struct publication *tipc_nametbl_insert_publ(u32 type, u32 lower, u32 upper, | |||
573 | { | 547 | { |
574 | struct name_seq *seq = nametbl_find_seq(type); | 548 | struct name_seq *seq = nametbl_find_seq(type); |
575 | 549 | ||
576 | dbg("tipc_nametbl_insert_publ: {%u,%u,%u} found %p\n", type, lower, upper, seq); | ||
577 | if (lower > upper) { | 550 | if (lower > upper) { |
578 | warn("Failed to publish illegal {%u,%u,%u}\n", | 551 | warn("Failed to publish illegal {%u,%u,%u}\n", |
579 | type, lower, upper); | 552 | type, lower, upper); |
580 | return NULL; | 553 | return NULL; |
581 | } | 554 | } |
582 | 555 | ||
583 | dbg("Publishing {%u,%u,%u} from 0x%x\n", type, lower, upper, node); | 556 | if (!seq) |
584 | if (!seq) { | ||
585 | seq = tipc_nameseq_create(type, &table.types[hash(type)]); | 557 | seq = tipc_nameseq_create(type, &table.types[hash(type)]); |
586 | dbg("tipc_nametbl_insert_publ: created %p\n", seq); | ||
587 | } | ||
588 | if (!seq) | 558 | if (!seq) |
589 | return NULL; | 559 | return NULL; |
590 | 560 | ||
@@ -601,7 +571,6 @@ struct publication *tipc_nametbl_remove_publ(u32 type, u32 lower, | |||
601 | if (!seq) | 571 | if (!seq) |
602 | return NULL; | 572 | return NULL; |
603 | 573 | ||
604 | dbg("Withdrawing {%u,%u} from 0x%x\n", type, lower, node); | ||
605 | publ = tipc_nameseq_remove_publ(seq, lower, node, ref, key); | 574 | publ = tipc_nameseq_remove_publ(seq, lower, node, ref, key); |
606 | 575 | ||
607 | if (!seq->first_free && list_empty(&seq->subscriptions)) { | 576 | if (!seq->first_free && list_empty(&seq->subscriptions)) { |
@@ -782,9 +751,8 @@ struct publication *tipc_nametbl_publish(u32 type, u32 lower, u32 upper, | |||
782 | table.local_publ_count++; | 751 | table.local_publ_count++; |
783 | publ = tipc_nametbl_insert_publ(type, lower, upper, scope, | 752 | publ = tipc_nametbl_insert_publ(type, lower, upper, scope, |
784 | tipc_own_addr, port_ref, key); | 753 | tipc_own_addr, port_ref, key); |
785 | if (publ && (scope != TIPC_NODE_SCOPE)) { | 754 | if (publ && (scope != TIPC_NODE_SCOPE)) |
786 | tipc_named_publish(publ); | 755 | tipc_named_publish(publ); |
787 | } | ||
788 | write_unlock_bh(&tipc_nametbl_lock); | 756 | write_unlock_bh(&tipc_nametbl_lock); |
789 | return publ; | 757 | return publ; |
790 | } | 758 | } |
@@ -797,7 +765,6 @@ int tipc_nametbl_withdraw(u32 type, u32 lower, u32 ref, u32 key) | |||
797 | { | 765 | { |
798 | struct publication *publ; | 766 | struct publication *publ; |
799 | 767 | ||
800 | dbg("tipc_nametbl_withdraw: {%u,%u}, key=%u\n", type, lower, key); | ||
801 | write_lock_bh(&tipc_nametbl_lock); | 768 | write_lock_bh(&tipc_nametbl_lock); |
802 | publ = tipc_nametbl_remove_publ(type, lower, tipc_own_addr, ref, key); | 769 | publ = tipc_nametbl_remove_publ(type, lower, tipc_own_addr, ref, key); |
803 | if (likely(publ)) { | 770 | if (likely(publ)) { |
@@ -827,13 +794,10 @@ void tipc_nametbl_subscribe(struct subscription *s) | |||
827 | 794 | ||
828 | write_lock_bh(&tipc_nametbl_lock); | 795 | write_lock_bh(&tipc_nametbl_lock); |
829 | seq = nametbl_find_seq(type); | 796 | seq = nametbl_find_seq(type); |
830 | if (!seq) { | 797 | if (!seq) |
831 | seq = tipc_nameseq_create(type, &table.types[hash(type)]); | 798 | seq = tipc_nameseq_create(type, &table.types[hash(type)]); |
832 | } | 799 | if (seq) { |
833 | if (seq){ | ||
834 | spin_lock_bh(&seq->lock); | 800 | spin_lock_bh(&seq->lock); |
835 | dbg("tipc_nametbl_subscribe:found %p for {%u,%u,%u}\n", | ||
836 | seq, type, s->seq.lower, s->seq.upper); | ||
837 | tipc_nameseq_subscribe(seq, s); | 801 | tipc_nameseq_subscribe(seq, s); |
838 | spin_unlock_bh(&seq->lock); | 802 | spin_unlock_bh(&seq->lock); |
839 | } else { | 803 | } else { |
@@ -853,7 +817,7 @@ void tipc_nametbl_unsubscribe(struct subscription *s) | |||
853 | 817 | ||
854 | write_lock_bh(&tipc_nametbl_lock); | 818 | write_lock_bh(&tipc_nametbl_lock); |
855 | seq = nametbl_find_seq(s->seq.type); | 819 | seq = nametbl_find_seq(s->seq.type); |
856 | if (seq != NULL){ | 820 | if (seq != NULL) { |
857 | spin_lock_bh(&seq->lock); | 821 | spin_lock_bh(&seq->lock); |
858 | list_del_init(&s->nameseq_list); | 822 | list_del_init(&s->nameseq_list); |
859 | spin_unlock_bh(&seq->lock); | 823 | spin_unlock_bh(&seq->lock); |
@@ -886,7 +850,7 @@ static void subseq_list(struct sub_seq *sseq, struct print_buf *buf, u32 depth, | |||
886 | } | 850 | } |
887 | 851 | ||
888 | do { | 852 | do { |
889 | sprintf (portIdStr, "<%u.%u.%u:%u>", | 853 | sprintf(portIdStr, "<%u.%u.%u:%u>", |
890 | tipc_zone(publ->node), tipc_cluster(publ->node), | 854 | tipc_zone(publ->node), tipc_cluster(publ->node), |
891 | tipc_node(publ->node), publ->ref); | 855 | tipc_node(publ->node), publ->ref); |
892 | tipc_printf(buf, "%-26s ", portIdStr); | 856 | tipc_printf(buf, "%-26s ", portIdStr); |