[svn-r14364] Description:

Avoid creating free space manager for fractal heap when just performing
queries.

Tested on:
        FreeBSD/32 6.2 (duty) in debug mode
        FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode
        Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
                                in debug mode
        Linux/64-amd64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN,
                                in production mode
        Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
                                in production mode
        Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
                                w/szip filter, in production mode
        Mac OS X/32 10.4.10 (amazon) in debug mode
        Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
This commit is contained in:
Quincey Koziol 2008-01-03 14:01:17 -05:00
parent 04d73e7a0c
commit 136cefdf91
3 changed files with 76 additions and 58 deletions

View File

@ -394,7 +394,6 @@ H5HF_dblock_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream,
{
H5HF_hdr_t *hdr = NULL; /* Fractal heap header info */
H5HF_direct_t *dblock = NULL; /* Fractal heap direct block info */
H5HF_debug_iter_ud1_t udata; /* User data for callbacks */
size_t blk_prefix_size; /* Size of prefix for block */
size_t amount_free; /* Amount of free space in block */
uint8_t *marker = NULL; /* Track free space for block */
@ -450,36 +449,43 @@ H5HF_dblock_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream,
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
/* Initialize the free space information for the heap */
if(H5HF_space_start(hdr, dxpl_id) < 0)
if(H5HF_space_start(hdr, dxpl_id, FALSE) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize heap free space")
/* Prepare user data for section iteration callback */
udata.stream = stream;
udata.indent = indent;
udata.fwidth = fwidth;
udata.dblock_addr = dblock->block_off;
udata.dblock_size = block_size;
udata.marker = marker;
udata.sect_count = 0;
udata.amount_free = 0;
/* If there is a free space manager for the heap, check for sections that overlap this block */
if(hdr->fspace) {
H5HF_debug_iter_ud1_t udata; /* User data for callbacks */
/* Print header */
HDfprintf(stream, "%*sFree Blocks (offset, size):\n", indent, "");
/* Prepare user data for section iteration callback */
udata.stream = stream;
udata.indent = indent;
udata.fwidth = fwidth;
udata.dblock_addr = dblock->block_off;
udata.dblock_size = block_size;
udata.marker = marker;
udata.sect_count = 0;
udata.amount_free = 0;
/* Iterate over the free space sections, to detect overlaps with this block */
if(H5FS_sect_iterate(f, dxpl_id, hdr->fspace, H5HF_dblock_debug_cb, &udata) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_BADITER, FAIL, "can't iterate over heap's free space")
/* Print header */
HDfprintf(stream, "%*sFree Blocks (offset, size):\n", indent, "");
/* Close the free space information */
if(H5HF_space_close(hdr, dxpl_id) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't release free space info")
/* Iterate over the free space sections, to detect overlaps with this block */
if(H5FS_sect_iterate(f, dxpl_id, hdr->fspace, H5HF_dblock_debug_cb, &udata) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_BADITER, FAIL, "can't iterate over heap's free space")
/* Keep the amount of space free */
amount_free = udata.amount_free;
/* Close the free space information */
if(H5HF_space_close(hdr, dxpl_id) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't release free space info")
/* Check for no free space */
if(amount_free == 0)
HDfprintf(stream, "%*s<none>\n", indent + 3, "");
/* Keep the amount of space free */
amount_free = udata.amount_free;
/* Check for no free space */
if(amount_free == 0)
HDfprintf(stream, "%*s<none>\n", indent + 3, "");
} /* end if */
else
amount_free = 0;
HDfprintf(stream, "%*s%-*s %.2f%%\n", indent, "", fwidth,
"Percent of available space for data used:",
@ -709,7 +715,6 @@ H5HF_sects_debug(H5F_t *f, hid_t dxpl_id, haddr_t fh_addr,
FILE *stream, int indent, int fwidth)
{
H5HF_hdr_t *hdr = NULL; /* Fractal heap header info */
H5HF_debug_iter_ud2_t udata; /* User data for callbacks */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5HF_sects_debug, FAIL)
@ -730,22 +735,27 @@ H5HF_sects_debug(H5F_t *f, hid_t dxpl_id, haddr_t fh_addr,
HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load fractal heap header")
/* Initialize the free space information for the heap */
if(H5HF_space_start(hdr, dxpl_id) < 0)
if(H5HF_space_start(hdr, dxpl_id, FALSE) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize heap free space")
/* Prepare user data for section iteration callback */
udata.fspace = hdr->fspace;
udata.stream = stream;
udata.indent = indent;
udata.fwidth = fwidth;
/* If there is a free space manager for the heap, iterate over them */
if(hdr->fspace) {
H5HF_debug_iter_ud2_t udata; /* User data for callbacks */
/* Iterate over all the free space sections */
if(H5FS_sect_iterate(f, dxpl_id, hdr->fspace, H5HF_sects_debug_cb, &udata) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_BADITER, FAIL, "can't iterate over heap's free space")
/* Prepare user data for section iteration callback */
udata.fspace = hdr->fspace;
udata.stream = stream;
udata.indent = indent;
udata.fwidth = fwidth;
/* Close the free space information */
if(H5HF_space_close(hdr, dxpl_id) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't release free space info")
/* Iterate over all the free space sections */
if(H5FS_sect_iterate(f, dxpl_id, hdr->fspace, H5HF_sects_debug_cb, &udata) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_BADITER, FAIL, "can't iterate over heap's free space")
/* Close the free space information */
if(H5HF_space_close(hdr, dxpl_id) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't release free space info")
} /* end if */
done:
if(hdr && H5AC_unprotect(f, dxpl_id, H5AC_FHEAP_HDR, fh_addr, hdr, H5AC__NO_FLAGS_SET) < 0)

View File

@ -692,7 +692,7 @@ H5_DLL herr_t H5HF_man_iter_offset(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter,
H5_DLL hbool_t H5HF_man_iter_ready(H5HF_block_iter_t *biter);
/* Free space manipulation routines */
H5_DLL herr_t H5HF_space_start(H5HF_hdr_t *hdr, hid_t dxpl_id);
H5_DLL herr_t H5HF_space_start(H5HF_hdr_t *hdr, hid_t dxpl_id, hbool_t may_create);
H5_DLL herr_t H5HF_space_add(H5HF_hdr_t *hdr, hid_t dxpl_id,
H5HF_free_section_t *node, unsigned flags);
H5_DLL htri_t H5HF_space_find(H5HF_hdr_t *hdr, hid_t dxpl_id, hsize_t request,

View File

@ -94,7 +94,7 @@
*-------------------------------------------------------------------------
*/
herr_t
H5HF_space_start(H5HF_hdr_t *hdr, hid_t dxpl_id)
H5HF_space_start(H5HF_hdr_t *hdr, hid_t dxpl_id, hbool_t may_create)
{
const H5FS_section_class_t *classes[] = { /* Free space section classes implemented for fractal heap */
H5HF_FSPACE_SECT_CLS_SINGLE,
@ -118,19 +118,22 @@ H5HF_space_start(H5HF_hdr_t *hdr, hid_t dxpl_id)
HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize free space info")
} /* end if */
else {
H5FS_create_t fs_create; /* Free space creation parameters */
/* Check if we are allowed to create the free space manager */
if(may_create) {
H5FS_create_t fs_create; /* Free space creation parameters */
/* Set the free space creation parameters */
fs_create.client = H5FS_CLIENT_FHEAP_ID;
fs_create.shrink_percent = H5HF_FSPACE_SHRINK;
fs_create.expand_percent = H5HF_FSPACE_EXPAND;
fs_create.max_sect_size = hdr->man_dtable.cparam.max_direct_size;
fs_create.max_sect_addr = hdr->man_dtable.cparam.max_index;
/* Set the free space creation parameters */
fs_create.client = H5FS_CLIENT_FHEAP_ID;
fs_create.shrink_percent = H5HF_FSPACE_SHRINK;
fs_create.expand_percent = H5HF_FSPACE_EXPAND;
fs_create.max_sect_size = hdr->man_dtable.cparam.max_direct_size;
fs_create.max_sect_addr = hdr->man_dtable.cparam.max_index;
/* Create the free space structure for the heap */
if(NULL == (hdr->fspace = H5FS_create(hdr->f, dxpl_id, &hdr->fs_addr,
&fs_create, NELMTS(classes), classes, hdr)))
HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize free space info")
/* Create the free space structure for the heap */
if(NULL == (hdr->fspace = H5FS_create(hdr->f, dxpl_id, &hdr->fs_addr,
&fs_create, NELMTS(classes), classes, hdr)))
HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize free space info")
} /* end if */
} /* end else */
done:
@ -170,7 +173,7 @@ H5HF_space_add(H5HF_hdr_t *hdr, hid_t dxpl_id, H5HF_free_section_t *node,
/* Check if the free space for the heap has been initialized */
if(!hdr->fspace)
if(H5HF_space_start(hdr, dxpl_id) < 0)
if(H5HF_space_start(hdr, dxpl_id, TRUE) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize heap free space")
/* Construct user data */
@ -204,7 +207,7 @@ done:
htri_t
H5HF_space_find(H5HF_hdr_t *hdr, hid_t dxpl_id, hsize_t request, H5HF_free_section_t **node)
{
htri_t node_found; /* Whether an existing free list node was found */
htri_t node_found = FALSE; /* Whether an existing free list node was found */
htri_t ret_value; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5HF_space_find)
@ -218,12 +221,13 @@ H5HF_space_find(H5HF_hdr_t *hdr, hid_t dxpl_id, hsize_t request, H5HF_free_secti
/* Check if the free space for the heap has been initialized */
if(!hdr->fspace)
if(H5HF_space_start(hdr, dxpl_id) < 0)
if(H5HF_space_start(hdr, dxpl_id, FALSE) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize heap free space")
/* Search for free space in the heap */
if((node_found = H5FS_sect_find(hdr->f, dxpl_id, hdr->fspace, request, (H5FS_section_info_t **)node)) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "can't locate free space in fractal heap")
if(hdr->fspace)
if((node_found = H5FS_sect_find(hdr->f, dxpl_id, hdr->fspace, request, (H5FS_section_info_t **)node)) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "can't locate free space in fractal heap")
/* Set return value */
ret_value = node_found;
@ -262,12 +266,16 @@ H5HF_space_size(H5HF_hdr_t *hdr, hid_t dxpl_id, hsize_t *fs_size)
/* Check if the free space for the heap has been initialized */
if(!hdr->fspace)
if(H5HF_space_start(hdr, dxpl_id) < 0)
if(H5HF_space_start(hdr, dxpl_id, FALSE) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize heap free space")
/* Get free space metadata size */
if(H5FS_size(hdr->f, hdr->fspace, fs_size) < 0)
HGOTO_ERROR(H5E_FSPACE, H5E_CANTGET, FAIL, "can't retrieve FS meta storage info")
if(hdr->fspace) {
if(H5FS_size(hdr->f, hdr->fspace, fs_size) < 0)
HGOTO_ERROR(H5E_FSPACE, H5E_CANTGET, FAIL, "can't retrieve FS meta storage info")
} /* end if */
else
*fs_size = 0;
done:
FUNC_LEAVE_NOAPI(ret_value)