summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/H5B2.c30
-rw-r--r--src/H5B2dbg.c61
-rw-r--r--src/H5B2hdr.c83
-rw-r--r--src/H5B2pkg.h4
-rw-r--r--src/H5C.c93
-rw-r--r--src/H5EAhdr.c33
-rw-r--r--src/H5FAhdr.c3
7 files changed, 162 insertions, 145 deletions
diff --git a/src/H5B2.c b/src/H5B2.c
index 7eb88c4..a171917 100644
--- a/src/H5B2.c
+++ b/src/H5B2.c
@@ -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 */
diff --git a/src/H5C.c b/src/H5C.c
index 2a4b4cf..c78c32c 100644
--- a/src/H5C.c
+++ b/src/H5C.c
@@ -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