X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fback-ldbm%2Fback-ldbm.h;h=b4f16656e087d04b256c40871a53cb866d3e8331;hb=90332c2de22d578483dd9b32240ddbaf8676dde7;hp=267bbcffa6361001ecdce5d54eb595dd935bc6c1;hpb=669b8f4047c03d4583a44ed8287d0d5920d15373;p=openldap diff --git a/servers/slapd/back-ldbm/back-ldbm.h b/servers/slapd/back-ldbm/back-ldbm.h index 267bbcffa6..b4f16656e0 100644 --- a/servers/slapd/back-ldbm/back-ldbm.h +++ b/servers/slapd/back-ldbm/back-ldbm.h @@ -1,4 +1,9 @@ /* back-ldbm.h - ldap ldbm back-end header file */ +/* $OpenLDAP$ */ +/* + * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ #ifndef _BACK_LDBM_H_ #define _BACK_LDBM_H_ @@ -9,27 +14,23 @@ LDAP_BEGIN_DECL #define DEFAULT_CACHE_SIZE 1000 -#ifdef HAVE_BERKELEY_DB2 +#if defined(HAVE_BERKELEY_DB) && DB_VERSION_MAJOR >= 2 # define DEFAULT_DBCACHE_SIZE (100 * DEFAULT_DB_PAGE_SIZE) #else # define DEFAULT_DBCACHE_SIZE 100000 #endif -#define DEFAULT_DB_DIRECTORY "/usr/tmp" -#define DEFAULT_MODE 0600 - -#define SUBLEN 3 +#define DN_BASE_PREFIX SLAP_INDEX_EQUALITY_PREFIX +#define DN_ONE_PREFIX '%' +#define DN_SUBTREE_PREFIX '@' /* - * there is a single index for each attribute. these prefixes insure + * there is a single index for each attribute. these prefixes ensure * that there is no collision among keys. */ -#define EQ_PREFIX '=' /* prefix for equality keys */ -#define APPROX_PREFIX '~' /* prefix for approx keys */ -#define SUB_PREFIX '*' /* prefix for substring keys */ -#define CONT_PREFIX '\\' /* prefix for continuation keys */ -#define UNKNOWN_PREFIX '?' /* prefix for unknown keys */ +/* allow PREFIX + byte for continuate number */ +#define SLAP_INDEX_CONT_SIZE ( sizeof(SLAP_INDEX_CONT_PREFIX) + sizeof(unsigned char) ) #define DEFAULT_BLOCKSIZE 8192 @@ -57,6 +58,11 @@ typedef ID ID_BLOCK; /* all ID_BLOCK macros operate on a pointer to a ID_BLOCK */ #define ID_BLOCK_NMAX(b) ((b)[ID_BLOCK_NMAX_OFFSET]) + +/* Use this macro to get the value, but not to set it. + * By default this is identical to above. + */ +#define ID_BLOCK_NMAXN(b) ID_BLOCK_NMAX(b) #define ID_BLOCK_NIDS(b) ((b)[ID_BLOCK_NIDS_OFFSET]) #define ID_BLOCK_ID(b, n) ((b)[ID_BLOCK_IDS_OFFSET+(n)]) @@ -68,8 +74,25 @@ typedef ID ID_BLOCK; #define ID_BLOCK_INDIRECT_VALUE 0 #define ID_BLOCK_INDIRECT(b) (ID_BLOCK_NIDS(b) == ID_BLOCK_INDIRECT_VALUE) +#define USE_INDIRECT_NIDS 1 + +#ifdef USE_INDIRECT_NIDS +/* + * Use the high bit of ID_BLOCK_NMAX to indicate an INDIRECT block, thus + * freeing up the ID_BLOCK_NIDS to store an actual count. This allows us + * to use binary search on INDIRECT blocks. + */ +#undef ID_BLOCK_NMAXN +#define ID_BLOCK_NMAXN(b) ((b)[ID_BLOCK_NMAX_OFFSET]&0x7fffffff) +#undef ID_BLOCK_INDIRECT_VALUE +#define ID_BLOCK_INDIRECT_VALUE 0x80000000 +#undef ID_BLOCK_INDIRECT +#define ID_BLOCK_INDIRECT(b) (ID_BLOCK_NMAX(b) & ID_BLOCK_INDIRECT_VALUE) + +#endif /* USE_INDIRECT_NIDS */ + /* for the in-core cache of entries */ -struct cache { +typedef struct ldbm_cache { int c_maxsize; int c_cursize; Avlnode *c_dntree; @@ -77,73 +100,50 @@ struct cache { Entry *c_lruhead; /* lru - add accessed entries here */ Entry *c_lrutail; /* lru - rem lru entries from here */ ldap_pvt_thread_mutex_t c_mutex; -}; +} Cache; #define CACHE_READ_LOCK 0 #define CACHE_WRITE_LOCK 1 /* for the cache of open index files */ -struct dbcache { +typedef struct ldbm_dbcache { int dbc_refcnt; int dbc_maxids; int dbc_maxindirect; + int dbc_dirty; + int dbc_flags; time_t dbc_lastref; long dbc_blksize; char *dbc_name; LDBM dbc_db; -}; + ldap_pvt_thread_mutex_t dbc_write_mutex; +} DBCache; -/* for the cache of attribute information (which are indexed, etc.) */ -struct attrinfo { - char *ai_type; /* type name (cn, sn, ...) */ - int ai_indexmask; /* how the attr is indexed */ -#define INDEX_PRESENCE 0x01 -#define INDEX_EQUALITY 0x02 -#define INDEX_APPROX 0x04 -#define INDEX_SUB 0x08 -#define INDEX_UNKNOWN 0x10 -#define INDEX_FROMINIT 0x20 - int ai_syntaxmask; /* what kind of syntax */ -/* ...from slap.h... -#define SYNTAX_CIS 0x01 -#define SYNTAX_CES 0x02 -#define SYNTAX_BIN 0x04 - ... etc. ... -*/ -}; - -#define MAXDBCACHE 10 - -/* this could be made an option */ -#ifndef SLAPD_NEXTID_CHUNK -#define SLAPD_NEXTID_CHUNK 32 -#endif +#define MAXDBCACHE 128 struct ldbminfo { + ldap_pvt_thread_rdwr_t li_giant_rwlock; ID li_nextid; -#if SLAPD_NEXTID_CHUNK > 1 - ID li_nextid_wrote; -#endif - char *li_nextid_file; - ldap_pvt_thread_mutex_t li_root_mutex; - ldap_pvt_thread_mutex_t li_add_mutex; - ldap_pvt_thread_mutex_t li_nextid_mutex; int li_mode; + slap_mask_t li_defaultmask; char *li_directory; - struct cache li_cache; + Cache li_cache; Avlnode *li_attrs; + int li_dblocking; /* lock databases */ + int li_dbwritesync; /* write sync */ int li_dbcachesize; - int li_dbcachewsync; - struct dbcache li_dbcache[MAXDBCACHE]; + DBCache li_dbcache[MAXDBCACHE]; ldap_pvt_thread_mutex_t li_dbcache_mutex; ldap_pvt_thread_cond_t li_dbcache_cv; -#ifdef HAVE_BERKELEY_DB2 - DB_ENV li_db_env; -#endif + DB_ENV *li_dbenv; + int li_envdirok; + int li_dbsyncfreq; + int li_dbsyncwaitn; + int li_dbsyncwaitinterval; + ldap_pvt_thread_t li_dbsynctid; + int li_dbshutdown; }; -extern int ldbm_ignore_nextid_file; - LDAP_END_DECL #include "proto-back-ldbm.h"