diff options
author | Mohamad Chaarawi <chaarawi@hdfgroup.org> | 2013-12-14 15:46:26 (GMT) |
---|---|---|
committer | Mohamad Chaarawi <chaarawi@hdfgroup.org> | 2013-12-14 15:46:26 (GMT) |
commit | f86006449772c00f68adadd0323015f3b7e4a935 (patch) | |
tree | 99709e84843b29f83bef1142b5d692df339b9974 | |
parent | 221190f1ff07be2a7924b4cf104c1b2098266266 (diff) | |
download | hdf5-f86006449772c00f68adadd0323015f3b7e4a935.zip hdf5-f86006449772c00f68adadd0323015f3b7e4a935.tar.gz hdf5-f86006449772c00f68adadd0323015f3b7e4a935.tar.bz2 |
[svn-r24554] fixes to creates/deletes as transaction is aborted.
-rw-r--r-- | examples/h5ff_client_dset.c | 24 | ||||
-rw-r--r-- | src/H5VLiod_attr.c | 74 | ||||
-rw-r--r-- | src/H5VLiod_dset.c | 40 | ||||
-rw-r--r-- | src/H5VLiod_dtype.c | 39 | ||||
-rw-r--r-- | src/H5VLiod_group.c | 47 | ||||
-rw-r--r-- | src/H5VLiod_link.c | 20 | ||||
-rw-r--r-- | src/H5VLiod_map.c | 40 |
7 files changed, 186 insertions, 98 deletions
diff --git a/examples/h5ff_client_dset.c b/examples/h5ff_client_dset.c index a44ae60..b2e3a74 100644 --- a/examples/h5ff_client_dset.c +++ b/examples/h5ff_client_dset.c @@ -386,7 +386,7 @@ int main(int argc, char **argv) { free(buf); } - +#if 0 /* create & start transaction 2 with num_peers = my_size. This means all processes are transaction leaders, and all have to call start and finish on the transaction. */ @@ -427,12 +427,6 @@ int main(int argc, char **argv) { ret = H5TRfinish(tid2, H5P_DEFAULT, NULL, H5_EVENT_STACK_NULL); assert(0 == ret); - if(my_rank == 0) { - /* release container version 1. This is async. */ - ret = H5RCrelease(rid2, e_stack); - assert(0 == ret); - } - H5ESget_count(e_stack, &num_events); H5ESwait_all(e_stack, &status); printf("%d events in event stack. H5ESwait_all Completion status = %d\n", num_events, status); @@ -505,6 +499,14 @@ int main(int argc, char **argv) { ret = H5RCrelease(rid4, e_stack); assert(0 == ret); +#endif + + if(my_rank == 0) { + /* release container version 1. This is async. */ + ret = H5RCrelease(rid2, e_stack); + assert(0 == ret); + } + /* close objects */ ret = H5Dclose_ff(did1, e_stack); assert(ret == 0); @@ -539,14 +541,6 @@ int main(int argc, char **argv) { assert(0 == ret); ret = H5RCclose(rid2); assert(0 == ret); - ret = H5RCclose(rid3); - assert(0 == ret); - ret = H5RCclose(rid4); - assert(0 == ret); - ret = H5TRclose(tid2); - assert(0 == ret); - ret = H5TRclose(tid3); - assert(0 == ret); H5ESclear(e_stack); diff --git a/src/H5VLiod_attr.c b/src/H5VLiod_attr.c index b855409..d34c2cf 100644 --- a/src/H5VLiod_attr.c +++ b/src/H5VLiod_attr.c @@ -76,6 +76,11 @@ H5VL_iod_server_attr_create_cb(AXE_engine_t UNUSED axe_engine, attr_name, loc_handle.wr_oh, attr_id); #endif + attr_oh.rd_oh.cookie = IOD_OH_UNDEFINED; + attr_oh.wr_oh.cookie = IOD_OH_UNDEFINED; + mdkv_oh.cookie = IOD_OH_UNDEFINED; + attr_kv_oh.cookie = IOD_OH_UNDEFINED; + if(loc_handle.rd_oh.cookie == IOD_OH_UNDEFINED) { /* Try and open the starting location */ if (iod_obj_open_read(coh, loc_id, wtid, NULL, &loc_handle.rd_oh, NULL) < 0) @@ -147,10 +152,6 @@ H5VL_iod_server_attr_create_cb(AXE_engine_t UNUSED axe_engine, if(H5VL_iod_insert_dataspace(mdkv_oh, wtid, input->space_id, NULL, NULL, NULL) < 0) HGOTO_ERROR2(H5E_SYM, H5E_CANTINIT, FAIL, "can't insert KV value"); - /* close the Metadata KV object */ - if(iod_obj_close(mdkv_oh, NULL, NULL) < 0) - HGOTO_ERROR2(H5E_SYM, H5E_CANTINIT, FAIL, "can't close object"); - /* if the starting location is not the last component, need to read the attrkv_id of the last object where attribute needs to be created */ @@ -180,16 +181,6 @@ H5VL_iod_server_attr_create_cb(AXE_engine_t UNUSED axe_engine, H5L_TYPE_HARD, &attr_id, NULL, NULL, NULL) < 0) HGOTO_ERROR2(H5E_SYM, H5E_CANTINIT, FAIL, "can't insert KV value"); - /* close the Attribute KV object */ - if(iod_obj_close(attr_kv_oh, NULL, NULL) < 0) - HGOTO_ERROR2(H5E_SYM, H5E_CANTINIT, FAIL, "can't close object"); - - /* close parent group if it is not the location we started the - traversal into */ - if(TRUE == opened_locally || loc_handle.rd_oh.cookie != obj_oh.rd_oh.cookie) { - iod_obj_close(obj_oh.rd_oh, NULL, NULL); - } - output.iod_oh.rd_oh.cookie = attr_oh.rd_oh.cookie; output.iod_oh.wr_oh.cookie = attr_oh.wr_oh.cookie; @@ -199,11 +190,35 @@ H5VL_iod_server_attr_create_cb(AXE_engine_t UNUSED axe_engine, HG_Handler_start_output(op_data->hg_handle, &output); - done: +done: + + /* close parent group if it is not the location we started the + traversal into */ + if(TRUE == opened_locally || loc_handle.rd_oh.cookie != obj_oh.rd_oh.cookie) { + iod_obj_close(obj_oh.rd_oh, NULL, NULL); + } + + /* close the Metadata KV object */ + if(mdkv_oh.cookie != IOD_OH_UNDEFINED && + iod_obj_close(mdkv_oh, NULL, NULL) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't close object"); + + /* close the Attribute KV object */ + if(attr_kv_oh.cookie != IOD_OH_UNDEFINED && + iod_obj_close(attr_kv_oh, NULL, NULL) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't close object"); /* return an UNDEFINED oh to the client if the operation failed */ if(ret_value < 0) { fprintf(stderr, "Failed Attribute Create\n"); + + if(attr_oh.rd_oh.cookie != IOD_OH_UNDEFINED && + iod_obj_close(attr_oh.rd_oh, NULL, NULL) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't close object"); + if(attr_oh.wr_oh.cookie != IOD_OH_UNDEFINED && + iod_obj_close(attr_oh.wr_oh, NULL, NULL) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't close object"); + output.iod_oh.rd_oh.cookie = IOD_OH_UNDEFINED; output.iod_oh.wr_oh.cookie = IOD_OH_UNDEFINED; HG_Handler_start_output(op_data->hg_handle, &output); @@ -1032,12 +1047,6 @@ H5VL_iod_server_attr_remove_cb(AXE_engine_t UNUSED axe_engine, HGOTO_ERROR2(H5E_ATTR, H5E_CANTINIT, FAIL, "can't open scratch pad"); } - /* close parent group if it is not the location we started the - traversal into */ - if(loc_handle.rd_oh.cookie != obj_oh.rd_oh.cookie) { - iod_obj_close(obj_oh.rd_oh, NULL, NULL); - } - /* get attribute ID */ if(H5VL_iod_get_metadata(attr_kv_oh.rd_oh, rtid, H5VL_IOD_LINK, attr_name, NULL, NULL, &iod_link) < 0) @@ -1067,10 +1076,6 @@ H5VL_iod_server_attr_remove_cb(AXE_engine_t UNUSED axe_engine, HGOTO_ERROR2(H5E_SYM, H5E_CANTDEC, FAIL, "Unable to unlink MDKV of attribute object"); } - /* close the attribute oh */ - if(iod_obj_close(attr_oh, NULL, NULL) < 0) - HGOTO_ERROR2(H5E_SYM, H5E_CANTINIT, FAIL, "can't close object"); - /* remove attribute */ kv.key = (void *)attr_name; kv.key_len = strlen(attr_name); @@ -1086,17 +1091,24 @@ H5VL_iod_server_attr_remove_cb(AXE_engine_t UNUSED axe_engine, HGOTO_ERROR2(H5E_SYM, H5E_CANTDEC, FAIL, "Unable to unlink object"); } - /* close the Attribute KV object */ - if(iod_obj_close(attr_kv_oh.rd_oh, NULL, NULL) < 0) - HGOTO_ERROR2(H5E_SYM, H5E_CANTFREE, FAIL, "can't close object"); - if(iod_obj_close(attr_kv_oh.wr_oh, NULL, NULL) < 0) - HGOTO_ERROR2(H5E_SYM, H5E_CANTFREE, FAIL, "can't close object"); - done: #if H5VL_IOD_DEBUG fprintf(stderr, "Done with attr remove, sending response to client\n"); #endif + /* close parent group if it is not the location we started the + traversal into */ + if(loc_handle.rd_oh.cookie != obj_oh.rd_oh.cookie) { + iod_obj_close(obj_oh.rd_oh, NULL, NULL); + } + + /* close the attribute oh */ + iod_obj_close(attr_oh, NULL, NULL); + + /* close the Attribute KV object */ + iod_obj_close(attr_kv_oh.rd_oh, NULL, NULL); + iod_obj_close(attr_kv_oh.wr_oh, NULL, NULL); + HG_Handler_start_output(op_data->hg_handle, &ret_value); input = (attr_op_in_t *)H5MM_xfree(input); diff --git a/src/H5VLiod_dset.c b/src/H5VLiod_dset.c index c85ebc0..91d7b1b 100644 --- a/src/H5VLiod_dset.c +++ b/src/H5VLiod_dset.c @@ -95,6 +95,7 @@ H5VL_iod_server_dset_create_cb(AXE_engine_t UNUSED axe_engine, iod_array_struct_t array; /* IOD array struct describing the dataset's dimensions */ scratch_pad sp; iod_ret_t ret = 0; + int step = 0; iod_size_t array_dims[H5S_MAX_RANK], current_dims[H5S_MAX_RANK]; herr_t ret_value = SUCCEED; @@ -152,6 +153,8 @@ H5VL_iod_server_dset_create_cb(AXE_engine_t UNUSED axe_engine, if (iod_obj_open_read(coh, dset_id, wtid, NULL, &dset_oh.rd_oh, NULL) < 0) HGOTO_ERROR2(H5E_SYM, H5E_CANTINIT, FAIL, "can't open Dataset for Read"); + step ++; + /* create the attribute KV object for the dataset */ if(iod_obj_create(coh, wtid, NULL, IOD_OBJ_KV, NULL, NULL, &attrkv_id, NULL) < 0) HGOTO_ERROR2(H5E_SYM, H5E_CANTINIT, FAIL, "can't create attribute KV object"); @@ -183,6 +186,8 @@ H5VL_iod_server_dset_create_cb(AXE_engine_t UNUSED axe_engine, if (iod_obj_open_write(coh, mdkv_id, wtid, NULL, &mdkv_oh, NULL) < 0) HGOTO_ERROR2(H5E_SYM, H5E_CANTINIT, FAIL, "can't create scratch pad"); + step ++; + if(H5P_DEFAULT == input->dcpl_id) input->dcpl_id = H5Pcopy(H5P_DATASET_CREATE_DEFAULT); dcpl_id = input->dcpl_id; @@ -219,19 +224,13 @@ H5VL_iod_server_dset_create_cb(AXE_engine_t UNUSED axe_engine, if(iod_obj_close(mdkv_oh, NULL, NULL) < 0) HGOTO_ERROR2(H5E_SYM, H5E_CANTINIT, FAIL, "can't close object"); + step --; + /* add link in parent group to current object */ if(H5VL_iod_insert_new_link(cur_oh.wr_oh, wtid, last_comp, H5L_TYPE_HARD, &dset_id, NULL, NULL, NULL) < 0) HGOTO_ERROR2(H5E_SYM, H5E_CANTINIT, FAIL, "can't insert KV value"); - /* close parent group if it is not the location we started the - traversal into */ - if(loc_handle.rd_oh.cookie != cur_oh.rd_oh.cookie) { - iod_obj_close(cur_oh.rd_oh, NULL, NULL); - } - if(loc_handle.wr_oh.cookie != cur_oh.wr_oh.cookie) { - iod_obj_close(cur_oh.wr_oh, NULL, NULL); - } output.iod_oh.rd_oh.cookie = dset_oh.rd_oh.cookie; output.iod_oh.wr_oh.cookie = dset_oh.wr_oh.cookie; @@ -243,9 +242,32 @@ H5VL_iod_server_dset_create_cb(AXE_engine_t UNUSED axe_engine, HG_Handler_start_output(op_data->hg_handle, &output); done: + /* close parent group if it is not the location we started the + traversal into */ + if(loc_handle.rd_oh.cookie != cur_oh.rd_oh.cookie) { + if(iod_obj_close(cur_oh.rd_oh, NULL, NULL) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't close current object handle"); + } + if(loc_handle.wr_oh.cookie != cur_oh.wr_oh.cookie) { + if(iod_obj_close(cur_oh.wr_oh, NULL, NULL) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't close current object handle"); + } /* return an UNDEFINED oh to the client if the operation failed */ if(ret_value < 0) { - fprintf(stderr, "failed to create/open Dataset\n"); + fprintf(stderr, "failed to create Dataset\n"); + + if(step == 2) { + if(iod_obj_close(mdkv_oh, NULL, NULL) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't close object"); + step --; + } + if(step == 1) { + if(iod_obj_close(dset_oh.rd_oh, NULL, NULL) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't close object"); + if(iod_obj_close(dset_oh.wr_oh, NULL, NULL) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't close object"); + } + output.iod_oh.rd_oh.cookie = IOD_OH_UNDEFINED; output.iod_oh.wr_oh.cookie = IOD_OH_UNDEFINED; HG_Handler_start_output(op_data->hg_handle, &output); diff --git a/src/H5VLiod_dtype.c b/src/H5VLiod_dtype.c index a8c5089..329ea1a 100644 --- a/src/H5VLiod_dtype.c +++ b/src/H5VLiod_dtype.c @@ -67,6 +67,7 @@ H5VL_iod_server_dtype_commit_cb(AXE_engine_t UNUSED axe_engine, iod_mem_desc_t *mem_desc = NULL; /* memory descriptor used for writing */ iod_blob_iodesc_t *file_desc = NULL; /* file descriptor used to write */ scratch_pad sp; + int step = 0; herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT @@ -94,6 +95,8 @@ H5VL_iod_server_dtype_commit_cb(AXE_engine_t UNUSED axe_engine, if (iod_obj_open_write(coh, dtype_id, wtid, NULL, &dtype_oh.wr_oh, NULL) < 0) HGOTO_ERROR2(H5E_SYM, H5E_CANTINIT, FAIL, "can't open BLOB"); + step ++; + /* create the metadata KV object for the datatype */ if(iod_obj_create(coh, wtid, NULL, IOD_OBJ_KV, NULL, NULL, &mdkv_id, NULL) < 0) HGOTO_ERROR2(H5E_SYM, H5E_CANTINIT, FAIL, "can't create metadata KV object"); @@ -125,6 +128,8 @@ H5VL_iod_server_dtype_commit_cb(AXE_engine_t UNUSED axe_engine, if (iod_obj_open_write(coh, mdkv_id, wtid, NULL, &mdkv_oh, NULL) < 0) HGOTO_ERROR2(H5E_SYM, H5E_CANTINIT, FAIL, "can't open metadata KV object"); + step ++; + /* determine the buffer size needed to store the encoded type of the datatype */ if(H5Tencode(input->type_id, NULL, &buf_size) < 0) HGOTO_ERROR2(H5E_SYM, H5E_CANTENCODE, FAIL, "failed to encode datatype type"); @@ -201,20 +206,13 @@ H5VL_iod_server_dtype_commit_cb(AXE_engine_t UNUSED axe_engine, if(iod_obj_close(mdkv_oh, NULL, NULL)) HGOTO_ERROR2(H5E_SYM, H5E_CANTINIT, FAIL, "can't close object"); + step --; + /* add link in parent group to current object */ if(H5VL_iod_insert_new_link(cur_oh.wr_oh, wtid, last_comp, H5L_TYPE_HARD, &dtype_id, NULL, NULL, NULL) < 0) HGOTO_ERROR2(H5E_SYM, H5E_CANTINIT, FAIL, "can't insert KV value"); - /* close parent group and its scratch pad if it is not the - location we started the traversal into */ - if(loc_handle.rd_oh.cookie != cur_oh.rd_oh.cookie) { - iod_obj_close(cur_oh.rd_oh, NULL, NULL); - } - if(loc_handle.wr_oh.cookie != cur_oh.wr_oh.cookie) { - iod_obj_close(cur_oh.wr_oh, NULL, NULL); - } - output.iod_oh.rd_oh.cookie = dtype_oh.rd_oh.cookie; output.iod_oh.wr_oh.cookie = dtype_oh.wr_oh.cookie; @@ -225,7 +223,30 @@ H5VL_iod_server_dtype_commit_cb(AXE_engine_t UNUSED axe_engine, HG_Handler_start_output(op_data->hg_handle, &output); done: + /* close parent group if it is not the location we started the + traversal into */ + if(loc_handle.rd_oh.cookie != cur_oh.rd_oh.cookie) { + if(iod_obj_close(cur_oh.rd_oh, NULL, NULL) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't close current object handle"); + } + if(loc_handle.wr_oh.cookie != cur_oh.wr_oh.cookie) { + if(iod_obj_close(cur_oh.wr_oh, NULL, NULL) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't close current object handle"); + } + if(ret_value < 0) { + if(step == 2) { + if(iod_obj_close(mdkv_oh, NULL, NULL) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't close object"); + step --; + } + if(step == 1) { + if(iod_obj_close(dtype_oh.rd_oh, NULL, NULL) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't close object"); + if(iod_obj_close(dtype_oh.wr_oh, NULL, NULL) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't close object"); + } + output.iod_oh.rd_oh.cookie = IOD_OH_UNDEFINED; output.iod_oh.wr_oh.cookie = IOD_OH_UNDEFINED; HG_Handler_start_output(op_data->hg_handle, &output); diff --git a/src/H5VLiod_group.c b/src/H5VLiod_group.c index 721363e..7bd4ef1 100644 --- a/src/H5VLiod_group.c +++ b/src/H5VLiod_group.c @@ -64,12 +64,13 @@ H5VL_iod_server_group_create_cb(AXE_engine_t UNUSED axe_engine, hid_t gcpl_id; scratch_pad sp; iod_ret_t ret; + int step = 0; herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT #if H5VL_IOD_DEBUG - fprintf(stderr, "Start group create %s at %"PRIu64"\n", name, loc_handle.wr_oh); + fprintf(stderr, "Start group create %s at %"PRIu64"\n", name, loc_handle.wr_oh); #endif /* the traversal will retrieve the location where the group needs @@ -96,6 +97,8 @@ H5VL_iod_server_group_create_cb(AXE_engine_t UNUSED axe_engine, HGOTO_ERROR2(H5E_SYM, H5E_CANTINIT, FAIL, "can't open Group for write"); } + step += 1; + /* create the metadata KV object for the group */ if(iod_obj_create(coh, wtid, NULL, IOD_OBJ_KV, NULL, NULL, &mdkv_id, NULL) < 0) HGOTO_ERROR2(H5E_SYM, H5E_CANTINIT, FAIL, "can't create metadata KV object"); @@ -128,6 +131,8 @@ H5VL_iod_server_group_create_cb(AXE_engine_t UNUSED axe_engine, if (iod_obj_open_write(coh, mdkv_id, wtid, NULL, &mdkv_oh, NULL) < 0) HGOTO_ERROR2(H5E_SYM, H5E_CANTINIT, FAIL, "can't create scratch pad"); + step ++; + if(H5P_DEFAULT == input->gcpl_id) input->gcpl_id = H5Pcopy(H5P_GROUP_CREATE_DEFAULT); gcpl_id = input->gcpl_id; @@ -151,22 +156,13 @@ H5VL_iod_server_group_create_cb(AXE_engine_t UNUSED axe_engine, if(iod_obj_close(mdkv_oh, NULL, NULL) < 0) HGOTO_ERROR2(H5E_SYM, H5E_CANTINIT, FAIL, "can't close object"); + step --; + /* add link in parent group to current object */ if(H5VL_iod_insert_new_link(cur_oh.wr_oh, wtid, last_comp, H5L_TYPE_HARD, &grp_id, NULL, NULL, NULL) < 0) HGOTO_ERROR2(H5E_SYM, H5E_CANTINIT, FAIL, "can't insert KV value"); - /* close parent group if it is not the location we started the - traversal into */ - if(loc_handle.rd_oh.cookie != cur_oh.rd_oh.cookie) { - if(iod_obj_close(cur_oh.rd_oh, NULL, NULL) < 0) - HGOTO_ERROR2(H5E_SYM, H5E_CANTINIT, FAIL, "can't close current object handle"); - } - if(loc_handle.wr_oh.cookie != cur_oh.wr_oh.cookie) { - if(iod_obj_close(cur_oh.wr_oh, NULL, NULL) < 0) - HGOTO_ERROR2(H5E_SYM, H5E_CANTINIT, FAIL, "can't close current object handle"); - } - #if H5VL_IOD_DEBUG fprintf(stderr, "Done with group create, sending response to client\n"); #endif @@ -179,10 +175,35 @@ H5VL_iod_server_group_create_cb(AXE_engine_t UNUSED axe_engine, fprintf(stderr, "Created group RD_OH %"PRIu64" WR_OH %"PRIu64"\n", grp_oh.rd_oh.cookie, grp_oh.wr_oh.cookie); - done: +done: + + /* close parent group if it is not the location we started the + traversal into */ + if(loc_handle.rd_oh.cookie != cur_oh.rd_oh.cookie) { + if(iod_obj_close(cur_oh.rd_oh, NULL, NULL) < 0) + HGOTO_ERROR2(H5E_SYM, H5E_CANTINIT, FAIL, "can't close current object handle"); + } + if(loc_handle.wr_oh.cookie != cur_oh.wr_oh.cookie) { + if(iod_obj_close(cur_oh.wr_oh, NULL, NULL) < 0) + HGOTO_ERROR2(H5E_SYM, H5E_CANTINIT, FAIL, "can't close current object handle"); + } + /* return an UNDEFINED oh to the client if the operation failed */ if(ret_value < 0) { fprintf(stderr, "Failed Group Create\n"); + + if(step == 2) { + if(iod_obj_close(mdkv_oh, NULL, NULL) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't close object"); + step --; + } + if(step == 1) { + if(iod_obj_close(grp_oh.rd_oh, NULL, NULL) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't close object"); + if(iod_obj_close(grp_oh.wr_oh, NULL, NULL) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't close object"); + } + output.iod_oh.rd_oh.cookie = IOD_OH_UNDEFINED; output.iod_oh.wr_oh.cookie = IOD_OH_UNDEFINED; HG_Handler_start_output(op_data->hg_handle, &output); diff --git a/src/H5VLiod_link.c b/src/H5VLiod_link.c index 0c51982..326bf6a 100644 --- a/src/H5VLiod_link.c +++ b/src/H5VLiod_link.c @@ -713,6 +713,8 @@ H5VL_iod_server_link_remove_cb(AXE_engine_t UNUSED axe_engine, uint32_t cs_scope = input->cs_scope; iod_handles_t cur_oh; iod_obj_id_t cur_id; + iod_handle_t obj_oh; + iod_handles_t mdkv_oh; const char *loc_name = input->path; char *last_comp = NULL; iod_kv_params_t kvs; @@ -753,8 +755,6 @@ H5VL_iod_server_link_remove_cb(AXE_engine_t UNUSED axe_engine, /* check the metadata information for the object and remove it from the container if this is the last link to it */ if(iod_link.link_type == H5L_TYPE_HARD) { - iod_handle_t obj_oh; - iod_handles_t mdkv_oh; scratch_pad sp; iod_checksum_t sp_cs = 0; uint64_t link_count = 0; @@ -796,15 +796,6 @@ H5VL_iod_server_link_remove_cb(AXE_engine_t UNUSED axe_engine, NULL, NULL, NULL) < 0) HGOTO_ERROR2(H5E_SYM, H5E_CANTINIT, FAIL, "can't insert KV value"); } - /* close the metadata scratch pad */ - if(iod_obj_close(mdkv_oh.rd_oh, NULL, NULL) < 0) - HGOTO_ERROR2(H5E_SYM, H5E_CANTINIT, FAIL, "can't close object"); - if(iod_obj_close(mdkv_oh.wr_oh, NULL, NULL) < 0) - HGOTO_ERROR2(H5E_SYM, H5E_CANTINIT, FAIL, "can't close object"); - - /* close the object */ - if(iod_obj_close(obj_oh, NULL, NULL) < 0) - HGOTO_ERROR2(H5E_SYM, H5E_CANTINIT, FAIL, "can't close object"); /* If this was the only link to the object, remove the object */ if(0 == link_count) { @@ -817,6 +808,8 @@ H5VL_iod_server_link_remove_cb(AXE_engine_t UNUSED axe_engine, } } +done: + /* close parent group if it is not the location we started the traversal into */ if(input->loc_oh.rd_oh.cookie != cur_oh.rd_oh.cookie) { @@ -826,7 +819,10 @@ H5VL_iod_server_link_remove_cb(AXE_engine_t UNUSED axe_engine, iod_obj_close(cur_oh.wr_oh, NULL, NULL); } -done: + /* close the metadata scratch pad */ + iod_obj_close(mdkv_oh.rd_oh, NULL, NULL); + iod_obj_close(mdkv_oh.wr_oh, NULL, NULL); + iod_obj_close(obj_oh, NULL, NULL); #if H5VL_IOD_DEBUG fprintf(stderr, "Done with link remove, sending response %d to client\n", diff --git a/src/H5VLiod_map.c b/src/H5VLiod_map.c index 753d676..7a48859 100644 --- a/src/H5VLiod_map.c +++ b/src/H5VLiod_map.c @@ -67,6 +67,7 @@ H5VL_iod_server_map_create_cb(AXE_engine_t UNUSED axe_engine, iod_obj_id_t cur_id; char *last_comp; /* the name of the group obtained from traversal function */ hid_t mcpl_id; + int step = 0; scratch_pad sp; herr_t ret_value = SUCCEED; @@ -96,6 +97,8 @@ H5VL_iod_server_map_create_cb(AXE_engine_t UNUSED axe_engine, if (iod_obj_open_write(coh, map_id, wtid, NULL, &map_oh.wr_oh, NULL) < 0) HGOTO_ERROR2(H5E_SYM, H5E_CANTINIT, FAIL, "can't open Map"); + step ++; + /* create the metadata KV object for the map */ if(iod_obj_create(coh, wtid, NULL, IOD_OBJ_KV, NULL, NULL, &mdkv_id, NULL) < 0) HGOTO_ERROR2(H5E_SYM, H5E_CANTINIT, FAIL, "can't create metadata KV object"); @@ -127,6 +130,8 @@ H5VL_iod_server_map_create_cb(AXE_engine_t UNUSED axe_engine, if (iod_obj_open_write(coh, mdkv_id, wtid, NULL, &mdkv_oh, NULL) < 0) HGOTO_ERROR2(H5E_SYM, H5E_CANTINIT, FAIL, "can't create scratch pad"); + step ++; + if(H5P_DEFAULT == input->mcpl_id) input->mcpl_id = H5Pcopy(H5P_GROUP_CREATE_DEFAULT); mcpl_id = input->mcpl_id; @@ -160,20 +165,13 @@ H5VL_iod_server_map_create_cb(AXE_engine_t UNUSED axe_engine, if(iod_obj_close(mdkv_oh, NULL, NULL) < 0) HGOTO_ERROR2(H5E_SYM, H5E_CANTINIT, FAIL, "can't close object"); + step --; + /* add link in parent group to current object */ if(H5VL_iod_insert_new_link(cur_oh.wr_oh, wtid, last_comp, H5L_TYPE_HARD, &map_id, NULL, NULL, NULL) < 0) HGOTO_ERROR2(H5E_SYM, H5E_CANTINIT, FAIL, "can't insert KV value"); - /* close parent group if it is not the location we started the - traversal into */ - if(loc_handle.rd_oh.cookie != cur_oh.rd_oh.cookie) { - iod_obj_close(cur_oh.rd_oh, NULL, NULL); - } - if(loc_handle.wr_oh.cookie != cur_oh.wr_oh.cookie) { - iod_obj_close(cur_oh.wr_oh, NULL, NULL); - } - #if H5VL_IOD_DEBUG fprintf(stderr, "Done with map create, sending response to client\n"); #endif @@ -184,9 +182,33 @@ H5VL_iod_server_map_create_cb(AXE_engine_t UNUSED axe_engine, HG_Handler_start_output(op_data->hg_handle, &output); done: + /* close parent group if it is not the location we started the + traversal into */ + if(loc_handle.rd_oh.cookie != cur_oh.rd_oh.cookie) { + if(iod_obj_close(cur_oh.rd_oh, NULL, NULL) < 0) + HGOTO_ERROR2(H5E_SYM, H5E_CANTINIT, FAIL, "can't close current object handle"); + } + if(loc_handle.wr_oh.cookie != cur_oh.wr_oh.cookie) { + if(iod_obj_close(cur_oh.wr_oh, NULL, NULL) < 0) + HGOTO_ERROR2(H5E_SYM, H5E_CANTINIT, FAIL, "can't close current object handle"); + } + /* return an UNDEFINED oh to the client if the operation failed */ if(ret_value < 0) { fprintf(stderr, "Failed Map Create\n"); + + if(step == 2) { + if(iod_obj_close(mdkv_oh, NULL, NULL) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't close object"); + step --; + } + if(step == 1) { + if(iod_obj_close(map_oh.rd_oh, NULL, NULL) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't close object"); + if(iod_obj_close(map_oh.wr_oh, NULL, NULL) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't close object"); + } + output.iod_oh.rd_oh.cookie = IOD_OH_UNDEFINED; output.iod_oh.wr_oh.cookie = IOD_OH_UNDEFINED; HG_Handler_start_output(op_data->hg_handle, &output); |