diff options
-rw-r--r-- | examples/h5ff_client_map.c | 163 | ||||
-rw-r--r-- | src/H5ES.c | 55 | ||||
-rw-r--r-- | src/H5FF.c | 255 | ||||
-rw-r--r-- | src/H5FFpublic.h | 4 | ||||
-rw-r--r-- | src/H5M.c | 2 | ||||
-rw-r--r-- | src/H5RC.c | 2 | ||||
-rw-r--r-- | src/H5TR.c | 2 | ||||
-rw-r--r-- | src/H5VLint.c | 2 | ||||
-rw-r--r-- | src/H5VLiod.c | 1233 | ||||
-rw-r--r-- | src/H5VLiod_client.c | 23 | ||||
-rw-r--r-- | src/H5VLiod_client.h | 4 | ||||
-rw-r--r-- | src/H5VLiod_common.h | 3 | ||||
-rw-r--r-- | src/H5VLiod_map.c | 13 | ||||
-rw-r--r-- | src/H5VLiod_obj.c | 57 | ||||
-rw-r--r-- | src/H5VLiod_server.c | 56 | ||||
-rw-r--r-- | src/H5VLiod_server.h | 5 | ||||
-rw-r--r-- | src/H5VLiod_util.c | 3 |
17 files changed, 1179 insertions, 703 deletions
diff --git a/examples/h5ff_client_map.c b/examples/h5ff_client_map.c index 45c8188..f7e2557 100644 --- a/examples/h5ff_client_map.c +++ b/examples/h5ff_client_map.c @@ -30,12 +30,14 @@ int main(int argc, char **argv) { hvl_t rdata[5]; /* Information to write */
int i;
+ void *map_token1, *map_token2, *map_token3;
+ size_t token_size1, token_size2, token_size3;
uint64_t version;
uint64_t trans_num;
int my_rank, my_size;
int provided;
- MPI_Request mpi_req;
+ MPI_Request mpi_req, mpi_reqs[6];
H5ES_status_t status;
size_t num_events = 0;
@@ -81,6 +83,31 @@ int main(int argc, char **argv) { e_stack = H5EScreate();
assert(e_stack);
+
+ /* set write buffer for VL data*/
+ {
+ int increment, j, n;
+
+ n = 0;
+ increment = 4;
+ /* Allocate and initialize VL data to write */
+ for(i = 0; i < 5; i++) {
+ int temp = i*increment + increment;
+
+ wdata[i].p = malloc(temp * sizeof(unsigned int));
+ wdata[i].len = temp;
+ for(j = 0; j < temp; j++)
+ ((unsigned int *)wdata[i].p)[j] = n ++;
+ } /* end for */
+ }
+
+ /* Create an HDF5 VL datatype */
+ dtid1 = H5Tvlen_create (H5T_NATIVE_UINT);
+ /* Create an HDF5 VL string datatype */
+ dtid2 = H5Tcopy(H5T_C_S1);
+ H5Tset_size(dtid2,H5T_VARIABLE);
+
+
/* create the file. */
file_id = H5Fcreate(file_name, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id);
assert(file_id);
@@ -102,76 +129,99 @@ int main(int argc, char **argv) { Leader can tell its delegates that the transaction is
started. */
if(0 == my_rank) {
+ trans_num = 1;
ret = H5TRstart(tid1, H5P_DEFAULT, H5_EVENT_STACK_NULL);
assert(0 == ret);
- }
- /* Tell Delegates that transaction 1 is started */
- trans_num = 1;
- MPI_Ibcast(&trans_num, 1, MPI_UINT64_T, 0, MPI_COMM_WORLD, &mpi_req);
+ /* Leader also create some objects in transaction 1 */
- /* Leader can continue writing to transaction 1,
- while others wait for the ibcast to complete */
- if(0 != my_rank)
- MPI_Wait(&mpi_req, MPI_STATUS_IGNORE);
+ /* create two groups */
+ gid1 = H5Gcreate_ff(file_id, "G1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT, tid1, e_stack);
+ gid2 = H5Gcreate_ff(gid1, "G2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT, tid1, e_stack);
- assert(1 == trans_num);
+ /* Create 3 Map objects with the key type being 32 bit LE integer */
- /*
- Assume the following object create calls are collective.
+ /* First Map object with a Value type a 32 bit LE integer */
+ map1 = H5Mcreate_ff(file_id, "MAP_1", H5T_STD_I32LE, H5T_STD_I32LE,
+ H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT, tid1, e_stack);
- In a real world scenario, the following create calls are
- independent by default; i.e. only 1 process, typically a leader
- process, calls them. The user does the local-to-global,
- global-to-local thing to get the objects accessible to all delegates.
+ /* Second Map object with a Value type being an HDF5 VL datatype */
+ map2 = H5Mcreate_ff(gid1, "MAP_2", H5T_STD_I32LE, dtid1,
+ H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT, tid1, e_stack);
- This will not fail here because IOD used for now is skeletal,
- so it does not matter if the calls are collective or
- independent.
- */
+ /* Third Map object with a Value type being an HDF5 VL string */
+ map3 = H5Mcreate_ff(gid2, "MAP_3", H5T_STD_I32LE, dtid2,
+ H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT, tid1, e_stack);
- /* create two groups */
- gid1 = H5Gcreate_ff(file_id, "G1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT, tid1, e_stack);
- gid2 = H5Gcreate_ff(gid1, "G2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT, tid1, e_stack);
+ assert(H5Gclose_ff(gid1, e_stack) == 0);
+ assert(H5Gclose_ff(gid2, e_stack) == 0);
+ }
- /* Create 3 Map objects with the key type being 32 bit LE integer */
+ /* Tell Delegates that transaction 1 is started */
+ MPI_Ibcast(&trans_num, 1, MPI_UINT64_T, 0, MPI_COMM_WORLD, &mpi_req);
- /* First Map object with a Value type a 32 bit LE integer */
- map1 = H5Mcreate_ff(file_id, "MAP_1", H5T_STD_I32LE, H5T_STD_I32LE,
- H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT, tid1, e_stack);
+ /* Do the local-to-global, global-to-local, so all delegates can
+ write the maps created in transaction 1 */
- /* Second Map object with a Value type being an HDF5 VL datatype */
- {
- int increment, j, n;
+ if(0 == my_rank) {
+ /* get the token size of each map */
+ ret = H5Oget_token(map1, NULL, &token_size1);
+ assert(0 == ret);
+ ret = H5Oget_token(map2, NULL, &token_size2);
+ assert(0 == ret);
+ ret = H5Oget_token(map3, NULL, &token_size3);
+ assert(0 == ret);
- n = 0;
- increment = 4;
- /* Allocate and initialize VL data to write */
- for(i = 0; i < 5; i++) {
- int temp = i*increment + increment;
+ /* allocate buffers for each token */
+ map_token1 = malloc(token_size1);
+ map_token2 = malloc(token_size2);
+ map_token3 = malloc(token_size3);
- wdata[i].p = malloc(temp * sizeof(unsigned int));
- wdata[i].len = temp;
- for(j = 0; j < temp; j++)
- ((unsigned int *)wdata[i].p)[j] = n ++;
- } /* end for */
+ /* get the token buffer */
+ ret = H5Oget_token(map1, map_token1, &token_size1);
+ assert(0 == ret);
+ ret = H5Oget_token(map2, map_token2, &token_size2);
+ assert(0 == ret);
+ ret = H5Oget_token(map3, map_token3, &token_size3);
+ assert(0 == ret);
- /* Create a datatype to refer to */
- dtid1 = H5Tvlen_create (H5T_NATIVE_UINT);
- map2 = H5Mcreate_ff(gid1, "MAP_2", H5T_STD_I32LE, dtid1,
- H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT, tid1, e_stack);
+ /* bcast the token sizes and the tokens */
+ MPI_Ibcast(&token_size1, sizeof(size_t), MPI_BYTE, 0, MPI_COMM_WORLD, &mpi_reqs[0]);
+ MPI_Ibcast(&token_size2, sizeof(size_t), MPI_BYTE, 0, MPI_COMM_WORLD, &mpi_reqs[1]);
+ MPI_Ibcast(&token_size3, sizeof(size_t), MPI_BYTE, 0, MPI_COMM_WORLD, &mpi_reqs[2]);
+ MPI_Ibcast(map_token1, token_size1, MPI_BYTE, 0, MPI_COMM_WORLD, &mpi_reqs[3]);
+ MPI_Ibcast(map_token2, token_size2, MPI_BYTE, 0, MPI_COMM_WORLD, &mpi_reqs[4]);
+ MPI_Ibcast(map_token3, token_size3, MPI_BYTE, 0, MPI_COMM_WORLD, &mpi_reqs[5]);
}
- /* Third Map object with a Value type being an HDF5 VL string */
- {
-
- /* Create a datatype to refer to */
- dtid2 = H5Tcopy(H5T_C_S1);
- H5Tset_size(dtid2,H5T_VARIABLE);
+ /* Leader can continue writing to transaction 1,
+ while others wait for the ibcast to complete */
+ if(0 != my_rank) {
- /* Val type, VL string */
- map3 = H5Mcreate_ff(gid2, "MAP_3", H5T_STD_I32LE, dtid2,
- H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT, tid1, e_stack);
+ /* this wait if for the transaction start */
+ MPI_Wait(&mpi_req, MPI_STATUS_IGNORE);
+ assert(1 == trans_num);
+
+ /* recieve the token sizes */
+ MPI_Ibcast(&token_size1, sizeof(size_t), MPI_BYTE, 0, MPI_COMM_WORLD, &mpi_reqs[0]);
+ MPI_Ibcast(&token_size2, sizeof(size_t), MPI_BYTE, 0, MPI_COMM_WORLD, &mpi_reqs[1]);
+ MPI_Ibcast(&token_size3, sizeof(size_t), MPI_BYTE, 0, MPI_COMM_WORLD, &mpi_reqs[2]);
+ MPI_Waitall(3, mpi_reqs, MPI_STATUS_IGNORE);
+
+ /* allocate buffers for each token */
+ map_token1 = malloc(token_size1);
+ map_token2 = malloc(token_size2);
+ map_token3 = malloc(token_size3);
+
+ /* recieve the tokens */
+ MPI_Ibcast(map_token1, token_size1, MPI_BYTE, 0, MPI_COMM_WORLD, &mpi_reqs[0]);
+ MPI_Ibcast(map_token2, token_size2, MPI_BYTE, 0, MPI_COMM_WORLD, &mpi_reqs[1]);
+ MPI_Ibcast(map_token3, token_size3, MPI_BYTE, 0, MPI_COMM_WORLD, &mpi_reqs[2]);
+ MPI_Waitall(3, mpi_reqs, MPI_STATUS_IGNORE);
+
+ map1 = H5Oopen_by_token(map_token1, rid1, e_stack);
+ map2 = H5Oopen_by_token(map_token2, rid1, e_stack);
+ map3 = H5Oopen_by_token(map_token3, rid1, e_stack);
}
/* write some KV pairs to each map object. */
@@ -216,6 +266,7 @@ int main(int argc, char **argv) { read context on it */
if(0 == my_rank) {
MPI_Wait(&mpi_req, MPI_STATUS_IGNORE);
+ MPI_Waitall(6, mpi_reqs, MPI_STATUS_IGNORE);
ret = H5TRfinish(tid1, H5P_DEFAULT, &rid2, H5_EVENT_STACK_NULL);
assert(0 == ret);
@@ -283,8 +334,6 @@ int main(int argc, char **argv) { assert(0 == ret);
}
- assert(H5Gclose_ff(gid1, e_stack) == 0);
- assert(H5Gclose_ff(gid2, e_stack) == 0);
assert(H5Mclose_ff(map1, e_stack) == 0);
assert(H5Mclose_ff(map2, e_stack) == 0);
assert(H5Mclose_ff(map3, e_stack) == 0);
@@ -416,6 +465,10 @@ int main(int argc, char **argv) { free(rdata[i].p);
}
+ free(map_token1);
+ free(map_token2);
+ free(map_token3);
+
/* This finalizes the EFF stack. ships a terminate and IOD finalize to the server
and shutsdown the FS server (when all clients send the terminate request)
and client */
@@ -13,8 +13,8 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol <koziol@hdfgroup.org> - * March, 2013 + * Programmer: Mohamad Chaarawi <chaarawi@hdfgroup.org> + * September, 2013 * * Purpose: Wrappers around existing HDF5 to support Exascale FastForward * functionality. @@ -34,7 +34,7 @@ /***********/ #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ -#include "H5ESprivate.h" /* Event Queues */ +#include "H5ESprivate.h" /* Event Stacks */ #include "H5Iprivate.h" /* IDs */ #include "H5MMprivate.h" /* Memory management */ #include "H5VLprivate.h" /* VOL plugins */ @@ -93,7 +93,7 @@ static const H5I_class_t H5I_ES_CLS[1] = {{ * Failure: negative * * Programmer: Mohamad Chaarawi - * April 2013 + * September 2013 * *------------------------------------------------------------------------- */ @@ -189,7 +189,7 @@ H5ES_term_interface(void) * Failure: FAIL * * Programmer: Mohamad Chaarawi - * March 2013 + * September 2013 * *------------------------------------------------------------------------- */ @@ -227,7 +227,7 @@ done: * Failure: FAIL * * Programmer: Mohamad Chaarawi - * March 2013 + * September 2013 * *------------------------------------------------------------------------- */ @@ -278,7 +278,7 @@ done: * Failure: FAIL * * Programmer: Mohamad Chaarawi - * March 2013 + * September 2013 * *------------------------------------------------------------------------- */ @@ -312,7 +312,7 @@ done: * Failure: FAIL * * Programmer: Mohamad Chaarawi - * March 2013 + * September 2013 * *------------------------------------------------------------------------- */ @@ -362,7 +362,7 @@ done: * Failure: FAIL * * Programmer: Mohamad Chaarawi - * March 2013 + * September 2013 * *------------------------------------------------------------------------- */ @@ -396,7 +396,7 @@ done: * Failure: FAIL * * Programmer: Mohamad Chaarawi - * March 2013 + * September 2013 * *------------------------------------------------------------------------- */ @@ -478,7 +478,7 @@ done: * Failure: FAIL * * Programmer: Mohamad Chaarawi - * March 2013 + * September 2013 * *------------------------------------------------------------------------- */ @@ -512,7 +512,7 @@ done: * Failure: FAIL * * Programmer: Mohamad Chaarawi - * March 2013 + * September 2013 * *------------------------------------------------------------------------- */ @@ -563,7 +563,7 @@ done: * Failure: FAIL * * Programmer: Mohamad Chaarawi - * March 2013 + * September 2013 * *------------------------------------------------------------------------- */ @@ -597,7 +597,7 @@ done: * Failure: FAIL * * Programmer: Mohamad Chaarawi - * March 2013 + * September 2013 * *------------------------------------------------------------------------- */ @@ -685,7 +685,7 @@ done: * Failure: FAIL * * Programmer: Mohamad Chaarawi - * March 2013 + * September 2013 * *------------------------------------------------------------------------- */ @@ -719,7 +719,7 @@ done: * Failure: FAIL * * Programmer: Mohamad Chaarawi - * March 2013 + * September 2013 * *------------------------------------------------------------------------- */ @@ -768,7 +768,7 @@ done: * Failure: FAIL * * Programmer: Mohamad Chaarawi - * March 2013 + * September 2013 * *------------------------------------------------------------------------- */ @@ -802,7 +802,7 @@ done: * Failure: FAIL * * Programmer: Mohamad Chaarawi - * March 2013 + * September 2013 * *------------------------------------------------------------------------- */ @@ -882,7 +882,7 @@ done: * Return: Non-negative on success/Negative on failure * * Programmer: Mohamad Chaarawi - * April 2013 + * September 2013 * *------------------------------------------------------------------------- */ @@ -913,7 +913,7 @@ done: * Return: Non-negative on success/Negative on failure * * Programmer: Mohamad Chaarawi - * April 2013 + * September 2013 * *------------------------------------------------------------------------- */ @@ -952,8 +952,7 @@ H5ESclear(hid_t es_id) tail->vol_plugin->nrefs --; if (0 == tail->vol_plugin->nrefs) { - tail->vol_plugin->container_name = (const char *)H5MM_xfree - (tail->vol_plugin->container_name); + tail->vol_plugin->container_name = H5MM_xfree(tail->vol_plugin->container_name); tail->vol_plugin = (H5VL_t *)H5MM_xfree(tail->vol_plugin); } tail->vol_plugin = NULL; @@ -981,7 +980,7 @@ done: * Return: Non-negative on success/Negative on failure * * Programmer: Mohamad Chaarawi - * April 2013 + * September 2013 * *------------------------------------------------------------------------- */ @@ -1015,7 +1014,7 @@ done: * Failure: Negative * * Programmer: Mohamad Chaarawi - * March 2013 + * September 2013 * *------------------------------------------------------------------------- */ @@ -1046,7 +1045,7 @@ H5ES_close(H5ES_t *e_stack) * Failure: FAIL * * Programmer: Mohamad Chaarawi - * March 2013 + * September 2013 * *------------------------------------------------------------------------- */ @@ -1110,7 +1109,7 @@ done: * Failure: FAIL * * Programmer: Mohamad Chaarawi - * March 2013 + * September 2013 * *------------------------------------------------------------------------- */ @@ -1159,7 +1158,7 @@ done: * Failure: FAIL * * Programmer: Mohamad Chaarawi - * March 2013 + * September 2013 * *------------------------------------------------------------------------- */ @@ -1209,7 +1208,7 @@ done: * Failure: FAIL * * Programmer: Mohamad Chaarawi - * March 2013 + * September 2013 * *------------------------------------------------------------------------- */ @@ -42,6 +42,7 @@ #include "H5Apkg.h" /* Attribute access */ #include "H5Dpkg.h" /* Dataset access */ #include "H5Eprivate.h" /* Error handling */ +#include "H5ESprivate.h" /* Event Stacks */ #include "H5Fpkg.h" /* File access */ #include "H5FFprivate.h" /* FastForward wrappers */ #include "H5Gpkg.h" /* Group access */ @@ -2668,7 +2669,183 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Oopen_ff() */ -#if 0 +/*------------------------------------------------------------------------- + * Function: H5Oget_token + * + * Purpose: This function retrieves a token representing an object in + * HDF5. This token can be used in H5Oopen_by_token(), to open the + * object in the same transaction it was created in. If the token + * buffer is NULL, the token size is returned in token_size. + * + * Return: Success: Non-negative with the link value in BUF. + * Failure: Negative + * + * Programmer: Mohamad Chaarawi + * August 2013 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Oget_token(hid_t obj_id, /*OUT*/void *token, /*OUT*/size_t *token_size) +{ + H5VL_iod_object_t *obj = NULL; /* object token of loc_id */ + iod_obj_id_t iod_id, mdkv_id, attrkv_id; + H5O_type_t type; + uint8_t *buf_ptr = (uint8_t *)token; + size_t dt_size = 0, space_size = 0; + H5T_t *dt = NULL; + H5S_t *space = NULL; + size_t keytype_size = 0, valtype_size; + H5T_t *kt = NULL, *vt = NULL; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + + /* get the file object */ + if(NULL == (obj = (H5VL_iod_object_t *)H5VL_get_object(obj_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier"); + + *token_size = sizeof(iod_obj_id_t)*3 + sizeof(H5O_type_t); + + switch(obj->obj_type) { + case H5I_GROUP: + iod_id = ((const H5VL_iod_group_t *)obj)->remote_group.iod_id; + mdkv_id = ((const H5VL_iod_group_t *)obj)->remote_group.mdkv_id; + attrkv_id = ((const H5VL_iod_group_t *)obj)->remote_group.attrkv_id; + type = H5O_TYPE_GROUP; + break; + case H5I_DATASET: + { + H5VL_iod_dset_t *dset = (H5VL_iod_dset_t *)obj; + + iod_id = dset->remote_dset.iod_id; + mdkv_id = dset->remote_dset.mdkv_id; + attrkv_id = dset->remote_dset.attrkv_id; + type = H5O_TYPE_DATASET; + + if(NULL == (dt = (H5T_t *)H5I_object_verify(dset->remote_dset.type_id, + H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a datatype") + if(NULL == (space = (H5S_t *)H5I_object_verify(dset->remote_dset.space_id, + H5I_DATASPACE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a dataspace") + + if(H5T_encode(dt, NULL, &dt_size) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "can't encode datatype") + + if(H5S_encode(space, NULL, &space_size) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTENCODE, FAIL, "can't encode dataspace") + + *token_size += dt_size + space_size + sizeof(size_t)*2; + + break; + } + case H5I_DATATYPE: + { + H5VL_iod_dtype_t *dtype = (H5VL_iod_dtype_t *)obj; + + iod_id = dtype->remote_dtype.iod_id; + mdkv_id = dtype->remote_dtype.mdkv_id; + attrkv_id = dtype->remote_dtype.attrkv_id; + type = H5O_TYPE_NAMED_DATATYPE; + + if(NULL == (dt = (H5T_t *)H5I_object_verify(dtype->remote_dtype.type_id, + H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a datatype") + + if(H5T_encode(dt, NULL, &dt_size) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "can't encode datatype") + + *token_size += dt_size + sizeof(size_t); + + break; + } + case H5I_MAP: + { + H5VL_iod_map_t *map = (H5VL_iod_map_t *)obj; + + iod_id = map->remote_map.iod_id; + mdkv_id = map->remote_map.mdkv_id; + attrkv_id = map->remote_map.attrkv_id; + type = H5O_TYPE_MAP; + + if(NULL == (kt = (H5T_t *)H5I_object_verify(map->remote_map.keytype_id, + H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a datatype") + + if(H5T_encode(kt, NULL, &keytype_size) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "can't encode datatype") + + if(NULL == (vt = (H5T_t *)H5I_object_verify(map->remote_map.valtype_id, + H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a datatype") + + if(H5T_encode(vt, NULL, &valtype_size) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "can't encode datatype") + + *token_size += keytype_size + valtype_size + sizeof(size_t)*2; + + break; + } + default: + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "bad object"); + } + + if(token) { + HDmemcpy(buf_ptr, &iod_id, sizeof(iod_obj_id_t)); + buf_ptr += sizeof(iod_obj_id_t); + HDmemcpy(buf_ptr, &mdkv_id, sizeof(iod_obj_id_t)); + buf_ptr += sizeof(iod_obj_id_t); + HDmemcpy(buf_ptr, &attrkv_id, sizeof(iod_obj_id_t)); + buf_ptr += sizeof(iod_obj_id_t); + HDmemcpy(buf_ptr, &type, sizeof(H5O_type_t)); + buf_ptr += sizeof(H5O_type_t); + + switch(obj->obj_type) { + case H5I_GROUP: + break; + case H5I_DATASET: + HDmemcpy(buf_ptr, &dt_size, sizeof(size_t)); + buf_ptr += sizeof(size_t); + if(H5T_encode(dt, buf_ptr, &dt_size) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "can't encode datatype") + buf_ptr += dt_size; + + HDmemcpy(buf_ptr, &space_size, sizeof(size_t)); + buf_ptr += sizeof(size_t); + if(H5S_encode(space, buf_ptr, &space_size) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTENCODE, FAIL, "can't encode dataspace") + buf_ptr += space_size; + break; + case H5I_DATATYPE: + HDmemcpy(buf_ptr, &dt_size, sizeof(size_t)); + buf_ptr += sizeof(size_t); + if(H5T_encode(dt, buf_ptr, &dt_size) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "can't encode datatype") + buf_ptr += dt_size; + break; + case H5I_MAP: + HDmemcpy(buf_ptr, &keytype_size, sizeof(size_t)); + buf_ptr += sizeof(size_t); + if(H5T_encode(kt, buf_ptr, &keytype_size) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "can't encode datatype") + buf_ptr += keytype_size; + + HDmemcpy(buf_ptr, &valtype_size, sizeof(size_t)); + buf_ptr += sizeof(size_t); + if(H5T_encode(vt, buf_ptr, &valtype_size) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "can't encode datatype") + buf_ptr += valtype_size; + break; + default: + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "bad object"); + } + } + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Oget_token() */ + /*------------------------------------------------------------------------- * Function: H5Oopen_by_addr_ff @@ -2687,59 +2864,59 @@ done: * *------------------------------------------------------------------------- */ -hid_t -H5Oopen_by_addr_ff(hid_t loc_id, haddr_ff_t addr, H5O_type_t type, - hid_t rcxt_id, hid_t estack_id) +hid_t +H5Oopen_by_token(const void *token, hid_t rcxt_id, hid_t estack_id) { - void *obj = NULL; /* object token of loc_id */ - H5VL_t *vol_plugin; /* VOL plugin information */ - hid_t dxpl_id = H5P_DATASET_XFER_DEFAULT; /* transfer property list to pass to the VOL plugin */ - H5P_genplist_t *plist ; /* Property list pointer */ - H5I_type_t opened_type; - void *opened_obj = NULL; - H5VL_loc_params_t loc_params; - hid_t ret_value = FAIL; + H5RC_t *rc = NULL; + H5VL_t *vol_plugin = NULL; /* VOL plugin pointer this event queue should use */ + 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; + const uint8_t *buf_ptr = (const uint8_t *)token; + hid_t ret_value = FAIL; FUNC_ENTER_API(FAIL) - H5TRACE2("i", "ia", loc_id, addr); - loc_params.type = H5VL_OBJECT_BY_ADDR; - loc_params.loc_data.loc_by_addr.addr = addr; - loc_params.loc_data.loc_by_addr.obj_type = type; - loc_params.obj_type = H5I_get_type(loc_id); + if(NULL == token) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no token") - /* get the file object */ - if(NULL == (obj = (void *)H5I_object(loc_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") - /* get the plugin pointer */ - if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information") + /* 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") - /* 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") + /* get the plugin pointer */ + if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(rcxt_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information"); - if(H5O_TYPE_NAMED_DATATYPE == type) { - /* Open the object through the VOL */ - if(NULL == (opened_obj = H5VL_object_open(obj, loc_params, vol_plugin, &opened_type, - dxpl_id, H5_EVENT_STACK_NULL))) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to open object") + 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"); + request->req = NULL; + req = &request->req; + request->next = NULL; + request->vol_plugin = vol_plugin; + vol_plugin->nrefs ++; } - else { - /* Open the object through the VOL */ - if(NULL == (opened_obj = H5VL_object_open(obj, loc_params, vol_plugin, &opened_type, - dxpl_id, estack_id))) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to open object") + + if(NULL == (opened_obj = H5VL_iod_obj_open_token(token, rc, &opened_type, req))) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to open object"); + + if(request && *req) { + /* insert in stack */ + if(H5ES_insert(estack_id, request) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "failed to insert request in event stack"); } + + vol_plugin->nrefs ++; + /* create hid_t for opened object */ if ((ret_value = H5VL_object_register(opened_obj, opened_type, vol_plugin, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize object handle") done: FUNC_LEAVE_API(ret_value) } /* end H5Oopen_by_addr_ff() */ -#endif /*------------------------------------------------------------------------- diff --git a/src/H5FFpublic.h b/src/H5FFpublic.h index 1441588..43dd4c5 100644 --- a/src/H5FFpublic.h +++ b/src/H5FFpublic.h @@ -154,8 +154,8 @@ H5_DLL herr_t H5Lget_val_ff(hid_t link_loc_id, const char *link_name, void *link H5_DLL hid_t H5Oopen_ff(hid_t loc_id, const char *name, hid_t lapl_id, hid_t rcxt_id); -//H5_DLL hid_t H5Oopen_by_addr_ff(hid_t loc_id, haddr_ff_t addr, H5O_type_t type, -//hid_t rcxt_id, hid_t estack_id); +H5_DLL herr_t H5Oget_token(hid_t obj_id, void *token, size_t *token_size); +H5_DLL hid_t H5Oopen_by_token(const void *token, hid_t rcxt_id, hid_t estack_id); H5_DLL herr_t H5Olink_ff(hid_t obj_id, hid_t new_loc_id, const char *new_name, hid_t lcpl_id, hid_t lapl_id, hid_t trans_id, hid_t estack_id); H5_DLL herr_t H5Oexists_by_name_ff(hid_t loc_id, const char *name, hbool_t *ret, @@ -26,7 +26,7 @@ /***********/ #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ -#include "H5ESprivate.h" /* Event Queues */ +#include "H5ESprivate.h" /* Event Stacks */ #include "H5Iprivate.h" /* IDs */ #include "H5Lprivate.h" /* Links */ #include "H5MMprivate.h" /* Memory management */ @@ -34,7 +34,7 @@ /***********/ #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ -#include "H5ESprivate.h" /* Event Queues */ +#include "H5ESprivate.h" /* Event Stacks */ #include "H5RCprivate.h" /* Read Contexts */ #include "H5Iprivate.h" /* IDs */ #include "H5MMprivate.h" /* Memory management */ @@ -34,7 +34,7 @@ /***********/ #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ -#include "H5ESprivate.h" /* Event Queues */ +#include "H5ESprivate.h" /* Event Stacks */ #include "H5Iprivate.h" /* IDs */ #include "H5MMprivate.h" /* Memory management */ #include "H5RCprivate.h" /* Read Contexts */ diff --git a/src/H5VLint.c b/src/H5VLint.c index c0a5d9a..dbeeb92 100644 --- a/src/H5VLint.c +++ b/src/H5VLint.c @@ -39,7 +39,7 @@ #include "H5private.h" /* Generic Functions */ #include "H5Dprivate.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ -#include "H5ESprivate.h" /* Event Queues */ +#include "H5ESprivate.h" /* Event Stacks */ #include "H5Iprivate.h" /* IDs */ #include "H5Ipkg.h" /* IDs Package header */ #include "H5Lprivate.h" /* Links */ diff --git a/src/H5VLiod.c b/src/H5VLiod.c index 95fd2a6..b1dcd3a 100644 --- a/src/H5VLiod.c +++ b/src/H5VLiod.c @@ -82,6 +82,7 @@ static hg_id_t H5VL_LINK_EXISTS_ID; static hg_id_t H5VL_LINK_GET_INFO_ID; static hg_id_t H5VL_LINK_GET_VAL_ID; static hg_id_t H5VL_LINK_REMOVE_ID; +static hg_id_t H5VL_OBJECT_OPEN_BY_TOKEN_ID; static hg_id_t H5VL_OBJECT_OPEN_ID; static hg_id_t H5VL_OBJECT_COPY_ID; static hg_id_t H5VL_OBJECT_EXISTS_ID; @@ -528,7 +529,7 @@ H5VL__iod_create_and_forward(hg_id_t op_id, H5RQ_type_t op_type, /* forward the call to the ION */ if(HG_Forward(PEER, op_id, input, output, hg_req) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "failed to ship file create"); + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "failed to ship operation"); /* Store/wait on request */ if(do_async) { @@ -667,6 +668,8 @@ EFF_init(MPI_Comm comm, MPI_Info UNUSED info) H5VL_LINK_ITERATE_ID = MERCURY_REGISTER("link_iterate", link_op_in_t, ret_t); H5VL_LINK_REMOVE_ID = MERCURY_REGISTER("link_remove", link_op_in_t, ret_t); + H5VL_OBJECT_OPEN_BY_TOKEN_ID = MERCURY_REGISTER("object_open_by_token", + object_token_in_t, iod_handle_t); H5VL_OBJECT_OPEN_ID = MERCURY_REGISTER("object_open", object_op_in_t, object_open_out_t); H5VL_OBJECT_COPY_ID = MERCURY_REGISTER("object_copy", object_copy_in_t, ret_t); H5VL_OBJECT_EXISTS_ID = MERCURY_REGISTER("object_exists", object_op_in_t, htri_t); @@ -5070,444 +5073,546 @@ done: /*------------------------------------------------------------------------- - * Function: H5VL_iod_object_open + * Function: H5VL_iod_obj_open_token * - * Purpose: Opens a object inside IOD file. + * Purpose: Opens a object inside IOD file using it IOD ID * * Return: Success: object id. * Failure: NULL * * Programmer: Mohamad Chaarawi - * November, 2012 + * September, 2013 * *------------------------------------------------------------------------- */ -static void * -H5VL_iod_object_open(void *_obj, H5VL_loc_params_t loc_params, - H5I_type_t *opened_type, hid_t dxpl_id, void **req) +void * +H5VL_iod_obj_open_token(const void *token, H5RC_t *rc, H5I_type_t *opened_type, void **req) { - H5VL_iod_object_t *obj = (H5VL_iod_object_t *)_obj; /* location object to open the group */ - H5P_genplist_t *plist = NULL; - hid_t rcxt_id; - H5RC_t *rc = NULL; - size_t num_parents = 0; - char *loc_name = NULL; - H5VL_iod_request_t **parent_reqs = NULL; - void *ret_value; + object_token_in_t input; + const uint8_t *buf_ptr = (const uint8_t *)token; + H5O_type_t obj_type; + iod_obj_id_t iod_id, mdkv_id, attrkv_id; + void *ret_value = NULL; FUNC_ENTER_NOAPI_NOINIT - /* get the context ID */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(dxpl_id))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, NULL, "can't find object for ID"); - if(H5P_get(plist, H5VL_CONTEXT_ID, &rcxt_id) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for trans_id"); + HDmemcpy(&iod_id, buf_ptr, sizeof(iod_obj_id_t)); + buf_ptr += sizeof(iod_obj_id_t); + HDmemcpy(&mdkv_id, buf_ptr, sizeof(iod_obj_id_t)); + buf_ptr += sizeof(iod_obj_id_t); + HDmemcpy(&attrkv_id, buf_ptr, sizeof(iod_obj_id_t)); + buf_ptr += sizeof(iod_obj_id_t); + HDmemcpy(&obj_type, buf_ptr, sizeof(H5O_type_t)); + buf_ptr += sizeof(H5O_type_t); + + switch(obj_type) { + case H5O_TYPE_DATASET: + { + H5VL_iod_dset_t *dset = NULL; /* the dataset object that is created and passed to the user */ - /* get the RC object */ - if(NULL == (rc = (H5RC_t *)H5I_object_verify(rcxt_id, H5I_RC))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "not a READ CONTEXT ID") + /* allocate the dataset object that is returned to the user */ + if(NULL == (dset = H5FL_CALLOC(H5VL_iod_dset_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate object struct"); + + dset->remote_dset.iod_oh.cookie = IOD_OH_UNDEFINED; + dset->remote_dset.iod_id = iod_id; + dset->remote_dset.mdkv_id = mdkv_id; + dset->remote_dset.attrkv_id = attrkv_id; + + dset->dapl_id = H5P_DATASET_ACCESS_DEFAULT; + dset->remote_dset.dcpl_id = H5P_DATASET_CREATE_DEFAULT; - if(H5VL_OBJECT_BY_ADDR == loc_params.type) { - switch(loc_params.loc_data.loc_by_addr.obj_type) { - case H5O_TYPE_DATASET: + /* decode dtype */ { - dset_open_in_t input; - H5VL_iod_dset_t *dset = NULL; /* the dataset object that is created and passed to the user */ + H5T_t *dt = NULL; + size_t dt_size; + + HDmemcpy(&dt_size, buf_ptr, sizeof(size_t)); + buf_ptr += sizeof(size_t); + /* Create datatype by decoding buffer */ + if(NULL == (dt = H5T_decode((const unsigned char *)buf_ptr))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, NULL, "can't decode object"); + /* Register the type */ + if((dset->remote_dset.type_id = H5I_register(H5I_DATATYPE, dt, TRUE)) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, NULL, "unable to register data type"); + buf_ptr += dt_size; + } - /* allocate the dataset object that is returned to the user */ - if(NULL == (dset = H5FL_CALLOC(H5VL_iod_dset_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate object struct"); + /* decode dspace */ + { + H5S_t *ds; + size_t space_size; + + HDmemcpy(&space_size, buf_ptr, sizeof(size_t)); + buf_ptr += sizeof(size_t); + if((ds = H5S_decode((const unsigned char *)buf_ptr)) == NULL) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDECODE, NULL, "can't decode object"); + /* Register the type */ + if((dset->remote_dset.space_id = H5I_register(H5I_DATASPACE, ds, TRUE)) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTREGISTER, NULL, "unable to register dataspace"); + buf_ptr += space_size; + } - dset->remote_dset.iod_oh.cookie = IOD_OH_UNDEFINED; - dset->remote_dset.iod_id = IOD_ID_UNDEFINED; - dset->remote_dset.dcpl_id = -1; - dset->remote_dset.type_id = -1; - dset->remote_dset.space_id = -1; + input.coh = rc->file->remote_file.coh; + input.iod_id = iod_id; - input.coh = obj->file->remote_file.coh; - input.loc_id = loc_params.loc_data.loc_by_addr.addr; - input.loc_oh.cookie = IOD_OH_UNDEFINED; - input.name = "."; - input.dapl_id = H5P_DATASET_ACCESS_DEFAULT; - input.rcxt_num = rc->c_version; - input.cs_scope = obj->file->md_integrity_scope; + /* set common object parameters */ + dset->common.obj_type = H5I_DATASET; + dset->common.file = rc->file; + dset->common.file->nopen_objs ++; + dset->common.obj_name = NULL; - dset->dapl_id = H5P_DATASET_ACCESS_DEFAULT; + if(H5VL__iod_create_and_forward(H5VL_OBJECT_OPEN_BY_TOKEN_ID, HG_OBJECT_OPEN_BY_TOKEN, + (H5VL_iod_object_t *)dset, 1, 0, NULL, + (H5VL_iod_req_info_t *)rc, &input, + &dset->remote_dset.iod_oh, dset, req) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "failed to create and ship dataset open_by_token"); - /* set common object parameters */ - dset->common.obj_type = H5I_DATASET; - dset->common.file = obj->file; - dset->common.file->nopen_objs ++; - dset->common.obj_name = NULL; + ret_value = (void *)dset; + *opened_type = H5I_DATASET; + break; + } + case H5O_TYPE_NAMED_DATATYPE: + { + H5VL_iod_dtype_t *dtype = NULL; /* the datatype object that is created and passed to the user */ - if(H5VL__iod_create_and_forward(H5VL_DSET_OPEN_ID, HG_DSET_OPEN, - (H5VL_iod_object_t *)dset, 1, 0, NULL, - (H5VL_iod_req_info_t *)rc, &input, &dset->remote_dset, dset, req) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "failed to create and ship dataset create"); + /* allocate the datatype object that is returned to the user */ + if(NULL == (dtype = H5FL_CALLOC(H5VL_iod_dtype_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate object struct"); - *opened_type = H5I_DATASET; - ret_value = (void *)dset; - break; - } - case H5O_TYPE_NAMED_DATATYPE: - { - dtype_open_in_t input; - H5VL_iod_dtype_t *dtype = NULL; /* the dataset object that is created and passed to the user */ + dtype->remote_dtype.iod_oh.cookie = IOD_OH_UNDEFINED; + dtype->remote_dtype.iod_id = iod_id; + dtype->remote_dtype.mdkv_id = mdkv_id; + dtype->remote_dtype.attrkv_id = attrkv_id; - /* allocate the datatype object that is returned to the user */ - if(NULL == (dtype = H5FL_CALLOC(H5VL_iod_dtype_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate object struct"); + dtype->tapl_id = H5P_DATATYPE_ACCESS_DEFAULT; + dtype->remote_dtype.tcpl_id = H5P_DATATYPE_CREATE_DEFAULT; - dtype->remote_dtype.iod_oh.cookie = IOD_OH_UNDEFINED; - dtype->remote_dtype.iod_id = IOD_ID_UNDEFINED; - dtype->remote_dtype.tcpl_id = -1; - dtype->remote_dtype.type_id = -1; + /* decode dtype */ + { + H5T_t *dt = NULL; + size_t dt_size; + + HDmemcpy(&dt_size, buf_ptr, sizeof(size_t)); + buf_ptr += sizeof(size_t); + /* Create datatype by decoding buffer */ + if(NULL == (dt = H5T_decode((const unsigned char *)buf_ptr))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, NULL, "can't decode object"); + /* Register the type */ + if((dtype->remote_dtype.type_id = H5I_register(H5I_DATATYPE, dt, TRUE)) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, NULL, "unable to register data type"); + buf_ptr += dt_size; + } - /* set the input structure for the HG encode routine */ - input.coh = obj->file->remote_file.coh; - input.loc_id = loc_params.loc_data.loc_by_addr.addr; - input.loc_oh.cookie = IOD_OH_UNDEFINED; - input.name = "."; - input.tapl_id = H5P_DATATYPE_ACCESS_DEFAULT; - input.rcxt_num = rc->c_version; - input.cs_scope = obj->file->md_integrity_scope; + /* set the input structure for the HG encode routine */ + input.coh = rc->file->remote_file.coh; + input.iod_id = iod_id; + + /* set common object parameters */ + dtype->common.obj_type = H5I_DATATYPE; + dtype->common.file = rc->file; + dtype->common.file->nopen_objs ++; + dtype->common.obj_name = NULL; + + if(H5VL__iod_create_and_forward(H5VL_OBJECT_OPEN_BY_TOKEN_ID, HG_OBJECT_OPEN_BY_TOKEN, + (H5VL_iod_object_t *)dtype, 1, 0, NULL, + (H5VL_iod_req_info_t *)rc, &input, + &dtype->remote_dtype.iod_oh, dtype, req) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "failed to create and ship datatype open_by_token"); + + ret_value = (void *)dtype; + *opened_type = H5I_DATATYPE; + break; + } + case H5O_TYPE_GROUP: + { + H5VL_iod_group_t *grp = NULL; /* the group object that is created and passed to the user */ + + /* allocate the dataset object that is returned to the user */ + if(NULL == (grp = H5FL_CALLOC(H5VL_iod_group_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate object struct"); + + grp->remote_group.iod_oh.cookie = IOD_OH_UNDEFINED; + grp->remote_group.iod_id = iod_id; + grp->remote_group.mdkv_id = mdkv_id; + grp->remote_group.attrkv_id = attrkv_id; + + grp->remote_group.gcpl_id = H5P_GROUP_CREATE_DEFAULT; + grp->gapl_id = H5P_GROUP_ACCESS_DEFAULT; + + /* set the input structure for the HG encode routine */ + input.coh = rc->file->remote_file.coh; + input.iod_id = iod_id; + + /* set common object parameters */ + grp->common.obj_type = H5I_GROUP; + grp->common.file = rc->file; + grp->common.file->nopen_objs ++; + grp->common.obj_name = NULL; + + if(H5VL__iod_create_and_forward(H5VL_OBJECT_OPEN_BY_TOKEN_ID, HG_OBJECT_OPEN_BY_TOKEN, + (H5VL_iod_object_t *)grp, 1, 0, NULL, + (H5VL_iod_req_info_t *)rc, &input, + &grp->remote_group.iod_oh, grp, req) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "failed to create and ship group open_by_token"); + + ret_value = (void *)grp; + *opened_type = H5I_GROUP; + break; + } + case H5O_TYPE_MAP: + { + H5VL_iod_map_t *map = NULL; /* the map object that is created and passed to the user */ - dtype->tapl_id = H5P_DATATYPE_ACCESS_DEFAULT; + /* allocate the dataset object that is returned to the user */ + if(NULL == (map = H5FL_CALLOC(H5VL_iod_map_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate object struct"); - /* set common object parameters */ - dtype->common.obj_type = H5I_DATATYPE; - dtype->common.file = obj->file; - dtype->common.file->nopen_objs ++; - dtype->common.obj_name = NULL; + map->remote_map.iod_oh.cookie = IOD_OH_UNDEFINED; + map->remote_map.iod_id = iod_id; + map->remote_map.mdkv_id = mdkv_id; + map->remote_map.attrkv_id = attrkv_id; - if(H5VL__iod_create_and_forward(H5VL_DTYPE_OPEN_ID, HG_DTYPE_OPEN, - (H5VL_iod_object_t *)dtype, 1, 0, NULL, - (H5VL_iod_req_info_t *)rc, &input, &dtype->remote_dtype, dtype, req) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "failed to create and ship datatype open"); + map->remote_map.mcpl_id = H5P_GROUP_CREATE_DEFAULT; + map->mapl_id = H5P_GROUP_ACCESS_DEFAULT; - *opened_type = H5I_DATATYPE; - ret_value = (void *)dtype; - break; + /* decode key_type */ + { + H5T_t *dt = NULL; + size_t dt_size; + + HDmemcpy(&dt_size, buf_ptr, sizeof(size_t)); + buf_ptr += sizeof(size_t); + /* Create datatype by decoding buffer */ + if(NULL == (dt = H5T_decode((const unsigned char *)buf_ptr))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, NULL, "can't decode object"); + /* Register the type */ + if((map->remote_map.keytype_id = H5I_register(H5I_DATATYPE, dt, TRUE)) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, NULL, "unable to register data type"); + buf_ptr += dt_size; } - case H5O_TYPE_GROUP: + /* decode val_type */ { - group_open_in_t input; - H5VL_iod_group_t *grp = NULL; /* the group object that is created and passed to the user */ + H5T_t *dt = NULL; + size_t dt_size; + + HDmemcpy(&dt_size, buf_ptr, sizeof(size_t)); + buf_ptr += sizeof(size_t); + /* Create datatype by decoding buffer */ + if(NULL == (dt = H5T_decode((const unsigned char *)buf_ptr))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, NULL, "can't decode object"); + /* Register the type */ + if((map->remote_map.valtype_id = H5I_register(H5I_DATATYPE, dt, TRUE)) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, NULL, "unable to register data type"); + buf_ptr += dt_size; + } - /* allocate the dataset object that is returned to the user */ - if(NULL == (grp = H5FL_CALLOC(H5VL_iod_group_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate object struct"); + /* set the input structure for the HG encode routine */ + input.coh = rc->file->remote_file.coh; + input.iod_id = iod_id; - grp->remote_group.iod_oh.cookie = IOD_OH_UNDEFINED; - grp->remote_group.iod_id = IOD_ID_UNDEFINED; - grp->remote_group.gcpl_id = -1; + /* set common object parameters */ + map->common.obj_type = H5I_MAP; + map->common.file = rc->file; + map->common.file->nopen_objs ++; + map->common.obj_name = NULL; - /* set the input structure for the HG encode routine */ - input.coh = obj->file->remote_file.coh; - input.loc_id = loc_params.loc_data.loc_by_addr.addr; - input.loc_oh.cookie = IOD_OH_UNDEFINED; - input.name = "."; - input.gapl_id = H5P_GROUP_ACCESS_DEFAULT; - input.rcxt_num = rc->c_version; - input.cs_scope = obj->file->md_integrity_scope; +#if H5VL_IOD_DEBUG + printf("Map open by token %llu: ID %llu\n", + g_axe_id, input.iod_id); +#endif - grp->gapl_id = H5P_GROUP_ACCESS_DEFAULT; + if(H5VL__iod_create_and_forward(H5VL_OBJECT_OPEN_BY_TOKEN_ID, HG_OBJECT_OPEN_BY_TOKEN, + (H5VL_iod_object_t *)map, 1, 0, NULL, + (H5VL_iod_req_info_t *)rc, &input, + &map->remote_map, map, req) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "failed to create and ship map open"); - /* set common object parameters */ - grp->common.obj_type = H5I_GROUP; - grp->common.file = obj->file; - grp->common.file->nopen_objs ++; - grp->common.obj_name = NULL; + ret_value = (void *)map; + *opened_type = H5I_MAP; + break; + } + case H5O_TYPE_UNKNOWN: + case H5O_TYPE_NTYPES: + default: + HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, NULL, "not a valid file object (dataset, map, group, or datatype)"); + } - if(H5VL__iod_create_and_forward(H5VL_GROUP_OPEN_ID, HG_GROUP_OPEN, - (H5VL_iod_object_t *)grp, 1, 0, NULL, - (H5VL_iod_req_info_t *)rc, &input, &grp->remote_group, grp, req) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "failed to create and ship group open"); +done: + FUNC_LEAVE_NOAPI(ret_value) +}/* end H5VL_iod_obj_open_token() */ - *opened_type = H5I_GROUP; - ret_value = (void *)grp; + +/*------------------------------------------------------------------------- + * Function: H5VL_iod_object_open + * + * Purpose: Opens a object inside IOD file. + * + * Return: Success: object id. + * Failure: NULL + * + * Programmer: Mohamad Chaarawi + * November, 2012 + * + *------------------------------------------------------------------------- + */ +static void * +H5VL_iod_object_open(void *_obj, H5VL_loc_params_t loc_params, + H5I_type_t *opened_type, hid_t dxpl_id, void **req) +{ + H5VL_iod_object_t *obj = (H5VL_iod_object_t *)_obj; /* location object to open the group */ + H5P_genplist_t *plist = NULL; + hid_t rcxt_id; + H5RC_t *rc = NULL; + size_t num_parents = 0; + char *loc_name = NULL; + object_op_in_t input; + H5VL_iod_remote_object_t remote_obj; /* generic remote object structure */ + H5VL_iod_request_t **parent_reqs = NULL; + void *ret_value; - break; - } - case H5O_TYPE_MAP: - { - map_open_in_t input; - H5VL_iod_map_t *map = NULL; /* the map object that is created and passed to the user */ + FUNC_ENTER_NOAPI_NOINIT - /* allocate the dataset object that is returned to the user */ - if(NULL == (map = H5FL_CALLOC(H5VL_iod_map_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate object struct"); + /* get the context ID */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(dxpl_id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, NULL, "can't find object for ID"); + if(H5P_get(plist, H5VL_CONTEXT_ID, &rcxt_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for trans_id"); - map->remote_map.iod_oh.cookie = IOD_OH_UNDEFINED; - map->remote_map.iod_id = IOD_ID_UNDEFINED; - map->remote_map.keytype_id = -1; - map->remote_map.valtype_id = -1; + /* get the RC object */ + if(NULL == (rc = (H5RC_t *)H5I_object_verify(rcxt_id, H5I_RC))) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "not a READ CONTEXT ID") - /* set the input structure for the HG encode routine */ - input.coh = obj->file->remote_file.coh; - input.loc_id = loc_params.loc_data.loc_by_addr.addr; - input.loc_oh.cookie = IOD_OH_UNDEFINED; - input.name = "."; - input.mapl_id = H5P_GROUP_ACCESS_DEFAULT; - input.rcxt_num = rc->c_version; - input.cs_scope = obj->file->md_integrity_scope; + /* allocate parent request array */ + if(NULL == (parent_reqs = (H5VL_iod_request_t **) + H5MM_malloc(sizeof(H5VL_iod_request_t *)))) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, NULL, "can't allocate parent req element"); - map->mapl_id = H5P_GROUP_ACCESS_DEFAULT; + /* retrieve parent requests */ + if(H5VL_iod_get_parent_requests(obj, (H5VL_iod_req_info_t *)rc, parent_reqs, &num_parents) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "Failed to retrieve parent requests"); - /* set common object parameters */ - map->common.obj_type = H5I_MAP; - map->common.file = obj->file; - map->common.file->nopen_objs ++; - map->common.obj_name = NULL; + /* retrieve IOD info of location object */ + if(H5VL_iod_get_loc_info(obj, &input.loc_id, &input.loc_oh, &input.loc_mdkv_id, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "Failed to resolve current location group info"); - if(H5VL__iod_create_and_forward(H5VL_MAP_OPEN_ID, HG_MAP_OPEN, - (H5VL_iod_object_t *)map, 1, 0, NULL, - (H5VL_iod_req_info_t *)rc, &input, &map->remote_map, map, req) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "failed to create and ship map open"); + if(H5VL_OBJECT_BY_SELF == loc_params.type) + loc_name = strdup("."); + else if(H5VL_OBJECT_BY_NAME == loc_params.type) + loc_name = strdup(loc_params.loc_data.loc_by_name.name); - *opened_type = H5I_MAP; - ret_value = (void *)map; + /* set the input structure for the HG encode routine */ + input.coh = obj->file->remote_file.coh; + input.loc_name = loc_name; + input.rcxt_num = rc->c_version; + input.cs_scope = obj->file->md_integrity_scope; - break; - } - default: - HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, NULL, "not a valid file object (dataset, map, group, or datatype)"); - } - } - else { - object_op_in_t input; - H5VL_iod_remote_object_t remote_obj; /* generic remote object structure */ + /* H5Oopen has to be synchronous */ + if(H5VL__iod_create_and_forward(H5VL_OBJECT_OPEN_ID, HG_OBJECT_OPEN, + obj, 1, num_parents, parent_reqs, + (H5VL_iod_req_info_t *)rc, &input, + &remote_obj, &remote_obj, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "failed to create and ship object open"); - /* allocate parent request array */ - if(NULL == (parent_reqs = (H5VL_iod_request_t **) - H5MM_malloc(sizeof(H5VL_iod_request_t *)))) - HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, NULL, "can't allocate parent req element"); + *opened_type = remote_obj.obj_type; - /* retrieve parent requests */ - if(H5VL_iod_get_parent_requests(obj, (H5VL_iod_req_info_t *)rc, parent_reqs, &num_parents) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "Failed to retrieve parent requests"); + if(loc_name) + HDfree(loc_name); - /* retrieve IOD info of location object */ - if(H5VL_iod_get_loc_info(obj, &input.loc_id, &input.loc_oh, &input.loc_mdkv_id, NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "Failed to resolve current location group info"); + switch(remote_obj.obj_type) { + case H5I_DATASET: + { + H5VL_iod_dset_t *dset = NULL; /* the dataset object that is created and passed to the user */ + + /* allocate the dataset object that is returned to the user */ + if(NULL == (dset = H5FL_CALLOC(H5VL_iod_dset_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate object struct"); + + dset->remote_dset.iod_oh.cookie = remote_obj.iod_oh.cookie; + dset->remote_dset.iod_id = remote_obj.iod_id; + dset->remote_dset.mdkv_id = remote_obj.mdkv_id; + dset->remote_dset.attrkv_id = remote_obj.attrkv_id; + dset->remote_dset.dcpl_id = remote_obj.cpl_id; + dset->remote_dset.type_id = remote_obj.type_id; + dset->remote_dset.space_id = remote_obj.space_id; + + if(dset->remote_dset.dcpl_id == H5P_DEFAULT){ + dset->remote_dset.dcpl_id = H5Pcopy(H5P_DATASET_CREATE_DEFAULT); + } - if(H5VL_OBJECT_BY_SELF == loc_params.type) - loc_name = strdup("."); - else if(H5VL_OBJECT_BY_NAME == loc_params.type) - loc_name = strdup(loc_params.loc_data.loc_by_name.name); + HDassert(dset->remote_dset.dcpl_id); + HDassert(dset->remote_dset.type_id); + HDassert(dset->remote_dset.space_id); - /* set the input structure for the HG encode routine */ - input.coh = obj->file->remote_file.coh; - input.loc_name = loc_name; - input.rcxt_num = rc->c_version; - input.cs_scope = obj->file->md_integrity_scope; + /* setup the local dataset struct */ + /* store the entire path of the dataset locally */ + { + size_t obj_name_len = HDstrlen(obj->obj_name); + size_t name_len = HDstrlen(loc_params.loc_data.loc_by_name.name); + + if (NULL == (dset->common.obj_name = (char *)HDmalloc(obj_name_len + name_len + 1))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate"); + HDmemcpy(dset->common.obj_name, obj->obj_name, obj_name_len); + HDmemcpy(dset->common.obj_name+obj_name_len, + loc_params.loc_data.loc_by_name.name, name_len); + dset->common.obj_name[obj_name_len+name_len] = '\0'; + } - /* H5Oopen has to be synchronous */ - if(H5VL__iod_create_and_forward(H5VL_OBJECT_OPEN_ID, HG_OBJECT_OPEN, - obj, 1, num_parents, parent_reqs, - (H5VL_iod_req_info_t *)rc, &input, - &remote_obj, &remote_obj, NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "failed to create and ship object open"); + if((dset->dapl_id = H5Pcopy(H5P_DATASET_CREATE_DEFAULT)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, NULL, "failed to copy dapl"); - *opened_type = remote_obj.obj_type; + /* set common object parameters */ + dset->common.obj_type = H5I_DATASET; + dset->common.file = obj->file; + dset->common.file->nopen_objs ++; - if(loc_name) - HDfree(loc_name); + ret_value = (void *)dset; + break; + } + case H5I_DATATYPE: + { + H5VL_iod_dtype_t *dtype = NULL; /* the dataset object that is created and passed to the user */ - switch(remote_obj.obj_type) { - case H5I_DATASET: - { - H5VL_iod_dset_t *dset = NULL; /* the dataset object that is created and passed to the user */ - - /* allocate the dataset object that is returned to the user */ - if(NULL == (dset = H5FL_CALLOC(H5VL_iod_dset_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate object struct"); - - dset->remote_dset.iod_oh.cookie = remote_obj.iod_oh.cookie; - dset->remote_dset.iod_id = remote_obj.iod_id; - dset->remote_dset.mdkv_id = remote_obj.mdkv_id; - dset->remote_dset.attrkv_id = remote_obj.attrkv_id; - dset->remote_dset.dcpl_id = remote_obj.cpl_id; - dset->remote_dset.type_id = remote_obj.type_id; - dset->remote_dset.space_id = remote_obj.space_id; - - if(dset->remote_dset.dcpl_id == H5P_DEFAULT){ - dset->remote_dset.dcpl_id = H5Pcopy(H5P_DATASET_CREATE_DEFAULT); - } + /* allocate the dataset object that is returned to the user */ + if(NULL == (dtype = H5FL_CALLOC(H5VL_iod_dtype_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate object struct"); - HDassert(dset->remote_dset.dcpl_id); - HDassert(dset->remote_dset.type_id); - HDassert(dset->remote_dset.space_id); - - /* setup the local dataset struct */ - /* store the entire path of the dataset locally */ - { - size_t obj_name_len = HDstrlen(obj->obj_name); - size_t name_len = HDstrlen(loc_params.loc_data.loc_by_name.name); - - if (NULL == (dset->common.obj_name = (char *)HDmalloc(obj_name_len + name_len + 1))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate"); - HDmemcpy(dset->common.obj_name, obj->obj_name, obj_name_len); - HDmemcpy(dset->common.obj_name+obj_name_len, - loc_params.loc_data.loc_by_name.name, name_len); - dset->common.obj_name[obj_name_len+name_len] = '\0'; - } + dtype->remote_dtype.iod_oh.cookie = remote_obj.iod_oh.cookie; + dtype->remote_dtype.iod_id = remote_obj.iod_id; + dtype->remote_dtype.mdkv_id = remote_obj.mdkv_id; + dtype->remote_dtype.attrkv_id = remote_obj.attrkv_id; + dtype->remote_dtype.tcpl_id = remote_obj.cpl_id; + dtype->remote_dtype.type_id = remote_obj.type_id; - if((dset->dapl_id = H5Pcopy(H5P_DATASET_CREATE_DEFAULT)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, NULL, "failed to copy dapl"); + if(dtype->remote_dtype.tcpl_id == H5P_DEFAULT){ + dtype->remote_dtype.tcpl_id = H5Pcopy(H5P_DATATYPE_CREATE_DEFAULT); + } - /* set common object parameters */ - dset->common.obj_type = H5I_DATASET; - dset->common.file = obj->file; - dset->common.file->nopen_objs ++; + HDassert(dtype->remote_dtype.tcpl_id); + HDassert(dtype->remote_dtype.type_id); - ret_value = (void *)dset; - break; - } - case H5I_DATATYPE: + /* setup the local dataset struct */ + /* store the entire path of the dataset locally */ { - H5VL_iod_dtype_t *dtype = NULL; /* the dataset object that is created and passed to the user */ - - /* allocate the dataset object that is returned to the user */ - if(NULL == (dtype = H5FL_CALLOC(H5VL_iod_dtype_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate object struct"); + size_t obj_name_len = HDstrlen(obj->obj_name); + size_t name_len = HDstrlen(loc_params.loc_data.loc_by_name.name); + + if (NULL == (dtype->common.obj_name = (char *)HDmalloc + (obj_name_len + name_len + 1))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate"); + HDmemcpy(dtype->common.obj_name, obj->obj_name, obj_name_len); + HDmemcpy(dtype->common.obj_name+obj_name_len, + loc_params.loc_data.loc_by_name.name, name_len); + dtype->common.obj_name[obj_name_len+name_len] = '\0'; + } - dtype->remote_dtype.iod_oh.cookie = remote_obj.iod_oh.cookie; - dtype->remote_dtype.iod_id = remote_obj.iod_id; - dtype->remote_dtype.mdkv_id = remote_obj.mdkv_id; - dtype->remote_dtype.attrkv_id = remote_obj.attrkv_id; - dtype->remote_dtype.tcpl_id = remote_obj.cpl_id; - dtype->remote_dtype.type_id = remote_obj.type_id; + if((dtype->tapl_id = H5Pcopy(H5P_DATATYPE_CREATE_DEFAULT)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, NULL, "failed to copy dapl"); - if(dtype->remote_dtype.tcpl_id == H5P_DEFAULT){ - dtype->remote_dtype.tcpl_id = H5Pcopy(H5P_DATATYPE_CREATE_DEFAULT); - } + /* set common object parameters */ + dtype->common.obj_type = H5I_DATATYPE; + dtype->common.file = obj->file; + dtype->common.file->nopen_objs ++; - HDassert(dtype->remote_dtype.tcpl_id); - HDassert(dtype->remote_dtype.type_id); - - /* setup the local dataset struct */ - /* store the entire path of the dataset locally */ - { - size_t obj_name_len = HDstrlen(obj->obj_name); - size_t name_len = HDstrlen(loc_params.loc_data.loc_by_name.name); - - if (NULL == (dtype->common.obj_name = (char *)HDmalloc - (obj_name_len + name_len + 1))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate"); - HDmemcpy(dtype->common.obj_name, obj->obj_name, obj_name_len); - HDmemcpy(dtype->common.obj_name+obj_name_len, - loc_params.loc_data.loc_by_name.name, name_len); - dtype->common.obj_name[obj_name_len+name_len] = '\0'; - } + ret_value = (void *)dtype; + break; + } + case H5I_GROUP: + { + H5VL_iod_group_t *grp = NULL; /* the group object that is created and passed to the user */ - if((dtype->tapl_id = H5Pcopy(H5P_DATATYPE_CREATE_DEFAULT)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, NULL, "failed to copy dapl"); + /* allocate the dataset object that is returned to the user */ + if(NULL == (grp = H5FL_CALLOC(H5VL_iod_group_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate object struct"); - /* set common object parameters */ - dtype->common.obj_type = H5I_DATATYPE; - dtype->common.file = obj->file; - dtype->common.file->nopen_objs ++; + grp->remote_group.iod_oh.cookie = remote_obj.iod_oh.cookie; + grp->remote_group.iod_id = remote_obj.iod_id; + grp->remote_group.mdkv_id = remote_obj.mdkv_id; + grp->remote_group.attrkv_id = remote_obj.attrkv_id; + grp->remote_group.gcpl_id = remote_obj.cpl_id; - ret_value = (void *)dtype; - break; + if(grp->remote_group.gcpl_id == H5P_DEFAULT){ + grp->remote_group.gcpl_id = H5Pcopy(H5P_GROUP_CREATE_DEFAULT); } - case H5I_GROUP: - { - H5VL_iod_group_t *grp = NULL; /* the group object that is created and passed to the user */ - - /* allocate the dataset object that is returned to the user */ - if(NULL == (grp = H5FL_CALLOC(H5VL_iod_group_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate object struct"); - grp->remote_group.iod_oh.cookie = remote_obj.iod_oh.cookie; - grp->remote_group.iod_id = remote_obj.iod_id; - grp->remote_group.mdkv_id = remote_obj.mdkv_id; - grp->remote_group.attrkv_id = remote_obj.attrkv_id; - grp->remote_group.gcpl_id = remote_obj.cpl_id; + HDassert(grp->remote_group.gcpl_id); - if(grp->remote_group.gcpl_id == H5P_DEFAULT){ - grp->remote_group.gcpl_id = H5Pcopy(H5P_GROUP_CREATE_DEFAULT); - } + /* setup the local dataset struct */ + /* store the entire path of the dataset locally */ + { + size_t obj_name_len = HDstrlen(obj->obj_name); + size_t name_len = HDstrlen(loc_params.loc_data.loc_by_name.name); + + if (NULL == (grp->common.obj_name = (char *)HDmalloc(obj_name_len + name_len + 1))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate"); + HDmemcpy(grp->common.obj_name, obj->obj_name, obj_name_len); + HDmemcpy(grp->common.obj_name+obj_name_len, + loc_params.loc_data.loc_by_name.name, name_len); + grp->common.obj_name[obj_name_len+name_len] = '\0'; + } - HDassert(grp->remote_group.gcpl_id); + if((grp->gapl_id = H5Pcopy(H5P_GROUP_CREATE_DEFAULT)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, NULL, "failed to copy gapl"); - /* setup the local dataset struct */ - /* store the entire path of the dataset locally */ - { - size_t obj_name_len = HDstrlen(obj->obj_name); - size_t name_len = HDstrlen(loc_params.loc_data.loc_by_name.name); + /* set common object parameters */ + grp->common.obj_type = H5I_GROUP; + grp->common.file = obj->file; + grp->common.file->nopen_objs ++; - if (NULL == (grp->common.obj_name = (char *)HDmalloc(obj_name_len + name_len + 1))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate"); - HDmemcpy(grp->common.obj_name, obj->obj_name, obj_name_len); - HDmemcpy(grp->common.obj_name+obj_name_len, - loc_params.loc_data.loc_by_name.name, name_len); - grp->common.obj_name[obj_name_len+name_len] = '\0'; - } + ret_value = (void *)grp; + break; + } + case H5I_MAP: + { + H5VL_iod_map_t *map = NULL; /* the map object that is created and passed to the user */ - if((grp->gapl_id = H5Pcopy(H5P_GROUP_CREATE_DEFAULT)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, NULL, "failed to copy gapl"); + /* allocate the dataset object that is returned to the user */ + if(NULL == (map = H5FL_CALLOC(H5VL_iod_map_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate object struct"); - /* set common object parameters */ - grp->common.obj_type = H5I_GROUP; - grp->common.file = obj->file; - grp->common.file->nopen_objs ++; + map->remote_map.iod_oh.cookie = remote_obj.iod_oh.cookie; + map->remote_map.iod_id = remote_obj.iod_id; + map->remote_map.mdkv_id = remote_obj.mdkv_id; + map->remote_map.attrkv_id = remote_obj.attrkv_id; + map->remote_map.mcpl_id = remote_obj.cpl_id; - ret_value = (void *)grp; - break; + if(map->remote_map.mcpl_id == H5P_DEFAULT){ + map->remote_map.mcpl_id = H5Pcopy(H5P_GROUP_CREATE_DEFAULT); } - case H5I_MAP: - { - H5VL_iod_map_t *map = NULL; /* the map object that is created and passed to the user */ - /* allocate the dataset object that is returned to the user */ - if(NULL == (map = H5FL_CALLOC(H5VL_iod_map_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate object struct"); + HDassert(map->remote_map.mcpl_id); - map->remote_map.iod_oh.cookie = remote_obj.iod_oh.cookie; - map->remote_map.iod_id = remote_obj.iod_id; - map->remote_map.mdkv_id = remote_obj.mdkv_id; - map->remote_map.attrkv_id = remote_obj.attrkv_id; - map->remote_map.mcpl_id = remote_obj.cpl_id; - - if(map->remote_map.mcpl_id == H5P_DEFAULT){ - map->remote_map.mcpl_id = H5Pcopy(H5P_GROUP_CREATE_DEFAULT); - } - - HDassert(map->remote_map.mcpl_id); - - /* setup the local dataset struct */ - /* store the entire path of the dataset locally */ - { - size_t obj_name_len = HDstrlen(obj->obj_name); - size_t name_len = HDstrlen(loc_params.loc_data.loc_by_name.name); - - if (NULL == (map->common.obj_name = (char *)HDmalloc(obj_name_len + name_len + 1))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate"); - HDmemcpy(map->common.obj_name, obj->obj_name, obj_name_len); - HDmemcpy(map->common.obj_name+obj_name_len, - loc_params.loc_data.loc_by_name.name, name_len); - map->common.obj_name[obj_name_len+name_len] = '\0'; - } + /* setup the local dataset struct */ + /* store the entire path of the dataset locally */ + { + size_t obj_name_len = HDstrlen(obj->obj_name); + size_t name_len = HDstrlen(loc_params.loc_data.loc_by_name.name); + + if (NULL == (map->common.obj_name = (char *)HDmalloc(obj_name_len + name_len + 1))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate"); + HDmemcpy(map->common.obj_name, obj->obj_name, obj_name_len); + HDmemcpy(map->common.obj_name+obj_name_len, + loc_params.loc_data.loc_by_name.name, name_len); + map->common.obj_name[obj_name_len+name_len] = '\0'; + } - if((map->mapl_id = H5Pcopy(H5P_GROUP_CREATE_DEFAULT)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, NULL, "failed to copy mapl"); + if((map->mapl_id = H5Pcopy(H5P_GROUP_CREATE_DEFAULT)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, NULL, "failed to copy mapl"); - /* set common object parameters */ - map->common.obj_type = H5I_MAP; - map->common.file = obj->file; - map->common.file->nopen_objs ++; + /* set common object parameters */ + map->common.obj_type = H5I_MAP; + map->common.file = obj->file; + map->common.file->nopen_objs ++; - ret_value = (void *)map; - break; - } - default: - HGOTO_ERROR(H5E_ARGS, H5E_CANTRELEASE, NULL, "not a valid file object (dataset, map, group, or datatype)") - break; + ret_value = (void *)map; + break; } + default: + HGOTO_ERROR(H5E_ARGS, H5E_CANTRELEASE, NULL, "not a valid file object (dataset, map, group, or datatype)") + break; } -done: + + done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_iod_object_open */ @@ -6780,216 +6885,6 @@ done: /*------------------------------------------------------------------------- - * Function: H5VL_iod_cancel - * - * Purpose: Cancel an asynchronous operation - * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: Mohamad Chaarawi - * April 2013 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL_iod_cancel(void **req, H5ES_status_t *status) -{ - H5VL_iod_request_t *request = *((H5VL_iod_request_t **)req); - hg_status_t hg_status; - int ret; - H5VL_iod_state_t state; - hg_request_t hg_req; /* Local function shipper request, for sync. operations */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - /* request has completed already, can not cancel */ - if(request->state == H5VL_IOD_COMPLETED) { - /* Call the completion function to check return values and free resources */ - if(H5VL_iod_request_complete(request->obj->file, request) < 0) - fprintf(stderr, "Operation Failed!\n"); - - *status = request->status; - - /* free the mercury request */ - request->req = H5MM_xfree(request->req); - - /* Decrement ref count on request */ - H5VL_iod_request_decr_rc(request); - } - - /* forward the cancel call to the IONs */ - if(HG_Forward(PEER, H5VL_CANCEL_OP_ID, &request->axe_id, &state, &hg_req) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "failed to ship attribute write"); - - /* Wait on the cancel request to return */ - ret = HG_Wait(hg_req, HG_MAX_IDLE_TIME, &hg_status); - - /* If the actual wait Fails, then the status of the cancel - operation is unknown */ - if(HG_FAIL == ret) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "failed to wait on cancel request") - else { - if(hg_status) { - /* If the operation to be canceled has already completed, - mark it so and complete it locally */ - if(state == H5VL_IOD_COMPLETED) { - if(H5VL_IOD_PENDING == request->state) { - if(H5VL_iod_request_wait(request->obj->file, request) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to wait for request"); - } - - *status = request->status; - - /* free the mercury request */ - request->req = H5MM_xfree(request->req); - - /* Decrement ref count on request */ - H5VL_iod_request_decr_rc(request); - } - - /* if the status returned is cancelled, then cancel it - locally too */ - else if (state == H5VL_IOD_CANCELLED) { - request->status = H5ES_STATUS_CANCEL; - request->state = H5VL_IOD_CANCELLED; - if(H5VL_iod_request_cancel(request->obj->file, request) < 0) - fprintf(stderr, "Operation Failed!\n"); - - *status = request->status; - - /* free the mercury request */ - request->req = H5MM_xfree(request->req); - - /* Decrement ref count on request */ - H5VL_iod_request_decr_rc(request); - } - } - else - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "Cancel Operation taking too long. Aborting"); - } - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_iod_cancel() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_iod_test - * - * Purpose: Test for an asynchronous operation's completion - * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: Quincey Koziol - * Wednesday, March 20, 2013 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL_iod_test(void **req, H5ES_status_t *status) -{ - H5VL_iod_request_t *request = *((H5VL_iod_request_t **)req); - hg_status_t hg_status; - int ret; - - FUNC_ENTER_NOAPI_NOINIT_NOERR - - /* Test completion of the request if is still pending */ - if(H5VL_IOD_PENDING == request->state) { - ret = HG_Wait(*((hg_request_t *)request->req), 0, &hg_status); - if(HG_FAIL == ret) { - fprintf(stderr, "failed to wait on request\n"); - request->status = H5ES_STATUS_FAIL; - request->state = H5VL_IOD_COMPLETED; - - /* remove the request from the file linked list */ - H5VL_iod_request_delete(request->obj->file, request); - - /* free the mercury request */ - request->req = H5MM_xfree(request->req); - - /* Decrement ref count on request */ - H5VL_iod_request_decr_rc(request); - } - else { - if(hg_status) { - request->status = H5ES_STATUS_SUCCEED; - request->state = H5VL_IOD_COMPLETED; - - /* Call the completion function to check return values and free resources */ - if(H5VL_iod_request_complete(request->obj->file, request) < 0) - fprintf(stderr, "Operation Failed!\n"); - - *status = request->status; - - /* free the mercury request */ - request->req = H5MM_xfree(request->req); - - /* Decrement ref count on request */ - H5VL_iod_request_decr_rc(request); - } - /* request has not finished, set return status appropriately */ - else - *status = request->status; - } - } - else { - *status = request->status; - /* free the mercury request */ - request->req = H5MM_xfree(request->req); - - /* Decrement ref count on request */ - H5VL_iod_request_decr_rc(request); - } - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5VL_iod_test() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_iod_wait - * - * Purpose: Wait for an asynchronous operation to complete - * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: Quincey Koziol - * Wednesday, March 20, 2013 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL_iod_wait(void **req, H5ES_status_t *status) -{ - H5VL_iod_request_t *request = *((H5VL_iod_request_t **)req); - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI_NOINIT - - /* Wait on completion of the request if it was not completed */ - if(H5VL_IOD_PENDING == request->state) { - if(H5VL_iod_request_wait(request->obj->file, request) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to wait for request") - } - - *status = request->status; - - /* free the mercury request */ - request->req = H5MM_xfree(request->req); - - /* Decrement ref count on request */ - H5VL_iod_request_decr_rc(request); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_iod_wait() */ - - -/*------------------------------------------------------------------------- * Function: H5VL_iod_rc_acquire * * Purpose: Forwards an acquire for a read context to IOD. @@ -7603,4 +7498,214 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_iod_tr_abort() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_iod_cancel + * + * Purpose: Cancel an asynchronous operation + * + * Return: Success: SUCCEED + * Failure: FAIL + * + * Programmer: Mohamad Chaarawi + * April 2013 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_iod_cancel(void **req, H5ES_status_t *status) +{ + H5VL_iod_request_t *request = *((H5VL_iod_request_t **)req); + hg_status_t hg_status; + int ret; + H5VL_iod_state_t state; + hg_request_t hg_req; /* Local function shipper request, for sync. operations */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + /* request has completed already, can not cancel */ + if(request->state == H5VL_IOD_COMPLETED) { + /* Call the completion function to check return values and free resources */ + if(H5VL_iod_request_complete(request->obj->file, request) < 0) + fprintf(stderr, "Operation Failed!\n"); + + *status = request->status; + + /* free the mercury request */ + request->req = H5MM_xfree(request->req); + + /* Decrement ref count on request */ + H5VL_iod_request_decr_rc(request); + } + + /* forward the cancel call to the IONs */ + if(HG_Forward(PEER, H5VL_CANCEL_OP_ID, &request->axe_id, &state, &hg_req) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "failed to ship attribute write"); + + /* Wait on the cancel request to return */ + ret = HG_Wait(hg_req, HG_MAX_IDLE_TIME, &hg_status); + + /* If the actual wait Fails, then the status of the cancel + operation is unknown */ + if(HG_FAIL == ret) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "failed to wait on cancel request") + else { + if(hg_status) { + /* If the operation to be canceled has already completed, + mark it so and complete it locally */ + if(state == H5VL_IOD_COMPLETED) { + if(H5VL_IOD_PENDING == request->state) { + if(H5VL_iod_request_wait(request->obj->file, request) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to wait for request"); + } + + *status = request->status; + + /* free the mercury request */ + request->req = H5MM_xfree(request->req); + + /* Decrement ref count on request */ + H5VL_iod_request_decr_rc(request); + } + + /* if the status returned is cancelled, then cancel it + locally too */ + else if (state == H5VL_IOD_CANCELLED) { + request->status = H5ES_STATUS_CANCEL; + request->state = H5VL_IOD_CANCELLED; + if(H5VL_iod_request_cancel(request->obj->file, request) < 0) + fprintf(stderr, "Operation Failed!\n"); + + *status = request->status; + + /* free the mercury request */ + request->req = H5MM_xfree(request->req); + + /* Decrement ref count on request */ + H5VL_iod_request_decr_rc(request); + } + } + else + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "Cancel Operation taking too long. Aborting"); + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_iod_cancel() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_iod_test + * + * Purpose: Test for an asynchronous operation's completion + * + * Return: Success: SUCCEED + * Failure: FAIL + * + * Programmer: Quincey Koziol + * Wednesday, March 20, 2013 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_iod_test(void **req, H5ES_status_t *status) +{ + H5VL_iod_request_t *request = *((H5VL_iod_request_t **)req); + hg_status_t hg_status; + int ret; + + FUNC_ENTER_NOAPI_NOINIT_NOERR + + /* Test completion of the request if is still pending */ + if(H5VL_IOD_PENDING == request->state) { + ret = HG_Wait(*((hg_request_t *)request->req), 0, &hg_status); + if(HG_FAIL == ret) { + fprintf(stderr, "failed to wait on request\n"); + request->status = H5ES_STATUS_FAIL; + request->state = H5VL_IOD_COMPLETED; + + /* remove the request from the file linked list */ + H5VL_iod_request_delete(request->obj->file, request); + + /* free the mercury request */ + request->req = H5MM_xfree(request->req); + + /* Decrement ref count on request */ + H5VL_iod_request_decr_rc(request); + } + else { + if(hg_status) { + request->status = H5ES_STATUS_SUCCEED; + request->state = H5VL_IOD_COMPLETED; + + /* Call the completion function to check return values and free resources */ + if(H5VL_iod_request_complete(request->obj->file, request) < 0) + fprintf(stderr, "Operation Failed!\n"); + + *status = request->status; + + /* free the mercury request */ + request->req = H5MM_xfree(request->req); + + /* Decrement ref count on request */ + H5VL_iod_request_decr_rc(request); + } + /* request has not finished, set return status appropriately */ + else + *status = request->status; + } + } + else { + *status = request->status; + /* free the mercury request */ + request->req = H5MM_xfree(request->req); + + /* Decrement ref count on request */ + H5VL_iod_request_decr_rc(request); + } + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5VL_iod_test() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_iod_wait + * + * Purpose: Wait for an asynchronous operation to complete + * + * Return: Success: SUCCEED + * Failure: FAIL + * + * Programmer: Quincey Koziol + * Wednesday, March 20, 2013 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_iod_wait(void **req, H5ES_status_t *status) +{ + H5VL_iod_request_t *request = *((H5VL_iod_request_t **)req); + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI_NOINIT + + /* Wait on completion of the request if it was not completed */ + if(H5VL_IOD_PENDING == request->state) { + if(H5VL_iod_request_wait(request->obj->file, request) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to wait for request") + } + + *status = request->status; + + /* free the mercury request */ + request->req = H5MM_xfree(request->req); + + /* Decrement ref count on request */ + H5VL_iod_request_decr_rc(request); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_iod_wait() */ + #endif /* H5_HAVE_EFF */ diff --git a/src/H5VLiod_client.c b/src/H5VLiod_client.c index 33ee818..c7b337a 100644 --- a/src/H5VLiod_client.c +++ b/src/H5VLiod_client.c @@ -267,7 +267,7 @@ H5VL_iod_request_wait(H5VL_iod_file_t *file, H5VL_iod_request_t *request) cur_req->status = H5ES_STATUS_SUCCEED; cur_req->state = H5VL_IOD_COMPLETED; if(H5VL_iod_request_complete(file, cur_req) < 0) { - fprintf(stderr, "Operation %d Failed!\n", cur_req->axe_id); + fprintf(stderr, "Operation %llu Failed!\n", cur_req->axe_id); } } } @@ -279,7 +279,7 @@ H5VL_iod_request_wait(H5VL_iod_file_t *file, H5VL_iod_request_t *request) /* request complete, remove it from list & break */ else { if(H5VL_iod_request_complete(file, request) < 0) { - fprintf(stderr, "Operation %d Failed!\n", request->axe_id); + fprintf(stderr, "Operation %llu Failed!\n", request->axe_id); } break; } @@ -336,7 +336,7 @@ H5VL_iod_request_wait_all(H5VL_iod_file_t *file) } if(H5VL_iod_request_complete(file, cur_req) < 0) - fprintf(stderr, "Operation %d Failed!\n", cur_req->axe_id); + fprintf(stderr, "Operation %llu Failed!\n", cur_req->axe_id); cur_req = tmp_req; } @@ -394,7 +394,7 @@ H5VL_iod_request_wait_some(H5VL_iod_file_t *file, const void *object) cur_req->status = H5ES_STATUS_SUCCEED; cur_req->state = H5VL_IOD_COMPLETED; if(H5VL_iod_request_complete(file, cur_req) < 0) - fprintf(stderr, "Operation %d Failed!\n", cur_req->axe_id); + fprintf(stderr, "Operation %llu Failed!\n", cur_req->axe_id); } } } @@ -1278,6 +1278,20 @@ H5VL_iod_request_complete(H5VL_iod_file_t *file, H5VL_iod_request_t *req) H5VL_iod_request_delete(file, req); break; } + case HG_OBJECT_OPEN_BY_TOKEN: + { + iod_handle_t *oh = (iod_handle_t *)req->data; + + if(IOD_OH_UNDEFINED == (*oh).cookie) { + fprintf(stderr, "failed to Open object by token\n"); + req->status = H5ES_STATUS_FAIL; + req->state = H5VL_IOD_COMPLETED; + } + + req->data = NULL; + H5VL_iod_request_delete(file, req); + break; + } case HG_OBJECT_OPEN: req->data = NULL; H5VL_iod_request_delete(file, req); @@ -1671,6 +1685,7 @@ H5VL_iod_request_cancel(H5VL_iod_file_t *file, H5VL_iod_request_t *req) H5VL_iod_request_delete(file, req); break; } + case HG_OBJECT_OPEN_BY_TOKEN: case HG_OBJECT_OPEN: case HG_LINK_GET_INFO: case HG_OBJECT_GET_INFO: diff --git a/src/H5VLiod_client.h b/src/H5VLiod_client.h index d9ad6f2..564d8b3 100644 --- a/src/H5VLiod_client.h +++ b/src/H5VLiod_client.h @@ -74,6 +74,7 @@ typedef enum H5RQ_type_t { HG_MAP_ITERATE, HG_MAP_DELETE, HG_MAP_CLOSE, + HG_OBJECT_OPEN_BY_TOKEN, HG_OBJECT_OPEN, HG_OBJECT_COPY, HG_OBJECT_VISIT, @@ -388,6 +389,9 @@ H5_DLL herr_t H5VL_iod_map_delete(void *map, hid_t key_mem_type_id, const void * hid_t trans_id, void **req); H5_DLL herr_t H5VL_iod_map_close(void *map, void **req); +H5_DLL void * H5VL_iod_obj_open_token(const void *token, H5RC_t *rc, + H5I_type_t *opened_type, void **req); + /* private routines for RC */ H5_DLL herr_t H5VL_iod_rc_acquire(H5VL_iod_file_t *file, H5RC_t *rc, uint64_t *c_version, hid_t rcapl_id, void **req); diff --git a/src/H5VLiod_common.h b/src/H5VLiod_common.h index 2d6f273..87acd76 100644 --- a/src/H5VLiod_common.h +++ b/src/H5VLiod_common.h @@ -309,6 +309,9 @@ MERCURY_GEN_PROC(link_get_val_in_t, ((axe_t)(axe_info)) ((uint32_t)(cs_scope)) ((hg_const_string_t)(path)) ((uint64_t)(length))) MERCURY_GEN_PROC(link_get_val_out_t, ((int32_t)(ret)) ((value_t)(value))) +MERCURY_GEN_PROC(object_token_in_t, ((axe_t)(axe_info)) ((uint32_t)(cs_scope)) + ((iod_handle_t)(coh)) ((iod_obj_id_t)(iod_id))) +//MERCURY_GEN_PROC(object_open_out_t, ((iod_handle_t)(iod_oh))) MERCURY_GEN_PROC(object_op_in_t, ((axe_t)(axe_info)) ((uint32_t)(cs_scope)) ((uint64_t)(rcxt_num)) ((iod_handle_t)(coh)) ((iod_handle_t)(loc_oh)) diff --git a/src/H5VLiod_map.c b/src/H5VLiod_map.c index 2992c31..95b7e26 100644 --- a/src/H5VLiod_map.c +++ b/src/H5VLiod_map.c @@ -254,7 +254,7 @@ H5VL_iod_server_map_open_cb(AXE_engine_t UNUSED axe_engine, } /* open the metadata scratch pad */ - if (iod_obj_open_write(coh, sp[0], NULL /*hints*/, &mdkv_oh, NULL) < 0) + if (iod_obj_open_read(coh, sp[0], NULL /*hints*/, &mdkv_oh, NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "can't open scratch pad"); /* MSC - retrieve metadata - need IOD*/ @@ -273,16 +273,17 @@ H5VL_iod_server_map_open_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 meta data KV handle"); + /* MSC - fake stuff for now*/ + map_oh.cookie = 1; + output.keytype_id = H5Tcopy(H5T_NATIVE_INT); + output.valtype_id = H5Tcopy(H5T_NATIVE_INT); + output.mcpl_id = H5P_GROUP_CREATE_DEFAULT; + output.iod_id = map_id; output.mdkv_id = sp[0]; output.attrkv_id = sp[1]; output.iod_oh = map_oh; - /* MSC - fake datatypes for now*/ - output.keytype_id = H5Tcopy(H5T_NATIVE_INT); - output.valtype_id = H5Tcopy(H5T_NATIVE_INT); - output.mcpl_id = H5P_GROUP_CREATE_DEFAULT; - #if H5VL_IOD_DEBUG fprintf(stderr, "Done with map open, sending response to client\n"); #endif diff --git a/src/H5VLiod_obj.c b/src/H5VLiod_obj.c index 9f0f6a6..d55b3a6 100644 --- a/src/H5VLiod_obj.c +++ b/src/H5VLiod_obj.c @@ -39,6 +39,63 @@ *------------------------------------------------------------------------- */ void +H5VL_iod_server_object_open_by_token_cb(AXE_engine_t UNUSED axe_engine, + size_t UNUSED num_n_parents, AXE_task_t UNUSED n_parents[], + size_t UNUSED num_s_parents, AXE_task_t UNUSED s_parents[], + void *_op_data) +{ + op_data_t *op_data = (op_data_t *)_op_data; + object_token_in_t *input = (object_token_in_t *)op_data->input; + iod_handle_t coh = input->coh; /* the container handle */ + iod_obj_id_t obj_id = input->iod_id; /* The ID of the object */ + //iod_trans_id_t rtid = input->rcxt_num; + //uint32_t cs_scope = input->cs_scope; + iod_handle_t obj_oh; /* The handle for object */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI_NOINIT + +#if H5VL_IOD_DEBUG + fprintf(stderr, "Start Object Open by token = %llu\n", obj_id); +#endif + + /* MSC - this needs to be read write ?? */ + if (iod_obj_open_write(coh, obj_id, NULL /*hints*/, &obj_oh, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't open current group"); + +#if H5VL_IOD_DEBUG + fprintf(stderr, "Done with object open by token, sending response to client\n"); +#endif + + HG_Handler_start_output(op_data->hg_handle, &obj_oh); + +done: + if(ret_value < 0) { + obj_oh.cookie = IOD_OH_UNDEFINED; + HG_Handler_start_output(op_data->hg_handle, &obj_oh); + } + + input = (object_op_in_t *)H5MM_xfree(input); + op_data = (op_data_t *)H5MM_xfree(op_data); + + FUNC_LEAVE_NOAPI_VOID +} /* end H5VL_iod_server_object_open_cb() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_iod_server_object_open_cb + * + * Purpose: Opens an existing object in the container + * + * Return: Success: SUCCEED + * Failure: Negative + * + * Programmer: Mohamad Chaarawi + * May, 2013 + * + *------------------------------------------------------------------------- + */ +void H5VL_iod_server_object_open_cb(AXE_engine_t UNUSED axe_engine, size_t UNUSED num_n_parents, AXE_task_t UNUSED n_parents[], size_t UNUSED num_s_parents, AXE_task_t UNUSED s_parents[], diff --git a/src/H5VLiod_server.c b/src/H5VLiod_server.c index 2f9c3eb..34f117b 100644 --- a/src/H5VLiod_server.c +++ b/src/H5VLiod_server.c @@ -140,6 +140,8 @@ H5VLiod_start_handler(MPI_Comm comm, MPI_Info UNUSED info) MERCURY_HANDLER_REGISTER("link_remove", H5VL_iod_server_link_remove, link_op_in_t, ret_t); + MERCURY_HANDLER_REGISTER("object_open_by_token", H5VL_iod_server_object_open_by_token, + object_token_in_t, iod_handle_t); MERCURY_HANDLER_REGISTER("object_open", H5VL_iod_server_object_open, object_op_in_t, object_open_out_t); MERCURY_HANDLER_REGISTER("object_copy", H5VL_iod_server_object_copy, @@ -2018,6 +2020,60 @@ done: /*------------------------------------------------------------------------- + * Function: H5VL_iod_server_object_open_by_token + * + * Purpose: Function shipper registered call for Object Open by token. + * Inserts the real worker routine into the Async Engine. + * + * Return: Success: HG_SUCCESS + * Failure: Negative + * + * Programmer: Mohamad Chaarawi + * May, 2013 + * + *------------------------------------------------------------------------- + */ +int +H5VL_iod_server_object_open_by_token(hg_handle_t handle) +{ + op_data_t *op_data = NULL; + object_token_in_t *input = NULL; + int ret_value = HG_SUCCESS; + + FUNC_ENTER_NOAPI_NOINIT + + if(NULL == (op_data = (op_data_t *)H5MM_malloc(sizeof(op_data_t)))) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, HG_FAIL, "can't allocate axe op_data struct"); + + if(NULL == (input = (object_token_in_t *) + H5MM_malloc(sizeof(object_token_in_t)))) + HGOTO_ERROR(H5E_DATATYPE, H5E_NOSPACE, HG_FAIL, "can't allocate input struct for decoding"); + + if(HG_FAIL == HG_Handler_get_input(handle, input)) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, HG_FAIL, "can't get input parameters"); + + if(NULL == engine) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, HG_FAIL, "AXE engine not started"); + + if(input->axe_info.count && + H5VL__iod_server_finish_axe_tasks(engine, input->axe_info.start_range, + input->axe_info.count) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, HG_FAIL, "Unable to cleanup AXE tasks"); + + op_data->hg_handle = handle; + op_data->input = (void *)input; + + if (AXE_SUCCEED != AXEcreate_task(engine, input->axe_info.axe_id, + input->axe_info.num_parents, input->axe_info.parent_axe_ids, + 0, NULL, H5VL_iod_server_object_open_by_token_cb, op_data, NULL)) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, HG_FAIL, "can't insert task into async engine"); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_iod_server_object_open_by_token() */ + + +/*------------------------------------------------------------------------- * Function: H5VL_iod_server_object_open * * Purpose: Function shipper registered call for Object Open. diff --git a/src/H5VLiod_server.h b/src/H5VLiod_server.h index 856c7ea..1b9aa22 100644 --- a/src/H5VLiod_server.h +++ b/src/H5VLiod_server.h @@ -114,6 +114,7 @@ H5_DLL int H5VL_iod_server_link_get_info(hg_handle_t handle); H5_DLL int H5VL_iod_server_link_get_val(hg_handle_t handle); H5_DLL int H5VL_iod_server_link_remove(hg_handle_t handle); H5_DLL int H5VL_iod_server_link_iterate(hg_handle_t handle); +H5_DLL int H5VL_iod_server_object_open_by_token(hg_handle_t handle); H5_DLL int H5VL_iod_server_object_open(hg_handle_t handle); H5_DLL int H5VL_iod_server_object_copy(hg_handle_t handle); H5_DLL int H5VL_iod_server_object_visit(hg_handle_t handle); @@ -284,6 +285,10 @@ H5_DLL void H5VL_iod_server_link_remove_cb(AXE_engine_t axe_engine, size_t num_s_parents, AXE_task_t s_parents[], void *op_data); +H5_DLL void H5VL_iod_server_object_open_by_token_cb(AXE_engine_t axe_engine, + size_t num_n_parents, AXE_task_t n_parents[], + size_t num_s_parents, AXE_task_t s_parents[], + void *_op_data); H5_DLL void H5VL_iod_server_object_open_cb(AXE_engine_t axe_engine, size_t num_n_parents, AXE_task_t n_parents[], size_t num_s_parents, AXE_task_t s_parents[], diff --git a/src/H5VLiod_util.c b/src/H5VLiod_util.c index d924ef3..33a4bfa 100644 --- a/src/H5VLiod_util.c +++ b/src/H5VLiod_util.c @@ -201,8 +201,9 @@ H5VL_iod_server_open_path(iod_handle_t coh, iod_obj_id_t loc_id, iod_handle_t lo cur_id = loc_id; if(cur_oh.cookie == IOD_OH_UNDEFINED) { + /* MSC - this needs to be read write ?? */ /* open the current group */ - if (iod_obj_open_read(coh, loc_id, NULL /*hints*/, &cur_oh, NULL) < 0) + 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"); } |