summaryrefslogtreecommitdiffstats
path: root/src/H5HFhdr.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2009-10-29 14:54:08 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2009-10-29 14:54:08 (GMT)
commitac0778592ae832ccd2b3ec4a6ed62d5340d8ea2a (patch)
tree54c6ad6ea49eb560abfa7cdd3e105426b184bf4b /src/H5HFhdr.c
parent7abd8c4d3003d56f6564a79dd0eaa4d97604a769 (diff)
downloadhdf5-ac0778592ae832ccd2b3ec4a6ed62d5340d8ea2a.zip
hdf5-ac0778592ae832ccd2b3ec4a6ed62d5340d8ea2a.tar.gz
hdf5-ac0778592ae832ccd2b3ec4a6ed62d5340d8ea2a.tar.bz2
[svn-r17786] Description:
Bring r17749 & 17785 from trunk to 1.8 branch: 17749: Refactor v2 B-tree code to bring it further in line with how the fractal heap code works, to make forthcoming modificaions easier. Also minor tweaks to the fractal heap code to clean it up a bit more also. 17785: Further refactor v2 B-tree code to bring it closer to modern data structure designed in the library, mainly by introducing a H5B2_t type so that the v2 B-tree could be held open, but not require the B-tree header to be protected the whole time. A few other minor tweaks as well. Also, remove unused 'dirty' flag from fractal heap header. Tested on: FreeBSD/32 6.3 (duty) in debug mode FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x, w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64-amd64 2.6 (smirom) w/Intel compilers, w/default API=1.6.x, w/C++ & FORTRAN, in production mode Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN, w/szip filter, in production mode Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN, in production mode Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in debug mode Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode Mac OS X/32 10.6.1 (amazon) in debug mode Mac OS X/32 10.6.1 (amazon) w/C++ & FORTRAN, w/threadsafe, in production mode
Diffstat (limited to 'src/H5HFhdr.c')
-rw-r--r--src/H5HFhdr.c69
1 files changed, 50 insertions, 19 deletions
diff --git a/src/H5HFhdr.c b/src/H5HFhdr.c
index d1f2675..c7dada2 100644
--- a/src/H5HFhdr.c
+++ b/src/H5HFhdr.c
@@ -79,7 +79,7 @@
/*********************/
/* Declare a free list to manage the H5HF_hdr_t struct */
-H5FL_DEFINE(H5HF_hdr_t);
+H5FL_DEFINE_STATIC(H5HF_hdr_t);
/*****************************/
@@ -110,7 +110,7 @@ H5HF_hdr_t *
H5HF_hdr_alloc(H5F_t *f)
{
H5HF_hdr_t *hdr = NULL; /* Shared fractal heap header */
- H5HF_hdr_t *ret_value = NULL; /* Return value */
+ H5HF_hdr_t *ret_value; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5HF_hdr_alloc)
@@ -121,7 +121,7 @@ H5HF_hdr_alloc(H5F_t *f)
/* Allocate space for the shared information */
if(NULL == (hdr = H5FL_CALLOC(H5HF_hdr_t)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for fractal heap shared header")
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "allocation failed for fractal heap shared header")
/* Set the internal parameters for the heap */
hdr->f = f;
@@ -132,9 +132,9 @@ H5HF_hdr_alloc(H5F_t *f)
ret_value = hdr;
done:
- if(!ret_value)
- if(hdr)
- (void)H5HF_cache_hdr_dest(f, hdr);
+ if(!ret_value && hdr)
+ if(H5HF_hdr_free(hdr) < 0)
+ HDONE_ERROR(H5E_HEAP, H5E_CANTRELEASE, NULL, "unable to release fractal heap header")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HF_hdr_alloc() */
@@ -409,9 +409,6 @@ H5HF_hdr_create(H5F_t *f, hid_t dxpl_id, const H5HF_create_t *cparam)
/* Set "huge" object tracker v2 B-tree address to indicate that there aren't any yet */
hdr->huge_bt2_addr = HADDR_UNDEF;
- /* Note that the shared info is dirty (it's not written to the file yet) */
- hdr->dirty = TRUE;
-
/* First phase of header final initialization */
/* (doesn't need ID length set up) */
if(H5HF_hdr_finish_init_phase1(hdr) < 0)
@@ -457,7 +454,7 @@ HDfprintf(stderr, "%s: hdr->filter_len = %u\n", FUNC, hdr->filter_len);
*/
switch(cparam->id_len) {
case 0: /* Set the length of heap IDs to just enough to hold the offset & length of 'normal' objects in the heap */
- hdr->id_len = 1 + hdr->heap_off_size + hdr->heap_len_size;
+ hdr->id_len = (unsigned)1 + hdr->heap_off_size + hdr->heap_len_size;
break;
case 1: /* Set the length of heap IDs to just enough to hold the information needed to directly access 'huge' objects in the heap */
@@ -505,15 +502,15 @@ HDfprintf(stderr, "%s: hdr->id_len = %Zu\n", FUNC, hdr->id_len);
/* Cache the new fractal heap header */
if(H5AC_set(f, dxpl_id, H5AC_FHEAP_HDR, hdr->heap_addr, hdr, H5AC__NO_FLAGS_SET) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, HADDR_UNDEF, "can't add fractal heap header to cache")
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTINSERT, HADDR_UNDEF, "can't add fractal heap header to cache")
/* Set address of heap header to return */
ret_value = hdr->heap_addr;
done:
- if(!H5F_addr_defined(ret_value))
- if(hdr)
- (void)H5HF_cache_hdr_dest(NULL, hdr);
+ if(!H5F_addr_defined(ret_value) && hdr)
+ if(H5HF_hdr_free(hdr) < 0)
+ HDONE_ERROR(H5E_HEAP, H5E_CANTRELEASE, HADDR_UNDEF, "unable to release fractal heap header")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HF_hdr_create() */
@@ -681,9 +678,6 @@ HDfprintf(stderr, "%s: Marking heap header as dirty\n", FUNC);
if(H5AC_mark_pinned_or_protected_entry_dirty(hdr->f, hdr) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTMARKDIRTY, FAIL, "unable to mark fractal heap header as dirty")
- /* Set the dirty flags for the heap header */
- hdr->dirty = TRUE;
-
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HF_hdr_dirty() */
@@ -1493,6 +1487,43 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5HF_hdr_free
+ *
+ * Purpose: Free shared fractal heap header
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * koziol@hdfgroup.org
+ * Oct 27 2009
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5HF_hdr_free(H5HF_hdr_t *hdr)
+{
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_hdr_free)
+
+ /*
+ * Check arguments.
+ */
+ HDassert(hdr);
+
+ /* Free the block size lookup table for the doubling table */
+ H5HF_dtable_dest(&hdr->man_dtable);
+
+ /* Release any I/O pipeline filter information */
+ if(hdr->pline.nused)
+ H5O_msg_reset(H5O_PLINE_ID, &(hdr->pline));
+
+ /* Free the shared info itself */
+ hdr = H5FL_FREE(H5HF_hdr_t, hdr);
+
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* end H5HF_hdr_free() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5HF_hdr_delete
*
* Purpose: Delete a fractal heap, starting with the header
@@ -1508,8 +1539,8 @@ done:
herr_t
H5HF_hdr_delete(H5HF_hdr_t *hdr, hid_t dxpl_id)
{
- unsigned cache_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting heap header */
- herr_t ret_value = SUCCEED;
+ unsigned cache_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting heap header */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5HF_hdr_delete, FAIL)