[SCM] Samba Shared Repository - branch master updated

Andrew Bartlett abartlet at samba.org
Wed Aug 8 22:27:02 MDT 2012


The branch, master has been updated
       via  1a1f01e s4-dsdb: Change talloc parent
       via  1727556 s4-dsdb: Remove ldb_sequence_type argument from partition_primary_sequence_number
       via  6ec963e s4-dsdb: simplify migration of old-style seqence numbers to metadata.tdb
       via  6a648b7 s4-dsdb: Reduce calls to the ldb layer by reloading less often
      from  47c5900 s3:nmbd: log a failure in get_domain_master_name_node_status_success() as level 1

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


- Log -----------------------------------------------------------------
commit 1a1f01ee7a754f2ecccce4f385fba6cb55d82518
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Thu Aug 9 12:23:58 2012 +1000

    s4-dsdb: Change talloc parent
    
    This matches the rest of the function.
    
    Andrew Bartlett
    
    Autobuild-User(master): Andrew Bartlett <abartlet at samba.org>
    Autobuild-Date(master): Thu Aug  9 06:26:36 CEST 2012 on sn-devel-104

commit 17275561a062b0453f9d2547ecebd6dff08aaa24
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Thu Aug 9 12:23:13 2012 +1000

    s4-dsdb: Remove ldb_sequence_type argument from partition_primary_sequence_number
    
    We always want LDB_SEQ_HIGHEST_SEQ here.
    
    Andrew Bartlett

commit 6ec963eef7c00315b2d941951602825a89fabb6e
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Thu Aug 9 12:20:37 2012 +1000

    s4-dsdb: simplify migration of old-style seqence numbers to metadata.tdb
    
    This simple operation does not need to be encased in generic ldb extended operations.
    
    Andrew Bartlett

commit 6a648b727f50e33a4c66a77e3980d7c0c2adcb49
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Thu Aug 9 10:21:38 2012 +1000

    s4-dsdb: Reduce calls to the ldb layer by reloading less often
    
    We do not need to reload the partition list to get the global sequence
    number, as that number is stored in the metadata.tdb, not the ldb files.
    
    Andrew Bartlett

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

Summary of changes:
 source4/dsdb/samdb/ldb_modules/partition.c         |  184 ++++++++------------
 source4/dsdb/samdb/ldb_modules/partition_init.c    |    8 +-
 .../dsdb/samdb/ldb_modules/partition_metadata.c    |   57 +------
 3 files changed, 82 insertions(+), 167 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source4/dsdb/samdb/ldb_modules/partition.c b/source4/dsdb/samdb/ldb_modules/partition.c
index d4f020f..4a9216b 100644
--- a/source4/dsdb/samdb/ldb_modules/partition.c
+++ b/source4/dsdb/samdb/ldb_modules/partition.c
@@ -985,7 +985,7 @@ static int partition_del_trans(struct ldb_module *module)
 }
 
 int partition_primary_sequence_number(struct ldb_module *module, TALLOC_CTX *mem_ctx, 
-				      enum ldb_sequence_type type, uint64_t *seq_number,
+				      uint64_t *seq_number,
 				      struct ldb_request *parent)
 {
 	int ret;
@@ -997,7 +997,7 @@ int partition_primary_sequence_number(struct ldb_module *module, TALLOC_CTX *mem
 	if (tseq == NULL) {
 		return ldb_oom(ldb_module_get_ctx(module));
 	}
-	tseq->type = type;
+	tseq->type = LDB_SEQ_HIGHEST_SEQ;
 	
 	ret = dsdb_module_extended(module, tseq, &res,
 				   LDB_EXTENDED_SEQUENCE_NUMBER,
@@ -1027,115 +1027,73 @@ int partition_primary_sequence_number(struct ldb_module *module, TALLOC_CTX *mem
  * Older version of sequence number as sum of sequence numbers for each partition
  */
 int partition_sequence_number_from_partitions(struct ldb_module *module,
-					      struct ldb_request *req,
-					      struct ldb_extended **ext)
+					      uint64_t *seqr)
 {
 	int ret;
 	unsigned int i;
 	uint64_t seq_number = 0;
 	struct partition_private_data *data = talloc_get_type(ldb_module_get_private(module),
 							      struct partition_private_data);
-	struct ldb_seqnum_request *seq;
-	struct ldb_seqnum_result *seqr;
-	struct ldb_request *treq;
-	struct ldb_seqnum_request *tseq;
-	struct ldb_seqnum_result *tseqr;
-	struct ldb_result *res;
-	struct dsdb_partition *p;
 
-	p = find_partition(data, NULL, req);
-	if (p != NULL) {
-		/* the caller specified what partition they want the
-		 * sequence number operation on - just pass it on
-		 */
-		return ldb_next_request(p->module, req);		
+	ret = partition_primary_sequence_number(module, data, &seq_number, NULL);
+	if (ret != LDB_SUCCESS) {
+		return ret;
 	}
-
-	seq = talloc_get_type(req->op.extended.data, struct ldb_seqnum_request);
-
-	switch (seq->type) {
-	case LDB_SEQ_NEXT:
-	case LDB_SEQ_HIGHEST_SEQ:
-
-		ret = partition_primary_sequence_number(module, req, seq->type, &seq_number, req);
+	
+	/* Skip the lot if 'data' isn't here yet (initialisation) */
+	for (i=0; data && data->partitions && data->partitions[i]; i++) {
+		struct ldb_seqnum_request *tseq;
+		struct ldb_seqnum_result *tseqr;
+		struct ldb_request *treq;
+		struct ldb_result *res = talloc_zero(data, struct ldb_result);
+		if (res == NULL) {
+			return ldb_oom(ldb_module_get_ctx(module));
+		}
+		tseq = talloc_zero(res, struct ldb_seqnum_request);
+		if (tseq == NULL) {
+			talloc_free(res);
+			return ldb_oom(ldb_module_get_ctx(module));
+		}
+		tseq->type = LDB_SEQ_HIGHEST_SEQ;
+		
+		ret = ldb_build_extended_req(&treq, ldb_module_get_ctx(module), res,
+					     LDB_EXTENDED_SEQUENCE_NUMBER,
+					     tseq,
+					     NULL,
+					     res,
+					     ldb_extended_default_callback,
+					     NULL);
+		LDB_REQ_SET_LOCATION(treq);
 		if (ret != LDB_SUCCESS) {
+			talloc_free(res);
 			return ret;
-		}
-
-		/* Skip the lot if 'data' isn't here yet (initialisation) */
-		for (i=0; data && data->partitions && data->partitions[i]; i++) {
-
-			res = talloc_zero(req, struct ldb_result);
-			if (res == NULL) {
-				return ldb_oom(ldb_module_get_ctx(module));
-			}
-			tseq = talloc_zero(res, struct ldb_seqnum_request);
-			if (tseq == NULL) {
-				talloc_free(res);
-				return ldb_oom(ldb_module_get_ctx(module));
 			}
-			tseq->type = seq->type;
-
-			ret = ldb_build_extended_req(&treq, ldb_module_get_ctx(module), res,
-						     LDB_EXTENDED_SEQUENCE_NUMBER,
-						     tseq,
-						     NULL,
-						     res,
-						     ldb_extended_default_callback,
-						     req);
-			LDB_REQ_SET_LOCATION(treq);
-			if (ret != LDB_SUCCESS) {
-				talloc_free(res);
-				return ret;
-			}
-
-			ret = ldb_request_add_control(treq,
-						      DSDB_CONTROL_CURRENT_PARTITION_OID,
-						      false, data->partitions[i]->ctrl);
-			if (ret != LDB_SUCCESS) {
-				talloc_free(res);
-				return ret;
-			}
-
-			ret = partition_request(data->partitions[i]->module, treq);
-			if (ret != LDB_SUCCESS) {
-				talloc_free(res);
-				return ret;
-			}
-			ret = ldb_wait(treq->handle, LDB_WAIT_ALL);
-			if (ret != LDB_SUCCESS) {
-				talloc_free(res);
-				return ret;
-			}
-			tseqr = talloc_get_type(res->extended->data,
-						struct ldb_seqnum_result);
-			seq_number += tseqr->seq_num;
+		
+		ret = ldb_request_add_control(treq,
+					      DSDB_CONTROL_CURRENT_PARTITION_OID,
+					      false, data->partitions[i]->ctrl);
+		if (ret != LDB_SUCCESS) {
 			talloc_free(res);
+			return ret;
 		}
-		break;
-
-	case LDB_SEQ_HIGHEST_TIMESTAMP:
-		return ldb_module_error(module, LDB_ERR_OPERATIONS_ERROR, "LDB_SEQ_HIGHEST_TIMESTAMP not supported");
-	}
-
-	*ext = talloc_zero(req, struct ldb_extended);
-	if (!*ext) {
-		return ldb_oom(ldb_module_get_ctx(module));
-	}
-	seqr = talloc_zero(*ext, struct ldb_seqnum_result);
-	if (seqr == NULL) {
-		talloc_free(*ext);
-		return ldb_oom(ldb_module_get_ctx(module));
-	}
-	(*ext)->oid = LDB_EXTENDED_SEQUENCE_NUMBER;
-	(*ext)->data = seqr;
-
-	seqr->seq_num = seq_number;
-	if (seq->type == LDB_SEQ_NEXT) {
-		seqr->seq_num++;
+		
+		ret = partition_request(data->partitions[i]->module, treq);
+		if (ret != LDB_SUCCESS) {
+			talloc_free(res);
+			return ret;
+		}
+		ret = ldb_wait(treq->handle, LDB_WAIT_ALL);
+		if (ret != LDB_SUCCESS) {
+			talloc_free(res);
+			return ret;
+		}
+		tseqr = talloc_get_type(res->extended->data,
+					struct ldb_seqnum_result);
+		seq_number += tseqr->seq_num;
+		talloc_free(res);
 	}
 
-	seqr->flags |= LDB_SEQ_GLOBAL_SEQUENCE;
+	*seqr = seq_number;
 	return LDB_SUCCESS;
 }
 
@@ -1154,14 +1112,6 @@ static int partition_sequence_number(struct ldb_module *module, struct ldb_reque
 	struct dsdb_partition *p;
 	int ret;
 
-	p = find_partition(data, NULL, req);
-	if (p != NULL) {
-		/* the caller specified what partition they want the
-		 * sequence number operation on - just pass it on
-		 */
-		return ldb_next_request(p->module, req);
-	}
-
 	seq = talloc_get_type_abort(req->op.extended.data, struct ldb_seqnum_request);
 	switch (seq->type) {
 	case LDB_SEQ_NEXT:
@@ -1172,6 +1122,26 @@ static int partition_sequence_number(struct ldb_module *module, struct ldb_reque
 		break;
 
 	case LDB_SEQ_HIGHEST_SEQ:
+
+		/* 
+		 * We can only query per-partition the individual
+		 * partition sequence number, so we don't need to run
+		 * this reload for every query of the next global seq
+		 * number 
+		 */
+		ret = partition_reload_if_required(module, data, req);
+		if (ret != LDB_SUCCESS) {
+			return ret;
+		}
+		
+		p = find_partition(data, NULL, req);
+		if (p != NULL) {
+			/* the caller specified what partition they want the
+			 * sequence number operation on - just pass it on
+			 */
+			return ldb_next_request(p->module, req);
+		}
+
 		ret = partition_metadata_sequence_number(module, &seq_number);
 		if (ret != LDB_SUCCESS) {
 			return ret;
@@ -1221,12 +1191,6 @@ static int partition_extended(struct ldb_module *module, struct ldb_request *req
 		ret = partition_metadata_inc_schema_sequence(module);
 		return ldb_module_done(req, NULL, NULL, ret);
 	}
-
-	/* see if we are still up-to-date */
-	ret = partition_reload_if_required(module, data, req);
-	if (ret != LDB_SUCCESS) {
-		return ret;
-	}
 	
 	if (strcmp(req->op.extended.oid, LDB_EXTENDED_SEQUENCE_NUMBER) == 0) {
 		return partition_sequence_number(module, req);
diff --git a/source4/dsdb/samdb/ldb_modules/partition_init.c b/source4/dsdb/samdb/ldb_modules/partition_init.c
index dc09e13..98896a7 100644
--- a/source4/dsdb/samdb/ldb_modules/partition_init.c
+++ b/source4/dsdb/samdb/ldb_modules/partition_init.c
@@ -397,7 +397,7 @@ int partition_reload_if_required(struct ldb_module *module,
 		return ldb_oom(ldb);
 	}
 
-	ret = partition_primary_sequence_number(module, mem_ctx, LDB_SEQ_HIGHEST_SEQ, &seq, parent);
+	ret = partition_primary_sequence_number(module, mem_ctx, &seq, parent);
 	if (ret != LDB_SUCCESS) {
 		talloc_free(mem_ctx);
 		return ret;
@@ -707,6 +707,12 @@ int partition_create(struct ldb_module *module, struct ldb_request *req)
 		return LDB_ERR_UNWILLING_TO_PERFORM;
 	}
 
+	/* see if we are still up-to-date */
+	ret = partition_reload_if_required(module, data, req);
+	if (ret != LDB_SUCCESS) {
+		return ret;
+	}
+
 	for (i=0; data->partitions && data->partitions[i]; i++) {
 		if (ldb_dn_compare(data->partitions[i]->ctrl->dn, dn) == 0) {
 			partition = data->partitions[i];
diff --git a/source4/dsdb/samdb/ldb_modules/partition_metadata.c b/source4/dsdb/samdb/ldb_modules/partition_metadata.c
index 0bf7a40..5826ac2 100644
--- a/source4/dsdb/samdb/ldb_modules/partition_metadata.c
+++ b/source4/dsdb/samdb/ldb_modules/partition_metadata.c
@@ -260,69 +260,14 @@ static int partition_metadata_open(struct ldb_module *module, bool create)
  */
 static int partition_metadata_set_sequence_number(struct ldb_module *module)
 {
-	struct partition_private_data *data;
-	struct ldb_result *res;
-	struct ldb_request *req;
-	struct ldb_seqnum_request *seq;
-	struct ldb_seqnum_result *seqr;
-	struct ldb_extended *ext;
-	TALLOC_CTX *tmp_ctx;
 	int ret;
 	uint64_t seq_number;
 
-	data = talloc_get_type_abort(ldb_module_get_private(module),
-				    struct partition_private_data);
-	if (!data || !data->metadata) {
-		return ldb_module_error(module, LDB_ERR_OPERATIONS_ERROR,
-					"partition_metadata: metadata not initialized");
-	}
-
-	tmp_ctx = talloc_new(data->metadata);
-	if (tmp_ctx == NULL) {
-		return ldb_module_oom(module);
-	}
-
-	res = talloc_zero(tmp_ctx, struct ldb_result);
-	if (res == NULL) {
-		talloc_free(tmp_ctx);
-		return ldb_module_oom(module);
-	}
-
-	seq = talloc_zero(tmp_ctx, struct ldb_seqnum_request);
-	if (seq == NULL) {
-		talloc_free(tmp_ctx);
-		return ldb_module_oom(module);
-	}
-	seq->type = LDB_SEQ_HIGHEST_SEQ;
-
-	/* Build an extended request, so it can be passed to each partition in
-	   partition_sequence_number_from_partitions() */
-	ret = ldb_build_extended_req(&req,
-				     ldb_module_get_ctx(module),
-				     tmp_ctx,
-				     LDB_EXTENDED_SEQUENCE_NUMBER,
-				     seq,
-				     NULL,
-				     res,
-				     ldb_extended_default_callback,
-				     NULL);
-	LDB_REQ_SET_LOCATION(req);
-	if (ret != LDB_SUCCESS) {
-		talloc_free(tmp_ctx);
-		return ret;
-	}
-
-	ret = partition_sequence_number_from_partitions(module, req, &ext);
+	ret = partition_sequence_number_from_partitions(module, &seq_number);
 	if (ret != LDB_SUCCESS) {
-		talloc_free(tmp_ctx);
 		return ret;
 	}
 
-	seqr = talloc_get_type_abort(ext->data, struct ldb_seqnum_result);
-	seq_number = seqr->seq_num;
-
-	talloc_free(tmp_ctx);
-
 	return partition_metadata_set_uint64(module, LDB_METADATA_SEQ_NUM, seq_number, true);
 }
 


-- 
Samba Shared Repository


More information about the samba-cvs mailing list