diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/H5AC.c | 1 | ||||
-rw-r--r-- | src/H5ACprivate.h | 1 | ||||
-rw-r--r-- | src/H5Cpkg.h | 2 | ||||
-rw-r--r-- | src/H5Edefin.h | 4 | ||||
-rw-r--r-- | src/H5Einit.h | 12 | ||||
-rw-r--r-- | src/H5Epubgen.h | 6 | ||||
-rw-r--r-- | src/H5Eterm.h | 4 | ||||
-rw-r--r-- | src/H5FDpublic.h | 25 | ||||
-rw-r--r-- | src/H5HF.c | 271 | ||||
-rw-r--r-- | src/H5HFcache.c | 364 | ||||
-rw-r--r-- | src/H5HFdbg.c | 129 | ||||
-rw-r--r-- | src/H5HFpkg.h | 155 | ||||
-rw-r--r-- | src/H5HFprivate.h | 65 | ||||
-rw-r--r-- | src/H5HFpublic.h | 53 | ||||
-rw-r--r-- | src/H5HFtest.c | 112 | ||||
-rw-r--r-- | src/H5err.txt | 5 | ||||
-rwxr-xr-x | src/Makefile.am | 3 | ||||
-rw-r--r-- | src/Makefile.in | 38 |
18 files changed, 1190 insertions, 60 deletions
@@ -742,6 +742,7 @@ static const char * H5AC_entry_type_names[H5AC_NTYPES] = "v2 B-tree headers", "v2 B-tree internal nodes", "v2 B-tree leaf nodes", + "fractal heap headers", "test entry" /* for testing only -- not used for actual files */ }; diff --git a/src/H5ACprivate.h b/src/H5ACprivate.h index 8f30c28..9817a4a 100644 --- a/src/H5ACprivate.h +++ b/src/H5ACprivate.h @@ -50,6 +50,7 @@ typedef enum { H5AC_BT2_INT_ID, /*v2 B-tree internal node */ H5AC_BT2_LEAF_ID, /*v2 B-tree leaf node */ H5AC_TEST_ID, /*test entry -- not used for actual files */ + H5AC_FHEAP_HDR_ID, /*fractal heap header */ H5AC_NTYPES /* Number of types, must be last */ } H5AC_type_t; diff --git a/src/H5Cpkg.h b/src/H5Cpkg.h index 3e2c049..7ee4647 100644 --- a/src/H5Cpkg.h +++ b/src/H5Cpkg.h @@ -609,7 +609,7 @@ ****************************************************************************/ #define H5C__H5C_T_MAGIC 0x005CAC0E -#define H5C__MAX_NUM_TYPE_IDS 9 +#define H5C__MAX_NUM_TYPE_IDS 10 #define H5C__PREFIX_LEN 32 struct H5C_t diff --git a/src/H5Edefin.h b/src/H5Edefin.h index 12582f4..82a74b8 100644 --- a/src/H5Edefin.h +++ b/src/H5Edefin.h @@ -40,7 +40,6 @@ hid_t H5E_OHDR_g = FAIL; /* Object header */ hid_t H5E_ATOM_g = FAIL; /* Object atom */ hid_t H5E_ATTR_g = FAIL; /* Attribute */ hid_t H5E_IO_g = FAIL; /* Low-level I/O */ -hid_t H5E_BLKTRK_g = FAIL; /* Block tracker */ hid_t H5E_SLIST_g = FAIL; /* Skip Lists */ hid_t H5E_EFL_g = FAIL; /* External file list */ hid_t H5E_TST_g = FAIL; /* Ternary Search Trees */ @@ -150,9 +149,6 @@ hid_t H5E_CANTUNPROTECT_g = FAIL; /* Unable to unprotect metadata */ hid_t H5E_MPI_g = FAIL; /* Some MPI function failed */ hid_t H5E_MPIERRSTR_g = FAIL; /* MPI Error String */ -/* Block tracker errors */ -hid_t H5E_OVERLAPS_g = FAIL; /* Blocks overlap */ - /* Dataspace errors */ hid_t H5E_CANTCLIP_g = FAIL; /* Can't clip hyperslab region */ hid_t H5E_CANTCOUNT_g = FAIL; /* Can't count elements */ diff --git a/src/H5Einit.h b/src/H5Einit.h index bf31088..b2a4563 100644 --- a/src/H5Einit.h +++ b/src/H5Einit.h @@ -123,11 +123,6 @@ if((msg = H5E_create_msg(cls, H5E_MAJOR, "Low-level I/O"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") if((H5E_IO_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -assert(H5E_BLKTRK_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MAJOR, "Block tracker"))==NULL) - HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_BLKTRK_g = H5I_register(H5I_ERROR_MSG, msg))<0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") assert(H5E_SLIST_g==(-1)); if((msg = H5E_create_msg(cls, H5E_MAJOR, "Skip Lists"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") @@ -552,13 +547,6 @@ if((msg = H5E_create_msg(cls, H5E_MINOR, "MPI Error String"))==NULL) if((H5E_MPIERRSTR_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -/* Block tracker errors */ -assert(H5E_OVERLAPS_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Blocks overlap"))==NULL) - HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_OVERLAPS_g = H5I_register(H5I_ERROR_MSG, msg))<0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") - /* Dataspace errors */ assert(H5E_CANTCLIP_g==(-1)); if((msg = H5E_create_msg(cls, H5E_MINOR, "Can't clip hyperslab region"))==NULL) diff --git a/src/H5Epubgen.h b/src/H5Epubgen.h index 4245a5c..c846a67 100644 --- a/src/H5Epubgen.h +++ b/src/H5Epubgen.h @@ -43,7 +43,6 @@ #define H5E_ATOM (H5OPEN H5E_ATOM_g) #define H5E_ATTR (H5OPEN H5E_ATTR_g) #define H5E_IO (H5OPEN H5E_IO_g) -#define H5E_BLKTRK (H5OPEN H5E_BLKTRK_g) #define H5E_SLIST (H5OPEN H5E_SLIST_g) #define H5E_EFL (H5OPEN H5E_EFL_g) #define H5E_TST (H5OPEN H5E_TST_g) @@ -71,7 +70,6 @@ H5_DLLVAR hid_t H5E_OHDR_g; /* Object header */ H5_DLLVAR hid_t H5E_ATOM_g; /* Object atom */ H5_DLLVAR hid_t H5E_ATTR_g; /* Attribute */ H5_DLLVAR hid_t H5E_IO_g; /* Low-level I/O */ -H5_DLLVAR hid_t H5E_BLKTRK_g; /* Block tracker */ H5_DLLVAR hid_t H5E_SLIST_g; /* Skip Lists */ H5_DLLVAR hid_t H5E_EFL_g; /* External file list */ H5_DLLVAR hid_t H5E_TST_g; /* Ternary Search Trees */ @@ -254,10 +252,6 @@ H5_DLLVAR hid_t H5E_CANTUNPROTECT_g; /* Unable to unprotect metadata */ H5_DLLVAR hid_t H5E_MPI_g; /* Some MPI function failed */ H5_DLLVAR hid_t H5E_MPIERRSTR_g; /* MPI Error String */ -/* Block tracker errors */ -#define H5E_OVERLAPS (H5OPEN H5E_OVERLAPS_g) -H5_DLLVAR hid_t H5E_OVERLAPS_g; /* Blocks overlap */ - /* Dataspace errors */ #define H5E_CANTCLIP (H5OPEN H5E_CANTCLIP_g) #define H5E_CANTCOUNT (H5OPEN H5E_CANTCOUNT_g) diff --git a/src/H5Eterm.h b/src/H5Eterm.h index 00eee70..66307f9 100644 --- a/src/H5Eterm.h +++ b/src/H5Eterm.h @@ -41,7 +41,6 @@ H5E_OHDR_g= H5E_ATOM_g= H5E_ATTR_g= H5E_IO_g= -H5E_BLKTRK_g= H5E_SLIST_g= H5E_EFL_g= H5E_TST_g= @@ -152,9 +151,6 @@ H5E_CANTUNPROTECT_g= H5E_MPI_g= H5E_MPIERRSTR_g= -/* Block tracker errors */ -H5E_OVERLAPS_g= - /* Dataspace errors */ H5E_CANTCLIP_g= H5E_CANTCOUNT_g= diff --git a/src/H5FDpublic.h b/src/H5FDpublic.h index 285404a..774b3f6 100644 --- a/src/H5FDpublic.h +++ b/src/H5FDpublic.h @@ -43,18 +43,21 @@ typedef enum H5FD_mem_t { H5FD_MEM_NTYPES /*must be last*/ } H5FD_mem_t; -/* Map "block tracker" header blocks to 'ohdr' type file memory, since its - * a fair amount of work to add a new kind of file memory, they are similar - * enough to object headers and probably too minor to deserve their own type. -QAK */ -#define H5FD_MEM_BLKTRK H5FD_MEM_OHDR - -/* Map "segmented heap" header blocks to 'ohdr' type file memory, since its - * a fair amount of work to add a new kind of file memory, they are similar +/* Map "fractal heap" header blocks to 'ohdr' type file memory, since its + * a fair amount of work to add a new kind of file memory and they are similar * enough to object headers and probably too minor to deserve their own type. - * Map "segmented heap" blocks to 'lheap' type file memory, since they will be - * replacing local heaps. -QAK */ -#define H5FD_MEM_SHEAP_HDR H5FD_MEM_OHDR -#define H5FD_MEM_SHEAP_BLOCK H5FD_MEM_LHEAP + * + * Map "fractal heap" indirect blocks to 'ohdr' type file memory, since they + * are similar to fractal heap header blocks. + * + * Map "fractal heap" direct blocks to 'lheap' type file memory, since they + * will be replacing local heaps. + * + * -QAK + */ +#define H5FD_MEM_FHEAP_HDR H5FD_MEM_OHDR +#define H5FD_MEM_FHEAP_INDIRECT H5FD_MEM_OHDR +#define H5FD_MEM_FHEAP_DIRECT H5FD_MEM_LHEAP /* * A free-list map which maps all types of allocation requests to a single diff --git a/src/H5HF.c b/src/H5HF.c new file mode 100644 index 0000000..1fe38cb --- /dev/null +++ b/src/H5HF.c @@ -0,0 +1,271 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/*------------------------------------------------------------------------- + * + * Created: H5HF.c + * Feb 24 2006 + * Quincey Koziol <koziol@ncsa.uiuc.edu> + * + * Purpose: Implements a "fractal heap" for storing variable- + * length objects in a file. + * + * Please see the documentation in: + * doc/html/TechNotes/FractalHeap.html for a full description + * of how they work, etc. + * + *------------------------------------------------------------------------- + */ + +/****************/ +/* Module Setup */ +/****************/ + +#define H5HF_PACKAGE /*suppress error about including H5HFpkg */ + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5HFpkg.h" /* Fractal heaps */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5MFprivate.h" /* File memory management */ + +/****************/ +/* Local Macros */ +/****************/ + + +/******************/ +/* Local Typedefs */ +/******************/ + + +/********************/ +/* Local Prototypes */ +/********************/ + +static herr_t H5HF_shared_free(void *_shared); + +/*********************/ +/* Package Variables */ +/*********************/ + +/* Declare a free list to manage the H5HF_t struct */ +H5FL_DEFINE(H5HF_t); + + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + + +/*******************/ +/* Local Variables */ +/*******************/ + +/* Declare a free list to manage the H5HF_shared_t struct */ +H5FL_DEFINE_STATIC(H5HF_shared_t); + + + +/*------------------------------------------------------------------------- + * Function: H5HF_shared_init + * + * Purpose: Allocate & initialize shared fractal heap info + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@ncsa.uiuc.edu + * Feb 24 2006 + * + *------------------------------------------------------------------------- + */ +herr_t +H5HF_shared_init(H5F_t *f, H5HF_t *fh, H5HF_type_t type) +{ + H5HF_shared_t *shared = NULL; /* Shared fractal heap information */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5HF_shared_init) + + /* Allocate space for the shared information */ + if(NULL == (shared = H5FL_CALLOC(H5HF_shared_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for fractal heap shared information") + + /* Set the type of heap address mapping */ + shared->type = type; + + /* Make shared B-tree info reference counted */ + if(NULL == (fh->shared = H5RC_create(shared, H5HF_shared_free))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't create ref-count wrapper for shared fractal heap info") + +done: + if(ret_value < 0) + if(shared) + H5HF_shared_free(shared); + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HF_shared_init() */ + + +/*------------------------------------------------------------------------- + * Function: H5HF_shared_free + * + * Purpose: Free shared fractal heap info + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@ncsa.uiuc.edu + * Feb 24 2006 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5HF_shared_free(void *_shared) +{ + H5HF_shared_t *shared = (H5HF_shared_t *)_shared; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI_NOINIT(H5HF_shared_free) + + /* Sanity check */ + HDassert(shared); + + /* Free the shared info itself */ + H5FL_FREE(H5HF_shared_t, shared); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HF_shared_free() */ + + +/*------------------------------------------------------------------------- + * Function: H5HF_create + * + * Purpose: Creates a new empty fractal heap in the file. + * + * Return: Non-negative on success (with address of new fractal heap + * filled in), negative on failure + * + * Programmer: Quincey Koziol + * koziol@ncsa.uiuc.edu + * Feb 24 2006 + * + *------------------------------------------------------------------------- + */ +herr_t +H5HF_create(H5F_t *f, hid_t dxpl_id, H5HF_type_t type, haddr_t *addr_p) +{ + H5HF_t *fh = NULL; /* The new fractal heap header information */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(H5HF_create, FAIL) + + /* + * Check arguments. + */ + HDassert(f); + HDassert(addr_p); + + /* + * Allocate file and memory data structures. + */ + if(NULL == (fh = H5FL_MALLOC(H5HF_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for fractal heap header") + + /* Assign internal information */ + HDmemset(&fh->cache_info, 0, sizeof(H5AC_info_t)); + + /* Initialize shared fractal heap info */ + if(H5HF_shared_init(f, fh, type) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't create shared fractal heap info") + + /* Allocate space for the header on disk */ + if(HADDR_UNDEF == (*addr_p = H5MF_alloc(f, H5FD_MEM_FHEAP_HDR, dxpl_id, (hsize_t)H5HF_HEADER_SIZE(f)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "file allocation failed for fractal heap header") + + /* Cache the new fractal heap node */ + if(H5AC_set(f, dxpl_id, H5AC_FHEAP_HDR, *addr_p, fh, H5AC__NO_FLAGS_SET) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't add fractal heap header to cache") + +done: + if(ret_value < 0) { + if(fh) + (void)H5HF_cache_hdr_dest(f, fh); + } /* end if */ + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HF_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5HF_insert + * + * Purpose: Insert a new object into a fractal heap. + * + * Return: Non-negative on success (with heap ID of new object + * filled in), negative on failure + * + * Programmer: Quincey Koziol + * koziol@ncsa.uiuc.edu + * Feb 24 2006 + * + *------------------------------------------------------------------------- + */ +herr_t +H5HF_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr, size_t size, + const void *obj, void *id/*out*/) +{ + H5HF_t *fh = NULL; /* The new fractal heap header information */ + H5HF_shared_t *shared; /* Shared fractal heap information */ + unsigned hdr_flags = H5AC__NO_FLAGS_SET; /* Metadata cache flags for header */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(H5HF_insert, FAIL) + + /* + * Check arguments. + */ + HDassert(f); + HDassert(H5F_addr_defined(addr)); + HDassert(size > 0); + HDassert(obj); + HDassert(id); + + /* + * Load the fractal heap header. + */ + if(NULL == (fh = H5AC_protect(f, dxpl_id, H5AC_FHEAP_HDR, addr, NULL, NULL, H5AC_WRITE))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load fractal heap header") + + /* Get the pointer to the shared fractal heap info */ + shared = H5RC_GET_OBJ(fh->shared); + HDassert(shared); + + /* Check if object is large enough to be standalone */ + if(size >= shared->standalone_size) { + } /* end if */ + else { + } /* end else */ + +done: + if(fh && H5AC_unprotect(f, dxpl_id, H5AC_FHEAP_HDR, addr, fh, hdr_flags) < 0) + HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release fractal heap header") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HF_insert() */ + diff --git a/src/H5HFcache.c b/src/H5HFcache.c new file mode 100644 index 0000000..9544242 --- /dev/null +++ b/src/H5HFcache.c @@ -0,0 +1,364 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/*------------------------------------------------------------------------- + * + * Created: H5HFcache.c + * Feb 24 2006 + * Quincey Koziol <koziol@ncsa.uiuc.edu> + * + * Purpose: Implement fractal heap metadata cache methods. + * + *------------------------------------------------------------------------- + */ + +/****************/ +/* Module Setup */ +/****************/ + +#define H5HF_PACKAGE /*suppress error about including H5HFpkg */ + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5HFpkg.h" /* Fractal heaps */ +#include "H5Eprivate.h" /* Error handling */ + +/****************/ +/* Local Macros */ +/****************/ + +/* Fractal heap format version #'s */ +#define H5HF_HDR_VERSION 0 /* Header */ + +/******************/ +/* Local Typedefs */ +/******************/ + +/********************/ +/* Local Prototypes */ +/********************/ + +/* Metadata cache callbacks */ +static H5HF_t *H5HF_cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_type, void *udata); +static herr_t H5HF_cache_hdr_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5HF_t *fh); +static herr_t H5HF_cache_hdr_clear(H5F_t *f, H5HF_t *fh, hbool_t destroy); +static herr_t H5HF_cache_hdr_size(const H5F_t *f, const H5HF_t *fh, size_t *size_ptr); + +/*********************/ +/* Package Variables */ +/*********************/ + +/* H5HF inherits cache-like properties from H5AC */ +const H5AC_class_t H5AC_FHEAP_HDR[1] = {{ + H5AC_FHEAP_HDR_ID, + (H5AC_load_func_t)H5HF_cache_hdr_load, + (H5AC_flush_func_t)H5HF_cache_hdr_flush, + (H5AC_dest_func_t)H5HF_cache_hdr_dest, + (H5AC_clear_func_t)H5HF_cache_hdr_clear, + (H5AC_size_func_t)H5HF_cache_hdr_size, +}}; + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + + +/*******************/ +/* Local Variables */ +/*******************/ + +/* Declare a free list to manage B-tree header data to/from disk */ +H5FL_BLK_DEFINE_STATIC(header_block); + + + +/*------------------------------------------------------------------------- + * Function: H5HF_cache_hdr_load + * + * Purpose: Loads a fractal heap header from the disk. + * + * Return: Success: Pointer to a new fractal heap + * + * Failure: NULL + * + * Programmer: Quincey Koziol + * koziol@ncsa.uiuc.edu + * Feb 24 2006 + * + *------------------------------------------------------------------------- + */ +static H5HF_t * +H5HF_cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED *udata1, void UNUSED *udata2) +{ + H5HF_t *fh = NULL; /* Fractal heap info */ + size_t size; /* Header size */ + uint8_t *buf = NULL; /* Temporary buffer */ + uint8_t *p; /* Pointer into raw data buffer */ + H5HF_type_t heap_type; /* Type of heap */ + uint32_t metadata_chksum; /* Metadata checksum value */ + H5HF_t *ret_value; /* Return value */ + + FUNC_ENTER_NOAPI(H5HF_cache_hdr_load, NULL) + + /* Check arguments */ + HDassert(f); + HDassert(H5F_addr_defined(addr)); + + /* Allocate space for the fractal heap data structure */ + if(NULL == (fh = H5FL_MALLOC(H5HF_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + HDmemset(&fh->cache_info, 0, sizeof(H5AC_info_t)); + + /* Compute the size of the fractal heap header on disk */ + size = H5HF_HEADER_SIZE(f); + + /* Allocate temporary buffer */ + if((buf = H5FL_BLK_MALLOC(header_block, size)) == NULL) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + + /* Read header from disk */ + if(H5F_block_read(f, H5FD_MEM_FHEAP_HDR, addr, size, dxpl_id, buf) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_READERROR, NULL, "can't read fractal heap header") + + p = buf; + + /* magic number */ + if(HDmemcmp(p, H5HF_HDR_MAGIC, H5HF_SIZEOF_MAGIC)) + HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "wrong fractal heap header signature") + p += H5HF_SIZEOF_MAGIC; + + /* version */ + if(*p++ != H5HF_HDR_VERSION) + HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "wrong fractal heap header version") + + /* Metadata flags (unused, currently) */ +/* XXX: Plan out metadata flags (including "read-only duplicate" feature) */ + if(*p++ != 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "unknown metadata flag in fractal heap header") + + /* Metadata checksum (unused, currently) */ + UINT32DECODE(p, metadata_chksum); +/* XXX: Verify checksum */ + if(metadata_chksum != 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "incorrect metadata checksum for fractal heap header") + + /* Fractal heap type */ + heap_type = *p++; + HDassert(H5HF_ABSOLUTE == 0); + if(heap_type > H5HF_MAPPED) + HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "incorrect fractal heap type") + + /* Initialize shared fractal heap info */ + if(H5HF_shared_init(f, fh, heap_type) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't create shared fractal heap info") + + /* Set return value */ + ret_value = fh; + +done: + if(buf) + H5FL_BLK_FREE(header_block, buf); + if(!ret_value && fh) + (void)H5HF_cache_hdr_dest(f, fh); + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HF_cache_hdr_load() */ /*lint !e818 Can't make udata a pointer to const */ + + +/*------------------------------------------------------------------------- + * Function: H5HF_cache_hdr_flush + * + * Purpose: Flushes a dirty fractal heap header to disk. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@ncsa.uiuc.edu + * Feb 24 2006 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5HF_cache_hdr_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5HF_t *fh) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(H5HF_cache_hdr_flush, FAIL) + + /* check arguments */ + HDassert(f); + HDassert(H5F_addr_defined(addr)); + HDassert(fh); + + if(fh->cache_info.is_dirty) { + H5HF_shared_t *shared; /* Shared fractal heap information */ + uint8_t *buf = NULL; /* Temporary raw data buffer */ + uint8_t *p; /* Pointer into raw data buffer */ + size_t size; /* Header size on disk */ + + /* Get the pointer to the shared B-tree info */ + shared = H5RC_GET_OBJ(fh->shared); + HDassert(shared); + + /* Compute the size of the B-tree header on disk */ + size = H5HF_HEADER_SIZE(f); + + /* Allocate temporary buffer */ + if((buf = H5FL_BLK_MALLOC(header_block, size)) == NULL) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + + p = buf; + + /* Magic number */ + HDmemcpy(p, H5HF_HDR_MAGIC, H5HF_SIZEOF_MAGIC); + p += H5HF_SIZEOF_MAGIC; + + /* Version # */ + *p++ = H5HF_HDR_VERSION; + + /* Metadata status flags */ +/* XXX: Set this? */ + *p++ = 0; + + /* Metadata checksum */ +/* XXX: Set this! (After all the metadata is in the buffer) */ + HDmemset(p, 0, 4); + p += 4; + + /* Fractal heap type */ + *p++ = shared->type; + + /* Write the B-tree header. */ + HDassert((size_t)(p - buf) == size); + if(H5F_block_write(f, H5FD_MEM_FHEAP_HDR, addr, size, dxpl_id, buf) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTFLUSH, FAIL, "unable to save fractal heap header to disk") + + H5FL_BLK_FREE(header_block, buf); + + fh->cache_info.is_dirty = FALSE; + } /* end if */ + + if(destroy) + if(H5HF_cache_hdr_dest(f, fh) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy fractal heap header") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5HF_cache_hdr_flush() */ + + +/*------------------------------------------------------------------------- + * Function: H5HF_cache_hdr_dest + * + * Purpose: Destroys a fractal heap header in memory. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@ncsa.uiuc.edu + * Feb 24 2006 + * + *------------------------------------------------------------------------- + */ +/* ARGSUSED */ +herr_t +H5HF_cache_hdr_dest(H5F_t UNUSED *f, H5HF_t *fh) +{ + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_cache_hdr_dest) + + /* + * Check arguments. + */ + HDassert(fh); + + /* Decrement reference count on shared fractal heap info */ + if(fh->shared) + H5RC_DEC(fh->shared); + + /* Free fractal heap header info */ + H5FL_FREE(H5HF_t, fh); + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5HF_cache_hdr_dest() */ + + +/*------------------------------------------------------------------------- + * Function: H5HF_cache_hdr_clear + * + * Purpose: Mark a fractal heap header in memory as non-dirty. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@ncsa.uiuc.edu + * Feb 24 2006 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5HF_cache_hdr_clear(H5F_t *f, H5HF_t *fh, hbool_t destroy) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5HF_cache_hdr_clear) + + /* + * Check arguments. + */ + HDassert(fh); + + /* Reset the dirty flag. */ + fh->cache_info.is_dirty = FALSE; + + if(destroy) + if(H5HF_cache_hdr_dest(f, fh) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy fractal heap header") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HF_cache_hdr_clear() */ + + +/*------------------------------------------------------------------------- + * Function: H5HF_cache_hdr_size + * + * Purpose: Compute the size in bytes of a fractal heap header + * on disk, and return it in *size_ptr. On failure, + * the value of *size_ptr is undefined. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@ncsa.uiuc.edu + * Feb 24 2006 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5HF_cache_hdr_size(const H5F_t *f, const H5HF_t UNUSED *fh, size_t *size_ptr) +{ + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_cache_hdr_size) + + /* check arguments */ + HDassert(f); + HDassert(size_ptr); + + /* Set size value */ + *size_ptr = H5HF_HEADER_SIZE(f); + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* H5HF_cache_hdr_size() */ + diff --git a/src/H5HFdbg.c b/src/H5HFdbg.c new file mode 100644 index 0000000..cb6476c --- /dev/null +++ b/src/H5HFdbg.c @@ -0,0 +1,129 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/*------------------------------------------------------------------------- + * + * Created: H5HFdbg.c + * Feb 24 2006 + * Quincey Koziol <koziol@ncsa.uiuc.edu> + * + * Purpose: Dump debugging information about a fractal heap + * + *------------------------------------------------------------------------- + */ + +/****************/ +/* Module Setup */ +/****************/ + +#define H5HF_PACKAGE /*suppress error about including H5HFpkg */ + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5HFpkg.h" /* Fractal heaps */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ + +/****************/ +/* Local Macros */ +/****************/ + + +/******************/ +/* Local Typedefs */ +/******************/ + + +/********************/ +/* Local Prototypes */ +/********************/ + + +/*********************/ +/* Package Variables */ +/*********************/ + + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + + +/*******************/ +/* Local Variables */ +/*******************/ + + +/*------------------------------------------------------------------------- + * Function: H5HF_hdr_debug + * + * Purpose: Prints debugging info about a fractal heap header. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@ncsa.uiuc.edu + * Feb 24 2006 + * + *------------------------------------------------------------------------- + */ +herr_t +H5HF_hdr_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, int fwidth) +{ + H5HF_t *fh = NULL; /* Fractal heap header info */ + H5HF_shared_t *shared; /* Shared fractal heap information */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(H5HF_hdr_debug, FAIL) + + /* + * Check arguments. + */ + HDassert(f); + HDassert(H5F_addr_defined(addr)); + HDassert(stream); + HDassert(indent >= 0); + HDassert(fwidth >= 0); + + /* + * Load the fractal heap header. + */ + if(NULL == (fh = H5AC_protect(f, dxpl_id, H5AC_FHEAP_HDR, addr, NULL, NULL, H5AC_READ))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load fractal heap header") + + /* Get the pointer to the shared fractal heap info */ + shared = H5RC_GET_OBJ(fh->shared); + HDassert(shared); + + /* Print opening message */ + HDfprintf(stream, "%*sFractal Heap Header...\n", indent, ""); + + /* + * Print the values. + */ + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, + "Heap addressing method:", + ((shared->type) == H5HF_ABSOLUTE ? "Absolute" : + ((shared->type) == H5HF_MAPPED ? "Mapped" : + "Unknown!"))); + +done: + if(fh && H5AC_unprotect(f, dxpl_id, H5AC_FHEAP_HDR, addr, fh, H5AC__NO_FLAGS_SET) < 0) + HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release fractal heap header") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HF_hdr_debug() */ + diff --git a/src/H5HFpkg.h b/src/H5HFpkg.h new file mode 100644 index 0000000..d311aff --- /dev/null +++ b/src/H5HFpkg.h @@ -0,0 +1,155 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Quincey Koziol <koziol@ncsa.uiuc.edu> + * Friday, February 24, 2006 + * + * Purpose: This file contains declarations which are visible only within + * the H5HF package. Source files outside the H5HF package should + * include H5HFprivate.h instead. + */ +#ifndef H5HF_PACKAGE +#error "Do not include this file outside the H5HF package!" +#endif + +#ifndef _H5HFpkg_H +#define _H5HFpkg_H + +/* Get package's private header */ +#include "H5HFprivate.h" + +/* Other private headers needed by this file */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5RCprivate.h" /* Reference counted object functions */ + +/**************************/ +/* Package Private Macros */ +/**************************/ + +/* Size of signature information (on disk) */ +#define H5HF_SIZEOF_MAGIC 4 + +/* Fractal heap signatures */ +#define H5HF_HDR_MAGIC "FRHP" /* Header */ + +/* Size of the fractal heap header on disk */ +#define H5HF_HEADER_SIZE(f) ( \ + /* General metadata fields */ \ + 4 /* Signature */ \ + + 1 /* Version */ \ + + 1 /* Metadata flags */ \ + + 4 /* Metadata checksum */ \ + \ + /* Fractal heap header specific fields */ \ + + 1 /* Heap type */ \ + ) + +/****************************/ +/* Package Private Typedefs */ +/****************************/ + +/* Doubling-table info */ +typedef struct H5HF_dtable_param_t { + /* Immutable, pre-set information for table */ + unsigned width; /* Number of columns in the table (must be power of 2) */ + hsize_t start_block_size; /* Starting block size for table (must be power of 2) */ + hsize_t max_direct_size; /* Maximum size of a direct block (must be power of 2) */ + hsize_t max_index; /* Maximum ID/offset for table (must be power of 2) */ + unsigned start_root_rows; /* Starting number of rows for root indirect block */ + /* 0 indicates to create the full indirect block for the root, + * right from the start. Doesn't have to be power of 2 + */ + + /* Derived information that varies during lifetime of table */ + haddr_t table_addr; /* Address of first block for table */ + /* Undefined if no space allocated for table */ + unsigned curr_root_rows; /* Current number of rows in the root indirect block */ + /* 0 indicates that the TABLE_ADDR field points + * to direct block (of START_BLOCK_SIZE) instead + * of indirect root block. + */ +} H5HF_dtable_param_t; + +/* Each fractal heap has certain information that can be shared across all + * the instances of blocks in that fractal heap. + */ +typedef struct H5HF_shared_t { + /* Shared internal information */ + hsize_t next_man_block; /* Offset of next direct managed block */ + hsize_t next_std_block; /* Offset of next direct standalone block */ + hsize_t total_man_free; /* Total amount of free space in managed blocks */ + hsize_t total_std_free; /* Total # of free standalone ID entries */ + + /* Doubling table information */ + /* (Partially set by user, partially derived/updated internally) */ + H5HF_dtable_param_t man_dtable_info; /* Doubling-table info for managed objects */ + H5HF_dtable_param_t std_dtable_info; /* Doubling-table info for standalone objects */ + + /* Information set by user */ + H5HF_type_t type; /* Type of address mapping */ + size_t standalone_size; /* Size of object to store standalone */ + size_t fixed_len_size; /* Size of objects (only for heaps w/fixed-length objects) */ + + /* Information derived from user parameters */ + hbool_t fixed_len_obj; /* Are objects in the heap fixed length? */ + hbool_t ref_count_obj; /* Are objects in the heap ref. counted? */ + hbool_t have_io_filter; /* Does the heap have I/O filters for the direct blocks? */ + hbool_t write_once; /* Is heap being written in "write once" mode? */ +} H5HF_shared_t; + +/* The fractal heap information */ +typedef struct H5HF_t { + /* Information for H5AC cache functions, _must_ be first field in structure */ + H5AC_info_t cache_info; + + /* Internal fractal heap information */ + H5RC_t *shared; /* Ref-counted shared info */ +} H5HF_t; + + +/*****************************/ +/* Package Private Variables */ +/*****************************/ + +/* H5HF header inherits cache-like properties from H5AC */ +H5_DLLVAR const H5AC_class_t H5AC_FHEAP_HDR[1]; + +/* Declare a free list to manage the H5HF_t struct */ +H5FL_EXTERN(H5HF_t); + + +/******************************/ +/* Package Private Prototypes */ +/******************************/ + +/* Routines for managing shared fractal heap info */ +H5_DLL herr_t H5HF_shared_init(H5F_t *f, H5HF_t *fh, H5HF_type_t type); + +/* Metadata cache callbacks */ +H5_DLL herr_t H5HF_cache_hdr_dest(H5F_t *f, H5HF_t *b); + +/* Debugging routines for dumping file structures */ +H5_DLL herr_t H5HF_hdr_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, + FILE *stream, int indent, int fwidth); + +/* Testing routines */ +#ifdef H5HF_TESTING +H5_DLL herr_t H5HF_get_addrmap_test(H5F_t *f, hid_t dxpl_id, haddr_t fh_addr, + H5HF_type_t *heap_type); +#endif /* H5HF_TESTING */ + +#endif /* _H5HFpkg_H */ + diff --git a/src/H5HFprivate.h b/src/H5HFprivate.h new file mode 100644 index 0000000..49c11c9 --- /dev/null +++ b/src/H5HFprivate.h @@ -0,0 +1,65 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/*------------------------------------------------------------------------- + * + * Created: H5HFprivate.h + * Feb 24 2006 + * Quincey Koziol <koziol@ncsa.uiuc.edu> + * + * Purpose: Private header for library accessible fractal heap routines. + * + *------------------------------------------------------------------------- + */ + +#ifndef _H5HFprivate_H +#define _H5HFprivate_H + +/* Include package's public header */ +#include "H5HFpublic.h" + +/* Private headers needed by this file */ +#include "H5Fprivate.h" /* File access */ + +/**************************/ +/* Library Private Macros */ +/**************************/ + + +/****************************/ +/* Library Private Typedefs */ +/****************************/ + +/* Types of heaps */ +typedef enum { + H5HF_ABSOLUTE, /* The heap uses absolute internal addressing */ + H5HF_MAPPED /* The heap maps internal addresses to allow compaction */ +} H5HF_type_t; + + +/*****************************/ +/* Library-private Variables */ +/*****************************/ + +/***************************************/ +/* Library-private Function Prototypes */ +/***************************************/ +H5_DLL herr_t H5HF_create(H5F_t *f, hid_t dxpl_id, H5HF_type_t type, + haddr_t *addr_p); +H5_DLL herr_t H5HF_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr, size_t size, + const void *obj, void *id/*out*/); + +#endif /* _H5HFprivate_H */ + + diff --git a/src/H5HFpublic.h b/src/H5HFpublic.h new file mode 100644 index 0000000..70453dc --- /dev/null +++ b/src/H5HFpublic.h @@ -0,0 +1,53 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/*------------------------------------------------------------------------- + * + * Created: H5HFpublic.h + * Feb 24 2006 + * Quincey Koziol <koziol@ncsa.uiuc.edu> + * + * Purpose: Public declarations for the fractal heap package. + * + *------------------------------------------------------------------------- + */ + +#ifndef _H5HFpublic_H +#define _H5HFpublic_H + +/* Public headers needed by this file */ +#include "H5public.h" + +/*****************/ +/* Public Macros */ +/*****************/ + +/*******************/ +/* Public Typedefs */ +/*******************/ + +/**********************************/ +/* Public API Function Prototypes */ +/**********************************/ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _H5HFpublic_H */ + diff --git a/src/H5HFtest.c b/src/H5HFtest.c new file mode 100644 index 0000000..e9a3eeb --- /dev/null +++ b/src/H5HFtest.c @@ -0,0 +1,112 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* Programmer: Quincey Koziol <koziol@ncsa.uiuc.edu> + * Thursday, February 3, 2005 + * + * Purpose: Fractal heap testing functions. + */ + +/****************/ +/* Module Setup */ +/****************/ + +#define H5HF_PACKAGE /*suppress error about including H5HFpkg */ +#define H5HF_TESTING /*suppress warning about H5HF testing funcs*/ + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5HFpkg.h" /* Fractal heaps */ +#include "H5Eprivate.h" /* Error handling */ + +/****************/ +/* Local Macros */ +/****************/ + + +/******************/ +/* Local Typedefs */ +/******************/ + + +/********************/ +/* Local Prototypes */ +/********************/ + + +/*********************/ +/* Package Variables */ +/*********************/ + + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + + +/*******************/ +/* Local Variables */ +/*******************/ + + + +/*------------------------------------------------------------------------- + * Function: H5HF_get_addrmap_test + * + * Purpose: Retrieve the address mapping type + * + * Return: Success: non-negative + * + * Failure: negative + * + * Programmer: Quincey Koziol + * Friday, February 24, 2006 + * + *------------------------------------------------------------------------- + */ +herr_t +H5HF_get_addrmap_test(H5F_t *f, hid_t dxpl_id, haddr_t fh_addr, H5HF_type_t *heap_type) +{ + H5HF_t *fh = NULL; /* Pointer to the B-tree header */ + H5HF_shared_t *shared; /* Shared fractal heap information */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5HF_get_addrmap_test) + + /* Check arguments. */ + HDassert(f); + HDassert(H5F_addr_defined(fh_addr)); + HDassert(heap_type); + + /* Look up the fractal heap header */ + if(NULL == (fh = H5AC_protect(f, dxpl_id, H5AC_FHEAP_HDR, fh_addr, NULL, NULL, H5AC_READ))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to load fractal heap header") + + /* Get the pointer to the shared fractal heap info */ + shared = H5RC_GET_OBJ(fh->shared); + HDassert(shared); + + /* Get fractal heap address mapping */ + *heap_type = shared->type; + +done: + /* Release fractal heap header node */ + if(fh && H5AC_unprotect(f, dxpl_id, H5AC_FHEAP_HDR, fh_addr, fh, H5AC__NO_FLAGS_SET) < 0) + HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap header info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* H5HF_get_addrmap_test() */ + diff --git a/src/H5err.txt b/src/H5err.txt index 65c4e1f..88eb01c 100644 --- a/src/H5err.txt +++ b/src/H5err.txt @@ -71,7 +71,6 @@ MAJOR, H5E_TST, Ternary Search Trees MAJOR, H5E_RS, Reference Counted Strings MAJOR, H5E_ERROR, Error API MAJOR, H5E_SLIST, Skip Lists -MAJOR, H5E_BLKTRK, Block tracker # Sections (for grouping minor errors) SECTION, ARGS, Argument errors @@ -91,7 +90,6 @@ SECTION, MPI, Parallel MPI errors SECTION, HEAP, Heap errors SECTION, FPH5, FPHDF5 errors SECTION, PIPELINE, I/O pipeline errors -SECTION, BLKTRK, Block tracker errors SECTION, SYSTEM, System level errors # Minor errors @@ -223,8 +221,5 @@ MINOR, PIPELINE, H5E_CANAPPLY, Error from filter 'can apply' callback MINOR, PIPELINE, H5E_SETLOCAL, Error from filter 'set local' callback MINOR, PIPELINE, H5E_NOENCODER, Filter present but encoding disabled -# Block tracker errors -MINOR, BLKTRK, H5E_OVERLAPS, Blocks overlap - # System level errors MINOR, SYSTEM, H5E_SYSERRSTR, System error message diff --git a/src/Makefile.am b/src/Makefile.am index d8c82d0..dc3629a 100755 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -55,6 +55,7 @@ libhdf5_la_SOURCES= H5.c H5A.c H5AC.c H5B.c H5Bcache.c H5B2.c H5B2cache.c \ H5Gstab.c \ H5Gtest.c \ H5Gtraverse.c \ + H5HF.c H5HFcache.c H5HFdbg.c H5HFtest.c \ H5HG.c H5HGdbg.c H5HL.c H5HLdbg.c H5HP.c H5I.c H5MF.c H5MM.c \ H5MP.c H5MPtest.c \ H5O.c \ @@ -83,7 +84,7 @@ include_HEADERS =H5public.h H5Apublic.h H5ACpublic.h H5Bpublic.h H5B2public.h \ H5Epubgen.h H5Epublic.h H5Fpublic.h H5FDpublic.h H5FDcore.h H5FDfamily.h \ H5FDfphdf5.h H5FDlog.h H5FDmpi.h H5FDmpio.h H5FDmpiposix.h \ H5FDmulti.h H5FDsec2.h H5FDstdio.h H5FDstream.h H5FPpublic.h \ - H5Gpublic.h H5HGpublic.h H5HLpublic.h H5Ipublic.h \ + H5Gpublic.h H5HFpublic.h H5HGpublic.h H5HLpublic.h H5Ipublic.h \ H5MMpublic.h H5Opublic.h H5Ppublic.h H5Rpublic.h H5Spublic.h \ H5Tpublic.h H5Zpublic.h H5pubconf.h hdf5.h H5api_adpt.h diff --git a/src/Makefile.in b/src/Makefile.in index 7a58aa4..1b5ea41 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -92,21 +92,22 @@ am_libhdf5_la_OBJECTS = H5.lo H5A.lo H5AC.lo H5B.lo H5Bcache.lo \ H5FDstdio.lo H5FDstream.lo H5FL.lo H5FO.lo H5FP.lo \ H5FPclient.lo H5FPserver.lo H5FS.lo H5G.lo H5Gent.lo \ H5Glink.lo H5Gloc.lo H5Gname.lo H5Gnode.lo H5Gobj.lo H5Goh.lo \ - H5Gstab.lo H5Gtest.lo H5Gtraverse.lo H5HG.lo H5HGdbg.lo \ - H5HL.lo H5HLdbg.lo H5HP.lo H5I.lo H5MF.lo H5MM.lo H5MP.lo \ - H5MPtest.lo H5O.lo H5Oattr.lo H5Obogus.lo H5Ocache.lo \ - H5Ocont.lo H5Odtype.lo H5Oefl.lo H5Ofill.lo H5Oginfo.lo \ - H5Olayout.lo H5Olinfo.lo H5Olink.lo H5Omtime.lo H5Oname.lo \ - H5Onull.lo H5Opline.lo H5Osdspace.lo H5Oshared.lo H5Ostab.lo \ - H5P.lo H5Pacpl.lo H5Pdcpl.lo H5Pdxpl.lo H5Pfapl.lo H5Pfcpl.lo \ - H5Pgcpl.lo H5Pocpl.lo H5Ptest.lo H5R.lo H5RC.lo H5RS.lo H5S.lo \ - H5Sall.lo H5Shyper.lo H5Smpio.lo H5Snone.lo H5Spoint.lo \ - H5Sselect.lo H5Stest.lo H5SL.lo H5ST.lo H5T.lo H5Tarray.lo \ - H5Tbit.lo H5Tcommit.lo H5Tcompound.lo H5Tconv.lo H5Tcset.lo \ - H5Tenum.lo H5Tfields.lo H5Tfixed.lo H5Tfloat.lo H5Tinit.lo \ - H5Tnative.lo H5Toffset.lo H5Toh.lo H5Topaque.lo H5Torder.lo \ - H5Tpad.lo H5Tprecis.lo H5Tstrpad.lo H5Tvlen.lo H5TS.lo H5V.lo \ - H5Z.lo H5Zdeflate.lo H5Zfletcher32.lo H5Znbit.lo H5Zshuffle.lo \ + H5Gstab.lo H5Gtest.lo H5Gtraverse.lo H5HF.lo H5HFcache.lo \ + H5HFdbg.lo H5HFtest.lo H5HG.lo H5HGdbg.lo H5HL.lo H5HLdbg.lo \ + H5HP.lo H5I.lo H5MF.lo H5MM.lo H5MP.lo H5MPtest.lo H5O.lo \ + H5Oattr.lo H5Obogus.lo H5Ocache.lo H5Ocont.lo H5Odtype.lo \ + H5Oefl.lo H5Ofill.lo H5Oginfo.lo H5Olayout.lo H5Olinfo.lo \ + H5Olink.lo H5Omtime.lo H5Oname.lo H5Onull.lo H5Opline.lo \ + H5Osdspace.lo H5Oshared.lo H5Ostab.lo H5P.lo H5Pacpl.lo \ + H5Pdcpl.lo H5Pdxpl.lo H5Pfapl.lo H5Pfcpl.lo H5Pgcpl.lo \ + H5Pocpl.lo H5Ptest.lo H5R.lo H5RC.lo H5RS.lo H5S.lo H5Sall.lo \ + H5Shyper.lo H5Smpio.lo H5Snone.lo H5Spoint.lo H5Sselect.lo \ + H5Stest.lo H5SL.lo H5ST.lo H5T.lo H5Tarray.lo H5Tbit.lo \ + H5Tcommit.lo H5Tcompound.lo H5Tconv.lo H5Tcset.lo H5Tenum.lo \ + H5Tfields.lo H5Tfixed.lo H5Tfloat.lo H5Tinit.lo H5Tnative.lo \ + H5Toffset.lo H5Toh.lo H5Topaque.lo H5Torder.lo H5Tpad.lo \ + H5Tprecis.lo H5Tstrpad.lo H5Tvlen.lo H5TS.lo H5V.lo H5Z.lo \ + H5Zdeflate.lo H5Zfletcher32.lo H5Znbit.lo H5Zshuffle.lo \ H5Zszip.lo H5Zscaleoffset.lo H5Ztrans.lo libhdf5_la_OBJECTS = $(am_libhdf5_la_OBJECTS) PROGRAMS = $(noinst_PROGRAMS) @@ -406,6 +407,7 @@ libhdf5_la_SOURCES = H5.c H5A.c H5AC.c H5B.c H5Bcache.c H5B2.c H5B2cache.c \ H5Gstab.c \ H5Gtest.c \ H5Gtraverse.c \ + H5HF.c H5HFcache.c H5HFdbg.c H5HFtest.c \ H5HG.c H5HGdbg.c H5HL.c H5HLdbg.c H5HP.c H5I.c H5MF.c H5MM.c \ H5MP.c H5MPtest.c \ H5O.c \ @@ -434,7 +436,7 @@ include_HEADERS = H5public.h H5Apublic.h H5ACpublic.h H5Bpublic.h H5B2public.h \ H5Epubgen.h H5Epublic.h H5Fpublic.h H5FDpublic.h H5FDcore.h H5FDfamily.h \ H5FDfphdf5.h H5FDlog.h H5FDmpi.h H5FDmpio.h H5FDmpiposix.h \ H5FDmulti.h H5FDsec2.h H5FDstdio.h H5FDstream.h H5FPpublic.h \ - H5Gpublic.h H5HGpublic.h H5HLpublic.h H5Ipublic.h \ + H5Gpublic.h H5HFpublic.h H5HGpublic.h H5HLpublic.h H5Ipublic.h \ H5MMpublic.h H5Opublic.h H5Ppublic.h H5Rpublic.h H5Spublic.h \ H5Tpublic.h H5Zpublic.h H5pubconf.h hdf5.h H5api_adpt.h @@ -613,6 +615,10 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Gstab.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Gtest.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Gtraverse.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5HF.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5HFcache.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5HFdbg.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5HFtest.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5HG.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5HGdbg.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5HL.Plo@am__quote@ |