summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMohamad Chaarawi <chaarawi@hdfgroup.org>2015-11-13 16:34:59 (GMT)
committerMohamad Chaarawi <chaarawi@hdfgroup.org>2015-11-13 16:34:59 (GMT)
commit4dd4d33fe90a2708088ce55688e9b848c9302f69 (patch)
tree7438a8532323605279e61857577e1caabb96fd78
parent48b507795750ac61f2cb1ab0b85b2ca9cfc7a0ea (diff)
downloadhdf5-4dd4d33fe90a2708088ce55688e9b848c9302f69.zip
hdf5-4dd4d33fe90a2708088ce55688e9b848c9302f69.tar.gz
hdf5-4dd4d33fe90a2708088ce55688e9b848c9302f69.tar.bz2
[svn-r28335] implement H5Rdereference
-rw-r--r--examples/h5ff_client_ref.c74
-rw-r--r--src/H5FF_ref.c120
-rw-r--r--src/H5FFpublic.h2
3 files changed, 181 insertions, 15 deletions
diff --git a/examples/h5ff_client_ref.c b/examples/h5ff_client_ref.c
index d9d08ab..806f221 100644
--- a/examples/h5ff_client_ref.c
+++ b/examples/h5ff_client_ref.c
@@ -32,6 +32,7 @@ int main(int argc, char **argv) {
char str_data[128];
const unsigned int nelem=60;
hsize_t dims[1];
+ hsize_t start[1], count[1];
int my_rank, my_size;
int provided;
@@ -202,7 +203,6 @@ int main(int argc, char **argv) {
/* test creating internal references */
{
href_ff_t ref1, ref2, ref3, ref4, ref5, ref6;
- hsize_t start[1], count[1];
hid_t dspace_region;
H5O_type_t obj_type;
@@ -210,11 +210,27 @@ int main(int argc, char **argv) {
assert(ret == 0);
ret = H5Rprint_ref(&ref1);
assert(ret == 0);
+ {
+ hid_t obj_id;
+
+ obj_id = H5Rdereference_ff(file_id, H5P_DEFAULT, &ref1, rid2, H5_EVENT_STACK_NULL);
+ assert(obj_id >= 0);
+ ret = H5Gclose(obj_id);
+ assert(ret == 0);
+ }
ret = H5Rcreate_object_ff(&ref2, map1, ".", H5P_DEFAULT, rid2, H5_EVENT_STACK_NULL);
assert(ret == 0);
ret = H5Rprint_ref(&ref2);
assert(ret == 0);
+ {
+ hid_t obj_id;
+
+ obj_id = H5Rdereference_ff(file_id, H5P_DEFAULT, &ref2, rid2, H5_EVENT_STACK_NULL);
+ assert(obj_id >= 0);
+ H5Mclose_ff(obj_id, H5_EVENT_STACK_NULL);
+ assert(ret == 0);
+ }
start[0] = 10;
count[0] = 30;
@@ -224,6 +240,15 @@ int main(int argc, char **argv) {
assert(ret == 0);
ret = H5Rprint_ref(&ref3);
assert(ret == 0);
+ assert(ret == 0);
+ {
+ hid_t obj_id;
+
+ obj_id = H5Rdereference_ff(file_id, H5P_DEFAULT, &ref3, rid2, H5_EVENT_STACK_NULL);
+ assert(obj_id >= 0);
+ H5Dclose(obj_id);
+ assert(ret == 0);
+ }
ret = H5Rcreate_attr_ff(&ref4, map1, ".", "Temperature", H5P_DEFAULT, rid2, H5_EVENT_STACK_NULL);
assert(ret == 0);
@@ -237,6 +262,15 @@ int main(int argc, char **argv) {
assert(ret == 0);
ret = H5Rprint_ref(&ref6);
assert(ret == 0);
+ assert(ret == 0);
+ {
+ hid_t obj_id;
+
+ obj_id = H5Rdereference_ff(file_id, H5P_DEFAULT, &ref6, rid2, H5_EVENT_STACK_NULL);
+ assert(obj_id >= 0);
+ H5Tclose(obj_id);
+ assert(ret == 0);
+ }
H5E_BEGIN_TRY {
dspace_region = H5Rget_region_ff(&ref1);
@@ -293,7 +327,6 @@ int main(int argc, char **argv) {
{
href_ff_t ref1, ref2, ref3;
hid_t dspace_region;
- hsize_t start[1], count[1];
H5O_type_t obj_type;
char fname[1024], pname[1024];
@@ -364,9 +397,33 @@ int main(int argc, char **argv) {
assert(ret == 0);
}
+#if 0
if(0 == my_rank) {
- /* release container version 2. This is async. */
- ret = H5RCrelease(rid2, e_stack);
+ hid_t did_obj, did_ref;
+
+ /* create transaction object */
+ tid2 = H5TRcreate(file_id, rid2, (uint64_t)3);
+ assert(tid2);
+ ret = H5TRstart(tid2, H5P_DEFAULT, e_stack);
+ assert(0 == ret);
+
+ /* create dataset D_OBJ */
+ did_obj = H5Dcreate_ff(file_id, "D_OBJ", H5T_STD_REF_OBJ, sid, H5P_DEFAULT,
+ H5P_DEFAULT, H5P_DEFAULT, tid2, e_stack);
+ assert(did_obj > 0);
+
+ /* create dataset D_REG */
+ did_ref = H5Dcreate_ff(file_id, "D_REG", H5T_STD_REF_DSETREG, sid, H5P_DEFAULT,
+ H5P_DEFAULT, H5P_DEFAULT, tid2, e_stack);
+ assert(did_ref > 0);
+
+ start[0] = 10;
+ count[0] = 30;
+ ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, NULL, count, NULL);
+ assert(ret == 0);
+
+ /* make this synchronous so we know the container version has been acquired */
+ ret = H5TRfinish(tid2, H5P_DEFAULT, &rid3, H5_EVENT_STACK_NULL);
assert(0 == ret);
ret = H5RCclose(rid1);
@@ -374,6 +431,12 @@ int main(int argc, char **argv) {
ret = H5RCclose(rid2);
assert(0 == ret);
}
+#endif
+ if(0 == my_rank) {
+ /* release container version 2. This is async. */
+ ret = H5RCrelease(rid2, e_stack);
+ assert(0 == ret);
+ }
ret = H5Sclose(sid);
assert(ret == 0);
@@ -382,6 +445,9 @@ int main(int argc, char **argv) {
ret = H5Pclose(fapl_id);
assert(ret == 0);
+
+
+
H5Fclose_ff(file_id, 1, H5_EVENT_STACK_NULL);
ret = H5ESclose(e_stack);
diff --git a/src/H5FF_ref.c b/src/H5FF_ref.c
index 8c464bc..301e71c 100644
--- a/src/H5FF_ref.c
+++ b/src/H5FF_ref.c
@@ -93,7 +93,6 @@ H5Rcreate_object_ff(href_ff_t *ref, hid_t loc_id, const char *name, hid_t lapl_i
/* Need to open the object if a path to it is given */
if(strcmp(name, ".")) {
- printf("Object %s not location object, so We need to open it.\n", name);
loc_params.type = H5VL_OBJECT_BY_NAME;
loc_params.loc_data.loc_by_name.name = name;
loc_params.loc_data.loc_by_name.lapl_id = lapl_id;
@@ -114,7 +113,6 @@ H5Rcreate_object_ff(href_ff_t *ref, hid_t loc_id, const char *name, hid_t lapl_i
obj_opened = TRUE;
}
else {
- printf("path is %s. Location object already open.\n", name);
opened_obj = (H5VL_object_t *)obj->vol_obj;
}
@@ -222,7 +220,6 @@ herr_t H5Rcreate_region_ff(href_ff_t *ref, hid_t loc_id, const char *name, hid_t
/* Need to open the object if a path to it is given */
if(strcmp(name, ".")) {
- printf("Object %s not location object, so We need to open it.\n", name);
loc_params.type = H5VL_OBJECT_BY_NAME;
loc_params.loc_data.loc_by_name.name = name;
loc_params.loc_data.loc_by_name.lapl_id = lapl_id;
@@ -315,7 +312,6 @@ herr_t H5Rcreate_attr_ff(href_ff_t *ref, hid_t loc_id, const char *name, const c
/* Need to open the object if a path to it is given */
if(strcmp(name, ".")) {
- printf("Object %s not location object, so We need to open it.\n", name);
loc_params.type = H5VL_OBJECT_BY_NAME;
loc_params.loc_data.loc_by_name.name = name;
loc_params.loc_data.loc_by_name.lapl_id = lapl_id;
@@ -526,7 +522,6 @@ done:
FUNC_LEAVE_API(ret_value)
} /* H5Rcreate_attr_ext_ff */
-#if 0
/*-------------------------------------------------------------------------
* Function: H5Rdereference_ff
@@ -541,16 +536,123 @@ done:
*
*-------------------------------------------------------------------------
*/
-hid_t H5Rdereference_ff(hid_t loc_id, hid_t oapl_id, const href_ff_t *ref,
- hid_t rcxt_id, hid_t estack_id)
+hid_t H5Rdereference_ff(hid_t loc_id, hid_t H5_ATTR_UNUSED oapl_id, const href_ff_t *ref,
+ hid_t rcxt_id, hid_t estack_id)
{
- hid_t ret_value; /* Return value */
+ const uint8_t *p;
+ char *pathname = NULL;
+ H5VL_object_t *obj = NULL;
+ hid_t ret_value; /* Return value */
+
+ FUNC_ENTER_API(FAIL)
+
+ /* Check args */
+ if(ref == NULL)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer");
+ if(ref->buf == NULL || ref->buf_size == 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference")
+
+ /* get the object */
+ if(NULL == (obj = H5VL_get_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object/file identifier")
+
+ p = (uint8_t *)ref->buf;
+
+ if(ref->ref_type == H5R_OBJECT || ref->ref_type == H5R_DATASET_REGION ||
+ ref->ref_type == H5R_ATTR) {
+ size_t token_size;
+ H5_priv_request_t *request = NULL; /* private request struct inserted in event queue */
+ void **req = NULL; /* pointer to plugin generate requests (Stays NULL if plugin does not support async */
+ H5I_type_t opened_type;
+ void *opened_obj = NULL;
+ H5TR_t tr;
+ H5RC_t *rc;
+
+ /* get the RC object */
+ if(NULL == (rc = (H5RC_t *)H5I_object_verify(rcxt_id, H5I_RC)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a READ CONTEXT ID")
+
+ if(estack_id != H5_EVENT_STACK_NULL) {
+ /* create the private request */
+ if(NULL == (request = (H5_priv_request_t *)H5MM_calloc(sizeof(H5_priv_request_t))))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
+ req = &request->req;
+ request->vol_cls = rc->vol_cls;
+ }
+
+ UINT64DECODE(p, token_size);
+
+ /* create the dummy TR object */
+ tr.file = rc->file;
+ tr.trans_num = rc->c_version;
+ tr.req_info.request = NULL;
+ tr.req_info.head = NULL;
+ tr.req_info.tail = NULL;
+ tr.req_info.num_req = 0;
+
+ if(NULL == (opened_obj = H5VL_iod_obj_open_token((const void *)p, &tr, &opened_type, req)))
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to open object");
+
+ if(request && *req)
+ if(H5ES_insert(estack_id, request) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "failed to insert request in event stack")
+
+ /* create hid_t for opened object */
+ if((ret_value = H5VL_register_id(opened_type, opened_obj, obj->vol_info, TRUE)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize object handle");
+
+ }
+ else if(ref->ref_type == H5R_OBJECT_EXT || ref->ref_type == H5R_DATASET_REGION_EXT ||
+ ref->ref_type == H5R_ATTR_EXT) {
+ size_t name_size;
+ hid_t lapl_id = H5P_LINK_ACCESS_DEFAULT;
+ hid_t dxpl_id = H5P_DATASET_XFER_DEFAULT;
+ H5P_genplist_t *plist;
+ H5I_type_t opened_type;
+ H5VL_object_t *opened_obj = NULL;
+ H5VL_loc_params_t loc_params;
+
+ /* retrieve the pathname of the object to dereference */
+ p = (uint8_t *)ref->buf;
+
+ UINT64DECODE(p, name_size);
+ p += name_size;
+ UINT64DECODE(p, name_size);
+ pathname = (char *)HDmalloc(name_size);
+ HDmemcpy(pathname, p, name_size);
+ pathname[name_size] = '\0';
+
+ loc_params.type = H5VL_OBJECT_BY_NAME;
+ loc_params.loc_data.loc_by_name.name = pathname;
+ loc_params.loc_data.loc_by_name.lapl_id = lapl_id;
+ loc_params.obj_type = H5I_get_type(loc_id);
+
+ /* store the transaction ID in the dxpl */
+ if(NULL == (plist = (H5P_genplist_t *)H5I_object(dxpl_id)))
+ HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
+ if(H5P_set(plist, H5VL_CONTEXT_ID, &rcxt_id) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for rcxt_id")
+
+ /* Open the object through the VOL */
+ if(NULL == (opened_obj = (H5VL_object_t *)H5VL_object_open(obj->vol_obj, loc_params,
+ obj->vol_info->vol_cls, &opened_type,
+ dxpl_id, H5_REQUEST_NULL)))
+ HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open object")
+
+ if((ret_value = H5VL_register_id(opened_type, opened_obj, obj->vol_info, TRUE)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize object handle")
+ }
+ else
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference type");
done:
+ if(pathname) {
+ HDfree(pathname);
+ pathname = NULL;
+ }
FUNC_LEAVE_API(ret_value)
} /* H5Rdereference_ff */
-#endif
/*-------------------------------------------------------------------------
diff --git a/src/H5FFpublic.h b/src/H5FFpublic.h
index d92bc7b..d2a6c3a 100644
--- a/src/H5FFpublic.h
+++ b/src/H5FFpublic.h
@@ -208,10 +208,8 @@ H5_DLL ssize_t H5Rget_filename_ff(const href_ff_t *ref, char *name/*out*/, size_
H5_DLL herr_t H5Rget_obj_type_ff(const href_ff_t *ref, H5O_type_t *obj_type);
H5_DLL hid_t H5Rget_region_ff(const href_ff_t *ref);
H5_DLL ssize_t H5Rget_name_ff(const href_ff_t *ref, char *name/*out*/, size_t size);
-#if 0
H5_DLL hid_t H5Rdereference_ff(hid_t loc_id, hid_t oapl_id, const href_ff_t *ref,
hid_t rcxt_id, hid_t estack_id);
-#endif
H5_DLL herr_t H5Aprefetch_ff(hid_t attr_id, hid_t rcxt_id, hrpl_t *replica_id,
hid_t dxpl_id, hid_t estack_id);