1 /* back-bdb.h - bdb back-end header file */
4 * Copyright 2000-2002 The OpenLDAP Foundation, All Rights Reserved.
5 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
18 #define BDB_IDL_MULTI 1
19 /* #define BDB_HIER 1 */
21 #define DN_BASE_PREFIX SLAP_INDEX_EQUALITY_PREFIX
22 #define DN_ONE_PREFIX '%'
23 #define DN_SUBTREE_PREFIX '@'
25 #define DBTzero(t) (memset((t), 0, sizeof(DBT)))
26 #define DBT2bv(t,bv) ((bv)->bv_val = (t)->data, \
27 (bv)->bv_len = (t)->size)
28 #define bv2DBT(bv,t) ((t)->data = (bv)->bv_val, \
29 (t)->size = (bv)->bv_len )
31 #define DEFAULT_MODE 0600
33 #define BDB_TXN_RETRIES 16
36 #define BDB_DBENV_HOME LDAP_RUNDIR LDAP_DIRSEP "openldap-hdb"
38 #define BDB_DBENV_HOME LDAP_RUNDIR LDAP_DIRSEP "openldap-bdb"
42 #define BDB_TMP_SUBDIR LDAP_DIRSEP "tmp"
43 #define BDB_LG_SUBDIR LDAP_DIRSEP "log"
44 #define BDB_DATA_SUBDIR LDAP_DIRSEP "data"
47 #define BDB_SUFFIX ".bdb"
48 #define BDB_ID2ENTRY 0
50 #define BDB_ID2PARENT 1
56 /* The bdb on-disk entry format is pretty space-inefficient. Average
57 * sized user entries are 3-4K each. You need at least two entries to
58 * fit into a single database page, more is better. 64K is BDB's
59 * upper bound. The same issues arise with IDLs in the index databases,
60 * but it's nearly impossible to avoid overflows there.
62 * When using BDB_IDL_MULTI, the IDL size is no longer an issue. Smaller
63 * pages are better for concurrency.
65 #ifndef BDB_ID2ENTRY_PAGESIZE
66 #define BDB_ID2ENTRY_PAGESIZE 16384
71 #define BDB_PAGESIZE 4096 /* BDB's original default */
73 #define BDB_PAGESIZE 16384
77 #define DEFAULT_CACHE_SIZE 1000
79 /* for the in-core cache of entries */
80 typedef struct bdb_cache {
85 Entry *c_lruhead; /* lru - add accessed entries here */
86 Entry *c_lrutail; /* lru - rem lru entries from here */
87 ldap_pvt_thread_mutex_t c_mutex;
90 #define CACHE_READ_LOCK 0
91 #define CACHE_WRITE_LOCK 1
93 #define BDB_INDICES 128
103 /* DB_ENV parameters */
104 /* The DB_ENV can be tuned via DB_CONFIG */
106 u_int32_t bi_dbenv_xflags; /* extra flags */
110 struct bdb_db_info **bi_databases;
111 ldap_pvt_thread_mutex_t bi_database_mutex;
112 int bi_db_opflags; /* db-specific flags */
114 slap_mask_t bi_defaultmask;
119 ldap_pvt_thread_rdwr_t bi_tree_rdwr;
125 u_int32_t bi_txn_cp_min;
126 u_int32_t bi_txn_cp_kbyte;
130 int bi_lock_detect_seconds;
131 ldap_pvt_thread_t bi_lock_detect_tid;
135 ldap_pvt_thread_mutex_t bi_lastid_mutex;
138 #define bi_id2entry bi_databases[BDB_ID2ENTRY]
140 #define bi_id2parent bi_databases[BDB_ID2PARENT]
142 #define bi_dn2id bi_databases[BDB_DN2ID]
151 #if DB_VERSION_MAJOR < 4
152 #define LOCK_DETECT(env,f,t,a) lock_detect(env, f, t, a)
153 #define LOCK_GET(env,i,f,o,m,l) lock_get(env, i, f, o, m, l)
154 #define TXN_CHECKPOINT(env,k,m,f) txn_checkpoint(env, k, m, f)
155 #define TXN_BEGIN(env,p,t,f) txn_begin((env), p, t, f)
156 #define TXN_PREPARE(txn,gid) txn_prepare((txn), (gid))
157 #define TXN_COMMIT(txn,f) txn_commit((txn), (f))
158 #define TXN_ABORT(txn) txn_abort((txn))
159 #define TXN_ID(txn) txn_id(txn)
161 #define LOCK_DETECT(env,f,t,a) (env)->lock_detect(env, f, t, a)
162 #define LOCK_GET(env,i,f,o,m,l) (env)->lock_get(env, i, f, o, m, l)
163 #define TXN_CHECKPOINT(env,k,m,f) (env)->txn_checkpoint(env, k, m, f)
164 #define TXN_BEGIN(env,p,t,f) (env)->txn_begin((env), p, t, f)
165 #define TXN_PREPARE(txn,g) (txn)->prepare((txn), (g))
166 #define TXN_COMMIT(txn,f) (txn)->commit((txn), (f))
167 #define TXN_ABORT(txn) (txn)->abort((txn))
168 #define TXN_ID(txn) (txn)->id(txn)
173 #include "proto-bdb.h"
175 #endif /* _BACK_BDB_H_ */