summaryrefslogtreecommitdiff
path: root/source3/lib/dbwrap
AgeCommit message (Collapse)AuthorFilesLines
2026-03-10s3: Warn if no mutexes available at runtimeVolker Lendecke1-2/+7
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Anoop C S <anoopcs@redhat.com> Reviewed-by: Shweta Sodani <ssodani@redhat.com> Reviewed-by: Xavi Hernandez <xhernandez@redhat.com> Reviewed-by: Guenther Deschner <gd@samba.org>
2025-08-05s3/dbwrap_watch: avoid leaking backend db handle in traversesRalph Boehme1-2/+4
Currently in a traverse callback dbwrap_record_get_db() returns the backend db handle. Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2025-04-02dbwrap: check for option "tdb_hash_size:DBNAME.tdb" in db_open()Ralph Boehme1-0/+5
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15767 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2024-03-22lib: Remove timeval_set()Volker Lendecke1-2/+6
We have the same function in tevent, no need to duplicate code. More lines just due to clang-format. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Fri Mar 22 06:07:42 UTC 2024 on atb-devel-224
2022-09-20s3:g_lock: add callback function to g_lock_lock()Stefan Metzmacher1-1/+1
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>
2022-09-20lib/dbwrap: allow dbwrap_merge_dbufs() to update an existing bufferStefan Metzmacher1-4/+4
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>
2022-09-20s3:dbwrap_watch: add dbwrap_watched_watch_force_alerting()Stefan Metzmacher2-0/+8
This is useful when we want to wakeup the next watcher without modifying the record. 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>
2022-09-20s3:dbwrap_watch: add dbwrap_watched_watch_reset_alerting() helperStefan Metzmacher2-0/+9
This can be used if the decision of using dbwrap_watched_watch_skip_alerting() needs to be reverted... 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>
2022-09-20s3:dbwrap_watch: let dbwrap_watched_watch_skip_alerting() also clear the ↵Stefan Metzmacher1-0/+1
selected watcher If a watcher was already selected for a wakeup notification reset it... 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>
2022-07-26s3:dbwrap_watch: call dbwrap_watched_trigger_wakeup() outside of the low ↵Stefan Metzmacher1-10/+11
level record lock This gives a nice speed up, as it's unlikely for the waiters to hit contention. The following test with 256 commections all looping with open/close on the same inode (share root) is improved drastically: smbtorture //127.0.0.1/m -Uroot%test smb2.create.bench-path-contention-shared \ --option='torture:bench_path=' \ --option="torture:timelimit=60" \ --option="torture:nprocs=256" From some like this: open[num/s=8800,avslat=0.021445,minlat=0.000095,maxlat=0.179786] close[num/s=8800,avslat=0.021658,minlat=0.000044,maxlat=0.179819] to: open[num/s=10223,avslat=0.017922,minlat=0.000083,maxlat=0.106759] close[num/s=10223,avslat=0.017694,minlat=0.000040,maxlat=0.107345] 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> Reviewed-by: Ralph Boehme <slow@samba.org> Autobuild-User(master): Ralph Böhme <slow@samba.org> Autobuild-Date(master): Tue Jul 26 14:32:35 UTC 2022 on sn-devel-184
2022-07-26s3:dbwrap_watch: only notify the first waiterStefan Metzmacher1-33/+72
In case of a highly contended record we will have a lot of watchers, which will all race to get g_lock_lock() to finish. If g_lock_unlock() wakes them all, e.g. 250 of them, we get a thundering herd, were 249 will only find that one of them as able to get the lock and re-add their watcher entry (not unlikely in a different order). With this commit we only wake the first watcher and let it remove itself once it no longer wants to monitor the record content (at that time it will wake the new first watcher). It means the woken watcher doesn't have to race with all others and also means order of watchers is kept, which means that we most likely get a fair latency distribution for all watchers. The following test with 256 commections all looping with open/close on the same inode (share root) is improved drastically: smbtorture //127.0.0.1/m -Uroot%test smb2.create.bench-path-contention-shared \ --option='torture:bench_path=' \ --option="torture:timelimit=60" \ --option="torture:nprocs=256" From some like this: open[num/s=80,avslat=2.793862,minlat=0.004097,maxlat=46.597053] close[num/s=80,avslat=2.387326,minlat=0.023875,maxlat=50.878165] to: open[num/s=8800,avslat=0.021445,minlat=0.000095,maxlat=0.179786] close[num/s=8800,avslat=0.021658,minlat=0.000044,maxlat=0.179819] 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> Reviewed-by: Ralph Boehme <slow@samba.org>
2022-07-26s3:dbwrap_watch: allow callers of dbwrap_watched_watch_send/recv() to manage ↵Stefan Metzmacher2-5/+32
the watcher instances The destructor triggered by dbwrap_watched_watch_recv() will remove the watcher instance via a dedicated dbwrap_do_locked(), just calling dbwrap_watched_watch_remove_instance() inside. But the typical caller triggers a dbwrap_do_locked() again after dbwrap_watched_watch_recv() returned. Which means we call dbwrap_do_locked() twice. We now allow dbwrap_watched_watch_recv() to return the existing instance id (if it still exists) and removes the destructor. That way the caller can pass the given instance id to dbwrap_watched_watch_remove_instance() from within its own dbwrap_do_locked(), when it decides to leave the queue, because it's happy with the new state of the record. In order to get the best performance dbwrap_watched_watch_remove_instance() should be called before any dbwrap_record_storev() or dbwrap_record_delete(), because that will only trigger a single low level storev/delete. If the caller found out that the state of the record doesn't meet the expectations and the callers wants to continue watching the record (from its current position, most likely the first one), dbwrap_watched_watch_remove_instance() can be skipped and the instance id can be passed to dbwrap_watched_watch_send() again, in order to resume waiting on the existing instance. Currently the watcher instance were always removed (most likely from the first position) and re-added (to the last position), which may cause unfair latencies. In order to improve the overhead of adding a new watcher instance the caller can call dbwrap_watched_watch_add_instance() before any dbwrap_record_storev() or dbwrap_record_delete(), which will only result in a single low level storev/delete. The returned instance id is then passed to dbwrap_watched_watch_send(), within the same dbwrap_do_locked() run. It also adds a way to avoid alerting any callers during the current dbwrap_do_locked() run. Layers above may only want to wake up watchers during specific situations and while it's useless to wake others in other situations. This will soon be used to add more fairness to the g_lock code. Note that this commit only prepares the api for the above to be useful, the instance returned by dbwrap_watched_watch_recv() is most likely 0, which means the watcher entry was already removed, but that will change in the following commits. 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> Reviewed-by: Ralph Boehme <slow@samba.org>
2022-07-26s3:dbwrap_watch: remove a watcher via db_watched_record_fini()Stefan Metzmacher1-85/+89
The new dbwrap_watched_watch_remove_instance() will just remove ourself from the in memory array and let db_watched_record_fini() call dbwrap_watched_record_storev() in order to write the modified version into the low level backend record. For now there's no change in behavior, but it allows us to change it soon.... 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> Reviewed-by: Ralph Boehme <slow@samba.org>
2022-07-26s3:dbwrap_watch: use dbwrap_watched_record_storev() to add a new watcherStefan Metzmacher1-52/+109
It means we only have one code path storing the low level record and that's dbwrap_watched_record_storev on the main record. It avoids the nested dbwrap_do_locked() and only uses dbwrap_parse_record() and talloc_memdup() when needed. 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> Reviewed-by: Ralph Boehme <slow@samba.org>
2022-07-26s3:dbwrap_watch: let dbwrap_watched_delete() call ↵Stefan Metzmacher1-14/+6
dbwrap_watched_record_storev(num_dbufs=0) dbwrap_watched_record_storev() will handle the high level storev and delete, it will find out if we can remove the record as there's no value and also no watchers to be stored. This is no real change for now as dbwrap_watched_record_wakeup() will always exits with wrec->watchers.count = 0, but that will change in the next commits. 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> Reviewed-by: Ralph Boehme <slow@samba.org>
2022-07-26s3:dbwrap_watch: filter out records with empty payload during traverseStefan Metzmacher1-0/+3
We will soon have records with just a number of watchers, but without payload. These records should not be visible during traverse. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
2022-07-26s3:dbwrap_watch: prepare dbwrap_watched_record_storev() to store watchers if ↵Stefan Metzmacher1-7/+40
requested It will also delete the low level record in case there are no watchers should be stored and no data buffers are given. This is no real change for now as dbwrap_watched_record_wakeup() will always exit with wrec->watchers.count = 0, but that will change in the next commits. 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> Reviewed-by: Ralph Boehme <slow@samba.org>
2022-07-26s3:dbwrap_watch: define/use DBWRAP_MAX_WATCHERSStefan Metzmacher1-1/+2
dbwrap backends are unlikely to be able to store UINT32_MAX*DBWRAP_WATCHER_BUF_LENGTH in a single record and most likely also not with the whole database! DBWRAP_MAX_WATCHERS = INT32_MAX/DBWRAP_WATCHER_BUF_LENGTH should be enough and makes further changes easier as we don't need to care about size_t overflows. 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> Reviewed-by: Ralph Boehme <slow@samba.org>
2022-07-26s3:dbwrap_watch: remove unused dbwrap_watched_do_locked_state.statusStefan Metzmacher1-4/+2
This is never set... 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> Reviewed-by: Ralph Boehme <slow@samba.org>
2022-07-26s3:dbwrap_watch: let dbwrap_watched_watch_recv() use tevent_req_received()Stefan Metzmacher1-0/+2
At the end of the dbwrap_watched_watch_recv() all temporary state should be destroyed. It also means dbwrap_watched_watch_state_destructor() was triggered. 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> Reviewed-by: Ralph Boehme <slow@samba.org>
2022-07-26s3:dbwrap_watch: don't use talloc_tos() for messaging_filtered_read_recv()Stefan Metzmacher1-1/+1
Async function always have their 'state' context for temporary memory. 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> Reviewed-by: Ralph Boehme <slow@samba.org>
2022-07-26s3:dbwrap_watch: move db_record and db_watched_record to ↵Stefan Metzmacher1-5/+8
dbwrap_watched_do_locked() This will help in the next commits. 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> Reviewed-by: Ralph Boehme <slow@samba.org>
2022-07-26s3:dbwrap_watch: split out a dbwrap_watched_watch_add_instance() helperStefan Metzmacher1-5/+23
This will be used in other places soon. 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> Reviewed-by: Ralph Boehme <slow@samba.org>
2022-07-26s3:dbwrap_watch: remove dbwrap_watched_record_wakeup_fn() indirectionStefan Metzmacher1-64/+52
This reduces quite some complexity and will make further changes (which will follow soon) easier. Review with git show --patience 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> Reviewed-by: Ralph Boehme <slow@samba.org>
2022-07-26s3:dbwrap_watch: also the fetch_locked case only needs to wake waiters just onceStefan Metzmacher1-26/+8
This is no change in behavior, because: - The first dbwrap_do_locked(dbwrap_watched_record_wakeup_fn), is called at the start of dbwrap_watched_record_{storev,delete}(). That means the nested dbwrap_do_locked() will pass the exact value same (unchanged) value to dbwrap_watched_record_wakeup_fn. - After the first change we have either removed the whole backend record in dbwrap_watched_record_delete or dbwrap_watched_record_storev() removed all watchers and store num_watchers = 0. - With that any further updates will have no watchers in the backend record, so dbwrap_do_locked(dbwrap_watched_record_wakeup_fn) will never do anything useful. It only burns cpu time any may cause memory fragmentation. 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> Reviewed-by: Ralph Boehme <slow@samba.org>
2022-07-26s3:dbwrap_watch: split out db_watched_record_fini() from ↵Stefan Metzmacher1-5/+12
db_watched_record_destructor() That makes it easier to understand that db_watched_record_init() and db_watched_record_fini() wrap any caller activity on the record, either during do_locked or between fetch_locked and the related destructor. 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> Reviewed-by: Ralph Boehme <slow@samba.org>
2022-07-26s3:dbwrap_watch: split out a db_watched_record_init() helper functionStefan Metzmacher1-51/+57
The code to construct a struct db_watched_record is mostly common between dbwrap_watched_fetch_locked() and dbwrap_watched_do_locked_fn(). 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> Reviewed-by: Ralph Boehme <slow@samba.org>
2022-07-26s3:dbwrap_watch: remove unused dbwrap_watched_do_locked_{storev,delete}()Stefan Metzmacher1-20/+5
dbwrap_watched_do_locked_{storev,delete}() was now exactly the same as dbwrap_watched_{storev,delete}(). We only need to know if dbwrap_watched_record_wakeup() is called from within dbwrap_watched_do_locked_fn(). 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> Reviewed-by: Ralph Boehme <slow@samba.org>
2022-07-26s3:dbwrap_watch: move the do_locked optimization to ↵Stefan Metzmacher1-29/+4
dbwrap_watched_record_wakeup() Both dbwrap_watched_record_storev() and dbwrap_watched_record_delete() call dbwrap_watched_record_wakeup() as their first action. So the behavior stays the same, but dbwrap_watched_do_locked_storev() and dbwrap_watched_do_locked_delete() are not trivial and we have the wakeup logic isolated in dbwrap_watched_record_wakeup() only. 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> Reviewed-by: Ralph Boehme <slow@samba.org>
2022-07-26s3:dbwrap_watch: add db_record_get_watched_record() helperStefan Metzmacher1-28/+22
This allows safe casting off rec->private_data to get struct db_watched_record. And that works fetch_locked and do_locked 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> Reviewed-by: Ralph Boehme <slow@samba.org>
2022-07-26s3:dbwrap_watch: use backend.{rec,initial_value} instead of subrec[_value]Stefan Metzmacher1-22/+29
This makes it much clearer to me what it actually is. Keeping the initial_value with struct db_watched_record will also simplify further changes. 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> Reviewed-by: Ralph Boehme <slow@samba.org>
2022-07-26s3:dbwrap_watch: only pass struct db_watched_record to ↵Stefan Metzmacher1-26/+17
dbwrap_watched_record_*() functions We get to the main 'struct db_record' via wrec->rec where needed. 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> Reviewed-by: Ralph Boehme <slow@samba.org>
2022-07-26s3:dbwrap_watch: use dbwrap_record_get_key() to access the keyStefan Metzmacher1-2/+4
We should avoid doing shortcuts if not needed. 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> Reviewed-by: Ralph Boehme <slow@samba.org>
2022-07-26s3:dbwrap_watch: move 'wrec' from dbwrap_watched_do_locked_state to ↵Stefan Metzmacher1-6/+4
dbwrap_watched_do_locked_fn We can use a local variable in dbwrap_watched_do_locked_fn. As 'wrec' should have the same lifetime as 'rec'. 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> Reviewed-by: Ralph Boehme <slow@samba.org>
2022-07-26s3:dbwrap_watch: use struct db_watched_record as rec->private_data for ↵Stefan Metzmacher1-8/+8
do_locked too There's no real reason to pass struct dbwrap_watched_do_locked_state anymore. The only difference is that we can't use talloc_get_type_abort(). 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> Reviewed-by: Ralph Boehme <slow@samba.org>
2022-07-26s3:dbwrap_watch: use dbwrap_record_get_db(rec) instead of state->dbStefan Metzmacher1-2/+4
We should try to avoid using dbwrap_watched_do_locked_state in low level code. 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> Reviewed-by: Ralph Boehme <slow@samba.org>
2022-07-26s3:dbwrap_watch: move wakeup_value to struct db_watched_recordStefan Metzmacher1-22/+22
For the do_locked case they have the same scope, but having it on db_watched_record will simplify further changes. 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> Reviewed-by: Ralph Boehme <slow@samba.org>
2022-07-26s3:dbwrap_watch: rename struct dbwrap_watched_record variables to 'wrec'Stefan Metzmacher1-45/+45
This makes it much easier to understand... 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> Reviewed-by: Ralph Boehme <slow@samba.org>
2022-07-26s3:dbwrap_watch: s/dbwrap_watched_subrec/dbwrap_watched_recordStefan Metzmacher1-25/+25
These functions operate on struct db_watched_record. 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> Reviewed-by: Ralph Boehme <slow@samba.org>
2022-07-26s3:dbwrap_watch: s/db_watched_subrec/db_watched_recordStefan Metzmacher1-24/+24
struct db_watched_record is the private data of the struct db_record produced by the struct db_context that uses struct db_watched_ctx. db_watched_subrec had nothing really todo with the sub record we got back from db_watched_ctx->backend. 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> Reviewed-by: Ralph Boehme <slow@samba.org>
2022-07-26s3:dbwrap_watch: use value_valid = false during dbwrap_watched_do_locked_fn()Stefan Metzmacher1-5/+6
This matches db_tdb_do_locked() and the fetch_locked based fallback in dbwrap_do_locked(). Calling dbwrap_record_get_value() is not allowed from within dbwrap_do_locked()! Now that rec.value is only internal, use it to remember the initial payload value. This will simplify further code changes as it makes the fetch_locked case. 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> Reviewed-by: Ralph Boehme <slow@samba.org>
2022-07-26s3:dbwrap_watch: let dbwrap_watched_watch_state_destructor() use DBG_WARNING()Stefan Metzmacher1-2/+2
When we (need) to ignore an error from dbwrap_do_locked() within dbwrap_watched_watch_state_destructor(), we better print this with log level 1 instead of 10. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
2022-07-01s3:dbwrap_ctdb: improve the error handling in ctdb_async_ctx_init_internal()Stefan Metzmacher1-3/+9
We should not map any error from ctdbd_init_async_connection() to EIO. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Fri Jul 1 18:34:17 UTC 2022 on sn-devel-184
2021-11-11dbwrap: Remove unused dbwrap_watched_wakeup()Volker Lendecke2-62/+0
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2021-08-17s3/lib/dbwrap: check if global_messaging_context() succeededRalph Boehme1-0/+4
The subsequent messaging_ctdb_connection() will fail an assert if messaging is not up and running, maybe it's a bit better to add a check if global_messaging_context() actually succeeded. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14787 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
2021-06-04dbwrap_ctdb: Remove "tryonly" from fetch_locked_internal()Volker Lendecke1-12/+3
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2021-06-04dbwrap: Remove "db_context->try_fetch_locked()" fn pointerVolker Lendecke1-19/+0
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2021-01-08lib: give global_contexts.c its own header fileVolker Lendecke1-1/+1
It's a bit shocking how many references we have to global contexts. Make this a bit more obvious. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2020-07-08s3:dbwrap_watch: avoid recursion into dbwrap_do_locked() from ↵Stefan Metzmacher1-4/+56
dbwrap_watched_do_locked_{storev,delete}() This avoids a lot of overhead! Using smbtorture3 //foo/bar -U% local-g-lock-ping-pong -o 500000 under valgrind --tool=callgrind... This change replaces this: 6,877,542,529 PROGRAM TOTALS 590,000,773 lib/tdb/common/lock.c:tdb_lock_list 479,000,608 lib/tdb/common/lock.c:tdb_unlock 446,500,532 lib/tdb/common/io.c:tdb_read 364,000,824 lib/tdb/common/hash.c:tdb_jenkins_hash 285,000,532 lib/tdb/common/io.c:tdb_write 262,054,669 /x86_64/multiarch/memmove-vec-unaligned-erms.S:__memcpy_avx_unaligned_erms 206,500,496 lib/tdb/common/mutex.c:tdb_mutex_lock 193,000,176 lib/tdb/common/tdb.c:tdb_find 160,000,256 lib/talloc/talloc.c:_talloc_get_type_abort 148,500,297 lib/tdb/common/tdb.c:tdb_storev 140,000,196 lib/tdb/common/lock.c:tdb_lock 130,000,858 lib/util/debug.c:debuglevel_get_class 128,003,722 lib/talloc/talloc.c:_talloc_free 128,000,118 lib/tdb/common/tdb.c:tdb_parse_record 126,000,576 lib/tdb/common/lock.c:tdb_brlock.part.3 121,000,272 lib/tdb/common/mutex.c:tdb_mutex_unlock 118,000,225 /nptl/pthread_mutex_lock.c:__pthread_mutex_lock_full 112,750,222 lib/tdb/common/freelist.c:tdb_allocate_from_freelist 108,500,168 lib/tdb/common/io.c:tdb_ofs_read 102,500,000 lib/tdb/common/io.c:tdb_parse_data by this: 5,706,522,398 PROGRAM TOTALS 434,000,617 lib/tdb/common/lock.c:tdb_lock_list 389,500,494 lib/tdb/common/io.c:tdb_read 359,000,488 lib/tdb/common/lock.c:tdb_unlock 285,000,532 lib/tdb/common/io.c:tdb_write 237,554,655 /x86_64/multiarch/memmove-vec-unaligned-erms.S:__memcpy_avx_unaligned_erms 208,000,668 lib/tdb/common/hash.c:tdb_jenkins_hash 206,500,496 lib/tdb/common/mutex.c:tdb_mutex_lock 160,000,256 lib/talloc/talloc.c:_talloc_get_type_abort 148,500,297 lib/tdb/common/tdb.c:tdb_storev 136,000,132 lib/tdb/common/tdb.c:tdb_find 130,000,858 lib/util/debug.c:debuglevel_get_class 126,000,576 lib/tdb/common/lock.c:tdb_brlock.part.3 121,000,272 lib/tdb/common/mutex.c:tdb_mutex_unlock 118,000,225 /nptl/pthread_mutex_lock.c:__pthread_mutex_lock_full 112,750,222 lib/tdb/common/freelist.c:tdb_allocate_from_freelist 112,000,168 lib/tdb/common/lock.c:tdb_lock 94,500,154 lib/tdb/common/io.c:tdb_ofs_read 94,000,188 /nptl/pthread_mutex_unlock.c:__pthread_mutex_unlock_full 86,000,086 lib/dbwrap/dbwrap.c:dbwrap_lock_order_lock 83,000,083 lib/dbwrap/dbwrap_tdb.c:db_tdb_do_locked time smbtorture3 //foo/bar -U% local-g-lock-ping-pong -o 5000000 gives: 902834 locks/sec real 0m11,103s user 0m8,233s sys 0m2,868s vs. 1037262 locks/sec real 0m9,685s user 0m6,788s sys 0m2,896s Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org> Autobuild-User(master): Volker Lendecke <vl@samba.org> Autobuild-Date(master): Wed Jul 8 11:02:39 UTC 2020 on sn-devel-184
2020-05-15lib: Allow DBWRAP_LOCK_ORDER_NONE in db_open()Volker Lendecke1-1/+2
locking.tdb will not have a LOCK_ORDER anymore, this will be done by the code in g_lock.c. We need to allow opening a database with dbwrap without having a lock order. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>