/* back-mdb.h - mdb back-end header file */
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software .
*
* Copyright 2000-2018 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* Public License.
*
* A copy of this license is available in the file LICENSE in the
* top-level directory of the distribution or, alternatively, at
* .
*/
#ifndef _BACK_MDB_H_
#define _BACK_MDB_H_
#include
#include "slap.h"
#include "lmdb.h"
LDAP_BEGIN_DECL
#undef MDB_TOOL_IDL_CACHING /* currently broken */
#define DN_BASE_PREFIX SLAP_INDEX_EQUALITY_PREFIX
#define DN_ONE_PREFIX '%'
#define DN_SUBTREE_PREFIX '@'
#define MDB_AD2ID 0
#define MDB_DN2ID 1
#define MDB_ID2ENTRY 2
#define MDB_NDB 3
/* The default search IDL stack cache depth */
#define DEFAULT_SEARCH_STACK_DEPTH 16
/* The minimum we can function with */
#define MINIMUM_SEARCH_STACK_DEPTH 8
#define MDB_INDICES 128
#define MDB_MAXADS 65536
/* Default to 10MB max */
#define DEFAULT_MAPSIZE (10*1048576)
/* Most users will never see this */
#define DEFAULT_RTXN_SIZE 10000
#ifdef LDAP_DEVEL
#define MDB_MONITOR_IDX
#endif /* LDAP_DEVEL */
typedef struct mdb_monitor_t {
void *mdm_cb;
struct berval mdm_ndn;
} mdb_monitor_t;
/* From ldap_rq.h */
struct re_s;
struct mdb_info {
MDB_env *mi_dbenv;
/* DB_ENV parameters */
/* The DB_ENV can be tuned via DB_CONFIG */
char *mi_dbenv_home;
uint32_t mi_dbenv_flags;
int mi_dbenv_mode;
size_t mi_mapsize;
ID mi_nextid;
slap_mask_t mi_defaultmask;
int mi_nattrs;
struct mdb_attrinfo **mi_attrs;
void *mi_search_stack;
int mi_search_stack_depth;
int mi_readers;
uint32_t mi_rtxn_size;
int mi_txn_cp;
uint32_t mi_txn_cp_min;
uint32_t mi_txn_cp_kbyte;
struct re_s *mi_txn_cp_task;
struct re_s *mi_index_task;
mdb_monitor_t mi_monitor;
#ifdef MDB_MONITOR_IDX
ldap_pvt_thread_mutex_t mi_idx_mutex;
Avlnode *mi_idx;
#endif /* MDB_MONITOR_IDX */
int mi_flags;
#define MDB_IS_OPEN 0x01
#define MDB_OPEN_INDEX 0x02
#define MDB_DEL_INDEX 0x08
#define MDB_RE_OPEN 0x10
#define MDB_NEED_UPGRADE 0x20
int mi_numads;
MDB_dbi mi_dbis[MDB_NDB];
AttributeDescription *mi_ads[MDB_MAXADS];
int mi_adxs[MDB_MAXADS];
};
#define mi_id2entry mi_dbis[MDB_ID2ENTRY]
#define mi_dn2id mi_dbis[MDB_DN2ID]
#define mi_ad2id mi_dbis[MDB_AD2ID]
typedef struct mdb_op_info {
OpExtra moi_oe;
MDB_txn* moi_txn;
int moi_ref;
char moi_flag;
} mdb_op_info;
#define MOI_READER 0x01
#define MOI_FREEIT 0x02
/* Copy an ID "src" to pointer "dst" in big-endian byte order */
#define MDB_ID2DISK( src, dst ) \
do { int i0; ID tmp; unsigned char *_p; \
tmp = (src); _p = (unsigned char *)(dst); \
for ( i0=sizeof(ID)-1; i0>=0; i0-- ) { \
_p[i0] = tmp & 0xff; tmp >>= 8; \
} \
} while(0)
/* Copy a pointer "src" to a pointer "dst" from big-endian to native order */
#define MDB_DISK2ID( src, dst ) \
do { unsigned i0; ID tmp = 0; unsigned char *_p; \
_p = (unsigned char *)(src); \
for ( i0=0; i0