summaryrefslogtreecommitdiffstats
path: root/src/H5B2hdr.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2015-12-19 14:42:15 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2015-12-19 14:42:15 (GMT)
commit9ceca0f89a0d27a6dfaeb3dd0cab2680281c5b60 (patch)
tree70640ab8a5ea83537c05afa0a1d4450802239c1f /src/H5B2hdr.c
parent2c55e17cfb6d396ffc33065bcba2ef8ceb7081b8 (diff)
downloadhdf5-9ceca0f89a0d27a6dfaeb3dd0cab2680281c5b60.zip
hdf5-9ceca0f89a0d27a6dfaeb3dd0cab2680281c5b60.tar.gz
hdf5-9ceca0f89a0d27a6dfaeb3dd0cab2680281c5b60.tar.bz2
[svn-r28710] Description:
Bring r28708 from revise_chunks branch: Fix earray, farray and btree2 use of incorrect file pointer when two files are opened and used to access the data structure. Misc. minor code cleanups as well. Tested on: MacOSX/64 10.11.2 (amazon) w/serial & parallel h5committest forthcoming
Diffstat (limited to 'src/H5B2hdr.c')
-rw-r--r--src/H5B2hdr.c83
1 files changed, 79 insertions, 4 deletions
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() */