summaryrefslogtreecommitdiff
path: root/source3/lib/dbwrap
AgeCommit message (Collapse)AuthorFilesLines
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>
2020-05-05lib: Fix a commentVolker Lendecke1-1/+1
The "deleted bit" went away with 341223a00596e Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
2020-04-28lib: Use ctdbd_req_send/recv in ctdb_parse_send/recvVolker Lendecke1-11/+5
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
2020-04-21dbwrap_watch: Set rec->value_valid while returning nested share_mode_do_locked()Anoop C S1-0/+1
As reported on samba-technical by Rouven WEILER <Rouven_Weiler@gmx.net>: https://lists.samba.org/archive/samba-technical/2020-April/135116.html Following backtrace was observed with vfs_fruit for time machine backup: [2020/04/10 08:00:38.107917, 0] ../../lib/dbwrap/dbwrap.c:82(dbwrap_record_get_value) PANIC: assert failed at ../../lib/dbwrap/dbwrap.c(82): rec->value_valid [2020/04/10 08:00:38.108499, 0] ../../source3/lib/util.c:830(smb_panic_s3) PANIC (pid 3427): assert failed: rec->value_valid [2020/04/10 08:00:38.109541, 0] ../../lib/util/fault.c:265(log_stack_trace) BACKTRACE: 37 stack frames: #0 /usr/lib/samba/amd64/libsamba-util.so.0.0.1'log_stack_trace+0x26 [0xfffffd7fee51de66] #1 /usr/lib/samba/amd64/libsmbconf.so.0'smb_panic_s3+0x26 [0xfffffd7fedf5a596] #2 /usr/lib/samba/amd64/libsamba-util.so.0.0.1'smb_panic+0x1f [0xfffffd7fee51df3f] #3 /usr/lib/samba/private/amd64/libdbwrap-samba4.so'dbwrap_record_get_value+0x2a [0xfffffd7feccb627a] #4 /usr/lib/samba/private/amd64/libsmbd-base-samba4.so'get_share_mode_lock+0x109 [0xfffffd7fee7195c9] #5 /usr/lib/samba/private/amd64/libsmbd-base-samba4.so'smbd_contend_level2_oplocks_begin+0xa1 [0xfffffd7fee7f7761] #6 /usr/lib/samba/private/amd64/libsmbd-base-samba4.so'brl_lock+0x635 [0xfffffd7fee710f45] #7 /usr/lib/samba/private/amd64/libsmbd-base-samba4.so'do_lock_fn+0xa4 [0xfffffd7fee70d534] #8 /usr/lib/samba/private/amd64/libsmbd-base-samba4.so'share_mode_do_locked_fn+0x86 [0xfffffd7fee7174b6] #9 /usr/lib/samba/amd64/libsmbconf.so.0'dbwrap_watched_do_locked_fn+0xfa [0xfffffd7fedf622ca] #10 /usr/lib/samba/private/amd64/libdbwrap-samba4.so'db_tdb_do_locked+0x12f [0xfffffd7feccb95cf] #11 /usr/lib/samba/private/amd64/libdbwrap-samba4.so'dbwrap_do_locked+0x48 [0xfffffd7feccb69a8] #12 /usr/lib/samba/amd64/libsmbconf.so.0'dbwrap_watched_do_locked+0x6f [0xfffffd7fedf60d7f] #13 /usr/lib/samba/private/amd64/libdbwrap-samba4.so'dbwrap_do_locked+0x48 [0xfffffd7feccb69a8] #14 /usr/lib/samba/private/amd64/libsmbd-base-samba4.so'share_mode_do_locked+0xd2 [0xfffffd7fee719b82] #15 /usr/lib/samba/private/amd64/libsmbd-base-samba4.so'do_lock+0xf0 [0xfffffd7fee70dfe0] #16 /usr/lib/samba/amd64/vfs/fruit.so'fruit_create_file+0x7ba [0xfffffd7fe88855aa] #17 /usr/lib/samba/private/amd64/libsmbd-base-samba4.so'smbd_smb2_request_process_create+0xa07 [0xfffffd7fee7d3237] #18 /usr/lib/samba/private/amd64/libsmbd-base-samba4.so'smbd_smb2_request_dispatch+0xc8f [0xfffffd7fee7c985f] #19 /usr/lib/samba/private/amd64/libsmbd-base-samba4.so'smbd_smb2_connection_handler+0x621 [0xfffffd7fee7ca7e1] #20 /usr/lib/samba/private/amd64/libtevent.so.0.10.2'tevent_common_invoke_fd_handler+0x80 [0xfffffd7fecd3a580] #21 /usr/lib/samba/private/amd64/libtevent.so.0.10.2'epoll_event_loop_once+0x22c [0xfffffd7fecd4180c] #22 /usr/lib/samba/private/amd64/libtevent.so.0.10.2'std_event_loop_once+0x40 [0xfffffd7fecd3f8f0] #23 /usr/lib/samba/private/amd64/libtevent.so.0.10.2'_tevent_loop_once+0x95 [0xfffffd7fecd39bd5] #24 /usr/lib/samba/private/amd64/libtevent.so.0.10.2'tevent_common_loop_wait+0x23 [0xfffffd7fecd39e43] #25 /usr/lib/samba/private/amd64/libtevent.so.0.10.2'std_event_loop_wait+0x40 [0xfffffd7fecd3f870] #26 /usr/lib/samba/private/amd64/libsmbd-base-samba4.so'smbd_process+0x777 [0xfffffd7fee7b8677] #27 /usr/lib/samba/sbin/amd64/smbd'smbd_accept_connection+0x189 [0x40d5b9] #28 /usr/lib/samba/private/amd64/libtevent.so.0.10.2'tevent_common_invoke_fd_handler+0x80 [0xfffffd7fecd3a580] #29 /usr/lib/samba/private/amd64/libtevent.so.0.10.2'epoll_event_loop_once+0x22c [0xfffffd7fecd4180c] #30 /usr/lib/samba/private/amd64/libtevent.so.0.10.2'std_event_loop_once+0x40 [0xfffffd7fecd3f8f0] #31 /usr/lib/samba/private/amd64/libtevent.so.0.10.2'_tevent_loop_once+0x95 [0xfffffd7fecd39bd5] #32 /usr/lib/samba/private/amd64/libtevent.so.0.10.2'tevent_common_loop_wait+0x23 [0xfffffd7fecd39e43] #33 /usr/lib/samba/private/amd64/libtevent.so.0.10.2'std_event_loop_wait+0x40 [0xfffffd7fecd3f870] #34 /usr/lib/samba/sbin/amd64/smbd'main+0x1a0f [0x40f9ff] #35 /usr/lib/samba/sbin/amd64/smbd'_start_crt+0x83 [0x408e73] #36 /usr/lib/samba/sbin/amd64/smbd'_start+0x18 [0x408dd8] In this particular nested share_mode_do_locked() invocation, callback comes through dbwrap_watched_do_locked_fn() where it fails to update rec->value_valid which further gets assigned to static_share_mode_record within share_mode_do_locked_fn(). BUG: https://bugzilla.samba.org/show_bug.cgi?id=14352 Signed-off-by: Anoop C S <anoopcs@redhat.com> Reviewed-by: Ralph Boehme <slow@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org> Autobuild-User(master): Ralph Böhme <slow@samba.org> Autobuild-Date(master): Tue Apr 21 17:37:43 UTC 2020 on sn-devel-184
2020-04-02dbwrap: fix possible memleak and false result check.Swen Schillig1-3/+6
A cstatus != 0 or a data.dsize != sizeof(uint32_t) does not guarantee to have no received data referenced by data.dptr. Therefore, make sure data.dptr is free'd. Reusing the same data structure as data input and data output parameter can lead to wrong results, especially when the output parameters value is used to detect errors. Create the additional local variable outdata to prevent this issue. Signed-off-by: Swen Schillig <swen@linux.ibm.com> Reviewed-by: Volker Lendecke <vl@samba.org> Reviewed-by: Martin Schwenke <martin@meltin.net> Autobuild-User(master): Martin Schwenke <martins@samba.org> Autobuild-Date(master): Thu Apr 2 11:26:32 UTC 2020 on sn-devel-184
2020-04-02dbwrap: fix comment in code leading to wrong function parameterSwen Schillig1-1/+1
Signed-off-by: Swen Schillig <swen@linux.ibm.com> Reviewed-by: Volker Lendecke <vl@samba.org> Reviewed-by: Martin Schwenke <martin@meltin.net>
2020-02-10dbwrap: Improve an error messageVolker Lendecke1-2/+3
Include the path where db_open() tried to find the ctdb socket Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2020-01-23dbwrap: Do direct struct initalization in db_ctdb_store_db_seqnum()Volker Lendecke1-8/+2
Save a few lines Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2020-01-20s3: lib: dbwrap_ctdb: Ensure value_valid is set when creating empty recordMartin Schwenke1-0/+1
Fixes: PANIC: assert failed at ../../lib/dbwrap/dbwrap.c(82): rec->value_valid PANIC (pid 902392): assert failed: rec->value_valid BACKTRACE: 16 stack frames: #0 bin/shared/libsamba-util.so.0(log_stack_trace+0x30) [0x7fb161f69cb0] #1 bin/shared/libsmbconf.so.0(smb_panic_s3+0x23) [0x7fb1619f4863] #2 bin/shared/libsamba-util.so.0(smb_panic+0x2f) [0x7fb161f69daf] #3 bin/shared/private/libdbwrap-samba4.so(dbwrap_record_get_value+0x27) [0x7fb160a04c57] #4 bin/shared/libsamba-passdb.so.0(+0x2d27c) [0x7fb1618e627c] #5 bin/shared/libsamba-passdb.so.0(pdb_add_aliasmem+0x33) [0x7fb1618db663] #6 bin/shared/libsamba-passdb.so.0(+0x1edbb) [0x7fb1618d7dbb] #7 bin/shared/libsamba-passdb.so.0(create_builtin_administrators+0x167) [0x7fb1618d8217] #8 bin/shared/private/libauth-samba4.so(finalize_local_nt_token+0x39d) [0x7fb16194bd5d] #9 bin/shared/private/libauth-samba4.so(create_local_nt_token_from_info3+0x304) [0x7fb16194c3f4] #10 bin/shared/private/libauth-samba4.so(create_local_token+0x3d6) [0x7fb161945106] #11 bin/shared/private/libauth-samba4.so(+0x154b4) [0x7fb1619474b4] #12 bin/shared/private/libauth-samba4.so(init_guest_session_info+0x58) [0x7fb161947798] #13 ./bin/smbd(main+0x80f) [0x55944ef8f91f] #14 /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xeb) [0x7fb161076bbb] #15 ./bin/smbd(_start+0x2a) [0x55944ef90f8a] This is a similar, additional fix to commit 36ea1e188d5ea8d40c47ffc466a494c1160e471c. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Mon Jan 20 04:25:57 UTC 2020 on sn-devel-184
2020-01-14lib: Remove "msg_ctx" from server_id_watch_send()Volker Lendecke1-1/+1
Not needed Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2020-01-13s3: lib: dbwrap. Cleanup. Add a couple of missing 'return NULL' statements ↵Jeremy Allison1-0/+2
on talloc fail. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
2020-01-13s3: lib: dbwrap_ctdb: Ensure value_valid is set true if we find the record ↵Jeremy Allison1-0/+1
in the marshall buffer. Found by "Christopher O Cowan - Christopher.O.Cowan@ibm.com" <Christopher.O.Cowan@ibm.com> Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
2020-01-08s3: lib: dbwrap: Set rec->value_valid to avoid backtrace in `smbstatus`Anoop C S1-0/+2
Following backtrace is observed on executing `smbstatus` with at least one SMB client connection established: PANIC: assert failed at ../../lib/dbwrap/dbwrap.c(82): rec->value_valid PANIC (pid 350270): assert failed: rec->value_valid BACKTRACE: 15 stack frames: #0 /usr/local/lib/libsamba-util.so.0(log_stack_trace+0x1f) [0x7fbbd9b32047] #1 /usr/local/lib/libsmbconf.so.0(smb_panic_s3+0x74) [0x7fbbd9c1e6ff] #2 /usr/local/lib/libsamba-util.so.0(smb_panic+0x28) [0x7fbbd9b32012] #3 /usr/local/lib/samba/libdbwrap- samba4.so(dbwrap_record_get_value+0x86) [0x7fbbd95800ac] #4 /usr/local/lib/samba/libsmbd-base-samba4.so(+0x28f563) [0x7fbbd999e563] #5 /usr/local/lib/samba/libsamba-cluster-support-samba4.so(+0x7851) [0x7fbbd92c7851] #6 /usr/local/lib/samba/libsamba-cluster-support- samba4.so(ctdbd_traverse+0x4ca) [0x7fbbd92cc641] #7 /usr/local/lib/samba/libsamba-cluster-support-samba4.so(+0x73eb) [0x7fbbd92c73eb] #8 /usr/local/lib/samba/libsamba-cluster-support-samba4.so(+0x7a52) [0x7fbbd92c7a52] #9 /usr/local/lib/samba/libdbwrap-samba4.so(dbwrap_traverse_read+0x35) [0x7fbbd9580de5] #10 /usr/local/lib/samba/libsmbd-base- samba4.so(smbXsrv_tcon_global_traverse+0xc5) [0x7fbbd999e7d9] #11 smbstatus(connections_forall_read+0x114) [0x55d17872b8ee] #12 smbstatus(main+0x7b2) [0x55d17872a2f3] #13 /lib64/libc.so.6(__libc_start_main+0xf3) [0x7fbbd93a21a3] #14 smbstatus(_start+0x2e) [0x55d17872894e] Can not dump core: corepath not set up Assertion on rec->value_valid fails as it is uninitialized in the following functions: traverse_read_callback traverse_persistent_callback_read Signed-off-by: Anoop C S <anoopcs@redhat.com> Reviewed-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Wed Jan 8 23:24:58 UTC 2020 on sn-devel-184
2019-11-22dbwrap_watch: Don't store in-RAM cachesVolker Lendecke1-269/+359
The history of this file is a mess with lots of bugs. Most of the bugs I believe are based on the cache of database contents we maintain in struct dbwrap_watch_rec. This patch removes that cache and does all modifications directly in the backend database. This means we have to mess with the database format in a few more places, but I think the format is simple enough that this does not really hurt. I tried for a few days to split this up into small pieces that are easier to understand, but every time I separated out individual chunks I found difficult to track down bugs that are all resolved in the final code presented here. It's more lines of code, but I hope it's more robust. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2019-11-22dbwrap_watch: Simplify struct dbwrap_watched_watch_stateVolker Lendecke1-82/+4
With the wakeup messages changed, we don't need to store what used to be the old message in the struct dbwrap_watched_watch_state anymore. We still need to store the key that is watched for removal of our watch entry in the request destructor Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2019-11-22dbwrap_watch: Simplify the wakeup messagesVolker Lendecke1-23/+21
The instance ID per process globally identifies a watch instance across databases. It's not necessary to send the database ID and the watched key across, the uin64_t instance ID is sufficient. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2019-11-22dbwrap_watch: Add a uin64_t instance to watchersVolker Lendecke1-6/+19
Initially used for debugging purposes only Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2019-11-22dbwrap_watch: Encapsulate watchers in "struct dbwrap_watcher"Volker Lendecke1-34/+69
Next patch will extend this structure Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2019-11-22dbwrap_watch: Prevent two watchers per fetch_locked sequenceVolker Lendecke1-0/+4
This can lead to very confusing bugs, and the code right now does not deal with it well. 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-3/+0
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 Lendecke2-0/+5
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-6/+11
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-10-24s3:dbwrap: initialize messaging before getting the ctdb connectionRalph Boehme1-1/+7
This is a better fix for bug #13465. Bug: https://bugzilla.samba.org/show_bug.cgi?id=13925 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2019-10-18dbwrap_watch: Fix cleaning up dead watchersVolker Lendecke1-0/+1
"wrec->num_watchers" changes in dbwrap_watch_rec_del_watcher(). In 32d6cc84c I forgot to update the copy of that variable. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Fri Oct 18 22:28:07 UTC 2019 on sn-devel-184
2019-10-02dbwrap_watch: Don't alert ourselves, fix raw.oplock.batch26 raceVolker Lendecke1-2/+14
This fixes the following flaky test: UNEXPECTED(failure): samba3.raw.oplock.batch26(nt4_dc) REASON: Exception: Exception: (../../source4/torture/raw/oplock.c:3718): wrong value for break_info.count got 0x2 - should be 0x1 You can reproduce it with two small msleeps, which means it's a race condition: diff --git a/source3/smbd/open.c b/source3/smbd/open.c index 20b5a3e294c..126c7fc021d 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -1917,6 +1917,14 @@ NTSTATUS send_break_message(struct messaging_context *msg_ctx, DATA_BLOB blob; NTSTATUS status; + { + static bool sent = false; + if (sent) { + smb_msleep(500); + } + sent = true; + } + if (DEBUGLVL(10)) { struct server_id_buf buf; DBG_DEBUG("Sending break message to %s\n", diff --git a/source3/smbd/oplock.c b/source3/smbd/oplock.c index b3da84b1269..d9c4dbb9487 100644 --- a/source3/smbd/oplock.c +++ b/source3/smbd/oplock.c @@ -858,6 +858,8 @@ static void process_oplock_break_message(struct messaging_context *msg_ctx, uint16_t break_to; bool break_needed = true; + smb_msleep(100); + msg = talloc(talloc_tos(), struct oplock_break_message); if (msg == NULL) { DBG_WARNING("talloc failed\n"); 15a8af075a2 introduced a bug where we immediately wake up ourselves after doing a watch_send, leading to two inter-smbd oplock break messages for this case. In theory, this should not matter, as in the oplock break handler in the destination smbd we check (fsp->sent_oplock_break != NO_BREAK_SENT) so that the break does not get sent twice. However, with the above two sleeps the oplock holding client could send out its oplock downgrade while the second inter-smbd break messages was on its way. The real fix would be to note in the share mode array that the inter-smbd message has already been sent, but as other users of dbwrap_watched_watch_send might also be affected by this bug, this fix should be sufficient to get rid of this flaky test. Unfortunately, dbwrap_watch.c is now pretty complex and needs some serious refactoring to become understandable again. But that's something for another day, sorry. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
2019-10-02dbwrap_watch: Remove "addwatch" handling from dbwrap_watched_save()Volker Lendecke1-28/+10
This has been moved to dbwrap_watched_watch_send() Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
2019-10-02dbwrap_watch: Move reallocating watchers to dbwrap_watched_watch_send()Volker Lendecke1-2/+19
Before 15a8af075a2 we did not have a separately allocated watchers array and dbwrap_watched_save() could play (too) smart tricks with dbwrap_record_storev(). Now that we always have watchers talloc'ed, we can remove those smart tricks from dbwrap_watched_save() in the next commit. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
2019-10-02dbwrap_watch: Slightly simplify dbwrap_watched_fetch_locked()Volker Lendecke1-4/+1
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
2019-09-17lib: Enable watching and storing dbwrap_watch records.Volker Lendecke1-14/+55
Samba so far on a dbwrap_watch record either watches or stores a record, but never both from the same db_record instance acquired from a dbwrap_fetch_locked(). In one of the next commits this will change, we will watch a record and at the same time store data into it. This patch enables a watch_send() followed by a storev() by properly keeping the watchers around. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2019-07-24s3/lib/dbwrap: clang: Fix 'Access to field results in a deref of a null'Noel Power1-0/+5
Fixes: source3/lib/dbwrap/dbwrap_ctdb.c:530:39: warning: Access to field 'm_write' results in a dereference of a null pointer (loaded from field 'transaction') <--[clang] if (pull_newest_from_marshall_buffer(ctx->transaction->m_write, key, Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
2019-07-24s3/lib/dwrap: clang: Fix 'Value stored to 'ret' is never read'Noel Power1-1/+1
Fixes: source3/lib/dbwrap/dbwrap_ctdb.c:95:2: warning: Value stored to 'ret' is never read <--[clang] ret = ctdbd_init_connection(mem_ctx, ^ ~~~~~~ Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
2019-07-16s3/lib/dwrap: clang: Fix 'Array access results in a null pointer dereference'Noel Power1-1/+1
Fixes: source3/lib/dbwrap/dbwrap_watch.c:55:3: warning: Array access (from variable 'wkey') results in a null pointer dereference <--[clang] SIVAL(wkey, 0, db_id_len); ^ 1 warning generated. Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
2019-07-04dbwrap: Add publically available dbwrap_watch_wakeup()Volker Lendecke2-0/+24
Without this, to notify watchers you need to actually store data. This might be a waste of resources. locking.tdb waiters might actually wait for leases.tdb or brlock.tdb changes, and locking.tdb records can be large. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
2019-07-04dbwrap: Rename dbwrap_watched_wakeup()Volker Lendecke1-6/+7
In the next step I want to make dbwrap_watched_wakeup() publically available under that canonical name. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
2019-05-28dbwrap: Use sizeof, not an integer constantVolker Lendecke1-1/+2
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2018-09-13dbwrap_ctdb: return correct record count for a persistent db read-only traverseRalph Boehme1-1/+9
Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Thu Sep 13 01:34:30 CEST 2018 on sn-devel-144
2018-09-12dbwrap_ctdb: increment record count in traverse_callback()Ralph Boehme1-0/+1
state->count wasn't incremented and is returned at the end of a dbwrap_traverse(). Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2018-09-12dbwrap_ctdb: use struct initializer in db_ctdb_traverse()Ralph Boehme1-4/+5
This ensures all struct members are implicitly initialized. Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2018-09-12dbwrap_ctdb: use struct initializer in db_ctdb_traverse_read()Ralph Boehme1-4/+5
This ensures all struct members are implicitly initialized. Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2018-09-12dbwrap_ctdb: README.Coding fixes in traverse_callback()Ralph Boehme1-3/+10
NULL initialize pointers, check function return values, explicit variable check against NULL. Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2018-09-12dbwrap_ctdb: simplify if conditionRalph Boehme1-6/+8
This just moves the talloc_memdup() out of the if condition as per README.Coding. Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2018-09-12dbwrap_ctdb: add error checking to ctdbd_dbpath()Ralph Boehme1-0/+5
Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2018-09-12dbwrap: early return, removes an indentation levelRalph Boehme1-17/+17
No change in behaviour. Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2018-09-12dbwrap: move sockname variable and call to lp_ctdbd_socket into contextRalph Boehme1-3/+3
sockname is only needed in a cluster. Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2018-09-07s3: Rename server_messaging_context() to global_messaging_context()Christof Schmitt1-1/+1
This reflects that the messaging context is also used outside of the server processes. The command used for the rename: find . -name '*.[hc]' -print0 | xargs -0 sed -i 's/server_messaging_context/global_messaging_context/' Signed-off-by: Christof Schmitt <cs@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
2018-08-17dbwrap: Clarify db_open_watched APIVolker Lendecke2-5/+5
Point out in the API that "backend" talloc_moves into the watched database. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Fri Aug 17 21:29:15 CEST 2018 on sn-devel-144