[SCM] Samba Shared Repository - branch master updated
Rusty Russell
rusty at samba.org
Tue Sep 13 18:22:02 MDT 2011
The branch, master has been updated
via 84a4289 tdb_compat: change offset of CLEAR_IF_FIRST lock.
via 72c4074 tdb_compat: support tdb_reopen/tdb_reopen_all for TDB2
via 26ce47e util_tdb: return -1/0 from lock_with_timeout functions.
via 5e0f62c dbwrap_tdb: handle tdb2 return values properly.
via 2d7c85a tdb2: fix prototypes which return enum TDB_ERROR.
via c5c0a4d tdb2: fix return handling in pytdb wrapper.
via 2237dae tdb2: add error conversion functions.
via 45467c0 tdb2: set tdb_error() on tdb_transaction_prepare_commit.
via 5e3731a tdb2: make tests work in parallel.
via 6716407 tdb2: fix error handling for tdb1_transaction_commit.
via 5de5889 tdb2: don't return -1 (ie. TDB_ERR_CORRUPT) on transaction write fail.
via fbf0783 tdb2: enhance tdb1 porting document.
via d96dfb2 tdb2: delete old tdb1 tests.
via 2dfa64c tdb2: test: Speed up run-01-new_database.
via c3f3cad tdb2: speed up testing.
via 5e2ad32 tdb2: test: convert (non-invasive) run tests to api tests.
via 5fac36f tdb2: test: fix run-57-die-during-transaction.c to be more efficient.
via 1cb92ea tdb2: don't continue if tdb1_find fails.
via 01b2214 tdb2: test: try (almost) all tests with TDB_VERSION1 flag.
via ef70f5d tdb2: log allocation failures in tdb1 backend.
via 6b11a26 tdb2: fix bogus error from tdb_unlockall() after fork in tdb1 backend.
via d269088 tdb2: check lock owner in tdb1 backend.
via 85fe9cf tdb2: return TDB_ERR_RDONLY from transactions on R/O databases, log nesting
via 26f3587 tdb2: add stats to tdb1 backend.
via b30bb0e tdb2: increment seqnum on tdb_wipe_all in tdb1 backend.
via f1a3ffe tdb2: log an error when calling tdb_store() on read-only TDB in tdb1 backend.
via 0ea5db4 tdb2: catch errors in tdb1_needs_recovery()
via b50b48f tdb2: add tdb_attribute_tdb1_max_dead
via 1323891 tdb2: expose and document tdb1_incompatible_hash.
via 6d02185 tdb2: make tdb1_null static.
via a15c1cf tdb2: tdb_repack
via a347a48 tdb2: unify tdb1_wipe into tdb_wipe.
via 662f46d tdb2: unify tdb1_get_seqnum/tdb1_increment_seqnum into tdb_get_seqnum/tdb_inc_seqnum
via 658ff5b tdb2: unify tdb1_firstkey/tdb1_nextkey into tdb_firstkey/tdb_nextkey.
via 8e14a3e tdb2: unify tdb1_check and tdb1_summary into tdb_check and tdb_summary.
via 5d9dd8d tdb2: unify tdb1_transaction_start etc. into tdb_transaction_start.
via 014ca65 tdb2: unify tdb1_parse_record into tdb_parse_record
via 9140fca tdb2: unify tdb1_chainlock et al. into tdb_chainlock
via 30294c7 tdb2: unify tdb1_traverse into tdb_traverse
via e6cbc0f tdb2: unify tdb1_store into tdb_store
via 10606b7 tdb2: unify tdb1_delete into tdb_delete.
via 6109599 tdb2: unify tdb1_append into tdb_append
via 02f5b8f tdb2: unify tdb1_fetch into tdb_fetch
via f68a56c tdb2: unify tdb1_store into tdb_store
via cbad6e2 tdb2: unify tdb1_open into tdb_open
via 333a23f tdb2: disallow SEED attribute with TDB_VERSION1.
via 6e16e29 tdb2: add TDB_ATTRIBUTE_TDB1_HASHSIZE
via f8dbfad tdb2: make tdb1_open use attributes for logging, hash function.
via 77d7ff6 tdb2: make jenkins_hash function non-static, rename to tdb_jenkins_hash.
via 75d69ce tdb2: remove double-open detection for TDB1 databases.
via c16184f tdb2: merge tdb1_context into tdb_context.
via 9975924 tdb2: use tdb->flags & TDB_RDONLY instead of tdb->read_only for TDB1 code.
via f7e84f8 tdb2: Make TDB1 use the same tdb_hash() wrapper as TDB2
via b4a5c6d tdb2: don't cancel transactions on lock failures in tdb1 backend.
via 88ce92b tdb2: suppress tdb1 backend logging when locking returns EINTR or EAGAIN
via bdd46e4 tdb2: make tdb1 use same low-level lock functions.
via c5b7c4a tdb2: Make tdb1 use the tdb_file structure.
via 5a3f207 tdb2: add TDB_VERSION1 flag.
via 9b98acb tdb2: Make TDB1 code use TDB2's open flags.
via 61b1bd1 tdb2: approximate INCOMPATIBLE_HASH flag with tdb1_incompatible_hash()
via ebb3017 tdb2: Make tdb1 share tdb_store flags, struct tdb_data and TDB_MAGIC_FOOD.
via e613eff tdb2: make TDB1 code use tdb2's TDB_ERROR and tdb_logerr()
via 50484d4 tdb2: make tdb1 headers include tdb2 headers.
via a14df0f tdb2: rearrange tdb_context layout so tdb1_context can match
via f6eee42 tdb2: add tdb1 code to build.
via f49d86e tdb2: remove TDB1 TDB_NO_FSYNC environment variable hack.
via 3b2c10f tdb2: get rid of TDB1 mark and nonblock functions.
via 0b81b07 tdb2: remove _PUBLIC_ in tdb1 functions.
via e9fe56c tdb2: Remove unused tdb1 functions.
via 9660546 tdb2: test: import tdb1's tests.
via bfcd0eb tdb2: include tdb1 source in tests.
via a81bb8d tdb2: import TDB1 code.
via 59527bc tdb2: make tests include a single mega-header to simplify future patches
via b67acb7 tdb2: tdb_foreach()
via 1664702 tdb2: keep link of every non-internal tdb.
via 617c1fc tdb2: save openhook, allow tdb_get_attribute() on it.
via 73e4f35 tdb_compat: make tdb2s temporarily read-only for tdb_traverse_read()
via bdc5499 tdb2: add TDB_RDONLY flag, allow setting/unsetting it.
via 37c704b tdb2: return TDB_ERR_RDONLY if trying to start a transaction on a R/O tdb.
via 2cf3f7c tdb2: save open_flags instead of mmap_flags.
via 376511e tdb_compat: adapt to tdb2 API change.
via ab61a57 tdb2: Hand error code to logging function.
via fb37849 tdb2: move transaction lock
via e69c90e tdb2: enforce TDB_CONVERT
via 34c2d16 tdb2: cleanup oob handling.
via 1bba793 tdb2: fix tdb_lock offset.
via 9b9aa55 tdb2: fix internal tdb_write_convert() error handling in tdb_open()
via e8eebe0 tdb2: Fix to always use 64-bit offset definition
via abb437c ccan: configure check for HAVE_BUILTIN_CHOOSE_EXPR
from a26fe03 s3:smb2cli: split cli->smb2.gss_blob from cli->secblob
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 84a4289b5236e38ab0afc6ef3c784d202c6b3c2c
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 08:13:28 2011 +0930
tdb_compat: change offset of CLEAR_IF_FIRST lock.
This makes it match tdb1, which mean it will Just Work as TDB2 gets
tdb1 format support.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
Autobuild-User: Rusty Russell <rusty at rustcorp.com.au>
Autobuild-Date: Wed Sep 14 02:21:29 CEST 2011 on sn-devel-104
commit 72c4074c65b7a525b001b9787d8b922538898a89
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 08:13:28 2011 +0930
tdb_compat: support tdb_reopen/tdb_reopen_all for TDB2
This matters with the clear-if-first support: we need to re-establish
those locks at this point.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
commit 26ce47ecc09537d3ee6dff205f3dd564a74e6301
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 08:13:28 2011 +0930
util_tdb: return -1/0 from lock_with_timeout functions.
Keeps the tdb2 API change (which returns error codes, rather than -1)
localized. The function returns -1 down the other path, so make it
consistent.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
commit 5e0f62c3c20250a7fdb4be11f08bd407b11a204b
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 08:13:28 2011 +0930
dbwrap_tdb: handle tdb2 return values properly.
TDB2 versions of tdb_parse_record etc return an error code, not -1.
Turn those into -1/0 in dbwrap_tdb to insulate the rest of the code
from that change.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
commit 2d7c85a971b2766e5ad6ce3664506deba87b53e1
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 08:13:28 2011 +0930
tdb2: fix prototypes which return enum TDB_ERROR.
Since enums and ints are compatible in C, the compiler didn't warn
that our prototypes for these functions disagreed with the
definitions.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit 6d3832ee613adeb9ae7ed6454996ffa39c32650f)
commit c5c0a4d3315d10921f2d4514724da045edbda296
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 08:13:27 2011 +0930
tdb2: fix return handling in pytdb wrapper.
tdb_close() does genuinely return non-zero, not an error code, even in tdb2.
And tdb_exists() returns true or false, not an error code.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
commit 2237daed7e4c6c38241bc07383ed1a421abe8d6c
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 08:13:27 2011 +0930
tdb2: add error conversion functions.
This clarifies the code a little, but also provides a more explicit
mechanism which can be used to debug error handling (by introducing
tdb_err_t and making it a pointer type).
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit afa6d57b7d93fe4675a952f556eb462951baa257)
commit 45467c0118da0c1d4e5644f4570f10aafe37a8a7
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 08:13:27 2011 +0930
tdb2: set tdb_error() on tdb_transaction_prepare_commit.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit feb36b14278b4230af70dab90369a345b6a027ef)
commit 5e3731a28101c0ee3435746e4b7340013477ad64
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 08:13:27 2011 +0930
tdb2: make tests work in parallel.
Lazy cut & paste of tdb names causes failure when we run in parallel.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit 380372e733416c2b348d5307f536d0a0807e95df)
commit 67164070d5bb6697ee139b20121656670b579cdf
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 08:13:27 2011 +0930
tdb2: fix error handling for tdb1_transaction_commit.
tdb_repack() returns an enum TDB_ERROR, whereas
tdb1_transaction_commit is expected to return 0 or -1.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit b679512e4260b9847e2f846b07443e6907d8276f)
commit 5de58894c73fc8e58aba0b2b031f468847ec99b8
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 08:13:27 2011 +0930
tdb2: don't return -1 (ie. TDB_ERR_CORRUPT) on transaction write fail.
A left-over -1 return; should be returning ecode (probably TDB_ERR_IO).
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit 077bdae6877d26749987b26a1b5b28cdba5ebbdd)
commit fbf0783722c226a56f576902dae8576d723df998
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 08:13:27 2011 +0930
tdb2: enhance tdb1 porting document.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit 9cbae0f976118472f0065eee674eacf6ab4b80c5)
commit d96dfb24d13c1e4ea05906e7a2478cc73aa91313
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 08:13:27 2011 +0930
tdb2: delete old tdb1 tests.
These two tdb1-specific tests have been superceded by the TDB_VERSION1
flags used in the main tests.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit e42097b73f6cd509aa17a48487a707401a2d4bd0)
commit 2dfa64c3c9dc9a0f9d6bbf19e4fb32a08ad87614
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 08:13:26 2011 +0930
tdb2: test: Speed up run-01-new_database.
Don't run tdb_check with failtest on, since it is very slow. Do the
tdb_check w/ failtest in a new test, but skip MMAP suppression which
doesn't add much and slows down valgrind a lot.
Before this change run-01-new_database took 40 seconds (under
valgrind), after it takes 8 seconds, and run-12-check takes 3
seconds).
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit b3ae89992ecaffed31dcc2e912539c289478801a)
commit c3f3cad9eb58b84a944e501aaede818d4225d057
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 08:13:26 2011 +0930
tdb2: speed up testing.
The time to run tests under valgrind has become excessive; particularly
the failure tests which fork(). Thus we cut down testing:
1) api-94-repack: reduce from 234 seconds to 2 seconds by cutting
iterations, despite adding TDB_VERSION1 tests.
2) api-missing-entries: reduce from 17 seconds to under 1 second by
not checking db inside loop, but at end.
This reduces the total ccanlint time from 729 to 489 seconds.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit a99c2ccf97465d47c3277d997ea93f20ff97ad4d)
commit 5e2ad32f810233499913a78ebec99581e0981d8e
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 08:13:26 2011 +0930
tdb2: test: convert (non-invasive) run tests to api tests.
This reduces compilation time, since these are merely linked with the
pre-built module, rather than recompiling it into the test (which
allows for fancy things like failtest).
This reduces the test compile time down from about 62 seconds to 45
seconds. Since ccanlint compiles tests three times (once normally,
once with coverage, and once with reduced config.h) this makes a
difference: we go from 780 seconds to 729 seconds.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit c4ca9f54301c0367891be6330f59fdd5dcdd51d1)
commit 5fac36f5adcc3bd483fa5b4e068db3c1174e8a4a
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 08:13:26 2011 +0930
tdb2: test: fix run-57-die-during-transaction.c to be more efficient.
We track malloc and free, but we didn't catch the free() inside
external_agent, which means that our list of allocations keeps
growing. Particularly under valgrind, which re-uses memory less than
the glibc allocator.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit d9cbd7d4454ae35e4e2f6d18a9469bf26948e4b9)
commit 1cb92ea9cf3efcc5f4295b7aeb8ddd10e174127c
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 08:13:26 2011 +0930
tdb2: don't continue if tdb1_find fails.
The TDB1 code's tdb1_find() returns 0 on error; the callers should
not assume that the error means that the entry wasn't found, but use
last_error to determine it.
This was found by looking at how long the failure path testing for
test/run-10-simple-store.c was taking under valgrind, ie:
valgrind -q ./run-10-simple-store --show-slowest
This change dropped the time for that test from 53 seconds to 19
seconds.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit 1be090a2d749713cfd0c4584cafb97bffd716189)
commit 01b2214a1893db5071addf1fdf17e9ac06ed63a0
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 08:13:26 2011 +0930
tdb2: test: try (almost) all tests with TDB_VERSION1 flag.
There are some minor changes required, in particular:
1) Make sure lockcheck understands tdb1 allrecord lock upgrades.
2) Handle tdb1 sequence number jumps: various operations increment the
sequence number twice, especually tdb_append.
3) Don't test fail on unlock, since it gets triggered with traversal on the
tdb1 backend (we didn't actually ever test this case for tdb2).
4) Move clear_if_first to offset 4, to match tdb1.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit 818ed29730b030ce79855fc35c212b51adff3180)
commit ef70f5dd35974115a85850d04b0f4b64e511659f
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 08:13:26 2011 +0930
tdb2: log allocation failures in tdb1 backend.
The TDB2 tests are stricter about this; they want every error logged.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit 670ba98f74b52df541d153eeab9d3310932e75cd)
commit 6b11a2630123453a7f40f728641882c440b57010
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 08:13:13 2011 +0930
tdb2: fix bogus error from tdb_unlockall() after fork in tdb1 backend.
We're always allowed to unlock after a fork; by setting the count to 0
before calling the generic unlock function we don't trigger the pid
check.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit ba5bb8eae6bcd230fd5321c618d6a9d56e74e7d1)
commit d26908846a84bcff7860ebdb384bbff030206675
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 08:12:13 2011 +0930
tdb2: check lock owner in tdb1 backend.
This reports errors if we fork() while holding a lock, or misuse a tdb
which we have dual-opened.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit bef6f1b02e95370ecb2cb44be87c82afc9cb74b2)
commit 85fe9cffe529fd6a8c76ca5f0e3c68c090ce25bf
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 08:11:13 2011 +0930
tdb2: return TDB_ERR_RDONLY from transactions on R/O databases, log nesting
Rather than rturning TDB_ERR_EINVAL, return TDB_ERR_RDONLY, and log
when we fail due to nesting.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit 27647f94668040d91de377849dce87dabd72be69)
commit 26f3587d4bf60fe3c82084a7661c4f856534725f
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 08:10:13 2011 +0930
tdb2: add stats to tdb1 backend.
It's actually quite a good fit; we use compare_wrong_bucket for dead
records, which is kind of correct (they should be in the free list).
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit a3e4ebff2eb9dc2e386160b8acf77d70236f4def)
commit b30bb0ed903a49a9a81d0418211e4f985eca20ab
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 08:09:13 2011 +0930
tdb2: increment seqnum on tdb_wipe_all in tdb1 backend.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit 79dee5018a407be1d0674d6108b60f8e8c882b7c)
commit f1a3ffe24a504f445b09269a165501439bc9da98
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 08:08:13 2011 +0930
tdb2: log an error when calling tdb_store() on read-only TDB in tdb1 backend.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit b236a8dcc37bb864b632a2898a64f3c9bf75b4ac)
commit 0ea5db4e0d81907ccdc25c79aa3b6f8074775426
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 08:07:13 2011 +0930
tdb2: catch errors in tdb1_needs_recovery()
The tdb1 backend simply returns "true" if there's an error determining
if a tdb needs recovery. But this leads failtest down a rabbit hole;
it's better to return the error at this case (and makes for better for
diagnostics, since they will come from the first fault, not later in
tdb1_transaction_recover().
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit 332d0c29baa6896e67c439aeb47f58a104fbc781)
commit b50b48f575d8ad2a709c89dab0a64e19e45d7b08
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 08:06:13 2011 +0930
tdb2: add tdb_attribute_tdb1_max_dead
This allows us to simulate the old "volatile" flag for tdb1. It's not
necessary for tdb2.
As this is the last function in tdb1.h, we remove that file.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit b8e64e9346793164651a36eccb3c205077e5c91b)
commit 13238912facb04ab3aafeb020de6226659d83e6b
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 08:05:13 2011 +0930
tdb2: expose and document tdb1_incompatible_hash.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit a4f2eb983b92b68bcad2a0d640924b8b456e3d69)
commit 6d0218598c3f3c69b8c2fdf40d3f9611885a51af
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 08:04:13 2011 +0930
tdb2: make tdb1_null static.
It's only used in two files, make it static in one and do it manually
in the other.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit 8571daf007f03a2888566dbaae8a5849ffba60f3)
commit a15c1cf175d7f29a50d7b2c1acb0f67faab1b06f
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 08:03:13 2011 +0930
tdb2: tdb_repack
Move the tdb1_repack() code into the core, make it general, rename to
tdb_repack().
It's generic code: copy database into temporary, wipe it, copy back.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit e487983a4099b6f760056ff7182f2ff543e6da71)
commit a347a4802695c41437e2966404d1e2fe2dee78b4
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 08:02:13 2011 +0930
tdb2: unify tdb1_wipe into tdb_wipe.
Switch on the TDB_VERSION1 flag.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit b2555a868e3ee58d1b31f9558e3623d49ed2b2f1)
commit 662f46de21437527a57f0cfc77e290a3ec9f3d94
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 08:01:13 2011 +0930
tdb2: unify tdb1_get_seqnum/tdb1_increment_seqnum into tdb_get_seqnum/tdb_inc_seqnum
Switch on the TDB_VERSION1 flag.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit 57359c26e9626aa986ee0538efd13a44a466f39d)
commit 658ff5b0f28e364d22ada4dbbc988ca0f82b911e
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 08:00:13 2011 +0930
tdb2: unify tdb1_firstkey/tdb1_nextkey into tdb_firstkey/tdb_nextkey.
Switch on the TDB_VERSION1 flag.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit 7366486e29e4f3d89a3e08fc114079d6441af850)
commit 8e14a3e06d42b0302868dc3911a2e607e42a51b3
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 07:59:13 2011 +0930
tdb2: unify tdb1_check and tdb1_summary into tdb_check and tdb_summary.
Switch on the TDB_VERSION1 flag. Also, change tdb1_check's checkfn argument
to return an error code (and set tdb->last_error accordingly).
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit ef92843f2c74ab9d4fa7f167a2182e5e8955df91)
commit 5d9dd8d541a761e0af2c8d50ee55485f2cef3e01
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 07:58:13 2011 +0930
tdb2: unify tdb1_transaction_start etc. into tdb_transaction_start.
Switch on the TDB_VERSION1 flag.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit 6bc8ea012391198bc3898ae2937558b60dd55906)
commit 014ca657e600ee2b3b4dc9d2ef482d050cd0917d
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 07:57:13 2011 +0930
tdb2: unify tdb1_parse_record into tdb_parse_record
Switch on the TDB_VERSION1 flag.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit 3352e4e947777d4a90a2dd4f3037e1e494231b25)
commit 9140fca812063be69842a6c64030e32c65c9dff1
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 07:56:13 2011 +0930
tdb2: unify tdb1_chainlock et al. into tdb_chainlock
Switch on the TDB_VERSION1 flag.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit ceb2f3eacbad917ee990afbc3dd800bfb0607887)
commit 30294c7b91456dd49b89a9b26eb0b1066087815c
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 07:55:13 2011 +0930
tdb2: unify tdb1_traverse into tdb_traverse
Switch on the TDB_VERSION1 flag; we now only do a tdb1_traverse_read on a
read-only database, as there is no tdb2 equivalent.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit cc2d609dfca7192305ad477b8c2b52cfdc1aa9be)
commit e6cbc0f00ec9ecb4c014ee484746d565382d5f67
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 07:54:13 2011 +0930
tdb2: unify tdb1_store into tdb_store
Switch on the TDB_VERSION1 flag.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit 2bba2a856a6cfdb93085b701557850bc1da99587)
commit 10606b7e3bdad19a60953dbad9e1d541a1a3b805
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 07:53:13 2011 +0930
tdb2: unify tdb1_delete into tdb_delete.
Switch on the TDB_VERSION1 flag.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit acb26c9c3ee054c8b2141db25c9bd7be064e425c)
commit 61095999cc158482f68fa53f16160033128615e8
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 07:52:13 2011 +0930
tdb2: unify tdb1_append into tdb_append
Switch on the TDB_VERSION1 flag.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit 8bc38cb177928ef739440c32e33a8eaf23a5dd22)
commit 02f5b8fef868b7f77f1ac385740328757bff4d93
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 07:51:13 2011 +0930
tdb2: unify tdb1_fetch into tdb_fetch
Switch on the TDB_VERSION1 flag.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit 08c05da588018c6b76834e57b66d525546643708)
commit f68a56ce8f38cc1768d8c2dca84f456f4ecfc625
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 07:50:13 2011 +0930
tdb2: unify tdb1_store into tdb_store
Switch on the TDB_VERSION1 flag.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit 98c754ffe65bc335f66161d6cc8705d4ea2710ec)
commit cbad6e2c140e59a6ec653bcfe773599a57a5042f
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 07:49:13 2011 +0930
tdb2: unify tdb1_open into tdb_open
Finally, we gut tdb1_open() to the tdb1-specific parts, and call it
from tdb_open if they specify the TDB_VERSION1 flag or the version is
a TDB1.
We also unify tdb_close(), based on the TDB_VERSION1 flag.
Note that tdb_open(TDB_VERSION1) will fail on an existing tdb if it's
a TDB2.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit c8c3b3568677e8b0105f84e4ab068c580faf4591)
commit 333a23fa995faf1735e5234272f56b792d91a877
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 07:48:13 2011 +0930
tdb2: disallow SEED attribute with TDB_VERSION1.
It also only makes sense with O_CREAT.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit fc44729c471bcdc7ab0410448d991a65e74cec3d)
commit 6e16e29d532d7542c210fd725bf61df1e7a97795
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 07:47:13 2011 +0930
tdb2: add TDB_ATTRIBUTE_TDB1_HASHSIZE
This replaces the tdb1_open "hash_size" argument. It will only be
valid when you call tdb_open() with O_CREAT in open_flags, and
TDB_VERSION1 in tdb_flags.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit 49475d68deecd0b31597ed6094229171d2699b11)
commit f8dbfad23c9cab9d52b366d56e8491666a90f714
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 07:46:13 2011 +0930
tdb2: make tdb1_open use attributes for logging, hash function.
This brings it closer to tdb_open(), so we can unify more easily.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit a446f1d4d161d66bbb19ba2551cf6429a4865964)
commit 77d7ff6c34f16dec70da3f3abc1c19d217e944a9
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 07:45:13 2011 +0930
tdb2: make jenkins_hash function non-static, rename to tdb_jenkins_hash.
We're going to need access to it from tdb1_open, so expose it now.
It's better in hash.c anyway.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit c8f6f8c2dea76042f74c02eff048847e62adcca6)
commit 75d69ce4f7135fa82d1743fdb61e37ee0bbc1508
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 07:44:13 2011 +0930
tdb2: remove double-open detection for TDB1 databases.
This is a percursor to unifying with tdb_open() from tdb2, which handles
this itself.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit 97224cbbe29e76522ec38d031c54b1cadce8ae03)
commit c16184f83b2fea59cd31ec968f0c6b7e06f9047b
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 07:43:13 2011 +0930
tdb2: merge tdb1_context into tdb_context.
Finally, we split out the tdb2-specific parts of tdb_context, and put
them into a "tdb2" sub-struct; the tdb1 parts go into a "tdb1"
sub-struct. We get rido of tdb1_context and use tdb_context
everywhere.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit bbeb528e74c0e234e1f724ac8d54be404cfc6f9a)
commit 997592431f3e62cacef13d9b75a12a3d8058e7b7
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 07:42:13 2011 +0930
tdb2: use tdb->flags & TDB_RDONLY instead of tdb->read_only for TDB1 code.
There's also a semantic change here: for tdb1, being read-only meant no
locking, and it was an error to try to lock a r/o database. For TDB2, you'd
need to specify TDB_NOLOCK, which suppresses locking silently.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit 4dc29a338fadeac805b369b4b0851c02f1b152c7)
commit f7e84f8ef86c3323f70e2fa30fd8a49cab1febf9
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 07:41:13 2011 +0930
tdb2: Make TDB1 use the same tdb_hash() wrapper as TDB2
This means converting the tdb1 inbuilt hash functions to the
tdb2-style, so they return 64 bit. We truncate to 32 bit everywhere
but in tdb_check() which needs to do so explicitly.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit 3e46dde21261966941469a6c75e1b45cd2d26324)
commit b4a5c6dcb6c60a32b92772396dadfffa6b721732
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 07:40:13 2011 +0930
tdb2: don't cancel transactions on lock failures in tdb1 backend.
In TDB2, the user can override locking functions, so they may
deliberarely fail (eg. be non-blocking) expecting to retry.
For this reason, the TDB2 API requires the caller to cancel the
transaction if tdb_transaction_prepare_commit() fails.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit 8458811a4126c22635b974718bfbf2876c893c37)
commit 88ce92b92efe12f8a7364eb1786d73ec8ecd7884
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 07:39:13 2011 +0930
tdb2: suppress tdb1 backend logging when locking returns EINTR or EAGAIN
The TDB1 code logs multiple times on errors; we must prevent that in
the limited case where locking fails. With TDB2, this can happen due
to the lock function attribute, where the user supplies replacement
locking functions which are allowed to return with errno EAGAIN or
EINTR for various special-effects. Flooding the logs for this is
unfriendly.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit a391b2b900bc6d5c0467869a454bdb5c51b5a3be)
commit bdd46e4513c7157a67408fcbd1e24b822cdbb960
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 07:38:13 2011 +0930
tdb2: make tdb1 use same low-level lock functions.
This means they will use the TDB_ATTRIBUTE_FLOCK functions, and get automatic
reopen support.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit fbad02b680b6cbc33ae305ae1cbcdead4eedc7b1)
commit c5b7c4aea8a1d2be1d61c3b909177cb5ef07fd62
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 07:37:13 2011 +0930
tdb2: Make tdb1 use the tdb_file structure.
Because tdb2 allows multiple opens of the same TDB, we separate out
the file information from the struct tdb_context. Do the same for
tdb1.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit 60210a73ec08a7b34ba637ad19e6749cf6dc1952)
commit 5a3f207318bee2fc2236ac1e19eda8ac2ae80829
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 07:36:13 2011 +0930
tdb2: add TDB_VERSION1 flag.
This will be set for old TDBs; we can start distinguishing paths based
on it now.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit 2b50be90a23893a06e0f1436a31d18b97ad0e11d)
commit 9b98acbba304f2c1c1fba5bda672e1005151e526
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 07:35:13 2011 +0930
tdb2: Make TDB1 code use TDB2's open flags.
This means getting rid of TDB_VOLATILE (perhaps we should use an
attribute for that?), TDB_INCOMPATIBLE_HASH (use the
tdb_attribute_hash for that) and TDB_CLEAR_IF_FIRST (use the
tdb_attribute_openhook for that).
We also get rid of TDB_DISALLOW_NESTING: that's the default for TDB2.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit 22d0e0dc59fc9d7e0046fec6971ef478c2d604fd)
commit 61b1bd1dca145a0417907793579352c66b016c23
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 07:34:13 2011 +0930
tdb2: approximate INCOMPATIBLE_HASH flag with tdb1_incompatible_hash()
Rather than leak TDB_INCOMPATIBLE_HASH through to the TDB2 API, we make
it that if they use the tdb1_incompatible_hash function as their hash,
then we treat it as if they had specified the TDB_INCOMPATIBLE_HASH
flag (ie. we mark the header so it's unusable by tdb < 1.2.6).
This precludes the possibility of using TDB_INCOMPATIBLE_HASH with a
custom hash function: that used to allow the user to ensure that old TDB
versions couldn't open the TDB file (and recent ones check the header to
ensure they're using the right hash). But that's a small loss.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit 3004f7e89a5978064b4fb29c1027e6d0d39e9418)
commit ebb3017cf08cc4dad3217db6cea404069b494b47
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 07:33:13 2011 +0930
tdb2: Make tdb1 share tdb_store flags, struct tdb_data and TDB_MAGIC_FOOD.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit 8a47d50d72ea62e378dc92b150c92c1317c73fa3)
commit e613effeae7c9373c9e635fc708ec2ce29661d4c
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 07:32:13 2011 +0930
tdb2: make TDB1 code use tdb2's TDB_ERROR and tdb_logerr()
To do this, we make sure that the first few fields of tdb1_context and
tdb_context are the same.
This sweep also fixes up a few paths where we weren't setting
tdb->ecode before our old logging function.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit 919937354a331bb964564a11b5a5b80403ff8db9)
commit 50484d4bede6b59706457e44a32cbe2d3e9c28d2
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 07:31:13 2011 +0930
tdb2: make tdb1 headers include tdb2 headers.
They're about to start sharing TDB2's definitions.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit 1e3138a0ad0c184d2ca49ce7bc47173eb2fe67bd)
commit a14df0f361bfb1dbe25abf9b7b129e99ee6a516f
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 07:30:13 2011 +0930
tdb2: rearrange tdb_context layout so tdb1_context can match
By moving all the parts of struct tdb_context which logging and
locking use to the beginning of the structure, we can make
tdb1_context match, and thus pass that directly to the tdb_logerr()
function, and later the locking functions.
This is only necessary until we unify tdb1_context and tdb_context.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit 0fd5be2955f8e6487c0f4ab711e2a6958bb8f412)
commit f6eee4216f35eced3314e6aeafba4c65872def99
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 07:29:13 2011 +0930
tdb2: add tdb1 code to build.
The following patches integrate it together, but from here on we build
it.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
commit f49d86edfe4e6dd83e896b0e82791b11bde36a64
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 07:28:13 2011 +0930
tdb2: remove TDB1 TDB_NO_FSYNC environment variable hack.
The caller should do this: the SAMBA compatibility later does.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit 75a6a6ad64156ef3b13493be2970ae3cb99ccf8b)
commit 3b2c10f8955096c5cb28e8ae157e0f08858c001e
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 07:27:13 2011 +0930
tdb2: get rid of TDB1 mark and nonblock functions.
We do this using hooks in tdb2.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit 444fade529f68eb2b0aebbc8de442478c5c6f916)
commit 0b81b07110c463300431a09f24e67144f97ad8b0
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 07:26:13 2011 +0930
tdb2: remove _PUBLIC_ in tdb1 functions.
They'll all be accessed via the tdb2 API.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit 39f55294799c6443c0ad7bef09f1c113cf89d295)
commit e9fe56cdf3285295642db09b70b673d865551b4a
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 07:25:13 2011 +0930
tdb2: Remove unused tdb1 functions.
We're going to use TDB2's API, so some TDB1 APIs are obviously unnecessary.
We also get rid of USE_RIGHT_MERGES and TRACE code.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit b929638e3cfe629285af3ecd0813e03eaeaa1133)
commit 9660546a18cc9af508e6e594349d869bdcefafb2
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 07:24:13 2011 +0930
tdb2: test: import tdb1's tests.
The main change is to s/tdb/tdb1_/ everywhere.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit fab544c24c1ad6523f95893abcaec4e6cce6c2b4)
commit bfcd0ebd980eb5ebc56e6b57fd158c2fad89fc78
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 07:23:13 2011 +0930
tdb2: include tdb1 source in tests.
Since we've renamed everything in tdb1, they won't clash.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit 5d6194b434f3664d1025df12ef06c6a25f693bc8)
commit a81bb8d7d1af9d8bfbd5e56f20001b777ce2d1ec
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 07:22:13 2011 +0930
tdb2: import TDB1 code.
We import the entire codebase, putting a "tdb1_" prefix on the files
and changing the "tdb_" prefix to "tdb1_" everywhere.
The next patches will gradually merge it with the TDB2 code where
necessary.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit 19e6c1a250ade1e7204ada17163294855585e825)
commit 59527bcc7b465bfa2cdfb5a9f5e40d68e888ace9
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 07:21:13 2011 +0930
tdb2: make tests include a single mega-header to simplify future patches
This lets us add the new files to a single place.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit 476567430be6962625bf399192e20938985232c7)
commit b67acb7e2a7cde01321daa6116c635a565accd27
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 07:20:13 2011 +0930
tdb2: tdb_foreach()
Create an iterator over every open tdb (not internal TDBs). This is
useful for re-establishing the tdb1-style active lock for
CLEAR_IF_FIRST.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit 1a0c636bc38213bd0322db47529f78f2dc22ffdd)
commit 1664702d2f0755a3caf7ba8dd433e34bb8d340b0
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 07:19:13 2011 +0930
tdb2: keep link of every non-internal tdb.
Instead of a per-file linked list, use a per-tdb list. This is needed
for tdb_foreach().
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit 2414f261918b4fb8a549dd385dba32118e37bf85)
commit 617c1fcfa476d65320dc2c14b21016b6b438c090
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 07:18:13 2011 +0930
tdb2: save openhook, allow tdb_get_attribute() on it.
This makes it easy to call it again after a fork(), such as for
re-establishing the CLEAR_IF_FIRST files locks.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit 937d0babe99dcd315040a9e48430140e63e4a7df)
commit 73e4f35e3d4dd7043a140355e4cd0f10f54c7337
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 07:17:13 2011 +0930
tdb_compat: make tdb2s temporarily read-only for tdb_traverse_read()
It doesn't make a difference unless the tdb2 opens a TDB1 on disk, in
which case tdb1_traverse() takes a write lock on the entire file. By
setting the tdb to read-only first, we simulate the old behaviour.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
commit bdc5499205367eccef5700cba8af95ba941ac9b2
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 07:16:13 2011 +0930
tdb2: add TDB_RDONLY flag, allow setting/unsetting it.
You can only unset it if the TDB was originally opened O_RDWR.
Also, cleaned up error handling in tdb_allrecord_lock() so we only get
one log message on a r/o database.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit b87e14495d5b07e1b247218a72329f10ecb3da7f)
commit 37c704be0af3b5915e6630264dc4379309d83160
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 07:15:13 2011 +0930
tdb2: return TDB_ERR_RDONLY if trying to start a transaction on a R/O tdb.
This is more accurate than returning TDB_ERR_EINVAL.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit 91436a25574597dbd1fd2de5bcd5826a234100d6)
commit 2cf3f7c07499f565101e1bcb835c73fc297ea72e
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 07:14:13 2011 +0930
tdb2: save open_flags instead of mmap_flags.
It's more consistent with what tdb1 does, and slightly more encapsulated.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
(Imported from CCAN commit 6b7c3c840eafbec211b9f58751c5ff754302a68e)
commit 376511ed4defeeeabcfaa83acd230afd4a46b6fd
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 07:13:13 2011 +0930
tdb_compat: adapt to tdb2 API change.
Add the ecode arg to all the log functions, and log it.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
commit ab61a57e0177ff50a22a8feea38abbf02edfd5da
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 07:12:13 2011 +0930
tdb2: Hand error code to logging function.
Since we've deprecated tdb_error() function (and it didn't work right
from inside the logging function anyway, since we didn't set
tdb->ecode yet) we need to hand it to the log function.
(Imported from CCAN commit 6e3d9e8a66bf8b45150500f176452ee8e9ee9927)
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
commit fb37849abda31b77a05718a316f52ed3fb0a8acd
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 07:11:13 2011 +0930
tdb2: move transaction lock
Make it the same offset as TDB1. This isn't strictly necessary, but
it would allow for total unification later, since TDB1 and TDB2's
transaction code is otherwise completely compatible.
(Imported from CCAN commit de432e8f857ce23bccde7c6ffa3e7e21456df18b)
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
commit e69c90e5d59027695f158751ed7922d2389d2b5b
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 07:10:13 2011 +0930
tdb2: enforce TDB_CONVERT
If the caller actually specifies TDB_CONVERT, fail if the TDB does not
need conversion. It's unusual for the user to specify TDB_CONVERT
(it's auto-detected) but better to be strict.
(Imported from CCAN commit 3e3ee8b0c1e77340ab9e8678c2d23646d8cdb627)
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
commit 34c2d1658a89462e9b34210cb19fe9ab33bc2194
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 07:09:13 2011 +0930
tdb2: cleanup oob handling.
The tdb_oob() function can fail due to errors, as well as because the length
asked for is greater than the size of the file. Clean that up:
(1) If probe is true, only fail if there's an error, not if the length is
too great.
(2) Exit tdb_open() if it tdb_oob() probe fails; this helps cut down
test time for failtest.
(3) Don't set probe to true in tdb_direct() fail; a minor issue, but it means
we log failure.
(Imported from CCAN commit 77658070a3e4f712b94d659b2e399031ce3394c8)
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
commit 1bba793fd64f635b8055a34973cded1f67e958e4
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 07:08:13 2011 +0930
tdb2: fix tdb_lock offset.
It can be 64 bits, for huge databases.
(Imported from CCAN commit 736c033322079baf754261d82b6a83de53b2bb4e)
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
commit 9b9aa556defbf35f782109464e4295d250e59f24
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 07:07:13 2011 +0930
tdb2: fix internal tdb_write_convert() error handling in tdb_open()
As noted, failtest was taking a long time, because a failure injected here
was not detected.
(Imported from CCAN commit 51f592dfcda4d58d6b9d8134b6e1aff791dc40f2)
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
commit e8eebe0fbc3c3c946380a1c554bc1214ae899663
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 07:06:13 2011 +0930
tdb2: Fix to always use 64-bit offset definition
We use off_t in the tdb2 interface (for tdb_attribute_flock); we need
to make sure that all callers agree on the size.
This also causes a problem in the tests: it's not enough to include
config.h first, we need the _FILE_OFFSET_BITS define from private.h.
Otherwise, we can disagree about the definitions of F_SETLK, F_SETLKW
and off_t, causing strange problems.
(Imported from CCAN commit baa17ee2d5e01a32030f19e566007417d72b4b6e)
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
commit abb437c0abedc6646927381017666db3f962befd
Author: Rusty Russell <rusty at rustcorp.com.au>
Date: Wed Sep 14 07:05:13 2011 +0930
ccan: configure check for HAVE_BUILTIN_CHOOSE_EXPR
We weren't testing for this, and without it, typesafe_cb just casts
its function argument. This is why I didn't get a warning when one of
my patches amended a function incorrectly.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
-----------------------------------------------------------------------
Summary of changes:
lib/ccan/libccan.m4 | 15 +
lib/ccan/wscript | 3 +
lib/ldb/ldb_tdb/ldb_tdb_wrap.c | 4 +-
lib/tdb2/check.c | 22 +-
lib/tdb2/doc/TDB1_porting.txt | 28 +
lib/tdb2/free.c | 74 +-
lib/tdb2/hash.c | 62 +-
lib/tdb2/io.c | 114 ++-
lib/tdb2/lock.c | 72 +-
lib/tdb2/open.c | 327 ++++--
lib/tdb2/private.h | 284 ++++--
lib/tdb2/private.h.orig | 618 ++++++++++
lib/tdb2/pytdb.c | 22 +-
lib/tdb2/summary.c | 14 +-
lib/tdb2/tdb.c | 205 +++-
lib/tdb2/tdb1_check.c | 478 ++++++++
lib/tdb2/tdb1_freelist.c | 322 ++++++
lib/tdb2/tdb1_hash.c | 347 ++++++
lib/tdb2/tdb1_io.c | 516 +++++++++
lib/tdb2/tdb1_lock.c | 560 +++++++++
lib/tdb2/tdb1_open.c | 234 ++++
lib/tdb2/tdb1_private.h | 178 +++
lib/tdb2/tdb1_summary.c | 202 ++++
lib/tdb2/tdb1_tdb.c | 840 ++++++++++++++
lib/tdb2/tdb1_transaction.c | 1336 ++++++++++++++++++++++
lib/tdb2/tdb1_traverse.c | 373 ++++++
lib/tdb2/tdb2.h | 82 ++-
lib/tdb2/test/api-12-store.c | 56 +
lib/tdb2/test/api-13-delete.c | 210 ++++
lib/tdb2/test/api-14-exists.c | 58 +
lib/tdb2/test/api-16-wipe_all.c | 50 +
lib/tdb2/test/api-21-parse_record.c | 71 ++
lib/tdb2/test/api-55-transaction.c | 76 ++
lib/tdb2/test/api-80-tdb_fd.c | 36 +
lib/tdb2/test/api-81-seqnum.c | 79 ++
lib/tdb2/test/api-82-lockattr.c | 248 ++++
lib/tdb2/test/api-83-openhook.c | 99 ++
lib/tdb2/test/api-91-get-stats.c | 59 +
lib/tdb2/test/api-92-get-set-readonly.c | 120 ++
lib/tdb2/test/api-93-repack.c | 82 ++
lib/tdb2/test/api-add-remove-flags.c | 94 ++
lib/tdb2/test/api-check-callback.c | 90 ++
lib/tdb2/test/api-firstkey-nextkey.c | 163 +++
lib/tdb2/test/api-fork-test.c | 204 ++++
lib/tdb2/test/api-locktimeout.c | 194 ++++
lib/tdb2/test/api-missing-entries.c | 43 +
lib/tdb2/test/api-open-multiple-times.c | 93 ++
lib/tdb2/test/api-record-expand.c | 55 +
lib/tdb2/test/api-simple-delete.c | 43 +
lib/tdb2/test/api-summary.c | 63 +
lib/tdb2/test/external-agent.c | 18 +-
lib/tdb2/test/external-agent.h | 3 +
lib/tdb2/test/failtest_helper.h | 6 +-
lib/tdb2/test/jenkins-be-hash.tdb1 | Bin 0 -> 696 bytes
lib/tdb2/test/jenkins-le-hash.tdb1 | Bin 0 -> 696 bytes
lib/tdb2/test/layout.c | 6 +-
lib/tdb2/test/lock-tracking.c | 13 +-
lib/tdb2/test/logging.c | 8 +-
lib/tdb2/test/logging.h | 2 +
lib/tdb2/test/old-nohash-be.tdb1 | Bin 0 -> 696 bytes
lib/tdb2/test/old-nohash-le.tdb1 | Bin 0 -> 696 bytes
lib/tdb2/test/run-001-encode.c | 9 +-
lib/tdb2/test/run-001-fls.c | 9 +-
lib/tdb2/test/run-01-new_database.c | 40 +-
lib/tdb2/test/run-02-expand.c | 9 +-
lib/tdb2/test/run-03-coalesce.c | 19 +-
lib/tdb2/test/run-04-basichash.c | 17 +-
lib/tdb2/test/run-05-readonly-open.c | 18 +-
lib/tdb2/test/run-10-simple-store.c | 16 +-
lib/tdb2/test/run-11-simple-fetch.c | 16 +-
lib/tdb2/test/run-12-check.c | 61 +
lib/tdb2/test/run-12-store.c | 58 -
lib/tdb2/test/run-13-delete.c | 207 ----
lib/tdb2/test/run-14-exists.c | 57 -
lib/tdb2/test/run-15-append.c | 44 +-
lib/tdb2/test/run-16-wipe_all.c | 50 -
lib/tdb2/test/run-20-growhash.c | 11 +-
lib/tdb2/test/run-21-parse_record.c | 70 --
lib/tdb2/test/run-25-hashoverload.c | 10 +-
lib/tdb2/test/run-30-exhaust-before-expand.c | 11 +-
lib/tdb2/test/run-35-convert.c | 57 +
lib/tdb2/test/run-50-multiple-freelists.c | 17 +-
lib/tdb2/test/run-55-transaction.c | 75 --
lib/tdb2/test/run-56-open-during-transaction.c | 22 +-
lib/tdb2/test/run-57-die-during-transaction.c | 57 +-
lib/tdb2/test/run-64-bit-tdb.c | 10 +-
lib/tdb2/test/run-80-tdb_fd.c | 35 -
lib/tdb2/test/run-81-seqnum.c | 71 --
lib/tdb2/test/run-82-lockattr.c | 263 -----
lib/tdb2/test/run-83-openhook.c | 98 --
lib/tdb2/test/run-90-get-set-attributes.c | 71 +-
lib/tdb2/test/run-91-get-stats.c | 59 -
lib/tdb2/test/run-add-remove-flags.c | 93 --
lib/tdb2/test/run-check-callback.c | 90 --
lib/tdb2/test/run-expand-in-transaction.c | 14 +-
lib/tdb2/test/run-features.c | 10 +-
lib/tdb2/test/run-firstkey-nextkey.c | 162 ---
lib/tdb2/test/run-fork-test.c | 180 ---
lib/tdb2/test/run-lockall.c | 20 +-
lib/tdb2/test/run-locktimeout.c | 192 ----
lib/tdb2/test/run-missing-entries.c | 48 -
lib/tdb2/test/run-open-multiple-times.c | 84 --
lib/tdb2/test/run-record-expand.c | 53 -
lib/tdb2/test/run-remap-in-read_traverse.c | 10 +-
lib/tdb2/test/run-seed.c | 10 +-
lib/tdb2/test/run-simple-delete.c | 42 -
lib/tdb2/test/run-summary.c | 60 -
lib/tdb2/test/run-tdb1-3G-file.c | 125 ++
lib/tdb2/test/run-tdb1-bad-tdb-header.c | 52 +
lib/tdb2/test/run-tdb1-check.c | 59 +
lib/tdb2/test/run-tdb1-corrupt.c | 123 ++
lib/tdb2/test/run-tdb1-endian.c | 56 +
lib/tdb2/test/run-tdb1-hashsize.c | 61 +
lib/tdb2/test/run-tdb1-incompatible.c | 213 ++++
lib/tdb2/test/run-tdb1-nested-transactions.c | 73 ++
lib/tdb2/test/run-tdb1-nested-traverse.c | 87 ++
lib/tdb2/test/run-tdb1-no-lock-during-traverse.c | 111 ++
lib/tdb2/test/run-tdb1-oldhash.c | 45 +
lib/tdb2/test/run-tdb1-readonly-check.c | 47 +
lib/tdb2/test/run-tdb1-rwlock-check.c | 42 +
lib/tdb2/test/run-tdb1-seqnum-wrap.c | 39 +
lib/tdb2/test/run-tdb1-summary.c | 56 +
lib/tdb2/test/run-tdb1-traverse-in-transaction.c | 85 ++
lib/tdb2/test/run-tdb1-wronghash-fail.c | 143 +++
lib/tdb2/test/run-tdb1-zero-append.c | 36 +
lib/tdb2/test/run-tdb1.c | 42 +
lib/tdb2/test/run-tdb_errorstr.c | 9 +-
lib/tdb2/test/run-tdb_foreach.c | 86 ++
lib/tdb2/test/run-traverse.c | 10 +-
lib/tdb2/test/rwlock-be.tdb1 | Bin 0 -> 696 bytes
lib/tdb2/test/rwlock-le.tdb1 | Bin 0 -> 696 bytes
lib/tdb2/test/tdb1-external-agent.c | 188 +++
lib/tdb2/test/tdb1-external-agent.h | 40 +
lib/tdb2/test/tdb1-lock-tracking.c | 146 +++
lib/tdb2/test/tdb1-lock-tracking.h | 26 +
lib/tdb2/test/tdb1.corrupt | Bin 0 -> 192512 bytes
lib/tdb2/test/tdb2-source.h | 21 +
lib/tdb2/tools/growtdb-bench.c | 4 +-
lib/tdb2/tools/speed.c | 11 +-
lib/tdb2/tools/tdb2tool.c | 10 +-
lib/tdb2/tools/tdb2torture.c | 10 +-
lib/tdb2/transaction.c | 348 +++---
lib/tdb2/traverse.c | 41 +-
lib/tdb2/wscript | 6 +-
lib/tdb_compat/tdb_compat.c | 71 ++-
lib/tdb_compat/tdb_compat.h | 17 +-
lib/util/tdb_wrap.c | 4 +-
source3/lib/dbwrap/dbwrap_tdb.c | 8 +-
source3/lib/util_tdb.c | 11 +-
149 files changed, 12000 insertions(+), 2871 deletions(-)
create mode 100644 lib/tdb2/private.h.orig
create mode 100644 lib/tdb2/tdb1_check.c
create mode 100644 lib/tdb2/tdb1_freelist.c
create mode 100644 lib/tdb2/tdb1_hash.c
create mode 100644 lib/tdb2/tdb1_io.c
create mode 100644 lib/tdb2/tdb1_lock.c
create mode 100644 lib/tdb2/tdb1_open.c
create mode 100644 lib/tdb2/tdb1_private.h
create mode 100644 lib/tdb2/tdb1_summary.c
create mode 100644 lib/tdb2/tdb1_tdb.c
create mode 100644 lib/tdb2/tdb1_transaction.c
create mode 100644 lib/tdb2/tdb1_traverse.c
create mode 100644 lib/tdb2/test/api-12-store.c
create mode 100644 lib/tdb2/test/api-13-delete.c
create mode 100644 lib/tdb2/test/api-14-exists.c
create mode 100644 lib/tdb2/test/api-16-wipe_all.c
create mode 100644 lib/tdb2/test/api-21-parse_record.c
create mode 100644 lib/tdb2/test/api-55-transaction.c
create mode 100644 lib/tdb2/test/api-80-tdb_fd.c
create mode 100644 lib/tdb2/test/api-81-seqnum.c
create mode 100644 lib/tdb2/test/api-82-lockattr.c
create mode 100644 lib/tdb2/test/api-83-openhook.c
create mode 100644 lib/tdb2/test/api-91-get-stats.c
create mode 100644 lib/tdb2/test/api-92-get-set-readonly.c
create mode 100644 lib/tdb2/test/api-93-repack.c
create mode 100644 lib/tdb2/test/api-add-remove-flags.c
create mode 100644 lib/tdb2/test/api-check-callback.c
create mode 100644 lib/tdb2/test/api-firstkey-nextkey.c
create mode 100644 lib/tdb2/test/api-fork-test.c
create mode 100644 lib/tdb2/test/api-locktimeout.c
create mode 100644 lib/tdb2/test/api-missing-entries.c
create mode 100644 lib/tdb2/test/api-open-multiple-times.c
create mode 100644 lib/tdb2/test/api-record-expand.c
create mode 100644 lib/tdb2/test/api-simple-delete.c
create mode 100644 lib/tdb2/test/api-summary.c
create mode 100644 lib/tdb2/test/jenkins-be-hash.tdb1
create mode 100644 lib/tdb2/test/jenkins-le-hash.tdb1
create mode 100644 lib/tdb2/test/old-nohash-be.tdb1
create mode 100644 lib/tdb2/test/old-nohash-le.tdb1
create mode 100644 lib/tdb2/test/run-12-check.c
delete mode 100644 lib/tdb2/test/run-12-store.c
delete mode 100644 lib/tdb2/test/run-13-delete.c
delete mode 100644 lib/tdb2/test/run-14-exists.c
delete mode 100644 lib/tdb2/test/run-16-wipe_all.c
delete mode 100644 lib/tdb2/test/run-21-parse_record.c
create mode 100644 lib/tdb2/test/run-35-convert.c
delete mode 100644 lib/tdb2/test/run-55-transaction.c
delete mode 100644 lib/tdb2/test/run-80-tdb_fd.c
delete mode 100644 lib/tdb2/test/run-81-seqnum.c
delete mode 100644 lib/tdb2/test/run-82-lockattr.c
delete mode 100644 lib/tdb2/test/run-83-openhook.c
delete mode 100644 lib/tdb2/test/run-91-get-stats.c
delete mode 100644 lib/tdb2/test/run-add-remove-flags.c
delete mode 100644 lib/tdb2/test/run-check-callback.c
delete mode 100644 lib/tdb2/test/run-firstkey-nextkey.c
delete mode 100644 lib/tdb2/test/run-fork-test.c
delete mode 100644 lib/tdb2/test/run-locktimeout.c
delete mode 100644 lib/tdb2/test/run-missing-entries.c
delete mode 100644 lib/tdb2/test/run-open-multiple-times.c
delete mode 100644 lib/tdb2/test/run-record-expand.c
delete mode 100644 lib/tdb2/test/run-simple-delete.c
delete mode 100644 lib/tdb2/test/run-summary.c
create mode 100644 lib/tdb2/test/run-tdb1-3G-file.c
create mode 100644 lib/tdb2/test/run-tdb1-bad-tdb-header.c
create mode 100644 lib/tdb2/test/run-tdb1-check.c
create mode 100644 lib/tdb2/test/run-tdb1-corrupt.c
create mode 100644 lib/tdb2/test/run-tdb1-endian.c
create mode 100644 lib/tdb2/test/run-tdb1-hashsize.c
create mode 100644 lib/tdb2/test/run-tdb1-incompatible.c
create mode 100644 lib/tdb2/test/run-tdb1-nested-transactions.c
create mode 100644 lib/tdb2/test/run-tdb1-nested-traverse.c
create mode 100644 lib/tdb2/test/run-tdb1-no-lock-during-traverse.c
create mode 100644 lib/tdb2/test/run-tdb1-oldhash.c
create mode 100644 lib/tdb2/test/run-tdb1-readonly-check.c
create mode 100644 lib/tdb2/test/run-tdb1-rwlock-check.c
create mode 100644 lib/tdb2/test/run-tdb1-seqnum-wrap.c
create mode 100644 lib/tdb2/test/run-tdb1-summary.c
create mode 100644 lib/tdb2/test/run-tdb1-traverse-in-transaction.c
create mode 100644 lib/tdb2/test/run-tdb1-wronghash-fail.c
create mode 100644 lib/tdb2/test/run-tdb1-zero-append.c
create mode 100644 lib/tdb2/test/run-tdb1.c
create mode 100644 lib/tdb2/test/run-tdb_foreach.c
create mode 100644 lib/tdb2/test/rwlock-be.tdb1
create mode 100644 lib/tdb2/test/rwlock-le.tdb1
create mode 100644 lib/tdb2/test/tdb1-external-agent.c
create mode 100644 lib/tdb2/test/tdb1-external-agent.h
create mode 100644 lib/tdb2/test/tdb1-lock-tracking.c
create mode 100644 lib/tdb2/test/tdb1-lock-tracking.h
create mode 100644 lib/tdb2/test/tdb1.corrupt
create mode 100644 lib/tdb2/test/tdb2-source.h
Changeset truncated at 500 lines:
diff --git a/lib/ccan/libccan.m4 b/lib/ccan/libccan.m4
index df38d3b..7dbea58 100644
--- a/lib/ccan/libccan.m4
+++ b/lib/ccan/libccan.m4
@@ -236,6 +236,21 @@ if test x"$samba_cv_builtin_types_compatible_p" = xyes ; then
[whether we have __builtin_types_compatible_p])
fi
+AC_CACHE_CHECK([whether we have __builtin_choose_exptr],
+ samba_cv_builtin_choose_expr,
+ [
+ AC_LINK_IFELSE(
+ [int main(void) {
+ return __builtin_choose_expr(1, 0, "garbage");
+ }],
+ samba_cv_builtin_types_choose_expr=yes)
+ ])
+
+if test x"$samba_cv_builtin_choose_expr" = xyes ; then
+ AC_DEFINE(HAVE_BUILTIN_CHOOSE_EXPR, 1,
+ [whether we have __builtin_choose_expr])
+fi
+
AC_CACHE_CHECK([whether we have __builtin_compound_literals],
samba_cv_builtin_compound_literals,
[
diff --git a/lib/ccan/wscript b/lib/ccan/wscript
index 0543a4d..9daf091 100644
--- a/lib/ccan/wscript
+++ b/lib/ccan/wscript
@@ -79,6 +79,9 @@ def configure(conf):
Logs.error("Failed endian determination. The PDP-11 is back?")
sys.exit(1)
+ conf.CHECK_CODE('return __builtin_choose_expr(1, 0, "garbage");',
+ link=True,
+ define='HAVE_BUILTIN_CHOOSE_EXPR')
conf.CHECK_CODE('return __builtin_clz(1) == (sizeof(int)*8 - 1) ? 0 : 1;',
link=True,
define='HAVE_BUILTIN_CLZ')
diff --git a/lib/ldb/ldb_tdb/ldb_tdb_wrap.c b/lib/ldb/ldb_tdb/ldb_tdb_wrap.c
index 16a037a..3ddcba5 100644
--- a/lib/ldb/ldb_tdb/ldb_tdb_wrap.c
+++ b/lib/ldb/ldb_tdb/ldb_tdb_wrap.c
@@ -28,6 +28,7 @@
#if BUILD_TDB2
static void ltdb_log_fn(struct tdb_context *tdb,
enum tdb_log_level level,
+ enum TDB_ERROR ecode,
const char *message,
struct ldb_context *ldb)
{
@@ -45,7 +46,8 @@ static void ltdb_log_fn(struct tdb_context *tdb,
ldb_level = LDB_DEBUG_FATAL;
}
- ldb_debug(ldb, ldb_level, "ltdb: tdb(%s): %s", name, message);
+ ldb_debug(ldb, ldb_level, "ltdb: tdb(%s): %s: %s", name,
+ tdb_errorstr(ecode), message);
}
#else /* !TDB2 */
static void ltdb_log_fn(struct tdb_context *tdb, enum tdb_debug_level level, const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4);
diff --git a/lib/tdb2/check.c b/lib/tdb2/check.c
index 52fb188..3003b62 100644
--- a/lib/tdb2/check.c
+++ b/lib/tdb2/check.c
@@ -148,7 +148,7 @@ static enum TDB_ERROR check_hash_chain(struct tdb_context *tdb,
off = tdb_read_off(tdb, off + offsetof(struct tdb_chain, next));
if (TDB_OFF_IS_ERR(off)) {
- return off;
+ return TDB_OFF_TO_ERR(off);
}
if (off == 0)
return TDB_SUCCESS;
@@ -436,7 +436,7 @@ fail:
static enum TDB_ERROR check_hash(struct tdb_context *tdb,
tdb_off_t used[],
size_t num_used, size_t num_ftables,
- int (*check)(TDB_DATA, TDB_DATA, void *),
+ enum TDB_ERROR (*check)(TDB_DATA, TDB_DATA, void *),
void *data)
{
/* Free tables also show up as used. */
@@ -478,7 +478,7 @@ static enum TDB_ERROR check_free(struct tdb_context *tdb,
}
- ecode = tdb->methods->oob(tdb, off
+ ecode = tdb->tdb2.io->oob(tdb, off
+ frec_len(frec)
+ sizeof(struct tdb_used_record),
false);
@@ -534,7 +534,7 @@ static enum TDB_ERROR check_free_table(struct tdb_context *tdb,
h = bucket_off(ftable_off, i);
for (off = tdb_read_off(tdb, h); off; off = f.next) {
if (TDB_OFF_IS_ERR(off)) {
- return off;
+ return TDB_OFF_TO_ERR(off);
}
if (!first) {
off &= TDB_OFF_MASK;
@@ -587,9 +587,9 @@ tdb_off_t dead_space(struct tdb_context *tdb, tdb_off_t off)
for (len = 0; off + len < tdb->file->map_size; len++) {
char c;
- ecode = tdb->methods->tread(tdb, off, &c, 1);
+ ecode = tdb->tdb2.io->tread(tdb, off, &c, 1);
if (ecode != TDB_SUCCESS) {
- return ecode;
+ return TDB_ERR_TO_OFF(ecode);
}
if (c != 0 && c != 0x43)
break;
@@ -634,7 +634,7 @@ static enum TDB_ERROR check_linear(struct tdb_context *tdb,
} else {
len = dead_space(tdb, off);
if (TDB_OFF_IS_ERR(len)) {
- return len;
+ return TDB_OFF_TO_ERR(len);
}
if (len < sizeof(rec.r)) {
return tdb_logerr(tdb, TDB_ERR_CORRUPT,
@@ -782,6 +782,12 @@ enum TDB_ERROR tdb_check_(struct tdb_context *tdb,
uint64_t features;
enum TDB_ERROR ecode;
+ if (tdb->flags & TDB_VERSION1) {
+ if (tdb1_check(tdb, check, data) == -1)
+ return tdb->last_error;
+ return TDB_SUCCESS;
+ }
+
ecode = tdb_allrecord_lock(tdb, F_RDLCK, TDB_LOCK_WAIT, false);
if (ecode != TDB_SUCCESS) {
return tdb->last_error = ecode;
@@ -805,7 +811,7 @@ enum TDB_ERROR tdb_check_(struct tdb_context *tdb,
for (ft = first_ftable(tdb); ft; ft = next_ftable(tdb, ft)) {
if (TDB_OFF_IS_ERR(ft)) {
- ecode = ft;
+ ecode = TDB_OFF_TO_ERR(ft);
goto out;
}
ecode = check_free_table(tdb, ft, num_ftables, fr, num_free,
diff --git a/lib/tdb2/doc/TDB1_porting.txt b/lib/tdb2/doc/TDB1_porting.txt
index 90ba249..ef305ca 100644
--- a/lib/tdb2/doc/TDB1_porting.txt
+++ b/lib/tdb2/doc/TDB1_porting.txt
@@ -42,3 +42,31 @@ Interface differences between TDB1 and TDB2.
tdb_lockall_read(): child must call tdb_unlockall_read()
tdb_chainlock(): child must call tdb_chainunlock()
tdb_parse() callback: child must return from tdb_parse()
+
+- tdb2 will not open a non-tdb file, even if O_CREAT is specified.
+
+- There is no tdb_traverse_read. For operating on TDB1 files, you can
+ simulate it by tdb_add_flag(tdb, TDB_RDONLY); tdb_traverse();
+ tdb_remove_flag(tdb, TDB_RDONLY). This may be desirable because
+ traverse on TDB1 files use a write lock on the entire database
+ unless it's read-only.
+
+- Failure inside a transaction (such as a lock function failing) does
+ not implicitly cancel the transaction; you still need to call
+ tdb_transaction_cancel().
+
+TDB1 Compatibility:
+
+- tdb2's offers a tdb1_incompatible_hash function, which is the same
+ as the default hash with the TDB_INCOMPATIBLE_HASH flag. There is
+ no way of marking an old TDB incompatible with versions < 1.2.6
+ while using any other hash.
+
+- The TDB_ATTRIBUTE_TDB1_HASHSIZE attribute can be used to control the
+ hash size, but only when creating (ie. O_CREAT) a TDB1
+ (ie. TDB_VERSION1).
+
+- There is no TDB_CLEAR_IF_FIRST flag; it has severe scalability and
+ API problems. If necessary, you can emulate this by using the open
+ hook and placing a 1-byte lock at offset 4. If your program forks,
+ you will need to place this lock again in the child.
diff --git a/lib/tdb2/free.c b/lib/tdb2/free.c
index a770751..bb819a2 100644
--- a/lib/tdb2/free.c
+++ b/lib/tdb2/free.c
@@ -65,18 +65,18 @@ enum TDB_ERROR tdb_ftable_init(struct tdb_context *tdb)
unsigned int rnd, max = 0, count = 0;
tdb_off_t off;
- tdb->ftable_off = off = first_ftable(tdb);
- tdb->ftable = 0;
+ tdb->tdb2.ftable_off = off = first_ftable(tdb);
+ tdb->tdb2.ftable = 0;
while (off) {
if (TDB_OFF_IS_ERR(off)) {
- return off;
+ return TDB_OFF_TO_ERR(off);
}
rnd = random();
if (rnd >= max) {
- tdb->ftable_off = off;
- tdb->ftable = count;
+ tdb->tdb2.ftable_off = off;
+ tdb->tdb2.ftable = count;
max = rnd;
}
@@ -146,14 +146,14 @@ static enum TDB_ERROR remove_from_list(struct tdb_context *tdb,
/* Get prev->next */
prev_next = tdb_read_off(tdb, off);
if (TDB_OFF_IS_ERR(prev_next))
- return prev_next;
+ return TDB_OFF_TO_ERR(prev_next);
/* If prev->next == 0, we were head: update bucket to point to next. */
if (prev_next == 0) {
/* We must preserve upper bits. */
head = tdb_read_off(tdb, b_off);
if (TDB_OFF_IS_ERR(head))
- return head;
+ return TDB_OFF_TO_ERR(head);
if ((head & TDB_OFF_MASK) != r_off) {
return tdb_logerr(tdb, TDB_ERR_CORRUPT, TDB_LOG_ERROR,
@@ -178,7 +178,7 @@ static enum TDB_ERROR remove_from_list(struct tdb_context *tdb,
if (r->next == 0) {
head = tdb_read_off(tdb, b_off);
if (TDB_OFF_IS_ERR(head))
- return head;
+ return TDB_OFF_TO_ERR(head);
head &= TDB_OFF_MASK;
off = head + offsetof(struct tdb_free_record, magic_and_prev);
} else {
@@ -215,10 +215,10 @@ static enum TDB_ERROR enqueue_in_free(struct tdb_context *tdb,
head = tdb_read_off(tdb, b_off);
if (TDB_OFF_IS_ERR(head))
- return head;
+ return TDB_OFF_TO_ERR(head);
/* We only need to set ftable_and_len; rest is set in enqueue_in_free */
- new.ftable_and_len = ((uint64_t)tdb->ftable << (64 - TDB_OFF_UPPER_STEAL))
+ new.ftable_and_len = ((uint64_t)tdb->tdb2.ftable << (64 - TDB_OFF_UPPER_STEAL))
| len;
/* new->next = head. */
@@ -287,8 +287,8 @@ static tdb_off_t ftable_offset(struct tdb_context *tdb, unsigned int ftable)
tdb_off_t off;
unsigned int i;
- if (likely(tdb->ftable == ftable))
- return tdb->ftable_off;
+ if (likely(tdb->tdb2.ftable == ftable))
+ return tdb->tdb2.ftable_off;
off = first_ftable(tdb);
for (i = 0; i < ftable; i++) {
@@ -336,7 +336,7 @@ static tdb_len_t coalesce(struct tdb_context *tdb,
nb_off = ftable_offset(tdb, ftable);
if (TDB_OFF_IS_ERR(nb_off)) {
tdb_access_release(tdb, r);
- ecode = nb_off;
+ ecode = TDB_OFF_TO_ERR(nb_off);
goto err;
}
nb_off = bucket_off(nb_off, bucket);
@@ -372,7 +372,7 @@ static tdb_len_t coalesce(struct tdb_context *tdb,
/* Did we just mess up a record you were hoping to use? */
if (end == *protect) {
tdb->stats.alloc_coalesce_iterate_clash++;
- *protect = TDB_ERR_NOEXIST;
+ *protect = TDB_ERR_TO_OFF(TDB_ERR_NOEXIST);
}
ecode = remove_from_list(tdb, nb_off, end, &rec);
@@ -393,7 +393,7 @@ static tdb_len_t coalesce(struct tdb_context *tdb,
/* Before we expand, check this isn't one you wanted protected? */
if (off == *protect) {
- *protect = TDB_ERR_EXISTS;
+ *protect = TDB_ERR_TO_OFF(TDB_ERR_EXISTS);
tdb->stats.alloc_coalesce_iterate_clash++;
}
@@ -421,7 +421,7 @@ static tdb_len_t coalesce(struct tdb_context *tdb,
if (ecode != TDB_SUCCESS) {
/* Need to drop lock. Can't rely on anything stable. */
tdb->stats.alloc_coalesce_lockfail++;
- *protect = TDB_ERR_CORRUPT;
+ *protect = TDB_ERR_TO_OFF(TDB_ERR_CORRUPT);
/* We have to drop this to avoid deadlocks, so make sure record
* doesn't get coalesced by someone else! */
@@ -441,7 +441,7 @@ static tdb_len_t coalesce(struct tdb_context *tdb,
ecode = add_free_record(tdb, off, end - off, TDB_LOCK_WAIT,
false);
if (ecode != TDB_SUCCESS) {
- return ecode;
+ return TDB_ERR_TO_OFF(ecode);
}
} else if (TDB_OFF_IS_ERR(*protect)) {
/* For simplicity, we always drop lock if they can't continue */
@@ -455,7 +455,7 @@ static tdb_len_t coalesce(struct tdb_context *tdb,
err:
/* To unify error paths, we *always* unlock bucket on error. */
tdb_unlock_free_bucket(tdb, b_off);
- return ecode;
+ return TDB_ERR_TO_OFF(ecode);
}
/* List is locked: we unlock it. */
@@ -469,7 +469,7 @@ static enum TDB_ERROR coalesce_list(struct tdb_context *tdb,
off = tdb_read_off(tdb, b_off);
if (TDB_OFF_IS_ERR(off)) {
- ecode = off;
+ ecode = TDB_OFF_TO_ERR(off);
goto unlock_err;
}
/* A little bit of paranoia: counter should be 0. */
@@ -488,7 +488,7 @@ static enum TDB_ERROR coalesce_list(struct tdb_context *tdb,
coal = coalesce(tdb, off, b_off, frec_len(&rec), &next);
if (TDB_OFF_IS_ERR(coal)) {
/* This has already unlocked on error. */
- return coal;
+ return TDB_OFF_TO_ERR(coal);
}
if (TDB_OFF_IS_ERR(next)) {
/* Coalescing had to unlock, so stop. */
@@ -520,7 +520,7 @@ static enum TDB_ERROR coalesce_list(struct tdb_context *tdb,
/* Get the old head. */
oldhoff = tdb_read_off(tdb, b_off);
if (TDB_OFF_IS_ERR(oldhoff)) {
- ecode = oldhoff;
+ ecode = TDB_OFF_TO_ERR(oldhoff);
goto unlock_err;
}
@@ -595,7 +595,7 @@ enum TDB_ERROR add_free_record(struct tdb_context *tdb,
len = len_with_header - sizeof(struct tdb_used_record);
- b_off = bucket_off(tdb->ftable_off, size_to_bucket(len));
+ b_off = bucket_off(tdb->tdb2.ftable_off, size_to_bucket(len));
ecode = tdb_lock_free_bucket(tdb, b_off, waitflag);
if (ecode != TDB_SUCCESS) {
return ecode;
@@ -606,7 +606,7 @@ enum TDB_ERROR add_free_record(struct tdb_context *tdb,
/* Coalescing unlocks free list. */
if (!ecode && coalesce)
- ecode = coalesce_list(tdb, tdb->ftable_off, b_off, 2);
+ ecode = coalesce_list(tdb, tdb->tdb2.ftable_off, b_off, 2);
else
tdb_unlock_free_bucket(tdb, b_off);
return ecode;
@@ -661,7 +661,7 @@ static tdb_off_t lock_and_alloc(struct tdb_context *tdb,
/* Lock this bucket. */
ecode = tdb_lock_free_bucket(tdb, b_off, TDB_LOCK_WAIT);
if (ecode != TDB_SUCCESS) {
- return ecode;
+ return TDB_ERR_TO_OFF(ecode);
}
best.ftable_and_len = -1ULL;
@@ -677,7 +677,7 @@ static tdb_off_t lock_and_alloc(struct tdb_context *tdb,
* as we go. */
off = tdb_read_off(tdb, b_off);
if (TDB_OFF_IS_ERR(off)) {
- ecode = off;
+ ecode = TDB_OFF_TO_ERR(off);
goto unlock_err;
}
off &= TDB_OFF_MASK;
@@ -752,7 +752,7 @@ static tdb_off_t lock_and_alloc(struct tdb_context *tdb,
/* For futureproofing, we put a 0 in any unused space. */
if (rec_extra_padding(&rec)) {
- ecode = tdb->methods->twrite(tdb, best_off + sizeof(rec)
+ ecode = tdb->tdb2.io->twrite(tdb, best_off + sizeof(rec)
+ keylen + datalen, "", 1);
if (ecode != TDB_SUCCESS) {
goto unlock_err;
@@ -768,7 +768,7 @@ static tdb_off_t lock_and_alloc(struct tdb_context *tdb,
+ frec_len(&best) - leftover,
leftover, TDB_LOCK_WAIT, false);
if (ecode != TDB_SUCCESS) {
- best_off = ecode;
+ best_off = TDB_ERR_TO_OFF(ecode);
}
}
tdb_unlock_free_bucket(tdb, b_off);
@@ -781,7 +781,7 @@ static tdb_off_t lock_and_alloc(struct tdb_context *tdb,
unlock_err:
tdb_unlock_free_bucket(tdb, b_off);
- return ecode;
+ return TDB_ERR_TO_OFF(ecode);
}
/* Get a free block from current free list, or 0 if none, -ve on error. */
@@ -800,9 +800,9 @@ static tdb_off_t get_free(struct tdb_context *tdb,
else
start_b = size_to_bucket(adjust_size(keylen, datalen));
- ftable_off = tdb->ftable_off;
- ftable = tdb->ftable;
- while (!wrapped || ftable_off != tdb->ftable_off) {
+ ftable_off = tdb->tdb2.ftable_off;
+ ftable = tdb->tdb2.ftable;
+ while (!wrapped || ftable_off != tdb->tdb2.ftable_off) {
/* Start at exact size bucket, and search up... */
for (b = find_free_head(tdb, ftable_off, start_b);
b < TDB_FREE_BUCKETS;
@@ -819,8 +819,8 @@ static tdb_off_t get_free(struct tdb_context *tdb,
if (b == TDB_FREE_BUCKETS - 1)
tdb->stats.alloc_bucket_max++;
/* Worked? Stay using this list. */
- tdb->ftable_off = ftable_off;
- tdb->ftable = ftable;
+ tdb->tdb2.ftable_off = ftable_off;
+ tdb->tdb2.ftable = ftable;
return off;
}
/* Didn't work. Try next bucket. */
@@ -898,7 +898,7 @@ static enum TDB_ERROR tdb_expand(struct tdb_context *tdb, tdb_len_t size)
/* Someone else may have expanded the file, so retry. */
old_size = tdb->file->map_size;
- tdb->methods->oob(tdb, tdb->file->map_size + 1, true);
+ tdb->tdb2.io->oob(tdb, tdb->file->map_size + 1, true);
if (tdb->file->map_size != old_size) {
tdb_unlock_expand(tdb, F_WRLCK);
return TDB_SUCCESS;
@@ -930,7 +930,7 @@ static enum TDB_ERROR tdb_expand(struct tdb_context *tdb, tdb_len_t size)
/* We need room for the record header too. */
wanted = adjust_size(0, sizeof(struct tdb_used_record) + wanted);
- ecode = tdb->methods->expand_file(tdb, wanted);
+ ecode = tdb->tdb2.io->expand_file(tdb, wanted);
if (ecode != TDB_SUCCESS) {
tdb_unlock_expand(tdb, F_WRLCK);
return ecode;
@@ -950,7 +950,7 @@ tdb_off_t alloc(struct tdb_context *tdb, size_t keylen, size_t datalen,
tdb_off_t off;
/* We can't hold pointers during this: we could unmap! */
- assert(!tdb->direct_access);
+ assert(!tdb->tdb2.direct_access);
for (;;) {
enum TDB_ERROR ecode;
@@ -960,7 +960,7 @@ tdb_off_t alloc(struct tdb_context *tdb, size_t keylen, size_t datalen,
ecode = tdb_expand(tdb, adjust_size(keylen, datalen));
if (ecode != TDB_SUCCESS) {
- return ecode;
+ return TDB_ERR_TO_OFF(ecode);
}
}
diff --git a/lib/tdb2/hash.c b/lib/tdb2/hash.c
index 1359cfe..619d56f 100644
--- a/lib/tdb2/hash.c
+++ b/lib/tdb2/hash.c
@@ -16,8 +16,20 @@
License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
#include "private.h"
+#include <ccan/hash/hash.h>
#include <assert.h>
+/* Default hash function. */
+uint64_t tdb_jenkins_hash(const void *key, size_t length, uint64_t seed,
+ void *unused)
+{
+ uint64_t ret;
+ /* hash64_stable assumes lower bits are more important; they are a
+ * slightly better hash. We use the upper bits first, so swap them. */
+ ret = hash64_stable((const unsigned char *)key, length, seed);
+ return (ret >> 32) | (ret << 32);
+}
+
uint64_t tdb_hash(struct tdb_context *tdb, const void *ptr, size_t len)
{
return tdb->hash_fn(ptr, len, tdb->hash_seed, tdb->hash_data);
@@ -78,7 +90,7 @@ static tdb_bool_err key_matches(struct tdb_context *tdb,
rkey = tdb_access_read(tdb, off + sizeof(*rec), key->dsize, false);
if (TDB_PTR_IS_ERR(rkey)) {
- return TDB_PTR_ERR(rkey);
+ return (tdb_bool_err)TDB_PTR_ERR(rkey);
}
if (memcmp(rkey, key->dptr, key->dsize) == 0)
ret = true;
@@ -116,7 +128,7 @@ static tdb_bool_err match(struct tdb_context *tdb,
off = val & TDB_OFF_MASK;
ecode = tdb_read_convert(tdb, off, rec, sizeof(*rec));
--
Samba Shared Repository
More information about the samba-cvs
mailing list