]> git.sur5r.net Git - openldap/blob - servers/slapd/back-ldbm/back-ldbm.h
If dn2id returns ID but id2entry returns NULL, log it.
[openldap] / servers / slapd / back-ldbm / back-ldbm.h
1 /* back-ldbm.h - ldap ldbm back-end header file */
2
3 #ifndef _BACK_LDBM_H_
4 #define _BACK_LDBM_H_
5
6 #include "ldbm.h"
7
8 LDAP_BEGIN_DECL
9
10 #define DEFAULT_CACHE_SIZE      1000
11
12 #ifdef HAVE_BERKELEY_DB2
13 #       define DEFAULT_DBCACHE_SIZE (100 * DEFAULT_DB_PAGE_SIZE)
14 #else
15 #       define DEFAULT_DBCACHE_SIZE 100000
16 #endif
17
18 #define DEFAULT_DB_DIRECTORY    "/usr/tmp"
19 #define DEFAULT_MODE            0600
20
21 #define SUBLEN                  3
22
23 /*
24  * there is a single index for each attribute.  these prefixes insure
25  * that there is no collision among keys.
26  */
27 #define EQ_PREFIX       '='     /* prefix for equality keys     */
28 #define APPROX_PREFIX   '~'     /* prefix for approx keys       */
29 #define SUB_PREFIX      '*'     /* prefix for substring keys    */
30 #define CONT_PREFIX     '\\'    /* prefix for continuation keys */
31
32 #define UNKNOWN_PREFIX  '?'     /* prefix for unknown keys    */
33
34 #define DEFAULT_BLOCKSIZE       8192
35
36 /*
37  * This structure represents an id block on disk and an id list
38  * in core.
39  *
40  * The fields have the following meanings:
41  *
42  *      b_nmax  maximum number of ids in this block. if this is == ALLIDSBLOCK,
43  *              then this block represents all ids.
44  *      b_nids  current number of ids in use in this block.  if this
45  *              is == INDBLOCK, then this block is an indirect block
46  *              containing a list of other blocks containing actual ids.
47  *              the list is terminated by an id of NOID.
48  *      b_ids   a list of the actual ids themselves
49  */
50 typedef struct block {
51         ID              b_nmax;         /* max number of ids in this list  */
52 #define ALLIDSBLOCK     0               /* == 0 => this is an allid block  */
53         ID              b_nids;         /* current number of ids used      */
54 #define INDBLOCK        0               /* == 0 => this is an indirect blk */
55         ID              b_ids[1];       /* the ids - actually bigger       */
56 } Block, IDList;
57
58 #define ALLIDS( idl )           ((idl)->b_nmax == ALLIDSBLOCK)
59 #define INDIRECT_BLOCK( idl )   ((idl)->b_nids == INDBLOCK)
60
61 /* for the in-core cache of entries */
62 struct cache {
63         int             c_maxsize;
64         int             c_cursize;
65         Avlnode         *c_dntree;
66         Avlnode         *c_idtree;
67         Entry           *c_lruhead;     /* lru - add accessed entries here */
68         Entry           *c_lrutail;     /* lru - rem lru entries from here */
69         pthread_mutex_t c_mutex;
70 };
71
72 /* for the cache of open index files */
73 struct dbcache {
74         char            *dbc_name;
75         int             dbc_refcnt;
76         time_t          dbc_lastref;
77         pthread_mutex_t dbc_mutex;
78         pthread_cond_t  dbc_cv;
79         int             dbc_readers;
80         long            dbc_blksize;
81         int             dbc_maxids;
82         int             dbc_maxindirect;
83         LDBM            dbc_db;
84 };
85
86 /* for the cache of attribute information (which are indexed, etc.) */
87 struct attrinfo {
88         char    *ai_type;       /* type name (cn, sn, ...)      */
89         int     ai_indexmask;   /* how the attr is indexed      */
90 #define INDEX_PRESENCE  0x01
91 #define INDEX_EQUALITY  0x02
92 #define INDEX_APPROX    0x04
93 #define INDEX_SUB       0x08
94 #define INDEX_UNKNOWN   0x10
95 #define INDEX_FROMINIT  0x20
96         int     ai_syntaxmask;  /* what kind of syntax          */
97 /* ...from slap.h...
98 #define SYNTAX_CIS      0x01
99 #define SYNTAX_CES      0x02
100 #define SYNTAX_BIN      0x04
101    ... etc. ...
102 */
103 };
104
105 #define MAXDBCACHE      10
106
107 /* this could be made an option */
108 #ifndef SLAPD_NEXTID_CHUNK
109 #define SLAPD_NEXTID_CHUNK      32
110 #endif
111
112 struct ldbminfo {
113         ID                      li_nextid;
114 #if SLAPD_NEXTID_CHUNK > 1
115         ID                      li_nextid_wrote;
116 #endif
117         char            *li_nextid_file;
118         pthread_mutex_t         li_root_mutex;
119         pthread_mutex_t         li_add_mutex;
120         pthread_mutex_t         li_nextid_mutex;
121         int                     li_mode;
122         char                    *li_directory;
123         struct cache            li_cache;
124         Avlnode                 *li_attrs;
125         int                     li_dbcachesize;
126         int                     li_dbcachewsync;
127         struct dbcache          li_dbcache[MAXDBCACHE];
128         pthread_mutex_t         li_dbcache_mutex;
129         pthread_cond_t          li_dbcache_cv;
130 };
131
132 #include "proto-back-ldbm.h"
133
134 LDAP_END_DECL
135
136 #endif /* _back_ldbm_h_ */