1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-28 07:21:54 +03:00
Commit Graph

197 Commits

Author SHA1 Message Date
Matthias Dieter Wallnöfer
0c2fbe5a0c samba:python - Py_RETURN_NONE remove compatibility code for releases < 2.4
http://www.python.org/doc//current/c-api/none.html

Reviewed-By: Jelmer Vernooij <jelmer@samba.org>

Autobuild-User(master): Matthias Dieter Wallnöfer <mdw@samba.org>
Autobuild-Date(master): Thu Jan  9 16:27:47 CET 2014 on sn-devel-104
2014-01-09 16:27:47 +01:00
Amitay Isaacs
fe1fc55c61 tdb: Sync to tdb 1.2.11 from upstream
(This used to be ctdb commit bb3a32ec055432afc7225c9fd7504fb187694bda)
2013-05-29 17:47:16 +10:00
Amitay Isaacs
8f643897bb lib/tdb: Sync tdb from samba git tree
Signed-off-by: Amitay Isaacs <amitay@gmail.com>

(This used to be ctdb commit 0f40ea2386892ae10b30beeded0e00edf4c019c3)
2012-04-13 17:49:03 +10:00
Amitay Isaacs
d6383c3ca5 lib/tdb: Remove the files required to build tdb as a library
Since tdb library will never be built from ctdb sources, we don't need the build
related files.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>

(This used to be ctdb commit a7aace3d165e6cb7d63950107e584edaee12a357)
2012-04-13 17:44:56 +10:00
Amitay Isaacs
634bbc5469 build: Use system tdb library if available
Signed-off-by: Amitay Isaacs <amitay@gmail.com>

(This used to be ctdb commit 10ab88a5c822ac403a70a9cd1a6c81020eb91d08)
2012-03-30 12:33:28 +11:00
Ronnie Sahlberg
94b7a84cb1 change TDB to be valgrind nice
(This used to be ctdb commit d306c3c9a53e012c412c96ab9743de6cd96826e0)
2012-02-22 16:07:17 +11:00
Rusty Russell
e68b97ffc9 tdb: expose transaction lock infrastructure for ctdb
tdb_traverse_read() grabs the transaction lock.  This can cause ctdbd
(which uses it) to block when it should not; expose mark and normal
variants of this lock, so ctdbd's child (the recovery daemon) can
acquire it and the ctdbd parent can mark it was held.

(This used to be ctdb commit d09fa845bd848d04507853809acf42e0471b44bf)
2011-01-18 14:07:41 +11:00
Jelmer Vernooij
f6e29e22f4 pytdb: Add __version__ attribute.
(This used to be ctdb commit 2b81314eb94d31f4efadd2a3dcf2f6e176338d3f)
2010-10-07 15:18:51 +10:30
Jelmer Vernooij
d8d8778aaf pytdb: Include Python.h first to prevent warning.
(This used to be ctdb commit 247dacde0d0de1358cc2c27d08914be605272023)
2010-10-07 15:18:30 +10:30
Kirill Smelkov
5f2bb5c83a pytdb: Check errors after PyObject_New() calls
The call could fail with e.g. MemoryError, and we'll dereference NULL
pointer without checking.

Signed-off-by: Kirill Smelkov <kirr@landau.phys.spbu.ru>
Signed-off-by: Jelmer Vernooij <jelmer@samba.org>

(This used to be ctdb commit 09369aa86e233a58ed131fa5b7584b6c86527d40)
2010-10-07 15:18:29 +10:30
Kirill Smelkov
30219892d0 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>

(This used to be ctdb commit ce84abcc6be31554da73920280e6bfc5b63b1464)
2010-10-07 15:18:27 +10:30
Kirill Smelkov
8270f9bd4f 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>

(This used to be ctdb commit 07880810941850e81442b888cd70d810d3f80fc3)
2010-10-07 15:18:25 +10:30
Rusty Russell
ac90f15424 tdb: fix non-WAF build, commit 1.2.6 ABI file.
Sorry Jeremy.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>

(This used to be ctdb commit 7db9838cb5af0d334efbbcb96bfa51d19b35941a)
2010-10-07 15:17:43 +10:30
Rusty Russell
74b2eacede 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>

(This used to be ctdb commit dd86b24ae5307fe09d4ae22b7070d747013a2b07)
2010-10-07 15:17:38 +10:30
Rusty Russell
6a4c5c8e71 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>

(This used to be ctdb commit 3f7ed2b46cb304d553d3f7bd34554d695b8ccc52)
2010-10-07 15:17:18 +10:30
Rusty Russell
9faf6888d4 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>

(This used to be ctdb commit 58c9d90c758aa7c062d84ab97f62947190526356)
2010-10-07 15:17:05 +10:30
Volker Lendecke
140592fe13 tdb: add restore
Based on an idea by Simon McVittie, largely rewritten

(This used to be ctdb commit 7cda5507f90d7598d745a1acfc66c2afa73cd4b5)
2010-10-07 15:15:45 +10:30
Günther Deschner
1cd12ba7f0 lib/tdb: fix c++ build warning in tdb_header_hash().
Guenther

(This used to be ctdb commit e34e639c214b010ff18140b769a8c9245c92006f)
2010-10-07 15:11:53 +10:30
Jelmer Vernooij
4892ad57de pytdb: Make filename argument optional.
(This used to be ctdb commit 3cc73c51caff51e0cba688aefd6f37e632c0e8d4)
2010-10-07 15:11:48 +10:30
Kirill Smelkov
665b3fbaa7 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>

(This used to be ctdb commit dcdd83e6d6786f0857acdf9aa04bca74a7ccf14d)
2010-10-07 15:11:26 +10:30
Kirill Smelkov
f1a720f08f 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>

(This used to be ctdb commit fd16bcc1434841d84fdf78f80163c97c0b52b3fe)
2010-10-07 15:11:24 +10:30
Kirill Smelkov
7b88df14e0 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>

(This used to be ctdb commit 1778fd02eec6e64737167c46173c0c76c85cc4d9)
2010-10-07 15:11:23 +10:30
Kirill Smelkov
2473345d46 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>

(This used to be ctdb commit d0c28ff1fedd27a99a7550fcc74e18cb1f536986)
2010-10-07 15:11:21 +10:30
Kirill Smelkov
95386b0283 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>

(This used to be ctdb commit 3ff413baf04ce28eb54a80141250ae1284b2a521)
2010-10-07 15:11:14 +10:30
Kirill Smelkov
7c72d220b5 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>

(This used to be ctdb commit 7389f8a8a634c2fe0f068831326d92e6bfa0d046)
2010-10-07 15:08:13 +10:30
Andrew Tridgell
bf8dfcfe7d tdb: added TDB_NO_FSYNC env variable
this might help reduce test times and load on test machines

(This used to be ctdb commit 5c4240c364c52073ca64fddf2aa2c1593db0093b)
2010-10-07 15:08:04 +10:30
Rusty Russell
bc2094c9ca tdb: increment version to 1.2.4
(This used to be ctdb commit f1c06608245ec34493c330d891e04c250ad64b20)
2010-10-07 15:07:22 +10:30
Rusty Russell
fc47015894 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>

(This used to be ctdb commit 63c582c99128c3623e270e8425966cab7744fb2f)
2010-10-07 15:05:59 +10:30
Rusty Russell
ef329186d6 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>

(This used to be ctdb commit 525390863ad39acea08ceb88531dc59d118fcad4)
2010-10-07 15:05:58 +10:30
Rusty Russell
05da60f770 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>

(This used to be ctdb commit 2558eb250011893d09dbeaedaffeefa0e397142f)
2010-10-07 15:05:56 +10:30
Rusty Russell
3bd7dd8bd8 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>

(This used to be ctdb commit b4162a95ff9ae28cda8d9c76c51c9480104517a7)
2010-10-07 15:05:55 +10:30
Rusty Russell
c27094742b tdb: workaround starvation problem in locking entire database.
(Imported from SAMBA 11ab43084b)

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.

CQ:S1018154
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>

(This used to be ctdb commit 9ec0009443a0ac4187ce5212a5143689daa58a02)
2010-08-16 10:22:21 +09:30
Rusty Russell
546eff9c93 tdb: Fix tdb_check() to work with read-only tdb databases.
(Import from SAMBA bc1c82ea13)
The function tdb_lockall() uses F_WRLCK internally, which doesn't work on
a fd opened with O_RDONLY. Use tdb_lockall_read() instead.

(This used to be ctdb commit a5db1122ec48d7e7384066848457c850c1a6cf3c)
2010-08-16 10:20:59 +09:30
Rusty Russell
fa2a32d5ef tdb: remove unused variable in tdb_new_database().
(Imported from SAMBA 2eab1d7fdc)

(This used to be ctdb commit 52a87e608d0406aee9df99f7ac3ce16e834b520b)
2010-08-16 10:20:53 +09:30
Rusty Russell
55010cab63 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>

(This used to be ctdb commit 27ba0e5a6681063225df7244a85aa304c51c6948)
2010-08-16 10:20:19 +09:30
Rusty Russell
7d094c3dd7 tdb: define _PUBLIC_ so we can compile tdb.
The Samba tree defines _PUBLIC_ (and _PRIVATE_) for libraries to
control visibility.  The last commit absorbed this from their tdb,
but we need to #define to stub it out since ctdb doesn't use it
(and doesn't need to: we only use tdb internally).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>

(This used to be ctdb commit 54bee0ec670724c337b882e7dda3e999ffa80691)
2010-04-22 14:11:38 +09:30
Andrew Tridgell
b2b5d9881a 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>

(Imported from commit 773a8afbba)

(This used to be ctdb commit e174dc084f11db0eb239b643affef2c02c711b1c)
2010-04-22 14:01:36 +09:30
Jelmer Vernooij
163603f4f4 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.

(Imported from commit 7da94cc4a6)

(This used to be ctdb commit f1242d9cba676d1d393375bea42613192c70662e)
2010-04-22 13:59:22 +09:30
Simo Sorce
bca9d2764e tdb: update exports and signatures files
(Imported from commit c1f6f61f62)

(This used to be ctdb commit e61ff181085b35cb4aba933350bfe4f64471b359)
2010-04-22 13:58:35 +09:30
Volker Lendecke
bae2979659 tdb: Add a non-blocking version of tdb_transaction_start
(Imported from commit 261c3b4f1b)

(This used to be ctdb commit 87ced00d6d98be4a34719af58694e7c940b4dd68)
2010-04-22 13:58:35 +09:30
Volker Lendecke
67312cefef tdb: Fix indentation in tdb_new_database()
(Imported from commit 59315887a0)

(This used to be ctdb commit fa38f818c71c85918e673ff563bf7a91a0c4cc17)
2010-04-22 13:58:07 +09:30
Volker Lendecke
599cd1045e Fix some nonempty blank lines
(Imported from commit ea8e0d5d54)

(This used to be ctdb commit 7161cb1607bb105cd6f4f32df50f519314e77b3f)
2010-04-22 13:58:07 +09:30
Andrew Tridgell
b52a04d987 python: use '#!/usr/bin/env python' to cope with varying install locations
this should be much more portable

(Imported from commit 088096d1ba)

(This used to be ctdb commit 7f1330adc690360a4a8ce85352df0908a93684a5)
2010-04-22 13:57:17 +09:30
Volker Lendecke
9e29197ca6 tdb: Fix bug 7248, avoid the nanosleep dependency
(Imported from commit e2c7e5c4f7)

(This used to be ctdb commit 3318c74386e202b77ba7e29b4c3e0ce4d88fcd5b)
2010-04-22 13:54:06 +09:30
Volker Lendecke
5a89ab2353 tdb: If tdb_parse_record does not find a record, return -1 instead of 0
(Imported from commit fb98f60594)

(This used to be ctdb commit e90aba9967ea4a8ae7f6bdfc19666c47bd92951e)
2010-04-22 13:54:06 +09:30
Rusty Russell
98b9b1defa 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>

(Imported from commit ec96ea690e)

(This used to be ctdb commit 4215c7025d2b29439c5acd19ce4e0fc4e67370b3)
2010-04-22 13:54:06 +09:30
Rusty Russell
a617fb4ab1 patch tdb-refactor-tdb_lock-and-tdb_lock_nonblock.patch
(Imported from commit 1bf482b9ef)

(This used to be ctdb commit 52b0f19636565ef633e63d2726a1cc8c41dccedb)
2010-04-22 13:54:06 +09:30
Rusty Russell
5c58560d50 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>

(Imported from commit ececeffd85)

(This used to be ctdb commit e5af0ce79c74f11daae2a8514e398c40535e2e67)
2010-04-22 13:54:06 +09:30
Rusty Russell
90480db96f 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>

(Imported from commit 8c3fda4318)

(This used to be ctdb commit 65bc926d1a9cb3af18cae6b1462b832a5bcec561)
2010-04-22 13:54:06 +09:30
Rusty Russell
24532663bf 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>

(Imported from commit 9f295eecff)

(This used to be ctdb commit 6d7093cf51d0256245cc6bab24c9550ed3f1d8a5)
2010-04-22 13:54:06 +09:30