dbwrap: add flags DBWRAP_FLAG_NONE

This is in preparation of adding a dbwrap_flags argument to db_open
and firends.

Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
dbwrap: add a dbwrap_flags argument to db_open()

This is in preparation to support handing flags to backends,
in particular activating read only record support for ctdb
databases. For a start, this does nothing but adding the
parameter, and all databases use DBWRAP_FLAG_NONE.

Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
dbwrap: add a dbwrap_flags argument to db_open_ctdb()

This is in preparation of directly supporting ctdb read only
record copies when opening a ctdb database from samba.

Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
dbwrap: add DBWRAP_FLAG_OPTIMIZE_READONLY_ACCESS

Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
dbwrap_ctdb: implement DBWRAP_FLAG_OPTIMIZE_READONLY_ACCESS

For non-persistent databases we try to use CTDB_CONTROL_SET_DB_READONLY
in order to make use of readonly records.

Pair-Programmed-With: Michael Adam <obnox@samba.org>

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Michael Adam <obnox@samba.org>
dbwrap_open: add 'dbwrap_optimize_readonly:* = yes' option

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
s3:rpc_client: optimize the netlogon_creds_cli.tdb for read-only access

Usually a record in this DB will be written once and then read
many times by winbindd processes on multiple nodes (when run in
a cluster). In order not to introduce a big performance penalty
with the increased correctness achieved by storing the netlogon
creds, in a cluster setup, we should activate ctdb's read only
record copies on this db.

Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
s3:registry: introduce REG_DBWRAP_FLAGS to use for all db_open calls

This is in accordance with the use of REG_TDB_FLAGS.

Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
dbwrap: add a dbwrap_flags argument to db_open_tdb()

...for consistency and in preparation of future flags
that the tdb backend might be aware of.

Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
dbwrap: add a dbwrap_flags argument to db_open_ntdb()

for consistency and to perpare for possible future
flags that the ntdb backend might be aware of.

Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
dbwrap: add dbwrap_flags argument to dbwrap_local_open()

To be consistent with db_open() and prepare for future
possible extensions.

Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
dbwrap: introduce DBWRAP_LOCK_ORDER_NONE for lock order "0".

Ther are still some databases which are opened (locally) with
lock oder 0, which means don't do lock oder checking,
thereby circumventing this deadlock-prevention mechanism.

Add a symbolic constant for this "0" to make this circumvention
more explicit.

Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
libcli: use DBWRAP_LOCK_ORDER_NONE when opening schannel_store.tdb

Make lack of lock order checking more visible.

Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
s4:cluster: use DBWRAP_LOCK_ODER_NONE for local_db_tmp_open()

Make lack of lock oder checking more visible.

Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
dbwrap: explicitly use DBWRAP_LOCK_ORDER_NONE in tdb->ntdb conversion

Make lack of lock order checking more visible.

Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
dbwrap: move definition of DBWRAP_LOCK_ORDER_MAX to the private header.

This is only needed internally.

Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
dbwrap: add DBWRAP_LOCK_ORDER_MIN

Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
dbwrap: add DBWRAP_LOCK_ORDER_VALID()

Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
dbwrap: add a comment explaining the supported lock orders

Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
dbwrap: completely check validity of lock order in dbwrap_check_lock_order()

This is currently not strictly necessay, because the
only caller catches the DBWRAP_LOCK_ORDER_NONE case,
and maximum is already checked,  but this seems too dangerous to me.

Use the new DBWRAP_LOCK_ORDER_VALID() macro.

Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>