summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Cahill <michael.cahill@wiredtiger.com>2011-11-03 23:48:27 +1100
committerMichael Cahill <michael.cahill@wiredtiger.com>2011-11-03 23:48:27 +1100
commit455cfc40f7239a3e93148704033572229f03f2c1 (patch)
tree71d4c307182b6e4782130624312af4e1b38c96ca
parent7eaba73eac3283c92b2c757efcd5c907d72301e0 (diff)
downloadmongo-455cfc40f7239a3e93148704033572229f03f2c1.tar.gz
Remove the workQ -- have application threads notify the read and eviction servers directly.
-rw-r--r--build_posix/aclocal/options.m410
-rw-r--r--src/api/api_conn.c12
-rw-r--r--src/api/api_session.c8
-rw-r--r--src/btree/bt_evict.c26
-rw-r--r--src/btree/bt_handle.c10
-rw-r--r--src/btree/bt_read.c37
-rw-r--r--src/conn/conn_handle.c17
-rw-r--r--src/conn/conn_open.c4
-rw-r--r--src/conn/workq.c4
-rw-r--r--src/include/api.h2
-rw-r--r--src/include/cache.h10
-rw-r--r--src/include/mutex.h32
-rw-r--r--src/os_posix/os_mtx.c15
-rw-r--r--src/os_posix/os_open.c12
-rw-r--r--src/os_posix/os_remove.c4
-rw-r--r--src/support/global.c4
-rw-r--r--src/support/serial.c34
17 files changed, 137 insertions, 104 deletions
diff --git a/build_posix/aclocal/options.m4 b/build_posix/aclocal/options.m4
index 74e37f56e56..bb4ba217055 100644
--- a/build_posix/aclocal/options.m4
+++ b/build_posix/aclocal/options.m4
@@ -72,6 +72,16 @@ no) db_cv_enable_verbose=no;;
esac
AC_MSG_RESULT($db_cv_enable_verbose)
+AH_TEMPLATE(HAVE_WORKQ, [Define to 1 to enable the workQ thread.])
+AC_MSG_CHECKING(if --enable-workq option specified)
+AC_ARG_ENABLE(workq,
+ [AC_HELP_STRING([--enable-workq],
+ [Configure the workQ thread.])], r=$enableval, r=no)
+case "$r" in
+yes) AC_DEFINE(HAVE_WORKQ);;
+esac
+AC_MSG_RESULT($r)
+
AC_MSG_CHECKING(if --with-spinlock option specified)
AH_TEMPLATE(SPINLOCK_TYPE, [Spinlock type from mutex.h.])
AC_ARG_WITH(spinlock,
diff --git a/src/api/api_conn.c b/src/api/api_conn.c
index 568ebf1e583..ee8d33a9b99 100644
--- a/src/api/api_conn.c
+++ b/src/api/api_conn.c
@@ -70,9 +70,9 @@ __conn_load_extension(
WT_ERR(entry(&session->iface, &__api, config));
/* Link onto the environment's list of open libraries. */
- __wt_lock(session, conn->mtx);
+ __wt_spin_lock(session, &conn->spinlock);
TAILQ_INSERT_TAIL(&conn->dlhqh, dlh, q);
- __wt_unlock(session, conn->mtx);
+ __wt_spin_unlock(session, &conn->spinlock);
if (0) {
err: if (dlh != NULL)
@@ -130,9 +130,9 @@ __conn_add_collator(WT_CONNECTION *wt_conn,
WT_ERR(__wt_strdup(session, name, &ncoll->name));
ncoll->collator = collator;
- __wt_lock(session, conn->mtx);
+ __wt_spin_lock(session, &conn->spinlock);
TAILQ_INSERT_TAIL(&conn->collqh, ncoll, q);
- __wt_unlock(session, conn->mtx);
+ __wt_spin_unlock(session, &conn->spinlock);
ncoll = NULL;
err: API_END(session);
__wt_free(session, ncoll);
@@ -164,9 +164,9 @@ __conn_add_compressor(WT_CONNECTION *wt_conn,
WT_ERR(__wt_strdup(session, name, &ncomp->name));
ncomp->compressor = compressor;
- __wt_lock(session, conn->mtx);
+ __wt_spin_lock(session, &conn->spinlock);
TAILQ_INSERT_TAIL(&conn->compqh, ncomp, q);
- __wt_unlock(session, conn->mtx);
+ __wt_spin_unlock(session, &conn->spinlock);
ncomp = NULL;
err: API_END(session);
__wt_free(session, ncomp);
diff --git a/src/api/api_session.c b/src/api/api_session.c
index bafde4fceee..f63df92a469 100644
--- a/src/api/api_session.c
+++ b/src/api/api_session.c
@@ -43,7 +43,7 @@ __session_close(WT_SESSION *wt_session, const char *config)
WT_TRET(__wt_schema_close_tables(session));
- __wt_lock(session, conn->mtx);
+ __wt_spin_lock(session, &conn->spinlock);
/* Unpin the current session buffer. */
if (session->sb != NULL)
__wt_sb_decrement(session, session->sb);
@@ -80,7 +80,7 @@ __session_close(WT_SESSION *wt_session, const char *config)
WT_PUBLISH(session->iface.connection, NULL);
session = &conn->default_session;
- __wt_unlock(session, conn->mtx);
+ __wt_spin_unlock(session, &conn->spinlock);
err: API_END(session);
return (ret);
@@ -424,7 +424,7 @@ __wt_open_session(WT_CONNECTION_IMPL *conn, int internal,
session = &conn->default_session;
session_ret = NULL;
- __wt_lock(session, conn->mtx);
+ __wt_spin_lock(session, &conn->spinlock);
/* Check to see if there's an available session slot. */
if (conn->session_cnt == conn->session_size - 1) {
@@ -479,6 +479,6 @@ __wt_open_session(WT_CONNECTION_IMPL *conn, int internal,
STATIC_ASSERT(offsetof(WT_CONNECTION_IMPL, iface) == 0);
*sessionp = session_ret;
-err: __wt_unlock(session, conn->mtx);
+err: __wt_spin_unlock(session, &conn->spinlock);
return (ret);
}
diff --git a/src/btree/bt_evict.c b/src/btree/bt_evict.c
index 151bb48f8d6..e52cd726fb9 100644
--- a/src/btree/bt_evict.c
+++ b/src/btree/bt_evict.c
@@ -104,10 +104,6 @@ __wt_workq_evict_server(WT_CONNECTION_IMPL *conn, int force)
cache = conn->cache;
session = &conn->default_session;
- /* If the eviction server is running, there's nothing to do. */
- if (cache->evict_pending)
- return;
-
/*
* If we're locking out reads, or over our cache limit, or forcing the
* issue (when closing the environment), run the eviction server.
@@ -126,7 +122,6 @@ __wt_workq_evict_server(WT_CONNECTION_IMPL *conn, int force)
bytes_inuse <= bytes_max ? "<=" : ">",
bytes_max / WT_MEGABYTE);
- cache->evict_pending = 1;
__wt_unlock(session, cache->mtx_evict);
}
@@ -143,8 +138,7 @@ __wt_workq_evict_server_exit(WT_CONNECTION_IMPL *conn)
cache = conn->cache;
session = &conn->default_session;
- if (!cache->evict_pending)
- __wt_unlock(session, cache->mtx_evict);
+ __wt_unlock(session, cache->mtx_evict);
}
/*
@@ -201,7 +195,6 @@ __wt_cache_evict_server(void *arg)
while (F_ISSET(conn, WT_SERVER_RUN)) {
WT_VERBOSE(session, EVICTSERVER, "eviction server sleeping");
__wt_lock(session, cache->mtx_evict);
- cache->evict_pending = 0;
if (!F_ISSET(conn, WT_SERVER_RUN))
break;
WT_VERBOSE(session, EVICTSERVER, "eviction server waking");
@@ -281,8 +274,19 @@ __evict_worker(WT_SESSION_IMPL *session)
bytes_inuse = __wt_cache_bytes_inuse(cache);
bytes_max = WT_STAT(conn->stats, cache_bytes_max);
if (cache->read_lockout) {
- if (bytes_inuse <= bytes_max - (bytes_max / 20))
+ if (bytes_inuse <= bytes_max - (bytes_max / 20)) {
+#ifndef HAVE_WORKQ
+ /*
+ * If there is no workQ and we have freed
+ * enough space to unlock reads, ping the read
+ * server. If there is a workQ, it will wake
+ * up the read server next time around its
+ * loop.
+ */
+ __wt_workq_read_server(conn, 0);
+#endif
break;
+ }
} else if (bytes_inuse < bytes_max)
break;
@@ -552,7 +556,7 @@ __evict_walk(WT_SESSION_IMPL *session)
* it's not that slow.
*/
ret = 0;
- __wt_lock(session, conn->mtx);
+ __wt_spin_lock(session, &conn->spinlock);
elem = WT_EVICT_WALK_BASE + (conn->btqcnt * WT_EVICT_WALK_PER_TABLE);
if (elem > cache->evict_entries) {
@@ -578,7 +582,7 @@ __evict_walk(WT_SESSION_IMPL *session)
goto err;
}
-err: __wt_unlock(session, conn->mtx);
+err: __wt_spin_unlock(session, &conn->spinlock);
return (ret);
}
diff --git a/src/btree/bt_handle.c b/src/btree/bt_handle.c
index fb994de4adc..80089902cef 100644
--- a/src/btree/bt_handle.c
+++ b/src/btree/bt_handle.c
@@ -71,7 +71,7 @@ __wt_btree_open(WT_SESSION_IMPL *session,
/* Increment the reference count if we already have the btree open. */
matched = 0;
- __wt_lock(session, conn->mtx);
+ __wt_spin_lock(session, &conn->spinlock);
TAILQ_FOREACH(btree, &conn->btqh, q) {
if (strcmp(filename, btree->filename) == 0) {
++btree->refcnt;
@@ -81,7 +81,7 @@ __wt_btree_open(WT_SESSION_IMPL *session,
}
}
if (matched) {
- __wt_unlock(session, conn->mtx);
+ __wt_spin_unlock(session, &conn->spinlock);
/* Check that the handle is open. */
__wt_readlock(session, btree->rwlock);
@@ -117,7 +117,7 @@ __wt_btree_open(WT_SESSION_IMPL *session,
TAILQ_INSERT_TAIL(&conn->btqh, btree, q);
++conn->btqcnt;
}
- __wt_unlock(session, conn->mtx);
+ __wt_spin_unlock(session, &conn->spinlock);
if (ret != 0)
return (ret);
@@ -461,13 +461,13 @@ __wt_btree_close(WT_SESSION_IMPL *session)
ret = 0;
/* Remove from the connection's list. */
- __wt_lock(session, conn->mtx);
+ __wt_spin_lock(session, &conn->spinlock);
inuse = (--btree->refcnt > 0);
if (!inuse) {
TAILQ_REMOVE(&conn->btqh, btree, q);
--conn->btqcnt;
}
- __wt_unlock(session, conn->mtx);
+ __wt_spin_unlock(session, &conn->spinlock);
if (inuse)
return (0);
diff --git a/src/btree/bt_read.c b/src/btree/bt_read.c
index b20ae9d9180..fe9c74efcb1 100644
--- a/src/btree/bt_read.c
+++ b/src/btree/bt_read.c
@@ -69,10 +69,8 @@ __wt_workq_read_server(WT_CONNECTION_IMPL *conn, int force)
*/
bytes_inuse = __wt_cache_bytes_inuse(cache);
bytes_max = WT_STAT(conn->stats, cache_bytes_max);
- if (cache->read_lockout) {
- if (bytes_inuse <= bytes_max - (bytes_max / 20))
- cache->read_lockout = 0;
- } else if (bytes_inuse > bytes_max + (bytes_max / 10)) {
+ if (!cache->read_lockout &&
+ bytes_inuse > bytes_max + (bytes_max / 10)) {
WT_VERBOSE(session, READSERVER,
"workQ locks out reads: "
"bytes-inuse %" PRIu64 " of bytes-max %" PRIu64,
@@ -80,19 +78,30 @@ __wt_workq_read_server(WT_CONNECTION_IMPL *conn, int force)
cache->read_lockout = 1;
}
- /* If the cache read server is running, there's nothing to do. */
- if (cache->read_pending)
- return;
-
+#ifdef HAVE_WORKQ
/*
- * If reads are locked out and we're not forcing the issue (that's when
- * closing the environment, or if there's a priority read waiting to be
- * handled), we're done.
+ * If there is a workQ thread, reads are locked out and we're not
+ * forcing the issue (that's when closing the environment, or if
+ * there's a priority read waiting to be handled), we're done.
*/
if (!force && cache->read_lockout)
return;
+#else
+ /*
+ * Wait for eviction to free some space: there is no workQ to wake us
+ * up later.
+ */
+ while (!force && cache->read_lockout) {
+ if (__wt_cache_bytes_inuse(cache) <=
+ bytes_max - (bytes_max / 20))
+ cache->read_lockout = 0;
+ else {
+ __wt_workq_evict_server(conn, 1);
+ __wt_yield();
+ }
+ }
+#endif
- cache->read_pending = 1;
__wt_unlock(session, cache->mtx_read);
}
@@ -109,8 +118,7 @@ __wt_workq_read_server_exit(WT_CONNECTION_IMPL *conn)
cache = conn->cache;
session = &conn->default_session;
- if (!cache->read_pending)
- __wt_unlock(session, cache->mtx_read);
+ __wt_unlock(session, cache->mtx_read);
}
/*
@@ -169,7 +177,6 @@ __wt_cache_read_server(void *arg)
while (F_ISSET(conn, WT_SERVER_RUN)) {
WT_VERBOSE(session, READSERVER, "read server sleeping");
__wt_lock(session, cache->mtx_read);
- cache->read_pending = 0;
if (!F_ISSET(conn, WT_SERVER_RUN))
break;
WT_VERBOSE(session, READSERVER, "read server waking");
diff --git a/src/conn/conn_handle.c b/src/conn/conn_handle.c
index 85b7f3e06a4..2cd9ef287b2 100644
--- a/src/conn/conn_handle.c
+++ b/src/conn/conn_handle.c
@@ -28,16 +28,12 @@ __wt_connection_init(WT_CONNECTION_IMPL *conn)
WT_RET(__wt_stat_alloc_connection_stats(session, &conn->stats));
/* workQ spinlock. */
- WT_SPINLOCK_INIT(&conn->workq_lock);
+ __wt_spin_init(session, &conn->workq_lock);
- /*
- * Connection mutex.
- *
- * !!!
- * Don't allocate the mutex until after we allocate statistics,
- * the lock functions update the statistics.
- */
- return (__wt_mtx_alloc(session, "WT_CONNECTION_IMPL", 0, &conn->mtx));
+ /* Connection spinlock. */
+ __wt_spin_init(session, &conn->spinlock);
+
+ return (0);
}
/*
@@ -66,9 +62,6 @@ __wt_connection_destroy(WT_CONNECTION_IMPL *conn)
if (conn->log_fh != NULL)
(void)__wt_close(session, conn->log_fh);
- if (conn->mtx != NULL)
- (void)__wt_mtx_destroy(session, conn->mtx);
-
/* Remove from the list of connections. */
__wt_lock(session, __wt_process.mtx);
TAILQ_REMOVE(&__wt_process.connqh, conn, q);
diff --git a/src/conn/conn_open.c b/src/conn/conn_open.c
index 4b9df735cc4..45bb98d3a8d 100644
--- a/src/conn/conn_open.c
+++ b/src/conn/conn_open.c
@@ -49,7 +49,9 @@ __wt_connection_open(WT_CONNECTION_IMPL *conn)
&conn->cache_evict_tid, __wt_cache_evict_server, conn));
WT_ERR(__wt_thread_create(
&conn->cache_read_tid, __wt_cache_read_server, conn));
+#ifdef HAVE_WORKQ
WT_ERR(__wt_thread_create(&conn->workq_tid, __wt_workq_srvr, conn));
+#endif
return (0);
@@ -104,6 +106,7 @@ __wt_connection_close(WT_CONNECTION_IMPL *conn)
__wt_workq_read_server_exit(conn);
WT_TRET(__wt_thread_join(conn->cache_read_tid));
+#ifdef HAVE_WORKW
/*
* Close down and wait for the workQ thread; this only happens after
* all other server threads have exited, as they may be waiting on a
@@ -111,6 +114,7 @@ __wt_connection_close(WT_CONNECTION_IMPL *conn)
*/
F_CLR(conn, WT_WORKQ_RUN);
WT_TRET(__wt_thread_join(conn->workq_tid));
+#endif
/* Discard the cache. */
__wt_cache_destroy(conn);
diff --git a/src/conn/workq.c b/src/conn/workq.c
index 0213fc590da..07378925515 100644
--- a/src/conn/workq.c
+++ b/src/conn/workq.c
@@ -7,6 +7,8 @@
#include "wt_internal.h"
+#ifdef HAVE_WORKQ
+
/*
* __wt_workq_srvr --
* Routine to process the WT_SESSION_IMPL work queue.
@@ -97,3 +99,5 @@ __wt_workq_srvr(void *arg)
}
return (NULL);
}
+
+#endif
diff --git a/src/include/api.h b/src/include/api.h
index 919b4d7b744..ea168133a32 100644
--- a/src/include/api.h
+++ b/src/include/api.h
@@ -146,7 +146,7 @@ struct __wt_connection_impl {
WT_SESSION_IMPL default_session;/* For operations without an
application-supplied session. */
- WT_MTX *mtx; /* Connection mutex */
+ WT_SPINLOCK spinlock; /* Connection spinlock */
/* Connection queue */
TAILQ_ENTRY(__wt_connection_impl) q;
diff --git a/src/include/cache.h b/src/include/cache.h
index 70f73360610..e610cab2aef 100644
--- a/src/include/cache.h
+++ b/src/include/cache.h
@@ -46,12 +46,7 @@ struct __wt_read_req {
* WiredTiger cache structure.
*/
struct __wt_cache {
- /*
- * The workQ thread sets evict_pending when it posts a message to
- * the cache thread, which clears it when the message is handled.
- */
WT_MTX *mtx_evict; /* Cache eviction server mutex */
- u_int volatile evict_pending; /* Message queued */
/*
* File sync can temporarily fail when a tree is active, that is, we may
@@ -68,12 +63,7 @@ struct __wt_cache {
WT_EVICT_REQ evict_request[20]; /* Eviction requests:
slot available if session is NULL */
- /*
- * The workQ thread sets read_pending when it posts a message to the
- * I/O thread, which clears it when the message is handled.
- */
WT_MTX *mtx_read; /* Cache read server mutex */
- u_int volatile read_pending; /* Message queued */
u_int volatile read_lockout; /* No reading until memory drains */
WT_READ_REQ read_request[40]; /* Read requests:
diff --git a/src/include/mutex.h b/src/include/mutex.h
index 66591d97e65..3942452545e 100644
--- a/src/include/mutex.h
+++ b/src/include/mutex.h
@@ -165,21 +165,29 @@ struct __wt_rwlock {
#define WT_SPINLOCK volatile int
-#define WT_SPINLOCK_INIT(t) do { \
- *(t) = 0; \
-} while (0)
+static inline void
+__wt_spin_init(WT_SESSION_IMPL *session, WT_SPINLOCK *t)
+{
+ WT_UNUSED(session);
+
+ *(t) = 0;
+}
static inline void
-__wt_spin_lock(WT_SPINLOCK *t)
+__wt_spin_lock(WT_SESSION_IMPL *session, WT_SPINLOCK *t)
{
+ WT_UNUSED(session);
+
while (__sync_lock_test_and_set(t, 1))
while (*t)
WT_PAUSE();
}
static inline void
-__wt_spin_unlock(WT_SPINLOCK *t)
+__wt_spin_unlock(WT_SESSION_IMPL *session, WT_SPINLOCK *t)
{
+ WT_UNUSED(session);
+
__sync_lock_release(t);
}
@@ -187,19 +195,25 @@ __wt_spin_unlock(WT_SPINLOCK *t)
#define WT_SPINLOCK pthread_mutex_t
-#define WT_SPINLOCK_INIT(t) do { \
+static inline void
+__wt_spin_init(WT_SESSION_IMPL *session, WT_SPINLOCK *t)
+{
+ WT_UNUSED(session);
+
(void)pthread_mutex_init(t, NULL); \
-} while (0)
+}
static inline void
-__wt_spin_lock(WT_SPINLOCK *t)
+__wt_spin_lock(WT_SESSION_IMPL *session, WT_SPINLOCK *t)
{
+ WT_UNUSED(session);
pthread_mutex_lock(t);
}
static inline void
-__wt_spin_unlock(WT_SPINLOCK *t)
+__wt_spin_unlock(WT_SESSION_IMPL *session, WT_SPINLOCK *t)
{
+ WT_UNUSED(session);
pthread_mutex_unlock(t);
}
diff --git a/src/os_posix/os_mtx.c b/src/os_posix/os_mtx.c
index 119a9305820..986fc742575 100644
--- a/src/os_posix/os_mtx.c
+++ b/src/os_posix/os_mtx.c
@@ -43,10 +43,7 @@ __wt_mtx_alloc(WT_SESSION_IMPL *session,
(void)pthread_condattr_destroy(&condattr);
mtx->name = name;
-
- /* If the normal state of the mutex is locked, lock it immediately. */
- if (is_locked)
- __wt_lock(session, mtx);
+ mtx->locked = is_locked;
*mtxp = mtx;
return (0);
@@ -78,7 +75,7 @@ __wt_lock(WT_SESSION_IMPL *session, WT_MTX *mtx)
* Check pthread_cond_wait() return for EINTR, ETIME and ETIMEDOUT,
* it's known to return these errors on some systems.
*/
- while (mtx->locked) {
+ while (mtx->locked > 0) {
ret = pthread_cond_wait(&mtx->cond, &mtx->mtx);
if (ret != 0 &&
ret != EINTR &&
@@ -91,7 +88,7 @@ __wt_lock(WT_SESSION_IMPL *session, WT_MTX *mtx)
}
}
- mtx->locked = 1;
+ ++mtx->locked;
if (session != NULL)
WT_CSTAT_INCR(session, mtx_lock);
@@ -121,10 +118,8 @@ __wt_unlock(WT_SESSION_IMPL *session, WT_MTX *mtx)
ret = 0;
WT_ERR(pthread_mutex_lock(&mtx->mtx));
- WT_ASSERT(session, mtx->locked);
- mtx->locked = 0;
- WT_ERR(pthread_cond_signal(&mtx->cond));
-
+ if (--mtx->locked == 0)
+ WT_ERR(pthread_cond_signal(&mtx->cond));
WT_ERR(pthread_mutex_unlock(&mtx->mtx));
return;
diff --git a/src/os_posix/os_open.c b/src/os_posix/os_open.c
index 5aff61bbd71..488d0c8073b 100644
--- a/src/os_posix/os_open.c
+++ b/src/os_posix/os_open.c
@@ -29,7 +29,7 @@ __wt_open(WT_SESSION_IMPL *session,
/* Increment the reference count if we already have the file open. */
matched = 0;
- __wt_lock(session, conn->mtx);
+ __wt_spin_lock(session, &conn->spinlock);
TAILQ_FOREACH(fh, &conn->fhqh, q) {
if (strcmp(name, fh->name) == 0) {
++fh->refcnt;
@@ -38,7 +38,7 @@ __wt_open(WT_SESSION_IMPL *session,
break;
}
}
- __wt_unlock(session, conn->mtx);
+ __wt_spin_unlock(session, &conn->spinlock);
if (matched)
return (0);
@@ -95,9 +95,9 @@ __wt_open(WT_SESSION_IMPL *session,
WT_ERR(__wt_filesize(session, fh, &fh->file_size));
/* Link onto the environment's list of files. */
- __wt_lock(session, conn->mtx);
+ __wt_spin_lock(session, &conn->spinlock);
TAILQ_INSERT_TAIL(&conn->fhqh, fh, q);
- __wt_unlock(session, conn->mtx);
+ __wt_spin_unlock(session, &conn->spinlock);
*fhp = fh;
@@ -131,9 +131,9 @@ __wt_close(WT_SESSION_IMPL *session, WT_FH *fh)
return (0);
/* Remove from the list and discard the memory. */
- __wt_lock(session, conn->mtx);
+ __wt_spin_lock(session, &conn->spinlock);
TAILQ_REMOVE(&conn->fhqh, fh, q);
- __wt_unlock(session, conn->mtx);
+ __wt_spin_unlock(session, &conn->spinlock);
if (close(fh->fd) != 0) {
__wt_err(session, errno, "%s", fh->name);
diff --git a/src/os_posix/os_remove.c b/src/os_posix/os_remove.c
index 320f2394879..65c6a6c98b9 100644
--- a/src/os_posix/os_remove.c
+++ b/src/os_posix/os_remove.c
@@ -25,12 +25,12 @@ __wt_remove(WT_SESSION_IMPL *session, const char *name)
WT_VERBOSE(session, FILEOPS, "fileops: %s: remove", name);
/* If the file is open, close/free it. */
- __wt_lock(session, conn->mtx);
+ __wt_spin_lock(session, &conn->spinlock);
TAILQ_FOREACH(fh, &conn->fhqh, q) {
if (strcmp(name, fh->name) == 0)
break;
}
- __wt_unlock(session, conn->mtx);
+ __wt_spin_unlock(session, &conn->spinlock);
/* This should be caught at a higher level. */
WT_ASSERT(session, fh == NULL);
diff --git a/src/support/global.c b/src/support/global.c
index a61ed719568..97accd34b35 100644
--- a/src/support/global.c
+++ b/src/support/global.c
@@ -17,8 +17,8 @@ __wt_pthread_once(void)
* Mutex allocation is the only thing we do that can fail (but, since
* it's the first mutex we ever create, it's the one that will fail).
*/
- __wt_pthread_once_failed =
- __wt_mtx_alloc(NULL, "WiredTiger process", 0, &__wt_process.mtx);
+ __wt_pthread_once_failed = __wt_mtx_alloc(
+ NULL, "WiredTiger process", 0, &__wt_process.mtx);
TAILQ_INIT(&__wt_process.connqh);
diff --git a/src/support/serial.c b/src/support/serial.c
index 9d61aec6edf..7571f73f849 100644
--- a/src/support/serial.c
+++ b/src/support/serial.c
@@ -38,17 +38,7 @@ __wt_session_serialize_func(WT_SESSION_IMPL *session,
session->wq_func = func;
session->wq_sleeping = op == WT_WORKQ_FUNC ? 0 : 1;
- /*
- * Functions are called directly (holding a spinlock), only
- * communication with other threads goes through serialization.
- */
- if (op == WT_WORKQ_FUNC) {
- __wt_spin_lock(&conn->workq_lock);
- func(session);
- __wt_spin_unlock(&conn->workq_lock);
- return (session->wq_ret);
- }
-
+#ifdef HAVE_WORKQ
/*
* Publish: there must be a barrier to ensure the structure fields are
* set before wq_state field change makes the entry visible to the workQ
@@ -72,6 +62,28 @@ __wt_session_serialize_func(WT_SESSION_IMPL *session,
WT_READ_BARRIER();
} else
__wt_lock(session, session->mtx);
+#else
+ /*
+ * Functions are called directly (holding a spinlock), only
+ * communication with other threads goes through serialization.
+ */
+ __wt_spin_lock(session, &conn->workq_lock);
+ func(session);
+ __wt_spin_unlock(session, &conn->workq_lock);
+
+ switch (op) {
+ case WT_WORKQ_EVICT:
+ __wt_workq_evict_server(conn, 1);
+ __wt_lock(session, session->mtx);
+ break;
+ case WT_WORKQ_READ:
+ __wt_workq_read_server(conn, 0);
+ __wt_lock(session, session->mtx);
+ break;
+ default:
+ break;
+ }
+#endif
return (session->wq_ret);
}