Skip to content

Commit

Permalink
Fix container tag delete error
Browse files Browse the repository at this point in the history
  • Loading branch information
houjun committed Jul 18, 2023
1 parent 8259f51 commit 03496c2
Show file tree
Hide file tree
Showing 4 changed files with 144 additions and 98 deletions.
130 changes: 73 additions & 57 deletions src/api/pdc_client_connect.c
Original file line number Diff line number Diff line change
Expand Up @@ -7061,12 +7061,16 @@ metadata_get_kvtag_rpc_cb(const struct hg_cb_info *callback_info)
pdc_client_mpi_rank_g);
}
client_lookup_args->ret = output.ret;
client_lookup_args->kvtag->name = strdup(output.kvtag.name);
if (output.kvtag.name)
client_lookup_args->kvtag->name = strdup(output.kvtag.name);
client_lookup_args->kvtag->size = output.kvtag.size;
client_lookup_args->kvtag->type = output.kvtag.type;
client_lookup_args->kvtag->value = malloc(output.kvtag.size);
memcpy(client_lookup_args->kvtag->value, output.kvtag.value, output.kvtag.size);
/* PDC_kvtag_dup(&(output.kvtag), &client_lookup_args->kvtag); */
if (output.kvtag.size > 0) {
client_lookup_args->kvtag->value = malloc(output.kvtag.size);
memcpy(client_lookup_args->kvtag->value, output.kvtag.value, output.kvtag.size);
}
else
client_lookup_args->kvtag->value = NULL;

done:
fflush(stdout);
Expand Down Expand Up @@ -7139,55 +7143,6 @@ PDC_get_kvtag(pdcid_t obj_id, char *tag_name, pdc_kvtag_t **kvtag, int is_cont)
FUNC_LEAVE(ret_value);
}

perr_t
PDCtag_delete(pdcid_t obj_id, char *tag_name)
{
perr_t ret_value = SUCCEED;
hg_return_t hg_ret = 0;
uint64_t meta_id;
uint32_t server_id;
hg_handle_t metadata_del_kvtag_handle;
metadata_get_kvtag_in_t in;
struct _pdc_obj_info * obj_prop;
struct _pdc_client_lookup_args lookup_args;

FUNC_ENTER(NULL);

obj_prop = PDC_obj_get_info(obj_id);
meta_id = obj_prop->obj_info_pub->meta_id;
server_id = PDC_get_server_by_obj_id(meta_id, pdc_server_num_g);

debug_server_id_count[server_id]++;

if (PDC_Client_try_lookup_server(server_id, 0) != SUCCEED)
PGOTO_ERROR(FAIL, "==CLIENT[%d]: ERROR with PDC_Client_try_lookup_server", pdc_client_mpi_rank_g);

HG_Create(send_context_g, pdc_server_info_g[server_id].addr, metadata_del_kvtag_register_id_g,
&metadata_del_kvtag_handle);

// Fill input structure
in.obj_id = meta_id;
in.hash_value = PDC_get_hash_by_name(obj_prop->obj_info_pub->name);
in.key = tag_name;

hg_ret = HG_Forward(metadata_del_kvtag_handle, metadata_add_tag_rpc_cb /*reuse*/, &lookup_args, &in);
if (hg_ret != HG_SUCCESS)
PGOTO_ERROR(FAIL, "PDC_Client_del_kvtag_metadata_with_name(): Could not start HG_Forward()");

// Wait for response from server
work_todo_g = 1;
PDC_Client_check_response(&send_context_g);

if (lookup_args.ret != 1)
printf("PDC_CLIENT: del kvtag NOT successful ... ret_value = %d\n", lookup_args.ret);

done:
fflush(stdout);
HG_Destroy(metadata_del_kvtag_handle);

FUNC_LEAVE(ret_value);
}

static hg_return_t
kvtag_query_bulk_cb(const struct hg_cb_info *hg_cb_info)
{
Expand Down Expand Up @@ -7454,6 +7409,68 @@ PDC_Client_query_kvtag_col(const pdc_kvtag_t *kvtag, int *n_res, uint64_t **pdc_
FUNC_LEAVE(ret_value);
}

perr_t
PDCtag_delete(pdcid_t obj_id, char *tag_name, int is_cont)
{
perr_t ret_value = SUCCEED;
hg_return_t hg_ret = 0;
uint64_t meta_id;
uint32_t server_id;
hg_handle_t metadata_del_kvtag_handle;
metadata_get_kvtag_in_t in;
struct _pdc_obj_info * obj_prop;
struct _pdc_cont_info * cont_prop;
struct _pdc_client_lookup_args lookup_args;

FUNC_ENTER(NULL);

if (is_cont) {
cont_prop = PDC_cont_get_info(obj_id);
meta_id = cont_prop->cont_info_pub->meta_id;
}
else {
obj_prop = PDC_obj_get_info(obj_id);
meta_id = obj_prop->obj_info_pub->meta_id;
}

server_id = PDC_get_server_by_obj_id(meta_id, pdc_server_num_g);

debug_server_id_count[server_id]++;

if (PDC_Client_try_lookup_server(server_id, 0) != SUCCEED)
PGOTO_ERROR(FAIL, "==CLIENT[%d]: ERROR with PDC_Client_try_lookup_server", pdc_client_mpi_rank_g);

HG_Create(send_context_g, pdc_server_info_g[server_id].addr, metadata_del_kvtag_register_id_g,
&metadata_del_kvtag_handle);

// Fill input structure
in.obj_id = meta_id;

if (is_cont)
in.hash_value = PDC_get_hash_by_name(cont_prop->cont_info_pub->name);
else
in.hash_value = PDC_get_hash_by_name(obj_prop->obj_info_pub->name);
in.key = tag_name;

hg_ret = HG_Forward(metadata_del_kvtag_handle, metadata_add_tag_rpc_cb /*reuse*/, &lookup_args, &in);
if (hg_ret != HG_SUCCESS)
PGOTO_ERROR(FAIL, "PDC_Client_del_kvtag_metadata_with_name(): Could not start HG_Forward()");

// Wait for response from server
work_todo_g = 1;
PDC_Client_check_response(&send_context_g);

if (lookup_args.ret != 1)
printf("PDC_CLIENT: del kvtag NOT successful ... ret_value = %d\n", lookup_args.ret);

done:
fflush(stdout);
HG_Destroy(metadata_del_kvtag_handle);

FUNC_LEAVE(ret_value);
}


/* - -------------------------------- */
/* New Simple Object Access Interface */
/* - -------------------------------- */
Expand Down Expand Up @@ -7483,7 +7500,6 @@ PDCcont_put(const char *cont_name, pdcid_t pdc)
}

pdcid_t

PDCcont_get_id(const char *cont_name, pdcid_t pdc_id)
{
pdcid_t cont_id;
Expand Down Expand Up @@ -7633,9 +7649,9 @@ PDCcont_del_tag(pdcid_t cont_id, char *tag_name)

FUNC_ENTER(NULL);

ret_value = PDCobj_del_tag(cont_id, tag_name);
ret_value = PDCtag_delete(cont_id, tag_name, 1);
if (ret_value != SUCCEED)
PGOTO_ERROR(FAIL, "==PDC_CLIENT[%d]: error with PDCobj_del_tag", pdc_client_mpi_rank_g);
PGOTO_ERROR(FAIL, "==PDC_CLIENT[%d]: error with PDCtag_delete", pdc_client_mpi_rank_g);

done:
fflush(stdout);
Expand Down Expand Up @@ -7831,7 +7847,7 @@ PDCobj_del_tag(pdcid_t obj_id, char *tag_name)

FUNC_ENTER(NULL);

ret_value = PDCtag_delete(obj_id, tag_name);
ret_value = PDCtag_delete(obj_id, tag_name, 0);
if (ret_value != SUCCEED)
PGOTO_ERROR(FAIL, "==PDC_CLIENT[%d]: Error with PDC_del_kvtag", pdc_client_mpi_rank_g);

Expand Down
10 changes: 0 additions & 10 deletions src/api/pdc_obj/include/pdc_prop.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,6 @@ struct pdc_obj_prop *PDCobj_prop_get_info(pdcid_t prop_id);
*/
perr_t PDCprop_update(pdcid_t obj_id, pdcid_t prop_id);

/**
* Delete a tag with a specific name and value
*
* \param obj_id[IN] Object ID
* \param tag_name [IN] Metadta field name
*
* \return Non-negative on success/Negative on failure
*/
perr_t PDCtag_delete(pdcid_t obj_id, char *tag_name);

/**
* **********
*
Expand Down
31 changes: 20 additions & 11 deletions src/server/pdc_server_metadata.c
Original file line number Diff line number Diff line change
Expand Up @@ -2779,6 +2779,7 @@ PDC_Server_del_kvtag(metadata_get_kvtag_in_t *in, metadata_add_tag_out_t *out)
int unlocked;
#endif
pdc_hash_table_entry_head *lookup_value;
pdc_cont_hash_table_entry_t *cont_lookup_value;

FUNC_ENTER(NULL);

Expand All @@ -2798,23 +2799,31 @@ PDC_Server_del_kvtag(metadata_get_kvtag_in_t *in, metadata_add_tag_out_t *out)
hg_thread_mutex_lock(&pdc_metadata_hash_table_mutex_g);
#endif

lookup_value = hash_table_lookup(metadata_hash_table_g, &hash_key);
if (lookup_value != NULL) {
pdc_metadata_t *target;
target = find_metadata_by_id_from_list(lookup_value->metadata, obj_id);
if (target != NULL) {
PDC_del_kvtag_value_from_list(&target->kvtag_list_head, in->key);
out->ret = 1;
// Look cont tags first
cont_lookup_value = hash_table_lookup(container_hash_table_g, &hash_key);
if (cont_lookup_value != NULL) {
PDC_del_kvtag_value_from_list(&cont_lookup_value->kvtag_list_head, in->key);
out->ret = 1;
}
else {
lookup_value = hash_table_lookup(metadata_hash_table_g, &hash_key);
if (lookup_value != NULL) {
pdc_metadata_t *target;
target = find_metadata_by_id_from_list(lookup_value->metadata, obj_id);
if (target != NULL) {
PDC_del_kvtag_value_from_list(&target->kvtag_list_head, in->key);
out->ret = 1;
}
else {
ret_value = FAIL;
out->ret = -1;
}
}
else {
ret_value = FAIL;
out->ret = -1;
}
}
else {
ret_value = FAIL;
out->ret = -1;
}

if (ret_value != SUCCEED) {
printf("==PDC_SERVER[%d]: %s - error \n", pdc_server_rank_g, __func__);
Expand Down
Loading

0 comments on commit 03496c2

Please sign in to comment.