[SCM] Samba Shared Repository - branch master updated

Martin Schwenke martins at samba.org
Wed Aug 13 03:25:04 MDT 2014


The branch, master has been updated
       via  c6d0e8d ctdb-readonly: Do not abort if revoke of readonly record fails on a node
       via  f96f395 ctdb-readonly: Add an early return to simplify code
      from  b8e9f6b ctdb-doc: Fix default database directories in ctdbd.1

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


- Log -----------------------------------------------------------------
commit c6d0e8dadcff55ea21973f4f7a89f241180d17e8
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Tue Aug 12 23:58:00 2014 +1000

    ctdb-readonly: Do not abort if revoke of readonly record fails on a node
    
    Revoking readonly record involves first marking the record on dmaster as
    RO_REVOKING_READONLY.  Then all the other nodes are sent update_record
    control to get rid of RO_DELEGATION.  Once that succeeds, the record
    is marked RO_REVOKING_COMPLETE.
    
    Currently, revoking of readonly delegations on the nodes is tried only
    once.  If a node goes in recovery, it can fail update_record control and
    revoke code will abort ctdb.  Since database recovery would revoke all
    readonly delegations anyway, there is no reason to abort.  Simply undo
    the start of revoke process by resetting RO_REVOKING_READONLY flag.
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    
    Autobuild-User(master): Martin Schwenke <martins at samba.org>
    Autobuild-Date(master): Wed Aug 13 11:24:09 CEST 2014 on sn-devel-104

commit f96f395d853e0181d9ee031c3e3f1d31f5cff35c
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Tue Aug 12 23:54:39 2014 +1000

    ctdb-readonly: Add an early return to simplify code
    
    This patch makes the subsequent logic change small and easier to
    understand.
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

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

Summary of changes:
 ctdb/server/ctdb_call.c |   78 ++++++++++++++++++++++++----------------------
 1 files changed, 41 insertions(+), 37 deletions(-)


Changeset truncated at 500 lines:

diff --git a/ctdb/server/ctdb_call.c b/ctdb/server/ctdb_call.c
index 1830b4a..a4fa03d 100644
--- a/ctdb/server/ctdb_call.c
+++ b/ctdb/server/ctdb_call.c
@@ -1539,7 +1539,8 @@ static void ctdb_revoke_timeout_handler(struct event_context *ev, struct timed_e
 static int ctdb_revoke_all_delegations(struct ctdb_context *ctdb, struct ctdb_db_context *ctdb_db, TDB_DATA tdata, TDB_DATA key, struct ctdb_ltdb_header *header, TDB_DATA data)
 {
 	struct ctdb_revoke_state *state = talloc_zero(ctdb, struct ctdb_revoke_state);
-	int status;
+	struct ctdb_ltdb_header new_header;
+	TDB_DATA new_data;
 
 	state->ctdb_db = ctdb_db;
 	state->key     = key;
@@ -1554,49 +1555,52 @@ static int ctdb_revoke_all_delegations(struct ctdb_context *ctdb, struct ctdb_db
 		event_loop_once(ctdb->ev);
 	}
 
-	status = state->status;
-
-	if (status == 0) {
-		struct ctdb_ltdb_header new_header;
-		TDB_DATA new_data;
+	if (ctdb_ltdb_lock(ctdb_db, key) != 0) {
+		DEBUG(DEBUG_ERR,("Failed to chainlock the database in revokechild\n"));
+		talloc_free(state);
+		return -1;
+	}
+	if (ctdb_ltdb_fetch(ctdb_db, key, &new_header, state, &new_data) != 0) {
+		ctdb_ltdb_unlock(ctdb_db, key);
+		DEBUG(DEBUG_ERR,("Failed for fetch tdb record in revokechild\n"));
+		talloc_free(state);
+		return -1;
+	}
+	header->rsn++;
+	if (new_header.rsn > header->rsn) {
+		ctdb_ltdb_unlock(ctdb_db, key);
+		DEBUG(DEBUG_ERR,("RSN too high in tdb record in revokechild\n"));
+		talloc_free(state);
+		return -1;
+	}
+	if ( (new_header.flags & (CTDB_REC_RO_REVOKING_READONLY|CTDB_REC_RO_HAVE_DELEGATIONS)) != (CTDB_REC_RO_REVOKING_READONLY|CTDB_REC_RO_HAVE_DELEGATIONS) ) {
+		ctdb_ltdb_unlock(ctdb_db, key);
+		DEBUG(DEBUG_ERR,("Flags are wrong in tdb record in revokechild\n"));
+		talloc_free(state);
+		return -1;
+	}
 
-		if (ctdb_ltdb_lock(ctdb_db, key) != 0) {
-			DEBUG(DEBUG_ERR,("Failed to chainlock the database in revokechild\n"));
-			talloc_free(state);
-			return -1;
-		}
-		if (ctdb_ltdb_fetch(ctdb_db, key, &new_header, state, &new_data) != 0) {
-			ctdb_ltdb_unlock(ctdb_db, key);
-			DEBUG(DEBUG_ERR,("Failed for fetch tdb record in revokechild\n"));
-			talloc_free(state);
-			return -1;
-		}
-		header->rsn++;
-		if (new_header.rsn > header->rsn) {
-			ctdb_ltdb_unlock(ctdb_db, key);
-			DEBUG(DEBUG_ERR,("RSN too high in tdb record in revokechild\n"));
-			talloc_free(state);
-			return -1;
-		}
-		if ( (new_header.flags & (CTDB_REC_RO_REVOKING_READONLY|CTDB_REC_RO_HAVE_DELEGATIONS)) != (CTDB_REC_RO_REVOKING_READONLY|CTDB_REC_RO_HAVE_DELEGATIONS) ) {
-			ctdb_ltdb_unlock(ctdb_db, key);
-			DEBUG(DEBUG_ERR,("Flags are wrong in tdb record in revokechild\n"));
-			talloc_free(state);
-			return -1;
-		}
+	/*
+	 * If revoke on all nodes succeed, revoke is complete.  Otherwise,
+	 * remove CTDB_REC_RO_REVOKING_READONLY flag and retry.
+	 */
+	if (state->status == 0) {
 		new_header.rsn++;
 		new_header.flags |= CTDB_REC_RO_REVOKE_COMPLETE;
-		if (ctdb_ltdb_store(ctdb_db, key, &new_header, new_data) != 0) {
-			ctdb_ltdb_unlock(ctdb_db, key);
-			DEBUG(DEBUG_ERR,("Failed to write new record in revokechild\n"));
-			talloc_free(state);
-			return -1;
-		}
+	} else {
+		DEBUG(DEBUG_NOTICE, ("Revoke all delegations failed, retrying.\n"));
+		new_header.flags &= ~CTDB_REC_RO_REVOKING_READONLY;
+	}
+	if (ctdb_ltdb_store(ctdb_db, key, &new_header, new_data) != 0) {
 		ctdb_ltdb_unlock(ctdb_db, key);
+		DEBUG(DEBUG_ERR,("Failed to write new record in revokechild\n"));
+		talloc_free(state);
+		return -1;
 	}
+	ctdb_ltdb_unlock(ctdb_db, key);
 
 	talloc_free(state);
-	return status;
+	return 0;
 }
 
 


-- 
Samba Shared Repository


More information about the samba-cvs mailing list