[SCM] CTDB repository - branch master updated - ctdb-2.0-18-g5067392

2013-01-06 Thread Amitay Isaacs
The branch, master has been updated
   via  5067392d2e06795559f25828b65c129608b65c0b (commit)
   via  81788cfabe960497b050c5ee4e4e487ee061012a (commit)
   via  4a9e96ad3d8fc46da1cd44cd82309c1b54301eb7 (commit)
  from  f81e9add466b1d9b2796c09c6ba63b77296ea149 (commit)

http://gitweb.samba.org/?p=ctdb.git;a=shortlog;h=master


- Log -
commit 5067392d2e06795559f25828b65c129608b65c0b
Author: Michael Adam 
Date:   Tue Nov 20 11:20:34 2012 +0100

ctdb:recover: fix a comment typo

Signed-off-by: Michael Adam 

commit 81788cfabe960497b050c5ee4e4e487ee061012a
Author: Michael Adam 
Date:   Fri Dec 21 11:52:57 2012 -0500

events/50.samba: fix testparm background update

creating the smb.conf cache with "-v" results in a cache file
that fails to load with "testparm -s ..." later on due to
"copy = " not being processable. (Copying the empty service name fails).

Signed-off-by: Michael Adam 

commit 4a9e96ad3d8fc46da1cd44cd82309c1b54301eb7
Author: Amitay Isaacs 
Date:   Fri Jan 4 14:32:55 2013 +1100

daemon: Add a tunable to enable automatic database priority setting

Samba versions 3.6.x and older do not set the database priority.
This can cause deadlock between Samba and CTDB since the locking order
of database will be different. A hack was added for automatic promotion
of priority for specific databases to avoid deadlock.  This code should
not be invoked with Samba version 4.x which correctly specifies the
priority for each database.

Signed-off-by: Amitay Isaacs 
Reviewed-by: Michael Adam 

---

Summary of changes:
 config/events.d/50.samba |2 +-
 doc/ctdbd.1.xml  |   13 +
 include/ctdb_private.h   |1 +
 server/ctdb_lock.c   |   14 +-
 server/ctdb_recover.c|2 +-
 server/ctdb_tunables.c   |1 +
 6 files changed, 26 insertions(+), 7 deletions(-)


Changeset truncated at 500 lines:

diff --git a/config/events.d/50.samba b/config/events.d/50.samba
index 4d9f121..a4d50fe 100755
--- a/config/events.d/50.samba
+++ b/config/events.d/50.samba
@@ -96,7 +96,7 @@ testparm_background_update() {
 # otherwise do a background update
 (
tmpfile="${smbconf_cache}.$$"
-   testparm -v -s > $tmpfile 2> /dev/null &
+   testparm -s > $tmpfile 2> /dev/null &
# remember the pid of the teamparm process
pid="$!"
# give it 10 seconds to run
diff --git a/doc/ctdbd.1.xml b/doc/ctdbd.1.xml
index d192feb..a0cba99 100644
--- a/doc/ctdbd.1.xml
+++ b/doc/ctdbd.1.xml
@@ -1098,6 +1098,19 @@
 detection.
 
 
+
+Samba3AvoidDeadlock
+Default: 0
+
+Enable code that prevents deadlocks with Samba (only for Samba 3.x).
+
+
+This should be set to 1 when using Samba version 3.x to enable special
+code in CTDB to avoid deadlock with Samba version 3.x.  This code
+is not required for Samba version 4.x and must not be enabled for
+Samba 4.x.
+
+
   
 
   LVS
diff --git a/include/ctdb_private.h b/include/ctdb_private.h
index 348df09..582a767 100644
--- a/include/ctdb_private.h
+++ b/include/ctdb_private.h
@@ -137,6 +137,7 @@ struct ctdb_tunable {
uint32_t pulldb_preallocation_size;
uint32_t no_ip_takeover_on_disabled;
uint32_t deadlock_timeout;
+   uint32_t samba3_hack;
 };
 
 /*
diff --git a/server/ctdb_lock.c b/server/ctdb_lock.c
index e78f3fc..8a2ba5c 100644
--- a/server/ctdb_lock.c
+++ b/server/ctdb_lock.c
@@ -96,8 +96,12 @@ struct lock_request {
  * By default, all databases are set to priority 1. So only when priority
  * is set to 1, check for databases that need higher priority.
  */
-static bool later_db(const char *name)
+static bool later_db(struct ctdb_context *ctdb, const char *name)
 {
+   if (ctdb->tunable.samba3_hack == 0) {
+   return false;
+   }
+
if (strstr(name, "brlock") ||
strstr(name, "g_lock") ||
strstr(name, "notify_onelevel") ||
@@ -120,7 +124,7 @@ int ctdb_lockall_prio(struct ctdb_context *ctdb, uint32_t 
priority)
if (ctdb_db->priority != priority) {
continue;
}
-   if (later_db(ctdb_db->db_name)) {
+   if (later_db(ctdb, ctdb_db->db_name)) {
continue;
}
DEBUG(DEBUG_INFO, ("locking database %s, priority:%u\n",
@@ -138,7 +142,7 @@ int ctdb_lockall_prio(struct ctdb_context *ctdb, uint32_t 
priority)
}
 
for (ctdb_db = ctdb->db_list; ctdb_db; ctdb_db = ctdb_db->next) {
-   if (!later_db(ctdb_db->db_name)) {
+   if (!later_db(ctdb, ctdb_db->db_name)) {
continue;
}
DEBUG(DEBUG_INFO, ("locking database %s, priority:%u\n",
@@ -228,7 +232,7 @@ int ctdb

[SCM] CTDB repository - branch master updated - ctdb-2.0-25-gb849fb4

2013-01-06 Thread Amitay Isaacs
The branch, master has been updated
   via  b849fb4923d6a34141fe19006a974de81508ceda (commit)
   via  c75b5e5b4d000f5c7dab403df8238ceed390c1c0 (commit)
   via  2629de72e1f37b5e46772c2ef8d8d0012fc4ed37 (commit)
   via  2bbee8ac23ad5b7adf7122d8c91d5f0d54582507 (commit)
   via  496387a585b2c5778c808cf02b8e1435abde4c3e (commit)
   via  3221fce9ee2f6fdd3bb17a5e1629ad52a32f90d6 (commit)
   via  776590bf84d221092298346a28d7fc0552a67c9d (commit)
  from  5067392d2e06795559f25828b65c129608b65c0b (commit)

http://gitweb.samba.org/?p=ctdb.git;a=shortlog;h=master


- Log -
commit b849fb4923d6a34141fe19006a974de81508ceda
Author: Amitay Isaacs 
Date:   Mon Jan 7 12:00:34 2013 +1100

tests/complex: Add NFS test when CTDB is killed on one of the nodes

Signed-off-by: Amitay Isaacs 

commit c75b5e5b4d000f5c7dab403df8238ceed390c1c0
Author: Martin Schwenke 
Date:   Tue Dec 4 15:00:44 2012 +1100

Eventscripts: Change the default reconfigure action to do nothing

A default action of restarting the service doesn't obey the principle
of least surprise.  It cause the NFS service to be implicitly
reintroduced.

This allows no-op functions to be removed from some eventscripts and
service restart functions to be added to others.

Signed-off-by: Martin Schwenke 

commit 2629de72e1f37b5e46772c2ef8d8d0012fc4ed37
Author: Martin Schwenke 
Date:   Tue Dec 4 14:52:25 2012 +1100

Eventscripts: Do not restart NFS on reconfigure

It looks like this restart was accidentally reintroduced in commit
fc0678d351187cfa4c71123f97c0f493aacd5d16 when $service_reconfigure
became unset so the default action of restarting the service would
occur.  From there cleanups have explicitly reintroduced it and
carried it through the code.

Also update the unit tests affected by this change.

The restart was originally removed in commit
bc481c3f1a44c50648488c4f8a7f15ec395d446f.

The default reconfigure action of restarting a service is clearly
suboptimal and will be addressed in a separate patch.

Signed-off-by: Martin Schwenke 

commit 2bbee8ac23ad5b7adf7122d8c91d5f0d54582507
Author: Martin Schwenke 
Date:   Tue Dec 4 14:28:06 2012 +1100

ctdbd: Initialise the node flags in just one place

Currently flags are initialised in 2 places.  One of them is in
ctdb_tcp_listen_automatic(), which just seems wrong.  This makes the
code easier to follow by just doing it in ctdb_start_daemon().

This means that the flags are now initialised later than previously.
However, it is still done before the transport is started and before
clients can connect.

In future it might make sense to do a similar thing with setting the
PNN.  However, the current optimisation is reasonably obvious...

Signed-off-by: Martin Schwenke 
Pair-programmed-with: Amitay Isaacs 

commit 496387a585b2c5778c808cf02b8e1435abde4c3e
Author: Martin Schwenke 
Date:   Mon Dec 3 15:44:12 2012 +1100

ctdbd: Remove debug option --node-ip, use --listen instead

This effectively reverts d96cb02c2c24f9eabbc53d3d38e90dea49cff3e0

Signed-off-by: Martin Schwenke 
Pair-programmed-with: Amitay Isaacs 

commit 3221fce9ee2f6fdd3bb17a5e1629ad52a32f90d6
Author: Martin Schwenke 
Date:   Mon Dec 3 15:32:49 2012 +1100

tests: Local daemons should use --listen instead of --node-ip

Signed-off-by: Martin Schwenke 
Pair-programmed-with: Amitay Isaacs 

commit 776590bf84d221092298346a28d7fc0552a67c9d
Author: Martin Schwenke 
Date:   Fri Nov 30 12:59:35 2012 +1100

Initscript: when checking status, print output of "ctdb ping" if it fails

At the moment the caller has no idea why it thinks CTDB isn't running
and we can't debug failures...

Signed-off-by: Martin Schwenke 

---

Summary of changes:
 config/ctdb.init   |5 +-
 config/events.d/40.vsftpd  |5 ++
 config/events.d/41.httpd   |5 ++
 config/events.d/49.winbind |6 --
 config/events.d/50.samba   |6 --
 config/events.d/60.nfs |2 -
 config/functions   |4 +-
 include/ctdb_private.h |1 -
 server/ctdb_daemon.c   |   23 +++
 server/ctdb_server.c   |   12 
 server/ctdbd.c |   26 +++-
 tcp/tcp_connect.c  |   69 ++--
 ...ilover_nfs_basic.sh => 45_failover_nfs_kill.sh} |   10 ++-
 tests/eventscripts/60.nfs.multi.001.sh |2 -
 tests/eventscripts/60.nfs.multi.002.sh |2 -

[SCM] CTDB repository - branch master updated - ctdb-2.0-28-g1a5410e

2013-01-06 Thread Amitay Isaacs
The branch, master has been updated
   via  1a5410e8349cdb96fdc51aa5ecd4f5734f6798a5 (commit)
   via  8164d9b29bf9080ccc76b1305fb6c07f1ed61d55 (commit)
   via  cc1a3ae911d3fee8b87fda5de5ab6d9499d7510a (commit)
  from  b849fb4923d6a34141fe19006a974de81508ceda (commit)

http://gitweb.samba.org/?p=ctdb.git;a=shortlog;h=master


- Log -
commit 1a5410e8349cdb96fdc51aa5ecd4f5734f6798a5
Author: Martin Schwenke 
Date:   Fri Nov 30 16:38:08 2012 +1100

tests: new simple integration test for delip interface garbage collection

Signed-off-by: Martin Schwenke 

commit 8164d9b29bf9080ccc76b1305fb6c07f1ed61d55
Author: Martin Schwenke 
Date:   Fri Nov 30 16:37:28 2012 +1100

tests: new function ip2ipmask() for integration testing

Signed-off-by: Martin Schwenke 

commit cc1a3ae911d3fee8b87fda5de5ab6d9499d7510a
Author: Martin Schwenke 
Date:   Fri Nov 23 20:09:07 2012 +1100

ctdbd: Clean up orphaned interfaces when an IP is deleted

Add a new function ctdb_remove_orphaned_ifaces() and call it in
ctdb_control_del_public_address().

ctdb_remove_orphaned_ifaces() uses a naive implementation that does
things in a very obvious way.  There are many ways to improve the
performance - some are mentioned in a comment in the code.  However, I
doubt that this will be a bottleneck even with a large number of
public IPs.  Running the eventscript is likely to outweigh the cost of
this cleanup.

Signed-off-by: Martin Schwenke 
Pair-programmed-with: Amitay Isaacs 

---

Summary of changes:
 server/ctdb_takeover.c|   76 +++--
 tests/scripts/integration.bash|7 +++
 tests/simple/20_delip_iface_gc.sh |   62 ++
 3 files changed, 141 insertions(+), 4 deletions(-)
 create mode 100755 tests/simple/20_delip_iface_gc.sh


Changeset truncated at 500 lines:

diff --git a/server/ctdb_takeover.c b/server/ctdb_takeover.c
index 5345251..df543fe 100644
--- a/server/ctdb_takeover.c
+++ b/server/ctdb_takeover.c
@@ -85,6 +85,74 @@ static int ctdb_add_local_iface(struct ctdb_context *ctdb, 
const char *iface)
return 0;
 }
 
+static bool vnn_has_interface_with_name(struct ctdb_vnn *vnn,
+   const char *name)
+{
+   int n;
+
+   for (n = 0; vnn->ifaces[n] != NULL; n++) {
+   if (strcmp(name, vnn->ifaces[n]) == 0) {
+   return true;
+   }
+   }
+
+   return false;
+}
+
+/* If any interfaces now have no possible IPs then delete them.  This
+ * implementation is naive (i.e. simple) rather than clever
+ * (i.e. complex).  Given that this is run on delip and that operation
+ * is rare, this doesn't need to be efficient - it needs to be
+ * foolproof.  One alternative is reference counting, where the logic
+ * is distributed and can, therefore, be broken in multiple places.
+ * Another alternative is to build a red-black tree of interfaces that
+ * can have addresses (by walking ctdb->vnn and ctdb->single_ip_vnn
+ * once) and then walking ctdb->ifaces once and deleting those not in
+ * the tree.  Let's go to one of those if the naive implementation
+ * causes problems...  :-)
+ */
+static void ctdb_remove_orphaned_ifaces(struct ctdb_context *ctdb,
+   struct ctdb_vnn *vnn,
+   TALLOC_CTX *mem_ctx)
+{
+   struct ctdb_iface *i;
+
+   /* For each interface, check if there's an IP using it. */
+   for(i=ctdb->ifaces; i; i=i->next) {
+   struct ctdb_vnn *tv;
+   bool found;
+
+   /* Only consider interfaces named in the given VNN. */
+   if (!vnn_has_interface_with_name(vnn, i->name)) {
+   continue;
+   }
+
+   /* Is the "single IP" on this interface? */
+   if ((ctdb->single_ip_vnn != NULL) &&
+   (ctdb->single_ip_vnn->ifaces[0] != NULL) &&
+   (strcmp(i->name, ctdb->single_ip_vnn->ifaces[0]) == 0)) {
+   /* Found, next interface please... */
+   continue;
+   }
+   /* Search for a vnn with this interface. */
+   found = false;
+   for (tv=ctdb->vnn; tv; tv=tv->next) {
+   if (vnn_has_interface_with_name(tv, i->name)) {
+   found = true;
+   break;
+   }
+   }
+
+   if (!found) {
+   /* None of the VNNs are using this interface. */
+   DLIST_REMOVE(ctdb->ifaces, i);
+   /* Caller will free mem_ctx when convenient. */
+   talloc_steal(mem_ctx, i);
+   }
+