summaryrefslogtreecommitdiffstats
path: root/src/H5HL.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2004-10-12 02:21:17 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2004-10-12 02:21:17 (GMT)
commit8e8aa93d98d3786fa2347f44a7f17c8238714616 (patch)
treefba0d5159eafbc3afb7be8678c4dfaadc8075134 /src/H5HL.c
parent513cba5d86852d759026bf76ab1a1b78bc7f8e5c (diff)
downloadhdf5-8e8aa93d98d3786fa2347f44a7f17c8238714616.zip
hdf5-8e8aa93d98d3786fa2347f44a7f17c8238714616.tar.gz
hdf5-8e8aa93d98d3786fa2347f44a7f17c8238714616.tar.bz2
[svn-r9402] Purpose:
Port development branch changes to release branch. Description: Initial step in bringing changes to support new metadata cache from the development branch to the release branch. Solution: This checkin just aligns the H5AC* API changes, as well as bringing back various minor code cleanups, etc. Platforms tested: FreeBSD 4.10 (sleipnir) w/parallel Solaris 2.7 (arabica) Linux 2.4 (verbena) w/FORTRAN
Diffstat (limited to 'src/H5HL.c')
-rw-r--r--src/H5HL.c180
1 files changed, 10 insertions, 170 deletions
diff --git a/src/H5HL.c b/src/H5HL.c
index 3813efe..44976a8 100644
--- a/src/H5HL.c
+++ b/src/H5HL.c
@@ -29,6 +29,7 @@
*-------------------------------------------------------------------------
*/
#define H5F_PACKAGE /* Suppress error about including H5Fpkg */
+#define H5HL_PACKAGE /* Suppress error about including H5HLpkg */
/* Pablo information */
/* (Put before include files to avoid problems with inline functions) */
@@ -39,19 +40,12 @@
#include "H5Eprivate.h" /* Error handling */
#include "H5Fpkg.h" /* File access */
#include "H5FLprivate.h" /* Free lists */
-#include "H5HLprivate.h" /* Local Heaps */
+#include "H5HLpkg.h" /* Local Heaps */
#include "H5MFprivate.h" /* File memory management */
-#include "H5MMprivate.h" /* Memory management */
/* Private macros */
#define H5HL_FREE_NULL 1 /*end of free list on disk */
#define H5HL_MIN_HEAP 256 /* Minimum size to reduce heap buffer to */
-#define H5HL_SIZEOF_HDR(F) \
- H5HL_ALIGN(H5HL_SIZEOF_MAGIC + /*heap signature */ \
- 4 + /*reserved */ \
- H5F_SIZEOF_SIZE (F) + /*data size */ \
- H5F_SIZEOF_SIZE (F) + /*free list head */ \
- H5F_SIZEOF_ADDR (F)) /*data address */
/*
* Local heap collection version.
@@ -59,23 +53,6 @@
#define H5HL_VERSION 0
/* Private typedefs */
-typedef struct H5HL_free_t {
- size_t offset; /*offset of free block */
- size_t size; /*size of free block */
- struct H5HL_free_t *prev; /*previous entry in free list */
- struct H5HL_free_t *next; /*next entry in free list */
-} H5HL_free_t;
-
-struct H5HL_t {
- H5AC_info_t cache_info; /* Information for H5AC cache functions, _must_ be */
- /* first field in structure */
- haddr_t addr; /*address of data */
- size_t disk_alloc; /*data bytes allocated on disk */
- size_t mem_alloc; /*data bytes allocated in mem */
- size_t disk_resrv; /*data bytes "reserved" on disk */
- uint8_t *chunk; /*the chunk, including header */
- H5HL_free_t *freelist; /*the free list */
-};
/* PRIVATE PROTOTYPES */
#ifdef NOT_YET
@@ -99,7 +76,7 @@ static herr_t H5HL_clear(H5HL_t *heap);
/*
* H5HL inherits cache-like properties from H5AC
*/
-static const H5AC_class_t H5AC_LHEAP[1] = {{
+const H5AC_class_t H5AC_LHEAP[1] = {{
H5AC_LHEAP_ID,
(H5AC_load_func_t)H5HL_load,
(H5AC_flush_func_t)H5HL_flush,
@@ -737,7 +714,7 @@ H5HL_read(H5F_t *f, hid_t dxpl_id, haddr_t addr, size_t offset, size_t size, voi
assert(f);
assert (H5F_addr_defined(addr));
- if (NULL == (heap = H5AC_protect(f, dxpl_id, H5AC_LHEAP, addr, NULL, NULL)))
+ if (NULL == (heap = H5AC_protect(f, dxpl_id, H5AC_LHEAP, addr, NULL, NULL, H5AC_READ)))
HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "unable to load heap");
assert(offset < heap->mem_alloc);
@@ -803,7 +780,7 @@ H5HL_protect(H5F_t *f, hid_t dxpl_id, haddr_t addr)
assert(f);
assert(H5F_addr_defined(addr));
- if (NULL == (ret_value = H5AC_protect(f, dxpl_id, H5AC_LHEAP, addr, NULL, NULL)))
+ if (NULL == (ret_value = H5AC_protect(f, dxpl_id, H5AC_LHEAP, addr, NULL, NULL, H5AC_READ)))
HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "unable to load heap");
done:
@@ -950,7 +927,7 @@ H5HL_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr, size_t buf_size, const void *
if (0==(f->intent & H5F_ACC_RDWR))
HGOTO_ERROR (H5E_HEAP, H5E_WRITEERROR, (size_t)(-1), "no write intent on file");
- if (NULL == (heap = H5AC_protect(f, dxpl_id, H5AC_LHEAP, addr, NULL, NULL)))
+ if (NULL == (heap = H5AC_protect(f, dxpl_id, H5AC_LHEAP, addr, NULL, NULL, H5AC_WRITE)))
HGOTO_ERROR(H5E_HEAP, H5E_PROTECT, (size_t)(-1), "unable to load heap");
heap->cache_info.dirty=TRUE;
@@ -1133,7 +1110,7 @@ H5HL_write(H5F_t *f, hid_t dxpl_id, haddr_t addr, size_t offset, size_t size, co
if (0==(f->intent & H5F_ACC_RDWR))
HGOTO_ERROR (H5E_HEAP, H5E_WRITEERROR, FAIL, "no write intent on file");
- if (NULL == (heap = H5AC_protect(f, dxpl_id, H5AC_LHEAP, addr, NULL, NULL)))
+ if (NULL == (heap = H5AC_protect(f, dxpl_id, H5AC_LHEAP, addr, NULL, NULL, H5AC_WRITE)))
HGOTO_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to load heap");
assert(offset < heap->mem_alloc);
@@ -1198,7 +1175,7 @@ H5HL_remove(H5F_t *f, hid_t dxpl_id, haddr_t addr, size_t offset, size_t size)
size = H5HL_ALIGN (size);
- if (NULL == (heap = H5AC_protect(f, dxpl_id, H5AC_LHEAP, addr, NULL, NULL)))
+ if (NULL == (heap = H5AC_protect(f, dxpl_id, H5AC_LHEAP, addr, NULL, NULL, H5AC_WRITE)))
HGOTO_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to load heap");
assert(offset < heap->mem_alloc);
@@ -1323,7 +1300,7 @@ H5HL_delete(H5F_t *f, hid_t dxpl_id, haddr_t addr)
sizeof_hdr= H5HL_SIZEOF_HDR(f);
/* Get heap pointer */
- if (NULL == (heap = H5AC_protect(f, dxpl_id, H5AC_LHEAP, addr, NULL, NULL)))
+ if (NULL == (heap = H5AC_protect(f, dxpl_id, H5AC_LHEAP, addr, NULL, NULL, H5AC_WRITE)))
HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load heap");
/* Check if the heap is contiguous on disk */
@@ -1354,146 +1331,9 @@ H5HL_delete(H5F_t *f, hid_t dxpl_id, haddr_t addr)
heap = NULL;
done:
- if (heap && H5AC_unprotect(f, dxpl_id, H5AC_LHEAP, addr, heap, FALSE)<0 && ret_value<0)
+ if (heap && H5AC_unprotect(f, dxpl_id, H5AC_LHEAP, addr, heap, FALSE)<0)
HDONE_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to release local heap");
FUNC_LEAVE_NOAPI(ret_value);
} /* end H5HL_delete() */
-
-/*-------------------------------------------------------------------------
- * Function: H5HL_debug
- *
- * Purpose: Prints debugging information about a heap.
- *
- * Return: Non-negative on success/Negative on failure
- *
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Aug 1 1997
- *
- * Modifications:
- * Robb Matzke, 1999-07-28
- * The ADDR argument is passed by value.
- *-------------------------------------------------------------------------
- */
-herr_t
-H5HL_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream, int indent, int fwidth)
-{
- H5HL_t *h = NULL;
- int i, j, overlap, free_block;
- uint8_t c;
- H5HL_free_t *freelist = NULL;
- uint8_t *marker = NULL;
- size_t amount_free = 0;
- herr_t ret_value=SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI(H5HL_debug, FAIL);
-
- /* check arguments */
- assert(f);
- assert(H5F_addr_defined(addr));
- assert(stream);
- assert(indent >= 0);
- assert(fwidth >= 0);
-
- if (NULL == (h = H5AC_find(f, dxpl_id, H5AC_LHEAP, addr, NULL, NULL)))
- HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load heap");
- fprintf(stream, "%*sLocal Heap...\n", indent, "");
- fprintf(stream, "%*s%-*s %d\n", indent, "", fwidth,
- "Dirty:",
- (int) (h->cache_info.dirty));
- fprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth,
- "Header size (in bytes):",
- (unsigned long) H5HL_SIZEOF_HDR(f));
- HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth,
- "Address of heap data:",
- h->addr);
- HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth,
- "Data bytes allocated on disk:",
- h->disk_alloc);
- HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth,
- "Data bytes allocated in core:",
- h->mem_alloc);
-
- /*
- * Traverse the free list and check that all free blocks fall within
- * the heap and that no two free blocks point to the same region of
- * the heap.
- */
- if (NULL==(marker = H5MM_calloc(h->mem_alloc)))
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
- fprintf(stream, "%*sFree Blocks (offset, size):\n", indent, "");
- for (free_block=0, freelist = h->freelist; freelist; freelist = freelist->next, free_block++) {
- char temp_str[32];
-
- sprintf(temp_str,"Block #%d:",free_block);
- HDfprintf(stream, "%*s%-*s %8Zu, %8Zu\n", indent+3, "", MAX(0,fwidth-9),
- temp_str,
- freelist->offset, freelist->size);
- if (freelist->offset + freelist->size > h->mem_alloc) {
- fprintf(stream, "***THAT FREE BLOCK IS OUT OF BOUNDS!\n");
- } else {
- for (i=overlap=0; i<(int)(freelist->size); i++) {
- if (marker[freelist->offset + i])
- overlap++;
- marker[freelist->offset + i] = 1;
- }
- if (overlap) {
- fprintf(stream, "***THAT FREE BLOCK OVERLAPPED A PREVIOUS "
- "ONE!\n");
- } else {
- amount_free += freelist->size;
- }
- }
- }
-
- if (h->mem_alloc) {
- fprintf(stream, "%*s%-*s %.2f%%\n", indent, "", fwidth,
- "Percent of heap used:",
- (100.0 * (double)(h->mem_alloc - amount_free) / (double)h->mem_alloc));
- }
- /*
- * Print the data in a VMS-style octal dump.
- */
- fprintf(stream, "%*sData follows (`__' indicates free region)...\n",
- indent, "");
- for (i=0; i<(int)(h->disk_alloc); i+=16) {
- fprintf(stream, "%*s %8d: ", indent, "", i);
- for (j = 0; j < 16; j++) {
- if (i+j<(int)(h->disk_alloc)) {
- if (marker[i + j]) {
- fprintf(stream, "__ ");
- } else {
- c = h->chunk[H5HL_SIZEOF_HDR(f) + i + j];
- fprintf(stream, "%02x ", c);
- }
- } else {
- fprintf(stream, " ");
- }
- if (7 == j)
- HDfputc(' ', stream);
- }
-
- for (j = 0; j < 16; j++) {
- if (i+j < (int)(h->disk_alloc)) {
- if (marker[i + j]) {
- HDfputc(' ', stream);
- } else {
- c = h->chunk[H5HL_SIZEOF_HDR(f) + i + j];
- if (c > ' ' && c < '~')
- HDfputc(c, stream);
- else
- HDfputc('.', stream);
- }
- }
- }
-
- HDfputc('\n', stream);
- }
-
- H5MM_xfree(marker);
-
-done:
- FUNC_LEAVE_NOAPI(ret_value);
-}