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.
vmware
Howard Chu 13 years ago
parent 38560c2517
commit df7ddb6bf4
  1. 4
      libraries/libmdb/mdb.c
  2. 12
      libraries/libmdb/mdb.h

@ -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 ((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; env->me_mfd = env->me_fd;
} else { } else {
/* synchronous fd for meta writes */ /* 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 * at runtime. Changing other flags requires closing the environment
* and re-opening it with the new flags. * and re-opening it with the new flags.
*/ */
#define CHANGEABLE (MDB_NOSYNC) #define CHANGEABLE (MDB_NOSYNC|MDB_NOMETASYNC)
int int
mdb_env_set_flags(MDB_env *env, unsigned int flag, int onoff) mdb_env_set_flags(MDB_env *env, unsigned int flag, int onoff)
{ {

@ -159,6 +159,8 @@ typedef void (MDB_rel_func)(MDB_val *item, void *oldptr, void *newptr, void *rel
#define MDB_NOSYNC 0x10000 #define MDB_NOSYNC 0x10000
/** read only */ /** read only */
#define MDB_RDONLY 0x20000 #define MDB_RDONLY 0x20000
/** don't fsync metapage after commit */
#define MDB_NOMETASYNC 0x40000
/** @} */ /** @} */
/** @defgroup mdb_open Database Flags /** @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 * 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 * and how often #mdb_env_sync() is called. This flag may be changed
* at any time using #mdb_env_set_flags(). * at any time using #mdb_env_set_flags().
* <li>#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().
* <li>#MDB_RDONLY * <li>#MDB_RDONLY
* Open the environment in read-only mode. No write operations will be allowed. * Open the environment in read-only mode. No write operations will be allowed.
* </ul> * </ul>
@ -392,8 +401,7 @@ void mdb_env_close(MDB_env *env);
/** @brief Set environment flags. /** @brief Set environment flags.
* *
* This may be used to set some flags that weren't already set during * 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_env_open(), or to unset these flags.
* #MDB_NOSYNC flag setting may be changed with this function.
* @param[in] env An environment handle returned by #mdb_env_create() * @param[in] env An environment handle returned by #mdb_env_create()
* @param[in] flags The flags to change, bitwise OR'ed together * @param[in] flags The flags to change, bitwise OR'ed together
* @param[in] onoff A non-zero value sets the flags, zero clears them. * @param[in] onoff A non-zero value sets the flags, zero clears them.

Loading…
Cancel
Save