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

344 Commits

Author SHA1 Message Date
Volker Lendecke
05235d5b44 tdb: Fix a typo
Signed-off-by: Volker Lendecke <vl@samba.org>

Autobuild-User(master): Simo Sorce <idra@samba.org>
Autobuild-Date(master): Sat Feb 16 17:13:32 CET 2013 on sn-devel-104
2013-02-16 17:13:32 +01:00
Volker Lendecke
72cd5d5ff6 tdb: Remove "header" from tdb_context
header.hash_size was the only thing we ever referenced outside of
tdb_open_ex and its direct callees. So this shrinks the tdb_context by
164 bytes.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>

Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Tue Feb  5 13:18:28 CET 2013 on sn-devel-104
2013-02-05 13:18:28 +01:00
Volker Lendecke
71247ec4bd tdb: Pass argument "header" to check_header_hash
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2013-02-05 08:55:09 +01:00
Volker Lendecke
1436107b07 tdb: Pass argument "header" to tdb_new_database
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2013-02-05 08:54:28 +01:00
Jeremy Allison
80a6fe8427 Remove some unused variables.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2013-01-19 10:32:30 +01:00
Volker Lendecke
f2d67af7bc tdb: Fix undefined prototype warnings
These functions are deliberately left without prototypes according to
3fdeaa399, but without prototypes we get warnings.

Reviewed-by: Rusty Russell <rusty@samba.org>

Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Mon Jan  7 11:20:19 CET 2013 on sn-devel-104
2013-01-07 11:20:19 +01:00
Volker Lendecke
1beb4bc9d1 tdb: Fix \n in error messages
Reviewed-by: Rusty Russell <rusty@samba.org>
2013-01-07 09:32:22 +01:00
Volker Lendecke
a444bb95a2 tdb: Add a comment explaining the "check"
I had to ask git blame to find why we have to do it here...

Reviewed-by: Rusty Russell <rusty@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>

Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Fri Dec 21 13:54:39 CET 2012 on sn-devel-104
2012-12-21 13:54:39 +01:00
Volker Lendecke
3109b541c9 tdb: Make tdb_new_database() follow a more conventional style
We usually "goto fail" on every error and then in normal flow set the
return variable to success. This patch removes a comment which from my
point of view is now obsolete. It violates the {} rule from README.Coding
here in favor of the style used in this function.

Reviewed-by: Rusty Russell <rusty@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2012-12-21 11:57:01 +01:00
Volker Lendecke
d972e6fa74 tdb: Fix a typo
Reviewed-by: Rusty Russell <rusty@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2012-12-21 11:56:47 +01:00
Volker Lendecke
c04de8f3a4 tdb: Fix a typo
Reviewed-by: Rusty Russell <rusty@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2012-12-21 11:56:38 +01:00
Volker Lendecke
24755d75b0 tdb: Use tdb_lock_covered_by_allrecord_lock in tdb_unlock
Reviewed-by: Rusty Russell <rusty@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2012-12-21 11:56:20 +01:00
Volker Lendecke
f8dafe5685 tdb: Factor out tdb_lock_covered_by_allrecord_lock from tdb_lock_list
Reviewed-by: Rusty Russell <rusty@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2012-12-21 11:56:09 +01:00
Volker Lendecke
26b8545df4 tdb: Simplify logic in tdb_lock_list slightly
Reviewed-by: Rusty Russell <rusty@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2012-12-21 11:55:55 +01:00
Volker Lendecke
0f4e7a1401 tdb: Slightly simplify tdb_lock_list
Avoid an else {} branch when we can do an early return

Reviewed-by: Rusty Russell <rusty@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2012-12-21 11:55:15 +01:00
Volker Lendecke
116ec13bb0 tdb: Fix blank line endings
Reviewed-by: Rusty Russell <rusty@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2012-12-21 11:54:53 +01:00
Volker Lendecke
7237fdd4dd tdb: Fix a comment
Reviewed-by: Rusty Russell <rusty@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2012-12-21 11:54:47 +01:00
Volker Lendecke
d2b852d79b tdb: Fix a typo
Reviewed-by: Rusty Russell <rusty@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2012-12-21 11:54:40 +01:00
Volker Lendecke
2c3fd8a13e tdb: Fix a missing CONVERT
methods->tdb_write expects data in on-disk format. For reading that
record, methods->tdb_read() has taken care of the on-disk to in-memory
representation according to the DOCONV() flag passed down. tdb_rec_write()
is a wrapper around methods->tdb_write just doing the CONVERT() on the
way to disk.

Reviewed-by: Rusty Russell <rusty@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2012-12-21 11:54:33 +01:00
Andreas Schneider
c9053796b3 tdb: Improve the documentation of tdb_reopen() and tdb_close().
Reviewed-by: Simo Sorce <idra@samba.org>

Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Wed Dec 12 14:58:50 CET 2012 on sn-devel-104
2012-12-12 14:58:50 +01:00
Andreas Schneider
7f08365a28 tdb: Fix possible crash bugs in the python tdb code.
You can't call tdb_error() for tdb_reopen() or tdb_close(), both return
the error code of close(2) and not a TDB_ERROR!

Reviewed-by: Simo Sorce <idra@samba.org>
Reviewed-by: Jelmer Vernooij <jelmer@samba.org>
2012-12-12 13:15:00 +01:00
Karolin Seeger
ede2aaef28 lib/tdb: Rename manpages/ to man/.
Trying to be more consistent.

Karolin

Reviewed-by: Andreas Schneider <asn@samba.org>
2012-12-03 14:35:11 +01:00
Karolin Seeger
68c6dcb094 docs: man tdbtool: Add missing meta data.
This avoids warnings during the waf build and removes "FIXME" entries from the
manpage.

Karolin

Reviewed-by: Andreas Schneider <asn@samba.org>
2012-11-29 13:41:49 +01:00
Volker Lendecke
c62f8baff8 tdb: Make tdb robust against improper CLEAR_IF_FIRST restart
When winbind is restarted, there is a potential crash in tdb. Following
situation: We are in a cluster with ctdb. A winbind child hangs
in a request to the DC. Cluster monitoring decides the node has a
problem. Cluster monitoring decides to kill ctdbd. winbind child
still hangs in a RPC request. winbind parent figures that ctdb is
dead and immediately commits suicide. winbind parent is restarted by
cluster management, overwriting gencache.tdb with CLEAR_IF_FIRST. The
CLEAR_IF_FIRST logic as implemented now will not see that a child still
has the tdb open, only the parent holds the ACTIVE_LOCK due to performance
reasons. During the CLEAR_IF_FIRST logic is done, there is a very small
window where we ftruncate(tfd, 0) the file and re-write a proper header
without a lock. When during this small window the winbind child comes
back, wanting to store something into gencache.tdb, that winbind child
will crash with a SIGBUS.

Sounds unlikely? See:

[2012/09/29 07:02:31.871607,  0] lib/util.c:1183(smb_panic)
  PANIC (pid 1814517): internal error
[2012/09/29 07:02:31.877596,  0] lib/util.c:1287(log_stack_trace)
  BACKTRACE: 35 stack frames:
   #0 winbindd(log_stack_trace+0x1a) [0x7feb7d4ca18a]
   #1 winbindd(smb_panic+0x2b) [0x7feb7d4ca25b]
   #2 winbindd(+0x1a3cc4) [0x7feb7d4bacc4]
   #3 /lib64/libc.so.6(+0x32900) [0x7feb7a929900]
   #4 /lib64/libc.so.6(memcpy+0x35) [0x7feb7a97f355]
   #5 /usr/lib64/libtdb.so.1(+0x6e76) [0x7feb7b0b0e76]
   #6 /usr/lib64/libtdb.so.1(+0x3d37) [0x7feb7b0add37]
   #7 /usr/lib64/libtdb.so.1(+0x863d) [0x7feb7b0b263d]
   #8 /usr/lib64/libtdb.so.1(+0x8700) [0x7feb7b0b2700]
   #9 /usr/lib64/libtdb.so.1(+0x2505) [0x7feb7b0ac505]
   #10 /usr/lib64/libtdb.so.1(+0x25b7) [0x7feb7b0ac5b7]
   #11 /usr/lib64/libtdb.so.1(tdb_fetch+0x13) [0x7feb7b0ac633]
   #12 winbindd(gencache_set_data_blob+0x259) [0x7feb7d4d8449]
   #13 winbindd(gencache_set+0x53) [0x7feb7d4d85b3]
   #14 winbindd(gencache_del+0x5e) [0x7feb7d4d879e]
   #15 winbindd(saf_delete+0x93) [0x7feb7d54b693]
   #16 winbindd(+0xe507e) [0x7feb7d3fc07e]
   #17 winbindd(+0xe85e5) [0x7feb7d3ff5e5]
   #18 winbindd(+0xe65be) [0x7feb7d3fd5be]
   #19 winbindd(+0xe7562) [0x7feb7d3fe562]
   #20 winbindd(init_dc_connection+0x2e) [0x7feb7d3fe5be]
   #21 winbindd(+0xe75d9) [0x7feb7d3fe5d9]
   #22 winbindd(cm_connect_netlogon+0x58) [0x7feb7d3fe658]
   #23 winbindd(_wbint_PingDc+0x61) [0x7feb7d410991]
   #24 winbindd(+0x103175) [0x7feb7d41a175]
   #25 winbindd(winbindd_dual_ndrcmd+0xb7) [0x7feb7d4107d7]
   #26 winbindd(+0xf8609) [0x7feb7d40f609]
   #27 winbindd(+0xf9075) [0x7feb7d410075]
   #28 winbindd(tevent_common_loop_immediate+0xe8) [0x7feb7d4db198]
   #29 winbindd(run_events_poll+0x3c) [0x7feb7d4d93fc]
   #30 winbindd(+0x1c2b52) [0x7feb7d4d9b52]
   #31 winbindd(_tevent_loop_once+0x90) [0x7feb7d4d9f60]
   #32 winbindd(main+0x7b3) [0x7feb7d3e7aa3]
   #33 /lib64/libc.so.6(__libc_start_main+0xfd) [0x7feb7a915cdd]
   #34 winbindd(+0xce2a9) [0x7feb7d3e52a9]

This is in a winbind child, logfiles surrounding indicate the parent
was restarted.

This patch takes all chain locks around the CLEAR_IF_FIRST introduced
tdb_new_database.
2012-10-06 13:23:42 +02:00
Rusty Russell
37fd93194d tdb: Make robust against shrinking tdbs
When probing for a size change (eg. just before tdb_expand, tdb_check,
tdb_rescue) we call tdb_oob(tdb, tdb->map_size, 1, 1).  Unfortunately
this does nothing if the tdb has actually shrunk, which as Volker
demonstrated, can actually happen if a "longlived" parent crashes.

So move the map/update size/remap before the limit check.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2012-10-06 13:23:41 +02:00
Rusty Russell
100d38d6e0 tdb: add -e option to tdbdump (and docment it).
This allows for an emergency best-effort dump.  It's a little better than
strings(1).

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

Autobuild-User(master): Rusty Russell <rusty@rustcorp.com.au>
Autobuild-Date(master): Thu Oct  4 03:16:06 CEST 2012 on sn-devel-104
2012-10-04 03:16:06 +02:00
Rusty Russell
ffde867891 tdb: tdbdump should log errors, and fail in that case.
Dumping a corrupt database should not exit silently with 0 status!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2012-10-04 09:04:23 +09:30
Rusty Russell
90f463b25f tdb: add tdb_rescue()
This allows for an emergency best-effort dump.  It's a little better than
strings(1).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2012-10-04 09:04:19 +09:30
Volker Lendecke
a168a7c791 tdb: Fix a typo
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Tue Oct  2 19:52:16 CEST 2012 on sn-devel-104
2012-10-02 19:52:16 +02:00
Björn Jacke
1f50b6c3ae tdb/test: fix build on OSF/1
Autobuild-User(master): Björn Jacke <bj@sernet.de>
Autobuild-Date(master): Fri Aug 10 23:33:20 CEST 2012 on sn-devel-104
2012-08-10 23:33:20 +02:00
Andreas Schneider
41cffa3c8b doc: Remove build/ from doxygen config or it will not work in brew.
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Sat Aug  4 16:31:22 CEST 2012 on sn-devel-104
2012-08-04 16:31:22 +02:00
Andrew Bartlett
ea6b8ee026 lib/tdb: Fix format string errors found by -Werror=format in tdb tests 2012-07-30 14:25:10 +10:00
Andrew Bartlett
c92a5670e3 pytdb: Check if the database is closed before we touch it
If .close() has already been called, we have to play dead - the
self->ctx is just not valid any more, as we have been shut down to
allow some other part of Samba to open the tdb.

Andrew Bartlett

Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Mon Jul 16 13:51:52 CEST 2012 on sn-devel-104
2012-07-16 13:51:51 +02:00
Andrew Bartlett
a8e88332a3 pytdb: Check for errors parsing strings into TDB_DATA
The call to PyStringAsString() can raise an exception, and we
want to return that rather than following a NULL pointer later.

Andrew Bartlett
2012-07-16 11:58:21 +02:00
Rusty Russell
66f59f0409 tdb: finish weaning off err.h.
Commit 3c4263e758 said it removed err.h
from tdb, unfortuntely it didn't: tap-interface.h still included it.

This finishes it properly!

Reported-by:Stefan Metzmacher <metze@samba.org>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>

Autobuild-User(master): Rusty Russell <rusty@rustcorp.com.au>
Autobuild-Date(master): Tue Jun 26 10:22:03 CEST 2012 on sn-devel-104
2012-06-26 10:22:03 +02:00
Rusty Russell
3c4263e758 tdb: don't use err.h in tests.
It's not portable.  While we could use ccan/err, it seems overkill since
we actually only use it in one test (I obviously cut & paste the #include).

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

Autobuild-User(master): Rusty Russell <rusty@rustcorp.com.au>
Autobuild-Date(master): Fri Jun 22 09:22:28 CEST 2012 on sn-devel-104
2012-06-22 09:22:28 +02:00
Rusty Russell
1783fe3443 tdb: make TDB_NOSYNC merely disable sync.
(As suggested by Stefan Metzmacher, based on the change to ntdb.)

Since commit ec96ea690e, we handle the case
where a process dies during a transaction commit.  Unfortunately, TDB_NOSYNC
means this no longer works, as it disables the recovery area as well as the
actual msync/fsync.  We should do everything except the syncs.

This also means we can do a complete test with $TDB_NO_FSYNC set; just
to get more complete coverage, we disable it explicitly for one test
(where we override the actual sync calls anyway).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2012-06-22 07:35:17 +02:00
Rusty Russell
f7f6992c1e autobuild: always set TDB_NO_FSYNC.
Then we unset it inside the tdb test target itself.  This means that
new code can't accidently forget it, and we can set it in the
'buildnice' script on sn-devel, for example.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2012-06-22 07:35:16 +02:00
Jelmer Vernooij
bf5934ca1b tdb/wscript: Remove unecessary semicolons. 2012-06-19 02:43:23 +02:00
Stefan Metzmacher
e2caba054f tdb: remove unused debug_fprintf() macro that breaks the build
The IRIX compiler doesn't support '...' in a macro.

metze
2012-06-14 09:34:14 +02:00
Michael Adam
0688cf102d tdb:tests: fix use of a non-existent word (existant) 2012-06-12 07:21:42 +02:00
Andrew Bartlett
c8877d8f63 build: Remove unused release scripts for tdb
These now use waf dist, and the script/librelease.sh script as a wrapper.

The mksyms.sh call in the source3/Makefile uses the copy in source3/script

Andrew Bartlett
2012-05-30 04:15:11 +02:00
Amitay Isaacs
593e731097 lib/tdb: Update ABI
Signed-off-by: Amitay Isaacs <amitay@gmail.com>

Autobuild-User: Rusty Russell <rusty@rustcorp.com.au>
Autobuild-Date: Thu Mar 29 13:12:46 CEST 2012 on sn-devel-104
2012-03-29 13:12:46 +02:00
Amitay Isaacs
3fdeaa3992 lib/tdb: Add/expose lock functions to support CTDB
This patch adds two lock functions used by CTDB to perform asynchronous
locking. These functions do not actually perform any fcntl operations,
but only increment internal counters.

 - tdb_transaction_write_lock_mark()
 - tdb_transaction_write_lock_unmark()

It also exposes two internal functions
 - tdb_lock_nonblock()
 - tdb_unlock()

These functions are NOT exposed in include/tdb.h to prevent any further
uses of these functions. If you ever need to use these functions, consider
using tdb2.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
2012-03-29 20:07:03 +10:30
Rusty Russell
4442c0b2c9 lib/tdb: fix transaction issue for HAVE_INCOHERENT_MMAP.
We unmap the tdb on expand, the remap.  But when we have INCOHERENT_MMAP
(ie. OpenBSD) and we're inside a transaction, doing the expand can mean
we need to read from the database to partially fill a transaction block.
This fails, because if mmap is incoherent we never allow accessing the
database via read/write.

The solution is not to unmap and remap until we've actually written the
padding at the end of the file.

Reported-by: Amitay Isaacs <amitay@gmail.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>

Autobuild-User: Rusty Russell <rusty@rustcorp.com.au>
Autobuild-Date: Fri Mar 23 02:53:15 CET 2012 on sn-devel-104
2012-03-23 02:53:15 +01:00
Rusty Russell
c12970cc91 lib/tdb: fix test/run-die-during-transaction when HAVE_INCOHERENT_MMAP.
Since we force mmap on, we don't intercept writes to the db, so we never
see it in an inconsistent state.  #ifdef over the check that we should have
recovered it at least once.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2012-03-23 10:43:48 +10:30
Rusty Russell
330e3e1b91 lib/tdb: fix missing return 0 code.
fde694274e made tdb_mmap return an int,
but didn't put the return 0 on the "internal db" case.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2012-03-23 10:41:55 +10:30
Rusty Russell
fde694274e lib/tdb: fix OpenBSD incoherent mmap.
This comment appears in two places in the code (commit
4c6a8273c6 from 2001):

	/*
	 * We must ensure the file is unmapped before doing this
	 * to ensure consistency with systems like OpenBSD where
	 * writes and mmaps are not consistent.
	 */

But this doesn't help, because if one process is using mmap and another
using pwrite, we get incoherent results.  As demonstrated by OpenBSD's
failure on the tdb unit tests.

Rather than disable mmap on OpenBSD, we test for this issue and force mmap
to be enabled.  This means that we will fail on very large TDBs on 32-bit
systems, but it's better than the horrendous performance penalty on every
OpenBSD system.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2012-03-22 01:57:37 +01:00
Rusty Russell
eafd837369 lib/tdb: fix up run-die-during-transaction test cases on Solaris.
By using a different include order, we end up with a different version of
FILE_OFFSET_BITS (and probably other things) in parts of the test.  The
different variants get linked together, and the result is weird: the stat
returns 0 size.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2012-03-22 01:57:37 +01:00
Rusty Russell
3272ba0d2d lib/tdb: remove unnecessary XOPEN and FILE_OFFSET_BITS defines in test/
These were relics: they don't need to be defined here as long as we are
careful to include the replace headers before any standard headers (we are).

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

Autobuild-User: Rusty Russell <rusty@rustcorp.com.au>
Autobuild-Date: Wed Mar 14 10:12:26 CET 2012 on sn-devel-104
2012-03-14 10:12:26 +01:00