]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-bdb/back-bdb.h
enable unindexed searches monitoring ifdef LDAP_DEVEL
[openldap] / servers / slapd / back-bdb / back-bdb.h
index 4405d82f50e2a796eb33a100260c300238848235..6776e3b68c798450d270bb19e8367b0b63f75b0a 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2006 The OpenLDAP Foundation.
+ * Copyright 2000-2007 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -58,6 +58,28 @@ LDAP_BEGIN_DECL
 #define        BDB_PAGESIZE    4096    /* BDB's original default */
 #endif
 
+/* 4.6.18 redefines cursor->locker */
+#if DB_VERSION_FULL >= 0x04060012
+
+struct __db_locker {
+       u_int32_t       id;
+};
+
+typedef struct __db_locker * BDB_LOCKER;
+
+extern int __lock_getlocker(DB_LOCKTAB *lt, u_int32_t locker, int create, DB_LOCKER **ret);
+
+#define CURSOR_SETLOCKER(cursor, id)   cursor->locker = id
+#define        CURSOR_GETLOCKER(cursor)        cursor->locker
+#else
+
+typedef u_int32_t BDB_LOCKER;
+
+#define CURSOR_SETLOCKER(cursor, id)   cursor->locker = id
+#define CURSOR_GETLOCKER(cursor)       cursor->locker
+
+#endif
+
 #define DEFAULT_CACHE_SIZE     1000
 
 /* The default search IDL stack cache depth */
@@ -68,9 +90,9 @@ LDAP_BEGIN_DECL
 
 typedef struct bdb_idl_cache_entry_s {
        struct berval kstr;
-       ldap_pvt_thread_rdwr_t idl_entry_rwlock;
        ID      *idl;
        DB      *db;
+       int             idl_flags;
        struct bdb_idl_cache_entry_s* idl_lru_prev;
        struct bdb_idl_cache_entry_s* idl_lru_next;
 } bdb_idl_cache_entry_t;
@@ -94,6 +116,8 @@ typedef struct bdb_entry_info {
 #define        CACHE_ENTRY_LOADING     0x10
 #define        CACHE_ENTRY_WALKING     0x20
 #define        CACHE_ENTRY_ONELEVEL    0x40
+#define        CACHE_ENTRY_REFERENCED  0x80
+       int bei_finders;
 
        /*
         * remaining fields require backend cache lock to access
@@ -121,20 +145,23 @@ typedef struct bdb_entry_info {
 
 /* for the in-core cache of entries */
 typedef struct bdb_cache {
-       int             c_maxsize;
-       int             c_cursize;
-       int             c_minfree;
-       int             c_eiused;       /* EntryInfo's in use */
-       int             c_leaves;       /* EntryInfo leaf nodes */
-       EntryInfo       c_dntree;
        EntryInfo       *c_eifree;      /* free list */
-       Avlnode         *c_idtree;
+       Avlnode         *c_idtree;
        EntryInfo       *c_lruhead;     /* lru - add accessed entries here */
        EntryInfo       *c_lrutail;     /* lru - rem lru entries from here */
+       EntryInfo       c_dntree;
+       unsigned        c_maxsize;
+       int             c_cursize;
+       unsigned        c_minfree;
+       unsigned        c_eimax;
+       int             c_eiused;       /* EntryInfo's in use */
+       int             c_leaves;       /* EntryInfo leaf nodes */
+       int             c_purging;
+       BDB_LOCKER      c_locker;       /* used by lru cleaner */
        ldap_pvt_thread_rdwr_t c_rwlock;
-       ldap_pvt_thread_mutex_t lru_head_mutex;
-       ldap_pvt_thread_mutex_t lru_tail_mutex;
-       u_int32_t       c_locker;       /* used by lru cleaner */
+       ldap_pvt_thread_mutex_t c_lru_mutex;
+       ldap_pvt_thread_mutex_t c_count_mutex;
+       ldap_pvt_thread_mutex_t c_eifree_mutex;
 #ifdef SLAP_ZONE_ALLOC
        void *c_zctx;
 #endif
@@ -150,6 +177,17 @@ struct bdb_db_info {
        DB                      *bdi_db;
 };
 
+#ifdef LDAP_DEVEL
+#define BDB_MONITOR_IDX
+#endif /* LDAP_DEVEL */
+
+typedef struct bdb_monitor_t {
+       void            *bdm_cb;
+       struct berval   bdm_nbase;
+       int             bdm_scope;
+       struct berval   bdm_filter;
+} bdb_monitor_t;
+
 /* From ldap_rq.h */
 struct re_s;
 
@@ -180,14 +218,13 @@ struct bdb_info {
        u_int32_t       bi_txn_cp_kbyte;
        struct re_s             *bi_txn_cp_task;
        struct re_s             *bi_index_task;
-       struct re_s             *bi_cache_task;
 
        int                     bi_lock_detect;
        long            bi_shm_key;
 
        ID                      bi_lastid;
        ldap_pvt_thread_mutex_t bi_lastid_mutex;
-       int             bi_idl_cache_max_size;
+       unsigned        bi_idl_cache_max_size;
        int             bi_idl_cache_size;
        Avlnode         *bi_idl_tree;
        bdb_idl_cache_entry_t   *bi_idl_lru_head;
@@ -197,6 +234,13 @@ struct bdb_info {
        alock_info_t    bi_alock_info;
        char            *bi_db_config_path;
        BerVarray       bi_db_config;
+       bdb_monitor_t   bi_monitor;
+
+#ifdef BDB_MONITOR_IDX
+       ldap_pvt_thread_mutex_t bi_idx_mutex;
+       Avlnode         *bi_idx;
+#endif /* BDB_MONITOR_IDX */
+
        int             bi_flags;
 #define        BDB_IS_OPEN             0x01
 #define        BDB_HAS_CONFIG  0x02
@@ -212,6 +256,7 @@ struct bdb_info {
 #define bi_id2entry    bi_databases[BDB_ID2ENTRY]
 #define bi_dn2id       bi_databases[BDB_DN2ID]
 
+
 struct bdb_lock_info {
        struct bdb_lock_info *bli_next;
        ID              bli_id;
@@ -221,14 +266,14 @@ struct bdb_lock_info {
 struct bdb_op_info {
        BackendDB*      boi_bdb;
        DB_TXN*         boi_txn;
+       BDB_LOCKER      boi_locker;
        u_int32_t       boi_err;
-       u_int32_t       boi_locker;
        int             boi_acl_cache;
        struct bdb_lock_info *boi_locks;        /* used when no txn */
 };
 
 #define        DB_OPEN(db, file, name, type, flags, mode) \
-       (db)->open(db, file, name, type, flags, mode)
+       ((db)->open)(db, file, name, type, flags, mode)
 
 #if DB_VERSION_MAJOR < 4
 #define LOCK_DETECT(env,f,t,a)         lock_detect(env, f, t, a)
@@ -259,9 +304,19 @@ struct bdb_op_info {
 #if DB_VERSION_FULL >= 0x04010011
 #undef DB_OPEN
 #define        DB_OPEN(db, file, name, type, flags, mode) \
-       (db)->open(db, NULL, file, name, type, flags, mode)
+       ((db)->open)(db, NULL, file, name, type, flags, mode)
+#endif
+
+/* BDB 4.6.18 makes locker a struct instead of an int */
+#if DB_VERSION_FULL >= 0x04060012
+#undef TXN_ID
+#define TXN_ID(txn)    (txn)->locker
+#endif
+
 #endif
 
+#ifndef DB_BUFFER_SMALL
+#define DB_BUFFER_SMALL                        ENOMEM
 #endif
 
 #define BDB_REUSE_LOCKERS