summaryrefslogtreecommitdiffstats
path: root/src/H5HFspace.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5HFspace.c')
-rw-r--r--src/H5HFspace.c188
1 files changed, 85 insertions, 103 deletions
diff --git a/src/H5HFspace.c b/src/H5HFspace.c
index 4d4b0f4..7e9f89e 100644
--- a/src/H5HFspace.c
+++ b/src/H5HFspace.c
@@ -26,56 +26,48 @@
/* Module Setup */
/****************/
-#define H5HF_PACKAGE /*suppress error about including H5HFpkg */
+#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 "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
*
@@ -101,12 +93,10 @@
herr_t
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,
- 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_NOAPI_NOINIT
@@ -116,37 +106,37 @@ H5HF_space_start(H5HF_hdr_t *hdr, hid_t dxpl_id, 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, dxpl_id, hdr->fs_addr,
- NELMTS(classes), classes, hdr, H5HF_FSPACE_THRHD_DEF, H5HF_FSPACE_ALIGN_DEF)))
+ if (NULL == (hdr->fspace = H5FS_open(hdr->f, dxpl_id, hdr->fs_addr, NELMTS(classes), classes, hdr,
+ H5HF_FSPACE_THRHD_DEF, 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, dxpl_id, &hdr->fs_addr,
- &fs_create, NELMTS(classes), classes, hdr, H5HF_FSPACE_THRHD_DEF, H5HF_FSPACE_ALIGN_DEF)))
+ if (NULL ==
+ (hdr->fspace = H5FS_create(hdr->f, dxpl_id, &hdr->fs_addr, &fs_create, NELMTS(classes),
+ classes, hdr, H5HF_FSPACE_THRHD_DEF, 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
*
@@ -163,11 +153,10 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5HF_space_add(H5HF_hdr_t *hdr, hid_t dxpl_id, H5HF_free_section_t *node,
- unsigned flags)
+H5HF_space_add(H5HF_hdr_t *hdr, hid_t dxpl_id, 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_NOAPI_NOINIT
@@ -178,23 +167,22 @@ H5HF_space_add(H5HF_hdr_t *hdr, hid_t dxpl_id, 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, dxpl_id, TRUE) < 0)
+ if (!hdr->fspace)
+ 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 */
- udata.hdr = hdr;
+ udata.hdr = hdr;
udata.dxpl_id = dxpl_id;
/* Add to the free space for the heap */
- if(H5FS_sect_add(hdr->f, dxpl_id, hdr->fspace, (H5FS_section_info_t *)node, flags, &udata) < 0)
+ if (H5FS_sect_add(hdr->f, dxpl_id, 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
*
@@ -213,8 +201,8 @@ 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 = FALSE; /* Whether an existing free list node was found */
- htri_t ret_value; /* Return value */
+ htri_t node_found = FALSE; /* Whether an existing free list node was found */
+ htri_t ret_value; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
@@ -226,13 +214,14 @@ H5HF_space_find(H5HF_hdr_t *hdr, hid_t dxpl_id, hsize_t request, H5HF_free_secti
HDassert(node);
/* Check if the free space for the heap has been initialized */
- if(!hdr->fspace)
- if(H5HF_space_start(hdr, dxpl_id, FALSE) < 0)
+ if (!hdr->fspace)
+ 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(hdr->fspace)
- if((node_found = H5FS_sect_find(hdr->f, dxpl_id, hdr->fspace, request, (H5FS_section_info_t **)node)) < 0)
+ 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 */
@@ -242,7 +231,6 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HF_space_find() */
-
/*-------------------------------------------------------------------------
* Function: H5HF_space_revert_root_cb
*
@@ -262,8 +250,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_NOAPI_NOINIT
@@ -273,14 +261,15 @@ H5HF_space_revert_root_cb(H5FS_section_info_t *_sect, void H5_ATTR_UNUSED *_udat
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 */
@@ -288,7 +277,6 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HF_space_revert_root_cb() */
-
/*-------------------------------------------------------------------------
* Function: H5HF_space_revert_root
*
@@ -307,7 +295,7 @@ done:
herr_t
H5HF_space_revert_root(const H5HF_hdr_t *hdr, hid_t dxpl_id)
{
- herr_t ret_value = SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
@@ -317,9 +305,9 @@ H5HF_space_revert_root(const H5HF_hdr_t *hdr, hid_t dxpl_id)
HDassert(hdr);
/* Only need to scan the sections if the free space has been initialized */
- if(hdr->fspace) {
- /* Iterate over all sections, reseting the parent pointers in 'single' sections */
- if(H5FS_sect_iterate(hdr->f, dxpl_id, hdr->fspace, H5HF_space_revert_root_cb, NULL) < 0)
+ if (hdr->fspace) {
+ /* Iterate over all sections, reseting the parent pointers in 'single' sections */
+ if (H5FS_sect_iterate(hdr->f, dxpl_id, 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")
} /* end if */
@@ -327,7 +315,6 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HF_space_revert_root() */
-
/*-------------------------------------------------------------------------
* Function: H5HF_space_create_root_cb
*
@@ -347,9 +334,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_NOAPI_NOINIT
@@ -365,22 +352,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
*
@@ -400,7 +387,7 @@ done:
herr_t
H5HF_space_create_root(const H5HF_hdr_t *hdr, hid_t dxpl_id, H5HF_indirect_t *root_iblock)
{
- herr_t ret_value = SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
@@ -411,9 +398,10 @@ H5HF_space_create_root(const H5HF_hdr_t *hdr, hid_t dxpl_id, H5HF_indirect_t *ro
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, dxpl_id, 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, dxpl_id, 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")
} /* end if */
@@ -421,7 +409,6 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HF_space_create_root() */
-
/*-------------------------------------------------------------------------
* Function: H5HF_space_size
*
@@ -439,7 +426,7 @@ done:
herr_t
H5HF_space_size(H5HF_hdr_t *hdr, hid_t dxpl_id, hsize_t *fs_size)
{
- herr_t ret_value = SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
@@ -450,13 +437,13 @@ H5HF_space_size(H5HF_hdr_t *hdr, hid_t dxpl_id, 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, dxpl_id, FALSE) < 0)
+ if (!hdr->fspace)
+ 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(hdr->fspace) {
- if(H5FS_size(hdr->f, hdr->fspace, fs_size) < 0)
+ 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
@@ -466,7 +453,6 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HF_space_size() */
-
/*-------------------------------------------------------------------------
* Function: H5HF_space_remove
*
@@ -484,7 +470,7 @@ done:
herr_t
H5HF_space_remove(H5HF_hdr_t *hdr, hid_t dxpl_id, H5HF_free_section_t *node)
{
- herr_t ret_value = SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
@@ -496,14 +482,13 @@ H5HF_space_remove(H5HF_hdr_t *hdr, hid_t dxpl_id, H5HF_free_section_t *node)
HDassert(node);
/* Remove from the free space for the heap */
- if(H5FS_sect_remove(hdr->f, dxpl_id, hdr->fspace, (H5FS_section_info_t *)node) < 0)
+ if (H5FS_sect_remove(hdr->f, dxpl_id, 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
*
@@ -522,7 +507,7 @@ done:
herr_t
H5HF_space_close(H5HF_hdr_t *hdr, hid_t dxpl_id)
{
- herr_t ret_value = SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
@@ -532,34 +517,33 @@ H5HF_space_close(H5HF_hdr_t *hdr, hid_t dxpl_id)
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")
#ifdef QAK
-HDfprintf(stderr, "%s: nsects = %Hu\n", FUNC, nsects);
+ HDfprintf(stderr, "%s: nsects = %Hu\n", FUNC, nsects);
#endif /* QAK */
/* Close the free space for the heap */
- if(H5FS_close(hdr->f, dxpl_id, hdr->fspace) < 0)
+ if (H5FS_close(hdr->f, dxpl_id, 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, dxpl_id, hdr->fs_addr) < 0)
+ if (!nsects) {
+ if (H5FS_delete(hdr->f, dxpl_id, 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
*
@@ -577,7 +561,7 @@ done:
herr_t
H5HF_space_delete(H5HF_hdr_t *hdr, hid_t dxpl_id)
{
- herr_t ret_value = SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
@@ -587,14 +571,13 @@ H5HF_space_delete(H5HF_hdr_t *hdr, hid_t dxpl_id)
HDassert(hdr);
/* Delete the free space manager */
- if(H5FS_delete(hdr->f, dxpl_id, hdr->fs_addr) < 0)
+ if (H5FS_delete(hdr->f, dxpl_id, 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_change_sect_class
*
@@ -613,11 +596,11 @@ done:
herr_t
H5HF_space_sect_change_class(H5HF_hdr_t *hdr, hid_t dxpl_id, H5HF_free_section_t *sect, unsigned new_class)
{
- herr_t ret_value = SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
#ifdef QAK
-HDfprintf(stderr, "%s: Called\n", FUNC);
+ HDfprintf(stderr, "%s: Called\n", FUNC);
#endif /* QAK */
/*
@@ -628,10 +611,9 @@ HDfprintf(stderr, "%s: Called\n", FUNC);
HDassert(sect);
/* Notify the free space manager that a section has changed class */
- if(H5FS_sect_change_class(hdr->f, dxpl_id, hdr->fspace, (H5FS_section_info_t *)sect, new_class) < 0)
+ if (H5FS_sect_change_class(hdr->f, dxpl_id, 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() */
-