diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/H5AC.c | 236 | ||||
-rw-r--r-- | src/H5ACprivate.h | 23 | ||||
-rw-r--r-- | src/H5B.c | 42 | ||||
-rw-r--r-- | src/H5Gnode.c | 18 | ||||
-rw-r--r-- | src/H5HG.c | 396 | ||||
-rw-r--r-- | src/H5HGdbg.c | 6 | ||||
-rw-r--r-- | src/H5HL.c | 180 | ||||
-rw-r--r-- | src/H5HLdbg.c | 6 | ||||
-rw-r--r-- | src/H5O.c | 24 | ||||
-rw-r--r-- | src/H5T.c | 1 | ||||
-rw-r--r-- | src/Makefile.in | 3 |
11 files changed, 230 insertions, 705 deletions
@@ -466,231 +466,6 @@ done: /*------------------------------------------------------------------------- - * Function: H5AC_find - * - * Purpose: Given an object type and the address at which that object - * is located in the file, return a pointer to the object. - * The optional UDATA1 and UDATA2 structures are passed down to - * the function that is responsible for loading the object into - * memory. - * - * The returned pointer is guaranteed to be valid until the next - * call to an H5AC function (if you want a pointer which is valid - * indefinately then see H5AC_protect()). - * - * If H5AC_DEBUG is defined then this function also - * checks that the requested object is not currently - * protected since it is illegal to modify a protected object - * except through the pointer returned by H5AC_protect(). - * - * Return: Success: Pointer to the object. The pointer is - * valid until some other cache function - * is called. - * - * Failure: NULL - * - * Programmer: Robb Matzke - * matzke@llnl.gov - * Jul 9 1997 - * - * Modifications: - * - * Robb Matzke, 4 Aug 1997 - * Fails immediately if the cached object is at the correct address - * but is of the wrong type. This happens if the caller doesn't know - * what type of object is at the address and calls this function with - * various type identifiers until one succeeds (cf., the debugger). - * - * Robb Matzke, 30 Oct 1997 - * Keeps track of hits, misses, and flushes per object type so we have - * some cache performance diagnostics. - * - * Robb Matzke, 1999-07-27 - * The ADDR argument is passed by value. - * - *------------------------------------------------------------------------- - */ -void * -H5AC_find(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t addr, - const void *udata1, void *udata2) -{ - unsigned idx; - void *thing; - H5AC_flush_func_t flush; - H5AC_info_t **info; -#ifdef H5_HAVE_PARALLEL - H5AC_info_t **dinfo = NULL; -#endif /* H5_HAVE_PARALLEL */ - H5AC_t *cache; - void *ret_value; /* Return value */ - - FUNC_ENTER_NOAPI(H5AC_find, NULL); - - assert(f); - assert(f->shared->cache); - assert(type); - assert(type->load); - assert(type->flush); - assert(H5F_addr_defined(addr)); - - /* Get local pointers to the file's cache information */ - idx = H5AC_HASH(f, addr); - cache = f->shared->cache; - info = cache->slot + idx; - -#ifdef H5_HAVE_PARALLEL - /* If MPIO, MPIPOSIX, or FPHDF5 is used, do special parallel I/O actions */ - if(IS_H5FD_MPI(f)) { - H5AC_dest_func_t dest; - - /* Get local pointer to file's dirty cache information */ - dinfo = cache->dslot + idx; - - /* Check if the cache has 'held' information for this cache slot */ - if (*dinfo) { - /* Sanity check that the 'clean' item is really clean */ - assert(*info); - assert((*info)->dirty==0); - - /* Destroy 'current' information */ - dest = (*info)->type->dest; - if ((dest)(f, (*info))<0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFREE, NULL, "unable to free cached object"); - - /* Restore 'held' information back to 'current' information */ - (*info)=(*dinfo); - - /* Clear 'held' information */ - (*dinfo)=NULL; - -#ifdef H5AC_DEBUG - cache->diagnostics[type->id].nrestores++; -#endif /* H5AC_DEBUG */ - } /* end if */ - } /* end if */ -#endif /* H5_HAVE_PARALLEL */ - - /* - * Return right away if the item is in the cache. - */ - if ((*info) && H5F_addr_eq(addr,(*info)->addr) -#ifdef H5AC_DEBUG - && (*info)->type==type -#endif /* H5AC_DEBUG */ - ) { -#ifndef H5AC_DEBUG - /* Sanity check that the object in the cache is the correct type */ - assert((*info)->type==type); -#endif /* H5AC_DEBUG */ - -#ifdef H5AC_DEBUG - cache->diagnostics[type->id].nhits++; -#endif /* H5AC_DEBUG */ - HGOTO_DONE(*info); - } -#ifdef H5AC_DEBUG - cache->diagnostics[type->id].nmisses++; -#endif /* H5AC_DEBUG */ - -#ifdef H5AC_DEBUG - /* - * Check that the requested thing isn't protected, for protected things - * can only be modified through the pointer already handed out by the - * H5AC_protect() function. - */ - { - H5AC_prot_t *prot = NULL; - int i; - - prot = cache->prot + idx; - for (i = 0; i < prot->nprots; i++) { - assert(H5F_addr_ne(addr, prot->slot[i]->addr)); - } - } -#endif /* H5AC_DEBUG */ - - /* - * Load a new thing. If it can't be loaded, then return an error - * without preempting anything. - */ - if (NULL == (thing = (type->load)(f, dxpl_id, addr, udata1, udata2))) - HGOTO_ERROR(H5E_CACHE, H5E_CANTLOAD, NULL, "unable to load object"); - -#ifdef H5_HAVE_PARALLEL - /* If MPIO, MPIPOSIX, or FPHDF5 is used, do special parallel I/O actions */ - if(IS_H5FD_MPI(f)) { - H5P_genplist_t *dxpl; /* Dataset transfer property list */ - H5FD_mpio_xfer_t xfer_mode; /* I/O transfer mode property value */ - - /* Get the dataset transfer property list */ - if (NULL == (dxpl = H5I_object(dxpl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a dataset creation property list"); - - /* Get the transfer mode property */ - if(H5P_get(dxpl, H5D_XFER_IO_XFER_MODE_NAME, &xfer_mode) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't retrieve xfer mode"); - - /* Make certain there is no 'held' info for this slot */ - assert((*dinfo)==NULL); - - /* Must be using collective I/O to flush metadata in parallel */ - if(xfer_mode==H5FD_MPIO_INDEPENDENT) { - /* Check if there is dirty metadata in this slot */ - if((*info) && (*info)->dirty) { - /* 'Hold' the current metadata for later */ - (*dinfo)=(*info); - - /* Reset the 'current' metadata, so it doesn't get flushed */ - (*info)=NULL; - -#ifdef H5AC_DEBUG - cache->diagnostics[(*dinfo)->type->id].nholds++; -#endif /* H5AC_DEBUG */ - } /* end if */ - } /* end else */ - } /* end if */ -#endif /* H5_HAVE_PARALLEL */ - - /* - * Flush & destroy the previous cache entry if there is one. - */ - if (*info) { -#ifdef H5AC_DEBUG - H5AC_subid_t type_id=(*info)->type->id; /* Remember this for later */ -#endif /* H5AC_DEBUG */ - - flush = (*info)->type->flush; - if ( (flush)(f, dxpl_id, TRUE, (*info)->addr, (*info)) < 0) { - /* - * The old thing could not be removed from the stack. - * Release the new thing and fail. - */ - if ((type->dest)(f, thing) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, NULL, "unable to destroy just-loaded object"); - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, NULL, "unable to flush existing cached object"); - } -#ifdef H5AC_DEBUG - cache->diagnostics[type_id].nflushes++; -#endif /* H5AC_DEBUG */ - } /* end if */ - - /* - * Make the cache point to the new thing. - */ - (*info)=thing; - (*info)->type = type; - (*info)->addr = addr; - assert((*info)->dirty==0); /* Should be clean after being loaded */ - - /* Set the return value */ - ret_value=thing; - -done: - FUNC_LEAVE_NOAPI(ret_value); -} - - -/*------------------------------------------------------------------------- * Function: H5AC_compare * * Purpose: Compare two hash entries by address. Unused entries are @@ -1419,8 +1194,15 @@ done: *------------------------------------------------------------------------- */ void * -H5AC_protect(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t addr, - const void *udata1, void *udata2) +H5AC_protect(H5F_t *f, + hid_t dxpl_id, + const H5AC_class_t *type, + haddr_t addr, + const void *udata1, + void *udata2, + H5AC_protect_t + UNUSED + rw) { int idx; void *thing=NULL; diff --git a/src/H5ACprivate.h b/src/H5ACprivate.h index dbe4ec9..7491f18 100644 --- a/src/H5ACprivate.h +++ b/src/H5ACprivate.h @@ -29,7 +29,7 @@ #ifndef _H5ACprivate_H #define _H5ACprivate_H -#include "H5ACpublic.h" /*public prototypes */ +#include "H5ACpublic.h" /*public prototypes */ /* Pivate headers needed by this header */ #include "H5private.h" /* Generic Functions */ @@ -101,6 +101,20 @@ typedef struct H5AC_info_t { } H5AC_info_t; typedef H5AC_info_t *H5AC_info_ptr_t; /* Typedef for free lists */ +/*===----------------------------------------------------------------------=== + * Protect Types + *===----------------------------------------------------------------------=== + * + * These are for the wrapper functions to H5AC_protect. They specify what + * type of operation you're planning on doing to the metadata. The + * Flexible Parallel HDF5 locking can then act accordingly. + */ + +typedef enum H5AC_protect_t { + H5AC_WRITE, /* Protect object for writing */ + H5AC_READ /* Protect object for reading */ +} H5AC_protect_t; + /* Typedef for metadata cache (defined in H5AC.c) */ typedef struct H5AC_t H5AC_t; @@ -135,12 +149,11 @@ H5_DLL herr_t H5AC_init(void); H5_DLL herr_t H5AC_create(H5F_t *f, int size_hint); H5_DLL herr_t H5AC_set(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t addr, void *thing); -H5_DLL void *H5AC_protect(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t addr, - const void *udata1, void *udata2); +H5_DLL void *H5AC_protect(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, + haddr_t addr, const void *udata1, void *udata2, + H5AC_protect_t rw); H5_DLL herr_t H5AC_unprotect(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t addr, void *thing, hbool_t deleted); -H5_DLL void *H5AC_find(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, - haddr_t addr, const void *udata1, void *udata2); H5_DLL herr_t H5AC_flush(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t addr, unsigned flags); H5_DLL herr_t H5AC_rename(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, @@ -630,7 +630,7 @@ H5B_find(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void *u * Perform a binary search to locate the child which contains * the thing for which we're searching. */ - if (NULL == (bt = H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata))) + if (NULL == (bt = H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata, H5AC_READ))) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree node") shared=H5RC_GET_OBJ(bt->rc_shared); HDassert(shared); @@ -806,7 +806,7 @@ H5B_split(H5F_t *f, hid_t dxpl_id, H5B_t *old_bt, haddr_t old_addr, */ if (H5B_create(f, dxpl_id, shared->type, udata, new_addr_p/*out*/) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to create B-tree") - if (NULL==(new_bt=H5AC_protect(f, dxpl_id, H5AC_BT, *new_addr_p, shared->type, udata))) + if (NULL==(new_bt=H5AC_protect(f, dxpl_id, H5AC_BT, *new_addr_p, shared->type, udata, H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to protect B-tree") new_bt->level = old_bt->level; @@ -835,7 +835,7 @@ H5B_split(H5F_t *f, hid_t dxpl_id, H5B_t *old_bt, haddr_t old_addr, new_bt->right = old_bt->right; if (H5F_addr_defined(old_bt->right)) { - if (NULL == (tmp_bt = H5AC_protect(f, dxpl_id, H5AC_BT, old_bt->right, shared->type, udata))) + if (NULL == (tmp_bt = H5AC_protect(f, dxpl_id, H5AC_BT, old_bt->right, shared->type, udata, H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load right sibling") tmp_bt->cache_info.dirty = TRUE; @@ -921,7 +921,7 @@ H5B_insert(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, assert(H5B_INS_RIGHT == my_ins); /* the current root */ - if (NULL == (bt = H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata))) + if (NULL == (bt = H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata, H5AC_READ))) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to locate root of B-tree") shared=H5RC_GET_OBJ(bt->rc_shared); HDassert(shared); @@ -937,7 +937,7 @@ H5B_insert(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, bt = NULL; /* the new node */ - if (NULL == (bt = H5AC_protect(f, dxpl_id, H5AC_BT, child, type, udata))) + if (NULL == (bt = H5AC_protect(f, dxpl_id, H5AC_BT, child, type, udata, H5AC_READ))) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load new node") if (!rt_key_changed) @@ -958,7 +958,7 @@ H5B_insert(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate file space to move root") /* update the new child's left pointer */ - if (NULL == (bt = H5AC_protect(f, dxpl_id, H5AC_BT, child, type, udata))) + if (NULL == (bt = H5AC_protect(f, dxpl_id, H5AC_BT, child, type, udata, H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load new child") bt->cache_info.dirty = TRUE; @@ -974,7 +974,7 @@ H5B_insert(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, * at the new location -QAK */ /* Bring the old root into the cache if it's not already */ - if (NULL == (bt = H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata))) + if (NULL == (bt = H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata, H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load new child") /* Make certain the old root info is marked as dirty before moving it, */ @@ -1189,7 +1189,7 @@ H5B_insert_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type * data. When the search completes IDX points to the child that * should get the new data. */ - if (NULL == (bt = H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata))) + if (NULL == (bt = H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata, H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR, "unable to load node") shared=H5RC_GET_OBJ(bt->rc_shared); HDassert(shared); @@ -1359,7 +1359,7 @@ H5B_insert_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type if (bt->nchildren == shared->two_k) { if (H5B_split(f, dxpl_id, bt, addr, idx, udata, new_node_p/*out*/)<0) HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, H5B_INS_ERROR, "unable to split node") - if (NULL == (twin = H5AC_protect(f, dxpl_id, H5AC_BT, *new_node_p, type, udata))) + if (NULL == (twin = H5AC_protect(f, dxpl_id, H5AC_BT, *new_node_p, type, udata, H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR, "unable to load node") if (idx<bt->nchildren) { tmp_bt = bt; @@ -1457,7 +1457,7 @@ H5B_iterate (H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, H5B_operator_t op assert(H5F_addr_defined(addr)); assert(udata); - if (NULL == (bt = H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata))) + if (NULL == (bt = H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata, H5AC_READ))) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree node") shared=H5RC_GET_OBJ(bt->rc_shared); HDassert(shared); @@ -1489,7 +1489,7 @@ H5B_iterate (H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, H5B_operator_t op * leave the B-tree node protected during an application * callback. */ - if (NULL == (bt = H5AC_protect(f, dxpl_id, H5AC_BT, cur_addr, type, udata))) + if (NULL == (bt = H5AC_protect(f, dxpl_id, H5AC_BT, cur_addr, type, udata, H5AC_READ))) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "B-tree node") HDmemcpy(child, bt->child, bt->nchildren*sizeof(haddr_t)); @@ -1581,7 +1581,7 @@ H5B_remove_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type * Perform a binary search to locate the child which contains the thing * for which we're searching. */ - if (NULL==(bt=H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata))) + if (NULL==(bt=H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata, H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR, "unable to load B-tree node") shared=H5RC_GET_OBJ(bt->rc_shared); HDassert(shared); @@ -1663,7 +1663,7 @@ H5B_remove_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type */ if (ret_value!=H5B_INS_REMOVE && level>0) { if (H5F_addr_defined(bt->right)) { - if (NULL == (sibling = H5AC_protect(f, dxpl_id, H5AC_BT, bt->right, type, udata))) + if (NULL == (sibling = H5AC_protect(f, dxpl_id, H5AC_BT, bt->right, type, udata, H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR, "unable to unlink node from tree") /* Make certain the native key for the right sibling is set up */ @@ -1694,7 +1694,7 @@ H5B_remove_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type bt->nchildren = 0; if (level>0) { if (H5F_addr_defined(bt->left)) { - if (NULL == (sibling = H5AC_protect(f, dxpl_id, H5AC_BT, bt->left, type, udata))) + if (NULL == (sibling = H5AC_protect(f, dxpl_id, H5AC_BT, bt->left, type, udata, H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR, "unable to load node from tree") sibling->right = bt->right; @@ -1706,7 +1706,7 @@ H5B_remove_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type sibling=NULL; /* Make certain future references will be caught */ } if (H5F_addr_defined(bt->right)) { - if (NULL == (sibling = H5AC_protect(f, dxpl_id, H5AC_BT, bt->right, type, udata))) + if (NULL == (sibling = H5AC_protect(f, dxpl_id, H5AC_BT, bt->right, type, udata, H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR, "unable to unlink node from tree") /* Copy left-most key from deleted node to left-most key in it's right neighbor */ @@ -1770,7 +1770,7 @@ H5B_remove_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type */ if (level>0) { if (H5F_addr_defined(bt->right)) { - if (NULL == (sibling = H5AC_protect(f, dxpl_id, H5AC_BT, bt->right, type, udata))) + if (NULL == (sibling = H5AC_protect(f, dxpl_id, H5AC_BT, bt->right, type, udata, H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR, "unable to unlink node from tree") HDmemcpy(H5B_NKEY(sibling,shared,0), H5B_NKEY(bt,shared,bt->nchildren), type->sizeof_nkey); @@ -1864,7 +1864,7 @@ H5B_remove(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void * If the B-tree is now empty then make sure we mark the root node as * being at level zero */ - if (NULL == (bt = H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata))) + if (NULL == (bt = H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata, H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree root node") if (0==bt->nchildren && 0!=bt->level) { @@ -1916,7 +1916,7 @@ H5B_delete(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void assert(H5F_addr_defined(addr)); /* Lock this B-tree node into memory for now */ - if (NULL == (bt = H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata))) + if (NULL == (bt = H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata, H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree node") shared=H5RC_GET_OBJ(bt->rc_shared); HDassert(shared); @@ -2119,7 +2119,7 @@ H5B_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, int f /* * Load the tree node. */ - if (NULL == (bt = H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata))) + if (NULL == (bt = H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata, H5AC_READ))) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree node") shared=H5RC_GET_OBJ(bt->rc_shared); HDassert(shared); @@ -2232,7 +2232,7 @@ H5B_assert(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type, void } } /* Initialize the queue */ - bt = H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata); + bt = H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata, H5AC_READ); assert(bt); cur = H5MM_calloc(sizeof(struct child_t)); assert (cur); @@ -2251,7 +2251,7 @@ H5B_assert(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type, void * test. */ for (ncell = 0; cur; ncell++) { - bt = H5AC_protect(f, dxpl_id, H5AC_BT, cur->addr, type, udata); + bt = H5AC_protect(f, dxpl_id, H5AC_BT, cur->addr, type, udata, H5AC_READ); assert(bt); /* Check node header */ diff --git a/src/H5Gnode.c b/src/H5Gnode.c index 4afc5f3..710de18 100644 --- a/src/H5Gnode.c +++ b/src/H5Gnode.c @@ -911,7 +911,7 @@ H5G_node_found(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED *_lt_key /* * Load the symbol table node for exclusive access. */ - if (NULL == (sn = H5AC_protect(f, dxpl_id, H5AC_SNODE, addr, NULL, NULL))) + if (NULL == (sn = H5AC_protect(f, dxpl_id, H5AC_SNODE, addr, NULL, NULL, H5AC_READ))) HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, FAIL, "unable to protect symbol table node"); /* Get base address of heap */ @@ -1032,7 +1032,7 @@ H5G_node_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr, void UNUSED *_lt_key, /* * Load the symbol node. */ - if (NULL == (sn = H5AC_protect(f, dxpl_id, H5AC_SNODE, addr, NULL, NULL))) + if (NULL == (sn = H5AC_protect(f, dxpl_id, H5AC_SNODE, addr, NULL, NULL, H5AC_WRITE))) HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5B_INS_ERROR, "unable to protect symbol table node"); /* Get base address of heap */ @@ -1092,7 +1092,7 @@ H5G_node_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr, void UNUSED *_lt_key, new_node_p/*out*/)<0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5B_INS_ERROR, "unable to split symbol table node"); - if (NULL == (snrt = H5AC_protect(f, dxpl_id, H5AC_SNODE, *new_node_p, NULL, NULL))) + if (NULL == (snrt = H5AC_protect(f, dxpl_id, H5AC_SNODE, *new_node_p, NULL, NULL, H5AC_WRITE))) HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5B_INS_ERROR, "unable to split symbol table node"); HDmemcpy(snrt->entry, sn->entry + H5F_SYM_LEAF_K(f), @@ -1215,7 +1215,7 @@ H5G_node_remove(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_lt_key/*in,out*/, assert(bt_udata); /* Load the symbol table */ - if (NULL==(sn=H5AC_protect(f, dxpl_id, H5AC_SNODE, addr, NULL, NULL))) + if (NULL==(sn=H5AC_protect(f, dxpl_id, H5AC_SNODE, addr, NULL, NULL, H5AC_WRITE))) HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5B_INS_ERROR, "unable to protect symbol table node"); /* "Normal" removal of a single entry from the symbol table node */ @@ -1440,7 +1440,7 @@ H5G_node_iterate (H5F_t *f, hid_t dxpl_id, void UNUSED *_lt_key, haddr_t addr, * Save information about the symbol table node since we can't lock it * because we're about to call an application function. */ - if (NULL == (sn = H5AC_protect(f, dxpl_id, H5AC_SNODE, addr, NULL, NULL))) + if (NULL == (sn = H5AC_protect(f, dxpl_id, H5AC_SNODE, addr, NULL, NULL, H5AC_READ))) HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5B_ITER_ERROR, "unable to load symbol table node"); nsyms = sn->nsyms; if (NULL==(name_off = H5MM_malloc (nsyms*sizeof(name_off[0])))) @@ -1538,7 +1538,7 @@ H5G_node_sumup(H5F_t *f, hid_t dxpl_id, void UNUSED *_lt_key, haddr_t addr, assert(num_objs); /* Find the object node and add the number of symbol entries. */ - if (NULL == (sn = H5AC_protect(f, dxpl_id, H5AC_SNODE, addr, NULL, NULL))) + if (NULL == (sn = H5AC_protect(f, dxpl_id, H5AC_SNODE, addr, NULL, NULL, H5AC_READ))) HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5B_ITER_ERROR, "unable to load symbol table node"); *num_objs += sn->nsyms; @@ -1588,7 +1588,7 @@ H5G_node_name(H5F_t *f, hid_t dxpl_id, void UNUSED *_lt_key, haddr_t addr, assert(H5F_addr_defined(addr)); assert(bt_udata); - if (NULL == (sn = H5AC_protect(f, dxpl_id, H5AC_SNODE, addr, NULL, NULL))) + if (NULL == (sn = H5AC_protect(f, dxpl_id, H5AC_SNODE, addr, NULL, NULL, H5AC_READ))) HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5B_ITER_ERROR, "unable to load symbol table node"); /* Find the node, locate the object symbol table entry and retrieve the name */ @@ -1653,7 +1653,7 @@ H5G_node_type(H5F_t *f, hid_t dxpl_id, void UNUSED *_lt_key, haddr_t addr, assert(bt_udata); /* Find the node, locate the object symbol table entry and retrieve the type */ - if (NULL == (sn = H5AC_protect(f, dxpl_id, H5AC_SNODE, addr, NULL, NULL))) + if (NULL == (sn = H5AC_protect(f, dxpl_id, H5AC_SNODE, addr, NULL, NULL, H5AC_READ))) HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5B_ITER_ERROR, "unable to load symbol table node"); if(bt_udata->idx >= bt_udata->num_objs && bt_udata->idx < (bt_udata->num_objs+sn->nsyms)) { @@ -1839,7 +1839,7 @@ H5G_node_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream, int indent, * If we couldn't load the symbol table node, then try loading the * B-tree node. */ - if (NULL == (sn = H5AC_protect(f, dxpl_id, H5AC_SNODE, addr, NULL, NULL))) { + if (NULL == (sn = H5AC_protect(f, dxpl_id, H5AC_SNODE, addr, NULL, NULL, H5AC_READ))) { H5G_bt_ud1_t udata; /*data to pass through B-tree */ H5E_clear(); /*discard that error */ @@ -37,6 +37,7 @@ */ #define H5F_PACKAGE /*suppress error about including H5Fpkg */ +#define H5HG_PACKAGE /*suppress error about including H5HGpkg */ /* Pablo information */ /* (Put before include files to avoid problems with inline functions) */ @@ -47,7 +48,7 @@ #include "H5Eprivate.h" /* Error handling */ #include "H5Fpkg.h" /* File access */ #include "H5FLprivate.h" /* Free lists */ -#include "H5HGprivate.h" /* Global heaps */ +#include "H5HGpkg.h" /* Global heaps */ #include "H5MFprivate.h" /* File memory management */ #include "H5MMprivate.h" /* Memory management */ @@ -59,17 +60,6 @@ #define H5HG_VERSION 1 /* - * Pad all global heap messages to a multiple of eight bytes so we can load - * the entire collection into memory and operate on it there. Eight should - * be sufficient for machines that have alignment constraints because our - * largest data type is eight bytes. - */ -#define H5HG_ALIGNMENT 8 -#define H5HG_ALIGN(X) (H5HG_ALIGNMENT*(((X)+H5HG_ALIGNMENT-1)/ \ - H5HG_ALIGNMENT)) -#define H5HG_ISALIGNED(X) ((X)==H5HG_ALIGN(X)) - -/* * All global heap collections are at least this big. This allows us to read * most collections with a single read() since we don't have to read a few * bytes of header to figure out the size. If the heap is larger than this @@ -111,16 +101,6 @@ H5F_SIZEOF_SIZE(f)) /*collection size */ /* - * The overhead associated with each object in the heap, always a multiple of - * the alignment so that the stuff that follows the header is aligned. - */ -#define H5HG_SIZEOF_OBJHDR(f) \ - H5HG_ALIGN(2 + /*object id number */ \ - 2 + /*reference count */ \ - 4 + /*reserved */ \ - H5F_SIZEOF_SIZE(f)) /*object data size */ - -/* * The initial guess for the number of messages in a collection. We assume * that all objects in that collection are zero length, giving the maximum * possible number of objects in the collection. The collection itself has @@ -139,28 +119,8 @@ /* Private typedefs */ -typedef struct H5HG_obj_t { - int nrefs; /*reference count */ - size_t size; /*total size of object */ - uint8_t *begin; /*ptr to object into heap->chunk*/ -} H5HG_obj_t; - -struct H5HG_heap_t { - H5AC_info_t cache_info; /* Information for H5AC cache functions, _must_ be */ - /* first field in structure */ - haddr_t addr; /*collection address */ - size_t size; /*total size of collection */ - uint8_t *chunk; /*the collection, incl. header */ - size_t nalloc; /*numb object slots allocated */ - size_t nused; /*number of slots used */ - /* If this value is >65535 then all indices */ - /* have been used at some time and the */ - /* correct new index should be searched for */ - H5HG_obj_t *obj; /*array of object descriptions */ -}; - /* PRIVATE PROTOTYPES */ -static H5HG_heap_t *H5HG_create(H5F_t *f, hid_t dxpl_id, size_t size); +static haddr_t H5HG_create(H5F_t *f, hid_t dxpl_id, size_t size); #ifdef NOT_YET static void *H5HG_peek(H5F_t *f, hid_t dxpl_id, H5HG_t *hobj); #endif /* NOT_YET */ @@ -176,7 +136,7 @@ static herr_t H5HG_clear(H5HG_heap_t *heap); /* * H5HG inherits cache-like properties from H5AC */ -static const H5AC_class_t H5AC_GHEAP[1] = {{ +const H5AC_class_t H5AC_GHEAP[1] = {{ H5AC_GHEAP_ID, (H5AC_load_func_t)H5HG_load, (H5AC_flush_func_t)H5HG_flush, @@ -217,18 +177,27 @@ H5FL_BLK_DEFINE_STATIC(heap_chunk); * * Modifications: * + * John Mainzer 5/26/04 + * Modified function to return the disk address of the new + * global heap collection, or HADDR_UNDEF on failure. This + * is necessary, as in some cases (i.e. flexible parallel) + * H5AC_set() will imediately flush and destroy the in memory + * version of the new collection. For the same reason, I + * moved the code which places the new collection on the cwfs + * list to just before the call to H5AC_set(). + * *------------------------------------------------------------------------- */ -static H5HG_heap_t * +static haddr_t H5HG_create (H5F_t *f, hid_t dxpl_id, size_t size) { H5HG_heap_t *heap = NULL; - H5HG_heap_t *ret_value = NULL; + haddr_t ret_value = HADDR_UNDEF; uint8_t *p = NULL; haddr_t addr; size_t n; - FUNC_ENTER_NOAPI(H5HG_create, NULL); + FUNC_ENTER_NOAPI(H5HG_create, HADDR_UNDEF); /* Check args */ assert (f); @@ -238,22 +207,27 @@ H5HG_create (H5F_t *f, hid_t dxpl_id, size_t size) /* Create it */ H5_CHECK_OVERFLOW(size,size_t,hsize_t); - if (HADDR_UNDEF==(addr=H5MF_alloc(f, H5FD_MEM_GHEAP, dxpl_id, (hsize_t)size))) - HGOTO_ERROR (H5E_HEAP, H5E_CANTINIT, NULL, "unable to allocate file space for global heap"); + if ( HADDR_UNDEF== + (addr=H5MF_alloc(f, H5FD_MEM_GHEAP, dxpl_id, (hsize_t)size))) + HGOTO_ERROR (H5E_HEAP, H5E_CANTINIT, HADDR_UNDEF, \ + "unable to allocate file space for global heap"); if (NULL==(heap = H5FL_MALLOC (H5HG_heap_t))) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, HADDR_UNDEF, \ + "memory allocation failed"); heap->addr = addr; heap->size = size; heap->cache_info.dirty = TRUE; if (NULL==(heap->chunk = H5FL_BLK_MALLOC (heap_chunk,size))) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, HADDR_UNDEF, \ + "memory allocation failed"); #ifdef H5_USING_PURIFY HDmemset(heap->chunk,0,size); #endif /* H5_USING_PURIFY */ heap->nalloc = H5HG_NOBJS (f, size); heap->nused = 1; /* account for index 0, which is used for the free object */ if (NULL==(heap->obj = H5FL_SEQ_MALLOC (H5HG_obj_t,heap->nalloc))) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, HADDR_UNDEF, \ + "memory allocation failed"); /* Initialize the header */ HDmemcpy (heap->chunk, H5HG_MAGIC, H5HG_SIZEOF_MAGIC); @@ -290,32 +264,37 @@ HDmemset(heap->chunk,0,size); HDmemset (p, 0, (size_t)((heap->chunk+heap->size) - p)); #endif /* OLD_WAY */ - /* Add the heap to the cache */ - if (H5AC_set (f, dxpl_id, H5AC_GHEAP, addr, heap)<0) - HGOTO_ERROR (H5E_HEAP, H5E_CANTINIT, NULL, "unable to cache global heap collection"); - /* Add this heap to the beginning of the CWFS list */ if (NULL==f->shared->cwfs) { f->shared->cwfs = H5MM_malloc (H5HG_NCWFS * sizeof(H5HG_heap_t*)); if (NULL==(f->shared->cwfs)) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, HADDR_UNDEF, \ + "memory allocation failed"); f->shared->cwfs[0] = heap; f->shared->ncwfs = 1; } else { - HDmemmove (f->shared->cwfs+1, f->shared->cwfs, MIN (f->shared->ncwfs, H5HG_NCWFS-1)*sizeof(H5HG_heap_t*)); + HDmemmove (f->shared->cwfs+1, f->shared->cwfs, + MIN (f->shared->ncwfs, H5HG_NCWFS-1)*sizeof(H5HG_heap_t*)); f->shared->cwfs[0] = heap; f->shared->ncwfs = MIN (H5HG_NCWFS, f->shared->ncwfs+1); } - ret_value = heap; + /* Add the heap to the cache */ + if (H5AC_set (f, dxpl_id, H5AC_GHEAP, addr, heap)<0) + HGOTO_ERROR (H5E_HEAP, H5E_CANTINIT, HADDR_UNDEF, \ + "unable to cache global heap collection"); + + ret_value = addr; done: - if (!ret_value && heap) { - if(H5HG_dest(f,heap)<0) - HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, NULL, "unable to destroy global heap collection"); + if ( ! ( H5F_addr_defined(addr) ) && heap) { + if ( H5HG_dest(f,heap) < 0 ) + HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, HADDR_UNDEF, \ + "unable to destroy global heap collection"); } + FUNC_LEAVE_NOAPI(ret_value); -} +} /* H5HG_create() */ /*------------------------------------------------------------------------- @@ -858,6 +837,23 @@ done: * * Modifications: * + * John Mainzer -- 5/24/04 + * The function used to modify the heap without protecting + * the relevant collection first. I did a half assed job + * of fixing the problem, which should hold until we try to + * support multi-threading. At that point it will have to + * be done right. + * + * See in line comment of this date for more details. + * + * John Mainzer - 5/26/04 + * Modified H5HG_create() to return the disk address of the + * new collection, instead of the address of its + * representation in core. This was necessary as in FP + * mode, the cache will immediately flush and destroy any + * entry inserted in it via H5AC_set(). I then modified + * this function to account for the change in H5HG_create(). + * *------------------------------------------------------------------------- */ herr_t @@ -866,6 +862,7 @@ H5HG_insert (H5F_t *f, hid_t dxpl_id, size_t size, void *obj, H5HG_t *hobj/*out* size_t need; /*total space needed for object */ int cwfsno; unsigned idx; + haddr_t addr = HADDR_UNDEF; H5HG_heap_t *heap = NULL; hbool_t found=0; /* Flag to indicate a heap with enough space was found */ herr_t ret_value=SUCCEED; /* Return value */ @@ -882,8 +879,35 @@ H5HG_insert (H5F_t *f, hid_t dxpl_id, size_t size, void *obj, H5HG_t *hobj/*out* /* Find a large enough collection on the CWFS list */ need = H5HG_SIZEOF_OBJHDR(f) + H5HG_ALIGN(size); + + /* Note that we don't have metadata cache locks on the entries in + * f->shared->cwfs. + * + * In the current situation, this doesn't matter, as we are single + * threaded, and as best I can tell, entries are added to and deleted + * from f->shared->cwfs as they are added to and deleted from the + * metadata cache. + * + * To be proper, we should either lock each entry in f->shared->cwfs + * as we examine it, or lock the whole array. However, at present + * I don't see the point as there will be significant overhead, + * and protecting and unprotecting all the collections in the global + * heap on a regular basis will skew the replacement policy. + * + * However, there is a bigger issue -- as best I can tell, we only look + * for free space in global heap chunks that are in cache. If we can't + * find any, we allocate a new chunk. This may be a problem in FP mode, + * as the metadata cache is disabled. Do we allocate a new heap + * collection for every entry in this case? + * + * Note that all this comes from a cursory read of the source. Don't + * take any of it as gospel. + * JRM - 5/24/04 + */ + for (cwfsno=0; cwfsno<f->shared->ncwfs; cwfsno++) { if (f->shared->cwfs[cwfsno]->obj[0].size>=need) { + addr = f->shared->cwfs[cwfsno]->addr; found=1; break; } /* end if */ @@ -901,9 +925,10 @@ H5HG_insert (H5F_t *f, hid_t dxpl_id, size_t size, void *obj, H5HG_t *hobj/*out* new_need -= f->shared->cwfs[cwfsno]->obj[0].size; new_need = MAX(f->shared->cwfs[cwfsno]->size, new_need); - if((f->shared->cwfs[cwfsno]->size+new_need)<=H5HG_MAXSIZE && H5MF_can_extend(f,H5FD_MEM_GHEAP,f->shared->cwfs[cwfsno]->addr,(hsize_t)f->shared->cwfs[cwfsno]->size,(hsize_t)need)) { + if((f->shared->cwfs[cwfsno]->size+new_need)<=H5HG_MAXSIZE && H5MF_can_extend(f,H5FD_MEM_GHEAP,f->shared->cwfs[cwfsno]->addr,(hsize_t)f->shared->cwfs[cwfsno]->size,(hsize_t)new_need)) { if(H5HG_extend(f,f->shared->cwfs[cwfsno],size)<0) HGOTO_ERROR (H5E_HEAP, H5E_CANTINIT, FAIL, "unable to extend global heap collection"); + addr = f->shared->cwfs[cwfsno]->addr; found=1; break; } /* end if */ @@ -915,18 +940,19 @@ H5HG_insert (H5F_t *f, hid_t dxpl_id, size_t size, void *obj, H5HG_t *hobj/*out* * new collection large enough for the message plus the collection header. */ if (!found) { - if (NULL==(heap=H5HG_create (f, dxpl_id, need+H5HG_SIZEOF_HDR (f)))) - HGOTO_ERROR (H5E_HEAP, H5E_CANTINIT, FAIL, "unable to allocate a global heap collection"); - assert (f->shared->ncwfs>0); - assert (f->shared->cwfs[0]==heap); - assert (f->shared->cwfs[0]->obj[0].size >= need); + + addr = H5HG_create(f, dxpl_id, need+H5HG_SIZEOF_HDR (f)); + + if ( ! H5F_addr_defined(addr) ) + HGOTO_ERROR (H5E_HEAP, H5E_CANTINIT, FAIL, \ + "unable to allocate a global heap collection"); cwfsno = 0; } /* end if */ else { - /* Found a heap with enough space */ - heap = f->shared->cwfs[cwfsno]; - /* Move the collection forward in the CWFS list, if it's not already at the front */ + /* Move the collection forward in the CWFS list, if it's not + * already at the front + */ if (cwfsno>0) { H5HG_heap_t *tmp = f->shared->cwfs[cwfsno]; f->shared->cwfs[cwfsno] = f->shared->cwfs[cwfsno-1]; @@ -934,7 +960,12 @@ H5HG_insert (H5F_t *f, hid_t dxpl_id, size_t size, void *obj, H5HG_t *hobj/*out* --cwfsno; } /* end if */ } /* end else */ + + HDassert(H5F_addr_defined(addr)); + if ( NULL == (heap = H5AC_protect(f, dxpl_id, H5AC_GHEAP, addr, NULL, NULL, H5AC_WRITE)) ) + HGOTO_ERROR (H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load heap"); + /* Split the free space to make room for the new object */ idx = H5HG_alloc (f, heap, size); assert (idx>0); @@ -955,73 +986,12 @@ H5HG_insert (H5F_t *f, hid_t dxpl_id, size_t size, void *obj, H5HG_t *hobj/*out* hobj->idx = idx; done: - FUNC_LEAVE_NOAPI(ret_value); -} - -#ifdef NOT_YET - -/*------------------------------------------------------------------------- - * Function: H5HG_peek - * - * Purpose: Given an ID for a global heap object return a pointer to the - * beginning of that object. This is intended for quick and - * dirty access to the object; otherwise use H5HG_read(). - * - * Return: Success: Ptr directly into the H5AC layer for the - * specified object of the global heap. The - * pointer is guaranteed to be valid only until - * some other hdf5 library function is called. - * - * Failure: NULL - * - * Programmer: Robb Matzke - * Monday, March 30, 1998 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -static void * -H5HG_peek (H5F_t *f, hid_t dxpl_id, H5HG_t *hobj) -{ - H5HG_heap_t *heap = NULL; - void *ret_value; - int i; - - FUNC_ENTER_NOAPI(H5HG_peek, NULL); - - /* Check args */ - assert (f); - assert (hobj); + if ( heap && H5AC_unprotect(f, dxpl_id, H5AC_GHEAP, heap->addr, heap, FALSE) < 0 ) + HDONE_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to unprotect heap."); - /* Load the heap and return a pointer to the object */ - if (NULL==(heap=H5AC_find(f, dxpl_id, H5AC_GHEAP, hobj->addr, NULL, NULL))) - HGOTO_ERROR (H5E_HEAP, H5E_CANTLOAD, NULL, "unable to load heap"); - - assert (hobj->idx>0 && hobj->idx<heap->nused); - ret_value = heap->obj[hobj->idx].begin + H5HG_SIZEOF_OBJHDR (f); - assert (ret_value); - - /* - * Advance the heap in the CWFS list. We might have done this already - * with the H5AC_find(), but it won't hurt to do it twice. - */ - if (heap->obj[0].begin) { - for (i=0; i<f->shared->ncwfs; i++) { - if (f->shared->cwfs[i]==heap) { - if (i) { - f->shared->cwfs[i] = f->shared->cwfs[i-1]; - f->shared->cwfs[i-1] = heap; - } - break; - } - } - } - -done: FUNC_LEAVE_NOAPI(ret_value); -} -#endif /* NOT_YET */ + +} /* H5HG_insert() */ /*------------------------------------------------------------------------- @@ -1059,7 +1029,7 @@ H5HG_read (H5F_t *f, hid_t dxpl_id, H5HG_t *hobj, void *object/*out*/) assert (hobj); /* Load the heap */ - if (NULL==(heap=H5AC_find(f, dxpl_id, H5AC_GHEAP, hobj->addr, NULL, NULL))) + if (NULL == (heap = H5AC_protect(f, dxpl_id, H5AC_GHEAP, hobj->addr, NULL, NULL, H5AC_READ))) HGOTO_ERROR (H5E_HEAP, H5E_CANTLOAD, NULL, "unable to load heap"); assert (hobj->idx>0 && hobj->idx<heap->nused); @@ -1071,8 +1041,8 @@ H5HG_read (H5F_t *f, hid_t dxpl_id, H5HG_t *hobj, void *object/*out*/) HDmemcpy (object, p, size); /* - * Advance the heap in the CWFS list. We might have done this already - * with the H5AC_find(), but it won't hurt to do it twice. + * Advance the heap in the CWFS list. We might have done this already + * with the H5AC_protect(), but it won't hurt to do it twice. */ if (heap->obj[0].begin) { for (i=0; i<f->shared->ncwfs; i++) { @@ -1090,6 +1060,9 @@ H5HG_read (H5F_t *f, hid_t dxpl_id, H5HG_t *hobj, void *object/*out*/) ret_value=object; done: + if (heap && H5AC_unprotect(f, dxpl_id, H5AC_GHEAP, hobj->addr, heap, FALSE)<0) + HDONE_ERROR(H5E_HEAP, H5E_PROTECT, NULL, "unable to release object header"); + FUNC_LEAVE_NOAPI(ret_value); } @@ -1128,23 +1101,28 @@ H5HG_link (H5F_t *f, hid_t dxpl_id, const H5HG_t *hobj, int adjust) if (0==(f->intent & H5F_ACC_RDWR)) HGOTO_ERROR (H5E_HEAP, H5E_WRITEERROR, FAIL, "no write intent on file"); - /* Load the heap */ - if (NULL==(heap=H5AC_find(f, dxpl_id, H5AC_GHEAP, hobj->addr, NULL, NULL))) - HGOTO_ERROR (H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load heap"); - assert (hobj->idx>0 && hobj->idx<heap->nused); - assert (heap->obj[hobj->idx].begin); - if (heap->obj[hobj->idx].nrefs+adjust<0) - HGOTO_ERROR (H5E_HEAP, H5E_BADRANGE, FAIL, "new link count would be out of range"); - if (heap->obj[hobj->idx].nrefs+adjust>H5HG_MAXLINK) - HGOTO_ERROR (H5E_HEAP, H5E_BADVALUE, FAIL, "new link count would be out of range"); - heap->obj[hobj->idx].nrefs += adjust; - if (adjust) + if(adjust!=0) { + /* Load the heap */ + if (NULL == (heap = H5AC_protect(f, dxpl_id, H5AC_GHEAP, hobj->addr, NULL, NULL, H5AC_WRITE))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load heap"); + + assert (hobj->idx>0 && hobj->idx<heap->nused); + assert (heap->obj[hobj->idx].begin); + if (heap->obj[hobj->idx].nrefs+adjust<0) + HGOTO_ERROR (H5E_HEAP, H5E_BADRANGE, FAIL, "new link count would be out of range"); + if (heap->obj[hobj->idx].nrefs+adjust>H5HG_MAXLINK) + HGOTO_ERROR (H5E_HEAP, H5E_BADVALUE, FAIL, "new link count would be out of range"); + heap->obj[hobj->idx].nrefs += adjust; heap->cache_info.dirty = TRUE; + } /* end if */ /* Set return value */ ret_value=heap->obj[hobj->idx].nrefs; done: + if (heap && H5AC_unprotect(f, dxpl_id, H5AC_GHEAP, hobj->addr, heap, FALSE)<0) + HDONE_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to release object header"); + FUNC_LEAVE_NOAPI(ret_value); } @@ -1171,6 +1149,7 @@ H5HG_remove (H5F_t *f, hid_t dxpl_id, H5HG_t *hobj) size_t need; int i; unsigned u; + hbool_t deleted=FALSE; /* Whether the heap gets deleted */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5HG_remove, FAIL); @@ -1182,8 +1161,9 @@ H5HG_remove (H5F_t *f, hid_t dxpl_id, H5HG_t *hobj) HGOTO_ERROR (H5E_HEAP, H5E_WRITEERROR, FAIL, "no write intent on file"); /* Load the heap */ - if (NULL==(heap=H5AC_find(f, dxpl_id, H5AC_GHEAP, hobj->addr, NULL, NULL))) - HGOTO_ERROR (H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load heap"); + if (NULL == (heap = H5AC_protect(f, dxpl_id, H5AC_GHEAP, hobj->addr, NULL, NULL, H5AC_WRITE))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load heap"); + assert (hobj->idx>0 && hobj->idx<heap->nused); assert (heap->obj[hobj->idx].begin); obj_start = heap->obj[hobj->idx].begin; @@ -1222,12 +1202,11 @@ H5HG_remove (H5F_t *f, hid_t dxpl_id, H5HG_t *hobj) heap->cache_info.dirty = FALSE; H5_CHECK_OVERFLOW(heap->size,size_t,hsize_t); H5MF_xfree(f, H5FD_MEM_GHEAP, dxpl_id, heap->addr, (hsize_t)heap->size); - H5AC_flush (f, dxpl_id, H5AC_GHEAP, heap->addr, H5F_FLUSH_INVALIDATE); - heap = NULL; + deleted=TRUE; /* Indicate that the object was deleted, for the unprotect call */ } else { /* * If the heap is in the CWFS list then advance it one position. The - * H5AC_find() might have done that too, but that's okay. If the + * H5AC_protect() might have done that too, but that's okay. If the * heap isn't on the CWFS list then add it to the end. */ for (i=0; i<f->shared->ncwfs; i++) { @@ -1236,7 +1215,7 @@ H5HG_remove (H5F_t *f, hid_t dxpl_id, H5HG_t *hobj) f->shared->cwfs[i] = f->shared->cwfs[i-1]; f->shared->cwfs[i-1] = heap; } - break; + break; } } if (i>=f->shared->ncwfs) { @@ -1246,106 +1225,9 @@ H5HG_remove (H5F_t *f, hid_t dxpl_id, H5HG_t *hobj) } done: - FUNC_LEAVE_NOAPI(ret_value); -} - - -/*------------------------------------------------------------------------- - * Function: H5HG_debug - * - * Purpose: Prints debugging information about a global heap collection. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Robb Matzke - * matzke@llnl.gov - * Mar 27, 1998 - * - * Modifications: - * Robb Matzke, 1999-07-28 - * The ADDR argument is passed by value. - * - * Robb Matzke, LLNL, 2003-06-05 - * The size does not include the object header, just the data. - *------------------------------------------------------------------------- - */ -herr_t -H5HG_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, - int fwidth) -{ - unsigned u, nused, maxobj; - unsigned j, k; - H5HG_heap_t *h = NULL; - char buf[64]; - uint8_t *p = NULL; - herr_t ret_value=SUCCEED; /* Return value */ + if (heap && H5AC_unprotect(f, dxpl_id, H5AC_GHEAP, hobj->addr, heap, deleted) != SUCCEED) + HDONE_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to release object header"); - FUNC_ENTER_NOAPI(H5HG_debug, FAIL); - - /* check arguments */ - assert(f); - assert(H5F_addr_defined (addr)); - assert(stream); - assert(indent >= 0); - assert(fwidth >= 0); - - if (NULL == (h = H5AC_find(f, dxpl_id, H5AC_GHEAP, addr, NULL, NULL))) - HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load global heap collection"); - fprintf(stream, "%*sGlobal Heap Collection...\n", indent, ""); - fprintf(stream, "%*s%-*s %d\n", indent, "", fwidth, - "Dirty:", - (int)(h->cache_info.dirty)); - fprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth, - "Total collection size in file:", - (unsigned long)(h->size)); - - for (u=1, nused=0, maxobj=0; u<h->nalloc; u++) { - if (h->obj[u].begin) { - nused++; - if (u>maxobj) maxobj = u; - } - } - fprintf (stream, "%*s%-*s %u/%lu/", indent, "", fwidth, - "Objects defined/allocated/max:", - nused, (unsigned long)h->nalloc); - fprintf (stream, nused ? "%u\n": "NA\n", maxobj); - - fprintf (stream, "%*s%-*s %lu\n", indent, "", fwidth, - "Free space:", - (unsigned long)(h->obj[0].size)); - - for (u=1; u<h->nalloc; u++) { - if (h->obj[u].begin) { - sprintf (buf, "Object %u", u); - fprintf (stream, "%*s%s\n", indent, "", buf); - fprintf (stream, "%*s%-*s %d\n", indent+3, "", MIN(fwidth-3, 0), - "Reference count:", - h->obj[u].nrefs); - fprintf (stream, "%*s%-*s %lu/%lu\n", indent+3, "", - MIN(fwidth-3, 0), - "Size of object body:", - (unsigned long)(h->obj[u].size), - (unsigned long)H5HG_ALIGN(h->obj[u].size)); - p = h->obj[u].begin + H5HG_SIZEOF_OBJHDR (f); - for (j=0; j<h->obj[u].size; j+=16) { - fprintf (stream, "%*s%04d: ", indent+6, "", j); - for (k=0; k<16; k++) { - if (8==k) fprintf (stream, " "); - if (j+k<h->obj[u].size) { - fprintf (stream, "%02x ", p[j+k]); - } else { - HDfputs(" ", stream); - } - } - for (k=0; k<16 && j+k<h->obj[u].size; k++) { - if (8==k) fprintf (stream, " "); - HDfputc(p[j+k]>' ' && p[j+k]<='~' ? p[j+k] : '.', stream); - } - fprintf (stream, "\n"); - } - } - } - -done: FUNC_LEAVE_NOAPI(ret_value); } + diff --git a/src/H5HGdbg.c b/src/H5HGdbg.c index 68a3e85..a16dabb 100644 --- a/src/H5HGdbg.c +++ b/src/H5HGdbg.c @@ -29,6 +29,10 @@ #include "H5HGpkg.h" /* Global heaps */ #include "H5Iprivate.h" /* ID Functions */ +/* Interface initialization */ +static int interface_initialize_g = 0; +#define INTERFACE_INIT NULL + /*------------------------------------------------------------------------- * Function: H5HG_debug @@ -75,7 +79,7 @@ H5HG_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, fprintf(stream, "%*sGlobal Heap Collection...\n", indent, ""); fprintf(stream, "%*s%-*s %d\n", indent, "", fwidth, "Dirty:", - (int)(h->cache_info.is_dirty)); + (int)(h->cache_info.dirty)); fprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth, "Total collection size in file:", (unsigned long)(h->size)); @@ -29,6 +29,7 @@ *------------------------------------------------------------------------- */ #define H5F_PACKAGE /* Suppress error about including H5Fpkg */ +#define H5HL_PACKAGE /* Suppress error about including H5HLpkg */ /* Pablo information */ /* (Put before include files to avoid problems with inline functions) */ @@ -39,19 +40,12 @@ #include "H5Eprivate.h" /* Error handling */ #include "H5Fpkg.h" /* File access */ #include "H5FLprivate.h" /* Free lists */ -#include "H5HLprivate.h" /* Local Heaps */ +#include "H5HLpkg.h" /* Local Heaps */ #include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ /* Private macros */ #define H5HL_FREE_NULL 1 /*end of free list on disk */ #define H5HL_MIN_HEAP 256 /* Minimum size to reduce heap buffer to */ -#define H5HL_SIZEOF_HDR(F) \ - H5HL_ALIGN(H5HL_SIZEOF_MAGIC + /*heap signature */ \ - 4 + /*reserved */ \ - H5F_SIZEOF_SIZE (F) + /*data size */ \ - H5F_SIZEOF_SIZE (F) + /*free list head */ \ - H5F_SIZEOF_ADDR (F)) /*data address */ /* * Local heap collection version. @@ -59,23 +53,6 @@ #define H5HL_VERSION 0 /* Private typedefs */ -typedef struct H5HL_free_t { - size_t offset; /*offset of free block */ - size_t size; /*size of free block */ - struct H5HL_free_t *prev; /*previous entry in free list */ - struct H5HL_free_t *next; /*next entry in free list */ -} H5HL_free_t; - -struct H5HL_t { - H5AC_info_t cache_info; /* Information for H5AC cache functions, _must_ be */ - /* first field in structure */ - haddr_t addr; /*address of data */ - size_t disk_alloc; /*data bytes allocated on disk */ - size_t mem_alloc; /*data bytes allocated in mem */ - size_t disk_resrv; /*data bytes "reserved" on disk */ - uint8_t *chunk; /*the chunk, including header */ - H5HL_free_t *freelist; /*the free list */ -}; /* PRIVATE PROTOTYPES */ #ifdef NOT_YET @@ -99,7 +76,7 @@ static herr_t H5HL_clear(H5HL_t *heap); /* * H5HL inherits cache-like properties from H5AC */ -static const H5AC_class_t H5AC_LHEAP[1] = {{ +const H5AC_class_t H5AC_LHEAP[1] = {{ H5AC_LHEAP_ID, (H5AC_load_func_t)H5HL_load, (H5AC_flush_func_t)H5HL_flush, @@ -737,7 +714,7 @@ H5HL_read(H5F_t *f, hid_t dxpl_id, haddr_t addr, size_t offset, size_t size, voi assert(f); assert (H5F_addr_defined(addr)); - if (NULL == (heap = H5AC_protect(f, dxpl_id, H5AC_LHEAP, addr, NULL, NULL))) + if (NULL == (heap = H5AC_protect(f, dxpl_id, H5AC_LHEAP, addr, NULL, NULL, H5AC_READ))) HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "unable to load heap"); assert(offset < heap->mem_alloc); @@ -803,7 +780,7 @@ H5HL_protect(H5F_t *f, hid_t dxpl_id, haddr_t addr) assert(f); assert(H5F_addr_defined(addr)); - if (NULL == (ret_value = H5AC_protect(f, dxpl_id, H5AC_LHEAP, addr, NULL, NULL))) + if (NULL == (ret_value = H5AC_protect(f, dxpl_id, H5AC_LHEAP, addr, NULL, NULL, H5AC_READ))) HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "unable to load heap"); done: @@ -950,7 +927,7 @@ H5HL_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr, size_t buf_size, const void * if (0==(f->intent & H5F_ACC_RDWR)) HGOTO_ERROR (H5E_HEAP, H5E_WRITEERROR, (size_t)(-1), "no write intent on file"); - if (NULL == (heap = H5AC_protect(f, dxpl_id, H5AC_LHEAP, addr, NULL, NULL))) + if (NULL == (heap = H5AC_protect(f, dxpl_id, H5AC_LHEAP, addr, NULL, NULL, H5AC_WRITE))) HGOTO_ERROR(H5E_HEAP, H5E_PROTECT, (size_t)(-1), "unable to load heap"); heap->cache_info.dirty=TRUE; @@ -1133,7 +1110,7 @@ H5HL_write(H5F_t *f, hid_t dxpl_id, haddr_t addr, size_t offset, size_t size, co if (0==(f->intent & H5F_ACC_RDWR)) HGOTO_ERROR (H5E_HEAP, H5E_WRITEERROR, FAIL, "no write intent on file"); - if (NULL == (heap = H5AC_protect(f, dxpl_id, H5AC_LHEAP, addr, NULL, NULL))) + if (NULL == (heap = H5AC_protect(f, dxpl_id, H5AC_LHEAP, addr, NULL, NULL, H5AC_WRITE))) HGOTO_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to load heap"); assert(offset < heap->mem_alloc); @@ -1198,7 +1175,7 @@ H5HL_remove(H5F_t *f, hid_t dxpl_id, haddr_t addr, size_t offset, size_t size) size = H5HL_ALIGN (size); - if (NULL == (heap = H5AC_protect(f, dxpl_id, H5AC_LHEAP, addr, NULL, NULL))) + if (NULL == (heap = H5AC_protect(f, dxpl_id, H5AC_LHEAP, addr, NULL, NULL, H5AC_WRITE))) HGOTO_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to load heap"); assert(offset < heap->mem_alloc); @@ -1323,7 +1300,7 @@ H5HL_delete(H5F_t *f, hid_t dxpl_id, haddr_t addr) sizeof_hdr= H5HL_SIZEOF_HDR(f); /* Get heap pointer */ - if (NULL == (heap = H5AC_protect(f, dxpl_id, H5AC_LHEAP, addr, NULL, NULL))) + if (NULL == (heap = H5AC_protect(f, dxpl_id, H5AC_LHEAP, addr, NULL, NULL, H5AC_WRITE))) HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load heap"); /* Check if the heap is contiguous on disk */ @@ -1354,146 +1331,9 @@ H5HL_delete(H5F_t *f, hid_t dxpl_id, haddr_t addr) heap = NULL; done: - if (heap && H5AC_unprotect(f, dxpl_id, H5AC_LHEAP, addr, heap, FALSE)<0 && ret_value<0) + if (heap && H5AC_unprotect(f, dxpl_id, H5AC_LHEAP, addr, heap, FALSE)<0) HDONE_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to release local heap"); FUNC_LEAVE_NOAPI(ret_value); } /* end H5HL_delete() */ - -/*------------------------------------------------------------------------- - * Function: H5HL_debug - * - * Purpose: Prints debugging information about a heap. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Robb Matzke - * matzke@llnl.gov - * Aug 1 1997 - * - * Modifications: - * Robb Matzke, 1999-07-28 - * The ADDR argument is passed by value. - *------------------------------------------------------------------------- - */ -herr_t -H5HL_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream, int indent, int fwidth) -{ - H5HL_t *h = NULL; - int i, j, overlap, free_block; - uint8_t c; - H5HL_free_t *freelist = NULL; - uint8_t *marker = NULL; - size_t amount_free = 0; - herr_t ret_value=SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(H5HL_debug, FAIL); - - /* check arguments */ - assert(f); - assert(H5F_addr_defined(addr)); - assert(stream); - assert(indent >= 0); - assert(fwidth >= 0); - - if (NULL == (h = H5AC_find(f, dxpl_id, H5AC_LHEAP, addr, NULL, NULL))) - HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load heap"); - fprintf(stream, "%*sLocal Heap...\n", indent, ""); - fprintf(stream, "%*s%-*s %d\n", indent, "", fwidth, - "Dirty:", - (int) (h->cache_info.dirty)); - fprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth, - "Header size (in bytes):", - (unsigned long) H5HL_SIZEOF_HDR(f)); - HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, - "Address of heap data:", - h->addr); - HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, - "Data bytes allocated on disk:", - h->disk_alloc); - HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, - "Data bytes allocated in core:", - h->mem_alloc); - - /* - * Traverse the free list and check that all free blocks fall within - * the heap and that no two free blocks point to the same region of - * the heap. - */ - if (NULL==(marker = H5MM_calloc(h->mem_alloc))) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); - fprintf(stream, "%*sFree Blocks (offset, size):\n", indent, ""); - for (free_block=0, freelist = h->freelist; freelist; freelist = freelist->next, free_block++) { - char temp_str[32]; - - sprintf(temp_str,"Block #%d:",free_block); - HDfprintf(stream, "%*s%-*s %8Zu, %8Zu\n", indent+3, "", MAX(0,fwidth-9), - temp_str, - freelist->offset, freelist->size); - if (freelist->offset + freelist->size > h->mem_alloc) { - fprintf(stream, "***THAT FREE BLOCK IS OUT OF BOUNDS!\n"); - } else { - for (i=overlap=0; i<(int)(freelist->size); i++) { - if (marker[freelist->offset + i]) - overlap++; - marker[freelist->offset + i] = 1; - } - if (overlap) { - fprintf(stream, "***THAT FREE BLOCK OVERLAPPED A PREVIOUS " - "ONE!\n"); - } else { - amount_free += freelist->size; - } - } - } - - if (h->mem_alloc) { - fprintf(stream, "%*s%-*s %.2f%%\n", indent, "", fwidth, - "Percent of heap used:", - (100.0 * (double)(h->mem_alloc - amount_free) / (double)h->mem_alloc)); - } - /* - * Print the data in a VMS-style octal dump. - */ - fprintf(stream, "%*sData follows (`__' indicates free region)...\n", - indent, ""); - for (i=0; i<(int)(h->disk_alloc); i+=16) { - fprintf(stream, "%*s %8d: ", indent, "", i); - for (j = 0; j < 16; j++) { - if (i+j<(int)(h->disk_alloc)) { - if (marker[i + j]) { - fprintf(stream, "__ "); - } else { - c = h->chunk[H5HL_SIZEOF_HDR(f) + i + j]; - fprintf(stream, "%02x ", c); - } - } else { - fprintf(stream, " "); - } - if (7 == j) - HDfputc(' ', stream); - } - - for (j = 0; j < 16; j++) { - if (i+j < (int)(h->disk_alloc)) { - if (marker[i + j]) { - HDfputc(' ', stream); - } else { - c = h->chunk[H5HL_SIZEOF_HDR(f) + i + j]; - if (c > ' ' && c < '~') - HDfputc(c, stream); - else - HDfputc('.', stream); - } - } - } - - HDfputc('\n', stream); - } - - H5MM_xfree(marker); - -done: - FUNC_LEAVE_NOAPI(ret_value); -} diff --git a/src/H5HLdbg.c b/src/H5HLdbg.c index aefa7c1..ee5f360 100644 --- a/src/H5HLdbg.c +++ b/src/H5HLdbg.c @@ -30,6 +30,10 @@ #include "H5Iprivate.h" /* ID Functions */ #include "H5MMprivate.h" /* Memory management */ +/* Interface initialization */ +static int interface_initialize_g = 0; +#define INTERFACE_INIT NULL + /*------------------------------------------------------------------------- * Function: H5HL_debug @@ -73,7 +77,7 @@ H5HL_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream, int indent, int fprintf(stream, "%*sLocal Heap...\n", indent, ""); fprintf(stream, "%*s%-*s %d\n", indent, "", fwidth, "Dirty:", - (int) (h->cache_info.is_dirty)); + (int) (h->cache_info.dirty)); fprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth, "Header size (in bytes):", (unsigned long) H5HL_SIZEOF_HDR(f)); @@ -1175,7 +1175,7 @@ H5O_link(const H5G_entry_t *ent, int adjust, hid_t dxpl_id) /* get header */ if (NULL == (oh = H5AC_protect(ent->file, dxpl_id, H5AC_OHDR, ent->header, - NULL, NULL))) + NULL, NULL, H5AC_WRITE))) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header"); /* adjust link count */ @@ -1308,7 +1308,7 @@ H5O_count_real (H5G_entry_t *ent, const H5O_class_t *type, hid_t dxpl_id) assert (type); /* Load the object header */ - if (NULL == (oh = H5AC_protect(ent->file, dxpl_id, H5AC_OHDR, ent->header, NULL, NULL))) + if (NULL == (oh = H5AC_protect(ent->file, dxpl_id, H5AC_OHDR, ent->header, NULL, NULL, H5AC_READ))) HGOTO_ERROR (H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header"); /* Loop over all messages, counting the ones of the type looked for */ @@ -1410,7 +1410,7 @@ H5O_exists_real(H5G_entry_t *ent, const H5O_class_t *type, int sequence, hid_t d assert(sequence>=0); /* Load the object header */ - if (NULL == (oh = H5AC_protect(ent->file, dxpl_id, H5AC_OHDR, ent->header, NULL, NULL))) + if (NULL == (oh = H5AC_protect(ent->file, dxpl_id, H5AC_OHDR, ent->header, NULL, NULL, H5AC_READ))) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header"); /* Scan through the messages looking for the right one */ @@ -1546,7 +1546,7 @@ H5O_read_real(H5G_entry_t *ent, const H5O_class_t *type, int sequence, void *mes } /* copy the message to the user-supplied buffer */ - if (NULL == (oh = H5AC_protect(ent->file, dxpl_id, H5AC_OHDR, ent->header, NULL, NULL))) + if (NULL == (oh = H5AC_protect(ent->file, dxpl_id, H5AC_OHDR, ent->header, NULL, NULL, H5AC_READ))) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "unable to load object header"); /* can we get it from the object header? */ @@ -1799,7 +1799,7 @@ H5O_modify_real(H5G_entry_t *ent, const H5O_class_t *type, int overwrite, if (0==(ent->file->intent & H5F_ACC_RDWR)) HGOTO_ERROR (H5E_OHDR, H5E_WRITEERROR, FAIL, "no write intent on file"); - if (NULL == (oh = H5AC_protect(ent->file, dxpl_id, H5AC_OHDR, ent->header, NULL, NULL))) + if (NULL == (oh = H5AC_protect(ent->file, dxpl_id, H5AC_OHDR, ent->header, NULL, NULL, H5AC_WRITE))) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header"); /* Count similar messages */ @@ -1888,7 +1888,7 @@ H5O_protect(H5G_entry_t *ent, hid_t dxpl_id) if (0==(ent->file->intent & H5F_ACC_RDWR)) HGOTO_ERROR (H5E_OHDR, H5E_WRITEERROR, NULL, "no write intent on file"); - if (NULL == (ret_value = H5AC_protect(ent->file, dxpl_id, H5AC_OHDR, ent->header, NULL, NULL))) + if (NULL == (ret_value = H5AC_protect(ent->file, dxpl_id, H5AC_OHDR, ent->header, NULL, NULL, H5AC_WRITE))) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "unable to load object header"); done: @@ -2261,7 +2261,7 @@ H5O_touch(H5G_entry_t *ent, hbool_t force, hid_t dxpl_id) HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "no write intent on file"); /* Get the object header */ - if (NULL==(oh=H5AC_protect(ent->file, dxpl_id, H5AC_OHDR, ent->header, NULL, NULL))) + if (NULL==(oh=H5AC_protect(ent->file, dxpl_id, H5AC_OHDR, ent->header, NULL, NULL, H5AC_WRITE))) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header"); /* Create/Update the modification time message */ @@ -2365,7 +2365,7 @@ H5O_bogus(H5G_entry_t *ent, hid_t dxpl_id) HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "no write intent on file"); /* Get the object header */ - if (NULL==(oh=H5AC_protect(ent->file, dxpl_id, H5AC_OHDR, ent->header, NULL, NULL))) + if (NULL==(oh=H5AC_protect(ent->file, dxpl_id, H5AC_OHDR, ent->header, NULL, NULL, H5AC_WRITE))) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header"); /* Create the "bogus" message */ @@ -2482,7 +2482,7 @@ H5O_remove_real(H5G_entry_t *ent, const H5O_class_t *type, int sequence, hid_t d HGOTO_ERROR (H5E_HEAP, H5E_WRITEERROR, FAIL, "no write intent on file"); /* load the object header */ - if (NULL == (oh = H5AC_protect(ent->file, dxpl_id, H5AC_OHDR, ent->header, NULL, NULL))) + if (NULL == (oh = H5AC_protect(ent->file, dxpl_id, H5AC_OHDR, ent->header, NULL, NULL, H5AC_WRITE))) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header"); for (u = seq = 0, curr_msg=&oh->mesg[0]; u < oh->nmesgs; u++,curr_msg++) { @@ -3171,7 +3171,7 @@ H5O_delete(H5F_t *f, hid_t dxpl_id, haddr_t addr) assert(H5F_addr_defined(addr)); /* Get the object header information */ - if (NULL == (oh = H5AC_protect(f, dxpl_id, H5AC_OHDR, addr, NULL, NULL))) + if (NULL == (oh = H5AC_protect(f, dxpl_id, H5AC_OHDR, addr, NULL, NULL, H5AC_WRITE))) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header"); /* Delete object */ @@ -3340,7 +3340,7 @@ H5O_get_info(H5G_entry_t *ent, H5O_stat_t *ostat, hid_t dxpl_id) assert (ostat); /* Get the object header information */ - if (NULL == (oh = H5AC_protect(ent->file, dxpl_id, H5AC_OHDR, ent->header, NULL, NULL))) + if (NULL == (oh = H5AC_protect(ent->file, dxpl_id, H5AC_OHDR, ent->header, NULL, NULL, H5AC_READ))) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header"); /* Iterate over all the messages, accumulating the total size & free space */ @@ -3450,7 +3450,7 @@ H5O_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, int f assert(indent >= 0); assert(fwidth >= 0); - if (NULL == (oh = H5AC_protect(f, dxpl_id, H5AC_OHDR, addr, NULL, NULL))) + if (NULL == (oh = H5AC_protect(f, dxpl_id, H5AC_OHDR, addr, NULL, NULL, H5AC_READ))) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header"); /* debug */ @@ -3415,7 +3415,6 @@ H5T_set_size(H5T_t *dt, size_t size) if(size<dt->shared->size) { int num_membs; unsigned i, max_index=0; - H5T_t *memb_type; size_t memb_offset, max_offset=0; size_t max_size; diff --git a/src/Makefile.in b/src/Makefile.in index ffd8cef..8827351 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -36,7 +36,8 @@ LIB_SRC=H5.c H5A.c H5AC.c H5B.c H5D.c H5Dcontig.c H5Dcompact.c H5Defl.c \ H5FDcore.c H5FDfamily.c H5FDgass.c H5FDlog.c H5FDmpi.c H5FDmpio.c \ H5FDmpiposix.c H5FDmulti.c H5FDsec2.c H5FDsrb.c H5FDstdio.c \ H5FDstream.c H5FL.c H5FO.c H5FS.c H5G.c H5Gent.c H5Gnode.c H5Gstab.c \ - H5HG.c H5HL.c H5HP.c H5I.c H5MF.c H5MM.c H5O.c H5Oattr.c H5Obogus.c \ + H5HG.c H5HGdbg.c H5HL.c H5HLdbg.c H5HP.c H5I.c H5MF.c H5MM.c H5O.c \ + H5Oattr.c H5Obogus.c \ H5Ocont.c H5Odtype.c H5Oefl.c H5Ofill.c H5Olayout.c H5Omtime.c \ H5Oname.c H5Onull.c H5Opline.c H5Osdspace.c H5Oshared.c H5Ostab.c \ H5P.c H5Pdcpl.c H5Pdxpl.c H5Pfapl.c H5Pfcpl.c H5Ptest.c H5R.c H5RC.c \ |