diff options
author | Robert Olsson <robert.olsson@its.uu.se> | 2007-03-19 19:27:37 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-04-26 01:26:32 -0400 |
commit | 05eee48c5af8213a71bd908ce17f577b2b776f79 (patch) | |
tree | 42a21c48e7a549642a71a6db2abd8f41d0338088 /net/ipv4 | |
parent | ca0605a7c8a42379c695308944b3ae82a85479f1 (diff) |
[IPV4]: fib_trie resize break
The patch below adds break condition for the resize operations. If
we don't achieve the desired fill factor a warning is printed. Trie
should still be operational but new thresholds should be considered.
Signed-off-by: Robert Olsson <robert.olsson@its.uu.se>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r-- | net/ipv4/fib_trie.c | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c index e2b39fdd6a04..5d2b43d9f8fc 100644 --- a/net/ipv4/fib_trie.c +++ b/net/ipv4/fib_trie.c | |||
@@ -50,7 +50,7 @@ | |||
50 | * Patrick McHardy <kaber@trash.net> | 50 | * Patrick McHardy <kaber@trash.net> |
51 | */ | 51 | */ |
52 | 52 | ||
53 | #define VERSION "0.407" | 53 | #define VERSION "0.408" |
54 | 54 | ||
55 | #include <asm/uaccess.h> | 55 | #include <asm/uaccess.h> |
56 | #include <asm/system.h> | 56 | #include <asm/system.h> |
@@ -458,6 +458,7 @@ static struct node *resize(struct trie *t, struct tnode *tn) | |||
458 | struct tnode *old_tn; | 458 | struct tnode *old_tn; |
459 | int inflate_threshold_use; | 459 | int inflate_threshold_use; |
460 | int halve_threshold_use; | 460 | int halve_threshold_use; |
461 | int max_resize; | ||
461 | 462 | ||
462 | if (!tn) | 463 | if (!tn) |
463 | return NULL; | 464 | return NULL; |
@@ -558,7 +559,8 @@ static struct node *resize(struct trie *t, struct tnode *tn) | |||
558 | inflate_threshold_use = inflate_threshold; | 559 | inflate_threshold_use = inflate_threshold; |
559 | 560 | ||
560 | err = 0; | 561 | err = 0; |
561 | while ((tn->full_children > 0 && | 562 | max_resize = 10; |
563 | while ((tn->full_children > 0 && max_resize-- && | ||
562 | 50 * (tn->full_children + tnode_child_length(tn) - tn->empty_children) >= | 564 | 50 * (tn->full_children + tnode_child_length(tn) - tn->empty_children) >= |
563 | inflate_threshold_use * tnode_child_length(tn))) { | 565 | inflate_threshold_use * tnode_child_length(tn))) { |
564 | 566 | ||
@@ -573,6 +575,15 @@ static struct node *resize(struct trie *t, struct tnode *tn) | |||
573 | } | 575 | } |
574 | } | 576 | } |
575 | 577 | ||
578 | if (max_resize < 0) { | ||
579 | if (!tn->parent) | ||
580 | printk(KERN_WARNING "Fix inflate_threshold_root. Now=%d size=%d bits\n", | ||
581 | inflate_threshold_root, tn->bits); | ||
582 | else | ||
583 | printk(KERN_WARNING "Fix inflate_threshold. Now=%d size=%d bits\n", | ||
584 | inflate_threshold, tn->bits); | ||
585 | } | ||
586 | |||
576 | check_tnode(tn); | 587 | check_tnode(tn); |
577 | 588 | ||
578 | /* | 589 | /* |
@@ -589,7 +600,8 @@ static struct node *resize(struct trie *t, struct tnode *tn) | |||
589 | halve_threshold_use = halve_threshold; | 600 | halve_threshold_use = halve_threshold; |
590 | 601 | ||
591 | err = 0; | 602 | err = 0; |
592 | while (tn->bits > 1 && | 603 | max_resize = 10; |
604 | while (tn->bits > 1 && max_resize-- && | ||
593 | 100 * (tnode_child_length(tn) - tn->empty_children) < | 605 | 100 * (tnode_child_length(tn) - tn->empty_children) < |
594 | halve_threshold_use * tnode_child_length(tn)) { | 606 | halve_threshold_use * tnode_child_length(tn)) { |
595 | 607 | ||
@@ -604,6 +616,14 @@ static struct node *resize(struct trie *t, struct tnode *tn) | |||
604 | } | 616 | } |
605 | } | 617 | } |
606 | 618 | ||
619 | if (max_resize < 0) { | ||
620 | if (!tn->parent) | ||
621 | printk(KERN_WARNING "Fix halve_threshold_root. Now=%d size=%d bits\n", | ||
622 | halve_threshold_root, tn->bits); | ||
623 | else | ||
624 | printk(KERN_WARNING "Fix halve_threshold. Now=%d size=%d bits\n", | ||
625 | halve_threshold, tn->bits); | ||
626 | } | ||
607 | 627 | ||
608 | /* Only one child remains */ | 628 | /* Only one child remains */ |
609 | if (tn->empty_children == tnode_child_length(tn) - 1) | 629 | if (tn->empty_children == tnode_child_length(tn) - 1) |