diff options
author | Vishwanath Venkatesan <vish@hdfgroup.org> | 2013-07-30 20:54:44 (GMT) |
---|---|---|
committer | Vishwanath Venkatesan <vish@hdfgroup.org> | 2013-07-30 20:54:44 (GMT) |
commit | 0c83c7df55bbd5d1b2c37f2e07484ffa4cd2e819 (patch) | |
tree | 02e36855beb558c4614b4240f425e3b3eb310178 | |
parent | f60d2ea53081c9efb8616d462374aa1503e0a70f (diff) | |
download | hdf5-0c83c7df55bbd5d1b2c37f2e07484ffa4cd2e819.zip hdf5-0c83c7df55bbd5d1b2c37f2e07484ffa4cd2e819.tar.gz hdf5-0c83c7df55bbd5d1b2c37f2e07484ffa4cd2e819.tar.bz2 |
[svn-r23947] Merging with hdf5_ff branch + updating the branch to work with updated
iod, mercury.
-rw-r--r-- | src/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/H5VLiod.c | 30 | ||||
-rw-r--r-- | src/H5VLiod_attr.c | 197 | ||||
-rw-r--r-- | src/H5VLiod_client.c | 2 | ||||
-rw-r--r-- | src/H5VLiod_common.h | 2 | ||||
-rw-r--r-- | src/H5VLiod_compactor.c | 2 | ||||
-rw-r--r-- | src/H5VLiod_dset.c | 770 | ||||
-rw-r--r-- | src/H5VLiod_dtype.c | 67 | ||||
-rw-r--r-- | src/H5VLiod_file.c | 18 | ||||
-rw-r--r-- | src/H5VLiod_group.c | 53 | ||||
-rw-r--r-- | src/H5VLiod_link.c | 304 | ||||
-rw-r--r-- | src/H5VLiod_map.c | 67 | ||||
-rw-r--r-- | src/H5VLiod_obj.c | 256 | ||||
-rw-r--r-- | src/H5VLiod_server.c | 789 | ||||
-rw-r--r-- | src/H5VLiod_server.h | 41 | ||||
-rw-r--r-- | src/H5VLiod_util.c | 1064 | ||||
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/Makefile.in | 5 |
18 files changed, 2014 insertions, 1655 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6b8137a..9daa7e1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -641,6 +641,7 @@ IF (HDF5_ENABLE_EFF) ${HDF5_SRC_DIR}/H5VLiod.c ${HDF5_SRC_DIR}/H5VLiod_client.c ${HDF5_SRC_DIR}/H5VLiod_server.c + ${HDF5_SRC_DIR}/H5VLiod_util.c ${HDF5_SRC_DIR}/H5VLiod_file.c ${HDF5_SRC_DIR}/H5VLiod_group.c ${HDF5_SRC_DIR}/H5VLiod_dset.c diff --git a/src/H5VLiod.c b/src/H5VLiod.c index e126dd0..9ac1b8f 100644 --- a/src/H5VLiod.c +++ b/src/H5VLiod.c @@ -454,6 +454,8 @@ EFF_finalize(void) return FAIL; if (HG_SUCCESS != HG_Finalize()) return FAIL; + if(NA_SUCCESS != NA_Finalize(network_class)) + return FAIL; return ret_value; } /* end EFF_finalize() */ @@ -4766,6 +4768,7 @@ H5VL_iod_link_create(H5VL_link_create_type_t create_type, void *_obj, H5VL_loc_p hbool_t do_async = (req == NULL) ? FALSE : TRUE; /* Whether we're performing async. I/O */ H5P_genplist_t *plist; /* Property list pointer */ char *loc_name = NULL, *new_name = NULL; + char *link_value = NULL; /* Value of soft link */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -4820,6 +4823,7 @@ H5VL_iod_link_create(H5VL_link_create_type_t create_type, void *_obj, H5VL_loc_p input.loc_name = loc_name; input.target_name = new_name; input.axe_id = axe_id ++; + input.link_value = strdup("\0"); #if H5VL_IOD_DEBUG printf("Hard Link Create axe %llu: %s ID %llu axe %llu to %s ID %llu axe %llu\n", @@ -4843,12 +4847,30 @@ H5VL_iod_link_create(H5VL_link_create_type_t create_type, void *_obj, H5VL_loc_p target_params.loc_data.loc_by_name.plist_id = lapl_id; /* determine target object whether it is absolute or - relative to the location object */ - if('/' == *target_name) + relative to the location object. Also set the link + value to the full path to the target object. */ + if('/' == *target_name) { + /* The target location object is the file root */ target_obj = (H5VL_iod_object_t *)obj->file; - else + + /* The path is absolute */ + link_value = strdup(target_name); + } + else { + size_t obj_name_len = HDstrlen(obj->obj_name); + size_t name_len = HDstrlen(target_name); + + /* The target location object is the same as the source object */ target_obj = obj; + /* The full path is determined by concatinating the + source object location to the target_name */ + if (NULL == (link_value = (char *)HDmalloc(obj_name_len + name_len + 1))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate"); + HDmemcpy(link_value, obj->obj_name, obj_name_len); + HDmemcpy(link_value+obj_name_len, target_name, name_len); + link_value[obj_name_len+name_len] = '\0'; + } /* Retrieve the parent info by traversing the path where the link should be created from. */ @@ -4872,6 +4894,7 @@ H5VL_iod_link_create(H5VL_link_create_type_t create_type, void *_obj, H5VL_loc_p input.lapl_id = lapl_id; input.loc_name = loc_name; input.target_name = new_name; + input.link_value = link_value; #if H5VL_IOD_DEBUG printf("Soft Link Create axe %llu: %s ID %llu axe %llu to %s ID %llu axe %llu\n", @@ -4954,6 +4977,7 @@ H5VL_iod_link_create(H5VL_link_create_type_t create_type, void *_obj, H5VL_loc_p done: if(loc_name) free(loc_name); if(new_name) free(new_name); + if(input.link_value) HDfree(input.link_value); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_iod_link_create() */ diff --git a/src/H5VLiod_attr.c b/src/H5VLiod_attr.c index dd8c786..dc17968 100644 --- a/src/H5VLiod_attr.c +++ b/src/H5VLiod_attr.c @@ -51,11 +51,10 @@ H5VL_iod_server_attr_create_cb(AXE_engine_t UNUSED axe_engine, iod_handle_t loc_handle = input->loc_oh; /* location handle to start lookup */ iod_obj_id_t loc_id = input->loc_id; /* The ID of the current location object */ iod_obj_id_t attr_id = input->attr_id; /* The ID of the attribute that needs to be created */ - iod_handle_t attr_oh, attr_kv_oh, cur_oh, mdkv_oh; /* object handles */ - iod_obj_id_t cur_id, mdkv_id; + iod_handle_t attr_oh, attr_kv_oh, obj_oh, mdkv_oh; /* object handles */ + iod_obj_id_t obj_id, mdkv_id; const char *loc_name = input->path; /* path to start hierarchy traversal */ const char *attr_name = input->attr_name; /* attribute's name */ - char *last_comp = NULL; /* the last component's name where attribute is created */ iod_array_struct_t array; /* IOD array structure for attribute's creation */ iod_size_t *max_dims; /* MAX dims for IOD */ scratch_pad_t sp; @@ -69,12 +68,9 @@ H5VL_iod_server_attr_create_cb(AXE_engine_t UNUSED axe_engine, fprintf(stderr, "Start attribute Create %s on object path %s\n", attr_name, loc_name); #endif - /* the traversal will retrieve the location where the attribute needs - to be created. The traversal will fail if an intermediate group - does not exist. */ - if(H5VL_iod_server_traverse(coh, loc_id, loc_handle, loc_name, FALSE, - &last_comp, &cur_id, &cur_oh) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't traverse path"); + /* Open the object where the attribute needs to be created. */ + if(H5VL_iod_server_open_path(coh, loc_id, loc_handle, loc_name, &obj_id, &obj_oh) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't open object"); /* Set the IOD array creation parameters */ array.cell_size = H5Tget_size(input->type_id); @@ -145,7 +141,7 @@ H5VL_iod_server_attr_create_cb(AXE_engine_t UNUSED axe_engine, HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't close object"); /* get scratch pad of the parent */ - if(iod_obj_get_scratch(cur_oh, IOD_TID_UNKNOWN, &sp, NULL, NULL) < 0) + if(iod_obj_get_scratch(obj_oh, IOD_TID_UNKNOWN, &sp, NULL, NULL) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "can't get scratch pad for object"); /* open the attribute KV in scratch pad */ @@ -153,8 +149,8 @@ H5VL_iod_server_attr_create_cb(AXE_engine_t UNUSED axe_engine, HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "can't open scratch pad"); /* insert new attribute in scratch pad of current object */ - if(H5VL_iod_insert_new_link(attr_kv_oh, IOD_TID_UNKNOWN, attr_name, attr_id, - NULL, NULL, NULL) < 0) + if(H5VL_iod_insert_new_link(attr_kv_oh, IOD_TID_UNKNOWN, attr_name, + H5L_TYPE_HARD, attr_id, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't insert KV value"); /* close the Attribute KV object */ @@ -164,17 +160,17 @@ H5VL_iod_server_attr_create_cb(AXE_engine_t UNUSED axe_engine, /* close parent group if it is not the location we started the traversal into */ - if(loc_handle.cookie != cur_oh.cookie) { - iod_obj_close(cur_oh, NULL, NULL); + if(loc_handle.cookie != obj_oh.cookie) { + iod_obj_close(obj_oh, NULL, NULL); } #if H5_DO_NATIVE - cur_oh.cookie = H5Acreate2(cur_oh.cookie, attr_name, input->type_id, + obj_oh.cookie = H5Acreate2(obj_oh.cookie, attr_name, input->type_id, input->space_id, H5P_DEFAULT, H5P_DEFAULT); - HDassert(cur_oh.cookie); + HDassert(obj_oh.cookie); #endif - output.iod_oh = cur_oh; + output.iod_oh = obj_oh; #if H5VL_IOD_DEBUG fprintf(stderr, "Done with attr create, sending response to client\n"); @@ -194,7 +190,6 @@ done: if(array.current_dims) free(array.current_dims); input = (attr_create_in_t *)H5MM_xfree(input); op_data = (op_data_t *)H5MM_xfree(op_data); - last_comp = (char *)H5MM_xfree(last_comp); FUNC_LEAVE_NOAPI_VOID } /* end H5VL_iod_server_attr_create_cb() */ @@ -225,13 +220,14 @@ H5VL_iod_server_attr_open_cb(AXE_engine_t UNUSED axe_engine, iod_handle_t coh = input->coh; /* container handle */ iod_handle_t loc_handle = input->loc_oh; /* location handle to start traversal */ iod_obj_id_t loc_id = input->loc_id; /* location ID */ - iod_handle_t attr_kv_oh, cur_oh, mdkv_oh; - iod_obj_id_t cur_id, mdkv_id; + iod_handle_t attr_kv_oh, attr_oh, obj_oh, mdkv_oh; + iod_obj_id_t obj_id; iod_obj_id_t attr_id; const char *loc_name = input->path; /* current path to start traversal */ const char *attr_name = input->attr_name; /* attribute's name to open */ - char *last_comp = NULL; /* name of last object in path */ scratch_pad_t sp; + iod_size_t kv_size = sizeof(H5VL_iod_link_t); + H5VL_iod_link_t iod_link; herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT @@ -240,15 +236,12 @@ H5VL_iod_server_attr_open_cb(AXE_engine_t UNUSED axe_engine, fprintf(stderr, "Start attribute Open %s\n", attr_name); #endif - /* the traversal will retrieve the location where the attribute needs - to be opened. The traversal will fail if an intermediate group - does not exist. */ - if(H5VL_iod_server_traverse(coh, loc_id, loc_handle, loc_name, FALSE, - &last_comp, &cur_id, &cur_oh) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't traverse path"); + /* Open the object where the attribute needs to be opened. */ + if(H5VL_iod_server_open_path(coh, loc_id, loc_handle, loc_name, &obj_id, &obj_oh) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't open object"); - /* get scratch pad of the parent */ - if(iod_obj_get_scratch(cur_oh, IOD_TID_UNKNOWN, &sp, NULL, NULL) < 0) + /* get scratch pad of the object */ + if(iod_obj_get_scratch(obj_oh, IOD_TID_UNKNOWN, &sp, NULL, NULL) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "can't get scratch pad for object"); /* MSC - Dont do this check until we have a real IOD */ @@ -263,24 +256,26 @@ H5VL_iod_server_attr_open_cb(AXE_engine_t UNUSED axe_engine, HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "can't open scratch pad"); /* get attribute ID */ - if(iod_kv_get_value(attr_kv_oh, IOD_TID_UNKNOWN, attr_name, &attr_id, - sizeof(iod_obj_id_t) , NULL, NULL) < 0) + if(iod_kv_get_value(attr_kv_oh, IOD_TID_UNKNOWN, attr_name, &iod_link, + &kv_size , NULL, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve Attribute ID from parent KV store"); + attr_id = iod_link.iod_id; + /* close parent group if it is not the location we started the traversal into */ - if(loc_handle.cookie != cur_oh.cookie) { - iod_obj_close(cur_oh, NULL, NULL); + if(loc_handle.cookie != obj_oh.cookie) { + iod_obj_close(obj_oh, NULL, NULL); } - + /* close the attribute KV holder */ iod_obj_close(attr_kv_oh, NULL, NULL); /* open the attribute */ - if (iod_obj_open_write(coh, attr_id, NULL /*hints*/, &cur_oh, NULL) < 0) + if (iod_obj_open_write(coh, attr_id, NULL /*hints*/, &attr_oh, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't open current group"); /* get scratch pad of the attribute */ - if(iod_obj_get_scratch(cur_oh, IOD_TID_UNKNOWN, &sp, NULL, NULL) < 0) + if(iod_obj_get_scratch(attr_oh, IOD_TID_UNKNOWN, &sp, NULL, NULL) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "can't get scratch pad for object"); /* open the metadata scratch pad of the attribute */ @@ -288,12 +283,12 @@ H5VL_iod_server_attr_open_cb(AXE_engine_t UNUSED axe_engine, HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "can't open scratch pad"); #if 0 - if(H5VL_iod_get_metadata(mdkv_oh, IOD_TID_UNKNOWN, H5VL_IOD_DATATYPE, "datatype", - NULL, NULL, NULL, &output.type_id) < 0) + if(H5VL_iod_get_metadata(mdkv_oh, IOD_TID_UNKNOWN, H5VL_IOD_DATATYPE, H5VL_IOD_KEY_OBJ_DATATYPE, + NULL, NULL, &output.type_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "failed to retrieve datatype"); - if(H5VL_iod_get_metadata(mdkv_oh, IOD_TID_UNKNOWN, H5VL_IOD_DATASPACE, "dataspace", - NULL, NULL, NULL, &output.space_id) < 0) + if(H5VL_iod_get_metadata(mdkv_oh, IOD_TID_UNKNOWN, H5VL_IOD_DATASPACE, H5VL_IOD_KEY_OBJ_DATASPACE, + NULL, NULL, &output.space_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "failed to retrieve dataspace"); #endif @@ -308,13 +303,13 @@ H5VL_iod_server_attr_open_cb(AXE_engine_t UNUSED axe_engine, #if H5_DO_NATIVE printf("attr name %s location %d %s\n", attr_name, loc_handle.cookie, loc_name); if(strcmp(loc_name, ".") == 0) - cur_oh.cookie = H5Aopen(loc_handle.cookie, attr_name, H5P_DEFAULT); + attr_oh.cookie = H5Aopen(loc_handle.cookie, attr_name, H5P_DEFAULT); else - cur_oh.cookie = H5Aopen_by_name(loc_handle.cookie, loc_name, + attr_oh.cookie = H5Aopen_by_name(loc_handle.cookie, loc_name, attr_name, H5P_DEFAULT, H5P_DEFAULT); - HDassert(cur_oh.cookie); - output.space_id = H5Aget_space(cur_oh.cookie); - output.type_id = H5Aget_type(cur_oh.cookie); + HDassert(attr_oh.cookie); + output.space_id = H5Aget_space(attr_oh.cookie); + output.type_id = H5Aget_type(attr_oh.cookie); output.acpl_id = H5P_ATTRIBUTE_CREATE_DEFAULT; #else /* fake a dataspace, type, and dcpl */ @@ -326,7 +321,7 @@ H5VL_iod_server_attr_open_cb(AXE_engine_t UNUSED axe_engine, } output.iod_id = attr_id; - output.iod_oh = cur_oh; + output.iod_oh = attr_oh; #if H5VL_IOD_DEBUG fprintf(stderr, "Done with attr open, sending response to client\n"); @@ -346,7 +341,6 @@ done: input = (attr_open_in_t *)H5MM_xfree(input); op_data = (op_data_t *)H5MM_xfree(op_data); - last_comp = (char *)H5MM_xfree(last_comp); FUNC_LEAVE_NOAPI_VOID } /* end H5VL_iod_server_attr_open_cb() */ @@ -417,8 +411,8 @@ H5VL_iod_server_attr_read_cb(AXE_engine_t UNUSED axe_engine, if (iod_obj_open_write(coh, sp.mdkv_id, NULL /*hints*/, &mdkv_oh, NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "can't open scratch pad"); - if(H5VL_iod_get_metadata(mdkv_oh, IOD_TID_UNKNOWN, H5VL_IOD_DATASPACE, "dataspace", - NULL, NULL, NULL, &space_id) < 0) + if(H5VL_iod_get_metadata(mdkv_oh, IOD_TID_UNKNOWN, H5VL_IOD_DATASPACE, H5VL_IOD_KEY_OBJ_DATASPACE, + NULL, NULL, &space_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "failed to retrieve dataspace"); /* close the metadata scratch pad */ @@ -589,8 +583,8 @@ H5VL_iod_server_attr_write_cb(AXE_engine_t UNUSED axe_engine, if (iod_obj_open_write(coh, sp.mdkv_id, NULL /*hints*/, &mdkv_oh, NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "can't open scratch pad"); - if(H5VL_iod_get_metadata(mdkv_oh, IOD_TID_UNKNOWN, H5VL_IOD_DATASPACE, "dataspace", - NULL, NULL, NULL, &space_id) < 0) + if(H5VL_iod_get_metadata(mdkv_oh, IOD_TID_UNKNOWN, H5VL_IOD_DATASPACE, H5VL_IOD_KEY_OBJ_DATASPACE, + NULL, NULL, &space_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "failed to retrieve dataspace"); /* close the metadata scratch pad */ @@ -673,13 +667,14 @@ H5VL_iod_server_attr_exists_cb(AXE_engine_t UNUSED axe_engine, iod_handle_t coh = input->coh; /* container handle */ iod_handle_t loc_handle = input->loc_oh; /* location handle to start lookup */ iod_obj_id_t loc_id = input->loc_id; /* The ID of the current location object */ - iod_handle_t cur_oh; /* current object handle accessed */ + iod_handle_t obj_oh; /* current object handle accessed */ iod_handle_t attr_kv_oh; /* KV handle holding attributes for object */ - iod_obj_id_t cur_id, attr_id; + iod_obj_id_t obj_id, attr_id; const char *loc_name = input->path; /* path to start hierarchy traversal */ const char *attr_name = input->attr_name; /* attribute's name */ - char *last_comp = NULL; /* the last component's name where attribute is created */ scratch_pad_t sp; + iod_size_t kv_size = sizeof(H5VL_iod_link_t); + H5VL_iod_link_t iod_link; htri_t ret = -1; herr_t ret_value = SUCCEED; @@ -689,21 +684,18 @@ H5VL_iod_server_attr_exists_cb(AXE_engine_t UNUSED axe_engine, fprintf(stderr, "Start attribute Exists %s\n", attr_name); #endif - /* the traversal will retrieve the location where the attribute needs - to be checked. The traversal will fail if an intermediate group - does not exist. */ - if(H5VL_iod_server_traverse(coh, loc_id, loc_handle, loc_name, FALSE, - &last_comp, &cur_id, &cur_oh) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't traverse path"); + /* Open the object where the attribute needs to be checked. */ + if(H5VL_iod_server_open_path(coh, loc_id, loc_handle, loc_name, &obj_id, &obj_oh) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't open object"); /* get scratch pad of the parent */ - if(iod_obj_get_scratch(cur_oh, IOD_TID_UNKNOWN, &sp, NULL, NULL) < 0) + if(iod_obj_get_scratch(obj_oh, IOD_TID_UNKNOWN, &sp, NULL, NULL) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "can't get scratch pad for object"); /* close parent group if it is not the location we started the traversal into */ - if(loc_handle.cookie != cur_oh.cookie) { - iod_obj_close(cur_oh, NULL, NULL); + if(loc_handle.cookie != obj_oh.cookie) { + iod_obj_close(obj_oh, NULL, NULL); } /* MSC - Dont do this check until we have a real IOD */ @@ -720,11 +712,12 @@ H5VL_iod_server_attr_exists_cb(AXE_engine_t UNUSED axe_engine, HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "can't open scratch pad"); /* get attribute ID */ - if(iod_kv_get_value(attr_kv_oh, IOD_TID_UNKNOWN, attr_name, &attr_id, - sizeof(iod_obj_id_t) , NULL, NULL) < 0) { + if(iod_kv_get_value(attr_kv_oh, IOD_TID_UNKNOWN, attr_name, &iod_link, + &kv_size, NULL, NULL) < 0) { ret = FALSE; } else { + attr_id = iod_link.iod_id; ret = TRUE; } @@ -746,7 +739,6 @@ done: input = (attr_op_in_t *)H5MM_xfree(input); op_data = (op_data_t *)H5MM_xfree(op_data); - last_comp = (char *)H5MM_xfree(last_comp); FUNC_LEAVE_NOAPI_VOID } /* end H5VL_iod_server_attr_exists_cb() */ @@ -776,15 +768,16 @@ H5VL_iod_server_attr_rename_cb(AXE_engine_t UNUSED axe_engine, iod_handle_t coh = input->coh; /* container handle */ iod_handle_t loc_handle = input->loc_oh; /* location handle to start lookup */ iod_obj_id_t loc_id = input->loc_id; /* The ID of the current location object */ - iod_handle_t cur_oh; /* current object handle accessed */ + iod_handle_t obj_oh; /* current object handle accessed */ iod_handle_t attr_kv_oh; /* KV handle holding attributes for object */ - iod_obj_id_t cur_id, attr_id; + iod_obj_id_t obj_id, attr_id; const char *loc_name = input->path; /* path to start hierarchy traversal */ const char *old_name = input->old_attr_name; const char *new_name = input->new_attr_name; - char *last_comp = NULL; /* the last component's name where attribute is created */ iod_kv_params_t kvs; /* KV lists for objects - used to unlink attribute object */ iod_kv_t kv; /* KV entry */ + iod_size_t kv_size = sizeof(H5VL_iod_link_t); + H5VL_iod_link_t iod_link; scratch_pad_t sp; herr_t ret_value = SUCCEED; @@ -794,21 +787,18 @@ H5VL_iod_server_attr_rename_cb(AXE_engine_t UNUSED axe_engine, fprintf(stderr, "Start attribute Rename %s to %s\n", old_name, new_name); #endif - /* the traversal will retrieve the location where the attribute - needs to be renamed. The traversal will fail if an intermediate - group does not exist. */ - if(H5VL_iod_server_traverse(coh, loc_id, loc_handle, loc_name, FALSE, - &last_comp, &cur_id, &cur_oh) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't traverse path"); + /* Open the object where the attribute needs to be checked. */ + if(H5VL_iod_server_open_path(coh, loc_id, loc_handle, loc_name, &obj_id, &obj_oh) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't open object"); /* get scratch pad of the parent */ - if(iod_obj_get_scratch(cur_oh, IOD_TID_UNKNOWN, &sp, NULL, NULL) < 0) + if(iod_obj_get_scratch(obj_oh, IOD_TID_UNKNOWN, &sp, NULL, NULL) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "can't get scratch pad for object"); /* close parent group if it is not the location we started the traversal into */ - if(loc_handle.cookie != cur_oh.cookie) { - iod_obj_close(cur_oh, NULL, NULL); + if(loc_handle.cookie != obj_oh.cookie) { + iod_obj_close(obj_oh, NULL, NULL); } /* MSC - Dont do this check until we have a real IOD */ @@ -823,21 +813,21 @@ H5VL_iod_server_attr_rename_cb(AXE_engine_t UNUSED axe_engine, HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "can't open scratch pad"); /* get attribute ID */ - if(iod_kv_get_value(attr_kv_oh, IOD_TID_UNKNOWN, old_name, &attr_id, - sizeof(iod_obj_id_t) , NULL, NULL) < 0) + if(iod_kv_get_value(attr_kv_oh, IOD_TID_UNKNOWN, old_name, &iod_link, + &kv_size, NULL, NULL) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "Attribute does not exist"); + attr_id = iod_link.iod_id; + /* remove attribute with old name */ kv.key = old_name; - kv.value = &attr_id; - kv.value_len = sizeof(iod_obj_id_t); kvs.kv = &kv; - if(iod_kv_unlink_keys(attr_kv_oh, IOD_TID_UNKNOWN, NULL, 1, &kvs, NULL) < 0) + if(iod_kv_unlink_keys(attr_kv_oh, IOD_TID_UNKNOWN, NULL, (iod_size_t)1, &kvs, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "Unable to unlink KV pair"); /* insert attribute with new name */ - if(H5VL_iod_insert_new_link(attr_kv_oh, IOD_TID_UNKNOWN, new_name, attr_id, - NULL, NULL, NULL) < 0) + if(H5VL_iod_insert_new_link(attr_kv_oh, IOD_TID_UNKNOWN, new_name, + H5L_TYPE_HARD, attr_id, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't insert KV value"); /* close the Attribute KV object */ @@ -858,7 +848,6 @@ done: input = (attr_rename_in_t *)H5MM_xfree(input); op_data = (op_data_t *)H5MM_xfree(op_data); - last_comp = (char *)H5MM_xfree(last_comp); FUNC_LEAVE_NOAPI_VOID } /* end H5VL_iod_server_attr_rename_cb() */ @@ -888,14 +877,15 @@ H5VL_iod_server_attr_remove_cb(AXE_engine_t UNUSED axe_engine, iod_handle_t coh = input->coh; /* container handle */ iod_handle_t loc_handle = input->loc_oh; /* location handle to start lookup */ iod_obj_id_t loc_id = input->loc_id; /* The ID of the current location object */ - iod_handle_t cur_oh; /* current object handle accessed */ + iod_handle_t obj_oh; /* current object handle accessed */ iod_handle_t attr_kv_oh; /* KV handle holding attributes for object */ - iod_obj_id_t cur_id, attr_id; + iod_obj_id_t obj_id, attr_id; const char *loc_name = input->path; /* path to start hierarchy traversal */ const char *attr_name = input->attr_name; /* attribute's name */ - char *last_comp = NULL; /* the last component's name where attribute is created */ iod_kv_params_t kvs; iod_kv_t kv; + iod_size_t kv_size = sizeof(H5VL_iod_link_t); + H5VL_iod_link_t iod_link; scratch_pad_t sp; herr_t ret_value = SUCCEED; @@ -905,21 +895,18 @@ H5VL_iod_server_attr_remove_cb(AXE_engine_t UNUSED axe_engine, fprintf(stderr, "Start attribute Remove %s\n", attr_name); #endif - /* the traversal will retrieve the location where the attribute - needs to be removed. The traversal will fail if an intermediate - group does not exist. */ - if(H5VL_iod_server_traverse(coh, loc_id, loc_handle, loc_name, FALSE, - &last_comp, &cur_id, &cur_oh) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't traverse path"); + /* Open the object where the attribute needs to be checked. */ + if(H5VL_iod_server_open_path(coh, loc_id, loc_handle, loc_name, &obj_id, &obj_oh) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't open object"); /* get scratch pad of the parent */ - if(iod_obj_get_scratch(cur_oh, IOD_TID_UNKNOWN, &sp, NULL, NULL) < 0) + if(iod_obj_get_scratch(obj_oh, IOD_TID_UNKNOWN, &sp, NULL, NULL) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "can't get scratch pad for object"); /* close parent group if it is not the location we started the traversal into */ - if(loc_handle.cookie != cur_oh.cookie) { - iod_obj_close(cur_oh, NULL, NULL); + if(loc_handle.cookie != obj_oh.cookie) { + iod_obj_close(obj_oh, NULL, NULL); } /* MSC - Dont do this check until we have a real IOD */ @@ -934,18 +921,17 @@ H5VL_iod_server_attr_remove_cb(AXE_engine_t UNUSED axe_engine, HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "can't open scratch pad"); /* get attribute ID */ - if(iod_kv_get_value(attr_kv_oh, IOD_TID_UNKNOWN, attr_name, &attr_id, - sizeof(iod_obj_id_t) , NULL, NULL) < 0) + if(iod_kv_get_value(attr_kv_oh, IOD_TID_UNKNOWN, attr_name, &iod_link, + &kv_size, NULL, NULL) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "Attribute does not exist"); + attr_id = iod_link.iod_id; + /* remove attribute */ kv.key = attr_name; - kv.value = &attr_id; - kv.value_len = sizeof(iod_obj_id_t); kvs.kv = &kv; - if(iod_kv_unlink_keys(attr_kv_oh,IOD_TID_UNKNOWN, NULL, 1, &kvs, NULL) < 0) + if(iod_kv_unlink_keys(attr_kv_oh,IOD_TID_UNKNOWN, NULL, (iod_size_t)1, &kvs, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "Unable to unlink KV pair"); - if(iod_obj_unlink(coh, attr_id, IOD_TID_UNKNOWN, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "Unable to unlink object"); @@ -962,7 +948,6 @@ done: input = (attr_op_in_t *)H5MM_xfree(input); op_data = (op_data_t *)H5MM_xfree(op_data); - last_comp = (char *)H5MM_xfree(last_comp); FUNC_LEAVE_NOAPI_VOID } /* end H5VL_iod_server_attr_remove_cb() */ @@ -990,7 +975,7 @@ H5VL_iod_server_attr_close_cb(AXE_engine_t UNUSED axe_engine, op_data_t *op_data = (op_data_t *)_op_data; attr_close_in_t *input = (attr_close_in_t *)op_data->input; iod_handle_t iod_oh = input->iod_oh; /* iod handle to close */ - iod_obj_id_t iod_id = input->iod_id; /* iod id of object to close */ + //iod_obj_id_t iod_id = input->iod_id; /* iod id of object to close */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT diff --git a/src/H5VLiod_client.c b/src/H5VLiod_client.c index 003d743..f630d53 100644 --- a/src/H5VLiod_client.c +++ b/src/H5VLiod_client.c @@ -540,7 +540,7 @@ H5VL_iod_request_complete(H5VL_iod_file_t *file, H5VL_iod_request_t *req) { hsize_t *count = (hsize_t *)req->data; - if(*count < 0) + if(*count == IOD_COUNT_UNDEFINED) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "MAP get_count failed at the server"); req->data = NULL; diff --git a/src/H5VLiod_common.h b/src/H5VLiod_common.h index 1a75e2c..6d696bf 100644 --- a/src/H5VLiod_common.h +++ b/src/H5VLiod_common.h @@ -28,6 +28,7 @@ #define NA_UNDEFINED NULL #define IOD_OH_UNDEFINED (pow(2.0,64.0) - 1) #define IOD_ID_UNDEFINED (pow(2.0,64.0) - 1) +#define IOD_COUNT_UNDEFINED (pow(2.0,64.0) - 1) #define H5VL_IOD_DEBUG 1 @@ -211,6 +212,7 @@ MERCURY_GEN_PROC(link_create_in_t, ((int8_t)(create_type)) ((iod_handle_t)(coh)) ((uint64_t)(parent_axe_id)) ((hg_string_t)(loc_name)) ((iod_handle_t)(target_loc_oh)) ((iod_obj_id_t)(target_loc_id)) ((uint64_t)(target_parent_axe_id)) ((hg_string_t)(target_name)) + ((hg_string_t)(link_value)) ((hid_t)(lapl_id)) ((hid_t)(lcpl_id)) ((uint64_t)(axe_id))) MERCURY_GEN_PROC(link_move_in_t, ((hbool_t)(copy_flag)) ((iod_handle_t)(coh)) ((iod_handle_t)(src_loc_oh)) ((iod_obj_id_t)(src_loc_id)) diff --git a/src/H5VLiod_compactor.c b/src/H5VLiod_compactor.c index 4092a15..77eff0f 100644 --- a/src/H5VLiod_compactor.c +++ b/src/H5VLiod_compactor.c @@ -384,7 +384,7 @@ int H5VL_iod_create_request_list (compactor *queue, request_list_t **list, HGOTO_ERROR(H5E_SYM, H5E_WRITEERROR, CP_FAIL, "can't get data from function shipper"); /* wait for it to complete */ - if(HG_SUCCESS != HG_Bulk_wait(bulk_request, HG_BULK_MAX_IDLE_TIME, HG_BULK_STATUS_IGNORE)) + if(HG_SUCCESS != HG_Bulk_wait(bulk_request, HG_MAX_IDLE_TIME, HG_STATUS_IGNORE)) HGOTO_ERROR(H5E_SYM, H5E_WRITEERROR, CP_FAIL, "can't get data from function shipper"); /* free the bds block handle */ diff --git a/src/H5VLiod_dset.c b/src/H5VLiod_dset.c index 93544a6..a7c2dff 100644 --- a/src/H5VLiod_dset.c +++ b/src/H5VLiod_dset.c @@ -1,33 +1,30 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * Copyright by the Board of Trustees of the University of Illinois. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the files COPYING and Copyright.html. COPYING can be found at the root * - * of the source code distribution tree; Copyright.html can be found at the * - * root level of an installed copy of the electronic HDF5 document set and * - * is linked from the top-level documents page. It can also be found at * - * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * - * access to either file, you may request a copy from help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - - - #include "H5VLiod_server.h" - #include "H5VLiod_compactor_queue.h" - #include "H5VLiod_compactor.h" - - #ifdef H5_HAVE_EFF - - - /* - * Programmer: Mohamad Chaarawi <chaarawi@hdfgroup.gov> - * June, 2013 - * - * Purpose: The IOD plugin server side dataset routines. - */ - + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#include "H5VLiod_server.h" +#include "H5VLiod_compactor_queue.h" +#include "H5VLiod_compactor.h" + +#ifdef H5_HAVE_EFF + +/* + * Programmer: Mohamad Chaarawi <chaarawi@hdfgroup.gov> + * June, 2013 + * + * Purpose: The IOD plugin server side dataset routines. + */ /*------------------------------------------------------------------------- @@ -180,8 +177,8 @@ H5VL_iod_server_dset_create_cb(AXE_engine_t UNUSED axe_engine, HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't close object"); /* add link in parent group to current object */ - if(H5VL_iod_insert_new_link(cur_oh, IOD_TID_UNKNOWN, last_comp, dset_id, - NULL, NULL, NULL) < 0) + if(H5VL_iod_insert_new_link(cur_oh, IOD_TID_UNKNOWN, last_comp, + H5L_TYPE_HARD, dset_id, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't insert KV value"); } @@ -222,7 +219,6 @@ done: FUNC_LEAVE_NOAPI_VOID } /* end H5VL_iod_server_dset_create_cb() */ - /*------------------------------------------------------------------------- * Function: H5VL_iod_server_dset_open_cb * @@ -249,10 +245,8 @@ H5VL_iod_server_dset_open_cb(AXE_engine_t UNUSED axe_engine, iod_handle_t loc_handle = input->loc_oh; /* location handle to start lookup */ iod_obj_id_t loc_id = input->loc_id; /* The ID of the current location object */ iod_obj_id_t dset_id; /* ID of the dataset to open */ - char *name = input->name; /* name of dset including path to open */ - char *last_comp; /* the name of the dataset obtained from the last component in the path */ - iod_handle_t cur_oh, mdkv_oh; - iod_obj_id_t cur_id; + iod_handle_t dset_oh, mdkv_oh; + const char *name = input->name; /* name of dset including path to open */ scratch_pad_t sp; herr_t ret_value = SUCCEED; @@ -262,29 +256,12 @@ H5VL_iod_server_dset_open_cb(AXE_engine_t UNUSED axe_engine, fprintf(stderr, "Start dataset Open %s\n", name); #endif - /* the traversal will retrieve the location where the dataset needs - to be opened. The traversal will fail if an intermediate group - does not exist. */ - if(H5VL_iod_server_traverse(coh, loc_id, loc_handle, name, FALSE, - &last_comp, &cur_id, &cur_oh) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't traverse path"); - - if(iod_kv_get_value(cur_oh, IOD_TID_UNKNOWN, last_comp, &dset_id, - sizeof(iod_obj_id_t), NULL, NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve Array ID from parent KV store"); - - /* close parent group and its scratch pad if it is not the - location we started the traversal into */ - if(loc_handle.cookie != cur_oh.cookie) { - iod_obj_close(cur_oh, NULL, NULL); - } - - /* open the dataset */ - if (iod_obj_open_write(coh, dset_id, NULL /*hints*/, &cur_oh, NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't open dataset"); + /* Traverse Path and open dset */ + if(H5VL_iod_server_open_path(coh, loc_id, loc_handle, name, &dset_id, &dset_oh) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't open object"); /* get scratch pad of the dataset */ - if(iod_obj_get_scratch(cur_oh, IOD_TID_UNKNOWN, &sp, NULL, NULL) < 0) + if(iod_obj_get_scratch(dset_oh, IOD_TID_UNKNOWN, &sp, NULL, NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "can't get scratch pad for object"); /* open the metadata scratch pad */ @@ -293,20 +270,20 @@ H5VL_iod_server_dset_open_cb(AXE_engine_t UNUSED axe_engine, /* MSC - retrieve metadata - NEED IOD */ #if 0 - if(H5VL_iod_get_metadata(mdkv_oh, IOD_TID_UNKNOWN, H5VL_IOD_PLIST, "create_plist", - NULL, NULL, NULL, &output.dcpl_id) < 0) + if(H5VL_iod_get_metadata(mdkv_oh, IOD_TID_UNKNOWN, H5VL_IOD_PLIST, H5VL_IOD_KEY_OBJ_CPL, + NULL, NULL, &output.dcpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "failed to retrieve dcpl"); - if(H5VL_iod_get_metadata(mdkv_oh, IOD_TID_UNKNOWN, H5VL_IOD_LINK_COUNT, "link_count", - NULL, NULL, NULL, &output.link_count) < 0) + if(H5VL_iod_get_metadata(mdkv_oh, IOD_TID_UNKNOWN, H5VL_IOD_LINK_COUNT, H5VL_IOD_KEY_OBJ_LINK_COUNT, + NULL, NULL, &output.link_count) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "failed to retrieve link count"); - if(H5VL_iod_get_metadata(mdkv_oh, IOD_TID_UNKNOWN, H5VL_IOD_DATATYPE, "datatype", - NULL, NULL, NULL, &output.type_id) < 0) + if(H5VL_iod_get_metadata(mdkv_oh, IOD_TID_UNKNOWN, H5VL_IOD_DATATYPE, H5VL_IOD_KEY_OBJ_DATATYPE, + NULL, NULL, &output.type_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "failed to retrieve datatype"); - if(H5VL_iod_get_metadata(mdkv_oh, IOD_TID_UNKNOWN, H5VL_IOD_DATASPACE, "dataspace", - NULL, NULL, NULL, &output.space_id) < 0) + if(H5VL_iod_get_metadata(mdkv_oh, IOD_TID_UNKNOWN, H5VL_IOD_DATASPACE, H5VL_IOD_KEY_OBJ_DATASPACE, + NULL, NULL, &output.space_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "failed to retrieve dataspace"); #endif @@ -320,10 +297,10 @@ H5VL_iod_server_dset_open_cb(AXE_engine_t UNUSED axe_engine, #if H5_DO_NATIVE printf("dataset name %s location %d\n", name, loc_handle.cookie); - cur_oh.cookie = H5Dopen(loc_handle.cookie, name, input->dapl_id); - HDassert(cur_oh.cookie); - output.space_id = H5Dget_space(cur_oh.cookie); - output.type_id = H5Dget_type(cur_oh.cookie); + dset_oh.cookie = H5Dopen(loc_handle.cookie, name, input->dapl_id); + HDassert(dset_oh.cookie); + output.space_id = H5Dget_space(dset_oh.cookie); + output.type_id = H5Dget_type(dset_oh.cookie); output.dcpl_id = H5P_DATASET_CREATE_DEFAULT; #else /* fake a dataspace, type, and dcpl */ @@ -331,7 +308,7 @@ H5VL_iod_server_dset_open_cb(AXE_engine_t UNUSED axe_engine, output.space_id = H5Screate_simple(1, dims, NULL); output.type_id = H5Tcopy(H5T_NATIVE_INT); output.dcpl_id = H5P_DATASET_CREATE_DEFAULT; - cur_oh.cookie = 1; + dset_oh.cookie = 1; #endif #if 0 @@ -361,7 +338,7 @@ H5VL_iod_server_dset_open_cb(AXE_engine_t UNUSED axe_engine, dset_id = 1; output.iod_id = dset_id; - output.iod_oh.cookie = cur_oh.cookie; + output.iod_oh.cookie = dset_oh.cookie; #if H5VL_IOD_DEBUG fprintf(stderr, "Done with dset open, sending response to client\n"); @@ -381,7 +358,6 @@ done: input = (dset_open_in_t *)H5MM_xfree(input); op_data = (op_data_t *)H5MM_xfree(op_data); - last_comp = (char *)H5MM_xfree(last_comp); FUNC_LEAVE_NOAPI_VOID } /* end H5VL_iod_server_dset_open_cb() */ @@ -423,182 +399,228 @@ H5VL_iod_server_dset_read_cb(AXE_engine_t UNUSED axe_engine, iod_array_iodesc_t file_desc; /* file descriptor used to read array */ iod_hyperslab_t *hslabs = NULL; /* IOD hyperslab generated from HDF5 filespace */ size_t size, buf_size, src_size, dst_size; - void *buf; /* buffer to hold outgoing data */ - uint8_t *buf_ptr; + void *buf = NULL; /* buffer to hold outgoing data */ + uint8_t *buf_ptr = NULL; hssize_t num_descriptors = 0, n; /* number of IOD file descriptors needed to describe filespace selection */ int ndims, i; /* dataset's rank/number of dimensions */ uint32_t cs = 0; /* checksum value */ size_t nelmts; /* number of elements selected to read */ na_addr_t dest = HG_Handler_get_addr(op_data->hg_handle); /* destination address to push data to */ hbool_t opened_locally = FALSE; /* flag to indicate whether we opened the dset here or if it was already open */ + iod_checksum_t *cs_list = NULL; + iod_ret_t *ret_list = NULL; + iod_array_io_t *io_array = NULL; /* arary for list I/O */ herr_t ret_value = SUCCEED; + FUNC_ENTER_NOAPI_NOINIT - FUNC_ENTER_NOAPI_NOINIT + /* open the dataset if we don't have the handle yet */ + if(iod_oh.cookie == IOD_OH_UNDEFINED) { + if (iod_obj_open_write(coh, iod_id, NULL /*hints*/, &iod_oh, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't open current group"); + opened_locally = TRUE; + } - /* open the dataset if we don't have the handle yet */ - if(iod_oh.cookie == IOD_OH_UNDEFINED) { - if (iod_obj_open_write(coh, iod_id, NULL /*hints*/, &iod_oh, NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't open current group"); - opened_locally = TRUE; - } + /* retrieve size of bulk data asked for to be read */ + size = HG_Bulk_handle_get_size(bulk_handle); - size = HG_Bulk_handle_get_size(bulk_handle); + /* get the number of points selected */ + nelmts = (size_t)H5Sget_select_npoints(space_id); - nelmts = (size_t)H5Sget_select_npoints(space_id); + /* retrieve source and destination datatype sizes for data conversion */ + src_size = H5Tget_size(src_id); + dst_size = H5Tget_size(dst_id); - src_size = H5Tget_size(src_id); - dst_size = H5Tget_size(dst_id); + /* adjust buffer size for datatype conversion */ + if(src_size > dst_size) { + buf_size = src_size * nelmts; +#if H5VL_IOD_DEBUG + fprintf(stderr, "Adjusted Buffer size because of datatype conversion from %d to %d: \n", + size, buf_size); +#endif + } + else { + buf_size = dst_size * nelmts; + if(buf_size != size) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "data size is not equal to expected size"); + } - /* adjust buffer size for datatype conversion */ - if(src_size > dst_size) { - buf_size = src_size * nelmts; - #if H5VL_IOD_DEBUG - fprintf(stderr, "Adjusted Buffer size because of datatype conversion from %d to %d: ", - size, buf_size); - #endif - } - else { - buf_size = dst_size * nelmts; - assert(buf_size == size); - } + /* allocate buffer to hold data */ + if(NULL == (buf = malloc(buf_size))) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate read buffer"); - if(NULL == (buf = malloc(buf_size))) - HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate read buffer"); + /* get the rank of the dataspace */ + if((ndims = H5Sget_simple_extent_ndims(space_id)) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get dataspace dimesnsion"); - /* get the rank of the dataspace */ - if((ndims = H5Sget_simple_extent_ndims(space_id)) < 0) - HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get dataspace dimesnsion"); + /* get the number of decriptors required, i.e. the numbers of iod + I/O operations needed */ + if(H5VL_iod_get_file_desc(space_id, &num_descriptors, NULL) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "unable to generate IOD file descriptor from dataspace selection"); - /* get the number of decriptors required, i.e. the numbers of iod - I/O operations needed */ - if(H5VL_iod_get_file_desc(space_id, &num_descriptors, NULL) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "unable to generate IOD file descriptor from dataspace selection"); + /* allocate the IOD hyperslab descriptors needed */ + if(NULL == (hslabs = (iod_hyperslab_t *)malloc + (sizeof(iod_hyperslab_t) * (size_t)num_descriptors))) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate iod array descriptors"); - /* allocate the IOD hyperslab descriptors needed */ - if(NULL == (hslabs = (iod_hyperslab_t *)malloc - (sizeof(iod_hyperslab_t) * (size_t)num_descriptors))) - HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate iod array descriptors"); + for(n=0 ; n<num_descriptors ; n++) { + hslabs[n].start = (iod_size_t *)malloc(sizeof(iod_size_t) * ndims); + hslabs[n].stride = (iod_size_t *)malloc(sizeof(iod_size_t) * ndims); + hslabs[n].block = (iod_size_t *)malloc(sizeof(iod_size_t) * ndims); + hslabs[n].count = (iod_size_t *)malloc(sizeof(iod_size_t) * ndims); + } - for(n=0 ; n<num_descriptors ; n++) { - hslabs[n].start = (iod_size_t *)malloc(sizeof(iod_size_t) * ndims); - hslabs[n].stride = (iod_size_t *)malloc(sizeof(iod_size_t) * ndims); - hslabs[n].block = (iod_size_t *)malloc(sizeof(iod_size_t) * ndims); - hslabs[n].count = (iod_size_t *)malloc(sizeof(iod_size_t) * ndims); - } + /* generate the descriptors after allocating the array */ + if(H5VL_iod_get_file_desc(space_id, &num_descriptors, hslabs) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "unable to generate IOD file descriptor from dataspace selection"); - /* generate the descriptors after allocating the array */ - if(H5VL_iod_get_file_desc(space_id, &num_descriptors, hslabs) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "unable to generate IOD file descriptor from dataspace selection"); - - buf_ptr = (uint8_t *)buf; - - /* read each descriptore from the IOD container */ - for(n=0 ; n<num_descriptors ; n++) { - hsize_t num_bytes = 0; - hsize_t num_elems = 0; - - /* determine how many bytes the current descriptor holds */ - for(i=0 ; i<ndims ; i++) - num_elems *= (hslabs[n].count[i] * hslabs[n].block[i]); - num_bytes = num_elems * src_size; - - #if 1 - /* set the memory descriptor */ - mem_desc.nfrag = 1; - mem_desc.frag->addr = (void *)buf_ptr; - mem_desc.frag->len = (iod_size_t)num_bytes; - #endif - - buf_ptr += num_bytes; - - /* set the file descriptor */ - file_desc = hslabs[n]; - - #if H5VL_IOD_DEBUG - for(i=0 ; i<ndims ; i++) { - fprintf(stderr, "Dim %d: start %zu stride %zu block %zu count %zu\n", - i, (size_t)file_desc.start[i], (size_t)file_desc.stride[i], - (size_t)file_desc.block[i], (size_t)file_desc.count[i]); - } - #endif - - /* read from array object */ - if(iod_array_read(iod_oh, IOD_TID_UNKNOWN, NULL, &mem_desc, &file_desc, NULL, NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_READERROR, FAIL, "can't read from array object"); - } + buf_ptr = (uint8_t *)buf; - { - hbool_t flag = FALSE; - int *ptr = (int *)buf; - - #if H5_DO_NATIVE - ret_value = H5Dread(iod_oh.cookie, src_id, H5S_ALL, space_id, dxpl_id, buf); - #else /* fake data */ - for(i=0;i<60;++i) - ptr[i] = i; - #endif - if(H5Tconvert(src_id, dst_id, nelmts, buf, NULL, dxpl_id) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "data type conversion failed"); - - /* calculate a checksum for the data to be sent */ - cs = H5checksum(buf, size, NULL); - - /* MSC - check if client requested to corrupt data */ - if(dxpl_id != H5P_DEFAULT && H5Pget_dxpl_inject_corruption(dxpl_id, &flag) < 0) - HGOTO_ERROR(H5E_SYM, H5E_READERROR, FAIL, "can't read property list"); - if(flag) { - fprintf(stderr, "Injecting a bad data value to cause corruption \n"); - ptr[0] = 10; - } - } + /* allocate the IOD array parameters for reading */ + if(NULL == (io_array = (iod_array_io_t *)malloc + (sizeof(iod_array_io_t) * (size_t)num_descriptors))) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate iod array"); - /* Create a new block handle to write the data */ - HG_Bulk_block_handle_create(buf, size, HG_BULK_READ_ONLY, &bulk_block_handle); + /* allocate cs array */ + if(NULL == (cs_list = (iod_checksum_t *)calloc + (sizeof(iod_checksum_t), (size_t)num_descriptors))) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate checksum array"); - /* Write bulk data here and wait for the data to be there */ - if(HG_SUCCESS != HG_Bulk_write_all(dest, bulk_handle, bulk_block_handle, &bulk_request)) - HGOTO_ERROR(H5E_SYM, H5E_READERROR, FAIL, "can't read from array object"); - /* wait for it to complete */ - if(HG_SUCCESS != HG_Bulk_wait(bulk_request, HG_BULK_MAX_IDLE_TIME, HG_BULK_STATUS_IGNORE)) - HGOTO_ERROR(H5E_SYM, H5E_READERROR, FAIL, "can't read from array object"); + /* allocate return array */ + if(NULL == (ret_list = (iod_ret_t *)calloc + (sizeof(iod_ret_t), (size_t)num_descriptors))) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate iod array"); - done: + /* Set up I/O list */ + for(n=0 ; n<num_descriptors ; n++) { + hsize_t num_bytes = 0; + hsize_t num_elems = 1; - output.ret = ret_value; - output.cs = cs; + /* determine how many bytes the current descriptor holds */ + for(i=0 ; i<ndims ; i++) + num_elems *= (hslabs[n].count[i] * hslabs[n].block[i]); + num_bytes = num_elems * src_size; - #if H5VL_IOD_DEBUG - fprintf(stderr, "Done with dset read, checksum %u, sending response to client\n", cs); - #endif +#if 0 + /* set the memory descriptor */ + mem_desc.nfrag = 1; + mem_desc.frag->addr = (void *)buf_ptr; + mem_desc.frag->len = (iod_size_t)num_bytes; +#endif - if(HG_SUCCESS != HG_Handler_start_output(op_data->hg_handle, &output)) - HDONE_ERROR(H5E_SYM, H5E_WRITEERROR, FAIL, "can't send result of write to client"); - if(HG_SUCCESS != HG_Bulk_block_handle_free(bulk_block_handle)) - HDONE_ERROR(H5E_SYM, H5E_WRITEERROR, FAIL, "can't free bds block handle"); + buf_ptr += num_bytes; - input = (dset_io_in_t *)H5MM_xfree(input); - op_data = (op_data_t *)H5MM_xfree(op_data); - free(buf); + /* set the file descriptor */ + file_desc = hslabs[n]; - /* free allocated descriptors */ - for(n=0 ; n<num_descriptors ; n++) { - free(hslabs[n].start); - free(hslabs[n].stride); - free(hslabs[n].block); - free(hslabs[n].count); - } - if(hslabs) - free(hslabs); +#if H5VL_IOD_DEBUG + for(i=0 ; i<ndims ; i++) { + fprintf(stderr, "Dim %d: start %zu stride %zu block %zu count %zu\n", + i, (size_t)file_desc.start[i], (size_t)file_desc.stride[i], + (size_t)file_desc.block[i], (size_t)file_desc.count[i]); + } +#endif - /* close the dataset if we opened it in this routine */ - if(opened_locally) { - if(iod_obj_close(iod_oh, NULL, NULL)) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't close Array object"); - } - FUNC_LEAVE_NOAPI_VOID - } /* end H5VL_iod_server_dset_read_cb() */ + /* setup list I/O parameters */ + io_array[n].oh = iod_oh; + io_array[n].hints = NULL; + io_array[n].mem_desc = &mem_desc; + io_array[n].io_desc = &file_desc; + io_array[n].cs = &cs_list[n]; + io_array[n].ret = &ret_list[n]; + } + + /* Read list IO */ + if(iod_array_read_list(coh, IOD_TID_UNKNOWN, (iod_size_t)num_descriptors, + io_array, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_READERROR, FAIL, "can't read from array object"); + + /* verify return values */ + for(n=0 ; n<num_descriptors ; n++) { + if(ret_list[n] < 0) + HGOTO_ERROR(H5E_SYM, H5E_READERROR, FAIL, "can't read from array object"); + } + + { + hbool_t flag = FALSE; + int *ptr = (int *)buf; + +#if H5_DO_NATIVE + ret_value = H5Dread(iod_oh.cookie, src_id, H5S_ALL, space_id, dxpl_id, buf); +#else /* fake data */ + for(i=0;i<60;++i) + ptr[i] = i; +#endif + + /* do data conversion */ + if(H5Tconvert(src_id, dst_id, nelmts, buf, NULL, dxpl_id) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "data type conversion failed"); + + /* calculate a checksum for the data to be sent */ + cs = H5checksum(buf, size, NULL); + + /* MSC - check if client requested to corrupt data */ + if(dxpl_id != H5P_DEFAULT && H5Pget_dxpl_inject_corruption(dxpl_id, &flag) < 0) + HGOTO_ERROR(H5E_SYM, H5E_READERROR, FAIL, "can't read property list"); + if(flag) { + fprintf(stderr, "Injecting a bad data value to cause corruption \n"); + ptr[0] = 10; + } + } + + /* Create a new block handle to write the data */ + HG_Bulk_block_handle_create(buf, size, HG_BULK_READ_ONLY, &bulk_block_handle); + + /* Write bulk data here and wait for the data to be there */ + if(HG_SUCCESS != HG_Bulk_write_all(dest, bulk_handle, bulk_block_handle, &bulk_request)) + HGOTO_ERROR(H5E_SYM, H5E_READERROR, FAIL, "can't read from array object"); + /* wait for it to complete */ + if(HG_SUCCESS != HG_Bulk_wait(bulk_request, HG_MAX_IDLE_TIME, HG_STATUS_IGNORE)) + HGOTO_ERROR(H5E_SYM, H5E_READERROR, FAIL, "can't read from array object"); + +done: + + output.ret = ret_value; + output.cs = cs; + +#if H5VL_IOD_DEBUG + fprintf(stderr, "Done with dset read, checksum %u, sending response to client\n", cs); +#endif + + if(HG_SUCCESS != HG_Handler_start_output(op_data->hg_handle, &output)) + HDONE_ERROR(H5E_SYM, H5E_WRITEERROR, FAIL, "can't send result of write to client"); + if(HG_SUCCESS != HG_Bulk_block_handle_free(bulk_block_handle)) + HDONE_ERROR(H5E_SYM, H5E_WRITEERROR, FAIL, "can't free bds block handle"); + input = (dset_io_in_t *)H5MM_xfree(input); + op_data = (op_data_t *)H5MM_xfree(op_data); + + if(buf) + free(buf); + + /* free allocated descriptors */ + for(n=0 ; n<num_descriptors ; n++) { + free(hslabs[n].start); + free(hslabs[n].stride); + free(hslabs[n].block); + free(hslabs[n].count); + } + if(hslabs) + free(hslabs); + if(io_array) + free(io_array); + if(cs_list) + free(cs_list); + if(ret_list) + free(ret_list); + + /* close the dataset if we opened it in this routine */ + if(opened_locally) { + if(iod_obj_close(iod_oh, NULL, NULL)) + HDONE_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't close Array object"); + } + FUNC_LEAVE_NOAPI_VOID +} /* end H5VL_iod_server_dset_read_cb() */ /*------------------------------------------------------------------------- * Function: H5VL_iod_server_dset_compactor_cb @@ -627,7 +649,6 @@ H5VL_iod_server_dset_read_cb(AXE_engine_t UNUSED axe_engine, request_list_t *wlist=NULL, *rlist=NULL; dataset_container_t *dlist=NULL, *drlist=NULL; int nentries = 0, ndatasets = 0, nrentries = 0, nrdatasets = 0; - iod_array_io_t *array_write = NULL; FUNC_ENTER_NOAPI_NOINIT @@ -681,17 +702,10 @@ H5VL_iod_server_dset_read_cb(AXE_engine_t UNUSED axe_engine, - array_write = (iod_array_io_t *) malloc (ndatasets * - sizeof (iod_array_io_t)); - if (NULL == array_write){ - HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "No space to allocate iod_array"); - } - - for ( i = 0; i < ndatasets; i ++){ + for ( i = 0; i < ndatasets; i ++){ H5VL_iod_compact_requests (wlist, &nentries,dlist[i].num_requests, dlist[i].requests); - if (CP_SUCCESS != H5VL_iod_server_compactor_write (wlist, nentries, - &array_write[i])){ + if (CP_SUCCESS != H5VL_iod_server_compactor_write (wlist, nentries)){ #if DEBUG_COMPACTOR fprintf (stderr,"COMPACTOR CB: compactor write failed \n"); #endif @@ -705,7 +719,7 @@ H5VL_iod_server_dset_read_cb(AXE_engine_t UNUSED axe_engine, The COH value can come from any of the list requests Once that is done --> execute the func : H5VL_iod_server_send_result - This sends results to all the clients about their completion. + This sends results to all the clients about their completion. There is a flaw in the IOD construction of io_array_t datastructure. They seem to have mem_desc and io_desc as pointers and there is no-way to specify @@ -713,11 +727,6 @@ H5VL_iod_server_dset_read_cb(AXE_engine_t UNUSED axe_engine, For now we can leave it at this! */ - - if (NULL != array_write){ - free(array_write); - array_write = NULL; - } if (NULL != wlist){ free(wlist); wlist = NULL; @@ -759,8 +768,7 @@ H5VL_iod_server_dset_read_cb(AXE_engine_t UNUSED axe_engine, *------------------------------------------------------------------------- */ -int H5VL_iod_server_compactor_write (void *_list, int num_requests, - iod_array_io_t *larray) +int H5VL_iod_server_compactor_write (void *_list, int num_requests) { int ret_value = CP_SUCCESS; @@ -780,13 +788,16 @@ int H5VL_iod_server_compactor_write (void *_list, int num_requests, hssize_t num_descriptors = 0, n =0; hbool_t opened_locally = FALSE; iod_hyperslab_t *hslabs = NULL; - iod_mem_desc_t *mem_desc = NULL; - iod_array_iodesc_t *file_desc=NULL; + iod_mem_desc_t *mem_desc = NULL, *tmp = NULL; + iod_array_iodesc_t file_desc; hsize_t num_bytes = 0, mem_reqs = 0, start_reqs = 0; hsize_t num_elems = 0, k = 0, j=0, curr_k = 0; hsize_t curr_j = 0, bytes_left = 0, curr_offset = 0; + iod_array_io_t *io_array = NULL; /* arary for list I/O */ + iod_checksum_t *cs_list = NULL; + iod_ret_t *ret_list = NULL; - + FUNC_ENTER_NOAPI_NOINIT if (num_requests <= 0){ @@ -800,15 +811,14 @@ int H5VL_iod_server_compactor_write (void *_list, int num_requests, #if DEBUG_COMPACTOR fprintf (stderr,"Entering COMPACTOR WRITE with requests %d\n", num_requests); #endif - + for (request_counter = 0; request_counter < num_requests; request_counter++){ - + if (list[request_counter].merged != USED_IN_MERGING){ - + /*When the request was used in merging we have to just manage the handle*/ if (list[request_counter].merged == NOT_MERGED){ - op_data = (op_data_t *)list[request_counter].op_data; input = (dset_io_in_t *)op_data->input; coh = input->coh; @@ -825,7 +835,7 @@ int H5VL_iod_server_compactor_write (void *_list, int num_requests, fprintf (stderr,"COMPACTOR WRITE: Request %d has not been merged \n", request_counter+1); size = list[request_counter].mem_length; buf = (void *)list[request_counter].mem_buf; - + #if DEBUG_COMPACTOR ptr = (int *) buf; fprintf(stderr,"COMPACTOR WRITE: Received a buffer of size %zd with values :", @@ -836,8 +846,7 @@ int H5VL_iod_server_compactor_write (void *_list, int num_requests, } fprintf(stderr, "\n"); #endif - } - + } if (list[request_counter].merged == MERGED){ op_data = (op_data_t *)list[request_counter].op_data; @@ -858,17 +867,15 @@ int H5VL_iod_server_compactor_write (void *_list, int num_requests, } dst_size = H5Tget_size(dst_id); - if(iod_oh.cookie == (int)IOD_OH_UNDEFINED) { if (iod_obj_open_write(coh, iod_id, NULL /*hints*/, &iod_oh, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't open current group"); opened_locally = TRUE; } - /* get the rank of the dataspace */ if((ndims = H5Sget_simple_extent_ndims(space_id)) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get dataspace dimesnsion"); - + /* get the number of decriptors required, i.e. the numbers of iod I/O operations needed */ if(H5VL_iod_get_file_desc(space_id, &num_descriptors, NULL) < 0) @@ -893,8 +900,8 @@ int H5VL_iod_server_compactor_write (void *_list, int num_requests, /* generate the descriptors after allocating the array */ if(H5VL_iod_get_file_desc(space_id, &num_descriptors, hslabs) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "unable to generate IOD file descriptor from dataspace selection"); - + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "unable to generate IOD file descriptor from dataspace selection"); + #if DEBUG_COMPACTOR for (n = 0; n < num_descriptors; n++){ fprintf (stderr,"COMPACTOR WRITE n: %llu\n", n); @@ -905,48 +912,58 @@ int H5VL_iod_server_compactor_write (void *_list, int num_requests, } } #endif - mem_desc = (iod_mem_desc_t *) malloc - (sizeof(iod_mem_desc_t) * (size_t)num_descriptors); - if (NULL == mem_desc){ - HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate iod array descriptors"); - } - file_desc = (iod_array_iodesc_t *) malloc - (sizeof(iod_array_iodesc_t) * (size_t)num_descriptors); - if (NULL == file_desc){ - HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate iod array descriptors"); - } + /* allocate the IOD array parameters for writing */ + if(NULL == (io_array = (iod_array_io_t *)malloc + (sizeof(iod_array_io_t) * (size_t)num_descriptors))) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate iod array"); + + /* allocate cs array */ + if(NULL == (cs_list = (iod_checksum_t *)calloc + (sizeof(iod_checksum_t), (size_t)num_descriptors))) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate checksum array"); + + /* allocate return array */ + if(NULL == (ret_list = (iod_ret_t *)calloc + (sizeof(iod_ret_t), (size_t)num_descriptors))) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate iod array"); curr_j = 0; - + for(n=0 ; n<num_descriptors ; n++) { - - num_bytes = 0; - num_elems = 1; - /* determine how many bytes the current descriptor holds */ - for(i=0 ; i<ndims ; i++) - num_elems *= (hslabs[n].count[i] * hslabs[n].block[i]); - num_bytes = num_elems * dst_size; - + num_bytes = 0; + num_elems = 1; + + /* determine how many bytes the current descriptor holds */ + for(i=0 ; i<ndims ; i++) + num_elems *= (hslabs[n].count[i] * hslabs[n].block[i]); + num_bytes = num_elems * dst_size; + + /*new memory descriptor for this hslab descriptor*/ + if (mem_desc != NULL) + mem_desc = NULL; + + + mem_desc = (iod_mem_desc_t *) malloc (sizeof(*mem_desc) + sizeof(mem_desc->frag[0])); + if (NULL == mem_desc){ + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL,"Can't allocate mem_desc \n"); + } + if (list[request_counter].merged == NOT_MERGED){ - + buf_ptr = (uint8_t *)buf; - + /* set the memory descriptor */ - - mem_desc[n].frag = (iod_mem_frag_t *) malloc (sizeof (iod_mem_frag_t)); - mem_desc[n].nfrag = 1; - mem_desc[n].frag->addr = (void *)buf_ptr; - mem_desc[n].frag->len = (iod_size_t)num_bytes; + mem_desc->nfrag = 1; + mem_desc->frag[0].addr = (void *)buf_ptr; + mem_desc->frag[0].len = (iod_size_t)num_bytes; buf_ptr += num_bytes; - if (NULL != buf){ - free(buf); - } + file_desc = hslabs[n]; } if (list[request_counter].merged == MERGED){ - + #if DEBUG_COMPACTOR fprintf (stderr, "COMPACTOR WRITE i: %d, num_mblocks: %zd, num_bytes: %lli, start_reqs: %lli\n", request_counter, list[request_counter].num_mblocks, num_bytes, start_reqs); @@ -959,10 +976,9 @@ int H5VL_iod_server_compactor_write (void *_list, int num_requests, mem_reqs = 0; fprintf (stderr,"COMPACTOR, curr_j: %lli, j: %lli, num_mblocks: %zd\n", curr_j, j, list[request_counter].num_mblocks); - + start_reqs = curr_j; for (j = curr_j; j < list[request_counter].num_mblocks; j++){ - if (k < num_bytes){ if (bytes_left){ k += bytes_left; @@ -975,7 +991,7 @@ int H5VL_iod_server_compactor_write (void *_list, int num_requests, curr_offset = list[request_counter].mblocks[j].offset + (list[request_counter].mblocks[j].len - bytes_left); mem_reqs += 1; - break; + break; } else{ /* <= case*/ k += list[request_counter].mblocks[j].len; @@ -984,92 +1000,82 @@ int H5VL_iod_server_compactor_write (void *_list, int num_requests, } } } - + curr_j += 1; fprintf (stderr,"COMPACTOR WRITE start_reqs: %lli, mem_reqs: %lli\n", start_reqs, mem_reqs); - + /*Determined the number of entries in the memory block for this hslab - descriptor*/ - mem_desc[n].nfrag = mem_reqs; - mem_desc[n].frag = - (iod_mem_frag_t *) malloc ((int)mem_reqs * sizeof(iod_mem_frag_t)); + descriptor*/ + + tmp = (iod_mem_desc_t *) realloc + (mem_desc, sizeof(*tmp) + (size_t)(mem_reqs * sizeof(mem_desc->frag[0]))); + if (tmp){ + mem_desc = tmp; + mem_desc->nfrag = mem_reqs; + tmp = NULL; + } - k = 0; fprintf (stderr,"COMPACTOR WRITE k: %lli start_reqs: %lli, mem_reqs: %lli\n", k, start_reqs, mem_reqs); - + for ( j = start_reqs; j < (start_reqs + mem_reqs); j++){ if ((j == curr_j) && (bytes_left)){ - mem_desc[n].frag[k].addr = (void *)(curr_offset); - mem_desc[n].frag[k].len = bytes_left; + mem_desc->frag[k].addr = (void *)(uintptr_t)(curr_offset); + mem_desc->frag[k].len = bytes_left; } else{ - mem_desc[n].frag[k].addr = (void *) + mem_desc->frag[k].addr = (void *)(uintptr_t) (list[request_counter].mblocks[j].offset); - mem_desc[n].frag[k].len = list[request_counter].mblocks[j].len; + mem_desc->frag[k].len = list[request_counter].mblocks[j].len; } k++; } curr_k += k; - + #if DEBUG_COMPACTOR for ( j = 0 ; j < k; j++){ - ptr = (int *)(mem_desc[n].frag[j].addr); + ptr = (int *)(mem_desc->frag[j].addr); fprintf(stderr, "COMPACTOR MERGED WRITE IOD_BUFFER j: %lli, k: %lli len: %llu\n", - j,k, mem_desc[n].frag[j].len); - for (ii = 0; ii < mem_desc[n].frag[j].len/sizeof(int); ii++) + j,k, mem_desc->frag[j].len); + for (ii = 0; ii < mem_desc->frag[j].len/sizeof(int); ii++) fprintf(stderr, "%d ", ptr[ii]); fprintf(stderr, "\n"); } fflush(stderr); #endif } - - file_desc[n] = hslabs[n]; + file_desc = hslabs[n]; + #if H5VL_IOD_DEBUG for(i=0 ; i<ndims ; i++) { fprintf(stderr, "Dim %d: start %zu stride %zu block %zu count %zu\n", - i, (size_t)file_desc[n].start[i], (size_t)file_desc[n].stride[i], - (size_t)file_desc[n].block[i], (size_t)file_desc[n].count[i]); + i, (size_t)file_desc.start[i], (size_t)file_desc.stride[i], + (size_t)file_desc.block[i], (size_t)file_desc.count[i]); } #endif + + io_array[n].oh = iod_oh; + io_array[n].hints = NULL; + io_array[n].mem_desc = mem_desc; + io_array[n].io_desc = &file_desc; + io_array[n].cs = &cs_list[n]; + io_array[n].ret = &ret_list[n]; } - - larray->oh = iod_oh; - larray->hints = NULL; - larray->mem_desc = mem_desc; - larray->io_desc = file_desc; - larray->cs = NULL; - larray->ret = NULL; + if(iod_array_write_list(coh, IOD_TID_UNKNOWN, (iod_size_t)num_descriptors, + io_array, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_READERROR, FAIL, "can't write array object"); - if(iod_array_write(iod_oh, IOD_TID_UNKNOWN, NULL, - mem_desc /*This is where the memory descriptor goes*/, - file_desc, - NULL, NULL) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write to array object"); if (NULL != mem_desc){ - for (n = 0; n < num_descriptors; n++){ - iod_mem_frag_t *frag = mem_desc[n].frag; - if (NULL != frag){ - free(frag); - } - } free(mem_desc); mem_desc = NULL; } - - if (NULL != file_desc){ - free(file_desc); - file_desc = NULL; - } - if (NULL != hslabs){ - for(n=0 ; n<num_descriptors ; n++) { + for(n=0 ; n<num_descriptors ; n++){ free(hslabs[n].start); free(hslabs[n].stride); free(hslabs[n].block); @@ -1077,6 +1083,12 @@ int H5VL_iod_server_compactor_write (void *_list, int num_requests, } free(hslabs); } + if(io_array) + free(io_array); + if(cs_list) + free(cs_list); + if(ret_list) + free(ret_list); /* write from array object */ /* TODO: VV Change checksum once that is fixed*/ if(opened_locally) { @@ -1084,13 +1096,8 @@ int H5VL_iod_server_compactor_write (void *_list, int num_requests, HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't close Array object"); } } - -#if H5VL_IOD_DEBUG - fprintf(stderr, "Done with dset write, sending %d response to client\n", ret_value); -#endif - } - + for (i = 0; i< num_requests; i++){ if (list[i].merged != MERGED){ op_data = (op_data_t *)list[i].op_data; @@ -1118,7 +1125,7 @@ int H5VL_iod_server_send_result (void *_list, dset_io_in_t *input = NULL; request_list_t *list = (request_list_t *)_list; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_NOAPI(NULL) for (i = 0; i< num_requests; i++){ if (list[i].merged != MERGED){ @@ -1131,12 +1138,13 @@ int H5VL_iod_server_send_result (void *_list, } } - done: + FUNC_LEAVE_NOAPI(ret_value); } - - + + + /*------------------------------------------------------------------------- * Function: H5VL_iod_server_dset_write_cb * @@ -1176,19 +1184,22 @@ H5VL_iod_server_dset_write_cb(AXE_engine_t UNUSED axe_engine, uint32_t data_cs = 0; hssize_t num_descriptors = 0, n; /* number of IOD file descriptors needed to describe filespace selection */ int ndims, i; /* dataset's rank/number of dimensions */ - void *buf; - uint8_t *buf_ptr; + unsigned u; + void *buf = NULL; + uint8_t *buf_ptr = NULL; size_t nelmts; /* number of elements selected to write */ hbool_t flag = FALSE; /* temp flag to indicate whether corruption will be inserted */ na_addr_t source = HG_Handler_get_addr(op_data->hg_handle); /* source address to pull data from */ hbool_t opened_locally = FALSE; /* flag to indicate whether we opened the dset here or if it was already open */ + iod_checksum_t *cs_list = NULL; + iod_ret_t *ret_list = NULL; + iod_array_io_t *io_array = NULL; /* arary for list I/O */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT #if H5VL_IOD_DEBUG - fprintf(stderr, "Dataset Write with AXE ID %llu, %d, %llu, %d\n", - input->axe_id, space_id, iod_id, iod_oh.cookie); + fprintf(stderr, "Dataset Write with AXE ID %llu\n",input->axe_id); #endif /* open the dataset if we don't have the handle yet */ if(iod_oh.cookie == IOD_OH_UNDEFINED) { @@ -1197,16 +1208,17 @@ H5VL_iod_server_dset_write_cb(AXE_engine_t UNUSED axe_engine, opened_locally = TRUE; } - /* Read bulk data here and wait for the data to be here */ + /* retrieve size of incoming bulk data */ size = HG_Bulk_handle_get_size(bulk_handle); - fprintf(stderr, "Size: %zd\n" ,size); - nelmts = (size_t)H5Sget_select_npoints(space_id); + /* get the number of points selected */ + nelmts = (size_t)H5Sget_select_npoints(space_id); + /* retrieve source and destination datatype sizes for data conversion */ src_size = H5Tget_size(src_id); dst_size = H5Tget_size(dst_id); - /* adjust buffer size for datatype conversion */ + /* adjust buffer size for data conversion */ if(src_size < dst_size) { buf_size = dst_size * nelmts; #if H5VL_IOD_DEBUG @@ -1216,13 +1228,15 @@ H5VL_iod_server_dset_write_cb(AXE_engine_t UNUSED axe_engine, } else { buf_size = src_size * nelmts; - fprintf (stderr, "size: %zd, buf_size: %zd\n", size, buf_size); - assert(buf_size == size); + if(buf_size != size) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "Incoming data size is not equal to expected size"); } + /* allocate buffer to hold data */ if(NULL == (buf = malloc(buf_size))) HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate read buffer"); + /* create a Mercury block handle for transfer */ HG_Bulk_block_handle_create(buf, size, HG_BULK_READWRITE, &bulk_block_handle); /* Write bulk data here and wait for the data to be there */ @@ -1247,7 +1261,7 @@ H5VL_iod_server_dset_write_cb(AXE_engine_t UNUSED axe_engine, if(dxpl_id != H5P_DEFAULT && H5Pget_dxpl_checksum(dxpl_id, &data_cs) < 0) HGOTO_ERROR(H5E_SYM, H5E_READERROR, FAIL, "can't read property list"); if(data_cs != 0) { - cs = H5_checksum_lookup4(buf, size, NULL); + cs = H5checksum(buf, size, NULL); if(cs != data_cs) { fprintf(stderr, "Errrr.. Network transfer Data corruption. expecting %u, got %u\n", data_cs, cs); @@ -1255,6 +1269,7 @@ H5VL_iod_server_dset_write_cb(AXE_engine_t UNUSED axe_engine, } } + /* convert data if needed */ if(H5Tconvert(src_id, dst_id, nelmts, buf, NULL, dxpl_id) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "data type conversion failed") @@ -1263,9 +1278,8 @@ H5VL_iod_server_dset_write_cb(AXE_engine_t UNUSED axe_engine, int *ptr = (int *)buf; fprintf(stderr, "DWRITE Received a buffer of size %d with values: ", size); - - for(i=0 ; i<size/sizeof(int) ; ++i) - fprintf(stderr, "%d ", ptr[i]); + for(u=0 ; u<size/sizeof(int) ; ++u) + fprintf(stderr, "%d ", ptr[u]); fprintf(stderr, "\n"); } #endif @@ -1297,6 +1311,21 @@ H5VL_iod_server_dset_write_cb(AXE_engine_t UNUSED axe_engine, buf_ptr = (uint8_t *)buf; + /* allocate the IOD array parameters for writing */ + if(NULL == (io_array = (iod_array_io_t *)malloc + (sizeof(iod_array_io_t) * (size_t)num_descriptors))) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate iod array"); + + /* allocate cs array */ + if(NULL == (cs_list = (iod_checksum_t *)calloc + (sizeof(iod_checksum_t), (size_t)num_descriptors))) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate checksum array"); + + /* allocate return array */ + if(NULL == (ret_list = (iod_ret_t *)calloc + (sizeof(iod_ret_t), (size_t)num_descriptors))) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate iod array"); + /* write each descriptore to the IOD container */ for(n=0 ; n<num_descriptors ; n++) { hsize_t num_bytes = 0; @@ -1327,9 +1356,24 @@ H5VL_iod_server_dset_write_cb(AXE_engine_t UNUSED axe_engine, } #endif - /* write from array object */ - if(iod_array_write(iod_oh, IOD_TID_UNKNOWN, NULL, &mem_desc, &file_desc, &cs, NULL) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write to array object"); + /* setup list I/O parameters */ + io_array[n].oh = iod_oh; + io_array[n].hints = NULL; + io_array[n].mem_desc = &mem_desc; + io_array[n].io_desc = &file_desc; + io_array[n].cs = &cs_list[n]; + io_array[n].ret = &ret_list[n]; + } + + /* Write list IO */ + if(iod_array_read_list(coh, IOD_TID_UNKNOWN, (iod_size_t)num_descriptors, + io_array, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_READERROR, FAIL, "can't read from array object"); + + /* verify return values */ + for(n=0 ; n<num_descriptors ; n++) { + if(ret_list[n] < 0) + HGOTO_ERROR(H5E_SYM, H5E_READERROR, FAIL, "can't read from array object"); } #if H5_DO_NATIVE @@ -1351,7 +1395,9 @@ done: input = (dset_io_in_t *)H5MM_xfree(input); op_data = (op_data_t *)H5MM_xfree(op_data); - free(buf); + + if(buf) + free(buf); /* free allocated descriptors */ for(n=0 ; n<num_descriptors ; n++) { @@ -1362,6 +1408,12 @@ done: } if(hslabs) free(hslabs); + if(io_array) + free(io_array); + if(cs_list) + free(cs_list); + if(ret_list) + free(ret_list); /* close the dataset if we opened it in this routine */ if(opened_locally) { @@ -1396,14 +1448,14 @@ H5VL_iod_server_dset_set_extent_cb(AXE_engine_t UNUSED axe_engine, iod_handle_t coh = input->coh; iod_handle_t iod_oh = input->iod_oh; iod_obj_id_t iod_id = input->iod_id; - int rank = input->dims.rank; /* rank of dataset */ + /* int rank = input->dims.rank; rank of dataset */ hbool_t opened_locally = FALSE; herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT #if H5VL_IOD_DEBUG - fprintf(stderr, "Start dataset Extend on the first dimension to %d\n", input->dims.size[0]); + fprintf(stderr, "Start dataset Extend\n"); #endif /* open the dataset if we don't have the handle yet */ @@ -1463,7 +1515,7 @@ H5VL_iod_server_dset_close_cb(AXE_engine_t UNUSED axe_engine, op_data_t *op_data = (op_data_t *)_op_data; dset_close_in_t *input = (dset_close_in_t *)op_data->input; iod_handle_t iod_oh = input->iod_oh; - iod_obj_id_t iod_id = input->iod_id; + //iod_obj_id_t iod_id = input->iod_id; herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT diff --git a/src/H5VLiod_dtype.c b/src/H5VLiod_dtype.c index 264ab27..a8c029c 100644 --- a/src/H5VLiod_dtype.c +++ b/src/H5VLiod_dtype.c @@ -167,22 +167,16 @@ H5VL_iod_server_dtype_commit_cb(AXE_engine_t UNUSED axe_engine, { iod_kv_t kv; char *key = NULL; - char *value = NULL; - key = strdup("size"); + key = strdup(H5VL_IOD_KEY_DTYPE_SIZE); kv.key = key; kv.value_len = sizeof(iod_size_t); - - if(NULL == (value = malloc (kv.value_len))) - HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate buffer"); - *((int32_t *)value) = buf_size; - kv.value = value; + kv.value = &buf_size; if (iod_kv_set(mdkv_oh, IOD_TID_UNKNOWN, NULL, &kv, NULL, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't set KV pair in parent"); free(key); - free(value); } /* close the Metadata KV object */ @@ -190,8 +184,8 @@ H5VL_iod_server_dtype_commit_cb(AXE_engine_t UNUSED axe_engine, HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't close object"); /* add link in parent group to current object */ - if(H5VL_iod_insert_new_link(cur_oh, IOD_TID_UNKNOWN, last_comp, dtype_id, - NULL, NULL, NULL) < 0) + if(H5VL_iod_insert_new_link(cur_oh, IOD_TID_UNKNOWN, last_comp, + H5L_TYPE_HARD, dtype_id, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't insert KV value"); } #if H5_DO_NATIVE @@ -258,39 +252,26 @@ H5VL_iod_server_dtype_open_cb(AXE_engine_t UNUSED axe_engine, iod_handle_t loc_handle = input->loc_oh; /* location handle to start lookup */ iod_obj_id_t loc_id = input->loc_id; /* The ID of the current location object */ iod_obj_id_t dtype_id; /* ID of datatype to open */ - iod_handle_t cur_oh, mdkv_oh; - iod_obj_id_t cur_id, mdkv_id; + iod_handle_t dtype_oh, mdkv_oh; const char *name = input->name; /* name of dtype including path to open */ - char *last_comp; /* the name of the datatype obtained from the last component in the path */ size_t buf_size; /* size of serialized datatype */ void *buf = NULL; iod_mem_desc_t mem_desc; /* memory descriptor used for reading */ iod_blob_iodesc_t file_desc; /* file descriptor used to write */ - iod_size_t kv_size = sizeof(iod_obj_id_t); scratch_pad_t sp; + iod_size_t kv_size; herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT fprintf(stderr, "Start datatype Open %s\n", name); - /* the traversal will retrieve the location where the datatype needs - to be opened. The traversal will fail if an intermediate group - does not exist. */ - if(H5VL_iod_server_traverse(coh, loc_id, loc_handle, name, FALSE, - &last_comp, &cur_id, &cur_oh) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't traverse path"); - - if(iod_kv_get_value(cur_oh, IOD_TID_UNKNOWN, last_comp, &dtype_id, - kv_size , NULL, NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve BLOB ID from parent KV store"); - - /* open the datatype */ - if (iod_obj_open_write(coh, dtype_id, NULL /*hints*/, &cur_oh, NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't open datatype"); + /* Traverse Path and open dtype */ + if(H5VL_iod_server_open_path(coh, loc_id, loc_handle, name, &dtype_id, &dtype_oh) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't open object"); /* get scratch pad of the datatype */ - if(iod_obj_get_scratch(cur_oh, IOD_TID_UNKNOWN, &sp, NULL, NULL) < 0) + if(iod_obj_get_scratch(dtype_oh, IOD_TID_UNKNOWN, &sp, NULL, NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "can't get scratch pad for object"); /* open the metadata scratch pad */ @@ -298,17 +279,20 @@ H5VL_iod_server_dtype_open_cb(AXE_engine_t UNUSED axe_engine, HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "can't open scratch pad"); #if 0 - if(H5VL_iod_get_metadata(mdkv_oh, IOD_TID_UNKNOWN, H5VL_IOD_PLIST, "create_plist", - NULL, NULL, NULL, &output.tcpl_id) < 0) + if(H5VL_iod_get_metadata(mdkv_oh, IOD_TID_UNKNOWN, H5VL_IOD_PLIST, H5VL_IOD_KEY_OBJ_CPL, + NULL, NULL, &output.tcpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "failed to retrieve tcpl"); - if(H5VL_iod_get_metadata(mdkv_oh, IOD_TID_UNKNOWN, H5VL_IOD_LINK_COUNT, "link_count", - NULL, NULL, NULL, &output.link_count) < 0) + if(H5VL_iod_get_metadata(mdkv_oh, IOD_TID_UNKNOWN, H5VL_IOD_LINK_COUNT, + H5VL_IOD_KEY_OBJ_LINK_COUNT, + NULL, NULL, &output.link_count) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "failed to retrieve link count"); + kv_size = sizeof(iod_size_t); + /* retrieve blob size metadata from scratch pad */ - if(iod_kv_get_value(mdkv_oh, IOD_TID_UNKNOWN, "size", &buf_size, - sizeof(iod_size_t), NULL, NULL) < 0) + if(iod_kv_get_value(mdkv_oh, IOD_TID_UNKNOWN, H5VL_IOD_KEY_DTYPE_SIZE, &buf_size, + &kv_size, NULL, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "datatype size lookup failed"); if(NULL == (buf = malloc(buf_size))) @@ -331,7 +315,7 @@ H5VL_iod_server_dtype_open_cb(AXE_engine_t UNUSED axe_engine, file_desc.frag->len = (iod_size_t)buf_size; /* read the serialized type value from the BLOB object */ - if(iod_blob_read(cur_oh, IOD_TID_UNKNOWN, NULL, &mem_desc, &file_desc, NULL, NULL) < 0) + if(iod_blob_read(dtype_oh, IOD_TID_UNKNOWN, NULL, &mem_desc, &file_desc, NULL, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to write BLOB object"); /* decode the datatype */ @@ -343,9 +327,9 @@ H5VL_iod_server_dtype_open_cb(AXE_engine_t UNUSED axe_engine, #if H5_DO_NATIVE printf("datatype name %s location %d\n", name, loc_handle.cookie); - cur_oh.cookie = H5Topen(loc_handle.cookie, name, input->tapl_id); - HDassert(cur_oh.cookie); - output.type_id = cur_oh.cookie; + dtype_oh.cookie = H5Topen(loc_handle.cookie, name, input->tapl_id); + HDassert(dtype_oh.cookie); + output.type_id = dtype_oh.cookie; output.tcpl_id = H5P_DATATYPE_CREATE_DEFAULT; #else /* fake a type, and tcpl */ @@ -354,7 +338,7 @@ H5VL_iod_server_dtype_open_cb(AXE_engine_t UNUSED axe_engine, #endif output.iod_id = dtype_id; - output.iod_oh = cur_oh; + output.iod_oh = dtype_oh; #if H5VL_IOD_DEBUG fprintf(stderr, "Done with dtype open, sending response to client\n"); @@ -373,7 +357,6 @@ done: H5Tclose(output.type_id); #endif - last_comp = (char *)H5MM_xfree(last_comp); input = (dtype_open_in_t *)H5MM_xfree(input); op_data = (op_data_t *)H5MM_xfree(op_data); @@ -403,7 +386,7 @@ H5VL_iod_server_dtype_close_cb(AXE_engine_t UNUSED axe_engine, op_data_t *op_data = (op_data_t *)_op_data; dtype_close_in_t *input = (dtype_close_in_t *)op_data->input; iod_handle_t iod_oh = input->iod_oh; - iod_obj_id_t iod_id = input->iod_id; + //iod_obj_id_t iod_id = input->iod_id; herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT diff --git a/src/H5VLiod_file.c b/src/H5VLiod_file.c index febc379..30c23ac 100644 --- a/src/H5VLiod_file.c +++ b/src/H5VLiod_file.c @@ -91,9 +91,7 @@ H5VL_iod_server_file_create_cb(AXE_engine_t UNUSED axe_engine, iod_kv_t kv; void *key = NULL; void *value = NULL; - size_t buf_size; hid_t fcpl_id; - uint64_t index; /* create the metadata KV object for the root group */ if(iod_obj_create(coh, IOD_TID_UNKNOWN, NULL, IOD_OBJ_KV, @@ -138,21 +136,21 @@ H5VL_iod_server_file_create_cb(AXE_engine_t UNUSED axe_engine, *((uint64_t *)value) = 1; kv.value_len = sizeof(uint64_t); - key = strdup("kv_index"); + key = strdup(H5VL_IOD_KEY_KV_IDS_INDEX); kv.key = (char *)key; if (iod_kv_set(mdkv_oh, IOD_TID_UNKNOWN, NULL, &kv, NULL, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't set KV pair in parent"); free(key); key = NULL; - key = strdup("array_index"); + key = strdup(H5VL_IOD_KEY_ARRAY_IDS_INDEX); kv.key = (char *)key; if (iod_kv_set(mdkv_oh, IOD_TID_UNKNOWN, NULL, &kv, NULL, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't set KV pair in parent"); free(key); key = NULL; - key = strdup("blob_index"); + key = strdup(H5VL_IOD_KEY_BLOB_IDS_INDEX); kv.key = (char *)key; if (iod_kv_set(mdkv_oh, IOD_TID_UNKNOWN, NULL, &kv, NULL, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't set KV pair in parent"); @@ -262,19 +260,19 @@ H5VL_iod_server_file_open_cb(AXE_engine_t UNUSED axe_engine, /* MSC - NEED IOD */ #if 0 - if(H5VL_iod_get_metadata(mdkv_oh, IOD_TID_UNKNOWN, H5VL_IOD_PLIST, "create_plist", - NULL, NULL, NULL, &output.fcpl_id) < 0) + if(H5VL_iod_get_metadata(mdkv_oh, IOD_TID_UNKNOWN, H5VL_IOD_PLIST, H5VL_IOD_KEY_OBJ_CPL, + NULL, NULL, &output.fcpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "failed to retrieve fcpl"); - if(iod_kv_get_value(mdkv_oh, IOD_TID_UNKNOWN, "kv_index", &output.kv_oid_index, + if(iod_kv_get_value(mdkv_oh, IOD_TID_UNKNOWN, H5VL_IOD_KEY_KV_IDS_INDEX, &output.kv_oid_index, sizeof(uint64_t), NULL, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "KV index lookup failed"); - if(iod_kv_get_value(mdkv_oh, IOD_TID_UNKNOWN, "array_index", &output.array_oid_index, + if(iod_kv_get_value(mdkv_oh, IOD_TID_UNKNOWN, H5VL_IOD_KEY_ARRAY_IDS_INDEX, &output.array_oid_index, sizeof(uint64_t), NULL, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "Array index lookup failed"); - if(iod_kv_get_value(mdkv_oh, IOD_TID_UNKNOWN, "blob_index", &output.blob_oid_index, + if(iod_kv_get_value(mdkv_oh, IOD_TID_UNKNOWN, H5VL_IOD_KEY_BLOB_IDS_INDEX, &output.blob_oid_index, sizeof(uint64_t), NULL, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "BLOB index lookup failed"); #endif diff --git a/src/H5VLiod_group.c b/src/H5VLiod_group.c index 018457d..57fd3cf 100644 --- a/src/H5VLiod_group.c +++ b/src/H5VLiod_group.c @@ -141,8 +141,8 @@ H5VL_iod_server_group_create_cb(AXE_engine_t UNUSED axe_engine, HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't close object"); /* add link in parent group to current object */ - if(H5VL_iod_insert_new_link(cur_oh, IOD_TID_UNKNOWN, last_comp, grp_id, - NULL, NULL, NULL) < 0) + if(H5VL_iod_insert_new_link(cur_oh, IOD_TID_UNKNOWN, last_comp, + H5L_TYPE_HARD, grp_id, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't insert KV value"); } /* end if */ @@ -209,10 +209,7 @@ H5VL_iod_server_group_open_cb(AXE_engine_t UNUSED axe_engine, iod_obj_id_t loc_id = input->loc_id; /* The ID of the current location object */ const char *name = input->name; /* group name including path to open */ iod_obj_id_t grp_id; /* The ID of the group that needs to be opened */ - iod_handle_t cur_oh, mdkv_oh; - iod_obj_id_t cur_id; - char *last_comp; /* the name of the group obtained from traversal function */ - iod_size_t kv_size; + iod_handle_t grp_oh, mdkv_oh; /* The group handle and its metadata KV handle */ scratch_pad_t sp; herr_t ret_value = SUCCEED; @@ -222,32 +219,12 @@ H5VL_iod_server_group_open_cb(AXE_engine_t UNUSED axe_engine, fprintf(stderr, "Start group open %s\n", name); #endif - /* the traversal will retrieve the location where the group needs - to be created. The traversal will fail if an intermediate group - does not exist. */ - if(H5VL_iod_server_traverse(coh, loc_id, loc_handle, name, FALSE, - &last_comp, &cur_id, &cur_oh) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't traverse path"); - - kv_size = sizeof(iod_obj_id_t); - - /* lookup group in the current location */ - if(iod_kv_get_value(cur_oh, IOD_TID_UNKNOWN, last_comp, &grp_id, &kv_size, NULL, NULL) < 0) { - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "Intermdiate group does not exist"); - } /* end if */ - - /* close parent group and its scratch pad if it is not the - location we started the traversal into */ - if(loc_handle.cookie != cur_oh.cookie) { - iod_obj_close(cur_oh, NULL, NULL); - } - - /* open the group */ - if (iod_obj_open_write(coh, grp_id, NULL, &cur_oh, NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't open current group"); + /* Traverse Path and open group */ + if(H5VL_iod_server_open_path(coh, loc_id, loc_handle, name, &grp_id, &grp_oh) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't open object"); /* get scratch pad of group */ - if(iod_obj_get_scratch(cur_oh, IOD_TID_UNKNOWN, &sp, NULL, NULL) < 0) + if(iod_obj_get_scratch(grp_oh, IOD_TID_UNKNOWN, &sp, NULL, NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "can't get scratch pad for object"); /* open the metadata scratch pad */ @@ -256,12 +233,13 @@ H5VL_iod_server_group_open_cb(AXE_engine_t UNUSED axe_engine, /* MSC - retrieve metadata, need IOD */ #if 0 - if(H5VL_iod_get_metadata(mdkv_oh, IOD_TID_UNKNOWN, H5VL_IOD_PLIST, "create_plist", - NULL, NULL, NULL, &output.gcpl_id) < 0) + if(H5VL_iod_get_metadata(mdkv_oh, IOD_TID_UNKNOWN, H5VL_IOD_PLIST, + H5VL_IOD_KEY_OBJ_CPL, NULL, NULL, &output.gcpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "failed to retrieve gcpl"); - if(H5VL_iod_get_metadata(mdkv_oh, IOD_TID_UNKNOWN, H5VL_IOD_LINK_COUNT, "link_count", - NULL, NULL, NULL, &output.link_count) < 0) + if(H5VL_iod_get_metadata(mdkv_oh, IOD_TID_UNKNOWN, H5VL_IOD_LINK_COUNT, + H5VL_IOD_KEY_OBJ_LINK_COUNT, + NULL, NULL, &output.link_count) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "failed to retrieve link count"); #endif @@ -270,12 +248,12 @@ H5VL_iod_server_group_open_cb(AXE_engine_t UNUSED axe_engine, HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't close meta data KV handle"); #if H5_DO_NATIVE - cur_oh.cookie = H5Gopen(loc_handle.cookie, name, input->gapl_id); - HDassert(cur_oh.cookie); + grp_oh.cookie = H5Gopen(loc_handle.cookie, name, input->gapl_id); + HDassert(grp_oh.cookie); #endif output.iod_id = grp_id; - output.iod_oh = cur_oh; + output.iod_oh = grp_oh; output.gcpl_id = H5P_GROUP_CREATE_DEFAULT; #if H5VL_IOD_DEBUG @@ -292,7 +270,6 @@ done: HG_Handler_start_output(op_data->hg_handle, &output); } - last_comp = (char *)H5MM_xfree(last_comp); input = (group_open_in_t *)H5MM_xfree(input); op_data = (op_data_t *)H5MM_xfree(op_data); diff --git a/src/H5VLiod_link.c b/src/H5VLiod_link.c index bab9663..c16e319 100644 --- a/src/H5VLiod_link.c +++ b/src/H5VLiod_link.c @@ -50,101 +50,150 @@ H5VL_iod_server_link_create_cb(AXE_engine_t UNUSED axe_engine, iod_handle_t coh = input->coh; /* the container handle */ iod_handle_t src_oh; /* The handle for creation src object */ iod_obj_id_t src_id; /* The ID of the creation src object */ - iod_handle_t cur_oh, target_oh; - iod_obj_id_t cur_id; + iod_handle_t target_oh; iod_obj_id_t target_id; /* The ID of the target object where link is created*/ char *src_last_comp = NULL, *dst_last_comp = NULL; - iod_kv_t kv; - iod_size_t kv_size = sizeof(iod_obj_id_t); + iod_size_t kv_size = sizeof(H5VL_iod_link_t); + H5VL_iod_link_t iod_link; herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT #if H5VL_IOD_DEBUG - fprintf(stderr, "Start link create\n"); + fprintf(stderr, "Start Link create\n"); #endif /* the traversal will retrieve the location where the link needs to be created from. The traversal will fail if an intermediate group does not exist. */ if(H5VL_iod_server_traverse(coh, input->loc_id, input->loc_oh, input->loc_name, FALSE, - &src_last_comp, &cur_id, &cur_oh) < 0) + &src_last_comp, &src_id, &src_oh) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't traverse path"); - /* lookup group in the current location */ - if(iod_kv_get_value(cur_oh, IOD_TID_UNKNOWN, src_last_comp, &src_id, &kv_size, NULL, NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "Intermdiate group does not exist"); - - /* close parent group if it is not the location we started the - traversal into */ - if(input->loc_oh.cookie != cur_oh.cookie) { - iod_obj_close(cur_oh, NULL, NULL); - } - - /* open the source group for link creation*/ - if (iod_obj_open_write(coh, src_id, NULL, &src_oh, NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't open current group"); +#if H5VL_IOD_DEBUG + fprintf(stderr, "new link name = %s\n", src_last_comp); +#endif if(H5VL_LINK_CREATE_HARD == create_type) { - /* Retrieve the parent of the object where the new link points - to. The traversal must not fail. */ - if(H5VL_iod_server_traverse(coh, input->target_loc_id, input->target_loc_oh, - input->target_name, FALSE, - &dst_last_comp, &cur_id, &cur_oh) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't traverse path"); - - /* lookup target object in the current location - the lookup - must succeed since this is a hard link. */ - if(iod_kv_get_value(cur_oh, IOD_TID_UNKNOWN, dst_last_comp, &target_id, &kv_size, - NULL, NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "Intermdiate group does not exist"); + scratch_pad_t sp; + iod_handle_t mdkv_oh; + uint64_t link_count = 0; + + /* Traverse Path and open the target object */ + if(H5VL_iod_server_open_path(coh, input->target_loc_id, input->target_loc_oh, + input->target_name, &target_id, &target_oh) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't open object"); + + /* add link in parent group to current object */ + if(H5VL_iod_insert_new_link(src_oh, IOD_TID_UNKNOWN, src_last_comp, + H5L_TYPE_HARD, target_id, NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't insert KV value"); + + /* get scratch pad */ + if(iod_obj_get_scratch(target_oh, IOD_TID_UNKNOWN, &sp, NULL, NULL) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "can't get scratch pad for object"); + + /* open the metadata scratch pad */ + if (iod_obj_open_write(coh, sp.mdkv_id, NULL /*hints*/, &mdkv_oh, NULL) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "can't open scratch pad"); + + if(H5VL_iod_get_metadata(mdkv_oh, IOD_TID_UNKNOWN, H5VL_IOD_LINK_COUNT, + H5VL_IOD_KEY_OBJ_LINK_COUNT, + NULL, NULL, &link_count) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "failed to retrieve link count"); + + link_count ++; + + /* insert link count metadata */ + if(H5VL_iod_insert_link_count(mdkv_oh, IOD_TID_UNKNOWN, link_count, + NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't insert KV value"); + + /* close the metadata scratch pad */ + if(iod_obj_close(mdkv_oh, NULL, NULL)) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't close object"); + + /* close the target location */ + if(input->target_loc_oh.cookie != target_oh.cookie) { + if(iod_obj_close(target_oh, NULL, NULL)) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't close object"); + } } else if(H5VL_LINK_CREATE_SOFT == create_type) { + iod_handle_t parent_oh; /* The handle for creation src object */ + iod_obj_id_t parent_id; /* The ID of the creation src object */ + /* Retrieve the parent of the object where the new link points to. The traversal must not fail. */ if(H5VL_iod_server_traverse(coh, input->target_loc_id, input->target_loc_oh, input->target_name, FALSE, - &dst_last_comp, &cur_id, &cur_oh) < 0) + &dst_last_comp, &parent_id, &parent_oh) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't traverse path"); /* lookup target object in the current location. The lookup might fail since this is a soft link */ - if(iod_kv_get_value(cur_oh, IOD_TID_UNKNOWN, dst_last_comp, - &target_id, &kv_size, NULL, NULL) < 0) { + if(iod_kv_get_value(parent_oh, IOD_TID_UNKNOWN, dst_last_comp, + &iod_link, &kv_size, NULL, NULL) < 0) { /* the lookup failed so just insert the target_id as undefined in the src object */ /* MSC - Figure out what to do when reaccessing this object after it was created */ target_id = IOD_ID_UNDEFINED; } - } - else - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "Invalid Link type"); + else { + target_id = iod_link.iod_id; + } - /* close parent group if it is not the location we started the - traversal into */ - if(input->loc_oh.cookie != cur_oh.cookie) { - iod_obj_close(cur_oh, NULL, NULL); - } + /* add link in parent group to the source location */ + if(H5VL_iod_insert_new_link(src_oh, IOD_TID_UNKNOWN, src_last_comp, + H5L_TYPE_SOFT, target_id, NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't insert KV value"); + + /* store the link value for new symbolic link */ + fprintf(stderr, "Full Soft link path = %s\n", input->link_value); + { + iod_kv_t kv; + char *key = NULL; + scratch_pad_t sp; + iod_handle_t mdkv_oh; + + /* get scratch pad */ + if(iod_obj_get_scratch(src_oh, IOD_TID_UNKNOWN, &sp, NULL, NULL) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "can't get scratch pad for object"); + + /* open the metadata scratch pad */ + if (iod_obj_open_write(coh, sp.mdkv_id, NULL, &mdkv_oh, NULL) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "can't open scratch pad"); - /* insert new link (target group's ID) in kv store of the source object */ - kv.key = HDstrdup(src_last_comp); - kv.value = &target_id; - kv.value_len = kv_size; - if (iod_kv_set(src_oh, IOD_TID_UNKNOWN, NULL, &kv, NULL, NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't set KV pair in parent"); - HDfree(kv.key); + key = strdup(H5VL_IOD_KEY_SOFT_LINK); + kv.key = key; + kv.value_len = strlen(input->link_value) + 1; + kv.value = input->link_value; - iod_obj_close(src_oh, NULL, NULL); + if (iod_kv_set(mdkv_oh, IOD_TID_UNKNOWN, NULL, &kv, NULL, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't set KV pair in parent"); - /* open the target object */ - if (iod_obj_open_write(coh, target_id, NULL, &target_oh, NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't open current group"); + free(key); - /* MSC - update metadata link information for this object */ + /* close the metadata scratch pad */ + if(iod_obj_close(mdkv_oh, NULL, NULL)) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't close object"); + } + + /* close parent group if it is not the location we started the + traversal into */ + if(input->target_loc_oh.cookie != parent_oh.cookie) { + iod_obj_close(parent_oh, NULL, NULL); + } + } + else + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "Invalid Link type"); - /* close the target object */ - iod_obj_close(target_oh, NULL, NULL); + /* close the source location */ + if(input->loc_oh.cookie != src_oh.cookie) { + if(iod_obj_close(src_oh, NULL, NULL)) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't close object"); + } #if H5_DO_NATIVE if(H5VL_LINK_CREATE_HARD == create_type) { @@ -163,7 +212,7 @@ H5VL_iod_server_link_create_cb(AXE_engine_t UNUSED axe_engine, done: #if H5VL_IOD_DEBUG - fprintf(stderr, "Done with link create, sending response to client\n"); + fprintf(stderr, "Done with link create, sending response %d to client\n", ret_value); #endif HG_Handler_start_output(op_data->hg_handle, &ret_value); @@ -204,10 +253,10 @@ H5VL_iod_server_link_move_cb(AXE_engine_t UNUSED axe_engine, iod_obj_id_t src_id; /* The ID of the src object */ iod_handle_t dst_oh; /* The handle for the dst object where link is created*/ iod_obj_id_t dst_id; /* The ID of the dst object where link is created*/ - iod_obj_id_t obj_id; /* The ID of the object to be moved/copied */ - char *last_comp = NULL; + char *src_last_comp = NULL, *dst_last_comp = NULL; iod_kv_t kv; - iod_size_t kv_size = sizeof(iod_obj_id_t); + iod_size_t kv_size = sizeof(H5VL_iod_link_t); + H5VL_iod_link_t iod_link; herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT @@ -220,37 +269,76 @@ H5VL_iod_server_link_move_cb(AXE_engine_t UNUSED axe_engine, to be moved/copied from. The traversal will fail if an intermediate group does not exist. */ if(H5VL_iod_server_traverse(coh, input->src_loc_id, input->src_loc_oh, input->src_loc_name, - FALSE, &last_comp, &src_id, &src_oh) < 0) + FALSE, &src_last_comp, &src_id, &src_oh) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't traverse path"); /* the traversal will retrieve the location where the link needs to be moved/copied to. The traversal will fail if an intermediate group does not exist. */ if(H5VL_iod_server_traverse(coh, input->dst_loc_id, input->dst_loc_oh, input->dst_loc_name, - FALSE, NULL, &dst_id, &dst_oh) < 0) + FALSE, &dst_last_comp, &dst_id, &dst_oh) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't traverse path"); /* lookup object ID in the current src location */ - if(iod_kv_get_value(src_oh, IOD_TID_UNKNOWN, last_comp, &obj_id, &kv_size, NULL, NULL) < 0) + if(iod_kv_get_value(src_oh, IOD_TID_UNKNOWN, src_last_comp, &iod_link, &kv_size, NULL, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "Object does not exist in source path"); /* Insert object in the destination path */ - kv.key = HDstrdup(last_comp); - kv.value = &obj_id; - kv.value_len = kv_size; - if (iod_kv_set(dst_oh, IOD_TID_UNKNOWN, NULL, &kv, NULL, NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't set KV pair in parent"); + if(H5VL_iod_insert_new_link(dst_oh, IOD_TID_UNKNOWN, dst_last_comp, + iod_link.link_type, iod_link.iod_id, NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't insert KV value"); + /* if the operation type is a Move, remove the KV pair from the source object */ if(!copy_flag) { iod_kv_params_t kvs; + kv.key = src_last_comp; kvs.kv = &kv; - if(iod_kv_unlink_keys(src_oh,IOD_TID_UNKNOWN, NULL, 1, &kvs, NULL) < 0) + + /* remove link from source object */ + if(iod_kv_unlink_keys(src_oh, IOD_TID_UNKNOWN, NULL, (iod_size_t)1, &kvs, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "Unable to unlink KV pair"); } - - HDfree(kv.key); + /* adjust link count on target object */ + else { + iod_handle_t target_oh; + iod_handle_t mdkv_oh; + scratch_pad_t sp; + uint64_t link_count = 0; + + /* open the current group */ + if (iod_obj_open_write(coh, iod_link.iod_id, NULL, &target_oh, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't open current group"); + + /* get scratch pad */ + if(iod_obj_get_scratch(target_oh, IOD_TID_UNKNOWN, &sp, NULL, NULL) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "can't get scratch pad for object"); + + /* open the metadata scratch pad */ + if (iod_obj_open_write(coh, sp.mdkv_id, NULL /*hints*/, &mdkv_oh, NULL) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "can't open scratch pad"); + + if(H5VL_iod_get_metadata(mdkv_oh, IOD_TID_UNKNOWN, H5VL_IOD_LINK_COUNT, + H5VL_IOD_KEY_OBJ_LINK_COUNT, + NULL, NULL, &link_count) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "failed to retrieve link count"); + + link_count ++; + + /* insert link count metadata */ + if(H5VL_iod_insert_link_count(mdkv_oh, IOD_TID_UNKNOWN, link_count, + NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't insert KV value"); + + /* close the metadata scratch pad */ + if(iod_obj_close(mdkv_oh, NULL, NULL)) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't close object"); + + /* close the target location */ + if(iod_obj_close(target_oh, NULL, NULL)) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't close object"); + } /* close source group if it is not the location we started the traversal into */ @@ -286,7 +374,8 @@ done: HG_Handler_start_output(op_data->hg_handle, &ret_value); - last_comp = (char *)H5MM_xfree(last_comp); + src_last_comp = (char *)H5MM_xfree(src_last_comp); + dst_last_comp = (char *)H5MM_xfree(dst_last_comp); input = (link_move_in_t *)H5MM_xfree(input); op_data = (op_data_t *)H5MM_xfree(op_data); @@ -323,7 +412,8 @@ H5VL_iod_server_link_exists_cb(AXE_engine_t UNUSED axe_engine, const char *loc_name = input->path; char *last_comp = NULL; htri_t ret = -1; - iod_size_t kv_size = sizeof(iod_obj_id_t); + iod_size_t kv_size = sizeof(H5VL_iod_link_t); + H5VL_iod_link_t iod_link; herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT @@ -342,7 +432,7 @@ H5VL_iod_server_link_exists_cb(AXE_engine_t UNUSED axe_engine, /* check the last component */ if(iod_kv_get_value(cur_oh, IOD_TID_UNKNOWN, last_comp, - &cur_id, &kv_size, NULL, NULL) < 0) { + &iod_link, &kv_size, NULL, NULL) < 0) { ret = FALSE; } /* end if */ else { @@ -359,7 +449,7 @@ done: /* close parent group if it is not the location we started the traversal into */ - if(loc_oh.cookie != IOD_OH_UNDEFINED && input->loc_oh.cookie != loc_oh.cookie) { + if(input->loc_oh.cookie != cur_oh.cookie) { iod_obj_close(loc_oh, NULL, NULL); } @@ -407,7 +497,8 @@ H5VL_iod_server_link_remove_cb(AXE_engine_t UNUSED axe_engine, char *last_comp = NULL; iod_kv_params_t kvs; iod_kv_t kv; - iod_size_t kv_size = sizeof(iod_obj_id_t); + iod_size_t kv_size = sizeof(H5VL_iod_link_t); + H5VL_iod_link_t iod_link; herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT @@ -424,20 +515,67 @@ H5VL_iod_server_link_remove_cb(AXE_engine_t UNUSED axe_engine, HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't traverse path"); /* lookup object ID in the current location */ - if(iod_kv_get_value(cur_oh, IOD_TID_UNKNOWN, last_comp, &obj_id, &kv_size, NULL, NULL) < 0) + if(iod_kv_get_value(cur_oh, IOD_TID_UNKNOWN, last_comp, &iod_link, &kv_size, NULL, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "Object does not exist in source path"); + obj_id = iod_link.iod_id; + /* unlink object from conainer */ - kv.key = HDstrdup(last_comp); - kv.value = &obj_id; - kv.value_len = kv_size; + kv.key = last_comp; kvs.kv = &kv; - if(iod_kv_unlink_keys(cur_oh, IOD_TID_UNKNOWN, NULL, 1, &kvs, NULL) < 0) + if(iod_kv_unlink_keys(cur_oh, IOD_TID_UNKNOWN, NULL, (iod_size_t)1, &kvs, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "Unable to unlink KV pair"); - HDfree(kv.key); - /* MSC - check the metadata information for the object and remove + /* MSC - NEED IOD */ +#if 0 + /* 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 == H5VL_LINK_CREATE_HARD) { + iod_handle_t obj_oh; + iod_handle_t mdkv_oh; + scratch_pad_t sp; + uint64_t link_count = 0; + + /* open the current group */ + if (iod_obj_open_write(coh, obj_id, NULL, &obj_oh, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't open current group"); + + /* get scratch pad */ + if(iod_obj_get_scratch(obj_oh, IOD_TID_UNKNOWN, &sp, NULL, NULL) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "can't get scratch pad for object"); + + /* open the metadata scratch pad */ + if (iod_obj_open_write(coh, sp.mdkv_id, NULL /*hints*/, &mdkv_oh, NULL) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "can't open scratch pad"); + + if(H5VL_iod_get_metadata(mdkv_oh, IOD_TID_UNKNOWN, H5VL_IOD_LINK_COUNT, + H5VL_IOD_KEY_OBJ_LINK_COUNT, + NULL, NULL, &link_count) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "failed to retrieve link count"); + + link_count --; + + /* if this is not the only link to the object, update the link count */ + if(0 != link_count) { + /* insert link count metadata */ + if(H5VL_iod_insert_link_count(mdkv_oh, IOD_TID_UNKNOWN, link_count, + NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't insert KV value"); + } + /* close the metadata scratch pad */ + if(iod_obj_close(mdkv_oh, NULL, NULL)) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't close object"); + /* close the object */ + if(iod_obj_close(obj_oh, NULL, NULL)) + HGOTO_ERROR(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) { + if(iod_obj_unlink(coh, obj_id, IOD_TID_UNKNOWN, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "Unable to unlink object"); + } + } +#endif /* close location object */ if(input->loc_oh.cookie != cur_oh.cookie) { diff --git a/src/H5VLiod_map.c b/src/H5VLiod_map.c index 002d315..27d239d 100644 --- a/src/H5VLiod_map.c +++ b/src/H5VLiod_map.c @@ -134,8 +134,8 @@ H5VL_iod_server_map_create_cb(AXE_engine_t UNUSED axe_engine, HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't close object"); /* add link in parent group to current object */ - if(H5VL_iod_insert_new_link(cur_oh, IOD_TID_UNKNOWN, last_comp, map_id, - NULL, NULL, NULL) < 0) + if(H5VL_iod_insert_new_link(cur_oh, IOD_TID_UNKNOWN, last_comp, + H5L_TYPE_HARD, map_id, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't insert KV value"); } /* end if */ @@ -196,10 +196,7 @@ H5VL_iod_server_map_open_cb(AXE_engine_t UNUSED axe_engine, iod_obj_id_t loc_id = input->loc_id; const char *name = input->name; iod_obj_id_t map_id; /* The ID of the map that needs to be opened */ - iod_handle_t cur_oh, mdkv_oh; - iod_obj_id_t cur_id, mdkv_id; - char *last_comp; /* the name of the map obtained from traversal function */ - iod_size_t kv_size; + iod_handle_t map_oh, mdkv_oh; scratch_pad_t sp; herr_t ret_value = SUCCEED; @@ -209,33 +206,12 @@ H5VL_iod_server_map_open_cb(AXE_engine_t UNUSED axe_engine, fprintf(stderr, "Start map open %s\n", name); #endif - /* the traversal will retrieve the location where the group needs - to be created. The traversal will fail if an intermediate group - does not exist. */ - if(H5VL_iod_server_traverse(coh, loc_id, loc_handle, name, FALSE, - &last_comp, &cur_id, &cur_oh) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't traverse path"); - - kv_size = sizeof(iod_obj_id_t); - - /* lookup map in the current location */ - if(iod_kv_get_value(cur_oh, IOD_TID_UNKNOWN, last_comp, &map_id, - &kv_size, NULL, NULL) < 0) { - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "Intermdiate group does not exist"); - } /* end if */ - - /* close parent group and its scratch pad if it is not the - location we started the traversal into */ - if(loc_handle.cookie != cur_oh.cookie) { - iod_obj_close(cur_oh, NULL, NULL); - } - - /* open the map */ - if (iod_obj_open_write(coh, map_id, NULL, &cur_oh, NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't open current map"); + /* Traverse Path and open map */ + if(H5VL_iod_server_open_path(coh, loc_id, loc_handle, name, &map_id, &map_oh) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't open object"); /* get scratch pad of map */ - if(iod_obj_get_scratch(cur_oh, IOD_TID_UNKNOWN, &sp, NULL, NULL) < 0) + if(iod_obj_get_scratch(map_oh, IOD_TID_UNKNOWN, &sp, NULL, NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "can't get scratch pad for object"); /* open the metadata scratch pad */ @@ -244,8 +220,9 @@ H5VL_iod_server_map_open_cb(AXE_engine_t UNUSED axe_engine, /* MSC - retrieve metadata - need IOD*/ #if 0 - if(H5VL_iod_get_metadata(mdkv_oh, IOD_TID_UNKNOWN, H5VL_IOD_LINK_COUNT, "link_count", - NULL, NULL, NULL, &output.link_count) < 0) + if(H5VL_iod_get_metadata(mdkv_oh, IOD_TID_UNKNOWN, H5VL_IOD_LINK_COUNT, + H5VL_IOD_KEY_OBJ_LINK_COUNT, + NULL, NULL, &output.link_count) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "failed to retrieve link count"); #endif @@ -254,7 +231,7 @@ H5VL_iod_server_map_open_cb(AXE_engine_t UNUSED axe_engine, HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't close meta data KV handle"); output.iod_id = map_id; - output.iod_oh = cur_oh; + output.iod_oh = map_oh; /* MSC - fake datatypes for now*/ output.keytype_id = H5Tcopy(H5T_NATIVE_INT); @@ -276,7 +253,6 @@ done: H5Tclose(output.keytype_id); H5Tclose(output.valtype_id); - last_comp = (char *)H5MM_xfree(last_comp); input = (map_open_in_t *)H5MM_xfree(input); op_data = (op_data_t *)H5MM_xfree(op_data); @@ -347,7 +323,7 @@ H5VL_iod_server_map_set_cb(AXE_engine_t UNUSED axe_engine, key_size = src_size; } - if(NULL == (key_buf = malloc(key_size))) + if(NULL == (key_buf = malloc((size_t)key_size))) HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate buffer"); memcpy(key_buf, key.buf, src_size); @@ -365,12 +341,11 @@ H5VL_iod_server_map_set_cb(AXE_engine_t UNUSED axe_engine, else { val_size = src_size; } - if(NULL == (val_buf = malloc(val_size))) + if(NULL == (val_buf = malloc((size_t)val_size))) HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate buffer"); memcpy(val_buf, val.buf, src_size); if(H5Tconvert(val_memtype_id, val_maptype_id, 1, val_buf, NULL, dxpl_id) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "data type conversion failed") - + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "data type conversion failed"); kv.key = key_buf; kv.value = val_buf; @@ -468,7 +443,7 @@ H5VL_iod_server_map_get_cb(AXE_engine_t UNUSED axe_engine, key_size = src_size; } - if(NULL == (key_buf = malloc(key_size))) + if(NULL == (key_buf = malloc((size_t)key_size))) HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate buffer"); memcpy(key_buf, key.buf, src_size); @@ -487,7 +462,7 @@ H5VL_iod_server_map_get_cb(AXE_engine_t UNUSED axe_engine, val_size = dst_size; } - if(NULL == (val_buf = malloc(val_size))) + if(NULL == (val_buf = malloc((size_t)val_size))) HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate buffer"); if(iod_kv_get_value(iod_oh, IOD_TID_UNKNOWN, key_buf, val_buf, @@ -542,7 +517,7 @@ done: /*------------------------------------------------------------------------- * Function: H5VL_iod_server_map_get_count_cb * - * Purpose: Get_Count a KV pair in map object + * Purpose: Get number of KV pairs in map object * * Return: Success: SUCCEED * Failure: Negative @@ -596,7 +571,7 @@ H5VL_iod_server_map_get_count_cb(AXE_engine_t UNUSED axe_engine, done: if(ret_value < 0) { - num = -1; + num = IOD_COUNT_UNDEFINED; if(HG_SUCCESS != HG_Handler_start_output(op_data->hg_handle, &num)) HDONE_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't send result of map get_count"); } @@ -673,7 +648,7 @@ H5VL_iod_server_map_exists_cb(AXE_engine_t UNUSED axe_engine, key_size = src_size; } - if(NULL == (key_buf = malloc(key_size))) + if(NULL == (key_buf = malloc((size_t)key_size))) HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate buffer"); memcpy(key_buf, key.buf, src_size); @@ -776,7 +751,7 @@ H5VL_iod_server_map_delete_cb(AXE_engine_t UNUSED axe_engine, key_size = src_size; } - if(NULL == (key_buf = malloc(key_size))) + if(NULL == (key_buf = malloc((size_t)key_size))) HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate buffer"); memcpy(key_buf, key.buf, src_size); @@ -786,7 +761,7 @@ H5VL_iod_server_map_delete_cb(AXE_engine_t UNUSED axe_engine, kv.key = key_buf; kvs.kv = &kv; - if(iod_kv_unlink_keys(iod_oh,IOD_TID_UNKNOWN, NULL, 1, &kvs, NULL) < 0) + if(iod_kv_unlink_keys(iod_oh,IOD_TID_UNKNOWN, NULL, (iod_size_t)1, &kvs, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "Unable to unlink KV pair"); done: diff --git a/src/H5VLiod_obj.c b/src/H5VLiod_obj.c index 7ff0e60..0801413 100644 --- a/src/H5VLiod_obj.c +++ b/src/H5VLiod_obj.c @@ -50,12 +50,8 @@ H5VL_iod_server_object_open_cb(AXE_engine_t UNUSED axe_engine, iod_handle_t coh = input->coh; /* the container handle */ iod_handle_t obj_oh; /* The handle for object */ iod_obj_id_t obj_id; /* The ID of the object */ - iod_handle_t cur_oh, mdkv_oh; - iod_obj_id_t cur_id; - char *last_comp = NULL; - iod_kv_t kv; + iod_handle_t mdkv_oh; scratch_pad_t sp; - iod_size_t kv_size = sizeof(iod_obj_id_t); herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT @@ -64,29 +60,13 @@ H5VL_iod_server_object_open_cb(AXE_engine_t UNUSED axe_engine, fprintf(stderr, "Start Object Open\n"); #endif - /* the traversal will retrieve the location where the object needs - to be opened to be created from. The traversal will fail if an - intermediate group does not exist. */ - if(H5VL_iod_server_traverse(coh, input->loc_id, input->loc_oh, input->loc_name, FALSE, - last_comp, &cur_id, &cur_oh) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't traverse path"); - - /* lookup object in the current location */ - if(iod_kv_get_value(cur_oh, IOD_TID_UNKNOWN, last_comp, &obj_id, &kv_size, NULL, NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "Intermdiate group does not exist"); - - /* close parent group if it is not the location we started the - traversal into */ - if(input->loc_oh.cookie != cur_oh.cookie) { - iod_obj_close(cur_oh, NULL, NULL); - } - - /* open the object */ - if (iod_obj_open_write(coh, obj_id, NULL, &obj_oh, NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't open current group"); + /* Traverse Path and open object */ + if(H5VL_iod_server_open_path(coh, input->loc_id, input->loc_oh, input->loc_name, + &obj_id, &obj_oh) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't open object"); /* get scratch pad of the object */ - if(iod_obj_get_scratch(cur_oh, IOD_TID_UNKNOWN, &sp, NULL, NULL) < 0) + if(iod_obj_get_scratch(obj_oh, IOD_TID_UNKNOWN, &sp, NULL, NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "can't get scratch pad for object"); /* open the metadata scratch pad */ @@ -95,33 +75,33 @@ H5VL_iod_server_object_open_cb(AXE_engine_t UNUSED axe_engine, /* MSC - NEED IOD */ #if 0 - if(H5VL_iod_get_metadata(mdkv_oh, IOD_TID_UNKNOWN, H5VL_IOD_OBJECT_TYPE, "object_type", - NULL, NULL, NULL, &output.obj_type) < 0) + if(H5VL_iod_get_metadata(mdkv_oh, IOD_TID_UNKNOWN, H5VL_IOD_OBJECT_TYPE, H5VL_IOD_KEY_OBJ_TYPE, + NULL, NULL, &output.obj_type) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "failed to retrieve link count"); - if(H5VL_iod_get_metadata(mdkv_oh, IOD_TID_UNKNOWN, H5VL_IOD_LINK_COUNT, "link_count", - NULL, NULL, NULL, &output.link_count) < 0) + if(H5VL_iod_get_metadata(mdkv_oh, IOD_TID_UNKNOWN, H5VL_IOD_LINK_COUNT, H5VL_IOD_KEY_OBJ_LINK_COUNT, + NULL, NULL, &output.link_count) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "failed to retrieve link count"); switch(output.obj_type) { case H5I_MAP: break; case H5I_GROUP: - if(H5VL_iod_get_metadata(mdkv_oh, IOD_TID_UNKNOWN, H5VL_IOD_PLIST, "create_plist", - NULL, NULL, NULL, &output.cpl_id) < 0) + if(H5VL_iod_get_metadata(mdkv_oh, IOD_TID_UNKNOWN, H5VL_IOD_PLIST, H5VL_IOD_KEY_OBJ_CPL, + NULL, NULL, &output.cpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "failed to retrieve dcpl"); break; case H5I_DATASET: - if(H5VL_iod_get_metadata(mdkv_oh, IOD_TID_UNKNOWN, H5VL_IOD_PLIST, "create_plist", - NULL, NULL, NULL, &output.cpl_id) < 0) + if(H5VL_iod_get_metadata(mdkv_oh, IOD_TID_UNKNOWN, H5VL_IOD_PLIST, H5VL_IOD_KEY_OBJ_CPL, + NULL, NULL, &output.cpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "failed to retrieve dcpl"); - if(H5VL_iod_get_metadata(mdkv_oh, IOD_TID_UNKNOWN, H5VL_IOD_DATATYPE, "datatype", - NULL, NULL, NULL, &output.type_id) < 0) + if(H5VL_iod_get_metadata(mdkv_oh, IOD_TID_UNKNOWN, H5VL_IOD_DATATYPE, H5VL_IOD_KEY_OBJ_DATATYPE, + NULL, NULL, &output.type_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "failed to retrieve datatype"); - if(H5VL_iod_get_metadata(mdkv_oh, IOD_TID_UNKNOWN, H5VL_IOD_DATASPACE, "dataspace", - NULL, NULL, NULL, &output.space_id) < 0) + if(H5VL_iod_get_metadata(mdkv_oh, IOD_TID_UNKNOWN, H5VL_IOD_DATASPACE, H5VL_IOD_KEY_OBJ_DATASPACE, + NULL, NULL, &output.space_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "failed to retrieve dataspace"); break; case H5I_DATATYPE: @@ -132,7 +112,7 @@ H5VL_iod_server_object_open_cb(AXE_engine_t UNUSED axe_engine, iod_blob_iodesc_t file_desc; /* file descriptor used to write */ /* retrieve blob size metadata from scratch pad */ - if(iod_kv_get_value(mdkv_oh, IOD_TID_UNKNOWN, "size", &buf_size, + if(iod_kv_get_value(mdkv_oh, IOD_TID_UNKNOWN, H5VL_IOD_KEY_DTYPE_SIZE, &buf_size, sizeof(iod_size_t), NULL, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "datatype size lookup failed"); @@ -150,7 +130,7 @@ H5VL_iod_server_object_open_cb(AXE_engine_t UNUSED axe_engine, file_desc.frag->len = (iod_size_t)buf_size; /* read the serialized type value from the BLOB object */ - if(iod_blob_read(cur_oh, IOD_TID_UNKNOWN, NULL, &mem_desc, &file_desc, NULL, NULL) < 0) + if(iod_blob_read(obj_oh, IOD_TID_UNKNOWN, NULL, &mem_desc, &file_desc, NULL, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to write BLOB object"); /* decode the datatype */ @@ -232,7 +212,6 @@ done: HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "not a valid object (dataset, group, or datatype)") } - last_comp = (char *)H5MM_xfree(last_comp); input = (object_op_in_t *)H5MM_xfree(input); op_data = (op_data_t *)H5MM_xfree(op_data); @@ -262,16 +241,16 @@ H5VL_iod_server_object_copy_cb(AXE_engine_t UNUSED axe_engine, op_data_t *op_data = (op_data_t *)_op_data; object_copy_in_t *input = (object_copy_in_t *)op_data->input; iod_handle_t coh = input->coh; /* the container handle */ - iod_handle_t src_oh; /* The handle for src parent */ - iod_obj_id_t src_id; /* The ID of the src parent */ iod_handle_t dst_oh; /* The handle for the dst object where link is created*/ iod_obj_id_t dst_id; /* The ID of the dst object where link is created*/ iod_obj_id_t obj_id; /* The ID of the object to be moved/copied */ + iod_handle_t obj_oh; /* The handle for the object to be moved/copied */ iod_obj_id_t new_id; /* The ID of the new object */ iod_handle_t mdkv_oh;/* The handle of the metadata KV for source object */ - char *last_comp = NULL, *new_name; + char *new_name = NULL; iod_kv_t kv; - iod_size_t kv_size = sizeof(iod_obj_id_t); + iod_size_t kv_size = sizeof(H5VL_iod_link_t); + H5VL_iod_link_t iod_link; herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT @@ -280,12 +259,10 @@ H5VL_iod_server_object_copy_cb(AXE_engine_t UNUSED axe_engine, fprintf(stderr, "Start object copy\n"); #endif - /* the traversal will retrieve the location where the object - exists. The traversal will fail if an intermediate group does - not exist. */ - if(H5VL_iod_server_traverse(coh, input->src_loc_id, input->src_loc_oh, input->src_loc_name, - FALSE, &last_comp, &src_id, &src_oh) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't traverse path"); + /* Traverse Path and open object */ + if(H5VL_iod_server_open_path(coh, input->src_loc_id, input->src_loc_oh, input->src_loc_name, + &obj_id, &obj_oh) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't open object"); /* the traversal will retrieve the location where the objects needs to be copied to. The traversal will fail if an @@ -294,47 +271,40 @@ H5VL_iod_server_object_copy_cb(AXE_engine_t UNUSED axe_engine, FALSE, &new_name, &dst_id, &dst_oh) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't traverse path"); - /* lookup object ID in the current src location */ - if(iod_kv_get_value(src_oh, IOD_TID_UNKNOWN, last_comp, &obj_id, &kv_size, NULL, NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "Object does not exist in source path"); /* MSC - NEED IOD & a lot more work*/ #if 0 - /* open the object */ - if (iod_obj_open_write(coh, obj_id, NULL, &obj_oh, NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't open current group"); - /* get scratch pad of the object */ - if(iod_obj_get_scratch(cur_oh, IOD_TID_UNKNOWN, &sp, NULL, NULL) < 0) + if(iod_obj_get_scratch(obj_oh, IOD_TID_UNKNOWN, &sp, NULL, NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "can't get scratch pad for object"); /* open the metadata scratch pad */ if (iod_obj_open_write(coh, sp.mdkv_id, NULL /*hints*/, &mdkv_oh, NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "can't open scratch pad"); - if(H5VL_iod_get_metadata(mdkv_oh, IOD_TID_UNKNOWN, H5VL_IOD_OBJECT_TYPE, "object_type", - NULL, NULL, NULL, &obj_type) < 0) + if(H5VL_iod_get_metadata(mdkv_oh, IOD_TID_UNKNOWN, H5VL_IOD_OBJECT_TYPE, H5VL_IOD_KEY_OBJ_TYPE, + NULL, NULL, &obj_type) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "failed to retrieve link count"); switch(obj_type) { case H5I_MAP: break; case H5I_GROUP: - if(H5VL_iod_get_metadata(mdkv_oh, IOD_TID_UNKNOWN, H5VL_IOD_PLIST, "create_plist", - NULL, NULL, NULL, &output.cpl_id) < 0) + if(H5VL_iod_get_metadata(mdkv_oh, IOD_TID_UNKNOWN, H5VL_IOD_PLIST, H5VL_IOD_KEY_OBJ_CPL, + NULL, NULL, &output.cpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "failed to retrieve dcpl"); break; case H5I_DATASET: - if(H5VL_iod_get_metadata(mdkv_oh, IOD_TID_UNKNOWN, H5VL_IOD_PLIST, "create_plist", - NULL, NULL, NULL, &output.cpl_id) < 0) + if(H5VL_iod_get_metadata(mdkv_oh, IOD_TID_UNKNOWN, H5VL_IOD_PLIST, H5VL_IOD_KEY_OBJ_CPL, + NULL, NULL, &output.cpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "failed to retrieve dcpl"); - if(H5VL_iod_get_metadata(mdkv_oh, IOD_TID_UNKNOWN, H5VL_IOD_DATATYPE, "datatype", - NULL, NULL, NULL, &output.type_id) < 0) + if(H5VL_iod_get_metadata(mdkv_oh, IOD_TID_UNKNOWN, H5VL_IOD_DATATYPE, H5VL_IOD_KEY_OBJ_DATATYPE, + NULL, NULL, &output.type_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "failed to retrieve datatype"); - if(H5VL_iod_get_metadata(mdkv_oh, IOD_TID_UNKNOWN, H5VL_IOD_DATASPACE, "dataspace", - NULL, NULL, NULL, &output.space_id) < 0) + if(H5VL_iod_get_metadata(mdkv_oh, IOD_TID_UNKNOWN, H5VL_IOD_DATASPACE, H5VL_IOD_KEY_OBJ_DATASPACE, + NULL, NULL, &output.space_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "failed to retrieve dataspace"); break; case H5I_DATATYPE: @@ -363,7 +333,7 @@ H5VL_iod_server_object_copy_cb(AXE_engine_t UNUSED axe_engine, file_desc.frag->len = (iod_size_t)buf_size; /* read the serialized type value from the BLOB object */ - if(iod_blob_read(cur_oh, IOD_TID_UNKNOWN, NULL, &mem_desc, &file_desc, NULL, NULL) < 0) + if(iod_blob_read(obj_oh, IOD_TID_UNKNOWN, NULL, &mem_desc, &file_desc, NULL, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to write BLOB object"); /* decode the datatype */ @@ -383,21 +353,16 @@ H5VL_iod_server_object_copy_cb(AXE_engine_t UNUSED axe_engine, if(iod_obj_close(mdkv_oh, NULL, NULL)) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't close object"); /* close the object handle */ - if(iod_obj_close(obj_oh, NULL, NULL)) + if(input->src_loc_oh.cookie != obj_oh.cookie && + iod_obj_close(obj_oh, NULL, NULL)) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't close object"); /* Insert object in the destination path */ - if(H5VL_iod_insert_new_link(dst_oh, IOD_TID_UNKNOWN, new_name, obj_id, - NULL, NULL, NULL) < 0) + if(H5VL_iod_insert_new_link(dst_oh, IOD_TID_UNKNOWN, new_name, + H5L_TYPE_HARD, obj_id, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't insert KV value"); #endif - /* close source group if it is not the location we started the - traversal into */ - if(input->src_loc_oh.cookie != src_oh.cookie) { - iod_obj_close(src_oh, NULL, NULL); - } - /* close dst group if it is not the location we started the traversal into */ if(input->dst_loc_oh.cookie != dst_oh.cookie) { @@ -418,7 +383,6 @@ done: HG_Handler_start_output(op_data->hg_handle, &ret_value); - last_comp = (char *)H5MM_xfree(last_comp); if(new_name) free(new_name); input = (object_copy_in_t *)H5MM_xfree(input); @@ -452,57 +416,37 @@ H5VL_iod_server_object_exists_cb(AXE_engine_t UNUSED axe_engine, iod_handle_t coh = input->coh; iod_handle_t loc_oh = input->loc_oh; iod_obj_id_t loc_id = input->loc_id; - iod_handle_t cur_oh; - iod_obj_id_t cur_id; + iod_handle_t obj_oh; + iod_obj_id_t obj_id; const char *loc_name = input->loc_name; - char *last_comp = NULL; htri_t ret = -1; - iod_size_t kv_size = sizeof(iod_obj_id_t); herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT - /* the traversal will retrieve the location where the object needs - to be checked */ - if(H5VL_iod_server_traverse(coh, loc_id, loc_oh, loc_name, FALSE, - &last_comp, &cur_id, &cur_oh) < 0) { + /* Traverse Path and open object */ + if(H5VL_iod_server_open_path(coh, loc_id, loc_oh, loc_name, &obj_id, &obj_oh) < 0) { ret = FALSE; HGOTO_DONE(SUCCEED); } - - /* check the last component */ - if(iod_kv_get_value(cur_oh, IOD_TID_UNKNOWN, last_comp, - &cur_id, &kv_size, NULL, NULL) < 0) { - ret = FALSE; - } /* end if */ else { - iod_handle_t obj_oh; - /* try to open the object */ - if (iod_obj_open_write(coh, cur_id, NULL, &obj_oh, NULL) < 0) { - ret = FALSE; - HGOTO_DONE(SUCCEED); - } - else { - /* close the object */ - iod_obj_close(obj_oh, NULL, NULL); - ret = TRUE; - } + /* close the object */ + if(loc_oh.cookie != obj_oh.cookie && + iod_obj_close(obj_oh, NULL, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't close object"); + + /* set return to TRUE */ + ret = TRUE; } +done: + #if H5_DO_NATIVE ret = H5Oexists_by_name(loc_oh.cookie, loc_name, H5P_DEFAULT); #else ret = FALSE; #endif -done: - - /* close parent group if it is not the location we started the - traversal into */ - if(loc_oh.cookie != IOD_OH_UNDEFINED && input->loc_oh.cookie != loc_oh.cookie) { - iod_obj_close(loc_oh, NULL, NULL); - } - #if H5VL_IOD_DEBUG fprintf(stderr, "Done with Object exists, sending response to client\n"); #endif @@ -511,7 +455,6 @@ done: input = (object_op_in_t *)H5MM_xfree(input); op_data = (op_data_t *)H5MM_xfree(op_data); - last_comp = (char *)H5MM_xfree(last_comp); FUNC_LEAVE_NOAPI_VOID } /* end H5VL_iod_server_object_exists_cb() */ @@ -541,40 +484,21 @@ H5VL_iod_server_object_set_comment_cb(AXE_engine_t UNUSED axe_engine, iod_handle_t coh = input->coh; iod_handle_t loc_oh = input->loc_oh; iod_obj_id_t loc_id = input->loc_id; - iod_handle_t cur_oh, mdkv_oh; - iod_obj_id_t cur_id, obj_id; + iod_handle_t obj_oh, mdkv_oh; + iod_obj_id_t obj_id; const char *loc_name = input->path; const char *comment = input->comment; - char *last_comp = NULL; scratch_pad_t sp; - iod_size_t kv_size = sizeof(iod_obj_id_t); herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT - /* the traversal will retrieve the location where the link needs - to be removed. The traversal will fail if an intermediate group - does not exist. */ - if(H5VL_iod_server_traverse(coh, loc_id, loc_oh, loc_name, - FALSE, &last_comp, &cur_id, &cur_oh) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't traverse path"); - - /* lookup object ID in the current location */ - if(iod_kv_get_value(cur_oh, IOD_TID_UNKNOWN, last_comp, &obj_id, &kv_size, NULL, NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "Object does not exist in source path"); - - /* close parent group and its scratch pad if it is not the - location we started the traversal into */ - if(loc_oh.cookie != cur_oh.cookie) { - iod_obj_close(cur_oh, NULL, NULL); - } - - /* open the object */ - if (iod_obj_open_write(coh, obj_id, NULL /*hints*/, &cur_oh, NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't open object"); + /* Traverse Path and open object */ + if(H5VL_iod_server_open_path(coh, loc_id, loc_oh, loc_name, &obj_id, &obj_oh) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't open object"); /* get scratch pad of the object */ - if(iod_obj_get_scratch(cur_oh, IOD_TID_UNKNOWN, &sp, NULL, NULL) < 0) + if(iod_obj_get_scratch(obj_oh, IOD_TID_UNKNOWN, &sp, NULL, NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "can't get scratch pad for object"); /* open the metadata scratch pad */ @@ -584,25 +508,24 @@ H5VL_iod_server_object_set_comment_cb(AXE_engine_t UNUSED axe_engine, { iod_kv_t kv; char *key = NULL; - char *value = NULL; - key = strdup("comment"); + key = strdup(H5VL_IOD_KEY_OBJ_COMMENT); kv.key = key; kv.value_len = strlen(comment) + 1; - value = strdup(comment); - kv.value = value; + kv.value = &comment; if (iod_kv_set(mdkv_oh, IOD_TID_UNKNOWN, NULL, &kv, NULL, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't set KV pair in parent"); free(key); - free(value); } /* close metadata KV and object */ if(iod_obj_close(mdkv_oh, NULL, NULL)) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't close object"); - if(iod_obj_close(cur_oh, NULL, NULL)) + + if(loc_oh.cookie != obj_oh.cookie && + iod_obj_close(obj_oh, NULL, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't close object"); #if H5_DO_NATIVE @@ -617,7 +540,6 @@ done: HG_Handler_start_output(op_data->hg_handle, &ret_value); - last_comp = (char *)H5MM_xfree(last_comp); input = (object_set_comment_in_t *)H5MM_xfree(input); op_data = (op_data_t *)H5MM_xfree(op_data); @@ -652,42 +574,21 @@ H5VL_iod_server_object_get_comment_cb(AXE_engine_t UNUSED axe_engine, iod_handle_t loc_oh = input->loc_oh; iod_obj_id_t loc_id = input->loc_id; size_t length = input->length; - iod_handle_t cur_oh, mdkv_oh; - iod_obj_id_t cur_id, obj_id; + iod_handle_t obj_oh, mdkv_oh; + iod_obj_id_t obj_id; const char *loc_name = input->path; - char *last_comp = NULL; - iod_kv_params_t kvs; - iod_kv_t kv; - iod_size_t kv_size = sizeof(iod_obj_id_t); scratch_pad_t sp; ssize_t size = 0; herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT - /* the traversal will retrieve the location where the link needs - to be removed. The traversal will fail if an intermediate group - does not exist. */ - if(H5VL_iod_server_traverse(coh, loc_id, loc_oh, loc_name, - FALSE, &last_comp, &cur_id, &cur_oh) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't traverse path"); - - /* lookup object ID in the current location */ - if(iod_kv_get_value(cur_oh, IOD_TID_UNKNOWN, last_comp, &obj_id, &kv_size, NULL, NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "Object does not exist in source path"); - - /* close parent group and its scratch pad if it is not the - location we started the traversal into */ - if(loc_oh.cookie != cur_oh.cookie) { - iod_obj_close(cur_oh, NULL, NULL); - } - - /* open the object */ - if (iod_obj_open_write(coh, obj_id, NULL /*hints*/, &cur_oh, NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't open object"); + /* Traverse Path and open object */ + if(H5VL_iod_server_open_path(coh, loc_id, loc_oh, loc_name, &obj_id, &obj_oh) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't open object"); /* get scratch pad of the object */ - if(iod_obj_get_scratch(cur_oh, IOD_TID_UNKNOWN, &sp, NULL, NULL) < 0) + if(iod_obj_get_scratch(obj_oh, IOD_TID_UNKNOWN, &sp, NULL, NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "can't get scratch pad for object"); /* open the metadata scratch pad */ @@ -700,14 +601,14 @@ H5VL_iod_server_object_get_comment_cb(AXE_engine_t UNUSED axe_engine, /* MSC - NEED IOD */ #if 0 - if(iod_kv_get_value(oh, IOD_TID_UNKNOWN, "comment", NULL, + if(iod_kv_get_value(oh, IOD_TID_UNKNOWN, H5VL_IOD_KEY_OBJ_COMMENT, NULL, &size, NULL, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "lookup failed"); if(NULL == (value = malloc (size))) HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate value buffer"); - if(iod_kv_get_value(oh, IOD_TID_UNKNOWN, "comment", value, + if(iod_kv_get_value(oh, IOD_TID_UNKNOWN, H5VL_IOD_KEY_OBJ_COMMENT, value, &size, NULL, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "lookup failed"); @@ -720,7 +621,9 @@ H5VL_iod_server_object_get_comment_cb(AXE_engine_t UNUSED axe_engine, /* close metadata KV and object */ if(iod_obj_close(mdkv_oh, NULL, NULL)) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't close object"); - if(iod_obj_close(cur_oh, NULL, NULL)) + + if(loc_oh.cookie != obj_oh.cookie && + iod_obj_close(obj_oh, NULL, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't close object"); @@ -756,7 +659,6 @@ done: free(comment.value); free(comment.value_size); - last_comp = (char *)H5MM_xfree(last_comp); input = (object_get_comment_in_t *)H5MM_xfree(input); op_data = (op_data_t *)H5MM_xfree(op_data); diff --git a/src/H5VLiod_server.c b/src/H5VLiod_server.c index 73109b8..066bd1d 100644 --- a/src/H5VLiod_server.c +++ b/src/H5VLiod_server.c @@ -13,18 +13,10 @@ * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#define H5G_PACKAGE /*suppress error about including H5Gpkg */ - -#include "H5Gpkg.h" /* Groups */ -#include "H5Sprivate.h" /* Dataspaces */ -#include "H5WBprivate.h" /* Wrapped Buffers */ #include "H5VLiod_server.h" #ifdef H5_HAVE_EFF -#include "H5VLiod_compactor_queue.h" -#include "H5VLiod_compactor.h" - /* * Programmer: Mohamad Chaarawi <chaarawi@hdfgroup.gov> * February, 2013 @@ -32,6 +24,10 @@ * Purpose: The IOD plugin server side routines. */ +#include "H5VLiod_compactor_queue.h" +#include "H5VLiod_compactor.h" + + static AXE_engine_t engine; static MPI_Comm iod_comm; static iod_obj_id_t ROOT_ID; @@ -39,15 +35,6 @@ static int num_peers = 0; static int terminate_requests = 0; static hbool_t shutdown = FALSE; static int request_id = 0; - - -#if 0 -static herr_t H5VL_iod_typeinfo_init(hid_t dset_type_id, const H5D_dxpl_cache_t *dxpl_cache, - hid_t dxpl_id, hid_t mem_type_id, hbool_t do_write, - H5D_type_info_t *type_info); -static herr_t H5VL_iod_typeinfo_term(const H5D_type_info_t *type_info); -#endif - herr_t H5VLiod_start_handler(MPI_Comm comm, MPI_Info UNUSED info) { @@ -57,7 +44,7 @@ H5VLiod_start_handler(MPI_Comm comm, MPI_Info UNUSED info) herr_t ret_value = SUCCEED; MPI_Comm_size(comm, &num_procs); - + iod_comm = comm; /* initialize the netwrok class */ @@ -67,10 +54,6 @@ H5VLiod_start_handler(MPI_Comm comm, MPI_Info UNUSED info) if(HG_SUCCESS != HG_Bulk_init(network_class)) return FAIL; - compactor_queue_flag = 0; - pthread_mutex_init(&lock, NULL); - curr_queue = NULL; - /* Register function and encoding/decoding functions */ MERCURY_HANDLER_REGISTER("eff_init", H5VL_iod_server_eff_init, eff_init_in_t, ret_t); @@ -202,6 +185,8 @@ H5VLiod_start_handler(MPI_Comm comm, MPI_Info UNUSED info) return FAIL; if(HG_SUCCESS != HG_Handler_finalize()) return FAIL; + if(NA_SUCCESS != NA_Finalize(network_class)) + return FAIL; return ret_value; } @@ -278,8 +263,6 @@ H5VL_iod_server_eff_finalize(hg_handle_t handle) shutdown = TRUE; } - - done: HG_Handler_start_output(handle, &ret_value); FUNC_LEAVE_NOAPI(ret_value) @@ -1287,7 +1270,6 @@ H5VL_iod_server_dset_read(hg_handle_t handle) op_data->hg_handle = handle; op_data->input = (void *)input; -#if 0 if(input->parent_axe_id) { if (AXE_SUCCEED != AXEcreate_task(engine, input->axe_id, 1, &input->parent_axe_id, 0, NULL, @@ -1299,14 +1281,6 @@ H5VL_iod_server_dset_read(hg_handle_t handle) H5VL_iod_server_dset_read_cb, op_data, NULL)) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, HG_FAIL, "can't insert task into async engine"); } -#endif - -#if 1 - if(CP_SUCCESS != H5VL_iod_server_dset_compactor(op_data, READ)){ - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, HG_FAIL, "compactor task failed for READ\n"); - } -#endif - done: FUNC_LEAVE_NOAPI(ret_value) @@ -1365,8 +1339,6 @@ H5VL_iod_server_dset_write(hg_handle_t handle) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, HG_FAIL, "can't insert task into async engine"); } #endif - fprintf (stderr, "AXE ID : %llu\n", - input->axe_id); #if 1 if(CP_SUCCESS != H5VL_iod_server_dset_compactor(op_data, WRITE)){ @@ -1374,11 +1346,13 @@ H5VL_iod_server_dset_write(hg_handle_t handle) } #endif + done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_iod_server_dset_write() */ + /*--------------------------------------------------------------------- * Function: H5VL_iod_server_dset_compactor * @@ -1488,7 +1462,6 @@ int H5VL_iod_server_dset_compactor(op_data_t *op_data, int request_type) FUNC_LEAVE_NOAPI(ret_value); } /*end H5VL_iod_server_dset_compactor */ - /*------------------------------------------------------------------------- * Function: H5VL_iod_server_dset_set_extent @@ -1504,6 +1477,8 @@ int H5VL_iod_server_dset_compactor(op_data_t *op_data, int request_type) * *------------------------------------------------------------------------- */ + + int H5VL_iod_server_dset_set_extent(hg_handle_t handle) { @@ -1635,9 +1610,10 @@ H5VL_iod_reconstruct_parents (AXE_engine_t axe_engine, done: FUNC_LEAVE_NOAPI(ret_value) - + } + /*------------------------------------------------------------------------- * Function: H5VL_iod_server_dset_close @@ -1757,6 +1733,7 @@ H5VL_iod_server_dset_close(hg_handle_t handle) FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_iod_server_dset_close() */ + /*------------------------------------------------------------------------- * Function: H5VL_iod_server_dtype_commit @@ -2984,742 +2961,4 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_iod_server_map_close() */ -herr_t -H5VL_iod_server_traverse(iod_handle_t coh, iod_obj_id_t loc_id, iod_handle_t loc_handle, - const char *path, hbool_t create_interm_grps, - char **last_comp, iod_obj_id_t *iod_id, iod_handle_t *iod_oh) -{ - char comp_buf[1024]; /* Temporary buffer for path components */ - char *comp; /* Pointer to buffer for path components */ - H5WB_t *wb = NULL; /* Wrapped buffer for temporary buffer */ - size_t nchars; /* component name length */ - iod_handle_t cur_oh, prev_oh; - iod_obj_id_t cur_id; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI_NOINIT - - assert(FALSE == create_interm_grps); - - cur_oh = loc_handle; - - if(cur_oh.cookie == IOD_OH_UNDEFINED) { - /* open the current group */ - if (iod_obj_open_write(coh, loc_id, NULL /*hints*/, &cur_oh, NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't open current group"); - } - - /* Wrap the local buffer for serialized header info */ - if(NULL == (wb = H5WB_wrap(comp_buf, sizeof(comp_buf)))) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't wrap buffer") - /* Get a pointer to a buffer that's large enough */ - if(NULL == (comp = (char *)H5WB_actual(wb, (HDstrlen(path) + 1)))) - HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't get actual buffer") - - /* Traverse the path */ - while((path = H5G__component(path, &nchars)) && *path) { - const char *s; /* Temporary string pointer */ - iod_size_t kv_size; - - /* Copy the component path into a null-terminated buffer. */ - HDmemcpy(comp, path, nchars); - comp[nchars] = '\0'; - - /* - * The special path `.' is a no-op. - */ - if('.' == comp[0] && !comp[1]) { - path += nchars; - continue; - } /* end if */ - - /* Check if this is the last component of the path */ - if(!((s = H5G__component(path + nchars, NULL)) && *s)) { - if(last_comp) { - *last_comp = HDstrdup(comp); - } - break; - } - - kv_size = sizeof(iod_obj_id_t); - - prev_oh = cur_oh; - - /* lookup next object in the current group */ - if(iod_kv_get_value(cur_oh, IOD_TID_UNKNOWN, comp, &cur_id, &kv_size, NULL, NULL) < 0) { - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "Intermdiate group does not exist"); - } /* end if */ - else { - /* Close previous handle unless it is the original one */ - if(loc_handle.cookie != prev_oh.cookie && - iod_obj_close(prev_oh, NULL, NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't close current object handle"); - - /* open the current group */ - if (iod_obj_open_write(coh, cur_id, NULL, &cur_oh, NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't open current group"); - } - - /* Advance to next component in string */ - path += nchars; - } /* end while */ - - /* Release temporary component buffer */ - if(wb && H5WB_unwrap(wb) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't release wrapped buffer"); - - *iod_id = cur_id; - *iod_oh = cur_oh; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} - -herr_t -H5VL_iod_get_file_desc(hid_t space_id, hssize_t *count, iod_hyperslab_t *hslabs) -{ - hssize_t num_descriptors = 0, n; - int ndims = 0, i; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI_NOINIT - - /* get the rank of this dataspace */ - if((ndims = H5Sget_simple_extent_ndims(space_id)) < 0) - HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get dataspace dimesnsion"); - - switch(H5Sget_select_type(space_id)) { - case H5S_SEL_NONE: - /* nothing selected */ - num_descriptors = 0; - HGOTO_DONE(SUCCEED); - case H5S_SEL_ALL: - /* The entire dataspace is selected, 1 large iod hyperslab is needed */ - num_descriptors = 1; - - if(NULL != hslabs) { - hsize_t dims[H5S_MAX_RANK]; - - /* get the dimensions sizes of the dataspace */ - if(H5Sget_simple_extent_dims(space_id, dims, NULL) < 0) - HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get dataspace dimesnsion sizes"); - /* populate the hyperslab */ - for(i=0 ; i<ndims ; i++) { - hslabs[0].start[i] = 0; - hslabs[0].stride[i] = 1; - hslabs[0].block[i] = dims[i]; - hslabs[0].count[i] = 1; - } - } - break; - case H5S_SEL_POINTS: - { - /* we need a hyperslab element for each point */ - if((num_descriptors = H5Sget_select_elem_npoints(space_id)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "invalid point selection"); - - if(NULL != hslabs) { - hsize_t *points = NULL; - size_t point_count = 0; - - point_count = ndims * num_descriptors * sizeof(hsize_t); - - if(NULL == (points = (hsize_t *)malloc(point_count))) - HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate array for points coords"); - - if(H5Sget_select_elem_pointlist(space_id, (hsize_t)0, - (hsize_t)num_descriptors, points) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "Failed to retrieve point coordinates"); - - /* populate the hyperslab */ - for(n=0 ; n<num_descriptors ; n++) { - hsize_t *cur_ptr = points; /* temp pointer into points array */ - - /* adjust the current pointer to the current point */ - cur_ptr += n*ndims; - for(i=0 ; i<ndims ; i++) { - hslabs[n].start[i] = *(cur_ptr+i); - hslabs[n].stride[i] = 1; - hslabs[n].count[i] = 1; - hslabs[n].block[i] = *(cur_ptr+ndims+i) + 1 - hslabs[n].start[i]; - } - } - - free(points); - } - break; - } - case H5S_SEL_HYPERSLABS: - { - /* if the selection is a regular hyperslab - selection, only 1 iod hyperslab object is - needed */ - if(H5Sselect_is_regular(space_id)) { - num_descriptors = 1; - - if(NULL != hslabs) { - if(H5Sget_reg_hyperslab_params(space_id, - hslabs[0].start, - hslabs[0].stride, - hslabs[0].count, - hslabs[0].block) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "Failed to retrieve hyperslab selection"); - } - } - /* Otherwise populate the hslabs by getting every block */ - else { - if((num_descriptors = H5Sget_select_hyper_nblocks(space_id)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "invalid hyperslab selection"); - - if(NULL != hslabs) { - hsize_t *blocks = NULL; - size_t block_count = 0; - - block_count = ndims * num_descriptors * sizeof(hsize_t) * 2; - - if(NULL == (blocks = (hsize_t *)malloc(block_count))) - HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate array for points coords"); - - fprintf(stderr, "block count = %zu\n", block_count); - - if(H5Sget_select_hyper_blocklist(space_id, (hsize_t)0, - (hsize_t)num_descriptors, blocks) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "Failed to retrieve point coordinates"); - - /* populate the hyperslab */ - for(n=0 ; n<num_descriptors ; n++) { - hsize_t *cur_ptr = blocks; /* temp pointer into blocks array */ - - /* adjust the current pointer to the current block */ - cur_ptr += n*ndims*2; - for(i=0 ; i<ndims ; i++) { - hslabs[n].start[i] = *(cur_ptr+i); - hslabs[n].stride[i] = 1; - hslabs[n].count[i] = 1; - hslabs[n].block[i] = *(cur_ptr+ndims+i) + 1 - hslabs[n].start[i]; - } - } - - free(blocks); - } - } - break; - } - case H5S_SEL_ERROR: - case H5S_SEL_N: - default: - HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "Invalid Selection type"); - } - - *count = num_descriptors; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} - -herr_t -H5VL_iod_insert_plist(iod_handle_t oh, iod_trans_id_t tid, hid_t plist_id, - iod_hint_list_t *hints, iod_checksum_t *cs, iod_event_t *event) -{ - void *key = NULL; - void *value = NULL; - iod_kv_t kv; - size_t buf_size; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI_NOINIT - - /* insert group creation properties in Metadata KV */ - key = strdup("create_plist"); - - /* determine the buffer size needed to store the encoded plist */ - if(H5Pencode(plist_id, NULL, &buf_size) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTENCODE, FAIL, "failed to encode plist"); - if(NULL == (value = malloc (buf_size))) - HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate plist buffer"); - /* encode plist */ - if(H5Pencode(plist_id, value, &buf_size) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTENCODE, FAIL, "failed to encode plist"); - - kv.key = (char *)key; - kv.value = value; - kv.value_len = (iod_size_t)buf_size; - /* insert kv pair into scratch pad */ - if (iod_kv_set(oh, tid, hints, &kv, cs, event) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't set KV pair in parent"); - -done: - if(key) { - free(key); - key = NULL; - } - if(value) { - free(value); - value = NULL; - } - - FUNC_LEAVE_NOAPI(ret_value) -} - -herr_t -H5VL_iod_insert_link_count(iod_handle_t oh, iod_trans_id_t tid, uint64_t count, - iod_hint_list_t *hints, iod_checksum_t *cs, iod_event_t *event) -{ - void *key = NULL; - void *value = NULL; - iod_kv_t kv; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI_NOINIT - - key = strdup("link_count"); - if(NULL == (value = malloc (sizeof(uint64_t)))) - HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate buffer"); - - *((uint64_t *)value) = count; - kv.key = (char *)key; - kv.value = value; - kv.value_len = sizeof(uint64_t); - - if (iod_kv_set(oh, tid, hints, &kv, cs, event) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't set KV pair in parent"); - -done: - if(key) { - free(key); - key = NULL; - } - if(value) { - free(value); - value = NULL; - } - FUNC_LEAVE_NOAPI(ret_value) -} - -herr_t -H5VL_iod_insert_object_type(iod_handle_t oh, iod_trans_id_t tid, H5I_type_t obj_type, - iod_hint_list_t *hints, iod_checksum_t *cs, iod_event_t *event) -{ - void *key = NULL; - void *value = NULL; - iod_kv_t kv; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI_NOINIT - - key = strdup("object_type"); - - if(NULL == (value = malloc (sizeof(int32_t)))) - HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate buffer"); - - *((int32_t *)value) = obj_type; - kv.key = (char *)key; - kv.value = value; - kv.value_len = sizeof(int32_t); - - if (iod_kv_set(oh, tid, hints, &kv, cs, event) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't set KV pair in parent"); - -done: - if(key) { - free(key); - key = NULL; - } - if(value) { - free(value); - value = NULL; - } - FUNC_LEAVE_NOAPI(ret_value) -} - -herr_t -H5VL_iod_insert_new_link(iod_handle_t oh, iod_trans_id_t tid, char *link_name, - iod_obj_id_t obj_id, iod_hint_list_t *hints, - iod_checksum_t *cs, iod_event_t *event) -{ - void *value = NULL; - iod_kv_t kv; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI_NOINIT - - if(NULL == (value = malloc (sizeof(iod_obj_id_t)))) - HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate buffer"); - - *((int32_t *)value) = obj_id; - kv.key = link_name; - kv.value = value; - kv.value_len = sizeof(iod_obj_id_t); - - if (iod_kv_set(oh, tid, hints, &kv, cs, event) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't set KV pair in parent"); - -done: - if(value) { - free(value); - value = NULL; - } - FUNC_LEAVE_NOAPI(ret_value) -} - -herr_t -H5VL_iod_insert_datatype(iod_handle_t oh, iod_trans_id_t tid, hid_t type_id, - iod_hint_list_t *hints, iod_checksum_t *cs, iod_event_t *event) -{ - void *key = NULL; - void *value = NULL; - iod_kv_t kv; - size_t buf_size; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI_NOINIT - - /* insert group creation properties in Metadata KV */ - key = strdup("datatype"); - - /* determine the buffer size needed to store the encoded type */ - if(H5Tencode(type_id, NULL, &buf_size) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTENCODE, FAIL, "failed to encode type"); - if(NULL == (value = malloc (buf_size))) - HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate type buffer"); - /* encode type */ - if(H5Tencode(type_id, value, &buf_size) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTENCODE, FAIL, "failed to encode type"); - - kv.key = (char *)key; - kv.value = value; - kv.value_len = (iod_size_t)buf_size; - /* insert kv pair into scratch pad */ - if (iod_kv_set(oh, tid, hints, &kv, cs, event) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't set KV pair in parent"); - -done: - if(key) { - free(key); - key = NULL; - } - if(value) { - free(value); - value = NULL; - } - - FUNC_LEAVE_NOAPI(ret_value) -} - -herr_t -H5VL_iod_insert_dataspace(iod_handle_t oh, iod_trans_id_t tid, hid_t space_id, - iod_hint_list_t *hints, iod_checksum_t *cs, iod_event_t *event) -{ - void *key = NULL; - void *value = NULL; - iod_kv_t kv; - size_t buf_size; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI_NOINIT - - /* insert group creation properties in Metadata KV */ - key = strdup("dataspace"); - - /* determine the buffer size needed to store the encoded space */ - if(H5Sencode(space_id, NULL, &buf_size) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTENCODE, FAIL, "failed to encode space"); - if(NULL == (value = malloc (buf_size))) - HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate space buffer"); - /* encode space */ - if(H5Sencode(space_id, value, &buf_size) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTENCODE, FAIL, "failed to encode space"); - - kv.key = (char *)key; - kv.value = value; - kv.value_len = (iod_size_t)buf_size; - /* insert kv pair into scratch pad */ - if (iod_kv_set(oh, tid, hints, &kv, cs, event) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't set KV pair in parent"); - -done: - if(key) { - free(key); - key = NULL; - } - if(value) { - free(value); - value = NULL; - } - - FUNC_LEAVE_NOAPI(ret_value) -} - -herr_t -H5VL_iod_get_metadata(iod_handle_t oh, iod_trans_id_t tid, H5VL_iod_metadata_t md_type, - const char *key, iod_hint_list_t *hints, iod_checksum_t *cs, - iod_event_t *event, void *ret) -{ - iod_size_t val_size = 0; - void *value; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI_NOINIT - - switch(md_type) { - case H5VL_IOD_PLIST: - { - hid_t plist_id = *((hid_t *)ret); - - if(iod_kv_get_value(oh, tid, key, NULL, &val_size, cs, event) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "lookup failed"); - - if(NULL == (value = malloc (val_size))) - HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate value buffer"); - - if(iod_kv_get_value(oh, tid, key, value, &val_size, hints, event) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "lookup failed"); - - if((plist_id = H5Pdecode(value)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTDECODE, FAIL, "failed to decode gcpl"); - break; - } - case H5VL_IOD_LINK_COUNT: - val_size = sizeof(uint64_t); - if(iod_kv_get_value(oh, tid, key, ret, &val_size, cs, event) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "link_count lookup failed"); - break; - case H5VL_IOD_DATATYPE: - { - hid_t type_id = *((hid_t *)ret); - - if(iod_kv_get_value(oh, tid, key, NULL, &val_size, cs, event) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "lookup failed"); - - if(NULL == (value = malloc (val_size))) - HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate value buffer"); - - if(iod_kv_get_value(oh, tid, key, value, &val_size, hints, event) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "lookup failed"); - - if((type_id = H5Tdecode(value)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTDECODE, FAIL, "failed to decode gcpl"); - break; - } - case H5VL_IOD_DATASPACE: - { - hid_t space_id = *((hid_t *)ret); - - if(iod_kv_get_value(oh, tid, key, NULL, &val_size, cs, event) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "lookup failed"); - - if(NULL == (value = malloc (val_size))) - HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate value buffer"); - - if(iod_kv_get_value(oh, tid, key, value, &val_size, hints, event) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "lookup failed"); - - if((space_id = H5Tdecode(value)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTDECODE, FAIL, "failed to decode gcpl"); - break; - } - default: - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "invalide metadata type"); - } -done: - if(value) { - free(value); - value = NULL; - } - - FUNC_LEAVE_NOAPI(ret_value) -} - - - - -#if 0 - -/*------------------------------------------------------------------------- - * Function: H5VL_iod_typeinfo_init - * - * Purpose: Routine for determining correct datatype information for - * each I/O action. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Mohamad Chaarawi - * June, 2013 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL_iod_typeinfo_init(hid_t dset_type_id, const H5D_dxpl_cache_t *dxpl_cache, - hid_t dxpl_id, hid_t mem_type_id, hbool_t do_write, - H5D_type_info_t *type_info) -{ - const H5T_t *src_type; /* Source datatype */ - const H5T_t *dst_type; /* Destination datatype */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - /* check args */ - HDassert(type_info); - - /* Initialize type info safely */ - HDmemset(type_info, 0, sizeof(*type_info)); - - /* Get the memory & dataset datatypes */ - if(NULL == (type_info->mem_type = (const H5T_t *)H5I_object_verify(mem_type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if(NULL == (type_info->dset_type = (const H5T_t *)H5I_object_verify(dset_type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - - if(do_write) { - src_type = type_info->mem_type; - dst_type = type_info->dset_type; - type_info->src_type_id = mem_type_id; - type_info->dst_type_id = dset_type_id; - } /* end if */ - else { - src_type = type_info->dset_type; - dst_type = type_info->mem_type; - type_info->src_type_id = dset_type_id; - type_info->dst_type_id = mem_type_id; - } /* end else */ - - /* - * Locate the type conversion function and data space conversion - * functions, and set up the element numbering information. If a data - * type conversion is necessary then register datatype atoms. Data type - * conversion is necessary if the user has set the `need_bkg' to a high - * enough value in xfer_parms since turning off datatype conversion also - * turns off background preservation. - */ - if(NULL == (type_info->tpath = H5T_path_find(src_type, dst_type, NULL, NULL, dxpl_id, FALSE))) - HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unable to convert between src and dest datatype") - - /* Precompute some useful information */ - type_info->src_type_size = H5T_get_size(src_type); - type_info->dst_type_size = H5T_get_size(dst_type); - type_info->max_type_size = MAX(type_info->src_type_size, type_info->dst_type_size); - type_info->is_conv_noop = H5T_path_noop(type_info->tpath); - type_info->is_xform_noop = H5Z_xform_noop(dxpl_cache->data_xform_prop); - if(type_info->is_xform_noop && type_info->is_conv_noop) { - type_info->cmpd_subset = NULL; - type_info->need_bkg = H5T_BKG_NO; - } /* end if */ - else { - size_t target_size; /* Desired buffer size */ - - /* Check if the datatypes are compound subsets of one another */ - type_info->cmpd_subset = H5T_path_compound_subset(type_info->tpath); - - /* Check if we need a background buffer */ - if(do_write && H5T_detect_class(type_info->dset_type, H5T_VLEN, FALSE)) - type_info->need_bkg = H5T_BKG_YES; - else { - H5T_bkg_t path_bkg; /* Type conversion's background info */ - - if((path_bkg = H5T_path_bkg(type_info->tpath))) { - /* Retrieve the bkgr buffer property */ - type_info->need_bkg = dxpl_cache->bkgr_buf_type; - type_info->need_bkg = MAX(path_bkg, type_info->need_bkg); - } /* end if */ - else - type_info->need_bkg = H5T_BKG_NO; /*never needed even if app says yes*/ - } /* end else */ - - - /* Set up datatype conversion/background buffers */ - - /* Get buffer size from DXPL */ - target_size = dxpl_cache->max_temp_buf; - - /* If the buffer is too small to hold even one element, try to make it bigger */ - if(target_size < type_info->max_type_size) { - hbool_t default_buffer_info; /* Whether the buffer information are the defaults */ - - /* Detect if we have all default settings for buffers */ - default_buffer_info = (hbool_t)((H5D_TEMP_BUF_SIZE == dxpl_cache->max_temp_buf) - && (NULL == dxpl_cache->tconv_buf) && (NULL == dxpl_cache->bkgr_buf)); - - /* Check if we are using the default buffer info */ - if(default_buffer_info) - /* OK to get bigger for library default settings */ - target_size = type_info->max_type_size; - else - /* Don't get bigger than the application has requested */ - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "temporary buffer max size is too small") - } /* end if */ - - /* Compute the number of elements that will fit into buffer */ - type_info->request_nelmts = target_size / type_info->max_type_size; - - /* Sanity check elements in temporary buffer */ - if(type_info->request_nelmts == 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "temporary buffer max size is too small") - - /* - * Get a temporary buffer for type conversion unless the app has already - * supplied one through the xfer properties. Instead of allocating a - * buffer which is the exact size, we allocate the target size. The - * malloc() is usually less resource-intensive if we allocate/free the - * same size over and over. - */ - if(NULL == (type_info->tconv_buf = (uint8_t *)dxpl_cache->tconv_buf)) { - /* Allocate temporary buffer */ - if(NULL == (type_info->tconv_buf = H5FL_BLK_MALLOC(type_conv, target_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion") - type_info->tconv_buf_allocated = TRUE; - } /* end if */ - if(type_info->need_bkg && NULL == (type_info->bkg_buf = (uint8_t *)dxpl_cache->bkgr_buf)) { - size_t bkg_size; /* Desired background buffer size */ - - /* Compute the background buffer size */ - /* (don't try to use buffers smaller than the default size) */ - bkg_size = type_info->request_nelmts * type_info->dst_type_size; - if(bkg_size < dxpl_cache->max_temp_buf) - bkg_size = dxpl_cache->max_temp_buf; - - /* Allocate background buffer */ - /* (Need calloc()-like call since memory needs to be initialized) */ - if(NULL == (type_info->bkg_buf = H5FL_BLK_CALLOC(type_conv, bkg_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for background conversion") - type_info->bkg_buf_allocated = TRUE; - } /* end if */ - } /* end else */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_iod_typeinfo_init() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_iod_typeinfo_term - * - * Purpose: Common logic for terminating a type info object - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * Thursday, March 6, 2008 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL_iod_typeinfo_term(const H5D_type_info_t *type_info) -{ - FUNC_ENTER_NOAPI_NOINIT_NOERR - - /* Check for releasing datatype conversion & background buffers */ - if(type_info->tconv_buf_allocated) { - HDassert(type_info->tconv_buf); - (void)H5FL_BLK_FREE(type_conv, type_info->tconv_buf); - } /* end if */ - if(type_info->bkg_buf_allocated) { - HDassert(type_info->bkg_buf); - (void)H5FL_BLK_FREE(type_conv, type_info->bkg_buf); - } /* end if */ - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5VL_iod_typeinfo_term() */ -#endif - #endif /* H5_HAVE_EFF */ diff --git a/src/H5VLiod_server.h b/src/H5VLiod_server.h index adf1e4b..6041116c 100644 --- a/src/H5VLiod_server.h +++ b/src/H5VLiod_server.h @@ -32,6 +32,19 @@ #define H5_DO_NATIVE 0 #define DEBUG_COMPACTOR 1 +/* Key names for Metadata stored in KV objects */ +#define H5VL_IOD_KEY_SOFT_LINK "soft_link_value" +#define H5VL_IOD_KEY_DTYPE_SIZE "serialized_size" +#define H5VL_IOD_KEY_KV_IDS_INDEX "kv_ids_index" +#define H5VL_IOD_KEY_ARRAY_IDS_INDEX "array_ids_index" +#define H5VL_IOD_KEY_BLOB_IDS_INDEX "blob_ids_index" +#define H5VL_IOD_KEY_OBJ_COMMENT "object_comment" +#define H5VL_IOD_KEY_OBJ_CPL "object_create_plist" +#define H5VL_IOD_KEY_OBJ_LINK_COUNT "object_link_count" +#define H5VL_IOD_KEY_OBJ_TYPE "object_type" +#define H5VL_IOD_KEY_OBJ_DATATYPE "object_datatype" +#define H5VL_IOD_KEY_OBJ_DATASPACE "object_dataspace" + /* Enum for metadata types stored in MD KV for HDF5->IOD objects */ typedef enum H5VL_iod_metadata_t { H5VL_IOD_PLIST, /*type ID for property lists */ @@ -55,10 +68,15 @@ typedef struct scratch_pad_t { iod_obj_id_t filler2_id; /* filler value - not used */ } scratch_pad_t; - int compactor_queue_flag; pthread_mutex_t lock; +/* the link value stored in KV stores */ +typedef struct H5VL_iod_link_t { + iod_obj_id_t iod_id; /* The ID of the object the link points to */ + H5L_type_t link_type; /* The type of the link (Hard & Soft only suppoted for now) */ +} H5VL_iod_link_t; + H5_DLL int H5VL_iod_server_eff_init(hg_handle_t handle); H5_DLL int H5VL_iod_server_eff_finalize(hg_handle_t handle); H5_DLL int H5VL_iod_server_file_create(hg_handle_t handle); @@ -115,12 +133,8 @@ H5_DLL void H5VL_iod_server_dset_compactor_cb(AXE_engine_t axe_engine, size_t num_s_parents, AXE_task_t s_parents[], void *queue); -H5_DLL int H5VL_iod_server_compactor_write (void *list, int num_requests, - iod_array_io_t *array_write); - -H5_DLL int H5VL_iod_server_compactor_read (void *_list, int num_requests, - iod_array_io_t *larray); - +H5_DLL int H5VL_iod_server_compactor_write (void *_list, int num_requests); +H5_DLL int H5VL_iod_server_compactor_read (void *_list, int num_requests); H5_DLL int H5VL_iod_server_send_result (void *list, int num_requests); @@ -299,6 +313,10 @@ H5_DLL void H5VL_iod_server_object_get_comment_cb(AXE_engine_t UNUSED axe_engine H5_DLL herr_t H5VL_iod_server_traverse(iod_handle_t coh, iod_obj_id_t loc_id, iod_handle_t loc_handle, const char *path, hbool_t create_interm_grps, char **last_comp, iod_obj_id_t *iod_id, iod_handle_t *iod_oh); +H5_DLL herr_t H5VL_iod_server_open_path(iod_handle_t coh, iod_obj_id_t loc_id, + iod_handle_t loc_handle, const char *path, + /*out*/iod_obj_id_t *iod_id, + /*out*/iod_handle_t *iod_oh); H5_DLL herr_t H5VL_iod_get_file_desc(hid_t space_id, hssize_t *count, iod_hyperslab_t *hslabs); H5_DLL herr_t H5VL_iod_insert_plist(iod_handle_t oh, iod_trans_id_t tid, hid_t plist_id, iod_hint_list_t *hints, iod_checksum_t *cs, iod_event_t *event); @@ -310,11 +328,10 @@ H5_DLL herr_t H5VL_iod_insert_datatype(iod_handle_t oh, iod_trans_id_t tid, hid_ iod_hint_list_t *hints, iod_checksum_t *cs, iod_event_t *event); H5_DLL herr_t H5VL_iod_insert_dataspace(iod_handle_t oh, iod_trans_id_t tid, hid_t space_id, iod_hint_list_t *hints, iod_checksum_t *cs, iod_event_t *event); -H5_DLL herr_t H5VL_iod_insert_new_link(iod_handle_t oh, iod_trans_id_t tid, char *link_name, - iod_obj_id_t obj_id, iod_hint_list_t *hints, - iod_checksum_t *cs, iod_event_t *event); +H5_DLL herr_t H5VL_iod_insert_new_link(iod_handle_t oh, iod_trans_id_t tid, const char *link_name, + H5L_type_t link_type, iod_obj_id_t obj_id, + iod_hint_list_t *hints, iod_checksum_t *cs, iod_event_t *event); H5_DLL herr_t H5VL_iod_get_metadata(iod_handle_t oh, iod_trans_id_t tid, H5VL_iod_metadata_t md_type, - const char *key, iod_hint_list_t *hints, iod_checksum_t *cs, - iod_event_t *event, void *ret); + const char *key, iod_checksum_t *cs, iod_event_t *event, void *ret); #endif /* H5_HAVE_EFF */ #endif /* _H5VLiod_server_H */ diff --git a/src/H5VLiod_util.c b/src/H5VLiod_util.c new file mode 100644 index 0000000..64580cb --- /dev/null +++ b/src/H5VLiod_util.c @@ -0,0 +1,1064 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#define H5G_PACKAGE /*suppress error about including H5Gpkg */ + +#include "H5Gpkg.h" /* Groups */ +#include "H5Sprivate.h" /* Dataspaces */ +#include "H5WBprivate.h" /* Wrapped Buffers */ +#include "H5VLiod_server.h" + +#ifdef H5_HAVE_EFF + +/* + * Programmer: Mohamad Chaarawi <chaarawi@hdfgroup.gov> + * February, 2013 + * + * Purpose: The IOD plugin server utility routines. + */ + +#if 0 +static herr_t H5VL_iod_typeinfo_init(hid_t dset_type_id, const H5D_dxpl_cache_t *dxpl_cache, + hid_t dxpl_id, hid_t mem_type_id, hbool_t do_write, + H5D_type_info_t *type_info); +static herr_t H5VL_iod_typeinfo_term(const H5D_type_info_t *type_info); +#endif + + +/*------------------------------------------------------------------------- + * Function: H5VL_iod_server_traverse + * + * Purpose: + * Function to Traverse the path in IOD KV objects given the + * starting location ID, object handle, and path name. This walks + * through the IOD KV objects to get to the last component in the + * path. The last component is not opened. Usually this is called when + * creating an object. The Function returns the iod ID and object + * handle of the before to last component, and the last component + * string, if the user requests it. + * + * Return: Success: SUCCEED + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_iod_server_traverse(iod_handle_t coh, iod_obj_id_t loc_id, iod_handle_t loc_handle, + const char *path, hbool_t create_interm_grps, + /* out */char **last_comp, /* out */iod_obj_id_t *iod_id, + /* out */iod_handle_t *iod_oh) +{ + char comp_buf[1024]; /* Temporary buffer for path components */ + char *comp; /* Pointer to buffer for path components */ + H5WB_t *wb = NULL; /* Wrapped buffer for temporary buffer */ + size_t nchars; /* component name length */ + iod_handle_t cur_oh, prev_oh; + iod_obj_id_t cur_id; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI_NOINIT + + assert(FALSE == create_interm_grps); + + cur_oh = loc_handle; + cur_id = loc_id; + + if(cur_oh.cookie == IOD_OH_UNDEFINED) { + /* open the current group */ + if (iod_obj_open_write(coh, loc_id, NULL /*hints*/, &cur_oh, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't open current group"); + } + + /* Wrap the local buffer for serialized header info */ + if(NULL == (wb = H5WB_wrap(comp_buf, sizeof(comp_buf)))) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't wrap buffer") + /* Get a pointer to a buffer that's large enough */ + if(NULL == (comp = (char *)H5WB_actual(wb, (HDstrlen(path) + 1)))) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't get actual buffer") + + /* Traverse the path */ + while((path = H5G__component(path, &nchars)) && *path) { + const char *s; /* Temporary string pointer */ + iod_size_t kv_size; + H5VL_iod_link_t value; + + /* Copy the component path into a null-terminated buffer. */ + HDmemcpy(comp, path, nchars); + comp[nchars] = '\0'; + + /* + * The special path `.' is a no-op. + */ + if('.' == comp[0] && !comp[1]) { + path += nchars; + continue; + } /* end if */ + + /* Check if this is the last component of the path */ + if(!((s = H5G__component(path + nchars, NULL)) && *s)) { + if(last_comp) { + *last_comp = HDstrdup(comp); + } + break; + } + + kv_size = sizeof(H5VL_iod_link_t); + + prev_oh = cur_oh; + + /* lookup next object in the current group */ + if(iod_kv_get_value(cur_oh, IOD_TID_UNKNOWN, comp, &value, &kv_size, NULL, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "Intermdiate group does not exist"); + + /* MSC - NEED IOD */ +#if 0 + /* if this a soft link, traverse the link value if the ID is undefined */ + if(IOD_ID_UNDEFINED == value.iod_id && + H5VL_LINK_CREATE_SOFT == value.link_type) { + scratch_pad_t sp; + iod_handle_t mdkv_oh; + char *link_value = NULL; + iod_size_t val_size = 0; + + /* get scratch pad of the object */ + if(iod_obj_get_scratch(cur_oh, IOD_TID_UNKNOWN, &sp, NULL, NULL) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "can't get scratch pad for object"); + + /* open the metadata scratch pad */ + if (iod_obj_open_write(coh, sp.mdkv_id, NULL /*hints*/, &mdkv_oh, NULL) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "can't open scratch pad"); + + /* retrieve the link value size */ + if(iod_kv_get_value(mdkv_oh, IOD_TID_UNKNOWN, H5VL_IOD_KEY_SOFT_LINK, NULL, + &val_size, NULL, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "datatype size lookup failed"); + + if(NULL == (link_value = (char *)malloc((size_t)val_size))) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate buffer"); + + /* retrieve the link value */ + if(iod_kv_get_value(mdkv_oh, IOD_TID_UNKNOWN, H5VL_IOD_KEY_SOFT_LINK, link_value, + &val_size, NULL, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "datatype size lookup failed"); + + /* Traverse Path and open the target object */ + if(H5VL_iod_server_open_path(coh, cur_id, cur_oh, link_value, + &cur_id, &cur_oh) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't open object"); + + /* close the metadata scratch pad */ + if(iod_obj_close(mdkv_oh, NULL, NULL)) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't close object"); + + free(link_value); + } + else +#endif + cur_id = value.iod_id; + + /* Close previous handle unless it is the original one */ + if(loc_handle.cookie != prev_oh.cookie && + iod_obj_close(prev_oh, NULL, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't close current object handle"); + + /* open the current group */ + if (iod_obj_open_write(coh, cur_id, NULL, &cur_oh, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't open current group"); + + /* Advance to next component in string */ + path += nchars; + } /* end while */ + + /* Release temporary component buffer */ + if(wb && H5WB_unwrap(wb) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't release wrapped buffer"); + + *iod_id = cur_id; + *iod_oh = cur_oh; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} + + +/*------------------------------------------------------------------------- + * Function: H5VL_iod_server_open_path + * + * Purpose: + * Function to Traverse the path in IOD KV objects given the + * starting location ID, object handle, and path name. This walks + * through the IOD KV objects to get to the last component in the + * path and opens the last component. Usually this is called when + * opening an object. The Function returns the iod ID and object + * handle of the last component, and the last component + * string, if the user requests it. + * + * Return: Success: SUCCEED + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_iod_server_open_path(iod_handle_t coh, iod_obj_id_t loc_id, iod_handle_t loc_handle, + const char *path, /*out*/iod_obj_id_t *iod_id, /*out*/iod_handle_t *iod_oh) +{ + char comp_buf[1024]; /* Temporary buffer for path components */ + char *comp; /* Pointer to buffer for path components */ + H5WB_t *wb = NULL; /* Wrapped buffer for temporary buffer */ + size_t nchars; /* component name length */ + iod_handle_t cur_oh, prev_oh; + iod_obj_id_t cur_id; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI_NOINIT + + cur_oh = loc_handle; + cur_id = loc_id; + + if(cur_oh.cookie == IOD_OH_UNDEFINED) { + /* open the current group */ + if (iod_obj_open_write(coh, loc_id, NULL /*hints*/, &cur_oh, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't open current group"); + } + + /* Wrap the local buffer for serialized header info */ + if(NULL == (wb = H5WB_wrap(comp_buf, sizeof(comp_buf)))) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't wrap buffer") + /* Get a pointer to a buffer that's large enough */ + if(NULL == (comp = (char *)H5WB_actual(wb, (HDstrlen(path) + 1)))) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't get actual buffer") + + /* Traverse the path */ + while((path = H5G__component(path, &nchars)) && *path) { + iod_size_t kv_size; + H5VL_iod_link_t value; + + /* Copy the component path into a null-terminated buffer. */ + HDmemcpy(comp, path, nchars); + comp[nchars] = '\0'; + + /* + * The special path `.' is a no-op. + */ + if('.' == comp[0] && !comp[1]) { + path += nchars; + continue; + } /* end if */ + + kv_size = sizeof(H5VL_iod_link_t); + + prev_oh = cur_oh; + + /* lookup next object in the current group */ + if(iod_kv_get_value(cur_oh, IOD_TID_UNKNOWN, comp, &value, &kv_size, NULL, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "Intermdiate group does not exist"); + + /* MSC - NEED IOD */ +#if 0 + /* if this a soft link, traverse the link value if the ID is undefined */ + if(IOD_ID_UNDEFINED == value.iod_id && + H5VL_LINK_CREATE_SOFT == value.link_type) { + scratch_pad_t sp; + iod_handle_t mdkv_oh; + char *link_value = NULL; + iod_size_t val_size = 0; + + /* get scratch pad of the object */ + if(iod_obj_get_scratch(cur_oh, IOD_TID_UNKNOWN, &sp, NULL, NULL) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "can't get scratch pad for object"); + + /* open the metadata scratch pad */ + if (iod_obj_open_write(coh, sp.mdkv_id, NULL /*hints*/, &mdkv_oh, NULL) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "can't open scratch pad"); + + /* retrieve the link value size */ + if(iod_kv_get_value(mdkv_oh, IOD_TID_UNKNOWN, H5VL_IOD_KEY_SOFT_LINK, NULL, + &val_size, NULL, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "datatype size lookup failed"); + + if(NULL == (link_value = (char *)malloc((size_t)val_size))) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate buffer"); + + /* retrieve the link value */ + if(iod_kv_get_value(mdkv_oh, IOD_TID_UNKNOWN, H5VL_IOD_KEY_SOFT_LINK, link_value, + &val_size, NULL, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "datatype size lookup failed"); + + /* Traverse Path and open the target object */ + if(H5VL_iod_server_open_path(coh, cur_id, cur_oh, link_value, + &cur_id, &cur_oh) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't open object"); + + /* close the metadata scratch pad */ + if(iod_obj_close(mdkv_oh, NULL, NULL)) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't close object"); + + free(link_value); + } + else +#endif + cur_id = value.iod_id; + + /* Close previous handle unless it is the original one */ + if(loc_handle.cookie != prev_oh.cookie && + iod_obj_close(prev_oh, NULL, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't close current object handle"); + + /* open the current group */ + if (iod_obj_open_write(coh, cur_id, NULL, &cur_oh, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't open current group"); + + /* Advance to next component in string */ + path += nchars; + } /* end while */ + + /* Release temporary component buffer */ + if(wb && H5WB_unwrap(wb) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't release wrapped buffer"); + + *iod_id = cur_id; + *iod_oh = cur_oh; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} + + +/*------------------------------------------------------------------------- + * Function: H5VL_iod_get_file_desc + * + * Purpose: + * Function to generate IOD hyperslab objects from HDF5 + * dataspace selections. If hslabs is NULL, a count of the number of + * hslabs needed is returned in count. + * + * Return: Success: SUCCEED + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_iod_get_file_desc(hid_t space_id, hssize_t *count, iod_hyperslab_t *hslabs) +{ + hssize_t num_descriptors = 0, n; + int ndims = 0, i; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI_NOINIT + + /* get the rank of this dataspace */ + if((ndims = H5Sget_simple_extent_ndims(space_id)) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get dataspace dimesnsion"); + + switch(H5Sget_select_type(space_id)) { + case H5S_SEL_NONE: + /* nothing selected */ + num_descriptors = 0; + HGOTO_DONE(SUCCEED); + case H5S_SEL_ALL: + /* The entire dataspace is selected, 1 large iod hyperslab is needed */ + num_descriptors = 1; + + if(NULL != hslabs) { + hsize_t dims[H5S_MAX_RANK]; + + /* get the dimensions sizes of the dataspace */ + if(H5Sget_simple_extent_dims(space_id, dims, NULL) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get dataspace dimesnsion sizes"); + /* populate the hyperslab */ + for(i=0 ; i<ndims ; i++) { + hslabs[0].start[i] = 0; + hslabs[0].stride[i] = 1; + hslabs[0].block[i] = dims[i]; + hslabs[0].count[i] = 1; + } + } + break; + case H5S_SEL_POINTS: + { + /* we need a hyperslab element for each point */ + if((num_descriptors = H5Sget_select_elem_npoints(space_id)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "invalid point selection"); + + if(NULL != hslabs) { + hsize_t *points = NULL; + size_t point_count = 0; + + point_count = ndims * num_descriptors * sizeof(hsize_t); + + if(NULL == (points = (hsize_t *)malloc(point_count))) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate array for points coords"); + + if(H5Sget_select_elem_pointlist(space_id, (hsize_t)0, + (hsize_t)num_descriptors, points) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "Failed to retrieve point coordinates"); + + /* populate the hyperslab */ + for(n=0 ; n<num_descriptors ; n++) { + hsize_t *cur_ptr = points; /* temp pointer into points array */ + + /* adjust the current pointer to the current point */ + cur_ptr += n*ndims; + for(i=0 ; i<ndims ; i++) { + hslabs[n].start[i] = *(cur_ptr+i); + hslabs[n].stride[i] = 1; + hslabs[n].count[i] = 1; + hslabs[n].block[i] = *(cur_ptr+ndims+i) + 1 - hslabs[n].start[i]; + } + } + + free(points); + } + break; + } + case H5S_SEL_HYPERSLABS: + { + /* if the selection is a regular hyperslab + selection, only 1 iod hyperslab object is + needed */ + if(H5Sselect_is_regular(space_id)) { + num_descriptors = 1; + + if(NULL != hslabs) { + if(H5Sget_reg_hyperslab_params(space_id, + hslabs[0].start, + hslabs[0].stride, + hslabs[0].count, + hslabs[0].block) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "Failed to retrieve hyperslab selection"); + } + } + /* Otherwise populate the hslabs by getting every block */ + else { + if((num_descriptors = H5Sget_select_hyper_nblocks(space_id)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "invalid hyperslab selection"); + + if(NULL != hslabs) { + hsize_t *blocks = NULL; + size_t block_count = 0; + + block_count = ndims * num_descriptors * sizeof(hsize_t) * 2; + + if(NULL == (blocks = (hsize_t *)malloc(block_count))) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate array for points coords"); + + fprintf(stderr, "block count = %zu\n", block_count); + + if(H5Sget_select_hyper_blocklist(space_id, (hsize_t)0, + (hsize_t)num_descriptors, blocks) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "Failed to retrieve point coordinates"); + + /* populate the hyperslab */ + for(n=0 ; n<num_descriptors ; n++) { + hsize_t *cur_ptr = blocks; /* temp pointer into blocks array */ + + /* adjust the current pointer to the current block */ + cur_ptr += n*ndims*2; + for(i=0 ; i<ndims ; i++) { + hslabs[n].start[i] = *(cur_ptr+i); + hslabs[n].stride[i] = 1; + hslabs[n].count[i] = 1; + hslabs[n].block[i] = *(cur_ptr+ndims+i) + 1 - hslabs[n].start[i]; + } + } + + free(blocks); + } + } + break; + } + case H5S_SEL_ERROR: + case H5S_SEL_N: + default: + HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "Invalid Selection type"); + } + + *count = num_descriptors; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} + + +/*------------------------------------------------------------------------- + * Function: H5VL_iod_insert_plist + * + * Purpose: Function to insert a creation property list in an + * IOD KV object. + * + * Return: Success: SUCCEED + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_iod_insert_plist(iod_handle_t oh, iod_trans_id_t tid, hid_t plist_id, + iod_hint_list_t *hints, iod_checksum_t *cs, iod_event_t *event) +{ + void *key = NULL; + void *value = NULL; + iod_kv_t kv; + size_t buf_size; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI_NOINIT + + /* insert group creation properties in Metadata KV */ + key = strdup(H5VL_IOD_KEY_OBJ_CPL); + + /* determine the buffer size needed to store the encoded plist */ + if(H5Pencode(plist_id, NULL, &buf_size) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTENCODE, FAIL, "failed to encode plist"); + if(NULL == (value = malloc (buf_size))) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate plist buffer"); + /* encode plist */ + if(H5Pencode(plist_id, value, &buf_size) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTENCODE, FAIL, "failed to encode plist"); + + kv.key = (char *)key; + kv.value = value; + kv.value_len = (iod_size_t)buf_size; + /* insert kv pair into scratch pad */ + if (iod_kv_set(oh, tid, hints, &kv, cs, event) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't set KV pair in parent"); + +done: + if(key) { + free(key); + key = NULL; + } + if(value) { + free(value); + value = NULL; + } + + FUNC_LEAVE_NOAPI(ret_value) +} + + +/*------------------------------------------------------------------------- + * Function: H5VL_iod_insert_link_count + * + * Purpose: Function to insert the link count in an + * IOD KV object. + * + * Return: Success: SUCCEED + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_iod_insert_link_count(iod_handle_t oh, iod_trans_id_t tid, uint64_t count, + iod_hint_list_t *hints, iod_checksum_t *cs, iod_event_t *event) +{ + void *key = NULL; + iod_kv_t kv; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI_NOINIT + + key = strdup(H5VL_IOD_KEY_OBJ_LINK_COUNT); + + kv.key = (char *)key; + kv.value = &count; + kv.value_len = sizeof(uint64_t); + + if (iod_kv_set(oh, tid, hints, &kv, cs, event) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't set KV pair in parent"); + +done: + if(key) { + free(key); + key = NULL; + } + FUNC_LEAVE_NOAPI(ret_value) +} + + +/*------------------------------------------------------------------------- + * Function: H5VL_iod_insert_object_type + * + * Purpose: Function to insert the object type in an + * IOD KV object. + * + * Return: Success: SUCCEED + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_iod_insert_object_type(iod_handle_t oh, iod_trans_id_t tid, H5I_type_t obj_type, + iod_hint_list_t *hints, iod_checksum_t *cs, iod_event_t *event) +{ + void *key = NULL; + iod_kv_t kv; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI_NOINIT + + key = strdup(H5VL_IOD_KEY_OBJ_TYPE); + + kv.key = (char *)key; + kv.value = &obj_type; + kv.value_len = sizeof(int32_t); + + if (iod_kv_set(oh, tid, hints, &kv, cs, event) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't set KV pair in parent"); + +done: + if(key) { + free(key); + key = NULL; + } + FUNC_LEAVE_NOAPI(ret_value) +} + + +/*------------------------------------------------------------------------- + * Function: H5VL_iod_insert_datatype + * + * Purpose: Function to insert a datatype in an + * IOD KV object. + * + * Return: Success: SUCCEED + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_iod_insert_datatype(iod_handle_t oh, iod_trans_id_t tid, hid_t type_id, + iod_hint_list_t *hints, iod_checksum_t *cs, iod_event_t *event) +{ + void *key = NULL; + void *value = NULL; + iod_kv_t kv; + size_t buf_size; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI_NOINIT + + /* insert group creation properties in Metadata KV */ + key = strdup(H5VL_IOD_KEY_OBJ_DATATYPE); + + /* determine the buffer size needed to store the encoded type */ + if(H5Tencode(type_id, NULL, &buf_size) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTENCODE, FAIL, "failed to encode type"); + if(NULL == (value = malloc (buf_size))) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate type buffer"); + /* encode type */ + if(H5Tencode(type_id, value, &buf_size) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTENCODE, FAIL, "failed to encode type"); + + kv.key = (char *)key; + kv.value = value; + kv.value_len = (iod_size_t)buf_size; + /* insert kv pair into scratch pad */ + if (iod_kv_set(oh, tid, hints, &kv, cs, event) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't set KV pair in parent"); + +done: + if(key) { + free(key); + key = NULL; + } + if(value) { + free(value); + value = NULL; + } + + FUNC_LEAVE_NOAPI(ret_value) +} + + +/*------------------------------------------------------------------------- + * Function: H5VL_iod_insert_dataspace + * + * Purpose: Function to insert a dataspace in an + * IOD KV object. + * + * Return: Success: SUCCEED + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_iod_insert_dataspace(iod_handle_t oh, iod_trans_id_t tid, hid_t space_id, + iod_hint_list_t *hints, iod_checksum_t *cs, iod_event_t *event) +{ + void *key = NULL; + void *value = NULL; + iod_kv_t kv; + size_t buf_size; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI_NOINIT + + /* insert group creation properties in Metadata KV */ + key = strdup(H5VL_IOD_KEY_OBJ_DATASPACE); + + /* determine the buffer size needed to store the encoded space */ + if(H5Sencode(space_id, NULL, &buf_size) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTENCODE, FAIL, "failed to encode space"); + if(NULL == (value = malloc (buf_size))) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate space buffer"); + /* encode space */ + if(H5Sencode(space_id, value, &buf_size) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTENCODE, FAIL, "failed to encode space"); + + kv.key = (char *)key; + kv.value = value; + kv.value_len = (iod_size_t)buf_size; + /* insert kv pair into scratch pad */ + if (iod_kv_set(oh, tid, hints, &kv, cs, event) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't set KV pair in parent"); + +done: + if(key) { + free(key); + key = NULL; + } + if(value) { + free(value); + value = NULL; + } + + FUNC_LEAVE_NOAPI(ret_value) +} + + +/*------------------------------------------------------------------------- + * Function: H5VL_iod_insert_new_link + * + * Purpose: Function to insert a link to another object in an + * IOD KV object. + * + * Return: Success: SUCCEED + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_iod_insert_new_link(iod_handle_t oh, iod_trans_id_t tid, const char *link_name, + H5L_type_t link_type, iod_obj_id_t obj_id, iod_hint_list_t *hints, + iod_checksum_t *cs, iod_event_t *event) +{ + iod_kv_t kv; + H5VL_iod_link_t value; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI_NOINIT + + value.iod_id = obj_id; + value.link_type = link_type; + + kv.key = link_name; + kv.value = &value; + kv.value_len = sizeof(H5VL_iod_link_t); + + if (iod_kv_set(oh, tid, hints, &kv, cs, event) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't set KV pair in parent"); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} + + +/*------------------------------------------------------------------------- + * Function: H5VL_iod_get_metadata + * + * Purpose: Function to retrieve a particular metadata value from an + * IOD KV object. + * + * Return: Success: SUCCEED + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_iod_get_metadata(iod_handle_t oh, iod_trans_id_t tid, H5VL_iod_metadata_t md_type, + const char *key, iod_checksum_t *cs, iod_event_t *event, void *ret) +{ + iod_size_t val_size = 0; + void *value = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI_NOINIT + + switch(md_type) { + case H5VL_IOD_PLIST: + { + hid_t plist_id = *((hid_t *)ret); + + if(iod_kv_get_value(oh, tid, key, NULL, &val_size, cs, event) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "lookup failed"); + + if(NULL == (value = malloc((size_t)val_size))) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate value buffer"); + + if(iod_kv_get_value(oh, tid, key, value, &val_size, cs, event) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "lookup failed"); + + if((plist_id = H5Pdecode(value)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTDECODE, FAIL, "failed to decode gcpl"); + break; + } + case H5VL_IOD_LINK_COUNT: + val_size = sizeof(uint64_t); + if(iod_kv_get_value(oh, tid, key, ret, &val_size, cs, event) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "link_count lookup failed"); + break; + case H5VL_IOD_DATATYPE: + { + hid_t type_id = *((hid_t *)ret); + + if(iod_kv_get_value(oh, tid, key, NULL, &val_size, cs, event) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "lookup failed"); + + if(NULL == (value = malloc((size_t)val_size))) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate value buffer"); + + if(iod_kv_get_value(oh, tid, key, value, &val_size, cs, event) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "lookup failed"); + + if((type_id = H5Tdecode(value)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTDECODE, FAIL, "failed to decode gcpl"); + break; + } + case H5VL_IOD_DATASPACE: + { + hid_t space_id = *((hid_t *)ret); + + if(iod_kv_get_value(oh, tid, key, NULL, &val_size, cs, event) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "lookup failed"); + + if(NULL == (value = malloc((size_t)val_size))) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate value buffer"); + + if(iod_kv_get_value(oh, tid, key, value, &val_size, cs, event) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "lookup failed"); + + if((space_id = H5Tdecode(value)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTDECODE, FAIL, "failed to decode gcpl"); + break; + } + case H5VL_IOD_OBJECT_TYPE: + val_size = sizeof(int32_t); + if(iod_kv_get_value(oh, tid, key, ret, &val_size, cs, event) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "link_count lookup failed"); + break; + default: + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "invalide metadata type"); + } +done: + if(value) { + free(value); + value = NULL; + } + + FUNC_LEAVE_NOAPI(ret_value) +} + + + +#if 0 + +/*------------------------------------------------------------------------- + * Function: H5VL_iod_typeinfo_init + * + * Purpose: Routine for determining correct datatype information for + * each I/O action. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Mohamad Chaarawi + * June, 2013 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_iod_typeinfo_init(hid_t dset_type_id, const H5D_dxpl_cache_t *dxpl_cache, + hid_t dxpl_id, hid_t mem_type_id, hbool_t do_write, + H5D_type_info_t *type_info) +{ + const H5T_t *src_type; /* Source datatype */ + const H5T_t *dst_type; /* Destination datatype */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + /* check args */ + HDassert(type_info); + + /* Initialize type info safely */ + HDmemset(type_info, 0, sizeof(*type_info)); + + /* Get the memory & dataset datatypes */ + if(NULL == (type_info->mem_type = (const H5T_t *)H5I_object_verify(mem_type_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") + if(NULL == (type_info->dset_type = (const H5T_t *)H5I_object_verify(dset_type_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") + + if(do_write) { + src_type = type_info->mem_type; + dst_type = type_info->dset_type; + type_info->src_type_id = mem_type_id; + type_info->dst_type_id = dset_type_id; + } /* end if */ + else { + src_type = type_info->dset_type; + dst_type = type_info->mem_type; + type_info->src_type_id = dset_type_id; + type_info->dst_type_id = mem_type_id; + } /* end else */ + + /* + * Locate the type conversion function and data space conversion + * functions, and set up the element numbering information. If a data + * type conversion is necessary then register datatype atoms. Data type + * conversion is necessary if the user has set the `need_bkg' to a high + * enough value in xfer_parms since turning off datatype conversion also + * turns off background preservation. + */ + if(NULL == (type_info->tpath = H5T_path_find(src_type, dst_type, NULL, NULL, dxpl_id, FALSE))) + HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unable to convert between src and dest datatype") + + /* Precompute some useful information */ + type_info->src_type_size = H5T_get_size(src_type); + type_info->dst_type_size = H5T_get_size(dst_type); + type_info->max_type_size = MAX(type_info->src_type_size, type_info->dst_type_size); + type_info->is_conv_noop = H5T_path_noop(type_info->tpath); + type_info->is_xform_noop = H5Z_xform_noop(dxpl_cache->data_xform_prop); + if(type_info->is_xform_noop && type_info->is_conv_noop) { + type_info->cmpd_subset = NULL; + type_info->need_bkg = H5T_BKG_NO; + } /* end if */ + else { + size_t target_size; /* Desired buffer size */ + + /* Check if the datatypes are compound subsets of one another */ + type_info->cmpd_subset = H5T_path_compound_subset(type_info->tpath); + + /* Check if we need a background buffer */ + if(do_write && H5T_detect_class(type_info->dset_type, H5T_VLEN, FALSE)) + type_info->need_bkg = H5T_BKG_YES; + else { + H5T_bkg_t path_bkg; /* Type conversion's background info */ + + if((path_bkg = H5T_path_bkg(type_info->tpath))) { + /* Retrieve the bkgr buffer property */ + type_info->need_bkg = dxpl_cache->bkgr_buf_type; + type_info->need_bkg = MAX(path_bkg, type_info->need_bkg); + } /* end if */ + else + type_info->need_bkg = H5T_BKG_NO; /*never needed even if app says yes*/ + } /* end else */ + + + /* Set up datatype conversion/background buffers */ + + /* Get buffer size from DXPL */ + target_size = dxpl_cache->max_temp_buf; + + /* If the buffer is too small to hold even one element, try to make it bigger */ + if(target_size < type_info->max_type_size) { + hbool_t default_buffer_info; /* Whether the buffer information are the defaults */ + + /* Detect if we have all default settings for buffers */ + default_buffer_info = (hbool_t)((H5D_TEMP_BUF_SIZE == dxpl_cache->max_temp_buf) + && (NULL == dxpl_cache->tconv_buf) && (NULL == dxpl_cache->bkgr_buf)); + + /* Check if we are using the default buffer info */ + if(default_buffer_info) + /* OK to get bigger for library default settings */ + target_size = type_info->max_type_size; + else + /* Don't get bigger than the application has requested */ + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "temporary buffer max size is too small") + } /* end if */ + + /* Compute the number of elements that will fit into buffer */ + type_info->request_nelmts = target_size / type_info->max_type_size; + + /* Sanity check elements in temporary buffer */ + if(type_info->request_nelmts == 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "temporary buffer max size is too small") + + /* + * Get a temporary buffer for type conversion unless the app has already + * supplied one through the xfer properties. Instead of allocating a + * buffer which is the exact size, we allocate the target size. The + * malloc() is usually less resource-intensive if we allocate/free the + * same size over and over. + */ + if(NULL == (type_info->tconv_buf = (uint8_t *)dxpl_cache->tconv_buf)) { + /* Allocate temporary buffer */ + if(NULL == (type_info->tconv_buf = H5FL_BLK_MALLOC(type_conv, target_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion") + type_info->tconv_buf_allocated = TRUE; + } /* end if */ + if(type_info->need_bkg && NULL == (type_info->bkg_buf = (uint8_t *)dxpl_cache->bkgr_buf)) { + size_t bkg_size; /* Desired background buffer size */ + + /* Compute the background buffer size */ + /* (don't try to use buffers smaller than the default size) */ + bkg_size = type_info->request_nelmts * type_info->dst_type_size; + if(bkg_size < dxpl_cache->max_temp_buf) + bkg_size = dxpl_cache->max_temp_buf; + + /* Allocate background buffer */ + /* (Need calloc()-like call since memory needs to be initialized) */ + if(NULL == (type_info->bkg_buf = H5FL_BLK_CALLOC(type_conv, bkg_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for background conversion") + type_info->bkg_buf_allocated = TRUE; + } /* end if */ + } /* end else */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_iod_typeinfo_init() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_iod_typeinfo_term + * + * Purpose: Common logic for terminating a type info object + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * Thursday, March 6, 2008 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_iod_typeinfo_term(const H5D_type_info_t *type_info) +{ + FUNC_ENTER_NOAPI_NOINIT_NOERR + + /* Check for releasing datatype conversion & background buffers */ + if(type_info->tconv_buf_allocated) { + HDassert(type_info->tconv_buf); + (void)H5FL_BLK_FREE(type_conv, type_info->tconv_buf); + } /* end if */ + if(type_info->bkg_buf_allocated) { + HDassert(type_info->bkg_buf); + (void)H5FL_BLK_FREE(type_conv, type_info->bkg_buf); + } /* end if */ + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5VL_iod_typeinfo_term() */ +#endif + +#endif /* H5_HAVE_EFF */ diff --git a/src/Makefile.am b/src/Makefile.am index eabfa84..82fe1a6 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -62,6 +62,7 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ H5VL.c H5VLint.c H5VLnative.c \ H5VLiod.c H5VLiod_client.c H5VLiod_server.c \ H5VLiod_encdec.c H5VLiod_compactor.c H5VLiod_compactor_queue.c \ + H5VLiod.c H5VLiod_client.c H5VLiod_server.c H5VLiod_encdec.c H5VLiod_util.c\ H5VLiod_file.c H5VLiod_group.c H5VLiod_dset.c H5VLiod_dtype.c \ H5VLiod_attr.c H5VLiod_link.c H5VLiod_obj.c H5VLiod_map.c \ H5FD.c H5FDcore.c \ diff --git a/src/Makefile.in b/src/Makefile.in index 4242315..670eeb4 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -136,7 +136,7 @@ am_libhdf5_la_OBJECTS = H5.lo H5checksum.lo H5dbg.lo H5system.lo \ H5Ftest.lo H5FA.lo H5FAcache.lo H5FAdbg.lo H5FAdblock.lo \ H5FAdblkpage.lo H5FAhdr.lo H5FAstat.lo H5FAtest.lo H5VL.lo \ H5VLint.lo H5VLnative.lo H5VLiod.lo H5VLiod_client.lo \ - H5VLiod_server.lo H5VLiod_encdec.lo H5VLiod_file.lo \ + H5VLiod_server.lo H5VLiod_encdec.lo H5VLiod_util.lo H5VLiod_file.lo \ H5VLiod_compactor_queue.lo H5VLiod_compactor.lo \ H5VLiod_group.lo H5VLiod_dset.lo H5VLiod_dtype.lo \ H5VLiod_attr.lo H5VLiod_link.lo H5VLiod_obj.lo H5VLiod_map.lo \ @@ -570,7 +570,7 @@ libhdf5_la_SOURCES = H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ H5FA.c H5FAcache.c H5FAdbg.c H5FAdblock.c H5FAdblkpage.c H5FAhdr.c \ H5FAstat.c H5FAtest.c \ H5VL.c H5VLint.c H5VLnative.c \ - H5VLiod.c H5VLiod_client.c H5VLiod_server.c H5VLiod_encdec.c \ + H5VLiod.c H5VLiod_client.c H5VLiod_server.c H5VLiod_encdec.c H5VLiod_util.c\ H5VLiod_file.c H5VLiod_group.c H5VLiod_dset.c H5VLiod_dtype.c \ H5VLiod_attr.c H5VLiod_link.c H5VLiod_obj.c H5VLiod_map.c \ H5FD.c H5FDcore.c \ @@ -1039,6 +1039,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5VLiod_map.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5VLiod_obj.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5VLiod_server.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5VLiod_util.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5VLnative.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5WB.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Z.Plo@am__quote@ |