diff options
author | Allen Byrne <byrn@hdfgroup.org> | 2020-09-30 14:27:10 (GMT) |
---|---|---|
committer | Allen Byrne <byrn@hdfgroup.org> | 2020-09-30 14:27:10 (GMT) |
commit | b2d661b508a7fc7a2592c13bc6bdc175551f075d (patch) | |
tree | 13baeb0d83a7c2a4c6299993c182b1227c2f6114 /src/H5B2cache.c | |
parent | 29ab58b58dce556639ea3154e262895773a8a8df (diff) | |
download | hdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.zip hdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.tar.gz hdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.tar.bz2 |
Clang-format of source files
Diffstat (limited to 'src/H5B2cache.c')
-rw-r--r-- | src/H5B2cache.c | 537 |
1 files changed, 258 insertions, 279 deletions
diff --git a/src/H5B2cache.c b/src/H5B2cache.c index 3b7dd5d..ce91085 100644 --- a/src/H5B2cache.c +++ b/src/H5B2cache.c @@ -26,38 +26,33 @@ /* Module Setup */ /****************/ -#include "H5B2module.h" /* This source code file is part of the H5B2 module */ - +#include "H5B2module.h" /* This source code file is part of the H5B2 module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5B2pkg.h" /* v2 B-trees */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5WBprivate.h" /* Wrapped Buffers */ - +#include "H5private.h" /* Generic Functions */ +#include "H5B2pkg.h" /* v2 B-trees */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5WBprivate.h" /* Wrapped Buffers */ /****************/ /* Local Macros */ /****************/ /* B-tree format version #'s */ -#define H5B2_HDR_VERSION 0 /* Header */ -#define H5B2_INT_VERSION 0 /* Internal node */ -#define H5B2_LEAF_VERSION 0 /* Leaf node */ - +#define H5B2_HDR_VERSION 0 /* Header */ +#define H5B2_INT_VERSION 0 /* Internal node */ +#define H5B2_LEAF_VERSION 0 /* Leaf node */ /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ @@ -65,31 +60,25 @@ /* Metadata cache callbacks */ static herr_t H5B2__cache_hdr_get_initial_load_size(void *udata, size_t *image_len); static htri_t H5B2__cache_hdr_verify_chksum(const void *image_ptr, size_t len, void *udata); -static void *H5B2__cache_hdr_deserialize(const void *image, size_t len, - void *udata, hbool_t *dirty); +static void * H5B2__cache_hdr_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); static herr_t H5B2__cache_hdr_image_len(const void *thing, size_t *image_len); -static herr_t H5B2__cache_hdr_serialize(const H5F_t *f, void *image, size_t len, - void *thing); +static herr_t H5B2__cache_hdr_serialize(const H5F_t *f, void *image, size_t len, void *thing); static herr_t H5B2__cache_hdr_notify(H5AC_notify_action_t action, void *thing); static herr_t H5B2__cache_hdr_free_icr(void *thing); static herr_t H5B2__cache_int_get_initial_load_size(void *udata, size_t *image_len); static htri_t H5B2__cache_int_verify_chksum(const void *image_ptr, size_t len, void *udata); -static void *H5B2__cache_int_deserialize(const void *image, size_t len, - void *udata, hbool_t *dirty); +static void * H5B2__cache_int_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); static herr_t H5B2__cache_int_image_len(const void *thing, size_t *image_len); -static herr_t H5B2__cache_int_serialize(const H5F_t *f, void *image, size_t len, - void *thing); +static herr_t H5B2__cache_int_serialize(const H5F_t *f, void *image, size_t len, void *thing); static herr_t H5B2__cache_int_notify(H5AC_notify_action_t action, void *thing); static herr_t H5B2__cache_int_free_icr(void *thing); static herr_t H5B2__cache_leaf_get_initial_load_size(void *udata, size_t *image_len); static htri_t H5B2__cache_leaf_verify_chksum(const void *image_ptr, size_t len, void *udata); -static void *H5B2__cache_leaf_deserialize(const void *image, size_t len, - void *udata, hbool_t *dirty); +static void * H5B2__cache_leaf_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); static herr_t H5B2__cache_leaf_image_len(const void *thing, size_t *image_len); -static herr_t H5B2__cache_leaf_serialize(const H5F_t *f, void *image, size_t len, - void *thing); +static herr_t H5B2__cache_leaf_serialize(const H5F_t *f, void *image, size_t len, void *thing); static herr_t H5B2__cache_leaf_notify(H5AC_notify_action_t action, void *thing); static herr_t H5B2__cache_leaf_free_icr(void *thing); @@ -99,70 +88,66 @@ static herr_t H5B2__cache_leaf_free_icr(void *thing); /* H5B2 inherits cache-like properties from H5AC */ const H5AC_class_t H5AC_BT2_HDR[1] = {{ - H5AC_BT2_HDR_ID, /* Metadata client ID */ - "v2 B-tree header", /* Metadata client name (for debugging) */ - H5FD_MEM_BTREE, /* File space memory type for client */ - H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ + H5AC_BT2_HDR_ID, /* Metadata client ID */ + "v2 B-tree header", /* Metadata client name (for debugging) */ + H5FD_MEM_BTREE, /* File space memory type for client */ + H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ H5B2__cache_hdr_get_initial_load_size, /* 'get_initial_load_size' callback */ - NULL, /* 'get_final_load_size' callback */ - H5B2__cache_hdr_verify_chksum, /* 'verify_chksum' callback */ - H5B2__cache_hdr_deserialize, /* 'deserialize' callback */ - H5B2__cache_hdr_image_len, /* 'image_len' callback */ - NULL, /* 'pre_serialize' callback */ - H5B2__cache_hdr_serialize, /* 'serialize' callback */ - H5B2__cache_hdr_notify, /* 'notify' callback */ - H5B2__cache_hdr_free_icr, /* 'free_icr' callback */ - NULL, /* 'fsf_size' callback */ + NULL, /* 'get_final_load_size' callback */ + H5B2__cache_hdr_verify_chksum, /* 'verify_chksum' callback */ + H5B2__cache_hdr_deserialize, /* 'deserialize' callback */ + H5B2__cache_hdr_image_len, /* 'image_len' callback */ + NULL, /* 'pre_serialize' callback */ + H5B2__cache_hdr_serialize, /* 'serialize' callback */ + H5B2__cache_hdr_notify, /* 'notify' callback */ + H5B2__cache_hdr_free_icr, /* 'free_icr' callback */ + NULL, /* 'fsf_size' callback */ }}; /* H5B2 inherits cache-like properties from H5AC */ const H5AC_class_t H5AC_BT2_INT[1] = {{ - H5AC_BT2_INT_ID, /* Metadata client ID */ - "v2 B-tree internal node", /* Metadata client name (for debugging) */ - H5FD_MEM_BTREE, /* File space memory type for client */ - H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ + H5AC_BT2_INT_ID, /* Metadata client ID */ + "v2 B-tree internal node", /* Metadata client name (for debugging) */ + H5FD_MEM_BTREE, /* File space memory type for client */ + H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ H5B2__cache_int_get_initial_load_size, /* 'get_initial_load_size' callback */ - NULL, /* 'get_final_load_size' callback */ - H5B2__cache_int_verify_chksum, /* 'verify_chksum' callback */ - H5B2__cache_int_deserialize, /* 'deserialize' callback */ - H5B2__cache_int_image_len, /* 'image_len' callback */ - NULL, /* 'pre_serialize' callback */ - H5B2__cache_int_serialize, /* 'serialize' callback */ - H5B2__cache_int_notify, /* 'notify' callback */ - H5B2__cache_int_free_icr, /* 'free_icr' callback */ - NULL, /* 'fsf_size' callback */ + NULL, /* 'get_final_load_size' callback */ + H5B2__cache_int_verify_chksum, /* 'verify_chksum' callback */ + H5B2__cache_int_deserialize, /* 'deserialize' callback */ + H5B2__cache_int_image_len, /* 'image_len' callback */ + NULL, /* 'pre_serialize' callback */ + H5B2__cache_int_serialize, /* 'serialize' callback */ + H5B2__cache_int_notify, /* 'notify' callback */ + H5B2__cache_int_free_icr, /* 'free_icr' callback */ + NULL, /* 'fsf_size' callback */ }}; /* H5B2 inherits cache-like properties from H5AC */ const H5AC_class_t H5AC_BT2_LEAF[1] = {{ - H5AC_BT2_LEAF_ID, /* Metadata client ID */ - "v2 B-tree leaf node", /* Metadata client name (for debugging) */ - H5FD_MEM_BTREE, /* File space memory type for client */ - H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ + H5AC_BT2_LEAF_ID, /* Metadata client ID */ + "v2 B-tree leaf node", /* Metadata client name (for debugging) */ + H5FD_MEM_BTREE, /* File space memory type for client */ + H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ H5B2__cache_leaf_get_initial_load_size, /* 'get_initial_load_size' callback */ - NULL, /* 'get_final_load_size' callback */ - H5B2__cache_leaf_verify_chksum, /* 'verify_chksum' callback */ - H5B2__cache_leaf_deserialize, /* 'deserialize' callback */ - H5B2__cache_leaf_image_len, /* 'image_len' callback */ - NULL, /* 'pre_serialize' callback */ - H5B2__cache_leaf_serialize, /* 'serialize' callback */ - H5B2__cache_leaf_notify, /* 'notify' callback */ - H5B2__cache_leaf_free_icr, /* 'free_icr' callback */ - NULL, /* 'fsf_size' callback */ + NULL, /* 'get_final_load_size' callback */ + H5B2__cache_leaf_verify_chksum, /* 'verify_chksum' callback */ + H5B2__cache_leaf_deserialize, /* 'deserialize' callback */ + H5B2__cache_leaf_image_len, /* 'image_len' callback */ + NULL, /* 'pre_serialize' callback */ + H5B2__cache_leaf_serialize, /* 'serialize' callback */ + H5B2__cache_leaf_notify, /* 'notify' callback */ + H5B2__cache_leaf_free_icr, /* 'free_icr' callback */ + NULL, /* 'fsf_size' callback */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5B2__cache_hdr_get_initial_load_size * @@ -193,7 +178,6 @@ H5B2__cache_hdr_get_initial_load_size(void *_udata, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5B2__cache_hdr_get_initial_load_size() */ - /*------------------------------------------------------------------------- * Function: H5B2__cache_hdr_verify_chksum * @@ -210,10 +194,10 @@ H5B2__cache_hdr_get_initial_load_size(void *_udata, size_t *image_len) static htri_t H5B2__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 @@ -223,13 +207,12 @@ H5B2__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) - ret_value = FALSE; + if (stored_chksum != computed_chksum) + ret_value = FALSE; FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__cache_hdr_verify_chksum() */ - /*------------------------------------------------------------------------- * Function: H5B2__cache_hdr_deserialize * @@ -244,17 +227,17 @@ H5B2__cache_hdr_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSE *------------------------------------------------------------------------- */ static void * -H5B2__cache_hdr_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, - void *_udata, hbool_t H5_ATTR_UNUSED *dirty) +H5B2__cache_hdr_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, void *_udata, + hbool_t H5_ATTR_UNUSED *dirty) { - H5B2_hdr_t *hdr = NULL; /* B-tree header */ + H5B2_hdr_t * hdr = NULL; /* B-tree header */ H5B2_hdr_cache_ud_t *udata = (H5B2_hdr_cache_ud_t *)_udata; - H5B2_create_t cparam; /* B-tree creation parameters */ - H5B2_subid_t id; /* ID of B-tree class, as found in file */ - uint16_t depth; /* Depth of B-tree */ - uint32_t stored_chksum; /* Stored metadata checksum value */ - const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ - H5B2_hdr_t *ret_value = NULL; /* Return value */ + H5B2_create_t cparam; /* B-tree creation parameters */ + H5B2_subid_t id; /* ID of B-tree class, as found in file */ + uint16_t depth; /* Depth of B-tree */ + uint32_t stored_chksum; /* Stored metadata checksum value */ + const uint8_t * image = (const uint8_t *)_image; /* Pointer into raw data buffer */ + H5B2_hdr_t * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -263,21 +246,21 @@ H5B2__cache_hdr_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, HDassert(udata); /* Allocate new B-tree header and reset cache info */ - if(NULL == (hdr = H5B2__hdr_alloc(udata->f))) + if (NULL == (hdr = H5B2__hdr_alloc(udata->f))) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "allocation failed for B-tree header") /* Magic number */ - if(HDmemcmp(image, H5B2_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) - HGOTO_ERROR(H5E_BTREE, H5E_BADVALUE, NULL, "wrong B-tree header signature") + if (HDmemcmp(image, H5B2_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) + HGOTO_ERROR(H5E_BTREE, H5E_BADVALUE, NULL, "wrong B-tree header signature") image += H5_SIZEOF_MAGIC; /* Version */ - if(*image++ != H5B2_HDR_VERSION) - HGOTO_ERROR(H5E_BTREE, H5E_BADRANGE, NULL, "wrong B-tree header version") + if (*image++ != H5B2_HDR_VERSION) + HGOTO_ERROR(H5E_BTREE, H5E_BADRANGE, NULL, "wrong B-tree header version") /* B-tree class */ id = (H5B2_subid_t)*image++; - if(id >= H5B2_NUM_BTREE_ID) + if (id >= H5B2_NUM_BTREE_ID) HGOTO_ERROR(H5E_BTREE, H5E_BADTYPE, NULL, "incorrect B-tree type") /* Node size (in bytes) */ @@ -308,7 +291,7 @@ H5B2__cache_hdr_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, /* Initialize B-tree header info */ cparam.cls = H5B2_client_class_g[id]; - if(H5B2__hdr_init(hdr, &cparam, udata->ctx_udata, depth) < 0) + if (H5B2__hdr_init(hdr, &cparam, udata->ctx_udata, depth) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, NULL, "can't initialize B-tree header info") /* Set the B-tree header's address */ @@ -321,14 +304,13 @@ H5B2__cache_hdr_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, ret_value = hdr; done: - if(!ret_value && hdr) - if(H5B2__hdr_free(hdr) < 0) + if (!ret_value && hdr) + if (H5B2__hdr_free(hdr) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTRELEASE, NULL, "can't release v2 B-tree header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__cache_hdr_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5B2__cache_hdr_image_len * @@ -344,7 +326,7 @@ done: static herr_t H5B2__cache_hdr_image_len(const void *_thing, size_t *image_len) { - const H5B2_hdr_t *hdr = (const H5B2_hdr_t *)_thing; /* Pointer to the B-tree header */ + const H5B2_hdr_t *hdr = (const H5B2_hdr_t *)_thing; /* Pointer to the B-tree header */ FUNC_ENTER_STATIC_NOERR @@ -358,7 +340,6 @@ H5B2__cache_hdr_image_len(const void *_thing, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5B2__cache_hdr_image_len() */ - /*------------------------------------------------------------------------- * Function: H5B2__cache_hdr_serialize * @@ -372,12 +353,11 @@ H5B2__cache_hdr_image_len(const void *_thing, size_t *image_len) *------------------------------------------------------------------------- */ static herr_t -H5B2__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, - void *_thing) +H5B2__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, void *_thing) { - H5B2_hdr_t *hdr = (H5B2_hdr_t *)_thing; /* Pointer to the B-tree header */ - uint8_t *image = (uint8_t *)_image; /* Pointer into raw data buffer */ - uint32_t metadata_chksum; /* Computed metadata checksum value */ + H5B2_hdr_t *hdr = (H5B2_hdr_t *)_thing; /* Pointer to the B-tree header */ + uint8_t * image = (uint8_t *)_image; /* Pointer into raw data buffer */ + uint32_t metadata_chksum; /* Computed metadata checksum value */ FUNC_ENTER_STATIC_NOERR @@ -429,7 +409,6 @@ H5B2__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED le FUNC_LEAVE_NOAPI(SUCCEED) } /* H5B2__cache_hdr_serialize() */ - /*------------------------------------------------------------------------- * Function: H5B2__cache_hdr_notify * @@ -445,8 +424,8 @@ H5B2__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED le static herr_t H5B2__cache_hdr_notify(H5AC_notify_action_t action, void *_thing) { - H5B2_hdr_t *hdr = (H5B2_hdr_t *)_thing; - herr_t ret_value = SUCCEED; + H5B2_hdr_t *hdr = (H5B2_hdr_t *)_thing; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -456,14 +435,14 @@ H5B2__cache_hdr_notify(H5AC_notify_action_t action, void *_thing) HDassert(hdr); /* Check if the file was opened with SWMR-write access */ - if(hdr->swmr_write) { - switch(action) { + if (hdr->swmr_write) { + switch (action) { case H5AC_NOTIFY_ACTION_AFTER_INSERT: - case H5AC_NOTIFY_ACTION_AFTER_LOAD: - /* do nothing */ + case H5AC_NOTIFY_ACTION_AFTER_LOAD: + /* do nothing */ break; - case H5AC_NOTIFY_ACTION_AFTER_FLUSH: + case H5AC_NOTIFY_ACTION_AFTER_FLUSH: /* Increment the shadow epoch, forcing new modifications to * internal and leaf nodes to create new shadow copies */ hdr->shadow_epoch++; @@ -475,39 +454,43 @@ H5B2__cache_hdr_notify(H5AC_notify_action_t action, void *_thing) case H5AC_NOTIFY_ACTION_CHILD_CLEANED: case H5AC_NOTIFY_ACTION_CHILD_UNSERIALIZED: case H5AC_NOTIFY_ACTION_CHILD_SERIALIZED: - /* do nothing */ + /* do nothing */ break; - case H5AC_NOTIFY_ACTION_BEFORE_EVICT: + case H5AC_NOTIFY_ACTION_BEFORE_EVICT: /* If hdr->parent != NULL, hdr->parent is used to destroy * the flush dependency before the header is evicted. */ - if(hdr->parent) { + if (hdr->parent) { /* Sanity check */ HDassert(hdr->top_proxy); - /* Destroy flush dependency on object header proxy */ - if(H5AC_proxy_entry_remove_child((H5AC_proxy_entry_t *)hdr->parent, (void *)hdr->top_proxy) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency between v2 B-tree and proxy") + /* Destroy flush dependency on object header proxy */ + if (H5AC_proxy_entry_remove_child((H5AC_proxy_entry_t *)hdr->parent, + (void *)hdr->top_proxy) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTUNDEPEND, FAIL, + "unable to destroy flush dependency between v2 B-tree and proxy") hdr->parent = NULL; - } /* end if */ + } /* end if */ /* Detach from 'top' proxy for extensible array */ - if(hdr->top_proxy) { - if(H5AC_proxy_entry_remove_child(hdr->top_proxy, hdr) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency between header and v2 B-tree 'top' proxy") + if (hdr->top_proxy) { + if (H5AC_proxy_entry_remove_child(hdr->top_proxy, hdr) < 0) + HGOTO_ERROR( + H5E_BTREE, H5E_CANTUNDEPEND, FAIL, + "unable to destroy flush dependency between header and v2 B-tree 'top' proxy") /* Don't reset hdr->top_proxy here, it's destroyed when the header is freed -QAK */ } /* end if */ - break; + break; default: #ifdef NDEBUG HGOTO_ERROR(H5E_BTREE, 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 */ else HDassert(NULL == hdr->parent); @@ -515,7 +498,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__cache_hdr_notify() */ - /*------------------------------------------------------------------------- * Function: H5B2__cache_hdr_free_icr * @@ -532,7 +514,7 @@ done: static herr_t H5B2__cache_hdr_free_icr(void *thing) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -540,14 +522,13 @@ H5B2__cache_hdr_free_icr(void *thing) HDassert(thing); /* Destroy v2 B-tree header */ - if(H5B2__hdr_free((H5B2_hdr_t *)thing) < 0) + if (H5B2__hdr_free((H5B2_hdr_t *)thing) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to free v2 B-tree header") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__cache_hdr_free_icr() */ - /*------------------------------------------------------------------------- * Function: H5B2__cache_int_get_initial_load_size * @@ -578,7 +559,6 @@ H5B2__cache_int_get_initial_load_size(void *_udata, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5B2__cache_int_get_initial_load_size() */ - /*------------------------------------------------------------------------- * Function: H5B2__cache_int_verify_chksum * @@ -595,12 +575,12 @@ H5B2__cache_int_get_initial_load_size(void *_udata, size_t *image_len) static htri_t H5B2__cache_int_verify_chksum(const void *_image, size_t H5_ATTR_UNUSED len, void *_udata) { - const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ - H5B2_internal_cache_ud_t *udata = (H5B2_internal_cache_ud_t *)_udata; /* Pointer to user data */ - size_t chk_size; /* Exact size of the node with checksum at the end */ - 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 */ + H5B2_internal_cache_ud_t *udata = (H5B2_internal_cache_ud_t *)_udata; /* Pointer to user data */ + size_t chk_size; /* Exact size of the node with checksum at the end */ + 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 @@ -609,18 +589,18 @@ H5B2__cache_int_verify_chksum(const void *_image, size_t H5_ATTR_UNUSED len, voi HDassert(udata); /* Internal node prefix header + records + child pointer triplets: size with checksum at the end */ - chk_size = H5B2_INT_PREFIX_SIZE + (udata->nrec * udata->hdr->rrec_size) + ((size_t)(udata->nrec + 1) * H5B2_INT_POINTER_SIZE(udata->hdr, udata->depth)); + chk_size = H5B2_INT_PREFIX_SIZE + (udata->nrec * udata->hdr->rrec_size) + + ((size_t)(udata->nrec + 1) * H5B2_INT_POINTER_SIZE(udata->hdr, udata->depth)); /* Get stored and computed checksums */ H5F_get_checksums(image, chk_size, &stored_chksum, &computed_chksum); - if(stored_chksum != computed_chksum) - ret_value = FALSE; + if (stored_chksum != computed_chksum) + ret_value = FALSE; FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__cache_int_verify_chksum() */ - /*------------------------------------------------------------------------- * Function: H5B2__cache_int_deserialize * @@ -635,18 +615,18 @@ H5B2__cache_int_verify_chksum(const void *_image, size_t H5_ATTR_UNUSED len, voi *------------------------------------------------------------------------- */ static void * -H5B2__cache_int_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, - void *_udata, hbool_t H5_ATTR_UNUSED *dirty) +H5B2__cache_int_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, void *_udata, + hbool_t H5_ATTR_UNUSED *dirty) { - H5B2_internal_cache_ud_t *udata = (H5B2_internal_cache_ud_t *)_udata; /* Pointer to user data */ - H5B2_internal_t *internal = NULL; /* Internal node read */ - const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ - uint8_t *native; /* Pointer to native record info */ - H5B2_node_ptr_t *int_node_ptr; /* Pointer to node pointer info */ - uint32_t stored_chksum; /* Stored metadata checksum value */ - unsigned u; /* Local index variable */ - H5B2_internal_t *ret_value = NULL; /* Return value */ - int node_nrec = 0; + H5B2_internal_cache_ud_t *udata = (H5B2_internal_cache_ud_t *)_udata; /* Pointer to user data */ + H5B2_internal_t * internal = NULL; /* Internal node read */ + const uint8_t * image = (const uint8_t *)_image; /* Pointer into raw data buffer */ + uint8_t * native; /* Pointer to native record info */ + H5B2_node_ptr_t * int_node_ptr; /* Pointer to node pointer info */ + uint32_t stored_chksum; /* Stored metadata checksum value */ + unsigned u; /* Local index variable */ + H5B2_internal_t * ret_value = NULL; /* Return value */ + int node_nrec = 0; FUNC_ENTER_STATIC @@ -655,48 +635,52 @@ H5B2__cache_int_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, HDassert(udata); /* Allocate new internal node and reset cache info */ - if(NULL == (internal = H5FL_CALLOC(H5B2_internal_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + if (NULL == (internal = H5FL_CALLOC(H5B2_internal_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Increment ref. count on B-tree header */ - if(H5B2__hdr_incr(udata->hdr) < 0) + if (H5B2__hdr_incr(udata->hdr) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINC, NULL, "can't increment ref. count on B-tree header") /* Share B-tree information */ - internal->hdr = udata->hdr; - internal->parent = udata->parent; + internal->hdr = udata->hdr; + internal->parent = udata->parent; internal->shadow_epoch = udata->hdr->shadow_epoch; /* Magic number */ - if(HDmemcmp(image, H5B2_INT_MAGIC, (size_t)H5_SIZEOF_MAGIC)) + if (HDmemcmp(image, H5B2_INT_MAGIC, (size_t)H5_SIZEOF_MAGIC)) HGOTO_ERROR(H5E_BTREE, H5E_BADVALUE, NULL, "wrong B-tree internal node signature") image += H5_SIZEOF_MAGIC; /* Version */ - if(*image++ != H5B2_INT_VERSION) + if (*image++ != H5B2_INT_VERSION) HGOTO_ERROR(H5E_BTREE, H5E_BADVALUE, NULL, "wrong B-tree internal node version") /* B-tree type */ - if(*image++ != (uint8_t)udata->hdr->cls->id) + if (*image++ != (uint8_t)udata->hdr->cls->id) HGOTO_ERROR(H5E_BTREE, H5E_BADTYPE, NULL, "incorrect B-tree type") /* Allocate space for the native keys in memory */ - if(NULL == (internal->int_native = (uint8_t *)H5FL_FAC_MALLOC(udata->hdr->node_info[udata->depth].nat_rec_fac))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for B-tree internal native keys") + if (NULL == + (internal->int_native = (uint8_t *)H5FL_FAC_MALLOC(udata->hdr->node_info[udata->depth].nat_rec_fac))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, + "memory allocation failed for B-tree internal native keys") /* Allocate space for the node pointers in memory */ - if(NULL == (internal->node_ptrs = (H5B2_node_ptr_t *)H5FL_FAC_MALLOC(udata->hdr->node_info[udata->depth].node_ptr_fac))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for B-tree internal node pointers") + if (NULL == (internal->node_ptrs = + (H5B2_node_ptr_t *)H5FL_FAC_MALLOC(udata->hdr->node_info[udata->depth].node_ptr_fac))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, + "memory allocation failed for B-tree internal node pointers") /* Set the number of records in the leaf & it's depth */ - internal->nrec = udata->nrec; + internal->nrec = udata->nrec; internal->depth = udata->depth; /* Deserialize records for internal node */ native = internal->int_native; - for(u = 0; u < internal->nrec; u++) { + for (u = 0; u < internal->nrec; u++) { /* Decode record */ - if((udata->hdr->cls->decode)(image, native, udata->hdr->cb_ctx) < 0) + if ((udata->hdr->cls->decode)(image, native, udata->hdr->cb_ctx) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, NULL, "unable to decode B-tree record") /* Move to next record */ @@ -706,13 +690,14 @@ H5B2__cache_int_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, /* Deserialize node pointers for internal node */ int_node_ptr = internal->node_ptrs; - for(u = 0; u < (unsigned)(internal->nrec + 1); u++) { + for (u = 0; u < (unsigned)(internal->nrec + 1); u++) { /* Decode node pointer */ H5F_addr_decode(udata->f, (const uint8_t **)&image, &(int_node_ptr->addr)); UINT64DECODE_VAR(image, node_nrec, udata->hdr->max_nrec_size); H5_CHECKED_ASSIGN(int_node_ptr->node_nrec, uint16_t, node_nrec, int); - if(udata->depth > 1) - UINT64DECODE_VAR(image, int_node_ptr->all_nrec, udata->hdr->node_info[udata->depth - 1].cum_max_nrec_size) + if (udata->depth > 1) + UINT64DECODE_VAR(image, int_node_ptr->all_nrec, + udata->hdr->node_info[udata->depth - 1].cum_max_nrec_size) else int_node_ptr->all_nrec = int_node_ptr->node_nrec; @@ -732,14 +717,13 @@ H5B2__cache_int_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, ret_value = internal; done: - if(!ret_value && internal) - if(H5B2__internal_free(internal) < 0) + if (!ret_value && internal) + if (H5B2__internal_free(internal) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, NULL, "unable to destroy B-tree internal node") FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__cache_int_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5B2__cache_int_image_len * @@ -755,7 +739,8 @@ done: static herr_t H5B2__cache_int_image_len(const void *_thing, size_t *image_len) { - const H5B2_internal_t *internal = (const H5B2_internal_t *)_thing; /* Pointer to the B-tree internal node */ + const H5B2_internal_t *internal = + (const H5B2_internal_t *)_thing; /* Pointer to the B-tree internal node */ FUNC_ENTER_STATIC_NOERR @@ -770,7 +755,6 @@ H5B2__cache_int_image_len(const void *_thing, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5B2__cache_int_image_len() */ - /*------------------------------------------------------------------------- * Function: H5B2__cache_int_serialize * @@ -784,16 +768,15 @@ H5B2__cache_int_image_len(const void *_thing, size_t *image_len) *------------------------------------------------------------------------- */ static herr_t -H5B2__cache_int_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, - void *_thing) +H5B2__cache_int_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, void *_thing) { - H5B2_internal_t *internal = (H5B2_internal_t *)_thing; /* Pointer to the B-tree internal node */ - uint8_t *image = (uint8_t *)_image; /* Pointer into raw data buffer */ - uint8_t *native; /* Pointer to native record info */ - H5B2_node_ptr_t *int_node_ptr; /* Pointer to node pointer info */ - uint32_t metadata_chksum; /* Computed metadata checksum value */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_internal_t *internal = (H5B2_internal_t *)_thing; /* Pointer to the B-tree internal node */ + uint8_t * image = (uint8_t *)_image; /* Pointer into raw data buffer */ + uint8_t * native; /* Pointer to native record info */ + H5B2_node_ptr_t *int_node_ptr; /* Pointer to node pointer info */ + uint32_t metadata_chksum; /* Computed metadata checksum value */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -817,9 +800,9 @@ H5B2__cache_int_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED le /* Serialize records for internal node */ native = internal->int_native; - for(u = 0; u < internal->nrec; u++) { + for (u = 0; u < internal->nrec; u++) { /* Encode record */ - if((internal->hdr->cls->encode)(image, native, internal->hdr->cb_ctx) < 0) + if ((internal->hdr->cls->encode)(image, native, internal->hdr->cb_ctx) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTENCODE, FAIL, "unable to encode B-tree record") /* Move to next record */ @@ -829,12 +812,13 @@ H5B2__cache_int_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED le /* Serialize node pointers for internal node */ int_node_ptr = internal->node_ptrs; - for(u = 0; u < (unsigned)(internal->nrec + 1); u++) { + for (u = 0; u < (unsigned)(internal->nrec + 1); u++) { /* Encode node pointer */ H5F_addr_encode(f, &image, int_node_ptr->addr); UINT64ENCODE_VAR(image, int_node_ptr->node_nrec, internal->hdr->max_nrec_size); - if(internal->depth > 1) - UINT64ENCODE_VAR(image, int_node_ptr->all_nrec, internal->hdr->node_info[internal->depth - 1].cum_max_nrec_size); + if (internal->depth > 1) + UINT64ENCODE_VAR(image, int_node_ptr->all_nrec, + internal->hdr->node_info[internal->depth - 1].cum_max_nrec_size); /* Move to next node pointer */ int_node_ptr++; @@ -856,7 +840,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__cache_int_serialize() */ - /*------------------------------------------------------------------------- * Function: H5B2__cache_int_notify * @@ -872,8 +855,8 @@ done: static herr_t H5B2__cache_int_notify(H5AC_notify_action_t action, void *_thing) { - H5B2_internal_t *internal = (H5B2_internal_t *)_thing; - herr_t ret_value = SUCCEED; + H5B2_internal_t *internal = (H5B2_internal_t *)_thing; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -884,34 +867,36 @@ H5B2__cache_int_notify(H5AC_notify_action_t action, void *_thing) HDassert(internal->hdr); /* Check if the file was opened with SWMR-write access */ - if(internal->hdr->swmr_write) { - switch(action) { + if (internal->hdr->swmr_write) { + 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(H5B2__create_flush_depend((H5AC_info_t *)internal->parent, (H5AC_info_t *)internal) < 0) + if (H5B2__create_flush_depend((H5AC_info_t *)internal->parent, (H5AC_info_t *)internal) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDEPEND, FAIL, "unable to create flush dependency") 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: case H5AC_NOTIFY_ACTION_CHILD_CLEANED: case H5AC_NOTIFY_ACTION_CHILD_UNSERIALIZED: case H5AC_NOTIFY_ACTION_CHILD_SERIALIZED: - /* do nothing */ - break; + /* do nothing */ + break; case H5AC_NOTIFY_ACTION_BEFORE_EVICT: - /* Destroy flush dependency on parent */ - if(H5B2__destroy_flush_depend((H5AC_info_t *)internal->parent, (H5AC_info_t *)internal) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency") + /* Destroy flush dependency on parent */ + if (H5B2__destroy_flush_depend((H5AC_info_t *)internal->parent, (H5AC_info_t *)internal) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency") /* Detach from 'top' proxy for v2 B-tree */ - if(internal->top_proxy) { - if(H5AC_proxy_entry_remove_child(internal->top_proxy, internal) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency between internal node and v2 B-tree 'top' proxy") + if (internal->top_proxy) { + if (H5AC_proxy_entry_remove_child(internal->top_proxy, internal) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTUNDEPEND, FAIL, + "unable to destroy flush dependency between internal node and v2 B-tree " + "'top' proxy") internal->top_proxy = NULL; } /* end if */ break; @@ -919,11 +904,11 @@ H5B2__cache_int_notify(H5AC_notify_action_t action, void *_thing) default: #ifdef NDEBUG HGOTO_ERROR(H5E_BTREE, 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 */ else HDassert(NULL == internal->top_proxy); @@ -931,7 +916,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__cache_int_notify() */ - /*------------------------------------------------------------------------- * Function: H5B2__cache_int_free_icr * @@ -948,8 +932,8 @@ done: static herr_t H5B2__cache_int_free_icr(void *_thing) { - H5B2_internal_t *internal = (H5B2_internal_t *)_thing; - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_internal_t *internal = (H5B2_internal_t *)_thing; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -957,14 +941,13 @@ H5B2__cache_int_free_icr(void *_thing) HDassert(internal); /* Release v2 B-tree internal node */ - if(H5B2__internal_free(internal) < 0) + if (H5B2__internal_free(internal) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to release v2 B-tree internal node") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__cache_int_free_icr() */ - /*------------------------------------------------------------------------- * Function: H5B2__cache_leaf_get_initial_load_size * @@ -995,7 +978,6 @@ H5B2__cache_leaf_get_initial_load_size(void *_udata, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5B2__cache_leaf_get_initial_load_size() */ - /*------------------------------------------------------------------------- * Function: H5B2__cache_leaf_verify_chksum * @@ -1012,12 +994,12 @@ H5B2__cache_leaf_get_initial_load_size(void *_udata, size_t *image_len) static htri_t H5B2__cache_leaf_verify_chksum(const void *_image, size_t H5_ATTR_UNUSED len, void *_udata) { - const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ - H5B2_internal_cache_ud_t *udata = (H5B2_internal_cache_ud_t *)_udata; /* Pointer to user data */ - size_t chk_size; /* Exact size of the node with checksum at the end */ - 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 */ + H5B2_internal_cache_ud_t *udata = (H5B2_internal_cache_ud_t *)_udata; /* Pointer to user data */ + size_t chk_size; /* Exact size of the node with checksum at the end */ + 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 @@ -1031,13 +1013,12 @@ H5B2__cache_leaf_verify_chksum(const void *_image, size_t H5_ATTR_UNUSED len, vo /* Get stored and computed checksums */ H5F_get_checksums(image, chk_size, &stored_chksum, &computed_chksum); - if(stored_chksum != computed_chksum) - ret_value = FALSE; + if (stored_chksum != computed_chksum) + ret_value = FALSE; FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__cache_leaf_verify_chksum() */ - /*------------------------------------------------------------------------- * Function: H5B2__cache_leaf_deserialize * @@ -1052,16 +1033,16 @@ H5B2__cache_leaf_verify_chksum(const void *_image, size_t H5_ATTR_UNUSED len, vo *------------------------------------------------------------------------- */ static void * -H5B2__cache_leaf_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, - void *_udata, hbool_t H5_ATTR_UNUSED *dirty) +H5B2__cache_leaf_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, void *_udata, + hbool_t H5_ATTR_UNUSED *dirty) { H5B2_leaf_cache_ud_t *udata = (H5B2_leaf_cache_ud_t *)_udata; - H5B2_leaf_t *leaf = NULL; /* Pointer to lead node loaded */ - const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ - uint8_t *native; /* Pointer to native keys */ - uint32_t stored_chksum; /* Stored metadata checksum value */ - unsigned u; /* Local index variable */ - H5B2_leaf_t *ret_value = NULL; /* Return value */ + H5B2_leaf_t * leaf = NULL; /* Pointer to lead node loaded */ + const uint8_t * image = (const uint8_t *)_image; /* Pointer into raw data buffer */ + uint8_t * native; /* Pointer to native keys */ + uint32_t stored_chksum; /* Stored metadata checksum value */ + unsigned u; /* Local index variable */ + H5B2_leaf_t * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -1070,43 +1051,43 @@ H5B2__cache_leaf_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, HDassert(udata); /* Allocate new leaf node and reset cache info */ - if(NULL == (leaf = H5FL_CALLOC(H5B2_leaf_t))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "memory allocation failed") + if (NULL == (leaf = H5FL_CALLOC(H5B2_leaf_t))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "memory allocation failed") /* Increment ref. count on B-tree header */ - if(H5B2__hdr_incr(udata->hdr) < 0) + if (H5B2__hdr_incr(udata->hdr) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINC, NULL, "can't increment ref. count on B-tree header") /* Share B-tree header information */ - leaf->hdr = udata->hdr; - leaf->parent = udata->parent; + leaf->hdr = udata->hdr; + leaf->parent = udata->parent; leaf->shadow_epoch = udata->hdr->shadow_epoch; /* Magic number */ - if(HDmemcmp(image, H5B2_LEAF_MAGIC, (size_t)H5_SIZEOF_MAGIC)) - HGOTO_ERROR(H5E_BTREE, H5E_BADVALUE, NULL, "wrong B-tree leaf node signature") + if (HDmemcmp(image, H5B2_LEAF_MAGIC, (size_t)H5_SIZEOF_MAGIC)) + HGOTO_ERROR(H5E_BTREE, H5E_BADVALUE, NULL, "wrong B-tree leaf node signature") image += H5_SIZEOF_MAGIC; /* Version */ - if(*image++ != H5B2_LEAF_VERSION) - HGOTO_ERROR(H5E_BTREE, H5E_BADRANGE, NULL, "wrong B-tree leaf node version") + if (*image++ != H5B2_LEAF_VERSION) + HGOTO_ERROR(H5E_BTREE, H5E_BADRANGE, NULL, "wrong B-tree leaf node version") /* B-tree type */ - if(*image++ != (uint8_t)udata->hdr->cls->id) + if (*image++ != (uint8_t)udata->hdr->cls->id) HGOTO_ERROR(H5E_BTREE, H5E_BADTYPE, NULL, "incorrect B-tree type") /* Allocate space for the native keys in memory */ - if(NULL == (leaf->leaf_native = (uint8_t *)H5FL_FAC_MALLOC(udata->hdr->node_info[0].nat_rec_fac))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "memory allocation failed for B-tree leaf native keys") + if (NULL == (leaf->leaf_native = (uint8_t *)H5FL_FAC_MALLOC(udata->hdr->node_info[0].nat_rec_fac))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "memory allocation failed for B-tree leaf native keys") /* Set the number of records in the leaf */ leaf->nrec = udata->nrec; /* Deserialize records for leaf node */ native = leaf->leaf_native; - for(u = 0; u < leaf->nrec; u++) { + for (u = 0; u < leaf->nrec; u++) { /* Decode record */ - if((udata->hdr->cls->decode)(image, native, udata->hdr->cb_ctx) < 0) + if ((udata->hdr->cls->decode)(image, native, udata->hdr->cb_ctx) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTENCODE, NULL, "unable to decode B-tree record") /* Move to next record */ @@ -1129,14 +1110,13 @@ H5B2__cache_leaf_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, ret_value = leaf; done: - if(!ret_value && leaf) - if(H5B2__leaf_free(leaf) < 0) + if (!ret_value && leaf) + if (H5B2__leaf_free(leaf) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, NULL, "unable to destroy B-tree leaf node") FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__cache_leaf_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5B2__cache_leaf_image_len * @@ -1152,7 +1132,7 @@ done: static herr_t H5B2__cache_leaf_image_len(const void *_thing, size_t *image_len) { - const H5B2_leaf_t *leaf = (const H5B2_leaf_t *)_thing; /* Pointer to the B-tree leaf node */ + const H5B2_leaf_t *leaf = (const H5B2_leaf_t *)_thing; /* Pointer to the B-tree leaf node */ FUNC_ENTER_STATIC_NOERR @@ -1167,7 +1147,6 @@ H5B2__cache_leaf_image_len(const void *_thing, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5B2__cache_leaf_image_len() */ - /*------------------------------------------------------------------------- * Function: H5B2__cache_leaf_serialize * @@ -1182,14 +1161,14 @@ H5B2__cache_leaf_image_len(const void *_thing, size_t *image_len) */ static herr_t H5B2__cache_leaf_serialize(const H5F_t H5_ATTR_UNUSED *f, void *_image, size_t H5_ATTR_UNUSED len, - void *_thing) + void *_thing) { - H5B2_leaf_t *leaf = (H5B2_leaf_t *)_thing; /* Pointer to the B-tree leaf node */ - uint8_t *image = (uint8_t *)_image; /* Pointer into raw data buffer */ - uint8_t *native; /* Pointer to native keys */ - uint32_t metadata_chksum; /* Computed metadata checksum value */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_leaf_t *leaf = (H5B2_leaf_t *)_thing; /* Pointer to the B-tree leaf node */ + uint8_t * image = (uint8_t *)_image; /* Pointer into raw data buffer */ + uint8_t * native; /* Pointer to native keys */ + uint32_t metadata_chksum; /* Computed metadata checksum value */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1213,9 +1192,9 @@ H5B2__cache_leaf_serialize(const H5F_t H5_ATTR_UNUSED *f, void *_image, size_t H /* Serialize records for leaf node */ native = leaf->leaf_native; - for(u = 0; u < leaf->nrec; u++) { + for (u = 0; u < leaf->nrec; u++) { /* Encode record */ - if((leaf->hdr->cls->encode)(image, native, leaf->hdr->cb_ctx) < 0) + if ((leaf->hdr->cls->encode)(image, native, leaf->hdr->cb_ctx) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTENCODE, FAIL, "unable to encode B-tree record") /* Move to next record */ @@ -1224,7 +1203,8 @@ H5B2__cache_leaf_serialize(const H5F_t H5_ATTR_UNUSED *f, void *_image, size_t H } /* end for */ /* Compute metadata checksum */ - metadata_chksum = H5_checksum_metadata(_image, (size_t)((const uint8_t *)image - (const uint8_t *)_image), 0); + metadata_chksum = + H5_checksum_metadata(_image, (size_t)((const uint8_t *)image - (const uint8_t *)_image), 0); /* Metadata checksum */ UINT32ENCODE(image, metadata_chksum); @@ -1239,7 +1219,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__cache_leaf_serialize() */ - /*------------------------------------------------------------------------- * Function: H5B2__cache_leaf_notify * @@ -1255,8 +1234,8 @@ done: static herr_t H5B2__cache_leaf_notify(H5AC_notify_action_t action, void *_thing) { - H5B2_leaf_t *leaf = (H5B2_leaf_t *)_thing; - herr_t ret_value = SUCCEED; + H5B2_leaf_t *leaf = (H5B2_leaf_t *)_thing; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -1267,16 +1246,16 @@ H5B2__cache_leaf_notify(H5AC_notify_action_t action, void *_thing) HDassert(leaf->hdr); /* Check if the file was opened with SWMR-write access */ - if(leaf->hdr->swmr_write) { - switch(action) { + if (leaf->hdr->swmr_write) { + 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(H5B2__create_flush_depend((H5AC_info_t *)leaf->parent, (H5AC_info_t *)leaf) < 0) + if (H5B2__create_flush_depend((H5AC_info_t *)leaf->parent, (H5AC_info_t *)leaf) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDEPEND, FAIL, "unable to create flush dependency") 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: @@ -1287,14 +1266,16 @@ H5B2__cache_leaf_notify(H5AC_notify_action_t action, void *_thing) break; case H5AC_NOTIFY_ACTION_BEFORE_EVICT: - /* Destroy flush dependency on parent */ - if(H5B2__destroy_flush_depend((H5AC_info_t *)leaf->parent, (H5AC_info_t *)leaf) < 0) + /* Destroy flush dependency on parent */ + if (H5B2__destroy_flush_depend((H5AC_info_t *)leaf->parent, (H5AC_info_t *)leaf) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency") /* Detach from 'top' proxy for v2 B-tree */ - if(leaf->top_proxy) { - if(H5AC_proxy_entry_remove_child(leaf->top_proxy, leaf) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency between leaf node and v2 B-tree 'top' proxy") + if (leaf->top_proxy) { + if (H5AC_proxy_entry_remove_child(leaf->top_proxy, leaf) < 0) + HGOTO_ERROR( + H5E_BTREE, H5E_CANTUNDEPEND, FAIL, + "unable to destroy flush dependency between leaf node and v2 B-tree 'top' proxy") leaf->top_proxy = NULL; } /* end if */ break; @@ -1302,11 +1283,11 @@ H5B2__cache_leaf_notify(H5AC_notify_action_t action, void *_thing) default: #ifdef NDEBUG HGOTO_ERROR(H5E_BTREE, 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 */ else HDassert(NULL == leaf->top_proxy); @@ -1314,7 +1295,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__cache_leaf_notify() */ - /*------------------------------------------------------------------------- * Function: H5B2__cache_leaf_free_icr * @@ -1331,8 +1311,8 @@ done: static herr_t H5B2__cache_leaf_free_icr(void *_thing) { - H5B2_leaf_t *leaf = (H5B2_leaf_t *)_thing; - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_leaf_t *leaf = (H5B2_leaf_t *)_thing; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1340,10 +1320,9 @@ H5B2__cache_leaf_free_icr(void *_thing) HDassert(leaf); /* Destroy v2 B-tree leaf node */ - if(H5B2__leaf_free(leaf) < 0) + if (H5B2__leaf_free(leaf) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to destroy B-tree leaf node") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__cache_leaf_free_icr() */ - |