The branch, v4-5-stable has been updated
       via  31052eb VERSION: Disable GIT_SNAPSHOTS for the 4.5.11 release.
       via  68ad60f WHATSNEW: Add release notes for Samba 4.5.11.
       via  4f6e1f1 ldb: protect Samba < 4.7 against incompatible ldb versions 
and require ldb < 1.2.0
       via  e4d7e60 wafsamba: add maxversion and version_blacklist to 
CHECK_BUNDLED_SYSTEM[_PKG]()
       via  96450f9 s3:gse_krb5: fix a possible crash in 
fill_mem_keytab_from_system_keytab()
       via  7d8f7fb s3:smb2_create: avoid reusing the 'tevent_req' within 
smbd_smb2_create_send()
       via  dc4a6a9 s3: libsmb: Correctly save and restore connection tcon in 
smbclient, smbcacls and smbtorture3.
       via  c939552 s3: libsmb: Correctly do lifecycle management on 
cli->smb1.tcon and cli->smb2.tcon.
       via  0d0d982 s3: libsmb: Fix cli_state_has_tcon() to cope with SMB2 
connections.
       via  cf68b64 s3: libsmb: Widen cli_state_get_tid() / cli_state_set_tid() 
to 32-bits.
       via  5d9c3b3 s3: smbtorture: Show correct use of cli_state_save_tcon() / 
cli_state_restore_tcon().
       via  5ec9fca s3: libsmb: Add cli_state_save_tcon() / 
cli_state_restore_tcon().
       via  43735d6 libcli: smb: Add smb2cli_tcon_set_id().
       via  85896c3 libcli: smb: Add smbXcli_tcon_copy().
       via  48a6971 auth/spnego: fix gensec_update_ev() argument order for the 
SPNEGO_FALLBACK case
       via  e260f4f s3:smbd: unimplement FSCTL_VALIDATE_NEGOTIATE_INFO with 
"server max protocol = SMB2_02"
       via  2544198 samba-tool: fix log message of 'samba-tool user 
syncpasswords'
       via  1329592 auth/ntlmssp: enforce NTLMSSP_NEGOTIATE_NTLM2 for the 
NTLMv2 client case
       via  ecdbe6e s3: smbd: fix regression with non-wide symlinks to 
directories over SMB3.
       via  bb6c6c6 s3: smbd: Add regression test for non-wide symlinks to 
directories fail over SMB3.
       via  f3e22f5 s3: smbd: When deleting an fsp pointer ensure we don't keep 
any references to it around.
       via  17543bd ctdb-recovery: Do not run local ip verification when in 
recovery
       via  fc7b70f ctdb-recovery: Get recmode unconditionally in the main_loop
       via  10a763d ctdb-recovery: Finish processing for recovery mode ACTIVE 
first
       via  40cc8d2 ctdb-recovery: Simplify logging of recovery mode setting
       via  da97cd2 ctdb-recovery: Setting up of recmode should be idempotent
       via  6c49f54 ctdb-recovery: Assign banning credits if database fails to 
freeze
       via  6627e19 ctdb-scripts: Don't send empty argument string to logger
       via  46ab108 Bug 15852. There are valid paths where 
conn->lsa_pipe_tcp->transport is NULL. Protect against this.
       via  16d4fd9 s3:smb2_sesssetup: allow a compound request after a 
SessionSetup
       via  48ab0c3 s3:smb2_tcon: allow a compound request after a TreeConnect
       via  5336447 libcli:smb2: Gracefully handle not supported for 
FSCTL_VALIDATE_NEGOTIATE_INFO
       via  e45a18f ctdb-tests: Add more NFS eventscript tests for call-out 
failures
       via  7e753fd ctdb-scripts: NFS call-out failures should cause event 
failure
       via  176bc89 s4/torture: test for bug 12798
       via  0e467e8 s3/smbd: fix exclusive lease optimisation
       via  9d6ac5b s3/locking: make find_share_mode_entry public
       via  be632f6 s3: VFS: Catia: Ensure path name is also converted.
       via  95e1df5 ctdb-tests: Add some extra tests for "ctdb nodestatus"
       via  29b9e19 ctdb-tools: "ctdb nodestatus" should only display header 
for "all"
       via  36f2b52 ctdb-tools: Stop "ctdb nodestatus" from always showing all 
nodes
       via  c8b18ab ctdb-readonly: Avoid a tight loop waiting for revoke to 
complete
       via  9dca467 Revert "ctdb-readonly: Avoid a tight loop waiting for 
revoke to complete"
       via  7922d48 VERSION: Bump version up to 4.5.11.
       via  15db83f Merge tag 'samba-4.5.10' into v4-5-test
       via  d6568b8 s3: smbd: Fix open_files.idl to correctly ignore 
share_mode_lease *lease in share_mode_entry.
       via  886edba VERSION: Bump version up to 4.5.10...
      from  558f8e6 VERSION: Disable GIT_SNAPSHOTS for the 4.5.10 release.

https://git.samba.org/?p=samba.git;a=shortlog;h=v4-5-stable


- Log -----------------------------------------------------------------
-----------------------------------------------------------------------

Summary of changes:
 VERSION                                            |  2 +-
 WHATSNEW.txt                                       | 94 +++++++++++++++++++++-
 auth/gensec/spnego.c                               |  6 +-
 auth/ntlmssp/ntlmssp_util.c                        | 21 +++++
 buildtools/wafsamba/samba_bundled.py               | 21 ++++-
 ctdb/config/events.d/60.nfs                        |  8 +-
 ctdb/config/functions                              |  2 +-
 ctdb/server/ctdb_call.c                            | 93 +++++++++++++--------
 ctdb/server/ctdb_recover.c                         | 31 +++----
 ctdb/server/ctdb_recoverd.c                        | 19 +++--
 ctdb/server/ctdb_recovery_helper.c                 |  1 +
 ....nfs.monitor.107.sh => 06.nfs.releaseip.001.sh} |  0
 ctdb/tests/eventscripts/06.nfs.releaseip.002.sh    | 12 +++
 ...{60.nfs.monitor.107.sh => 06.nfs.takeip.001.sh} |  0
 ctdb/tests/eventscripts/06.nfs.takeip.002.sh       | 12 +++
 ctdb/tests/eventscripts/60.nfs.monitor.109.sh      | 12 +++
 ....nfs.monitor.107.sh => 60.nfs.releaseip.001.sh} |  0
 ctdb/tests/eventscripts/60.nfs.releaseip.002.sh    | 12 +++
 ...0.nfs.monitor.107.sh => 60.nfs.shutdown.001.sh} |  0
 ctdb/tests/eventscripts/60.nfs.shutdown.002.sh     | 12 +++
 ...60.nfs.monitor.107.sh => 60.nfs.startup.001.sh} |  0
 ctdb/tests/eventscripts/60.nfs.startup.002.sh      | 12 +++
 ...{60.nfs.monitor.107.sh => 60.nfs.takeip.001.sh} |  0
 ctdb/tests/eventscripts/60.nfs.takeip.002.sh       | 12 +++
 ...db.nodestatus.001.sh => ctdb.nodestatus.003.sh} | 12 +--
 ...db.nodestatus.001.sh => ctdb.nodestatus.004.sh} | 13 +--
 ctdb/tests/tool/ctdb.nodestatus.005.sh             | 28 +++++++
 ctdb/tests/tool/ctdb.nodestatus.006.sh             | 40 +++++++++
 ctdb/tools/ctdb.c                                  | 29 ++++---
 lib/ldb/wscript                                    | 19 ++++-
 libcli/smb/smbXcli_base.c                          | 52 ++++++++++++
 libcli/smb/smbXcli_base.h                          |  3 +
 python/samba/netcmd/user.py                        |  2 +-
 selftest/target/Samba3.pm                          |  7 ++
 source3/client/client.c                            |  5 +-
 source3/lib/util_sd.c                              | 24 +++++-
 source3/librpc/crypto/gse_krb5.c                   |  8 ++
 source3/librpc/idl/open_files.idl                  |  2 +-
 source3/libsmb/cliconnect.c                        | 23 +++++-
 source3/libsmb/clidfs.c                            | 18 ++++-
 source3/libsmb/clientgen.c                         | 67 +++++++++++----
 source3/libsmb/proto.h                             |  7 +-
 source3/locking/locking.c                          |  2 +-
 source3/locking/proto.h                            |  2 +
 source3/locking/share_mode_lock.c                  |  4 +-
 source3/modules/vfs_catia.c                        | 41 ++++++++--
 source3/script/tests/test_smbclient_s3.sh          | 55 +++++++++++++
 source3/smbd/files.c                               |  4 +-
 source3/smbd/open.c                                | 24 +++++-
 source3/smbd/oplock.c                              | 30 ++++++-
 source3/smbd/smb2_create.c                         | 43 +++++-----
 source3/smbd/smb2_ioctl_network_fs.c               | 17 ++++
 source3/smbd/smb2_sesssetup.c                      |  1 +
 source3/smbd/smb2_tcon.c                           |  2 +
 source3/torture/test_smb2.c                        |  8 +-
 source3/torture/torture.c                          | 24 +++++-
 source3/utils/net_rpc.c                            | 12 ++-
 source3/utils/smbcacls.c                           | 12 ++-
 source3/winbindd/winbindd_cm.c                     |  8 +-
 source4/torture/smb2/lease.c                       | 82 +++++++++++++++++++
 60 files changed, 930 insertions(+), 182 deletions(-)
 copy ctdb/tests/eventscripts/{60.nfs.monitor.107.sh => 
06.nfs.releaseip.001.sh} (100%)
 create mode 100755 ctdb/tests/eventscripts/06.nfs.releaseip.002.sh
 copy ctdb/tests/eventscripts/{60.nfs.monitor.107.sh => 06.nfs.takeip.001.sh} 
(100%)
 create mode 100755 ctdb/tests/eventscripts/06.nfs.takeip.002.sh
 create mode 100755 ctdb/tests/eventscripts/60.nfs.monitor.109.sh
 copy ctdb/tests/eventscripts/{60.nfs.monitor.107.sh => 
60.nfs.releaseip.001.sh} (100%)
 create mode 100755 ctdb/tests/eventscripts/60.nfs.releaseip.002.sh
 copy ctdb/tests/eventscripts/{60.nfs.monitor.107.sh => 60.nfs.shutdown.001.sh} 
(100%)
 create mode 100755 ctdb/tests/eventscripts/60.nfs.shutdown.002.sh
 copy ctdb/tests/eventscripts/{60.nfs.monitor.107.sh => 60.nfs.startup.001.sh} 
(100%)
 create mode 100755 ctdb/tests/eventscripts/60.nfs.startup.002.sh
 copy ctdb/tests/eventscripts/{60.nfs.monitor.107.sh => 60.nfs.takeip.001.sh} 
(100%)
 create mode 100755 ctdb/tests/eventscripts/60.nfs.takeip.002.sh
 copy ctdb/tests/tool/{ctdb.nodestatus.001.sh => ctdb.nodestatus.003.sh} (73%)
 copy ctdb/tests/tool/{ctdb.nodestatus.001.sh => ctdb.nodestatus.004.sh} (64%)
 create mode 100755 ctdb/tests/tool/ctdb.nodestatus.005.sh
 create mode 100755 ctdb/tests/tool/ctdb.nodestatus.006.sh


Changeset truncated at 500 lines:

diff --git a/VERSION b/VERSION
index 9d55484..22871d4 100644
--- a/VERSION
+++ b/VERSION
@@ -25,7 +25,7 @@
 ########################################################
 SAMBA_VERSION_MAJOR=4
 SAMBA_VERSION_MINOR=5
-SAMBA_VERSION_RELEASE=10
+SAMBA_VERSION_RELEASE=11
 
 ########################################################
 # If a official release has a serious bug              #
diff --git a/WHATSNEW.txt b/WHATSNEW.txt
index fcc30ad..0c022e7 100644
--- a/WHATSNEW.txt
+++ b/WHATSNEW.txt
@@ -1,4 +1,94 @@
                    ==============================
+                   Release Notes for Samba 4.5.11
+                            July 6, 2017
+                   ==============================
+
+
+This is the latest stable release of the Samba 4.5 release series.
+
+
+Changes since 4.5.10:
+---------------------
+
+o  Jeremy Allison <j...@samba.org>
+   * BUG 12793: s3: smbd: Fix open_files.idl to correctly ignore
+     share_mode_lease *lease in share_mode_entry.
+   * BUG 12804: s3: VFS: Catia: Ensure path name is also converted.
+   * BUG 12818: s3: smbd: When deleting an fsp pointer ensure we don't keep
+     any references to it around.
+   * BUG 12831: s3: libsmb: Correctly save and restore connection tcon
+     in 'smbclient', 'smbcacls' and 'smbtorture3'.
+
+o  Ralph Boehme <s...@samba.org>
+   * BUG 12798: s3/smbd: Fix exclusive lease optimisation.
+
+o  Amitay Isaacs <ami...@gmail.com>
+   * BUG 12856: ctdb-scripts: Don't send empty argument string to logger.
+   * BUG 12857: ctdb-recovery: Do not run local ip verification when in
+     recovery.
+
+o  Daniel Kobras <d.kob...@science-computing.de>
+   * BUG 12860: s3: smbd: Fix regression with non-wide symlinks to directories
+     over SMB3.
+
+o  Stefan Metzmacher <me...@samba.org>
+   * BUG 12768: samba-tool: Fix log message of 'samba-tool user syncpasswords'.
+   * BUG 12772: s3:smbd: unimplement FSCTL_VALIDATE_NEGOTIATE_INFO with
+     "server max protocol = SMB2_02".
+   * BUG 12788: auth/spnego: Fix gensec_update_ev() argument order for
+     the SPNEGO_FALLBACK case.
+   * BUG 12832: s3:smb2_create: Avoid reusing the 'tevent_req' within
+     smbd_smb2_create_send().
+   * BUG 12844: Related requests with TreeConnect fail with
+     NETWORK_NAME_DELETED.
+   * BUG 12845: Related requests with SessionSetup fail with INTERNAL_ERROR.
+   * BUG 12859: ldb: protect Samba < 4.7 against incompatible ldb
+     versions and require ldb < 1.2.0.
+   * BUG 12862: auth/ntlmssp: Enforce NTLMSSP_NEGOTIATE_NTLM2 for the NTLMv2
+     client case.
+
+o  Michael Saxl <m...@mwsys.mine.bz>
+   * BUG 10490: s3:gse_krb5: Fix a possible crash in
+     fill_mem_keytab_from_system_keytab().
+
+o  Andreas Schneider <a...@samba.org>
+   * BUG 12808: libcli:smb2: Gracefully handle not supported for
+     FSCTL_VALIDATE_NEGOTIATE_INFO.
+
+o  Martin Schwenke <mar...@meltin.net>
+   * BUG 12802: 'ctdb nodestatus' incorrectly displays status for all nodes
+     with wrong exit code.
+   * BUG 12837: ctdb-scripts: NFS call-out failures should cause event failure.
+
+o  Richard Sharpe <richard.sha...@primarydata.com>
+   * BUG 15852: There are valid paths where conn->lsa_pipe_tcp->transport
+     is NULL.
+
+
+#######################################
+Reporting bugs & Development Discussion
+#######################################
+
+Please discuss this release on the samba-technical mailing list or by
+joining the #samba-technical IRC channel on irc.freenode.net.
+
+If you do report problems then please try to send high quality
+feedback. If you don't provide vital information to help us track down
+the problem then you will probably be ignored.  All bug reports should
+be filed under the Samba 4.1 and newer product in the project's Bugzilla
+database (https://bugzilla.samba.org/).
+
+
+======================================================================
+== Our Code, Our Bugs, Our Responsibility.
+== The Samba Team
+======================================================================
+
+
+Release notes for older releases follow:
+----------------------------------------
+
+                   ==============================
                    Release Notes for Samba 4.5.10
                             May 24, 2017
                    ==============================
@@ -47,8 +137,8 @@ database (https://bugzilla.samba.org/).
 ======================================================================
 
 
-Release notes for older releases follow:
-----------------------------------------
+----------------------------------------------------------------------
+
 
                    =============================
                    Release Notes for Samba 4.5.9
diff --git a/auth/gensec/spnego.c b/auth/gensec/spnego.c
index 5f5047a..962e1fc 100644
--- a/auth/gensec/spnego.c
+++ b/auth/gensec/spnego.c
@@ -366,7 +366,7 @@ static NTSTATUS gensec_spnego_server_try_fallback(struct 
gensec_security *gensec
                        return nt_status;
                }
                nt_status = gensec_update_ev(spnego_state->sub_sec_security,
-                                         ev, out_mem_ctx, in, out);
+                                            out_mem_ctx, ev, in, out);
                return nt_status;
        }
        DEBUG(1, ("Failed to parse SPNEGO request\n"));
@@ -756,8 +756,8 @@ static NTSTATUS gensec_spnego_update(struct gensec_security 
*gensec_security, TA
 
        switch (spnego_state->state_position) {
        case SPNEGO_FALLBACK:
-               return gensec_update_ev(spnego_state->sub_sec_security, ev,
-                                    out_mem_ctx, in, out);
+               return gensec_update_ev(spnego_state->sub_sec_security,
+                                       out_mem_ctx, ev, in, out);
        case SPNEGO_SERVER_START:
        {
                NTSTATUS nt_status;
diff --git a/auth/ntlmssp/ntlmssp_util.c b/auth/ntlmssp/ntlmssp_util.c
index 4ae6101..9c7325a 100644
--- a/auth/ntlmssp/ntlmssp_util.c
+++ b/auth/ntlmssp/ntlmssp_util.c
@@ -75,6 +75,27 @@ NTSTATUS ntlmssp_handle_neg_flags(struct ntlmssp_state 
*ntlmssp_state,
 {
        uint32_t missing_flags = ntlmssp_state->required_flags;
 
+       if (ntlmssp_state->use_ntlmv2) {
+               /*
+                * Using NTLMv2 as a client implies
+                * using NTLMSSP_NEGOTIATE_NTLM2
+                * (NTLMSSP_NEGOTIATE_EXTENDED_SESSIONSECURITY)
+                *
+                * Note that 'use_ntlmv2' is only set
+                * true in the client case.
+                *
+                * Even if the server has a bug and does not announce
+                * it, we need to assume it's present.
+                *
+                * Note that we also have the flag
+                * in ntlmssp_state->required_flags,
+                * see gensec_ntlmssp_client_start().
+                *
+                * See bug #12862.
+                */
+               flags |= NTLMSSP_NEGOTIATE_NTLM2;
+       }
+
        if (flags & NTLMSSP_NEGOTIATE_UNICODE) {
                ntlmssp_state->neg_flags |= NTLMSSP_NEGOTIATE_UNICODE;
                ntlmssp_state->neg_flags &= ~NTLMSSP_NEGOTIATE_OEM;
diff --git a/buildtools/wafsamba/samba_bundled.py 
b/buildtools/wafsamba/samba_bundled.py
index ea88807..aa6199e 100644
--- a/buildtools/wafsamba/samba_bundled.py
+++ b/buildtools/wafsamba/samba_bundled.py
@@ -110,6 +110,7 @@ def LIB_MUST_BE_PRIVATE(conf, libname):
 
 @conf
 def CHECK_BUNDLED_SYSTEM_PKG(conf, libname, minversion='0.0.0',
+        maxversion=None, version_blacklist=[],
         onlyif=None, implied_deps=None, pkg=None):
     '''check if a library is available as a system library.
 
@@ -117,12 +118,15 @@ def CHECK_BUNDLED_SYSTEM_PKG(conf, libname, 
minversion='0.0.0',
     '''
     return conf.CHECK_BUNDLED_SYSTEM(libname,
                                      minversion=minversion,
+                                     maxversion=maxversion,
+                                     version_blacklist=version_blacklist,
                                      onlyif=onlyif,
                                      implied_deps=implied_deps,
                                      pkg=pkg)
 
 @conf
 def CHECK_BUNDLED_SYSTEM(conf, libname, minversion='0.0.0',
+                         maxversion=None, version_blacklist=[],
                          checkfunctions=None, headers=None, checkcode=None,
                          onlyif=None, implied_deps=None,
                          require_headers=True, pkg=None, set_target=True):
@@ -181,16 +185,29 @@ def CHECK_BUNDLED_SYSTEM(conf, libname, 
minversion='0.0.0',
     minversion = minimum_library_version(conf, libname, minversion)
 
     msg = 'Checking for system %s' % libname
+    msg_ver = []
     if minversion != '0.0.0':
-        msg += ' >= %s' % minversion
+        msg_ver.append('>=%s' % minversion)
+    if maxversion is not None:
+        msg_ver.append('<=%s' % maxversion)
+    for v in version_blacklist:
+        msg_ver.append('!=%s' % v)
+    if msg_ver != []:
+        msg += " (%s)" % (" ".join(msg_ver))
 
     uselib_store=libname.upper()
     if pkg is None:
         pkg = libname
 
+    version_checks = '%s >= %s' % (pkg, minversion)
+    if maxversion is not None:
+        version_checks += ' %s <= %s' % (pkg, maxversion)
+    for v in version_blacklist:
+        version_checks += ' %s != %s' % (pkg, v)
+
     # try pkgconfig first
     if (conf.CHECK_CFG(package=pkg,
-                      args='"%s >= %s" --cflags --libs' % (pkg, minversion),
+                      args='"%s" --cflags --libs' % (version_checks),
                       msg=msg, uselib_store=uselib_store) and
         check_functions_headers_code()):
         if set_target:
diff --git a/ctdb/config/events.d/60.nfs b/ctdb/config/events.d/60.nfs
index 15948f5..9198413 100755
--- a/ctdb/config/events.d/60.nfs
+++ b/ctdb/config/events.d/60.nfs
@@ -258,20 +258,20 @@ ctdb_service_check_reconfigure
 
 case "$1" in
 startup)
-       nfs_callout "$@"
+       nfs_callout "$@" || exit $?
        ;;
 
 shutdown)
-        nfs_callout "$@"
+       nfs_callout "$@" || exit $?
        ;;
 
 takeip)
-       nfs_callout "$@"
+       nfs_callout "$@" || exit $?
        ctdb_service_set_reconfigure
        ;;
 
 releaseip)
-       nfs_callout "$@"
+       nfs_callout "$@" || exit $?
        ctdb_service_set_reconfigure
        ;;
 
diff --git a/ctdb/config/functions b/ctdb/config/functions
index a29daf5..885289a 100755
--- a/ctdb/config/functions
+++ b/ctdb/config/functions
@@ -150,7 +150,7 @@ script_log ()
        *)
            # Handle all syslog:* variants here too.  There's no tool to do
            # the lossy things, so just use logger.
-           logger -t "ctdbd: ${_tag}" "$*"
+           logger -t "ctdbd: ${_tag}" "$@"
            ;;
     esac
 }
diff --git a/ctdb/server/ctdb_call.c b/ctdb/server/ctdb_call.c
index f9c2922..93642cd 100644
--- a/ctdb/server/ctdb_call.c
+++ b/ctdb/server/ctdb_call.c
@@ -1561,6 +1561,7 @@ void ctdb_send_keepalive(struct ctdb_context *ctdb, 
uint32_t destnode)
 
 
 struct revokechild_deferred_call {
+       struct revokechild_deferred_call *prev, *next;
        struct ctdb_context *ctdb;
        struct ctdb_req_header *hdr;
        deferred_requeue_fn fn;
@@ -1576,50 +1577,31 @@ struct revokechild_handle {
        int fd[2];
        pid_t child;
        TDB_DATA key;
-};
-
-struct revokechild_requeue_handle {
-       struct ctdb_context *ctdb;
-       struct ctdb_req_header *hdr;
-       deferred_requeue_fn fn;
-       void *ctx;
+       struct revokechild_deferred_call *deferred_call_list;
 };
 
 static void deferred_call_requeue(struct tevent_context *ev,
                                  struct tevent_timer *te,
                                  struct timeval t, void *private_data)
 {
-       struct revokechild_requeue_handle *requeue_handle = 
talloc_get_type(private_data, struct revokechild_requeue_handle);
-
-       requeue_handle->fn(requeue_handle->ctx, requeue_handle->hdr);
-       talloc_free(requeue_handle);
-}
+       struct revokechild_deferred_call *dlist = talloc_get_type_abort(
+               private_data, struct revokechild_deferred_call);
 
-static int deferred_call_destructor(struct revokechild_deferred_call 
*deferred_call)
-{
-       struct ctdb_context *ctdb = deferred_call->ctdb;
-       struct revokechild_requeue_handle *requeue_handle = talloc(ctdb, struct 
revokechild_requeue_handle);
-
-       requeue_handle->ctdb = ctdb;
-       requeue_handle->hdr  = deferred_call->hdr;
-       requeue_handle->fn   = deferred_call->fn;
-       requeue_handle->ctx  = deferred_call->ctx;
-       talloc_steal(requeue_handle, requeue_handle->hdr);
-
-       /* Always delay revoke requests.  Either wait for the read/write
-        * operation to complete, or if revoking failed wait for recovery to
-        * complete
-        */
-       tevent_add_timer(ctdb->ev, requeue_handle,
-                        timeval_current_ofs(1, 0),
-                        deferred_call_requeue, requeue_handle);
+       while (dlist != NULL) {
+               struct revokechild_deferred_call *dcall = dlist;
 
-       return 0;
+               DLIST_REMOVE(dlist, dcall);
+               dcall->fn(dcall->ctx, dcall->hdr);
+               talloc_free(dcall);
+       }
 }
 
 
 static int revokechild_destructor(struct revokechild_handle *rc)
 {
+       struct revokechild_deferred_call *now_list = NULL;
+       struct revokechild_deferred_call *delay_list = NULL;
+
        if (rc->fde != NULL) {
                talloc_free(rc->fde);
        }
@@ -1633,6 +1615,48 @@ static int revokechild_destructor(struct 
revokechild_handle *rc)
        ctdb_kill(rc->ctdb, rc->child, SIGKILL);
 
        DLIST_REMOVE(rc->ctdb_db->revokechild_active, rc);
+
+       while (rc->deferred_call_list != NULL) {
+               struct revokechild_deferred_call *dcall;
+
+               dcall = rc->deferred_call_list;
+               DLIST_REMOVE(rc->deferred_call_list, dcall);
+
+               /* If revoke is successful, then first process all the calls
+                * that need write access, and delay readonly requests by 1
+                * second grace.
+                *
+                * If revoke is unsuccessful, most likely because of node
+                * failure, delay all the pending requests, so database can
+                * be recovered.
+                */
+
+               if (rc->status == 0) {
+                       struct ctdb_req_call_old *c;
+
+                       c = (struct ctdb_req_call_old *)dcall->hdr;
+                       if (c->flags & CTDB_WANT_READONLY) {
+                               DLIST_ADD(delay_list, dcall);
+                       } else {
+                               DLIST_ADD(now_list, dcall);
+                       }
+               } else {
+                       DLIST_ADD(delay_list, dcall);
+               }
+       }
+
+       if (now_list != NULL) {
+               tevent_add_timer(rc->ctdb->ev, rc->ctdb_db,
+                                tevent_timeval_current_ofs(0, 0),
+                                deferred_call_requeue, now_list);
+       }
+
+       if (delay_list != NULL) {
+               tevent_add_timer(rc->ctdb->ev, rc->ctdb_db,
+                                tevent_timeval_current_ofs(1, 0),
+                                deferred_call_requeue, delay_list);
+       }
+
        return 0;
 }
 
@@ -1911,19 +1935,18 @@ int ctdb_add_revoke_deferred_call(struct ctdb_context 
*ctdb, struct ctdb_db_cont
                return -1;
        }
 
-       deferred_call = talloc(rc, struct revokechild_deferred_call);
+       deferred_call = talloc(ctdb_db, struct revokechild_deferred_call);
        if (deferred_call == NULL) {
                DEBUG(DEBUG_ERR,("Failed to allocate deferred call structure 
for revoking record\n"));
                return -1;
        }
 
        deferred_call->ctdb = ctdb;
-       deferred_call->hdr  = hdr;
+       deferred_call->hdr  = talloc_steal(deferred_call, hdr);
        deferred_call->fn   = fn;
        deferred_call->ctx  = call_context;
 
-       talloc_set_destructor(deferred_call, deferred_call_destructor);
-       talloc_steal(deferred_call, hdr);
+       DLIST_ADD(rc->deferred_call_list, deferred_call);
 
        return 0;
 }
diff --git a/ctdb/server/ctdb_recover.c b/ctdb/server/ctdb_recover.c
index 6bed61c..ea8a0b3 100644
--- a/ctdb/server/ctdb_recover.c
+++ b/ctdb/server/ctdb_recover.c
@@ -856,26 +856,27 @@ int32_t ctdb_control_set_recmode(struct ctdb_context 
*ctdb,
        struct set_recmode_state *state;
        struct ctdb_cluster_mutex_handle *h;
 
+       if (recmode == ctdb->recovery_mode) {
+               DEBUG(DEBUG_INFO,
+                     ("Recovery mode already set to %s\n",
+                      recmode == CTDB_RECOVERY_NORMAL ? "NORMAL" : "ACTIVE"));
+               return 0;
+       }
+
+       DEBUG(DEBUG_NOTICE,
+             ("Recovery mode set to %s\n",
+              recmode == CTDB_RECOVERY_NORMAL ? "NORMAL" : "ACTIVE"));
+
        /* if we enter recovery but stay in recovery for too long
           we will eventually drop all our ip addresses
        */
-       if (recmode == CTDB_RECOVERY_NORMAL) {
-               talloc_free(ctdb->release_ips_ctx);
-               ctdb->release_ips_ctx = NULL;
-       } else {
+       if (recmode == CTDB_RECOVERY_ACTIVE) {
                if (ctdb_deferred_drop_all_ips(ctdb) != 0) {
-                       DEBUG(DEBUG_ERR,("Failed to set up deferred drop all 
ips\n"));
+                       DEBUG(DEBUG_ERR,
+                             ("Failed to set up deferred drop all ips\n"));
                }
-       }
 
-       if (recmode != ctdb->recovery_mode) {
-               DEBUG(DEBUG_NOTICE,(__location__ " Recovery mode set to %s\n", 
-                        recmode==CTDB_RECOVERY_NORMAL?"NORMAL":"ACTIVE"));
-       }
-
-       if (recmode != CTDB_RECOVERY_NORMAL ||
-           ctdb->recovery_mode != CTDB_RECOVERY_ACTIVE) {
-               ctdb->recovery_mode = recmode;
+               ctdb->recovery_mode = CTDB_RECOVERY_ACTIVE;
                return 0;
        }
 
@@ -884,6 +885,8 @@ int32_t ctdb_control_set_recmode(struct ctdb_context *ctdb,
         * Therefore, what follows is special handling when setting
         * recovery mode back to normal */
 
+       TALLOC_FREE(ctdb->release_ips_ctx);
+
        for (ctdb_db = ctdb->db_list; ctdb_db != NULL; ctdb_db = ctdb_db->next) 
{
                if (ctdb_db->generation != ctdb->vnn_map->generation) {
                        DEBUG(DEBUG_ERR,
diff --git a/ctdb/server/ctdb_recoverd.c b/ctdb/server/ctdb_recoverd.c
index d233817..f947ee0 100644
--- a/ctdb/server/ctdb_recoverd.c
+++ b/ctdb/server/ctdb_recoverd.c
@@ -2596,6 +2596,13 @@ static void main_loop(struct ctdb_context *ctdb, struct 
ctdb_recoverd *rec,
                return;
        }
 
+       ret = ctdb_ctrl_getrecmode(ctdb, mem_ctx, CONTROL_TIMEOUT(),
+                                  CTDB_CURRENT_NODE, &ctdb->recovery_mode);
+       if (ret != 0) {
+               DEBUG(DEBUG_ERR, ("Failed to read recmode from local node\n"));
+               return;
+       }
+
        /* if the local daemon is STOPPED or BANNED, we verify that the 
databases are
           also frozen and that the recmode is set to active.


-- 
Samba Shared Repository

Reply via email to