ldb: Rework index_transaction_cache_size to allow caller to specify a larger size
authorGary Lockyer <gary@catalyst.net.nz>
Thu, 4 Jul 2019 04:49:29 +0000 (16:49 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 4 Jul 2019 10:02:23 +0000 (10:02 +0000)
The previous code would override the caller with the DB size
estimate rather than allowing the caller to force the bigger size.

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
lib/ldb/ldb_key_value/ldb_kv_index.c

index 4d2ad3b677bf36da6f4892a4906950748262f09c..ef275b2801331c4b05ad00ea533e70c4199f79f9 100644 (file)
@@ -3650,12 +3650,18 @@ int ldb_kv_reindex(struct ldb_module *module)
        }
 
        /*
-        * Calculate the size of the index cache that we'll need for
-        * the re-index
+        * Calculate the size of the index cache needed for
+        * the re-index. If specified always use the
+        * ldb_kv->index_transaction_cache_size otherwise use the maximum
+        * of the size estimate or the DEFAULT_INDEX_CACHE_SIZE
         */
-       index_cache_size = ldb_kv->kv_ops->get_size(ldb_kv);
-       if (index_cache_size < DEFAULT_INDEX_CACHE_SIZE) {
-               index_cache_size = DEFAULT_INDEX_CACHE_SIZE;
+       if (ldb_kv->index_transaction_cache_size > 0) {
+               index_cache_size = ldb_kv->index_transaction_cache_size;
+       } else {
+               index_cache_size = ldb_kv->kv_ops->get_size(ldb_kv);
+               if (index_cache_size < DEFAULT_INDEX_CACHE_SIZE) {
+                       index_cache_size = DEFAULT_INDEX_CACHE_SIZE;
+               }
        }
 
        /*