From bc010e55565dd53a40cb0187afe34f8506a990e2 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Mon, 13 Oct 2008 01:24:09 -0500 Subject: [svn-r15840] Description: Convert local heap cache client to use metadata journaling cache. Other minor cleanups & simplifications, etc. Tested on: FreeBSD/32 6.2 (duty) in debug mode FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64-amd64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN, in production mode Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN, in production mode Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN, w/szip filter, in production mode Mac OS X/32 10.5.2 (amazon) in debug mode Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode --- MANIFEST | 2 + src/H5AC2.c | 3 +- src/H5AC2private.h | 3 +- src/H5B.c | 17 +- src/H5Bprivate.h | 6 +- src/H5C2pkg.h | 2 +- src/H5Dint.c | 18 +- src/H5Distore.c | 23 +- src/H5E.c | 2 +- src/H5Fdbg.c | 2 +- src/H5Gdeprec.c | 50 +- src/H5Gent.c | 6 +- src/H5Glink.c | 60 +-- src/H5Gnode.c | 69 ++- src/H5Gpkg.h | 14 +- src/H5Gstab.c | 60 ++- src/H5Gtest.c | 46 +- src/H5HF.c | 93 ---- src/H5HFcache.c | 67 +-- src/H5HFdblock.c | 51 ++- src/H5HFhdr.c | 42 +- src/H5HFiblock.c | 55 ++- src/H5HFpkg.h | 8 +- src/H5HGcache.c | 14 +- src/H5HGpkg.h | 21 +- src/H5HL.c | 1288 ++++++++++++++++++++++++---------------------------- src/H5HLcache.c | 648 ++++++++++++++++++++++++++ src/H5HLdbg.c | 70 ++- src/H5HLint.c | 325 +++++++++++++ src/H5HLpkg.h | 88 +++- src/H5HLprivate.h | 8 +- src/H5Lexternal.c | 16 +- src/H5Oefl.c | 16 +- src/Makefile.am | 4 +- src/Makefile.in | 53 ++- test/lheap.c | 35 +- 36 files changed, 2071 insertions(+), 1214 deletions(-) create mode 100644 src/H5HLcache.c create mode 100644 src/H5HLint.c diff --git a/MANIFEST b/MANIFEST index 998dd7b..f94692c 100644 --- a/MANIFEST +++ b/MANIFEST @@ -595,7 +595,9 @@ ./src/H5HGprivate.h ./src/H5HGpublic.h ./src/H5HL.c +./src/H5HLcache.c ./src/H5HLdbg.c +./src/H5HLint.c ./src/H5HLpkg.h ./src/H5HLprivate.h ./src/H5HLpublic.h diff --git a/src/H5AC2.c b/src/H5AC2.c index 2d79e9b..c66096d 100644 --- a/src/H5AC2.c +++ b/src/H5AC2.c @@ -498,7 +498,8 @@ static const char * H5AC2_entry_type_names[H5AC2_NTYPES] = { "B-tree nodes", "symbol table nodes", - "local heaps", + "local heap prefixes", + "local heap data blocks", "global heaps", "object headers", "object header chunks", diff --git a/src/H5AC2private.h b/src/H5AC2private.h index cdbe177..c9d3beb 100644 --- a/src/H5AC2private.h +++ b/src/H5AC2private.h @@ -54,7 +54,8 @@ typedef enum { H5AC2_BT_ID = 0, /*B-tree nodes */ H5AC2_SNODE_ID, /*symbol table nodes */ - H5AC2_LHEAP_ID, /*local heap */ + H5AC2_LHEAP_PRFX_ID, /*local heap prefix */ + H5AC2_LHEAP_DBLK_ID, /*local heap data block */ H5AC2_GHEAP_ID, /*global heap */ H5AC2_OHDR_ID, /*object header */ H5AC2_OHDR_CHK_ID, /*object header chunk */ diff --git a/src/H5B.c b/src/H5B.c index a5ede15..12c0407 100644 --- a/src/H5B.c +++ b/src/H5B.c @@ -350,8 +350,7 @@ H5B_find(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void *u while (lt < rt && cmp) { idx = (lt + rt) / 2; /* compare */ - if ((cmp = (type->cmp3) (f, dxpl_id, H5B_NKEY(bt,shared,idx), udata, - H5B_NKEY(bt,shared,idx+1))) < 0) { + if ((cmp = (type->cmp3)(H5B_NKEY(bt,shared,idx), udata, H5B_NKEY(bt,shared,idx+1))) < 0) { rt = idx; } else { lt = idx+1; @@ -971,8 +970,7 @@ H5B_insert_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type while (lt < rt && cmp) { idx = (lt + rt) / 2; - if ((cmp = (type->cmp3) (f, dxpl_id, H5B_NKEY(bt,shared,idx), udata, - H5B_NKEY(bt,shared,idx+1))) < 0) { + if ((cmp = (type->cmp3)(H5B_NKEY(bt,shared,idx), udata, H5B_NKEY(bt,shared,idx+1))) < 0) { rt = idx; } else { lt = idx + 1; @@ -1166,7 +1164,7 @@ H5B_insert_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type * The max key in the original left node must be equal to the min key * in the new node. */ - cmp = (type->cmp2) (f, dxpl_id, H5B_NKEY(bt,shared,bt->nchildren), udata, + cmp = (type->cmp2)(H5B_NKEY(bt,shared,bt->nchildren), udata, H5B_NKEY(twin,shared,0)); assert(0 == cmp); #endif @@ -1449,8 +1447,7 @@ H5B_remove_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type rt = bt->nchildren; while (ltcmp3)(f, dxpl_id, H5B_NKEY(bt,shared,idx), udata, - H5B_NKEY(bt,shared,idx+1)))<0) { + if ((cmp=(type->cmp3)(H5B_NKEY(bt,shared,idx), udata, H5B_NKEY(bt,shared,idx+1)))<0) { rt = idx; } else { lt = idx+1; @@ -2300,14 +2297,14 @@ H5B_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, int f HDfprintf(stream, "%*s%-*s\n", indent + 3, "", MAX(0, fwidth - 3), "Left Key:"); assert(H5B_NKEY(bt,shared,u)); - (void)(type->debug_key)(stream, f, dxpl_id, indent+6, MAX (0, fwidth-6), + (void)(type->debug_key)(stream, indent+6, MAX (0, fwidth-6), H5B_NKEY(bt,shared,u), udata); /* Decode the 'right' key & print it */ HDfprintf(stream, "%*s%-*s\n", indent + 3, "", MAX(0, fwidth - 3), "Right Key:"); assert(H5B_NKEY(bt,shared,u+1)); - (void)(type->debug_key)(stream, f, dxpl_id, indent+6, MAX (0, fwidth-6), + (void)(type->debug_key)(stream, indent+6, MAX (0, fwidth-6), H5B_NKEY(bt,shared,u+1), udata); } } @@ -2438,7 +2435,7 @@ H5B_assert(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type, void tail = tmp; /* Check that the keys are monotonically increasing */ - cmp = (type->cmp2) (f, dxpl_id, H5B_NKEY(bt,shared,i), udata, + cmp = (type->cmp2)(H5B_NKEY(bt,shared,i), udata, H5B_NKEY(bt,shared,i+1)); assert(cmp < 0); } diff --git a/src/H5Bprivate.h b/src/H5Bprivate.h index 3b0a869..da18733 100644 --- a/src/H5Bprivate.h +++ b/src/H5Bprivate.h @@ -100,8 +100,8 @@ typedef struct H5B_class_t { size_t sizeof_nkey; /*size of native (memory) key*/ H5RC_t * (*get_shared)(const H5F_t*, const void*); /*shared info for node */ herr_t (*new_node)(H5F_t*, hid_t, H5B_ins_t, void*, void*, void*, haddr_t*); - int (*cmp2)(H5F_t*, hid_t, void*, void*, void*); /*compare 2 keys */ - int (*cmp3)(H5F_t*, hid_t, void*, void*, void*); /*compare 3 keys */ + int (*cmp2)(void*, void*, void*); /*compare 2 keys */ + int (*cmp3)(void*, void*, void*); /*compare 3 keys */ herr_t (*found)(H5F_t*, hid_t, haddr_t, const void*, void*); /* insert new data */ @@ -119,7 +119,7 @@ typedef struct H5B_class_t { /* encode, decode, debug key values */ herr_t (*decode)(const H5B_shared_t*, const uint8_t*, void*); herr_t (*encode)(const H5B_shared_t*, uint8_t*, const void*); - herr_t (*debug_key)(FILE*, H5F_t*, hid_t, int, int, const void*, const void*); + herr_t (*debug_key)(FILE*, int, int, const void*, const void*); } H5B_class_t; /* Information about B-tree */ diff --git a/src/H5C2pkg.h b/src/H5C2pkg.h index 66fdd6f..3510dc7 100644 --- a/src/H5C2pkg.h +++ b/src/H5C2pkg.h @@ -1156,7 +1156,7 @@ typedef struct H5C2_mdjsc_record_t #define H5C2__HASH_TABLE_LEN (64 * 1024) /* must be a power of 2 */ #define H5C2__H5C2_T_MAGIC 0x005CAC0F -#define H5C2__MAX_NUM_TYPE_IDS 17 +#define H5C2__MAX_NUM_TYPE_IDS 18 #define H5C2__PREFIX_LEN 32 #define H5C2__MAX_API_NAME_LEN 128 diff --git a/src/H5Dint.c b/src/H5Dint.c index 8406cda..2d7b16d 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -904,7 +904,7 @@ H5D_update_oh_info(H5F_t *file, hid_t dxpl_id, H5D_t *dset) /* Update external storage message, if it's used */ if(dset->shared->dcpl_cache.efl.nused > 0) { H5O_efl_t *efl = &dset->shared->dcpl_cache.efl; /* Dataset's external file list */ - H5HL_t *heap; /* Pointer to local heap for EFL file names */ + H5HL_t *heap; /* Pointer to local heap for EFL file names */ size_t heap_size = H5HL_ALIGN(1); size_t u; @@ -917,12 +917,12 @@ H5D_update_oh_info(H5F_t *file, hid_t dxpl_id, H5D_t *dset) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create EFL file name heap") /* Pin the heap down in memory */ - if(NULL == (heap = H5HL_protect(file, dxpl_id, efl->heap_addr, H5AC_WRITE))) + if(NULL == (heap = H5HL_protect(file, dxpl_id, efl->heap_addr, H5AC2_WRITE))) HGOTO_ERROR(H5E_DATASET, H5E_CANTPROTECT, FAIL, "unable to protect EFL file name heap") /* Insert "empty" name first */ if((size_t)(-1) == H5HL_insert(file, dxpl_id, heap, (size_t)1, "")) { - H5HL_unprotect(file, dxpl_id, heap, efl->heap_addr); + H5HL_unprotect(heap); HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "unable to insert file name into heap") } /* end if */ @@ -932,7 +932,7 @@ H5D_update_oh_info(H5F_t *file, hid_t dxpl_id, H5D_t *dset) /* Insert file name into heap */ if((size_t)(-1) == (offset = H5HL_insert(file, dxpl_id, heap, HDstrlen(efl->slot[u].name) + 1, efl->slot[u].name))) { - H5HL_unprotect(file, dxpl_id, heap, efl->heap_addr); + H5HL_unprotect(heap); HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "unable to insert file name into heap") } /* end if */ @@ -942,7 +942,7 @@ H5D_update_oh_info(H5F_t *file, hid_t dxpl_id, H5D_t *dset) } /* end for */ /* Release the heap */ - if(H5HL_unprotect(file, dxpl_id, heap, efl->heap_addr) < 0) + if(H5HL_unprotect(heap) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTUNPROTECT, FAIL, "unable to unprotect EFL file name heap") heap = NULL; @@ -1572,7 +1572,7 @@ H5D_close(H5D_t *dataset) dataset->shared->fo_count--; if(dataset->shared->fo_count == 0) { /* Flush the dataset's information */ - if(H5D_flush_real(dataset, H5AC_dxpl_id, H5F_FLUSH_NONE) < 0) + if(H5D_flush_real(dataset, H5AC2_dxpl_id, H5F_FLUSH_NONE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to flush cached dataset info") /* Free the data sieve buffer, if it's been allocated */ @@ -1608,7 +1608,7 @@ H5D_close(H5D_t *dataset) } /* end if */ /* Flush and destroy chunks in the cache */ - if(H5D_chunk_dest(dataset->oloc.file, H5AC_dxpl_id, dataset) < 0) + if(H5D_chunk_dest(dataset->oloc.file, H5AC2_dxpl_id, dataset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to destroy chunk cache") break; @@ -1634,7 +1634,7 @@ H5D_close(H5D_t *dataset) /* Remove the dataset from the list of opened objects in the file */ if(H5FO_top_decr(dataset->oloc.file, dataset->oloc.addr) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "can't decrement count for object") - if(H5FO_delete(dataset->oloc.file, H5AC_dxpl_id, dataset->oloc.addr) < 0) + if(H5FO_delete(dataset->oloc.file, H5AC2_dxpl_id, dataset->oloc.addr) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "can't remove dataset from list of open objects") /* Close the dataset object */ @@ -2196,7 +2196,7 @@ H5D_vlen_get_buf_size_alloc(size_t size, void *info) H5D_vlen_bufsize_t *vlen_bufsize = (H5D_vlen_bufsize_t *)info; void *ret_value; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_vlen_get_buf_size_alloc) + FUNC_ENTER_NOAPI_NOINIT(H5D_vlen_get_buf_size_alloc) /* Get a temporary pointer to space for the VL data */ if((vlen_bufsize->vl_tbuf = H5FL_BLK_REALLOC(vlen_vl_buf, vlen_bufsize->vl_tbuf, size)) != NULL) diff --git a/src/H5Distore.c b/src/H5Distore.c index 424a81d..93f956c 100644 --- a/src/H5Distore.c +++ b/src/H5Distore.c @@ -135,10 +135,8 @@ static H5RC_t *H5D_istore_get_shared(const H5F_t *f, const void *_udata); static herr_t H5D_istore_new_node(H5F_t *f, hid_t dxpl_id, H5B_ins_t, void *_lt_key, void *_udata, void *_rt_key, haddr_t *addr_p /*out*/); -static int H5D_istore_cmp2(H5F_t *f, hid_t dxpl_id, void *_lt_key, void *_udata, - void *_rt_key); -static int H5D_istore_cmp3(H5F_t *f, hid_t dxpl_id, void *_lt_key, void *_udata, - void *_rt_key); +static int H5D_istore_cmp2(void *_lt_key, void *_udata, void *_rt_key); +static int H5D_istore_cmp3(void *_lt_key, void *_udata, void *_rt_key); static herr_t H5D_istore_found(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_lt_key, void *_udata); static H5B_ins_t H5D_istore_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_lt_key, @@ -151,9 +149,8 @@ static H5B_ins_t H5D_istore_remove( H5F_t *f, hid_t dxpl_id, haddr_t addr, void hbool_t *rt_key_changed); static herr_t H5D_istore_decode_key(const H5B_shared_t *shared, const uint8_t *raw, void *_key); static herr_t H5D_istore_encode_key(const H5B_shared_t *shared, uint8_t *raw, const void *_key); -static herr_t H5D_istore_debug_key(FILE *stream, H5F_t *f, hid_t dxpl_id, - int indent, int fwidth, const void *key, - const void *udata); +static herr_t H5D_istore_debug_key(FILE *stream, int indent, int fwidth, + const void *key, const void *udata); /* Chunked layout indexing callbacks */ static herr_t H5D_istore_idx_init(const H5D_chk_idx_info_t *idx_info); @@ -345,8 +342,8 @@ H5D_istore_encode_key(const H5B_shared_t *shared, uint8_t *raw, const void *_key */ /* ARGSUSED */ static herr_t -H5D_istore_debug_key(FILE *stream, H5F_t UNUSED *f, hid_t UNUSED dxpl_id, int indent, int fwidth, - const void *_key, const void *_udata) +H5D_istore_debug_key(FILE *stream, int indent, int fwidth, const void *_key, + const void *_udata) { const H5D_istore_key_t *key = (const H5D_istore_key_t *)_key; const H5D_istore_ud0_t *udata = (const H5D_istore_ud0_t *)_udata; @@ -388,8 +385,7 @@ H5D_istore_debug_key(FILE *stream, H5F_t UNUSED *f, hid_t UNUSED dxpl_id, int in */ /* ARGSUSED */ static int -H5D_istore_cmp2(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, void *_lt_key, void *_udata, - void *_rt_key) +H5D_istore_cmp2(void *_lt_key, void *_udata, void *_rt_key) { H5D_istore_key_t *lt_key = (H5D_istore_key_t *) _lt_key; H5D_istore_key_t *rt_key = (H5D_istore_key_t *) _rt_key; @@ -439,8 +435,7 @@ H5D_istore_cmp2(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, void *_lt_key, void *_uda */ /* ARGSUSED */ static int -H5D_istore_cmp3(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, void *_lt_key, void *_udata, - void *_rt_key) +H5D_istore_cmp3(void *_lt_key, void *_udata, void *_rt_key) { H5D_istore_key_t *lt_key = (H5D_istore_key_t *) _lt_key; H5D_istore_key_t *rt_key = (H5D_istore_key_t *) _rt_key; @@ -668,7 +663,7 @@ H5D_istore_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_lt_key, HDassert(rt_key); HDassert(new_node_p); - cmp = H5D_istore_cmp3(f, dxpl_id, lt_key, udata, rt_key); + cmp = H5D_istore_cmp3(lt_key, udata, rt_key); HDassert(cmp <= 0); if(cmp < 0) { diff --git a/src/H5E.c b/src/H5E.c index 72f0619..6068fff 100644 --- a/src/H5E.c +++ b/src/H5E.c @@ -334,7 +334,7 @@ H5E_get_stack(void) { H5E_t *estack; - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5E_get_stack) + FUNC_ENTER_NOAPI_NOINIT(H5E_get_stack) estack = pthread_getspecific(H5TS_errstk_key_g); diff --git a/src/H5Fdbg.c b/src/H5Fdbg.c index d0fe402..edc138f 100644 --- a/src/H5Fdbg.c +++ b/src/H5Fdbg.c @@ -138,7 +138,7 @@ H5F_debug(H5F_t *f, FILE *stream, int indent, int fwidth) root_ent.header = root_oloc->addr; /* Display root group symbol table entry info */ - H5G_ent_debug(f, &root_ent, stream, indent + 3, MAX(0, fwidth - 3), NULL); + H5G_ent_debug(&root_ent, stream, indent + 3, MAX(0, fwidth - 3), NULL); } /* end if */ done: diff --git a/src/H5Gdeprec.c b/src/H5Gdeprec.c index d38e30e..051dd23 100644 --- a/src/H5Gdeprec.c +++ b/src/H5Gdeprec.c @@ -204,7 +204,7 @@ H5Gcreate1(hid_t loc_id, const char *name, size_t size_hint) hid_t tmp_gcpl = (-1); /* Temporary group creation property list */ hid_t ret_value; /* Return value */ - FUNC_ENTER_API_META(H5Gcreate1, loc_id, H5AC_dxpl_id, FAIL) + FUNC_ENTER_API_META(H5Gcreate1, loc_id, H5AC2_dxpl_id, FAIL) H5TRACE3("i", "i*sz", loc_id, name, size_hint); /* Check arguments */ @@ -244,7 +244,7 @@ H5Gcreate1(hid_t loc_id, const char *name, size_t size_hint) /* Create the new group & get its ID */ if(NULL == (grp = H5G_create_named(&loc, name, H5P_LINK_CREATE_DEFAULT, - tmp_gcpl, H5P_GROUP_ACCESS_DEFAULT, H5AC_dxpl_id))) + tmp_gcpl, H5P_GROUP_ACCESS_DEFAULT, H5AC2_dxpl_id))) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group") if((ret_value = H5I_register(H5I_GROUP, grp)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register group") @@ -296,7 +296,7 @@ H5Gopen1(hid_t loc_id, const char *name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") /* Open the group */ - if((grp = H5G_open_name(&loc, name, H5P_DEFAULT, H5AC_dxpl_id)) == NULL) + if((grp = H5G_open_name(&loc, name, H5P_DEFAULT, H5AC2_dxpl_id)) == NULL) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open group") /* Register an atom for the group */ @@ -326,7 +326,7 @@ H5Glink(hid_t cur_loc_id, H5G_link_t type, const char *cur_name, const char *new { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API_META(H5Glink, cur_loc_id, H5AC_dxpl_id, FAIL) + FUNC_ENTER_API_META(H5Glink, cur_loc_id, H5AC2_dxpl_id, FAIL) H5TRACE4("e", "iLl*s*s", cur_loc_id, type, cur_name, new_name); /* Check arguments */ @@ -347,7 +347,7 @@ H5Glink(hid_t cur_loc_id, H5G_link_t type, const char *cur_name, const char *new HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") /* Create the link */ - if(H5L_create_soft(cur_name, &cur_loc, new_name, H5P_DEFAULT, H5P_DEFAULT, H5AC_dxpl_id) < 0) + if(H5L_create_soft(cur_name, &cur_loc, new_name, H5P_DEFAULT, H5P_DEFAULT, H5AC2_dxpl_id) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") } /* end else if */ else @@ -372,7 +372,7 @@ H5Glink2(hid_t cur_loc_id, const char *cur_name, H5G_link_t type, { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API_META(H5Glink2, cur_loc_id, H5AC_dxpl_id, FAIL) + FUNC_ENTER_API_META(H5Glink2, cur_loc_id, H5AC2_dxpl_id, FAIL) H5TRACE5("e", "i*sLli*s", cur_loc_id, cur_name, type, new_loc_id, new_name); /* Check arguments */ @@ -398,7 +398,7 @@ H5Glink2(hid_t cur_loc_id, const char *cur_name, H5G_link_t type, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") /* Create the link */ - if(H5L_create_soft(cur_name, &new_loc, new_name, H5P_DEFAULT, H5P_DEFAULT, H5AC_dxpl_id) < 0) + if(H5L_create_soft(cur_name, &new_loc, new_name, H5P_DEFAULT, H5P_DEFAULT, H5AC2_dxpl_id) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") } /* end else if */ else @@ -455,7 +455,7 @@ H5G_link_hard(hid_t cur_loc_id, const char *cur_name, hid_t new_loc_id, /* Create the link */ if(H5L_create_hard(cur_loc_p, cur_name, new_loc_p, new_name, - H5P_DEFAULT, H5P_DEFAULT, H5AC_dxpl_id) < 0) + H5P_DEFAULT, H5P_DEFAULT, H5AC2_dxpl_id) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") done: @@ -475,7 +475,7 @@ H5Gmove(hid_t src_loc_id, const char *src_name, const char *dst_name) { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API_META(H5Gmove, src_loc_id, H5AC_dxpl_id, FAIL) + FUNC_ENTER_API_META(H5Gmove, src_loc_id, H5AC2_dxpl_id, FAIL) H5TRACE3("e", "i*s*s", src_loc_id, src_name, dst_name); /* Call common routine to move the link */ @@ -500,7 +500,7 @@ H5Gmove2(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API_META(H5Gmove2, dst_loc_id, H5AC_dxpl_id, FAIL) + FUNC_ENTER_API_META(H5Gmove2, dst_loc_id, H5AC2_dxpl_id, FAIL) H5TRACE4("e", "i*si*s", src_loc_id, src_name, dst_loc_id, dst_name); /* Call common routine to move the link */ @@ -561,7 +561,7 @@ H5G_move(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, /* Move the link */ if(H5L_move(src_loc_p, src_name, dst_loc_p, dst_name, FALSE, H5P_DEFAULT, - H5P_DEFAULT, H5AC_dxpl_id) < 0) + H5P_DEFAULT, H5AC2_dxpl_id) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTMOVE, FAIL, "unable to move link") done: @@ -582,7 +582,7 @@ H5Gunlink(hid_t loc_id, const char *name) H5G_loc_t loc; /* Group's location */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API_META(H5Gunlink, loc_id, H5AC_dxpl_id, FAIL) + FUNC_ENTER_API_META(H5Gunlink, loc_id, H5AC2_dxpl_id, FAIL) H5TRACE2("e", "i*s", loc_id, name); /* Check arguments */ @@ -592,7 +592,7 @@ H5Gunlink(hid_t loc_id, const char *name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") /* Call H5L routine... */ - if(H5L_delete(&loc, name, H5P_DEFAULT, H5AC_dxpl_id) < 0) + if(H5L_delete(&loc, name, H5P_DEFAULT, H5AC2_dxpl_id) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "couldn't delete link") done: @@ -624,7 +624,7 @@ H5Gget_linkval(hid_t loc_id, const char *name, size_t size, char *buf/*out*/) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") /* Call the new link routine which provides this capability */ - if(H5L_get_val(&loc, name, buf, size, H5P_DEFAULT, H5AC_ind_dxpl_id) < 0) + if(H5L_get_val(&loc, name, buf, size, H5P_DEFAULT, H5AC2_ind_dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "couldn't get link info") done: @@ -655,7 +655,7 @@ H5Gset_comment(hid_t loc_id, const char *name, const char *comment) H5G_loc_t loc; herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API_META(H5Gset_comment, loc_id, H5AC_dxpl_id, FAIL) + FUNC_ENTER_API_META(H5Gset_comment, loc_id, H5AC2_dxpl_id, FAIL) H5TRACE3("e", "i*s*s", loc_id, name, comment); if(H5G_loc(loc_id, &loc) < 0) @@ -663,7 +663,7 @@ H5Gset_comment(hid_t loc_id, const char *name, const char *comment) if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") - if(H5G_loc_set_comment(&loc, name, comment, H5P_DEFAULT, H5AC_dxpl_id) < 0) + if(H5G_loc_set_comment(&loc, name, comment, H5P_DEFAULT, H5AC2_dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to set comment value") done: @@ -710,7 +710,7 @@ H5Gget_comment(hid_t loc_id, const char *name, size_t bufsize, char *buf) if(bufsize > 0 && !buf) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no buffer specified") - if((ret_value = (int)H5G_loc_get_comment(&loc, name, buf, bufsize, H5P_DEFAULT, H5AC_ind_dxpl_id)) < 0) + if((ret_value = (int)H5G_loc_get_comment(&loc, name, buf, bufsize, H5P_DEFAULT, H5AC2_ind_dxpl_id)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to get comment value") done: @@ -774,7 +774,7 @@ H5Giterate(hid_t loc_id, const char *name, int *idx_p, H5G_iterate_t op, lnk_op.op_func.op_old = op; /* Call private function. */ - if((ret_value = H5G_iterate(loc_id, name, H5_INDEX_NAME, H5_ITER_INC, idx, &last_obj, &lnk_op, op_data, H5P_DEFAULT, H5AC_ind_dxpl_id)) < 0) + if((ret_value = H5G_iterate(loc_id, name, H5_INDEX_NAME, H5_ITER_INC, idx, &last_obj, &lnk_op, op_data, H5P_DEFAULT, H5AC2_ind_dxpl_id)) < 0) HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "group iteration failed") /* Set the index we stopped at */ @@ -816,7 +816,7 @@ H5Gget_num_objs(hid_t loc_id, hsize_t *num_objs) /* Check args */ if(H5G_loc(loc_id, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location ID") - if(H5O_obj_type(loc.oloc, &obj_type, H5AC_ind_dxpl_id) < 0) + if(H5O_obj_type(loc.oloc, &obj_type, H5AC2_ind_dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get object type") if(obj_type != H5O_TYPE_GROUP) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") @@ -824,7 +824,7 @@ H5Gget_num_objs(hid_t loc_id, hsize_t *num_objs) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad pointer to # of objects") /* Retrieve information about the group */ - if(H5G_obj_info(loc.oloc, &grp_info, H5AC_ind_dxpl_id) < 0) + if(H5G_obj_info(loc.oloc, &grp_info, H5AC2_ind_dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTCOUNT, FAIL, "can't determine") /* Set the number of objects [sic: links] in the group */ @@ -869,7 +869,7 @@ H5Gget_objinfo(hid_t loc_id, const char *name, hbool_t follow_link, HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") /* Get info */ - if(H5G_get_objinfo(&loc, name, follow_link, statbuf, H5AC_ind_dxpl_id) < 0) + if(H5G_get_objinfo(&loc, name, follow_link, statbuf, H5AC2_ind_dxpl_id) < 0) HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "cannot stat object") done: @@ -1062,13 +1062,13 @@ H5Gget_objname_by_idx(hid_t loc_id, hsize_t idx, char *name, size_t size) /* Check args */ if(H5G_loc(loc_id, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location ID") - if(H5O_obj_type(loc.oloc, &obj_type, H5AC_ind_dxpl_id) < 0) + if(H5O_obj_type(loc.oloc, &obj_type, H5AC2_ind_dxpl_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get object type") if(obj_type != H5O_TYPE_GROUP) HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "not a group") /* Call internal function */ - if((ret_value = H5G_obj_get_name_by_idx(loc.oloc, H5_INDEX_NAME, H5_ITER_INC, idx, name, size, H5AC_ind_dxpl_id)) < 0) + if((ret_value = H5G_obj_get_name_by_idx(loc.oloc, H5_INDEX_NAME, H5_ITER_INC, idx, name, size, H5AC2_ind_dxpl_id)) < 0) HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, FAIL, "can't get object name") done: @@ -1104,13 +1104,13 @@ H5Gget_objtype_by_idx(hid_t loc_id, hsize_t idx) /* Check args */ if(H5G_loc(loc_id, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5G_UNKNOWN, "not a location ID") - if(H5O_obj_type(loc.oloc, &obj_type, H5AC_ind_dxpl_id) < 0) + if(H5O_obj_type(loc.oloc, &obj_type, H5AC2_ind_dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get object type") if(obj_type != H5O_TYPE_GROUP) HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, FAIL, "not a group") /* Call internal function*/ - if((ret_value = H5G_obj_get_type_by_idx(loc.oloc, idx, H5AC_ind_dxpl_id)) == H5G_UNKNOWN) + if((ret_value = H5G_obj_get_type_by_idx(loc.oloc, idx, H5AC2_ind_dxpl_id)) == H5G_UNKNOWN) HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, FAIL, "can't get object type") done: diff --git a/src/H5Gent.c b/src/H5Gent.c index 7c0a2f6..21023ee 100644 --- a/src/H5Gent.c +++ b/src/H5Gent.c @@ -441,8 +441,8 @@ done: *------------------------------------------------------------------------- */ herr_t -H5G_ent_debug(H5F_t *f, const H5G_entry_t *ent, FILE *stream, - int indent, int fwidth, H5HL_t *heap) +H5G_ent_debug(const H5G_entry_t *ent, FILE *stream, int indent, int fwidth, + const H5HL_t *heap) { const char *lval = NULL; int nested_indent, nested_fwidth; @@ -490,7 +490,7 @@ H5G_ent_debug(H5F_t *f, const H5G_entry_t *ent, FILE *stream, "Link value offset:", (unsigned long)(ent->cache.slink.lval_offset)); if(heap) { - lval = H5HL_offset_into(f, heap, ent->cache.slink.lval_offset); + lval = H5HL_offset_into(heap, ent->cache.slink.lval_offset); HDfprintf(stream, "%*s%-*s %s\n", nested_indent, "", nested_fwidth, "Link value:", lval); diff --git a/src/H5Glink.c b/src/H5Glink.c index 75a3e83..8122f6a 100644 --- a/src/H5Glink.c +++ b/src/H5Glink.c @@ -217,13 +217,12 @@ H5G_link_cmp_corder_dec(const void *lnk1, const void *lnk2) *------------------------------------------------------------------------- */ herr_t -H5G_ent_to_link(H5F_t *f, H5O_link_t *lnk, const H5HL_t *heap, +H5G_ent_to_link(H5O_link_t *lnk, const H5HL_t *heap, const H5G_entry_t *ent, const char *name) { FUNC_ENTER_NOAPI_NOFUNC(H5G_ent_to_link) /* check arguments */ - HDassert(f); HDassert(lnk); HDassert(heap); HDassert(ent); @@ -240,7 +239,7 @@ H5G_ent_to_link(H5F_t *f, H5O_link_t *lnk, const H5HL_t *heap, if(ent->type == H5G_CACHED_SLINK) { const char *s; /* Pointer to link value */ - s = H5HL_offset_into(f, heap, ent->cache.slink.lval_offset); + s = H5HL_offset_into(heap, ent->cache.slink.lval_offset); HDassert(s); /* Copy the link value */ @@ -262,61 +261,6 @@ H5G_ent_to_link(H5F_t *f, H5O_link_t *lnk, const H5HL_t *heap, /*------------------------------------------------------------------------- - * Function: H5G_ent_to_info - * - * Purpose: Make link info for a symbol table entry - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * koziol@hdfgroup.org - * Nov 16 2006 - * - *------------------------------------------------------------------------- - */ -herr_t -H5G_ent_to_info(H5F_t *f, H5L_info_t *info, const H5HL_t *heap, - const H5G_entry_t *ent) -{ - FUNC_ENTER_NOAPI_NOFUNC(H5G_ent_to_info) - - /* check arguments */ - HDassert(f); - HDassert(info); - HDassert(heap); - HDassert(ent); - - /* Set (default) common info for info */ - info->cset = H5F_DEFAULT_CSET; - info->corder = 0; - info->corder_valid = FALSE; /* Creation order not valid for this link */ - - /* Object is a symbolic or hard link */ - if(ent->type == H5G_CACHED_SLINK) { - const char *s; /* Pointer to link value */ - - s = H5HL_offset_into(f, heap, ent->cache.slink.lval_offset); - HDassert(s); - - /* Get the link value size */ - info->u.val_size = HDstrlen(s) + 1; - - /* Set link type */ - info->type = H5L_TYPE_SOFT; - } /* end if */ - else { - /* Set address of object */ - info->u.address = ent->header; - - /* Set link type */ - info->type = H5L_TYPE_HARD; - } /* end else */ - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5G_ent_to_info() */ - - -/*------------------------------------------------------------------------- * Function: H5G_link_to_info * * Purpose: Retrieve information from a link object diff --git a/src/H5Gnode.c b/src/H5Gnode.c index 0e918bf..4c44bd9 100644 --- a/src/H5Gnode.c +++ b/src/H5Gnode.c @@ -88,10 +88,8 @@ static H5RC_t *H5G_node_get_shared(const H5F_t *f, const void *_udata); static herr_t H5G_node_create(H5F_t *f, hid_t dxpl_id, H5B_ins_t op, void *_lt_key, void *_udata, void *_rt_key, haddr_t *addr_p/*out*/); -static int H5G_node_cmp2(H5F_t *f, hid_t dxpl_id, void *_lt_key, void *_udata, - void *_rt_key); -static int H5G_node_cmp3(H5F_t *f, hid_t dxpl_id, void *_lt_key, void *_udata, - void *_rt_key); +static int H5G_node_cmp2(void *_lt_key, void *_udata, void *_rt_key); +static int H5G_node_cmp3(void *_lt_key, void *_udata, void *_rt_key); static herr_t H5G_node_found(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_lt_key, void *_udata); static H5B_ins_t H5G_node_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_lt_key, @@ -104,9 +102,8 @@ static H5B_ins_t H5G_node_remove(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *lt void *rt_key, hbool_t *rt_key_changed); static herr_t H5G_node_decode_key(const H5B_shared_t *shared, const uint8_t *raw, void *_key); static herr_t H5G_node_encode_key(const H5B_shared_t *shared, uint8_t *raw, const void *_key); -static herr_t H5G_node_debug_key(FILE *stream, H5F_t *f, hid_t dxpl_id, - int indent, int fwidth, const void *key, - const void *udata); +static herr_t H5G_node_debug_key(FILE *stream, int indent, int fwidth, + const void *key, const void *udata); /* H5G symbol table node inherits cache-like properties from H5AC2 */ const H5AC2_class_t H5AC2_SNODE[1] = {{ @@ -247,8 +244,8 @@ H5G_node_encode_key(const H5B_shared_t *shared, uint8_t *raw, const void *_key) *------------------------------------------------------------------------- */ static herr_t -H5G_node_debug_key(FILE *stream, H5F_t *f, hid_t UNUSED dxpl_id, int indent, - int fwidth, const void *_key, const void *_udata) +H5G_node_debug_key(FILE *stream, int indent, int fwidth, const void *_key, + const void *_udata) { const H5G_node_key_t *key = (const H5G_node_key_t *) _key; const H5G_bt_common_t *udata = (const H5G_bt_common_t *) _udata; @@ -265,7 +262,7 @@ H5G_node_debug_key(FILE *stream, H5F_t *f, hid_t UNUSED dxpl_id, int indent, HDfprintf(stream, "%*s%-*s ", indent, "", fwidth, "Name:"); - s = H5HL_offset_into(f, udata->heap, key->offset); + s = H5HL_offset_into(udata->heap, key->offset); HDfprintf(stream, "%s\n", s); } /* end if */ else @@ -633,8 +630,7 @@ done: *------------------------------------------------------------------------- */ static int -H5G_node_cmp2(H5F_t *f, hid_t UNUSED dxpl_id, void *_lt_key, void *_udata, - void *_rt_key) +H5G_node_cmp2(void *_lt_key, void *_udata, void *_rt_key) { H5G_bt_common_t *udata = (H5G_bt_common_t *) _udata; H5G_node_key_t *lt_key = (H5G_node_key_t *) _lt_key; @@ -651,7 +647,7 @@ H5G_node_cmp2(H5F_t *f, hid_t UNUSED dxpl_id, void *_lt_key, void *_udata, HDassert(rt_key); /* Get base address of heap */ - base = H5HL_offset_into(f, udata->heap, (size_t)0); + base = H5HL_offset_into(udata->heap, (size_t)0); HDassert(base); /* Get pointers to string names */ @@ -693,8 +689,7 @@ H5G_node_cmp2(H5F_t *f, hid_t UNUSED dxpl_id, void *_lt_key, void *_udata, *------------------------------------------------------------------------- */ static int -H5G_node_cmp3(H5F_t *f, hid_t UNUSED dxpl_id, void *_lt_key, void *_udata, - void *_rt_key) +H5G_node_cmp3(void *_lt_key, void *_udata, void *_rt_key) { H5G_bt_common_t *udata = (H5G_bt_common_t *) _udata; H5G_node_key_t *lt_key = (H5G_node_key_t *) _lt_key; @@ -711,7 +706,7 @@ H5G_node_cmp3(H5F_t *f, hid_t UNUSED dxpl_id, void *_lt_key, void *_udata, HDassert(rt_key); /* Get base address of heap */ - base = H5HL_offset_into(f, udata->heap, (size_t)0); + base = H5HL_offset_into(udata->heap, (size_t)0); HDassert(base); /* left side */ @@ -783,7 +778,7 @@ H5G_node_found(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED *_lt_key HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, FAIL, "unable to protect symbol table node") /* Get base address of heap */ - base = H5HL_offset_into(f, udata->common.heap, (size_t)0); + base = H5HL_offset_into(udata->common.heap, (size_t)0); HDassert(base); /* @@ -889,7 +884,7 @@ H5G_node_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr, HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5B_INS_ERROR, "unable to protect symbol table node") /* Get base address of heap */ - base = H5HL_offset_into(f, udata->common.heap, (size_t)0); + base = H5HL_offset_into(udata->common.heap, (size_t)0); HDassert(base); /* @@ -1055,7 +1050,7 @@ H5G_node_remove(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_lt_key/*in,out*/, const char *base; /* Base of heap */ /* Get base address of heap */ - base = H5HL_offset_into(f, udata->common.heap, (size_t)0); + base = H5HL_offset_into(udata->common.heap, (size_t)0); /* Find the name with a binary search */ rt = sn->nsyms; @@ -1075,7 +1070,7 @@ H5G_node_remove(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_lt_key/*in,out*/, HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5B_INS_ERROR, "name not found") /* Get a pointer to the name of the link */ - if(NULL == (lnk.name = H5HL_offset_into(f, udata->common.heap, sn->entry[idx].name_off))) + if(NULL == (lnk.name = H5HL_offset_into(udata->common.heap, sn->entry[idx].name_off))) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to get link name") /* Set up rest of link structure */ @@ -1084,7 +1079,7 @@ H5G_node_remove(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_lt_key/*in,out*/, lnk.cset = H5T_CSET_ASCII; if(sn->entry[idx].type == H5G_CACHED_SLINK) { lnk.type = H5L_TYPE_SOFT; - lnk.u.soft.name = H5HL_offset_into(f, udata->common.heap, sn->entry[idx].cache.slink.lval_offset); + lnk.u.soft.name = H5HL_offset_into(udata->common.heap, sn->entry[idx].cache.slink.lval_offset); } /* end if */ else { lnk.type = H5L_TYPE_HARD; @@ -1269,11 +1264,11 @@ H5G_node_iterate(H5F_t *f, hid_t dxpl_id, const void UNUSED *_lt_key, haddr_t ad const char *name; /* Pointer to link name in heap */ /* Get the pointer to the name of the link in the heap */ - name = H5HL_offset_into(f, udata->heap, ents[u].name_off); + name = H5HL_offset_into(udata->heap, ents[u].name_off); HDassert(name); /* Convert the entry to a link */ - if(H5G_ent_to_link(f, &lnk, udata->heap, &ents[u], name) < 0) + if(H5G_ent_to_link(&lnk, udata->heap, &ents[u], name) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTCONVERT, H5_ITER_ERROR, "unable to convert symbol table entry to link") /* Make the callback */ @@ -1502,7 +1497,7 @@ H5G_node_copy(H5F_t *f, hid_t dxpl_id, const void UNUSED *_lt_key, haddr_t addr, H5G_bt_it_cpy_t *udata = (H5G_bt_it_cpy_t *)_udata; const H5O_loc_t *src_oloc = udata->src_oloc; H5O_copy_t *cpy_info = udata->cpy_info; - H5HL_t *heap = NULL; + H5HL_t *heap = NULL; H5G_node_t *sn = NULL; unsigned int i; /* Local index variable */ int ret_value = H5_ITER_CONT; @@ -1519,7 +1514,7 @@ H5G_node_copy(H5F_t *f, hid_t dxpl_id, const void UNUSED *_lt_key, haddr_t addr, HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5_ITER_ERROR, "unable to load symbol table node") /* get the base address of the heap */ - if(NULL == (heap = H5HL_protect(f, dxpl_id, udata->src_heap_addr, H5AC_READ))) + if(NULL == (heap = H5HL_protect(f, dxpl_id, udata->src_heap_addr, H5AC2_READ))) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5_ITER_ERROR, "unable to protect symbol name") /* copy object in this node one by one */ @@ -1545,7 +1540,7 @@ H5G_node_copy(H5F_t *f, hid_t dxpl_id, const void UNUSED *_lt_key, haddr_t addr, grp_loc.oloc = (H5O_loc_t *)src_oloc; /* Get pointer to link value in local heap */ - link_name = (char *)H5HL_offset_into(f, heap, tmp_src_ent.cache.slink.lval_offset); + link_name = (char *)H5HL_offset_into(heap, tmp_src_ent.cache.slink.lval_offset); /* Check if the object pointed by the soft link exists in the source file */ if(H5G_loc_info(&grp_loc, link_name, FALSE, &oinfo, H5P_DEFAULT, dxpl_id) >= 0) { @@ -1583,7 +1578,7 @@ H5G_node_copy(H5F_t *f, hid_t dxpl_id, const void UNUSED *_lt_key, haddr_t addr, /* Construct link information for eventual insertion */ lnk.type = H5L_TYPE_SOFT; - lnk.u.soft.name = H5HL_offset_into(f, heap, src_ent->cache.slink.lval_offset); + lnk.u.soft.name = H5HL_offset_into(heap, src_ent->cache.slink.lval_offset); } /* else if */ else HDassert(0 && "Unknown entry type"); @@ -1595,7 +1590,7 @@ H5G_node_copy(H5F_t *f, hid_t dxpl_id, const void UNUSED *_lt_key, haddr_t addr, /* lnk.name = name; */ /* This will be set in callback */ /* Determine name of source object */ - name = H5HL_offset_into(f, heap, src_ent->name_off); + name = H5HL_offset_into(heap, src_ent->name_off); HDassert(name); /* Insert the new object in the destination file's group */ @@ -1605,10 +1600,10 @@ H5G_node_copy(H5F_t *f, hid_t dxpl_id, const void UNUSED *_lt_key, haddr_t addr, } /* end of for (i=0; insyms; i++) */ done: - if (heap && H5HL_unprotect(f, dxpl_id, heap, udata->src_heap_addr) < 0) + if(heap && H5HL_unprotect(heap) < 0) HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5_ITER_ERROR, "unable to unprotect symbol name") - if (sn && H5AC2_unprotect(f, dxpl_id, H5AC2_SNODE, addr, (size_t)0, sn, H5AC2__NO_FLAGS_SET) < 0) + if(sn && H5AC2_unprotect(f, dxpl_id, H5AC2_SNODE, addr, (size_t)0, sn, H5AC2__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5_ITER_ERROR, "unable to release object header") FUNC_LEAVE_NOAPI(ret_value) @@ -1670,14 +1665,14 @@ H5G_node_build_table(H5F_t *f, hid_t dxpl_id, const void UNUSED *_lt_key, haddr_ unsigned linkno; /* Link allocated */ /* Get pointer to link's name in the heap */ - name = H5HL_offset_into(f, udata->heap, sn->entry[u].name_off); + name = H5HL_offset_into(udata->heap, sn->entry[u].name_off); HDassert(name); /* Determine the link to operate on in the table */ linkno = udata->ltable->nlinks++; /* Convert the entry to a link */ - if(H5G_ent_to_link(f, &udata->ltable->lnks[linkno], udata->heap, &sn->entry[u], name) < 0) + if(H5G_ent_to_link(&udata->ltable->lnks[linkno], udata->heap, &sn->entry[u], name) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTCONVERT, H5_ITER_ERROR, "unable to convert symbol table entry to link") } /* end for */ @@ -1740,7 +1735,7 @@ H5G_node_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream, int indent, int fwidth, haddr_t heap_addr) { H5G_node_t *sn = NULL; - H5HL_t *heap = NULL; + H5HL_t *heap = NULL; unsigned u; herr_t ret_value = SUCCEED; /* Return value */ @@ -1757,7 +1752,7 @@ H5G_node_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream, int indent, /* Pin the heap down in memory */ if(heap_addr > 0 && H5F_addr_defined(heap_addr)) - if(NULL == (heap = H5HL_protect(f, dxpl_id, heap_addr, H5AC_READ))) + if(NULL == (heap = H5HL_protect(f, dxpl_id, heap_addr, H5AC2_READ))) HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, FAIL, "unable to protect symbol table heap") /* @@ -1789,7 +1784,7 @@ H5G_node_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream, int indent, fprintf(stream, "%*sSymbol %u:\n", indent - 3, "", u); if(heap) { - const char *s = H5HL_offset_into(f, heap, sn->entry[u].name_off); + const char *s = H5HL_offset_into(heap, sn->entry[u].name_off); if(s) fprintf(stream, "%*s%-*s `%s'\n", indent, "", fwidth, "Name:", s); @@ -1797,14 +1792,14 @@ H5G_node_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream, int indent, else fprintf(stream, "%*s%-*s\n", indent, "", fwidth, "Warning: Invalid heap address given, name not displayed!"); - H5G_ent_debug(f, sn->entry + u, stream, indent, fwidth, heap); + H5G_ent_debug(sn->entry + u, stream, indent, fwidth, heap); } /* end for */ } /* end if */ done: if(sn && H5AC2_unprotect(f, dxpl_id, H5AC2_SNODE, addr, (size_t)0, sn, H5AC2__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to release symbol table node") - if(heap && H5HL_unprotect(f, dxpl_id, heap, heap_addr) < 0) + if(heap && H5HL_unprotect(heap) < 0) HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol table heap") FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Gpkg.h b/src/H5Gpkg.h index 53692c5..66cfaa7 100644 --- a/src/H5Gpkg.h +++ b/src/H5Gpkg.h @@ -161,7 +161,7 @@ typedef struct { typedef struct H5G_bt_common_t { /* downward */ const char *name; /*points to temporary memory */ - H5HL_t *heap; /*symbol table heap */ + H5HL_t *heap; /*symbol table heap */ } H5G_bt_common_t; /* @@ -206,7 +206,7 @@ typedef struct H5G_bt_lkp_t { */ typedef struct H5G_bt_it_it_t { /* downward */ - H5HL_t *heap; /*symbol table heap */ + H5HL_t *heap; /*symbol table heap */ hsize_t skip; /*initial entries to skip */ H5G_lib_iterate_t op; /*iteration operator */ void *op_data; /*user-defined operator data */ @@ -237,7 +237,7 @@ typedef struct H5G_bt_it_idx_common_t { typedef struct H5G_bt_it_bt_t { /* downward */ size_t alloc_nlinks; /* Number of links allocated in table */ - H5HL_t *heap; /*symbol table heap */ + H5HL_t *heap; /*symbol table heap */ /* upward */ H5G_link_table_t *ltable; /* Link table to add information to */ @@ -402,8 +402,8 @@ H5_DLL herr_t H5G_ent_encode_vec(const H5F_t *f, uint8_t **pp, const H5G_entry_t *ent, unsigned n); H5_DLL herr_t H5G_ent_convert(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, const char *name, const H5O_link_t *lnk, H5G_entry_t *ent); -H5_DLL herr_t H5G_ent_debug(H5F_t *f, const H5G_entry_t *ent, - FILE * stream, int indent, int fwidth, H5HL_t *heap); +H5_DLL herr_t H5G_ent_debug(const H5G_entry_t *ent, + FILE * stream, int indent, int fwidth, const H5HL_t *heap); /* Functions that understand symbol table nodes */ H5_DLL herr_t H5G_node_init(H5F_t *f); @@ -425,10 +425,8 @@ H5_DLL int H5G_link_cmp_name_inc(const void *lnk1, const void *lnk2); H5_DLL int H5G_link_cmp_name_dec(const void *lnk1, const void *lnk2); H5_DLL int H5G_link_cmp_corder_inc(const void *lnk1, const void *lnk2); H5_DLL int H5G_link_cmp_corder_dec(const void *lnk1, const void *lnk2); -H5_DLL herr_t H5G_ent_to_link(H5F_t *f, H5O_link_t *lnk, const H5HL_t *heap, +H5_DLL herr_t H5G_ent_to_link(H5O_link_t *lnk, const H5HL_t *heap, const H5G_entry_t *ent, const char *name); -H5_DLL herr_t H5G_ent_to_info(H5F_t *f, H5L_info_t *info, const H5HL_t *heap, - const H5G_entry_t *ent); H5_DLL herr_t H5G_link_to_info(const H5O_link_t *lnk, H5L_info_t *linfo); H5_DLL herr_t H5G_link_to_loc(const H5G_loc_t *grp_loc, const H5O_link_t *lnk, H5G_loc_t *obj_loc); diff --git a/src/H5Gstab.c b/src/H5Gstab.c index a5280b5..9ca0c90 100644 --- a/src/H5Gstab.c +++ b/src/H5Gstab.c @@ -33,9 +33,8 @@ /* User data for finding link information from B-tree */ typedef struct { /* downward */ - H5F_t *file; /* Pointer to file for query */ const char *name; /* Name to search for */ - H5HL_t *heap; /* Local heap for group */ + H5HL_t *heap; /* Local heap for group */ /* upward */ H5O_link_t *lnk; /* Caller's link location */ @@ -45,7 +44,7 @@ typedef struct { typedef struct H5G_bt_it_gnbi_t { /* downward */ H5G_bt_it_idx_common_t common; /* Common information for "by index" lookup */ - H5HL_t *heap; /*symbol table heap */ + H5HL_t *heap; /*symbol table heap */ /* upward */ char *name; /*member name to be returned */ @@ -67,7 +66,7 @@ typedef struct H5G_bt_it_gtbi_t { typedef struct H5G_bt_it_lbi_t { /* downward */ H5G_bt_it_idx_common_t common; /* Common information for "by index" lookup */ - H5HL_t *heap; /*symbol table heap */ + H5HL_t *heap; /*symbol table heap */ /* upward */ H5O_link_t *lnk; /*link to be returned */ @@ -99,7 +98,7 @@ typedef struct H5G_bt_it_lbi_t { herr_t H5G_stab_create_components(H5F_t *f, H5O_stab_t *stab, size_t size_hint, hid_t dxpl_id) { - H5HL_t *heap = NULL; /* Pointer to local heap */ + H5HL_t *heap = NULL; /* Pointer to local heap */ size_t name_offset; /* Offset of "" name */ herr_t ret_value = SUCCEED; /* Return value */ @@ -136,7 +135,7 @@ H5G_stab_create_components(H5F_t *f, H5O_stab_t *stab, size_t size_hint, hid_t d done: /* Release resources */ - if(heap && H5HL_unprotect(f, dxpl_id, heap, stab->heap_addr) < 0) + if(heap && H5HL_unprotect(heap) < 0) HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol table heap") FUNC_LEAVE_NOAPI(ret_value) @@ -223,7 +222,7 @@ herr_t H5G_stab_insert_real(H5F_t *f, H5O_stab_t *stab, const char *name, H5O_link_t *obj_lnk, hid_t dxpl_id) { - H5HL_t *heap = NULL; /* Pointer to local heap */ + H5HL_t *heap = NULL; /* Pointer to local heap */ H5G_bt_ins_t udata; /* Data to pass through B-tree */ herr_t ret_value = SUCCEED; /* Return value */ @@ -250,7 +249,7 @@ H5G_stab_insert_real(H5F_t *f, H5O_stab_t *stab, const char *name, done: /* Release resources */ - if(heap && H5HL_unprotect(f, dxpl_id, heap, stab->heap_addr) < 0) + if(heap && H5HL_unprotect(heap) < 0) HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol table heap") FUNC_LEAVE_NOAPI(ret_value) @@ -314,7 +313,7 @@ herr_t H5G_stab_remove(H5O_loc_t *loc, hid_t dxpl_id, H5RS_str_t *grp_full_path_r, const char *name) { - H5HL_t *heap = NULL; /* Pointer to local heap */ + H5HL_t *heap = NULL; /* Pointer to local heap */ H5O_stab_t stab; /*symbol table message */ H5G_bt_rm_t udata; /*data to pass through B-tree */ herr_t ret_value = SUCCEED; /* Return value */ @@ -343,7 +342,7 @@ H5G_stab_remove(H5O_loc_t *loc, hid_t dxpl_id, H5RS_str_t *grp_full_path_r, done: /* Release resources */ - if(heap && H5HL_unprotect(loc->file, dxpl_id, heap, stab.heap_addr) < 0) + if(heap && H5HL_unprotect(heap) < 0) HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol table heap") FUNC_LEAVE_NOAPI(ret_value) @@ -366,9 +365,9 @@ herr_t H5G_stab_remove_by_idx(H5O_loc_t *grp_oloc, hid_t dxpl_id, H5RS_str_t *grp_full_path_r, H5_iter_order_t order, hsize_t n) { - H5HL_t *heap = NULL; /* Pointer to local heap */ + H5HL_t *heap = NULL; /* Pointer to local heap */ H5O_stab_t stab; /* Symbol table message */ - H5G_bt_rm_t udata; /* Data to pass through B-tree */ + H5G_bt_rm_t udata; /* Data to pass through B-tree */ H5O_link_t obj_lnk; /* Object's link within group */ hbool_t lnk_copied = FALSE; /* Whether the link was copied */ herr_t ret_value = SUCCEED; /* Return value */ @@ -401,7 +400,7 @@ H5G_stab_remove_by_idx(H5O_loc_t *grp_oloc, hid_t dxpl_id, H5RS_str_t *grp_full_ done: /* Release resources */ - if(heap && H5HL_unprotect(grp_oloc->file, dxpl_id, heap, stab.heap_addr) < 0) + if(heap && H5HL_unprotect(heap) < 0) HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol table heap") /* Reset the link information, if we have a copy */ @@ -429,8 +428,8 @@ done: herr_t H5G_stab_delete(H5F_t *f, hid_t dxpl_id, const H5O_stab_t *stab) { - H5HL_t *heap = NULL; /* Pointer to local heap */ - H5G_bt_rm_t udata; /*data to pass through B-tree */ + H5HL_t *heap = NULL; /* Pointer to local heap */ + H5G_bt_rm_t udata; /*data to pass through B-tree */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(H5G_stab_delete, FAIL) @@ -453,7 +452,7 @@ H5G_stab_delete(H5F_t *f, hid_t dxpl_id, const H5O_stab_t *stab) HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to delete symbol table B-tree") /* Release resources */ - if(H5HL_unprotect(f, dxpl_id, heap, stab->heap_addr) < 0) + if(H5HL_unprotect(heap) < 0) HGOTO_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol table heap") heap = NULL; @@ -463,7 +462,7 @@ H5G_stab_delete(H5F_t *f, hid_t dxpl_id, const H5O_stab_t *stab) done: /* Release resources */ - if(heap && H5HL_unprotect(f, dxpl_id, heap, stab->heap_addr) < 0) + if(heap && H5HL_unprotect(heap) < 0) HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol table heap") FUNC_LEAVE_NOAPI(ret_value) @@ -486,7 +485,7 @@ herr_t H5G_stab_iterate(const H5O_loc_t *oloc, hid_t dxpl_id, H5_iter_order_t order, hsize_t skip, hsize_t *last_lnk, H5G_lib_iterate_t op, void *op_data) { - H5HL_t *heap = NULL; /* Local heap for group */ + H5HL_t *heap = NULL; /* Local heap for group */ H5O_stab_t stab; /* Info about symbol table */ H5G_link_table_t ltable = {0, NULL}; /* Link table */ herr_t ret_value; @@ -553,7 +552,7 @@ H5G_stab_iterate(const H5O_loc_t *oloc, hid_t dxpl_id, H5_iter_order_t order, done: /* Release resources */ - if(heap && H5HL_unprotect(oloc->file, dxpl_id, heap, stab.heap_addr) < 0) + if(heap && H5HL_unprotect(heap) < 0) HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol table heap") if(ltable.lnks && H5G_link_release_table(<able) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to release link table") @@ -677,7 +676,7 @@ H5G_stab_get_name_by_idx_cb(const H5G_entry_t *ent, void *_udata) /* Get name offset in heap */ name_off = ent->name_off; - name = H5HL_offset_into(udata->common.f, udata->heap, name_off); + name = H5HL_offset_into(udata->heap, name_off); HDassert(name); udata->name = H5MM_strdup(name); HDassert(udata->name); @@ -703,7 +702,7 @@ ssize_t H5G_stab_get_name_by_idx(H5O_loc_t *oloc, H5_iter_order_t order, hsize_t n, char* name, size_t size, hid_t dxpl_id) { - H5HL_t *heap = NULL; /* Pointer to local heap */ + H5HL_t *heap = NULL; /* Pointer to local heap */ H5O_stab_t stab; /* Info about local heap & B-tree */ H5G_bt_it_gnbi_t udata; /* Iteration information */ ssize_t ret_value; /* Return value */ @@ -761,7 +760,7 @@ H5G_stab_get_name_by_idx(H5O_loc_t *oloc, H5_iter_order_t order, hsize_t n, done: /* Release resources */ - if(heap && H5HL_unprotect(oloc->file, dxpl_id, heap, stab.heap_addr) < 0) + if(heap && H5HL_unprotect(heap) < 0) HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol table heap") /* Free the duplicated name */ @@ -797,7 +796,7 @@ H5G_stab_lookup_cb(const H5G_entry_t *ent, void *_udata) /* Check for setting link info */ if(udata->lnk) /* Convert the entry to a link */ - if(H5G_ent_to_link(udata->file, udata->lnk, udata->heap, ent, udata->name) < 0) + if(H5G_ent_to_link(udata->lnk, udata->heap, ent, udata->name) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTCONVERT, FAIL, "unable to convert symbol table entry to link") done: @@ -822,7 +821,7 @@ herr_t H5G_stab_lookup(H5O_loc_t *grp_oloc, const char *name, H5O_link_t *lnk, hid_t dxpl_id) { - H5HL_t *heap = NULL; /* Pointer to local heap */ + H5HL_t *heap = NULL; /* Pointer to local heap */ H5G_bt_lkp_t bt_udata; /* Data to pass through B-tree */ H5G_stab_fnd_ud_t udata; /* 'User data' to give to callback */ H5O_stab_t stab; /* Symbol table message */ @@ -844,7 +843,6 @@ H5G_stab_lookup(H5O_loc_t *grp_oloc, const char *name, H5O_link_t *lnk, HGOTO_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to protect symbol table heap") /* Set up user data to pass to 'find' operation callback */ - udata.file = grp_oloc->file; udata.name = name; udata.lnk = lnk; udata.heap = heap; @@ -861,7 +859,7 @@ H5G_stab_lookup(H5O_loc_t *grp_oloc, const char *name, H5O_link_t *lnk, done: /* Release resources */ - if(heap && H5HL_unprotect(grp_oloc->file, dxpl_id, heap, stab.heap_addr) < 0) + if(heap && H5HL_unprotect(heap) < 0) HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol table heap") FUNC_LEAVE_NOAPI(ret_value) @@ -896,11 +894,11 @@ H5G_stab_lookup_by_idx_cb(const H5G_entry_t *ent, void *_udata) HDassert(udata && udata->heap); /* Get a pointer to the link name */ - name = H5HL_offset_into(udata->common.f, udata->heap, ent->name_off); + name = H5HL_offset_into(udata->heap, ent->name_off); HDassert(name); /* Convert the entry to a link */ - if(H5G_ent_to_link(udata->common.f, udata->lnk, udata->heap, ent, name) < 0) + if(H5G_ent_to_link(udata->lnk, udata->heap, ent, name) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTCONVERT, FAIL, "unable to convert symbol table entry to link") udata->found = TRUE; @@ -926,8 +924,8 @@ herr_t H5G_stab_lookup_by_idx(H5O_loc_t *grp_oloc, H5_iter_order_t order, hsize_t n, H5O_link_t *lnk, hid_t dxpl_id) { - H5HL_t *heap = NULL; /* Pointer to local heap */ - H5G_bt_it_lbi_t udata; /* Iteration information */ + H5HL_t *heap = NULL; /* Pointer to local heap */ + H5G_bt_it_lbi_t udata; /* Iteration information */ H5O_stab_t stab; /* Symbol table message */ herr_t ret_value = SUCCEED; /* Return value */ @@ -976,7 +974,7 @@ H5G_stab_lookup_by_idx(H5O_loc_t *grp_oloc, H5_iter_order_t order, hsize_t n, done: /* Release resources */ - if(heap && H5HL_unprotect(grp_oloc->file, dxpl_id, heap, stab.heap_addr) < 0) + if(heap && H5HL_unprotect(heap) < 0) HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol table heap") FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Gtest.c b/src/H5Gtest.c index 2921bf0..7400355 100644 --- a/src/H5Gtest.c +++ b/src/H5Gtest.c @@ -108,11 +108,11 @@ H5G_is_empty_test(hid_t gid) /* "New format" checks */ /* Check if the group has any link messages */ - if((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_LINK_ID, H5AC_dxpl_id)) < 0) + if((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_LINK_ID, H5AC2_dxpl_id)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header") if(msg_exists > 0) { /* Sanity check that new group format shouldn't have old messages */ - if((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_STAB_ID, H5AC_dxpl_id)) < 0) + if((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_STAB_ID, H5AC2_dxpl_id)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header") if(msg_exists > 0) HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "both symbol table and link messages found") @@ -121,19 +121,19 @@ H5G_is_empty_test(hid_t gid) } /* end if */ /* Check for a link info message */ - if((linfo_exists = H5O_msg_exists(&(grp->oloc), H5O_LINFO_ID, H5AC_dxpl_id)) < 0) + if((linfo_exists = H5O_msg_exists(&(grp->oloc), H5O_LINFO_ID, H5AC2_dxpl_id)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header") if(linfo_exists > 0) { H5O_linfo_t linfo; /* Link info message */ /* Sanity check that new group format shouldn't have old messages */ - if((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_STAB_ID, H5AC_dxpl_id)) < 0) + if((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_STAB_ID, H5AC2_dxpl_id)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header") if(msg_exists > 0) HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "both symbol table and link info messages found") /* Get the link info */ - if(NULL == H5G_obj_get_linfo(&(grp->oloc), &linfo, H5AC_dxpl_id)) + if(NULL == H5G_obj_get_linfo(&(grp->oloc), &linfo, H5AC2_dxpl_id)) HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "can't get link info") /* Check for 'dense' link storage file addresses being defined */ @@ -152,7 +152,7 @@ H5G_is_empty_test(hid_t gid) /* "Old format" checks */ /* Check if the group has a symbol table message */ - if((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_STAB_ID, H5AC_dxpl_id)) < 0) + if((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_STAB_ID, H5AC2_dxpl_id)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header") if(msg_exists > 0) { H5O_stab_t stab; /* Info about local heap & B-tree */ @@ -161,17 +161,17 @@ H5G_is_empty_test(hid_t gid) /* Sanity check that old group format shouldn't have new messages */ if(linfo_exists > 0) HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "both symbol table and link info messages found") - if((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_GINFO_ID, H5AC_dxpl_id)) < 0) + if((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_GINFO_ID, H5AC2_dxpl_id)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header") if(msg_exists > 0) HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "both symbol table and group info messages found") /* Get the B-tree & local heap info */ - if(NULL == H5O_msg_read(&(grp->oloc), H5O_STAB_ID, &stab, H5AC_dxpl_id)) + if(NULL == H5O_msg_read(&(grp->oloc), H5O_STAB_ID, &stab, H5AC2_dxpl_id)) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to read symbol table message") /* Get the count of links in the group */ - if(H5G_stab_count(&(grp->oloc), &nlinks, H5AC_dxpl_id) < 0) + if(H5G_stab_count(&(grp->oloc), &nlinks, H5AC2_dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to count links") /* Check for link count */ @@ -217,13 +217,13 @@ H5G_has_links_test(hid_t gid, unsigned *nmsgs) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") /* Check if the group has any link messages */ - if((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_LINK_ID, H5AC_dxpl_id)) < 0) + if((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_LINK_ID, H5AC2_dxpl_id)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header") if(msg_exists == 0) HGOTO_DONE(FALSE) /* Check if the group has a symbol table message */ - if((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_STAB_ID, H5AC_dxpl_id)) < 0) + if((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_STAB_ID, H5AC2_dxpl_id)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header") if(msg_exists > 0) HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "both symbol table and link messages found") @@ -233,7 +233,7 @@ H5G_has_links_test(hid_t gid, unsigned *nmsgs) int msg_count; /* Number of messages of a type */ /* Check how many link messages there are */ - if((msg_count = H5O_msg_count(&(grp->oloc), H5O_LINK_ID, H5AC_dxpl_id)) < 0) + if((msg_count = H5O_msg_count(&(grp->oloc), H5O_LINK_ID, H5AC2_dxpl_id)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTCOUNT, FAIL, "unable to count link messages") *nmsgs = (unsigned)msg_count; } /* end if */ @@ -275,13 +275,13 @@ H5G_has_stab_test(hid_t gid) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") /* Check if the group has a symbol table message */ - if((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_STAB_ID, H5AC_dxpl_id)) < 0) + if((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_STAB_ID, H5AC2_dxpl_id)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header") if(msg_exists == 0) HGOTO_DONE(FALSE) /* Check if the group has any link messages */ - if((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_LINK_ID, H5AC_dxpl_id)) < 0) + if((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_LINK_ID, H5AC2_dxpl_id)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header") if(msg_exists > 0) HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "both symbol table and link messages found") @@ -325,25 +325,25 @@ H5G_is_new_dense_test(hid_t gid) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") /* Check if the group has a symbol table message */ - if((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_STAB_ID, H5AC_dxpl_id)) < 0) + if((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_STAB_ID, H5AC2_dxpl_id)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header") if(msg_exists > 0) HGOTO_DONE(FALSE) /* Check if the group has any link messages */ - if((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_LINK_ID, H5AC_dxpl_id)) < 0) + if((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_LINK_ID, H5AC2_dxpl_id)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header") if(msg_exists > 0) HGOTO_DONE(FALSE) /* Check if the group has link info message */ - if((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_LINFO_ID, H5AC_dxpl_id)) < 0) + if((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_LINFO_ID, H5AC2_dxpl_id)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header") if(msg_exists > 0) { H5O_linfo_t linfo; /* Link info message */ /* Get the link info */ - if(NULL == H5G_obj_get_linfo(&(grp->oloc), &linfo, H5AC_dxpl_id)) + if(NULL == H5G_obj_get_linfo(&(grp->oloc), &linfo, H5AC2_dxpl_id)) HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "can't get link info") /* Check for 'dense' link storage file addresses being defined */ @@ -393,7 +393,7 @@ H5G_new_dense_info_test(hid_t gid, hsize_t *name_count, hsize_t *corder_count) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") /* Get the link info */ - if(NULL == H5G_obj_get_linfo(&(grp->oloc), &linfo, H5AC_dxpl_id)) + if(NULL == H5G_obj_get_linfo(&(grp->oloc), &linfo, H5AC2_dxpl_id)) HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "can't get link info") /* Check for 'dense' link storage file addresses being defined */ @@ -403,13 +403,13 @@ H5G_new_dense_info_test(hid_t gid, hsize_t *name_count, hsize_t *corder_count) HGOTO_DONE(FAIL) /* Retrieve # of records in name index */ - if(H5B2_get_nrec(grp->oloc.file, H5AC_dxpl_id, H5G_BT2_NAME, linfo.name_bt2_addr, name_count) < 0) + if(H5B2_get_nrec(grp->oloc.file, H5AC2_dxpl_id, H5G_BT2_NAME, linfo.name_bt2_addr, name_count) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTCOUNT, FAIL, "unable to retrieve # of records from name index") /* Check if there is a creation order index */ if(H5F_addr_defined(linfo.corder_bt2_addr)) { /* Retrieve # of records in creation order index */ - if(H5B2_get_nrec(grp->oloc.file, H5AC_dxpl_id, H5G_BT2_CORDER, linfo.corder_bt2_addr, corder_count) < 0) + if(H5B2_get_nrec(grp->oloc.file, H5AC2_dxpl_id, H5G_BT2_CORDER, linfo.corder_bt2_addr, corder_count) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTCOUNT, FAIL, "unable to retrieve # of records from creation order index") } /* end if */ else @@ -453,11 +453,11 @@ H5G_lheap_size_test(hid_t gid, size_t *lheap_size) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") /* Make certain the group has a symbol table message */ - if(NULL == H5O_msg_read(&(grp->oloc), H5O_STAB_ID, &stab, H5AC_dxpl_id)) + if(NULL == H5O_msg_read(&(grp->oloc), H5O_STAB_ID, &stab, H5AC2_dxpl_id)) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read symbol table message") /* Check the size of the local heap for the group */ - if(H5HL_get_size(grp->oloc.file, H5AC_dxpl_id, stab.heap_addr, lheap_size) < 0) + if(H5HL_get_size(grp->oloc.file, H5AC2_dxpl_id, stab.heap_addr, lheap_size) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGETSIZE, FAIL, "can't query local heap size") done: diff --git a/src/H5HF.c b/src/H5HF.c index 918fdc9..469b1bc 100644 --- a/src/H5HF.c +++ b/src/H5HF.c @@ -942,96 +942,3 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_delete() */ - -/*------------------------------------------------------------------------- - * Function: H5HF_cache_hdr_dest - * - * Purpose: Destroys a fractal heap header in memory. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu - * Feb 24 2006 - * - *------------------------------------------------------------------------- - */ -/* ARGSUSED */ -herr_t -H5HF_cache_hdr_dest(H5HF_hdr_t *hdr) -{ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_cache_hdr_dest) - - /* - * Check arguments. - */ - HDassert(hdr); - HDassert(hdr->rc == 0); - - /* Free the block size lookup table for the doubling table */ - H5HF_dtable_dest(&hdr->man_dtable); - - /* Release any I/O pipeline filter information */ - if(hdr->pline.nused) - H5O_msg_reset(H5O_PLINE_ID, &(hdr->pline)); - - /* Free the shared info itself */ - H5FL_FREE(H5HF_hdr_t, hdr); - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5HF_cache_hdr_dest() */ - - -/*------------------------------------------------------------------------- - * Function: H5HF_cache_iblock_dest - * - * Purpose: Destroys a fractal heap indirect block in memory. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu - * Mar 6 2006 - * - *------------------------------------------------------------------------- - */ -/* ARGSUSED */ -herr_t -H5HF_cache_iblock_dest(H5HF_indirect_t *iblock) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT(H5HF_cache_iblock_dest) - - /* - * Check arguments. - */ - HDassert(iblock); - HDassert(iblock->rc == 0); -#ifdef QAK -HDfprintf(stderr, "%s: Destroying indirect block\n", FUNC); -#endif /* QAK */ - - /* Decrement reference count on shared info */ - HDassert(iblock->hdr); - if(H5HF_hdr_decr(iblock->hdr) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared heap header") - if(iblock->parent) - if(H5HF_iblock_decr(iblock->parent) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared indirect block") - - /* Release entry tables */ - if(iblock->ents) - H5FL_SEQ_FREE(H5HF_indirect_ent_t, iblock->ents); - if(iblock->filt_ents) - H5FL_SEQ_FREE(H5HF_indirect_filt_ent_t, iblock->filt_ents); - if(iblock->child_iblocks) - H5FL_SEQ_FREE(H5HF_indirect_ptr_t, iblock->child_iblocks); - - /* Free fractal heap indirect block info */ - H5FL_FREE(H5HF_indirect_t, iblock); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5HF_cache_iblock_dest() */ - diff --git a/src/H5HFcache.c b/src/H5HFcache.c index 1e12edc..dfcf29c 100644 --- a/src/H5HFcache.c +++ b/src/H5HFcache.c @@ -97,6 +97,7 @@ static void *H5HF_cache_dblock_deserialize(haddr_t addr, size_t len, static herr_t H5HF_cache_dblock_serialize(const H5F_t * f, hid_t dxpl_id, haddr_t addr, size_t len, void *image, void *_thing, unsigned *flags, haddr_t *new_addr, size_t *new_len, void **new_image); +static herr_t H5HF_cache_dblock_free_icr(haddr_t addr, size_t len, void *thing); /*********************/ @@ -421,7 +422,7 @@ HDfprintf(stderr, "%s: hdr->fspace = %p\n", FUNC, hdr->fspace); done: /* Release resources */ if(!ret_value && hdr) - (void)H5HF_cache_hdr_dest(hdr); + (void)H5HF_hdr_dest(hdr); FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_cache_hdr_deserialize() */ /*lint !e818 Can't make udata a pointer to const */ @@ -618,7 +619,7 @@ H5HF_cache_hdr_free_icr(haddr_t UNUSED addr, size_t UNUSED len, void *thing) HDassert(thing); /* Destroy B-tree node */ - H5HF_cache_hdr_dest(thing); + H5HF_hdr_dest(thing); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HF_cache_hdr_free_icr() */ @@ -816,7 +817,7 @@ HDfprintf(stderr, "%s: iblock->ents[%Zu] = {%a}\n", FUNC, u, iblock->ents[u].add done: /* Release resources */ if(!ret_value && iblock) - (void)H5HF_cache_iblock_dest(iblock); + (void)H5HF_man_iblock_dest(iblock); FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_cache_iblock_deserialize() */ @@ -992,12 +993,11 @@ H5HF_cache_iblock_free_icr(haddr_t UNUSED addr, size_t UNUSED len, void *thing) HDassert(thing); /* Destroy fractal heap indirect block */ - H5HF_cache_iblock_dest(thing); + H5HF_man_iblock_dest(thing); FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF_cache_iblock_free_icr() */ - /*------------------------------------------------------------------------- * Function: H5HF_cache_dblock_deserialize @@ -1608,7 +1608,6 @@ done: } /* H5HF_cache_dblock_serialize() */ - /*------------------------------------------------------------------------- * Function: H5HF_cache_dblock_free_icr @@ -1626,63 +1625,19 @@ done: * *------------------------------------------------------------------------- */ - herr_t -H5HF_cache_dblock_free_icr(haddr_t UNUSED addr, - size_t UNUSED len, - void *thing) +H5HF_cache_dblock_free_icr(haddr_t UNUSED addr, size_t UNUSED len, void *thing) { - herr_t ret_value = SUCCEED; /* Return value */ - H5HF_direct_t * dblock; - - FUNC_ENTER_NOAPI_NOINIT(H5HF_cache_dblock_free_icr) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_cache_dblock_free_icr) /* * Check arguments. */ - HDassert( thing ); - - dblock = (H5HF_direct_t *)thing; - -#ifdef QAK -HDfprintf(stderr, "%s: Destroying direct block, dblock = %p\n", FUNC, dblock); -#endif /* QAK */ - - /* Set the shared heap header's file context for this operation */ - /* This doesn't seem to be necessary, and at present, we don't pass - * in the file pointer to this callback -- will comment it out - * for now. - * -- JRM - */ - /* dblock->hdr->f = f; */ - - /* Decrement reference count on shared fractal heap info */ - HDassert( dblock->hdr != NULL ); - - if ( H5HF_hdr_decr(dblock->hdr) < 0 ) { - - HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, \ - "can't decrement reference count on shared heap header") - } - - if ( dblock->parent ) { - - if ( H5HF_iblock_decr(dblock->parent) < 0 ) { - - HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, \ - "can't decrement reference count on shared indirect block") - } - } - - /* Free block's buffer */ - dblock->blk = H5FL_BLK_FREE(direct_block, dblock->blk); - - /* Free fractal heap direct block info */ - H5FL_FREE(H5HF_direct_t, dblock); - -done: + HDassert(thing); - FUNC_LEAVE_NOAPI(ret_value) + /* Destroy fractal heap direct block */ + H5HF_man_dblock_dest(thing); + FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HF_cache_dblock_free_icr() */ diff --git a/src/H5HFdblock.c b/src/H5HFdblock.c index 8ded761..7515013 100644 --- a/src/H5HFdblock.c +++ b/src/H5HFdblock.c @@ -195,7 +195,7 @@ HDfprintf(stderr, "%s: direct block address = %a\n", FUNC, dblock_addr); done: if(ret_value < 0) if(dblock) - H5HF_cache_dblock_free_icr(dblock_addr, dblock->size, (void *)dblock); + H5HF_man_dblock_dest(dblock); FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_man_dblock_create() */ @@ -765,3 +765,52 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_man_dblock_delete() */ + +/*------------------------------------------------------------------------- + * Function: H5HF_man_dblock_dest + * + * Purpose: Destroys a fractal heap direct block in memory. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@ncsa.uiuc.edu + * Feb 27 2006 + * + *------------------------------------------------------------------------- + */ +herr_t +H5HF_man_dblock_dest(H5HF_direct_t *dblock) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5HF_man_dblock_dest) + + /* + * Check arguments. + */ + HDassert(dblock); + +#ifdef QAK +HDfprintf(stderr, "%s: Destroying direct block, dblock = %p\n", FUNC, dblock); +#endif /* QAK */ + + /* Decrement reference count on shared fractal heap info */ + HDassert(dblock->hdr != NULL); + if(H5HF_hdr_decr(dblock->hdr) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared heap header") + + if(dblock->parent) + if(H5HF_iblock_decr(dblock->parent) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared indirect block") + + /* Free block's buffer */ + dblock->blk = H5FL_BLK_FREE(direct_block, dblock->blk); + + /* Free fractal heap direct block info */ + H5FL_FREE(H5HF_direct_t, dblock); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HF_man_dblock_dest() */ + diff --git a/src/H5HFhdr.c b/src/H5HFhdr.c index c68133c..ecdbca1 100644 --- a/src/H5HFhdr.c +++ b/src/H5HFhdr.c @@ -131,7 +131,7 @@ H5HF_hdr_alloc(H5F_t *f) done: if(!ret_value) if(hdr) - (void)H5HF_cache_hdr_dest(hdr); + (void)H5HF_hdr_dest(hdr); FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_hdr_alloc() */ @@ -510,7 +510,7 @@ HDfprintf(stderr, "%s: hdr->id_len = %Zu\n", FUNC, hdr->id_len); done: if(!H5F_addr_defined(ret_value)) if(hdr) - (void)H5HF_cache_hdr_dest(hdr); + (void)H5HF_hdr_dest(hdr); FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_hdr_create() */ @@ -1611,3 +1611,41 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_hdr_delete() */ + +/*------------------------------------------------------------------------- + * Function: H5HF_hdr_dest + * + * Purpose: Destroys a fractal heap header in memory. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@ncsa.uiuc.edu + * Feb 24 2006 + * + *------------------------------------------------------------------------- + */ +herr_t +H5HF_hdr_dest(H5HF_hdr_t *hdr) +{ + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_hdr_dest) + + /* + * Check arguments. + */ + HDassert(hdr); + HDassert(hdr->rc == 0); + + /* Free the block size lookup table for the doubling table */ + H5HF_dtable_dest(&hdr->man_dtable); + + /* Release any I/O pipeline filter information */ + if(hdr->pline.nused) + H5O_msg_reset(H5O_PLINE_ID, &(hdr->pline)); + + /* Free the shared info itself */ + H5FL_FREE(H5HF_hdr_t, hdr); + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5HF_hdr_dest() */ + diff --git a/src/H5HFiblock.c b/src/H5HFiblock.c index 052fd3b..a43dd42 100644 --- a/src/H5HFiblock.c +++ b/src/H5HFiblock.c @@ -1128,7 +1128,7 @@ HDfprintf(stderr, "%s: dir_rows = %u\n", FUNC, dir_rows); done: if(ret_value < 0) if(iblock) - (void)H5HF_cache_iblock_dest(iblock); + (void)H5HF_man_iblock_dest(iblock); FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_man_iblock_create() */ @@ -1664,3 +1664,56 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_man_iblock_size() */ + +/*------------------------------------------------------------------------- + * Function: H5HF_man_iblock_dest + * + * Purpose: Destroys a fractal heap indirect block in memory. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@ncsa.uiuc.edu + * Mar 6 2006 + * + *------------------------------------------------------------------------- + */ +herr_t +H5HF_man_iblock_dest(H5HF_indirect_t *iblock) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5HF_man_iblock_dest) + + /* + * Check arguments. + */ + HDassert(iblock); + HDassert(iblock->rc == 0); +#ifdef QAK +HDfprintf(stderr, "%s: Destroying indirect block\n", FUNC); +#endif /* QAK */ + + /* Decrement reference count on shared info */ + HDassert(iblock->hdr); + if(H5HF_hdr_decr(iblock->hdr) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared heap header") + if(iblock->parent) + if(H5HF_iblock_decr(iblock->parent) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared indirect block") + + /* Release entry tables */ + if(iblock->ents) + H5FL_SEQ_FREE(H5HF_indirect_ent_t, iblock->ents); + if(iblock->filt_ents) + H5FL_SEQ_FREE(H5HF_indirect_filt_ent_t, iblock->filt_ents); + if(iblock->child_iblocks) + H5FL_SEQ_FREE(H5HF_indirect_ptr_t, iblock->child_iblocks); + + /* Free fractal heap indirect block info */ + H5FL_FREE(H5HF_indirect_t, iblock); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HF_man_iblock_dest() */ + diff --git a/src/H5HFpkg.h b/src/H5HFpkg.h index b169ac7..d5cedb1 100644 --- a/src/H5HFpkg.h +++ b/src/H5HFpkg.h @@ -663,6 +663,7 @@ H5_DLL herr_t H5HF_hdr_reverse_iter(H5HF_hdr_t *hdr, hid_t dxpl_id, H5_DLL herr_t H5HF_hdr_reset_iter(H5HF_hdr_t *hdr, hsize_t curr_off); H5_DLL herr_t H5HF_hdr_empty(H5HF_hdr_t *hdr); H5_DLL herr_t H5HF_hdr_delete(H5HF_hdr_t *hdr, hid_t dxpl_id); +H5_DLL herr_t H5HF_hdr_dest(H5HF_hdr_t *hdr); /* Indirect block routines */ H5_DLL herr_t H5HF_iblock_incr(H5HF_indirect_t *iblock); @@ -693,6 +694,7 @@ H5_DLL herr_t H5HF_man_iblock_delete(H5HF_hdr_t *hdr, hid_t dxpl_id, unsigned par_entry); H5_DLL herr_t H5HF_man_iblock_size(H5F_t *f, hid_t dxpl_id, H5HF_hdr_t *hdr, haddr_t iblock_addr, unsigned nrows, H5HF_indirect_t *par_iblock, unsigned par_entry, hsize_t *heap_size/*out*/); +H5_DLL herr_t H5HF_man_iblock_dest(H5HF_indirect_t *iblock); /* Direct block routines */ H5_DLL herr_t H5HF_man_dblock_new(H5HF_hdr_t *fh, hid_t dxpl_id, size_t request, @@ -711,6 +713,7 @@ H5_DLL herr_t H5HF_man_dblock_locate(H5HF_hdr_t *hdr, hid_t dxpl_id, unsigned *par_entry, hbool_t *par_did_protect, H5AC2_protect_t rw); H5_DLL herr_t H5HF_man_dblock_delete(H5F_t *f, hid_t dxpl_id, haddr_t dblock_addr, hsize_t dblock_size); +H5_DLL herr_t H5HF_man_dblock_dest(H5HF_direct_t *dblock); /* Managed object routines */ H5_DLL herr_t H5HF_man_insert(H5HF_hdr_t *fh, hid_t dxpl_id, size_t obj_size, @@ -750,11 +753,6 @@ H5_DLL herr_t H5HF_tiny_op(H5HF_hdr_t *hdr, const uint8_t *id, H5HF_operator_t op, void *op_data); H5_DLL herr_t H5HF_tiny_remove(H5HF_hdr_t *fh, const uint8_t *id); -/* Metadata cache callbacks */ -H5_DLL herr_t H5HF_cache_hdr_dest(H5HF_hdr_t *hdr); -H5_DLL herr_t H5HF_cache_dblock_free_icr(haddr_t addr, size_t len, void *thing); -H5_DLL herr_t H5HF_cache_iblock_dest(H5HF_indirect_t *iblock); - /* Debugging routines for dumping file structures */ H5_DLL herr_t H5HF_hdr_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, int fwidth); diff --git a/src/H5HGcache.c b/src/H5HGcache.c index 6f4cf45..4b45c1b 100755 --- a/src/H5HGcache.c +++ b/src/H5HGcache.c @@ -60,12 +60,12 @@ /* Metadata cache callbacks */ static void *H5HG_deserialize(haddr_t addr, size_t len, const void *image, - const void *udata, hbool_t *dirty); + void *udata, hbool_t *dirty); +static herr_t H5HG_image_len(const void *thing, size_t *image_len_ptr); static herr_t H5HG_serialize(const H5F_t *f, hid_t dxpl_id, haddr_t addr, size_t len, void *image, void *thing, unsigned *flags, haddr_t *new_addr, size_t *new_len, void **new_image); static herr_t H5HG_free_icr(haddr_t addr, size_t len, void *thing); -static herr_t H5HG_image_len(const void *thing, size_t *image_len_ptr); /*********************/ /* Package Variables */ @@ -122,16 +122,16 @@ const H5AC2_class_t H5AC2_GHEAP[1] = {{ */ static void * H5HG_deserialize(haddr_t addr, size_t UNUSED len, const void *image, - const void *_udata, hbool_t UNUSED *dirty) + void *_udata, hbool_t UNUSED *dirty) { H5HG_heap_t *heap = NULL; - uint8_t *p = NULL; - int i; + H5F_t *f = (H5F_t *)_udata; + uint8_t *p; size_t nalloc, need; size_t max_idx=0; /* The maximum index seen */ - H5HG_heap_t *ret_value = NULL; /* Return value */ - H5F_t *f = (H5F_t *)_udata; + int i; + H5HG_heap_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5HG_deserialize, NULL); diff --git a/src/H5HGpkg.h b/src/H5HGpkg.h index f526d00..1b335ee 100644 --- a/src/H5HGpkg.h +++ b/src/H5HGpkg.h @@ -44,6 +44,16 @@ /* The cache subclass */ H5_DLLVAR const H5AC2_class_t H5AC2_GHEAP[1]; +/* Declare a free list to manage the H5HG_t struct */ +H5FL_EXTERN(H5HG_heap_t); + +/* Declare a free list to manage sequences of H5HG_obj_t's */ +H5FL_SEQ_EXTERN(H5HG_obj_t); + +/* Declare a PQ free list to manage heap chunks */ +H5FL_BLK_EXTERN(heap_chunk); + + /**************************/ /* Package Private Macros */ /**************************/ @@ -162,18 +172,7 @@ struct H5HG_heap_t { /******************************/ /* Package Private Prototypes */ /******************************/ - H5_DLL herr_t H5HG_dest(H5HG_heap_t *heap); -/* Declare a free list to manage the H5HG_t struct */ -H5FL_EXTERN(H5HG_heap_t); - -/* Declare a free list to manage sequences of H5HG_obj_t's */ -H5FL_SEQ_EXTERN(H5HG_obj_t); - -/* Declare a PQ free list to manage heap chunks */ -H5FL_BLK_EXTERN(heap_chunk); - - #endif diff --git a/src/H5HL.c b/src/H5HL.c index 358816b..5c7c247 100644 --- a/src/H5HL.c +++ b/src/H5HL.c @@ -29,62 +29,81 @@ * *------------------------------------------------------------------------- */ + +/****************/ +/* Module Setup */ +/****************/ #define H5F_PACKAGE /* Suppress error about including H5Fpkg */ #define H5HL_PACKAGE /* Suppress error about including H5HLpkg */ +/***********/ +/* Headers */ +/***********/ #include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ +#include "H5AC2private.h" /* Metadata cache */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fpkg.h" /* File access */ #include "H5FLprivate.h" /* Free lists */ #include "H5HLpkg.h" /* Local Heaps */ #include "H5MFprivate.h" /* File memory management */ -/* Private macros */ -#define H5HL_FREE_NULL 1 /*end of free list on disk */ -#define H5HL_MIN_HEAP 128 /* Minimum size to reduce heap buffer to */ +/****************/ +/* Local Macros */ +/****************/ + +/* Minimum size to reduce heap buffer to */ +#define H5HL_MIN_HEAP 128 + +/* Set the local heap size to speculatively read in */ +/* (needs to be more than the local heap prefix size to work at all and + * should be larger than the default local heap size to save the + * extra I/O operations) */ +#define H5HL_SPEC_READ_SIZE 512 + -/* - * Local heap collection version. - */ -#define H5HL_VERSION 0 -/* Private typedefs */ +/******************/ +/* Local Typedefs */ +/******************/ + + +/********************/ +/* Package Typedefs */ +/********************/ + + +/********************/ +/* Local Prototypes */ +/********************/ -/* PRIVATE PROTOTYPES */ -static herr_t H5HL_serialize(H5F_t *f, H5HL_t *heap, uint8_t *buf); static H5HL_free_t *H5HL_remove_free(H5HL_t *heap, H5HL_free_t *fl); static herr_t H5HL_minimize_heap_space(H5F_t *f, hid_t dxpl_id, H5HL_t *heap); -/* Metadata cache callbacks */ -static H5HL_t *H5HL_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *udata1, - void *udata2); -static herr_t H5HL_flush(H5F_t *f, hid_t dxpl_id, hbool_t dest, haddr_t addr, H5HL_t *heap, unsigned UNUSED * flags_ptr); -static herr_t H5HL_dest(H5F_t *f, H5HL_t *heap); -static herr_t H5HL_clear(H5F_t *f, H5HL_t *heap, hbool_t destroy); -static herr_t H5HL_size(const H5F_t *f, const H5HL_t *heap, size_t *size_ptr); -/* - * H5HL inherits cache-like properties from H5AC - */ -const H5AC_class_t H5AC_LHEAP[1] = {{ - H5AC_LHEAP_ID, - (H5AC_load_func_t)H5HL_load, - (H5AC_flush_func_t)H5HL_flush, - (H5AC_dest_func_t)H5HL_dest, - (H5AC_clear_func_t)H5HL_clear, - (H5AC_size_func_t)H5HL_size, -}}; +/*********************/ +/* Package Variables */ +/*********************/ /* Declare a free list to manage the H5HL_free_t struct */ -H5FL_DEFINE_STATIC(H5HL_free_t); +H5FL_DEFINE(H5HL_free_t); /* Declare a free list to manage the H5HL_t struct */ -H5FL_DEFINE_STATIC(H5HL_t); +H5FL_DEFINE(H5HL_t); /* Declare a PQ free list to manage the heap chunk information */ -H5FL_BLK_DEFINE_STATIC(heap_chunk); +H5FL_BLK_DEFINE(lheap_chunk); + + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + + +/*******************/ +/* Local Variables */ +/*******************/ + /*------------------------------------------------------------------------- @@ -106,198 +125,190 @@ H5FL_BLK_DEFINE_STATIC(heap_chunk); * matzke@llnl.gov * Jul 16 1997 * - * Modifications: - * - * Robb Matzke, 5 Aug 1997 - * Takes a flag that determines the type of heap that is - * created. - * - * John Mainzer, 6/7/05 - * Removed code modifying the is_dirty field of the cache info. - * *------------------------------------------------------------------------- */ herr_t H5HL_create(H5F_t *f, hid_t dxpl_id, size_t size_hint, haddr_t *addr_p/*out*/) { - H5HL_t *heap = NULL; - hsize_t total_size; /*total heap size on disk */ - size_t sizeof_hdr; /* Cache H5HL header size for file */ - herr_t ret_value = SUCCEED; + H5HL_t *heap = NULL; /* Heap created */ + H5HL_prfx_t *prfx = NULL; /* Heap prefix */ + hsize_t total_size; /* Total heap size on disk */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5HL_create, FAIL); + FUNC_ENTER_NOAPI(H5HL_create, FAIL) /* check arguments */ - assert(f); - assert(addr_p); + HDassert(f); + HDassert(addr_p); - if (size_hint && size_hint < H5HL_SIZEOF_FREE(f)) + /* Adjust size hint as necessary */ + if(size_hint && size_hint < H5HL_SIZEOF_FREE(f)) size_hint = H5HL_SIZEOF_FREE(f); size_hint = H5HL_ALIGN(size_hint); - /* Cache this for later */ - sizeof_hdr= H5HL_SIZEOF_HDR(f); - - /* allocate file version */ - total_size = sizeof_hdr + size_hint; - if (HADDR_UNDEF==(*addr_p=H5MF_alloc(f, H5FD_MEM_LHEAP, dxpl_id, total_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate file memory"); - - /* allocate memory version */ - if (NULL==(heap = H5FL_CALLOC(H5HL_t))) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); - heap->addr = *addr_p + (hsize_t)sizeof_hdr; - heap->heap_alloc = size_hint; - if (NULL==(heap->chunk = H5FL_BLK_CALLOC(heap_chunk,(sizeof_hdr + size_hint)))) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); + /* Allocate memory structure */ + if(NULL == (heap = H5FL_CALLOC(H5HL_t))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "memory allocation failed") + heap->prfx_size = H5HL_SIZEOF_HDR(f); + + /* Allocate file space */ + total_size = heap->prfx_size + size_hint; + if(HADDR_UNDEF == (heap->prfx_addr = H5MF_alloc(f, H5FD_MEM_LHEAP, dxpl_id, total_size))) + HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, FAIL, "unable to allocate file memory") + + /* Initialize info */ + heap->single_cache_obj = TRUE; + heap->dblk_addr = heap->prfx_addr + (hsize_t)heap->prfx_size; + heap->dblk_size = size_hint; + if(size_hint) + if(NULL == (heap->image = H5FL_BLK_CALLOC(lheap_chunk, size_hint))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "memory allocation failed") /* free list */ - if (size_hint) { - if (NULL==(heap->freelist = H5FL_MALLOC(H5HL_free_t))) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); + if(size_hint) { + if(NULL == (heap->freelist = H5FL_MALLOC(H5HL_free_t))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "memory allocation failed") heap->freelist->offset = 0; heap->freelist->size = size_hint; heap->freelist->prev = heap->freelist->next = NULL; - } else { + } /* end if */ + else heap->freelist = NULL; - } - /* add to cache */ - if (H5AC_set(f, dxpl_id, H5AC_LHEAP, *addr_p, heap, H5AC__NO_FLAGS_SET) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "unable to cache heap"); + /* Allocate the heap prefix */ + if(NULL == (prfx = H5HL_prfx_new(heap))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "memory allocation failed") + + /* Add to cache */ + if(H5AC2_set(f, dxpl_id, H5AC2_LHEAP_PRFX, heap->prfx_addr, (size_t)total_size, prfx, H5AC2__NO_FLAGS_SET) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "unable to cache local heap prefix") + + /* Set address to return */ + *addr_p = heap->prfx_addr; done: - if (ret_value<0) { - if (H5F_addr_defined(*addr_p)) - H5MF_xfree(f, H5FD_MEM_LHEAP, dxpl_id, *addr_p, total_size); - if (heap) { - if(H5HL_dest(f,heap)<0) - HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy local heap collection"); - } - } - FUNC_LEAVE_NOAPI(ret_value); -} + if(ret_value < 0) { + if(prfx) { + if(H5HL_prfx_dest(prfx) < 0) + HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy local heap prefix") + } /* end if */ + else { + if(heap) { + if(H5F_addr_defined(heap->prfx_addr)) + if(H5MF_xfree(f, H5FD_MEM_LHEAP, dxpl_id, heap->prfx_addr, total_size) < 0) + HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "can't release heap data?") + if(H5HL_dest(heap) < 0) + HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy local heap") + } /* end if */ + } /* end else */ + } /* end if */ + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HL_create() */ /*------------------------------------------------------------------------- - * Function: H5HL_load - * - * Purpose: Loads a heap from disk. + * Function: H5HL_dblk_realloc * - * Return: Success: Ptr to a local heap memory data structure. + * Purpose: Reallocate data block for heap * - * Failure: NULL - * - * Programmer: Robb Matzke - * matzke@llnl.gov - * Jul 17 1997 + * Return: Success: Non-negative + * Failure: Negative * - * Modifications: - * Robb Matzke, 1999-07-28 - * The ADDR argument is passed by value. + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * Oct 12 2008 * - * Quincey Koziol, 2002-7-180 - * Added dxpl parameter to allow more control over I/O from metadata - * cache. *------------------------------------------------------------------------- */ -static H5HL_t * -H5HL_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * udata1, - void UNUSED * udata2) +static herr_t +H5HL_dblk_realloc(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, size_t new_heap_size) { - uint8_t hdr[52]; - size_t sizeof_hdr; /* Cache H5HL header size for file */ - const uint8_t *p = NULL; - H5HL_t *heap = NULL; - H5HL_free_t *fl = NULL, *tail = NULL; - size_t free_block = H5HL_FREE_NULL; - H5HL_t *ret_value; + H5HL_dblk_t *dblk; /* Local heap data block */ + haddr_t old_addr; /* Old location of heap data block */ + haddr_t new_addr; /* New location of heap data block */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5HL_load, NULL) + FUNC_ENTER_NOAPI_NOINIT(H5HL_dblk_realloc) /* check arguments */ - HDassert(f); - HDassert(H5F_addr_defined(addr)); - HDassert(!udata1); - HDassert(!udata2); - - /* Cache this for later */ - sizeof_hdr = H5HL_SIZEOF_HDR(f); - HDassert(sizeof_hdr <= sizeof(hdr)); - - /* Get the local heap's header */ - if(H5F_block_read(f, H5FD_MEM_LHEAP, addr, sizeof_hdr, dxpl_id, hdr) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_READERROR, NULL, "unable to read heap header") - p = hdr; - - /* Check magic number */ - if(HDmemcmp(hdr, H5HL_MAGIC, (size_t)H5HL_SIZEOF_MAGIC)) - HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "bad heap signature") - p += H5HL_SIZEOF_MAGIC; - - /* Version */ - if(H5HL_VERSION != *p++) - HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "wrong version number in global heap") - - /* Reserved */ - p += 3; + HDassert(heap); + HDassert(new_heap_size > 0); + + /* Release old space on disk */ + old_addr = heap->dblk_addr; + H5_CHECK_OVERFLOW(heap->dblk_size, size_t, hsize_t); + if(H5MF_xfree(f, H5FD_MEM_LHEAP, dxpl_id, old_addr, (hsize_t)heap->dblk_size) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "can't release old heap data?") + + /* Allocate new space on disk */ + H5_CHECK_OVERFLOW(new_heap_size, size_t, hsize_t); + if(HADDR_UNDEF == (new_addr = H5MF_alloc(f, H5FD_MEM_LHEAP, dxpl_id, (hsize_t)new_heap_size))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "unable to allocate file space for heap") + + /* Check if heap data block actually moved in the file */ + if(H5F_addr_eq(old_addr, new_addr)) { + /* Check if heap data block is contiguous w/prefix */ + if(heap->single_cache_obj) { + /* Sanity check */ + HDassert(H5F_addr_eq(heap->prfx_addr + heap->prfx_size, heap->dblk_addr)); + HDassert(heap->prfx); + + /* Resize the heap prefix in the cache */ + if(H5AC2_resize_pinned_entry(heap->prfx, (size_t)(heap->prfx_size + new_heap_size)) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTRESIZE, FAIL, "unable to resize heap in cache") + } /* end if */ + else { + /* Sanity check */ + HDassert(H5F_addr_ne(heap->prfx_addr + heap->prfx_size, heap->dblk_addr)); + HDassert(heap->dblk); + + /* Resize the heap data block in the cache */ + if(H5AC2_resize_pinned_entry(heap->dblk, (size_t)new_heap_size) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTRESIZE, FAIL, "unable to resize heap in cache") + } /* end else */ + } /* end if */ + else { + /* Check if heap data block was contiguous w/prefix previously */ + if(heap->single_cache_obj) { + /* Create new heap data block */ + if(NULL == (dblk = H5HL_dblk_new(heap))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "unable to allocate local heap data block") + + /* Resize current heap prefix */ + heap->prfx_size = H5HL_SIZEOF_HDR(f); + if(H5AC2_resize_pinned_entry(heap->prfx, (size_t)heap->prfx_size) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTRESIZE, FAIL, "unable to resize heap prefix in cache") + + /* Insert data block into cache (pinned) */ + if(H5AC2_set(f, dxpl_id, H5AC2_LHEAP_DBLK, new_addr, (size_t)new_heap_size, dblk, H5AC2__PIN_ENTRY_FLAG) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "unable to cache local heap data block") + dblk = NULL; + + /* Reset 'single cache object' flag */ + heap->single_cache_obj = FALSE; + } /* end if */ + else { + /* Resize the heap data block in the cache */ + /* (ignore [unlikely] case where heap data block ends up + * contiguous w/heap prefix again. + */ + if(H5AC2_resize_pinned_entry(heap->dblk, (size_t)new_heap_size) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTRESIZE, FAIL, "unable to resize heap data block in cache") - /* Allocate space in memory for the heap */ - if(NULL == (heap = H5FL_CALLOC(H5HL_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") - - /* heap data size */ - H5F_DECODE_LENGTH(f, p, heap->heap_alloc); - - /* free list head */ - H5F_DECODE_LENGTH(f, p, free_block); - if(free_block != H5HL_FREE_NULL && free_block >= heap->heap_alloc) - HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "bad heap free list") - - /* data */ - H5F_addr_decode(f, &p, &(heap->addr)); - if(NULL == (heap->chunk = H5FL_BLK_CALLOC(heap_chunk, (sizeof_hdr + heap->heap_alloc)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") - if(heap->heap_alloc && - H5F_block_read(f, H5FD_MEM_LHEAP, heap->addr, heap->heap_alloc, dxpl_id, heap->chunk + sizeof_hdr) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "unable to read heap data") - - /* Build free list */ - while(H5HL_FREE_NULL != free_block) { - if(free_block >= heap->heap_alloc) - HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "bad heap free list") - if(NULL == (fl = H5FL_MALLOC(H5HL_free_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") - fl->offset = free_block; - fl->prev = tail; - fl->next = NULL; - if(tail) - tail->next = fl; - tail = fl; - if(!heap->freelist) - heap->freelist = fl; - - p = heap->chunk + sizeof_hdr + free_block; - - H5F_DECODE_LENGTH(f, p, free_block); - if(free_block == 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "free block size is zero?") - - H5F_DECODE_LENGTH(f, p, fl->size); - if (fl->offset + fl->size > heap->heap_alloc) - HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "bad heap free list") - } /* end while */ + /* Relocate the heap data block in the cache */ + if(H5AC2_rename(f, H5AC2_LHEAP_DBLK, old_addr, new_addr) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTRENAME, FAIL, "unable to move heap data block in cache") + } /* end else */ + } /* end else */ - /* Set return value */ - ret_value = heap; + /* Update heap info*/ + heap->dblk_addr = new_addr; + heap->dblk_size = new_heap_size; done: - if(!ret_value && heap) - if(H5HL_dest(f,heap) < 0) - HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, NULL, "unable to destroy local heap collection") - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5HL_load() */ +} /* end H5HL_dblk_realloc() */ /*------------------------------------------------------------------------- @@ -334,9 +345,8 @@ done: static herr_t H5HL_minimize_heap_space(H5F_t *f, hid_t dxpl_id, H5HL_t *heap) { - size_t new_heap_size = heap->heap_alloc; /* New size of heap */ - size_t sizeof_hdr; - herr_t ret_value = SUCCEED; + size_t new_heap_size = heap->dblk_size; /* New size of heap */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5HL_minimize_heap_space, FAIL) @@ -344,8 +354,6 @@ H5HL_minimize_heap_space(H5F_t *f, hid_t dxpl_id, H5HL_t *heap) HDassert(f); HDassert(heap); - sizeof_hdr = H5HL_SIZEOF_HDR(f); /* cache H5HL header size for file */ - /* * Check to see if we can reduce the size of the heap in memory by * eliminating free blocks at the tail of the buffer before flushing the @@ -358,7 +366,7 @@ H5HL_minimize_heap_space(H5F_t *f, hid_t dxpl_id, H5HL_t *heap) /* Search for a free block at the end of the buffer */ for(tmp_fl = heap->freelist; tmp_fl; tmp_fl = tmp_fl->next) /* Check if the end of this free block is at the end of the buffer */ - if(tmp_fl->offset + tmp_fl->size == heap->heap_alloc) { + if(tmp_fl->offset + tmp_fl->size == heap->dblk_size) { last_fl = tmp_fl; break; } /* end if */ @@ -373,7 +381,7 @@ H5HL_minimize_heap_space(H5F_t *f, hid_t dxpl_id, H5HL_t *heap) * buffer size (and the memory buffer is larger than the * minimum size), reduce or eliminate it. */ - if(last_fl->size >= (heap->heap_alloc / 2) && heap->heap_alloc > H5HL_MIN_HEAP) { + if(last_fl->size >= (heap->dblk_size / 2) && heap->dblk_size > H5HL_MIN_HEAP) { /* * Reduce size of buffer until it's too small or would * eliminate the free block @@ -395,8 +403,9 @@ H5HL_minimize_heap_space(H5F_t *f, hid_t dxpl_id, H5HL_t *heap) /* Truncate the free block */ last_fl->size = H5HL_ALIGN(new_heap_size - last_fl->offset); new_heap_size = last_fl->offset + last_fl->size; - assert(last_fl->size >= H5HL_SIZEOF_FREE(f)); - } else { + HDassert(last_fl->size >= H5HL_SIZEOF_FREE(f)); + } /* end if */ + else { /* * Set the size of the memory buffer to the start * of the free list @@ -406,12 +415,13 @@ H5HL_minimize_heap_space(H5F_t *f, hid_t dxpl_id, H5HL_t *heap) /* Eliminate the free block from the list */ last_fl = H5HL_remove_free(heap, last_fl); } /* end else */ - } else { + } /* end if */ + else { /* Truncate the free block */ last_fl->size = H5HL_ALIGN(new_heap_size - last_fl->offset); new_heap_size = last_fl->offset + last_fl->size; - assert(last_fl->size >= H5HL_SIZEOF_FREE(f)); - assert(last_fl->size == H5HL_ALIGN(last_fl->size)); + HDassert(last_fl->size >= H5HL_SIZEOF_FREE(f)); + HDassert(last_fl->size == H5HL_ALIGN(last_fl->size)); } /* end else */ } /* end if */ } /* end if */ @@ -422,31 +432,16 @@ H5HL_minimize_heap_space(H5F_t *f, hid_t dxpl_id, H5HL_t *heap) * data segment of the heap to another contiguous block of disk * storage. */ - if(new_heap_size != heap->heap_alloc) { - haddr_t old_addr = heap->addr, - new_addr; - - HDassert(new_heap_size < heap->heap_alloc); + if(new_heap_size != heap->dblk_size) { + HDassert(new_heap_size < heap->dblk_size); /* Resize the memory buffer */ - heap->chunk = H5FL_BLK_REALLOC(heap_chunk, heap->chunk, (sizeof_hdr + new_heap_size)); - if(!heap->chunk) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - - /* Release old space on disk */ - /* (Should be safe to free old heap space first, since it's shrinking -QAK) */ - H5_CHECK_OVERFLOW(heap->heap_alloc, size_t, hsize_t); - H5MF_xfree(f, H5FD_MEM_LHEAP, dxpl_id, old_addr, (hsize_t)heap->heap_alloc); - H5E_clear_stack(NULL); /* don't really care if the free failed */ - - /* Allocate new space on disk */ - H5_CHECK_OVERFLOW(new_heap_size, size_t, hsize_t); - if(HADDR_UNDEF == (new_addr = H5MF_alloc(f, H5FD_MEM_LHEAP, dxpl_id, (hsize_t)new_heap_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate file space for heap") - - /* Update heap info*/ - heap->addr = new_addr; - heap->heap_alloc = new_heap_size; + if(NULL == (heap->image = H5FL_BLK_REALLOC(lheap_chunk, heap->image, new_heap_size))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "memory allocation failed") + + /* Reallocate data block in file */ + if(H5HL_dblk_realloc(f, dxpl_id, heap, new_heap_size) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTRESIZE, FAIL, "reallocating data block failed") } /* end if */ done: @@ -455,313 +450,95 @@ done: /*------------------------------------------------------------------------- - * Function: H5HL_serialize + * Function: H5HL_protect * - * Purpose: Serialize the heap. This function will eliminate free - * blocks at the tail of the heap and also split the block - * if it needs to be split for the file. This is so that we - * can serialize it correctly. + * Purpose: This function is a wrapper for the H5AC2_protect call. * - * Return: Non-negative on success/Negative on failure + * Return: Success: Non-NULL pointer to the local heap prefix. + * Failure: NULL * * Programmer: Bill Wendling * wendling@ncsa.uiuc.edu - * Sept. 16, 2003 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -static herr_t -H5HL_serialize(H5F_t *f, H5HL_t *heap, uint8_t *buf) -{ - H5HL_free_t *fl; - uint8_t *p; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HL_serialize) - - /* check args */ - assert(buf); - assert(heap); - - /* serialize the header */ - p = buf; - fl = heap->freelist; - HDmemcpy(p, H5HL_MAGIC, (size_t)H5HL_SIZEOF_MAGIC); - p += H5HL_SIZEOF_MAGIC; - *p++ = H5HL_VERSION; - *p++ = 0; /*reserved*/ - *p++ = 0; /*reserved*/ - *p++ = 0; /*reserved*/ - H5F_ENCODE_LENGTH(f, p, heap->heap_alloc); - H5F_ENCODE_LENGTH(f, p, fl ? fl->offset : H5HL_FREE_NULL); - H5F_addr_encode(f, &p, heap->addr); - - /* serialize the free list */ - for (; fl; fl = fl->next) { - assert (fl->offset == H5HL_ALIGN (fl->offset)); - p = heap->chunk + H5HL_SIZEOF_HDR(f) + fl->offset; - - if (fl->next) { - H5F_ENCODE_LENGTH(f, p, fl->next->offset); - } else { - H5F_ENCODE_LENGTH(f, p, H5HL_FREE_NULL); - } - - H5F_ENCODE_LENGTH(f, p, fl->size); - } - - FUNC_LEAVE_NOAPI(ret_value) -} - - -/*------------------------------------------------------------------------- - * Function: H5HL_flush - * - * Purpose: Flushes a heap from memory to disk if it's dirty. Optionally - * deletes the heap from memory. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Robb Matzke - * matzke@llnl.gov - * Jul 17 1997 - * - * Modifications: - * rky, 1998-08-28 - * Only p0 writes metadata to disk. - * - * Robb Matzke, 1999-07-28 - * The ADDR argument is passed by value. - * - * Quincey Koziol, 2002-7-180 - * Added dxpl parameter to allow more control over I/O from metadata - * cache. - * - * Bill Wendling, 2003-09-16 - * Separated out the bit that serializes the heap. - * - * John Mainzer, 2005-08-10 - * Removed call to H5HL_minimize_heap_space(). It does disk space - * allocation, which can cause problems if done at flush time. - * Instead, disk space allocation/deallocation is now done at - * insert/remove time. - * - * John Mainzer, 2006-08-21 - * Added the flags_ptr parameter. This parameter exists to - * allow the flush routine to report to the cache if the - * entry is resized or renamed as a result of the flush. - * *flags_ptr is set to H5C_CALLBACK__NO_FLAGS_SET on entry. - * - *------------------------------------------------------------------------- - */ -static herr_t -H5HL_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5HL_t *heap, unsigned UNUSED * flags_ptr) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(H5HL_flush, FAIL); - - /* check arguments */ - HDassert( f ); - HDassert( H5F_addr_defined(addr) ); - HDassert( heap ); - - if (heap->cache_info.is_dirty) { - haddr_t hdr_end_addr; - size_t sizeof_hdr = H5HL_SIZEOF_HDR(f); /* cache H5HL header size for file */ - - /* Write the header */ - if (H5HL_serialize(f, heap, heap->chunk) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTSERIALIZE, FAIL, "unable to serialize local heap") - - /* Copy buffer to disk */ - hdr_end_addr = addr + (hsize_t)sizeof_hdr; - - if (H5F_addr_eq(heap->addr, hdr_end_addr)) { - /* The header and data are contiguous */ - if (H5F_block_write(f, H5FD_MEM_LHEAP, addr, (sizeof_hdr + heap->heap_alloc), - dxpl_id, heap->chunk) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_WRITEERROR, FAIL, "unable to write heap header and data to file") - } else { - if (H5F_block_write(f, H5FD_MEM_LHEAP, addr, sizeof_hdr, dxpl_id, heap->chunk) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_WRITEERROR, FAIL, "unable to write heap header to file") - - if (H5F_block_write(f, H5FD_MEM_LHEAP, heap->addr, heap->heap_alloc, - dxpl_id, heap->chunk + sizeof_hdr) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_WRITEERROR, FAIL, "unable to write heap data to file") - } - - heap->cache_info.is_dirty = FALSE; - } - - /* Should we destroy the memory version? */ - if (destroy) { - if (H5HL_dest(f,heap) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy local heap collection") - } - -done: - FUNC_LEAVE_NOAPI(ret_value) -} - - -/*------------------------------------------------------------------------- - * Function: H5HL_dest - * - * Purpose: Destroys a heap in memory. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu - * Jan 15 2003 - * - * Modifications: + * Sept. 17, 2003 * *------------------------------------------------------------------------- */ -static herr_t -H5HL_dest(H5F_t UNUSED *f, H5HL_t *heap) +H5HL_t * +H5HL_protect(H5F_t *f, hid_t dxpl_id, haddr_t addr, H5AC2_protect_t rw) { - H5HL_free_t *fl; + H5HL_cache_prfx_ud_t prfx_udata; /* User data for protecting local heap prefix */ + H5HL_prfx_t *prfx = NULL; /* Local heap prefix */ + H5HL_dblk_t *dblk = NULL; /* Local heap data block */ + H5HL_t *heap; /* Heap data structure */ + unsigned prfx_cache_flags = H5AC2__NO_FLAGS_SET; /* Cache flags for unprotecting prefix entry */ + unsigned dblk_cache_flags = H5AC2__NO_FLAGS_SET; /* Cache flags for unprotecting data block entry */ + H5HL_t *ret_value; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HL_dest); + FUNC_ENTER_NOAPI(H5HL_protect, NULL) /* check arguments */ - assert(heap); + HDassert(f); + HDassert(H5F_addr_defined(addr)); - /* Verify that node is clean */ - assert (heap->cache_info.is_dirty==FALSE); + /* Construct the user data for protect callback */ + prfx_udata.made_attempt = FALSE; + prfx_udata.f = f; + prfx_udata.loaded = FALSE; + prfx_udata.free_block = 0; + + /* Protect the local heap prefix */ + if(NULL == (prfx = (H5HL_prfx_t *)H5AC2_protect(f, dxpl_id, H5AC2_LHEAP_PRFX, addr, H5HL_SPEC_READ_SIZE, &prfx_udata, rw))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "unable to load heap prefix") + + /* Get the pointer to the heap */ + heap = prfx->heap; + + /* Check if the heap is already pinned in memory */ + /* (for re-entrant situation) */ + if(heap->prots == 0) { + /* Check if heap has separate data block */ + if(heap->single_cache_obj) { + /* Set the flag for pinning the prefix when unprotecting it */ + prfx_cache_flags |= H5AC2__PIN_ENTRY_FLAG; + } /* end if */ + else { + H5HL_cache_dblk_ud_t dblk_udata; /* User data for protecting local heap data block */ - if(heap->chunk) - heap->chunk = H5FL_BLK_FREE(heap_chunk,heap->chunk); - while (heap->freelist) { - fl = heap->freelist; - heap->freelist = fl->next; - H5FL_FREE(H5HL_free_t,fl); - } - H5FL_FREE(H5HL_t,heap); + /* Construct the user data for protect callback */ + dblk_udata.f = f; + dblk_udata.heap = heap; + dblk_udata.free_block = prfx_udata.loaded ? prfx_udata.free_block : + (heap->freelist ? heap->freelist->offset : H5HL_FREE_NULL); + dblk_udata.loaded = FALSE; - FUNC_LEAVE_NOAPI(SUCCEED); -} /* end H5HL_dest() */ + /* Protect the local heap data block */ + if(NULL == (dblk = (H5HL_dblk_t *)H5AC2_protect(f, dxpl_id, H5AC2_LHEAP_DBLK, heap->dblk_addr, heap->dblk_size, &dblk_udata, rw))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "unable to load heap data block") - -/*------------------------------------------------------------------------- - * Function: H5HL_clear - * - * Purpose: Mark a local heap in memory as non-dirty. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu - * Mar 20 2003 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -static herr_t -H5HL_clear(H5F_t *f, H5HL_t *heap, hbool_t destroy) -{ - herr_t ret_value = SUCCEED; + /* Pin the prefix, if the data block was loaded from file */ + if(dblk_udata.loaded) + prfx_cache_flags |= H5AC2__PIN_ENTRY_FLAG; - FUNC_ENTER_NOAPI_NOINIT(H5HL_clear); - - /* check arguments */ - assert(heap); + /* Set the flag for pinning the data block when unprotecting it */ + dblk_cache_flags |= H5AC2__PIN_ENTRY_FLAG; + } /* end if */ + } /* end if */ - /* Mark heap as clean */ - heap->cache_info.is_dirty = FALSE; + /* Increment # of times heap is protected */ + heap->prots++; - if (destroy) - if (H5HL_dest(f, heap) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy local heap collection"); + /* Set return value */ + ret_value = heap; done: - FUNC_LEAVE_NOAPI(ret_value); -} /* end H5HL_clear() */ - - -/*------------------------------------------------------------------------- - * Function: H5HL_size - * - * Purpose: Compute the size in bytes of the specified instance of - * H5HL_t on disk, and return it in *len_ptr. On failure, - * the value of *len_ptr is undefined. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: John Mainzer - * 5/13/04 - * - * Modifications: - *------------------------------------------------------------------------- - */ -static herr_t -H5HL_size(const H5F_t *f, const H5HL_t *heap, size_t *size_ptr) -{ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HL_size); - - /* check arguments */ - HDassert(f); - HDassert(heap); - HDassert(size_ptr); - - *size_ptr = H5HL_SIZEOF_HDR(f) + heap->heap_alloc; - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5HL_size() */ - - -/*------------------------------------------------------------------------- - * Function: H5HL_protect - * - * Purpose: This function is a wrapper for the H5AC_protect call. The - * old H5HL_peek call (which this once was) wasn't "safe" - * for FPHDF5. (It'd get a read lock on an object but once - * it got that object, it'd release it keeping the old - * pointer value, which is no longer valid. This won't work - * since the pointer into some metdata block can become - * invalid.) - * - * N.B.: This function is always called in conjunction with - * the H5HL_offset_into function. The return from that - * function is the proper pointer to the heap's object. This - * is done so that the return from this function can be sent - * to H5HL_unprotect. - * - * Return: Success: Ptr to the object. The pointer points to a - * chunk of memory large enough to hold the - * object from the specified offset (usually the - * beginning of the object) to the end of the - * object. Do not attempt to read past the end - * of the object. - * Failure: NULL - * - * Programmer: Bill Wendling - * wendling@ncsa.uiuc.edu - * Sept. 17, 2003 - * - *------------------------------------------------------------------------- - */ -H5HL_t * -H5HL_protect(H5F_t *f, hid_t dxpl_id, haddr_t addr, H5AC_protect_t rw) -{ - H5HL_t *ret_value; - - FUNC_ENTER_NOAPI(H5HL_protect, NULL) - - /* check arguments */ - HDassert(f); - HDassert(H5F_addr_defined(addr)); + /* Release the prefix from the cache, now pinned */ + if(prfx && H5AC2_unprotect(f, dxpl_id, H5AC2_LHEAP_PRFX, heap->prfx_addr, (size_t)0, prfx, prfx_cache_flags) < 0) + HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, NULL, "unable to release local heap prefix") - if(NULL == (ret_value = H5AC_protect(f, dxpl_id, H5AC_LHEAP, addr, NULL, NULL, rw))) - HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "unable to load heap") + /* Release the data block from the cache, now pinned */ + if(dblk && H5AC2_unprotect(f, dxpl_id, H5AC2_LHEAP_DBLK, heap->dblk_addr, (size_t)0, dblk, dblk_cache_flags) < 0) + HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, NULL, "unable to release local heap data block") -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HL_protect() */ @@ -779,23 +556,23 @@ done: * wendling@ncsa.uiuc.edu * Sept. 17, 2003 * - * Modifications: - * *------------------------------------------------------------------------- */ void * -H5HL_offset_into(H5F_t *f, const H5HL_t *heap, size_t offset) +H5HL_offset_into(const H5HL_t *heap, size_t offset) { /* * We need to have called some other function before this to get a * valid heap pointer. So, this can remain "FUNC_ENTER_NOAPI_NOINIT" */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HL_offset_into) - assert(f); - assert(heap); - assert(offset < heap->heap_alloc); - FUNC_LEAVE_NOAPI(heap->chunk + H5HL_SIZEOF_HDR(f) + offset) -} + + /* Sanity check */ + HDassert(heap); + HDassert(offset < heap->dblk_size); + + FUNC_LEAVE_NOAPI(heap->image + offset) +} /* end H5HL_offset_into() */ /*------------------------------------------------------------------------- @@ -813,19 +590,36 @@ H5HL_offset_into(H5F_t *f, const H5HL_t *heap, size_t offset) *------------------------------------------------------------------------- */ herr_t -H5HL_unprotect(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, haddr_t addr) +H5HL_unprotect(H5HL_t *heap) { - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5HL_unprotect, FAIL) /* check arguments */ - HDassert(f); HDassert(heap); - HDassert(H5F_addr_defined(addr)); - if(H5AC_unprotect(f, dxpl_id, H5AC_LHEAP, addr, (void *)heap, H5AC__NO_FLAGS_SET) != SUCCEED) - HGOTO_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to release object header") + /* Decrement # of times heap is protected */ + heap->prots--; + + /* Check for last unprotection of heap */ + if(heap->prots == 0) { + /* Check for separate heap data block */ + if(heap->single_cache_obj) { + /* Mark local heap prefix as evictable again */ + if(H5AC2_unpin_entry(heap->prfx) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPIN, FAIL, "unable to unpin local heap data block") + } /* end if */ + else { + /* Sanity check */ + HDassert(heap->dblk); + + /* Mark local heap data block as evictable again */ + /* (data block still pins prefix) */ + if(H5AC2_unpin_entry(heap->dblk) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPIN, FAIL, "unable to unpin local heap data block") + } /* end else */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) @@ -844,22 +638,66 @@ done: * matzke@llnl.gov * Jul 17 1997 * - * Modifications: - * *------------------------------------------------------------------------- */ static H5HL_free_t * H5HL_remove_free(H5HL_t *heap, H5HL_free_t *fl) { - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HL_remove_free); + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HL_remove_free) - if (fl->prev) fl->prev->next = fl->next; - if (fl->next) fl->next->prev = fl->prev; + if(fl->prev) + fl->prev->next = fl->next; + if(fl->next) + fl->next->prev = fl->prev; - if (!fl->prev) heap->freelist = fl->next; + if(!fl->prev) + heap->freelist = fl->next; - FUNC_LEAVE_NOAPI(H5FL_FREE(H5HL_free_t,fl)); -} + FUNC_LEAVE_NOAPI(H5FL_FREE(H5HL_free_t, fl)) +} /* end H5HL_remove_free() */ + + +/*------------------------------------------------------------------------- + * Function: H5HL_dirty + * + * Purpose: Mark heap as dirty + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * Oct 12 2008 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5HL_dirty(H5HL_t *heap) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5HL_dirty) + + /* check arguments */ + HDassert(heap); + HDassert(heap->prfx); + + /* Mark heap data block as dirty, if there is one */ + if(!heap->single_cache_obj) { + /* Sanity check */ + HDassert(heap->dblk); + + if(H5AC2_mark_pinned_or_protected_entry_dirty(heap->dblk) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTMARKDIRTY, FAIL, "unable to mark heap data block as dirty") + } /* end if */ + + /* Mark heap prefix as dirty */ + if(H5AC2_mark_pinned_or_protected_entry_dirty(heap->prfx) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTMARKDIRTY, FAIL, "unable to mark heap prefix as dirty") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HL_dirty() */ /*------------------------------------------------------------------------- @@ -884,10 +722,9 @@ H5HL_insert(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, size_t buf_size, const void * size_t offset = 0; size_t need_size; hbool_t found; - size_t sizeof_hdr; /* Cache H5HL header size for file */ size_t ret_value; /* Return value */ - FUNC_ENTER_NOAPI(H5HL_insert, (size_t)(-1)) + FUNC_ENTER_NOAPI(H5HL_insert, UFAIL) /* check arguments */ HDassert(f); @@ -901,11 +738,8 @@ H5HL_insert(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, size_t buf_size, const void * * so we just accept that an extra flush of the heap info could occur * if an error occurs -QAK) */ - if(H5AC_mark_pinned_or_protected_entry_dirty(f, heap) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTMARKDIRTY, (size_t)(-1), "unable to mark heap as dirty") - - /* Cache this for later */ - sizeof_hdr = H5HL_SIZEOF_HDR(f); + if(H5HL_dirty(heap) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTMARKDIRTY, UFAIL, "unable to mark heap as dirty") /* * In order to keep the free list descriptors aligned on word boundaries, @@ -949,12 +783,13 @@ H5HL_insert(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, size_t buf_size, const void * */ if(found == FALSE) { size_t need_more; /* How much more space we need */ - size_t new_heap_alloc; /* Final size of space allocated for heap */ + size_t new_dblk_size; /* Final size of space allocated for heap data block */ + size_t old_dblk_size; /* Previous size of space allocated for heap data block */ htri_t can_extend; /* Whether the local heap's data segment on disk can be extended */ /* At least double the heap's size, making certain there's enough room * for the new object */ - need_more = MAX(need_size, heap->heap_alloc); + need_more = MAX(need_size, heap->dblk_size); /* If there is no last free block or it's not at the end of the heap, * and the amount of space to allocate is not big enough to include at @@ -962,85 +797,50 @@ H5HL_insert(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, size_t buf_size, const void * * space requested to just the amount of space needed. (Generally * speaking, this only occurs when the heap is small -QAK) */ - if(!(last_fl && last_fl->offset + last_fl->size == heap->heap_alloc) + if(!(last_fl && last_fl->offset + last_fl->size == heap->dblk_size) && (need_more < (need_size + H5HL_SIZEOF_FREE(f)))) need_more = need_size; - new_heap_alloc = heap->heap_alloc + need_more; -#if 0 /* JRM */ /* delete this once we are convinced that the general - * fix will do the job. - */ -/* - * XXX: This is a _total_ hack, a real kludge. :-/ The metadata cache currently - * responds very poorly when an object is inserted into the cache (or - * resized) that is larger than the current cache size. It waits through - * an entire 'epoch' of cache operations to resize the cache larger (getting - * _very_ poor performance), instead of immediately accommodating the large - * object by increasing the cache size. - * - * So, what we are doing here is to look at the current cache size, check - * if the new local heap will overwhelm the cache and, if so, resize the - * cache to be large enough to hold the new local heap block along with - * leaving room for other objects in the cache. - * - * John will be working on a fix inside the cache itself, so this special - * case code here can be removed when he's finished. - QAK, 2007/12/21 - */ -{ - H5AC_cache_config_t mdc_config; - - /* Retrieve the current cache information */ - mdc_config.version = H5AC__CURR_CACHE_CONFIG_VERSION; - if(H5AC_get_cache_auto_resize_config(f->shared->cache, &mdc_config) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (size_t)-1, "H5AC_get_cache_auto_resize_config() failed.") - - /* Check if the current cache will get blown out by adding this heap - * block and resize it if so. - */ - if((2 * new_heap_alloc) >= mdc_config.initial_size) { - mdc_config.set_initial_size = TRUE; - mdc_config.initial_size = 2 * new_heap_alloc; - - if(H5AC_set_cache_auto_resize_config(f->shared->cache, &mdc_config) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (size_t)-1, "H5AC_set_cache_auto_resize_config() failed.") - } /* end if */ -} -#endif /* JRM */ - HDassert(heap->heap_alloc < new_heap_alloc); - H5_CHECK_OVERFLOW(heap->heap_alloc, size_t, hsize_t); - H5_CHECK_OVERFLOW(new_heap_alloc, size_t, hsize_t); + new_dblk_size = heap->dblk_size + need_more; + HDassert(heap->dblk_size < new_dblk_size); + old_dblk_size = heap->dblk_size; + H5_CHECK_OVERFLOW(heap->dblk_size, size_t, hsize_t); + H5_CHECK_OVERFLOW(new_dblk_size, size_t, hsize_t); /* Check if current heap is extendible */ - can_extend = H5MF_can_extend(f, H5FD_MEM_LHEAP, heap->addr, (hsize_t)(heap->heap_alloc), (hsize_t)need_more); + can_extend = H5MF_can_extend(f, H5FD_MEM_LHEAP, heap->dblk_addr, (hsize_t)(heap->dblk_size), (hsize_t)need_more); if(can_extend < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, (size_t)(-1), "unable to check whether heap can be extended") + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, UFAIL, "unable to check whether heap can be extended") - /* extend the current heap if we can... */ + /* Check if we can extend heap in file */ if(can_extend == TRUE) { - if(H5MF_extend(f, H5FD_MEM_LHEAP, heap->addr, (hsize_t)(heap->heap_alloc), (hsize_t)need_more) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, (size_t)(-1), "can't extend heap on disk") + /* Extend file space allocation */ + if(H5MF_extend(f, H5FD_MEM_LHEAP, heap->dblk_addr, (hsize_t)(heap->dblk_size), (hsize_t)need_more) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, UFAIL, "can't extend heap on disk") + + /* Check for prefix & data block contiguous */ + if(heap->single_cache_obj) { + /* Resize prefix+data block */ + if(H5AC2_resize_pinned_entry(heap->prfx, (size_t)(heap->prfx_size + new_dblk_size)) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTRESIZE, UFAIL, "unable to resize heap prefix in cache") + } /* end if */ + else { + /* Resize 'standalone' data block */ + if(H5AC2_resize_pinned_entry(heap->dblk, (size_t)new_dblk_size) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTRESIZE, UFAIL, "unable to resize heap data block in cache") + } /* end else */ + + /* Note new size */ + heap->dblk_size = new_dblk_size; } /* end if */ else { /* ...if we can't, allocate a new chunk & release the old */ - haddr_t new_addr; - - /* The new allocation may fail -- to avoid the possiblity of - * file corruption, allocate the new heap first, and then - * deallocate the old. - */ - - /* allocate new disk space for the heap */ - if((new_addr = H5MF_alloc(f, H5FD_MEM_LHEAP, dxpl_id, (hsize_t)new_heap_alloc)) == HADDR_UNDEF) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, (size_t)(-1), "unable to allocate file space for heap") - - /* Release old space on disk */ - H5MF_xfree(f, H5FD_MEM_LHEAP, dxpl_id, heap->addr, (hsize_t)heap->heap_alloc); - H5E_clear_stack(NULL); /* don't really care if the free failed */ - - heap->addr = new_addr; + /* Reallocate data block in file */ + if(H5HL_dblk_realloc(f, dxpl_id, heap, new_dblk_size) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTRESIZE, UFAIL, "reallocating data block failed") } /* end else */ /* If the last free list in the heap is at the end of the heap, extend it */ - if(last_fl && last_fl->offset + last_fl->size == heap->heap_alloc) { + if(last_fl && last_fl->offset + last_fl->size == old_dblk_size) { /* * Increase the size of the last free block. */ @@ -1065,17 +865,18 @@ H5HL_insert(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, size_t buf_size, const void * * Create a new free list element large enough that we can * take some space out of it right away. */ - offset = heap->heap_alloc; + offset = old_dblk_size; if(need_more - need_size >= H5HL_SIZEOF_FREE(f)) { if(NULL == (fl = H5FL_MALLOC(H5HL_free_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, (size_t)(-1), "memory allocation failed") - fl->offset = heap->heap_alloc + need_size; + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, UFAIL, "memory allocation failed") + fl->offset = old_dblk_size + need_size; fl->size = need_more - need_size; HDassert(fl->offset == H5HL_ALIGN(fl->offset)); HDassert(fl->size == H5HL_ALIGN(fl->size)); fl->prev = NULL; fl->next = heap->freelist; - if (heap->freelist) heap->freelist->prev = fl; + if(heap->freelist) + heap->freelist->prev = fl; heap->freelist = fl; #ifdef H5HL_DEBUG } else if (H5DEBUG(HL) && need_more > need_size) { @@ -1090,24 +891,20 @@ H5HL_insert(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, size_t buf_size, const void * if (H5DEBUG(HL)) { fprintf(H5DEBUG(HL), "H5HL: resize mem buf from %lu to %lu bytes\n", - (unsigned long)(heap->heap_alloc), - (unsigned long)(heap->heap_alloc + need_more)); + (unsigned long)(old_dblk_size), + (unsigned long)(old_dblk_size + need_more)); } #endif - heap->heap_alloc = new_heap_alloc; - heap->chunk = H5FL_BLK_REALLOC(heap_chunk, heap->chunk, (sizeof_hdr + heap->heap_alloc)); - if(NULL == heap->chunk) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, (size_t)(-1), "memory allocation failed") + if(NULL == (heap->image = H5FL_BLK_REALLOC(lheap_chunk, heap->image, heap->dblk_size))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, UFAIL, "memory allocation failed") /* Clear new section so junk doesn't appear in the file */ /* (Avoid clearing section which will be overwritten with newly inserted data) */ - HDmemset(heap->chunk + sizeof_hdr + offset + buf_size, 0, (new_heap_alloc - (offset + buf_size))); + HDmemset(heap->image + offset + buf_size, 0, (new_dblk_size - (offset + buf_size))); } /* end if */ - /* - * Copy the data into the heap - */ - HDmemcpy(heap->chunk + sizeof_hdr + offset, buf, buf_size); + /* Copy the data into the heap */ + HDmemcpy(heap->image + offset, buf, buf_size); /* Set return value */ ret_value = offset; @@ -1147,7 +944,7 @@ H5HL_remove(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, size_t offset, size_t size) H5HL_free_t *fl = NULL; herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5HL_remove, FAIL); + FUNC_ENTER_NOAPI(H5HL_remove, FAIL) /* check arguments */ HDassert(f); @@ -1157,8 +954,8 @@ H5HL_remove(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, size_t offset, size_t size) size = H5HL_ALIGN(size); - HDassert(offset < heap->heap_alloc); - HDassert(offset + size <= heap->heap_alloc); + HDassert(offset < heap->dblk_size); + HDassert(offset + size <= heap->dblk_size); /* Mark heap as dirty in cache */ /* (A bit early in the process, but it's difficult to determine in the @@ -1166,7 +963,7 @@ H5HL_remove(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, size_t offset, size_t size) * so we just accept that an extra flush of the heap info could occur * if an error occurs -QAK) */ - if(H5AC_mark_pinned_or_protected_entry_dirty(f, heap) < 0) + if(H5HL_dirty(heap) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTMARKDIRTY, FAIL, "unable to mark heap as dirty") /* @@ -1181,18 +978,18 @@ H5HL_remove(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, size_t offset, size_t size) if((offset + size) == fl->offset) { fl->offset = offset; fl->size += size; - HDassert(fl->offset==H5HL_ALIGN (fl->offset)); - HDassert(fl->size==H5HL_ALIGN (fl->size)); + HDassert(fl->offset == H5HL_ALIGN(fl->offset)); + HDassert(fl->size == H5HL_ALIGN(fl->size)); fl2 = fl->next; while(fl2) { if((fl2->offset + fl2->size) == fl->offset) { fl->offset = fl2->offset; fl->size += fl2->size; - HDassert(fl->offset == H5HL_ALIGN (fl->offset)); - HDassert(fl->size == H5HL_ALIGN (fl->size)); + HDassert(fl->offset == H5HL_ALIGN(fl->offset)); + HDassert(fl->size == H5HL_ALIGN(fl->size)); fl2 = H5HL_remove_free(heap, fl2); - if(((fl->offset + fl->size) == heap->heap_alloc ) && - ((2 * fl->size) > heap->heap_alloc )) { + if(((fl->offset + fl->size) == heap->dblk_size) && + ((2 * fl->size) > heap->dblk_size)) { if(H5HL_minimize_heap_space(f, dxpl_id, heap) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "heap size minimization failed") } @@ -1200,8 +997,8 @@ H5HL_remove(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, size_t offset, size_t size) } fl2 = fl2->next; } - if(((fl->offset + fl->size) == heap->heap_alloc) && - ((2 * fl->size) > heap->heap_alloc)) { + if(((fl->offset + fl->size) == heap->dblk_size) && + ((2 * fl->size) > heap->dblk_size)) { if(H5HL_minimize_heap_space(f, dxpl_id, heap) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "heap size minimization failed") } @@ -1209,28 +1006,28 @@ H5HL_remove(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, size_t offset, size_t size) } else if(fl->offset + fl->size == offset) { fl->size += size; fl2 = fl->next; - HDassert(fl->size==H5HL_ALIGN (fl->size)); + HDassert(fl->size == H5HL_ALIGN(fl->size)); while(fl2) { if(fl->offset + fl->size == fl2->offset) { fl->size += fl2->size; - HDassert(fl->size==H5HL_ALIGN (fl->size)); + HDassert(fl->size == H5HL_ALIGN(fl->size)); fl2 = H5HL_remove_free(heap, fl2); - if(((fl->offset + fl->size) == heap->heap_alloc) && - ((2 * fl->size) > heap->heap_alloc)) { + if(((fl->offset + fl->size) == heap->dblk_size) && + ((2 * fl->size) > heap->dblk_size)) { if(H5HL_minimize_heap_space(f, dxpl_id, heap) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "heap size minimization failed") - } + } /* end if */ HGOTO_DONE(SUCCEED); - } + } /* end if */ fl2 = fl2->next; - } - if(((fl->offset + fl->size) == heap->heap_alloc) && - ((2 * fl->size) > heap->heap_alloc)) { + } /* end while */ + if(((fl->offset + fl->size) == heap->dblk_size) && + ((2 * fl->size) > heap->dblk_size)) { if(H5HL_minimize_heap_space(f, dxpl_id, heap) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "heap size minimization failed") - } + } /* end if */ HGOTO_DONE(SUCCEED); - } + } /* end if */ fl = fl->next; } /* end while */ @@ -1264,14 +1061,14 @@ H5HL_remove(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, size_t offset, size_t size) heap->freelist->prev = fl; heap->freelist = fl; - if(((fl->offset + fl->size) == heap->heap_alloc) && - ((2 * fl->size) > heap->heap_alloc)) { + if(((fl->offset + fl->size) == heap->dblk_size) && + ((2 * fl->size) > heap->dblk_size)) { if(H5HL_minimize_heap_space(f, dxpl_id, heap) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "heap size minimization failed") } /* end if */ done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5HL_remove() */ @@ -1286,67 +1083,91 @@ done: * koziol@ncsa.uiuc.edu * Mar 22 2003 * - * Modifications: - * - * John Mainzer - 6/17/05 - * Modified function to use the new dirtied parmeter of - * H5AC_unprotect(), which allows management of the is_dirty - * field of the cache info to be moved into the cache code. - * *------------------------------------------------------------------------- */ herr_t H5HL_delete(H5F_t *f, hid_t dxpl_id, haddr_t addr) { - H5HL_t *heap = NULL; - size_t sizeof_hdr; /* Cache H5HL header size for file */ - herr_t ret_value=SUCCEED; /* Return value */ + H5HL_cache_prfx_ud_t prfx_udata; /* User data for protecting local heap prefix */ + H5HL_prfx_t *prfx = NULL; /* Local heap prefix */ + H5HL_dblk_t *dblk = NULL; /* Local heap data block */ + H5HL_t *heap; /* Heap data structure */ + unsigned cache_flags = H5AC2__NO_FLAGS_SET; /* Cache flags for unprotecting entries */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5HL_delete, FAIL); + FUNC_ENTER_NOAPI(H5HL_delete, FAIL) /* check arguments */ - assert(f); - assert(H5F_addr_defined(addr)); - - /* Cache this for later */ - sizeof_hdr= H5HL_SIZEOF_HDR(f); + HDassert(f); + HDassert(H5F_addr_defined(addr)); - /* Get heap pointer */ - 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"); + /* Construct the user data for protect callback */ + prfx_udata.made_attempt = FALSE; + prfx_udata.f = f; + prfx_udata.loaded = FALSE; + prfx_udata.free_block = 0; + + /* Protect the local heap prefix */ + if(NULL == (prfx = (H5HL_prfx_t *)H5AC2_protect(f, dxpl_id, H5AC2_LHEAP_PRFX, addr, H5HL_SPEC_READ_SIZE, &prfx_udata, H5AC2_WRITE))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load heap prefix") + + /* Get the pointer to the heap */ + heap = prfx->heap; + + /* Check if heap has separate data block */ + if(!heap->single_cache_obj) { + H5HL_cache_dblk_ud_t dblk_udata; /* User data for protecting local heap data block */ + + /* Construct the user data for protect callback */ + dblk_udata.f = f; + dblk_udata.heap = heap; + dblk_udata.free_block = prfx_udata.loaded ? prfx_udata.free_block : + (heap->freelist ? heap->freelist->offset : H5HL_FREE_NULL); + dblk_udata.loaded = FALSE; + + /* Protect the local heap data block */ + if(NULL == (dblk = (H5HL_dblk_t *)H5AC2_protect(f, dxpl_id, H5AC2_LHEAP_DBLK, heap->dblk_addr, heap->dblk_size, &dblk_udata, H5AC2_WRITE))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load heap data block") + + /* Pin the prefix, if the data block was loaded from file */ + if(dblk_udata.loaded) { + if(H5AC2_pin_protected_entry(prfx) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTPIN, FAIL, "unable to pin local heap prefix") + } /* end if */ + } /* end if */ /* Check if the heap is contiguous on disk */ - assert(!H5F_addr_overflow(addr,sizeof_hdr)); - if(H5F_addr_eq(heap->addr,addr+sizeof_hdr)) { + if(heap->single_cache_obj) { /* Free the contiguous local heap in one call */ - H5_CHECK_OVERFLOW(sizeof_hdr+heap->heap_alloc,size_t,hsize_t); - if (H5MF_xfree(f, H5FD_MEM_LHEAP, dxpl_id, addr, (hsize_t)(sizeof_hdr+heap->heap_alloc))<0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to free contiguous local heap"); + H5_CHECK_OVERFLOW(heap->prfx_size + heap->dblk_size, size_t, hsize_t); + if(H5MF_xfree(f, H5FD_MEM_LHEAP, dxpl_id, addr, (hsize_t)(heap->prfx_size + heap->dblk_size)) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to free contiguous local heap") } /* end if */ else { - /* Free the local heap's header */ - H5_CHECK_OVERFLOW(sizeof_hdr,size_t,hsize_t); - if (H5MF_xfree(f, H5FD_MEM_LHEAP, dxpl_id, addr, (hsize_t)sizeof_hdr)<0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to free local heap header"); - - /* Free the local heap's data */ - H5_CHECK_OVERFLOW(heap->heap_alloc,size_t,hsize_t); - if (H5MF_xfree(f, H5FD_MEM_LHEAP, dxpl_id, heap->addr, (hsize_t)heap->heap_alloc)<0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to free local heap data"); + /* Free the local heap's prefix */ + H5_CHECK_OVERFLOW(heap->prfx_size, size_t, hsize_t); + if(H5MF_xfree(f, H5FD_MEM_LHEAP, dxpl_id, heap->prfx_addr, (hsize_t)heap->prfx_size) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to free local heap header") + + /* Free the local heap's data block */ + H5_CHECK_OVERFLOW(heap->dblk_size, size_t, hsize_t); + if(H5MF_xfree(f, H5FD_MEM_LHEAP, dxpl_id, heap->dblk_addr, (hsize_t)heap->dblk_size) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to free local heap data") } /* end else */ - /* Release the local heap metadata from the cache */ - if (H5AC_unprotect(f, dxpl_id, H5AC_LHEAP, addr, heap, H5AC__DIRTIED_FLAG | H5C__DELETED_FLAG)<0) { - heap = NULL; - HGOTO_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to release local heap"); - } - heap = NULL; + /* Set the flags for releasing the prefix and data block */ + cache_flags |= H5AC2__DIRTIED_FLAG | H5AC2__DELETED_FLAG; done: - if (heap && H5AC_unprotect(f, dxpl_id, H5AC_LHEAP, addr, heap, H5AC__NO_FLAGS_SET)<0) - HDONE_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to release local heap"); + /* Release the data block from the cache, now deleted */ + if(dblk && H5AC2_unprotect(f, dxpl_id, H5AC2_LHEAP_DBLK, heap->dblk_addr, (size_t)0, dblk, cache_flags) < 0) + HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release local heap data block") + + /* Release the prefix from the cache, now deleted */ + if(prfx && H5AC2_unprotect(f, dxpl_id, H5AC2_LHEAP_PRFX, heap->prfx_addr, (size_t)0, prfx, cache_flags) < 0) + HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release local heap prefix") - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5HL_delete() */ @@ -1366,8 +1187,10 @@ done: herr_t H5HL_get_size(H5F_t *f, hid_t dxpl_id, haddr_t addr, size_t *size) { - H5HL_t *heap = NULL; /* Heap to query */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HL_cache_prfx_ud_t prfx_udata; /* User data for protecting local heap prefix */ + H5HL_prfx_t *prfx = NULL; /* Local heap prefix */ + H5HL_t *heap; /* Heap data structure */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5HL_get_size, FAIL) @@ -1376,16 +1199,25 @@ H5HL_get_size(H5F_t *f, hid_t dxpl_id, haddr_t addr, size_t *size) HDassert(H5F_addr_defined(addr)); HDassert(size); - /* Get heap pointer */ - if(NULL == (heap = H5AC_protect(f, dxpl_id, H5AC_LHEAP, addr, NULL, NULL, H5AC_READ))) - HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load heap") + /* Construct the user data for protect callback */ + prfx_udata.made_attempt = FALSE; + prfx_udata.f = f; + prfx_udata.loaded = FALSE; + prfx_udata.free_block = 0; + + /* Protect the local heap prefix */ + if(NULL == (prfx = (H5HL_prfx_t *)H5AC2_protect(f, dxpl_id, H5AC2_LHEAP_PRFX, addr, H5HL_SPEC_READ_SIZE, &prfx_udata, H5AC2_READ))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load heap prefix") + + /* Get the pointer to the heap */ + heap = prfx->heap; /* Set the size to return */ - *size = heap->heap_alloc; + *size = heap->dblk_size; done: - if(heap && H5AC_unprotect(f, dxpl_id, H5AC_LHEAP, addr, heap, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to release local heap") + if(prfx && H5AC2_unprotect(f, dxpl_id, H5AC2_LHEAP_PRFX, heap->prfx_addr, (size_t)0, prfx, H5AC2__NO_FLAGS_SET) < 0) + HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release local heap prefix") FUNC_LEAVE_NOAPI(ret_value) } /* end H5HL_get_size() */ @@ -1407,9 +1239,10 @@ done: herr_t H5HL_heapsize(H5F_t *f, hid_t dxpl_id, haddr_t addr, hsize_t *heap_size) { - H5HL_t *heap = NULL; /* Heap to query */ - size_t local_heap_size = 0; - herr_t ret_value = SUCCEED; /* Return value */ + H5HL_cache_prfx_ud_t prfx_udata; /* User data for protecting local heap prefix */ + H5HL_prfx_t *prfx = NULL; /* Local heap prefix */ + H5HL_t *heap; /* Heap data structure */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5HL_heapsize, FAIL) @@ -1418,21 +1251,68 @@ H5HL_heapsize(H5F_t *f, hid_t dxpl_id, haddr_t addr, hsize_t *heap_size) HDassert(H5F_addr_defined(addr)); HDassert(heap_size); - /* Get heap pointer */ - if(NULL == (heap = H5AC_protect(f, dxpl_id, H5AC_LHEAP, addr, NULL, NULL, H5AC_READ))) - HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load heap") + /* Construct the user data for protect callback */ + prfx_udata.made_attempt = FALSE; + prfx_udata.f = f; + prfx_udata.loaded = FALSE; + prfx_udata.free_block = 0; - /* Get the total size of the local heap */ - if(H5HL_size(f, heap, &local_heap_size) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to compute size of local heap") + /* Protect the local heap prefix */ + if(NULL == (prfx = (H5HL_prfx_t *)H5AC2_protect(f, dxpl_id, H5AC2_LHEAP_PRFX, addr, H5HL_SPEC_READ_SIZE, &prfx_udata, H5AC2_READ))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load heap prefix") + + /* Get the pointer to the heap */ + heap = prfx->heap; /* Accumulate the size of the local heap */ - *heap_size += (hsize_t)local_heap_size; + *heap_size += (hsize_t)(heap->prfx_size + heap->dblk_size); done: - if(heap && H5AC_unprotect(f, dxpl_id, H5AC_LHEAP, addr, heap, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to release local heap") + if(prfx && H5AC2_unprotect(f, dxpl_id, H5AC2_LHEAP_PRFX, heap->prfx_addr, (size_t)0, prfx, H5AC2__NO_FLAGS_SET) < 0) + HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release local heap prefix") FUNC_LEAVE_NOAPI(ret_value) } /* end H5HL_heapsize() */ + +/*------------------------------------------------------------------------- + * Function: H5HL_dest + * + * Purpose: Destroys a heap in memory. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@ncsa.uiuc.edu + * Jan 15 2003 + * + *------------------------------------------------------------------------- + */ +herr_t +H5HL_dest(H5HL_t *heap) +{ + FUNC_ENTER_NOAPI_NOFUNC(H5HL_dest) + + /* check arguments */ + HDassert(heap); + + /* Verify that node is unused */ + HDassert(heap->prots == 0); + HDassert(heap->rc == 0); + HDassert(heap->prfx == NULL); + HDassert(heap->dblk == NULL); + + if(heap->image) + heap->image = H5FL_BLK_FREE(lheap_chunk, heap->image); + while(heap->freelist) { + H5HL_free_t *fl; + + fl = heap->freelist; + heap->freelist = fl->next; + H5FL_FREE(H5HL_free_t, fl); + } /* end while */ + H5FL_FREE(H5HL_t, heap); + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5HL_dest() */ + diff --git a/src/H5HLcache.c b/src/H5HLcache.c new file mode 100644 index 0000000..fef4340 --- /dev/null +++ b/src/H5HLcache.c @@ -0,0 +1,648 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/*------------------------------------------------------------------------- + * + * Created: H5HLcache.c + * Jul 23 2008 + * Quincey Koziol + * + * Purpose: Local heap metadata cache callbacks. + * + *------------------------------------------------------------------------- + */ + +/****************/ +/* Module Setup */ +/****************/ + +#define H5HL_PACKAGE /* Suppress error about including H5HLpkg */ + + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5HLpkg.h" /* Local Heaps */ + +/****************/ +/* Local Macros */ +/****************/ + +/* Local heap format version */ +#define H5HL_VERSION 0 + +/* Value indicating end of free list on disk */ +#define H5HL_FREE_NULL 1 + + +/******************/ +/* Local Typedefs */ +/******************/ + + +/********************/ +/* Package Typedefs */ +/********************/ + + +/********************/ +/* Local Prototypes */ +/********************/ + +/* Metadata cache callbacks */ +static void *H5HL_prfx_deserialize(haddr_t addr, size_t len, const void *image, + void *udata, hbool_t *dirty); +static herr_t H5HL_prfx_image_len(const void *thing, size_t *image_len_ptr); +static herr_t H5HL_prfx_serialize(const H5F_t *f, hid_t dxpl_id, haddr_t addr, size_t len, + void *image, void *thing, unsigned *flags, haddr_t *new_addr, + size_t *new_len, void **new_image); +static herr_t H5HL_prfx_free_icr(haddr_t addr, size_t len, void *thing); + +static void *H5HL_dblk_deserialize(haddr_t addr, size_t len, const void *image, + void *udata, hbool_t *dirty); +static herr_t H5HL_dblk_serialize(const H5F_t *f, hid_t dxpl_id, haddr_t addr, size_t len, + void *image, void *thing, unsigned *flags, haddr_t *new_addr, + size_t *new_len, void **new_image); +static herr_t H5HL_dblk_free_icr(haddr_t addr, size_t len, void *thing); + + +/*********************/ +/* Package Variables */ +/*********************/ + +/* + * H5HL prefix inherits cache-like properties from H5AC2 + */ +const H5AC2_class_t H5AC2_LHEAP_PRFX[1] = {{ + H5AC2_LHEAP_PRFX_ID, + "local heap prefix", + H5FD_MEM_LHEAP, + H5HL_prfx_deserialize, + H5HL_prfx_image_len, + H5HL_prfx_serialize, + H5HL_prfx_free_icr, + NULL, +}}; + +/* + * H5HL data block inherits cache-like properties from H5AC2 + */ +const H5AC2_class_t H5AC2_LHEAP_DBLK[1] = {{ + H5AC2_LHEAP_DBLK_ID, + "local heap data block", + H5FD_MEM_LHEAP, + H5HL_dblk_deserialize, + NULL, + H5HL_dblk_serialize, + H5HL_dblk_free_icr, + NULL, +}}; + +/* Declare a free list to manage the H5HL_free_t struct */ +H5FL_EXTERN(H5HL_free_t); + +/* Declare a free list to manage the H5HL_t struct */ +H5FL_EXTERN(H5HL_t); + +/* Declare a PQ free list to manage the heap chunk information */ +H5FL_BLK_EXTERN(lheap_chunk); + + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + + +/*******************/ +/* Local Variables */ +/*******************/ + + + +/*------------------------------------------------------------------------- + * Function: H5HL_fl_deserialize + * + * Purpose: Deserialize the free list for a heap data block + * + * Return: Success: SUCCESS + * Failure: FAIL + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * Oct 12 2008 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5HL_fl_deserialize(const H5F_t *f, H5HL_t *heap, hsize_t free_block) +{ + H5HL_free_t *fl, *tail = NULL; /* Heap free block nodes */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5HL_fl_deserialize) + + /* check arguments */ + HDassert(heap); + + /* Build free list */ + while(H5HL_FREE_NULL != free_block) { + const uint8_t *p; /* Pointer into image buffer */ + + /* Sanity check */ + if(free_block >= heap->dblk_size) + HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "bad heap free list") + + /* Allocate & initialize free list node */ + if(NULL == (fl = H5FL_MALLOC(H5HL_free_t))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "memory allocation failed") + fl->offset = (size_t)free_block; + fl->prev = tail; + fl->next = NULL; + + /* Insert node into list */ + if(tail) + tail->next = fl; + tail = fl; + if(!heap->freelist) + heap->freelist = fl; + + /* Decode offset of next free block */ + p = heap->image + free_block; + H5F_DECODE_LENGTH(f, p, free_block); + if(free_block == 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "free block size is zero?") + + /* Decode length of this free block */ + H5F_DECODE_LENGTH(f, p, fl->size); + if(fl->offset + fl->size > heap->dblk_size) + HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "bad heap free list") + } /* end while */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HL_fl_deserialize() */ + + +/*------------------------------------------------------------------------- + * Function: H5HL_fl_serialize + * + * Purpose: Serialize the free list for a heap data block + * + * Return: Success: SUCCESS + * Failure: FAIL + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * Oct 12 2008 + * + *------------------------------------------------------------------------- + */ +static void +H5HL_fl_serialize(const H5F_t *f, H5HL_t *heap) +{ + H5HL_free_t *fl; /* Pointer to heap free list node */ + + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HL_fl_serialize) + + /* check arguments */ + HDassert(heap); + + /* Serialize the free list into the heap data's image */ + for(fl = heap->freelist; fl; fl = fl->next) { + uint8_t *p; /* Pointer into raw data buffer */ + + HDassert(fl->offset == H5HL_ALIGN(fl->offset)); + p = heap->image + fl->offset; + + if(fl->next) + H5F_ENCODE_LENGTH(f, p, fl->next->offset) + else + H5F_ENCODE_LENGTH(f, p, H5HL_FREE_NULL) + + H5F_ENCODE_LENGTH(f, p, fl->size); + } /* end for */ + + FUNC_LEAVE_NOAPI_VOID +} /* end H5HL_fl_serialize() */ + + +/*------------------------------------------------------------------------- + * Function: H5HL_prfx_deserialize + * + * Purpose: Deserialize the data structure from disk. + * + * Return: Success: SUCCESS + * Failure: FAIL + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * Oct 11 2008 + * + *------------------------------------------------------------------------- + */ +static void * +H5HL_prfx_deserialize(haddr_t addr, size_t len, const void *image, + void *_udata, hbool_t UNUSED *dirty) +{ + H5HL_t *heap = NULL; /* Local heap */ + H5HL_prfx_t *prfx = NULL; /* Heap prefix deserialized */ + H5HL_cache_prfx_ud_t *udata = (H5HL_cache_prfx_ud_t *)_udata; /* User data for callback */ + const uint8_t *p; /* Pointer into image buffer */ + H5HL_prfx_t *ret_value; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5HL_prfx_deserialize) + + /* check arguments */ + HDassert(H5F_addr_defined(addr)); + HDassert(len > 0); + HDassert(image); + HDassert(udata); + HDassert(udata->f); + + /* Point to beginning of image buffer */ + p = (const uint8_t *)image; + + /* Magic number */ + if(HDmemcmp(p, H5HL_MAGIC, (size_t)H5HL_SIZEOF_MAGIC)) + HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "bad local heap signature") + p += H5HL_SIZEOF_MAGIC; + + /* Version */ + if(H5HL_VERSION != *p++) + HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "wrong version number in local heap") + + /* Reserved */ + p += 3; + + /* Allocate space in memory for the heap */ + if(NULL == (heap = H5FL_CALLOC(H5HL_t))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "memory allocation failed") + + /* Allocate the heap prefix */ + if(NULL == (prfx = H5HL_prfx_new(heap))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "memory allocation failed") + + /* Store the prefix's address & length */ + heap->prfx_addr = addr; + heap->prfx_size = H5HL_SIZEOF_HDR(udata->f); + + /* Heap data size */ + H5F_DECODE_LENGTH(udata->f, p, heap->dblk_size); + + /* Free list head */ + H5F_DECODE_LENGTH(udata->f, p, udata->free_block); + if(udata->free_block != H5HL_FREE_NULL && udata->free_block >= heap->dblk_size) + HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "bad heap free list") + + /* Heap data address */ + H5F_addr_decode(udata->f, &p, &(heap->dblk_addr)); + + /* Check if heap block exists */ + if(heap->dblk_size) { + /* Check if heap data block is contiguous with header */ + if(H5F_addr_eq((heap->prfx_addr + heap->prfx_size), heap->dblk_addr)) { + /* Note that the heap should be a single object in the cache */ + heap->single_cache_obj = TRUE; + + /* Check if the current image from the cache is big enough to hold the heap data */ + if(len >= (heap->prfx_size + heap->dblk_size)) { + /* Allocate space for the heap data image */ + if(NULL == (heap->image = H5FL_BLK_MALLOC(lheap_chunk, heap->dblk_size))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "memory allocation failed") + + /* Copy the heap data from the image */ + HDmemcpy(heap->image, p, heap->dblk_size); + + /* Build free list */ + if(H5HL_fl_deserialize(udata->f, heap, udata->free_block) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, NULL, "can't initialize free list") + } /* end if */ + else + /* Make certain the length was OK on the retry */ + HDassert(!udata->made_attempt); + + /* Note that we've made one attempt at decoding the local heap already */ + /* (useful when the length is incorrect and the cache will retry with a larger one) */ + udata->made_attempt = TRUE; + } /* end if */ + else + /* Note that the heap should _NOT_ be a single object in the cache */ + heap->single_cache_obj = FALSE; + } /* end if */ + + /* Set flag to indicate prefix from loaded from file */ + udata->loaded = TRUE; + + /* Set return value */ + ret_value = prfx; + +done: + /* Release the [possibly partially initialized] local heap on errors */ + if(!ret_value) { + if(prfx) { + if(H5HL_prfx_dest(prfx) < 0) + HDONE_ERROR(H5E_HEAP, H5E_CANTRELEASE, NULL, "unable to destroy local heap prefix") + } /* end if */ + else { + if(heap && H5HL_dest(heap) < 0) + HDONE_ERROR(H5E_HEAP, H5E_CANTRELEASE, NULL, "unable to destroy local heap") + } /* end else */ + } /* end if */ + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HL_prfx_deserialize() */ + + +/*------------------------------------------------------------------------- + * Function: H5HL_prfx_image_len + * + * Purpose: Tell the metadata cache about the actual size of the object + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * Oct 11 2008 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5HL_prfx_image_len(const void *thing, size_t *image_len_ptr) +{ + const H5HL_prfx_t *prfx = (const H5HL_prfx_t *)thing; /* The local heap prefix */ + + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HL_prfx_image_len) + + /* Check arguments */ + HDassert(prfx); + HDassert(prfx->heap); + HDassert(image_len_ptr); + + /* Report the local heap's size, including the data block, if it's contiguous w/prefix */ + if(prfx->heap->single_cache_obj) + *image_len_ptr = prfx->heap->prfx_size + prfx->heap->dblk_size; + else + *image_len_ptr = prfx->heap->prfx_size; + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5HL_prfx_image_len() */ + + +/*------------------------------------------------------------------------- + * Function: H5HL_prfx_serialize + * + * Purpose: Serializes a 'in core' representation of data structure + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * Oct 11 2008 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5HL_prfx_serialize(const H5F_t *f, hid_t UNUSED dxpl_id, haddr_t UNUSED addr, + size_t UNUSED len, void *image, void *_thing, unsigned *flags, + haddr_t UNUSED *new_addr, size_t UNUSED *new_len, void UNUSED **new_image) +{ + H5HL_prfx_t *prfx = (H5HL_prfx_t *)_thing; /* Pointer to the local heap prefix */ + H5HL_t *heap; /* Pointer to the local heap */ + uint8_t *p; /* Pointer into raw data buffer */ + + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HL_prfx_serialize) + + /* check arguments */ + HDassert(f); + HDassert(image); + HDassert(prfx); + HDassert(prfx->heap); + HDassert(flags); + + /* Get the pointer to the heap */ + heap = prfx->heap; + + /* Point to the cache image */ + p = (uint8_t *)image; + + /* Serialize the header */ + HDmemcpy(p, H5HL_MAGIC, (size_t)H5HL_SIZEOF_MAGIC); + p += H5HL_SIZEOF_MAGIC; + *p++ = H5HL_VERSION; + *p++ = 0; /*reserved*/ + *p++ = 0; /*reserved*/ + *p++ = 0; /*reserved*/ + H5F_ENCODE_LENGTH(f, p, heap->dblk_size); + H5F_ENCODE_LENGTH(f, p, heap->freelist ? heap->freelist->offset : H5HL_FREE_NULL); + H5F_addr_encode(f, &p, heap->dblk_addr); + + /* Check if the local heap is a single object in cache */ + if(heap->single_cache_obj) { + /* Serialize the free list into the heap data's image */ + H5HL_fl_serialize(f, heap); + + /* Copy the heap data block into the cache image */ + HDmemcpy(p, heap->image, heap->dblk_size); + } /* end if */ + + /* Reset the cache flags for this operation */ + *flags = 0; + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* H5HL_prfx_serialize() */ + + +/*------------------------------------------------------------------------- + * Function: H5HL_prfx_free_icr + * + * Purpose: Destroy/release an "in core representation" of a data + * structure + * + * Return: Success: SUCCEED + * Failure: FAIL + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * October 11, 2008 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5HL_prfx_free_icr(haddr_t UNUSED addr, size_t UNUSED len, void *thing) +{ + H5HL_prfx_t *prfx = (H5HL_prfx_t *)thing; /* Local heap prefix to destroy */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5HL_prfx_free_icr) + + /* Check arguments */ + HDassert(prfx); + + /* Destroy local heap prefix */ + if(H5HL_prfx_dest(prfx) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't destroy local heap prefix") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5HL_prfx_free_icr() */ + + +/*------------------------------------------------------------------------- + * Function: H5HL_dblk_deserialize + * + * Purpose: Deserialize the data structure from disk. + * + * Return: Success: SUCCESS + * Failure: FAIL + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * Oct 12 2008 + * + *------------------------------------------------------------------------- + */ +static void * +H5HL_dblk_deserialize(haddr_t UNUSED addr, size_t UNUSED len, const void *image, + void *_udata, hbool_t UNUSED *dirty) +{ + H5HL_dblk_t *dblk = NULL; /* Local heap data block deserialized */ + H5HL_cache_dblk_ud_t *udata = (H5HL_cache_dblk_ud_t *)_udata; /* User data for callback */ + H5HL_dblk_t *ret_value = NULL; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5HL_dblk_deserialize) + + /* check arguments */ + HDassert(image); + HDassert(udata); + HDassert(udata->f); + HDassert(udata->heap); + HDassert(!udata->heap->single_cache_obj); + HDassert(NULL == udata->heap->dblk); + + /* Allocate space in memory for the heap data block */ + if(NULL == (dblk = H5HL_dblk_new(udata->heap))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "memory allocation failed") + + /* Check for heap still retaining image */ + if(NULL == udata->heap->image) { + /* Allocate space for the heap data image */ + if(NULL == (udata->heap->image = H5FL_BLK_MALLOC(lheap_chunk, udata->heap->dblk_size))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "memory allocation failed") + + /* Copy the cache image into the heap's data image */ + HDmemcpy(udata->heap->image, image, udata->heap->dblk_size); + + /* Build free list */ + if(H5HL_fl_deserialize(udata->f, udata->heap, udata->free_block) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, NULL, "can't initialize free list") + } /* end if */ + + /* Set flag to indicate data block from loaded from file */ + udata->loaded = TRUE; + + /* Set return value */ + ret_value = dblk; + +done: + /* Release the [possibly partially initialized] local heap on errors */ + if(!ret_value && dblk) + if(H5HL_dblk_dest(dblk) < 0) + HDONE_ERROR(H5E_HEAP, H5E_CANTRELEASE, NULL, "unable to destroy local heap data block") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HL_dblk_deserialize() */ + + +/*------------------------------------------------------------------------- + * Function: H5HL_dblk_serialize + * + * Purpose: Serializes a 'in core' representation of data structure + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * Oct 12 2008 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5HL_dblk_serialize(const H5F_t *f, hid_t UNUSED dxpl_id, haddr_t UNUSED addr, + size_t UNUSED len, void *image, void *_thing, unsigned *flags, + haddr_t UNUSED *new_addr, size_t UNUSED *new_len, void UNUSED **new_image) +{ + H5HL_dblk_t *dblk = (H5HL_dblk_t *)_thing; /* Pointer to the local heap data block */ + H5HL_t *heap; /* Pointer to the local heap */ + + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HL_dblk_serialize) + + /* check arguments */ + HDassert(image); + HDassert(dblk); + HDassert(flags); + + /* Get the pointer to the heap */ + heap = dblk->heap; + + /* Serialize the free list into the heap data's image */ + H5HL_fl_serialize(f, heap); + + /* Copy the heap's data block into the cache's image */ + HDmemcpy(image, heap->image, heap->dblk_size); + + /* Reset the cache flags for this operation */ + *flags = 0; + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* H5HL_dblk_serialize() */ + + +/*------------------------------------------------------------------------- + * Function: H5HL_dblk_free_icr + * + * Purpose: Destroy/release an "in core representation" of a data + * structure + * + * Return: Success: SUCCEED + * Failure: FAIL + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * October 12, 2008 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5HL_dblk_free_icr(haddr_t UNUSED addr, size_t UNUSED len, void *thing) +{ + H5HL_dblk_t *dblk = (H5HL_dblk_t *)thing; /* Local heap data block to destroy */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5HL_dblk_free_icr) + + /* Check arguments */ + HDassert(dblk); + + /* Destroy local heap data block */ + if(H5HL_dblk_dest(dblk) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "unable to destroy local heap data block") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5HL_dblk_free_icr() */ + diff --git a/src/H5HLdbg.c b/src/H5HLdbg.c index f4211f8..1a36095 100644 --- a/src/H5HLdbg.c +++ b/src/H5HLdbg.c @@ -46,7 +46,7 @@ * * John Mainzer, 6/17/05 * Modified the function to use the new dirtied parameter of - * of H5AC_unprotect() instead of modifying the is_dirty + * of H5AC2_unprotect() instead of modifying the is_dirty * field of the cache info. * *------------------------------------------------------------------------- @@ -59,82 +59,78 @@ H5HL_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream, int indent, int H5HL_free_t *freelist = NULL; uint8_t *marker = NULL; size_t amount_free = 0; - herr_t ret_value=SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5HL_debug, FAIL); + FUNC_ENTER_NOAPI(H5HL_debug, FAIL) /* check arguments */ - assert(f); - assert(H5F_addr_defined(addr)); - assert(stream); - assert(indent >= 0); - assert(fwidth >= 0); + HDassert(f); + HDassert(H5F_addr_defined(addr)); + HDassert(stream); + HDassert(indent >= 0); + HDassert(fwidth >= 0); - if (NULL == (h = H5AC_protect(f, dxpl_id, H5AC_LHEAP, addr, NULL, NULL, H5AC_READ))) - HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load heap"); + if(NULL == (h = H5HL_protect(f, dxpl_id, addr, H5AC2_READ))) + 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.is_dirty)); fprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth, "Header size (in bytes):", - (unsigned long) H5HL_SIZEOF_HDR(f)); + (unsigned long)h->prfx_size); HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, "Address of heap data:", - h->addr); + h->dblk_addr); HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, "Data bytes allocated for heap:", - h->heap_alloc); + h->dblk_size); /* * 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->heap_alloc))) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); + if(NULL == (marker = (uint8_t *)H5MM_calloc(h->dblk_size))) + 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++) { + 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->heap_alloc) { + if((freelist->offset + freelist->size) > h->dblk_size) 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]) + else { + for(i = overlap = 0; i < (int)(freelist->size); i++) { + if(marker[freelist->offset + i]) overlap++; marker[freelist->offset + i] = 1; - } - if (overlap) { + } /* end for */ + if(overlap) fprintf(stream, "***THAT FREE BLOCK OVERLAPPED A PREVIOUS " "ONE!\n"); - } else { + else amount_free += freelist->size; - } - } - } + } /* end for */ + } /* end for */ - if (h->heap_alloc) { + if(h->dblk_size) fprintf(stream, "%*s%-*s %.2f%%\n", indent, "", fwidth, "Percent of heap used:", - (100.0 * (double)(h->heap_alloc - amount_free) / (double)h->heap_alloc)); - } + (100.0 * (double)(h->dblk_size - amount_free) / (double)h->dblk_size)); /* * Print the data in a VMS-style octal dump. */ - H5_buffer_dump(stream, indent, h->chunk, marker, H5HL_SIZEOF_HDR(f), h->heap_alloc); + H5_buffer_dump(stream, indent, h->image, marker, (size_t)0, h->dblk_size); done: - if (h && H5AC_unprotect(f, dxpl_id, H5AC_LHEAP, addr, h, FALSE) != SUCCEED) - HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header"); + if(h && H5HL_unprotect(h) < 0) + HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header") H5MM_xfree(marker); - FUNC_LEAVE_NOAPI(ret_value); -} + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HL_debug() */ + diff --git a/src/H5HLint.c b/src/H5HLint.c new file mode 100644 index 0000000..84a121f --- /dev/null +++ b/src/H5HLint.c @@ -0,0 +1,325 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/*------------------------------------------------------------------------- + * + * Created: H5HLint.c + * Oct 12 2008 + * Quincey Koziol + * + * Purpose: Local heap internal routines. + * + *------------------------------------------------------------------------- + */ + +/****************/ +/* Module Setup */ +/****************/ + +#define H5HL_PACKAGE /* Suppress error about including H5HLpkg */ + + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5HLpkg.h" /* Local Heaps */ + +/****************/ +/* Local Macros */ +/****************/ + + +/******************/ +/* Local Typedefs */ +/******************/ + + +/********************/ +/* Package Typedefs */ +/********************/ + + +/********************/ +/* Local Prototypes */ +/********************/ + + +/*********************/ +/* Package Variables */ +/*********************/ + + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + + +/*******************/ +/* Local Variables */ +/*******************/ + +/* Declare a free list to manage the H5HL_dblk_t struct */ +H5FL_DEFINE(H5HL_dblk_t); + +/* Declare a free list to manage the H5HL_prfx_t struct */ +H5FL_DEFINE(H5HL_prfx_t); + + + +/*------------------------------------------------------------------------- + * Function: H5HL_inc_rc + * + * Purpose: Increment ref. count on heap + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * Oct 12 2008 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5HL_inc_rc(H5HL_t *heap) +{ + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HL_inc_rc) + + /* check arguments */ + HDassert(heap); + + /* Increment heap's ref. count */ + heap->rc++; + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5HL_inc_rc() */ + + +/*------------------------------------------------------------------------- + * Function: H5HL_dec_rc + * + * Purpose: Decrement ref. count on heap + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * Oct 12 2008 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5HL_dec_rc(H5HL_t *heap) +{ + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HL_dec_rc) + + /* check arguments */ + HDassert(heap); + + /* Decrement heap's ref. count */ + heap->rc--; + + /* Check if we should destroy the heap */ + if(heap->rc == 0) + H5HL_dest(heap); + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5HL_dec_rc() */ + + +/*------------------------------------------------------------------------- + * Function: H5HL_prfx_new + * + * Purpose: Create a new local heap prefix object + * + * Return: Success: non-NULL pointer to new local heap prefix + * Failure: NULL + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * Oct 12 2008 + * + *------------------------------------------------------------------------- + */ +H5HL_prfx_t * +H5HL_prfx_new(H5HL_t *heap) +{ + H5HL_prfx_t *prfx = NULL; /* New local heap prefix */ + H5HL_prfx_t *ret_value; /* Return value */ + + FUNC_ENTER_NOAPI(H5HL_prfx_new, NULL) + + /* check arguments */ + HDassert(heap); + + /* Allocate new local heap prefix */ + if(NULL == (prfx = H5FL_CALLOC(H5HL_prfx_t))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "memory allocation failed") + + /* Increment ref. count on heap data structure */ + if(H5HL_inc_rc(heap) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, NULL, "can't increment heap ref. count") + + /* Link the heap & the prefix */ + prfx->heap = heap; + heap->prfx = prfx; + + /* Set the return value */ + ret_value = prfx; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HL_prfx_new() */ + + +/*------------------------------------------------------------------------- + * Function: H5HL_prfx_dest + * + * Purpose: Destroy a local heap prefix object + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * Oct 12 2008 + * + *------------------------------------------------------------------------- + */ +herr_t +H5HL_prfx_dest(H5HL_prfx_t *prfx) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(H5HL_prfx_dest, FAIL) + + /* check arguments */ + HDassert(prfx); + + /* Unlink prefix from heap */ + prfx->heap->prfx = NULL; + + /* Decrement ref. count on heap data structure */ + if(H5HL_dec_rc(prfx->heap) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement heap ref. count") + + /* Unlink heap from prefix */ + prfx->heap = NULL; + + /* Free local heap prefix */ + H5FL_FREE(H5HL_prfx_t, prfx); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HL_prfx_dest() */ + + +/*------------------------------------------------------------------------- + * Function: H5HL_dblk_new + * + * Purpose: Create a new local heap data block object + * + * Return: Success: non-NULL pointer to new local heap data block + * Failure: NULL + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * Oct 12 2008 + * + *------------------------------------------------------------------------- + */ +H5HL_dblk_t * +H5HL_dblk_new(H5HL_t *heap) +{ + H5HL_dblk_t *dblk = NULL; /* New local heap data block */ + H5HL_dblk_t *ret_value; /* Return value */ + + FUNC_ENTER_NOAPI(H5HL_dblk_new, NULL) + + /* check arguments */ + HDassert(heap); + + /* Allocate new local heap data block */ + if(NULL == (dblk = H5FL_CALLOC(H5HL_dblk_t))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "memory allocation failed") + + /* Increment ref. count on heap data structure */ + if(H5HL_inc_rc(heap) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, NULL, "can't increment heap ref. count") + + /* Link the heap & the data block */ + dblk->heap = heap; + heap->dblk = dblk; + + /* Set the return value */ + ret_value = dblk; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HL_dblk_new() */ + + +/*------------------------------------------------------------------------- + * Function: H5HL_dblk_dest + * + * Purpose: Destroy a local heap data block object + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * Oct 12 2008 + * + *------------------------------------------------------------------------- + */ +herr_t +H5HL_dblk_dest(H5HL_dblk_t *dblk) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(H5HL_dblk_dest, FAIL) + + /* check arguments */ + HDassert(dblk); + + /* Check if data block was initialized */ + if(dblk->heap) { + /* Unlink data block from heap */ + dblk->heap->dblk = NULL; + + /* Unpin the local heap prefix */ + if(H5AC2_unpin_entry(dblk->heap->prfx) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPIN, FAIL, "can't unpin local heap prefix") + + /* Decrement ref. count on heap data structure */ + if(H5HL_dec_rc(dblk->heap) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement heap ref. count") + + /* Unlink heap from data block */ + dblk->heap = NULL; + } /* end if */ + + /* Free local heap data block */ + H5FL_FREE(H5HL_dblk_t, dblk); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HL_dblk_dest() */ + diff --git a/src/H5HLpkg.h b/src/H5HLpkg.h index fe6f107..54626a6 100644 --- a/src/H5HLpkg.h +++ b/src/H5HLpkg.h @@ -37,8 +37,12 @@ /* Package Private Variables */ /*****************************/ -/* The cache subclass */ -H5_DLLVAR const H5AC_class_t H5AC_LHEAP[1]; +/* The local heap prefix cache subclass */ +H5_DLLVAR const H5AC2_class_t H5AC2_LHEAP_PRFX[1]; + +/* The local heap data block cache subclass */ +H5_DLLVAR const H5AC2_class_t H5AC2_LHEAP_DBLK[1]; + /**************************/ /* Package Private Macros */ @@ -46,10 +50,15 @@ H5_DLLVAR const H5AC_class_t H5AC_LHEAP[1]; #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 */ + 1 + /*version */ \ + 3 + /*reserved */ \ + H5F_SIZEOF_SIZE(F) + /*data size */ \ + H5F_SIZEOF_SIZE(F) + /*free list head */ \ + H5F_SIZEOF_ADDR(F)) /*data address */ + +/* Value indicating end of free list on disk */ +#define H5HL_FREE_NULL 1 + /****************************/ /* Package Private Typedefs */ @@ -62,19 +71,76 @@ typedef struct H5HL_free_t { struct H5HL_free_t *next; /*next entry in free list */ } H5HL_free_t; +/* Forward declarations */ +typedef struct H5HL_dblk_t H5HL_dblk_t; +typedef struct H5HL_prfx_t H5HL_prfx_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 heap_alloc; /*size of heap on disk and in mem */ - uint8_t *chunk; /*the chunk, including header */ + size_t rc; /* Ref. count for prefix & data block using this struct */ + size_t prots; /* # of times the heap has been protected */ + H5HL_prfx_t *prfx; /* The prefix object for the heap */ + haddr_t prfx_addr; /* address of heap prefix */ + size_t prfx_size; /* size of heap prefix */ + H5HL_dblk_t *dblk; /* The data block object for the heap */ + haddr_t dblk_addr; /* address of data block */ + size_t dblk_size; /* size of heap data block on disk and in mem */ + hbool_t single_cache_obj; /* Indicate if the heap is a single object in the cache */ + uint8_t *image; /*the heap image, including header */ H5HL_free_t *freelist; /*the free list */ }; +/* Struct for heap data block */ +struct H5HL_dblk_t { + H5AC2_info_t cache_info; /* Information for H5AC2 cache functions, _must_ be */ + /* first field in structure */ + H5HL_t *heap; /* Pointer to heap for data block */ +}; + +/* Struct for heap prefix */ +struct H5HL_prfx_t { + H5AC2_info_t cache_info; /* Information for H5AC2 cache functions, _must_ be */ + /* first field in structure */ + H5HL_t *heap; /* Pointer to heap for prefix */ +}; + +/* Callback information for loading local heap prefix from disk */ +typedef struct H5HL_cache_prfx_ud_t { + /* Downwards */ + hbool_t made_attempt; /* Whether the deserialize routine was already attempted */ + H5F_t *f; /* File pointer */ + + /* Upwards */ + hbool_t loaded; /* Whether prefix was loaded from file */ + hsize_t free_block; /* First free block in heap */ +} H5HL_cache_prfx_ud_t; + +/* Callback information for loading local heap data block from disk */ +typedef struct H5HL_cache_dblk_ud_t { + /* Downwards */ + H5F_t *f; /* File pointer */ + H5HL_t *heap; /* Local heap */ + hsize_t free_block; /* First free block in heap */ + + /* Upwards */ + hbool_t loaded; /* Whether data block was loaded from file */ +} H5HL_cache_dblk_ud_t; + + /******************************/ /* Package Private Prototypes */ /******************************/ +/* Heap routines */ +H5_DLL herr_t H5HL_dest(H5HL_t *heap); + +/* Heap prefix routines */ +H5_DLL H5HL_prfx_t *H5HL_prfx_new(H5HL_t *heap); +H5_DLL herr_t H5HL_prfx_dest(H5HL_prfx_t *prfx); + +/* Heap data block routines */ +H5_DLL H5HL_dblk_t *H5HL_dblk_new(H5HL_t *heap); +H5_DLL herr_t H5HL_dblk_dest(H5HL_dblk_t *dblk); + #endif diff --git a/src/H5HLprivate.h b/src/H5HLprivate.h index d8a4b49..26f2cb7 100644 --- a/src/H5HLprivate.h +++ b/src/H5HLprivate.h @@ -33,7 +33,7 @@ /* Private headers needed by this file. */ #include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ +#include "H5AC2private.h" /* Metadata cache */ #include "H5Fprivate.h" /* File access */ /* @@ -64,11 +64,11 @@ typedef struct H5HL_t H5HL_t; * Library prototypes... */ H5_DLL herr_t H5HL_create(H5F_t *f, hid_t dxpl_id, size_t size_hint, haddr_t *addr/*out*/); -H5_DLL H5HL_t *H5HL_protect(H5F_t *f, hid_t dxpl_id, haddr_t addr, H5AC_protect_t rw); -H5_DLL void *H5HL_offset_into(H5F_t *f, const H5HL_t *heap, size_t offset); +H5_DLL H5HL_t *H5HL_protect(H5F_t *f, hid_t dxpl_id, haddr_t addr, H5AC2_protect_t rw); +H5_DLL void *H5HL_offset_into(const H5HL_t *heap, size_t offset); H5_DLL herr_t H5HL_remove(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, size_t offset, size_t size); -H5_DLL herr_t H5HL_unprotect(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, haddr_t addr); +H5_DLL herr_t H5HL_unprotect(H5HL_t *heap); H5_DLL size_t H5HL_insert(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, size_t size, const void *buf); H5_DLL herr_t H5HL_delete(H5F_t *f, hid_t dxpl_id, haddr_t addr); diff --git a/src/H5Lexternal.c b/src/H5Lexternal.c index f7f0865..9186bf4 100644 --- a/src/H5Lexternal.c +++ b/src/H5Lexternal.c @@ -255,7 +255,7 @@ H5L_extern_traverse(const char UNUSED *link_name, hid_t cur_group, /* target file_name is an absolute pathname: see RM for detailed description */ if (CHECK_ABSOLUTE(file_name) || CHECK_ABS_PATH(file_name)) { if(NULL == (ext_file = H5F_open(file_name, ((intent & H5F_ACC_RDWR) ? H5F_ACC_RDWR : H5F_ACC_RDONLY), - H5P_FILE_CREATE_DEFAULT, fapl_id, H5AC_dxpl_id))) { + H5P_FILE_CREATE_DEFAULT, fapl_id, H5AC2_dxpl_id))) { H5E_clear_stack(NULL); /* get last component of file_name */ GET_LAST_DELIMITER(file_name, ptr) @@ -264,7 +264,7 @@ H5L_extern_traverse(const char UNUSED *link_name, hid_t cur_group, } } else if (CHECK_ABS_DRIVE(file_name)) { if(NULL == (ext_file = H5F_open(file_name, ((intent & H5F_ACC_RDWR) ? H5F_ACC_RDWR : H5F_ACC_RDONLY), - H5P_FILE_CREATE_DEFAULT, fapl_id, H5AC_dxpl_id))) { + H5P_FILE_CREATE_DEFAULT, fapl_id, H5AC2_dxpl_id))) { H5E_clear_stack(NULL); /* strip ":" */ HDstrcpy(tempname, &file_name[2]); @@ -285,7 +285,7 @@ H5L_extern_traverse(const char UNUSED *link_name, hid_t cur_group, HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't prepend prefix to filename") ext_file = H5F_open(full_name, ((intent & H5F_ACC_RDWR) ? H5F_ACC_RDWR : H5F_ACC_RDONLY), - H5P_FILE_CREATE_DEFAULT, fapl_id, H5AC_dxpl_id); + H5P_FILE_CREATE_DEFAULT, fapl_id, H5AC2_dxpl_id); if (full_name) H5MM_xfree(full_name); if (ext_file != NULL) @@ -305,7 +305,7 @@ H5L_extern_traverse(const char UNUSED *link_name, hid_t cur_group, if (H5L_build_name(my_prefix, tempname, &full_name/*out*/) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't prepend prefix to filename") if ((ext_file=H5F_open(full_name, ((intent & H5F_ACC_RDWR) ? H5F_ACC_RDWR : H5F_ACC_RDONLY), - H5P_FILE_CREATE_DEFAULT, fapl_id, H5AC_dxpl_id)) == NULL) + H5P_FILE_CREATE_DEFAULT, fapl_id, H5AC2_dxpl_id)) == NULL) H5E_clear_stack(NULL); if (full_name) H5MM_xfree(full_name); @@ -317,7 +317,7 @@ H5L_extern_traverse(const char UNUSED *link_name, hid_t cur_group, if (H5L_build_name(extpath, tempname, &full_name/*out*/) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't prepend prefix to filename") if ((ext_file = H5F_open(full_name, ((intent & H5F_ACC_RDWR) ? H5F_ACC_RDWR : H5F_ACC_RDONLY), - H5P_FILE_CREATE_DEFAULT, fapl_id, H5AC_dxpl_id)) == NULL) + H5P_FILE_CREATE_DEFAULT, fapl_id, H5AC2_dxpl_id)) == NULL) H5E_clear_stack(NULL); if (full_name) H5MM_xfree(full_name); @@ -326,7 +326,7 @@ H5L_extern_traverse(const char UNUSED *link_name, hid_t cur_group, /* try the relative file_name stored in tempname */ if (ext_file == NULL) { if ((ext_file=H5F_open(tempname, ((intent & H5F_ACC_RDWR) ? H5F_ACC_RDWR : H5F_ACC_RDONLY), - H5P_FILE_CREATE_DEFAULT, fapl_id, H5AC_dxpl_id)) == NULL) + H5P_FILE_CREATE_DEFAULT, fapl_id, H5AC2_dxpl_id)) == NULL) HGOTO_ERROR(H5E_LINK, H5E_CANTOPENFILE, FAIL, "unable to open external file") } @@ -452,7 +452,7 @@ H5Lcreate_external(const char *file_name, const char *obj_name, uint8_t *p; /* Pointer into external link buffer */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API_META(H5Lcreate_external, link_loc_id, H5AC_dxpl_id, FAIL) + FUNC_ENTER_API_META(H5Lcreate_external, link_loc_id, H5AC2_dxpl_id, FAIL) H5TRACE6("e", "*s*si*sii", file_name, obj_name, link_loc_id, link_name, lcpl_id, lapl_id); @@ -479,7 +479,7 @@ H5Lcreate_external(const char *file_name, const char *obj_name, HDstrcpy((char *)p, obj_name); /* External link's object */ /* Create an external link */ - if(H5L_create_ud(&link_loc, link_name, ext_link_buf, buf_size, H5L_TYPE_EXTERNAL, lcpl_id, lapl_id, H5AC_dxpl_id) < 0) + if(H5L_create_ud(&link_loc, link_name, ext_link_buf, buf_size, H5L_TYPE_EXTERNAL, lcpl_id, lapl_id, H5AC2_dxpl_id) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") done: diff --git a/src/H5Oefl.c b/src/H5Oefl.c index 5fa9d6a..49a183e 100644 --- a/src/H5Oefl.c +++ b/src/H5Oefl.c @@ -122,14 +122,14 @@ H5O_efl_decode(H5F_t *f, hid_t dxpl_id, unsigned UNUSED mesg_flags, #ifndef NDEBUG HDassert(H5F_addr_defined(mesg->heap_addr)); - if(NULL == (heap = H5HL_protect(f, dxpl_id, mesg->heap_addr, H5AC_READ))) + if(NULL == (heap = H5HL_protect(f, dxpl_id, mesg->heap_addr, H5AC2_READ))) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, NULL, "unable to read protect link value") - s = H5HL_offset_into(f, heap, 0); + s = H5HL_offset_into(heap, 0); HDassert(s && !*s); - if(H5HL_unprotect(f, dxpl_id, heap, mesg->heap_addr) < 0) + if(H5HL_unprotect(heap) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, NULL, "unable to read unprotect link value") heap = NULL; #endif @@ -139,13 +139,13 @@ H5O_efl_decode(H5F_t *f, hid_t dxpl_id, unsigned UNUSED mesg_flags, if(NULL == mesg->slot) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") - if(NULL == (heap = H5HL_protect(f, dxpl_id, mesg->heap_addr, H5AC_READ))) + if(NULL == (heap = H5HL_protect(f, dxpl_id, mesg->heap_addr, H5AC2_READ))) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, NULL, "unable to read protect link value") for(u = 0; u < mesg->nused; u++) { /* Name */ H5F_DECODE_LENGTH (f, p, mesg->slot[u].name_offset); - s = H5HL_offset_into(f, heap, mesg->slot[u].name_offset); + s = H5HL_offset_into(heap, mesg->slot[u].name_offset); HDassert(s && *s); mesg->slot[u].name = H5MM_xstrdup (s); HDassert(mesg->slot[u].name); @@ -158,7 +158,7 @@ H5O_efl_decode(H5F_t *f, hid_t dxpl_id, unsigned UNUSED mesg_flags, HDassert(mesg->slot[u].size > 0); } /* end for */ - if(H5HL_unprotect(f, dxpl_id, heap, mesg->heap_addr) < 0) + if(H5HL_unprotect(heap) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, NULL, "unable to read unprotect link value") heap = NULL; @@ -450,7 +450,7 @@ H5O_efl_copy_file(H5F_t UNUSED *file_src, void *mesg_src, H5F_t *file_dst, HGOTO_ERROR(H5E_EFL, H5E_CANTINIT, NULL, "can't create heap") /* Pin the heap down in memory */ - if(NULL == (heap = H5HL_protect(file_dst, dxpl_id, efl_dst->heap_addr, H5AC_WRITE))) + if(NULL == (heap = H5HL_protect(file_dst, dxpl_id, efl_dst->heap_addr, H5AC2_WRITE))) HGOTO_ERROR(H5E_EFL, H5E_PROTECT, NULL, "unable to protect EFL file name heap") /* Insert "empty" name first */ @@ -481,7 +481,7 @@ H5O_efl_copy_file(H5F_t UNUSED *file_src, void *mesg_src, H5F_t *file_dst, done: /* Release resources */ - if(heap && H5HL_unprotect(file_dst, dxpl_id, heap, efl_dst->heap_addr) < 0) + if(heap && H5HL_unprotect(heap) < 0) HDONE_ERROR(H5E_EFL, H5E_PROTECT, NULL, "unable to unprotect EFL file name heap") if(!ret_value) if(efl_dst) diff --git a/src/Makefile.am b/src/Makefile.am index 8a77070..3f25918 100755 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -63,7 +63,9 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ H5HF.c H5HFbtree2.c H5HFcache.c H5HFdbg.c H5HFdblock.c H5HFdtable.c \ H5HFhdr.c H5HFhuge.c H5HFiblock.c H5HFiter.c H5HFman.c H5HFsection.c \ H5HFspace.c H5HFstat.c H5HFtest.c H5HFtiny.c \ - H5HG.c H5HGcache.c H5HGdbg.c H5HL.c H5HLdbg.c H5HP.c H5I.c H5L.c H5Lexternal.c \ + H5HG.c H5HGcache.c H5HGdbg.c \ + H5HL.c H5HLcache.c H5HLdbg.c H5HLint.c \ + H5HP.c H5I.c H5L.c H5Lexternal.c \ H5MF.c H5MM.c H5MP.c H5MPtest.c \ H5O.c H5Oainfo.c H5Oalloc.c H5Oattr.c \ H5Oattribute.c H5Obogus.c H5Obtreek.c H5Ocache.c H5Ochunk.c \ diff --git a/src/Makefile.in b/src/Makefile.in index cf79748..c8b8fb5 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -98,29 +98,30 @@ am_libhdf5_la_OBJECTS = H5.lo H5checksum.lo H5dbg.lo H5system.lo \ H5HFcache.lo H5HFdbg.lo H5HFdblock.lo H5HFdtable.lo H5HFhdr.lo \ H5HFhuge.lo H5HFiblock.lo H5HFiter.lo H5HFman.lo \ H5HFsection.lo H5HFspace.lo H5HFstat.lo H5HFtest.lo \ - H5HFtiny.lo H5HG.lo H5HGcache.lo H5HGdbg.lo H5HL.lo H5HLdbg.lo \ - H5HP.lo H5I.lo H5L.lo H5Lexternal.lo H5MF.lo H5MM.lo H5MP.lo \ - H5MPtest.lo H5O.lo H5Oainfo.lo H5Oalloc.lo H5Oattr.lo \ - H5Oattribute.lo H5Obogus.lo H5Obtreek.lo H5Ocache.lo \ - H5Ochunk.lo H5Ocont.lo H5Ocopy.lo H5Odbg.lo H5Odrvinfo.lo \ - H5Odtype.lo H5Oefl.lo H5Ofill.lo H5Oginfo.lo H5Olayout.lo \ - H5Olinfo.lo H5Olink.lo H5Omdj_msg.lo H5Omessage.lo H5Omtime.lo \ - H5Oname.lo H5Onull.lo H5Opline.lo H5Orefcount.lo H5Osdspace.lo \ - H5Oshared.lo H5Ostab.lo H5Oshmesg.lo H5Otest.lo H5Ounknown.lo \ - H5P.lo H5Pacpl.lo H5Pdcpl.lo H5Pdeprec.lo H5Pdxpl.lo \ - H5Pfapl.lo H5Pfcpl.lo H5Pfmpl.lo H5Pgcpl.lo H5Pint.lo \ - H5Plapl.lo H5Plcpl.lo H5Pocpl.lo H5Pocpypl.lo H5Pstrcpl.lo \ - H5Ptest.lo H5R.lo H5Rdeprec.lo H5RC.lo H5RS.lo H5S.lo \ - H5Sall.lo H5Sdbg.lo H5Shyper.lo H5Smpio.lo H5Snone.lo \ - H5Spoint.lo H5Sselect.lo H5Stest.lo H5SL.lo H5SM.lo \ - H5SMbtree2.lo H5SMcache.lo H5SMtest.lo H5ST.lo H5T.lo \ - H5Tarray.lo H5Tbit.lo H5Tcommit.lo H5Tcompound.lo H5Tconv.lo \ - H5Tcset.lo H5Tdbg.lo H5Tdeprec.lo H5Tenum.lo H5Tfields.lo \ - H5Tfixed.lo H5Tfloat.lo H5Tinit.lo H5Tnative.lo H5Toffset.lo \ - H5Toh.lo H5Topaque.lo H5Torder.lo H5Tpad.lo H5Tprecis.lo \ - H5Tstrpad.lo H5Tvisit.lo H5Tvlen.lo H5TS.lo H5V.lo H5WB.lo \ - H5Z.lo H5Zdeflate.lo H5Zfletcher32.lo H5Znbit.lo H5Zshuffle.lo \ - H5Zszip.lo H5Zscaleoffset.lo H5Ztrans.lo + H5HFtiny.lo H5HG.lo H5HGcache.lo H5HGdbg.lo H5HL.lo \ + H5HLcache.lo H5HLdbg.lo H5HLint.lo H5HP.lo H5I.lo H5L.lo \ + H5Lexternal.lo H5MF.lo H5MM.lo H5MP.lo H5MPtest.lo H5O.lo \ + H5Oainfo.lo H5Oalloc.lo H5Oattr.lo H5Oattribute.lo H5Obogus.lo \ + H5Obtreek.lo H5Ocache.lo H5Ochunk.lo H5Ocont.lo H5Ocopy.lo \ + H5Odbg.lo H5Odrvinfo.lo H5Odtype.lo H5Oefl.lo H5Ofill.lo \ + H5Oginfo.lo H5Olayout.lo H5Olinfo.lo H5Olink.lo H5Omdj_msg.lo \ + H5Omessage.lo H5Omtime.lo H5Oname.lo H5Onull.lo H5Opline.lo \ + H5Orefcount.lo H5Osdspace.lo H5Oshared.lo H5Ostab.lo \ + H5Oshmesg.lo H5Otest.lo H5Ounknown.lo H5P.lo H5Pacpl.lo \ + H5Pdcpl.lo H5Pdeprec.lo H5Pdxpl.lo H5Pfapl.lo H5Pfcpl.lo \ + H5Pfmpl.lo H5Pgcpl.lo H5Pint.lo H5Plapl.lo H5Plcpl.lo \ + H5Pocpl.lo H5Pocpypl.lo H5Pstrcpl.lo H5Ptest.lo H5R.lo \ + H5Rdeprec.lo H5RC.lo H5RS.lo H5S.lo H5Sall.lo H5Sdbg.lo \ + H5Shyper.lo H5Smpio.lo H5Snone.lo H5Spoint.lo H5Sselect.lo \ + H5Stest.lo H5SL.lo H5SM.lo H5SMbtree2.lo H5SMcache.lo \ + H5SMtest.lo H5ST.lo H5T.lo H5Tarray.lo H5Tbit.lo H5Tcommit.lo \ + H5Tcompound.lo H5Tconv.lo H5Tcset.lo H5Tdbg.lo H5Tdeprec.lo \ + H5Tenum.lo H5Tfields.lo H5Tfixed.lo H5Tfloat.lo H5Tinit.lo \ + H5Tnative.lo H5Toffset.lo H5Toh.lo H5Topaque.lo H5Torder.lo \ + H5Tpad.lo H5Tprecis.lo H5Tstrpad.lo H5Tvisit.lo H5Tvlen.lo \ + H5TS.lo H5V.lo H5WB.lo H5Z.lo H5Zdeflate.lo H5Zfletcher32.lo \ + H5Znbit.lo H5Zshuffle.lo H5Zszip.lo H5Zscaleoffset.lo \ + H5Ztrans.lo libhdf5_la_OBJECTS = $(am_libhdf5_la_OBJECTS) libhdf5_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ @@ -442,7 +443,9 @@ libhdf5_la_SOURCES = H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ H5HF.c H5HFbtree2.c H5HFcache.c H5HFdbg.c H5HFdblock.c H5HFdtable.c \ H5HFhdr.c H5HFhuge.c H5HFiblock.c H5HFiter.c H5HFman.c H5HFsection.c \ H5HFspace.c H5HFstat.c H5HFtest.c H5HFtiny.c \ - H5HG.c H5HGcache.c H5HGdbg.c H5HL.c H5HLdbg.c H5HP.c H5I.c H5L.c H5Lexternal.c \ + H5HG.c H5HGcache.c H5HGdbg.c \ + H5HL.c H5HLcache.c H5HLdbg.c H5HLint.c \ + H5HP.c H5I.c H5L.c H5Lexternal.c \ H5MF.c H5MM.c H5MP.c H5MPtest.c \ H5O.c H5Oainfo.c H5Oalloc.c H5Oattr.c \ H5Oattribute.c H5Obogus.c H5Obtreek.c H5Ocache.c H5Ochunk.c \ @@ -705,7 +708,9 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5HGcache.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5HGdbg.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5HL.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5HLcache.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5HLdbg.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5HLint.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5HP.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5I.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5L.Plo@am__quote@ diff --git a/test/lheap.c b/test/lheap.c index 537d42d..bf245d9 100644 --- a/test/lheap.c +++ b/test/lheap.c @@ -20,7 +20,7 @@ * Purpose: Test local heaps used by symbol tables (groups). */ #include "h5test.h" -#include "H5ACprivate.h" +#include "H5AC2private.h" #include "H5HLprivate.h" #include "H5Iprivate.h" @@ -76,7 +76,7 @@ main(void) h5_fixname(FILENAME[0], fapl, filename, sizeof filename); if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0) goto error; - if(NULL == (f = H5I_object(file))) { + if(NULL == (f = (H5F_t *)H5I_object(file))) { H5_FAILED(); H5Eprint2(H5E_DEFAULT, stdout); goto error; @@ -86,23 +86,25 @@ main(void) H5Eprint2(H5E_DEFAULT, stdout); goto error; } - if (NULL == (heap = H5HL_protect(f, H5P_DATASET_XFER_DEFAULT, heap_addr, H5AC_WRITE))) { + if (NULL == (heap = H5HL_protect(f, H5P_DATASET_XFER_DEFAULT, heap_addr, H5AC2_WRITE))) { H5_FAILED(); H5Eprint2(H5E_DEFAULT, stdout); goto error; } for(i = 0; i < NOBJS; i++) { sprintf(buf, "%03d-", i); - for (j=4; j4) buf[j] = '\0'; + for(j = 4; j < i; j++) + buf[j] = '0' + j % 10; + if(j > 4) + buf[j] = '\0'; - if ((size_t)(-1)==(obj[i]=H5HL_insert(f, H5P_DATASET_XFER_DEFAULT, heap, strlen(buf)+1, buf))) { + if((size_t)(-1) == (obj[i] = H5HL_insert(f, H5P_DATASET_XFER_DEFAULT, heap, strlen(buf) + 1, buf))) { H5_FAILED(); H5Eprint2(H5E_DEFAULT, stdout); goto error; } } - if (H5HL_unprotect(f, H5P_DATASET_XFER_DEFAULT, heap, heap_addr) < 0) { + if(H5HL_unprotect(heap) < 0) { H5_FAILED(); H5Eprint2(H5E_DEFAULT, stdout); goto error; @@ -116,24 +118,26 @@ main(void) TESTING("local heap read"); h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if ((file=H5Fopen(filename, H5F_ACC_RDONLY, fapl))<0) goto error; - if (NULL==(f=H5I_object(file))) { + if((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) goto error; + if(NULL == (f = (H5F_t *)H5I_object(file))) { H5_FAILED(); H5Eprint2(H5E_DEFAULT, stdout); goto error; } - for (i=0; i4) buf[j] = '\0'; + for(j = 4; j < i; j++) + buf[j] = '0' + j % 10; + if(j > 4) + buf[j] = '\0'; - if (NULL == (heap = H5HL_protect(f, H5P_DATASET_XFER_DEFAULT, heap_addr, H5AC_READ))) { + if (NULL == (heap = H5HL_protect(f, H5P_DATASET_XFER_DEFAULT, heap_addr, H5AC2_READ))) { H5_FAILED(); H5Eprint2(H5E_DEFAULT, stdout); goto error; } - if (NULL == (s = H5HL_offset_into(f, heap, obj[i]))) { + if (NULL == (s = (const char *)H5HL_offset_into(heap, obj[i]))) { H5_FAILED(); H5Eprint2(H5E_DEFAULT, stdout); goto error; @@ -147,7 +151,7 @@ main(void) goto error; } - if (H5HL_unprotect(f, H5P_DATASET_XFER_DEFAULT, heap, heap_addr) < 0) { + if(H5HL_unprotect(heap) < 0) { H5_FAILED(); H5Eprint2(H5E_DEFAULT, stdout); goto error; @@ -168,3 +172,4 @@ main(void) } H5E_END_TRY; return 1; } + -- cgit v0.12