Commit 5939e55b authored by Philip Carns's avatar Philip Carns
Browse files

incorporate margo logging

parent 950ba473
...@@ -14,6 +14,15 @@ ...@@ -14,6 +14,15 @@
extern "C" { extern "C" {
#endif #endif
#define BAKE_TRACE(_mid, _format, f...) margo_trace(_mid, "bake: " _format, ##f)
#define BAKE_DEBUG(_mid, _format, f...) margo_debug(_mid, "bake: " _format, ##f)
#define BAKE_INFO(_mid, _format, f...) margo_info(_mid, "bake: " _format, ##f)
#define BAKE_WARNING(_mid, _format, f...) \
margo_warning(_mid, "bake: " _format, ##f)
#define BAKE_ERROR(_mid, _format, f...) margo_error(_mid, "bake: " _format, ##f)
#define BAKE_CRITICAL(_mid, _format, f...) \
margo_critical(_mid, "bake: " _format, ##f)
typedef struct { typedef struct {
uuid_t id; uuid_t id;
} bake_target_id_t; } bake_target_id_t;
......
...@@ -20,12 +20,12 @@ static int bake_register_provider(bedrock_args_t args, ...@@ -20,12 +20,12 @@ static int bake_register_provider(bedrock_args_t args,
const char* config = bedrock_args_get_config(args); const char* config = bedrock_args_get_config(args);
const char* name = bedrock_args_get_name(args); const char* name = bedrock_args_get_name(args);
printf("Registering a Bake provider\n"); BAKE_TRACE(mid, "bake_register_provider()");
printf(" -> mid = %p\n", (void*)mid); BAKE_INFO(mid, " -> mid = %p", (void*)mid);
printf(" -> provider id = %d\n", provider_id); BAKE_INFO(mid, " -> provider id = %d", provider_id);
printf(" -> pool = %p\n", (void*)pool); BAKE_INFO(mid, " -> pool = %p", (void*)pool);
printf(" -> config = %s\n", config); BAKE_INFO(mid, " -> config = %s", config);
printf(" -> name = %s\n", name); BAKE_INFO(mid, " -> name = %s", name);
bpargs.json_config = config; bpargs.json_config = config;
ret = bake_provider_register(mid, provider_id, &bpargs, ret = bake_provider_register(mid, provider_id, &bpargs,
...@@ -39,8 +39,6 @@ static int bake_deregister_provider(bedrock_module_provider_t provider) ...@@ -39,8 +39,6 @@ static int bake_deregister_provider(bedrock_module_provider_t provider)
{ {
int ret; int ret;
printf("Deregistering a Bake provider\n");
ret = bake_provider_destroy(provider); ret = bake_provider_destroy(provider);
if (ret < 0) return (-1); if (ret < 0) return (-1);
...@@ -57,8 +55,7 @@ static int bake_init_client(margo_instance_id mid, ...@@ -57,8 +55,7 @@ static int bake_init_client(margo_instance_id mid,
{ {
int ret; int ret;
printf("Registering a Bake client\n"); BAKE_TRACE(mid, "bake_init_client()");
printf(" -> mid = %p\n", (void*)mid);
ret = bake_client_init(mid, (bake_client_t*)client); ret = bake_client_init(mid, (bake_client_t*)client);
if (ret < 0) return (-1); if (ret < 0) return (-1);
...@@ -70,8 +67,6 @@ static int bake_finalize_client(bedrock_module_client_t client) ...@@ -70,8 +67,6 @@ static int bake_finalize_client(bedrock_module_client_t client)
{ {
int ret; int ret;
printf("Finalizing a Bake client\n");
ret = bake_client_finalize(client); ret = bake_client_finalize(client);
if (ret < 0) return (-1); if (ret < 0) return (-1);
...@@ -85,8 +80,6 @@ static int bake_create_provider_handle(bedrock_module_client_t client, ...@@ -85,8 +80,6 @@ static int bake_create_provider_handle(bedrock_module_client_t client,
{ {
int ret; int ret;
printf("Creating Bake provider handle\n");
ret = bake_provider_handle_create(client, address, provider_id, ret = bake_provider_handle_create(client, address, provider_id,
(bake_provider_handle_t*)ph); (bake_provider_handle_t*)ph);
if (ret < 0) return (-1); if (ret < 0) return (-1);
...@@ -98,7 +91,6 @@ static int bake_destroy_provider_handle(bedrock_module_provider_handle_t ph) ...@@ -98,7 +91,6 @@ static int bake_destroy_provider_handle(bedrock_module_provider_handle_t ph)
{ {
int ret; int ret;
printf("Destroying Bake provider handle\n");
ret = bake_provider_handle_release(ph); ret = bake_provider_handle_release(ph);
if (ret < 0) return (-1); if (ret < 0) return (-1);
......
...@@ -157,10 +157,10 @@ int bake_client_init(margo_instance_id mid, bake_client_t* client) ...@@ -157,10 +157,10 @@ int bake_client_init(margo_instance_id mid, bake_client_t* client)
int bake_client_finalize(bake_client_t client) int bake_client_finalize(bake_client_t client)
{ {
if (client->num_provider_handles != 0) { if (client->num_provider_handles != 0) {
fprintf(stderr, BAKE_WARNING(client->mid,
"[BAKE] Warning: %llu provider handles not released before " "%llu provider handles not released before "
"bake_client_finalize was called\n", "bake_client_finalize was called\n",
(long long unsigned int)client->num_provider_handles); (long long unsigned int)client->num_provider_handles);
} }
free(client); free(client);
return BAKE_SUCCESS; return BAKE_SUCCESS;
......
...@@ -175,13 +175,10 @@ static int bake_file_backend_initialize(bake_provider_t provider, ...@@ -175,13 +175,10 @@ static int bake_file_backend_initialize(bake_provider_t provider,
if (!json_object_get_boolean( if (!json_object_get_boolean(
json_object_object_get(provider->json_cfg, "pipeline_enable"))) { json_object_object_get(provider->json_cfg, "pipeline_enable"))) {
fprintf(stderr, "Error: The Bake file backend requires pipelining.\n"); BAKE_ERROR(provider->mid, "the bake file backend requires pipelining");
fprintf(stderr, BAKE_ERROR(provider->mid,
" Enable pipelining with -p on the bake-server-daemon " "please enable pipelining in the provider's json "
"command line or\n"); "configuration or with bake-server-daemon -p");
fprintf(stderr,
" programmatically with bake_provider_set_conf(provider, "
"\"pipeline_enabled\", \"1\")\n");
return (BAKE_ERR_INVALID_ARG); return (BAKE_ERR_INVALID_ARG);
} }
...@@ -219,8 +216,8 @@ static int bake_file_backend_initialize(bake_provider_t provider, ...@@ -219,8 +216,8 @@ static int bake_file_backend_initialize(bake_provider_t provider,
new_entry->log_fd new_entry->log_fd
= abt_io_open(new_entry->abtioi, path, O_RDWR | O_DIRECT, 0); = abt_io_open(new_entry->abtioi, path, O_RDWR | O_DIRECT, 0);
if (new_entry->log_fd < 0) { if (new_entry->log_fd < 0) {
fprintf(stderr, "open(): %s on %s\n", strerror(-new_entry->log_fd), BAKE_ERROR(provider->mid, "open(): %s on %s",
path); strerror(-new_entry->log_fd), path);
ret = BAKE_ERR_IO; ret = BAKE_ERR_IO;
goto error_cleanup; goto error_cleanup;
} }
...@@ -252,8 +249,7 @@ static int bake_file_backend_initialize(bake_provider_t provider, ...@@ -252,8 +249,7 @@ static int bake_file_backend_initialize(bake_provider_t provider,
*target = new_entry->file_root->pool_id; *target = new_entry->file_root->pool_id;
if (uuid_is_null(target->id)) { if (uuid_is_null(target->id)) {
fprintf(stderr, "Error: BAKE pool %s is not properly formatted\n", BAKE_ERROR(provider->mid, "pool %s is not properly formatted", path);
path);
ret = BAKE_ERR_IO; ret = BAKE_ERR_IO;
goto error_cleanup; goto error_cleanup;
} }
...@@ -262,16 +258,16 @@ static int bake_file_backend_initialize(bake_provider_t provider, ...@@ -262,16 +258,16 @@ static int bake_file_backend_initialize(bake_provider_t provider,
new_entry->log_alignment = json_object_get_int( new_entry->log_alignment = json_object_get_int(
json_object_object_get(file_backend_json, "alignment")); json_object_object_get(file_backend_json, "alignment"));
if (new_entry->log_alignment < 0) { if (new_entry->log_alignment < 0) {
fprintf(stderr, "Error: negative alignment %d\n", BAKE_ERROR(provider->mid, "negative alignment %d",
new_entry->log_alignment); new_entry->log_alignment);
ret = BAKE_ERR_INVALID_ARG; ret = BAKE_ERR_INVALID_ARG;
goto error_cleanup; goto error_cleanup;
} }
if (!(((unsigned)new_entry->log_alignment if (!(((unsigned)new_entry->log_alignment
& ((unsigned)new_entry->log_alignment - 1)) & ((unsigned)new_entry->log_alignment - 1))
== 0)) { == 0)) {
fprintf(stderr, "Error: alignment %d is not a power of 2 or zero\n", BAKE_ERROR(provider->mid, "alignment %d is not a power of 2 or zero",
new_entry->log_alignment); new_entry->log_alignment);
ret = BAKE_ERR_INVALID_ARG; ret = BAKE_ERR_INVALID_ARG;
goto error_cleanup; goto error_cleanup;
} }
...@@ -281,9 +277,9 @@ static int bake_file_backend_initialize(bake_provider_t provider, ...@@ -281,9 +277,9 @@ static int bake_file_backend_initialize(bake_provider_t provider,
*/ */
json_object_array_add(target_array, json_object_new_string(path)); json_object_array_add(target_array, json_object_new_string(path));
fprintf(stderr, BAKE_WARNING(provider->mid,
"WARNING: Bake file backend does not yet support the following:\n"); "bake file backend does not yet support the following:");
fprintf(stderr, " * writes to non-zero region offsets\n"); BAKE_WARNING(provider->mid, " * writes to non-zero region offsets");
*context = new_entry; *context = new_entry;
return 0; return 0;
...@@ -395,9 +391,9 @@ static int bake_file_write_raw(backend_context_t context, ...@@ -395,9 +391,9 @@ static int bake_file_write_raw(backend_context_t context,
* write offsets are aligned. * write offsets are aligned.
*/ */
if (offset != 0) { if (offset != 0) {
fprintf(stderr, BAKE_ERROR(entry->provider->mid,
"Error: Bake file backend does not yet support unaligned " "bake file backend does not yet support writes to non-zero "
"writes.\n"); "region offsets");
return (BAKE_ERR_OP_UNSUPPORTED); return (BAKE_ERR_OP_UNSUPPORTED);
} }
...@@ -446,9 +442,9 @@ static int bake_file_write_bulk(backend_context_t context, ...@@ -446,9 +442,9 @@ static int bake_file_write_bulk(backend_context_t context,
* write offsets are aligned. * write offsets are aligned.
*/ */
if (region_offset != 0) { if (region_offset != 0) {
fprintf(stderr, BAKE_ERROR(entry->provider->mid,
"Error: Bake file backend does not yet support unaligned " "bake file backend does not yet support writes to non-zero "
"writes.\n"); "region offsets");
return (BAKE_ERR_OP_UNSUPPORTED); return (BAKE_ERR_OP_UNSUPPORTED);
} }
......
...@@ -102,7 +102,7 @@ static int bake_pmem_backend_initialize(bake_provider_t provider, ...@@ -102,7 +102,7 @@ static int bake_pmem_backend_initialize(bake_provider_t provider,
new_context->pmem_pool = pmemobj_open(path, NULL); new_context->pmem_pool = pmemobj_open(path, NULL);
if (!(new_context->pmem_pool)) { if (!(new_context->pmem_pool)) {
fprintf(stderr, "pmemobj_open: %s\n", pmemobj_errormsg()); BAKE_ERROR(provider->mid, "pmemobj_open: %s", pmemobj_errormsg());
free(new_context->filename); free(new_context->filename);
free(new_context->root); free(new_context->root);
free(new_context); free(new_context);
...@@ -116,8 +116,7 @@ static int bake_pmem_backend_initialize(bake_provider_t provider, ...@@ -116,8 +116,7 @@ static int bake_pmem_backend_initialize(bake_provider_t provider,
bake_target_id_t tid = new_context->pmem_root->pool_id; bake_target_id_t tid = new_context->pmem_root->pool_id;
if (uuid_is_null(tid.id)) { if (uuid_is_null(tid.id)) {
fprintf(stderr, "Error: BAKE pool %s is not properly initialized\n", BAKE_ERROR(provider->mid, "pool %s is not properly initialized", path);
path);
pmemobj_close(new_context->pmem_pool); pmemobj_close(new_context->pmem_pool);
free(new_context->filename); free(new_context->filename);
free(new_context->root); free(new_context->root);
......
...@@ -85,10 +85,11 @@ int bake_provider_register(margo_instance_id mid, ...@@ -85,10 +85,11 @@ int bake_provider_register(margo_instance_id mid,
margo_provider_registered_name(mid, "bake_probe_rpc", provider_id, &id, margo_provider_registered_name(mid, "bake_probe_rpc", provider_id, &id,
&flag); &flag);
if (flag == HG_TRUE) { if (flag == HG_TRUE) {
fprintf(stderr, BAKE_ERROR(
"bake_provider_register(): a BAKE provider with the same " mid,
"id (%d) already exists\n", "bake_provider_register(): a bake provider with the same "
provider_id); "id (%d) already exists",
provider_id);
return BAKE_ERR_MERCURY; return BAKE_ERR_MERCURY;
} }
} }
...@@ -102,8 +103,8 @@ int bake_provider_register(margo_instance_id mid, ...@@ -102,8 +103,8 @@ int bake_provider_register(margo_instance_id mid,
strlen(args.json_config)); strlen(args.json_config));
if (!config) { if (!config) {
jerr = json_tokener_get_error(tokener); jerr = json_tokener_get_error(tokener);
fprintf(stderr, "JSON parse error: %s", BAKE_ERROR(mid, "JSON parse error: %s",
json_tokener_error_desc(jerr)); json_tokener_error_desc(jerr));
json_tokener_free(tokener); json_tokener_free(tokener);
return BAKE_ERR_INVALID_ARG; return BAKE_ERR_INVALID_ARG;
} }
...@@ -116,7 +117,7 @@ int bake_provider_register(margo_instance_id mid, ...@@ -116,7 +117,7 @@ int bake_provider_register(margo_instance_id mid,
/* validate and complete configuration */ /* validate and complete configuration */
ret = validate_and_complete_config(config, args.rpc_pool); ret = validate_and_complete_config(config, args.rpc_pool);
if (ret != 0) { if (ret != 0) {
fprintf(stderr, "Could not validate and complete configuration"); BAKE_ERROR(mid, "could not validate and complete configuration");
json_object_put(config); json_object_put(config);
return BAKE_ERR_INVALID_ARG; return BAKE_ERR_INVALID_ARG;
} }
...@@ -136,7 +137,7 @@ int bake_provider_register(margo_instance_id mid, ...@@ -136,7 +137,7 @@ int bake_provider_register(margo_instance_id mid,
ret = setup_poolset(tmp_provider); ret = setup_poolset(tmp_provider);
if (ret != 0) { if (ret != 0) {
fprintf(stderr, "Could not create poolset for pipelining"); BAKE_ERROR(mid, "could not create poolset for pipelining");
json_object_put(config); json_object_put(config);
free(tmp_provider); free(tmp_provider);
return ret; return ret;
...@@ -346,7 +347,7 @@ int bake_provider_add_storage_target(bake_provider_t provider, ...@@ -346,7 +347,7 @@ int bake_provider_add_storage_target(bake_provider_t provider,
} else if (strcmp(backend_type, "file") == 0) { } else if (strcmp(backend_type, "file") == 0) {
new_entry->backend = &g_bake_file_backend; new_entry->backend = &g_bake_file_backend;
} else { } else {
fprintf(stderr, "ERROR: unknown backend type \"%s\"\n", backend_type); BAKE_ERROR(provider->mid, "unknown backend type \"%s\"", backend_type);
free(backend_type); free(backend_type);
return BAKE_ERR_BACKEND_TYPE; return BAKE_ERR_BACKEND_TYPE;
} }
...@@ -370,8 +371,8 @@ int bake_provider_add_storage_target(bake_provider_t provider, ...@@ -370,8 +371,8 @@ int bake_provider_add_storage_target(bake_provider_t provider,
HASH_FIND(hh, provider->targets, &tid, sizeof(bake_target_id_t), HASH_FIND(hh, provider->targets, &tid, sizeof(bake_target_id_t),
check_entry); check_entry);
if (check_entry != new_entry) { if (check_entry != new_entry) {
fprintf(stderr, BAKE_ERROR(provider->mid,
"Error: BAKE could not insert new pmem pool into the hash\n"); "could not insert new pmem pool into the hash");
new_entry->backend->_finalize(ctx); new_entry->backend->_finalize(ctx);
free(new_entry); free(new_entry);
ret = BAKE_ERR_ALLOCATION; ret = BAKE_ERR_ALLOCATION;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment