summaryrefslogtreecommitdiffstats
path: root/src/H5FSsection.c
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2020-10-01 16:47:45 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2020-10-01 16:47:45 (GMT)
commit1ba1f2f3222cbe8df0bf601929a4bffd478d7e02 (patch)
treeae51dfc33cf40432dad25a5088767115a98f195e /src/H5FSsection.c
parent8eef7d295cc3dd134aef0a826f1de4287629996d (diff)
downloadhdf5-1ba1f2f3222cbe8df0bf601929a4bffd478d7e02.zip
hdf5-1ba1f2f3222cbe8df0bf601929a4bffd478d7e02.tar.gz
hdf5-1ba1f2f3222cbe8df0bf601929a4bffd478d7e02.tar.bz2
Source formatted
Diffstat (limited to 'src/H5FSsection.c')
-rw-r--r--src/H5FSsection.c1155
1 files changed, 585 insertions, 570 deletions
diff --git a/src/H5FSsection.c b/src/H5FSsection.c
index 432a36d..59be78c 100644
--- a/src/H5FSsection.c
+++ b/src/H5FSsection.c
@@ -23,66 +23,57 @@
/* Module Setup */
/****************/
-#define H5FS_PACKAGE /*suppress error about including H5FSpkg */
-
+#define H5FS_PACKAGE /*suppress error about including H5FSpkg */
/***********/
/* Headers */
/***********/
-#include "H5private.h" /* Generic Functions */
-#include "H5Eprivate.h" /* Error handling */
-#include "H5FSpkg.h" /* File free space */
-#include "H5MFprivate.h" /* File memory management */
-#include "H5VMprivate.h" /* Vectors and arrays */
-
+#include "H5private.h" /* Generic Functions */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5FSpkg.h" /* File free space */
+#include "H5MFprivate.h" /* File memory management */
+#include "H5VMprivate.h" /* Vectors and arrays */
/****************/
/* Local Macros */
/****************/
-
/******************/
/* Local Typedefs */
/******************/
/* User data for skip list iterator callback for iterating over section size nodes */
typedef struct {
- H5FS_t *fspace; /* Free space manager info */
- H5FS_operator_t op; /* Operator for the iteration */
- void *op_data; /* Information to pass to the operator */
+ H5FS_t * fspace; /* Free space manager info */
+ H5FS_operator_t op; /* Operator for the iteration */
+ void * op_data; /* Information to pass to the operator */
} H5FS_iter_ud_t;
-
/********************/
/* Package Typedefs */
/********************/
-
/********************/
/* Local Prototypes */
/********************/
-static herr_t H5FS_sect_increase(H5FS_t *fspace, const H5FS_section_class_t *cls,
- unsigned flags);
+static herr_t H5FS_sect_increase(H5FS_t *fspace, const H5FS_section_class_t *cls, unsigned flags);
static herr_t H5FS_sect_decrease(H5FS_t *fspace, const H5FS_section_class_t *cls);
static herr_t H5FS_size_node_decr(H5FS_sinfo_t *sinfo, unsigned bin, H5FS_node_t *fspace_node,
- const H5FS_section_class_t *cls);
+ const H5FS_section_class_t *cls);
static herr_t H5FS_sect_unlink_size(H5FS_sinfo_t *sinfo, const H5FS_section_class_t *cls,
- H5FS_section_info_t *sect);
-static herr_t H5FS_sect_unlink_rest(H5FS_t *fspace,
- const H5FS_section_class_t *cls, H5FS_section_info_t *sect);
+ H5FS_section_info_t *sect);
+static herr_t H5FS_sect_unlink_rest(H5FS_t *fspace, const H5FS_section_class_t *cls,
+ H5FS_section_info_t *sect);
static herr_t H5FS_sect_remove_real(H5FS_t *fspace, H5FS_section_info_t *sect);
static herr_t H5FS_sect_link_size(H5FS_sinfo_t *sinfo, const H5FS_section_class_t *cls,
- H5FS_section_info_t *sect);
-static herr_t H5FS_sect_link_rest(H5FS_t *fspace, const H5FS_section_class_t *cls,
- H5FS_section_info_t *sect, unsigned flags);
-static herr_t H5FS_sect_link(H5FS_t *fspace, H5FS_section_info_t *sect,
- unsigned flags);
-static herr_t H5FS_sect_merge(H5FS_t *fspace, H5FS_section_info_t **sect,
- void *op_data);
+ H5FS_section_info_t *sect);
+static herr_t H5FS_sect_link_rest(H5FS_t *fspace, const H5FS_section_class_t *cls, H5FS_section_info_t *sect,
+ unsigned flags);
+static herr_t H5FS_sect_link(H5FS_t *fspace, H5FS_section_info_t *sect, unsigned flags);
+static herr_t H5FS_sect_merge(H5FS_t *fspace, H5FS_section_info_t **sect, void *op_data);
static htri_t H5FS_sect_find_node(H5FS_t *fspace, hsize_t request, H5FS_section_info_t **node);
static herr_t H5FS_sect_serialize_size(H5FS_t *fspace);
-
/*********************/
/* Package Variables */
/*********************/
@@ -96,18 +87,14 @@ H5FL_SEQ_DEFINE(H5FS_bin_t);
/* Declare a free list to manage the H5FS_sinfo_t struct */
H5FL_DEFINE(H5FS_sinfo_t);
-
/*****************************/
/* Library Private Variables */
/*****************************/
-
/*******************/
/* Local Variables */
/*******************/
-
-
/*-------------------------------------------------------------------------
* Function: H5FS_sinfo_new
*
@@ -133,31 +120,33 @@ H5FS_sinfo_new(H5F_t *f, H5FS_t *fspace)
HDassert(f);
HDassert(fspace);
#ifdef H5FS_SINFO_DEBUG
-HDfprintf(stderr, "%s: fspace->addr = %a\n", FUNC, fspace->addr);
+ HDfprintf(stderr, "%s: fspace->addr = %a\n", FUNC, fspace->addr);
#endif /* H5FS_SINFO_DEBUG */
/* Allocate the free space header */
- if(NULL == (sinfo = H5FL_CALLOC(H5FS_sinfo_t)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
+ if (NULL == (sinfo = H5FL_CALLOC(H5FS_sinfo_t)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
/* Set non-zero values */
- sinfo->nbins = H5VM_log2_gen(fspace->max_sect_size);
+ sinfo->nbins = H5VM_log2_gen(fspace->max_sect_size);
sinfo->sect_prefix_size = (size_t)H5FS_SINFO_PREFIX_SIZE(f);
- sinfo->sect_off_size = (fspace->max_sect_addr + 7) / 8;
- sinfo->sect_len_size = H5VM_limit_enc_size((uint64_t)fspace->max_sect_size);
+ sinfo->sect_off_size = (fspace->max_sect_addr + 7) / 8;
+ sinfo->sect_len_size = H5VM_limit_enc_size((uint64_t)fspace->max_sect_size);
#ifdef H5FS_SINFO_DEBUG
-HDfprintf(stderr, "%s: fspace->max_sect_size = %Hu\n", FUNC, fspace->max_sect_size);
-HDfprintf(stderr, "%s: fspace->max_sect_addr = %u\n", FUNC, fspace->max_sect_addr);
-HDfprintf(stderr, "%s: sinfo->nbins = %u\n", FUNC, sinfo->nbins);
-HDfprintf(stderr, "%s: sinfo->sect_off_size = %u, sinfo->sect_len_size = %u\n", FUNC, sinfo->sect_off_size, sinfo->sect_len_size);
+ HDfprintf(stderr, "%s: fspace->max_sect_size = %Hu\n", FUNC, fspace->max_sect_size);
+ HDfprintf(stderr, "%s: fspace->max_sect_addr = %u\n", FUNC, fspace->max_sect_addr);
+ HDfprintf(stderr, "%s: sinfo->nbins = %u\n", FUNC, sinfo->nbins);
+ HDfprintf(stderr, "%s: sinfo->sect_off_size = %u, sinfo->sect_len_size = %u\n", FUNC,
+ sinfo->sect_off_size, sinfo->sect_len_size);
#endif /* H5FS_SINFO_DEBUG */
/* Allocate space for the section size bins */
- if(NULL == (sinfo->bins = H5FL_SEQ_CALLOC(H5FS_bin_t, (size_t)sinfo->nbins)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for free space section bin array")
+ if (NULL == (sinfo->bins = H5FL_SEQ_CALLOC(H5FS_bin_t, (size_t)sinfo->nbins)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed for free space section bin array")
/* Increment the reference count on the free space manager header */
- if(H5FS_incr(fspace) < 0)
+ if (H5FS_incr(fspace) < 0)
HGOTO_ERROR(H5E_FSPACE, H5E_CANTINC, NULL, "unable to increment ref. count on free space header")
sinfo->fspace = fspace;
@@ -170,9 +159,9 @@ HDfprintf(stderr, "%s: sinfo->sect_off_size = %u, sinfo->sect_len_size = %u\n",
ret_value = sinfo;
done:
- if(ret_value == NULL && sinfo) {
+ if (ret_value == NULL && sinfo) {
/* Release bins for skip lists */
- if(sinfo->bins)
+ if (sinfo->bins)
sinfo->bins = H5FL_SEQ_FREE(H5FS_bin_t, sinfo->bins);
/* Release free space section info */
@@ -182,7 +171,6 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5FS_sinfo_new() */
-
/*-------------------------------------------------------------------------
* Function: H5FS_sinfo_lock
*
@@ -204,13 +192,15 @@ done:
static herr_t
H5FS_sinfo_lock(H5F_t *f, hid_t dxpl_id, H5FS_t *fspace, H5AC_protect_t accmode)
{
- H5FS_sinfo_cache_ud_t cache_udata; /* User-data for cache callback */
- herr_t ret_value = SUCCEED; /* Return value */
+ H5FS_sinfo_cache_ud_t cache_udata; /* User-data for cache callback */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
#ifdef H5FS_SINFO_DEBUG
-HDfprintf(stderr, "%s: Called, fspace->addr = %a, fspace->sinfo = %p, fspace->sect_addr = %a\n", FUNC, fspace->addr, fspace->sinfo, fspace->sect_addr);
-HDfprintf(stderr, "%s: fspace->alloc_sect_size = %Hu, fspace->sect_size = %Hu\n", FUNC, fspace->alloc_sect_size, fspace->sect_size);
+ HDfprintf(stderr, "%s: Called, fspace->addr = %a, fspace->sinfo = %p, fspace->sect_addr = %a\n", FUNC,
+ fspace->addr, fspace->sinfo, fspace->sect_addr);
+ HDfprintf(stderr, "%s: fspace->alloc_sect_size = %Hu, fspace->sect_size = %Hu\n", FUNC,
+ fspace->alloc_sect_size, fspace->sect_size);
#endif /* H5FS_SINFO_DEBUG */
/* Check arguments. */
@@ -220,51 +210,56 @@ HDfprintf(stderr, "%s: fspace->alloc_sect_size = %Hu, fspace->sect_size = %Hu\n"
/* If the free space header doesn't already "own" the section info, load
* section info or create it
*/
- if(fspace->sinfo) {
+ if (fspace->sinfo) {
/* Check if the section info was protected & we want a different access mode */
- if(fspace->sinfo_protected && accmode != fspace->sinfo_accmode) {
+ if (fspace->sinfo_protected && accmode != fspace->sinfo_accmode) {
/* Check if we need to switch from read-only access to read-write */
- if(H5AC_WRITE == accmode) {
+ if (H5AC_WRITE == accmode) {
/* Unprotect the read-only section info */
- if(H5AC_unprotect(f, dxpl_id, H5AC_FSPACE_SINFO, fspace->sect_addr, fspace->sinfo, H5AC__NO_FLAGS_SET) < 0)
- HGOTO_ERROR(H5E_FSPACE, H5E_CANTUNPROTECT, FAIL, "unable to release free space section info")
+ if (H5AC_unprotect(f, dxpl_id, H5AC_FSPACE_SINFO, fspace->sect_addr, fspace->sinfo,
+ H5AC__NO_FLAGS_SET) < 0)
+ HGOTO_ERROR(H5E_FSPACE, H5E_CANTUNPROTECT, FAIL,
+ "unable to release free space section info")
/* Re-protect the section info with read-write access */
- cache_udata.f = f;
+ cache_udata.f = f;
cache_udata.dxpl_id = dxpl_id;
- cache_udata.fspace = fspace;
- if(NULL == (fspace->sinfo = (H5FS_sinfo_t *)H5AC_protect(f, dxpl_id, H5AC_FSPACE_SINFO, fspace->sect_addr, &cache_udata, H5AC_WRITE)))
+ cache_udata.fspace = fspace;
+ if (NULL == (fspace->sinfo = (H5FS_sinfo_t *)H5AC_protect(
+ f, dxpl_id, H5AC_FSPACE_SINFO, fspace->sect_addr, &cache_udata, H5AC_WRITE)))
HGOTO_ERROR(H5E_FSPACE, H5E_CANTPROTECT, FAIL, "unable to load free space sections")
/* Switch the access mode we have */
fspace->sinfo_accmode = H5AC_WRITE;
} /* end if */
- } /* end if */
- } /* end if */
+ } /* end if */
+ } /* end if */
else {
/* If the section address is defined, load it from the file */
- if(H5F_addr_defined(fspace->sect_addr)) {
+ if (H5F_addr_defined(fspace->sect_addr)) {
/* Sanity check */
HDassert(fspace->sinfo_protected == FALSE);
HDassert(H5F_addr_defined(fspace->addr));
#ifdef H5FS_SINFO_DEBUG
-HDfprintf(stderr, "%s: Reading in existing sections, fspace->sect_addr = %a\n", FUNC, fspace->sect_addr);
+ HDfprintf(stderr, "%s: Reading in existing sections, fspace->sect_addr = %a\n", FUNC,
+ fspace->sect_addr);
#endif /* H5FS_SINFO_DEBUG */
/* Protect the free space sections */
- cache_udata.f = f;
+ cache_udata.f = f;
cache_udata.dxpl_id = dxpl_id;
- cache_udata.fspace = fspace;
- if(NULL == (fspace->sinfo = (H5FS_sinfo_t *)H5AC_protect(f, dxpl_id, H5AC_FSPACE_SINFO, fspace->sect_addr, &cache_udata, accmode)))
+ cache_udata.fspace = fspace;
+ if (NULL == (fspace->sinfo = (H5FS_sinfo_t *)H5AC_protect(
+ f, dxpl_id, H5AC_FSPACE_SINFO, fspace->sect_addr, &cache_udata, accmode)))
HGOTO_ERROR(H5E_FSPACE, H5E_CANTPROTECT, FAIL, "unable to load free space sections")
/* Remember that we protected the section info & the access mode */
fspace->sinfo_protected = TRUE;
- fspace->sinfo_accmode = accmode;
+ fspace->sinfo_accmode = accmode;
} /* end if */
else {
#ifdef H5FS_SINFO_DEBUG
-HDfprintf(stderr, "%s: Creating new section info\n", FUNC);
+ HDfprintf(stderr, "%s: Creating new section info\n", FUNC);
#endif /* H5FS_SINFO_DEBUG */
/* Sanity check */
HDassert(fspace->tot_sect_count == 0);
@@ -272,13 +267,13 @@ HDfprintf(stderr, "%s: Creating new section info\n", FUNC);
HDassert(fspace->ghost_sect_count == 0);
/* Allocate and initialize free space section info */
- if(NULL == (fspace->sinfo = H5FS_sinfo_new(f, fspace)))
+ if (NULL == (fspace->sinfo = H5FS_sinfo_new(f, fspace)))
HGOTO_ERROR(H5E_FSPACE, H5E_CANTCREATE, FAIL, "can't create section info")
/* Set initial size of section info to 0 */
fspace->sect_size = fspace->alloc_sect_size = 0;
} /* end if */
- } /* end if */
+ } /* end if */
HDassert(fspace->rc == 2);
/* Increment the section info lock count */
@@ -286,13 +281,14 @@ HDfprintf(stderr, "%s: Creating new section info\n", FUNC);
done:
#ifdef H5FS_SINFO_DEBUG
-HDfprintf(stderr, "%s: Leaving, fspace->addr = %a, fspace->sinfo = %p, fspace->sect_addr = %a\n", FUNC, fspace->addr, fspace->sinfo, fspace->sect_addr);
-HDfprintf(stderr, "%s: fspace->alloc_sect_size = %Hu, fspace->sect_size = %Hu\n", FUNC, fspace->alloc_sect_size, fspace->sect_size);
+ HDfprintf(stderr, "%s: Leaving, fspace->addr = %a, fspace->sinfo = %p, fspace->sect_addr = %a\n", FUNC,
+ fspace->addr, fspace->sinfo, fspace->sect_addr);
+ HDfprintf(stderr, "%s: fspace->alloc_sect_size = %Hu, fspace->sect_size = %Hu\n", FUNC,
+ fspace->alloc_sect_size, fspace->sect_size);
#endif /* H5FS_SINFO_DEBUG */
FUNC_LEAVE_NOAPI(ret_value)
} /* H5FS_sinfo_lock() */
-
/*-------------------------------------------------------------------------
* Function: H5FS_sinfo_unlock
*
@@ -310,13 +306,18 @@ HDfprintf(stderr, "%s: fspace->alloc_sect_size = %Hu, fspace->sect_size = %Hu\n"
static herr_t
H5FS_sinfo_unlock(H5F_t *f, hid_t dxpl_id, H5FS_t *fspace, hbool_t modified)
{
- herr_t ret_value = SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
#ifdef H5FS_SINFO_DEBUG
-HDfprintf(stderr, "%s: Called, modified = %t, fspace->addr = %a, fspace->sect_addr = %a\n", FUNC, modified, fspace->addr, fspace->sect_addr);
-HDfprintf(stderr, "%s: fspace->sinfo_lock_count = %u, fspace->sinfo_modified = %t, fspace->sinfo_protected = %t\n", FUNC, fspace->sinfo_lock_count, fspace->sinfo_modified, fspace->sinfo_protected);
-HDfprintf(stderr, "%s: fspace->alloc_sect_size = %Hu, fspace->sect_size = %Hu\n", FUNC, fspace->alloc_sect_size, fspace->sect_size);
+ HDfprintf(stderr, "%s: Called, modified = %t, fspace->addr = %a, fspace->sect_addr = %a\n", FUNC,
+ modified, fspace->addr, fspace->sect_addr);
+ HDfprintf(
+ stderr,
+ "%s: fspace->sinfo_lock_count = %u, fspace->sinfo_modified = %t, fspace->sinfo_protected = %t\n",
+ FUNC, fspace->sinfo_lock_count, fspace->sinfo_modified, fspace->sinfo_protected);
+ HDfprintf(stderr, "%s: fspace->alloc_sect_size = %Hu, fspace->sect_size = %Hu\n", FUNC,
+ fspace->alloc_sect_size, fspace->sect_size);
#endif /* H5FS_SINFO_DEBUG */
/* Check arguments. */
@@ -326,9 +327,9 @@ HDfprintf(stderr, "%s: fspace->alloc_sect_size = %Hu, fspace->sect_size = %Hu\n"
HDassert(fspace->sinfo);
/* Check if we modified any section */
- if(modified) {
+ if (modified) {
/* Check if the section info was protected with a different access mode */
- if(fspace->sinfo_protected && fspace->sinfo_accmode != H5AC_WRITE)
+ if (fspace->sinfo_protected && fspace->sinfo_accmode != H5AC_WRITE)
HGOTO_ERROR(H5E_FSPACE, H5E_CANTDIRTY, FAIL, "attempt to modify read-only section info")
/* If we modified the section info, mark it dirty */
@@ -340,7 +341,7 @@ HDfprintf(stderr, "%s: fspace->alloc_sect_size = %Hu, fspace->sect_size = %Hu\n"
/* Assume that the modification will affect the statistics in the header
* and mark that dirty also
*/
- if(H5FS_dirty(fspace) < 0)
+ if (H5FS_dirty(fspace) < 0)
HGOTO_ERROR(H5E_FSPACE, H5E_CANTMARKDIRTY, FAIL, "unable to mark free space header as dirty")
} /* end if */
@@ -348,23 +349,24 @@ HDfprintf(stderr, "%s: fspace->alloc_sect_size = %Hu, fspace->sect_size = %Hu\n"
fspace->sinfo_lock_count--;
/* Check if section info lock count dropped to zero */
- if(fspace->sinfo_lock_count == 0) {
- hbool_t release_sinfo_space = FALSE; /* Flag to indicate section info space in file should be released */
+ if (fspace->sinfo_lock_count == 0) {
+ hbool_t release_sinfo_space =
+ FALSE; /* Flag to indicate section info space in file should be released */
/* Check if we actually protected the section info */
- if(fspace->sinfo_protected) {
- unsigned cache_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting heap */
+ if (fspace->sinfo_protected) {
+ unsigned cache_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting heap */
/* Sanity check */
HDassert(H5F_addr_defined(fspace->addr));
/* Check if we've made new changes to the section info while locked */
- if(fspace->sinfo_modified) {
+ if (fspace->sinfo_modified) {
/* Note that we've modified the section info */
cache_flags |= H5AC__DIRTIED_FLAG;
/* Check if the section info size in the file has changed */
- if(fspace->sect_size != fspace->alloc_sect_size)
+ if (fspace->sect_size != fspace->alloc_sect_size)
cache_flags |= H5AC__DELETED_FLAG | H5AC__TAKE_OWNERSHIP_FLAG;
} /* end if */
@@ -375,35 +377,36 @@ HDfprintf(stderr, "%s: fspace->alloc_sect_size = %Hu, fspace->sect_size = %Hu\n"
/* (Possibly dirty) */
/* (Possibly taking ownership from the cache) */
#ifdef H5FS_SINFO_DEBUG
-HDfprintf(stderr, "%s: Unprotecting section info, cache_flags = %u\n", FUNC, cache_flags);
+ HDfprintf(stderr, "%s: Unprotecting section info, cache_flags = %u\n", FUNC, cache_flags);
#endif /* H5FS_SINFO_DEBUG */
- if(H5AC_unprotect(f, dxpl_id, H5AC_FSPACE_SINFO, fspace->sect_addr, fspace->sinfo, cache_flags) < 0)
+ if (H5AC_unprotect(f, dxpl_id, H5AC_FSPACE_SINFO, fspace->sect_addr, fspace->sinfo, cache_flags) <
+ 0)
HGOTO_ERROR(H5E_FSPACE, H5E_CANTUNPROTECT, FAIL, "unable to release free space section info")
/* Reset the protected flag on the section info */
fspace->sinfo_protected = FALSE;
/* Check if header is taking ownership of section info */
- if((cache_flags & H5AC__TAKE_OWNERSHIP_FLAG)) {
+ if ((cache_flags & H5AC__TAKE_OWNERSHIP_FLAG)) {
#ifdef H5FS_SINFO_DEBUG
-HDfprintf(stderr, "%s: Taking ownership of section info\n", FUNC);
+ HDfprintf(stderr, "%s: Taking ownership of section info\n", FUNC);
#endif /* H5FS_SINFO_DEBUG */
/* Set flag to release section info space in file */
release_sinfo_space = TRUE;
} /* end if */
else {
#ifdef H5FS_SINFO_DEBUG
-HDfprintf(stderr, "%s: Relinquishing section info ownership\n", FUNC);
+ HDfprintf(stderr, "%s: Relinquishing section info ownership\n", FUNC);
#endif /* H5FS_SINFO_DEBUG */
/* Free space header relinquished ownership of section info */
fspace->sinfo = NULL;
} /* end else */
- } /* end if */
+ } /* end if */
else {
/* Check if the section info was modified */
- if(fspace->sinfo_modified) {
+ if (fspace->sinfo_modified) {
/* Check if we need to release section info in the file */
- if(H5F_addr_defined(fspace->sect_addr))
+ if (H5F_addr_defined(fspace->sect_addr))
/* Set flag to release section info space in file */
release_sinfo_space = TRUE;
else
@@ -411,50 +414,52 @@ HDfprintf(stderr, "%s: Relinquishing section info ownership\n", FUNC);
} /* end if */
else {
/* Sanity checks... */
- if(H5F_addr_defined(fspace->sect_addr))
+ if (H5F_addr_defined(fspace->sect_addr))
HDassert(fspace->alloc_sect_size == fspace->sect_size);
else
HDassert(fspace->alloc_sect_size == 0);
} /* end else */
- } /* end else */
+ } /* end else */
/* Reset the "section info modified" flag */
fspace->sinfo_modified = FALSE;
/* Check if header needs to release section info in the file */
- if(release_sinfo_space) {
- haddr_t old_sect_addr = fspace->sect_addr; /* Previous location of section info in file */
- hsize_t old_alloc_sect_size = fspace->alloc_sect_size; /* Previous size of section info in file */
+ if (release_sinfo_space) {
+ haddr_t old_sect_addr = fspace->sect_addr; /* Previous location of section info in file */
+ hsize_t old_alloc_sect_size = fspace->alloc_sect_size; /* Previous size of section info in file */
/* Sanity check */
HDassert(H5F_addr_defined(fspace->addr));
/* Reset section info in header */
- fspace->sect_addr = HADDR_UNDEF;
+ fspace->sect_addr = HADDR_UNDEF;
fspace->alloc_sect_size = 0;
/* If we haven't already marked the header dirty, do so now */
- if(!modified)
- if(H5FS_dirty(fspace) < 0)
- HGOTO_ERROR(H5E_FSPACE, H5E_CANTMARKDIRTY, FAIL, "unable to mark free space header as dirty")
+ if (!modified)
+ if (H5FS_dirty(fspace) < 0)
+ HGOTO_ERROR(H5E_FSPACE, H5E_CANTMARKDIRTY, FAIL,
+ "unable to mark free space header as dirty")
#ifdef H5FS_SINFO_DEBUG
-HDfprintf(stderr, "%s: Freeing section info on disk, old_sect_addr = %a, old_alloc_sect_size = %Hu\n", FUNC, old_sect_addr, old_alloc_sect_size);
+ HDfprintf(stderr,
+ "%s: Freeing section info on disk, old_sect_addr = %a, old_alloc_sect_size = %Hu\n",
+ FUNC, old_sect_addr, old_alloc_sect_size);
#endif /* H5FS_SINFO_DEBUG */
/* Release space for section info in file */
- if(H5MF_xfree(f, H5FD_MEM_FSPACE_SINFO, dxpl_id, old_sect_addr, old_alloc_sect_size) < 0)
+ if (H5MF_xfree(f, H5FD_MEM_FSPACE_SINFO, dxpl_id, old_sect_addr, old_alloc_sect_size) < 0)
HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, "unable to free free space sections")
} /* end if */
- } /* end if */
+ } /* end if */
done:
#ifdef H5FS_SINFO_DEBUG
-HDfprintf(stderr, "%s: Leaving, ret_value = %d\n", FUNC, ret_value);
+ HDfprintf(stderr, "%s: Leaving, ret_value = %d\n", FUNC, ret_value);
#endif /* H5FS_SINFO_DEBUG */
FUNC_LEAVE_NOAPI(ret_value)
} /* H5FS_sinfo_unlock() */
-
/*-------------------------------------------------------------------------
* Function: H5FS_sect_serialize_size
*
@@ -476,25 +481,32 @@ H5FS_sect_serialize_size(H5FS_t *fspace)
/* Check arguments. */
HDassert(fspace);
#ifdef QAK
-HDfprintf(stderr, "%s: Check 1.0 - fspace->sect_size = %Hu\n", "H5FS_sect_serialize_size", fspace->sect_size);
-HDfprintf(stderr, "%s: fspace->serial_sect_count = %Zu\n", "H5FS_sect_serialize_size", fspace->serial_sect_count);
-HDfprintf(stderr, "%s: fspace->alloc_sect_size = %Hu\n", "H5FS_sect_serialize_size", fspace->alloc_sect_size);
-HDfprintf(stderr, "%s: fspace->sinfo->serial_size_count = %Zu\n", "H5FS_sect_serialize_size", fspace->sinfo->serial_size_count);
+ HDfprintf(stderr, "%s: Check 1.0 - fspace->sect_size = %Hu\n", "H5FS_sect_serialize_size",
+ fspace->sect_size);
+ HDfprintf(stderr, "%s: fspace->serial_sect_count = %Zu\n", "H5FS_sect_serialize_size",
+ fspace->serial_sect_count);
+ HDfprintf(stderr, "%s: fspace->alloc_sect_size = %Hu\n", "H5FS_sect_serialize_size",
+ fspace->alloc_sect_size);
+ HDfprintf(stderr, "%s: fspace->sinfo->serial_size_count = %Zu\n", "H5FS_sect_serialize_size",
+ fspace->sinfo->serial_size_count);
#endif /* QAK */
/* Compute the size of the buffer required to serialize all the sections */
- if(fspace->serial_sect_count > 0) {
- size_t sect_buf_size; /* Section buffer size */
+ if (fspace->serial_sect_count > 0) {
+ size_t sect_buf_size; /* Section buffer size */
/* Serialized sections prefix */
sect_buf_size = fspace->sinfo->sect_prefix_size;
/* Count for each differently sized serializable section */
#ifdef QAK
-HDfprintf(stderr, "%s: fspace->sinfo->serial_size_count = %Zu\n", "H5FS_sect_serialize_size", fspace->sinfo->serial_size_count);
-HDfprintf(stderr, "%s: fspace->serial_sect_count = %Hu\n", "H5FS_sect_serialize_size", fspace->serial_sect_count);
+ HDfprintf(stderr, "%s: fspace->sinfo->serial_size_count = %Zu\n", "H5FS_sect_serialize_size",
+ fspace->sinfo->serial_size_count);
+ HDfprintf(stderr, "%s: fspace->serial_sect_count = %Hu\n", "H5FS_sect_serialize_size",
+ fspace->serial_sect_count);
#endif /* QAK */
- sect_buf_size += fspace->sinfo->serial_size_count * H5VM_limit_enc_size((uint64_t)fspace->serial_sect_count);
+ sect_buf_size +=
+ fspace->sinfo->serial_size_count * H5VM_limit_enc_size((uint64_t)fspace->serial_sect_count);
/* Size for each differently sized serializable section */
sect_buf_size += fspace->sinfo->serial_size_count * fspace->sinfo->sect_len_size;
@@ -518,7 +530,6 @@ HDfprintf(stderr, "%s: fspace->serial_sect_count = %Hu\n", "H5FS_sect_serialize_
FUNC_LEAVE_NOAPI(SUCCEED)
} /* H5FS_sect_serialize_size() */
-
/*-------------------------------------------------------------------------
* Function: H5FS_sect_increase
*
@@ -534,10 +545,9 @@ HDfprintf(stderr, "%s: fspace->serial_sect_count = %Hu\n", "H5FS_sect_serialize_
*-------------------------------------------------------------------------
*/
static herr_t
-H5FS_sect_increase(H5FS_t *fspace, const H5FS_section_class_t *cls,
- unsigned flags)
+H5FS_sect_increase(H5FS_t *fspace, const H5FS_section_class_t *cls, unsigned flags)
{
- herr_t ret_value = SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
@@ -550,7 +560,7 @@ H5FS_sect_increase(H5FS_t *fspace, const H5FS_section_class_t *cls,
fspace->tot_sect_count++;
/* Check for serializable or 'ghost' section */
- if(cls->flags & H5FS_CLS_GHOST_OBJ) {
+ if (cls->flags & H5FS_CLS_GHOST_OBJ) {
/* Sanity check */
HDassert(cls->serial_size == 0);
@@ -563,24 +573,23 @@ H5FS_sect_increase(H5FS_t *fspace, const H5FS_section_class_t *cls,
/* Increment amount of space required to serialize all sections */
#ifdef QAK
-HDfprintf(stderr, "%s: sinfo->serial_size = %Zu\n", FUNC, fspace->sinfo->serial_size);
-HDfprintf(stderr, "%s: cls->serial_size = %Zu\n", FUNC, cls->serial_size);
+ HDfprintf(stderr, "%s: sinfo->serial_size = %Zu\n", FUNC, fspace->sinfo->serial_size);
+ HDfprintf(stderr, "%s: cls->serial_size = %Zu\n", FUNC, cls->serial_size);
#endif /* QAK */
fspace->sinfo->serial_size += cls->serial_size;
/* Update the free space sections' serialized size */
/* (if we're not deserializing the sections from disk) */
- if(!(flags & H5FS_ADD_DESERIALIZING)) {
- if(H5FS_sect_serialize_size(fspace) < 0)
+ if (!(flags & H5FS_ADD_DESERIALIZING)) {
+ if (H5FS_sect_serialize_size(fspace) < 0)
HGOTO_ERROR(H5E_FSPACE, H5E_CANTCOMPUTE, FAIL, "can't adjust free space section size on disk")
} /* end if */
- } /* end else */
+ } /* end else */
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5FS_sect_increase() */
-
/*-------------------------------------------------------------------------
* Function: H5FS_sect_decrease
*
@@ -599,7 +608,7 @@ done:
static herr_t
H5FS_sect_decrease(H5FS_t *fspace, const H5FS_section_class_t *cls)
{
- herr_t ret_value = SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
@@ -612,7 +621,7 @@ H5FS_sect_decrease(H5FS_t *fspace, const H5FS_section_class_t *cls)
fspace->tot_sect_count--;
/* Check for serializable or 'ghost' section */
- if(cls->flags & H5FS_CLS_GHOST_OBJ) {
+ if (cls->flags & H5FS_CLS_GHOST_OBJ) {
/* Sanity check */
HDassert(cls->serial_size == 0);
@@ -625,13 +634,13 @@ H5FS_sect_decrease(H5FS_t *fspace, const H5FS_section_class_t *cls)
/* Decrement amount of space required to serialize all sections */
#ifdef QAK
-HDfprintf(stderr, "%s: fspace->serial_size = %Zu\n", FUNC, fspace->sinfo->serial_size);
-HDfprintf(stderr, "%s: cls->serial_size = %Zu\n", FUNC, cls->serial_size);
+ HDfprintf(stderr, "%s: fspace->serial_size = %Zu\n", FUNC, fspace->sinfo->serial_size);
+ HDfprintf(stderr, "%s: cls->serial_size = %Zu\n", FUNC, cls->serial_size);
#endif /* QAK */
fspace->sinfo->serial_size -= cls->serial_size;
/* Update the free space sections' serialized size */
- if(H5FS_sect_serialize_size(fspace) < 0)
+ if (H5FS_sect_serialize_size(fspace) < 0)
HGOTO_ERROR(H5E_FSPACE, H5E_CANTCOMPUTE, FAIL, "can't adjust free space section size on disk")
} /* end else */
@@ -639,7 +648,6 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5FS_sect_decrease() */
-
/*-------------------------------------------------------------------------
* Function: H5FS_size_node_decr
*
@@ -655,9 +663,9 @@ done:
*/
static herr_t
H5FS_size_node_decr(H5FS_sinfo_t *sinfo, unsigned bin, H5FS_node_t *fspace_node,
- const H5FS_section_class_t *cls)
+ const H5FS_section_class_t *cls)
{
- herr_t ret_value = SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
@@ -672,11 +680,11 @@ H5FS_size_node_decr(H5FS_sinfo_t *sinfo, unsigned bin, H5FS_node_t *fspace_node,
*/
sinfo->bins[bin].tot_sect_count--;
#ifdef QAK
-HDfprintf(stderr, "%s: sinfo->bins[%u].sect_count = %Zu\n", FUNC, bin, sinfo->bins[bin].sect_count);
+ HDfprintf(stderr, "%s: sinfo->bins[%u].sect_count = %Zu\n", FUNC, bin, sinfo->bins[bin].sect_count);
#endif /* QAK */
/* Check for 'ghost' or 'serializable' section */
- if(cls->flags & H5FS_CLS_GHOST_OBJ) {
+ if (cls->flags & H5FS_CLS_GHOST_OBJ) {
/* Decrement node's ghost section count */
fspace_node->ghost_count--;
@@ -684,7 +692,7 @@ HDfprintf(stderr, "%s: sinfo->bins[%u].sect_count = %Zu\n", FUNC, bin, sinfo->bi
sinfo->bins[bin].ghost_sect_count--;
/* If the node has no more ghost sections, decrement number of ghost section sizes managed */
- if(fspace_node->ghost_count == 0)
+ if (fspace_node->ghost_count == 0)
sinfo->ghost_size_count--;
} /* end if */
else {
@@ -694,14 +702,15 @@ HDfprintf(stderr, "%s: sinfo->bins[%u].sect_count = %Zu\n", FUNC, bin, sinfo->bi
/* Decrement bin's serializable section count */
sinfo->bins[bin].serial_sect_count--;
- /* If the node has no more serializable sections, decrement number of serializable section sizes managed */
- if(fspace_node->serial_count == 0)
+ /* If the node has no more serializable sections, decrement number of serializable section sizes
+ * managed */
+ if (fspace_node->serial_count == 0)
sinfo->serial_size_count--;
} /* end else */
/* Check for no more nodes on list of that size */
- if(H5SL_count(fspace_node->sect_list) == 0) {
- H5FS_node_t *tmp_fspace_node; /* Free space list size node */
+ if (H5SL_count(fspace_node->sect_list) == 0) {
+ H5FS_node_t *tmp_fspace_node; /* Free space list size node */
/* Sanity checks */
HDassert(fspace_node->ghost_count == 0);
@@ -709,11 +718,11 @@ HDfprintf(stderr, "%s: sinfo->bins[%u].sect_count = %Zu\n", FUNC, bin, sinfo->bi
/* Remove size tracking list from bin */
tmp_fspace_node = (H5FS_node_t *)H5SL_remove(sinfo->bins[bin].bin_list, &fspace_node->sect_size);
- if(tmp_fspace_node == NULL || tmp_fspace_node != fspace_node)
+ if (tmp_fspace_node == NULL || tmp_fspace_node != fspace_node)
HGOTO_ERROR(H5E_FSPACE, H5E_CANTREMOVE, FAIL, "can't remove free space node from skip list")
/* Destroy skip list for size tracking node */
- if(H5SL_close(fspace_node->sect_list) < 0)
+ if (H5SL_close(fspace_node->sect_list) < 0)
HGOTO_ERROR(H5E_FSPACE, H5E_CANTCLOSEOBJ, FAIL, "can't destroy size tracking node's skip list")
/* Release free space list node */
@@ -727,7 +736,6 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5FS_size_node_decr() */
-
/*-------------------------------------------------------------------------
* Function: H5FS_sect_unlink_size
*
@@ -743,13 +751,12 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5FS_sect_unlink_size(H5FS_sinfo_t *sinfo, const H5FS_section_class_t *cls,
- H5FS_section_info_t *sect)
+H5FS_sect_unlink_size(H5FS_sinfo_t *sinfo, const H5FS_section_class_t *cls, H5FS_section_info_t *sect)
{
- H5FS_node_t *fspace_node; /* Free list size node */
- H5FS_section_info_t *tmp_sect_node; /* Temporary section node */
- unsigned bin; /* Bin to put the free space section in */
- herr_t ret_value = SUCCEED; /* Return value */
+ H5FS_node_t * fspace_node; /* Free list size node */
+ H5FS_section_info_t *tmp_sect_node; /* Temporary section node */
+ unsigned bin; /* Bin to put the free space section in */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
@@ -762,27 +769,26 @@ H5FS_sect_unlink_size(H5FS_sinfo_t *sinfo, const H5FS_section_class_t *cls,
/* Determine correct bin which holds items of at least the section's size */
bin = H5VM_log2_gen(sect->size);
HDassert(bin < sinfo->nbins);
- if(sinfo->bins[bin].bin_list == NULL)
+ if (sinfo->bins[bin].bin_list == NULL)
HGOTO_ERROR(H5E_FSPACE, H5E_NOTFOUND, FAIL, "node's bin is empty?")
/* Find space node for section's size */
- if((fspace_node = (H5FS_node_t *)H5SL_search(sinfo->bins[bin].bin_list, &sect->size)) == NULL)
+ if ((fspace_node = (H5FS_node_t *)H5SL_search(sinfo->bins[bin].bin_list, &sect->size)) == NULL)
HGOTO_ERROR(H5E_FSPACE, H5E_NOTFOUND, FAIL, "can't find section size node")
/* Remove the section's node from the list */
tmp_sect_node = (H5FS_section_info_t *)H5SL_remove(fspace_node->sect_list, &sect->addr);
- if(tmp_sect_node == NULL || tmp_sect_node != sect)
+ if (tmp_sect_node == NULL || tmp_sect_node != sect)
HGOTO_ERROR(H5E_FSPACE, H5E_NOTFOUND, FAIL, "can't find section node on size list")
/* Decrement # of sections in section size node */
- if(H5FS_size_node_decr(sinfo, bin, fspace_node, cls) < 0)
+ if (H5FS_size_node_decr(sinfo, bin, fspace_node, cls) < 0)
HGOTO_ERROR(H5E_FSPACE, H5E_CANTREMOVE, FAIL, "can't remove free space size node from skip list")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5FS_sect_unlink_size() */
-
/*-------------------------------------------------------------------------
* Function: H5FS_sect_unlink_rest
*
@@ -800,10 +806,9 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5FS_sect_unlink_rest(H5FS_t *fspace, const H5FS_section_class_t *cls,
- H5FS_section_info_t *sect)
+H5FS_sect_unlink_rest(H5FS_t *fspace, const H5FS_section_class_t *cls, H5FS_section_info_t *sect)
{
- herr_t ret_value = SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
@@ -814,24 +819,25 @@ H5FS_sect_unlink_rest(H5FS_t *fspace, const H5FS_section_class_t *cls,
HDassert(sect);
/* Remove node from merge list, if it was entered there */
- if(!(cls->flags & H5FS_CLS_SEPAR_OBJ)) {
+ if (!(cls->flags & H5FS_CLS_SEPAR_OBJ)) {
H5FS_section_info_t *tmp_sect_node; /* Temporary section node */
#ifdef QAK
-HDfprintf(stderr, "%s: removing object from merge list, sect->type = %u\n", FUNC, (unsigned)sect->type);
+ HDfprintf(stderr, "%s: removing object from merge list, sect->type = %u\n", FUNC,
+ (unsigned)sect->type);
#endif /* QAK */
tmp_sect_node = (H5FS_section_info_t *)H5SL_remove(fspace->sinfo->merge_list, &sect->addr);
- if(tmp_sect_node == NULL || tmp_sect_node != sect)
+ if (tmp_sect_node == NULL || tmp_sect_node != sect)
HGOTO_ERROR(H5E_FSPACE, H5E_NOTFOUND, FAIL, "can't find section node on size list")
} /* end if */
/* Update section info & check if we need less room for the serialized free space sections */
- if(H5FS_sect_decrease(fspace, cls) < 0)
+ if (H5FS_sect_decrease(fspace, cls) < 0)
HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "can't increase free space section size on disk")
- /* Decrement amount of free space managed */
+ /* Decrement amount of free space managed */
#ifdef QAK
-HDfprintf(stderr, "%s: fspace->tot_space = %Hu\n", FUNC, fspace->tot_space);
+ HDfprintf(stderr, "%s: fspace->tot_space = %Hu\n", FUNC, fspace->tot_space);
#endif /* QAK */
fspace->tot_space -= sect->size;
@@ -839,7 +845,6 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5FS_sect_unlink_rest() */
-
/*-------------------------------------------------------------------------
* Function: H5FS_sect_remove_real
*
@@ -856,8 +861,8 @@ done:
static herr_t
H5FS_sect_remove_real(H5FS_t *fspace, H5FS_section_info_t *sect)
{
- const H5FS_section_class_t *cls; /* Class of section */
- herr_t ret_value = SUCCEED; /* Return value */
+ const H5FS_section_class_t *cls; /* Class of section */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
@@ -870,18 +875,18 @@ H5FS_sect_remove_real(H5FS_t *fspace, H5FS_section_info_t *sect)
cls = &fspace->sect_cls[sect->type];
/* Remove node from size tracked data structures */
- if(H5FS_sect_unlink_size(fspace->sinfo, cls, sect) < 0)
+ if (H5FS_sect_unlink_size(fspace->sinfo, cls, sect) < 0)
HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, "can't remove section from size tracking data structures")
/* Update rest of free space manager data structures for node removal */
- if(H5FS_sect_unlink_rest(fspace, cls, sect) < 0)
- HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, "can't remove section from non-size tracking data structures")
+ if (H5FS_sect_unlink_rest(fspace, cls, sect) < 0)
+ HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL,
+ "can't remove section from non-size tracking data structures")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5FS_sect_remove_real() */
-
/*-------------------------------------------------------------------------
* Function: H5FS_sect_remove
*
@@ -896,11 +901,10 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5FS_sect_remove(H5F_t *f, hid_t dxpl_id, H5FS_t *fspace,
- H5FS_section_info_t *sect)
+H5FS_sect_remove(H5F_t *f, hid_t dxpl_id, H5FS_t *fspace, H5FS_section_info_t *sect)
{
- hbool_t sinfo_valid = FALSE; /* Whether the section info is valid */
- herr_t ret_value = SUCCEED; /* Return value */
+ hbool_t sinfo_valid = FALSE; /* Whether the section info is valid */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
@@ -910,23 +914,22 @@ H5FS_sect_remove(H5F_t *f, hid_t dxpl_id, H5FS_t *fspace,
HDassert(sect);
/* Get a pointer to the section info */
- if(H5FS_sinfo_lock(f, dxpl_id, fspace, H5AC_WRITE) < 0)
+ if (H5FS_sinfo_lock(f, dxpl_id, fspace, H5AC_WRITE) < 0)
HGOTO_ERROR(H5E_FSPACE, H5E_CANTGET, FAIL, "can't get section info")
sinfo_valid = TRUE;
/* Perform actual section removal */
- if(H5FS_sect_remove_real(fspace, sect) < 0)
+ if (H5FS_sect_remove_real(fspace, sect) < 0)
HGOTO_ERROR(H5E_FSPACE, H5E_CANTREMOVE, FAIL, "can't remove section")
done:
/* Release the section info */
- if(sinfo_valid && H5FS_sinfo_unlock(f, dxpl_id, fspace, TRUE) < 0)
+ if (sinfo_valid && H5FS_sinfo_unlock(f, dxpl_id, fspace, TRUE) < 0)
HDONE_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, "can't release section info")
FUNC_LEAVE_NOAPI(ret_value)
} /* H5FS_sect_remove() */
-
/*-------------------------------------------------------------------------
* Function: H5FS_sect_link_size
*
@@ -941,17 +944,16 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5FS_sect_link_size(H5FS_sinfo_t *sinfo, const H5FS_section_class_t *cls,
- H5FS_section_info_t *sect)
+H5FS_sect_link_size(H5FS_sinfo_t *sinfo, const H5FS_section_class_t *cls, H5FS_section_info_t *sect)
{
- H5FS_node_t *fspace_node = NULL; /* Pointer to free space node of the correct size */
- hbool_t fspace_node_alloc = FALSE; /* Whether the free space node was allocated */
- unsigned bin; /* Bin to put the free space section in */
- herr_t ret_value = SUCCEED; /* Return value */
+ H5FS_node_t *fspace_node = NULL; /* Pointer to free space node of the correct size */
+ hbool_t fspace_node_alloc = FALSE; /* Whether the free space node was allocated */
+ unsigned bin; /* Bin to put the free space section in */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
#ifdef QAK
-HDfprintf(stderr, "%s: sect->size = %Hu, sect->addr = %a\n", FUNC, sect->size, sect->addr);
+ HDfprintf(stderr, "%s: sect->size = %Hu, sect->addr = %a\n", FUNC, sect->size, sect->addr);
#endif /* QAK */
/* Check arguments. */
@@ -963,8 +965,8 @@ HDfprintf(stderr, "%s: sect->size = %Hu, sect->addr = %a\n", FUNC, sect->size, s
/* Determine correct bin which holds items of the section's size */
bin = H5VM_log2_gen(sect->size);
HDassert(bin < sinfo->nbins);
- if(sinfo->bins[bin].bin_list == NULL) {
- if(NULL == (sinfo->bins[bin].bin_list = H5SL_create(H5SL_TYPE_HSIZE, NULL)))
+ if (sinfo->bins[bin].bin_list == NULL) {
+ if (NULL == (sinfo->bins[bin].bin_list = H5SL_create(H5SL_TYPE_HSIZE, NULL)))
HGOTO_ERROR(H5E_FSPACE, H5E_CANTCREATE, FAIL, "can't create skip list for free space nodes")
} /* end if */
else {
@@ -973,20 +975,20 @@ HDfprintf(stderr, "%s: sect->size = %Hu, sect->addr = %a\n", FUNC, sect->size, s
} /* end else */
/* Check if we need to create a new skip list for nodes of this size */
- if(fspace_node == NULL) {
+ if (fspace_node == NULL) {
/* Allocate new free list size node */
- if(NULL == (fspace_node = H5FL_MALLOC(H5FS_node_t)))
+ if (NULL == (fspace_node = H5FL_MALLOC(H5FS_node_t)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for free space node")
fspace_node_alloc = TRUE;
/* Initialize the free list size node */
- fspace_node->sect_size = sect->size;
+ fspace_node->sect_size = sect->size;
fspace_node->serial_count = fspace_node->ghost_count = 0;
- if(NULL == (fspace_node->sect_list = H5SL_create(H5SL_TYPE_HADDR, NULL)))
+ if (NULL == (fspace_node->sect_list = H5SL_create(H5SL_TYPE_HADDR, NULL)))
HGOTO_ERROR(H5E_FSPACE, H5E_CANTCREATE, FAIL, "can't create skip list for free space nodes")
/* Insert new free space size node into bin's list */
- if(H5SL_insert(sinfo->bins[bin].bin_list, fspace_node, &fspace_node->sect_size) < 0)
+ if (H5SL_insert(sinfo->bins[bin].bin_list, fspace_node, &fspace_node->sect_size) < 0)
HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "can't insert free space node into skip list")
fspace_node_alloc = FALSE; /* (owned by the bin skip list now, don't need to free on error) */
@@ -999,15 +1001,15 @@ HDfprintf(stderr, "%s: sect->size = %Hu, sect->addr = %a\n", FUNC, sect->size, s
* the bin's skiplist is also a skiplist...)
*/
#ifdef QAK
-HDfprintf(stderr, "%s: sinfo->bins[%u].sect_count = %Zu\n", FUNC, bin, sinfo->bins[bin].sect_count);
+ HDfprintf(stderr, "%s: sinfo->bins[%u].sect_count = %Zu\n", FUNC, bin, sinfo->bins[bin].sect_count);
#endif /* QAK */
sinfo->bins[bin].tot_sect_count++;
- if(cls->flags & H5FS_CLS_GHOST_OBJ) {
+ if (cls->flags & H5FS_CLS_GHOST_OBJ) {
sinfo->bins[bin].ghost_sect_count++;
fspace_node->ghost_count++;
/* Check for first ghost section in node */
- if(fspace_node->ghost_count == 1)
+ if (fspace_node->ghost_count == 1)
sinfo->ghost_size_count++;
} /* end if */
else {
@@ -1015,26 +1017,26 @@ HDfprintf(stderr, "%s: sinfo->bins[%u].sect_count = %Zu\n", FUNC, bin, sinfo->bi
fspace_node->serial_count++;
/* Check for first serializable section in node */
- if(fspace_node->serial_count == 1)
+ if (fspace_node->serial_count == 1)
sinfo->serial_size_count++;
} /* end else */
/* Insert free space node into correct skip list */
- if(H5SL_insert(fspace_node->sect_list, sect, &sect->addr) < 0)
+ if (H5SL_insert(fspace_node->sect_list, sect, &sect->addr) < 0)
HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "can't insert free space node into skip list")
done:
- if(ret_value < 0)
- if(fspace_node && fspace_node_alloc) {
- if(fspace_node->sect_list && H5SL_close(fspace_node->sect_list) < 0)
- HDONE_ERROR(H5E_FSPACE, H5E_CANTCLOSEOBJ, FAIL, "can't destroy size free space node's skip list")
+ if (ret_value < 0)
+ if (fspace_node && fspace_node_alloc) {
+ if (fspace_node->sect_list && H5SL_close(fspace_node->sect_list) < 0)
+ HDONE_ERROR(H5E_FSPACE, H5E_CANTCLOSEOBJ, FAIL,
+ "can't destroy size free space node's skip list")
fspace_node = H5FL_FREE(H5FS_node_t, fspace_node);
} /* end if */
FUNC_LEAVE_NOAPI(ret_value)
} /* H5FS_sect_link_size() */
-
/*-------------------------------------------------------------------------
* Function: H5FS_sect_link_rest
*
@@ -1051,10 +1053,10 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5FS_sect_link_rest(H5FS_t *fspace, const H5FS_section_class_t *cls,
- H5FS_section_info_t *sect, unsigned flags)
+H5FS_sect_link_rest(H5FS_t *fspace, const H5FS_section_class_t *cls, H5FS_section_info_t *sect,
+ unsigned flags)
{
- herr_t ret_value = SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
@@ -1064,19 +1066,22 @@ H5FS_sect_link_rest(H5FS_t *fspace, const H5FS_section_class_t *cls,
HDassert(sect);
/* Add section to the address-ordered list of sections, if allowed */
- if(!(cls->flags & H5FS_CLS_SEPAR_OBJ)) {
+ if (!(cls->flags & H5FS_CLS_SEPAR_OBJ)) {
#ifdef QAK
-HDfprintf(stderr, "%s: inserting object into merge list, sect->type = %u\n", FUNC, (unsigned)sect->type);
+ HDfprintf(stderr, "%s: inserting object into merge list, sect->type = %u\n", FUNC,
+ (unsigned)sect->type);
#endif /* QAK */
- if(fspace->sinfo->merge_list == NULL)
- if(NULL == (fspace->sinfo->merge_list = H5SL_create(H5SL_TYPE_HADDR, NULL)))
- HGOTO_ERROR(H5E_FSPACE, H5E_CANTCREATE, FAIL, "can't create skip list for merging free space sections")
- if(H5SL_insert(fspace->sinfo->merge_list, sect, &sect->addr) < 0)
- HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "can't insert free space node into merging skip list")
+ if (fspace->sinfo->merge_list == NULL)
+ if (NULL == (fspace->sinfo->merge_list = H5SL_create(H5SL_TYPE_HADDR, NULL)))
+ HGOTO_ERROR(H5E_FSPACE, H5E_CANTCREATE, FAIL,
+ "can't create skip list for merging free space sections")
+ if (H5SL_insert(fspace->sinfo->merge_list, sect, &sect->addr) < 0)
+ HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL,
+ "can't insert free space node into merging skip list")
} /* end if */
/* Update section info & check if we need more room for the serialized free space sections */
- if(H5FS_sect_increase(fspace, cls, flags) < 0)
+ if (H5FS_sect_increase(fspace, cls, flags) < 0)
HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "can't increase free space section size on disk")
/* Increment amount of free space managed */
@@ -1086,7 +1091,6 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5FS_sect_link_rest() */
-
/*-------------------------------------------------------------------------
* Function: H5FS_sect_link
*
@@ -1104,8 +1108,8 @@ done:
static herr_t
H5FS_sect_link(H5FS_t *fspace, H5FS_section_info_t *sect, unsigned flags)
{
- const H5FS_section_class_t *cls; /* Class of section */
- herr_t ret_value = SUCCEED; /* Return value */
+ const H5FS_section_class_t *cls; /* Class of section */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
@@ -1119,26 +1123,26 @@ H5FS_sect_link(H5FS_t *fspace, H5FS_section_info_t *sect, unsigned flags)
/* Add section to size tracked data structures */
#ifdef QAK
-HDfprintf(stderr, "%s: Check 1.0 - fspace->tot_space = %Hu\n", FUNC, fspace->tot_space);
+ HDfprintf(stderr, "%s: Check 1.0 - fspace->tot_space = %Hu\n", FUNC, fspace->tot_space);
#endif /* QAK */
- if(H5FS_sect_link_size(fspace->sinfo, cls, sect) < 0)
+ if (H5FS_sect_link_size(fspace->sinfo, cls, sect) < 0)
HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "can't add section to size tracking data structures")
#ifdef QAK
-HDfprintf(stderr, "%s: Check 2.0 - fspace->tot_space = %Hu\n", FUNC, fspace->tot_space);
+ HDfprintf(stderr, "%s: Check 2.0 - fspace->tot_space = %Hu\n", FUNC, fspace->tot_space);
#endif /* QAK */
/* Update rest of free space manager data structures for section addition */
- if(H5FS_sect_link_rest(fspace, cls, sect, flags) < 0)
- HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "can't add section to non-size tracking data structures")
+ if (H5FS_sect_link_rest(fspace, cls, sect, flags) < 0)
+ HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL,
+ "can't add section to non-size tracking data structures")
#ifdef QAK
-HDfprintf(stderr, "%s: Check 3.0 - fspace->tot_space = %Hu\n", FUNC, fspace->tot_space);
+ HDfprintf(stderr, "%s: Check 3.0 - fspace->tot_space = %Hu\n", FUNC, fspace->tot_space);
#endif /* QAK */
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5FS_sect_link() */
-
/*-------------------------------------------------------------------------
* Function: H5FS_sect_merge
*
@@ -1163,11 +1167,11 @@ done:
static herr_t
H5FS_sect_merge(H5FS_t *fspace, H5FS_section_info_t **sect, void *op_data)
{
- H5FS_section_class_t *sect_cls; /* Section's class */
- hbool_t modified; /* Flag to indicate merge or shrink occurred */
- hbool_t remove_sect = FALSE; /* Whether a section should be removed before shrinking */
- htri_t status; /* Status value */
- herr_t ret_value = SUCCEED; /* Return value */
+ H5FS_section_class_t *sect_cls; /* Section's class */
+ hbool_t modified; /* Flag to indicate merge or shrink occurred */
+ hbool_t remove_sect = FALSE; /* Whether a section should be removed before shrinking */
+ htri_t status; /* Status value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
@@ -1178,13 +1182,13 @@ H5FS_sect_merge(H5FS_t *fspace, H5FS_section_info_t **sect, void *op_data)
HDassert((*sect)->size);
/* Loop until no more merging */
- if(fspace->sinfo->merge_list) {
+ if (fspace->sinfo->merge_list) {
do {
- H5SL_node_t *less_sect_node; /* Skip list node for section less than new section */
- H5SL_node_t *greater_sect_node; /* Skip list node for section greater than new section */
- H5FS_section_info_t *tmp_sect; /* Temporary free space section */
- H5FS_section_class_t *tmp_sect_cls; /* Temporary section's class */
- hbool_t greater_sect_node_valid = FALSE; /* Indicate if 'greater than' section node is valid */
+ H5SL_node_t * less_sect_node; /* Skip list node for section less than new section */
+ H5SL_node_t * greater_sect_node; /* Skip list node for section greater than new section */
+ H5FS_section_info_t * tmp_sect; /* Temporary free space section */
+ H5FS_section_class_t *tmp_sect_cls; /* Temporary section's class */
+ hbool_t greater_sect_node_valid = FALSE; /* Indicate if 'greater than' section node is valid */
/* Reset 'modification occurred' flag */
modified = FALSE;
@@ -1193,9 +1197,9 @@ H5FS_sect_merge(H5FS_t *fspace, H5FS_section_info_t **sect, void *op_data)
less_sect_node = H5SL_below(fspace->sinfo->merge_list, &(*sect)->addr);
/* Check for node before new node able to merge with new node */
- if(less_sect_node) {
+ if (less_sect_node) {
/* Check for node greater than section */
- greater_sect_node = H5SL_next(less_sect_node);
+ greater_sect_node = H5SL_next(less_sect_node);
greater_sect_node_valid = TRUE;
/* Get section for 'less than' skip list node */
@@ -1203,27 +1207,28 @@ H5FS_sect_merge(H5FS_t *fspace, H5FS_section_info_t **sect, void *op_data)
/* Get classes for right & left sections */
tmp_sect_cls = &fspace->sect_cls[tmp_sect->type];
- sect_cls = &fspace->sect_cls[(*sect)->type];
+ sect_cls = &fspace->sect_cls[(*sect)->type];
/* Check if sections of the left most class can merge with sections
* of another class & whether the sections are the same type,
* then check for 'can merge' callback
*/
- if((!(tmp_sect_cls->flags & H5FS_CLS_MERGE_SYM) || (tmp_sect->type == (*sect)->type))
- && tmp_sect_cls->can_merge) {
+ if ((!(tmp_sect_cls->flags & H5FS_CLS_MERGE_SYM) || (tmp_sect->type == (*sect)->type)) &&
+ tmp_sect_cls->can_merge) {
/* Determine if the sections can merge */
- if((status = (*tmp_sect_cls->can_merge)(tmp_sect, *sect, op_data)) < 0)
+ if ((status = (*tmp_sect_cls->can_merge)(tmp_sect, *sect, op_data)) < 0)
HGOTO_ERROR(H5E_FSPACE, H5E_CANTMERGE, FAIL, "can't check for merging sections")
- if(status > 0) {
+ if (status > 0) {
/* Sanity check */
HDassert(tmp_sect_cls->merge);
/* Remove 'less than' node from data structures */
- if(H5FS_sect_remove_real(fspace, tmp_sect) < 0)
- HGOTO_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, "can't remove section from internal data structures")
+ if (H5FS_sect_remove_real(fspace, tmp_sect) < 0)
+ HGOTO_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL,
+ "can't remove section from internal data structures")
/* Merge the two sections together */
- if((*tmp_sect_cls->merge)(tmp_sect, *sect, op_data) < 0)
+ if ((*tmp_sect_cls->merge)(tmp_sect, *sect, op_data) < 0)
HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "can't merge two sections")
/* Retarget section pointer to 'less than' node that was merged into */
@@ -1232,54 +1237,56 @@ H5FS_sect_merge(H5FS_t *fspace, H5FS_section_info_t **sect, void *op_data)
/* Indicate successful merge occurred */
modified = TRUE;
} /* end if */
- } /* end if */
- } /* end if */
+ } /* end if */
+ } /* end if */
/* Look for section after new (or merged) section, if not already determined */
- if(!greater_sect_node_valid)
+ if (!greater_sect_node_valid)
greater_sect_node = H5SL_above(fspace->sinfo->merge_list, &(*sect)->addr);
/* Check for node after new node able to merge with new node */
- if(greater_sect_node) {
+ if (greater_sect_node) {
/* Get section for 'greater than' skip list node */
tmp_sect = (H5FS_section_info_t *)H5SL_item(greater_sect_node);
/* Get classes for right & left sections */
- sect_cls = &fspace->sect_cls[(*sect)->type];
+ sect_cls = &fspace->sect_cls[(*sect)->type];
tmp_sect_cls = &fspace->sect_cls[tmp_sect->type];
/* Check if sections of the left most class can merge with sections
* of another class & whether the sections are the same type,
* then check for 'can merge' callback
*/
- if((!(sect_cls->flags & H5FS_CLS_MERGE_SYM) || ((*sect)->type == tmp_sect->type))
- && sect_cls->can_merge) {
+ if ((!(sect_cls->flags & H5FS_CLS_MERGE_SYM) || ((*sect)->type == tmp_sect->type)) &&
+ sect_cls->can_merge) {
/* Determine if the sections can merge */
- if((status = (*sect_cls->can_merge)(*sect, tmp_sect, op_data)) < 0)
+ if ((status = (*sect_cls->can_merge)(*sect, tmp_sect, op_data)) < 0)
HGOTO_ERROR(H5E_FSPACE, H5E_CANTMERGE, FAIL, "can't check for merging sections")
- if(status > 0) {
+ if (status > 0) {
/* Sanity check */
HDassert(sect_cls->merge);
/* Remove 'greater than' node from data structures */
- if(H5FS_sect_remove_real(fspace, tmp_sect) < 0)
- HGOTO_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, "can't remove section from internal data structures")
+ if (H5FS_sect_remove_real(fspace, tmp_sect) < 0)
+ HGOTO_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL,
+ "can't remove section from internal data structures")
/* Merge the two sections together */
- if((*sect_cls->merge)(*sect, tmp_sect, op_data) < 0)
+ if ((*sect_cls->merge)(*sect, tmp_sect, op_data) < 0)
HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "can't merge two sections")
/* Indicate successful merge occurred */
modified = TRUE;
} /* end if */
- } /* end if */
- } /* end if */
- } while(modified);
+ } /* end if */
+ } /* end if */
+ } while (modified);
} /* end if */
HDassert(*sect);
#ifdef QAK
-HDfprintf(stderr, "%s: Done merging, (*sect) = {%a, %Hu, %u, %s}\n", FUNC, (*sect)->addr, (*sect)->size, (*sect)->type, ((*sect)->state == H5FS_SECT_LIVE ? "H5FS_SECT_LIVE" : "H5FS_SECT_SERIALIZED"));
+ HDfprintf(stderr, "%s: Done merging, (*sect) = {%a, %Hu, %u, %s}\n", FUNC, (*sect)->addr, (*sect)->size,
+ (*sect)->type, ((*sect)->state == H5FS_SECT_LIVE ? "H5FS_SECT_LIVE" : "H5FS_SECT_SERIALIZED"));
#endif /* QAK */
/* Loop until no more shrinking */
@@ -1289,36 +1296,37 @@ HDfprintf(stderr, "%s: Done merging, (*sect) = {%a, %Hu, %u, %s}\n", FUNC, (*sec
/* Check for (possibly merged) section able to shrink the size of the container */
sect_cls = &fspace->sect_cls[(*sect)->type];
- if(sect_cls->can_shrink) {
- if((status = (*sect_cls->can_shrink)(*sect, op_data)) < 0)
+ if (sect_cls->can_shrink) {
+ if ((status = (*sect_cls->can_shrink)(*sect, op_data)) < 0)
HGOTO_ERROR(H5E_FSPACE, H5E_CANTSHRINK, FAIL, "can't check for shrinking container")
- if(status > 0) {
+ if (status > 0) {
#ifdef QAK
-HDfprintf(stderr, "%s: Can shrink!\n", FUNC);
+ HDfprintf(stderr, "%s: Can shrink!\n", FUNC);
#endif /* QAK */
- /* Remove SECT from free-space manager */
+ /* Remove SECT from free-space manager */
/* (only possible to happen on second+ pass through loop) */
- if(remove_sect) {
- if(H5FS_sect_remove_real(fspace, *sect) < 0)
- HGOTO_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, "can't remove section from internal data structures")
- remove_sect = FALSE;
- } /* end if */
+ if (remove_sect) {
+ if (H5FS_sect_remove_real(fspace, *sect) < 0)
+ HGOTO_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL,
+ "can't remove section from internal data structures")
+ remove_sect = FALSE;
+ } /* end if */
/* Shrink the container */
/* (callback can indicate that it has discarded the section by setting *sect to NULL) */
HDassert(sect_cls->shrink);
- if((*sect_cls->shrink)(sect, op_data) < 0)
+ if ((*sect_cls->shrink)(sect, op_data) < 0)
HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "can't shrink free space container")
/* If this section was shrunk away, we may need to shrink another section */
- if(*sect == NULL) {
+ if (*sect == NULL) {
/* Check for sections on merge list */
- if(fspace->sinfo->merge_list) {
- H5SL_node_t *last_node; /* Last node in merge list */
+ if (fspace->sinfo->merge_list) {
+ H5SL_node_t *last_node; /* Last node in merge list */
/* Check for last node in the merge list */
- if(NULL != (last_node = H5SL_last(fspace->sinfo->merge_list))) {
+ if (NULL != (last_node = H5SL_last(fspace->sinfo->merge_list))) {
/* Get the pointer to the last section, from the last node */
*sect = (H5FS_section_info_t *)H5SL_item(last_node);
HDassert(*sect);
@@ -1326,35 +1334,36 @@ HDfprintf(stderr, "%s: Can shrink!\n", FUNC);
/* Indicate that this section needs to be removed if it causes a shrink */
remove_sect = TRUE;
} /* end if */
- } /* end if */
- } /* end if */
+ } /* end if */
+ } /* end if */
/* Indicate successful merge occurred */
modified = TRUE;
} /* end if */
- } /* end if */
- } while(modified && *sect);
+ } /* end if */
+ } while (modified && *sect);
/* Check for section that was shrunk away and next section not shrinking */
- if(remove_sect && (*sect != NULL))
- *sect = NULL;
+ if (remove_sect && (*sect != NULL))
+ *sect = NULL;
#ifdef QAK
-HDfprintf(stderr, "%s: Done shrinking\n", FUNC);
-if(*sect)
- HDfprintf(stderr, "%s: (*sect) = {%a, %Hu, %u, %s}\n", FUNC, (*sect)->addr, (*sect)->size, (*sect)->type, ((*sect)->state == H5FS_SECT_LIVE ? "H5FS_SECT_LIVE" : "H5FS_SECT_SERIALIZED"));
-else
- HDfprintf(stderr, "%s: *sect = %p\n", FUNC, *sect);
+ HDfprintf(stderr, "%s: Done shrinking\n", FUNC);
+ if (*sect)
+ HDfprintf(stderr, "%s: (*sect) = {%a, %Hu, %u, %s}\n", FUNC, (*sect)->addr, (*sect)->size,
+ (*sect)->type,
+ ((*sect)->state == H5FS_SECT_LIVE ? "H5FS_SECT_LIVE" : "H5FS_SECT_SERIALIZED"));
+ else
+ HDfprintf(stderr, "%s: *sect = %p\n", FUNC, *sect);
#endif /* QAK */
done:
#ifdef QAK
-HDfprintf(stderr, "%s: Leaving, ret_value = %d\n", FUNC, ret_value);
+ HDfprintf(stderr, "%s: Leaving, ret_value = %d\n", FUNC, ret_value);
#endif /* QAK */
FUNC_LEAVE_NOAPI(ret_value)
} /* H5FS_sect_merge() */
-
/*-------------------------------------------------------------------------
* Function: H5FS_sect_add
*
@@ -1370,18 +1379,19 @@ HDfprintf(stderr, "%s: Leaving, ret_value = %d\n", FUNC, ret_value);
*-------------------------------------------------------------------------
*/
herr_t
-H5FS_sect_add(H5F_t *f, hid_t dxpl_id, H5FS_t *fspace, H5FS_section_info_t *sect,
- unsigned flags, void *op_data)
+H5FS_sect_add(H5F_t *f, hid_t dxpl_id, H5FS_t *fspace, H5FS_section_info_t *sect, unsigned flags,
+ void *op_data)
{
- H5FS_section_class_t *cls; /* Section's class */
- hbool_t sinfo_valid = FALSE; /* Whether the section info is valid */
- hbool_t sinfo_modified = FALSE; /* Whether the section info was modified */
- herr_t ret_value = SUCCEED; /* Return value */
+ H5FS_section_class_t *cls; /* Section's class */
+ hbool_t sinfo_valid = FALSE; /* Whether the section info is valid */
+ hbool_t sinfo_modified = FALSE; /* Whether the section info was modified */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
#ifdef H5FS_SINFO_DEBUG
-HDfprintf(stderr, "%s: *sect = {%a, %Hu, %u, %s}\n", FUNC, sect->addr, sect->size, sect->type, (sect->state == H5FS_SECT_LIVE ? "H5FS_SECT_LIVE" : "H5FS_SECT_SERIALIZED"));
+ HDfprintf(stderr, "%s: *sect = {%a, %Hu, %u, %s}\n", FUNC, sect->addr, sect->size, sect->type,
+ (sect->state == H5FS_SECT_LIVE ? "H5FS_SECT_LIVE" : "H5FS_SECT_SERIALIZED"));
#endif /* H5FS_SINFO_DEBUG */
/* Check arguments. */
@@ -1391,25 +1401,25 @@ HDfprintf(stderr, "%s: *sect = {%a, %Hu, %u, %s}\n", FUNC, sect->addr, sect->siz
HDassert(sect->size);
/* Get a pointer to the section info */
- if(H5FS_sinfo_lock(f, dxpl_id, fspace, H5AC_WRITE) < 0)
+ if (H5FS_sinfo_lock(f, dxpl_id, fspace, H5AC_WRITE) < 0)
HGOTO_ERROR(H5E_FSPACE, H5E_CANTGET, FAIL, "can't get section info")
sinfo_valid = TRUE;
/* Call "add" section class callback, if there is one */
cls = &fspace->sect_cls[sect->type];
- if(cls->add) {
- if((*cls->add)(sect, &flags, op_data) < 0)
+ if (cls->add) {
+ if ((*cls->add)(sect, &flags, op_data) < 0)
HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "'add' section class callback failed")
} /* end if */
/* Check for merging returned space with existing section node */
- if(flags & H5FS_ADD_RETURNED_SPACE) {
+ if (flags & H5FS_ADD_RETURNED_SPACE) {
#ifdef H5FS_SINFO_DEBUG
-HDfprintf(stderr, "%s: Returning space\n", FUNC);
+ HDfprintf(stderr, "%s: Returning space\n", FUNC);
#endif /* H5FS_SINFO_DEBUG */
/* Attempt to merge returned section with existing sections */
- if(H5FS_sect_merge(fspace, &sect, op_data) < 0)
+ if (H5FS_sect_merge(fspace, &sect, op_data) < 0)
HGOTO_ERROR(H5E_FSPACE, H5E_CANTMERGE, FAIL, "can't merge sections")
} /* end if */
@@ -1417,34 +1427,33 @@ HDfprintf(stderr, "%s: Returning space\n", FUNC);
/* (If section has been completely merged or shrunk away, 'sect' will
* be NULL at this point - QAK)
*/
- if(sect)
- if(H5FS_sect_link(fspace, sect, flags) < 0)
+ if (sect)
+ if (H5FS_sect_link(fspace, sect, flags) < 0)
HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "can't insert free space section into skip list")
#ifdef H5FS_SINFO_DEBUG
-HDfprintf(stderr, "%s: fspace->tot_space = %Hu\n", FUNC, fspace->tot_space);
+ HDfprintf(stderr, "%s: fspace->tot_space = %Hu\n", FUNC, fspace->tot_space);
#endif /* H5FS_SINFO_DEBUG */
/* Mark free space sections as changed */
/* (if adding sections while deserializing sections, don't set the flag) */
- if(!(flags & H5FS_ADD_DESERIALIZING))
+ if (!(flags & H5FS_ADD_DESERIALIZING))
sinfo_modified = TRUE;
done:
/* Release the section info */
- if(sinfo_valid && H5FS_sinfo_unlock(f, dxpl_id, fspace, sinfo_modified) < 0)
+ if (sinfo_valid && H5FS_sinfo_unlock(f, dxpl_id, fspace, sinfo_modified) < 0)
HDONE_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, "can't release section info")
#ifdef H5FS_DEBUG_ASSERT
-if(!(flags & (H5FS_ADD_DESERIALIZING | H5FS_ADD_SKIP_VALID)))
- H5FS_assert(fspace);
+ if (!(flags & (H5FS_ADD_DESERIALIZING | H5FS_ADD_SKIP_VALID)))
+ H5FS_assert(fspace);
#endif /* H5FS_DEBUG_ASSERT */
#ifdef H5FS_SINFO_DEBUG
-HDfprintf(stderr, "%s: Leaving, ret_value = %d\n", FUNC, ret_value);
+ HDfprintf(stderr, "%s: Leaving, ret_value = %d\n", FUNC, ret_value);
#endif /* H5FS_SINFO_DEBUG */
FUNC_LEAVE_NOAPI(ret_value)
} /* H5FS_sect_add() */
-
/*-------------------------------------------------------------------------
* Function: H5FS_sect_try_extend
*
@@ -1459,17 +1468,18 @@ HDfprintf(stderr, "%s: Leaving, ret_value = %d\n", FUNC, ret_value);
*-------------------------------------------------------------------------
*/
htri_t
-H5FS_sect_try_extend(H5F_t *f, hid_t dxpl_id, H5FS_t *fspace, haddr_t addr,
- hsize_t size, hsize_t extra_requested)
+H5FS_sect_try_extend(H5F_t *f, hid_t dxpl_id, H5FS_t *fspace, haddr_t addr, hsize_t size,
+ hsize_t extra_requested)
{
- hbool_t sinfo_valid = FALSE; /* Whether the section info is valid */
- hbool_t sinfo_modified = FALSE; /* Whether the section info was modified */
- htri_t ret_value = FALSE; /* Return value */
+ hbool_t sinfo_valid = FALSE; /* Whether the section info is valid */
+ hbool_t sinfo_modified = FALSE; /* Whether the section info was modified */
+ htri_t ret_value = FALSE; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
#ifdef H5FS_SINFO_DEBUG
-HDfprintf(stderr, "%s: addr = %a, size = %Hu, extra_requested = %hu\n", FUNC, addr, size, extra_requested);
+ HDfprintf(stderr, "%s: addr = %a, size = %Hu, extra_requested = %hu\n", FUNC, addr, size,
+ extra_requested);
#endif /* H5FS_SINFO_DEBUG */
/* Check arguments. */
@@ -1481,39 +1491,38 @@ HDfprintf(stderr, "%s: addr = %a, size = %Hu, extra_requested = %hu\n", FUNC, ad
/* Check for any sections on free space list */
#ifdef H5FS_SINFO_DEBUG
-HDfprintf(stderr, "%s: fspace->tot_sect_count = %Hu\n", FUNC, fspace->tot_sect_count);
-HDfprintf(stderr, "%s: fspace->serial_sect_count = %Hu\n", FUNC, fspace->serial_sect_count);
-HDfprintf(stderr, "%s: fspace->ghost_sect_count = %Hu\n", FUNC, fspace->ghost_sect_count);
+ HDfprintf(stderr, "%s: fspace->tot_sect_count = %Hu\n", FUNC, fspace->tot_sect_count);
+ HDfprintf(stderr, "%s: fspace->serial_sect_count = %Hu\n", FUNC, fspace->serial_sect_count);
+ HDfprintf(stderr, "%s: fspace->ghost_sect_count = %Hu\n", FUNC, fspace->ghost_sect_count);
#endif /* H5FS_SINFO_DEBUG */
- if(fspace->tot_sect_count > 0) {
- H5FS_section_info_t *sect; /* Temporary free space section */
+ if (fspace->tot_sect_count > 0) {
+ H5FS_section_info_t *sect; /* Temporary free space section */
/* Get a pointer to the section info */
- if(H5FS_sinfo_lock(f, dxpl_id, fspace, H5AC_WRITE) < 0)
+ if (H5FS_sinfo_lock(f, dxpl_id, fspace, H5AC_WRITE) < 0)
HGOTO_ERROR(H5E_FSPACE, H5E_CANTGET, FAIL, "can't get section info")
sinfo_valid = TRUE;
+ /*
-/*
+ Pseudo-code for algorithm:
+
+ _section_ = <Get pointer to section with address > _region.addr_>
+ if(_section_)
+ if(_section_ adjoins _region_ && _section.size_ >= _extra_requested_)
+ <remove section from data structures>
+ if(_section.size_ > _extra_requested_)
+ if(<can adjust _section_>)
+ <adjust _section_ by _extra_requested_>
+ <add adjusted section back to data structures>
+ else
+ <re-add UNadjusted section back to data structures>
+ <error>
+ <mark free space sections as changed in metadata cache>
-Pseudo-code for algorithm:
-
-_section_ = <Get pointer to section with address > _region.addr_>
-if(_section_)
- if(_section_ adjoins _region_ && _section.size_ >= _extra_requested_)
- <remove section from data structures>
- if(_section.size_ > _extra_requested_)
- if(<can adjust _section_>)
- <adjust _section_ by _extra_requested_>
- <add adjusted section back to data structures>
- else
- <re-add UNadjusted section back to data structures>
- <error>
- <mark free space sections as changed in metadata cache>
-
-*/
+ */
/* Look for a section after block to extend */
- if((sect = (H5FS_section_info_t *)H5SL_greater(fspace->sinfo->merge_list, &addr))) {
+ if ((sect = (H5FS_section_info_t *)H5SL_greater(fspace->sinfo->merge_list, &addr))) {
/* Check if this section adjoins the block and is large enough to
* fulfill extension request.
*
@@ -1521,12 +1530,13 @@ if(_section_)
* possible neighboring nodes and is not at the end of the file
* (or it would have been eliminated), etc)
*/
- if(sect->size >= extra_requested && (addr + size) == sect->addr) {
- H5FS_section_class_t *cls; /* Section's class */
+ if (sect->size >= extra_requested && (addr + size) == sect->addr) {
+ H5FS_section_class_t *cls; /* Section's class */
/* Remove section from data structures */
- if(H5FS_sect_remove_real(fspace, sect) < 0)
- HGOTO_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, "can't remove section from internal data structures")
+ if (H5FS_sect_remove_real(fspace, sect) < 0)
+ HGOTO_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL,
+ "can't remove section from internal data structures")
/* Get class for section */
cls = &fspace->sect_cls[sect->type];
@@ -1537,7 +1547,7 @@ if(_section_)
* for the current usage, so I've deferred messing with
* it. - QAK - 2008/01/08)
*/
- if(sect->size > extra_requested) {
+ if (sect->size > extra_requested) {
/* Sanity check (for now) */
HDassert(cls->flags & H5FS_CLS_ADJUST_OK);
@@ -1546,15 +1556,16 @@ if(_section_)
sect->size -= extra_requested;
/* Re-add adjusted section to free sections data structures */
- if(H5FS_sect_link(fspace, sect, 0) < 0)
- HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "can't insert free space section into skip list")
+ if (H5FS_sect_link(fspace, sect, 0) < 0)
+ HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL,
+ "can't insert free space section into skip list")
} /* end if */
else {
/* Sanity check */
HDassert(sect->size == extra_requested);
/* Exact match, so just free section */
- if((*cls->free)(sect) < 0)
+ if ((*cls->free)(sect) < 0)
HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, "can't free section")
} /* end else */
@@ -1564,18 +1575,17 @@ if(_section_)
/* Indicate success */
HGOTO_DONE(TRUE);
} /* end if */
- } /* end if */
- } /* end if */
+ } /* end if */
+ } /* end if */
done:
/* Release the section info */
- if(sinfo_valid && H5FS_sinfo_unlock(f, dxpl_id, fspace, sinfo_modified) < 0)
+ if (sinfo_valid && H5FS_sinfo_unlock(f, dxpl_id, fspace, sinfo_modified) < 0)
HDONE_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, "can't release section info")
FUNC_LEAVE_NOAPI(ret_value)
} /* H5FS_sect_try_extend() */
-
/*-------------------------------------------------------------------------
* Function: H5FS_sect_find_node
*
@@ -1599,13 +1609,13 @@ done:
static htri_t
H5FS_sect_find_node(H5FS_t *fspace, hsize_t request, H5FS_section_info_t **node)
{
- H5FS_node_t *fspace_node; /* Free list size node */
- unsigned bin; /* Bin to put the free space section in */
- htri_t ret_value = FALSE; /* Return value */
+ H5FS_node_t *fspace_node; /* Free list size node */
+ unsigned bin; /* Bin to put the free space section in */
+ htri_t ret_value = FALSE; /* Return value */
- H5SL_node_t *curr_size_node=NULL;
- const H5FS_section_class_t *cls; /* Class of section */
- hsize_t alignment;
+ H5SL_node_t * curr_size_node = NULL;
+ const H5FS_section_class_t *cls; /* Class of section */
+ hsize_t alignment;
FUNC_ENTER_NOAPI_NOINIT
@@ -1620,45 +1630,49 @@ H5FS_sect_find_node(H5FS_t *fspace, hsize_t request, H5FS_section_info_t **node)
bin = H5VM_log2_gen(request);
HDassert(bin < fspace->sinfo->nbins);
#ifdef QAK
-HDfprintf(stderr, "%s: fspace->sinfo->nbins = %u\n", FUNC, fspace->sinfo->nbins);
-HDfprintf(stderr, "%s: bin = %u\n", FUNC, bin);
+ HDfprintf(stderr, "%s: fspace->sinfo->nbins = %u\n", FUNC, fspace->sinfo->nbins);
+ HDfprintf(stderr, "%s: bin = %u\n", FUNC, bin);
#endif /* QAK */
alignment = fspace->alignment;
- if(!((alignment > 1) && (request >= fspace->threshold)))
- alignment = 0; /* no alignment */
+ if (!((alignment > 1) && (request >= fspace->threshold)))
+ alignment = 0; /* no alignment */
do {
/* Check if there's any sections in this bin */
- if(fspace->sinfo->bins[bin].bin_list) {
-
- if (!alignment) { /* no alignment */
- /* Find the first free space section that is large enough to fulfill request */
- /* (Since the bins use skip lists to track the sizes of the address-ordered
- * lists, this is actually a "best fit" algorithm)
- */
- /* Look for large enough free space section in this bin */
- if((fspace_node = (H5FS_node_t *)H5SL_greater(fspace->sinfo->bins[bin].bin_list, &request))) {
- /* Take first node off of the list (ie. node w/lowest address) */
- if(NULL == (*node = (H5FS_section_info_t *)H5SL_remove_first(fspace_node->sect_list)))
- HGOTO_ERROR(H5E_FSPACE, H5E_CANTREMOVE, FAIL, "can't remove free space node from skip list")
-
- /* Get section's class */
- cls = &fspace->sect_cls[(*node)->type];
- /* Decrement # of sections in section size node */
- if(H5FS_size_node_decr(fspace->sinfo, bin, fspace_node, cls) < 0)
- HGOTO_ERROR(H5E_FSPACE, H5E_CANTREMOVE, FAIL, "can't remove free space size node from skip list")
- if(H5FS_sect_unlink_rest(fspace, cls, *node) < 0)
- HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, "can't remove section from non-size tracking data structures")
- /* Indicate that we found a node for the request */
- HGOTO_DONE(TRUE)
- } /* end if */
- } /* end if */
+ if (fspace->sinfo->bins[bin].bin_list) {
+
+ if (!alignment) { /* no alignment */
+ /* Find the first free space section that is large enough to fulfill request */
+ /* (Since the bins use skip lists to track the sizes of the address-ordered
+ * lists, this is actually a "best fit" algorithm)
+ */
+ /* Look for large enough free space section in this bin */
+ if ((fspace_node =
+ (H5FS_node_t *)H5SL_greater(fspace->sinfo->bins[bin].bin_list, &request))) {
+ /* Take first node off of the list (ie. node w/lowest address) */
+ if (NULL == (*node = (H5FS_section_info_t *)H5SL_remove_first(fspace_node->sect_list)))
+ HGOTO_ERROR(H5E_FSPACE, H5E_CANTREMOVE, FAIL,
+ "can't remove free space node from skip list")
+
+ /* Get section's class */
+ cls = &fspace->sect_cls[(*node)->type];
+ /* Decrement # of sections in section size node */
+ if (H5FS_size_node_decr(fspace->sinfo, bin, fspace_node, cls) < 0)
+ HGOTO_ERROR(H5E_FSPACE, H5E_CANTREMOVE, FAIL,
+ "can't remove free space size node from skip list")
+ if (H5FS_sect_unlink_rest(fspace, cls, *node) < 0)
+ HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL,
+ "can't remove section from non-size tracking data structures")
+ /* Indicate that we found a node for the request */
+ HGOTO_DONE(TRUE)
+ } /* end if */
+ } /* end if */
else { /* alignment is set */
/* get the first node of a certain size in this bin */
curr_size_node = H5SL_first(fspace->sinfo->bins[bin].bin_list);
while (curr_size_node != NULL) {
- H5FS_node_t *curr_fspace_node=NULL;
- H5SL_node_t *curr_sect_node=NULL;
+ H5FS_node_t *curr_fspace_node = NULL;
+ H5SL_node_t *curr_sect_node = NULL;
/* Get the free space node for free space sections of the same size */
curr_fspace_node = (H5FS_node_t *)H5SL_item(curr_size_node);
@@ -1666,10 +1680,10 @@ HDfprintf(stderr, "%s: bin = %u\n", FUNC, bin);
/* Get the Skip list which holds pointers to actual free list sections */
curr_sect_node = (H5SL_node_t *)H5SL_first(curr_fspace_node->sect_list);
- while(curr_sect_node != NULL) {
- H5FS_section_info_t *curr_sect=NULL;
- hsize_t mis_align=0, frag_size=0;
- H5FS_section_info_t *split_sect=NULL;
+ while (curr_sect_node != NULL) {
+ H5FS_section_info_t *curr_sect = NULL;
+ hsize_t mis_align = 0, frag_size = 0;
+ H5FS_section_info_t *split_sect = NULL;
/* Get section node */
curr_sect = (H5FS_section_info_t *)H5SL_item(curr_sect_node);
@@ -1687,14 +1701,18 @@ HDfprintf(stderr, "%s: bin = %u\n", FUNC, bin);
if ((curr_sect->size >= (request + frag_size)) && (cls->split)) {
/* remove the section with aligned address */
- if(NULL == (*node = (H5FS_section_info_t *)H5SL_remove(curr_fspace_node->sect_list, &curr_sect->addr)))
- HGOTO_ERROR(H5E_FSPACE, H5E_CANTREMOVE, FAIL, "can't remove free space node from skip list")
+ if (NULL == (*node = (H5FS_section_info_t *)H5SL_remove(
+ curr_fspace_node->sect_list, &curr_sect->addr)))
+ HGOTO_ERROR(H5E_FSPACE, H5E_CANTREMOVE, FAIL,
+ "can't remove free space node from skip list")
/* Decrement # of sections in section size node */
- if(H5FS_size_node_decr(fspace->sinfo, bin, curr_fspace_node, cls) < 0)
- HGOTO_ERROR(H5E_FSPACE, H5E_CANTREMOVE, FAIL, "can't remove free space size node from skip list")
+ if (H5FS_size_node_decr(fspace->sinfo, bin, curr_fspace_node, cls) < 0)
+ HGOTO_ERROR(H5E_FSPACE, H5E_CANTREMOVE, FAIL,
+ "can't remove free space size node from skip list")
- if(H5FS_sect_unlink_rest(fspace, cls, *node) < 0)
- HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, "can't remove section from non-size tracking data structures")
+ if (H5FS_sect_unlink_rest(fspace, cls, *node) < 0)
+ HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL,
+ "can't remove section from non-size tracking data structures")
/*
* The split() callback splits NODE into 2 sections:
@@ -1704,8 +1722,9 @@ HDfprintf(stderr, "%s: bin = %u\n", FUNC, bin);
*/
if (mis_align) {
split_sect = cls->split(*node, frag_size);
- if((H5FS_sect_link(fspace, split_sect, 0) < 0))
- HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "can't insert free space section into skip list")
+ if ((H5FS_sect_link(fspace, split_sect, 0) < 0))
+ HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL,
+ "can't insert free space section into skip list")
/* sanity check */
HDassert(split_sect->addr < (*node)->addr);
HDassert(request <= (*node)->size);
@@ -1721,17 +1740,16 @@ HDfprintf(stderr, "%s: bin = %u\n", FUNC, bin);
/* Get the next size node in the bin */
curr_size_node = H5SL_next(curr_size_node);
} /* end while of curr_size_node */
- } /* else of alignment */
- } /* if bin_list */
- /* Advance to next larger bin */
+ } /* else of alignment */
+ } /* if bin_list */
+ /* Advance to next larger bin */
bin++;
- } while(bin < fspace->sinfo->nbins);
+ } while (bin < fspace->sinfo->nbins);
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5FS_sect_find_node() */
-
/*-------------------------------------------------------------------------
* Function: H5FS_sect_find
*
@@ -1752,17 +1770,16 @@ done:
*-------------------------------------------------------------------------
*/
htri_t
-H5FS_sect_find(H5F_t *f, hid_t dxpl_id, H5FS_t *fspace, hsize_t request,
- H5FS_section_info_t **node)
+H5FS_sect_find(H5F_t *f, hid_t dxpl_id, H5FS_t *fspace, hsize_t request, H5FS_section_info_t **node)
{
- hbool_t sinfo_valid = FALSE; /* Whether the section info is valid */
- hbool_t sinfo_modified = FALSE; /* Whether the section info was modified */
- htri_t ret_value = FALSE; /* Return value */
+ hbool_t sinfo_valid = FALSE; /* Whether the section info is valid */
+ hbool_t sinfo_modified = FALSE; /* Whether the section info was modified */
+ htri_t ret_value = FALSE; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
#ifdef QAK
-HDfprintf(stderr, "%s: request = %Hu\n", FUNC, request);
+ HDfprintf(stderr, "%s: request = %Hu\n", FUNC, request);
#endif /* QAK */
/* Check arguments. */
@@ -1773,33 +1790,34 @@ HDfprintf(stderr, "%s: request = %Hu\n", FUNC, request);
/* Check for any sections on free space list */
#ifdef QAK
-HDfprintf(stderr, "%s: fspace->tot_sect_count = %Hu\n", FUNC, fspace->tot_sect_count);
-HDfprintf(stderr, "%s: fspace->serial_sect_count = %Hu\n", FUNC, fspace->serial_sect_count);
-HDfprintf(stderr, "%s: fspace->ghost_sect_count = %Hu\n", FUNC, fspace->ghost_sect_count);
+ HDfprintf(stderr, "%s: fspace->tot_sect_count = %Hu\n", FUNC, fspace->tot_sect_count);
+ HDfprintf(stderr, "%s: fspace->serial_sect_count = %Hu\n", FUNC, fspace->serial_sect_count);
+ HDfprintf(stderr, "%s: fspace->ghost_sect_count = %Hu\n", FUNC, fspace->ghost_sect_count);
#endif /* QAK */
- if(fspace->tot_sect_count > 0) {
+ if (fspace->tot_sect_count > 0) {
/* Get a pointer to the section info */
- if(H5FS_sinfo_lock(f, dxpl_id, fspace, H5AC_WRITE) < 0)
+ if (H5FS_sinfo_lock(f, dxpl_id, fspace, H5AC_WRITE) < 0)
HGOTO_ERROR(H5E_FSPACE, H5E_CANTGET, FAIL, "can't get section info")
sinfo_valid = TRUE;
/* Look for node in bins */
- if((ret_value = H5FS_sect_find_node(fspace, request, node)) < 0)
+ if ((ret_value = H5FS_sect_find_node(fspace, request, node)) < 0)
HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, "can't remove section from bins")
/* Decrement # of sections on free list, if we found an object */
- if(ret_value > 0) {
+ if (ret_value > 0) {
/* Note that we've modified the section info */
sinfo_modified = TRUE;
#ifdef QAK
-HDfprintf(stderr, "%s: (*node)->size = %Hu, (*node)->addr = %a, (*node)->type = %u\n", FUNC, (*node)->size, (*node)->addr, (*node)->type);
+ HDfprintf(stderr, "%s: (*node)->size = %Hu, (*node)->addr = %a, (*node)->type = %u\n", FUNC,
+ (*node)->size, (*node)->addr, (*node)->type);
#endif /* QAK */
- }
+ }
} /* end if */
done:
/* Release the section info */
- if(sinfo_valid && H5FS_sinfo_unlock(f, dxpl_id, fspace, sinfo_modified) < 0)
+ if (sinfo_valid && H5FS_sinfo_unlock(f, dxpl_id, fspace, sinfo_modified) < 0)
HDONE_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, "can't release section info")
#ifdef H5FS_DEBUG_ASSERT
@@ -1808,7 +1826,6 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5FS_sect_find() */
-
/*-------------------------------------------------------------------------
* Function: H5FS_iterate_sect_cb
*
@@ -1827,9 +1844,9 @@ done:
static herr_t
H5FS_iterate_sect_cb(void *_item, void H5_ATTR_UNUSED *key, void *_udata)
{
- H5FS_section_info_t *sect_info = (H5FS_section_info_t *)_item; /* Free space section to work on */
- H5FS_iter_ud_t *udata = (H5FS_iter_ud_t *)_udata; /* Callback info */
- herr_t ret_value = SUCCEED; /* Return value */
+ H5FS_section_info_t *sect_info = (H5FS_section_info_t *)_item; /* Free space section to work on */
+ H5FS_iter_ud_t * udata = (H5FS_iter_ud_t *)_udata; /* Callback info */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
@@ -1839,14 +1856,13 @@ H5FS_iterate_sect_cb(void *_item, void H5_ATTR_UNUSED *key, void *_udata)
HDassert(udata->op);
/* Make callback for this section */
- if((*udata->op)(sect_info, udata->op_data) < 0)
+ if ((*udata->op)(sect_info, udata->op_data) < 0)
HGOTO_ERROR(H5E_FSPACE, H5E_BADITER, FAIL, "iteration callback failed")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5FS_iterate_sect_cb() */
-
/*-------------------------------------------------------------------------
* Function: H5FS_iterate_node_cb
*
@@ -1865,9 +1881,9 @@ done:
static herr_t
H5FS_iterate_node_cb(void *_item, void H5_ATTR_UNUSED *key, void *_udata)
{
- H5FS_node_t *fspace_node = (H5FS_node_t *)_item; /* Free space size node to work on */
- H5FS_iter_ud_t *udata = (H5FS_iter_ud_t *)_udata; /* Callback info */
- herr_t ret_value = SUCCEED; /* Return value */
+ H5FS_node_t * fspace_node = (H5FS_node_t *)_item; /* Free space size node to work on */
+ H5FS_iter_ud_t *udata = (H5FS_iter_ud_t *)_udata; /* Callback info */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
@@ -1878,14 +1894,13 @@ H5FS_iterate_node_cb(void *_item, void H5_ATTR_UNUSED *key, void *_udata)
/* Iterate through all the sections of this size */
HDassert(fspace_node->sect_list);
- if(H5SL_iterate(fspace_node->sect_list, H5FS_iterate_sect_cb, udata) < 0)
+ if (H5SL_iterate(fspace_node->sect_list, H5FS_iterate_sect_cb, udata) < 0)
HGOTO_ERROR(H5E_FSPACE, H5E_BADITER, FAIL, "can't iterate over section nodes")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5FS_iterate_node_cb() */
-
/*-------------------------------------------------------------------------
* Function: H5FS_sect_iterate
*
@@ -1903,9 +1918,9 @@ done:
herr_t
H5FS_sect_iterate(H5F_t *f, hid_t dxpl_id, H5FS_t *fspace, H5FS_operator_t op, void *op_data)
{
- H5FS_iter_ud_t udata; /* User data for callbacks */
- hbool_t sinfo_valid = FALSE; /* Whether the section info is valid */
- herr_t ret_value = SUCCEED; /* Return value */
+ H5FS_iter_ud_t udata; /* User data for callbacks */
+ hbool_t sinfo_valid = FALSE; /* Whether the section info is valid */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
@@ -1914,46 +1929,45 @@ H5FS_sect_iterate(H5F_t *f, hid_t dxpl_id, H5FS_t *fspace, H5FS_operator_t op, v
HDassert(op);
#ifdef QAK
-HDfprintf(stderr, "%s: fspace->tot_sect_count = %Hu\n", FUNC, fspace->tot_sect_count);
+ HDfprintf(stderr, "%s: fspace->tot_sect_count = %Hu\n", FUNC, fspace->tot_sect_count);
#endif /* QAK */
/* Set up user data for iterator */
- udata.fspace = fspace;
- udata.op = op;
+ udata.fspace = fspace;
+ udata.op = op;
udata.op_data = op_data;
/* Iterate over sections, if there are any */
- if(fspace->tot_sect_count) {
- unsigned bin; /* Current bin we are on */
+ if (fspace->tot_sect_count) {
+ unsigned bin; /* Current bin we are on */
/* Get a pointer to the section info */
- if(H5FS_sinfo_lock(f, dxpl_id, fspace, H5AC_READ) < 0)
+ if (H5FS_sinfo_lock(f, dxpl_id, fspace, H5AC_READ) < 0)
HGOTO_ERROR(H5E_FSPACE, H5E_CANTGET, FAIL, "can't get section info")
sinfo_valid = TRUE;
/* Iterate over all the bins */
#ifdef QAK
-HDfprintf(stderr, "%s: Iterate over section bins\n", FUNC);
+ HDfprintf(stderr, "%s: Iterate over section bins\n", FUNC);
#endif /* QAK */
- for(bin = 0; bin < fspace->sinfo->nbins; bin++) {
+ for (bin = 0; bin < fspace->sinfo->nbins; bin++) {
/* Check if there are any sections in this bin */
- if(fspace->sinfo->bins[bin].bin_list) {
+ if (fspace->sinfo->bins[bin].bin_list) {
/* Iterate over list of section size nodes for bin */
- if(H5SL_iterate(fspace->sinfo->bins[bin].bin_list, H5FS_iterate_node_cb, &udata) < 0)
+ if (H5SL_iterate(fspace->sinfo->bins[bin].bin_list, H5FS_iterate_node_cb, &udata) < 0)
HGOTO_ERROR(H5E_FSPACE, H5E_BADITER, FAIL, "can't iterate over section size nodes")
} /* end if */
- } /* end for */
- } /* end if */
+ } /* end for */
+ } /* end if */
done:
/* Release the section info */
- if(sinfo_valid && H5FS_sinfo_unlock(f, dxpl_id, fspace, FALSE) < 0)
+ if (sinfo_valid && H5FS_sinfo_unlock(f, dxpl_id, fspace, FALSE) < 0)
HDONE_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, "can't release section info")
FUNC_LEAVE_NOAPI(ret_value)
} /* H5FS_sect_iterate() */
-
/*-------------------------------------------------------------------------
* Function: H5FS_sect_stats
*
@@ -1976,15 +1990,14 @@ H5FS_sect_stats(const H5FS_t *fspace, hsize_t *tot_space, hsize_t *nsects)
HDassert(fspace);
/* Get the stats desired */
- if(tot_space)
+ if (tot_space)
*tot_space = fspace->tot_space;
- if(nsects)
+ if (nsects)
*nsects = fspace->tot_sect_count;
FUNC_LEAVE_NOAPI(SUCCEED)
} /* H5FS_sect_stats() */
-
/*-------------------------------------------------------------------------
* Function: H5FS_sect_change_class
*
@@ -2001,14 +2014,13 @@ H5FS_sect_stats(const H5FS_t *fspace, hsize_t *tot_space, hsize_t *nsects)
*-------------------------------------------------------------------------
*/
herr_t
-H5FS_sect_change_class(H5F_t *f, hid_t dxpl_id, H5FS_t *fspace,
- H5FS_section_info_t *sect, unsigned new_class)
+H5FS_sect_change_class(H5F_t *f, hid_t dxpl_id, H5FS_t *fspace, H5FS_section_info_t *sect, unsigned new_class)
{
- const H5FS_section_class_t *old_cls; /* Old class of section */
- const H5FS_section_class_t *new_cls; /* New class of section */
- unsigned old_class; /* Old class ID of section */
- hbool_t sinfo_valid = FALSE; /* Whether the section info is valid */
- herr_t ret_value = SUCCEED; /* Return value */
+ const H5FS_section_class_t *old_cls; /* Old class of section */
+ const H5FS_section_class_t *new_cls; /* New class of section */
+ unsigned old_class; /* Old class ID of section */
+ hbool_t sinfo_valid = FALSE; /* Whether the section info is valid */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
@@ -2019,32 +2031,32 @@ H5FS_sect_change_class(H5F_t *f, hid_t dxpl_id, H5FS_t *fspace,
HDassert(new_class < fspace->nclasses);
/* Get a pointer to the section info */
- if(H5FS_sinfo_lock(f, dxpl_id, fspace, H5AC_WRITE) < 0)
+ if (H5FS_sinfo_lock(f, dxpl_id, fspace, H5AC_WRITE) < 0)
HGOTO_ERROR(H5E_FSPACE, H5E_CANTGET, FAIL, "can't get section info")
sinfo_valid = TRUE;
/* Get class info */
old_class = sect->type;
- old_cls = &fspace->sect_cls[sect->type];
- new_cls = &fspace->sect_cls[new_class];
+ old_cls = &fspace->sect_cls[sect->type];
+ new_cls = &fspace->sect_cls[new_class];
#ifdef QAK
-HDfprintf(stderr, "%s: old_cls->flags = %x\n", FUNC, old_cls->flags);
-HDfprintf(stderr, "%s: new_cls->flags = %x\n", FUNC, new_cls->flags);
+ HDfprintf(stderr, "%s: old_cls->flags = %x\n", FUNC, old_cls->flags);
+ HDfprintf(stderr, "%s: new_cls->flags = %x\n", FUNC, new_cls->flags);
#endif /* QAK */
/* Check if the section's class change will affect the # of serializable or ghost sections */
- if((old_cls->flags & H5FS_CLS_GHOST_OBJ) != (new_cls->flags & H5FS_CLS_GHOST_OBJ)) {
- H5FS_node_t *fspace_node; /* Free list size node */
- unsigned bin; /* Bin to put the free space section in */
- hbool_t to_ghost; /* Flag if the section is changing to a ghost section */
+ if ((old_cls->flags & H5FS_CLS_GHOST_OBJ) != (new_cls->flags & H5FS_CLS_GHOST_OBJ)) {
+ H5FS_node_t *fspace_node; /* Free list size node */
+ unsigned bin; /* Bin to put the free space section in */
+ hbool_t to_ghost; /* Flag if the section is changing to a ghost section */
/* Determine if this section is becoming a ghost or is becoming serializable */
- if(old_cls->flags & H5FS_CLS_GHOST_OBJ)
+ if (old_cls->flags & H5FS_CLS_GHOST_OBJ)
to_ghost = FALSE;
else
to_ghost = TRUE;
#ifdef QAK
-HDfprintf(stderr, "%s: to_ghost = %u\n", FUNC, to_ghost);
+ HDfprintf(stderr, "%s: to_ghost = %u\n", FUNC, to_ghost);
#endif /* QAK */
/* Sanity check */
@@ -2060,7 +2072,7 @@ HDfprintf(stderr, "%s: to_ghost = %u\n", FUNC, to_ghost);
HDassert(fspace_node);
/* Adjust serializable/ghost counts */
- if(to_ghost) {
+ if (to_ghost) {
/* Adjust global section count totals */
fspace->serial_sect_count--;
fspace->ghost_sect_count++;
@@ -2074,9 +2086,9 @@ HDfprintf(stderr, "%s: to_ghost = %u\n", FUNC, to_ghost);
fspace_node->ghost_count++;
/* Check if we switched a section size node's status */
- if(fspace_node->serial_count == 0)
+ if (fspace_node->serial_count == 0)
fspace->sinfo->serial_size_count--;
- if(fspace_node->ghost_count == 1)
+ if (fspace_node->ghost_count == 1)
fspace->sinfo->ghost_size_count++;
} /* end if */
else {
@@ -2093,48 +2105,52 @@ HDfprintf(stderr, "%s: to_ghost = %u\n", FUNC, to_ghost);
fspace_node->ghost_count--;
/* Check if we switched a section size node's status */
- if(fspace_node->serial_count == 1)
+ if (fspace_node->serial_count == 1)
fspace->sinfo->serial_size_count++;
- if(fspace_node->ghost_count == 0)
+ if (fspace_node->ghost_count == 0)
fspace->sinfo->ghost_size_count--;
} /* end else */
- } /* end if */
+ } /* end if */
/* Check if the section's class change will affect the mergable list */
- if((old_cls->flags & H5FS_CLS_SEPAR_OBJ) != (new_cls->flags & H5FS_CLS_SEPAR_OBJ)) {
- hbool_t to_mergable; /* Flag if the section is changing to a mergable section */
+ if ((old_cls->flags & H5FS_CLS_SEPAR_OBJ) != (new_cls->flags & H5FS_CLS_SEPAR_OBJ)) {
+ hbool_t to_mergable; /* Flag if the section is changing to a mergable section */
/* Determine if this section is becoming mergable or is becoming separate */
- if(old_cls->flags & H5FS_CLS_SEPAR_OBJ)
+ if (old_cls->flags & H5FS_CLS_SEPAR_OBJ)
to_mergable = TRUE;
else
to_mergable = FALSE;
#ifdef QAK
-HDfprintf(stderr, "%s: to_mergable = %u\n", FUNC, to_mergable);
+ HDfprintf(stderr, "%s: to_mergable = %u\n", FUNC, to_mergable);
#endif /* QAK */
/* Add or remove section from merge list, as appropriate */
- if(to_mergable) {
+ if (to_mergable) {
#ifdef QAK
-HDfprintf(stderr, "%s: inserting object into merge list, sect->type = %u\n", FUNC, (unsigned)sect->type);
+ HDfprintf(stderr, "%s: inserting object into merge list, sect->type = %u\n", FUNC,
+ (unsigned)sect->type);
#endif /* QAK */
- if(fspace->sinfo->merge_list == NULL)
- if(NULL == (fspace->sinfo->merge_list = H5SL_create(H5SL_TYPE_HADDR, NULL)))
- HGOTO_ERROR(H5E_FSPACE, H5E_CANTCREATE, FAIL, "can't create skip list for merging free space sections")
- if(H5SL_insert(fspace->sinfo->merge_list, sect, &sect->addr) < 0)
- HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "can't insert free space node into merging skip list")
+ if (fspace->sinfo->merge_list == NULL)
+ if (NULL == (fspace->sinfo->merge_list = H5SL_create(H5SL_TYPE_HADDR, NULL)))
+ HGOTO_ERROR(H5E_FSPACE, H5E_CANTCREATE, FAIL,
+ "can't create skip list for merging free space sections")
+ if (H5SL_insert(fspace->sinfo->merge_list, sect, &sect->addr) < 0)
+ HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL,
+ "can't insert free space node into merging skip list")
} /* end if */
else {
H5FS_section_info_t *tmp_sect_node; /* Temporary section node */
#ifdef QAK
-HDfprintf(stderr, "%s: removing object from merge list, sect->type = %u\n", FUNC, (unsigned)sect->type);
+ HDfprintf(stderr, "%s: removing object from merge list, sect->type = %u\n", FUNC,
+ (unsigned)sect->type);
#endif /* QAK */
tmp_sect_node = (H5FS_section_info_t *)H5SL_remove(fspace->sinfo->merge_list, &sect->addr);
- if(tmp_sect_node == NULL || tmp_sect_node != sect)
+ if (tmp_sect_node == NULL || tmp_sect_node != sect)
HGOTO_ERROR(H5E_FSPACE, H5E_NOTFOUND, FAIL, "can't find section node on size list")
} /* end else */
- } /* end if */
+ } /* end if */
/* Change the section's class */
sect->type = new_class;
@@ -2144,19 +2160,19 @@ HDfprintf(stderr, "%s: removing object from merge list, sect->type = %u\n", FUNC
fspace->sinfo->serial_size += fspace->sect_cls[new_class].serial_size;
/* Update current space used for free space sections */
- if(H5FS_sect_serialize_size(fspace) < 0)
+ if (H5FS_sect_serialize_size(fspace) < 0)
HGOTO_ERROR(H5E_FSPACE, H5E_CANTCOMPUTE, FAIL, "can't adjust free space section size on disk")
done:
/* Release the section info */
- if(sinfo_valid && H5FS_sinfo_unlock(f, dxpl_id, fspace, TRUE) < 0)
+ if (sinfo_valid && H5FS_sinfo_unlock(f, dxpl_id, fspace, TRUE) < 0)
HDONE_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, "can't release section info")
FUNC_LEAVE_NOAPI(ret_value)
} /* H5FS_sect_change_class() */
#ifdef H5FS_DEBUG_ASSERT
-
+
/*-------------------------------------------------------------------------
* Function: H5FS_sect_assert
*
@@ -2173,86 +2189,87 @@ done:
herr_t
H5FS_sect_assert(const H5FS_t *fspace)
{
- hsize_t separate_obj; /* The number of separate objects managed */
+ hsize_t separate_obj; /* The number of separate objects managed */
FUNC_ENTER_NOAPI_NOINIT_NOERR
#ifdef QAK
-HDfprintf(stderr, "%s: fspace->tot_sect_count = %Hu\n", "H5FS_sect_assert", fspace->tot_sect_count);
+ HDfprintf(stderr, "%s: fspace->tot_sect_count = %Hu\n", "H5FS_sect_assert", fspace->tot_sect_count);
#endif /* QAK */
/* Initialize state */
separate_obj = 0;
/* Check for bins to work on */
- if(fspace->sinfo->bins) {
- hsize_t acc_tot_sect_count; /* Accumulated total section count from bins */
- hsize_t acc_serial_sect_count; /* Accumulated serializable section count from bins */
- hsize_t acc_ghost_sect_count; /* Accumulated ghost section count from bins */
- size_t acc_tot_size_count; /* Accumulated total section size count from bins */
- size_t acc_serial_size_count; /* Accumulated serializable section size count from bins */
- size_t acc_ghost_size_count; /* Accumulated ghost section size count from bins */
- unsigned u; /* Local index variable */
+ if (fspace->sinfo->bins) {
+ hsize_t acc_tot_sect_count; /* Accumulated total section count from bins */
+ hsize_t acc_serial_sect_count; /* Accumulated serializable section count from bins */
+ hsize_t acc_ghost_sect_count; /* Accumulated ghost section count from bins */
+ size_t acc_tot_size_count; /* Accumulated total section size count from bins */
+ size_t acc_serial_size_count; /* Accumulated serializable section size count from bins */
+ size_t acc_ghost_size_count; /* Accumulated ghost section size count from bins */
+ unsigned u; /* Local index variable */
/* Walk through all sections in bins */
- acc_tot_sect_count = 0;
+ acc_tot_sect_count = 0;
acc_serial_sect_count = 0;
- acc_ghost_sect_count = 0;
- acc_tot_size_count = 0;
+ acc_ghost_sect_count = 0;
+ acc_tot_size_count = 0;
acc_serial_size_count = 0;
- acc_ghost_size_count = 0;
- for(u = 0; u < fspace->sinfo->nbins; u++) {
+ acc_ghost_size_count = 0;
+ for (u = 0; u < fspace->sinfo->nbins; u++) {
acc_tot_sect_count += fspace->sinfo->bins[u].tot_sect_count;
acc_serial_sect_count += fspace->sinfo->bins[u].serial_sect_count;
acc_ghost_sect_count += fspace->sinfo->bins[u].ghost_sect_count;
- if(fspace->sinfo->bins[u].bin_list) {
- H5SL_node_t *curr_size_node; /* Current section size node in skip list */
- size_t bin_serial_count; /* # of serializable sections in this bin */
- size_t bin_ghost_count; /* # of ghost sections in this bin */
+ if (fspace->sinfo->bins[u].bin_list) {
+ H5SL_node_t *curr_size_node; /* Current section size node in skip list */
+ size_t bin_serial_count; /* # of serializable sections in this bin */
+ size_t bin_ghost_count; /* # of ghost sections in this bin */
acc_tot_size_count += H5SL_count(fspace->sinfo->bins[u].bin_list);
/* Walk through the sections in this bin */
- curr_size_node = H5SL_first(fspace->sinfo->bins[u].bin_list);
+ curr_size_node = H5SL_first(fspace->sinfo->bins[u].bin_list);
bin_serial_count = 0;
- bin_ghost_count = 0;
- while(curr_size_node != NULL) {
+ bin_ghost_count = 0;
+ while (curr_size_node != NULL) {
H5FS_node_t *fspace_node; /* Section size node */
H5SL_node_t *curr_sect_node; /* Current section node in skip list */
- size_t size_serial_count; /* # of serializable sections of this size */
- size_t size_ghost_count; /* # of ghost sections of this size */
+ size_t size_serial_count; /* # of serializable sections of this size */
+ size_t size_ghost_count; /* # of ghost sections of this size */
/* Get section size node */
fspace_node = H5SL_item(curr_size_node);
/* Check sections on list */
- curr_sect_node = H5SL_first(fspace_node->sect_list);
+ curr_sect_node = H5SL_first(fspace_node->sect_list);
size_serial_count = 0;
- size_ghost_count = 0;
- while(curr_sect_node != NULL) {
- H5FS_section_class_t *cls; /* Class of section */
- H5FS_section_info_t *sect; /* Section */
+ size_ghost_count = 0;
+ while (curr_sect_node != NULL) {
+ H5FS_section_class_t *cls; /* Class of section */
+ H5FS_section_info_t * sect; /* Section */
/* Get section node & it's class */
sect = H5SL_item(curr_sect_node);
- cls = &fspace->sect_cls[sect->type];
+ cls = &fspace->sect_cls[sect->type];
#ifdef QAK
-HDfprintf(stderr, "%s: sect->size = %Hu, sect->addr = %a, sect->type = %u\n", "H5FS_assert", sect->size, sect->addr, sect->type);
+ HDfprintf(stderr, "%s: sect->size = %Hu, sect->addr = %a, sect->type = %u\n",
+ "H5FS_assert", sect->size, sect->addr, sect->type);
#endif /* QAK */
/* Sanity check section */
HDassert(H5F_addr_defined(sect->addr));
HDassert(fspace_node->sect_size == sect->size);
- if(cls->valid)
+ if (cls->valid)
(*cls->valid)(cls, sect);
/* Add to correct count */
- if(cls->flags & H5FS_CLS_GHOST_OBJ)
+ if (cls->flags & H5FS_CLS_GHOST_OBJ)
size_ghost_count++;
else
size_serial_count++;
/* Count node, if separate */
- if(cls->flags & H5FS_CLS_SEPAR_OBJ)
+ if (cls->flags & H5FS_CLS_SEPAR_OBJ)
separate_obj++;
/* Get the next section node in the list */
@@ -2264,9 +2281,9 @@ HDfprintf(stderr, "%s: sect->size = %Hu, sect->addr = %a, sect->type = %u\n", "H
HDassert(fspace_node->ghost_count == size_ghost_count);
/* Add to global count of serializable & ghost section sizes */
- if(fspace_node->serial_count > 0)
+ if (fspace_node->serial_count > 0)
acc_serial_size_count++;
- if(fspace_node->ghost_count > 0)
+ if (fspace_node->ghost_count > 0)
acc_ghost_size_count++;
/* Add to bin's serializable & ghost counts */
@@ -2282,7 +2299,7 @@ HDfprintf(stderr, "%s: sect->size = %Hu, sect->addr = %a, sect->type = %u\n", "H
HDassert(fspace->sinfo->bins[u].serial_sect_count == bin_serial_count);
HDassert(fspace->sinfo->bins[u].ghost_sect_count == bin_ghost_count);
} /* end if */
- } /* end for */
+ } /* end for */
/* Check counts from bins vs. global counts */
HDassert(fspace->sinfo->tot_size_count == acc_tot_size_count);
@@ -2300,14 +2317,13 @@ HDfprintf(stderr, "%s: sect->size = %Hu, sect->addr = %a, sect->type = %u\n", "H
} /* end else */
/* Make certain that the number of sections on the address list is correct */
- if(fspace->sinfo->merge_list)
+ if (fspace->sinfo->merge_list)
HDassert(fspace->tot_sect_count == (separate_obj + H5SL_count(fspace->sinfo->merge_list)));
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5FS_sect_assert() */
#endif /* H5FS_DEBUG_ASSERT */
-
/*-------------------------------------------------------------------------
* Function: H5FS_sect_try_shrink_eoa
*
@@ -2324,60 +2340,60 @@ HDfprintf(stderr, "%s: sect->size = %Hu, sect->addr = %a, sect->type = %u\n", "H
htri_t
H5FS_sect_try_shrink_eoa(const H5F_t *f, hid_t dxpl_id, const H5FS_t *fspace, void *op_data)
{
- hbool_t sinfo_valid = FALSE; /* Whether the section info is valid */
- hbool_t section_removed = FALSE; /* Whether a section was removed */
- htri_t ret_value = FALSE; /* Return value */
+ hbool_t sinfo_valid = FALSE; /* Whether the section info is valid */
+ hbool_t section_removed = FALSE; /* Whether a section was removed */
+ htri_t ret_value = FALSE; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
/* Check arguments. */
HDassert(fspace);
- if(H5FS_sinfo_lock(f, dxpl_id, fspace, H5AC_WRITE) < 0)
+ if (H5FS_sinfo_lock(f, dxpl_id, fspace, H5AC_WRITE) < 0)
HGOTO_ERROR(H5E_FSPACE, H5E_CANTGET, FAIL, "can't get section info")
sinfo_valid = TRUE;
- if(fspace->sinfo && fspace->sinfo->merge_list) {
- H5SL_node_t *last_node; /* Last node in merge list */
+ if (fspace->sinfo && fspace->sinfo->merge_list) {
+ H5SL_node_t *last_node; /* Last node in merge list */
/* Check for last node in the merge list */
- if(NULL != (last_node = H5SL_last(fspace->sinfo->merge_list))) {
- H5FS_section_info_t *tmp_sect; /* Temporary free space section */
- H5FS_section_class_t *tmp_sect_cls; /* Temporary section's class */
+ if (NULL != (last_node = H5SL_last(fspace->sinfo->merge_list))) {
+ H5FS_section_info_t * tmp_sect; /* Temporary free space section */
+ H5FS_section_class_t *tmp_sect_cls; /* Temporary section's class */
/* Get the pointer to the last section, from the last node */
tmp_sect = (H5FS_section_info_t *)H5SL_item(last_node);
HDassert(tmp_sect);
- tmp_sect_cls = &fspace->sect_cls[tmp_sect->type];
- if(tmp_sect_cls->can_shrink) {
+ tmp_sect_cls = &fspace->sect_cls[tmp_sect->type];
+ if (tmp_sect_cls->can_shrink) {
/* Check if the section can be shrunk away */
- if((ret_value = (*tmp_sect_cls->can_shrink)(tmp_sect, op_data)) < 0)
- HGOTO_ERROR(H5E_FSPACE, H5E_CANTSHRINK, FAIL, "can't check for shrinking container")
- if(ret_value > 0) {
- HDassert(tmp_sect_cls->shrink);
+ if ((ret_value = (*tmp_sect_cls->can_shrink)(tmp_sect, op_data)) < 0)
+ HGOTO_ERROR(H5E_FSPACE, H5E_CANTSHRINK, FAIL, "can't check for shrinking container")
+ if (ret_value > 0) {
+ HDassert(tmp_sect_cls->shrink);
/* Remove section from free space manager */
- if(H5FS_sect_remove_real(fspace, tmp_sect) < 0)
- HGOTO_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, "can't remove section from internal data structures")
+ if (H5FS_sect_remove_real(fspace, tmp_sect) < 0)
+ HGOTO_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL,
+ "can't remove section from internal data structures")
section_removed = TRUE;
/* Shrink away section */
- if((*tmp_sect_cls->shrink)(&tmp_sect, op_data) < 0)
- HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "can't shrink free space container")
- } /* end if */
- } /* end if */
- } /* end if */
- } /* end if */
+ if ((*tmp_sect_cls->shrink)(&tmp_sect, op_data) < 0)
+ HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "can't shrink free space container")
+ } /* end if */
+ } /* end if */
+ } /* end if */
+ } /* end if */
done:
/* Release the section info */
- if(sinfo_valid && H5FS_sinfo_unlock(f, dxpl_id, fspace, section_removed) < 0)
+ if (sinfo_valid && H5FS_sinfo_unlock(f, dxpl_id, fspace, section_removed) < 0)
HDONE_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, "can't release section info")
FUNC_LEAVE_NOAPI(ret_value)
} /* H5FS_sect_try_shrink_eoa() */
-
/*-------------------------------------------------------------------------
* Function: H5FS_sect_query_last_sect
*
@@ -2398,23 +2414,22 @@ H5FS_sect_query_last_sect(const H5FS_t *fspace, haddr_t *sect_addr, hsize_t *sec
/* Check arguments. */
HDassert(fspace);
- if(fspace->sinfo && fspace->sinfo->merge_list) {
- H5SL_node_t *last_node; /* Last node in merge list */
+ if (fspace->sinfo && fspace->sinfo->merge_list) {
+ H5SL_node_t *last_node; /* Last node in merge list */
/* Check for last node in the merge list */
- if(NULL != (last_node = H5SL_last(fspace->sinfo->merge_list))) {
- H5FS_section_info_t *tmp_sect; /* Temporary free space section */
+ if (NULL != (last_node = H5SL_last(fspace->sinfo->merge_list))) {
+ H5FS_section_info_t *tmp_sect; /* Temporary free space section */
/* Get the pointer to the last section, from the last node */
tmp_sect = (H5FS_section_info_t *)H5SL_item(last_node);
HDassert(tmp_sect);
- if(sect_addr)
+ if (sect_addr)
*sect_addr = tmp_sect->addr;
- if(sect_size)
+ if (sect_size)
*sect_size = tmp_sect->size;
- } /* end if */
- } /* end if */
+ } /* end if */
+ } /* end if */
FUNC_LEAVE_NOAPI(SUCCEED)
} /* H5FS_sect_query_last_sect() */
-