summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSusan LoVerso <sue@wiredtiger.com>2014-12-02 11:24:55 -0500
committerSusan LoVerso <sue@wiredtiger.com>2014-12-02 11:24:55 -0500
commit91e2e694ed558b66b6a9561e4dc5c74edaca7edf (patch)
tree263cf273d2ec4d2dde6164dd8e9153586cec6dbe /src
parente1c185dd64706dbbb650e3d5abf32cd79a8b1d7a (diff)
downloadmongo-91e2e694ed558b66b6a9561e4dc5c74edaca7edf.tar.gz
Make pre-alloc a boolean and convert connection log settings to flags.
Diffstat (limited to 'src')
-rw-r--r--src/btree/bt_cursor.c4
-rw-r--r--src/config/config_def.c10
-rw-r--r--src/conn/conn_ckpt.c3
-rw-r--r--src/conn/conn_log.c30
-rw-r--r--src/conn/conn_open.c2
-rw-r--r--src/cursor/cur_log.c4
-rw-r--r--src/include/connection.h6
-rw-r--r--src/include/wiredtiger.in5
-rw-r--r--src/log/log.c4
-rw-r--r--src/meta/meta_track.c2
-rw-r--r--src/txn/txn.c4
-rw-r--r--src/txn/txn_ckpt.c8
-rw-r--r--src/txn/txn_log.c3
13 files changed, 48 insertions, 37 deletions
diff --git a/src/btree/bt_cursor.c b/src/btree/bt_cursor.c
index 5b2d9b055b5..f189760c7dd 100644
--- a/src/btree/bt_cursor.c
+++ b/src/btree/bt_cursor.c
@@ -968,7 +968,7 @@ __wt_btcur_range_truncate(WT_CURSOR_BTREE *start, WT_CURSOR_BTREE *stop)
* the logging code) disabling writing of the in-memory remove records
* to disk.
*/
- if (S2C(session)->logging)
+ if (FLD_ISSET(S2C(session)->log_flags, WT_CONN_LOG_ENABLED))
WT_RET(__wt_txn_truncate_log(session, start, stop));
switch (btree->type) {
@@ -1000,7 +1000,7 @@ __wt_btcur_range_truncate(WT_CURSOR_BTREE *start, WT_CURSOR_BTREE *stop)
break;
}
-err: if (S2C(session)->logging)
+err: if (FLD_ISSET(S2C(session)->log_flags, WT_CONN_LOG_ENABLED))
WT_TRET(__wt_txn_truncate_end(session));
return (ret);
}
diff --git a/src/config/config_def.c b/src/config/config_def.c
index 18edb91d766..270f60e39af 100644
--- a/src/config/config_def.c
+++ b/src/config/config_def.c
@@ -298,7 +298,7 @@ static const WT_CONFIG_CHECK confchk_log_subconfigs[] = {
{ "enabled", "boolean", NULL, NULL },
{ "file_max", "int", "min=100KB,max=2GB", NULL },
{ "path", "string", NULL, NULL },
- { "prealloc", "int", "min=0", NULL },
+ { "prealloc", "boolean", NULL, NULL },
{ NULL, NULL, NULL, NULL }
};
@@ -655,7 +655,7 @@ static const WT_CONFIG_ENTRY config_entries[] = {
"eviction=(threads_max=1,threads_min=1),eviction_dirty_target=80,"
"eviction_target=80,eviction_trigger=95,exclusive=0,extensions=,"
"file_extend=,hazard_max=1000,log=(archive=,enabled=0,"
- "file_max=100MB,path=\"\",prealloc=2),lsm_manager=(merge=,"
+ "file_max=100MB,path=\"\",prealloc=),lsm_manager=(merge=,"
"worker_thread_max=4),lsm_merge=,mmap=,multiprocess=0,"
"session_max=100,shared_cache=(chunk=10MB,name=,reserve=0,"
"size=500MB),statistics=none,statistics_log=(on_close=0,"
@@ -672,7 +672,7 @@ static const WT_CONFIG_ENTRY config_entries[] = {
"eviction=(threads_max=1,threads_min=1),eviction_dirty_target=80,"
"eviction_target=80,eviction_trigger=95,exclusive=0,extensions=,"
"file_extend=,hazard_max=1000,log=(archive=,enabled=0,"
- "file_max=100MB,path=\"\",prealloc=2),lsm_manager=(merge=,"
+ "file_max=100MB,path=\"\",prealloc=),lsm_manager=(merge=,"
"worker_thread_max=4),lsm_merge=,mmap=,multiprocess=0,"
"session_max=100,shared_cache=(chunk=10MB,name=,reserve=0,"
"size=500MB),statistics=none,statistics_log=(on_close=0,"
@@ -689,7 +689,7 @@ static const WT_CONFIG_ENTRY config_entries[] = {
"direct_io=,error_prefix=,eviction=(threads_max=1,threads_min=1),"
"eviction_dirty_target=80,eviction_target=80,eviction_trigger=95,"
"extensions=,file_extend=,hazard_max=1000,log=(archive=,enabled=0"
- ",file_max=100MB,path=\"\",prealloc=2),lsm_manager=(merge=,"
+ ",file_max=100MB,path=\"\",prealloc=),lsm_manager=(merge=,"
"worker_thread_max=4),lsm_merge=,mmap=,multiprocess=0,"
"session_max=100,shared_cache=(chunk=10MB,name=,reserve=0,"
"size=500MB),statistics=none,statistics_log=(on_close=0,"
@@ -705,7 +705,7 @@ static const WT_CONFIG_ENTRY config_entries[] = {
"direct_io=,error_prefix=,eviction=(threads_max=1,threads_min=1),"
"eviction_dirty_target=80,eviction_target=80,eviction_trigger=95,"
"extensions=,file_extend=,hazard_max=1000,log=(archive=,enabled=0"
- ",file_max=100MB,path=\"\",prealloc=2),lsm_manager=(merge=,"
+ ",file_max=100MB,path=\"\",prealloc=),lsm_manager=(merge=,"
"worker_thread_max=4),lsm_merge=,mmap=,multiprocess=0,"
"session_max=100,shared_cache=(chunk=10MB,name=,reserve=0,"
"size=500MB),statistics=none,statistics_log=(on_close=0,"
diff --git a/src/conn/conn_ckpt.c b/src/conn/conn_ckpt.c
index e631752f1ea..40b103d6f24 100644
--- a/src/conn/conn_ckpt.c
+++ b/src/conn/conn_ckpt.c
@@ -35,7 +35,8 @@ __ckpt_server_config(WT_SESSION_IMPL *session, const char **cfg, int *startp)
conn->ckpt_logsize = (wt_off_t)cval.val;
__wt_log_written_reset(session);
if ((conn->ckpt_usecs == 0 && conn->ckpt_logsize == 0) ||
- (conn->ckpt_logsize && !conn->logging && conn->ckpt_usecs == 0)) {
+ (conn->ckpt_logsize && conn->ckpt_usecs == 0 &&
+ !FLD_ISSET(conn->log_flags, WT_CONN_LOG_ENABLED))) {
*startp = 0;
return (0);
}
diff --git a/src/conn/conn_log.c b/src/conn/conn_log.c
index 5b7390f69cb..5598538314c 100644
--- a/src/conn/conn_log.c
+++ b/src/conn/conn_log.c
@@ -57,7 +57,8 @@ __logmgr_config(WT_SESSION_IMPL *session, const char **cfg, int *runp)
return (0);
WT_RET(__wt_config_gets(session, cfg, "log.archive", &cval));
- conn->archive = cval.val != 0;
+ if (cval.val != 0)
+ FLD_SET(conn->log_flags, WT_CONN_LOG_ARCHIVE);
WT_RET(__wt_config_gets(session, cfg, "log.file_max", &cval));
conn->log_file_max = (wt_off_t)cval.val;
@@ -67,7 +68,14 @@ __logmgr_config(WT_SESSION_IMPL *session, const char **cfg, int *runp)
WT_RET(__wt_strndup(session, cval.str, cval.len, &conn->log_path));
WT_RET(__wt_config_gets(session, cfg, "log.prealloc", &cval));
- conn->log_prealloc = (uint32_t)cval.val;
+ /*
+ * If pre-allocation is configured, set the initial number to one.
+ * We'll adapt as load dictates.
+ */
+ if (cval.val != 0) {
+ FLD_SET(conn->log_flags, WT_CONN_LOG_PREALLOC);
+ conn->log_prealloc = 1;
+ }
WT_RET(__logmgr_sync_cfg(session, cfg));
return (0);
@@ -159,7 +167,7 @@ __log_prealloc_once(WT_SESSION_IMPL *session)
WT_CONNECTION_IMPL *conn;
WT_DECL_RET;
WT_LOG *log;
- u_int i, prepared, reccount;
+ u_int i, reccount;
char **recfiles;
conn = S2C(session);
@@ -174,10 +182,8 @@ __log_prealloc_once(WT_SESSION_IMPL *session)
WT_ERR(__wt_dirlist(session, conn->log_path,
WT_LOG_PREPNAME, WT_DIRLIST_INCLUDE,
&recfiles, &reccount));
- prepared = reccount;
__wt_log_files_free(session, recfiles, reccount);
recfiles = NULL;
- reccount = 0;
/*
* Adjust the number of files to pre-allocate if we find that
* the critical path had to allocate them since we last ran.
@@ -194,7 +200,7 @@ __log_prealloc_once(WT_SESSION_IMPL *session)
/*
* Allocate up to the maximum number that we just computed and detected.
*/
- for (i = prepared; i < (u_int)conn->log_prealloc; i++)
+ for (i = reccount; i < (u_int)conn->log_prealloc; i++)
WT_ERR(__wt_log_prealloc(session, ++log->prep_fileid));
if (0)
@@ -221,7 +227,8 @@ __wt_log_truncate_files(
WT_UNUSED(cfg);
conn = S2C(session);
log = conn->log;
- if (F_ISSET(conn, WT_CONN_SERVER_RUN) && conn->archive)
+ if (F_ISSET(conn, WT_CONN_SERVER_RUN) &&
+ FLD_ISSET(conn->log_flags, WT_CONN_LOG_ARCHIVE))
WT_RET_MSG(session, EINVAL,
"Attempt to archive manually while a server is running");
@@ -270,7 +277,7 @@ __log_server(void *arg)
/*
* Perform the archive.
*/
- if (conn->archive) {
+ if (FLD_ISSET(conn->log_flags, WT_CONN_LOG_ARCHIVE)) {
if (__wt_try_writelock(
session, log->log_archive_lock) == 0) {
locked = 1;
@@ -315,7 +322,7 @@ __wt_logmgr_create(WT_SESSION_IMPL *session, const char *cfg[])
if (!run)
return (0);
- conn->logging = 1;
+ FLD_SET(conn->log_flags, WT_CONN_LOG_ENABLED);
/*
* Logging is on, allocate the WT_LOG structure and open the log file.
*/
@@ -348,7 +355,8 @@ __wt_logmgr_create(WT_SESSION_IMPL *session, const char *cfg[])
WT_RET(__wt_log_slot_init(session));
/* If no log thread services are configured, we're done. */
- if (!conn->archive && conn->log_prealloc == 0)
+ if (!FLD_ISSET(conn->log_flags,
+ (WT_CONN_LOG_ARCHIVE | WT_CONN_LOG_PREALLOC)))
return (0);
/*
@@ -392,7 +400,7 @@ __wt_logmgr_destroy(WT_SESSION_IMPL *session)
conn = S2C(session);
- if (!conn->logging)
+ if (!FLD_ISSET(conn->log_flags, WT_CONN_LOG_ENABLED))
return (0);
if (conn->log_tid_set) {
WT_TRET(__wt_cond_signal(session, conn->log_cond));
diff --git a/src/conn/conn_open.c b/src/conn/conn_open.c
index b4450b62bf4..04de2a58422 100644
--- a/src/conn/conn_open.c
+++ b/src/conn/conn_open.c
@@ -124,7 +124,7 @@ __wt_connection_close(WT_CONNECTION_IMPL *conn)
* has completed then shut down the log manager (only after closing
* data handles).
*/
- if (conn->logging) {
+ if (FLD_ISSET(conn->log_flags, WT_CONN_LOG_ENABLED)) {
WT_TRET(__wt_txn_checkpoint_log(
session, 1, WT_TXN_LOG_CKPT_STOP, NULL));
WT_TRET(__wt_logmgr_destroy(session));
diff --git a/src/cursor/cur_log.c b/src/cursor/cur_log.c
index 803d68e890c..d942ca6ea3b 100644
--- a/src/cursor/cur_log.c
+++ b/src/cursor/cur_log.c
@@ -284,7 +284,7 @@ __curlog_close(WT_CURSOR *cursor)
CURSOR_API_CALL(cursor, session, close, NULL);
cl = (WT_CURSOR_LOG *)cursor;
conn = S2C(session);
- WT_ASSERT(session, conn->logging);
+ WT_ASSERT(session, FLD_ISSET(conn->log_flags, WT_CONN_LOG_ENABLED));
log = conn->log;
WT_TRET(__wt_readunlock(session, log->log_archive_lock));
WT_TRET(__curlog_reset(cursor));
@@ -329,7 +329,7 @@ __wt_curlog_open(WT_SESSION_IMPL *session,
WT_STATIC_ASSERT(offsetof(WT_CURSOR_LOG, iface) == 0);
conn = S2C(session);
- if (!conn->logging)
+ if (!FLD_ISSET(conn->log_flags, WT_CONN_LOG_ENABLED))
WT_RET_MSG(session, EINVAL,
"Cannot open a log cursor without logging enabled");
diff --git a/src/include/connection.h b/src/include/connection.h
index cfba6d4300d..e1ff13ad691 100644
--- a/src/include/connection.h
+++ b/src/include/connection.h
@@ -247,8 +247,10 @@ struct __wt_connection_impl {
const char *stat_stamp; /* Statistics log entry timestamp */
long stat_usecs; /* Statistics log period */
- int logging; /* Global logging configuration */
- int archive; /* Global archive configuration */
+#define WT_CONN_LOG_ARCHIVE 0x01 /* Archive is enabled */
+#define WT_CONN_LOG_ENABLED 0x02 /* Logging is enabled */
+#define WT_CONN_LOG_PREALLOC 0x04 /* Pre-allocation is enabled */
+ uint32_t log_flags; /* Global logging configuration */
WT_CONDVAR *log_cond; /* Log archive wait mutex */
WT_SESSION_IMPL *log_session; /* Log archive session */
wt_thread_t log_tid; /* Log archive thread */
diff --git a/src/include/wiredtiger.in b/src/include/wiredtiger.in
index 2ea53272543..14ffcff408e 100644
--- a/src/include/wiredtiger.in
+++ b/src/include/wiredtiger.in
@@ -1890,9 +1890,8 @@ struct __wt_connection {
* which the log files are written. If the value is not an absolute path name\,
* the files are created relative to the database home., a string; default \c
* "".}
- * @config{&nbsp;&nbsp;&nbsp;&nbsp;prealloc, number of pre-allocated log
- * files. May increase if actual usage does not keep up., an integer greater
- * than or equal to 0; default \c 2.}
+ * @config{&nbsp;&nbsp;&nbsp;&nbsp;prealloc, pre-allocate log files., a
+ * boolean flag; default \c true.}
* @config{ ),,}
* @config{lsm_manager = (, configure database wide options for LSM tree
* management., a set of related configuration options defined below.}
diff --git a/src/log/log.c b/src/log/log.c
index 4bc03d150c4..885a63f56b0 100644
--- a/src/log/log.c
+++ b/src/log/log.c
@@ -38,7 +38,7 @@ __wt_log_written_reset(WT_SESSION_IMPL *session)
WT_LOG *log;
conn = S2C(session);
- if (!conn->logging)
+ if (!FLD_ISSET(conn->log_flags, WT_CONN_LOG_ENABLED))
return;
log = conn->log;
log->log_written = 0;
@@ -1498,7 +1498,7 @@ __wt_log_vprintf(WT_SESSION_IMPL *session, const char *fmt, va_list ap)
conn = S2C(session);
- if (!conn->logging)
+ if (!FLD_ISSET(conn->log_flags, WT_CONN_LOG_ENABLED))
return (0);
va_copy(ap_copy, ap);
diff --git a/src/meta/meta_track.c b/src/meta/meta_track.c
index 78455f90ab9..a240ee76cb8 100644
--- a/src/meta/meta_track.c
+++ b/src/meta/meta_track.c
@@ -221,7 +221,7 @@ __wt_meta_track_off(WT_SESSION_IMPL *session, int unroll)
* durability, checkpoint the metadata.
*/
if (!unroll && ret == 0 && session->metafile != NULL &&
- !S2C(session)->logging)
+ !FLD_ISSET(S2C(session)->log_flags, WT_CONN_LOG_ENABLED))
WT_WITH_BTREE(session, session->metafile,
ret = __wt_checkpoint(session, NULL));
diff --git a/src/txn/txn.c b/src/txn/txn.c
index 48cdc1c08be..f958361a905 100644
--- a/src/txn/txn.c
+++ b/src/txn/txn.c
@@ -357,8 +357,8 @@ __wt_txn_commit(WT_SESSION_IMPL *session, const char *cfg[])
(WT_SESSION *)session, txn->id, 1));
/* If we are logging, write a commit log record. */
- if (ret == 0 &&
- txn->mod_count > 0 && S2C(session)->logging &&
+ if (ret == 0 && txn->mod_count > 0 &&
+ FLD_ISSET(S2C(session)->log_flags, WT_CONN_LOG_ENABLED) &&
!F_ISSET(session, WT_SESSION_NO_LOGGING))
ret = __wt_txn_log_commit(session, cfg);
diff --git a/src/txn/txn_ckpt.c b/src/txn/txn_ckpt.c
index 9254692ea93..e149cdeaa15 100644
--- a/src/txn/txn_ckpt.c
+++ b/src/txn/txn_ckpt.c
@@ -376,7 +376,7 @@ __wt_txn_checkpoint(WT_SESSION_IMPL *session, const char *cfg[])
tracking = 1;
/* Tell logging that we are about to start a database checkpoint. */
- if (conn->logging && full)
+ if (FLD_ISSET(conn->log_flags, WT_CONN_LOG_ENABLED) && full)
WT_ERR(__wt_txn_checkpoint_log(
session, full, WT_TXN_LOG_CKPT_PREPARE, NULL));
@@ -392,7 +392,7 @@ __wt_txn_checkpoint(WT_SESSION_IMPL *session, const char *cfg[])
WT_ERR(__wt_txn_begin(session, txn_cfg));
/* Tell logging that we have started a database checkpoint. */
- if (conn->logging && full) {
+ if (FLD_ISSET(conn->log_flags, WT_CONN_LOG_ENABLED) && full) {
WT_ERR(__wt_txn_checkpoint_log(
session, full, WT_TXN_LOG_CKPT_START, NULL));
logging = 1;
@@ -877,7 +877,7 @@ __checkpoint_worker(
WT_FULL_BARRIER();
/* Tell logging that a file checkpoint is starting. */
- if (conn->logging)
+ if (FLD_ISSET(conn->log_flags, WT_CONN_LOG_ENABLED))
WT_ERR(__wt_txn_checkpoint_log(
session, 0, WT_TXN_LOG_CKPT_START, &ckptlsn));
@@ -914,7 +914,7 @@ fake: /* Update the object's metadata. */
}
/* Tell logging that the checkpoint is complete. */
- if (conn->logging)
+ if (FLD_ISSET(conn->log_flags, WT_CONN_LOG_ENABLED))
WT_ERR(__wt_txn_checkpoint_log(
session, 0, WT_TXN_LOG_CKPT_STOP, NULL));
diff --git a/src/txn/txn_log.c b/src/txn/txn_log.c
index 03a71056a9a..2ca0dfd0aee 100644
--- a/src/txn/txn_log.c
+++ b/src/txn/txn_log.c
@@ -138,7 +138,8 @@ __wt_txn_log_op(WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt)
WT_TXN *txn;
WT_TXN_OP *op;
- if (!S2C(session)->logging || F_ISSET(session, WT_SESSION_NO_LOGGING))
+ if (!FLD_ISSET(S2C(session)->log_flags, WT_CONN_LOG_ENABLED) ||
+ F_ISSET(session, WT_SESSION_NO_LOGGING))
return (0);
txn = &session->txn;