/[pkg-openldap]/people/torsten/openldap2.2/servers/slapd/back-bdb/back-bdb.h
ViewVC logotype

Contents of /people/torsten/openldap2.2/servers/slapd/back-bdb/back-bdb.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 453 - (show annotations) (download)
Thu Mar 24 23:13:29 2005 UTC (8 years, 2 months ago) by torsten
File MIME type: text/plain
File size: 7168 byte(s)
 r1556@pulsar:  torsten | 2005-03-25 00:18:41 +0100
  * Applied patch by Quanah Gibson-Mount (directory administrator of Stanford)
    to add -q option to some tools for quick operation without updating
    logs. This is mostly for importing directories from LDIF backups.
1 /* back-bdb.h - bdb back-end header file */
2 /* $OpenLDAP: pkg/ldap/servers/slapd/back-bdb/back-bdb.h,v 1.92.2.13 2005/01/20 17:01:10 kurt Exp $ */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 *
5 * Copyright 2000-2005 The OpenLDAP Foundation.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted only as authorized by the OpenLDAP
10 * Public License.
11 *
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>.
15 */
16
17 #ifndef _BACK_BDB_H_
18 #define _BACK_BDB_H_
19
20 #include <portable.h>
21 #include "slap.h"
22 #include <db.h>
23
24 LDAP_BEGIN_DECL
25
26 #define DB_VERSION_FULL ((DB_VERSION_MAJOR << 24) | (DB_VERSION_MINOR << 16) | DB_VERSION_PATCH)
27
28 #define BDB_SUBENTRIES 1
29
30 #define DN_BASE_PREFIX SLAP_INDEX_EQUALITY_PREFIX
31 #define DN_ONE_PREFIX '%'
32 #define DN_SUBTREE_PREFIX '@'
33
34 #define DBTzero(t) (memset((t), 0, sizeof(DBT)))
35 #define DBT2bv(t,bv) ((bv)->bv_val = (t)->data, \
36 (bv)->bv_len = (t)->size)
37 #define bv2DBT(bv,t) ((t)->data = (bv)->bv_val, \
38 (t)->size = (bv)->bv_len )
39
40 #define BDB_TXN_RETRIES 16
41
42 #define BDB_MAX_ADD_LOOP 30
43
44 #ifdef BDB_SUBDIRS
45 #define BDB_TMP_SUBDIR "tmp"
46 #define BDB_LG_SUBDIR "log"
47 #define BDB_DATA_SUBDIR "data"
48 #endif
49
50 #define BDB_SUFFIX ".bdb"
51 #define BDB_ID2ENTRY 0
52 #define BDB_DN2ID 1
53 #define BDB_NDB 2
54
55 /* The bdb on-disk entry format is pretty space-inefficient. Average
56 * sized user entries are 3-4K each. You need at least two entries to
57 * fit into a single database page, more is better. 64K is BDB's
58 * upper bound. Smaller pages are better for concurrency.
59 */
60 #ifndef BDB_ID2ENTRY_PAGESIZE
61 #define BDB_ID2ENTRY_PAGESIZE 16384
62 #endif
63
64 #ifndef BDB_PAGESIZE
65 #define BDB_PAGESIZE 4096 /* BDB's original default */
66 #endif
67
68 #define DEFAULT_CACHE_SIZE 1000
69
70 /* The default search IDL stack cache depth */
71 #define DEFAULT_SEARCH_STACK_DEPTH 16
72
73 /* The minimum we can function with */
74 #define MINIMUM_SEARCH_STACK_DEPTH 8
75
76 typedef struct bdb_idl_cache_entry_s {
77 struct berval kstr;
78 ldap_pvt_thread_rdwr_t idl_entry_rwlock;
79 ID *idl;
80 DB *db;
81 struct bdb_idl_cache_entry_s* idl_lru_prev;
82 struct bdb_idl_cache_entry_s* idl_lru_next;
83 } bdb_idl_cache_entry_t;
84
85 /* BDB backend specific entry info */
86 typedef struct bdb_entry_info {
87 struct bdb_entry_info *bei_parent;
88 ID bei_id;
89
90 /* we use the bei_id as a lockobj, but we need to make the size != 4
91 * to avoid conflicting with BDB's internal locks. So add a byte here
92 * that is always zero.
93 */
94 char bei_lockpad;
95
96 short bei_state;
97 #define CACHE_ENTRY_DELETED 1
98 #define CACHE_ENTRY_NO_KIDS 2
99 #define CACHE_ENTRY_NOT_LINKED 4
100 #define CACHE_ENTRY_NO_GRANDKIDS 8
101 #define CACHE_ENTRY_LOADING 0x10
102
103 /*
104 * remaining fields require backend cache lock to access
105 */
106 struct berval bei_nrdn;
107 #ifdef BDB_HIER
108 struct berval bei_rdn;
109 int bei_modrdns; /* track renames */
110 int bei_ckids; /* number of kids cached */
111 int bei_dkids; /* number of kids on-disk, plus 1 */
112 #endif
113 Entry *bei_e;
114 Avlnode *bei_kids;
115 ldap_pvt_thread_mutex_t bei_kids_mutex;
116
117 struct bdb_entry_info *bei_lrunext; /* for cache lru list */
118 struct bdb_entry_info *bei_lruprev;
119 } EntryInfo;
120 #undef BEI
121 #define BEI(e) ((EntryInfo *) ((e)->e_private))
122
123 /* for the in-core cache of entries */
124 typedef struct bdb_cache {
125 int c_maxsize;
126 int c_cursize;
127 int c_eiused; /* EntryInfo's in use */
128 EntryInfo c_dntree;
129 EntryInfo *c_eifree; /* free list */
130 Avlnode *c_idtree;
131 EntryInfo *c_lruhead; /* lru - add accessed entries here */
132 EntryInfo *c_lrutail; /* lru - rem lru entries from here */
133 ldap_pvt_thread_rdwr_t c_rwlock;
134 ldap_pvt_thread_mutex_t lru_mutex;
135 u_int32_t c_locker; /* used by lru cleaner */
136 } Cache;
137
138 #define CACHE_READ_LOCK 0
139 #define CACHE_WRITE_LOCK 1
140
141 #define BDB_INDICES 128
142
143 struct bdb_db_info {
144 char *bdi_name;
145 DB *bdi_db;
146 };
147
148 struct bdb_info {
149 DB_ENV *bi_dbenv;
150
151 /* DB_ENV parameters */
152 /* The DB_ENV can be tuned via DB_CONFIG */
153 char *bi_dbenv_home;
154 u_int32_t bi_dbenv_xflags; /* extra flags */
155 int bi_dbenv_mode;
156
157 int bi_ndatabases;
158 struct bdb_db_info **bi_databases;
159 ldap_pvt_thread_mutex_t bi_database_mutex;
160 int bi_db_opflags; /* db-specific flags */
161
162 slap_mask_t bi_defaultmask;
163 Cache bi_cache;
164 Avlnode *bi_attrs;
165 void *bi_search_stack;
166 int bi_search_stack_depth;
167
168 int bi_txn_cp;
169 u_int32_t bi_txn_cp_min;
170 u_int32_t bi_txn_cp_kbyte;
171
172 int bi_lock_detect;
173 long bi_shm_key;
174
175 ID bi_lastid;
176 ldap_pvt_thread_mutex_t bi_lastid_mutex;
177 LDAP_LIST_HEAD(pl, slap_op) bi_psearch_list;
178 ldap_pvt_thread_rdwr_t bi_pslist_rwlock;
179 LDAP_LIST_HEAD(se, slap_session_entry) bi_session_list;
180 int bi_idl_cache_max_size;
181 int bi_idl_cache_size;
182 Avlnode *bi_idl_tree;
183 bdb_idl_cache_entry_t *bi_idl_lru_head;
184 bdb_idl_cache_entry_t *bi_idl_lru_tail;
185 ldap_pvt_thread_rdwr_t bi_idl_tree_rwlock;
186 ldap_pvt_thread_mutex_t bi_idl_tree_lrulock;
187 };
188
189 #define bi_id2entry bi_databases[BDB_ID2ENTRY]
190 #define bi_dn2id bi_databases[BDB_DN2ID]
191
192 struct bdb_lock_info {
193 struct bdb_lock_info *bli_next;
194 ID bli_id;
195 DB_LOCK bli_lock;
196 };
197
198 struct bdb_op_info {
199 BackendDB* boi_bdb;
200 DB_TXN* boi_txn;
201 u_int32_t boi_err;
202 u_int32_t boi_locker;
203 int boi_acl_cache;
204 struct bdb_lock_info *boi_locks; /* used when no txn */
205 };
206
207 #define DB_OPEN(db, file, name, type, flags, mode) \
208 (db)->open(db, file, name, type, flags, mode)
209
210 #if DB_VERSION_MAJOR < 4
211 #define LOCK_DETECT(env,f,t,a) lock_detect(env, f, t, a)
212 #define LOCK_GET(env,i,f,o,m,l) lock_get(env, i, f, o, m, l)
213 #define LOCK_PUT(env,l) lock_put(env, l)
214 #define TXN_CHECKPOINT(env,k,m,f) txn_checkpoint(env, k, m, f)
215 #define TXN_BEGIN(env,p,t,f) txn_begin((env), p, t, f)
216 #define TXN_PREPARE(txn,gid) txn_prepare((txn), (gid))
217 #define TXN_COMMIT(txn,f) txn_commit((txn), (f))
218 #define TXN_ABORT(txn) txn_abort((txn))
219 #define TXN_ID(txn) txn_id(txn)
220 #define XLOCK_ID(env, locker) lock_id(env, locker)
221 #define XLOCK_ID_FREE(env, locker) lock_id_free(env, locker)
222 #else
223 #define LOCK_DETECT(env,f,t,a) (env)->lock_detect(env, f, t, a)
224 #define LOCK_GET(env,i,f,o,m,l) (env)->lock_get(env, i, f, o, m, l)
225 #define LOCK_PUT(env,l) (env)->lock_put(env, l)
226 #define TXN_CHECKPOINT(env,k,m,f) (env)->txn_checkpoint(env, k, m, f)
227 #define TXN_BEGIN(env,p,t,f) (env)->txn_begin((env), p, t, f)
228 #define TXN_PREPARE(txn,g) (txn)->prepare((txn), (g))
229 #define TXN_COMMIT(txn,f) (txn)->commit((txn), (f))
230 #define TXN_ABORT(txn) (txn)->abort((txn))
231 #define TXN_ID(txn) (txn)->id(txn)
232 #define XLOCK_ID(env, locker) (env)->lock_id(env, locker)
233 #define XLOCK_ID_FREE(env, locker) (env)->lock_id_free(env, locker)
234
235 /* BDB 4.1.17 adds txn arg to db->open */
236 #if DB_VERSION_FULL >= 0x04010011
237 #undef DB_OPEN
238 #define DB_OPEN(db, file, name, type, flags, mode) \
239 (db)->open(db, NULL, file, name, type, flags, mode)
240 #endif
241
242 #endif
243
244 #define BDB_REUSE_LOCKERS
245
246 #define BDB_CSN_COMMIT 0
247 #define BDB_CSN_ABORT 1
248 #define BDB_CSN_RETRY 2
249
250 LDAP_END_DECL
251
252 #include "proto-bdb.h"
253
254 #endif /* _BACK_BDB_H_ */

  ViewVC Help
Powered by ViewVC 1.1.5