From 10cf31edc93f768591a62c54a5078c4df0fc8b5a Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Mon, 28 Dec 2015 21:44:23 -0500 Subject: [svn-r28732] Merge of r8662-28680, 28692-28728 from revise_chunks. Tested on: Unbuntu 15.10 (Linux 4.2.0 x86_64) gcc 5.2.1 Autotools serial w/ C++ and Fortran Autotools parallel w/ Fortran (MPICH 3.1.4) CMake serial (CMake 3.3.2) --- examples/h5_vds-percival-unlim.c | 5 +- src/H5Adense.c | 89 +- src/H5Aint.c | 21 +- src/H5Apkg.h | 22 +- src/H5B.c | 12 +- src/H5B2.c | 126 +-- src/H5B2cache.c | 36 +- src/H5B2dbg.c | 64 +- src/H5B2hdr.c | 91 ++- src/H5B2int.c | 4 +- src/H5B2pkg.h | 11 +- src/H5B2private.h | 10 +- src/H5B2test.c | 7 +- src/H5Bdbg.c | 1 - src/H5Bpkg.h | 4 - src/H5Bprivate.h | 2 +- src/H5C.c | 29 +- src/H5Dbtree.c | 1 - src/H5Dbtree2.c | 125 +-- src/H5Dchunk.c | 16 +- src/H5Dearray.c | 59 -- src/H5Dfarray.c | 57 -- src/H5Dint.c | 135 ++++ src/H5Dpkg.h | 21 - src/H5Dprivate.h | 2 + src/H5EAhdr.c | 5 +- src/H5EAprivate.h | 1 - src/H5F.c | 29 +- src/H5FAhdr.c | 3 +- src/H5FAprivate.h | 1 - src/H5FS.c | 2 +- src/H5Fint.c | 15 +- src/H5Gdense.c | 32 +- src/H5Gobj.c | 2 +- src/H5Goh.c | 4 +- src/H5Gpublic.h | 4 +- src/H5Gstab.c | 4 +- src/H5Gtest.c | 6 +- src/H5HFhdr.c | 1 - src/H5HFhuge.c | 25 +- src/H5HFpkg.h | 1 - src/H5HFstat.c | 2 +- src/H5Oainfo.c | 17 +- src/H5Oattribute.c | 103 +-- src/H5Oflush.c | 35 +- src/H5Olayout.c | 2 +- src/H5Oprivate.h | 8 +- src/H5Otest.c | 35 +- src/H5SM.c | 20 +- test/Makefile.am | 15 +- test/btree2.c | 210 ++++- test/cache_tagging.c | 124 +-- test/dsets.c | 194 ++--- test/earray.c | 179 +++- test/farray.c | 163 +++- test/ohdr.c | 1 - test/swmr.c | 1664 ++++++++++++++++++++++++++++++++++---- tools/h5dump/h5dumpgentest.c | 9 +- tools/lib/h5tools_dump.c | 3 - 59 files changed, 2706 insertions(+), 1163 deletions(-) diff --git a/examples/h5_vds-percival-unlim.c b/examples/h5_vds-percival-unlim.c index b5f3ebd..2496c37 100644 --- a/examples/h5_vds-percival-unlim.c +++ b/examples/h5_vds-percival-unlim.c @@ -288,8 +288,9 @@ main (void) /* Read all VDS data */ - //EIP We should be able to do it by using H5S_ALL instead of making selection - // or using H5Sselect_all from vspace. + /* EIP We should be able to do it by using H5S_ALL instead of making selection + * or using H5Sselect_all from vspace. + */ start[0] = 0; start[1] = 0; start[2] = 0; diff --git a/src/H5Adense.c b/src/H5Adense.c index 8bc0e05..148977d 100644 --- a/src/H5Adense.c +++ b/src/H5Adense.c @@ -126,7 +126,6 @@ typedef struct H5A_bt2_ud_rm_t { /* downward */ H5A_bt2_ud_common_t common; /* Common info for B-tree user data (must be first) */ haddr_t corder_bt2_addr; /* v2 B-tree address of creation order index */ - void *parent; /* Flush dependency parent */ } H5A_bt2_ud_rm_t; /* @@ -141,7 +140,6 @@ typedef struct H5A_bt2_ud_rmbi_t { H5HF_t *shared_fheap; /* Fractal heap handle for shared messages */ H5_index_t idx_type; /* Index type for operation */ haddr_t other_bt2_addr; /* v2 B-tree address of "other" index */ - void *parent; /* Flush dependency parent */ } H5A_bt2_ud_rmbi_t; @@ -185,7 +183,7 @@ typedef struct H5A_bt2_ud_rmbi_t { *------------------------------------------------------------------------- */ herr_t -H5A_dense_create(H5F_t *f, hid_t dxpl_id, H5O_ainfo_t *ainfo, void *parent) +H5A_dense_create(H5F_t *f, hid_t dxpl_id, H5O_ainfo_t *ainfo) { H5HF_create_t fheap_cparam; /* Fractal heap creation parameters */ H5B2_create_t bt2_cparam; /* v2 B-tree creation parameters */ @@ -248,7 +246,7 @@ HDfprintf(stderr, "%s: fheap_id_len = %Zu\n", FUNC, fheap_id_len); H5O_FHEAP_ID_LEN; /* Fractal heap ID */ bt2_cparam.split_percent = H5A_NAME_BT2_SPLIT_PERC; bt2_cparam.merge_percent = H5A_NAME_BT2_MERGE_PERC; - if(NULL == (bt2_name = H5B2_create(f, dxpl_id, &bt2_cparam, NULL, parent))) + if(NULL == (bt2_name = H5B2_create(f, dxpl_id, &bt2_cparam, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to create v2 B-tree for name index") /* Retrieve the v2 B-tree's address in the file */ @@ -269,7 +267,7 @@ HDfprintf(stderr, "%s: ainfo->name_bt2_addr = %a\n", FUNC, ainfo->name_bt2_addr) H5O_FHEAP_ID_LEN; /* Fractal heap ID */ bt2_cparam.split_percent = H5A_CORDER_BT2_SPLIT_PERC; bt2_cparam.merge_percent = H5A_CORDER_BT2_MERGE_PERC; - if(NULL == (bt2_corder = H5B2_create(f, dxpl_id, &bt2_cparam, NULL, parent))) + if(NULL == (bt2_corder = H5B2_create(f, dxpl_id, &bt2_cparam, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to create v2 B-tree for creation order index") /* Retrieve the v2 B-tree's address in the file */ @@ -342,7 +340,7 @@ H5A__dense_fnd_cb(const H5A_t *attr, hbool_t *took_ownership, void *_user_attr) */ H5A_t * H5A_dense_open(H5F_t *f, hid_t dxpl_id, const H5O_ainfo_t *ainfo, - const char *name, void *parent) + const char *name) { H5A_bt2_ud_common_t udata; /* User data for v2 B-tree modify */ H5HF_t *fheap = NULL; /* Fractal heap handle */ @@ -386,7 +384,7 @@ H5A_dense_open(H5F_t *f, hid_t dxpl_id, const H5O_ainfo_t *ainfo, } /* end if */ /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(f, dxpl_id, ainfo->name_bt2_addr, NULL, parent))) + if(NULL == (bt2_name = H5B2_open(f, dxpl_id, ainfo->name_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "unable to open v2 B-tree for name index") /* Create the "udata" information for v2 B-tree record find */ @@ -445,7 +443,6 @@ H5A_dense_insert(H5F_t *f, hid_t dxpl_id, const H5O_ainfo_t *ainfo, H5A_t *attr) uint8_t attr_buf[H5A_ATTR_BUF_SIZE]; /* Buffer for serializing message */ unsigned mesg_flags = 0; /* Flags for storing message */ htri_t attr_sharable; /* Flag indicating attributes are sharable */ - H5O_proxy_t *oh_proxy = NULL; /* Attribute's object header proxy */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -531,14 +528,8 @@ H5A_dense_insert(H5F_t *f, hid_t dxpl_id, const H5O_ainfo_t *ainfo, H5A_t *attr) HGOTO_ERROR(H5E_ATTR, H5E_CANTINSERT, FAIL, "unable to insert attribute into fractal heap") } /* end else */ - /* Check for SWMR writes to the file */ - if(H5F_INTENT(f) & H5F_ACC_SWMR_WRITE) - /* Pin the attribute's object header proxy */ - if(NULL == (oh_proxy = H5O_pin_flush_dep_proxy(&attr->oloc, dxpl_id))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTPIN, FAIL, "unable to pin attribute object header proxy") - /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(f, dxpl_id, ainfo->name_bt2_addr, NULL, oh_proxy))) + if(NULL == (bt2_name = H5B2_open(f, dxpl_id, ainfo->name_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Create the callback information for v2 B-tree record insertion */ @@ -562,7 +553,7 @@ H5A_dense_insert(H5F_t *f, hid_t dxpl_id, const H5O_ainfo_t *ainfo, H5A_t *attr) if(ainfo->index_corder) { /* Open the creation order index v2 B-tree */ HDassert(H5F_addr_defined(ainfo->corder_bt2_addr)); - if(NULL == (bt2_corder = H5B2_open(f, dxpl_id, ainfo->corder_bt2_addr, NULL, oh_proxy))) + if(NULL == (bt2_corder = H5B2_open(f, dxpl_id, ainfo->corder_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for creation order index") /* Insert the record into the creation order index v2 B-tree */ @@ -572,8 +563,6 @@ H5A_dense_insert(H5F_t *f, hid_t dxpl_id, const H5O_ainfo_t *ainfo, H5A_t *attr) done: /* Release resources */ - if(oh_proxy && H5O_unpin_flush_dep_proxy(oh_proxy) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTUNPIN, FAIL, "unable to unpin attribute object header proxy") if(shared_fheap && H5HF_close(shared_fheap, dxpl_id) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") if(fheap && H5HF_close(fheap, dxpl_id) < 0) @@ -648,7 +637,6 @@ H5A__dense_write_bt2_cb(void *_record, void *_op_data, hbool_t *changed) H5B2_t *bt2_corder = NULL; /* v2 B-tree handle for creation order index */ H5WB_t *wb = NULL; /* Wrapped buffer for attribute data */ uint8_t attr_buf[H5A_ATTR_BUF_SIZE]; /* Buffer for serializing attribute */ - H5O_proxy_t *oh_proxy = NULL; /* Attribute's object header proxy */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -672,14 +660,8 @@ H5A__dense_write_bt2_cb(void *_record, void *_op_data, hbool_t *changed) if(H5F_addr_defined(op_data->corder_bt2_addr)) { H5A_bt2_ud_common_t udata; /* User data for v2 B-tree modify */ - /* Check for SWMR writes to the file */ - if(H5F_INTENT(op_data->f) & H5F_ACC_SWMR_WRITE) - /* Pin the attribute's object header proxy */ - if(NULL == (oh_proxy = H5O_pin_flush_dep_proxy(&op_data->attr->oloc, op_data->dxpl_id))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTPIN, FAIL, "unable to pin attribute object header proxy") - /* Open the creation order index v2 B-tree */ - if(NULL == (bt2_corder = H5B2_open(op_data->f, op_data->dxpl_id, op_data->corder_bt2_addr, NULL, oh_proxy))) + if(NULL == (bt2_corder = H5B2_open(op_data->f, op_data->dxpl_id, op_data->corder_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for creation order index") /* Create the "udata" information for v2 B-tree record modify */ @@ -740,8 +722,6 @@ H5A__dense_write_bt2_cb(void *_record, void *_op_data, hbool_t *changed) done: /* Release resources */ - if(oh_proxy && H5O_unpin_flush_dep_proxy(oh_proxy) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTUNPIN, FAIL, "unable to unpin attribute object header proxy") if(bt2_corder && H5B2_close(bt2_corder, op_data->dxpl_id) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for creation order index") if(wb && H5WB_unwrap(wb) < 0) @@ -773,7 +753,6 @@ H5A_dense_write(H5F_t *f, hid_t dxpl_id, const H5O_ainfo_t *ainfo, H5A_t *attr) H5HF_t *shared_fheap = NULL; /* Fractal heap handle for shared header messages */ H5B2_t *bt2_name = NULL; /* v2 B-tree handle for name index */ htri_t attr_sharable; /* Flag indicating attributes are sharable */ - H5O_proxy_t *oh_proxy = NULL; /* Attribute's object header proxy */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -811,14 +790,8 @@ H5A_dense_write(H5F_t *f, hid_t dxpl_id, const H5O_ainfo_t *ainfo, H5A_t *attr) if(NULL == (fheap = H5HF_open(f, dxpl_id, ainfo->fheap_addr))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") - /* Check for SWMR writes to the file */ - if(H5F_INTENT(f) & H5F_ACC_SWMR_WRITE) - /* Pin the attribute's object header proxy */ - if(NULL == (oh_proxy = H5O_pin_flush_dep_proxy(&attr->oloc, dxpl_id))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTPIN, FAIL, "unable to pin attribute object header proxy") - /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(f, dxpl_id, ainfo->name_bt2_addr, NULL, oh_proxy))) + if(NULL == (bt2_name = H5B2_open(f, dxpl_id, ainfo->name_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Create the "udata" information for v2 B-tree record modify */ @@ -847,8 +820,6 @@ H5A_dense_write(H5F_t *f, hid_t dxpl_id, const H5O_ainfo_t *ainfo, H5A_t *attr) done: /* Release resources */ - if(oh_proxy && H5O_unpin_flush_dep_proxy(oh_proxy) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTUNPIN, FAIL, "unable to unpin attribute object header proxy") if(shared_fheap && H5HF_close(shared_fheap, dxpl_id) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") if(fheap && H5HF_close(fheap, dxpl_id) < 0) @@ -919,7 +890,7 @@ done: */ herr_t H5A_dense_rename(H5F_t *f, hid_t dxpl_id, const H5O_ainfo_t *ainfo, - const char *old_name, const char *new_name, void *parent) + const char *old_name, const char *new_name) { H5A_bt2_ud_common_t udata; /* User data for v2 B-tree modify */ H5HF_t *fheap = NULL; /* Fractal heap handle */ @@ -966,7 +937,7 @@ H5A_dense_rename(H5F_t *f, hid_t dxpl_id, const H5O_ainfo_t *ainfo, HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(f, dxpl_id, ainfo->name_bt2_addr, NULL, parent))) + if(NULL == (bt2_name = H5B2_open(f, dxpl_id, ainfo->name_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Create the "udata" information for v2 B-tree record modify */ @@ -1041,7 +1012,7 @@ H5A_dense_rename(H5F_t *f, hid_t dxpl_id, const H5O_ainfo_t *ainfo, HGOTO_ERROR(H5E_ATTR, H5E_WRITEERROR, FAIL, "error determining if message should be shared") /* Delete old attribute from dense storage */ - if(H5A_dense_remove(f, dxpl_id, ainfo, old_name, parent) < 0) + if(H5A_dense_remove(f, dxpl_id, ainfo, old_name) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute in dense storage") done: @@ -1172,7 +1143,7 @@ done: herr_t H5A_dense_iterate(H5F_t *f, hid_t dxpl_id, hid_t loc_id, const H5O_ainfo_t *ainfo, H5_index_t idx_type, H5_iter_order_t order, - hsize_t skip, void *parent, hsize_t *last_attr, + hsize_t skip, hsize_t *last_attr, const H5A_attr_iter_op_t *attr_op, void *op_data) { H5HF_t *fheap = NULL; /* Fractal heap handle */ @@ -1246,7 +1217,7 @@ H5A_dense_iterate(H5F_t *f, hid_t dxpl_id, hid_t loc_id, } /* end if */ /* Open the index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, dxpl_id, bt2_addr, NULL, parent))) + if(NULL == (bt2 = H5B2_open(f, dxpl_id, bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for index") /* Construct the user data for v2 B-tree iterator callback */ @@ -1272,7 +1243,7 @@ H5A_dense_iterate(H5F_t *f, hid_t dxpl_id, hid_t loc_id, else { /* Build the table of attributes for this object */ /* (build table using the name index, but sort according to idx_type) */ - if(H5A_dense_build_table(f, dxpl_id, ainfo, idx_type, order, parent, &atable) < 0) + if(H5A_dense_build_table(f, dxpl_id, ainfo, idx_type, order, &atable) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "error building table of attributes") /* Iterate over attributes in table */ @@ -1322,7 +1293,7 @@ H5A__dense_remove_bt2_cb(const void *_record, void *_udata) /* Check for removing the link from the creation order index */ if(H5F_addr_defined(udata->corder_bt2_addr)) { /* Open the creation order index v2 B-tree */ - if(NULL == (bt2_corder = H5B2_open(udata->common.f, udata->common.dxpl_id, udata->corder_bt2_addr, NULL, udata->parent))) + if(NULL == (bt2_corder = H5B2_open(udata->common.f, udata->common.dxpl_id, udata->corder_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for creation order index") /* Set up the user data for the v2 B-tree 'record remove' callback */ @@ -1374,7 +1345,7 @@ done: */ herr_t H5A_dense_remove(H5F_t *f, hid_t dxpl_id, const H5O_ainfo_t *ainfo, - const char *name, void *parent) + const char *name) { H5A_bt2_ud_rm_t udata; /* User data for v2 B-tree record removal */ H5HF_t *fheap = NULL; /* Fractal heap handle */ @@ -1418,7 +1389,7 @@ H5A_dense_remove(H5F_t *f, hid_t dxpl_id, const H5O_ainfo_t *ainfo, } /* end if */ /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(f, dxpl_id, ainfo->name_bt2_addr, NULL, parent))) + if(NULL == (bt2_name = H5B2_open(f, dxpl_id, ainfo->name_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Set up the user data for the v2 B-tree 'record remove' callback */ @@ -1431,7 +1402,6 @@ H5A_dense_remove(H5F_t *f, hid_t dxpl_id, const H5O_ainfo_t *ainfo, udata.common.found_op = H5A__dense_fnd_cb; /* v2 B-tree comparison callback */ udata.common.found_op_data = &attr_copy; udata.corder_bt2_addr = ainfo->corder_bt2_addr; - udata.parent = parent; /* Remove the record from the name index v2 B-tree */ if(H5B2_remove(bt2_name, dxpl_id, &udata, H5A__dense_remove_bt2_cb, &udata) < 0) @@ -1533,7 +1503,7 @@ H5A__dense_remove_by_idx_bt2_cb(const void *_record, void *_bt2_udata) } /* end else */ /* Open the index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(bt2_udata->f, bt2_udata->dxpl_id, bt2_udata->other_bt2_addr, NULL, bt2_udata->parent))) + if(NULL == (bt2 = H5B2_open(bt2_udata->f, bt2_udata->dxpl_id, bt2_udata->other_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for index") /* Set the common information for the v2 B-tree remove operation */ @@ -1595,7 +1565,7 @@ done: */ herr_t H5A_dense_remove_by_idx(H5F_t *f, hid_t dxpl_id, const H5O_ainfo_t *ainfo, - H5_index_t idx_type, H5_iter_order_t order, hsize_t n, void *parent) + H5_index_t idx_type, H5_iter_order_t order, hsize_t n) { H5HF_t *fheap = NULL; /* Fractal heap handle */ H5HF_t *shared_fheap = NULL; /* Fractal heap handle for shared header messages */ @@ -1665,7 +1635,7 @@ H5A_dense_remove_by_idx(H5F_t *f, hid_t dxpl_id, const H5O_ainfo_t *ainfo, } /* end if */ /* Open the index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, dxpl_id, bt2_addr, NULL, parent))) + if(NULL == (bt2 = H5B2_open(f, dxpl_id, bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for index") /* Set up the user data for the v2 B-tree 'record remove' callback */ @@ -1675,16 +1645,15 @@ H5A_dense_remove_by_idx(H5F_t *f, hid_t dxpl_id, const H5O_ainfo_t *ainfo, udata.shared_fheap = shared_fheap; udata.idx_type = idx_type; udata.other_bt2_addr = idx_type == H5_INDEX_NAME ? ainfo->corder_bt2_addr : ainfo->name_bt2_addr; - udata.parent = parent; /* Remove the record from the name index v2 B-tree */ - if(H5B2_remove_by_idx(bt2, dxpl_id, order, n, NULL, H5A__dense_remove_by_idx_bt2_cb, &udata) < 0) + if(H5B2_remove_by_idx(bt2, dxpl_id, order, n, H5A__dense_remove_by_idx_bt2_cb, &udata) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTREMOVE, FAIL, "unable to remove attribute from v2 B-tree index") } /* end if */ else { /* Build the table of attributes for this object */ /* (build table using the name index, but sort according to idx_type) */ - if(H5A_dense_build_table(f, dxpl_id, ainfo, idx_type, order, parent, &atable) < 0) + if(H5A_dense_build_table(f, dxpl_id, ainfo, idx_type, order, &atable) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "error building table of attributes") /* Check for skipping too many attributes */ @@ -1692,7 +1661,7 @@ H5A_dense_remove_by_idx(H5F_t *f, hid_t dxpl_id, const H5O_ainfo_t *ainfo, HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index specified") /* Delete appropriate attribute from dense storage */ - if(H5A_dense_remove(f, dxpl_id, ainfo, ((atable.attrs[n])->shared)->name, parent) < 0) + if(H5A_dense_remove(f, dxpl_id, ainfo, ((atable.attrs[n])->shared)->name) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute in dense storage") } /* end else */ @@ -1727,7 +1696,7 @@ done: */ htri_t H5A_dense_exists(H5F_t *f, hid_t dxpl_id, const H5O_ainfo_t *ainfo, - const char *name, void *parent) + const char *name) { H5A_bt2_ud_common_t udata; /* User data for v2 B-tree modify */ H5HF_t *fheap = NULL; /* Fractal heap handle */ @@ -1770,7 +1739,7 @@ H5A_dense_exists(H5F_t *f, hid_t dxpl_id, const H5O_ainfo_t *ainfo, } /* end if */ /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(f, dxpl_id, ainfo->name_bt2_addr, NULL, parent))) + if(NULL == (bt2_name = H5B2_open(f, dxpl_id, ainfo->name_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Create the "udata" information for v2 B-tree record 'find' */ @@ -1881,7 +1850,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5A_dense_delete(H5F_t *f, hid_t dxpl_id, H5O_ainfo_t *ainfo, void *parent) +H5A_dense_delete(H5F_t *f, hid_t dxpl_id, H5O_ainfo_t *ainfo) { H5A_bt2_ud_common_t udata; /* v2 B-tree user data for deleting attributes */ H5HF_t *fheap = NULL; /* Fractal heap handle */ @@ -1911,7 +1880,7 @@ H5A_dense_delete(H5F_t *f, hid_t dxpl_id, H5O_ainfo_t *ainfo, void *parent) udata.found_op_data = NULL; /* Delete name index v2 B-tree */ - if(H5B2_delete(f, dxpl_id, ainfo->name_bt2_addr, NULL, parent, H5A__dense_delete_bt2_cb, &udata) < 0) + if(H5B2_delete(f, dxpl_id, ainfo->name_bt2_addr, NULL, H5A__dense_delete_bt2_cb, &udata) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete v2 B-tree for name index") ainfo->name_bt2_addr = HADDR_UNDEF; @@ -1923,7 +1892,7 @@ H5A_dense_delete(H5F_t *f, hid_t dxpl_id, H5O_ainfo_t *ainfo, void *parent) /* Check if we should delete the creation order index v2 B-tree */ if(H5F_addr_defined(ainfo->corder_bt2_addr)) { /* Delete the creation order index, without adjusting the ref. count on the attributes */ - if(H5B2_delete(f, dxpl_id, ainfo->corder_bt2_addr, NULL, parent, NULL, NULL) < 0) + if(H5B2_delete(f, dxpl_id, ainfo->corder_bt2_addr, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete v2 B-tree for creation order index") ainfo->corder_bt2_addr = HADDR_UNDEF; } /* end if */ diff --git a/src/H5Aint.c b/src/H5Aint.c index bde64c4..80761b6 100644 --- a/src/H5Aint.c +++ b/src/H5Aint.c @@ -1407,8 +1407,7 @@ done: */ herr_t H5A_dense_build_table(H5F_t *f, hid_t dxpl_id, const H5O_ainfo_t *ainfo, - H5_index_t idx_type, H5_iter_order_t order, void *parent, - H5A_attr_table_t *atable) + H5_index_t idx_type, H5_iter_order_t order, H5A_attr_table_t *atable) { H5B2_t *bt2_name = NULL; /* v2 B-tree handle for name index */ hsize_t nrec; /* # of records in v2 B-tree */ @@ -1424,7 +1423,7 @@ H5A_dense_build_table(H5F_t *f, hid_t dxpl_id, const H5O_ainfo_t *ainfo, HDassert(atable); /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(f, dxpl_id, ainfo->name_bt2_addr, NULL, parent))) + if(NULL == (bt2_name = H5B2_open(f, dxpl_id, ainfo->name_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Retrieve # of records in "name" B-tree */ @@ -1455,7 +1454,7 @@ H5A_dense_build_table(H5F_t *f, hid_t dxpl_id, const H5O_ainfo_t *ainfo, /* Iterate over the links in the group, building a table of the link messages */ if(H5A_dense_iterate(f, dxpl_id, (hid_t)0, ainfo, H5_INDEX_NAME, - H5_ITER_NATIVE, (hsize_t)0, parent, NULL, &attr_op, &udata) < 0) + H5_ITER_NATIVE, (hsize_t)0, NULL, &attr_op, &udata) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "error building attribute table") /* Sort attribute table in correct iteration order */ @@ -1789,7 +1788,6 @@ htri_t H5A_get_ainfo(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5O_ainfo_t *ainfo) { H5B2_t *bt2_name = NULL; /* v2 B-tree handle for name index */ - H5O_proxy_t *oh_proxy = NULL; /* Object header proxy */ htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_TAG(dxpl_id, oh->cache_info.addr, FAIL) @@ -1811,14 +1809,8 @@ H5A_get_ainfo(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5O_ainfo_t *ainfo) if(ainfo->nattrs == HSIZET_MAX) { /* Check if we are using "dense" attribute storage */ if(H5F_addr_defined(ainfo->fheap_addr)) { - /* Check for SWMR writes to the file */ - if(H5F_INTENT(f) & H5F_ACC_SWMR_WRITE) - /* Pin the attribute's object header proxy */ - if(NULL == (oh_proxy = H5O_pin_flush_dep_proxy_oh(f, dxpl_id, oh))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTPIN, FAIL, "unable to pin object header proxy") - /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(f, dxpl_id, ainfo->name_bt2_addr, NULL, oh_proxy))) + if(NULL == (bt2_name = H5B2_open(f, dxpl_id, ainfo->name_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Retrieve # of records in "name" B-tree */ @@ -1834,8 +1826,6 @@ H5A_get_ainfo(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5O_ainfo_t *ainfo) done: /* Release resources */ - if(oh_proxy && H5O_unpin_flush_dep_proxy(oh_proxy) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTUNPIN, FAIL, "unable to unpin attribute object header proxy") if(bt2_name && H5B2_close(bt2_name, dxpl_id) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for name index") @@ -2364,9 +2354,8 @@ H5A_dense_post_copy_file_all(const H5O_loc_t *src_oloc, const H5O_ainfo_t *ainfo attr_op.op_type = H5A_ATTR_OP_LIB; attr_op.u.lib_op = H5A__dense_post_copy_file_cb; - /*!FIXME must pass something for parent once SWMR works with H5Ocopy -NAF */ if(H5A_dense_iterate(src_oloc->file, dxpl_id, (hid_t)0, ainfo_src, H5_INDEX_NAME, - H5_ITER_NATIVE, (hsize_t)0, NULL, NULL, &attr_op, &udata) < 0) + H5_ITER_NATIVE, (hsize_t)0, NULL, &attr_op, &udata) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "error building attribute table") done: diff --git a/src/H5Apkg.h b/src/H5Apkg.h index ab036fa..5858147 100644 --- a/src/H5Apkg.h +++ b/src/H5Apkg.h @@ -207,37 +207,34 @@ H5_DLL herr_t H5A__read(const H5A_t *attr, const H5T_t *mem_type, void *buf, hid H5_DLL ssize_t H5A__get_name(H5A_t *attr, size_t buf_size, char *buf); /* Attribute "dense" storage routines */ -H5_DLL herr_t H5A_dense_create(H5F_t *f, hid_t dxpl_id, H5O_ainfo_t *ainfo, - void *parent); +H5_DLL herr_t H5A_dense_create(H5F_t *f, hid_t dxpl_id, H5O_ainfo_t *ainfo); H5_DLL H5A_t *H5A_dense_open(H5F_t *f, hid_t dxpl_id, const H5O_ainfo_t *ainfo, - const char *name, void *parent); + const char *name); H5_DLL herr_t H5A_dense_insert(H5F_t *f, hid_t dxpl_id, const H5O_ainfo_t *ainfo, H5A_t *attr); H5_DLL herr_t H5A_dense_write(H5F_t *f, hid_t dxpl_id, const H5O_ainfo_t *ainfo, H5A_t *attr); H5_DLL herr_t H5A_dense_rename(H5F_t *f, hid_t dxpl_id, const H5O_ainfo_t *ainfo, - const char *old_name, const char *new_name, void *parent); + const char *old_name, const char *new_name); H5_DLL herr_t H5A_dense_iterate(H5F_t *f, hid_t dxpl_id, hid_t loc_id, const H5O_ainfo_t *ainfo, H5_index_t idx_type, H5_iter_order_t order, - hsize_t skip, void *parent, hsize_t *last_attr, const H5A_attr_iter_op_t *attr_op, + hsize_t skip, hsize_t *last_attr, const H5A_attr_iter_op_t *attr_op, void *op_data); H5_DLL herr_t H5A_dense_remove(H5F_t *f, hid_t dxpl_id, - const H5O_ainfo_t *ainfo, const char *name, void *parent); + const H5O_ainfo_t *ainfo, const char *name); H5_DLL herr_t H5A_dense_remove_by_idx(H5F_t *f, hid_t dxpl_id, const H5O_ainfo_t *ainfo, H5_index_t idx_type, H5_iter_order_t order, - hsize_t n, void *parent); + hsize_t n); H5_DLL htri_t H5A_dense_exists(H5F_t *f, hid_t dxpl_id, const H5O_ainfo_t *ainfo, - const char *name, void *parent); -H5_DLL herr_t H5A_dense_delete(H5F_t *f, hid_t dxpl_id, H5O_ainfo_t *ainfo, - void *parent); - + const char *name); +H5_DLL herr_t H5A_dense_delete(H5F_t *f, hid_t dxpl_id, H5O_ainfo_t *ainfo); /* Attribute table operations */ H5_DLL herr_t H5A_compact_build_table(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5_index_t idx_type, H5_iter_order_t order, H5A_attr_table_t *atable); H5_DLL herr_t H5A_dense_build_table(H5F_t *f, hid_t dxpl_id, const H5O_ainfo_t *ainfo, H5_index_t idx_type, H5_iter_order_t order, - void *parent, H5A_attr_table_t *atable); + H5A_attr_table_t *atable); H5_DLL herr_t H5A_attr_iterate_table(const H5A_attr_table_t *atable, hsize_t skip, hsize_t *last_attr, hid_t loc_id, const H5A_attr_iter_op_t *attr_op, void *op_data); @@ -270,7 +267,6 @@ H5_DLL herr_t H5A_attr_post_copy_file(const H5O_loc_t *src_oloc, const H5A_t *me H5_DLL herr_t H5A_dense_post_copy_file_all(const H5O_loc_t *src_oloc, const H5O_ainfo_t * ainfo_src, H5O_loc_t *dst_oloc, H5O_ainfo_t *ainfo_dst, hid_t dxpl_id, H5O_copy_t *cpy_info); - /* Testing functions */ #ifdef H5A_TESTING H5_DLL htri_t H5A_is_shared_test(hid_t aid); diff --git a/src/H5B.c b/src/H5B.c index b000cbd..3b34c4d 100644 --- a/src/H5B.c +++ b/src/H5B.c @@ -487,7 +487,6 @@ H5B__split(H5F_t *f, hid_t dxpl_id, H5B_ins_ud_t *bt_ud, unsigned idx, HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to create B-tree") cache_udata.f = f; cache_udata.type = shared->type; - cache_udata.parent = bt_ud->bt->parent; cache_udata.rc_shared = bt_ud->bt->rc_shared; if(NULL == (split_bt_ud->bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, split_bt_ud->addr, &cache_udata, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree") @@ -613,8 +612,7 @@ H5B_insert(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void /* Check if the root node split */ if(H5B_INS_NOOP == my_ins) { - /* The root node did not split - just update the flush dependency (if - * necessary) and exit */ + /* The root node did not split - just return */ HDassert(!split_bt_ud.bt); HGOTO_DONE(SUCCEED) } /* end if */ @@ -878,7 +876,6 @@ H5B__insert_helper(H5F_t *f, hid_t dxpl_id, H5B_ins_ud_t *bt_ud, /* Set up user data for cache callbacks */ cache_udata.f = f; cache_udata.type = type; - cache_udata.parent = bt; cache_udata.rc_shared = rc_shared; if(0 == bt->nchildren) { @@ -1277,6 +1274,7 @@ H5B__remove_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *typ FUNC_ENTER_STATIC HDassert(f); + HDassert(H5F_addr_defined(addr)); HDassert(type); HDassert(type->decode); HDassert(type->cmp3); @@ -2038,11 +2036,10 @@ done: *------------------------------------------------------------------------- */ htri_t -H5B_valid(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, - void *parent) +H5B_valid(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr) { H5B_t *bt = NULL; /* The B-tree */ - H5UC_t *rc_shared; /* Ref-counted shared info */ + H5UC_t *rc_shared; /* Ref-counted shared info */ H5B_shared_t *shared; /* Pointer to shared B-tree info */ H5B_cache_ud_t cache_udata; /* User-data for metadata cache callback */ htri_t ret_value = SUCCEED; /* Return value */ @@ -2069,7 +2066,6 @@ H5B_valid(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, */ cache_udata.f = f; cache_udata.type = type; - cache_udata.parent = parent; cache_udata.rc_shared = rc_shared; if(NULL == (bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, &cache_udata, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree node") diff --git a/src/H5B2.c b/src/H5B2.c index 84ff8de..f421bdb 100644 --- a/src/H5B2.c +++ b/src/H5B2.c @@ -134,12 +134,10 @@ H5FL_DEFINE_STATIC(H5B2_t); *------------------------------------------------------------------------- */ H5B2_t * -H5B2_create(H5F_t *f, hid_t dxpl_id, const H5B2_create_t *cparam, - void *ctx_udata, void *parent) +H5B2_create(H5F_t *f, hid_t dxpl_id, const H5B2_create_t *cparam, void *ctx_udata) { H5B2_t *bt2 = NULL; /* Pointer to the B-tree */ H5B2_hdr_t *hdr = NULL; /* Pointer to the B-tree header */ - H5B2_hdr_cache_ud_t cache_udata; /* User-data for callback */ haddr_t hdr_addr; /* B-tree header address */ H5B2_t *ret_value = NULL; /* Return value */ @@ -155,7 +153,7 @@ H5B2_create(H5F_t *f, hid_t dxpl_id, const H5B2_create_t *cparam, HDcompile_assert(H5B2_NUM_BTREE_ID == NELMTS(H5B2_client_class_g)); /* Create shared v2 B-tree header */ - if(HADDR_UNDEF == (hdr_addr = H5B2__hdr_create(f, dxpl_id, cparam, ctx_udata, parent))) + if(HADDR_UNDEF == (hdr_addr = H5B2__hdr_create(f, dxpl_id, cparam, ctx_udata))) HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, NULL, "can't create v2 B-tree header") /* Create v2 B-tree wrapper */ @@ -163,12 +161,8 @@ H5B2_create(H5F_t *f, hid_t dxpl_id, const H5B2_create_t *cparam, HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "memory allocation failed for v2 B-tree info") /* Look up the B-tree header */ - cache_udata.f = f; - cache_udata.parent = parent; - cache_udata.addr = hdr_addr; - cache_udata.ctx_udata = ctx_udata; - if(NULL == (hdr = (H5B2_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, hdr_addr, &cache_udata, H5AC__NO_FLAGS_SET))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, NULL, "unable to load B-tree header") + if(NULL == (hdr = H5B2__hdr_protect(f, dxpl_id, hdr_addr, ctx_udata, H5AC__NO_FLAGS_SET))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, NULL, "unable to protect v2 B-tree header") /* Point v2 B-tree wrapper at header and bump it's ref count */ bt2->hdr = hdr; @@ -186,7 +180,7 @@ H5B2_create(H5F_t *f, hid_t dxpl_id, const H5B2_create_t *cparam, ret_value = bt2; done: - if(hdr && H5AC_unprotect(f, dxpl_id, H5AC_BT2_HDR, hdr_addr, hdr, H5AC__NO_FLAGS_SET) < 0) + if(hdr && H5B2__hdr_unprotect(hdr, dxpl_id, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, NULL, "unable to release v2 B-tree header") if(!ret_value && bt2) if(H5B2_close(bt2, dxpl_id) < 0) @@ -211,11 +205,10 @@ done: *------------------------------------------------------------------------- */ H5B2_t * -H5B2_open(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *ctx_udata, void *parent) +H5B2_open(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *ctx_udata) { H5B2_t *bt2 = NULL; /* Pointer to the B-tree */ H5B2_hdr_t *hdr = NULL; /* Pointer to the B-tree header */ - H5B2_hdr_cache_ud_t cache_udata; /* User-data for callback */ H5B2_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -225,12 +218,8 @@ H5B2_open(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *ctx_udata, void *parent) HDassert(H5F_addr_defined(addr)); /* Look up the B-tree header */ - cache_udata.f = f; - cache_udata.parent = parent; - cache_udata.addr = addr; - cache_udata.ctx_udata = ctx_udata; - if(NULL == (hdr = (H5B2_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, &cache_udata, H5AC__READ_ONLY_FLAG))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, NULL, "unable to load B-tree header") + if(NULL == (hdr = H5B2__hdr_protect(f, dxpl_id, addr, ctx_udata, H5AC__READ_ONLY_FLAG))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, NULL, "unable to protect v2 B-tree header") /* Check for pending heap deletion */ if(hdr->pending_delete) @@ -256,7 +245,7 @@ H5B2_open(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *ctx_udata, void *parent) ret_value = bt2; done: - if(hdr && H5AC_unprotect(f, dxpl_id, H5AC_BT2_HDR, addr, hdr, H5AC__NO_FLAGS_SET) < 0) + if(hdr && H5B2__hdr_unprotect(hdr, dxpl_id, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, NULL, "unable to release v2 B-tree header") if(!ret_value && bt2) if(H5B2_close(bt2, dxpl_id) < 0) @@ -914,12 +903,6 @@ done: * * Purpose: Removes the n'th record from a B-tree. * - * The 'udata' parameter is only used to pass through to the - * crt_flush_dep and upd_flush_dep callbacks, so it only - * needs to contain enough information for those (if any - it - * can be NULL). Specifically, it does not need to identify - * the specific record to search for. - * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol @@ -930,7 +913,7 @@ done: */ herr_t H5B2_remove_by_idx(H5B2_t *bt2, hid_t dxpl_id, H5_iter_order_t order, - hsize_t idx, void *udata, H5B2_remove_t op, void *op_data) + hsize_t idx, H5B2_remove_t op, void *op_data) { H5B2_hdr_t *hdr; /* Pointer to the B-tree header */ herr_t ret_value = SUCCEED; /* Return value */ @@ -964,7 +947,7 @@ H5B2_remove_by_idx(H5B2_t *bt2, hid_t dxpl_id, H5_iter_order_t order, if(H5B2__remove_internal_by_idx(hdr, dxpl_id, &depth_decreased, NULL, NULL, hdr->depth, &(hdr->cache_info), NULL, &hdr->root, - H5B2_POS_ROOT, idx, udata, op, op_data) < 0) + H5B2_POS_ROOT, idx, op, op_data) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDELETE, FAIL, "unable to remove record from B-tree internal node") /* Check for decreasing the depth of the B-tree */ @@ -1310,7 +1293,7 @@ H5B2_modify(H5B2_t *bt2, hid_t dxpl_id, void *udata, H5B2_modify_t op, /* Unlock current node */ if(H5AC_unprotect(hdr->f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, leaf_flags) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") - } + } /* end block */ done: if(parent) { @@ -1388,7 +1371,7 @@ H5B2_close(H5B2_t *bt2, hid_t dxpl_id) /* Lock the v2 B-tree header into memory */ /* (OK to pass in NULL for callback context, since we know the header must be in the cache) */ - if(NULL == (hdr = (H5B2_hdr_t *)H5AC_protect(bt2->f, dxpl_id, H5AC_BT2_HDR, bt2_addr, NULL, H5AC__NO_FLAGS_SET))) + if(NULL == (hdr = H5B2__hdr_protect(bt2->f, dxpl_id, bt2_addr, NULL, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect v2 B-tree header") /* Set the shared v2 B-tree header's file context for this operation */ @@ -1447,10 +1430,9 @@ done: */ herr_t H5B2_delete(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *ctx_udata, - void *parent, H5B2_remove_t op, void *op_data) + H5B2_remove_t op, void *op_data) { H5B2_hdr_t *hdr = NULL; /* Pointer to the B-tree header */ - H5B2_hdr_cache_ud_t cache_udata; /* User-data for callback */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1463,11 +1445,7 @@ H5B2_delete(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *ctx_udata, #ifdef QAK HDfprintf(stderr, "%s: addr = %a\n", FUNC, addr); #endif /* QAK */ - cache_udata.f = f; - cache_udata.parent = parent; - cache_udata.addr = addr; - cache_udata.ctx_udata = ctx_udata; - if(NULL == (hdr = (H5B2_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, &cache_udata, H5AC__NO_FLAGS_SET))) + if(NULL == (hdr = H5B2__hdr_protect(f, dxpl_id, addr, ctx_udata, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect v2 B-tree header") /* Remember the callback & context for later */ @@ -1489,7 +1467,7 @@ HDfprintf(stderr, "%s: addr = %a\n", FUNC, addr); done: /* Unprotect the header, if an error occurred */ - if(hdr && H5AC_unprotect(f, dxpl_id, H5AC_BT2_HDR, addr, hdr, H5AC__NO_FLAGS_SET) < 0) + if(hdr && H5B2__hdr_unprotect(hdr, dxpl_id, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release v2 B-tree header") FUNC_LEAVE_NOAPI(ret_value) @@ -1524,64 +1502,38 @@ HDfprintf(stderr, "%s: Called\n", FUNC); /* * Check arguments. + * + * At present, this function is only used to setup a flush dependency + * between an object header proxy and the v2 B-tree header when + * the B-tree is being used to index a chunked data set. + * + * Make sure that the parameters are congruent with this. */ HDassert(bt2); HDassert(hdr); - - /* Set the shared v2 B-tree header's file context for this operation */ - bt2->hdr->f = bt2->f; - - /* Set up flush dependency between parent entry and B-tree header */ - if(H5B2__create_flush_depend(parent_entry, (H5AC_info_t *)hdr) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTDEPEND, FAIL, "unable to create flush dependency on file metadata") - -done: - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5B2_depend() */ - - -/*------------------------------------------------------------------------- - * Function: H5B2_undepend - * - * Purpose: Remove a child flush dependency between the v2 B-tree's - * header and another piece of metadata in the file. - * - * Return: SUCCEED/FAIL - * - * Programmer: Dana Robinson - * Fall 2012 - * - *------------------------------------------------------------------------- - */ -herr_t -H5B2_undepend(H5AC_info_t *parent_entry, H5B2_t *bt2) -{ - /* Local variables */ - H5B2_hdr_t *hdr = bt2->hdr; /* Header for B-tree */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(SUCCEED) - -#ifdef QAK -HDfprintf(stderr, "%s: Called\n", FUNC); -#endif /* QAK */ + HDassert(parent_entry); + HDassert(parent_entry->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + HDassert(parent_entry->type); + HDassert(parent_entry->type->id == H5AC_OHDR_PROXY_ID); + HDassert(hdr->parent == NULL || hdr->parent == parent_entry); /* - * Check arguments. + * Check to see if the flush dependency between the object header proxy + * and the v2 B-tree header has already been setup. If it hasn't, then + * set it up. */ - HDassert(bt2); - HDassert(hdr); + if(NULL == hdr->parent) { + /* Set the shared v2 B-tree header's file context for this operation */ + bt2->hdr->f = bt2->f; - /* Set the shared v2 B-tree header's file context for this operation */ - bt2->hdr->f = bt2->f; + /* Set up flush dependency between parent entry and B-tree header */ + if(H5B2__create_flush_depend(parent_entry, (H5AC_info_t *)hdr) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTDEPEND, FAIL, "unable to create flush dependency on file metadata") - /* Remove flush dependency between parent entry and B-tree header */ - if(H5B2__destroy_flush_depend(parent_entry, (H5AC_info_t *)hdr) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency on file metadata") + hdr->parent = parent_entry; + } /* end if */ done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5B2_undepend() */ +} /* end H5B2_depend() */ diff --git a/src/H5B2cache.c b/src/H5B2cache.c index 58e76af..2c40761 100644 --- a/src/H5B2cache.c +++ b/src/H5B2cache.c @@ -328,7 +328,7 @@ H5B2__cache_hdr_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, /* Initialize B-tree header info */ cparam.cls = H5B2_client_class_g[id]; - if(H5B2__hdr_init(hdr, &cparam, udata->ctx_udata, udata->parent, depth) < 0) + if(H5B2__hdr_init(hdr, &cparam, udata->ctx_udata, depth) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, NULL, "can't initialize B-tree header info") /* Set the B-tree header's address */ @@ -501,23 +501,35 @@ H5B2__cache_hdr_notify(H5AC_notify_action_t action, void *_thing) /* Check if the file was opened with SWMR-write access */ if(hdr->swmr_write) { - HDassert(hdr->parent); switch(action) { case H5AC_NOTIFY_ACTION_AFTER_INSERT: case H5AC_NOTIFY_ACTION_AFTER_LOAD: - /* Create flush dependency on parent */ - if(H5B2__create_flush_depend((H5AC_info_t *)hdr->parent, (H5AC_info_t *)hdr) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTDEPEND, FAIL, "unable to create flush dependency") - break; - case H5AC_NOTIFY_ACTION_AFTER_FLUSH: /* do nothing */ - break; + break; - case H5AC_NOTIFY_ACTION_BEFORE_EVICT: - /* Destroy flush dependency on parent */ - if(H5B2__destroy_flush_depend((H5AC_info_t *)hdr->parent, (H5AC_info_t *)hdr) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency") + case H5AC_NOTIFY_ACTION_BEFORE_EVICT: + /* If hdr->parent != NULL, the v2 B-tree header + * must be employed as the index for a chunked + * data set which has been modified by the SWMR writer. + * + * In this case, hdr->parent must contain a + * pointer to the object header proxy which is the flush + * dependency parent of the v2 B-tree header. + * + * hdr->parent is used to destroy the flush dependency + * before the v2 B-tree header is evicted. + */ + if(hdr->parent) { + /* Sanity checks */ + HDassert(((H5AC_info_t *)hdr->parent)->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + HDassert(((H5AC_info_t *)hdr->parent)->type); + HDassert(((H5AC_info_t *)hdr->parent)->type->id == H5AC_OHDR_PROXY_ID); + + /* Destroy flush dependency on object header proxy */ + if(H5B2__destroy_flush_depend((H5AC_info_t *)hdr->parent, (H5AC_info_t *)hdr) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency") + } /* end if */ break; default: diff --git a/src/H5B2dbg.c b/src/H5B2dbg.c index c7dc165..b0e9ba2 100644 --- a/src/H5B2dbg.c +++ b/src/H5B2dbg.c @@ -95,7 +95,6 @@ H5B2__hdr_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, void *dbg_ctx = NULL; /* v2 B-tree debugging context */ unsigned u; /* Local index variable */ char temp_str[128]; /* Temporary string, for formatting */ - H5B2_hdr_cache_ud_t cache_udata; /* User-data for callback */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -114,20 +113,13 @@ H5B2__hdr_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, (NULL == type->crt_dbg_ctx && NULL == type->dst_dbg_ctx)); /* Check for debugging context callback available */ - if(type->crt_dbg_ctx) { + if(type->crt_dbg_ctx) /* Create debugging context */ if(NULL == (dbg_ctx = (type->crt_dbg_ctx)(f, dxpl_id, obj_addr))) HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "unable to create v2 B-tree debugging context") - } /* end if */ - /* - * Load the B-tree header. - */ - cache_udata.f = f; - cache_udata.addr = addr; - cache_udata.ctx_udata = dbg_ctx; - cache_udata.parent = NULL; - if(NULL == (hdr = (H5B2_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, &cache_udata, H5AC__READ_ONLY_FLAG))) + /* Load the B-tree header */ + if(NULL == (hdr = H5B2__hdr_protect(f, dxpl_id, addr, dbg_ctx, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree header") /* Set file pointer for this B-tree operation */ @@ -181,11 +173,8 @@ H5B2__hdr_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, done: if(dbg_ctx && (type->dst_dbg_ctx)(dbg_ctx) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTRELEASE, FAIL, "unable to release v2 B-tree debugging context") - if(hdr) { - hdr->f = NULL; - if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_HDR, addr, hdr, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree header") - } /* end if */ + if(hdr && H5B2__hdr_unprotect(hdr, dxpl_id, H5AC__NO_FLAGS_SET) < 0) + HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release v2 B-tree header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__hdr_debug() */ @@ -213,7 +202,6 @@ H5B2__int_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, void *dbg_ctx = NULL; /* v2 B-tree debugging context */ unsigned u; /* Local index variable */ char temp_str[128]; /* Temporary string, for formatting */ - H5B2_hdr_cache_ud_t cache_udata; /* User-data for callback */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -240,15 +228,9 @@ H5B2__int_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "unable to create v2 B-tree debugging context") } /* end if */ - /* - * Load the B-tree header. - */ - cache_udata.f = f; - cache_udata.addr = hdr_addr; - cache_udata.ctx_udata = dbg_ctx; - cache_udata.parent = NULL; - if(NULL == (hdr = (H5B2_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, hdr_addr, &cache_udata, H5AC__READ_ONLY_FLAG))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree header") + /* Load the B-tree header */ + if(NULL == (hdr = H5B2__hdr_protect(f, dxpl_id, hdr_addr, dbg_ctx, H5AC__READ_ONLY_FLAG))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load v2 B-tree header") /* Set file pointer for this B-tree operation */ hdr->f = f; @@ -311,11 +293,8 @@ H5B2__int_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, done: if(dbg_ctx && (type->dst_dbg_ctx)(dbg_ctx) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTRELEASE, FAIL, "unable to release v2 B-tree debugging context") - if(hdr) { - hdr->f = NULL; - if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_HDR, hdr_addr, hdr, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree header") - } /* end if */ + if(hdr && H5B2__hdr_unprotect(hdr, dxpl_id, H5AC__NO_FLAGS_SET) < 0) + HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release v2 B-tree header") if(internal && H5AC_unprotect(f, dxpl_id, H5AC_BT2_INT, addr, internal, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree internal node") @@ -342,7 +321,6 @@ H5B2__leaf_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent { H5B2_hdr_t *hdr = NULL; /* B-tree header */ H5B2_leaf_t *leaf = NULL; /* B-tree leaf node */ - H5B2_hdr_cache_ud_t cache_udata; /* User-data for callback */ void *dbg_ctx = NULL; /* v2 B-tree debugging context */ unsigned u; /* Local index variable */ char temp_str[128]; /* Temporary string, for formatting */ @@ -366,21 +344,14 @@ H5B2__leaf_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent HDassert(nrec > 0); /* Check for debugging context callback available */ - if(type->crt_dbg_ctx) { + if(type->crt_dbg_ctx) /* Create debugging context */ if(NULL == (dbg_ctx = (type->crt_dbg_ctx)(f, dxpl_id, obj_addr))) HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "unable to create v2 B-tree debugging context") - } /* end if */ - /* - * Load the B-tree header. - */ - cache_udata.f = f; - cache_udata.addr = hdr_addr; - cache_udata.ctx_udata = dbg_ctx; - cache_udata.parent = NULL; - if(NULL == (hdr = (H5B2_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, hdr_addr, &cache_udata, H5AC__READ_ONLY_FLAG))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree header") + /* Load the B-tree header */ + if(NULL == (hdr = H5B2__hdr_protect(f, dxpl_id, hdr_addr, dbg_ctx, H5AC__READ_ONLY_FLAG))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect v2 B-tree header") /* Set file pointer for this B-tree operation */ hdr->f = f; @@ -426,11 +397,8 @@ H5B2__leaf_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent done: if(dbg_ctx && (type->dst_dbg_ctx)(dbg_ctx) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTRELEASE, FAIL, "unable to release v2 B-tree debugging context") - if(hdr) { - hdr->f = NULL; - if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_HDR, hdr_addr, hdr, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree header") - } /* end if */ + if(hdr && H5B2__hdr_unprotect(hdr, dxpl_id, H5AC__NO_FLAGS_SET) < 0) + HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree header") if(leaf && H5AC_unprotect(f, dxpl_id, H5AC_BT2_LEAF, addr, leaf, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree leaf node") diff --git a/src/H5B2hdr.c b/src/H5B2hdr.c index f3945bc..414d3c3 100644 --- a/src/H5B2hdr.c +++ b/src/H5B2hdr.c @@ -109,7 +109,7 @@ H5FL_SEQ_DEFINE(H5B2_node_info_t); */ herr_t H5B2__hdr_init(H5B2_hdr_t *hdr, const H5B2_create_t *cparam, void *ctx_udata, - void *parent, uint16_t depth) + uint16_t depth) { size_t sz_max_nrec; /* Temporary variable for range checking */ unsigned u_max_nrec_size; /* Temporary variable for range checking */ @@ -133,7 +133,7 @@ H5B2__hdr_init(H5B2_hdr_t *hdr, const H5B2_create_t *cparam, void *ctx_udata, HDassert(cparam->merge_percent < (cparam->split_percent / 2)); /* Initialize basic information */ - hdr->parent = parent; + hdr->parent = NULL; hdr->rc = 0; hdr->pending_delete = FALSE; @@ -220,10 +220,9 @@ HDmemset(hdr->page, 0, hdr->node_size); hdr->shadowed_internal = NULL; /* Create the callback context, if the callback exists */ - if(hdr->cls->crt_context) { + if(hdr->cls->crt_context) if(NULL == (hdr->cb_ctx = (*hdr->cls->crt_context)(ctx_udata))) HGOTO_ERROR(H5E_BTREE, H5E_CANTCREATE, FAIL, "unable to create v2 B-tree client callback context") - } /* end if */ done: if(ret_value < 0) @@ -295,7 +294,7 @@ done: */ haddr_t H5B2__hdr_create(H5F_t *f, hid_t dxpl_id, const H5B2_create_t *cparam, - void *ctx_udata, void *parent) + void *ctx_udata) { H5B2_hdr_t *hdr = NULL; /* The new v2 B-tree header information */ haddr_t ret_value = HADDR_UNDEF; /* Return value */ @@ -313,7 +312,7 @@ H5B2__hdr_create(H5F_t *f, hid_t dxpl_id, const H5B2_create_t *cparam, HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, HADDR_UNDEF, "allocation failed for B-tree header") /* Initialize shared B-tree info */ - if(H5B2__hdr_init(hdr, cparam, ctx_udata, parent, (uint16_t)0) < 0) + if(H5B2__hdr_init(hdr, cparam, ctx_udata, (uint16_t)0) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, HADDR_UNDEF, "can't create shared B-tree info") /* Allocate space for the header on disk */ @@ -499,6 +498,82 @@ done: /*------------------------------------------------------------------------- + * Function: H5B2__hdr_protect + * + * Purpose: Convenience wrapper around protecting v2 B-tree header + * + * Return: Non-NULL pointer to header on success/NULL on failure + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * Dec 18 2015 + * + *------------------------------------------------------------------------- + */ +H5B2_hdr_t * +H5B2__hdr_protect(H5F_t *f, hid_t dxpl_id, haddr_t hdr_addr, void *ctx_udata, + unsigned flags) +{ + H5B2_hdr_cache_ud_t udata; /* User data for cache callbacks */ + H5B2_hdr_t *ret_value = NULL; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Sanity check */ + HDassert(f); + HDassert(H5F_addr_defined(hdr_addr)); + + /* only the H5AC__READ_ONLY_FLAG may appear in flags */ + HDassert((flags & (unsigned)(~H5AC__READ_ONLY_FLAG)) == 0); + + /* Set up user data for cache callbacks */ + udata.f = f; + udata.addr = hdr_addr; + udata.ctx_udata = ctx_udata; + + /* Protect the header */ + if(NULL == (ret_value = (H5B2_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, hdr_addr, &udata, flags))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, NULL, "unable to load v2 B-tree header, address = %llu", (unsigned long long)hdr_addr) + ret_value->f = f; /* (Must be set again here, in case the header was already in the cache -QAK) */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5B2__hdr_protect() */ + + +/*------------------------------------------------------------------------- + * Function: H5B2__hdr_unprotect + * + * Purpose: Convenience wrapper around unprotecting v2 B-tree header + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * Dec 18 2015 + * + *------------------------------------------------------------------------- + */ +herr_t +H5B2__hdr_unprotect(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned cache_flags) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Sanity check */ + HDassert(hdr); + + /* Unprotect the header */ + if(H5AC_unprotect(hdr->f, dxpl_id, H5AC_BT2_HDR, hdr->addr, hdr, cache_flags) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to unprotect v2 B-tree header, address = %llu", (unsigned long long)hdr->addr) + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5B2__hdr_unprotect() */ + + +/*------------------------------------------------------------------------- * Function: H5B2__hdr_free * * Purpose: Free B-tree header info @@ -620,8 +695,8 @@ H5B2__hdr_delete(H5B2_hdr_t *hdr, hid_t dxpl_id) done: /* Unprotect the header with appropriate flags */ - if(H5AC_unprotect(hdr->f, dxpl_id, H5AC_BT2_HDR, hdr->addr, hdr, cache_flags) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree header") + if(H5B2__hdr_unprotect(hdr, dxpl_id, cache_flags) < 0) + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release v2 B-tree header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__hdr_delete() */ diff --git a/src/H5B2int.c b/src/H5B2int.c index f7927db..a33b8c3 100644 --- a/src/H5B2int.c +++ b/src/H5B2int.c @@ -3410,7 +3410,7 @@ H5B2__remove_internal_by_idx(H5B2_hdr_t *hdr, hid_t dxpl_id, hbool_t *depth_decreased, void *swap_loc, void *swap_parent, uint16_t depth, H5AC_info_t *parent_cache_info, unsigned *parent_cache_info_flags_ptr, H5B2_node_ptr_t *curr_node_ptr, H5B2_nodepos_t curr_pos, hsize_t n, - void *udata, H5B2_remove_t op, void *op_data) + H5B2_remove_t op, void *op_data) { H5AC_info_t *new_cache_info; /* Pointer to new cache info */ unsigned *new_cache_info_flags_ptr = NULL; @@ -3702,7 +3702,7 @@ H5B2__remove_internal_by_idx(H5B2_hdr_t *hdr, hid_t dxpl_id, /* Attempt to remove record from child node */ if(depth > 1) { if(H5B2__remove_internal_by_idx(hdr, dxpl_id, depth_decreased, swap_loc, swap_parent, (uint16_t)(depth - 1), - new_cache_info, new_cache_info_flags_ptr, new_node_ptr, next_pos, n, udata, op, op_data) < 0) + new_cache_info, new_cache_info_flags_ptr, new_node_ptr, next_pos, n, op, op_data) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDELETE, FAIL, "unable to remove record from B-tree internal node") } /* end if */ else { diff --git a/src/H5B2pkg.h b/src/H5B2pkg.h index 834ef3d..5691d5f 100644 --- a/src/H5B2pkg.h +++ b/src/H5B2pkg.h @@ -241,7 +241,6 @@ typedef enum H5B2_nodepos_t { /* Callback info for loading a free space header into the cache */ typedef struct H5B2_hdr_cache_ud_t { H5F_t *f; /* File that v2 b-tree header is within */ - void *parent; /* Flush dependency parent */ haddr_t addr; /* Address of B-tree header in the file */ void *ctx_udata; /* User-data for protecting */ } H5B2_hdr_cache_ud_t; @@ -313,14 +312,18 @@ H5_DLL herr_t H5B2__destroy_flush_depend(H5AC_info_t *parent_entry, /* Routines for managing B-tree header info */ H5_DLL H5B2_hdr_t *H5B2__hdr_alloc(H5F_t *f); H5_DLL haddr_t H5B2__hdr_create(H5F_t *f, hid_t dxpl_id, - const H5B2_create_t *cparam, void *ctx_udata, void *parent); + const H5B2_create_t *cparam, void *ctx_udata); H5_DLL herr_t H5B2__hdr_init(H5B2_hdr_t *hdr, const H5B2_create_t *cparam, - void *ctx_udata, void *parent, uint16_t depth); + void *ctx_udata, uint16_t depth); H5_DLL herr_t H5B2__hdr_incr(H5B2_hdr_t *hdr); H5_DLL herr_t H5B2__hdr_decr(H5B2_hdr_t *hdr); H5_DLL herr_t H5B2__hdr_fuse_incr(H5B2_hdr_t *hdr); H5_DLL size_t H5B2__hdr_fuse_decr(H5B2_hdr_t *hdr); H5_DLL herr_t H5B2__hdr_dirty(H5B2_hdr_t *hdr); +H5_DLL H5B2_hdr_t *H5B2__hdr_protect(H5F_t *f, hid_t dxpl_id, haddr_t hdr_addr, + void *ctx_udata, unsigned flags); +H5_DLL herr_t H5B2__hdr_unprotect(H5B2_hdr_t *hdr, hid_t dxpl_id, + unsigned cache_flags); H5_DLL herr_t H5B2__hdr_delete(H5B2_hdr_t *hdr, hid_t dxpl_id); /* Routines for operating on leaf nodes */ @@ -379,7 +382,7 @@ H5_DLL herr_t H5B2__remove_internal_by_idx(H5B2_hdr_t *hdr, hid_t dxpl_id, hbool_t *depth_decreased, void *swap_loc, void *swap_parent, uint16_t depth, H5AC_info_t *parent_cache_info, unsigned *parent_cache_info_flags_ptr, H5B2_node_ptr_t *curr_node_ptr, H5B2_nodepos_t curr_pos, hsize_t n, - void *udata, H5B2_remove_t op, void *op_data); + H5B2_remove_t op, void *op_data); H5_DLL herr_t H5B2__remove_leaf_by_idx(H5B2_hdr_t *hdr, hid_t dxpl_id, H5B2_node_ptr_t *curr_node_ptr, H5B2_nodepos_t curr_pos, void *parent, unsigned idx, H5B2_remove_t op, void *op_data); diff --git a/src/H5B2private.h b/src/H5B2private.h index 1047a29..cc60c9b 100644 --- a/src/H5B2private.h +++ b/src/H5B2private.h @@ -129,9 +129,8 @@ typedef struct H5B2_t H5B2_t; /* Library-private Function Prototypes */ /***************************************/ H5_DLL H5B2_t *H5B2_create(H5F_t *f, hid_t dxpl_id, const H5B2_create_t *cparam, - void *ctx_udata, void *parent); -H5_DLL H5B2_t *H5B2_open(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *ctx_udata, - void *parent); + void *ctx_udata); +H5_DLL H5B2_t *H5B2_open(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *ctx_udata); H5_DLL herr_t H5B2_get_addr(const H5B2_t *bt2, haddr_t *addr/*out*/); H5_DLL herr_t H5B2_insert(H5B2_t *bt2, hid_t dxpl_id, void *udata); H5_DLL herr_t H5B2_iterate(H5B2_t *bt2, hid_t dxpl_id, H5B2_operator_t op, @@ -147,20 +146,19 @@ H5_DLL herr_t H5B2_modify(H5B2_t *bt2, hid_t dxpl_id, void *udata, H5_DLL herr_t H5B2_remove(H5B2_t *b2, hid_t dxpl_id, void *udata, H5B2_remove_t op, void *op_data); H5_DLL herr_t H5B2_remove_by_idx(H5B2_t *bt2, hid_t dxpl_id, - H5_iter_order_t order, hsize_t idx, void *udata, H5B2_remove_t op, + H5_iter_order_t order, hsize_t idx, H5B2_remove_t op, void *op_data); H5_DLL herr_t H5B2_get_nrec(const H5B2_t *bt2, hsize_t *nrec); H5_DLL herr_t H5B2_size(H5B2_t *bt2, hid_t dxpl_id, hsize_t *btree_size); H5_DLL herr_t H5B2_close(H5B2_t *bt2, hid_t dxpl_id); H5_DLL herr_t H5B2_delete(H5F_t *f, hid_t dxpl_id, haddr_t addr, - void *ctx_udata, void *parent, H5B2_remove_t op, void *op_data); + void *ctx_udata, H5B2_remove_t op, void *op_data); H5_DLL htri_t H5B2_support(H5B2_t *bt2, hid_t dxpl_id, void *udata, H5AC_info_t *child); H5_DLL herr_t H5B2_unsupport(H5B2_t *bt2, hid_t dxpl_id, void *udata, H5AC_info_t *child); H5_DLL herr_t H5B2_depend(H5AC_info_t *parent_entry, H5B2_t *bt2); -H5_DLL herr_t H5B2_undepend(H5AC_info_t *parent_entry, H5B2_t *bt2); /* Statistics routines */ H5_DLL herr_t H5B2_stat_info(H5B2_t *bt2, H5B2_stat_t *info); diff --git a/src/H5B2test.c b/src/H5B2test.c index 654659b..a72dc30 100644 --- a/src/H5B2test.c +++ b/src/H5B2test.c @@ -67,8 +67,8 @@ static herr_t H5B2__test_store(void *nrecord, const void *udata); static herr_t H5B2__test_compare(const void *rec1, const void *rec2); static herr_t H5B2__test_encode(uint8_t *raw, const void *nrecord, void *ctx); static herr_t H5B2__test_decode(const uint8_t *raw, void *nrecord, void *ctx); -static herr_t H5B2__test_debug(FILE *stream, const H5F_t *f, hid_t dxpl_id, - int indent, int fwidth, const void *record, const void *_udata); +static herr_t H5B2__test_debug(FILE *stream, int indent, int fwidth, + const void *record, const void *_udata); static void *H5B2__test_crt_dbg_context(H5F_t *f, hid_t dxpl_id, haddr_t addr); @@ -295,8 +295,7 @@ H5B2__test_decode(const uint8_t *raw, void *nrecord, void *_ctx) *------------------------------------------------------------------------- */ static herr_t -H5B2__test_debug(FILE *stream, const H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, - int indent, int fwidth, const void *record, +H5B2__test_debug(FILE *stream, int indent, int fwidth, const void *record, const void H5_ATTR_UNUSED *_udata) { FUNC_ENTER_STATIC_NOERR diff --git a/src/H5Bdbg.c b/src/H5Bdbg.c index ed7ccf2..b22264d 100644 --- a/src/H5Bdbg.c +++ b/src/H5Bdbg.c @@ -92,7 +92,6 @@ H5B_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, int f cache_udata.f = f; cache_udata.type = type; cache_udata.rc_shared = rc_shared; - cache_udata.parent = NULL; if(NULL == (bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, &cache_udata, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree node") diff --git a/src/H5Bpkg.h b/src/H5Bpkg.h index e9cf69a..e645626 100644 --- a/src/H5Bpkg.h +++ b/src/H5Bpkg.h @@ -59,16 +59,12 @@ typedef struct H5B_t { haddr_t right; /*address of right sibling */ uint8_t *native; /*array of keys in native format */ haddr_t *child; /*2k child pointers */ - - /* Not stored on disk */ - void *parent; /* Flush dependency parent */ } H5B_t; /* Callback info for loading a B-tree node into the cache */ typedef struct H5B_cache_ud_t { H5F_t *f; /* File that B-tree node is within */ const struct H5B_class_t *type; /* Type of tree */ - void *parent; /* Flush dependency parent */ H5UC_t *rc_shared; /* Ref-counted shared info */ } H5B_cache_ud_t; diff --git a/src/H5Bprivate.h b/src/H5Bprivate.h index 3251a47..02fb82c 100644 --- a/src/H5Bprivate.h +++ b/src/H5Bprivate.h @@ -177,6 +177,6 @@ H5_DLL herr_t H5B_shared_free(void *_shared); H5_DLL herr_t H5B_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream, int indent, int fwidth, const H5B_class_t *type, void *udata); H5_DLL htri_t H5B_valid(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, - haddr_t addr, void *parent); + haddr_t addr); #endif /* _H5Bprivate_H */ diff --git a/src/H5C.c b/src/H5C.c index 448e6fe..5c3d9ef 100644 --- a/src/H5C.c +++ b/src/H5C.c @@ -3428,7 +3428,7 @@ done: ( H5C_validate_pinned_entry_list(cache_ptr) < 0 ) || ( H5C_validate_lru_list(cache_ptr) < 0 ) ) { - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, NULL, \ "an extreme sanity check failed on exit.\n"); } #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ @@ -7610,8 +7610,8 @@ H5C_flush_ring(H5F_t *f, hid_t dxpl_id, H5C_ring_t ring, unsigned flags) #if H5C_DO_EXTREME_SANITY_CHECKS if((H5C_validate_protected_entry_list(cache_ptr) < 0) || - (H5C_validate_pinned_entry_list(cache_ptr) < 0 || - (H5C_validate_lru_list(cache_ptr) < 0)) { + (H5C_validate_pinned_entry_list(cache_ptr) < 0) || + (H5C_validate_lru_list(cache_ptr) < 0)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on entry.\n"); #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ @@ -9439,10 +9439,8 @@ H5C_validate_lru_list(H5C_t * cache_ptr) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 1 failed") } - if ( ( cache_ptr->LRU_list_len < 0 ) || ( cache_ptr->LRU_list_size < 0 ) ) { - + if(cache_ptr->LRU_list_len < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 2 failed") - } if ( ( cache_ptr->LRU_list_len == 1 ) && @@ -9569,10 +9567,8 @@ H5C_validate_pinned_entry_list(H5C_t * cache_ptr) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 1 failed") } - if ( ( cache_ptr->pel_len < 0 ) || ( cache_ptr->pel_size < 0 ) ) { - + if(cache_ptr->pel_len < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 2 failed") - } if ( ( cache_ptr->pel_len == 1 ) && @@ -9692,21 +9688,12 @@ H5C_validate_protected_entry_list(H5C_t * cache_ptr) HDassert( cache_ptr ); HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); - if ( ( ( cache_ptr->pl_head_ptr == NULL ) - || - ( cache_ptr->pl_tail_ptr == NULL ) - ) - && - ( cache_ptr->pl_head_ptr != cache_ptr->pl_tail_ptr ) - ) { - + if(((cache_ptr->pl_head_ptr == NULL) || (cache_ptr->pl_tail_ptr == NULL)) + && (cache_ptr->pl_head_ptr != cache_ptr->pl_tail_ptr)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 1 failed") - } - - if ( ( cache_ptr->pl_len < 0 ) || ( cache_ptr->pl_size < 0 ) ) { + if(cache_ptr->pl_len < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 2 failed") - } if ( ( cache_ptr->pl_len == 1 ) && diff --git a/src/H5Dbtree.c b/src/H5Dbtree.c index 159acb0..8ef14b9 100644 --- a/src/H5Dbtree.c +++ b/src/H5Dbtree.c @@ -940,7 +940,6 @@ H5D__btree_idx_create(const H5D_chk_idx_info_t *idx_info) /* Initialize "user" data for B-tree callbacks, etc. */ udata.layout = idx_info->layout; udata.storage = idx_info->storage; - udata.rdcc = NULL; /* Create the v1 B-tree for the chunk index */ if(H5B_create(idx_info->f, idx_info->dxpl_id, H5B_BTREE, &udata, &(idx_info->storage->idx_addr)/*out*/) < 0) diff --git a/src/H5Dbtree2.c b/src/H5Dbtree2.c index 5ff174d..f286db2 100644 --- a/src/H5Dbtree2.c +++ b/src/H5Dbtree2.c @@ -107,6 +107,7 @@ static herr_t H5D__bt2_filt_debug(FILE *stream, int indent, int fwidth, /* Helper routine */ static herr_t H5D__bt2_idx_open(const H5D_chk_idx_info_t *idx_info); +static herr_t H5D__btree2_idx_depend(const H5D_chk_idx_info_t *idx_info); /* Callback for H5B2_iterate() which is called in H5D__bt2_idx_iterate() */ static int H5D__bt2_idx_iterate_cb(const void *_record, void *_udata); @@ -735,6 +736,63 @@ H5D__bt2_idx_init(const H5D_chk_idx_info_t H5_ATTR_UNUSED *idx_info, /*------------------------------------------------------------------------- + * Function: H5D__btree2_idx_depend + * + * Purpose: Create flush dependency between v2 B-tree and dataset's + * object header. + * + * Return: Success: non-negative + * Failure: negative + * + * Programmer: Quincey Koziol + * Friday, December 18, 2015 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5D__btree2_idx_depend(const H5D_chk_idx_info_t *idx_info) +{ + H5O_loc_t oloc; /* Temporary object header location for dataset */ + H5O_proxy_t *oh_proxy = NULL; /* Dataset's object header proxy */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check args */ + HDassert(idx_info); + HDassert(idx_info->f); + HDassert(H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE); + HDassert(idx_info->pline); + HDassert(idx_info->layout); + HDassert(H5D_CHUNK_IDX_BT2 == idx_info->layout->idx_type); + HDassert(idx_info->storage); + HDassert(H5D_CHUNK_IDX_BT2 == idx_info->storage->idx_type); + HDassert(H5F_addr_defined(idx_info->storage->idx_addr)); + HDassert(idx_info->storage->u.btree2.bt2); + + /* Set up object header location for dataset */ + H5O_loc_reset(&oloc); + oloc.file = idx_info->f; + oloc.addr = idx_info->storage->u.btree.dset_ohdr_addr; + + /* Pin the dataset's object header proxy */ + if(NULL == (oh_proxy = H5O_pin_flush_dep_proxy(&oloc, idx_info->dxpl_id))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTPIN, FAIL, "unable to pin dataset object header proxy") + + /* Make the v2 B-tree a child flush dependency of the dataset's object header */ + if(H5B2_depend((H5AC_info_t *)oh_proxy, idx_info->storage->u.btree2.bt2) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTDEPEND, FAIL, "unable to create flush dependency on object header") + +done: + /* Unpin the dataset's object header proxy */ + if(oh_proxy && H5O_unpin_flush_dep_proxy(oh_proxy) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTUNPIN, FAIL, "unable to unpin dataset object header proxy") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5D__btree2_idx_depend() */ + + +/*------------------------------------------------------------------------- * Function: H5D__bt2_idx_open() * * Purpose: Opens an existing v2 B-tree. @@ -755,8 +813,6 @@ static herr_t H5D__bt2_idx_open(const H5D_chk_idx_info_t *idx_info) { H5D_bt2_ctx_ud_t u_ctx; /* user data for creating context */ - H5O_loc_t oloc; /* Temporary object header location for dataset */ - H5O_proxy_t *oh_proxy = NULL; /* Dataset's object header proxy */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -777,26 +833,16 @@ H5D__bt2_idx_open(const H5D_chk_idx_info_t *idx_info) u_ctx.chunk_size = idx_info->layout->size; u_ctx.dim = idx_info->layout->dim; - /* Check for SWMR writes to the file */ - if(H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE) { - /* Set up object header location for dataset */ - H5O_loc_reset(&oloc); - oloc.file = idx_info->f; - oloc.addr = idx_info->storage->u.btree.dset_ohdr_addr; - - /* Pin the dataset's object header proxy */ - if(NULL == (oh_proxy = H5O_pin_flush_dep_proxy(&oloc, idx_info->dxpl_id))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTPIN, FAIL, "unable to pin dataset object header proxy") - } /* end if */ - /* Open v2 B-tree for the chunk index */ - if(NULL == (idx_info->storage->u.btree2.bt2 = H5B2_open(idx_info->f, idx_info->dxpl_id, idx_info->storage->idx_addr , &u_ctx, oh_proxy))) + if(NULL == (idx_info->storage->u.btree2.bt2 = H5B2_open(idx_info->f, idx_info->dxpl_id, idx_info->storage->idx_addr, &u_ctx))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't open v2 B-tree for tracking chunked dataset") -done: - if(oh_proxy && H5O_unpin_flush_dep_proxy(oh_proxy) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTUNPIN, FAIL, "unable to unpin dataset object header proxy") + /* Check for SWMR writes to the file */ + if(H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE) + if(H5D__btree2_idx_depend(idx_info) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTDEPEND, FAIL, "unable to create flush dependency on object header") +done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__bt2_idx_open() */ @@ -817,8 +863,6 @@ H5D__bt2_idx_create(const H5D_chk_idx_info_t *idx_info) { H5B2_create_t bt2_cparam; /* v2 B-tree creation parameters */ H5D_bt2_ctx_ud_t u_ctx; /* data for context call */ - H5O_loc_t oloc; /* Temporary object header location for dataset */ - H5O_proxy_t *oh_proxy = NULL; /* Dataset's object header proxy */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -861,30 +905,20 @@ H5D__bt2_idx_create(const H5D_chk_idx_info_t *idx_info) u_ctx.chunk_size = idx_info->layout->size; u_ctx.dim = idx_info->layout->dim; - /* Check for SWMR writes to the file */ - if(H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE) { - /* Set up object header location for dataset */ - H5O_loc_reset(&oloc); - oloc.file = idx_info->f; - oloc.addr = idx_info->storage->u.btree.dset_ohdr_addr; - - /* Pin the dataset's object header proxy */ - if(NULL == (oh_proxy = H5O_pin_flush_dep_proxy(&oloc, idx_info->dxpl_id))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTPIN, FAIL, "unable to pin dataset object header proxy") - } /* end if */ - /* Create the v2 B-tree for the chunked dataset */ - if(NULL == (idx_info->storage->u.btree2.bt2 = H5B2_create(idx_info->f, idx_info->dxpl_id, &bt2_cparam, &u_ctx, oh_proxy))) + if(NULL == (idx_info->storage->u.btree2.bt2 = H5B2_create(idx_info->f, idx_info->dxpl_id, &bt2_cparam, &u_ctx))) HGOTO_ERROR(H5E_DATASET, H5E_CANTCREATE, FAIL, "can't create v2 B-tree for tracking chunked dataset") /* Retrieve the v2 B-tree's address in the file */ if(H5B2_get_addr(idx_info->storage->u.btree2.bt2, &(idx_info->storage->idx_addr)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get v2 B-tree address for tracking chunked dataset") -done: - if(oh_proxy && H5O_unpin_flush_dep_proxy(oh_proxy) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTUNPIN, FAIL, "unable to unpin dataset object header proxy") + /* Check for SWMR writes to the file */ + if(H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE) + if(H5D__btree2_idx_depend(idx_info) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTDEPEND, FAIL, "unable to create flush dependency on object header") +done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__bt2_idx_create() */ @@ -1345,8 +1379,6 @@ H5D__bt2_idx_delete(const H5D_chk_idx_info_t *idx_info) H5D_bt2_remove_ud_t remove_udata; /* User data for removal callback */ H5B2_remove_t remove_op; /* The removal callback */ H5D_bt2_ctx_ud_t u_ctx; /* data for context call */ - H5O_loc_t oloc; /* Temporary object header location for dataset */ - H5O_proxy_t *oh_proxy = NULL; /* Dataset's object header proxy */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1376,30 +1408,15 @@ H5D__bt2_idx_delete(const H5D_chk_idx_info_t *idx_info) else remove_op = H5D__bt2_remove_cb; - /* Check for SWMR writes to the file */ - if(H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE) { - /* Set up object header location for dataset */ - H5O_loc_reset(&oloc); - oloc.file = idx_info->f; - oloc.addr = idx_info->storage->u.btree.dset_ohdr_addr; - - /* Pin the dataset's object header proxy */ - if(NULL == (oh_proxy = H5O_pin_flush_dep_proxy(&oloc, idx_info->dxpl_id))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTPIN, FAIL, "unable to pin dataset object header proxy") - } /* end if */ - /* Delete the v2 B-tree */ /*(space in the file for each object is freed in the 'remove' callback) */ - if(H5B2_delete(idx_info->f, idx_info->dxpl_id, idx_info->storage->idx_addr, &u_ctx, oh_proxy, remove_op, &remove_udata) < 0) + if(H5B2_delete(idx_info->f, idx_info->dxpl_id, idx_info->storage->idx_addr, &u_ctx, remove_op, &remove_udata) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTDELETE, FAIL, "can't delete v2 B-tree") idx_info->storage->idx_addr = HADDR_UNDEF; } /* end if */ done: - if(oh_proxy && H5O_unpin_flush_dep_proxy(oh_proxy) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTUNPIN, FAIL, "unable to unpin dataset object header proxy") - FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__bt2_idx_delete() */ diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index 1310a97..7b5df07 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -1937,7 +1937,6 @@ H5D__chunk_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, /* Set chunk's [scaled] coordinates */ io_info->store->chunk.scaled = chunk_info->scaled; - /* Load the chunk into cache and lock it. */ /* Determine if we should use the chunk cache */ if((cacheable = H5D__chunk_cacheable(io_info, udata.chunk_block.offset, FALSE)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't tell if chunk is cacheable") @@ -3361,12 +3360,9 @@ H5D__chunk_lock(const H5D_io_info_t *io_info, H5D_chunk_ud_t *udata, if(NULL == (ent = H5FL_CALLOC(H5D_rdcc_ent_t))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, NULL, "can't allocate raw data chunk entry") - ent->locked = 0; ent->edge_chunk_state = disable_filters ? H5D_RDCC_DISABLE_FILTERS : 0; if(udata->new_unfilt_chunk) ent->edge_chunk_state |= H5D_RDCC_NEWLY_DISABLED_FILTERS; - ent->dirty = FALSE; - ent->deleted = FALSE; /* Initialize the new entry */ ent->chunk_block.offset = chunk_addr; @@ -3884,16 +3880,13 @@ H5D__chunk_allocate(const H5D_t *dset, hid_t dxpl_id, hbool_t full_overwrite, } /* end else */ while(!carry) { - /* None of the chunks should be allocated */ hbool_t need_insert = FALSE; /* Whether the chunk needs to be inserted into the index */ - /* Reset size of chunk in bytes, in case filtered size changes */ - /* chunk_size = orig_chunk_size; */ - /* Look up this chunk */ if(H5D__chunk_lookup(dset, dxpl_id, scaled, &udata) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "error looking up chunk address") #ifndef NDEBUG + /* None of the chunks should be allocated */ if(H5D_CHUNK_IDX_NONE != layout->storage.u.chunk.idx_type) HDassert(!H5F_addr_defined(udata.chunk_block.offset)); @@ -3961,7 +3954,6 @@ H5D__chunk_allocate(const H5D_t *dset, hid_t dxpl_id, hbool_t full_overwrite, udata.common.layout = &layout->u.chunk; udata.common.storage = &layout->storage.u.chunk; udata.common.scaled = scaled; - udata.common.rdcc = &dset->shared->cache.chunk; udata.chunk_block.offset = HADDR_UNDEF; H5_CHECKED_ASSIGN(udata.chunk_block.length, uint32_t, chunk_size, size_t); udata.filter_mask = filter_mask; @@ -4750,7 +4742,6 @@ H5D__chunk_prune_by_extent(H5D_t *dset, hid_t dxpl_id, const hsize_t *old_dim) /* Initialize user data for removal */ idx_udata.layout = &layout->u.chunk; idx_udata.storage = &layout->storage.u.chunk; - idx_udata.rdcc = rdcc; /* Determine if partial edge chunk filters are disabled */ disable_edge_filters = (layout->u.chunk.flags @@ -6177,12 +6168,11 @@ H5D__chunk_file_alloc(const H5D_chk_idx_info_t *idx_info, const H5F_block_t *old /* Release previous chunk */ /* Only free the old location if not doing SWMR writes - otherwise * we must keep the old chunk around in case a reader has an - * outdated version of the b-tree node + * outdated version of the B-tree node */ - if(!(H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE)) { + if(!(H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE)) if(H5MF_xfree(idx_info->f, H5FD_MEM_DRAW, idx_info->dxpl_id, old_chunk->offset, old_chunk->length) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to free chunk") - } alloc_chunk = TRUE; *need_modify = TRUE; } /* end if */ diff --git a/src/H5Dearray.c b/src/H5Dearray.c index 35de599..84c26bf 100644 --- a/src/H5Dearray.c +++ b/src/H5Dearray.c @@ -149,7 +149,6 @@ static herr_t H5D__earray_idx_dest(const H5D_chk_idx_info_t *idx_info); /* Generic extensible array routines */ static herr_t H5D__earray_idx_open(const H5D_chk_idx_info_t *idx_info); static herr_t H5D__earray_idx_depend(const H5D_chk_idx_info_t *idx_info); -static herr_t H5D__earray_idx_undepend(const H5D_chk_idx_info_t *idx_info); /*********************/ @@ -776,63 +775,6 @@ done: /*------------------------------------------------------------------------- - * Function: H5D__earray_idx_undepend - * - * Purpose: Remove flush dependency between extensible array and dataset's - * object header. - * - * Return: Success: non-negative - * Failure: negative - * - * Programmer: Quincey Koziol - * Tuesday, June 2, 2009 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5D__earray_idx_undepend(const H5D_chk_idx_info_t *idx_info) -{ - H5O_loc_t oloc; /* Temporary object header location for dataset */ - H5O_proxy_t *oh_proxy = NULL; /* Dataset's object header proxy */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - /* Check args */ - HDassert(idx_info); - HDassert(idx_info->f); - HDassert(H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE); - HDassert(idx_info->pline); - HDassert(idx_info->layout); - HDassert(H5D_CHUNK_IDX_EARRAY == idx_info->layout->idx_type); - HDassert(idx_info->storage); - HDassert(H5D_CHUNK_IDX_EARRAY == idx_info->storage->idx_type); - HDassert(H5F_addr_defined(idx_info->storage->idx_addr)); - HDassert(idx_info->storage->u.earray.ea); - - /* Set up object header location for dataset */ - H5O_loc_reset(&oloc); - oloc.file = idx_info->f; - oloc.addr = idx_info->storage->u.earray.dset_ohdr_addr; - - /* Pin the dataset's object header proxy */ - if(NULL == (oh_proxy = H5O_pin_flush_dep_proxy(&oloc, idx_info->dxpl_id))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTPIN, FAIL, "unable to pin dataset object header proxy") - - /* Remove the extensible array as a child flush dependency of the dataset's object header */ - if(H5EA_undepend((H5AC_info_t *)oh_proxy, idx_info->storage->u.earray.ea) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTUNDEPEND, FAIL, "unable to remove flush dependency on object header") - -done: - /* Unpin the dataset's object header proxy */ - if(oh_proxy && H5O_unpin_flush_dep_proxy(oh_proxy) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTUNPIN, FAIL, "unable to unpin dataset object header proxy") - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5D__earray_idx_undepend() */ - - -/*------------------------------------------------------------------------- * Function: H5D__earray_idx_open * * Purpose: Opens an existing extensible array. @@ -1386,7 +1328,6 @@ H5D__earray_idx_iterate(const H5D_chk_idx_info_t *idx_info, HDmemset(&udata, 0, sizeof udata); udata.common.layout = idx_info->layout; udata.common.storage = idx_info->storage; - udata.common.rdcc = NULL; HDmemset(&udata.chunk_rec, 0, sizeof(udata.chunk_rec)); udata.filtered = (idx_info->pline->nused > 0); if(!udata.filtered) { diff --git a/src/H5Dfarray.c b/src/H5Dfarray.c index a1dc23b..2958a66 100644 --- a/src/H5Dfarray.c +++ b/src/H5Dfarray.c @@ -150,7 +150,6 @@ static herr_t H5D__farray_idx_dest(const H5D_chk_idx_info_t *idx_info); /* Generic extensible array routines */ static herr_t H5D__farray_idx_open(const H5D_chk_idx_info_t *idx_info); static herr_t H5D__farray_idx_depend(const H5D_chk_idx_info_t *idx_info); -static herr_t H5D__farray_idx_undepend(const H5D_chk_idx_info_t *idx_info); /*********************/ /* Package Variables */ @@ -777,61 +776,6 @@ done: /*------------------------------------------------------------------------- - * Function: H5D__farray_idx_undepend - * - * Purpose: Remove flush dependency between fixed array and dataset's - * object header. - * - * Return: Success: non-negative - * Failure: negative - * - * Programmer: Copied and modified from H5Dearray.c - * - *------------------------------------------------------------------------- - */ -static herr_t -H5D__farray_idx_undepend(const H5D_chk_idx_info_t *idx_info) -{ - H5O_loc_t oloc; /* Temporary object header location for dataset */ - H5O_proxy_t *oh_proxy = NULL; /* Dataset's object header proxy */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - /* Check args */ - HDassert(idx_info); - HDassert(idx_info->f); - HDassert(H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE); - HDassert(idx_info->pline); - HDassert(idx_info->layout); - HDassert(H5D_CHUNK_IDX_FARRAY == idx_info->layout->idx_type); - HDassert(idx_info->storage); - HDassert(H5D_CHUNK_IDX_FARRAY == idx_info->storage->idx_type); - HDassert(H5F_addr_defined(idx_info->storage->idx_addr)); - HDassert(idx_info->storage->u.farray.fa); - - /* Set up object header location for dataset */ - H5O_loc_reset(&oloc); - oloc.file = idx_info->f; - oloc.addr = idx_info->storage->u.farray.dset_ohdr_addr; - - /* Pin the dataset's object header proxy */ - if(NULL == (oh_proxy = H5O_pin_flush_dep_proxy(&oloc, idx_info->dxpl_id))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTPIN, FAIL, "unable to pin dataset object header proxy") - - /* Remove the extensible array as a child flush dependency of the dataset's object header */ - if(H5FA_undepend((H5AC_info_t *)oh_proxy, idx_info->storage->u.farray.fa) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTUNDEPEND, FAIL, "unable to remove flush dependency on object header") - -done: - /* Unpin the dataset's object header proxy */ - if(oh_proxy && H5O_unpin_flush_dep_proxy(oh_proxy) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTUNPIN, FAIL, "unable to unpin dataset object header proxy") - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5D__farray_idx_undepend() */ - -/*------------------------------------------------------------------------- * Function: H5D__farray_idx_init * * Purpose: Initialize the indexing information for a dataset. @@ -1272,7 +1216,6 @@ H5D__farray_idx_iterate(const H5D_chk_idx_info_t *idx_info, HDmemset(&udata, 0, sizeof udata); udata.common.layout = idx_info->layout; udata.common.storage = idx_info->storage; - udata.common.rdcc = NULL; HDmemset(&udata.chunk_rec, 0, sizeof(udata.chunk_rec)); udata.filtered = (idx_info->pline->nused > 0); if(!udata.filtered) { diff --git a/src/H5Dint.c b/src/H5Dint.c index 8073d9d..ed0e63e 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -1940,6 +1940,141 @@ done: /*------------------------------------------------------------------------- + * Function: H5D_mult_refresh_close + * + * Purpose: Closing down the needed information when the dataset has + * multiple opens. (From H5O_refresh_metadata_close()) + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Vailin Choi; 12/24/15 + * + *------------------------------------------------------------------------- + */ +herr_t +H5D_mult_refresh_close(hid_t dset_id, hid_t dxpl_id) +{ + H5D_t *dataset; /* Dataset to refresh */ + herr_t ret_value = SUCCEED; /* return value */ + + FUNC_ENTER_NOAPI(FAIL) + + if(NULL == (dataset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") + + /* check args */ + HDassert(dataset && dataset->oloc.file && dataset->shared); + HDassert(dataset->shared->fo_count > 0); + + if(dataset->shared->fo_count > 1) { + /* Free cached information for each kind of dataset */ + switch(dataset->shared->layout.type) { + case H5D_CONTIGUOUS: + /* Free the data sieve buffer, if it's been allocated */ + if(dataset->shared->cache.contig.sieve_buf) + dataset->shared->cache.contig.sieve_buf = (unsigned char *)H5FL_BLK_FREE(sieve_buf,dataset->shared->cache.contig.sieve_buf); + break; + + case H5D_CHUNKED: + /* Check for skip list for iterating over chunks during I/O to close */ + if(dataset->shared->cache.chunk.sel_chunks) { + HDassert(H5SL_count(dataset->shared->cache.chunk.sel_chunks) == 0); + H5SL_close(dataset->shared->cache.chunk.sel_chunks); + dataset->shared->cache.chunk.sel_chunks = NULL; + } /* end if */ + + /* Check for cached single chunk dataspace */ + if(dataset->shared->cache.chunk.single_space) { + (void)H5S_close(dataset->shared->cache.chunk.single_space); + dataset->shared->cache.chunk.single_space = NULL; + } /* end if */ + + /* Check for cached single element chunk info */ + if(dataset->shared->cache.chunk.single_chunk_info) { + dataset->shared->cache.chunk.single_chunk_info = H5FL_FREE(H5D_chunk_info_t, dataset->shared->cache.chunk.single_chunk_info); + dataset->shared->cache.chunk.single_chunk_info = NULL; + } /* end if */ + break; + + case H5D_COMPACT: + /* Nothing special to do (info freed in the layout destroy) */ + break; + + case H5D_VIRTUAL: + break; + + case H5D_LAYOUT_ERROR: + case H5D_NLAYOUTS: + default: + HDassert("not implemented yet" && 0); +#ifdef NDEBUG + HGOTO_ERROR(H5E_IO, H5E_UNSUPPORTED, FAIL, "unsupported storage layout") +#endif /* NDEBUG */ + } /* end switch */ /*lint !e788 All appropriate cases are covered */ + + /* Destroy any cached layout information for the dataset */ + if(dataset->shared->layout.ops->dest && (dataset->shared->layout.ops->dest)(dataset, dxpl_id) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to destroy layout info") + + } /* end if */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5D_mult_refresh_close() */ + + +/*------------------------------------------------------------------------- + * Function: H5D_mult_refresh_reopen + * + * Purpose: Re-initialize the needed info when the dataset has multiple + * opens. (From H5O_refresh_metadata_reopen()) + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Vailin Choi; 12/24/15 + * + *------------------------------------------------------------------------- + */ +herr_t +H5D_mult_refresh_reopen(H5D_t *dataset, hid_t dxpl_id) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* check args */ + HDassert(dataset && dataset->oloc.file && dataset->shared); + HDassert(dataset->shared->fo_count > 0); + + if(dataset->shared->fo_count > 1) { + + /* Release dataspace info */ + if(H5S_close(dataset->shared->space) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to release dataspace") + + /* Re-load dataspace info */ + if(NULL == (dataset->shared->space = H5S_read(&(dataset->oloc), dxpl_id))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to load dataspace info from dataset header") + + /* Cache the dataset's dataspace info */ + if(H5D__cache_dataspace_info(dataset) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "can't cache dataspace info") + + if(H5O_msg_reset(H5O_LAYOUT_ID, &dataset->shared->layout) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTRESET, NULL, "unable to reset layout info") + + /* Re-load layout message info */ + if(NULL == H5O_msg_read(&(dataset->oloc), H5O_LAYOUT_ID, &(dataset->shared->layout), dxpl_id)) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to read data layout message") + } + +done: + FUNC_LEAVE_NOAPI(ret_value) + +} /* H5D_mult_refresh_reopen() */ + + +/*------------------------------------------------------------------------- * Function: H5D_oloc * * Purpose: Returns a pointer to the object location for a dataset. diff --git a/src/H5Dpkg.h b/src/H5Dpkg.h index 248808d..fe38dd4 100644 --- a/src/H5Dpkg.h +++ b/src/H5Dpkg.h @@ -276,9 +276,6 @@ typedef struct H5D_chunk_common_ud_t { const H5O_layout_chunk_t *layout; /* Chunk layout description */ const H5O_storage_chunk_t *storage; /* Chunk storage description */ const hsize_t *scaled; /* Scaled coordinates for a chunk */ - const struct H5D_rdcc_t *rdcc; /* Chunk cache. Only necessary if the index may - * be modified, and if any chunks in the dset - * may be cached */ } H5D_chunk_common_ud_t; /* B-tree callback info for various operations */ @@ -455,8 +452,6 @@ typedef struct H5D_shared_t { hid_t type_id; /* ID for dataset's datatype */ H5T_t *type; /* Datatype for this dataset */ H5S_t *space; /* Dataspace of this dataset */ - hbool_t space_dirty; /* Whether the dataspace info needs to be flushed to the file */ - hbool_t layout_dirty; /* Whether the layout info needs to be flushed to the file */ hid_t dcpl_id; /* Dataset creation property id */ H5D_dcpl_cache_t dcpl_cache; /* Cached DCPL values */ H5O_layout_t layout; /* Data layout */ @@ -715,11 +710,6 @@ H5_DLL herr_t H5D__chunk_bh_info(const H5O_loc_t *loc, hid_t dxpl_id, H5O_t *oh, H5_DLL herr_t H5D__chunk_dump_index(H5D_t *dset, hid_t dxpl_id, FILE *stream); H5_DLL herr_t H5D__chunk_delete(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5O_storage_t *store); -H5_DLL herr_t H5D__chunk_create_flush_dep(const H5D_rdcc_t *rdcc, - const H5O_layout_chunk_t *layout, const hsize_t offset[], void *parent); -H5_DLL herr_t H5D__chunk_update_flush_dep(const H5D_rdcc_t *rdcc, - const H5O_layout_chunk_t *layout, const hsize_t offset[], void *old_parent, - void *new_parent); H5_DLL herr_t H5D__chunk_direct_write(const H5D_t *dset, hid_t dxpl_id, uint32_t filters, hsize_t *offset, uint32_t data_size, const void *buf); #ifdef H5D_CHUNK_DEBUG @@ -766,17 +756,6 @@ H5_DLL herr_t H5D__fill_refill_vl(H5D_fill_buf_info_t *fb_info, size_t nelmts, hid_t dxpl_id); H5_DLL herr_t H5D__fill_term(H5D_fill_buf_info_t *fb_info); -/* Functions that operate on chunk proxy objects */ -H5_DLL herr_t H5D__chunk_proxy_create(H5D_t *dset, hid_t dxpl_id, - H5D_chunk_ud_t *udata, H5D_rdcc_ent_t *ent); -H5_DLL herr_t H5D__chunk_proxy_remove(const H5D_t *dset, hid_t dxpl_it, - H5D_rdcc_ent_t *ent); -H5_DLL herr_t H5D__chunk_proxy_mark(H5D_rdcc_ent_t *ent, hbool_t dirty); -H5_DLL herr_t H5D__chunk_proxy_create_flush_dep(H5D_rdcc_ent_t *ent, - void *parent); -H5_DLL herr_t H5D__chunk_proxy_update_flush_dep(H5D_rdcc_ent_t *ent, - void *old_parent, void *new_parent); - #ifdef H5_HAVE_PARALLEL #ifdef H5S_DEBUG diff --git a/src/H5Dprivate.h b/src/H5Dprivate.h index cb04f2e..4c5f914 100644 --- a/src/H5Dprivate.h +++ b/src/H5Dprivate.h @@ -173,6 +173,8 @@ typedef struct H5D_append_flush_t { H5_DLL herr_t H5D_init(void); H5_DLL H5D_t *H5D_open(const H5G_loc_t *loc, hid_t dapl_id, hid_t dxpl_id); H5_DLL herr_t H5D_close(H5D_t *dataset); +H5_DLL herr_t H5D_mult_refresh_close(hid_t dset_id, hid_t dxpl_id); +H5_DLL herr_t H5D_mult_refresh_reopen(H5D_t *dataset, hid_t dxpl_id); H5_DLL H5O_loc_t *H5D_oloc(H5D_t *dataset); H5_DLL H5G_name_t *H5D_nameof(H5D_t *dataset); H5_DLL H5T_t *H5D_typeof(const H5D_t *dset); diff --git a/src/H5EAhdr.c b/src/H5EAhdr.c index e60f804..46224f6 100644 --- a/src/H5EAhdr.c +++ b/src/H5EAhdr.c @@ -43,7 +43,7 @@ #include "H5Eprivate.h" /* Error handling */ #include "H5EApkg.h" /* Extensible Arrays */ #include "H5MFprivate.h" /* File memory management */ -#include "H5VMprivate.h" /* Vectors and arrays */ +#include "H5VMprivate.h" /* Vectors and arrays */ /****************/ @@ -619,7 +619,7 @@ END_FUNC(PKG) /* end H5EA__hdr_modified() */ * * Purpose: Convenience wrapper around protecting extensible array header * - * Return: Non-NULL pointer to index block on success/NULL on failure + * Return: Non-NULL pointer to header on success/NULL on failure * * Programmer: Quincey Koziol * koziol@hdfgroup.org @@ -650,6 +650,7 @@ H5EA__hdr_protect(H5F_t *f, hid_t dxpl_id, haddr_t ea_addr, void *ctx_udata, /* Protect the header */ if(NULL == (ret_value = (H5EA_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_EARRAY_HDR, ea_addr, &udata, flags))) H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array header, address = %llu", (unsigned long long)ea_addr) + ret_value->f = f; /* (Must be set again here, in case the header was already in the cache -QAK) */ CATCH diff --git a/src/H5EAprivate.h b/src/H5EAprivate.h index 5203af7..c00e118 100644 --- a/src/H5EAprivate.h +++ b/src/H5EAprivate.h @@ -143,7 +143,6 @@ H5_DLL herr_t H5EA_get_addr(const H5EA_t *ea, haddr_t *addr); H5_DLL herr_t H5EA_set(const H5EA_t *ea, hid_t dxpl_id, hsize_t idx, const void *elmt); H5_DLL herr_t H5EA_get(const H5EA_t *ea, hid_t dxpl_id, hsize_t idx, void *elmt); H5_DLL herr_t H5EA_depend(H5AC_info_t *parent_entry, H5EA_t *ea); -H5_DLL herr_t H5EA_undepend(H5AC_info_t *parent_entry, H5EA_t *ea); H5_DLL herr_t H5EA_iterate(H5EA_t *fa, hid_t dxpl_id, H5EA_operator_t op, void *udata); H5_DLL herr_t H5EA_close(H5EA_t *ea, hid_t dxpl_id); H5_DLL herr_t H5EA_delete(H5F_t *f, hid_t dxpl_id, haddr_t ea_addr, void *ctx_udata); diff --git a/src/H5F.c b/src/H5F.c index 09765cb..948eb7a 100644 --- a/src/H5F.c +++ b/src/H5F.c @@ -760,13 +760,6 @@ H5Fclose(hid_t file_id) if((nref = H5I_get_ref(file_id, FALSE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't get ID ref count") if(nref == 1) { - if(f->shared->sblock) { /* Clear status_flags */ - f->shared->sblock->status_flags &= ~H5F_SUPER_WRITE_ACCESS; - f->shared->sblock->status_flags &= ~H5F_SUPER_SWMR_WRITE_ACCESS; - /* Mark superblock dirty in cache, so change will get encoded */ - if(H5F_super_dirty(f) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTMARKDIRTY, FAIL, "unable to mark superblock as dirty") - } if(H5F_flush(f, H5AC_dxpl_id, FALSE) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush cache") } @@ -1640,13 +1633,13 @@ H5Fstart_swmr_write(hid_t file_id) HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush file's cached information") /* Get the # of opened named datatypes and attributes */ - if(H5F_get_obj_count(file, H5F_OBJ_LOCAL|H5F_OBJ_DATATYPE|H5F_OBJ_ATTR, FALSE, &nt_attr_count) < 0) + if(H5F_get_obj_count(file, H5F_OBJ_DATATYPE|H5F_OBJ_ATTR, FALSE, &nt_attr_count) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_BADITER, FAIL, "H5F_get_obj_count failed") if(nt_attr_count) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "named datatypes and/or attributes opened in the file") /* Get the # of opened datasets and groups */ - if(H5F_get_obj_count(file, H5F_OBJ_LOCAL|H5F_OBJ_GROUP|H5F_OBJ_DATASET, FALSE, &grp_dset_count) < 0) + if(H5F_get_obj_count(file, H5F_OBJ_GROUP|H5F_OBJ_DATASET, FALSE, &grp_dset_count) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_BADITER, FAIL, "H5F_get_obj_count failed") if(grp_dset_count) { @@ -1661,13 +1654,13 @@ H5Fstart_swmr_write(hid_t file_id) HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, FAIL, "can't allocate buffer for H5G_name_t") /* Get the list of opened object ids (groups & datasets) */ - if(H5F_get_obj_ids(file, H5F_OBJ_LOCAL|H5F_OBJ_GROUP|H5F_OBJ_DATASET, grp_dset_count, obj_ids, FALSE, &grp_dset_count) < 0) + if(H5F_get_obj_ids(file, H5F_OBJ_GROUP|H5F_OBJ_DATASET, grp_dset_count, obj_ids, FALSE, &grp_dset_count) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "H5F_get_obj_ids failed") /* Refresh opened objects (groups, datasets) in the file */ for(u = 0; u < grp_dset_count; u++) { H5O_loc_t *oloc; /* object location */ - + H5G_loc_t tmp_loc; /* Set up the id's group location */ obj_glocs[u].oloc = &obj_olocs[u]; obj_glocs[u].path = &obj_paths[u]; @@ -1677,9 +1670,13 @@ H5Fstart_swmr_write(hid_t file_id) if((oloc = H5O_get_loc(obj_ids[u])) == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an object") - /* Refresh (part 1) */ - if(H5O_refresh_metadata_close(obj_ids[u], *oloc, &obj_glocs[u], H5AC_dxpl_id) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CLOSEERROR, FAIL, "can't refresh-close object") + /* Make deep local copy of object's location information */ + H5G_loc(obj_ids[u], &tmp_loc); + H5G_loc_copy(&obj_glocs[u], &tmp_loc, H5_COPY_DEEP); + + /* Close the object */ + if(H5I_dec_ref(obj_ids[u]) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTCLOSEOBJ, FAIL, "decrementing object ID failed") } /* end for */ } /* end if */ @@ -1724,9 +1721,9 @@ H5Fstart_swmr_write(hid_t file_id) if(H5F_evict_cache_entries(file, H5AC_dxpl_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to evict file's cached information") - /* Refresh (part 2: reopen) the objects (groups & datasets) in the file */ + /* Refresh (reopen) the objects (groups & datasets) in the file */ for(u = 0; u < grp_dset_count; u++) { - if(H5O_refresh_metadata_reopen(obj_ids[u], &obj_glocs[u], H5AC_dxpl_id) < 0) + if(H5O_refresh_metadata_reopen(obj_ids[u], &obj_glocs[u], H5AC_dxpl_id, TRUE) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CLOSEERROR, FAIL, "can't refresh-close object") } diff --git a/src/H5FAhdr.c b/src/H5FAhdr.c index 3acf807..a71d92e 100644 --- a/src/H5FAhdr.c +++ b/src/H5FAhdr.c @@ -400,7 +400,7 @@ END_FUNC(PKG) /* end H5FA__hdr_modified() */ * * Purpose: Convenience wrapper around protecting fixed array header * - * Return: Non-NULL pointer to index block on success/NULL on failure + * Return: Non-NULL pointer to header on success/NULL on failure * * Programmer: Quincey Koziol * koziol@hdfgroup.org @@ -431,6 +431,7 @@ H5FA__hdr_protect(H5F_t *f, hid_t dxpl_id, haddr_t fa_addr, void *ctx_udata, /* Protect the header */ if(NULL == (ret_value = (H5FA_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_FARRAY_HDR, fa_addr, &udata, flags))) H5E_THROW(H5E_CANTPROTECT, "unable to protect fixed array header, address = %llu", (unsigned long long)fa_addr) + ret_value->f = f; /* (Must be set again here, in case the header was already in the cache -QAK) */ CATCH diff --git a/src/H5FAprivate.h b/src/H5FAprivate.h index 2ce4a1d..b7c141a 100644 --- a/src/H5FAprivate.h +++ b/src/H5FAprivate.h @@ -128,7 +128,6 @@ H5_DLL herr_t H5FA_get_addr(const H5FA_t *fa, haddr_t *addr); H5_DLL herr_t H5FA_set(const H5FA_t *fa, hid_t dxpl_id, hsize_t idx, const void *elmt); H5_DLL herr_t H5FA_get(const H5FA_t *fa, hid_t dxpl_id, hsize_t idx, void *elmt); H5_DLL herr_t H5FA_depend(H5AC_info_t *parent_entry, H5FA_t *fa); -H5_DLL herr_t H5FA_undepend(H5AC_info_t *parent_entry, H5FA_t *fa); H5_DLL herr_t H5FA_iterate(H5FA_t *fa, hid_t dxpl_id, H5FA_operator_t op, void *udata); H5_DLL herr_t H5FA_close(H5FA_t *fa, hid_t dxpl_id); H5_DLL herr_t H5FA_delete(H5F_t *f, hid_t dxpl_id, haddr_t fa_addr, void *ctx_udata); diff --git a/src/H5FS.c b/src/H5FS.c index 30ea330..bb45c75 100644 --- a/src/H5FS.c +++ b/src/H5FS.c @@ -1045,7 +1045,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5FA_undepend + * Function: H5FS_undepend * * Purpose: Remove a child flush dependency between the free space * manager's and another piece of metadata in the file. diff --git a/src/H5Fint.c b/src/H5Fint.c index cc693ca..b6cc1f1 100644 --- a/src/H5Fint.c +++ b/src/H5Fint.c @@ -633,19 +633,17 @@ H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get sieve buffer size") if(H5P_get(plist, H5F_ACS_LATEST_FORMAT_NAME, &(f->shared->latest_format)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get 'latest format' flag") - + /* Require the latest format to use SWMR */ + /* (Need to revisit this when the 1.10 release is made, and require + * 1.10 or later -QAK) + */ /* For latest format or SWMR_WRITE, activate all latest version support */ if((f->shared->latest_format) || (H5F_INTENT(f) & H5F_ACC_SWMR_WRITE)) f->shared->latest_flags |= H5F_LATEST_ALL_FLAGS; - if(H5P_get(plist, H5F_ACS_USE_MDC_LOGGING_NAME, &(f->shared->use_mdc_logging)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get 'use mdc logging' flag") if(H5P_get(plist, H5F_ACS_START_MDC_LOG_ON_ACCESS_NAME, &(f->shared->start_mdc_log_on_access)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get 'start mdc log on access' flag") - /* Require the latest format to use SWMR */ - /* (Need to revisit this when the 1.10 release is made, and require - * 1.10 or later -QAK) - */ if(H5P_get(plist, H5F_ACS_META_BLOCK_SIZE_NAME, &(f->shared->meta_aggr.alloc_size)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get metadata cache size") f->shared->meta_aggr.feature_flag = H5FD_FEAT_AGGREGATE_METADATA; @@ -1143,12 +1141,11 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, if(NULL == (lf = H5FD_open(name, flags, fapl_id, HADDR_UNDEF))) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file") - } /* end if */ - /* Place an advisory lock on the file */ + /* Place an advisory lock on the file & create the 'top' file structure */ if((H5FD_lock(lf, (hbool_t)((flags & H5F_ACC_RDWR) ? TRUE : FALSE)) < 0) || - (NULL == (file = H5F_new(NULL, flags, fcpl_id, fapl_id, lf)))) { + (NULL == (file = H5F_new(NULL, flags, fcpl_id, fapl_id, lf)))) { if(H5FD_close(lf) < 0) /* Closing will remove the lock */ HDONE_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to close low-level file info") HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to lock the file or initialize file structure") diff --git a/src/H5Gdense.c b/src/H5Gdense.c index 9f3a556..e8fa237 100644 --- a/src/H5Gdense.c +++ b/src/H5Gdense.c @@ -327,7 +327,7 @@ HDfprintf(stderr, "%s: fheap_id_len = %Zu\n", FUNC, fheap_id_len); (uint32_t)fheap_id_len; /* Fractal heap ID */ bt2_cparam.split_percent = H5G_NAME_BT2_SPLIT_PERC; bt2_cparam.merge_percent = H5G_NAME_BT2_MERGE_PERC; - if(NULL == (bt2_name = H5B2_create(f, dxpl_id, &bt2_cparam, NULL, NULL))) + if(NULL == (bt2_name = H5B2_create(f, dxpl_id, &bt2_cparam, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create v2 B-tree for name index") /* Retrieve the v2 B-tree's address in the file */ @@ -348,7 +348,7 @@ HDfprintf(stderr, "%s: linfo->name_bt2_addr = %a\n", FUNC, linfo->name_bt2_addr) (uint32_t)fheap_id_len; /* Fractal heap ID */ bt2_cparam.split_percent = H5G_CORDER_BT2_SPLIT_PERC; bt2_cparam.merge_percent = H5G_CORDER_BT2_MERGE_PERC; - if(NULL == (bt2_corder = H5B2_create(f, dxpl_id, &bt2_cparam, NULL, NULL))) + if(NULL == (bt2_corder = H5B2_create(f, dxpl_id, &bt2_cparam, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create v2 B-tree for creation order index") /* Retrieve the v2 B-tree's address in the file */ @@ -440,7 +440,7 @@ HDfprintf(stderr, "%s: HDstrlen(lnk->name) = %Zu, link_size = %Zu\n", FUNC, HDst HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "unable to insert link into fractal heap") /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(f, dxpl_id, linfo->name_bt2_addr, NULL, NULL))) + if(NULL == (bt2_name = H5B2_open(f, dxpl_id, linfo->name_bt2_addr, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Create the callback information for v2 B-tree record insertion */ @@ -462,7 +462,7 @@ HDfprintf(stderr, "%s: HDstrlen(lnk->name) = %Zu, link_size = %Zu\n", FUNC, HDst if(linfo->index_corder) { /* Open the creation order index v2 B-tree */ HDassert(H5F_addr_defined(linfo->corder_bt2_addr)); - if(NULL == (bt2_corder = H5B2_open(f, dxpl_id, linfo->corder_bt2_addr, NULL, NULL))) + if(NULL == (bt2_corder = H5B2_open(f, dxpl_id, linfo->corder_bt2_addr, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for creation order index") /* Insert the record into the creation order index v2 B-tree */ @@ -559,7 +559,7 @@ H5G__dense_lookup(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo, HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(f, dxpl_id, linfo->name_bt2_addr, NULL, NULL))) + if(NULL == (bt2_name = H5B2_open(f, dxpl_id, linfo->name_bt2_addr, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Construct the user data for v2 B-tree callback */ @@ -735,7 +735,7 @@ H5G__dense_lookup_by_idx(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo, HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Open the index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, dxpl_id, bt2_addr, NULL, NULL))) + if(NULL == (bt2 = H5B2_open(f, dxpl_id, bt2_addr, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for index") /* Construct the user data for v2 B-tree callback */ @@ -1044,7 +1044,7 @@ H5G__dense_iterate(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo, HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Open the index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, dxpl_id, bt2_addr, NULL, NULL))) + if(NULL == (bt2 = H5B2_open(f, dxpl_id, bt2_addr, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for index") /* Construct the user data for v2 B-tree iterator callback */ @@ -1246,7 +1246,7 @@ H5G__dense_get_name_by_idx(H5F_t *f, hid_t dxpl_id, H5O_linfo_t *linfo, HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Open the index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, dxpl_id, bt2_addr, NULL, NULL))) + if(NULL == (bt2 = H5B2_open(f, dxpl_id, bt2_addr, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for index") /* Set up the user data for the v2 B-tree 'record remove' callback */ @@ -1328,7 +1328,7 @@ H5G_dense_remove_fh_cb(const void *obj, size_t H5_ATTR_UNUSED obj_len, void *_ud H5G_bt2_ud_common_t bt2_udata; /* Info for B-tree callbacks */ /* Open the creation order index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(udata->f, udata->dxpl_id, udata->corder_bt2_addr, NULL, NULL))) + if(NULL == (bt2 = H5B2_open(udata->f, udata->dxpl_id, udata->corder_bt2_addr, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for creation order index") /* Set up the user data for the v2 B-tree 'record remove' callback */ @@ -1442,7 +1442,7 @@ H5G__dense_remove(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo, HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Open the name index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, dxpl_id, linfo->name_bt2_addr, NULL, NULL))) + if(NULL == (bt2 = H5B2_open(f, dxpl_id, linfo->name_bt2_addr, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Set up the user data for the v2 B-tree 'record remove' callback */ @@ -1579,7 +1579,7 @@ H5G_dense_remove_by_idx_bt2_cb(const void *_record, void *_bt2_udata) } /* end else */ /* Open the index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(bt2_udata->f, bt2_udata->dxpl_id, bt2_udata->other_bt2_addr, NULL, NULL))) + if(NULL == (bt2 = H5B2_open(bt2_udata->f, bt2_udata->dxpl_id, bt2_udata->other_bt2_addr, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for 'other' index") /* Set the common information for the v2 B-tree remove operation */ @@ -1684,7 +1684,7 @@ H5G__dense_remove_by_idx(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo, HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Open the index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, dxpl_id, bt2_addr, NULL, NULL))) + if(NULL == (bt2 = H5B2_open(f, dxpl_id, bt2_addr, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for index") /* Set up the user data for the v2 B-tree 'remove by index' callback */ @@ -1696,7 +1696,7 @@ H5G__dense_remove_by_idx(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo, udata.grp_full_path_r = grp_full_path_r; /* Remove the record from the name index v2 B-tree */ - if(H5B2_remove_by_idx(bt2, dxpl_id, order, n, NULL, H5G_dense_remove_by_idx_bt2_cb, &udata) < 0) + if(H5B2_remove_by_idx(bt2, dxpl_id, order, n, H5G_dense_remove_by_idx_bt2_cb, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTREMOVE, FAIL, "unable to remove link from indexed v2 B-tree") } /* end if */ else { /* Otherwise, we need to build a table of the links and sort it */ @@ -1778,7 +1778,7 @@ H5G__dense_delete(H5F_t *f, hid_t dxpl_id, H5O_linfo_t *linfo, hbool_t adj_link) udata.replace_names = FALSE; /* Delete the name index, adjusting the ref. count on links removed */ - if(H5B2_delete(f, dxpl_id, linfo->name_bt2_addr, NULL, NULL, H5G_dense_remove_bt2_cb, &udata) < 0) + if(H5B2_delete(f, dxpl_id, linfo->name_bt2_addr, NULL, H5G_dense_remove_bt2_cb, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to delete v2 B-tree for name index") /* Close the fractal heap */ @@ -1787,7 +1787,7 @@ H5G__dense_delete(H5F_t *f, hid_t dxpl_id, H5O_linfo_t *linfo, hbool_t adj_link) } /* end if */ else { /* Delete the name index, without adjusting the ref. count on the links */ - if(H5B2_delete(f, dxpl_id, linfo->name_bt2_addr, NULL, NULL, NULL, NULL) < 0) + if(H5B2_delete(f, dxpl_id, linfo->name_bt2_addr, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to delete v2 B-tree for name index") } /* end else */ linfo->name_bt2_addr = HADDR_UNDEF; @@ -1796,7 +1796,7 @@ H5G__dense_delete(H5F_t *f, hid_t dxpl_id, H5O_linfo_t *linfo, hbool_t adj_link) if(linfo->index_corder) { /* Delete the creation order index, without adjusting the ref. count on the links */ HDassert(H5F_addr_defined(linfo->corder_bt2_addr)); - if(H5B2_delete(f, dxpl_id, linfo->corder_bt2_addr, NULL, NULL, NULL, NULL) < 0) + if(H5B2_delete(f, dxpl_id, linfo->corder_bt2_addr, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to delete v2 B-tree for creation order index") linfo->corder_bt2_addr = HADDR_UNDEF; } /* end if */ diff --git a/src/H5Gobj.c b/src/H5Gobj.c index 4991967..92ad0af 100644 --- a/src/H5Gobj.c +++ b/src/H5Gobj.c @@ -342,7 +342,7 @@ H5G__obj_get_linfo(const H5O_loc_t *grp_oloc, H5O_linfo_t *linfo, hid_t dxpl_id) /* Check if we are using "dense" link storage */ if(H5F_addr_defined(linfo->fheap_addr)) { /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(grp_oloc->file, dxpl_id, linfo->name_bt2_addr, NULL, NULL))) + if(NULL == (bt2_name = H5B2_open(grp_oloc->file, dxpl_id, linfo->name_bt2_addr, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Retrieve # of records in "name" B-tree */ diff --git a/src/H5Goh.c b/src/H5Goh.c index dc6083c..bde540c 100644 --- a/src/H5Goh.c +++ b/src/H5Goh.c @@ -363,7 +363,7 @@ H5O_group_bh_info(const H5O_loc_t *loc, hid_t dxpl_id, H5O_t *oh, H5_ih_info_t * /* Check if name index available */ if(H5F_addr_defined(linfo.name_bt2_addr)) { /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(loc->file, dxpl_id, linfo.name_bt2_addr, NULL, NULL))) + if(NULL == (bt2_name = H5B2_open(loc->file, dxpl_id, linfo.name_bt2_addr, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Get name index B-tree size */ @@ -374,7 +374,7 @@ H5O_group_bh_info(const H5O_loc_t *loc, hid_t dxpl_id, H5O_t *oh, H5_ih_info_t * /* Check if creation order index available */ if(H5F_addr_defined(linfo.corder_bt2_addr)) { /* Open the creation order index v2 B-tree */ - if(NULL == (bt2_corder = H5B2_open(loc->file, dxpl_id, linfo.corder_bt2_addr, NULL, NULL))) + if(NULL == (bt2_corder = H5B2_open(loc->file, dxpl_id, linfo.corder_bt2_addr, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for creation order index") /* Get creation order index B-tree size */ diff --git a/src/H5Gpublic.h b/src/H5Gpublic.h index 10b07c0..9d8ade5 100644 --- a/src/H5Gpublic.h +++ b/src/H5Gpublic.h @@ -84,6 +84,8 @@ H5_DLL herr_t H5Gget_info_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5G_info_t *ginfo, hid_t lapl_id); H5_DLL herr_t H5Gclose(hid_t group_id); +H5_DLL herr_t H5Gflush(hid_t group_id); +H5_DLL herr_t H5Grefresh(hid_t group_id); /* Symbols defined for compatibility with previous versions of the HDF5 API. * @@ -167,8 +169,6 @@ H5_DLL herr_t H5Gget_objinfo(hid_t loc_id, const char *name, hbool_t follow_link, H5G_stat_t *statbuf/*out*/); H5_DLL ssize_t H5Gget_objname_by_idx(hid_t loc_id, hsize_t idx, char* name, size_t size); -H5_DLL herr_t H5Gflush(hid_t group_id); -H5_DLL herr_t H5Grefresh(hid_t group_id); H5_DLL H5G_obj_t H5Gget_objtype_by_idx(hid_t loc_id, hsize_t idx); #endif /* H5_NO_DEPRECATED_SYMBOLS */ diff --git a/src/H5Gstab.c b/src/H5Gstab.c index c8e5bc8..27fa67a 100644 --- a/src/H5Gstab.c +++ b/src/H5Gstab.c @@ -1067,10 +1067,10 @@ H5G__stab_valid(H5O_loc_t *grp_oloc, hid_t dxpl_id, H5O_stab_t *alt_stab) HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "unable to read symbol table message"); /* Check if the symbol table message's b-tree address is valid */ - if(H5B_valid(grp_oloc->file, dxpl_id, H5B_SNODE, stab.btree_addr, NULL) < 0) { + if(H5B_valid(grp_oloc->file, dxpl_id, H5B_SNODE, stab.btree_addr) < 0) { /* Address is invalid, try the b-tree address in the alternate symbol * table message */ - if(!alt_stab || H5B_valid(grp_oloc->file, dxpl_id, H5B_SNODE, alt_stab->btree_addr, NULL) < 0) + if(!alt_stab || H5B_valid(grp_oloc->file, dxpl_id, H5B_SNODE, alt_stab->btree_addr) < 0) HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "unable to locate b-tree") else { /* The alternate symbol table's b-tree address is valid. Adjust the diff --git a/src/H5Gtest.c b/src/H5Gtest.c index b021f9d..a8796fb 100644 --- a/src/H5Gtest.c +++ b/src/H5Gtest.c @@ -413,7 +413,7 @@ H5G__new_dense_info_test(hid_t gid, hsize_t *name_count, hsize_t *corder_count) HGOTO_DONE_TAG(FAIL, FAIL) /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(grp->oloc.file, dxpl_id, linfo.name_bt2_addr, NULL, NULL))) + if(NULL == (bt2_name = H5B2_open(grp->oloc.file, dxpl_id, linfo.name_bt2_addr, NULL))) HGOTO_ERROR_TAG(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Retrieve # of records in name index */ @@ -423,7 +423,7 @@ H5G__new_dense_info_test(hid_t gid, hsize_t *name_count, hsize_t *corder_count) /* Check if there is a creation order index */ if(H5F_addr_defined(linfo.corder_bt2_addr)) { /* Open the creation order index v2 B-tree */ - if(NULL == (bt2_corder = H5B2_open(grp->oloc.file, dxpl_id, linfo.corder_bt2_addr, NULL, NULL))) + if(NULL == (bt2_corder = H5B2_open(grp->oloc.file, dxpl_id, linfo.corder_bt2_addr, NULL))) HGOTO_ERROR_TAG(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for creation order index") /* Retrieve # of records in creation order index */ @@ -633,7 +633,7 @@ H5G__verify_cached_stab_test(H5O_loc_t *grp_oloc, H5G_entry_t *ent) HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "cached stab info does not match object header") /* Verify that the btree address is valid */ - if(H5B_valid(grp_oloc->file, H5AC_ind_dxpl_id, H5B_SNODE, stab.btree_addr, NULL) < 0) + if(H5B_valid(grp_oloc->file, dxpl_id, H5B_SNODE, stab.btree_addr) < 0) HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "b-tree address is invalid") /* Verify that the heap address is valid */ diff --git a/src/H5HFhdr.c b/src/H5HFhdr.c index d1426c6..42857c0 100644 --- a/src/H5HFhdr.c +++ b/src/H5HFhdr.c @@ -126,7 +126,6 @@ H5HF_hdr_alloc(H5F_t *f) /* Set the internal parameters for the heap */ hdr->f = f; - hdr->swmr_write = (H5F_INTENT(f) & H5F_ACC_SWMR_WRITE) > 0; hdr->sizeof_size = H5F_SIZEOF_SIZE(f); hdr->sizeof_addr = H5F_SIZEOF_ADDR(f); diff --git a/src/H5HFhuge.c b/src/H5HFhuge.c index 95095e9..2b01a74 100644 --- a/src/H5HFhuge.c +++ b/src/H5HFhuge.c @@ -157,16 +157,13 @@ H5HF_huge_bt2_create(H5HF_hdr_t *hdr, hid_t dxpl_id) bt2_cparam.merge_percent = H5HF_HUGE_BT2_MERGE_PERC; /* Create v2 B-tree for tracking 'huge' objects */ - if(NULL == (hdr->huge_bt2 = H5B2_create(hdr->f, dxpl_id, &bt2_cparam, hdr->f, NULL))) + if(NULL == (hdr->huge_bt2 = H5B2_create(hdr->f, dxpl_id, &bt2_cparam, hdr->f))) HGOTO_ERROR(H5E_HEAP, H5E_CANTCREATE, FAIL, "can't create v2 B-tree for tracking 'huge' heap objects") /* Retrieve the v2 B-tree's address in the file */ if(H5B2_get_addr(hdr->huge_bt2, &hdr->huge_bt2_addr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't get v2 B-tree address for tracking 'huge' heap objects") - /* Create a flush dependency between the 'huge' v2 B-tree and the fractal heap */ - if(hdr->swmr_write && H5B2_depend((H5AC_info_t *)hdr, hdr->huge_bt2) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTDEPEND, FAIL, "can't create flush dependency between fractal heap and 'huge' v2 B-tree") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_huge_bt2_create() */ @@ -342,7 +339,7 @@ HDfprintf(stderr, "%s: obj_size = %Zu\n", FUNC, obj_size); /* Check if v2 B-tree is open yet */ if(NULL == hdr->huge_bt2) { /* Open existing v2 B-tree */ - if(NULL == (hdr->huge_bt2 = H5B2_open(hdr->f, dxpl_id, hdr->huge_bt2_addr, hdr->f, NULL))) + if(NULL == (hdr->huge_bt2 = H5B2_open(hdr->f, dxpl_id, hdr->huge_bt2_addr, hdr->f))) HGOTO_ERROR(H5E_HEAP, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for tracking 'huge' heap objects") } /* end if */ } /* end else */ @@ -548,7 +545,7 @@ H5HF_huge_get_obj_len(H5HF_hdr_t *hdr, hid_t dxpl_id, const uint8_t *id, /* Check if v2 B-tree is open yet */ if(NULL == hdr->huge_bt2) { /* Open existing v2 B-tree */ - if(NULL == (hdr->huge_bt2 = H5B2_open(hdr->f, dxpl_id, hdr->huge_bt2_addr, hdr->f, NULL))) + if(NULL == (hdr->huge_bt2 = H5B2_open(hdr->f, dxpl_id, hdr->huge_bt2_addr, hdr->f))) HGOTO_ERROR(H5E_HEAP, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for tracking 'huge' heap objects") } /* end if */ @@ -632,7 +629,7 @@ H5HF__huge_get_obj_off(H5HF_hdr_t *hdr, hid_t dxpl_id, const uint8_t *id, /* Check if v2 B-tree is open yet */ if(NULL == hdr->huge_bt2) { /* Open existing v2 B-tree */ - if(NULL == (hdr->huge_bt2 = H5B2_open(hdr->f, dxpl_id, hdr->huge_bt2_addr, hdr->f, NULL))) + if(NULL == (hdr->huge_bt2 = H5B2_open(hdr->f, dxpl_id, hdr->huge_bt2_addr, hdr->f))) HGOTO_ERROR(H5E_HEAP, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for tracking 'huge' heap objects") } /* end if */ @@ -726,7 +723,7 @@ H5HF_huge_op_real(H5HF_hdr_t *hdr, hid_t dxpl_id, const uint8_t *id, /* Check if v2 B-tree is open yet */ if(NULL == hdr->huge_bt2) { /* Open existing v2 B-tree */ - if(NULL == (hdr->huge_bt2 = H5B2_open(hdr->f, dxpl_id, hdr->huge_bt2_addr, hdr->f, NULL))) + if(NULL == (hdr->huge_bt2 = H5B2_open(hdr->f, dxpl_id, hdr->huge_bt2_addr, hdr->f))) HGOTO_ERROR(H5E_HEAP, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for tracking 'huge' heap objects") } /* end if */ @@ -874,7 +871,7 @@ H5HF_huge_write(H5HF_hdr_t *hdr, hid_t dxpl_id, const uint8_t *id, /* Check if v2 B-tree is open yet */ if(NULL == hdr->huge_bt2) { /* Open existing v2 B-tree */ - if(NULL == (hdr->huge_bt2 = H5B2_open(hdr->f, dxpl_id, hdr->huge_bt2_addr, hdr->f, NULL))) + if(NULL == (hdr->huge_bt2 = H5B2_open(hdr->f, dxpl_id, hdr->huge_bt2_addr, hdr->f))) HGOTO_ERROR(H5E_HEAP, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for tracking 'huge' heap objects") } /* end if */ @@ -1004,7 +1001,7 @@ H5HF_huge_remove(H5HF_hdr_t *hdr, hid_t dxpl_id, const uint8_t *id) /* Check if v2 B-tree is open yet */ if(NULL == hdr->huge_bt2) { /* Open existing v2 B-tree */ - if(NULL == (hdr->huge_bt2 = H5B2_open(hdr->f, dxpl_id, hdr->huge_bt2_addr, hdr->f, NULL))) + if(NULL == (hdr->huge_bt2 = H5B2_open(hdr->f, dxpl_id, hdr->huge_bt2_addr, hdr->f))) HGOTO_ERROR(H5E_HEAP, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for tracking 'huge' heap objects") } /* end if */ @@ -1125,13 +1122,9 @@ H5HF_huge_term(H5HF_hdr_t *hdr, hid_t dxpl_id) /* Sanity check */ HDassert(hdr->huge_size == 0); - /* Destroy the flush dependency between the 'huge' v2 B-tree and the fractal heap */ - if(hdr->swmr_write && H5B2_undepend((H5AC_info_t *)hdr, hdr->huge_bt2) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTUNDEPEND, FAIL, "can't destroy flush dependency between fractal heap and 'huge' v2 B-tree") - /* Delete the v2 B-tree */ /* (any v2 B-tree class will work here) */ - if(H5B2_delete(hdr->f, dxpl_id, hdr->huge_bt2_addr, hdr->f, NULL, NULL, NULL) < 0) + if(H5B2_delete(hdr->f, dxpl_id, hdr->huge_bt2_addr, hdr->f, NULL, NULL) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDELETE, FAIL, "can't delete v2 B-tree") /* Reset the information about 'huge' objects in the file */ @@ -1199,7 +1192,7 @@ H5HF_huge_delete(H5HF_hdr_t *hdr, hid_t dxpl_id) } /* end else */ /* Delete the v2 B-tree */ - if(H5B2_delete(hdr->f, dxpl_id, hdr->huge_bt2_addr, hdr->f, NULL, op, &udata) < 0) + if(H5B2_delete(hdr->f, dxpl_id, hdr->huge_bt2_addr, hdr->f, op, &udata) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDELETE, FAIL, "can't delete v2 B-tree") done: diff --git a/src/H5HFpkg.h b/src/H5HFpkg.h index b4e6558..15b62e2 100644 --- a/src/H5HFpkg.h +++ b/src/H5HFpkg.h @@ -360,7 +360,6 @@ typedef struct H5HF_hdr_t { uint8_t heap_off_size; /* Size of heap offsets (in bytes) */ uint8_t heap_len_size; /* Size of heap ID lengths (in bytes) */ hbool_t checked_filters; /* TRUE if pipeline passes can_apply checks */ - hbool_t swmr_write; /* Flag indicating the file is opened with SWMR-write access */ } H5HF_hdr_t; /* Common indirect block doubling table entry */ diff --git a/src/H5HFstat.c b/src/H5HFstat.c index b54a191..303b1f4 100644 --- a/src/H5HFstat.c +++ b/src/H5HFstat.c @@ -156,7 +156,7 @@ H5HF_size(const H5HF_t *fh, hid_t dxpl_id, hsize_t *heap_size) /* Check for B-tree storage of huge objects in fractal heap */ if(H5F_addr_defined(hdr->huge_bt2_addr)) { /* Open the huge object index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(hdr->f, dxpl_id, hdr->huge_bt2_addr, hdr->f, NULL))) + if(NULL == (bt2 = H5B2_open(hdr->f, dxpl_id, hdr->huge_bt2_addr, hdr->f))) HGOTO_ERROR(H5E_HEAP, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for tracking 'huge' objects") /* Get the B-tree storage */ diff --git a/src/H5Oainfo.c b/src/H5Oainfo.c index 9e32af4..44c6611 100644 --- a/src/H5Oainfo.c +++ b/src/H5Oainfo.c @@ -339,7 +339,6 @@ static herr_t H5O_ainfo_delete(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, void *_mesg) { H5O_ainfo_t *ainfo = (H5O_ainfo_t *)_mesg; - H5O_proxy_t *oh_proxy = NULL; /* Object header proxy */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -351,22 +350,12 @@ H5O_ainfo_delete(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, void *_mesg) /* If the object is using "dense" attribute storage, delete it */ if(H5F_addr_defined(ainfo->fheap_addr)) { - /* Check for SWMR writes to the file */ - if(H5F_INTENT(f) & H5F_ACC_SWMR_WRITE) - /* Pin the attribute's object header proxy */ - if(NULL == (oh_proxy = H5O_pin_flush_dep_proxy_oh(f, dxpl_id, open_oh))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTPIN, FAIL, "unable to pin object header proxy") - /* Delete the attribute */ - if(H5A_dense_delete(f, dxpl_id, ainfo, oh_proxy) < 0) + if(H5A_dense_delete(f, dxpl_id, ainfo) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to free dense attribute storage") } /* end if */ done: - /* Release resources */ - if(oh_proxy && H5O_unpin_flush_dep_proxy(oh_proxy) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTUNPIN, FAIL, "unable to unpin attribute object header proxy") - FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_ainfo_delete() */ @@ -449,9 +438,7 @@ H5O_ainfo_copy_file(H5F_t *file_src, void *mesg_src, H5F_t *file_dst, /* Set copied metadata tag */ H5_BEGIN_TAG(dxpl_id, H5AC__COPIED_TAG, NULL); - /*!FIXME Must pass something for the parent, once we have a way to - * depend on an object being copied (ohdr proxy?) -NAF */ - if(H5A_dense_create(file_dst, dxpl_id, ainfo_dst, NULL) < 0) + if(H5A_dense_create(file_dst, dxpl_id, ainfo_dst) < 0) HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTINIT, NULL, "unable to create dense storage for attributes") /* Reset metadata tag */ diff --git a/src/H5Oattribute.c b/src/H5Oattribute.c index a11e6dc..9b494a1 100644 --- a/src/H5Oattribute.c +++ b/src/H5Oattribute.c @@ -220,7 +220,6 @@ herr_t H5O_attr_create(const H5O_loc_t *loc, hid_t dxpl_id, H5A_t *attr) { H5O_t *oh = NULL; /* Pointer to actual object header */ - H5O_proxy_t *oh_proxy = NULL; /* Object header proxy */ H5O_ainfo_t ainfo; /* Attribute information for object */ htri_t shared_mesg; /* Should this message be stored in the Shared Message table? */ herr_t ret_value = SUCCEED; /* Return value */ @@ -281,14 +280,8 @@ H5O_attr_create(const H5O_loc_t *loc, hid_t dxpl_id, H5A_t *attr) H5O_iter_cvt_t udata; /* User data for callback */ H5O_mesg_operator_t op; /* Wrapper for operator */ - /* Check for SWMR writes to the file */ - if(H5F_INTENT(loc->file) & H5F_ACC_SWMR_WRITE) - /* Pin the attribute's object header proxy */ - if(NULL == (oh_proxy = H5O_pin_flush_dep_proxy_oh(loc->file, dxpl_id, oh))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTPIN, FAIL, "unable to pin object header proxy") - /* Create dense storage for attributes */ - if(H5A_dense_create(loc->file, dxpl_id, &ainfo, oh_proxy) < 0) + if(H5A_dense_create(loc->file, dxpl_id, &ainfo) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to create dense storage for attributes") /* Set up user data for callback */ @@ -401,8 +394,6 @@ H5O_attr_create(const H5O_loc_t *loc, hid_t dxpl_id, H5A_t *attr) HGOTO_ERROR(H5E_ATTR, H5E_CANTUPDATE, FAIL, "unable to update time on object") done: - if(oh_proxy && H5O_unpin_flush_dep_proxy(oh_proxy) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTUNPIN, FAIL, "unable to unpin attribute object header proxy") if(oh && H5O_unpin(oh) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTUNPIN, FAIL, "unable to unpin object header") @@ -480,7 +471,6 @@ H5A_t * H5O_attr_open_by_name(const H5O_loc_t *loc, const char *name, hid_t dxpl_id) { H5O_t *oh = NULL; /* Pointer to actual object header */ - H5O_proxy_t *oh_proxy = NULL; /* Object header proxy */ H5O_ainfo_t ainfo; /* Attribute information for object */ H5A_t *exist_attr = NULL; /* Existing opened attribute object */ H5A_t *opened_attr = NULL; /* Newly opened attribute object */ @@ -517,14 +507,8 @@ H5O_attr_open_by_name(const H5O_loc_t *loc, const char *name, hid_t dxpl_id) else { /* Check for attributes in dense storage */ if(H5F_addr_defined(ainfo.fheap_addr)) { - /* Check for SWMR writes to the file */ - if(H5F_INTENT(loc->file) & H5F_ACC_SWMR_WRITE) - /* Pin the attribute's object header proxy */ - if(NULL == (oh_proxy = H5O_pin_flush_dep_proxy_oh(loc->file, dxpl_id, oh))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTPIN, NULL, "unable to pin object header proxy") - /* Open attribute with dense storage */ - if(NULL == (opened_attr = H5A_dense_open(loc->file, dxpl_id, &ainfo, name, oh_proxy))) + if(NULL == (opened_attr = H5A_dense_open(loc->file, dxpl_id, &ainfo, name))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "can't open attribute") } /* end if */ else { @@ -559,8 +543,6 @@ H5O_attr_open_by_name(const H5O_loc_t *loc, const char *name, hid_t dxpl_id) ret_value = opened_attr; done: - if(oh_proxy && H5O_unpin_flush_dep_proxy(oh_proxy) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTUNPIN, NULL, "unable to unpin attribute object header proxy") if(oh && H5O_unprotect(loc, dxpl_id, oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTUNPROTECT, NULL, "unable to release object header") @@ -1199,7 +1181,6 @@ H5O_attr_rename(const H5O_loc_t *loc, hid_t dxpl_id, const char *old_name, const char *new_name) { H5O_t *oh = NULL; /* Pointer to actual object header */ - H5O_proxy_t *oh_proxy = NULL; /* Attribute's object header proxy */ H5O_ainfo_t ainfo; /* Attribute information for object */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1224,14 +1205,8 @@ H5O_attr_rename(const H5O_loc_t *loc, hid_t dxpl_id, const char *old_name, /* Check for attributes stored densely */ if(H5F_addr_defined(ainfo.fheap_addr)) { - /* Check for SWMR writes to the file */ - if(H5F_INTENT(loc->file) & H5F_ACC_SWMR_WRITE) - /* Pin the attribute's object header proxy */ - if(NULL == (oh_proxy = H5O_pin_flush_dep_proxy_oh(loc->file, dxpl_id, oh))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTPIN, FAIL, "unable to pin attribute object header proxy") - /* Rename the attribute data in dense storage */ - if(H5A_dense_rename(loc->file, dxpl_id, &ainfo, old_name, new_name, oh_proxy) < 0) + if(H5A_dense_rename(loc->file, dxpl_id, &ainfo, old_name, new_name) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTUPDATE, FAIL, "error updating attribute") } /* end if */ else { @@ -1271,8 +1246,6 @@ H5O_attr_rename(const H5O_loc_t *loc, hid_t dxpl_id, const char *old_name, HGOTO_ERROR(H5E_ATTR, H5E_CANTUPDATE, FAIL, "unable to update time on object") done: - if(oh_proxy && H5O_unpin_flush_dep_proxy(oh_proxy) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTUNPIN, FAIL, "unable to unpin attribute object header proxy") if(oh && H5O_unpin(oh) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTUNPIN, FAIL, "unable to unpin object header") @@ -1298,7 +1271,6 @@ H5O_attr_iterate_real(hid_t loc_id, const H5O_loc_t *loc, hid_t dxpl_id, hsize_t *last_attr, const H5A_attr_iter_op_t *attr_op, void *op_data) { H5O_t *oh = NULL; /* Pointer to actual object header */ - H5O_proxy_t *oh_proxy = NULL; /* Object header proxy */ H5O_ainfo_t ainfo; /* Attribute information for object */ H5A_attr_table_t atable = {0, NULL}; /* Table of attributes */ herr_t ret_value = FAIL; /* Return value */ @@ -1329,19 +1301,13 @@ H5O_attr_iterate_real(hid_t loc_id, const H5O_loc_t *loc, hid_t dxpl_id, if(skip > 0 && skip >= ainfo.nattrs) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index specified") - /* Check for SWMR writes to the file */ - if(H5F_INTENT(loc->file) & H5F_ACC_SWMR_WRITE) - /* Pin the attribute's object header proxy */ - if(NULL == (oh_proxy = H5O_pin_flush_dep_proxy_oh(loc->file, dxpl_id, oh))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTPIN, FAIL, "unable to pin object header proxy") - /* Release the object header */ if(H5O_unprotect(loc, dxpl_id, oh, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") oh = NULL; /* Iterate over attributes in dense storage */ - if((ret_value = H5A_dense_iterate(loc->file, dxpl_id, loc_id, &ainfo, idx_type, order, skip, oh_proxy, last_attr, attr_op, op_data)) < 0) + if((ret_value = H5A_dense_iterate(loc->file, dxpl_id, loc_id, &ainfo, idx_type, order, skip, last_attr, attr_op, op_data)) < 0) HERROR(H5E_ATTR, H5E_BADITER, "error iterating over attributes"); } /* end if */ else { @@ -1365,8 +1331,6 @@ H5O_attr_iterate_real(hid_t loc_id, const H5O_loc_t *loc, hid_t dxpl_id, done: /* Release resources */ - if(oh_proxy && H5O_unpin_flush_dep_proxy(oh_proxy) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTUNPIN, FAIL, "unable to unpin attribute object header proxy") if(oh && H5O_unprotect(loc, dxpl_id, oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") if(atable.attrs && H5A_attr_release_table(&atable) < 0) @@ -1439,7 +1403,6 @@ H5O_attr_remove_update(const H5O_loc_t *loc, H5O_t *oh, H5O_ainfo_t *ainfo, hid_t dxpl_id) { H5A_attr_table_t atable = {0, NULL}; /* Table of attributes */ - H5O_proxy_t *oh_proxy = NULL; /* Object header proxy */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1457,14 +1420,8 @@ H5O_attr_remove_update(const H5O_loc_t *loc, H5O_t *oh, H5O_ainfo_t *ainfo, hbool_t can_convert = TRUE; /* Whether converting to attribute messages is possible */ size_t u; /* Local index */ - /* Check for SWMR writes to the file */ - if(H5F_INTENT(loc->file) & H5F_ACC_SWMR_WRITE) - /* Pin the attribute's object header proxy */ - if(NULL == (oh_proxy = H5O_pin_flush_dep_proxy_oh(loc->file, dxpl_id, oh))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTPIN, FAIL, "unable to pin object header proxy") - /* Build the table of attributes for this object */ - if(H5A_dense_build_table(loc->file, dxpl_id, ainfo, H5_INDEX_NAME, H5_ITER_NATIVE, oh_proxy, &atable) < 0) + if(H5A_dense_build_table(loc->file, dxpl_id, ainfo, H5_INDEX_NAME, H5_ITER_NATIVE, &atable) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "error building attribute table") /* Inspect attributes in table for ones that can't be converted back @@ -1519,7 +1476,7 @@ H5O_attr_remove_update(const H5O_loc_t *loc, H5O_t *oh, H5O_ainfo_t *ainfo, } /* end for */ /* Remove the dense storage */ - if(H5A_dense_delete(loc->file, dxpl_id, ainfo, oh_proxy) < 0) + if(H5A_dense_delete(loc->file, dxpl_id, ainfo) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete dense attribute storage") } /* end if */ } /* end if */ @@ -1538,8 +1495,6 @@ H5O_attr_remove_update(const H5O_loc_t *loc, H5O_t *oh, H5O_ainfo_t *ainfo, done: /* Release resources */ - if(oh_proxy && H5O_unpin_flush_dep_proxy(oh_proxy) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTUNPIN, FAIL, "unable to unpin attribute object header proxy") if(atable.attrs && H5A_attr_release_table(&atable) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "unable to release attribute table") @@ -1612,7 +1567,6 @@ herr_t H5O_attr_remove(const H5O_loc_t *loc, const char *name, hid_t dxpl_id) { H5O_t *oh = NULL; /* Pointer to actual object header */ - H5O_proxy_t *oh_proxy = NULL; /* Object header proxy */ H5O_ainfo_t ainfo; /* Attribute information for object */ htri_t ainfo_exists = FALSE; /* Whether the attribute info exists in the file */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1637,14 +1591,8 @@ H5O_attr_remove(const H5O_loc_t *loc, const char *name, hid_t dxpl_id) /* Check for attributes stored densely */ if(H5F_addr_defined(ainfo.fheap_addr)) { - /* Check for SWMR writes to the file */ - if(H5F_INTENT(loc->file) & H5F_ACC_SWMR_WRITE) - /* Pin the attribute's object header proxy */ - if(NULL == (oh_proxy = H5O_pin_flush_dep_proxy_oh(loc->file, dxpl_id, oh))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTPIN, FAIL, "unable to pin object header proxy") - /* Delete attribute from dense storage */ - if(H5A_dense_remove(loc->file, dxpl_id, &ainfo, name, oh_proxy) < 0) + if(H5A_dense_remove(loc->file, dxpl_id, &ainfo, name) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute in dense storage") } /* end if */ else { @@ -1678,8 +1626,6 @@ H5O_attr_remove(const H5O_loc_t *loc, const char *name, hid_t dxpl_id) HGOTO_ERROR(H5E_ATTR, H5E_CANTUPDATE, FAIL, "unable to update time on object") done: - if(oh_proxy && H5O_unpin_flush_dep_proxy(oh_proxy) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTUNPIN, FAIL, "unable to unpin attribute object header proxy") if(oh && H5O_unpin(oh) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTUNPIN, FAIL, "unable to unpin object header") @@ -1705,7 +1651,6 @@ H5O_attr_remove_by_idx(const H5O_loc_t *loc, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, hid_t dxpl_id) { H5O_t *oh = NULL; /* Pointer to actual object header */ - H5O_proxy_t *oh_proxy = NULL; /* Object header proxy */ H5O_ainfo_t ainfo; /* Attribute information for object */ htri_t ainfo_exists = FALSE; /* Whether the attribute info exists in the file */ H5A_attr_table_t atable = {0, NULL}; /* Table of attributes */ @@ -1730,14 +1675,8 @@ H5O_attr_remove_by_idx(const H5O_loc_t *loc, H5_index_t idx_type, /* Check for attributes stored densely */ if(H5F_addr_defined(ainfo.fheap_addr)) { - /* Check for SWMR writes to the file */ - if(H5F_INTENT(loc->file) & H5F_ACC_SWMR_WRITE) - /* Pin the attribute's object header proxy */ - if(NULL == (oh_proxy = H5O_pin_flush_dep_proxy_oh(loc->file, dxpl_id, oh))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTPIN, FAIL, "unable to pin object header proxy") - /* Delete attribute from dense storage */ - if(H5A_dense_remove_by_idx(loc->file, dxpl_id, &ainfo, idx_type, order, n, oh_proxy) < 0) + if(H5A_dense_remove_by_idx(loc->file, dxpl_id, &ainfo, idx_type, order, n) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute in dense storage") } /* end if */ else { @@ -1779,8 +1718,6 @@ H5O_attr_remove_by_idx(const H5O_loc_t *loc, H5_index_t idx_type, HGOTO_ERROR(H5E_ATTR, H5E_CANTUPDATE, FAIL, "unable to update time on object") done: - if(oh_proxy && H5O_unpin_flush_dep_proxy(oh_proxy) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTUNPIN, FAIL, "unable to unpin attribute object header proxy") if(oh && H5O_unpin(oh) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTUNPIN, FAIL, "unable to unpin object header") if(atable.attrs && H5A_attr_release_table(&atable) < 0) @@ -1900,7 +1837,6 @@ htri_t H5O_attr_exists(const H5O_loc_t *loc, const char *name, hid_t dxpl_id) { H5O_t *oh = NULL; /* Pointer to actual object header */ - H5O_proxy_t *oh_proxy = NULL; /* Object header proxy */ H5O_ainfo_t ainfo; /* Attribute information for object */ htri_t ret_value = FAIL; /* Return value */ @@ -1924,14 +1860,8 @@ H5O_attr_exists(const H5O_loc_t *loc, const char *name, hid_t dxpl_id) /* Check for attributes stored densely */ if(H5F_addr_defined(ainfo.fheap_addr)) { - /* Check for SWMR writes to the file */ - if(H5F_INTENT(loc->file) & H5F_ACC_SWMR_WRITE) - /* Pin the attribute's object header proxy */ - if(NULL == (oh_proxy = H5O_pin_flush_dep_proxy_oh(loc->file, dxpl_id, oh))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTPIN, FAIL, "unable to pin object header proxy") - /* Check if attribute exists in dense storage */ - if((ret_value = H5A_dense_exists(loc->file, dxpl_id, &ainfo, name, oh_proxy)) < 0) + if((ret_value = H5A_dense_exists(loc->file, dxpl_id, &ainfo, name)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_BADITER, FAIL, "error checking for existence of attribute") } /* end if */ else { @@ -1955,8 +1885,6 @@ H5O_attr_exists(const H5O_loc_t *loc, const char *name, hid_t dxpl_id) } /* end else */ done: - if(oh_proxy && H5O_unpin_flush_dep_proxy(oh_proxy) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTUNPIN, FAIL, "unable to unpin attribute object header proxy") if(oh && H5O_unprotect(loc, dxpl_id, oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") @@ -1982,7 +1910,6 @@ H5O_attr_bh_info(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5_ih_info_t *bh_info) H5HF_t *fheap = NULL; /* Fractal heap handle */ H5B2_t *bt2_name = NULL; /* v2 B-tree handle for name index */ H5B2_t *bt2_corder = NULL; /* v2 B-tree handle for creation order index */ - H5O_proxy_t *oh_proxy = NULL; /* Object header proxy */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2000,16 +1927,10 @@ H5O_attr_bh_info(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5_ih_info_t *bh_info) if((ainfo_exists = H5A_get_ainfo(f, dxpl_id, oh, &ainfo)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't check for attribute info message") else if(ainfo_exists > 0) { - /* Check for SWMR writes to the file */ - if(H5F_INTENT(f) & H5F_ACC_SWMR_WRITE) - /* Pin the attribute's object header proxy */ - if(NULL == (oh_proxy = H5O_pin_flush_dep_proxy_oh(f, dxpl_id, oh))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTPIN, FAIL, "unable to pin object header proxy") - /* Check if name index available */ if(H5F_addr_defined(ainfo.name_bt2_addr)) { /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(f, dxpl_id, ainfo.name_bt2_addr, NULL, oh_proxy))) + if(NULL == (bt2_name = H5B2_open(f, dxpl_id, ainfo.name_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Get name index B-tree size */ @@ -2020,7 +1941,7 @@ H5O_attr_bh_info(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5_ih_info_t *bh_info) /* Check if creation order index available */ if(H5F_addr_defined(ainfo.corder_bt2_addr)) { /* Open the creation order index v2 B-tree */ - if(NULL == (bt2_corder = H5B2_open(f, dxpl_id, ainfo.corder_bt2_addr, NULL, oh_proxy))) + if(NULL == (bt2_corder = H5B2_open(f, dxpl_id, ainfo.corder_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for creation order index") /* Get creation order index B-tree size */ @@ -2043,8 +1964,6 @@ H5O_attr_bh_info(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5_ih_info_t *bh_info) done: /* Release resources */ - if(oh_proxy && H5O_unpin_flush_dep_proxy(oh_proxy) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTUNPIN, FAIL, "unable to unpin attribute object header proxy") if(fheap && H5HF_close(fheap, dxpl_id) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTCLOSEOBJ, FAIL, "can't close fractal heap") if(bt2_name && H5B2_close(bt2_name, dxpl_id) < 0) diff --git a/src/H5Oflush.c b/src/H5Oflush.c index e9189f8..00fa937 100644 --- a/src/H5Oflush.c +++ b/src/H5Oflush.c @@ -218,10 +218,11 @@ done: * * Note: This is based on the original H5O_refresh_metadata() but * is split into 2 routines. - * (This is done so that H5Fstart_swmr_write() can use these + * This is done so that H5Fstart_swmr_write() can use these * 2 routines to refresh opened objects. This may be * restored back to the original code when H5Fstart_swmr_write() * uses a different approach to handle issues with opened objects. + * H5Fstart_swmr_write() no longer calls the 1st routine. (12/24/15) * * Return: Non-negative on success, negative on failure * @@ -241,6 +242,11 @@ H5O_refresh_metadata(hid_t oid, H5O_loc_t oloc, hid_t dxpl_id) FUNC_ENTER_NOAPI(FAIL) + /* If the file is opened with write access, + no need to perform refresh actions. */ + if(H5F_INTENT(oloc.file) & H5F_ACC_RDWR) + HGOTO_DONE(SUCCEED) + /* Create empty object location */ obj_loc.oloc = &obj_oloc; obj_loc.path = &obj_path; @@ -257,7 +263,7 @@ H5O_refresh_metadata(hid_t oid, H5O_loc_t oloc, hid_t dxpl_id) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to refresh object") /* Re-open the object, re-fetching its metadata */ - if((H5O_refresh_metadata_reopen(oid, &obj_loc, dxpl_id)) < 0) + if((H5O_refresh_metadata_reopen(oid, &obj_loc, dxpl_id, FALSE)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to refresh object") done: @@ -273,10 +279,11 @@ done: * * Purpose: This is the first part of the original routine H5O_refresh_metadata(). * (1) Save object location information. - * (2) Get object cork status - * (3) Close the object - * (4) Flush and evict object metadata - * (5) Re-cork the object if needed + * (2) Handle multiple dataset opens + * (3) Get object cork status + * (4) Close the object + * (5) Flush and evict object metadata + * (6) Re-cork the object if needed * * Return: Success: Non-negative * Failure: Negative @@ -303,6 +310,12 @@ H5O_refresh_metadata_close(hid_t oid, H5O_loc_t oloc, H5G_loc_t *obj_loc, hid_t H5G_loc_copy(obj_loc, &tmp_loc, H5_COPY_DEEP); } /* end if */ + /* Get object's type */ + if(H5I_get_type(oid) == H5I_DATASET) { + if(H5D_mult_refresh_close(oid, dxpl_id) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "unable to prepare refresh for dataset") + } + /* Retrieve tag for object */ if(H5O_oh_tag(&oloc, dxpl_id, &tag) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFLUSH, FAIL, "unable to get object header address") @@ -337,8 +350,8 @@ done: * Function: H5O_refresh_metadata_reopen * * Purpose: This is the second part of the original routine H5O_refresh_metadata(). - * (1) Re-open object with the saved object location information. - * (2) Re-register object ID with the re-opened object. + * (1) Re-open object with the saved object location information. + * (2) Re-register object ID with the re-opened object. * * Return: SUCCEED/FAIL * @@ -348,7 +361,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5O_refresh_metadata_reopen(hid_t oid, H5G_loc_t *obj_loc, hid_t dxpl_id) +H5O_refresh_metadata_reopen(hid_t oid, H5G_loc_t *obj_loc, hid_t dxpl_id, hbool_t start_swmr) { void *object = NULL; /* Dataset for this operation */ H5I_type_t type; @@ -379,6 +392,10 @@ H5O_refresh_metadata_reopen(hid_t oid, H5G_loc_t *obj_loc, hid_t dxpl_id) /* Re-open the dataset */ if(NULL == (object = H5D_open(obj_loc, H5P_DATASET_ACCESS_DEFAULT, dxpl_id))) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "unable to open dataset") + if(!start_swmr) { /* No need to handle multiple opens when H5Fstart_swmr_write() */ + if(H5D_mult_refresh_reopen(object, dxpl_id) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "unable to finish refresh for dataset") + } break; case(H5I_UNINIT): diff --git a/src/H5Olayout.c b/src/H5Olayout.c index a73a4d9..ca56255 100644 --- a/src/H5Olayout.c +++ b/src/H5Olayout.c @@ -307,7 +307,7 @@ H5O__layout_decode(H5F_t *f, hid_t H5_ATTR_UNUSED dxpl_id, H5O_t H5_ATTR_UNUSED if(mesg->u.chunk.flags & H5O_LAYOUT_CHUNK_SINGLE_INDEX_WITH_FILTER) { H5F_DECODE_LENGTH(f, p, mesg->storage.u.chunk.u.single.nbytes); UINT32DECODE(p, mesg->storage.u.chunk.u.single.filter_mask); - } + } /* end if */ /* Set the chunk operations */ mesg->storage.u.chunk.ops = H5D_COPS_SINGLE; diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h index 5cba610..3c7b78a 100644 --- a/src/H5Oprivate.h +++ b/src/H5Oprivate.h @@ -909,7 +909,7 @@ H5_DLL herr_t H5O_msg_unlock(const H5O_loc_t *loc, unsigned type_id, hid_t dxpl_ H5_DLL herr_t H5O_flush_common(H5O_loc_t *oloc, hid_t obj_id, hid_t dxpl_id); H5_DLL herr_t H5O_refresh_metadata(hid_t oid, H5O_loc_t oloc, hid_t dxpl_id); H5_DLL herr_t H5O_refresh_metadata_close(hid_t oid, H5O_loc_t oloc, H5G_loc_t *obj_loc, hid_t dxpl_id); -H5_DLL herr_t H5O_refresh_metadata_reopen(hid_t oid, H5G_loc_t *obj_loc, hid_t dxpl_id); +H5_DLL herr_t H5O_refresh_metadata_reopen(hid_t oid, H5G_loc_t *obj_loc, hid_t dxpl_id, hbool_t start_swmr); /* Object copying routines */ H5_DLL herr_t H5O_copy_header_map(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */, @@ -931,12 +931,6 @@ H5_DLL herr_t H5O_loc_hold_file(H5O_loc_t *loc); H5_DLL herr_t H5O_loc_free(H5O_loc_t *loc); H5_DLL H5O_loc_t *H5O_get_loc(hid_t id); -/* Storage operators */ -H5_DLL void *H5O_storage_copy(const void *mesg, void *dest); -H5_DLL herr_t H5O_storage_reset(void *mesg); -H5_DLL size_t H5O_storage_meta_size(const H5F_t *f, const H5O_storage_t *storage, - hbool_t include_compact_data); - /* EFL operators */ H5_DLL hsize_t H5O_efl_total_size(H5O_efl_t *efl); diff --git a/src/H5Otest.c b/src/H5Otest.c index a911469..1c149e3 100644 --- a/src/H5Otest.c +++ b/src/H5Otest.c @@ -159,7 +159,6 @@ htri_t H5O_is_attr_empty_test(hid_t oid) { H5O_t *oh = NULL; /* Object header */ - H5O_proxy_t *oh_proxy = NULL; /* Object header proxy */ H5B2_t *bt2_name = NULL; /* v2 B-tree handle for name index */ H5O_ainfo_t ainfo; /* Attribute information for object */ htri_t ainfo_exists = FALSE; /* Whether the attribute info exists in the file */ @@ -195,17 +194,11 @@ H5O_is_attr_empty_test(hid_t oid) /* Check for any messages in object header */ HDassert(nattrs == 0); - /* Check for SWMR writes to the file */ - if(H5F_INTENT(loc->file) & H5F_ACC_SWMR_WRITE) - /* Pin the attribute's object header proxy */ - if(NULL == (oh_proxy = H5O_pin_flush_dep_proxy_oh(loc->file, H5AC_ind_dxpl_id, oh))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTPIN, FAIL, "unable to pin object header proxy") - /* Set metadata tag in dxpl_id */ H5_BEGIN_TAG(H5AC_ind_dxpl_id, loc->addr, FAIL); /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(loc->file, H5AC_ind_dxpl_id, ainfo.name_bt2_addr, NULL, oh_proxy))) + if(NULL == (bt2_name = H5B2_open(loc->file, H5AC_ind_dxpl_id, ainfo.name_bt2_addr, NULL))) HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Reset metadata tag in dxpl_id */ @@ -230,8 +223,6 @@ done: /* Release resources */ if(bt2_name && H5B2_close(bt2_name, H5AC_ind_dxpl_id) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for name index") - if(oh_proxy && H5O_unpin_flush_dep_proxy(oh_proxy) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPIN, FAIL, "unable to unpin attribute object header proxy") if(oh && H5O_unprotect(loc, H5AC_ind_dxpl_id, oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") @@ -262,7 +253,6 @@ herr_t H5O_num_attrs_test(hid_t oid, hsize_t *nattrs) { H5O_t *oh = NULL; /* Object header */ - H5O_proxy_t *oh_proxy = NULL; /* Object header proxy */ H5B2_t *bt2_name = NULL; /* v2 B-tree handle for name index */ H5O_ainfo_t ainfo; /* Attribute information for object */ H5O_loc_t *loc; /* Pointer to object's location */ @@ -297,17 +287,11 @@ H5O_num_attrs_test(hid_t oid, hsize_t *nattrs) /* Check for any messages in object header */ HDassert(obj_nattrs == 0); - /* Check for SWMR writes to the file */ - if(H5F_INTENT(loc->file) & H5F_ACC_SWMR_WRITE) - /* Pin the attribute's object header proxy */ - if(NULL == (oh_proxy = H5O_pin_flush_dep_proxy_oh(loc->file, H5AC_ind_dxpl_id, oh))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTPIN, FAIL, "unable to pin object header proxy") - /* Set metadata tag in dxpl_id */ H5_BEGIN_TAG(H5AC_ind_dxpl_id, loc->addr, FAIL); /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(loc->file, H5AC_ind_dxpl_id, ainfo.name_bt2_addr, NULL, oh_proxy))) + if(NULL == (bt2_name = H5B2_open(loc->file, H5AC_ind_dxpl_id, ainfo.name_bt2_addr, NULL))) HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Reset metadata tag in dxpl_id */ @@ -329,8 +313,6 @@ done: /* Release resources */ if(bt2_name && H5B2_close(bt2_name, H5AC_ind_dxpl_id) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for name index") - if(oh_proxy && H5O_unpin_flush_dep_proxy(oh_proxy) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPIN, FAIL, "unable to unpin attribute object header proxy") if(oh && H5O_unprotect(loc, H5AC_ind_dxpl_id, oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") @@ -363,7 +345,6 @@ herr_t H5O_attr_dense_info_test(hid_t oid, hsize_t *name_count, hsize_t *corder_count) { H5O_t *oh = NULL; /* Object header */ - H5O_proxy_t *oh_proxy = NULL; /* Object header proxy */ H5B2_t *bt2_name = NULL; /* v2 B-tree handle for name index */ H5B2_t *bt2_corder = NULL; /* v2 B-tree handle for creation order index */ H5O_ainfo_t ainfo; /* Attribute information for object */ @@ -391,12 +372,6 @@ H5O_attr_dense_info_test(hid_t oid, hsize_t *name_count, hsize_t *corder_count) HGOTO_ERROR_TAG(H5E_ATTR, H5E_CANTGET, FAIL, "can't check for attribute info message") } /* end if */ - /* Check for SWMR writes to the file */ - if(H5F_INTENT(loc->file) & H5F_ACC_SWMR_WRITE) - /* Pin the attribute's object header proxy */ - if(NULL == (oh_proxy = H5O_pin_flush_dep_proxy_oh(loc->file, H5AC_ind_dxpl_id, oh))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTPIN, FAIL, "unable to pin object header proxy") - /* Check for 'dense' attribute storage file addresses being defined */ if(!H5F_addr_defined(ainfo.fheap_addr)) HGOTO_DONE_TAG(FAIL, FAIL) @@ -404,7 +379,7 @@ H5O_attr_dense_info_test(hid_t oid, hsize_t *name_count, hsize_t *corder_count) HGOTO_DONE_TAG(FAIL, FAIL) /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(loc->file, H5AC_ind_dxpl_id, ainfo.name_bt2_addr, NULL, oh_proxy))) + if(NULL == (bt2_name = H5B2_open(loc->file, H5AC_ind_dxpl_id, ainfo.name_bt2_addr, NULL))) HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Retrieve # of records in name index */ @@ -414,7 +389,7 @@ H5O_attr_dense_info_test(hid_t oid, hsize_t *name_count, hsize_t *corder_count) /* Check if there is a creation order index */ if(H5F_addr_defined(ainfo.corder_bt2_addr)) { /* Open the creation order index v2 B-tree */ - if(NULL == (bt2_corder = H5B2_open(loc->file, H5AC_ind_dxpl_id, ainfo.corder_bt2_addr, NULL, oh_proxy))) + if(NULL == (bt2_corder = H5B2_open(loc->file, H5AC_ind_dxpl_id, ainfo.corder_bt2_addr, NULL))) HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for creation order index") /* Retrieve # of records in creation order index */ @@ -433,8 +408,6 @@ done: HDONE_ERROR(H5E_OHDR, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for name index") if(bt2_corder && H5B2_close(bt2_corder, H5AC_ind_dxpl_id) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for creation order index") - if(oh_proxy && H5O_unpin_flush_dep_proxy(oh_proxy) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPIN, FAIL, "unable to unpin attribute object header proxy") if(oh && H5O_unprotect(loc, H5AC_ind_dxpl_id, oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") diff --git a/src/H5SM.c b/src/H5SM.c index 908463e..4a562dd 100644 --- a/src/H5SM.c +++ b/src/H5SM.c @@ -500,7 +500,7 @@ H5SM_create_index(H5F_t *f, H5SM_index_header_t *header, hid_t dxpl_id) bt2_cparam.rrec_size = (uint32_t)H5SM_SOHM_ENTRY_SIZE(f); bt2_cparam.split_percent = H5SM_B2_SPLIT_PERCENT; bt2_cparam.merge_percent = H5SM_B2_MERGE_PERCENT; - if(NULL == (bt2 = H5B2_create(f, dxpl_id, &bt2_cparam, f, NULL))) + if(NULL == (bt2 = H5B2_create(f, dxpl_id, &bt2_cparam, f))) HGOTO_ERROR(H5E_SOHM, H5E_CANTCREATE, FAIL, "B-tree creation failed for SOHM index") /* Retrieve the v2 B-tree's address in the file */ @@ -600,7 +600,7 @@ H5SM_delete_index(H5F_t *f, H5SM_index_header_t *header, hid_t dxpl_id, HDassert(header->index_type == H5SM_BTREE); /* Delete the B-tree. */ - if(H5B2_delete(f, dxpl_id, header->index_addr, f, NULL, NULL, NULL) < 0) + if(H5B2_delete(f, dxpl_id, header->index_addr, f, NULL, NULL) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTDELETE, FAIL, "unable to delete B-tree") /* Revert to list unless B-trees can have zero records */ @@ -743,7 +743,7 @@ H5SM_convert_list_to_btree(H5F_t *f, H5SM_index_header_t *header, bt2_cparam.rrec_size = (uint32_t)H5SM_SOHM_ENTRY_SIZE(f); bt2_cparam.split_percent = H5SM_B2_SPLIT_PERCENT; bt2_cparam.merge_percent = H5SM_B2_MERGE_PERCENT; - if(NULL == (bt2 = H5B2_create(f, dxpl_id, &bt2_cparam, f, NULL))) + if(NULL == (bt2 = H5B2_create(f, dxpl_id, &bt2_cparam, f))) HGOTO_ERROR(H5E_SOHM, H5E_CANTCREATE, FAIL, "B-tree creation failed for SOHM index") /* Retrieve the v2 B-tree's address in the file */ @@ -856,7 +856,7 @@ H5SM_convert_btree_to_list(H5F_t * f, H5SM_index_header_t * header, hid_t dxpl_i /* Delete the B-tree and have messages copy themselves to the * list as they're deleted */ - if(H5B2_delete(f, dxpl_id, btree_addr, f, NULL, H5SM_bt2_convert_to_list_op, list) < 0) + if(H5B2_delete(f, dxpl_id, btree_addr, f, H5SM_bt2_convert_to_list_op, list) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTDELETE, FAIL, "unable to delete B-tree") done: @@ -1339,7 +1339,7 @@ H5SM_write_mesg(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, HDassert(header->index_type == H5SM_BTREE); /* Open the index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, dxpl_id, header->index_addr, f, NULL))) + if(NULL == (bt2 = H5B2_open(f, dxpl_id, header->index_addr, f))) HGOTO_ERROR(H5E_SOHM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for SOHM index") if(defer) { @@ -1467,7 +1467,7 @@ H5SM_write_mesg(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, /* Open the index v2 B-tree, if it isn't already */ if(NULL == bt2) { - if(NULL == (bt2 = H5B2_open(f, dxpl_id, header->index_addr, f, NULL))) + if(NULL == (bt2 = H5B2_open(f, dxpl_id, header->index_addr, f))) HGOTO_ERROR(H5E_SOHM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for SOHM index") } /* end if */ @@ -1836,7 +1836,7 @@ H5SM_delete_from_index(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, HDassert(header->index_type == H5SM_BTREE); /* Open the index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, dxpl_id, header->index_addr, f, NULL))) + if(NULL == (bt2 = H5B2_open(f, dxpl_id, header->index_addr, f))) HGOTO_ERROR(H5E_SOHM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for SOHM index") /* If this returns failure, it means that the message wasn't found. @@ -1866,7 +1866,7 @@ H5SM_delete_from_index(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, else { /* Open the index v2 B-tree, if it isn't already */ if(NULL == bt2) { - if(NULL == (bt2 = H5B2_open(f, dxpl_id, header->index_addr, f, NULL))) + if(NULL == (bt2 = H5B2_open(f, dxpl_id, header->index_addr, f))) HGOTO_ERROR(H5E_SOHM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for SOHM index") } /* end if */ @@ -2218,7 +2218,7 @@ H5SM_get_refcount(H5F_t *f, hid_t dxpl_id, unsigned type_id, HDassert(header->index_type == H5SM_BTREE); /* Open the index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, dxpl_id, header->index_addr, f, NULL))) + if(NULL == (bt2 = H5B2_open(f, dxpl_id, header->index_addr, f))) HGOTO_ERROR(H5E_SOHM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for SOHM index") /* Look up the message in the v2 B-tree */ @@ -2752,7 +2752,7 @@ H5SM_ih_size(H5F_t *f, hid_t dxpl_id, hsize_t *hdr_size, H5_ih_info_t *ih_info) if(table->indexes[u].index_type == H5SM_BTREE) { if(H5F_addr_defined(table->indexes[u].index_addr)) { /* Open the index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, dxpl_id, table->indexes[u].index_addr, f, NULL))) + if(NULL == (bt2 = H5B2_open(f, dxpl_id, table->indexes[u].index_addr, f))) HGOTO_ERROR(H5E_SOHM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for SOHM index") if(H5B2_size(bt2, dxpl_id, &(ih_info->index_size)) < 0) diff --git a/test/Makefile.am b/test/Makefile.am index 59ba43b..cef7c75 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -51,17 +51,14 @@ check_SCRIPTS = $(TEST_SCRIPT) # executed, generally most specific tests to least specific tests. # As an exception, long-running tests should occur earlier in the list. # This gives them more time to run when tests are executing in parallel. -# These tests (fheap, btree2) are under development and are not used by -# the library yet. Move them to the end so that their failure do not block -# other current library code tests. -TEST_PROG= testhdf5 lheap ohdr stab gheap cache cache_api cache_tagging \ +TEST_PROG= testhdf5 cache cache_api cache_tagging lheap ohdr stab gheap \ + farray earray btree2 fheap \ pool accum hyperslab istore bittests dt_arith \ dtypes dsets cmpd_dset filter_fail extend external efc objcopy links unlink \ twriteorder big mtime fillval mount flush1 flush2 app_ref enum \ set_extent ttsafe enc_dec_plist enc_dec_plist_cross_platform\ getname vfd ntypes dangle dtransform reserved cross_read \ - freespace mf vds farray earray btree2 fheap file_image unregister \ - cache_logging cork swmr + freespace mf vds file_image unregister cache_logging cork swmr # List programs to be built when testing here. # error_test and err_compat are built at the same time as the other tests, but executed by testerror.sh. @@ -174,9 +171,9 @@ CHECK_CLEANFILES+=accum.h5 cmpd_dset.h5 compact_dataset.h5 dataset.h5 \ multi_file-[rs].h5 core_file plugin.h5 \ new_move_[ab].h5 ntypes.h5 dangle.h5 error_test.h5 err_compat.h5 \ dtransform.h5 test_filters.h5 get_file_name.h5 tstint[1-2].h5 \ - unlink_chunked.h5 btree2.h5 objcopy_src.h5 objcopy_dst.h5 \ - objcopy_ext.dat trefer1.h5 trefer2.h5 app_ref.h5 farray.h5 \ - earray.h5 efc[0-5].h5 log_vfd_out.log \ + unlink_chunked.h5 btree2.h5 btree2_tmp.h5 objcopy_src.h5 objcopy_dst.h5 \ + objcopy_ext.dat trefer1.h5 trefer2.h5 app_ref.h5 farray.h5 farray_tmp.h5 \ + earray.h5 earray_tmp.h5 efc[0-5].h5 log_vfd_out.log \ new_multi_file_v16-r.h5 new_multi_file_v16-s.h5 \ split_get_file_image_test-m.h5 split_get_file_image_test-r.h5 \ file_image_core_test.h5.copy unregister_filter_1.h5 unregister_filter_2.h5 \ diff --git a/test/btree2.c b/test/btree2.c index 83c079b..7a2432c 100644 --- a/test/btree2.c +++ b/test/btree2.c @@ -31,6 +31,7 @@ const char *FILENAME[] = { "btree2", + "btree2_tmp", NULL }; @@ -108,9 +109,8 @@ create_file(hid_t *file, H5F_t **f, hid_t fapl) STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(*f) < 0) { + if(H5AC_ignore_tags(*f) < 0) STACK_ERROR - } /* Success */ return(0); @@ -138,7 +138,7 @@ create_btree(H5F_t *f, hid_t dxpl, const H5B2_create_t *cparam, H5B2_t **bt2, haddr_t *bt2_addr) { /* Create the v2 B-tree & get its address */ - if(NULL == (*bt2 = H5B2_create(f, dxpl, cparam, f, NULL))) + if(NULL == (*bt2 = H5B2_create(f, dxpl, cparam, f))) FAIL_STACK_ERROR if(H5B2_get_addr(*bt2, bt2_addr/*out*/) < 0) FAIL_STACK_ERROR @@ -177,7 +177,7 @@ reopen_btree(H5F_t *f, hid_t dxpl, H5B2_t **bt2, haddr_t bt2_addr, FAIL_STACK_ERROR /* Re-open v2 B-tree */ - if(NULL == (*bt2 = H5B2_open(f, dxpl, bt2_addr, f, NULL))) + if(NULL == (*bt2 = H5B2_open(f, dxpl, bt2_addr, f))) FAIL_STACK_ERROR } /* end if */ @@ -2810,9 +2810,8 @@ HDfprintf(stderr,"curr_time=%lu\n",(unsigned long)curr_time); STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(f) < 0) { + if(H5AC_ignore_tags(f) < 0) STACK_ERROR - } /* Create the v2 B-tree & get its address */ if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0) @@ -2849,12 +2848,11 @@ HDfprintf(stderr,"curr_time=%lu\n",(unsigned long)curr_time); FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(f) < 0) { + if(H5AC_ignore_tags(f) < 0) STACK_ERROR - } /* Re-open v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, dxpl, bt2_addr, f, NULL))) + if(NULL == (bt2 = H5B2_open(f, dxpl, bt2_addr, f))) FAIL_STACK_ERROR /* Check up on B-tree after re-open */ @@ -4909,7 +4907,7 @@ test_remove_level1_collapse(hid_t fapl, const H5B2_create_t *cparam, /* Check record values in root of B-tree */ ninfo.depth = 0; - ninfo.nrec = INSERT_SPLIT_ROOT_NREC - u; + ninfo.nrec = (uint16_t)(INSERT_SPLIT_ROOT_NREC - u); record = 31; /* Middle record in root node */ if(check_node_info(bt2, dxpl, record, &ninfo) < 0) TEST_ERROR @@ -6379,9 +6377,8 @@ gen_l4_btree2(const char *filename, hid_t fapl, const H5B2_create_t *cparam, STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(f) < 0) { + if(H5AC_ignore_tags(f) < 0) STACK_ERROR - } /* Create the v2 B-tree & get its address */ if(create_btree(f, dxpl, cparam, &bt2, bt2_addr) < 0) @@ -6535,9 +6532,8 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time); FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(f) < 0) { + if(H5AC_ignore_tags(f) < 0) STACK_ERROR - } /* Re-shuffle record #'s */ for(u = 0; u < INSERT_MANY; u++) { @@ -6551,7 +6547,7 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time); } /* end for */ /* Re-open v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, dxpl, bt2_addr, f, NULL))) + if(NULL == (bt2 = H5B2_open(f, dxpl, bt2_addr, f))) FAIL_STACK_ERROR /* Remove all records */ @@ -6631,12 +6627,11 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time); FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(f) < 0) { + if(H5AC_ignore_tags(f) < 0) STACK_ERROR - } /* Re-open v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, dxpl, bt2_addr, f, NULL))) + if(NULL == (bt2 = H5B2_open(f, dxpl, bt2_addr, f))) FAIL_STACK_ERROR /* Remove all records */ @@ -6646,7 +6641,7 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time); rrecord = HSIZET_MAX; /* Remove random record */ - if(H5B2_remove_by_idx(bt2, dxpl, H5_ITER_INC, (hsize_t)rem_idx, NULL, remove_cb, &rrecord) < 0) + if(H5B2_remove_by_idx(bt2, dxpl, H5_ITER_INC, (hsize_t)rem_idx, remove_cb, &rrecord) < 0) FAIL_STACK_ERROR /* Make certain that the record value is correct */ @@ -6720,19 +6715,18 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time); FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(f) < 0) { + if(H5AC_ignore_tags(f) < 0) STACK_ERROR - } /* Re-open v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, dxpl, bt2_addr, f, NULL))) + if(NULL == (bt2 = H5B2_open(f, dxpl, bt2_addr, f))) FAIL_STACK_ERROR /* Remove all records */ for(u = 0; u < INSERT_MANY; u++) { /* Remove first record */ rrecord = HSIZET_MAX; - if(H5B2_remove_by_idx(bt2, dxpl, H5_ITER_INC, (hsize_t)0, NULL, remove_cb, &rrecord) < 0) + if(H5B2_remove_by_idx(bt2, dxpl, H5_ITER_INC, (hsize_t)0, remove_cb, &rrecord) < 0) FAIL_STACK_ERROR /* Make certain that the record value is correct */ @@ -6806,19 +6800,18 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time); FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(f) < 0) { + if(H5AC_ignore_tags(f) < 0) STACK_ERROR - } /* Re-open v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, dxpl, bt2_addr, f, NULL))) + if(NULL == (bt2 = H5B2_open(f, dxpl, bt2_addr, f))) FAIL_STACK_ERROR /* Remove all records */ for(u = 0; u < INSERT_MANY; u++) { /* Remove last record */ rrecord = HSIZET_MAX; - if(H5B2_remove_by_idx(bt2, dxpl, H5_ITER_DEC, (hsize_t)0, NULL, remove_cb, &rrecord) < 0) + if(H5B2_remove_by_idx(bt2, dxpl, H5_ITER_DEC, (hsize_t)0, remove_cb, &rrecord) < 0) FAIL_STACK_ERROR /* Make certain that the record value is correct */ @@ -7157,9 +7150,8 @@ test_delete(hid_t fapl, const H5B2_create_t *cparam) STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(f) < 0) { + if(H5AC_ignore_tags(f) < 0) STACK_ERROR - } /* Create the v2 B-tree & get its address */ if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0) @@ -7173,7 +7165,7 @@ test_delete(hid_t fapl, const H5B2_create_t *cparam) /* * Delete v2 B-tree */ - if(H5B2_delete(f, dxpl, bt2_addr, f, NULL, NULL, NULL) < 0) + if(H5B2_delete(f, dxpl, bt2_addr, f, NULL, NULL) < 0) FAIL_STACK_ERROR /* Close the file */ @@ -7202,9 +7194,8 @@ test_delete(hid_t fapl, const H5B2_create_t *cparam) STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(f) < 0) { + if(H5AC_ignore_tags(f) < 0) STACK_ERROR - } /* Create the v2 B-tree & get its address */ if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0) @@ -7231,7 +7222,7 @@ test_delete(hid_t fapl, const H5B2_create_t *cparam) /* * Delete v2 B-tree */ - if(H5B2_delete(f, H5P_DATASET_XFER_DEFAULT, bt2_addr, f, NULL, NULL, NULL) < 0) + if(H5B2_delete(f, H5P_DATASET_XFER_DEFAULT, bt2_addr, f, NULL, NULL) < 0) FAIL_STACK_ERROR /* Close file */ @@ -7260,9 +7251,8 @@ test_delete(hid_t fapl, const H5B2_create_t *cparam) STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(f) < 0) { + if(H5AC_ignore_tags(f) < 0) STACK_ERROR - } /* Create the v2 B-tree & get its address */ if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0) @@ -7289,7 +7279,7 @@ test_delete(hid_t fapl, const H5B2_create_t *cparam) /* * Delete v2 B-tree */ - if(H5B2_delete(f, dxpl, bt2_addr, f, NULL, NULL, NULL) < 0) + if(H5B2_delete(f, dxpl, bt2_addr, f, NULL, NULL) < 0) FAIL_STACK_ERROR /* Close file */ @@ -7318,9 +7308,8 @@ test_delete(hid_t fapl, const H5B2_create_t *cparam) STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(f) < 0) { + if(H5AC_ignore_tags(f) < 0) STACK_ERROR - } /* Create the v2 B-tree & get its address */ if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0) @@ -7347,7 +7336,7 @@ test_delete(hid_t fapl, const H5B2_create_t *cparam) /* * Delete v2 B-tree */ - if(H5B2_delete(f, dxpl, bt2_addr, f, NULL, NULL, NULL) < 0) + if(H5B2_delete(f, dxpl, bt2_addr, f, NULL, NULL) < 0) FAIL_STACK_ERROR /* Close file */ @@ -7605,6 +7594,146 @@ error: /*------------------------------------------------------------------------- + * Function: test_open_twice_diff + * + * Purpose: Open a v2 B-tree twice, through different "top" file + * handles, with an intermediate file open that takes the "shared" + * file handle from the first B-tree's file pointer. + * + * Return: Success: 0 + * Failure: 1 + * + * Programmer: Quincey Koziol + * Friday, December 18, 2015 + * + *------------------------------------------------------------------------- + */ +static unsigned +test_open_twice_diff(hid_t fapl, const H5B2_create_t *cparam) +{ + char filename[1024]; /* Filename to use */ + char filename_tmp[1024]; /* Temporary file name */ + hid_t file = -1; /* File ID */ + hid_t file2 = -1; /* File ID */ + hid_t file0 = -1; /* File ID */ + hid_t file00 = -1; /* File ID */ + H5F_t *f = NULL; /* Internal file object pointer */ + H5F_t *f2 = NULL; /* Internal file object pointer */ + hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ + H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ + H5B2_t *bt2_2 = NULL; /* Second v2 B-tree wrapper */ + haddr_t bt2_addr; /* Address of B-tree created */ + + h5_fixname(FILENAME[0], fapl, filename, sizeof filename); + + /* + * Display testing message + */ + TESTING("open B-tree twice, through different file handles"); + + /* Create the file to work on */ + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR + + /* Get a pointer to the internal file object */ + if(NULL == (f = (H5F_t *)H5I_object(file))) + FAIL_STACK_ERROR + + /* Ignore metadata tags in the file's cache */ + if(H5AC_ignore_tags(f) < 0) + FAIL_STACK_ERROR + + /* Create the v2 B-tree & get its address */ + if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0) + TEST_ERROR + + /* Re-open v2 B-tree */ + if(NULL == (bt2_2 = H5B2_open(f, dxpl, bt2_addr, f))) + FAIL_STACK_ERROR + + /* Close the second v2 B-tree wrapper */ + if(H5B2_close(bt2_2, dxpl) < 0) + FAIL_STACK_ERROR + bt2_2 = NULL; + + /* Re-open the file */ + /* (So that there is something holding the file open when the extensible + * array is closed) + */ + if((file0 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR + + /* Close the first v2 B-tree wrapper */ + if(H5B2_close(bt2, dxpl) < 0) + FAIL_STACK_ERROR + bt2 = NULL; + + /* Close the file */ + /* (close before second file, to detect error on internal B-tree header's + * shared file information) + */ + if(H5Fclose(file) < 0) + FAIL_STACK_ERROR + file = -1; + + /* Open a different file */ + /* (This re-allocates the 'top' file pointer and assigns it a different + * 'shared' file pointer, making the file pointer in the fixed array's + * header stale) + */ + h5_fixname(FILENAME[1], fapl, filename_tmp, sizeof(filename_tmp)); + if((file00 = H5Fcreate(filename_tmp, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR + + /* Re-open the file with the v2 B-tree array */ + if((file2 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR + + /* Get a pointer to the internal file object */ + if(NULL == (f2 = (H5F_t *)H5I_object(file2))) + FAIL_STACK_ERROR + + /* Open the B-tree through the second file handle */ + if(NULL == (bt2_2 = H5B2_open(f2, dxpl, bt2_addr, f2))) + FAIL_STACK_ERROR + + /* Close the extra file handles */ + if(H5Fclose(file0) < 0) + FAIL_STACK_ERROR + if(H5Fclose(file00) < 0) + FAIL_STACK_ERROR + + /* Close the second v2 B-tree */ + if(H5B2_close(bt2_2, dxpl) < 0) + FAIL_STACK_ERROR + bt2_2 = NULL; + + /* Close file */ + if(H5Fclose(file2) < 0) + FAIL_STACK_ERROR + + /* All tests passed */ + PASSED(); + + /* All tests passed */ + return(0); + +error: + H5E_BEGIN_TRY { + if(bt2) + H5B2_close(bt2, dxpl); + if(bt2) + H5B2_close(bt2_2, dxpl); + H5Fclose(file); + H5Fclose(file2); + H5Fclose(file0); + H5Fclose(file00); + } H5E_END_TRY; + return(1); +} /* test_open_twice_diff() */ + + +/*------------------------------------------------------------------------- * Function: main * * Purpose: Test the B-tree v2 code @@ -7712,6 +7841,9 @@ main(void) nerrors += test_modify(fapl, &cparam, &tparam); } /* end for */ + /* Test opening B-trees twice */ + nerrors += test_open_twice_diff(fapl, &cparam); + /* Verify symbol table messages are cached */ nerrors += (h5_verify_cached_stabs(FILENAME, fapl) < 0 ? 1 : 0); diff --git a/test/cache_tagging.c b/test/cache_tagging.c index 80ba2eb..470f7a1 100644 --- a/test/cache_tagging.c +++ b/test/cache_tagging.c @@ -112,103 +112,105 @@ static unsigned check_invalid_tag_application(void); static void print_entry_type_to_screen(int id) { - printf("Type = "); + HDfprintf(stdout, "Type = "); switch (id) { - case 0: - printf("B-tree Node(0)"); + case H5AC_BT_ID: + HDfprintf(stdout, "v1 B-tree Node"); break; - case 1: - printf("Symbol Table Node(1)"); + case H5AC_SNODE_ID: + HDfprintf(stdout, "Symbol Table Node"); break; - case 2: - printf("Local Heap Prefix(2)"); + case H5AC_LHEAP_PRFX_ID: + HDfprintf(stdout, "Local Heap Prefix"); break; - case 3: - printf("Local Heap Data Block(3)"); + case H5AC_LHEAP_DBLK_ID: + HDfprintf(stdout, "Local Heap Data Block"); break; - case 4: - printf("Global Heap(4)"); + case H5AC_GHEAP_ID: + HDfprintf(stdout, "Global Heap"); break; - case 5: - printf("Object Header(5)"); + case H5AC_OHDR_ID: + HDfprintf(stdout, "Object Header"); break; - case 6: - printf("Object Header Chunk(6)"); + case H5AC_OHDR_CHK_ID: + HDfprintf(stdout, "Object Header Chunk"); break; - case 7: - printf("v2 B-tree Header(7)"); + case H5AC_BT2_HDR_ID: + HDfprintf(stdout, "v2 B-tree Header"); break; - case 8: - printf("v2 B-tree Internal Node(8)"); + case H5AC_BT2_INT_ID: + HDfprintf(stdout, "v2 B-tree Internal Node"); break; - case 9: - printf("v2 B-tree Leaf Node(9)"); + case H5AC_BT2_LEAF_ID: + HDfprintf(stdout, "v2 B-tree Leaf Node"); break; - case 10: - printf("Fractal Heap Header(10)"); + case H5AC_FHEAP_HDR_ID: + HDfprintf(stdout, "Fractal Heap Header"); break; - case 11: - printf("Fractal Heap Direct Block(11)"); + case H5AC_FHEAP_DBLOCK_ID: + HDfprintf(stdout, "Fractal Heap Direct Block"); break; - case 12: - printf("Fractal Heap Indirect Block(12)"); + case H5AC_FHEAP_IBLOCK_ID: + HDfprintf(stdout, "Fractal Heap Indirect Block"); break; - case 13: - printf("Free Space Header(13)"); + case H5AC_FSPACE_HDR_ID: + HDfprintf(stdout, "Free Space Header"); break; - case 14: - printf("Free Space Section(14)"); + case H5AC_FSPACE_SINFO_ID: + HDfprintf(stdout, "Free Space Section"); break; - case 15: - printf("Shared Object Header Message Master Table(15)"); + case H5AC_SOHM_TABLE_ID: + HDfprintf(stdout, "Shared Object Header Message Master Table"); break; - case 16: - printf("Shared Message Index Stored As A List(16)"); + case H5AC_SOHM_LIST_ID: + HDfprintf(stdout, "Shared Message Index Stored As A List"); break; - case 17: - printf("Extensible Array Header(17)"); + case H5AC_EARRAY_HDR_ID: + HDfprintf(stdout, "Extensible Array Header"); break; - case 18: - printf("Extensible Array Index Block(18)"); + case H5AC_EARRAY_IBLOCK_ID: + HDfprintf(stdout, "Extensible Array Index Block"); break; - case 19: - printf("Extensible Array Super Block(19)"); + case H5AC_EARRAY_SBLOCK_ID: + HDfprintf(stdout, "Extensible Array Super Block"); break; - case 20: - printf("Extensible Array Data Block(20)"); + case H5AC_EARRAY_DBLOCK_ID: + HDfprintf(stdout, "Extensible Array Data Block"); break; - case 21: - printf("Extensible Array Data Block Page(21)"); + case H5AC_EARRAY_DBLK_PAGE_ID: + HDfprintf(stdout, "Extensible Array Data Block Page"); break; - case 22: - printf("Chunk Proxy(22)"); + case H5AC_FARRAY_HDR_ID: + HDfprintf(stdout, "Fixed Array Header"); break; - case 23: - printf("Fixed Array Header(23)"); + case H5AC_FARRAY_DBLOCK_ID: + HDfprintf(stdout, "Fixed Array Data Block"); break; - case 24: - printf("Fixed Array Data Block(24)"); + case H5AC_FARRAY_DBLK_PAGE_ID: + HDfprintf(stdout, "Fixed Array Data Block Page"); break; - case 25: - printf("Fixed Array Data Block Page(25)"); + case H5AC_SUPERBLOCK_ID: + HDfprintf(stdout, "File Superblock"); break; - case 26: - printf("File Superblock(26)"); + case H5AC_DRVRINFO_ID: + HDfprintf(stdout, "Driver Info Block"); break; - case 27: - printf("Test Entry(27)"); + case H5AC_TEST_ID: + HDfprintf(stdout, "Test Entry"); break; - case 28: - printf("Number of Types(28)"); + case H5AC_NTYPES: + HDfprintf(stdout, "BADNESS: Number of Types"); break; default: - printf("*Unknown*"); + HDfprintf(stdout, "BADNESS: *Unknown*"); break; } /* end switch */ + HDfprintf(stdout, " (%d)", id); + } /* print_entry_type_to_screen */ @@ -225,8 +227,6 @@ print_entry_type_to_screen(int id) * Programmer: Mike McGreevy * January 25, 2010 * - * Modifications: - * *------------------------------------------------------------------------- */ static int print_index(hid_t fid) { diff --git a/test/dsets.c b/test/dsets.c index 9775214..4b7123d 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -10069,6 +10069,80 @@ error: /*------------------------------------------------------------------------- + * Function: test_zero_dim_dset + * + * Purpose: Tests support for reading a 1D chunled dataset with + * dimension size = 0. + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Mohamad Chaarawi + * Wednesdat, July 9, 2014 + * + *------------------------------------------------------------------------- + */ +static herr_t +test_zero_dim_dset(hid_t fapl) +{ + char filename[FILENAME_BUF_SIZE]; + hid_t fid = -1; /* File ID */ + hid_t dcpl = -1; /* Dataset creation property list ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t dsid = -1; /* Dataset ID */ + hsize_t dim, chunk_dim; /* Dataset and chunk dimensions */ + int data[1]; + + TESTING("shrinking large chunk"); + + h5_fixname(FILENAME[16], fapl, filename, sizeof filename); + + /* Create file */ + if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR + + /* Create dataset creation property list */ + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR + + /* Set 1 chunk size */ + chunk_dim = 1; + if(H5Pset_chunk(dcpl, 1, &chunk_dim) < 0) FAIL_STACK_ERROR + + /* Create 1D dataspace with 0 dim size */ + dim = 0; + if((sid = H5Screate_simple(1, &dim, NULL)) < 0) FAIL_STACK_ERROR + + /* Create chunked dataset */ + if((dsid = H5Dcreate2(fid, "dset", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + + /* write 0 elements from dataset */ + if(H5Dwrite(dsid, H5T_NATIVE_INT, sid, sid, H5P_DEFAULT, data) < 0) FAIL_STACK_ERROR + + /* Read 0 elements from dataset */ + if(H5Dread(dsid, H5T_NATIVE_INT, sid, sid, H5P_DEFAULT, data) < 0) FAIL_STACK_ERROR + + /* Close everything */ + if(H5Sclose(sid) < 0) FAIL_STACK_ERROR + if(H5Dclose(dsid) < 0) FAIL_STACK_ERROR + if(H5Pclose(dcpl) < 0) FAIL_STACK_ERROR + if(H5Fclose(fid) < 0) FAIL_STACK_ERROR + + PASSED(); + + return 0; + +error: + H5E_BEGIN_TRY { + H5Pclose(dcpl); + H5Dclose(dsid); + H5Sclose(sid); + H5Fclose(fid); + } H5E_END_TRY; + return -1; +} /* end test_zero_dim_dset() */ + + +/*------------------------------------------------------------------------- * Function: test_swmr_non_latest * * Purpose: Checks that a file created with either: @@ -10672,80 +10746,6 @@ error: /*------------------------------------------------------------------------- - * Function: test_zero_dim_dset - * - * Purpose: Tests support for reading a 1D chunled dataset with - * dimension size = 0. - * - * Return: Success: 0 - * Failure: -1 - * - * Programmer: Mohamad Chaarawi - * Wednesdat, July 9, 2014 - * - *------------------------------------------------------------------------- - */ -static herr_t -test_zero_dim_dset(hid_t fapl) -{ - char filename[FILENAME_BUF_SIZE]; - hid_t fid = -1; /* File ID */ - hid_t dcpl = -1; /* Dataset creation property list ID */ - hid_t sid = -1; /* Dataspace ID */ - hid_t dsid = -1; /* Dataset ID */ - hsize_t dim, chunk_dim; /* Dataset and chunk dimensions */ - int data[1]; - - TESTING("shrinking large chunk"); - - h5_fixname(FILENAME[16], fapl, filename, sizeof filename); - - /* Create file */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR - - /* Create dataset creation property list */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR - - /* Set 1 chunk size */ - chunk_dim = 1; - if(H5Pset_chunk(dcpl, 1, &chunk_dim) < 0) FAIL_STACK_ERROR - - /* Create 1D dataspace with 0 dim size */ - dim = 0; - if((sid = H5Screate_simple(1, &dim, NULL)) < 0) FAIL_STACK_ERROR - - /* Create chunked dataset */ - if((dsid = H5Dcreate2(fid, "dset", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR - - /* write 0 elements from dataset */ - if(H5Dwrite(dsid, H5T_NATIVE_INT, sid, sid, H5P_DEFAULT, data) < 0) FAIL_STACK_ERROR - - /* Read 0 elements from dataset */ - if(H5Dread(dsid, H5T_NATIVE_INT, sid, sid, H5P_DEFAULT, data) < 0) FAIL_STACK_ERROR - - /* Close everything */ - if(H5Sclose(sid) < 0) FAIL_STACK_ERROR - if(H5Dclose(dsid) < 0) FAIL_STACK_ERROR - if(H5Pclose(dcpl) < 0) FAIL_STACK_ERROR - if(H5Fclose(fid) < 0) FAIL_STACK_ERROR - - PASSED(); - - return 0; - -error: - H5E_BEGIN_TRY { - H5Pclose(dcpl); - H5Dclose(dsid); - H5Sclose(sid); - H5Fclose(fid); - } H5E_END_TRY; - return -1; -} /* end test_zero_dim_dset() */ - - -/*------------------------------------------------------------------------- * Function: test_scatter * * Purpose: Tests H5Dscatter with a variety of different selections @@ -11851,38 +11851,38 @@ main(void) nerrors += (test_simple_io(envval, my_fapl) < 0 ? 1 : 0); nerrors += (test_compact_io(my_fapl) < 0 ? 1 : 0); nerrors += (test_max_compact(my_fapl) < 0 ? 1 : 0); - nerrors += (test_conv_buffer(file) < 0 ? 1 : 0); + nerrors += (test_conv_buffer(file) < 0 ? 1 : 0); nerrors += (test_tconv(file) < 0 ? 1 : 0); nerrors += (test_filters(file, my_fapl) < 0 ? 1 : 0); nerrors += (test_onebyte_shuffle(file) < 0 ? 1 : 0); - nerrors += (test_nbit_int(file) < 0 ? 1 : 0); - nerrors += (test_nbit_float(file) < 0 ? 1 : 0); - nerrors += (test_nbit_double(file) < 0 ? 1 : 0); - nerrors += (test_nbit_array(file) < 0 ? 1 : 0); + nerrors += (test_nbit_int(file) < 0 ? 1 : 0); + nerrors += (test_nbit_float(file) < 0 ? 1 : 0); + nerrors += (test_nbit_double(file) < 0 ? 1 : 0); + nerrors += (test_nbit_array(file) < 0 ? 1 : 0); nerrors += (test_nbit_compound(file) < 0 ? 1 : 0); nerrors += (test_nbit_compound_2(file) < 0 ? 1 : 0); nerrors += (test_nbit_compound_3(file) < 0 ? 1 : 0); nerrors += (test_nbit_int_size(file) < 0 ? 1 : 0); nerrors += (test_nbit_flt_size(file) < 0 ? 1 : 0); nerrors += (test_scaleoffset_int(file) < 0 ? 1 : 0); - nerrors += (test_scaleoffset_int_2(file) < 0 ? 1 : 0); - nerrors += (test_scaleoffset_float(file) < 0 ? 1 : 0); - nerrors += (test_scaleoffset_float_2(file) < 0 ? 1 : 0); - nerrors += (test_scaleoffset_double(file) < 0 ? 1 : 0); + nerrors += (test_scaleoffset_int_2(file) < 0 ? 1 : 0); + nerrors += (test_scaleoffset_float(file) < 0 ? 1 : 0); + nerrors += (test_scaleoffset_float_2(file) < 0 ? 1 : 0); + nerrors += (test_scaleoffset_double(file) < 0 ? 1 : 0); nerrors += (test_scaleoffset_double_2(file) < 0 ? 1 : 0); - nerrors += (test_multiopen (file) < 0 ? 1 : 0); - nerrors += (test_types(file) < 0 ? 1 : 0); - nerrors += (test_userblock_offset(envval, my_fapl) < 0 ? 1 : 0); + nerrors += (test_multiopen (file) < 0 ? 1 : 0); + nerrors += (test_types(file) < 0 ? 1 : 0); + nerrors += (test_userblock_offset(envval, my_fapl) < 0 ? 1 : 0); nerrors += (test_missing_filter(file) < 0 ? 1 : 0); - nerrors += (test_can_apply(file) < 0 ? 1 : 0); - nerrors += (test_can_apply2(file) < 0 ? 1 : 0); - nerrors += (test_set_local(my_fapl) < 0 ? 1 : 0); + nerrors += (test_can_apply(file) < 0 ? 1 : 0); + nerrors += (test_can_apply2(file) < 0 ? 1 : 0); + nerrors += (test_set_local(my_fapl) < 0 ? 1 : 0); nerrors += (test_can_apply_szip(file) < 0 ? 1 : 0); - nerrors += (test_compare_dcpl(file) < 0 ? 1 : 0); - nerrors += (test_copy_dcpl(file, my_fapl) < 0 ? 1 : 0); + nerrors += (test_compare_dcpl(file) < 0 ? 1 : 0); + nerrors += (test_copy_dcpl(file, my_fapl) < 0 ? 1 : 0); nerrors += (test_filter_delete(file) < 0 ? 1 : 0); - nerrors += (test_filters_endianess() < 0 ? 1 : 0); - nerrors += (test_zero_dims(file) < 0 ? 1 : 0); + nerrors += (test_filters_endianess() < 0 ? 1 : 0); + nerrors += (test_zero_dims(file) < 0 ? 1 : 0); nerrors += (test_missing_chunk(file) < 0 ? 1 : 0); nerrors += (test_random_chunks(my_fapl) < 0 ? 1 : 0); #ifndef H5_NO_DEPRECATED_SYMBOLS @@ -11902,10 +11902,10 @@ main(void) nerrors += (test_single_chunk(my_fapl) < 0 ? 1 : 0); nerrors += (test_large_chunk_shrink(my_fapl) < 0 ? 1 : 0); nerrors += (test_zero_dim_dset(my_fapl) < 0 ? 1 : 0); - nerrors += (test_swmr_non_latest(envval, my_fapl) < 0 ? 1 : 0); - nerrors += (test_earray_hdr_fd(envval, my_fapl) < 0 ? 1 : 0); - nerrors += (test_farray_hdr_fd(envval, my_fapl) < 0 ? 1 : 0); - nerrors += (test_bt2_hdr_fd(envval, my_fapl) < 0 ? 1 : 0); + nerrors += (test_swmr_non_latest(envval, my_fapl) < 0 ? 1 : 0); + nerrors += (test_earray_hdr_fd(envval, my_fapl) < 0 ? 1 : 0); + nerrors += (test_farray_hdr_fd(envval, my_fapl) < 0 ? 1 : 0); + nerrors += (test_bt2_hdr_fd(envval, my_fapl) < 0 ? 1 : 0); if(H5Fclose(file) < 0) goto error; diff --git a/test/earray.c b/test/earray.c index 3bd46e8..1753104 100644 --- a/test/earray.c +++ b/test/earray.c @@ -185,6 +185,7 @@ static herr_t earray_cache_test_free_icr(void *thing); /* Local variables */ const char *FILENAME[] = { "earray", + "earray_tmp", NULL }; @@ -344,9 +345,8 @@ create_file(unsigned flags, hid_t fapl, hid_t *file, H5F_t **f) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(*f) < 0) { + if(H5AC_ignore_tags(*f) < 0) FAIL_STACK_ERROR - } /* Success */ return(0); @@ -455,17 +455,19 @@ reopen_file(hid_t *file, H5F_t **f, hid_t fapl, hid_t dxpl, /* (actually will close & re-open the file as well) */ if(tparam->reopen_array) { /* Close array, if given */ - if(ea) { + if(ea && *ea) { if(H5EA_close(*ea, dxpl) < 0) FAIL_STACK_ERROR *ea = NULL; } /* end if */ /* Close file */ - if(H5Fclose(*file) < 0) - FAIL_STACK_ERROR - *file = (-1); - *f = NULL; + if(*file) { + if(H5Fclose(*file) < 0) + FAIL_STACK_ERROR + *file = (-1); + *f = NULL; + } /* end if */ /* Re-open the file */ if((*file = H5Fopen(filename_g, H5F_ACC_RDWR, fapl)) < 0) @@ -476,15 +478,13 @@ reopen_file(hid_t *file, H5F_t **f, hid_t fapl, hid_t dxpl, FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(*f) < 0) { + if(H5AC_ignore_tags(*f) < 0) FAIL_STACK_ERROR - } /* Re-open array, if given */ - if(ea) { + if(ea) if(NULL == (*ea = H5EA_open(*f, dxpl, ea_addr, NULL))) FAIL_STACK_ERROR - } /* end if */ } /* end if */ /* Success */ @@ -1009,7 +1009,7 @@ test_create(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t H5_ATTR_UNUSE /* Set invalid max. # of elements per data block page bits */ if(test_cparam.idx_blk_elmts > 0) { HDmemcpy(&test_cparam, cparam, sizeof(test_cparam)); - test_cparam.max_dblk_page_nelmts_bits = H5VM_log2_gen((uint64_t)test_cparam.idx_blk_elmts) - 1; + test_cparam.max_dblk_page_nelmts_bits = (uint8_t)(H5VM_log2_gen((uint64_t)test_cparam.idx_blk_elmts) - 1); H5E_BEGIN_TRY { ea = H5EA_create(f, H5P_DATASET_XFER_DEFAULT, &test_cparam, NULL); } H5E_END_TRY; @@ -1036,7 +1036,7 @@ test_create(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t H5_ATTR_UNUSE TEST_ERROR } /* end if */ HDmemcpy(&test_cparam, cparam, sizeof(test_cparam)); - test_cparam.max_dblk_page_nelmts_bits = test_cparam.max_nelmts_bits + 1; + test_cparam.max_dblk_page_nelmts_bits = (uint8_t)(test_cparam.max_nelmts_bits + 1); H5E_BEGIN_TRY { ea = H5EA_create(f, H5P_DATASET_XFER_DEFAULT, &test_cparam, NULL); } H5E_END_TRY; @@ -1272,6 +1272,148 @@ error: /*------------------------------------------------------------------------- + * Function: test_open_twice_diff + * + * Purpose: Open an extensible array twice, through different "top" file + * handles, with an intermediate file open that takes the "shared" + * file handle from the first extensible array's file pointer. + * + * Return: Success: 0 + * Failure: 1 + * + * Programmer: Quincey Koziol + * Friday, December 18, 2015 + * + *------------------------------------------------------------------------- + */ +static unsigned +test_open_twice_diff(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam) +{ + char filename_tmp[EARRAY_FILENAME_LEN]; /* Temporary file name */ + hid_t file = -1; /* File ID */ + hid_t file2 = -1; /* File ID */ + hid_t file0 = -1; /* File ID */ + hid_t file00 = -1; /* File ID */ + H5F_t *f = NULL; /* Internal file object pointer */ + H5F_t *f2 = NULL; /* Internal file object pointer */ + H5EA_t *ea = NULL; /* Extensible array wrapper */ + H5EA_t *ea2 = NULL; /* Extensible array wrapper */ + haddr_t ea_addr = HADDR_UNDEF; /* Array address in file */ + + /* Create file & retrieve pointer to internal file object */ + if(create_file(H5F_ACC_TRUNC, fapl, &file, &f) < 0) + TEST_ERROR + + /* + * Display testing message + */ + TESTING("open extensible array twice, through different file handles"); + + /* Create array */ + if(create_array(f, H5P_DATASET_XFER_DEFAULT, cparam, &ea, &ea_addr, NULL) < 0) + TEST_ERROR + + /* Open the array again, through the first file handle */ + if(NULL == (ea2 = H5EA_open(f, H5P_DATASET_XFER_DEFAULT, ea_addr, NULL))) + FAIL_STACK_ERROR + + /* Verify the creation parameters */ + if(verify_cparam(ea, cparam) < 0) + TEST_ERROR + if(verify_cparam(ea2, cparam) < 0) + TEST_ERROR + + /* Close the second extensible array wrapper */ + if(H5EA_close(ea2, H5P_DATASET_XFER_DEFAULT) < 0) + FAIL_STACK_ERROR + ea2 = NULL; + + /* Re-open the file */ + /* (So that there is something holding the file open when the extensible + * array is closed) + */ + if((file0 = H5Fopen(filename_g, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR + + /* Check for closing & re-opening the file */ + if(reopen_file(&file, &f, fapl, H5P_DATASET_XFER_DEFAULT, &ea, ea_addr, tparam) < 0) + TEST_ERROR + + /* Verify the creation parameters */ + if(verify_cparam(ea, cparam) < 0) + TEST_ERROR + + /* Close the first extensible array wrapper */ + if(H5EA_close(ea, H5P_DATASET_XFER_DEFAULT) < 0) + FAIL_STACK_ERROR + ea = NULL; + + /* Close the first file */ + /* (close before second file, to detect error on internal array header's + * shared file information) + */ + if(H5Fclose(file) < 0) + FAIL_STACK_ERROR + file = -1; + + /* Open a different file */ + /* (This re-allocates the 'top' file pointer and assigns it a different + * 'shared' file pointer, making the file pointer in the extensible array's + * header stale) + */ + h5_fixname(FILENAME[1], fapl, filename_tmp, sizeof(filename_tmp)); + if((file00 = H5Fcreate(filename_tmp, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR + + + /* Re-open the file with the extensible array */ + if((file2 = H5Fopen(filename_g, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR + + /* Get a pointer to the internal file object */ + if(NULL == (f2 = (H5F_t *)H5I_object(file2))) + FAIL_STACK_ERROR + + /* Open the extensible array through the second file handle */ + if(NULL == (ea2 = H5EA_open(f2, H5P_DATASET_XFER_DEFAULT, ea_addr, NULL))) + FAIL_STACK_ERROR + + /* Verify the creation parameters */ + if(verify_cparam(ea2, cparam) < 0) + TEST_ERROR + + /* Close the extra file handles */ + if(H5Fclose(file0) < 0) + FAIL_STACK_ERROR + if(H5Fclose(file00) < 0) + FAIL_STACK_ERROR + + /* Close array, delete array, close file & verify file is empty */ + if(finish(file2, fapl, f2, ea2, ea_addr) < 0) + TEST_ERROR + + /* All tests passed */ + PASSED() + + return 0; + +error: + H5E_BEGIN_TRY { + if(ea) + H5EA_close(ea, H5P_DATASET_XFER_DEFAULT); + if(ea2) + H5EA_close(ea2, H5P_DATASET_XFER_DEFAULT); + H5Fclose(file); + H5Fclose(file2); + H5Fclose(file0); + H5Fclose(file00); + } H5E_END_TRY; + + return 1; +} /* test_open_twice_diff() */ + + +/*------------------------------------------------------------------------- * Function: test_delete_open * * Purpose: Delete opened extensible array (& open deleted array) @@ -1469,7 +1611,7 @@ eiter_fw_next(void *_eiter) * *------------------------------------------------------------------------- */ -static hssize_t +static H5_ATTR_PURE hssize_t eiter_fw_max(const void *_eiter) { const eiter_fw_t *eiter = (const eiter_fw_t *)_eiter; @@ -1687,7 +1829,7 @@ eiter_rv_next(void *_eiter) * *------------------------------------------------------------------------- */ -static hssize_t +static H5_ATTR_PURE hssize_t eiter_rv_max(const void *_eiter) { const eiter_rv_t *eiter = (const eiter_rv_t *)_eiter; @@ -1939,7 +2081,7 @@ eiter_rnd_next(void *_eiter) * *------------------------------------------------------------------------- */ -static hssize_t +static H5_ATTR_PURE hssize_t eiter_rnd_max(const void *_eiter) { const eiter_rnd_t *eiter = (const eiter_rnd_t *)_eiter; @@ -2160,7 +2302,7 @@ eiter_cyc_next(void *_eiter) * *------------------------------------------------------------------------- */ -static hssize_t +static H5_ATTR_PURE hssize_t eiter_cyc_max(const void *_eiter) { const eiter_cyc_t *eiter = (const eiter_cyc_t *)_eiter; @@ -2587,7 +2729,7 @@ main(void) /* Seed random #'s */ curr_time = HDtime(NULL); - HDsrandom((unsigned long)curr_time); + HDsrandom((unsigned)curr_time); /* Create an empty file to retrieve size */ { @@ -2638,6 +2780,7 @@ main(void) nerrors += test_create(fapl, &cparam, &tparam); nerrors += test_reopen(fapl, &cparam, &tparam); nerrors += test_open_twice(fapl, &cparam, &tparam); + nerrors += test_open_twice_diff(fapl, &cparam, &tparam); nerrors += test_delete_open(fapl, &cparam, &tparam); /* * nerrors += test_flush_depend(env_h5_drvr, fapl, &cparam, &tparam); diff --git a/test/farray.c b/test/farray.c index e3e59da..50a9856 100644 --- a/test/farray.c +++ b/test/farray.c @@ -102,6 +102,7 @@ struct farray_test_param_t { /* Local variables */ const char *FILENAME[] = { "farray", + "farray_tmp", NULL }; @@ -159,9 +160,8 @@ create_file(hid_t fapl, hid_t *file, H5F_t **f) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(*f) < 0) { + if(H5AC_ignore_tags(*f) < 0) FAIL_STACK_ERROR - } /* Success */ return(0); @@ -274,17 +274,19 @@ reopen_file(hid_t *file, H5F_t **f, hid_t fapl, hid_t dxpl, /* (actually will close & re-open the file as well) */ if(tparam->reopen_array) { /* Close array, if given */ - if(fa) { + if(fa && *fa) { if(H5FA_close(*fa, dxpl) < 0) FAIL_STACK_ERROR *fa = NULL; } /* end if */ /* Close file */ - if(H5Fclose(*file) < 0) - FAIL_STACK_ERROR - *file = (-1); - *f = NULL; + if(*file) { + if(H5Fclose(*file) < 0) + FAIL_STACK_ERROR + *file = (-1); + *f = NULL; + } /* end if */ /* Re-open the file */ if((*file = H5Fopen(filename_g, H5F_ACC_RDWR, fapl)) < 0) @@ -295,15 +297,13 @@ reopen_file(hid_t *file, H5F_t **f, hid_t fapl, hid_t dxpl, FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(*f) < 0) { + if(H5AC_ignore_tags(*f) < 0) FAIL_STACK_ERROR - } /* Re-open array, if given */ - if(fa) { + if(fa) if(NULL == (*fa = H5FA_open(*f, dxpl, fa_addr, NULL))) FAIL_STACK_ERROR - } /* end if */ } /* end if */ /* Success */ @@ -722,6 +722,144 @@ error: /*------------------------------------------------------------------------- + * Function: test_open_twice_diff + * + * Purpose: Open a fixed array twice, through different "top" file + * handles, with an intermediate file open that takes the "shared" + * file handle from the first fixed array's file pointer. + * + * Return: Success: 0 + * Failure: 1 + * + * Programmer: Quincey Koziol + * Friday, December 18, 2015 + * + *------------------------------------------------------------------------- + */ +static unsigned +test_open_twice_diff(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t *tparam) +{ + char filename_tmp[FARRAY_FILENAME_LEN]; /* Temporary file name */ + hid_t file = -1; /* File ID */ + hid_t file2 = -1; /* File ID */ + hid_t file0 = -1; /* File ID */ + hid_t file00 = -1; /* File ID */ + H5F_t *f = NULL; /* Internal file object pointer */ + H5F_t *f2 = NULL; /* Internal file object pointer */ + H5FA_t *fa = NULL; /* Fixed array wrapper */ + H5FA_t *fa2 = NULL; /* Fixed array wrapper */ + haddr_t fa_addr = HADDR_UNDEF; /* Array address in file */ + + /* + * Display testing message + */ + TESTING("open fixed array twice, through different file handles"); + + /* Create file & retrieve pointer to internal file object */ + if(create_file(fapl, &file, &f) < 0) + TEST_ERROR + + /* Create array */ + if(create_array(f, H5P_DATASET_XFER_DEFAULT, cparam, &fa, &fa_addr) < 0) + TEST_ERROR + + /* Open the array again, through the first file handle */ + if(NULL == (fa2 = H5FA_open(f, H5P_DATASET_XFER_DEFAULT, fa_addr, NULL))) + FAIL_STACK_ERROR + + /* Verify the creation parameters */ + if(verify_cparam(fa, cparam) < 0) + TEST_ERROR + if(verify_cparam(fa2, cparam) < 0) + TEST_ERROR + + /* Close the second fixed array wrapper */ + if(H5FA_close(fa2, H5P_DATASET_XFER_DEFAULT) < 0) + FAIL_STACK_ERROR + fa2 = NULL; + + /* Re-open the file */ + /* (So that there is something holding the file open when the extensible + * array is closed) + */ + if((file0 = H5Fopen(filename_g, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR + + /* Check for closing & re-opening the file */ + if(reopen_file(&file, &f, fapl, H5P_DATASET_XFER_DEFAULT, &fa, fa_addr, tparam) < 0) + TEST_ERROR + + /* Close the first fixed array wrapper */ + if(H5FA_close(fa, H5P_DATASET_XFER_DEFAULT) < 0) + FAIL_STACK_ERROR + fa = NULL; + + /* Close the first file */ + /* (close before second file, to detect error on internal array header's + * shared file information) + */ + if(H5Fclose(file) < 0) + FAIL_STACK_ERROR + file = -1; + + /* Open a different file */ + /* (This re-allocates the 'top' file pointer and assigns it a different + * 'shared' file pointer, making the file pointer in the fixed array's + * header stale) + */ + h5_fixname(FILENAME[1], fapl, filename_tmp, sizeof(filename_tmp)); + if((file00 = H5Fcreate(filename_tmp, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR + + + /* Re-open the file with the fixed array */ + if((file2 = H5Fopen(filename_g, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR + + /* Get a pointer to the internal file object */ + if(NULL == (f2 = (H5F_t *)H5I_object(file2))) + FAIL_STACK_ERROR + + /* Open the fixed array through the second file handle */ + if(NULL == (fa2 = H5FA_open(f2, H5P_DATASET_XFER_DEFAULT, fa_addr, NULL))) + FAIL_STACK_ERROR + + /* Verify the creation parameters */ + if(verify_cparam(fa2, cparam) < 0) + TEST_ERROR + + /* Close the extra file handles */ + if(H5Fclose(file0) < 0) + FAIL_STACK_ERROR + if(H5Fclose(file00) < 0) + FAIL_STACK_ERROR + + /* Close array, delete array, close file & verify file is empty */ + if(finish(file2, fapl, f2, fa2, fa_addr) < 0) + TEST_ERROR + + /* All tests passed */ + PASSED() + + return 0; + +error: + H5E_BEGIN_TRY { + if(fa) + H5FA_close(fa, H5P_DATASET_XFER_DEFAULT); + if(fa2) + H5FA_close(fa2, H5P_DATASET_XFER_DEFAULT); + H5Fclose(file); + H5Fclose(file2); + H5Fclose(file0); + H5Fclose(file00); + } H5E_END_TRY; + + return 1; +} /* test_open_twice_diff() */ + + +/*------------------------------------------------------------------------- * Function: test_delete_open * * Purpose: Delete opened fixed array (& open deleted array) @@ -1535,7 +1673,7 @@ main(void) /* Seed random #'s */ curr_time = HDtime(NULL); - HDsrandom((unsigned long)curr_time); + HDsrandom((unsigned)curr_time); /* Create an empty file to retrieve size */ { @@ -1586,6 +1724,7 @@ main(void) nerrors += test_create(fapl, &cparam, &tparam); nerrors += test_reopen(fapl, &cparam, &tparam); nerrors += test_open_twice(fapl, &cparam, &tparam); + nerrors += test_open_twice_diff(fapl, &cparam, &tparam); nerrors += test_delete_open(fapl, &cparam, &tparam); /* Iterate over the type of capacity tests */ diff --git a/test/ohdr.c b/test/ohdr.c index 6faced9..295d149 100644 --- a/test/ohdr.c +++ b/test/ohdr.c @@ -982,7 +982,6 @@ main(void) PASSED(); } - /* Close the file we created */ if(H5Fclose(file) < 0) TEST_ERROR diff --git a/test/swmr.c b/test/swmr.c index cb7aa81..1599acd 100644 --- a/test/swmr.c +++ b/test/swmr.c @@ -38,15 +38,15 @@ #define H5F_TESTING #include "H5Fpkg.h" /* File access */ +#define H5D_FRIEND /*suppress error about including H5FDpkg */ +#define H5D_TESTING +#include "H5Dpkg.h" + /* This file needs to access the file driver testing code */ #define H5FD_FRIEND /*suppress error about including H5FDpkg */ #define H5FD_TESTING #include "H5FDpkg.h" /* File drivers */ -#define H5D_FRIEND /*suppress error about including H5Dpkg */ -#define H5D_TESTING -#include "H5Dpkg.h" - const char *FILENAME[] = { "swmr0", /* 0 */ @@ -57,9 +57,6 @@ const char *FILENAME[] = { #define NAME_BUF_SIZE 1024 /* Length of file name */ -/* Name of message file that is used by test_start_swmr_write_concur() */ -#define DONE_MESSAGE "DONE_MESSAGE" /* The message file to create */ - /* Tests for H5Pget/set_metadata_read_attempts(), H5Fget_metadata_read_retry_info */ static int test_metadata_read_attempts(hid_t in_fapl); static int test_metadata_read_retry_info(hid_t in_fapl); @@ -92,6 +89,12 @@ static int test_file_lock_swmr_concur(hid_t fapl); /* Tests for SWMR VFD flag */ static int test_swmr_vfd_flag(void); +/* Tests for H5Drefresh: concurrent access */ +static int test_refresh_concur(hid_t in_fapl, hbool_t new_format); + +/* Tests for multiple opens of files and datasets with H5Drefresh() & H5Fstart_swmr_write(): same process */ +static int test_multiple_same(hid_t in_fapl, hbool_t new_format); + /* * Tests for H5Pget/set_metadata_read_attemps(), H5Fget_metadata_read_retry_info() */ @@ -1508,28 +1511,30 @@ error: /* * test_start_swmr_write(): * - * Verify SWMR writing is enabled via H5Fstart_swmr_write(): + * Verify SWMR writing is enabled via H5Fstart_swmr_write(): * Mainly test for file created with SWMR_WRITE + with/without latest format: * --file will have v3 superblock and all latest version support enabled * - * (a) Creating a file + * (A) Creating a file * Create a file with SWMR_WRITE + non-latest-format * Create a chunked dataset "dataset1" in the file -- should be using latest chunk indexing * Should fail to enable SWMR as the file is already in SWMR writing mode * Close the file * - * (a) Opening a file + * (B) Opening a file * Open the file with write + non-latest-format * --file has v3 superblock and all latest version support enabled - * Open dataset "dataset1"--keep it open - * Create a chunked dataset "dataset2" in the file -- should be using latest chunk indexing -- keep it open + * Open dataset "dataset1" 3 times--keep it open + * Write to "dataset1" + * Create a group in the file + * Create a chunked dataset "dataset2" in the group--should be using latest chunk indexing--keep it open * Should succeed in enabling SWMR - * Should succeed in writing/reading from "dataset1" - * Close "dataset1" and "dataset2" - * Create "dataset3" -- should be using latest chunk indexing + * Should succeed in reading from multiple opens of "dataset1" + * Close multiple opens of "dataset1" + * Close "dataset2" + * Create "dataset3"--should be using latest chunk indexing * Close "dataset3" - * Close the file - * + * Close the group and file */ static int test_start_swmr_write(hid_t in_fapl, hbool_t new_format) @@ -1540,6 +1545,7 @@ test_start_swmr_write(hid_t in_fapl, hbool_t new_format) hid_t dcpl = -1; /* Dataset creation property */ hid_t file_fapl = -1; /* File access property for the file */ hid_t did1 = -1, did2 = -1, did3 = -1; /* Dataset IDs */ + hid_t did1_a = -1, did1_b = -1; hid_t sid1 = -1, sid2 = -1, sid3 = -1; /* Dataspace IDs */ hsize_t dim[1] = {1}; /* Dimension sizes */ hsize_t max_dim[1] = {H5S_UNLIMITED}; /* Maximum dimension sizes */ @@ -1690,6 +1696,14 @@ test_start_swmr_write(hid_t in_fapl, hbool_t new_format) if((did1 = H5Dopen2(fid, "dataset1", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR; + /* open "dataset1" second time */ + if((did1_a = H5Dopen2(fid, "dataset1", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR; + + /* open "dataset1" third time */ + if((did1_b = H5Dopen2(fid, "dataset1", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR; + /* Write to "dataset1" */ wdata = 88; if(H5Dwrite(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &wdata) < 0) @@ -1735,16 +1749,33 @@ test_start_swmr_write(hid_t in_fapl, hbool_t new_format) if(H5Pclose(file_fapl) < 0) FAIL_STACK_ERROR; + rdata = 0; + /* Read from "dataset1" via did1_b (multiple opens) */ + if(H5Dread(did1_b, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdata) < 0) + FAIL_STACK_ERROR; + if(wdata != rdata) + FAIL_STACK_ERROR; + if(H5Dclose(did1_b) < 0) + FAIL_STACK_ERROR; + /* Read from "dataset1" */ + rdata = 0; if(H5Dread(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdata) < 0) FAIL_STACK_ERROR; if(wdata != rdata) FAIL_STACK_ERROR; - - /* Close "dataset1" */ if(H5Dclose(did1) < 0) FAIL_STACK_ERROR; + rdata = 0; + /* Read from "dataset1" via did1_a (multiple opens) */ + if(H5Dread(did1_a, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdata) < 0) + FAIL_STACK_ERROR; + if(wdata != rdata) + FAIL_STACK_ERROR; + if(H5Dclose(did1_a) < 0) + FAIL_STACK_ERROR; + /* Close "dataset2", dataspace, dataset creation property list */ if(H5Dclose(did2) < 0) FAIL_STACK_ERROR; @@ -1801,6 +1832,8 @@ error: H5Gclose(gid); H5Pclose(dcpl); H5Dclose(did1); + H5Dclose(did1_a); + H5Dclose(did1_b); H5Dclose(did2); H5Dclose(did3); H5Sclose(sid1); @@ -1843,17 +1876,17 @@ error: * --First time succeed, second time fail * --Close the file (2) --Open the file with write + with/without latest format - * --succeed to enable SWMR writing mode - * --reopen the same file + * --Succeed to enable SWMR writing mode + * --Reopen the same file * --fail to enable SWMR writing mode for the reopened file * --Close the file (3) --Open the file with write + with/without latest format - * --open the same file again + * --Open the same file again * --succeed to enable SWMR for the first opened file * --fail to enable SWMR for the second opened file * --Close the file * - * (E) (!new_format): When opening a file which is created with write + non-latest-format: + * (D) (!new_format): When opening a file which is created with write + non-latest-format: * (1) Open the file with SWMR write+latest format * --fail to open due to superblock version not 3 * (2) Open the file with SWMR write+non-latest-format @@ -2277,12 +2310,15 @@ error: * --result in v3 superblock with latest chunk indexing types * (b) Create the file with SWMR write + non-latest-format: * --result in v3 superblock with latest chunk indexing types + * Create a chunked dataset with 1 extendible dimension in the file * * Verify concurrent access for H5Fstart_swmr_write()-- * (1) Parent: open a file with write access * Child: concurrent open of the file with read & SWMR read (fail) * (2) Parent: open a file with write access; enable SWMR writing mode - * Child: concurrent open of the file with read & SWMR read (succeed) + * Child: open the file 2 times with read & SWMR read (succeed) + * open the dataset 2 times with the 2 file opens + * verify data read from multiple opens of the dataset is correct * (3) Parent: open a file with write access; enable SWMR writing mode * Child: Concurrent open of the file with read only (fail) * (4) Parent: open a file with write access; enable SWMR writing mode @@ -2305,7 +2341,7 @@ test_start_swmr_write_concur(hid_t H5_ATTR_UNUSED in_fapl, hbool_t H5_ATTR_UNUSE static int test_start_swmr_write_concur(hid_t in_fapl, hbool_t new_format) { - hid_t fid; /* File ID */ + hid_t fid = -1, fid1 = -1, fid2 = -1; /* File IDs */ hid_t fapl; /* File access property list */ pid_t childpid=0; /* Child process ID */ pid_t tmppid; /* Child process ID returned by waitpid */ @@ -2314,15 +2350,25 @@ test_start_swmr_write_concur(hid_t in_fapl, hbool_t new_format) int child_exit_val; /* Exit status of the child */ char filename[NAME_BUF_SIZE]; /* File name */ + hid_t did = -1, did1 = -1, did2 = -1, did3 = -1; + hid_t sid = -1; + hid_t dcpl = -1; + hsize_t chunk_dims[1] = {1}; + hsize_t maxdims[1] = {H5S_UNLIMITED}; + hsize_t dims[1] = {1}; + int wdata = 0; + + int out_pdf[2]; + int in_pdf[2]; + int notify = 0; + /* Output message about test being performed */ if(new_format) { - TESTING("Testing H5Fstart_swmr_write()--concurrent access for latest format"); + TESTING("H5Fstart_swmr_write()--concurrent access for latest format"); } else { - TESTING("Testing H5Fstart_swmr_write()--concurrent access for non-latest-format"); + TESTING("H5Fstart_swmr_write()--concurrent access for non-latest-format"); } /* end if */ - - if((fapl = H5Pcopy(in_fapl)) < 0) FAIL_STACK_ERROR @@ -2343,12 +2389,29 @@ test_start_swmr_write_concur(hid_t in_fapl, hbool_t new_format) FAIL_STACK_ERROR } /* end if */ + /* Create a chunked dataset with 1 extendible dimension */ + if((sid = H5Screate_simple(1, dims, maxdims)) < 0) + FAIL_STACK_ERROR; + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + FAIL_STACK_ERROR + if(H5Pset_chunk(dcpl, 1, chunk_dims) < 0) + FAIL_STACK_ERROR; + if((did = H5Dcreate2(fid, "dataset", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR; + + /* Close the dataset */ + if(H5Dclose(did) < 0) + FAIL_STACK_ERROR + if(H5Sclose(sid) < 0) + FAIL_STACK_ERROR + /* Close the file */ if(H5Fclose(fid) < 0) FAIL_STACK_ERROR - /* Remove the message file to be sure */ - HDremove(DONE_MESSAGE); + /* Create 1 pipe */ + if(HDpipe(out_pdf) < 0) + FAIL_STACK_ERROR /* * Case (1): @@ -2361,11 +2424,18 @@ test_start_swmr_write_concur(hid_t in_fapl, hbool_t new_format) FAIL_STACK_ERROR if(childpid == 0) { /* Child process */ + int child_notify = 0; - /* Wait till parent process completes the open */ - if(h5_wait_message(DONE_MESSAGE) < 0) + /* Close unused write end for out_pdf */ + if(HDclose(out_pdf[1]) < 0) HDexit(EXIT_FAILURE); + /* Wait for notification from parent process */ + while(child_notify != 1) { + if(HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) + HDexit(EXIT_FAILURE); + } + /* Should fail */ H5E_BEGIN_TRY { /* Open the test file */ @@ -2374,15 +2444,29 @@ test_start_swmr_write_concur(hid_t in_fapl, hbool_t new_format) if(fid >= 0) HDexit(EXIT_FAILURE); + /* Close the pipe */ + if(HDclose(out_pdf[0]) < 0) + HDexit(EXIT_FAILURE); + HDexit(EXIT_SUCCESS); } + /* close unused read end for out_pdf */ + if(HDclose(out_pdf[0]) < 0) + FAIL_STACK_ERROR + /* Open the test file */ if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR - /* Send the message that the open completes */ - h5_send_message(DONE_MESSAGE); + /* Notify child process */ + notify = 1; + if(HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) + FAIL_STACK_ERROR; + + /* Close the pipe */ + if(HDclose(out_pdf[1]) < 0) + FAIL_STACK_ERROR; /* Wait for child process to complete */ if((tmppid = HDwaitpid(childpid, &child_status, child_wait_option)) < 0) @@ -2405,38 +2489,176 @@ test_start_swmr_write_concur(hid_t in_fapl, hbool_t new_format) * will succeed with H5Fstart_swmr_write() */ - /* Remove the message file to be sure */ - HDremove(DONE_MESSAGE); + /* Create 2 pipes */ + if(HDpipe(out_pdf) < 0) + FAIL_STACK_ERROR + if(HDpipe(in_pdf) < 0) + FAIL_STACK_ERROR /* Fork child process */ if((childpid = HDfork()) < 0) FAIL_STACK_ERROR if(childpid == 0) { /* Child process */ - hid_t child_fid; /* File ID */ + hid_t child_fid1 = -1, child_fid2; /* File IDs */ + hid_t child_did1 = -1, child_did2 = -1; /* Dataset IDs */ + int child_notify = 0; + int rdata = 0; + + /* Close unused write end for out_pdf */ + if(HDclose(out_pdf[1]) < 0) + HDexit(EXIT_FAILURE); + /* close unused read end for in_pdf */ + if(HDclose(in_pdf[0]) < 0) + HDexit(EXIT_FAILURE); + + /* Wait for notification from parent process */ + while(child_notify != 1) { + if(HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) + HDexit(EXIT_FAILURE); + } + + /* Should succeed in opening the test file 2 times */ + if((child_fid1 = H5Fopen(filename, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, fapl)) < 0) + HDexit(EXIT_FAILURE); + if((child_fid2 = H5Fopen(filename, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, fapl)) < 0) + HDexit(EXIT_FAILURE); + + /* open "dataset" 2 times */ + if((child_did1 = H5Dopen2(child_fid1, "dataset", H5P_DEFAULT)) < 0) + HDexit(EXIT_FAILURE); + if((child_did2 = H5Dopen2(child_fid2, "dataset", H5P_DEFAULT)) < 0) + HDexit(EXIT_FAILURE); + + /* Read from "dataset" via child_did1 */ + rdata = 0; + if(H5Dread(child_did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdata) < 0) + HDexit(EXIT_FAILURE); + if(rdata != 88) + HDexit(EXIT_FAILURE); + + /* Notify parent process */ + child_notify = 2; + if(HDwrite(in_pdf[1], &child_notify, sizeof(int)) < 0) + HDexit(EXIT_FAILURE); + + /* Wait for notification from parent process */ + while(child_notify != 3) { + if(HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) + HDexit(EXIT_FAILURE); + } + + /* Refresh "dataset" via child_did2 */ + if(H5Drefresh(child_did2) < 0) + HDexit(EXIT_FAILURE); + + /* Read from "dataset" child_did2 */ + rdata = 0; + if(H5Dread(child_did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdata) < 0) + HDexit(EXIT_FAILURE); + if(rdata != 99) + HDexit(EXIT_FAILURE); + + /* Read from "dataset" child_did1 */ + rdata = 0; + if(H5Dread(child_did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdata) < 0) + HDexit(EXIT_FAILURE); + if(rdata != 99) + HDexit(EXIT_FAILURE); - /* Wait till parent process completes the open */ - if(h5_wait_message(DONE_MESSAGE) < 0) + /* Close the dataset */ + if(H5Dclose(child_did1)) + HDexit(EXIT_FAILURE); + if(H5Dclose(child_did2)) HDexit(EXIT_FAILURE); - /* Should succeed in opening the test file */ - if((child_fid = H5Fopen(filename, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, fapl)) < 0) + /* Close the file */ + if(H5Fclose(child_fid1) < 0) HDexit(EXIT_FAILURE); - if(H5Fclose(child_fid) < 0) + if(H5Fclose(child_fid2) < 0) HDexit(EXIT_FAILURE); + + /* Close the pipe */ + if(HDclose(out_pdf[0]) < 0) + HDexit(EXIT_FAILURE); + if(HDclose(in_pdf[1]) < 0) + HDexit(EXIT_FAILURE); + HDexit(EXIT_SUCCESS); } + /* close unused read end for out_pdf */ + if(HDclose(out_pdf[0]) < 0) + FAIL_STACK_ERROR + /* Close unused write end for in_pdf */ + if(HDclose(in_pdf[1]) < 0) + FAIL_STACK_ERROR + /* Open the test file */ - if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if((fid1 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR + if((fid2 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR + + /* open "dataset", keep it open */ + if((did1 = H5Dopen2(fid1, "dataset", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR; + if((did2 = H5Dopen2(fid2, "dataset", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR; + if((did3 = H5Dopen2(fid1, "dataset", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR; + + /* Write to "dataset" */ + wdata = 88; + if(H5Dwrite(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &wdata) < 0) + FAIL_STACK_ERROR; + + /* Flush to disk */ + if(H5Fflush(fid1, H5F_SCOPE_LOCAL) < 0) + FAIL_STACK_ERROR; /* Enable SWMR writing mode */ - if(H5Fstart_swmr_write(fid) < 0) + if(H5Fstart_swmr_write(fid1) < 0) TEST_ERROR - /* Send the message that H5Fstart_swmr_write() completes */ - h5_send_message(DONE_MESSAGE); + /* Notify child process */ + notify = 1; + if(HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) + FAIL_STACK_ERROR; + + /* Wait for notification from child process */ + while(notify != 2) { + if(HDread(in_pdf[0], ¬ify, sizeof(int)) < 0) + FAIL_STACK_ERROR; + } + + /* Write to "dataset" */ + wdata = 99; + if(H5Dwrite(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &wdata) < 0) + FAIL_STACK_ERROR; + + /* Flush to disk */ + if(H5Fflush(fid1, H5F_SCOPE_LOCAL) < 0) + FAIL_STACK_ERROR; + + /* Notify child process */ + notify = 3; + if(HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) + FAIL_STACK_ERROR; + + /* Close the dataset */ + if(H5Dclose(did1) < 0) + FAIL_STACK_ERROR + if(H5Dclose(did2) < 0) + FAIL_STACK_ERROR + if(H5Dclose(did3) < 0) + FAIL_STACK_ERROR + + /* Close the pipes */ + if(HDclose(out_pdf[1]) < 0) + FAIL_STACK_ERROR; + if(HDclose(in_pdf[0]) < 0) + FAIL_STACK_ERROR; /* Wait for child process to complete */ if((tmppid = HDwaitpid(childpid, &child_status, child_wait_option)) < 0) @@ -2450,28 +2672,38 @@ test_start_swmr_write_concur(hid_t in_fapl, hbool_t new_format) TEST_ERROR /* Close the file */ - if(H5Fclose(fid) < 0) + if(H5Fclose(fid1) < 0) + FAIL_STACK_ERROR + if(H5Fclose(fid2) < 0) FAIL_STACK_ERROR + /* * Case (3): * Verify concurrent file open with H5F_ACC_RDONLY * will fail with H5Fstart_swmr_write() */ - - /* Remove the message file to be sure */ - HDremove(DONE_MESSAGE); + /* Create 1 pipe */ + if(HDpipe(out_pdf) < 0) + FAIL_STACK_ERROR /* Fork child process */ if((childpid = HDfork()) < 0) FAIL_STACK_ERROR if(childpid == 0) { /* Child process */ + int child_notify = 0; - /* Wait till parent process completes the open */ - if(h5_wait_message(DONE_MESSAGE) < 0) + /* Close unused write end for out_pdf */ + if(HDclose(out_pdf[1]) < 0) HDexit(EXIT_FAILURE); + /* Wait for notification from parent process */ + while(child_notify != 1) { + if(HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) + HDexit(EXIT_FAILURE); + } + /* Should fail in opening the test file */ H5E_BEGIN_TRY { fid = H5Fopen(filename, H5F_ACC_RDONLY, fapl); @@ -2482,6 +2714,10 @@ test_start_swmr_write_concur(hid_t in_fapl, hbool_t new_format) HDexit(EXIT_SUCCESS); } /* end if */ + /* close unused read end for out_pdf */ + if(HDclose(out_pdf[0]) < 0) + FAIL_STACK_ERROR + /* Open the test file */ if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR @@ -2490,8 +2726,14 @@ test_start_swmr_write_concur(hid_t in_fapl, hbool_t new_format) if(H5Fstart_swmr_write(fid) < 0) TEST_ERROR - /* Send the message that H5Fstart_swmr_write() completes */ - h5_send_message(DONE_MESSAGE); + /* Notify child process */ + notify = 1; + if(HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) + FAIL_STACK_ERROR; + + /* Close the pipe */ + if(HDclose(out_pdf[1]) < 0) + FAIL_STACK_ERROR; /* Wait for child process to complete */ if((tmppid = HDwaitpid(childpid, &child_status, child_wait_option)) < 0) @@ -2514,19 +2756,27 @@ test_start_swmr_write_concur(hid_t in_fapl, hbool_t new_format) * will fail with H5Fstart_swmr_write() */ - /* Remove the message file to be sure */ - HDremove(DONE_MESSAGE); + /* Create 1 pipe */ + if(HDpipe(out_pdf) < 0) + FAIL_STACK_ERROR /* Fork child process */ if((childpid = HDfork()) < 0) FAIL_STACK_ERROR if(childpid == 0) { /* Child process */ + int child_notify = 0; - /* Wait till parent process completes the open */ - if(h5_wait_message(DONE_MESSAGE) < 0) + /* Close unused write end for out_pdf */ + if(HDclose(out_pdf[1]) < 0) HDexit(EXIT_FAILURE); + /* Wait for notification from parent process */ + while(child_notify != 1) { + if(HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) + HDexit(EXIT_FAILURE); + } + /* Should fail in opening the test file */ H5E_BEGIN_TRY { fid = H5Fopen(filename, H5F_ACC_RDWR, fapl); @@ -2534,9 +2784,17 @@ test_start_swmr_write_concur(hid_t in_fapl, hbool_t new_format) if(fid >= 0) HDexit(EXIT_FAILURE); + /* Close the pipe */ + if(HDclose(out_pdf[0]) < 0) + HDexit(EXIT_FAILURE); + HDexit(EXIT_SUCCESS); } /* end if */ + /* close unused read end for out_pdf */ + if(HDclose(out_pdf[0]) < 0) + FAIL_STACK_ERROR + /* Open the test file */ if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR @@ -2545,8 +2803,14 @@ test_start_swmr_write_concur(hid_t in_fapl, hbool_t new_format) if(H5Fstart_swmr_write(fid) < 0) TEST_ERROR - /* Send the message that H5Fstart_swmr_write() completes */ - h5_send_message(DONE_MESSAGE); + /* Notify child process */ + notify = 1; + if(HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) + FAIL_STACK_ERROR; + + /* Close the pipe */ + if(HDclose(out_pdf[1]) < 0) + FAIL_STACK_ERROR /* Wait for child process to complete */ if((tmppid = HDwaitpid(childpid, &child_status, child_wait_option)) < 0) @@ -2569,19 +2833,27 @@ test_start_swmr_write_concur(hid_t in_fapl, hbool_t new_format) * will fail with H5Fstart_swmr_write() */ - /* Remove the message file to be sure */ - HDremove(DONE_MESSAGE); + /* Create 1 pipe */ + if(HDpipe(out_pdf) < 0) + FAIL_STACK_ERROR /* Fork child process */ if((childpid = HDfork()) < 0) FAIL_STACK_ERROR if(childpid == 0) { /* Child process */ + int child_notify = 0; - /* Wait till parent process completes the open */ - if(h5_wait_message(DONE_MESSAGE) < 0) + /* Close unused write end for out_pdf */ + if(HDclose(out_pdf[1]) < 0) HDexit(EXIT_FAILURE); + /* Wait for notification from parent process */ + while(child_notify != 1) { + if(HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) + HDexit(EXIT_FAILURE); + } + /* Should fail in opening the test file */ H5E_BEGIN_TRY { fid = H5Fopen(filename, H5F_ACC_RDWR|H5F_ACC_SWMR_WRITE, fapl); @@ -2589,9 +2861,17 @@ test_start_swmr_write_concur(hid_t in_fapl, hbool_t new_format) if(fid >= 0) HDexit(EXIT_FAILURE); + /* Close the pipe */ + if(HDclose(out_pdf[0]) < 0) + HDexit(EXIT_FAILURE); + HDexit(EXIT_SUCCESS); } + /* close unused read end for out_pdf */ + if(HDclose(out_pdf[0]) < 0) + FAIL_STACK_ERROR + /* Open the test file */ if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR @@ -2600,8 +2880,14 @@ test_start_swmr_write_concur(hid_t in_fapl, hbool_t new_format) if(H5Fstart_swmr_write(fid) < 0) TEST_ERROR - /* Send the message that H5Fstart_swmr_write() completes */ - h5_send_message(DONE_MESSAGE); + /* Notify child process */ + notify = 1; + if(HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) + FAIL_STACK_ERROR; + + /* Close the pipe */ + if(HDclose(out_pdf[1]) < 0) + FAIL_STACK_ERROR; /* Wait for child process to complete */ if((tmppid = HDwaitpid(childpid, &child_status, child_wait_option)) < 0) @@ -2627,6 +2913,8 @@ test_start_swmr_write_concur(hid_t in_fapl, hbool_t new_format) error: H5E_BEGIN_TRY { + H5Sclose(sid); + H5Pclose(dcpl); H5Pclose(fapl); H5Fclose(fid); } H5E_END_TRY; @@ -4243,6 +4531,8 @@ test_file_lock_concur(hid_t in_fapl) pid_t childpid=0; /* Child process ID */ int child_status; /* Status passed to waitpid */ int child_wait_option=0; /* Options passed to waitpid */ + int out_pdf[2]; + int notify = 0; /* Output message about test being performed */ TESTING("File open with different combinations of flags--concurrent access"); @@ -4265,8 +4555,9 @@ test_file_lock_concur(hid_t in_fapl) * Case 1: 1) RDWR 2) RDWR : should fail */ - /* Remove the message file to be sure */ - HDremove(DONE_MESSAGE); + /* Create 1 pipe */ + if(HDpipe(out_pdf) < 0) + FAIL_STACK_ERROR /* Fork child process */ if((childpid = HDfork()) < 0) @@ -4274,11 +4565,18 @@ test_file_lock_concur(hid_t in_fapl) if(childpid == 0) { /* Child process */ hid_t child_fid; /* File ID */ + int child_notify = 0; - /* Wait till parent process completes the open */ - if(h5_wait_message(DONE_MESSAGE) < 0) + /* Close unused write end for out_pdf */ + if(HDclose(out_pdf[1]) < 0) HDexit(EXIT_FAILURE); + /* Wait for notification from parent process */ + while(child_notify != 1) { + if(HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) + HDexit(EXIT_FAILURE); + } + /* Open the test file */ H5E_BEGIN_TRY { child_fid = H5Fopen(filename, H5F_ACC_RDWR, fapl); @@ -4287,15 +4585,30 @@ test_file_lock_concur(hid_t in_fapl) /* Should fail */ if(child_fid == FAIL) HDexit(EXIT_SUCCESS); + + /* Close the pipe */ + if(HDclose(out_pdf[0]) < 0) + HDexit(EXIT_FAILURE); + HDexit(EXIT_FAILURE); } + /* close unused read end for out_pdf */ + if(HDclose(out_pdf[0]) < 0) + FAIL_STACK_ERROR + /* Open the test file */ if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR - /* Send the message that the open completes */ - h5_send_message(DONE_MESSAGE); + /* Notify child process */ + notify = 1; + if(HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) + FAIL_STACK_ERROR; + + /* Close the pipe */ + if(HDclose(out_pdf[1]) < 0) + FAIL_STACK_ERROR; /* Wait for child process to complete */ if(HDwaitpid(childpid, &child_status, child_wait_option) < 0) @@ -4303,9 +4616,9 @@ test_file_lock_concur(hid_t in_fapl) /* Check if child terminated normally */ if(WIFEXITED(child_status)) { - /* Check exit status of the child */ - if(WEXITSTATUS(child_status) != 0) - TEST_ERROR + /* Check exit status of the child */ + if(WEXITSTATUS(child_status) != 0) + TEST_ERROR } else FAIL_STACK_ERROR @@ -4316,8 +4629,9 @@ test_file_lock_concur(hid_t in_fapl) /* * Case 2: 1) RDWR 2) RDONLY : should fail */ - /* Remove the message file just to be sure */ - HDremove(DONE_MESSAGE); + /* Create 1 pipe */ + if(HDpipe(out_pdf) < 0) + FAIL_STACK_ERROR /* Fork child process */ if((childpid = HDfork()) < 0) @@ -4325,11 +4639,18 @@ test_file_lock_concur(hid_t in_fapl) if(childpid == 0) { /* Child process */ hid_t child_fid; /* File ID */ + int child_notify = 0; - /* Wait till parent process completes the open */ - if(h5_wait_message(DONE_MESSAGE) < 0) + /* Close unused write end for out_pdf */ + if(HDclose(out_pdf[1]) < 0) HDexit(EXIT_FAILURE); + /* Wait for notification from parent process */ + while(child_notify != 1) { + if(HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) + HDexit(EXIT_FAILURE); + } + /* Opens the test file */ H5E_BEGIN_TRY { child_fid = H5Fopen(filename, H5F_ACC_RDONLY, fapl); @@ -4338,15 +4659,30 @@ test_file_lock_concur(hid_t in_fapl) /* Should fail */ if(child_fid == FAIL) HDexit(EXIT_SUCCESS); + + /* Close the pipe */ + if(HDclose(out_pdf[0]) < 0) + HDexit(EXIT_FAILURE); + HDexit(EXIT_FAILURE); } + /* close unused read end for out_pdf */ + if(HDclose(out_pdf[0]) < 0) + FAIL_STACK_ERROR + /* Opens the test file */ if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR - /* Send the message that the open completes */ - h5_send_message(DONE_MESSAGE); + /* Notify child process */ + notify = 1; + if(HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) + FAIL_STACK_ERROR; + + /* Close the pipe */ + if(HDclose(out_pdf[1]) < 0) + FAIL_STACK_ERROR; /* Wait for child process to complete */ if(HDwaitpid(childpid, &child_status, child_wait_option) < 0) @@ -4368,8 +4704,9 @@ test_file_lock_concur(hid_t in_fapl) * Case 3: 1) RDONLY 2) RDWR : should fail */ - /* Remove the message file just to be sure */ - HDremove(DONE_MESSAGE); + /* Create 1 pipe */ + if(HDpipe(out_pdf) < 0) + FAIL_STACK_ERROR /* Fork child process */ if((childpid = HDfork()) < 0) @@ -4377,11 +4714,18 @@ test_file_lock_concur(hid_t in_fapl) if(childpid == 0) { /* Child process */ hid_t child_fid; /* File ID */ + int child_notify = 0; - /* Wait till parent process completes the open */ - if(h5_wait_message(DONE_MESSAGE) < 0) + /* Close unused write end for out_pdf */ + if(HDclose(out_pdf[1]) < 0) HDexit(EXIT_FAILURE); + /* Wait for notification from parent process */ + while(child_notify != 1) { + if(HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) + HDexit(EXIT_FAILURE); + } + /* Opens the test file */ H5E_BEGIN_TRY { child_fid = H5Fopen(filename, H5F_ACC_RDWR, fapl); @@ -4390,15 +4734,30 @@ test_file_lock_concur(hid_t in_fapl) /* Should fail */ if(child_fid == FAIL) HDexit(EXIT_SUCCESS); + + /* Close the pipe */ + if(HDclose(out_pdf[0]) < 0) + HDexit(EXIT_FAILURE); + HDexit(EXIT_FAILURE); } /* end if */ + /* close unused read end for out_pdf */ + if(HDclose(out_pdf[0]) < 0) + FAIL_STACK_ERROR + /* Opens the test file */ if((fid = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) FAIL_STACK_ERROR + + /* Notify child process */ + notify = 1; + if(HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) + FAIL_STACK_ERROR; - /* Send the message that the open completes */ - h5_send_message(DONE_MESSAGE); + /* Close the pipe */ + if(HDclose(out_pdf[1]) < 0) + FAIL_STACK_ERROR; /* Wait for child process to complete */ if(HDwaitpid(childpid, &child_status, child_wait_option) < 0) @@ -4420,7 +4779,9 @@ test_file_lock_concur(hid_t in_fapl) * Case 4: 1) RDONLY 2) RDONLY : should succeed */ - HDremove(DONE_MESSAGE); + /* Create 1 pipe */ + if(HDpipe(out_pdf) < 0) + FAIL_STACK_ERROR /* Fork child process */ if((childpid = HDfork()) < 0) @@ -4428,11 +4789,18 @@ test_file_lock_concur(hid_t in_fapl) if(childpid == 0) { /* Child process */ hid_t child_fid; /* File ID */ + int child_notify = 0; - /* Wait till parent process completes the open */ - if(h5_wait_message(DONE_MESSAGE) < 0) + /* Close unused write end for out_pdf */ + if(HDclose(out_pdf[1]) < 0) HDexit(EXIT_FAILURE); + /* Wait for notification from parent process */ + while(child_notify != 1) { + if(HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) + HDexit(EXIT_FAILURE); + } + /* Opens the test file */ H5E_BEGIN_TRY { child_fid = H5Fopen(filename, H5F_ACC_RDONLY, fapl); @@ -4442,19 +4810,34 @@ test_file_lock_concur(hid_t in_fapl) if(child_fid >= 0) { /* Close the file */ if(H5Fclose(child_fid) < 0) - FAIL_STACK_ERROR + HDexit(EXIT_FAILURE); + + /* Close the pipe */ + if(HDclose(out_pdf[0]) < 0) + HDexit(EXIT_FAILURE); + HDexit(EXIT_SUCCESS); } /* end if */ HDexit(EXIT_FAILURE); } /* end if */ + /* close unused read end for out_pdf */ + if(HDclose(out_pdf[0]) < 0) + FAIL_STACK_ERROR + /* Create file */ if((fid = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) FAIL_STACK_ERROR - /* Send the message that the open completes */ - h5_send_message(DONE_MESSAGE); + /* Notify child process */ + notify = 1; + if(HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) + FAIL_STACK_ERROR; + + /* Close the pipe */ + if(HDclose(out_pdf[1]) < 0) + FAIL_STACK_ERROR; /* Wait for child process to complete */ if(HDwaitpid(childpid, &child_status, child_wait_option) < 0) @@ -4524,6 +4907,8 @@ test_file_lock_swmr_concur(hid_t in_fapl) pid_t childpid=0; /* Child process ID */ int child_status; /* Status passed to waitpid */ int child_wait_option=0; /* Options passed to waitpid */ + int out_pdf[2]; + int notify = 0; /* Output message about test being performed */ TESTING("File open with different combintations of flags + SWMR flags--concurrent access"); @@ -4550,8 +4935,9 @@ test_file_lock_swmr_concur(hid_t in_fapl) * Case 1: 1) RDWR 2) RDWR|SWMR_WRITE : should fail */ - /* Remove the message file to be sure */ - HDremove(DONE_MESSAGE); + /* Create 1 pipe */ + if(HDpipe(out_pdf) < 0) + FAIL_STACK_ERROR /* Fork child process */ if((childpid = HDfork()) < 0) @@ -4559,11 +4945,18 @@ test_file_lock_swmr_concur(hid_t in_fapl) if(childpid == 0) { /* Child process */ hid_t child_fid; /* File ID */ + int child_notify = 0; - /* Wait till parent process completes the open */ - if(h5_wait_message(DONE_MESSAGE) < 0) + /* Close unused write end for out_pdf */ + if(HDclose(out_pdf[1]) < 0) HDexit(EXIT_FAILURE); + /* Wait for notification from parent process */ + while(child_notify != 1) { + if(HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) + HDexit(EXIT_FAILURE); + } + /* Open the test file */ H5E_BEGIN_TRY { child_fid = H5Fopen(filename, H5F_ACC_RDWR|H5F_ACC_SWMR_WRITE, fapl); @@ -4572,15 +4965,30 @@ test_file_lock_swmr_concur(hid_t in_fapl) /* Should fail */ if(child_fid == FAIL) HDexit(EXIT_SUCCESS); + + /* Close the pipe */ + if(HDclose(out_pdf[0]) < 0) + HDexit(EXIT_FAILURE); + HDexit(EXIT_FAILURE); } + /* close unused read end for out_pdf */ + if(HDclose(out_pdf[0]) < 0) + FAIL_STACK_ERROR + /* Open the test file */ if((fid = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - /* Send the message that the open completes */ - h5_send_message(DONE_MESSAGE); + /* Notify child process */ + notify = 1; + if(HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) + FAIL_STACK_ERROR; + + /* Close the pipe */ + if(HDclose(out_pdf[1]) < 0) + FAIL_STACK_ERROR; /* Wait for child process to complete */ if(HDwaitpid(childpid, &child_status, child_wait_option) < 0) @@ -4602,20 +5010,28 @@ test_file_lock_swmr_concur(hid_t in_fapl) * Case 2: 1) RDWR 2) RDONLY|SWMR_READ: should fail */ - /* Remove the message file to be sure */ - HDremove(DONE_MESSAGE); + /* Create 1 pipe */ + if(HDpipe(out_pdf) < 0) + FAIL_STACK_ERROR /* Fork child process */ if((childpid = HDfork()) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR if(childpid == 0) { /* Child process */ hid_t child_fid; /* File ID */ + int child_notify = 0; - /* Wait till parent process completes the open */ - if(h5_wait_message(DONE_MESSAGE) < 0) + /* Close unused write end for out_pdf */ + if(HDclose(out_pdf[1]) < 0) HDexit(EXIT_FAILURE); + /* Wait for notification from parent process */ + while(child_notify != 1) { + if(HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) + HDexit(EXIT_FAILURE); + } + /* Open the test file */ H5E_BEGIN_TRY { child_fid = H5Fopen(filename, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, fapl); @@ -4624,19 +5040,34 @@ test_file_lock_swmr_concur(hid_t in_fapl) /* Should fail */ if(child_fid == FAIL) HDexit(EXIT_SUCCESS); + + /* Close the pipe */ + if(HDclose(out_pdf[0]) < 0) + HDexit(EXIT_FAILURE); + HDexit(EXIT_FAILURE); } + /* close unused read end for out_pdf */ + if(HDclose(out_pdf[0]) < 0) + FAIL_STACK_ERROR + /* Open the test file */ if((fid = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - /* Send the message that the open completes */ - h5_send_message(DONE_MESSAGE); + /* Notify child process */ + notify = 1; + if(HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) + FAIL_STACK_ERROR; + + /* Close the pipe */ + if(HDclose(out_pdf[1]) < 0) + FAIL_STACK_ERROR; /* Wait for child process to complete */ if(HDwaitpid(childpid, &child_status, child_wait_option) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR /* Check if child terminated normally */ if(WIFEXITED(child_status)) { @@ -4654,8 +5085,9 @@ test_file_lock_swmr_concur(hid_t in_fapl) * Case 3: 1) RDWR|SWMR_WRITE 2) RDWR : should fail */ - /* Remove the message file to be sure */ - HDremove(DONE_MESSAGE); + /* Create 1 pipe */ + if(HDpipe(out_pdf) < 0) + FAIL_STACK_ERROR /* Fork child process */ if((childpid = HDfork()) < 0) @@ -4663,11 +5095,18 @@ test_file_lock_swmr_concur(hid_t in_fapl) if(childpid == 0) { /* Child process */ hid_t child_fid; /* File ID */ + int child_notify = 0; - /* Wait till parent process completes the open */ - if(h5_wait_message(DONE_MESSAGE) < 0) + /* Close unused write end for out_pdf */ + if(HDclose(out_pdf[1]) < 0) HDexit(EXIT_FAILURE); + /* Wait for notification from parent process */ + while(child_notify != 1) { + if(HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) + HDexit(EXIT_FAILURE); + } + /* Open the test file */ H5E_BEGIN_TRY { child_fid = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT); @@ -4676,15 +5115,30 @@ test_file_lock_swmr_concur(hid_t in_fapl) /* Should fail */ if(child_fid == FAIL) HDexit(EXIT_SUCCESS); + + /* Close the pipe */ + if(HDclose(out_pdf[0]) < 0) + HDexit(EXIT_FAILURE); + HDexit(EXIT_FAILURE); } + /* close unused read end for out_pdf */ + if(HDclose(out_pdf[0]) < 0) + FAIL_STACK_ERROR + /* Open the test file */ if((fid = H5Fopen(filename, H5F_ACC_RDWR|H5F_ACC_SWMR_WRITE, fapl)) < 0) FAIL_STACK_ERROR - /* Send the message that the open completes */ - h5_send_message(DONE_MESSAGE); + /* Notify child process */ + notify = 1; + if(HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) + FAIL_STACK_ERROR; + + /* Close the pipe */ + if(HDclose(out_pdf[1]) < 0) + FAIL_STACK_ERROR; /* Wait for child process to complete */ if(HDwaitpid(childpid, &child_status, child_wait_option) < 0) @@ -4706,8 +5160,8 @@ test_file_lock_swmr_concur(hid_t in_fapl) * Case 4: 1) RDWR|SWMR_WRITE 2) RDWR|SWMR_WRITE : should fail */ - /* Remove the message file just to be sure */ - HDremove(DONE_MESSAGE); + if(HDpipe(out_pdf) < 0) + FAIL_STACK_ERROR /* Fork child process */ if((childpid = HDfork()) < 0) @@ -4715,11 +5169,18 @@ test_file_lock_swmr_concur(hid_t in_fapl) if(childpid == 0) { /* Child process */ hid_t child_fid; /* File ID */ + int child_notify = 0; - /* Wait till parent process completes the open */ - if(h5_wait_message(DONE_MESSAGE) < 0) + /* Close unused write end for out_pdf */ + if(HDclose(out_pdf[1]) < 0) HDexit(EXIT_FAILURE); + /* Wait for notification from parent process */ + while(child_notify != 1) { + if(HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) + HDexit(EXIT_FAILURE); + } + /* Open the test file */ H5E_BEGIN_TRY { child_fid = H5Fopen(filename, H5F_ACC_RDWR|H5F_ACC_SWMR_WRITE, fapl); @@ -4728,15 +5189,30 @@ test_file_lock_swmr_concur(hid_t in_fapl) /* Should fail */ if(child_fid == FAIL) HDexit(EXIT_SUCCESS); + + /* Close the pipe */ + if(HDclose(out_pdf[0]) < 0) + HDexit(EXIT_FAILURE); + HDexit(EXIT_FAILURE); } + /* close unused read end for out_pdf */ + if(HDclose(out_pdf[0]) < 0) + FAIL_STACK_ERROR + /* Open the test file */ if((fid = H5Fopen(filename, H5F_ACC_RDWR|H5F_ACC_SWMR_WRITE, fapl)) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR - /* Send the message that the open completes */ - h5_send_message(DONE_MESSAGE); + /* Notify child process */ + notify = 1; + if(HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) + FAIL_STACK_ERROR; + + /* Close the pipe */ + if(HDclose(out_pdf[1]) < 0) + FAIL_STACK_ERROR; /* Wait for child process to complete */ if(HDwaitpid(childpid, &child_status, child_wait_option) < 0) @@ -4758,20 +5234,27 @@ test_file_lock_swmr_concur(hid_t in_fapl) * Case 5: 1) RDWR|SWMR_WRITE 2) RDONLY|SWMR_READ : should succeed */ - /* Remove the message file just to be sure */ - HDremove(DONE_MESSAGE); + if(HDpipe(out_pdf) < 0) + FAIL_STACK_ERROR /* Fork child process */ if((childpid = HDfork()) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR if(childpid == 0) { /* Child process */ hid_t child_fid; /* File ID */ + int child_notify = 0; - /* Wait till parent process completes the open */ - if(h5_wait_message(DONE_MESSAGE) < 0) + /* Close unused write end for out_pdf */ + if(HDclose(out_pdf[1]) < 0) HDexit(EXIT_FAILURE); + /* Wait for notification from parent process */ + while(child_notify != 1) { + if(HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) + HDexit(EXIT_FAILURE); + } + /* Open the test file */ H5E_BEGIN_TRY { child_fid = H5Fopen(filename, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, fapl); @@ -4783,15 +5266,30 @@ test_file_lock_swmr_concur(hid_t in_fapl) FAIL_STACK_ERROR HDexit(EXIT_SUCCESS); } + + /* Close the pipe */ + if(HDclose(out_pdf[0]) < 0) + HDexit(EXIT_FAILURE); + HDexit(EXIT_FAILURE); } + /* close unused read end for out_pdf */ + if(HDclose(out_pdf[0]) < 0) + FAIL_STACK_ERROR + /* Open the test file */ if((fid = H5Fopen(filename, H5F_ACC_RDWR|H5F_ACC_SWMR_WRITE, fapl)) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR + + /* Notify child process */ + notify = 1; + if(HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) + FAIL_STACK_ERROR; - /* Send the message that the open completes */ - h5_send_message(DONE_MESSAGE); + /* Close the pipe */ + if(HDclose(out_pdf[1]) < 0) + FAIL_STACK_ERROR; /* Wait for child process to complete */ if(HDwaitpid(childpid, &child_status, child_wait_option) < 0) @@ -4813,8 +5311,8 @@ test_file_lock_swmr_concur(hid_t in_fapl) * Case 6: 1) RDWR|SWMR_WRITE 2) RDONLY : should fail */ - /* Remove the message file just to be sure */ - HDremove(DONE_MESSAGE); + if(HDpipe(out_pdf) < 0) + FAIL_STACK_ERROR /* Fork child process */ if((childpid = HDfork()) < 0) @@ -4822,11 +5320,18 @@ test_file_lock_swmr_concur(hid_t in_fapl) if(childpid == 0) { /* Child process */ hid_t child_fid; /* File ID */ + int child_notify = 0; - /* Wait till parent process completes the open */ - if(h5_wait_message(DONE_MESSAGE) < 0) + /* Close unused write end for out_pdf */ + if(HDclose(out_pdf[1]) < 0) HDexit(EXIT_FAILURE); + /* Wait for notification from parent process */ + while(child_notify != 1) { + if(HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) + HDexit(EXIT_FAILURE); + } + /* Open the test file */ H5E_BEGIN_TRY { child_fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT); @@ -4835,15 +5340,30 @@ test_file_lock_swmr_concur(hid_t in_fapl) /* Should fail */ if(child_fid == FAIL) HDexit(EXIT_SUCCESS); + + /* Close the pipe */ + if(HDclose(out_pdf[0]) < 0) + HDexit(EXIT_FAILURE); + HDexit(EXIT_FAILURE); } + /* close unused read end for out_pdf */ + if(HDclose(out_pdf[0]) < 0) + FAIL_STACK_ERROR + /* Open the test file */ if((fid = H5Fopen(filename, H5F_ACC_RDWR|H5F_ACC_SWMR_WRITE, fapl)) < 0) FAIL_STACK_ERROR - /* Send the message that the open completes */ - h5_send_message(DONE_MESSAGE); + /* Notify child process */ + notify = 1; + if(HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) + FAIL_STACK_ERROR; + + /* Close the pipe */ + if(HDclose(out_pdf[1]) < 0) + FAIL_STACK_ERROR; /* Wait for child process to complete */ if(HDwaitpid(childpid, &child_status, child_wait_option) < 0) @@ -4865,8 +5385,9 @@ test_file_lock_swmr_concur(hid_t in_fapl) * Case 7: 1) RDONLY|SWMR_READ 2) RDWR : should fail */ - /* Remove the message file just to be sure */ - HDremove(DONE_MESSAGE); + /* Create 1 pipe */ + if(HDpipe(out_pdf) < 0) + FAIL_STACK_ERROR /* Fork child process */ if((childpid = HDfork()) < 0) @@ -4874,11 +5395,18 @@ test_file_lock_swmr_concur(hid_t in_fapl) if(childpid == 0) { /* Child process */ hid_t child_fid; /* File ID */ + int child_notify = 0; - /* Wait till parent process completes the open */ - if(h5_wait_message(DONE_MESSAGE) < 0) + /* Close unused write end for out_pdf */ + if(HDclose(out_pdf[1]) < 0) HDexit(EXIT_FAILURE); + /* Wait for notification from parent process */ + while(child_notify != 1) { + if(HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) + HDexit(EXIT_FAILURE); + } + /* Open the test file */ H5E_BEGIN_TRY { child_fid = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT); @@ -4887,15 +5415,30 @@ test_file_lock_swmr_concur(hid_t in_fapl) /* Should fail */ if(child_fid == FAIL) HDexit(EXIT_SUCCESS); + + /* Close the pipe */ + if(HDclose(out_pdf[0]) < 0) + HDexit(EXIT_FAILURE); + HDexit(EXIT_FAILURE); } + /* close unused read end for out_pdf */ + if(HDclose(out_pdf[0]) < 0) + FAIL_STACK_ERROR + /* Open the test file */ if((fid = H5Fopen(filename, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, fapl)) < 0) FAIL_STACK_ERROR - /* Send the message that the open completes */ - h5_send_message(DONE_MESSAGE); + /* Notify child process */ + notify = 1; + if(HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) + FAIL_STACK_ERROR; + + /* Close the pipe */ + if(HDclose(out_pdf[1]) < 0) + FAIL_STACK_ERROR; /* Wait for child process to complete */ if(HDwaitpid(childpid, &child_status, child_wait_option) < 0) @@ -4917,8 +5460,9 @@ test_file_lock_swmr_concur(hid_t in_fapl) * Case 8: 1) RDONLY|SWMR_READ 2) RDWR|SWMR_WRITE : should fail */ - /* Remove the message file just to be sure */ - HDremove(DONE_MESSAGE); + /* Create 1 pipe */ + if(HDpipe(out_pdf) < 0) + FAIL_STACK_ERROR /* Fork child process */ if((childpid = HDfork()) < 0) @@ -4926,11 +5470,18 @@ test_file_lock_swmr_concur(hid_t in_fapl) if(childpid == 0) { /* Child process */ hid_t child_fid; /* File ID */ + int child_notify = 0; - /* Wait till parent process completes the open */ - if(h5_wait_message(DONE_MESSAGE) < 0) + /* Close unused write end for out_pdf */ + if(HDclose(out_pdf[1]) < 0) HDexit(EXIT_FAILURE); + /* Wait for notification from parent process */ + while(child_notify != 1) { + if(HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) + HDexit(EXIT_FAILURE); + } + /* Open the test file */ H5E_BEGIN_TRY { child_fid = H5Fopen(filename, H5F_ACC_RDWR|H5F_ACC_SWMR_WRITE, fapl); @@ -4939,15 +5490,30 @@ test_file_lock_swmr_concur(hid_t in_fapl) /* Should fail */ if(child_fid == FAIL) HDexit(EXIT_SUCCESS); + + /* Close the pipe */ + if(HDclose(out_pdf[0]) < 0) + HDexit(EXIT_FAILURE); + HDexit(EXIT_FAILURE); } + /* close unused read end for out_pdf */ + if(HDclose(out_pdf[0]) < 0) + FAIL_STACK_ERROR + /* Open the test file */ if((fid = H5Fopen(filename, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, fapl)) < 0) FAIL_STACK_ERROR - /* Send the message that the open completes */ - h5_send_message(DONE_MESSAGE); + /* Notify child process */ + notify = 1; + if(HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) + FAIL_STACK_ERROR; + + /* Close the pipe */ + if(HDclose(out_pdf[1]) < 0) + FAIL_STACK_ERROR; /* Wait for child process to complete */ if(HDwaitpid(childpid, &child_status, child_wait_option) < 0) @@ -4969,8 +5535,9 @@ test_file_lock_swmr_concur(hid_t in_fapl) * Case 9: 1) RDONLY|SWMR_READ 2) RDONLY|SWMR_READ : should succeed */ - /* Remove the message file just to be sure */ - HDremove(DONE_MESSAGE); + /* Create 1 pipe */ + if(HDpipe(out_pdf) < 0) + FAIL_STACK_ERROR /* Fork child process */ if((childpid = HDfork()) < 0) @@ -4978,11 +5545,18 @@ test_file_lock_swmr_concur(hid_t in_fapl) if(childpid == 0) { /* Child process */ hid_t child_fid; /* File ID */ + int child_notify = 0; - /* Wait till parent process completes the open */ - if(h5_wait_message(DONE_MESSAGE) < 0) + /* Close unused write end for out_pdf */ + if(HDclose(out_pdf[1]) < 0) HDexit(EXIT_FAILURE); + /* Wait for notification from parent process */ + while(child_notify != 1) { + if(HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) + HDexit(EXIT_FAILURE); + } + /* Open the test file */ H5E_BEGIN_TRY { child_fid = H5Fopen(filename, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, fapl); @@ -4994,15 +5568,30 @@ test_file_lock_swmr_concur(hid_t in_fapl) FAIL_STACK_ERROR HDexit(EXIT_SUCCESS); } + + /* Close the pipe */ + if(HDclose(out_pdf[0]) < 0) + HDexit(EXIT_FAILURE); + HDexit(EXIT_FAILURE); } + /* close unused read end for out_pdf */ + if(HDclose(out_pdf[0]) < 0) + FAIL_STACK_ERROR + /* Open the test file */ if((fid = H5Fopen(filename, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, fapl)) < 0) FAIL_STACK_ERROR - /* Send the message that the open completes */ - h5_send_message(DONE_MESSAGE); + /* Notify child process */ + notify = 1; + if(HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) + FAIL_STACK_ERROR; + + /* Close the pipe */ + if(HDclose(out_pdf[1]) < 0) + FAIL_STACK_ERROR; /* Wait for child process to complete */ if(HDwaitpid(childpid, &child_status, child_wait_option) < 0) @@ -5024,8 +5613,9 @@ test_file_lock_swmr_concur(hid_t in_fapl) * Case 10: 1) RDONLY|SWMR_READ 2) RDONLY : should succeed */ - /* Remove the message file just to be sure */ - HDremove(DONE_MESSAGE); + /* Create 1 pipe */ + if(HDpipe(out_pdf) < 0) + FAIL_STACK_ERROR /* Fork child process */ if((childpid = HDfork()) < 0) @@ -5033,11 +5623,18 @@ test_file_lock_swmr_concur(hid_t in_fapl) if(childpid == 0) { /* Child process */ hid_t child_fid; /* File ID */ + int child_notify = 0; - /* Wait till parent process completes the open */ - if(h5_wait_message(DONE_MESSAGE) < 0) + /* Close unused write end for out_pdf */ + if(HDclose(out_pdf[1]) < 0) HDexit(EXIT_FAILURE); + /* Wait for notification from parent process */ + while(child_notify != 1) { + if(HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) + HDexit(EXIT_FAILURE); + } + /* Open the test file */ if((child_fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR @@ -5048,15 +5645,30 @@ test_file_lock_swmr_concur(hid_t in_fapl) FAIL_STACK_ERROR HDexit(EXIT_SUCCESS); } + + /* Close the pipe */ + if(HDclose(out_pdf[0]) < 0) + HDexit(EXIT_FAILURE); + HDexit(EXIT_FAILURE); } + /* close unused read end for out_pdf */ + if(HDclose(out_pdf[0]) < 0) + FAIL_STACK_ERROR + /* Open the test file */ if((fid = H5Fopen(filename, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, fapl)) < 0) FAIL_STACK_ERROR - /* Send the message that the open completes */ - h5_send_message(DONE_MESSAGE); + /* Notify child process */ + notify = 1; + if(HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) + FAIL_STACK_ERROR; + + /* Close the pipe */ + if(HDclose(out_pdf[1]) < 0) + FAIL_STACK_ERROR; /* Wait for child process to complete */ if(HDwaitpid(childpid, &child_status, child_wait_option) < 0) @@ -5078,8 +5690,9 @@ test_file_lock_swmr_concur(hid_t in_fapl) * Case 11: 1) RDONLY 2) RDWR|SWMR_WRITE : should fail */ - /* Remove the message file just to be sure */ - HDremove(DONE_MESSAGE); + /* Create 1 pipe */ + if(HDpipe(out_pdf) < 0) + FAIL_STACK_ERROR /* Fork child process */ if((childpid = HDfork()) < 0) @@ -5087,11 +5700,18 @@ test_file_lock_swmr_concur(hid_t in_fapl) if(childpid == 0) { /* Child process */ hid_t child_fid; /* File ID */ + int child_notify = 0; - /* Wait till parent process completes the open */ - if(h5_wait_message(DONE_MESSAGE) < 0) + /* Close unused write end for out_pdf */ + if(HDclose(out_pdf[1]) < 0) HDexit(EXIT_FAILURE); + /* Wait for notification from parent process */ + while(child_notify != 1) { + if(HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) + HDexit(EXIT_FAILURE); + } + /* Open the test file */ H5E_BEGIN_TRY { child_fid = H5Fopen(filename, H5F_ACC_RDWR|H5F_ACC_SWMR_WRITE, fapl); @@ -5100,15 +5720,30 @@ test_file_lock_swmr_concur(hid_t in_fapl) /* Should fail */ if(child_fid == FAIL) HDexit(EXIT_SUCCESS); + + /* Close the pipe */ + if(HDclose(out_pdf[0]) < 0) + HDexit(EXIT_FAILURE); + HDexit(EXIT_FAILURE); } + /* Close unused read end for out_pdf */ + if(HDclose(out_pdf[0]) < 0) + FAIL_STACK_ERROR + /* Open the test file */ if((fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - /* Send the message that the open completes */ - h5_send_message(DONE_MESSAGE); + /* Notify child process */ + notify = 1; + if(HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) + FAIL_STACK_ERROR; + + /* Close the pipe */ + if(HDclose(out_pdf[1]) < 0) + FAIL_STACK_ERROR; /* Wait for child process to complete */ if(HDwaitpid(childpid, &child_status, child_wait_option) < 0) @@ -5130,8 +5765,9 @@ test_file_lock_swmr_concur(hid_t in_fapl) * Case 12: 1) RDONLY 2) RDONLY|SWMR_READ : should succeed */ - /* Remove the message file just to be sure */ - HDremove(DONE_MESSAGE); + /* Create 1 pipe */ + if(HDpipe(out_pdf) < 0) + FAIL_STACK_ERROR /* Fork child process */ if((childpid = HDfork()) < 0) @@ -5139,11 +5775,18 @@ test_file_lock_swmr_concur(hid_t in_fapl) if(childpid == 0) { /* Child process */ hid_t child_fid; /* File ID */ + int child_notify = 0; - /* Wait till parent process completes the open */ - if(h5_wait_message(DONE_MESSAGE) < 0) + /* Close unused write end for out_pdf */ + if(HDclose(out_pdf[1]) < 0) HDexit(EXIT_FAILURE); + /* Wait for notification from parent process */ + while(child_notify != 1) { + if(HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) + HDexit(EXIT_FAILURE); + } + /* Open the test file */ H5E_BEGIN_TRY { child_fid = H5Fopen(filename, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, fapl); @@ -5155,15 +5798,30 @@ test_file_lock_swmr_concur(hid_t in_fapl) FAIL_STACK_ERROR HDexit(EXIT_SUCCESS); } + + /* Close the pipe */ + if(HDclose(out_pdf[0]) < 0) + HDexit(EXIT_FAILURE); + HDexit(EXIT_FAILURE); } + /* close unused read end for out_pdf */ + if(HDclose(out_pdf[0]) < 0) + FAIL_STACK_ERROR + /* Open the test file */ if((fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - /* Send the message that the open completes */ - h5_send_message(DONE_MESSAGE); + /* Notify child process */ + notify = 1; + if(HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) + FAIL_STACK_ERROR; + + /* Close the pipe */ + if(HDclose(out_pdf[1]) < 0) + FAIL_STACK_ERROR; /* Wait for child process to complete */ if(HDwaitpid(childpid, &child_status, child_wait_option) < 0) @@ -5364,6 +6022,664 @@ error: } /* test_bug_refresh() */ #endif /* OUT */ +/* + * test_refresh_concur(): + * + * The "new_format" parameter indicates whether to create the file with latest format or not. + * To have SWMR support, can use either one of the following in creating a file: + * (a) Create the file with write + latest format: + * --result in v3 superblock with latest chunk indexing types + * (b) Create the file with SWMR write + non-latest-format: + * --result in v3 superblock with latest chunk indexing types + * + * Verify H5Drefresh() works correctly with concurrent access: + * Parent process: + * (1) Open the test file, write to the dataset + * (2) Notify child process #A + * (3) Wait for notification from child process #B + * (4) Extend the dataset, write to the dataset, flush the file + * (5) Notify child process #C + * Child process: + * (1) Wait for notification from parent process #A + * (2) Open the file 2 times + * (3) Open the dataset 2 times with the 2 files + * (4) Verify the dataset's dimension and data read are correct + * (5) Notify parent process #B + * (6) Wait for notification from parent process #C + * (7) Refresh the dataset + * (8) Verify the dataset's dimension and data are correct + */ +#if !(defined(H5_HAVE_FORK) && defined(H5_HAVE_WAITPID)) + +static int +test_refresh_concur(hid_t H5_ATTR_UNUSED in_fapl, hbool_t H5_ATTR_UNUSED new_format) +{ + SKIPPED(); + HDputs(" Test skipped due to fork or waitpid not defined."); + return 0; +} /* test_refresh_concur() */ + +#else /* defined(H5_HAVE_FORK && defined(H5_HAVE_WAITPID) */ + +static int +test_refresh_concur(hid_t in_fapl, hbool_t new_format) +{ + hid_t fid; /* File ID */ + hid_t fapl; /* File access property list */ + pid_t childpid=0; /* Child process ID */ + pid_t tmppid; /* Child process ID returned by waitpid */ + int child_status; /* Status passed to waitpid */ + int child_wait_option=0; /* Options passed to waitpid */ + int child_exit_val; /* Exit status of the child */ + char filename[NAME_BUF_SIZE]; /* File name */ + + hid_t did = -1; + hid_t sid = -1; + hid_t dcpl = -1; + hsize_t chunk_dims[1] = {1}; + hsize_t maxdims[1] = {H5S_UNLIMITED}; + hsize_t dims[1] = { 1 }; + hsize_t new_dims[1] = {2}; + + int out_pdf[2]; + int in_pdf[2]; + int notify = 0; + int wbuf[2]; + + /* Output message about test being performed */ + if(new_format) { + TESTING("H5Drefresh()--concurrent access for latest format"); + } else { + TESTING("H5Drefresh()--concurrent access for non-latest-format"); + } /* end if */ + + + if((fapl = H5Pcopy(in_fapl)) < 0) + FAIL_STACK_ERROR + + /* Set the filename to use for this test (dependent on fapl) */ + h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); + + if(new_format) { + /* Set to use the latest library format */ + if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + FAIL_STACK_ERROR + + /* Create the test file */ + if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR + } else { + /* Create the test file without latest format but with SWMR write */ + if((fid = H5Fcreate(filename, H5F_ACC_TRUNC|H5F_ACC_SWMR_WRITE, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR + } /* end if */ + + /* Create a chunked dataset with 1 extendible dimension */ + if((sid = H5Screate_simple(1, dims, maxdims)) < 0) + FAIL_STACK_ERROR; + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + FAIL_STACK_ERROR + if(H5Pset_chunk(dcpl, 1, chunk_dims) < 0) + FAIL_STACK_ERROR; + if((did = H5Dcreate2(fid, "dataset", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR; + + /* Closing */ + if(H5Dclose(did) < 0) + FAIL_STACK_ERROR + if(H5Sclose(sid) < 0) + FAIL_STACK_ERROR + if(H5Pclose(dcpl) < 0) + FAIL_STACK_ERROR + + /* Close the file */ + if(H5Fclose(fid) < 0) + FAIL_STACK_ERROR + + /* Create 2 pipes */ + if(HDpipe(out_pdf) < 0) + FAIL_STACK_ERROR + if(HDpipe(in_pdf) < 0) + FAIL_STACK_ERROR + + /* Fork child process */ + if((childpid = HDfork()) < 0) + FAIL_STACK_ERROR + + if(childpid == 0) { /* Child process */ + hid_t child_fid1 = -1; /* File ID */ + hid_t child_fid2 = -1; /* File ID */ + hid_t child_did1 = -1, child_did2 = -1; + hid_t child_sid = -1; + hsize_t tdims[1]; + int rbuf[2] = {0, 0}; + int child_notify = 0; + + /* Close unused write end for out_pdf */ + if(HDclose(out_pdf[1]) < 0) + HDexit(EXIT_FAILURE); + + /* close unused read end for in_pdf */ + if(HDclose(in_pdf[0]) < 0) + HDexit(EXIT_FAILURE); + + /* Wait for notification from parent process */ + while(child_notify != 1) { + if(HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) + HDexit(EXIT_FAILURE); + } + + /* Open the file 2 times */ + if((child_fid1 = H5Fopen(filename, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, fapl)) < 0) + HDexit(EXIT_FAILURE); + + if((child_fid2 = H5Fopen(filename, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, fapl)) < 0) + HDexit(EXIT_FAILURE); + + /* Open the dataset 2 times */ + if((child_did1 = H5Dopen2(child_fid1, "dataset", H5P_DEFAULT)) < 0) + HDexit(EXIT_FAILURE); + if((child_did2 = H5Dopen2(child_fid2, "dataset", H5P_DEFAULT)) < 0) + HDexit(EXIT_FAILURE); + + /* Get the dataset's dataspace via did1 */ + if((child_sid = H5Dget_space(child_did1)) < 0) + HDexit(EXIT_FAILURE); + if(H5Sget_simple_extent_dims(child_sid, tdims, NULL) < 0) + HDexit(EXIT_FAILURE); + if(tdims[0] != 1) + HDexit(EXIT_FAILURE); + + /* Read from the dataset via did2 */ + if(H5Dread(child_did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) + HDexit(EXIT_FAILURE); + + /* Verify the data is correct */ + if(rbuf[0] != 99) + HDexit(EXIT_FAILURE); + + /* Notify parent process */ + child_notify = 2; + if(HDwrite(in_pdf[1], &child_notify, sizeof(int)) < 0) + HDexit(EXIT_FAILURE); + + /* Wait for notification from parent process */ + while(child_notify != 3) { + if(HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) + HDexit(EXIT_FAILURE); + } + + /* Refresh dataset via did1 */ + if(H5Drefresh(child_did1) < 0) + HDexit(EXIT_FAILURE); + + /* Get the dataset's dataspace and verify */ + if((child_sid = H5Dget_space(child_did1)) < 0) + HDexit(EXIT_FAILURE); + if(H5Sget_simple_extent_dims(child_sid, tdims, NULL) < 0) + HDexit(EXIT_FAILURE); + + if(tdims[0] != 2) + HDexit(EXIT_FAILURE); + + /* Read from the dataset */ + if(H5Dread(child_did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) + HDexit(EXIT_FAILURE); + + /* Verify the data is correct */ + if(rbuf[0] != 100 || rbuf[1] != 100) + HDexit(EXIT_FAILURE); + + /* Close the 2 datasets */ + if(H5Dclose(child_did1) < 0) + HDexit(EXIT_FAILURE); + if(H5Dclose(child_did2) < 0) + HDexit(EXIT_FAILURE); + + /* Close the 2 files */ + if(H5Fclose(child_fid1) < 0) + HDexit(EXIT_FAILURE); + if(H5Fclose(child_fid2) < 0) + HDexit(EXIT_FAILURE); + + /* Close the pipes */ + if(HDclose(out_pdf[0]) < 0) + HDexit(EXIT_FAILURE); + if(HDclose(in_pdf[1]) < 0) + HDexit(EXIT_FAILURE); + + HDexit(EXIT_SUCCESS); + } + + /* Close unused read end for out_pdf */ + if(HDclose(out_pdf[0]) < 0) + FAIL_STACK_ERROR + /* Close unused write end for in_pdf */ + if(HDclose(in_pdf[1]) < 0) + FAIL_STACK_ERROR + + /* Open the test file */ + if((fid = H5Fopen(filename, H5F_ACC_RDWR|H5F_ACC_SWMR_WRITE, fapl)) < 0) + FAIL_STACK_ERROR + + /* Open the dataset */ + if((did = H5Dopen2(fid, "dataset", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR; + + /* Write to the dataset */ + wbuf[0] = wbuf[1] = 99; + if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf) < 0) + FAIL_STACK_ERROR; + + /* Flush to disk */ + if(H5Fflush(fid, H5F_SCOPE_LOCAL) < 0) + FAIL_STACK_ERROR; + + /* Notify child process */ + notify = 1; + if(HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) + FAIL_STACK_ERROR; + + + /* Wait for notification from child process */ + while(notify != 2) { + if(HDread(in_pdf[0], ¬ify, sizeof(int)) < 0) + FAIL_STACK_ERROR; + } + + /* Extend the dataset */ + if(H5Dset_extent(did, new_dims) < 0) + FAIL_STACK_ERROR; + + /* Write to the dataset */ + wbuf[0] = wbuf[1] = 100; + if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf) < 0) + FAIL_STACK_ERROR; + + /* Flush to disk */ + if(H5Fflush(fid, H5F_SCOPE_LOCAL) < 0) + FAIL_STACK_ERROR; + + /* Notify child process */ + notify = 3; + if(HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) + FAIL_STACK_ERROR; + + /* Close the pipes */ + if(HDclose(out_pdf[1]) < 0) + FAIL_STACK_ERROR; + if(HDclose(in_pdf[0]) < 0) + FAIL_STACK_ERROR; + + /* Wait for child process to complete */ + if((tmppid = HDwaitpid(childpid, &child_status, child_wait_option)) < 0) + FAIL_STACK_ERROR + + /* Check exit status of child process */ + if(WIFEXITED(child_status)) { + if((child_exit_val = WEXITSTATUS(child_status)) != 0) + TEST_ERROR + } else /* Child process terminated abnormally */ + TEST_ERROR + + /* Close the dataset */ + if(H5Dclose(did) < 0) + FAIL_STACK_ERROR + + /* Close the file */ + if(H5Fclose(fid) < 0) + FAIL_STACK_ERROR + + /* Close the property list */ + if(H5Pclose(fapl) < 0) + FAIL_STACK_ERROR + + PASSED(); + return 0; + +error: + H5E_BEGIN_TRY { + H5Dclose(did); + H5Sclose(sid); + H5Pclose(dcpl); + H5Pclose(fapl); + H5Fclose(fid); + } H5E_END_TRY; + + return -1; + +} /* test_refresh_concur() */ +#endif /* !(defined(H5_HAVE_FORK) && defined(H5_HAVE_WAITPID)) */ + +/* + * test_multiple_same(): + * + * The "new_format" parameter indicates whether to create the file with latest format or not. + * To have SWMR support, can use either one of the following in creating a file: + * (a) Create the file with write + latest format: + * --result in v3 superblock with latest chunk indexing types + * (b) Create the file with SWMR write + non-latest-format: + * --result in v3 superblock with latest chunk indexing types + * + * Verify that H5Drefresh() and H5Fstart_swmr_write() work properly with multiple + * opens of files and datasets. + */ +static int +test_multiple_same(hid_t in_fapl, hbool_t new_format) +{ + hid_t fid = -1, fid1 = -1, fid2 = -1, fid3 = -1; /* File IDs */ + hid_t fapl; /* File access property list */ + char filename[NAME_BUF_SIZE]; /* File name */ + hid_t did = -1, did1 = -1, did2 = -1, did3 = -1; + hid_t sid = -1; + hid_t dcpl = -1; + hsize_t chunk_dims[2] = {1, 2}; + hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; + hsize_t dims[2] = {1, 1}; + int rbuf = 0; + int wbuf = 0; + + /* Output message about test being performed */ + if(new_format) { + TESTING("multiple--single process access for latest format"); + } else { + TESTING("multiple--single process access for non-latest-format"); + } /* end if */ + + + if((fapl = H5Pcopy(in_fapl)) < 0) + FAIL_STACK_ERROR + + /* Set the filename to use for this test (dependent on fapl) */ + h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); + + if(new_format) { + /* Set to use the latest library format */ + if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + FAIL_STACK_ERROR + + /* Create the test file */ + if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR + } else { + /* Create the test file without latest format but with SWMR write */ + if((fid = H5Fcreate(filename, H5F_ACC_TRUNC|H5F_ACC_SWMR_WRITE, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR + } /* end if */ + + /* Create a chunked dataset with 1 extendible dimension */ + if((sid = H5Screate_simple(2, dims, maxdims)) < 0) + FAIL_STACK_ERROR; + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + FAIL_STACK_ERROR + if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) + FAIL_STACK_ERROR; + if((did = H5Dcreate2(fid, "dataset", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR; + + /* Closing */ + if(H5Dclose(did) < 0) + FAIL_STACK_ERROR + if(H5Sclose(sid) < 0) + FAIL_STACK_ERROR + if(H5Pclose(dcpl) < 0) + FAIL_STACK_ERROR + + /* Close the file */ + if(H5Fclose(fid) < 0) + FAIL_STACK_ERROR + + /* Case 1 */ + + /* Open the file 3 times: SWMR-write, read-write, read-only */ + if((fid1 = H5Fopen(filename, H5F_ACC_RDWR|H5F_ACC_SWMR_WRITE, fapl)) < 0) + FAIL_STACK_ERROR + if((fid2 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR + if((fid3 = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) + FAIL_STACK_ERROR + + /* Open the dataset 3 times with fid1, fid2, fid3 */ + if((did1 = H5Dopen2(fid1, "dataset", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if((did2 = H5Dopen2(fid2, "dataset", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if((did3 = H5Dopen2(fid3, "dataset", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + + + /* Write to the dataset via did1 */ + wbuf = 88; + if(H5Dwrite(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &wbuf) < 0) + FAIL_STACK_ERROR; + + /* Refresh via did2 */ + if(H5Drefresh(did2) < 0) + FAIL_STACK_ERROR; + + /* Read from the dataset via did2 */ + rbuf = 0; + if(H5Dread(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rbuf) < 0) + FAIL_STACK_ERROR; + /* Verify the data is correct */ + if(rbuf != 88) + FAIL_STACK_ERROR; + + /* Write to the dataset via did3 */ + wbuf = 99; + if(H5Dwrite(did3, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &wbuf) < 0) + FAIL_STACK_ERROR; + + /* Refresh via did1 */ + if(H5Drefresh(did1) < 0) + FAIL_STACK_ERROR; + + /* Read from the dataset via did1 */ + rbuf = 0; + if(H5Dread(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rbuf) < 0) + FAIL_STACK_ERROR; + /* Verify the data is correct */ + if(rbuf != 99) + FAIL_STACK_ERROR; + + /* Close datasets */ + if(H5Dclose(did1) < 0) + FAIL_STACK_ERROR; + if(H5Dclose(did2) < 0) + FAIL_STACK_ERROR; + if(H5Dclose(did3) < 0) + FAIL_STACK_ERROR; + + /* Close files */ + if(H5Fclose(fid1) < 0) + FAIL_STACK_ERROR + if(H5Fclose(fid2) < 0) + FAIL_STACK_ERROR + if(H5Fclose(fid3) < 0) + FAIL_STACK_ERROR + + /* Case 2 */ + + /* Open the file 3 times: read-write, read-only, read-write */ + if((fid1 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR + if((fid2 = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) + FAIL_STACK_ERROR + if((fid3 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR + + /* Open the dataset 3 times with fid1, fid2, fid3 */ + if((did1 = H5Dopen2(fid1, "dataset", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if((did2 = H5Dopen2(fid2, "dataset", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if((did3 = H5Dopen2(fid3, "dataset", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + + /* Write to the dataset via did1 */ + wbuf = 88; + if(H5Dwrite(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &wbuf) < 0) + FAIL_STACK_ERROR; + + /* Refresh via did2 */ + if(H5Drefresh(did2) < 0) + FAIL_STACK_ERROR; + + /* Read from dataset via did2 */ + rbuf = 0; + if(H5Dread(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rbuf) < 0) + FAIL_STACK_ERROR; + if(rbuf != wbuf) + FAIL_STACK_ERROR; + + /* Write to dataset via did3 */ + wbuf = 99; + if(H5Dwrite(did3, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &wbuf) < 0) + FAIL_STACK_ERROR; + + /* Enable SWMR write */ + if(H5Fstart_swmr_write(fid1) < 0) + FAIL_STACK_ERROR; + + /* Read from dataset via did1 and verify data is correct */ + rbuf = 0; + if(H5Dread(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rbuf) < 0) + FAIL_STACK_ERROR; + if(rbuf != wbuf) + FAIL_STACK_ERROR; + + /* Write to dataset via did2 */ + wbuf = 100; + if(H5Dwrite(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &wbuf) < 0) + FAIL_STACK_ERROR; + + /* Refresh dataset via did3 */ + if(H5Drefresh(did3) < 0) + FAIL_STACK_ERROR; + + /* Read from dataset via did3 and verify data is correct */ + rbuf = 0; + if(H5Dread(did3, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rbuf) < 0) + FAIL_STACK_ERROR; + if(rbuf != wbuf) + FAIL_STACK_ERROR; + + /* Close datasets */ + if(H5Dclose(did1) < 0) + FAIL_STACK_ERROR; + if(H5Dclose(did2) < 0) + FAIL_STACK_ERROR; + if(H5Dclose(did3) < 0) + FAIL_STACK_ERROR; + + /* Close files */ + if(H5Fclose(fid1) < 0) + FAIL_STACK_ERROR + if(H5Fclose(fid2) < 0) + FAIL_STACK_ERROR; + if(H5Fclose(fid3) < 0) + FAIL_STACK_ERROR + + /* Case 3 */ + + /* Open the file 3 times: read-write, read-only, read-only */ + if((fid1 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR + if((fid2 = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) + FAIL_STACK_ERROR + if((fid3 = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) + FAIL_STACK_ERROR + + /* Open the dataset 3 times with fid1, fid2, fid3 */ + if((did1 = H5Dopen2(fid1, "dataset", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if((did2 = H5Dopen2(fid2, "dataset", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if((did3 = H5Dopen2(fid3, "dataset", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + + /* Write to the dataset via did1 */ + wbuf = 88; + if(H5Dwrite(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &wbuf) < 0) + FAIL_STACK_ERROR; + + /* Refresh dataset via did2 */ + if(H5Drefresh(did2) < 0) + FAIL_STACK_ERROR; + + /* Read from dataset via did2 and verify data is correct */ + rbuf = 0; + if(H5Dread(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rbuf) < 0) + FAIL_STACK_ERROR; + if(rbuf != wbuf) + FAIL_STACK_ERROR; + + /* Close dataset via did2 */ + if(H5Dclose(did2) < 0) + FAIL_STACK_ERROR; + + /* Close file via fid2 */ + if(H5Fclose(fid2) < 0) + FAIL_STACK_ERROR + + /* Write to dataset via did3 */ + wbuf = 99; + if(H5Dwrite(did3, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &wbuf) < 0) + FAIL_STACK_ERROR; + + /* Close dataset via did3 */ + if(H5Dclose(did3) < 0) + FAIL_STACK_ERROR; + + /* Close file via fid3 */ + if(H5Fclose(fid3) < 0) + FAIL_STACK_ERROR + + /* Enable SWMR writing */ + if(H5Fstart_swmr_write(fid1) < 0) + FAIL_STACK_ERROR; + + /* Read from dataset via did1 and verify data is correct */ + rbuf = 0; + if(H5Dread(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rbuf) < 0) + FAIL_STACK_ERROR; + if(rbuf != wbuf) + FAIL_STACK_ERROR; + + /* Close dataset via did1 */ + if(H5Dclose(did1) < 0) + FAIL_STACK_ERROR; + + /* Close file via fid1 */ + if(H5Fclose(fid1) < 0) + FAIL_STACK_ERROR + + /* Close the property list */ + if(H5Pclose(fapl) < 0) + FAIL_STACK_ERROR + + PASSED(); + return 0; + +error: + H5E_BEGIN_TRY { + H5Dclose(did); + H5Dclose(did1); + H5Dclose(did2); + H5Dclose(did3); + H5Sclose(sid); + H5Pclose(dcpl); + H5Pclose(fapl); + H5Fclose(fid); + H5Fclose(fid1); + H5Fclose(fid2); + H5Fclose(fid3); + } H5E_END_TRY; + + return -1; + +} /* test_multiple_same() */ + /**************************************************************** ** ** Tests for new public routines introduced from the SWMR project. @@ -5394,6 +6710,10 @@ main(void) #ifdef OUT nerrors += test_bug_refresh(fapl); #endif + nerrors += test_refresh_concur(fapl, TRUE); + nerrors += test_refresh_concur(fapl, FALSE); + nerrors += test_multiple_same(fapl, TRUE); + nerrors += test_multiple_same(fapl, FALSE); /* Tests on H5Pget/set_metadata_read_attempts() and H5Fget_metadata_read_retry_info() */ nerrors += test_metadata_read_attempts(fapl); @@ -5447,7 +6767,7 @@ main(void) nerrors += test_swmr_vfd_flag(); if(nerrors) - goto error; + goto error; printf("All tests passed.\n"); diff --git a/tools/h5dump/h5dumpgentest.c b/tools/h5dump/h5dumpgentest.c index 059fee5..0eeaec5 100644 --- a/tools/h5dump/h5dumpgentest.c +++ b/tools/h5dump/h5dumpgentest.c @@ -7502,22 +7502,17 @@ gent_charsets(void) const char *utf8_p_; } CharSetInfo; - hid_t charset_dtid; - hid_t ascii_dtid; + hid_t charset_dtid = H5Tcreate( H5T_COMPOUND, sizeof( CharSetInfo ) ); + hid_t ascii_dtid = H5Tcreate( H5T_STRING, H5T_VARIABLE ); hid_t utf8_dtid = H5Tcreate( H5T_STRING, H5T_VARIABLE ); const char * writeData[] = { "ascii", "utf8", }; sid = H5Screate_simple( 1, dim, NULL ); fid = H5Fcreate( FILE68, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT ); - - charset_dtid = H5Tcreate( H5T_COMPOUND, sizeof( CharSetInfo ) ); - - ascii_dtid = H5Tcreate( H5T_STRING, H5T_VARIABLE ); status = H5Tset_cset( ascii_dtid, H5T_CSET_ASCII ); HDassert(status >= 0); H5Tinsert( charset_dtid, "ascii", HOFFSET(CharSetInfo, ascii_p_ ), ascii_dtid ); - utf8_dtid = H5Tcreate( H5T_STRING, H5T_VARIABLE ); status = H5Tset_cset( utf8_dtid, H5T_CSET_UTF8 ); HDassert(status >= 0); H5Tinsert( charset_dtid, "utf8", HOFFSET( CharSetInfo, utf8_p_ ), utf8_dtid ); diff --git a/tools/lib/h5tools_dump.c b/tools/lib/h5tools_dump.c index c6e96e4..39cfbeb 100644 --- a/tools/lib/h5tools_dump.c +++ b/tools/lib/h5tools_dump.c @@ -1543,7 +1543,6 @@ h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info, h5tools_cont /* Hyperslab info */ hsize_t hs_offset[H5S_MAX_RANK]; /* starting offset */ hsize_t hs_size[H5S_MAX_RANK]; /* size this pass */ - //hsize_t hs_count[H5S_MAX_RANK]; /* size this pass */ hsize_t hs_nelmts; /* elements in request */ /* VL data special information */ @@ -1626,11 +1625,9 @@ h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info, h5tools_cont hs_size[i] = MIN(total_size[i] - hs_offset[i], sm_size[i]); ctx->p_max_idx[i] = ctx->p_min_idx[i] + hs_size[i]; hs_nelmts *= hs_size[i]; -// hs_count[i] = 1; } H5Sselect_hyperslab(f_space, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL); -// H5Sselect_hyperslab(f_space, H5S_SELECT_SET, hs_offset, NULL, hs_count, hs_size); H5Sselect_hyperslab(sm_space, H5S_SELECT_SET, zero, NULL, &hs_nelmts, NULL); } else { -- cgit v0.12