rusty/samba.git
11 years agosource3/utils/smbcontrol: convert to dbwrap dbwrap
Rusty Russell [Fri, 15 Jun 2012 04:15:19 +0000 (13:45 +0930)]
source3/utils/smbcontrol: convert to dbwrap

ie. winbindd_cache.tdb.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
11 years agosource3/nmbd: convert to dbwrap
Rusty Russell [Fri, 15 Jun 2012 04:14:19 +0000 (13:44 +0930)]
source3/nmbd: convert to dbwrap

ie. wins.tdb.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
11 years agosource3/winbindd: restore validate logic.
Rusty Russell [Fri, 15 Jun 2012 04:13:19 +0000 (13:43 +0930)]
source3/winbindd: restore validate logic.

Now tdb_validate is db_validate, restore the caller in
source3/winbindd/winbindd_cache.c.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
11 years agosource3/lib/tdb_validate: convert to dbwrap, rename to db_validate.
Rusty Russell [Fri, 15 Jun 2012 04:12:19 +0000 (13:42 +0930)]
source3/lib/tdb_validate: convert to dbwrap, rename to db_validate.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
11 years agosource3/winbindd: convert to dbwrap
Rusty Russell [Fri, 15 Jun 2012 04:11:19 +0000 (13:41 +0930)]
source3/winbindd: convert to dbwrap

We temporarily comment out the tdb_validate calls, until the next patch
where we change that to db_validate.

There's a subtlety here: rather than unlinking winbindd_cache.tdb, we
open it with O_TRUNC.  That way it works even if it's actually
winbindd_cache.ntdb.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
11 years agosource3/lib/gencache.c: convert to dbwrap.
Rusty Russell [Fri, 15 Jun 2012 04:10:19 +0000 (13:40 +0930)]
source3/lib/gencache.c: convert to dbwrap.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
11 years agosource3/intl/lan_tdb.c: convert to dbwrap.
Rusty Russell [Fri, 15 Jun 2012 04:09:19 +0000 (13:39 +0930)]
source3/intl/lan_tdb.c: convert to dbwrap.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
11 years agolibsmbsharemodes: make it handle locking.ntdb.
Rusty Russell [Fri, 15 Jun 2012 04:08:19 +0000 (13:38 +0930)]
libsmbsharemodes: make it handle locking.ntdb.

Rather than force the caller to know what file to specify, we open the
.ntdb file instead if it exists.

This has a problem: if the upgraded Samba hasn't been restarted yet,
this heuristic will fail.  Similarly, a downgrade might leave the ntdb
file around.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
11 years agosource3/printing/tests/vlp.c: convert to dbwrap.
Rusty Russell [Fri, 15 Jun 2012 04:07:19 +0000 (13:37 +0930)]
source3/printing/tests/vlp.c: convert to dbwrap.

Note that migrate_internal() still uses tdb directly; I didn't want to
risk converting that, and there's not much point since an old database
must be a tdb.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
11 years agosource3/lib/eventlog: convert to dbwrap.
Rusty Russell [Fri, 15 Jun 2012 04:07:19 +0000 (13:37 +0930)]
source3/lib/eventlog: convert to dbwrap.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
11 years agosource3/passdb/pdb_tdb.c: convert to dbwrap.
Rusty Russell [Fri, 15 Jun 2012 04:07:19 +0000 (13:37 +0930)]
source3/passdb/pdb_tdb.c: convert to dbwrap.

Access winbindd_idmap.tdb via dbwrap.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
11 years agosource3/libsmb/samlogon_cache.c: convert to dbwrap.
Rusty Russell [Fri, 15 Jun 2012 04:07:19 +0000 (13:37 +0930)]
source3/libsmb/samlogon_cache.c: convert to dbwrap.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
11 years agosource3/printing/nt_printing_tdb: convert to dbwrap.
Rusty Russell [Fri, 15 Jun 2012 04:07:19 +0000 (13:37 +0930)]
source3/printing/nt_printing_tdb: convert to dbwrap.

I removed the version 3 upgrade: I didn't want to change it to a
traverse without testing, and dbwrap doesn't support firstkey/nextkey
traversal.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
11 years agosource3/printing: convert to dbwrap.
Rusty Russell [Fri, 15 Jun 2012 04:07:18 +0000 (13:37 +0930)]
source3/printing: convert to dbwrap.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
11 years agosource3/passdb/login_cache: convert to dbwrap.
Rusty Russell [Fri, 15 Jun 2012 04:07:18 +0000 (13:37 +0930)]
source3/passdb/login_cache: convert to dbwrap.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
11 years agosource3/groupdb/mapping_tdb: convert to dbwrap.
Rusty Russell [Fri, 15 Jun 2012 04:07:18 +0000 (13:37 +0930)]
source3/groupdb/mapping_tdb: convert to dbwrap.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
11 years agosource3/registry: convert to dbwrap.
Rusty Russell [Fri, 15 Jun 2012 04:07:18 +0000 (13:37 +0930)]
source3/registry: convert to dbwrap.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
11 years agosource3/dbwrap: db_s3open()
Rusty Russell [Fri, 15 Jun 2012 04:07:18 +0000 (13:37 +0930)]
source3/dbwrap: db_s3open()

Convenient wrapper to convert source3/ callers from tdb_open_log() to using
dbwrap.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
11 years agolib/dbwrap: depend directly on tdb, not tdb_compat.
Rusty Russell [Fri, 15 Jun 2012 04:07:18 +0000 (13:37 +0930)]
lib/dbwrap: depend directly on tdb, not tdb_compat.

Simple change, as we get rid of tdb_compat in favour of either ntdb directly
or dbwrap.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
11 years agodbwrap: dbwrap_hash_size().
Rusty Russell [Fri, 15 Jun 2012 04:07:18 +0000 (13:37 +0930)]
dbwrap: dbwrap_hash_size().

Implemented for ntdb and tdb; falls back to 0 for others.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
11 years agodbwrap: dbwrap_name().
Rusty Russell [Fri, 15 Jun 2012 04:07:18 +0000 (13:37 +0930)]
dbwrap: dbwrap_name().

Useful for debug messages: particularly once we start switching between .tdb
and .ntdb files.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
11 years agodbwrap: dbwrap_transaction_start_nonblock().
Rusty Russell [Fri, 15 Jun 2012 04:07:17 +0000 (13:37 +0930)]
dbwrap: dbwrap_transaction_start_nonblock().

Implemented for ntdb and tdb; falls back to the blocking variant
for others.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
11 years agodbwrap: dbwrap_fetch_locked_timeout().
Rusty Russell [Fri, 15 Jun 2012 04:07:17 +0000 (13:37 +0930)]
dbwrap: dbwrap_fetch_locked_timeout().

Implemented for ntdb and tdb; falls back to the non-timeout variant
for others.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
11 years agodbwrap: add dbwrap_check() function.
Rusty Russell [Fri, 15 Jun 2012 04:07:17 +0000 (13:37 +0930)]
dbwrap: add dbwrap_check() function.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
11 years agodbwrap: dbwrap_local_open()
Rusty Russell [Fri, 15 Jun 2012 04:07:09 +0000 (13:37 +0930)]
dbwrap: dbwrap_local_open()

This simply opens a tdb: it will eventually switch depending on the
extension.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
11 years agodbwrap: remove get_flags().
Rusty Russell [Fri, 15 Jun 2012 03:53:02 +0000 (13:23 +0930)]
dbwrap: remove get_flags().

The flags returned were TDB-specific: this was only used for detecting
the endianness of obsolete databases (the conversion code was put in in
2003, with reference to Samba 2.3).

It's easier to remove it than to translate the NTDB flags to TDB flags,
and it's a really weird thing to ask for anyway.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
11 years agoutil_tdb: move timeout chainlock variants from source3/lib/util/util_tdb.c
Rusty Russell [Fri, 15 Jun 2012 03:53:02 +0000 (13:23 +0930)]
util_tdb: move timeout chainlock variants from source3/lib/util/util_tdb.c

We're about to use them for dbwrap.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
11 years agolib/util_tdb: depend directly on tdb, not tdb_compat.
Rusty Russell [Fri, 15 Jun 2012 03:53:02 +0000 (13:23 +0930)]
lib/util_tdb: depend directly on tdb, not tdb_compat.

Simple change, as we get rid of tdb_compat in favour of tdb directly.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
11 years agoutil: util_ntdb ntdb_fetch_int32/ntdb_store_int32 and ntdb_add_int32_atomic
Rusty Russell [Fri, 15 Jun 2012 03:53:02 +0000 (13:23 +0930)]
util: util_ntdb ntdb_fetch_int32/ntdb_store_int32 and ntdb_add_int32_atomic

Similar to the util_tdb versions, but return the error code.

ntdb_add_int32_atomic seems a clearer name than tdb_change_int32_atomic.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
11 years agoutil: util_ntdb.c gets NTDB_ERROR => NTSTATUS map.
Rusty Russell [Fri, 15 Jun 2012 03:53:02 +0000 (13:23 +0930)]
util: util_ntdb.c gets NTDB_ERROR => NTSTATUS map.

Very similar to the tdb version.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
11 years agoutil: util_ntdb.c gains bystring functions.
Rusty Russell [Fri, 15 Jun 2012 03:52:43 +0000 (13:22 +0930)]
util: util_ntdb.c gains bystring functions.

Very similar to the util_tdb versions, but these return the error.
I've only implemented those functions actually used.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
11 years agoutil: ntdb_new() supports NTDB_CLEAR_IF_FIRST.
Rusty Russell [Fri, 15 Jun 2012 03:51:43 +0000 (13:21 +0930)]
util: ntdb_new() supports NTDB_CLEAR_IF_FIRST.

There are various issues with NTDB_CLEAR_IF_FIRST which makes it
better if we don't have to use it, but much of the code does, so
we fake up support here.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
11 years agoutil: util_ntdb.c
Rusty Russell [Fri, 15 Jun 2012 03:50:43 +0000 (13:20 +0930)]
util: util_ntdb.c

The first function is ntdb_new: this is preferred over ntdb_open, as
it makes the ntdb_context returned (and all NTDB_DATA returned from
ntdb_fetch) valid talloc pointers.

The API is very similar to tdb_wrap_open().

Note that we handle $TDB_NO_FSYNC here, since ntdb doesn't do that
hack (and it's great for speeding up testing!).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
11 years agontdb: put it back into the build.
Rusty Russell [Fri, 15 Jun 2012 03:49:43 +0000 (13:19 +0930)]
ntdb: put it back into the build.

This doesn't do anything with it yet, just wires it back into the build
(under tdb_compat, which should be going away soon).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
11 years agontdb: optimize ntdb_fetch.
Rusty Russell [Fri, 15 Jun 2012 03:49:40 +0000 (13:19 +0930)]
ntdb: optimize ntdb_fetch.

We access the key on lookup, then access the data in the caller.  It
makes more sense to access both at once.  We also put in a likely()
for the case where the hash is not chained.

Before:
Adding 1000 records: 3644-3724(3675) ns (129656 bytes)
Finding 1000 records: 1596-1696(1622) ns (129656 bytes)
Missing 1000 records: 1409-1525(1452) ns (129656 bytes)
Traversing 1000 records: 1636-1747(1668) ns (129656 bytes)
Deleting 1000 records: 3138-3223(3175) ns (129656 bytes)
Re-adding 1000 records: 3278-3414(3329) ns (129656 bytes)
Appending 1000 records: 5396-5529(5426) ns (253312 bytes)
Churning 1000 records: 9451-10095(9584) ns (253312 bytes)
smbtorture results (--entries=1000)
ntdb speed 183881-191112(188223) ops/sec

After:
Adding 1000 records: 3590-3701(3640) ns (129656 bytes)
Finding 1000 records: 1539-1605(1566) ns (129656 bytes)
Missing 1000 records: 1398-1440(1413) ns (129656 bytes)
Traversing 1000 records: 1629-2015(1710) ns (129656 bytes)
Deleting 1000 records: 3118-3236(3163) ns (129656 bytes)
Re-adding 1000 records: 3235-3355(3275) ns (129656 bytes)
Appending 1000 records: 5335-5444(5385) ns (253312 bytes)
Churning 1000 records: 9350-9955(9494) ns (253312 bytes)
smbtorture results (--entries=1000)
ntdb speed 180559-199981(195106) ops/sec

11 years agontdb: add -h arg to ntdbrestore
Rusty Russell [Fri, 15 Jun 2012 03:49:38 +0000 (13:19 +0930)]
ntdb: add -h arg to ntdbrestore

Since our default hashsize is 8192 not 131, we look fat when we convert
near-empty TDBs.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
11 years agontdb: reduce default hashsize on ntdbtorture.
Rusty Russell [Fri, 15 Jun 2012 03:49:37 +0000 (13:19 +0930)]
ntdb: reduce default hashsize on ntdbtorture.

Just like tdbtorture, having a hashsize of 2 stresses us much more!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
11 years agontdb: add NTDB_ATTRIBUTE_HASHSIZE
Rusty Russell [Fri, 15 Jun 2012 03:49:35 +0000 (13:19 +0930)]
ntdb: add NTDB_ATTRIBUTE_HASHSIZE

Since we've given up on expansion, let them frob the hashsize again.
We have attributes, so we should use them for optional stuff like
this.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
11 years agontdb: remove hash table trees.
Rusty Russell [Fri, 15 Jun 2012 03:49:32 +0000 (13:19 +0930)]
ntdb: remove hash table trees.

TDB2 started with a top-level hash of 1024 entries, divided into 128
groups of 8 buckets.  When a bucket filled, the 8 bucket group
expanded into pointers into 8 new 64-entry hash tables.  When these
filled, they expanded in turn, etc.

It's a nice idea to automatically expand the hash tables, but it
doesn't pay off.  Remove it for NTDB.

1) It only beats TDB performance when the database is huge and the
   TDB hashsize is small.  We are about 20% slower on medium-size
   databases (1000 to 10000 records), worse on really small ones.
2) Since we're 64 bits, our hash tables are already twice as expensive
   as TDB.
3) Since our hash function is good, it means that all groups tend to
   fill at the same time, meaning the hash enlarges by a factor of 128
   all at once, leading to a very large database at that point.
4) Our efficiency would improve if we enlarged the top level, but
   that makes our minimum db size even worse: it's already over 8k,
   and jumps to 1M after about 1000 entries!
5) Making the sub group size larger gives a shallower tree, which
   performs better, but makes the "hash explosion" problem worse.
6) The code is complicated, having to handle delete and reshuffling
   groups of hash buckets, and expansion of buckets.
7) We have to handle the case where all the records somehow end up with
   the same hash value, which requires special code to chain records for
   that case.

On the other hand, it would be nice if we didn't degrade as badly as
TDB does when the hash chains get long.

This patch removes the hash-growing code, but instead of chaining like
TDB does when a bucket fills, we point the bucket to an array of
record pointers.  Since each on-disk NTDB pointer contains some hash
bits from the record (we steal the upper 8 bits of the offset), 99.5%
of the time we don't need to load the record to determine if it
matches.  This makes an array of offsets much more cache-friendly than
a linked list.

Here are the times (in ns) for tdb_store of N records, tdb_store of N
records the second time, and a fetch of all N records.  I've also
included the final database size and the smbtorture local.[n]tdb_speed
results.

Benchmark details:
1) Compiled with -O2.
2) assert() was disabled in TDB2 and NTDB.
3) The "optimize fetch" patch was applied to NTDB.

10 runs, using tmpfs (otherwise massive swapping as db hits ~30M,
despite plenty of RAM).

Insert Re-ins Fetch Size dbspeed
(nsec) (nsec) (nsec) (Kb) (ops/sec)
TDB (10000 hashsize):
100 records:  3882  3320 1609    53 203204
1000 records:  3651  3281 1571   115 218021
10000 records:  3404  3326 1595   880 202874
100000 records:  4317  3825 2097  8262 126811
1000000 records: 11568 11578 9320 77005  25046

TDB2 (1024 hashsize, expandable):
100 records:  3867  3329 1699    17 187100
1000 records:  4040  3249 1639   154 186255
10000 records:  4143  3300 1695  1226 185110
100000 records:  4481  3425 1800 17848 163483
1000000 records:  4055  3534 1878   106386 160774

NTDB (8192 hashsize)
100 records:  4259  3376 1692    82 190852
1000 records:  3640  3275 1566   130 195106
10000 records:  4337  3438 1614   773 188362
100000 records:  4750  5165 1746  9001 169197
1000000 records:  4897  5180 2341 83838 121901

Analysis:
1) TDB wins on small databases, beating TDB2 by ~15%, NTDB by ~10%.
2) TDB starts to lose when hash chains get 10 long (fetch 10% slower
   than TDB2/NTDB).
3) TDB does horribly when hash chains get 100 long (fetch 4x slower
   than NTDB, 5x slower than TDB2, insert about 2-3x slower).
4) TDB2 databases are 40% larger than TDB1.  NTDB is about 15% larger
   than TDB1

11 years agontdb: special accessor functions for read/write of an offset.
Rusty Russell [Fri, 15 Jun 2012 03:27:40 +0000 (12:57 +0930)]
ntdb: special accessor functions for read/write of an offset.

We also split off the NTDB_CONVERT case (where the ntdb is of a
different endian) into its own io function.

NTDB speed:
Adding 10000 records: 3894-9951(8553) ns (815528 bytes)
Finding 10000 records: 1644-4294(3580) ns (815528 bytes)
Missing 10000 records: 1497-4018(3303) ns (815528 bytes)
Traversing 10000 records: 1585-4225(3505) ns (815528 bytes)
Deleting 10000 records: 3088-8154(6927) ns (815528 bytes)
Re-adding 10000 records: 3192-8308(7089) ns (815528 bytes)
Appending 10000 records: 5187-13307(11365) ns (1274312 bytes)
Churning 10000 records: 6772-17567(15078) ns (1274312 bytes)
NTDB speed in transaction:
Adding 10000 records: 1602-2404(2214) ns (815528 bytes)
Finding 10000 records: 456-871(778) ns (815528 bytes)
Missing 10000 records: 393-522(503) ns (815528 bytes)
Traversing 10000 records: 729-1015(945) ns (815528 bytes)
Deleting 10000 records: 1065-1476(1374) ns (815528 bytes)
Re-adding 10000 records: 1397-1930(1819) ns (815528 bytes)
Appending 10000 records: 2927-3351(3184) ns (1274312 bytes)
Churning 10000 records: 3921-4697(4378) ns (1274312 bytes)
smbtorture results:
ntdb speed 86581-191518(175666) ops/sec
Applying patch..increase-top-level.patch

11 years agontdb: inline oob check
Rusty Russell [Fri, 15 Jun 2012 03:26:40 +0000 (12:56 +0930)]
ntdb: inline oob check

The simple "is it in range" check can be inline; complex cases can be
handed through to the normal or transaction handler.

NTDB speed:
Adding 10000 records: 4111-9983(9149) ns (815528 bytes)
Finding 10000 records: 1667-4464(3810) ns (815528 bytes)
Missing 10000 records: 1511-3992(3546) ns (815528 bytes)
Traversing 10000 records: 1698-4254(3724) ns (815528 bytes)
Deleting 10000 records: 3608-7998(7358) ns (815528 bytes)
Re-adding 10000 records: 3259-8504(7805) ns (815528 bytes)
Appending 10000 records: 5393-13579(12356) ns (1274312 bytes)
Churning 10000 records: 6966-17813(16136) ns (1274312 bytes)
NTDB speed in transaction:
Adding 10000 records: 916-2230(2004) ns (815528 bytes)
Finding 10000 records: 330-866(770) ns (815528 bytes)
Missing 10000 records: 196-520(471) ns (815528 bytes)
Traversing 10000 records: 356-879(800) ns (815528 bytes)
Deleting 10000 records: 505-1267(1108) ns (815528 bytes)
Re-adding 10000 records: 658-1681(1477) ns (815528 bytes)
Appending 10000 records: 1088-2827(2498) ns (1274312 bytes)
Churning 10000 records: 1636-4267(3785) ns (1274312 bytes)
smbtorture results:
ntdb speed 85588-189430(157110) ops/sec

11 years agontdb: allocator attribute.
Rusty Russell [Fri, 15 Jun 2012 03:25:40 +0000 (12:55 +0930)]
ntdb: allocator attribute.

This is designed to allow us to make ntdb_context (and NTDB_DATA returned
from ntdb_fetch) a talloc pointer.  But it can also be used for any other
alternate allocator.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
11 years agontdb: fix recovery data write.
Rusty Russell [Fri, 15 Jun 2012 03:15:22 +0000 (12:45 +0930)]
ntdb: fix recovery data write.

We were missing the last few bytes.  Found by 100 runs of ntdbtorture
-t -k.

The transaction test code didn't catch this, because usually those
last few bytes are irrelevant to the actual contents of the database.
We fix the test.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
11 years agontdb: make sure file is always a multiple of PAGESIZE (now NTDB_PGSIZE)
Rusty Russell [Fri, 15 Jun 2012 03:13:08 +0000 (12:43 +0930)]
ntdb: make sure file is always a multiple of PAGESIZE (now NTDB_PGSIZE)

ntdb uses tdb's transaction code, and it has an undocumented but implicit
assumption: that the transaction recovery area is always aligned to the
transaction pagesize.  This means that no block will overlap the recovery
area.

This is maintained by rounding the size of the database up, so do the same
for ntdb.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
11 years agontdb: fix corner case in direct access in transaction code.
Rusty Russell [Fri, 15 Jun 2012 02:35:13 +0000 (12:05 +0930)]
ntdb: fix corner case in direct access in transaction code.

We allow direct access to the ntdb in certain cases during a transaction:
if the access is within a transaction block, or still untouched on disk.

However, we weren't careful enough to check the final block, which is
a different length.  This can happen even after the next patch, which
maintains the database length as a multiple of PAGESIZE, because a
newly created database is not a multiple of pagesize (it becomes so as
soon as we add a record, however).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
11 years agontdb: enhance external-helper test code.
Rusty Russell [Fri, 15 Jun 2012 02:11:49 +0000 (11:41 +0930)]
ntdb: enhance external-helper test code.

Our external test helper is a bit primitive when it comes to doing STORE or
FETCH commands: let us specify the data we expect, instead of assuming it's
the same as the key.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
11 years agontdb: use NTDB_LOG_WARNING level for failed open() without O_CREAT.
Rusty Russell [Tue, 12 Jun 2012 07:21:42 +0000 (16:51 +0930)]
ntdb: use NTDB_LOG_WARNING level for failed open() without O_CREAT.

This is a fairly common pattern in Samba, and if we log an error on
every open it spams the logs.  On the other hand, other errors are
potentially more serious, so we still use NTDB_LOG_ERROR on them.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
11 years agoccan: remove bogus debug print.
Rusty Russell [Tue, 12 Jun 2012 07:19:45 +0000 (16:49 +0930)]
ccan: remove bogus debug print.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
11 years agontdb: make fork test more thorough.
Rusty Russell [Tue, 12 Jun 2012 07:19:38 +0000 (16:49 +0930)]
ntdb: make fork test more thorough.

We document that the child of a fork() can do a brunlock() if the parent
does a brlock: we should not log an error when they do this.

Also, test the case where we fork() and return inside a parse function
(which is allowed).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
11 years agontdb: print \n at end of log messages in tests.
Rusty Russell [Tue, 12 Jun 2012 04:38:47 +0000 (14:08 +0930)]
ntdb: print \n at end of log messages in tests.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
11 years agontdb: reduce race between creating file and getting open lock.
Rusty Russell [Tue, 12 Jun 2012 04:38:47 +0000 (14:08 +0930)]
ntdb: reduce race between creating file and getting open lock.

In tdb, we grab the open lock immediately after we open the file.  In
ntdb, we usually did some work first.  tdbtorture managed to get in
before the creator grabbed the lock:

testing with 3 processes, 5000 loops, seed=1338246020
ntdb:torture.ntdb:IO Error:ntdb_open: torture.ntdb is not a ntdb file
29023:torture.ntdb:db open failed

At cost of a little duplicated code, we can reduce the race.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
11 years agontdb: catch any valgrind errors in test
Rusty Russell [Tue, 12 Jun 2012 04:38:47 +0000 (14:08 +0930)]
ntdb: catch any valgrind errors in test

Make --valgrind and --valgrind-log options work!

Amitay figured this out!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
11 years agontdb: catch any valgrind errors in test
Rusty Russell [Tue, 12 Jun 2012 04:38:47 +0000 (14:08 +0930)]
ntdb: catch any valgrind errors in test

We need --error-exitcode=, otherwise valgrind errors don't cause the
test to fail.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
11 years agontdb: remove ntdb_error()
Rusty Russell [Tue, 12 Jun 2012 04:38:47 +0000 (14:08 +0930)]
ntdb: remove ntdb_error()

It was a hack to make compatibility easier.  Since we're not doing that,
it can go away: all callers must use the return value now.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
11 years agoTDB2: Goodbye TDB2, Hello NTDB.
Rusty Russell [Tue, 12 Jun 2012 04:38:23 +0000 (14:08 +0930)]
TDB2: Goodbye TDB2, Hello NTDB.

This renames everything from tdb2 to ntdb: importantly, we no longer
use the tdb_ namespace, so you can link against both ntdb and tdb if
you want to.

This also enables building of standalone ntdb by the autobuild script.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
11 years agotdb2: Fix typo in TDB1_porting.txt
Kirill Smelkov [Tue, 12 Jun 2012 04:36:45 +0000 (14:06 +0930)]
tdb2: Fix typo in TDB1_porting.txt

Judging by code it's tdb1, where you needed to free old key's dptr
manually.

Signed-off-by: Kirill Smelkov <kirr@mns.spb.ru>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
11 years agoTDB2: more internal cleanups after TDB1 compatibility removal.
Rusty Russell [Tue, 12 Jun 2012 04:36:44 +0000 (14:06 +0930)]
TDB2: more internal cleanups after TDB1 compatibility removal.

This eliminates the separate tdb2 substructure, and makes some
tdb1-required functions static.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
11 years agoTDB2: remove TDB1 compatibility.
Rusty Russell [Tue, 12 Jun 2012 04:36:41 +0000 (14:06 +0930)]
TDB2: remove TDB1 compatibility.

This rips out all the TDB1 compatibility from tdb2.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
11 years agoTDB2: make SAMBA use tdb1 again for the moment.
Rusty Russell [Tue, 12 Jun 2012 04:36:38 +0000 (14:06 +0930)]
TDB2: make SAMBA use tdb1 again for the moment.

Otherwise the following surgery will break the SAMBA build and testsuite.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
11 years agos3:smb2_ioctl: make use of file_fsp_smb2()
Stefan Metzmacher [Fri, 8 Jun 2012 10:12:59 +0000 (12:12 +0200)]
s3:smb2_ioctl: make use of file_fsp_smb2()

metze

Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Sun Jun 10 01:10:15 CEST 2012 on sn-devel-104

11 years agos3:smb2_lock: make use of file_fsp_smb2()
Stefan Metzmacher [Fri, 8 Jun 2012 09:57:21 +0000 (11:57 +0200)]
s3:smb2_lock: make use of file_fsp_smb2()

metze

11 years agos3:smb2_write: make use of file_fsp_smb2()
Stefan Metzmacher [Fri, 8 Jun 2012 09:47:05 +0000 (11:47 +0200)]
s3:smb2_write: make use of file_fsp_smb2()

metze

11 years agos3:smb2_read: make use of file_fsp_smb2()
Stefan Metzmacher [Fri, 8 Jun 2012 09:24:02 +0000 (11:24 +0200)]
s3:smb2_read: make use of file_fsp_smb2()

metze

11 years agos3:smb2_notify: make use of file_fsp_smb2()
Stefan Metzmacher [Fri, 8 Jun 2012 09:05:58 +0000 (11:05 +0200)]
s3:smb2_notify: make use of file_fsp_smb2()

metze

11 years agos3:smb2_setinfo: make use of file_fsp_smb2()
Stefan Metzmacher [Fri, 8 Jun 2012 08:54:46 +0000 (10:54 +0200)]
s3:smb2_setinfo: make use of file_fsp_smb2()

metze

11 years agos3:smb2_getinfo: make use of file_fsp_smb2()
Stefan Metzmacher [Fri, 8 Jun 2012 08:46:13 +0000 (10:46 +0200)]
s3:smb2_getinfo: make use of file_fsp_smb2()

metze

11 years agos3:smb2_find: make use of file_fsp_smb2()
Stefan Metzmacher [Fri, 8 Jun 2012 08:42:43 +0000 (10:42 +0200)]
s3:smb2_find: make use of file_fsp_smb2()

metze

11 years agos3:smb2_break: make use of file_fsp_smb2()
Stefan Metzmacher [Fri, 8 Jun 2012 08:36:24 +0000 (10:36 +0200)]
s3:smb2_break: make use of file_fsp_smb2()

metze

11 years agos3:smb2_close: make use of file_fsp_smb2()
Stefan Metzmacher [Fri, 8 Jun 2012 08:31:58 +0000 (10:31 +0200)]
s3:smb2_close: make use of file_fsp_smb2()

metze

11 years agos3:smb2_flush: make use of file_fsp_smb2()
Stefan Metzmacher [Fri, 8 Jun 2012 08:14:45 +0000 (10:14 +0200)]
s3:smb2_flush: make use of file_fsp_smb2()

metze

11 years agos3:smbd: add file_fsp_smb2()
Stefan Metzmacher [Fri, 8 Jun 2012 08:11:57 +0000 (10:11 +0200)]
s3:smbd: add file_fsp_smb2()

metze

11 years agos3:smb2_write: pass fsp->fnum to init_strict_lock_struct()
Stefan Metzmacher [Fri, 8 Jun 2012 09:19:00 +0000 (11:19 +0200)]
s3:smb2_write: pass fsp->fnum to init_strict_lock_struct()

fsp->fnum is the same as in_file_id_volatile.

When we start to support durable handles we should pass
in_file_id_persistent.

metze

Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Sat Jun  9 18:50:32 CEST 2012 on sn-devel-104

11 years agos3:smb2_read: pass fsp->fnum to init_strict_lock_struct()
Stefan Metzmacher [Fri, 8 Jun 2012 09:19:00 +0000 (11:19 +0200)]
s3:smb2_read: pass fsp->fnum to init_strict_lock_struct()

fsp->fnum is the same as in_file_id_volatile.

When we start to support durable handles we should pass
in_file_id_persistent.

metze

11 years agos3:smb2_lock: use fsp->fnum as locking context
Stefan Metzmacher [Fri, 8 Jun 2012 09:19:00 +0000 (11:19 +0200)]
s3:smb2_lock: use fsp->fnum as locking context

fsp->fnum is the same as in_file_id_volatile.

When we start to support durable handles we should pass
in_file_id_persistent.

metze

11 years agos3:smb2_lock: use smb2req->compat_chain_fsp instead of looking it up again
Stefan Metzmacher [Fri, 8 Jun 2012 10:05:56 +0000 (12:05 +0200)]
s3:smb2_lock: use smb2req->compat_chain_fsp instead of looking it up again

metze

11 years agos3:smbd: set req->smb2req->compat_chain_fsp in file_fsp()
Stefan Metzmacher [Sat, 9 Jun 2012 09:09:25 +0000 (11:09 +0200)]
s3:smbd: set req->smb2req->compat_chain_fsp in file_fsp()

metze

11 years agos3:smb2_close: add missing TALLOC_FREE(subreq) in smbd_smb2_request_close_done()
Stefan Metzmacher [Fri, 8 Jun 2012 08:29:44 +0000 (10:29 +0200)]
s3:smb2_close: add missing TALLOC_FREE(subreq) in smbd_smb2_request_close_done()

metze

Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Sat Jun  9 13:57:31 CEST 2012 on sn-devel-104

11 years agos3:smbd: readd START_PROFILE(smbd_idle)/END_PROFILE(smbd_idle)
Stefan Metzmacher [Fri, 8 Jun 2012 12:07:51 +0000 (14:07 +0200)]
s3:smbd: readd START_PROFILE(smbd_idle)/END_PROFILE(smbd_idle)

metze

11 years agotdb2: use ccan/err instead of err.h
Rusty Russell [Sat, 9 Jun 2012 06:48:57 +0000 (16:18 +0930)]
tdb2: use ccan/err instead of err.h

Solaris has no err.h, so use CCAN replacement.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Autobuild-User(master): Rusty Russell <rusty@rustcorp.com.au>
Autobuild-Date(master): Sat Jun  9 12:07:15 CEST 2012 on sn-devel-104

11 years agoccan: make failtest use ccan/err.
Rusty Russell [Sat, 9 Jun 2012 06:11:23 +0000 (15:41 +0930)]
ccan: make failtest use ccan/err.

As per CCAN commit 48b700953f9c856102e91596103238f5da9ea079.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
11 years agoccan: import err module.from ccan revision 5add556a1cb64b49a664506aa76216d885b22c97
Rusty Russell [Sat, 9 Jun 2012 06:07:20 +0000 (15:37 +0930)]
ccan: import err module.from ccan revision 5add556a1cb64b49a664506aa76216d885b22c97

This allows us to avoid err.h in failtest.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
11 years agos3:smbd: change set_file_oplock() to return NTSTATUS
Michael Adam [Fri, 8 Jun 2012 15:47:31 +0000 (17:47 +0200)]
s3:smbd: change set_file_oplock() to return NTSTATUS

Pair-Programmed-With: Volker Lendecke <vl@samba.org>
Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>

Autobuild-User(master): Michael Adam <obnox@samba.org>
Autobuild-Date(master): Fri Jun  8 23:20:20 CEST 2012 on sn-devel-104

11 years agos3: Replace an if with a boolean short circuit
Volker Lendecke [Fri, 8 Jun 2012 12:26:52 +0000 (14:26 +0200)]
s3: Replace an if with a boolean short circuit

Signed-off-by: Michael Adam <obnox@samba.org>
11 years agos3: Assigning ?True:False to a bool is a bit pointless
Volker Lendecke [Fri, 8 Jun 2012 12:29:41 +0000 (14:29 +0200)]
s3: Assigning ?True:False to a bool is a bit pointless

Signed-off-by: Michael Adam <obnox@samba.org>
11 years agos3: Remove unnecessary ()
Volker Lendecke [Fri, 8 Jun 2012 12:24:41 +0000 (14:24 +0200)]
s3: Remove unnecessary ()

Signed-off-by: Michael Adam <obnox@samba.org>
11 years agos3: Replace an if with a boolean short circuit
Volker Lendecke [Fri, 8 Jun 2012 12:26:52 +0000 (14:26 +0200)]
s3: Replace an if with a boolean short circuit

Signed-off-by: Michael Adam <obnox@samba.org>
11 years agos3: Assigning ?True:False to a bool is a bit pointless
Volker Lendecke [Fri, 8 Jun 2012 12:25:23 +0000 (14:25 +0200)]
s3: Assigning ?True:False to a bool is a bit pointless

Signed-off-by: Michael Adam <obnox@samba.org>
11 years agos3: Remove unnecessary ()
Volker Lendecke [Fri, 8 Jun 2012 12:24:41 +0000 (14:24 +0200)]
s3: Remove unnecessary ()

Signed-off-by: Michael Adam <obnox@samba.org>
11 years agotevent: change version to 0.9.16
Stefan Metzmacher [Fri, 8 Jun 2012 10:50:21 +0000 (12:50 +0200)]
tevent: change version to 0.9.16

This adds tevent_*_trace_*() and tevent_context_init_ops()

metze

Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Fri Jun  8 20:47:41 CEST 2012 on sn-devel-104

11 years agotevent: expose tevent_context_init_ops
Stefan Metzmacher [Fri, 11 May 2012 13:19:55 +0000 (15:19 +0200)]
tevent: expose tevent_context_init_ops

This can be used to implement wrapper backends,
while passing a private pointer to the backens init function
via ev->additional_data.

metze

11 years agolib/tevent: Add trace point callback
Martin Schwenke [Tue, 5 Jun 2012 06:00:07 +0000 (16:00 +1000)]
lib/tevent: Add trace point callback

Set/get a single callback function to be invoked at various trace
points.  Define "before wait" and "after wait" trace points - more
trace points can be added later if required.

CTDB wants this to log long waits and events.

Pair-programmed-with: Amitay Isaacs <amitay@gmail.com>
Signed-off-by: Martin Schwenke <martin@meltin.net>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
11 years agolib/tevent: In poll_event_context, add a pointer back to the tevent_context
Martin Schwenke [Thu, 7 Jun 2012 02:26:02 +0000 (12:26 +1000)]
lib/tevent: In poll_event_context, add a pointer back to the tevent_context

This makes it consistent with the other backends.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
11 years agos3:smbd: remove unnecessary variable readret from read_file()
Michael Adam [Fri, 8 Jun 2012 14:06:24 +0000 (16:06 +0200)]
s3:smbd: remove unnecessary variable readret from read_file()

Pair-Programmed-With: Volker Lendecke <vl@samba.org>

Autobuild-User(master): Michael Adam <obnox@samba.org>
Autobuild-Date(master): Fri Jun  8 18:08:09 CEST 2012 on sn-devel-104

11 years agos3:smbd: remove ancient DMF_FIX from read_file().
Michael Adam [Fri, 8 Jun 2012 12:23:09 +0000 (14:23 +0200)]
s3:smbd: remove ancient DMF_FIX from read_file().

Pair-Programmed-With: Volker Lendecke <vl@samba.org>

11 years agobuild: do not run fsrvp tests as part of selftest
David Disseldorp [Tue, 5 Jun 2012 18:02:04 +0000 (20:02 +0200)]
build: do not run fsrvp tests as part of selftest

Autobuild-User(master): David Disseldorp <ddiss@samba.org>
Autobuild-Date(master): Fri Jun  8 15:24:45 CEST 2012 on sn-devel-104

11 years agos4-torture: fsrvp test suite
David Disseldorp [Fri, 9 Mar 2012 15:02:19 +0000 (16:02 +0100)]
s4-torture: fsrvp test suite

Covers most operations defined by the File Server Remote VSS Protocol.

11 years agodoc: add FSRVP commands to rpcclient man page
David Disseldorp [Tue, 3 Apr 2012 12:17:35 +0000 (14:17 +0200)]
doc: add FSRVP commands to rpcclient man page

11 years agos3-rpcclient: add fsrvp commands
David Disseldorp [Mon, 26 Mar 2012 15:34:52 +0000 (17:34 +0200)]
s3-rpcclient: add fsrvp commands

fss_create_expose connects to an FSRVP server and negotiates the
creation and exposure of a share shadow-copy.
shadow-copies of multiple shares can be requested with a single
fss_create_expose request.

ddiss@plati:~> bin/rpcclient -k -U 'LURCH\administrator%password' \
                             ncacn_np:lutze[sign]
rpcclient $> fss_create_expose backup ro hyper
381884f2-b578-45ea-b8d2-cf82491f4011: shadow-copy set created
...
share hyper@{B6137E21-9CBB-4547-A21D-E7AD40D0874B} exposed as a snapshot
of \\lutze\hyper

fss_delete removes the shadow-copy share:
rpcclient $> fss_delete hyper 381884f2-b578-45ea-b8d2-cf82491f4011 \
                        b6137e21-9cbb-4547-a21d-e7ad40d0874

Shadow-copies can be created read-write or read-only.
Experimenting with Windows Server "8" beta, a recovery complete call is
required after creating a read-write (ATTR_AUTO_RECOVERY) shadow copy.
Otherwise subsequent creation requests fail with
FSRVP_E_SHADOW_COPY_SET_IN_PROGRESS.

11 years agoidl: add File Server Remote VSS Protocol idl
David Disseldorp [Tue, 21 Feb 2012 13:04:42 +0000 (14:04 +0100)]
idl: add File Server Remote VSS Protocol idl

MS-FSRVP preview documents used as reference.
H_ERROR codes should be moved to a more generic file.

11 years agosamba_util: mark smb_panic as _NORETURN_.
Rusty Russell [Thu, 7 Jun 2012 22:38:00 +0000 (08:08 +0930)]
samba_util: mark smb_panic as _NORETURN_.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Autobuild-User(master): Rusty Russell <rusty@rustcorp.com.au>
Autobuild-Date(master): Fri Jun  8 09:14:26 CEST 2012 on sn-devel-104