From 24d1ab848cc8716c74901b203f566670723acfaf Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Wed, 28 Nov 2001 03:11:04 +0000 Subject: [PATCH] Added experimental support for DB_DIRTY_READ. --- servers/slapd/back-bdb/add.c | 3 ++- servers/slapd/back-bdb/back-bdb.h | 1 + servers/slapd/back-bdb/config.c | 5 +++++ servers/slapd/back-bdb/dbcache.c | 2 +- servers/slapd/back-bdb/delete.c | 3 ++- servers/slapd/back-bdb/dn2id.c | 8 ++++---- servers/slapd/back-bdb/id2entry.c | 2 +- servers/slapd/back-bdb/idl.c | 9 ++++++--- servers/slapd/back-bdb/init.c | 2 +- servers/slapd/back-bdb/modify.c | 3 ++- servers/slapd/back-bdb/modrdn.c | 3 ++- servers/slapd/back-bdb/passwd.c | 3 ++- servers/slapd/back-bdb/tools.c | 8 +++++--- 13 files changed, 34 insertions(+), 18 deletions(-) diff --git a/servers/slapd/back-bdb/add.c b/servers/slapd/back-bdb/add.c index fff5f65345..090f855e18 100644 --- a/servers/slapd/back-bdb/add.c +++ b/servers/slapd/back-bdb/add.c @@ -70,7 +70,8 @@ retry: rc = txn_abort( ltid ); /* begin transaction */ if( bdb->bi_txn ) { - rc = txn_begin( bdb->bi_dbenv, NULL, <id, 0 ); + rc = txn_begin( bdb->bi_dbenv, NULL, <id, + bdb->bi_db_opflags ); text = NULL; if( rc != 0 ) { Debug( LDAP_DEBUG_TRACE, diff --git a/servers/slapd/back-bdb/back-bdb.h b/servers/slapd/back-bdb/back-bdb.h index ec71844477..26eb103c5c 100644 --- a/servers/slapd/back-bdb/back-bdb.h +++ b/servers/slapd/back-bdb/back-bdb.h @@ -72,6 +72,7 @@ struct bdb_info { int bi_ndatabases; struct bdb_db_info **bi_databases; ldap_pvt_thread_mutex_t bi_database_mutex; + int bi_db_opflags; /* db-specific flags */ slap_mask_t bi_defaultmask; Avlnode *bi_attrs; diff --git a/servers/slapd/back-bdb/config.c b/servers/slapd/back-bdb/config.c index da6a7db39f..75d41a4dc4 100644 --- a/servers/slapd/back-bdb/config.c +++ b/servers/slapd/back-bdb/config.c @@ -13,6 +13,7 @@ #include "back-bdb.h" #define SLAP_BDB_ALLOW_DBNOTXN +#define SLAP_BDB_ALLOW_DIRTY_READ int bdb_db_config( @@ -48,6 +49,10 @@ bdb_db_config( /* turn off transactions, use CDB mode instead */ } else if ( strcasecmp( argv[0], "dbnotxn" ) == 0 ) { bdb->bi_txn = 0; +#endif +#ifdef SLAP_BDB_ALLOW_DIRTY_READ + } else if ( strcasecmp( argv[0], "dirtyread" ) == 0 ) { + bdb->bi_db_opflags |= DB_DIRTY_READ; #endif /* transaction checkpoint configuration */ } else if ( strcasecmp( argv[0], "dbnosync" ) == 0 ) { diff --git a/servers/slapd/back-bdb/dbcache.c b/servers/slapd/back-bdb/dbcache.c index db63bcd705..a959c23505 100644 --- a/servers/slapd/back-bdb/dbcache.c +++ b/servers/slapd/back-bdb/dbcache.c @@ -73,7 +73,7 @@ bdb_db_cache( rc = db->bdi_db->open( db->bdi_db, file, name, - DB_BTREE, DB_CREATE|DB_THREAD, + DB_BTREE, bdb->bi_db_opflags | DB_CREATE | DB_THREAD, bdb->bi_dbenv_mode ); ch_free( file ); diff --git a/servers/slapd/back-bdb/delete.c b/servers/slapd/back-bdb/delete.c index 22e67f6f67..b64f972f7e 100644 --- a/servers/slapd/back-bdb/delete.c +++ b/servers/slapd/back-bdb/delete.c @@ -50,7 +50,8 @@ retry: /* transaction retry */ if( bdb->bi_txn ) { /* begin transaction */ - rc = txn_begin( bdb->bi_dbenv, NULL, <id, 0 ); + rc = txn_begin( bdb->bi_dbenv, NULL, <id, + bdb->bi_db_opflags ); text = NULL; if( rc != 0 ) { Debug( LDAP_DEBUG_TRACE, diff --git a/servers/slapd/back-bdb/dn2id.c b/servers/slapd/back-bdb/dn2id.c index 3395d47fbb..0e73b95738 100644 --- a/servers/slapd/back-bdb/dn2id.c +++ b/servers/slapd/back-bdb/dn2id.c @@ -210,7 +210,7 @@ bdb_dn2id( data.flags = DB_DBT_USERMEM; /* fetch it */ - rc = db->get( db, txn, &key, &data, 0 ); + rc = db->get( db, txn, &key, &data, bdb->bi_db_opflags ); if( rc != 0 ) { Debug( LDAP_DEBUG_TRACE, "<= bdb_dn2id: get failed: %s (%d)\n", @@ -260,7 +260,7 @@ bdb_dn2id_matched( *id = NOID; /* fetch it */ - rc = db->get( db, txn, &key, &data, 0 ); + rc = db->get( db, txn, &key, &data, bdb->bi_db_opflags ); if( rc == DB_NOTFOUND ) { char *pdn = dn_parent( be, dn ); @@ -339,7 +339,7 @@ bdb_dn2id_children( data.doff = 0; data.dlen = sizeof(id); - rc = db->get( db, txn, &key, &data, 0 ); + rc = db->get( db, txn, &key, &data, bdb->bi_db_opflags ); Debug( LDAP_DEBUG_TRACE, "<= bdb_dn2id_children( %s ): %schildren (%d)\n", dn, @@ -376,7 +376,7 @@ bdb_dn2idl( data.flags = DB_DBT_USERMEM; /* fetch it */ - rc = db->get( db, NULL, &key, &data, 0 ); + rc = db->get( db, NULL, &key, &data, bdb->bi_db_opflags ); if( rc != 0 ) { Debug( LDAP_DEBUG_TRACE, diff --git a/servers/slapd/back-bdb/id2entry.c b/servers/slapd/back-bdb/id2entry.c index 2edc0dbe0e..2ca460ead7 100644 --- a/servers/slapd/back-bdb/id2entry.c +++ b/servers/slapd/back-bdb/id2entry.c @@ -92,7 +92,7 @@ int bdb_id2entry( data.flags = DB_DBT_MALLOC; /* fetch it */ - rc = db->get( db, tid, &key, &data, 0 ); + rc = db->get( db, tid, &key, &data, bdb->bi_db_opflags ); if( rc != 0 ) { return rc; diff --git a/servers/slapd/back-bdb/idl.c b/servers/slapd/back-bdb/idl.c index 0d080894a0..b3b11458a3 100644 --- a/servers/slapd/back-bdb/idl.c +++ b/servers/slapd/back-bdb/idl.c @@ -220,6 +220,7 @@ bdb_idl_fetch_key( DBT *key, ID *ids ) { + struct bdb_info *bdb = (struct bdb_info *) be->be_private; int rc; DBT data; @@ -231,7 +232,7 @@ bdb_idl_fetch_key( data.flags = DB_DBT_USERMEM; /* fetch it */ - rc = db->get( db, tid, key, &data, 0 ); + rc = db->get( db, tid, key, &data, bdb->bi_db_opflags ); if( rc == DB_NOTFOUND ) { return rc; @@ -268,6 +269,7 @@ bdb_idl_insert_key( DBT *key, ID id ) { + struct bdb_info *bdb = (struct bdb_info *) be->be_private; int rc; ID ids[BDB_IDL_DB_SIZE]; DBT data; @@ -284,7 +286,7 @@ bdb_idl_insert_key( data.flags = DB_DBT_USERMEM; /* fetch the key for read/modify/write */ - rc = db->get( db, tid, key, &data, DB_RMW ); + rc = db->get( db, tid, key, &data, DB_RMW | bdb->bi_db_opflags ); if( rc == DB_NOTFOUND ) { ids[0] = 1; @@ -358,6 +360,7 @@ bdb_idl_delete_key( DBT *key, ID id ) { + struct bdb_info *bdb = (struct bdb_info *) be->be_private; int rc; ID ids[BDB_IDL_DB_SIZE]; DBT data; @@ -374,7 +377,7 @@ bdb_idl_delete_key( data.flags = DB_DBT_USERMEM; /* fetch the key for read/modify/write */ - rc = db->get( db, tid, key, &data, DB_RMW ); + rc = db->get( db, tid, key, &data, DB_RMW | bdb->bi_db_opflags ); if ( rc != 0 ) { Debug( LDAP_DEBUG_ANY, "=> bdb_idl_delete_key: " diff --git a/servers/slapd/back-bdb/init.c b/servers/slapd/back-bdb/init.c index 8e5f5b51af..b7775be791 100644 --- a/servers/slapd/back-bdb/init.c +++ b/servers/slapd/back-bdb/init.c @@ -210,7 +210,7 @@ bdb_db_open( BackendDB *be ) } } - flags = DB_THREAD | DB_CREATE; + flags = DB_THREAD | DB_CREATE | bdb->bi_db_opflags; bdb->bi_databases = (struct bdb_db_info **) ch_malloc( BDB_INDICES * sizeof(struct bdb_db_info *) ); diff --git a/servers/slapd/back-bdb/modify.c b/servers/slapd/back-bdb/modify.c index 42869b59a7..a72be960b4 100644 --- a/servers/slapd/back-bdb/modify.c +++ b/servers/slapd/back-bdb/modify.c @@ -189,7 +189,8 @@ retry: /* transaction retry */ if( bdb->bi_txn ) { /* begin transaction */ - rc = txn_begin( bdb->bi_dbenv, NULL, <id, 0 ); + rc = txn_begin( bdb->bi_dbenv, NULL, <id, + bdb->bi_db_opflags ); text = NULL; if( rc != 0 ) { Debug( LDAP_DEBUG_TRACE, diff --git a/servers/slapd/back-bdb/modrdn.c b/servers/slapd/back-bdb/modrdn.c index 6742f71b46..1f907af2ca 100644 --- a/servers/slapd/back-bdb/modrdn.c +++ b/servers/slapd/back-bdb/modrdn.c @@ -83,7 +83,8 @@ retry: /* transaction retry */ if( bdb->bi_txn ) { /* begin transaction */ - rc = txn_begin( bdb->bi_dbenv, NULL, <id, 0 ); + rc = txn_begin( bdb->bi_dbenv, NULL, <id, + bdb->bi_db_opflags ); text = NULL; if( rc != 0 ) { Debug( LDAP_DEBUG_TRACE, diff --git a/servers/slapd/back-bdb/passwd.c b/servers/slapd/back-bdb/passwd.c index 96ea8dc6e3..f41f8ed8a9 100644 --- a/servers/slapd/back-bdb/passwd.c +++ b/servers/slapd/back-bdb/passwd.c @@ -99,7 +99,8 @@ retry: /* transaction retry */ if( bdb->bi_txn ) { /* begin transaction */ - rc = txn_begin( bdb->bi_dbenv, NULL, <id, 0 ); + rc = txn_begin( bdb->bi_dbenv, NULL, <id, + bdb->bi_db_opflags ); *text = NULL; if( rc != 0 ) { Debug( LDAP_DEBUG_TRACE, diff --git a/servers/slapd/back-bdb/tools.c b/servers/slapd/back-bdb/tools.c index 892db3ee73..2738bf10ee 100644 --- a/servers/slapd/back-bdb/tools.c +++ b/servers/slapd/back-bdb/tools.c @@ -64,7 +64,8 @@ ID bdb_tool_entry_next( if (cursor == NULL) { rc = bdb->bi_id2entry->bdi_db->cursor( - bdb->bi_id2entry->bdi_db, NULL, &cursor, 0 ); + bdb->bi_id2entry->bdi_db, NULL, &cursor, + bdb->bi_db_opflags ); if( rc != 0 ) { return NOID; } @@ -120,7 +121,8 @@ ID bdb_tool_entry_put( (long) e->e_id, e->e_dn, 0 ); if( bdb->bi_txn ) { - rc = txn_begin( bdb->bi_dbenv, NULL, &tid, 0 ); + rc = txn_begin( bdb->bi_dbenv, NULL, &tid, + bdb->bi_db_opflags ); if( rc != 0 ) { Debug( LDAP_DEBUG_ANY, "=> bdb_tool_entry_put: txn_begin failed: %s (%d)\n", @@ -208,7 +210,7 @@ int bdb_tool_entry_reindex( } if( bi->bi_txn ) { - rc = txn_begin( bi->bi_dbenv, NULL, &tid, 0 ); + rc = txn_begin( bi->bi_dbenv, NULL, &tid, bi->bi_db_opflags ); if( rc != 0 ) { Debug( LDAP_DEBUG_ANY, "=> bdb_tool_entry_reindex: txn_begin failed: %s (%d)\n", -- 2.39.5