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

300 Commits

Author SHA1 Message Date
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
Rusty Russell
583ffeae40 lib/tdb: fix tests for standalone out-of-tree.
Commit 4d58d0fa8f didn't work for lib/tdb
outside the build tree: symlink was pointing to wrong place.

Copy simplification from lib/tdb2, and fix the build farm.

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

Autobuild-User: Rusty Russell <rusty@rustcorp.com.au>
Autobuild-Date: Sat Mar 10 07:07:45 CET 2012 on sn-devel-104
2012-03-10 07:07:45 +01:00
Rusty Russell
4d58d0fa8f tdb: build and run unit tests in tdb/test/
Now we can build the test binaries: the CCAN style is to compile
everything called "compile_ok*.c", compile and run everything called
"run*.c", compile, link with the module, and run everything called
"api*.c", and link any other C files (presumably test helpers) into
all the tests.

Unfortunately, actually passing that between the various parts of
wscript is painful, so I open-coded the names.

Also, the tests expect to be run in a (temporary) directory they can
pollute, with the test directory found in test/ (to find the canned
TDB files, for example).

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

Autobuild-User: Rusty Russell <rusty@rustcorp.com.au>
Autobuild-Date: Tue Feb 14 06:53:46 CET 2012 on sn-devel-104
2012-02-14 06:53:46 +01:00
Rusty Russell
205242e176 tdb/test: fix up tests for use in SAMBA tdb code.
1) Make sure we include "tdb_private.h" first, to get the right headers
   (esp. the correct setting of _FILE_OFFSET_BITS before unistd.h).
2) Fix 3G file test since expand logic has changed.
3) Fix nested transaction test, since default is to allow nesting.
4) Capture fdatasync, which was slowing down transaction expand.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2012-02-14 14:45:21 +10:30
Rusty Russell
8fa345d952 tdb: wean CCAN-style unit tests off of tap.
We could use subunit, but that's overkill.  Just print messages when
we fail, and use exit status.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2012-02-14 14:45:19 +10:30
Rusty Russell
0802791081 tdb: import unit tests from CCAN into tdb/test/
I pulled tdb into CCAN as an experiment a while ago; it doesn't belong
there, but it has accumulated some important unit tests.

These are copied from CCAN version init-1486-gc438ec1 with #include "../"
changed to #include "../common/".

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2012-02-14 04:05:43 +10:30
Rusty Russell
390b9a2dd8 tdb: make tdb_private.h idempotent.
The most convenient way to write unit tests in C is to directly
#include the C files (CCAN uses this, for example).  That works quite
well, but it means that tdb_private.h now needs to be protected
against multiple inclusions.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2012-02-14 04:04:43 +10:30
Ira Cooper
eff69aa0f9 Add "repack" command to tdbtool.
Autobuild-User: Jeremy Allison <jra@samba.org>
Autobuild-Date: Sat Jan  7 02:18:41 CET 2012 on sn-devel-104
2012-01-07 02:18:40 +01:00
Ira Cooper
7b42ceb414 Fix compile when TDB_TRACE is enabled.
Autobuild-User: Jeremy Allison <jra@samba.org>
Autobuild-Date: Fri Jan  6 04:16:41 CET 2012 on sn-devel-104
2012-01-06 04:16:41 +01:00
Volker Lendecke
c1e9537ed0 tdb: Use tdb_parse_record in tdb_update_hash
This avoids a tdb_fetch, thus a malloc/memcpy/free in the tdb_store path
2011-12-25 13:31:58 +01:00
Rusty Russell
5767224b7f tdb: don't free old recovery area when expanding if already at EOF.
We allocate a new recovery area by expanding the file.  But if the
recovery area is already at the end of file (as shown in at least one
client case), we can simply expand the record, rather than freeing it
and creating a new one.

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

Autobuild-User: Rusty Russell <rusty@rustcorp.com.au>
Autobuild-Date: Wed Dec 21 06:25:40 CET 2011 on sn-devel-104
2011-12-21 06:25:40 +01:00
Rusty Russell
3a2a755e33 tdb: use same expansion factor logic when expanding for new recovery area.
If we're expanding because the current recovery area is too small, we
expand only the amount we need.  This can quickly lead to exponential
growth when we have a slowly-expanding record (hence a
slowly-expanding transaction size).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2011-12-21 14:17:16 +10:30
Volker Lendecke
664add1775 tdb: Avoid a malloc/memcpy in _tdb_store 2011-12-19 15:18:08 +01:00
Rusty Russell
b64494535d tdb: be more careful on 4G files.
I came across a tdb which had wrapped to 4G + 4K, and the contents had been
destroyed by processes which thought it only 4k long.  Fix this by checking
on open, and making tdb_oob() check for wrap itself.

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

Autobuild-User: Rusty Russell <rusty@rustcorp.com.au>
Autobuild-Date: Mon Dec 19 07:52:01 CET 2011 on sn-devel-104
2011-12-19 07:52:01 +01:00
Amitay Isaacs
20789bfdde tdb: Fix python documentation for tdb module 2011-12-13 00:55:32 +11:00
Jeremy Allison
3741cf999e Remove unused variable.
Autobuild-User: Jeremy Allison <jra@samba.org>
Autobuild-Date: Thu Nov 24 00:17:41 CET 2011 on sn-devel-104
2011-11-24 00:17:40 +01:00
Jeremy Allison
3e6e1aed94 Fix a bunch of "warning: variable ‘XXXX’ set but not used [-Wunused-but-set-variable]" warnings from the new gcc.
Autobuild-User: Jeremy Allison <jra@samba.org>
Autobuild-Date: Mon Nov 21 23:39:08 CET 2011 on sn-devel-104
2011-11-21 23:39:08 +01:00
Jelmer Vernooij
86afe83d86 waf: Factor checking for undefined symbol flags out into separate method.
Autobuild-User: Jelmer Vernooij <jelmer@samba.org>
Autobuild-Date: Sun Nov 13 19:38:38 CET 2011 on sn-devel-104
2011-11-13 19:38:38 +01:00
Jelmer Vernooij
3585abcd4c pytdb: Shorter description which fits on a single line. 2011-11-13 18:06:06 +01:00
Jelmer Vernooij
774f85649b tdb: Only check for pkg-config file when checking for system tdb. 2011-11-13 18:06:06 +01:00
Jelmer Vernooij
31912781ca wafsamba: Only install .pc files if libraries are public. 2011-08-21 03:22:05 +02:00
Jelmer Vernooij
a5025a3c2f tdb: Install pkg-config file. 2011-08-21 03:22:05 +02:00
Rusty Russell
ee720fc19c tdb: increment sequence number in tdb_wipe_all().
TDB2 testing revealed that tdb1 doesn't do this.  It's minor, but fix it.

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

Autobuild-User: Rusty Russell <rusty@rustcorp.com.au>
Autobuild-Date: Tue Aug 16 10:47:41 CEST 2011 on sn-devel-104
2011-08-16 10:47:41 +02:00
Andrew Tridgell
e01f3108ff tdb: remove 'EOF' print from tdbrestore
the EOF message is pointless, and makes for noisy scripts

Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>
2011-07-21 11:44:37 +10:00
Rusty Russell
5eecc85423 tdb2: create tdb2 versions of various testing TDBs.
Soon, TDB2 will handle tdb1 files, but until then, we substitute.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2011-06-20 11:18:36 +02:00
Rusty Russell
6bc59d77b6 tdb_store: check returns for 0, not -1.
TDB2 returns a negative error number on failure.  This is compatible
if we always check for != 0 instead of == -1.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2011-06-20 11:18:35 +02:00
Rusty Russell
4fa51257b2 tdb: enable VALGRIND to remove valgrind noise.
Andrew Bartlett complained that valgrind needs --partial-loads-ok=yes otherwise
the Jenkins hash makes it complain.

My benchmarking here revealed that at least with modern gcc (4.5) and CPU
(Intel i5 32 bit) there's no measurable performance penalty for the
"correct" code, so rip out the optimized one.

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

Autobuild-User: Rusty Russell <rusty@rustcorp.com.au>
Autobuild-Date: Wed Jun  8 11:05:47 CEST 2011 on sn-devel-104
2011-06-08 11:05:47 +02:00
Rusty Russell
43ab5aa390 lib/tdb/python/tests/simple.py: don't assume TDB ordering.
TDB2 can break this assumption.

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

Autobuild-User: Rusty Russell <rusty@rustcorp.com.au>
Autobuild-Date: Thu Jun  2 12:07:40 CEST 2011 on sn-devel-104
2011-06-02 12:07:39 +02:00
Günther Deschner
73c31f044e tdb: fix a build warning.
Guenther
2011-05-06 10:48:11 +02:00
Jelmer Vernooij
bf3b2e2aee Support the 'PYTHON' environment variable.
Autobuild-User: Jelmer Vernooij <jelmer@samba.org>
Autobuild-Date: Sat Apr 23 04:19:05 CEST 2011 on sn-devel-104
2011-04-23 04:19:04 +02:00
Simo Sorce
1804d9a646 tdb_backup: avoid transaction on backup file, use lockall
Transactions have the side effect of generating bigger files.
By removing the transaction files get as much as 30% smaller.

Autobuild-User: Simo Sorce <idra@samba.org>
Autobuild-Date: Tue Apr 19 23:34:37 CEST 2011 on sn-devel-104
2011-04-19 23:34:37 +02:00
Rusty Russell
36cfa7b79e tdb: make sure we skip over recovery area correctly.
If it's really the recovery area, we can trust the rec_len field, and
don't have to go groping for bitpatterns.

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

Autobuild-User: Rusty Russell <rusty@rustcorp.com.au>
Autobuild-Date: Tue Apr 19 14:15:22 CEST 2011 on sn-devel-104
2011-04-19 14:15:22 +02:00
Simo Sorce
cb884186a5 tdb_expand: limit the expansion with huge records
ldb can create huge records when saving indexes.
Limit the tdb expansion to avoid consuming a lot of memory for
no good reason if the record being saved is huge.
2011-04-18 22:15:11 +09:30
Rusty Russell
094ab60053 tdb: tdb_repack() only when it's worthwhile.
tdb_repack() is expensive and consumes memory, so we can spend some
effort to see if it's worthwhile.  In particular, tdbbackup doesn't
need to repack: it started with an empty database!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2011-04-18 22:15:11 +09:30
Rusty Russell
6aa72dae8f tdb: fix transaction recovery area for converted tdbs.
This is why macros are dangerous; these were converting the pointers, not the
things pointed to!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2011-04-18 22:15:11 +09:30
Volker Lendecke
0080f944b4 tdb: Fix Coverity ID 2238: SECURE_CODING 2011-03-30 09:58:32 +02:00
Volker Lendecke
25397de589 tdb: Fix Coverity ID 2192: NO_EFFECT
(ret < 0) can never be true
2011-03-27 22:22:12 +02:00
Andrew Tridgell
bfce962c8f tdb: rename convert_string() to tdb_convert_string()
this prevents a conflict with the convert_string() in samba
2011-03-25 04:37:06 +01:00
Andrew Tridgell
c56e3ccfc9 lib: don't install public headers if a private library
for talloc/tevent/tdb, only install headers if we are doing a
standalone build
2011-03-15 12:22:20 +11:00
Andrew Tridgell
7b948a39e1 tdb: use public_headers to install header files 2011-03-15 12:22:19 +11:00
Andrew Tridgell
0a0ebd73fb tdb: use system include style for system headers 2011-03-15 12:22:19 +11:00
Andrew Tridgell
949427c208 python: use os.environ[] instead of os.putenv()
using os.putenv() causes too much confusion, as it doesn't update
os.getenv()

Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>
2011-02-22 02:51:10 +01:00
Volker Lendecke
91cad71390 tdb: Fix a C++ warning
Autobuild-User: Volker Lendecke <vlendec@samba.org>
Autobuild-Date: Sat Feb 12 19:50:55 CET 2011 on sn-devel-104
2011-02-12 19:50:55 +01:00
Andrew Tridgell
8b8caac6d0 build: removed the old autogen.sh and autogen-waf.sh scripts
for the builds that use waf only, these are no longer needed and just
cause confusion

Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>
2011-02-07 15:03:40 +11:00
Andreas Schneider
b42afa0edf tdb: Added doxygen documentation.
Autobuild-User: Andreas Schneider <asn@samba.org>
Autobuild-Date: Wed Jan 19 11:26:34 CET 2011 on sn-devel-104
2011-01-19 11:26:34 +01:00