From a3d61e0485c70ec5215c34b6caf40e2e6c6c5338 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 24 May 2004 16:27:23 +0000 Subject: r848: convert lib/tdb into the same layout as lib/ldb metze (This used to be commit bacab322ce89979f0ad0811cd15b73d81eceb69d) --- source4/lib/tdb/include/spinlock.h | 59 ++++++++++++++ source4/lib/tdb/include/tdb.h | 153 +++++++++++++++++++++++++++++++++++++ source4/lib/tdb/include/tdbutil.h | 37 +++++++++ 3 files changed, 249 insertions(+) create mode 100644 source4/lib/tdb/include/spinlock.h create mode 100644 source4/lib/tdb/include/tdb.h create mode 100644 source4/lib/tdb/include/tdbutil.h (limited to 'source4/lib/tdb/include') diff --git a/source4/lib/tdb/include/spinlock.h b/source4/lib/tdb/include/spinlock.h new file mode 100644 index 0000000000..967fe37457 --- /dev/null +++ b/source4/lib/tdb/include/spinlock.h @@ -0,0 +1,59 @@ +#ifndef __SPINLOCK_H__ +#define __SPINLOCK_H__ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "tdb.h" + +#ifdef USE_SPINLOCKS + +#define RWLOCK_BIAS 0x1000UL + +/* OS SPECIFIC */ +#define MAX_BUSY_LOOPS 1000 +#undef USE_SCHED_YIELD + +/* ARCH SPECIFIC */ +/* We should make sure these are padded to a cache line */ +#if defined(SPARC_SPINLOCKS) +typedef volatile char spinlock_t; +#elif defined(POWERPC_SPINLOCKS) +typedef volatile unsigned long spinlock_t; +#elif defined(INTEL_SPINLOCKS) +typedef volatile int spinlock_t; +#elif defined(MIPS_SPINLOCKS) +typedef volatile unsigned long spinlock_t; +#else +#error Need to implement spinlock code in spinlock.h +#endif + +typedef struct { + spinlock_t lock; + volatile int count; +} tdb_rwlock_t; + +int tdb_spinlock(TDB_CONTEXT *tdb, int list, int rw_type); +int tdb_spinunlock(TDB_CONTEXT *tdb, int list, int rw_type); +int tdb_create_rwlocks(int fd, unsigned int hash_size); +int tdb_clear_spinlocks(TDB_CONTEXT *tdb); + +#define TDB_SPINLOCK_SIZE(hash_size) (((hash_size) + 1) * sizeof(tdb_rwlock_t)) + +#else /* !USE_SPINLOCKS */ +#if 0 +#define tdb_create_rwlocks(fd, hash_size) 0 +#define tdb_spinlock(tdb, list, rw_type) (-1) +#define tdb_spinunlock(tdb, list, rw_type) (-1) +#else +int tdb_spinlock(TDB_CONTEXT *tdb, int list, int rw_type); +int tdb_spinunlock(TDB_CONTEXT *tdb, int list, int rw_type); +int tdb_create_rwlocks(int fd, unsigned int hash_size); +#endif +int tdb_clear_spinlocks(TDB_CONTEXT *tdb); +#define TDB_SPINLOCK_SIZE(hash_size) 0 + +#endif + +#endif diff --git a/source4/lib/tdb/include/tdb.h b/source4/lib/tdb/include/tdb.h new file mode 100644 index 0000000000..73a0ea8f83 --- /dev/null +++ b/source4/lib/tdb/include/tdb.h @@ -0,0 +1,153 @@ +#ifndef __TDB_H__ +#define __TDB_H__ + +/* + Unix SMB/CIFS implementation. + + trivial database library + + Copyright (C) Andrew Tridgell 1999-2004 + + ** NOTE! The following LGPL license applies to the tdb + ** library. This does NOT imply that all of Samba is released + ** under the LGPL + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifdef __cplusplus +extern "C" { +#endif + + +/* flags to tdb_store() */ +#define TDB_REPLACE 1 +#define TDB_INSERT 2 +#define TDB_MODIFY 3 + +/* flags for tdb_open() */ +#define TDB_DEFAULT 0 /* just a readability place holder */ +#define TDB_CLEAR_IF_FIRST 1 +#define TDB_INTERNAL 2 /* don't store on disk */ +#define TDB_NOLOCK 4 /* don't do any locking */ +#define TDB_NOMMAP 8 /* don't use mmap */ +#define TDB_CONVERT 16 /* convert endian (internal use) */ +#define TDB_BIGENDIAN 32 /* header is big-endian (internal use) */ + +#define TDB_ERRCODE(code, ret) ((tdb->ecode = (code)), ret) + +/* error codes */ +enum TDB_ERROR {TDB_SUCCESS=0, TDB_ERR_CORRUPT, TDB_ERR_IO, TDB_ERR_LOCK, + TDB_ERR_OOM, TDB_ERR_EXISTS, TDB_ERR_NOLOCK, TDB_ERR_LOCK_TIMEOUT, + TDB_ERR_NOEXIST}; + +#ifndef u32 +#define u32 unsigned +#endif + +typedef struct TDB_DATA { + char *dptr; + size_t dsize; +} TDB_DATA; + +typedef u32 tdb_len; +typedef u32 tdb_off; + +/* this is stored at the front of every database */ +struct tdb_header { + char magic_food[32]; /* for /etc/magic */ + u32 version; /* version of the code */ + u32 hash_size; /* number of hash entries */ + tdb_off rwlocks; + tdb_off reserved[31]; +}; + +struct tdb_lock_type { + u32 count; + u32 ltype; +}; + +struct tdb_traverse_lock { + struct tdb_traverse_lock *next; + u32 off; + u32 hash; +}; + +/* this is the context structure that is returned from a db open */ +typedef struct tdb_context { + char *name; /* the name of the database */ + void *map_ptr; /* where it is currently mapped */ + int fd; /* open file descriptor for the database */ + tdb_len map_size; /* how much space has been mapped */ + int read_only; /* opened read-only */ + struct tdb_lock_type *locked; /* array of chain locks */ + enum TDB_ERROR ecode; /* error code for last tdb error */ + struct tdb_header header; /* a cached copy of the header */ + u32 flags; /* the flags passed to tdb_open */ + u32 *lockedkeys; /* array of locked keys: first is #keys */ + struct tdb_traverse_lock travlocks; /* current traversal locks */ + struct tdb_context *next; /* all tdbs to avoid multiple opens */ + dev_t device; /* uniquely identifies this tdb */ + ino_t inode; /* uniquely identifies this tdb */ + void (*log_fn)(struct tdb_context *tdb, int level, const char *, ...); /* logging function */ + int open_flags; /* flags used in the open - needed by reopen */ +} TDB_CONTEXT; + +void tdb_debug(TDB_CONTEXT *, int , const char *, ...); + +typedef int (*tdb_traverse_func)(TDB_CONTEXT *, TDB_DATA, TDB_DATA, void *); +typedef void (*tdb_log_func)(TDB_CONTEXT *, int , const char *, ...); + +TDB_CONTEXT *tdb_open(const char *name, int hash_size, int tdb_flags, + int open_flags, mode_t mode); +TDB_CONTEXT *tdb_open_ex(const char *name, int hash_size, int tdb_flags, + int open_flags, mode_t mode, + tdb_log_func log_fn); + +int tdb_reopen(TDB_CONTEXT *tdb); +int tdb_reopen_all(void); +void tdb_logging_function(TDB_CONTEXT *tdb, tdb_log_func); +enum TDB_ERROR tdb_error(TDB_CONTEXT *tdb); +const char *tdb_errorstr(TDB_CONTEXT *tdb); +TDB_DATA tdb_fetch(TDB_CONTEXT *tdb, TDB_DATA key); +int tdb_delete(TDB_CONTEXT *tdb, TDB_DATA key); +int tdb_store(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA dbuf, int flag); +int tdb_append(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA new_dbuf); +int tdb_close(TDB_CONTEXT *tdb); +TDB_DATA tdb_firstkey(TDB_CONTEXT *tdb); +TDB_DATA tdb_nextkey(TDB_CONTEXT *tdb, TDB_DATA key); +int tdb_traverse(TDB_CONTEXT *tdb, tdb_traverse_func fn, void *); +int tdb_exists(TDB_CONTEXT *tdb, TDB_DATA key); +int tdb_lockkeys(TDB_CONTEXT *tdb, u32 number, TDB_DATA keys[]); +void tdb_unlockkeys(TDB_CONTEXT *tdb); +int tdb_lockall(TDB_CONTEXT *tdb); +void tdb_unlockall(TDB_CONTEXT *tdb); + +/* Low level locking functions: use with care */ +void tdb_set_lock_alarm(sig_atomic_t *palarm); +int tdb_chainlock(TDB_CONTEXT *tdb, TDB_DATA key); +int tdb_chainunlock(TDB_CONTEXT *tdb, TDB_DATA key); + +/* Debug functions. Not used in production. */ +void tdb_dump_all(TDB_CONTEXT *tdb); +int tdb_printfreelist(TDB_CONTEXT *tdb); + +extern TDB_DATA tdb_null; + +#ifdef __cplusplus +} +#endif + +#endif /* tdb.h */ diff --git a/source4/lib/tdb/include/tdbutil.h b/source4/lib/tdb/include/tdbutil.h new file mode 100644 index 0000000000..01473446a1 --- /dev/null +++ b/source4/lib/tdb/include/tdbutil.h @@ -0,0 +1,37 @@ +/* + Unix SMB/CIFS implementation. + tdb utility functions + Copyright (C) Andrew Tridgell 1999 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#ifndef __TDBUTIL_H__ +#define __TDBUTIL_H__ + + +/* single node of a list returned by tdb_search_keys */ +typedef struct keys_node +{ + struct keys_node *prev, *next; + TDB_DATA node_key; +} TDB_LIST_NODE; + + +TDB_LIST_NODE *tdb_search_keys(TDB_CONTEXT*, const char*); +void tdb_search_list_free(TDB_LIST_NODE*); + + +#endif /* __TDBUTIL_H__ */ -- cgit From fa2e9ec311b99dee2fbff5ee5fa2c743298dacad Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 1 Jun 2004 08:12:45 +0000 Subject: r960: convert 'unsigned int' to uint_t in the most places metze (This used to be commit 18062d2ed9fc9224c43143c10efbf2f6f1f5bbe0) --- source4/lib/tdb/include/spinlock.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/tdb/include') diff --git a/source4/lib/tdb/include/spinlock.h b/source4/lib/tdb/include/spinlock.h index 967fe37457..1255d455de 100644 --- a/source4/lib/tdb/include/spinlock.h +++ b/source4/lib/tdb/include/spinlock.h @@ -36,7 +36,7 @@ typedef struct { int tdb_spinlock(TDB_CONTEXT *tdb, int list, int rw_type); int tdb_spinunlock(TDB_CONTEXT *tdb, int list, int rw_type); -int tdb_create_rwlocks(int fd, unsigned int hash_size); +int tdb_create_rwlocks(int fd, uint_t hash_size); int tdb_clear_spinlocks(TDB_CONTEXT *tdb); #define TDB_SPINLOCK_SIZE(hash_size) (((hash_size) + 1) * sizeof(tdb_rwlock_t)) @@ -49,7 +49,7 @@ int tdb_clear_spinlocks(TDB_CONTEXT *tdb); #else int tdb_spinlock(TDB_CONTEXT *tdb, int list, int rw_type); int tdb_spinunlock(TDB_CONTEXT *tdb, int list, int rw_type); -int tdb_create_rwlocks(int fd, unsigned int hash_size); +int tdb_create_rwlocks(int fd, uint_t hash_size); #endif int tdb_clear_spinlocks(TDB_CONTEXT *tdb); #define TDB_SPINLOCK_SIZE(hash_size) 0 -- cgit From b619abb98e0c9384f75586a56e63fd3a1fc6badb Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 7 Jun 2004 01:51:04 +0000 Subject: r1053: Make tdb build standalone: - #include - uint_t isn't a valid type, change back to unsigned int (This used to be commit f690325565d2393bba3cb9f6e7cdf3753cbd4423) --- source4/lib/tdb/include/spinlock.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/tdb/include') diff --git a/source4/lib/tdb/include/spinlock.h b/source4/lib/tdb/include/spinlock.h index 1255d455de..967fe37457 100644 --- a/source4/lib/tdb/include/spinlock.h +++ b/source4/lib/tdb/include/spinlock.h @@ -36,7 +36,7 @@ typedef struct { int tdb_spinlock(TDB_CONTEXT *tdb, int list, int rw_type); int tdb_spinunlock(TDB_CONTEXT *tdb, int list, int rw_type); -int tdb_create_rwlocks(int fd, uint_t hash_size); +int tdb_create_rwlocks(int fd, unsigned int hash_size); int tdb_clear_spinlocks(TDB_CONTEXT *tdb); #define TDB_SPINLOCK_SIZE(hash_size) (((hash_size) + 1) * sizeof(tdb_rwlock_t)) @@ -49,7 +49,7 @@ int tdb_clear_spinlocks(TDB_CONTEXT *tdb); #else int tdb_spinlock(TDB_CONTEXT *tdb, int list, int rw_type); int tdb_spinunlock(TDB_CONTEXT *tdb, int list, int rw_type); -int tdb_create_rwlocks(int fd, uint_t hash_size); +int tdb_create_rwlocks(int fd, unsigned int hash_size); #endif int tdb_clear_spinlocks(TDB_CONTEXT *tdb); #define TDB_SPINLOCK_SIZE(hash_size) 0 -- cgit From 85d8d24d3dd5e84c465050a2440d9a21c970c826 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 25 Aug 2004 01:12:59 +0000 Subject: r2034: Allow user-selectable hash functions on open only. Jeremy. (This used to be commit b43320ee5c9ac14c330e61ae62e0786b088e04fa) --- source4/lib/tdb/include/tdb.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source4/lib/tdb/include') diff --git a/source4/lib/tdb/include/tdb.h b/source4/lib/tdb/include/tdb.h index 73a0ea8f83..02b89087a8 100644 --- a/source4/lib/tdb/include/tdb.h +++ b/source4/lib/tdb/include/tdb.h @@ -102,6 +102,7 @@ typedef struct tdb_context { dev_t device; /* uniquely identifies this tdb */ ino_t inode; /* uniquely identifies this tdb */ void (*log_fn)(struct tdb_context *tdb, int level, const char *, ...); /* logging function */ + u32 (*hash_fn)(TDB_DATA *key); int open_flags; /* flags used in the open - needed by reopen */ } TDB_CONTEXT; @@ -109,12 +110,14 @@ void tdb_debug(TDB_CONTEXT *, int , const char *, ...); typedef int (*tdb_traverse_func)(TDB_CONTEXT *, TDB_DATA, TDB_DATA, void *); typedef void (*tdb_log_func)(TDB_CONTEXT *, int , const char *, ...); +typedef u32 (*tdb_hash_func)(TDB_DATA *key); TDB_CONTEXT *tdb_open(const char *name, int hash_size, int tdb_flags, int open_flags, mode_t mode); TDB_CONTEXT *tdb_open_ex(const char *name, int hash_size, int tdb_flags, int open_flags, mode_t mode, - tdb_log_func log_fn); + tdb_log_func log_fn, + tdb_hash_func hash_fn); int tdb_reopen(TDB_CONTEXT *tdb); int tdb_reopen_all(void); -- cgit From 8fa455d815ff4ad3bda57d1c7b683adfe04efd85 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 7 Sep 2004 13:44:49 +0000 Subject: r2238: the tdb_debug() function was totally bogus - remove it (you can't convert a ... varargs function to a va_list by just a cast!!) also mark the tdb log function with PRINTF_ATTRIBUTE() and fixed some bad format errors in tdb.c that jim found. (This used to be commit c26c92eb8f538748fcbb2ae5a0a8a02bffbbbf86) --- source4/lib/tdb/include/tdb.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'source4/lib/tdb/include') diff --git a/source4/lib/tdb/include/tdb.h b/source4/lib/tdb/include/tdb.h index 02b89087a8..ed8c247b08 100644 --- a/source4/lib/tdb/include/tdb.h +++ b/source4/lib/tdb/include/tdb.h @@ -101,13 +101,11 @@ typedef struct tdb_context { struct tdb_context *next; /* all tdbs to avoid multiple opens */ dev_t device; /* uniquely identifies this tdb */ ino_t inode; /* uniquely identifies this tdb */ - void (*log_fn)(struct tdb_context *tdb, int level, const char *, ...); /* logging function */ + void (*log_fn)(struct tdb_context *tdb, int level, const char *, ...) PRINTF_ATTRIBUTE(3,4); /* logging function */ u32 (*hash_fn)(TDB_DATA *key); int open_flags; /* flags used in the open - needed by reopen */ } TDB_CONTEXT; -void tdb_debug(TDB_CONTEXT *, int , const char *, ...); - typedef int (*tdb_traverse_func)(TDB_CONTEXT *, TDB_DATA, TDB_DATA, void *); typedef void (*tdb_log_func)(TDB_CONTEXT *, int , const char *, ...); typedef u32 (*tdb_hash_func)(TDB_DATA *key); -- cgit From 787b65b048f2079c51a8f3e8ad36fcd5cde39f12 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 22 Sep 2004 05:12:21 +0000 Subject: r2493: allow tdb to build standalone (This used to be commit 0d5af5b70bd010e7107b18f73a4b899e05c4f025) --- source4/lib/tdb/include/tdb.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source4/lib/tdb/include') diff --git a/source4/lib/tdb/include/tdb.h b/source4/lib/tdb/include/tdb.h index ed8c247b08..6f4f3235a7 100644 --- a/source4/lib/tdb/include/tdb.h +++ b/source4/lib/tdb/include/tdb.h @@ -85,6 +85,10 @@ struct tdb_traverse_lock { u32 hash; }; +#ifndef PRINTF_ATTRIBUTE +#define PRINTF_ATTRIBUTE(a,b) +#endif + /* this is the context structure that is returned from a db open */ typedef struct tdb_context { char *name; /* the name of the database */ -- cgit From 83928ac670bb17d4a1a8204d52468e5cca7c03d6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 15 Oct 2004 06:41:35 +0000 Subject: r2985: got rid of the unused tdb_lockkeys() and tdb_unlockkeys() functions they have been broken for 4 years (ever since they were added) and have been never used, which makes them prime candidates for destruction. (This used to be commit 0b53ab85aae4569c04495f07c18a65fd6b47bf4c) --- source4/lib/tdb/include/tdb.h | 3 --- 1 file changed, 3 deletions(-) (limited to 'source4/lib/tdb/include') diff --git a/source4/lib/tdb/include/tdb.h b/source4/lib/tdb/include/tdb.h index 6f4f3235a7..416333f0b0 100644 --- a/source4/lib/tdb/include/tdb.h +++ b/source4/lib/tdb/include/tdb.h @@ -100,7 +100,6 @@ typedef struct tdb_context { enum TDB_ERROR ecode; /* error code for last tdb error */ struct tdb_header header; /* a cached copy of the header */ u32 flags; /* the flags passed to tdb_open */ - u32 *lockedkeys; /* array of locked keys: first is #keys */ struct tdb_traverse_lock travlocks; /* current traversal locks */ struct tdb_context *next; /* all tdbs to avoid multiple opens */ dev_t device; /* uniquely identifies this tdb */ @@ -135,8 +134,6 @@ TDB_DATA tdb_firstkey(TDB_CONTEXT *tdb); TDB_DATA tdb_nextkey(TDB_CONTEXT *tdb, TDB_DATA key); int tdb_traverse(TDB_CONTEXT *tdb, tdb_traverse_func fn, void *); int tdb_exists(TDB_CONTEXT *tdb, TDB_DATA key); -int tdb_lockkeys(TDB_CONTEXT *tdb, u32 number, TDB_DATA keys[]); -void tdb_unlockkeys(TDB_CONTEXT *tdb); int tdb_lockall(TDB_CONTEXT *tdb); void tdb_unlockall(TDB_CONTEXT *tdb); -- cgit From 852228e8c67f2dc29a8402ae94998f562878c15f Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 31 Jan 2005 16:46:48 +0000 Subject: r5143: don't generate prototypes for lib/tdb/ metze (This used to be commit 1c48c30aaf58d069cdba2f59b5c012bc4bdd3efc) --- source4/lib/tdb/include/tdb.h | 2 ++ source4/lib/tdb/include/tdbutil.h | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'source4/lib/tdb/include') diff --git a/source4/lib/tdb/include/tdb.h b/source4/lib/tdb/include/tdb.h index 416333f0b0..f53503a1d6 100644 --- a/source4/lib/tdb/include/tdb.h +++ b/source4/lib/tdb/include/tdb.h @@ -141,6 +141,8 @@ void tdb_unlockall(TDB_CONTEXT *tdb); void tdb_set_lock_alarm(sig_atomic_t *palarm); int tdb_chainlock(TDB_CONTEXT *tdb, TDB_DATA key); int tdb_chainunlock(TDB_CONTEXT *tdb, TDB_DATA key); +int tdb_chainlock_read(TDB_CONTEXT *tdb, TDB_DATA key); +int tdb_chainunlock_read(TDB_CONTEXT *tdb, TDB_DATA key); /* Debug functions. Not used in production. */ void tdb_dump_all(TDB_CONTEXT *tdb); diff --git a/source4/lib/tdb/include/tdbutil.h b/source4/lib/tdb/include/tdbutil.h index 01473446a1..cfa83bd937 100644 --- a/source4/lib/tdb/include/tdbutil.h +++ b/source4/lib/tdb/include/tdbutil.h @@ -32,6 +32,14 @@ typedef struct keys_node TDB_LIST_NODE *tdb_search_keys(TDB_CONTEXT*, const char*); void tdb_search_list_free(TDB_LIST_NODE*); - +int32_t tdb_change_int32_atomic(TDB_CONTEXT *tdb, const char *keystr, int32_t *oldval, int32_t change_val); +int tdb_lock_bystring(TDB_CONTEXT *tdb, const char *keyval, uint_t timeout); +void tdb_unlock_bystring(TDB_CONTEXT *tdb, const char *keyval); +int32_t tdb_fetch_int32(TDB_CONTEXT *tdb, const char *keystr); +int tdb_store_int32(TDB_CONTEXT *tdb, const char *keystr, int32_t v); +int tdb_traverse_delete_fn(TDB_CONTEXT *the_tdb, TDB_DATA key, TDB_DATA dbuf, + void *state); +int tdb_store_bystring(TDB_CONTEXT *tdb, const char *keystr, TDB_DATA data, int flags); +TDB_DATA tdb_fetch_bystring(TDB_CONTEXT *tdb, const char *keystr); #endif /* __TDBUTIL_H__ */ -- cgit From fedf0b0d91fdf2a6ae0ef47acd4047f662bd3374 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 10 Feb 2005 03:48:43 +0000 Subject: r5296: - only include the tdb headers where they are needed - removed the u32 hack in events.c as I think this was only needed as tdb.h defines u32. Metze, can you check that this hack is indeed no longer needed on your suse system? (This used to be commit 6f79432fe656164d4770dbce114a30dda5e7bf9a) --- source4/lib/tdb/include/tdb.h | 2 ++ source4/lib/tdb/include/tdbutil.h | 2 ++ 2 files changed, 4 insertions(+) (limited to 'source4/lib/tdb/include') diff --git a/source4/lib/tdb/include/tdb.h b/source4/lib/tdb/include/tdb.h index f53503a1d6..1de5517d91 100644 --- a/source4/lib/tdb/include/tdb.h +++ b/source4/lib/tdb/include/tdb.h @@ -154,4 +154,6 @@ extern TDB_DATA tdb_null; } #endif +#include "spinlock.h" + #endif /* tdb.h */ diff --git a/source4/lib/tdb/include/tdbutil.h b/source4/lib/tdb/include/tdbutil.h index cfa83bd937..80d93b7984 100644 --- a/source4/lib/tdb/include/tdbutil.h +++ b/source4/lib/tdb/include/tdbutil.h @@ -21,6 +21,8 @@ #ifndef __TDBUTIL_H__ #define __TDBUTIL_H__ +#include "tdb.h" + /* single node of a list returned by tdb_search_keys */ typedef struct keys_node -- cgit From 639edc4097d1d5f011ce642b97b522ac4cb8b4ae Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 13 Mar 2005 01:40:45 +0000 Subject: r5779: Remove signal and timeout gubbage from tdb. (This used to be commit dbb56e9a59cf00d57b09ded6d60bf9424d5f1f4c) --- source4/lib/tdb/include/tdb.h | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/lib/tdb/include') diff --git a/source4/lib/tdb/include/tdb.h b/source4/lib/tdb/include/tdb.h index 1de5517d91..846b157758 100644 --- a/source4/lib/tdb/include/tdb.h +++ b/source4/lib/tdb/include/tdb.h @@ -138,7 +138,6 @@ int tdb_lockall(TDB_CONTEXT *tdb); void tdb_unlockall(TDB_CONTEXT *tdb); /* Low level locking functions: use with care */ -void tdb_set_lock_alarm(sig_atomic_t *palarm); int tdb_chainlock(TDB_CONTEXT *tdb, TDB_DATA key); int tdb_chainunlock(TDB_CONTEXT *tdb, TDB_DATA key); int tdb_chainlock_read(TDB_CONTEXT *tdb, TDB_DATA key); -- cgit From 03cd26e353b74d88b02ce36dc73932452a7b3715 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 13 Mar 2005 02:20:51 +0000 Subject: r5780: Remove unused arguments. (This used to be commit 1ee84e373e2b44c96f9353f194b766d6a144e7ce) --- source4/lib/tdb/include/tdbutil.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/tdb/include') diff --git a/source4/lib/tdb/include/tdbutil.h b/source4/lib/tdb/include/tdbutil.h index 80d93b7984..fb9e5cf48f 100644 --- a/source4/lib/tdb/include/tdbutil.h +++ b/source4/lib/tdb/include/tdbutil.h @@ -35,7 +35,7 @@ typedef struct keys_node TDB_LIST_NODE *tdb_search_keys(TDB_CONTEXT*, const char*); void tdb_search_list_free(TDB_LIST_NODE*); int32_t tdb_change_int32_atomic(TDB_CONTEXT *tdb, const char *keystr, int32_t *oldval, int32_t change_val); -int tdb_lock_bystring(TDB_CONTEXT *tdb, const char *keyval, uint_t timeout); +int tdb_lock_bystring(TDB_CONTEXT *tdb, const char *keyval); void tdb_unlock_bystring(TDB_CONTEXT *tdb, const char *keyval); int32_t tdb_fetch_int32(TDB_CONTEXT *tdb, const char *keystr); int tdb_store_int32(TDB_CONTEXT *tdb, const char *keystr, int32_t v); -- cgit From 7de12a8d50ebb5ead2c44b9d726bb134dc8919b6 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 21 Aug 2005 15:45:16 +0000 Subject: r9448: Work on reading the secrets tdb. Build tdbsam support by default. (This used to be commit 9ea601c0a675767f8ea5f316c9355572dffbc4c0) --- source4/lib/tdb/include/tdbutil.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/lib/tdb/include') diff --git a/source4/lib/tdb/include/tdbutil.h b/source4/lib/tdb/include/tdbutil.h index fb9e5cf48f..0d86ddc993 100644 --- a/source4/lib/tdb/include/tdbutil.h +++ b/source4/lib/tdb/include/tdbutil.h @@ -43,5 +43,7 @@ int tdb_traverse_delete_fn(TDB_CONTEXT *the_tdb, TDB_DATA key, TDB_DATA dbuf, void *state); int tdb_store_bystring(TDB_CONTEXT *tdb, const char *keystr, TDB_DATA data, int flags); TDB_DATA tdb_fetch_bystring(TDB_CONTEXT *tdb, const char *keystr); +int tdb_unpack(TDB_CONTEXT *tdb, char *buf, int bufsize, const char *fmt, ...); +size_t tdb_pack(TDB_CONTEXT *tdb, char *buf, int bufsize, const char *fmt, ...); #endif /* __TDBUTIL_H__ */ -- cgit From 6e388c27d86d77f2c7f9414fbb152c246ca53022 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 21 Aug 2005 20:01:10 +0000 Subject: r9455: Support for reading the policy database (This used to be commit 7548a5012aad41bde0652d4532d184545997be86) --- source4/lib/tdb/include/tdbutil.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/lib/tdb/include') diff --git a/source4/lib/tdb/include/tdbutil.h b/source4/lib/tdb/include/tdbutil.h index 0d86ddc993..2f7c0ec234 100644 --- a/source4/lib/tdb/include/tdbutil.h +++ b/source4/lib/tdb/include/tdbutil.h @@ -38,7 +38,9 @@ int32_t tdb_change_int32_atomic(TDB_CONTEXT *tdb, const char *keystr, int32_t *o int tdb_lock_bystring(TDB_CONTEXT *tdb, const char *keyval); void tdb_unlock_bystring(TDB_CONTEXT *tdb, const char *keyval); int32_t tdb_fetch_int32(TDB_CONTEXT *tdb, const char *keystr); +BOOL tdb_store_uint32(TDB_CONTEXT *tdb, const char *keystr, uint32_t value); int tdb_store_int32(TDB_CONTEXT *tdb, const char *keystr, int32_t v); +BOOL tdb_fetch_uint32(TDB_CONTEXT *tdb, const char *keystr, uint32_t *value); int tdb_traverse_delete_fn(TDB_CONTEXT *the_tdb, TDB_DATA key, TDB_DATA dbuf, void *state); int tdb_store_bystring(TDB_CONTEXT *tdb, const char *keystr, TDB_DATA data, int flags); -- cgit From 0868b7c77d42efd5f361f605bfc0d8d46841db95 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 16 Sep 2005 03:52:42 +0000 Subject: r10253: a fairly large tdb cleanup and re-organise. Nearly all of this change just involves splitting up the core tdb.c code into separate files on logical boundaries, but there are some minor functional changes as well: - move the 'struct tdb_context' into tdb_private.h, hiding it from users. This was done to allow the structure to change without breaking code that uses tdb. - added accessor functions tdb_fd(), tdb_name(), and tdb_log_fn() to access the elements of struct tdb_context that were used by external code but are no longer visible - simplied tdb_append() to use tdb_fetch()/tdb_store(), which is just as good due to the way tdb locks work - changed some of the types (such as tdb_off to tdb_off_t) to make syntax highlighting work better - removed the old optional spinlock code. It was a bad idea. - fixed a bug in tdb_reopen_all() that caused tdbtorture to sometimes fail or report nasty looking errors. This is the only real bug fixed in this commit. Jeremy/Jerry, you might like to pickup this change for Samba3, as that could definately affect smbd in Samba3. The aim of all of these changes is to make the tdb transactions/journaling code I am working on easier to write. I started to write it on top of the existing tdb.c code and it got very messy. Splitting up the code makes it much easier to follow. There are more cleanups we could do in tdb, such as using uint32_t instead of u32 (suggested by metze). I'll leave those for another day. (This used to be commit 4673cdd0d261614e707b72a7a348bb0e7dbb2482) --- source4/lib/tdb/include/spinlock.h | 59 ------------------ source4/lib/tdb/include/tdb.h | 109 ++++++++++----------------------- source4/lib/tdb/include/tdbconfig.h.in | 19 ++++++ source4/lib/tdb/include/tdbutil.h | 27 ++++---- 4 files changed, 65 insertions(+), 149 deletions(-) delete mode 100644 source4/lib/tdb/include/spinlock.h create mode 100644 source4/lib/tdb/include/tdbconfig.h.in (limited to 'source4/lib/tdb/include') diff --git a/source4/lib/tdb/include/spinlock.h b/source4/lib/tdb/include/spinlock.h deleted file mode 100644 index 967fe37457..0000000000 --- a/source4/lib/tdb/include/spinlock.h +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef __SPINLOCK_H__ -#define __SPINLOCK_H__ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "tdb.h" - -#ifdef USE_SPINLOCKS - -#define RWLOCK_BIAS 0x1000UL - -/* OS SPECIFIC */ -#define MAX_BUSY_LOOPS 1000 -#undef USE_SCHED_YIELD - -/* ARCH SPECIFIC */ -/* We should make sure these are padded to a cache line */ -#if defined(SPARC_SPINLOCKS) -typedef volatile char spinlock_t; -#elif defined(POWERPC_SPINLOCKS) -typedef volatile unsigned long spinlock_t; -#elif defined(INTEL_SPINLOCKS) -typedef volatile int spinlock_t; -#elif defined(MIPS_SPINLOCKS) -typedef volatile unsigned long spinlock_t; -#else -#error Need to implement spinlock code in spinlock.h -#endif - -typedef struct { - spinlock_t lock; - volatile int count; -} tdb_rwlock_t; - -int tdb_spinlock(TDB_CONTEXT *tdb, int list, int rw_type); -int tdb_spinunlock(TDB_CONTEXT *tdb, int list, int rw_type); -int tdb_create_rwlocks(int fd, unsigned int hash_size); -int tdb_clear_spinlocks(TDB_CONTEXT *tdb); - -#define TDB_SPINLOCK_SIZE(hash_size) (((hash_size) + 1) * sizeof(tdb_rwlock_t)) - -#else /* !USE_SPINLOCKS */ -#if 0 -#define tdb_create_rwlocks(fd, hash_size) 0 -#define tdb_spinlock(tdb, list, rw_type) (-1) -#define tdb_spinunlock(tdb, list, rw_type) (-1) -#else -int tdb_spinlock(TDB_CONTEXT *tdb, int list, int rw_type); -int tdb_spinunlock(TDB_CONTEXT *tdb, int list, int rw_type); -int tdb_create_rwlocks(int fd, unsigned int hash_size); -#endif -int tdb_clear_spinlocks(TDB_CONTEXT *tdb); -#define TDB_SPINLOCK_SIZE(hash_size) 0 - -#endif - -#endif diff --git a/source4/lib/tdb/include/tdb.h b/source4/lib/tdb/include/tdb.h index 846b157758..cc3f3c18d8 100644 --- a/source4/lib/tdb/include/tdb.h +++ b/source4/lib/tdb/include/tdb.h @@ -53,99 +53,58 @@ enum TDB_ERROR {TDB_SUCCESS=0, TDB_ERR_CORRUPT, TDB_ERR_IO, TDB_ERR_LOCK, TDB_ERR_OOM, TDB_ERR_EXISTS, TDB_ERR_NOLOCK, TDB_ERR_LOCK_TIMEOUT, TDB_ERR_NOEXIST}; -#ifndef u32 -#define u32 unsigned -#endif - typedef struct TDB_DATA { - char *dptr; + unsigned char *dptr; size_t dsize; } TDB_DATA; -typedef u32 tdb_len; -typedef u32 tdb_off; - -/* this is stored at the front of every database */ -struct tdb_header { - char magic_food[32]; /* for /etc/magic */ - u32 version; /* version of the code */ - u32 hash_size; /* number of hash entries */ - tdb_off rwlocks; - tdb_off reserved[31]; -}; - -struct tdb_lock_type { - u32 count; - u32 ltype; -}; - -struct tdb_traverse_lock { - struct tdb_traverse_lock *next; - u32 off; - u32 hash; -}; - #ifndef PRINTF_ATTRIBUTE #define PRINTF_ATTRIBUTE(a,b) #endif /* this is the context structure that is returned from a db open */ -typedef struct tdb_context { - char *name; /* the name of the database */ - void *map_ptr; /* where it is currently mapped */ - int fd; /* open file descriptor for the database */ - tdb_len map_size; /* how much space has been mapped */ - int read_only; /* opened read-only */ - struct tdb_lock_type *locked; /* array of chain locks */ - enum TDB_ERROR ecode; /* error code for last tdb error */ - struct tdb_header header; /* a cached copy of the header */ - u32 flags; /* the flags passed to tdb_open */ - struct tdb_traverse_lock travlocks; /* current traversal locks */ - struct tdb_context *next; /* all tdbs to avoid multiple opens */ - dev_t device; /* uniquely identifies this tdb */ - ino_t inode; /* uniquely identifies this tdb */ - void (*log_fn)(struct tdb_context *tdb, int level, const char *, ...) PRINTF_ATTRIBUTE(3,4); /* logging function */ - u32 (*hash_fn)(TDB_DATA *key); - int open_flags; /* flags used in the open - needed by reopen */ -} TDB_CONTEXT; - -typedef int (*tdb_traverse_func)(TDB_CONTEXT *, TDB_DATA, TDB_DATA, void *); -typedef void (*tdb_log_func)(TDB_CONTEXT *, int , const char *, ...); -typedef u32 (*tdb_hash_func)(TDB_DATA *key); - -TDB_CONTEXT *tdb_open(const char *name, int hash_size, int tdb_flags, +typedef struct tdb_context TDB_CONTEXT; + +typedef int (*tdb_traverse_func)(struct tdb_context *, TDB_DATA, TDB_DATA, void *); +typedef void (*tdb_log_func)(struct tdb_context *, int , const char *, ...); +typedef unsigned int (*tdb_hash_func)(TDB_DATA *key); + +struct tdb_context *tdb_open(const char *name, int hash_size, int tdb_flags, int open_flags, mode_t mode); -TDB_CONTEXT *tdb_open_ex(const char *name, int hash_size, int tdb_flags, +struct tdb_context *tdb_open_ex(const char *name, int hash_size, int tdb_flags, int open_flags, mode_t mode, tdb_log_func log_fn, tdb_hash_func hash_fn); -int tdb_reopen(TDB_CONTEXT *tdb); +int tdb_reopen(struct tdb_context *tdb); int tdb_reopen_all(void); -void tdb_logging_function(TDB_CONTEXT *tdb, tdb_log_func); -enum TDB_ERROR tdb_error(TDB_CONTEXT *tdb); -const char *tdb_errorstr(TDB_CONTEXT *tdb); -TDB_DATA tdb_fetch(TDB_CONTEXT *tdb, TDB_DATA key); -int tdb_delete(TDB_CONTEXT *tdb, TDB_DATA key); -int tdb_store(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA dbuf, int flag); -int tdb_append(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA new_dbuf); -int tdb_close(TDB_CONTEXT *tdb); -TDB_DATA tdb_firstkey(TDB_CONTEXT *tdb); -TDB_DATA tdb_nextkey(TDB_CONTEXT *tdb, TDB_DATA key); -int tdb_traverse(TDB_CONTEXT *tdb, tdb_traverse_func fn, void *); -int tdb_exists(TDB_CONTEXT *tdb, TDB_DATA key); -int tdb_lockall(TDB_CONTEXT *tdb); -void tdb_unlockall(TDB_CONTEXT *tdb); +void tdb_logging_function(struct tdb_context *tdb, tdb_log_func); +enum TDB_ERROR tdb_error(struct tdb_context *tdb); +const char *tdb_errorstr(struct tdb_context *tdb); +TDB_DATA tdb_fetch(struct tdb_context *tdb, TDB_DATA key); +int tdb_delete(struct tdb_context *tdb, TDB_DATA key); +int tdb_store(struct tdb_context *tdb, TDB_DATA key, TDB_DATA dbuf, int flag); +int tdb_append(struct tdb_context *tdb, TDB_DATA key, TDB_DATA new_dbuf); +int tdb_close(struct tdb_context *tdb); +TDB_DATA tdb_firstkey(struct tdb_context *tdb); +TDB_DATA tdb_nextkey(struct tdb_context *tdb, TDB_DATA key); +int tdb_traverse(struct tdb_context *tdb, tdb_traverse_func fn, void *); +int tdb_exists(struct tdb_context *tdb, TDB_DATA key); +int tdb_lockall(struct tdb_context *tdb); +void tdb_unlockall(struct tdb_context *tdb); +const char *tdb_name(struct tdb_context *tdb); +int tdb_fd(struct tdb_context *tdb); +tdb_log_func tdb_log_fn(struct tdb_context *tdb); /* Low level locking functions: use with care */ -int tdb_chainlock(TDB_CONTEXT *tdb, TDB_DATA key); -int tdb_chainunlock(TDB_CONTEXT *tdb, TDB_DATA key); -int tdb_chainlock_read(TDB_CONTEXT *tdb, TDB_DATA key); -int tdb_chainunlock_read(TDB_CONTEXT *tdb, TDB_DATA key); +int tdb_chainlock(struct tdb_context *tdb, TDB_DATA key); +int tdb_chainunlock(struct tdb_context *tdb, TDB_DATA key); +int tdb_chainlock_read(struct tdb_context *tdb, TDB_DATA key); +int tdb_chainunlock_read(struct tdb_context *tdb, TDB_DATA key); /* Debug functions. Not used in production. */ -void tdb_dump_all(TDB_CONTEXT *tdb); -int tdb_printfreelist(TDB_CONTEXT *tdb); +void tdb_dump_all(struct tdb_context *tdb); +int tdb_printfreelist(struct tdb_context *tdb); extern TDB_DATA tdb_null; @@ -153,6 +112,4 @@ extern TDB_DATA tdb_null; } #endif -#include "spinlock.h" - #endif /* tdb.h */ diff --git a/source4/lib/tdb/include/tdbconfig.h.in b/source4/lib/tdb/include/tdbconfig.h.in new file mode 100644 index 0000000000..c4f42af803 --- /dev/null +++ b/source4/lib/tdb/include/tdbconfig.h.in @@ -0,0 +1,19 @@ +/* include/tdbconfig.h.in. Generated automatically from configure.in by autoheader 2.13. */ + +/* Define if you have a working `mmap' system call. */ +#undef HAVE_MMAP + +/* Define if you have the getpagesize function. */ +#undef HAVE_GETPAGESIZE + +/* Define if you have the mmap function. */ +#undef HAVE_MMAP + +/* Define if you have the pread function. */ +#undef HAVE_PREAD + +/* Define if you have the pwrite function. */ +#undef HAVE_PWRITE + +/* Define if you have the header file. */ +#undef HAVE_UNISTD_H diff --git a/source4/lib/tdb/include/tdbutil.h b/source4/lib/tdb/include/tdbutil.h index 2f7c0ec234..02802c958d 100644 --- a/source4/lib/tdb/include/tdbutil.h +++ b/source4/lib/tdb/include/tdbutil.h @@ -23,7 +23,6 @@ #include "tdb.h" - /* single node of a list returned by tdb_search_keys */ typedef struct keys_node { @@ -32,20 +31,20 @@ typedef struct keys_node } TDB_LIST_NODE; -TDB_LIST_NODE *tdb_search_keys(TDB_CONTEXT*, const char*); +TDB_LIST_NODE *tdb_search_keys(struct tdb_context*, const char*); void tdb_search_list_free(TDB_LIST_NODE*); -int32_t tdb_change_int32_atomic(TDB_CONTEXT *tdb, const char *keystr, int32_t *oldval, int32_t change_val); -int tdb_lock_bystring(TDB_CONTEXT *tdb, const char *keyval); -void tdb_unlock_bystring(TDB_CONTEXT *tdb, const char *keyval); -int32_t tdb_fetch_int32(TDB_CONTEXT *tdb, const char *keystr); -BOOL tdb_store_uint32(TDB_CONTEXT *tdb, const char *keystr, uint32_t value); -int tdb_store_int32(TDB_CONTEXT *tdb, const char *keystr, int32_t v); -BOOL tdb_fetch_uint32(TDB_CONTEXT *tdb, const char *keystr, uint32_t *value); -int tdb_traverse_delete_fn(TDB_CONTEXT *the_tdb, TDB_DATA key, TDB_DATA dbuf, +int32_t tdb_change_int32_atomic(struct tdb_context *tdb, const char *keystr, int32_t *oldval, int32_t change_val); +int tdb_lock_bystring(struct tdb_context *tdb, const char *keyval); +void tdb_unlock_bystring(struct tdb_context *tdb, const char *keyval); +int32_t tdb_fetch_int32(struct tdb_context *tdb, const char *keystr); +BOOL tdb_store_uint32(struct tdb_context *tdb, const char *keystr, uint32_t value); +int tdb_store_int32(struct tdb_context *tdb, const char *keystr, int32_t v); +BOOL tdb_fetch_uint32(struct tdb_context *tdb, const char *keystr, uint32_t *value); +int tdb_traverse_delete_fn(struct tdb_context *the_tdb, TDB_DATA key, TDB_DATA dbuf, void *state); -int tdb_store_bystring(TDB_CONTEXT *tdb, const char *keystr, TDB_DATA data, int flags); -TDB_DATA tdb_fetch_bystring(TDB_CONTEXT *tdb, const char *keystr); -int tdb_unpack(TDB_CONTEXT *tdb, char *buf, int bufsize, const char *fmt, ...); -size_t tdb_pack(TDB_CONTEXT *tdb, char *buf, int bufsize, const char *fmt, ...); +int tdb_store_bystring(struct tdb_context *tdb, const char *keystr, TDB_DATA data, int flags); +TDB_DATA tdb_fetch_bystring(struct tdb_context *tdb, const char *keystr); +int tdb_unpack(struct tdb_context *tdb, char *buf, int bufsize, const char *fmt, ...); +size_t tdb_pack(struct tdb_context *tdb, char *buf, int bufsize, const char *fmt, ...); #endif /* __TDBUTIL_H__ */ -- cgit From ede8415d61b6791114c65de1c283a4e8c11f1585 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 22 Sep 2005 03:56:41 +0000 Subject: r10405: added transactions into tdb, and hook them into ldb. See my samba-technical posting for more details on the transactions design. This also adds a number of command line arguments to tdbtorture, making it more flexible, and fixes some lock deadlock conditions in the tdbtorture code. (This used to be commit 06bd8abba942ec9f1e23f5c5d546cbb71ca3a701) --- source4/lib/tdb/include/tdb.h | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'source4/lib/tdb/include') diff --git a/source4/lib/tdb/include/tdb.h b/source4/lib/tdb/include/tdb.h index cc3f3c18d8..3f123d814c 100644 --- a/source4/lib/tdb/include/tdb.h +++ b/source4/lib/tdb/include/tdb.h @@ -45,13 +45,14 @@ extern "C" { #define TDB_NOMMAP 8 /* don't use mmap */ #define TDB_CONVERT 16 /* convert endian (internal use) */ #define TDB_BIGENDIAN 32 /* header is big-endian (internal use) */ +#define TDB_NOSYNC 64 /* don't use synchronous transactions */ #define TDB_ERRCODE(code, ret) ((tdb->ecode = (code)), ret) /* error codes */ enum TDB_ERROR {TDB_SUCCESS=0, TDB_ERR_CORRUPT, TDB_ERR_IO, TDB_ERR_LOCK, TDB_ERR_OOM, TDB_ERR_EXISTS, TDB_ERR_NOLOCK, TDB_ERR_LOCK_TIMEOUT, - TDB_ERR_NOEXIST}; + TDB_ERR_NOEXIST, TDB_ERR_EINVAL}; typedef struct TDB_DATA { unsigned char *dptr; @@ -59,7 +60,15 @@ typedef struct TDB_DATA { } TDB_DATA; #ifndef PRINTF_ATTRIBUTE -#define PRINTF_ATTRIBUTE(a,b) +#if (__GNUC__ >= 3) +/** Use gcc attribute to check printf fns. a1 is the 1-based index of + * the parameter containing the format, and a2 the index of the first + * argument. Note that some gcc 2.x versions don't handle this + * properly **/ +#define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (__printf__, a1, a2))) +#else +#define PRINTF_ATTRIBUTE(a1, a2) +#endif #endif /* this is the context structure that is returned from a db open */ @@ -95,6 +104,10 @@ void tdb_unlockall(struct tdb_context *tdb); const char *tdb_name(struct tdb_context *tdb); int tdb_fd(struct tdb_context *tdb); tdb_log_func tdb_log_fn(struct tdb_context *tdb); +int tdb_transaction_start(struct tdb_context *tdb); +int tdb_transaction_commit(struct tdb_context *tdb); +int tdb_transaction_cancel(struct tdb_context *tdb); +int tdb_transaction_recover(struct tdb_context *tdb); /* Low level locking functions: use with care */ int tdb_chainlock(struct tdb_context *tdb, TDB_DATA key); -- cgit From bd310b792509f7305d7dc029eb4bec109322a4bf Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 22 Sep 2005 13:12:46 +0000 Subject: r10421: following on discussions with simo, I have worked out a way of allowing searches to proceed while another process is in a transaction, then only upgrading the transaction lock to a write lock on commit. The solution is: - split tdb_traverse() into two calls, called tdb_traverse() and tdb_traverse_read(). The _read() version only gets read locks, and will fail any write operations made in the callback from the traverse. - the normal tdb_traverse() call allows for read or write operations in the callback, but gets the transaction lock, preventing transastions from starting inside the traverse In addition we enforce the following rule that you may not start a transaction within a traverse callback, although you can start a traverse within a transaction With these rules in place I believe all the deadlock possibilities are removed, and we can now allow for searches to happen in parallel with transactions (This used to be commit 7dd31288a701d772e45b1960ac4ce4cc1be782ed) --- source4/lib/tdb/include/tdb.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/lib/tdb/include') diff --git a/source4/lib/tdb/include/tdb.h b/source4/lib/tdb/include/tdb.h index 3f123d814c..c116f29fc1 100644 --- a/source4/lib/tdb/include/tdb.h +++ b/source4/lib/tdb/include/tdb.h @@ -52,7 +52,7 @@ extern "C" { /* error codes */ enum TDB_ERROR {TDB_SUCCESS=0, TDB_ERR_CORRUPT, TDB_ERR_IO, TDB_ERR_LOCK, TDB_ERR_OOM, TDB_ERR_EXISTS, TDB_ERR_NOLOCK, TDB_ERR_LOCK_TIMEOUT, - TDB_ERR_NOEXIST, TDB_ERR_EINVAL}; + TDB_ERR_NOEXIST, TDB_ERR_EINVAL, TDB_ERR_RDONLY}; typedef struct TDB_DATA { unsigned char *dptr; @@ -98,6 +98,7 @@ int tdb_close(struct tdb_context *tdb); TDB_DATA tdb_firstkey(struct tdb_context *tdb); TDB_DATA tdb_nextkey(struct tdb_context *tdb, TDB_DATA key); int tdb_traverse(struct tdb_context *tdb, tdb_traverse_func fn, void *); +int tdb_traverse_read(struct tdb_context *tdb, tdb_traverse_func fn, void *); int tdb_exists(struct tdb_context *tdb, TDB_DATA key); int tdb_lockall(struct tdb_context *tdb); void tdb_unlockall(struct tdb_context *tdb); -- cgit From 5c9590587197dcb95007fdc54318187d5716c7c6 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Tue, 8 Nov 2005 00:11:45 +0000 Subject: r11567: Ldb API change patch. This patch changes the way lsb_search is called and the meaning of the returned integer. The last argument of ldb_search is changed from struct ldb_message to struct ldb_result which contains a pointer to a struct ldb_message list and a count of the number of messages. The return is not the count of messages anymore but instead it is an ldb error value. I tryed to keep the patch as tiny as possible bu as you can guess I had to change a good amount of places. I also tried to double check all my changes being sure that the calling functions would still behave as before. But this patch is big enough that I fear some bug may have been introduced anyway even if it passes the test suite. So if you are currently working on any file being touched please give it a deep look and blame me for any error. Simo. (This used to be commit 22c8c97e6fb466b41859e090e959d7f1134be780) --- source4/lib/tdb/include/tdbconfig.h.in | 57 ++++++++++++++++++++++++++++------ 1 file changed, 48 insertions(+), 9 deletions(-) (limited to 'source4/lib/tdb/include') diff --git a/source4/lib/tdb/include/tdbconfig.h.in b/source4/lib/tdb/include/tdbconfig.h.in index c4f42af803..d6d2c09b3c 100644 --- a/source4/lib/tdb/include/tdbconfig.h.in +++ b/source4/lib/tdb/include/tdbconfig.h.in @@ -1,19 +1,58 @@ -/* include/tdbconfig.h.in. Generated automatically from configure.in by autoheader 2.13. */ +/* include/tdbconfig.h.in. Generated from configure.in by autoheader. */ -/* Define if you have a working `mmap' system call. */ -#undef HAVE_MMAP - -/* Define if you have the getpagesize function. */ +/* Define to 1 if you have the `getpagesize' function. */ #undef HAVE_GETPAGESIZE -/* Define if you have the mmap function. */ +/* Define to 1 if you have the header file. */ +#undef HAVE_INTTYPES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_MEMORY_H + +/* Define to 1 if you have the `mmap' function. */ #undef HAVE_MMAP -/* Define if you have the pread function. */ +/* Define to 1 if you have the `pread' function. */ #undef HAVE_PREAD -/* Define if you have the pwrite function. */ +/* Define to 1 if you have the `pwrite' function. */ #undef HAVE_PWRITE -/* Define if you have the header file. */ +/* Define to 1 if you have the header file. */ +#undef HAVE_STDINT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDLIB_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRING_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_STAT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION + +/* Define to 1 if you have the ANSI C header files. */ +#undef STDC_HEADERS -- cgit From 3434cd778c975eb1bb29d257770bd6dbb2335ce9 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 21 Mar 2006 11:47:24 +0000 Subject: r14616: added notify change support to the posix backend It doesn't fully work yet, and doesn't yet have all the efficiency that is planned, but it doesn't break anything and I wanted to get the code in the tree to minimise the chance of collisions with the work metze is doing. (This used to be commit 1624ea88e6eef89caacc36e7513aa79df0d579b9) --- source4/lib/tdb/include/tdbutil.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/tdb/include') diff --git a/source4/lib/tdb/include/tdbutil.h b/source4/lib/tdb/include/tdbutil.h index 02802c958d..26747373f4 100644 --- a/source4/lib/tdb/include/tdbutil.h +++ b/source4/lib/tdb/include/tdbutil.h @@ -44,6 +44,7 @@ int tdb_traverse_delete_fn(struct tdb_context *the_tdb, TDB_DATA key, TDB_DATA d void *state); int tdb_store_bystring(struct tdb_context *tdb, const char *keystr, TDB_DATA data, int flags); TDB_DATA tdb_fetch_bystring(struct tdb_context *tdb, const char *keystr); +int tdb_delete_bystring(struct tdb_context *tdb, const char *keystr); int tdb_unpack(struct tdb_context *tdb, char *buf, int bufsize, const char *fmt, ...); size_t tdb_pack(struct tdb_context *tdb, char *buf, int bufsize, const char *fmt, ...); -- cgit From 3387746c4517d6766146080980ac467b72b62316 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 30 Mar 2006 04:52:39 +0000 Subject: r14799: added a tdb_get_seqnum() call, and the TDB_SEQNUM flag. This allows for an extremely lightweight test to see if a tdb has possibly changed. (This used to be commit f325ba605ccceca63712c0f2c98961e35e437b3d) --- source4/lib/tdb/include/tdb.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/lib/tdb/include') diff --git a/source4/lib/tdb/include/tdb.h b/source4/lib/tdb/include/tdb.h index c116f29fc1..ddde17850b 100644 --- a/source4/lib/tdb/include/tdb.h +++ b/source4/lib/tdb/include/tdb.h @@ -46,6 +46,7 @@ extern "C" { #define TDB_CONVERT 16 /* convert endian (internal use) */ #define TDB_BIGENDIAN 32 /* header is big-endian (internal use) */ #define TDB_NOSYNC 64 /* don't use synchronous transactions */ +#define TDB_SEQNUM 128 /* maintain a sequence number */ #define TDB_ERRCODE(code, ret) ((tdb->ecode = (code)), ret) @@ -109,6 +110,7 @@ int tdb_transaction_start(struct tdb_context *tdb); int tdb_transaction_commit(struct tdb_context *tdb); int tdb_transaction_cancel(struct tdb_context *tdb); int tdb_transaction_recover(struct tdb_context *tdb); +int tdb_get_seqnum(struct tdb_context *tdb); /* Low level locking functions: use with care */ int tdb_chainlock(struct tdb_context *tdb, TDB_DATA key); -- cgit From fce0dcf2450f68fdc201152bdd063569bdcf1770 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 17 Apr 2006 11:42:59 +0000 Subject: r15100: Port the bugfix for #3569 to Samba4 (This used to be commit 5f1d52f232051324082b840f29dd7719a9328bd5) --- source4/lib/tdb/include/tdb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/tdb/include') diff --git a/source4/lib/tdb/include/tdb.h b/source4/lib/tdb/include/tdb.h index ddde17850b..4004c73460 100644 --- a/source4/lib/tdb/include/tdb.h +++ b/source4/lib/tdb/include/tdb.h @@ -87,7 +87,7 @@ struct tdb_context *tdb_open_ex(const char *name, int hash_size, int tdb_flags, tdb_hash_func hash_fn); int tdb_reopen(struct tdb_context *tdb); -int tdb_reopen_all(void); +int tdb_reopen_all(int parent_longlived); void tdb_logging_function(struct tdb_context *tdb, tdb_log_func); enum TDB_ERROR tdb_error(struct tdb_context *tdb); const char *tdb_errorstr(struct tdb_context *tdb); -- cgit From d3fee429aee87e9c05a4a606fbf0b60b16dac782 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 3 Jul 2006 06:40:56 +0000 Subject: r16774: This patch modifies the tdb API to allow the logging function to be used as part of ldb. This allows tdb failures to be passed all the way up to Samba's DEBUG system, which allowed easier debugging. Unfortunately I had to extend the tdb API, as the logging function didn't have a context pointer. I've worked over the 'debug levels' in TDB. Most of them were 0, which didn't seem right, as some were trace-like messages. We didn't see any of these previously, except when accessing TDB directly. Andrew Bartlett (This used to be commit 58898092c1ce043f6d698db5065f372b79109e22) --- source4/lib/tdb/include/tdb.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'source4/lib/tdb/include') diff --git a/source4/lib/tdb/include/tdb.h b/source4/lib/tdb/include/tdb.h index 4004c73460..785bbbe29b 100644 --- a/source4/lib/tdb/include/tdb.h +++ b/source4/lib/tdb/include/tdb.h @@ -55,6 +55,10 @@ enum TDB_ERROR {TDB_SUCCESS=0, TDB_ERR_CORRUPT, TDB_ERR_IO, TDB_ERR_LOCK, TDB_ERR_OOM, TDB_ERR_EXISTS, TDB_ERR_NOLOCK, TDB_ERR_LOCK_TIMEOUT, TDB_ERR_NOEXIST, TDB_ERR_EINVAL, TDB_ERR_RDONLY}; +/* debugging uses one of the following levels */ +enum tdb_debug_level {TDB_DEBUG_FATAL = 0, TDB_DEBUG_ERROR, + TDB_DEBUG_WARNING, TDB_DEBUG_TRACE}; + typedef struct TDB_DATA { unsigned char *dptr; size_t dsize; @@ -76,19 +80,20 @@ typedef struct TDB_DATA { typedef struct tdb_context TDB_CONTEXT; typedef int (*tdb_traverse_func)(struct tdb_context *, TDB_DATA, TDB_DATA, void *); -typedef void (*tdb_log_func)(struct tdb_context *, int , const char *, ...); +typedef void (*tdb_log_func)(struct tdb_context *, enum tdb_debug_level, const char *, ...) PRINTF_ATTRIBUTE(3, 4); typedef unsigned int (*tdb_hash_func)(TDB_DATA *key); struct tdb_context *tdb_open(const char *name, int hash_size, int tdb_flags, int open_flags, mode_t mode); struct tdb_context *tdb_open_ex(const char *name, int hash_size, int tdb_flags, int open_flags, mode_t mode, - tdb_log_func log_fn, + tdb_log_func log_fn, void *log_private, tdb_hash_func hash_fn); +void *tdb_logging_private(struct tdb_context *tdb); int tdb_reopen(struct tdb_context *tdb); int tdb_reopen_all(int parent_longlived); -void tdb_logging_function(struct tdb_context *tdb, tdb_log_func); +void tdb_logging_function(struct tdb_context *tdb, tdb_log_func log_fn, void *log_private); enum TDB_ERROR tdb_error(struct tdb_context *tdb); const char *tdb_errorstr(struct tdb_context *tdb); TDB_DATA tdb_fetch(struct tdb_context *tdb, TDB_DATA key); @@ -106,6 +111,7 @@ void tdb_unlockall(struct tdb_context *tdb); const char *tdb_name(struct tdb_context *tdb); int tdb_fd(struct tdb_context *tdb); tdb_log_func tdb_log_fn(struct tdb_context *tdb); +void *tdb_get_logging_private(struct tdb_context *tdb); int tdb_transaction_start(struct tdb_context *tdb); int tdb_transaction_commit(struct tdb_context *tdb); int tdb_transaction_cancel(struct tdb_context *tdb); -- cgit From 35fda6c5f344e71b1ed0bd195a62161e31401149 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 10 Jul 2006 12:51:36 +0000 Subject: r16916: Implement metze's proposed changes to the tdb logging API. This clearly links the log function with its private pointer, and makes the argument list for tdb_open_ex a bit shorter. Andrew Bartlett (This used to be commit 5d5503e8d8a10ead3ef21a5ffda52cadb9a07727) --- source4/lib/tdb/include/tdb.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'source4/lib/tdb/include') diff --git a/source4/lib/tdb/include/tdb.h b/source4/lib/tdb/include/tdb.h index 785bbbe29b..296a946c42 100644 --- a/source4/lib/tdb/include/tdb.h +++ b/source4/lib/tdb/include/tdb.h @@ -83,17 +83,21 @@ typedef int (*tdb_traverse_func)(struct tdb_context *, TDB_DATA, TDB_DATA, void typedef void (*tdb_log_func)(struct tdb_context *, enum tdb_debug_level, const char *, ...) PRINTF_ATTRIBUTE(3, 4); typedef unsigned int (*tdb_hash_func)(TDB_DATA *key); +struct tdb_logging_context { + tdb_log_func log_fn; + void *log_private; +}; + struct tdb_context *tdb_open(const char *name, int hash_size, int tdb_flags, int open_flags, mode_t mode); struct tdb_context *tdb_open_ex(const char *name, int hash_size, int tdb_flags, int open_flags, mode_t mode, - tdb_log_func log_fn, void *log_private, + const struct tdb_logging_context *log_ctx, tdb_hash_func hash_fn); -void *tdb_logging_private(struct tdb_context *tdb); int tdb_reopen(struct tdb_context *tdb); int tdb_reopen_all(int parent_longlived); -void tdb_logging_function(struct tdb_context *tdb, tdb_log_func log_fn, void *log_private); +void tdb_set_logging_function(struct tdb_context *tdb, const struct tdb_logging_context *log); enum TDB_ERROR tdb_error(struct tdb_context *tdb); const char *tdb_errorstr(struct tdb_context *tdb); TDB_DATA tdb_fetch(struct tdb_context *tdb, TDB_DATA key); -- cgit From 1779e80bfb0f7b6cd6e29ad66912c68ef05e87fe Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 14 Oct 2006 10:36:14 +0000 Subject: r19276: remove unused file metze (This used to be commit bd4cd24a9dc370552a90f267bdcabf4cb45c8507) --- source4/lib/tdb/include/tdbconfig.h.in | 58 ---------------------------------- 1 file changed, 58 deletions(-) delete mode 100644 source4/lib/tdb/include/tdbconfig.h.in (limited to 'source4/lib/tdb/include') diff --git a/source4/lib/tdb/include/tdbconfig.h.in b/source4/lib/tdb/include/tdbconfig.h.in deleted file mode 100644 index d6d2c09b3c..0000000000 --- a/source4/lib/tdb/include/tdbconfig.h.in +++ /dev/null @@ -1,58 +0,0 @@ -/* include/tdbconfig.h.in. Generated from configure.in by autoheader. */ - -/* Define to 1 if you have the `getpagesize' function. */ -#undef HAVE_GETPAGESIZE - -/* Define to 1 if you have the header file. */ -#undef HAVE_INTTYPES_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_MEMORY_H - -/* Define to 1 if you have the `mmap' function. */ -#undef HAVE_MMAP - -/* Define to 1 if you have the `pread' function. */ -#undef HAVE_PREAD - -/* Define to 1 if you have the `pwrite' function. */ -#undef HAVE_PWRITE - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDINT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDLIB_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STRINGS_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STRING_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_STAT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_TYPES_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_UNISTD_H - -/* Define to the address where bug reports for this package should be sent. */ -#undef PACKAGE_BUGREPORT - -/* Define to the full name of this package. */ -#undef PACKAGE_NAME - -/* Define to the full name and version of this package. */ -#undef PACKAGE_STRING - -/* Define to the one symbol short name of this package. */ -#undef PACKAGE_TARNAME - -/* Define to the version of this package. */ -#undef PACKAGE_VERSION - -/* Define to 1 if you have the ANSI C header files. */ -#undef STDC_HEADERS -- cgit From cba142f1ae71b03266210e254c251683846d7fd7 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 18 Oct 2006 21:41:59 +0000 Subject: r19401: make tdb_lockall() much more efficient, and add a tdb_lockall_read() call which does a read lock on all chains. These will be used to make ldb searches more efficient (This used to be commit de664ec1f8cf179f1d650563272c0de3f7636e2b) --- source4/lib/tdb/include/tdb.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source4/lib/tdb/include') diff --git a/source4/lib/tdb/include/tdb.h b/source4/lib/tdb/include/tdb.h index 296a946c42..af3792cbfe 100644 --- a/source4/lib/tdb/include/tdb.h +++ b/source4/lib/tdb/include/tdb.h @@ -111,7 +111,9 @@ int tdb_traverse(struct tdb_context *tdb, tdb_traverse_func fn, void *); int tdb_traverse_read(struct tdb_context *tdb, tdb_traverse_func fn, void *); int tdb_exists(struct tdb_context *tdb, TDB_DATA key); int tdb_lockall(struct tdb_context *tdb); -void tdb_unlockall(struct tdb_context *tdb); +int tdb_unlockall(struct tdb_context *tdb); +int tdb_lockall_read(struct tdb_context *tdb); +int tdb_unlockall_read(struct tdb_context *tdb); const char *tdb_name(struct tdb_context *tdb); int tdb_fd(struct tdb_context *tdb); tdb_log_func tdb_log_fn(struct tdb_context *tdb); -- cgit From 118c064a473562274bff8fb47f37437db904b8fb Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 20 Oct 2006 08:06:14 +0000 Subject: r19423: merge some tdb changes from SAMBA_3_0 to SAMBA_4_0 this is in preparation of a merge in the other direction (This used to be commit db3211079fd594aa03c3b9bb3eb6ad86bdd32837) --- source4/lib/tdb/include/tdb.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/tdb/include') diff --git a/source4/lib/tdb/include/tdb.h b/source4/lib/tdb/include/tdb.h index af3792cbfe..8a2110ba6e 100644 --- a/source4/lib/tdb/include/tdb.h +++ b/source4/lib/tdb/include/tdb.h @@ -123,6 +123,7 @@ int tdb_transaction_commit(struct tdb_context *tdb); int tdb_transaction_cancel(struct tdb_context *tdb); int tdb_transaction_recover(struct tdb_context *tdb); int tdb_get_seqnum(struct tdb_context *tdb); +int tdb_hash_size(struct tdb_context *tdb); /* Low level locking functions: use with care */ int tdb_chainlock(struct tdb_context *tdb, TDB_DATA key); -- cgit From d71502b07cc0d113f4555d244bef9f06024907e4 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 20 Oct 2006 09:48:18 +0000 Subject: r19425: two more tdb functions from samba3 (This used to be commit c9d9d79c34e8a36a6f684b173b1cc861330adc5c) --- source4/lib/tdb/include/tdb.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/lib/tdb/include') diff --git a/source4/lib/tdb/include/tdb.h b/source4/lib/tdb/include/tdb.h index 8a2110ba6e..4d29cece04 100644 --- a/source4/lib/tdb/include/tdb.h +++ b/source4/lib/tdb/include/tdb.h @@ -124,6 +124,8 @@ int tdb_transaction_cancel(struct tdb_context *tdb); int tdb_transaction_recover(struct tdb_context *tdb); int tdb_get_seqnum(struct tdb_context *tdb); int tdb_hash_size(struct tdb_context *tdb); +size_t tdb_map_size(struct tdb_context *tdb); +int tdb_get_flags(struct tdb_context *tdb); /* Low level locking functions: use with care */ int tdb_chainlock(struct tdb_context *tdb, TDB_DATA key); -- cgit From af870da6194b47c6cd09445c1e03832d00e951bb Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 20 Oct 2006 23:32:23 +0000 Subject: r19428: moved tdbutil.c from lib/tdb/common/ to lib/util/util_tdb.c tdbutil.c is Samba specific, so should not be part of the generic tdb library (This used to be commit 979dd24f5e44605fc1603b690913b8c31be7478f) --- source4/lib/tdb/include/tdbutil.h | 51 --------------------------------------- 1 file changed, 51 deletions(-) delete mode 100644 source4/lib/tdb/include/tdbutil.h (limited to 'source4/lib/tdb/include') diff --git a/source4/lib/tdb/include/tdbutil.h b/source4/lib/tdb/include/tdbutil.h deleted file mode 100644 index 26747373f4..0000000000 --- a/source4/lib/tdb/include/tdbutil.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - Unix SMB/CIFS implementation. - tdb utility functions - Copyright (C) Andrew Tridgell 1999 - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#ifndef __TDBUTIL_H__ -#define __TDBUTIL_H__ - -#include "tdb.h" - -/* single node of a list returned by tdb_search_keys */ -typedef struct keys_node -{ - struct keys_node *prev, *next; - TDB_DATA node_key; -} TDB_LIST_NODE; - - -TDB_LIST_NODE *tdb_search_keys(struct tdb_context*, const char*); -void tdb_search_list_free(TDB_LIST_NODE*); -int32_t tdb_change_int32_atomic(struct tdb_context *tdb, const char *keystr, int32_t *oldval, int32_t change_val); -int tdb_lock_bystring(struct tdb_context *tdb, const char *keyval); -void tdb_unlock_bystring(struct tdb_context *tdb, const char *keyval); -int32_t tdb_fetch_int32(struct tdb_context *tdb, const char *keystr); -BOOL tdb_store_uint32(struct tdb_context *tdb, const char *keystr, uint32_t value); -int tdb_store_int32(struct tdb_context *tdb, const char *keystr, int32_t v); -BOOL tdb_fetch_uint32(struct tdb_context *tdb, const char *keystr, uint32_t *value); -int tdb_traverse_delete_fn(struct tdb_context *the_tdb, TDB_DATA key, TDB_DATA dbuf, - void *state); -int tdb_store_bystring(struct tdb_context *tdb, const char *keystr, TDB_DATA data, int flags); -TDB_DATA tdb_fetch_bystring(struct tdb_context *tdb, const char *keystr); -int tdb_delete_bystring(struct tdb_context *tdb, const char *keystr); -int tdb_unpack(struct tdb_context *tdb, char *buf, int bufsize, const char *fmt, ...); -size_t tdb_pack(struct tdb_context *tdb, char *buf, int bufsize, const char *fmt, ...); - -#endif /* __TDBUTIL_H__ */ -- cgit From 9da0c020571d901569e552224bfedd8bedbf43ba Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 30 Nov 2006 03:25:07 +0000 Subject: r19960: Add code to check for loops in the free list. Should help us validate tdb's against corruption. Jeremy. (This used to be commit bd0710fa09799cb496b1f9f365c57c3b542445f3) --- source4/lib/tdb/include/tdb.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/tdb/include') diff --git a/source4/lib/tdb/include/tdb.h b/source4/lib/tdb/include/tdb.h index 4d29cece04..cbcaf9023c 100644 --- a/source4/lib/tdb/include/tdb.h +++ b/source4/lib/tdb/include/tdb.h @@ -136,6 +136,7 @@ int tdb_chainunlock_read(struct tdb_context *tdb, TDB_DATA key); /* Debug functions. Not used in production. */ void tdb_dump_all(struct tdb_context *tdb); int tdb_printfreelist(struct tdb_context *tdb); +int tdb_validate_freelist(struct tdb_context *tdb, int *pnum_entries); extern TDB_DATA tdb_null; -- cgit From eaaf246d4fa42df5e590ee5bfe54e672abd26b02 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 19 Feb 2007 11:45:33 +0000 Subject: r21445: Apply tdb_parse_record Tridges error return, merge to 3_0_25 and 4_0 (This used to be commit afe7d7855841066b88859976ac748cbf438a9a9f) --- source4/lib/tdb/include/tdb.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source4/lib/tdb/include') diff --git a/source4/lib/tdb/include/tdb.h b/source4/lib/tdb/include/tdb.h index cbcaf9023c..07a8160f10 100644 --- a/source4/lib/tdb/include/tdb.h +++ b/source4/lib/tdb/include/tdb.h @@ -101,6 +101,10 @@ void tdb_set_logging_function(struct tdb_context *tdb, const struct tdb_logging_ enum TDB_ERROR tdb_error(struct tdb_context *tdb); const char *tdb_errorstr(struct tdb_context *tdb); TDB_DATA tdb_fetch(struct tdb_context *tdb, TDB_DATA key); +int tdb_parse_record(struct tdb_context *tdb, TDB_DATA key, + int (*parser)(TDB_DATA key, TDB_DATA data, + void *private_data), + void *private_data); int tdb_delete(struct tdb_context *tdb, TDB_DATA key); int tdb_store(struct tdb_context *tdb, TDB_DATA key, TDB_DATA dbuf, int flag); int tdb_append(struct tdb_context *tdb, TDB_DATA key, TDB_DATA new_dbuf); -- cgit From 0aebd296cd6834567509d0b100d486f1ef4d104e Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 6 Mar 2007 10:11:15 +0000 Subject: r21722: Add the dead record functionality presented on samba-technical@samba.org. If you do a tdb_set_max_dead(tdb, n), then for this tdb a delete operation will only mark a record as dead and re-use it if a new record is created. The parameter n allows for at most n dead records per hash chain. If this number is exceeded, all dead records are put on the central freelist. Volker (This used to be commit 98a27ab28a3cd554e370a9a0e3652f4dea8749e9) --- source4/lib/tdb/include/tdb.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/tdb/include') diff --git a/source4/lib/tdb/include/tdb.h b/source4/lib/tdb/include/tdb.h index 07a8160f10..e54c9b8da2 100644 --- a/source4/lib/tdb/include/tdb.h +++ b/source4/lib/tdb/include/tdb.h @@ -94,6 +94,7 @@ struct tdb_context *tdb_open_ex(const char *name, int hash_size, int tdb_flags, int open_flags, mode_t mode, const struct tdb_logging_context *log_ctx, tdb_hash_func hash_fn); +void tdb_set_max_dead(struct tdb_context *tdb, int max_dead); int tdb_reopen(struct tdb_context *tdb); int tdb_reopen_all(int parent_longlived); -- cgit From 769efdf048d80c4081487d555649de0f31738dd1 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Apr 2007 18:56:25 +0000 Subject: r22041: merge trivial changes from samba3 metze (This used to be commit 902a76ca705f07c61f86a9ef1346583ba9d3157d) --- source4/lib/tdb/include/tdb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/tdb/include') diff --git a/source4/lib/tdb/include/tdb.h b/source4/lib/tdb/include/tdb.h index e54c9b8da2..dafe2a130e 100644 --- a/source4/lib/tdb/include/tdb.h +++ b/source4/lib/tdb/include/tdb.h @@ -98,7 +98,7 @@ void tdb_set_max_dead(struct tdb_context *tdb, int max_dead); int tdb_reopen(struct tdb_context *tdb); int tdb_reopen_all(int parent_longlived); -void tdb_set_logging_function(struct tdb_context *tdb, const struct tdb_logging_context *log); +void tdb_set_logging_function(struct tdb_context *tdb, const struct tdb_logging_context *log_ctx); enum TDB_ERROR tdb_error(struct tdb_context *tdb); const char *tdb_errorstr(struct tdb_context *tdb); TDB_DATA tdb_fetch(struct tdb_context *tdb, TDB_DATA key); -- cgit From 046870c023c950377c97c58e79ec730351a3fa97 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 21 Apr 2007 07:25:40 +0000 Subject: r22422: merged tdb changes from ctdb (This used to be commit a0ff739bcab32065d9d3957eb1d93f7791f84f04) --- source4/lib/tdb/include/tdb.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/tdb/include') diff --git a/source4/lib/tdb/include/tdb.h b/source4/lib/tdb/include/tdb.h index dafe2a130e..e77b78f7ed 100644 --- a/source4/lib/tdb/include/tdb.h +++ b/source4/lib/tdb/include/tdb.h @@ -134,6 +134,7 @@ int tdb_get_flags(struct tdb_context *tdb); /* Low level locking functions: use with care */ int tdb_chainlock(struct tdb_context *tdb, TDB_DATA key); +int tdb_chainlock_nonblock(struct tdb_context *tdb, TDB_DATA key); int tdb_chainunlock(struct tdb_context *tdb, TDB_DATA key); int tdb_chainlock_read(struct tdb_context *tdb, TDB_DATA key); int tdb_chainunlock_read(struct tdb_context *tdb, TDB_DATA key); -- cgit From a2b250258502907399dbbe9f738d4212c1b0618e Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 14 May 2007 01:00:06 +0000 Subject: r22832: merged the latest tdb changes from ctdb to Samba4 (This used to be commit a88ab4fa3a07c31bc45c612043f9e096f384eda4) --- source4/lib/tdb/include/tdb.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'source4/lib/tdb/include') diff --git a/source4/lib/tdb/include/tdb.h b/source4/lib/tdb/include/tdb.h index e77b78f7ed..9a9a4b489a 100644 --- a/source4/lib/tdb/include/tdb.h +++ b/source4/lib/tdb/include/tdb.h @@ -116,9 +116,13 @@ int tdb_traverse(struct tdb_context *tdb, tdb_traverse_func fn, void *); int tdb_traverse_read(struct tdb_context *tdb, tdb_traverse_func fn, void *); int tdb_exists(struct tdb_context *tdb, TDB_DATA key); int tdb_lockall(struct tdb_context *tdb); +int tdb_lockall_nonblock(struct tdb_context *tdb); int tdb_unlockall(struct tdb_context *tdb); int tdb_lockall_read(struct tdb_context *tdb); +int tdb_lockall_read_nonblock(struct tdb_context *tdb); int tdb_unlockall_read(struct tdb_context *tdb); +int tdb_lockall_mark(struct tdb_context *tdb); +int tdb_lockall_unmark(struct tdb_context *tdb); const char *tdb_name(struct tdb_context *tdb); int tdb_fd(struct tdb_context *tdb); tdb_log_func tdb_log_fn(struct tdb_context *tdb); @@ -131,6 +135,8 @@ int tdb_get_seqnum(struct tdb_context *tdb); int tdb_hash_size(struct tdb_context *tdb); size_t tdb_map_size(struct tdb_context *tdb); int tdb_get_flags(struct tdb_context *tdb); +void tdb_enable_seqnum(struct tdb_context *tdb); +void tdb_increment_seqnum_nonblock(struct tdb_context *tdb); /* Low level locking functions: use with care */ int tdb_chainlock(struct tdb_context *tdb, TDB_DATA key); @@ -138,6 +144,8 @@ int tdb_chainlock_nonblock(struct tdb_context *tdb, TDB_DATA key); int tdb_chainunlock(struct tdb_context *tdb, TDB_DATA key); int tdb_chainlock_read(struct tdb_context *tdb, TDB_DATA key); int tdb_chainunlock_read(struct tdb_context *tdb, TDB_DATA key); +int tdb_chainlock_mark(struct tdb_context *tdb, TDB_DATA key); +int tdb_chainlock_unmark(struct tdb_context *tdb, TDB_DATA key); /* Debug functions. Not used in production. */ void tdb_dump_all(struct tdb_context *tdb); -- cgit From b8d69a7ea2505b706ff7c74d7c97bc89d82dfa07 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 02:46:15 +0000 Subject: r23795: more v2->v3 conversion (This used to be commit 84b468b2f8f2dffda89593f816e8bc6a8b6d42ac) --- source4/lib/tdb/include/tdb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/tdb/include') diff --git a/source4/lib/tdb/include/tdb.h b/source4/lib/tdb/include/tdb.h index 9a9a4b489a..2788fd2aa0 100644 --- a/source4/lib/tdb/include/tdb.h +++ b/source4/lib/tdb/include/tdb.h @@ -15,7 +15,7 @@ This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. + version 3 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -- cgit From 6c973f4e8ccbcb6c9275f8a54e26abb19df7e15a Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 03:42:26 +0000 Subject: r23798: updated old Temple Place FSF addresses to new URL (This used to be commit 40c0919aaa9c1b14bbaebb95ecce53eb0380fdbb) --- source4/lib/tdb/include/tdb.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source4/lib/tdb/include') diff --git a/source4/lib/tdb/include/tdb.h b/source4/lib/tdb/include/tdb.h index 2788fd2aa0..fb59911ebe 100644 --- a/source4/lib/tdb/include/tdb.h +++ b/source4/lib/tdb/include/tdb.h @@ -23,8 +23,7 @@ Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + License along with this library; if not, see . */ #ifdef __cplusplus -- cgit From c94cba5b7bb0c1cc2cfb0eebc8efe0250de29e0a Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 20 Jul 2007 14:52:47 +0000 Subject: r23978: Merge r23161 from Samba3: Add TDB_VOLATILE as open_flag to activate the per-hashchain dead record optimization. (This used to be commit 868cdb1781fe94afbc1658e72bf06de20193bcd7) --- source4/lib/tdb/include/tdb.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/tdb/include') diff --git a/source4/lib/tdb/include/tdb.h b/source4/lib/tdb/include/tdb.h index fb59911ebe..f3a0dbe7bf 100644 --- a/source4/lib/tdb/include/tdb.h +++ b/source4/lib/tdb/include/tdb.h @@ -46,6 +46,7 @@ extern "C" { #define TDB_BIGENDIAN 32 /* header is big-endian (internal use) */ #define TDB_NOSYNC 64 /* don't use synchronous transactions */ #define TDB_SEQNUM 128 /* maintain a sequence number */ +#define TDB_VOLATILE 256 /* Activate the per-hashchain freelist, default 5 */ #define TDB_ERRCODE(code, ret) ((tdb->ecode = (code)), ret) -- cgit From 2cb22d93ae0eef86a4bcf0fe5f7fb138e43db880 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 7 Nov 2007 06:59:02 +0100 Subject: r25892: Keep the tdb code in sync between 3.2.x and 4.0. Add in the alarm fix to allow locks to exit on alarm signal. Sync up the changes in tools. Jeremy. (This used to be commit cb6c663fa8818f49cc36f196bb5f4dea47edd69e) --- source4/lib/tdb/include/tdb.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/lib/tdb/include') diff --git a/source4/lib/tdb/include/tdb.h b/source4/lib/tdb/include/tdb.h index f3a0dbe7bf..7de4c419a8 100644 --- a/source4/lib/tdb/include/tdb.h +++ b/source4/lib/tdb/include/tdb.h @@ -147,6 +147,8 @@ int tdb_chainunlock_read(struct tdb_context *tdb, TDB_DATA key); int tdb_chainlock_mark(struct tdb_context *tdb, TDB_DATA key); int tdb_chainlock_unmark(struct tdb_context *tdb, TDB_DATA key); +void tdb_setalarm_sigptr(struct tdb_context *tdb, volatile sig_atomic_t *sigptr); + /* Debug functions. Not used in production. */ void tdb_dump_all(struct tdb_context *tdb); int tdb_printfreelist(struct tdb_context *tdb); -- cgit From 9170998427ebbb7abfd9b482fb6e0d051bca5205 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 15 Jan 2008 14:05:47 +1100 Subject: merged tdb from ctdb bzr tree (This used to be commit ed0c3a0f74c305b3b8554b05c3f97cf79db8296a) --- source4/lib/tdb/include/tdb.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source4/lib/tdb/include') diff --git a/source4/lib/tdb/include/tdb.h b/source4/lib/tdb/include/tdb.h index 7de4c419a8..0058d55793 100644 --- a/source4/lib/tdb/include/tdb.h +++ b/source4/lib/tdb/include/tdb.h @@ -135,6 +135,8 @@ int tdb_get_seqnum(struct tdb_context *tdb); int tdb_hash_size(struct tdb_context *tdb); size_t tdb_map_size(struct tdb_context *tdb); int tdb_get_flags(struct tdb_context *tdb); +void tdb_add_flags(struct tdb_context *tdb, unsigned flag); +void tdb_remove_flags(struct tdb_context *tdb, unsigned flag); void tdb_enable_seqnum(struct tdb_context *tdb); void tdb_increment_seqnum_nonblock(struct tdb_context *tdb); @@ -153,6 +155,9 @@ void tdb_setalarm_sigptr(struct tdb_context *tdb, volatile sig_atomic_t *sigptr) void tdb_dump_all(struct tdb_context *tdb); int tdb_printfreelist(struct tdb_context *tdb); int tdb_validate_freelist(struct tdb_context *tdb, int *pnum_entries); +int tdb_wipe_all(struct tdb_context *tdb); +int tdb_freelist_size(struct tdb_context *tdb); +int tdb_validate(struct tdb_context *tdb); extern TDB_DATA tdb_null; -- cgit From 61a015a786c52008f4471e62750ad93507bce518 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 18 Jan 2008 15:45:22 +1100 Subject: merged changes from v3-2-test (This used to be commit 7077df3e2e3f171532f6a5ac87d45201736c9c11) --- source4/lib/tdb/include/tdb.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'source4/lib/tdb/include') diff --git a/source4/lib/tdb/include/tdb.h b/source4/lib/tdb/include/tdb.h index 0058d55793..0008085de5 100644 --- a/source4/lib/tdb/include/tdb.h +++ b/source4/lib/tdb/include/tdb.h @@ -32,9 +32,9 @@ extern "C" { /* flags to tdb_store() */ -#define TDB_REPLACE 1 -#define TDB_INSERT 2 -#define TDB_MODIFY 3 +#define TDB_REPLACE 1 /* Unused */ +#define TDB_INSERT 2 /* Don't overwrite an existing entry */ +#define TDB_MODIFY 3 /* Don't create an existing entry */ /* flags for tdb_open() */ #define TDB_DEFAULT 0 /* just a readability place holder */ @@ -157,7 +157,6 @@ int tdb_printfreelist(struct tdb_context *tdb); int tdb_validate_freelist(struct tdb_context *tdb, int *pnum_entries); int tdb_wipe_all(struct tdb_context *tdb); int tdb_freelist_size(struct tdb_context *tdb); -int tdb_validate(struct tdb_context *tdb); extern TDB_DATA tdb_null; -- cgit