summaryrefslogtreecommitdiffstats
path: root/src/H5Ochunk.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2016-11-12 09:05:47 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2016-11-12 09:05:47 (GMT)
commit1c6924f18bd8fdad63c4f191c00605092c17fa6e (patch)
treecfa3351ffe9a04b46e2ed226da6a5c00a80b4caa /src/H5Ochunk.c
parent70938cbf28ca91a17d8d975d5b5ebcd44648e1c9 (diff)
downloadhdf5-1c6924f18bd8fdad63c4f191c00605092c17fa6e.zip
hdf5-1c6924f18bd8fdad63c4f191c00605092c17fa6e.tar.gz
hdf5-1c6924f18bd8fdad63c4f191c00605092c17fa6e.tar.bz2
Refactor H5O code to clean up message allocation, align cache deserialize code
with revise_chunks changes, and remove unused "message locking" code.
Diffstat (limited to 'src/H5Ochunk.c')
-rw-r--r--src/H5Ochunk.c58
1 files changed, 49 insertions, 9 deletions
diff --git a/src/H5Ochunk.c b/src/H5Ochunk.c
index 18561b3..f6eb135 100644
--- a/src/H5Ochunk.c
+++ b/src/H5Ochunk.c
@@ -93,7 +93,8 @@ H5FL_DEFINE(H5O_chunk_proxy_t);
*-------------------------------------------------------------------------
*/
herr_t
-H5O_chunk_add(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned idx)
+H5O_chunk_add(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned idx,
+ unsigned cont_chunkno)
{
H5O_chunk_proxy_t *chk_proxy = NULL; /* Proxy for chunk, to mark it dirty in the cache */
herr_t ret_value = SUCCEED; /* Return value */
@@ -110,14 +111,16 @@ H5O_chunk_add(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned idx)
if(NULL == (chk_proxy = H5FL_CALLOC(H5O_chunk_proxy_t)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
- /* Set the values in the chunk proxy */
- chk_proxy->oh = oh;
- chk_proxy->chunkno = idx;
-
/* Increment reference count on object header */
if(H5O_inc_rc(oh) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTINC, FAIL, "can't increment reference count on object header")
+ /* Set the values in the chunk proxy */
+ chk_proxy->f = f;
+ chk_proxy->oh = oh;
+ chk_proxy->chunkno = idx;
+ chk_proxy->cont_chunkno = cont_chunkno;
+
/* Insert the chunk proxy into the cache */
if(H5AC_insert_entry(f, dxpl_id, H5AC_OHDR_CHK, oh->chunk[idx].addr, chk_proxy, H5AC__NO_FLAGS_SET) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "unable to cache object header chunk")
@@ -126,8 +129,8 @@ H5O_chunk_add(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned idx)
done:
if(ret_value < 0)
- if(chk_proxy)
- chk_proxy = H5FL_FREE(H5O_chunk_proxy_t, chk_proxy);
+ if(chk_proxy && H5O__chunk_dest(chk_proxy) < 0)
+ HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "unable to destroy object header chunk")
FUNC_LEAVE_NOAPI_TAG(ret_value, FAIL)
} /* end H5O_chunk_add() */
@@ -172,6 +175,7 @@ H5O_chunk_protect(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned idx)
HGOTO_ERROR(H5E_OHDR, H5E_CANTINC, NULL, "can't increment reference count on object header")
/* Set chunk proxy fields */
+ chk_proxy->f = f;
chk_proxy->oh = oh;
chk_proxy->chunkno = idx;
} /* end if */
@@ -200,8 +204,8 @@ H5O_chunk_protect(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned idx)
done:
/* Cleanup on error */
if(!ret_value)
- if(0 == idx && chk_proxy)
- chk_proxy = H5FL_FREE(H5O_chunk_proxy_t, chk_proxy);
+ if(0 == idx && chk_proxy && H5O__chunk_dest(chk_proxy) < 0)
+ HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, NULL, "unable to destroy object header chunk")
FUNC_LEAVE_NOAPI_TAG(ret_value, NULL)
} /* end H5O_chunk_protect() */
@@ -409,3 +413,39 @@ done:
FUNC_LEAVE_NOAPI_TAG(ret_value, FAIL)
} /* end H5O_chunk_delete() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5O__chunk_dest
+ *
+ * Purpose: Destroy a chunk proxy object
+ *
+ * Return: Success: SUCCEED
+ * Failure: FAIL
+ *
+ * Programmer: Quincey Koziol
+ * koziol@hdfgroup.org
+ * July 13, 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5O__chunk_dest(H5O_chunk_proxy_t *chk_proxy)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_PACKAGE
+
+ /* Check arguments */
+ HDassert(chk_proxy);
+
+ /* Decrement reference count of object header */
+ if(chk_proxy->oh && H5O_dec_rc(chk_proxy->oh) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTDEC, FAIL, "can't decrement reference count on object header")
+
+ /* Release the chunk proxy object */
+ chk_proxy = H5FL_FREE(H5O_chunk_proxy_t, chk_proxy);
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* H5O__chunk_dest() */
+