From 2225a61798269d33f531d45dbffae2e2bbee8eda Mon Sep 17 00:00:00 2001
From: marko <>
Date: Fri, 20 Mar 2009 13:47:17 +0000
Subject: [PATCH] branches/zip: fil_init(): Add the parameter hash_size.

---
 ChangeLog         |  5 ++++
 fil/fil0fil.c     | 69 +++++++++++++++--------------------------------
 include/fil0fil.h |  1 +
 srv/srv0start.c   |  3 ++-
 4 files changed, 30 insertions(+), 48 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index f41d0859ca7..215e9d7916b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -9,6 +9,11 @@
 	* data/data0type.c, handler/ha_innodb.cc, include/ha_prototypes.h:
 	Declare innobase_get_at_most_n_mbchars() in ha_prototypes.h.
 
+2009-03-20	The InnoDB Team
+
+	* fil/fil0fil.h, fil/fil0fil.c, srv/srv0start.c:
+	Add the parameter hash_size to fil_init().
+
 2009-03-20	The InnoDB Team
 
 	* fil/fil0fil.c:
diff --git a/fil/fil0fil.c b/fil/fil0fil.c
index eebfdd979f3..aededfeb6e4 100644
--- a/fil/fil0fil.c
+++ b/fil/fil0fil.c
@@ -1456,64 +1456,39 @@ fil_check_adress_in_tablespace(
 	return(FALSE);
 }
 
-/********************************************************************
-Creates a the tablespace memory cache. */
-static
-fil_system_t*
-fil_system_create(
-/*==============*/
-				/* out, own: tablespace memory cache */
-	ulint	hash_size,	/* in: hash table size */
-	ulint	max_n_open)	/* in: maximum number of open files; must be
-				> 10 */
-{
-	fil_system_t*	system;
-
-	ut_a(hash_size > 0);
-	ut_a(max_n_open > 0);
-
-	system = mem_alloc(sizeof(fil_system_t));
-
-	mutex_create(&system->mutex, SYNC_ANY_LATCH);
-
-	system->spaces = hash_create(hash_size);
-	system->name_hash = hash_create(hash_size);
-
-	UT_LIST_INIT(system->LRU);
-
-	system->n_open = 0;
-	system->max_n_open = max_n_open;
-
-	system->modification_counter = 0;
-	system->max_assigned_id = 0;
-
-	system->tablespace_version = 0;
-
-	UT_LIST_INIT(system->unflushed_spaces);
-	UT_LIST_INIT(system->space_list);
-
-	return(system);
-}
-
 /********************************************************************
 Initializes the tablespace memory cache. */
 UNIV_INTERN
 void
 fil_init(
 /*=====*/
+	ulint	hash_size,	/* in: hash table size */
 	ulint	max_n_open)	/* in: max number of open files */
 {
-	ulint	hash_size;
-
 	ut_a(fil_system == NULL);
 
-	if (srv_file_per_table) {
-		hash_size = 50000;
-	} else {
-		hash_size = 5000;
-	}
+	ut_a(hash_size > 0);
+	ut_a(max_n_open > 0);
 
-	fil_system = fil_system_create(hash_size, max_n_open);
+	fil_system = mem_alloc(sizeof(fil_system_t));
+
+	mutex_create(&fil_system->mutex, SYNC_ANY_LATCH);
+
+	fil_system->spaces = hash_create(hash_size);
+	fil_system->name_hash = hash_create(hash_size);
+
+	UT_LIST_INIT(fil_system->LRU);
+
+	fil_system->n_open = 0;
+	fil_system->max_n_open = max_n_open;
+
+	fil_system->modification_counter = 0;
+	fil_system->max_assigned_id = 0;
+
+	fil_system->tablespace_version = 0;
+
+	UT_LIST_INIT(fil_system->unflushed_spaces);
+	UT_LIST_INIT(fil_system->space_list);
 }
 
 /***********************************************************************
diff --git a/include/fil0fil.h b/include/fil0fil.h
index 29dd4722b20..ca1f9d37224 100644
--- a/include/fil0fil.h
+++ b/include/fil0fil.h
@@ -263,6 +263,7 @@ UNIV_INTERN
 void
 fil_init(
 /*=====*/
+	ulint	hash_size,	/* in: hash table size */
 	ulint	max_n_open);	/* in: max number of open files */
 /***********************************************************************
 Opens all log files and system tablespace data files. They stay open until the
diff --git a/srv/srv0start.c b/srv/srv0start.c
index 39eb073f928..237ec230f9f 100644
--- a/srv/srv0start.c
+++ b/srv/srv0start.c
@@ -1273,7 +1273,8 @@ innobase_start_or_create_for_mysql(void)
 			    SRV_MAX_N_PENDING_SYNC_IOS);
 	}
 
-	fil_init(srv_max_n_open_files);
+	fil_init(srv_file_per_table ? 50000 : 5000,
+		 srv_max_n_open_files);
 
 	ret = buf_pool_init();