X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fback-ldbm%2Fback-ldbm.h;h=e0816acd48ef2b6422a0028a5092522385476af2;hb=ebc746bf35bff61e92869a63f8a21c6f6527bed5;hp=28243301907197768cd7e076f56c776301ff8e73;hpb=42e0d83cb3a1a1c5b25183f1ab74ce7edbe25de7;p=openldap diff --git a/servers/slapd/back-ldbm/back-ldbm.h b/servers/slapd/back-ldbm/back-ldbm.h index 2824330190..e0816acd48 100644 --- a/servers/slapd/back-ldbm/back-ldbm.h +++ b/servers/slapd/back-ldbm/back-ldbm.h @@ -5,8 +5,16 @@ #include "ldbm.h" +LDAP_BEGIN_DECL + #define DEFAULT_CACHE_SIZE 1000 -#define DEFAULT_DBCACHE_SIZE 100000 + +#ifdef HAVE_BERKELEY_DB2 +# 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 @@ -21,6 +29,8 @@ #define SUB_PREFIX '*' /* prefix for substring keys */ #define CONT_PREFIX '\\' /* prefix for continuation keys */ +#define UNKNOWN_PREFIX '?' /* prefix for unknown keys */ + #define DEFAULT_BLOCKSIZE 8192 /* @@ -37,16 +47,26 @@ * the list is terminated by an id of NOID. * b_ids a list of the actual ids themselves */ -typedef struct block { - ID b_nmax; /* max number of ids in this list */ -#define ALLIDSBLOCK 0 /* == 0 => this is an allid block */ - ID b_nids; /* current number of ids used */ -#define INDBLOCK 0 /* == 0 => this is an indirect blk */ - ID b_ids[1]; /* the ids - actually bigger */ -} Block, IDList; -#define ALLIDS( idl ) ((idl)->b_nmax == ALLIDSBLOCK) -#define INDIRECT_BLOCK( idl ) ((idl)->b_nids == INDBLOCK) +typedef ID ID_BLOCK; + +#define ID_BLOCK_NMAX_OFFSET 0 +#define ID_BLOCK_NIDS_OFFSET 1 +#define ID_BLOCK_IDS_OFFSET 2 + +/* all ID_BLOCK macros operate on a pointer to a ID_BLOCK */ + +#define ID_BLOCK_NMAX(b) ((b)[ID_BLOCK_NMAX_OFFSET]) +#define ID_BLOCK_NIDS(b) ((b)[ID_BLOCK_NIDS_OFFSET]) +#define ID_BLOCK_ID(b, n) ((b)[ID_BLOCK_IDS_OFFSET+(n)]) + +#define ID_BLOCK_NOID(b, n) (ID_BLOCK_ID((b),(n)) == NOID) + +#define ID_BLOCK_ALLIDS_VALUE 0 +#define ID_BLOCK_ALLIDS(b) (ID_BLOCK_NMAX(b) == ID_BLOCK_ALLIDS_VALUE) + +#define ID_BLOCK_INDIRECT_VALUE 0 +#define ID_BLOCK_INDIRECT(b) (ID_BLOCK_NIDS(b) == ID_BLOCK_INDIRECT_VALUE) /* for the in-core cache of entries */ struct cache { @@ -56,21 +76,18 @@ struct cache { Avlnode *c_idtree; Entry *c_lruhead; /* lru - add accessed entries here */ Entry *c_lrutail; /* lru - rem lru entries from here */ - pthread_mutex_t c_mutex; + ldap_pvt_thread_mutex_t c_mutex; }; /* for the cache of open index files */ struct dbcache { - char *dbc_name; int dbc_refcnt; - time_t dbc_lastref; - pthread_mutex_t dbc_mutex; - pthread_cond_t dbc_cv; - int dbc_readers; - long dbc_blksize; int dbc_maxids; int dbc_maxindirect; - LDBM dbc_db; + time_t dbc_lastref; + long dbc_blksize; + char *dbc_name; + LDBM dbc_db; }; /* for the cache of attribute information (which are indexed, etc.) */ @@ -94,21 +111,33 @@ struct attrinfo { #define MAXDBCACHE 10 +/* this could be made an option */ +#ifndef SLAPD_NEXTID_CHUNK +#define SLAPD_NEXTID_CHUNK 32 +#endif + struct ldbminfo { ID li_nextid; - pthread_mutex_t li_nextid_mutex; +#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; char *li_directory; struct cache li_cache; Avlnode *li_attrs; int li_dbcachesize; + int li_dbcachewsync; struct dbcache li_dbcache[MAXDBCACHE]; - pthread_mutex_t li_dbcache_mutex; - pthread_cond_t li_dbcache_cv; + ldap_pvt_thread_mutex_t li_dbcache_mutex; + ldap_pvt_thread_cond_t li_dbcache_cv; }; -#ifdef NEEDPROTOS #include "proto-back-ldbm.h" -#endif + +LDAP_END_DECL #endif /* _back_ldbm_h_ */