From 191cc19ae0a2feb72d2171a0808fdc71a3b862dd Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Wed, 23 Nov 2016 16:45:47 -0500 Subject: Added vlen reclaim functions to a test in tfile.c that leaks memory. --- test/tfile.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test/tfile.c b/test/tfile.c index 833d2d9..d6cb427 100644 --- a/test/tfile.c +++ b/test/tfile.c @@ -2268,12 +2268,11 @@ test_file_double_file_dataset_open(hbool_t new_format) CHECK(ret, FAIL, "H5Dwrite"); /* Closing */ + /* (Leave sid1 open for later use) */ ret = H5Dclose(did1); CHECK(ret, FAIL, "H5Dclose"); ret = H5Tclose(tid1); CHECK(ret, FAIL, "H5Tclose"); - ret = H5Sclose(sid1); - CHECK(ret, FAIL, "H5Sclose"); ret = H5Pclose(dcpl); CHECK(ret, FAIL, "H5Dclose"); @@ -2392,6 +2391,8 @@ test_file_double_file_dataset_open(hbool_t new_format) HDmemset(buffer, 0, sizeof(char*) * 5); ret = H5Dread(did2, tid2, H5S_ALL, H5S_ALL, H5P_DEFAULT, buffer); CHECK(ret, FAIL, "H5Dread"); + ret = H5Dvlen_reclaim(tid2, sid1, H5P_DEFAULT, buffer); + CHECK(ret, FAIL, "H5Dvlen_reclaim"); /* Second file's dataset close */ ret = H5Dclose(did2); @@ -2404,6 +2405,9 @@ test_file_double_file_dataset_open(hbool_t new_format) /* First file's dataset read */ HDmemset(buffer, 0, sizeof(char*) * 5); ret = H5Dread(did1, tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, buffer); + CHECK(ret, FAIL, "H5Dread"); + ret = H5Dvlen_reclaim(tid2, sid1, H5P_DEFAULT, buffer); + CHECK(ret, FAIL, "H5Dvlen_reclaim"); /* First file's dataset close */ ret = H5Dclose(did1); @@ -2416,6 +2420,8 @@ test_file_double_file_dataset_open(hbool_t new_format) /* Closing */ ret = H5Tclose(tid1); CHECK(ret, FAIL, "H5Tclose"); + ret = H5Sclose(sid1); + CHECK(ret, FAIL, "H5Sclose"); ret = H5Tclose(tid2); CHECK(ret, FAIL, "H5Tclose"); -- cgit v0.12 From c9bbc2f1ccd0cb6403bf4221de46ef1e831d779c Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Fri, 25 Nov 2016 21:09:45 -0500 Subject: Added src/H5config.h.in~ to .gitignore. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 49b76e1..40c6a69 100644 --- a/.gitignore +++ b/.gitignore @@ -71,6 +71,7 @@ src/H5Einit.h src/H5Epubgen.h src/H5Eterm.h src/H5config.h.in +src/H5config.h.in~ src/H5overflow.h src/H5version.h src/Makefile.in -- cgit v0.12 From 1aa2373b2e1a651bec507dcb14a89b51815a972c Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Sun, 27 Nov 2016 16:05:03 -0500 Subject: Simplified .gitignore by using patterns. --- .gitignore | 113 ++++++++++--------------------------------------------------- 1 file changed, 18 insertions(+), 95 deletions(-) diff --git a/.gitignore b/.gitignore index 40c6a69..7424325 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,22 @@ -/Makefile.in +# .gitignore file for HDF5 + +# Makefile.in files +**/Makefile.in + +# Java .classes files +**/java/.classes + +# Backup files +# Editor-specific extensions should go in your ~/.gitconfig, but we +# include the standard Unix backup '~' extension since autoheader +# backs up H5config.h.in when it creates a new one and the +# extension is always '~'. +**/*~ + +# Other files, most of which are created by the Autotools though +# some are created by scripts in bin/ /aclocal.m4 /autom4te.cache -bin/Makefile.in bin/compile bin/config.guess bin/config.sub @@ -11,109 +26,17 @@ bin/ltmain.sh bin/missing bin/test-driver /build* -c++/Makefile.in -c++/examples/Makefile.in -c++/src/Makefile.in -c++/src/header_files/Makefile.in -c++/test/Makefile.in -config/Makefile.in -config/cmake/Makefile.in -config/cmake/UserMacros/Makefile.in -config/cmake/scripts/Makefile.in -config/cmake_ext_mod/Makefile.in -config/site-specific/Makefile.in /configure -examples/Makefile.in -fortran/Makefile.in -fortran/examples/Makefile.in -fortran/src/Makefile.in -fortran/test/Makefile.in -fortran/testpar/Makefile.in -hl/Makefile.in -hl/c++/Makefile.in -hl/c++/examples/Makefile.in -hl/c++/src/Makefile.in -hl/c++/test/Makefile.in -hl/examples/Makefile.in -hl/fortran/Makefile.in -hl/fortran/examples/Makefile.in -hl/fortran/src/Makefile.in -hl/fortran/test/Makefile.in -hl/src/Makefile.in -hl/test/Makefile.in -hl/tools/Makefile.in -hl/tools/gif2h5/Makefile.in -hl/tools/gif2h5/testfiles/Makefile.in -java/Makefile.in -java/examples/Makefile.in -java/examples/datasets/.classes -java/examples/datasets/Makefile.in -java/examples/datatypes/.classes -java/examples/datatypes/Makefile.in -java/examples/groups/.classes -java/examples/groups/Makefile.in -java/examples/intro/.classes -java/examples/intro/Makefile.in -java/src/.classes -java/src/Makefile.in -java/src/jni/Makefile.in -java/test/.classes -java/test/Makefile.in -m4/Makefile.in m4/libtool.m4 m4/ltoptions.m4 m4/ltsugar.m4 m4/ltversion.m4 m4/lt~obsolete.m4 -release_docs/Makefile.in src/H5Edefin.h src/H5Einit.h src/H5Epubgen.h src/H5Eterm.h src/H5config.h.in -src/H5config.h.in~ src/H5overflow.h src/H5version.h -src/Makefile.in -test/Makefile.in -test/testfiles/Makefile.in -test/testfiles/plist_files/Makefile.in -testpar/Makefile.in -tools/Makefile.in -tools/lib/Makefile.in -tools/src/Makefile.in -tools/test/Makefile.in -tools/testfiles/Makefile.in -tools/testfiles/pbits/Makefile.in -tools/testfiles/vds/Makefile.in -tools/src/h5copy/Makefile.in -tools/src/h5diff/Makefile.in -tools/src/h5dump/Makefile.in -tools/src/h5format_convert/Makefile.in -tools/src/h5import/Makefile.in -tools/src/h5jam/Makefile.in -tools/src/h5ls/Makefile.in -tools/src/h5repack/Makefile.in -tools/src/h5stat/Makefile.in -tools/src/misc/Makefile.in -tools/src/misc/vds/Makefile.in -tools/test/h5copy/Makefile.in -tools/test/h5copy/testfiles/Makefile.in -tools/test/h5diff/Makefile.in -tools/test/h5diff/testfiles/Makefile.in -tools/test/h5dump/Makefile.in -tools/test/h5dump/errfiles/Makefile.in -tools/test/h5format_convert/Makefile.in -tools/test/h5import/Makefile.in -tools/test/h5import/testfiles/Makefile.in -tools/test/h5jam/Makefile.in -tools/test/h5jam/testfiles/Makefile.in -tools/test/h5ls/Makefile.in -tools/test/h5repack/Makefile.in -tools/test/h5repack/testfiles/Makefile.in -tools/test/h5stat/Makefile.in -tools/test/h5stat/testfiles/Makefile.in -tools/test/misc/Makefile.in -tools/test/misc/testfiles/Makefile.in -tools/test/misc/vds/Makefile.in -tools/test/perform/Makefile.in + -- cgit v0.12 From 460b573a73e1cfa73ad16dc7fff286fd561ff735 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Sun, 27 Nov 2016 19:00:12 -0600 Subject: Eliminate unnecessary data structure for parallel collective metadata cache I/O --- src/H5C.c | 17 +---------------- src/H5Cmpio.c | 55 ++++++++++--------------------------------------------- src/H5Cpkg.h | 9 --------- testpar/t_cache.c | 1 - 4 files changed, 11 insertions(+), 71 deletions(-) diff --git a/src/H5C.c b/src/H5C.c index 31f887d..af2440c 100644 --- a/src/H5C.c +++ b/src/H5C.c @@ -216,9 +216,6 @@ H5FL_DEFINE_STATIC(H5C_t); /* Declare a free list to manage flush dependency arrays */ H5FL_BLK_DEFINE_STATIC(parent); -/* Declare extern free list to manage the H5C_collective_write_t struct */ -H5FL_EXTERN(H5C_collective_write_t); - /*------------------------------------------------------------------------- @@ -5859,20 +5856,8 @@ H5C__flush_single_entry(const H5F_t *f, hid_t dxpl_id, H5C_cache_entry_t *entry_ if(((entry_ptr->type->flags) & H5C__CLASS_SKIP_WRITES) == 0) { #ifdef H5_HAVE_PARALLEL if(collective_write_list) { - H5C_collective_write_t *item; - - if(NULL == (item = (H5C_collective_write_t *)H5FL_MALLOC(H5C_collective_write_t))) - HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "unable to allocate skip list item") - - item->length = entry_ptr->size; - item->free_buf = FALSE; - item->buf = entry_ptr->image_ptr; - item->offset = entry_ptr->addr; - - if(H5SL_insert(collective_write_list, item, &item->offset) < 0) { - H5MM_free(item); + if(H5SL_insert(collective_write_list, entry_ptr, &entry_ptr->addr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTINSERT, FAIL, "unable to insert skip list item") - } /* end if */ } /* end if */ else #endif /* H5_HAVE_PARALLEL */ diff --git a/src/H5Cmpio.c b/src/H5Cmpio.c index 72de4d0..0d666de 100644 --- a/src/H5Cmpio.c +++ b/src/H5Cmpio.c @@ -66,7 +66,6 @@ /********************/ static herr_t H5C__collective_write(H5F_t *f, hid_t dxpl_id, H5SL_t *collective_write_list); -static herr_t H5C__collective_write_free(void *_item, void *key, void *op_data); /*********************/ @@ -83,9 +82,6 @@ static herr_t H5C__collective_write_free(void *_item, void *key, void *op_data); /* Local Variables */ /*******************/ -/* Declare a free list to manage the H5C_collective_write_t struct */ -H5FL_DEFINE(H5C_collective_write_t); - /*------------------------------------------------------------------------- @@ -783,7 +779,7 @@ done: candidate_assignment_table = (int *)H5MM_xfree((void *)candidate_assignment_table); if(collective_write_list) - if(H5SL_destroy(collective_write_list, H5C__collective_write_free, NULL) < 0) + if(H5SL_close(collective_write_list) < 0) HDONE_ERROR(H5E_CACHE, H5E_CANTFREE, FAIL, "failed to destroy skip list") FUNC_LEAVE_NOAPI(ret_value) @@ -1382,7 +1378,7 @@ H5C__collective_write(H5F_t *f, hid_t dxpl_id, H5SL_t *collective_write_list) if(count > 0) { H5FD_mpio_xfer_t xfer_mode = H5FD_MPIO_COLLECTIVE; H5SL_node_t *node; - H5C_collective_write_t *item; + H5C_cache_entry_t *entry_ptr; void *base_buf; int i; @@ -1400,25 +1396,25 @@ H5C__collective_write(H5F_t *f, hid_t dxpl_id, H5SL_t *collective_write_list) /* Fill arrays */ node = H5SL_first(collective_write_list); HDassert(node); - if(NULL == (item = (H5C_collective_write_t *)H5SL_item(node))) + if(NULL == (entry_ptr = (H5C_cache_entry_t *)H5SL_item(node))) HGOTO_ERROR(H5E_CACHE, H5E_NOTFOUND, FAIL, "can't retrieve skip list item") /* Set up initial array position & buffer base address */ - length_array[0] = (int)item->length; - base_buf = item->buf; + length_array[0] = (int)entry_ptr->size; + base_buf = entry_ptr->image_ptr; buf_array[0] = (MPI_Aint)0; - offset_array[0] = (MPI_Aint)item->offset; + offset_array[0] = (MPI_Aint)entry_ptr->addr; node = H5SL_next(node); i = 1; while(node) { - if(NULL == (item = (H5C_collective_write_t *)H5SL_item(node))) + if(NULL == (entry_ptr = (H5C_cache_entry_t *)H5SL_item(node))) HGOTO_ERROR(H5E_CACHE, H5E_NOTFOUND, FAIL, "can't retrieve skip list item") /* Set up array position */ - length_array[i] = (int)item->length; - buf_array[i] = (MPI_Aint)item->buf - (MPI_Aint)base_buf; - offset_array[i] = (MPI_Aint)item->offset; + length_array[i] = (int)entry_ptr->size; + buf_array[i] = (MPI_Aint)entry_ptr->image_ptr - (MPI_Aint)base_buf; + offset_array[i] = (MPI_Aint)entry_ptr->addr; /* Advance to next node & array location */ node = H5SL_next(node); @@ -1491,36 +1487,5 @@ done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5C__collective_write() */ - - -/*------------------------------------------------------------------------- - * - * Function: H5C__collective_write_free - * - * Purpose: Release node on collective write skiplist - * - * Return: FAIL if error is detected, SUCCEED otherwise. - * - * Programmer: Mohamad Chaarawi - * February, 2016 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5C__collective_write_free(void *_item, void H5_ATTR_UNUSED *key, void H5_ATTR_UNUSED *op_data) -{ - H5C_collective_write_t *item = (H5C_collective_write_t *)_item; - - FUNC_ENTER_STATIC_NOERR - - /* Sanity check */ - HDassert(item); - - if(item->free_buf) - item->buf = H5MM_xfree(item->buf); - H5FL_FREE(H5C_collective_write_t, item); - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5C__collective_write_free() */ #endif /* H5_HAVE_PARALLEL */ diff --git a/src/H5Cpkg.h b/src/H5Cpkg.h index 78ae930..63c2c8b 100644 --- a/src/H5Cpkg.h +++ b/src/H5Cpkg.h @@ -4310,15 +4310,6 @@ struct H5C_t { char prefix[H5C__PREFIX_LEN]; }; -#ifdef H5_HAVE_PARALLEL -typedef struct H5C_collective_write_t { - size_t length; - hbool_t free_buf; - void *buf; - haddr_t offset; -} H5C_collective_write_t; -#endif /* H5_HAVE_PARALLEL */ - /* Define typedef for tagged cache entry iteration callbacks */ typedef int (*H5C_tag_iter_cb_t)(H5C_cache_entry_t *entry, void *ctx); diff --git a/testpar/t_cache.c b/testpar/t_cache.c index 0fa0096..ef89c8d 100644 --- a/testpar/t_cache.c +++ b/testpar/t_cache.c @@ -2522,7 +2522,6 @@ datum_serialize(const H5F_t *f, HDassert( aux_ptr ); HDassert( aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC ); -// HDassert( entry_ptr->aux_ptr == NULL ); entry_ptr->aux_ptr = aux_ptr; -- cgit v0.12 From 1a0de8ebd8f82f41b0fa0cb3d172c85a3a24bc3a Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Sun, 27 Nov 2016 20:50:13 -0500 Subject: Updated the format of H5AC/C_dump_cache() to include more information and be easier to read. --- src/H5ACprivate.h | 6 ++++- src/H5Cdbg.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 66 insertions(+), 13 deletions(-) diff --git a/src/H5ACprivate.h b/src/H5ACprivate.h index 2251af4..19d3657 100644 --- a/src/H5ACprivate.h +++ b/src/H5ACprivate.h @@ -57,7 +57,11 @@ #define H5AC_TAG_SIZE sizeof(haddr_t) #define H5AC_TAG_DEF (H5AC__INVALID_TAG) -/* Types of metadata objects cached */ +/* Types of metadata objects cached + * + * NOTE: If you add types to this enum, please update + * the list of types in type_names_g in H5Cdbg.c! + */ typedef enum { H5AC_BT_ID = 0, /* ( 0) B-tree nodes */ H5AC_SNODE_ID, /* ( 1) symbol table nodes */ diff --git a/src/H5Cdbg.c b/src/H5Cdbg.c index 3961aa4..10c1384 100644 --- a/src/H5Cdbg.c +++ b/src/H5Cdbg.c @@ -72,6 +72,40 @@ herr_t H5C_dump_cache_skip_list(H5C_t *cache_ptr, char *calling_fcn); /* Local Variables */ /*******************/ +/* Constant names for the dump cache function. + * Needs to be kept in sync with the H5AC_type_t enum in H5ACprivate.h! + */ +static const char *type_names_g[] = { + "(H5AC_BT_ID)", /* 0 */ + "(H5AC_SNODE_ID)", /* 1 */ + "(H5AC_LHEAP_PRFX_ID)", /* 2 */ + "(H5AC_LHEAP_DBLK_ID)", /* 3 */ + "(H5AC_GHEAP_ID)", /* 4 */ + "(H5AC_OHDR_ID)", /* 5 */ + "(H5AC_OHDR_CHK_ID)", /* 6 */ + "(H5AC_BT2_HDR_ID)", /* 7 */ + "(H5AC_BT2_INT_ID)", /* 8 */ + "(H5AC_BT2_LEAF_ID)", /* 9 */ + "(H5AC_FHEAP_HDR_ID)", /* 10 */ + "(H5AC_FHEAP_DBLOCK_ID)", /* 11 */ + "(H5AC_FHEAP_IBLOCK_ID)", /* 12 */ + "(H5AC_FSPACE_HDR_ID)", /* 13 */ + "(H5AC_FSPACE_SINFO_ID)", /* 14 */ + "(H5AC_SOHM_TABLE_ID)", /* 15 */ + "(H5AC_SOHM_LIST_ID)", /* 16 */ + "(H5AC_EARRAY_HDR_ID)", /* 17 */ + "(H5AC_EARRAY_IBLOCK_ID)", /* 18 */ + "(H5AC_EARRAY_SBLOCK_ID)", /* 19 */ + "(H5AC_EARRAY_DBLOCK_ID)", /* 20 */ + "(H5AC_EARRAY_DBLK_PAGE_ID)", /* 21 */ + "(H5AC_FARRAY_HDR_ID)", /* 22 */ + "(H5AC_FARRAY_DBLOCK_ID)", /* 23 */ + "(H5AC_FARRAY_DBLK_PAGE_ID)", /* 24 */ + "(H5AC_SUPERBLOCK_ID)", /* 25 */ + "(H5AC_DRVRINFO_ID)", /* 26 */ + "(H5AC_TEST_ID (BADNESS!))", /* 27 */ + "(H5AC_NTYPES (BADNESS!))" /* 28 */ +}; /*------------------------------------------------------------------------- @@ -126,24 +160,39 @@ H5C_dump_cache(H5C_t * cache_ptr, const char * cache_name) * skip list -- scan the skip list generating the desired output. */ - HDfprintf(stdout, "\n\nDump of metadata cache \"%s\".\n", cache_name); - HDfprintf(stdout, - "Num: Addr: Len: Type: Prot: Pinned: Dirty:\n"); + HDfprintf(stdout, "\n\nDump of metadata cache \"%s\"\n", cache_name); + + /* Print header */ + HDfprintf(stdout, "Entry "); + HDfprintf(stdout, "| Address "); + HDfprintf(stdout, "| Tag "); + HDfprintf(stdout, "| Len "); + HDfprintf(stdout, "| Ring "); + HDfprintf(stdout, "| Type "); + HDfprintf(stdout, "| Prot/Pin/Dirty"); + HDfprintf(stdout, "\n"); + + HDfprintf(stdout, "----------------------------------------------------------------------------------------------------------\n"); i = 0; entry_ptr = (H5C_cache_entry_t *)H5SL_remove_first(slist_ptr); while(entry_ptr != NULL) { HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - HDfprintf(stdout, - "%s%d 0x%16llx 0x%3llx %2d %d %d %d\n", - cache_ptr->prefix, i, - (long long)(entry_ptr->addr), - (long long)(entry_ptr->size), - (int)(entry_ptr->type->id), - (int)(entry_ptr->is_protected), - (int)(entry_ptr->is_pinned), - (int)(entry_ptr->is_dirty)); + /* Print entry */ + HDfprintf(stdout, "%s%5d ", cache_ptr->prefix, i); + HDfprintf(stdout, " 0x%16llx ", (long long)(entry_ptr->addr)); + if(NULL == entry_ptr->tag_info) + HDfprintf(stdout, " %16s ", "N/A"); + else + HDfprintf(stdout, " 0x%16llx ", (long long)(entry_ptr->tag_info->tag)); + HDfprintf(stdout, " %5lld ", (long long)(entry_ptr->size)); + HDfprintf(stdout, " %d ", (int)(entry_ptr->ring)); + HDfprintf(stdout, " %2d %-26s ", (int)(entry_ptr->type->id), type_names_g[(int)(entry_ptr->type->id)]); + HDfprintf(stdout, " %d", (int)(entry_ptr->is_protected)); + HDfprintf(stdout, " %d", (int)(entry_ptr->is_pinned)); + HDfprintf(stdout, " %d", (int)(entry_ptr->is_dirty)); + HDfprintf(stdout, "\n"); /* remove the next (first) item in the skip list */ entry_ptr = (H5C_cache_entry_t *)H5SL_remove_first(slist_ptr); -- cgit v0.12 From 2cb2d5a533c2de7503014da3250c3088e1ba089d Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Mon, 28 Nov 2016 01:26:33 -0600 Subject: Remove "collective write list" parameter from H5C__flush_single_entry() as it is only used in a couple of places. The collective write list has been moved to be internal to the cache data structure instead. --- src/H5C.c | 39 +++++++++++++++++---------------------- src/H5Cmpio.c | 53 ++++++++++++++++++++++++++++++++--------------------- src/H5Cpkg.h | 16 ++++++++++------ src/H5Ctag.c | 2 +- 4 files changed, 60 insertions(+), 50 deletions(-) diff --git a/src/H5C.c b/src/H5C.c index af2440c..e57dc81 100644 --- a/src/H5C.c +++ b/src/H5C.c @@ -366,6 +366,7 @@ H5C_create(size_t max_cache_size, cache_ptr->coll_list_size = (size_t)0; cache_ptr->coll_head_ptr = NULL; cache_ptr->coll_tail_ptr = NULL; + cache_ptr->coll_write_list = NULL; #endif /* H5_HAVE_PARALLEL */ cache_ptr->cLRU_list_len = 0; @@ -811,7 +812,7 @@ H5C_expunge_entry(H5F_t *f, hid_t dxpl_id, const H5C_class_t *type, /* Delete the entry from the skip list on destroy */ flush_flags |= H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG; - if(H5C__flush_single_entry(f, dxpl_id, entry_ptr, flush_flags, NULL) < 0) + if(H5C__flush_single_entry(f, dxpl_id, entry_ptr, flush_flags) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTEXPUNGE, FAIL, "can't flush entry") done: @@ -3111,7 +3112,7 @@ H5C_unprotect(H5F_t * f, /* Delete the entry from the skip list on destroy */ flush_flags |= H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG; - if(H5C__flush_single_entry(f, dxpl_id, entry_ptr, flush_flags, NULL) < 0) + if(H5C__flush_single_entry(f, dxpl_id, entry_ptr, flush_flags) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "Can't flush entry") } @@ -3125,7 +3126,7 @@ H5C_unprotect(H5F_t * f, else if(test_entry_ptr != entry_ptr) HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "hash table contains multiple entries for addr?!?.") - if(H5C__flush_single_entry(f, dxpl_id, entry_ptr, H5C__FLUSH_CLEAR_ONLY_FLAG | H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG, NULL) < 0) + if(H5C__flush_single_entry(f, dxpl_id, entry_ptr, H5C__FLUSH_CLEAR_ONLY_FLAG | H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "Can't clear entry") } #endif /* H5_HAVE_PARALLEL */ @@ -4318,7 +4319,7 @@ H5C__autoadjust__ageout__evict_aged_out_entries(H5F_t * f, cache_ptr->entries_removed_counter = 0; cache_ptr->last_entry_removed_ptr = NULL; - if(H5C__flush_single_entry(f, dxpl_id, entry_ptr, H5C__NO_FLAGS_SET, NULL) < 0) + if(H5C__flush_single_entry(f, dxpl_id, entry_ptr, H5C__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush entry") if(cache_ptr->entries_removed_counter > 1 || cache_ptr->last_entry_removed_ptr == prev_ptr) @@ -4329,7 +4330,7 @@ H5C__autoadjust__ageout__evict_aged_out_entries(H5F_t * f, bytes_evicted += entry_ptr->size; - if(H5C__flush_single_entry(f, dxpl_id, entry_ptr, H5C__FLUSH_INVALIDATE_FLAG | H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG, NULL) < 0 ) + if(H5C__flush_single_entry(f, dxpl_id, entry_ptr, H5C__FLUSH_INVALIDATE_FLAG | H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG) < 0 ) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush entry") } @@ -4412,7 +4413,7 @@ H5C__autoadjust__ageout__evict_aged_out_entries(H5F_t * f, prev_ptr = entry_ptr->prev; if ( ! (entry_ptr->is_dirty) ) { - if(H5C__flush_single_entry(f, dxpl_id, entry_ptr, H5C__FLUSH_INVALIDATE_FLAG | H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG, NULL) < 0) + if(H5C__flush_single_entry(f, dxpl_id, entry_ptr, H5C__FLUSH_INVALIDATE_FLAG | H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush clean entry") } /* just skip the entry if it is dirty, as we can't do @@ -5209,7 +5210,7 @@ H5C_flush_invalidate_ring(const H5F_t * f, hid_t dxpl_id, H5C_ring_t ring, */ protected_entries++; } else if(entry_ptr->is_pinned) { - if(H5C__flush_single_entry(f, dxpl_id, entry_ptr, H5C__DURING_FLUSH_FLAG, NULL) < 0) + if(H5C__flush_single_entry(f, dxpl_id, entry_ptr, H5C__DURING_FLUSH_FLAG) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "dirty pinned entry flush failed.") if(cache_ptr->slist_changed) { @@ -5226,8 +5227,7 @@ H5C_flush_invalidate_ring(const H5F_t * f, hid_t dxpl_id, H5C_ring_t ring, } /* end if */ } /* end if */ else { - if(H5C__flush_single_entry(f, dxpl_id, entry_ptr, - (cooked_flags | H5C__DURING_FLUSH_FLAG | H5C__FLUSH_INVALIDATE_FLAG | H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG), NULL) < 0) + if(H5C__flush_single_entry(f, dxpl_id, entry_ptr, (cooked_flags | H5C__DURING_FLUSH_FLAG | H5C__FLUSH_INVALIDATE_FLAG | H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG)) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "dirty entry flush destroy failed.") if(cache_ptr->slist_changed) { @@ -5324,8 +5324,7 @@ H5C_flush_invalidate_ring(const H5F_t * f, hid_t dxpl_id, H5C_ring_t ring, * or three entries. */ cache_ptr->entry_watched_for_removal = next_entry_ptr; - if(H5C__flush_single_entry(f, dxpl_id, entry_ptr, - (cooked_flags | H5C__DURING_FLUSH_FLAG | H5C__FLUSH_INVALIDATE_FLAG | H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG), NULL) < 0) + if(H5C__flush_single_entry(f, dxpl_id, entry_ptr, (cooked_flags | H5C__DURING_FLUSH_FLAG | H5C__FLUSH_INVALIDATE_FLAG | H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG)) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Entry flush destroy failed.") /* Check for the next entry getting removed */ @@ -5613,7 +5612,7 @@ H5C_flush_ring(H5F_t *f, hid_t dxpl_id, H5C_ring_t ring, unsigned flags) protected_entries++; } /* end if */ else { - if(H5C__flush_single_entry(f, dxpl_id, entry_ptr, (flags | H5C__DURING_FLUSH_FLAG), NULL) < 0) + if(H5C__flush_single_entry(f, dxpl_id, entry_ptr, (flags | H5C__DURING_FLUSH_FLAG)) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't flush entry.") if(cache_ptr->slist_changed) { @@ -5721,11 +5720,7 @@ done: */ herr_t H5C__flush_single_entry(const H5F_t *f, hid_t dxpl_id, H5C_cache_entry_t *entry_ptr, - unsigned flags, H5SL_t -#ifndef H5_HAVE_PARALLEL - H5_ATTR_UNUSED -#endif /* NDEBUG */ - *collective_write_list) + unsigned flags) { H5C_t * cache_ptr; /* Cache for file */ hbool_t destroy; /* external flag */ @@ -5855,8 +5850,8 @@ H5C__flush_single_entry(const H5F_t *f, hid_t dxpl_id, H5C_cache_entry_t *entry_ if(((entry_ptr->type->flags) & H5C__CLASS_SKIP_WRITES) == 0) { #ifdef H5_HAVE_PARALLEL - if(collective_write_list) { - if(H5SL_insert(collective_write_list, entry_ptr, &entry_ptr->addr) < 0) + if(cache_ptr->coll_write_list) { + if(H5SL_insert(cache_ptr->coll_write_list, entry_ptr, &entry_ptr->addr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTINSERT, FAIL, "unable to insert skip list item") } /* end if */ else @@ -6679,7 +6674,7 @@ H5C_make_space_in_cache(H5F_t * f, } /* end if */ #endif - if(H5C__flush_single_entry(f, dxpl_id, entry_ptr, H5C__NO_FLAGS_SET, NULL) < 0) + if(H5C__flush_single_entry(f, dxpl_id, entry_ptr, H5C__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush entry") if ( ( cache_ptr->entries_removed_counter > 1 ) || @@ -6696,7 +6691,7 @@ H5C_make_space_in_cache(H5F_t * f, cache_ptr->entries_scanned_to_make_space++; #endif /* H5C_COLLECT_CACHE_STATS */ - if(H5C__flush_single_entry(f, dxpl_id, entry_ptr, H5C__FLUSH_INVALIDATE_FLAG | H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG, NULL) < 0) + if(H5C__flush_single_entry(f, dxpl_id, entry_ptr, H5C__FLUSH_INVALIDATE_FLAG | H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush entry") } else { /* We have enough space so don't flush clean entry. */ @@ -6837,7 +6832,7 @@ H5C_make_space_in_cache(H5F_t * f, #ifdef H5_HAVE_PARALLEL if(!(entry_ptr->coll_access)) { #endif /* H5_HAVE_PARALLEL */ - if(H5C__flush_single_entry(f, dxpl_id, entry_ptr, H5C__FLUSH_INVALIDATE_FLAG | H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG, NULL) < 0) + if(H5C__flush_single_entry(f, dxpl_id, entry_ptr, H5C__FLUSH_INVALIDATE_FLAG | H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush entry") #ifdef H5_HAVE_PARALLEL } /* end if */ diff --git a/src/H5Cmpio.c b/src/H5Cmpio.c index 0d666de..ab94879 100644 --- a/src/H5Cmpio.c +++ b/src/H5Cmpio.c @@ -64,8 +64,7 @@ /********************/ /* Local Prototypes */ /********************/ -static herr_t H5C__collective_write(H5F_t *f, hid_t dxpl_id, - H5SL_t *collective_write_list); +static herr_t H5C__collective_write(H5F_t *f, hid_t dxpl_id); /*********************/ @@ -226,7 +225,6 @@ H5C_apply_candidate_list(H5F_t * f, H5C_cache_entry_t * entry_ptr = NULL; H5C_cache_entry_t * flush_ptr = NULL; H5C_cache_entry_t * delayed_ptr = NULL; - H5SL_t * collective_write_list = NULL; #if H5C_DO_SANITY_CHECKS haddr_t last_addr; #endif /* H5C_DO_SANITY_CHECKS */ @@ -260,8 +258,11 @@ H5C_apply_candidate_list(H5F_t * f, #endif /* H5C_APPLY_CANDIDATE_LIST__DEBUG */ if(f->coll_md_write) { + /* Sanity check */ + HDassert(NULL == cache_ptr->coll_write_list); + /* Create skip list of entries for collective write */ - if(NULL == (collective_write_list = H5SL_create(H5SL_TYPE_HADDR, NULL))) + if(NULL == (cache_ptr->coll_write_list = H5SL_create(H5SL_TYPE_HADDR, NULL))) HGOTO_ERROR(H5E_DATASET, H5E_CANTCREATE, FAIL, "can't create skip list for entries") } /* end if */ @@ -475,7 +476,7 @@ H5C_apply_candidate_list(H5F_t * f, cache_ptr->entries_removed_counter = 0; cache_ptr->last_entry_removed_ptr = NULL; - if(H5C__flush_single_entry(f, dxpl_id, clear_ptr, H5C__FLUSH_CLEAR_ONLY_FLAG | H5C__GENERATE_IMAGE_FLAG | H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG, NULL) < 0) + if(H5C__flush_single_entry(f, dxpl_id, clear_ptr, H5C__FLUSH_CLEAR_ONLY_FLAG | H5C__GENERATE_IMAGE_FLAG | H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't clear entry.") if((cache_ptr->entries_removed_counter > 1) || @@ -525,7 +526,7 @@ H5C_apply_candidate_list(H5F_t * f, cache_ptr->last_entry_removed_ptr = NULL; /* Add this entry to the list of entries to collectively write */ - if(H5C__flush_single_entry(f, dxpl_id, flush_ptr, H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG, collective_write_list) < 0) + if(H5C__flush_single_entry(f, dxpl_id, flush_ptr, H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't flush entry.") if((cache_ptr->entries_removed_counter > 1) || @@ -681,7 +682,7 @@ H5C_apply_candidate_list(H5F_t * f, (long long)clear_ptr->addr); #endif /* H5C_APPLY_CANDIDATE_LIST__DEBUG */ - if(H5C__flush_single_entry(f, dxpl_id, clear_ptr, H5C__FLUSH_CLEAR_ONLY_FLAG | H5C__GENERATE_IMAGE_FLAG | H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG, NULL) < 0) + if(H5C__flush_single_entry(f, dxpl_id, clear_ptr, H5C__FLUSH_CLEAR_ONLY_FLAG | H5C__GENERATE_IMAGE_FLAG | H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't clear entry.") } /* end else-if */ @@ -698,7 +699,7 @@ H5C_apply_candidate_list(H5F_t * f, #endif /* H5C_APPLY_CANDIDATE_LIST__DEBUG */ /* Add this entry to the list of entries to collectively write */ - if(H5C__flush_single_entry(f, dxpl_id, flush_ptr, H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG, collective_write_list) < 0) + if(H5C__flush_single_entry(f, dxpl_id, flush_ptr, H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't clear entry.") } /* end else-if */ } /* end if */ @@ -732,14 +733,14 @@ H5C_apply_candidate_list(H5F_t * f, if (delayed_ptr) { if (delayed_ptr->clear_on_unprotect) { - if(H5C__flush_single_entry(f, dxpl_id, delayed_ptr, H5C__FLUSH_CLEAR_ONLY_FLAG | H5C__GENERATE_IMAGE_FLAG, NULL) < 0) + if(H5C__flush_single_entry(f, dxpl_id, delayed_ptr, H5C__FLUSH_CLEAR_ONLY_FLAG | H5C__GENERATE_IMAGE_FLAG) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't flush entry.") entry_ptr->clear_on_unprotect = FALSE; entries_cleared++; } else if (delayed_ptr->flush_immediately) { /* Add this entry to the list of entries to collectively write */ - if(H5C__flush_single_entry(f, dxpl_id, delayed_ptr, H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG, collective_write_list) < 0) + if(H5C__flush_single_entry(f, dxpl_id, delayed_ptr, H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't flush entry collectively.") entry_ptr->flush_immediately = FALSE; @@ -752,10 +753,11 @@ H5C_apply_candidate_list(H5F_t * f, /* If we've deferred writing to do it collectively, take care of that now */ if(f->coll_md_write) { - HDassert(collective_write_list); + /* Sanity check */ + HDassert(cache_ptr->coll_write_list); /* Write collective list */ - if(H5C__collective_write(f, dxpl_id, collective_write_list) < 0) + if(H5C__collective_write(f, dxpl_id) < 0) HGOTO_ERROR(H5E_CACHE, H5E_WRITEERROR, FAIL, "Can't write metadata collectively") } /* end if */ @@ -778,9 +780,11 @@ done: if(candidate_assignment_table != NULL) candidate_assignment_table = (int *)H5MM_xfree((void *)candidate_assignment_table); - if(collective_write_list) - if(H5SL_close(collective_write_list) < 0) + if(cache_ptr->coll_write_list) { + if(H5SL_close(cache_ptr->coll_write_list) < 0) HDONE_ERROR(H5E_CACHE, H5E_CANTFREE, FAIL, "failed to destroy skip list") + cache_ptr->coll_write_list = NULL; + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* H5C_apply_candidate_list() */ @@ -1019,7 +1023,7 @@ done: * * Note that unlike H5C_apply_candidate_list(), * H5C_mark_entries_as_clean() makes all its calls to - * H6C_flush_single_entry() with the + * H5C__flush_single_entry() with the * H5C__FLUSH_CLEAR_ONLY_FLAG set. As a result, * the pre_serialize() and serialize calls are not made. * @@ -1178,7 +1182,7 @@ H5C_mark_entries_as_clean(H5F_t * f, * * Note that unlike H5C_apply_candidate_list(), * H5C_mark_entries_as_clean() makes all its calls to - * H6C_flush_single_entry() with the H5C__FLUSH_CLEAR_ONLY_FLAG + * H5C__flush_single_entry() with the H5C__FLUSH_CLEAR_ONLY_FLAG * set. As a result, the pre_serialize() and serialize calls are * not made. * @@ -1213,7 +1217,7 @@ H5C_mark_entries_as_clean(H5F_t * f, entry_ptr = entry_ptr->prev; entries_cleared++; - if(H5C__flush_single_entry(f, dxpl_id, clear_ptr, H5C__FLUSH_CLEAR_ONLY_FLAG | H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG, NULL) < 0) + if(H5C__flush_single_entry(f, dxpl_id, clear_ptr, H5C__FLUSH_CLEAR_ONLY_FLAG | H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't clear entry.") } else { @@ -1241,7 +1245,7 @@ H5C_mark_entries_as_clean(H5F_t * f, entry_ptr = entry_ptr->next; entries_cleared++; - if(H5C__flush_single_entry(f, dxpl_id, clear_ptr, H5C__FLUSH_CLEAR_ONLY_FLAG | H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG, NULL) < 0 ) + if(H5C__flush_single_entry(f, dxpl_id, clear_ptr, H5C__FLUSH_CLEAR_ONLY_FLAG | H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG) < 0 ) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't clear entry.") } else { @@ -1349,8 +1353,9 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5C__collective_write(H5F_t *f, hid_t dxpl_id, H5SL_t *collective_write_list) +H5C__collective_write(H5F_t *f, hid_t dxpl_id) { + H5AC_t *cache_ptr; H5P_genplist_t *plist = NULL; H5FD_mpio_xfer_t orig_xfer_mode = H5FD_MPIO_COLLECTIVE; int count; @@ -1366,6 +1371,12 @@ H5C__collective_write(H5F_t *f, hid_t dxpl_id, H5SL_t *collective_write_list) FUNC_ENTER_STATIC + /* Sanity checks */ + HDassert(f != NULL); + cache_ptr = f->shared->cache; + HDassert(cache_ptr != NULL); + HDassert(cache_ptr->coll_write_list != NULL); + /* Get original transfer mode */ if(NULL == (plist = (H5P_genplist_t *)H5I_object(dxpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data transfer property list") @@ -1373,7 +1384,7 @@ H5C__collective_write(H5F_t *f, hid_t dxpl_id, H5SL_t *collective_write_list) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set MPI-I/O property") /* Get number of entries in collective write list */ - count = (int)H5SL_count(collective_write_list); + count = (int)H5SL_count(cache_ptr->coll_write_list); if(count > 0) { H5FD_mpio_xfer_t xfer_mode = H5FD_MPIO_COLLECTIVE; @@ -1394,7 +1405,7 @@ H5C__collective_write(H5F_t *f, hid_t dxpl_id, H5SL_t *collective_write_list) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "memory allocation failed for collective offset table length array") /* Fill arrays */ - node = H5SL_first(collective_write_list); + node = H5SL_first(cache_ptr->coll_write_list); HDassert(node); if(NULL == (entry_ptr = (H5C_cache_entry_t *)H5SL_item(node))) HGOTO_ERROR(H5E_CACHE, H5E_NOTFOUND, FAIL, "can't retrieve skip list item") diff --git a/src/H5Cpkg.h b/src/H5Cpkg.h index 63c2c8b..16efb5c 100644 --- a/src/H5Cpkg.h +++ b/src/H5Cpkg.h @@ -3430,7 +3430,7 @@ typedef struct H5C_tag_info_t { * entry is removed from the cache by any means (eviction, * expungement, or take ownership at this point in time). * Functions that perform scans on lists may set this field - * to zero prior to calling H5C_flush_single_entry(). + * to zero prior to calling H5C__flush_single_entry(). * Unexpected changes to the counter indicate that an entry * was removed from the cache as a side effect of the flush. * @@ -3438,7 +3438,7 @@ typedef struct H5C_tag_info_t { * which contained the last entry to be removed from the cache, * or NULL if there either is no such entry, or if a function * performing a scan of a list has set this field to NULL prior - * to calling H5C_flush_single_entry(). + * to calling H5C__flush_single_entry(). * * WARNING!!! This field must NEVER be dereferenced. It is * maintained to allow functions that perform scans of lists @@ -4069,17 +4069,17 @@ typedef struct H5C_tag_info_t { * obtain estimates of how frequently these restarts occur. * * slist_scan_restarts: Number of times a scan of the slist (that contains - * calls to H5C_flush_single_entry()) has been restarted to + * calls to H5C__flush_single_entry()) has been restarted to * avoid potential issues with change of status of the next * entry in the scan. * * LRU_scan_restarts: Number of times a scan of the LRU list (that contains - * calls to H5C_flush_single_entry()) has been restarted to + * calls to H5C__flush_single_entry()) has been restarted to * avoid potential issues with change of status of the next * entry in the scan. * * hash_bucket_scan_restarts: Number of times a scan of a hash bucket list - * (that contains calls to H5C_flush_single_entry()) has been + * (that contains calls to H5C__flush_single_entry()) has been * restarted to avoid potential issues with change of status * of the next entry in the scan. * @@ -4205,10 +4205,14 @@ struct H5C_t { H5C_cache_entry_t * dLRU_tail_ptr; #ifdef H5_HAVE_PARALLEL + /* Fields for collective metadata reads */ int32_t coll_list_len; size_t coll_list_size; H5C_cache_entry_t * coll_head_ptr; H5C_cache_entry_t * coll_tail_ptr; + + /* Fields for collective metadata writes */ + H5SL_t * coll_write_list; #endif /* H5_HAVE_PARALLEL */ /* Fields for automatic cache size adjustment */ @@ -4328,7 +4332,7 @@ H5_DLLVAR const H5C_class_t H5C__epoch_marker_class; /* General routines */ H5_DLL herr_t H5C__flush_single_entry(const H5F_t *f, hid_t dxpl_id, - H5C_cache_entry_t *entry_ptr, unsigned flags, H5SL_t *collective_write_list); + H5C_cache_entry_t *entry_ptr, unsigned flags); H5_DLL herr_t H5C__flush_marked_entries(H5F_t * f, hid_t dxpl_id); H5_DLL herr_t H5C__iter_tagged_entries(H5C_t *cache, haddr_t tag, hbool_t match_global, H5C_tag_iter_cb_t cb, void *cb_ctx); diff --git a/src/H5Ctag.c b/src/H5Ctag.c index 33f7c22..6d5b454 100644 --- a/src/H5Ctag.c +++ b/src/H5Ctag.c @@ -467,7 +467,7 @@ H5C__evict_tagged_entries_cb(H5C_cache_entry_t *entry, void *_ctx) ctx->pinned_entries_need_evicted = TRUE; else { /* Evict the Entry */ - if(H5C__flush_single_entry(ctx->f, ctx->dxpl_id, entry, H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG | H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG, NULL) < 0) + if(H5C__flush_single_entry(ctx->f, ctx->dxpl_id, entry, H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG | H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, H5_ITER_ERROR, "Entry eviction failed.") ctx->evicted_entries_last_pass = TRUE; } /* end else */ -- cgit v0.12 From 7a8c7c6063e328fdac28aa3f77ead4bdc91860e5 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Mon, 28 Nov 2016 12:47:59 -0500 Subject: Updated the cache dump to use the stored type name instead of the (redundant) array of names I previously created. --- src/H5ACprivate.h | 6 +----- src/H5Cdbg.c | 42 ++++-------------------------------------- 2 files changed, 5 insertions(+), 43 deletions(-) diff --git a/src/H5ACprivate.h b/src/H5ACprivate.h index 19d3657..2251af4 100644 --- a/src/H5ACprivate.h +++ b/src/H5ACprivate.h @@ -57,11 +57,7 @@ #define H5AC_TAG_SIZE sizeof(haddr_t) #define H5AC_TAG_DEF (H5AC__INVALID_TAG) -/* Types of metadata objects cached - * - * NOTE: If you add types to this enum, please update - * the list of types in type_names_g in H5Cdbg.c! - */ +/* Types of metadata objects cached */ typedef enum { H5AC_BT_ID = 0, /* ( 0) B-tree nodes */ H5AC_SNODE_ID, /* ( 1) symbol table nodes */ diff --git a/src/H5Cdbg.c b/src/H5Cdbg.c index 10c1384..16077c8 100644 --- a/src/H5Cdbg.c +++ b/src/H5Cdbg.c @@ -72,40 +72,6 @@ herr_t H5C_dump_cache_skip_list(H5C_t *cache_ptr, char *calling_fcn); /* Local Variables */ /*******************/ -/* Constant names for the dump cache function. - * Needs to be kept in sync with the H5AC_type_t enum in H5ACprivate.h! - */ -static const char *type_names_g[] = { - "(H5AC_BT_ID)", /* 0 */ - "(H5AC_SNODE_ID)", /* 1 */ - "(H5AC_LHEAP_PRFX_ID)", /* 2 */ - "(H5AC_LHEAP_DBLK_ID)", /* 3 */ - "(H5AC_GHEAP_ID)", /* 4 */ - "(H5AC_OHDR_ID)", /* 5 */ - "(H5AC_OHDR_CHK_ID)", /* 6 */ - "(H5AC_BT2_HDR_ID)", /* 7 */ - "(H5AC_BT2_INT_ID)", /* 8 */ - "(H5AC_BT2_LEAF_ID)", /* 9 */ - "(H5AC_FHEAP_HDR_ID)", /* 10 */ - "(H5AC_FHEAP_DBLOCK_ID)", /* 11 */ - "(H5AC_FHEAP_IBLOCK_ID)", /* 12 */ - "(H5AC_FSPACE_HDR_ID)", /* 13 */ - "(H5AC_FSPACE_SINFO_ID)", /* 14 */ - "(H5AC_SOHM_TABLE_ID)", /* 15 */ - "(H5AC_SOHM_LIST_ID)", /* 16 */ - "(H5AC_EARRAY_HDR_ID)", /* 17 */ - "(H5AC_EARRAY_IBLOCK_ID)", /* 18 */ - "(H5AC_EARRAY_SBLOCK_ID)", /* 19 */ - "(H5AC_EARRAY_DBLOCK_ID)", /* 20 */ - "(H5AC_EARRAY_DBLK_PAGE_ID)", /* 21 */ - "(H5AC_FARRAY_HDR_ID)", /* 22 */ - "(H5AC_FARRAY_DBLOCK_ID)", /* 23 */ - "(H5AC_FARRAY_DBLK_PAGE_ID)", /* 24 */ - "(H5AC_SUPERBLOCK_ID)", /* 25 */ - "(H5AC_DRVRINFO_ID)", /* 26 */ - "(H5AC_TEST_ID (BADNESS!))", /* 27 */ - "(H5AC_NTYPES (BADNESS!))" /* 28 */ -}; /*------------------------------------------------------------------------- @@ -166,13 +132,13 @@ H5C_dump_cache(H5C_t * cache_ptr, const char * cache_name) HDfprintf(stdout, "Entry "); HDfprintf(stdout, "| Address "); HDfprintf(stdout, "| Tag "); - HDfprintf(stdout, "| Len "); + HDfprintf(stdout, "| Size "); HDfprintf(stdout, "| Ring "); - HDfprintf(stdout, "| Type "); + HDfprintf(stdout, "| Type "); HDfprintf(stdout, "| Prot/Pin/Dirty"); HDfprintf(stdout, "\n"); - HDfprintf(stdout, "----------------------------------------------------------------------------------------------------------\n"); + HDfprintf(stdout, "----------------------------------------------------------------------------------------------------------------\n"); i = 0; entry_ptr = (H5C_cache_entry_t *)H5SL_remove_first(slist_ptr); @@ -188,7 +154,7 @@ H5C_dump_cache(H5C_t * cache_ptr, const char * cache_name) HDfprintf(stdout, " 0x%16llx ", (long long)(entry_ptr->tag_info->tag)); HDfprintf(stdout, " %5lld ", (long long)(entry_ptr->size)); HDfprintf(stdout, " %d ", (int)(entry_ptr->ring)); - HDfprintf(stdout, " %2d %-26s ", (int)(entry_ptr->type->id), type_names_g[(int)(entry_ptr->type->id)]); + HDfprintf(stdout, " %2d %-32s ", (int)(entry_ptr->type->id), (entry_ptr->type->name)); HDfprintf(stdout, " %d", (int)(entry_ptr->is_protected)); HDfprintf(stdout, " %d", (int)(entry_ptr->is_pinned)); HDfprintf(stdout, " %d", (int)(entry_ptr->is_dirty)); -- cgit v0.12 From b092dbcdfdfc7477596ae49f816f18e0dadf0fb1 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Mon, 28 Nov 2016 16:34:36 -0800 Subject: Bring over another batch (hopefully the last) of non-SWMR "normalization" changes from the revise_chunks branch. --- src/H5B2.c | 4 +- src/H5B2int.c | 2 +- src/H5B2pkg.h | 4 +- src/H5Dchunk.c | 1 - src/H5EA.c | 199 +++++++++++++++++++++++++++--------------------- src/H5EAcache.c | 19 ++++- src/H5F.c | 97 ++++++++++++++++++++++++ src/H5FA.c | 210 ++++++++++++++++++++++++++++----------------------- src/H5FAhdr.c | 2 + src/H5FDcore.c | 43 +++++++---- src/H5FDfamily.c | 47 ++++++------ src/H5FDlog.c | 50 ++++++------ src/H5FDsec2.c | 34 +++++---- src/H5FDstdio.c | 49 +++++++----- src/H5Fint.c | 103 +++++++++++++++---------- src/H5Zscaleoffset.c | 52 ------------- test/ohdr.c | 3 +- 17 files changed, 550 insertions(+), 369 deletions(-) diff --git a/src/H5B2.c b/src/H5B2.c index bce6a9f..af5fae7 100644 --- a/src/H5B2.c +++ b/src/H5B2.c @@ -343,11 +343,11 @@ H5B2_update(H5B2_t *bt2, hid_t dxpl_id, void *udata, H5B2_modify_t op, void *op_ /* Attempt to insert record into B-tree */ if(hdr->depth > 0) { if(H5B2__update_internal(hdr, dxpl_id, hdr->depth, NULL, &hdr->root, &status, H5B2_POS_ROOT, udata, op, op_data) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, FAIL, "unable to update record in B-tree internal node") + HGOTO_ERROR(H5E_BTREE, H5E_CANTUPDATE, FAIL, "unable to update record in B-tree internal node") } /* end if */ else { if(H5B2__update_leaf(hdr, dxpl_id, &hdr->root, &status, H5B2_POS_ROOT, udata, op, op_data) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, FAIL, "unable to update record in B-tree leaf node") + HGOTO_ERROR(H5E_BTREE, H5E_CANTUPDATE, FAIL, "unable to update record in B-tree leaf node") } /* end else */ /* Sanity check */ diff --git a/src/H5B2int.c b/src/H5B2int.c index 3bd788c..a8fa59f 100644 --- a/src/H5B2int.c +++ b/src/H5B2int.c @@ -1925,7 +1925,7 @@ H5B2__update_leaf(H5B2_hdr_t *hdr, hid_t dxpl_id, H5B2_node_ptr_t *curr_node_ptr if((hdr->cls->store)(H5B2_LEAF_NREC(leaf, hdr, idx), udata) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, FAIL, "unable to insert record into leaf node") - /* Mark the node as dirty if it changed */ + /* Mark the node as dirty */ leaf_flags |= H5AC__DIRTIED_FLAG; /* Indicate that the record was inserted */ diff --git a/src/H5B2pkg.h b/src/H5B2pkg.h index edac296..6a385d4 100644 --- a/src/H5B2pkg.h +++ b/src/H5B2pkg.h @@ -261,8 +261,8 @@ typedef struct H5B2_leaf_cache_ud_t { #ifdef H5B2_TESTING /* Node information for testing */ typedef struct H5B2_node_info_test_t { - unsigned depth; /* Depth of node */ - unsigned nrec; /* Number of records in node */ + uint16_t depth; /* Depth of node */ + uint16_t nrec; /* Number of records in node */ } H5B2_node_info_test_t; #endif /* H5B2_TESTING */ diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index dde83fe..7637339 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -4851,7 +4851,6 @@ H5D__chunk_prune_by_extent(H5D_t *dset, hid_t dxpl_id, const hsize_t *old_dim) * will never change. */ chk_store.chunk.scaled = scaled; H5D_BUILD_IO_INFO_RD(&chk_io_info, dset, dxpl_cache, dxpl_id, H5AC_rawdata_dxpl_id, &chk_store, NULL); - chk_io_info.raw_dxpl_id = H5AC_rawdata_dxpl_id; /* Compose chunked index info struct */ idx_info.f = dset->oloc.file; diff --git a/src/H5EA.c b/src/H5EA.c index 8a4c5a1..9c3f3e7 100644 --- a/src/H5EA.c +++ b/src/H5EA.c @@ -78,6 +78,8 @@ static herr_t H5EA__lookup_elmt(const H5EA_t *ea, hid_t dxpl_id, hsize_t idx, hbool_t will_extend, unsigned thing_acc, void **thing, uint8_t **thing_elmt_buf, hsize_t *thing_elmt_idx, H5EA__unprotect_func_t *thing_unprot_func); +static H5EA_t *H5EA__new(H5F_t *f, hid_t dxpl_id, haddr_t ea_addr, + hbool_t from_open, void *ctx_udata); /*********************/ @@ -116,49 +118,45 @@ H5FL_BLK_DEFINE(ea_native_elmt); /*------------------------------------------------------------------------- - * Function: H5EA_create + * Function: H5EA__new * - * Purpose: Creates a new empty extensible array in the file. + * Purpose: Allocate and initialize a new extensible array wrapper in memory * - * Return: Pointer to earray wrapper on success + * Return: Pointer to earray wrapper success * NULL on failure * * Programmer: Quincey Koziol - * koziol@hdfgroup.org - * Jun 17 2008 + * koziol@lbl.gov + * Oct 10 2016 * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, +BEGIN_FUNC(STATIC, ERR, H5EA_t *, NULL, NULL, -H5EA_create(H5F_t *f, hid_t dxpl_id, const H5EA_create_t *cparam, void *ctx_udata)) +H5EA__new(H5F_t *f, hid_t dxpl_id, haddr_t ea_addr, hbool_t from_open, void *ctx_udata)) /* Local variables */ H5EA_t *ea = NULL; /* Pointer to new extensible array */ H5EA_hdr_t *hdr = NULL; /* The extensible array header information */ - haddr_t ea_addr; /* Array header address */ /* * Check arguments. */ HDassert(f); - HDassert(cparam); - - /* H5EA interface sanity check */ - HDcompile_assert(H5EA_NUM_CLS_ID == NELMTS(H5EA_client_class_g)); - - /* Create extensible array header */ - if(HADDR_UNDEF == (ea_addr = H5EA__hdr_create(f, dxpl_id, cparam, ctx_udata))) - H5E_THROW(H5E_CANTINIT, "can't create extensible array header") + HDassert(H5F_addr_defined(ea_addr)); /* Allocate extensible array wrapper */ - if(NULL == (ea = H5FL_MALLOC(H5EA_t))) + if(NULL == (ea = H5FL_CALLOC(H5EA_t))) H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array info") /* Lock the array header into memory */ - if(NULL == (hdr = H5EA__hdr_protect(f, dxpl_id, ea_addr, ctx_udata, H5AC__NO_FLAGS_SET))) + if(NULL == (hdr = H5EA__hdr_protect(f, dxpl_id, ea_addr, ctx_udata, H5AC__READ_ONLY_FLAG))) H5E_THROW(H5E_CANTPROTECT, "unable to load extensible array header") + /* Check for pending array deletion */ + if(from_open && hdr->pending_delete) + H5E_THROW(H5E_CANTOPENOBJ, "can't open extensible array pending deletion") + /* Point extensible array wrapper at header and bump it's ref count */ ea->hdr = hdr; if(H5EA__hdr_incr(ea->hdr) < 0) @@ -182,6 +180,57 @@ CATCH if(ea && H5EA_close(ea, dxpl_id) < 0) H5E_THROW(H5E_CLOSEERROR, "unable to close extensible array") +END_FUNC(STATIC) /* end H5EA__new() */ + + +/*------------------------------------------------------------------------- + * Function: H5EA_create + * + * Purpose: Creates a new empty extensible array in the file. + * + * Return: Pointer to earray wrapper on success + * NULL on failure + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * Jun 17 2008 + * + *------------------------------------------------------------------------- + */ +BEGIN_FUNC(PRIV, ERR, +H5EA_t *, NULL, NULL, +H5EA_create(H5F_t *f, hid_t dxpl_id, const H5EA_create_t *cparam, void *ctx_udata)) + + /* Local variables */ + H5EA_t *ea = NULL; /* Pointer to new extensible array */ + haddr_t ea_addr; /* Array header address */ + + /* + * Check arguments. + */ + HDassert(f); + HDassert(cparam); + + /* H5EA interface sanity check */ + HDcompile_assert(H5EA_NUM_CLS_ID == NELMTS(H5EA_client_class_g)); + + /* Create extensible array header */ + if(HADDR_UNDEF == (ea_addr = H5EA__hdr_create(f, dxpl_id, cparam, ctx_udata))) + H5E_THROW(H5E_CANTINIT, "can't create extensible array header") + + /* Allocate and initialize new extensible array wrapper */ + if(NULL == (ea = H5EA__new(f, dxpl_id, ea_addr, FALSE, ctx_udata))) + H5E_THROW(H5E_CANTINIT, "allocation and/or initialization failed for extensible array wrapper") + + /* Set the return value */ + ret_value = ea; + +CATCH + + if(!ret_value) + if(ea && H5EA_close(ea, dxpl_id) < 0) + H5E_THROW(H5E_CLOSEERROR, "unable to close extensible array") + END_FUNC(PRIV) /* end H5EA_create() */ @@ -205,7 +254,6 @@ H5EA_open(H5F_t *f, hid_t dxpl_id, haddr_t ea_addr, void *ctx_udata)) /* Local variables */ H5EA_t *ea = NULL; /* Pointer to new extensible array wrapper */ - H5EA_hdr_t *hdr = NULL; /* The extensible array header information */ /* * Check arguments. @@ -213,37 +261,15 @@ H5EA_open(H5F_t *f, hid_t dxpl_id, haddr_t ea_addr, void *ctx_udata)) HDassert(f); HDassert(H5F_addr_defined(ea_addr)); - /* Load the array header into memory */ - if(NULL == (hdr = H5EA__hdr_protect(f, dxpl_id, ea_addr, ctx_udata, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, "unable to load extensible array header, address = %llu", (unsigned long long)ea_addr) - - /* Check for pending array deletion */ - if(hdr->pending_delete) - H5E_THROW(H5E_CANTOPENOBJ, "can't open extensible array pending deletion") - - /* Create fractal heap info */ - if(NULL == (ea = H5FL_MALLOC(H5EA_t))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array info") - - /* Point extensible array wrapper at header */ - ea->hdr = hdr; - if(H5EA__hdr_incr(ea->hdr) < 0) - H5E_THROW(H5E_CANTINC, "can't increment reference count on shared array header") - - /* Increment # of files using this array header */ - if(H5EA__hdr_fuse_incr(ea->hdr) < 0) - H5E_THROW(H5E_CANTINC, "can't increment file reference count on shared array header") - - /* Set file pointer for this array open context */ - ea->f = f; + /* Allocate and initialize new extensible array wrapper */ + if(NULL == (ea = H5EA__new(f, dxpl_id, ea_addr, TRUE, ctx_udata))) + H5E_THROW(H5E_CANTINIT, "allocation and/or initialization failed for extensible array wrapper") /* Set the return value */ ret_value = ea; CATCH - if(hdr && H5EA__hdr_unprotect(hdr, dxpl_id, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array header") if(!ret_value) if(ea && H5EA_close(ea, dxpl_id) < 0) H5E_THROW(H5E_CLOSEERROR, "unable to close extensible array") @@ -818,26 +844,28 @@ H5EA_close(H5EA_t *ea, hid_t dxpl_id)) */ HDassert(ea); - /* Decrement file reference & check if this is the last open extensible array using the shared array header */ - if(0 == H5EA__hdr_fuse_decr(ea->hdr)) { - /* Set the shared array header's file context for this operation */ - ea->hdr->f = ea->f; - - /* Shut down anything that can't be put in the header's 'flush' callback */ - - /* Check for pending array deletion */ - if(ea->hdr->pending_delete) { - /* Set local info, so array deletion can occur after decrementing the - * header's ref count - */ - pending_delete = TRUE; - ea_addr = ea->hdr->addr; + /* Close the header, if it was set */ + if(ea->hdr) { + /* Decrement file reference & check if this is the last open extensible array using the shared array header */ + if(0 == H5EA__hdr_fuse_decr(ea->hdr)) { + /* Set the shared array header's file context for this operation */ + ea->hdr->f = ea->f; + + /* Shut down anything that can't be put in the header's 'flush' callback */ + + /* Check for pending array deletion */ + if(ea->hdr->pending_delete) { + /* Set local info, so array deletion can occur after decrementing the + * header's ref count + */ + pending_delete = TRUE; + ea_addr = ea->hdr->addr; + } /* end if */ } /* end if */ - } /* end if */ - /* Check for pending array deletion */ - if(pending_delete) { - H5EA_hdr_t *hdr; /* Another pointer to extensible array header */ + /* Check for pending array deletion */ + if(pending_delete) { + H5EA_hdr_t *hdr; /* Another pointer to extensible array header */ #ifndef NDEBUG { @@ -854,33 +882,34 @@ H5EA_close(H5EA_t *ea, hid_t dxpl_id)) } #endif /* NDEBUG */ - /* Lock the array header into memory */ - /* (OK to pass in NULL for callback context, since we know the header must be in the cache) */ - if(NULL == (hdr = H5EA__hdr_protect(ea->f, dxpl_id, ea_addr, NULL, H5AC__NO_FLAGS_SET))) - H5E_THROW(H5E_CANTLOAD, "unable to load extensible array header") + /* Lock the array header into memory */ + /* (OK to pass in NULL for callback context, since we know the header must be in the cache) */ + if(NULL == (hdr = H5EA__hdr_protect(ea->f, dxpl_id, ea_addr, NULL, H5AC__NO_FLAGS_SET))) + H5E_THROW(H5E_CANTLOAD, "unable to load extensible array header") - /* Set the shared array header's file context for this operation */ - hdr->f = ea->f; + /* Set the shared array header's file context for this operation */ + hdr->f = ea->f; - /* Decrement the reference count on the array header */ - /* (don't put in H5EA_hdr_fuse_decr() as the array header may be evicted - * immediately -QAK) - */ - if(H5EA__hdr_decr(ea->hdr) < 0) - H5E_THROW(H5E_CANTDEC, "can't decrement reference count on shared array header") + /* Decrement the reference count on the array header */ + /* (don't put in H5EA_hdr_fuse_decr() as the array header may be evicted + * immediately -QAK) + */ + if(H5EA__hdr_decr(ea->hdr) < 0) + H5E_THROW(H5E_CANTDEC, "can't decrement reference count on shared array header") - /* Delete array, starting with header (unprotects header) */ - if(H5EA__hdr_delete(hdr, dxpl_id) < 0) - H5E_THROW(H5E_CANTDELETE, "unable to delete extensible array") + /* Delete array, starting with header (unprotects header) */ + if(H5EA__hdr_delete(hdr, dxpl_id) < 0) + H5E_THROW(H5E_CANTDELETE, "unable to delete extensible array") + } /* end if */ + else { + /* Decrement the reference count on the array header */ + /* (don't put in H5EA_hdr_fuse_decr() as the array header may be evicted + * immediately -QAK) + */ + if(H5EA__hdr_decr(ea->hdr) < 0) + H5E_THROW(H5E_CANTDEC, "can't decrement reference count on shared array header") + } /* end else */ } /* end if */ - else { - /* Decrement the reference count on the array header */ - /* (don't put in H5EA_hdr_fuse_decr() as the array header may be evicted - * immediately -QAK) - */ - if(H5EA__hdr_decr(ea->hdr) < 0) - H5E_THROW(H5E_CANTDEC, "can't decrement reference count on shared array header") - } /* end else */ /* Release the extensible array wrapper */ ea = (H5EA_t *)H5FL_FREE(H5EA_t, ea); diff --git a/src/H5EAcache.c b/src/H5EAcache.c index 4210b07..b7846e9 100644 --- a/src/H5EAcache.c +++ b/src/H5EAcache.c @@ -893,7 +893,11 @@ H5EA__cache_iblock_notify(H5AC_notify_action_t action, void *_thing)) break; default: +#ifdef NDEBUG H5E_THROW(H5E_BADVALUE, "unknown action from metadata cache") +#else /* NDEBUG */ + HDassert(0 && "Unknown action?!?"); +#endif /* NDEBUG */ } /* end switch */ CATCH @@ -955,7 +959,6 @@ H5EA__cache_sblock_get_initial_load_size(void *_udata, size_t *image_len)) /* Check arguments */ HDassert(udata); HDassert(udata->hdr); - HDassert(udata->parent); HDassert(udata->sblk_idx > 0); HDassert(H5F_addr_defined(udata->sblk_addr)); HDassert(image_len); @@ -1293,7 +1296,11 @@ H5EA__cache_sblock_notify(H5AC_notify_action_t action, void *_thing)) break; default: +#ifdef NDEBUG H5E_THROW(H5E_BADVALUE, "unknown action from metadata cache") +#else /* NDEBUG */ + HDassert(0 && "Unknown action?!?"); +#endif /* NDEBUG */ } /* end switch */ CATCH @@ -1355,7 +1362,6 @@ H5EA__cache_dblock_get_initial_load_size(void *_udata, size_t *image_len)) /* Check arguments */ HDassert(udata); HDassert(udata->hdr); - HDassert(udata->parent); HDassert(udata->nelmts > 0); HDassert(image_len); @@ -1694,7 +1700,11 @@ H5EA__cache_dblock_notify(H5AC_notify_action_t action, void *_thing)) break; default: +#ifdef NDEBUG H5E_THROW(H5E_BADVALUE, "unknown action from metadata cache") +#else /* NDEBUG */ + HDassert(0 && "Unknown action?!?"); +#endif /* NDEBUG */ } /* end switch */ CATCH @@ -1802,7 +1812,6 @@ H5EA__cache_dblk_page_get_initial_load_size(void *_udata, size_t *image_len)) /* Check arguments */ HDassert(udata); HDassert(udata->hdr); - HDassert(udata->parent); HDassert(image_len); /* Set the image length size */ @@ -2063,7 +2072,11 @@ H5EA__cache_dblk_page_notify(H5AC_notify_action_t action, void *_thing)) break; default: +#ifdef NDEBUG H5E_THROW(H5E_BADVALUE, "unknown action from metadata cache") +#else /* NDEBUG */ + HDassert(0 && "Unknown action?!?"); +#endif /* NDEBUG */ } /* end switch */ CATCH diff --git a/src/H5F.c b/src/H5F.c index c70f813..d2d002a 100644 --- a/src/H5F.c +++ b/src/H5F.c @@ -1367,6 +1367,103 @@ done: /*------------------------------------------------------------------------- + * Function: H5Fget_metadata_read_retry_info + * + * Purpose: To retrieve the collection of read retries for metadata items with checksum. + * + * Return: Success: non-negative on success + * Failure: Negative + * + * Programmer: Vailin Choi; October 2013 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Fget_metadata_read_retry_info(hid_t file_id, H5F_retry_info_t *info) +{ + H5F_t *file; /* File object for file ID */ + unsigned i, j; /* Local index variable */ + size_t tot_size; /* Size of each retries[i] */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE2("e", "i*x", file_id, info); + + /* Check args */ + if(!info) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct") + + /* Get the file pointer */ + if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") + + /* Copy the # of bins for "retries" array */ + info->nbins = file->shared->retries_nbins; + + /* Initialize the array of "retries" */ + HDmemset(info->retries, 0, sizeof(info->retries)); + + /* Return if there are no bins -- no retries */ + if(!info->nbins) + HGOTO_DONE(SUCCEED); + + /* Calculate size for each retries[i] */ + tot_size = info->nbins * sizeof(uint32_t); + + /* Map and copy information to info's retries for metadata items with tracking for read retries */ + j = 0; + for(i = 0; i < H5AC_NTYPES; i++) { + switch(i) { + case H5AC_OHDR_ID: + case H5AC_OHDR_CHK_ID: + case H5AC_BT2_HDR_ID: + case H5AC_BT2_INT_ID: + case H5AC_BT2_LEAF_ID: + case H5AC_FHEAP_HDR_ID: + case H5AC_FHEAP_DBLOCK_ID: + case H5AC_FHEAP_IBLOCK_ID: + case H5AC_FSPACE_HDR_ID: + case H5AC_FSPACE_SINFO_ID: + case H5AC_SOHM_TABLE_ID: + case H5AC_SOHM_LIST_ID: + case H5AC_EARRAY_HDR_ID: + case H5AC_EARRAY_IBLOCK_ID: + case H5AC_EARRAY_SBLOCK_ID: + case H5AC_EARRAY_DBLOCK_ID: + case H5AC_EARRAY_DBLK_PAGE_ID: + case H5AC_FARRAY_HDR_ID: + case H5AC_FARRAY_DBLOCK_ID: + case H5AC_FARRAY_DBLK_PAGE_ID: + case H5AC_SUPERBLOCK_ID: + HDassert(j < H5F_NUM_METADATA_READ_RETRY_TYPES); + if(file->shared->retries[i] != NULL) { + /* Allocate memory for retries[i] + * + * This memory should be released by the user with + * the H5free_memory() call. + */ + if(NULL == (info->retries[j] = (uint32_t *)H5MM_malloc(tot_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + + /* Copy the information */ + HDmemcpy(info->retries[j], file->shared->retries[i], tot_size); + } /* end if */ + + /* Increment location in info->retries[] array */ + j++; + break; + + default: + break; + } /* end switch */ + } /* end for */ + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Fget_metadata_read_retry_info() */ + + +/*------------------------------------------------------------------------- * Function: H5Fget_free_sections * * Purpose: To get free-space section information for free-space manager with diff --git a/src/H5FA.c b/src/H5FA.c index 4435af0..c6c2e1b 100644 --- a/src/H5FA.c +++ b/src/H5FA.c @@ -64,6 +64,8 @@ /********************/ /* Local Prototypes */ /********************/ +static H5FA_t *H5FA__new(H5F_t *f, hid_t dxpl_id, haddr_t fa_addr, + hbool_t from_open, void *ctx_udata); /*********************/ @@ -103,51 +105,44 @@ H5FL_BLK_DEFINE(fa_native_elmt); /*------------------------------------------------------------------------- - * Function: H5FA_create + * Function: H5FA__new * - * Purpose: Creates a new fixed array (header) in the file. + * Purpose: Allocate and initialize a new fixe array wrapper in memory * - * Return: Pointer to fixed array wrapper on success + * Return: Pointer to farray wrapper success * NULL on failure * - * Programmer: Vailin Choi - * Thursday, April 30, 2009 + * Programmer: Quincey Koziol + * koziol@lbl.gov + * Oct 17 2016 * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, +BEGIN_FUNC(STATIC, ERR, H5FA_t *, NULL, NULL, -H5FA_create(H5F_t *f, hid_t dxpl_id, const H5FA_create_t *cparam, void *ctx_udata)) +H5FA__new(H5F_t *f, hid_t dxpl_id, haddr_t fa_addr, hbool_t from_open, void *ctx_udata)) /* Local variables */ H5FA_t *fa = NULL; /* Pointer to new fixed array */ H5FA_hdr_t *hdr = NULL; /* The fixed array header information */ - haddr_t fa_addr; /* Fixed Array header address */ - -#ifdef H5FA_DEBUG -HDfprintf(stderr, "%s: Called\n", FUNC); -#endif /* H5FA_DEBUG */ /* * Check arguments. */ HDassert(f); - HDassert(cparam); - - /* H5FA interface sanity check */ - HDcompile_assert(H5FA_NUM_CLS_ID == NELMTS(H5FA_client_class_g)); - - /* Create fixed array header */ - if(HADDR_UNDEF == (fa_addr = H5FA__hdr_create(f, dxpl_id, cparam, ctx_udata))) - H5E_THROW(H5E_CANTINIT, "can't create fixed array header") + HDassert(H5F_addr_defined(fa_addr)); /* Allocate fixed array wrapper */ - if(NULL == (fa = H5FL_MALLOC(H5FA_t))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for fixed array info") + if(NULL == (fa = H5FL_CALLOC(H5FA_t))) + H5E_THROW(H5E_CANTALLOC, "memory allocation failed for fixed array info") /* Lock the array header into memory */ - if(NULL == (hdr = H5FA__hdr_protect(f, dxpl_id, fa_addr, ctx_udata, H5AC__NO_FLAGS_SET))) - H5E_THROW(H5E_CANTPROTECT, "unable to load fixed array header") + if(NULL == (hdr = H5FA__hdr_protect(f, dxpl_id, fa_addr, ctx_udata, H5AC__READ_ONLY_FLAG))) + H5E_THROW(H5E_CANTPROTECT, "unable to load fixed array header") + + /* Check for pending array deletion */ + if(from_open && hdr->pending_delete) + H5E_THROW(H5E_CANTOPENOBJ, "can't open fixed array pending deletion") /* Point fixed array wrapper at header and bump it's ref count */ fa->hdr = hdr; @@ -172,6 +167,56 @@ CATCH if(fa && H5FA_close(fa, dxpl_id) < 0) H5E_THROW(H5E_CLOSEERROR, "unable to close fixed array") +END_FUNC(STATIC) /* end H5FA__new() */ + + +/*------------------------------------------------------------------------- + * Function: H5FA_create + * + * Purpose: Creates a new fixed array (header) in the file. + * + * Return: Pointer to fixed array wrapper on success + * NULL on failure + * + * Programmer: Vailin Choi + * Thursday, April 30, 2009 + * + *------------------------------------------------------------------------- + */ +BEGIN_FUNC(PRIV, ERR, +H5FA_t *, NULL, NULL, +H5FA_create(H5F_t *f, hid_t dxpl_id, const H5FA_create_t *cparam, void *ctx_udata)) + + /* Local variables */ + H5FA_t *fa = NULL; /* Pointer to new fixed array */ + haddr_t fa_addr; /* Fixed array header address */ + + /* + * Check arguments. + */ + HDassert(f); + HDassert(cparam); + + /* H5FA interface sanity check */ + HDcompile_assert(H5FA_NUM_CLS_ID == NELMTS(H5FA_client_class_g)); + + /* Create fixed array header */ + if(HADDR_UNDEF == (fa_addr = H5FA__hdr_create(f, dxpl_id, cparam, ctx_udata))) + H5E_THROW(H5E_CANTINIT, "can't create fixed array header") + + /* Allocate and initialize new fixed array wrapper */ + if(NULL == (fa = H5FA__new(f, dxpl_id, fa_addr, FALSE, ctx_udata))) + H5E_THROW(H5E_CANTINIT, "allocation and/or initialization failed for fixed array wrapper") + + /* Set the return value */ + ret_value = fa; + +CATCH + + if(!ret_value) + if(fa && H5FA_close(fa, dxpl_id) < 0) + H5E_THROW(H5E_CLOSEERROR, "unable to close fixed array") + END_FUNC(PRIV) /* end H5FA_create() */ @@ -194,7 +239,6 @@ H5FA_open(H5F_t *f, hid_t dxpl_id, haddr_t fa_addr, void *ctx_udata)) /* Local variables */ H5FA_t *fa = NULL; /* Pointer to new fixed array wrapper */ - H5FA_hdr_t *hdr = NULL; /* The fixed array header information */ /* * Check arguments. @@ -202,40 +246,15 @@ H5FA_open(H5F_t *f, hid_t dxpl_id, haddr_t fa_addr, void *ctx_udata)) HDassert(f); HDassert(H5F_addr_defined(fa_addr)); - /* Load the array header into memory */ -#ifdef H5FA_DEBUG -HDfprintf(stderr, "%s: fa_addr = %a\n", FUNC, fa_addr); -#endif /* H5FA_DEBUG */ - if(NULL == (hdr = H5FA__hdr_protect(f, dxpl_id, fa_addr, ctx_udata, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, "unable to load fixed array header, address = %llu", (unsigned long long)fa_addr) - - /* Check for pending array deletion */ - if(hdr->pending_delete) - H5E_THROW(H5E_CANTOPENOBJ, "can't open fixed array pending deletion") - - /* Create fixed array info */ - if(NULL == (fa = H5FL_MALLOC(H5FA_t))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for fixed array info") - - /* Point fixed array wrapper at header */ - fa->hdr = hdr; - if(H5FA__hdr_incr(fa->hdr) < 0) - H5E_THROW(H5E_CANTINC, "can't increment reference count on shared array header") - - /* Increment # of files using this array header */ - if(H5FA__hdr_fuse_incr(fa->hdr) < 0) - H5E_THROW(H5E_CANTINC, "can't increment file reference count on shared array header") - - /* Set file pointer for this array open context */ - fa->f = f; + /* Allocate and initialize new fixed array wrapper */ + if(NULL == (fa = H5FA__new(f, dxpl_id, fa_addr, TRUE, ctx_udata))) + H5E_THROW(H5E_CANTINIT, "allocation and/or initialization failed for fixed array wrapper") /* Set the return value */ ret_value = fa; CATCH - if(hdr && H5FA__hdr_unprotect(hdr, dxpl_id, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array header") if(!ret_value) if(fa && H5FA_close(fa, dxpl_id) < 0) H5E_THROW(H5E_CLOSEERROR, "unable to close fixed array") @@ -534,26 +553,28 @@ H5FA_close(H5FA_t *fa, hid_t dxpl_id)) */ HDassert(fa); - /* Decrement file reference & check if this is the last open fixed array using the shared array header */ - if(0 == H5FA__hdr_fuse_decr(fa->hdr)) { - /* Set the shared array header's file context for this operation */ - fa->hdr->f = fa->f; - - /* Shut down anything that can't be put in the header's 'flush' callback */ - - /* Check for pending array deletion */ - if(fa->hdr->pending_delete) { - /* Set local info, so array deletion can occur after decrementing the - * header's ref count - */ - pending_delete = TRUE; - fa_addr = fa->hdr->addr; + /* Close the header, if it was set */ + if(fa->hdr) { + /* Decrement file reference & check if this is the last open fixed array using the shared array header */ + if(0 == H5FA__hdr_fuse_decr(fa->hdr)) { + /* Set the shared array header's file context for this operation */ + fa->hdr->f = fa->f; + + /* Shut down anything that can't be put in the header's 'flush' callback */ + + /* Check for pending array deletion */ + if(fa->hdr->pending_delete) { + /* Set local info, so array deletion can occur after decrementing the + * header's ref count + */ + pending_delete = TRUE; + fa_addr = fa->hdr->addr; + } /* end if */ } /* end if */ - } /* end if */ - /* Check for pending array deletion */ - if(pending_delete) { - H5FA_hdr_t *hdr; /* Another pointer to fixed array header */ + /* Check for pending array deletion */ + if(pending_delete) { + H5FA_hdr_t *hdr; /* Another pointer to fixed array header */ #ifndef NDEBUG { @@ -570,33 +591,34 @@ H5FA_close(H5FA_t *fa, hid_t dxpl_id)) } #endif /* NDEBUG */ - /* Lock the array header into memory */ - /* (OK to pass in NULL for callback context, since we know the header must be in the cache) */ - if(NULL == (hdr = H5FA__hdr_protect(fa->f, dxpl_id, fa_addr, NULL, H5AC__NO_FLAGS_SET))) - H5E_THROW(H5E_CANTLOAD, "unable to load fixed array header") + /* Lock the array header into memory */ + /* (OK to pass in NULL for callback context, since we know the header must be in the cache) */ + if(NULL == (hdr = H5FA__hdr_protect(fa->f, dxpl_id, fa_addr, NULL, H5AC__NO_FLAGS_SET))) + H5E_THROW(H5E_CANTLOAD, "unable to load fixed array header") - /* Set the shared array header's file context for this operation */ - hdr->f = fa->f; + /* Set the shared array header's file context for this operation */ + hdr->f = fa->f; - /* Decrement the reference count on the array header */ - /* (don't put in H5FA_hdr_fuse_decr() as the array header may be evicted - * immediately -QAK) - */ - if(H5FA__hdr_decr(fa->hdr) < 0) - H5E_THROW(H5E_CANTDEC, "can't decrement reference count on shared array header") + /* Decrement the reference count on the array header */ + /* (don't put in H5FA_hdr_fuse_decr() as the array header may be evicted + * immediately -QAK) + */ + if(H5FA__hdr_decr(fa->hdr) < 0) + H5E_THROW(H5E_CANTDEC, "can't decrement reference count on shared array header") - /* Delete array, starting with header (unprotects header) */ - if(H5FA__hdr_delete(hdr, dxpl_id) < 0) - H5E_THROW(H5E_CANTDELETE, "unable to delete fixed array") + /* Delete array, starting with header (unprotects header) */ + if(H5FA__hdr_delete(hdr, dxpl_id) < 0) + H5E_THROW(H5E_CANTDELETE, "unable to delete fixed array") + } /* end if */ + else { + /* Decrement the reference count on the array header */ + /* (don't put in H5FA_hdr_fuse_decr() as the array header may be evicted + * immediately -QAK) + */ + if(H5FA__hdr_decr(fa->hdr) < 0) + H5E_THROW(H5E_CANTDEC, "can't decrement reference count on shared array header") + } /* end else */ } /* end if */ - else { - /* Decrement the reference count on the array header */ - /* (don't put in H5FA_hdr_fuse_decr() as the array header may be evicted - * immediately -QAK) - */ - if(H5FA__hdr_decr(fa->hdr) < 0) - H5E_THROW(H5E_CANTDEC, "can't decrement reference count on shared array header") - } /* end else */ /* Release the fixed array wrapper */ fa = H5FL_FREE(H5FA_t, fa); diff --git a/src/H5FAhdr.c b/src/H5FAhdr.c index d844f06..d6e32dc 100644 --- a/src/H5FAhdr.c +++ b/src/H5FAhdr.c @@ -119,6 +119,7 @@ H5FA__hdr_alloc(H5F_t *f)) ret_value = hdr; CATCH + if(!ret_value) if(hdr && H5FA__hdr_dest(hdr) < 0) H5E_THROW(H5E_CANTFREE, "unable to destroy fixed array header") @@ -225,6 +226,7 @@ H5FA__hdr_create(H5F_t *f, hid_t dxpl_id, const H5FA_create_t *cparam, ret_value = hdr->addr; CATCH + if(!H5F_addr_defined(ret_value)) if(hdr) { /* Release header's disk space */ diff --git a/src/H5FDcore.c b/src/H5FDcore.c index f29e231..9090679 100644 --- a/src/H5FDcore.c +++ b/src/H5FDcore.c @@ -1479,23 +1479,31 @@ done: static herr_t H5FD_core_lock(H5FD_t *_file, hbool_t rw) { - H5FD_core_t *file = (H5FD_core_t*)_file; /* VFD file struct */ - int lock; /* The type of lock */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_core_t *file = (H5FD_core_t*)_file; /* VFD file struct */ + int lock_flags; /* file locking flags */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT HDassert(file); + + /* Only set the lock if there is a file descriptor. If no file + * descriptor, this is a no-op. + */ if(file->fd >= 0) { - /* Determine the type of lock */ - lock = rw ? LOCK_EX : LOCK_SH; - - /* Place the lock with non-blocking */ - if(HDflock(file->fd, lock | LOCK_NB) < 0) - HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "unable to flock file") - } - /* Otherwise a noop */ + /* Set exclusive or shared lock based on rw status */ + lock_flags = rw ? LOCK_EX : LOCK_SH; + + /* Place a non-blocking lock on the file */ + if(HDflock(file->fd, lock_flags | LOCK_NB) < 0) { + if(ENOSYS == errno) + HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "file locking disabled on this file system (use HDF5_USE_FILE_LOCKING environment variable to override)") + else + HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "unable to lock file") + } /* end if */ + + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) @@ -1525,11 +1533,16 @@ H5FD_core_unlock(H5FD_t *_file) if(file->fd >= 0) { - if(HDflock(file->fd, LOCK_UN) < 0) - HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "unable to flock (unlock) file") - } - /* Otherwise a noop */ + if(HDflock(file->fd, LOCK_UN) < 0) { + if(ENOSYS == errno) + HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "file locking disabled on this file system (use HDF5_USE_FILE_LOCKING environment variable to override)") + else + HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "unable to unlock file") + } /* end if */ + + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_core_unlock() */ + diff --git a/src/H5FDfamily.c b/src/H5FDfamily.c index 7ec8751..f0d4dba 100644 --- a/src/H5FDfamily.c +++ b/src/H5FDfamily.c @@ -1339,33 +1339,37 @@ done: static herr_t H5FD_family_lock(H5FD_t *_file, hbool_t rw) { - H5FD_family_t *file = (H5FD_family_t *)_file; /* VFD file struct */ - unsigned u, i; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_family_t *file = (H5FD_family_t *)_file; /* VFD file struct */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Place the lock on all the member files */ - for(u = 0; u < file->nmembs; u++) { - if(file->memb[u]) { + for(u = 0; u < file->nmembs; u++) + if(file->memb[u]) if(H5FD_lock(file->memb[u], rw) < 0) - break; - } /* end if */ - } /* end for */ + break; - if(u < file->nmembs) { /* Try to unlock the member files done before */ - for(i = 0; i < u; i++) { - if(H5FD_unlock(file->memb[i]) < 0) - /* Push error, but keep going*/ - HDONE_ERROR(H5E_IO, H5E_CANTUNLOCK, FAIL, "unable to unlock member files") - } - HGOTO_ERROR(H5E_IO, H5E_CANTLOCK, FAIL, "unable to lock member files") + /* If one of the locks failed, try to unlock the locked member files + * in an attempt to return to a fully unlocked state. + */ + if(u < file->nmembs) { + unsigned v; /* Local index variable */ + + for(v = 0; v < v; v++) { + if(H5FD_unlock(file->memb[v]) < 0) + /* Push error, but keep going */ + HDONE_ERROR(H5E_IO, H5E_CANTUNLOCK, FAIL, "unable to unlock member files") + } /* end for */ + HGOTO_ERROR(H5E_IO, H5E_CANTLOCK, FAIL, "unable to lock member files") } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_family_lock() */ + /*------------------------------------------------------------------------- * Function: H5FD_family_unlock * @@ -1381,19 +1385,18 @@ static herr_t H5FD_family_unlock(H5FD_t *_file) { H5FD_family_t *file = (H5FD_family_t *)_file; /* VFD file struct */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Remove the lock on the member files */ - for(u = 0; u < file->nmembs; u++) { - if(file->memb[u]) { + for(u = 0; u < file->nmembs; u++) + if(file->memb[u]) if(H5FD_unlock(file->memb[u]) < 0) - HGOTO_ERROR(H5E_IO, H5E_CANTUNLOCK, FAIL, "unable to unlock member files") - } /* end if */ - } /* end for */ + HGOTO_ERROR(H5E_IO, H5E_CANTUNLOCK, FAIL, "unable to unlock member files") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_family_unlock() */ + diff --git a/src/H5FDlog.c b/src/H5FDlog.c index 9f5dfa5..a2891cb 100644 --- a/src/H5FDlog.c +++ b/src/H5FDlog.c @@ -1567,15 +1567,7 @@ static herr_t H5FD_log_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR_UNUSED closing) { H5FD_log_t *file = (H5FD_log_t *)_file; -#ifdef H5_HAVE_WIN32_API - LARGE_INTEGER li; /* 64-bit (union) integer for SetFilePointer() call */ - DWORD dwPtrLow; /* Low-order pointer bits from SetFilePointer() - * Only used as an error code here. - */ - DWORD dwError; /* DWORD error code from GetLastError() */ - BOOL bError; /* Boolean error flag */ -#endif /* H5_HAVE_WIN32_API */ -herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1586,6 +1578,14 @@ herr_t ret_value = SUCCEED; /* Return value */ #ifdef H5_HAVE_GETTIMEOFDAY struct timeval timeval_start, timeval_stop; #endif /* H5_HAVE_GETTIMEOFDAY */ +#ifdef H5_HAVE_WIN32_API + LARGE_INTEGER li; /* 64-bit (union) integer for SetFilePointer() call */ + DWORD dwPtrLow; /* Low-order pointer bits from SetFilePointer() + * Only used as an error code here. + */ + DWORD dwError; /* DWORD error code from GetLastError() */ + BOOL bError; /* Boolean error flag */ +#endif /* H5_HAVE_WIN32_API */ #ifdef H5_HAVE_GETTIMEOFDAY if(file->fa.flags & H5FD_LOG_TIME_TRUNCATE) @@ -1677,21 +1677,25 @@ done: static herr_t H5FD_log_lock(H5FD_t *_file, hbool_t rw) { - H5FD_log_t *file = (H5FD_log_t *)_file; - int lock; - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_log_t *file = (H5FD_log_t *)_file; /* VFD file struct */ + int lock_flags; /* file locking flags */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Sanity check */ HDassert(file); - /* Determine the type of lock */ - lock = rw ? LOCK_EX : LOCK_SH; + /* Set exclusive or shared lock based on rw status */ + lock_flags = rw ? LOCK_EX : LOCK_SH; - /* Place the lock with non-blocking */ - if(HDflock(file->fd, lock | LOCK_NB) < 0) - HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "unable to flock file") + /* Place a non-blocking lock on the file */ + if(HDflock(file->fd, lock_flags | LOCK_NB) < 0) { + if(ENOSYS == errno) + HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "file locking disabled on this file system (use HDF5_USE_FILE_LOCKING environment variable to override)") + else + HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "unable to lock file") + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) @@ -1712,15 +1716,19 @@ done: static herr_t H5FD_log_unlock(H5FD_t *_file) { - H5FD_log_t *file = (H5FD_log_t *)_file; /* VFD file struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_log_t *file = (H5FD_log_t *)_file; /* VFD file struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT HDassert(file); - if(HDflock(file->fd, LOCK_UN) < 0) - HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "unable to flock (unlock) file") + if(HDflock(file->fd, LOCK_UN) < 0) { + if(ENOSYS == errno) + HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "file locking disabled on this file system (use HDF5_USE_FILE_LOCKING environment variable to override)") + else + HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "unable to unlock file") + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5FDsec2.c b/src/H5FDsec2.c index bb8f004..04a0790 100644 --- a/src/H5FDsec2.c +++ b/src/H5FDsec2.c @@ -922,20 +922,24 @@ done: static herr_t H5FD_sec2_lock(H5FD_t *_file, hbool_t rw) { - H5FD_sec2_t *file = (H5FD_sec2_t *)_file; /* VFD file struct */ - int lock; /* The type of lock */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_sec2_t *file = (H5FD_sec2_t *)_file; /* VFD file struct */ + int lock_flags; /* file locking flags */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT HDassert(file); - /* Determine the type of lock */ - lock = rw ? LOCK_EX : LOCK_SH; - - /* Place the lock with non-blocking */ - if(HDflock(file->fd, lock | LOCK_NB) < 0) - HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "unable to flock file") + /* Set exclusive or shared lock based on rw status */ + lock_flags = rw ? LOCK_EX : LOCK_SH; + + /* Place a non-blocking lock on the file */ + if(HDflock(file->fd, lock_flags | LOCK_NB) < 0) { + if(ENOSYS == errno) + HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "file locking disabled on this file system (use HDF5_USE_FILE_LOCKING environment variable to override)") + else + HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "unable to lock file") + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) @@ -956,15 +960,19 @@ done: static herr_t H5FD_sec2_unlock(H5FD_t *_file) { - H5FD_sec2_t *file = (H5FD_sec2_t *)_file; /* VFD file struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_sec2_t *file = (H5FD_sec2_t *)_file; /* VFD file struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT HDassert(file); - if(HDflock(file->fd, LOCK_UN) < 0) - HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "unable to flock (unlock) file") + if(HDflock(file->fd, LOCK_UN) < 0) { + if(ENOSYS == errno) + HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "file locking disabled on this file system (use HDF5_USE_FILE_LOCKING environment variable to override)") + else + HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "unable to unlock file") + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5FDstdio.c b/src/H5FDstdio.c index 0168ff4..7056f7f 100644 --- a/src/H5FDstdio.c +++ b/src/H5FDstdio.c @@ -24,6 +24,7 @@ * and is not intended for production use! */ #include +#include #include #include #include @@ -1078,8 +1079,8 @@ H5FD_stdio_truncate(H5FD_t *_file, hid_t /*UNUSED*/ dxpl_id, * Function: H5FD_stdio_lock * * Purpose: Lock a file via flock - * * NOTE: This function is a no-op if flock() is not present. + * * Errors: * IO FCNTL flock failed. * @@ -1093,21 +1094,27 @@ static herr_t H5FD_stdio_lock(H5FD_t *_file, hbool_t rw) { #ifdef H5_HAVE_FLOCK - H5FD_stdio_t *file = (H5FD_stdio_t*)_file; - int lock; /* The type of lock */ - static const char *func = "H5FD_stdio_lock"; /* Function Name for error reporting */ + H5FD_stdio_t *file = (H5FD_stdio_t*)_file; /* VFD file struct */ + int lock_flags; /* file locking flags */ + static const char *func = "H5FD_stdio_lock"; /* Function Name for error reporting */ /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); assert(file); - /* Determine the type of lock */ - lock = rw ? LOCK_EX : LOCK_SH; + /* Set exclusive or shared lock based on rw status */ + lock_flags = rw ? LOCK_EX : LOCK_SH; - /* Place the lock with non-blocking */ - if(flock(file->fd, lock | LOCK_NB) < 0) - H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_FCNTL, "flock failed", -1) + /* Place a non-blocking lock on the file */ + if(flock(file->fd, lock_flags | LOCK_NB) < 0) { + if(ENOSYS == errno) + H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_FCNTL, "file locking disabled on this file system (use HDF5_USE_FILE_LOCKING environment variable to override)", -1) + else + H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_FCNTL, "file lock failed", -1) + } /* end if */ + + /* Flush the stream */ if(fflush(file->fp) < 0) H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_WRITEERROR, "fflush failed", -1) @@ -1117,16 +1124,15 @@ H5FD_stdio_lock(H5FD_t *_file, hbool_t rw) } /* end H5FD_stdio_lock() */ /*------------------------------------------------------------------------- - * Function: H5F_stdio_unlock - * - * Purpose: Unlock a file via flock + * Function: H5F_stdio_unlock * + * Purpose: Unlock a file via flock + * NOTE: This function is a no-op if flock() is not present. * - * NOTE: This function is a no-op if flock() is not present. * Errors: * IO FCNTL flock failed. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * * Programmer: Vailin Choi; March 2015 * @@ -1136,18 +1142,25 @@ static herr_t H5FD_stdio_unlock(H5FD_t *_file) { #ifdef H5_HAVE_FLOCK - H5FD_stdio_t *file = (H5FD_stdio_t*)_file; - static const char *func = "H5FD_stdio_unlock"; /* Function Name for error reporting */ + H5FD_stdio_t *file = (H5FD_stdio_t*)_file; /* VFD file struct */ + static const char *func = "H5FD_stdio_unlock"; /* Function Name for error reporting */ /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); assert(file); + /* Flush the stream */ if(fflush(file->fp) < 0) H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_WRITEERROR, "fflush failed", -1) - if(flock(file->fd, LOCK_UN) < 0) - H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_FCNTL, "flock (unlock) failed", -1) + + /* Place a non-blocking lock on the file */ + if(flock(file->fd, LOCK_UN) < 0) { + if(ENOSYS == errno) + H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_FCNTL, "file locking disabled on this file system (use HDF5_USE_FILE_LOCKING environment variable to override)", -1) + else + H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_FCNTL, "file unlock failed", -1) + } /* end if */ #endif /* H5_HAVE_FLOCK */ diff --git a/src/H5Fint.c b/src/H5Fint.c index dbaf3cc..152148d 100644 --- a/src/H5Fint.c +++ b/src/H5Fint.c @@ -171,6 +171,8 @@ H5F_get_access_plist(H5F_t *f, hbool_t app_ref) latest_format = TRUE; if(H5P_set(new_plist, H5F_ACS_LATEST_FORMAT_NAME, &latest_format) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set 'latest format' flag") + if(H5P_set(new_plist, H5F_ACS_METADATA_READ_ATTEMPTS_NAME, &(f->shared->read_attempts)) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set 'read attempts ' flag") if(H5P_set(new_plist, H5F_ACS_OBJECT_FLUSH_CB_NAME, &(f->shared->object_flush)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set object flush callback") @@ -998,6 +1000,8 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5F_close_degree_t fc_degree; /*file close degree */ hbool_t evict_on_close; /* evict on close value from plist */ H5F_t *ret_value = NULL; /*actual return value */ + char *lock_env_var = NULL;/*env var pointer */ + hbool_t use_file_locking; /*read from env var */ FUNC_ENTER_NOAPI(NULL) @@ -1012,6 +1016,16 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, if(NULL == (drvr = H5FD_get_class(fapl_id))) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "unable to retrieve VFL class") + /* Check the environment variable that determines if we care + * about file locking. File locking should be used unless explicitly + * disabled. + */ + lock_env_var = HDgetenv("HDF5_USE_FILE_LOCKING"); + if(lock_env_var && !HDstrcmp(lock_env_var, "FALSE")) + use_file_locking = FALSE; + else + use_file_locking = TRUE; + /* * Opening a file is a two step process. First we try to open the * file in a way which doesn't affect its state (like not truncating @@ -1024,52 +1038,52 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, * way for us to detect it here anyway). */ if(drvr->cmp) - tent_flags = flags & ~(H5F_ACC_CREAT|H5F_ACC_TRUNC|H5F_ACC_EXCL); + tent_flags = flags & ~(H5F_ACC_CREAT|H5F_ACC_TRUNC|H5F_ACC_EXCL); else - tent_flags = flags; + tent_flags = flags; if(NULL == (lf = H5FD_open(name, tent_flags, fapl_id, HADDR_UNDEF))) { - if(tent_flags == flags) { + if(tent_flags == flags) { #ifndef H5_USING_MEMCHECKER time_t mytime = HDtime(NULL); - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file: time = %s, name = '%s', tent_flags = %x", HDctime(&mytime), name, tent_flags) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file: time = %s, name = '%s', tent_flags = %x", HDctime(&mytime), name, tent_flags) #else /* H5_USING_MEMCHECKER */ - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file: name = '%s', tent_flags = %x", name, tent_flags) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file: name = '%s', tent_flags = %x", name, tent_flags) #endif /* H5_USING_MEMCHECKER */ } /* end if */ H5E_clear_stack(NULL); - tent_flags = flags; - if(NULL == (lf = H5FD_open(name, tent_flags, fapl_id, HADDR_UNDEF))) { + tent_flags = flags; + if(NULL == (lf = H5FD_open(name, tent_flags, fapl_id, HADDR_UNDEF))) { #ifndef H5_USING_MEMCHECKER time_t mytime = HDtime(NULL); - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file: time = %s, name = '%s', tent_flags = %x", HDctime(&mytime), name, tent_flags) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file: time = %s, name = '%s', tent_flags = %x", HDctime(&mytime), name, tent_flags) #else /* H5_USING_MEMCHECKER */ - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file: name = '%s', tent_flags = %x", name, tent_flags) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file: name = '%s', tent_flags = %x", name, tent_flags) #endif /* H5_USING_MEMCHECKER */ } /* end if */ } /* end if */ /* Is the file already open? */ if((shared = H5F_sfile_search(lf)) != NULL) { - /* - * The file is already open, so use that one instead of the one we - * just opened. We only one one H5FD_t* per file so one doesn't - * confuse the other. But fail if this request was to truncate the - * file (since we can't do that while the file is open), or if the - * request was to create a non-existent file (since the file already - * exists), or if the new request adds write access (since the - * readers don't expect the file to change under them). - */ - if(H5FD_close(lf) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to close low-level file info") - if(flags & H5F_ACC_TRUNC) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to truncate a file which is already open") - if(flags & H5F_ACC_EXCL) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "file exists") - if((flags & H5F_ACC_RDWR) && 0 == (shared->flags & H5F_ACC_RDWR)) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "file is already open for read-only") + /* + * The file is already open, so use that one instead of the one we + * just opened. We only one one H5FD_t* per file so one doesn't + * confuse the other. But fail if this request was to truncate the + * file (since we can't do that while the file is open), or if the + * request was to create a non-existent file (since the file already + * exists), or if the new request adds write access (since the + * readers don't expect the file to change under them). + */ + if(H5FD_close(lf) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to close low-level file info") + if(flags & H5F_ACC_TRUNC) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to truncate a file which is already open") + if(flags & H5F_ACC_EXCL) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "file exists") + if((flags & H5F_ACC_RDWR) && 0 == (shared->flags & H5F_ACC_RDWR)) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "file is already open for read-only") /* Allocate new "high-level" file struct */ if((file = H5F_new(shared, flags, fcpl_id, fapl_id, NULL)) == NULL) @@ -1089,8 +1103,19 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, if(NULL == (lf = H5FD_open(name, flags, fapl_id, HADDR_UNDEF))) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file") } /* end if */ + + /* Place an advisory lock on the file */ + if(use_file_locking) + if(H5FD_lock(lf, (hbool_t)((flags & H5F_ACC_RDWR) ? TRUE : FALSE)) < 0) { + /* Locking failed - Closing will remove the lock */ + if(H5FD_close(lf) < 0) + HDONE_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to close low-level file info") + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to lock the file") + } /* end if */ + + /* Create the 'top' file structure */ if(NULL == (file = H5F_new(NULL, flags, fcpl_id, fapl_id, lf))) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to create new file object") + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to initialize file structure") } /* end else */ /* Retain the name the file was opened with */ @@ -1121,15 +1146,16 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, */ if(H5G_mkroot(file, dxpl_id, TRUE) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to create/open root group") - } else if (1 == shared->nrefs) { + } /* end if */ + else if (1 == shared->nrefs) { - /* Read the superblock if it hasn't been read before. */ + /* Read the superblock if it hasn't been read before. */ if(H5F__super_read(file, dxpl_id, TRUE) < 0) - HGOTO_ERROR(H5E_FILE, H5E_READERROR, NULL, "unable to read superblock") + HGOTO_ERROR(H5E_FILE, H5E_READERROR, NULL, "unable to read superblock") - /* Open the root group */ - if(H5G_mkroot(file, dxpl_id, FALSE) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to read root group") + /* Open the root group */ + if(H5G_mkroot(file, dxpl_id, FALSE) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to read root group") } /* end if */ /* Get the file access property list, for future queries */ @@ -1150,7 +1176,8 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, shared->fc_degree = lf->cls->fc_degree; else shared->fc_degree = fc_degree; - } else if(shared->nrefs > 1) { + } /* end if */ + else if(shared->nrefs > 1) { if(fc_degree == H5F_CLOSE_DEFAULT && shared->fc_degree != lf->cls->fc_degree) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "file close degree doesn't match") if(fc_degree != H5F_CLOSE_DEFAULT && fc_degree != shared->fc_degree) @@ -1174,19 +1201,19 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, /* Formulate the absolute path for later search of target file for external links */ if(H5_build_extpath(name, &file->extpath) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to build extpath") + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to build extpath") /* Formulate the actual file name, after following symlinks, etc. */ if(H5F_build_actual_name(file, a_plist, name, &file->actual_name) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to build actual name") + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to build actual name") /* Success */ ret_value = file; done: if(!ret_value && file) - if(H5F_dest(file, dxpl_id, FALSE) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "problems closing file") + if(H5F_dest(file, dxpl_id, FALSE) < 0) + HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "problems closing file") FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_open() */ diff --git a/src/H5Zscaleoffset.c b/src/H5Zscaleoffset.c index 91a6c00..1cca9b1 100644 --- a/src/H5Zscaleoffset.c +++ b/src/H5Zscaleoffset.c @@ -667,58 +667,6 @@ H5Z_class2_t H5Z_SCALEOFFSET[1] = {{ H5Z_scaleoffset_modify_4(i, type, pow_fun, buf, d_nelmts, min, D_val) \ } -/* Include our own rounding routine and alias it to the stdc macros, if they - * aren't available. - */ -#if !(defined(H5_HAVE_LLROUND) && defined(H5_HAVE_LLROUNDF) && defined(H5_HAVE_LROUND) && defined(H5_HAVE_LROUNDF) && defined(H5_HAVE_ROUND) && defined(H5_HAVE_ROUNDF)) -/* Round a floating-point value to the nearest integer value 4/19/05 */ -/* rounding to the bigger absolute value if val is in the middle, - 0.5 -> 1, -0.5 ->-1 -5/9/05, KY */ -static double -H5Z__scaleoffset_rnd(double val) -{ - double u_val, l_val; - - u_val = HDceil(val); - l_val = HDfloor(val); - - if(val > 0) { - if((u_val - val) <= (val - l_val)) - return u_val; - else - return l_val; - } /* end if */ - else { - if((val - l_val) <= (u_val - val)) - return l_val; - else - return u_val; - } -} /* H5Z__scaleoffset_rnd() */ - -/* Alias rounding macros to routine above, if not defined */ -#if !defined(H5_HAVE_LLROUND) -#define llround(x) H5Z__scaleoffset_rnd(x) -#endif /* !defined(H5_HAVE_LLROUND) */ -#if !defined(H5_HAVE_LLROUNDF) -#define llroundf(x) H5Z__scaleoffset_rnd(x) -#endif /* !defined(H5_HAVE_LLROUNDF) */ -#if !defined(H5_HAVE_LROUND) -#define lround(x) H5Z__scaleoffset_rnd(x) -#endif /* !defined(H5_HAVE_LROUND) */ -#if !defined(H5_HAVE_LROUNDF) -#define lroundf(x) H5Z__scaleoffset_rnd(x) -#endif /* !defined(H5_HAVE_LROUNDF) */ -#if !defined(H5_HAVE_ROUND) -#define round(x) H5Z__scaleoffset_rnd(x) -#endif /* !defined(H5_HAVE_ROUND) */ -#if !defined(H5_HAVE_ROUNDF) -#define roundf(x) H5Z__scaleoffset_rnd(x) -#endif /* !defined(H5_HAVE_ROUNDF) */ - -#endif /* !(defined(H5_HAVE_LLROUND) && defined(H5_HAVE_LLROUNDF) && defined(H5_HAVE_LROUND) && defined(H5_HAVE_LROUNDF) && defined(H5_HAVE_ROUND) && defined(H5_HAVE_ROUNDF)) */ - /*------------------------------------------------------------------------- * Function: H5Z_can_apply_scaleoffset diff --git a/test/ohdr.c b/test/ohdr.c index e613a98..1478c5c 100644 --- a/test/ohdr.c +++ b/test/ohdr.c @@ -609,9 +609,8 @@ main(void) H5F_t *f = NULL; char filename[1024]; H5O_hdr_info_t hdr_info; /* Object info */ - H5O_loc_t oh_loc, oh_loc2; /* Object header locations */ + H5O_loc_t oh_loc; /* Object header locations */ time_t time_new, ro; - int chunkno; /* Chunk index for message */ int i; /* Local index variable */ unsigned b; /* Index for "new format" loop */ herr_t ret; /* Generic return value */ -- cgit v0.12