1 /* back-mdb.h - mdb back-end header file */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 2000-2015 The OpenLDAP Foundation.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted only as authorized by the OpenLDAP
12 * A copy of this license is available in the file LICENSE in the
13 * top-level directory of the distribution or, alternatively, at
14 * <http://www.OpenLDAP.org/license.html>.
26 #undef MDB_TOOL_IDL_CACHING /* currently no perf gain */
28 #define DN_BASE_PREFIX SLAP_INDEX_EQUALITY_PREFIX
29 #define DN_ONE_PREFIX '%'
30 #define DN_SUBTREE_PREFIX '@'
34 #define MDB_ID2ENTRY 2
37 /* The default search IDL stack cache depth */
38 #define DEFAULT_SEARCH_STACK_DEPTH 16
40 /* The minimum we can function with */
41 #define MINIMUM_SEARCH_STACK_DEPTH 8
43 #define MDB_INDICES 128
45 #define MDB_MAXADS 65536
47 /* Default to 10MB max */
48 #define DEFAULT_MAPSIZE (10*1048576)
50 /* Most users will never see this */
51 #define DEFAULT_RTXN_SIZE 10000
53 #define MDB_MONITOR_IDX
55 typedef struct mdb_monitor_t {
57 struct berval mdm_ndn;
66 /* DB_ENV parameters */
68 uint32_t mi_dbenv_flags;
73 size_t mi_maxentrysize;
75 slap_mask_t mi_defaultmask;
77 struct mdb_attrinfo **mi_attrs;
78 void *mi_search_stack;
79 int mi_search_stack_depth;
82 uint32_t mi_rtxn_size;
84 uint32_t mi_txn_cp_min;
85 uint32_t mi_txn_cp_kbyte;
86 struct re_s *mi_txn_cp_task;
87 struct re_s *mi_index_task;
89 mdb_monitor_t mi_monitor;
91 #ifdef MDB_MONITOR_IDX
92 ldap_pvt_thread_mutex_t mi_idx_mutex;
94 #endif /* MDB_MONITOR_IDX */
97 #define MDB_IS_OPEN 0x01
98 #define MDB_OPEN_INDEX 0x02
99 #define MDB_DEL_INDEX 0x08
100 #define MDB_RE_OPEN 0x10
101 #define MDB_NEED_UPGRADE 0x20
105 MDB_dbi mi_dbis[MDB_NDB];
106 AttributeDescription *mi_ads[MDB_MAXADS];
107 int mi_adxs[MDB_MAXADS];
110 #define mi_id2entry mi_dbis[MDB_ID2ENTRY]
111 #define mi_dn2id mi_dbis[MDB_DN2ID]
112 #define mi_ad2id mi_dbis[MDB_AD2ID]
114 typedef struct mdb_op_info {
120 #define MOI_READER 0x01
121 #define MOI_FREEIT 0x02
122 #define MOI_KEEPER 0x04
124 /* Copy an ID "src" to pointer "dst" in big-endian byte order */
125 #define MDB_ID2DISK( src, dst ) \
126 do { int i0; ID tmp; unsigned char *_p; \
127 tmp = (src); _p = (unsigned char *)(dst); \
128 for ( i0=sizeof(ID)-1; i0>=0; i0-- ) { \
129 _p[i0] = tmp & 0xff; tmp >>= 8; \
133 /* Copy a pointer "src" to a pointer "dst" from big-endian to native order */
134 #define MDB_DISK2ID( src, dst ) \
135 do { unsigned i0; ID tmp = 0; unsigned char *_p; \
136 _p = (unsigned char *)(src); \
137 for ( i0=0; i0<sizeof(ID); i0++ ) { \
138 tmp <<= 8; tmp |= *_p++; \
144 /* for the cache of attribute information (which are indexed, etc.) */
145 typedef struct mdb_attrinfo {
146 AttributeDescription *ai_desc; /* attribute description cn;lang-en */
147 slap_mask_t ai_indexmask; /* how the attr is indexed */
148 slap_mask_t ai_newmask; /* new settings to replace old mask */
149 #ifdef LDAP_COMP_MATCH
150 ComponentReference* ai_cr; /*component indexing*/
152 Avlnode *ai_root; /* for tools */
153 MDB_cursor *ai_cursor; /* for tools */
154 int ai_idx; /* position in AI array */
158 /* tool threaded indexer state */
159 typedef struct mdb_attrixinfo {
166 /* These flags must not clash with SLAP_INDEX flags or ops in slap.h! */
167 #define MDB_INDEX_DELETING 0x8000U /* index is being modified */
168 #define MDB_INDEX_UPDATE_OP 0x03 /* performing an index update */
170 /* For slapindex to record which attrs in an entry belong to which
173 typedef struct AttrList {
174 struct AttrList *next;
182 #if defined(__i386) || defined(__x86_64)
183 #define MISALIGNED_OK 1
185 #define ALIGNER (sizeof(size_t)-1)
188 typedef struct IndexRbody {
195 typedef struct IndexRec {
198 #define ir_ai iru.irb.ai
199 #define ir_attrs iru.irb.attrs
200 #define ir_tptr iru.irb.tptr
201 #define ir_i iru.irb.i
202 /* cache line alignment */
203 char pad[(sizeof(IndexRbody)+CACHELINE-1) & (!CACHELINE-1)];
207 #define MAXRDNS SLAP_LDAPDN_MAXLEN/4
209 #include "proto-mdb.h"
211 #endif /* _BACK_MDB_H_ */