diff options
author | Andrew Bartlett <abartlet@samba.org> | 2013-06-23 19:47:35 +1000 |
---|---|---|
committer | Karolin Seeger <kseeger@samba.org> | 2013-08-05 20:25:08 +0200 |
commit | 75ef73f5f912681bf7697ac37c76c0f2ac7ae30b (patch) | |
tree | 2242fd75bf6ab10514398059055a6506e59669e6 | |
parent | c4c3d7ffc8b136ddfd63b12e52f2e59af2058b0c (diff) | |
download | samba-75ef73f5f912681bf7697ac37c76c0f2ac7ae30b.tar.gz |
dsdb-descriptor: Do not do a subtree search unless we have child entries
This avoids a subtree search here in most cases where an object is deleted.
Andrew Bartlett
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
(cherry picked from commit 03b44d26fd17761675fe33ab29e8f325f59d8a5c)
-rw-r--r-- | source4/dsdb/samdb/ldb_modules/descriptor.c | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/source4/dsdb/samdb/ldb_modules/descriptor.c b/source4/dsdb/samdb/ldb_modules/descriptor.c index 7743baaaa5b..ceac8db7de2 100644 --- a/source4/dsdb/samdb/ldb_modules/descriptor.c +++ b/source4/dsdb/samdb/ldb_modules/descriptor.c @@ -1186,16 +1186,47 @@ static int descriptor_sd_propagation_recursive(struct ldb_module *module, const char * const no_attrs[] = { "@__NONE__", NULL }; struct descriptor_changes *c; struct descriptor_changes *stopped_stack = NULL; + enum ldb_scope scope; int ret; /* + * First confirm this object has children, or exists (depending on change->force_self) + * + * LDB_SCOPE_SUBTREE searches are expensive. + * + * Note: that we do not search for deleted/recycled objects + */ + ret = dsdb_module_search(module, + change, + &res, + change->dn, + LDB_SCOPE_ONELEVEL, + no_attrs, + DSDB_FLAG_NEXT_MODULE | + DSDB_FLAG_AS_SYSTEM, + NULL, /* parent_req */ + "(objectClass=*)"); + if (ret != LDB_SUCCESS) { + return ret; + } + + if (res->count == 0 && !change->force_self) { + TALLOC_FREE(res); + return LDB_SUCCESS; + } else if (res->count == 0 && change->force_self) { + scope = LDB_SCOPE_BASE; + } else { + scope = LDB_SCOPE_SUBTREE; + } + + /* * Note: that we do not search for deleted/recycled objects */ ret = dsdb_module_search(module, change, &res, change->dn, - LDB_SCOPE_SUBTREE, + scope, no_attrs, DSDB_FLAG_NEXT_MODULE | DSDB_FLAG_AS_SYSTEM, |