[SCM] Samba Shared Repository - branch master updated

Martin Schwenke martins at samba.org
Tue May 1 14:21:02 UTC 2018


The branch, master has been updated
       via  c6c67d9 ctdb-scripts: Remove function rewrite_ctdb_options()
       via  043f3f2 ctdb-scripts: Drop support for CTDB_DBDIR=tmpfs
       via  eb7ec16 ctdb-daemon: Change default volatile database directory
       via  8ea7fa5 ctdb-tests: CTDB_DBDIR_PERSISTENT should not depend on CTDB_DBDIR
       via  051203e ctdb-scripts: Fix location of persistent databases
       via  eba893f ctdb-tests: Fix location of persistent databases
       via  3459a15 ctdb-scripts: Drop UDP/file logging warning from ctdbd_wrapper
       via  9a5ba6b ctdb-daemon: Log the logging location when not logging via syslog()
       via  8821857 ctdb-scripts: Drop warning when there is no recovery lock
       via  79c49f6 ctdb-daemon: Reorder main() to improve the structure
       via  9623c92 ctdb-daemon: Consolidate basic CTDB context initialisation
       via  1b57487 ctdb-daemon: Drop duplicate initialisation of request ID context
       via  4eea531 ctdb-daemon: Move ctdb_init() to the only place it is used
       via  f4fe768 ctdb-docs: Move remaining test options to README
       via  8a835ae ctdb-daemon: Drop ctdbd --torture and --valgrinding options
       via  32430f8 ctdb-scripts: Drop CTDB_VALGRIND testing option
       via  8c43ce7 ctdb-daemon: Drop ctdbd --sloppy-start and --nopublicipcheck options
       via  5081cec ctdb-tests: Make local daemon tests depend on CTDB_TEST_MODE
       via  3c7b766 ctdb-daemon: Add testing environment variable CTDB_TEST_MODE
       via  0349d65 ctdb-daemon: Drop ctdbd --notification-script command-line option
       via  e5af067 ctdb-scripts: Drop CTDB_NOTIFY_SCRIPT configuration option
       via  7e9dd3f ctdb-tests: Ensure notify.sh is available to local daemons
       via  ed80fc1 ctdb-daemon: Provide a default location for the notification script
       via  518be6d ctdb-daemon: Use a local variable instead of repeating getenv()
       via  7052f87 ctdb-daemon: Drop unused function ctdb_set_notification_script()
       via  17ad7d9 ctdb-daemon: Set ctdb->notification_script directly
       via  f5ee088 ctdb-docs: Move some configuration options out of the debug section
       via  cdd51df ctdb-docs: Move some ctdbd options out of the debug section
       via  b3dc0dc ctdb-build: Rename ctdb-client2 subsystem to ctdb-client
       via  e70fe41 ctdb-daemon: Move ctdb_client.c to server/ subdir
       via  45202d8 ctdb-build: Drop unnessary dependency on ctdb-client
       via  01c8dc7 ctdb-client: Remove ununsed functions from old client code
      from  aefe444 ceph: VFS: Add asynchronous fsync to ceph module, fake using synchronous call.

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit c6c67d9ed29d863d74ad98d1d344797ad2e1db54
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Apr 19 21:57:07 2018 +1000

    ctdb-scripts: Remove function rewrite_ctdb_options()
    
    This is no longer necessary after the removal of support for
    CTDB_DBDIR=tmpfs.
    
    File-local variable ctdb_rundir is no longer used, so drop it.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    
    Autobuild-User(master): Martin Schwenke <martins at samba.org>
    Autobuild-Date(master): Tue May  1 16:20:37 CEST 2018 on sn-devel-144

commit 043f3f266a988dadbf2992800c198af6c4bc0569
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Apr 19 21:54:11 2018 +1000

    ctdb-scripts: Drop support for CTDB_DBDIR=tmpfs
    
    CTDB has no business mounting filesystems.  Instead, documentation
    for the new configuration system will include a recommendation that a
    tmpfs be mounted on the volatile database directory.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit eb7ec16a963e13e903171227b655dbbf7f2a4051
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Apr 26 11:58:13 2018 +1000

    ctdb-daemon: Change default volatile database directory
    
    Volatile databases now have their own subdirectory.  This makes things
    easier if we later recommend mounting a tmpfs on the volatile database
    directory, rather than supporting the current CTDB_DBDIR=tmpfs magic.
    
    No need to create database directories for local daemon tests.  ctdbd
    will do that.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 8ea7fa57f4a82d7ebd6f8aa77fd8073b0196cb6e
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Apr 30 20:44:36 2018 +1000

    ctdb-tests: CTDB_DBDIR_PERSISTENT should not depend on CTDB_DBDIR
    
    Add new variable CTDB_DBDIR_BASE, just for event script unit tests.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 051203e1f80c1365e8f72fc3e819e6dda3aac4f2
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Apr 30 20:26:20 2018 +1000

    ctdb-scripts: Fix location of persistent databases
    
    If CTDB_DBDIR_PERSISTENT is not set then set the default relative to
    CTDB_VARDIR.  The persistent database directory is not (necessarily)
    relative to the volatile one.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit eba893f06c99c3585a5c4f8ada39000b7de31439
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Apr 30 20:24:40 2018 +1000

    ctdb-tests: Fix location of persistent databases
    
    Always use CTDB_DBDIR_PERSISTENT, which is setup by the test
    infrastructure.  The persistent database directory is
    not (necessarily) relative to the volatile one.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 3459a152f75ad0fc594d34a0486f2e998aed8cac
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Apr 16 19:08:20 2018 +1000

    ctdb-scripts: Drop UDP/file logging warning from ctdbd_wrapper
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 9a5ba6b9c939214f5f133a184817bd68f6b86279
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Apr 16 19:05:54 2018 +1000

    ctdb-daemon: Log the logging location when not logging via syslog()
    
    A variant of this is currently done by the wrapper but will be removed
    from there because the wrapper will no longer see the CTDB_LOGGING
    option.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 8821857cdfa775eee27f9bb5c7ea270c334880f8
Author: Martin Schwenke <martin at meltin.net>
Date:   Sat Apr 14 21:38:32 2018 +1000

    ctdb-scripts: Drop warning when there is no recovery lock
    
    After configuration changes ctdbd_wrapper will no longer see the
    CTDB_RECOVERY_LOCK option.  The daemon already logs a warning if the
    recovery lock is not set, so simply drop this extra warning.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 79c49f60a98dfc390b7ef6a4195833237532507d
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Apr 18 10:57:54 2018 +1000

    ctdb-daemon: Reorder main() to improve the structure
    
    Move code into clearly defined sections.  Add a fail label for fatal
    errors to ensure memory is freed.  Modernise debug messages.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 9623c920ab142a3d6dafaaad4086edab9eae63f5
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Apr 18 14:44:01 2018 +1000

    ctdb-daemon: Consolidate basic CTDB context initialisation
    
    None of this initialisation needs configuration options, so centralise
    it with the context initialisation.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 1b574876753a2a76acefeed0a0268dad2c9db293
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Apr 18 10:51:26 2018 +1000

    ctdb-daemon: Drop duplicate initialisation of request ID context
    
    This doesn't require configuration options so keep the instance in
    ctdb_init().
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 4eea531416ab0516f82bffa4f35345d8d0785d36
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Apr 18 10:36:05 2018 +1000

    ctdb-daemon: Move ctdb_init() to the only place it is used
    
    This used to be used by client code but not anymore, so move it to
    where it is used.  Drop the comment because it is wrong.  Modernise
    logging.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit f4fe768ca3518873b24e74ba4857c870fac1e46d
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Apr 5 16:12:31 2018 +1000

    ctdb-docs: Move remaining test options to README
    
    Test options do not belong in the user documentation.  Move them to
    the README file in the tests/ subdirectory.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 8a835ae175ddfb5c6b2644d576199043a145dd3d
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Apr 18 10:21:20 2018 +1000

    ctdb-daemon: Drop ctdbd --torture and --valgrinding options
    
    These haven't been used by anyone in a long time.  --valgrinding is
    less use with CTDB_VALGRINDING now gone.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 32430f84159a02f3f6cadd325bcac92b44e0c8dc
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Apr 30 16:01:57 2018 +1000

    ctdb-scripts: Drop CTDB_VALGRIND testing option
    
    This is too inflexible for general use.  There is no use finding a new
    home for this in the new configuration scheme.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 8c43ce74948e0b218e19f677670238490dd93d69
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Apr 5 16:25:14 2018 +1000

    ctdb-daemon: Drop ctdbd --sloppy-start and --nopublicipcheck options
    
    CTDB_LOCAL_DAEMON_MODE=yes is used instead.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 5081cec49e33031c117e8fa6c876e186fade0904
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Apr 5 15:46:53 2018 +1000

    ctdb-tests: Make local daemon tests depend on CTDB_TEST_MODE
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 3c7b766e5a2fc23149d7cb78ca1167e3ec1ca5a3
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Apr 5 15:37:42 2018 +1000

    ctdb-daemon: Add testing environment variable CTDB_TEST_MODE
    
    This is a generic indicator that tests are being run.
    
    For local daemons, this will replace --sloppy-start and
    --nopublicipcheck - it also does --nosetsched, which isn't being
    removed at this point.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 0349d658547918f1fa33043849a0865e745c6e37
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Mar 29 15:25:47 2018 +1100

    ctdb-daemon: Drop ctdbd --notification-script command-line option
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit e5af067866d503e1ea53472507290c905e71791f
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Mar 29 15:11:04 2018 +1100

    ctdb-scripts: Drop CTDB_NOTIFY_SCRIPT configuration option
    
    Notification scripts are installed into $CTDB_BASE/notify.d/ and are
    always run by notify.sh.  Leave notify.sh where it is for now but no
    longer consider it a configuration file.  This is an interim measure
    and will be changed again soon.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 7e9dd3fd3c30962c1e47fc5514cdd88c8cbc96b7
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Mar 30 20:46:41 2018 +1100

    ctdb-tests: Ensure notify.sh is available to local daemons
    
    Changes to notification configuration are coming, so ensure notify.sh
    is always "installed" for local daemons.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit ed80fc13444b317a8e783d82cf49e03e680ec1e8
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Mar 29 14:58:49 2018 +1100

    ctdb-daemon: Provide a default location for the notification script
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 518be6d5a26771040801f76db1279912128f3bc1
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Apr 26 20:32:30 2018 +1000

    ctdb-daemon: Use a local variable instead of repeating getenv()
    
    Makes the error handling easier and the code more compact.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 7052f87903fc5daaad2e155f345800ee897d19b2
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Mar 29 15:32:53 2018 +1100

    ctdb-daemon: Drop unused function ctdb_set_notification_script()
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 17ad7d9114bfc749350daa3988fe3223569ef945
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Mar 29 14:50:17 2018 +1100

    ctdb-daemon: Set ctdb->notification_script directly
    
    This doesn't need a wrapper function.  It gets in the way if building
    a value involves allocating memory (e.g. talloc_asprintf()) and then
    ctdb_set_notification_script() duplicates that memory.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit f5ee088420e592cdc9de30d1b38188ff27796ae4
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue May 1 14:05:32 2018 +1000

    ctdb-docs: Move some configuration options out of the debug section
    
    These aren't test options so improve their visibility.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit cdd51df35fcf606488764052a7b113dd802ff74b
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Apr 5 16:11:48 2018 +1000

    ctdb-docs: Move some ctdbd options out of the debug section
    
    ctdbd -i might be useful with systemd or similar, so should be
    documented.
    
    --nosetsched and --script-log-level options are valid user-level
    options.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit b3dc0dca47a424e22c0bbd13346d14b7a9f21402
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Mon Apr 30 19:38:47 2018 +1000

    ctdb-build: Rename ctdb-client2 subsystem to ctdb-client
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit e70fe41949fee46ee2907f0363697c60dfc113b7
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Mon Apr 30 19:36:43 2018 +1000

    ctdb-daemon: Move ctdb_client.c to server/ subdir
    
    It is used only by the code in the server directory.  It's mainly used
    in recovery daemon and vacuuming child process.
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit 45202d86c54960d8d39493def19c01c79746ef20
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Mon Apr 30 19:37:04 2018 +1000

    ctdb-build: Drop unnessary dependency on ctdb-client
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit 01c8dc7e15b8764a9b8c8e34b84d0cab790edf47
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Mon Apr 30 19:32:13 2018 +1000

    ctdb-client: Remove ununsed functions from old client code
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13411
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

-----------------------------------------------------------------------

Summary of changes:
 ctdb/client/ctdb_client.c                        | 4428 ----------------------
 ctdb/config/ctdbd_wrapper                        |   65 +-
 ctdb/config/debug_locks.sh                       |    2 +-
 ctdb/config/events.d/00.ctdb                     |    2 +-
 ctdb/config/functions                            |   26 -
 ctdb/config/notify.d.README                      |    6 -
 ctdb/config/notify.sh                            |    3 -
 ctdb/doc/ctdb.7.xml                              |   21 +-
 ctdb/doc/ctdbd.1.xml                             |  162 +-
 ctdb/doc/ctdbd.conf.5.xml                        |  307 +-
 ctdb/include/ctdb_client.h                       |  223 --
 ctdb/include/ctdb_private.h                      |    1 -
 ctdb/packaging/RPM/ctdb.spec.in                  |    5 +-
 ctdb/server/ctdb_client.c                        | 2082 ++++++++++
 ctdb/server/ctdb_monitor.c                       |   10 -
 ctdb/server/ctdbd.c                              |  317 +-
 ctdb/tests/README                                |   43 +
 ctdb/tests/eventscripts/00.ctdb.init.007.sh      |    2 +-
 ctdb/tests/eventscripts/00.ctdb.init.008.sh      |    2 +-
 ctdb/tests/eventscripts/05.system.monitor.001.sh |    2 +-
 ctdb/tests/eventscripts/scripts/local.sh         |    8 +-
 ctdb/tests/eventscripts/stubs/df                 |    9 +-
 ctdb/tests/run_tests.sh                          |    2 +
 ctdb/tests/simple/scripts/local_daemons.bash     |    8 +-
 ctdb/wscript                                     |   26 +-
 25 files changed, 2513 insertions(+), 5249 deletions(-)
 delete mode 100644 ctdb/client/ctdb_client.c
 create mode 100644 ctdb/server/ctdb_client.c


Changeset truncated at 500 lines:

diff --git a/ctdb/client/ctdb_client.c b/ctdb/client/ctdb_client.c
deleted file mode 100644
index a7624b7..0000000
--- a/ctdb/client/ctdb_client.c
+++ /dev/null
@@ -1,4428 +0,0 @@
-/* 
-   ctdb daemon code
-
-   Copyright (C) Andrew Tridgell  2007
-   Copyright (C) Ronnie Sahlberg  2007
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 3 of the License, or
-   (at your option) any later version.
-   
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-   
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "replace.h"
-#include "system/network.h"
-#include "system/filesys.h"
-#include "system/locale.h"
-
-#include <talloc.h>
-#include <tevent.h>
-#include <tdb.h>
-
-#include "lib/tdb_wrap/tdb_wrap.h"
-#include "lib/util/dlinklist.h"
-#include "lib/util/time.h"
-#include "lib/util/debug.h"
-#include "lib/util/samba_util.h"
-
-#include "ctdb_private.h"
-#include "ctdb_client.h"
-
-#include "common/reqid.h"
-#include "common/system.h"
-#include "common/common.h"
-#include "common/logging.h"
-
-/*
-  allocate a packet for use in client<->daemon communication
- */
-struct ctdb_req_header *_ctdbd_allocate_pkt(struct ctdb_context *ctdb,
-					    TALLOC_CTX *mem_ctx, 
-					    enum ctdb_operation operation, 
-					    size_t length, size_t slength,
-					    const char *type)
-{
-	int size;
-	struct ctdb_req_header *hdr;
-
-	length = MAX(length, slength);
-	size = (length+(CTDB_DS_ALIGNMENT-1)) & ~(CTDB_DS_ALIGNMENT-1);
-
-	hdr = (struct ctdb_req_header *)talloc_zero_size(mem_ctx, size);
-	if (hdr == NULL) {
-		DEBUG(DEBUG_ERR,("Unable to allocate packet for operation %u of length %u\n",
-			 operation, (unsigned)length));
-		return NULL;
-	}
-	talloc_set_name_const(hdr, type);
-	hdr->length       = length;
-	hdr->operation    = operation;
-	hdr->ctdb_magic   = CTDB_MAGIC;
-	hdr->ctdb_version = CTDB_PROTOCOL;
-	hdr->srcnode      = ctdb->pnn;
-	if (ctdb->vnn_map) {
-		hdr->generation = ctdb->vnn_map->generation;
-	}
-
-	return hdr;
-}
-
-/*
-  local version of ctdb_call
-*/
-int ctdb_call_local(struct ctdb_db_context *ctdb_db, struct ctdb_call *call,
-		    struct ctdb_ltdb_header *header, TALLOC_CTX *mem_ctx,
-		    TDB_DATA *data, bool updatetdb)
-{
-	struct ctdb_call_info *c;
-	struct ctdb_registered_call *fn;
-	struct ctdb_context *ctdb = ctdb_db->ctdb;
-	
-	c = talloc_zero(mem_ctx, struct ctdb_call_info);
-	CTDB_NO_MEMORY(ctdb, c);
-
-	c->key = call->key;
-	c->call_data = &call->call_data;
-	c->record_data.dptr = talloc_memdup(c, data->dptr, data->dsize);
-	c->record_data.dsize = data->dsize;
-	CTDB_NO_MEMORY(ctdb, c->record_data.dptr);
-	c->header = header;
-
-	for (fn=ctdb_db->calls;fn;fn=fn->next) {
-		if (fn->id == call->call_id) break;
-	}
-	if (fn == NULL) {
-		ctdb_set_error(ctdb, "Unknown call id %u\n", call->call_id);
-		talloc_free(c);
-		return -1;
-	}
-
-	if (fn->fn(c) != 0) {
-		ctdb_set_error(ctdb, "ctdb_call %u failed\n", call->call_id);
-		talloc_free(c);
-		return -1;
-	}
-
-	/* we need to force the record to be written out if this was a remote access */
-	if (c->new_data == NULL) {
-		c->new_data = &c->record_data;
-	}
-
-	if (c->new_data && updatetdb) {
-		/* XXX check that we always have the lock here? */
-		if (ctdb_ltdb_store(ctdb_db, call->key, header, *c->new_data) != 0) {
-			ctdb_set_error(ctdb, "ctdb_call tdb_store failed\n");
-			talloc_free(c);
-			return -1;
-		}
-	}
-
-	if (c->reply_data) {
-		call->reply_data = *c->reply_data;
-
-		talloc_steal(call, call->reply_data.dptr);
-		talloc_set_name_const(call->reply_data.dptr, __location__);
-	} else {
-		call->reply_data.dptr = NULL;
-		call->reply_data.dsize = 0;
-	}
-	call->status = c->status;
-
-	talloc_free(c);
-
-	return 0;
-}
-
-
-/*
-  queue a packet for sending from client to daemon
-*/
-static int ctdb_client_queue_pkt(struct ctdb_context *ctdb, struct ctdb_req_header *hdr)
-{
-	return ctdb_queue_send(ctdb->daemon.queue, (uint8_t *)hdr, hdr->length);
-}
-
-
-/*
-  called when a CTDB_REPLY_CALL packet comes in in the client
-
-  This packet comes in response to a CTDB_REQ_CALL request packet. It
-  contains any reply data from the call
-*/
-static void ctdb_client_reply_call(struct ctdb_context *ctdb, struct ctdb_req_header *hdr)
-{
-	struct ctdb_reply_call_old *c = (struct ctdb_reply_call_old *)hdr;
-	struct ctdb_client_call_state *state;
-
-	state = reqid_find(ctdb->idr, hdr->reqid, struct ctdb_client_call_state);
-	if (state == NULL) {
-		DEBUG(DEBUG_ERR,(__location__ " reqid %u not found\n", hdr->reqid));
-		return;
-	}
-
-	if (hdr->reqid != state->reqid) {
-		/* we found a record  but it was the wrong one */
-		DEBUG(DEBUG_ERR, ("Dropped client call reply with reqid:%u\n",hdr->reqid));
-		return;
-	}
-
-	state->call->reply_data.dptr = c->data;
-	state->call->reply_data.dsize = c->datalen;
-	state->call->status = c->status;
-
-	talloc_steal(state, c);
-
-	state->state = CTDB_CALL_DONE;
-
-	if (state->async.fn) {
-		state->async.fn(state);
-	}
-}
-
-void ctdb_request_message(struct ctdb_context *ctdb,
-			  struct ctdb_req_header *hdr)
-{
-	struct ctdb_req_message_old *c = (struct ctdb_req_message_old *)hdr;
-	TDB_DATA data;
-
-	data.dsize = c->datalen;
-	data.dptr = talloc_memdup(c, &c->data[0], c->datalen);
-	if (data.dptr == NULL) {
-		DEBUG(DEBUG_ERR, (__location__ " Memory allocation failure\n"));
-		return;
-	}
-
-	srvid_dispatch(ctdb->srv, c->srvid, CTDB_SRVID_ALL, data);
-}
-
-static void ctdb_client_reply_control(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
-
-/*
-  this is called in the client, when data comes in from the daemon
- */
-void ctdb_client_read_cb(uint8_t *data, size_t cnt, void *args)
-{
-	struct ctdb_context *ctdb = talloc_get_type(args, struct ctdb_context);
-	struct ctdb_req_header *hdr = (struct ctdb_req_header *)data;
-	TALLOC_CTX *tmp_ctx;
-
-	/* place the packet as a child of a tmp_ctx. We then use
-	   talloc_free() below to free it. If any of the calls want
-	   to keep it, then they will steal it somewhere else, and the
-	   talloc_free() will be a no-op */
-	tmp_ctx = talloc_new(ctdb);
-	talloc_steal(tmp_ctx, hdr);
-
-	if (cnt == 0) {
-		DEBUG(DEBUG_CRIT,("Daemon has exited - shutting down client\n"));
-		exit(1);
-	}
-
-	if (cnt < sizeof(*hdr)) {
-		DEBUG(DEBUG_CRIT,("Bad packet length %u in client\n", (unsigned)cnt));
-		goto done;
-	}
-	if (cnt != hdr->length) {
-		ctdb_set_error(ctdb, "Bad header length %u expected %u in client\n", 
-			       (unsigned)hdr->length, (unsigned)cnt);
-		goto done;
-	}
-
-	if (hdr->ctdb_magic != CTDB_MAGIC) {
-		ctdb_set_error(ctdb, "Non CTDB packet rejected in client\n");
-		goto done;
-	}
-
-	if (hdr->ctdb_version != CTDB_PROTOCOL) {
-		ctdb_set_error(ctdb, "Bad CTDB version 0x%x rejected in client\n", hdr->ctdb_version);
-		goto done;
-	}
-
-	switch (hdr->operation) {
-	case CTDB_REPLY_CALL:
-		ctdb_client_reply_call(ctdb, hdr);
-		break;
-
-	case CTDB_REQ_MESSAGE:
-		ctdb_request_message(ctdb, hdr);
-		break;
-
-	case CTDB_REPLY_CONTROL:
-		ctdb_client_reply_control(ctdb, hdr);
-		break;
-
-	default:
-		DEBUG(DEBUG_CRIT,("bogus operation code:%u\n",hdr->operation));
-	}
-
-done:
-	talloc_free(tmp_ctx);
-}
-
-/*
-  connect to a unix domain socket
-*/
-int ctdb_socket_connect(struct ctdb_context *ctdb)
-{
-	struct sockaddr_un addr;
-	int ret;
-
-	memset(&addr, 0, sizeof(addr));
-	addr.sun_family = AF_UNIX;
-	strncpy(addr.sun_path, ctdb->daemon.name, sizeof(addr.sun_path)-1);
-
-	ctdb->daemon.sd = socket(AF_UNIX, SOCK_STREAM, 0);
-	if (ctdb->daemon.sd == -1) {
-		DEBUG(DEBUG_ERR,(__location__ " Failed to open client socket. Errno:%s(%d)\n", strerror(errno), errno));
-		return -1;
-	}
-
-	if (connect(ctdb->daemon.sd, (struct sockaddr *)&addr, sizeof(addr)) == -1) {
-		DEBUG(DEBUG_ERR,
-		      (__location__
-		       "Failed to connect client socket to daemon (%s)\n",
-		       strerror(errno)));
-		close(ctdb->daemon.sd);
-		ctdb->daemon.sd = -1;
-		return -1;
-	}
-
-	ret = set_blocking(ctdb->daemon.sd, false);
-	if (ret != 0) {
-		DEBUG(DEBUG_ERR,
-		      (__location__
-		       " failed to set socket non-blocking (%s)\n",
-		       strerror(errno)));
-		close(ctdb->daemon.sd);
-		ctdb->daemon.sd = -1;
-		return -1;
-	}
-
-	set_close_on_exec(ctdb->daemon.sd);
-
-	ctdb->daemon.queue = ctdb_queue_setup(ctdb, ctdb, ctdb->daemon.sd, 
-					      CTDB_DS_ALIGNMENT, 
-					      ctdb_client_read_cb, ctdb, "to-ctdbd");
-	return 0;
-}
-
-
-struct ctdb_record_handle {
-	struct ctdb_db_context *ctdb_db;
-	TDB_DATA key;
-	TDB_DATA *data;
-	struct ctdb_ltdb_header header;
-};
-
-
-/*
-  make a recv call to the local ctdb daemon - called from client context
-
-  This is called when the program wants to wait for a ctdb_call to complete and get the 
-  results. This call will block unless the call has already completed.
-*/
-int ctdb_call_recv(struct ctdb_client_call_state *state, struct ctdb_call *call)
-{
-	if (state == NULL) {
-		return -1;
-	}
-
-	while (state->state < CTDB_CALL_DONE) {
-		tevent_loop_once(state->ctdb_db->ctdb->ev);
-	}
-	if (state->state != CTDB_CALL_DONE) {
-		DEBUG(DEBUG_ERR,(__location__ " ctdb_call_recv failed\n"));
-		talloc_free(state);
-		return -1;
-	}
-
-	if (state->call->reply_data.dsize) {
-		call->reply_data.dptr = talloc_memdup(state->ctdb_db,
-						      state->call->reply_data.dptr,
-						      state->call->reply_data.dsize);
-		call->reply_data.dsize = state->call->reply_data.dsize;
-	} else {
-		call->reply_data.dptr = NULL;
-		call->reply_data.dsize = 0;
-	}
-	call->status = state->call->status;
-	talloc_free(state);
-
-	return call->status;
-}
-
-
-
-
-/*
-  destroy a ctdb_call in client
-*/
-static int ctdb_client_call_destructor(struct ctdb_client_call_state *state)	
-{
-	reqid_remove(state->ctdb_db->ctdb->idr, state->reqid);
-	return 0;
-}
-
-/*
-  construct an event driven local ctdb_call
-
-  this is used so that locally processed ctdb_call requests are processed
-  in an event driven manner
-*/
-static struct ctdb_client_call_state *ctdb_client_call_local_send(struct ctdb_db_context *ctdb_db, 
-								  struct ctdb_call *call,
-								  struct ctdb_ltdb_header *header,
-								  TDB_DATA *data)
-{
-	struct ctdb_client_call_state *state;
-	struct ctdb_context *ctdb = ctdb_db->ctdb;
-	int ret;
-
-	state = talloc_zero(ctdb_db, struct ctdb_client_call_state);
-	CTDB_NO_MEMORY_NULL(ctdb, state);
-	state->call = talloc_zero(state, struct ctdb_call);
-	CTDB_NO_MEMORY_NULL(ctdb, state->call);
-
-	talloc_steal(state, data->dptr);
-
-	state->state   = CTDB_CALL_DONE;
-	*(state->call) = *call;
-	state->ctdb_db = ctdb_db;
-
-	ret = ctdb_call_local(ctdb_db, state->call, header, state, data, true);
-	if (ret != 0) {
-		DEBUG(DEBUG_DEBUG,("ctdb_call_local() failed, ignoring return code %d\n", ret));
-	}
-
-	return state;
-}
-
-/*
-  make a ctdb call to the local daemon - async send. Called from client context.
-
-  This constructs a ctdb_call request and queues it for processing. 
-  This call never blocks.
-*/
-struct ctdb_client_call_state *ctdb_call_send(struct ctdb_db_context *ctdb_db, 
-					      struct ctdb_call *call)
-{
-	struct ctdb_client_call_state *state;
-	struct ctdb_context *ctdb = ctdb_db->ctdb;
-	struct ctdb_ltdb_header header;
-	TDB_DATA data;
-	int ret;
-	size_t len;
-	struct ctdb_req_call_old *c;
-
-	/* if the domain socket is not yet open, open it */
-	if (ctdb->daemon.sd==-1) {
-		ctdb_socket_connect(ctdb);
-	}
-
-	ret = ctdb_ltdb_lock(ctdb_db, call->key);
-	if (ret != 0) {
-		DEBUG(DEBUG_ERR,(__location__ " Failed to get chainlock\n"));
-		return NULL;
-	}
-
-	ret = ctdb_ltdb_fetch(ctdb_db, call->key, &header, ctdb_db, &data);
-
-	if ((call->flags & CTDB_IMMEDIATE_MIGRATION) && (header.flags & CTDB_REC_RO_HAVE_DELEGATIONS)) {
-		ret = -1;
-	}
-
-	if (ret == 0 && header.dmaster == ctdb->pnn) {
-		state = ctdb_client_call_local_send(ctdb_db, call, &header, &data);
-		talloc_free(data.dptr);
-		ctdb_ltdb_unlock(ctdb_db, call->key);
-		return state;
-	}
-
-	ctdb_ltdb_unlock(ctdb_db, call->key);
-	talloc_free(data.dptr);
-
-	state = talloc_zero(ctdb_db, struct ctdb_client_call_state);
-	if (state == NULL) {
-		DEBUG(DEBUG_ERR, (__location__ " failed to allocate state\n"));
-		return NULL;
-	}
-	state->call = talloc_zero(state, struct ctdb_call);
-	if (state->call == NULL) {
-		DEBUG(DEBUG_ERR, (__location__ " failed to allocate state->call\n"));
-		return NULL;
-	}
-
-	len = offsetof(struct ctdb_req_call_old, data) + call->key.dsize + call->call_data.dsize;
-	c = ctdbd_allocate_pkt(ctdb, state, CTDB_REQ_CALL, len, struct ctdb_req_call_old);
-	if (c == NULL) {
-		DEBUG(DEBUG_ERR, (__location__ " failed to allocate packet\n"));
-		return NULL;
-	}
-
-	state->reqid     = reqid_new(ctdb->idr, state);
-	state->ctdb_db = ctdb_db;
-	talloc_set_destructor(state, ctdb_client_call_destructor);
-
-	c->hdr.reqid     = state->reqid;
-	c->flags         = call->flags;
-	c->db_id         = ctdb_db->db_id;
-	c->callid        = call->call_id;
-	c->hopcount      = 0;
-	c->keylen        = call->key.dsize;
-	c->calldatalen   = call->call_data.dsize;
-	memcpy(&c->data[0], call->key.dptr, call->key.dsize);
-	memcpy(&c->data[call->key.dsize], 
-	       call->call_data.dptr, call->call_data.dsize);
-	*(state->call)              = *call;
-	state->call->call_data.dptr = &c->data[call->key.dsize];
-	state->call->key.dptr       = &c->data[0];
-
-	state->state  = CTDB_CALL_WAIT;
-
-
-	ctdb_client_queue_pkt(ctdb, &c->hdr);
-
-	return state;
-}


-- 
Samba Shared Repository



More information about the samba-cvs mailing list