2
0

080-21-fib_trie-Fall-back-to-slen-update-on-inflate-halve-f.patch 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. From: Alexander Duyck <alexander.h.duyck@redhat.com>
  2. Date: Thu, 22 Jan 2015 15:51:20 -0800
  3. Subject: [PATCH] fib_trie: Fall back to slen update on inflate/halve failure
  4. This change corrects an issue where if inflate or halve fails we were
  5. exiting the resize function without at least updating the slen for the
  6. node. To correct this I have moved the update of max_size into the while
  7. loop so that it is only decremented on a successful call to either inflate
  8. or halve.
  9. Signed-off-by: Alexander Duyck <alexander.h.duyck@redhat.com>
  10. Signed-off-by: David S. Miller <davem@davemloft.net>
  11. ---
  12. --- a/net/ipv4/fib_trie.c
  13. +++ b/net/ipv4/fib_trie.c
  14. @@ -752,7 +752,7 @@ static void resize(struct trie *t, struc
  15. {
  16. struct tnode *tp = node_parent(tn), *n = NULL;
  17. struct tnode __rcu **cptr;
  18. - int max_work;
  19. + int max_work = MAX_WORK;
  20. pr_debug("In tnode_resize %p inflate_threshold=%d threshold=%d\n",
  21. tn, inflate_threshold, halve_threshold);
  22. @@ -775,8 +775,7 @@ static void resize(struct trie *t, struc
  23. /* Double as long as the resulting node has a number of
  24. * nonempty nodes that are above the threshold.
  25. */
  26. - max_work = MAX_WORK;
  27. - while (should_inflate(tp, tn) && max_work--) {
  28. + while (should_inflate(tp, tn) && max_work) {
  29. if (inflate(t, tn)) {
  30. #ifdef CONFIG_IP_FIB_TRIE_STATS
  31. this_cpu_inc(t->stats->resize_node_skipped);
  32. @@ -784,6 +783,7 @@ static void resize(struct trie *t, struc
  33. break;
  34. }
  35. + max_work--;
  36. tn = rtnl_dereference(*cptr);
  37. }
  38. @@ -794,8 +794,7 @@ static void resize(struct trie *t, struc
  39. /* Halve as long as the number of empty children in this
  40. * node is above threshold.
  41. */
  42. - max_work = MAX_WORK;
  43. - while (should_halve(tp, tn) && max_work--) {
  44. + while (should_halve(tp, tn) && max_work) {
  45. if (halve(t, tn)) {
  46. #ifdef CONFIG_IP_FIB_TRIE_STATS
  47. this_cpu_inc(t->stats->resize_node_skipped);
  48. @@ -803,6 +802,7 @@ static void resize(struct trie *t, struc
  49. break;
  50. }
  51. + max_work--;
  52. tn = rtnl_dereference(*cptr);
  53. }