diff options
author | Mohamad Chaarawi <chaarawi@hdfgroup.org> | 2013-06-26 21:45:35 (GMT) |
---|---|---|
committer | Mohamad Chaarawi <chaarawi@hdfgroup.org> | 2013-06-26 21:45:35 (GMT) |
commit | 5d7f70d45d3d45a6541d36636896042487a2a702 (patch) | |
tree | 3194a7e682149debc0df302bf29436bfec197b6d | |
parent | 23a0f9be0e2c85c3949b6174aa0d99ba113ad7e0 (diff) | |
download | hdf5-5d7f70d45d3d45a6541d36636896042487a2a702.zip hdf5-5d7f70d45d3d45a6541d36636896042487a2a702.tar.gz hdf5-5d7f70d45d3d45a6541d36636896042487a2a702.tar.bz2 |
[svn-r23831] - valgrind and fix some memory leaks discovered in object creations
- fix issue discovered when close operations are synchronous. Make all operations pending on object complete
- fix issue with EQ ID registration and termination
-rw-r--r-- | examples/test_client.c | 9 | ||||
-rw-r--r-- | examples/test_client_acg.c | 76 | ||||
-rw-r--r-- | src/H5.c | 1 | ||||
-rw-r--r-- | src/H5EQ.c | 2 | ||||
-rw-r--r-- | src/H5EQprivate.h | 1 | ||||
-rw-r--r-- | src/H5VLiod.c | 334 | ||||
-rw-r--r-- | src/H5VLiod_client.c | 21 | ||||
-rw-r--r-- | src/H5VLiod_server.c | 391 | ||||
-rw-r--r-- | src/H5private.h | 1 |
9 files changed, 627 insertions, 209 deletions
diff --git a/examples/test_client.c b/examples/test_client.c index 0d46e0c..74abac2 100644 --- a/examples/test_client.c +++ b/examples/test_client.c @@ -251,7 +251,7 @@ int main(int argc, char **argv) { the data in the buffer is in BE byte order. Type conversion will
happen at the server when we detect that the dataset type is of
LE order and the datatype here is in BE order. */
- ret = H5Dwrite_ff(did3, H5T_STD_I32BE, dataspaceId, dataspaceId, H5P_DEFAULT, data3,
+ ret = H5Dwrite_ff(did3, H5T_STD_I16BE, dataspaceId, dataspaceId, H5P_DEFAULT, data3,
0, event_q);
assert(ret == 0);
@@ -457,9 +457,7 @@ int main(int argc, char **argv) { for(i=0;i<nelem;++i)
fprintf(stderr, "%d ",r_data[i]);
fprintf(stderr, "\n");
-
fprintf(stderr, "Checksum Receieved = %u Checksum Computed = %u (Should be Equal)\n", read1_cs, cs);
- assert(read1_cs == cs);
/* Print the data that has been read with an injected fault,
This should print the array similar to the previous one, but with the
@@ -468,8 +466,9 @@ int main(int argc, char **argv) { for(i=0;i<nelem;++i)
fprintf(stderr, "%d ",r2_data[i]);
fprintf(stderr, "\n");
-
fprintf(stderr, "Checksum Receieved = %u Checksum Computed = %u (Should NOT be Equal)\n", read2_cs, cs);
+
+ assert(read1_cs == cs);
assert(read2_cs != cs);
fprintf(stderr, "\n*****************************************************************************************************************\n");
@@ -627,8 +626,8 @@ int main(int argc, char **argv) { fprintf(stderr, "Close all open objects then Wait for events in EQ\n");
fprintf(stderr, "*****************************************************************************************************************\n");
- assert(H5Aclose(aid2) == 0);
assert(H5Tclose(int_id) == 0);
+ assert(H5Aclose(aid2) == 0);
assert(H5Gclose(gid1) == 0);
assert(H5Fclose(file_id) == 0);
diff --git a/examples/test_client_acg.c b/examples/test_client_acg.c index c4b2340..c22517f 100644 --- a/examples/test_client_acg.c +++ b/examples/test_client_acg.c @@ -68,6 +68,81 @@ int main(int argc, char **argv) { file_id = H5Fcreate_ff(file_name, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id, event_q);
assert(file_id);
+#if 0
+ {
+ int r_data[60], r2_data[60];
+ hid_t did1;
+ unsigned read1_cs, read2_cs, cs=448091133;
+
+
+ /* create a dataspace. This is a local Bookeeping operation that
+ does not touch the file */
+ dim = 60;
+ sid = H5Screate_simple(1, &dim, NULL);
+
+ did1 = H5Dcreate_ff(file_id,"D1",H5T_STD_I32LE,sid,
+ H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT, 0, event_q);
+ assert(did1);
+
+ dxpl_id = H5Pcreate (H5P_DATASET_XFER);
+ H5Pset_dxpl_checksum_ptr(dxpl_id, &read1_cs);
+ ret = H5Dread_ff(did1, H5T_STD_I32LE, sid, sid, dxpl_id, r_data,
+ 0, event_q);
+ assert(ret == 0);
+ H5Pclose(dxpl_id);
+
+ /*
+ if(H5EQpop(event_q, &req1) < 0)
+ exit(1);
+ assert(H5AOtest(req1, &status1) == 0);
+ (status1 == H5AO_PENDING) ? fprintf(stderr, "Read is still pending\n") : fprintf(stderr, "Read has completed\n");
+ */
+
+ dxpl_id = H5Pcreate (H5P_DATASET_XFER);
+ H5Pset_dxpl_inject_corruption(dxpl_id, 1);
+ H5Pset_dxpl_checksum_ptr(dxpl_id, &read2_cs);
+ ret = H5Dread_ff(did1, H5T_STD_I32LE, sid, sid, dxpl_id, r2_data,
+ 0, event_q);
+ assert(ret == 0);
+ H5Pclose(dxpl_id);
+
+ if(H5EQpop(event_q, &req1) < 0)
+ exit(1);
+ assert(H5AOtest(req1, &status1) == 0);
+ (status1 == H5AO_PENDING) ? fprintf(stderr, "Read is still pending\n") : fprintf(stderr, "Read has completed\n");
+
+ if(H5AO_PENDING == status1) {
+ assert(H5AOwait(req1, &status1) == 0);
+ assert (status1);
+ }
+ else
+ assert(H5AO_SUCCEEDED == status1);
+
+ assert(H5Dclose_ff(did1, event_q) == 0);
+ assert(H5Fclose_ff(file_id, event_q) == 0);
+
+ H5EQwait(event_q, &num_requests, &status);
+
+ fprintf(stderr, "Printing After Waiting ");
+ for(i=0;i<60;++i)
+ fprintf(stderr, "%d ",r_data[i]);
+ fprintf(stderr, "\n");
+ fprintf(stderr, "Checksum Receieved = %u Checksum Computed = %u (Should be Equal)\n", read1_cs, cs);
+
+ fprintf(stderr, "Printing Corrupted Data ");
+ for(i=0;i<60;++i)
+ fprintf(stderr, "%d ",r2_data[i]);
+ fprintf(stderr, "\n");
+ fprintf(stderr, "Checksum Receieved = %u Checksum Computed = %u (Should NOT be Equal)\n", read2_cs, cs);
+
+ assert(read1_cs == cs);
+ assert(read2_cs != cs);
+
+ H5Sclose(sid);
+ }
+#endif
+
+#if 1
/* Create 1-D dataspace */
dim = 0;
max_dim = H5S_UNLIMITED;
@@ -146,6 +221,7 @@ int main(int argc, char **argv) { for(u = 0; u < 60; u++)
if(read_elem[u] != write_elem[u])
return 1;
+#endif
fprintf(stderr, "\n*****************************************************************************************************************\n");
fprintf(stderr, "Finalize EFF stack\n");
@@ -258,6 +258,7 @@ H5_term_library(void) pending += DOWN(A); pending += DOWN(S); pending += DOWN(T); + pending += DOWN(EQ); /* Don't shut down the file code until objects in files are shut down */ if(pending == 0) pending += DOWN(F); @@ -129,7 +129,7 @@ H5EQ_init_interface(void) FUNC_ENTER_NOAPI_NOINIT - /* Initialize the atom group for the file IDs */ + /* Initialize the atom group for the EQ IDs */ if(H5I_register_type(H5I_EQ_CLS) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize interface") diff --git a/src/H5EQprivate.h b/src/H5EQprivate.h index 3862cfa..34904e1 100644 --- a/src/H5EQprivate.h +++ b/src/H5EQprivate.h @@ -59,7 +59,6 @@ typedef struct H5EQ_t { /* Library Private Prototypes */ /******************************/ -H5_DLL int H5EQ_term_interface(void); herr_t H5EQ_init(void); /* API wrappers */ diff --git a/src/H5VLiod.c b/src/H5VLiod.c index b35a100..89fb2e8 100644 --- a/src/H5VLiod.c +++ b/src/H5VLiod.c @@ -870,7 +870,7 @@ H5VL_iod_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl file->common.obj_type = H5I_FILE; /* The name of the location is the root's object name "\" */ - file->common.obj_name = strdup("/"); + file->common.obj_name = HDstrdup("/"); file->common.obj_name[1] = '\0'; file->common.file = file; @@ -1003,7 +1003,7 @@ H5VL_iod_file_open(const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_i file->common.obj_type = H5I_FILE; /* The name of the location is the root's object name "\" */ - file->common.obj_name = strdup("/"); + file->common.obj_name = HDstrdup("/"); file->common.obj_name[1] = '\0'; file->common.file = file; @@ -1470,7 +1470,7 @@ H5VL_iod_group_create(void *_obj, H5VL_loc_params_t loc_params, const char *name iod_obj_id_t iod_id; iod_handle_t iod_oh; uint64_t parent_axe_id; - char *new_name; /* resolved path to where we need to start traversal at the server */ + char *new_name = NULL; /* resolved path to where we need to start traversal at the server */ hg_request_t _hg_req; /* Local function shipper request, for sync. operations */ hg_request_t *hg_req = NULL; H5VL_iod_request_t _request; /* Local request, for sync. operations */ @@ -1545,12 +1545,16 @@ H5VL_iod_group_create(void *_obj, H5VL_loc_params_t loc_params, const char *name /* setup the local group struct */ /* store the entire path of the group locally */ - if (NULL == (grp->common.obj_name = (char *)malloc - (HDstrlen(obj->obj_name) + HDstrlen(name) + 1))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate"); - HDstrcpy(grp->common.obj_name, obj->obj_name); - HDstrcat(grp->common.obj_name, name); - grp->common.obj_name[HDstrlen(obj->obj_name) + HDstrlen(name) + 1] = '\0'; + { + size_t obj_name_len = HDstrlen(obj->obj_name); + size_t name_len = HDstrlen(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, name, name_len); + grp->common.obj_name[obj_name_len+name_len] = '\0'; + } /* copy property lists */ if((grp->remote_group.gcpl_id = H5Pcopy(gcpl_id)) < 0) @@ -1606,7 +1610,7 @@ H5VL_iod_group_create(void *_obj, H5VL_loc_params_t loc_params, const char *name ret_value = (void *)grp; done: - free(new_name); + if(new_name) free(new_name); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_iod_group_create() */ @@ -1634,7 +1638,7 @@ H5VL_iod_group_open(void *_obj, H5VL_loc_params_t loc_params, const char *name, iod_obj_id_t iod_id; iod_handle_t iod_oh; uint64_t parent_axe_id; - char *new_name; /* resolved path to where we need to start traversal at the server */ + char *new_name = NULL; /* resolved path to where we need to start traversal at the server */ hg_request_t _hg_req; /* Local function shipper request, for sync. operations */ hg_request_t *hg_req = NULL; H5VL_iod_request_t _request; /* Local request, for sync. operations */ @@ -1690,12 +1694,16 @@ H5VL_iod_group_open(void *_obj, H5VL_loc_params_t loc_params, const char *name, /* setup the local group struct */ /* store the entire path of the group locally */ - if (NULL == (grp->common.obj_name = (char *)malloc - (HDstrlen(obj->obj_name) + HDstrlen(name) + 1))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate"); - HDstrcpy(grp->common.obj_name, obj->obj_name); - HDstrcat(grp->common.obj_name, name); - grp->common.obj_name[HDstrlen(obj->obj_name) + HDstrlen(name) + 1] = '\0'; + { + size_t obj_name_len = HDstrlen(obj->obj_name); + size_t name_len = HDstrlen(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, name, name_len); + grp->common.obj_name[obj_name_len+name_len] = '\0'; + } /* copy property lists */ if((grp->gapl_id = H5Pcopy(gapl_id)) < 0) @@ -1749,7 +1757,7 @@ H5VL_iod_group_open(void *_obj, H5VL_loc_params_t loc_params, const char *name, ret_value = (void *)grp; done: - free(new_name); + if(new_name) free(new_name); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_iod_group_open() */ @@ -1829,6 +1837,13 @@ H5VL_iod_group_close(void *_grp, hid_t dxpl_id, void **req) FUNC_ENTER_NOAPI_NOINIT + /* If this call is not asynchronous, complete and remove all + requests that are associated with this object from the List */ + if(!do_async) { + if(H5VL_iod_request_wait_some(grp->common.file, grp) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't wait on all object requests"); + } + /* allocate an integer to receive the return value if the group close succeeded or not */ status = (int *)malloc(sizeof(int)); @@ -1926,7 +1941,7 @@ H5VL_iod_dataset_create(void *_obj, H5VL_loc_params_t loc_params, const char *na iod_obj_id_t iod_id; iod_handle_t iod_oh; uint64_t parent_axe_id; - char *new_name; /* resolved path to where we need to start traversal at the server */ + char *new_name = NULL; /* resolved path to where we need to start traversal at the server */ hg_request_t _hg_req; /* Local function shipper request, for sync. operations */ hg_request_t *hg_req = NULL; H5VL_iod_request_t _request; /* Local request, for sync. operations */ @@ -2003,12 +2018,16 @@ H5VL_iod_dataset_create(void *_obj, H5VL_loc_params_t loc_params, const char *na /* setup the local dataset struct */ /* store the entire path of the dataset locally */ - if (NULL == (dset->common.obj_name = (char *)malloc - (HDstrlen(obj->obj_name) + HDstrlen(name) + 1))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate"); - HDstrcpy(dset->common.obj_name, obj->obj_name); - HDstrcat(dset->common.obj_name, name); - dset->common.obj_name[HDstrlen(obj->obj_name) + HDstrlen(name) + 1] = '\0'; + { + size_t obj_name_len = HDstrlen(obj->obj_name); + size_t name_len = HDstrlen(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, name, name_len); + dset->common.obj_name[obj_name_len+name_len] = '\0'; + } /* copy property lists, dtype, and dspace*/ if((dset->remote_dset.dcpl_id = H5Pcopy(dcpl_id)) < 0) @@ -2069,7 +2088,7 @@ H5VL_iod_dataset_create(void *_obj, H5VL_loc_params_t loc_params, const char *na ret_value = (void *)dset; done: - free(new_name); + if(new_name) free(new_name); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_iod_dataset_create() */ @@ -2097,7 +2116,7 @@ H5VL_iod_dataset_open(void *_obj, H5VL_loc_params_t loc_params, const char *name iod_obj_id_t iod_id; iod_handle_t iod_oh; uint64_t parent_axe_id; - char *new_name; /* resolved path to where we need to start traversal at the server */ + char *new_name = NULL; /* resolved path to where we need to start traversal at the server */ hg_request_t _hg_req; /* Local function shipper request, for sync. operations */ hg_request_t *hg_req = NULL; H5VL_iod_request_t _request; /* Local request, for sync. operations */ @@ -2151,14 +2170,22 @@ H5VL_iod_dataset_open(void *_obj, H5VL_loc_params_t loc_params, const char *name /* setup the local dataset struct */ /* store the entire path of the dataset locally */ - if (NULL == (dset->common.obj_name = (char *)malloc - (HDstrlen(obj->obj_name) + HDstrlen(name) + 1))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate"); - HDstrcpy(dset->common.obj_name, obj->obj_name); - HDstrcat(dset->common.obj_name, name); - dset->common.obj_name[HDstrlen(obj->obj_name) + HDstrlen(name) + 1] = '\0'; + { + size_t obj_name_len = HDstrlen(obj->obj_name); + size_t name_len = HDstrlen(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, name, name_len); + dset->common.obj_name[obj_name_len+name_len] = '\0'; + } + +#if H5VL_IOD_DEBUG printf("Dataset Open %s LOC ID %llu, axe id %llu, parent %llu\n", dset->common.obj_name, input.loc_id, input.axe_id, input.parent_axe_id); +#endif + if((dset->dapl_id = H5Pcopy(dapl_id)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, NULL, "failed to copy dapl"); @@ -2211,7 +2238,7 @@ H5VL_iod_dataset_open(void *_obj, H5VL_loc_params_t loc_params, const char *name ret_value = (void *)dset; done: - free(new_name); + if(new_name) free(new_name); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_iod_dataset_open() */ @@ -2400,12 +2427,13 @@ H5VL_iod_dataset_read(void *_dset, hid_t mem_type_id, hid_t mem_space_id, info->buf_ptr = buf; info->nelmts = nelmts; info->type_size = type_size; + info->cs_ptr = NULL; /* store a copy of the dataspace selection to be able to calculate the checksum later */ if(NULL == (info->space = H5S_copy(mem_space, FALSE, TRUE))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to copy dataspace"); /* Get the dxpl plist structure */ if(NULL == (plist = (H5P_genplist_t *)H5I_object(dxpl_id))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, NULL, "can't find object for ID"); + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* store the pointer to the buffer where the checksum needs to be placed */ if(H5P_get(plist, H5D_XFER_CHECKSUM_PTR_NAME, &info->cs_ptr) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to get checksum pointer value"); @@ -2558,7 +2586,7 @@ H5VL_iod_dataset_write(void *_dset, hid_t mem_type_id, hid_t mem_space_id, /* Get the dcpl plist structure */ if(NULL == (plist = (H5P_genplist_t *)H5I_object(dxpl_id))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, NULL, "can't find object for ID"); + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); if(H5P_get(plist, H5D_XFER_CHECKSUM_NAME, &user_cs) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to get checksum value"); @@ -2966,10 +2994,17 @@ H5VL_iod_dataset_close(void *_dset, hid_t dxpl_id, void **req) -1 == dset->remote_dset.space_id) { /* Synchronously wait on the request attached to the dataset */ if(H5VL_iod_request_wait(dset->common.file, dset->common.request) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't wait on HG request"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't wait dset request"); dset->common.request = NULL; } + /* If this call is not asynchronous, complete and remove all + requests that are associated with this object from the List */ + if(!do_async) { + if(H5VL_iod_request_wait_some(dset->common.file, dset) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't wait on all object requests"); + } + /* determine the parent axe IDs array for this operation*/ if(H5VL_iod_get_axe_parents((H5VL_iod_object_t *)dset, &num_parents, NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get num AXE parents"); @@ -3045,6 +3080,7 @@ H5VL_iod_dataset_close(void *_dset, hid_t dxpl_id, void **req) /* Synchronously wait on the request */ if(H5VL_iod_request_wait(dset->common.file, request) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't wait on HG request"); + /* Sanity check */ HDassert(request == &_request); } /* end else */ @@ -3079,7 +3115,7 @@ H5VL_iod_datatype_commit(void *_obj, H5VL_loc_params_t loc_params, const char *n dtype_commit_in_t input; iod_obj_id_t iod_id; iod_handle_t iod_oh; - char *new_name; /* resolved path to where we need to start traversal at the server */ + char *new_name = NULL; /* resolved path to where we need to start traversal at the server */ hg_request_t _hg_req; /* Local function shipper request, for sync. operations */ hg_request_t *hg_req = NULL; H5VL_iod_request_t _request; /* Local request, for sync. operations */ @@ -3143,12 +3179,16 @@ H5VL_iod_datatype_commit(void *_obj, H5VL_loc_params_t loc_params, const char *n /* setup the local datatype struct */ /* store the entire path of the datatype locally */ - if (NULL == (dtype->common.obj_name = (char *)malloc - (HDstrlen(obj->obj_name) + HDstrlen(name) + 1))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate"); - HDstrcpy(dtype->common.obj_name, obj->obj_name); - HDstrcat(dtype->common.obj_name, name); - dtype->common.obj_name[HDstrlen(obj->obj_name) + HDstrlen(name) + 1] = '\0'; + { + size_t obj_name_len = HDstrlen(obj->obj_name); + size_t name_len = HDstrlen(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, name, name_len); + dtype->common.obj_name[obj_name_len+name_len] = '\0'; + } /* store a copy of the datatype parameters*/ if((dtype->remote_dtype.tcpl_id = H5Pcopy(tcpl_id)) < 0) @@ -3206,6 +3246,7 @@ H5VL_iod_datatype_commit(void *_obj, H5VL_loc_params_t loc_params, const char *n ret_value = (void *)dtype; done: + if(new_name) free(new_name); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_iod_datatype_commit() */ @@ -3232,7 +3273,7 @@ H5VL_iod_datatype_open(void *_obj, H5VL_loc_params_t loc_params, const char *nam dtype_open_in_t input; iod_obj_id_t iod_id; iod_handle_t iod_oh; - char *new_name; /* resolved path to where we need to start traversal at the server */ + char *new_name = NULL; /* resolved path to where we need to start traversal at the server */ hg_request_t _hg_req; /* Local function shipper request, for sync. operations */ hg_request_t *hg_req = NULL; H5VL_iod_request_t _request; /* Local request, for sync. operations */ @@ -3286,12 +3327,16 @@ H5VL_iod_datatype_open(void *_obj, H5VL_loc_params_t loc_params, const char *nam /* setup the local datatype struct */ /* store the entire path of the datatype locally */ - if (NULL == (dtype->common.obj_name = (char *)malloc - (HDstrlen(obj->obj_name) + HDstrlen(name) + 1))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate"); - HDstrcpy(dtype->common.obj_name, obj->obj_name); - HDstrcat(dtype->common.obj_name, name); - dtype->common.obj_name[HDstrlen(obj->obj_name) + HDstrlen(name) + 1] = '\0'; + { + size_t obj_name_len = HDstrlen(obj->obj_name); + size_t name_len = HDstrlen(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, name, name_len); + dtype->common.obj_name[obj_name_len+name_len] = '\0'; + } if((dtype->tapl_id = H5Pcopy(tapl_id)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, NULL, "failed to copy tapl"); @@ -3345,6 +3390,7 @@ H5VL_iod_datatype_open(void *_obj, H5VL_loc_params_t loc_params, const char *nam ret_value = (void *)dtype; done: + if(new_name) free(new_name); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_iod_datatype_open() */ @@ -3405,12 +3451,18 @@ H5VL_iod_datatype_close(void *obj, hid_t dxpl_id, void **req) hg_request_t *hg_req = NULL; H5VL_iod_request_t _request; /* Local request, for sync. operations */ H5VL_iod_request_t *request = NULL; - uint64_t parent_axe_id; hbool_t do_async = (req == NULL) ? FALSE : TRUE; /* Whether we're performing async. I/O */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT + /* If this call is not asynchronous, complete and remove all + requests that are associated with this object from the List */ + if(!do_async) { + if(H5VL_iod_request_wait_some(dtype->common.file, dtype) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't wait on all object requests"); + } + /* set the parent axe id */ if(dtype->common.request) input.parent_axe_id = dtype->common.request->axe_id; @@ -3455,6 +3507,11 @@ H5VL_iod_datatype_close(void *obj, hid_t dxpl_id, void **req) /* add request to container's linked list */ H5VL_iod_request_add(dtype->common.file, request); +#if H5VL_IOD_DEBUG + printf("Datatype Close %s, axe id %llu, parent %d\n", + dtype->common.obj_name, input.axe_id, input.parent_axe_id); +#endif + /* Store/wait on request */ if(do_async) { /* Sanity check */ @@ -3501,7 +3558,7 @@ H5VL_iod_attribute_create(void *_obj, H5VL_loc_params_t loc_params, const char * H5P_genplist_t *plist; iod_obj_id_t iod_id; iod_handle_t iod_oh; - char *new_name; /* resolved path to where we need to start traversal at the server */ + char *new_name = NULL; /* resolved path to where we need to start traversal at the server */ const char *path; /* path on where the traversal starts relative to the location object specified */ hg_request_t _hg_req; /* Local function shipper request, for sync. operations */ hg_request_t *hg_req = NULL; @@ -3558,11 +3615,6 @@ H5VL_iod_attribute_create(void *_obj, H5VL_loc_params_t loc_params, const char * input.space_id = space_id; input.axe_id = axe_id ++; -#if H5VL_IOD_DEBUG - printf("Attribute Create %s IOD ID %llu, axe id %llu, parent %llu\n", - attr_name, input.attr_id, input.axe_id, input.parent_axe_id); -#endif - /* get a function shipper request */ if(do_async) { if(NULL == (hg_req = (hg_request_t *)H5MM_malloc(sizeof(hg_request_t)))) @@ -3583,18 +3635,27 @@ H5VL_iod_attribute_create(void *_obj, H5VL_loc_params_t loc_params, const char * attr->loc_name = HDstrdup(obj->obj_name); } else if (loc_params.type == H5VL_OBJECT_BY_NAME) { + size_t obj_name_len = HDstrlen(obj->obj_name); + size_t name_len; + path = loc_params.loc_data.loc_by_name.name; - if (NULL == (attr->loc_name = (char *)malloc - (HDstrlen(obj->obj_name) + HDstrlen(path) + 1))) + name_len = HDstrlen(path); + + if (NULL == (attr->loc_name = (char *)HDmalloc(obj_name_len + name_len + 1))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate"); - HDstrcpy(attr->loc_name, obj->obj_name); - HDstrcat(attr->loc_name, path); - attr->loc_name[HDstrlen(obj->obj_name) + HDstrlen(path) + 1] = '\0'; + HDmemcpy(attr->loc_name, obj->obj_name, obj_name_len); + HDmemcpy(attr->loc_name+obj_name_len, path, name_len); + attr->loc_name[obj_name_len+name_len] = '\0'; } /* store the name of the attribute locally */ attr->common.obj_name = strdup(attr_name); +#if H5VL_IOD_DEBUG + printf("Attribute Create %s IOD ID %llu, axe id %llu, parent %llu\n", + attr_name, input.attr_id, input.axe_id, input.parent_axe_id); +#endif + /* copy property lists, dtype, and dspace*/ if((attr->remote_attr.acpl_id = H5Pcopy(acpl_id)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, NULL, "failed to copy acpl"); @@ -3652,7 +3713,7 @@ H5VL_iod_attribute_create(void *_obj, H5VL_loc_params_t loc_params, const char * ret_value = (void *)attr; done: - free(new_name); + if(new_name) free(new_name); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_iod_attribute_create() */ @@ -3677,7 +3738,7 @@ H5VL_iod_attribute_open(void *_obj, H5VL_loc_params_t loc_params, const char *at H5VL_iod_object_t *obj = (H5VL_iod_object_t *)_obj; /* location object to create the attribute */ H5VL_iod_attr_t *attr = NULL; /* the attribute object that is created and passed to the user */ attr_open_in_t input; - char *new_name; /* resolved path to where we need to start traversal at the server */ + char *new_name = NULL; /* resolved path to where we need to start traversal at the server */ const char *path; /* path on where the traversal starts relative to the location object specified */ iod_obj_id_t iod_id; iod_handle_t iod_oh; @@ -3741,13 +3802,17 @@ H5VL_iod_attribute_open(void *_obj, H5VL_loc_params_t loc_params, const char *at attr->loc_name = HDstrdup(obj->obj_name); } else if (loc_params.type == H5VL_OBJECT_BY_NAME) { + size_t obj_name_len = HDstrlen(obj->obj_name); + size_t name_len; + path = loc_params.loc_data.loc_by_name.name; - if (NULL == (attr->loc_name = (char *)malloc - (HDstrlen(obj->obj_name) + HDstrlen(path) + 1))) + name_len = HDstrlen(path); + + if (NULL == (attr->loc_name = (char *)HDmalloc(obj_name_len + name_len + 1))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate"); - HDstrcpy(attr->loc_name, obj->obj_name); - HDstrcat(attr->loc_name, path); - attr->loc_name[HDstrlen(obj->obj_name) + HDstrlen(path) + 1] = '\0'; + HDmemcpy(attr->loc_name, obj->obj_name, obj_name_len); + HDmemcpy(attr->loc_name+obj_name_len, path, name_len); + attr->loc_name[obj_name_len+name_len] = '\0'; } /* store the name of the attribute locally */ @@ -3802,7 +3867,7 @@ H5VL_iod_attribute_open(void *_obj, H5VL_loc_params_t loc_params, const char *at ret_value = (void *)attr; done: - free(new_name); + if(new_name) free(new_name); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_iod_attribute_open() */ @@ -4095,7 +4160,7 @@ H5VL_iod_attribute_remove(void *_obj, H5VL_loc_params_t loc_params, const char * attr_op_in_t input; iod_obj_id_t iod_id; iod_handle_t iod_oh; - char *new_name; /* resolved path to where we need to start traversal at the server */ + char *new_name = NULL; /* resolved path to where we need to start traversal at the server */ hg_request_t _hg_req; /* Local function shipper request, for sync. operations */ hg_request_t *hg_req = NULL; H5VL_iod_request_t _request; /* Local request, for sync. operations */ @@ -4172,9 +4237,7 @@ H5VL_iod_attribute_remove(void *_obj, H5VL_loc_params_t loc_params, const char * } /* end else */ done: - - free(new_name); - + if(new_name) free(new_name); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_iod_attribute_remove() */ @@ -4299,7 +4362,7 @@ H5VL_iod_attribute_get(void *_obj, H5VL_attr_get_t get_type, hid_t dxpl_id, H5VL_loc_params_t loc_params = va_arg (arguments, H5VL_loc_params_t); char *attr_name = va_arg (arguments, char *); htri_t *ret = va_arg (arguments, htri_t *); - char *new_name; + char *new_name = NULL; attr_op_in_t input; /* Retrieve the parent AXE id by traversing the path where the @@ -4364,7 +4427,7 @@ H5VL_iod_attribute_get(void *_obj, H5VL_attr_get_t get_type, hid_t dxpl_id, HDassert(request == &_request); } /* end else */ - free(new_name); + if(new_name) free(new_name); break; } /* H5Aget_info */ @@ -4443,6 +4506,13 @@ H5VL_iod_attribute_close(void *_attr, hid_t dxpl_id, void **req) attr->common.request = NULL; } + /* If this call is not asynchronous, complete and remove all + requests that are associated with this object from the List */ + if(!do_async) { + if(H5VL_iod_request_wait_some(attr->common.file, attr) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't wait on all object requests"); + } + /* get all the parents required to complete before this operation can start */ if(H5VL_iod_get_axe_parents((H5VL_iod_object_t *)attr, &num_parents, NULL) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get num AXE parents"); @@ -4740,10 +4810,10 @@ H5VL_iod_link_create(H5VL_link_create_type_t create_type, void *_obj, H5VL_loc_p HDassert(request == &_request); } /* end else */ - free(loc_name); - free(new_name); - done: + if(loc_name) free(loc_name); + if(new_name) free(new_name); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_iod_link_create() */ @@ -4804,13 +4874,16 @@ H5VL_iod_link_move(void *_src_obj, H5VL_loc_params_t loc_params1, char *link_name = NULL; /* generate the entire path of the new link */ - if (NULL == (link_name = (char *)malloc(HDstrlen(dst_obj->obj_name) + - HDstrlen(loc_params2.loc_data.loc_by_name.name) + 1))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate"); - HDstrcpy(link_name, dst_obj->obj_name); - HDstrcat(link_name, loc_params2.loc_data.loc_by_name.name); - link_name[HDstrlen(dst_obj->obj_name) + - HDstrlen(loc_params2.loc_data.loc_by_name.name) + 1] = '\0'; + { + size_t obj_name_len = HDstrlen(dst_obj->obj_name); + size_t name_len = HDstrlen(loc_params2.loc_data.loc_by_name.name); + + if (NULL == (link_name = (char *)HDmalloc(obj_name_len + name_len + 1))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate"); + HDmemcpy(link_name, dst_obj->obj_name, obj_name_len); + HDmemcpy(link_name+obj_name_len, loc_params2.loc_data.loc_by_name.name, name_len); + link_name[obj_name_len+name_len] = '\0'; + } //H5VL_iod_update_link(dst_obj, loc_params2, link_name); free(link_name); } @@ -4888,8 +4961,8 @@ H5VL_iod_link_move(void *_src_obj, H5VL_loc_params_t loc_params1, } /* end else */ done: - free(src_name); - free(dst_name); + if(src_name) free(src_name); + if(dst_name) free(dst_name); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_iod_link_move() */ @@ -5022,7 +5095,7 @@ H5VL_iod_link_get(void *_obj, H5VL_loc_params_t loc_params, H5VL_link_get_t get_ HDassert(request == &_request); } /* end else */ - free(new_name); + if(new_name) free(new_name); break; } /* H5Lget_info/H5Lget_info_by_idx */ @@ -5153,8 +5226,8 @@ H5VL_iod_link_remove(void *_obj, H5VL_loc_params_t loc_params, hid_t dxpl_id, vo HDassert(request == &_request); } /* end else */ - free(new_name); done: + if(new_name) free(new_name); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_iod_link_remove() */ @@ -5181,7 +5254,7 @@ H5VL_iod_object_open(void *_obj, H5VL_loc_params_t loc_params, H5VL_iod_request_t request; /* Local request, for sync. operations */ H5VL_iod_remote_object_t remote_obj; /* generic remote object structure */ object_op_in_t input; - char *new_name; + char *new_name = NULL; void *ret_value; FUNC_ENTER_NOAPI_NOINIT @@ -5243,14 +5316,18 @@ H5VL_iod_object_open(void *_obj, H5VL_loc_params_t loc_params, /* setup the local dataset struct */ /* store the entire path of the dataset locally */ - if (NULL == (dset->common.obj_name = (char *)malloc - (HDstrlen(obj->obj_name) + - HDstrlen(loc_params.loc_data.loc_by_name.name) + 1))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate"); - HDstrcpy(dset->common.obj_name, obj->obj_name); - HDstrcat(dset->common.obj_name, loc_params.loc_data.loc_by_name.name); - dset->common.obj_name[HDstrlen(obj->obj_name) + - HDstrlen(loc_params.loc_data.loc_by_name.name) + 1] = '\0'; + { + 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'; + } + if((dset->dapl_id = H5Pcopy(H5P_DATASET_CREATE_DEFAULT)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, NULL, "failed to copy dapl"); @@ -5284,14 +5361,19 @@ H5VL_iod_object_open(void *_obj, H5VL_loc_params_t loc_params, /* setup the local dataset struct */ /* store the entire path of the dataset locally */ - if (NULL == (dtype->common.obj_name = (char *)malloc - (HDstrlen(obj->obj_name) + - HDstrlen(loc_params.loc_data.loc_by_name.name) + 1))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate"); - HDstrcpy(dtype->common.obj_name, obj->obj_name); - HDstrcat(dtype->common.obj_name, loc_params.loc_data.loc_by_name.name); - dtype->common.obj_name[HDstrlen(obj->obj_name) + - HDstrlen(loc_params.loc_data.loc_by_name.name) + 1] = '\0'; + { + 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'; + } + if((dtype->tapl_id = H5Pcopy(H5P_DATATYPE_CREATE_DEFAULT)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, NULL, "failed to copy dapl"); @@ -5323,14 +5405,18 @@ H5VL_iod_object_open(void *_obj, H5VL_loc_params_t loc_params, /* setup the local dataset struct */ /* store the entire path of the dataset locally */ - if (NULL == (grp->common.obj_name = (char *)malloc - (HDstrlen(obj->obj_name) + - HDstrlen(loc_params.loc_data.loc_by_name.name) + 1))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate"); - HDstrcpy(grp->common.obj_name, obj->obj_name); - HDstrcat(grp->common.obj_name, loc_params.loc_data.loc_by_name.name); - grp->common.obj_name[HDstrlen(obj->obj_name) + - HDstrlen(loc_params.loc_data.loc_by_name.name) + 1] = '\0'; + { + 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'; + } + if((grp->gapl_id = H5Pcopy(H5P_GROUP_CREATE_DEFAULT)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, NULL, "failed to copy gapl"); @@ -5348,7 +5434,7 @@ H5VL_iod_object_open(void *_obj, H5VL_loc_params_t loc_params, } done: - free(new_name); + if(new_name) free(new_name); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_iod_object_open */ @@ -5467,8 +5553,8 @@ H5VL_iod_object_copy(void *_src_obj, H5VL_loc_params_t loc_params1, const char * } /* end else */ done: - free(new_src_name); - free(new_dst_name); + if(new_src_name) free(new_src_name); + if(new_dst_name) free(new_dst_name); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_iod_object_copy() */ @@ -5537,7 +5623,7 @@ H5VL_iod_object_misc(void *_obj, H5VL_loc_params_t loc_params, H5VL_object_misc_ { const char *old_name = va_arg (arguments, const char *); const char *new_name = va_arg (arguments, const char *); - char *loc_name; + char *loc_name = NULL; attr_rename_in_t input; /* Retrieve the parent AXE id by traversing the path where the @@ -5608,7 +5694,7 @@ H5VL_iod_object_misc(void *_obj, H5VL_loc_params_t loc_params, H5VL_object_misc_ HDassert(request == &_request); } /* end else */ - free(loc_name); + if(loc_name) free(loc_name); break; } /* H5Oset_comment */ @@ -5682,7 +5768,7 @@ H5VL_iod_object_misc(void *_obj, H5VL_loc_params_t loc_params, H5VL_object_misc_ if(loc_params.type == H5VL_OBJECT_BY_SELF) obj->comment = HDstrdup(comment); - free(loc_name); + if(loc_name) free(loc_name); break; } /* H5Oincr_refcount / H5Odecr_refcount */ @@ -5810,7 +5896,7 @@ H5VL_iod_object_get(void *_obj, H5VL_loc_params_t loc_params, H5VL_object_get_t HDassert(request == &_request); } /* end else */ - free(new_name); + if(new_name) free(new_name); break; } /* H5Oget_comment / H5Oget_comment_by_name */ @@ -5915,7 +6001,7 @@ H5VL_iod_object_get(void *_obj, H5VL_loc_params_t loc_params, H5VL_object_get_t HDassert(request == &_request); } /* end else */ - free(new_name); + if(new_name) free(new_name); break; } /* H5Oget_info / H5Oget_info_by_name / H5Oget_info_by_idx */ diff --git a/src/H5VLiod_client.c b/src/H5VLiod_client.c index 475d3bf..66825dc 100644 --- a/src/H5VLiod_client.c +++ b/src/H5VLiod_client.c @@ -141,7 +141,7 @@ H5VL_iod_request_wait(H5VL_iod_file_t *file, H5VL_iod_request_t *request) H5VL_iod_request_t *tmp_req = NULL; if(cur_req) { - if(cur_req->req != request->req) { + if(HG_FILE_CLOSE != cur_req->type && cur_req->req != request->req) { hg_status_t tmp_status; tmp_req = cur_req->next; @@ -243,15 +243,15 @@ H5VL_iod_request_wait_some(H5VL_iod_file_t *file, const void *object) fprintf(stderr, "failed to wait on request\n"); cur_req->status = H5AO_FAILED; cur_req->state = H5VL_IOD_COMPLETED; + H5VL_iod_request_delete(file, cur_req); } else { HDassert(status); cur_req->status = H5AO_SUCCEEDED; cur_req->state = H5VL_IOD_COMPLETED; + if(H5VL_iod_request_complete(file, cur_req) < 0) + fprintf(stderr, "Operation Failed!\n"); } - - if(H5VL_iod_request_complete(file, cur_req) < 0) - fprintf(stderr, "Operation Failed!\n"); } cur_req = tmp_req; } @@ -360,9 +360,8 @@ H5VL_iod_request_complete(H5VL_iod_file_t *file, H5VL_iod_request_t *req) req->state = H5VL_IOD_COMPLETED; } else { - uint32_t internal_cs; + uint32_t internal_cs = 0; - fprintf(stderr, "size %d nelmts %d\n", info->type_size, info->nelmts); /* calculate a checksum for the data recieved */ internal_cs = H5S_checksum(info->buf_ptr, info->type_size, info->nelmts, info->space); @@ -511,7 +510,10 @@ H5VL_iod_request_complete(H5VL_iod_file_t *file, H5VL_iod_request_t *req) H5VL_iod_request_delete(file, req); /* free attr components */ - free(attr->common.obj_name); + if(attr->common.obj_name) + free(attr->common.obj_name); + if(attr->loc_name) + free(attr->loc_name); if(attr->common.comment) HDfree(attr->common.comment); if(attr->remote_attr.acpl_id != H5P_ATTRIBUTE_CREATE_DEFAULT && @@ -766,7 +768,10 @@ H5VL_iod_request_cancel(H5VL_iod_file_t *file, H5VL_iod_request_t *req) H5VL_iod_request_delete(file, req); /* free attr components */ - free(attr->common.obj_name); + if(attr->common.obj_name) + free(attr->common.obj_name); + if(attr->loc_name) + free(attr->loc_name); if(attr->common.comment) HDfree(attr->common.comment); if(attr->remote_attr.acpl_id != 0 && diff --git a/src/H5VLiod_server.c b/src/H5VLiod_server.c index dc9796a..cc417076 100644 --- a/src/H5VLiod_server.c +++ b/src/H5VLiod_server.c @@ -308,7 +308,7 @@ H5VLiod_start_handler(MPI_Comm comm, MPI_Info UNUSED info) return FAIL; /* Set number of threads in AXE engine */ - if(AXEset_num_threads(&engine_attr, 1) != AXE_SUCCEED) + if(AXEset_num_threads(&engine_attr, 4) != AXE_SUCCEED) return FAIL; /* Create AXE engine */ @@ -3589,6 +3589,9 @@ H5VL_iod_server_dset_write_cb(AXE_engine_t UNUSED axe_engine, FUNC_ENTER_NOAPI_NOINIT +#if H5VL_IOD_DEBUG + fprintf(stderr, "Dataset Write with AXE ID %llu\n",input->axe_id); +#endif /* open the dataset if we don't have the handle yet */ if(iod_oh.cookie == IOD_OH_UNDEFINED) { if (iod_obj_open_write(coh, iod_id, NULL /*hints*/, &iod_oh, NULL) < 0) @@ -3607,8 +3610,8 @@ H5VL_iod_server_dset_write_cb(AXE_engine_t UNUSED axe_engine, if(src_size < dst_size) { buf_size = dst_size * nelmts; #if H5VL_IOD_DEBUG - fprintf(stderr, "Adjusted Buffer size because of datatype conversion from %d to %d: ", - size, buf_size); + fprintf(stderr, "Adjusted Buffer size because of datatype conversion from %d to %d\n", + size, buf_size); #endif } else { @@ -3654,20 +3657,21 @@ H5VL_iod_server_dset_write_cb(AXE_engine_t UNUSED axe_engine, if(H5Tconvert(src_id, dst_id, nelmts, buf, NULL, dxpl_id) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "data type conversion failed") +#if H5VL_IOD_DEBUG { int i; int *buf_ptr = (int *)buf; - fprintf(stderr, "Received a buffer of size %d with values: ", size); + fprintf(stderr, "DWRITE Received a buffer of size %d with values: ", size); for(i=0;i<60;++i) fprintf(stderr, "%d ", buf_ptr[i]); fprintf(stderr, "\n"); } +#endif mem_desc.nfrag = 1; mem_desc.frag->addr = buf; mem_desc.frag->len = (iod_size_t)buf_size; - mem_desc.nfrag = 1; /* MSC TODO - populate file location hyperslab */ @@ -4508,7 +4512,7 @@ H5VL_iod_server_attr_open_cb(AXE_engine_t UNUSED axe_engine, /* get attribute ID */ if(iod_kv_get_value(attr_kv_oh, IOD_TID_UNKNOWN, attr_name, &attr_id, sizeof(iod_obj_id_t) , NULL, NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve Array ID from parent KV store"); + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve Attribute ID from parent KV store"); /* close parent group if it is not the location we started the traversal into */ @@ -4522,7 +4526,11 @@ H5VL_iod_server_attr_open_cb(AXE_engine_t UNUSED axe_engine, if (iod_obj_open_write(coh, attr_id, NULL /*hints*/, &cur_oh, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't open current group"); - /* open the metadata scratch pad */ + /* get scratch pad of the attribute */ + if(iod_obj_get_scratch(cur_oh, IOD_TID_UNKNOWN, &sp, NULL, NULL) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "can't get scratch pad for object"); + + /* open the metadata scratch pad of the attribute */ if (iod_obj_open_write(coh, sp.mdkv_id, NULL /*hints*/, &mdkv_oh, NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "can't open scratch pad"); @@ -4616,18 +4624,16 @@ H5VL_iod_server_attr_read_cb(AXE_engine_t UNUSED axe_engine, size_t size; void *buf; na_addr_t dest = HG_Handler_get_addr(op_data->hg_handle); + hbool_t opened_locally = FALSE; herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT - /* If the attribute handle and ID are not avaiable, traverse the path to obtain it */ - if(iod_id == IOD_ID_UNDEFINED) { - ;/* traverse routine */ - } /* open the attribute if we don't have the handle yet */ if(iod_oh.cookie == IOD_OH_UNDEFINED) { if (iod_obj_open_write(coh, iod_id, NULL /*hints*/, &iod_oh, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't open current group"); + opened_locally = TRUE; } size = HG_Bulk_handle_get_size(bulk_handle); @@ -4635,11 +4641,13 @@ H5VL_iod_server_attr_read_cb(AXE_engine_t UNUSED axe_engine, if(NULL == (buf = malloc(size))) HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate read buffer"); + /* create memory descriptor for reading */ mem_desc.nfrag = 1; - //mem_desc.frag[0].addr = buf; - //mem_desc.frag[0].len = (iod_size_t)size; + mem_desc.frag->addr = buf; + mem_desc.frag->len = (iod_size_t)size; - /* MSC TODO - populate file location hyperslab */ + /* retrieve the dataspace of the attribute and create file descriptor for reading */ + /* MSC TODO - populate file descriptor hyperslab */ /* read from array object */ if(iod_array_read(iod_oh, IOD_TID_UNKNOWN, NULL, &mem_desc, &file_desc, NULL, NULL) < 0) @@ -4669,7 +4677,9 @@ H5VL_iod_server_attr_read_cb(AXE_engine_t UNUSED axe_engine, HGOTO_ERROR(H5E_SYM, H5E_READERROR, FAIL, "can't read from array object"); done: +#if H5VL_IOD_DEBUG fprintf(stderr, "Done with attr read, sending response to client\n"); +#endif if(HG_SUCCESS != HG_Handler_start_output(op_data->hg_handle, &ret_value)) HDONE_ERROR(H5E_SYM, H5E_WRITEERROR, FAIL, "can't send result of write to client"); @@ -4680,6 +4690,12 @@ done: op_data = (op_data_t *)H5MM_xfree(op_data); free(buf); + /* close the attribute if we opened it in this routine */ + if(opened_locally) { + if(iod_obj_close(iod_oh, NULL, NULL)) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't close Array object"); + } + FUNC_LEAVE_NOAPI_VOID } /* end H5VL_iod_server_attr_read_cb() */ @@ -4718,16 +4734,11 @@ H5VL_iod_server_attr_write_cb(AXE_engine_t UNUSED axe_engine, void *buf; ssize_t ret; na_addr_t source = HG_Handler_get_addr(op_data->hg_handle); + hbool_t opened_locally = FALSE; herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT - fprintf(stderr, "Start attribute Write\n"); - - /* If the attribute handle and ID are not avaiable, traverse the path to obtain it */ - if(iod_id == IOD_ID_UNDEFINED) { - ;/* traverse routine */ - } /* open the attribute if we don't have the handle yet */ if(iod_oh.cookie == IOD_OH_UNDEFINED) { if (iod_obj_open_write(coh, iod_id, NULL /*hints*/, &iod_oh, NULL) < 0) @@ -4752,21 +4763,24 @@ H5VL_iod_server_attr_write_cb(AXE_engine_t UNUSED axe_engine, if(HG_SUCCESS != HG_Bulk_block_handle_free(bulk_block_handle)) HGOTO_ERROR(H5E_SYM, H5E_WRITEERROR, FAIL, "can't free bds block handle"); +#if H5VL_IOD_DEBUG { int i; int *buf_ptr = (int *)buf; - fprintf(stderr, "Received a buffer of size %d with values: ", size); + fprintf(stderr, "AWRITE Received a buffer of size %d with values: ", size); for(i=0;i<60;++i) fprintf(stderr, "%d ", buf_ptr[i]); fprintf(stderr, "\n"); } +#endif mem_desc.nfrag = 1; - //mem_desc.frag[0].addr = buf; - //mem_desc.frag[0].len = (iod_size_t)size; + mem_desc.frag->addr = buf; + mem_desc.frag->len = (iod_size_t)size; - /* MSC TODO - populate file location hyperslab */ + /* retrieve the dataspace of the attribute and create file descriptor for reading */ + /* MSC TODO - populate file descriptor hyperslab */ /* write from array object */ if(iod_array_write(iod_oh, IOD_TID_UNKNOWN, NULL, &mem_desc, &file_desc, NULL, NULL) < 0) @@ -4777,7 +4791,10 @@ H5VL_iod_server_attr_write_cb(AXE_engine_t UNUSED axe_engine, #endif done: +#if H5VL_IOD_DEBUG fprintf(stderr, "Done with attr write, sending %d response to client\n", ret_value); +#endif + if(HG_SUCCESS != HG_Handler_start_output(op_data->hg_handle, &ret_value)) HDONE_ERROR(H5E_SYM, H5E_WRITEERROR, FAIL, "can't send result of write to client"); @@ -4785,6 +4802,11 @@ done: op_data = (op_data_t *)H5MM_xfree(op_data); free(buf); + /* close the dataset if we opened it in this routine */ + if(opened_locally) { + if(iod_obj_close(iod_oh, NULL, NULL)) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't close Array object"); + } FUNC_LEAVE_NOAPI_VOID } /* end H5VL_iod_server_attr_write_cb() */ @@ -4813,17 +4835,20 @@ H5VL_iod_server_attr_exists_cb(AXE_engine_t UNUSED axe_engine, iod_handle_t coh = input->coh; iod_handle_t loc_handle = input->loc_oh; iod_obj_id_t loc_id = input->loc_id; - iod_handle_t cur_oh, mdkv_oh; - iod_obj_id_t cur_id, mdkv_id; + iod_handle_t cur_oh, attr_kv_oh; + iod_obj_id_t cur_id, attr_id; const char *loc_name = input->path; const char *attr_name = input->attr_name; char *last_comp = NULL; + scratch_pad_t sp; htri_t ret = -1; herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT +#if H5VL_IOD_DEBUG fprintf(stderr, "Start attribute Exists %s\n", attr_name); +#endif /* the traversal will retrieve the location where the attribute needs to be checked. The traversal will fail if an intermediate group @@ -4832,8 +4857,36 @@ H5VL_iod_server_attr_exists_cb(AXE_engine_t UNUSED axe_engine, &last_comp, &cur_id, &cur_oh) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't traverse path"); - /*MSC - check the attribute in the scratch pad KV store when it is - there */ + /* get scratch pad of the parent */ + if(iod_obj_get_scratch(cur_oh, IOD_TID_UNKNOWN, &sp, NULL, NULL) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "can't get scratch pad for object"); + + /* close parent group if it is not the location we started the + traversal into */ + if(loc_handle.cookie != cur_oh.cookie) { + iod_obj_close(cur_oh, NULL, NULL); + } + + /* if attribute KV does not exist, return false*/ + if(IOD_ID_UNDEFINED == sp.attr_id) { + ret = FALSE; + HGOTO_DONE(SUCCEED); + } + + /* open the attribute KV in scratch pad */ + if (iod_obj_open_write(coh, sp.attr_id, NULL /*hints*/, &attr_kv_oh, NULL) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "can't open scratch pad"); + + /* get attribute ID */ + if(iod_kv_get_value(attr_kv_oh, IOD_TID_UNKNOWN, attr_name, &attr_id, + sizeof(iod_obj_id_t) , NULL, NULL) < 0) { + ret = FALSE; + } + else { + ret = TRUE; + } + + iod_obj_close(attr_kv_oh, NULL, NULL); #if H5_DO_NATIVE ret = H5Aexists(loc_handle.cookie, attr_name); @@ -4842,7 +4895,11 @@ H5VL_iod_server_attr_exists_cb(AXE_engine_t UNUSED axe_engine, #endif done: + +#if H5VL_IOD_DEBUG fprintf(stderr, "Done with attr exists, sending response to client\n"); +#endif + HG_Handler_start_output(op_data->hg_handle, &ret); input = (attr_op_in_t *)H5MM_xfree(input); @@ -4877,17 +4934,22 @@ H5VL_iod_server_attr_rename_cb(AXE_engine_t UNUSED axe_engine, iod_handle_t coh = input->coh; iod_handle_t loc_handle = input->loc_oh; iod_obj_id_t loc_id = input->loc_id; - iod_handle_t cur_oh, mdkv_oh; - iod_obj_id_t cur_id, mdkv_id; + iod_handle_t cur_oh, attr_kv_oh; + iod_obj_id_t cur_id, attr_id; const char *loc_name = input->path; const char *old_name = input->old_attr_name; const char *new_name = input->new_attr_name; char *last_comp = NULL; + iod_kv_params_t kvs; + iod_kv_t kv; + scratch_pad_t sp; herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT +#if H5VL_IOD_DEBUG fprintf(stderr, "Start attribute Rename %s to %s\n", old_name, new_name); +#endif /* the traversal will retrieve the location where the attribute needs to be renamed. The traversal will fail if an intermediate @@ -4896,15 +4958,57 @@ H5VL_iod_server_attr_rename_cb(AXE_engine_t UNUSED axe_engine, &last_comp, &cur_id, &cur_oh) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't traverse path"); - /*MSC - Rename the attribute from the scratch pad KV store when it - is there */ + /* get scratch pad of the parent */ + if(iod_obj_get_scratch(cur_oh, IOD_TID_UNKNOWN, &sp, NULL, NULL) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "can't get scratch pad for object"); + + /* close parent group if it is not the location we started the + traversal into */ + if(loc_handle.cookie != cur_oh.cookie) { + iod_obj_close(cur_oh, NULL, NULL); + } + + /* if attribute KV does not exist, return error*/ + if(IOD_ID_UNDEFINED == sp.attr_id) + HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "Object has no attributes"); + + /* open the attribute KV in scratch pad */ + if (iod_obj_open_write(coh, sp.attr_id, NULL /*hints*/, &attr_kv_oh, NULL) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "can't open scratch pad"); + + /* get attribute ID */ + if(iod_kv_get_value(attr_kv_oh, IOD_TID_UNKNOWN, old_name, &attr_id, + sizeof(iod_obj_id_t) , NULL, NULL) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "Attribute does not exist"); + + /* remove attribute with old name */ + kv.key = old_name; + kv.value = &attr_id; + kv.value_len = sizeof(iod_obj_id_t); + kvs.kv = &kv; + if(iod_kv_unlink_keys(attr_kv_oh,IOD_TID_UNKNOWN, NULL, 1, &kvs, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "Unable to unlink KV pair"); + + /* insert attribute with new name */ + kv.key = strdup(new_name); + kv.value = &attr_id; + kv.value_len = sizeof(iod_obj_id_t); + if (iod_kv_set(attr_kv_oh, IOD_TID_UNKNOWN, NULL, &kv, NULL, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't set KV pair in parent"); + HDfree(kv.key); + + iod_obj_close(attr_kv_oh, NULL, NULL); #if H5_DO_NATIVE ret_value = H5Arename(loc_handle.cookie, old_name, new_name); #endif done: + +#if H5VL_IOD_DEBUG fprintf(stderr, "Done with attr rename, sending response to client\n"); +#endif + HG_Handler_start_output(op_data->hg_handle, &ret_value); input = (attr_rename_in_t *)H5MM_xfree(input); @@ -4939,16 +5043,21 @@ H5VL_iod_server_attr_remove_cb(AXE_engine_t UNUSED axe_engine, iod_handle_t coh = input->coh; iod_handle_t loc_handle = input->loc_oh; iod_obj_id_t loc_id = input->loc_id; - iod_handle_t cur_oh, mdkv_oh; - iod_obj_id_t cur_id, mdkv_id; + iod_handle_t cur_oh, attr_kv_oh; + iod_obj_id_t cur_id, attr_id; const char *loc_name = input->path; const char *attr_name = input->attr_name; char *last_comp = NULL; + iod_kv_params_t kvs; + iod_kv_t kv; + scratch_pad_t sp; herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT +#if H5VL_IOD_DEBUG fprintf(stderr, "Start attribute Remove %s\n", attr_name); +#endif /* the traversal will retrieve the location where the attribute needs to be removed. The traversal will fail if an intermediate @@ -4957,15 +5066,49 @@ H5VL_iod_server_attr_remove_cb(AXE_engine_t UNUSED axe_engine, &last_comp, &cur_id, &cur_oh) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't traverse path"); - /*MSC - Remove the attribute from the scratch pad KV store when it - is there */ + /* get scratch pad of the parent */ + if(iod_obj_get_scratch(cur_oh, IOD_TID_UNKNOWN, &sp, NULL, NULL) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "can't get scratch pad for object"); + + /* close parent group if it is not the location we started the + traversal into */ + if(loc_handle.cookie != cur_oh.cookie) { + iod_obj_close(cur_oh, NULL, NULL); + } + + /* if attribute KV does not exist, return error*/ + if(IOD_ID_UNDEFINED == sp.attr_id) + HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "Object has no attributes"); + + /* open the attribute KV in scratch pad */ + if (iod_obj_open_write(coh, sp.attr_id, NULL /*hints*/, &attr_kv_oh, NULL) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "can't open scratch pad"); + + /* get attribute ID */ + if(iod_kv_get_value(attr_kv_oh, IOD_TID_UNKNOWN, attr_name, &attr_id, + sizeof(iod_obj_id_t) , NULL, NULL) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "Attribute does not exist"); + + /* remove attribute */ + kv.key = attr_name; + kv.value = &attr_id; + kv.value_len = sizeof(iod_obj_id_t); + kvs.kv = &kv; + if(iod_kv_unlink_keys(attr_kv_oh,IOD_TID_UNKNOWN, NULL, 1, &kvs, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "Unable to unlink KV pair"); + + if(iod_obj_unlink(coh, attr_id, IOD_TID_UNKNOWN, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "Unable to unlink object"); #if H5_DO_NATIVE ret_value = H5Adelete(loc_handle.cookie, attr_name); #endif done: +#if H5VL_IOD_DEBUG fprintf(stderr, "Done with attr remove, sending response to client\n"); +#endif + HG_Handler_start_output(op_data->hg_handle, &ret_value); input = (attr_op_in_t *)H5MM_xfree(input); @@ -5003,7 +5146,9 @@ H5VL_iod_server_attr_close_cb(AXE_engine_t UNUSED axe_engine, FUNC_ENTER_NOAPI_NOINIT +#if H5VL_IOD_DEBUG fprintf(stderr, "Start attribute Close\n"); +#endif if(iod_oh.cookie != IOD_OH_UNDEFINED) { #if H5_DO_NATIVE @@ -5018,7 +5163,10 @@ H5VL_iod_server_attr_close_cb(AXE_engine_t UNUSED axe_engine, } done: +#if H5VL_IOD_DEBUG fprintf(stderr, "Done with attr close, sending response to client\n"); +#endif + HG_Handler_start_output(op_data->hg_handle, &ret_value); input = (attr_close_in_t *)H5MM_xfree(input); @@ -5053,27 +5201,29 @@ H5VL_iod_server_link_create_cb(AXE_engine_t UNUSED axe_engine, iod_handle_t coh = input->coh; /* the container handle */ iod_handle_t src_oh; /* The handle for creation src object */ iod_obj_id_t src_id; /* The ID of the creation src object */ - iod_handle_t cur_oh; + iod_handle_t cur_oh, target_oh; iod_obj_id_t cur_id; iod_obj_id_t target_id; /* The ID of the target object where link is created*/ - char *last_comp = NULL; + char *src_last_comp = NULL, *dst_last_comp = NULL; iod_kv_t kv; iod_size_t kv_size = sizeof(iod_obj_id_t); herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT +#if H5VL_IOD_DEBUG fprintf(stderr, "Start link create\n"); +#endif /* the traversal will retrieve the location where the link needs to be created from. The traversal will fail if an intermediate group does not exist. */ if(H5VL_iod_server_traverse(coh, input->loc_id, input->loc_oh, input->loc_name, FALSE, - &last_comp, &cur_id, &cur_oh) < 0) + &src_last_comp, &cur_id, &cur_oh) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't traverse path"); /* lookup group in the current location */ - if(iod_kv_get_value(cur_oh, IOD_TID_UNKNOWN, last_comp, &src_id, &kv_size, NULL, NULL) < 0) + if(iod_kv_get_value(cur_oh, IOD_TID_UNKNOWN, src_last_comp, &src_id, &kv_size, NULL, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "Intermdiate group does not exist"); /* close parent group if it is not the location we started the @@ -5091,12 +5241,13 @@ H5VL_iod_server_link_create_cb(AXE_engine_t UNUSED axe_engine, to. The traversal must not fail. */ if(H5VL_iod_server_traverse(coh, input->target_loc_id, input->target_loc_oh, input->target_name, FALSE, - &last_comp, &cur_id, &cur_oh) < 0) + &dst_last_comp, &cur_id, &cur_oh) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't traverse path"); /* lookup target object in the current location - the lookup must succeed since this is a hard link. */ - if(iod_kv_get_value(cur_oh, IOD_TID_UNKNOWN, last_comp, &target_id, &kv_size, NULL, NULL) < 0) + if(iod_kv_get_value(cur_oh, IOD_TID_UNKNOWN, dst_last_comp, &target_id, &kv_size, + NULL, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "Intermdiate group does not exist"); } else if(H5VL_LINK_CREATE_SOFT == create_type) { @@ -5104,15 +5255,17 @@ H5VL_iod_server_link_create_cb(AXE_engine_t UNUSED axe_engine, to. The traversal must not fail. */ if(H5VL_iod_server_traverse(coh, input->target_loc_id, input->target_loc_oh, input->target_name, FALSE, - &last_comp, &cur_id, &cur_oh) < 0) + &dst_last_comp, &cur_id, &cur_oh) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't traverse path"); /* lookup target object in the current location. The lookup might fail since this is a soft link */ - if(iod_kv_get_value(cur_oh, IOD_TID_UNKNOWN, last_comp, + if(iod_kv_get_value(cur_oh, IOD_TID_UNKNOWN, dst_last_comp, &target_id, &kv_size, NULL, NULL) < 0) { /* the lookup failed so just insert the target_id as undefined in the src object */ + /* MSC - Figure out what to do when reaccessing this + object after it was created */ target_id = IOD_ID_UNDEFINED; } } @@ -5126,7 +5279,7 @@ H5VL_iod_server_link_create_cb(AXE_engine_t UNUSED axe_engine, } /* insert new link (target group's ID) in kv store of the source object */ - kv.key = HDstrdup(last_comp); + kv.key = HDstrdup(src_last_comp); kv.value = &target_id; kv.value_len = kv_size; if (iod_kv_set(src_oh, IOD_TID_UNKNOWN, NULL, &kv, NULL, NULL) < 0) @@ -5138,6 +5291,15 @@ H5VL_iod_server_link_create_cb(AXE_engine_t UNUSED axe_engine, iod_obj_close(src_oh, NULL, NULL); } + /* open the target object */ + if (iod_obj_open_write(coh, target_id, NULL, &target_oh, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't open current group"); + + /* MSC - update metadata link information for this object */ + + /* close the target object */ + iod_obj_close(target_oh, NULL, NULL); + #if H5_DO_NATIVE if(H5VL_LINK_CREATE_HARD == create_type) { if(H5Lcreate_hard(input->target_loc_oh.cookie, input->target_name, @@ -5154,10 +5316,14 @@ H5VL_iod_server_link_create_cb(AXE_engine_t UNUSED axe_engine, #endif done: +#if H5VL_IOD_DEBUG fprintf(stderr, "Done with link create, sending response to client\n"); +#endif + HG_Handler_start_output(op_data->hg_handle, &ret_value); - last_comp = (char *)H5MM_xfree(last_comp); + src_last_comp = (char *)H5MM_xfree(src_last_comp); + dst_last_comp = (char *)H5MM_xfree(dst_last_comp); input = (link_create_in_t *)H5MM_xfree(input); op_data = (op_data_t *)H5MM_xfree(op_data); @@ -5200,7 +5366,9 @@ H5VL_iod_server_link_move_cb(AXE_engine_t UNUSED axe_engine, FUNC_ENTER_NOAPI_NOINIT +#if H5VL_IOD_DEBUG fprintf(stderr, "Start link move\n"); +#endif /* the traversal will retrieve the location where the link needs to be moved/copied from. The traversal will fail if an intermediate group @@ -5233,7 +5401,7 @@ H5VL_iod_server_link_move_cb(AXE_engine_t UNUSED axe_engine, kvs.kv = &kv; if(iod_kv_unlink_keys(src_oh,IOD_TID_UNKNOWN, NULL, 1, &kvs, NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "Unable to unlink KV pair");; + HGOTO_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "Unable to unlink KV pair"); } HDfree(kv.key); @@ -5266,7 +5434,10 @@ H5VL_iod_server_link_move_cb(AXE_engine_t UNUSED axe_engine, #endif done: +#if H5VL_IOD_DEBUG fprintf(stderr, "Done with link move, sending response to client\n"); +#endif + HG_Handler_start_output(op_data->hg_handle, &ret_value); last_comp = (char *)H5MM_xfree(last_comp); @@ -5311,7 +5482,9 @@ H5VL_iod_server_link_exists_cb(AXE_engine_t UNUSED axe_engine, FUNC_ENTER_NOAPI_NOINIT +#if H5VL_IOD_DEBUG fprintf(stderr, "Start link Exists\n"); +#endif /* the traversal will retrieve the location where the link needs to be checked */ @@ -5344,7 +5517,10 @@ done: iod_obj_close(loc_oh, NULL, NULL); } +#if H5VL_IOD_DEBUG fprintf(stderr, "Done with link exists, sending response to client\n"); +#endif + HG_Handler_start_output(op_data->hg_handle, &ret); input = (link_op_in_t *)H5MM_xfree(input); @@ -5390,7 +5566,9 @@ H5VL_iod_server_link_remove_cb(AXE_engine_t UNUSED axe_engine, FUNC_ENTER_NOAPI_NOINIT +#if H5VL_IOD_DEBUG fprintf(stderr, "Start link Remove\n"); +#endif /* the traversal will retrieve the location where the link needs to be removed. The traversal will fail if an intermediate group @@ -5412,6 +5590,9 @@ H5VL_iod_server_link_remove_cb(AXE_engine_t UNUSED axe_engine, HGOTO_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "Unable to unlink KV pair"); HDfree(kv.key); + /* MSC - check the metadata information for the object and remove + it from the container if this is the last link to it */ + /* close location object */ if(input->loc_oh.cookie != cur_oh.cookie) { iod_obj_close(cur_oh, NULL, NULL); @@ -5423,7 +5604,11 @@ H5VL_iod_server_link_remove_cb(AXE_engine_t UNUSED axe_engine, #endif done: + +#if H5VL_IOD_DEBUG fprintf(stderr, "Done with link remove, sending response to client\n"); +#endif + HG_Handler_start_output(op_data->hg_handle, &ret_value); last_comp = (char *)H5MM_xfree(last_comp); @@ -5459,16 +5644,19 @@ H5VL_iod_server_object_open_cb(AXE_engine_t UNUSED axe_engine, iod_handle_t coh = input->coh; /* the container handle */ iod_handle_t obj_oh; /* The handle for object */ iod_obj_id_t obj_id; /* The ID of the object */ - iod_handle_t cur_oh; + iod_handle_t cur_oh, mdkv_oh; iod_obj_id_t cur_id; char *last_comp = NULL; iod_kv_t kv; + scratch_pad_t sp; iod_size_t kv_size = sizeof(iod_obj_id_t); herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT +#if H5VL_IOD_DEBUG fprintf(stderr, "Start Object Open\n"); +#endif /* the traversal will retrieve the location where the object needs to be opened to be created from. The traversal will fail if an @@ -5491,10 +5679,20 @@ H5VL_iod_server_object_open_cb(AXE_engine_t UNUSED axe_engine, if (iod_obj_open_write(coh, obj_id, NULL, &obj_oh, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't open current group"); -#if 0 - /* When we have a real IOD, open the scratch pad and read the - object's metadata */ -#endif + /* get scratch pad of the dataset */ + if(iod_obj_get_scratch(cur_oh, IOD_TID_UNKNOWN, &sp, NULL, NULL) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "can't get scratch pad for object"); + + /* open the metadata scratch pad */ + if (iod_obj_open_write(coh, sp.mdkv_id, NULL /*hints*/, &mdkv_oh, NULL) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "can't open scratch pad"); + + /* MSC - Read object's metadata */ + + /* close the metadata scratch pad */ + if(iod_obj_close(mdkv_oh, NULL, NULL)) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't close object"); + #if H5_DO_NATIVE obj_oh.cookie = H5Oopen(input->loc_oh.cookie, input->loc_name, H5P_DEFAULT); @@ -5529,7 +5727,10 @@ H5VL_iod_server_object_open_cb(AXE_engine_t UNUSED axe_engine, output.iod_id = obj_id; output.iod_oh = obj_oh; +#if H5VL_IOD_DEBUG fprintf(stderr, "Done with object open, sending response to client\n"); +#endif + HG_Handler_start_output(op_data->hg_handle, &output); done: @@ -5597,7 +5798,9 @@ H5VL_iod_server_object_copy_cb(AXE_engine_t UNUSED axe_engine, FUNC_ENTER_NOAPI_NOINIT +#if H5VL_IOD_DEBUG fprintf(stderr, "Start object copy\n"); +#endif /* the traversal will retrieve the location where the object exists. The traversal will fail if an intermediate group does @@ -5648,7 +5851,10 @@ H5VL_iod_server_object_copy_cb(AXE_engine_t UNUSED axe_engine, #endif done: +#if H5VL_IOD_DEBUG fprintf(stderr, "Done with object Copy, sending response to client\n"); +#endif + HG_Handler_start_output(op_data->hg_handle, &ret_value); last_comp = (char *)H5MM_xfree(last_comp); @@ -5695,8 +5901,6 @@ H5VL_iod_server_object_exists_cb(AXE_engine_t UNUSED axe_engine, FUNC_ENTER_NOAPI_NOINIT - fprintf(stderr, "Start Object Exists\n"); - /* the traversal will retrieve the location where the object needs to be checked */ if(H5VL_iod_server_traverse(coh, loc_id, loc_oh, loc_name, FALSE, @@ -5738,7 +5942,10 @@ done: iod_obj_close(loc_oh, NULL, NULL); } +#if H5VL_IOD_DEBUG fprintf(stderr, "Done with Object exists, sending response to client\n"); +#endif + HG_Handler_start_output(op_data->hg_handle, &ret); input = (object_op_in_t *)H5MM_xfree(input); @@ -5773,20 +5980,19 @@ H5VL_iod_server_object_set_comment_cb(AXE_engine_t UNUSED axe_engine, iod_handle_t coh = input->coh; iod_handle_t loc_oh = input->loc_oh; iod_obj_id_t loc_id = input->loc_id; - iod_handle_t cur_oh; + iod_handle_t cur_oh, mdkv_oh; iod_obj_id_t cur_id, obj_id; const char *loc_name = input->path; const char *comment = input->comment; char *last_comp = NULL; iod_kv_params_t kvs; iod_kv_t kv; + scratch_pad_t sp; iod_size_t kv_size = sizeof(iod_obj_id_t); herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT - fprintf(stderr, "Start Object set comment: %s on %s\n", comment, loc_name); - /* the traversal will retrieve the location where the link needs to be removed. The traversal will fail if an intermediate group does not exist. */ @@ -5798,11 +6004,31 @@ H5VL_iod_server_object_set_comment_cb(AXE_engine_t UNUSED axe_engine, if(iod_kv_get_value(cur_oh, IOD_TID_UNKNOWN, last_comp, &obj_id, &kv_size, NULL, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "Object does not exist in source path"); - /* Open object */ - /* retrieve scratch pad */ - /* open scratch pad */ - /* update scratch pad with comment */ - /* close scratch pad and object */ + /* close parent group and its scratch pad if it is not the + location we started the traversal into */ + if(loc_oh.cookie != cur_oh.cookie) { + iod_obj_close(cur_oh, NULL, NULL); + } + + /* open the object */ + if (iod_obj_open_write(coh, obj_id, NULL /*hints*/, &cur_oh, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't open object"); + + /* get scratch pad of the object */ + if(iod_obj_get_scratch(cur_oh, IOD_TID_UNKNOWN, &sp, NULL, NULL) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "can't get scratch pad for object"); + + /* open the metadata scratch pad */ + if (iod_obj_open_write(coh, sp.mdkv_id, NULL /*hints*/, &mdkv_oh, NULL) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "can't open scratch pad"); + + /* MSC - update scratch pad with comment */ + + /* close metadata KV and object */ + if(iod_obj_close(mdkv_oh, NULL, NULL)) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't close object"); + if(iod_obj_close(cur_oh, NULL, NULL)) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't close object"); #if H5_DO_NATIVE if(H5Oset_comment(loc_oh.cookie, comment) < 0) @@ -5810,7 +6036,10 @@ H5VL_iod_server_object_set_comment_cb(AXE_engine_t UNUSED axe_engine, #endif done: +#if H5VL_IOD_DEBUG fprintf(stderr, "Done with set comment, sending response to client\n"); +#endif + HG_Handler_start_output(op_data->hg_handle, &ret_value); last_comp = (char *)H5MM_xfree(last_comp); @@ -5848,20 +6077,19 @@ H5VL_iod_server_object_get_comment_cb(AXE_engine_t UNUSED axe_engine, iod_handle_t loc_oh = input->loc_oh; iod_obj_id_t loc_id = input->loc_id; size_t length = input->length; - iod_handle_t cur_oh; + iod_handle_t cur_oh, mdkv_oh; iod_obj_id_t cur_id, obj_id; const char *loc_name = input->path; char *last_comp = NULL; iod_kv_params_t kvs; iod_kv_t kv; iod_size_t kv_size = sizeof(iod_obj_id_t); + scratch_pad_t sp; ssize_t size = 0; herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT - fprintf(stderr, "Start Object get comment on %s\n", loc_name); - /* the traversal will retrieve the location where the link needs to be removed. The traversal will fail if an intermediate group does not exist. */ @@ -5873,11 +6101,31 @@ H5VL_iod_server_object_get_comment_cb(AXE_engine_t UNUSED axe_engine, if(iod_kv_get_value(cur_oh, IOD_TID_UNKNOWN, last_comp, &obj_id, &kv_size, NULL, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "Object does not exist in source path"); - /* Open object */ - /* retrieve scratch pad */ - /* open scratch pad */ - /* get comment */ - /* close scratch pad and object */ + /* close parent group and its scratch pad if it is not the + location we started the traversal into */ + if(loc_oh.cookie != cur_oh.cookie) { + iod_obj_close(cur_oh, NULL, NULL); + } + + /* open the object */ + if (iod_obj_open_write(coh, obj_id, NULL /*hints*/, &cur_oh, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't open object"); + + /* get scratch pad of the object */ + if(iod_obj_get_scratch(cur_oh, IOD_TID_UNKNOWN, &sp, NULL, NULL) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "can't get scratch pad for object"); + + /* open the metadata scratch pad */ + if (iod_obj_open_write(coh, sp.mdkv_id, NULL /*hints*/, &mdkv_oh, NULL) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "can't open scratch pad"); + + /* MSC - Get comment from MD KV store*/ + + /* close metadata KV and object */ + if(iod_obj_close(mdkv_oh, NULL, NULL)) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't close object"); + if(iod_obj_close(cur_oh, NULL, NULL)) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't close object"); comment.value_size = (ssize_t *)malloc(sizeof(ssize_t)); comment.value = NULL; @@ -5905,7 +6153,10 @@ done: output.ret = ret_value; output.name = comment; +#if H5VL_IOD_DEBUG fprintf(stderr, "Done with get comment, sending response to client\n"); +#endif + HG_Handler_start_output(op_data->hg_handle, &output); if(comment.value) diff --git a/src/H5private.h b/src/H5private.h index 42ea519..2d9c51c 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -2346,6 +2346,7 @@ H5_DLL int H5A_term_interface(void); H5_DLL int H5AC_term_interface(void); H5_DLL int H5D_term_interface(void); H5_DLL int H5E_term_interface(void); +H5_DLL int H5EQ_term_interface(void); H5_DLL int H5F_term_interface(void); H5_DLL int H5FS_term_interface(void); H5_DLL int H5G_term_interface(void); |