From df7ddb6bf44a6ceec7f3974293fdc0669b68251f Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Thu, 5 Jul 2012 18:11:18 -0700 Subject: [PATCH] Add MDB_NOMETASYNC env option. Just a trial. This may not make sense if we decide to split the meta pages into their own separate file, to allow meta traffic to reside on a separate spindle. --- libraries/libmdb/mdb.c | 4 ++-- libraries/libmdb/mdb.h | 12 ++++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/libraries/libmdb/mdb.c b/libraries/libmdb/mdb.c index 729725dd92..c32057c8a1 100644 --- a/libraries/libmdb/mdb.c +++ b/libraries/libmdb/mdb.c @@ -3037,7 +3037,7 @@ mdb_env_open(MDB_env *env, const char *path, unsigned int flags, mode_t mode) } if ((rc = mdb_env_open2(env, flags)) == MDB_SUCCESS) { - if (flags & (MDB_RDONLY|MDB_NOSYNC)) { + if (flags & (MDB_RDONLY|MDB_NOSYNC|MDB_NOMETASYNC)) { env->me_mfd = env->me_fd; } else { /* synchronous fd for meta writes */ @@ -6096,7 +6096,7 @@ mdb_put(MDB_txn *txn, MDB_dbi dbi, * at runtime. Changing other flags requires closing the environment * and re-opening it with the new flags. */ -#define CHANGEABLE (MDB_NOSYNC) +#define CHANGEABLE (MDB_NOSYNC|MDB_NOMETASYNC) int mdb_env_set_flags(MDB_env *env, unsigned int flag, int onoff) { diff --git a/libraries/libmdb/mdb.h b/libraries/libmdb/mdb.h index bcf36659c4..587013f6f4 100644 --- a/libraries/libmdb/mdb.h +++ b/libraries/libmdb/mdb.h @@ -159,6 +159,8 @@ typedef void (MDB_rel_func)(MDB_val *item, void *oldptr, void *newptr, void *rel #define MDB_NOSYNC 0x10000 /** read only */ #define MDB_RDONLY 0x20000 + /** don't fsync metapage after commit */ +#define MDB_NOMETASYNC 0x40000 /** @} */ /** @defgroup mdb_open Database Flags @@ -334,6 +336,13 @@ int mdb_env_create(MDB_env **env); * at risk is governed by how often the system flushes dirty buffers to disk * and how often #mdb_env_sync() is called. This flag may be changed * at any time using #mdb_env_set_flags(). + *
  • #MDB_NOMETASYNC + * Don't perform a synchronous flush of the meta page after committing + * a transaction. This is similar to the #MDB_NOSYNC case, but safer + * because the transaction data is still flushed. The meta page for any + * transaction N will be flushed by the data flush of transaction N+1. + * In case of a system crash, the last committed transaction may be + * lost. This flag may be changed at any time using #mdb_env_set_flags(). *
  • #MDB_RDONLY * Open the environment in read-only mode. No write operations will be allowed. * @@ -392,8 +401,7 @@ void mdb_env_close(MDB_env *env); /** @brief Set environment flags. * * This may be used to set some flags that weren't already set during - * #mdb_env_open(), or to unset these flags. Currently only the - * #MDB_NOSYNC flag setting may be changed with this function. + * #mdb_env_open(), or to unset these flags. * @param[in] env An environment handle returned by #mdb_env_create() * @param[in] flags The flags to change, bitwise OR'ed together * @param[in] onoff A non-zero value sets the flags, zero clears them. -- 2.39.5