diff --git a/ctdb/common/cmdline.c b/ctdb/common/cmdline.c index 4753d8286bc..4995cc8de13 100644 --- a/ctdb/common/cmdline.c +++ b/ctdb/common/cmdline.c @@ -31,11 +31,13 @@ static struct { const char *transport; const char *myaddress; int self_connect; + const char *db_dir; } ctdb_cmdline = { .nlist = NULL, .transport = "tcp", .myaddress = NULL, .self_connect = 0, + .db_dir = "." }; @@ -45,6 +47,7 @@ struct poptOption popt_ctdb_cmdline[] = { { "transport", 0, POPT_ARG_STRING, &ctdb_cmdline.transport, 0, "protocol transport", NULL }, { "self-connect", 0, POPT_ARG_NONE, &ctdb_cmdline.self_connect, 0, "enable self connect", "boolean" }, { "debug", 'd', POPT_ARG_INT, &LogLevel, 0, "debug level"}, + { "dbdir", 0, POPT_ARG_STRING, &ctdb_cmdline.db_dir, 0, "directory for the tdb files", NULL }, { NULL } }; @@ -93,5 +96,11 @@ struct ctdb_context *ctdb_cmdline_init(struct event_context *ev) exit(1); } + ret = ctdb_set_tdb_dir(ctdb, ctdb_cmdline.db_dir); + if (ret == -1) { + printf("ctdb_set_tdb_dir failed - %s\n", ctdb_errstr(ctdb)); + exit(1); + } + return ctdb; } diff --git a/ctdb/common/ctdb.c b/ctdb/common/ctdb.c index de7a36f0c47..691d0b30628 100644 --- a/ctdb/common/ctdb.c +++ b/ctdb/common/ctdb.c @@ -73,6 +73,18 @@ void ctdb_set_max_lacount(struct ctdb_context *ctdb, unsigned count) ctdb->max_lacount = count; } +/* + set the directory for the local databases +*/ +int ctdb_set_tdb_dir(struct ctdb_context *ctdb, const char *dir) +{ + ctdb->db_directory = talloc_strdup(ctdb, dir); + if (ctdb->db_directory == NULL) { + return -1; + } + return 0; +} + /* add a node to the list of active nodes */ diff --git a/ctdb/common/ctdb_ltdb.c b/ctdb/common/ctdb_ltdb.c index 1d34d90e2ed..63a1e22d496 100644 --- a/ctdb/common/ctdb_ltdb.c +++ b/ctdb/common/ctdb_ltdb.c @@ -84,7 +84,7 @@ struct ctdb_db_context *ctdb_attach(struct ctdb_context *ctdb, const char *name, /* add the node id to the database name, so when we run on loopback we don't conflict in the local filesystem */ - name = talloc_asprintf(ctdb_db, "%s.%u", name, ctdb_get_vnn(ctdb)); + name = talloc_asprintf(ctdb_db, "%s/%s", ctdb->db_directory, name); /* when we have a separate daemon this will need to be a real file, not a TDB_INTERNAL, so the parent can access it to diff --git a/ctdb/include/ctdb.h b/ctdb/include/ctdb.h index a61b7518123..7339a56b2b7 100644 --- a/ctdb/include/ctdb.h +++ b/ctdb/include/ctdb.h @@ -71,6 +71,11 @@ struct ctdb_context *ctdb_init(struct event_context *ev); */ int ctdb_set_transport(struct ctdb_context *ctdb, const char *transport); +/* + set the directory for the local databases +*/ +int ctdb_set_tdb_dir(struct ctdb_context *ctdb, const char *dir); + /* set some flags */ diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h index 72ee5dadd66..36a6c8de5da 100644 --- a/ctdb/include/ctdb_private.h +++ b/ctdb/include/ctdb_private.h @@ -119,6 +119,7 @@ struct ctdb_context { struct event_context *ev; struct ctdb_address address; const char *name; + const char *db_directory; uint32_t vnn; /* our own vnn */ uint32_t num_nodes; uint32_t num_connected; @@ -460,4 +461,6 @@ struct ctdb_call_state *ctdb_daemon_call_send_remote(struct ctdb_db_context *ctd struct ctdb_call *call, struct ctdb_ltdb_header *header); +void ctdb_request_finished(struct ctdb_context *ctdb, struct ctdb_req_header *hdr); + #endif