1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

server: only do the mkdir() calls for db_directory* once at the start

metze

(This used to be ctdb commit f30f33685db50860b6cd6fd1b6bdc3066620a78f)
This commit is contained in:
Stefan Metzmacher 2009-11-29 12:39:23 +01:00
parent b48228e7f9
commit 9a96ae0c97
4 changed files with 52 additions and 25 deletions

View File

@ -1416,7 +1416,7 @@ int32_t ctdb_control_get_server_id_list(struct ctdb_context *ctdb,
int32_t ctdb_control_uptime(struct ctdb_context *ctdb,
TDB_DATA *outdata);
int ctdb_attach_persistent(struct ctdb_context *ctdb);
int ctdb_attach_databases(struct ctdb_context *ctdb);
int32_t ctdb_control_persistent_store(struct ctdb_context *ctdb,
struct ctdb_req_control *c,

View File

@ -764,9 +764,9 @@ int ctdb_start_daemon(struct ctdb_context *ctdb, bool do_fork, bool use_syslog)
ctdb_fatal(ctdb, "transport failed to initialise");
}
/* attach to any existing persistent databases */
if (ctdb_attach_persistent(ctdb) != 0) {
ctdb_fatal(ctdb, "Failed to attach to persistent databases\n");
/* attach to existing databases */
if (ctdb_attach_databases(ctdb) != 0) {
ctdb_fatal(ctdb, "Failed to attach to databases\n");
}
/* start frozen, then let the first election sort things out */

View File

@ -223,25 +223,6 @@ static int ctdb_local_attach(struct ctdb_context *ctdb, const char *db_name, boo
}
}
if (ctdb->db_directory == NULL) {
ctdb->db_directory = VARDIR "/ctdb";
}
/* make sure the db directory exists */
if (mkdir(ctdb->db_directory, 0700) == -1 && errno != EEXIST) {
DEBUG(DEBUG_CRIT,(__location__ " Unable to create ctdb directory '%s'\n",
ctdb->db_directory));
talloc_free(ctdb_db);
return -1;
}
if (persistent && mkdir(ctdb->db_directory_persistent, 0700) == -1 && errno != EEXIST) {
DEBUG(DEBUG_CRIT,(__location__ " Unable to create ctdb persistent directory '%s'\n",
ctdb->db_directory_persistent));
talloc_free(ctdb_db);
return -1;
}
/* open the database */
ctdb_db->db_path = talloc_asprintf(ctdb_db, "%s/%s.%u",
persistent?ctdb->db_directory_persistent:ctdb->db_directory,
@ -377,7 +358,7 @@ int32_t ctdb_control_db_attach(struct ctdb_context *ctdb, TDB_DATA indata,
/*
attach to all existing persistent databases
*/
int ctdb_attach_persistent(struct ctdb_context *ctdb)
static int ctdb_attach_persistent(struct ctdb_context *ctdb)
{
DIR *d;
struct dirent *de;
@ -432,6 +413,52 @@ int ctdb_attach_persistent(struct ctdb_context *ctdb)
return 0;
}
int ctdb_attach_databases(struct ctdb_context *ctdb)
{
int ret;
if (ctdb->db_directory == NULL) {
ctdb->db_directory = VARDIR "/ctdb";
}
if (ctdb->db_directory_persistent == NULL) {
ctdb->db_directory_persistent = VARDIR "/ctdb/persistent";
}
if (ctdb->db_directory_state == NULL) {
ctdb->db_directory_state = VARDIR "/ctdb/state";
}
/* make sure the db directory exists */
ret = mkdir(ctdb->db_directory, 0700);
if (ret == -1 && errno != EEXIST) {
DEBUG(DEBUG_CRIT,(__location__ " Unable to create ctdb directory '%s'\n",
ctdb->db_directory));
return -1;
}
/* make sure the persistent db directory exists */
ret = mkdir(ctdb->db_directory_persistent, 0700);
if (ret == -1 && errno != EEXIST) {
DEBUG(DEBUG_CRIT,(__location__ " Unable to create ctdb persistent directory '%s'\n",
ctdb->db_directory_persistent));
return -1;
}
/* make sure the internal state db directory exists */
ret = mkdir(ctdb->db_directory_state, 0700);
if (ret == -1 && errno != EEXIST) {
DEBUG(DEBUG_CRIT,(__location__ " Unable to create ctdb state directory '%s'\n",
ctdb->db_directory_state));
return -1;
}
ret = ctdb_attach_persistent(ctdb);
if (ret != 0) {
return ret;
}
return 0;
}
/*
called when a broadcast seqnum update comes in
*/

View File

@ -679,7 +679,7 @@ daemons_start_1 ()
echo "Node $no_public_ips will have no public IPs."
fi
local ctdb_options="--reclock=$var_dir/rec.lock --nlist $nodes --nopublicipcheck --event-script-dir=$CTDB_DIR/tests/events.d --logfile=$var_dir/daemons.log -d 0 --dbdir=$var_dir/test.db --dbdir-persistent=$var_dir/test.db/persistent"
local ctdb_options="--reclock=$var_dir/rec.lock --nlist $nodes --nopublicipcheck --event-script-dir=$CTDB_DIR/tests/events.d --logfile=$var_dir/daemons.log -d 0 --dbdir=$var_dir/test.db --dbdir-persistent=$var_dir/test.db/persistent --dbdir-state=$var_dir/test.db/state"
if [ $(id -u) -eq 0 ]; then
ctdb_options="$ctdb_options --public-interface=lo"