summaryrefslogtreecommitdiffstats
path: root/src/H5FScache.c
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2020-10-01 14:04:36 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2020-10-01 14:04:36 (GMT)
commitf1ba03cea5b82699a984c80bd2deac14fdc8df18 (patch)
treeebe777c3e0b83f4c4cec9212731da9ebe0a0cfd3 /src/H5FScache.c
parent10343c197906415388f2a4c8d292e21d25cf7381 (diff)
downloadhdf5-f1ba03cea5b82699a984c80bd2deac14fdc8df18.zip
hdf5-f1ba03cea5b82699a984c80bd2deac14fdc8df18.tar.gz
hdf5-f1ba03cea5b82699a984c80bd2deac14fdc8df18.tar.bz2
Source formatted
Diffstat (limited to 'src/H5FScache.c')
-rw-r--r--src/H5FScache.c524
1 files changed, 251 insertions, 273 deletions
diff --git a/src/H5FScache.c b/src/H5FScache.c
index 4c75fb1..bf91e22 100644
--- a/src/H5FScache.c
+++ b/src/H5FScache.c
@@ -26,31 +26,28 @@
/* Module Setup */
/****************/
-#include "H5FSmodule.h" /* This source code file is part of the H5FS module */
-
+#include "H5FSmodule.h" /* This source code file is part of the H5FS module */
/***********/
/* Headers */
/***********/
-#include "H5private.h" /* Generic Functions */
-#include "H5ACprivate.h" /* Metadata cache */
-#include "H5Eprivate.h" /* Error handling */
-#include "H5Fprivate.h" /* File */
-#include "H5FSpkg.h" /* File free space */
-#include "H5MFprivate.h" /* File memory management */
-#include "H5MMprivate.h" /* Memory management */
-#include "H5VMprivate.h" /* Vectors and arrays */
-#include "H5WBprivate.h" /* Wrapped Buffers */
-
+#include "H5private.h" /* Generic Functions */
+#include "H5ACprivate.h" /* Metadata cache */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5Fprivate.h" /* File */
+#include "H5FSpkg.h" /* File free space */
+#include "H5MFprivate.h" /* File memory management */
+#include "H5MMprivate.h" /* Memory management */
+#include "H5VMprivate.h" /* Vectors and arrays */
+#include "H5WBprivate.h" /* Wrapped Buffers */
/****************/
/* Local Macros */
/****************/
/* File free space format version #'s */
-#define H5FS_HDR_VERSION 0 /* Header */
-#define H5FS_SINFO_VERSION 0 /* Serialized sections */
-
+#define H5FS_HDR_VERSION 0 /* Header */
+#define H5FS_SINFO_VERSION 0 /* Serialized sections */
/******************/
/* Local Typedefs */
@@ -58,17 +55,15 @@
/* User data for skip list iterator callback for iterating over section size nodes when syncing */
typedef struct {
- H5FS_sinfo_t *sinfo; /* Free space section info */
- uint8_t **image; /* Pointer to address of buffer pointer to serialize with */
- unsigned sect_cnt_size; /* # of bytes to encode section size counts in */
+ H5FS_sinfo_t *sinfo; /* Free space section info */
+ uint8_t ** image; /* Pointer to address of buffer pointer to serialize with */
+ unsigned sect_cnt_size; /* # of bytes to encode section size counts in */
} H5FS_iter_ud_t;
-
/********************/
/* Package Typedefs */
/********************/
-
/********************/
/* Local Prototypes */
/********************/
@@ -80,81 +75,72 @@ static herr_t H5FS__sinfo_serialize_node_cb(void *_item, void H5_ATTR_UNUSED *ke
/* Metadata cache callbacks */
static herr_t H5FS__cache_hdr_get_initial_load_size(void *udata, size_t *image_len);
static htri_t H5FS__cache_hdr_verify_chksum(const void *image_ptr, size_t len, void *udata_ptr);
-static void *H5FS__cache_hdr_deserialize(const void *image, size_t len,
- void *udata, hbool_t *dirty);
+static void * H5FS__cache_hdr_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty);
static herr_t H5FS__cache_hdr_image_len(const void *thing, size_t *image_len);
-static herr_t H5FS__cache_hdr_pre_serialize(H5F_t *f, void *thing, haddr_t addr,
- size_t len, haddr_t *new_addr, size_t *new_len, unsigned *flags);
-static herr_t H5FS__cache_hdr_serialize(const H5F_t *f, void *image,
- size_t len, void *thing);
+static herr_t H5FS__cache_hdr_pre_serialize(H5F_t *f, void *thing, haddr_t addr, size_t len,
+ haddr_t *new_addr, size_t *new_len, unsigned *flags);
+static herr_t H5FS__cache_hdr_serialize(const H5F_t *f, void *image, size_t len, void *thing);
static herr_t H5FS__cache_hdr_notify(H5AC_notify_action_t action, void *thing);
static herr_t H5FS__cache_hdr_free_icr(void *thing);
static herr_t H5FS__cache_sinfo_get_initial_load_size(void *udata, size_t *image_len);
static htri_t H5FS__cache_sinfo_verify_chksum(const void *image_ptr, size_t len, void *udata_ptr);
-static void *H5FS__cache_sinfo_deserialize(const void *image, size_t len,
- void *udata, hbool_t *dirty);
+static void * H5FS__cache_sinfo_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty);
static herr_t H5FS__cache_sinfo_image_len(const void *thing, size_t *image_len);
-static herr_t H5FS__cache_sinfo_pre_serialize(H5F_t *f, void *thing,
- haddr_t addr, size_t len, haddr_t *new_addr, size_t *new_len, unsigned *flags);
-static herr_t H5FS__cache_sinfo_serialize(const H5F_t *f, void *image,
- size_t len, void *thing);
+static herr_t H5FS__cache_sinfo_pre_serialize(H5F_t *f, void *thing, haddr_t addr, size_t len,
+ haddr_t *new_addr, size_t *new_len, unsigned *flags);
+static herr_t H5FS__cache_sinfo_serialize(const H5F_t *f, void *image, size_t len, void *thing);
static herr_t H5FS__cache_sinfo_notify(H5AC_notify_action_t action, void *thing);
static herr_t H5FS__cache_sinfo_free_icr(void *thing);
-
/*********************/
/* Package Variables */
/*********************/
/* H5FS header inherits cache-like properties from H5AC */
const H5AC_class_t H5AC_FSPACE_HDR[1] = {{
- H5AC_FSPACE_HDR_ID, /* Metadata client ID */
- "Free Space Header", /* Metadata client name (for debugging) */
- H5FD_MEM_FSPACE_HDR, /* File space memory type for client */
- H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */
- H5FS__cache_hdr_get_initial_load_size, /* 'get_initial_load_size' callback */
- NULL, /* 'get_final_load_size' callback */
- H5FS__cache_hdr_verify_chksum, /* 'verify_chksum' callback */
- H5FS__cache_hdr_deserialize, /* 'deserialize' callback */
- H5FS__cache_hdr_image_len, /* 'image_len' callback */
- H5FS__cache_hdr_pre_serialize, /* 'pre_serialize' callback */
- H5FS__cache_hdr_serialize, /* 'serialize' callback */
- H5FS__cache_hdr_notify, /* 'notify' callback */
- H5FS__cache_hdr_free_icr, /* 'free_icr' callback */
- NULL, /* 'fsf_size' callback */
+ H5AC_FSPACE_HDR_ID, /* Metadata client ID */
+ "Free Space Header", /* Metadata client name (for debugging) */
+ H5FD_MEM_FSPACE_HDR, /* File space memory type for client */
+ H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */
+ H5FS__cache_hdr_get_initial_load_size, /* 'get_initial_load_size' callback */
+ NULL, /* 'get_final_load_size' callback */
+ H5FS__cache_hdr_verify_chksum, /* 'verify_chksum' callback */
+ H5FS__cache_hdr_deserialize, /* 'deserialize' callback */
+ H5FS__cache_hdr_image_len, /* 'image_len' callback */
+ H5FS__cache_hdr_pre_serialize, /* 'pre_serialize' callback */
+ H5FS__cache_hdr_serialize, /* 'serialize' callback */
+ H5FS__cache_hdr_notify, /* 'notify' callback */
+ H5FS__cache_hdr_free_icr, /* 'free_icr' callback */
+ NULL, /* 'fsf_size' callback */
}};
/* H5FS section info inherits cache-like properties from H5AC */
const H5AC_class_t H5AC_FSPACE_SINFO[1] = {{
- H5AC_FSPACE_SINFO_ID, /* Metadata client ID */
- "Free Space Section Info", /* Metadata client name (for debugging) */
- H5FD_MEM_FSPACE_SINFO, /* File space memory type for client */
- H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */
- H5FS__cache_sinfo_get_initial_load_size, /* 'get_initial_load_size' callback */
- NULL, /* 'get_final_load_size' callback */
- H5FS__cache_sinfo_verify_chksum, /* 'verify_chksum' callback */
- H5FS__cache_sinfo_deserialize, /* 'deserialize' callback */
- H5FS__cache_sinfo_image_len, /* 'image_len' callback */
- H5FS__cache_sinfo_pre_serialize, /* 'pre_serialize' callback */
- H5FS__cache_sinfo_serialize, /* 'serialize' callback */
- H5FS__cache_sinfo_notify, /* 'notify' callback */
- H5FS__cache_sinfo_free_icr, /* 'free_icr' callback */
- NULL, /* 'fsf_size' callback */
+ H5AC_FSPACE_SINFO_ID, /* Metadata client ID */
+ "Free Space Section Info", /* Metadata client name (for debugging) */
+ H5FD_MEM_FSPACE_SINFO, /* File space memory type for client */
+ H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */
+ H5FS__cache_sinfo_get_initial_load_size, /* 'get_initial_load_size' callback */
+ NULL, /* 'get_final_load_size' callback */
+ H5FS__cache_sinfo_verify_chksum, /* 'verify_chksum' callback */
+ H5FS__cache_sinfo_deserialize, /* 'deserialize' callback */
+ H5FS__cache_sinfo_image_len, /* 'image_len' callback */
+ H5FS__cache_sinfo_pre_serialize, /* 'pre_serialize' callback */
+ H5FS__cache_sinfo_serialize, /* 'serialize' callback */
+ H5FS__cache_sinfo_notify, /* 'notify' callback */
+ H5FS__cache_sinfo_free_icr, /* 'free_icr' callback */
+ NULL, /* 'fsf_size' callback */
}};
-
/*****************************/
/* Library Private Variables */
/*****************************/
-
/*******************/
/* Local Variables */
/*******************/
-
-
/*-------------------------------------------------------------------------
* Function: H5FS__cache_hdr_get_initial_load_size
*
@@ -185,7 +171,6 @@ H5FS__cache_hdr_get_initial_load_size(void *_udata, size_t *image_len)
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5FS__cache_hdr_get_initial_load_size() */
-
/*-------------------------------------------------------------------------
* Function: H5FS__cache_hdr_verify_chksum
*
@@ -202,10 +187,10 @@ H5FS__cache_hdr_get_initial_load_size(void *_udata, size_t *image_len)
htri_t
H5FS__cache_hdr_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata)
{
- const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */
- uint32_t stored_chksum; /* Stored metadata checksum value */
- uint32_t computed_chksum; /* Computed metadata checksum value */
- htri_t ret_value = TRUE; /* Return value */
+ const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */
+ uint32_t stored_chksum; /* Stored metadata checksum value */
+ uint32_t computed_chksum; /* Computed metadata checksum value */
+ htri_t ret_value = TRUE; /* Return value */
FUNC_ENTER_STATIC_NOERR
@@ -215,13 +200,12 @@ H5FS__cache_hdr_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSE
/* Get stored and computed checksums */
H5F_get_checksums(image, len, &stored_chksum, &computed_chksum);
- if(stored_chksum != computed_chksum)
+ if (stored_chksum != computed_chksum)
ret_value = FALSE;
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FS__cache_hdr_verify_chksum() */
-
/*-------------------------------------------------------------------------
* Function: H5FS__cache_hdr_deserialize
*
@@ -240,14 +224,14 @@ H5FS__cache_hdr_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSE
*/
static void *
H5FS__cache_hdr_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_udata,
- hbool_t H5_ATTR_UNUSED *dirty)
+ hbool_t H5_ATTR_UNUSED *dirty)
{
- H5FS_t *fspace = NULL; /* Free space header info */
- H5FS_hdr_cache_ud_t *udata = (H5FS_hdr_cache_ud_t *)_udata; /* User data for callback */
- const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */
- uint32_t stored_chksum; /* Stored metadata checksum value */
- unsigned nclasses; /* Number of section classes */
- H5FS_t *ret_value = NULL; /* Return value */
+ H5FS_t * fspace = NULL; /* Free space header info */
+ H5FS_hdr_cache_ud_t *udata = (H5FS_hdr_cache_ud_t *)_udata; /* User data for callback */
+ const uint8_t * image = (const uint8_t *)_image; /* Pointer into raw data buffer */
+ uint32_t stored_chksum; /* Stored metadata checksum value */
+ unsigned nclasses; /* Number of section classes */
+ H5FS_t * ret_value = NULL; /* Return value */
FUNC_ENTER_STATIC
@@ -257,24 +241,24 @@ H5FS__cache_hdr_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len
HDassert(udata->f);
/* Allocate a new free space manager */
- if(NULL == (fspace = H5FS__new(udata->f, udata->nclasses, udata->classes, udata->cls_init_udata)))
+ if (NULL == (fspace = H5FS__new(udata->f, udata->nclasses, udata->classes, udata->cls_init_udata)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
/* Set free space manager's internal information */
fspace->addr = udata->addr;
/* Magic number */
- if(HDmemcmp(image, H5FS_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC))
+ if (HDmemcmp(image, H5FS_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC))
HGOTO_ERROR(H5E_FSPACE, H5E_CANTLOAD, NULL, "wrong free space header signature")
image += H5_SIZEOF_MAGIC;
/* Version */
- if(*image++ != H5FS_HDR_VERSION)
+ if (*image++ != H5FS_HDR_VERSION)
HGOTO_ERROR(H5E_FSPACE, H5E_CANTLOAD, NULL, "wrong free space header version")
/* Client ID */
fspace->client = (H5FS_client_t)*image++;
- if(fspace->client >= H5FS_NUM_CLIENT_ID)
+ if (fspace->client >= H5FS_NUM_CLIENT_ID)
HGOTO_ERROR(H5E_FSPACE, H5E_CANTLOAD, NULL, "unknown client ID in free space header")
/* Total space tracked */
@@ -292,7 +276,7 @@ H5FS__cache_hdr_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len
/* # of section classes */
/* (only check if we actually have some classes) */
UINT16DECODE(image, nclasses);
- if(fspace->nclasses > 0 && nclasses > fspace->nclasses)
+ if (fspace->nclasses > 0 && nclasses > fspace->nclasses)
HGOTO_ERROR(H5E_FSPACE, H5E_CANTLOAD, NULL, "section class count mismatch")
/* Shrink percent */
@@ -331,14 +315,13 @@ H5FS__cache_hdr_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len
done:
/* Release resources */
- if(!ret_value && fspace)
- if(H5FS__hdr_dest(fspace) < 0)
+ if (!ret_value && fspace)
+ if (H5FS__hdr_dest(fspace) < 0)
HDONE_ERROR(H5E_FSPACE, H5E_CANTFREE, NULL, "unable to destroy free space header")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FS__cache_hdr_deserialize() */
-
/*-------------------------------------------------------------------------
* Function: H5FS__cache_hdr_image_len
*
@@ -355,7 +338,7 @@ done:
static herr_t
H5FS__cache_hdr_image_len(const void *_thing, size_t *image_len)
{
- const H5FS_t *fspace = (const H5FS_t *)_thing; /* Pointer to the object */
+ const H5FS_t *fspace = (const H5FS_t *)_thing; /* Pointer to the object */
FUNC_ENTER_STATIC_NOERR
@@ -371,7 +354,6 @@ H5FS__cache_hdr_image_len(const void *_thing, size_t *image_len)
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5FS__cache_hdr_image_len() */
-
/*-------------------------------------------------------------------------
* Function: H5FS__cache_hdr_pre_serialize
*
@@ -400,13 +382,13 @@ H5FS__cache_hdr_image_len(const void *_thing, size_t *image_len)
*-------------------------------------------------------------------------
*/
static herr_t
-H5FS__cache_hdr_pre_serialize(H5F_t *f, void *_thing,
- haddr_t addr, size_t H5_ATTR_UNUSED len, haddr_t H5_ATTR_NDEBUG_UNUSED *new_addr,
- size_t H5_ATTR_NDEBUG_UNUSED *new_len, unsigned *flags)
+H5FS__cache_hdr_pre_serialize(H5F_t *f, void *_thing, haddr_t addr, size_t H5_ATTR_UNUSED len,
+ haddr_t H5_ATTR_NDEBUG_UNUSED *new_addr, size_t H5_ATTR_NDEBUG_UNUSED *new_len,
+ unsigned *flags)
{
- H5FS_t *fspace = (H5FS_t *)_thing; /* Pointer to the object */
- H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */
- herr_t ret_value = SUCCEED; /* Return value */
+ H5FS_t * fspace = (H5FS_t *)_thing; /* Pointer to the object */
+ H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
@@ -420,11 +402,11 @@ H5FS__cache_hdr_pre_serialize(H5F_t *f, void *_thing,
HDassert(new_len);
HDassert(flags);
- if(fspace->sinfo) {
+ if (fspace->sinfo) {
H5AC_ring_t ring;
/* Retrieve the ring type for the header */
- if(H5AC_get_entry_ring(f, addr, &ring) < 0)
+ if (H5AC_get_entry_ring(f, addr, &ring) < 0)
HGOTO_ERROR(H5E_FSPACE, H5E_CANTGET, FAIL, "unable to get property value");
/* Set the ring type for the section info in the API context */
@@ -508,11 +490,11 @@ H5FS__cache_hdr_pre_serialize(H5F_t *f, void *_thing,
* as dirty, as the metadata cache would not be attempting to
* serialize the header if it thought it was clean.
*/
- if(fspace->serial_sect_count > 0 && H5F_addr_defined(fspace->addr)) {
+ if (fspace->serial_sect_count > 0 && H5F_addr_defined(fspace->addr)) {
/* Sanity check */
HDassert(fspace->sect_size > 0);
- if(!H5F_addr_defined(fspace->sect_addr)) { /* case 1 */
+ if (!H5F_addr_defined(fspace->sect_addr)) { /* case 1 */
haddr_t tag = HADDR_UNDEF;
haddr_t sect_addr;
hsize_t saved_sect_size, new_sect_size;
@@ -521,35 +503,41 @@ H5FS__cache_hdr_pre_serialize(H5F_t *f, void *_thing,
* into the metadata cache.
*/
saved_sect_size = fspace->sect_size;
- if(HADDR_UNDEF == (sect_addr = H5MF_alloc((H5F_t *)f, H5FD_MEM_FSPACE_SINFO, fspace->sect_size)))
- HGOTO_ERROR(H5E_FSPACE, H5E_NOSPACE, FAIL, "file allocation failed for free space sections")
+ if (HADDR_UNDEF ==
+ (sect_addr = H5MF_alloc((H5F_t *)f, H5FD_MEM_FSPACE_SINFO, fspace->sect_size)))
+ HGOTO_ERROR(H5E_FSPACE, H5E_NOSPACE, FAIL,
+ "file allocation failed for free space sections")
/* fspace->sect_size may change in size after H5MF_alloc().
* If increased in size, free the previous allocation and
* allocate again with the bigger fspace->sect_size.
*/
- if(fspace->sect_size > saved_sect_size) {
+ if (fspace->sect_size > saved_sect_size) {
new_sect_size = fspace->sect_size;
- if(H5MF_xfree(f, H5FD_MEM_FSPACE_SINFO, sect_addr, saved_sect_size) < 0)
+ if (H5MF_xfree(f, H5FD_MEM_FSPACE_SINFO, sect_addr, saved_sect_size) < 0)
HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, "unable to free free space sections")
- if(HADDR_UNDEF == (sect_addr = H5MF_alloc((H5F_t *)f, H5FD_MEM_FSPACE_SINFO, new_sect_size)))
- HGOTO_ERROR(H5E_FSPACE, H5E_NOSPACE, FAIL, "file allocation failed for free space sections")
- fspace->sect_size = new_sect_size;
+ if (HADDR_UNDEF ==
+ (sect_addr = H5MF_alloc((H5F_t *)f, H5FD_MEM_FSPACE_SINFO, new_sect_size)))
+ HGOTO_ERROR(H5E_FSPACE, H5E_NOSPACE, FAIL,
+ "file allocation failed for free space sections")
+ fspace->sect_size = new_sect_size;
fspace->alloc_sect_size = new_sect_size;
- } else {
+ }
+ else {
fspace->alloc_sect_size = saved_sect_size;
- fspace->sect_size = saved_sect_size;
+ fspace->sect_size = saved_sect_size;
}
fspace->sect_addr = sect_addr;
/* Get the tag for this free space manager and use it to insert the entry */
- if(H5AC_get_tag((const void *)fspace, &tag) < 0)
+ if (H5AC_get_tag((const void *)fspace, &tag) < 0)
HGOTO_ERROR(H5E_FSPACE, H5E_CANTTAG, FAIL, "can't get tag for metadata cache object")
H5_BEGIN_TAG(tag)
- if(H5AC_insert_entry((H5F_t *)f, H5AC_FSPACE_SINFO, fspace->sect_addr, fspace->sinfo, H5AC__NO_FLAGS_SET) < 0)
+ if (H5AC_insert_entry((H5F_t *)f, H5AC_FSPACE_SINFO, fspace->sect_addr, fspace->sinfo,
+ H5AC__NO_FLAGS_SET) < 0)
HGOTO_ERROR_TAG(H5E_FSPACE, H5E_CANTINIT, FAIL, "can't add free space sections to cache")
H5_END_TAG
@@ -559,8 +547,8 @@ H5FS__cache_hdr_pre_serialize(H5F_t *f, void *_thing,
* so set fspace->sinfo to NULL.
*/
fspace->sinfo = NULL;
- } /* end if */
- else if(H5F_IS_TMP_ADDR(f, fspace->sect_addr)) { /* case 2 */
+ } /* end if */
+ else if (H5F_IS_TMP_ADDR(f, fspace->sect_addr)) { /* case 2 */
haddr_t new_sect_addr;
/* move the section info from temporary (AKA imaginary) file
@@ -575,18 +563,20 @@ H5FS__cache_hdr_pre_serialize(H5F_t *f, void *_thing,
HDassert(fspace->alloc_sect_size == (size_t)fspace->sect_size);
/* Allocate space for the section info in file */
- if(HADDR_UNDEF == (new_sect_addr = H5MF_alloc((H5F_t *)f, H5FD_MEM_FSPACE_SINFO, fspace->sect_size)))
- HGOTO_ERROR(H5E_FSPACE, H5E_NOSPACE, FAIL, "file allocation failed for free space sections")
+ if (HADDR_UNDEF ==
+ (new_sect_addr = H5MF_alloc((H5F_t *)f, H5FD_MEM_FSPACE_SINFO, fspace->sect_size)))
+ HGOTO_ERROR(H5E_FSPACE, H5E_NOSPACE, FAIL,
+ "file allocation failed for free space sections")
fspace->alloc_sect_size = (size_t)fspace->sect_size;
HDassert(fspace->sinfo->cache_info.size == fspace->alloc_sect_size);
/* Let the metadata cache know the section info moved */
- if(H5AC_move_entry((H5F_t *)f, H5AC_FSPACE_SINFO, fspace->sect_addr, new_sect_addr) < 0)
+ if (H5AC_move_entry((H5F_t *)f, H5AC_FSPACE_SINFO, fspace->sect_addr, new_sect_addr) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTMOVE, FAIL, "unable to move section info")
fspace->sect_addr = new_sect_addr;
- } /* end else-if */
+ } /* end else-if */
else { /* case 3 -- nothing to do but sanity checking */
/* if my reading of the code is correct, this should always
* be the case. If not, we will have to add code to resize
@@ -595,15 +585,15 @@ H5FS__cache_hdr_pre_serialize(H5F_t *f, void *_thing,
HDassert(fspace->sect_size > 0);
HDassert(fspace->alloc_sect_size == (size_t)fspace->sect_size);
} /* end else */
- } /* end else */
+ } /* end else */
else {
/* for one reason or another (see comment above) there should
* not be any file space allocated for the section info.
*/
- HDassert(!H5F_addr_defined(fspace->sect_addr));
+ HDassert(!H5F_addr_defined(fspace->sect_addr));
} /* end else */
- } /* end if */
- else if(H5F_addr_defined(fspace->sect_addr)) {
+ } /* end if */
+ else if (H5F_addr_defined(fspace->sect_addr)) {
/* Here the metadata cache is managing the section info.
*
* Do some sanity checks, and then test to see if the section
@@ -611,14 +601,14 @@ H5FS__cache_hdr_pre_serialize(H5F_t *f, void *_thing,
* real file space lest the header be written to file with
* a nonsense section info address.
*/
- if(!H5F_POINT_OF_NO_RETURN(f)) {
+ if (!H5F_POINT_OF_NO_RETURN(f)) {
HDassert(fspace->sect_size > 0);
HDassert(fspace->alloc_sect_size == (size_t)fspace->sect_size);
} /* end if */
- if(H5F_IS_TMP_ADDR(f, fspace->sect_addr)) {
+ if (H5F_IS_TMP_ADDR(f, fspace->sect_addr)) {
unsigned sect_status = 0;
- haddr_t new_sect_addr;
+ haddr_t new_sect_addr;
/* we have work to do -- must relocate section info into
* real file space.
@@ -628,7 +618,7 @@ H5FS__cache_hdr_pre_serialize(H5F_t *f, void *_thing,
* cache. Further, since fspace->sinfo is NULL, it must be
* unprotected and un-pinned. Start by verifying this.
*/
- if(H5AC_get_entry_status(f, fspace->sect_addr, &sect_status) < 0)
+ if (H5AC_get_entry_status(f, fspace->sect_addr, &sect_status) < 0)
HGOTO_ERROR(H5E_FSPACE, H5E_CANTGET, FAIL, "can't get section info status")
HDassert(sect_status & H5AC_ES__IN_CACHE);
@@ -636,7 +626,8 @@ H5FS__cache_hdr_pre_serialize(H5F_t *f, void *_thing,
HDassert((sect_status & H5AC_ES__IS_PINNED) == 0);
/* Allocate space for the section info in file */
- if(HADDR_UNDEF == (new_sect_addr = H5MF_alloc((H5F_t *)f, H5FD_MEM_FSPACE_SINFO, fspace->sect_size)))
+ if (HADDR_UNDEF ==
+ (new_sect_addr = H5MF_alloc((H5F_t *)f, H5FD_MEM_FSPACE_SINFO, fspace->sect_size)))
HGOTO_ERROR(H5E_FSPACE, H5E_NOSPACE, FAIL, "file allocation failed for free space sections")
fspace->alloc_sect_size = (size_t)fspace->sect_size;
@@ -645,7 +636,7 @@ H5FS__cache_hdr_pre_serialize(H5F_t *f, void *_thing,
HDassert(!H5F_addr_eq(fspace->sect_addr, new_sect_addr));
/* Let the metadata cache know the section info moved */
- if(H5AC_move_entry((H5F_t *)f, H5AC_FSPACE_SINFO, fspace->sect_addr, new_sect_addr) < 0)
+ if (H5AC_move_entry((H5F_t *)f, H5AC_FSPACE_SINFO, fspace->sect_addr, new_sect_addr) < 0)
HGOTO_ERROR(H5E_FSPACE, H5E_CANTMOVE, FAIL, "unable to move section info")
/* Update the internal address for the section info */
@@ -654,9 +645,9 @@ H5FS__cache_hdr_pre_serialize(H5F_t *f, void *_thing,
/* No need to mark the header dirty, as we are about to
* serialize it.
*/
- } /* end if */
- } /* end else-if */
- else { /* there is no section info at present */
+ } /* end if */
+ } /* end else-if */
+ else { /* there is no section info at present */
/* do some sanity checks */
HDassert(fspace->serial_sect_count == 0);
HDassert(fspace->tot_sect_count == fspace->ghost_sect_count);
@@ -667,13 +658,12 @@ H5FS__cache_hdr_pre_serialize(H5F_t *f, void *_thing,
done:
/* Reset the ring in the API context */
- if(orig_ring != H5AC_RING_INV)
+ if (orig_ring != H5AC_RING_INV)
H5AC_set_ring(orig_ring, NULL);
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FS__cache_hdr_pre_serialize() */
-
/*-------------------------------------------------------------------------
* Function: H5FS__cache_hdr_serialize
*
@@ -691,13 +681,12 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5FS__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_UNUSED len,
- void *_thing)
+H5FS__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_thing)
{
- H5FS_t *fspace = (H5FS_t *)_thing; /* Pointer to the object */
- uint8_t *image = (uint8_t *)_image; /* Pointer into raw data buffer */
- uint32_t metadata_chksum; /* Computed metadata checksum value */
- herr_t ret_value = SUCCEED; /* Return value */
+ H5FS_t * fspace = (H5FS_t *)_thing; /* Pointer to the object */
+ uint8_t *image = (uint8_t *)_image; /* Pointer into raw data buffer */
+ uint32_t metadata_chksum; /* Computed metadata checksum value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC_NOERR
@@ -717,12 +706,11 @@ H5FS__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_UN
* into real file space if necessary before this function was called.
* The following asserts are a cursory check on this.
*/
- HDassert((! H5F_addr_defined(fspace->sect_addr)) || (! H5F_IS_TMP_ADDR(f, fspace->sect_addr)));
+ HDassert((!H5F_addr_defined(fspace->sect_addr)) || (!H5F_IS_TMP_ADDR(f, fspace->sect_addr)));
- if(!H5F_POINT_OF_NO_RETURN(f))
- HDassert((! H5F_addr_defined(fspace->sect_addr)) ||
- ((fspace->sect_size > 0) &&
- (fspace->alloc_sect_size == (size_t)fspace->sect_size)));
+ if (!H5F_POINT_OF_NO_RETURN(f))
+ HDassert((!H5F_addr_defined(fspace->sect_addr)) ||
+ ((fspace->sect_size > 0) && (fspace->alloc_sect_size == (size_t)fspace->sect_size)));
/* Magic number */
H5MM_memcpy(image, H5FS_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC);
@@ -784,7 +772,6 @@ H5FS__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_UN
FUNC_LEAVE_NOAPI(ret_value)
} /* H5FS__cache_hdr_serialize() */
-
/*-------------------------------------------------------------------------
* Function: H5FS__cache_hdr_notify
*
@@ -800,8 +787,8 @@ H5FS__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_UN
herr_t
H5FS__cache_hdr_notify(H5AC_notify_action_t action, void *_thing)
{
- H5FS_t *fspace = (H5FS_t *)_thing; /* Pointer to the object */
- herr_t ret_value = SUCCEED; /* Return value */
+ H5FS_t *fspace = (H5FS_t *)_thing; /* Pointer to the object */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
@@ -809,7 +796,7 @@ H5FS__cache_hdr_notify(H5AC_notify_action_t action, void *_thing)
HDassert(fspace);
/* Determine which action to take */
- switch(action) {
+ switch (action) {
case H5AC_NOTIFY_ACTION_AFTER_INSERT:
case H5AC_NOTIFY_ACTION_AFTER_LOAD:
case H5AC_NOTIFY_ACTION_AFTER_FLUSH:
@@ -817,7 +804,7 @@ H5FS__cache_hdr_notify(H5AC_notify_action_t action, void *_thing)
break;
case H5AC_NOTIFY_ACTION_ENTRY_DIRTIED:
- if(H5AC_unsettle_entry_ring(fspace) < 0)
+ if (H5AC_unsettle_entry_ring(fspace) < 0)
HGOTO_ERROR(H5E_FSPACE, H5E_CANTFLUSH, FAIL, "unable to mark FSM ring as unsettled")
break;
@@ -833,16 +820,15 @@ H5FS__cache_hdr_notify(H5AC_notify_action_t action, void *_thing)
default:
#ifdef NDEBUG
HGOTO_ERROR(H5E_FSPACE, H5E_BADVALUE, FAIL, "unknown action from metadata cache")
-#else /* NDEBUG */
+#else /* NDEBUG */
HDassert(0 && "Unknown action?!?");
#endif /* NDEBUG */
- } /* end switch */
+ } /* end switch */
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5FS__cache_hdr_notify() */
+} /* end H5FS__cache_hdr_notify() */
-
/*-------------------------------------------------------------------------
* Function: H5FS__cache_hdr_free_icr
*
@@ -863,8 +849,8 @@ done:
static herr_t
H5FS__cache_hdr_free_icr(void *_thing)
{
- H5FS_t *fspace = (H5FS_t *)_thing; /* Pointer to the object */
- herr_t ret_value = SUCCEED; /* Return value */
+ H5FS_t *fspace = (H5FS_t *)_thing; /* Pointer to the object */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
@@ -877,14 +863,13 @@ H5FS__cache_hdr_free_icr(void *_thing)
HDassert(!fspace->sinfo);
/* Destroy free space header */
- if(H5FS__hdr_dest(fspace) < 0)
+ if (H5FS__hdr_dest(fspace) < 0)
HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, "unable to destroy free space header")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FS__cache_hdr_free_icr() */
-
/*-------------------------------------------------------------------------
* Function: H5FS__cache_sinfo_get_initial_load_size()
*
@@ -900,9 +885,9 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5FS__cache_sinfo_get_initial_load_size(void *_udata, size_t *image_len)
+H5FS__cache_sinfo_get_initial_load_size(void *_udata, size_t *image_len)
{
- const H5FS_t *fspace; /* free space manager */
+ const H5FS_t * fspace; /* free space manager */
H5FS_sinfo_cache_ud_t *udata = (H5FS_sinfo_cache_ud_t *)_udata; /* User data for callback */
FUNC_ENTER_STATIC_NOERR
@@ -920,7 +905,6 @@ H5FS__cache_sinfo_get_initial_load_size(void *_udata, size_t *image_len)
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5FS__cache_sinfo_get_initial_load_size() */
-
/*-------------------------------------------------------------------------
* Function: H5FS__cache_sinfo_verify_chksum
*
@@ -937,10 +921,10 @@ H5FS__cache_sinfo_get_initial_load_size(void *_udata, size_t *image_len)
htri_t
H5FS__cache_sinfo_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata)
{
- const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */
- uint32_t stored_chksum; /* Stored metadata checksum value */
- uint32_t computed_chksum; /* Computed metadata checksum value */
- htri_t ret_value = TRUE; /* Return value */
+ const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */
+ uint32_t stored_chksum; /* Stored metadata checksum value */
+ uint32_t computed_chksum; /* Computed metadata checksum value */
+ htri_t ret_value = TRUE; /* Return value */
FUNC_ENTER_PACKAGE_NOERR
@@ -950,13 +934,12 @@ H5FS__cache_sinfo_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNU
/* Get stored and computed checksums */
H5F_get_checksums(image, len, &stored_chksum, &computed_chksum);
- if(stored_chksum != computed_chksum)
+ if (stored_chksum != computed_chksum)
ret_value = FALSE;
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FS__cache_sinfo_verify_chksum() */
-
/*-------------------------------------------------------------------------
* Function: H5FS__cache_sinfo_deserialize
*
@@ -975,17 +958,17 @@ H5FS__cache_sinfo_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNU
*/
static void *
H5FS__cache_sinfo_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_udata,
- hbool_t H5_ATTR_NDEBUG_UNUSED *dirty)
+ hbool_t H5_ATTR_NDEBUG_UNUSED *dirty)
{
- H5FS_sinfo_cache_ud_t *udata = (H5FS_sinfo_cache_ud_t *)_udata; /* User data for callback */
- H5FS_t *fspace; /* free space manager */
- H5FS_sinfo_t *sinfo = NULL; /* Free space section info */
- haddr_t fs_addr; /* Free space header address */
- size_t old_sect_size; /* Old section size */
- const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */
- const uint8_t *chksum_image; /* Points to chksum location */
- uint32_t stored_chksum; /* Stored metadata checksum */
- void * ret_value = NULL; /* Return value */
+ H5FS_sinfo_cache_ud_t *udata = (H5FS_sinfo_cache_ud_t *)_udata; /* User data for callback */
+ H5FS_t * fspace; /* free space manager */
+ H5FS_sinfo_t * sinfo = NULL; /* Free space section info */
+ haddr_t fs_addr; /* Free space header address */
+ size_t old_sect_size; /* Old section size */
+ const uint8_t * image = (const uint8_t *)_image; /* Pointer into raw data buffer */
+ const uint8_t * chksum_image; /* Points to chksum location */
+ uint32_t stored_chksum; /* Stored metadata checksum */
+ void * ret_value = NULL; /* Return value */
FUNC_ENTER_STATIC
@@ -998,52 +981,53 @@ H5FS__cache_sinfo_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED l
HDassert(dirty);
/* Allocate a new free space section info */
- if(NULL == (sinfo = H5FS__sinfo_new(udata->f, fspace)))
+ if (NULL == (sinfo = H5FS__sinfo_new(udata->f, fspace)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
/* initialize old_sect_size */
H5_CHECKED_ASSIGN(old_sect_size, size_t, fspace->sect_size, hsize_t);
/* Magic number */
- if(HDmemcmp(image, H5FS_SINFO_MAGIC, (size_t)H5_SIZEOF_MAGIC))
+ if (HDmemcmp(image, H5FS_SINFO_MAGIC, (size_t)H5_SIZEOF_MAGIC))
HGOTO_ERROR(H5E_FSPACE, H5E_CANTLOAD, NULL, "wrong free space sections signature")
image += H5_SIZEOF_MAGIC;
/* Version */
- if(*image++ != H5FS_SINFO_VERSION)
+ if (*image++ != H5FS_SINFO_VERSION)
HGOTO_ERROR(H5E_FSPACE, H5E_CANTLOAD, NULL, "wrong free space sections version")
/* Address of free space header for these sections */
H5F_addr_decode(udata->f, &image, &fs_addr);
- if(H5F_addr_ne(fs_addr, fspace->addr))
+ if (H5F_addr_ne(fs_addr, fspace->addr))
HGOTO_ERROR(H5E_FSPACE, H5E_CANTLOAD, NULL, "incorrect header address for free space sections")
/* Check for any serialized sections */
- if(fspace->serial_sect_count > 0) {
- hsize_t old_tot_sect_count; /* Total section count from header */
- hsize_t H5_ATTR_NDEBUG_UNUSED old_serial_sect_count; /* Total serializable section count from header */
+ if (fspace->serial_sect_count > 0) {
+ hsize_t old_tot_sect_count; /* Total section count from header */
+ hsize_t H5_ATTR_NDEBUG_UNUSED
+ old_serial_sect_count; /* Total serializable section count from header */
hsize_t H5_ATTR_NDEBUG_UNUSED old_ghost_sect_count; /* Total ghost section count from header */
hsize_t H5_ATTR_NDEBUG_UNUSED old_tot_space; /* Total space managed from header */
- unsigned sect_cnt_size; /* The size of the section size counts */
+ unsigned sect_cnt_size; /* The size of the section size counts */
/* Compute the size of the section counts */
sect_cnt_size = H5VM_limit_enc_size((uint64_t)fspace->serial_sect_count);
/* Reset the section count, the "add" routine will update it */
- old_tot_sect_count = fspace->tot_sect_count;
- old_serial_sect_count = fspace->serial_sect_count;
- old_ghost_sect_count = fspace->ghost_sect_count;
- old_tot_space = fspace->tot_space;
- fspace->tot_sect_count = 0;
+ old_tot_sect_count = fspace->tot_sect_count;
+ old_serial_sect_count = fspace->serial_sect_count;
+ old_ghost_sect_count = fspace->ghost_sect_count;
+ old_tot_space = fspace->tot_space;
+ fspace->tot_sect_count = 0;
fspace->serial_sect_count = 0;
- fspace->ghost_sect_count = 0;
- fspace->tot_space = 0;
+ fspace->ghost_sect_count = 0;
+ fspace->tot_space = 0;
/* Walk through the image, deserializing sections */
do {
- hsize_t sect_size = 0; /* Current section size */
- size_t node_count = 0; /* # of sections of this size */
- size_t u; /* Local index variable */
+ hsize_t sect_size = 0; /* Current section size */
+ size_t node_count = 0; /* # of sections of this size */
+ size_t u; /* Local index variable */
/* The number of sections of this node's size */
UINT64DECODE_VAR(image, node_count, sect_cnt_size);
@@ -1054,11 +1038,11 @@ H5FS__cache_sinfo_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED l
HDassert(sect_size);
/* Loop over nodes of this size */
- for(u = 0; u < node_count; u++) {
- H5FS_section_info_t *new_sect; /* Section that was deserialized */
- haddr_t sect_addr = 0; /* Address of free space section in the address space */
- unsigned sect_type; /* Type of free space section */
- unsigned des_flags; /* Flags from deserialize callback */
+ for (u = 0; u < node_count; u++) {
+ H5FS_section_info_t *new_sect; /* Section that was deserialized */
+ haddr_t sect_addr = 0; /* Address of free space section in the address space */
+ unsigned sect_type; /* Type of free space section */
+ unsigned des_flags; /* Flags from deserialize callback */
/* The address of the section */
UINT64DECODE_VAR(image, sect_addr, sinfo->sect_off_size);
@@ -1069,22 +1053,24 @@ H5FS__cache_sinfo_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED l
/* Call 'deserialize' callback for this section */
des_flags = 0;
HDassert(fspace->sect_cls[sect_type].deserialize);
- if(NULL == (new_sect = (*fspace->sect_cls[sect_type].deserialize) (&fspace->sect_cls[sect_type], image, sect_addr, sect_size, &des_flags)))
+ if (NULL == (new_sect = (*fspace->sect_cls[sect_type].deserialize)(
+ &fspace->sect_cls[sect_type], image, sect_addr, sect_size, &des_flags)))
HGOTO_ERROR(H5E_FSPACE, H5E_CANTDECODE, NULL, "can't deserialize section")
/* Update offset in serialization image */
image += fspace->sect_cls[sect_type].serial_size;
/* Insert section in free space manager, unless requested not to */
- if(!(des_flags & H5FS_DESERIALIZE_NO_ADD))
- if(H5FS_sect_add(udata->f, fspace, new_sect, H5FS_ADD_DESERIALIZING, udata) < 0)
- HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, NULL, "can't add section to free space manager")
+ if (!(des_flags & H5FS_DESERIALIZE_NO_ADD))
+ if (H5FS_sect_add(udata->f, fspace, new_sect, H5FS_ADD_DESERIALIZING, udata) < 0)
+ HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, NULL,
+ "can't add section to free space manager")
} /* end for */
- if(fspace->tot_sect_count == old_tot_sect_count)
+ if (fspace->tot_sect_count == old_tot_sect_count)
break;
- } while(image < (((const uint8_t *)_image + old_sect_size) - H5FS_SIZEOF_CHKSUM));
+ } while (image < (((const uint8_t *)_image + old_sect_size) - H5FS_SIZEOF_CHKSUM));
/* Sanity check */
HDassert((size_t)(image - (const uint8_t *)_image) <= (old_sect_size - H5FS_SIZEOF_CHKSUM));
@@ -1104,20 +1090,19 @@ H5FS__cache_sinfo_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED l
/* Sanity check */
HDassert((image == chksum_image) ||
- ((size_t)((image - (const uint8_t *)_image) + (chksum_image - image)) == old_sect_size));
+ ((size_t)((image - (const uint8_t *)_image) + (chksum_image - image)) == old_sect_size));
/* Set return value */
ret_value = sinfo;
done:
- if(!ret_value && sinfo)
- if(H5FS__sinfo_dest(sinfo) < 0)
+ if (!ret_value && sinfo)
+ if (H5FS__sinfo_dest(sinfo) < 0)
HDONE_ERROR(H5E_FSPACE, H5E_CANTFREE, NULL, "unable to destroy free space info")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FS__cache_sinfo_deserialize() */
-
/*-------------------------------------------------------------------------
* Function: H5FS__cache_sinfo_image_len
*
@@ -1134,7 +1119,7 @@ done:
static herr_t
H5FS__cache_sinfo_image_len(const void *_thing, size_t *image_len)
{
- const H5FS_sinfo_t *sinfo = (const H5FS_sinfo_t *)_thing; /* Pointer to the object */
+ const H5FS_sinfo_t *sinfo = (const H5FS_sinfo_t *)_thing; /* Pointer to the object */
FUNC_ENTER_STATIC_NOERR
@@ -1153,7 +1138,6 @@ H5FS__cache_sinfo_image_len(const void *_thing, size_t *image_len)
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5FS__cache_sinfo_image_len() */
-
/*-------------------------------------------------------------------------
* Function: H5FS__cache_sinfo_pre_serialize
*
@@ -1171,14 +1155,13 @@ H5FS__cache_sinfo_image_len(const void *_thing, size_t *image_len)
*-------------------------------------------------------------------------
*/
static herr_t
-H5FS__cache_sinfo_pre_serialize(H5F_t *f, void *_thing, haddr_t addr,
- size_t H5_ATTR_NDEBUG_UNUSED len, haddr_t *new_addr, size_t H5_ATTR_NDEBUG_UNUSED *new_len,
- unsigned *flags)
+H5FS__cache_sinfo_pre_serialize(H5F_t *f, void *_thing, haddr_t addr, size_t H5_ATTR_NDEBUG_UNUSED len,
+ haddr_t *new_addr, size_t H5_ATTR_NDEBUG_UNUSED *new_len, unsigned *flags)
{
- H5FS_sinfo_t *sinfo = (H5FS_sinfo_t *)_thing; /* Pointer to the object */
- H5FS_t *fspace; /* Free space header */
- haddr_t sinfo_addr; /* Address for section info */
- herr_t ret_value = SUCCEED; /* Return value */
+ H5FS_sinfo_t *sinfo = (H5FS_sinfo_t *)_thing; /* Pointer to the object */
+ H5FS_t * fspace; /* Free space header */
+ haddr_t sinfo_addr; /* Address for section info */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
@@ -1201,13 +1184,13 @@ H5FS__cache_sinfo_pre_serialize(H5F_t *f, void *_thing, haddr_t addr,
sinfo_addr = addr; /* this will change if we relocate the section data */
/* Check for section info at temporary address */
- if(H5F_IS_TMP_ADDR(f, fspace->sect_addr)) {
+ if (H5F_IS_TMP_ADDR(f, fspace->sect_addr)) {
/* Sanity check */
HDassert(fspace->sect_size > 0);
HDassert(H5F_addr_eq(fspace->sect_addr, addr));
/* Allocate space for the section info in file */
- if(HADDR_UNDEF == (sinfo_addr = H5MF_alloc((H5F_t *)f, H5FD_MEM_FSPACE_SINFO, fspace->sect_size)))
+ if (HADDR_UNDEF == (sinfo_addr = H5MF_alloc((H5F_t *)f, H5FD_MEM_FSPACE_SINFO, fspace->sect_size)))
HGOTO_ERROR(H5E_FSPACE, H5E_NOSPACE, FAIL, "file allocation failed for free space sections")
fspace->alloc_sect_size = (size_t)fspace->sect_size;
@@ -1216,20 +1199,20 @@ H5FS__cache_sinfo_pre_serialize(H5F_t *f, void *_thing, haddr_t addr,
HDassert(!H5F_addr_eq(sinfo->fspace->sect_addr, sinfo_addr));
/* Let the metadata cache know the section info moved */
- if(H5AC_move_entry((H5F_t *)f, H5AC_FSPACE_SINFO, sinfo->fspace->sect_addr, sinfo_addr) < 0)
+ if (H5AC_move_entry((H5F_t *)f, H5AC_FSPACE_SINFO, sinfo->fspace->sect_addr, sinfo_addr) < 0)
HGOTO_ERROR(H5E_FSPACE, H5E_CANTMOVE, FAIL, "unable to move section info")
/* Update the internal address for the section info */
sinfo->fspace->sect_addr = sinfo_addr;
/* Mark free space header as dirty */
- if(H5AC_mark_entry_dirty(fspace) < 0)
+ if (H5AC_mark_entry_dirty(fspace) < 0)
HGOTO_ERROR(H5E_FSPACE, H5E_CANTMARKDIRTY, FAIL, "unable to mark free space header as dirty")
} /* end if */
- if(!H5F_addr_eq(addr, sinfo_addr)) {
+ if (!H5F_addr_eq(addr, sinfo_addr)) {
*new_addr = sinfo_addr;
- *flags = H5C__SERIALIZE_MOVED_FLAG;
+ *flags = H5C__SERIALIZE_MOVED_FLAG;
} /* end if */
else
*flags = 0;
@@ -1238,7 +1221,6 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FS__cache_sinfo_pre_serialize() */
-
/*-------------------------------------------------------------------------
* Function: H5FS__cache_sinfo_serialize
*
@@ -1256,16 +1238,15 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5FS__cache_sinfo_serialize(const H5F_t *f, void *_image, size_t len,
- void *_thing)
+H5FS__cache_sinfo_serialize(const H5F_t *f, void *_image, size_t len, void *_thing)
{
- H5FS_sinfo_t *sinfo = (H5FS_sinfo_t *)_thing; /* Pointer to the object */
- H5FS_iter_ud_t udata; /* User data for callbacks */
- uint8_t *image = (uint8_t *)_image; /* Pointer into raw data buffer */
- uint8_t *chksum_image = NULL; /* Points to chksum location */
- uint32_t metadata_chksum; /* Computed metadata checksum value */
- unsigned bin; /* Current bin we are on */
- herr_t ret_value = SUCCEED; /* Return value */
+ H5FS_sinfo_t * sinfo = (H5FS_sinfo_t *)_thing; /* Pointer to the object */
+ H5FS_iter_ud_t udata; /* User data for callbacks */
+ uint8_t * image = (uint8_t *)_image; /* Pointer into raw data buffer */
+ uint8_t * chksum_image = NULL; /* Points to chksum location */
+ uint32_t metadata_chksum; /* Computed metadata checksum value */
+ unsigned bin; /* Current bin we are on */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
@@ -1292,23 +1273,22 @@ H5FS__cache_sinfo_serialize(const H5F_t *f, void *_image, size_t len,
H5F_addr_encode(f, &image, sinfo->fspace->addr);
/* Set up user data for iterator */
- udata.sinfo = sinfo;
- udata.image = &image;
+ udata.sinfo = sinfo;
+ udata.image = &image;
udata.sect_cnt_size = H5VM_limit_enc_size((uint64_t)sinfo->fspace->serial_sect_count);
/* Iterate over all the bins */
- for(bin = 0; bin < sinfo->nbins; bin++)
+ for (bin = 0; bin < sinfo->nbins; bin++)
/* Check if there are any sections in this bin */
- if(sinfo->bins[bin].bin_list)
+ if (sinfo->bins[bin].bin_list)
/* Iterate over list of section size nodes for bin */
- if(H5SL_iterate(sinfo->bins[bin].bin_list, H5FS__sinfo_serialize_node_cb, &udata) < 0)
+ if (H5SL_iterate(sinfo->bins[bin].bin_list, H5FS__sinfo_serialize_node_cb, &udata) < 0)
HGOTO_ERROR(H5E_FSPACE, H5E_BADITER, FAIL, "can't iterate over section size nodes")
-
/* Compute checksum */
/* There may be empty space between entries and chksum */
- chksum_image = (uint8_t *)(_image) + len - H5FS_SIZEOF_CHKSUM;
+ chksum_image = (uint8_t *)(_image) + len - H5FS_SIZEOF_CHKSUM;
metadata_chksum = H5_checksum_metadata(_image, (size_t)(chksum_image - (uint8_t *)_image), 0);
/* Metadata checksum */
UINT32ENCODE(chksum_image, metadata_chksum);
@@ -1322,7 +1302,6 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FS__cache_sinfo_serialize() */
-
/*-------------------------------------------------------------------------
* Function: H5FS__cache_sinfo_notify
*
@@ -1338,8 +1317,8 @@ done:
herr_t
H5FS__cache_sinfo_notify(H5AC_notify_action_t action, void *_thing)
{
- H5FS_sinfo_t *sinfo = (H5FS_sinfo_t *)_thing;
- herr_t ret_value = SUCCEED; /* Return value */
+ H5FS_sinfo_t *sinfo = (H5FS_sinfo_t *)_thing;
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
@@ -1347,17 +1326,20 @@ H5FS__cache_sinfo_notify(H5AC_notify_action_t action, void *_thing)
HDassert(sinfo);
/* Check if the file was opened with SWMR-write access */
- if(sinfo->fspace->swmr_write) {
+ if (sinfo->fspace->swmr_write) {
/* Determine which action to take */
- switch(action) {
+ switch (action) {
case H5AC_NOTIFY_ACTION_AFTER_INSERT:
- case H5AC_NOTIFY_ACTION_AFTER_LOAD:
+ case H5AC_NOTIFY_ACTION_AFTER_LOAD:
/* Create flush dependency on parent */
- if(H5FS__create_flush_depend((H5AC_info_t *)sinfo->fspace, (H5AC_info_t *)sinfo) < 0)
- HGOTO_ERROR(H5E_FSPACE, H5E_CANTDEPEND, FAIL, "unable to create flush dependency between data block and header, address = %llu", (unsigned long long)sinfo->fspace->sect_addr)
+ if (H5FS__create_flush_depend((H5AC_info_t *)sinfo->fspace, (H5AC_info_t *)sinfo) < 0)
+ HGOTO_ERROR(
+ H5E_FSPACE, H5E_CANTDEPEND, FAIL,
+ "unable to create flush dependency between data block and header, address = %llu",
+ (unsigned long long)sinfo->fspace->sect_addr)
break;
- case H5AC_NOTIFY_ACTION_AFTER_FLUSH:
+ case H5AC_NOTIFY_ACTION_AFTER_FLUSH:
case H5AC_NOTIFY_ACTION_ENTRY_DIRTIED:
case H5AC_NOTIFY_ACTION_ENTRY_CLEANED:
case H5AC_NOTIFY_ACTION_CHILD_DIRTIED:
@@ -1368,25 +1350,24 @@ H5FS__cache_sinfo_notify(H5AC_notify_action_t action, void *_thing)
break;
case H5AC_NOTIFY_ACTION_BEFORE_EVICT:
- /* Destroy flush dependency on parent */
- if(H5FS__destroy_flush_depend((H5AC_info_t *)sinfo->fspace, (H5AC_info_t *)sinfo) < 0)
+ /* Destroy flush dependency on parent */
+ if (H5FS__destroy_flush_depend((H5AC_info_t *)sinfo->fspace, (H5AC_info_t *)sinfo) < 0)
HGOTO_ERROR(H5E_FSPACE, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency")
break;
default:
#ifdef NDEBUG
HGOTO_ERROR(H5E_FSPACE, H5E_BADVALUE, FAIL, "unknown action from metadata cache")
-#else /* NDEBUG */
+#else /* NDEBUG */
HDassert(0 && "Unknown action?!?");
-#endif /* NDEBUG */
+#endif /* NDEBUG */
} /* end switch */
- } /* end if */
+ } /* end if */
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5FS__cache_sinfo_notify() */
+} /* end H5FS__cache_sinfo_notify() */
-
/*-------------------------------------------------------------------------
* Function: H5FS__cache_sinfo_free_icr
*
@@ -1408,8 +1389,8 @@ done:
static herr_t
H5FS__cache_sinfo_free_icr(void *_thing)
{
- H5FS_sinfo_t *sinfo = (H5FS_sinfo_t *)_thing; /* Pointer to the object */
- herr_t ret_value = SUCCEED; /* Return value */
+ H5FS_sinfo_t *sinfo = (H5FS_sinfo_t *)_thing; /* Pointer to the object */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
@@ -1422,14 +1403,13 @@ H5FS__cache_sinfo_free_icr(void *_thing)
HDassert(sinfo->fspace->cache_info.is_pinned);
/* Destroy free space info */
- if(H5FS__sinfo_dest(sinfo) < 0)
+ if (H5FS__sinfo_dest(sinfo) < 0)
HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, "unable to destroy free space info")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FS__cache_sinfo_free_icr() */
-
/*-------------------------------------------------------------------------
* Function: H5FS__sinfo_serialize_sect_cb
*
@@ -1446,10 +1426,10 @@ done:
static herr_t
H5FS__sinfo_serialize_sect_cb(void *_item, void H5_ATTR_UNUSED *key, void *_udata)
{
- H5FS_section_class_t *sect_cls; /* Class of section */
- H5FS_section_info_t *sect= (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_class_t *sect_cls; /* Class of section */
+ H5FS_section_info_t * sect = (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_STATIC
@@ -1462,7 +1442,7 @@ H5FS__sinfo_serialize_sect_cb(void *_item, void H5_ATTR_UNUSED *key, void *_udat
sect_cls = &udata->sinfo->fspace->sect_cls[sect->type];
/* Check if this section should be serialized (i.e. is not a ghost section) */
- if(!(sect_cls->flags & H5FS_CLS_GHOST_OBJ)) {
+ if (!(sect_cls->flags & H5FS_CLS_GHOST_OBJ)) {
/* The address of the section */
UINT64ENCODE_VAR(*udata->image, sect->addr, udata->sinfo->sect_off_size);
@@ -1470,8 +1450,8 @@ H5FS__sinfo_serialize_sect_cb(void *_item, void H5_ATTR_UNUSED *key, void *_udat
*(*udata->image)++ = (uint8_t)sect->type;
/* Call 'serialize' callback for this section */
- if(sect_cls->serialize) {
- if((*sect_cls->serialize)(sect_cls, sect, *udata->image) < 0)
+ if (sect_cls->serialize) {
+ if ((*sect_cls->serialize)(sect_cls, sect, *udata->image) < 0)
HGOTO_ERROR(H5E_FSPACE, H5E_CANTSERIALIZE, FAIL, "can't synchronize section")
/* Update offset in serialization buffer */
@@ -1485,7 +1465,6 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5FS__sinfo_serialize_sect_cb() */
-
/*-------------------------------------------------------------------------
* Function: H5FS__sinfo_serialize_node_cb
*
@@ -1502,9 +1481,9 @@ done:
static herr_t
H5FS__sinfo_serialize_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_STATIC
@@ -1514,7 +1493,7 @@ H5FS__sinfo_serialize_node_cb(void *_item, void H5_ATTR_UNUSED *key, void *_udat
HDassert(udata->image);
/* Check if this node has any serializable sections */
- if(fspace_node->serial_count > 0) {
+ if (fspace_node->serial_count > 0) {
/* The number of serializable sections of this node's size */
UINT64ENCODE_VAR(*udata->image, fspace_node->serial_count, udata->sect_cnt_size);
@@ -1523,11 +1502,10 @@ H5FS__sinfo_serialize_node_cb(void *_item, void H5_ATTR_UNUSED *key, void *_udat
/* Iterate through all the sections of this size */
HDassert(fspace_node->sect_list);
- if(H5SL_iterate(fspace_node->sect_list, H5FS__sinfo_serialize_sect_cb, udata) < 0)
+ if (H5SL_iterate(fspace_node->sect_list, H5FS__sinfo_serialize_sect_cb, udata) < 0)
HGOTO_ERROR(H5E_FSPACE, H5E_BADITER, FAIL, "can't iterate over section nodes")
} /* end if */
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5FS__sinfo_serialize_node_cb() */
-