summaryrefslogtreecommitdiffstats
path: root/src/H5Groot.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5Groot.c')
-rw-r--r--src/H5Groot.c155
1 files changed, 36 insertions, 119 deletions
diff --git a/src/H5Groot.c b/src/H5Groot.c
index 9d3fc6f..5d07142 100644
--- a/src/H5Groot.c
+++ b/src/H5Groot.c
@@ -76,99 +76,6 @@ H5G_rootof(H5F_t *f)
/*-------------------------------------------------------------------------
- * Function: H5G_root_ent_decode
- *
- * Purpose: Decodes the root group symbol table entry into the file
- * structure, and updates the root group address in the file
- * structure.
- *
- * Return: Success: Non-negative with *pp pointing to the first byte
- * following the symbol table entry.
- *
- * Failure: Negative
- *
- * Programmer: Quincey Koziol
- * koziol@ncsa.uiuc.edu
- * Sep 26 2005
- *
- *-------------------------------------------------------------------------
- */
-herr_t
-H5G_root_ent_decode(H5F_t *f, const uint8_t **pp)
-{
- const uint8_t *p_ret = *pp + H5G_SIZEOF_ENTRY(f);
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI(H5G_root_ent_decode, FAIL)
-
- /* check arguments */
- HDassert(f);
- HDassert(pp);
-
- /* Allocate space for the root group symbol table entry */
- HDassert(!f->shared->root_ent);
- if(NULL == (f->shared->root_ent = (H5G_entry_t *)H5MM_calloc(sizeof(H5G_entry_t))))
- HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "can't allocate space for symbol table entry")
-
- /* decode the root group symbol table entry */
- if(H5G_ent_decode_vec(f, pp, f->shared->root_ent, 1) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTDECODE, FAIL, "can't decode symbol table entry")
-
- /* Set the root group address to the correct value */
- f->shared->root_addr = f->shared->root_ent->header;
-
- /* Set decode pointer */
- *pp = p_ret;
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5G_root_ent_decode() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5G_root_ent_encode
- *
- * Purpose: Encodes the root group symbol table entry into the buffer
- * pointed to by *pp.
- *
- * Return: Success: Non-negative, with *pp pointing to the first byte
- * after the symbol table entry.
- *
- * Failure: Negative
- *
- * Programmer: Quincey Koziol
- * koziol@ncsa.uiuc.edu
- * Sep 26 2005
- *
- *-------------------------------------------------------------------------
- */
-herr_t
-H5G_root_ent_encode(H5F_t *f, uint8_t **pp)
-{
- uint8_t *p_ret = *pp + H5G_SIZEOF_ENTRY(f);
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI(H5G_root_ent_encode, FAIL)
-
- /* check arguments */
- HDassert(f);
- HDassert(f->shared);
- HDassert(f->shared->root_ent);
- HDassert(pp);
-
- /* Encode entry */
- if(H5G_ent_encode_vec(f, pp, f->shared->root_ent, 1) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTENCODE, FAIL, "can't encode symbol table entry")
-
- /* Set encode pointer */
- *pp = p_ret;
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5G_root_ent_encode() */
-
-
-/*-------------------------------------------------------------------------
* Function: H5G_mkroot
*
* Purpose: Creates a root group in an empty file and opens it. If a
@@ -191,12 +98,15 @@ H5G_mkroot(H5F_t *f, hid_t dxpl_id, hbool_t create_root)
{
H5G_loc_t root_loc; /* Root location information */
htri_t stab_exists = -1; /* Whether the symbol table exists */
- herr_t ret_value = SUCCEED; /* Return value */
+ hbool_t sblock_dirty = FALSE; /* Whether superblock was dirtied */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5G_mkroot, FAIL)
/* check args */
HDassert(f);
+ HDassert(f->shared);
+ HDassert(f->shared->sblock);
/* Check if the root group is already initialized */
if(f->shared->root_grp)
@@ -230,7 +140,6 @@ H5G_mkroot(H5F_t *f, hid_t dxpl_id, hbool_t create_root)
H5P_genplist_t *fc_plist; /* File creation property list */
H5O_ginfo_t ginfo; /* Group info parameters */
H5O_linfo_t linfo; /* Link info parameters */
- unsigned super_vers; /* Superblock version */
/* Get the file creation property list */
/* (Which is a sub-class of the group creation property class) */
@@ -245,34 +154,33 @@ H5G_mkroot(H5F_t *f, hid_t dxpl_id, hbool_t create_root)
if(H5P_get(fc_plist, H5G_CRT_LINK_INFO_NAME, &linfo) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get link info")
- /* Get the superblock version */
- if(H5P_get(fc_plist, H5F_CRT_SUPER_VERS_NAME, &super_vers) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get superblock version")
-
/* Create root group */
if(H5G_obj_create(f, dxpl_id, &ginfo, &linfo, f->shared->fcpl_id, root_loc.oloc/*out*/) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group entry")
if(1 != H5O_link(root_loc.oloc, 1, dxpl_id))
HGOTO_ERROR(H5E_SYM, H5E_LINKCOUNT, FAIL, "internal error (wrong link count)")
+ /* Mark superblock dirty, so root group info is flushed */
+ sblock_dirty = TRUE;
+
/* Create the root group symbol table entry */
- HDassert(!f->shared->root_ent);
- if(super_vers < HDF5_SUPERBLOCK_VERSION_2) {
+ HDassert(!f->shared->sblock->root_ent);
+ if(f->shared->sblock->super_vers < HDF5_SUPERBLOCK_VERSION_2) {
/* Allocate space for the root group symbol table entry */
- if(NULL == (f->shared->root_ent = (H5G_entry_t *) H5MM_calloc(sizeof(H5G_entry_t))))
+ if(NULL == (f->shared->sblock->root_ent = (H5G_entry_t *)H5MM_calloc(sizeof(H5G_entry_t))))
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "can't allocate space for symbol table entry")
/* Initialize the root group symbol table entry */
- f->shared->root_ent->dirty = TRUE;
- f->shared->root_ent->type = H5G_NOTHING_CACHED; /* We will cache the stab later */
- f->shared->root_ent->name_off = 0; /* No name (yet) */
- f->shared->root_ent->header = root_loc.oloc->addr;
- f->shared->root_ent->file = root_loc.oloc->file;
+ f->shared->sblock->root_ent->dirty = TRUE;
+ f->shared->sblock->root_ent->type = H5G_NOTHING_CACHED; /* We will cache the stab later */
+ f->shared->sblock->root_ent->name_off = 0; /* No name (yet) */
+ f->shared->sblock->root_ent->header = root_loc.oloc->addr;
+ f->shared->sblock->root_ent->file = root_loc.oloc->file;
} /* end if */
} /* end if */
else {
/* Create root group object location from f */
- root_loc.oloc->addr = f->shared->root_addr;
+ root_loc.oloc->addr = f->shared->sblock->root_addr;
root_loc.oloc->file = f;
/*
@@ -282,7 +190,7 @@ H5G_mkroot(H5F_t *f, hid_t dxpl_id, hbool_t create_root)
HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open root group")
/* Actions to take if the symbol table information is cached */
- if(f->shared->root_ent && f->shared->root_ent->type == H5G_CACHED_STAB) {
+ if(f->shared->sblock->root_ent && f->shared->sblock->root_ent->type == H5G_CACHED_STAB) {
/* Check for the situation where the symbol table is cached but does
* not exist. This can happen if, for example, an external link is
* added to the root group. */
@@ -291,7 +199,7 @@ H5G_mkroot(H5F_t *f, hid_t dxpl_id, hbool_t create_root)
/* Remove the cache if the stab does not exist */
if(!stab_exists)
- f->shared->root_ent->type = H5G_NOTHING_CACHED;
+ f->shared->sblock->root_ent->type = H5G_NOTHING_CACHED;
#ifndef H5_STRICT_FORMAT_CHECKS
/* If symbol table information is cached, check if we should replace the
* symbol table message with the cached symbol table information */
@@ -299,8 +207,8 @@ H5G_mkroot(H5F_t *f, hid_t dxpl_id, hbool_t create_root)
H5O_stab_t cached_stab;
/* Retrieve the cached symbol table information */
- cached_stab.btree_addr = f->shared->root_ent->cache.stab.btree_addr;
- cached_stab.heap_addr = f->shared->root_ent->cache.stab.heap_addr;
+ cached_stab.btree_addr = f->shared->sblock->root_ent->cache.stab.btree_addr;
+ cached_stab.heap_addr = f->shared->sblock->root_ent->cache.stab.heap_addr;
/* Check if the symbol table message is valid, and replace with the
* cached symbol table if necessary */
@@ -316,8 +224,8 @@ H5G_mkroot(H5F_t *f, hid_t dxpl_id, hbool_t create_root)
* present, so we don't need to check the superblock version. We do this if
* we have write access, the root entry has been allocated (i.e.
* super_vers < 2) and the stab info is not already cached. */
- if((H5F_INTENT(f) & H5F_ACC_RDWR) && stab_exists != FALSE && f->shared->root_ent
- && f->shared->root_ent->type != H5G_CACHED_STAB) {
+ if((H5F_INTENT(f) & H5F_ACC_RDWR) && stab_exists != FALSE && f->shared->sblock->root_ent
+ && f->shared->sblock->root_ent->type != H5G_CACHED_STAB) {
H5O_stab_t stab; /* Symbol table */
/* Check if the stab message exists. It's possible for the root group
@@ -332,9 +240,12 @@ H5G_mkroot(H5F_t *f, hid_t dxpl_id, hbool_t create_root)
HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "unable to read symbol table message")
/* Update the root group symbol table entry */
- f->shared->root_ent->type = H5G_CACHED_STAB;
- f->shared->root_ent->cache.stab.btree_addr = stab.btree_addr;
- f->shared->root_ent->cache.stab.heap_addr = stab.heap_addr;
+ f->shared->sblock->root_ent->type = H5G_CACHED_STAB;
+ f->shared->sblock->root_ent->cache.stab.btree_addr = stab.btree_addr;
+ f->shared->sblock->root_ent->cache.stab.heap_addr = stab.heap_addr;
+
+ /* Mark superblock dirty, so root group info is flushed */
+ sblock_dirty = TRUE;
} /* end if */
} /* end if */
@@ -347,7 +258,7 @@ H5G_mkroot(H5F_t *f, hid_t dxpl_id, hbool_t create_root)
* in the number of open objects in the file.
*/
HDassert((1 == f->nopen_objs) ||
- (2 == f->nopen_objs && HADDR_UNDEF != f->shared->extension_addr));
+ (2 == f->nopen_objs && HADDR_UNDEF != f->shared->sblock->ext_addr));
f->nopen_objs--;
done:
@@ -359,10 +270,16 @@ done:
f->shared->root_grp->shared = H5FL_FREE(H5G_shared_t, f->shared->root_grp->shared);
f->shared->root_grp = H5FL_FREE(H5G_t, f->shared->root_grp);
} /* end if */
- f->shared->root_ent = (H5G_entry_t *) H5MM_xfree(f->shared->root_ent);
+ if(f->shared->sblock)
+ f->shared->sblock->root_ent = (H5G_entry_t *)H5MM_xfree(f->shared->sblock->root_ent);
H5G_name_free(root_loc.path);
} /* end if */
+ /* Mark superblock dirty in cache, if necessary */
+ if(sblock_dirty)
+ if(H5AC_mark_pinned_or_protected_entry_dirty(f, f->shared->sblock) < 0)
+ HDONE_ERROR(H5E_FILE, H5E_CANTMARKDIRTY, FAIL, "unable to mark superblock as dirty")
+
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5G_mkroot() */