summaryrefslogtreecommitdiff
path: root/ctdb/common
Commit message (Collapse)AuthorAgeFilesLines
* ctdb-util: Log an error if there is no way to set schedulerMartin Schwenke2014-09-171-0/+1
| | | | | | | | Although configure should catch this, logging a run-time error is better than being mystified when ctdbd silently exits. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-daemon: Make sure ctdb runs with real-time priorityAmitay Isaacs2014-09-121-4/+7
| | | | | Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-util: Rename db_wrap to tdb_wrap and make it a build subsystemMartin Schwenke2014-09-101-1/+1
| | | | | | | | | | | | | | | This makes it consistent with Samba, to ease transition. Update unit test code to link to with tdb_wrap instead of including db_wrap.c. There are some potential whitespace fixes in this commit that have been ignored. CTDB's lib/tdb_wrap will be deleted after the transition to Samba's lib/tdb_wrap, so there's no point polishing it too much. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-logging: Move variable debug_extra from debug.*Martin Schwenke2014-09-101-0/+1
| | | | | | | | debug_extra is CTDB-specific. Moving it will help with the transitions to Samba's updated debug.[ch]. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-common: Add some missing #includesMartin Schwenke2014-09-103-0/+5
| | | | | | | | To avoid warnings when using --enable-developer, which uses -Wmissing-prototypes. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-common: Refactor code to convert TDB_DATA key to aligned uint32 arrayAmitay Isaacs2014-09-051-0/+18
| | | | | Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-daemon: Fix some strict-aliasing warningsMartin Schwenke2014-08-211-1/+1
| | | | | | | | | | | | | | Seeing these with -Wall: ../server/ctdb_call.c:1117:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] record_flags = *(uint32_t *)&c->data[c->keylen + c->datalen]; ^ memcpy() seems to be the easiest way to get fix these. The alternative would be to use unmarshalling functions. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-util: Fix warning about ignored result from system()Martin Schwenke2014-08-211-2/+6
| | | | | Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb: Use sys_read() and sys_write() to ensure correct signal interactionMartin Schwenke2014-08-211-4/+6
| | | | | | | ... and avoid compiler warnings in some cases. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-common: Copy functions sys_read() and sys_write() from source3Martin Schwenke2014-08-211-0/+34
| | | | | | | | | We really should extricate these from source3 and into some common code. However, just copy them for now to help get rid of a lot of warnings. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-util: Refactor record marshalling routines to avoid extra tallocAmitay Isaacs2014-07-231-20/+13
| | | | | Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Volker Lendecke <vl@samba.org>
* ctdb-util: Refactor ctdb_marshall_recordAmitay Isaacs2014-07-231-14/+37
| | | | | | | Create new routines ctdb_marshall_record_size and ctdb_marshall_record_copy Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Volker Lendecke <vl@samba.org>
* ctdb-util: Fix nonempty line endingsAmitay Isaacs2014-07-231-3/+3
| | | | | Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Volker Lendecke <vl@samba.org>
* ctdb: Fix verbose_memory_namesVolker Lendecke2014-07-221-1/+1
| | | | | | | | | | | | If we have already partly written a packet, "data" and thus "pkt->data" does not point to the start of the packet anymore. Assign "hdr" while it still points at the start of the header. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Amitay Isaacs <amitay@gmail.com> Autobuild-User(master): Amitay Isaacs <amitay@samba.org> Autobuild-Date(master): Tue Jul 22 06:09:50 CEST 2014 on sn-devel-104
* ctdb: Avoid a talloc in ctdb_queue_sendVolker Lendecke2014-07-221-3/+6
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-ltdb: Use tdb_null instead of zeroing TDB_DATA variableAmitay Isaacs2014-07-141-4/+2
| | | | | | | | Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Volker Lendecke <vl@samba.org> Autobuild-User(master): Volker Lendecke <vl@samba.org> Autobuild-Date(master): Mon Jul 14 16:01:31 CEST 2014 on sn-devel-104
* ctdb-common: Use SCHED_RESET_ON_FORK when setting SCHED_FIFOMartin Schwenke2014-07-071-1/+7
| | | | | | | | | | This makes the scheduler reset code a no-op. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com> Autobuild-User(master): Amitay Isaacs <amitay@samba.org> Autobuild-Date(master): Mon Jul 7 13:28:25 CEST 2014 on sn-devel-104
* ctdb-daemon: Check PID in ctdb_remove_pidfile(), not unreliable flagMartin Schwenke2014-07-051-8/+0
| | | | | | | | | | | | | | | | | | If something unexpectedly uses fork() then an exiting child will remove the PID file while the main daemon is still running. The real test is whether the current process has the PID of the main CTDB daemon, which is the process that calls setsid(). This could be done using getpgrp() instead. At the moment the eventscript handler harmlessly calls setpgid() - harmless because the atexit() handlers are cleared upon exec(). However, it is possible that process groups will be used more in future so it is probably better to rely on the session ID. Thanks to Sumit Bose <sbose@redhat.com> for the idea. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-logging: Move controls handling functions from common to serverAmitay Isaacs2014-06-121-41/+0
| | | | | Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-logging: Split ringbuffer handling code from ctdb_collect_logAmitay Isaacs2014-06-121-7/+21
| | | | | Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-common: Move mkdir_p_or_die to system utilitiesAmitay Isaacs2014-06-122-14/+14
| | | | | Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-daemon: Rename ctdb_mkdir_p_or_die to mkdir_p_or_dieAmitay Isaacs2014-06-121-1/+1
| | | | | | | This function does not require ctdb context. Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-common: Move lockdown_memory to system utilitiesAmitay Isaacs2014-06-122-27/+28
| | | | | Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-daemon: Rename ctdb_lockdown_memory to lockdown_memoryAmitay Isaacs2014-06-121-1/+1
| | | | | Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-daemon: Instead of passing ctdb context, pass valgrinding booleanAmitay Isaacs2014-06-121-2/+2
| | | | | Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-common: Keep debug level related functions with logging codeAmitay Isaacs2014-06-122-40/+40
| | | | | Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-common: Remove unused functionsAmitay Isaacs2014-06-121-16/+0
| | | | | Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-common: Separate more system utilities that are independent of ctdbAmitay Isaacs2014-06-122-251/+252
| | | | | Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-common: Separate system utilties that are ctdb independentAmitay Isaacs2014-06-122-49/+71
| | | | | | | | Routines in system_common and system_<os> are supposed to be ctdb functions with OS specific implementations. Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-common: No dynamic memory allocation in mkdir_p()Martin Schwenke2014-06-121-10/+27
| | | | | | | | | Allocate an array of size PATH_MAX on the stack instead. To stop unnecessary recursion, try to create the desired directory before creating ancestors and only create ancestors on ENOENT. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-common: Do not dynamically allocate memory when not necessaryMartin Schwenke2014-06-121-19/+17
| | | | | | | | Copy these values onto the stack instead. INET6_ADDRSTRLEN is 46, so 64 is plenty for an IP address and a port number. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-common: Drop ctdb prefix from utility functions independent of ctdbAmitay Isaacs2014-06-122-4/+4
| | | | | Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-common: Changing scheduler policy does not require ctdb contextAmitay Isaacs2014-06-122-3/+3
| | | | | Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-common: Do not abort if restoring scheduling policy failsAmitay Isaacs2014-06-121-3/+3
| | | | | | | | This code is only executed in child processes, so aborting does not really achieve much. Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-common: No need to save previous scheduler priorityAmitay Isaacs2014-06-121-26/+8
| | | | | | | | When calling sched_setscheduler() with SCHED_OTHER, the only valid priority is 0. Nice value is "restored" anyway. Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-util: Do not use mlockall() on AIXAmitay Isaacs2014-03-041-6/+1
| | | | | | | Memory lockdown causes recovery daemon to crash on AIX. Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-common: mkdir_p should not try to create .Amitay Isaacs2014-01-161-0/+4
| | | | | Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-common: Refactor code to keep track of child processesAmitay Isaacs2013-11-271-8/+14
| | | | | | | This code can then be used to track child processes created with vfork(). Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Michael Adam <obnox@samba.org>
* ctdb-common: Coverity fixesAmitay Isaacs2013-11-193-16/+37
| | | | | Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Michael Adam <obnox@samba.org>
* common: New function ctdb_mkdir_p_or_die()Martin Schwenke2013-10-251-0/+14
| | | | | | Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit 7b971df79b0b63f83555205eacf48d49ca3a273a)
* common: New function mkdir_p()Martin Schwenke2013-10-251-0/+28
| | | | | | | | | Behaves like mkdir -p. Signed-off-by: Martin Schwenke <martin@meltin.net> Pair-programmed-with: Amitay Isaacs <amitay@gmail.com> (This used to be ctdb commit afe2145d91725daf1399f0a24f1cddcf65f0ec31)
* common/util: Use AIX specific code for setting high priority for CTDB daemonAmitay Isaacs2013-10-221-3/+51
| | | | | | Signed-off-by: Amitay Isaacs <amitay@gmail.com> (This used to be ctdb commit 7764cf67a61bbf1caad5aa8e2d75a262b9da654c)
* common: Fix setting of debug level in the client codeAmitay Isaacs2013-10-041-0/+7
| | | | | | Signed-off-by: Amitay Isaacs <amitay@gmail.com> (This used to be ctdb commit 299fa487549e36572b757852d21471f9e23f6e8f)
* utils: Make debug level strings case-insensitiveMartin Schwenke2013-09-251-1/+1
| | | | | | | Signed-off-by: Martin Schwenke <martin@meltin.net> Pair-programmed-with: Amitay Isaacs <amitay@gmail.com> (This used to be ctdb commit c700dd0c7b6b43b61b3e231643b5d7cbe2f9592a)
* common: Make parse_ip() valgrind-cleanMartin Schwenke2013-09-111-0/+2
| | | | | | | Signed-off-by: Martin Schwenke <martin@meltin.net> Pair-programmed-with: Amitay Isaacs <amitay@gmail.com> (This used to be ctdb commit c0bb147ca09e82019b05ec22995623cffc3184e2)
* common/io: Limit the queue buffer size for fair scheduling via teventAmitay Isaacs2013-08-221-12/+31
| | | | | | | | | | | | | | | | | | | | If we process all the data available in a socket buffer, CTDB can stay busy processing lots of packets via immediate event mechanism in tevent. After processing an immediate event, tevent returns without epoll_wait. So as long as there are immediate events, tevent will never poll other FDs. CTDB will report this as "Event handling took xx seconds" warning. This is misleading since CTDB is very busy processing packets, but never gets to the point of polling FDs. The improvement in socket handling made it worse when handling traverse control. There were lots of packets filled in the socket buffer quickly and CTDB stayed busy processing those packets and not polling other FDs and timer events. This can lead to controls timing out and in worse case other nodes marking busy node as disconnected. Signed-off-by: Amitay Isaacs <amitay@gmail.com> (This used to be ctdb commit 92939c1178d04116d842708bc2d6a9c2950e36cc)
* Revert "common/io: Keep queue buffer size multiple of 4K"Amitay Isaacs2013-08-221-22/+6
| | | | | | | | | | | | | | | This reverts commit 5e9b1a7e24d058ff88aaa0563db36a804e866fa9. This is not the best approach. Allowing queue buffer size to grow indefinitely causes large number of CTDB packets to be queued up very quickly which when processed via immediate events will block CTDB from processing events from other FDs. If there are immediate events queued up, tevent will never process any of the FDs till all immediate events are processed. Signed-off-by: Amitay Isaacs <amitay@gmail.com> (This used to be ctdb commit d8b094e804efc53fae9f44c6ef961b7b5797d290)
* Revert "LACOUNT: Add back lacount mechanism to defer migrating a ↵Amitay Isaacs2013-08-221-1/+0
| | | | | | | | | | | | | | | | | | | fetched/read copy until after default of 20 consecutive requests from the same node" This reverts commit 035c0d981bde8c0eee8b3f24ba8e2dc817e5b504. This is a premature optimization. Record can bounce between nodes very quickly if it is a contended record. There is no need to hold a record on a node unnecessarily. In case record contention becomes bad, enabling sticky records on a database is a better idea. Conflicts: include/ctdb_private.h server/ctdb_tunables.c Signed-off-by: Amitay Isaacs <amitay@gmail.com> (This used to be ctdb commit ac417b0003f0116f116834ad2ac51482d25cfa0d)
* ctdbd: For volatile databases, write an empty record with rsn=0 only on dmasterAmitay Isaacs2013-08-221-1/+3
| | | | | | | | | | Empty record with rsn=0 should not be written on any other node other than dmaster. This is however not true for persistent databases. So currently apply the check only for volatile databases. Signed-off-by: Amitay Isaacs <amitay@gmail.com> (This used to be ctdb commit df83ae7a047dab4803e0d94b1c11df48ae17ca96)
* util: In passing the code, fix a space vs. tab in set_close_on_exec().Michael Adam2013-08-191-1/+1
| | | | | | Signed-off-by: Michael Adam <obnox@samba.org> (This used to be ctdb commit f9556a6f1fe0046308c8b363e6dcaf3f7ce6f2b7)