mirror of
https://github.com/HDFGroup/hdf5.git
synced 2025-04-18 17:40:55 +08:00
[svn-r12317] Purpose:
Code checkpoint Description: More progress on fractal heap, can now re-open an existing heap, although the free space algorithm still needs work. Also, use the new "pinned entry" metadata cache code. Platforms tested: FreeBSD 4.11 (sleipnir) Linux 2.4 (heping) Solaris 9 (shanti) Linux 2.4/64 (mir)
This commit is contained in:
parent
eb96132022
commit
4965bf1839
1
MANIFEST
1
MANIFEST
@ -497,6 +497,7 @@
|
||||
./src/H5HFhdr.c
|
||||
./src/H5HFiblock.c
|
||||
./src/H5HFint.c
|
||||
./src/H5HFiter.c
|
||||
./src/H5HFpkg.h
|
||||
./src/H5HFprivate.h
|
||||
./src/H5HFpublic.h
|
||||
|
325
src/H5HF.c
325
src/H5HF.c
@ -39,6 +39,7 @@
|
||||
/***********/
|
||||
#include "H5private.h" /* Generic Functions */
|
||||
#include "H5Eprivate.h" /* Error handling */
|
||||
#include "H5FOprivate.h" /* File objects */
|
||||
#include "H5HFpkg.h" /* Fractal heaps */
|
||||
#include "H5MFprivate.h" /* File memory management */
|
||||
|
||||
@ -66,8 +67,8 @@
|
||||
/* Package Variables */
|
||||
/*********************/
|
||||
|
||||
/* Declare a free list to manage the H5HF_t struct */
|
||||
H5FL_DEFINE(H5HF_t);
|
||||
/* Declare a free list to manage the H5HF_hdr_t struct */
|
||||
H5FL_DEFINE(H5HF_hdr_t);
|
||||
|
||||
|
||||
/*****************************/
|
||||
@ -79,6 +80,9 @@ H5FL_DEFINE(H5HF_t);
|
||||
/* Local Variables */
|
||||
/*******************/
|
||||
|
||||
/* Declare a free list to manage the H5HF_t struct */
|
||||
H5FL_DEFINE_STATIC(H5HF_t);
|
||||
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
@ -86,8 +90,8 @@ H5FL_DEFINE(H5HF_t);
|
||||
*
|
||||
* 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
|
||||
* Return: Pointer to heap wrapper on success
|
||||
* NULL on failure
|
||||
*
|
||||
* Programmer: Quincey Koziol
|
||||
* koziol@ncsa.uiuc.edu
|
||||
@ -95,54 +99,228 @@ H5FL_DEFINE(H5HF_t);
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
H5HF_create(H5F_t *f, hid_t dxpl_id, H5HF_create_t *cparam, haddr_t *addr_p,
|
||||
size_t *id_len_p)
|
||||
H5HF_t *
|
||||
H5HF_create(H5F_t *f, hid_t dxpl_id, H5HF_create_t *cparam)
|
||||
{
|
||||
H5HF_t *hdr = NULL; /* The new fractal heap header information */
|
||||
herr_t ret_value = SUCCEED; /* Return value */
|
||||
H5HF_t *fh = NULL; /* Pointer to new fractal heap */
|
||||
H5HF_hdr_t *hdr = NULL; /* The new fractal heap header information */
|
||||
haddr_t hdr_addr; /* Heap header address */
|
||||
H5HF_t *ret_value; /* Return value */
|
||||
|
||||
FUNC_ENTER_NOAPI(H5HF_create, FAIL)
|
||||
FUNC_ENTER_NOAPI(H5HF_create, NULL)
|
||||
|
||||
/*
|
||||
* Check arguments.
|
||||
*/
|
||||
HDassert(f);
|
||||
HDassert(cparam);
|
||||
HDassert(addr_p);
|
||||
HDassert(id_len_p);
|
||||
|
||||
/* Allocate & basic initialization for the shared header */
|
||||
if(NULL == (hdr = H5HF_hdr_alloc(f)))
|
||||
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate space for shared heap info")
|
||||
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate space for shared 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(hdr))))
|
||||
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "file allocation failed for fractal heap header")
|
||||
if(HADDR_UNDEF == (hdr_addr = H5MF_alloc(f, H5FD_MEM_FHEAP_HDR, dxpl_id, (hsize_t)H5HF_HEADER_SIZE(hdr))))
|
||||
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "file allocation failed for fractal heap header")
|
||||
|
||||
/* Initialize shared fractal heap header */
|
||||
if(H5HF_hdr_init(hdr, *addr_p, cparam) < 0)
|
||||
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't initialize shared fractal heap header")
|
||||
/* (This routine is only called for newly created heaps) */
|
||||
if(H5HF_hdr_init(hdr, hdr_addr, cparam) < 0)
|
||||
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't initialize shared fractal heap header")
|
||||
|
||||
/* Set the length of heap IDs */
|
||||
*id_len_p = hdr->id_len;
|
||||
#ifdef QAK
|
||||
HDfprintf(stderr, "%s: hdr->id_len = %Zu\n", FUNC, hdr->id_len);
|
||||
#endif /* QAK */
|
||||
|
||||
/* Cache the new fractal heap header */
|
||||
if(H5AC_set(f, dxpl_id, H5AC_FHEAP_HDR, *addr_p, hdr, H5AC__NO_FLAGS_SET) < 0)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't add fractal heap header to cache")
|
||||
if(H5AC_set(f, dxpl_id, H5AC_FHEAP_HDR, hdr_addr, hdr, H5AC__NO_FLAGS_SET) < 0)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, NULL, "can't add fractal heap header to cache")
|
||||
|
||||
/* Create fractal heap wrapper */
|
||||
if(NULL == (fh = H5FL_MALLOC(H5HF_t)))
|
||||
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for fractal heap info")
|
||||
|
||||
/* Lock the heap header into memory */
|
||||
#ifdef QAK
|
||||
HDfprintf(stderr, "%s: fh_addr = %a\n", FUNC, fh_addr);
|
||||
#endif /* QAK */
|
||||
if(NULL == (hdr = H5AC_protect(f, dxpl_id, H5AC_FHEAP_HDR, hdr_addr, NULL, NULL, H5AC_WRITE)))
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, NULL, "unable to load fractal heap header")
|
||||
|
||||
/* Point fractal heap wrapper at header */
|
||||
fh->hdr = hdr;
|
||||
if(H5HF_hdr_incr(fh->hdr) < 0)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, NULL, "can't increment reference count on shared heap header")
|
||||
|
||||
/* Unlock heap header, now pinned */
|
||||
if(H5AC_unprotect(f, dxpl_id, H5AC_FHEAP_HDR, hdr_addr, hdr, H5AC__NO_FLAGS_SET) < 0)
|
||||
HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, NULL, "unable to release fractal heap header")
|
||||
hdr = NULL;
|
||||
|
||||
/* Add heap to list of open objects in file */
|
||||
if(H5FO_insert(f, fh->hdr->heap_addr, fh) < 0)
|
||||
HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, NULL, "can't insert heap into list of open objects")
|
||||
|
||||
/* Set open object count */
|
||||
fh->fo_count = 1;
|
||||
|
||||
/* Set the return value */
|
||||
ret_value = fh;
|
||||
|
||||
done:
|
||||
if(ret_value < 0) {
|
||||
if(hdr)
|
||||
if(!ret_value) {
|
||||
if(fh)
|
||||
(void)H5HF_close(fh);
|
||||
else if(hdr)
|
||||
(void)H5HF_cache_hdr_dest(f, hdr);
|
||||
} /* end if */
|
||||
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* end H5HF_create() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5HF_open
|
||||
*
|
||||
* Purpose: Opens an existing fractal heap in the file.
|
||||
*
|
||||
* Return: Pointer to heap wrapper on success
|
||||
* NULL on failure
|
||||
*
|
||||
* Programmer: Quincey Koziol
|
||||
* koziol@ncsa.uiuc.edu
|
||||
* Apr 18 2006
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
H5HF_t *
|
||||
H5HF_open(H5F_t *f, hid_t dxpl_id, haddr_t fh_addr)
|
||||
{
|
||||
H5HF_t *fh = NULL; /* Pointer to new fractal heap */
|
||||
H5HF_hdr_t *hdr = NULL; /* The new fractal heap header information */
|
||||
H5HF_t *ret_value; /* Return value */
|
||||
|
||||
FUNC_ENTER_NOAPI(H5HF_open, NULL)
|
||||
|
||||
/*
|
||||
* Check arguments.
|
||||
*/
|
||||
HDassert(f);
|
||||
HDassert(H5F_addr_defined(fh_addr));
|
||||
|
||||
/* Check if group was already open */
|
||||
if((fh = H5FO_opened(f, fh_addr)) == NULL) {
|
||||
|
||||
/* Clear any errors from H5FO_opened() */
|
||||
H5E_clear_stack(NULL);
|
||||
|
||||
/* Load the heap header into memory */
|
||||
#ifdef QAK
|
||||
HDfprintf(stderr, "%s: fh_addr = %a\n", FUNC, fh_addr);
|
||||
#endif /* QAK */
|
||||
if(NULL == (hdr = H5AC_protect(f, dxpl_id, H5AC_FHEAP_HDR, fh_addr, NULL, NULL, H5AC_READ)))
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "unable to load fractal heap header")
|
||||
#ifdef QAK
|
||||
HDfprintf(stderr, "%s: hdr->rc = %u\n", FUNC, hdr->rc);
|
||||
#endif /* QAK */
|
||||
|
||||
/* Create fractal heap info */
|
||||
if(NULL == (fh = H5FL_MALLOC(H5HF_t)))
|
||||
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for fractal heap info")
|
||||
|
||||
/* Point fractal heap wrapper at header */
|
||||
fh->hdr = hdr;
|
||||
if(H5HF_hdr_incr(fh->hdr) < 0)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, NULL, "can't increment reference count on shared heap header")
|
||||
|
||||
/* Add heap to list of open objects in file */
|
||||
if(H5FO_insert(f, fh->hdr->heap_addr, fh) < 0)
|
||||
HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, NULL, "can't insert heap into list of open objects")
|
||||
|
||||
/* Set open object count */
|
||||
fh->fo_count = 1;
|
||||
} /* end if */
|
||||
else {
|
||||
/* Increment shared reference count */
|
||||
fh->fo_count++;
|
||||
} /* end else */
|
||||
|
||||
/* Set the return value */
|
||||
ret_value = fh;
|
||||
|
||||
done:
|
||||
if(hdr && H5AC_unprotect(f, dxpl_id, H5AC_FHEAP_HDR, fh_addr, hdr, H5AC__NO_FLAGS_SET) < 0)
|
||||
HDONE_ERROR(H5E_HEAP, H5E_PROTECT, NULL, "unable to release fractal heap header")
|
||||
if(!ret_value) {
|
||||
if(fh)
|
||||
(void)H5HF_close(fh);
|
||||
} /* end if */
|
||||
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* end H5HF_open() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5HF_get_id_len
|
||||
*
|
||||
* Purpose: Get the size of IDs for entries in a fractal heap
|
||||
*
|
||||
* Return: SUCCEED/FAIL
|
||||
*
|
||||
* Programmer: Quincey Koziol
|
||||
* koziol@ncsa.uiuc.edu
|
||||
* Apr 17 2006
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
H5HF_get_id_len(H5HF_t *fh, size_t *id_len_p)
|
||||
{
|
||||
FUNC_ENTER_NOAPI_NOFUNC(H5HF_get_id_len)
|
||||
|
||||
/*
|
||||
* Check arguments.
|
||||
*/
|
||||
HDassert(fh);
|
||||
HDassert(id_len_p);
|
||||
|
||||
/* Retrieve the ID length for entries in this heap */
|
||||
*id_len_p = fh->hdr->id_len;
|
||||
|
||||
FUNC_LEAVE_NOAPI(SUCCEED)
|
||||
} /* end H5HF_get_id_len() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5HF_get_heap_addr
|
||||
*
|
||||
* Purpose: Get the address of a fractal heap
|
||||
*
|
||||
* Return: SUCCEED/FAIL
|
||||
*
|
||||
* Programmer: Quincey Koziol
|
||||
* koziol@ncsa.uiuc.edu
|
||||
* Apr 18 2006
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
H5HF_get_heap_addr(H5HF_t *fh, haddr_t *heap_addr_p)
|
||||
{
|
||||
FUNC_ENTER_NOAPI_NOFUNC(H5HF_get_heap_addr)
|
||||
|
||||
/*
|
||||
* Check arguments.
|
||||
*/
|
||||
HDassert(fh);
|
||||
HDassert(heap_addr_p);
|
||||
|
||||
/* Retrieve the heap header address for this heap */
|
||||
*heap_addr_p = fh->hdr->heap_addr;
|
||||
|
||||
FUNC_LEAVE_NOAPI(SUCCEED)
|
||||
} /* end H5HF_get_heap_addr() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5HF_insert
|
||||
@ -159,11 +337,10 @@ done:
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
H5HF_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr, size_t size,
|
||||
const void *obj, void *id/*out*/)
|
||||
H5HF_insert(H5HF_t *fh, hid_t dxpl_id, size_t size, const void *obj,
|
||||
void *id/*out*/)
|
||||
{
|
||||
H5HF_t *hdr = NULL; /* The fractal heap header information */
|
||||
unsigned hdr_flags = H5AC__NO_FLAGS_SET; /* Metadata cache flags for header */
|
||||
H5HF_hdr_t *hdr = NULL; /* The fractal heap header information */
|
||||
herr_t ret_value = SUCCEED;
|
||||
|
||||
FUNC_ENTER_NOAPI(H5HF_insert, FAIL)
|
||||
@ -174,17 +351,13 @@ HDfprintf(stderr, "%s: size = %Zu\n", FUNC, size);
|
||||
/*
|
||||
* Check arguments.
|
||||
*/
|
||||
HDassert(f);
|
||||
HDassert(H5F_addr_defined(addr));
|
||||
HDassert(fh);
|
||||
HDassert(size > 0);
|
||||
HDassert(obj);
|
||||
HDassert(id);
|
||||
|
||||
/*
|
||||
* Load the fractal heap header.
|
||||
*/
|
||||
if(NULL == (hdr = H5AC_protect(f, dxpl_id, H5AC_FHEAP_HDR, addr, NULL, NULL, H5AC_WRITE)))
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load fractal heap header")
|
||||
/* Get the fractal heap header */
|
||||
hdr = fh->hdr;
|
||||
|
||||
/* Check if object is large enough to be standalone */
|
||||
if(size >= hdr->standalone_size) {
|
||||
@ -208,14 +381,7 @@ HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "'write once' managed blocks not su
|
||||
} /* end else */
|
||||
} /* end else */
|
||||
|
||||
/* Check for making header dirty */
|
||||
if(hdr->dirty)
|
||||
hdr_flags |= H5AC__DIRTIED_FLAG;
|
||||
|
||||
done:
|
||||
if(hdr && H5AC_unprotect(f, dxpl_id, H5AC_FHEAP_HDR, addr, hdr, hdr_flags) < 0)
|
||||
HDONE_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to release fractal heap header")
|
||||
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* end H5HF_insert() */
|
||||
|
||||
@ -234,10 +400,9 @@ done:
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
H5HF_read(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_id,
|
||||
void *obj/*out*/)
|
||||
H5HF_read(H5HF_t *fh, hid_t dxpl_id, const void *_id, void *obj/*out*/)
|
||||
{
|
||||
H5HF_t *hdr = NULL; /* The fractal heap header information */
|
||||
H5HF_hdr_t *hdr = NULL; /* The fractal heap header information */
|
||||
const uint8_t *id = (const uint8_t *)_id; /* Object ID */
|
||||
hsize_t obj_off; /* Object's offset in heap */
|
||||
size_t obj_len; /* Object's length in heap */
|
||||
@ -248,16 +413,12 @@ H5HF_read(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_id,
|
||||
/*
|
||||
* Check arguments.
|
||||
*/
|
||||
HDassert(f);
|
||||
HDassert(H5F_addr_defined(addr));
|
||||
HDassert(fh);
|
||||
HDassert(id);
|
||||
HDassert(obj);
|
||||
|
||||
/*
|
||||
* Load the fractal heap header.
|
||||
*/
|
||||
if(NULL == (hdr = H5AC_protect(f, dxpl_id, H5AC_FHEAP_HDR, addr, NULL, NULL, H5AC_READ)))
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load fractal heap header")
|
||||
/* Get the fractal heap header */
|
||||
hdr = fh->hdr;
|
||||
|
||||
/* Decode the object offset within the heap & it's length */
|
||||
UINT64DECODE_VAR(id, obj_off, hdr->heap_off_size);
|
||||
@ -277,9 +438,65 @@ HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "standalone blocks not supported ye
|
||||
} /* end else */
|
||||
|
||||
done:
|
||||
if(hdr && H5AC_unprotect(f, dxpl_id, H5AC_FHEAP_HDR, addr, hdr, H5AC__NO_FLAGS_SET) < 0)
|
||||
HDONE_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to release fractal heap header")
|
||||
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* end H5HF_read() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5HF_close
|
||||
*
|
||||
* Purpose: Close a fractal heap wrapper
|
||||
*
|
||||
* Return: SUCCEED/FAIL
|
||||
*
|
||||
* Programmer: Quincey Koziol
|
||||
* koziol@ncsa.uiuc.edu
|
||||
* Apr 17 2006
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
H5HF_close(H5HF_t *fh)
|
||||
{
|
||||
herr_t ret_value = SUCCEED;
|
||||
|
||||
FUNC_ENTER_NOAPI(H5HF_close, FAIL)
|
||||
|
||||
/*
|
||||
* Check arguments.
|
||||
*/
|
||||
HDassert(fh);
|
||||
|
||||
/* Decrement shared object count */
|
||||
--fh->fo_count;
|
||||
|
||||
/* Check if this is the last reference to the shared heap wrapper */
|
||||
if(0 == fh->fo_count) {
|
||||
/* Remove the heap from the list of opened objects in the file */
|
||||
if(H5FO_delete(fh->hdr->f, H5AC_dxpl_id, fh->hdr->heap_addr) < 0)
|
||||
HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't remove group from list of open objects")
|
||||
|
||||
/* Reset the free list information */
|
||||
/* (Bump the "generation" counter in case this heap header is still
|
||||
* in the cache when the heap is re-opened -QAK)
|
||||
*/
|
||||
H5HF_flist_reset(fh->hdr->flist);
|
||||
fh->hdr->fl_gen++;
|
||||
fh->hdr->freelist_sync = FALSE;
|
||||
|
||||
/* Reset the block iterator */
|
||||
if(H5HF_man_iter_reset(&fh->hdr->next_block) < 0)
|
||||
HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't reset block iterator")
|
||||
|
||||
/* Decrement the reference count on the heap header */
|
||||
if(H5HF_hdr_decr(fh->hdr) < 0)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared heap header")
|
||||
|
||||
/* Release the fractal heap wrapper */
|
||||
H5FL_FREE(H5HF_t, fh);
|
||||
} /* end if */
|
||||
|
||||
done:
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* end H5HF_close() */
|
||||
|
||||
|
362
src/H5HFcache.c
362
src/H5HFcache.c
@ -62,10 +62,10 @@
|
||||
/********************/
|
||||
|
||||
/* Metadata cache callbacks */
|
||||
static H5HF_t *H5HF_cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *udata, void *udata2);
|
||||
static herr_t H5HF_cache_hdr_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5HF_t *hdr);
|
||||
static herr_t H5HF_cache_hdr_clear(H5F_t *f, H5HF_t *hdr, hbool_t destroy);
|
||||
static herr_t H5HF_cache_hdr_size(const H5F_t *f, const H5HF_t *hdr, size_t *size_ptr);
|
||||
static H5HF_hdr_t *H5HF_cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *udata, void *udata2);
|
||||
static herr_t H5HF_cache_hdr_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5HF_hdr_t *hdr);
|
||||
static herr_t H5HF_cache_hdr_clear(H5F_t *f, H5HF_hdr_t *hdr, hbool_t destroy);
|
||||
static herr_t H5HF_cache_hdr_size(const H5F_t *f, const H5HF_hdr_t *hdr, size_t *size_ptr);
|
||||
static H5HF_direct_t *H5HF_cache_dblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *udata, void *udata2);
|
||||
static herr_t H5HF_cache_dblock_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5HF_direct_t *dblock);
|
||||
static herr_t H5HF_cache_dblock_clear(H5F_t *f, H5HF_direct_t *dblock, hbool_t destroy);
|
||||
@ -249,17 +249,17 @@ H5HF_dtable_encode(H5F_t *f, uint8_t **pp, const H5HF_dtable_t *dtable)
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static H5HF_t *
|
||||
static H5HF_hdr_t *
|
||||
H5HF_cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED *udata1, void UNUSED *udata2)
|
||||
{
|
||||
H5HF_t *hdr = NULL; /* Fractal heap info */
|
||||
H5HF_hdr_t *hdr = NULL; /* Fractal heap info */
|
||||
size_t size; /* Header size */
|
||||
uint8_t *buf = NULL; /* Temporary buffer */
|
||||
const uint8_t *p; /* Pointer into raw data buffer */
|
||||
uint32_t metadata_chksum; /* Metadata checksum value */
|
||||
H5HF_t *ret_value; /* Return value */
|
||||
H5HF_hdr_t *ret_value; /* Return value */
|
||||
|
||||
FUNC_ENTER_NOAPI(H5HF_cache_hdr_load, NULL)
|
||||
FUNC_ENTER_NOAPI_NOINIT(H5HF_cache_hdr_load)
|
||||
#ifdef QAK
|
||||
HDfprintf(stderr, "%s: Load heap header, addr = %a\n", FUNC, addr);
|
||||
#endif /* QAK */
|
||||
@ -324,6 +324,7 @@ HDfprintf(stderr, "%s: Load heap header, addr = %a\n", FUNC, addr);
|
||||
/* Statistics information */
|
||||
H5F_DECODE_LENGTH(f, p, hdr->total_size);
|
||||
H5F_DECODE_LENGTH(f, p, hdr->man_size);
|
||||
H5F_DECODE_LENGTH(f, p, hdr->man_alloc_size);
|
||||
H5F_DECODE_LENGTH(f, p, hdr->std_size);
|
||||
H5F_DECODE_LENGTH(f, p, hdr->nobjs);
|
||||
|
||||
@ -333,9 +334,18 @@ HDfprintf(stderr, "%s: Load heap header, addr = %a\n", FUNC, addr);
|
||||
|
||||
HDassert((size_t)(p - buf) == size);
|
||||
|
||||
/* Make shared heap info reference counted */
|
||||
/* If the heap has any blocks stored, the memory free list is out of sync */
|
||||
if(H5F_addr_defined(hdr->man_dtable.table_addr))
|
||||
hdr->freelist_sync = FALSE;
|
||||
else
|
||||
hdr->freelist_sync = TRUE;
|
||||
|
||||
/* Finish initialization of heap header */
|
||||
if(H5HF_hdr_finish_init(hdr) < 0)
|
||||
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't create ref-count wrapper for shared fractal heap header")
|
||||
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, NULL, "can't finish initializing shared fractal heap header")
|
||||
#ifdef QAK
|
||||
HDfprintf(stderr, "%s: hdr->flist = %p\n", FUNC, hdr->flist);
|
||||
#endif /* QAK */
|
||||
|
||||
/* Set return value */
|
||||
ret_value = hdr;
|
||||
@ -364,11 +374,11 @@ done:
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static herr_t
|
||||
H5HF_cache_hdr_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5HF_t *hdr)
|
||||
H5HF_cache_hdr_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5HF_hdr_t *hdr)
|
||||
{
|
||||
herr_t ret_value = SUCCEED; /* Return value */
|
||||
|
||||
FUNC_ENTER_NOAPI(H5HF_cache_hdr_flush, FAIL)
|
||||
FUNC_ENTER_NOAPI_NOINIT(H5HF_cache_hdr_flush)
|
||||
#ifdef QAK
|
||||
HDfprintf(stderr, "%s: Flushing heap header, addr = %a, destroy = %u\n", FUNC, addr, (unsigned)destroy);
|
||||
#endif /* QAK */
|
||||
@ -424,6 +434,7 @@ HDfprintf(stderr, "%s: Flushing heap header, addr = %a, destroy = %u\n", FUNC, a
|
||||
/* Statistics information */
|
||||
H5F_ENCODE_LENGTH(f, p, hdr->total_size);
|
||||
H5F_ENCODE_LENGTH(f, p, hdr->man_size);
|
||||
H5F_ENCODE_LENGTH(f, p, hdr->man_alloc_size);
|
||||
H5F_ENCODE_LENGTH(f, p, hdr->std_size);
|
||||
H5F_ENCODE_LENGTH(f, p, hdr->nobjs);
|
||||
|
||||
@ -450,47 +461,6 @@ done:
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* H5HF_cache_hdr_flush() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5HF_cache_hdr_dest_real
|
||||
*
|
||||
* 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
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
H5HF_cache_hdr_dest_real(H5HF_t *hdr)
|
||||
{
|
||||
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_cache_hdr_dest_real)
|
||||
|
||||
/*
|
||||
* Check arguments.
|
||||
*/
|
||||
HDassert(hdr);
|
||||
/* XXX: Take out this goofy routine, after metadata cache is supporting
|
||||
* "un-evictable" flag
|
||||
*/
|
||||
if(hdr->rc == 0 && hdr->evicted == TRUE) {
|
||||
/* Free the free list information for the heap */
|
||||
if(hdr->flist)
|
||||
H5HF_flist_free(hdr->flist);
|
||||
|
||||
/* Free the block size lookup table for the doubling table */
|
||||
H5HF_dtable_dest(&hdr->man_dtable);
|
||||
|
||||
/* Free the shared info itself */
|
||||
H5FL_FREE(H5HF_t, hdr);
|
||||
} /* end if */
|
||||
|
||||
FUNC_LEAVE_NOAPI(SUCCEED)
|
||||
} /* end H5HF_cache_hdr_dest_real() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5HF_cache_hdr_dest
|
||||
@ -507,7 +477,7 @@ H5HF_cache_hdr_dest_real(H5HF_t *hdr)
|
||||
*/
|
||||
/* ARGSUSED */
|
||||
herr_t
|
||||
H5HF_cache_hdr_dest(H5F_t UNUSED *f, H5HF_t *hdr)
|
||||
H5HF_cache_hdr_dest(H5F_t UNUSED *f, H5HF_hdr_t *hdr)
|
||||
{
|
||||
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_cache_hdr_dest)
|
||||
|
||||
@ -515,17 +485,16 @@ H5HF_cache_hdr_dest(H5F_t UNUSED *f, H5HF_t *hdr)
|
||||
* Check arguments.
|
||||
*/
|
||||
HDassert(hdr);
|
||||
/* XXX: Enable this after the metadata cache supports the "un-evictable" flag */
|
||||
/* HDassert(hdr->rc == 0); */
|
||||
/* XXX: Take out this goofy 'if' statement, after metadata cache is supporting
|
||||
* "un-evictable" flag
|
||||
*/
|
||||
/* XXX: Take out 'evicted' flag after "un-evictable" flag is working */
|
||||
hdr->evicted = TRUE;
|
||||
/* XXX: Take out this goofy routine, after metadata cache is supporting
|
||||
* "un-evictable" flag
|
||||
*/
|
||||
H5HF_cache_hdr_dest_real(hdr);
|
||||
HDassert(hdr->rc == 0);
|
||||
|
||||
/* Free the free list section information */
|
||||
H5HF_flist_free(hdr->flist);
|
||||
|
||||
/* Free the block size lookup table for the doubling table */
|
||||
H5HF_dtable_dest(&hdr->man_dtable);
|
||||
|
||||
/* Free the shared info itself */
|
||||
H5FL_FREE(H5HF_hdr_t, hdr);
|
||||
|
||||
FUNC_LEAVE_NOAPI(SUCCEED)
|
||||
} /* end H5HF_cache_hdr_dest() */
|
||||
@ -545,7 +514,7 @@ H5HF_cache_hdr_dest(H5F_t UNUSED *f, H5HF_t *hdr)
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static herr_t
|
||||
H5HF_cache_hdr_clear(H5F_t *f, H5HF_t *hdr, hbool_t destroy)
|
||||
H5HF_cache_hdr_clear(H5F_t *f, H5HF_hdr_t *hdr, hbool_t destroy)
|
||||
{
|
||||
herr_t ret_value = SUCCEED; /* Return value */
|
||||
|
||||
@ -584,7 +553,7 @@ done:
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static herr_t
|
||||
H5HF_cache_hdr_size(const H5F_t *f, const H5HF_t *hdr, size_t *size_ptr)
|
||||
H5HF_cache_hdr_size(const H5F_t UNUSED *f, const H5HF_hdr_t *hdr, size_t *size_ptr)
|
||||
{
|
||||
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_cache_hdr_size)
|
||||
|
||||
@ -616,22 +585,22 @@ H5HF_cache_hdr_size(const H5F_t *f, const H5HF_t *hdr, size_t *size_ptr)
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static H5HF_direct_t *
|
||||
H5HF_cache_dblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_size, void *_hdr)
|
||||
H5HF_cache_dblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_size, void *_par_info)
|
||||
{
|
||||
const size_t *size = (const size_t *)_size; /* Size of block */
|
||||
H5HF_t *hdr = (H5HF_t *)_hdr; /* Shared heap header information */
|
||||
H5HF_parent_t *par_info = (H5HF_parent_t *)_par_info; /* Pointer to parent information */
|
||||
H5HF_direct_t *dblock = NULL; /* Direct block info */
|
||||
const uint8_t *p; /* Pointer into raw data buffer */
|
||||
haddr_t heap_addr; /* Address of heap header in the file */
|
||||
uint32_t metadata_chksum; /* Metadata checksum value */
|
||||
H5HF_direct_t *ret_value; /* Return value */
|
||||
|
||||
FUNC_ENTER_NOAPI(H5HF_cache_dblock_load, NULL)
|
||||
FUNC_ENTER_NOAPI_NOINIT(H5HF_cache_dblock_load)
|
||||
|
||||
/* Check arguments */
|
||||
HDassert(f);
|
||||
HDassert(H5F_addr_defined(addr));
|
||||
HDassert(hdr);
|
||||
HDassert(par_info);
|
||||
|
||||
/* Allocate space for the fractal heap direct block */
|
||||
if(NULL == (dblock = H5FL_MALLOC(H5HF_direct_t)))
|
||||
@ -639,14 +608,15 @@ H5HF_cache_dblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_size,
|
||||
HDmemset(&dblock->cache_info, 0, sizeof(H5AC_info_t));
|
||||
|
||||
/* Share common heap information */
|
||||
dblock->shared = hdr;
|
||||
if(H5HF_hdr_incr(hdr) < 0)
|
||||
dblock->hdr = par_info->hdr;
|
||||
if(H5HF_hdr_incr(dblock->hdr) < 0)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, NULL, "can't increment reference count on shared heap header")
|
||||
|
||||
/* Set block's internal information */
|
||||
dblock->size = *size;
|
||||
dblock->blk_off_size = H5HF_SIZEOF_OFFSET_LEN(dblock->size);
|
||||
dblock->free_list = NULL;
|
||||
dblock->fl_gen = 0;
|
||||
|
||||
/* Allocate block buffer */
|
||||
/* XXX: Change to using free-list factories */
|
||||
@ -681,48 +651,27 @@ H5HF_cache_dblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_size,
|
||||
|
||||
/* Address of heap that owns this block (skip) */
|
||||
H5F_addr_decode(f, &p, &heap_addr);
|
||||
if(H5F_addr_ne(heap_addr, hdr->heap_addr))
|
||||
if(H5F_addr_ne(heap_addr, dblock->hdr->heap_addr))
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "incorrect heap header address for direct block")
|
||||
|
||||
/* Address of parent block */
|
||||
H5F_addr_decode(f, &p, &dblock->par_addr);
|
||||
UINT16DECODE(p, dblock->par_entry);
|
||||
UINT16DECODE(p, dblock->par_nrows);
|
||||
if(H5F_addr_defined(dblock->par_addr)) {
|
||||
H5HF_indirect_t *iblock; /* Pointer to parent indirect block */
|
||||
|
||||
/* Check for direct block as a child of the root indirect block
|
||||
* and retrieve the # of rows in the root indirect block from
|
||||
* the shared heap header, because the root indirect block can
|
||||
* change size.
|
||||
*/
|
||||
if(H5F_addr_eq(iblock->par_addr, hdr->man_dtable.table_addr))
|
||||
dblock->par_nrows = hdr->man_dtable.curr_root_rows;
|
||||
|
||||
/* Protect parent indirect block */
|
||||
if(NULL == (iblock = H5AC_protect(f, dxpl_id, H5AC_FHEAP_IBLOCK, dblock->par_addr, &dblock->par_nrows, hdr, hdr->mode)))
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, NULL, "unable to protect fractal heap indirect block")
|
||||
|
||||
dblock->parent = par_info->iblock;
|
||||
dblock->par_entry = par_info->entry;
|
||||
if(dblock->parent) {
|
||||
/* Share parent block */
|
||||
dblock->parent = iblock;
|
||||
if(H5HF_iblock_incr(iblock) < 0)
|
||||
if(H5HF_iblock_incr(dblock->parent) < 0)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, NULL, "can't increment reference count on shared indirect block")
|
||||
|
||||
/* Retrieve this block's free space from parent */
|
||||
dblock->blk_free_space = iblock->ents[dblock->par_entry].free_space;
|
||||
|
||||
/* Release the indirect block */
|
||||
if(H5AC_unprotect(f, dxpl_id, H5AC_FHEAP_IBLOCK, dblock->par_addr, iblock, H5AC__NO_FLAGS_SET) < 0)
|
||||
HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, NULL, "unable to release fractal heap indirect block")
|
||||
dblock->blk_free_space = dblock->parent->ents[dblock->par_entry].free_space;
|
||||
} /* end if */
|
||||
else {
|
||||
/* Direct block is linked directly from heap header */
|
||||
dblock->parent = NULL;
|
||||
dblock->blk_free_space = hdr->total_man_free;
|
||||
dblock->blk_free_space = dblock->hdr->total_man_free;
|
||||
} /* end else */
|
||||
|
||||
/* Offset of heap within the heap's address space */
|
||||
UINT64DECODE_VAR(p, dblock->block_off, hdr->heap_off_size);
|
||||
UINT64DECODE_VAR(p, dblock->block_off, dblock->hdr->heap_off_size);
|
||||
|
||||
/* Offset of free list head */
|
||||
/* (Defer deserializing the whole free list until we actually need to modify it) */
|
||||
@ -757,7 +706,7 @@ H5HF_cache_dblock_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr,
|
||||
{
|
||||
herr_t ret_value = SUCCEED; /* Return value */
|
||||
|
||||
FUNC_ENTER_NOAPI(H5HF_cache_dblock_flush, FAIL)
|
||||
FUNC_ENTER_NOAPI_NOINIT(H5HF_cache_dblock_flush)
|
||||
|
||||
/* check arguments */
|
||||
HDassert(f);
|
||||
@ -765,11 +714,11 @@ H5HF_cache_dblock_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr,
|
||||
HDassert(dblock);
|
||||
|
||||
if(dblock->cache_info.is_dirty) {
|
||||
H5HF_t *hdr; /* Shared fractal heap information */
|
||||
H5HF_hdr_t *hdr; /* Shared fractal heap information */
|
||||
uint8_t *p; /* Pointer into raw data buffer */
|
||||
|
||||
/* Get the pointer to the shared heap header */
|
||||
hdr = dblock->shared;
|
||||
hdr = dblock->hdr;
|
||||
|
||||
p = dblock->blk;
|
||||
|
||||
@ -792,11 +741,6 @@ H5HF_cache_dblock_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr,
|
||||
/* Address of heap header for heap which owns this block */
|
||||
H5F_addr_encode(f, &p, hdr->heap_addr);
|
||||
|
||||
/* Info for parent block of this block */
|
||||
H5F_addr_encode(f, &p, dblock->par_addr);
|
||||
UINT16ENCODE(p, dblock->par_entry);
|
||||
UINT16ENCODE(p, dblock->par_nrows);
|
||||
|
||||
/* Offset of block in heap */
|
||||
UINT64ENCODE_VAR(p, dblock->block_off, hdr->heap_off_size);
|
||||
|
||||
@ -888,33 +832,17 @@ H5HF_cache_dblock_dest(H5F_t UNUSED *f, H5HF_direct_t *dblock)
|
||||
HDassert(dblock);
|
||||
|
||||
/* Decrement reference count on shared fractal heap info */
|
||||
HDassert(dblock->shared);
|
||||
if(H5HF_hdr_decr(dblock->shared) < 0)
|
||||
HDassert(dblock->hdr);
|
||||
if(H5HF_hdr_decr(dblock->hdr) < 0)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared heap header")
|
||||
if(dblock->parent)
|
||||
if(H5HF_iblock_decr(dblock->parent) < 0)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared indirect block")
|
||||
|
||||
/* Check for free list & free it, if necessary */
|
||||
if(dblock->free_list) {
|
||||
H5HF_direct_free_node_t *node; /* Pointer to free list node for block */
|
||||
|
||||
/* Walk through list, freeing the nodes */
|
||||
node = dblock->free_list->first;
|
||||
while(node) {
|
||||
H5HF_direct_free_node_t *last_node; /* Pointer to last free list node for block */
|
||||
|
||||
/* Advance to next node */
|
||||
last_node = node;
|
||||
node = node->next;
|
||||
|
||||
/* Release the last node */
|
||||
H5FL_FREE(H5HF_direct_free_node_t, last_node);
|
||||
} /* end while */
|
||||
|
||||
/* Release the free list head */
|
||||
H5FL_FREE(H5HF_direct_free_head_t, dblock->free_list);
|
||||
} /* end if */
|
||||
if(dblock->free_list)
|
||||
if(H5HF_man_dblock_destroy_freelist(dblock) < 0)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't destroy free list for direct block")
|
||||
|
||||
/* Free block's buffer */
|
||||
H5FL_BLK_FREE(direct_block, dblock->blk);
|
||||
@ -1014,10 +942,10 @@ H5HF_cache_dblock_size(const H5F_t UNUSED *f, const H5HF_direct_t *dblock, size_
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static H5HF_indirect_t *
|
||||
H5HF_cache_iblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_nrows, void *_hdr)
|
||||
H5HF_cache_iblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_nrows, void *_par_info)
|
||||
{
|
||||
const unsigned *nrows = (const unsigned *)_nrows; /* # of rows in indirect block */
|
||||
H5HF_t *hdr = (H5HF_t *)_hdr; /* Shared header information */
|
||||
H5HF_parent_t *par_info = (H5HF_parent_t *)_par_info; /* Shared parent information */
|
||||
H5HF_indirect_t *iblock = NULL; /* Indirect block info */
|
||||
uint8_t *buf = NULL; /* Temporary buffer */
|
||||
const uint8_t *p; /* Pointer into raw data buffer */
|
||||
@ -1029,7 +957,7 @@ H5HF_cache_iblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_nrows
|
||||
size_t u; /* Local index variable */
|
||||
H5HF_indirect_t *ret_value; /* Return value */
|
||||
|
||||
FUNC_ENTER_NOAPI(H5HF_cache_iblock_load, NULL)
|
||||
FUNC_ENTER_NOAPI_NOINIT(H5HF_cache_iblock_load)
|
||||
#ifdef QAK
|
||||
HDfprintf(stderr, "%s: Load indirect block, addr = %a\n", FUNC, addr);
|
||||
#endif /* QAK */
|
||||
@ -1037,7 +965,7 @@ HDfprintf(stderr, "%s: Load indirect block, addr = %a\n", FUNC, addr);
|
||||
/* Check arguments */
|
||||
HDassert(f);
|
||||
HDassert(H5F_addr_defined(addr));
|
||||
HDassert(hdr);
|
||||
HDassert(par_info);
|
||||
|
||||
/* Allocate space for the fractal heap indirect block */
|
||||
if(NULL == (iblock = H5FL_MALLOC(H5HF_indirect_t)))
|
||||
@ -1045,8 +973,8 @@ HDfprintf(stderr, "%s: Load indirect block, addr = %a\n", FUNC, addr);
|
||||
HDmemset(&iblock->cache_info, 0, sizeof(H5AC_info_t));
|
||||
|
||||
/* Share common heap information */
|
||||
iblock->shared = hdr;
|
||||
if(H5HF_hdr_incr(hdr) < 0)
|
||||
iblock->hdr = par_info->hdr;
|
||||
if(H5HF_hdr_incr(iblock->hdr) < 0)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, NULL, "can't increment reference count on shared heap header")
|
||||
|
||||
/* Set block's internal information */
|
||||
@ -1054,10 +982,10 @@ HDfprintf(stderr, "%s: Load indirect block, addr = %a\n", FUNC, addr);
|
||||
iblock->nrows = *nrows;
|
||||
iblock->addr = addr;
|
||||
iblock->dirty = FALSE;
|
||||
iblock->evicted = FALSE;
|
||||
iblock->fl_gen = 0;
|
||||
|
||||
/* Compute size of indirect block */
|
||||
iblock->size = H5HF_MAN_INDIRECT_SIZE(hdr, iblock);
|
||||
iblock->size = H5HF_MAN_INDIRECT_SIZE(iblock->hdr, iblock);
|
||||
|
||||
/* Allocate buffer to decode block */
|
||||
/* XXX: Use free list factories? */
|
||||
@ -1092,89 +1020,60 @@ HDfprintf(stderr, "%s: Load indirect block, addr = %a\n", FUNC, addr);
|
||||
|
||||
/* Address of heap that owns this block */
|
||||
H5F_addr_decode(f, &p, &heap_addr);
|
||||
if(H5F_addr_ne(heap_addr, hdr->heap_addr))
|
||||
if(H5F_addr_ne(heap_addr, iblock->hdr->heap_addr))
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "incorrect heap header address for direct block")
|
||||
|
||||
/* Address of parent block */
|
||||
H5F_addr_decode(f, &p, &iblock->par_addr);
|
||||
UINT16DECODE(p, iblock->par_entry);
|
||||
UINT16DECODE(p, iblock->par_nrows);
|
||||
if(H5F_addr_defined(iblock->par_addr)) {
|
||||
H5HF_indirect_t *tmp_iblock; /* Pointer to parent indirect block */
|
||||
|
||||
/* Check for indirect block as a child of the root indirect block
|
||||
* and retrieve the # of rows in the root indirect block from
|
||||
* the shared heap header, because the root indirect block can
|
||||
* change size.
|
||||
*/
|
||||
if(H5F_addr_eq(iblock->par_addr, hdr->man_dtable.table_addr))
|
||||
iblock->par_nrows = hdr->man_dtable.curr_root_rows;
|
||||
|
||||
/* Protect parent indirect block */
|
||||
if(NULL == (tmp_iblock = H5AC_protect(f, dxpl_id, H5AC_FHEAP_IBLOCK, iblock->par_addr, &iblock->par_nrows, hdr, hdr->mode)))
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, NULL, "unable to protect fractal heap indirect block")
|
||||
|
||||
iblock->parent = par_info->iblock;
|
||||
iblock->par_entry = par_info->entry;
|
||||
if(iblock->parent) {
|
||||
/* Share parent block */
|
||||
iblock->parent = tmp_iblock;
|
||||
if(H5HF_iblock_incr(tmp_iblock) < 0)
|
||||
if(H5HF_iblock_incr(iblock->parent) < 0)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, NULL, "can't increment reference count on shared indirect block")
|
||||
|
||||
/* Retrieve this block's free space from parent */
|
||||
iblock->child_free_space = tmp_iblock->ents[iblock->par_entry].free_space;
|
||||
|
||||
/* Release the indirect block */
|
||||
if(H5AC_unprotect(f, dxpl_id, H5AC_FHEAP_IBLOCK, iblock->par_addr, tmp_iblock, H5AC__NO_FLAGS_SET) < 0)
|
||||
HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, NULL, "unable to release fractal heap indirect block")
|
||||
tmp_iblock = NULL;
|
||||
iblock->child_free_space = iblock->parent->ents[iblock->par_entry].free_space;
|
||||
|
||||
/* Set max. # of rows in this block */
|
||||
iblock->max_rows = iblock->nrows;
|
||||
} /* end if */
|
||||
else {
|
||||
/* Direct block is linked directly from heap header */
|
||||
iblock->parent = NULL;
|
||||
iblock->child_free_space = hdr->total_man_free;
|
||||
iblock->child_free_space = iblock->hdr->total_man_free;
|
||||
|
||||
/* Set max. # of rows in this block */
|
||||
iblock->max_rows = hdr->man_dtable.max_root_rows;
|
||||
iblock->max_rows = iblock->hdr->man_dtable.max_root_rows;
|
||||
} /* end else */
|
||||
|
||||
/* Offset of heap within the heap's address space */
|
||||
UINT64DECODE_VAR(p, iblock->block_off, hdr->heap_off_size);
|
||||
|
||||
/* Offset of next entry to allocate within this block */
|
||||
UINT32DECODE(p, iblock->next_entry);
|
||||
|
||||
/* Compute next block column, row & size */
|
||||
iblock->next_col = iblock->next_entry % hdr->man_dtable.cparam.width;
|
||||
iblock->next_row = iblock->next_entry / hdr->man_dtable.cparam.width;
|
||||
iblock->next_size = hdr->man_dtable.row_block_size[iblock->next_row];
|
||||
UINT64DECODE_VAR(p, iblock->block_off, iblock->hdr->heap_off_size);
|
||||
|
||||
/* Allocate & decode indirect block entry tables */
|
||||
HDassert(iblock->nrows > 0);
|
||||
if(NULL == (iblock->ents = H5FL_SEQ_MALLOC(H5HF_indirect_ent_t, (iblock->nrows * hdr->man_dtable.cparam.width))))
|
||||
if(NULL == (iblock->ents = H5FL_SEQ_MALLOC(H5HF_indirect_ent_t, (iblock->nrows * iblock->hdr->man_dtable.cparam.width))))
|
||||
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for direct entries")
|
||||
#ifndef NDEBUG
|
||||
/* Reset child free space */
|
||||
acc_child_free_space = 0;
|
||||
#endif /* NDEBUG */
|
||||
for(u = 0; u < (iblock->nrows * hdr->man_dtable.cparam.width); u++) {
|
||||
for(u = 0; u < (iblock->nrows * iblock->hdr->man_dtable.cparam.width); u++) {
|
||||
/* Decode block address */
|
||||
H5F_addr_decode(f, &p, &(iblock->ents[u].addr));
|
||||
|
||||
/* Decode direct & indirect blocks differently */
|
||||
if(u < (hdr->man_dtable.max_direct_rows * hdr->man_dtable.cparam.width))
|
||||
UINT32DECODE_VAR(p, iblock->ents[u].free_space, hdr->man_dtable.max_dir_blk_off_size)
|
||||
if(u < (iblock->hdr->man_dtable.max_direct_rows * iblock->hdr->man_dtable.cparam.width))
|
||||
UINT32DECODE_VAR(p, iblock->ents[u].free_space, iblock->hdr->man_dtable.max_dir_blk_off_size)
|
||||
else
|
||||
UINT64DECODE_VAR(p, iblock->ents[u].free_space, hdr->heap_off_size)
|
||||
UINT64DECODE_VAR(p, iblock->ents[u].free_space, iblock->hdr->heap_off_size)
|
||||
#ifdef QAK
|
||||
HDfprintf(stderr, "%s: iblock->ents[%Zu] = {%a, %Hu}\n", FUNC, u, iblock->ents[u].addr, iblock->ents[u].free_space);
|
||||
#endif /* QAK */
|
||||
#ifndef NDEBUG
|
||||
acc_child_free_space += iblock->ents[u].free_space;
|
||||
#endif /* NDEBUG */
|
||||
/* XXX: Add code to indirect block cache load routine to create range sections for skipped blocks */
|
||||
/* XXX: ?? How to add code to indirect block cache load routine to create indirect sections for skipped blocks ?? */
|
||||
} /* end for */
|
||||
#ifndef NDEBUG
|
||||
HDassert(acc_child_free_space == iblock->child_free_space);
|
||||
HDassert(iblock->parent == NULL || acc_child_free_space == iblock->child_free_space);
|
||||
#endif /* NDEBUG */
|
||||
|
||||
/* Sanity check */
|
||||
@ -1213,7 +1112,7 @@ H5HF_cache_iblock_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr,
|
||||
{
|
||||
herr_t ret_value = SUCCEED; /* Return value */
|
||||
|
||||
FUNC_ENTER_NOAPI(H5HF_cache_iblock_flush, FAIL)
|
||||
FUNC_ENTER_NOAPI_NOINIT(H5HF_cache_iblock_flush)
|
||||
#ifdef QAK
|
||||
HDfprintf(stderr, "%s: Flushing indirect block, addr = %a, destroy = %u\n", FUNC, addr, (unsigned)destroy);
|
||||
#endif /* QAK */
|
||||
@ -1224,7 +1123,7 @@ HDfprintf(stderr, "%s: Flushing indirect block, addr = %a, destroy = %u\n", FUNC
|
||||
HDassert(iblock);
|
||||
|
||||
if(iblock->cache_info.is_dirty) {
|
||||
H5HF_t *hdr; /* Shared fractal heap information */
|
||||
H5HF_hdr_t *hdr; /* Shared fractal heap information */
|
||||
uint8_t *buf = NULL; /* Temporary buffer */
|
||||
uint8_t *p; /* Pointer into raw data buffer */
|
||||
size_t u; /* Local index variable */
|
||||
@ -1233,7 +1132,7 @@ HDfprintf(stderr, "%s: Flushing indirect block, addr = %a, destroy = %u\n", FUNC
|
||||
HDassert(iblock->dirty);
|
||||
|
||||
/* Get the pointer to the shared heap header */
|
||||
hdr = iblock->shared;
|
||||
hdr = iblock->hdr;
|
||||
|
||||
/* Allocate buffer to encode block */
|
||||
/* XXX: Use free list factories? */
|
||||
@ -1267,17 +1166,9 @@ HDfprintf(stderr, "%s: hdr->man_dtable.cparam.width = %u\n", FUNC, hdr->man_dtab
|
||||
/* Address of heap header for heap which owns this block */
|
||||
H5F_addr_encode(f, &p, hdr->heap_addr);
|
||||
|
||||
/* Info for parent block of this block */
|
||||
H5F_addr_encode(f, &p, iblock->par_addr);
|
||||
UINT16ENCODE(p, iblock->par_entry);
|
||||
UINT16ENCODE(p, iblock->par_nrows);
|
||||
|
||||
/* Offset of block in heap */
|
||||
UINT64ENCODE_VAR(p, iblock->block_off, hdr->heap_off_size);
|
||||
|
||||
/* Next block entry to allocate from */
|
||||
UINT32ENCODE(p, iblock->next_entry);
|
||||
|
||||
/* Encode indirect block-specific fields */
|
||||
for(u = 0; u < (iblock->nrows * hdr->man_dtable.cparam.width); u++) {
|
||||
#ifdef QAK
|
||||
@ -1316,58 +1207,6 @@ done:
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* H5HF_cache_iblock_flush() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5HF_cache_iblock_dest_real
|
||||
*
|
||||
* Purpose: Destroys a fractal heap indirect block in memory.
|
||||
*
|
||||
* Return: Non-negative on success/Negative on failure
|
||||
*
|
||||
* Programmer: Quincey Koziol
|
||||
* koziol@ncsa.uiuc.edu
|
||||
* Mar 6 2006
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
H5HF_cache_iblock_dest_real(H5HF_indirect_t *iblock)
|
||||
{
|
||||
herr_t ret_value = SUCCEED; /* Return value */
|
||||
|
||||
FUNC_ENTER_NOAPI_NOINIT(H5HF_cache_iblock_dest_real)
|
||||
|
||||
/*
|
||||
* Check arguments.
|
||||
*/
|
||||
HDassert(iblock);
|
||||
#ifdef QAK
|
||||
HDfprintf(stderr, "%s: Destroying indirect block\n", "H5HF_cache_iblock_dest");
|
||||
#endif /* QAK */
|
||||
/* XXX: Take out this goofy routine, after metadata cache is supporting
|
||||
* "un-evictable" flag
|
||||
*/
|
||||
if(iblock->rc == 0 && iblock->evicted) {
|
||||
/* Decrement reference count on shared info */
|
||||
HDassert(iblock->shared);
|
||||
if(H5HF_hdr_decr(iblock->shared) < 0)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared heap header")
|
||||
if(iblock->parent)
|
||||
if(H5HF_iblock_decr(iblock->parent) < 0)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared indirect block")
|
||||
|
||||
/* Release entry tables */
|
||||
if(iblock->ents)
|
||||
H5FL_SEQ_FREE(H5HF_indirect_ent_t, iblock->ents);
|
||||
|
||||
/* Free fractal heap indirect block info */
|
||||
H5FL_FREE(H5HF_indirect_t, iblock);
|
||||
} /* end if */
|
||||
|
||||
done:
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* end H5HF_cache_iblock_dest_real() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5HF_cache_iblock_dest
|
||||
@ -1394,17 +1233,26 @@ H5HF_cache_iblock_dest(H5F_t UNUSED *f, H5HF_indirect_t *iblock)
|
||||
* Check arguments.
|
||||
*/
|
||||
HDassert(iblock);
|
||||
/* XXX: Enable this after the metadata cache supports the "un-evictable" flag */
|
||||
/* HDassert(iblock->rc == 0); */
|
||||
HDassert(iblock->rc == 0);
|
||||
HDassert(!iblock->dirty);
|
||||
#ifdef QAK
|
||||
HDfprintf(stderr, "%s: Destroying indirect block\n", "H5HF_cache_iblock_dest");
|
||||
#endif /* QAK */
|
||||
/* XXX: Take out 'evicted' flag after "un-evictable" flag is working */
|
||||
iblock->evicted = TRUE;
|
||||
/* XXX: Take out this goofy routine, after metadata cache is supporting
|
||||
* "un-evictable" flag
|
||||
*/
|
||||
ret_value = H5HF_cache_iblock_dest_real(iblock);
|
||||
|
||||
/* Decrement reference count on shared info */
|
||||
HDassert(iblock->hdr);
|
||||
if(H5HF_hdr_decr(iblock->hdr) < 0)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared heap header")
|
||||
if(iblock->parent)
|
||||
if(H5HF_iblock_decr(iblock->parent) < 0)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared indirect block")
|
||||
|
||||
/* Release entry tables */
|
||||
if(iblock->ents)
|
||||
H5FL_SEQ_FREE(H5HF_indirect_ent_t, iblock->ents);
|
||||
|
||||
/* Free fractal heap indirect block info */
|
||||
H5FL_FREE(H5HF_indirect_t, iblock);
|
||||
|
||||
done:
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include "H5FLprivate.h" /* Free Lists */
|
||||
#include "H5HFpkg.h" /* Fractal heaps */
|
||||
#include "H5MMprivate.h" /* Memory management */
|
||||
#include "H5Vprivate.h" /* Vectors and arrays */
|
||||
|
||||
/****************/
|
||||
/* Local Macros */
|
||||
@ -164,7 +165,7 @@ H5HF_dtable_debug(H5HF_dtable_t *dtable, FILE *stream, int indent, int fwidth)
|
||||
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_hdr_t *hdr = NULL; /* Fractal heap header info */
|
||||
herr_t ret_value = SUCCEED; /* Return value */
|
||||
|
||||
FUNC_ENTER_NOAPI(H5HF_hdr_debug, FAIL)
|
||||
@ -181,7 +182,7 @@ H5HF_hdr_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent,
|
||||
/*
|
||||
* Load the fractal heap header.
|
||||
*/
|
||||
if(NULL == (fh = H5AC_protect(f, dxpl_id, H5AC_FHEAP_HDR, addr, NULL, NULL, H5AC_READ)))
|
||||
if(NULL == (hdr = H5AC_protect(f, dxpl_id, H5AC_FHEAP_HDR, addr, NULL, NULL, H5AC_READ)))
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load fractal heap header")
|
||||
|
||||
/* Print opening message */
|
||||
@ -192,36 +193,36 @@ H5HF_hdr_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent,
|
||||
*/
|
||||
HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
|
||||
"Heap address mapping method:",
|
||||
((fh->addrmap) == H5HF_ABSOLUTE ? "Absolute" :
|
||||
((fh->addrmap) == H5HF_MAPPED ? "Mapped" :
|
||||
((hdr->addrmap) == H5HF_ABSOLUTE ? "Absolute" :
|
||||
((hdr->addrmap) == H5HF_MAPPED ? "Mapped" :
|
||||
"Unknown!")));
|
||||
HDfprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth,
|
||||
"Min. size of standalone object:",
|
||||
(unsigned long)fh->standalone_size);
|
||||
(unsigned long)hdr->standalone_size);
|
||||
HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth,
|
||||
"Total free space in managed blocks:",
|
||||
fh->total_man_free);
|
||||
hdr->total_man_free);
|
||||
HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth,
|
||||
"Total # of free entries for standalone blocks:",
|
||||
fh->total_std_free);
|
||||
hdr->total_std_free);
|
||||
HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth,
|
||||
"Total data block size:",
|
||||
fh->total_size);
|
||||
hdr->total_size);
|
||||
HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth,
|
||||
"Total managed space data block size:",
|
||||
fh->man_size);
|
||||
hdr->man_size);
|
||||
HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth,
|
||||
"Total standalone space data block size:",
|
||||
fh->std_size);
|
||||
hdr->std_size);
|
||||
HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth,
|
||||
"Number of objects in heap:",
|
||||
fh->nobjs);
|
||||
hdr->nobjs);
|
||||
|
||||
HDfprintf(stream, "%*sManaged Objects Doubling-Table Info...\n", indent, "");
|
||||
H5HF_dtable_debug(&fh->man_dtable, stream, indent + 3, MAX(0, fwidth -3));
|
||||
H5HF_dtable_debug(&hdr->man_dtable, stream, indent + 3, MAX(0, fwidth -3));
|
||||
|
||||
done:
|
||||
if(fh && H5AC_unprotect(f, dxpl_id, H5AC_FHEAP_HDR, addr, fh, H5AC__NO_FLAGS_SET) < 0)
|
||||
if(hdr && H5AC_unprotect(f, dxpl_id, H5AC_FHEAP_HDR, addr, hdr, H5AC__NO_FLAGS_SET) < 0)
|
||||
HDONE_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to release fractal heap header")
|
||||
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
@ -245,7 +246,7 @@ herr_t
|
||||
H5HF_dblock_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream,
|
||||
int indent, int fwidth, haddr_t hdr_addr, size_t block_size)
|
||||
{
|
||||
H5HF_t *hdr = NULL; /* Fractal heap header info */
|
||||
H5HF_hdr_t *hdr = NULL; /* Fractal heap header info */
|
||||
H5HF_direct_t *dblock = NULL; /* Fractal heap direct block info */
|
||||
H5HF_direct_free_node_t *node; /* Pointer to free list node for block */
|
||||
size_t blk_prefix_size; /* Size of prefix for block */
|
||||
@ -278,7 +279,7 @@ H5HF_dblock_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream,
|
||||
/*
|
||||
* Load the heap direct block
|
||||
*/
|
||||
if(NULL == (dblock = H5AC_protect(f, dxpl_id, H5AC_FHEAP_DBLOCK, addr, &block_size, hdr, H5AC_READ)))
|
||||
if(NULL == (dblock = H5HF_man_dblock_protect(hdr, dxpl_id, addr, block_size, NULL, 0, H5AC_READ)))
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load fractal heap direct block")
|
||||
|
||||
/* Check for valid free list */
|
||||
@ -296,15 +297,6 @@ H5HF_dblock_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream,
|
||||
HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth,
|
||||
"Address of fractal heap that owns this block:",
|
||||
hdr->heap_addr);
|
||||
HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth,
|
||||
"Parent address:",
|
||||
dblock->par_addr);
|
||||
HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
|
||||
"Parent entry:",
|
||||
dblock->par_entry);
|
||||
HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
|
||||
"Parent # of rows:",
|
||||
dblock->par_nrows);
|
||||
HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth,
|
||||
"Offset of direct block in heap:",
|
||||
dblock->block_off);
|
||||
@ -397,10 +389,11 @@ herr_t
|
||||
H5HF_iblock_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream,
|
||||
int indent, int fwidth, haddr_t hdr_addr, unsigned nrows)
|
||||
{
|
||||
H5HF_t *hdr = NULL; /* Fractal heap header info */
|
||||
H5HF_hdr_t *hdr = NULL; /* Fractal heap header info */
|
||||
H5HF_indirect_t *iblock = NULL; /* Fractal heap direct block info */
|
||||
size_t dblock_size; /* Current direct block size */
|
||||
char temp_str[64]; /* Temporary string, for formatting */
|
||||
hsize_t child_free_space; /* Block's children's free space */
|
||||
size_t u, v; /* Local index variable */
|
||||
herr_t ret_value = SUCCEED; /* Return value */
|
||||
|
||||
@ -426,33 +419,29 @@ H5HF_iblock_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream,
|
||||
/*
|
||||
* Load the heap direct block
|
||||
*/
|
||||
if(NULL == (iblock = H5AC_protect(f, dxpl_id, H5AC_FHEAP_IBLOCK, addr, &nrows, hdr, H5AC_READ)))
|
||||
if(NULL == (iblock = H5HF_man_iblock_protect(hdr, dxpl_id, addr, nrows, NULL, 0, H5AC_READ)))
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load fractal heap indirect block")
|
||||
|
||||
/* Print opening message */
|
||||
HDfprintf(stream, "%*sFractal Heap Indirect Block...\n", indent, "");
|
||||
|
||||
/* Compute the child free space */
|
||||
child_free_space = 0;
|
||||
for(u = 0; u < (iblock->nrows * hdr->man_dtable.cparam.width); u++)
|
||||
child_free_space += iblock->ents[u].free_space;
|
||||
|
||||
/*
|
||||
* Print the values.
|
||||
*/
|
||||
HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth,
|
||||
"Address of fractal heap that owns this block:",
|
||||
hdr->heap_addr);
|
||||
HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth,
|
||||
"Parent address:",
|
||||
iblock->par_addr);
|
||||
HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
|
||||
"Parent entry:",
|
||||
iblock->par_entry);
|
||||
HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
|
||||
"Parent # of rows:",
|
||||
iblock->par_nrows);
|
||||
HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth,
|
||||
"Offset of indirect block in heap:",
|
||||
iblock->block_off);
|
||||
HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth,
|
||||
"Total children free space:",
|
||||
iblock->child_free_space);
|
||||
child_free_space);
|
||||
HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth,
|
||||
"Size of indirect block:",
|
||||
iblock->size);
|
||||
@ -465,15 +454,6 @@ H5HF_iblock_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream,
|
||||
HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
|
||||
"Max direct block rows:",
|
||||
hdr->man_dtable.max_direct_rows);
|
||||
HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
|
||||
"Next block column:",
|
||||
iblock->next_col);
|
||||
HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
|
||||
"Next block row:",
|
||||
iblock->next_row);
|
||||
HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth,
|
||||
"Next block size:",
|
||||
iblock->next_size);
|
||||
|
||||
/* Print the entry tables */
|
||||
HDfprintf(stream, "%*sDirect Block Entries (address, free space):\n", indent, "");
|
||||
@ -494,15 +474,21 @@ H5HF_iblock_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream,
|
||||
} /* end for */
|
||||
HDfprintf(stream, "%*sIndirect Block Entries:\n", indent, "");
|
||||
if(iblock->nrows > hdr->man_dtable.max_direct_rows) {
|
||||
unsigned first_row_bits; /* Number of bits used bit addresses in first row */
|
||||
unsigned num_indirect_rows; /* Number of rows of blocks in each indirect block */
|
||||
|
||||
first_row_bits = H5V_log2_of2(hdr->man_dtable.cparam.start_block_size) +
|
||||
H5V_log2_of2(hdr->man_dtable.cparam.width);
|
||||
for(u = hdr->man_dtable.max_direct_rows; u < iblock->nrows; u++) {
|
||||
sprintf(temp_str, "Row #%u:", (unsigned)u);
|
||||
num_indirect_rows = (H5V_log2_gen(hdr->man_dtable.row_block_size[u]) - first_row_bits) + 1;
|
||||
sprintf(temp_str, "Row #%u: (# of rows: %u)", (unsigned)u, num_indirect_rows);
|
||||
HDfprintf(stream, "%*s%-*s\n", indent + 3, "", MAX(0, fwidth - 3),
|
||||
temp_str);
|
||||
for(v = 0; v < hdr->man_dtable.cparam.width; v++) {
|
||||
size_t off = (u * hdr->man_dtable.cparam.width) + v;
|
||||
|
||||
sprintf(temp_str, "Col #%u:", (unsigned)v);
|
||||
HDfprintf(stream, "%*s%-*s %9a, %8Zu\n", indent + 6, "", MAX(0, fwidth - 6),
|
||||
HDfprintf(stream, "%*s%-*s %9a, %8Hu\n", indent + 6, "", MAX(0, fwidth - 6),
|
||||
temp_str,
|
||||
iblock->ents[off].addr,
|
||||
iblock->ents[off].free_space);
|
||||
|
269
src/H5HFdblock.c
269
src/H5HFdblock.c
@ -56,6 +56,8 @@
|
||||
/********************/
|
||||
/* Local Prototypes */
|
||||
/********************/
|
||||
static herr_t H5HF_man_dblock_regen_freelist(H5HF_direct_t *dblock,
|
||||
haddr_t dblock_addr);
|
||||
|
||||
|
||||
/*********************/
|
||||
@ -97,7 +99,7 @@ H5FL_DEFINE(H5HF_direct_free_node_t);
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
H5HF_man_dblock_create(hid_t dxpl_id, H5HF_t *hdr, H5HF_indirect_t *par_iblock,
|
||||
H5HF_man_dblock_create(hid_t dxpl_id, H5HF_hdr_t *hdr, H5HF_indirect_t *par_iblock,
|
||||
unsigned par_entry, size_t block_size, hsize_t block_off, haddr_t *addr_p,
|
||||
H5HF_free_section_t **ret_sec_node)
|
||||
{
|
||||
@ -126,7 +128,7 @@ H5HF_man_dblock_create(hid_t dxpl_id, H5HF_t *hdr, H5HF_indirect_t *par_iblock,
|
||||
HDmemset(&dblock->cache_info, 0, sizeof(H5AC_info_t));
|
||||
|
||||
/* Share common heap information */
|
||||
dblock->shared = hdr;
|
||||
dblock->hdr = hdr;
|
||||
if(H5HF_hdr_incr(hdr) < 0)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, FAIL, "can't increment reference count on shared heap header")
|
||||
|
||||
@ -138,17 +140,12 @@ HDfprintf(stderr, "%s: size = %Zu, block_off = %Hu\n", FUNC, block_size, block_o
|
||||
if(dblock->parent) {
|
||||
if(H5HF_iblock_incr(par_iblock) < 0)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, FAIL, "can't increment reference count on shared indirect block")
|
||||
dblock->par_addr = par_iblock->addr;
|
||||
dblock->par_nrows = par_iblock->nrows;
|
||||
} /* end if */
|
||||
else {
|
||||
dblock->par_addr = HADDR_UNDEF;
|
||||
dblock->par_nrows = 0;
|
||||
} /* end else */
|
||||
dblock->par_entry = par_entry;
|
||||
dblock->size = block_size;
|
||||
dblock->block_off = block_off;
|
||||
dblock->blk_off_size = H5HF_SIZEOF_OFFSET_LEN(block_size);
|
||||
dblock->fl_gen = hdr->fl_gen; /* New blocks have their free list generation set up correctly */
|
||||
dblock->free_list_head = H5HF_MAN_ABS_DIRECT_OVERHEAD_DBLOCK(hdr, dblock);
|
||||
dblock->blk_free_space = block_size -
|
||||
(H5HF_MAN_ABS_DIRECT_OVERHEAD_SIZE(hdr, block_size) + H5HF_MAN_ABS_DIRECT_OBJ_PREFIX_LEN(hdr));
|
||||
@ -194,6 +191,12 @@ HDmemset(dblock->blk, 0, dblock->size);
|
||||
/* (section size is "object size", without the metadata overhead) */
|
||||
sec_node->sect_size = node->size - H5HF_MAN_ABS_DIRECT_OBJ_PREFIX_LEN(hdr);
|
||||
sec_node->type = H5HF_SECT_SINGLE;
|
||||
sec_node->u.single.parent = dblock->parent;
|
||||
if(dblock->parent) {
|
||||
if(H5HF_iblock_incr(dblock->parent) < 0)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, FAIL, "can't increment reference count on shared indirect block")
|
||||
} /* end if */
|
||||
sec_node->u.single.par_entry = dblock->par_entry;
|
||||
sec_node->u.single.dblock_addr = *addr_p;
|
||||
sec_node->u.single.dblock_size = block_size;
|
||||
|
||||
@ -256,7 +259,7 @@ H5HF_man_dblock_build_freelist(H5HF_direct_t *dblock, haddr_t dblock_addr)
|
||||
if(dblock->free_list_head == 0)
|
||||
head->first = NULL;
|
||||
else {
|
||||
H5HF_t *hdr; /* Pointer to shared heap header */
|
||||
H5HF_hdr_t *hdr; /* Pointer to shared heap header */
|
||||
H5HF_free_section_t *sec_node; /* Pointer to free list section for block */
|
||||
H5HF_direct_free_node_t *node = NULL; /* Pointer to free list node for block */
|
||||
H5HF_direct_free_node_t *prev_node; /* Pointer to previous free list node for block */
|
||||
@ -266,7 +269,7 @@ H5HF_man_dblock_build_freelist(H5HF_direct_t *dblock, haddr_t dblock_addr)
|
||||
uint8_t *p; /* Temporary pointer to free node info */
|
||||
|
||||
/* Get the pointer to the shared heap info */
|
||||
hdr = dblock->shared;
|
||||
hdr = dblock->hdr;
|
||||
|
||||
/* Point to first node in free list */
|
||||
p = dblock->blk + dblock->free_list_head;
|
||||
@ -300,6 +303,12 @@ H5HF_man_dblock_build_freelist(H5HF_direct_t *dblock, haddr_t dblock_addr)
|
||||
/* (section size is "object size", without the metadata overhead) */
|
||||
sec_node->sect_size = node->size - H5HF_MAN_ABS_DIRECT_OBJ_PREFIX_LEN(hdr);
|
||||
sec_node->type = H5HF_SECT_SINGLE;
|
||||
sec_node->u.single.parent = dblock->parent;
|
||||
if(dblock->parent) {
|
||||
if(H5HF_iblock_incr(dblock->parent) < 0)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, FAIL, "can't increment reference count on shared indirect block")
|
||||
} /* end if */
|
||||
sec_node->u.single.par_entry = dblock->par_entry;
|
||||
sec_node->u.single.dblock_addr = dblock_addr;
|
||||
sec_node->u.single.dblock_size = dblock->size;
|
||||
|
||||
@ -343,6 +352,12 @@ H5HF_man_dblock_build_freelist(H5HF_direct_t *dblock, haddr_t dblock_addr)
|
||||
/* (section size is "object size", without the metadata overhead) */
|
||||
sec_node->sect_size = node->size - H5HF_MAN_ABS_DIRECT_OBJ_PREFIX_LEN(hdr);
|
||||
sec_node->type = H5HF_SECT_SINGLE;
|
||||
sec_node->u.single.parent = dblock->parent;
|
||||
if(dblock->parent) {
|
||||
if(H5HF_iblock_incr(dblock->parent) < 0)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, FAIL, "can't increment reference count on shared indirect block")
|
||||
} /* end if */
|
||||
sec_node->u.single.par_entry = dblock->par_entry;
|
||||
sec_node->u.single.dblock_addr = dblock_addr;
|
||||
sec_node->u.single.dblock_size = dblock->size;
|
||||
|
||||
@ -367,6 +382,123 @@ done:
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* end H5HF_man_dblock_build_freelist() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5HF_man_dblock_regen_freelist
|
||||
*
|
||||
* Purpose: Regenerate the free section information for the free space
|
||||
* in a direct block's free list.
|
||||
*
|
||||
* Return: SUCCEED/FAIL
|
||||
*
|
||||
* Programmer: Quincey Koziol
|
||||
* koziol@ncsa.uiuc.edu
|
||||
* Apr 25 2006
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static herr_t
|
||||
H5HF_man_dblock_regen_freelist(H5HF_direct_t *dblock, haddr_t dblock_addr)
|
||||
{
|
||||
H5HF_hdr_t *hdr; /* Pointer to shared heap header */
|
||||
H5HF_free_section_t *sec_node; /* Pointer to free list section for block */
|
||||
H5HF_direct_free_node_t *node; /* First node in free list */
|
||||
herr_t ret_value = SUCCEED; /* Return value */
|
||||
|
||||
FUNC_ENTER_NOAPI_NOINIT(H5HF_man_dblock_regen_freelist)
|
||||
|
||||
/*
|
||||
* Check arguments.
|
||||
*/
|
||||
HDassert(dblock);
|
||||
HDassert(dblock->free_list);
|
||||
|
||||
/* Get the pointer to the shared heap info */
|
||||
hdr = dblock->hdr;
|
||||
|
||||
/* Iterate through nodes on block's free list */
|
||||
node = dblock->free_list->first;
|
||||
while(node) {
|
||||
/* Create free list section node */
|
||||
if(NULL == (sec_node = H5FL_MALLOC(H5HF_free_section_t)))
|
||||
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for direct block free list section")
|
||||
|
||||
/* Set section's information */
|
||||
sec_node->sect_addr = dblock->block_off + node->my_offset;
|
||||
/* (section size is "object size", without the metadata overhead) */
|
||||
sec_node->sect_size = node->size - H5HF_MAN_ABS_DIRECT_OBJ_PREFIX_LEN(hdr);
|
||||
sec_node->type = H5HF_SECT_SINGLE;
|
||||
sec_node->u.single.parent = dblock->parent;
|
||||
if(dblock->parent) {
|
||||
if(H5HF_iblock_incr(dblock->parent) < 0)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, FAIL, "can't increment reference count on shared indirect block")
|
||||
} /* end if */
|
||||
sec_node->u.single.par_entry = dblock->par_entry;
|
||||
sec_node->u.single.dblock_addr = dblock_addr;
|
||||
sec_node->u.single.dblock_size = dblock->size;
|
||||
|
||||
/* Add new free space to the global list of space */
|
||||
if(H5HF_flist_add(hdr->flist, sec_node, &sec_node->sect_size, &sec_node->sect_addr) < 0)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't add direct block free space to global list")
|
||||
|
||||
/* Advance to next node */
|
||||
node = node->next;
|
||||
} /* end while */
|
||||
|
||||
done:
|
||||
/* XXX: cleanup on failure? */
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* end H5HF_man_dblock_regen_freelist() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5HF_man_dblock_destroy_freelist
|
||||
*
|
||||
* Purpose: Destroy the free list information for a direct block
|
||||
*
|
||||
* Return: SUCCEED/FAIL
|
||||
*
|
||||
* Programmer: Quincey Koziol
|
||||
* koziol@ncsa.uiuc.edu
|
||||
* Apr 22 2006
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
H5HF_man_dblock_destroy_freelist(H5HF_direct_t *dblock)
|
||||
{
|
||||
H5HF_direct_free_node_t *node; /* Pointer to free list node for block */
|
||||
|
||||
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_man_dblock_destroy_freelist)
|
||||
|
||||
/*
|
||||
* Check arguments.
|
||||
*/
|
||||
HDassert(dblock);
|
||||
HDassert(dblock->free_list);
|
||||
|
||||
/* Walk through list, freeing the nodes */
|
||||
node = dblock->free_list->first;
|
||||
while(node) {
|
||||
H5HF_direct_free_node_t *last_node; /* Pointer to last free list node for block */
|
||||
|
||||
/* Advance to next node */
|
||||
last_node = node;
|
||||
node = node->next;
|
||||
|
||||
/* Release the last node */
|
||||
H5FL_FREE(H5HF_direct_free_node_t, last_node);
|
||||
} /* end while */
|
||||
|
||||
/* Release the free list head */
|
||||
H5FL_FREE(H5HF_direct_free_head_t, dblock->free_list);
|
||||
|
||||
/* Reset the free list head */
|
||||
dblock->free_list = NULL;
|
||||
|
||||
FUNC_LEAVE_NOAPI(SUCCEED)
|
||||
} /* end H5HF_man_dblock_destroy_freelist() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5HF_man_dblock_adj_free
|
||||
@ -382,9 +514,9 @@ done:
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
H5HF_man_dblock_adj_free(hid_t dxpl_id, H5HF_direct_t *dblock, ssize_t amt)
|
||||
H5HF_man_dblock_adj_free(H5HF_direct_t *dblock, ssize_t amt)
|
||||
{
|
||||
H5HF_t *hdr; /* Shared heap information */
|
||||
H5HF_hdr_t *hdr; /* Shared heap information */
|
||||
herr_t ret_value = SUCCEED; /* Return value */
|
||||
|
||||
FUNC_ENTER_NOAPI_NOINIT(H5HF_man_dblock_adj_free)
|
||||
@ -398,7 +530,7 @@ HDfprintf(stderr, "%s: amt = %Zd\n", FUNC, amt);
|
||||
HDassert(dblock);
|
||||
|
||||
/* Get the pointer to the shared heap header */
|
||||
hdr = dblock->shared;
|
||||
hdr = dblock->hdr;
|
||||
|
||||
/* Adjust space available in block */
|
||||
HDassert(amt > 0 || dblock->blk_free_space >= (size_t)-amt);
|
||||
@ -424,7 +556,7 @@ HDfprintf(stderr, "%s: iblock->ents[dblock->par_entry].free_space = %Hu\n", FUNC
|
||||
iblock->child_free_space += amt;
|
||||
|
||||
/* Mark indirect block as dirty */
|
||||
if(H5HF_iblock_dirty(dxpl_id, iblock) < 0)
|
||||
if(H5HF_iblock_dirty(iblock) < 0)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTDIRTY, FAIL, "can't mark indirect block as dirty")
|
||||
|
||||
/* Modify the free space in parent block(s) */
|
||||
@ -443,7 +575,7 @@ HDfprintf(stderr, "%s: iblock->ents[dblock->par_entry].free_space = %Hu\n", FUNC
|
||||
iblock->child_free_space += amt;
|
||||
|
||||
/* Mark indirect block as dirty */
|
||||
if(H5HF_iblock_dirty(dxpl_id, iblock) < 0)
|
||||
if(H5HF_iblock_dirty(iblock) < 0)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTDIRTY, FAIL, "can't mark indirect block as dirty")
|
||||
} /* end while */
|
||||
} /* end if */
|
||||
@ -456,7 +588,7 @@ HDfprintf(stderr, "%s: hdr->total_man_free = %Hu\n", FUNC, hdr->total_man_free);
|
||||
#endif /* QAK */
|
||||
|
||||
/* Mark heap header as modified */
|
||||
if(H5HF_hdr_dirty(dxpl_id, hdr) < 0)
|
||||
if(H5HF_hdr_dirty(hdr) < 0)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTDIRTY, FAIL, "can't mark heap header as dirty")
|
||||
|
||||
done:
|
||||
@ -479,12 +611,13 @@ done:
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
H5HF_man_dblock_new(H5HF_t *hdr, hid_t dxpl_id, size_t request)
|
||||
H5HF_man_dblock_new(H5HF_hdr_t *hdr, hid_t dxpl_id, size_t request)
|
||||
{
|
||||
haddr_t dblock_addr; /* Address of new direct block */
|
||||
size_t dblock_size; /* Size of new direct block */
|
||||
size_t min_dblock_size; /* Min. size of direct block to allocate */
|
||||
herr_t ret_value = SUCCEED; /* Return value */
|
||||
haddr_t dblock_addr; /* Address of new direct block */
|
||||
hsize_t dblock_off; /* Direct block offset in heap address space */
|
||||
size_t dblock_size; /* Size of new direct block */
|
||||
size_t min_dblock_size; /* Min. size of direct block to allocate */
|
||||
herr_t ret_value = SUCCEED; /* Return value */
|
||||
|
||||
FUNC_ENTER_NOAPI_NOINIT(H5HF_man_dblock_new)
|
||||
#ifdef QAK
|
||||
@ -523,7 +656,8 @@ HDfprintf(stderr, "%s: Check 2 - min_dblock_size = %Zu\n", FUNC, min_dblock_size
|
||||
min_dblock_size == hdr->man_dtable.cparam.start_block_size) {
|
||||
/* Create new direct block at starting offset */
|
||||
dblock_size = hdr->man_dtable.cparam.start_block_size;
|
||||
if(H5HF_man_dblock_create(dxpl_id, hdr, NULL, 0, dblock_size, (hsize_t)0, &dblock_addr, NULL) < 0)
|
||||
dblock_off = 0;
|
||||
if(H5HF_man_dblock_create(dxpl_id, hdr, NULL, 0, dblock_size, dblock_off, &dblock_addr, NULL) < 0)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "can't allocate fractal heap direct block")
|
||||
|
||||
#ifdef QAK
|
||||
@ -541,15 +675,14 @@ HDfprintf(stderr, "%s: dblock_addr = %a\n", FUNC, dblock_addr);
|
||||
/* Root entry already exists, go get indirect block for new direct block */
|
||||
else {
|
||||
H5HF_indirect_t *iblock; /* Pointer to indirect block to create */
|
||||
haddr_t iblock_addr; /* Indirect block's address */
|
||||
size_t dblock_entry; /* Direct entry for new direct block */
|
||||
hsize_t dblock_off; /* Direct block offset in heap address space */
|
||||
|
||||
/* Find indirect block with room for block of correct size */
|
||||
if(NULL == (iblock = H5HF_man_iblock_place_dblock(hdr, dxpl_id, min_dblock_size, &iblock_addr, &dblock_entry, &dblock_size)))
|
||||
if(NULL == (iblock = H5HF_man_iblock_place_dblock(hdr, dxpl_id, min_dblock_size, &dblock_entry, &dblock_size)))
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "unable to locate indirect block with space for direct block")
|
||||
#ifdef QAK
|
||||
HDfprintf(stderr, "%s: iblock_addr = %a\n", FUNC, iblock_addr);
|
||||
HDfprintf(stderr, "%s: iblock = %p\n", FUNC, iblock);
|
||||
HDfprintf(stderr, "%s: iblock->addr = %a\n", FUNC, iblock->addr);
|
||||
HDfprintf(stderr, "%s: dblock_entry = %Zu\n", FUNC, dblock_entry);
|
||||
HDfprintf(stderr, "%s: dblock_size = %Zu\n", FUNC, dblock_size);
|
||||
#endif /* QAK */
|
||||
@ -571,15 +704,89 @@ HDfprintf(stderr, "%s: dblock_addr = %a\n", FUNC, dblock_addr);
|
||||
iblock->ents[dblock_entry].addr = dblock_addr;
|
||||
|
||||
/* Mark indirect block as modified */
|
||||
if(H5HF_iblock_dirty(dxpl_id, iblock) < 0)
|
||||
if(H5HF_iblock_dirty(iblock) < 0)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTDIRTY, FAIL, "can't mark indirect block as dirty")
|
||||
|
||||
/* Release the indirect block (marked as dirty) */
|
||||
if(H5AC_unprotect(hdr->f, dxpl_id, H5AC_FHEAP_IBLOCK, iblock_addr, iblock, H5AC__DIRTIED_FLAG) < 0)
|
||||
HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap indirect block")
|
||||
} /* end else */
|
||||
|
||||
/* Advance the allocated heap size/new block iterator */
|
||||
if(H5HF_hdr_inc_alloc(hdr, dblock_off + dblock_size, 1) < 0)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't increase allocated heap size")
|
||||
|
||||
done:
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* end H5HF_man_dblock_new() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5HF_man_dblock_protect
|
||||
*
|
||||
* Purpose: Convenience wrapper around H5AC_protect on a direct block
|
||||
* (Use H5AC_unprotect to unprotect it for now)
|
||||
*
|
||||
* Return: Pointer to direct block on success, NULL on failure
|
||||
*
|
||||
* Programmer: Quincey Koziol
|
||||
* koziol@ncsa.uiuc.edu
|
||||
* Apr 17 2006
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
H5HF_direct_t *
|
||||
H5HF_man_dblock_protect(H5HF_hdr_t *hdr, hid_t dxpl_id, haddr_t dblock_addr,
|
||||
size_t dblock_size, H5HF_indirect_t *par_iblock, unsigned par_entry,
|
||||
H5AC_protect_t rw)
|
||||
{
|
||||
H5HF_parent_t par_info; /* Parent info for loading block */
|
||||
H5HF_direct_t *dblock; /* Direct block from cache */
|
||||
H5HF_direct_t *ret_value; /* Return value */
|
||||
|
||||
FUNC_ENTER_NOAPI_NOINIT(H5HF_man_dblock_protect)
|
||||
#ifdef QAK
|
||||
HDfprintf(stderr, "%s: dblock_addr = %a, dblock_size = %Zu\n", FUNC, dblock_addr, dblock_size);
|
||||
#endif /* QAK */
|
||||
|
||||
/*
|
||||
* Check arguments.
|
||||
*/
|
||||
HDassert(hdr);
|
||||
HDassert(H5F_addr_defined(dblock_addr));
|
||||
HDassert(dblock_size > 0);
|
||||
|
||||
/* Set up parent info */
|
||||
par_info.hdr = hdr;
|
||||
par_info.iblock = par_iblock;
|
||||
par_info.entry = par_entry;
|
||||
|
||||
/* Protect the direct block */
|
||||
if(NULL == (dblock = H5AC_protect(hdr->f, dxpl_id, H5AC_FHEAP_DBLOCK, dblock_addr, &dblock_size, &par_info, rw)))
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, NULL, "unable to protect fractal heap direct block")
|
||||
|
||||
/* Regenerate the free list information for this block, if necessary */
|
||||
/* (Only create free list information if write access is requested) */
|
||||
if(rw == H5AC_WRITE && hdr->fl_gen != dblock->fl_gen) {
|
||||
#ifdef QAK
|
||||
HDfprintf(stderr, "%s: building free list for direct block\n", FUNC);
|
||||
#endif /* QAK */
|
||||
/* If the block has a free list from a previous generation, get rid of it */
|
||||
if(dblock->free_list) {
|
||||
if(H5HF_man_dblock_regen_freelist(dblock, dblock_addr) < 0)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, NULL, "can't regenerate free list for direct block")
|
||||
} /* end if */
|
||||
else {
|
||||
/* Build the free list for the block */
|
||||
if(H5HF_man_dblock_build_freelist(dblock, dblock_addr) < 0)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTDECODE, NULL, "can't decode free list for block")
|
||||
} /* end else */
|
||||
HDassert(dblock->free_list);
|
||||
|
||||
/* Mark the block's free list generation as up to date now */
|
||||
dblock->fl_gen = hdr->fl_gen;
|
||||
} /* end if */
|
||||
|
||||
/* Set the return value */
|
||||
ret_value = dblock;
|
||||
|
||||
done:
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* end H5HF_man_dblock_protect() */
|
||||
|
||||
|
@ -211,3 +211,37 @@ H5HF_dtable_dest(H5HF_dtable_t *dtable)
|
||||
FUNC_LEAVE_NOAPI(SUCCEED)
|
||||
} /* end H5HF_dtable_dest() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5HF_dtable_size_to_row
|
||||
*
|
||||
* Purpose: Compute row that can hold block of a certain size
|
||||
*
|
||||
* Return: Non-negative on success (can't fail)
|
||||
*
|
||||
* Programmer: Quincey Koziol
|
||||
* koziol@ncsa.uiuc.edu
|
||||
* Apr 25 2006
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
unsigned
|
||||
H5HF_dtable_size_to_row(H5HF_dtable_t *dtable, size_t block_size)
|
||||
{
|
||||
unsigned row; /* Row where block will fit */
|
||||
|
||||
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_dtable_size_to_row)
|
||||
|
||||
/*
|
||||
* Check arguments.
|
||||
*/
|
||||
HDassert(dtable);
|
||||
|
||||
if(block_size == dtable->cparam.start_block_size)
|
||||
row = 0;
|
||||
else
|
||||
row = (H5V_log2_of2((uint32_t)block_size) - H5V_log2_of2(dtable->cparam.start_block_size)) + 1;
|
||||
|
||||
FUNC_LEAVE_NOAPI(row)
|
||||
} /* end H5HF_dtable_size_to_row() */
|
||||
|
||||
|
113
src/H5HFflist.c
113
src/H5HFflist.c
@ -78,6 +78,7 @@ struct H5HF_freelist_t {
|
||||
/* Local Prototypes */
|
||||
/********************/
|
||||
static herr_t H5HF_flist_node_free_cb(void *item, void *key, void *op_data);
|
||||
static herr_t H5HF_flist_init(H5HF_freelist_t *flist);
|
||||
|
||||
|
||||
/*********************/
|
||||
@ -105,6 +106,41 @@ H5FL_SEQ_DEFINE_STATIC(H5SL_ptr_t);
|
||||
/*******************/
|
||||
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5HF_flist_init
|
||||
*
|
||||
* Purpose: Initialize free list for heap
|
||||
*
|
||||
* Return: Success: non-negative
|
||||
*
|
||||
* Failure: negative
|
||||
*
|
||||
* Programmer: Quincey Koziol
|
||||
* Tuesday, April 18, 2006
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static herr_t
|
||||
H5HF_flist_init(H5HF_freelist_t *flist)
|
||||
{
|
||||
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_flist_init)
|
||||
|
||||
/* Check arguments. */
|
||||
HDassert(flist);
|
||||
|
||||
/* Set free list parameters */
|
||||
flist->tot_space = 0;
|
||||
flist->sec_count = 0;
|
||||
flist->single.node = NULL;
|
||||
flist->single.size_key = NULL;
|
||||
flist->single.addr_key = NULL;
|
||||
flist->bins = NULL;
|
||||
flist->using_bins = FALSE;
|
||||
|
||||
FUNC_LEAVE_NOAPI(SUCCEED)
|
||||
} /* H5HF_flist_init() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5HF_flist_create
|
||||
@ -121,7 +157,7 @@ H5FL_SEQ_DEFINE_STATIC(H5SL_ptr_t);
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
H5HF_freelist_t *
|
||||
H5HF_flist_create(size_t max_block_size, H5SL_operator_t node_free_op)
|
||||
H5HF_flist_create(unsigned max_index_bits, H5SL_operator_t node_free_op)
|
||||
{
|
||||
H5HF_freelist_t *flist; /* New free list structure */
|
||||
H5HF_freelist_t *ret_value; /* Return value */
|
||||
@ -136,16 +172,12 @@ H5HF_flist_create(size_t max_block_size, H5SL_operator_t node_free_op)
|
||||
if(NULL == (flist = H5FL_MALLOC(H5HF_freelist_t)))
|
||||
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for fractal heap free list")
|
||||
|
||||
/* Set free list parameters */
|
||||
flist->tot_space = 0;
|
||||
flist->sec_count = 0;
|
||||
flist->single.node = NULL;
|
||||
flist->single.size_key = NULL;
|
||||
flist->single.addr_key = NULL;
|
||||
flist->nbins = H5V_log2_of2(max_block_size);
|
||||
/* Set immutable free list parameters */
|
||||
flist->nbins = max_index_bits;
|
||||
flist->node_free_op = node_free_op;
|
||||
flist->bins = NULL;
|
||||
flist->using_bins = FALSE;
|
||||
|
||||
/* Set modifiable free list parameters */
|
||||
H5HF_flist_init(flist);
|
||||
|
||||
/* Set return value */
|
||||
ret_value = flist;
|
||||
@ -190,6 +222,7 @@ HDfprintf(stderr, "%s: *size_key = %Zu, *addr_key = %a\n", FUNC, *size_key, *add
|
||||
|
||||
/* Determine correct bin which holds items of the section's size */
|
||||
bin = H5V_log2_gen((hsize_t)*size_key);
|
||||
HDassert(bin < flist->nbins);
|
||||
if(flist->bins[bin] == NULL) {
|
||||
if(NULL == (flist->bins[bin] = H5SL_create(H5SL_TYPE_SIZE, 0.5, H5HF_FLIST_DEFAULT_SKIPLIST_HEIGHT)))
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTCREATE, FAIL, "can't create skip list for free list nodes")
|
||||
@ -256,6 +289,9 @@ HDfprintf(stderr, "%s: *size_key = %Zu, *addr_key = %a\n", FUNC, *size_key, *add
|
||||
HDassert(addr_key);
|
||||
|
||||
/* Check for special cases of # of sections on free list */
|
||||
#ifdef QAK
|
||||
HDfprintf(stderr, "%s: flist->sec_count = %Zu\n", FUNC, flist->sec_count);
|
||||
#endif /* QAK */
|
||||
if(flist->sec_count == 0) {
|
||||
HDassert(flist->single.node == NULL);
|
||||
|
||||
@ -330,6 +366,7 @@ H5HF_flist_find_bin_node(H5HF_freelist_t *flist, size_t request, void **node)
|
||||
|
||||
/* Determine correct bin which holds items of at least the section's size */
|
||||
bin = H5V_log2_gen((hsize_t)request);
|
||||
HDassert(bin < flist->nbins);
|
||||
while(bin < flist->nbins && flist->bins[bin] == NULL)
|
||||
bin++;
|
||||
|
||||
@ -412,6 +449,9 @@ HDfprintf(stderr, "%s: request = %Zu\n", FUNC, request);
|
||||
HDassert(node);
|
||||
|
||||
/* Check for any sections on free list */
|
||||
#ifdef QAK
|
||||
HDfprintf(stderr, "%s: flist->sec_count = %Zu\n", FUNC, flist->sec_count);
|
||||
#endif /* QAK */
|
||||
if(flist->sec_count > 0) {
|
||||
/* Check for single section */
|
||||
/* XXX: Take out the "&& !flist->using_bins" when bins converted back into single section */
|
||||
@ -435,8 +475,9 @@ HDfprintf(stderr, "%s: request = %Zu\n", FUNC, request);
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "can't remove section from bins")
|
||||
} /* end else */
|
||||
|
||||
/* Decrement # of sections on free list */
|
||||
flist->sec_count--;
|
||||
/* Decrement # of sections on free list, if we found an object */
|
||||
if(ret_value > 0) {
|
||||
flist->sec_count--;
|
||||
/* XXX: Should check for only one section in bins & convert to single section
|
||||
* This is somewhat hard because we "lose" the the size & address keys
|
||||
* (The address key is actually available, but the size key is gone, unless
|
||||
@ -444,8 +485,9 @@ HDfprintf(stderr, "%s: request = %Zu\n", FUNC, request);
|
||||
*
|
||||
* Drop back to using a "single" node when the bins are empty.
|
||||
*/
|
||||
if(flist->sec_count == 0)
|
||||
flist->using_bins = FALSE;
|
||||
if(flist->sec_count == 0)
|
||||
flist->using_bins = FALSE;
|
||||
} /* end if */
|
||||
} /* end if */
|
||||
|
||||
done:
|
||||
@ -487,25 +529,26 @@ H5HF_flist_node_free_cb(void *item, void UNUSED *key, void *op_data)
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5HF_flist_free
|
||||
* Function: H5HF_flist_reset
|
||||
*
|
||||
* Purpose: Destroy & deallocate free list structure
|
||||
* Purpose: Reset free list structure by freeing all existing sections
|
||||
* and restoring free list info to initial conditions.
|
||||
*
|
||||
* Return: Success: non-negative
|
||||
*
|
||||
* Failure: negative
|
||||
*
|
||||
* Programmer: Quincey Koziol
|
||||
* Tuesday, March 7, 2006
|
||||
* Tuesday, April 18, 2006
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
H5HF_flist_free(H5HF_freelist_t *flist)
|
||||
H5HF_flist_reset(H5HF_freelist_t *flist)
|
||||
{
|
||||
unsigned u; /* Local index variable */
|
||||
|
||||
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_flist_free)
|
||||
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_flist_reset)
|
||||
|
||||
/* Check arguments. */
|
||||
HDassert(flist);
|
||||
@ -531,6 +574,38 @@ H5HF_flist_free(H5HF_freelist_t *flist)
|
||||
H5FL_SEQ_FREE(H5SL_ptr_t, flist->bins);
|
||||
} /* end if */
|
||||
|
||||
/* Reset free list info back to initial state */
|
||||
H5HF_flist_init(flist);
|
||||
|
||||
FUNC_LEAVE_NOAPI(SUCCEED)
|
||||
} /* H5HF_flist_reset() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5HF_flist_free
|
||||
*
|
||||
* Purpose: Destroy & deallocate free list structure
|
||||
*
|
||||
* Return: Success: non-negative
|
||||
*
|
||||
* Failure: negative
|
||||
*
|
||||
* Programmer: Quincey Koziol
|
||||
* Tuesday, March 7, 2006
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
H5HF_flist_free(H5HF_freelist_t *flist)
|
||||
{
|
||||
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_flist_free)
|
||||
|
||||
/* Check arguments. */
|
||||
HDassert(flist);
|
||||
|
||||
/* Reset free list information */
|
||||
H5HF_flist_reset(flist);
|
||||
|
||||
/* Free fractal heap free list info */
|
||||
H5FL_FREE(H5HF_freelist_t, flist);
|
||||
|
||||
|
165
src/H5HFhdr.c
165
src/H5HFhdr.c
@ -92,11 +92,11 @@
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
H5HF_t *
|
||||
H5HF_hdr_t *
|
||||
H5HF_hdr_alloc(H5F_t *f)
|
||||
{
|
||||
H5HF_t *fh = NULL; /* Shared fractal heap header */
|
||||
H5HF_t *ret_value = NULL; /* Return value */
|
||||
H5HF_hdr_t *hdr = NULL; /* Shared fractal heap header */
|
||||
H5HF_hdr_t *ret_value = NULL; /* Return value */
|
||||
|
||||
FUNC_ENTER_NOAPI_NOINIT(H5HF_hdr_alloc)
|
||||
|
||||
@ -106,21 +106,21 @@ H5HF_hdr_alloc(H5F_t *f)
|
||||
HDassert(f);
|
||||
|
||||
/* Allocate space for the shared information */
|
||||
if(NULL == (fh = H5FL_CALLOC(H5HF_t)))
|
||||
if(NULL == (hdr = H5FL_CALLOC(H5HF_hdr_t)))
|
||||
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for fractal heap shared header")
|
||||
|
||||
/* Set the internal parameters for the heap */
|
||||
fh->f = f;
|
||||
fh->sizeof_size = H5F_SIZEOF_SIZE(f);
|
||||
fh->sizeof_addr = H5F_SIZEOF_ADDR(f);
|
||||
hdr->f = f;
|
||||
hdr->sizeof_size = H5F_SIZEOF_SIZE(f);
|
||||
hdr->sizeof_addr = H5F_SIZEOF_ADDR(f);
|
||||
|
||||
/* Set the return value */
|
||||
ret_value = fh;
|
||||
ret_value = hdr;
|
||||
|
||||
done:
|
||||
if(!ret_value)
|
||||
if(fh)
|
||||
(void)H5HF_cache_hdr_dest(f, fh);
|
||||
if(hdr)
|
||||
(void)H5HF_cache_hdr_dest(f, hdr);
|
||||
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* end H5HF_hdr_alloc() */
|
||||
@ -141,7 +141,7 @@ done:
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static hsize_t
|
||||
H5HF_hdr_compute_free_space(H5HF_t *hdr, hsize_t iblock_size)
|
||||
H5HF_hdr_compute_free_space(H5HF_hdr_t *hdr, hsize_t iblock_size)
|
||||
{
|
||||
hsize_t acc_heap_size; /* Accumumated heap space */
|
||||
hsize_t acc_dblock_free; /* Accumumated direct block free space */
|
||||
@ -189,7 +189,7 @@ H5HF_hdr_compute_free_space(H5HF_t *hdr, hsize_t iblock_size)
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
H5HF_hdr_finish_init(H5HF_t *hdr)
|
||||
H5HF_hdr_finish_init(H5HF_hdr_t *hdr)
|
||||
{
|
||||
size_t u; /* Local index variable */
|
||||
herr_t ret_value = SUCCEED; /* Return value */
|
||||
@ -207,9 +207,16 @@ H5HF_hdr_finish_init(H5HF_t *hdr)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize doubling table info")
|
||||
|
||||
/* Create the free-list structure for the heap */
|
||||
if(NULL == (hdr->flist = H5HF_flist_create(hdr->man_dtable.cparam.max_direct_size, H5HF_free_section_free_cb)))
|
||||
if(NULL == (hdr->flist = H5HF_flist_create(hdr->man_dtable.cparam.max_index, H5HF_free_section_free_cb)))
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize free list info")
|
||||
|
||||
/* Start the free list "generation" count */
|
||||
/* (Must be "out of sync" with starting value for indirect & direct block
|
||||
* cache loading routines, in order to trigger re-building the free list
|
||||
* information for each block when a heap is opened->closed->reopened -QAK)
|
||||
*/
|
||||
hdr->fl_gen = 1;
|
||||
|
||||
/* Set the size of heap IDs */
|
||||
hdr->id_len = hdr->heap_off_size + MIN(hdr->man_dtable.max_dir_blk_off_size,
|
||||
((H5V_log2_gen((hsize_t)hdr->standalone_size) + 7) / 8));
|
||||
@ -229,6 +236,10 @@ HDfprintf(stderr, "%s: row_dblock_free[%Zu] = %Hu\n", FUNC, u, hdr->man_dtable.r
|
||||
#endif /* QAK */
|
||||
} /* end for */
|
||||
|
||||
/* Initialize the block iterator for searching for free space */
|
||||
if(H5HF_man_iter_init(&hdr->next_block) < 0)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize space search block iterator")
|
||||
|
||||
done:
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* end H5HF_hdr_finish_init() */
|
||||
@ -248,7 +259,7 @@ done:
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
H5HF_hdr_init(H5HF_t *fh, haddr_t fh_addr, H5HF_create_t *cparam)
|
||||
H5HF_hdr_init(H5HF_hdr_t *hdr, haddr_t fh_addr, H5HF_create_t *cparam)
|
||||
{
|
||||
herr_t ret_value = SUCCEED; /* Return value */
|
||||
|
||||
@ -257,7 +268,7 @@ H5HF_hdr_init(H5HF_t *fh, haddr_t fh_addr, H5HF_create_t *cparam)
|
||||
/*
|
||||
* Check arguments.
|
||||
*/
|
||||
HDassert(fh);
|
||||
HDassert(hdr);
|
||||
HDassert(cparam);
|
||||
|
||||
#ifndef NDEBUG
|
||||
@ -271,30 +282,33 @@ H5HF_hdr_init(H5HF_t *fh, haddr_t fh_addr, H5HF_create_t *cparam)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, FAIL, "max. direct block size not power of two")
|
||||
if(cparam->managed.max_direct_size < cparam->standalone_size)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, FAIL, "max. direct block size not large enough to hold all managed blocks")
|
||||
if(cparam->managed.max_index > (8 * fh->sizeof_size) || cparam->managed.max_index == 0)
|
||||
if(cparam->managed.max_index > (8 * hdr->sizeof_size) || cparam->managed.max_index == 0)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, FAIL, "max. direct block size not power of two")
|
||||
#endif /* NDEBUG */
|
||||
|
||||
/* Set the creation parameters for the heap */
|
||||
fh->heap_addr = fh_addr;
|
||||
fh->addrmap = cparam->addrmap;
|
||||
fh->standalone_size = cparam->standalone_size;
|
||||
HDmemcpy(&(fh->man_dtable.cparam), &(cparam->managed), sizeof(H5HF_dtable_cparam_t));
|
||||
hdr->heap_addr = fh_addr;
|
||||
hdr->addrmap = cparam->addrmap;
|
||||
hdr->standalone_size = cparam->standalone_size;
|
||||
HDmemcpy(&(hdr->man_dtable.cparam), &(cparam->managed), sizeof(H5HF_dtable_cparam_t));
|
||||
|
||||
/* Set root table address */
|
||||
fh->man_dtable.table_addr = HADDR_UNDEF;
|
||||
hdr->man_dtable.table_addr = HADDR_UNDEF;
|
||||
|
||||
/* Newly created heap's free list is always in sync in memory */
|
||||
hdr->freelist_sync = TRUE;
|
||||
|
||||
/* Note that the shared info is dirty (it's not written to the file yet) */
|
||||
fh->dirty = TRUE;
|
||||
hdr->dirty = TRUE;
|
||||
|
||||
/* Make shared heap info reference counted */
|
||||
if(H5HF_hdr_finish_init(fh) < 0)
|
||||
if(H5HF_hdr_finish_init(hdr) < 0)
|
||||
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't create ref-count wrapper for shared fractal heap header")
|
||||
|
||||
done:
|
||||
if(ret_value < 0)
|
||||
if(fh)
|
||||
(void)H5HF_cache_hdr_dest(NULL, fh);
|
||||
if(hdr)
|
||||
(void)H5HF_cache_hdr_dest(NULL, hdr);
|
||||
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* end H5HF_hdr_init() */
|
||||
@ -314,9 +328,11 @@ done:
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
H5HF_hdr_incr(H5HF_t *hdr)
|
||||
H5HF_hdr_incr(H5HF_hdr_t *hdr)
|
||||
{
|
||||
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_hdr_incr)
|
||||
herr_t ret_value = SUCCEED; /* Return value */
|
||||
|
||||
FUNC_ENTER_NOAPI_NOINIT(H5HF_hdr_incr)
|
||||
|
||||
/* Sanity check */
|
||||
HDassert(hdr);
|
||||
@ -324,11 +340,16 @@ H5HF_hdr_incr(H5HF_t *hdr)
|
||||
/* XXX: When "un-evictable" feature is finished, mark the header as
|
||||
* unevictable on the first block to share it. - QAK
|
||||
*/
|
||||
/* Mark header as un-evictable when a block is depending on it */
|
||||
if(hdr->rc == 0)
|
||||
if(H5AC_pin_protected_entry(hdr->f, hdr) < 0)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTPIN, FAIL, "unable to pin fractal heap header")
|
||||
|
||||
/* Increment reference count on shared header */
|
||||
hdr->rc++;
|
||||
|
||||
FUNC_LEAVE_NOAPI(SUCCEED)
|
||||
done:
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* end H5HF_hdr_incr() */
|
||||
|
||||
|
||||
@ -346,9 +367,11 @@ H5HF_hdr_incr(H5HF_t *hdr)
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
H5HF_hdr_decr(H5HF_t *hdr)
|
||||
H5HF_hdr_decr(H5HF_hdr_t *hdr)
|
||||
{
|
||||
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_hdr_decr)
|
||||
herr_t ret_value = SUCCEED; /* Return value */
|
||||
|
||||
FUNC_ENTER_NOAPI_NOINIT(H5HF_hdr_decr)
|
||||
|
||||
/* Sanity check */
|
||||
HDassert(hdr);
|
||||
@ -356,13 +379,13 @@ H5HF_hdr_decr(H5HF_t *hdr)
|
||||
/* Decrement reference count on shared header */
|
||||
hdr->rc--;
|
||||
|
||||
/* XXX: When "un-evictable" feature is finished, mark the header as
|
||||
* evictable when the ref. count drops to zero. - QAK
|
||||
*/
|
||||
/* XXX: Take this call out after "un-evictable" flag is working */
|
||||
H5HF_cache_hdr_dest_real(hdr);
|
||||
/* Mark header as evictable again when no child blocks depend on it */
|
||||
if(hdr->rc == 0)
|
||||
if(H5AC_unpin_entry(hdr->f, hdr) < 0)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPIN, FAIL, "unable to unpin fractal heap header")
|
||||
|
||||
FUNC_LEAVE_NOAPI(SUCCEED)
|
||||
done:
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* end H5HF_hdr_decr() */
|
||||
|
||||
|
||||
@ -380,10 +403,8 @@ H5HF_hdr_decr(H5HF_t *hdr)
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
H5HF_hdr_dirty(hid_t dxpl_id, H5HF_t *hdr)
|
||||
H5HF_hdr_dirty(H5HF_hdr_t *hdr)
|
||||
{
|
||||
H5HF_t *tmp_hdr; /* Temporary pointer to heap header */
|
||||
hbool_t is_protected; /* Whether the indirect block is protected */
|
||||
herr_t ret_value = SUCCEED; /* Return value */
|
||||
|
||||
FUNC_ENTER_NOAPI_NOINIT(H5HF_hdr_dirty)
|
||||
@ -394,29 +415,13 @@ HDfprintf(stderr, "%s: Marking heap header as dirty\n", FUNC);
|
||||
/* Sanity check */
|
||||
HDassert(hdr);
|
||||
|
||||
/* XXX: When "un-evictable" feature is finished, just mark the header as dirty
|
||||
* in the cache, instead of this protect -> unprotect kludge - QAK
|
||||
*/
|
||||
/* Protect the header */
|
||||
is_protected = hdr->cache_info.is_protected;
|
||||
if(!is_protected) {
|
||||
#ifdef QAK
|
||||
HDfprintf(stderr, "%s: hdr->heap_addr = %a\n", FUNC, hdr->heap_addr);
|
||||
#endif /* QAK */
|
||||
if(NULL == (tmp_hdr = H5AC_protect(hdr->f, dxpl_id, H5AC_FHEAP_HDR, hdr->heap_addr, NULL, NULL, H5AC_WRITE)))
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect fractal heap indirect block")
|
||||
HDassert(hdr == tmp_hdr);
|
||||
} /* end if */
|
||||
/* Mark header as dirty in cache */
|
||||
if(H5AC_mark_pinned_entry_dirty(hdr->f, hdr, FALSE, 0) < 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;
|
||||
|
||||
/* Release the heap header (marked as dirty) */
|
||||
if(!is_protected) {
|
||||
if(H5AC_unprotect(hdr->f, dxpl_id, H5AC_FHEAP_HDR, hdr->heap_addr, tmp_hdr, H5AC__DIRTIED_FLAG) < 0)
|
||||
HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap indirect block")
|
||||
} /* end if */
|
||||
|
||||
done:
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* end H5HF_hdr_dirty() */
|
||||
@ -436,7 +441,7 @@ done:
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
H5HF_hdr_extend_heap(H5HF_t *hdr, hsize_t new_size, hsize_t extra_free)
|
||||
H5HF_hdr_extend_heap(H5HF_hdr_t *hdr, hsize_t new_size, hsize_t extra_free)
|
||||
{
|
||||
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_hdr_extend_heap)
|
||||
|
||||
@ -456,3 +461,45 @@ H5HF_hdr_extend_heap(H5HF_t *hdr, hsize_t new_size, hsize_t extra_free)
|
||||
FUNC_LEAVE_NOAPI(SUCCEED)
|
||||
} /* end H5HF_hdr_extend_heap() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5HF_hdr_inc_alloc
|
||||
*
|
||||
* Purpose: Increase allocated size of heap
|
||||
*
|
||||
* Return: Non-negative on success/Negative on failure
|
||||
*
|
||||
* Programmer: Quincey Koziol
|
||||
* koziol@ncsa.uiuc.edu
|
||||
* Apr 24 2006
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
H5HF_hdr_inc_alloc(H5HF_hdr_t *hdr, hsize_t new_alloc_size, unsigned nentries)
|
||||
{
|
||||
herr_t ret_value = SUCCEED; /* Return value */
|
||||
|
||||
FUNC_ENTER_NOAPI_NOINIT(H5HF_hdr_inc_alloc)
|
||||
|
||||
/*
|
||||
* Check arguments.
|
||||
*/
|
||||
HDassert(hdr);
|
||||
HDassert(new_alloc_size >= hdr->man_alloc_size);
|
||||
|
||||
/* Advance the iterator for the current location with in the indirect block */
|
||||
if(hdr->next_block.curr)
|
||||
if(H5HF_man_iter_next(hdr, &hdr->next_block, nentries) < 0)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTNEXT, FAIL, "unable to advance current block iterator location")
|
||||
|
||||
/* Update the "allocated" size within the heap */
|
||||
hdr->man_alloc_size = new_alloc_size;
|
||||
#ifdef QAK
|
||||
HDfprintf(stderr, "%s: hdr->man_alloc_size = %Hu\n", FUNC, hdr->man_alloc_size);
|
||||
#endif /* QAK */
|
||||
|
||||
done:
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* end H5HF_hdr_inc_alloc() */
|
||||
|
||||
|
1216
src/H5HFiblock.c
1216
src/H5HFiblock.c
File diff suppressed because it is too large
Load Diff
227
src/H5HFint.c
227
src/H5HFint.c
@ -57,6 +57,7 @@
|
||||
/********************/
|
||||
/* Local Prototypes */
|
||||
/********************/
|
||||
static herr_t H5HF_man_start_freelist(H5HF_hdr_t *hdr, hid_t dxpl_id);
|
||||
|
||||
|
||||
/*********************/
|
||||
@ -93,18 +94,133 @@ H5FL_DEFINE(H5HF_free_section_t);
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
H5HF_free_section_free_cb(void *item, void UNUSED *key, void UNUSED *op_data)
|
||||
H5HF_free_section_free_cb(void *_sect, void UNUSED *key, void UNUSED *op_data)
|
||||
{
|
||||
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_free_section_free_cb)
|
||||
H5HF_free_section_t *sect = (H5HF_free_section_t *)_sect;
|
||||
H5HF_indirect_t *iblock = NULL; /* Indirect block referenced */
|
||||
herr_t ret_value = 0; /* Return value */
|
||||
|
||||
HDassert(item);
|
||||
FUNC_ENTER_NOAPI_NOINIT(H5HF_free_section_free_cb)
|
||||
|
||||
HDassert(sect);
|
||||
|
||||
/* Find indirect block that free section references */
|
||||
switch(sect->type) {
|
||||
case H5HF_SECT_SINGLE:
|
||||
iblock = sect->u.single.parent;
|
||||
break;
|
||||
|
||||
case H5HF_SECT_OPAQUE:
|
||||
iblock = sect->u.opaque.iblock;
|
||||
break;
|
||||
|
||||
case H5HF_SECT_RANGE:
|
||||
iblock = sect->u.range.iblock;
|
||||
break;
|
||||
|
||||
case H5HF_SECT_INDIRECT:
|
||||
iblock = sect->u.indirect.iblock;
|
||||
break;
|
||||
} /* end switch */
|
||||
|
||||
/* Release indirect block, if there was one */
|
||||
if(iblock)
|
||||
if(H5HF_iblock_decr(iblock) < 0)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared indirect block")
|
||||
|
||||
/* Release the sections */
|
||||
H5FL_FREE(H5HF_free_section_t, item);
|
||||
H5FL_FREE(H5HF_free_section_t, sect);
|
||||
|
||||
FUNC_LEAVE_NOAPI(0)
|
||||
done:
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* H5HF_free_section_free_cb() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5HF_man_start_freelist
|
||||
*
|
||||
* Purpose: Start free list for existing heap, by bringing in root direct
|
||||
* or indirect block and it's free space sections.
|
||||
*
|
||||
* Return: SUCCEED/FAIL
|
||||
*
|
||||
* Programmer: Quincey Koziol
|
||||
* koziol@ncsa.uiuc.edu
|
||||
* Apr 25 2006
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static herr_t
|
||||
H5HF_man_start_freelist(H5HF_hdr_t *hdr, hid_t dxpl_id)
|
||||
{
|
||||
herr_t ret_value = SUCCEED; /* Return value */
|
||||
|
||||
FUNC_ENTER_NOAPI_NOINIT(H5HF_man_start_freelist)
|
||||
|
||||
/*
|
||||
* Check arguments.
|
||||
*/
|
||||
HDassert(hdr);
|
||||
|
||||
/* Check for empty heap */
|
||||
if(!H5F_addr_defined(hdr->man_dtable.table_addr)) {
|
||||
#ifdef QAK
|
||||
HDfprintf(stderr, "%s: Empty heap to [not] start\n", FUNC);
|
||||
#endif /* QAK */
|
||||
/* Nothing to do */
|
||||
;
|
||||
} /* end if */
|
||||
/* Check for root direct block */
|
||||
else if(hdr->man_dtable.curr_root_rows == 0) {
|
||||
H5HF_direct_t *dblock; /* Pointer to direct block to query */
|
||||
haddr_t dblock_addr; /* Direct block address */
|
||||
size_t dblock_size; /* Direct block size */
|
||||
|
||||
#ifdef QAK
|
||||
HDfprintf(stderr, "%s: Root direct block to start\n", FUNC);
|
||||
#endif /* QAK */
|
||||
/* Bring root direct block into memory */
|
||||
/* (which will parse it's free list) */
|
||||
/* (Could create an "opaque" section for it, but it doesn't seem worthwhile) */
|
||||
dblock_addr = hdr->man_dtable.table_addr;
|
||||
dblock_size = hdr->man_dtable.cparam.start_block_size;
|
||||
if(NULL == (dblock = H5HF_man_dblock_protect(hdr, dxpl_id, dblock_addr, dblock_size, NULL, 0, H5AC_WRITE)))
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect fractal heap direct block")
|
||||
|
||||
/* Unlock direct block */
|
||||
if(H5AC_unprotect(hdr->f, dxpl_id, H5AC_FHEAP_DBLOCK, dblock_addr, dblock, H5AC__NO_FLAGS_SET) < 0)
|
||||
HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap direct block")
|
||||
dblock = NULL;
|
||||
} /* end if */
|
||||
/* Must be a root indirect block */
|
||||
else {
|
||||
H5HF_indirect_t *iblock; /* Pointer to root indirect block to query */
|
||||
haddr_t iblock_addr; /* Indirect block's address */
|
||||
|
||||
#ifdef QAK
|
||||
HDfprintf(stderr, "%s: Root indirect block to start\n", FUNC);
|
||||
#endif /* QAK */
|
||||
/* Get indirect block info */
|
||||
iblock_addr = hdr->man_dtable.table_addr;
|
||||
|
||||
/* Lock root indirect block */
|
||||
/* (which will parse it's free space) */
|
||||
if(NULL == (iblock = H5HF_man_iblock_protect(hdr, dxpl_id, iblock_addr, hdr->man_dtable.curr_root_rows, NULL, 0, H5AC_WRITE)))
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect fractal heap indirect block")
|
||||
|
||||
/* Release the root indirect block */
|
||||
if(H5AC_unprotect(hdr->f, dxpl_id, H5AC_FHEAP_IBLOCK, iblock_addr, iblock, H5AC__NO_FLAGS_SET) < 0)
|
||||
HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap indirect block")
|
||||
iblock = NULL;
|
||||
} /* end else */
|
||||
|
||||
/* Mark heap as being in sync now */
|
||||
hdr->freelist_sync = TRUE;
|
||||
|
||||
done:
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* end H5HF_man_start_freelist() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5HF_man_find
|
||||
@ -121,10 +237,11 @@ H5HF_free_section_free_cb(void *item, void UNUSED *key, void UNUSED *op_data)
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
H5HF_man_find(H5HF_t *hdr, hid_t dxpl_id, size_t request,
|
||||
H5HF_man_find(H5HF_hdr_t *hdr, hid_t dxpl_id, size_t request,
|
||||
H5HF_free_section_t **sec_node/*out*/)
|
||||
{
|
||||
htri_t node_found; /* Whether an existing free list node was found */
|
||||
hbool_t search_again; /* Whether to search again for another free section */
|
||||
herr_t ret_value = SUCCEED; /* Return value */
|
||||
|
||||
FUNC_ENTER_NOAPI_NOINIT(H5HF_man_find)
|
||||
@ -139,14 +256,51 @@ HDfprintf(stderr, "%s: request = %Zu\n", FUNC, request);
|
||||
HDassert(request > 0);
|
||||
HDassert(sec_node);
|
||||
|
||||
/* Look for free space in global free list */
|
||||
if((node_found = H5HF_flist_find(hdr->flist, request, (void **)sec_node)) < 0)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "can't locate free space in fractal heap direct block")
|
||||
/* Search for free space in the globel free list, until a non-opaque node is found */
|
||||
do {
|
||||
/* Done searching, unless opaque node found */
|
||||
search_again = FALSE;
|
||||
|
||||
/* Look for free space in global free list */
|
||||
if((node_found = H5HF_flist_find(hdr->flist, request, (void **)sec_node)) < 0)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "can't locate free space in fractal heap direct block")
|
||||
|
||||
/* Check for opaque section */
|
||||
if(node_found) {
|
||||
if((*sec_node)->type == H5HF_SECT_OPAQUE) {
|
||||
/* Break opaque section down into component sections */
|
||||
if(H5HF_man_iblock_alloc_opaque(hdr, dxpl_id, sec_node) < 0)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "can't break up opaque free section")
|
||||
|
||||
/* Search again */
|
||||
search_again = TRUE;
|
||||
} /* end if */
|
||||
} /* end if */
|
||||
/* If we didn't find a node, check if we've looked in all the direct blocks in the heap for space */
|
||||
else {
|
||||
#ifdef QAK
|
||||
HDfprintf(stderr, "%s: hdr->freelist_sync = %u\n", FUNC, (unsigned)hdr->freelist_sync);
|
||||
#endif /* QAK */
|
||||
if(!hdr->freelist_sync) {
|
||||
#ifdef QAK
|
||||
HDfprintf(stderr, "%s: Start free list for existing blocks in heap\n", FUNC);
|
||||
#endif /* QAK */
|
||||
/* Start freelist for existing heap */
|
||||
if(H5HF_man_start_freelist(hdr, dxpl_id) < 0)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTCREATE, FAIL, "can't start fractal heap free list")
|
||||
|
||||
/* Search again */
|
||||
search_again = TRUE;
|
||||
} /* end if */
|
||||
} /* end else */
|
||||
} while(search_again);
|
||||
|
||||
/* XXX: Make certain we've loaded all the direct blocks in the heap */
|
||||
|
||||
/* If we didn't find a node, go make one big enough to hold the requested block */
|
||||
if(!node_found) {
|
||||
#ifdef QAK
|
||||
HDfprintf(stderr, "%s: Allocate new direct block\n", FUNC);
|
||||
#endif /* QAK */
|
||||
/* Allocate direct block big enough to hold requested size */
|
||||
if(H5HF_man_dblock_new(hdr, dxpl_id, request) < 0)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTCREATE, FAIL, "can't create fractal heap direct block")
|
||||
@ -158,10 +312,9 @@ HDfprintf(stderr, "%s: request = %Zu\n", FUNC, request);
|
||||
} /* end if */
|
||||
HDassert(*sec_node);
|
||||
#ifdef QAK
|
||||
HDfprintf(stderr, "%s: (*sec_node)->block_addr = %a\n", FUNC, (*sec_node)->block_addr);
|
||||
HDfprintf(stderr, "%s: (*sec_node)->block_size = %Zu\n", FUNC, (*sec_node)->block_size);
|
||||
HDfprintf(stderr, "%s: (*sec_node)->sect_addr = %a\n", FUNC, (*sec_node)->sect_addr);
|
||||
HDfprintf(stderr, "%s: (*sec_node)->sect_size = %Zu\n", FUNC, (*sec_node)->sect_size);
|
||||
HDfprintf(stderr, "%s: (*sec_node)->type = %u\n", FUNC, (unsigned)(*sec_node)->type);
|
||||
#endif /* QAK */
|
||||
|
||||
done:
|
||||
@ -183,7 +336,7 @@ done:
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
H5HF_man_insert(H5HF_t *hdr, hid_t dxpl_id, H5HF_free_section_t *sec_node,
|
||||
H5HF_man_insert(H5HF_hdr_t *hdr, hid_t dxpl_id, H5HF_free_section_t *sec_node,
|
||||
size_t obj_size, const void *obj, void *id)
|
||||
{
|
||||
H5HF_direct_t *dblock = NULL; /* Pointer to direct block to modify */
|
||||
@ -205,8 +358,9 @@ H5HF_man_insert(H5HF_t *hdr, hid_t dxpl_id, H5HF_free_section_t *sec_node,
|
||||
#ifdef QAK
|
||||
HDfprintf(stderr, "%s: sec_node->sect_addr = %a\n", FUNC, sec_node->sect_addr);
|
||||
HDfprintf(stderr, "%s: sec_node->sect_size = %Zu\n", FUNC, sec_node->sect_size);
|
||||
HDfprintf(stderr, "%s: sec_node->u.indirect.iblock_addr = %a\n", FUNC, sec_node->u.indirect.iblock_addr);
|
||||
HDfprintf(stderr, "%s: sec_node->u.indirect.iblock_nrows = %u\n", FUNC, sec_node->u.indirect.iblock_nrows);
|
||||
HDfprintf(stderr, "%s: sec_node->u.indirect.iblock = %p\n", FUNC, sec_node->u.indirect.iblock);
|
||||
if(sec_node->u.indirect.iblock)
|
||||
HDfprintf(stderr, "%s: sec_node->u.indirect.iblock->addr = %a\n", FUNC, sec_node->u.indirect.iblock->addr);
|
||||
HDfprintf(stderr, "%s: sec_node->u.indirect.row = %u\n", FUNC, sec_node->u.indirect.row);
|
||||
HDfprintf(stderr, "%s: sec_node->u.indirect.col = %u\n", FUNC, sec_node->u.indirect.col);
|
||||
HDfprintf(stderr, "%s: sec_node->u.indirect.num_entries = %u\n", FUNC, sec_node->u.indirect.num_entries);
|
||||
@ -215,7 +369,7 @@ HDfprintf(stderr, "%s: sec_node->u.indirect.indir_nrows = %u\n", FUNC, sec_node-
|
||||
#endif /* QAK */
|
||||
|
||||
/* Allocate 'single' selection out of 'indirect' selection */
|
||||
if(H5HF_man_iblock_alloc_indirect(hdr, dxpl_id, &sec_node, obj_size) < 0)
|
||||
if(H5HF_man_iblock_alloc_indirect(hdr, dxpl_id, &sec_node) < 0)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "can't break up indirect free section")
|
||||
} /* end if */
|
||||
/* Check for range section */
|
||||
@ -223,14 +377,15 @@ HDfprintf(stderr, "%s: sec_node->u.indirect.indir_nrows = %u\n", FUNC, sec_node-
|
||||
#ifdef QAK
|
||||
HDfprintf(stderr, "%s: sec_node->sect_addr = %a\n", FUNC, sec_node->sect_addr);
|
||||
HDfprintf(stderr, "%s: sec_node->sect_size = %Zu\n", FUNC, sec_node->sect_size);
|
||||
HDfprintf(stderr, "%s: sec_node->u.range.iblock_addr = %a\n", FUNC, sec_node->u.range.iblock_addr);
|
||||
HDfprintf(stderr, "%s: sec_node->u.range.iblock_nrows = %u\n", FUNC, sec_node->u.range.iblock_nrows);
|
||||
HDfprintf(stderr, "%s: sec_node->u.range.iblock = %p\n", FUNC, sec_node->u.range.iblock);
|
||||
if(sec_node->u.range.iblock)
|
||||
HDfprintf(stderr, "%s: sec_node->u.range.iblock->addr = %a\n", FUNC, sec_node->u.range.iblock->addr);
|
||||
HDfprintf(stderr, "%s: sec_node->u.range.row = %u\n", FUNC, sec_node->u.range.row);
|
||||
HDfprintf(stderr, "%s: sec_node->u.range.col = %u\n", FUNC, sec_node->u.range.col);
|
||||
HDfprintf(stderr, "%s: sec_node->u.range.num_entries = %u\n", FUNC, sec_node->u.range.num_entries);
|
||||
#endif /* QAK */
|
||||
/* Allocate 'single' selection out of 'range' selection */
|
||||
if(H5HF_man_iblock_alloc_range(hdr, dxpl_id, &sec_node, obj_size) < 0)
|
||||
if(H5HF_man_iblock_alloc_range(hdr, dxpl_id, &sec_node) < 0)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "can't break up range free section")
|
||||
} /* end if */
|
||||
|
||||
@ -238,11 +393,15 @@ HDfprintf(stderr, "%s: sec_node->u.range.num_entries = %u\n", FUNC, sec_node->u.
|
||||
#ifdef QAK
|
||||
HDfprintf(stderr, "%s: sec_node->sect_addr = %a\n", FUNC, sec_node->sect_addr);
|
||||
HDfprintf(stderr, "%s: sec_node->sect_size = %Zu\n", FUNC, sec_node->sect_size);
|
||||
HDfprintf(stderr, "%s: sec_node->u.single.parent = %p\n", FUNC, sec_node->u.single.parent);
|
||||
if(sec_node->u.single.parent)
|
||||
HDfprintf(stderr, "%s: sec_node->u.single.parent->addr = %a\n", FUNC, sec_node->u.single.parent->addr);
|
||||
HDfprintf(stderr, "%s: sec_node->u.single.par_entry = %u\n", FUNC, sec_node->u.single.par_entry);
|
||||
HDfprintf(stderr, "%s: sec_node->u.single.dblock_addr = %a\n", FUNC, sec_node->u.single.dblock_addr);
|
||||
HDfprintf(stderr, "%s: sec_node->u.single.dblock_size = %Zu\n", FUNC, sec_node->u.single.dblock_size);
|
||||
#endif /* QAK */
|
||||
dblock_addr = sec_node->u.single.dblock_addr;
|
||||
if(NULL == (dblock = H5AC_protect(hdr->f, dxpl_id, H5AC_FHEAP_DBLOCK, dblock_addr, &sec_node->u.single.dblock_size, hdr, H5AC_WRITE)))
|
||||
if(NULL == (dblock = H5HF_man_dblock_protect(hdr, dxpl_id, dblock_addr, sec_node->u.single.dblock_size, sec_node->u.single.parent, sec_node->u.single.par_entry, H5AC_WRITE)))
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to load fractal heap direct block")
|
||||
|
||||
/* Insert object into block */
|
||||
@ -314,6 +473,14 @@ HDfprintf(stderr, "%s: node->size = %Zu\n", FUNC, node->size);
|
||||
free_frag_size = (unsigned char )(node->size - full_obj_size);
|
||||
whole_node = TRUE;
|
||||
|
||||
/* Drop reference count on parent indirect block of direct block that free section is in */
|
||||
HDassert(dblock->parent == NULL ||
|
||||
sec_node->u.single.parent == NULL ||
|
||||
dblock->parent == sec_node->u.single.parent);
|
||||
if(sec_node->u.single.parent)
|
||||
if(H5HF_iblock_decr(sec_node->u.single.parent) < 0)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared indirect block")
|
||||
|
||||
/* Release the memory for the free list node & section */
|
||||
H5FL_FREE(H5HF_direct_free_node_t, node);
|
||||
H5FL_FREE(H5HF_free_section_t, sec_node);
|
||||
@ -350,7 +517,7 @@ HDfprintf(stderr, "%s: full_obj_size = %Zu\n", FUNC, full_obj_size);
|
||||
HDfprintf(stderr, "%s: alloc_obj_size = %Zu\n", FUNC, alloc_obj_size);
|
||||
#endif /* QAK */
|
||||
/* Reduce space available in parent block(s) */
|
||||
if(H5HF_man_dblock_adj_free(dxpl_id, dblock, -(ssize_t)free_obj_size) < 0)
|
||||
if(H5HF_man_dblock_adj_free(dblock, -(ssize_t)free_obj_size) < 0)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't adjust free space for direct block & parents")
|
||||
|
||||
/* Encode the object in the block */
|
||||
@ -391,7 +558,7 @@ HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "inserting within mapped managed bl
|
||||
hdr->nobjs++;
|
||||
|
||||
/* Mark heap header as modified */
|
||||
if(H5HF_hdr_dirty(dxpl_id, hdr) < 0)
|
||||
if(H5HF_hdr_dirty(hdr) < 0)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTDIRTY, FAIL, "can't mark heap header as dirty")
|
||||
|
||||
done:
|
||||
@ -417,7 +584,7 @@ done:
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
H5HF_man_read(H5HF_t *hdr, hid_t dxpl_id, hsize_t obj_off, size_t obj_len, void *obj)
|
||||
H5HF_man_read(H5HF_hdr_t *hdr, hid_t dxpl_id, hsize_t obj_off, size_t obj_len, void *obj)
|
||||
{
|
||||
H5HF_direct_t *dblock; /* Pointer to direct block to query */
|
||||
size_t blk_off; /* Offset of object in block */
|
||||
@ -441,11 +608,11 @@ HDfprintf(stderr, "%s: obj_off = %Hu, obj_len = %Zu\n", FUNC, obj_off, obj_len);
|
||||
/* Check for root direct block */
|
||||
if(hdr->man_dtable.curr_root_rows == 0) {
|
||||
/* Set direct block info */
|
||||
dblock_addr = hdr->man_dtable.table_addr;
|
||||
dblock_size = hdr->man_dtable.cparam.start_block_size;
|
||||
dblock_addr = hdr->man_dtable.table_addr;
|
||||
dblock_size = hdr->man_dtable.cparam.start_block_size;
|
||||
|
||||
/* Lock direct block */
|
||||
if(NULL == (dblock = H5AC_protect(hdr->f, dxpl_id, H5AC_FHEAP_DBLOCK, dblock_addr, &dblock_size, hdr, H5AC_READ)))
|
||||
if(NULL == (dblock = H5HF_man_dblock_protect(hdr, dxpl_id, dblock_addr, dblock_size, NULL, 0, H5AC_READ)))
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect fractal heap direct block")
|
||||
} /* end if */
|
||||
else {
|
||||
@ -467,8 +634,8 @@ HDfprintf(stderr, "%s: row = %u, col = %u\n", FUNC, row, col);
|
||||
HDfprintf(stderr, "%s: iblock_addr = %a\n", FUNC, iblock_addr);
|
||||
#endif /* QAK */
|
||||
|
||||
/* Lock indirect block */
|
||||
if(NULL == (iblock = H5AC_protect(hdr->f, dxpl_id, H5AC_FHEAP_IBLOCK, iblock_addr, &hdr->man_dtable.curr_root_rows, hdr, H5AC_READ)))
|
||||
/* Lock root indirect block */
|
||||
if(NULL == (iblock = H5HF_man_iblock_protect(hdr, dxpl_id, iblock_addr, hdr->man_dtable.curr_root_rows, NULL, 0, H5AC_READ)))
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect fractal heap indirect block")
|
||||
|
||||
/* Check for indirect block row */
|
||||
@ -490,7 +657,7 @@ HDfprintf(stderr, "%s: entry = %Zu\n", FUNC, entry);
|
||||
new_iblock_addr = iblock->ents[entry].addr;
|
||||
|
||||
/* Lock new indirect block */
|
||||
if(NULL == (new_iblock = H5AC_protect(hdr->f, dxpl_id, H5AC_FHEAP_IBLOCK, new_iblock_addr, &nrows, hdr, H5AC_READ)))
|
||||
if(NULL == (new_iblock = H5HF_man_iblock_protect(hdr, dxpl_id, new_iblock_addr, nrows, iblock, entry, H5AC_READ)))
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect fractal heap indirect block")
|
||||
|
||||
/* Release the current indirect block */
|
||||
@ -525,7 +692,7 @@ HDfprintf(stderr, "%s: entry address = %a\n", FUNC, iblock->ents[entry].addr);
|
||||
dblock_size = hdr->man_dtable.row_block_size[row];
|
||||
|
||||
/* Lock direct block */
|
||||
if(NULL == (dblock = H5AC_protect(hdr->f, dxpl_id, H5AC_FHEAP_DBLOCK, dblock_addr, &dblock_size, hdr, H5AC_READ)))
|
||||
if(NULL == (dblock = H5HF_man_dblock_protect(hdr, dxpl_id, dblock_addr, dblock_size, iblock, entry, H5AC_READ)))
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect fractal heap direct block")
|
||||
|
||||
/* Unlock indirect block */
|
||||
|
693
src/H5HFiter.c
Normal file
693
src/H5HFiter.c
Normal file
@ -0,0 +1,693 @@
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* 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: H5HFiter.c
|
||||
* Apr 24 2006
|
||||
* Quincey Koziol <koziol@ncsa.uiuc.edu>
|
||||
*
|
||||
* Purpose: Block iteration routines for fractal heaps.
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/****************/
|
||||
/* Module Setup */
|
||||
/****************/
|
||||
|
||||
#define H5HF_PACKAGE /*suppress error about including H5HFpkg */
|
||||
|
||||
/***********/
|
||||
/* Headers */
|
||||
/***********/
|
||||
#include "H5private.h" /* Generic Functions */
|
||||
#include "H5Eprivate.h" /* Error handling */
|
||||
#include "H5HFpkg.h" /* Fractal heaps */
|
||||
#include "H5Vprivate.h" /* Vectors and arrays */
|
||||
|
||||
/****************/
|
||||
/* Local Macros */
|
||||
/****************/
|
||||
|
||||
|
||||
/******************/
|
||||
/* Local Typedefs */
|
||||
/******************/
|
||||
|
||||
|
||||
/********************/
|
||||
/* Package Typedefs */
|
||||
/********************/
|
||||
|
||||
|
||||
/********************/
|
||||
/* Local Prototypes */
|
||||
/********************/
|
||||
|
||||
|
||||
/*********************/
|
||||
/* Package Variables */
|
||||
/*********************/
|
||||
|
||||
|
||||
/*****************************/
|
||||
/* Library Private Variables */
|
||||
/*****************************/
|
||||
|
||||
|
||||
/*******************/
|
||||
/* Local Variables */
|
||||
/*******************/
|
||||
|
||||
/* Declare a free list to manage the H5HF_block_loc_t struct */
|
||||
H5FL_DEFINE(H5HF_block_loc_t);
|
||||
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5HF_man_iter_init
|
||||
*
|
||||
* Purpose: Initialize a block iterator for walking over all the blocks
|
||||
* in a fractal heap. (initialization finishes when iterator is
|
||||
* actually used)
|
||||
*
|
||||
* Return: SUCCEED/FAIL
|
||||
*
|
||||
* Programmer: Quincey Koziol
|
||||
* koziol@ncsa.uiuc.edu
|
||||
* Apr 24 2006
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
H5HF_man_iter_init(H5HF_block_iter_t *biter)
|
||||
{
|
||||
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_man_iter_init)
|
||||
|
||||
/*
|
||||
* Check arguments.
|
||||
*/
|
||||
HDassert(biter);
|
||||
|
||||
/* Reset block iterator information */
|
||||
HDmemset(biter, 0, sizeof(H5HF_block_iter_t));
|
||||
|
||||
FUNC_LEAVE_NOAPI(SUCCEED)
|
||||
} /* end H5HF_man_iter_init() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5HF_man_iter_start_offset
|
||||
*
|
||||
* Purpose: Initialize a block iterator to a particular location, given
|
||||
* an offset in the heap
|
||||
*
|
||||
* Return: SUCCEED/FAIL
|
||||
*
|
||||
* Programmer: Quincey Koziol
|
||||
* koziol@ncsa.uiuc.edu
|
||||
* Apr 24 2006
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
H5HF_man_iter_start_offset(H5HF_hdr_t *hdr, hid_t dxpl_id,
|
||||
H5HF_block_iter_t *biter, hsize_t offset)
|
||||
{
|
||||
H5HF_indirect_t *iblock; /* Indirect block for location context */
|
||||
haddr_t iblock_addr; /* Address of indirect block */
|
||||
unsigned iblock_nrows; /* # of rows in indirect block */
|
||||
H5HF_indirect_t *iblock_parent; /* Parent indirect block of location context */
|
||||
unsigned iblock_par_entry; /* Entry within parent indirect block */
|
||||
hsize_t curr_offset; /* Current offset, as adjusted */
|
||||
unsigned row; /* Current row we are on */
|
||||
unsigned col; /* Column in row */
|
||||
hbool_t root_block = TRUE; /* Flag to indicate the current block is the root indirect block */
|
||||
herr_t ret_value = SUCCEED; /* Return value */
|
||||
|
||||
FUNC_ENTER_NOAPI_NOINIT(H5HF_man_iter_start_offset)
|
||||
|
||||
/*
|
||||
* Check arguments.
|
||||
*/
|
||||
HDassert(biter);
|
||||
HDassert(!biter->ready);
|
||||
|
||||
/* Check for empty heap */
|
||||
HDassert(offset >= hdr->man_dtable.cparam.start_block_size);
|
||||
|
||||
/* Allocate level structure */
|
||||
if(NULL == (biter->curr = H5FL_MALLOC(H5HF_block_loc_t)))
|
||||
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for direct block free list section")
|
||||
|
||||
/*
|
||||
1: <Scan down block offsets for dtable rows until find a row >= offset>
|
||||
<Set current location's row, col, entry & size>
|
||||
<If row < max_direct_rows>
|
||||
<Done>
|
||||
<Else - row > max_direct_rows>
|
||||
<Create new block level>
|
||||
<Link new block level into iterator>
|
||||
<Adjust offset for block offset for row>
|
||||
<Make new block level the current context>
|
||||
<Goto 1>
|
||||
|
||||
*/
|
||||
do {
|
||||
/* Walk down the rows in the doubling table until we've found the correct row for the next block */
|
||||
for(row = 0; row < hdr->man_dtable.max_root_rows; row++)
|
||||
if((offset >= hdr->man_dtable.row_block_off[row]) &&
|
||||
(offset < hdr->man_dtable.row_block_off[row] +
|
||||
(hdr->man_dtable.cparam.width * hdr->man_dtable.row_block_size[row])))
|
||||
break;
|
||||
|
||||
/* Adjust offset by row offset */
|
||||
curr_offset = offset - hdr->man_dtable.row_block_off[row];
|
||||
|
||||
/* Compute column */
|
||||
col = curr_offset / hdr->man_dtable.row_block_size[row];
|
||||
#ifdef QAK
|
||||
HDfprintf(stderr, "%s: row = %u, col = %u\n", FUNC, row, col);
|
||||
HDfprintf(stderr, "%s: offset = %Hu\n", FUNC, offset);
|
||||
HDfprintf(stderr, "%s: curr_offset = %Hu\n", FUNC, curr_offset);
|
||||
#endif /* QAK */
|
||||
|
||||
/* Set the current level's context */
|
||||
biter->curr->row = row;
|
||||
biter->curr->col = col;
|
||||
biter->curr->entry = (row * hdr->man_dtable.cparam.width) + col;
|
||||
#ifdef QAK
|
||||
HDfprintf(stderr, "%s: biter->curr->entry = %u\n", FUNC, biter->curr->entry);
|
||||
#endif /* QAK */
|
||||
|
||||
/* Get the context indirect block's information */
|
||||
if(root_block) {
|
||||
iblock_addr = hdr->man_dtable.table_addr;
|
||||
iblock_nrows = hdr->man_dtable.curr_root_rows;
|
||||
iblock_parent = NULL;
|
||||
iblock_par_entry = 0;
|
||||
|
||||
/* The root block can't go up further... */
|
||||
biter->curr->up = NULL;
|
||||
|
||||
/* Next time through the loop will not be with the root indirect block */
|
||||
root_block = FALSE;
|
||||
} /* end if */
|
||||
else {
|
||||
hsize_t child_size; /* Size of new indirect block to create */
|
||||
|
||||
/* Retrieve the parent information from the previous context location */
|
||||
iblock_parent = biter->curr->up->context;
|
||||
iblock_par_entry = biter->curr->up->entry;
|
||||
|
||||
/* Look up the address of context indirect block */
|
||||
iblock_addr = iblock_parent->ents[iblock_par_entry].addr;
|
||||
|
||||
/* Compute # of rows in context indirect block */
|
||||
child_size = hdr->man_dtable.row_block_size[biter->curr->up->row];
|
||||
iblock_nrows = (H5V_log2_gen(child_size) - hdr->man_dtable.first_row_bits) + 1;
|
||||
} /* end else */
|
||||
|
||||
/* Load indirect block for this context location */
|
||||
if(NULL == (iblock = H5HF_man_iblock_protect(hdr, dxpl_id, iblock_addr, iblock_nrows, iblock_parent, iblock_par_entry, H5AC_WRITE)))
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect fractal heap indirect block")
|
||||
|
||||
/* Make indirect block the context for the current location */
|
||||
biter->curr->context = iblock;
|
||||
|
||||
/* Hold the indirect block with the location */
|
||||
if(H5HF_iblock_incr(biter->curr->context) < 0)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, FAIL, "can't increment reference count on shared indirect block")
|
||||
|
||||
/* Release the current indirect block */
|
||||
if(H5AC_unprotect(hdr->f, dxpl_id, H5AC_FHEAP_IBLOCK, iblock_addr, iblock, H5AC__NO_FLAGS_SET) < 0)
|
||||
HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap indirect block")
|
||||
iblock = NULL;
|
||||
|
||||
/* See if the location falls in a direct block row */
|
||||
/* Or, if the offset has just filled up a direct or indirect block */
|
||||
if(curr_offset == (col * hdr->man_dtable.row_block_size[row]) || row < hdr->man_dtable.max_direct_rows) {
|
||||
HDassert(curr_offset - (col * hdr->man_dtable.row_block_size[row]) == 0);
|
||||
break; /* Done now */
|
||||
} /* end if */
|
||||
/* Indirect block row */
|
||||
else {
|
||||
H5HF_block_loc_t *new_loc; /* Pointer to new block location */
|
||||
|
||||
/* Allocate level structure */
|
||||
if(NULL == (new_loc = H5FL_MALLOC(H5HF_block_loc_t)))
|
||||
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for direct block free list section")
|
||||
|
||||
/* Link new level into iterator */
|
||||
new_loc->up = biter->curr;
|
||||
|
||||
/* Adjust offset for new level */
|
||||
offset = curr_offset - (col * hdr->man_dtable.row_block_size[row]);
|
||||
|
||||
/* Make new block the current context */
|
||||
biter->curr = new_loc;
|
||||
} /* end else */
|
||||
} while(1); /* Breaks out in middle */
|
||||
|
||||
/* Set flag to indicate block iterator finished initializing */
|
||||
biter->ready = TRUE;
|
||||
|
||||
done:
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* end H5HF_man_iter_start_offset() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5HF_man_iter_start
|
||||
*
|
||||
* Purpose: Initialize a block iterator to a particular location within
|
||||
* an indirect block
|
||||
*
|
||||
* Return: SUCCEED/FAIL
|
||||
*
|
||||
* Programmer: Quincey Koziol
|
||||
* koziol@ncsa.uiuc.edu
|
||||
* Apr 24 2006
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
H5HF_man_iter_start_entry(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter,
|
||||
H5HF_indirect_t *iblock, unsigned start_entry)
|
||||
{
|
||||
H5HF_block_loc_t *new_loc; /* Pointer to new block location */
|
||||
herr_t ret_value = SUCCEED; /* Return value */
|
||||
|
||||
FUNC_ENTER_NOAPI_NOINIT(H5HF_man_iter_start_entry)
|
||||
|
||||
/*
|
||||
* Check arguments.
|
||||
*/
|
||||
HDassert(hdr);
|
||||
HDassert(biter);
|
||||
HDassert(!biter->ready);
|
||||
HDassert(iblock);
|
||||
|
||||
/* Create new location for iterator */
|
||||
if(NULL == (new_loc = H5FL_MALLOC(H5HF_block_loc_t)))
|
||||
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for direct block free list section")
|
||||
|
||||
/* Set up location context */
|
||||
new_loc->entry = start_entry;
|
||||
new_loc->row = start_entry / hdr->man_dtable.cparam.width;
|
||||
new_loc->col = start_entry % hdr->man_dtable.cparam.width;
|
||||
new_loc->context = iblock;
|
||||
new_loc->up = NULL;
|
||||
|
||||
/* Increment reference count on indirect block */
|
||||
if(H5HF_iblock_incr(new_loc->context) < 0)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, FAIL, "can't increment reference count on shared indirect block")
|
||||
|
||||
/* Make new location the current location */
|
||||
biter->curr = new_loc;
|
||||
|
||||
/* Set flag to indicate block iterator finished initializing */
|
||||
biter->ready = TRUE;
|
||||
|
||||
done:
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* end H5HF_man_iter_start_entry() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5HF_man_iter_reset
|
||||
*
|
||||
* Purpose: Reset a block iterator to it's initial state, freeing any
|
||||
* location context it currently has
|
||||
*
|
||||
* Return: SUCCEED/FAIL
|
||||
*
|
||||
* Programmer: Quincey Koziol
|
||||
* koziol@ncsa.uiuc.edu
|
||||
* Apr 24 2006
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
H5HF_man_iter_reset(H5HF_block_iter_t *biter)
|
||||
{
|
||||
herr_t ret_value = SUCCEED; /* Return value */
|
||||
|
||||
FUNC_ENTER_NOAPI_NOINIT(H5HF_man_iter_reset)
|
||||
|
||||
/*
|
||||
* Check arguments.
|
||||
*/
|
||||
HDassert(biter);
|
||||
|
||||
/* Free any location contexts that exist */
|
||||
if(biter->curr) {
|
||||
H5HF_block_loc_t *curr_loc; /* Pointer to current block location */
|
||||
H5HF_block_loc_t *next_loc; /* Pointer to next block location */
|
||||
|
||||
/* Free location contexts */
|
||||
curr_loc = biter->curr;
|
||||
while(curr_loc) {
|
||||
/* Get pointer to next node */
|
||||
next_loc = curr_loc->up;
|
||||
|
||||
/* If this node is holding an indirect block, release the block */
|
||||
if(curr_loc->context)
|
||||
if(H5HF_iblock_decr(curr_loc->context) < 0)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared indirect block")
|
||||
|
||||
/* Free the current location context */
|
||||
H5FL_FREE(H5HF_block_loc_t, curr_loc);
|
||||
|
||||
/* Advance to next location */
|
||||
curr_loc = next_loc;
|
||||
} /* end while */
|
||||
|
||||
/* Reset top location context */
|
||||
biter->curr = NULL;
|
||||
} /* end if */
|
||||
|
||||
/* Reset block iterator flags */
|
||||
biter->ready = FALSE;
|
||||
|
||||
done:
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* end H5HF_man_iter_reset() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5HF_man_iter_next
|
||||
*
|
||||
* Purpose: Advance to the next block within the current block of the heap
|
||||
*
|
||||
* Return: SUCCEED/FAIL
|
||||
*
|
||||
* Programmer: Quincey Koziol
|
||||
* koziol@ncsa.uiuc.edu
|
||||
* Apr 24 2006
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
H5HF_man_iter_next(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter, unsigned nentries)
|
||||
{
|
||||
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_man_iter_next)
|
||||
|
||||
/*
|
||||
* Check arguments.
|
||||
*/
|
||||
HDassert(biter);
|
||||
HDassert(biter->curr);
|
||||
HDassert(biter->curr->context);
|
||||
|
||||
/* Advance to next entry in current block */
|
||||
HDassert(biter->curr->row < biter->curr->context->nrows);
|
||||
if(nentries == 1) {
|
||||
/* Increment block entry */
|
||||
biter->curr->entry++;
|
||||
|
||||
/* Increment column */
|
||||
biter->curr->col++;
|
||||
|
||||
/* Check for walking off end of column */
|
||||
if(biter->curr->col == hdr->man_dtable.cparam.width) {
|
||||
/* Reset column */
|
||||
biter->curr->col = 0;
|
||||
|
||||
/* Increment row & block size */
|
||||
biter->curr->row++;
|
||||
} /* end if */
|
||||
} /* end if */
|
||||
/* Advance multiple entries */
|
||||
else {
|
||||
biter->curr->entry += nentries;
|
||||
biter->curr->row = biter->curr->entry / hdr->man_dtable.cparam.width;
|
||||
biter->curr->col = biter->curr->entry % hdr->man_dtable.cparam.width;
|
||||
} /* end else */
|
||||
HDassert(biter->curr->row <= biter->curr->context->nrows);
|
||||
|
||||
FUNC_LEAVE_NOAPI(SUCCEED)
|
||||
} /* end H5HF_man_iter_next() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5HF_man_iter_up
|
||||
*
|
||||
* Purpose: Move iterator up one level
|
||||
*
|
||||
* Return: SUCCEED/FAIL
|
||||
*
|
||||
* Programmer: Quincey Koziol
|
||||
* koziol@ncsa.uiuc.edu
|
||||
* Apr 24 2006
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
H5HF_man_iter_up(H5HF_block_iter_t *biter)
|
||||
{
|
||||
H5HF_block_loc_t *up_loc; /* Pointer to 'up' block location */
|
||||
herr_t ret_value = SUCCEED; /* Return value */
|
||||
|
||||
FUNC_ENTER_NOAPI_NOINIT(H5HF_man_iter_up)
|
||||
|
||||
/*
|
||||
* Check arguments.
|
||||
*/
|
||||
HDassert(biter);
|
||||
HDassert(biter->ready);
|
||||
HDassert(biter->curr);
|
||||
HDassert(biter->curr->up);
|
||||
HDassert(biter->curr->context);
|
||||
|
||||
/* Release hold on current location's indirect block */
|
||||
if(H5HF_iblock_decr(biter->curr->context) < 0)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared indirect block")
|
||||
|
||||
/* Get pointer to location context above this one */
|
||||
up_loc = biter->curr->up;
|
||||
|
||||
/* Release this location */
|
||||
H5FL_FREE(H5HF_block_loc_t, biter->curr);
|
||||
|
||||
/* Point location to next location up */
|
||||
biter->curr = up_loc;
|
||||
|
||||
done:
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* end H5HF_man_iter_up() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5HF_man_iter_down
|
||||
*
|
||||
* Purpose: Move iterator down one level
|
||||
*
|
||||
* Return: SUCCEED/FAIL
|
||||
*
|
||||
* Programmer: Quincey Koziol
|
||||
* koziol@ncsa.uiuc.edu
|
||||
* Apr 24 2006
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
H5HF_man_iter_down(H5HF_block_iter_t *biter, H5HF_indirect_t *iblock)
|
||||
{
|
||||
H5HF_block_loc_t *down_loc; /* Pointer to new 'down' block location */
|
||||
herr_t ret_value = SUCCEED; /* Return value */
|
||||
|
||||
FUNC_ENTER_NOAPI_NOINIT(H5HF_man_iter_down)
|
||||
|
||||
/*
|
||||
* Check arguments.
|
||||
*/
|
||||
HDassert(biter);
|
||||
HDassert(biter->ready);
|
||||
HDassert(biter->curr);
|
||||
HDassert(biter->curr->context);
|
||||
|
||||
/* Create new location to move down to */
|
||||
if(NULL == (down_loc = H5FL_MALLOC(H5HF_block_loc_t)))
|
||||
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for direct block free list section")
|
||||
|
||||
/* Initialize down location */
|
||||
down_loc->row = 0;
|
||||
down_loc->col = 0;
|
||||
down_loc->entry = 0;
|
||||
down_loc->context = iblock;
|
||||
down_loc->up = biter->curr;
|
||||
|
||||
/* Increment reference count on indirect block */
|
||||
if(H5HF_iblock_incr(down_loc->context) < 0)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, FAIL, "can't increment reference count on shared indirect block")
|
||||
|
||||
/* Make down location the current location */
|
||||
biter->curr = down_loc;
|
||||
|
||||
done:
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* end H5HF_man_iter_down() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5HF_man_iter_update_iblock
|
||||
*
|
||||
* Purpose: Update indirect block for current iterator location
|
||||
*
|
||||
* Return: SUCCEED/FAIL
|
||||
*
|
||||
* Programmer: Quincey Koziol
|
||||
* koziol@ncsa.uiuc.edu
|
||||
* Apr 24 2006
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
H5HF_man_iter_update_iblock(H5HF_block_iter_t *biter, H5HF_indirect_t *iblock)
|
||||
{
|
||||
herr_t ret_value = SUCCEED; /* Return value */
|
||||
|
||||
FUNC_ENTER_NOAPI_NOINIT(H5HF_man_iter_update_iblock)
|
||||
|
||||
/*
|
||||
* Check arguments.
|
||||
*/
|
||||
HDassert(biter);
|
||||
HDassert(biter->ready);
|
||||
HDassert(biter->curr);
|
||||
HDassert(biter->curr->context);
|
||||
|
||||
/* Release hold on current location's indirect block */
|
||||
if(H5HF_iblock_decr(biter->curr->context) < 0)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared indirect block")
|
||||
|
||||
/* Update current location's indirect block */
|
||||
biter->curr->context = iblock;
|
||||
|
||||
/* Add hold to current location's indirect block */
|
||||
if(H5HF_iblock_incr(biter->curr->context) < 0)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, FAIL, "can't increment reference count on shared indirect block")
|
||||
|
||||
done:
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* end H5HF_man_iter_update_iblock() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5HF_man_iter_curr
|
||||
*
|
||||
* Purpose: Retrieve information about the current block iterator location
|
||||
*
|
||||
* Return: SUCCEED/FAIL
|
||||
*
|
||||
* Programmer: Quincey Koziol
|
||||
* koziol@ncsa.uiuc.edu
|
||||
* Apr 24 2006
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
H5HF_man_iter_curr(H5HF_block_iter_t *biter, unsigned *row, unsigned *col,
|
||||
unsigned *entry, H5HF_indirect_t **block)
|
||||
{
|
||||
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_man_iter_curr)
|
||||
|
||||
/*
|
||||
* Check arguments.
|
||||
*/
|
||||
HDassert(biter);
|
||||
HDassert(biter->ready);
|
||||
|
||||
/* Retrieve the information asked for */
|
||||
if(row)
|
||||
*row = biter->curr->row;
|
||||
if(col)
|
||||
*col = biter->curr->col;
|
||||
if(entry)
|
||||
*entry = biter->curr->entry;
|
||||
if(block)
|
||||
*block = biter->curr->context;
|
||||
|
||||
FUNC_LEAVE_NOAPI(SUCCEED)
|
||||
} /* end H5HF_man_iter_curr() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5HF_man_iter_offset
|
||||
*
|
||||
* Purpose: Retrieve offset of iterator in heap
|
||||
*
|
||||
* Return: SUCCEED/FAIL
|
||||
*
|
||||
* Programmer: Quincey Koziol
|
||||
* koziol@ncsa.uiuc.edu
|
||||
* Apr 25 2006
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
H5HF_man_iter_offset(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter, hsize_t *offset)
|
||||
{
|
||||
hsize_t curr_offset; /* For computing offset in heap */
|
||||
|
||||
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_man_iter_offset)
|
||||
|
||||
/*
|
||||
* Check arguments.
|
||||
*/
|
||||
HDassert(biter);
|
||||
HDassert(biter->ready);
|
||||
HDassert(biter->curr->context);
|
||||
HDassert(offset);
|
||||
|
||||
/* Compute the offset in the heap */
|
||||
curr_offset = biter->curr->context->block_off;
|
||||
curr_offset += hdr->man_dtable.row_block_off[biter->curr->row];
|
||||
curr_offset += biter->curr->col * hdr->man_dtable.row_block_size[biter->curr->row];
|
||||
|
||||
/* Assign the return value */
|
||||
*offset = curr_offset;
|
||||
|
||||
FUNC_LEAVE_NOAPI(SUCCEED)
|
||||
} /* end H5HF_man_iter_offset() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5HF_man_iter_ready
|
||||
*
|
||||
* Purpose: Query if iterator is ready to use
|
||||
*
|
||||
* Return: SUCCEED/FAIL
|
||||
*
|
||||
* Programmer: Quincey Koziol
|
||||
* koziol@ncsa.uiuc.edu
|
||||
* Apr 25 2006
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
hbool_t
|
||||
H5HF_man_iter_ready(H5HF_block_iter_t *biter)
|
||||
{
|
||||
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_man_iter_ready)
|
||||
|
||||
/*
|
||||
* Check arguments.
|
||||
*/
|
||||
HDassert(biter);
|
||||
|
||||
FUNC_LEAVE_NOAPI(biter->ready)
|
||||
} /* end H5HF_man_iter_ready() */
|
||||
|
263
src/H5HFpkg.h
263
src/H5HFpkg.h
@ -79,6 +79,7 @@
|
||||
+ (h)->sizeof_size /* Total std. free entries */ \
|
||||
+ (h)->sizeof_size /* Total size of heap */ \
|
||||
+ (h)->sizeof_size /* Size of man. space in heap */ \
|
||||
+ (h)->sizeof_size /* Size of alloacted man. space in heap */ \
|
||||
+ (h)->sizeof_size /* Size of std. space in heap */ \
|
||||
+ (h)->sizeof_size /* Number of objects in heap */ \
|
||||
+ H5HF_DTABLE_INFO_SIZE(h) /* Size of managed obj. doubling-table info */ \
|
||||
@ -99,9 +100,6 @@
|
||||
\
|
||||
/* Fractal heap managed, absolutely mapped direct block specific fields */ \
|
||||
+ (h)->sizeof_addr /* File address of heap owning the block */ \
|
||||
+ (h)->sizeof_addr /* File address of parent block */ \
|
||||
+ 2 /* Entry within parent block */ \
|
||||
+ 2 /* # of rows for parent block */ \
|
||||
+ (h)->heap_off_size /* Offset of the block in the heap */ \
|
||||
+ H5HF_SIZEOF_OFFSET_LEN(s) /* Offset of first descriptor in free list */ \
|
||||
)
|
||||
@ -111,9 +109,6 @@
|
||||
\
|
||||
/* Fractal heap managed, absolutely mapped direct block specific fields */ \
|
||||
+ (h)->sizeof_addr /* File address of heap owning the block */ \
|
||||
+ (h)->sizeof_addr /* File address of parent block */ \
|
||||
+ 2 /* Entry within parent block */ \
|
||||
+ 2 /* # of rows for parent block */ \
|
||||
+ (h)->heap_off_size /* Offset of the block in the heap */ \
|
||||
+ (d)->blk_off_size /* Offset of first descriptor in free list */ \
|
||||
)
|
||||
@ -125,11 +120,7 @@
|
||||
\
|
||||
/* Fractal heap managed, absolutely mapped indirect block specific fields */ \
|
||||
+ (h)->sizeof_addr /* File address of heap owning the block */ \
|
||||
+ (h)->sizeof_addr /* File address of parent block */ \
|
||||
+ 2 /* Entry within parent block */ \
|
||||
+ 2 /* # of rows for parent block */ \
|
||||
+ (h)->heap_off_size /* Offset of the block in the heap */ \
|
||||
+ 4 /* Next block entry to allocate from */ \
|
||||
+ (MIN((i)->nrows, (h)->man_dtable.max_direct_rows) * (h)->man_dtable.cparam.width * ((h)->sizeof_addr + (h)->man_dtable.max_dir_blk_off_size)) /* Size of entries for direct blocks */ \
|
||||
+ ((((i)->nrows > (h)->man_dtable.max_direct_rows) ? ((i)->nrows - (h)->man_dtable.max_direct_rows) : 0) * (h)->man_dtable.cparam.width * ((h)->sizeof_addr + (h)->heap_off_size)) /* Size of entries for indirect blocks */ \
|
||||
)
|
||||
@ -148,7 +139,7 @@ typedef struct H5HF_dtable_t {
|
||||
/* Immutable, pre-set information for table */
|
||||
H5HF_dtable_cparam_t cparam; /* Creation parameters for table */
|
||||
|
||||
/* Derived information (stored, vary during lifetime of table) */
|
||||
/* Derived information (stored, 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 */
|
||||
@ -175,46 +166,34 @@ typedef struct H5HF_dtable_t {
|
||||
/* Fractal heap free list info (forward decl - defined in H5HFflist.c) */
|
||||
typedef struct H5HF_freelist_t H5HF_freelist_t;
|
||||
|
||||
/* Fractal heap free list section info */
|
||||
typedef struct H5HF_free_section_t {
|
||||
haddr_t sect_addr; /* Address of free list section in the file */
|
||||
/* (Not actually used as address, used as unique ID for free list node) */
|
||||
size_t sect_size; /* Size of free space section */
|
||||
/* (section size is "object size", without the metadata overhead, since metadata overhead varies from block to block) */
|
||||
/* (for range sections, this is the largest single section within the range) */
|
||||
enum {H5HF_SECT_SINGLE, H5HF_SECT_RANGE, H5HF_SECT_INDIRECT} type; /* Type of free space section */
|
||||
union {
|
||||
struct {
|
||||
haddr_t dblock_addr; /* Address of direct block for free section */
|
||||
size_t dblock_size; /* Size of direct block */
|
||||
/* (Needed to retrieve direct block) */
|
||||
} single;
|
||||
struct {
|
||||
haddr_t iblock_addr; /* Address of indirect block for free section */
|
||||
unsigned iblock_nrows; /* Number of rows in indirect block */
|
||||
/* (Needed to retrieve indirect block) */
|
||||
unsigned row; /* Row for range of blocks */
|
||||
unsigned col; /* Column for range of blocks */
|
||||
unsigned num_entries; /* Number of entries covered */
|
||||
} range;
|
||||
struct {
|
||||
haddr_t iblock_addr; /* Address of indirect block for free section */
|
||||
unsigned iblock_nrows; /* Number of rows in indirect block */
|
||||
/* (Needed to retrieve indirect block) */
|
||||
unsigned row; /* Row for range of blocks */
|
||||
unsigned col; /* Column for range of blocks */
|
||||
unsigned num_entries; /* Number of entries covered */
|
||||
unsigned indir_row; /* Row for indirect range of blocks */
|
||||
unsigned indir_nrows; /* Number of rows in indirect blocks */
|
||||
} indirect;
|
||||
} u;
|
||||
} H5HF_free_section_t;
|
||||
/* Forward decl indirect block info */
|
||||
typedef struct H5HF_indirect_t H5HF_indirect_t;
|
||||
|
||||
/* Fractal heap block location */
|
||||
typedef struct H5HF_block_loc_t {
|
||||
/* Necessary table fields */
|
||||
unsigned row; /* Row of block in doubling table */
|
||||
unsigned col; /* Column of block in doubling table */
|
||||
|
||||
/* Derived/computed/cached table fields */
|
||||
unsigned entry; /* Entry of block in doubling table */
|
||||
|
||||
/* Infrastructure */
|
||||
H5HF_indirect_t *context; /* Pointer to the indirect block containing the block */
|
||||
struct H5HF_block_loc_t *up; /* Pointer to next level up in the stack of levels */
|
||||
} H5HF_block_loc_t;
|
||||
|
||||
/* Fractal heap block iterator info */
|
||||
typedef struct H5HF_block_iter_t {
|
||||
hbool_t ready; /* Set if iterator is finished initializing */
|
||||
H5HF_block_loc_t *curr; /* Pointer to the current level information for iterator */
|
||||
} H5HF_block_iter_t;
|
||||
|
||||
/* The fractal heap header information */
|
||||
/* (Each fractal heap header has certain information that is shared across all
|
||||
* the instances of blocks in that fractal heap)
|
||||
*/
|
||||
typedef struct H5HF_t {
|
||||
typedef struct H5HF_hdr_t {
|
||||
/* Information for H5AC cache functions, _must_ be first field in structure */
|
||||
H5AC_info_t cache_info;
|
||||
|
||||
@ -225,20 +204,28 @@ typedef struct H5HF_t {
|
||||
/* Statistics for heap */
|
||||
hsize_t total_size; /* Total amount of space used by heap (managed & standalone) */
|
||||
hsize_t man_size; /* Total amount of managed space in heap */
|
||||
hsize_t man_alloc_size; /* Total amount of allocated managed space in heap */
|
||||
hsize_t std_size; /* Total amount of standalone space in heap */
|
||||
hsize_t nobjs; /* Number of objects in heap */
|
||||
|
||||
/* Cached/computed values (not stored in header) */
|
||||
size_t rc; /* Reference count of child blocks */
|
||||
hbool_t dirty; /* Shared info is modified */
|
||||
hbool_t evicted; /* Shared info is evicted from cache */
|
||||
haddr_t heap_addr; /* Address of heap header in the file */
|
||||
H5AC_protect_t mode; /* Access mode for heap */
|
||||
H5F_t *f; /* Pointer to file for heap */
|
||||
size_t sizeof_size; /* Size of file sizes */
|
||||
size_t sizeof_addr; /* Size of file addresses */
|
||||
H5HF_freelist_t *flist; /* Free list for objects in heap */
|
||||
size_t id_len; /* Size of heap IDs */
|
||||
H5HF_freelist_t *flist; /* Free list for objects in heap */
|
||||
unsigned fl_gen; /* Free list "generation" */
|
||||
H5HF_block_iter_t next_block; /* Block iterator for searching for next block with space */
|
||||
hbool_t freelist_sync; /* If the heap's free list in memory is in sync with the free list on disk */
|
||||
/* (ie. all existing blocks have been scanned
|
||||
* for free space (or heap is new and there are
|
||||
* no blocks with unknown free space) and new
|
||||
* free space is added by adding new blocks)
|
||||
*/
|
||||
|
||||
/* Doubling table information */
|
||||
/* (Partially set by user, partially derived/updated internally) */
|
||||
@ -254,7 +241,7 @@ typedef struct H5HF_t {
|
||||
hbool_t debug_objs; /* Is the heap storing objects in 'debug' format */
|
||||
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_t;
|
||||
} H5HF_hdr_t;
|
||||
|
||||
/* Indirect block entry */
|
||||
typedef struct H5HF_indirect_ent_t {
|
||||
@ -264,33 +251,27 @@ typedef struct H5HF_indirect_ent_t {
|
||||
} H5HF_indirect_ent_t;
|
||||
|
||||
/* Fractal heap indirect block */
|
||||
typedef struct H5HF_indirect_t {
|
||||
struct H5HF_indirect_t {
|
||||
/* Information for H5AC cache functions, _must_ be first field in structure */
|
||||
H5AC_info_t cache_info;
|
||||
|
||||
/* Internal heap information */
|
||||
/* Internal heap information (not stored) */
|
||||
size_t rc; /* Reference count of child blocks */
|
||||
hbool_t dirty; /* Info is modified */
|
||||
hbool_t evicted; /* Info is evicted from cache */
|
||||
H5HF_t *shared; /* Shared heap header info */
|
||||
H5HF_hdr_t *hdr; /* Shared heap header info */
|
||||
unsigned fl_gen; /* Free list "generation" */
|
||||
struct H5HF_indirect_t *parent; /* Shared parent indirect block info */
|
||||
unsigned par_entry; /* Entry in parent's table */
|
||||
hsize_t child_free_space; /* Total amount of free space in children */
|
||||
haddr_t addr; /* Address of this indirect block on disk */
|
||||
unsigned nrows; /* Total # of rows in indirect block */
|
||||
unsigned max_rows; /* Max. # of rows in indirect block */
|
||||
size_t size; /* Size of indirect block on disk */
|
||||
unsigned next_col; /* "Column" of next managed block (in doubling table) */
|
||||
unsigned next_row; /* "Row" of next managed block (in doubling table) */
|
||||
hsize_t next_size; /* Size of next managed block */
|
||||
H5HF_indirect_ent_t *ents; /* Pointer to block entry table */
|
||||
|
||||
/* Stored values */
|
||||
haddr_t par_addr; /* Address of parent block on disk */
|
||||
unsigned par_entry; /* Entry in parent's table */
|
||||
unsigned par_nrows; /* Total # of rows in parent indirect block */
|
||||
hsize_t block_off; /* Offset of the block within the heap's address space */
|
||||
size_t next_entry; /* Entry of next managed block */
|
||||
} H5HF_indirect_t;
|
||||
H5HF_indirect_ent_t *ents; /* Pointer to block entry table */
|
||||
};
|
||||
|
||||
/* Direct block free list node */
|
||||
typedef struct H5HF_direct_free_node_t {
|
||||
@ -314,8 +295,10 @@ typedef struct H5HF_direct_t {
|
||||
H5AC_info_t cache_info;
|
||||
|
||||
/* Internal heap information */
|
||||
H5HF_t *shared; /* Shared heap header info */
|
||||
H5HF_hdr_t *hdr; /* Shared heap header info */
|
||||
unsigned fl_gen; /* Free list "generation" */
|
||||
H5HF_indirect_t *parent; /* Shared parent indirect block info */
|
||||
unsigned par_entry; /* Entry in parent's table */
|
||||
size_t size; /* Size of direct block */
|
||||
unsigned blk_off_size; /* Size of offsets in the block */
|
||||
size_t blk_free_space; /* Total amount of free space in block */
|
||||
@ -323,13 +306,16 @@ typedef struct H5HF_direct_t {
|
||||
uint8_t *blk; /* Pointer to buffer containing block data */
|
||||
|
||||
/* Stored values */
|
||||
haddr_t par_addr; /* Address of parent block on disk */
|
||||
unsigned par_entry; /* Entry in parent's table */
|
||||
unsigned par_nrows; /* Total # of rows in parent indirect block */
|
||||
hsize_t block_off; /* Offset of the block within the heap's address space */
|
||||
size_t free_list_head; /* Offset of head of free list in block */
|
||||
} H5HF_direct_t;
|
||||
|
||||
/* Fractal heap */
|
||||
struct H5HF_t {
|
||||
H5HF_hdr_t *hdr; /* Pointer to internal fractal heap header info */
|
||||
unsigned fo_count; /* Open object count for file */
|
||||
};
|
||||
|
||||
/* Fractal heap metadata statistics info */
|
||||
typedef struct H5HF_stat_t {
|
||||
hsize_t total_size; /* Total size of heap allocated (man & std) */
|
||||
@ -339,6 +325,56 @@ typedef struct H5HF_stat_t {
|
||||
hsize_t nobjs; /* Number of objects in heap */
|
||||
} H5HF_stat_t;
|
||||
|
||||
/* Fractal heap free list section info */
|
||||
typedef struct H5HF_free_section_t {
|
||||
haddr_t sect_addr; /* Address of free list section in the file */
|
||||
/* (Not actually used as address, used as unique ID for free list node) */
|
||||
size_t sect_size; /* Size of free space section */
|
||||
/* (section size is "object size", without the metadata overhead, since metadata overhead varies from block to block) */
|
||||
/* (for range sections, this is the largest single section within the range) */
|
||||
enum {
|
||||
H5HF_SECT_SINGLE, /* Section is actual bytes in a direct block */
|
||||
H5HF_SECT_OPAQUE, /* Section is an opaque # of bytes in child of an indirect block */
|
||||
H5HF_SECT_RANGE, /* Section is a range of direct blocks in an indirect block row */
|
||||
H5HF_SECT_INDIRECT} /* Section is a range of _indirect_ blocks in an indirect block row */
|
||||
type; /* Type of free space section */
|
||||
union {
|
||||
struct {
|
||||
H5HF_indirect_t *parent; /* Indirect block parent for free section's direct block */
|
||||
unsigned par_entry; /* Entry of free section's direct block in parent indirect block */
|
||||
/* (Needed to retrieve direct block) */
|
||||
|
||||
haddr_t dblock_addr; /* Address of direct block for free section */
|
||||
size_t dblock_size; /* Size of direct block */
|
||||
/* (Needed to retrieve direct block) */
|
||||
} single;
|
||||
struct {
|
||||
H5HF_indirect_t *iblock; /* Indirect block parent for free section's child block */
|
||||
unsigned entry; /* Entry of free section's child block in parent indirect block */
|
||||
} opaque;
|
||||
struct {
|
||||
H5HF_indirect_t *iblock; /* Indirect block for free section */
|
||||
unsigned row; /* Row for range of blocks */
|
||||
unsigned col; /* Column for range of blocks */
|
||||
unsigned num_entries; /* Number of entries covered */
|
||||
} range;
|
||||
struct {
|
||||
H5HF_indirect_t *iblock; /* Indirect block for free section */
|
||||
unsigned row; /* Row for range of blocks */
|
||||
unsigned col; /* Column for range of blocks */
|
||||
unsigned num_entries; /* Number of entries covered */
|
||||
unsigned indir_row; /* Row for indirect range of blocks */
|
||||
unsigned indir_nrows; /* Number of rows in indirect blocks */
|
||||
} indirect;
|
||||
} u;
|
||||
} H5HF_free_section_t;
|
||||
|
||||
/* Fractal heap "parent info" (for loading a block) */
|
||||
typedef struct H5HF_parent_t {
|
||||
H5HF_hdr_t *hdr; /* Pointer to heap header info */
|
||||
H5HF_indirect_t *iblock; /* Pointer to parent indirect block */
|
||||
unsigned entry; /* Location of block in parent's entry table */
|
||||
} H5HF_parent_t;
|
||||
|
||||
/*****************************/
|
||||
/* Package Private Variables */
|
||||
@ -353,8 +389,8 @@ H5_DLLVAR const H5AC_class_t H5AC_FHEAP_DBLOCK[1];
|
||||
/* H5HF indirect block inherits cache-like properties from H5AC */
|
||||
H5_DLLVAR const H5AC_class_t H5AC_FHEAP_IBLOCK[1];
|
||||
|
||||
/* Declare a free list to manage the H5HF_t struct */
|
||||
H5FL_EXTERN(H5HF_t);
|
||||
/* Declare a free list to manage the H5HF_hdr_t struct */
|
||||
H5FL_EXTERN(H5HF_hdr_t);
|
||||
|
||||
/* Declare a free list to manage the H5HF_direct_t struct */
|
||||
H5FL_EXTERN(H5HF_direct_t);
|
||||
@ -383,57 +419,68 @@ H5FL_EXTERN(H5HF_free_section_t);
|
||||
/******************************/
|
||||
|
||||
/* Routines for managing shared fractal heap header */
|
||||
H5_DLL H5HF_t * H5HF_hdr_alloc(H5F_t *f);
|
||||
H5_DLL herr_t H5HF_hdr_init(H5HF_t *hdr, haddr_t heap_addr, H5HF_create_t *cparam);
|
||||
H5_DLL herr_t H5HF_hdr_finish_init(H5HF_t *hdr);
|
||||
H5_DLL H5HF_hdr_t * H5HF_hdr_alloc(H5F_t *f);
|
||||
H5_DLL herr_t H5HF_hdr_init(H5HF_hdr_t *hdr, haddr_t fh_addr, H5HF_create_t *cparam);
|
||||
H5_DLL herr_t H5HF_hdr_finish_init(H5HF_hdr_t *hdr);
|
||||
|
||||
/* Doubling table routines */
|
||||
H5_DLL herr_t H5HF_dtable_init(H5HF_dtable_t *dtable);
|
||||
H5_DLL herr_t H5HF_dtable_dest(H5HF_dtable_t *dtable);
|
||||
H5_DLL herr_t H5HF_dtable_lookup(const H5HF_dtable_t *dtable, hsize_t off,
|
||||
unsigned *row, unsigned *col);
|
||||
H5_DLL unsigned H5HF_dtable_size_to_row(H5HF_dtable_t *dtable, size_t block_size);
|
||||
|
||||
/* Heap header routines */
|
||||
H5_DLL herr_t H5HF_cache_hdr_dest_real(H5HF_t *hdr);
|
||||
H5_DLL herr_t H5HF_hdr_incr(H5HF_t *hdr);
|
||||
H5_DLL herr_t H5HF_hdr_decr(H5HF_t *hdr);
|
||||
H5_DLL herr_t H5HF_hdr_dirty(hid_t dxpl_id, H5HF_t *hdr);
|
||||
H5_DLL herr_t H5HF_hdr_extend_heap(H5HF_t *hdr, hsize_t new_size, hsize_t extra_free);
|
||||
H5_DLL herr_t H5HF_hdr_incr(H5HF_hdr_t *hdr);
|
||||
H5_DLL herr_t H5HF_hdr_decr(H5HF_hdr_t *hdr);
|
||||
H5_DLL herr_t H5HF_hdr_dirty(H5HF_hdr_t *hdr);
|
||||
H5_DLL herr_t H5HF_hdr_extend_heap(H5HF_hdr_t *hdr, hsize_t new_size, hsize_t extra_free);
|
||||
H5_DLL herr_t H5HF_hdr_inc_alloc(H5HF_hdr_t *hdr, hsize_t new_alloc_size,
|
||||
unsigned nentries);
|
||||
|
||||
/* Indirect block routines */
|
||||
H5_DLL herr_t H5HF_cache_iblock_dest_real(H5HF_indirect_t *iblock);
|
||||
H5_DLL herr_t H5HF_iblock_incr(H5HF_indirect_t *iblock);
|
||||
H5_DLL herr_t H5HF_iblock_decr(H5HF_indirect_t *iblock);
|
||||
H5_DLL herr_t H5HF_iblock_dirty(hid_t dxpl_id, H5HF_indirect_t *iblock);
|
||||
H5_DLL H5HF_indirect_t * H5HF_man_iblock_place_dblock(H5HF_t *fh, hid_t dxpl_id,
|
||||
size_t min_dblock_size, haddr_t *addr_p, size_t *entry_p,
|
||||
size_t *dblock_size);
|
||||
H5_DLL herr_t H5HF_man_iblock_alloc_range(H5HF_t *hdr, hid_t dxpl_id,
|
||||
H5HF_free_section_t **sec_node, size_t obj_size);
|
||||
H5_DLL herr_t H5HF_man_iblock_alloc_indirect(H5HF_t *hdr, hid_t dxpl_id,
|
||||
H5HF_free_section_t **sec_node, size_t obj_size);
|
||||
H5_DLL herr_t H5HF_iblock_dirty(H5HF_indirect_t *iblock);
|
||||
H5_DLL H5HF_indirect_t * H5HF_man_iblock_place_dblock(H5HF_hdr_t *fh, hid_t dxpl_id,
|
||||
size_t min_dblock_size, size_t *entry_p, size_t *dblock_size);
|
||||
H5_DLL herr_t H5HF_man_iblock_alloc_range(H5HF_hdr_t *hdr, hid_t dxpl_id,
|
||||
H5HF_free_section_t **sec_node);
|
||||
H5_DLL herr_t H5HF_man_iblock_alloc_indirect(H5HF_hdr_t *hdr, hid_t dxpl_id,
|
||||
H5HF_free_section_t **sec_node);
|
||||
H5_DLL herr_t H5HF_man_iblock_alloc_opaque(H5HF_hdr_t *hdr, hid_t dxpl_id,
|
||||
H5HF_free_section_t **sec_node);
|
||||
H5_DLL H5HF_indirect_t *H5HF_man_iblock_protect(H5HF_hdr_t *hdr, hid_t dxpl_id,
|
||||
haddr_t iblock_addr, unsigned iblock_nrows,
|
||||
H5HF_indirect_t *par_iblock, unsigned par_entry,
|
||||
H5AC_protect_t rw);
|
||||
|
||||
/* Direct block routines */
|
||||
H5_DLL herr_t H5HF_man_dblock_new(H5HF_t *fh, hid_t dxpl_id, size_t request);
|
||||
H5_DLL herr_t H5HF_man_dblock_create(hid_t dxpl_id, H5HF_t *hdr,
|
||||
H5_DLL herr_t H5HF_man_dblock_new(H5HF_hdr_t *fh, hid_t dxpl_id, size_t request);
|
||||
H5_DLL herr_t H5HF_man_dblock_build_freelist(H5HF_direct_t *dblock, haddr_t dblock_addr);
|
||||
H5_DLL herr_t H5HF_man_dblock_destroy_freelist(H5HF_direct_t *dblock);
|
||||
H5_DLL herr_t H5HF_man_dblock_adj_free(H5HF_direct_t *dblock, ssize_t amt);
|
||||
H5_DLL herr_t H5HF_man_dblock_create(hid_t dxpl_id, H5HF_hdr_t *hdr,
|
||||
H5HF_indirect_t *par_iblock, unsigned par_entry, size_t block_size,
|
||||
hsize_t block_off, haddr_t *addr_p, H5HF_free_section_t **ret_sec_node);
|
||||
H5_DLL herr_t H5HF_man_dblock_adj_free(hid_t dxpl_id, H5HF_direct_t *dblock, ssize_t amt);
|
||||
H5_DLL herr_t H5HF_man_dblock_build_freelist(H5HF_direct_t *dblock, haddr_t dblock_addr);
|
||||
H5_DLL H5HF_direct_t *H5HF_man_dblock_protect(H5HF_hdr_t *hdr, hid_t dxpl_id,
|
||||
haddr_t dblock_addr, size_t dblock_size,
|
||||
H5HF_indirect_t *par_iblock, unsigned par_entry,
|
||||
H5AC_protect_t rw);
|
||||
|
||||
/* Routines for internal operations */
|
||||
H5_DLL herr_t H5HF_free_section_free_cb(void *item, void UNUSED *key,
|
||||
void UNUSED *op_data);
|
||||
H5_DLL herr_t H5HF_man_find(H5HF_t *fh, hid_t dxpl_id, size_t request,
|
||||
H5_DLL herr_t H5HF_man_find(H5HF_hdr_t *fh, hid_t dxpl_id, size_t request,
|
||||
H5HF_free_section_t **sec_node/*out*/);
|
||||
H5_DLL herr_t H5HF_man_insert(H5HF_t *fh, hid_t dxpl_id,
|
||||
H5_DLL herr_t H5HF_man_insert(H5HF_hdr_t *fh, hid_t dxpl_id,
|
||||
H5HF_free_section_t *sec_node, size_t obj_size, const void *obj,
|
||||
void *id);
|
||||
H5_DLL herr_t H5HF_man_read(H5HF_t *fh, hid_t dxpl_id, hsize_t obj_off,
|
||||
H5_DLL herr_t H5HF_man_read(H5HF_hdr_t *fh, hid_t dxpl_id, hsize_t obj_off,
|
||||
size_t obj_len, void *obj);
|
||||
|
||||
/* Metadata cache callbacks */
|
||||
H5_DLL herr_t H5HF_cache_hdr_dest(H5F_t *f, H5HF_t *fh);
|
||||
H5_DLL herr_t H5HF_cache_hdr_dest(H5F_t *f, H5HF_hdr_t *fh);
|
||||
H5_DLL herr_t H5HF_cache_dblock_dest(H5F_t *f, H5HF_direct_t *dblock);
|
||||
H5_DLL herr_t H5HF_cache_iblock_dest(H5F_t *f, H5HF_indirect_t *iblock);
|
||||
|
||||
@ -446,24 +493,40 @@ H5_DLL herr_t H5HF_iblock_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr,
|
||||
FILE *stream, int indent, int fwidth, haddr_t hdr_addr, unsigned nrows);
|
||||
|
||||
/* Statistics routines */
|
||||
H5_DLL herr_t H5HF_stat_info(H5F_t *f, hid_t dxpl_id, haddr_t fh_addr,
|
||||
H5HF_stat_t *stats);
|
||||
H5_DLL herr_t H5HF_stat_info(H5HF_t *fh, H5HF_stat_t *stats);
|
||||
|
||||
/* Free list routines */
|
||||
H5_DLL H5HF_freelist_t * H5HF_flist_create(size_t max_block_size,
|
||||
H5_DLL H5HF_freelist_t * H5HF_flist_create(unsigned max_index_bits,
|
||||
H5SL_operator_t node_free_op);
|
||||
H5_DLL herr_t H5HF_flist_add(H5HF_freelist_t *flist, void *node, size_t *size_key,
|
||||
haddr_t *addr_key);
|
||||
H5_DLL htri_t H5HF_flist_find(H5HF_freelist_t *flist, size_t request,
|
||||
void **node);
|
||||
H5_DLL herr_t H5HF_flist_reset(H5HF_freelist_t *flist);
|
||||
H5_DLL herr_t H5HF_flist_free(H5HF_freelist_t *flist);
|
||||
|
||||
/* Block iteration routines */
|
||||
H5_DLL herr_t H5HF_man_iter_init(H5HF_block_iter_t *biter);
|
||||
H5_DLL herr_t H5HF_man_iter_start_offset(H5HF_hdr_t *hdr, hid_t dxpl_id,
|
||||
H5HF_block_iter_t *biter, hsize_t offset);
|
||||
H5_DLL herr_t H5HF_man_iter_start_entry(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter,
|
||||
H5HF_indirect_t *iblock, unsigned start_entry);
|
||||
H5_DLL herr_t H5HF_man_iter_next(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter,
|
||||
unsigned nentries);
|
||||
H5_DLL herr_t H5HF_man_iter_up(H5HF_block_iter_t *biter);
|
||||
H5_DLL herr_t H5HF_man_iter_down(H5HF_block_iter_t *biter, H5HF_indirect_t *iblock);
|
||||
H5_DLL herr_t H5HF_man_iter_reset(H5HF_block_iter_t *biter);
|
||||
H5_DLL herr_t H5HF_man_iter_update_iblock(H5HF_block_iter_t *biter, H5HF_indirect_t *iblock);
|
||||
H5_DLL herr_t H5HF_man_iter_curr(H5HF_block_iter_t *biter, unsigned *row, unsigned *col,
|
||||
unsigned *entry, H5HF_indirect_t **block);
|
||||
H5_DLL herr_t H5HF_man_iter_offset(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter,
|
||||
hsize_t *offset);
|
||||
H5_DLL hbool_t H5HF_man_iter_ready(H5HF_block_iter_t *biter);
|
||||
|
||||
/* Testing routines */
|
||||
#ifdef H5HF_TESTING
|
||||
H5_DLL herr_t H5HF_get_cparam_test(H5F_t *f, hid_t dxpl_id, haddr_t fh_addr,
|
||||
H5HF_create_t *cparam);
|
||||
H5_DLL hsize_t H5HF_get_dblock_free_test(H5F_t *f, hid_t dxpl_id,
|
||||
haddr_t fh_addr, unsigned row);
|
||||
H5_DLL herr_t H5HF_get_cparam_test(H5HF_t *fh, H5HF_create_t *cparam);
|
||||
H5_DLL hsize_t H5HF_get_dblock_free_test(H5HF_t *fh, unsigned row);
|
||||
#endif /* H5HF_TESTING */
|
||||
|
||||
#endif /* _H5HFpkg_H */
|
||||
|
@ -67,6 +67,9 @@ typedef struct H5HF_create_t {
|
||||
/* (i.e. max. size of object to manage) */
|
||||
} H5HF_create_t;
|
||||
|
||||
/* Fractal heap info (forward decl - defined in H5HFpkg.h) */
|
||||
typedef struct H5HF_t H5HF_t;
|
||||
|
||||
|
||||
/*****************************/
|
||||
/* Library-private Variables */
|
||||
@ -75,13 +78,15 @@ typedef struct H5HF_create_t {
|
||||
/***************************************/
|
||||
/* Library-private Function Prototypes */
|
||||
/***************************************/
|
||||
H5_DLL herr_t H5HF_create(H5F_t *f, hid_t dxpl_id, H5HF_create_t *cparam,
|
||||
haddr_t *addr_p, size_t *id_len_p);
|
||||
H5_DLL herr_t H5HF_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr, size_t size,
|
||||
H5_DLL H5HF_t *H5HF_create(H5F_t *f, hid_t dxpl_id, H5HF_create_t *cparam);
|
||||
H5_DLL H5HF_t *H5HF_open(H5F_t *f, hid_t dxpl_id, haddr_t fh_addr);
|
||||
H5_DLL herr_t H5HF_get_id_len(H5HF_t *fh, size_t *id_len_p);
|
||||
H5_DLL herr_t H5HF_get_heap_addr(H5HF_t *fh, haddr_t *heap_addr);
|
||||
H5_DLL herr_t H5HF_insert(H5HF_t *fh, hid_t dxpl_id, size_t size,
|
||||
const void *obj, void *id/*out*/);
|
||||
H5_DLL herr_t H5HF_read(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *id,
|
||||
H5_DLL herr_t H5HF_read(H5HF_t *fh, hid_t dxpl_id, const void *id,
|
||||
void *obj/*out*/);
|
||||
H5_DLL herr_t H5HF_close(H5HF_t *fh);
|
||||
|
||||
#endif /* _H5HFprivate_H */
|
||||
|
||||
|
||||
|
@ -83,35 +83,22 @@
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
H5HF_stat_info(H5F_t *f, hid_t dxpl_id, haddr_t fh_addr, H5HF_stat_t *stats)
|
||||
H5HF_stat_info(H5HF_t *fh, H5HF_stat_t *stats)
|
||||
{
|
||||
H5HF_t *hdr = NULL; /* Pointer to the fractal heap header */
|
||||
herr_t ret_value = SUCCEED; /* Return value */
|
||||
|
||||
FUNC_ENTER_NOAPI_NOINIT(H5HF_stat_info)
|
||||
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_stat_info)
|
||||
|
||||
/* Check arguments. */
|
||||
HDassert(f);
|
||||
HDassert(H5F_addr_defined(fh_addr));
|
||||
HDassert(fh);
|
||||
HDassert(stats);
|
||||
|
||||
/* Look up the fractal heap header */
|
||||
if(NULL == (hdr = 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")
|
||||
|
||||
/* Report statistics for fractal heap */
|
||||
stats->total_size = hdr->total_size;
|
||||
stats->man_size = hdr->man_size;
|
||||
stats->std_size = hdr->std_size;
|
||||
stats->man_free_space = hdr->total_man_free;
|
||||
stats->nobjs = hdr->nobjs;
|
||||
stats->total_size = fh->hdr->total_size;
|
||||
stats->man_size = fh->hdr->man_size;
|
||||
stats->std_size = fh->hdr->std_size;
|
||||
stats->man_free_space = fh->hdr->total_man_free;
|
||||
stats->nobjs = fh->hdr->nobjs;
|
||||
/* XXX: Add more metadata statistics for the heap */
|
||||
|
||||
done:
|
||||
/* Release fractal heap header node */
|
||||
if(hdr && H5AC_unprotect(f, dxpl_id, H5AC_FHEAP_HDR, fh_addr, hdr, H5AC__NO_FLAGS_SET) < 0)
|
||||
HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap header info")
|
||||
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
FUNC_LEAVE_NOAPI(SUCCEED)
|
||||
} /* H5HF_stat_info() */
|
||||
|
||||
|
@ -84,33 +84,20 @@
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
H5HF_get_cparam_test(H5F_t *f, hid_t dxpl_id, haddr_t fh_addr, H5HF_create_t *cparam)
|
||||
H5HF_get_cparam_test(H5HF_t *fh, H5HF_create_t *cparam)
|
||||
{
|
||||
H5HF_t *hdr = NULL; /* Pointer to the fractal heap header */
|
||||
herr_t ret_value = SUCCEED; /* Return value */
|
||||
|
||||
FUNC_ENTER_NOAPI_NOINIT(H5HF_get_cparam_test)
|
||||
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_get_cparam_test)
|
||||
|
||||
/* Check arguments. */
|
||||
HDassert(f);
|
||||
HDassert(H5F_addr_defined(fh_addr));
|
||||
HDassert(fh);
|
||||
HDassert(cparam);
|
||||
|
||||
/* Look up the fractal heap header */
|
||||
if(NULL == (hdr = 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 fractal heap creation parameters */
|
||||
cparam->addrmap = hdr->addrmap;
|
||||
cparam->standalone_size = hdr->standalone_size;
|
||||
HDmemcpy(&(cparam->managed), &(hdr->man_dtable.cparam), sizeof(H5HF_dtable_cparam_t));
|
||||
cparam->addrmap = fh->hdr->addrmap;
|
||||
cparam->standalone_size = fh->hdr->standalone_size;
|
||||
HDmemcpy(&(cparam->managed), &(fh->hdr->man_dtable.cparam), sizeof(H5HF_dtable_cparam_t));
|
||||
|
||||
done:
|
||||
/* Release fractal heap header node */
|
||||
if(hdr && H5AC_unprotect(f, dxpl_id, H5AC_FHEAP_HDR, fh_addr, hdr, H5AC__NO_FLAGS_SET) < 0)
|
||||
HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap header info")
|
||||
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
FUNC_LEAVE_NOAPI(SUCCEED)
|
||||
} /* H5HF_get_cparam_test() */
|
||||
|
||||
|
||||
@ -130,28 +117,17 @@ done:
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
hsize_t
|
||||
H5HF_get_dblock_free_test(H5F_t *f, hid_t dxpl_id, haddr_t fh_addr, unsigned row)
|
||||
H5HF_get_dblock_free_test(H5HF_t *fh, unsigned row)
|
||||
{
|
||||
H5HF_t *hdr = NULL; /* Pointer to the fractal heap header */
|
||||
hsize_t ret_value; /* Return value */
|
||||
|
||||
FUNC_ENTER_NOAPI_NOINIT(H5HF_get_dblock_free_test)
|
||||
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_get_dblock_free_test)
|
||||
|
||||
/* Check arguments. */
|
||||
HDassert(f);
|
||||
HDassert(H5F_addr_defined(fh_addr));
|
||||
|
||||
/* Look up the fractal heap header */
|
||||
if(NULL == (hdr = H5AC_protect(f, dxpl_id, H5AC_FHEAP_HDR, fh_addr, NULL, NULL, H5AC_READ)))
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, 0, "unable to load fractal heap header")
|
||||
HDassert(fh);
|
||||
|
||||
/* Return direct block free space */
|
||||
ret_value = hdr->man_dtable.row_dblock_free[row];
|
||||
|
||||
done:
|
||||
/* Release fractal heap header node */
|
||||
if(hdr && H5AC_unprotect(f, dxpl_id, H5AC_FHEAP_HDR, fh_addr, hdr, H5AC__NO_FLAGS_SET) < 0)
|
||||
HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, 0, "unable to release fractal heap header info")
|
||||
ret_value = fh->hdr->man_dtable.row_dblock_free[row];
|
||||
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* H5HF_get_dblock_free_test() */
|
||||
|
@ -56,7 +56,7 @@ libhdf5_la_SOURCES= H5.c H5dbg.c H5A.c H5AC.c H5B.c H5Bcache.c \
|
||||
H5Gtest.c \
|
||||
H5Gtraverse.c \
|
||||
H5HF.c H5HFcache.c H5HFdbg.c H5HFdblock.c H5HFdtable.c H5HFflist.c \
|
||||
H5HFhdr.c H5HFiblock.c H5HFint.c H5HFstat.c H5HFtest.c \
|
||||
H5HFhdr.c H5HFiblock.c H5HFint.c H5HFiter.c H5HFstat.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 \
|
||||
|
@ -94,7 +94,7 @@ am_libhdf5_la_OBJECTS = H5.lo H5dbg.lo H5A.lo H5AC.lo H5B.lo \
|
||||
H5Glink.lo H5Gloc.lo H5Gname.lo H5Gnode.lo H5Gobj.lo H5Goh.lo \
|
||||
H5Gstab.lo H5Gtest.lo H5Gtraverse.lo H5HF.lo H5HFcache.lo \
|
||||
H5HFdbg.lo H5HFdblock.lo H5HFdtable.lo H5HFflist.lo H5HFhdr.lo \
|
||||
H5HFiblock.lo H5HFint.lo H5HFstat.lo H5HFtest.lo H5HG.lo \
|
||||
H5HFiblock.lo H5HFint.lo H5HFiter.lo H5HFstat.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 \
|
||||
@ -411,7 +411,7 @@ libhdf5_la_SOURCES = H5.c H5dbg.c H5A.c H5AC.c H5B.c H5Bcache.c \
|
||||
H5Gtest.c \
|
||||
H5Gtraverse.c \
|
||||
H5HF.c H5HFcache.c H5HFdbg.c H5HFdblock.c H5HFdtable.c H5HFflist.c \
|
||||
H5HFhdr.c H5HFiblock.c H5HFint.c H5HFstat.c H5HFtest.c \
|
||||
H5HFhdr.c H5HFiblock.c H5HFint.c H5HFiter.c H5HFstat.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 \
|
||||
@ -626,6 +626,7 @@ distclean-compile:
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5HFhdr.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5HFiblock.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5HFint.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5HFiter.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5HFstat.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@
|
||||
|
4154
test/fheap.c
4154
test/fheap.c
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user