int ldbm_instance_delete_instance_entry_callback(Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry* entryAfter, int *returncode, char *returntext, void *arg) { char *instance_name; struct ldbminfo *li = (struct ldbminfo *)arg; struct ldbm_instance *inst = NULL; parse_ldbm_instance_entry(entryBefore, &instance_name); inst = ldbm_instance_find_by_name(li, instance_name); if (inst == NULL) { LDAPDebug(LDAP_DEBUG_ANY, "ldbm: instance '%s' does not exist!\n", instance_name, 0, 0); if (returntext) { PR_snprintf(returntext, SLAPI_DSE_RETURNTEXT_SIZE, "No ldbm instance exists with the name '%s'\n", instance_name); } if (returncode) { *returncode = LDAP_UNWILLING_TO_PERFORM; } slapi_ch_free((void **)&instance_name); return SLAPI_DSE_CALLBACK_ERROR; } /* check if some online task is happening */ if ((instance_set_busy(inst) != 0) || (slapi_counter_get_value(inst->inst_ref_count) > 0)) { LDAPDebug(LDAP_DEBUG_ANY, "ldbm: '%s' is in the middle of a task. " "Cancel the task or wait for it to finish, " "then try again.\n", instance_name, 0, 0); if (returntext) { PR_snprintf(returntext, SLAPI_DSE_RETURNTEXT_SIZE, "ldbm instance '%s' is in the middle of a " "task. Cancel the task or wait for it to finish, " "then try again.\n", instance_name); } if (returncode) { *returncode = LDAP_UNWILLING_TO_PERFORM; } slapi_ch_free((void **)&instance_name); return SLAPI_DSE_CALLBACK_ERROR; } /* okay, we're gonna delete this database instance. take it offline. */ LDAPDebug(LDAP_DEBUG_ANY, "ldbm: Bringing %s offline...\n", instance_name, 0, 0); slapi_mtn_be_stopping(inst->inst_be); dblayer_instance_close(inst->inst_be); slapi_ch_free((void **)&instance_name); return SLAPI_DSE_CALLBACK_OK; }
void allinstance_set_busy(struct ldbminfo *li) { ldbm_instance *inst; Object *inst_obj; /* server is up -- mark all backends busy */ for (inst_obj = objset_first_obj(li->li_instance_set); inst_obj; inst_obj = objset_next_obj(li->li_instance_set, inst_obj)) { inst = (ldbm_instance *)object_get_data(inst_obj); if (instance_set_busy(inst)) { LDAPDebug1Arg(LDAP_DEBUG_TRACE, "could not set instance [%s] as busy, probably already busy\n", inst->inst_name); } } }
int ldbm_back_dbverify( Slapi_PBlock *pb ) { struct ldbminfo *li = NULL; Object *inst_obj = NULL; ldbm_instance *inst = NULL; int verbose = 0; int rval = 1; int rval_main = 0; char **instance_names = NULL; char *dbdir = NULL; slapi_log_err(SLAPI_LOG_TRACE, "ldbm_back_dbverify", "Verifying db files...\n"); slapi_pblock_get(pb, SLAPI_BACKEND_INSTANCE_NAME, &instance_names); slapi_pblock_get(pb, SLAPI_SEQ_TYPE, &verbose); slapi_pblock_get(pb, SLAPI_PLUGIN_PRIVATE, &li); slapi_pblock_get(pb, SLAPI_DBVERIFY_DBDIR, &dbdir); ldbm_config_load_dse_info(li); ldbm_config_internal_set(li, CONFIG_DB_TRANSACTION_LOGGING, "off"); /* no write needed; choose EXPORT MODE */ if (0 != dblayer_start(li, DBLAYER_EXPORT_MODE)) { slapi_log_err(SLAPI_LOG_ERR, "ldbm_back_dbverify", "dbverify: Failed to init database\n"); return rval; } /* server is up */ slapi_log_err(SLAPI_LOG_TRACE, "ldbm_back_dbverify", "server is up\n"); if (instance_names) /* instance is specified */ { char **inp = NULL; for (inp = instance_names; inp && *inp; inp++) { inst = ldbm_instance_find_by_name(li, *inp); if (inst) { if (dbdir){ /* verifying backup */ slapi_ch_free_string(&inst->inst_parent_dir_name); inst->inst_parent_dir_name = slapi_ch_strdup(dbdir); } rval_main |= dbverify_ext(inst, verbose); } else { rval_main |= 1; /* no such instance */ } } } else /* all instances */ { for (inst_obj = objset_first_obj(li->li_instance_set); inst_obj; inst_obj = objset_next_obj(li->li_instance_set, inst_obj)) { inst = (ldbm_instance *)object_get_data(inst_obj); /* check if an import/restore is already ongoing... */ if (instance_set_busy(inst) != 0) { /* standalone, only. never happens */ slapi_log_err(SLAPI_LOG_WARNING, "ldbm_back_dbverify", "Backend '%s' is already in the middle of " "another task and cannot be disturbed.\n", inst->inst_name); continue; /* skip this instance and go to the next*/ } if (dbdir){ /* verifying backup */ slapi_ch_free_string(&inst->inst_parent_dir_name); inst->inst_parent_dir_name = slapi_ch_strdup(dbdir); } rval_main |= dbverify_ext(inst, verbose); } } /* close the database down again */ rval = dblayer_post_close(li, DBLAYER_EXPORT_MODE); if (0 != rval) { slapi_log_err(SLAPI_LOG_ERR, "ldbm_back_dbverify", "Failed to close database\n"); } return rval_main; }