diff options
author | Jakub Hrozek <jhrozek@redhat.com> | 2016-04-29 17:51:49 +0200 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2016-06-23 13:47:16 +0200 |
commit | 40de79d69860ec7f04bf7795bd88b641ec42fd23 (patch) | |
tree | be738e89fc954188e4e9ea19403065fb76f059ed /src/db/sysdb_ops.c | |
parent | a257259b05d62ebe548b6c798a3aa03a97dbc0c2 (diff) | |
download | sssd-40de79d69860ec7f04bf7795bd88b641ec42fd23.tar.gz sssd-40de79d69860ec7f04bf7795bd88b641ec42fd23.tar.xz sssd-40de79d69860ec7f04bf7795bd88b641ec42fd23.zip |
SYSDB: Check if group attributes differ before saving a group
Adds a new function sysdb_entry_attrs_diff() used in group saving code.
This function is used to check if the result of updating a group would
result in actually changing the sysdb entry -- often, we would try to
dump the same data to the cache during update. If that's the case, the
update code now only updates the timestamp cache, avoiding costly
writes.
Reviewed-by: Sumit Bose <sbose@redhat.com>
Diffstat (limited to 'src/db/sysdb_ops.c')
-rw-r--r-- | src/db/sysdb_ops.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/db/sysdb_ops.c b/src/db/sysdb_ops.c index 4ea0d0ad7..eca6ca1d9 100644 --- a/src/db/sysdb_ops.c +++ b/src/db/sysdb_ops.c @@ -1172,10 +1172,15 @@ int sysdb_set_entry_attr(struct sysdb_ctx *sysdb, struct sysdb_attrs *attrs, int mod_op) { + bool sysdb_write = true; errno_t ret = EOK; errno_t tret = EOK; - ret = sysdb_set_cache_entry_attr(sysdb->ldb, entry_dn, attrs, mod_op); + sysdb_write = sysdb_entry_attrs_diff(sysdb, entry_dn, attrs, mod_op); + if (sysdb_write == true) { + ret = sysdb_set_cache_entry_attr(sysdb->ldb, entry_dn, attrs, mod_op); + } + if (ret == EOK) { tret = sysdb_set_ts_entry_attr(sysdb, entry_dn, attrs, mod_op); if (tret != EOK) { @@ -2563,6 +2568,7 @@ static errno_t sysdb_store_new_group(struct sss_domain_info *domain, static errno_t sysdb_store_group_attrs(struct sss_domain_info *domain, const char *name, gid_t gid, + struct ldb_message *cached_group, struct sysdb_attrs *attrs, uint64_t cache_timeout, time_t now); @@ -2575,7 +2581,7 @@ int sysdb_store_group(struct sss_domain_info *domain, time_t now) { TALLOC_CTX *tmp_ctx; - static const char *src_attrs[] = { SYSDB_NAME, SYSDB_GIDNUM, NULL }; + static const char *src_attrs[] = { "*", NULL }; struct ldb_message *msg; bool new_group = false; int ret; @@ -2628,13 +2634,12 @@ int sysdb_store_group(struct sss_domain_info *domain, now = time(NULL); } - /* FIXME: use the remote modification timestamp to know if the - * group needs any update */ - if (new_group) { - ret = sysdb_store_new_group(domain, name, gid, attrs, cache_timeout, now); + ret = sysdb_store_new_group(domain, name, gid, attrs, + cache_timeout, now); } else { - ret = sysdb_store_group_attrs(domain, name, gid, attrs, cache_timeout, now); + ret = sysdb_store_group_attrs(domain, name, gid, msg, attrs, + cache_timeout, now); } if (ret != EOK) { DEBUG(SSSDBG_OP_FAILURE, "Cache update failed: %d\n", ret); @@ -2713,6 +2718,7 @@ static errno_t sysdb_store_new_group(struct sss_domain_info *domain, static errno_t sysdb_store_group_attrs(struct sss_domain_info *domain, const char *name, gid_t gid, + struct ldb_message *cached_group, struct sysdb_attrs *attrs, uint64_t cache_timeout, time_t now) |