summaryrefslogtreecommitdiffstats
path: root/src/H5HFspace.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5HFspace.c')
-rw-r--r--src/H5HFspace.c177
1 files changed, 79 insertions, 98 deletions
diff --git a/src/H5HFspace.c b/src/H5HFspace.c
index b518996..651ae70 100644
--- a/src/H5HFspace.c
+++ b/src/H5HFspace.c
@@ -26,57 +26,48 @@
/* Module Setup */
/****************/
-#include "H5HFmodule.h" /* This source code file is part of the H5HF module */
-
+#include "H5HFmodule.h" /* This source code file is part of the H5HF module */
/***********/
/* Headers */
/***********/
-#include "H5private.h" /* Generic Functions */
-#include "H5Eprivate.h" /* Error handling */
-#include "H5HFpkg.h" /* Fractal heaps */
-
+#include "H5private.h" /* Generic Functions */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5HFpkg.h" /* Fractal heaps */
/****************/
/* Local Macros */
/****************/
-#define H5HF_FSPACE_SHRINK 80 /* Percent of "normal" size to shrink serialized free space size */
-#define H5HF_FSPACE_EXPAND 120 /* Percent of "normal" size to expand serialized free space size */
-#define H5HF_FSPACE_THRHD_DEF 1 /* Default: no alignment threshold */
-#define H5HF_FSPACE_ALIGN_DEF 1 /* Default: no alignment */
+#define H5HF_FSPACE_SHRINK 80 /* Percent of "normal" size to shrink serialized free space size */
+#define H5HF_FSPACE_EXPAND 120 /* Percent of "normal" size to expand serialized free space size */
+#define H5HF_FSPACE_THRHD_DEF 1 /* Default: no alignment threshold */
+#define H5HF_FSPACE_ALIGN_DEF 1 /* Default: no alignment */
/******************/
/* Local Typedefs */
/******************/
-
/********************/
/* Package Typedefs */
/********************/
-
/********************/
/* Local Prototypes */
/********************/
-
/*********************/
/* Package Variables */
/*********************/
-
/*****************************/
/* Library Private Variables */
/*****************************/
-
/*******************/
/* Local Variables */
/*******************/
-
-
/*-------------------------------------------------------------------------
* Function: H5HF__space_start
*
@@ -96,12 +87,10 @@
herr_t
H5HF__space_start(H5HF_hdr_t *hdr, hbool_t may_create)
{
- const H5FS_section_class_t *classes[] = { /* Free space section classes implemented for fractal heap */
- H5HF_FSPACE_SECT_CLS_SINGLE,
- H5HF_FSPACE_SECT_CLS_FIRST_ROW,
- H5HF_FSPACE_SECT_CLS_NORMAL_ROW,
- H5HF_FSPACE_SECT_CLS_INDIRECT};
- herr_t ret_value = SUCCEED; /* Return value */
+ const H5FS_section_class_t *classes[] = {/* Free space section classes implemented for fractal heap */
+ H5HF_FSPACE_SECT_CLS_SINGLE, H5HF_FSPACE_SECT_CLS_FIRST_ROW,
+ H5HF_FSPACE_SECT_CLS_NORMAL_ROW, H5HF_FSPACE_SECT_CLS_INDIRECT};
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
@@ -111,37 +100,37 @@ H5HF__space_start(H5HF_hdr_t *hdr, hbool_t may_create)
HDassert(hdr);
/* Check for creating free space info for the heap */
- if(H5F_addr_defined(hdr->fs_addr)) {
+ if (H5F_addr_defined(hdr->fs_addr)) {
/* Open an existing free space structure for the heap */
- if(NULL == (hdr->fspace = H5FS_open(hdr->f, hdr->fs_addr,
- NELMTS(classes), classes, hdr, (hsize_t)H5HF_FSPACE_THRHD_DEF, (hsize_t)H5HF_FSPACE_ALIGN_DEF)))
+ if (NULL == (hdr->fspace = H5FS_open(hdr->f, hdr->fs_addr, NELMTS(classes), classes, hdr,
+ (hsize_t)H5HF_FSPACE_THRHD_DEF, (hsize_t)H5HF_FSPACE_ALIGN_DEF)))
HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize free space info")
} /* end if */
else {
/* Check if we are allowed to create the free space manager */
- if(may_create) {
- H5FS_create_t fs_create; /* Free space creation parameters */
+ 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.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;
+ 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, &hdr->fs_addr,
- &fs_create, NELMTS(classes), classes, hdr, (hsize_t)H5HF_FSPACE_THRHD_DEF, (hsize_t)H5HF_FSPACE_ALIGN_DEF)))
+ if (NULL ==
+ (hdr->fspace = H5FS_create(hdr->f, &hdr->fs_addr, &fs_create, NELMTS(classes), classes, hdr,
+ (hsize_t)H5HF_FSPACE_THRHD_DEF, (hsize_t)H5HF_FSPACE_ALIGN_DEF)))
HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize free space info")
HDassert(H5F_addr_defined(hdr->fs_addr));
} /* end if */
- } /* end else */
+ } /* end else */
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HF__space_start() */
-
/*-------------------------------------------------------------------------
* Function: H5HF__space_add
*
@@ -159,8 +148,8 @@ done:
herr_t
H5HF__space_add(H5HF_hdr_t *hdr, H5HF_free_section_t *node, unsigned flags)
{
- H5HF_sect_add_ud_t udata; /* User data for free space manager 'add' */
- herr_t ret_value = SUCCEED; /* Return value */
+ H5HF_sect_add_ud_t udata; /* User data for free space manager 'add' */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
@@ -171,22 +160,21 @@ H5HF__space_add(H5HF_hdr_t *hdr, H5HF_free_section_t *node, unsigned flags)
HDassert(node);
/* Check if the free space for the heap has been initialized */
- if(!hdr->fspace)
- if(H5HF__space_start(hdr, TRUE) < 0)
+ if (!hdr->fspace)
+ if (H5HF__space_start(hdr, TRUE) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize heap free space")
/* Construct user data */
udata.hdr = hdr;
/* Add to the free space for the heap */
- if(H5FS_sect_add(hdr->f, hdr->fspace, (H5FS_section_info_t *)node, flags, &udata) < 0)
+ if (H5FS_sect_add(hdr->f, hdr->fspace, (H5FS_section_info_t *)node, flags, &udata) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTINSERT, FAIL, "can't add section to heap free space")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HF__space_add() */
-
/*-------------------------------------------------------------------------
* Function: H5HF__space_find
*
@@ -203,8 +191,8 @@ done:
htri_t
H5HF__space_find(H5HF_hdr_t *hdr, hsize_t request, H5HF_free_section_t **node)
{
- htri_t node_found = FALSE; /* Whether an existing free list node was found */
- htri_t ret_value = FAIL; /* Return value */
+ htri_t node_found = FALSE; /* Whether an existing free list node was found */
+ htri_t ret_value = FAIL; /* Return value */
FUNC_ENTER_PACKAGE
@@ -216,13 +204,13 @@ H5HF__space_find(H5HF_hdr_t *hdr, hsize_t request, H5HF_free_section_t **node)
HDassert(node);
/* Check if the free space for the heap has been initialized */
- if(!hdr->fspace)
- if(H5HF__space_start(hdr, FALSE) < 0)
+ if (!hdr->fspace)
+ if (H5HF__space_start(hdr, FALSE) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize heap free space")
/* Search for free space in the heap */
- if(hdr->fspace)
- if((node_found = H5FS_sect_find(hdr->f, hdr->fspace, request, (H5FS_section_info_t **)node)) < 0)
+ if (hdr->fspace)
+ if ((node_found = H5FS_sect_find(hdr->f, 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 */
@@ -232,7 +220,6 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HF__space_find() */
-
/*-------------------------------------------------------------------------
* Function: H5HF__space_revert_root_cb
*
@@ -251,8 +238,8 @@ done:
static herr_t
H5HF__space_revert_root_cb(H5FS_section_info_t *_sect, void H5_ATTR_UNUSED *_udata)
{
- H5HF_free_section_t *sect = (H5HF_free_section_t *)_sect; /* Section to dump info */
- herr_t ret_value = SUCCEED; /* Return value */
+ H5HF_free_section_t *sect = (H5HF_free_section_t *)_sect; /* Section to dump info */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
@@ -262,14 +249,15 @@ H5HF__space_revert_root_cb(H5FS_section_info_t *_sect, void H5_ATTR_UNUSED *_uda
HDassert(sect);
/* Only modify "live" single blocks... */
- if(sect->sect_info.type == H5HF_FSPACE_SECT_SINGLE && sect->sect_info.state == H5FS_SECT_LIVE) {
+ if (sect->sect_info.type == H5HF_FSPACE_SECT_SINGLE && sect->sect_info.state == H5FS_SECT_LIVE) {
/* Release hold on previous indirect block (we must have one) */
HDassert(sect->u.single.parent);
- if(H5HF__iblock_decr(sect->u.single.parent) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on section's indirect block")
+ if (H5HF__iblock_decr(sect->u.single.parent) < 0)
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL,
+ "can't decrement reference count on section's indirect block")
/* Reset parent information */
- sect->u.single.parent = NULL;
+ sect->u.single.parent = NULL;
sect->u.single.par_entry = 0;
} /* end if */
@@ -277,7 +265,6 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HF__space_revert_root_cb() */
-
/*-------------------------------------------------------------------------
* Function: H5HF__space_revert_root
*
@@ -295,7 +282,7 @@ done:
herr_t
H5HF__space_revert_root(const H5HF_hdr_t *hdr)
{
- herr_t ret_value = SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
@@ -305,16 +292,15 @@ H5HF__space_revert_root(const H5HF_hdr_t *hdr)
HDassert(hdr);
/* Only need to scan the sections if the free space has been initialized */
- if(hdr->fspace)
+ if (hdr->fspace)
/* Iterate over all sections, resetting the parent pointers in 'single' sections */
- if(H5FS_sect_iterate(hdr->f, hdr->fspace, H5HF__space_revert_root_cb, NULL) < 0)
+ if (H5FS_sect_iterate(hdr->f, hdr->fspace, H5HF__space_revert_root_cb, NULL) < 0)
HGOTO_ERROR(H5E_FSPACE, H5E_BADITER, FAIL, "can't iterate over sections to reset parent pointers")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HF__space_revert_root() */
-
/*-------------------------------------------------------------------------
* Function: H5HF__space_create_root_cb
*
@@ -333,9 +319,9 @@ done:
static herr_t
H5HF__space_create_root_cb(H5FS_section_info_t *_sect, void *_udata)
{
- H5HF_free_section_t *sect = (H5HF_free_section_t *)_sect; /* Section to dump info */
- H5HF_indirect_t *root_iblock = (H5HF_indirect_t *)_udata; /* User data for callback */
- herr_t ret_value = SUCCEED; /* Return value */
+ H5HF_free_section_t *sect = (H5HF_free_section_t *)_sect; /* Section to dump info */
+ H5HF_indirect_t * root_iblock = (H5HF_indirect_t *)_udata; /* User data for callback */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
@@ -351,22 +337,22 @@ H5HF__space_create_root_cb(H5FS_section_info_t *_sect, void *_udata)
HDassert(sect->sect_info.type == H5HF_FSPACE_SECT_SINGLE);
/* Increment ref. count on new root indirect block */
- if(H5HF__iblock_incr(root_iblock) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, FAIL, "can't increment reference count on section's indirect block")
+ if (H5HF__iblock_incr(root_iblock) < 0)
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, FAIL,
+ "can't increment reference count on section's indirect block")
/* Set parent info ("live" section must _NOT_ have a parent right now) */
- if(sect->sect_info.state == H5FS_SECT_SERIALIZED)
- sect->sect_info.state = H5FS_SECT_LIVE; /* Mark "live" now */
+ if (sect->sect_info.state == H5FS_SECT_SERIALIZED)
+ sect->sect_info.state = H5FS_SECT_LIVE; /* Mark "live" now */
else
- HDassert(!sect->u.single.parent);
- sect->u.single.parent = root_iblock;
+ HDassert(!sect->u.single.parent);
+ sect->u.single.parent = root_iblock;
sect->u.single.par_entry = 0;
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HF__space_create_root_cb() */
-
/*-------------------------------------------------------------------------
* Function: H5HF__space_create_root
*
@@ -385,7 +371,7 @@ done:
herr_t
H5HF__space_create_root(const H5HF_hdr_t *hdr, H5HF_indirect_t *root_iblock)
{
- herr_t ret_value = SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
@@ -396,16 +382,16 @@ H5HF__space_create_root(const H5HF_hdr_t *hdr, H5HF_indirect_t *root_iblock)
HDassert(root_iblock);
/* Only need to scan the sections if the free space has been initialized */
- if(hdr->fspace)
- /* Iterate over all sections, seting the parent pointers in 'single' sections to the new indirect block */
- if(H5FS_sect_iterate(hdr->f, hdr->fspace, H5HF__space_create_root_cb, root_iblock) < 0)
+ if (hdr->fspace)
+ /* Iterate over all sections, seting the parent pointers in 'single' sections to the new indirect
+ * block */
+ if (H5FS_sect_iterate(hdr->f, hdr->fspace, H5HF__space_create_root_cb, root_iblock) < 0)
HGOTO_ERROR(H5E_FSPACE, H5E_BADITER, FAIL, "can't iterate over sections to set parent pointers")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HF__space_create_root() */
-
/*-------------------------------------------------------------------------
* Function: H5HF__space_size
*
@@ -422,7 +408,7 @@ done:
herr_t
H5HF__space_size(H5HF_hdr_t *hdr, hsize_t *fs_size)
{
- herr_t ret_value = SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
@@ -433,13 +419,13 @@ H5HF__space_size(H5HF_hdr_t *hdr, hsize_t *fs_size)
HDassert(fs_size);
/* Check if the free space for the heap has been initialized */
- if(!hdr->fspace)
- if(H5HF__space_start(hdr, FALSE) < 0)
+ if (!hdr->fspace)
+ if (H5HF__space_start(hdr, FALSE) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize heap free space")
/* Get free space metadata size */
- if(hdr->fspace) {
- if(H5FS_size(hdr->fspace, fs_size) < 0)
+ if (hdr->fspace) {
+ if (H5FS_size(hdr->fspace, fs_size) < 0)
HGOTO_ERROR(H5E_FSPACE, H5E_CANTGET, FAIL, "can't retrieve FS meta storage info")
} /* end if */
else
@@ -449,7 +435,6 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HF__space_size() */
-
/*-------------------------------------------------------------------------
* Function: H5HF__space_remove
*
@@ -466,7 +451,7 @@ done:
herr_t
H5HF__space_remove(H5HF_hdr_t *hdr, H5HF_free_section_t *node)
{
- herr_t ret_value = SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
@@ -478,14 +463,13 @@ H5HF__space_remove(H5HF_hdr_t *hdr, H5HF_free_section_t *node)
HDassert(node);
/* Remove from the free space for the heap */
- if(H5FS_sect_remove(hdr->f, hdr->fspace, (H5FS_section_info_t *)node) < 0)
+ if (H5FS_sect_remove(hdr->f, hdr->fspace, (H5FS_section_info_t *)node) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTREMOVE, FAIL, "can't remove section from heap free space")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HF__space_remove() */
-
/*-------------------------------------------------------------------------
* Function: H5HF__space_close
*
@@ -503,7 +487,7 @@ done:
herr_t
H5HF__space_close(H5HF_hdr_t *hdr)
{
- herr_t ret_value = SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
@@ -513,31 +497,30 @@ H5HF__space_close(H5HF_hdr_t *hdr)
HDassert(hdr);
/* Check if the free space was ever opened */
- if(hdr->fspace) {
- hsize_t nsects; /* Number of sections for this heap */
+ if (hdr->fspace) {
+ hsize_t nsects; /* Number of sections for this heap */
/* Retrieve the number of sections for this heap */
- if(H5FS_sect_stats(hdr->fspace, NULL, &nsects) < 0)
+ if (H5FS_sect_stats(hdr->fspace, NULL, &nsects) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTCOUNT, FAIL, "can't query free space section count")
/* Close the free space for the heap */
- if(H5FS_close(hdr->f, hdr->fspace) < 0)
+ if (H5FS_close(hdr->f, hdr->fspace) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't release free space info")
hdr->fspace = NULL;
/* Check if we can delete the free space manager for this heap */
- if(!nsects) {
- if(H5FS_delete(hdr->f, hdr->fs_addr) < 0)
+ if (!nsects) {
+ if (H5FS_delete(hdr->f, hdr->fs_addr) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTDELETE, FAIL, "can't delete free space info")
hdr->fs_addr = HADDR_UNDEF;
} /* end if */
- } /* end if */
+ } /* end if */
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HF__space_close() */
-
/*-------------------------------------------------------------------------
* Function: H5HF__space_delete
*
@@ -554,7 +537,7 @@ done:
herr_t
H5HF__space_delete(H5HF_hdr_t *hdr)
{
- herr_t ret_value = SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
@@ -564,14 +547,13 @@ H5HF__space_delete(H5HF_hdr_t *hdr)
HDassert(hdr);
/* Delete the free space manager */
- if(H5FS_delete(hdr->f, hdr->fs_addr) < 0)
+ if (H5FS_delete(hdr->f, hdr->fs_addr) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "can't delete to free space manager")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HF__space_delete() */
-
/*-------------------------------------------------------------------------
* Function: H5HF__space_sect_change_class
*
@@ -589,7 +571,7 @@ done:
herr_t
H5HF__space_sect_change_class(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, uint16_t new_class)
{
- herr_t ret_value = SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
@@ -601,10 +583,9 @@ H5HF__space_sect_change_class(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, uint16
HDassert(sect);
/* Notify the free space manager that a section has changed class */
- if(H5FS_sect_change_class(hdr->f, hdr->fspace, (H5FS_section_info_t *)sect, new_class) < 0)
+ if (H5FS_sect_change_class(hdr->f, hdr->fspace, (H5FS_section_info_t *)sect, new_class) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTMODIFY, FAIL, "can't modify class of free space section")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HF__space_sect_change_class() */
-