diff options
-rw-r--r-- | src/H5B2.c | 30 | ||||
-rw-r--r-- | src/H5B2dbg.c | 61 | ||||
-rw-r--r-- | src/H5B2hdr.c | 83 | ||||
-rw-r--r-- | src/H5B2pkg.h | 4 | ||||
-rw-r--r-- | src/H5C.c | 93 | ||||
-rw-r--r-- | src/H5EAhdr.c | 33 | ||||
-rw-r--r-- | src/H5FAhdr.c | 3 | ||||
-rw-r--r-- | test/Makefile.am | 14 | ||||
-rw-r--r-- | test/btree2.c | 182 | ||||
-rw-r--r-- | test/dsets.c | 67 | ||||
-rw-r--r-- | test/earray.c | 197 | ||||
-rw-r--r-- | test/farray.c | 163 |
12 files changed, 680 insertions, 250 deletions
@@ -134,7 +134,6 @@ H5B2_create(H5F_t *f, hid_t dxpl_id, const H5B2_create_t *cparam, void *ctx_udat { H5B2_t *bt2 = NULL; /* Pointer to the B-tree */ H5B2_hdr_t *hdr = NULL; /* Pointer to the B-tree header */ - H5B2_hdr_cache_ud_t cache_udata; /* User-data for callback */ haddr_t hdr_addr; /* B-tree header address */ H5B2_t *ret_value = NULL; /* Return value */ @@ -158,11 +157,8 @@ H5B2_create(H5F_t *f, hid_t dxpl_id, const H5B2_create_t *cparam, void *ctx_udat HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "memory allocation failed for v2 B-tree info") /* Look up the B-tree header */ - cache_udata.f = f; - cache_udata.addr = hdr_addr; - cache_udata.ctx_udata = ctx_udata; - if(NULL == (hdr = (H5B2_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, hdr_addr, &cache_udata, H5AC__NO_FLAGS_SET))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, NULL, "unable to load B-tree header") + if(NULL == (hdr = H5B2__hdr_protect(f, dxpl_id, hdr_addr, ctx_udata, H5AC__NO_FLAGS_SET))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, NULL, "unable to protect v2 B-tree header") /* Point v2 B-tree wrapper at header and bump it's ref count */ bt2->hdr = hdr; @@ -180,7 +176,7 @@ H5B2_create(H5F_t *f, hid_t dxpl_id, const H5B2_create_t *cparam, void *ctx_udat ret_value = bt2; done: - if(hdr && H5AC_unprotect(f, dxpl_id, H5AC_BT2_HDR, hdr_addr, hdr, H5AC__NO_FLAGS_SET) < 0) + if(hdr && H5B2__hdr_unprotect(hdr, dxpl_id, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, NULL, "unable to release v2 B-tree header") if(!ret_value && bt2) if(H5B2_close(bt2, dxpl_id) < 0) @@ -209,7 +205,6 @@ H5B2_open(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *ctx_udata) { H5B2_t *bt2 = NULL; /* Pointer to the B-tree */ H5B2_hdr_t *hdr = NULL; /* Pointer to the B-tree header */ - H5B2_hdr_cache_ud_t cache_udata; /* User-data for callback */ H5B2_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -219,11 +214,8 @@ H5B2_open(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *ctx_udata) HDassert(H5F_addr_defined(addr)); /* Look up the B-tree header */ - cache_udata.f = f; - cache_udata.addr = addr; - cache_udata.ctx_udata = ctx_udata; - if(NULL == (hdr = (H5B2_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, &cache_udata, H5AC__READ_ONLY_FLAG))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, NULL, "unable to load B-tree header") + if(NULL == (hdr = H5B2__hdr_protect(f, dxpl_id, addr, ctx_udata, H5AC__READ_ONLY_FLAG))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, NULL, "unable to protect v2 B-tree header") /* Check for pending heap deletion */ if(hdr->pending_delete) @@ -249,7 +241,7 @@ H5B2_open(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *ctx_udata) ret_value = bt2; done: - if(hdr && H5AC_unprotect(f, dxpl_id, H5AC_BT2_HDR, addr, hdr, H5AC__NO_FLAGS_SET) < 0) + if(hdr && H5B2__hdr_unprotect(hdr, dxpl_id, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, NULL, "unable to release v2 B-tree header") if(!ret_value && bt2) if(H5B2_close(bt2, dxpl_id) < 0) @@ -1282,7 +1274,7 @@ H5B2_close(H5B2_t *bt2, hid_t dxpl_id) /* Lock the v2 B-tree header into memory */ /* (OK to pass in NULL for callback context, since we know the header must be in the cache) */ - if(NULL == (hdr = (H5B2_hdr_t *)H5AC_protect(bt2->f, dxpl_id, H5AC_BT2_HDR, bt2_addr, NULL, H5AC__NO_FLAGS_SET))) + if(NULL == (hdr = H5B2__hdr_protect(bt2->f, dxpl_id, bt2_addr, NULL, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect v2 B-tree header") /* Set the shared v2 B-tree header's file context for this operation */ @@ -1344,7 +1336,6 @@ H5B2_delete(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *ctx_udata, H5B2_remove_t op, void *op_data) { H5B2_hdr_t *hdr = NULL; /* Pointer to the B-tree header */ - H5B2_hdr_cache_ud_t cache_udata; /* User-data for callback */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1357,10 +1348,7 @@ H5B2_delete(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *ctx_udata, #ifdef QAK HDfprintf(stderr, "%s: addr = %a\n", FUNC, addr); #endif /* QAK */ - cache_udata.f = f; - cache_udata.addr = addr; - cache_udata.ctx_udata = ctx_udata; - if(NULL == (hdr = (H5B2_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, &cache_udata, H5AC__NO_FLAGS_SET))) + if(NULL == (hdr = H5B2__hdr_protect(f, dxpl_id, addr, ctx_udata, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect v2 B-tree header") /* Remember the callback & context for later */ @@ -1382,7 +1370,7 @@ HDfprintf(stderr, "%s: addr = %a\n", FUNC, addr); done: /* Unprotect the header, if an error occurred */ - if(hdr && H5AC_unprotect(f, dxpl_id, H5AC_BT2_HDR, addr, hdr, H5AC__NO_FLAGS_SET) < 0) + if(hdr && H5B2__hdr_unprotect(hdr, dxpl_id, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release v2 B-tree header") FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5B2dbg.c b/src/H5B2dbg.c index ad9f970..73084d2 100644 --- a/src/H5B2dbg.c +++ b/src/H5B2dbg.c @@ -95,7 +95,6 @@ H5B2__hdr_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, void *dbg_ctx = NULL; /* v2 B-tree debugging context */ unsigned u; /* Local index variable */ char temp_str[128]; /* Temporary string, for formatting */ - H5B2_hdr_cache_ud_t cache_udata; /* User-data for callback */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -114,19 +113,13 @@ H5B2__hdr_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, (NULL == type->crt_dbg_ctx && NULL == type->dst_dbg_ctx)); /* Check for debugging context callback available */ - if(type->crt_dbg_ctx) { + if(type->crt_dbg_ctx) /* Create debugging context */ if(NULL == (dbg_ctx = (type->crt_dbg_ctx)(f, dxpl_id, obj_addr))) HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "unable to create v2 B-tree debugging context") - } /* end if */ - /* - * Load the B-tree header. - */ - cache_udata.f = f; - cache_udata.addr = addr; - cache_udata.ctx_udata = dbg_ctx; - if(NULL == (hdr = (H5B2_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, &cache_udata, H5AC__READ_ONLY_FLAG))) + /* Load the B-tree header */ + if(NULL == (hdr = H5B2__hdr_protect(f, dxpl_id, addr, dbg_ctx, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree header") /* Set file pointer for this B-tree operation */ @@ -180,11 +173,8 @@ H5B2__hdr_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, done: if(dbg_ctx && (type->dst_dbg_ctx)(dbg_ctx) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTRELEASE, FAIL, "unable to release v2 B-tree debugging context") - if(hdr) { - hdr->f = NULL; - if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_HDR, addr, hdr, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree header") - } /* end if */ + if(hdr && H5B2__hdr_unprotect(hdr, dxpl_id, H5AC__NO_FLAGS_SET) < 0) + HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release v2 B-tree header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__hdr_debug() */ @@ -212,7 +202,6 @@ H5B2__int_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, void *dbg_ctx = NULL; /* v2 B-tree debugging context */ unsigned u; /* Local index variable */ char temp_str[128]; /* Temporary string, for formatting */ - H5B2_hdr_cache_ud_t cache_udata; /* User-data for callback */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -239,14 +228,9 @@ H5B2__int_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "unable to create v2 B-tree debugging context") } /* end if */ - /* - * Load the B-tree header. - */ - cache_udata.f = f; - cache_udata.addr = hdr_addr; - cache_udata.ctx_udata = dbg_ctx; - if(NULL == (hdr = (H5B2_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, hdr_addr, &cache_udata, H5AC__READ_ONLY_FLAG))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree header") + /* Load the B-tree header */ + if(NULL == (hdr = H5B2__hdr_protect(f, dxpl_id, hdr_addr, dbg_ctx, H5AC__READ_ONLY_FLAG))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load v2 B-tree header") /* Set file pointer for this B-tree operation */ hdr->f = f; @@ -309,11 +293,8 @@ H5B2__int_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, done: if(dbg_ctx && (type->dst_dbg_ctx)(dbg_ctx) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTRELEASE, FAIL, "unable to release v2 B-tree debugging context") - if(hdr) { - hdr->f = NULL; - if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_HDR, hdr_addr, hdr, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree header") - } /* end if */ + if(hdr && H5B2__hdr_unprotect(hdr, dxpl_id, H5AC__NO_FLAGS_SET) < 0) + HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release v2 B-tree header") if(internal && H5AC_unprotect(f, dxpl_id, H5AC_BT2_INT, addr, internal, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree internal node") @@ -340,7 +321,6 @@ H5B2__leaf_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent { H5B2_hdr_t *hdr = NULL; /* B-tree header */ H5B2_leaf_t *leaf = NULL; /* B-tree leaf node */ - H5B2_hdr_cache_ud_t cache_udata; /* User-data for callback */ void *dbg_ctx = NULL; /* v2 B-tree debugging context */ unsigned u; /* Local index variable */ char temp_str[128]; /* Temporary string, for formatting */ @@ -364,20 +344,14 @@ H5B2__leaf_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent HDassert(nrec > 0); /* Check for debugging context callback available */ - if(type->crt_dbg_ctx) { + if(type->crt_dbg_ctx) /* Create debugging context */ if(NULL == (dbg_ctx = (type->crt_dbg_ctx)(f, dxpl_id, obj_addr))) HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "unable to create v2 B-tree debugging context") - } /* end if */ - /* - * Load the B-tree header. - */ - cache_udata.f = f; - cache_udata.addr = hdr_addr; - cache_udata.ctx_udata = dbg_ctx; - if(NULL == (hdr = (H5B2_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, hdr_addr, &cache_udata, H5AC__READ_ONLY_FLAG))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree header") + /* Load the B-tree header */ + if(NULL == (hdr = H5B2__hdr_protect(f, dxpl_id, hdr_addr, dbg_ctx, H5AC__READ_ONLY_FLAG))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect v2 B-tree header") /* Set file pointer for this B-tree operation */ hdr->f = f; @@ -423,11 +397,8 @@ H5B2__leaf_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent done: if(dbg_ctx && (type->dst_dbg_ctx)(dbg_ctx) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTRELEASE, FAIL, "unable to release v2 B-tree debugging context") - if(hdr) { - hdr->f = NULL; - if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_HDR, hdr_addr, hdr, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree header") - } /* end if */ + if(hdr && H5B2__hdr_unprotect(hdr, dxpl_id, H5AC__NO_FLAGS_SET) < 0) + HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree header") if(leaf && H5AC_unprotect(f, dxpl_id, H5AC_BT2_LEAF, addr, leaf, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree leaf node") diff --git a/src/H5B2hdr.c b/src/H5B2hdr.c index 16d8467..25ac141 100644 --- a/src/H5B2hdr.c +++ b/src/H5B2hdr.c @@ -209,10 +209,9 @@ HDmemset(hdr->page, 0, hdr->node_size); } /* end if */ /* Create the callback context, if the callback exists */ - if(hdr->cls->crt_context) { + if(hdr->cls->crt_context) if(NULL == (hdr->cb_ctx = (*hdr->cls->crt_context)(ctx_udata))) HGOTO_ERROR(H5E_BTREE, H5E_CANTCREATE, FAIL, "unable to create v2 B-tree client callback context") - } /* end if */ done: if(ret_value < 0) @@ -488,6 +487,82 @@ done: /*------------------------------------------------------------------------- + * Function: H5B2__hdr_protect + * + * Purpose: Convenience wrapper around protecting v2 B-tree header + * + * Return: Non-NULL pointer to header on success/NULL on failure + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * Dec 18 2015 + * + *------------------------------------------------------------------------- + */ +H5B2_hdr_t * +H5B2__hdr_protect(H5F_t *f, hid_t dxpl_id, haddr_t hdr_addr, void *ctx_udata, + unsigned flags) +{ + H5B2_hdr_cache_ud_t udata; /* User data for cache callbacks */ + H5B2_hdr_t *ret_value = NULL; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Sanity check */ + HDassert(f); + HDassert(H5F_addr_defined(hdr_addr)); + + /* only the H5AC__READ_ONLY_FLAG may appear in flags */ + HDassert((flags & (unsigned)(~H5AC__READ_ONLY_FLAG)) == 0); + + /* Set up user data for cache callbacks */ + udata.f = f; + udata.addr = hdr_addr; + udata.ctx_udata = ctx_udata; + + /* Protect the header */ + if(NULL == (ret_value = (H5B2_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, hdr_addr, &udata, flags))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, NULL, "unable to load v2 B-tree header, address = %llu", (unsigned long long)hdr_addr) + ret_value->f = f; /* (Must be set again here, in case the header was already in the cache -QAK) */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5B2__hdr_protect() */ + + +/*------------------------------------------------------------------------- + * Function: H5B2__hdr_unprotect + * + * Purpose: Convenience wrapper around unprotecting v2 B-tree header + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * Dec 18 2015 + * + *------------------------------------------------------------------------- + */ +herr_t +H5B2__hdr_unprotect(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned cache_flags) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Sanity check */ + HDassert(hdr); + + /* Unprotect the header */ + if(H5AC_unprotect(hdr->f, dxpl_id, H5AC_BT2_HDR, hdr->addr, hdr, cache_flags) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to unprotect v2 B-tree header, address = %llu", (unsigned long long)hdr->addr) + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5B2__hdr_unprotect() */ + + +/*------------------------------------------------------------------------- * Function: H5B2__hdr_free * * Purpose: Free B-tree header info @@ -609,8 +684,8 @@ H5B2__hdr_delete(H5B2_hdr_t *hdr, hid_t dxpl_id) done: /* Unprotect the header with appropriate flags */ - if(H5AC_unprotect(hdr->f, dxpl_id, H5AC_BT2_HDR, hdr->addr, hdr, cache_flags) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree header") + if(H5B2__hdr_unprotect(hdr, dxpl_id, cache_flags) < 0) + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release v2 B-tree header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__hdr_delete() */ diff --git a/src/H5B2pkg.h b/src/H5B2pkg.h index d661efa..f58850e 100644 --- a/src/H5B2pkg.h +++ b/src/H5B2pkg.h @@ -302,6 +302,10 @@ H5_DLL herr_t H5B2__hdr_decr(H5B2_hdr_t *hdr); H5_DLL herr_t H5B2__hdr_fuse_incr(H5B2_hdr_t *hdr); H5_DLL size_t H5B2__hdr_fuse_decr(H5B2_hdr_t *hdr); H5_DLL herr_t H5B2__hdr_dirty(H5B2_hdr_t *hdr); +H5_DLL H5B2_hdr_t *H5B2__hdr_protect(H5F_t *f, hid_t dxpl_id, haddr_t hdr_addr, + void *ctx_udata, unsigned flags); +H5_DLL herr_t H5B2__hdr_unprotect(H5B2_hdr_t *hdr, hid_t dxpl_id, + unsigned cache_flags); H5_DLL herr_t H5B2__hdr_delete(H5B2_hdr_t *hdr, hid_t dxpl_id); /* Routines for operating on leaf nodes */ @@ -2938,7 +2938,7 @@ done: ( H5C_validate_pinned_entry_list(cache_ptr) < 0 ) || ( H5C_validate_lru_list(cache_ptr) < 0 ) ) { - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, NULL, \ "an extreme sanity check failed on exit.\n"); } #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ @@ -6802,7 +6802,7 @@ H5C_flush_invalidate_ring(const H5F_t * f, hid_t dxpl_id, H5C_ring_t ring, /* Get cache entry for this node */ next_entry_ptr = (H5C_cache_entry_t *)H5SL_item(node_ptr); - if ( NULL == next_entry_ptr ) + if(NULL == next_entry_ptr) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "next_entry_ptr == NULL ?!?!") HDassert(next_entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); @@ -7240,8 +7240,8 @@ H5C_flush_ring(H5F_t *f, hid_t dxpl_id, H5C_ring_t ring, unsigned flags) #if H5C_DO_EXTREME_SANITY_CHECKS if((H5C_validate_protected_entry_list(cache_ptr) < 0) || - (H5C_validate_pinned_entry_list(cache_ptr) < 0 || - (H5C_validate_lru_list(cache_ptr) < 0)) { + (H5C_validate_pinned_entry_list(cache_ptr) < 0) || + (H5C_validate_lru_list(cache_ptr) < 0)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on entry.\n"); #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ @@ -7604,7 +7604,7 @@ done: * * Refactored function to delay all modifications of the * metadata cache data structures until after any calls - * to the pre-serialize or serialize callbacks. + * to the pre-serialize or serialize callbacks. * * Need to do this, as some pre-serialize or serialize * calls result in calls to the metadata cache and @@ -7668,7 +7668,7 @@ H5C__flush_single_entry(const H5F_t *f, hid_t dxpl_id, H5C_cache_entry_t *entry_ else destroy_entry = destroy; - /* we will write the entry to disk if it exists, is dirty, and if the + /* we will write the entry to disk if it exists, is dirty, and if the * clear only flag is not set. */ if(entry_ptr->is_dirty && !clear_only) @@ -8057,7 +8057,7 @@ H5C__flush_single_entry(const H5F_t *f, hid_t dxpl_id, H5C_cache_entry_t *entry_ /* only log a flush if we actually wrote to disk */ H5C__UPDATE_STATS_FOR_FLUSH(cache_ptr, entry_ptr) - } + } /* end else if */ if(destroy) { if(take_ownership) @@ -8066,7 +8066,7 @@ H5C__flush_single_entry(const H5F_t *f, hid_t dxpl_id, H5C_cache_entry_t *entry_ HDassert(destroy_entry); H5C__UPDATE_STATS_FOR_EVICTION(cache_ptr, entry_ptr, take_ownership) - } + } /* end if */ /* If the entry's type has a 'notify' callback and the entry is about * to be removed from the cache, send a 'before eviction' notice while @@ -8306,12 +8306,12 @@ H5C_load_entry(H5F_t * f, /* verify absence of prohibited or unsupported type flag combinations */ HDassert(!(type->flags & H5C__CLASS_NO_IO_FLAG)); - + /* for now, we do not combine the speculative load and compressed flags */ HDassert(!((type->flags & H5C__CLASS_SPECULATIVE_LOAD_FLAG) && (type->flags & H5C__CLASS_COMPRESSED_FLAG))); - /* Can't see how skip reads could be usefully combined with + /* Can't see how skip reads could be usefully combined with * either the speculative read or compressed flags. Hence disallow. */ HDassert(!((type->flags & H5C__CLASS_SKIP_READS) && @@ -8433,12 +8433,10 @@ H5C_load_entry(H5F_t * f, } /* Allocate the buffer for reading the on-disk entry image */ if(NULL == (image = H5MM_malloc(len + H5C_IMAGE_EXTRA_SPACE))) - - HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, NULL, \ - "memory allocation failed for on disk image buffer.") + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, NULL, "memory allocation failed for on disk image buffer.") #if H5C_DO_MEMORY_SANITY_CHECKS - HDmemcpy(((uint8_t *)image) + len, H5C_IMAGE_SANITY_VALUE, H5C_IMAGE_EXTRA_SPACE); + HDmemcpy(image + len, H5C_IMAGE_SANITY_VALUE, H5C_IMAGE_EXTRA_SPACE); #endif /* H5C_DO_MEMORY_SANITY_CHECKS */ /* Get the on-disk entry image */ @@ -8472,12 +8470,9 @@ H5C_load_entry(H5F_t * f, /* Get the actual image size for the thing */ if(type->image_len(thing, &new_len, &compressed, &compressed_size) < 0) - - HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, NULL, \ - "can't retrieve image length") + HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, NULL, "can't retrieve image length") if(new_len == 0) - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, NULL, "image length is 0") HDassert(((type->flags & H5C__CLASS_COMPRESSED_FLAG) != 0) || @@ -8521,15 +8516,13 @@ H5C_load_entry(H5F_t * f, if(NULL == (new_image = H5MM_realloc(image, new_len + H5C_IMAGE_EXTRA_SPACE))) - HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, NULL, \ - "image null after H5MM_realloc()") + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, NULL, "image null after H5MM_realloc()") image = new_image; #if H5C_DO_MEMORY_SANITY_CHECKS - HDmemcpy(((uint8_t *)image) + new_len, - H5C_IMAGE_SANITY_VALUE, H5C_IMAGE_EXTRA_SPACE); + HDmemcpy(((uint8_t *)image) + new_len, H5C_IMAGE_SANITY_VALUE, H5C_IMAGE_EXTRA_SPACE); #endif /* H5C_DO_MEMORY_SANITY_CHECKS */ @@ -8550,15 +8543,13 @@ H5C_load_entry(H5F_t * f, if ( type->free_icr(thing) < 0 ) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, NULL, \ - "free_icr callback failed") + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, NULL, "free_icr callback failed") /* Go get the on-disk image again */ if(H5F_block_read(f, type->mem_type, addr, new_len, dxpl_id, image) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTLOAD, NULL, \ - "Can't read image") + HGOTO_ERROR(H5E_CACHE, H5E_CANTLOAD, NULL, "Can't read image") /* Deserialize on-disk image into native memory * form again @@ -8621,7 +8612,7 @@ H5C_load_entry(H5F_t * f, * * HDassert( ( dirty == FALSE ) || ( type->id == 5 || type->id == 6 ) ); * - * note that type ids 5 & 6 are associated with object headers in the + * note that type ids 5 & 6 are associated with object headers in the * metadata cache. * * When we get to using H5C for other purposes, we may wish to @@ -8824,8 +8815,8 @@ H5C_make_space_in_cache(H5F_t * f, ( entry_ptr != NULL ) ) { - HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - HDassert( ! (entry_ptr->is_protected) ); + HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + HDassert( !(entry_ptr->is_protected) ); HDassert( ! (entry_ptr->is_read_only) ); HDassert( (entry_ptr->ro_ref_count) == 0 ); @@ -8857,8 +8848,8 @@ H5C_make_space_in_cache(H5F_t * f, * last_entry_removed_ptr prior to the call to * H5C__flush_single_entry() so that we can spot * unexpected removals of entries from the cache, - * and set the restart_scan flag if proceeding - * would be likely to cause us to scan an entry + * and set the restart_scan flag if proceeding + * would be likely to cause us to scan an entry * that is no longer in the cache. */ cache_ptr->entries_removed_counter = 0; @@ -8881,7 +8872,6 @@ H5C_make_space_in_cache(H5F_t * f, if(H5C__flush_single_entry(f, dxpl_id, entry_ptr, H5C__FLUSH_INVALIDATE_FLAG | H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG, NULL) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush entry") - } else { /* We have enough space so don't flush clean entry. */ #if H5C_COLLECT_CACHE_STATS @@ -8906,15 +8896,15 @@ H5C_make_space_in_cache(H5F_t * f, if ( didnt_flush_entry ) { - /* epoch markers don't get flushed, and we don't touch + /* epoch markers don't get flushed, and we don't touch * entries that are in the process of being flushed. - * Hence no need for sanity checks, as we haven't - * flushed anything. Thus just set entry_ptr to prev_ptr + * Hence no need for sanity checks, as we haven't + * flushed anything. Thus just set entry_ptr to prev_ptr * and go on. */ entry_ptr = prev_ptr; - } else if ( ( restart_scan ) + } else if ( ( restart_scan ) || ( prev_ptr->is_dirty != prev_is_dirty ) || @@ -9084,10 +9074,8 @@ H5C_validate_lru_list(H5C_t * cache_ptr) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 1 failed") } - if ( ( cache_ptr->LRU_list_len < 0 ) || ( cache_ptr->LRU_list_size < 0 ) ) { - + if(cache_ptr->LRU_list_len < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 2 failed") - } if ( ( cache_ptr->LRU_list_len == 1 ) && @@ -9214,10 +9202,8 @@ H5C_validate_pinned_entry_list(H5C_t * cache_ptr) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 1 failed") } - if ( ( cache_ptr->pel_len < 0 ) || ( cache_ptr->pel_size < 0 ) ) { - + if(cache_ptr->pel_len < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 2 failed") - } if ( ( cache_ptr->pel_len == 1 ) && @@ -9337,21 +9323,12 @@ H5C_validate_protected_entry_list(H5C_t * cache_ptr) HDassert( cache_ptr ); HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); - if ( ( ( cache_ptr->pl_head_ptr == NULL ) - || - ( cache_ptr->pl_tail_ptr == NULL ) - ) - && - ( cache_ptr->pl_head_ptr != cache_ptr->pl_tail_ptr ) - ) { - + if(((cache_ptr->pl_head_ptr == NULL) || (cache_ptr->pl_tail_ptr == NULL)) + && (cache_ptr->pl_head_ptr != cache_ptr->pl_tail_ptr)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 1 failed") - } - - if ( ( cache_ptr->pl_len < 0 ) || ( cache_ptr->pl_size < 0 ) ) { + if(cache_ptr->pl_len < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 2 failed") - } if ( ( cache_ptr->pl_len == 1 ) && @@ -9682,7 +9659,7 @@ done: * Function: H5C_ignore_tags * * Purpose: Override all assertion frameworks associated with making - * sure proper tags are applied to metadata. + * sure proper tags are applied to cache entries. * * NOTE: This should really only be used in tests that need * to access internal functions without going through @@ -9794,7 +9771,7 @@ done: * Return: FAIL if error is detected, SUCCEED otherwise. * * Programmer: Mike McGreevy - * November 3, 2009 + * August 19, 2010 * *------------------------------------------------------------------------- */ @@ -9837,7 +9814,7 @@ done: * Return: FAIL if error is detected, SUCCEED otherwise. * * Programmer: Mike McGreevy - * November 3, 2009 + * September 9, 2010 * *------------------------------------------------------------------------- */ @@ -9883,7 +9860,7 @@ H5C_mark_tagged_entries(H5C_t * cache_ptr, haddr_t tag) * Return: FAIL if error is detected, SUCCEED otherwise. * * Programmer: Mike McGreevy - * November 3, 2009 + * November 3, 2010 * *------------------------------------------------------------------------- */ diff --git a/src/H5EAhdr.c b/src/H5EAhdr.c index eff4b54..da15087 100644 --- a/src/H5EAhdr.c +++ b/src/H5EAhdr.c @@ -43,7 +43,7 @@ #include "H5Eprivate.h" /* Error handling */ #include "H5EApkg.h" /* Extensible Arrays */ #include "H5MFprivate.h" /* File memory management */ -#include "H5VMprivate.h" /* Vectors and arrays */ +#include "H5VMprivate.h" /* Vectors and arrays */ /****************/ @@ -128,7 +128,7 @@ H5EA__hdr_alloc(H5F_t *f)) /* Allocate space for the shared information */ if(NULL == (hdr = H5FL_CALLOC(H5EA_hdr_t))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array shared header") + H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array shared header") /* Set non-zero internal fields */ hdr->addr = HADDR_UNDEF; @@ -390,35 +390,35 @@ HDfprintf(stderr, "%s: Called\n", FUNC); /* Check for valid parameters */ if(cparam->raw_elmt_size == 0) - H5E_THROW(H5E_BADVALUE, "element size must be greater than zero") + H5E_THROW(H5E_BADVALUE, "element size must be greater than zero") if(cparam->max_nelmts_bits == 0) - H5E_THROW(H5E_BADVALUE, "max. # of elements bits must be greater than zero") + H5E_THROW(H5E_BADVALUE, "max. # of elements bits must be greater than zero") if(cparam->max_nelmts_bits > H5EA_MAX_NELMTS_IDX_MAX) - H5E_THROW(H5E_BADVALUE, "max. # of elements bits must be <= %u", (unsigned)H5EA_MAX_NELMTS_IDX_MAX) + H5E_THROW(H5E_BADVALUE, "max. # of elements bits must be <= %u", (unsigned)H5EA_MAX_NELMTS_IDX_MAX) if(cparam->sup_blk_min_data_ptrs < 2) - H5E_THROW(H5E_BADVALUE, "min # of data block pointers in super block must be >= two") + H5E_THROW(H5E_BADVALUE, "min # of data block pointers in super block must be >= two") if(!POWER_OF_TWO(cparam->sup_blk_min_data_ptrs)) - H5E_THROW(H5E_BADVALUE, "min # of data block pointers in super block must be power of two") + H5E_THROW(H5E_BADVALUE, "min # of data block pointers in super block must be power of two") if(!POWER_OF_TWO(cparam->data_blk_min_elmts)) - H5E_THROW(H5E_BADVALUE, "min # of elements per data block must be power of two") + H5E_THROW(H5E_BADVALUE, "min # of elements per data block must be power of two") dblk_page_nelmts = (size_t)1 << cparam->max_dblk_page_nelmts_bits; if(dblk_page_nelmts < cparam->idx_blk_elmts) - H5E_THROW(H5E_BADVALUE, "# of elements per data block page must be greater than # of elements in index block") + H5E_THROW(H5E_BADVALUE, "# of elements per data block page must be greater than # of elements in index block") /* Compute the number of elements in data blocks for first actual super block */ sblk_idx = H5EA_SBLK_FIRST_IDX(cparam->sup_blk_min_data_ptrs); dblk_nelmts = H5EA_SBLK_DBLK_NELMTS(sblk_idx, cparam->data_blk_min_elmts); if(dblk_page_nelmts < dblk_nelmts) - H5E_THROW(H5E_BADVALUE, "max. # of elements per data block page bits must be > # of elements in first data block from super block") + H5E_THROW(H5E_BADVALUE, "max. # of elements per data block page bits must be > # of elements in first data block from super block") if(cparam->max_dblk_page_nelmts_bits > cparam->max_nelmts_bits) - H5E_THROW(H5E_BADVALUE, "max. # of elements per data block page bits must be <= max. # of elements bits") + H5E_THROW(H5E_BADVALUE, "max. # of elements per data block page bits must be <= max. # of elements bits") } #endif /* NDEBUG */ /* Allocate space for the shared information */ if(NULL == (hdr = H5EA__hdr_alloc(f))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array shared header") + H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array shared header") /* Set the internal parameters for the array */ hdr->idx_blk_addr = HADDR_UNDEF; @@ -428,15 +428,15 @@ HDfprintf(stderr, "%s: Called\n", FUNC); /* Finish initializing extensible array header */ if(H5EA__hdr_init(hdr, ctx_udata) < 0) - H5E_THROW(H5E_CANTINIT, "initialization failed for extensible array header") + H5E_THROW(H5E_CANTINIT, "initialization failed for extensible array header") /* Allocate space for the header on disk */ if(HADDR_UNDEF == (hdr->addr = H5MF_alloc(f, H5FD_MEM_EARRAY_HDR, dxpl_id, (hsize_t)hdr->size))) - H5E_THROW(H5E_CANTALLOC, "file allocation failed for extensible array header") + H5E_THROW(H5E_CANTALLOC, "file allocation failed for extensible array header") /* Cache the new extensible array header */ if(H5AC_insert_entry(f, dxpl_id, H5AC_EARRAY_HDR, hdr->addr, hdr, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTINSERT, "can't add extensible array header to cache") + H5E_THROW(H5E_CANTINSERT, "can't add extensible array header to cache") /* Set address of array header to return */ ret_value = hdr->addr; @@ -616,7 +616,7 @@ END_FUNC(PKG) /* end H5EA__hdr_modified() */ * * Purpose: Convenience wrapper around protecting extensible array header * - * Return: Non-NULL pointer to index block on success/NULL on failure + * Return: Non-NULL pointer to header on success/NULL on failure * * Programmer: Quincey Koziol * koziol@hdfgroup.org @@ -647,6 +647,7 @@ H5EA__hdr_protect(H5F_t *f, hid_t dxpl_id, haddr_t ea_addr, void *ctx_udata, /* Protect the header */ if(NULL == (ret_value = (H5EA_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_EARRAY_HDR, ea_addr, &udata, flags))) H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array header, address = %llu", (unsigned long long)ea_addr) + ret_value->f = f; /* (Must be set again here, in case the header was already in the cache -QAK) */ CATCH diff --git a/src/H5FAhdr.c b/src/H5FAhdr.c index 62b1837..ac9a103 100644 --- a/src/H5FAhdr.c +++ b/src/H5FAhdr.c @@ -397,7 +397,7 @@ END_FUNC(PKG) /* end H5FA__hdr_modified() */ * * Purpose: Convenience wrapper around protecting fixed array header * - * Return: Non-NULL pointer to index block on success/NULL on failure + * Return: Non-NULL pointer to header on success/NULL on failure * * Programmer: Quincey Koziol * koziol@hdfgroup.org @@ -428,6 +428,7 @@ H5FA__hdr_protect(H5F_t *f, hid_t dxpl_id, haddr_t fa_addr, void *ctx_udata, /* Protect the header */ if(NULL == (ret_value = (H5FA_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_FARRAY_HDR, fa_addr, &udata, flags))) H5E_THROW(H5E_CANTPROTECT, "unable to protect fixed array header, address = %llu", (unsigned long long)fa_addr) + ret_value->f = f; /* (Must be set again here, in case the header was already in the cache -QAK) */ CATCH diff --git a/test/Makefile.am b/test/Makefile.am index d9c53d4..8389cc4 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -37,16 +37,14 @@ check_SCRIPTS = $(TEST_SCRIPT) # executed, generally most specific tests to least specific tests. # As an exception, long-running tests should occur earlier in the list. # This gives them more time to run when tests are executing in parallel. -# These tests (fheap, btree2) are under development and are not used by -# the library yet. Move them to the end so that their failure do not block -# other current library code tests. -TEST_PROG= testhdf5 lheap ohdr stab gheap cache cache_api cache_tagging \ +TEST_PROG= testhdf5 cache cache_api cache_tagging lheap ohdr stab gheap \ + farray earray btree2 fheap \ pool accum hyperslab istore bittests dt_arith \ dtypes dsets cmpd_dset filter_fail extend external efc objcopy links unlink \ big mtime fillval mount flush1 flush2 app_ref enum \ set_extent ttsafe enc_dec_plist enc_dec_plist_cross_platform\ getname vfd ntypes dangle dtransform reserved cross_read \ - freespace mf vds farray earray btree2 fheap file_image unregister + freespace mf vds file_image unregister # List programs to be built when testing here. error_test and err_compat are # built at the same time as the other tests, but executed by testerror.sh. @@ -145,9 +143,9 @@ CHECK_CLEANFILES+=accum.h5 cmpd_dset.h5 compact_dataset.h5 dataset.h5 dset_offse multi_file-[rs].h5 core_file plugin.h5 \ new_move_[ab].h5 ntypes.h5 dangle.h5 error_test.h5 err_compat.h5 \ dtransform.h5 test_filters.h5 get_file_name.h5 tstint[1-2].h5 \ - unlink_chunked.h5 btree2.h5 objcopy_src.h5 objcopy_dst.h5 \ - objcopy_ext.dat trefer1.h5 trefer2.h5 app_ref.h5 farray.h5 \ - earray.h5 efc[0-5].h5 log_vfd_out.log \ + unlink_chunked.h5 btree2.h5 btree2_tmp.h5 objcopy_src.h5 objcopy_dst.h5 \ + objcopy_ext.dat trefer1.h5 trefer2.h5 app_ref.h5 farray.h5 farray_tmp.h5 \ + earray.h5 earray_tmp.h5 efc[0-5].h5 log_vfd_out.log \ new_multi_file_v16-r.h5 new_multi_file_v16-s.h5 \ split_get_file_image_test-m.h5 split_get_file_image_test-r.h5 \ file_image_core_test.h5.copy unregister_filter_1.h5 unregister_filter_2.h5 \ diff --git a/test/btree2.c b/test/btree2.c index 8f84135..7a2432c 100644 --- a/test/btree2.c +++ b/test/btree2.c @@ -31,6 +31,7 @@ const char *FILENAME[] = { "btree2", + "btree2_tmp", NULL }; @@ -108,9 +109,8 @@ create_file(hid_t *file, H5F_t **f, hid_t fapl) STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(*f) < 0) { + if(H5AC_ignore_tags(*f) < 0) STACK_ERROR - } /* Success */ return(0); @@ -2810,9 +2810,8 @@ HDfprintf(stderr,"curr_time=%lu\n",(unsigned long)curr_time); STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(f) < 0) { + if(H5AC_ignore_tags(f) < 0) STACK_ERROR - } /* Create the v2 B-tree & get its address */ if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0) @@ -2849,9 +2848,8 @@ HDfprintf(stderr,"curr_time=%lu\n",(unsigned long)curr_time); FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(f) < 0) { + if(H5AC_ignore_tags(f) < 0) STACK_ERROR - } /* Re-open v2 B-tree */ if(NULL == (bt2 = H5B2_open(f, dxpl, bt2_addr, f))) @@ -4909,7 +4907,7 @@ test_remove_level1_collapse(hid_t fapl, const H5B2_create_t *cparam, /* Check record values in root of B-tree */ ninfo.depth = 0; - ninfo.nrec = INSERT_SPLIT_ROOT_NREC - u; + ninfo.nrec = (uint16_t)(INSERT_SPLIT_ROOT_NREC - u); record = 31; /* Middle record in root node */ if(check_node_info(bt2, dxpl, record, &ninfo) < 0) TEST_ERROR @@ -6379,9 +6377,8 @@ gen_l4_btree2(const char *filename, hid_t fapl, const H5B2_create_t *cparam, STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(f) < 0) { + if(H5AC_ignore_tags(f) < 0) STACK_ERROR - } /* Create the v2 B-tree & get its address */ if(create_btree(f, dxpl, cparam, &bt2, bt2_addr) < 0) @@ -6535,9 +6532,8 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time); FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(f) < 0) { + if(H5AC_ignore_tags(f) < 0) STACK_ERROR - } /* Re-shuffle record #'s */ for(u = 0; u < INSERT_MANY; u++) { @@ -6631,9 +6627,8 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time); FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(f) < 0) { + if(H5AC_ignore_tags(f) < 0) STACK_ERROR - } /* Re-open v2 B-tree */ if(NULL == (bt2 = H5B2_open(f, dxpl, bt2_addr, f))) @@ -6720,9 +6715,8 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time); FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(f) < 0) { + if(H5AC_ignore_tags(f) < 0) STACK_ERROR - } /* Re-open v2 B-tree */ if(NULL == (bt2 = H5B2_open(f, dxpl, bt2_addr, f))) @@ -6806,9 +6800,8 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time); FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(f) < 0) { + if(H5AC_ignore_tags(f) < 0) STACK_ERROR - } /* Re-open v2 B-tree */ if(NULL == (bt2 = H5B2_open(f, dxpl, bt2_addr, f))) @@ -7157,9 +7150,8 @@ test_delete(hid_t fapl, const H5B2_create_t *cparam) STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(f) < 0) { + if(H5AC_ignore_tags(f) < 0) STACK_ERROR - } /* Create the v2 B-tree & get its address */ if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0) @@ -7202,9 +7194,8 @@ test_delete(hid_t fapl, const H5B2_create_t *cparam) STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(f) < 0) { + if(H5AC_ignore_tags(f) < 0) STACK_ERROR - } /* Create the v2 B-tree & get its address */ if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0) @@ -7260,9 +7251,8 @@ test_delete(hid_t fapl, const H5B2_create_t *cparam) STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(f) < 0) { + if(H5AC_ignore_tags(f) < 0) STACK_ERROR - } /* Create the v2 B-tree & get its address */ if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0) @@ -7318,9 +7308,8 @@ test_delete(hid_t fapl, const H5B2_create_t *cparam) STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(f) < 0) { + if(H5AC_ignore_tags(f) < 0) STACK_ERROR - } /* Create the v2 B-tree & get its address */ if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0) @@ -7605,6 +7594,146 @@ error: /*------------------------------------------------------------------------- + * Function: test_open_twice_diff + * + * Purpose: Open a v2 B-tree twice, through different "top" file + * handles, with an intermediate file open that takes the "shared" + * file handle from the first B-tree's file pointer. + * + * Return: Success: 0 + * Failure: 1 + * + * Programmer: Quincey Koziol + * Friday, December 18, 2015 + * + *------------------------------------------------------------------------- + */ +static unsigned +test_open_twice_diff(hid_t fapl, const H5B2_create_t *cparam) +{ + char filename[1024]; /* Filename to use */ + char filename_tmp[1024]; /* Temporary file name */ + hid_t file = -1; /* File ID */ + hid_t file2 = -1; /* File ID */ + hid_t file0 = -1; /* File ID */ + hid_t file00 = -1; /* File ID */ + H5F_t *f = NULL; /* Internal file object pointer */ + H5F_t *f2 = NULL; /* Internal file object pointer */ + hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ + H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ + H5B2_t *bt2_2 = NULL; /* Second v2 B-tree wrapper */ + haddr_t bt2_addr; /* Address of B-tree created */ + + h5_fixname(FILENAME[0], fapl, filename, sizeof filename); + + /* + * Display testing message + */ + TESTING("open B-tree twice, through different file handles"); + + /* Create the file to work on */ + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR + + /* Get a pointer to the internal file object */ + if(NULL == (f = (H5F_t *)H5I_object(file))) + FAIL_STACK_ERROR + + /* Ignore metadata tags in the file's cache */ + if(H5AC_ignore_tags(f) < 0) + FAIL_STACK_ERROR + + /* Create the v2 B-tree & get its address */ + if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0) + TEST_ERROR + + /* Re-open v2 B-tree */ + if(NULL == (bt2_2 = H5B2_open(f, dxpl, bt2_addr, f))) + FAIL_STACK_ERROR + + /* Close the second v2 B-tree wrapper */ + if(H5B2_close(bt2_2, dxpl) < 0) + FAIL_STACK_ERROR + bt2_2 = NULL; + + /* Re-open the file */ + /* (So that there is something holding the file open when the extensible + * array is closed) + */ + if((file0 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR + + /* Close the first v2 B-tree wrapper */ + if(H5B2_close(bt2, dxpl) < 0) + FAIL_STACK_ERROR + bt2 = NULL; + + /* Close the file */ + /* (close before second file, to detect error on internal B-tree header's + * shared file information) + */ + if(H5Fclose(file) < 0) + FAIL_STACK_ERROR + file = -1; + + /* Open a different file */ + /* (This re-allocates the 'top' file pointer and assigns it a different + * 'shared' file pointer, making the file pointer in the fixed array's + * header stale) + */ + h5_fixname(FILENAME[1], fapl, filename_tmp, sizeof(filename_tmp)); + if((file00 = H5Fcreate(filename_tmp, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR + + /* Re-open the file with the v2 B-tree array */ + if((file2 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR + + /* Get a pointer to the internal file object */ + if(NULL == (f2 = (H5F_t *)H5I_object(file2))) + FAIL_STACK_ERROR + + /* Open the B-tree through the second file handle */ + if(NULL == (bt2_2 = H5B2_open(f2, dxpl, bt2_addr, f2))) + FAIL_STACK_ERROR + + /* Close the extra file handles */ + if(H5Fclose(file0) < 0) + FAIL_STACK_ERROR + if(H5Fclose(file00) < 0) + FAIL_STACK_ERROR + + /* Close the second v2 B-tree */ + if(H5B2_close(bt2_2, dxpl) < 0) + FAIL_STACK_ERROR + bt2_2 = NULL; + + /* Close file */ + if(H5Fclose(file2) < 0) + FAIL_STACK_ERROR + + /* All tests passed */ + PASSED(); + + /* All tests passed */ + return(0); + +error: + H5E_BEGIN_TRY { + if(bt2) + H5B2_close(bt2, dxpl); + if(bt2) + H5B2_close(bt2_2, dxpl); + H5Fclose(file); + H5Fclose(file2); + H5Fclose(file0); + H5Fclose(file00); + } H5E_END_TRY; + return(1); +} /* test_open_twice_diff() */ + + +/*------------------------------------------------------------------------- * Function: main * * Purpose: Test the B-tree v2 code @@ -7712,6 +7841,9 @@ main(void) nerrors += test_modify(fapl, &cparam, &tparam); } /* end for */ + /* Test opening B-trees twice */ + nerrors += test_open_twice_diff(fapl, &cparam); + /* Verify symbol table messages are cached */ nerrors += (h5_verify_cached_stabs(FILENAME, fapl) < 0 ? 1 : 0); diff --git a/test/dsets.c b/test/dsets.c index c0e8702..a9cda93 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -388,14 +388,14 @@ test_create(hid_t file) static herr_t test_simple_io(const char *env_h5_drvr, hid_t fapl) { - char filename[FILENAME_BUF_SIZE]; - hid_t file = -1, dataset = -1, space = -1, xfer = -1; - int i, j, n; - hsize_t dims[2]; - void *tconv_buf = NULL; - int f = -1; - haddr_t offset; - int rdata[DSET_DIM1][DSET_DIM2]; + char filename[FILENAME_BUF_SIZE]; + hid_t file = -1, dataset = -1, space = -1, xfer = -1; + int i, j, n; + hsize_t dims[2]; + void *tconv_buf = NULL; + int f = -1; + haddr_t offset; + int rdata[DSET_DIM1][DSET_DIM2]; TESTING("simple I/O"); @@ -465,7 +465,8 @@ test_simple_io(const char *env_h5_drvr, hid_t fapl) f = HDopen(filename, O_RDONLY, 0); HDlseek(f, (off_t)offset, SEEK_SET); - HDread(f, rdata, sizeof(int)*DSET_DIM1*DSET_DIM2); + if(HDread(f, rdata, sizeof(int)*DSET_DIM1*DSET_DIM2) < 0) + goto error; /* Check that the values read are the same as the values written */ for(i = 0; i < DSET_DIM1; i++) { @@ -6702,7 +6703,7 @@ test_random_chunks(hid_t fapl) if(H5Fclose(file) < 0) TEST_ERROR; - /* Create file for second test */ + /* Create second file */ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR; /* Create dataspace with unlimited maximum dimensions */ @@ -7474,7 +7475,7 @@ test_big_chunks_bypass_cache(hid_t fapl) if(H5Dread(dsid, H5T_NATIVE_INT, H5S_ALL, sid, H5P_DEFAULT, rdata2) < 0) for(i = 0; i < BYPASS_CHUNK_DIM / 2; i++) - if(rdata2[i] != i) { + if(rdata2[i] != i) { printf(" Read different values than written in the chunk.\n"); printf(" At line %d and index %d, rdata2 = %d. It should be %d.\n", __LINE__, i, rdata2[i], i); TEST_ERROR @@ -9145,38 +9146,38 @@ main(void) nerrors += (test_simple_io(envval, my_fapl) < 0 ? 1 : 0); nerrors += (test_compact_io(my_fapl) < 0 ? 1 : 0); nerrors += (test_max_compact(my_fapl) < 0 ? 1 : 0); - nerrors += (test_conv_buffer(file) < 0 ? 1 : 0); + nerrors += (test_conv_buffer(file) < 0 ? 1 : 0); nerrors += (test_tconv(file) < 0 ? 1 : 0); nerrors += (test_filters(file, my_fapl) < 0 ? 1 : 0); nerrors += (test_onebyte_shuffle(file) < 0 ? 1 : 0); - nerrors += (test_nbit_int(file) < 0 ? 1 : 0); - nerrors += (test_nbit_float(file) < 0 ? 1 : 0); - nerrors += (test_nbit_double(file) < 0 ? 1 : 0); - nerrors += (test_nbit_array(file) < 0 ? 1 : 0); + nerrors += (test_nbit_int(file) < 0 ? 1 : 0); + nerrors += (test_nbit_float(file) < 0 ? 1 : 0); + nerrors += (test_nbit_double(file) < 0 ? 1 : 0); + nerrors += (test_nbit_array(file) < 0 ? 1 : 0); nerrors += (test_nbit_compound(file) < 0 ? 1 : 0); nerrors += (test_nbit_compound_2(file) < 0 ? 1 : 0); nerrors += (test_nbit_compound_3(file) < 0 ? 1 : 0); nerrors += (test_nbit_int_size(file) < 0 ? 1 : 0); nerrors += (test_nbit_flt_size(file) < 0 ? 1 : 0); nerrors += (test_scaleoffset_int(file) < 0 ? 1 : 0); - nerrors += (test_scaleoffset_int_2(file) < 0 ? 1 : 0); - nerrors += (test_scaleoffset_float(file) < 0 ? 1 : 0); - nerrors += (test_scaleoffset_float_2(file) < 0 ? 1 : 0); - nerrors += (test_scaleoffset_double(file) < 0 ? 1 : 0); + nerrors += (test_scaleoffset_int_2(file) < 0 ? 1 : 0); + nerrors += (test_scaleoffset_float(file) < 0 ? 1 : 0); + nerrors += (test_scaleoffset_float_2(file) < 0 ? 1 : 0); + nerrors += (test_scaleoffset_double(file) < 0 ? 1 : 0); nerrors += (test_scaleoffset_double_2(file) < 0 ? 1 : 0); - nerrors += (test_multiopen (file) < 0 ? 1 : 0); - nerrors += (test_types(file) < 0 ? 1 : 0); - nerrors += (test_userblock_offset(envval, my_fapl) < 0 ? 1 : 0); + nerrors += (test_multiopen (file) < 0 ? 1 : 0); + nerrors += (test_types(file) < 0 ? 1 : 0); + nerrors += (test_userblock_offset(envval, my_fapl) < 0 ? 1 : 0); nerrors += (test_missing_filter(file) < 0 ? 1 : 0); - nerrors += (test_can_apply(file) < 0 ? 1 : 0); - nerrors += (test_can_apply2(file) < 0 ? 1 : 0); - nerrors += (test_set_local(my_fapl) < 0 ? 1 : 0); + nerrors += (test_can_apply(file) < 0 ? 1 : 0); + nerrors += (test_can_apply2(file) < 0 ? 1 : 0); + nerrors += (test_set_local(my_fapl) < 0 ? 1 : 0); nerrors += (test_can_apply_szip(file) < 0 ? 1 : 0); - nerrors += (test_compare_dcpl(file) < 0 ? 1 : 0); - nerrors += (test_copy_dcpl(file, my_fapl) < 0 ? 1 : 0); + nerrors += (test_compare_dcpl(file) < 0 ? 1 : 0); + nerrors += (test_copy_dcpl(file, my_fapl) < 0 ? 1 : 0); nerrors += (test_filter_delete(file) < 0 ? 1 : 0); - nerrors += (test_filters_endianess() < 0 ? 1 : 0); - nerrors += (test_zero_dims(file) < 0 ? 1 : 0); + nerrors += (test_filters_endianess() < 0 ? 1 : 0); + nerrors += (test_zero_dims(file) < 0 ? 1 : 0); nerrors += (test_missing_chunk(file) < 0 ? 1 : 0); nerrors += (test_random_chunks(my_fapl) < 0 ? 1 : 0); #ifndef H5_NO_DEPRECATED_SYMBOLS @@ -9186,9 +9187,9 @@ main(void) nerrors += (test_chunk_cache(my_fapl) < 0 ? 1 : 0); nerrors += (test_big_chunks_bypass_cache(my_fapl) < 0 ? 1 : 0); nerrors += (test_chunk_expand(my_fapl) < 0 ? 1 : 0); - nerrors += (test_layout_extend(my_fapl) < 0 ? 1 : 0); - nerrors += (test_large_chunk_shrink(my_fapl) < 0 ? 1 : 0); - nerrors += (test_zero_dim_dset(my_fapl) < 0 ? 1 : 0); + nerrors += (test_layout_extend(my_fapl) < 0 ? 1 : 0); + nerrors += (test_large_chunk_shrink(my_fapl) < 0 ? 1 : 0); + nerrors += (test_zero_dim_dset(my_fapl) < 0 ? 1 : 0); if(H5Fclose(file) < 0) goto error; diff --git a/test/earray.c b/test/earray.c index 368ee42..95733e9 100644 --- a/test/earray.c +++ b/test/earray.c @@ -185,6 +185,7 @@ static herr_t earray_cache_test_free_icr(void *thing); /* Local variables */ const char *FILENAME[] = { "earray", + "earray_tmp", NULL }; @@ -332,10 +333,10 @@ finish_tparam(earray_test_param_t *tparam) *------------------------------------------------------------------------- */ static int -create_file(hid_t fapl, hid_t *file, H5F_t **f) +create_file(unsigned flags, hid_t fapl, hid_t *file, H5F_t **f) { /* Create the file to work on */ - if((*file = H5Fcreate(filename_g, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if((*file = H5Fcreate(filename_g, flags, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ @@ -343,9 +344,8 @@ create_file(hid_t fapl, hid_t *file, H5F_t **f) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(*f) < 0) { + if(H5AC_ignore_tags(*f) < 0) FAIL_STACK_ERROR - } /* Success */ return(0); @@ -454,17 +454,19 @@ reopen_file(hid_t *file, H5F_t **f, hid_t fapl, hid_t dxpl, /* (actually will close & re-open the file as well) */ if(tparam->reopen_array) { /* Close array, if given */ - if(ea) { + if(ea && *ea) { if(H5EA_close(*ea, dxpl) < 0) FAIL_STACK_ERROR *ea = NULL; } /* end if */ /* Close file */ - if(H5Fclose(*file) < 0) - FAIL_STACK_ERROR - *file = (-1); - *f = NULL; + if(*file) { + if(H5Fclose(*file) < 0) + FAIL_STACK_ERROR + *file = (-1); + *f = NULL; + } /* end if */ /* Re-open the file */ if((*file = H5Fopen(filename_g, H5F_ACC_RDWR, fapl)) < 0) @@ -475,15 +477,13 @@ reopen_file(hid_t *file, H5F_t **f, hid_t fapl, hid_t dxpl, FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(*f) < 0) { + if(H5AC_ignore_tags(*f) < 0) FAIL_STACK_ERROR - } /* Re-open array, if given */ - if(ea) { + if(ea) if(NULL == (*ea = H5EA_open(*f, dxpl, ea_addr, NULL))) FAIL_STACK_ERROR - } /* end if */ } /* end if */ /* Success */ @@ -893,7 +893,7 @@ test_create(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t H5_ATTR_UNUSE haddr_t ea_addr = HADDR_UNDEF; /* Array address in file */ /* Create file & retrieve pointer to internal file object */ - if(create_file(fapl, &file, &f) < 0) + if(create_file(H5F_ACC_TRUNC, fapl, &file, &f) < 0) TEST_ERROR /* @@ -1008,7 +1008,7 @@ test_create(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t H5_ATTR_UNUSE /* Set invalid max. # of elements per data block page bits */ if(test_cparam.idx_blk_elmts > 0) { HDmemcpy(&test_cparam, cparam, sizeof(test_cparam)); - test_cparam.max_dblk_page_nelmts_bits = H5VM_log2_gen((uint64_t)test_cparam.idx_blk_elmts) - 1; + test_cparam.max_dblk_page_nelmts_bits = (uint8_t)(H5VM_log2_gen((uint64_t)test_cparam.idx_blk_elmts) - 1); H5E_BEGIN_TRY { ea = H5EA_create(f, H5P_DATASET_XFER_DEFAULT, &test_cparam, NULL); } H5E_END_TRY; @@ -1035,7 +1035,7 @@ test_create(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t H5_ATTR_UNUSE TEST_ERROR } /* end if */ HDmemcpy(&test_cparam, cparam, sizeof(test_cparam)); - test_cparam.max_dblk_page_nelmts_bits = test_cparam.max_nelmts_bits + 1; + test_cparam.max_dblk_page_nelmts_bits = (uint8_t)(test_cparam.max_nelmts_bits + 1); H5E_BEGIN_TRY { ea = H5EA_create(f, H5P_DATASET_XFER_DEFAULT, &test_cparam, NULL); } H5E_END_TRY; @@ -1115,7 +1115,7 @@ test_reopen(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam) haddr_t ea_addr = HADDR_UNDEF; /* Array address in file */ /* Create file & retrieve pointer to internal file object */ - if(create_file(fapl, &file, &f) < 0) + if(create_file(H5F_ACC_TRUNC, fapl, &file, &f) < 0) TEST_ERROR /* @@ -1188,7 +1188,7 @@ test_open_twice(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam) haddr_t ea_addr = HADDR_UNDEF; /* Array address in file */ /* Create file & retrieve pointer to internal file object */ - if(create_file(fapl, &file, &f) < 0) + if(create_file(H5F_ACC_TRUNC, fapl, &file, &f) < 0) TEST_ERROR /* @@ -1271,6 +1271,148 @@ error: /*------------------------------------------------------------------------- + * Function: test_open_twice_diff + * + * Purpose: Open an extensible array twice, through different "top" file + * handles, with an intermediate file open that takes the "shared" + * file handle from the first extensible array's file pointer. + * + * Return: Success: 0 + * Failure: 1 + * + * Programmer: Quincey Koziol + * Friday, December 18, 2015 + * + *------------------------------------------------------------------------- + */ +static unsigned +test_open_twice_diff(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam) +{ + char filename_tmp[EARRAY_FILENAME_LEN]; /* Temporary file name */ + hid_t file = -1; /* File ID */ + hid_t file2 = -1; /* File ID */ + hid_t file0 = -1; /* File ID */ + hid_t file00 = -1; /* File ID */ + H5F_t *f = NULL; /* Internal file object pointer */ + H5F_t *f2 = NULL; /* Internal file object pointer */ + H5EA_t *ea = NULL; /* Extensible array wrapper */ + H5EA_t *ea2 = NULL; /* Extensible array wrapper */ + haddr_t ea_addr = HADDR_UNDEF; /* Array address in file */ + + /* Create file & retrieve pointer to internal file object */ + if(create_file(H5F_ACC_TRUNC, fapl, &file, &f) < 0) + TEST_ERROR + + /* + * Display testing message + */ + TESTING("open extensible array twice, through different file handles"); + + /* Create array */ + if(create_array(f, H5P_DATASET_XFER_DEFAULT, cparam, &ea, &ea_addr, NULL) < 0) + TEST_ERROR + + /* Open the array again, through the first file handle */ + if(NULL == (ea2 = H5EA_open(f, H5P_DATASET_XFER_DEFAULT, ea_addr, NULL))) + FAIL_STACK_ERROR + + /* Verify the creation parameters */ + if(verify_cparam(ea, cparam) < 0) + TEST_ERROR + if(verify_cparam(ea2, cparam) < 0) + TEST_ERROR + + /* Close the second extensible array wrapper */ + if(H5EA_close(ea2, H5P_DATASET_XFER_DEFAULT) < 0) + FAIL_STACK_ERROR + ea2 = NULL; + + /* Re-open the file */ + /* (So that there is something holding the file open when the extensible + * array is closed) + */ + if((file0 = H5Fopen(filename_g, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR + + /* Check for closing & re-opening the file */ + if(reopen_file(&file, &f, fapl, H5P_DATASET_XFER_DEFAULT, &ea, ea_addr, tparam) < 0) + TEST_ERROR + + /* Verify the creation parameters */ + if(verify_cparam(ea, cparam) < 0) + TEST_ERROR + + /* Close the first extensible array wrapper */ + if(H5EA_close(ea, H5P_DATASET_XFER_DEFAULT) < 0) + FAIL_STACK_ERROR + ea = NULL; + + /* Close the first file */ + /* (close before second file, to detect error on internal array header's + * shared file information) + */ + if(H5Fclose(file) < 0) + FAIL_STACK_ERROR + file = -1; + + /* Open a different file */ + /* (This re-allocates the 'top' file pointer and assigns it a different + * 'shared' file pointer, making the file pointer in the extensible array's + * header stale) + */ + h5_fixname(FILENAME[1], fapl, filename_tmp, sizeof(filename_tmp)); + if((file00 = H5Fcreate(filename_tmp, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR + + + /* Re-open the file with the extensible array */ + if((file2 = H5Fopen(filename_g, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR + + /* Get a pointer to the internal file object */ + if(NULL == (f2 = (H5F_t *)H5I_object(file2))) + FAIL_STACK_ERROR + + /* Open the extensible array through the second file handle */ + if(NULL == (ea2 = H5EA_open(f2, H5P_DATASET_XFER_DEFAULT, ea_addr, NULL))) + FAIL_STACK_ERROR + + /* Verify the creation parameters */ + if(verify_cparam(ea2, cparam) < 0) + TEST_ERROR + + /* Close the extra file handles */ + if(H5Fclose(file0) < 0) + FAIL_STACK_ERROR + if(H5Fclose(file00) < 0) + FAIL_STACK_ERROR + + /* Close array, delete array, close file & verify file is empty */ + if(finish(file2, fapl, f2, ea2, ea_addr) < 0) + TEST_ERROR + + /* All tests passed */ + PASSED() + + return 0; + +error: + H5E_BEGIN_TRY { + if(ea) + H5EA_close(ea, H5P_DATASET_XFER_DEFAULT); + if(ea2) + H5EA_close(ea2, H5P_DATASET_XFER_DEFAULT); + H5Fclose(file); + H5Fclose(file2); + H5Fclose(file0); + H5Fclose(file00); + } H5E_END_TRY; + + return 1; +} /* test_open_twice_diff() */ + + +/*------------------------------------------------------------------------- * Function: test_delete_open * * Purpose: Delete opened extensible array (& open deleted array) @@ -1294,7 +1436,7 @@ test_delete_open(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam) h5_stat_size_t file_size; /* File size, after deleting array */ /* Create file & retrieve pointer to internal file object */ - if(create_file(fapl, &file, &f) < 0) + if(create_file(H5F_ACC_TRUNC, fapl, &file, &f) < 0) TEST_ERROR /* @@ -1483,7 +1625,7 @@ test_flush_depend(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t H5_ATTR hsize_t idx; /* Index value of element */ /* Create file & retrieve pointer to internal file object */ - if(create_file(fapl, &file, &f) < 0) + if(create_file(H5F_ACC_TRUNC, fapl, &file, &f) < 0) TEST_ERROR /* @@ -1758,7 +1900,7 @@ eiter_fw_next(void *_eiter) * *------------------------------------------------------------------------- */ -static hssize_t +static H5_ATTR_PURE hssize_t eiter_fw_max(const void *_eiter) { const eiter_fw_t *eiter = (const eiter_fw_t *)_eiter; @@ -1976,7 +2118,7 @@ eiter_rv_next(void *_eiter) * *------------------------------------------------------------------------- */ -static hssize_t +static H5_ATTR_PURE hssize_t eiter_rv_max(const void *_eiter) { const eiter_rv_t *eiter = (const eiter_rv_t *)_eiter; @@ -2228,7 +2370,7 @@ eiter_rnd_next(void *_eiter) * *------------------------------------------------------------------------- */ -static hssize_t +static H5_ATTR_PURE hssize_t eiter_rnd_max(const void *_eiter) { const eiter_rnd_t *eiter = (const eiter_rnd_t *)_eiter; @@ -2449,7 +2591,7 @@ eiter_cyc_next(void *_eiter) * *------------------------------------------------------------------------- */ -static hssize_t +static H5_ATTR_PURE hssize_t eiter_cyc_max(const void *_eiter) { const eiter_cyc_t *eiter = (const eiter_cyc_t *)_eiter; @@ -2537,7 +2679,7 @@ test_set_elmts(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam, TESTING(test_str); /* Create file & retrieve pointer to internal file object */ - if(create_file(fapl, &file, &f) < 0) + if(create_file(H5F_ACC_TRUNC, fapl, &file, &f) < 0) TEST_ERROR /* Create array */ @@ -2711,7 +2853,7 @@ test_skip_elmts(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam, TESTING(test_str); /* Create file & retrieve pointer to internal file object */ - if(create_file(fapl, &file, &f) < 0) + if(create_file(H5F_ACC_TRUNC, fapl, &file, &f) < 0) TEST_ERROR /* Create array */ @@ -2871,7 +3013,7 @@ main(void) /* Seed random #'s */ curr_time = HDtime(NULL); - HDsrandom((unsigned long)curr_time); + HDsrandom((unsigned)curr_time); /* Create an empty file to retrieve size */ { @@ -2922,6 +3064,7 @@ main(void) nerrors += test_create(fapl, &cparam, &tparam); nerrors += test_reopen(fapl, &cparam, &tparam); nerrors += test_open_twice(fapl, &cparam, &tparam); + nerrors += test_open_twice_diff(fapl, &cparam, &tparam); nerrors += test_delete_open(fapl, &cparam, &tparam); nerrors += test_flush_depend(fapl, &cparam, &tparam); diff --git a/test/farray.c b/test/farray.c index e3e59da..50a9856 100644 --- a/test/farray.c +++ b/test/farray.c @@ -102,6 +102,7 @@ struct farray_test_param_t { /* Local variables */ const char *FILENAME[] = { "farray", + "farray_tmp", NULL }; @@ -159,9 +160,8 @@ create_file(hid_t fapl, hid_t *file, H5F_t **f) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(*f) < 0) { + if(H5AC_ignore_tags(*f) < 0) FAIL_STACK_ERROR - } /* Success */ return(0); @@ -274,17 +274,19 @@ reopen_file(hid_t *file, H5F_t **f, hid_t fapl, hid_t dxpl, /* (actually will close & re-open the file as well) */ if(tparam->reopen_array) { /* Close array, if given */ - if(fa) { + if(fa && *fa) { if(H5FA_close(*fa, dxpl) < 0) FAIL_STACK_ERROR *fa = NULL; } /* end if */ /* Close file */ - if(H5Fclose(*file) < 0) - FAIL_STACK_ERROR - *file = (-1); - *f = NULL; + if(*file) { + if(H5Fclose(*file) < 0) + FAIL_STACK_ERROR + *file = (-1); + *f = NULL; + } /* end if */ /* Re-open the file */ if((*file = H5Fopen(filename_g, H5F_ACC_RDWR, fapl)) < 0) @@ -295,15 +297,13 @@ reopen_file(hid_t *file, H5F_t **f, hid_t fapl, hid_t dxpl, FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(*f) < 0) { + if(H5AC_ignore_tags(*f) < 0) FAIL_STACK_ERROR - } /* Re-open array, if given */ - if(fa) { + if(fa) if(NULL == (*fa = H5FA_open(*f, dxpl, fa_addr, NULL))) FAIL_STACK_ERROR - } /* end if */ } /* end if */ /* Success */ @@ -722,6 +722,144 @@ error: /*------------------------------------------------------------------------- + * Function: test_open_twice_diff + * + * Purpose: Open a fixed array twice, through different "top" file + * handles, with an intermediate file open that takes the "shared" + * file handle from the first fixed array's file pointer. + * + * Return: Success: 0 + * Failure: 1 + * + * Programmer: Quincey Koziol + * Friday, December 18, 2015 + * + *------------------------------------------------------------------------- + */ +static unsigned +test_open_twice_diff(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t *tparam) +{ + char filename_tmp[FARRAY_FILENAME_LEN]; /* Temporary file name */ + hid_t file = -1; /* File ID */ + hid_t file2 = -1; /* File ID */ + hid_t file0 = -1; /* File ID */ + hid_t file00 = -1; /* File ID */ + H5F_t *f = NULL; /* Internal file object pointer */ + H5F_t *f2 = NULL; /* Internal file object pointer */ + H5FA_t *fa = NULL; /* Fixed array wrapper */ + H5FA_t *fa2 = NULL; /* Fixed array wrapper */ + haddr_t fa_addr = HADDR_UNDEF; /* Array address in file */ + + /* + * Display testing message + */ + TESTING("open fixed array twice, through different file handles"); + + /* Create file & retrieve pointer to internal file object */ + if(create_file(fapl, &file, &f) < 0) + TEST_ERROR + + /* Create array */ + if(create_array(f, H5P_DATASET_XFER_DEFAULT, cparam, &fa, &fa_addr) < 0) + TEST_ERROR + + /* Open the array again, through the first file handle */ + if(NULL == (fa2 = H5FA_open(f, H5P_DATASET_XFER_DEFAULT, fa_addr, NULL))) + FAIL_STACK_ERROR + + /* Verify the creation parameters */ + if(verify_cparam(fa, cparam) < 0) + TEST_ERROR + if(verify_cparam(fa2, cparam) < 0) + TEST_ERROR + + /* Close the second fixed array wrapper */ + if(H5FA_close(fa2, H5P_DATASET_XFER_DEFAULT) < 0) + FAIL_STACK_ERROR + fa2 = NULL; + + /* Re-open the file */ + /* (So that there is something holding the file open when the extensible + * array is closed) + */ + if((file0 = H5Fopen(filename_g, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR + + /* Check for closing & re-opening the file */ + if(reopen_file(&file, &f, fapl, H5P_DATASET_XFER_DEFAULT, &fa, fa_addr, tparam) < 0) + TEST_ERROR + + /* Close the first fixed array wrapper */ + if(H5FA_close(fa, H5P_DATASET_XFER_DEFAULT) < 0) + FAIL_STACK_ERROR + fa = NULL; + + /* Close the first file */ + /* (close before second file, to detect error on internal array header's + * shared file information) + */ + if(H5Fclose(file) < 0) + FAIL_STACK_ERROR + file = -1; + + /* Open a different file */ + /* (This re-allocates the 'top' file pointer and assigns it a different + * 'shared' file pointer, making the file pointer in the fixed array's + * header stale) + */ + h5_fixname(FILENAME[1], fapl, filename_tmp, sizeof(filename_tmp)); + if((file00 = H5Fcreate(filename_tmp, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR + + + /* Re-open the file with the fixed array */ + if((file2 = H5Fopen(filename_g, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR + + /* Get a pointer to the internal file object */ + if(NULL == (f2 = (H5F_t *)H5I_object(file2))) + FAIL_STACK_ERROR + + /* Open the fixed array through the second file handle */ + if(NULL == (fa2 = H5FA_open(f2, H5P_DATASET_XFER_DEFAULT, fa_addr, NULL))) + FAIL_STACK_ERROR + + /* Verify the creation parameters */ + if(verify_cparam(fa2, cparam) < 0) + TEST_ERROR + + /* Close the extra file handles */ + if(H5Fclose(file0) < 0) + FAIL_STACK_ERROR + if(H5Fclose(file00) < 0) + FAIL_STACK_ERROR + + /* Close array, delete array, close file & verify file is empty */ + if(finish(file2, fapl, f2, fa2, fa_addr) < 0) + TEST_ERROR + + /* All tests passed */ + PASSED() + + return 0; + +error: + H5E_BEGIN_TRY { + if(fa) + H5FA_close(fa, H5P_DATASET_XFER_DEFAULT); + if(fa2) + H5FA_close(fa2, H5P_DATASET_XFER_DEFAULT); + H5Fclose(file); + H5Fclose(file2); + H5Fclose(file0); + H5Fclose(file00); + } H5E_END_TRY; + + return 1; +} /* test_open_twice_diff() */ + + +/*------------------------------------------------------------------------- * Function: test_delete_open * * Purpose: Delete opened fixed array (& open deleted array) @@ -1535,7 +1673,7 @@ main(void) /* Seed random #'s */ curr_time = HDtime(NULL); - HDsrandom((unsigned long)curr_time); + HDsrandom((unsigned)curr_time); /* Create an empty file to retrieve size */ { @@ -1586,6 +1724,7 @@ main(void) nerrors += test_create(fapl, &cparam, &tparam); nerrors += test_reopen(fapl, &cparam, &tparam); nerrors += test_open_twice(fapl, &cparam, &tparam); + nerrors += test_open_twice_diff(fapl, &cparam, &tparam); nerrors += test_delete_open(fapl, &cparam, &tparam); /* Iterate over the type of capacity tests */ |