back-bdb.h 2.58 KB
Newer Older
1
/* back-bdb.h - bdb back-end header file */
Kurt Zeilenga's avatar
Kurt Zeilenga committed
2
3
/* $OpenLDAP$ */
/*
4
 * Copyright 2000-2001 The OpenLDAP Foundation, All Rights Reserved.
Kurt Zeilenga's avatar
Kurt Zeilenga committed
5
6
7
8
9
10
11
12
13
 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
 */

#ifndef _BACK_BDB_H_
#define _BACK_BDB_H_

#include <portable.h>
#include <db.h>

14
15
#include "slap.h"

Kurt Zeilenga's avatar
Kurt Zeilenga committed
16
17
LDAP_BEGIN_DECL

18
#define BDB_FILTER_INDICES 1
19
#define BDB_IDL_MULTI		1
Kurt Zeilenga's avatar
Kurt Zeilenga committed
20

Kurt Zeilenga's avatar
Kurt Zeilenga committed
21
22
23
24
#define DN_BASE_PREFIX		SLAP_INDEX_EQUALITY_PREFIX
#define DN_ONE_PREFIX	 	'%'
#define DN_SUBTREE_PREFIX 	'@'

25
26
27
28
29
30
#define DBTzero(t)			(memset((t), 0, sizeof(DBT)))
#define DBT2bv(t,bv)		((bv)->bv_val = (t)->data, \
								(bv)->bv_len = (t)->size)
#define bv2DBT(bv,t)		((t)->data = (bv)->bv_val, \
								(t)->size = (bv)->bv_len )

Kurt Zeilenga's avatar
Kurt Zeilenga committed
31
#define DEFAULT_MODE		0600
Kurt Zeilenga's avatar
Kurt Zeilenga committed
32

Kurt Zeilenga's avatar
Kurt Zeilenga committed
33
34
#define BDB_TXN_RETRIES	16

35
#define BDB_DBENV_HOME	LDAP_RUNDIR LDAP_DIRSEP "openldap-bdb"
Kurt Zeilenga's avatar
Kurt Zeilenga committed
36

37
#ifdef BDB_SUBDIRS
38
39
40
#define BDB_TMP_SUBDIR	LDAP_DIRSEP "tmp"
#define BDB_LG_SUBDIR	LDAP_DIRSEP "log"
#define BDB_DATA_SUBDIR	LDAP_DIRSEP "data"
41
#endif
Kurt Zeilenga's avatar
Kurt Zeilenga committed
42

43
#define BDB_SUFFIX		".bdb"
44
45
46
#define BDB_ID2ENTRY	0
#define BDB_DN2ID		1
#define BDB_NDB			2
47

48
49
50
/* The bdb on-disk entry format is pretty space-inefficient. Average
 * sized user entries are 3-4K each. You need at least two entries to
 * fit into a single database page, more is better. 64K is BDB's
51
52
 * upper bound. The same issues arise with IDLs in the index databases,
 * but it's nearly impossible to avoid overflows there.
53
54
55
 * 
 * When using BDB_IDL_MULTI, the IDL size is no longer an issue. Smaller
 * pages are better for concurrency.
56
 */
57
#ifndef BDB_PAGESIZE
58
59
60
#ifdef BDB_IDL_MULTI
#define	BDB_PAGESIZE	4096	/* BDB's original default */
#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
70
71
72
73
74
	DB			*bdi_db;
};

struct bdb_info {
	DB_ENV		*bi_dbenv;

75
76
	/* DB_ENV parameters */
	/* The DB_ENV can be tuned via DB_CONFIG */
77
78
79
80
81
	char		*bi_dbenv_home;
	u_int32_t	bi_dbenv_xflags; /* extra flags */
	int			bi_dbenv_mode;

	int			bi_ndatabases;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
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
87

	slap_mask_t	bi_defaultmask;
	Avlnode		*bi_attrs;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
88

89
	int		bi_txn;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
90
91
92
	int			bi_txn_cp;
	u_int32_t	bi_txn_cp_min;
	u_int32_t	bi_txn_cp_kbyte;
93
94
95
96
97
98

#ifndef NO_THREADS
	int			bi_lock_detect;
	int			bi_lock_detect_seconds;
	ldap_pvt_thread_t	bi_lock_detect_tid;
#endif
99
100

	ID			bi_lastid;
101
	ldap_pvt_thread_mutex_t	bi_lastid_mutex;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
102
};
103

104
#define bi_id2entry	bi_databases[BDB_ID2ENTRY]
Kurt Zeilenga's avatar
Kurt Zeilenga committed
105
#define bi_dn2id	bi_databases[BDB_DN2ID]
Kurt Zeilenga's avatar
Kurt Zeilenga committed
106

107
108
109
110
111
112
struct bdb_op_info {
	BackendDB*	boi_bdb;
	DB_TXN*		boi_txn;
	int			boi_err;
};

Kurt Zeilenga's avatar
Kurt Zeilenga committed
113
114
LDAP_END_DECL

Kurt Zeilenga's avatar
Kurt Zeilenga committed
115
116
#include "proto-bdb.h"

Kurt Zeilenga's avatar
Kurt Zeilenga committed
117
#endif /* _BACK_BDB_H_ */