summaryrefslogtreecommitdiff
path: root/lib/dbwrap/dbwrap.c
AgeCommit message (Collapse)AuthorFilesLines
2026-02-15lib: Avoid DEBUGADDs in debug_lock_order()Volker Lendecke1-12/+19
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Anoop C S <anoopcs@samba.org>
2023-08-08lib:dbwrap: Remove unneeded space in debug messageJoseph Sutton1-1/+1
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-06-13lib:dbwrap: Add dbwrap_merge_dbs()Pavel Filipenský1-0/+29
Signed-off-by: Pavel Filipenský <pfilipensky@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
2022-09-20lib/dbwrap: allow dbwrap_merge_dbufs() to update an existing bufferStefan Metzmacher1-8/+14
This will be useful in future... BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2021-11-04lib/dbwrap: reset deleted record to tdb_nullRalph Boehme1-6/+3
This allows the calling the following sequence of dbwrap functions: dbwrap_delete_record(rec); data = dbwrap_record_get_value(rec); without triggering the assert rec->value_valid inside dbwrap_record_get_value(). Note that dbwrap_record_storev() continues to invalidate the record, so this change somewhat blurs our semantics. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14882 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Thu Nov 4 19:49:47 UTC 2021 on sn-devel-184
2021-06-04dbwrap: Remove unused dbwrap_try_fetch_locked()Volker Lendecke1-10/+0
Small simplification, this has not been used since 2014 when the notifyd went in. Can easily be added if needed again. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2020-05-15dbwrap: Make dbwrap_lock_order_[un]lock() publicVolker Lendecke1-4/+4
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2020-05-15dbwrap: Simplify dbwrap_lock_order_[un]lock()Volker Lendecke1-34/+49
Directly pass the database name and lock order to the core functions, avoid passing struct db_context. In the next steps these functions will become public: locking.tdb will be based on g_lock.c to avoid holding a tdb-level locking.tdb mutex while doing complex file system operations like unlink() which can take ages on FAT for example. This means that g_lock.c will participate in the dbwrap lock order protection and needs access to dbwrap_lock_order_[un]lock() without providing a direct db_context. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2019-11-22dbwrap: Don't set rec->value in dbwrap_do_locked()Volker Lendecke1-0/+6
We pass that via the callback now Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2019-11-22dbwrap: Protect against invalid db_record->valueVolker Lendecke1-0/+13
After dbwrap_record_storev()/delete(), dbwrap_record_get_value() information is stale. Assert on the attempt to re-fetch data after it became stale. This can't protect against someone copying the result from dbwrap_record_get_value() somewhere else, but it's better than nothing. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2019-11-22dbwrap: Pass "value" to dbwrap_do_locked() callbackVolker Lendecke1-3/+10
I want to reduce dbwrap_record_get_value(). It makes the caller believe it can make a copy of the TDB_DATA returned and that the value remains constant. It's not, as you can always do a dbwrap_record_store(). This patch removes one requirement for getting the value out of a db_record via dbwrap_record_get_value(). You can still make a copy, but from an API perspective to me it's more obvious that "value" as a parameter to the callback has a limited lifetime. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2019-09-10dbwrap: Initialize state in dbwrap_delete()Volker Lendecke1-1/+1
Probably not required, but looks safer and gives static checkers less reason to complain about potentially uninitialized variable reads Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2019-06-26lib/dwrap: Fix 'Null pointer passed as an argument to a 'nonnull' parameter 'Noel Power1-1/+1
Fixes: lib/dbwrap/dbwrap.c:645:4: warning: Null pointer passed as an argument to a 'nonnull' parameter <--[clang] memcpy(p, dbufs[i].dptr, thislen); Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
2019-06-26lib/dbwrap: clang: Fix 'all argument is an uninitialized value'Noel Power1-2/+3
Fixes: lib/dbwrap/dbwrap.c:533:4: warning: 2nd function call argument is an uninitialized value <--[clang] dbwrap_lock_order_unlock(db, lockptr); ^ Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
2019-05-08dbwrap: Adapt tdb_data_buf's overflow handling to modern conventionsVolker Lendecke1-4/+2
This is the way we do it right now, avoid confusion why "tmp" might be needed Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2019-05-08dbwrap: Fix tdb_data_buf()Volker Lendecke1-1/+1
IIRC there are platforms that don't like memcpy() with len=0. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2018-09-07dbwrap: Remove a pointless "return;"Volker Lendecke1-1/+0
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
2018-08-17dbwrap: Fix a typoVolker Lendecke1-1/+1
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Reviewed-by: Rowland Penny <rpenny@samba.org>
2017-08-16dbwrap: Convert dbwrap_delete to dbwrap_do_lockedVolker Lendecke1-9/+16
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2017-08-16dbwrap: Convert dbwrap_store to dbwrap_do_lockedVolker Lendecke1-9/+17
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2017-07-25dbwrap: Add dbwrap_do_lockedVolker Lendecke1-0/+36
With a proper implementation this enables modifications without having to allocate a record. In really performance sensitive code paths this matters. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
2017-07-25dbwrap: Factor out the core dbwrap lock order logicVolker Lendecke1-46/+58
This will allow dbwrap_do_locked to check the order without talloc Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
2017-07-25dbwrap: Add dbwrap_record_storevVolker Lendecke1-2/+8
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
2017-07-25dbwrap: Convert backend store to storevVolker Lendecke1-1/+1
Convert all implementors of dbwrap_store to a storev-style call by using the dbwrap_merge_dbufs call For dbwrap_tdb, this matches tdb_storev. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
2017-07-25dbwrap: Add dbwrap_merge_dbufsVolker Lendecke1-0/+48
Transitional code to implement dbwrap_record_storev Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
2017-04-18dbwrap: add dbwrap_parse_record_send/recvRalph Boehme1-0/+112
The req_state parameter tells the caller whether the async request is blocked in a full send queue: req_state >= DBWRAP_REQ_DISPATCHED := request is dispatched req_state < DBWRAP_REQ_DISPATCHED := send queue is full This is useful in a clustered Samba environment where the async dbwrap request is sent over a socket to the local ctdbd. If the send queue is full and the caller was issuing multiple async dbwrap requests in a loop, the caller knows it's probably time to stop sending requests for now and try again later. This will be used in subsequent commits in smbd_smb2_query_directory_send() when implementing async write time updates. Directories may contain umpteen files so we send many requests to ctdb without going through tevent and reading the responses which has the potential to deadlock. Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2016-07-15dbwrap: Remove dbwrap_watchers.tdb based codeVolker Lendecke1-22/+0
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2016-03-06lib: Avoid "includes.h" in dbwrap.cVolker Lendecke1-1/+4
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ira Cooper <ira@samba.org>
2015-09-22dbwrap: Make dbwrap_db_id return size_tVolker Lendecke1-2/+2
This will make an on-stack db-id easier Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
2015-09-22dbwrap: Remove unused dbwrap_hash_size()Volker Lendecke1-5/+0
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
2014-02-07dbwrap: completely check validity of lock order in dbwrap_check_lock_order()Michael Adam1-1/+1
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>
2014-02-07dbwrap: introduce DBWRAP_LOCK_ORDER_NONE for lock order "0".Michael Adam1-1/+1
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>
2013-12-14dbwrap: No lock_order check if not requiredVolker Lendecke1-13/+6
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2013-12-14dbwrap: Avoid a stackframe in fetch_locked_internalVolker Lendecke1-5/+2
This shows in profiles. We call this so often that this is a pretty hot code path. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2013-06-06Revert "dbwrap: dbwrap_fetch_locked_timeout()."Volker Lendecke1-27/+0
This reverts commit f6eb187fdab6b8088bb065e418fe604c4eba7751. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Rusty Russell <rusty@rustcorp.com.au> Autobuild-User(master): Volker Lendecke <vl@samba.org> Autobuild-Date(master): Thu Jun 6 14:26:26 CEST 2013 on sn-devel-104
2013-03-27dbwrap: Add a comment explaining a restrictionVolker Lendecke1-0/+11
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Autobuild-User(master): Stefan Metzmacher <metze@samba.org> Autobuild-Date(master): Wed Mar 27 13:40:15 CET 2013 on sn-devel-104
2013-02-08dbwrap: Prevent transactions on non-persistent dbsVolker Lendecke1-0/+5
dbwrap_ctdb does not allow this anyway. This patch will avoid suprises when going non-clustered to clustered. Not everybody is developing against a clustered environment :-) Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2013-01-15dbwrap: add dbwrap_is_persistent()Michael Adam1-0/+5
Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
2012-08-03lib/dbwrap: rewrite lock order check to ease debuggingGregor Beck1-30/+55
Signed-off-by: Stefan Metzmacher <metze@samba.org> Autobuild-User(master): Stefan Metzmacher <metze@samba.org> Autobuild-Date(master): Fri Aug 3 12:52:38 CEST 2012 on sn-devel-104
2012-06-22dbwrap: dbwrap_hash_size().Rusty Russell1-0/+5
Implemented for ntdb and tdb; falls back to 0 for others. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2012-06-22dbwrap: dbwrap_name().Rusty Russell1-0/+5
Useful for debug messages: particularly once we start switching between .tdb and .ntdb files. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2012-06-22dbwrap: dbwrap_transaction_start_nonblock().Rusty Russell1-0/+10
Implemented for ntdb and tdb; falls back to the blocking variant for others. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2012-06-22dbwrap: dbwrap_fetch_locked_timeout().Rusty Russell1-0/+27
Implemented for ntdb and tdb; falls back to the non-timeout variant for others. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2012-06-22dbwrap: add dbwrap_check() function.Rusty Russell1-0/+21
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2012-06-22dbwrap: remove get_flags().Rusty Russell1-5/+0
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>
2012-05-14move the dbwrap library to the top levelMichael Adam1-0/+398
Autobuild-User: Michael Adam <obnox@samba.org> Autobuild-Date: Mon May 14 04:04:55 CEST 2012 on sn-devel-104