[SCM] Samba Shared Repository - branch master updated
Andrew Tridgell
tridge at samba.org
Mon Oct 26 19:13:25 MDT 2009
The branch, master has been updated
via 6afac82... s4-ldb: '+' can also happen in base64 encoded index DNs
via 8ae0abc... s4:ldb Add detail to failures in the indexing code
via 5e920f2... s4:dsdb Rework partitions module for better tracing
via 3c6c230... s4:ldb Add additional tracing of the ldb API
via 53b160e... s4:dsdb Remove partition_extended_schema_update_now
from f381faa... s3: Rename new parameter "ldap ref follow" to "ldap follow referral".
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 6afac82e4b2e09262cf3151bc87a82c5abb39932
Author: Andrew Tridgell <tridge at samba.org>
Date: Tue Oct 27 11:44:05 2009 +1100
s4-ldb: '+' can also happen in base64 encoded index DNs
commit 8ae0abc65f9023d031c799516efe52cb36c612f5
Author: Andrew Bartlett <abartlet at samba.org>
Date: Tue Oct 27 11:10:49 2009 +1100
s4:ldb Add detail to failures in the indexing code
commit 5e920f2a232ea0bce366895b0b789b1362e88180
Author: Andrew Bartlett <abartlet at samba.org>
Date: Tue Oct 27 10:54:16 2009 +1100
s4:dsdb Rework partitions module for better tracing
This means we need to create a fake 'module' which only has a 'next'
pointer, so that we can now ldb_next_request() (which incorporates
tracing). The remainaing stub of partition_request() is retained so
that we can indicate which partition an operation is destined for.
Similar tracing is added to the transaction handlers.
Andrew Bartlett
commit 3c6c230b2d5c8a2632163a5f11d9e3f1f3db1639
Author: Andrew Bartlett <abartlet at samba.org>
Date: Tue Oct 27 10:43:51 2009 +1100
s4:ldb Add additional tracing of the ldb API
This helps pin down where errors occour, by printing a call stack and
setting error strings and trace messages in the transaction case.
Andrew Bartlett
commit 53b160e1b80f66b0728020783df5bf433048a148
Author: Andrew Bartlett <abartlet at samba.org>
Date: Mon Oct 26 10:23:10 2009 +1100
s4:dsdb Remove partition_extended_schema_update_now
The schema update now request is now handled above the partitions
module.
Andrew Bartlett
-----------------------------------------------------------------------
Summary of changes:
source4/dsdb/samdb/ldb_modules/partition.c | 173 +++++++---------------
source4/dsdb/samdb/ldb_modules/partition.h | 13 --
source4/dsdb/samdb/ldb_modules/partition_init.c | 38 +++---
source4/lib/ldb/common/ldb.c | 20 +++
source4/lib/ldb/common/ldb_dn.c | 2 +-
source4/lib/ldb/common/ldb_modules.c | 64 ++++++++-
source4/lib/ldb/ldb_tdb/ldb_index.c | 10 +-
7 files changed, 165 insertions(+), 155 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 587d920..a36ab3a 100644
--- a/source4/dsdb/samdb/ldb_modules/partition.c
+++ b/source4/dsdb/samdb/ldb_modules/partition.c
@@ -68,48 +68,23 @@ static struct partition_context *partition_init_ctx(struct ldb_module *module, s
int partition_request(struct ldb_module *module, struct ldb_request *request)
{
- int ret;
- switch (request->operation) {
- case LDB_SEARCH:
- PARTITION_FIND_OP(module, search);
- ret = module->ops->search(module, request);
- break;
- case LDB_ADD:
- PARTITION_FIND_OP(module, add);
- ret = module->ops->add(module, request);
- break;
- case LDB_MODIFY:
- PARTITION_FIND_OP(module, modify);
- ret = module->ops->modify(module, request);
- break;
- case LDB_DELETE:
- PARTITION_FIND_OP(module, del);
- ret = module->ops->del(module, request);
- break;
- case LDB_RENAME:
- PARTITION_FIND_OP(module, rename);
- ret = module->ops->rename(module, request);
- break;
- case LDB_EXTENDED:
- PARTITION_FIND_OP(module, extended);
- ret = module->ops->extended(module, request);
- break;
- default:
- PARTITION_FIND_OP(module, request);
- ret = module->ops->request(module, request);
- break;
- }
- if (ret == LDB_SUCCESS) {
- return ret;
- }
- if (!ldb_errstring(ldb_module_get_ctx(module))) {
- /* Set a default error string, to place the blame somewhere */
- ldb_asprintf_errstring(ldb_module_get_ctx(module),
- "error in module %s: %s (%d)",
- module->ops->name,
- ldb_strerror(ret), ret);
+ if ((module && module->ldb->flags & LDB_FLG_ENABLE_TRACING)) { \
+ const struct dsdb_control_current_partition *partition = NULL;
+ struct ldb_control *partition_ctrl = ldb_request_get_control(request, DSDB_CONTROL_CURRENT_PARTITION_OID);
+ if (partition_ctrl) {
+ partition = talloc_get_type(partition_ctrl->data,
+ struct dsdb_control_current_partition);
+ }
+
+ if (partition != NULL) {
+ ldb_debug(module->ldb, LDB_DEBUG_TRACE, "partition_request() -> %s",
+ ldb_dn_get_linearized(partition->dn));
+ } else {
+ ldb_debug(module->ldb, LDB_DEBUG_TRACE, "partition_request() -> (metadata partition)");
+ }
}
- return ret;
+
+ return ldb_next_request(module, request);
}
static struct dsdb_partition *find_partition(struct partition_private_data *data,
@@ -358,9 +333,9 @@ static int partition_prep_request(struct partition_context *ac,
}
} else {
- /* make sure you put the NEXT module here, or
- * partition_request() will simply loop forever on itself */
- ac->part_req[ac->num_requests].module = ac->module->next;
+ /* make sure you put the module here, or
+ * or ldb_next_request() will skip a module */
+ ac->part_req[ac->num_requests].module = ac->module;
}
ac->num_requests++;
@@ -414,7 +389,7 @@ static int partition_replicate(struct ldb_module *module, struct ldb_request *re
return ldb_next_request(module, req);
}
- if (req->operation != LDB_SEARCH) {
+ if (req->operation != LDB_SEARCH && ldb_dn_is_special(dn)) {
/* Is this a special DN, we need to replicate to every backend? */
for (i=0; data->replicate && data->replicate[i]; i++) {
if (ldb_dn_compare(data->replicate[i],
@@ -663,6 +638,9 @@ static int partition_start_trans(struct ldb_module *module)
/* Look at base DN */
/* Figure out which partition it is under */
/* Skip the lot if 'data' isn't here yet (initialization) */
+ if ((module && module->ldb->flags & LDB_FLG_ENABLE_TRACING)) {
+ ldb_debug(module->ldb, LDB_DEBUG_TRACE, "partition_start_trans() -> (metadata partition)");
+ }
ret = ldb_next_start_trans(module);
if (ret != LDB_SUCCESS) {
return ret;
@@ -674,17 +652,15 @@ static int partition_start_trans(struct ldb_module *module)
}
for (i=0; data && data->partitions && data->partitions[i]; i++) {
- struct ldb_module *next = data->partitions[i]->module;
- PARTITION_FIND_OP(next, start_transaction);
-
- ret = next->ops->start_transaction(next);
+ if ((module && module->ldb->flags & LDB_FLG_ENABLE_TRACING)) {
+ ldb_debug(module->ldb, LDB_DEBUG_TRACE, "partition_start_trans() -> %s",
+ ldb_dn_get_linearized(data->partitions[i]->ctrl->dn));
+ }
+ ret = ldb_next_start_trans(data->partitions[i]->module);
if (ret != LDB_SUCCESS) {
/* Back it out, if it fails on one */
for (i--; i >= 0; i--) {
- next = data->partitions[i]->module;
- PARTITION_FIND_OP(next, del_transaction);
-
- next->ops->del_transaction(next);
+ ldb_next_del_trans(data->partitions[i]->module);
}
ldb_next_del_trans(module);
return ret;
@@ -704,20 +680,22 @@ static int partition_prepare_commit(struct ldb_module *module)
struct partition_private_data);
for (i=0; data && data->partitions && data->partitions[i]; i++) {
- struct ldb_module *next_prepare = data->partitions[i]->module;
int ret;
- PARTITION_FIND_OP_NOERROR(next_prepare, prepare_commit);
- if (next_prepare == NULL) {
- continue;
+ if ((module && module->ldb->flags & LDB_FLG_ENABLE_TRACING)) {
+ ldb_debug(module->ldb, LDB_DEBUG_TRACE, "partition_prepare_commit() -> %s",
+ ldb_dn_get_linearized(data->partitions[i]->ctrl->dn));
}
-
- ret = next_prepare->ops->prepare_commit(next_prepare);
+ ret = ldb_next_prepare_commit(data->partitions[i]->module);
if (ret != LDB_SUCCESS) {
+ ldb_asprintf_errstring(module->ldb, "prepare_commit error on %s: %s", ldb_dn_get_linearized(data->partitions[i]->ctrl->dn), ldb_errstring(module->ldb));
return ret;
}
}
+ if ((module && module->ldb->flags & LDB_FLG_ENABLE_TRACING)) {
+ ldb_debug(module->ldb, LDB_DEBUG_TRACE, "partition_prepare_commit() -> (metadata partition)");
+ }
return ldb_next_prepare_commit(module);
}
@@ -729,13 +707,15 @@ static int partition_end_trans(struct ldb_module *module)
struct partition_private_data *data = talloc_get_type(module->private_data,
struct partition_private_data);
for (i=0; data && data->partitions && data->partitions[i]; i++) {
- struct ldb_module *next_end = data->partitions[i]->module;
int ret;
- PARTITION_FIND_OP(next_end, end_transaction);
-
- ret = next_end->ops->end_transaction(next_end);
+ if ((module && module->ldb->flags & LDB_FLG_ENABLE_TRACING)) {
+ ldb_debug(module->ldb, LDB_DEBUG_TRACE, "partition_end_trans() -> %s",
+ ldb_dn_get_linearized(data->partitions[i]->ctrl->dn));
+ }
+ ret = ldb_next_end_trans(data->partitions[i]->module);
if (ret != LDB_SUCCESS) {
+ ldb_asprintf_errstring(module->ldb, "end_trans error on %s: %s", ldb_dn_get_linearized(data->partitions[i]->ctrl->dn), ldb_errstring(module->ldb));
return ret;
}
}
@@ -746,6 +726,9 @@ static int partition_end_trans(struct ldb_module *module)
}
data->in_transaction--;
+ if ((module && module->ldb->flags & LDB_FLG_ENABLE_TRACING)) {
+ ldb_debug(module->ldb, LDB_DEBUG_TRACE, "partition_end_trans() -> (metadata partition)");
+ }
return ldb_next_end_trans(module);
}
@@ -756,11 +739,13 @@ static int partition_del_trans(struct ldb_module *module)
struct partition_private_data *data = talloc_get_type(module->private_data,
struct partition_private_data);
for (i=0; data && data->partitions && data->partitions[i]; i++) {
- struct ldb_module *next = data->partitions[i]->module;
- PARTITION_FIND_OP(next, del_transaction);
-
- ret = next->ops->del_transaction(next);
+ if ((module && module->ldb->flags & LDB_FLG_ENABLE_TRACING)) {
+ ldb_debug(module->ldb, LDB_DEBUG_TRACE, "partition_del_trans() -> %s",
+ ldb_dn_get_linearized(data->partitions[i]->ctrl->dn));
+ }
+ ret = ldb_next_del_trans(data->partitions[i]->module);
if (ret != LDB_SUCCESS) {
+ ldb_asprintf_errstring(module->ldb, "del_trans error on %s: %s", ldb_dn_get_linearized(data->partitions[i]->ctrl->dn), ldb_errstring(module->ldb));
final_ret = ret;
}
}
@@ -771,6 +756,9 @@ static int partition_del_trans(struct ldb_module *module)
}
data->in_transaction--;
+ if ((module && module->ldb->flags & LDB_FLG_ENABLE_TRACING)) {
+ ldb_debug(module->ldb, LDB_DEBUG_TRACE, "partition_del_trans() -> (metadata partition)");
+ }
ret = ldb_next_del_trans(module);
if (ret != LDB_SUCCESS) {
final_ret = ret;
@@ -1072,52 +1060,6 @@ static int partition_sequence_number(struct ldb_module *module, struct ldb_reque
return ldb_module_done(req, NULL, ext, LDB_SUCCESS);
}
-static int partition_extended_schema_update_now(struct ldb_module *module, struct ldb_request *req)
-{
- struct dsdb_partition *partition;
- struct partition_private_data *data;
- struct ldb_dn *schema_dn;
- struct partition_context *ac;
- int ret;
-
- schema_dn = talloc_get_type(req->op.extended.data, struct ldb_dn);
- if (!schema_dn) {
- ldb_debug(ldb_module_get_ctx(module), LDB_DEBUG_FATAL, "partition_extended: invalid extended data\n");
- return LDB_ERR_PROTOCOL_ERROR;
- }
-
- data = talloc_get_type(module->private_data, struct partition_private_data);
- if (!data) {
- return LDB_ERR_OPERATIONS_ERROR;
- }
-
- partition = find_partition( data, schema_dn, req);
- if (!partition) {
- return ldb_next_request(module, req);
- }
-
- ac = partition_init_ctx(module, req);
- if (!ac) {
- return LDB_ERR_OPERATIONS_ERROR;
- }
-
- /* we need to add a control but we never touch the original request */
- ret = partition_prep_request(ac, partition);
- if (ret != LDB_SUCCESS) {
- return ret;
- }
-
- /* fire the first one */
- ret = partition_call_first(ac);
-
- if (ret != LDB_SUCCESS){
- return ret;
- }
-
- return ldb_module_done(req, NULL, NULL, ret);
-}
-
-
/* extended */
static int partition_extended(struct ldb_module *module, struct ldb_request *req)
{
@@ -1143,11 +1085,6 @@ static int partition_extended(struct ldb_module *module, struct ldb_request *req
return partition_create(module, req);
}
- /* forward schemaUpdateNow operation to schema_fsmo module*/
- if (strcmp(req->op.extended.oid, DSDB_EXTENDED_SCHEMA_UPDATE_NOW_OID) == 0) {
- return partition_extended_schema_update_now( module, req );
- }
-
/*
* as the extended operation has no dn
* we need to send it to all partitions
diff --git a/source4/dsdb/samdb/ldb_modules/partition.h b/source4/dsdb/samdb/ldb_modules/partition.h
index dda0b86..81c98f4 100644
--- a/source4/dsdb/samdb/ldb_modules/partition.h
+++ b/source4/dsdb/samdb/ldb_modules/partition.h
@@ -48,17 +48,4 @@ struct partition_private_data {
uint32_t in_transaction;
};
-#define PARTITION_FIND_OP_NOERROR(module, op) do { \
- while (module && module->ops->op == NULL) module = module->next; \
-} while (0)
-
-#define PARTITION_FIND_OP(module, op) do { \
- PARTITION_FIND_OP_NOERROR(module, op); \
- if (module == NULL) { \
- ldb_asprintf_errstring(ldb_module_get_ctx(module), \
- "Unable to find backend operation for " #op ); \
- return LDB_ERR_OPERATIONS_ERROR; \
- } \
-} while (0)
-
#include "dsdb/samdb/ldb_modules/partition_proto.h"
diff --git a/source4/dsdb/samdb/ldb_modules/partition_init.c b/source4/dsdb/samdb/ldb_modules/partition_init.c
index 5967bc8..d3400f8 100644
--- a/source4/dsdb/samdb/ldb_modules/partition_init.c
+++ b/source4/dsdb/samdb/ldb_modules/partition_init.c
@@ -188,6 +188,7 @@ static int new_partition_from_dn(struct ldb_context *ldb, struct partition_priva
const char *backend_url;
struct dsdb_control_current_partition *ctrl;
struct ldb_module *backend_module;
+ struct ldb_module *module_chain;
const char **modules;
int ret;
@@ -261,7 +262,7 @@ static int new_partition_from_dn(struct ldb_context *ldb, struct partition_priva
talloc_free(*partition);
return LDB_ERR_CONSTRAINT_VIOLATION;
}
- ret = ldb_load_modules_list(ldb, modules, backend_module, &(*partition)->module);
+ ret = ldb_load_modules_list(ldb, modules, backend_module, &module_chain);
if (ret != LDB_SUCCESS) {
ldb_asprintf_errstring(ldb,
"partition_init: "
@@ -270,7 +271,7 @@ static int new_partition_from_dn(struct ldb_context *ldb, struct partition_priva
talloc_free(*partition);
return ret;
}
- ret = ldb_init_module_chain(ldb, (*partition)->module);
+ ret = ldb_init_module_chain(ldb, module_chain);
if (ret != LDB_SUCCESS) {
ldb_asprintf_errstring(ldb,
"partition_init: "
@@ -280,16 +281,24 @@ static int new_partition_from_dn(struct ldb_context *ldb, struct partition_priva
return ret;
}
- talloc_steal((*partition), (*partition)->module);
+ /* This weirdness allows us to use ldb_next_request() in partition.c */
+ (*partition)->module = ldb_module_new(*partition, ldb, "partition_next", NULL);
+ if (!(*partition)->module) {
+ ldb_oom(ldb);
+ talloc_free(*partition);
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+ (*partition)->module->next = talloc_steal((*partition)->module, module_chain);
/* if we were in a transaction then we need to start a
transaction on this new partition, otherwise we'll get a
transaction mismatch when we end the transaction */
if (data->in_transaction) {
- struct ldb_module *next = (*partition)->module;
- PARTITION_FIND_OP(next, start_transaction);
-
- ret = next->ops->start_transaction(next);
+ if (ldb->flags & LDB_FLG_ENABLE_TRACING) {
+ ldb_debug(ldb, LDB_DEBUG_TRACE, "partition_start_trans() -> %s (new partition)",
+ ldb_dn_get_linearized((*partition)->ctrl->dn));
+ }
+ ret = ldb_next_start_trans((*partition)->module);
}
return ret;
@@ -409,7 +418,6 @@ int partition_reload_if_required(struct ldb_module *module,
DATA_BLOB dn_blob;
struct ldb_dn *dn;
struct dsdb_partition *partition;
- struct ldb_module tmp_module;
struct ldb_result *dn_res;
const char *no_attrs[] = { NULL };
@@ -470,12 +478,8 @@ int partition_reload_if_required(struct ldb_module *module,
return ret;
}
- /* Hack to be able to re-use dsdb_module_search_dn, which calls ldb_next_request(), which needs ->next filled out */
- tmp_module = *partition->module;
- tmp_module.next = partition->module;
-
/* Get the 'correct' case of the partition DNs from the database */
- ret = dsdb_module_search_dn(&tmp_module, data, &dn_res,
+ ret = dsdb_module_search_dn(partition->module, data, &dn_res,
dn, no_attrs);
if (ret == LDB_SUCCESS) {
talloc_free(partition->ctrl->dn);
@@ -541,7 +545,7 @@ static int new_partition_set_replicated_metadata(struct ldb_context *ldb,
return ret;
}
/* do request */
- ret = partition_request(partition->module, add_req);
+ ret = ldb_next_request(partition->module, add_req);
/* wait */
if (ret == LDB_SUCCESS) {
ret = ldb_wait(add_req->handle, LDB_WAIT_ALL);
@@ -568,7 +572,7 @@ static int new_partition_set_replicated_metadata(struct ldb_context *ldb,
return ret;
}
/* do request */
- ret = partition_request(partition->module, del_req);
+ ret = ldb_next_request(partition->module, del_req);
/* wait */
if (ret == LDB_SUCCESS) {
@@ -595,7 +599,7 @@ static int new_partition_set_replicated_metadata(struct ldb_context *ldb,
}
/* do the add again */
- ret = partition_request(partition->module, add_req);
+ ret = ldb_next_request(partition->module, add_req);
/* wait */
if (ret == LDB_SUCCESS) {
@@ -694,7 +698,7 @@ int partition_create(struct ldb_module *module, struct ldb_request *req)
last_req = mod_req;
- ret = partition_request(module, mod_req);
+ ret = ldb_next_request(module, mod_req);
if (ret == LDB_SUCCESS) {
ret = ldb_wait(mod_req->handle, LDB_WAIT_ALL);
}
diff --git a/source4/lib/ldb/common/ldb.c b/source4/lib/ldb/common/ldb.c
index 59727d7..9be3aa1 100644
--- a/source4/lib/ldb/common/ldb.c
+++ b/source4/lib/ldb/common/ldb.c
@@ -288,6 +288,10 @@ void ldb_reset_err_string(struct ldb_context *ldb)
#define FIRST_OP_NOERR(ldb, op) do { \
module = ldb->modules; \
while (module && module->ops->op == NULL) module = module->next; \
+ if ((ldb->flags & LDB_FLG_ENABLE_TRACING) && module) { \
+ ldb_debug(ldb, LDB_DEBUG_TRACE, "ldb_trace_request: (%s)->" #op, \
+ module->ops->name); \
+ } \
} while (0)
#define FIRST_OP(ldb, op) do { \
@@ -335,6 +339,10 @@ int ldb_transaction_start(struct ldb_context *ldb)
status);
}
}
+ if ((module && module->ldb->flags & LDB_FLG_ENABLE_TRACING)) {
+ ldb_debug(module->ldb, LDB_DEBUG_TRACE, "start ldb transaction error: %s",
+ ldb_errstring(module->ldb));
+ }
return status;
}
@@ -383,6 +391,10 @@ int ldb_transaction_prepare_commit(struct ldb_context *ldb)
ldb_strerror(status),
status);
}
+ if ((module && module->ldb->flags & LDB_FLG_ENABLE_TRACING)) {
+ ldb_debug(module->ldb, LDB_DEBUG_TRACE, "prepare commit transaction error: %s",
+ ldb_errstring(module->ldb));
+ }
}
return status;
@@ -432,6 +444,10 @@ int ldb_transaction_commit(struct ldb_context *ldb)
ldb_strerror(status),
status);
}
+ if ((module && module->ldb->flags & LDB_FLG_ENABLE_TRACING)) {
+ ldb_debug(module->ldb, LDB_DEBUG_TRACE, "commit ldb transaction error: %s",
+ ldb_errstring(module->ldb));
+ }
/* cancel the transaction */
FIRST_OP(ldb, del_transaction);
module->ops->del_transaction(module);
@@ -477,6 +493,10 @@ int ldb_transaction_cancel(struct ldb_context *ldb)
ldb_strerror(status),
status);
}
+ if ((module && module->ldb->flags & LDB_FLG_ENABLE_TRACING)) {
+ ldb_debug(module->ldb, LDB_DEBUG_TRACE, "cancel ldb transaction error: %s",
+ ldb_errstring(module->ldb));
+ }
}
return status;
}
diff --git a/source4/lib/ldb/common/ldb_dn.c b/source4/lib/ldb/common/ldb_dn.c
index 639e8b2..8beda35 100644
--- a/source4/lib/ldb/common/ldb_dn.c
+++ b/source4/lib/ldb/common/ldb_dn.c
@@ -767,6 +767,7 @@ static bool ldb_dn_explode(struct ldb_dn *dn)
continue;
case '=':
+ case '+':
/* to main compatibility with earlier
versions of ldb indexing, we have to
accept the base64 encoded binary index
@@ -779,7 +780,6 @@ static bool ldb_dn_explode(struct ldb_dn *dn)
}
/* fall through */
case '\n':
- case '+':
case '<':
case '>':
case '#':
diff --git a/source4/lib/ldb/common/ldb_modules.c b/source4/lib/ldb/common/ldb_modules.c
index 69b8ed0..e79f072 100644
--- a/source4/lib/ldb/common/ldb_modules.c
+++ b/source4/lib/ldb/common/ldb_modules.c
--
Samba Shared Repository
More information about the samba-cvs
mailing list