summaryrefslogtreecommitdiffstats
path: root/src/H5Fsuper.c
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2020-10-01 16:47:45 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2020-10-01 16:47:45 (GMT)
commit1ba1f2f3222cbe8df0bf601929a4bffd478d7e02 (patch)
treeae51dfc33cf40432dad25a5088767115a98f195e /src/H5Fsuper.c
parent8eef7d295cc3dd134aef0a826f1de4287629996d (diff)
downloadhdf5-1ba1f2f3222cbe8df0bf601929a4bffd478d7e02.zip
hdf5-1ba1f2f3222cbe8df0bf601929a4bffd478d7e02.tar.gz
hdf5-1ba1f2f3222cbe8df0bf601929a4bffd478d7e02.tar.bz2
Source formatted
Diffstat (limited to 'src/H5Fsuper.c')
-rw-r--r--src/H5Fsuper.c322
1 files changed, 154 insertions, 168 deletions
diff --git a/src/H5Fsuper.c b/src/H5Fsuper.c
index b032ca9..cb331d0 100644
--- a/src/H5Fsuper.c
+++ b/src/H5Fsuper.c
@@ -15,52 +15,45 @@
/* Module Setup */
/****************/
-#define H5F_PACKAGE /*suppress error about including H5Fpkg */
+#define H5F_PACKAGE /*suppress error about including H5Fpkg */
/* Interface initialization */
-#define H5_INTERFACE_INIT_FUNC H5F_init_super_interface
-
+#define H5_INTERFACE_INIT_FUNC H5F_init_super_interface
/***********/
/* Headers */
/***********/
-#include "H5private.h" /* Generic Functions */
-#include "H5ACprivate.h" /* Metadata cache */
-#include "H5Eprivate.h" /* Error handling */
-#include "H5Fpkg.h" /* File access */
-#include "H5FDprivate.h" /* File drivers */
-#include "H5Iprivate.h" /* IDs */
-#include "H5MMprivate.h" /* Memory management */
-#include "H5Pprivate.h" /* Property lists */
-#include "H5SMprivate.h" /* Shared Object Header Messages */
-
+#include "H5private.h" /* Generic Functions */
+#include "H5ACprivate.h" /* Metadata cache */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5Fpkg.h" /* File access */
+#include "H5FDprivate.h" /* File drivers */
+#include "H5Iprivate.h" /* IDs */
+#include "H5MMprivate.h" /* Memory management */
+#include "H5Pprivate.h" /* Property lists */
+#include "H5SMprivate.h" /* Shared Object Header Messages */
/****************/
/* Local Macros */
/****************/
-
/******************/
/* Local Typedefs */
/******************/
-
/********************/
/* Package Typedefs */
/********************/
-
/********************/
/* Local Prototypes */
/********************/
static herr_t H5F_super_ext_create(H5F_t *f, hid_t dxpl_id, H5O_loc_t *ext_ptr);
-
/*********************/
/* Package Variables */
/*********************/
-
/*****************************/
/* Library Private Variables */
/*****************************/
@@ -68,13 +61,10 @@ static herr_t H5F_super_ext_create(H5F_t *f, hid_t dxpl_id, H5O_loc_t *ext_ptr);
/* Declare a free list to manage the H5F_super_t struct */
H5FL_DEFINE(H5F_super_t);
-
/*******************/
/* Local Variables */
/*******************/
-
-
/*--------------------------------------------------------------------------
NAME
H5F_init_super_interface -- Initialize interface-specific information
@@ -96,7 +86,6 @@ H5F_init_super_interface(void)
FUNC_LEAVE_NOAPI(H5F_init())
} /* H5F_init_super_interface() */
-
/*-------------------------------------------------------------------------
* Function: H5F_super_ext_create
*
@@ -112,7 +101,7 @@ H5F_init_super_interface(void)
static herr_t
H5F_super_ext_create(H5F_t *f, hid_t dxpl_id, H5O_loc_t *ext_ptr)
{
- herr_t ret_value = SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
@@ -124,9 +113,11 @@ H5F_super_ext_create(H5F_t *f, hid_t dxpl_id, H5O_loc_t *ext_ptr)
HDassert(ext_ptr);
/* Check for older version of superblock format that can't support superblock extensions */
- if(f->shared->sblock->super_vers < HDF5_SUPERBLOCK_VERSION_2)
- HGOTO_ERROR(H5E_FILE, H5E_CANTCREATE, FAIL, "superblock extension not permitted with version %u of superblock", f->shared->sblock->super_vers)
- else if(H5F_addr_defined(f->shared->sblock->ext_addr))
+ if (f->shared->sblock->super_vers < HDF5_SUPERBLOCK_VERSION_2)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTCREATE, FAIL,
+ "superblock extension not permitted with version %u of superblock",
+ f->shared->sblock->super_vers)
+ else if (H5F_addr_defined(f->shared->sblock->ext_addr))
HGOTO_ERROR(H5E_FILE, H5E_CANTCREATE, FAIL, "superblock extension already exists?!?!")
else {
/* The superblock extension isn't actually a group, but the
@@ -138,7 +129,7 @@ H5F_super_ext_create(H5F_t *f, hid_t dxpl_id, H5O_loc_t *ext_ptr)
* extension.
*/
H5O_loc_reset(ext_ptr);
- if(H5O_create(f, dxpl_id, 0, (size_t)1, H5P_GROUP_CREATE_DEFAULT, ext_ptr) < 0)
+ if (H5O_create(f, dxpl_id, 0, (size_t)1, H5P_GROUP_CREATE_DEFAULT, ext_ptr) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTCREATE, FAIL, "unable to create superblock extension")
/* Record the address of the superblock extension */
@@ -149,7 +140,6 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5F_super_ext_create() */
-
/*-------------------------------------------------------------------------
* Function: H5F_super_ext_open
*
@@ -165,7 +155,7 @@ done:
herr_t
H5F_super_ext_open(H5F_t *f, haddr_t ext_addr, H5O_loc_t *ext_ptr)
{
- herr_t ret_value = SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
@@ -180,14 +170,13 @@ H5F_super_ext_open(H5F_t *f, haddr_t ext_addr, H5O_loc_t *ext_ptr)
ext_ptr->addr = ext_addr;
/* Open the superblock extension object header */
- if(H5O_open(ext_ptr) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open superblock extension")
+ if (H5O_open(ext_ptr) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open superblock extension")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5F_super_ext_open() */
-
/*-------------------------------------------------------------------------
* Function: H5F_super_ext_close
*
@@ -201,10 +190,9 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5F_super_ext_close(H5F_t *f, H5O_loc_t *ext_ptr, hid_t dxpl_id,
- hbool_t was_created)
+H5F_super_ext_close(H5F_t *f, H5O_loc_t *ext_ptr, hid_t dxpl_id, hbool_t was_created)
{
- herr_t ret_value = SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
@@ -213,19 +201,19 @@ H5F_super_ext_close(H5F_t *f, H5O_loc_t *ext_ptr, hid_t dxpl_id,
HDassert(ext_ptr);
/* Check if extension was created */
- if(was_created) {
+ if (was_created) {
/* Increment link count on superblock extension's object header */
- if(H5O_link(ext_ptr, 1, dxpl_id) < 0)
+ if (H5O_link(ext_ptr, 1, dxpl_id) < 0)
HGOTO_ERROR(H5E_FILE, H5E_LINKCOUNT, FAIL, "unable to increment hard link count")
/* Decrement refcount on superblock extension's object header in memory */
- if(H5O_dec_rc_by_loc(ext_ptr, dxpl_id) < 0)
- HDONE_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "unable to decrement refcount on superblock extension")
+ if (H5O_dec_rc_by_loc(ext_ptr, dxpl_id) < 0)
+ HDONE_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "unable to decrement refcount on superblock extension")
} /* end if */
/* Twiddle the number of open objects to avoid closing the file. */
f->nopen_objs++;
- if(H5O_close(ext_ptr) < 0)
+ if (H5O_close(ext_ptr) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, FAIL, "unable to close superblock extension")
f->nopen_objs--;
@@ -233,7 +221,6 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5F_super_ext_close() */
-
/*-------------------------------------------------------------------------
* Function: H5F_super_read
*
@@ -254,49 +241,49 @@ done:
herr_t
H5F_super_read(H5F_t *f, hid_t dxpl_id)
{
- H5P_genplist_t *dxpl; /* DXPL object */
- H5F_super_t * sblock = NULL; /* superblock structure */
- unsigned sblock_flags = H5AC__NO_FLAGS_SET; /* flags used in superblock unprotect call */
- haddr_t super_addr; /* Absolute address of superblock */
- H5AC_protect_t rw; /* read/write permissions for file */
- hbool_t dirtied = FALSE; /* Bool for sblock protect call */
- herr_t ret_value = SUCCEED; /* return value */
+ H5P_genplist_t *dxpl; /* DXPL object */
+ H5F_super_t * sblock = NULL; /* superblock structure */
+ unsigned sblock_flags = H5AC__NO_FLAGS_SET; /* flags used in superblock unprotect call */
+ haddr_t super_addr; /* Absolute address of superblock */
+ H5AC_protect_t rw; /* read/write permissions for file */
+ hbool_t dirtied = FALSE; /* Bool for sblock protect call */
+ herr_t ret_value = SUCCEED; /* return value */
FUNC_ENTER_NOAPI(FAIL)
/* Get the DXPL plist object for DXPL ID */
- if(NULL == (dxpl = (H5P_genplist_t *)H5I_object(dxpl_id)))
+ if (NULL == (dxpl = (H5P_genplist_t *)H5I_object(dxpl_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list")
/* Find the superblock */
- if(H5FD_locate_signature(f->shared->lf, dxpl, &super_addr) < 0)
+ if (H5FD_locate_signature(f->shared->lf, dxpl, &super_addr) < 0)
HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, FAIL, "unable to locate file signature")
- if(HADDR_UNDEF == super_addr)
+ if (HADDR_UNDEF == super_addr)
HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, FAIL, "file signature not found")
/* Check for userblock present */
- if(H5F_addr_gt(super_addr, 0)) {
+ if (H5F_addr_gt(super_addr, 0)) {
/* Set the base address for the file in the VFD now */
- if(H5FD_set_base_addr(f->shared->lf, super_addr) < 0)
+ if (H5FD_set_base_addr(f->shared->lf, super_addr) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "failed to set base address for file driver")
} /* end if */
/* Determine file intent for superblock protect */
- if(H5F_INTENT(f) & H5F_ACC_RDWR)
+ if (H5F_INTENT(f) & H5F_ACC_RDWR)
rw = H5AC_WRITE;
else
rw = H5AC_READ;
/* Look up the superblock */
- if(NULL == (sblock = (H5F_super_t *)H5AC_protect(f, dxpl_id, H5AC_SUPERBLOCK, (haddr_t)0, &dirtied, rw)))
+ if (NULL == (sblock = (H5F_super_t *)H5AC_protect(f, dxpl_id, H5AC_SUPERBLOCK, (haddr_t)0, &dirtied, rw)))
HGOTO_ERROR(H5E_CACHE, H5E_CANTPROTECT, FAIL, "unable to load superblock")
/* Mark the superblock dirty if it was modified during loading or VFD indicated to do so */
- if((H5AC_WRITE == rw) && (dirtied || H5F_HAS_FEATURE(f, H5FD_FEAT_DIRTY_SBLK_LOAD)))
+ if ((H5AC_WRITE == rw) && (dirtied || H5F_HAS_FEATURE(f, H5FD_FEAT_DIRTY_SBLK_LOAD)))
sblock_flags |= H5AC__DIRTIED_FLAG;
/* Pin the superblock in the cache */
- if(H5AC_pin_protected_entry(sblock) < 0)
+ if (H5AC_pin_protected_entry(sblock) < 0)
HGOTO_ERROR(H5E_FSPACE, H5E_CANTPIN, FAIL, "unable to pin superblock")
/* Set the pointer to the pinned superblock */
@@ -304,13 +291,12 @@ H5F_super_read(H5F_t *f, hid_t dxpl_id)
done:
/* Release the superblock */
- if(sblock && H5AC_unprotect(f, dxpl_id, H5AC_SUPERBLOCK, (haddr_t)0, sblock, sblock_flags) < 0)
+ if (sblock && H5AC_unprotect(f, dxpl_id, H5AC_SUPERBLOCK, (haddr_t)0, sblock, sblock_flags) < 0)
HDONE_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "unable to close superblock")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5F_super_read() */
-
/*-------------------------------------------------------------------------
* Function: H5F_super_init
*
@@ -330,62 +316,62 @@ done:
herr_t
H5F_super_init(H5F_t *f, hid_t dxpl_id)
{
- H5F_super_t *sblock = NULL; /* Superblock cache structure */
- hbool_t sblock_in_cache = FALSE; /* Whether the superblock has been inserted into the metadata cache */
- H5P_genplist_t *plist; /* File creation property list */
- hsize_t userblock_size; /* Size of userblock, in bytes */
- hsize_t superblock_size; /* Size of superblock, in bytes */
- size_t driver_size; /* Size of driver info block (bytes) */
- unsigned super_vers = HDF5_SUPERBLOCK_VERSION_DEF; /* Superblock version for file */
- H5O_loc_t ext_loc; /* Superblock extension object location */
- hbool_t need_ext; /* Whether the superblock extension is needed */
- hbool_t ext_created = FALSE; /* Whether the extension has been created */
- herr_t ret_value = SUCCEED; /* Return Value */
+ H5F_super_t *sblock = NULL; /* Superblock cache structure */
+ hbool_t sblock_in_cache = FALSE; /* Whether the superblock has been inserted into the metadata cache */
+ H5P_genplist_t *plist; /* File creation property list */
+ hsize_t userblock_size; /* Size of userblock, in bytes */
+ hsize_t superblock_size; /* Size of superblock, in bytes */
+ size_t driver_size; /* Size of driver info block (bytes) */
+ unsigned super_vers = HDF5_SUPERBLOCK_VERSION_DEF; /* Superblock version for file */
+ H5O_loc_t ext_loc; /* Superblock extension object location */
+ hbool_t need_ext; /* Whether the superblock extension is needed */
+ hbool_t ext_created = FALSE; /* Whether the extension has been created */
+ herr_t ret_value = SUCCEED; /* Return Value */
FUNC_ENTER_NOAPI(FAIL)
/* Allocate space for the superblock */
- if(NULL == (sblock = H5FL_CALLOC(H5F_super_t)))
+ if (NULL == (sblock = H5FL_CALLOC(H5F_super_t)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
/* Initialize various address information */
- sblock->base_addr = HADDR_UNDEF;
- sblock->ext_addr = HADDR_UNDEF;
+ sblock->base_addr = HADDR_UNDEF;
+ sblock->ext_addr = HADDR_UNDEF;
sblock->driver_addr = HADDR_UNDEF;
- sblock->root_addr = HADDR_UNDEF;
+ sblock->root_addr = HADDR_UNDEF;
/* Get the shared file creation property list */
- if(NULL == (plist = (H5P_genplist_t *)H5I_object(f->shared->fcpl_id)))
+ if (NULL == (plist = (H5P_genplist_t *)H5I_object(f->shared->fcpl_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list")
/* Initialize sym_leaf_k */
- if(H5P_get(plist, H5F_CRT_SYM_LEAF_NAME, &sblock->sym_leaf_k) < 0)
+ if (H5P_get(plist, H5F_CRT_SYM_LEAF_NAME, &sblock->sym_leaf_k) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get byte number for object size")
/* Initialize btree_k */
- if(H5P_get(plist, H5F_CRT_BTREE_RANK_NAME, &sblock->btree_k[0]) < 0)
+ if (H5P_get(plist, H5F_CRT_BTREE_RANK_NAME, &sblock->btree_k[0]) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get rank for btree internal nodes")
/* Bump superblock version if we are to use the latest version of the format */
- if(f->shared->latest_format)
+ if (f->shared->latest_format)
super_vers = HDF5_SUPERBLOCK_VERSION_LATEST;
/* Bump superblock version to create superblock extension for SOHM info */
- else if(f->shared->sohm_nindexes > 0)
+ else if (f->shared->sohm_nindexes > 0)
super_vers = HDF5_SUPERBLOCK_VERSION_2;
/* Check for non-default indexed storage B-tree internal 'K' value
* and set the version # of the superblock to 1 if it is a non-default
* value.
*/
- else if(sblock->btree_k[H5B_CHUNK_ID] != HDF5_BTREE_CHUNK_IK_DEF)
+ else if (sblock->btree_k[H5B_CHUNK_ID] != HDF5_BTREE_CHUNK_IK_DEF)
super_vers = HDF5_SUPERBLOCK_VERSION_1;
/* If a newer superblock version is required, set it here */
- if(super_vers != HDF5_SUPERBLOCK_VERSION_DEF) {
- H5P_genplist_t *c_plist; /* Property list */
+ if (super_vers != HDF5_SUPERBLOCK_VERSION_DEF) {
+ H5P_genplist_t *c_plist; /* Property list */
- if(NULL == (c_plist = (H5P_genplist_t *)H5I_object(f->shared->fcpl_id)))
+ if (NULL == (c_plist = (H5P_genplist_t *)H5I_object(f->shared->fcpl_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not property list")
- if(H5P_set(c_plist, H5F_CRT_SUPER_VERS_NAME, &super_vers) < 0)
+ if (H5P_set(c_plist, H5F_CRT_SUPER_VERS_NAME, &super_vers) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set superblock version")
} /* end if */
@@ -395,28 +381,29 @@ H5F_super_init(H5F_t *f, hid_t dxpl_id)
* base address is set to the same thing as the superblock for
* now.
*/
- if(H5P_get(plist, H5F_CRT_USER_BLOCK_NAME, &userblock_size) < 0)
+ if (H5P_get(plist, H5F_CRT_USER_BLOCK_NAME, &userblock_size) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get userblock size")
/* Sanity check the userblock size vs. the file's allocation alignment */
- if(userblock_size > 0) {
- if(userblock_size < f->shared->alignment)
+ if (userblock_size > 0) {
+ if (userblock_size < f->shared->alignment)
HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "userblock size must be > file object alignment")
- if(0 != (userblock_size % f->shared->alignment))
- HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "userblock size must be an integral multiple of file object alignment")
+ if (0 != (userblock_size % f->shared->alignment))
+ HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL,
+ "userblock size must be an integral multiple of file object alignment")
} /* end if */
- sblock->base_addr = userblock_size;
+ sblock->base_addr = userblock_size;
sblock->status_flags = 0;
/* Reserve space for the userblock */
- if(H5FD_set_eoa(f->shared->lf, H5FD_MEM_SUPER, userblock_size) < 0)
+ if (H5FD_set_eoa(f->shared->lf, H5FD_MEM_SUPER, userblock_size) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to set EOA value for userblock")
/* Set the base address for the file in the VFD now, after allocating
* space for userblock.
*/
- if(H5FD_set_base_addr(f->shared->lf, sblock->base_addr) < 0)
+ if (H5FD_set_base_addr(f->shared->lf, sblock->base_addr) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "failed to set base address for file driver")
/* Save a local copy of the superblock version number */
@@ -427,7 +414,7 @@ H5F_super_init(H5F_t *f, hid_t dxpl_id)
/* Compute the size of the driver information block */
H5_CHECKED_ASSIGN(driver_size, size_t, H5FD_sb_size(f->shared->lf), hsize_t);
- if(driver_size > 0) {
+ if (driver_size > 0) {
driver_size += H5F_DRVINFOBLOCK_HDR_SIZE;
/*
@@ -443,15 +430,15 @@ H5F_super_init(H5F_t *f, hid_t dxpl_id)
* superblock need to be at the beginning of the file and only the first
* allocation request is required to return memory at format address zero.
*/
- if(super_vers < HDF5_SUPERBLOCK_VERSION_2)
+ if (super_vers < HDF5_SUPERBLOCK_VERSION_2)
superblock_size += driver_size;
/* Reserve space in the file for the superblock, instead of allocating it */
- if(H5FD_set_eoa(f->shared->lf, H5FD_MEM_SUPER, superblock_size) < 0)
+ if (H5FD_set_eoa(f->shared->lf, H5FD_MEM_SUPER, superblock_size) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to set EOA value for superblock")
/* Insert superblock into cache, pinned */
- if(H5AC_insert_entry(f, dxpl_id, H5AC_SUPERBLOCK, (haddr_t)0, sblock, H5AC__PIN_ENTRY_FLAG) < 0)
+ if (H5AC_insert_entry(f, dxpl_id, H5AC_SUPERBLOCK, (haddr_t)0, sblock, H5AC__PIN_ENTRY_FLAG) < 0)
HGOTO_ERROR(H5E_CACHE, H5E_CANTINS, FAIL, "can't add superblock to cache")
sblock_in_cache = TRUE;
@@ -463,7 +450,7 @@ H5F_super_init(H5F_t *f, hid_t dxpl_id)
*/
/* Files with SOHM indices always need the superblock extension */
- if(f->shared->sohm_nindexes > 0) {
+ if (f->shared->sohm_nindexes > 0) {
HDassert(super_vers >= HDF5_SUPERBLOCK_VERSION_2);
need_ext = TRUE;
} /* end if */
@@ -471,14 +458,14 @@ H5F_super_init(H5F_t *f, hid_t dxpl_id)
* for the superblock extension, check for non-default values to store
* in it.
*/
- else if(super_vers >= HDF5_SUPERBLOCK_VERSION_2) {
+ else if (super_vers >= HDF5_SUPERBLOCK_VERSION_2) {
/* Check for non-default v1 B-tree 'K' values to store */
- if(sblock->btree_k[H5B_SNODE_ID] != HDF5_BTREE_SNODE_IK_DEF ||
- sblock->btree_k[H5B_CHUNK_ID] != HDF5_BTREE_CHUNK_IK_DEF ||
- sblock->sym_leaf_k != H5F_CRT_SYM_LEAF_DEF)
+ if (sblock->btree_k[H5B_SNODE_ID] != HDF5_BTREE_SNODE_IK_DEF ||
+ sblock->btree_k[H5B_CHUNK_ID] != HDF5_BTREE_CHUNK_IK_DEF ||
+ sblock->sym_leaf_k != H5F_CRT_SYM_LEAF_DEF)
need_ext = TRUE;
/* Check for driver info to store */
- else if(driver_size > 0)
+ else if (driver_size > 0)
need_ext = TRUE;
else
need_ext = FALSE;
@@ -487,7 +474,7 @@ H5F_super_init(H5F_t *f, hid_t dxpl_id)
need_ext = FALSE;
/* Create the superblock extension for "extra" superblock data, if necessary. */
- if(need_ext) {
+ if (need_ext) {
/* The superblock extension isn't actually a group, but the
* default group creation list should work fine.
* If we don't supply a size for the object header, HDF5 will
@@ -496,86 +483,88 @@ H5F_super_init(H5F_t *f, hid_t dxpl_id)
* be tuned if more information is added to the superblock
* extension.
*/
- if(H5F_super_ext_create(f, dxpl_id, &ext_loc) < 0)
+ if (H5F_super_ext_create(f, dxpl_id, &ext_loc) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTCREATE, FAIL, "unable to create superblock extension")
ext_created = TRUE;
/* Create the Shared Object Header Message table and register it with
* the metadata cache, if this file supports shared messages.
*/
- if(f->shared->sohm_nindexes > 0) {
+ if (f->shared->sohm_nindexes > 0) {
/* Initialize the shared message code & write the SOHM message to the extension */
- if(H5SM_init(f, plist, &ext_loc, dxpl_id) < 0)
+ if (H5SM_init(f, plist, &ext_loc, dxpl_id) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to create SOHM table")
} /* end if */
/* Check for non-default v1 B-tree 'K' values to store */
- if(sblock->btree_k[H5B_SNODE_ID] != HDF5_BTREE_SNODE_IK_DEF ||
- sblock->btree_k[H5B_CHUNK_ID] != HDF5_BTREE_CHUNK_IK_DEF ||
- sblock->sym_leaf_k != H5F_CRT_SYM_LEAF_DEF) {
- H5O_btreek_t btreek; /* v1 B-tree 'K' value message for superblock extension */
+ if (sblock->btree_k[H5B_SNODE_ID] != HDF5_BTREE_SNODE_IK_DEF ||
+ sblock->btree_k[H5B_CHUNK_ID] != HDF5_BTREE_CHUNK_IK_DEF ||
+ sblock->sym_leaf_k != H5F_CRT_SYM_LEAF_DEF) {
+ H5O_btreek_t btreek; /* v1 B-tree 'K' value message for superblock extension */
/* Write v1 B-tree 'K' value information to the superblock extension */
btreek.btree_k[H5B_CHUNK_ID] = sblock->btree_k[H5B_CHUNK_ID];
btreek.btree_k[H5B_SNODE_ID] = sblock->btree_k[H5B_SNODE_ID];
- btreek.sym_leaf_k = sblock->sym_leaf_k;
- if(H5O_msg_create(&ext_loc, H5O_BTREEK_ID, H5O_MSG_FLAG_CONSTANT | H5O_MSG_FLAG_DONTSHARE, H5O_UPDATE_TIME, &btreek, dxpl_id) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to update v1 B-tree 'K' value header message")
+ btreek.sym_leaf_k = sblock->sym_leaf_k;
+ if (H5O_msg_create(&ext_loc, H5O_BTREEK_ID, H5O_MSG_FLAG_CONSTANT | H5O_MSG_FLAG_DONTSHARE,
+ H5O_UPDATE_TIME, &btreek, dxpl_id) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL,
+ "unable to update v1 B-tree 'K' value header message")
} /* end if */
/* Check for driver info to store */
- if(driver_size > 0) {
- H5O_drvinfo_t drvinfo; /* Driver info */
- uint8_t dbuf[H5F_MAX_DRVINFOBLOCK_SIZE]; /* Driver info block encoding buffer */
+ if (driver_size > 0) {
+ H5O_drvinfo_t drvinfo; /* Driver info */
+ uint8_t dbuf[H5F_MAX_DRVINFOBLOCK_SIZE]; /* Driver info block encoding buffer */
/* Sanity check */
HDassert(driver_size <= H5F_MAX_DRVINFOBLOCK_SIZE);
/* Encode driver-specific data */
- if(H5FD_sb_encode(f->shared->lf, drvinfo.name, dbuf) < 0)
+ if (H5FD_sb_encode(f->shared->lf, drvinfo.name, dbuf) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to encode driver information")
/* Write driver info information to the superblock extension */
drvinfo.len = driver_size;
drvinfo.buf = dbuf;
- if(H5O_msg_create(&ext_loc, H5O_DRVINFO_ID, H5O_MSG_FLAG_DONTSHARE, H5O_UPDATE_TIME, &drvinfo, dxpl_id) < 0)
+ if (H5O_msg_create(&ext_loc, H5O_DRVINFO_ID, H5O_MSG_FLAG_DONTSHARE, H5O_UPDATE_TIME, &drvinfo,
+ dxpl_id) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to update driver info header message")
} /* end if */
- } /* end if */
+ } /* end if */
done:
/* Close superblock extension, if it was created */
- if(ext_created && H5F_super_ext_close(f, &ext_loc, dxpl_id, ext_created) < 0)
+ if (ext_created && H5F_super_ext_close(f, &ext_loc, dxpl_id, ext_created) < 0)
HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "unable to close file's superblock extension")
/* Cleanup on failure */
- if(ret_value < 0) {
+ if (ret_value < 0) {
/* Check if the superblock has been allocated yet */
- if(sblock) {
+ if (sblock) {
/* Check if we've cached it already */
- if(sblock_in_cache) {
+ if (sblock_in_cache) {
/* Unpin superblock in cache */
- if(H5AC_unpin_entry(sblock) < 0)
+ if (H5AC_unpin_entry(sblock) < 0)
HDONE_ERROR(H5E_FILE, H5E_CANTUNPIN, FAIL, "unable to unpin superblock")
/* Evict the superblock from the cache */
- if(H5AC_expunge_entry(f, dxpl_id, H5AC_SUPERBLOCK, (haddr_t)0, H5AC__NO_FLAGS_SET) < 0)
+ if (H5AC_expunge_entry(f, dxpl_id, H5AC_SUPERBLOCK, (haddr_t)0, H5AC__NO_FLAGS_SET) < 0)
HDONE_ERROR(H5E_FILE, H5E_CANTEXPUNGE, FAIL, "unable to expunge superblock")
} /* end if */
else
/* Free superblock */
- if(H5F_super_free(sblock) < 0)
- HDONE_ERROR(H5E_FILE, H5E_CANTFREE, FAIL, "unable to destroy superblock")
+ if (H5F_super_free(sblock) < 0)
+ HDONE_ERROR(H5E_FILE, H5E_CANTFREE, FAIL, "unable to destroy superblock")
/* Reset variables in file structure */
f->shared->sblock = NULL;
} /* end if */
- } /* end if */
+ } /* end if */
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5F_super_init() */
-
/*-------------------------------------------------------------------------
* Function: H5F_super_dirty
*
@@ -592,7 +581,7 @@ done:
herr_t
H5F_super_dirty(H5F_t *f)
{
- herr_t ret_value = SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
@@ -602,14 +591,13 @@ H5F_super_dirty(H5F_t *f)
HDassert(f->shared->sblock);
/* Mark superblock dirty in cache, so change to EOA will get encoded */
- if(H5AC_mark_entry_dirty(f->shared->sblock) < 0)
+ if (H5AC_mark_entry_dirty(f->shared->sblock) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTMARKDIRTY, FAIL, "unable to mark superblock as dirty")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5F_super_dirty() */
-
/*-------------------------------------------------------------------------
* Function: H5F_super_free
*
@@ -640,7 +628,6 @@ H5F_super_free(H5F_super_t *sblock)
FUNC_LEAVE_NOAPI(SUCCEED)
} /* H5F_super_free() */
-
/*-------------------------------------------------------------------------
* Function: H5F_super_size
*
@@ -657,7 +644,7 @@ H5F_super_free(H5F_super_t *sblock)
herr_t
H5F_super_size(H5F_t *f, hid_t dxpl_id, hsize_t *super_size, hsize_t *super_ext_size)
{
- herr_t ret_value = SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
@@ -667,14 +654,14 @@ H5F_super_size(H5F_t *f, hid_t dxpl_id, hsize_t *super_size, hsize_t *super_ext_
HDassert(f->shared->sblock);
/* Set the superblock size */
- if(super_size)
- *super_size = (hsize_t)H5F_SUPERBLOCK_SIZE(f->shared->sblock->super_vers, f);
+ if (super_size)
+ *super_size = (hsize_t)H5F_SUPERBLOCK_SIZE(f->shared->sblock->super_vers, f);
/* Set the superblock extension size */
- if(super_ext_size) {
- if(H5F_addr_defined(f->shared->sblock->ext_addr)) {
- H5O_loc_t ext_loc; /* "Object location" for superblock extension */
- H5O_hdr_info_t hdr_info; /* Object info for superblock extension */
+ if (super_ext_size) {
+ if (H5F_addr_defined(f->shared->sblock->ext_addr)) {
+ H5O_loc_t ext_loc; /* "Object location" for superblock extension */
+ H5O_hdr_info_t hdr_info; /* Object info for superblock extension */
/* Set up "fake" object location for superblock extension */
H5O_loc_reset(&ext_loc);
@@ -682,7 +669,7 @@ H5F_super_size(H5F_t *f, hid_t dxpl_id, hsize_t *super_size, hsize_t *super_ext_
ext_loc.addr = f->shared->sblock->ext_addr;
/* Get object header info for superblock extension */
- if(H5O_get_hdr_info(&ext_loc, dxpl_id, &hdr_info) < 0)
+ if (H5O_get_hdr_info(&ext_loc, dxpl_id, &hdr_info) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to retrieve superblock extension info")
/* Set the superblock extension size */
@@ -697,7 +684,6 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5F_super_size() */
-
/*-------------------------------------------------------------------------
* Function: H5F_super_ext_write_msg()
*
@@ -712,11 +698,11 @@ done:
herr_t
H5F_super_ext_write_msg(H5F_t *f, hid_t dxpl_id, unsigned id, void *mesg, hbool_t may_create)
{
- hbool_t ext_created = FALSE; /* Whether superblock extension was created */
- hbool_t ext_opened = FALSE; /* Whether superblock extension was opened */
- H5O_loc_t ext_loc; /* "Object location" for superblock extension */
- htri_t status; /* Indicate whether the message exists or not */
- herr_t ret_value = SUCCEED; /* Return value */
+ hbool_t ext_created = FALSE; /* Whether superblock extension was created */
+ hbool_t ext_opened = FALSE; /* Whether superblock extension was opened */
+ H5O_loc_t ext_loc; /* "Object location" for superblock extension */
+ htri_t status; /* Indicate whether the message exists or not */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
@@ -726,50 +712,50 @@ H5F_super_ext_write_msg(H5F_t *f, hid_t dxpl_id, unsigned id, void *mesg, hbool_
HDassert(f->shared->sblock);
/* Open/create the superblock extension object header */
- if(H5F_addr_defined(f->shared->sblock->ext_addr)) {
- if(H5F_super_ext_open(f, f->shared->sblock->ext_addr, &ext_loc) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTOPENOBJ, FAIL, "unable to open file's superblock extension")
+ if (H5F_addr_defined(f->shared->sblock->ext_addr)) {
+ if (H5F_super_ext_open(f, f->shared->sblock->ext_addr, &ext_loc) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTOPENOBJ, FAIL, "unable to open file's superblock extension")
} /* end if */
else {
HDassert(may_create);
- if(H5F_super_ext_create(f, dxpl_id, &ext_loc) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTCREATE, FAIL, "unable to create file's superblock extension")
+ if (H5F_super_ext_create(f, dxpl_id, &ext_loc) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTCREATE, FAIL, "unable to create file's superblock extension")
ext_created = TRUE;
} /* end else */
HDassert(H5F_addr_defined(ext_loc.addr));
ext_opened = TRUE;
/* Check if message with ID does not exist in the object header */
- if((status = H5O_msg_exists(&ext_loc, id, dxpl_id)) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to check object header for message or message exists")
+ if ((status = H5O_msg_exists(&ext_loc, id, dxpl_id)) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL,
+ "unable to check object header for message or message exists")
/* Check for creating vs. writing */
- if(may_create) {
- if(status)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "Message should not exist")
+ if (may_create) {
+ if (status)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "Message should not exist")
- /* Create the message with ID in the superblock extension */
- if(H5O_msg_create(&ext_loc, id, H5O_MSG_FLAG_DONTSHARE, H5O_UPDATE_TIME, mesg, dxpl_id) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to create the message in object header")
+ /* Create the message with ID in the superblock extension */
+ if (H5O_msg_create(&ext_loc, id, H5O_MSG_FLAG_DONTSHARE, H5O_UPDATE_TIME, mesg, dxpl_id) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to create the message in object header")
} /* end if */
else {
- if(!status)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "Message should exist")
+ if (!status)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "Message should exist")
- /* Update the message with ID in the superblock extension */
- if(H5O_msg_write(&ext_loc, id, H5O_MSG_FLAG_DONTSHARE, H5O_UPDATE_TIME, mesg, dxpl_id) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to write the message in object header")
+ /* Update the message with ID in the superblock extension */
+ if (H5O_msg_write(&ext_loc, id, H5O_MSG_FLAG_DONTSHARE, H5O_UPDATE_TIME, mesg, dxpl_id) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to write the message in object header")
} /* end else */
done:
/* Close the superblock extension, if it was opened */
- if(ext_opened && H5F_super_ext_close(f, &ext_loc, dxpl_id, ext_created) < 0)
+ if (ext_opened && H5F_super_ext_close(f, &ext_loc, dxpl_id, ext_created) < 0)
HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "unable to close file's superblock extension")
/* Mark superblock dirty in cache, if superblock extension was created */
- if(ext_created && H5AC_mark_entry_dirty(f->shared->sblock) < 0)
+ if (ext_created && H5AC_mark_entry_dirty(f->shared->sblock) < 0)
HDONE_ERROR(H5E_FILE, H5E_CANTMARKDIRTY, FAIL, "unable to mark superblock as dirty")
FUNC_LEAVE_NOAPI(ret_value)
} /* H5F_super_ext_write_msg() */
-