1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-25 23:21:54 +03:00
Commit Graph

45 Commits

Author SHA1 Message Date
David Disseldorp
d9d16cb582 g_lock: don't leak lock_path onto talloc tos
Also check for allocation failures.

Signed-off-by: David Disseldorp <ddiss@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-11-03 23:46:05 +01:00
Michael Adam
cf0cb0add9 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>
2014-02-07 16:06:06 +01:00
Stefan Metzmacher
f3915cf0ec s3:lib: make use of samba_tevent_context_init()
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2013-02-19 23:47:47 +01:00
Stefan Metzmacher
774c28416b s3:g_lock: use serverid_exists() with SERVERID_UNIQUE_ID_NOT_TO_VERIFY
metze
2012-08-24 13:43:31 +02:00
Volker Lendecke
cbe25105c7 s3-g_lock: Make g_lock_lock more robust
If for some reason the cleanup of dbwrap_watch_send does not work
properly, we might starve indefinitely. Make the lock routine more
robust by retrying every 5-10 seconds. g_lock_trylock will clean up
orphaned entries.

Signed-off-by: Christian Ambach <ambi@samba.org>

Autobuild-User(master): Christian Ambach <ambi@samba.org>
Autobuild-Date(master): Thu Aug 16 19:44:00 CEST 2012 on sn-devel-104
2012-08-16 19:44:00 +02:00
Volker Lendecke
494003fb67 s3-g_lock: Properly free "rec" on retry to avoid deadlock
Signed-off-by: Christian Ambach <ambi@samba.org>
2012-08-16 18:05:34 +02:00
Michael Adam
73b200064f s3:util: rename procid_equal() to serverid_equal()
Signed-off-by: Stefan Metzmacher <metze@samba.org>
2012-06-21 08:27:32 +02:00
Volker Lendecke
1be6d849ab s3-g_lock: Use dbwrap_record_watch_send/recv
This simplifies the g_lock implementation. The new implementation tries to
acquire a lock. If that fails due to a lock conflict, wait for the g_lock
record to change. Upon change, just try again. The old logic had to cope with
pending records and an ugly hack into ctdb itself. As a bonus, we now get a
really clean async g_lock_lock_send/recv that can asynchronously wait for a
global lock. This would have been almost impossible to do without the
dbwrap_record_watch infrastructure.
2012-04-19 22:24:19 +02:00
Andrew Bartlett
367c567c5f lib/util: Remove sys_poll as it is no longer needed
sys_poll() is only needed if the signal pipe is set up and used, but as
no signal handler ever writes to the pipe, this can all be removed.

signal based events are now handled via tevent.

Andrew Bartlett

Signed-off-by: Jeremy Allison <jra@samba.org>
2012-02-16 15:49:21 -08:00
Volker Lendecke
45e61fcf61 s3: Add a "lock_order" argument to db_open
This will be used to enforce a lock hierarchy between the databases. We have
seen deadlocks between locking.tdb, brlock.tdb, serverid.tdb and notify*.tdb.
These should be fixed by refusing a dbwrap_fetch_locked that does not follow a
defined lock hierarchy.
2012-01-18 14:48:04 +01:00
Volker Lendecke
0f9d14820e s3: Remove a bunch of calls to procid_self()
All callers to messaging_[re]init only used procid_self()
2011-12-12 21:50:25 +01:00
Michael Adam
736af26062 s3:g_lock: convert to use only dbwrap wrapper functions.
Avoid direct use of the db_record and db_context structs.
2011-10-11 14:17:57 +02:00
Michael Adam
aa0f102fd7 s3:g_lock: add a missing \n to a debug message in g_lock_init 2011-09-20 06:28:27 +02:00
Gregor Beck
9c0252446f s3: let g_lock_unlock() return more specific status codes on failure
Signed-off-by: Michael Adam <obnox@samba.org>
2011-09-07 19:50:05 +02:00
Michael Adam
0b5c4a601a s3:dbwrap: move all .c and .h files of dbwrap to lib/dbwrap/
Autobuild-User: Michael Adam <obnox@samba.org>
Autobuild-Date: Fri Jul 29 13:34:22 CEST 2011 on sn-devel-104
2011-07-29 13:34:22 +02:00
Michael Adam
1abdd9b2bb s3:dbwrap: move db_open() to a file dbwrap_open.c of its own.
Also start new folder lib/dbwrap/ where dbwrap_open.c is stored and
make the fallbacke implementation functoins non-static and create a
dbwrap_private.h header file that contains their prototypes.
2011-07-29 12:23:13 +02:00
Michael Adam
75c7320497 s3:g_lock: explicitly include dbwrap.h 2011-07-29 12:23:12 +02:00
Christian Ambach
2ff0d5882f s3:g_lock: g_lock.tdb should not be executable
TDBs are not executable, so do not create the file with
the execution bit set

Autobuild-User: Christian Ambach <ambi@samba.org>
Autobuild-Date: Mon Jun 27 17:09:12 CEST 2011 on sn-devel-104
2011-06-27 17:09:12 +02:00
Andrew Bartlett
16b1c77644 lib/util Bring procid_str() into lib/util as server_id_string()
This is needed for OpenChange, which prints Samba struct server_id
values in debug messages.

Andrew Bartlett
2011-06-09 12:40:09 +02:00
Andrew Bartlett
3d15137653 s3-talloc Change TALLOC_ARRAY() to talloc_array()
Using the standard macro makes it easier to move code into common, as
TALLOC_ARRAY isn't standard talloc.
2011-06-09 12:40:08 +02:00
Günther Deschner
d8cfca3a9b s3: only include tdb headers where needed.
Guenther
2011-05-06 10:48:10 +02:00
Volker Lendecke
8f4e39f6f7 s3: Fix g_lock_lock after the select/poll conversion
Without clustering we don't have an fd to listen on, and sys_poll
needs one element of space

Autobuild-User: Volker Lendecke <vlendec@samba.org>
Autobuild-Date: Wed Mar 30 18:36:50 CEST 2011 on sn-devel-104
2011-03-30 18:36:50 +02:00
Günther Deschner
ab36d597e7 s3-messages: make ndr_messaging.h part of messages.h.
Guenther
2011-03-30 01:13:09 +02:00
Günther Deschner
b2af281e50 s3-messages: only include messages.h where needed.
Guenther
2011-03-30 01:13:09 +02:00
Günther Deschner
0e771263ee s3-includes: only include system/filesys.h when needed.
Guenther
2011-03-30 01:13:07 +02:00
Volker Lendecke
81bdaafab3 s3: Eliminate sys_select from g_lock_lock 2011-02-28 16:40:19 +01:00
Günther Deschner
b38d0542e1 samba: share select wrappers.
Guenther
2010-10-01 22:30:22 +02:00
Jeremy Allison
f98d217514 Change to using TDB_INCOMPATIBLE_HASH (the jenkins hash) on all
TDB_CLEAR_IF_FIRST tdb's. For tdb's like gencache where we open
without CLEAR_IF_FIRST and then with CLEAR_IF_FIRST if corrupt
this is still safe to use as if opening an existing tdb the new
hash will be ignored - it's only used on creating a new tdb not
opening an old one.

Jeremy.
2010-09-27 17:18:54 -07:00
Günther Deschner
8e16d6dbdf s3-build: only include ctdbd_conn.h where needed.
Guenther
2010-09-20 13:54:50 -07:00
Volker Lendecke
5648c3f67e s3: messaging_ctdbd_connection() was only called with procid_self()
Eventually we'll get this right...
2010-08-31 17:07:41 +02:00
Volker Lendecke
0f83aa8650 s3: Remove the dependency of g_lock on procid_self
procid_self() references global vars, don't depend on them unnecessarily
2010-08-28 12:28:53 +02:00
Volker Lendecke
300667e4a9 s3: Pass procid_self() explicitly to messaging_ctdbd_connection() 2010-07-05 11:06:23 +02:00
Günther Deschner
c6ebab846d s3: only include gen_ndr headers where needed.
This shrinks include/includes.h.gch by the size of 7 MB and reduces build time
as follows:

ccache build w/o patch
real    4m21.529s
ccache build with patch
real    3m6.402s

pch build w/o patch
real    4m26.318s
pch build with patch
real    3m6.932s

Guenther
2010-05-06 00:22:59 +02:00
Volker Lendecke
79100c2421 s3: Add "g_lock_do" as a convenience wrapper function 2010-03-12 14:23:25 +01:00
Volker Lendecke
f8b246e44c s3: Fix timeout calculation if g_lock_lock is given a timeout < 60s
Detected while showing this code to obnox :-)
2010-02-16 15:28:42 +01:00
Volker Lendecke
83542d973c s3: Slightly increase parallelism in g_lock
There's no need to still hold the g_lock tdb-level lock while telling the
waiters to retry
2010-02-16 13:21:10 +01:00
Volker Lendecke
be919d6fae s3: Avoid starving locks when many processes die at the same time
In g_lock_unlock we have a little race between the process_exists and
messaging_send call: We only send to 5 waiters now, they all might have died
between us checking their existence and sending the message. This change makes
g_lock_lock retry at least once every minute.
2010-02-16 13:21:10 +01:00
Volker Lendecke
725b3654f8 s3: Avoid a thundering herd in g_lock_unlock
Only notify the first 5 pending lock waiters. This avoids a thundering herd
problem that is really nasty in a cluster. It also makes acquiring a lock a bit
more FIFO, lock waiters are added to the end of the array.
2010-02-16 13:21:10 +01:00
Volker Lendecke
07978bd175 s3: Optimize g_lock_lock for a heavily contended case
Only check the existence of the lock owner in g_lock_parse, check the rest of
the records only when we got the lock successfully. This reduces the load on
process_exists which can involve a network roundtrip in the clustered case.
2010-02-16 13:21:10 +01:00
Volker Lendecke
f3bdb163f4 s3: Fix handling of processes that died in g_lock
g_lock_parse might have thrown away entries from the locks array because the
processes were not around anymore. Don't store the orphaned entries.
2010-02-16 13:21:10 +01:00
Volker Lendecke
bac235dd30 s3: Fix a typo 2010-02-15 16:36:20 +01:00
Jeremy Allison
10e54fb422 Fix warning messages on compile in g_lock.c Volker & Michael please check.
Jeremy.
2010-02-12 22:21:19 -08:00
Michael Adam
83fffbeb44 s3:g_lock: remove a nested event loop, replacing the inner loop by select
This made smbd crash in g_lock_lock() when trying to start a
transaction on a db with an already started transaction,
e.g. in a tcon_and_X where the share_info.tdb was not yet
initialized but share_info.tdb was already locked by another
process or writing acces to the winreg rpc pipe where the
registry tdb was already locked by another process.

What we really _want_ to do here by design is to react to
MSG_DBWRAP_G_LOCK_RETRY messages that are either sent
by a client doing g_lock_unlock or by ourselves when
we receive a CTDB_SRVID_SAMBA_NOTIFY or
CTDB_SRVID_RECONFIGURE message from ctdbd, i.e. when
either a client holding a lock or a complete node
has died.

Doing this properly involves calling tevent_loop_once(),
but doing this here with the main ctdbd messaging context
creates a nested event loop when g_lock_lock() is called
from the main event loop.

So as a quick fix, we act a little corasely here: we do
a select on the ctdb connection fd and when it is readable
or we get EINTR, then we retry without actually parsing
any ctdb packages or dispatching messages. This means that
we retry more often than necessary and intended by design,
but this does not harm and it is unobtrusive. When we have
finished, the main loop will pick up all the messages and
ctdb packets. The only extra twist is that we cannot use
timed events here but have to handcode a timeout for select.

Michael
2010-02-12 23:12:12 +01:00
Michael Adam
8e306b51b7 s3:g_lock: remove an unreached code path.
Michael
2010-02-12 23:12:12 +01:00
Volker Lendecke
4c1c3f2549 s3: Implement global locks in a g_lock tdb
This is the basis to implement global locks in ctdb without depending on a
shared file system. The initial goal is to make ctdb persistent transactions
deterministic without too many timeouts.
2010-02-12 23:12:09 +01:00