summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKeith Bostic <keith.bostic@mongodb.com>2016-05-31 20:30:18 -0400
committerMichael Cahill <michael.cahill@mongodb.com>2016-06-01 10:30:18 +1000
commit7033ed47f3986edb08ec8c4933e6ef211e73b3c4 (patch)
tree6cdc57dd2b037f9f61848ba1eae74c214b406e6a /src
parentb89aaece7b2a58d183a0a2b33e20157ad7f02258 (diff)
downloadmongo-7033ed47f3986edb08ec8c4933e6ef211e73b3c4.tar.gz
WT-2674 simplify metadata file check (#2763)
Remove the need for a hash and name comparison to identify the metadata file, set a flag in the data handle when the file is opened. Move the code to insert the data handle into the connection list from the find function to the allocate function for clarity.
Diffstat (limited to 'src')
-rw-r--r--src/conn/conn_api.c1
-rw-r--r--src/conn/conn_dhandle.c21
-rw-r--r--src/include/connection.h1
-rw-r--r--src/include/dhandle.h5
-rw-r--r--src/include/extern.h1
-rw-r--r--src/include/meta.h3
-rw-r--r--src/meta/meta_table.c12
7 files changed, 17 insertions, 27 deletions
diff --git a/src/conn/conn_api.c b/src/conn/conn_api.c
index 279e3d4a8b5..dde3fb6930e 100644
--- a/src/conn/conn_api.c
+++ b/src/conn/conn_api.c
@@ -2330,7 +2330,6 @@ wiredtiger_open(const char *home, WT_EVENT_HANDLER *event_handler,
*/
WT_ERR(__wt_turtle_init(session));
- __wt_metadata_init(session);
WT_ERR(__wt_metadata_cursor(session, NULL));
/* Start the worker threads and run recovery. */
diff --git a/src/conn/conn_dhandle.c b/src/conn/conn_dhandle.c
index d8fd07b6007..4c2cf9a8dc2 100644
--- a/src/conn/conn_dhandle.c
+++ b/src/conn/conn_dhandle.c
@@ -39,6 +39,9 @@ __conn_dhandle_alloc(WT_SESSION_IMPL *session,
WT_BTREE *btree;
WT_DATA_HANDLE *dhandle;
WT_DECL_RET;
+ uint64_t bucket;
+
+ *dhandlep = NULL;
WT_RET(__wt_calloc_one(session, &dhandle));
@@ -57,6 +60,16 @@ __conn_dhandle_alloc(WT_SESSION_IMPL *session,
__wt_stat_dsrc_init(dhandle);
+ if (strcmp(uri, WT_METAFILE_URI) == 0)
+ F_SET(dhandle, WT_DHANDLE_IS_METADATA);
+
+ /*
+ * Prepend the handle to the connection list, assuming we're likely to
+ * need new files again soon, until they are cached by all sessions.
+ */
+ bucket = dhandle->name_hash % WT_HASH_ARRAY_SIZE;
+ WT_CONN_DHANDLE_INSERT(S2C(session), dhandle, bucket);
+
*dhandlep = dhandle;
return (0);
@@ -106,14 +119,6 @@ __wt_conn_dhandle_find(
WT_RET(__conn_dhandle_alloc(session, uri, checkpoint, &dhandle));
- /*
- * Prepend the handle to the connection list, assuming we're likely to
- * need new files again soon, until they are cached by all sessions.
- * Find the right hash bucket to insert into as well.
- */
- bucket = dhandle->name_hash % WT_HASH_ARRAY_SIZE;
- WT_CONN_DHANDLE_INSERT(conn, dhandle, bucket);
-
session->dhandle = dhandle;
return (0);
}
diff --git a/src/include/connection.h b/src/include/connection.h
index e6cff08f0ae..0e0c357279a 100644
--- a/src/include/connection.h
+++ b/src/include/connection.h
@@ -352,7 +352,6 @@ struct __wt_connection_impl {
uint32_t txn_logsync; /* Log sync configuration */
WT_SESSION_IMPL *meta_ckpt_session;/* Metadata checkpoint session */
- uint64_t meta_uri_hash; /* Metadata file name hash */
WT_SESSION_IMPL *sweep_session; /* Handle sweep session */
wt_thread_t sweep_tid; /* Handle sweep thread */
diff --git a/src/include/dhandle.h b/src/include/dhandle.h
index 8b313428d06..9a11594c893 100644
--- a/src/include/dhandle.h
+++ b/src/include/dhandle.h
@@ -82,7 +82,8 @@ struct __wt_data_handle {
#define WT_DHANDLE_DISCARD 0x02 /* Discard on release */
#define WT_DHANDLE_DISCARD_FORCE 0x04 /* Force discard on release */
#define WT_DHANDLE_EXCLUSIVE 0x08 /* Need exclusive access */
-#define WT_DHANDLE_LOCK_ONLY 0x10 /* Handle only used as a lock */
-#define WT_DHANDLE_OPEN 0x20 /* Handle is open */
+#define WT_DHANDLE_IS_METADATA 0x10 /* Metadata handle */
+#define WT_DHANDLE_LOCK_ONLY 0x20 /* Handle only used as a lock */
+#define WT_DHANDLE_OPEN 0x40 /* Handle is open */
uint32_t flags;
};
diff --git a/src/include/extern.h b/src/include/extern.h
index bb2e6ae47cc..4ca5c8461a0 100644
--- a/src/include/extern.h
+++ b/src/include/extern.h
@@ -461,7 +461,6 @@ extern int __wt_ext_metadata_search(WT_EXTENSION_API *wt_api, WT_SESSION *wt_ses
extern int __wt_ext_metadata_update(WT_EXTENSION_API *wt_api, WT_SESSION *wt_session, const char *key, const char *value);
extern int __wt_metadata_get_ckptlist( WT_SESSION *session, const char *name, WT_CKPT **ckptbasep);
extern void __wt_metadata_free_ckptlist(WT_SESSION *session, WT_CKPT *ckptbase);
-extern void __wt_metadata_init(WT_SESSION_IMPL *session);
extern int __wt_metadata_cursor_open( WT_SESSION_IMPL *session, const char *config, WT_CURSOR **cursorp);
extern int __wt_metadata_cursor(WT_SESSION_IMPL *session, WT_CURSOR **cursorp);
extern int __wt_metadata_cursor_release(WT_SESSION_IMPL *session, WT_CURSOR **cursorp);
diff --git a/src/include/meta.h b/src/include/meta.h
index ba4149979ef..63c79dbc72e 100644
--- a/src/include/meta.h
+++ b/src/include/meta.h
@@ -34,8 +34,7 @@
* when diagnostic is enabled.
*/
#define WT_IS_METADATA(session, dh) \
- ((dh)->name_hash == S2C(session)->meta_uri_hash && \
- strcmp((dh)->name, WT_METAFILE_URI) == 0)
+ F_ISSET((dh), WT_DHANDLE_IS_METADATA)
#define WT_METAFILE_ID 0 /* Metadata file ID */
#define WT_METADATA_VERSION "WiredTiger version" /* Version keys */
diff --git a/src/meta/meta_table.c b/src/meta/meta_table.c
index dd65f1a7ef9..38a2edd7219 100644
--- a/src/meta/meta_table.c
+++ b/src/meta/meta_table.c
@@ -9,18 +9,6 @@
#include "wt_internal.h"
/*
- * __wt_metadata_init --
- * Metadata initialization.
- */
-void
-__wt_metadata_init(WT_SESSION_IMPL *session)
-{
- /* We cache the metadata file's URI hash for fast detection. */
- S2C(session)->meta_uri_hash =
- __wt_hash_city64(WT_METAFILE_URI, strlen(WT_METAFILE_URI));
-}
-
-/*
* __metadata_turtle --
* Return if a key's value should be taken from the turtle file.
*/