]> git.sur5r.net Git - openldap/blob - servers/slapd/back-bdb/back-bdb.h
When using BDB_IDL_MULTI, there are no longer any issues with storing
[openldap] / servers / slapd / back-bdb / back-bdb.h
1 /* back-bdb.h - bdb back-end header file */
2 /* $OpenLDAP$ */
3 /*
4  * Copyright 2000-2001 The OpenLDAP Foundation, All Rights Reserved.
5  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
6  */
7
8 #ifndef _BACK_BDB_H_
9 #define _BACK_BDB_H_
10
11 #include <portable.h>
12 #include <db.h>
13
14 #include "slap.h"
15
16 LDAP_BEGIN_DECL
17
18 #define BDB_FILTER_INDICES 1
19 #define BDB_IDL_MULTI           1
20
21 #define DN_BASE_PREFIX          SLAP_INDEX_EQUALITY_PREFIX
22 #define DN_ONE_PREFIX           '%'
23 #define DN_SUBTREE_PREFIX       '@'
24
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 )
30
31 #define DEFAULT_MODE            0600
32
33 #define BDB_TXN_RETRIES 16
34
35 #define BDB_DBENV_HOME  LDAP_RUNDIR LDAP_DIRSEP "openldap-bdb"
36
37 #ifdef BDB_SUBDIRS
38 #define BDB_TMP_SUBDIR  LDAP_DIRSEP "tmp"
39 #define BDB_LG_SUBDIR   LDAP_DIRSEP "log"
40 #define BDB_DATA_SUBDIR LDAP_DIRSEP "data"
41 #endif
42
43 #define BDB_SUFFIX              ".bdb"
44 #define BDB_ID2ENTRY    0
45 #define BDB_DN2ID               1
46 #define BDB_NDB                 2
47
48 /* The bdb on-disk entry format is pretty space-inefficient. Average
49  * sized user entries are 3-4K each. You need at least two entries to
50  * fit into a single database page, more is better. 64K is BDB's
51  * upper bound. The same issues arise with IDLs in the index databases,
52  * but it's nearly impossible to avoid overflows there.
53  * 
54  * When using BDB_IDL_MULTI, the IDL size is no longer an issue. Smaller
55  * pages are better for concurrency.
56  */
57 #ifndef BDB_PAGESIZE
58 #ifdef BDB_IDL_MULTI
59 #define BDB_PAGESIZE    4096    /* BDB's original default */
60 #else
61 #define BDB_PAGESIZE    16384
62 #endif
63 #endif
64
65 #define BDB_INDICES             128
66
67 struct bdb_db_info {
68         char            *bdi_name;
69         DB                      *bdi_db;
70 };
71
72 struct bdb_info {
73         DB_ENV          *bi_dbenv;
74
75         /* DB_ENV parameters */
76         /* The DB_ENV can be tuned via DB_CONFIG */
77         char            *bi_dbenv_home;
78         u_int32_t       bi_dbenv_xflags; /* extra flags */
79         int                     bi_dbenv_mode;
80
81         int                     bi_ndatabases;
82         struct bdb_db_info **bi_databases;
83         ldap_pvt_thread_mutex_t bi_database_mutex;
84         int             bi_db_opflags;  /* db-specific flags */
85
86         slap_mask_t     bi_defaultmask;
87         Avlnode         *bi_attrs;
88
89         int             bi_txn;
90         int                     bi_txn_cp;
91         u_int32_t       bi_txn_cp_min;
92         u_int32_t       bi_txn_cp_kbyte;
93
94 #ifndef NO_THREADS
95         int                     bi_lock_detect;
96         int                     bi_lock_detect_seconds;
97         ldap_pvt_thread_t       bi_lock_detect_tid;
98 #endif
99
100         ID                      bi_lastid;
101         ldap_pvt_thread_mutex_t bi_lastid_mutex;
102 };
103
104 #define bi_id2entry     bi_databases[BDB_ID2ENTRY]
105 #define bi_dn2id        bi_databases[BDB_DN2ID]
106
107 struct bdb_op_info {
108         BackendDB*      boi_bdb;
109         DB_TXN*         boi_txn;
110         int                     boi_err;
111 };
112
113 LDAP_END_DECL
114
115 #include "proto-bdb.h"
116
117 #endif /* _BACK_BDB_H_ */