diff options
-rw-r--r-- | MANIFEST | 1 | ||||
-rw-r--r-- | src/H5AC.c | 1 | ||||
-rw-r--r-- | src/H5ACprivate.h | 1 | ||||
-rw-r--r-- | src/H5Adense.c | 50 | ||||
-rw-r--r-- | src/H5Aint.c | 16 | ||||
-rw-r--r-- | src/H5B2int.c | 12 | ||||
-rw-r--r-- | src/H5Bdbg.c | 4 | ||||
-rw-r--r-- | src/H5Cpkg.h | 2 | ||||
-rw-r--r-- | src/H5Dbtree.c | 132 | ||||
-rw-r--r-- | src/H5Dbtree2.c | 45 | ||||
-rw-r--r-- | src/H5Dearray.c | 32 | ||||
-rw-r--r-- | src/H5Dproxy.c | 8 | ||||
-rw-r--r-- | src/H5O.c | 127 | ||||
-rw-r--r-- | src/H5Oainfo.c | 23 | ||||
-rw-r--r-- | src/H5Oalloc.c | 2 | ||||
-rw-r--r-- | src/H5Oattribute.c | 113 | ||||
-rw-r--r-- | src/H5Ocache.c | 84 | ||||
-rw-r--r-- | src/H5Ochunk.c | 16 | ||||
-rw-r--r-- | src/H5Ocopy.c | 9 | ||||
-rw-r--r-- | src/H5Opkg.h | 28 | ||||
-rw-r--r-- | src/H5Oprivate.h | 5 | ||||
-rw-r--r-- | src/H5Oproxy.c | 587 | ||||
-rw-r--r-- | src/H5Otest.c | 39 | ||||
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/Makefile.in | 38 | ||||
-rw-r--r-- | test/swmr_sparse_reader.c | 15 |
26 files changed, 1176 insertions, 216 deletions
@@ -814,6 +814,7 @@ ./src/H5Opkg.h ./src/H5Opline.c ./src/H5Oprivate.h +./src/H5Oproxy.c ./src/H5Opublic.h ./src/H5Orefcount.c ./src/H5Osdspace.c @@ -426,6 +426,7 @@ static const char * H5AC_entry_type_names[H5AC_NTYPES] = "global heaps", "object headers", "object header chunks", + "object header proxies", "v2 B-tree headers", "v2 B-tree internal nodes", "v2 B-tree leaf nodes", diff --git a/src/H5ACprivate.h b/src/H5ACprivate.h index 9efdc2d..6bf7bd7 100644 --- a/src/H5ACprivate.h +++ b/src/H5ACprivate.h @@ -59,6 +59,7 @@ typedef enum { H5AC_GHEAP_ID, /*global heap */ H5AC_OHDR_ID, /*object header */ H5AC_OHDR_CHK_ID, /*object header chunk */ + H5AC_OHDR_PROXY_ID, /*object header proxy */ H5AC_BT2_HDR_ID, /*v2 B-tree header */ H5AC_BT2_INT_ID, /*v2 B-tree internal node */ H5AC_BT2_LEAF_ID, /*v2 B-tree leaf node */ diff --git a/src/H5Adense.c b/src/H5Adense.c index 3005749..c357c65 100644 --- a/src/H5Adense.c +++ b/src/H5Adense.c @@ -445,7 +445,7 @@ 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_t *oh = NULL; /* Attribute's object header */ + H5O_proxy_t *oh_proxy = NULL; /* Attribute's object header proxy */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -533,13 +533,12 @@ H5A_dense_insert(H5F_t *f, hid_t dxpl_id, const H5O_ainfo_t *ainfo, H5A_t *attr) /* Check for SWMR writes to the file */ if(H5F_INTENT(f) & H5F_ACC_SWMR_WRITE) - /* Pin the attribute's object header */ - /*!FIXME change to use ohdr proxy once those changes are merged -NAF */ - if(NULL == (oh = H5O_pin(&attr->oloc, dxpl_id))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTPIN, FAIL, "unable to pin attribute object header") + /* 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))) + if(NULL == (bt2_name = H5B2_open(f, dxpl_id, ainfo->name_bt2_addr, NULL, oh_proxy))) 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,9 +561,8 @@ H5A_dense_insert(H5F_t *f, hid_t dxpl_id, const H5O_ainfo_t *ainfo, H5A_t *attr) /* Check if we should create a creation order index v2 B-tree record */ if(ainfo->index_corder) { /* Open the creation order index v2 B-tree */ - /*!FIXME use ohdr proxy -NAF */ HDassert(H5F_addr_defined(ainfo->corder_bt2_addr)); - if(NULL == (bt2_corder = H5B2_open(f, dxpl_id, ainfo->corder_bt2_addr, NULL, oh))) + if(NULL == (bt2_corder = H5B2_open(f, dxpl_id, ainfo->corder_bt2_addr, NULL, oh_proxy))) 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 */ @@ -574,8 +572,8 @@ H5A_dense_insert(H5F_t *f, hid_t dxpl_id, const H5O_ainfo_t *ainfo, H5A_t *attr) done: /* Release resources */ - if(oh && H5O_unpin(oh) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTUNPIN, FAIL, "unable to unpin attribute object header") + 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) @@ -650,7 +648,7 @@ 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_t *oh = NULL; /* Attribute's object header */ + H5O_proxy_t *oh_proxy = NULL; /* Attribute's object header proxy */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -676,14 +674,12 @@ H5A_dense_write_bt2_cb(void *_record, void *_op_data, hbool_t *changed) /* Check for SWMR writes to the file */ if(H5F_INTENT(op_data->f) & H5F_ACC_SWMR_WRITE) - /* Pin the attribute's object header */ - /*!FIXME change to use ohdr proxy once those changes are merged -NAF */ - if(NULL == (oh = H5O_pin(&op_data->attr->oloc, op_data->dxpl_id))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTPIN, FAIL, "unable to pin attribute object header") + /* 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 */ - /*!FIXME use ohdr proxy -NAF */ - if(NULL == (bt2_corder = H5B2_open(op_data->f, op_data->dxpl_id, op_data->corder_bt2_addr, NULL, oh))) + if(NULL == (bt2_corder = H5B2_open(op_data->f, op_data->dxpl_id, op_data->corder_bt2_addr, NULL, oh_proxy))) 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 */ @@ -744,8 +740,8 @@ H5A_dense_write_bt2_cb(void *_record, void *_op_data, hbool_t *changed) done: /* Release resources */ - if(oh && H5O_unpin(oh) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTUNPIN, FAIL, "unable to unpin attribute object header") + 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) @@ -777,7 +773,7 @@ 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_t *oh = NULL; /* Attribute's object header */ + H5O_proxy_t *oh_proxy = NULL; /* Attribute's object header proxy */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -817,14 +813,12 @@ H5A_dense_write(H5F_t *f, hid_t dxpl_id, const H5O_ainfo_t *ainfo, H5A_t *attr) /* Check for SWMR writes to the file */ if(H5F_INTENT(f) & H5F_ACC_SWMR_WRITE) - /* Pin the attribute's object header */ - /*!FIXME change to use ohdr proxy once those changes are merged -NAF */ - if(NULL == (oh = H5O_pin(&attr->oloc, dxpl_id))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTPIN, FAIL, "unable to pin attribute object header") + /* 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 */ - /*!FIXME use ohdr proxy -NAF */ - if(NULL == (bt2_name = H5B2_open(f, dxpl_id, ainfo->name_bt2_addr, NULL, oh))) + if(NULL == (bt2_name = H5B2_open(f, dxpl_id, ainfo->name_bt2_addr, NULL, oh_proxy))) 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 */ @@ -853,8 +847,8 @@ H5A_dense_write(H5F_t *f, hid_t dxpl_id, const H5O_ainfo_t *ainfo, H5A_t *attr) done: /* Release resources */ - if(oh && H5O_unpin(oh) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTUNPIN, FAIL, "unable to unpin attribute object header") + 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) diff --git a/src/H5Aint.c b/src/H5Aint.c index e6e25c4..8a22630 100644 --- a/src/H5Aint.c +++ b/src/H5Aint.c @@ -690,6 +690,7 @@ 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; /* Return value */ FUNC_ENTER_NOAPI_TAG(dxpl_id, oh->cache_info.addr, FAIL) @@ -711,9 +712,14 @@ 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 */ - /*!FIXME use ohdr proxy -NAF */ - if(NULL == (bt2_name = H5B2_open(f, dxpl_id, ainfo->name_bt2_addr, NULL, oh))) + if(NULL == (bt2_name = H5B2_open(f, dxpl_id, ainfo->name_bt2_addr, NULL, oh_proxy))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Retrieve # of records in "name" B-tree */ @@ -729,6 +735,8 @@ 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") @@ -1252,8 +1260,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; - - if(H5A_dense_iterate(src_oloc->file, dxpl_id, (hid_t)0, ainfo_src, H5_INDEX_NAME, + /*!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) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "error building attribute table") diff --git a/src/H5B2int.c b/src/H5B2int.c index c741d5a..17fbe5e 100644 --- a/src/H5B2int.c +++ b/src/H5B2int.c @@ -4184,7 +4184,11 @@ done: /*------------------------------------------------------------------------- * Function: H5B2_shadow_internal * - * Purpose: fnord + * Purpose: "Shadow: an internal node - copy it to a new location, + * leaving the data in the old location intact (for now). + * This is done when writing in SWMR mode to ensure that + * readers do not see nodes that are out of date with + * respect to each other and thereby inconsistent. * * Return: Non-negative on success/Negative on failure * @@ -4281,7 +4285,11 @@ done: /*------------------------------------------------------------------------- * Function: H5B2_shadow_leaf * - * Purpose: fnord + * Purpose: "Shadow: a leaf node - copy it to a new location, leaving + * the data in the old location intact (for now). This is + * done when writing in SWMR mode to ensure that readers do + * not see nodes that are out of date with respect to each + * other and thereby inconsistent. * * Return: Non-negative on success/Negative on failure * diff --git a/src/H5Bdbg.c b/src/H5Bdbg.c index 3fb7dd8..c309a0a 100644 --- a/src/H5Bdbg.c +++ b/src/H5Bdbg.c @@ -77,6 +77,9 @@ H5B_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, int f HDassert(fwidth >= 0); HDassert(type); + /* Currently does not support SWMR access */ + HDassert(!(H5F_INTENT(f) & H5F_ACC_SWMR_WRITE)); + /* Get shared info for B-tree */ if(NULL == (rc_shared = (type->get_shared)(f, udata))) HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree's shared ref. count object") @@ -89,6 +92,7 @@ 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))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree node") diff --git a/src/H5Cpkg.h b/src/H5Cpkg.h index 4c7e40d..57197be 100644 --- a/src/H5Cpkg.h +++ b/src/H5Cpkg.h @@ -838,7 +838,7 @@ #define H5C__HASH_TABLE_LEN (64 * 1024) /* must be a power of 2 */ #define H5C__H5C_T_MAGIC 0x005CAC0E -#define H5C__MAX_NUM_TYPE_IDS 28 +#define H5C__MAX_NUM_TYPE_IDS 29 #define H5C__PREFIX_LEN 32 struct H5C_t diff --git a/src/H5Dbtree.c b/src/H5Dbtree.c index 0bd2d20..7ba29b8 100644 --- a/src/H5Dbtree.c +++ b/src/H5Dbtree.c @@ -976,7 +976,7 @@ H5D__btree_idx_create(const H5D_chk_idx_info_t *idx_info) { H5D_chunk_common_ud_t udata; /* User data for B-tree callback */ H5O_loc_t oloc; /* Temporary object header location for dataset */ - H5O_t *oh = NULL; /* Dataset's object header */ + H5O_proxy_t *oh_proxy = NULL; /* Dataset's object header proxy */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1001,18 +1001,18 @@ H5D__btree_idx_create(const H5D_chk_idx_info_t *idx_info) oloc.file = idx_info->f; oloc.addr = idx_info->storage->u.btree.dset_ohdr_addr; - /* Pin the dataset's object header */ - if(NULL == (oh = H5O_pin(&oloc, idx_info->dxpl_id))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTPIN, FAIL, "unable to pin dataset object header") + /* 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 v1 B-tree for the chunk index */ - if(H5B_create(idx_info->f, idx_info->dxpl_id, H5B_BTREE, &udata, oh, &(idx_info->storage->idx_addr)/*out*/) < 0) + if(H5B_create(idx_info->f, idx_info->dxpl_id, H5B_BTREE, &udata, oh_proxy, &(idx_info->storage->idx_addr)/*out*/) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't create B-tree") done: - if(oh && H5O_unpin(oh) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTUNPIN, FAIL, "unable to unpin dataset object header") + 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__btree_idx_create() */ @@ -1064,7 +1064,7 @@ static herr_t H5D__btree_idx_insert(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata) { H5O_loc_t oloc; /* Temporary object header location for dataset */ - H5O_t *oh = NULL; /* Dataset's object header */ + H5O_proxy_t *oh_proxy = NULL; /* Dataset's object header proxy */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1085,21 +1085,21 @@ H5D__btree_idx_insert(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata) oloc.file = idx_info->f; oloc.addr = idx_info->storage->u.btree.dset_ohdr_addr; - /* Pin the dataset's object header */ - if(NULL == (oh = H5O_pin(&oloc, idx_info->dxpl_id))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTPIN, FAIL, "unable to pin dataset object header") + /* 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 chunk it if it doesn't exist, or reallocate the chunk if * its size changed. */ - if(H5B_insert(idx_info->f, idx_info->dxpl_id, H5B_BTREE, idx_info->storage->idx_addr, udata, oh) < 0) + if(H5B_insert(idx_info->f, idx_info->dxpl_id, H5B_BTREE, idx_info->storage->idx_addr, udata, oh_proxy) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to allocate chunk") done: - if(oh && H5O_unpin(oh) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTUNPIN, FAIL, "unable to unpin dataset object header") + 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) } /* H5D__btree_idx_insert() */ @@ -1123,7 +1123,7 @@ static herr_t H5D__btree_idx_get_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata) { H5O_loc_t oloc; /* Temporary object header location for dataset */ - H5O_t *oh = NULL; /* Dataset's object header */ + H5O_proxy_t *oh_proxy = NULL; /* Dataset's object header proxy */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1145,18 +1145,18 @@ H5D__btree_idx_get_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udat oloc.file = idx_info->f; oloc.addr = idx_info->storage->u.btree.dset_ohdr_addr; - /* Pin the dataset's object header */ - if(NULL == (oh = H5O_pin(&oloc, idx_info->dxpl_id))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTPIN, FAIL, "unable to pin dataset object header") + /* 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 */ /* Go get the chunk information from the B-tree */ - if(H5B_find(idx_info->f, idx_info->dxpl_id, H5B_BTREE, idx_info->storage->idx_addr, udata, oh) < 0) + if(H5B_find(idx_info->f, idx_info->dxpl_id, H5B_BTREE, idx_info->storage->idx_addr, udata, oh_proxy) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get chunk info") done: - if(oh && H5O_unpin(oh) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTUNPIN, FAIL, "unable to unpin dataset object header") + 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) } /* H5D__btree_idx_get_addr() */ @@ -1229,7 +1229,7 @@ H5D__btree_idx_iterate(const H5D_chk_idx_info_t *idx_info, { H5D_btree_it_ud_t udata; /* User data for B-tree iterator callback */ H5O_loc_t oloc; /* Temporary object header location for dataset */ - H5O_t *oh = NULL; /* Dataset's object header */ + H5O_proxy_t *oh_proxy = NULL; /* Dataset's object header proxy */ int ret_value; /* Return value */ FUNC_ENTER_STATIC @@ -1251,9 +1251,9 @@ H5D__btree_idx_iterate(const H5D_chk_idx_info_t *idx_info, oloc.file = idx_info->f; oloc.addr = idx_info->storage->u.btree.dset_ohdr_addr; - /* Pin the dataset's object header */ - if(NULL == (oh = H5O_pin(&oloc, idx_info->dxpl_id))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTPIN, FAIL, "unable to pin dataset object header") + /* 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 */ /* Initialize userdata */ @@ -1264,12 +1264,12 @@ H5D__btree_idx_iterate(const H5D_chk_idx_info_t *idx_info, udata.udata = chunk_udata; /* Iterate over existing chunks */ - if((ret_value = H5B_iterate(idx_info->f, idx_info->dxpl_id, H5B_BTREE, idx_info->storage->idx_addr, H5D__btree_idx_iterate_cb, &udata, oh)) < 0) + if((ret_value = H5B_iterate(idx_info->f, idx_info->dxpl_id, H5B_BTREE, idx_info->storage->idx_addr, H5D__btree_idx_iterate_cb, &udata, oh_proxy)) < 0) HERROR(H5E_DATASET, H5E_BADITER, "unable to iterate over chunk B-tree"); done: - if(oh && H5O_unpin(oh) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTUNPIN, FAIL, "unable to unpin dataset object header") + 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__btree_idx_iterate() */ @@ -1290,9 +1290,9 @@ done: static herr_t H5D__btree_idx_remove(const H5D_chk_idx_info_t *idx_info, H5D_chunk_common_ud_t *udata) { - H5O_loc_t oloc; /* Temporary object header location for dataset */ - H5O_t *oh = NULL; /* Dataset's object header */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 @@ -1312,20 +1312,20 @@ H5D__btree_idx_remove(const H5D_chk_idx_info_t *idx_info, H5D_chunk_common_ud_t oloc.file = idx_info->f; oloc.addr = idx_info->storage->u.btree.dset_ohdr_addr; - /* Pin the dataset's object header */ - if(NULL == (oh = H5O_pin(&oloc, idx_info->dxpl_id))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTPIN, FAIL, "unable to pin dataset object header") + /* 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 */ /* Remove the chunk from the v1 B-tree index and release the space for the * chunk (in the B-tree callback). */ - if(H5B_remove(idx_info->f, idx_info->dxpl_id, H5B_BTREE, idx_info->storage->idx_addr, udata, oh) < 0) + if(H5B_remove(idx_info->f, idx_info->dxpl_id, H5B_BTREE, idx_info->storage->idx_addr, udata, oh_proxy) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTDELETE, FAIL, "unable to remove chunk entry") done: - if(oh && H5O_unpin(oh) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTUNPIN, FAIL, "unable to unpin dataset object header") + 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) } /* H5D__btree_idx_remove() */ @@ -1349,7 +1349,7 @@ static herr_t H5D__btree_idx_delete(const H5D_chk_idx_info_t *idx_info) { H5O_loc_t oloc; /* Temporary object header location for dataset */ - H5O_t *oh = NULL; /* Dataset's object header */ + H5O_proxy_t *oh_proxy = NULL; /* Dataset's object header proxy */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1374,9 +1374,9 @@ H5D__btree_idx_delete(const H5D_chk_idx_info_t *idx_info) oloc.file = idx_info->f; oloc.addr = idx_info->storage->u.btree.dset_ohdr_addr; - /* Pin the dataset's object header */ - if(NULL == (oh = H5O_pin(&oloc, idx_info->dxpl_id))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTPIN, FAIL, "unable to pin dataset object header") + /* 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 */ /* Set up temporary chunked storage info */ @@ -1392,7 +1392,7 @@ H5D__btree_idx_delete(const H5D_chk_idx_info_t *idx_info) udata.storage = &tmp_storage; /* Delete entire B-tree */ - if(H5B_delete(idx_info->f, idx_info->dxpl_id, H5B_BTREE, tmp_storage.idx_addr, &udata, oh) < 0) + if(H5B_delete(idx_info->f, idx_info->dxpl_id, H5B_BTREE, tmp_storage.idx_addr, &udata, oh_proxy) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTDELETE, FAIL, "unable to delete chunk B-tree") /* Release the shared B-tree page */ @@ -1403,8 +1403,8 @@ H5D__btree_idx_delete(const H5D_chk_idx_info_t *idx_info) } /* end if */ done: - if(oh && H5O_unpin(oh) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTUNPIN, FAIL, "unable to unpin dataset object header") + 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__btree_idx_delete() */ @@ -1513,7 +1513,7 @@ H5D__btree_idx_size(const H5D_chk_idx_info_t *idx_info, hsize_t *index_size) H5B_info_t bt_info; /* B-tree info */ hbool_t shared_init = FALSE; /* Whether shared B-tree info is initialized */ H5O_loc_t oloc; /* Temporary object header location for dataset */ - H5O_t *oh = NULL; /* Dataset's object header */ + H5O_proxy_t *oh_proxy = NULL; /* Dataset's object header proxy */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1534,9 +1534,9 @@ H5D__btree_idx_size(const H5D_chk_idx_info_t *idx_info, hsize_t *index_size) oloc.file = idx_info->f; oloc.addr = idx_info->storage->u.btree.dset_ohdr_addr; - /* Pin the dataset's object header */ - if(NULL == (oh = H5O_pin(&oloc, idx_info->dxpl_id))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTPIN, FAIL, "unable to pin dataset object header") + /* 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 */ /* Initialize the shared info for the B-tree traversal */ @@ -1550,15 +1550,15 @@ H5D__btree_idx_size(const H5D_chk_idx_info_t *idx_info, hsize_t *index_size) udata.storage = idx_info->storage; /* Get metadata information for B-tree */ - if(H5B_get_info(idx_info->f, idx_info->dxpl_id, H5B_BTREE, idx_info->storage->idx_addr, &bt_info, NULL, &udata, oh) < 0) + if(H5B_get_info(idx_info->f, idx_info->dxpl_id, H5B_BTREE, idx_info->storage->idx_addr, &bt_info, NULL, &udata, oh_proxy) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to iterate over chunk B-tree") /* Set the size of the B-tree */ *index_size = bt_info.size; done: - if(oh && H5O_unpin(oh) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTUNPIN, FAIL, "unable to unpin dataset object header") + 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") if(shared_init) { if(NULL == idx_info->storage->u.btree.shared) @@ -1617,7 +1617,7 @@ H5D__btree_idx_support(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata H5AC_info_t *child_entry) { H5O_loc_t oloc; /* Temporary object header location for dataset */ - H5O_t *oh = NULL; /* Dataset's object header */ + H5O_proxy_t *oh_proxy = NULL; /* Dataset's object header proxy */ htri_t ret_value; /* Return value */ FUNC_ENTER_STATIC @@ -1638,17 +1638,18 @@ H5D__btree_idx_support(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata oloc.file = idx_info->f; oloc.addr = idx_info->storage->u.btree.dset_ohdr_addr; - /* Pin the dataset's object header */ - if(NULL == (oh = H5O_pin(&oloc, idx_info->dxpl_id))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTPIN, FAIL, "unable to pin dataset object header") + /* 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") /* Add the flush dependency on the chunk */ - if((ret_value = H5B_support(idx_info->f, idx_info->dxpl_id, H5B_BTREE, idx_info->storage->idx_addr, udata, oh, child_entry)) < 0) + if((ret_value = H5B_support(idx_info->f, idx_info->dxpl_id, H5B_BTREE, idx_info->storage->idx_addr, + udata, oh_proxy, child_entry)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTDEPEND, FAIL, "unable to create flush dependency on b-tree array metadata") done: - if(oh && H5O_unpin(oh) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTUNPIN, FAIL, "unable to unpin dataset object header") + 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__btree_idx_support() */ @@ -1672,7 +1673,7 @@ H5D__btree_idx_unsupport(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata, H5AC_info_t *child_entry) { H5O_loc_t oloc; /* Temporary object header location for dataset */ - H5O_t *oh = NULL; /* Dataset's object header */ + H5O_proxy_t *oh_proxy = NULL; /* Dataset's object header proxy */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1693,17 +1694,18 @@ H5D__btree_idx_unsupport(const H5D_chk_idx_info_t *idx_info, oloc.file = idx_info->f; oloc.addr = idx_info->storage->u.btree.dset_ohdr_addr; - /* Pin the dataset's object header */ - if(NULL == (oh = H5O_pin(&oloc, idx_info->dxpl_id))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTPIN, FAIL, "unable to pin dataset object header") + /* 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 flush dependency on the chunk */ - if((ret_value = H5B_unsupport(idx_info->f, idx_info->dxpl_id, H5B_BTREE, idx_info->storage->idx_addr, udata, oh, child_entry)) < 0) + if((ret_value = H5B_unsupport(idx_info->f, idx_info->dxpl_id, H5B_BTREE, idx_info->storage->idx_addr, + udata, oh_proxy, child_entry)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency on b-tree array metadata") done: - if(oh && H5O_unpin(oh) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTUNPIN, FAIL, "unable to unpin dataset object header") + 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__btree_idx_unsupport() */ diff --git a/src/H5Dbtree2.c b/src/H5Dbtree2.c index 56d8bcf..674bb2a 100644 --- a/src/H5Dbtree2.c +++ b/src/H5Dbtree2.c @@ -993,7 +993,7 @@ 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_t *oh = NULL; /* Dataset's object header */ + H5O_proxy_t *oh_proxy = NULL; /* Dataset's object header proxy */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1020,19 +1020,18 @@ H5D_bt2_idx_open(const H5D_chk_idx_info_t *idx_info) oloc.file = idx_info->f; oloc.addr = idx_info->storage->u.btree.dset_ohdr_addr; - /* Pin the dataset's object header */ - /*!FIXME change to use ohdr proxy once those changes are merged -NAF */ - if(NULL == (oh = H5O_pin(&oloc, idx_info->dxpl_id))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTPIN, FAIL, "unable to pin dataset object header") + /* 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))) + 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))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't open v2 B-tree for tracking chunked dataset") done: - if(oh && H5O_unpin(oh) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTUNPIN, FAIL, "unable to unpin dataset object header") + 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_open() */ @@ -1055,7 +1054,7 @@ 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_t *oh = NULL; /* Dataset's object header */ + H5O_proxy_t *oh_proxy = NULL; /* Dataset's object header proxy */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1104,14 +1103,13 @@ H5D_bt2_idx_create(const H5D_chk_idx_info_t *idx_info) oloc.file = idx_info->f; oloc.addr = idx_info->storage->u.btree.dset_ohdr_addr; - /* Pin the dataset's object header */ - /*!FIXME change to use ohdr proxy once those changes are merged -NAF */ - if(NULL == (oh = H5O_pin(&oloc, idx_info->dxpl_id))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTPIN, FAIL, "unable to pin dataset object header") + /* 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))) + if(NULL == (idx_info->storage->u.btree2.bt2 = H5B2_create(idx_info->f, idx_info->dxpl_id, &bt2_cparam, &u_ctx, oh_proxy))) 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 */ @@ -1119,8 +1117,8 @@ H5D_bt2_idx_create(const H5D_chk_idx_info_t *idx_info) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get v2 B-tree address for tracking chunked dataset") done: - if(oh && H5O_unpin(oh) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTUNPIN, FAIL, "unable to unpin dataset object header") + 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_create() */ @@ -1797,7 +1795,7 @@ H5D_bt2_idx_delete(const H5D_chk_idx_info_t *idx_info) 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_t *oh = NULL; /* Dataset's object header */ + H5O_proxy_t *oh_proxy = NULL; /* Dataset's object header proxy */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1839,23 +1837,22 @@ H5D_bt2_idx_delete(const H5D_chk_idx_info_t *idx_info) oloc.file = idx_info->f; oloc.addr = idx_info->storage->u.btree.dset_ohdr_addr; - /* Pin the dataset's object header */ - /*!FIXME change to use ohdr proxy once those changes are merged -NAF */ - if(NULL == (oh = H5O_pin(&oloc, idx_info->dxpl_id))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTPIN, FAIL, "unable to pin dataset object header") + /* 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, remove_op, &remove_udata) < 0) + if(H5B2_delete(idx_info->f, idx_info->dxpl_id, idx_info->storage->idx_addr, &u_ctx, oh_proxy, 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 && H5O_unpin(oh) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTUNPIN, FAIL, "unable to unpin dataset object header") + 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/H5Dearray.c b/src/H5Dearray.c index 215eef8..e05a17a 100644 --- a/src/H5Dearray.c +++ b/src/H5Dearray.c @@ -720,7 +720,7 @@ static herr_t H5D_earray_idx_depend(const H5D_chk_idx_info_t *idx_info) { H5O_loc_t oloc; /* Temporary object header location for dataset */ - H5O_t *oh = NULL; /* Dataset's object header */ + H5O_proxy_t *oh_proxy = NULL; /* Dataset's object header proxy */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -742,18 +742,18 @@ H5D_earray_idx_depend(const H5D_chk_idx_info_t *idx_info) oloc.file = idx_info->f; oloc.addr = idx_info->storage->u.earray.dset_ohdr_addr; - /* Pin the dataset's object header */ - if(NULL == (oh = H5O_pin(&oloc, idx_info->dxpl_id))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTPIN, FAIL, "unable to pin dataset object header") + /* 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 extensible array a child flush dependency of the dataset's object header */ - if(H5EA_depend((H5AC_info_t *)oh, idx_info->storage->u.earray.ea) < 0) + if(H5EA_depend((H5AC_info_t *)oh_proxy, idx_info->storage->u.earray.ea) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTDEPEND, FAIL, "unable to create flush dependency on object header") done: - /* Unpin the dataset's object header */ - if(oh && H5O_unpin(oh) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTUNPIN, FAIL, "unable to unpin dataset object header") + /* 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_depend() */ @@ -777,7 +777,7 @@ 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_t *oh = NULL; /* Dataset's object header */ + H5O_proxy_t *oh_proxy = NULL; /* Dataset's object header proxy */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -799,18 +799,18 @@ H5D_earray_idx_undepend(const H5D_chk_idx_info_t *idx_info) oloc.file = idx_info->f; oloc.addr = idx_info->storage->u.earray.dset_ohdr_addr; - /* Pin the dataset's object header */ - if(NULL == (oh = H5O_pin(&oloc, idx_info->dxpl_id))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTPIN, FAIL, "unable to pin dataset object header") + /* 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, idx_info->storage->u.earray.ea) < 0) + 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 */ - if(oh && H5O_unpin(oh) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTUNPIN, FAIL, "unable to unpin dataset object header") + /* 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() */ diff --git a/src/H5Dproxy.c b/src/H5Dproxy.c index 7f0ad9d..507a0bf 100644 --- a/src/H5Dproxy.c +++ b/src/H5Dproxy.c @@ -73,7 +73,7 @@ static herr_t H5D__chunk_proxy_destroy(H5D_chunk_proxy_t *proxy); /* Metadata cache (H5AC) callbacks */ -static H5D_chunk_proxy_t *H5D__cache_proxy_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *udata, void *udata2); +static H5D_chunk_proxy_t *H5D__cache_proxy_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *udata); static herr_t H5D__cache_proxy_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5D_chunk_proxy_t *proxy, unsigned UNUSED * flags_ptr); static herr_t H5D__cache_proxy_dest(H5F_t *f, H5D_chunk_proxy_t *proxy); static herr_t H5D__cache_proxy_clear(H5F_t *f, H5D_chunk_proxy_t *proxy, hbool_t destroy); @@ -128,7 +128,7 @@ H5FL_DEFINE_STATIC(H5D_chunk_proxy_t); */ static H5D_chunk_proxy_t * H5D__cache_proxy_load(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, haddr_t UNUSED addr, - const void UNUSED *udata1, void UNUSED *udata2) + const void UNUSED *udata) { H5D_chunk_proxy_t *ret_value; /* Return value */ @@ -365,7 +365,7 @@ HDfprintf(stderr, "%s: ent->proxy_addr = %a\n", FUNC, ent->proxy_addr); /* Create a flush dependency between the proxy (as the child) and the * metadata object in the index (as the parent). */ - if((supported = (dset->shared->layout.storage.u.chunk.ops->support)(&idx_info, udata, (H5AC_info_t *)proxy)) < 0) + if((supported = (dset->shared->layout.storage.u.chunk.ops->support)(&idx_info, (H5D_chunk_common_ud_t *)udata, (H5AC_info_t *)proxy)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTDEPEND, FAIL, "unable to create flush dependency for chunk proxy") proxy->supported = (hbool_t)supported; @@ -540,7 +540,7 @@ H5D__chunk_proxy_destroy(H5D_chunk_proxy_t *proxy) * Purpose: Creates a flush dependency between the specified chunk * (child) and parent, if not already present. * -+ * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * * Programmer: Neil Fortner * 21 Sept 2010 @@ -1153,6 +1153,7 @@ H5O_create(H5F_t *f, hid_t dxpl_id, size_t size_hint, size_t initial_rc, oh->version = H5O_VERSION_1; oh->sizeof_size = H5F_SIZEOF_SIZE(f); oh->sizeof_addr = H5F_SIZEOF_ADDR(f); + oh->swmr_write = !!(H5F_INTENT(f) & H5F_ACC_SWMR_WRITE); #ifdef H5O_ENABLE_BAD_MESG_COUNT /* Check whether the "bad message count" property is set */ if(H5P_exist_plist(oc_plist, H5O_BAD_MESG_COUNT_NAME) > 0) { @@ -1165,6 +1166,14 @@ H5O_create(H5F_t *f, hid_t dxpl_id, size_t size_hint, size_t initial_rc, /* Set initial status flags */ oh->flags = oh_flags; + /* Create object header proxy if doing SWMR writes */ + if(H5F_INTENT(f) & H5F_ACC_SWMR_WRITE) { + if(H5O_proxy_create(f, dxpl_id, oh) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTCREATE, FAIL, "can't create object header proxy") + } /* end if */ + else + oh->proxy_addr = HADDR_UNDEF; + /* Initialize version-specific fields */ if(oh->version > H5O_VERSION_1) { /* Initialize all time fields with current time, if we are storing them */ @@ -3536,3 +3545,121 @@ H5O_free(H5O_t *oh) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O_free() */ + +/*------------------------------------------------------------------------- + * Function: H5O_pin_flush_dep_proxy + * + * Purpose: Pin an object header proxy for use as a flush dependency + * parent for items referenced by the object header. + * + * Return: Success: Pointer to the object header proxy + * structure for the object. + * Failure: NULL + * + * Programmer: Neil Fortner + * Mar 16 2012 + * + *------------------------------------------------------------------------- + */ +H5O_proxy_t * +H5O_pin_flush_dep_proxy(H5O_loc_t *loc, hid_t dxpl_id) +{ + H5O_t *oh = NULL; /* Object header */ + H5O_proxy_t *proxy = NULL; /* Object header proxy */ + H5O_proxy_t *ret_value = NULL; /* Return value */ + + FUNC_ENTER_NOAPI(NULL) + + /* check args */ + HDassert(loc); + + /* Get header */ + if(NULL == (oh = H5O_protect(loc, dxpl_id, H5AC_READ))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, NULL, "unable to protect object header") + + /* Pin object header proxy */ + if(NULL == (proxy = H5O_proxy_pin(loc->file, dxpl_id, oh))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTPIN, NULL, "unable to pin object header proxy") + + /* Set the return value */ + ret_value = proxy; + +done: + /* Release the object header from the cache */ + if(oh && H5O_unprotect(loc, dxpl_id, oh, H5AC__NO_FLAGS_SET) < 0) + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, NULL, "unable to release object header") + + if(!ret_value) + if(proxy && H5O_proxy_unpin(proxy) < 0) + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPIN, NULL, "unable to release object header proxy") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_pin_flush_dep_proxy() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_pin_flush_dep_proxy_oh + * + * Purpose: Pin an object header proxy for use as a flush dependency + * parent for items referenced by the object header. + * + * Return: Success: Pointer to the object header proxy + * structure for the object. + * Failure: NULL + * + * Programmer: Neil Fortner + * Mar 16 2012 + * + *------------------------------------------------------------------------- + */ +H5O_proxy_t * +H5O_pin_flush_dep_proxy_oh(H5F_t *f, hid_t dxpl_id, H5O_t *oh) +{ + H5O_proxy_t *ret_value = NULL; /* Return value */ + + FUNC_ENTER_NOAPI(NULL) + + /* check args */ + HDassert(f); + HDassert(oh); + + /* Pin object header proxy */ + if(NULL == (ret_value = H5O_proxy_pin(f, dxpl_id, oh))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTPIN, NULL, "unable to pin object header proxy") + +done: + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_pin_flush_dep_proxy_oh() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_unpin_flush_dep_proxy + * + * Purpose: Unpin an object header proxy. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Neil Fortner + * Mar 16 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5O_unpin_flush_dep_proxy(H5O_proxy_t *proxy) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* check args */ + HDassert(proxy); + + /* Unin object header proxy */ + if(H5O_proxy_unpin(proxy) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPIN, FAIL, "unable to unpin object header proxy") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_unpin_flush_dep_proxy() */ + diff --git a/src/H5Oainfo.c b/src/H5Oainfo.c index bbdfe2e..a3a0766 100644 --- a/src/H5Oainfo.c +++ b/src/H5Oainfo.c @@ -323,7 +323,9 @@ H5O_ainfo_free(void *mesg) /*------------------------------------------------------------------------- * Function: H5O_ainfo_delete * - * Purpose: Free file space referenced by message + * Purpose: Free file space referenced by message. Note that open_oh + * *must* be non-NULL - this means that calls to + * H5O_msg_delete must include an oh if the type is ainfo. * * Return: Non-negative on success/Negative on failure * @@ -336,6 +338,7 @@ 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 @@ -343,14 +346,26 @@ H5O_ainfo_delete(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, void *_mesg) /* check args */ HDassert(f); HDassert(ainfo); + HDassert(open_oh); /* If the object is using "dense" attribute storage, delete it */ - if(H5F_addr_defined(ainfo->fheap_addr)) - /*!FIXME use ohdr proxy -NAF */ - if(H5A_dense_delete(f, dxpl_id, ainfo, open_oh) < 0) + 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) 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() */ diff --git a/src/H5Oalloc.c b/src/H5Oalloc.c index 5c00fb2..0ff52f1 100644 --- a/src/H5Oalloc.c +++ b/src/H5Oalloc.c @@ -1081,7 +1081,7 @@ H5O_alloc_new_chunk(H5F_t *f, hid_t dxpl_id, H5O_t *oh, size_t size, size_t *new oh->mesg[idx].chunkno = chunkno; /* Insert the new chunk into the cache */ - if(H5O_chunk_add(f, dxpl_id, oh, chunkno) < 0) + if(H5O_chunk_add(f, dxpl_id, oh, chunkno, oh->mesg[found_null].chunkno) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "can't add new chunk to cache") /* Initialize the continuation information */ diff --git a/src/H5Oattribute.c b/src/H5Oattribute.c index 9370aa9..45893d3 100644 --- a/src/H5Oattribute.c +++ b/src/H5Oattribute.c @@ -219,6 +219,7 @@ 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 */ @@ -279,9 +280,14 @@ 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 */ - /*!FIXME use ohdr proxy -NAF */ - if(H5A_dense_create(loc->file, dxpl_id, &ainfo, oh) < 0) + if(H5A_dense_create(loc->file, dxpl_id, &ainfo, oh_proxy) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to create dense storage for attributes") /* Set up user data for callback */ @@ -394,6 +400,8 @@ 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") @@ -471,6 +479,7 @@ 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 */ @@ -507,9 +516,14 @@ 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 */ - /*!FIXME use ohdr proxy -NAF */ - if(NULL == (opened_attr = H5A_dense_open(loc->file, dxpl_id, &ainfo, name, oh))) + if(NULL == (opened_attr = H5A_dense_open(loc->file, dxpl_id, &ainfo, name, oh_proxy))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "can't open attribute") } /* end if */ else { @@ -544,6 +558,8 @@ 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") @@ -1182,6 +1198,7 @@ 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 */ @@ -1206,8 +1223,14 @@ 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) < 0) + if(H5A_dense_rename(loc->file, dxpl_id, &ainfo, old_name, new_name, oh_proxy) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTUPDATE, FAIL, "error updating attribute") } /* end if */ else { @@ -1247,6 +1270,8 @@ 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") @@ -1272,6 +1297,7 @@ 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; /* Return value */ @@ -1302,14 +1328,19 @@ 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 */ - /*!FIXME use ohdr proxy -NAF */ - if((ret_value = H5A_dense_iterate(loc->file, dxpl_id, loc_id, &ainfo, idx_type, order, skip, oh, last_attr, attr_op, op_data)) < 0) + 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) HERROR(H5E_ATTR, H5E_BADITER, "error iterating over attributes"); } /* end if */ else { @@ -1333,6 +1364,8 @@ 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) @@ -1405,6 +1438,7 @@ 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 @@ -1422,9 +1456,14 @@ 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 */ - /*!FIXME use ohdr proxy -NAF */ - if(H5A_dense_build_table(loc->file, dxpl_id, ainfo, H5_INDEX_NAME, H5_ITER_NATIVE, oh, &atable) < 0) + if(H5A_dense_build_table(loc->file, dxpl_id, ainfo, H5_INDEX_NAME, H5_ITER_NATIVE, oh_proxy, &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 @@ -1479,8 +1518,7 @@ H5O_attr_remove_update(const H5O_loc_t *loc, H5O_t *oh, H5O_ainfo_t *ainfo, } /* end for */ /* Remove the dense storage */ - /*!FIXME use ohdr proxy -NAF */ - if(H5A_dense_delete(loc->file, dxpl_id, ainfo, oh) < 0) + if(H5A_dense_delete(loc->file, dxpl_id, ainfo, oh_proxy) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete dense attribute storage") } /* end if */ } /* end if */ @@ -1499,6 +1537,8 @@ 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") @@ -1571,6 +1611,7 @@ 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 */ @@ -1595,9 +1636,14 @@ 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 */ - /*!FIXME use ohdr proxy -NAF */ - if(H5A_dense_remove(loc->file, dxpl_id, &ainfo, name, oh) < 0) + if(H5A_dense_remove(loc->file, dxpl_id, &ainfo, name, oh_proxy) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute in dense storage") } /* end if */ else { @@ -1631,6 +1677,8 @@ 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") @@ -1656,6 +1704,7 @@ 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 */ @@ -1680,9 +1729,14 @@ 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 */ - /*!FIXME use ohdr proxy -NAF */ - if(H5A_dense_remove_by_idx(loc->file, dxpl_id, &ainfo, idx_type, order, n, oh) < 0) + if(H5A_dense_remove_by_idx(loc->file, dxpl_id, &ainfo, idx_type, order, n, oh_proxy) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute in dense storage") } /* end if */ else { @@ -1724,6 +1778,8 @@ 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) @@ -1843,6 +1899,7 @@ 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; /* Return value */ @@ -1866,9 +1923,14 @@ 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 */ - /*!FIXME use ohdr proxy -NAF */ - if((ret_value = H5A_dense_exists(loc->file, dxpl_id, &ainfo, name, oh)) < 0) + if((ret_value = H5A_dense_exists(loc->file, dxpl_id, &ainfo, name, oh_proxy)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_BADITER, FAIL, "error checking for existence of attribute") } /* end if */ else { @@ -1892,6 +1954,8 @@ 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") @@ -1917,6 +1981,7 @@ 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) @@ -1934,11 +1999,16 @@ 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)) { - /*!FIXME use ohdr proxy -NAF */ /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(f, dxpl_id, ainfo.name_bt2_addr, NULL, oh))) + if(NULL == (bt2_name = H5B2_open(f, dxpl_id, ainfo.name_bt2_addr, NULL, oh_proxy))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Get name index B-tree size */ @@ -1948,9 +2018,8 @@ 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)) { - /*!FIXME use ohdr proxy -NAF */ /* Open the creation order index v2 B-tree */ - if(NULL == (bt2_corder = H5B2_open(f, dxpl_id, ainfo.corder_bt2_addr, NULL, oh))) + if(NULL == (bt2_corder = H5B2_open(f, dxpl_id, ainfo.corder_bt2_addr, NULL, oh_proxy))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for creation order index") /* Get creation order index B-tree size */ @@ -1973,6 +2042,8 @@ 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/H5Ocache.c b/src/H5Ocache.c index f09f693..856a5bc 100644 --- a/src/H5Ocache.c +++ b/src/H5Ocache.c @@ -78,6 +78,7 @@ static H5O_chunk_proxy_t *H5O_cache_chk_load(H5F_t *f, hid_t dxpl_id, haddr_t ad static herr_t H5O_cache_chk_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5O_chunk_proxy_t *chk_proxy, unsigned UNUSED * flags_ptr); static herr_t H5O_cache_chk_dest(H5F_t *f, H5O_chunk_proxy_t *chk_proxy); static herr_t H5O_cache_chk_clear(H5F_t *f, H5O_chunk_proxy_t *chk_proxy, hbool_t destroy); +static herr_t H5O_cache_chk_notify(H5AC_notify_action_t action, H5O_chunk_proxy_t *chk_proxy); static herr_t H5O_cache_chk_size(const H5F_t *f, const H5O_chunk_proxy_t *chk_proxy, size_t *size_ptr); /* Chunk proxy routines */ @@ -115,7 +116,7 @@ const H5AC_class_t H5AC_OHDR_CHK[1] = {{ (H5AC_flush_func_t)H5O_cache_chk_flush, (H5AC_dest_func_t)H5O_cache_chk_dest, (H5AC_clear_func_t)H5O_cache_chk_clear, - (H5AC_notify_func_t)NULL, + (H5AC_notify_func_t)H5O_cache_chk_notify, (H5AC_size_func_t)H5O_cache_chk_size, }}; @@ -198,6 +199,16 @@ H5O_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata) /* File-specific, non-stored information */ oh->sizeof_size = H5F_SIZEOF_SIZE(udata->common.f); oh->sizeof_addr = H5F_SIZEOF_ADDR(udata->common.f); + oh->swmr_write = !!(H5F_INTENT(udata->common.f) & H5F_ACC_SWMR_WRITE); + + /* Create object header proxy if doing SWMR writes */ + HDassert(!oh->proxy_present); + if(H5F_INTENT(f) & H5F_ACC_SWMR_WRITE) { + if(H5O_proxy_create(f, dxpl_id, oh) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTCREATE, NULL, "can't create object header proxy") + } /* end if */ + else + oh->proxy_addr = HADDR_UNDEF; /* Check for presence of magic number */ /* (indicates version 2 or later) */ @@ -935,6 +946,77 @@ done: /*------------------------------------------------------------------------- + * Function: H5O_cache_chk_notify + * + * Purpose: Handle cache action notifications + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Neil Fortner + * Mar 20 2012 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5O_cache_chk_notify(H5AC_notify_action_t action, H5O_chunk_proxy_t *chk_proxy) +{ + void *parent = NULL; /* Chunk containing continuation message that points to this chunk */ + H5O_chunk_proxy_t *cont_chk_proxy = NULL; /* Proxy for chunk containing continuation message that points to this chunk, if not chunk 0 */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + /* + * Check arguments. + */ + HDassert(chk_proxy); + HDassert(chk_proxy->oh); + + if(chk_proxy->oh->swmr_write) { + switch(action) { + case H5AC_NOTIFY_ACTION_AFTER_INSERT: + /* Add flush dependency from chunk containing the continuation message + * that points to this chunk (either oh or another chunk proxy object) + */ + if(chk_proxy->cont_chunkno == 0) + parent = chk_proxy->oh; + else { + if(NULL == (cont_chk_proxy = H5O_chunk_protect(chk_proxy->f, H5AC_ind_dxpl_id, chk_proxy->oh, chk_proxy->cont_chunkno))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header chunk") + parent = cont_chk_proxy; + } /* end else */ + + if(H5AC_create_flush_dependency(parent, chk_proxy) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTDEPEND, FAIL, "unable to create flush dependency") + + /* Add flush dependency on object header proxy, if proxy exists */ + if(chk_proxy->oh->proxy_present) + if(H5O_proxy_depend(chk_proxy->f, H5AC_ind_dxpl_id, chk_proxy->oh, chk_proxy) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTDEPEND, FAIL, "can't create flush dependency on object header proxy") + + case H5AC_NOTIFY_ACTION_BEFORE_EVICT: + /* Nothing to do */ + break; + + default: +#ifdef NDEBUG + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "unknown action from metadata cache") +#else /* NDEBUG */ + HDassert(0 && "Unknown action?!?"); +#endif /* NDEBUG */ + } /* end switch */ + } /* end if */ + +done: + if(cont_chk_proxy) + if(H5O_chunk_unprotect(chk_proxy->f, H5AC_ind_dxpl_id, cont_chk_proxy, FALSE) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_cache_chk_notify() */ + + +/*------------------------------------------------------------------------- * Function: H5O_cache_chk_size * * Purpose: Compute the size in bytes of the specified instance of diff --git a/src/H5Ochunk.c b/src/H5Ochunk.c index 41d3f66..af4233e 100644 --- a/src/H5Ochunk.c +++ b/src/H5Ochunk.c @@ -92,9 +92,10 @@ H5FL_DEFINE(H5O_chunk_proxy_t); *------------------------------------------------------------------------- */ herr_t -H5O_chunk_add(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned idx) +H5O_chunk_add(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned idx, + unsigned cont_chunkno) { - H5O_chunk_proxy_t *chk_proxy = NULL; /* Proxy for chunk, to mark it dirty in the cache */ + H5O_chunk_proxy_t *chk_proxy = NULL; /* Proxy for chunk, to mark it dirty in the cache */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_TAG(dxpl_id, oh->cache_info.addr, FAIL) @@ -110,8 +111,10 @@ H5O_chunk_add(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned idx) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Set the values in the chunk proxy */ + chk_proxy->f = f; chk_proxy->oh = oh; chk_proxy->chunkno = idx; + chk_proxy->cont_chunkno = cont_chunkno; /* Increment reference count on object header */ if(H5O_inc_rc(oh) < 0) @@ -120,6 +123,7 @@ H5O_chunk_add(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned idx) /* Insert the chunk proxy into the cache */ if(H5AC_insert_entry(f, dxpl_id, H5AC_OHDR_CHK, oh->chunk[idx].addr, chk_proxy, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "unable to cache object header chunk") + chk_proxy = NULL; done: @@ -170,6 +174,7 @@ H5O_chunk_protect(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned idx) HGOTO_ERROR(H5E_OHDR, H5E_CANTINC, NULL, "can't increment reference count on object header") /* Set chunk proxy fields */ + chk_proxy->f = f; chk_proxy->oh = oh; chk_proxy->chunkno = idx; } /* end if */ @@ -371,6 +376,7 @@ H5O_chunk_delete(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned idx) { H5O_chunk_proxy_t *chk_proxy; /* Proxy for chunk, to mark it dirty in the cache */ H5O_chk_cache_ud_t chk_udata; /* User data for loading chunk */ + unsigned cache_flags = H5AC__DELETED_FLAG; /* Flags for unprotecting proxy */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_TAG(dxpl_id, oh->cache_info.addr, FAIL) @@ -396,8 +402,12 @@ H5O_chunk_delete(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned idx) HDassert(chk_proxy->oh == oh); HDassert(chk_proxy->chunkno == idx); + /* Only free file space if not doing SWMR writes */ + if(!(H5F_INTENT(f) & H5F_ACC_SWMR_WRITE)) + cache_flags |= H5AC__DIRTIED_FLAG | H5AC__FREE_FILE_SPACE_FLAG; + /* Release the chunk proxy from the cache, marking it deleted */ - if(H5AC_unprotect(f, dxpl_id, H5AC_OHDR_CHK, oh->chunk[idx].addr, chk_proxy, (H5AC__DIRTIED_FLAG | H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG)) < 0) + if(H5AC_unprotect(f, dxpl_id, H5AC_OHDR_CHK, oh->chunk[idx].addr, chk_proxy, cache_flags) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header chunk") done: diff --git a/src/H5Ocopy.c b/src/H5Ocopy.c index ceb6563..3a08d82 100644 --- a/src/H5Ocopy.c +++ b/src/H5Ocopy.c @@ -449,6 +449,7 @@ H5O_copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, oh_dst->attr_msgs_seen = oh_src->attr_msgs_seen; oh_dst->sizeof_size = H5F_SIZEOF_SIZE(oloc_dst->file); oh_dst->sizeof_addr = H5F_SIZEOF_ADDR(oloc_dst->file); + oh_dst->swmr_write = !!(H5F_INTENT(oloc_dst->file) & H5F_ACC_SWMR_WRITE); /* Copy time fields */ oh_dst->atime = oh_src->atime; @@ -460,6 +461,14 @@ H5O_copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, oh_dst->max_compact = oh_src->max_compact; oh_dst->min_dense = oh_src->min_dense; + /* Create object header proxy if doing SWMR writes */ + if(H5F_INTENT(oloc_dst->file) & H5F_ACC_SWMR_WRITE) { + if(H5O_proxy_create(oloc_dst->file, dxpl_id, oh_dst) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTCREATE, FAIL, "can't create object header proxy") + } /* end if */ + else + oh_dst->proxy_addr = HADDR_UNDEF; + /* Initialize size of chunk array. Start off with zero chunks so this field * is consistent with the current state of the chunk array. This is * important if an error occurs. diff --git a/src/H5Opkg.h b/src/H5Opkg.h index 3eb5afb..b9f074e 100644 --- a/src/H5Opkg.h +++ b/src/H5Opkg.h @@ -267,6 +267,7 @@ struct H5O_t { /* File-specific information (not stored) */ size_t sizeof_size; /* Size of file sizes */ size_t sizeof_addr; /* Size of file addresses */ + hbool_t swmr_write; /* Whether we are doing SWMR writes */ /* Debugging information (not stored) */ #ifdef H5O_ENABLE_BAD_MESG_COUNT @@ -312,6 +313,10 @@ struct H5O_t { size_t nchunks; /*number of chunks */ size_t alloc_nchunks; /*chunks allocated */ H5O_chunk_t *chunk; /*array of chunks */ + + /* Object header proxy information (not stored) */ + haddr_t proxy_addr; /* Temporary address of object header proxy */ + hbool_t proxy_present; /* Whether the proxy is present in cache (and we have to track dependencies) */ }; /* Class for types of objects in file */ @@ -368,8 +373,10 @@ typedef struct H5O_chunk_proxy_t { H5AC_info_t cache_info; /* Information for metadata cache functions, _must_ be */ /* first field in structure */ + H5F_t *f; /* Pointer to file for object header/chunk */ H5O_t *oh; /* Object header for this chunk */ unsigned chunkno; /* Chunk number for this chunk */ + unsigned cont_chunkno; /* Chunk number for the chunk containing the continuation message that points to this chunk */ } H5O_chunk_proxy_t; /* Callback information for loading object header chunk from disk */ @@ -381,6 +388,14 @@ typedef struct H5O_chk_cache_ud_t { H5O_common_cache_ud_t common; /* Common object header cache callback info */ } H5O_chk_cache_ud_t; +/* Metadata cache object header proxy type */ +struct H5O_proxy_t { + H5AC_info_t cache_info; /* Information for H5AC cache functions, _must_ be */ + /* first field in structure */ + H5F_t *f; /* Pointer to file for object header/chunk */ + H5O_t *oh; /* Object header */ +}; + /* H5O object header inherits cache-like properties from H5AC */ H5_DLLVAR const H5AC_class_t H5AC_OHDR[1]; @@ -559,7 +574,8 @@ H5_DLL herr_t H5O_msg_iterate_real(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *t const H5O_mesg_operator_t *op, void *op_data, hid_t dxpl_id); /* Object header chunk routines */ -H5_DLL herr_t H5O_chunk_add(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned idx); +H5_DLL herr_t H5O_chunk_add(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned idx, + unsigned cont_chunkno); H5_DLL H5O_chunk_proxy_t *H5O_chunk_protect(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned idx); H5_DLL herr_t H5O_chunk_unprotect(H5F_t *f, hid_t dxpl_id, @@ -607,6 +623,16 @@ H5_DLL herr_t H5O_attr_link(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, void *_mesg H5_DLL herr_t H5O_attr_count_real(H5F_t *f, hid_t dxpl_id, H5O_t *oh, hsize_t *nattrs); +/* Object header proxy operators */ +H5_DLL herr_t H5O_proxy_create(H5F_t *f, hid_t dxpl_id, H5O_t *oh); +H5_DLL H5O_proxy_t *H5O_proxy_pin(H5F_t *f, hid_t dxpl_id, + H5O_t *oh); +H5_DLL herr_t H5O_proxy_unpin(H5O_proxy_t *proxy); +H5_DLL herr_t H5O_proxy_depend(H5F_t *f, hid_t dxpl_id, H5O_t *oh, + void *parent); +H5_DLL herr_t H5O_proxy_undepend(H5F_t *f, hid_t dxpl_id, H5O_t *oh, + void *parent); + /* These functions operate on object locations */ H5_DLL H5O_loc_t *H5O_get_loc(hid_t id); diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h index 66744f3..1bef253 100644 --- a/src/H5Oprivate.h +++ b/src/H5Oprivate.h @@ -45,6 +45,7 @@ typedef struct H5O_msg_class_t H5O_msg_class_t; typedef struct H5O_mesg_t H5O_mesg_t; typedef struct H5O_t H5O_t; +typedef struct H5O_proxy_t H5O_proxy_t; /* Values used to create the shared message & attribute heaps */ /* (Note that these parameters have been tuned so that the resulting heap ID @@ -774,6 +775,10 @@ H5_DLL herr_t H5O_get_nlinks(const H5O_loc_t *loc, hid_t dxpl_id, hsize_t *nlink H5_DLL void *H5O_obj_create(H5F_t *f, H5O_type_t obj_type, void *crt_info, H5G_loc_t *obj_loc, hid_t dxpl_id); H5_DLL haddr_t H5O_get_oh_addr(const H5O_t *oh); H5_DLL herr_t H5O_get_rc_and_type(const H5O_loc_t *oloc, hid_t dxpl_id, unsigned *rc, H5O_type_t *otype); +H5_DLL H5O_proxy_t *H5O_pin_flush_dep_proxy(H5O_loc_t *loc, hid_t dxpl_id); +H5_DLL H5O_proxy_t *H5O_pin_flush_dep_proxy_oh(H5F_t *f, hid_t dxpl_id, + H5O_t *oh); +H5_DLL herr_t H5O_unpin_flush_dep_proxy(H5O_proxy_t *proxy); /* Object header message routines */ H5_DLL herr_t H5O_msg_create(const H5O_loc_t *loc, unsigned type_id, unsigned mesg_flags, diff --git a/src/H5Oproxy.c b/src/H5Oproxy.c new file mode 100644 index 0000000..82b09f0 --- /dev/null +++ b/src/H5Oproxy.c @@ -0,0 +1,587 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/*------------------------------------------------------------------------- + * + * Created: H5Oproxy.c + * February 28 2012 + * Neil Fortner <nfortne2@hdfgroup.org> + * + * Purpose: Implement object header's metadata cache proxy cache + * methods. + * + * Note: Object header proxies exist only to make integrating the + * object header chunks with the metadata cache's flush + * dependencies easier and less coupled than directly tying + * them together. + * + * Object header proxies never exist on disk (hence their + * lack of a 'load' callback) and their 'flush' callback + * does nothing. + * + *------------------------------------------------------------------------- + */ + +/****************/ +/* Module Setup */ +/****************/ + +#define H5O_PACKAGE /*suppress error about including H5Opkg */ + + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5Opkg.h" /* Object headers */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5MFprivate.h" /* File memory management */ + + +/****************/ +/* Local Macros */ +/****************/ + + +/******************/ +/* Local Typedefs */ +/******************/ + + +/********************/ +/* Package Typedefs */ +/********************/ + + +/********************/ +/* Local Prototypes */ +/********************/ + +/* Metadata cache (H5AC) callbacks */ +static H5O_proxy_t *H5O_cache_proxy_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, + void *udata); +static herr_t H5O_cache_proxy_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, + haddr_t addr, H5O_proxy_t *proxy, unsigned UNUSED * flags_ptr); +static herr_t H5O_cache_proxy_dest(H5F_t *f, H5O_proxy_t *proxy); +static herr_t H5O_cache_proxy_clear(H5F_t *f, H5O_proxy_t *proxy, + hbool_t destroy); +static herr_t H5O_cache_proxy_notify(H5AC_notify_action_t action, + H5O_proxy_t *proxy); +static herr_t H5O_cache_proxy_size(const H5F_t *f, const H5O_proxy_t *proxy, + size_t *size_ptr); + + +/*********************/ +/* Package Variables */ +/*********************/ + +/* H5O proxy inherits cache-like properties from H5AC */ +const H5AC_class_t H5AC_OHDR_PROXY[1] = {{ + H5AC_OHDR_PROXY_ID, + (H5AC_load_func_t)H5O_cache_proxy_load, + (H5AC_flush_func_t)H5O_cache_proxy_flush, + (H5AC_dest_func_t)H5O_cache_proxy_dest, + (H5AC_clear_func_t)H5O_cache_proxy_clear, + (H5AC_notify_func_t)H5O_cache_proxy_notify, + (H5AC_size_func_t)H5O_cache_proxy_size, +}}; + + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + + +/*******************/ +/* Local Variables */ +/*******************/ + +/* Declare a free list to manage H5O_proxy_t objects */ +H5FL_DEFINE_STATIC(H5O_proxy_t); + + + +/*------------------------------------------------------------------------- + * Function: H5O_cache_proxy_load + * + * Purpose: Creates an object header proxy and creates flush + * dependencies from all object header chunks on this proxy. + * + * Return: Success: Pointer to a new object header proxy + * Failure: NULL + * + * Programmer: Neil Fortner + * Mar 15 2012 + * + *------------------------------------------------------------------------- + */ +static H5O_proxy_t * +H5O_cache_proxy_load(H5F_t *f, hid_t UNUSED dxpl_id, haddr_t addr, void *udata) +{ + H5O_t *oh = (H5O_t *)udata; /* Parent object header */ + H5O_proxy_t *proxy = NULL; /* Object header proxy */ + H5O_proxy_t *ret_value; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + HDassert(f); + HDassert(H5F_addr_defined(addr)); + HDassert(udata); + HDassert(oh->proxy_addr == addr); + + /* Create object header proxy object & initialize fields */ + if(NULL == (proxy = H5FL_CALLOC(H5O_proxy_t))) + HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, NULL, "can't allocate object header proxy") + proxy->f = f; + proxy->oh = oh; + + /* Set return value */ + ret_value = proxy; + proxy = NULL; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5O_cache_proxy_load() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_cache_proxy_flush + * + * Purpose: Flush callback for object header proxies. Does nothing + * except destroy the object if requested. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Neil Fortner + * Mar 15 2012 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5O_cache_proxy_flush(H5F_t *f, hid_t UNUSED dxpl_id, hbool_t destroy, + haddr_t addr, H5O_proxy_t *proxy, unsigned UNUSED *flags_ptr) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + /* check arguments */ + HDassert(f); + HDassert(H5F_addr_defined(addr)); + HDassert(proxy); + + /* The dirty flag should not be set */ + HDassert(!proxy->cache_info.is_dirty); + + if(destroy) + if(H5O_cache_proxy_dest(f, proxy) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to destroy object header proxy") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5O_cache_proxy_flush() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_cache_proxy_dest + * + * Purpose: Destroys an object header proxy in memory. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Neil Fortner + * Mar 15 2012 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5O_cache_proxy_dest(H5F_t UNUSED *f, H5O_proxy_t *proxy) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT_NOERR + + HDassert(proxy); + HDassert(proxy->oh); + + /* Free the object header proxy object */ + proxy = H5FL_FREE(H5O_proxy_t, proxy); + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_cache_proxy_dest() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_cache_proxy_clear + * + * Purpose: Clear callback for object header proxies. Does nothing + * except destroy the object if requested. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Neil Fortner + * Mar 15 2012 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5O_cache_proxy_clear(H5F_t *f, H5O_proxy_t *proxy, hbool_t destroy) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + /* + * Check arguments. + */ + HDassert(proxy); + + /* The dirty flag should not be set */ + HDassert(!proxy->cache_info.is_dirty); + + if(destroy) + if(H5O_cache_proxy_dest(f, proxy) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to destroy object header proxy") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_cache_proxy_clear() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_cache_proxy_notify + * + * Purpose: Handle cache action notifications + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Neil Fortner + * Mar 20 2012 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5O_cache_proxy_notify(H5AC_notify_action_t action, H5O_proxy_t *proxy) +{ + H5O_chunk_proxy_t *chk_proxy = NULL; /* Object header chunk proxy */ + unsigned i; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + /* + * Check arguments. + */ + HDassert(proxy); + HDassert(proxy->f); + HDassert(proxy->oh); + HDassert(proxy->oh->swmr_write); + + switch(action) { + case H5AC_NOTIFY_ACTION_AFTER_INSERT: + /* Create flush dependency on object header chunk 0 */ + if(H5AC_create_flush_dependency(proxy->oh, proxy) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTDEPEND, FAIL, "unable to create flush dependency") + + /* Create flush dependencies on all other object header chunks */ + for(i=1; i<proxy->oh->nchunks; i++) { + if(NULL == (chk_proxy = H5O_chunk_protect(proxy->f, H5AC_ind_dxpl_id, proxy->oh, i))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header chunk") + if(H5AC_create_flush_dependency(chk_proxy, proxy) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTDEPEND, FAIL, "unable to create flush dependency") + if(H5O_chunk_unprotect(proxy->f, H5AC_ind_dxpl_id, chk_proxy, FALSE) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk") + chk_proxy = NULL; + } /* end for */ + + /* Mark proxy as present on the object header */ + proxy->oh->proxy_present = TRUE; + + break; + + case H5AC_NOTIFY_ACTION_BEFORE_EVICT: + /* Mark proxy as not present on the object header */ + proxy->oh->proxy_present = FALSE; + + break; + + default: +#ifdef NDEBUG + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "unknown action from metadata cache") +#else /* NDEBUG */ + HDassert(0 && "Unknown action?!?"); +#endif /* NDEBUG */ + } /* end switch */ + +done: + if(chk_proxy) { + HDassert(ret_value < 0); + if(H5O_chunk_unprotect(proxy->f, H5AC_ind_dxpl_id, chk_proxy, FALSE) < 0) + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk") + } /* end if */ + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_cache_proxy_notify() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_cache_proxy_size + * + * Purpose: Compute the size in bytes of an object header proxy + * on disk, and return it in *size_ptr. + * + * Return: 0 (never fails) + * + * Programmer: Neil Fortner + * Mar 15 2012 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5O_cache_proxy_size(const H5F_t UNUSED *f, + const H5O_proxy_t UNUSED *proxy, size_t *size_ptr) +{ + FUNC_ENTER_NOAPI_NOINIT_NOERR + + /* check arguments */ + HDassert(size_ptr); + + /* Object header proxies are represented as 1 byte in cache */ + /* (would be 0 bytes, but cache won't allow it currently. See + * H5D_cache_proxy_size) */ + *size_ptr = 1; + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* H5O_cache_proxy_size() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_proxy_create + * + * Purpose: Allocate temporary space for the object header proxy. We + * save the actual creation of the proxy to the "load" + * callback, to save time for objects that do not have any + * flush dependency children and to simplify the code. The + * load callback needs to set up the flush dependencies + * anyways because the proxy cannot stay pinned by the object + * header or it would be imnpossible to evict the two due to + * the circular dependencies. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Neil Fortner + * Mar 15 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5O_proxy_create(H5F_t *f, hid_t UNUSED dxpl_id, H5O_t *oh) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + HDassert(f); + HDassert(oh); + + /* Get a temp. address for object header proxy */ + if(HADDR_UNDEF == (oh->proxy_addr = H5MF_alloc_tmp(f, (hsize_t)1))) + HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, FAIL, "file allocation failed for object header proxy") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_proxy_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_proxy_pin + * + * Purpose: Returns the proxy object for the specified object header, + * pinned. This proxy can be used as a flush dependency + * parent for items that depend on this object header. + * + * Return: Success: Pointer to a pinned object header proxy + * Failure: NULL + * + * Programmer: Neil Fortner + * Mar 15 2012 + * + *------------------------------------------------------------------------- + */ +H5O_proxy_t * +H5O_proxy_pin(H5F_t *f, hid_t dxpl_id, H5O_t *oh) +{ + H5O_proxy_t *proxy = NULL; /* Object header proxy */ + H5O_proxy_t *ret_value = NULL; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + HDassert(f); + HDassert(oh); + HDassert(H5F_addr_defined(oh->proxy_addr)); + + /* Protect the object header proxy */ + if(NULL == (proxy = (H5O_proxy_t *)H5AC_protect(f, dxpl_id, H5AC_OHDR_PROXY, oh->proxy_addr, oh, H5AC_READ))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, NULL, "unable to protect object header proxy"); + + /* Unprotect the object header proxy and pin it */ + if(H5AC_unprotect(f, dxpl_id, H5AC_OHDR_PROXY, oh->proxy_addr, proxy, H5AC__PIN_ENTRY_FLAG) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, NULL, "unable to unprotect object header proxy"); + + /* Set return value */ + ret_value = proxy; + proxy = NULL; + +done: + if(proxy) { + HDassert(!ret_value); + if(H5AC_unprotect(f, dxpl_id, H5AC_OHDR_PROXY, oh->proxy_addr, proxy, H5AC__NO_FLAGS_SET) < 0) + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, NULL, "unable to unprotect object header proxy"); + } /* end if */ + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_proxy_pin() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_proxy_unpin + * + * Purpose: Unpins the specified object header proxy from the cache. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Neil Fortner + * Mar 15 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5O_proxy_unpin(H5O_proxy_t *proxy) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + HDassert(proxy); + + /* Unpin the object header proxy */ + if(H5AC_unpin_entry(proxy) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPIN, FAIL, "unable to unpin object header proxy") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_proxy_unpin() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_proxy_depend + * + * Purpose: Creates a flush dependency between the object header proxy + * (as child) and the specified object (as parent). + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Neil Fortner + * Mar 20 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5O_proxy_depend(H5F_t *f, hid_t dxpl_id, H5O_t *oh, void *parent) +{ + H5O_proxy_t *proxy = NULL; /* Object header proxy */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + HDassert(f); + HDassert(oh); + HDassert(H5F_addr_defined(oh->proxy_addr)); + HDassert(parent); + + /* Protect the object header proxy */ + if(NULL == (proxy = (H5O_proxy_t *)H5AC_protect(f, dxpl_id, H5AC_OHDR_PROXY, oh->proxy_addr, oh, H5AC_READ))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to protect object header proxy"); + + /* Add the flush dependency on the parent object */ + if(H5AC_create_flush_dependency(parent, proxy) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTDEPEND, FAIL, "unable to create flush dependency") + + /* Unprotect the object header proxy */ + if(H5AC_unprotect(f, dxpl_id, H5AC_OHDR_PROXY, oh->proxy_addr, proxy, H5AC__NO_FLAGS_SET) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header proxy"); + proxy = NULL; + +done: + if(proxy) { + HDassert(ret_value < 0); + if(H5AC_unprotect(f, dxpl_id, H5AC_OHDR_PROXY, oh->proxy_addr, proxy, H5AC__NO_FLAGS_SET) < 0) + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header proxy"); + } /* end if */ + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_proxy_depend() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_proxy_undepend + * + * Purpose: Destroys the flush dependency between the object header + * proxy (as child) and the specified object (as parent). + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Neil Fortner + * Mar 20 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5O_proxy_undepend(H5F_t *f, hid_t dxpl_id, H5O_t *oh, void *parent) +{ + H5O_proxy_t *proxy = NULL; /* Object header proxy */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + HDassert(f); + HDassert(oh); + HDassert(H5F_addr_defined(oh->proxy_addr)); + HDassert(parent); + + /* Protect the object header proxy */ + if(NULL == (proxy = (H5O_proxy_t *)H5AC_protect(f, dxpl_id, H5AC_OHDR_PROXY, oh->proxy_addr, oh, H5AC_READ))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to protect object header proxy"); + + /* Add the flush dependency on the parent object */ + if(H5AC_destroy_flush_dependency(parent, proxy) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency") + + /* Unprotect the object header proxy */ + if(H5AC_unprotect(f, dxpl_id, H5AC_OHDR_PROXY, oh->proxy_addr, proxy, H5AC__NO_FLAGS_SET) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header proxy"); + proxy = NULL; + +done: + if(proxy) { + HDassert(ret_value < 0); + if(H5AC_unprotect(f, dxpl_id, H5AC_OHDR_PROXY, oh->proxy_addr, proxy, H5AC__NO_FLAGS_SET) < 0) + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header proxy"); + } /* end if */ + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_proxy_undepend() */ + diff --git a/src/H5Otest.c b/src/H5Otest.c index 21e4ca8..9c1b9d8 100644 --- a/src/H5Otest.c +++ b/src/H5Otest.c @@ -159,6 +159,7 @@ 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 */ @@ -194,12 +195,17 @@ 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 */ - /*!FIXME use ohdr proxy -NAF */ - if(NULL == (bt2_name = H5B2_open(loc->file, H5AC_ind_dxpl_id, ainfo.name_bt2_addr, NULL, oh))) + if(NULL == (bt2_name = H5B2_open(loc->file, H5AC_ind_dxpl_id, ainfo.name_bt2_addr, NULL, oh_proxy))) HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Reset metadata tag in dxpl_id */ @@ -224,6 +230,8 @@ 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") @@ -254,6 +262,7 @@ 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 */ @@ -288,12 +297,17 @@ 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 */ - /*!FIXME use ohdr proxy -NAF */ - if(NULL == (bt2_name = H5B2_open(loc->file, H5AC_ind_dxpl_id, ainfo.name_bt2_addr, NULL, oh))) + if(NULL == (bt2_name = H5B2_open(loc->file, H5AC_ind_dxpl_id, ainfo.name_bt2_addr, NULL, oh_proxy))) HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Reset metadata tag in dxpl_id */ @@ -315,6 +329,8 @@ 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") @@ -347,6 +363,7 @@ 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 */ @@ -374,6 +391,12 @@ 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) @@ -381,8 +404,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 */ - /*!FIXME use ohdr proxy -NAF */ - if(NULL == (bt2_name = H5B2_open(loc->file, H5AC_ind_dxpl_id, ainfo.name_bt2_addr, NULL, oh))) + if(NULL == (bt2_name = H5B2_open(loc->file, H5AC_ind_dxpl_id, ainfo.name_bt2_addr, NULL, oh_proxy))) HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Retrieve # of records in name index */ @@ -392,8 +414,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 */ - /*!FIXME use ohdr proxy -NAF */ - if(NULL == (bt2_corder = H5B2_open(loc->file, H5AC_ind_dxpl_id, ainfo.corder_bt2_addr, NULL, oh))) + if(NULL == (bt2_corder = H5B2_open(loc->file, H5AC_ind_dxpl_id, ainfo.corder_bt2_addr, NULL, oh_proxy))) 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 */ @@ -412,6 +433,8 @@ 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/Makefile.am b/src/Makefile.am index 36ab249..c426581 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -83,7 +83,7 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ H5Ofill.c H5Oflush.c H5Ofsinfo.c H5Oginfo.c \ H5Olayout.c \ H5Olinfo.c H5Olink.c H5Omessage.c H5Omtime.c \ - H5Oname.c H5Onull.c H5Opline.c H5Orefcount.c \ + H5Oname.c H5Onull.c H5Opline.c H5Oproxy.c H5Orefcount.c \ H5Osdspace.c H5Oshared.c \ H5Oshmesg.c \ H5Ostab.c \ diff --git a/src/Makefile.in b/src/Makefile.in index 71a8f80..cad6093 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -133,23 +133,24 @@ am_libhdf5_la_OBJECTS = H5.lo H5checksum.lo H5dbg.lo H5system.lo \ H5Ochunk.lo H5Ocont.lo H5Ocopy.lo H5Odbg.lo H5Odrvinfo.lo \ H5Odtype.lo H5Oefl.lo H5Ofill.lo H5Oflush.lo H5Ofsinfo.lo \ H5Oginfo.lo H5Olayout.lo H5Olinfo.lo H5Olink.lo H5Omessage.lo \ - H5Omtime.lo H5Oname.lo H5Onull.lo H5Opline.lo H5Orefcount.lo \ - H5Osdspace.lo H5Oshared.lo H5Oshmesg.lo H5Ostab.lo \ - H5Ostorage.lo H5Otest.lo H5Ounknown.lo H5P.lo H5Pacpl.lo \ - H5Pdapl.lo H5Pdcpl.lo H5Pdeprec.lo H5Pdxpl.lo H5Pfapl.lo \ - H5Pfcpl.lo H5Pfmpl.lo H5Pgcpl.lo H5Pint.lo H5Plapl.lo \ - H5Plcpl.lo H5Pocpl.lo H5Pocpypl.lo H5Pstrcpl.lo H5Ptest.lo \ - H5R.lo H5Rdeprec.lo H5RC.lo H5RS.lo H5S.lo H5Sall.lo H5Sdbg.lo \ - H5Shyper.lo H5Smpio.lo H5Snone.lo H5Spoint.lo H5Sselect.lo \ - H5Stest.lo H5SL.lo H5SM.lo H5SMbtree2.lo H5SMcache.lo \ - H5SMmessage.lo H5SMtest.lo H5ST.lo H5T.lo H5Tarray.lo \ - H5Tbit.lo H5Tcommit.lo H5Tcompound.lo H5Tconv.lo H5Tcset.lo \ - H5Tdbg.lo H5Tdeprec.lo H5Tenum.lo H5Tfields.lo H5Tfixed.lo \ - H5Tfloat.lo H5Tinit.lo H5Tnative.lo H5Toffset.lo H5Toh.lo \ - H5Topaque.lo H5Torder.lo H5Tpad.lo H5Tprecis.lo H5Tstrpad.lo \ - H5Tvisit.lo H5Tvlen.lo H5TS.lo H5V.lo H5WB.lo H5Z.lo \ - H5Zdeflate.lo H5Zfletcher32.lo H5Znbit.lo H5Zshuffle.lo \ - H5Zszip.lo H5Zscaleoffset.lo H5Ztrans.lo + H5Omtime.lo H5Oname.lo H5Onull.lo H5Opline.lo H5Oproxy.lo \ + H5Orefcount.lo H5Osdspace.lo H5Oshared.lo H5Oshmesg.lo \ + H5Ostab.lo H5Ostorage.lo H5Otest.lo H5Ounknown.lo H5P.lo \ + H5Pacpl.lo H5Pdapl.lo H5Pdcpl.lo H5Pdeprec.lo H5Pdxpl.lo \ + H5Pfapl.lo H5Pfcpl.lo H5Pfmpl.lo H5Pgcpl.lo H5Pint.lo \ + H5Plapl.lo H5Plcpl.lo H5Pocpl.lo H5Pocpypl.lo H5Pstrcpl.lo \ + H5Ptest.lo H5R.lo H5Rdeprec.lo H5RC.lo H5RS.lo H5S.lo \ + H5Sall.lo H5Sdbg.lo H5Shyper.lo H5Smpio.lo H5Snone.lo \ + H5Spoint.lo H5Sselect.lo H5Stest.lo H5SL.lo H5SM.lo \ + H5SMbtree2.lo H5SMcache.lo H5SMmessage.lo H5SMtest.lo H5ST.lo \ + H5T.lo H5Tarray.lo H5Tbit.lo H5Tcommit.lo H5Tcompound.lo \ + H5Tconv.lo H5Tcset.lo H5Tdbg.lo H5Tdeprec.lo H5Tenum.lo \ + H5Tfields.lo H5Tfixed.lo H5Tfloat.lo H5Tinit.lo H5Tnative.lo \ + H5Toffset.lo H5Toh.lo H5Topaque.lo H5Torder.lo H5Tpad.lo \ + H5Tprecis.lo H5Tstrpad.lo H5Tvisit.lo H5Tvlen.lo H5TS.lo \ + H5V.lo H5WB.lo H5Z.lo H5Zdeflate.lo H5Zfletcher32.lo \ + H5Znbit.lo H5Zshuffle.lo H5Zszip.lo H5Zscaleoffset.lo \ + H5Ztrans.lo libhdf5_la_OBJECTS = $(am_libhdf5_la_OBJECTS) AM_V_lt = $(am__v_lt_$(V)) am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) @@ -545,7 +546,7 @@ libhdf5_la_SOURCES = H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ H5Ofill.c H5Oflush.c H5Ofsinfo.c H5Oginfo.c \ H5Olayout.c \ H5Olinfo.c H5Olink.c H5Omessage.c H5Omtime.c \ - H5Oname.c H5Onull.c H5Opline.c H5Orefcount.c \ + H5Oname.c H5Onull.c H5Opline.c H5Oproxy.c H5Orefcount.c \ H5Osdspace.c H5Oshared.c \ H5Oshmesg.c \ H5Ostab.c \ @@ -900,6 +901,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Oname.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Onull.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Opline.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Oproxy.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Orefcount.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Osdspace.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Oshared.Plo@am__quote@ diff --git a/test/swmr_sparse_reader.c b/test/swmr_sparse_reader.c index 1402435..ab34d97 100644 --- a/test/swmr_sparse_reader.c +++ b/test/swmr_sparse_reader.c @@ -122,25 +122,12 @@ check_dataset(hid_t fid, unsigned verbose, const symbol_info_t *symbol, symbol_t fprintf(stderr, "Symbol = '%s', location = %lld\n", symbol->name, (long long)start);
/* Read record from dataset */
-#ifdef OHDR_DEPS_WORK
- /* Even with the sequence number attribute and all the flush dependencues,
- * it is still currently possible for the attribute to be updated before the
- * index and/or raw data, because the attribute may reside in an object
- * header chunk afer the first. Until this is fixed, just allow the read
- * value to be 0. */
record->rec_id = (uint64_t)ULLONG_MAX;
-#else /* OHDR_DEPS_WORK */
- record->rec_id = (uint64_t)0;
-#endif /* OHDR_DEPS_WORK */
if(H5Dread(dsid, symbol_tid, rec_sid, file_sid, H5P_DEFAULT, record) < 0)
return -1;
/* Verify record value */
- if(record->rec_id != start[1]
-#ifndef OHDR_DEPS_WORK
- && record->rec_id != (uint64_t)0
-#endif
- ) {
+ if(record->rec_id != start[1]) {
fprintf(stderr, "*** ERROR ***\n");
fprintf(stderr, "Incorrect record value!\n");
fprintf(stderr, "Symbol = '%s', location = %lld, record->rec_id = %llu\n", symbol->name, (long long)start, (unsigned long long)record->rec_id);
|