diff options
author | Mohamad Chaarawi <chaarawi@hdfgroup.org> | 2013-07-16 16:02:22 (GMT) |
---|---|---|
committer | Mohamad Chaarawi <chaarawi@hdfgroup.org> | 2013-07-16 16:02:22 (GMT) |
commit | 8ed1df3f85e60d6cdf2531700be90a8fdaceb1d5 (patch) | |
tree | 9e28d7c2aa1df5517c6098aa96c1d3cdd01949b1 /src | |
parent | 0cba93e0a48754e5cd769178af0cf325fa670878 (diff) | |
download | hdf5-8ed1df3f85e60d6cdf2531700be90a8fdaceb1d5.zip hdf5-8ed1df3f85e60d6cdf2531700be90a8fdaceb1d5.tar.gz hdf5-8ed1df3f85e60d6cdf2531700be90a8fdaceb1d5.tar.bz2 |
[svn-r23906] - update VOL metadata written on creates and read on opens.
- rename examples
- fix some minor things
Diffstat (limited to 'src')
-rw-r--r-- | src/H5M.c | 1 | ||||
-rw-r--r-- | src/H5VLiod_attr.c | 51 | ||||
-rw-r--r-- | src/H5VLiod_common.h | 1 | ||||
-rw-r--r-- | src/H5VLiod_dset.c | 207 | ||||
-rw-r--r-- | src/H5VLiod_dtype.c | 132 | ||||
-rw-r--r-- | src/H5VLiod_file.c | 89 | ||||
-rw-r--r-- | src/H5VLiod_group.c | 81 | ||||
-rw-r--r-- | src/H5VLiod_map.c | 25 | ||||
-rw-r--r-- | src/H5VLiod_obj.c | 2 | ||||
-rw-r--r-- | src/H5VLiod_server.c | 4 | ||||
-rw-r--r-- | src/H5VLiod_server.h | 6 |
11 files changed, 431 insertions, 168 deletions
@@ -830,6 +830,7 @@ H5Mclose_ff(hid_t map_id, hid_t eq_id) herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) + H5TRACE2("e", "ii", map_id, eq_id); /* Check args */ if(NULL == H5I_object_verify(map_id, H5I_MAP)) diff --git a/src/H5VLiod_attr.c b/src/H5VLiod_attr.c index 44229df..5a9e047 100644 --- a/src/H5VLiod_attr.c +++ b/src/H5VLiod_attr.c @@ -125,11 +125,10 @@ H5VL_iod_server_attr_create_cb(AXE_engine_t UNUSED axe_engine, if (iod_obj_open_write(coh, mdkv_id, NULL, &mdkv_oh, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create scratch pad"); - /* MSC - TODO store things */ - -#if 0 - /* insert attribute metadata into scratch pad */ - kv.key = HDstrdup("attribute_dtype"); + /* MSC - need to check size of datatype if it fits in + entry otherwise create a BLOB*/ + /* insert datatype metadata into scratch pad */ + kv.key = strdup("dtype"); /* determine the buffer size needed to store the encoded type of the attribute */ if(H5Tencode(input->type_id, NULL, &buf_size) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTENCODE, FAIL, "failed to encode attribute type"); @@ -142,10 +141,11 @@ H5VL_iod_server_attr_create_cb(AXE_engine_t UNUSED axe_engine, /* insert kv pair into scratch pad */ if (iod_kv_set(mdkv_oh, IOD_TID_UNKNOWN, NULL, &kv, NULL, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't set KV pair in parent"); - HDfree(kv.key); + free(kv.key); free(kv.value); - kv.key = HDstrdup("attribute_dspace"); + /* insert dataspace metadata into scratch pad */ + kv.key = strdup("dspace"); /* determine the buffer size needed to store the encoded space of the attribute */ if(H5Sencode(input->space_id, NULL, &buf_size) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTENCODE, FAIL, "failed to encode attribute space"); @@ -158,9 +158,8 @@ H5VL_iod_server_attr_create_cb(AXE_engine_t UNUSED axe_engine, /* insert kv pair into scratch pad */ if (iod_kv_set(mdkv_oh, IOD_TID_UNKNOWN, NULL, &kv, NULL, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't set KV pair in parent"); - HDfree(kv.key); + free(kv.key); free(kv.value); -#endif /* close the Metadata KV object */ if(iod_obj_close(mdkv_oh, NULL, NULL)) @@ -310,7 +309,37 @@ H5VL_iod_server_attr_open_cb(AXE_engine_t UNUSED axe_engine, if (iod_obj_open_write(coh, sp.mdkv_id, NULL /*hints*/, &mdkv_oh, NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "can't open scratch pad"); - /* MSC - retrieve all metadata from scratch pad */ +#if 0 + kv_size = 0; + /* read the attributes's datatype */ + if(iod_kv_get_value(mdkv_oh, IOD_TID_UNKNOWN, "dtype", NULL, + &kv_size, NULL, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "dtype lookup failed"); + if(NULL == (buf = H5MM_malloc (kv_size))) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate dtype buffer"); + if(iod_kv_get_value(mdkv_oh, IOD_TID_UNKNOWN, "dtype", buf, + &kv_size, NULL, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "attribute dtype lookup failed"); + if((output.type_id = H5Tdecode(buf)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTDECODE, FAIL, "failed to decode datatype"); + free(buf); + buf = NULL; + + kv_size = 0; + /* read the attributes's dataspace */ + if(iod_kv_get_value(mdkv_oh, IOD_TID_UNKNOWN, "dspace", NULL, + &kv_size, NULL, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "dspace lookup failed"); + if(NULL == (buf = H5MM_malloc (kv_size))) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate dspace buffer"); + if(iod_kv_get_value(mdkv_oh, IOD_TID_UNKNOWN, "dspace", buf, + &kv_size, NULL, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "attribute dspace lookup failed"); + if((output.space_id = H5Tdecode(buf)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTDECODE, FAIL, "failed to decode dataspace"); + free(buf); + buf = NULL; +#endif /* close the metadata scratch pad */ if(iod_obj_close(mdkv_oh, NULL, NULL)) @@ -582,7 +611,7 @@ done: op_data = (op_data_t *)H5MM_xfree(op_data); free(buf); - /* close the dataset if we opened it in this routine */ + /* 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"); diff --git a/src/H5VLiod_common.h b/src/H5VLiod_common.h index 41adb68..cfea8ac 100644 --- a/src/H5VLiod_common.h +++ b/src/H5VLiod_common.h @@ -76,6 +76,7 @@ H5_DLL int hg_proc_iod_handle_t(hg_proc_t proc, void *data); H5_DLL int hg_proc_dims_t(hg_proc_t proc, void *data); H5_DLL int hg_proc_axe_ids_t(hg_proc_t proc, void *data); H5_DLL int hg_proc_name_t(hg_proc_t proc, void *data); +H5_DLL int hg_proc_value_t(hg_proc_t proc, void *data); H5_DLL int hg_proc_binary_buf_t(hg_proc_t proc, void *data); MERCURY_GEN_PROC(eff_init_in_t, ((uint32_t)(proc_num))) diff --git a/src/H5VLiod_dset.c b/src/H5VLiod_dset.c index d2b31d0..40d7fe3 100644 --- a/src/H5VLiod_dset.c +++ b/src/H5VLiod_dset.c @@ -139,69 +139,93 @@ H5VL_iod_server_dset_create_cb(AXE_engine_t UNUSED axe_engine, if (iod_obj_open_write(coh, mdkv_id, NULL, &mdkv_oh, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create scratch pad"); - /* MSC - TODO store things */ -#if 0 - /* insert layout metadata into scratch pad */ - kv.key = HDstrdup("dataset_dcpl"); - /* determine the buffer size needed to store the encoded dcpl of the dataset */ - if(H5Pencode(input->dcpl_id, NULL, &buf_size) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTENCODE, FAIL, "failed to encode dataset dcpl"); - if(NULL == (kv.value = malloc (buf_size))) - HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate dcpl buffer"); - /* encode dcpl of the dataset */ - if(H5Pencode(input->dcpl_id, kv.value, &buf_size) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTENCODE, FAIL, "failed to encode dataset dcpl"); - kv.value_len = (iod_size_t)buf_size; - /* insert kv pair into scratch pad */ - if (iod_kv_set(mdkv_oh, IOD_TID_UNKNOWN, NULL, &kv, NULL, NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't set KV pair in parent"); - HDfree(kv.key); - free(kv.value); - - /* insert datatyoe metadata into scratch pad */ - kv.key = HDstrdup("dataset_dtype"); - /* determine the buffer size needed to store the encoded type of the dataset */ - if(H5Tencode(input->type_id, NULL, &buf_size) < 0) + { + size_t buf_size; + hid_t dcpl_id; + uint64_t count; + + if(H5P_DEFAULT == input->dcpl_id) + dcpl_id = H5P_DATASET_CREATE_DEFAULT; + else + dcpl_id = input->dcpl_id; + + /* insert dataset creation properties in Metadata KV */ + kv.key = strdup("dcpl"); + /* determine the buffer size needed to store the encoded dcpl of the dataset */ + if(H5Pencode(dcpl_id, NULL, &buf_size) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTENCODE, FAIL, "failed to encode dataset dcpl"); + if(NULL == (kv.value = malloc (buf_size))) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate dcpl buffer"); + /* encode dcpl of the dataset */ + if(H5Pencode(dcpl_id, kv.value, &buf_size) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTENCODE, FAIL, "failed to encode dataset dcpl"); + kv.value_len = (iod_size_t)buf_size; + /* insert kv pair into scratch pad */ + if (iod_kv_set(mdkv_oh, IOD_TID_UNKNOWN, NULL, &kv, NULL, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't set KV pair in parent"); + free(kv.key); + free(kv.value); + + /* MSC - need to check size of datatype if it fits in + entry otherwise create a BLOB*/ + /* insert datatype metadata into scratch pad */ + kv.key = strdup("dtype"); + /* determine the buffer size needed to store the encoded type of the dataset */ + if(H5Tencode(input->type_id, NULL, &buf_size) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTENCODE, FAIL, "failed to encode dataset type"); + if(NULL == (kv.value = malloc (buf_size))) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate type buffer"); + /* encode datatype of the dataset */ + if(H5Tencode(input->type_id, kv.value, &buf_size) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTENCODE, FAIL, "failed to encode dataset type"); - if(NULL == (kv.value = malloc (buf_size))) - HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate type buffer"); - /* encode datatype of the dataset */ - if(H5Tencode(input->type_id, kv.value, &buf_size) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTENCODE, FAIL, "failed to encode dataset type"); - kv.value_len = (iod_size_t)buf_size; - /* insert kv pair into scratch pad */ - if (iod_kv_set(mdkv_oh, IOD_TID_UNKNOWN, NULL, &kv, NULL, NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't set KV pair in parent"); - HDfree(kv.key); - free(kv.value); - - kv.key = HDstrdup("dataset_dspace"); - /* determine the buffer size needed to store the encoded space of the dataset */ - if(H5Sencode(input->space_id, NULL, &buf_size) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTENCODE, FAIL, "failed to encode dataset space"); - if(NULL == (kv.value = malloc (buf_size))) - HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate space buffer"); - /* encode dataspace of the dataset */ - if(H5Sencode(input->space_id, kv.value, &buf_size) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTENCODE, FAIL, "failed to encode dataset space"); - kv.value_len = (iod_size_t)buf_size; - /* insert kv pair into scratch pad */ - if (iod_kv_set(mdkv_oh, IOD_TID_UNKNOWN, NULL, &kv, NULL, NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't set KV pair in parent"); - HDfree(kv.key); - free(kv.value); -#endif + kv.value_len = (iod_size_t)buf_size; + /* insert kv pair into scratch pad */ + if (iod_kv_set(mdkv_oh, IOD_TID_UNKNOWN, NULL, &kv, NULL, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't set KV pair in parent"); + free(kv.key); + free(kv.value); + + /* insert dataspace metadata into scratch pad */ + kv.key = strdup("dspace"); + /* determine the buffer size needed to store the encoded space of the dataset */ + if(H5Sencode(input->space_id, NULL, &buf_size) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTENCODE, FAIL, "failed to encode dataset space"); + if(NULL == (kv.value = malloc (buf_size))) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate space buffer"); + /* encode dataspace of the dataset */ + if(H5Sencode(input->space_id, kv.value, &buf_size) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTENCODE, FAIL, "failed to encode dataset space"); + kv.value_len = (iod_size_t)buf_size; + /* insert kv pair into scratch pad */ + if (iod_kv_set(mdkv_oh, IOD_TID_UNKNOWN, NULL, &kv, NULL, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't set KV pair in parent"); + free(kv.key); + free(kv.value); + + /* insert link count metadata on object */ + if(NULL == (kv.value = malloc (sizeof(uint64_t)))) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate buffer"); + /* initial count is 1, since object is created now */ + count = 1; + memcpy(kv.value, &count, sizeof(uint64_t)); + kv.key = strdup("link_count"); + if (iod_kv_set(mdkv_oh, IOD_TID_UNKNOWN, NULL, &kv, NULL, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't set KV pair in parent"); + free(kv.key); + free(kv.value); + } + /* close the Metadata KV object */ if(iod_obj_close(mdkv_oh, NULL, NULL)) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't close object"); - kv.key = HDstrdup(last_comp); + kv.key = strdup(last_comp); kv.value = &dset_id; kv.value_len = sizeof(iod_obj_id_t); /* insert new dataset in kv store of current group */ if (iod_kv_set(cur_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); + free(kv.key); } /* close parent group if it is not the location we started the @@ -214,7 +238,7 @@ H5VL_iod_server_dset_create_cb(AXE_engine_t UNUSED axe_engine, cur_oh.cookie = H5Dcreate2(loc_handle.cookie, last_comp, input->type_id, input->space_id, input->lcpl_id, input->dcpl_id, input->dapl_id); - HDassert(cur_oh.cookie); + assert(cur_oh.cookie); #endif output.iod_oh = cur_oh; @@ -272,8 +296,9 @@ H5VL_iod_server_dset_open_cb(AXE_engine_t UNUSED axe_engine, iod_obj_id_t dset_id; char *name = input->name; char *last_comp; + void *buf = NULL; scratch_pad_t sp; - iod_size_t kv_size = sizeof(iod_obj_id_t); + iod_size_t kv_size; herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT @@ -289,6 +314,8 @@ H5VL_iod_server_dset_open_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"); + kv_size = sizeof(iod_obj_id_t); + if(iod_kv_get_value(cur_oh, IOD_TID_UNKNOWN, last_comp, &dset_id, kv_size , NULL, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve Array ID from parent KV store"); @@ -311,34 +338,58 @@ H5VL_iod_server_dset_open_cb(AXE_engine_t UNUSED axe_engine, if (iod_obj_open_write(coh, sp.mdkv_id, NULL /*hints*/, &mdkv_oh, NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "can't open scratch pad"); + /* MSC - retrieve metadata */ #if 0 - /* MSC - retrieve all metadata from scratch pad */ - if(iod_kv_get_value(mdkv_oh, IOD_TID_UNKNOWN, "dataset_dcpl", NULL, - &output.dcpl_size, NULL, NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "dataset dcpl lookup failed"); - if(NULL == (output.dcpl = H5MM_malloc (output.dcpl_size))) + kv_size = 0; + /* read the datasets's creation properties */ + if(iod_kv_get_value(mdkv_oh, IOD_TID_UNKNOWN, "dcpl", NULL, + &kv_size, NULL, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "dcpl lookup failed"); + if(NULL == (buf = malloc (kv_size))) HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate dcpl buffer"); - if(iod_kv_get_value(mdkv_oh, IOD_TID_UNKNOWN, "dataset_dcpl", output.dcpl, - &output.dcpl_size, NULL, NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "dataset dcpl lookup failed"); - - if(iod_kv_get_value(mdkv_oh, IOD_TID_UNKNOWN, "dataset_dtype", NULL, - &output.dtype_size, NULL, NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "dataset dtype lookup failed"); - if(NULL == (output.dtype = H5MM_malloc (output.dtype_size))) + if(iod_kv_get_value(mdkv_oh, IOD_TID_UNKNOWN, "dcpl", buf, + &kv_size, NULL, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "dcpl lookup failed"); + if((output.dcpl_id = H5Pdecode(buf)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTDECODE, FAIL, "failed to decode dcpl"); + free(buf); + buf = NULL; + + kv_size = 0; + /* read the datasets's datatype */ + if(iod_kv_get_value(mdkv_oh, IOD_TID_UNKNOWN, "dtype", NULL, + &kv_size, NULL, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "dtype lookup failed"); + if(NULL == (buf = H5MM_malloc (kv_size))) HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate dtype buffer"); - if(iod_kv_get_value(mdkv_oh, IOD_TID_UNKNOWN, "dataset_dtype", output.dtype, - &output.dtype_size, NULL, NULL) < 0) + if(iod_kv_get_value(mdkv_oh, IOD_TID_UNKNOWN, "dtype", buf, + &kv_size, NULL, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "dataset dtype lookup failed"); - - if(iod_kv_get_value(mdkv_oh, IOD_TID_UNKNOWN, "dataset_dspace", NULL, - &output.dspace_size, NULL, NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "dataset dspace lookup failed"); - if(NULL == (output.dspace = H5MM_malloc (output.dspace_size))) + if((output.type_id = H5Tdecode(buf)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTDECODE, FAIL, "failed to decode datatype"); + free(buf); + buf = NULL; + + kv_size = 0; + /* read the datasets's dataspace */ + if(iod_kv_get_value(mdkv_oh, IOD_TID_UNKNOWN, "dspace", NULL, + &kv_size, NULL, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "dspace lookup failed"); + if(NULL == (buf = H5MM_malloc (kv_size))) HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate dspace buffer"); - if(iod_kv_get_value(mdkv_oh, IOD_TID_UNKNOWN, "dataset_dspace", output.dspace, - &output.dspace_size, NULL, NULL) < 0) + if(iod_kv_get_value(mdkv_oh, IOD_TID_UNKNOWN, "dspace", buf, + &kv_size, NULL, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "dataset dspace lookup failed"); + if((output.space_id = H5Tdecode(buf)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTDECODE, FAIL, "failed to decode dataspace"); + free(buf); + buf = NULL; + + kv_size = sizeof(uint64_t); + /* read the dataset's link count */ + if(iod_kv_get_value(mdkv_oh, IOD_TID_UNKNOWN, "link_count", output.link_count, + &kv_size, NULL, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "link_count lookup failed"); #endif /* close the metadata scratch pad */ @@ -484,7 +535,7 @@ H5VL_iod_server_dset_read_cb(AXE_engine_t UNUSED axe_engine, if(src_size > dst_size) { buf_size = src_size * nelmts; #if H5VL_IOD_DEBUG - fprintf(stderr, "Adjusted Buffer size because of datatype conversion from %d to %d: ", + fprintf(stderr, "Adjusted Buffer size because of datatype conversion from %d to %d: \n", size, buf_size); #endif } diff --git a/src/H5VLiod_dtype.c b/src/H5VLiod_dtype.c index d5e39a8..6bc17c1 100644 --- a/src/H5VLiod_dtype.c +++ b/src/H5VLiod_dtype.c @@ -142,50 +142,67 @@ H5VL_iod_server_dtype_commit_cb(AXE_engine_t UNUSED axe_engine, if(iod_blob_write(dtype_oh, IOD_TID_UNKNOWN, NULL, &mem_desc, &file_desc, NULL, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to write BLOB object"); - /* MSC - TODO store things */ -#if 0 - /* insert datatype metadata into scratch pad */ - - kv.key = HDstrdup("datatype_tcpl"); - /* determine the buffer size needed to store the encoded tcpl of the datatype */ - if(H5Pencode(input->tcpl_id, NULL, &value_size) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTENCODE, FAIL, "failed to encode datatype tcpl"); - if(NULL == (kv.value = malloc (value_size))) - HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate tcpl buffer"); - /* encode tcpl of the datatype */ - if(H5Pencode(input->tcpl_id, kv.value, &value_size) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTENCODE, FAIL, "failed to encode datatype tcpl"); - kv.value_len = (iod_size_t)value_size; - /* insert kv pair into scratch pad */ - if (iod_kv_set(mdkv_oh, IOD_TID_UNKNOWN, NULL, &kv, NULL, NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't set KV pair in parent"); - HDfree(kv.key); - free(kv.value); - - kv.key = HDstrdup("datatype_size"); - kv.value_len = sizeof(iod_size_t); - if(NULL == (kv.value = malloc (kv.value_len))) - HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate buffer"); - memcpy(kv.value, &buf_size, kv.value_len); - - /* insert kv pair into scratch pad */ - if (iod_kv_set(mdkv_oh, IOD_TID_UNKNOWN, NULL, &kv, NULL, NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't set KV pair in parent"); - HDfree(kv.key); - free(kv.value); -#endif + { + size_t tcpl_size = 0; + hid_t tcpl_id; + uint64_t count; + + if(H5P_DEFAULT == input->tcpl_id) + tcpl_id = H5P_DATATYPE_CREATE_DEFAULT; + else + tcpl_id = input->tcpl_id; + + /* insert datatype creation properties in Metadata KV */ + kv.key = strdup("tcpl"); + /* determine the buffer size needed to store the encoded tcpl of the datatype */ + if(H5Pencode(tcpl_id, NULL, &tcpl_size) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTENCODE, FAIL, "failed to encode tcpl"); + if(NULL == (kv.value = malloc (tcpl_size))) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate tcpl buffer"); + /* encode tcpl of the datatype */ + if(H5Pencode(tcpl_id, kv.value, &tcpl_size) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTENCODE, FAIL, "failed to encode tcpl"); + kv.value_len = (iod_size_t)tcpl_size; + /* insert kv pair into scratch pad */ + if (iod_kv_set(mdkv_oh, IOD_TID_UNKNOWN, NULL, &kv, NULL, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't set KV pair in parent"); + free(kv.key); + free(kv.value); + + /* insert link count metadata on object */ + if(NULL == (kv.value = malloc (sizeof(uint64_t)))) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate buffer"); + /* initial count is 1, since object is created now */ + count = 1; + memcpy(kv.value, &count, sizeof(uint64_t)); + kv.key = strdup("link_count"); + if (iod_kv_set(mdkv_oh, IOD_TID_UNKNOWN, NULL, &kv, NULL, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't set KV pair in parent"); + free(kv.key); + free(kv.value); + + kv.key = strdup("size"); + kv.value_len = sizeof(iod_size_t); + if(NULL == (kv.value = malloc (kv.value_len))) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate buffer"); + memcpy(kv.value, &buf_size, kv.value_len); + if (iod_kv_set(mdkv_oh, IOD_TID_UNKNOWN, NULL, &kv, NULL, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't set KV pair in parent"); + free(kv.key); + free(kv.value); + } /* close the Metadata KV object */ if(iod_obj_close(mdkv_oh, NULL, NULL)) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't close object"); - kv.key = HDstrdup(last_comp); + kv.key = strdup(last_comp); kv.value = &dtype_id; kv.value_len = sizeof(iod_obj_id_t); /* insert new datatype in kv store of current group */ if (iod_kv_set(cur_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); + free(kv.key); } #if H5_DO_NATIVE cur_oh.cookie = H5Tcopy(input->type_id); @@ -256,7 +273,7 @@ H5VL_iod_server_dtype_open_cb(AXE_engine_t UNUSED axe_engine, const char *name = input->name; char *last_comp; /* the name of the datatype obtained from the last component in the path */ size_t buf_size; - void *buf; + void *buf = NULL, *tcpl = NULL; iod_mem_desc_t mem_desc; iod_blob_iodesc_t file_desc; iod_size_t kv_size = sizeof(iod_obj_id_t); @@ -294,25 +311,42 @@ H5VL_iod_server_dtype_open_cb(AXE_engine_t UNUSED axe_engine, but since no real IOD, can't do anything now */ #if 0 - /*retrieve tcpl metadata from scratch pad */ - if(iod_kv_get_value(mdkv_oh, IOD_TID_UNKNOWN, "datatype_tcpl", NULL, - &output.tcpl_size, NULL, NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "datatype tcpl lookup failed"); - if(NULL == (output.tcpl = H5MM_malloc (output.tcpl_size))) + kv_size = 0; + /* read the datatypes's creation properties */ + if(iod_kv_get_value(mdkv_oh, IOD_TID_UNKNOWN, "tcpl", NULL, + &kv_size, NULL, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "tcpl lookup failed"); + if(NULL == (tcpl = malloc (kv_size))) HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate tcpl buffer"); - if(iod_kv_get_value(mdkv_oh, IOD_TID_UNKNOWN, "datatype_tcpl", output.tcpl, - &output.tcpl_size, NULL, NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "datatype tcpl lookup failed"); + if(iod_kv_get_value(mdkv_oh, IOD_TID_UNKNOWN, "tcpl", tcpl, + &kv_size, NULL, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "tcpl lookup failed"); + if((output.tcpl_id = H5Pdecode(tcpl)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTDECODE, FAIL, "failed to decode tcpl"); + free(tcpl); + tcpl = NULL; + + kv_size = sizeof(uint64_t); + /* read the datatype's link count */ + if(iod_kv_get_value(mdkv_oh, IOD_TID_UNKNOWN, "link_count", output.link_count, + &kv_size, NULL, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "link_count lookup failed"); /*retrieve blob size metadata from scratch pad */ - if(iod_kv_get_value(mdkv_oh, IOD_TID_UNKNOWN, "datatype_size", &buf_size, + if(iod_kv_get_value(mdkv_oh, IOD_TID_UNKNOWN, "size", &buf_size, sizeof(iod_size_t), NULL, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "datatype size lookup failed"); if(NULL == (buf = malloc(buf_size))) HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate BLOB read buffer"); +#endif - /* create memory descriptor for writing */ + /* 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 0 + /* create memory descriptor for reading */ mem_desc.nfrag = 1; mem_desc.frag->addr = buf; mem_desc.frag->len = (iod_size_t)buf_size; @@ -322,8 +356,8 @@ H5VL_iod_server_dtype_open_cb(AXE_engine_t UNUSED axe_engine, file_desc.frag->offset = 0; file_desc.frag->len = (iod_size_t)buf_size; - /* write the serialized type value to the BLOB object */ - if(iod_blob_write(cur_oh, IOD_TID_UNKNOWN, NULL, &mem_desc, &file_desc, NULL, NULL) < 0) + /* read the serialized type value from the BLOB object */ + if(iod_blob_read(cur_oh, IOD_TID_UNKNOWN, NULL, &mem_desc, &file_desc, NULL, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to write BLOB object"); /* decode the datatype */ @@ -333,10 +367,6 @@ H5VL_iod_server_dtype_open_cb(AXE_engine_t UNUSED axe_engine, free(buf); #endif - /* 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 printf("datatype name %s location %d\n", name, loc_handle.cookie); cur_oh.cookie = H5Topen(loc_handle.cookie, name, input->tapl_id); diff --git a/src/H5VLiod_file.c b/src/H5VLiod_file.c index 15db6aa..94fb4b7 100644 --- a/src/H5VLiod_file.c +++ b/src/H5VLiod_file.c @@ -112,7 +112,58 @@ H5VL_iod_server_file_create_cb(AXE_engine_t UNUSED axe_engine, if (iod_obj_open_write(coh, mdkv_id, NULL, &mdkv_oh, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create scratch pad"); - /* MSC - TODO store things */ + /* store metadata */ + { + iod_kv_t kv; + size_t buf_size; + hid_t fcpl_id; + uint64_t index; + + if(H5P_DEFAULT == input->fcpl_id) + fcpl_id = H5P_FILE_CREATE_DEFAULT; + else + fcpl_id = input->fcpl_id; + + /* insert file creation properties in Metadata KV */ + kv.key = strdup("fcpl"); + /* determine the buffer size needed to store the encoded fcpl of the file */ + if(H5Pencode(fcpl_id, NULL, &buf_size) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTENCODE, FAIL, "failed to encode file fcpl"); + if(NULL == (kv.value = malloc (buf_size))) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate fcpl buffer"); + /* encode fcpl of the file */ + if(H5Pencode(fcpl_id, kv.value, &buf_size) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTENCODE, FAIL, "failed to encode file fcpl"); + kv.value_len = (iod_size_t)buf_size; + /* insert kv pair into scratch pad */ + if (iod_kv_set(mdkv_oh, IOD_TID_UNKNOWN, NULL, &kv, NULL, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't set KV pair in parent"); + free(kv.key); + free(kv.value); + + /* insert initial indexes for IOD IDs */ + if(NULL == (kv.value = malloc (sizeof(uint64_t)))) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate fcpl buffer"); + index = 1; + memcpy(kv.value, &index, sizeof(uint64_t)); + + kv.key = strdup("kv_index"); + if (iod_kv_set(mdkv_oh, IOD_TID_UNKNOWN, NULL, &kv, NULL, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't set KV pair in parent"); + free(kv.key); + + kv.key = strdup("array_index"); + if (iod_kv_set(mdkv_oh, IOD_TID_UNKNOWN, NULL, &kv, NULL, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't set KV pair in parent"); + free(kv.key); + + kv.key = strdup("blob_index"); + if (iod_kv_set(mdkv_oh, IOD_TID_UNKNOWN, NULL, &kv, NULL, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't set KV pair in parent"); + free(kv.key); + + free(kv.value); + } if(iod_obj_close(mdkv_oh, NULL, NULL)) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't close root object handle"); @@ -204,12 +255,44 @@ H5VL_iod_server_file_open_cb(AXE_engine_t UNUSED axe_engine, if (iod_obj_open_write(coh, sp.mdkv_id, NULL /*hints*/, &mdkv_oh, NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "can't open scratch pad"); - /* MSC - retrieve metadata */ + /* retrieve all metadata from scratch pad */ + /* MSC - fake for now */ output.kv_oid_index = 1; output.array_oid_index = 1; output.blob_oid_index = 1; output.fcpl_id = H5P_FILE_CREATE_DEFAULT; +#if 0 + { + void *fcpl_buf = NULL; + size_t fcpl_size = 0; + + if(iod_kv_get_value(mdkv_oh, IOD_TID_UNKNOWN, "fcpl", NULL, + &fcpl_size, NULL, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "file fcpl lookup failed"); + if(NULL == (fcpl_buf = H5MM_malloc (output.fcpl_size))) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate fcpl buffer"); + if(iod_kv_get_value(mdkv_oh, IOD_TID_UNKNOWN, "file_fcpl", fcpl_buf, + &fcpl_size, NULL, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "file fcpl lookup failed"); + if((output.fcpl_id = H5Pdecode(fcpl_buf)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTDECODE, FAIL, "failed to decode file fcpl"); + free(fcpl_buf); + + if(iod_kv_get_value(mdkv_oh, IOD_TID_UNKNOWN, "kv_index", &output.kv_oid_index, + sizeof(uint64_t), NULL, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "KV index lookup failed"); + + if(iod_kv_get_value(mdkv_oh, IOD_TID_UNKNOWN, "array_index", &output.array_oid_index, + sizeof(uint64_t), NULL, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "Array index lookup failed"); + + if(iod_kv_get_value(mdkv_oh, IOD_TID_UNKNOWN, "blob_index", &output.blob_oid_index, + sizeof(uint64_t), NULL, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "BLOB index lookup failed"); + } +#endif + /* close the metadata scratch pad */ if(iod_obj_close(mdkv_oh, NULL, NULL)) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't close root object handle"); @@ -217,7 +300,7 @@ H5VL_iod_server_file_open_cb(AXE_engine_t UNUSED axe_engine, #if H5_DO_NATIVE { coh.cookie = H5Fopen(input->name, H5F_ACC_RDWR, H5P_DEFAULT); - HDassert(coh.cookie); + assert(coh.cookie); root_oh.cookie = coh.cookie; fprintf(stderr, "Opened Native file %s with ID %d\n", input->name, root_oh.cookie); } diff --git a/src/H5VLiod_group.c b/src/H5VLiod_group.c index c59fc64..b830079 100644 --- a/src/H5VLiod_group.c +++ b/src/H5VLiod_group.c @@ -115,18 +115,58 @@ H5VL_iod_server_group_create_cb(AXE_engine_t UNUSED axe_engine, if (iod_obj_open_write(coh, mdkv_id, NULL, &mdkv_oh, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create scratch pad"); - /* MSC - TODO store things */ + /* store metadata */ + { + iod_kv_t kv; + size_t buf_size; + hid_t gcpl_id; + uint64_t count; + + if(H5P_DEFAULT == input->gcpl_id) + gcpl_id = H5P_GROUP_CREATE_DEFAULT; + else + gcpl_id = input->gcpl_id; + + /* insert group creation properties in Metadata KV */ + kv.key = strdup("gcpl"); + /* determine the buffer size needed to store the encoded gcpl of the group */ + if(H5Pencode(gcpl_id, NULL, &buf_size) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTENCODE, FAIL, "failed to encode group gcpl"); + if(NULL == (kv.value = malloc (buf_size))) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate gcpl buffer"); + /* encode gcpl of the group */ + if(H5Pencode(gcpl_id, kv.value, &buf_size) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTENCODE, FAIL, "failed to encode group gcpl"); + kv.value_len = (iod_size_t)buf_size; + /* insert kv pair into scratch pad */ + if (iod_kv_set(mdkv_oh, IOD_TID_UNKNOWN, NULL, &kv, NULL, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't set KV pair in parent"); + free(kv.key); + free(kv.value); + + /* insert link count metadata on object */ + if(NULL == (kv.value = malloc (sizeof(uint64_t)))) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate buffer"); + /* initial count is 1, since object is created now */ + count = 1; + memcpy(kv.value, &count, sizeof(uint64_t)); + kv.key = strdup("link_count"); + if (iod_kv_set(mdkv_oh, IOD_TID_UNKNOWN, NULL, &kv, NULL, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't set KV pair in parent"); + free(kv.key); + free(kv.value); + } if(iod_obj_close(mdkv_oh, NULL, NULL)) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't close object"); /* insert new group in kv store of parent object */ - kv.key = HDstrdup(last_comp); + kv.key = strdup(last_comp); kv.value = &grp_id; kv.value_len = sizeof(iod_obj_id_t); if (iod_kv_set(cur_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); + free(kv.key); } /* end if */ /* close parent group if it is not the location we started the @@ -137,7 +177,7 @@ H5VL_iod_server_group_create_cb(AXE_engine_t UNUSED axe_engine, #if H5_DO_NATIVE grp_oh.cookie = H5Gcreate2(loc_handle.cookie, name, input->lcpl_id, - input->gcpl_id, input->gapl_id); + input->gcpl_id, input->gapl_id); HDassert(grp_oh.cookie); #endif @@ -239,16 +279,29 @@ H5VL_iod_server_group_open_cb(AXE_engine_t UNUSED axe_engine, /* MSC - retrieve metadata */ #if 0 - /* When we have a real IOD, open the scratch pad and read the - group's metadata */ - if(iod_kv_get_value(mdkv_oh, IOD_TID_UNKNOWN, "dataset_gcpl", NULL, - &output.gcpl_size, NULL, NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "dataset gcpl lookup failed"); - if(NULL == (output.gcpl = H5MM_malloc (output.gcpl_size))) - HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate gcpl buffer"); - if(iod_kv_get_value(mdkv_oh, IOD_TID_UNKNOWN, "dataset_gcpl", output.gcpl, - &output.gcpl_size, NULL, NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "dataset dcpl lookup failed"); + { + void *buf = NULL; + + kv_size = 0; + /* read the group's creation properties */ + if(iod_kv_get_value(mdkv_oh, IOD_TID_UNKNOWN, "gcpl", NULL, + &kv_size, NULL, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "group gcpl lookup failed"); + if(NULL == (buf = malloc (kv_size))) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate gcpl buffer"); + if(iod_kv_get_value(mdkv_oh, IOD_TID_UNKNOWN, "gcpl", buf, + &kv_size, NULL, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "group gcpl lookup failed"); + if((output.gcpl_id = H5Pdecode(buf)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTDECODE, FAIL, "failed to decode gcpl"); + free(buf); + + kv_size = sizeof(uint64_t); + /* read the group's link count */ + if(iod_kv_get_value(mdkv_oh, IOD_TID_UNKNOWN, "link_count", output.link_count, + &kv_size, NULL, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "link_count lookup failed"); + } #endif /* close the metadata scratch pad */ diff --git a/src/H5VLiod_map.c b/src/H5VLiod_map.c index 3c8c8f2..a96b9e9 100644 --- a/src/H5VLiod_map.c +++ b/src/H5VLiod_map.c @@ -62,6 +62,7 @@ H5VL_iod_server_map_create_cb(AXE_engine_t UNUSED axe_engine, iod_kv_t kv; scratch_pad_t sp; iod_ret_t ret; + uint64_t count; hbool_t collective = FALSE; /* MSC - change when we allow for collective */ herr_t ret_value = SUCCEED; @@ -117,18 +118,28 @@ H5VL_iod_server_map_create_cb(AXE_engine_t UNUSED axe_engine, if (iod_obj_open_write(coh, mdkv_id, NULL, &mdkv_oh, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create scratch pad"); - /* MSC - TODO store things */ + /* insert link count metadata on object */ + if(NULL == (kv.value = malloc (sizeof(uint64_t)))) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate buffer"); + /* initial count is 1, since object is created now */ + count = 1; + memcpy(kv.value, &count, sizeof(uint64_t)); + kv.key = strdup("link_count"); + if (iod_kv_set(mdkv_oh, IOD_TID_UNKNOWN, NULL, &kv, NULL, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't set KV pair in parent"); + free(kv.key); + free(kv.value); if(iod_obj_close(mdkv_oh, NULL, NULL)) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't close object"); /* insert new map in kv store of parent object */ - kv.key = HDstrdup(last_comp); + kv.key = strdup(last_comp); kv.value = &map_id; kv.value_len = sizeof(iod_obj_id_t); if (iod_kv_set(cur_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); + free(kv.key); } /* end if */ /* close parent group if it is not the location we started the @@ -137,7 +148,6 @@ H5VL_iod_server_map_create_cb(AXE_engine_t UNUSED axe_engine, iod_obj_close(cur_oh, NULL, NULL); } - #if H5VL_IOD_DEBUG fprintf(stderr, "Done with map create, sending response to client\n"); #endif @@ -236,6 +246,13 @@ H5VL_iod_server_map_open_cb(AXE_engine_t UNUSED axe_engine, HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "can't open scratch pad"); /* MSC - retrieve metadata */ +#if 0 + kv_size = sizeof(uint64_t); + /* read the map's link count */ + if(iod_kv_get_value(mdkv_oh, IOD_TID_UNKNOWN, "link_count", output.link_count, + &kv_size, NULL, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "link_count lookup failed"); +#endif /* close the metadata scratch pad */ if(iod_obj_close(mdkv_oh, NULL, NULL)) diff --git a/src/H5VLiod_obj.c b/src/H5VLiod_obj.c index be0dfe0..b9d3fda 100644 --- a/src/H5VLiod_obj.c +++ b/src/H5VLiod_obj.c @@ -540,7 +540,7 @@ H5VL_iod_server_object_get_comment_cb(AXE_engine_t UNUSED axe_engine, #if H5_DO_NATIVE if(0 != length) { size = H5Oget_comment(loc_oh.cookie, NULL, length); - comment.value = malloc(size); + comment.value = malloc(size+1); } if((size = H5Oget_comment(loc_oh.cookie, comment.value, length)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "Unable to get object comment"); diff --git a/src/H5VLiod_server.c b/src/H5VLiod_server.c index 7dcedfa..a3f29a1 100644 --- a/src/H5VLiod_server.c +++ b/src/H5VLiod_server.c @@ -178,9 +178,7 @@ H5VLiod_start_handler(MPI_Comm comm, MPI_Info UNUSED info) /* Loop tp receive requests from clients */ while(1) { - /* Receive new function calls */ - if(HG_SUCCESS != HG_Handler_process(HG_HANDLER_MAX_IDLE_TIME, HG_STATUS_IGNORE)) - return FAIL; + HG_Handler_process(0, HG_STATUS_IGNORE); if(shutdown) break; } diff --git a/src/H5VLiod_server.h b/src/H5VLiod_server.h index 0a7a643..deda473 100644 --- a/src/H5VLiod_server.h +++ b/src/H5VLiod_server.h @@ -224,9 +224,9 @@ H5_DLL void H5VL_iod_server_link_create_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_link_move_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); + 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_link_exists_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[], |