1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00
Commit Graph

661 Commits

Author SHA1 Message Date
Kirill Smelkov
bdd6bef5dd pytdb: Add support for tdb_repack()
Cc: 597386@bugs.debian.org
Signed-off-by: Kirill Smelkov <kirr@landau.phys.spbu.ru>
Signed-off-by: Jelmer Vernooij <jelmer@samba.org>
2010-10-02 22:40:56 +02:00
Kirill Smelkov
a29142855e pytdb: Add TDB_INCOMPATIBLE_HASH open flag
In 2dcf76 Rusty added TDB_INCOMPATIBLE_HASH open flag which selects
Jenkins lookup3 hash for new databases.

Expose this flag to python users too.

Cc: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Kirill Smelkov <kirr@mns.spb.ru>
Signed-off-by: Jelmer Vernooij <jelmer@samba.org>
2010-10-02 22:36:52 +02:00
Rusty Russell
b7cd6af5b4 tdb: fix non-WAF build, commit 1.2.6 ABI file.
Sorry Jeremy.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2010-09-27 11:06:51 +09:30
Rusty Russell
2dcf76c924 tdb: TDB_INCOMPATIBLE_HASH, to allow safe changing of default hash.
This flag to tdb_open/tdb_open_ex effects creation of a new database:
1) Uses the Jenkins lookup3 hash instead of the old gdbm hash if none is
   specified,
2) Places a non-zero field in header->rwlocks, so older versions of TDB will
   refuse to open it.

This means that the caller (ie Samba) can set this flag to safely
change the hash function.  Versions of TDB from this one on will either
use the correct hash or refuse to open (if a different hash is specified).
Older TDB versions will see the nonzero rwlocks field and refuse to open
it under any conditions.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2010-09-27 10:48:28 +09:30
Rusty Russell
ccac258d14 tdb: automatically identify Jenkins hash tdbs
If the caller to tdb_open_ex() doesn't specify a hash, and tdb_old_hash
doesn't match, try tdb_jenkins_hash.

This was Metze's idea: it makes life simpler, especially with the upcoming
TDB_INCOMPATIBLE_HASH flag.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2010-09-27 10:48:28 +09:30
Rusty Russell
3258cf3f11 tdb: add Bob Jenkins lookup3 hash as helper hash.
This is a better hash than the default: shipping it with tdb makes it easy
for callers to use it as the hash by passing it to tdb_open_ex().

This version taken from CCAN and modified, which took it from
http://www.burtleburtle.net/bob/c/lookup3.c.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2010-09-27 10:48:28 +09:30
Volker Lendecke
66731461a6 tdb: add restore
Based on an idea by Simon McVittie, largely rewritten
2010-09-23 12:19:09 -07:00
Günther Deschner
1585c4df68 lib/tdb: fix c++ build warning in tdb_header_hash().
Guenther
2010-09-20 16:15:11 -07:00
Jelmer Vernooij
7a59c90189 pytdb: Make filename argument optional. 2010-09-19 10:42:29 -07:00
Kirill Smelkov
4c72655678 pytdb: Add support for tdb_freelist_size()
Cc: 597386@bugs.debian.org
Signed-off-by: Kirill Smelkov <kirr@landau.phys.spbu.ru>
Signed-off-by: Jelmer Vernooij <jelmer@samba.org>
2010-09-19 10:03:00 -07:00
Kirill Smelkov
b3314d6ad8 pytdb: Add support for tdb_transaction_prepare_commit()
Cc: 597386@bugs.debian.org
Signed-off-by: Kirill Smelkov <kirr@landau.phys.spbu.ru>
Signed-off-by: Jelmer Vernooij <jelmer@samba.org>
2010-09-19 09:35:43 -07:00
Kirill Smelkov
b826ef9697 pytdb: Add support for tdb_enable_seqnum, tdb_get_seqnum and tdb_increment_seqnum_nonblock
Cc: 597386@bugs.debian.org
Signed-off-by: Kirill Smelkov <kirr@landau.phys.spbu.ru>
Signed-off-by: Jelmer Vernooij <jelmer@samba.org>
2010-09-19 09:34:33 -07:00
Kirill Smelkov
a2621034e9 pytdb: Update open flags to match those for tdb_open() in tdb.h
Namely TDB_NOSYNC, TDB_SEQNUM, TDB_VOLATILE, TDB_ALLOW_NESTING and
TDB_DISALLOW_NESTING were missing.

Cc: 597386@bugs.debian.org
Signed-off-by: Kirill Smelkov <kirr@mns.spb.ru>
Signed-off-by: Jelmer Vernooij <jelmer@samba.org>
2010-09-19 09:31:34 -07:00
Kirill Smelkov
277a1b229c pytdb: Fix repr segfault for internal db
The problem was tdb->name is NULL for TDB_INTERNAL databases, and
so it was crashing ...

    #0  0xb76944f3 in strlen () from /lib/i686/cmov/libc.so.6
    #1  0x0809862b in PyString_FromFormatV (format=0xb72b6a26 "Tdb('%s')", vargs=0xbfc26a94 "")
        at ../Objects/stringobject.c:211
    #2  0x08098888 in PyString_FromFormat (format=0xb72b6a26 "Tdb('%s')") at ../Objects/stringobject.c:358
    #3  0xb72b65f2 in tdb_object_repr (self=0xb759e060) at ./pytdb.c:439

Cc: 597089@bugs.debian.org
Signed-off-by: Kirill Smelkov <kirr@mns.spb.ru>
Signed-off-by: Jelmer Vernooij <jelmer@samba.org>
2010-09-19 09:31:20 -07:00
Kirill Smelkov
c4b1971259 pytdb: Add support for tdb_add_flags() & tdb_remove_flags()
Note, unlike tdb_open where flags is `int', tdb_{add,remove}_flags want
flags as `unsigned', so instead of "i" I used "I" in PyArg_ParseTuple.

Cc: 597386@bugs.debian.org
Signed-off-by: Kirill Smelkov <kirr@mns.spb.ru>
Signed-off-by: Jelmer Vernooij <jelmer@samba.org>
2010-09-19 09:31:08 -07:00
Andrew Tridgell
ff515ff477 tdb: added TDB_NO_FSYNC env variable
this might help reduce test times and load on test machines
2010-09-16 21:09:17 +10:00
Stefan Metzmacher
4c3e6a59af tdb: add ABI/tdb-1.2.4.sigs
metze
2010-09-14 13:10:47 +02:00
Stefan Metzmacher
d10b2c07be lib/tdb: change version to 1.2.4 after hash checking improvments
lib/tdb: change version to 1.2.4 after hash checking improvments

metze

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2010-09-13 20:08:58 +09:30
Rusty Russell
786b726300 tdb: put example hashes into header, so we notice incorrect hash_fn.
This is Stefan Metzmacher <metze@samba.org>'s patch with minor changes:
1) Use the TDB_MAGIC constant so both hashes aren't of strings.
2) Check the hash in tdb_check (paranoia, really).
3) Additional check in the (unlikely!) case where both examples hash to 0.
4) Cosmetic changes to var names and complaint message.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2010-09-13 20:05:59 +09:30
Rusty Russell
f77708e962 tdb: fix tdb_check() on other-endian tdbs.
We must not endian-convert the magic string, just the rest.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2010-09-13 19:59:18 +09:30
Rusty Russell
82e5644c9d tdb: fix tdb_check() on read-only TDBs to actually work.
Commit bc1c82ea13 "Fix tdb_check() to work with read-only tdb databases."
claimed to do this, but tdb_lockall_read() fails on read-only databases.

Also make sure we can still do tdb_check() inside a transaction (weird,
but we previously allowed it so don't break the API).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2010-09-13 19:58:23 +09:30
Rusty Russell
9e0deff904 tdb: make check more robust against recovery failures.
We can end up with dead areas when we die during transaction commit;
tdb_check() fails on such a (valid) database.

This is particularly noticable now we no longer truncate on recovery;
if the recovery area was at the end of the file we used to remove it
that way.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2010-09-13 19:55:26 +09:30
Björn Jacke
20254221d2 tdb/waf: the deps for rt are provided by libreplace 2010-08-31 13:06:39 +02:00
Jelmer Vernooij
3dc7203713 Use DocBook DTD rather than Samba one, as no Samba-specific things are
used in the tdb manpages.
2010-08-22 14:05:58 +02:00
Rusty Russell
11ab43084b tdb: workaround starvation problem in locking entire database.
We saw tdb_lockall() take 71 seconds under heavy load; this is because Linux
(at least) doesn't prevent new small locks being obtained while we're waiting
for a big log.

The workaround is to do divide and conquer using non-blocking chainlocks: if
we get down to a single chain we block.  Using a simple test program where
children did "hold lock for 100ms, sleep for 1 second" the time to do
tdb_lockall() dropped signifiantly.  There are ln(hashsize) locks taken in
the contended case, but that's slow anyway.

More analysis is given in my blog at http://rusty.ozlabs.org/?p=120

This may also help transactions, though in that case it's the initial
read lock which uses this gradual locking routine; the update-to-write-lock
code is separate and still tries to update in one go.

Even though ABI doesn't change, minor version bumped so behavior change
can be easily detected.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2010-08-14 02:31:22 +09:30
Björn Jacke
5390baeb6b tdb: add TDB_DEPS variable filled with required libraries
This is required for Solaris, which needs to link in librt to make use of
fdatasync().
2010-08-13 14:57:44 +02:00
Jeremy Allison
bc1c82ea13 Fix tdb_check() to work with read-only tdb databases. The function tdb_lockall() uses F_WRLCK internally, which doesn't work on a fd opened with O_RDONLY. Use tdb_lockall_read() instead.
Jeremy.
2010-07-29 08:56:35 +09:30
Günther Deschner
f7a3bd4fa4 tdb: fix the build on mac os x 10.6.4.
Guenther
2010-07-01 23:14:57 +02:00
Andrew Tridgell
0be1820718 s4-ldb: use CHECK_XSLTPROC_MANPAGES() 2010-06-24 18:46:57 +10:00
Jelmer Vernooij
5e67566f5e pytdb: Cleanup formatting. 2010-06-19 22:46:44 +02:00
Jelmer Vernooij
bd1786f7f1 wafsamba: Fix typo: noextenion -> noextension. 2010-06-19 12:10:29 +02:00
Jelmer Vernooij
04fc459a30 tdb-waf: Don't install binaries when using system tdb. 2010-05-31 04:20:44 +02:00
Jelmer Vernooij
e6129bd596 tdb-waf: Simplify manpage handling. 2010-05-31 04:16:19 +02:00
Jelmer Vernooij
3858b5db8b s4-waf: sanitize library names like the old build system did, only add
-samba4 suffix for libraries that are bundled.
2010-05-31 03:28:42 +02:00
Stefan Metzmacher
b81887f2d9 tdb: commit ABI/tdb-1.2.2.sigs
metze
2010-05-11 18:11:05 +02:00
Günther Deschner
2eab1d7fdc tdb: remove unused variable in tdb_new_database().
Guenther
2010-05-11 13:41:17 +02:00
Rusty Russell
91e4a1760d tdb: fix short write logic in tdb_new_database
Commit 207a213c/24fed55d purported to fix the problem of signals during
tdb_new_database (which could cause a spurious short write, hence a failure).
However, the code is wrong: newdb+written is not correct.

Fix this by introducing a general tdb_write_all() and using it here and in
the tracing code.

Cc: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2010-05-05 15:37:18 +09:30
Andrew Tridgell
06fa4c8ebc build: make python development headers not mandatory in standalone libs
This needed an update to the python tool in waf

thanks to Kai for spotting this
2010-04-21 16:17:08 +10:00
Andrew Tridgell
773a8afbba tdb: update tdb ABI to use hide_symbols=True
We now use -fvisibilty=hidden to hide symbols from outside the tdb
shared library.

This also moved tdb_transaction_recover() into the tdb_private.h
header, as it should never have been a public API. For that reason we
are changing the version number. We're only doing a minor version
increment as it is extremely unlikely that anyone was actually using
tdb_transaction_recover() as its locking requirements were rather
unusual.

Pair-Programmed-With: Rusty Russell <rusty@samba.org>
2010-04-20 15:50:27 +10:00
Andrew Tridgell
f96353adcf s4-waf: rebuild signature files with the api type maps
This is not strictly necessary, as the old types would compare equal,
but it is neater to use the generic type names
2010-04-18 15:39:59 +10:00
Andrew Tridgell
805f651dbf tdb-waf: added ABI checking for tdb 2010-04-18 15:00:38 +10:00
Andrew Tridgell
c10d267a76 s4-waf: don't try to use the system lib for the library build
when building library FOO, don't try to find the system library FOO
    
Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>
2010-04-13 23:03:27 +10:00
Andrew Tridgell
367ba43b63 tdb-waf: added build of manpages and config options for RPM build
Building a RPM from the fedora spec file now works with minimal changes

Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>
2010-04-13 20:15:41 +10:00
Andrew Tridgell
98942c8d84 build: use a common autogen-waf.sh for all builds
the symlink will get updated with the right target when waf dist is
used in each directory
2010-04-12 11:17:35 +10:00
Jelmer Vernooij
7da94cc4a6 subunit: Support formatting compatible with upstream subunit, for consistency.
Upstream subunit makes a ":" after commands optional, so I've fixed any
places where we might trigger commands accidently. I've filed a bug
about this in subunit.
2010-04-11 20:57:33 +02:00
Andrew Tridgell
7ae4372124 s4-waf: fixed waf distcheck for our standalone libs and s4 2010-04-06 20:27:26 +10:00
Andrew Tridgell
fe060c8f50 s4-waf: added simple 'waf test' support for tdb, talloc and ldb 2010-04-06 20:27:26 +10:00
Andrew Tridgell
ccfce0bbae s4-waf: autogen-waf.sh for the standalone library builds 2010-04-06 20:27:25 +10:00
Andrew Tridgell
c8835f440a s4-waf: use a common pattern for finding buildtools and libs 2010-04-06 20:27:25 +10:00
Andrew Tridgell
553324bc10 s4-waf: move to a universal method of recursing into subdirs
This works with both standalone lib builds and bundled builds
2010-04-06 20:27:25 +10:00
Andrew Tridgell
8dc8d31f4a s4-waf: fixed finding of buildtools and srcdir 2010-04-06 20:27:25 +10:00
Andrew Tridgell
1883ee6dbc s4-waf: avoid having to run waf configure before waf dist
This should be useful for building tarballs from a clean checkout
2010-04-06 20:27:25 +10:00
Andrew Tridgell
9e9e878e8f s4-waf: allow standalone tarball build of libraries 2010-04-06 20:27:25 +10:00
Andrew Tridgell
528d7c7cf3 s4-waf: added 'waf dist' to our standalone libs as well 2010-04-06 20:27:25 +10:00
Andrew Tridgell
874e39cbf0 s4-waf: added implied_deps for system libraries
when we use a system version of a library such as talloc, then we
no longer get the automtica dependency propogation of talloc implying
libreplace. That means we don't get the includes for libreplace, which
means things can fail to build.

To fix this this change adds an implied_deps option to
CHECK_BUNDLED_SYSTEM(), which tells the samba_deps module to add an
implied dependency on the listed targets if the system library is
chosen.
2010-04-06 20:27:17 +10:00
Andrew Tridgell
bfbf43cc36 s4-waf: support the use of system libraries
distros can set --bundled-libraries=NONE to force use of all system
libraries. If the right version isn't found then configure will fail.

Users may choose which libraries to use from the system, and which to
use bundled libs. The default is to try system libs, and use them if
their version matches the one in the source tree.
2010-04-06 20:27:13 +10:00
Andrew Tridgell
c2d17cf978 s4-waf: set default for bundled libraries 2010-04-06 20:27:12 +10:00
Andrew Tridgell
42c9380760 s4-waf: set the bundled library extension for some libs 2010-04-06 20:27:12 +10:00
Andrew Tridgell
f9eae32f4b s4-waf: mark the wscript files as python so vim/emacs knows how to highlight them 2010-04-06 20:27:11 +10:00
Andrew Tridgell
8b14d217c4 s4-waf: fdatasync is in librt on solaris8 2010-04-06 20:27:08 +10:00
Andrew Tridgell
365f29136f build: only enable pytdb on s4 build 2010-04-06 20:26:51 +10:00
Andrew Tridgell
69fb313233 build: enable pytdb 2010-04-06 20:26:51 +10:00
Andrew Tridgell
7ed65d2e12 build: result of hack session with ita 2010-04-06 20:26:40 +10:00
Andrew Tridgell
5ad6369cd0 build: started to split up wafsamba.py into separate modules 2010-04-06 20:26:38 +10:00
Andrew Tridgell
a3421fe6e9 build: added BUILD_SUBDIR() wrapper 2010-04-06 20:26:35 +10:00
Andrew Tridgell
9a1cd09a10 build: added ADD_CFLAGS() and started of Samba4 build 2010-04-06 20:26:34 +10:00
Andrew Tridgell
0316ec1d89 build: tdb does not depend on talloc 2010-04-06 20:26:34 +10:00
Andrew Tridgell
2b5a1cc70c build: added waf build rules for ldb 2010-04-06 20:26:34 +10:00
Andrew Tridgell
8f062f4a0f build: neater way to find libreplace and start on tevent waf build 2010-04-06 20:26:33 +10:00
Andrew Tridgell
2bd0756dc5 build: more binaries for waf tdb build 2010-04-06 20:26:33 +10:00
Andrew Tridgell
8d6eb2a02c build: added waf build for tdb 2010-04-06 20:26:33 +10:00
Simo Sorce
c1f6f61f62 tdb: update exports and signatures files 2010-03-26 15:21:15 -04:00
Volker Lendecke
261c3b4f1b tdb: Add a non-blocking version of tdb_transaction_start 2010-03-26 14:27:47 -04:00
Volker Lendecke
59315887a0 tdb: Fix indentation in tdb_new_database() 2010-03-25 10:30:10 +01:00
Volker Lendecke
ea8e0d5d54 Fix some nonempty blank lines 2010-03-25 10:24:45 +01:00
Andrew Tridgell
088096d1ba python: use '#!/usr/bin/env python' to cope with varying install locations
this should be much more portable
2010-03-25 14:37:19 +11:00
Volker Lendecke
e2c7e5c4f7 tdb: Fix bug 7248, avoid the nanosleep dependency 2010-03-22 21:29:21 +01:00
Volker Lendecke
fb98f60594 tdb: If tdb_parse_record does not find a record, return -1 instead of 0 2010-02-28 17:40:59 +01:00
Rusty Russell
ec96ea690e tdb: handle processes dying during transaction commit.
tdb transactions were designed to be robust against the machine
powering off, but interestingly were never designed to handle the case
where an administrator kill -9's a process during commit.  Because
recovery is only done on tdb_open, processes with the tdb already
mapped will simply use it despite it being corrupt and needing
recovery.

The solution to this is to check for recovery every time we grab a
data lock: we could have gained the lock because a process just died.
This has no measurable cost: here is the time for tdbtorture -s 0 -n 1
-l 10000:

Before:
	2.75 2.50 2.81 3.19 2.91 2.53 2.72 2.50 2.78 2.77 = Avg 2.75

After:
	2.81 2.57 3.42 2.49 3.02 2.49 2.84 2.48 2.80 2.43 = Avg 2.74

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2010-02-24 13:23:58 +10:30
Rusty Russell
1bf482b9ef patch tdb-refactor-tdb_lock-and-tdb_lock_nonblock.patch 2010-02-24 13:18:06 +10:30
Rusty Russell
ececeffd85 tdb: add -k option to tdbtorture
To test the case of death of a process during transaction commit, add
a -k (kill random) option to tdbtorture.  The easiest way to do this
is to make every worker a child (unless there's only one child), which
is why this patch is bigger than you might expect.

Using -k without -t (always transactions) you expect corruption, though
it doesn't happen every time.  With -t, we currently get corruption but
the next patch fixes that.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2010-02-24 10:53:05 +10:30
Rusty Russell
8c3fda4318 tdb: don't truncate tdb on recovery
The current recovery code truncates the tdb file on recovery.  This is
fine if recovery is only done on first open, but is a really bad idea
as we move to allowing recovery on "live" databases.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2010-02-24 10:50:41 +10:30
Rusty Russell
9f295eecff tdb: remove lock ops
Now the transaction code uses the standard allrecord lock, that stops
us from trying to grab any per-record locks anyway.  We don't need to
have special noop lock ops for transactions.

This is a nice simplification: if you see brlock, you know it's really
going to grab a lock.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2010-02-24 10:49:22 +10:30
Rusty Russell
a84222bbaf tdb: rename tdb_release_extra_locks() to tdb_release_transaction_locks()
tdb_release_extra_locks() is too general: it carefully skips over the
transaction lock, even though the only caller then drops it.  Change
this, and rename it to show it's clearly transaction-specific.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2010-02-24 11:02:55 +10:30
Rusty Russell
dd1b508c63 tdb: cleanup: remove ltype argument from _tdb_transaction_cancel.
Now the transaction allrecord lock is the standard one, and thus is cleaned
in tdb_release_extra_locks(), _tdb_transaction_cancel() doesn't need to
know what type it is.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2010-02-24 12:42:24 +10:30
Rusty Russell
fca1621965 tdb: tdb_allrecord_lock/tdb_allrecord_unlock/tdb_allrecord_upgrade
Centralize locking of all chains of the tdb; rename _tdb_lockall to
tdb_allrecord_lock and _tdb_unlockall to tdb_allrecord_unlock, and
tdb_brlock_upgrade to tdb_allrecord_upgrade.

Then we use this in the transaction code.  Unfortunately, if the transaction
code records that it has grabbed the allrecord lock read-only, write locks
will fail, so we treat this upgradable lock as a write lock, and mark it
as upgradable using the otherwise-unused offset field.

One subtlety: now the transaction code is using the allrecord_lock, the
tdb_release_extra_locks() function drops it for us, so we no longer need
to do it manually in _tdb_transaction_cancel.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2010-02-17 15:42:15 +10:30
Rusty Russell
caaf5c6baa tdb: suppress record write locks when allrecord lock is taken.
Records themselves get (read) locked by the traversal code against delete.
Interestingly, this locking isn't done when the allrecord lock has been
taken, though the allrecord lock until recently didn't cover the actual
records (it now goes to end of file).

The write record lock, grabbed by the delete code, is not suppressed
by the allrecord lock.  This is now bad: it causes us to punch a hole
in the allrecord lock when we release the write record lock.  Make this
consistent: *no* record locks of any kind when the allrecord lock is
taken.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2010-02-24 10:45:26 +10:30
Rusty Russell
9341f230f8 tdb: cleanup: always grab allrecord lock to infinity.
We were previously inconsistent with our "global" lock: the
transaction code grabbed it from FREELIST_TOP to end of file, and the
rest of the code grabbed it from FREELIST_TOP to end of the hash
chains.  Change it to always grab to end of file for simplicity and
so we can merge the two.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2010-02-24 10:45:14 +10:30
Rusty Russell
1ab8776247 tdb: remove num_locks
This was redundant before this patch series: it mirrored num_lockrecs
exactly.  It still does.

Also, skip useless branch when locks == 1: unconditional assignment is
cheaper anyway.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2010-02-17 15:01:07 +10:30
Rusty Russell
d48c3e4982 tdb: use tdb_nest_lock() for seqnum lock.
This is pure overhead, but it centralizes the locking.  Realloc (esp. as
most implementations are lazy) is fast compared to the fnctl anyway.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2010-02-17 12:40:57 +10:30
Rusty Russell
4738d474c4 tdb: use tdb_nest_lock() for active lock.
Use our newly-generic nested lock tracking for the active lock.

Note that the tdb_have_extra_locks() and tdb_release_extra_locks()
functions have to skip over this lock now it is tracked.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2010-02-24 10:44:40 +10:30
Rusty Russell
9136818df3 tdb: use tdb_nest_lock() for open lock.
This never nests, so it's overkill, but it centralizes the locking into
lock.c and removes the ugly flag in the transaction code to track whether
we have the lock or not.

Note that we have a temporary hack so this places a real lock, despite
the fact that we are in a transaction.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2010-02-22 13:58:07 +10:30
Rusty Russell
e8fa70a321 tdb: use tdb_nest_lock() for transaction lock.
Rather than a boutique lock and a separate nest count, use our
newly-generic nested lock tracking for the transaction lock.

Note that the tdb_have_extra_locks() and tdb_release_extra_locks()
functions have to skip over this lock now it is tracked.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2010-02-17 12:37:34 +10:30
Rusty Russell
ce41411c84 tdb: cleanup: find_nestlock() helper.
Factor out two loops which find locks; we are going to introduce a couple
more so a helper makes sense.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2010-02-17 12:35:54 +10:30
Rusty Russell
db270734d8 tdb: cleanup: tdb_release_extra_locks() helper
Move locking intelligence back into lock.c, rather than open-coding the
lock release in transaction.c.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2010-02-24 10:41:15 +10:30
Rusty Russell
fba42f1fb4 tdb: cleanup: tdb_have_extra_locks() helper
In many places we check whether locks are held: add a helper to do this.

The _tdb_lockall() case has already checked for the allrecord lock, so
the extra work done by tdb_have_extra_locks() is merely redundant.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2010-02-17 12:34:26 +10:30
Rusty Russell
b754f61d23 tdb: don't suppress the transaction lock because of the allrecord lock.
tdb_transaction_lock() and tdb_transaction_unlock() do nothing if we
hold the allrecord lock.  However, the two locks don't overlap, so
this is wrong.

This simplification makes the transaction lock a straight-forward nested
lock.

There are two callers for these functions:
1) The transaction code, which already makes sure the allrecord_lock
   isn't held.
2) The traverse code, which wants to stop transactions whether it has the
   allrecord lock or not.  There have been deadlocks here before, however
   this should not bring them back (I hope!)

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2010-02-17 12:31:49 +10:30
Rusty Russell
5d9de604d9 tdb: cleanup: tdb_nest_lock/tdb_nest_unlock
Because fcntl locks don't nest, we track them in the tdb->lockrecs array
and only place/release them when the count goes to 1/0.  We only do this
for record locks, so we simply place the list number (or -1 for the free
list) in the structure.

To generalize this:

1) Put the offset rather than list number in struct tdb_lock_type.
2) Rename _tdb_lock() to tdb_nest_lock, make it non-static and move the
   allrecord check out to the callers (except the mark case which doesn't
   care).
3) Rename _tdb_unlock() to tdb_nest_unlock(), make it non-static and
   move the allrecord out to the callers (except mark again).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2010-02-17 12:26:13 +10:30
Rusty Russell
e9114a7585 tdb: cleanup: rename global_lock to allrecord_lock.
The word global is overloaded in tdb.  The global_lock inside struct
tdb_context is used to indicate we hold a lock across all the chains.

Rename it to allrecord_lock.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2010-02-17 12:19:47 +10:30
Rusty Russell
7ab422d6fb tdb: cleanup: rename GLOBAL_LOCK to OPEN_LOCK.
The word global is overloaded in tdb.  The GLOBAL_LOCK offset is used at
open time to serialize initialization (and by the transaction code to block
open).

Rename it to OPEN_LOCK.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2010-02-17 12:18:33 +10:30
Rusty Russell
a6e0ef87d2 tdb: make _tdb_transaction_cancel static.
Now tdb_open() calls tdb_transaction_cancel() instead of
_tdb_transaction_cancel, we can make it static.

Signed-off-by: Rusty Russell<rusty@rustcorp.com.au>
2010-02-24 10:39:59 +10:30
Rusty Russell
452b4a5a6e tdb: cleanup: split brlock and brunlock methods.
This is taken from the CCAN code base: rather than using tdb_brlock for
locking and unlocking, we split it into brlock and brunlock functions.

For extra debugging information, brunlock says what kind of lock it is
unlocking (even though fnctl locks don't need this).  This requires an
extra argument to tdb_transaction_unlock() so we know whether the
lock was upgraded to a write lock or not.

We also use a "flags" argument tdb_brlock:
1) TDB_LOCK_NOWAIT replaces lck_type = F_SETLK (vs F_SETLKW).
2) TDB_LOCK_MARK_ONLY replaces setting TDB_MARK_LOCK bit in ltype.
3) TDB_LOCK_PROBE replaces the "probe" argument.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2010-02-17 12:17:19 +10:30
Brad Hards
09e756b1d6 Spelling fixes for tdb.
Signed-off-by: Matthias Dieter Wallnöfer <mwallnoefer@yahoo.de>
2010-02-22 21:45:31 +01:00
Andrew Tridgell
1373e748aa tdb: use fdatasync() instead of fsync() in transactions
This might help on some filesystems
2010-02-13 22:36:11 +11:00
Volker Lendecke
6824c6f46b tdb: Apply some const, just for clarity 2010-02-13 12:19:09 +01:00
Rusty Russell
b37b452cb8 tdb: fix recovery reuse after crash
If a process (or the machine) dies after just after writing the
recovery head (pointing at the end of file), the recovery record will filled
with 0x42.  This will not invoke a recovery on open, since rec.magic
!= TDB_RECOVERY_MAGIC.

Unfortunately, the first transaction commit will happily reuse that
area: tdb_recovery_allocate() doesn't check the magic.  The recovery
record has length 0x42424242, and it writes that back into the
now-valid-looking transaction header) for the next comer (which
happens to be tdb_wipe_all in my tests).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2010-02-10 16:56:14 +10:30
Rusty Russell
6269cdcd15 tdb: give a name to the invalid recovery area constant (0)
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2010-02-10 16:56:13 +10:30
Simo Sorce
6339de7f4f release-scripts: parametrize scripts
This should make it easier to keep all release scripts alined as it will reduce
the difference between them to ideally a few variables

Also moves the tdb script in the scripts directory.
2010-02-08 10:29:06 -05:00
Simo Sorce
70534adee1 tdb: raise version to 1.2.1
after recent fixes we need to raise the version to 1.2.1 so that
we can require also the right patched version.
2010-02-06 10:48:39 -05:00
Volker Lendecke
531059696e tdb: fix an early release of the global lock that can cause data corruption
There was a bug in tdb where the

                tdb_brlock(tdb, GLOBAL_LOCK, F_UNLCK, F_SETLKW, 0, 1);

(ending the transaction-"mutex") was done before the

                        /* remove the recovery marker */

This means that when a transaction is committed there is a window where another
opener of the file sees the transaction marker while the transaction committer
is still fully functional and working on it. This led to transaction being
rolled back by that second opener of the file while transaction_commit() gave
no error to the caller.

This patch moves the F_UNLCK to after the recovery marker was removed, closing
this window.
2010-02-01 15:06:29 +01:00
Stefan Metzmacher
c01f443ebc tdb: fix standalone 'make installdocs'
metze
2010-01-06 14:43:39 +01:00
Brian Lu
0a3a6bb8f9 tdb: create symbol links to shared libraries see https://bugzilla.samba.org/show_bug.cgi?id=6991 for details
Signed-off-by: Stefan Metzmacher <metze@samba.org>
2010-01-06 14:27:50 +01:00
Jelmer Vernooij
0110990f01 tdb: Also build and install tdb manpages from standalone tdb. 2009-12-21 23:40:12 +01:00
Jelmer Vernooij
8b278e6dc1 tdb: Fix formatting of API check file. 2009-12-21 23:40:12 +01:00
Günther Deschner
a23084e1e8 tdbtool: avoid using c++ reserved words.
Guenther
2009-12-17 15:40:42 +01:00
Simo Sorce
4334092cba Fix release script with newer versins of git 2009-12-07 09:25:03 -05:00
Matthias Dieter Wallnöfer
9776cb0345 tdb tools: Mostly cosmetic adaptions
Signed-off-by: Stefan Metzmacher <metze@samba.org>
2009-11-20 16:50:48 +01:00
Stefan Metzmacher
5ca0a4bfd6 tdb: change version to 1.2.0 after adding TDB_*ALLOW_NESTING
metze
2009-11-20 09:45:43 +01:00
Stefan Metzmacher
3b9f19ed91 tdb: add TDB_DISALLOW_NESTING and make TDB_ALLOW_NESTING the default behavior
We need to keep TDB_ALLOW_NESTING as default behavior,
so that existing code continues to work.

However we may change the default together with a major version
number change in future.

metze
2009-11-20 09:45:36 +01:00
Ronnie Sahlberg
436b55db1f New attempt at TDB transaction nesting allow/disallow.
Make the default be that transaction is not allowed and any attempt to create a nested transaction will fail with TDB_ERR_NESTING.

If an application can cope with transaction nesting and the implicit
semantics of tdb_transaction_commit(), it can enable transaction nesting
by using the TDB_ALLOW_NESTING flag.
(cherry picked from ctdb commit 3e49e41c21eb8c53084aa8cc7fd3557bdd8eb7b6)

Signed-off-by: Stefan Metzmacher <metze@samba.org>
2009-11-20 09:45:34 +01:00
Stefan Metzmacher
85449b7bcc tdb: always set tdb->tracefd to -1 to be safe on goto fail
metze
2009-11-20 09:45:34 +01:00
Volker Lendecke
be88a126ea tdb: Fix a C++ warning 2009-11-08 00:28:22 +01:00
Kirill Smelkov
83de5c8263 tdb: update README a bit
While studying tdb, I've noticed a couple of mismatches between readme
and actual code:

- tdb_open_ex changed it's log_fn argument to log_ctx
- there is now no tdb_update(), which it seems was transformed into
  non-exported tdb_update_hash()

There were other mismatches, but I don't remember them now, sorry.

Signed-off-by: Kirill Smelkov <kirr@mns.spb.ru>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2009-10-29 10:14:34 +10:30
Kirill Smelkov
71a21393dd tdb: add tests for double .close() in pytdb
The reason I do it is that when using older python-tdb as shipped in
Debian Lenny, python interpreter crashes on this test:

    (gdb) bt
    #0  0xb7f8c424 in __kernel_vsyscall ()
    #1  0xb7df5640 in raise () from /lib/i686/cmov/libc.so.6
    #2  0xb7df7018 in abort () from /lib/i686/cmov/libc.so.6
    #3  0xb7e3234d in __libc_message () from /lib/i686/cmov/libc.so.6
    #4  0xb7e38624 in malloc_printerr () from /lib/i686/cmov/libc.so.6
    #5  0xb7e3a826 in free () from /lib/i686/cmov/libc.so.6
    #6  0xb7b39c84 in tdb_close () from /usr/lib/libtdb.so.1
    #7  0xb7b43e14 in ?? () from /var/lib/python-support/python2.5/_tdb.so
    #8  0x0a038d08 in ?? ()
    #9  0x00000000 in ?? ()

master's pytdb does not (we have a check for self->closed in obj_close()),
but still...

Signed-off-by: Kirill Smelkov <kirr@mns.spb.ru>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2009-10-29 10:14:33 +10:30
Kirill Smelkov
b4424f8234 tdb: reset tdb->fd to -1 in tdb_close()
So that erroneous double tdb_close() calls do not try to close() same
fd again. This is like SAFE_FREE() but for fd.

Signed-off-by: Kirill Smelkov <kirr@mns.spb.ru>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2009-10-29 10:14:33 +10:30
Kirill Smelkov
cfed5f946d tdb: fix typo in python's Tdb.get() docstring
It's Tdb.get(), not Tdb.fetch().

Signed-off-by: Kirill Smelkov <kirr@mns.spb.ru>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2009-10-29 10:14:33 +10:30
Kirill Smelkov
ecbe5ebd8d tdb: kill last bits from swig
We no longer use swig for pytdb, so there is no need for swig make
rules. Also pytdb.c header should be updated.

Signed-off-by: Kirill Smelkov <kirr@mns.spb.ru>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2009-10-29 10:14:33 +10:30
Andrew Tridgell
d4c0e8fdf0 tdb: detect tdb store of identical records and skip
This can help with ldb where we rewrite the index records
2009-10-25 13:15:18 +11:00
Stefan Metzmacher
3b62e250c0 tdb: rename 'struct list_struct' into 'struct tdb_record'
metze
2009-10-23 18:27:20 +02:00
Rusty Russell
0944931159 lib/tdb: make tdbtool use tdb_check() for "check" command
Also, set logging function so we get more informative messages.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2009-10-22 00:11:34 +10:30
Rusty Russell
022b4d4aa6 lib/tdb: add tdb_check()
ctdb wants a quick way to detect corrupt tdbs; particularly, tdbs with
loops in their hash chains.  tdb_check() provides this.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2009-10-22 00:10:34 +10:30
Rusty Russell
0fc6800005 lib/tdb: add -t (always use transactions) option to tdbtorture
This means you can kill it at any time and expect no corruption.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2009-10-22 00:10:54 +10:30
Rusty Russell
b77f41d58b lib/tdb: wean off TDB_ERRCODE.
It was a regrettable hack which I used to reduce line count in tdb; in fact it caused confusion as can be seen in this patch.
In particular, ecode now needs to be set before TDB_LOG anyway, and having it exposed in
the header is useless (the struct tdb_context isn't defined, so it's doubly useless).
Also, we should never set errno, as io.c was doing.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2009-10-22 00:09:43 +10:30
Rusty Russell
703004340c lib/tdb: TDB_TRACE support (for developers)
When TDB_TRACE is defined (in tdb_private.h), verbose tracing of tdb operations is enabled.
This can be replayed using "replay_trace" from http://ccan.ozlabs.org/info/tdb.

The majority of this patch comes from moving internal functions to _<funcname> to
avoid double-tracing.  There should be no additional overhead for the normal (!TDB_TRACE)
case.

Note that the verbose traces compress really well with rzip.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2009-10-22 00:00:12 +10:30
Andrew Tridgell
5dcf0069b6 tdb: fixed the intermittent failure of tdbtorture in the build farm
There was a race condition that caused the torture.tdb to be left in a
state that needed recovery. The torture code thought that any message
from the tdb code was an error, so the "recovered" message, which is a
TDB_DEBUG_TRACE message, marked the run as being an error when it
isn't.
2009-10-20 10:59:40 +11:00
Michael Adam
e440a2e11e tdb:tdbtool: fix indentation.
Michael
2009-09-21 17:47:51 +02:00
Michael Adam
91e1bab2e9 tdb:tdbtool: add transaction_start/_commit/_cancel commands.
So one can perform tdbtool operations protected by transactions.

Michael
2009-09-21 17:47:51 +02:00
Michael Adam
817383d88d tdb:tdbtool: add the "speed" command to the help text.
Michael
2009-09-21 17:47:51 +02:00
Andrew Tridgell
9c69795626 tdb: increase minor version
we depend on reads in transactions for s4 replication
2009-09-19 14:12:00 -07:00
Andrew Tridgell
46c99ec2a3 tdb: allow reads after prepare commit
We previously only allowed a commit to happen after a prepare
commit. It is in fact safe to allow reads between a prepare and a
commit, and the s4 replication code can make use of that, so allow it.
2009-09-15 14:04:22 -07:00
Michael Adam
55dcf928eb tdb:mksigs: allow PRINTF_ATTRIBUTE(..) macros function types as funcion args
Michael
2009-09-11 15:31:31 +02:00
Michael Adam
cfa4e7ec75 tdb:mksigs: normalize bool -> _Bool
Michael
2009-09-11 15:31:31 +02:00
Michael Adam
25939a627f tdb:mksigs: ignore symbols (like _DEPRECATED_) after closing function parentheses
Michael
2009-09-11 15:31:30 +02:00
Michael Adam
13bfcd5a93 tdb:mksigs: correctly ignode multiline function typedefs
by first concatenating multilint parentheses and removing typefes afterwards.

Michael
2009-09-11 15:31:30 +02:00
Michael Adam
ecd12bfb38 tdb:mksigs: ignore struct forward declarations.
Michael
2009-09-11 15:31:30 +02:00
Michael Adam
400f08450b tdb:mksyms: allow characters after closing functions parenthesis.
Michael
2009-09-11 15:31:29 +02:00
Michael Adam
907e05595f tdb:mksyms: allow double pointer return value of functions.
Michael
2009-09-11 15:31:29 +02:00
Günther Deschner
1c2f4919ab tdb: fix c++ build warning.
Guenther
2009-09-07 11:57:10 +02:00
Michael Adam
0d120be36b One would expect I could spell my name... 2009-08-30 00:56:04 +02:00
Michael Adam
84446a2407 tdb: move the original abi_checks script to script/abi_checks_gcc.sh
Michael
2009-08-30 00:51:55 +02:00
Michael Adam
f7c473f534 tdb: run abi_checks as part of "make test".
Strange: I had to place "test:: abi_checks" before the main
"test::" target here, otherwise the abi checks would not get run.

Michael
2009-08-30 00:51:55 +02:00
Michael Adam
dff3f37cf1 tdb: remove files generated by "make abi_checks" in "make clean".
Michael
2009-08-30 00:51:55 +02:00
Michael Adam
e21ecfc563 tdb: add a target "abi_checks" to tdb.
Simply run "make abi_checks" to call the abi check script appropriately.

Michael
2009-08-30 00:51:54 +02:00
Michael Adam
9636e0d373 tdb: add script/abi_checks.sh. check for abi changes without gcc magic.
USAGE: abi_checks.sh LIBRARY_NAME header1 [header2 ...]

This creates symbol signature lists using the mksyms and mksigs scripts
and compares them with the checked in lists.

Michael
2009-08-30 00:51:54 +02:00
Michael Adam
0760a04ef9 tdb: add script to extract signatures from header files.
This produces output like the output gcc produces when
invoked with the -aux-info switch.

Run like this: cat include/tdb.h | ./script/mksigs.pl

This simple parser is probably too coarse to handle all
possible header files, but it treats tdb.h correctly...

Michael
2009-08-30 00:51:54 +02:00
Michael Adam
006fd0c43c tdb: add scripts to extract library symbols (exports file) from headers
Michael
2009-08-30 00:51:53 +02:00
Rusty Russell
398d0c2929 lib/tdb: don't overwrite TDBs with different version numbers.
In future, this may happen, and we don't want to clobber them.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2009-08-28 13:43:05 +10:00
Jeremy Allison
4fc9f9c3f9 Add define guards around otherwise unused variable.
Jeremy.
2009-08-06 11:47:08 -07:00
Rusty Russell
252f7da702 There is one signedness issue in tdb which prevents traverses of TDB records
over the 2G offset on systems which support 64 bit file offsets.  This fixes
that case.

On systems with 32 bit offsets, expansion and fcntl locking on these records
will fail anyway.  SAMBA already does '#define _FILE_OFFSET_BITS 64' in
config.h (on my 32-bit x86 Linux system at least) to get 64 bit file offsets.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2009-08-06 13:13:42 +10:00
Rusty Russell
a207cca1d3 tdb: don't alter tdb->flags in tdb_reopen_all()
The flags are user-visible, via tdb_get_flags/add_flags/remove_flags.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
2009-07-31 14:40:28 +02:00
Rusty Russell
3b2f074bda tdb: Reimplementation of Metze's "lib/tdb: if we know pwrite and pread are thread/fork safe tdb_reopen_all() should be a noop".
This version just wraps the reopen code, so we still re-grab the lock and do
the normal sanity checks.

The reason we do this at all is to avoid global fd limits, see:
http://forums.fedoraforum.org/showthread.php?t=210393

Note also that this whole reopen concept is fundamentally racy: if the parent
goes away before the child calls tdb_reopen_all, the database can be left
without an active lock and another TDB_CLEAR_IF_FIRST opener will clear it.
A fork_with_tdbs() wrapper could use a pipe to solve this, but it's hardly
elegant (what if there are other independent things which have similar needs?).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
2009-07-31 14:40:28 +02:00
Rusty Russell
fa91bc6719 tdb: Revert "lib/tdb: if we know pwrite and pread are thread/fork safe tdb_reopen_all() should be a noop"
This reverts commit e17df483fb.

tdb_reopen_all also restores the active lock, required for TDB_CLEAR_IF_FIRST.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
2009-07-31 14:40:28 +02:00
Rusty Russell
36c0f0f99a realloc() has that horrible overloaded free semantic when size is 0:
current code does a free of the old record in this case, then fail.
2009-07-30 13:10:33 -07:00
Rusty Russell
a88c281ddc If the record is at the end of the database, pretending it has length 1
might take us out-of-bounds.  Only pretend to be length 1 for the malloc.
2009-07-30 13:09:33 -07:00
Rusty Russell
760104188d tdb: fix locking error
54a51839ea "Make tdb transaction lock
recursive (samba version)" was broken: I "cleaned it up" and prevented
it from ever unlocking.

To see the problem:
	$ bin/tdbtorture -s 1248142523
	tdb_brlock failed (fd=3) at offset 8 rw_type=1 lck_type=14 len=1
	tdb_transaction_lock: failed to get transaction lock
	tdb_transaction_start failed: Resource deadlock avoided

My testcase relied on the *count* being correct, which it was.  Fixing that
now.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Michael Adam <obnox@samba.org>
2009-07-21 10:21:53 +02:00
Rusty Russell
54a51839ea Make tdb transaction lock recursive (samba version)
This patch replaces 6ed27edbcd and
1a416ff13c, which fixed the bug where traversals
inside transactions would release the transaction lock early.

This solution is more general, and solves the more minor symptom that nested
traversals would also release the transaction lock early.  (It was also suggestd in
Volker's comment in 6ed27ed).

This patch also applies to ctdb, if the traverse.c part is removed (ctdb's tdb
code never received the previous two fixes).

Tested using the testsuite from ccan (adapted to the samba code).  Thanks to
Michael Adam for feedback.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Michael Adam <obnox@samba.org>
2009-07-20 22:17:20 +02:00
Björn Jacke
cdf025f012 tdb: fix define of tdbdir when srcdir != "." 2009-07-03 18:24:42 +02:00
Simo Sorce
7119241c0d Sort the signature files 2009-07-03 08:45:30 -04:00
Jelmer Vernooij
43b7a0e34e tdb: Fix help string in configure flag to enable Python bindings. 2009-06-17 21:12:50 +02:00
Simo Sorce
ac1d311e9c fix release scripts to always git clean
This makes sure we do not include foreign object files or other
build byproducts by mistake.
2009-06-17 14:18:03 -04:00
Simo Sorce
7aee9f92e7 Add exports file and abi checker for tdb
This is a first attempt at exporting symbols only for public functions
We also provide a rudimentary ABI checker that tries to check that
function signatures are not changed by mistake.
Given our use of macros this is not an API checker.
It's all based on tdb.h contents and the gcc -aux-info option
2009-06-15 16:31:12 -04:00
Simo Sorce
57ba31ca96 Add option to --disable-python on build 2009-06-15 16:31:11 -04:00
Slava Semushin
497b9e460b lib/tdb/tools/tdbtorture.c: fixed memory leak.
Found by cppcheck:
[lib/tdb/tools/tdbtorture.c:326]: (error) Memory leak: pids
2009-06-06 22:33:39 +02:00
Andrew Tridgell
a6cc04a200 overallocate all records by 25%
This greatly reduces the fragmentation of databases where records
tend to grow slowly by a small amount each time. The case where this
is most seen is the ldb index records. Adding this overallocation
reduced the size of the resulting database by more than 20x when
running a test that adds 10k users.
2009-06-01 13:13:07 +10:00
Andrew Tridgell
a386173fa1 auto-repack in transactions that expand the tdb
The idea behind this is to recover from badly fragmented free
lists. Choosing the point where the file expands is fairly arbitrary,
but seems to work well.
2009-06-01 13:11:39 +10:00
Andrew Tridgell
08be1420ba fixed tdbbackup to give tdb error messages 2009-05-28 17:35:12 +10:00
Andrew Tridgell
5ab03dbecc Merge branch 'master' of ssh://git.samba.org/data/git/samba 2009-05-28 16:12:34 +10:00
Andrew Tridgell
4b4fec65db make TDB_NOSYNC affect all the fsync/msync calls in transactions
During a transaction commit tdb normally uses fsync/msync calls to
make it crash safe. This can be disabled using the TDB_NOSYNC flag,
but it wasn't disabling all the code paths that caused a fsync/msync.
2009-05-28 16:08:28 +10:00
Tim Prouty
c299833bf8 tdb: Fix some recently introduced warnings in tdbtool 2009-05-27 13:18:12 -07:00
Andrew Tridgell
e15027155d added some more speed tests to tdbtool
This adds 3 simple speed tests to tdbtool, for transaction store,
store and fetch.

On my laptop this shows transactions costing about 10ms
2009-05-26 09:24:37 +10:00
Jim McDonough
a91bcbccf8 Detect tight loop in tdb_find() 2009-05-21 16:29:48 -04:00
Jelmer Vernooij
6230eb94af Update copies of config.guess and config.sub. 2009-05-16 04:03:12 +02:00
Simo Sorce
d52172654c Update tdb and talloc web pages 2009-05-05 19:04:39 -04:00
Simo Sorce
b58abb262c Add release scripts for talloc and tdb 2009-05-05 09:51:00 -04:00
Tim Prouty
42c0931441 tdb: Remove unused variable 2009-03-31 16:24:07 -07:00
Andrew Tridgell
7a5e6940cf up the version to 1.1.4 with the addition of
tdb_transaction_prepare_commit()
2009-03-31 15:06:23 +11:00
Andrew Tridgell
84547b8dba added basic testing of tdb_transaction_prepare_commit() in tdbtorture 2009-03-31 13:59:03 +11:00
Howard Chu
b90863c0b7 Add tdb_transaction_prepare_commit()
Using tdb_transaction_prepare_commit() gives us 2-phase commits. This
allows us to safely commit across multiple tdb databases at once, with
reasonable transaction semantics

Signed-off-by: tridge@samba.org
2009-03-31 13:15:54 +11:00
Stefan Metzmacher
e17df483fb lib/tdb: if we know pwrite and pread are thread/fork safe tdb_reopen_all() should be a noop
The reason for tdb_reopen_all() is that the seek pointer on fds are shared between
parent and child.

metze
2009-02-25 13:57:11 -08:00
Stefan Metzmacher
e6bb55c3d5 lib/tdb: don't generate a static library for the samba4 build
We also don't do this for talloc and ldb.

metze
2009-02-03 10:24:38 +01:00
Stefan Metzmacher
662e05f7a9 lib/tdb: the python bindings don't use swig anymore
metze
2009-02-02 15:16:08 +01:00
Tim Prouty
2c2545d45a s3 build: Remove unused fstat check to fix a bunch of HAVE_FSTAT warnings 2009-01-30 14:41:07 -08:00
Stefan Metzmacher
3718cf294a lib/tdb: include replace.h and system/filesys.h in pytdb.c
This fixes the build on Tru64.

metze
2009-01-30 19:38:59 +01:00
Jelmer Vernooij
ba5d6e6d70 Avoid using a utility header for Python replacements included in Samba,
since this will not be shipped with talloc/tdb/tevent/etc.
2009-01-08 12:20:20 +01:00
Tim Prouty
61a23c5eea s3/s4 build: Fix Py_RETURN_NONE to work with python versions < 2.4 2009-01-07 15:03:16 -08:00
Jelmer Vernooij
d2c70d24e1 py: Properly increase the reference counter of Py_None. 2009-01-06 04:13:57 +01:00
Jeremy Allison
07e0094365 Fix all warnings in source3 with gcc4.3.
Jeremy.
2008-12-31 18:06:57 -08:00
Jelmer Vernooij
22703bf3ff standalone: Use more variables, preparing to include these files from main
Samba 4 makefile.
2008-12-23 19:44:11 +01:00
Jelmer Vernooij
6704c27a78 Fix standalone build of tdb python module, update ignores for standalone tdb. 2008-12-22 23:39:30 +01:00
Jelmer Vernooij
6fe6983e4c Make sure to not close tdb database more than once. 2008-12-18 20:42:50 +00:00
Jelmer Vernooij
8c1ede0b32 Remove swig use from tdb standalone build. 2008-12-18 19:49:53 +00:00
Jelmer Vernooij
2da551bbcc Implement missing functions in pytdb. 2008-12-18 19:41:02 +00:00
Jelmer Vernooij
2a61fd41e9 Add simple manually written replacement for the tdb module. 2008-12-18 18:57:21 +00:00
Tim Prouty
e48a5cd5d4 s3/s4: Fix "shadows a global declaration" warning 2008-12-16 08:34:53 -08:00
Holger Hetterich
42366bcbbd Added a simple tdb integrity check to tdbtool. The command "check" runs traverse on the currently open tdb, and returns the number of entries if the integrity check is successful. 2008-12-16 13:58:48 +01:00
Andrew Tridgell
936d76802f imported the tdb_repack() code from CTDB
The tdb_repack() function repacks a TDB so that it has a single
freelist entry. The file doesn't shrink, but it does remove all
freelist fragmentation. This code originated in the CTDB vacuuming
code, but will now be used in ldb to cope with fragmentation from
re-indexing
2008-12-16 14:38:17 +11:00
Andrew Tridgell
2e4247782b make tdbbackup use transactions
tdbbackup was originally written before we had transactions, and it
attempted to use its own fsync() calls to make it safe. Now that we
have transactions we can do it in a much safer (and faster!) fashion
2008-12-16 14:36:56 +11:00
Stefan Metzmacher
8b7199e7b2 lib/tdb: increase the version number after some critial changes
The tdb_transaction/traverse interaction fixes are critical.

metze
2008-09-29 04:15:11 +02:00
Simo Sorce
3235e25425 Add shared-build target to tdb.
Useful to build multiple standalone libraries that depend on each other
without having to install them to the final install dir during the build.
2008-09-19 18:07:53 -04:00
Jelmer Vernooij
186d2d83cb Provide tdb.open and ldb.open python functions. 2008-09-19 12:47:52 +02:00
Jelmer Vernooij
94855cd692 Move common libraries from root to lib/. 2008-09-17 14:11:12 +02:00