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_FILTER_INDICES 1
19 #define BDB_IDL_MULTI 1
20 /* #define BDB_HIER 1 */
22 #define DN_BASE_PREFIX SLAP_INDEX_EQUALITY_PREFIX
23 #define DN_ONE_PREFIX '%'
24 #define DN_SUBTREE_PREFIX '@'
26 #define DBTzero(t) (memset((t), 0, sizeof(DBT)))
27 #define DBT2bv(t,bv) ((bv)->bv_val = (t)->data, \
28 (bv)->bv_len = (t)->size)
29 #define bv2DBT(bv,t) ((t)->data = (bv)->bv_val, \
30 (t)->size = (bv)->bv_len )
32 #define DEFAULT_MODE 0600
34 #define BDB_TXN_RETRIES 16
37 #define BDB_DBENV_HOME LDAP_RUNDIR LDAP_DIRSEP "openldap-hdb"
39 #define BDB_DBENV_HOME LDAP_RUNDIR LDAP_DIRSEP "openldap-bdb"
43 #define BDB_TMP_SUBDIR LDAP_DIRSEP "tmp"
44 #define BDB_LG_SUBDIR LDAP_DIRSEP "log"
45 #define BDB_DATA_SUBDIR LDAP_DIRSEP "data"
48 #define BDB_SUFFIX ".bdb"
49 #define BDB_ID2ENTRY 0
51 #define BDB_ID2PARENT 1
57 /* The bdb on-disk entry format is pretty space-inefficient. Average
58 * sized user entries are 3-4K each. You need at least two entries to
59 * fit into a single database page, more is better. 64K is BDB's
60 * upper bound. The same issues arise with IDLs in the index databases,
61 * but it's nearly impossible to avoid overflows there.
63 * When using BDB_IDL_MULTI, the IDL size is no longer an issue. Smaller
64 * pages are better for concurrency.
66 #ifndef BDB_ID2ENTRY_PAGESIZE
67 #define BDB_ID2ENTRY_PAGESIZE 16384
72 #define BDB_PAGESIZE 4096 /* BDB's original default */
74 #define BDB_PAGESIZE 16384
78 #define DEFAULT_CACHE_SIZE 1000
80 /* for the in-core cache of entries */
81 typedef struct bdb_cache {
86 Entry *c_lruhead; /* lru - add accessed entries here */
87 Entry *c_lrutail; /* lru - rem lru entries from here */
88 ldap_pvt_thread_mutex_t c_mutex;
91 #define CACHE_READ_LOCK 0
92 #define CACHE_WRITE_LOCK 1
94 #define BDB_INDICES 128
104 /* DB_ENV parameters */
105 /* The DB_ENV can be tuned via DB_CONFIG */
107 u_int32_t bi_dbenv_xflags; /* extra flags */
111 struct bdb_db_info **bi_databases;
112 ldap_pvt_thread_mutex_t bi_database_mutex;
113 int bi_db_opflags; /* db-specific flags */
115 slap_mask_t bi_defaultmask;
120 ldap_pvt_thread_rdwr_t bi_tree_rdwr;
127 u_int32_t bi_txn_cp_min;
128 u_int32_t bi_txn_cp_kbyte;
132 int bi_lock_detect_seconds;
133 ldap_pvt_thread_t bi_lock_detect_tid;
137 ldap_pvt_thread_mutex_t bi_lastid_mutex;
140 #define bi_id2entry bi_databases[BDB_ID2ENTRY]
142 #define bi_id2parent bi_databases[BDB_ID2PARENT]
144 #define bi_dn2id bi_databases[BDB_DN2ID]
153 #if DB_VERSION_MAJOR < 4
154 #define TXN_CHECKPOINT(env, k, m, f) txn_checkpoint(env, k, m, f)
155 #define TXN_ID(txn) txn_id(txn)
156 #define LOCK_DETECT(env, f, t, a) lock_detect(env, f, t, a)
157 #define LOCK_GET(env, i, f, o, m, l) lock_get(env, i, f, o, m, l)
159 #define TXN_CHECKPOINT(env, k, m, f) (env)->txn_checkpoint(env, k, m, f)
160 #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)
167 #include "proto-bdb.h"
169 #endif /* _BACK_BDB_H_ */