1 /* back-mdb.h - mdb back-end header file */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 2000-2013 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 broken */
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)
51 #define MDB_MONITOR_IDX
52 #endif /* LDAP_DEVEL */
54 typedef struct mdb_monitor_t {
56 struct berval mdm_ndn;
65 /* DB_ENV parameters */
66 /* The DB_ENV can be tuned via DB_CONFIG */
68 uint32_t mi_dbenv_flags;
74 slap_mask_t mi_defaultmask;
76 struct mdb_attrinfo **mi_attrs;
77 void *mi_search_stack;
78 int mi_search_stack_depth;
82 uint32_t mi_txn_cp_min;
83 uint32_t mi_txn_cp_kbyte;
84 struct re_s *mi_txn_cp_task;
85 struct re_s *mi_index_task;
87 mdb_monitor_t mi_monitor;
89 #ifdef MDB_MONITOR_IDX
90 ldap_pvt_thread_mutex_t mi_idx_mutex;
92 #endif /* MDB_MONITOR_IDX */
95 #define MDB_IS_OPEN 0x01
96 #define MDB_OPEN_INDEX 0x02
97 #define MDB_DEL_INDEX 0x08
98 #define MDB_RE_OPEN 0x10
99 #define MDB_NEED_UPGRADE 0x20
103 MDB_dbi mi_dbis[MDB_NDB];
104 AttributeDescription *mi_ads[MDB_MAXADS];
105 int mi_adxs[MDB_MAXADS];
108 #define mi_id2entry mi_dbis[MDB_ID2ENTRY]
109 #define mi_dn2id mi_dbis[MDB_DN2ID]
110 #define mi_ad2id mi_dbis[MDB_AD2ID]
112 typedef struct mdb_op_info {
118 #define MOI_READER 0x01
119 #define MOI_FREEIT 0x02
121 /* Copy an ID "src" to pointer "dst" in big-endian byte order */
122 #define MDB_ID2DISK( src, dst ) \
123 do { int i0; ID tmp; unsigned char *_p; \
124 tmp = (src); _p = (unsigned char *)(dst); \
125 for ( i0=sizeof(ID)-1; i0>=0; i0-- ) { \
126 _p[i0] = tmp & 0xff; tmp >>= 8; \
130 /* Copy a pointer "src" to a pointer "dst" from big-endian to native order */
131 #define MDB_DISK2ID( src, dst ) \
132 do { unsigned i0; ID tmp = 0; unsigned char *_p; \
133 _p = (unsigned char *)(src); \
134 for ( i0=0; i0<sizeof(ID); i0++ ) { \
135 tmp <<= 8; tmp |= *_p++; \
141 /* for the cache of attribute information (which are indexed, etc.) */
142 typedef struct mdb_attrinfo {
143 AttributeDescription *ai_desc; /* attribute description cn;lang-en */
144 slap_mask_t ai_indexmask; /* how the attr is indexed */
145 slap_mask_t ai_newmask; /* new settings to replace old mask */
146 #ifdef LDAP_COMP_MATCH
147 ComponentReference* ai_cr; /*component indexing*/
149 Avlnode *ai_root; /* for tools */
150 void *ai_flist; /* for tools */
151 void *ai_clist; /* for tools */
152 MDB_cursor *ai_cursor; /* for tools */
153 int ai_idx; /* position in AI array */
157 /* These flags must not clash with SLAP_INDEX flags or ops in slap.h! */
158 #define MDB_INDEX_DELETING 0x8000U /* index is being modified */
159 #define MDB_INDEX_UPDATE_OP 0x03 /* performing an index update */
161 /* For slapindex to record which attrs in an entry belong to which
164 typedef struct AttrList {
165 struct AttrList *next;
173 #if defined(__i386) || defined(__x86_64)
174 #define MISALIGNED_OK 1
176 #define ALIGNER (sizeof(size_t)-1)
179 typedef struct IndexRbody {
186 typedef struct IndexRec {
189 #define ir_ai iru.irb.ai
190 #define ir_attrs iru.irb.attrs
191 #define ir_tptr iru.irb.tptr
192 #define ir_i iru.irb.i
193 /* cache line alignment */
194 char pad[(sizeof(IndexRbody)+CACHELINE-1) & (!CACHELINE-1)];
198 #define MAXRDNS SLAP_LDAPDN_MAXLEN/4
200 #include "proto-mdb.h"
202 #endif /* _BACK_MDB_H_ */