From c36d5d56e62f879dbc1c58155097dfc26746a7f4 Mon Sep 17 00:00:00 2001 From: Sumit Bose Date: Tue, 14 Nov 2017 13:09:18 +0100 Subject: [PATCH 56/57] sysdb: do not use LDB_SCOPE_ONELEVEL MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently the index for one-level searches is a huge blob which maps all parents with all it children. Handling this blob is costly and since all searches using LDB_SCOPE_ONELEVEL also have a filter with indexed attributes a sub-tree search would be more efficient. But since libldb currently first looks at the scope and hence use the one-level index blob we have to explicitly use LDB_SCOPE_SUBTREE in the callers to use the more efficient attribute based inxed. Related to https://pagure.io/SSSD/sssd/issue/3503 Reviewed-by: Jakub Hrozek Reviewed-by: Fabiano FidĂȘncio (cherry picked from commit 98195e591c4d97caa6125e8214879660b740973f) --- src/db/sysdb_autofs.c | 2 +- src/db/sysdb_ranges.c | 2 +- src/db/sysdb_subdomains.c | 2 +- src/responder/ifp/ifp_users.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/db/sysdb_autofs.c b/src/db/sysdb_autofs.c index b3e9b4ec83b66ec65a72ab7a3180106e2293d8a5..89803a778c370c899611ee5e15b7ae1a48e82cb9 100644 --- a/src/db/sysdb_autofs.c +++ b/src/db/sysdb_autofs.c @@ -384,7 +384,7 @@ sysdb_autofs_entries_by_map(TALLOC_CTX *mem_ctx, goto done; } - ret = sysdb_search_entry(tmp_ctx, domain->sysdb, mapdn, LDB_SCOPE_ONELEVEL, + ret = sysdb_search_entry(tmp_ctx, domain->sysdb, mapdn, LDB_SCOPE_SUBTREE, filter, attrs, &count, &msgs); if (ret != EOK && ret != ENOENT) { DEBUG(SSSDBG_OP_FAILURE, "sysdb search failed: %d\n", ret); diff --git a/src/db/sysdb_ranges.c b/src/db/sysdb_ranges.c index 511e4785d9aa68b2a33b440e1c5ee62e5ccf7ce4..be3a0d37220f833d27417808ddfef0e74c0ba9b2 100644 --- a/src/db/sysdb_ranges.c +++ b/src/db/sysdb_ranges.c @@ -71,7 +71,7 @@ errno_t sysdb_get_ranges(TALLOC_CTX *mem_ctx, struct sysdb_ctx *sysdb, goto done; } ret = ldb_search(sysdb->ldb, tmp_ctx, &res, - basedn, LDB_SCOPE_ONELEVEL, + basedn, LDB_SCOPE_SUBTREE, attrs, "objectclass=%s", SYSDB_ID_RANGE_CLASS); if (ret != LDB_SUCCESS) { ret = EIO; diff --git a/src/db/sysdb_subdomains.c b/src/db/sysdb_subdomains.c index 353561765904efe4bd698c38949a1b290ecf0b80..0dd05c24c963f12a28ef6f6b64dc40faa7fcc649 100644 --- a/src/db/sysdb_subdomains.c +++ b/src/db/sysdb_subdomains.c @@ -338,7 +338,7 @@ errno_t sysdb_update_subdomains(struct sss_domain_info *domain, goto done; } ret = ldb_search(domain->sysdb->ldb, tmp_ctx, &res, - basedn, LDB_SCOPE_ONELEVEL, + basedn, LDB_SCOPE_SUBTREE, attrs, "objectclass=%s", SYSDB_SUBDOMAIN_CLASS); if (ret != LDB_SUCCESS) { ret = EIO; diff --git a/src/responder/ifp/ifp_users.c b/src/responder/ifp/ifp_users.c index cb342a245ef6545168a7a60c252505f50576fdf7..f66587b8cf81a555dd1cb7aff12e0c8347c250b1 100644 --- a/src/responder/ifp/ifp_users.c +++ b/src/responder/ifp/ifp_users.c @@ -1449,7 +1449,7 @@ void ifp_users_user_get_extra_attributes(struct sbus_request *sbus_req, } ret = sysdb_search_entry(sbus_req, domain->sysdb, basedn, - LDB_SCOPE_ONELEVEL, filter, + LDB_SCOPE_SUBTREE, filter, extra, &count, &user); if (ret != EOK) { DEBUG(SSSDBG_CRIT_FAILURE, "Unable to lookup user [%d]: %s\n", -- 2.14.3