datapath: Allow the number of hash entries to exceed TBL_MAX_BUCKETS
authorSimon Horman <horms@verge.net.au>
Wed, 3 Aug 2011 02:19:47 +0000 (11:19 +0900)
committerJesse Gross <jesse@nicira.com>
Wed, 3 Aug 2011 04:45:20 +0000 (21:45 -0700)
* If the number of entries in a table exceeds
  the number of buckets that it has then
  an attempt will be made to resize the table.

* There is a limit of TBL_MAX_BUCKETS placed on
  the number of buckets of a table.

* If this limit is exceeded keep using the existing table.
  This allows a table to hold more than TBL_MAX_BUCKETS
  entries at the expense of increased hash collisions.

Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Jesse Gross <jesse@nicira.com>
datapath/datapath.c
datapath/tunnel.c

index a964c27f469e3618d854f47ff9da9068c40ea900..3ec5be4e3bf55b0c7a554c51788b6f6740acb59b 100644 (file)
@@ -629,11 +629,13 @@ static int expand_table(struct datapath *dp)
        struct tbl *new_table;
 
        new_table = tbl_expand(old_table);
-       if (IS_ERR(new_table))
-               return PTR_ERR(new_table);
-
-       rcu_assign_pointer(dp->table, new_table);
-       tbl_deferred_destroy(old_table, NULL);
+       if (IS_ERR(new_table)) {
+               if (PTR_ERR(new_table) != -ENOSPC)
+                       return PTR_ERR(new_table);
+       } else {
+               rcu_assign_pointer(dp->table, new_table);
+               tbl_deferred_destroy(old_table, NULL);
+       }
 
        return 0;
 }
index c2439f0e17c37e24806d9d8ae69b866cff7d8962..1ef81ab7893f08172d16df71861ad7bda1a7cb1f 100644 (file)
@@ -249,11 +249,13 @@ static int add_port(struct vport *vport)
                struct tbl *new_table;
 
                new_table = tbl_expand(cur_table);
-               if (IS_ERR(new_table))
-                       return PTR_ERR(new_table);
-
-               rcu_assign_pointer(port_table, new_table);
-               tbl_deferred_destroy(cur_table, NULL);
+               if (IS_ERR(new_table)) {
+                       if (PTR_ERR(new_table) != -ENOSPC)
+                               return PTR_ERR(new_table);
+               } else {
+                       rcu_assign_pointer(port_table, new_table);
+                       tbl_deferred_destroy(cur_table, NULL);
+               }
        }
 
        err = tbl_insert(rtnl_dereference(port_table), &tnl_vport->tbl_node,