From 322816c9666cf1010361bcf827f0d61183c3d904 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Mon, 14 Dec 2015 12:42:26 -0500 Subject: [svn-r28638] HDFFV-9273: cmakehdf5 --script failed in linux platypus Solution: remove --script option from cmakehdf5. Tested: platypus --- bin/cmakehdf5 | 266 ---------------------------------------------------------- 1 file changed, 266 deletions(-) diff --git a/bin/cmakehdf5 b/bin/cmakehdf5 index 772e54c..48869cf 100755 --- a/bin/cmakehdf5 +++ b/bin/cmakehdf5 @@ -12,8 +12,6 @@ DPRINT=: #DPRINT=echo -# use the ctest scripting method if --script is given -if [ "$1" != "--script" ]; then # variable names # The "extra" number is the step number and easier to see all logfiles in # the sorted order of steps @@ -353,267 +351,3 @@ exit_code=$? # Show a closing time stamp TIMESTAMP exit $exit_code - -else -# --------------- -# older version -# --------------- - -# variable names -progname=`basename $0` # program name -cminfile="cmakemin.$$" # Cmake minimum file -cfgfile=$progname.$$ # configure file -ctest_log=ctest.log # output of ctest script -install_log=install.log # output of installation -$DPRINT $cfgfile - -# Remove temporary generated files if exit 0 -trap "rm -f $cminfile $cfgfile" 0 - -#============= -# Function definitions -#============= -TIMESTAMP() -{ - echo "=====" "`date`" "=====" -} - - -#========== -# main -#========== -# Show a start time stamp -TIMESTAMP - -# Explain what and where log files are. -cat <.log: output of configure - LastBuild_.log: output of build - LastTest_.log: output of testing - LastTestsFailed_.log: list of failed tests - -EOF - -# First generate the two needed input files, the $cimnfile and $cfgfile. -# Then use ctest to use the two input files. - -#========== -# create the configure file -#========== -# Create the cmake minimum required file to be used by the following -# configure file. Though not absolute needed, it is better to generate -# this file before the configure file. Quote the EOF to preven substitution -# in the text. -#========== -#========== -cat > $cfgfile <<'EOF' -cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR) -######################################################## -# This dashboard is maintained by The HDF Group -# For any comments please contact cdashhelp@hdfgroup.org -# -######################################################## - -set (CTEST_DASHBOARD_ROOT ${CTEST_SCRIPT_DIRECTORY}) -set (CTEST_SOURCE_DIRECTORY "../hdf5") -set (CTEST_BINARY_DIRECTORY ".") -set (CTEST_CMAKE_GENERATOR "Unix Makefiles") -set (CTEST_BUILD_CONFIGURATION "Release") -set (CTEST_MAX_N 8) - -# -- CDash variables -set (LOCAL_NO_SUBMIT TRUE) # No CDash submit. -set (MODEL "Experimental") -set (CDASH_LOCAL TRUE) -set (SITE_BUILDNAME_SUFFIX "cmakehdf5") - -# -- URL set for internal check, default is to not update -set (LOCAL_SKIP_UPDATE TRUE) -set (REPOSITORY_URL "http://svn.${hdfgroup_url}/hdf5/branches/hdf5_1_8") -# -- Standard build options -set (ADD_BUILD_OPTIONS "-DCMAKE_INSTALL_PREFIX:PATH=${CTEST_BINARY_DIRECTORY} -DHDF5_ALLOW_EXTERNAL_SUPPORT:STRING=\"SVN\" -DHDF5_PACKAGE_EXTLIBS:BOOL=ON") - -# Use multiple CPU cores to build -include(ProcessorCount) -ProcessorCount(N) -if(NOT N EQUAL 0) - if(N GREATER ${CTEST_MAX_N}) - set(N ${CTEST_MAX_N}) - endif(N GREATER ${CTEST_MAX_N}) - set(CTEST_BUILD_FLAGS -j${N}) - set(ctest_test_args ${ctest_test_args} PARALLEL_LEVEL ${N}) -endif() - -# ----------------------------------------------------------- -# -- Get environment -# ----------------------------------------------------------- - ## -- set hostname - ## -------------------------- - find_program (HOSTNAME_CMD NAMES hostname) - exec_program (${HOSTNAME_CMD} ARGS OUTPUT_VARIABLE HOSTNAME) - set (CTEST_SITE "${HOSTNAME}${CTEST_SITE_EXT}") - find_program (UNAME NAMES uname) - macro (getuname name flag) - exec_program ("${UNAME}" ARGS "${flag}" OUTPUT_VARIABLE "${name}") - endmacro (getuname) - - getuname (osname -s) - getuname (osrel -r) - getuname (cpu -m) - - if (SITE_BUILDNAME_SUFFIX) - set (CTEST_BUILD_NAME "${osname}-${osrel}-${cpu}-${SITE_BUILDNAME_SUFFIX}") - else (SITE_BUILDNAME_SUFFIX) - set (CTEST_BUILD_NAME "${osname}-${osrel}-${cpu}") - endif (SITE_BUILDNAME_SUFFIX) -# ----------------------------------------------------------- - -set (BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DSITE:STRING=${CTEST_SITE} -DBUILDNAME:STRING=${CTEST_BUILD_NAME}") - -#----------------------------------------------------------------------------- -# MAC machines need special option -#----------------------------------------------------------------------------- -if (APPLE) - # Compiler choice - execute_process(COMMAND xcrun --find cc OUTPUT_VARIABLE XCODE_CC OUTPUT_STRIP_TRAILING_WHITESPACE) - execute_process(COMMAND xcrun --find c++ OUTPUT_VARIABLE XCODE_CXX OUTPUT_STRIP_TRAILING_WHITESPACE) - set(ENV{CC} "${XCODE_CC}") - set(ENV{CXX} "${XCODE_CXX}") - # Shared fortran is not supported, build static - set (BUILD_OPTIONS "${BUILD_OPTIONS} -DBUILD_SHARED_LIBS:BOOL=OFF -DCMAKE_ANSI_CFLAGS:STRING=-fPIC") - set (BUILD_OPTIONS "${BUILD_OPTIONS} -DCTEST_USE_LAUNCHERS:BOOL=ON -DCMAKE_BUILD_WITH_INSTALL_RPATH:BOOL=OFF") -endif (APPLE) - - -# ----------------------------------------------------------- -find_package (Subversion) -set (CTEST_UPDATE_COMMAND "${Subversion_SVN_EXECUTABLE}") -# -- Only clean build folder if LOCAL_CLEAR_BUILD is set -if (LOCAL_CLEAR_BUILD) - set (CTEST_START_WITH_EMPTY_BINARY_DIRECTORY TRUE) - if(NOT EXISTS "${CTEST_BINARY_DIRECTORY}") - file(MAKE_DIRECTORY "${CTEST_BINARY_DIRECTORY}") - else() - ctest_empty_binary_directory(${CTEST_BINARY_DIRECTORY}) - endif() -endif (LOCAL_CLEAR_BUILD) - -#----------------------------------------------------------------------------- -# Send the main script as a note. -list (APPEND CTEST_NOTES_FILES - "${CMAKE_CURRENT_LIST_FILE}" - "${CTEST_SOURCE_DIRECTORY}/config/cmake/cacheinit.cmake" - ) - -# Check for required variables. -foreach (req - CTEST_CMAKE_GENERATOR - CTEST_SITE - CTEST_BUILD_NAME - ) - if (NOT DEFINED ${req}) - message(FATAL_ERROR "The containing script must set ${req}") - endif (NOT DEFINED ${req}) -endforeach (req) - -## -- set output to english -set($ENV{LC_MESSAGES} "en_EN") - -#----------------------------------------------------------------------------- -# Initialize the CTEST commands -#------------------------------ -set (CTEST_CMAKE_COMMAND "\"${CMAKE_COMMAND}\"") -set (CTEST_CONFIGURE_COMMAND - "${CTEST_CMAKE_COMMAND} -C \"${CTEST_SOURCE_DIRECTORY}/config/cmake/cacheinit.cmake\" -DCMAKE_BUILD_TYPE:STRING=${CTEST_BUILD_CONFIGURATION} ${BUILD_OPTIONS} \"-G${CTEST_CMAKE_GENERATOR}\" \"${CTEST_SOURCE_DIRECTORY}\"") - -# Print summary information. -foreach (v - CTEST_SITE - CTEST_BUILD_NAME - CTEST_SOURCE_DIRECTORY - CTEST_BINARY_DIRECTORY - CTEST_CMAKE_GENERATOR - CTEST_BUILD_CONFIGURATION - CTEST_CONFIGURE_COMMAND - CTEST_SCRIPT_DIRECTORY - ) - set (vars "${vars} ${v}=[${${v}}]\n") -endforeach (v) -message ("Dashboard script configuration:\n${vars}\n") - -ctest_start (${MODEL} TRACK ${MODEL}) -if (NOT LOCAL_SKIP_UPDATE) - ctest_update (SOURCE "${CTEST_SOURCE_DIRECTORY}") -endif (NOT LOCAL_SKIP_UPDATE) -if(NOT res STREQUAL "0") - message (FATAL_ERROR "Configure FAILED") -endif() -message ("Configure DONE") -configure_file(${CTEST_SOURCE_DIRECTORY}/config/cmake/CTestCustom.cmake ${CTEST_BINARY_DIRECTORY}/CTestCustom.cmake) -ctest_read_custom_files ("${CTEST_BINARY_DIRECTORY}") -ctest_configure (BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) -if (NOT LOCAL_NO_SUBMIT) - ctest_submit (PARTS Update Configure Notes) -endif (NOT LOCAL_NO_SUBMIT) -ctest_build (BUILD "${CTEST_BINARY_DIRECTORY}" APPEND RETURN_VALUE res) -if (NOT LOCAL_NO_SUBMIT) - ctest_submit (PARTS Build) -endif (NOT LOCAL_NO_SUBMIT) -if(NOT res STREQUAL "0") - message (FATAL_ERROR "Build FAILED") -endif() -message ("build DONE") -if (NOT LOCAL_SKIP_TEST) - ctest_build (BUILD "${CTEST_BINARY_DIRECTORY}" APPEND ${ctest_test_args} RETURN_VALUE res) - if (NOT LOCAL_NO_SUBMIT) - ctest_submit (PARTS Test) - endif (NOT LOCAL_NO_SUBMIT) - if(NOT res STREQUAL "0") - message (FATAL_ERROR "Test FAILED") - endif() - message ("test DONE") -endif (NOT LOCAL_SKIP_TEST) -if(NOT LOCAL_MEMCHECK_TEST) - ##----------------------------------------------- - ## Package the product - ##----------------------------------------------- - execute_process(COMMAND cpack -C ${CTEST_BUILD_CONFIGURATION} -V - WORKING_DIRECTORY ${CTEST_BINARY_DIRECTORY} - RESULT_VARIABLE cpackResult - OUTPUT_VARIABLE cpackLog - ERROR_VARIABLE cpackLog.err - ) - file(WRITE ${CTEST_BINARY_DIRECTORY}/cpack.log "${cpackLog.err}" "${cpackLog}") -endif(NOT LOCAL_MEMCHECK_TEST) -#----------------------------------------------------------------------------- - -message ("DONE") -EOF - - -# Run ctest -ctest -S $cfgfile -C Release -V -O $ctest_log -exit_code=$? -if [ $exit_code = 0 ]; then - echo CTest script completed without error -else - echo Error encountered CTest script -fi -# Using HDF5-*.sh because actual name is unavailable -install_sh=HDF5-*.sh -echo installing with $install_sh ... -./$install_sh --skip-license > $install_log -exit_code=$? -if [ $exit_code = 0 ]; then - echo Complete without error -else - echo Error encountered -fi -TIMESTAMP -exit $exit_code - -fi - -- cgit v0.12 From ddd91a7b1932d7efebcaba60d13beb5f237fc95d Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Mon, 14 Dec 2015 13:31:53 -0500 Subject: [svn-r28643] Add H5D_t pointer to chunk callback. Normalization for future single chunk indexing. Tested on: Ubuntu 15.10 (Linux 4.2.0 x86_64) gcc 5.2.1 serial only (these changes have been in revise_chunks for a long time) --- src/H5Dbtree.c | 5 +++-- src/H5Dchunk.c | 10 +++++----- src/H5Dpkg.h | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/H5Dbtree.c b/src/H5Dbtree.c index 30c3a28..e50a7ee 100644 --- a/src/H5Dbtree.c +++ b/src/H5Dbtree.c @@ -127,7 +127,7 @@ static herr_t H5D__btree_idx_init(const H5D_chk_idx_info_t *idx_info, static herr_t H5D__btree_idx_create(const H5D_chk_idx_info_t *idx_info); static hbool_t H5D__btree_idx_is_space_alloc(const H5O_storage_chunk_t *storage); static herr_t H5D__btree_idx_insert(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_ud_t *udata); + H5D_chunk_ud_t *udata, const H5D_t *dset); static herr_t H5D__btree_idx_get_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata); static int H5D__btree_idx_iterate(const H5D_chk_idx_info_t *idx_info, @@ -991,7 +991,8 @@ H5D__btree_idx_is_space_alloc(const H5O_storage_chunk_t *storage) *------------------------------------------------------------------------- */ static herr_t -H5D__btree_idx_insert(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata) +H5D__btree_idx_insert(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata, + const H5D_t H5_ATTR_UNUSED *dset) { herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index 4b33ebd..4ad6156 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -408,7 +408,7 @@ H5D__chunk_direct_write(const H5D_t *dset, hid_t dxpl_id, uint32_t filters, /* Set the chunk's filter mask to the new settings */ udata.filter_mask = filters; - if((layout->storage.u.chunk.ops->insert)(&idx_info, &udata) < 0) + if((layout->storage.u.chunk.ops->insert)(&idx_info, &udata, NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "unable to insert chunk addr into index") } /* end if */ @@ -2090,7 +2090,7 @@ H5D__chunk_write(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, } /* end if */ else { if(need_insert && io_info->dset->shared->layout.storage.u.chunk.ops->insert) - if((io_info->dset->shared->layout.storage.u.chunk.ops->insert)(&idx_info, &udata) < 0) + if((io_info->dset->shared->layout.storage.u.chunk.ops->insert)(&idx_info, &udata, NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "unable to insert chunk addr into index") } /* end else */ @@ -2714,7 +2714,7 @@ H5D__chunk_flush_entry(const H5D_t *dset, hid_t dxpl_id, const H5D_dxpl_cache_t /* Insert the chunk record into the index */ if(need_insert && dset->shared->layout.storage.u.chunk.ops->insert) - if((dset->shared->layout.storage.u.chunk.ops->insert)(&idx_info, &udata) < 0) + if((dset->shared->layout.storage.u.chunk.ops->insert)(&idx_info, &udata, dset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "unable to insert chunk addr into index") /* Cache the chunk's info, in case it's accessed again shortly */ @@ -3690,7 +3690,7 @@ H5D__chunk_allocate(const H5D_t *dset, hid_t dxpl_id, hbool_t full_overwrite, * serial operation. -QAK */ if(need_insert && ops->insert) - if((ops->insert)(&idx_info, &udata) < 0) + if((ops->insert)(&idx_info, &udata, dset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "unable to insert chunk addr into index") /* Increment indices and adjust the edge chunk state */ @@ -4822,7 +4822,7 @@ H5D__chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) /* Insert chunk record into index */ if(need_insert && udata->idx_info_dst->storage->ops->insert) - if((udata->idx_info_dst->storage->ops->insert)(udata->idx_info_dst, &udata_dst) < 0) + if((udata->idx_info_dst->storage->ops->insert)(udata->idx_info_dst, &udata_dst, NULL) < 0) HGOTO_ERROR_TAG(H5E_DATASET, H5E_CANTINSERT, H5_ITER_ERROR, "unable to insert chunk addr into index") /* Reset metadata tag in dxpl_id */ diff --git a/src/H5Dpkg.h b/src/H5Dpkg.h index f391e8c..e9e87af 100644 --- a/src/H5Dpkg.h +++ b/src/H5Dpkg.h @@ -276,7 +276,7 @@ typedef herr_t (*H5D_chunk_init_func_t)(const H5D_chk_idx_info_t *idx_info, typedef herr_t (*H5D_chunk_create_func_t)(const H5D_chk_idx_info_t *idx_info); typedef hbool_t (*H5D_chunk_is_space_alloc_func_t)(const H5O_storage_chunk_t *storage); typedef herr_t (*H5D_chunk_insert_func_t)(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_ud_t *udata); + H5D_chunk_ud_t *udata, const H5D_t *dset); typedef herr_t (*H5D_chunk_get_addr_func_t)(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata); typedef herr_t (*H5D_chunk_resize_func_t)(H5O_layout_chunk_t *layout); -- cgit v0.12 From 61cee5f91a60fa369165f378fe51ca677a300e74 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Mon, 14 Dec 2015 14:19:19 -0500 Subject: [svn-r28646] Minor normalization with revise_chunks. Also purged obsolete /*ARGSUSED*/ from the library. Tested on: Ubuntu 15.10 (Linux 4.2.0 x86_64) gcc 5.2.1 serial only (these changes have been in revise_chunks for a long time) --- src/H5A.c | 2 -- src/H5Dbtree.c | 6 ------ src/H5Dchunk.c | 3 --- src/H5Dcontig.c | 1 - src/H5Dint.c | 12 +++++------- src/H5EAdblkpage.c | 1 - src/H5EAdblock.c | 1 - src/H5EAiblock.c | 1 - src/H5EAsblock.c | 1 - src/H5FDfamily.c | 1 - src/H5Fint.c | 7 ++++--- src/H5Fprivate.h | 3 +-- src/H5Fsuper.c | 2 +- src/H5Pdcpl.c | 1 - src/H5Pdxpl.c | 3 --- src/H5Plapl.c | 6 ------ src/H5Pocpypl.c | 3 --- src/H5Tvlen.c | 12 ------------ src/H5Zfletcher32.c | 1 - src/H5Zshuffle.c | 1 - 20 files changed, 11 insertions(+), 57 deletions(-) diff --git a/src/H5A.c b/src/H5A.c index cc30319..7d87505 100644 --- a/src/H5A.c +++ b/src/H5A.c @@ -244,7 +244,6 @@ H5A_term_package(void) develop. --------------------------------------------------------------------------*/ -/* ARGSUSED */ hid_t H5Acreate2(hid_t loc_id, const char *attr_name, hid_t type_id, hid_t space_id, hid_t acpl_id, hid_t H5_ATTR_UNUSED aapl_id) @@ -319,7 +318,6 @@ done: develop. --------------------------------------------------------------------------*/ -/* ARGSUSED */ hid_t H5Acreate_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, hid_t type_id, hid_t space_id, hid_t acpl_id, hid_t H5_ATTR_UNUSED aapl_id, diff --git a/src/H5Dbtree.c b/src/H5Dbtree.c index e50a7ee..85238da 100644 --- a/src/H5Dbtree.c +++ b/src/H5Dbtree.c @@ -218,7 +218,6 @@ H5FL_DEFINE_STATIC(H5O_layout_chunk_t); * *------------------------------------------------------------------------- */ -/* ARGSUSED */ static H5UC_t * H5D__btree_get_shared(const H5F_t H5_ATTR_UNUSED *f, const void *_udata) { @@ -439,7 +438,6 @@ H5D__btree_cmp3(void *_lt_key, void *_udata, void *_rt_key) * *------------------------------------------------------------------------- */ -/* ARGSUSED */ static htri_t H5D__btree_found(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, const void *_lt_key, void *_udata) @@ -539,7 +537,6 @@ done: * *------------------------------------------------------------------------- */ -/* ARGSUSED */ static H5B_ins_t H5D__btree_insert(H5F_t *f, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, void *_lt_key, hbool_t *lt_key_changed, @@ -633,7 +630,6 @@ done: * *------------------------------------------------------------------------- */ -/* ARGSUSED */ static H5B_ins_t H5D__btree_remove(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_lt_key /*in,out */ , hbool_t *lt_key_changed /*out */ , @@ -761,7 +757,6 @@ H5D__btree_encode_key(const H5B_shared_t *shared, uint8_t *raw, const void *_key * *------------------------------------------------------------------------- */ -/* ARGSUSED */ static herr_t H5D__btree_debug_key(FILE *stream, int indent, int fwidth, const void *_key, const void *_udata) @@ -1072,7 +1067,6 @@ done: * *------------------------------------------------------------------------- */ -/* ARGSUSED */ static int H5D__btree_idx_iterate_cb(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, const void *_lt_key, haddr_t addr, const void H5_ATTR_UNUSED *_rt_key, diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index 4ad6156..ab621ca 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -1648,7 +1648,6 @@ done: * *------------------------------------------------------------------------- */ -/* ARGSUSED */ static herr_t H5D__chunk_mem_cb(void H5_ATTR_UNUSED *elem, const H5T_t H5_ATTR_UNUSED *type, unsigned ndims, const hsize_t *coords, void *_fm) { @@ -3309,7 +3308,6 @@ done: * *------------------------------------------------------------------------- */ -/* ARGSUSED */ static int H5D__chunk_allocated_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) { @@ -5184,7 +5182,6 @@ done: * *------------------------------------------------------------------------- */ -/* ARGSUSED */ static int H5D__chunk_dump_index_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) { diff --git a/src/H5Dcontig.c b/src/H5Dcontig.c index 988bb61..b5b9b0d 100644 --- a/src/H5Dcontig.c +++ b/src/H5Dcontig.c @@ -390,7 +390,6 @@ done: * *------------------------------------------------------------------------- */ -/* ARGSUSED */ static herr_t H5D__contig_construct(H5F_t *f, H5D_t *dset) { diff --git a/src/H5Dint.c b/src/H5Dint.c index b9899c8..4ec48bb 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -1847,7 +1847,7 @@ H5D__alloc_storage(const H5D_t *dset, hid_t dxpl_id, H5D_time_alloc_t time_alloc case H5D_CHUNKED: if(!(*dset->shared->layout.ops->is_space_alloc)(&dset->shared->layout.storage)) { - /* Create the root of the B-tree that describes chunked storage */ + /* Create the root of the index that manages chunked storage */ if(H5D__chunk_create(dset /*in,out*/, dxpl_id) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to initialize chunked storage") @@ -1860,7 +1860,7 @@ H5D__alloc_storage(const H5D_t *dset, hid_t dxpl_id, H5D_time_alloc_t time_alloc /* If space allocation is set to 'early' and we are extending * the dataset, indicate that space should be allocated, so the - * B-tree gets expanded. -QAK + * index gets expanded. -QAK */ if(dset->shared->dcpl_cache.fill.alloc_time == H5D_ALLOC_TIME_EARLY && time_alloc == H5D_ALLOC_EXTEND) @@ -1911,7 +1911,7 @@ H5D__alloc_storage(const H5D_t *dset, hid_t dxpl_id, H5D_time_alloc_t time_alloc /* Check if we need to initialize the space */ if(must_init_space) { if(layout->type == H5D_CHUNKED) { - /* If we are doing incremental allocation and the B-tree got + /* If we are doing incremental allocation and the index got * created during a H5Dwrite call, don't initialize the storage * now, wait for the actual writes to each block and let the * low-level chunking routines handle initialize the fill-values. @@ -1934,10 +1934,9 @@ H5D__alloc_storage(const H5D_t *dset, hid_t dxpl_id, H5D_time_alloc_t time_alloc /* If we are filling the dataset on allocation or "if set" and * the fill value _is_ set, do that now */ if(dset->shared->dcpl_cache.fill.fill_time == H5D_FILL_TIME_ALLOC || - (dset->shared->dcpl_cache.fill.fill_time == H5D_FILL_TIME_IFSET && fill_status == H5D_FILL_VALUE_USER_DEFINED)) { + (dset->shared->dcpl_cache.fill.fill_time == H5D_FILL_TIME_IFSET && fill_status == H5D_FILL_VALUE_USER_DEFINED)) if(H5D__init_storage(dset, full_overwrite, old_dim, dxpl_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize dataset with fill value") - } /* end if */ } /* end else */ } /* end if */ @@ -2253,7 +2252,6 @@ H5D__vlen_get_buf_size_alloc(size_t size, void *info) * *------------------------------------------------------------------------- */ -/* ARGSUSED */ herr_t H5D__vlen_get_buf_size(void H5_ATTR_UNUSED *elem, hid_t type_id, unsigned H5_ATTR_UNUSED ndim, const hsize_t *point, void *op_data) { @@ -2623,7 +2621,7 @@ H5D__mark(const H5D_t *dataset, hid_t H5_ATTR_UNUSED dxpl_id, unsigned flags) /* Update the layout on disk, if it's been changed */ if(flags & H5D_MARK_LAYOUT) { if(H5D__layout_oh_write(dataset, dxpl_id, oh, update_flags) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to update layout/pline/efl info") + HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to update layout info") /* Reset the "update the modification time" flag, so we only do it once */ update_flags = 0; diff --git a/src/H5EAdblkpage.c b/src/H5EAdblkpage.c index 15bad43..9f3b39a 100644 --- a/src/H5EAdblkpage.c +++ b/src/H5EAdblkpage.c @@ -290,7 +290,6 @@ END_FUNC(PKG) /* end H5EA__dblk_page_unprotect() */ * *------------------------------------------------------------------------- */ -/* ARGSUSED */ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__dblk_page_dest(H5EA_dblk_page_t *dblk_page)) diff --git a/src/H5EAdblock.c b/src/H5EAdblock.c index cd20bba..3eaaf1c 100644 --- a/src/H5EAdblock.c +++ b/src/H5EAdblock.c @@ -457,7 +457,6 @@ END_FUNC(PKG) /* end H5EA__dblock_delete() */ * *------------------------------------------------------------------------- */ -/* ARGSUSED */ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__dblock_dest(H5EA_dblock_t *dblock)) diff --git a/src/H5EAiblock.c b/src/H5EAiblock.c index 3f49d0d..623ae30 100644 --- a/src/H5EAiblock.c +++ b/src/H5EAiblock.c @@ -432,7 +432,6 @@ END_FUNC(PKG) /* end H5EA__iblock_delete() */ * *------------------------------------------------------------------------- */ -/* ARGSUSED */ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__iblock_dest(H5EA_iblock_t *iblock)) diff --git a/src/H5EAsblock.c b/src/H5EAsblock.c index 7753f0e..f775484 100644 --- a/src/H5EAsblock.c +++ b/src/H5EAsblock.c @@ -409,7 +409,6 @@ END_FUNC(PKG) /* end H5EA__sblock_delete() */ * *------------------------------------------------------------------------- */ -/* ARGSUSED */ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__sblock_dest(H5EA_sblock_t *sblock)) diff --git a/src/H5FDfamily.c b/src/H5FDfamily.c index 310b72f..b92a685 100644 --- a/src/H5FDfamily.c +++ b/src/H5FDfamily.c @@ -861,7 +861,6 @@ H5FD_family_cmp(const H5FD_t *_f1, const H5FD_t *_f2) * *------------------------------------------------------------------------- */ -/* ARGSUSED */ static herr_t H5FD_family_query(const H5FD_t * _file, unsigned long *flags /* out */) { diff --git a/src/H5Fint.c b/src/H5Fint.c index c17267d..94a5488 100644 --- a/src/H5Fint.c +++ b/src/H5Fint.c @@ -130,7 +130,7 @@ H5F_get_access_plist(H5F_t *f, hbool_t app_ref) H5FD_driver_prop_t driver_prop; /* Property for driver ID & info */ hbool_t driver_prop_copied = FALSE; /* Whether the driver property has been set up */ unsigned efc_size = 0; - hid_t ret_value = SUCCEED; + hid_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1052,6 +1052,7 @@ 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) { + /* Read the superblock if it hasn't been read before. */ if(H5F__super_read(file, dxpl_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_READERROR, NULL, "unable to read superblock") @@ -1099,8 +1100,8 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, 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/H5Fprivate.h b/src/H5Fprivate.h index 658d123..fae8b99 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -645,8 +645,7 @@ H5_DLL hid_t H5F_get_driver_id(const H5F_t *f); H5_DLL herr_t H5F_get_fileno(const H5F_t *f, unsigned long *filenum); H5_DLL hbool_t H5F_has_feature(const H5F_t *f, unsigned feature); H5_DLL haddr_t H5F_get_eoa(const H5F_t *f, H5FD_mem_t type); -H5_DLL herr_t H5F_get_vfd_handle(const H5F_t *file, hid_t fapl, - void **file_handle); +H5_DLL herr_t H5F_get_vfd_handle(const H5F_t *file, hid_t fapl, void **file_handle); /* Functions that check file mounting information */ H5_DLL hbool_t H5F_is_mount(const H5F_t *file); diff --git a/src/H5Fsuper.c b/src/H5Fsuper.c index c6b1c83..a0f9536 100644 --- a/src/H5Fsuper.c +++ b/src/H5Fsuper.c @@ -296,7 +296,7 @@ H5F__super_read(H5F_t *f, hid_t dxpl_id) /* Make certain we can read the fixed-size portion of the superblock */ if(H5F__set_eoa(f, H5FD_MEM_SUPER, - H5F_SUPERBLOCK_FIXED_SIZE + H5F_SUPERBLOCK_MINIMAL_VARLEN_SIZE) < 0) + (haddr_t)(H5F_SUPERBLOCK_FIXED_SIZE + H5F_SUPERBLOCK_MINIMAL_VARLEN_SIZE)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "set end of space allocation request failed") /* Set up the user data for cache callbacks */ diff --git a/src/H5Pdcpl.c b/src/H5Pdcpl.c index afef06b..145e1b5 100644 --- a/src/H5Pdcpl.c +++ b/src/H5Pdcpl.c @@ -288,7 +288,6 @@ done: * *------------------------------------------------------------------------- */ -/* ARGSUSED */ static herr_t H5P__dcrt_layout_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) diff --git a/src/H5Pdxpl.c b/src/H5Pdxpl.c index 9ab3580..d56a52a 100644 --- a/src/H5Pdxpl.c +++ b/src/H5Pdxpl.c @@ -858,7 +858,6 @@ done: * *------------------------------------------------------------------------- */ -/* ARGSUSED */ static herr_t H5P__dxfr_xform_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { @@ -890,7 +889,6 @@ done: * *------------------------------------------------------------------------- */ -/* ARGSUSED */ static herr_t H5P__dxfr_xform_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { @@ -977,7 +975,6 @@ done: * *------------------------------------------------------------------------- */ -/* ARGSUSED */ static herr_t H5P__dxfr_xform_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { diff --git a/src/H5Plapl.c b/src/H5Plapl.c index f70fe5e..b7c682c 100644 --- a/src/H5Plapl.c +++ b/src/H5Plapl.c @@ -451,7 +451,6 @@ done: * *-------------------------------------------------------------------------- */ -/* ARGSUSED */ static herr_t H5P__lacc_elink_fapl_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { @@ -488,7 +487,6 @@ done: * *-------------------------------------------------------------------------- */ -/* ARGSUSED */ static herr_t H5P__lacc_elink_fapl_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { @@ -578,7 +576,6 @@ done: * *--------------------------------------------------------------------------- */ -/* ARGSUSED */ static herr_t H5P__lacc_elink_fapl_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { @@ -785,7 +782,6 @@ done: * *------------------------------------------------------------------------- */ -/* ARGSUSED */ static herr_t H5P__lacc_elink_pref_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { @@ -811,7 +807,6 @@ H5P__lacc_elink_pref_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED * *------------------------------------------------------------------------- */ -/* ARGSUSED */ static herr_t H5P__lacc_elink_pref_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { @@ -872,7 +867,6 @@ done: * *------------------------------------------------------------------------- */ -/* ARGSUSED */ static herr_t H5P__lacc_elink_pref_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { diff --git a/src/H5Pocpypl.c b/src/H5Pocpypl.c index 7657d52..faa2a04 100644 --- a/src/H5Pocpypl.c +++ b/src/H5Pocpypl.c @@ -497,7 +497,6 @@ done: * *-------------------------------------------------------------------------- */ -/* ARGSUSED */ static herr_t H5P__ocpy_merge_comm_dt_list_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) @@ -527,7 +526,6 @@ H5P__ocpy_merge_comm_dt_list_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATT * *-------------------------------------------------------------------------- */ -/* ARGSUSED */ static herr_t H5P__ocpy_merge_comm_dt_list_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) @@ -616,7 +614,6 @@ done: * *--------------------------------------------------------------------------- */ -/* ARGSUSED */ static herr_t H5P__ocpy_merge_comm_dt_list_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { diff --git a/src/H5Tvlen.c b/src/H5Tvlen.c index 26346d6..2abdf6f 100644 --- a/src/H5Tvlen.c +++ b/src/H5Tvlen.c @@ -365,7 +365,6 @@ H5T_vlen_seq_mem_getptr(void *_vl) * *------------------------------------------------------------------------- */ -/* ARGSUSED */ static htri_t H5T_vlen_seq_mem_isnull(const H5F_t H5_ATTR_UNUSED *f, void *_vl) { @@ -403,7 +402,6 @@ H5T_vlen_seq_mem_isnull(const H5F_t H5_ATTR_UNUSED *f, void *_vl) * *------------------------------------------------------------------------- */ -/* ARGSUSED */ static herr_t H5T_vlen_seq_mem_read(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, void *_vl, void *buf, size_t len) { @@ -445,7 +443,6 @@ H5T_vlen_seq_mem_read(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, voi * *------------------------------------------------------------------------- */ -/* ARGSUSED */ static herr_t H5T_vlen_seq_mem_write(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, const H5T_vlen_alloc_info_t *vl_alloc_info, void *_vl, void *buf, void H5_ATTR_UNUSED *_bg, size_t seq_len, size_t base_size) { @@ -502,7 +499,6 @@ done: * *------------------------------------------------------------------------- */ -/* ARGSUSED */ static herr_t H5T_vlen_seq_mem_setnull(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, void *_vl, void H5_ATTR_UNUSED *_bg) { @@ -606,7 +602,6 @@ H5T_vlen_str_mem_getptr(void *_vl) * *------------------------------------------------------------------------- */ -/* ARGSUSED */ static htri_t H5T_vlen_str_mem_isnull(const H5F_t H5_ATTR_UNUSED *f, void *_vl) { @@ -638,7 +633,6 @@ H5T_vlen_str_mem_isnull(const H5F_t H5_ATTR_UNUSED *f, void *_vl) * *------------------------------------------------------------------------- */ -/* ARGSUSED */ static herr_t H5T_vlen_str_mem_read(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, void *_vl, void *buf, size_t len) { @@ -679,7 +673,6 @@ H5T_vlen_str_mem_read(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, voi * *------------------------------------------------------------------------- */ -/* ARGSUSED */ static herr_t H5T_vlen_str_mem_write(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, const H5T_vlen_alloc_info_t *vl_alloc_info, void *_vl, void *buf, void H5_ATTR_UNUSED *_bg, size_t seq_len, size_t base_size) { @@ -726,7 +719,6 @@ done: * *------------------------------------------------------------------------- */ -/* ARGSUSED */ static herr_t H5T_vlen_str_mem_setnull(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, void *_vl, void H5_ATTR_UNUSED *_bg) { @@ -782,7 +774,6 @@ H5T_vlen_disk_getlen(const void *_vl) * *------------------------------------------------------------------------- */ -/* ARGSUSED */ static void * H5T_vlen_disk_getptr(void H5_ATTR_UNUSED *vl) { @@ -840,7 +831,6 @@ H5T_vlen_disk_isnull(const H5F_t *f, void *_vl) * *------------------------------------------------------------------------- */ -/* ARGSUSED */ static herr_t H5T_vlen_disk_read(H5F_t *f, hid_t dxpl_id, void *_vl, void *buf, size_t H5_ATTR_UNUSED len) { @@ -886,7 +876,6 @@ done: * *------------------------------------------------------------------------- */ -/* ARGSUSED */ static herr_t H5T_vlen_disk_write(H5F_t *f, hid_t dxpl_id, const H5T_vlen_alloc_info_t H5_ATTR_UNUSED *vl_alloc_info, void *_vl, void *buf, void *_bg, size_t seq_len, size_t base_size) @@ -1146,7 +1135,6 @@ done: EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -/* ARGSUSED */ herr_t H5T_vlen_reclaim(void *elem, hid_t type_id, unsigned H5_ATTR_UNUSED ndim, const hsize_t H5_ATTR_UNUSED *point, void *op_data) { diff --git a/src/H5Zfletcher32.c b/src/H5Zfletcher32.c index 690d7a2..9ff85cc 100644 --- a/src/H5Zfletcher32.c +++ b/src/H5Zfletcher32.c @@ -70,7 +70,6 @@ const H5Z_class2_t H5Z_FLETCHER32[1] = {{ * with Release 1.6.2 and before. *------------------------------------------------------------------------- */ -/* ARGSUSED */ static size_t H5Z_filter_fletcher32 (unsigned flags, size_t H5_ATTR_UNUSED cd_nelmts, const unsigned H5_ATTR_UNUSED cd_values[], size_t nbytes, size_t *buf_size, void **buf) diff --git a/src/H5Zshuffle.c b/src/H5Zshuffle.c index 3fa6c8d..4cf6adf 100644 --- a/src/H5Zshuffle.c +++ b/src/H5Zshuffle.c @@ -61,7 +61,6 @@ const H5Z_class2_t H5Z_SHUFFLE[1] = {{ * *------------------------------------------------------------------------- */ -/* ARGSUSED */ static herr_t H5Z_set_local_shuffle(hid_t dcpl_id, hid_t type_id, hid_t H5_ATTR_UNUSED space_id) { -- cgit v0.12 From ae8e3348cfee076ddb1b1e24b5e4486481686cc5 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Tue, 15 Dec 2015 00:38:03 -0500 Subject: [svn-r28655] Updated MANIFEST :/ --- MANIFEST | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MANIFEST b/MANIFEST index a870613..3923060 100644 --- a/MANIFEST +++ b/MANIFEST @@ -643,9 +643,11 @@ ./src/H5HL.c ./src/H5HLcache.c ./src/H5HLdbg.c +./src/H5HLdblk.c ./src/H5HLint.c ./src/H5HLmodule.h ./src/H5HLpkg.h +./src/H5HLprfx.c ./src/H5HLprivate.h ./src/H5HLpublic.h ./src/H5HP.c -- cgit v0.12 From 410d8365d0650b3bc9113fbc9176978f83291fbe Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Tue, 15 Dec 2015 11:15:55 -0500 Subject: [svn-r28663] Merge of r28662 from revise_chunks. Whitespace only. --- src/H5B.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/H5B.c b/src/H5B.c index 7f933cd..b26c38b 100644 --- a/src/H5B.c +++ b/src/H5B.c @@ -612,6 +612,7 @@ H5B_insert(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void /* Check if the root node split */ if(H5B_INS_NOOP == my_ins) { + /* The root node did not split - just return */ HDassert(!split_bt_ud.bt); HGOTO_DONE(SUCCEED) } /* end if */ @@ -2035,7 +2036,7 @@ htri_t H5B_valid(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr) { H5B_t *bt = NULL; /* The B-tree */ - H5UC_t *rc_shared; /* Ref-counted shared info */ + H5UC_t *rc_shared; /* Ref-counted shared info */ H5B_shared_t *shared; /* Pointer to shared B-tree info */ H5B_cache_ud_t cache_udata; /* User-data for metadata cache callback */ htri_t ret_value = SUCCEED; /* Return value */ -- cgit v0.12 From b3426914a877877b43c90b6804130076ee1b3c2c Mon Sep 17 00:00:00 2001 From: Larry Knox Date: Tue, 15 Dec 2015 15:52:12 -0500 Subject: [svn-r28669] Changes to correct errors found with -ansi flag. h5tools_dump.c Removed 3 lines commented out with //. h5_vds-percival-unlim.c Changed C++-style comment to C-style comment. Tested with h5committest.new. --- examples/h5_vds-percival-unlim.c | 5 +++-- tools/lib/h5tools_dump.c | 3 --- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/examples/h5_vds-percival-unlim.c b/examples/h5_vds-percival-unlim.c index b5f3ebd..2496c37 100644 --- a/examples/h5_vds-percival-unlim.c +++ b/examples/h5_vds-percival-unlim.c @@ -288,8 +288,9 @@ main (void) /* Read all VDS data */ - //EIP We should be able to do it by using H5S_ALL instead of making selection - // or using H5Sselect_all from vspace. + /* EIP We should be able to do it by using H5S_ALL instead of making selection + * or using H5Sselect_all from vspace. + */ start[0] = 0; start[1] = 0; start[2] = 0; diff --git a/tools/lib/h5tools_dump.c b/tools/lib/h5tools_dump.c index 0d39981..1876e4f 100644 --- a/tools/lib/h5tools_dump.c +++ b/tools/lib/h5tools_dump.c @@ -1539,7 +1539,6 @@ h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info, h5tools_cont /* Hyperslab info */ hsize_t hs_offset[H5S_MAX_RANK]; /* starting offset */ hsize_t hs_size[H5S_MAX_RANK]; /* size this pass */ - //hsize_t hs_count[H5S_MAX_RANK]; /* size this pass */ hsize_t hs_nelmts; /* elements in request */ /* VL data special information */ @@ -1622,11 +1621,9 @@ h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info, h5tools_cont hs_size[i] = MIN(total_size[i] - hs_offset[i], sm_size[i]); ctx->p_max_idx[i] = ctx->p_min_idx[i] + hs_size[i]; hs_nelmts *= hs_size[i]; -// hs_count[i] = 1; } H5Sselect_hyperslab(f_space, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL); -// H5Sselect_hyperslab(f_space, H5S_SELECT_SET, hs_offset, NULL, hs_count, hs_size); H5Sselect_hyperslab(sm_space, H5S_SELECT_SET, zero, NULL, &hs_nelmts, NULL); } else { -- cgit v0.12 From 1ab7e61c392e471cbb3ec4cd5dfd1c375a2d4562 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Tue, 15 Dec 2015 21:27:35 -0500 Subject: [svn-r28678] Updated the cache_tagging test to correctly output tags in the debug/verbose function. Tested on: 64-bit Ubuntu 15.10 (Linux 4.2.0 x86_64) gcc 5.2.1 serial only --- test/cache_tagging.c | 124 +++++++++++++++++++++++++-------------------------- 1 file changed, 62 insertions(+), 62 deletions(-) diff --git a/test/cache_tagging.c b/test/cache_tagging.c index 80ba2eb..470f7a1 100644 --- a/test/cache_tagging.c +++ b/test/cache_tagging.c @@ -112,103 +112,105 @@ static unsigned check_invalid_tag_application(void); static void print_entry_type_to_screen(int id) { - printf("Type = "); + HDfprintf(stdout, "Type = "); switch (id) { - case 0: - printf("B-tree Node(0)"); + case H5AC_BT_ID: + HDfprintf(stdout, "v1 B-tree Node"); break; - case 1: - printf("Symbol Table Node(1)"); + case H5AC_SNODE_ID: + HDfprintf(stdout, "Symbol Table Node"); break; - case 2: - printf("Local Heap Prefix(2)"); + case H5AC_LHEAP_PRFX_ID: + HDfprintf(stdout, "Local Heap Prefix"); break; - case 3: - printf("Local Heap Data Block(3)"); + case H5AC_LHEAP_DBLK_ID: + HDfprintf(stdout, "Local Heap Data Block"); break; - case 4: - printf("Global Heap(4)"); + case H5AC_GHEAP_ID: + HDfprintf(stdout, "Global Heap"); break; - case 5: - printf("Object Header(5)"); + case H5AC_OHDR_ID: + HDfprintf(stdout, "Object Header"); break; - case 6: - printf("Object Header Chunk(6)"); + case H5AC_OHDR_CHK_ID: + HDfprintf(stdout, "Object Header Chunk"); break; - case 7: - printf("v2 B-tree Header(7)"); + case H5AC_BT2_HDR_ID: + HDfprintf(stdout, "v2 B-tree Header"); break; - case 8: - printf("v2 B-tree Internal Node(8)"); + case H5AC_BT2_INT_ID: + HDfprintf(stdout, "v2 B-tree Internal Node"); break; - case 9: - printf("v2 B-tree Leaf Node(9)"); + case H5AC_BT2_LEAF_ID: + HDfprintf(stdout, "v2 B-tree Leaf Node"); break; - case 10: - printf("Fractal Heap Header(10)"); + case H5AC_FHEAP_HDR_ID: + HDfprintf(stdout, "Fractal Heap Header"); break; - case 11: - printf("Fractal Heap Direct Block(11)"); + case H5AC_FHEAP_DBLOCK_ID: + HDfprintf(stdout, "Fractal Heap Direct Block"); break; - case 12: - printf("Fractal Heap Indirect Block(12)"); + case H5AC_FHEAP_IBLOCK_ID: + HDfprintf(stdout, "Fractal Heap Indirect Block"); break; - case 13: - printf("Free Space Header(13)"); + case H5AC_FSPACE_HDR_ID: + HDfprintf(stdout, "Free Space Header"); break; - case 14: - printf("Free Space Section(14)"); + case H5AC_FSPACE_SINFO_ID: + HDfprintf(stdout, "Free Space Section"); break; - case 15: - printf("Shared Object Header Message Master Table(15)"); + case H5AC_SOHM_TABLE_ID: + HDfprintf(stdout, "Shared Object Header Message Master Table"); break; - case 16: - printf("Shared Message Index Stored As A List(16)"); + case H5AC_SOHM_LIST_ID: + HDfprintf(stdout, "Shared Message Index Stored As A List"); break; - case 17: - printf("Extensible Array Header(17)"); + case H5AC_EARRAY_HDR_ID: + HDfprintf(stdout, "Extensible Array Header"); break; - case 18: - printf("Extensible Array Index Block(18)"); + case H5AC_EARRAY_IBLOCK_ID: + HDfprintf(stdout, "Extensible Array Index Block"); break; - case 19: - printf("Extensible Array Super Block(19)"); + case H5AC_EARRAY_SBLOCK_ID: + HDfprintf(stdout, "Extensible Array Super Block"); break; - case 20: - printf("Extensible Array Data Block(20)"); + case H5AC_EARRAY_DBLOCK_ID: + HDfprintf(stdout, "Extensible Array Data Block"); break; - case 21: - printf("Extensible Array Data Block Page(21)"); + case H5AC_EARRAY_DBLK_PAGE_ID: + HDfprintf(stdout, "Extensible Array Data Block Page"); break; - case 22: - printf("Chunk Proxy(22)"); + case H5AC_FARRAY_HDR_ID: + HDfprintf(stdout, "Fixed Array Header"); break; - case 23: - printf("Fixed Array Header(23)"); + case H5AC_FARRAY_DBLOCK_ID: + HDfprintf(stdout, "Fixed Array Data Block"); break; - case 24: - printf("Fixed Array Data Block(24)"); + case H5AC_FARRAY_DBLK_PAGE_ID: + HDfprintf(stdout, "Fixed Array Data Block Page"); break; - case 25: - printf("Fixed Array Data Block Page(25)"); + case H5AC_SUPERBLOCK_ID: + HDfprintf(stdout, "File Superblock"); break; - case 26: - printf("File Superblock(26)"); + case H5AC_DRVRINFO_ID: + HDfprintf(stdout, "Driver Info Block"); break; - case 27: - printf("Test Entry(27)"); + case H5AC_TEST_ID: + HDfprintf(stdout, "Test Entry"); break; - case 28: - printf("Number of Types(28)"); + case H5AC_NTYPES: + HDfprintf(stdout, "BADNESS: Number of Types"); break; default: - printf("*Unknown*"); + HDfprintf(stdout, "BADNESS: *Unknown*"); break; } /* end switch */ + HDfprintf(stdout, " (%d)", id); + } /* print_entry_type_to_screen */ @@ -225,8 +227,6 @@ print_entry_type_to_screen(int id) * Programmer: Mike McGreevy * January 25, 2010 * - * Modifications: - * *------------------------------------------------------------------------- */ static int print_index(hid_t fid) { -- cgit v0.12 From 0a00732c4d9ba64a0507fd5dfe73929496383074 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Thu, 17 Dec 2015 01:31:27 -0500 Subject: [svn-r28696] Minor normalization with revise_chunks. Tested on: 64-bit Ubuntu 15.10 (Linux 4.2.0 x86_64) gcc 5.2.1 serial only --- src/H5AC.c | 1 + test/accum.c | 118 +++++++++++++++++++++---------------------- test/links.c | 11 ++-- test/objcopy.c | 54 +++++++++++--------- test/ohdr.c | 8 +-- tools/h5dump/h5dumpgentest.c | 24 +++------ 6 files changed, 106 insertions(+), 110 deletions(-) diff --git a/src/H5AC.c b/src/H5AC.c index 93f1ee4..f5b331f 100644 --- a/src/H5AC.c +++ b/src/H5AC.c @@ -46,6 +46,7 @@ #include "H5FDprivate.h" /* File drivers */ #include "H5Iprivate.h" /* IDs */ #include "H5Pprivate.h" /* Property lists */ +#include "H5SLprivate.h" /* Skip Lists */ /****************/ diff --git a/test/accum.c b/test/accum.c index 268b7e1..edfc751 100644 --- a/test/accum.c +++ b/test/accum.c @@ -164,7 +164,7 @@ test_write_read(const H5F_io_info_t *fio_info) /* Allocate buffers */ write_buf = (int *)HDmalloc(1024 * sizeof(int)); HDassert(write_buf); - read_buf = (int *)HDcalloc(1024, sizeof(int)); + read_buf = (int *)HDcalloc((size_t)1024, sizeof(int)); HDassert(read_buf); /* Fill buffer with data, zero out read buffer */ @@ -175,7 +175,7 @@ test_write_read(const H5F_io_info_t *fio_info) /* Write 1KB at Address 0 */ if(accum_write(0, 1024, write_buf) < 0) FAIL_STACK_ERROR; if(accum_read(0, 1024, read_buf) < 0) FAIL_STACK_ERROR; - if(HDmemcmp(write_buf, read_buf, 1024) != 0) TEST_ERROR; + if(HDmemcmp(write_buf, read_buf, (size_t)1024) != 0) TEST_ERROR; if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR; @@ -220,7 +220,7 @@ test_write_read_nonacc_front(const H5F_io_info_t *fio_info) /* Allocate buffers */ write_buf = (int *)HDmalloc(2048 * sizeof(int)); HDassert(write_buf); - read_buf = (int *)HDcalloc(2048, sizeof(int)); + read_buf = (int *)HDcalloc((size_t)2048, sizeof(int)); HDassert(read_buf); /* Fill buffer with data, zero out read buffer */ @@ -234,7 +234,7 @@ test_write_read_nonacc_front(const H5F_io_info_t *fio_info) if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR; if(accum_write(1024, 1024, write_buf) < 0) FAIL_STACK_ERROR; if(accum_read(0, 1024, read_buf) < 0) FAIL_STACK_ERROR; - if(HDmemcmp(write_buf, read_buf, 1024) != 0) TEST_ERROR; + if(HDmemcmp(write_buf, read_buf, (size_t)1024) != 0) TEST_ERROR; if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR; @@ -279,7 +279,7 @@ test_write_read_nonacc_end(const H5F_io_info_t *fio_info) /* Allocate buffers */ write_buf = (int *)HDmalloc(2048 * sizeof(int)); HDassert(write_buf); - read_buf = (int *)HDcalloc(2048, sizeof(int)); + read_buf = (int *)HDcalloc((size_t)2048, sizeof(int)); HDassert(read_buf); /* Fill buffer with data, zero out read buffer */ @@ -293,7 +293,7 @@ test_write_read_nonacc_end(const H5F_io_info_t *fio_info) if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR; if(accum_write(0, 1024, write_buf) < 0) FAIL_STACK_ERROR; if(accum_read(1024, 1024, read_buf) < 0) FAIL_STACK_ERROR; - if(HDmemcmp(write_buf, read_buf, 1024) != 0) TEST_ERROR; + if(HDmemcmp(write_buf, read_buf, (size_t)1024) != 0) TEST_ERROR; if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR; @@ -525,7 +525,7 @@ test_accum_overlap(const H5F_io_info_t *fio_info) /* Allocate buffers */ wbuf = (int32_t *)HDmalloc(4096 * sizeof(int32_t)); HDassert(wbuf); - rbuf = (int32_t *)HDcalloc(4096, sizeof(int32_t)); + rbuf = (int32_t *)HDcalloc((size_t)4096, sizeof(int32_t)); HDassert(rbuf); /* Case 1: No metadata in accumulator */ @@ -697,7 +697,7 @@ test_accum_overlap_clean(const H5F_io_info_t *fio_info) /* Allocate buffers */ wbuf = (int32_t *)HDmalloc(4096 * sizeof(int32_t)); HDassert(wbuf); - rbuf = (int32_t *)HDcalloc(4096, sizeof(int32_t)); + rbuf = (int32_t *)HDcalloc((size_t)4096, sizeof(int32_t)); HDassert(rbuf); /* Case 1: No metadata in accumulator */ @@ -876,7 +876,7 @@ test_accum_non_overlap_size(const H5F_io_info_t *fio_info) /* Allocate buffers */ wbuf = (int *)HDmalloc(4096 * sizeof(int32_t)); HDassert(wbuf); - rbuf = (int *)HDcalloc(4096, sizeof(int32_t)); + rbuf = (int *)HDcalloc((size_t)4096, sizeof(int32_t)); HDassert(rbuf); /* Case 1: No metadata in accumulator */ @@ -943,7 +943,7 @@ test_accum_overlap_size(const H5F_io_info_t *fio_info) /* Allocate buffers */ wbuf = (int32_t *)HDmalloc(4096 * sizeof(int32_t)); HDassert(wbuf); - rbuf = (int32_t *)HDcalloc(4096, sizeof(int32_t)); + rbuf = (int32_t *)HDcalloc((size_t)4096, sizeof(int32_t)); HDassert(rbuf); /* Case 1: No metadata in accumulator */ @@ -1050,11 +1050,11 @@ test_accum_adjust(const H5F_io_info_t *fio_info) /* Read back and verify first write */ if(accum_read((1024 * 1024), (1024 * 1024) - 1, rbuf) < 0) FAIL_STACK_ERROR; - if(HDmemcmp(wbuf, rbuf, (1024 * 1024) - 1) != 0) TEST_ERROR; + if(HDmemcmp(wbuf, rbuf, (size_t)((1024 * 1024) - 1)) != 0) TEST_ERROR; /* Read back and verify second write */ if(accum_read((1024 * 1024) - 1024, 1024, rbuf) < 0) FAIL_STACK_ERROR; - if(HDmemcmp(wbuf, rbuf, 1024) != 0) TEST_ERROR; + if(HDmemcmp(wbuf, rbuf, (size_t)1024) != 0) TEST_ERROR; /* Reset accumulator for next case */ if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR; @@ -1080,10 +1080,10 @@ test_accum_adjust(const H5F_io_info_t *fio_info) /* Read back and verify both pieces of data */ if(accum_read(1048576, 1048575, rbuf) < 0) FAIL_STACK_ERROR; - if(HDmemcmp(wbuf, rbuf, 1048576) != 0) TEST_ERROR; + if(HDmemcmp(wbuf, rbuf, (size_t)1048576) != 0) TEST_ERROR; if(accum_read(5, 1048571, rbuf) < 0) FAIL_STACK_ERROR; - if(HDmemcmp(wbuf, rbuf, 1048571) != 0) TEST_ERROR; + if(HDmemcmp(wbuf, rbuf, (size_t)1048571) != 0) TEST_ERROR; /* Reset accumulator for next case */ if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR; @@ -1118,7 +1118,7 @@ test_accum_adjust(const H5F_io_info_t *fio_info) /* Read in the piece we wrote to disk above, and then verify that the data is as expected */ if(accum_read((1024 * 1024) - 1, 1024, rbuf) < 0) FAIL_STACK_ERROR; - if(HDmemcmp(wbuf, rbuf, 1024) != 0) TEST_ERROR; + if(HDmemcmp(wbuf, rbuf, (size_t)1024) != 0) TEST_ERROR; /* Reset accumulator for next case */ if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR; @@ -1158,7 +1158,7 @@ test_accum_adjust(const H5F_io_info_t *fio_info) /* Read in the piece we wrote to disk above, and then verify that the data is as expected */ if(accum_read(1048571, 349523, rbuf) < 0) FAIL_STACK_ERROR; - if(HDmemcmp(wbuf, rbuf, 349523) != 0) TEST_ERROR; + if(HDmemcmp(wbuf, rbuf, (size_t)349523) != 0) TEST_ERROR; /* Reset accumulator for next case */ if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR; @@ -1195,7 +1195,7 @@ test_accum_adjust(const H5F_io_info_t *fio_info) /* Read in the piece we wrote to disk above, and then verify that the data is as expected */ if(accum_read((1024 * 1024) - 5, 10, rbuf) < 0) FAIL_STACK_ERROR; - if(HDmemcmp(wbuf, rbuf, 10) != 0) TEST_ERROR; + if(HDmemcmp(wbuf, rbuf, (size_t)10) != 0) TEST_ERROR; /* Reset accumulator for next case */ if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR; @@ -1227,7 +1227,7 @@ test_accum_adjust(const H5F_io_info_t *fio_info) /* Read in the piece we wrote to disk above, and then verify that the data is as expected */ if(accum_read(1048571, 349523, rbuf) < 0) FAIL_STACK_ERROR; - if(HDmemcmp(wbuf, rbuf, 349523) != 0) TEST_ERROR; + if(HDmemcmp(wbuf, rbuf, (size_t)349523) != 0) TEST_ERROR; if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR; @@ -1310,7 +1310,7 @@ test_read_after(const H5F_io_info_t *fio_info) /* Read in the piece we wrote to disk above, and then verify that the data is as expected */ if(accum_read(512, 512, rbuf) < 0) FAIL_STACK_ERROR; - if(HDmemcmp(wbuf, rbuf, 128) != 0) TEST_ERROR; + if(HDmemcmp(wbuf, rbuf, (size_t)128) != 0) TEST_ERROR; if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR; @@ -1352,13 +1352,13 @@ test_big(const H5F_io_info_t *fio_info) unsigned u; /* Local index variable */ /* Allocate space for the write & read buffers */ - wbuf = (uint8_t *)HDmalloc(BIG_BUF_SIZE); + wbuf = (uint8_t *)HDmalloc((size_t)BIG_BUF_SIZE); HDassert(wbuf); - wbuf2 = (uint8_t *)HDmalloc(BIG_BUF_SIZE); + wbuf2 = (uint8_t *)HDmalloc((size_t)BIG_BUF_SIZE); HDassert(wbuf2); - rbuf = (uint8_t *)HDcalloc(BIG_BUF_SIZE + 1536, 1); + rbuf = (uint8_t *)HDcalloc((size_t)(BIG_BUF_SIZE + 1536), (size_t)1); HDassert(rbuf); - zbuf = (uint8_t *)HDcalloc(BIG_BUF_SIZE + 1536, 1); + zbuf = (uint8_t *)HDcalloc((size_t)(BIG_BUF_SIZE + 1536), (size_t)1); HDassert(zbuf); /* Initialize write buffers */ @@ -1376,12 +1376,12 @@ test_big(const H5F_io_info_t *fio_info) if(accum_read(0, BIG_BUF_SIZE, rbuf) < 0) FAIL_STACK_ERROR; /* Verify data read */ - if(HDmemcmp(wbuf, rbuf, BIG_BUF_SIZE) != 0) TEST_ERROR; + if(HDmemcmp(wbuf, rbuf, (size_t)BIG_BUF_SIZE) != 0) TEST_ERROR; /* Reset data in file back to zeros & reset the read buffer */ if(accum_write(0, BIG_BUF_SIZE, zbuf) < 0) FAIL_STACK_ERROR; - HDmemset(rbuf, 0, BIG_BUF_SIZE); + HDmemset(rbuf, 0, (size_t)BIG_BUF_SIZE); if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR; @@ -1393,14 +1393,14 @@ test_big(const H5F_io_info_t *fio_info) if(accum_read(0, BIG_BUF_SIZE, rbuf) < 0) FAIL_STACK_ERROR; /* Verify data read */ - if(HDmemcmp(zbuf, rbuf, 1024) != 0) TEST_ERROR; - if(HDmemcmp(wbuf, rbuf + 1024, 1024) != 0) TEST_ERROR; - if(HDmemcmp(zbuf, rbuf + 2048, (BIG_BUF_SIZE - 2048)) != 0) TEST_ERROR; + if(HDmemcmp(zbuf, rbuf, (size_t)1024) != 0) TEST_ERROR; + if(HDmemcmp(wbuf, rbuf + 1024, (size_t)1024) != 0) TEST_ERROR; + if(HDmemcmp(zbuf, rbuf + 2048, (size_t)(BIG_BUF_SIZE - 2048)) != 0) TEST_ERROR; /* Reset data in file back to zeros & reset the read buffer */ if(accum_write(1024, 1024, zbuf) < 0) FAIL_STACK_ERROR; - HDmemset(rbuf, 0, BIG_BUF_SIZE); + HDmemset(rbuf, 0, (size_t)BIG_BUF_SIZE); if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR; @@ -1412,13 +1412,13 @@ test_big(const H5F_io_info_t *fio_info) if(accum_read(0, BIG_BUF_SIZE, rbuf) < 0) FAIL_STACK_ERROR; /* Verify data read */ - if(HDmemcmp(zbuf, rbuf, (BIG_BUF_SIZE - 512)) != 0) TEST_ERROR; - if(HDmemcmp(wbuf, rbuf + (BIG_BUF_SIZE - 512), 512) != 0) TEST_ERROR; + if(HDmemcmp(zbuf, rbuf, (size_t)(BIG_BUF_SIZE - 512)) != 0) TEST_ERROR; + if(HDmemcmp(wbuf, rbuf + (BIG_BUF_SIZE - 512), (size_t)512) != 0) TEST_ERROR; /* Reset data in file back to zeros & reset the read buffer */ if(accum_write(BIG_BUF_SIZE - 512, 1024, zbuf) < 0) FAIL_STACK_ERROR; - HDmemset(rbuf, 0, BIG_BUF_SIZE); + HDmemset(rbuf, 0, (size_t)BIG_BUF_SIZE); if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR; @@ -1430,13 +1430,13 @@ test_big(const H5F_io_info_t *fio_info) if(accum_read(512, BIG_BUF_SIZE, rbuf) < 0) FAIL_STACK_ERROR; /* Verify data read */ - if(HDmemcmp(wbuf + 512, rbuf, 512) != 0) TEST_ERROR; - if(HDmemcmp(zbuf, rbuf + 512, (BIG_BUF_SIZE - 512)) != 0) TEST_ERROR; + if(HDmemcmp(wbuf + 512, rbuf, (size_t)512) != 0) TEST_ERROR; + if(HDmemcmp(zbuf, rbuf + 512, (size_t)(BIG_BUF_SIZE - 512)) != 0) TEST_ERROR; /* Reset data in file back to zeros & reset the read buffer */ if(accum_write(0, 1024, zbuf) < 0) FAIL_STACK_ERROR; - HDmemset(rbuf, 0, BIG_BUF_SIZE); + HDmemset(rbuf, 0, (size_t)BIG_BUF_SIZE); if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR; @@ -1453,12 +1453,12 @@ test_big(const H5F_io_info_t *fio_info) if(accum_read(0, BIG_BUF_SIZE, rbuf) < 0) FAIL_STACK_ERROR; /* Verify data read */ - if(HDmemcmp(wbuf2, rbuf, BIG_BUF_SIZE) != 0) TEST_ERROR; + if(HDmemcmp(wbuf2, rbuf, (size_t)BIG_BUF_SIZE) != 0) TEST_ERROR; /* Reset data in file back to zeros & reset the read buffer */ if(accum_write(0, BIG_BUF_SIZE, zbuf) < 0) FAIL_STACK_ERROR; - HDmemset(rbuf, 0, BIG_BUF_SIZE); + HDmemset(rbuf, 0, (size_t)BIG_BUF_SIZE); if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR; @@ -1475,13 +1475,13 @@ test_big(const H5F_io_info_t *fio_info) if(accum_read(0, BIG_BUF_SIZE + 512, rbuf) < 0) FAIL_STACK_ERROR; /* Verify data read */ - if(HDmemcmp(wbuf2, rbuf, BIG_BUF_SIZE) != 0) TEST_ERROR; - if(HDmemcmp(wbuf + 512, rbuf + BIG_BUF_SIZE, 512) != 0) TEST_ERROR; + if(HDmemcmp(wbuf2, rbuf, (size_t)BIG_BUF_SIZE) != 0) TEST_ERROR; + if(HDmemcmp(wbuf + 512, rbuf + BIG_BUF_SIZE, (size_t)512) != 0) TEST_ERROR; /* Reset data in file back to zeros & reset the read buffer */ if(accum_write(0, BIG_BUF_SIZE + 512, zbuf) < 0) FAIL_STACK_ERROR; - HDmemset(rbuf, 0, BIG_BUF_SIZE + 512); + HDmemset(rbuf, 0, (size_t)(BIG_BUF_SIZE + 512)); if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR; @@ -1502,14 +1502,14 @@ test_big(const H5F_io_info_t *fio_info) if(accum_read(0, BIG_BUF_SIZE + 1024, rbuf) < 0) FAIL_STACK_ERROR; /* Verify data read */ - if(HDmemcmp(wbuf2, rbuf, BIG_BUF_SIZE) != 0) TEST_ERROR; - if(HDmemcmp(zbuf, rbuf + BIG_BUF_SIZE, 512) != 0) TEST_ERROR; - if(HDmemcmp(wbuf, rbuf + BIG_BUF_SIZE + 512, 512) != 0) TEST_ERROR; + if(HDmemcmp(wbuf2, rbuf, (size_t)BIG_BUF_SIZE) != 0) TEST_ERROR; + if(HDmemcmp(zbuf, rbuf + BIG_BUF_SIZE, (size_t)512) != 0) TEST_ERROR; + if(HDmemcmp(wbuf, rbuf + BIG_BUF_SIZE + 512, (size_t)512) != 0) TEST_ERROR; /* Reset data in file back to zeros & reset the read buffer */ if(accum_write(0, BIG_BUF_SIZE + 1536, zbuf) < 0) FAIL_STACK_ERROR; - HDmemset(rbuf, 0, BIG_BUF_SIZE + 1024); + HDmemset(rbuf, 0, (size_t)(BIG_BUF_SIZE + 1024)); if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR; @@ -1531,13 +1531,13 @@ test_big(const H5F_io_info_t *fio_info) if(accum_read(0, BIG_BUF_SIZE + 1536, rbuf) < 0) FAIL_STACK_ERROR; /* Verify data read */ - if(HDmemcmp(zbuf, rbuf, 1536) != 0) TEST_ERROR; - if(HDmemcmp(wbuf2, rbuf + 1536, BIG_BUF_SIZE) != 0) TEST_ERROR; + if(HDmemcmp(zbuf, rbuf, (size_t)1536) != 0) TEST_ERROR; + if(HDmemcmp(wbuf2, rbuf + 1536, (size_t)BIG_BUF_SIZE) != 0) TEST_ERROR; /* Reset data in file back to zeros & reset the read buffer */ if(accum_write(1536, BIG_BUF_SIZE, zbuf) < 0) FAIL_STACK_ERROR; - HDmemset(rbuf, 0, BIG_BUF_SIZE + 1536); + HDmemset(rbuf, 0, (size_t)(BIG_BUF_SIZE + 1536)); if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR; @@ -1558,13 +1558,13 @@ test_big(const H5F_io_info_t *fio_info) if(accum_read(0, BIG_BUF_SIZE + 512, rbuf) < 0) FAIL_STACK_ERROR; /* Verify data read */ - if(HDmemcmp(zbuf, rbuf, 512) != 0) TEST_ERROR; - if(HDmemcmp(wbuf2, rbuf + 512, BIG_BUF_SIZE) != 0) TEST_ERROR; + if(HDmemcmp(zbuf, rbuf, (size_t)512) != 0) TEST_ERROR; + if(HDmemcmp(wbuf2, rbuf + 512, (size_t)BIG_BUF_SIZE) != 0) TEST_ERROR; /* Reset data in file back to zeros & reset the read buffer */ if(accum_write(512, BIG_BUF_SIZE, zbuf) < 0) FAIL_STACK_ERROR; - HDmemset(rbuf, 0, BIG_BUF_SIZE + 512); + HDmemset(rbuf, 0, (size_t)(BIG_BUF_SIZE + 512)); if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR; @@ -1585,14 +1585,14 @@ test_big(const H5F_io_info_t *fio_info) if(accum_read(0, BIG_BUF_SIZE + 1536, rbuf) < 0) FAIL_STACK_ERROR; /* Verify data read */ - if(HDmemcmp(wbuf, rbuf, 1024) != 0) TEST_ERROR; - if(HDmemcmp(zbuf, rbuf + 1024, 512) != 0) TEST_ERROR; - if(HDmemcmp(wbuf2, rbuf + 1536, BIG_BUF_SIZE) != 0) TEST_ERROR; + if(HDmemcmp(wbuf, rbuf, (size_t)1024) != 0) TEST_ERROR; + if(HDmemcmp(zbuf, rbuf + 1024, (size_t)512) != 0) TEST_ERROR; + if(HDmemcmp(wbuf2, rbuf + 1536, (size_t)BIG_BUF_SIZE) != 0) TEST_ERROR; /* Reset data in file back to zeros & reset the read buffer */ if(accum_write(0, BIG_BUF_SIZE + 1536, zbuf) < 0) FAIL_STACK_ERROR; - HDmemset(rbuf, 0, BIG_BUF_SIZE + 1536); + HDmemset(rbuf, 0, (size_t)(BIG_BUF_SIZE + 1536)); if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR; @@ -1613,8 +1613,8 @@ test_big(const H5F_io_info_t *fio_info) if(accum_read(0, BIG_BUF_SIZE + 512, rbuf) < 0) FAIL_STACK_ERROR; /* Verify data read */ - if(HDmemcmp(wbuf, rbuf, 512) != 0) TEST_ERROR; - if(HDmemcmp(wbuf2, rbuf + 512, BIG_BUF_SIZE) != 0) TEST_ERROR; + if(HDmemcmp(wbuf, rbuf, (size_t)512) != 0) TEST_ERROR; + if(HDmemcmp(wbuf2, rbuf + 512, (size_t)BIG_BUF_SIZE) != 0) TEST_ERROR; if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR; @@ -1666,9 +1666,9 @@ test_random_write(const H5F_io_info_t *fio_info) unsigned u; /* Local index variable */ /* Allocate space for the write & read buffers */ - wbuf = (uint8_t *)HDmalloc(RANDOM_BUF_SIZE); + wbuf = (uint8_t *)HDmalloc((size_t)RANDOM_BUF_SIZE); HDassert(wbuf); - rbuf = (uint8_t *)HDcalloc(RANDOM_BUF_SIZE, 1); + rbuf = (uint8_t *)HDcalloc((size_t)RANDOM_BUF_SIZE, (size_t)1); HDassert(rbuf); /* Initialize write buffer */ @@ -1752,7 +1752,7 @@ HDfprintf(stderr, "Random # seed was: %u\n", seed); if(accum_read(RANDOM_BASE_OFF, RANDOM_BUF_SIZE, rbuf) < 0) FAIL_STACK_ERROR; /* Verify data read back in */ - if(HDmemcmp(wbuf, rbuf, RANDOM_BUF_SIZE) != 0) TEST_ERROR; + if(HDmemcmp(wbuf, rbuf, (size_t)RANDOM_BUF_SIZE) != 0) TEST_ERROR; if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR; diff --git a/test/links.c b/test/links.c index db5922b..2886304 100644 --- a/test/links.c +++ b/test/links.c @@ -3848,7 +3848,6 @@ external_set_elink_fapl3(hbool_t new_format) { hid_t core_fapl = -1, stdio_fapl = -1; hid_t lapl_id = -1, new_lapl_id = -1, l_fapl = -1, out_fapl; - int ret; if(new_format) TESTING("H5Pset/get_fapl() (w/new group format)") @@ -3907,11 +3906,11 @@ external_set_elink_fapl3(hbool_t new_format) error: H5E_BEGIN_TRY { - H5Pclose(l_fapl); - H5Pclose(lapl_id); - H5Pclose(new_lapl_id); - H5Pclose(core_fapl); - H5Pclose(stdio_fapl); + H5Pclose(l_fapl); + H5Pclose(lapl_id); + H5Pclose(new_lapl_id); + H5Pclose(core_fapl); + H5Pclose(stdio_fapl); } H5E_END_TRY; return -1; } /* end external_set_elink_fapl3() */ diff --git a/test/objcopy.c b/test/objcopy.c index 82be446..f3806cd 100644 --- a/test/objcopy.c +++ b/test/objcopy.c @@ -1243,12 +1243,11 @@ compare_datasets(hid_t did, hid_t did2, hid_t pid, const void *wbuf) if(offset1 != offset2) TEST_ERROR if(size1 != size2) TEST_ERROR - if(strcmp(name1, name2) != 0) TEST_ERROR + if(HDstrcmp(name1, name2) != 0) TEST_ERROR } - /* Remove external file information from the dcpls */ - - /* reset external file information from the dcpls */ + /* Reset external file information from the dcpls */ + /* (Directly removing default property causes memory leak) */ if (H5P_reset_external_file_test(dcpl) < 0) TEST_ERROR if (H5P_reset_external_file_test(dcpl2) < 0) TEST_ERROR } @@ -2311,7 +2310,7 @@ test_copy_dataset_compound(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t #endif /* H5_CLEAR_MEMORY */ for(i = 0; i < DIM_SIZE_1; i++) { buf[i].a = i; - buf[i].d = 1.0F / (i + 1); + buf[i].d = (double)1.0F / (double)(i + 1); } /* end for */ /* Initialize the filenames */ @@ -2443,9 +2442,9 @@ test_copy_dataset_chunked(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t /* set initial data values */ for(i = 0; i < DIM_SIZE_1; i++) { - buf1d[i] = (float)(i / 2.0F); + buf1d[i] = (float)i / 2.0F; for(j = 0; j < DIM_SIZE_2; j++) - buf2d[i][j] = (float)(i + (j / 100.0F)); + buf2d[i][j] = (float)i + ((float)j / 100.0F); } /* end for */ /* Initialize the filenames */ @@ -2695,10 +2694,10 @@ test_copy_dataset_chunked_empty(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, if(H5Ocopy(fid_src, NAME_DATASET_CHUNKED, fid_dst, NAME_DATASET_CHUNKED, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR if(H5Ocopy(fid_src, NAME_DATASET_CHUNKED2, fid_dst, NAME_DATASET_CHUNKED2, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - /* open the dataset for copy */ + /* open the dataset NAME_DATASET_CHUNKED in SRC file */ if((did = H5Dopen2(fid_src, NAME_DATASET_CHUNKED, H5P_DEFAULT)) < 0) TEST_ERROR - /* open the destination dataset */ + /* open the copied dataset NAME_DATASET_CHUNKED at destination */ if((did2 = H5Dopen2(fid_dst, NAME_DATASET_CHUNKED, H5P_DEFAULT)) < 0) TEST_ERROR /* Check if the datasets are equal */ @@ -2710,10 +2709,10 @@ test_copy_dataset_chunked_empty(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, /* close the source dataset */ if(H5Dclose(did) < 0) TEST_ERROR - /* open the dataset for copy */ + /* open the dataset NAME_DATASET_CHUNKED_SINGLE in SRC file */ if((did = H5Dopen2(fid_src, NAME_DATASET_CHUNKED2, H5P_DEFAULT)) < 0) TEST_ERROR - /* open the destination dataset */ + /* open the copied dataset NAME_DATASET_CHUNKED2 at destination */ if((did2 = H5Dopen2(fid_dst, NAME_DATASET_CHUNKED2, H5P_DEFAULT)) < 0) TEST_ERROR /* Check if the datasets are equal */ @@ -2786,9 +2785,9 @@ test_copy_dataset_chunked_sparse(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, /* set initial data values */ for(i = 0; i < DIM_SIZE_1; i++) { - buf1d[i] = (float)(i / 10.0F); + buf1d[i] = (float)i / 10.0F; for(j = 0; j < DIM_SIZE_2; j++) - buf2d[i][j] = (float)(i + (j / 100.0F)); + buf2d[i][j] = (float)i + ((float)j / 100.0F); } /* end for */ /* Initialize the filenames */ @@ -2836,6 +2835,7 @@ test_copy_dataset_chunked_sparse(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, /* close the dataset */ if(H5Dclose(did) < 0) TEST_ERROR + /* Set 2-D dataspace dimensions */ dim2d[0]=DIM_SIZE_1; dim2d[1]=DIM_SIZE_2; @@ -2874,6 +2874,7 @@ test_copy_dataset_chunked_sparse(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, /* close the dataset */ if(H5Dclose(did) < 0) TEST_ERROR + /* close the SRC file */ if(H5Fclose(fid_src) < 0) TEST_ERROR @@ -2906,6 +2907,7 @@ test_copy_dataset_chunked_sparse(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, /* close the source dataset */ if(H5Dclose(did) < 0) TEST_ERROR + /* open the dataset for copy */ if((did = H5Dopen2(fid_src, NAME_DATASET_CHUNKED2, H5P_DEFAULT)) < 0) TEST_ERROR @@ -2994,8 +2996,8 @@ test_copy_dataset_compressed(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR /* Set dataspace dimensions */ - dim2d[0]=DIM_SIZE_1; - dim2d[1]=DIM_SIZE_2; + dim2d[0] = DIM_SIZE_1; + dim2d[1] = DIM_SIZE_2; /* create dataspace */ if((sid = H5Screate_simple(2, dim2d, NULL)) < 0) TEST_ERROR @@ -3110,7 +3112,7 @@ test_copy_dataset_compact(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t /* set initial data values */ for (i=0; i Date: Thu, 17 Dec 2015 10:10:06 -0500 Subject: [svn-r28702] Description: Fix typo in comment. Tested on: (Unneeded) --- src/H5Aint.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/H5Aint.c b/src/H5Aint.c index baa352c..12ffb7d 100644 --- a/src/H5Aint.c +++ b/src/H5Aint.c @@ -1878,7 +1878,7 @@ H5A_set_version(const H5F_t *f, H5A_t *attr) /* Check which version to encode attribute with */ if(use_latest_format) - attr->shared->version = H5O_ATTR_VERSION_LATEST; /* Write out latest version of format */ + attr->shared->version = H5O_ATTR_VERSION_LATEST; /* Write out latest attribute version */ else if(attr->shared->encoding != H5T_CSET_ASCII) attr->shared->version = H5O_ATTR_VERSION_3; /* Write version which includes the character encoding */ else if(type_shared || space_shared) -- cgit v0.12 From 9ceca0f89a0d27a6dfaeb3dd0cab2680281c5b60 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Sat, 19 Dec 2015 09:42:15 -0500 Subject: [svn-r28710] Description: Bring r28708 from revise_chunks branch: Fix earray, farray and btree2 use of incorrect file pointer when two files are opened and used to access the data structure. Misc. minor code cleanups as well. Tested on: MacOSX/64 10.11.2 (amazon) w/serial & parallel h5committest forthcoming --- src/H5B2.c | 30 +++------ src/H5B2dbg.c | 61 +++++------------ src/H5B2hdr.c | 83 +++++++++++++++++++++-- src/H5B2pkg.h | 4 ++ src/H5C.c | 93 ++++++++++---------------- src/H5EAhdr.c | 33 +++++----- src/H5FAhdr.c | 3 +- test/Makefile.am | 14 ++-- test/btree2.c | 182 +++++++++++++++++++++++++++++++++++++++++++------- test/dsets.c | 67 +++++++++---------- test/earray.c | 197 +++++++++++++++++++++++++++++++++++++++++++++++-------- test/farray.c | 163 +++++++++++++++++++++++++++++++++++++++++---- 12 files changed, 680 insertions(+), 250 deletions(-) diff --git a/src/H5B2.c b/src/H5B2.c index 7eb88c4..a171917 100644 --- a/src/H5B2.c +++ b/src/H5B2.c @@ -134,7 +134,6 @@ H5B2_create(H5F_t *f, hid_t dxpl_id, const H5B2_create_t *cparam, void *ctx_udat { H5B2_t *bt2 = NULL; /* Pointer to the B-tree */ H5B2_hdr_t *hdr = NULL; /* Pointer to the B-tree header */ - H5B2_hdr_cache_ud_t cache_udata; /* User-data for callback */ haddr_t hdr_addr; /* B-tree header address */ H5B2_t *ret_value = NULL; /* Return value */ @@ -158,11 +157,8 @@ H5B2_create(H5F_t *f, hid_t dxpl_id, const H5B2_create_t *cparam, void *ctx_udat HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "memory allocation failed for v2 B-tree info") /* Look up the B-tree header */ - cache_udata.f = f; - cache_udata.addr = hdr_addr; - cache_udata.ctx_udata = ctx_udata; - if(NULL == (hdr = (H5B2_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, hdr_addr, &cache_udata, H5AC__NO_FLAGS_SET))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, NULL, "unable to load B-tree header") + if(NULL == (hdr = H5B2__hdr_protect(f, dxpl_id, hdr_addr, ctx_udata, H5AC__NO_FLAGS_SET))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, NULL, "unable to protect v2 B-tree header") /* Point v2 B-tree wrapper at header and bump it's ref count */ bt2->hdr = hdr; @@ -180,7 +176,7 @@ H5B2_create(H5F_t *f, hid_t dxpl_id, const H5B2_create_t *cparam, void *ctx_udat ret_value = bt2; done: - if(hdr && H5AC_unprotect(f, dxpl_id, H5AC_BT2_HDR, hdr_addr, hdr, H5AC__NO_FLAGS_SET) < 0) + if(hdr && H5B2__hdr_unprotect(hdr, dxpl_id, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, NULL, "unable to release v2 B-tree header") if(!ret_value && bt2) if(H5B2_close(bt2, dxpl_id) < 0) @@ -209,7 +205,6 @@ H5B2_open(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *ctx_udata) { H5B2_t *bt2 = NULL; /* Pointer to the B-tree */ H5B2_hdr_t *hdr = NULL; /* Pointer to the B-tree header */ - H5B2_hdr_cache_ud_t cache_udata; /* User-data for callback */ H5B2_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -219,11 +214,8 @@ H5B2_open(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *ctx_udata) HDassert(H5F_addr_defined(addr)); /* Look up the B-tree header */ - cache_udata.f = f; - cache_udata.addr = addr; - cache_udata.ctx_udata = ctx_udata; - if(NULL == (hdr = (H5B2_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, &cache_udata, H5AC__READ_ONLY_FLAG))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, NULL, "unable to load B-tree header") + if(NULL == (hdr = H5B2__hdr_protect(f, dxpl_id, addr, ctx_udata, H5AC__READ_ONLY_FLAG))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, NULL, "unable to protect v2 B-tree header") /* Check for pending heap deletion */ if(hdr->pending_delete) @@ -249,7 +241,7 @@ H5B2_open(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *ctx_udata) ret_value = bt2; done: - if(hdr && H5AC_unprotect(f, dxpl_id, H5AC_BT2_HDR, addr, hdr, H5AC__NO_FLAGS_SET) < 0) + if(hdr && H5B2__hdr_unprotect(hdr, dxpl_id, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, NULL, "unable to release v2 B-tree header") if(!ret_value && bt2) if(H5B2_close(bt2, dxpl_id) < 0) @@ -1282,7 +1274,7 @@ H5B2_close(H5B2_t *bt2, hid_t dxpl_id) /* Lock the v2 B-tree header into memory */ /* (OK to pass in NULL for callback context, since we know the header must be in the cache) */ - if(NULL == (hdr = (H5B2_hdr_t *)H5AC_protect(bt2->f, dxpl_id, H5AC_BT2_HDR, bt2_addr, NULL, H5AC__NO_FLAGS_SET))) + if(NULL == (hdr = H5B2__hdr_protect(bt2->f, dxpl_id, bt2_addr, NULL, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect v2 B-tree header") /* Set the shared v2 B-tree header's file context for this operation */ @@ -1344,7 +1336,6 @@ H5B2_delete(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *ctx_udata, H5B2_remove_t op, void *op_data) { H5B2_hdr_t *hdr = NULL; /* Pointer to the B-tree header */ - H5B2_hdr_cache_ud_t cache_udata; /* User-data for callback */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1357,10 +1348,7 @@ H5B2_delete(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *ctx_udata, #ifdef QAK HDfprintf(stderr, "%s: addr = %a\n", FUNC, addr); #endif /* QAK */ - cache_udata.f = f; - cache_udata.addr = addr; - cache_udata.ctx_udata = ctx_udata; - if(NULL == (hdr = (H5B2_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, &cache_udata, H5AC__NO_FLAGS_SET))) + if(NULL == (hdr = H5B2__hdr_protect(f, dxpl_id, addr, ctx_udata, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect v2 B-tree header") /* Remember the callback & context for later */ @@ -1382,7 +1370,7 @@ HDfprintf(stderr, "%s: addr = %a\n", FUNC, addr); done: /* Unprotect the header, if an error occurred */ - if(hdr && H5AC_unprotect(f, dxpl_id, H5AC_BT2_HDR, addr, hdr, H5AC__NO_FLAGS_SET) < 0) + if(hdr && H5B2__hdr_unprotect(hdr, dxpl_id, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release v2 B-tree header") FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5B2dbg.c b/src/H5B2dbg.c index ad9f970..73084d2 100644 --- a/src/H5B2dbg.c +++ b/src/H5B2dbg.c @@ -95,7 +95,6 @@ H5B2__hdr_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, void *dbg_ctx = NULL; /* v2 B-tree debugging context */ unsigned u; /* Local index variable */ char temp_str[128]; /* Temporary string, for formatting */ - H5B2_hdr_cache_ud_t cache_udata; /* User-data for callback */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -114,19 +113,13 @@ H5B2__hdr_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, (NULL == type->crt_dbg_ctx && NULL == type->dst_dbg_ctx)); /* Check for debugging context callback available */ - if(type->crt_dbg_ctx) { + if(type->crt_dbg_ctx) /* Create debugging context */ if(NULL == (dbg_ctx = (type->crt_dbg_ctx)(f, dxpl_id, obj_addr))) HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "unable to create v2 B-tree debugging context") - } /* end if */ - /* - * Load the B-tree header. - */ - cache_udata.f = f; - cache_udata.addr = addr; - cache_udata.ctx_udata = dbg_ctx; - if(NULL == (hdr = (H5B2_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, &cache_udata, H5AC__READ_ONLY_FLAG))) + /* Load the B-tree header */ + if(NULL == (hdr = H5B2__hdr_protect(f, dxpl_id, addr, dbg_ctx, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree header") /* Set file pointer for this B-tree operation */ @@ -180,11 +173,8 @@ H5B2__hdr_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, done: if(dbg_ctx && (type->dst_dbg_ctx)(dbg_ctx) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTRELEASE, FAIL, "unable to release v2 B-tree debugging context") - if(hdr) { - hdr->f = NULL; - if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_HDR, addr, hdr, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree header") - } /* end if */ + if(hdr && H5B2__hdr_unprotect(hdr, dxpl_id, H5AC__NO_FLAGS_SET) < 0) + HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release v2 B-tree header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__hdr_debug() */ @@ -212,7 +202,6 @@ H5B2__int_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, void *dbg_ctx = NULL; /* v2 B-tree debugging context */ unsigned u; /* Local index variable */ char temp_str[128]; /* Temporary string, for formatting */ - H5B2_hdr_cache_ud_t cache_udata; /* User-data for callback */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -239,14 +228,9 @@ H5B2__int_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "unable to create v2 B-tree debugging context") } /* end if */ - /* - * Load the B-tree header. - */ - cache_udata.f = f; - cache_udata.addr = hdr_addr; - cache_udata.ctx_udata = dbg_ctx; - if(NULL == (hdr = (H5B2_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, hdr_addr, &cache_udata, H5AC__READ_ONLY_FLAG))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree header") + /* Load the B-tree header */ + if(NULL == (hdr = H5B2__hdr_protect(f, dxpl_id, hdr_addr, dbg_ctx, H5AC__READ_ONLY_FLAG))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load v2 B-tree header") /* Set file pointer for this B-tree operation */ hdr->f = f; @@ -309,11 +293,8 @@ H5B2__int_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, done: if(dbg_ctx && (type->dst_dbg_ctx)(dbg_ctx) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTRELEASE, FAIL, "unable to release v2 B-tree debugging context") - if(hdr) { - hdr->f = NULL; - if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_HDR, hdr_addr, hdr, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree header") - } /* end if */ + if(hdr && H5B2__hdr_unprotect(hdr, dxpl_id, H5AC__NO_FLAGS_SET) < 0) + HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release v2 B-tree header") if(internal && H5AC_unprotect(f, dxpl_id, H5AC_BT2_INT, addr, internal, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree internal node") @@ -340,7 +321,6 @@ H5B2__leaf_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent { H5B2_hdr_t *hdr = NULL; /* B-tree header */ H5B2_leaf_t *leaf = NULL; /* B-tree leaf node */ - H5B2_hdr_cache_ud_t cache_udata; /* User-data for callback */ void *dbg_ctx = NULL; /* v2 B-tree debugging context */ unsigned u; /* Local index variable */ char temp_str[128]; /* Temporary string, for formatting */ @@ -364,20 +344,14 @@ H5B2__leaf_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent HDassert(nrec > 0); /* Check for debugging context callback available */ - if(type->crt_dbg_ctx) { + if(type->crt_dbg_ctx) /* Create debugging context */ if(NULL == (dbg_ctx = (type->crt_dbg_ctx)(f, dxpl_id, obj_addr))) HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "unable to create v2 B-tree debugging context") - } /* end if */ - /* - * Load the B-tree header. - */ - cache_udata.f = f; - cache_udata.addr = hdr_addr; - cache_udata.ctx_udata = dbg_ctx; - if(NULL == (hdr = (H5B2_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, hdr_addr, &cache_udata, H5AC__READ_ONLY_FLAG))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree header") + /* Load the B-tree header */ + if(NULL == (hdr = H5B2__hdr_protect(f, dxpl_id, hdr_addr, dbg_ctx, H5AC__READ_ONLY_FLAG))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect v2 B-tree header") /* Set file pointer for this B-tree operation */ hdr->f = f; @@ -423,11 +397,8 @@ H5B2__leaf_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent done: if(dbg_ctx && (type->dst_dbg_ctx)(dbg_ctx) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTRELEASE, FAIL, "unable to release v2 B-tree debugging context") - if(hdr) { - hdr->f = NULL; - if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_HDR, hdr_addr, hdr, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree header") - } /* end if */ + if(hdr && H5B2__hdr_unprotect(hdr, dxpl_id, H5AC__NO_FLAGS_SET) < 0) + HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree header") if(leaf && H5AC_unprotect(f, dxpl_id, H5AC_BT2_LEAF, addr, leaf, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree leaf node") diff --git a/src/H5B2hdr.c b/src/H5B2hdr.c index 16d8467..25ac141 100644 --- a/src/H5B2hdr.c +++ b/src/H5B2hdr.c @@ -209,10 +209,9 @@ HDmemset(hdr->page, 0, hdr->node_size); } /* end if */ /* Create the callback context, if the callback exists */ - if(hdr->cls->crt_context) { + if(hdr->cls->crt_context) if(NULL == (hdr->cb_ctx = (*hdr->cls->crt_context)(ctx_udata))) HGOTO_ERROR(H5E_BTREE, H5E_CANTCREATE, FAIL, "unable to create v2 B-tree client callback context") - } /* end if */ done: if(ret_value < 0) @@ -488,6 +487,82 @@ done: /*------------------------------------------------------------------------- + * Function: H5B2__hdr_protect + * + * Purpose: Convenience wrapper around protecting v2 B-tree header + * + * Return: Non-NULL pointer to header on success/NULL on failure + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * Dec 18 2015 + * + *------------------------------------------------------------------------- + */ +H5B2_hdr_t * +H5B2__hdr_protect(H5F_t *f, hid_t dxpl_id, haddr_t hdr_addr, void *ctx_udata, + unsigned flags) +{ + H5B2_hdr_cache_ud_t udata; /* User data for cache callbacks */ + H5B2_hdr_t *ret_value = NULL; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Sanity check */ + HDassert(f); + HDassert(H5F_addr_defined(hdr_addr)); + + /* only the H5AC__READ_ONLY_FLAG may appear in flags */ + HDassert((flags & (unsigned)(~H5AC__READ_ONLY_FLAG)) == 0); + + /* Set up user data for cache callbacks */ + udata.f = f; + udata.addr = hdr_addr; + udata.ctx_udata = ctx_udata; + + /* Protect the header */ + if(NULL == (ret_value = (H5B2_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, hdr_addr, &udata, flags))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, NULL, "unable to load v2 B-tree header, address = %llu", (unsigned long long)hdr_addr) + ret_value->f = f; /* (Must be set again here, in case the header was already in the cache -QAK) */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5B2__hdr_protect() */ + + +/*------------------------------------------------------------------------- + * Function: H5B2__hdr_unprotect + * + * Purpose: Convenience wrapper around unprotecting v2 B-tree header + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * Dec 18 2015 + * + *------------------------------------------------------------------------- + */ +herr_t +H5B2__hdr_unprotect(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned cache_flags) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Sanity check */ + HDassert(hdr); + + /* Unprotect the header */ + if(H5AC_unprotect(hdr->f, dxpl_id, H5AC_BT2_HDR, hdr->addr, hdr, cache_flags) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to unprotect v2 B-tree header, address = %llu", (unsigned long long)hdr->addr) + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5B2__hdr_unprotect() */ + + +/*------------------------------------------------------------------------- * Function: H5B2__hdr_free * * Purpose: Free B-tree header info @@ -609,8 +684,8 @@ H5B2__hdr_delete(H5B2_hdr_t *hdr, hid_t dxpl_id) done: /* Unprotect the header with appropriate flags */ - if(H5AC_unprotect(hdr->f, dxpl_id, H5AC_BT2_HDR, hdr->addr, hdr, cache_flags) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree header") + if(H5B2__hdr_unprotect(hdr, dxpl_id, cache_flags) < 0) + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release v2 B-tree header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__hdr_delete() */ diff --git a/src/H5B2pkg.h b/src/H5B2pkg.h index d661efa..f58850e 100644 --- a/src/H5B2pkg.h +++ b/src/H5B2pkg.h @@ -302,6 +302,10 @@ H5_DLL herr_t H5B2__hdr_decr(H5B2_hdr_t *hdr); H5_DLL herr_t H5B2__hdr_fuse_incr(H5B2_hdr_t *hdr); H5_DLL size_t H5B2__hdr_fuse_decr(H5B2_hdr_t *hdr); H5_DLL herr_t H5B2__hdr_dirty(H5B2_hdr_t *hdr); +H5_DLL H5B2_hdr_t *H5B2__hdr_protect(H5F_t *f, hid_t dxpl_id, haddr_t hdr_addr, + void *ctx_udata, unsigned flags); +H5_DLL herr_t H5B2__hdr_unprotect(H5B2_hdr_t *hdr, hid_t dxpl_id, + unsigned cache_flags); H5_DLL herr_t H5B2__hdr_delete(H5B2_hdr_t *hdr, hid_t dxpl_id); /* Routines for operating on leaf nodes */ diff --git a/src/H5C.c b/src/H5C.c index 2a4b4cf..c78c32c 100644 --- a/src/H5C.c +++ b/src/H5C.c @@ -2938,7 +2938,7 @@ done: ( H5C_validate_pinned_entry_list(cache_ptr) < 0 ) || ( H5C_validate_lru_list(cache_ptr) < 0 ) ) { - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, NULL, \ "an extreme sanity check failed on exit.\n"); } #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ @@ -6802,7 +6802,7 @@ H5C_flush_invalidate_ring(const H5F_t * f, hid_t dxpl_id, H5C_ring_t ring, /* Get cache entry for this node */ next_entry_ptr = (H5C_cache_entry_t *)H5SL_item(node_ptr); - if ( NULL == next_entry_ptr ) + if(NULL == next_entry_ptr) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "next_entry_ptr == NULL ?!?!") HDassert(next_entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); @@ -7240,8 +7240,8 @@ H5C_flush_ring(H5F_t *f, hid_t dxpl_id, H5C_ring_t ring, unsigned flags) #if H5C_DO_EXTREME_SANITY_CHECKS if((H5C_validate_protected_entry_list(cache_ptr) < 0) || - (H5C_validate_pinned_entry_list(cache_ptr) < 0 || - (H5C_validate_lru_list(cache_ptr) < 0)) { + (H5C_validate_pinned_entry_list(cache_ptr) < 0) || + (H5C_validate_lru_list(cache_ptr) < 0)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on entry.\n"); #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ @@ -7604,7 +7604,7 @@ done: * * Refactored function to delay all modifications of the * metadata cache data structures until after any calls - * to the pre-serialize or serialize callbacks. + * to the pre-serialize or serialize callbacks. * * Need to do this, as some pre-serialize or serialize * calls result in calls to the metadata cache and @@ -7668,7 +7668,7 @@ H5C__flush_single_entry(const H5F_t *f, hid_t dxpl_id, H5C_cache_entry_t *entry_ else destroy_entry = destroy; - /* we will write the entry to disk if it exists, is dirty, and if the + /* we will write the entry to disk if it exists, is dirty, and if the * clear only flag is not set. */ if(entry_ptr->is_dirty && !clear_only) @@ -8057,7 +8057,7 @@ H5C__flush_single_entry(const H5F_t *f, hid_t dxpl_id, H5C_cache_entry_t *entry_ /* only log a flush if we actually wrote to disk */ H5C__UPDATE_STATS_FOR_FLUSH(cache_ptr, entry_ptr) - } + } /* end else if */ if(destroy) { if(take_ownership) @@ -8066,7 +8066,7 @@ H5C__flush_single_entry(const H5F_t *f, hid_t dxpl_id, H5C_cache_entry_t *entry_ HDassert(destroy_entry); H5C__UPDATE_STATS_FOR_EVICTION(cache_ptr, entry_ptr, take_ownership) - } + } /* end if */ /* If the entry's type has a 'notify' callback and the entry is about * to be removed from the cache, send a 'before eviction' notice while @@ -8306,12 +8306,12 @@ H5C_load_entry(H5F_t * f, /* verify absence of prohibited or unsupported type flag combinations */ HDassert(!(type->flags & H5C__CLASS_NO_IO_FLAG)); - + /* for now, we do not combine the speculative load and compressed flags */ HDassert(!((type->flags & H5C__CLASS_SPECULATIVE_LOAD_FLAG) && (type->flags & H5C__CLASS_COMPRESSED_FLAG))); - /* Can't see how skip reads could be usefully combined with + /* Can't see how skip reads could be usefully combined with * either the speculative read or compressed flags. Hence disallow. */ HDassert(!((type->flags & H5C__CLASS_SKIP_READS) && @@ -8433,12 +8433,10 @@ H5C_load_entry(H5F_t * f, } /* Allocate the buffer for reading the on-disk entry image */ if(NULL == (image = H5MM_malloc(len + H5C_IMAGE_EXTRA_SPACE))) - - HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, NULL, \ - "memory allocation failed for on disk image buffer.") + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, NULL, "memory allocation failed for on disk image buffer.") #if H5C_DO_MEMORY_SANITY_CHECKS - HDmemcpy(((uint8_t *)image) + len, H5C_IMAGE_SANITY_VALUE, H5C_IMAGE_EXTRA_SPACE); + HDmemcpy(image + len, H5C_IMAGE_SANITY_VALUE, H5C_IMAGE_EXTRA_SPACE); #endif /* H5C_DO_MEMORY_SANITY_CHECKS */ /* Get the on-disk entry image */ @@ -8472,12 +8470,9 @@ H5C_load_entry(H5F_t * f, /* Get the actual image size for the thing */ if(type->image_len(thing, &new_len, &compressed, &compressed_size) < 0) - - HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, NULL, \ - "can't retrieve image length") + HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, NULL, "can't retrieve image length") if(new_len == 0) - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, NULL, "image length is 0") HDassert(((type->flags & H5C__CLASS_COMPRESSED_FLAG) != 0) || @@ -8521,15 +8516,13 @@ H5C_load_entry(H5F_t * f, if(NULL == (new_image = H5MM_realloc(image, new_len + H5C_IMAGE_EXTRA_SPACE))) - HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, NULL, \ - "image null after H5MM_realloc()") + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, NULL, "image null after H5MM_realloc()") image = new_image; #if H5C_DO_MEMORY_SANITY_CHECKS - HDmemcpy(((uint8_t *)image) + new_len, - H5C_IMAGE_SANITY_VALUE, H5C_IMAGE_EXTRA_SPACE); + HDmemcpy(((uint8_t *)image) + new_len, H5C_IMAGE_SANITY_VALUE, H5C_IMAGE_EXTRA_SPACE); #endif /* H5C_DO_MEMORY_SANITY_CHECKS */ @@ -8550,15 +8543,13 @@ H5C_load_entry(H5F_t * f, if ( type->free_icr(thing) < 0 ) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, NULL, \ - "free_icr callback failed") + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, NULL, "free_icr callback failed") /* Go get the on-disk image again */ if(H5F_block_read(f, type->mem_type, addr, new_len, dxpl_id, image) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTLOAD, NULL, \ - "Can't read image") + HGOTO_ERROR(H5E_CACHE, H5E_CANTLOAD, NULL, "Can't read image") /* Deserialize on-disk image into native memory * form again @@ -8621,7 +8612,7 @@ H5C_load_entry(H5F_t * f, * * HDassert( ( dirty == FALSE ) || ( type->id == 5 || type->id == 6 ) ); * - * note that type ids 5 & 6 are associated with object headers in the + * note that type ids 5 & 6 are associated with object headers in the * metadata cache. * * When we get to using H5C for other purposes, we may wish to @@ -8824,8 +8815,8 @@ H5C_make_space_in_cache(H5F_t * f, ( entry_ptr != NULL ) ) { - HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - HDassert( ! (entry_ptr->is_protected) ); + HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + HDassert( !(entry_ptr->is_protected) ); HDassert( ! (entry_ptr->is_read_only) ); HDassert( (entry_ptr->ro_ref_count) == 0 ); @@ -8857,8 +8848,8 @@ H5C_make_space_in_cache(H5F_t * f, * last_entry_removed_ptr prior to the call to * H5C__flush_single_entry() so that we can spot * unexpected removals of entries from the cache, - * and set the restart_scan flag if proceeding - * would be likely to cause us to scan an entry + * and set the restart_scan flag if proceeding + * would be likely to cause us to scan an entry * that is no longer in the cache. */ cache_ptr->entries_removed_counter = 0; @@ -8881,7 +8872,6 @@ H5C_make_space_in_cache(H5F_t * f, if(H5C__flush_single_entry(f, dxpl_id, entry_ptr, H5C__FLUSH_INVALIDATE_FLAG | H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG, NULL) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush entry") - } else { /* We have enough space so don't flush clean entry. */ #if H5C_COLLECT_CACHE_STATS @@ -8906,15 +8896,15 @@ H5C_make_space_in_cache(H5F_t * f, if ( didnt_flush_entry ) { - /* epoch markers don't get flushed, and we don't touch + /* epoch markers don't get flushed, and we don't touch * entries that are in the process of being flushed. - * Hence no need for sanity checks, as we haven't - * flushed anything. Thus just set entry_ptr to prev_ptr + * Hence no need for sanity checks, as we haven't + * flushed anything. Thus just set entry_ptr to prev_ptr * and go on. */ entry_ptr = prev_ptr; - } else if ( ( restart_scan ) + } else if ( ( restart_scan ) || ( prev_ptr->is_dirty != prev_is_dirty ) || @@ -9084,10 +9074,8 @@ H5C_validate_lru_list(H5C_t * cache_ptr) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 1 failed") } - if ( ( cache_ptr->LRU_list_len < 0 ) || ( cache_ptr->LRU_list_size < 0 ) ) { - + if(cache_ptr->LRU_list_len < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 2 failed") - } if ( ( cache_ptr->LRU_list_len == 1 ) && @@ -9214,10 +9202,8 @@ H5C_validate_pinned_entry_list(H5C_t * cache_ptr) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 1 failed") } - if ( ( cache_ptr->pel_len < 0 ) || ( cache_ptr->pel_size < 0 ) ) { - + if(cache_ptr->pel_len < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 2 failed") - } if ( ( cache_ptr->pel_len == 1 ) && @@ -9337,21 +9323,12 @@ H5C_validate_protected_entry_list(H5C_t * cache_ptr) HDassert( cache_ptr ); HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); - if ( ( ( cache_ptr->pl_head_ptr == NULL ) - || - ( cache_ptr->pl_tail_ptr == NULL ) - ) - && - ( cache_ptr->pl_head_ptr != cache_ptr->pl_tail_ptr ) - ) { - + if(((cache_ptr->pl_head_ptr == NULL) || (cache_ptr->pl_tail_ptr == NULL)) + && (cache_ptr->pl_head_ptr != cache_ptr->pl_tail_ptr)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 1 failed") - } - - if ( ( cache_ptr->pl_len < 0 ) || ( cache_ptr->pl_size < 0 ) ) { + if(cache_ptr->pl_len < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 2 failed") - } if ( ( cache_ptr->pl_len == 1 ) && @@ -9682,7 +9659,7 @@ done: * Function: H5C_ignore_tags * * Purpose: Override all assertion frameworks associated with making - * sure proper tags are applied to metadata. + * sure proper tags are applied to cache entries. * * NOTE: This should really only be used in tests that need * to access internal functions without going through @@ -9794,7 +9771,7 @@ done: * Return: FAIL if error is detected, SUCCEED otherwise. * * Programmer: Mike McGreevy - * November 3, 2009 + * August 19, 2010 * *------------------------------------------------------------------------- */ @@ -9837,7 +9814,7 @@ done: * Return: FAIL if error is detected, SUCCEED otherwise. * * Programmer: Mike McGreevy - * November 3, 2009 + * September 9, 2010 * *------------------------------------------------------------------------- */ @@ -9883,7 +9860,7 @@ H5C_mark_tagged_entries(H5C_t * cache_ptr, haddr_t tag) * Return: FAIL if error is detected, SUCCEED otherwise. * * Programmer: Mike McGreevy - * November 3, 2009 + * November 3, 2010 * *------------------------------------------------------------------------- */ diff --git a/src/H5EAhdr.c b/src/H5EAhdr.c index eff4b54..da15087 100644 --- a/src/H5EAhdr.c +++ b/src/H5EAhdr.c @@ -43,7 +43,7 @@ #include "H5Eprivate.h" /* Error handling */ #include "H5EApkg.h" /* Extensible Arrays */ #include "H5MFprivate.h" /* File memory management */ -#include "H5VMprivate.h" /* Vectors and arrays */ +#include "H5VMprivate.h" /* Vectors and arrays */ /****************/ @@ -128,7 +128,7 @@ H5EA__hdr_alloc(H5F_t *f)) /* Allocate space for the shared information */ if(NULL == (hdr = H5FL_CALLOC(H5EA_hdr_t))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array shared header") + H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array shared header") /* Set non-zero internal fields */ hdr->addr = HADDR_UNDEF; @@ -390,35 +390,35 @@ HDfprintf(stderr, "%s: Called\n", FUNC); /* Check for valid parameters */ if(cparam->raw_elmt_size == 0) - H5E_THROW(H5E_BADVALUE, "element size must be greater than zero") + H5E_THROW(H5E_BADVALUE, "element size must be greater than zero") if(cparam->max_nelmts_bits == 0) - H5E_THROW(H5E_BADVALUE, "max. # of elements bits must be greater than zero") + H5E_THROW(H5E_BADVALUE, "max. # of elements bits must be greater than zero") if(cparam->max_nelmts_bits > H5EA_MAX_NELMTS_IDX_MAX) - H5E_THROW(H5E_BADVALUE, "max. # of elements bits must be <= %u", (unsigned)H5EA_MAX_NELMTS_IDX_MAX) + H5E_THROW(H5E_BADVALUE, "max. # of elements bits must be <= %u", (unsigned)H5EA_MAX_NELMTS_IDX_MAX) if(cparam->sup_blk_min_data_ptrs < 2) - H5E_THROW(H5E_BADVALUE, "min # of data block pointers in super block must be >= two") + H5E_THROW(H5E_BADVALUE, "min # of data block pointers in super block must be >= two") if(!POWER_OF_TWO(cparam->sup_blk_min_data_ptrs)) - H5E_THROW(H5E_BADVALUE, "min # of data block pointers in super block must be power of two") + H5E_THROW(H5E_BADVALUE, "min # of data block pointers in super block must be power of two") if(!POWER_OF_TWO(cparam->data_blk_min_elmts)) - H5E_THROW(H5E_BADVALUE, "min # of elements per data block must be power of two") + H5E_THROW(H5E_BADVALUE, "min # of elements per data block must be power of two") dblk_page_nelmts = (size_t)1 << cparam->max_dblk_page_nelmts_bits; if(dblk_page_nelmts < cparam->idx_blk_elmts) - H5E_THROW(H5E_BADVALUE, "# of elements per data block page must be greater than # of elements in index block") + H5E_THROW(H5E_BADVALUE, "# of elements per data block page must be greater than # of elements in index block") /* Compute the number of elements in data blocks for first actual super block */ sblk_idx = H5EA_SBLK_FIRST_IDX(cparam->sup_blk_min_data_ptrs); dblk_nelmts = H5EA_SBLK_DBLK_NELMTS(sblk_idx, cparam->data_blk_min_elmts); if(dblk_page_nelmts < dblk_nelmts) - H5E_THROW(H5E_BADVALUE, "max. # of elements per data block page bits must be > # of elements in first data block from super block") + H5E_THROW(H5E_BADVALUE, "max. # of elements per data block page bits must be > # of elements in first data block from super block") if(cparam->max_dblk_page_nelmts_bits > cparam->max_nelmts_bits) - H5E_THROW(H5E_BADVALUE, "max. # of elements per data block page bits must be <= max. # of elements bits") + H5E_THROW(H5E_BADVALUE, "max. # of elements per data block page bits must be <= max. # of elements bits") } #endif /* NDEBUG */ /* Allocate space for the shared information */ if(NULL == (hdr = H5EA__hdr_alloc(f))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array shared header") + H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array shared header") /* Set the internal parameters for the array */ hdr->idx_blk_addr = HADDR_UNDEF; @@ -428,15 +428,15 @@ HDfprintf(stderr, "%s: Called\n", FUNC); /* Finish initializing extensible array header */ if(H5EA__hdr_init(hdr, ctx_udata) < 0) - H5E_THROW(H5E_CANTINIT, "initialization failed for extensible array header") + H5E_THROW(H5E_CANTINIT, "initialization failed for extensible array header") /* Allocate space for the header on disk */ if(HADDR_UNDEF == (hdr->addr = H5MF_alloc(f, H5FD_MEM_EARRAY_HDR, dxpl_id, (hsize_t)hdr->size))) - H5E_THROW(H5E_CANTALLOC, "file allocation failed for extensible array header") + H5E_THROW(H5E_CANTALLOC, "file allocation failed for extensible array header") /* Cache the new extensible array header */ if(H5AC_insert_entry(f, dxpl_id, H5AC_EARRAY_HDR, hdr->addr, hdr, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTINSERT, "can't add extensible array header to cache") + H5E_THROW(H5E_CANTINSERT, "can't add extensible array header to cache") /* Set address of array header to return */ ret_value = hdr->addr; @@ -616,7 +616,7 @@ END_FUNC(PKG) /* end H5EA__hdr_modified() */ * * Purpose: Convenience wrapper around protecting extensible array header * - * Return: Non-NULL pointer to index block on success/NULL on failure + * Return: Non-NULL pointer to header on success/NULL on failure * * Programmer: Quincey Koziol * koziol@hdfgroup.org @@ -647,6 +647,7 @@ H5EA__hdr_protect(H5F_t *f, hid_t dxpl_id, haddr_t ea_addr, void *ctx_udata, /* Protect the header */ if(NULL == (ret_value = (H5EA_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_EARRAY_HDR, ea_addr, &udata, flags))) H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array header, address = %llu", (unsigned long long)ea_addr) + ret_value->f = f; /* (Must be set again here, in case the header was already in the cache -QAK) */ CATCH diff --git a/src/H5FAhdr.c b/src/H5FAhdr.c index 62b1837..ac9a103 100644 --- a/src/H5FAhdr.c +++ b/src/H5FAhdr.c @@ -397,7 +397,7 @@ END_FUNC(PKG) /* end H5FA__hdr_modified() */ * * Purpose: Convenience wrapper around protecting fixed array header * - * Return: Non-NULL pointer to index block on success/NULL on failure + * Return: Non-NULL pointer to header on success/NULL on failure * * Programmer: Quincey Koziol * koziol@hdfgroup.org @@ -428,6 +428,7 @@ H5FA__hdr_protect(H5F_t *f, hid_t dxpl_id, haddr_t fa_addr, void *ctx_udata, /* Protect the header */ if(NULL == (ret_value = (H5FA_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_FARRAY_HDR, fa_addr, &udata, flags))) H5E_THROW(H5E_CANTPROTECT, "unable to protect fixed array header, address = %llu", (unsigned long long)fa_addr) + ret_value->f = f; /* (Must be set again here, in case the header was already in the cache -QAK) */ CATCH diff --git a/test/Makefile.am b/test/Makefile.am index d9c53d4..8389cc4 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -37,16 +37,14 @@ check_SCRIPTS = $(TEST_SCRIPT) # executed, generally most specific tests to least specific tests. # As an exception, long-running tests should occur earlier in the list. # This gives them more time to run when tests are executing in parallel. -# These tests (fheap, btree2) are under development and are not used by -# the library yet. Move them to the end so that their failure do not block -# other current library code tests. -TEST_PROG= testhdf5 lheap ohdr stab gheap cache cache_api cache_tagging \ +TEST_PROG= testhdf5 cache cache_api cache_tagging lheap ohdr stab gheap \ + farray earray btree2 fheap \ pool accum hyperslab istore bittests dt_arith \ dtypes dsets cmpd_dset filter_fail extend external efc objcopy links unlink \ big mtime fillval mount flush1 flush2 app_ref enum \ set_extent ttsafe enc_dec_plist enc_dec_plist_cross_platform\ getname vfd ntypes dangle dtransform reserved cross_read \ - freespace mf vds farray earray btree2 fheap file_image unregister + freespace mf vds file_image unregister # List programs to be built when testing here. error_test and err_compat are # built at the same time as the other tests, but executed by testerror.sh. @@ -145,9 +143,9 @@ CHECK_CLEANFILES+=accum.h5 cmpd_dset.h5 compact_dataset.h5 dataset.h5 dset_offse multi_file-[rs].h5 core_file plugin.h5 \ new_move_[ab].h5 ntypes.h5 dangle.h5 error_test.h5 err_compat.h5 \ dtransform.h5 test_filters.h5 get_file_name.h5 tstint[1-2].h5 \ - unlink_chunked.h5 btree2.h5 objcopy_src.h5 objcopy_dst.h5 \ - objcopy_ext.dat trefer1.h5 trefer2.h5 app_ref.h5 farray.h5 \ - earray.h5 efc[0-5].h5 log_vfd_out.log \ + unlink_chunked.h5 btree2.h5 btree2_tmp.h5 objcopy_src.h5 objcopy_dst.h5 \ + objcopy_ext.dat trefer1.h5 trefer2.h5 app_ref.h5 farray.h5 farray_tmp.h5 \ + earray.h5 earray_tmp.h5 efc[0-5].h5 log_vfd_out.log \ new_multi_file_v16-r.h5 new_multi_file_v16-s.h5 \ split_get_file_image_test-m.h5 split_get_file_image_test-r.h5 \ file_image_core_test.h5.copy unregister_filter_1.h5 unregister_filter_2.h5 \ diff --git a/test/btree2.c b/test/btree2.c index 8f84135..7a2432c 100644 --- a/test/btree2.c +++ b/test/btree2.c @@ -31,6 +31,7 @@ const char *FILENAME[] = { "btree2", + "btree2_tmp", NULL }; @@ -108,9 +109,8 @@ create_file(hid_t *file, H5F_t **f, hid_t fapl) STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(*f) < 0) { + if(H5AC_ignore_tags(*f) < 0) STACK_ERROR - } /* Success */ return(0); @@ -2810,9 +2810,8 @@ HDfprintf(stderr,"curr_time=%lu\n",(unsigned long)curr_time); STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(f) < 0) { + if(H5AC_ignore_tags(f) < 0) STACK_ERROR - } /* Create the v2 B-tree & get its address */ if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0) @@ -2849,9 +2848,8 @@ HDfprintf(stderr,"curr_time=%lu\n",(unsigned long)curr_time); FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(f) < 0) { + if(H5AC_ignore_tags(f) < 0) STACK_ERROR - } /* Re-open v2 B-tree */ if(NULL == (bt2 = H5B2_open(f, dxpl, bt2_addr, f))) @@ -4909,7 +4907,7 @@ test_remove_level1_collapse(hid_t fapl, const H5B2_create_t *cparam, /* Check record values in root of B-tree */ ninfo.depth = 0; - ninfo.nrec = INSERT_SPLIT_ROOT_NREC - u; + ninfo.nrec = (uint16_t)(INSERT_SPLIT_ROOT_NREC - u); record = 31; /* Middle record in root node */ if(check_node_info(bt2, dxpl, record, &ninfo) < 0) TEST_ERROR @@ -6379,9 +6377,8 @@ gen_l4_btree2(const char *filename, hid_t fapl, const H5B2_create_t *cparam, STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(f) < 0) { + if(H5AC_ignore_tags(f) < 0) STACK_ERROR - } /* Create the v2 B-tree & get its address */ if(create_btree(f, dxpl, cparam, &bt2, bt2_addr) < 0) @@ -6535,9 +6532,8 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time); FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(f) < 0) { + if(H5AC_ignore_tags(f) < 0) STACK_ERROR - } /* Re-shuffle record #'s */ for(u = 0; u < INSERT_MANY; u++) { @@ -6631,9 +6627,8 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time); FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(f) < 0) { + if(H5AC_ignore_tags(f) < 0) STACK_ERROR - } /* Re-open v2 B-tree */ if(NULL == (bt2 = H5B2_open(f, dxpl, bt2_addr, f))) @@ -6720,9 +6715,8 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time); FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(f) < 0) { + if(H5AC_ignore_tags(f) < 0) STACK_ERROR - } /* Re-open v2 B-tree */ if(NULL == (bt2 = H5B2_open(f, dxpl, bt2_addr, f))) @@ -6806,9 +6800,8 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time); FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(f) < 0) { + if(H5AC_ignore_tags(f) < 0) STACK_ERROR - } /* Re-open v2 B-tree */ if(NULL == (bt2 = H5B2_open(f, dxpl, bt2_addr, f))) @@ -7157,9 +7150,8 @@ test_delete(hid_t fapl, const H5B2_create_t *cparam) STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(f) < 0) { + if(H5AC_ignore_tags(f) < 0) STACK_ERROR - } /* Create the v2 B-tree & get its address */ if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0) @@ -7202,9 +7194,8 @@ test_delete(hid_t fapl, const H5B2_create_t *cparam) STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(f) < 0) { + if(H5AC_ignore_tags(f) < 0) STACK_ERROR - } /* Create the v2 B-tree & get its address */ if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0) @@ -7260,9 +7251,8 @@ test_delete(hid_t fapl, const H5B2_create_t *cparam) STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(f) < 0) { + if(H5AC_ignore_tags(f) < 0) STACK_ERROR - } /* Create the v2 B-tree & get its address */ if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0) @@ -7318,9 +7308,8 @@ test_delete(hid_t fapl, const H5B2_create_t *cparam) STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(f) < 0) { + if(H5AC_ignore_tags(f) < 0) STACK_ERROR - } /* Create the v2 B-tree & get its address */ if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0) @@ -7605,6 +7594,146 @@ error: /*------------------------------------------------------------------------- + * Function: test_open_twice_diff + * + * Purpose: Open a v2 B-tree twice, through different "top" file + * handles, with an intermediate file open that takes the "shared" + * file handle from the first B-tree's file pointer. + * + * Return: Success: 0 + * Failure: 1 + * + * Programmer: Quincey Koziol + * Friday, December 18, 2015 + * + *------------------------------------------------------------------------- + */ +static unsigned +test_open_twice_diff(hid_t fapl, const H5B2_create_t *cparam) +{ + char filename[1024]; /* Filename to use */ + char filename_tmp[1024]; /* Temporary file name */ + hid_t file = -1; /* File ID */ + hid_t file2 = -1; /* File ID */ + hid_t file0 = -1; /* File ID */ + hid_t file00 = -1; /* File ID */ + H5F_t *f = NULL; /* Internal file object pointer */ + H5F_t *f2 = NULL; /* Internal file object pointer */ + hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ + H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ + H5B2_t *bt2_2 = NULL; /* Second v2 B-tree wrapper */ + haddr_t bt2_addr; /* Address of B-tree created */ + + h5_fixname(FILENAME[0], fapl, filename, sizeof filename); + + /* + * Display testing message + */ + TESTING("open B-tree twice, through different file handles"); + + /* Create the file to work on */ + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR + + /* Get a pointer to the internal file object */ + if(NULL == (f = (H5F_t *)H5I_object(file))) + FAIL_STACK_ERROR + + /* Ignore metadata tags in the file's cache */ + if(H5AC_ignore_tags(f) < 0) + FAIL_STACK_ERROR + + /* Create the v2 B-tree & get its address */ + if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0) + TEST_ERROR + + /* Re-open v2 B-tree */ + if(NULL == (bt2_2 = H5B2_open(f, dxpl, bt2_addr, f))) + FAIL_STACK_ERROR + + /* Close the second v2 B-tree wrapper */ + if(H5B2_close(bt2_2, dxpl) < 0) + FAIL_STACK_ERROR + bt2_2 = NULL; + + /* Re-open the file */ + /* (So that there is something holding the file open when the extensible + * array is closed) + */ + if((file0 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR + + /* Close the first v2 B-tree wrapper */ + if(H5B2_close(bt2, dxpl) < 0) + FAIL_STACK_ERROR + bt2 = NULL; + + /* Close the file */ + /* (close before second file, to detect error on internal B-tree header's + * shared file information) + */ + if(H5Fclose(file) < 0) + FAIL_STACK_ERROR + file = -1; + + /* Open a different file */ + /* (This re-allocates the 'top' file pointer and assigns it a different + * 'shared' file pointer, making the file pointer in the fixed array's + * header stale) + */ + h5_fixname(FILENAME[1], fapl, filename_tmp, sizeof(filename_tmp)); + if((file00 = H5Fcreate(filename_tmp, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR + + /* Re-open the file with the v2 B-tree array */ + if((file2 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR + + /* Get a pointer to the internal file object */ + if(NULL == (f2 = (H5F_t *)H5I_object(file2))) + FAIL_STACK_ERROR + + /* Open the B-tree through the second file handle */ + if(NULL == (bt2_2 = H5B2_open(f2, dxpl, bt2_addr, f2))) + FAIL_STACK_ERROR + + /* Close the extra file handles */ + if(H5Fclose(file0) < 0) + FAIL_STACK_ERROR + if(H5Fclose(file00) < 0) + FAIL_STACK_ERROR + + /* Close the second v2 B-tree */ + if(H5B2_close(bt2_2, dxpl) < 0) + FAIL_STACK_ERROR + bt2_2 = NULL; + + /* Close file */ + if(H5Fclose(file2) < 0) + FAIL_STACK_ERROR + + /* All tests passed */ + PASSED(); + + /* All tests passed */ + return(0); + +error: + H5E_BEGIN_TRY { + if(bt2) + H5B2_close(bt2, dxpl); + if(bt2) + H5B2_close(bt2_2, dxpl); + H5Fclose(file); + H5Fclose(file2); + H5Fclose(file0); + H5Fclose(file00); + } H5E_END_TRY; + return(1); +} /* test_open_twice_diff() */ + + +/*------------------------------------------------------------------------- * Function: main * * Purpose: Test the B-tree v2 code @@ -7712,6 +7841,9 @@ main(void) nerrors += test_modify(fapl, &cparam, &tparam); } /* end for */ + /* Test opening B-trees twice */ + nerrors += test_open_twice_diff(fapl, &cparam); + /* Verify symbol table messages are cached */ nerrors += (h5_verify_cached_stabs(FILENAME, fapl) < 0 ? 1 : 0); diff --git a/test/dsets.c b/test/dsets.c index c0e8702..a9cda93 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -388,14 +388,14 @@ test_create(hid_t file) static herr_t test_simple_io(const char *env_h5_drvr, hid_t fapl) { - char filename[FILENAME_BUF_SIZE]; - hid_t file = -1, dataset = -1, space = -1, xfer = -1; - int i, j, n; - hsize_t dims[2]; - void *tconv_buf = NULL; - int f = -1; - haddr_t offset; - int rdata[DSET_DIM1][DSET_DIM2]; + char filename[FILENAME_BUF_SIZE]; + hid_t file = -1, dataset = -1, space = -1, xfer = -1; + int i, j, n; + hsize_t dims[2]; + void *tconv_buf = NULL; + int f = -1; + haddr_t offset; + int rdata[DSET_DIM1][DSET_DIM2]; TESTING("simple I/O"); @@ -465,7 +465,8 @@ test_simple_io(const char *env_h5_drvr, hid_t fapl) f = HDopen(filename, O_RDONLY, 0); HDlseek(f, (off_t)offset, SEEK_SET); - HDread(f, rdata, sizeof(int)*DSET_DIM1*DSET_DIM2); + if(HDread(f, rdata, sizeof(int)*DSET_DIM1*DSET_DIM2) < 0) + goto error; /* Check that the values read are the same as the values written */ for(i = 0; i < DSET_DIM1; i++) { @@ -6702,7 +6703,7 @@ test_random_chunks(hid_t fapl) if(H5Fclose(file) < 0) TEST_ERROR; - /* Create file for second test */ + /* Create second file */ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR; /* Create dataspace with unlimited maximum dimensions */ @@ -7474,7 +7475,7 @@ test_big_chunks_bypass_cache(hid_t fapl) if(H5Dread(dsid, H5T_NATIVE_INT, H5S_ALL, sid, H5P_DEFAULT, rdata2) < 0) for(i = 0; i < BYPASS_CHUNK_DIM / 2; i++) - if(rdata2[i] != i) { + if(rdata2[i] != i) { printf(" Read different values than written in the chunk.\n"); printf(" At line %d and index %d, rdata2 = %d. It should be %d.\n", __LINE__, i, rdata2[i], i); TEST_ERROR @@ -9145,38 +9146,38 @@ main(void) nerrors += (test_simple_io(envval, my_fapl) < 0 ? 1 : 0); nerrors += (test_compact_io(my_fapl) < 0 ? 1 : 0); nerrors += (test_max_compact(my_fapl) < 0 ? 1 : 0); - nerrors += (test_conv_buffer(file) < 0 ? 1 : 0); + nerrors += (test_conv_buffer(file) < 0 ? 1 : 0); nerrors += (test_tconv(file) < 0 ? 1 : 0); nerrors += (test_filters(file, my_fapl) < 0 ? 1 : 0); nerrors += (test_onebyte_shuffle(file) < 0 ? 1 : 0); - nerrors += (test_nbit_int(file) < 0 ? 1 : 0); - nerrors += (test_nbit_float(file) < 0 ? 1 : 0); - nerrors += (test_nbit_double(file) < 0 ? 1 : 0); - nerrors += (test_nbit_array(file) < 0 ? 1 : 0); + nerrors += (test_nbit_int(file) < 0 ? 1 : 0); + nerrors += (test_nbit_float(file) < 0 ? 1 : 0); + nerrors += (test_nbit_double(file) < 0 ? 1 : 0); + nerrors += (test_nbit_array(file) < 0 ? 1 : 0); nerrors += (test_nbit_compound(file) < 0 ? 1 : 0); nerrors += (test_nbit_compound_2(file) < 0 ? 1 : 0); nerrors += (test_nbit_compound_3(file) < 0 ? 1 : 0); nerrors += (test_nbit_int_size(file) < 0 ? 1 : 0); nerrors += (test_nbit_flt_size(file) < 0 ? 1 : 0); nerrors += (test_scaleoffset_int(file) < 0 ? 1 : 0); - nerrors += (test_scaleoffset_int_2(file) < 0 ? 1 : 0); - nerrors += (test_scaleoffset_float(file) < 0 ? 1 : 0); - nerrors += (test_scaleoffset_float_2(file) < 0 ? 1 : 0); - nerrors += (test_scaleoffset_double(file) < 0 ? 1 : 0); + nerrors += (test_scaleoffset_int_2(file) < 0 ? 1 : 0); + nerrors += (test_scaleoffset_float(file) < 0 ? 1 : 0); + nerrors += (test_scaleoffset_float_2(file) < 0 ? 1 : 0); + nerrors += (test_scaleoffset_double(file) < 0 ? 1 : 0); nerrors += (test_scaleoffset_double_2(file) < 0 ? 1 : 0); - nerrors += (test_multiopen (file) < 0 ? 1 : 0); - nerrors += (test_types(file) < 0 ? 1 : 0); - nerrors += (test_userblock_offset(envval, my_fapl) < 0 ? 1 : 0); + nerrors += (test_multiopen (file) < 0 ? 1 : 0); + nerrors += (test_types(file) < 0 ? 1 : 0); + nerrors += (test_userblock_offset(envval, my_fapl) < 0 ? 1 : 0); nerrors += (test_missing_filter(file) < 0 ? 1 : 0); - nerrors += (test_can_apply(file) < 0 ? 1 : 0); - nerrors += (test_can_apply2(file) < 0 ? 1 : 0); - nerrors += (test_set_local(my_fapl) < 0 ? 1 : 0); + nerrors += (test_can_apply(file) < 0 ? 1 : 0); + nerrors += (test_can_apply2(file) < 0 ? 1 : 0); + nerrors += (test_set_local(my_fapl) < 0 ? 1 : 0); nerrors += (test_can_apply_szip(file) < 0 ? 1 : 0); - nerrors += (test_compare_dcpl(file) < 0 ? 1 : 0); - nerrors += (test_copy_dcpl(file, my_fapl) < 0 ? 1 : 0); + nerrors += (test_compare_dcpl(file) < 0 ? 1 : 0); + nerrors += (test_copy_dcpl(file, my_fapl) < 0 ? 1 : 0); nerrors += (test_filter_delete(file) < 0 ? 1 : 0); - nerrors += (test_filters_endianess() < 0 ? 1 : 0); - nerrors += (test_zero_dims(file) < 0 ? 1 : 0); + nerrors += (test_filters_endianess() < 0 ? 1 : 0); + nerrors += (test_zero_dims(file) < 0 ? 1 : 0); nerrors += (test_missing_chunk(file) < 0 ? 1 : 0); nerrors += (test_random_chunks(my_fapl) < 0 ? 1 : 0); #ifndef H5_NO_DEPRECATED_SYMBOLS @@ -9186,9 +9187,9 @@ main(void) nerrors += (test_chunk_cache(my_fapl) < 0 ? 1 : 0); nerrors += (test_big_chunks_bypass_cache(my_fapl) < 0 ? 1 : 0); nerrors += (test_chunk_expand(my_fapl) < 0 ? 1 : 0); - nerrors += (test_layout_extend(my_fapl) < 0 ? 1 : 0); - nerrors += (test_large_chunk_shrink(my_fapl) < 0 ? 1 : 0); - nerrors += (test_zero_dim_dset(my_fapl) < 0 ? 1 : 0); + nerrors += (test_layout_extend(my_fapl) < 0 ? 1 : 0); + nerrors += (test_large_chunk_shrink(my_fapl) < 0 ? 1 : 0); + nerrors += (test_zero_dim_dset(my_fapl) < 0 ? 1 : 0); if(H5Fclose(file) < 0) goto error; diff --git a/test/earray.c b/test/earray.c index 368ee42..95733e9 100644 --- a/test/earray.c +++ b/test/earray.c @@ -185,6 +185,7 @@ static herr_t earray_cache_test_free_icr(void *thing); /* Local variables */ const char *FILENAME[] = { "earray", + "earray_tmp", NULL }; @@ -332,10 +333,10 @@ finish_tparam(earray_test_param_t *tparam) *------------------------------------------------------------------------- */ static int -create_file(hid_t fapl, hid_t *file, H5F_t **f) +create_file(unsigned flags, hid_t fapl, hid_t *file, H5F_t **f) { /* Create the file to work on */ - if((*file = H5Fcreate(filename_g, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if((*file = H5Fcreate(filename_g, flags, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ @@ -343,9 +344,8 @@ create_file(hid_t fapl, hid_t *file, H5F_t **f) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(*f) < 0) { + if(H5AC_ignore_tags(*f) < 0) FAIL_STACK_ERROR - } /* Success */ return(0); @@ -454,17 +454,19 @@ reopen_file(hid_t *file, H5F_t **f, hid_t fapl, hid_t dxpl, /* (actually will close & re-open the file as well) */ if(tparam->reopen_array) { /* Close array, if given */ - if(ea) { + if(ea && *ea) { if(H5EA_close(*ea, dxpl) < 0) FAIL_STACK_ERROR *ea = NULL; } /* end if */ /* Close file */ - if(H5Fclose(*file) < 0) - FAIL_STACK_ERROR - *file = (-1); - *f = NULL; + if(*file) { + if(H5Fclose(*file) < 0) + FAIL_STACK_ERROR + *file = (-1); + *f = NULL; + } /* end if */ /* Re-open the file */ if((*file = H5Fopen(filename_g, H5F_ACC_RDWR, fapl)) < 0) @@ -475,15 +477,13 @@ reopen_file(hid_t *file, H5F_t **f, hid_t fapl, hid_t dxpl, FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(*f) < 0) { + if(H5AC_ignore_tags(*f) < 0) FAIL_STACK_ERROR - } /* Re-open array, if given */ - if(ea) { + if(ea) if(NULL == (*ea = H5EA_open(*f, dxpl, ea_addr, NULL))) FAIL_STACK_ERROR - } /* end if */ } /* end if */ /* Success */ @@ -893,7 +893,7 @@ test_create(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t H5_ATTR_UNUSE haddr_t ea_addr = HADDR_UNDEF; /* Array address in file */ /* Create file & retrieve pointer to internal file object */ - if(create_file(fapl, &file, &f) < 0) + if(create_file(H5F_ACC_TRUNC, fapl, &file, &f) < 0) TEST_ERROR /* @@ -1008,7 +1008,7 @@ test_create(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t H5_ATTR_UNUSE /* Set invalid max. # of elements per data block page bits */ if(test_cparam.idx_blk_elmts > 0) { HDmemcpy(&test_cparam, cparam, sizeof(test_cparam)); - test_cparam.max_dblk_page_nelmts_bits = H5VM_log2_gen((uint64_t)test_cparam.idx_blk_elmts) - 1; + test_cparam.max_dblk_page_nelmts_bits = (uint8_t)(H5VM_log2_gen((uint64_t)test_cparam.idx_blk_elmts) - 1); H5E_BEGIN_TRY { ea = H5EA_create(f, H5P_DATASET_XFER_DEFAULT, &test_cparam, NULL); } H5E_END_TRY; @@ -1035,7 +1035,7 @@ test_create(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t H5_ATTR_UNUSE TEST_ERROR } /* end if */ HDmemcpy(&test_cparam, cparam, sizeof(test_cparam)); - test_cparam.max_dblk_page_nelmts_bits = test_cparam.max_nelmts_bits + 1; + test_cparam.max_dblk_page_nelmts_bits = (uint8_t)(test_cparam.max_nelmts_bits + 1); H5E_BEGIN_TRY { ea = H5EA_create(f, H5P_DATASET_XFER_DEFAULT, &test_cparam, NULL); } H5E_END_TRY; @@ -1115,7 +1115,7 @@ test_reopen(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam) haddr_t ea_addr = HADDR_UNDEF; /* Array address in file */ /* Create file & retrieve pointer to internal file object */ - if(create_file(fapl, &file, &f) < 0) + if(create_file(H5F_ACC_TRUNC, fapl, &file, &f) < 0) TEST_ERROR /* @@ -1188,7 +1188,7 @@ test_open_twice(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam) haddr_t ea_addr = HADDR_UNDEF; /* Array address in file */ /* Create file & retrieve pointer to internal file object */ - if(create_file(fapl, &file, &f) < 0) + if(create_file(H5F_ACC_TRUNC, fapl, &file, &f) < 0) TEST_ERROR /* @@ -1271,6 +1271,148 @@ error: /*------------------------------------------------------------------------- + * Function: test_open_twice_diff + * + * Purpose: Open an extensible array twice, through different "top" file + * handles, with an intermediate file open that takes the "shared" + * file handle from the first extensible array's file pointer. + * + * Return: Success: 0 + * Failure: 1 + * + * Programmer: Quincey Koziol + * Friday, December 18, 2015 + * + *------------------------------------------------------------------------- + */ +static unsigned +test_open_twice_diff(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam) +{ + char filename_tmp[EARRAY_FILENAME_LEN]; /* Temporary file name */ + hid_t file = -1; /* File ID */ + hid_t file2 = -1; /* File ID */ + hid_t file0 = -1; /* File ID */ + hid_t file00 = -1; /* File ID */ + H5F_t *f = NULL; /* Internal file object pointer */ + H5F_t *f2 = NULL; /* Internal file object pointer */ + H5EA_t *ea = NULL; /* Extensible array wrapper */ + H5EA_t *ea2 = NULL; /* Extensible array wrapper */ + haddr_t ea_addr = HADDR_UNDEF; /* Array address in file */ + + /* Create file & retrieve pointer to internal file object */ + if(create_file(H5F_ACC_TRUNC, fapl, &file, &f) < 0) + TEST_ERROR + + /* + * Display testing message + */ + TESTING("open extensible array twice, through different file handles"); + + /* Create array */ + if(create_array(f, H5P_DATASET_XFER_DEFAULT, cparam, &ea, &ea_addr, NULL) < 0) + TEST_ERROR + + /* Open the array again, through the first file handle */ + if(NULL == (ea2 = H5EA_open(f, H5P_DATASET_XFER_DEFAULT, ea_addr, NULL))) + FAIL_STACK_ERROR + + /* Verify the creation parameters */ + if(verify_cparam(ea, cparam) < 0) + TEST_ERROR + if(verify_cparam(ea2, cparam) < 0) + TEST_ERROR + + /* Close the second extensible array wrapper */ + if(H5EA_close(ea2, H5P_DATASET_XFER_DEFAULT) < 0) + FAIL_STACK_ERROR + ea2 = NULL; + + /* Re-open the file */ + /* (So that there is something holding the file open when the extensible + * array is closed) + */ + if((file0 = H5Fopen(filename_g, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR + + /* Check for closing & re-opening the file */ + if(reopen_file(&file, &f, fapl, H5P_DATASET_XFER_DEFAULT, &ea, ea_addr, tparam) < 0) + TEST_ERROR + + /* Verify the creation parameters */ + if(verify_cparam(ea, cparam) < 0) + TEST_ERROR + + /* Close the first extensible array wrapper */ + if(H5EA_close(ea, H5P_DATASET_XFER_DEFAULT) < 0) + FAIL_STACK_ERROR + ea = NULL; + + /* Close the first file */ + /* (close before second file, to detect error on internal array header's + * shared file information) + */ + if(H5Fclose(file) < 0) + FAIL_STACK_ERROR + file = -1; + + /* Open a different file */ + /* (This re-allocates the 'top' file pointer and assigns it a different + * 'shared' file pointer, making the file pointer in the extensible array's + * header stale) + */ + h5_fixname(FILENAME[1], fapl, filename_tmp, sizeof(filename_tmp)); + if((file00 = H5Fcreate(filename_tmp, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR + + + /* Re-open the file with the extensible array */ + if((file2 = H5Fopen(filename_g, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR + + /* Get a pointer to the internal file object */ + if(NULL == (f2 = (H5F_t *)H5I_object(file2))) + FAIL_STACK_ERROR + + /* Open the extensible array through the second file handle */ + if(NULL == (ea2 = H5EA_open(f2, H5P_DATASET_XFER_DEFAULT, ea_addr, NULL))) + FAIL_STACK_ERROR + + /* Verify the creation parameters */ + if(verify_cparam(ea2, cparam) < 0) + TEST_ERROR + + /* Close the extra file handles */ + if(H5Fclose(file0) < 0) + FAIL_STACK_ERROR + if(H5Fclose(file00) < 0) + FAIL_STACK_ERROR + + /* Close array, delete array, close file & verify file is empty */ + if(finish(file2, fapl, f2, ea2, ea_addr) < 0) + TEST_ERROR + + /* All tests passed */ + PASSED() + + return 0; + +error: + H5E_BEGIN_TRY { + if(ea) + H5EA_close(ea, H5P_DATASET_XFER_DEFAULT); + if(ea2) + H5EA_close(ea2, H5P_DATASET_XFER_DEFAULT); + H5Fclose(file); + H5Fclose(file2); + H5Fclose(file0); + H5Fclose(file00); + } H5E_END_TRY; + + return 1; +} /* test_open_twice_diff() */ + + +/*------------------------------------------------------------------------- * Function: test_delete_open * * Purpose: Delete opened extensible array (& open deleted array) @@ -1294,7 +1436,7 @@ test_delete_open(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam) h5_stat_size_t file_size; /* File size, after deleting array */ /* Create file & retrieve pointer to internal file object */ - if(create_file(fapl, &file, &f) < 0) + if(create_file(H5F_ACC_TRUNC, fapl, &file, &f) < 0) TEST_ERROR /* @@ -1483,7 +1625,7 @@ test_flush_depend(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t H5_ATTR hsize_t idx; /* Index value of element */ /* Create file & retrieve pointer to internal file object */ - if(create_file(fapl, &file, &f) < 0) + if(create_file(H5F_ACC_TRUNC, fapl, &file, &f) < 0) TEST_ERROR /* @@ -1758,7 +1900,7 @@ eiter_fw_next(void *_eiter) * *------------------------------------------------------------------------- */ -static hssize_t +static H5_ATTR_PURE hssize_t eiter_fw_max(const void *_eiter) { const eiter_fw_t *eiter = (const eiter_fw_t *)_eiter; @@ -1976,7 +2118,7 @@ eiter_rv_next(void *_eiter) * *------------------------------------------------------------------------- */ -static hssize_t +static H5_ATTR_PURE hssize_t eiter_rv_max(const void *_eiter) { const eiter_rv_t *eiter = (const eiter_rv_t *)_eiter; @@ -2228,7 +2370,7 @@ eiter_rnd_next(void *_eiter) * *------------------------------------------------------------------------- */ -static hssize_t +static H5_ATTR_PURE hssize_t eiter_rnd_max(const void *_eiter) { const eiter_rnd_t *eiter = (const eiter_rnd_t *)_eiter; @@ -2449,7 +2591,7 @@ eiter_cyc_next(void *_eiter) * *------------------------------------------------------------------------- */ -static hssize_t +static H5_ATTR_PURE hssize_t eiter_cyc_max(const void *_eiter) { const eiter_cyc_t *eiter = (const eiter_cyc_t *)_eiter; @@ -2537,7 +2679,7 @@ test_set_elmts(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam, TESTING(test_str); /* Create file & retrieve pointer to internal file object */ - if(create_file(fapl, &file, &f) < 0) + if(create_file(H5F_ACC_TRUNC, fapl, &file, &f) < 0) TEST_ERROR /* Create array */ @@ -2711,7 +2853,7 @@ test_skip_elmts(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam, TESTING(test_str); /* Create file & retrieve pointer to internal file object */ - if(create_file(fapl, &file, &f) < 0) + if(create_file(H5F_ACC_TRUNC, fapl, &file, &f) < 0) TEST_ERROR /* Create array */ @@ -2871,7 +3013,7 @@ main(void) /* Seed random #'s */ curr_time = HDtime(NULL); - HDsrandom((unsigned long)curr_time); + HDsrandom((unsigned)curr_time); /* Create an empty file to retrieve size */ { @@ -2922,6 +3064,7 @@ main(void) nerrors += test_create(fapl, &cparam, &tparam); nerrors += test_reopen(fapl, &cparam, &tparam); nerrors += test_open_twice(fapl, &cparam, &tparam); + nerrors += test_open_twice_diff(fapl, &cparam, &tparam); nerrors += test_delete_open(fapl, &cparam, &tparam); nerrors += test_flush_depend(fapl, &cparam, &tparam); diff --git a/test/farray.c b/test/farray.c index e3e59da..50a9856 100644 --- a/test/farray.c +++ b/test/farray.c @@ -102,6 +102,7 @@ struct farray_test_param_t { /* Local variables */ const char *FILENAME[] = { "farray", + "farray_tmp", NULL }; @@ -159,9 +160,8 @@ create_file(hid_t fapl, hid_t *file, H5F_t **f) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(*f) < 0) { + if(H5AC_ignore_tags(*f) < 0) FAIL_STACK_ERROR - } /* Success */ return(0); @@ -274,17 +274,19 @@ reopen_file(hid_t *file, H5F_t **f, hid_t fapl, hid_t dxpl, /* (actually will close & re-open the file as well) */ if(tparam->reopen_array) { /* Close array, if given */ - if(fa) { + if(fa && *fa) { if(H5FA_close(*fa, dxpl) < 0) FAIL_STACK_ERROR *fa = NULL; } /* end if */ /* Close file */ - if(H5Fclose(*file) < 0) - FAIL_STACK_ERROR - *file = (-1); - *f = NULL; + if(*file) { + if(H5Fclose(*file) < 0) + FAIL_STACK_ERROR + *file = (-1); + *f = NULL; + } /* end if */ /* Re-open the file */ if((*file = H5Fopen(filename_g, H5F_ACC_RDWR, fapl)) < 0) @@ -295,15 +297,13 @@ reopen_file(hid_t *file, H5F_t **f, hid_t fapl, hid_t dxpl, FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(*f) < 0) { + if(H5AC_ignore_tags(*f) < 0) FAIL_STACK_ERROR - } /* Re-open array, if given */ - if(fa) { + if(fa) if(NULL == (*fa = H5FA_open(*f, dxpl, fa_addr, NULL))) FAIL_STACK_ERROR - } /* end if */ } /* end if */ /* Success */ @@ -722,6 +722,144 @@ error: /*------------------------------------------------------------------------- + * Function: test_open_twice_diff + * + * Purpose: Open a fixed array twice, through different "top" file + * handles, with an intermediate file open that takes the "shared" + * file handle from the first fixed array's file pointer. + * + * Return: Success: 0 + * Failure: 1 + * + * Programmer: Quincey Koziol + * Friday, December 18, 2015 + * + *------------------------------------------------------------------------- + */ +static unsigned +test_open_twice_diff(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t *tparam) +{ + char filename_tmp[FARRAY_FILENAME_LEN]; /* Temporary file name */ + hid_t file = -1; /* File ID */ + hid_t file2 = -1; /* File ID */ + hid_t file0 = -1; /* File ID */ + hid_t file00 = -1; /* File ID */ + H5F_t *f = NULL; /* Internal file object pointer */ + H5F_t *f2 = NULL; /* Internal file object pointer */ + H5FA_t *fa = NULL; /* Fixed array wrapper */ + H5FA_t *fa2 = NULL; /* Fixed array wrapper */ + haddr_t fa_addr = HADDR_UNDEF; /* Array address in file */ + + /* + * Display testing message + */ + TESTING("open fixed array twice, through different file handles"); + + /* Create file & retrieve pointer to internal file object */ + if(create_file(fapl, &file, &f) < 0) + TEST_ERROR + + /* Create array */ + if(create_array(f, H5P_DATASET_XFER_DEFAULT, cparam, &fa, &fa_addr) < 0) + TEST_ERROR + + /* Open the array again, through the first file handle */ + if(NULL == (fa2 = H5FA_open(f, H5P_DATASET_XFER_DEFAULT, fa_addr, NULL))) + FAIL_STACK_ERROR + + /* Verify the creation parameters */ + if(verify_cparam(fa, cparam) < 0) + TEST_ERROR + if(verify_cparam(fa2, cparam) < 0) + TEST_ERROR + + /* Close the second fixed array wrapper */ + if(H5FA_close(fa2, H5P_DATASET_XFER_DEFAULT) < 0) + FAIL_STACK_ERROR + fa2 = NULL; + + /* Re-open the file */ + /* (So that there is something holding the file open when the extensible + * array is closed) + */ + if((file0 = H5Fopen(filename_g, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR + + /* Check for closing & re-opening the file */ + if(reopen_file(&file, &f, fapl, H5P_DATASET_XFER_DEFAULT, &fa, fa_addr, tparam) < 0) + TEST_ERROR + + /* Close the first fixed array wrapper */ + if(H5FA_close(fa, H5P_DATASET_XFER_DEFAULT) < 0) + FAIL_STACK_ERROR + fa = NULL; + + /* Close the first file */ + /* (close before second file, to detect error on internal array header's + * shared file information) + */ + if(H5Fclose(file) < 0) + FAIL_STACK_ERROR + file = -1; + + /* Open a different file */ + /* (This re-allocates the 'top' file pointer and assigns it a different + * 'shared' file pointer, making the file pointer in the fixed array's + * header stale) + */ + h5_fixname(FILENAME[1], fapl, filename_tmp, sizeof(filename_tmp)); + if((file00 = H5Fcreate(filename_tmp, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR + + + /* Re-open the file with the fixed array */ + if((file2 = H5Fopen(filename_g, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR + + /* Get a pointer to the internal file object */ + if(NULL == (f2 = (H5F_t *)H5I_object(file2))) + FAIL_STACK_ERROR + + /* Open the fixed array through the second file handle */ + if(NULL == (fa2 = H5FA_open(f2, H5P_DATASET_XFER_DEFAULT, fa_addr, NULL))) + FAIL_STACK_ERROR + + /* Verify the creation parameters */ + if(verify_cparam(fa2, cparam) < 0) + TEST_ERROR + + /* Close the extra file handles */ + if(H5Fclose(file0) < 0) + FAIL_STACK_ERROR + if(H5Fclose(file00) < 0) + FAIL_STACK_ERROR + + /* Close array, delete array, close file & verify file is empty */ + if(finish(file2, fapl, f2, fa2, fa_addr) < 0) + TEST_ERROR + + /* All tests passed */ + PASSED() + + return 0; + +error: + H5E_BEGIN_TRY { + if(fa) + H5FA_close(fa, H5P_DATASET_XFER_DEFAULT); + if(fa2) + H5FA_close(fa2, H5P_DATASET_XFER_DEFAULT); + H5Fclose(file); + H5Fclose(file2); + H5Fclose(file0); + H5Fclose(file00); + } H5E_END_TRY; + + return 1; +} /* test_open_twice_diff() */ + + +/*------------------------------------------------------------------------- * Function: test_delete_open * * Purpose: Delete opened fixed array (& open deleted array) @@ -1535,7 +1673,7 @@ main(void) /* Seed random #'s */ curr_time = HDtime(NULL); - HDsrandom((unsigned long)curr_time); + HDsrandom((unsigned)curr_time); /* Create an empty file to retrieve size */ { @@ -1586,6 +1724,7 @@ main(void) nerrors += test_create(fapl, &cparam, &tparam); nerrors += test_reopen(fapl, &cparam, &tparam); nerrors += test_open_twice(fapl, &cparam, &tparam); + nerrors += test_open_twice_diff(fapl, &cparam, &tparam); nerrors += test_delete_open(fapl, &cparam, &tparam); /* Iterate over the type of capacity tests */ -- cgit v0.12 From 4a25e5b788b6264eaed93de45a55a333b204a037 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Mon, 21 Dec 2015 17:22:55 -0500 Subject: [svn-r28717] Description: Minor change to align w/revise_chunks branch Tested on: MacOSX/64 10.11.2 (amazon) w/serial & parallel (too minor for h5committest) --- src/H5Dchunk.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index ab621ca..efd94c0 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -1885,6 +1885,9 @@ H5D__chunk_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, void *chunk = NULL; /* Pointer to locked chunk buffer */ htri_t cacheable; /* Whether the chunk is cacheable */ + /* Set chunk's [scaled] coordinates */ + io_info->store->chunk.scaled = chunk_info->scaled; + /* Determine if we should use the chunk cache */ if((cacheable = H5D__chunk_cacheable(io_info, udata.chunk_block.offset, FALSE)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't tell if chunk is cacheable") @@ -1895,9 +1898,6 @@ H5D__chunk_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, H5_CHECK_OVERFLOW(type_info->src_type_size, /*From:*/ size_t, /*To:*/ uint32_t); src_accessed_bytes = chunk_info->chunk_points * (uint32_t)type_info->src_type_size; - /* Set chunk's [scaled] coordinates */ - io_info->store->chunk.scaled = chunk_info->scaled; - /* Lock the chunk into the cache */ if(NULL == (chunk = H5D__chunk_lock(io_info, &udata, FALSE))) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "unable to read raw data chunk") @@ -2011,6 +2011,9 @@ H5D__chunk_write(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, HDassert((H5F_addr_defined(udata.chunk_block.offset) && udata.chunk_block.length > 0) || (!H5F_addr_defined(udata.chunk_block.offset) && udata.chunk_block.length == 0)); + /* Set chunk's [scaled] coordinates */ + io_info->store->chunk.scaled = chunk_info->scaled; + /* Determine if we should use the chunk cache */ if((cacheable = H5D__chunk_cacheable(io_info, udata.chunk_block.offset, TRUE)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't tell if chunk is cacheable") @@ -2029,9 +2032,6 @@ H5D__chunk_write(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, fm->fsel_type == H5S_SEL_POINTS) entire_chunk = FALSE; - /* Set chunk's [scaled] coordinates */ - io_info->store->chunk.scaled = chunk_info->scaled; - /* Lock the chunk into the cache */ if(NULL == (chunk = H5D__chunk_lock(io_info, &udata, entire_chunk))) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "unable to read raw data chunk") @@ -3684,9 +3684,6 @@ H5D__chunk_allocate(const H5D_t *dset, hid_t dxpl_id, hbool_t full_overwrite, } /* end if */ /* Insert the chunk record into the index */ - /* (Note that this isn't safe, from a SWMR perspective, unlike - * serial operation. -QAK - */ if(need_insert && ops->insert) if((ops->insert)(&idx_info, &udata, dset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "unable to insert chunk addr into index") -- cgit v0.12 From 6f83966fb9709ebd30e41d70f1bfd36ddce79636 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Tue, 22 Dec 2015 15:12:08 -0500 Subject: [svn-r28723] Description: Bring over rest of performance improvements for extending chunked datasets and normalize against revise_chunks branch. Tested on: MacOSX/64 10.11.2 (amazon) w/serial & parallel) (h5committest forthcoming) --- src/H5Dchunk.c | 184 ++++++++++++++++++++++++++++++++++++++++++------------- src/H5Dint.c | 5 ++ src/H5Dlayout.c | 6 +- src/H5Dpkg.h | 9 ++- src/H5Oprivate.h | 4 ++ src/H5Pdcpl.c | 38 ++++++++---- 6 files changed, 187 insertions(+), 59 deletions(-) diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index efd94c0..2e000e3 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -72,6 +72,10 @@ #define H5D_CHUNK_GET_NODE_INFO(map, node) (map->use_single ? map->single_chunk_info : (H5D_chunk_info_t *)H5SL_item(node)) #define H5D_CHUNK_GET_NEXT_NODE(map, node) (map->use_single ? (H5SL_node_t *)NULL : H5SL_next(node)) +/* Sanity check on chunk index types: commonly used by a lot of routines in this file */ +#define H5D_CHUNK_STORAGE_INDEX_CHK(storage) \ + HDassert((H5D_CHUNK_IDX_BTREE == storage->idx_type && H5D_COPS_BTREE == storage->ops)); + /* * Feature: If this constant is defined then every cache preemption and load * causes a character to be printed on the standard error stream: @@ -215,7 +219,7 @@ H5D__nonexistent_readvv(const H5D_io_info_t *io_info, /* Helper routines */ static herr_t H5D__chunk_set_info_real(H5O_layout_chunk_t *layout, unsigned ndims, - const hsize_t *curr_dims); + const hsize_t *curr_dims, const hsize_t *max_dims); static void *H5D__chunk_mem_alloc(size_t size, const H5O_pline_t *pline); static void *H5D__chunk_mem_xfree(void *chk, const H5O_pline_t *pline); static void *H5D__chunk_mem_realloc(void *chk, size_t size, @@ -244,7 +248,8 @@ static herr_t H5D__chunk_cache_prune(const H5D_t *dset, hid_t dxpl_id, const H5D_dxpl_cache_t *dxpl_cache, size_t size); static herr_t H5D__chunk_prune_fill(H5D_chunk_it_ud1_t *udata); static herr_t H5D__chunk_file_alloc(const H5D_chk_idx_info_t *idx_info, - const H5F_block_t *old_chunk, H5F_block_t *new_chunk, hbool_t *need_insert); + const H5F_block_t *old_chunk, H5F_block_t *new_chunk, hbool_t *need_insert, + hsize_t scaled[]); #ifdef H5_HAVE_PARALLEL static herr_t H5D__chunk_collective_fill(const H5D_t *dset, hid_t dxpl_id, H5D_chunk_coll_info_t *chunk_info, size_t chunk_size, const void *fill_buf); @@ -377,7 +382,7 @@ H5D__chunk_direct_write(const H5D_t *dset, hid_t dxpl_id, uint32_t filters, /* Create the chunk it if it doesn't exist, or reallocate the chunk * if its size changed. */ - if(H5D__chunk_file_alloc(&idx_info, &old_chunk, &udata.chunk_block, &need_insert) < 0) + if(H5D__chunk_file_alloc(&idx_info, &old_chunk, &udata.chunk_block, &need_insert, scaled) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "unable to allocate chunk") /* Make sure the address of the chunk is returned. */ @@ -430,7 +435,8 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5D__chunk_set_info_real(H5O_layout_chunk_t *layout, unsigned ndims, const hsize_t *curr_dims) +H5D__chunk_set_info_real(H5O_layout_chunk_t *layout, unsigned ndims, + const hsize_t *curr_dims, const hsize_t *max_dims) { unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ @@ -443,17 +449,21 @@ H5D__chunk_set_info_real(H5O_layout_chunk_t *layout, unsigned ndims, const hsize HDassert(curr_dims); /* Compute the # of chunks in dataset dimensions */ - for(u = 0, layout->nchunks = 1; u < ndims; u++) { + for(u = 0, layout->nchunks = 1, layout->max_nchunks = 1; u < ndims; u++) { /* Round up to the next integer # of chunks, to accomodate partial chunks */ layout->chunks[u] = ((curr_dims[u] + layout->dim[u]) - 1) / layout->dim[u]; + layout->max_chunks[u] = ((max_dims[u] + layout->dim[u]) - 1) / layout->dim[u]; /* Accumulate the # of chunks */ layout->nchunks *= layout->chunks[u]; + layout->max_nchunks *= layout->max_chunks[u]; } /* end for */ /* Get the "down" sizes for each dimension */ if(H5VM_array_down(ndims, layout->chunks, layout->down_chunks) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't compute 'down' chunk size value") + if(H5VM_array_down(ndims, layout->max_chunks, layout->max_down_chunks) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't compute 'down' chunk size value") done: FUNC_LEAVE_NOAPI(ret_value) @@ -483,7 +493,7 @@ H5D__chunk_set_info(const H5D_t *dset) HDassert(dset); /* Set the base layout information */ - if(H5D__chunk_set_info_real(&dset->shared->layout.u.chunk, dset->shared->ndims, dset->shared->curr_dims) < 0) + if(H5D__chunk_set_info_real(&dset->shared->layout.u.chunk, dset->shared->ndims, dset->shared->curr_dims, dset->shared->max_dims) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set layout's chunk info") /* Call the index's "resize" callback */ @@ -596,6 +606,7 @@ H5D__chunk_init(H5F_t *f, hid_t dxpl_id, const H5D_t *dset, hid_t dapl_id) H5D_chk_idx_info_t idx_info; /* Chunked index info */ H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); /* Convenience pointer to dataset's chunk cache */ H5P_genplist_t *dapl; /* Data access property list object pointer */ + H5O_storage_chunk_t *sc = &(dset->shared->layout.storage.u.chunk); herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -603,6 +614,7 @@ H5D__chunk_init(H5F_t *f, hid_t dxpl_id, const H5D_t *dset, hid_t dapl_id) /* Sanity check */ HDassert(f); HDassert(dset); + H5D_CHUNK_STORAGE_INDEX_CHK(sc); if(NULL == (dapl = (H5P_genplist_t *)H5I_object(dapl_id))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for fapl ID") @@ -686,12 +698,14 @@ done: hbool_t H5D__chunk_is_space_alloc(const H5O_storage_t *storage) { + const H5O_storage_chunk_t *sc = &(storage->u.chunk); hbool_t ret_value = FALSE; /* Return value */ FUNC_ENTER_PACKAGE_NOERR /* Sanity checks */ HDassert(storage); + H5D_CHUNK_STORAGE_INDEX_CHK(sc); /* Query index layer */ ret_value = (storage->u.chunk.ops->is_space_alloc)(&storage->u.chunk); @@ -1343,6 +1357,9 @@ H5D__create_chunk_file_map_hyper(H5D_chunk_map_t *fm, const H5D_io_info_t HDmemcpy(new_chunk_info->scaled, scaled, sizeof(hsize_t) * fm->f_ndims); new_chunk_info->scaled[fm->f_ndims] = 0; + /* Copy the chunk's scaled coordinates */ + HDmemcpy(new_chunk_info->scaled, scaled, sizeof(hsize_t) * fm->f_ndims); + /* Insert the new chunk into the skip list */ if(H5SL_insert(fm->sel_chunks, new_chunk_info, &new_chunk_info->index) < 0) { H5D__free_chunk_info(new_chunk_info, NULL, NULL); @@ -1600,6 +1617,7 @@ H5D__chunk_file_cb(void H5_ATTR_UNUSED *elem, const H5T_t H5_ATTR_UNUSED *type, /* Set the chunk's scaled coordinates */ HDmemcpy(chunk_info->scaled, scaled, sizeof(hsize_t) * fm->f_ndims); chunk_info->scaled[fm->f_ndims] = 0; + HDmemcpy(chunk_info->scaled, scaled, sizeof(hsize_t) * fm->f_ndims); /* Insert the new chunk into the skip list */ if(H5SL_insert(fm->sel_chunks,chunk_info,&chunk_info->index) < 0) { @@ -2056,7 +2074,7 @@ H5D__chunk_write(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, udata.chunk_block.length = io_info->dset->shared->layout.u.chunk.size; /* Allocate the chunk */ - if(H5D__chunk_file_alloc(&idx_info, NULL, &udata.chunk_block, &need_insert) < 0) + if(H5D__chunk_file_alloc(&idx_info, NULL, &udata.chunk_block, &need_insert, chunk_info->scaled) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "unable to insert/resize chunk on chunk level") /* Make sure the address of the chunk is returned. */ @@ -2221,12 +2239,14 @@ H5D__chunk_dest(H5D_t *dset, hid_t dxpl_id) H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); /* Dataset's chunk cache */ H5D_rdcc_ent_t *ent = NULL, *next = NULL; /* Pointer to current & next cache entries */ int nerrors = 0; /* Accumulated count of errors */ + H5O_storage_chunk_t *sc = &(dset->shared->layout.storage.u.chunk); herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC_TAG(dxpl_id, dset->oloc.addr, FAIL) /* Sanity checks */ HDassert(dset); + H5D_CHUNK_STORAGE_INDEX_CHK(sc); /* Fill the DXPL cache values for later use */ if(H5D__get_dxpl_cache(dxpl_id, &dxpl_cache) < 0) @@ -2287,6 +2307,7 @@ H5D_chunk_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr) /* Sanity checks */ HDassert(storage); HDassert(storage->ops); + H5D_CHUNK_STORAGE_INDEX_CHK(storage); /* Reset index structures */ if((storage->ops->reset)(storage, reset_addr) < 0) @@ -2351,6 +2372,7 @@ H5D__chunk_cinfo_cache_update(H5D_chunk_cached_t *last, const H5D_chunk_ud_t *ud HDmemcpy(last->scaled, udata->common.scaled, sizeof(hsize_t) * udata->common.layout->ndims); last->addr = udata->chunk_block.offset; H5_CHECKED_ASSIGN(last->nbytes, uint32_t, udata->chunk_block.length, hsize_t); + last->chunk_idx = udata->chunk_idx; last->filter_mask = udata->filter_mask; /* Indicate that the cached info is valid */ @@ -2397,6 +2419,7 @@ H5D__chunk_cinfo_cache_found(const H5D_chunk_cached_t *last, H5D_chunk_ud_t *uda /* Retrieve the information from the cache */ udata->chunk_block.offset = last->addr; udata->chunk_block.length = last->nbytes; + udata->chunk_idx = last->chunk_idx; udata->filter_mask = last->filter_mask; /* Indicate that the data was found */ @@ -2427,6 +2450,7 @@ herr_t H5D__chunk_create(const H5D_t *dset /*in,out*/, hid_t dxpl_id) { H5D_chk_idx_info_t idx_info; /* Chunked index info */ + H5O_storage_chunk_t *sc = &(dset->shared->layout.storage.u.chunk); herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -2435,6 +2459,8 @@ H5D__chunk_create(const H5D_t *dset /*in,out*/, hid_t dxpl_id) HDassert(dset); HDassert(H5D_CHUNKED == dset->shared->layout.type); HDassert(dset->shared->layout.u.chunk.ndims > 0 && dset->shared->layout.u.chunk.ndims <= H5O_LAYOUT_NDIMS); + H5D_CHUNK_STORAGE_INDEX_CHK(sc); + #ifndef NDEBUG { unsigned u; /* Local index variable */ @@ -2527,12 +2553,14 @@ H5D__chunk_lookup(const H5D_t *dset, hid_t dxpl_id, const hsize_t *scaled, H5D_rdcc_ent_t *ent = NULL; /* Cache entry */ hbool_t found = FALSE; /* In cache? */ unsigned u; /* Counter */ + H5O_storage_chunk_t *sc = &(dset->shared->layout.storage.u.chunk); herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE HDassert(dset); HDassert(dset->shared->layout.u.chunk.ndims > 0); + H5D_CHUNK_STORAGE_INDEX_CHK(sc); HDassert(scaled); HDassert(udata); @@ -2563,6 +2591,7 @@ H5D__chunk_lookup(const H5D_t *dset, hid_t dxpl_id, const hsize_t *scaled, if(found) { udata->chunk_block.offset = ent->chunk_block.offset; udata->chunk_block.length = ent->chunk_block.length;; + udata->chunk_idx = ent->chunk_idx; } /* end if */ else { /* Invalidate idx_hint, to signal that the chunk is not in cache */ @@ -2614,12 +2643,14 @@ H5D__chunk_flush_entry(const H5D_t *dset, hid_t dxpl_id, const H5D_dxpl_cache_t { void *buf = NULL; /* Temporary buffer */ hbool_t point_of_no_return = FALSE; + H5O_storage_chunk_t *sc = &(dset->shared->layout.storage.u.chunk); herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC_TAG(dxpl_id, dset->oloc.addr, FAIL) HDassert(dset); HDassert(dset->shared); + H5D_CHUNK_STORAGE_INDEX_CHK(sc); HDassert(dxpl_cache); HDassert(ent); HDassert(!ent->locked); @@ -2638,6 +2669,7 @@ H5D__chunk_flush_entry(const H5D_t *dset, hid_t dxpl_id, const H5D_dxpl_cache_t udata.chunk_block.offset = ent->chunk_block.offset; udata.chunk_block.length = dset->shared->layout.u.chunk.size; udata.filter_mask = 0; + udata.chunk_idx = ent->chunk_idx; /* Should the chunk be filtered before writing it to disk? */ if(dset->shared->dcpl_cache.pline.nused) { @@ -2697,7 +2729,7 @@ H5D__chunk_flush_entry(const H5D_t *dset, hid_t dxpl_id, const H5D_dxpl_cache_t /* Create the chunk it if it doesn't exist, or reallocate the chunk * if its size changed. */ - if(H5D__chunk_file_alloc(&idx_info, &(ent->chunk_block), &udata.chunk_block, &need_insert) < 0) + if(H5D__chunk_file_alloc(&idx_info, &(ent->chunk_block), &udata.chunk_block, &need_insert, ent->scaled) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "unable to insert/resize chunk on chunk level") /* Update the chunk entry's info, in case it was allocated or relocated */ @@ -2804,8 +2836,19 @@ H5D__chunk_cache_evict(const H5D_t *dset, hid_t dxpl_id, const H5D_dxpl_cache_t rdcc->tail = ent->prev; ent->prev = ent->next = NULL; - /* Only clear hash table slot if chunk was not marked as deleted already */ - if(!ent->deleted) + /* Unlink from temporary list */ + if(ent->tmp_prev) { + HDassert(rdcc->tmp_head->tmp_next); + ent->tmp_prev->tmp_next = ent->tmp_next; + if(ent->tmp_next) { + ent->tmp_next->tmp_prev = ent->tmp_prev; + ent->tmp_next = NULL; + } /* end if */ + ent->tmp_prev = NULL; + } /* end if */ + else + /* Only clear hash table slot if the chunk was not on the temporary list + */ rdcc->slot[ent->idx] = NULL; /* Remove from cache */ @@ -2980,6 +3023,7 @@ H5D__chunk_lock(const H5D_io_info_t *io_info, H5D_chunk_ud_t *udata, HDassert(udata); HDassert(dset); HDassert(TRUE == H5P_isa_class(io_info->dxpl_id, H5P_DATASET_XFER)); + HDassert(!rdcc->tmp_head); /* Get the chunk's size */ HDassert(layout->u.chunk.size > 0); @@ -2999,7 +3043,7 @@ H5D__chunk_lock(const H5D_io_info_t *io_info, H5D_chunk_ud_t *udata, unsigned u; /*counters */ /* Make sure this is the right chunk */ - for(u = 0; u < layout->u.chunk.ndims; u++) + for(u = 0; u < layout->u.chunk.ndims - 1; u++) HDassert(io_info->store->chunk.scaled[u] == ent->scaled[u]); } #endif /* NDEBUG */ @@ -3147,6 +3191,7 @@ H5D__chunk_lock(const H5D_io_info_t *io_info, H5D_chunk_ud_t *udata, /* Initialize the new entry */ ent->chunk_block.offset = chunk_addr; ent->chunk_block.length = chunk_alloc; + ent->chunk_idx = udata->chunk_idx; HDmemcpy(ent->scaled, udata->common.scaled, sizeof(hsize_t) * layout->u.chunk.ndims); H5_CHECKED_ASSIGN(ent->rd_count, uint32_t, chunk_size, size_t); H5_CHECKED_ASSIGN(ent->wr_count, uint32_t, chunk_size, size_t); @@ -3167,6 +3212,9 @@ H5D__chunk_lock(const H5D_io_info_t *io_info, H5D_chunk_ud_t *udata, } /* end if */ else rdcc->head = rdcc->tail = ent; + ent->tmp_next = NULL; + ent->tmp_prev = NULL; + } /* end if */ else /* We did not add the chunk to cache */ @@ -3255,7 +3303,9 @@ H5D__chunk_unlock(const H5D_io_info_t *io_info, const H5D_chunk_ud_t *udata, HDmemset(&fake_ent, 0, sizeof(fake_ent)); fake_ent.dirty = TRUE; HDmemcpy(fake_ent.scaled, udata->common.scaled, sizeof(hsize_t) * layout->u.chunk.ndims); + HDmemcpy(fake_ent.scaled, udata->common.scaled, sizeof(hsize_t) * layout->u.chunk.ndims); HDassert(layout->u.chunk.size > 0); + fake_ent.chunk_idx = udata->chunk_idx; fake_ent.chunk_block.offset = udata->chunk_block.offset; fake_ent.chunk_block.length = udata->chunk_block.length; fake_ent.chunk = (uint8_t *)chunk; @@ -3344,12 +3394,14 @@ H5D__chunk_allocated(H5D_t *dset, hid_t dxpl_id, hsize_t *nbytes) H5D_dxpl_cache_t _dxpl_cache; /* Data transfer property cache buffer */ H5D_dxpl_cache_t *dxpl_cache = &_dxpl_cache; /* Data transfer property cache */ hsize_t chunk_bytes = 0; /* Number of bytes allocated for chunks */ + H5O_storage_chunk_t *sc = &(dset->shared->layout.storage.u.chunk); herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE HDassert(dset); HDassert(dset->shared); + H5D_CHUNK_STORAGE_INDEX_CHK(sc); /* Fill the DXPL cache values for later use */ if(H5D__get_dxpl_cache(dxpl_id, &dxpl_cache) < 0) @@ -3426,6 +3478,7 @@ H5D__chunk_allocate(const H5D_t *dset, hid_t dxpl_id, hbool_t full_overwrite, unsigned op_dim; /* Current operating dimension */ H5D_fill_buf_info_t fb_info; /* Dataset's fill buffer info */ hbool_t fb_info_init = FALSE; /* Whether the fill value buffer has been initialized */ + const H5O_storage_chunk_t *sc = &(layout->storage.u.chunk); herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_TAG(dxpl_id, dset->oloc.addr, FAIL) @@ -3433,6 +3486,7 @@ H5D__chunk_allocate(const H5D_t *dset, hid_t dxpl_id, hbool_t full_overwrite, /* Check args */ HDassert(dset && H5D_CHUNKED == layout->type); HDassert(layout->u.chunk.ndims > 0 && layout->u.chunk.ndims <= H5O_LAYOUT_NDIMS); + H5D_CHUNK_STORAGE_INDEX_CHK(sc); HDassert(TRUE == H5P_isa_class(dxpl_id, H5P_DATASET_XFER)); /* Retrieve the dataset dimensions */ @@ -3552,6 +3606,7 @@ H5D__chunk_allocate(const H5D_t *dset, hid_t dxpl_id, hbool_t full_overwrite, * Note that min_unalloc & max_unalloc are in scaled coordinates. * */ + chunk_size = orig_chunk_size; for(op_dim = 0; op_dim < space_ndims; op_dim++) { H5D_chunk_ud_t udata; /* User data for querying chunk info */ int i; /* Local index variable */ @@ -3570,18 +3625,11 @@ H5D__chunk_allocate(const H5D_t *dset, hid_t dxpl_id, hbool_t full_overwrite, while(!carry) { hbool_t need_insert = FALSE; /* Whether the chunk needs to be inserted into the index */ - /* Reset size of chunk in bytes, in case filtered size changes */ - chunk_size = orig_chunk_size; - + /* Look up this chunk */ + if(H5D__chunk_lookup(dset, dxpl_id, scaled, &udata) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "error looking up chunk address") #ifndef NDEBUG /* None of the chunks should be allocated */ - { - /* Look up this chunk */ - if(H5D__chunk_lookup(dset, dxpl_id, scaled, &udata) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "error looking up chunk address") - - HDassert(!H5F_addr_defined(udata.chunk_block.offset)); - } /* end block */ /* Make sure the chunk is really in the dataset and outside the * original dimensions */ @@ -3636,6 +3684,8 @@ H5D__chunk_allocate(const H5D_t *dset, hid_t dxpl_id, hbool_t full_overwrite, /* Keep the number of bytes the chunk turned in to */ chunk_size = nbytes; } /* end if */ + else + chunk_size = layout->u.chunk.size; } /* end if */ /* Initialize the chunk information */ @@ -3647,7 +3697,7 @@ H5D__chunk_allocate(const H5D_t *dset, hid_t dxpl_id, hbool_t full_overwrite, udata.filter_mask = filter_mask; /* Allocate the chunk (with all processes) */ - if(H5D__chunk_file_alloc(&idx_info, NULL, &udata.chunk_block, &need_insert) < 0) + if(H5D__chunk_file_alloc(&idx_info, NULL, &udata.chunk_block, &need_insert, scaled) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "unable to insert/resize chunk on chunk level") HDassert(H5F_addr_defined(udata.chunk_block.offset)); @@ -4139,6 +4189,7 @@ H5D__chunk_prune_by_extent(H5D_t *dset, hid_t dxpl_id, const hsize_t *old_dim) hsize_t hyper_start[H5O_LAYOUT_NDIMS]; /* Starting location of hyperslab */ uint32_t elmts_per_chunk; /* Elements in chunk */ unsigned u; /* Local index variable */ + const H5O_storage_chunk_t *sc = &(layout->storage.u.chunk); herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -4146,6 +4197,7 @@ H5D__chunk_prune_by_extent(H5D_t *dset, hid_t dxpl_id, const hsize_t *old_dim) /* Check args */ HDassert(dset && H5D_CHUNKED == layout->type); HDassert(layout->u.chunk.ndims > 0 && layout->u.chunk.ndims <= H5O_LAYOUT_NDIMS); + H5D_CHUNK_STORAGE_INDEX_CHK(sc); HDassert(dxpl_cache); /* Fill the DXPL cache values for later use */ @@ -4284,6 +4336,8 @@ H5D__chunk_prune_by_extent(H5D_t *dset, hid_t dxpl_id, const hsize_t *old_dim) while(!carry) { int i; /* Local index variable */ + udata.common.scaled = scaled; + if(0 == ndims_outside_fill) { HDassert(fill_dim[op_dim]); HDassert(scaled[op_dim] == min_mod_chunk_sc[op_dim]); @@ -4322,7 +4376,7 @@ H5D__chunk_prune_by_extent(H5D_t *dset, hid_t dxpl_id, const hsize_t *old_dim) /* Remove the chunk from disk, if present */ if(H5F_addr_defined(chk_udata.chunk_block.offset)) { /* Update the offset in idx_udata */ - idx_udata.scaled = scaled; + idx_udata.scaled = udata.common.scaled; /* Remove the chunk from disk */ if((layout->storage.u.chunk.ops->remove)(&idx_info, &idx_udata) < 0) @@ -4444,12 +4498,14 @@ H5D__chunk_addrmap(const H5D_io_info_t *io_info, haddr_t chunk_addr[]) H5D_chk_idx_info_t idx_info; /* Chunked index info */ const H5D_t *dset = io_info->dset; /* Local pointer to dataset info */ H5D_chunk_it_ud2_t udata; /* User data for iteration callback */ + H5O_storage_chunk_t *sc = &(dset->shared->layout.storage.u.chunk); herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE HDassert(dset); HDassert(dset->shared); + H5D_CHUNK_STORAGE_INDEX_CHK(sc); HDassert(chunk_addr); /* Set up user data for B-tree callback */ @@ -4497,6 +4553,7 @@ H5D__chunk_delete(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5O_storage_t *storage) H5O_pline_t pline; /* I/O pipeline message */ hbool_t pline_read = FALSE; /* Whether the I/O pipeline message was read from the file */ htri_t exists; /* Flag if header message of interest exists */ + H5O_storage_chunk_t *sc = &(storage->u.chunk); herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -4505,6 +4562,7 @@ H5D__chunk_delete(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5O_storage_t *storage) HDassert(f); HDassert(oh); HDassert(storage); + H5D_CHUNK_STORAGE_INDEX_CHK(sc); /* Check for I/O pipeline message */ if((exists = H5O_msg_exists_oh(oh, H5O_PLINE_ID)) < 0) @@ -4571,6 +4629,8 @@ H5D__chunk_update_cache(H5D_t *dset, hid_t dxpl_id) { H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); /*raw data chunk cache */ H5D_rdcc_ent_t *ent, *next; /*cache entry */ + H5D_rdcc_ent_t tmp_head; /* Sentinel entry for temporary entry list */ + H5D_rdcc_ent_t *tmp_tail; /* Tail pointer for temporary entry list */ H5D_dxpl_cache_t _dxpl_cache; /* Data transfer property cache buffer */ H5D_dxpl_cache_t *dxpl_cache = &_dxpl_cache; /* Data transfer property cache */ herr_t ret_value = SUCCEED; /* Return value */ @@ -4588,6 +4648,11 @@ H5D__chunk_update_cache(H5D_t *dset, hid_t dxpl_id) if(H5D__get_dxpl_cache(dxpl_id, &dxpl_cache) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't fill dxpl cache") + /* Add temporary entry list to rdcc */ + (void)HDmemset(&tmp_head, 0, sizeof(tmp_head)); + rdcc->tmp_head = &tmp_head; + tmp_tail = &tmp_head; + /* Recompute the index for each cached chunk that is in a dataset */ for(ent = rdcc->head; ent; ent = next) { unsigned old_idx; /* Previous index number */ @@ -4608,37 +4673,58 @@ H5D__chunk_update_cache(H5D_t *dset, hid_t dxpl_id) HDassert(old_ent->locked == FALSE); HDassert(old_ent->deleted == FALSE); - /* Mark the old entry as deleted, but do not evict (yet). - * Make sure we do not make any calls to the index + /* Insert the old entry into the temporary list, but do not + * evict (yet). Make sure we do not make any calls to the index * until all chunks have updated indices! */ - old_ent->deleted = TRUE; + HDassert(!old_ent->tmp_next); + HDassert(!old_ent->tmp_prev); + tmp_tail->tmp_next = old_ent; + old_ent->tmp_prev = tmp_tail; + tmp_tail = old_ent; } /* end if */ /* Insert this chunk into correct location in hash table */ rdcc->slot[ent->idx] = ent; - /* If this chunk was previously marked as deleted and therefore - * not in the hash table, reset the deleted flag. + /* If this chunk was previously on the temporary list and therefore + * not in the hash table, remove it from the temporary list. * Otherwise clear the old hash table slot. */ - if(ent->deleted) - ent->deleted = FALSE; + if(ent->tmp_prev) { + HDassert(tmp_head.tmp_next); + HDassert(tmp_tail != &tmp_head); + ent->tmp_prev->tmp_next = ent->tmp_next; + if(ent->tmp_next) { + ent->tmp_next->tmp_prev = ent->tmp_prev; + ent->tmp_next = NULL; + } /* end if */ + else { + HDassert(tmp_tail == ent); + tmp_tail = ent->tmp_prev; + } /* end else */ + ent->tmp_prev = NULL; + } /* end if */ else rdcc->slot[old_idx] = NULL; } /* end if */ } /* end for */ - /* Evict chunks that are still marked as deleted */ - for(ent = rdcc->head; ent; ent = next) { - /* Get the pointer to the next cache entry */ - next = ent->next; + /* tmp_tail is no longer needed, and will be invalidated by + * H5D_chunk_cache_evict anyways. */ + tmp_tail = NULL; + + /* Evict chunks that are still on the temporary list */ + while(tmp_head.tmp_next) { + ent = tmp_head.tmp_next; /* Remove the old entry from the cache */ - if(ent->deleted) - if(H5D__chunk_cache_evict(dset, dxpl_id, dxpl_cache, ent, TRUE) < 0) - HGOTO_ERROR(H5E_IO, H5E_CANTFLUSH, FAIL, "unable to flush one or more raw data chunks") - } /* end for */ + if(H5D__chunk_cache_evict(dset, dxpl_id, dxpl_cache, ent, TRUE) < 0) + HGOTO_ERROR(H5E_IO, H5E_CANTFLUSH, FAIL, "unable to flush one or more raw data chunks") + } /* end while */ done: + /* Remove temporary list from rdcc */ + rdcc->tmp_head = NULL; + FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_update_cache() */ @@ -4803,8 +4889,11 @@ H5D__chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) udata->buf_size = buf_size; } /* end if */ + udata_dst.chunk_idx = H5VM_array_offset_pre(udata_dst.common.layout->ndims - 1, + udata_dst.common.layout->down_chunks, udata_dst.common.scaled); + /* Allocate chunk in the file */ - if(H5D__chunk_file_alloc(udata->idx_info_dst, NULL, &udata_dst.chunk_block, &need_insert) < 0) + if(H5D__chunk_file_alloc(udata->idx_info_dst, NULL, &udata_dst.chunk_block, &need_insert, udata_dst.common.scaled) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "unable to insert/resize chunk on chunk level") /* Write chunk data to destination file */ @@ -4850,6 +4939,9 @@ H5D__chunk_copy(H5F_t *f_src, H5O_storage_chunk_t *storage_src, H5D_chunk_it_ud3_t udata; /* User data for iteration callback */ H5D_chk_idx_info_t idx_info_dst; /* Dest. chunked index info */ H5D_chk_idx_info_t idx_info_src; /* Source chunked index info */ + int sndims; /* Rank of dataspace */ + hsize_t curr_dims[H5O_LAYOUT_NDIMS]; /* Curr. size of dataset dimensions */ + hsize_t max_dims[H5O_LAYOUT_NDIMS]; /* Curr. size of dataset dimensions */ H5O_pline_t _pline; /* Temporary pipeline info */ const H5O_pline_t *pline; /* Pointer to pipeline info to use */ H5T_path_t *tpath_src_mem = NULL, *tpath_mem_dst = NULL; /* Datatype conversion paths */ @@ -4873,9 +4965,11 @@ H5D__chunk_copy(H5F_t *f_src, H5O_storage_chunk_t *storage_src, /* Check args */ HDassert(f_src); HDassert(storage_src); + H5D_CHUNK_STORAGE_INDEX_CHK(storage_src); HDassert(layout_src); HDassert(f_dst); HDassert(storage_dst); + H5D_CHUNK_STORAGE_INDEX_CHK(storage_dst); HDassert(ds_extent_src); HDassert(dt_src); @@ -4893,17 +4987,15 @@ H5D__chunk_copy(H5F_t *f_src, H5O_storage_chunk_t *storage_src, /* Initialize layout information */ { - hsize_t curr_dims[H5O_LAYOUT_NDIMS]; /* Curr. size of dataset dimensions */ - int sndims; /* Rank of dataspace */ unsigned ndims; /* Rank of dataspace */ /* Get the dim info for dataset */ - if((sndims = H5S_extent_get_dims(ds_extent_src, curr_dims, NULL)) < 0) + if((sndims = H5S_extent_get_dims(ds_extent_src, curr_dims, max_dims)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get dataspace dimensions") H5_CHECKED_ASSIGN(ndims, unsigned, sndims, int); /* Set the source layout chunk information */ - if(H5D__chunk_set_info_real(layout_src, ndims, curr_dims) < 0) + if(H5D__chunk_set_info_real(layout_src, ndims, curr_dims, max_dims) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set layout's chunk info") } /* end block */ @@ -5105,6 +5197,7 @@ H5D__chunk_bh_info(const H5O_loc_t *loc, hid_t dxpl_id, H5O_t *oh, H5O_layout_t H5D_chk_idx_info_t idx_info; /* Chunked index info */ H5S_t *space = NULL; /* Dataset's dataspace */ H5O_pline_t pline; /* I/O pipeline message */ + H5O_storage_chunk_t *sc = &(layout->storage.u.chunk); htri_t exists; /* Flag if header message of interest exists */ hbool_t idx_info_init = FALSE; /* Whether the chunk index info has been initialized */ hbool_t pline_read = FALSE; /* Whether the I/O pipeline message was read */ @@ -5117,6 +5210,7 @@ H5D__chunk_bh_info(const H5O_loc_t *loc, hid_t dxpl_id, H5O_t *oh, H5O_layout_t HDassert(loc->file); HDassert(H5F_addr_defined(loc->addr)); HDassert(layout); + H5D_CHUNK_STORAGE_INDEX_CHK(sc); HDassert(index_size); /* Check for I/O pipeline message */ @@ -5226,12 +5320,14 @@ H5D__chunk_dump_index_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) herr_t H5D__chunk_dump_index(H5D_t *dset, hid_t dxpl_id, FILE *stream) { + H5O_storage_chunk_t *sc = &(dset->shared->layout.storage.u.chunk); herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(dset); + H5D_CHUNK_STORAGE_INDEX_CHK(sc); /* Only display info if stream is defined */ if(stream) { @@ -5449,7 +5545,7 @@ done: */ static herr_t H5D__chunk_file_alloc(const H5D_chk_idx_info_t *idx_info, const H5F_block_t *old_chunk, - H5F_block_t *new_chunk, hbool_t *need_insert) + H5F_block_t *new_chunk, hbool_t *need_insert, hsize_t scaled[]) { hbool_t alloc_chunk = FALSE; /* Whether to allocate chunk */ herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5Dint.c b/src/H5Dint.c index 4ec48bb..ab2f8d0 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -718,6 +718,7 @@ static herr_t H5D__cache_dataspace_info(const H5D_t *dset) { int sndims; /* Signed number of dimensions of dataspace rank */ + unsigned u; /* Local index value */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -730,6 +731,10 @@ H5D__cache_dataspace_info(const H5D_t *dset) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't cache dataspace dimensions") dset->shared->ndims = (unsigned)sndims; + /* Compute the inital 'power2up' values */ + for(u = 0; u < dset->shared->ndims; u++) + dset->shared->curr_power2up[u] = H5VM_power2up(dset->shared->curr_dims[u]); + done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__cache_dataspace_info() */ diff --git a/src/H5Dlayout.c b/src/H5Dlayout.c index 8676d7c..16ff81b 100644 --- a/src/H5Dlayout.c +++ b/src/H5Dlayout.c @@ -150,6 +150,7 @@ H5D__layout_meta_size(const H5F_t *f, const H5O_layout_t *layout, hbool_t includ switch(layout->type) { case H5D_COMPACT: + /* This information only present in older versions of message */ /* Size of raw data */ ret_value += 2; if(include_compact_data) @@ -157,6 +158,7 @@ H5D__layout_meta_size(const H5F_t *f, const H5O_layout_t *layout, hbool_t includ break; case H5D_CONTIGUOUS: + /* This information only present in older versions of message */ ret_value += H5F_SIZEOF_ADDR(f); /* Address of data */ ret_value += H5F_SIZEOF_SIZE(f); /* Length of data */ break; @@ -206,7 +208,7 @@ herr_t H5D__layout_oh_create(H5F_t *file, hid_t dxpl_id, H5O_t *oh, H5D_t *dset, hid_t dapl_id) { - H5O_layout_t *layout; /* Dataset's layout information */ + H5O_layout_t *layout; /* Dataset's layout information */ const H5O_fill_t *fill_prop; /* Pointer to dataset's fill value information */ hbool_t layout_init = FALSE; /* Flag to indicate that chunk information was initialized */ herr_t ret_value = SUCCEED; /* Return value */ @@ -401,7 +403,7 @@ done: /*------------------------------------------------------------------------- * Function: H5D__layout_oh_write * - * Purpose: Write layout/pline/efl information for dataset + * Purpose: Write layout information for dataset * * Return: Success: SUCCEED * Failure: FAIL diff --git a/src/H5Dpkg.h b/src/H5Dpkg.h index e9e87af..06e763c 100644 --- a/src/H5Dpkg.h +++ b/src/H5Dpkg.h @@ -240,7 +240,7 @@ typedef struct H5D_chk_idx_info_t { typedef struct H5D_chunk_rec_t { hsize_t scaled[H5O_LAYOUT_NDIMS]; /* Logical offset to start */ uint32_t nbytes; /* Size of stored data */ - unsigned filter_mask; /* Excluded filters */ + uint32_t filter_mask; /* Excluded filters */ haddr_t chunk_addr; /* Address of chunk in file */ } H5D_chunk_rec_t; @@ -264,6 +264,7 @@ typedef struct H5D_chunk_ud_t { unsigned idx_hint; /*index of chunk in cache, if present */ H5F_block_t chunk_block; /*offset/length of chunk in file */ unsigned filter_mask; /*excluded filters */ + hsize_t chunk_idx; /*chunk index for EA, FA indexing */ } H5D_chunk_ud_t; /* Typedef for "generic" chunk callbacks */ @@ -363,6 +364,7 @@ typedef struct H5D_chunk_cached_t { hsize_t scaled[H5O_LAYOUT_NDIMS]; /*scaled offset of chunk*/ haddr_t addr; /*file address of chunk */ uint32_t nbytes; /*size of stored data */ + hsize_t chunk_idx; /*index of chunk in dataset */ unsigned filter_mask; /*excluded filters */ } H5D_chunk_cached_t; @@ -379,6 +381,7 @@ typedef struct H5D_rdcc_t { double w0; /* Chunk preemption policy */ struct H5D_rdcc_ent_t *head; /* Head of doubly linked list */ struct H5D_rdcc_ent_t *tail; /* Tail of doubly linked list */ + struct H5D_rdcc_ent_t *tmp_head; /* Head of temporary doubly linked list. Chunks on this list are not in the hash table (slot). The head entry is a sentinel (does not refer to an actual chunk). */ size_t nbytes_used; /* Current cached raw data in bytes */ int nused; /* Number of chunk slots in use */ H5D_chunk_cached_t last; /* Cached copy of last chunk information */ @@ -422,6 +425,7 @@ typedef struct H5D_shared_t { /* Cached dataspace info */ unsigned ndims; /* The dataset's dataspace rank */ hsize_t curr_dims[H5S_MAX_RANK]; /* The curr. size of dataset dimensions */ + hsize_t curr_power2up[H5S_MAX_RANK]; /* The curr. dim sizes, rounded up to next power of 2 */ hsize_t max_dims[H5S_MAX_RANK]; /* The max. size of dataset dimensions */ /* Buffered/cached information for types of raw data storage*/ @@ -502,10 +506,13 @@ typedef struct H5D_rdcc_ent_t { uint32_t rd_count; /*bytes remaining to be read */ uint32_t wr_count; /*bytes remaining to be written */ H5F_block_t chunk_block; /*offset/length of chunk in file */ + hsize_t chunk_idx; /*index of chunk in dataset */ uint8_t *chunk; /*the unfiltered chunk data */ unsigned idx; /*index in hash table */ struct H5D_rdcc_ent_t *next;/*next item in doubly-linked list */ struct H5D_rdcc_ent_t *prev;/*previous item in doubly-linked list */ + struct H5D_rdcc_ent_t *tmp_next;/*next item in temporary doubly-linked list */ + struct H5D_rdcc_ent_t *tmp_prev;/*previous item in temporary doubly-linked list */ } H5D_rdcc_ent_t; typedef H5D_rdcc_ent_t *H5D_rdcc_ent_ptr_t; /* For free lists */ diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h index 0d77a83..9235d6c 100644 --- a/src/H5Oprivate.h +++ b/src/H5Oprivate.h @@ -506,10 +506,14 @@ typedef struct H5O_storage_t { typedef struct H5O_layout_chunk_t { unsigned ndims; /* Num dimensions in chunk */ uint32_t dim[H5O_LAYOUT_NDIMS]; /* Size of chunk in elements */ + unsigned enc_bytes_per_dim; /* Encoded # of bytes for storing each chunk dimension */ uint32_t size; /* Size of chunk in bytes */ hsize_t nchunks; /* Number of chunks in dataset */ + hsize_t max_nchunks; /* Max. number of chunks in dataset */ hsize_t chunks[H5O_LAYOUT_NDIMS]; /* # of chunks in each dataset dimension */ + hsize_t max_chunks[H5O_LAYOUT_NDIMS]; /* # of chunks in each dataset's max. dimension */ hsize_t down_chunks[H5O_LAYOUT_NDIMS]; /* "down" size of number of chunks in each dimension */ + hsize_t max_down_chunks[H5O_LAYOUT_NDIMS]; /* "down" size of number of chunks in each max dim */ } H5O_layout_chunk_t; typedef struct H5O_layout_t { diff --git a/src/H5Pdcpl.c b/src/H5Pdcpl.c index 145e1b5..03d987f 100644 --- a/src/H5Pdcpl.c +++ b/src/H5Pdcpl.c @@ -29,14 +29,14 @@ /****************/ #include "H5Pmodule.h" /* This source code file is part of the H5P module */ +#define H5D_FRIEND /* Suppress error about including H5Dpkg */ /***********/ /* Headers */ /***********/ #include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5Dprivate.h" /* Datasets */ +#include "H5Dpkg.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ #include "H5FLprivate.h" /* Free Lists */ #include "H5Iprivate.h" /* IDs */ @@ -45,6 +45,7 @@ #include "H5Ppkg.h" /* Property lists */ #include "H5Sprivate.h" /* Dataspaces */ #include "H5Tprivate.h" /* Datatypes */ +#include "H5VMprivate.h" /* Vectors and arrays */ #include "H5Zprivate.h" /* Data filters */ @@ -55,28 +56,28 @@ /* Define default layout information */ #define H5D_DEF_STORAGE_COMPACT_INIT {(hbool_t)FALSE, (size_t)0, NULL} #define H5D_DEF_STORAGE_CONTIG_INIT {HADDR_UNDEF, (hsize_t)0} -#define H5D_DEF_STORAGE_CHUNK_INIT {H5D_CHUNK_IDX_BTREE, HADDR_UNDEF, NULL, {{HADDR_UNDEF, NULL}}} -#define H5D_DEF_LAYOUT_CHUNK_INIT {(unsigned)0, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, (uint32_t)0, (hsize_t)0, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}} +#define H5D_DEF_STORAGE_CHUNK_INIT {H5D_CHUNK_IDX_BTREE, HADDR_UNDEF, H5D_COPS_BTREE, {{HADDR_UNDEF, NULL}}} +#define H5D_DEF_LAYOUT_CHUNK_INIT {(unsigned)0, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, (unsigned)0, (uint32_t)0, (hsize_t)0, (hsize_t)0, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}} #define H5D_DEF_STORAGE_VIRTUAL_INIT {{HADDR_UNDEF, 0}, 0, NULL, 0, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, H5D_VDS_ERROR, HSIZE_UNDEF, -1, -1, FALSE} #ifdef H5_HAVE_C99_DESIGNATED_INITIALIZER #define H5D_DEF_STORAGE_COMPACT {H5D_COMPACT, { .compact = H5D_DEF_STORAGE_COMPACT_INIT }} #define H5D_DEF_STORAGE_CONTIG {H5D_CONTIGUOUS, { .contig = H5D_DEF_STORAGE_CONTIG_INIT }} #define H5D_DEF_STORAGE_CHUNK {H5D_CHUNKED, { .chunk = H5D_DEF_STORAGE_CHUNK_INIT }} #define H5D_DEF_STORAGE_VIRTUAL {H5D_VIRTUAL, { .virt = H5D_DEF_STORAGE_VIRTUAL_INIT }} -#define H5D_DEF_LAYOUT_COMPACT {H5D_COMPACT, H5O_LAYOUT_VERSION_3, NULL, {H5D_DEF_LAYOUT_CHUNK_INIT}, H5D_DEF_STORAGE_COMPACT} -#define H5D_DEF_LAYOUT_CONTIG {H5D_CONTIGUOUS, H5O_LAYOUT_VERSION_3, NULL, {H5D_DEF_LAYOUT_CHUNK_INIT}, H5D_DEF_STORAGE_CONTIG} -#define H5D_DEF_LAYOUT_CHUNK {H5D_CHUNKED, H5O_LAYOUT_VERSION_3, NULL, {H5D_DEF_LAYOUT_CHUNK_INIT}, H5D_DEF_STORAGE_CHUNK} -#define H5D_DEF_LAYOUT_VIRTUAL {H5D_VIRTUAL, H5O_LAYOUT_VERSION_3, NULL, {H5D_DEF_LAYOUT_CHUNK_INIT}, H5D_DEF_STORAGE_VIRTUAL} +#define H5D_DEF_LAYOUT_COMPACT {H5D_COMPACT, H5O_LAYOUT_VERSION_DEFAULT, H5D_LOPS_COMPACT, {H5D_DEF_LAYOUT_CHUNK_INIT}, H5D_DEF_STORAGE_COMPACT} +#define H5D_DEF_LAYOUT_CONTIG {H5D_CONTIGUOUS, H5O_LAYOUT_VERSION_DEFAULT, H5D_LOPS_CONTIG, {H5D_DEF_LAYOUT_CHUNK_INIT}, H5D_DEF_STORAGE_CONTIG} +#define H5D_DEF_LAYOUT_CHUNK {H5D_CHUNKED, H5O_LAYOUT_VERSION_DEFAULT, H5D_LOPS_CHUNK, {H5D_DEF_LAYOUT_CHUNK_INIT}, H5D_DEF_STORAGE_CHUNK} +#define H5D_DEF_LAYOUT_VIRTUAL {H5D_VIRTUAL, H5O_LAYOUT_VERSION_4, H5D_LOPS_VIRTUAL, {H5D_DEF_LAYOUT_CHUNK_INIT}, H5D_DEF_STORAGE_VIRTUAL} #else /* H5_HAVE_C99_DESIGNATED_INITIALIZER */ /* Note that the compact & chunked layout initialization values are using the * contiguous layout initialization in the union, because the contiguous * layout is first in the union. These values are overridden in the * H5P__init_def_layout() routine. -QAK */ -#define H5D_DEF_LAYOUT_COMPACT {H5D_COMPACT, H5O_LAYOUT_VERSION_3, NULL, {H5D_DEF_LAYOUT_CHUNK_INIT}, {H5D_CONTIGUOUS, H5D_DEF_STORAGE_CONTIG_INIT}} -#define H5D_DEF_LAYOUT_CONTIG {H5D_CONTIGUOUS, H5O_LAYOUT_VERSION_3, NULL, {H5D_DEF_LAYOUT_CHUNK_INIT}, {H5D_CONTIGUOUS, H5D_DEF_STORAGE_CONTIG_INIT}} -#define H5D_DEF_LAYOUT_CHUNK {H5D_CHUNKED, H5O_LAYOUT_VERSION_3, NULL, {H5D_DEF_LAYOUT_CHUNK_INIT}, {H5D_CONTIGUOUS, H5D_DEF_STORAGE_CONTIG_INIT}} -#define H5D_DEF_LAYOUT_VIRTUAL {H5D_VIRTUAL, H5O_LAYOUT_VERSION_3, NULL, {H5D_DEF_LAYOUT_CHUNK_INIT}, {H5D_CONTIGUOUS, H5D_DEF_STORAGE_CONTIG_INIT}} +#define H5D_DEF_LAYOUT_COMPACT {H5D_COMPACT, H5O_LAYOUT_VERSION_DEFAULT, NULL, {H5D_DEF_LAYOUT_CHUNK_INIT}, {H5D_CONTIGUOUS, H5D_DEF_STORAGE_CONTIG_INIT}} +#define H5D_DEF_LAYOUT_CONTIG {H5D_CONTIGUOUS, H5O_LAYOUT_VERSION_DEFAULT, NULL, {H5D_DEF_LAYOUT_CHUNK_INIT}, {H5D_CONTIGUOUS, H5D_DEF_STORAGE_CONTIG_INIT}} +#define H5D_DEF_LAYOUT_CHUNK {H5D_CHUNKED, H5O_LAYOUT_VERSION_DEFAULT, NULL, {H5D_DEF_LAYOUT_CHUNK_INIT}, {H5D_CONTIGUOUS, H5D_DEF_STORAGE_CONTIG_INIT}} +#define H5D_DEF_LAYOUT_VIRTUAL {H5D_VIRTUAL, H5O_LAYOUT_VERSION_4, NULL, {H5D_DEF_LAYOUT_CHUNK_INIT}, {H5D_CONTIGUOUS, H5D_DEF_STORAGE_CONTIG_INIT}} #endif /* H5_HAVE_C99_DESIGNATED_INITIALIZER */ /* ======== Dataset creation properties ======== */ @@ -1997,6 +1998,7 @@ H5Pset_chunk(hid_t plist_id, int ndims, const hsize_t dim[/*ndims*/]) H5P_genplist_t *plist; /* Property list pointer */ H5O_layout_t chunk_layout; /* Layout information for setting chunk info */ uint64_t chunk_nelmts; /* Number of elements in chunk */ + unsigned max_enc_bytes_per_dim; /* Max. number of bytes required to encode this dimension */ unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ @@ -2024,7 +2026,10 @@ H5Pset_chunk(hid_t plist_id, int ndims, const hsize_t dim[/*ndims*/]) HDmemcpy(&chunk_layout, &H5D_def_layout_chunk_g, sizeof(H5D_def_layout_chunk_g)); HDmemset(&chunk_layout.u.chunk.dim, 0, sizeof(chunk_layout.u.chunk.dim)); chunk_nelmts = 1; + max_enc_bytes_per_dim = 0; for(u = 0; u < (unsigned)ndims; u++) { + unsigned enc_bytes_per_dim; /* Number of bytes required to encode this dimension */ + if(dim[u] == 0) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "all chunk dimensions must be positive") if(dim[u] != (dim[u] & 0xffffffff)) @@ -2033,7 +2038,16 @@ H5Pset_chunk(hid_t plist_id, int ndims, const hsize_t dim[/*ndims*/]) if(chunk_nelmts > (uint64_t)0xffffffff) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "number of elements in chunk must be < 4GB") chunk_layout.u.chunk.dim[u] = (uint32_t)dim[u]; /* Store user's chunk dimensions */ + + /* Get encoded size of dim, in bytes */ + enc_bytes_per_dim = (H5VM_log2_gen(dim[u]) + 8) / 8; + + /* Check if this is the largest value so far */ + if(enc_bytes_per_dim > max_enc_bytes_per_dim) + max_enc_bytes_per_dim = enc_bytes_per_dim; } /* end for */ + HDassert(max_enc_bytes_per_dim > 0 && max_enc_bytes_per_dim <= 8); + chunk_layout.u.chunk.enc_bytes_per_dim = max_enc_bytes_per_dim; /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) -- cgit v0.12 From 6d8b831b3125ce66e23aba1f3ec16a03e00b5b82 Mon Sep 17 00:00:00 2001 From: HDF Tester Date: Sun, 27 Dec 2015 23:20:23 -0500 Subject: [svn-r28730] Snapshot version 1.9 release 233 --- README.txt | 2 +- c++/src/cpp_doc_config | 2 +- config/lt_vers.am | 2 +- configure.ac | 2 +- release_docs/RELEASE.txt | 2 +- src/H5public.h | 4 ++-- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.txt b/README.txt index 291e8a6..6dfd021 100644 --- a/README.txt +++ b/README.txt @@ -1,4 +1,4 @@ -HDF5 version 1.9.233 released on 2015-10-06 +HDF5 version 1.9.234 currently under development Please refer to the release_docs/INSTALL file for installation instructions. ------------------------------------------------------------------------------ diff --git a/c++/src/cpp_doc_config b/c++/src/cpp_doc_config index 7060fd2..623f9c7 100644 --- a/c++/src/cpp_doc_config +++ b/c++/src/cpp_doc_config @@ -38,7 +38,7 @@ PROJECT_NAME = "HDF5 C++ API" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = "1.9.233 currently under development" +PROJECT_NUMBER = "1.9.234 currently under development" # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/config/lt_vers.am b/config/lt_vers.am index 401bcb9..a3b7634 100644 --- a/config/lt_vers.am +++ b/config/lt_vers.am @@ -19,7 +19,7 @@ # After making changes, run bin/reconfigure to update other configure related # files like Makefile.in. LT_VERS_INTERFACE = 6 -LT_VERS_REVISION = 223 +LT_VERS_REVISION = 224 LT_VERS_AGE = 0 ## If the API changes *at all*, increment LT_VERS_INTERFACE and diff --git a/configure.ac b/configure.ac index 0c3514c..0e853a8 100644 --- a/configure.ac +++ b/configure.ac @@ -26,7 +26,7 @@ AC_PREREQ([2.69]) ## NOTE: Do not forget to change the version number here when we do a ## release!!! ## -AC_INIT([HDF5], [1.9.232], [help@hdfgroup.org]) +AC_INIT([HDF5], [1.9.234], [help@hdfgroup.org]) AC_CONFIG_SRCDIR([src/H5.c]) AC_CONFIG_HEADERS([src/H5config.h]) diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index 1cfe382..2c9c79f 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -1,4 +1,4 @@ -HDF5 version 1.9.233 released on 2015-10-06 +HDF5 version 1.9.234 currently under development ================================================================================ diff --git a/src/H5public.h b/src/H5public.h index 5b95fb7..554ad26 100644 --- a/src/H5public.h +++ b/src/H5public.h @@ -94,10 +94,10 @@ extern "C" { /* Version numbers */ #define H5_VERS_MAJOR 1 /* For major interface/format changes */ #define H5_VERS_MINOR 9 /* For minor interface/format changes */ -#define H5_VERS_RELEASE 233 /* For tweaks, bug-fixes, or development */ +#define H5_VERS_RELEASE 234 /* For tweaks, bug-fixes, or development */ #define H5_VERS_SUBRELEASE "" /* For pre-releases like snap0 */ /* Empty string for real releases. */ -#define H5_VERS_INFO "HDF5 library version: 1.9.233" /* Full version string */ +#define H5_VERS_INFO "HDF5 library version: 1.9.234" /* Full version string */ #define H5check() H5check_version(H5_VERS_MAJOR,H5_VERS_MINOR, \ H5_VERS_RELEASE) -- cgit v0.12 From b5504be6cc6f61b5a8ce78f243b81b6afe9d13c9 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Tue, 29 Dec 2015 12:06:36 -0500 Subject: [svn-r28742] Description: Add 'update' operation to v2 B-trees, which will insert a new record, or modify an existing one, depending on if the record exists or not. Tested on: MacOSX/64 10.11.2 (amazon) w/serial & parallel (h5committest forthcoming) --- src/H5Abtree2.c | 8 +- src/H5B2.c | 74 +- src/H5B2dbg.c | 44 +- src/H5B2int.c | 401 +++++++ src/H5B2pkg.h | 27 +- src/H5B2private.h | 5 +- src/H5B2test.c | 168 ++- src/H5Gbtree2.c | 8 +- src/H5HFbtree2.c | 57 +- src/H5SMbtree2.c | 44 +- test/btree2.c | 2902 ++++++++++++++++++++++++++++++++++++++++++++------ tools/misc/h5debug.c | 4 + 12 files changed, 3227 insertions(+), 515 deletions(-) diff --git a/src/H5Abtree2.c b/src/H5Abtree2.c index 972fb0b..716ad4a 100644 --- a/src/H5Abtree2.c +++ b/src/H5Abtree2.c @@ -116,9 +116,7 @@ const H5B2_class_t H5A_BT2_NAME[1]={{ /* B-tree class information */ H5A__dense_btree2_name_compare, /* Record comparison callback */ H5A__dense_btree2_name_encode, /* Record encoding callback */ H5A__dense_btree2_name_decode, /* Record decoding callback */ - H5A__dense_btree2_name_debug, /* Record debugging callback */ - NULL, /* Create debugging context */ - NULL /* Destroy debugging context */ + H5A__dense_btree2_name_debug /* Record debugging callback */ }}; /* v2 B-tree class for indexing 'creation order' field of attributes */ @@ -132,9 +130,7 @@ const H5B2_class_t H5A_BT2_CORDER[1]={{ /* B-tree class information */ H5A__dense_btree2_corder_compare, /* Record comparison callback */ H5A__dense_btree2_corder_encode, /* Record encoding callback */ H5A__dense_btree2_corder_decode, /* Record decoding callback */ - H5A__dense_btree2_corder_debug, /* Record debugging callback */ - NULL, /* Create debugging context */ - NULL /* Destroy debugging context */ + H5A__dense_btree2_corder_debug /* Record debugging callback */ }}; diff --git a/src/H5B2.c b/src/H5B2.c index a171917..c105a93 100644 --- a/src/H5B2.c +++ b/src/H5B2.c @@ -86,6 +86,7 @@ extern const H5B2_class_t H5G_BT2_CORDER[1]; extern const H5B2_class_t H5SM_INDEX[1]; extern const H5B2_class_t H5A_BT2_NAME[1]; extern const H5B2_class_t H5A_BT2_CORDER[1]; +extern const H5B2_class_t H5B2_TEST2[1]; const H5B2_class_t *const H5B2_client_class_g[] = { H5B2_TEST, /* 0 - H5B2_TEST_ID */ @@ -98,6 +99,7 @@ const H5B2_class_t *const H5B2_client_class_g[] = { H5SM_INDEX, /* 7 - H5B2_SOHM_INDEX_ID */ H5A_BT2_NAME, /* 8 - H5B2_ATTR_DENSE_NAME_ID */ H5A_BT2_CORDER, /* 9 - H5B2_ATTR_DENSE_CORDER_ID */ + H5B2_TEST2, /* 10 - H5B2_TEST_ID */ }; @@ -282,36 +284,78 @@ H5B2_insert(H5B2_t *bt2, hid_t dxpl_id, void *udata) /* Get the v2 B-tree header */ hdr = bt2->hdr; + /* Insert the record */ + if(H5B2__insert_hdr(hdr, dxpl_id, udata) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, FAIL, "unable to insert record into B-tree") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5B2_insert() */ + + +/*------------------------------------------------------------------------- + * Function: H5B2_update + * + * Purpose: Insert or modify a record to the B-tree. + * If the record exists already, it is modified as if H5B2_modify + * was called). If it doesn't exist, it is inserted as if + * H5B2_insert was called. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * Dec 23 2015 + * + *------------------------------------------------------------------------- + */ +herr_t +H5B2_update(H5B2_t *bt2, hid_t dxpl_id, void *udata, H5B2_modify_t op, void *op_data) +{ + H5B2_hdr_t *hdr; /* Pointer to the B-tree header */ + H5B2_update_status_t status = H5B2_UPDATE_UNKNOWN; /* Whether the record was inserted/modified */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Check arguments. */ + HDassert(bt2); + HDassert(udata); + + /* Set the shared v2 B-tree header's file context for this operation */ + bt2->hdr->f = bt2->f; + + /* Get the v2 B-tree header */ + hdr = bt2->hdr; + /* Check if the root node is allocated yet */ if(!H5F_addr_defined(hdr->root.addr)) { /* Create root node as leaf node in B-tree */ if(H5B2__create_leaf(hdr, dxpl_id, &(hdr->root)) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to create root node") } /* end if */ - /* Check if we need to split the root node (equiv. to a 1->2 node split) */ - else if(hdr->root.node_nrec == hdr->node_info[hdr->depth].split_nrec) { - /* Split root node */ - if(H5B2__split_root(hdr, dxpl_id) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, FAIL, "unable to split root node") - } /* end if */ /* Attempt to insert record into B-tree */ if(hdr->depth > 0) { - if(H5B2__insert_internal(hdr, dxpl_id, hdr->depth, NULL, &hdr->root, H5B2_POS_ROOT, udata) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, FAIL, "unable to insert record into B-tree internal node") + 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") } /* end if */ else { - if(H5B2__insert_leaf(hdr, dxpl_id, &hdr->root, H5B2_POS_ROOT, udata) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, FAIL, "unable to insert record into B-tree leaf node") + 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") } /* end else */ - /* Mark B-tree header as dirty */ - if(H5B2__hdr_dirty(hdr) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTMARKDIRTY, FAIL, "unable to mark B-tree header dirty") + /* Sanity check */ + HDassert(H5B2_UPDATE_UNKNOWN != status); + + /* Use insert algorithm if nodes to leaf full */ + if(H5B2_UPDATE_INSERT_CHILD_FULL == status) + if(H5B2__insert_hdr(hdr, dxpl_id, udata) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, FAIL, "unable to insert record into B-tree") done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5B2_insert() */ +} /* H5B2_update() */ /*------------------------------------------------------------------------- @@ -1202,7 +1246,7 @@ H5B2_modify(H5B2_t *bt2, hid_t dxpl_id, void *udata, H5B2_modify_t op, /* Unlock current node */ if(H5AC_unprotect(hdr->f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, leaf_flags) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") - } + } /* end block */ done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5B2dbg.c b/src/H5B2dbg.c index 73084d2..ddff9e9 100644 --- a/src/H5B2dbg.c +++ b/src/H5B2dbg.c @@ -92,7 +92,6 @@ H5B2__hdr_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, const H5B2_class_t *type, haddr_t obj_addr) { H5B2_hdr_t *hdr = NULL; /* B-tree header info */ - void *dbg_ctx = NULL; /* v2 B-tree debugging context */ unsigned u; /* Local index variable */ char temp_str[128]; /* Temporary string, for formatting */ herr_t ret_value = SUCCEED; /* Return value */ @@ -109,17 +108,9 @@ H5B2__hdr_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, HDassert(indent >= 0); HDassert(fwidth >= 0); HDassert(type); - HDassert((type->crt_dbg_ctx && type->dst_dbg_ctx) || - (NULL == type->crt_dbg_ctx && NULL == type->dst_dbg_ctx)); - - /* Check for debugging context callback available */ - if(type->crt_dbg_ctx) - /* Create debugging context */ - if(NULL == (dbg_ctx = (type->crt_dbg_ctx)(f, dxpl_id, obj_addr))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "unable to create v2 B-tree debugging context") /* Load the B-tree header */ - if(NULL == (hdr = H5B2__hdr_protect(f, dxpl_id, addr, dbg_ctx, H5AC__READ_ONLY_FLAG))) + if(NULL == (hdr = H5B2__hdr_protect(f, dxpl_id, addr, f, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree header") /* Set file pointer for this B-tree operation */ @@ -171,8 +162,6 @@ H5B2__hdr_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, } /* end for */ done: - if(dbg_ctx && (type->dst_dbg_ctx)(dbg_ctx) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTRELEASE, FAIL, "unable to release v2 B-tree debugging context") if(hdr && H5B2__hdr_unprotect(hdr, dxpl_id, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release v2 B-tree header") @@ -199,7 +188,6 @@ H5B2__int_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, { H5B2_hdr_t *hdr = NULL; /* B-tree header */ H5B2_internal_t *internal = NULL; /* B-tree internal node */ - void *dbg_ctx = NULL; /* v2 B-tree debugging context */ unsigned u; /* Local index variable */ char temp_str[128]; /* Temporary string, for formatting */ herr_t ret_value=SUCCEED; /* Return value */ @@ -215,21 +203,12 @@ H5B2__int_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, HDassert(indent >= 0); HDassert(fwidth >= 0); HDassert(type); - HDassert((type->crt_dbg_ctx && type->dst_dbg_ctx) || - (NULL == type->crt_dbg_ctx && NULL == type->dst_dbg_ctx)); HDassert(H5F_addr_defined(hdr_addr)); HDassert(H5F_addr_defined(obj_addr)); HDassert(nrec > 0); - /* Check for debugging context callback available */ - if(type->crt_dbg_ctx) { - /* Create debugging context */ - if(NULL == (dbg_ctx = (type->crt_dbg_ctx)(f, dxpl_id, obj_addr))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "unable to create v2 B-tree debugging context") - } /* end if */ - /* Load the B-tree header */ - if(NULL == (hdr = H5B2__hdr_protect(f, dxpl_id, hdr_addr, dbg_ctx, H5AC__READ_ONLY_FLAG))) + if(NULL == (hdr = H5B2__hdr_protect(f, dxpl_id, hdr_addr, f, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load v2 B-tree header") /* Set file pointer for this B-tree operation */ @@ -279,7 +258,7 @@ H5B2__int_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, HDfprintf(stream, "%*s%-*s\n", indent + 3, "", MAX(0, fwidth - 3), temp_str); HDassert(H5B2_INT_NREC(internal, hdr, u)); - (void)(type->debug)(stream, indent + 6, MAX (0, fwidth-6), H5B2_INT_NREC(internal, hdr, u), dbg_ctx); + (void)(type->debug)(stream, indent + 6, MAX (0, fwidth-6), H5B2_INT_NREC(internal, hdr, u), hdr->cb_ctx); } /* end for */ /* Print final node pointer */ @@ -291,8 +270,6 @@ H5B2__int_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, internal->node_ptrs[u].addr); done: - if(dbg_ctx && (type->dst_dbg_ctx)(dbg_ctx) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTRELEASE, FAIL, "unable to release v2 B-tree debugging context") if(hdr && H5B2__hdr_unprotect(hdr, dxpl_id, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release v2 B-tree header") if(internal && H5AC_unprotect(f, dxpl_id, H5AC_BT2_INT, addr, internal, H5AC__NO_FLAGS_SET) < 0) @@ -321,7 +298,6 @@ H5B2__leaf_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent { H5B2_hdr_t *hdr = NULL; /* B-tree header */ H5B2_leaf_t *leaf = NULL; /* B-tree leaf node */ - void *dbg_ctx = NULL; /* v2 B-tree debugging context */ unsigned u; /* Local index variable */ char temp_str[128]; /* Temporary string, for formatting */ herr_t ret_value = SUCCEED; /* Return value */ @@ -337,20 +313,12 @@ H5B2__leaf_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent HDassert(indent >= 0); HDassert(fwidth >= 0); HDassert(type); - HDassert((type->crt_dbg_ctx && type->dst_dbg_ctx) || - (NULL == type->crt_dbg_ctx && NULL == type->dst_dbg_ctx)); HDassert(H5F_addr_defined(hdr_addr)); HDassert(H5F_addr_defined(obj_addr)); HDassert(nrec > 0); - /* Check for debugging context callback available */ - if(type->crt_dbg_ctx) - /* Create debugging context */ - if(NULL == (dbg_ctx = (type->crt_dbg_ctx)(f, dxpl_id, obj_addr))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "unable to create v2 B-tree debugging context") - /* Load the B-tree header */ - if(NULL == (hdr = H5B2__hdr_protect(f, dxpl_id, hdr_addr, dbg_ctx, H5AC__READ_ONLY_FLAG))) + if(NULL == (hdr = H5B2__hdr_protect(f, dxpl_id, hdr_addr, f, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect v2 B-tree header") /* Set file pointer for this B-tree operation */ @@ -391,12 +359,10 @@ H5B2__leaf_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent HDfprintf(stream, "%*s%-*s\n", indent + 3, "", MAX(0, fwidth - 3), temp_str); HDassert(H5B2_LEAF_NREC(leaf, hdr, u)); - (void)(type->debug)(stream, indent + 6, MAX (0, fwidth-6), H5B2_LEAF_NREC(leaf, hdr, u), dbg_ctx); + (void)(type->debug)(stream, indent + 6, MAX (0, fwidth-6), H5B2_LEAF_NREC(leaf, hdr, u), hdr->cb_ctx); } /* end for */ done: - if(dbg_ctx && (type->dst_dbg_ctx)(dbg_ctx) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTRELEASE, FAIL, "unable to release v2 B-tree debugging context") if(hdr && H5B2__hdr_unprotect(hdr, dxpl_id, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree header") if(leaf && H5AC_unprotect(f, dxpl_id, H5AC_BT2_LEAF, addr, leaf, H5AC__NO_FLAGS_SET) < 0) diff --git a/src/H5B2int.c b/src/H5B2int.c index b8c9634..363d903 100644 --- a/src/H5B2int.c +++ b/src/H5B2int.c @@ -1513,6 +1513,62 @@ done: /*------------------------------------------------------------------------- + * Function: H5B2__insert_hdr + * + * Purpose: Adds a new record to the B-tree. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * Dec 23 2015 + * + *------------------------------------------------------------------------- + */ +herr_t +H5B2__insert_hdr(H5B2_hdr_t *hdr, hid_t dxpl_id, void *udata) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Check arguments. */ + HDassert(hdr); + HDassert(udata); + + /* Check if the root node is allocated yet */ + if(!H5F_addr_defined(hdr->root.addr)) { + /* Create root node as leaf node in B-tree */ + if(H5B2__create_leaf(hdr, dxpl_id, &(hdr->root)) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to create root node") + } /* end if */ + /* Check if we need to split the root node (equiv. to a 1->2 node split) */ + else if(hdr->root.node_nrec == hdr->node_info[hdr->depth].split_nrec) { + /* Split root node */ + if(H5B2__split_root(hdr, dxpl_id) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, FAIL, "unable to split root node") + } /* end if */ + + /* Attempt to insert record into B-tree */ + if(hdr->depth > 0) { + if(H5B2__insert_internal(hdr, dxpl_id, hdr->depth, NULL, &hdr->root, H5B2_POS_ROOT, udata) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, FAIL, "unable to insert record into B-tree internal node") + } /* end if */ + else { + if(H5B2__insert_leaf(hdr, dxpl_id, &hdr->root, H5B2_POS_ROOT, udata) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, FAIL, "unable to insert record into B-tree leaf node") + } /* end else */ + + /* Mark B-tree header as dirty */ + if(H5B2__hdr_dirty(hdr) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTMARKDIRTY, FAIL, "unable to mark B-tree header dirty") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5B2__insert_hdr() */ + + +/*------------------------------------------------------------------------- * Function: H5B2__insert_leaf * * Purpose: Adds a new record to a B-tree leaf node. @@ -1644,6 +1700,9 @@ H5B2__insert_internal(H5B2_hdr_t *hdr, hid_t dxpl_id, uint16_t depth, if(NULL == (internal = H5B2__protect_internal(hdr, dxpl_id, curr_node_ptr->addr, curr_node_ptr->node_nrec, depth, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree internal node") + /* Sanity check number of records */ + HDassert(internal->nrec == curr_node_ptr->node_nrec); + /* Split or redistribute child node pointers, if necessary */ { int cmp; /* Comparison value of records */ @@ -1755,6 +1814,348 @@ done: /*------------------------------------------------------------------------- + * Function: H5B2__update_leaf + * + * Purpose: Insert or modify a record in a B-tree leaf node. + * If the record exists already, it is modified as if H5B2_modify + * was called). If it doesn't exist, it is inserted as if + * H5B2_insert was called. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * Dec 23 2015 + * + *------------------------------------------------------------------------- + */ +herr_t +H5B2__update_leaf(H5B2_hdr_t *hdr, hid_t dxpl_id, H5B2_node_ptr_t *curr_node_ptr, + H5B2_update_status_t *status, H5B2_nodepos_t curr_pos, void *udata, + H5B2_modify_t op, void *op_data) +{ + H5B2_leaf_t *leaf; /* Pointer to leaf node */ + unsigned leaf_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting the leaf node */ + int cmp = -1; /* Comparison value of records */ + unsigned idx; /* Location of record which matches key */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Check arguments. */ + HDassert(hdr); + HDassert(curr_node_ptr); + HDassert(H5F_addr_defined(curr_node_ptr->addr)); + + /* Lock current B-tree node */ + if(NULL == (leaf = H5B2__protect_leaf(hdr, dxpl_id, curr_node_ptr->addr, curr_node_ptr->node_nrec, H5AC__NO_FLAGS_SET))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree leaf node") + + /* Sanity check number of records */ + HDassert(curr_node_ptr->all_nrec == curr_node_ptr->node_nrec); + HDassert(leaf->nrec == curr_node_ptr->node_nrec); + + /* Check for inserting into empty leaf */ + if(leaf->nrec == 0) + idx = 0; + else { + /* Find correct location to insert this record */ + cmp = H5B2__locate_record(hdr->cls, leaf->nrec, hdr->nat_off, leaf->leaf_native, udata, &idx); + + /* Check for inserting a record */ + if(0 != cmp) { + /* Check if the leaf node is full */ + if(curr_node_ptr->node_nrec == hdr->node_info[0].split_nrec) { + /* Indicate that the leaf is full, but we need to insert */ + *status = H5B2_UPDATE_INSERT_CHILD_FULL; + + /* Let calling routine handle insertion */ + HGOTO_DONE(SUCCEED) + } /* end if */ + + /* Adjust index to leave room for record to insert */ + if(cmp > 0) + idx++; + + /* Make room for new record */ + if(idx < leaf->nrec) + HDmemmove(H5B2_LEAF_NREC(leaf, hdr, idx + 1), H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size * (leaf->nrec - idx)); + } /* end if */ + } /* end else */ + + /* Check for modifying existing record */ + if(0 == cmp) { + hbool_t changed = FALSE; /* Whether the 'modify' callback changed the record */ + + /* Make callback for current record */ + if((op)(H5B2_LEAF_NREC(leaf, hdr, idx), op_data, &changed) < 0) { + /* Make certain that the callback didn't modify the value if it failed */ + HDassert(changed == FALSE); + + HGOTO_ERROR(H5E_BTREE, H5E_CANTMODIFY, FAIL, "'modify' callback failed for B-tree update operation") + } /* end if */ + + /* Mark the node as dirty if it changed */ + leaf_flags |= (changed ? H5AC__DIRTIED_FLAG : 0); + + /* Indicate that the record was modified */ + *status = H5B2_UPDATE_MODIFY_DONE; + } /* end if */ + else { + /* Must have a leaf node with enough space to insert a record now */ + HDassert(curr_node_ptr->node_nrec < hdr->node_info[0].max_nrec); + + /* Make callback to store record in native form */ + 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 */ + leaf_flags |= H5AC__DIRTIED_FLAG; + + /* Indicate that the record was inserted */ + *status = H5B2_UPDATE_INSERT_DONE; + + /* Update record count for node pointer to current node */ + curr_node_ptr->all_nrec++; + curr_node_ptr->node_nrec++; + + /* Update record count for current node */ + leaf->nrec++; + } /* end else */ + + /* Check for new record being the min or max for the tree */ + /* (Don't use 'else' for the idx check, to allow for root leaf node) */ + if(H5B2_POS_MIDDLE != curr_pos) { + if(idx == 0) { + if(H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) { + if(hdr->min_native_rec == NULL) + if(NULL == (hdr->min_native_rec = (uint8_t *)HDmalloc(hdr->cls->nrec_size))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for v2 B-tree min record info") + HDmemcpy(hdr->min_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size); + } /* end if */ + } /* end if */ + if(idx == (unsigned)(leaf->nrec - 1)) { + if(H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) { + if(hdr->max_native_rec == NULL) + if(NULL == (hdr->max_native_rec = (uint8_t *)HDmalloc(hdr->cls->nrec_size))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for v2 B-tree max record info") + HDmemcpy(hdr->max_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size); + } /* end if */ + } /* end if */ + } /* end if */ + +done: + /* Release the B-tree leaf node */ + if(leaf && H5AC_unprotect(hdr->f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr->addr, leaf, leaf_flags) < 0) + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release leaf B-tree node") + + FUNC_LEAVE_NOAPI(ret_value) +} /* H5B2__update_leaf() */ + + +/*------------------------------------------------------------------------- + * Function: H5B2__update_internal + * + * Purpose: Insert or modify a record in a B-tree leaf node. + * If the record exists already, it is modified as if H5B2_modify + * was called). If it doesn't exist, it is inserted as if + * H5B2_insert was called. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * Dec 24 2015 + * + *------------------------------------------------------------------------- + */ +herr_t +H5B2__update_internal(H5B2_hdr_t *hdr, hid_t dxpl_id, uint16_t depth, + unsigned *parent_cache_info_flags_ptr, H5B2_node_ptr_t *curr_node_ptr, + H5B2_update_status_t *status, H5B2_nodepos_t curr_pos, void *udata, + H5B2_modify_t op, void *op_data) +{ + H5B2_internal_t *internal = NULL; /* Pointer to internal node */ + unsigned internal_flags = H5AC__NO_FLAGS_SET; + int cmp; /* Comparison value of records */ + unsigned idx; /* Location of record which matches key */ + H5B2_nodepos_t next_pos = H5B2_POS_MIDDLE; /* Position of node */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Check arguments. */ + HDassert(hdr); + HDassert(depth > 0); + HDassert(curr_node_ptr); + HDassert(H5F_addr_defined(curr_node_ptr->addr)); + + /* Lock current B-tree node */ + if(NULL == (internal = H5B2__protect_internal(hdr, dxpl_id, curr_node_ptr->addr, curr_node_ptr->node_nrec, depth, H5AC__NO_FLAGS_SET))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree internal node") + + /* Sanity check number of records */ + HDassert(internal->nrec == curr_node_ptr->node_nrec); + + /* Locate node pointer for child */ + cmp = H5B2__locate_record(hdr->cls, internal->nrec, hdr->nat_off, internal->int_native, udata, &idx); + + /* Check for modifying existing record */ + if(0 == cmp) { + hbool_t changed = FALSE; /* Whether the 'modify' callback changed the record */ + + /* Make callback for current record */ + if((op)(H5B2_INT_NREC(internal, hdr, idx), op_data, &changed) < 0) { + /* Make certain that the callback didn't modify the value if it failed */ + HDassert(changed == FALSE); + + HGOTO_ERROR(H5E_BTREE, H5E_CANTMODIFY, FAIL, "'modify' callback failed for B-tree update operation") + } /* end if */ + + /* Mark the node as dirty if it changed */ + internal_flags |= (changed ? H5AC__DIRTIED_FLAG : 0); + + /* Indicate that the record was modified */ + *status = H5B2_UPDATE_MODIFY_DONE; + } /* end if */ + else { + /* Adjust index to leave room for node to insert */ + if(cmp > 0) + idx++; + + /* Check if this node is left/right-most */ + if(H5B2_POS_MIDDLE != curr_pos) { + if(idx == 0) { + if(H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) + next_pos = H5B2_POS_LEFT; + } /* end if */ + else if(idx == internal->nrec) { + if(H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) + next_pos = H5B2_POS_RIGHT; + } /* end else */ + } /* end if */ + + /* Attempt to update record in child */ + if(depth > 1) { + if(H5B2__update_internal(hdr, dxpl_id, (uint16_t)(depth - 1), &internal_flags, &internal->node_ptrs[idx], status, next_pos, udata, op, op_data) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTUPDATE, FAIL, "unable to update record in internal B-tree node") + } /* end if */ + else { + if(H5B2__update_leaf(hdr, dxpl_id, &internal->node_ptrs[idx], status, next_pos, udata, op, op_data) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTUPDATE, FAIL, "unable to update record in leaf B-tree node") + } /* end else */ + + /* Take actions based on child's status report */ + switch(*status) { + case H5B2_UPDATE_MODIFY_DONE: + /* No action */ + break; + + case H5B2_UPDATE_INSERT_DONE: + /* Mark node as dirty */ + internal_flags |= H5AC__DIRTIED_FLAG; + + /* Update total record count for node pointer to current node */ + curr_node_ptr->all_nrec++; + break; + + case H5B2_UPDATE_INSERT_CHILD_FULL: + /* Split/redistribute this node */ + if(internal->nrec == hdr->node_info[depth].split_nrec) { + hbool_t could_split = FALSE; /* Whether the child node could split */ + +#ifdef QAK +HDfprintf(stderr, "%s: idx = %u, internal->nrec = %u\n", FUNC, idx, internal->nrec); +HDfprintf(stderr, "%s: hdr->node_info[%u].split_nrec = %u\n", FUNC, (unsigned)depth, (unsigned)hdr->node_info[depth].split_nrec); +HDfprintf(stderr, "%s: hdr->node_info[%u].split_nrec = %u\n", FUNC, (unsigned)(depth - 1), (unsigned)hdr->node_info[depth - 1].split_nrec); +#endif /* QAK */ + if(idx == 0) { /* Left-most child */ +#ifdef QAK +HDfprintf(stderr, "%s: Left-most child\n", FUNC); +HDfprintf(stderr, "%s: internal->node_ptrs[%u].node_nrec = %u\n", FUNC, (unsigned)idx, (unsigned)internal->node_ptrs[idx].node_nrec); +HDfprintf(stderr, "%s: internal->node_ptrs[%u].node_nrec = %u\n", FUNC, (unsigned)(idx + 1), (unsigned)internal->node_ptrs[idx + 1].node_nrec); +#endif /* QAK */ + /* Check for left-most child and its neighbor being close to full */ + if((internal->node_ptrs[idx].node_nrec + internal->node_ptrs[idx + 1].node_nrec) + >= ((hdr->node_info[depth - 1].split_nrec * 2) - 1)) + could_split = TRUE; + } /* end if */ + else if(idx == internal->nrec) { /* Right-most child */ +#ifdef QAK +HDfprintf(stderr, "%s: Right-most child\n", FUNC); +HDfprintf(stderr, "%s: internal->node_ptrs[%u].node_nrec = %u\n", FUNC, (unsigned)(idx - 1), (unsigned)internal->node_ptrs[idx - 1].node_nrec); +HDfprintf(stderr, "%s: internal->node_ptrs[%u].node_nrec = %u\n", FUNC, (unsigned)idx, (unsigned)internal->node_ptrs[idx].node_nrec); +#endif /* QAK */ + /* Check for right-most child and its neighbor being close to full */ + if((internal->node_ptrs[idx - 1].node_nrec + internal->node_ptrs[idx].node_nrec) + >= ((hdr->node_info[depth - 1].split_nrec * 2) - 1)) + could_split = TRUE; + } /* end else-if */ + else { /* Middle child */ +#ifdef QAK +HDfprintf(stderr, "%s: Middle child\n", FUNC); +HDfprintf(stderr, "%s: internal->node_ptrs[%u].node_nrec = %u\n", FUNC, (unsigned)(idx - 1), (unsigned)internal->node_ptrs[idx - 1].node_nrec); +HDfprintf(stderr, "%s: internal->node_ptrs[%u].node_nrec = %u\n", FUNC, (unsigned)idx, (unsigned)internal->node_ptrs[idx].node_nrec); +HDfprintf(stderr, "%s: internal->node_ptrs[%u].node_nrec = %u\n", FUNC, (unsigned)(idx + 1), (unsigned)internal->node_ptrs[idx + 1].node_nrec); +#endif /* QAK */ + /* Check for middle child and its left neighbor being close to full */ + if((internal->node_ptrs[idx - 1].node_nrec + internal->node_ptrs[idx].node_nrec) + >= ((hdr->node_info[depth - 1].split_nrec * 2) - 1)) + could_split = TRUE; + /* Check for middle child and its right neighbor being close to full */ + else if((internal->node_ptrs[idx].node_nrec + internal->node_ptrs[idx + 1].node_nrec) + >= ((hdr->node_info[depth - 1].split_nrec * 2) - 1)) + could_split = TRUE; + } /* end if */ + + /* If this node is full and the child node insertion could + * cause a split, punt back up to caller, leaving the + * "insert child full" status. + */ + if(could_split) { + /* Release the internal B-tree node */ + if(H5AC_unprotect(hdr->f, dxpl_id, H5AC_BT2_INT, curr_node_ptr->addr, internal, internal_flags) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release internal B-tree node") + internal = NULL; + +#ifdef QAK +HDfprintf(stderr, "%s: Punting back to caller\n", FUNC); +#endif /* QAK */ + /* Punt back to caller */ + HGOTO_DONE(SUCCEED); + } /* end if */ + } /* end if */ + + /* Release the internal B-tree node */ + if(H5AC_unprotect(hdr->f, dxpl_id, H5AC_BT2_INT, curr_node_ptr->addr, internal, internal_flags) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release internal B-tree node") + internal = NULL; + + /* Indicate that the record was inserted */ + *status = H5B2_UPDATE_INSERT_DONE; + + /* Dodge sideways into inserting a record into this node */ + if(H5B2__insert_internal(hdr, dxpl_id, depth, parent_cache_info_flags_ptr, curr_node_ptr, curr_pos, udata) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, FAIL, "unable to insert record into internal B-tree node") + break; + + case H5B2_UPDATE_UNKNOWN: + default: + HDassert(0 && "Invalid update status"); + HGOTO_ERROR(H5E_BTREE, H5E_CANTUPDATE, FAIL, "invalid update status") + } /* end switch */ + } /* end else */ + +done: + /* Release the internal B-tree node */ + if(internal && H5AC_unprotect(hdr->f, dxpl_id, H5AC_BT2_INT, curr_node_ptr->addr, internal, internal_flags) < 0) + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release internal B-tree node") + + FUNC_LEAVE_NOAPI(ret_value) +} /* H5B2__update_internal() */ + + +/*------------------------------------------------------------------------- * Function: H5B2__create_leaf * * Purpose: Creates empty leaf node of a B-tree and update node pointer diff --git a/src/H5B2pkg.h b/src/H5B2pkg.h index f58850e..d6b6c04 100644 --- a/src/H5B2pkg.h +++ b/src/H5B2pkg.h @@ -228,6 +228,14 @@ typedef enum H5B2_nodepos_t { H5B2_POS_MIDDLE /* Node is neither right or left-most in tree */ } H5B2_nodepos_t; +/* Update status */ +typedef enum H5B2_update_status_t { + H5B2_UPDATE_UNKNOWN, /* Unknown update status (initial state) */ + H5B2_UPDATE_MODIFY_DONE, /* Update successfully modified existing record */ + H5B2_UPDATE_INSERT_DONE, /* Update inserted record successfully */ + H5B2_UPDATE_INSERT_CHILD_FULL /* Update will insert record, but child is full */ +} H5B2_update_status_t; + /* Callback info for loading a free space header into the cache */ typedef struct H5B2_hdr_cache_ud_t { H5F_t *f; /* File that v2 b-tree header is within */ @@ -252,7 +260,7 @@ typedef struct H5B2_leaf_cache_ud_t { #ifdef H5B2_TESTING /* Node information for testing */ -typedef struct { +typedef struct H5B2_node_info_test_t { unsigned depth; /* Depth of node */ unsigned nrec; /* Number of records in node */ } H5B2_node_info_test_t; @@ -281,6 +289,13 @@ H5FL_EXTERN(H5B2_leaf_t); /* Internal v2 B-tree testing class */ #ifdef H5B2_TESTING H5_DLLVAR const H5B2_class_t H5B2_TEST[1]; +H5_DLLVAR const H5B2_class_t H5B2_TEST2[1]; + +/* B-tree record for testing H5B2_TEST2 class */ +typedef struct H5B2_test_rec_t { + hsize_t key; /* Key for record */ + hsize_t val; /* Value for record */ +} H5B2_test_rec_t; #endif /* H5B2_TESTING */ /* Array of v2 B-tree client ID -> client class mappings */ @@ -327,12 +342,22 @@ H5_DLL herr_t H5B2__leaf_free(H5B2_leaf_t *l); H5_DLL herr_t H5B2__internal_free(H5B2_internal_t *i); /* Routines for inserting records */ +H5_DLL herr_t H5B2__insert_hdr(H5B2_hdr_t *hdr, hid_t dxpl_id, void *udata); H5_DLL herr_t H5B2__insert_internal(H5B2_hdr_t *hdr, hid_t dxpl_id, uint16_t depth, unsigned *parent_cache_info_flags_ptr, H5B2_node_ptr_t *curr_node_ptr, H5B2_nodepos_t curr_pos, void *udata); H5_DLL herr_t H5B2__insert_leaf(H5B2_hdr_t *hdr, hid_t dxpl_id, H5B2_node_ptr_t *curr_node_ptr, H5B2_nodepos_t curr_pos, void *udata); +/* Routines for update records */ +H5_DLL herr_t H5B2__update_internal(H5B2_hdr_t *hdr, hid_t dxpl_id, + uint16_t depth, unsigned *parent_cache_info_flags_ptr, + H5B2_node_ptr_t *curr_node_ptr, H5B2_update_status_t *status, + H5B2_nodepos_t curr_pos, void *udata, H5B2_modify_t op, void *op_data); +H5_DLL herr_t H5B2__update_leaf(H5B2_hdr_t *hdr, hid_t dxpl_id, + H5B2_node_ptr_t *curr_node_ptr, H5B2_update_status_t *status, + H5B2_nodepos_t curr_pos, void *udata, H5B2_modify_t op, void *op_data); + /* Routines for iterating over nodes/records */ H5_DLL herr_t H5B2__iterate_node(H5B2_hdr_t *hdr, hid_t dxpl_id, uint16_t depth, const H5B2_node_ptr_t *curr_node, H5B2_operator_t op, void *op_data); diff --git a/src/H5B2private.h b/src/H5B2private.h index 9e3c2d7..ff94680 100644 --- a/src/H5B2private.h +++ b/src/H5B2private.h @@ -54,6 +54,7 @@ typedef enum H5B2_subid_t { H5B2_SOHM_INDEX_ID, /* B-tree is an index for shared object header messages */ H5B2_ATTR_DENSE_NAME_ID, /* B-tree is for indexing 'name' field for "dense" attribute storage on objects */ H5B2_ATTR_DENSE_CORDER_ID, /* B-tree is for indexing 'creation order' field for "dense" attribute storage on objects */ + H5B2_TEST2_ID, /* Another B-tree is for testing (do not use for actual data) */ H5B2_NUM_BTREE_ID /* Number of B-tree IDs (must be last) */ } H5B2_subid_t; @@ -94,8 +95,6 @@ struct H5B2_class_t { herr_t (*decode)(const uint8_t *raw, void *record, void *ctx); /* Decode record from disk storage form to native form */ herr_t (*debug)(FILE *stream, int indent, int fwidth, /* Print a record for debugging */ const void *record, const void *ctx); - void *(*crt_dbg_ctx)(H5F_t *f, hid_t dxpl_id, haddr_t obj_addr); /* Create debugging context */ - herr_t (*dst_dbg_ctx)(void *dbg_ctx); /* Destroy debugging context */ }; /* v2 B-tree creation parameters */ @@ -140,6 +139,8 @@ H5_DLL herr_t H5B2_neighbor(H5B2_t *bt2, hid_t dxpl_id, H5B2_compare_t range, void *udata, H5B2_found_t op, void *op_data); H5_DLL herr_t H5B2_modify(H5B2_t *bt2, hid_t dxpl_id, void *udata, H5B2_modify_t op, void *op_data); +H5_DLL herr_t H5B2_update(H5B2_t *bt2, hid_t dxpl_id, void *udata, + H5B2_modify_t op, void *op_data); H5_DLL herr_t H5B2_remove(H5B2_t *b2, hid_t dxpl_id, void *udata, H5B2_remove_t op, void *op_data); H5_DLL herr_t H5B2_remove_by_idx(H5B2_t *bt2, hid_t dxpl_id, diff --git a/src/H5B2test.c b/src/H5B2test.c index 87fddf7..e0c96fb 100644 --- a/src/H5B2test.c +++ b/src/H5B2test.c @@ -61,6 +61,7 @@ typedef struct H5B2_test_ctx_t { /* Local Prototypes */ /********************/ +/* v2 B-tree driver callbacks for 'test' B-trees */ static void *H5B2__test_crt_context(void *udata); static herr_t H5B2__test_dst_context(void *ctx); static herr_t H5B2__test_store(void *nrecord, const void *udata); @@ -69,13 +70,21 @@ static herr_t H5B2__test_encode(uint8_t *raw, const void *nrecord, void *ctx); static herr_t H5B2__test_decode(const uint8_t *raw, void *nrecord, void *ctx); static herr_t H5B2__test_debug(FILE *stream, int indent, int fwidth, const void *record, const void *_udata); -static void *H5B2__test_crt_dbg_context(H5F_t *f, hid_t dxpl_id, haddr_t addr); + +/* v2 B-tree driver callbacks for 'test2' B-trees */ +static herr_t H5B2__test2_store(void *nrecord, const void *udata); +static herr_t H5B2__test2_compare(const void *rec1, const void *rec2); +static herr_t H5B2__test2_encode(uint8_t *raw, const void *nrecord, void *ctx); +static herr_t H5B2__test2_decode(const uint8_t *raw, void *nrecord, void *ctx); +static herr_t H5B2__test2_debug(FILE *stream, int indent, int fwidth, + const void *record, const void *_udata); /*********************/ /* Package Variables */ /*********************/ +/* Class structure for testing simple B-tree records */ const H5B2_class_t H5B2_TEST[1]={{ /* B-tree class information */ H5B2_TEST_ID, /* Type of B-tree */ "H5B2_TEST_ID", /* Name of B-tree class */ @@ -86,9 +95,21 @@ const H5B2_class_t H5B2_TEST[1]={{ /* B-tree class information */ H5B2__test_compare, /* Record comparison callback */ H5B2__test_encode, /* Record encoding callback */ H5B2__test_decode, /* Record decoding callback */ - H5B2__test_debug, /* Record debugging callback */ - H5B2__test_crt_dbg_context, /* Create debugging context */ - H5B2__test_dst_context /* Destroy debugging context */ + H5B2__test_debug /* Record debugging callback */ +}}; + +/* Class structure for testing key/value B-tree records */ +const H5B2_class_t H5B2_TEST2[1]={{ /* B-tree class information */ + H5B2_TEST2_ID, /* Type of B-tree */ + "H5B2_TEST2_ID", /* Name of B-tree class */ + sizeof(H5B2_test_rec_t), /* Size of native record */ + H5B2__test_crt_context, /* Create client callback context */ + H5B2__test_dst_context, /* Destroy client callback context */ + H5B2__test2_store, /* Record storage callback */ + H5B2__test2_compare, /* Record comparison callback */ + H5B2__test2_encode, /* Record encoding callback */ + H5B2__test2_decode, /* Record decoding callback */ + H5B2__test2_debug /* Record debugging callback */ }}; @@ -310,42 +331,139 @@ H5B2__test_debug(FILE *stream, int indent, int fwidth, const void *record, /*------------------------------------------------------------------------- - * Function: H5B2__test_crt_dbg_context + * Function: H5B2__test2_store * - * Purpose: Create context for debugging callback + * Purpose: Store native information into record for B-tree * - * Return: Success: non-NULL - * Failure: NULL + * Return: Success: non-negative + * Failure: negative * * Programmer: Quincey Koziol - * Tuesday, December 1, 2009 + * Friday, December 25, 2015 * *------------------------------------------------------------------------- */ -static void * -H5B2__test_crt_dbg_context(H5F_t *f, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t H5_ATTR_UNUSED addr) +static herr_t +H5B2__test2_store(void *nrecord, const void *udata) { - H5B2_test_ctx_t *ctx; /* Callback context structure */ - void *ret_value = NULL; /* Return value */ + FUNC_ENTER_STATIC_NOERR - FUNC_ENTER_STATIC + *(H5B2_test_rec_t *)nrecord = *(const H5B2_test_rec_t *)udata; + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* H5B2__test2_store() */ + + +/*------------------------------------------------------------------------- + * Function: H5B2__test2_compare + * + * Purpose: Compare two native information records, according to some key + * + * Return: <0 if rec1 < rec2 + * =0 if rec1 == rec2 + * >0 if rec1 > rec2 + * + * Programmer: Quincey Koziol + * Friday, December 25, 2015 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5B2__test2_compare(const void *rec1, const void *rec2) +{ + FUNC_ENTER_STATIC_NOERR + + FUNC_LEAVE_NOAPI((herr_t)(((const H5B2_test_rec_t *)rec1)->key - ((const H5B2_test_rec_t *)rec2)->key)) +} /* H5B2__test2_compare() */ + + +/*------------------------------------------------------------------------- + * Function: H5B2__test2_encode + * + * Purpose: Encode native information into raw form for storing on disk + * + * Return: Success: non-negative + * Failure: negative + * + * Programmer: Quincey Koziol + * Friday, December 25, 2015 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5B2__test2_encode(uint8_t *raw, const void *nrecord, void *_ctx) +{ + H5B2_test_ctx_t *ctx = (H5B2_test_ctx_t *)_ctx; /* Callback context structure */ + + FUNC_ENTER_STATIC_NOERR /* Sanity check */ - HDassert(f); + HDassert(ctx); - /* Allocate callback context */ - if(NULL == (ctx = H5FL_MALLOC(H5B2_test_ctx_t))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "can't allocate callback context") + H5F_ENCODE_LENGTH_LEN(raw, ((const H5B2_test_rec_t *)nrecord)->key, ctx->sizeof_size); + H5F_ENCODE_LENGTH_LEN(raw, ((const H5B2_test_rec_t *)nrecord)->val, ctx->sizeof_size); - /* Determine the size of addresses & lengths in the file */ - ctx->sizeof_size = H5F_SIZEOF_SIZE(f); + FUNC_LEAVE_NOAPI(SUCCEED) +} /* H5B2__test2_encode() */ - /* Set return value */ - ret_value = ctx; + +/*------------------------------------------------------------------------- + * Function: H5B2__test2_decode + * + * Purpose: Decode raw disk form of record into native form + * + * Return: Success: non-negative + * Failure: negative + * + * Programmer: Quincey Koziol + * Friday, December 25, 2015 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5B2__test2_decode(const uint8_t *raw, void *nrecord, void *_ctx) +{ + H5B2_test_ctx_t *ctx = (H5B2_test_ctx_t *)_ctx; /* Callback context structure */ -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5B2__test_crt_dbg_context() */ + FUNC_ENTER_STATIC_NOERR + + /* Sanity check */ + HDassert(ctx); + + H5F_DECODE_LENGTH_LEN(raw, ((H5B2_test_rec_t *)nrecord)->key, ctx->sizeof_size); + H5F_DECODE_LENGTH_LEN(raw, ((H5B2_test_rec_t *)nrecord)->val, ctx->sizeof_size); + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* H5B2__test2_decode() */ + + +/*------------------------------------------------------------------------- + * Function: H5B2__test2_debug + * + * Purpose: Debug native form of record + * + * Return: Success: non-negative + * Failure: negative + * + * Programmer: Quincey Koziol + * Friday, December 25, 2015 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5B2__test2_debug(FILE *stream, int indent, int fwidth, const void *record, + const void H5_ATTR_UNUSED *_udata) +{ + FUNC_ENTER_STATIC_NOERR + + HDassert(record); + + HDfprintf(stream, "%*s%-*s (%Hu, %Hu)\n", indent, "", fwidth, "Record:", + ((const H5B2_test_rec_t *)record)->key, + ((const H5B2_test_rec_t *)record)->val); + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* H5B2__test2_debug() */ /*------------------------------------------------------------------------- diff --git a/src/H5Gbtree2.c b/src/H5Gbtree2.c index b464930..1a99b12 100644 --- a/src/H5Gbtree2.c +++ b/src/H5Gbtree2.c @@ -114,9 +114,7 @@ const H5B2_class_t H5G_BT2_NAME[1]={{ /* B-tree class information */ H5G_dense_btree2_name_compare, /* Record comparison callback */ H5G_dense_btree2_name_encode, /* Record encoding callback */ H5G_dense_btree2_name_decode, /* Record decoding callback */ - H5G_dense_btree2_name_debug, /* Record debugging callback */ - NULL, /* Create debugging context */ - NULL /* Destroy debugging context */ + H5G_dense_btree2_name_debug /* Record debugging callback */ }}; /* v2 B-tree class for indexing 'creation order' field of links */ @@ -130,9 +128,7 @@ const H5B2_class_t H5G_BT2_CORDER[1]={{ /* B-tree class information */ H5G_dense_btree2_corder_compare, /* Record comparison callback */ H5G_dense_btree2_corder_encode, /* Record encoding callback */ H5G_dense_btree2_corder_decode, /* Record decoding callback */ - H5G_dense_btree2_corder_debug, /* Record debugging callback */ - NULL, /* Create debugging context */ - NULL /* Destroy debugging context */ + H5G_dense_btree2_corder_debug /* Record debugging callback */ }}; /*****************************/ diff --git a/src/H5HFbtree2.c b/src/H5HFbtree2.c index d82de93..a79bf58 100644 --- a/src/H5HFbtree2.c +++ b/src/H5HFbtree2.c @@ -71,7 +71,6 @@ typedef struct H5HF_huge_bt2_ctx_t { /* Common callbacks */ static void *H5HF__huge_bt2_crt_context(void *udata); static herr_t H5HF__huge_bt2_dst_context(void *ctx); -static void *H5HF__huge_bt2_crt_dbg_context(H5F_t *f, hid_t dxpl_id, haddr_t addr); /* Callbacks for indirect objects */ static herr_t H5HF__huge_bt2_indir_store(void *native, const void *udata); @@ -127,9 +126,7 @@ const H5B2_class_t H5HF_HUGE_BT2_INDIR[1]={{ /* B-tree class information */ H5HF__huge_bt2_indir_compare, /* Record comparison callback */ H5HF__huge_bt2_indir_encode, /* Record encoding callback */ H5HF__huge_bt2_indir_decode, /* Record decoding callback */ - H5HF__huge_bt2_indir_debug, /* Record debugging callback */ - H5HF__huge_bt2_crt_dbg_context, /* Create debugging context */ - H5HF__huge_bt2_dst_context /* Destroy debugging context */ + H5HF__huge_bt2_indir_debug /* Record debugging callback */ }}; /* v2 B-tree class for indirectly accessed, filtered 'huge' objects */ @@ -143,9 +140,7 @@ const H5B2_class_t H5HF_HUGE_BT2_FILT_INDIR[1]={{ /* B-tree class information */ H5HF__huge_bt2_filt_indir_compare, /* Record comparison callback */ H5HF__huge_bt2_filt_indir_encode, /* Record encoding callback */ H5HF__huge_bt2_filt_indir_decode, /* Record decoding callback */ - H5HF__huge_bt2_filt_indir_debug, /* Record debugging callback */ - H5HF__huge_bt2_crt_dbg_context, /* Create debugging context */ - H5HF__huge_bt2_dst_context /* Destroy debugging context */ + H5HF__huge_bt2_filt_indir_debug /* Record debugging callback */ }}; /* v2 B-tree class for directly accessed 'huge' objects */ @@ -159,9 +154,7 @@ const H5B2_class_t H5HF_HUGE_BT2_DIR[1]={{ /* B-tree class information */ H5HF__huge_bt2_dir_compare, /* Record comparison callback */ H5HF__huge_bt2_dir_encode, /* Record encoding callback */ H5HF__huge_bt2_dir_decode, /* Record decoding callback */ - H5HF__huge_bt2_dir_debug, /* Record debugging callback */ - H5HF__huge_bt2_crt_dbg_context, /* Create debugging context */ - H5HF__huge_bt2_dst_context /* Destroy debugging context */ + H5HF__huge_bt2_dir_debug /* Record debugging callback */ }}; /* v2 B-tree class for directly accessed, filtered 'huge' objects */ @@ -175,9 +168,7 @@ const H5B2_class_t H5HF_HUGE_BT2_FILT_DIR[1]={{ /* B-tree class information */ H5HF__huge_bt2_filt_dir_compare, /* Record comparison callback */ H5HF__huge_bt2_filt_dir_encode, /* Record encoding callback */ H5HF__huge_bt2_filt_dir_decode, /* Record decoding callback */ - H5HF__huge_bt2_filt_dir_debug, /* Record debugging callback */ - H5HF__huge_bt2_crt_dbg_context, /* Create debugging context */ - H5HF__huge_bt2_dst_context /* Destroy debugging context */ + H5HF__huge_bt2_filt_dir_debug /* Record debugging callback */ }}; /*****************************/ @@ -270,46 +261,6 @@ H5HF__huge_bt2_dst_context(void *_ctx) /*------------------------------------------------------------------------- - * Function: H5HF__huge_bt2_crt_dbg_context - * - * Purpose: Create context for debugging callback - * - * Return: Success: non-NULL - * Failure: NULL - * - * Programmer: Quincey Koziol - * Tuesday, December 1, 2009 - * - *------------------------------------------------------------------------- - */ -static void * -H5HF__huge_bt2_crt_dbg_context(H5F_t *f, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t H5_ATTR_UNUSED addr) -{ - H5HF_huge_bt2_ctx_t *ctx; /* Callback context structure */ - void *ret_value = NULL; /* Return value */ - - FUNC_ENTER_STATIC - - /* Sanity check */ - HDassert(f); - - /* Allocate callback context */ - if(NULL == (ctx = H5FL_MALLOC(H5HF_huge_bt2_ctx_t))) - HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "can't allocate callback context") - - /* Determine the size of addresses & lengths in the file */ - ctx->sizeof_addr = H5F_SIZEOF_ADDR(f); - ctx->sizeof_size = H5F_SIZEOF_SIZE(f); - - /* Set return value */ - ret_value = ctx; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5HF__huge_bt2_crt_dbg_context() */ - - -/*------------------------------------------------------------------------- * Function: H5HF__huge_bt2_indir_found * * Purpose: Retrieve record for indirectly accessed 'huge' object, when diff --git a/src/H5SMbtree2.c b/src/H5SMbtree2.c index e533ae8..0110c1e 100644 --- a/src/H5SMbtree2.c +++ b/src/H5SMbtree2.c @@ -50,7 +50,6 @@ static herr_t H5SM__bt2_dst_context(void *ctx); static herr_t H5SM__bt2_store(void *native, const void *udata); static herr_t H5SM__bt2_debug(FILE *stream, int indent, int fwidth, const void *record, const void *_udata); -static void *H5SM__bt2_crt_dbg_context(H5F_t *f, hid_t dxpl_id, haddr_t addr); /*****************************/ @@ -67,9 +66,7 @@ const H5B2_class_t H5SM_INDEX[1]={{ /* B-tree class information */ H5SM__message_compare, /* Record comparison callback */ H5SM__message_encode, /* Record encoding callback */ H5SM__message_decode, /* Record decoding callback */ - H5SM__bt2_debug, /* Record debugging callback */ - H5SM__bt2_crt_dbg_context, /* Create debugging context */ - H5SM__bt2_dst_context /* Destroy debugging context */ + H5SM__bt2_debug /* Record debugging callback */ }}; @@ -218,45 +215,6 @@ H5SM__bt2_debug(FILE *stream, int indent, int fwidth, /*------------------------------------------------------------------------- - * Function: H5SM__bt2_crt_dbg_context - * - * Purpose: Create context for debugging callback - * - * Return: Success: non-NULL - * Failure: NULL - * - * Programmer: Quincey Koziol - * Tuesday, December 1, 2009 - * - *------------------------------------------------------------------------- - */ -static void * -H5SM__bt2_crt_dbg_context(H5F_t *f, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t H5_ATTR_UNUSED addr) -{ - H5SM_bt2_ctx_t *ctx; /* Callback context structure */ - void *ret_value = NULL; /* Return value */ - - FUNC_ENTER_STATIC - - /* Sanity check */ - HDassert(f); - - /* Allocate callback context */ - if(NULL == (ctx = H5FL_MALLOC(H5SM_bt2_ctx_t))) - HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "can't allocate callback context") - - /* Determine the size of addresses & lengths in the file */ - ctx->sizeof_addr = H5F_SIZEOF_ADDR(f); - - /* Set return value */ - ret_value = ctx; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5SM__bt2_crt_dbg_context() */ - - -/*------------------------------------------------------------------------- * Function: H5SM_bt2_convert_to_list_op * * Purpose: An H5B2_remove_t callback function to convert a SOHM diff --git a/test/btree2.c b/test/btree2.c index 7a2432c..04c94fd 100644 --- a/test/btree2.c +++ b/test/btree2.c @@ -36,8 +36,11 @@ const char *FILENAME[] = { }; #define INSERT_SPLIT_ROOT_NREC 63 -#define INSERT_MANY (1000*1000) -#define FIND_MANY (INSERT_MANY/100) +#define INSERT_SPLIT_ROOT_NREC_REC 64 +#define INSERT_MANY (1000 * 1000) +#define INSERT_MANY_REC (2600 * 1000) +#define FIND_MANY (INSERT_MANY / 100) +#define FIND_MANY_REC (INSERT_MANY_REC / 100) #define FIND_NEIGHBOR 2000 #define DELETE_SMALL 20 #define DELETE_MEDIUM 200 @@ -63,7 +66,7 @@ typedef struct bt2_test_param_t { *------------------------------------------------------------------------- */ static int -init_cparam(H5B2_create_t *cparam) +init_cparam(H5B2_create_t *cparam, H5B2_create_t *cparam2) { /* Wipe out background */ HDmemset(cparam, 0, sizeof(*cparam)); @@ -75,6 +78,16 @@ init_cparam(H5B2_create_t *cparam) cparam->split_percent = 100; cparam->merge_percent = 40; + /* Wipe out background */ + HDmemset(cparam2, 0, sizeof(*cparam2)); + + /* General parameters */ + cparam2->cls = H5B2_TEST2; + cparam2->node_size = (size_t)1024; + cparam2->rrec_size = (size_t)16; + cparam2->split_percent = 100; + cparam2->merge_percent = 40; + return(0); } /* init_cparam() */ @@ -154,6 +167,47 @@ error: /*------------------------------------------------------------------------- + * Function: reopen_file + * + * Purpose: Re-open the file + * + * Return: Success: 0 + * Failure: 1 + * + * Programmer: Quincey Koziol + * Monday, December 28, 2015 + * + *------------------------------------------------------------------------- + */ +static int +reopen_file(hid_t *file, H5F_t **f, hid_t fapl) +{ + char filename[1024]; /* Filename to use */ + + /* Set the filename to use for this test (dependent on fapl) */ + h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); + + /* Create the file to work on */ + if((*file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + TEST_ERROR + + /* Get a pointer to the internal file object */ + if(NULL == (*f = (H5F_t *)H5I_object(*file))) + STACK_ERROR + + /* Ignore metadata tags in the file's cache */ + if(H5AC_ignore_tags(*f) < 0) + STACK_ERROR + + /* Success */ + return(0); + +error: + return(-1); +} /* end create_file() */ + + +/*------------------------------------------------------------------------- * Function: reopen_btree * * Purpose: Perform common "re-open" operations on B-tree for testing @@ -237,11 +291,11 @@ error: *------------------------------------------------------------------------- */ static int -check_node_depth(H5B2_t *bt2, hid_t dxpl, hsize_t record, unsigned depth) +check_node_depth(H5B2_t *bt2, hid_t dxpl, void *record, unsigned depth) { int rec_depth; /* Depth of record in B-tree */ - if((rec_depth = H5B2_get_node_depth_test(bt2, dxpl, &record)) < 0) + if((rec_depth = H5B2_get_node_depth_test(bt2, dxpl, record)) < 0) FAIL_STACK_ERROR if((unsigned)rec_depth != depth) TEST_ERROR @@ -285,7 +339,7 @@ check_node_info(H5B2_t *bt2, hid_t dxpl, hsize_t record, error: return(-1); -} /* end check_node_depth() */ +} /* end check_node_info() */ /*------------------------------------------------------------------------- @@ -294,7 +348,6 @@ error: * Purpose: v2 B-tree iterator callback * * Return: Success: 0 - * * Failure: 1 * * Programmer: Quincey Koziol @@ -317,12 +370,41 @@ iter_cb(const void *_record, void *_op_data) /*------------------------------------------------------------------------- + * Function: iter_rec_cb + * + * Purpose: v2 B-tree iterator callback for H5B2_test_rec_t records + * + * Return: Success: 0 + * Failure: 1 + * + * Programmer: Quincey Koziol + * Friday, December 25, 2015 + * + *------------------------------------------------------------------------- + */ +static int +iter_rec_cb(const void *_record, void *_op_data) +{ + const H5B2_test_rec_t *record = (const H5B2_test_rec_t *)_record; + H5B2_test_rec_t *idx = (H5B2_test_rec_t *)_op_data; + + if(record->key != idx->key) + return(H5_ITER_ERROR); + if(record->val != idx->val) + return(H5_ITER_ERROR); + + idx->key++; + idx->val += 2; + return(H5_ITER_CONT); +} /* end iter_rec_cb() */ + + +/*------------------------------------------------------------------------- * Function: find_cb * * Purpose: v2 B-tree find callback * * Return: Success: TRUE/FALSE - * * Failure: FAIL * * Programmer: Quincey Koziol @@ -344,6 +426,33 @@ find_cb(const void *_record, void *_op_data) /*------------------------------------------------------------------------- + * Function: find_rec_cb + * + * Purpose: v2 B-tree find callback for H5B2_test_rec_t records + * + * Return: Success: TRUE/FALSE + * Failure: FAIL + * + * Programmer: Quincey Koziol + * Friday, December 25, 2015 + * + *------------------------------------------------------------------------- + */ +static int +find_rec_cb(const void *_record, void *_op_data) +{ + const H5B2_test_rec_t *record = (const H5B2_test_rec_t *)_record; + H5B2_test_rec_t *search = (H5B2_test_rec_t *)_op_data; + + if(record->key != search->key) + return(FALSE); + + search->val = record->val; + return(TRUE); +} /* end find_rec_cb() */ + + +/*------------------------------------------------------------------------- * Function: find_dec_cb * * Purpose: v2 B-tree find callback for indexing in decreasing order @@ -372,6 +481,34 @@ find_dec_cb(const void *_record, void *_op_data) /*------------------------------------------------------------------------- + * Function: index_rec_cb + * + * Purpose: v2 B-tree index callback for H5B2_test_rec_t records + * + * Return: Success: TRUE/FALSE + * Failure: FAIL + * + * Programmer: Quincey Koziol + * Friday, December 25, 2015 + * + *------------------------------------------------------------------------- + */ +static int +index_rec_cb(const void *_record, void *_op_data) +{ + const H5B2_test_rec_t *record = (const H5B2_test_rec_t *)_record; + H5B2_test_rec_t *search = (H5B2_test_rec_t *)_op_data; + + HDassert(record); + HDassert(search); + + search->key = record->key; + search->val = record->val; + return(TRUE); +} /* end index_rec_cb() */ + + +/*------------------------------------------------------------------------- * Function: neighbor_cb * * Purpose: v2 B-tree neighbor callback @@ -425,6 +562,57 @@ modify_cb(void *_record, void *_op_data, hbool_t *changed) /*------------------------------------------------------------------------- + * Function: modify_rec_cb + * + * Purpose: v2 B-tree modify callback for H5B2_test_rec_t records + * + * Return: Success: 0 + * Failure: 1 + * + * Programmer: Quincey Koziol + * Friday, December 25, 2015 + * + *------------------------------------------------------------------------- + */ +static int +modify_rec_cb(void *_record, void *_op_data, hbool_t *changed) +{ + H5B2_test_rec_t *record = (H5B2_test_rec_t *)_record; + H5B2_test_rec_t *modify = (H5B2_test_rec_t *)_op_data; + + HDassert(record->key == modify->key); + record->val = modify->val; + *changed = TRUE; + + return(0); +} /* end modify_rec_cb() */ + + +/*------------------------------------------------------------------------- + * Function: no_modify_cb + * + * Purpose: v2 B-tree modify callback for updates which shouldn't change + * the record (ie. inserting not modifying) + * + * Return: Success: 0 + * Failure: 1 + * + * Programmer: Quincey Koziol + * Wednesday, December 23, 2015 + * + *------------------------------------------------------------------------- + */ +static int +no_modify_cb(void H5_ATTR_UNUSED *_record, void H5_ATTR_UNUSED *_op_data, + hbool_t *changed) +{ + *changed = FALSE; + + return(1); +} /* end no_modify_cb() */ + + +/*------------------------------------------------------------------------- * Function: remove_cb * * Purpose: v2 B-tree remove callback @@ -717,7 +905,8 @@ test_insert_split_root(hid_t fapl, const H5B2_create_t *cparam, bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC - 1); if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)33, (unsigned)0) < 0) + record = (hsize_t)33; + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ @@ -734,7 +923,8 @@ test_insert_split_root(hid_t fapl, const H5B2_create_t *cparam, bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC; if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)33, (unsigned)1) < 0) + record = (hsize_t)33; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ @@ -755,7 +945,8 @@ test_insert_split_root(hid_t fapl, const H5B2_create_t *cparam, bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC + 2); if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)33, (unsigned)1) < 0) + record = (hsize_t)33; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ @@ -889,7 +1080,8 @@ test_insert_level1_2leaf_redistrib(hid_t fapl, const H5B2_create_t *cparam, bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC; if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)INSERT_SPLIT_ROOT_NREC, (unsigned)1) < 0) + record = (hsize_t)INSERT_SPLIT_ROOT_NREC; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ @@ -909,7 +1101,8 @@ test_insert_level1_2leaf_redistrib(hid_t fapl, const H5B2_create_t *cparam, bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC + (INSERT_SPLIT_ROOT_NREC / 2) + 1); if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)((INSERT_SPLIT_ROOT_NREC / 2) + (INSERT_SPLIT_ROOT_NREC / 4) + 1), (unsigned)1) < 0) + record = (hsize_t)((INSERT_SPLIT_ROOT_NREC / 2) + (INSERT_SPLIT_ROOT_NREC / 4) + 1); + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR /* Close the v2 B-tree */ @@ -940,7 +1133,8 @@ test_insert_level1_2leaf_redistrib(hid_t fapl, const H5B2_create_t *cparam, bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC; if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)(INSERT_SPLIT_ROOT_NREC / 2), (unsigned)1) < 0) + record = (hsize_t)(INSERT_SPLIT_ROOT_NREC / 2); + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ @@ -959,7 +1153,8 @@ test_insert_level1_2leaf_redistrib(hid_t fapl, const H5B2_create_t *cparam, bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC + (INSERT_SPLIT_ROOT_NREC / 2) + 1; if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)((INSERT_SPLIT_ROOT_NREC / 2) + (INSERT_SPLIT_ROOT_NREC / 4) + 1), (unsigned)1) < 0) + record = (hsize_t)((INSERT_SPLIT_ROOT_NREC / 2) + (INSERT_SPLIT_ROOT_NREC / 4) + 1); + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR /* Close the v2 B-tree */ @@ -1041,7 +1236,7 @@ test_insert_level1_side_split(hid_t fapl, const H5B2_create_t *cparam, if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = INSERT_SPLIT_ROOT_NREC + (INSERT_SPLIT_ROOT_NREC / 2); - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ @@ -1061,10 +1256,10 @@ test_insert_level1_side_split(hid_t fapl, const H5B2_create_t *cparam, if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = 31; - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 63; - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR /* Close the v2 B-tree */ @@ -1096,7 +1291,7 @@ test_insert_level1_side_split(hid_t fapl, const H5B2_create_t *cparam, if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = (INSERT_SPLIT_ROOT_NREC / 2); - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ @@ -1115,9 +1310,11 @@ test_insert_level1_side_split(hid_t fapl, const H5B2_create_t *cparam, bt2_stat.nrecords = 2 * INSERT_SPLIT_ROOT_NREC; if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)62, (unsigned)1) < 0) + record = 62; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)94, (unsigned)1) < 0) + record = 94; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR /* Close the v2 B-tree */ @@ -1202,7 +1399,7 @@ test_insert_level1_3leaf_redistrib(hid_t fapl, const H5B2_create_t *cparam, if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = (2 * INSERT_SPLIT_ROOT_NREC); - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ @@ -1222,10 +1419,10 @@ test_insert_level1_3leaf_redistrib(hid_t fapl, const H5B2_create_t *cparam, if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = (INSERT_SPLIT_ROOT_NREC / 2); - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = (INSERT_SPLIT_ROOT_NREC + (INSERT_SPLIT_ROOT_NREC / 2) + 1); - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ @@ -1244,9 +1441,11 @@ test_insert_level1_3leaf_redistrib(hid_t fapl, const H5B2_create_t *cparam, bt2_stat.nrecords = (2 * INSERT_SPLIT_ROOT_NREC) + (INSERT_SPLIT_ROOT_NREC / 2) + 1; if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)52, (unsigned)1) < 0) + record = 52; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)105, (unsigned)1) < 0) + record = 105; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ @@ -1343,7 +1542,7 @@ test_insert_level1_middle_split(hid_t fapl, const H5B2_create_t *cparam, if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = (2 * INSERT_SPLIT_ROOT_NREC) + (INSERT_SPLIT_ROOT_NREC / 2); - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ @@ -1362,11 +1561,14 @@ test_insert_level1_middle_split(hid_t fapl, const H5B2_create_t *cparam, bt2_stat.nrecords = 3 * INSERT_SPLIT_ROOT_NREC; if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)62, (unsigned)1) < 0) + record = 62; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)94, (unsigned)1) < 0) + record = 94; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)126, (unsigned)1) < 0) + record = 126; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ @@ -1464,7 +1666,8 @@ test_insert_make_level2(hid_t fapl, const H5B2_create_t *cparam, bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC * 29) + 1; if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)948, (unsigned)2) < 0) + record = 948; + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ @@ -1513,7 +1716,8 @@ test_insert_make_level2(hid_t fapl, const H5B2_create_t *cparam, FAIL_STACK_ERROR /* Check with B-tree */ - if(check_node_depth(bt2, dxpl, (hsize_t)948, (unsigned)2) < 0) + record = 948; + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR /* Attempt to find existant record in internal node of level-2 B-tree */ @@ -1522,7 +1726,8 @@ test_insert_make_level2(hid_t fapl, const H5B2_create_t *cparam, FAIL_STACK_ERROR /* Check with B-tree */ - if(check_node_depth(bt2, dxpl, (hsize_t)505, (unsigned)1) < 0) + record = 505; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR /* Attempt to find existant record in leaf of level-2 B-tree */ @@ -1531,7 +1736,8 @@ test_insert_make_level2(hid_t fapl, const H5B2_create_t *cparam, FAIL_STACK_ERROR /* Check with B-tree */ - if(check_node_depth(bt2, dxpl, (hsize_t)555, (unsigned)0) < 0) + record = 555; + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) TEST_ERROR /* Attempt to index non-existant record in level-2 B-tree */ @@ -1642,11 +1848,14 @@ test_insert_level2_leaf_redistrib(hid_t fapl, const H5B2_create_t *cparam, bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC * 29) + (INSERT_SPLIT_ROOT_NREC / 2); if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)1008, (unsigned)2) < 0) + record = 1008; + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)1859, (unsigned)1) < 0) + record = 1859; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)1921, (unsigned)0) < 0) + record = 1921; + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ @@ -1663,11 +1872,14 @@ test_insert_level2_leaf_redistrib(hid_t fapl, const H5B2_create_t *cparam, bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC * 29) + (INSERT_SPLIT_ROOT_NREC / 2) + 1; if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)1008, (unsigned)2) < 0) + record = 1008; + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)1875, (unsigned)1) < 0) + record = 1875; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)1922, (unsigned)0) < 0) + record = 1922; + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) TEST_ERROR PASSED(); @@ -1683,11 +1895,14 @@ test_insert_level2_leaf_redistrib(hid_t fapl, const H5B2_create_t *cparam, bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC * 29) + (INSERT_SPLIT_ROOT_NREC / 2) + 1; if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)1008, (unsigned)2) < 0) + record = 1008; + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)94, (unsigned)1) < 0) + record = 94; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)32, (unsigned)0) < 0) + record = 32; + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) TEST_ERROR /* Add more records to left-most leaf, to force a 2->1 split and then a @@ -1704,11 +1919,14 @@ test_insert_level2_leaf_redistrib(hid_t fapl, const H5B2_create_t *cparam, bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC * 30) + 1; if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)1008, (unsigned)2) < 0) + record = 1008; + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)47, (unsigned)1) < 0) + record = 47; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)0, (unsigned)0) < 0) + record = 0; + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) TEST_ERROR PASSED(); @@ -1724,13 +1942,17 @@ test_insert_level2_leaf_redistrib(hid_t fapl, const H5B2_create_t *cparam, bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC * 30) + 1; if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)1008, (unsigned)2) < 0) /* Record in root node */ + record = 1008; + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) /* Record in root node */ TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)535, (unsigned)1) < 0) /* Record in middle node before insertion point */ + record = 535; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) /* Record in middle node before insertion point */ TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)630, (unsigned)1) < 0) /* Record in middle node after insertion point */ + record = 630; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) /* Record in middle node after insertion point */ TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)568, (unsigned)0) < 0) /* Record in leaf node just after insertion point */ + record = 568; + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) /* Record in leaf node just after insertion point */ TEST_ERROR /* Add more records to middle leaf, to force a split and a 3 node redistribution on middle leaf */ @@ -1745,13 +1967,17 @@ test_insert_level2_leaf_redistrib(hid_t fapl, const H5B2_create_t *cparam, bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC * 30) + (INSERT_SPLIT_ROOT_NREC / 2) + 2; if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)1008, (unsigned)2) < 0) /* Record in root node */ + record = 1008; + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) /* Record in root node */ TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)524, (unsigned)1) < 0) /* Record in middle node before insertion point */ + record = 524; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) /* Record in middle node before insertion point */ TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)577, (unsigned)1) < 0) /* Record in middle node after insertion point */ + record = 577; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) /* Record in middle node after insertion point */ TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)568, (unsigned)0) < 0) /* Record in leaf node just after insertion point */ + record = 568; + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) /* Record in leaf node just after insertion point */ TEST_ERROR /* Check for closing & re-opening the B-tree */ @@ -1851,13 +2077,13 @@ test_insert_level2_leaf_split(hid_t fapl, const H5B2_create_t *cparam, if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = 946; /* Record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR record = 1797; /* Right-most record in right internal node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 1859; /* Right-most record in right-most leaf */ - if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ @@ -1877,16 +2103,16 @@ test_insert_level2_leaf_split(hid_t fapl, const H5B2_create_t *cparam, if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = 946; /* Record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR record = 1828; /* Next-to-right-most record in right-most internal node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 1860; /* Right-most record in right-most internal node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 1891; /* Right-most record in right-most leaf */ - if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) TEST_ERROR PASSED(); @@ -1903,13 +2129,13 @@ test_insert_level2_leaf_split(hid_t fapl, const H5B2_create_t *cparam, if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = 946; /* Record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR record = 63; /* Left-most record in left-most internal node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 1; /* Left-most record in left-most leaf */ - if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) TEST_ERROR /* Add another record to left-most leaf, to force a 1->2 node split on left leaf */ @@ -1923,16 +2149,16 @@ test_insert_level2_leaf_split(hid_t fapl, const H5B2_create_t *cparam, if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = 946; /* Record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR record = 63; /* Left-most record in left-most internal node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 32; /* Left-most record in left internal node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 0; /* Left-most record in left-most leaf */ - if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) TEST_ERROR PASSED(); @@ -1949,16 +2175,16 @@ test_insert_level2_leaf_split(hid_t fapl, const H5B2_create_t *cparam, if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = 946; /* Record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR record = 504; /* Record in internal node just before insertion point */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 568; /* Record in internal node just after insertion point */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 506; /* Record in leaf node just after insertion point */ - if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) TEST_ERROR /* Add another record to middle leaf, to force a node split on middle leaf */ @@ -1972,19 +2198,19 @@ test_insert_level2_leaf_split(hid_t fapl, const H5B2_create_t *cparam, if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = 946; /* Record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR record = 504; /* Left-most record of split in left internal node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 537; /* Middle record of split in left internal node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 568; /* Right-most record of split in left internal node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 506; /* Record in leaf node just after insertion point */ - if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ @@ -2081,13 +2307,13 @@ test_insert_level2_2internal_redistrib(hid_t fapl, const H5B2_create_t *cparam, if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = 1318; /* Record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR record = 3114; /* Right-most record in right internal node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 3145; /* Right-most record in right leaf node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ @@ -2105,13 +2331,13 @@ test_insert_level2_2internal_redistrib(hid_t fapl, const H5B2_create_t *cparam, if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = 1822; /* Record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR record = 3114; /* Right-most record in right internal node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 3146; /* Right-most record in right leaf node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) TEST_ERROR PASSED(); @@ -2128,13 +2354,13 @@ test_insert_level2_2internal_redistrib(hid_t fapl, const H5B2_create_t *cparam, if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = 1822; /* Record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR record = 436; /* Left-most record in left internal node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 374; /* Left-most record in left leaf node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) TEST_ERROR /* Force left-most internal node to redistribute */ @@ -2150,13 +2376,13 @@ test_insert_level2_2internal_redistrib(hid_t fapl, const H5B2_create_t *cparam, if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = 1570; /* Record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR record = 61; /* Left-most record in left internal node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 0; /* Left-most record in left leaf node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ @@ -2253,13 +2479,13 @@ test_insert_level2_2internal_split(hid_t fapl, const H5B2_create_t *cparam, if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = 2759; /* Record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR record = 4555; /* Right-most record in right internal node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 4586; /* Right-most record in right leaf node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ @@ -2277,16 +2503,16 @@ test_insert_level2_2internal_split(hid_t fapl, const H5B2_create_t *cparam, if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = 2759; /* Left record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR record = 3704; /* Right record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR record = 4555; /* Right-most record in right internal node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 4387; /* Right-most record in right leaf node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) TEST_ERROR PASSED(); @@ -2303,13 +2529,13 @@ test_insert_level2_2internal_split(hid_t fapl, const H5B2_create_t *cparam, if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = 2759; /* Left record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR record = 932; /* Left-most record in left internal node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 870; /* Left-most record in left leaf node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) TEST_ERROR /* Force left-most internal node to split */ @@ -2325,16 +2551,16 @@ test_insert_level2_2internal_split(hid_t fapl, const H5B2_create_t *cparam, if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = 870; /* Left record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR record = 1814; /* Next-to-left-most record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR record = 61; /* Left-most record in left internal node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 0; /* Left-most record in left leaf node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ @@ -2436,19 +2662,19 @@ test_insert_level2_3internal_redistrib(hid_t fapl, const H5B2_create_t *cparam, if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = 1889; /* Left record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR record = 3703; /* Right record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR record = 2267; /* Record to left of insertion point in middle internal node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 3199; /* Record to right of insertion point in middle internal node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 3137; /* Record just above insertion point in leaf node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ @@ -2468,19 +2694,19 @@ test_insert_level2_3internal_redistrib(hid_t fapl, const H5B2_create_t *cparam, if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = 1889; /* Left record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR record = 3703; /* Right record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR record = 3104; /* Record to left of insertion point in middle internal node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 3137; /* Record to right of insertion point in middle internal node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 3135; /* Record just above insertion point in leaf node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ @@ -2498,21 +2724,21 @@ test_insert_level2_3internal_redistrib(hid_t fapl, const H5B2_create_t *cparam, if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = 1574; /* Left record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR record = 3104; /* Right record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR #ifdef NONE record = 2862; /* Record to left of insertion point in right internal node (now) */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR #endif /* NONE */ record = 3137; /* Record to right of insertion point in right internal node (now) */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 3135; /* Record just above insertion point in leaf node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ @@ -2588,126 +2814,2129 @@ test_insert_level2_3internal_split(hid_t fapl, const H5B2_create_t *cparam, */ TESTING("B-tree insert: split 3 internals to 4 in level 2 B-tree"); - /* Create the file for the test */ - if(create_file(&file, &f, fapl) < 0) + /* Create the file for the test */ + if(create_file(&file, &f, fapl) < 0) + TEST_ERROR + + /* Create the v2 B-tree & get its address */ + if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0) + TEST_ERROR + + /* Insert enough records to force root to split into 3 internal nodes */ + /* (and fill right internal node) */ + for(u = 0; u < (INSERT_SPLIT_ROOT_NREC * 31); u++) { + record = u; + if(H5B2_insert(bt2, dxpl, &record) < 0) + FAIL_STACK_ERROR + } /* end for */ + for(; u < (INSERT_SPLIT_ROOT_NREC * 74); u++) { + record = u + ((INSERT_SPLIT_ROOT_NREC * 13) + ((3 * INSERT_SPLIT_ROOT_NREC) / 4) + 3); + if(H5B2_insert(bt2, dxpl, &record) < 0) + FAIL_STACK_ERROR + } /* end for */ + + /* Check for closing & re-opening the B-tree */ + if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0) + TEST_ERROR + + /* Check up on B-tree */ + bt2_stat.depth = 2; + bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC * 74; + if(check_stats(bt2, &bt2_stat) < 0) + TEST_ERROR + record = 1889; /* Left record in root node */ + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) + TEST_ERROR + record = 3703; /* Right record in root node */ + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) + TEST_ERROR + record = 1952; /* Record to left of insertion point in middle internal node */ + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) + TEST_ERROR + record = 2884; /* Record to right of insertion point in middle internal node */ + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) + TEST_ERROR + record = 2822; /* Record just after insertion point in leaf node */ + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) + TEST_ERROR + + /* Insert records to fill up middle internal node */ + for(u = 0; u < ((INSERT_SPLIT_ROOT_NREC * 13) + ((3 * INSERT_SPLIT_ROOT_NREC) / 4) + 2); u++) { + record = u + (INSERT_SPLIT_ROOT_NREC * 31); + if(H5B2_insert(bt2, dxpl, &record) < 0) + FAIL_STACK_ERROR + } /* end for */ + + /* Check up on B-tree */ + bt2_stat.depth = 2; + bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC * 87) + ((3 * INSERT_SPLIT_ROOT_NREC) / 4) + 2; + if(check_stats(bt2, &bt2_stat) < 0) + TEST_ERROR + record = 1889; /* Left record in root node */ + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) + TEST_ERROR + record = 3703; /* Right record in root node */ + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) + TEST_ERROR + record = 2789; /* Record to left of insertion point in middle internal node */ + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) + TEST_ERROR + record = 2822; /* Record to right of insertion point in middle internal node */ + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) + TEST_ERROR + record = 2823; /* Record just above insertion point in leaf node */ + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) + TEST_ERROR + + /* Check for closing & re-opening the B-tree */ + if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0) + TEST_ERROR + + /* Insert record to split middle internal node */ + record = u + (INSERT_SPLIT_ROOT_NREC * 31); + if(H5B2_insert(bt2, dxpl, &record) < 0) + FAIL_STACK_ERROR + + /* Check up on B-tree */ + bt2_stat.depth = 2; + bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC * 87) + ((3 * INSERT_SPLIT_ROOT_NREC) / 4) + 3; + if(check_stats(bt2, &bt2_stat) < 0) + TEST_ERROR + record = 1889; /* Left record in root node */ + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) + TEST_ERROR + record = 2789; /* Middle record in root node */ + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) + TEST_ERROR + record = 3703; /* Right record in root node */ + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) + TEST_ERROR +#ifdef NONE + record = 3049; /* Record to left of insertion point in middle internal node */ + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) + TEST_ERROR +#endif /* NONE */ + record = 2822; /* Record to right of insertion point in middle internal node */ + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) + TEST_ERROR + record = 2823; /* Record just above insertion point in leaf node */ + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) + TEST_ERROR + + /* Check for closing & re-opening the B-tree */ + if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0) + TEST_ERROR + + /* Iterate over B-tree to check records have been inserted correctly */ + idx = 0; + if(H5B2_iterate(bt2, dxpl, iter_cb, &idx) < 0) + FAIL_STACK_ERROR + + /* Make certain that the index is correct */ + if(idx != ((INSERT_SPLIT_ROOT_NREC * 87) + ((3 * INSERT_SPLIT_ROOT_NREC) / 4) + 3)) + TEST_ERROR + + /* Close the v2 B-tree */ + if(H5B2_close(bt2, dxpl) < 0) + FAIL_STACK_ERROR + bt2 = NULL; + + /* Close file */ + if(H5Fclose(file) < 0) + FAIL_STACK_ERROR + + PASSED(); + + return 0; + +error: + H5E_BEGIN_TRY { + if(bt2) + H5B2_close(bt2, dxpl); + H5Fclose(file); + } H5E_END_TRY; + return 1; +} /* test_insert_level2_3internal_split() */ + + +/*------------------------------------------------------------------------- + * Function: test_insert_lots + * + * Purpose: Basic tests for the B-tree v2 code. This test inserts many + * records in random order, enough to make at a level 4 B-tree. + * + * Return: Success: 0 + * + * Failure: 1 + * + * Programmer: Quincey Koziol + * Saturday, February 19, 2005 + * + *------------------------------------------------------------------------- + */ +static unsigned +test_insert_lots(hid_t fapl, const H5B2_create_t *cparam, + const bt2_test_param_t *tparam) +{ + hid_t file = -1; /* File ID */ + char filename[1024]; /* Filename to use */ + H5F_t *f = NULL; /* Internal file object pointer */ + hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ + H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ + haddr_t bt2_addr; /* Address of B-tree created */ + hsize_t record; /* Record to insert into tree */ + hsize_t idx; /* Index within B-tree, for iterator */ + time_t curr_time; /* Current time, for seeding random number generator */ + hsize_t *records; /* Record #'s for random insertion */ + unsigned u; /* Local index variable */ + unsigned swap_idx; /* Location to swap with when shuffling */ + hsize_t temp_rec; /* Temporary record */ + H5B2_stat_t bt2_stat; /* Statistics about B-tree created */ + hsize_t nrec; /* Number of records in B-tree */ + herr_t ret; /* Generic error return value */ + + /* Initialize random number seed */ + curr_time=HDtime(NULL); +#ifdef QAK +curr_time=1109170019; +HDfprintf(stderr,"curr_time=%lu\n",(unsigned long)curr_time); +#endif /* QAK */ + HDsrandom((unsigned)curr_time); + + /* + * Test inserting many records into v2 B-tree + */ + TESTING("B-tree insert: create random level 4 B-tree"); + + /* Allocate space for the records */ + if(NULL == (records = (hsize_t *)HDmalloc(sizeof(hsize_t) * INSERT_MANY))) + TEST_ERROR + + /* Initialize record #'s */ + for(u = 0; u < INSERT_MANY; u++) + records[u] = u; + + /* Shuffle record #'s */ + for(u = 0; u < INSERT_MANY; u++) { + swap_idx = ((unsigned)HDrandom() % (INSERT_MANY - u)) + u; + temp_rec = records[u]; + records[u] = records[swap_idx]; + records[swap_idx] = temp_rec; + } /* end for */ + + /* Set the filename to use for this test (dependent on fapl) */ + h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); + + /* Create the file to work on */ + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + + /* Get a pointer to the internal file object */ + if(NULL == (f = (H5F_t *)H5I_object(file))) + STACK_ERROR + + /* Ignore metadata tags in the file's cache */ + if(H5AC_ignore_tags(f) < 0) + STACK_ERROR + + /* Create the v2 B-tree & get its address */ + if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0) + TEST_ERROR + + /* Insert random records */ + for(u = 0; u < INSERT_MANY; u++) { + record = records[u]; + if(H5B2_insert(bt2, dxpl, &record) < 0) + FAIL_STACK_ERROR + } /* end for */ + + /* Check up on B-tree */ + bt2_stat.depth = 4; + bt2_stat.nrecords = INSERT_MANY; + if(check_stats(bt2, &bt2_stat) < 0) + TEST_ERROR + + /* Close the v2 B-tree */ + if(H5B2_close(bt2, dxpl) < 0) + FAIL_STACK_ERROR + bt2 = NULL; + + /* Close file */ + if(H5Fclose(file) < 0) + STACK_ERROR + + /* Re-open the file */ + if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR + + /* Get a pointer to the internal file object */ + if(NULL == (f = (H5F_t *)H5I_object(file))) + FAIL_STACK_ERROR + + /* Ignore metadata tags in the file's cache */ + if(H5AC_ignore_tags(f) < 0) + STACK_ERROR + + /* Re-open v2 B-tree */ + if(NULL == (bt2 = H5B2_open(f, dxpl, bt2_addr, f))) + FAIL_STACK_ERROR + + /* Check up on B-tree after re-open */ + bt2_stat.depth = 4; + bt2_stat.nrecords = INSERT_MANY; + if(check_stats(bt2, &bt2_stat) < 0) + TEST_ERROR + + /* Iterate over B-tree to check records have been inserted correctly */ + idx = 0; + if(H5B2_iterate(bt2, dxpl, iter_cb, &idx) < 0) + FAIL_STACK_ERROR + + /* Make certain that the index is correct */ + if(idx != INSERT_MANY) + TEST_ERROR + + /* Attempt to find non-existant record in level-4 B-tree */ + /* (Should not be found, but not fail) */ + idx = INSERT_MANY * 2; + if(H5B2_find(bt2, dxpl, &idx, find_cb, &idx) != FALSE) + TEST_ERROR + + /* Find random records */ + for(u = 0; u < FIND_MANY; u++) { + /* Pick random record */ + idx = (hsize_t)(HDrandom()%INSERT_MANY); + + /* Attempt to find existant record in root of level-4 B-tree */ + if(H5B2_find(bt2, dxpl, &idx, find_cb, &idx) != TRUE) + FAIL_STACK_ERROR + } /* end for */ + + /* Attempt to index non-existant record in level-4 B-tree, in increasing & decreasing order */ + H5E_BEGIN_TRY { + ret = H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)(INSERT_MANY*3), find_cb, NULL); + } H5E_END_TRY; + /* Should fail */ + if(ret != FAIL) + TEST_ERROR + H5E_BEGIN_TRY { + ret = H5B2_index(bt2, dxpl, H5_ITER_DEC, (hsize_t)(INSERT_MANY*3), find_cb, NULL); + } H5E_END_TRY; + /* Should fail */ + if(ret != FAIL) + TEST_ERROR + + /* Find random records */ + for(u = 0; u < FIND_MANY; u++) { + /* Pick random record */ + idx = (hsize_t)(HDrandom() % INSERT_MANY); + + /* Attempt to find existant record in root of level-4 B-tree */ + /* (in increasing order) */ + if(H5B2_index(bt2, dxpl, H5_ITER_INC, idx, find_cb, &idx) < 0) + FAIL_STACK_ERROR + + /* Attempt to find existant record in root of level-4 B-tree */ + /* (in decreasing order) */ + if(H5B2_index(bt2, dxpl, H5_ITER_DEC, idx, find_dec_cb, &idx) < 0) + FAIL_STACK_ERROR + } /* end for */ + + PASSED(); + + TESTING("B-tree insert: attempt duplicate record in level 4 B-tree"); + + /* Check for closing & re-opening the B-tree */ + if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0) + TEST_ERROR + + record = INSERT_MANY / 2; + H5E_BEGIN_TRY { + ret = H5B2_insert(bt2, dxpl, &record); + } H5E_END_TRY; + /* Should fail */ + if(ret != FAIL) + TEST_ERROR + + /* Query the number of records in the B-tree */ + if(H5B2_get_nrec(bt2, &nrec) < 0) + FAIL_STACK_ERROR + + /* Make certain that the # of records is correct */ + if(nrec != INSERT_MANY) + TEST_ERROR + + /* Close the v2 B-tree */ + if(H5B2_close(bt2, dxpl) < 0) + FAIL_STACK_ERROR + bt2 = NULL; + + /* Close file */ + if(H5Fclose(file) < 0) + TEST_ERROR + + PASSED(); + + HDfree(records); + + return 0; + +error: + H5E_BEGIN_TRY { + if(bt2) + H5B2_close(bt2, dxpl); + H5Fclose(file); + } H5E_END_TRY; + HDfree(records); + return 1; +} /* test_insert_lots() */ + + +/*------------------------------------------------------------------------- + * Function: test_update_basic + * + * Purpose: Basic tests for the v2 B-tree update operation + * + * Return: Success: 0 + * Failure: 1 + * + * Programmer: Quincey Koziol + * Wednesday, December 23, 2015 + * + *------------------------------------------------------------------------- + */ +static unsigned +test_update_basic(hid_t fapl, const H5B2_create_t *cparam, + const bt2_test_param_t *tparam) +{ + hid_t file = -1; /* File ID */ + H5F_t *f = NULL; /* Internal file object pointer */ + hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ + H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ + haddr_t bt2_addr; /* Address of B-tree created */ + H5B2_test_rec_t record; /* Record to insert into tree */ + H5B2_test_rec_t modify; /* Modified value */ + H5B2_test_rec_t find; /* Record to find */ + herr_t ret; /* Generic error return value */ + + /* Create the file for the test */ + if(create_file(&file, &f, fapl) < 0) + TEST_ERROR + + /* Create the v2 B-tree & get its address */ + if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0) + TEST_ERROR + + /* + * Test insert record into empty v2 B-tree + */ + TESTING("B-tree update: inserting first record in empty B-tree"); + + /* Check for closing & re-opening the B-tree */ + if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0) + TEST_ERROR + + record.key = 42; + record.val = 72; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + + /* Attempt to find non-existant record in B-tree with 1 record */ + /* (Should not be found, but not fail) */ + find.key = 10; + find.val = (hsize_t)-1; + if(H5B2_find(bt2, dxpl, &find, find_rec_cb, &find) != FALSE) + FAIL_STACK_ERROR + if(find.val != (hsize_t)-1) + TEST_ERROR + + /* Try again with NULL 'op' */ + /* (Should not be found, but not fail) */ + if(H5B2_find(bt2, dxpl, &find, NULL, NULL) != FALSE) + FAIL_STACK_ERROR + if(find.val != (hsize_t)-1) + TEST_ERROR + + /* Attempt to find existant record in B-tree with 1 record */ + find.key = 42; + if(H5B2_find(bt2, dxpl, &find, find_rec_cb, &find) != TRUE) + FAIL_STACK_ERROR + if(find.val != 72) + TEST_ERROR + + /* Try again with NULL 'op' */ + find.val = (hsize_t)-1; + if(H5B2_find(bt2, dxpl, &find, NULL, NULL) != TRUE) + FAIL_STACK_ERROR + if(find.val != (hsize_t)-1) + TEST_ERROR + + /* Attempt to index non-existant record in B-tree with 1 record */ + H5E_BEGIN_TRY { + ret = H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)1, index_rec_cb, NULL); + } H5E_END_TRY; + /* Should fail */ + if(ret != FAIL) + TEST_ERROR + + /* Attempt to index existing record in B-tree with 1 record */ + find.key = (hsize_t)-1; + if(H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)0, index_rec_cb, &find) < 0) + FAIL_STACK_ERROR + if(find.key != 42) + TEST_ERROR + if(find.val != 72) + TEST_ERROR + + PASSED(); + + + /* + * Test update only record into v2 B-tree + */ + TESTING("B-tree update: update only record in B-tree"); + + /* Check for closing & re-opening the B-tree */ + if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0) + TEST_ERROR + + modify.key = 42; + modify.val = 43; + if(H5B2_update(bt2, dxpl, &modify, modify_rec_cb, &modify) < 0) + FAIL_STACK_ERROR + + /* Attempt to find non-existant record in B-tree with 1 record */ + /* (Should not be found, but not fail) */ + find.key = 10; + find.val = (hsize_t)-1; + if(H5B2_find(bt2, dxpl, &find, find_rec_cb, &find) != FALSE) + FAIL_STACK_ERROR + if(find.val != (hsize_t)-1) + TEST_ERROR + + /* Try again with NULL 'op' */ + /* (Should not be found, but not fail) */ + if(H5B2_find(bt2, dxpl, &find, NULL, NULL) != FALSE) + FAIL_STACK_ERROR + if(find.val != (hsize_t)-1) + TEST_ERROR + + /* Attempt to find modified record in B-tree with 1 record */ + find.key = 42; + if(H5B2_find(bt2, dxpl, &find, find_rec_cb, &find) != TRUE) + FAIL_STACK_ERROR + if(find.val != 43) + TEST_ERROR + + /* Try again with NULL 'op' */ + find.val = (hsize_t)-1; + if(H5B2_find(bt2, dxpl, &find, NULL, NULL) != TRUE) + FAIL_STACK_ERROR + if(find.val != (hsize_t)-1) + TEST_ERROR + + /* Attempt to index non-existant record in B-tree with 1 record */ + H5E_BEGIN_TRY { + ret = H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)1, index_rec_cb, NULL); + } H5E_END_TRY; + /* Should fail */ + if(ret != FAIL) + TEST_ERROR + + /* Attempt to index existing record in B-tree with 1 record */ + find.key = (hsize_t)-1; + find.val = (hsize_t)-1; + if(H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)0, index_rec_cb, &find) < 0) + FAIL_STACK_ERROR + if(find.key != 42) + TEST_ERROR + if(find.val != 43) + TEST_ERROR + + PASSED(); + + + /* + * Test inserting more records into v2 B-tree + */ + TESTING("B-tree update: insert several records"); + + /* Check for closing & re-opening the B-tree */ + if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0) + TEST_ERROR + + /* + * Test inserting second record into v2 B-tree, before all other records + */ + record.key = 34; + record.val = 11; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + + /* + * Test inserting third record into v2 B-tree, after all other records + */ + record.key = 56; + record.val = 12; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + + /* + * Test inserting fourth record into v2 B-tree, in the middle of other records + */ + record.key = 38; + record.val = 13; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + + /* Attempt to find non-existant record in level-0 B-tree with several records */ + /* (Should not be found, but not fail) */ + find.key = 10; + find.val = (hsize_t)-1; + if(H5B2_find(bt2, dxpl, &find, find_rec_cb, &find) != FALSE) + TEST_ERROR + if(find.val != (hsize_t)-1) + TEST_ERROR + + /* Attempt to find existant record in level-0 B-tree with several records */ + find.key = 56; + if(H5B2_find(bt2, dxpl, &find, find_rec_cb, &find) != TRUE) + TEST_ERROR + if(find.val != 12) + TEST_ERROR + + /* Attempt to index non-existant record in B-tree with several records */ + H5E_BEGIN_TRY { + ret = H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)4, index_rec_cb, NULL); + } H5E_END_TRY; + /* Should fail */ + if(ret != FAIL) + TEST_ERROR + + /* Attempt to index existing record in B-tree with several records */ + find.key = (hsize_t)-1; + find.val = (hsize_t)-1; + if(H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)0, index_rec_cb, &find) < 0) + TEST_ERROR + if(find.key != 34) + TEST_ERROR + if(find.val != 11) + TEST_ERROR + find.key = (hsize_t)-1; + find.val = (hsize_t)-1; + if(H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)1, index_rec_cb, &find) < 0) + TEST_ERROR + if(find.key != 38) + TEST_ERROR + if(find.val != 13) + TEST_ERROR + find.key = (hsize_t)-1; + find.val = (hsize_t)-1; + if(H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)2, index_rec_cb, &find) < 0) + TEST_ERROR + if(find.key != 42) + TEST_ERROR + if(find.val != 43) + TEST_ERROR + find.key = (hsize_t)-1; + find.val = (hsize_t)-1; + if(H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)3, index_rec_cb, &find) < 0) + TEST_ERROR + if(find.key != 56) + TEST_ERROR + if(find.val != 12) + TEST_ERROR + + PASSED(); + + + /* + * Test updating all existing records in v2 B-tree + */ + TESTING("B-tree update: update several records"); + + record.key = 34; + modify.key = 34; + modify.val = 21; + if(H5B2_update(bt2, dxpl, &record, modify_rec_cb, &modify) < 0) + FAIL_STACK_ERROR + record.key = 38; + modify.key = 38; + modify.val = 23; + if(H5B2_update(bt2, dxpl, &record, modify_rec_cb, &modify) < 0) + FAIL_STACK_ERROR + record.key = 42; + modify.key = 42; + modify.val = 24; + if(H5B2_update(bt2, dxpl, &record, modify_rec_cb, &modify) < 0) + FAIL_STACK_ERROR + record.key = 56; + modify.key = 56; + modify.val = 22; + if(H5B2_update(bt2, dxpl, &record, modify_rec_cb, &modify) < 0) + FAIL_STACK_ERROR + + /* Attempt to find non-existant record in level-0 B-tree with several records */ + /* (Should not be found, but not fail) */ + find.key = 41; + find.val = (hsize_t)-1; + if(H5B2_find(bt2, dxpl, &find, find_rec_cb, &find) != FALSE) + TEST_ERROR + if(find.val != (hsize_t)-1) + TEST_ERROR + + /* Attempt to find existant record in level-0 B-tree with several record */ + find.key = 56; + if(H5B2_find(bt2, dxpl, &find, find_rec_cb, &find) != TRUE) + TEST_ERROR + if(find.val != 22) + TEST_ERROR + + /* Attempt to index non-existant record in B-tree with several records */ + H5E_BEGIN_TRY { + ret = H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)4, index_rec_cb, NULL); + } H5E_END_TRY; + /* Should fail */ + if(ret != FAIL) + TEST_ERROR + + /* Attempt to index existing record in B-tree with several records */ + find.key = (hsize_t)-1; + find.val = (hsize_t)-1; + if(H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)0, index_rec_cb, &find) < 0) + TEST_ERROR + if(find.key != 34) + TEST_ERROR + if(find.val != 21) + TEST_ERROR + find.key = (hsize_t)-1; + find.val = (hsize_t)-1; + if(H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)1, index_rec_cb, &find) < 0) + TEST_ERROR + if(find.key != 38) + TEST_ERROR + if(find.val != 23) + TEST_ERROR + find.key = (hsize_t)-1; + find.val = (hsize_t)-1; + if(H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)2, index_rec_cb, &find) < 0) + TEST_ERROR + if(find.key != 42) + TEST_ERROR + if(find.val != 24) + TEST_ERROR + find.key = (hsize_t)-1; + find.val = (hsize_t)-1; + if(H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)3, index_rec_cb, &find) < 0) + TEST_ERROR + if(find.key != 56) + TEST_ERROR + if(find.val != 22) + TEST_ERROR + + /* Close the v2 B-tree */ + if(H5B2_close(bt2, dxpl) < 0) + FAIL_STACK_ERROR + bt2 = NULL; + + /* Close the file */ + if(H5Fclose(file) < 0) + TEST_ERROR + + PASSED(); + + + /* All tests passed */ + return(0); + +error: + H5E_BEGIN_TRY { + if(bt2) + H5B2_close(bt2, dxpl); + H5Fclose(file); + } H5E_END_TRY; + return(1); +} /* test_update_basic() */ + + +/*------------------------------------------------------------------------- + * Function: test_update_split_root + * + * Purpose: Basic tests for the B-tree v2 code. This test inserts enough + * records to split the root node and force the tree to depth 1. + * It also continues to add a few more records to each of the + * left and right leaf nodes after the split + * + * Return: Success: 0 + * Failure: 1 + * + * Programmer: Quincey Koziol + * Wednesday, December 23, 2015 + * + *------------------------------------------------------------------------- + */ +static unsigned +test_update_split_root(hid_t fapl, const H5B2_create_t *cparam, + const bt2_test_param_t *tparam) +{ + hid_t file = -1; /* File ID */ + H5F_t *f = NULL; /* Internal file object pointer */ + hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ + H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ + haddr_t bt2_addr; /* Address of B-tree created */ + H5B2_test_rec_t record; /* Record to insert into tree */ + H5B2_test_rec_t modify; /* Modified value */ + H5B2_test_rec_t find; /* Record to find */ + H5B2_test_rec_t idx; /* Index within B-tree, for iterator */ + H5B2_stat_t bt2_stat; /* Statistics about B-tree created */ + unsigned u; /* Local index variable */ + herr_t ret; /* Generic error return value */ + + /* + * Test inserting enough records into v2 B-tree to split the root node + */ + TESTING("B-tree update: split root"); + + /* Create the file for the test */ + if(create_file(&file, &f, fapl) < 0) + TEST_ERROR + + /* Create the v2 B-tree & get its address */ + if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0) + TEST_ERROR + + /* Insert records to fill root leaf node */ + for(u = 0; u < (INSERT_SPLIT_ROOT_NREC_REC - 1); u++) { + record.key = u + 2; + record.val = u * 2 + 4; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + } /* end for */ + + /* Check up on B-tree */ + bt2_stat.depth = 0; + bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC_REC - 1); + if(check_stats(bt2, &bt2_stat) < 0) + TEST_ERROR + record.key = 33; + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) + TEST_ERROR + + /* Check for closing & re-opening the B-tree */ + if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0) + TEST_ERROR + + /* Insert record to split root leaf node */ + record.key = INSERT_SPLIT_ROOT_NREC_REC + 1; + record.val = (INSERT_SPLIT_ROOT_NREC_REC - 1) * 2 + 4; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + + /* Check up on B-tree */ + bt2_stat.depth = 1; + bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC_REC; + if(check_stats(bt2, &bt2_stat) < 0) + TEST_ERROR + record.key = 33; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) + TEST_ERROR + + /* Iterate over B-tree to check records have been inserted correctly */ + idx.key = 2; + idx.val = 4; + if(H5B2_iterate(bt2, dxpl, iter_rec_cb, &idx) < 0) + FAIL_STACK_ERROR + + /* Make certain that the index is correct */ + if(idx.key != (INSERT_SPLIT_ROOT_NREC_REC + 2)) + TEST_ERROR + + /* Check for closing & re-opening the B-tree */ + if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0) + TEST_ERROR + + /* Modify all records */ + for(u = 0; u < INSERT_SPLIT_ROOT_NREC_REC; u++) { + record.key = u + 2; + modify.key = u + 2; + modify.val = u * 2 + 5; + if(H5B2_update(bt2, dxpl, &record, modify_rec_cb, &modify) < 0) + FAIL_STACK_ERROR + } /* end for */ + + /* Check up on B-tree */ + bt2_stat.depth = 1; + bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC_REC; + if(check_stats(bt2, &bt2_stat) < 0) + TEST_ERROR + record.key = 33; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) + TEST_ERROR + + /* Iterate over B-tree to check records have been inserted correctly */ + idx.key = 2; + idx.val = 5; + if(H5B2_iterate(bt2, dxpl, iter_rec_cb, &idx) < 0) + FAIL_STACK_ERROR + + /* Make certain that the index is correct */ + if(idx.key != (INSERT_SPLIT_ROOT_NREC_REC + 2)) + TEST_ERROR + + + /* Check for closing & re-opening the B-tree */ + if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0) + TEST_ERROR + + /* Insert a couple more records, on the left side of the B-tree */ + record.key = 0; + record.val = 1; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + record.key = 1; + record.val = 3; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + + /* Check up on B-tree */ + bt2_stat.depth = 1; + bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC_REC + 2); + if(check_stats(bt2, &bt2_stat) < 0) + TEST_ERROR + record.key = 33; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) + TEST_ERROR + + /* Check for closing & re-opening the B-tree */ + if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0) + TEST_ERROR + + + /* Iterate over B-tree to check records have been inserted correctly */ + idx.key = 0; + idx.val = 1; + if(H5B2_iterate(bt2, dxpl, iter_rec_cb, &idx) < 0) + FAIL_STACK_ERROR + + /* Make certain that the index is correct */ + if(idx.key != (INSERT_SPLIT_ROOT_NREC_REC + 2)) + TEST_ERROR + + /* Attempt to find non-existant record in level-1 B-tree */ + /* (Should not be found, but not fail) */ + find.key = 800; + find.val = (hsize_t)-1; + if(H5B2_find(bt2, dxpl, &find, find_rec_cb, &find) != FALSE) + TEST_ERROR + if(find.val != (hsize_t)-1) + TEST_ERROR + + /* Attempt to find existant record in root of level-1 B-tree */ + find.key = 33; + find.val = (hsize_t)-1; + if(H5B2_find(bt2, dxpl, &find, find_rec_cb, &find) != TRUE) + FAIL_STACK_ERROR + if(find.key != 33) + TEST_ERROR + if(find.val != 67) + TEST_ERROR + + /* Attempt to find existant record in leaf of level-1 B-tree */ + find.key = 56; + find.val = (hsize_t)-1; + if(H5B2_find(bt2, dxpl, &find, find_rec_cb, &find) != TRUE) + FAIL_STACK_ERROR + if(find.key != 56) + TEST_ERROR + if(find.val != 113) + TEST_ERROR + + /* Attempt to index non-existant record in level-1 B-tree */ + H5E_BEGIN_TRY { + ret = H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)(INSERT_SPLIT_ROOT_NREC_REC + 2), index_rec_cb, NULL); + } H5E_END_TRY; + /* Should fail */ + if(ret != FAIL) + TEST_ERROR + + /* Attempt to index existing record in root of level-1 B-tree */ + find.key = (hsize_t)-1; + find.val = (hsize_t)-1; + if(H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)33, index_rec_cb, &find) < 0) + FAIL_STACK_ERROR + if(find.key != 33) + TEST_ERROR + if(find.val != 67) + TEST_ERROR + + /* Attempt to index existing record in left leaf of level-1 B-tree */ + find.key = (hsize_t)-1; + find.val = (hsize_t)-1; + if(H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)0, index_rec_cb, &find) < 0) + FAIL_STACK_ERROR + if(find.key != 0) + TEST_ERROR + if(find.val != 1) + TEST_ERROR + + /* Attempt to index existing record in right leaf of level-1 B-tree */ + find.key = (hsize_t)-1; + find.val = (hsize_t)-1; + if(H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)50, index_rec_cb, &find) < 0) + FAIL_STACK_ERROR + if(find.key != 50) + TEST_ERROR + if(find.val != 101) + TEST_ERROR + + /* Close the v2 B-tree */ + if(H5B2_close(bt2, dxpl) < 0) + FAIL_STACK_ERROR + bt2 = NULL; + + if(H5Fclose(file) < 0) + TEST_ERROR + + PASSED(); + + return 0; + +error: + H5E_BEGIN_TRY { + if(bt2) + H5B2_close(bt2, dxpl); + H5Fclose(file); + } H5E_END_TRY; + return 1; +} /* test_update_split_root() */ + + +/*------------------------------------------------------------------------- + * Function: test_update_level1_2leaf_redistrib + * + * Purpose: Basic tests for the B-tree v2 code. This test inserts enough + * records to split the root node and force the tree to depth 1. + * It continues to add a more records to the each of the + * left and right leaf nodes after the split to force a 2 node + * redistribution + * + * Return: Success: 0 + * Failure: 1 + * + * Programmer: Quincey Koziol + * Saturday, December 26, 2015 + * + *------------------------------------------------------------------------- + */ +static unsigned +test_update_level1_2leaf_redistrib(hid_t fapl, const H5B2_create_t *cparam, + const bt2_test_param_t *tparam) +{ + hid_t file = -1; /* File ID */ + H5F_t *f = NULL; /* Internal file object pointer */ + hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ + H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ + haddr_t bt2_addr; /* Address of B-tree created */ + H5B2_test_rec_t record; /* Record to insert into tree */ + H5B2_stat_t bt2_stat; /* Statistics about B-tree created */ + unsigned u; /* Local index variable */ + + /* + * Test inserting many records into v2 B-tree + */ + TESTING("B-tree update: redistribute 2 leaves in level 1 B-tree (l->r)"); + + /* Create the file for the test */ + if(create_file(&file, &f, fapl) < 0) + TEST_ERROR + + /* Create the v2 B-tree & get its address */ + if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0) + TEST_ERROR + + /* Insert enough records to force root to split into 2 leaves */ + for(u = 0; u < INSERT_SPLIT_ROOT_NREC_REC; u++) { + record.key = u + (INSERT_SPLIT_ROOT_NREC_REC / 2) + 1; + record.val = u + (INSERT_SPLIT_ROOT_NREC_REC / 2) + 10; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + } /* end for */ + + /* Check up on B-tree */ + bt2_stat.depth = 1; + bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC_REC; + if(check_stats(bt2, &bt2_stat) < 0) + TEST_ERROR + record.key = INSERT_SPLIT_ROOT_NREC_REC; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) + TEST_ERROR + + /* Check for closing & re-opening the B-tree */ + if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0) + TEST_ERROR + + + /* Force redistribution from left node into right node */ + for(u = 0; u < (INSERT_SPLIT_ROOT_NREC_REC / 2) + 1; u++) { + record.key = u; + record.val = u + 9; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + } /* end for */ + + /* Check up on B-tree */ + bt2_stat.depth = 1; + bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC_REC + (INSERT_SPLIT_ROOT_NREC_REC / 2) + 1); + if(check_stats(bt2, &bt2_stat) < 0) + TEST_ERROR + record.key = (INSERT_SPLIT_ROOT_NREC_REC / 2) + (INSERT_SPLIT_ROOT_NREC_REC / 4); + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) + TEST_ERROR + + /* Close the v2 B-tree */ + if(H5B2_close(bt2, dxpl) < 0) + FAIL_STACK_ERROR + bt2 = NULL; + + PASSED(); + + /* + * Test inserting many records into v2 B-tree + */ + TESTING("B-tree update: redistribute 2 leaves in level 1 B-tree (r->l)"); + + /* Create the v2 B-tree & get its address */ + if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0) + TEST_ERROR + + /* Insert enough records to force root to split into 2 leaves */ + for(u = 0; u < INSERT_SPLIT_ROOT_NREC_REC; u++) { + record.key = u; + record.val = u + 9; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + } /* end for */ + + /* Check up on B-tree */ + bt2_stat.depth = 1; + bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC_REC; + if(check_stats(bt2, &bt2_stat) < 0) + TEST_ERROR + record.key = (INSERT_SPLIT_ROOT_NREC_REC / 2) - 1; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) + TEST_ERROR + + /* Check for closing & re-opening the B-tree */ + if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0) + TEST_ERROR + + /* Force redistribution from left node into right node */ + for(u = 0; u < (INSERT_SPLIT_ROOT_NREC_REC / 2) + 1; u++) { + record.key = u + INSERT_SPLIT_ROOT_NREC_REC; + record.val = u + INSERT_SPLIT_ROOT_NREC_REC + 9; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + } /* end for */ + + /* Check up on B-tree */ + bt2_stat.depth = 1; + bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC_REC + (INSERT_SPLIT_ROOT_NREC_REC / 2) + 1; + if(check_stats(bt2, &bt2_stat) < 0) + TEST_ERROR + record.key = (INSERT_SPLIT_ROOT_NREC_REC / 2) + (INSERT_SPLIT_ROOT_NREC_REC / 4) - 1; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) + TEST_ERROR + + /* Close the v2 B-tree */ + if(H5B2_close(bt2, dxpl) < 0) + FAIL_STACK_ERROR + bt2 = NULL; + + /* Close file */ + if(H5Fclose(file) < 0) + FAIL_STACK_ERROR + + PASSED(); + + return 0; + +error: + H5E_BEGIN_TRY { + if(bt2) + H5B2_close(bt2, dxpl); + H5Fclose(file); + } H5E_END_TRY; + return 1; +} /* test_update_level1_2leaf_redistrib() */ + + +/*------------------------------------------------------------------------- + * Function: test_update_level1_side_split + * + * Purpose: Basic tests for the B-tree v2 code. This test inserts enough + * records to split the root node and force the tree to depth 1. + * It continues to add a more records to the each of the + * left and right leaf nodes after the split to force a 2 node + * split, adding another node to the B-tree + * + * Return: Success: 0 + * Failure: 1 + * + * Programmer: Quincey Koziol + * Saturday, December 26, 2015 + * + *------------------------------------------------------------------------- + */ +static unsigned +test_update_level1_side_split(hid_t fapl, const H5B2_create_t *cparam, + const bt2_test_param_t *tparam) +{ + hid_t file = -1; /* File ID */ + H5F_t *f = NULL; /* Internal file object pointer */ + hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ + H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ + haddr_t bt2_addr; /* Address of B-tree created */ + H5B2_test_rec_t record; /* Record to insert into tree */ + H5B2_stat_t bt2_stat; /* Statistics about B-tree created */ + unsigned u; /* Local index variable */ + + /* + * Test inserting many records into v2 B-tree + */ + TESTING("B-tree update: split side leaf into 2 leaves in level 1 B-tree (l->r)"); + + /* Create the file for the test */ + if(create_file(&file, &f, fapl) < 0) + TEST_ERROR + + /* Create the v2 B-tree & get its address */ + if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0) + TEST_ERROR + + /* Insert enough records to force root to split into 2 leaves */ + for(u = 0; u < INSERT_SPLIT_ROOT_NREC_REC; u++) { + record.key = u + INSERT_SPLIT_ROOT_NREC_REC; + record.val = u + INSERT_SPLIT_ROOT_NREC_REC + 10; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + } /* end for */ + + /* Check up on B-tree */ + bt2_stat.depth = 1; + bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC_REC; + if(check_stats(bt2, &bt2_stat) < 0) + TEST_ERROR + record.key = INSERT_SPLIT_ROOT_NREC_REC + (INSERT_SPLIT_ROOT_NREC_REC / 2) - 1; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) + TEST_ERROR + + /* Check for closing & re-opening the B-tree */ + if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0) + TEST_ERROR + + /* Force left node to split */ + for(u = 0; u < INSERT_SPLIT_ROOT_NREC_REC; u++) { + record.key = u; + record.val = u + 10; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + } /* end for */ + + /* Check up on B-tree */ + bt2_stat.depth = 1; + bt2_stat.nrecords = 2 * INSERT_SPLIT_ROOT_NREC_REC; + if(check_stats(bt2, &bt2_stat) < 0) + TEST_ERROR + record.key = 31; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) + TEST_ERROR + record.key = 64; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) + TEST_ERROR + + /* Close the v2 B-tree */ + if(H5B2_close(bt2, dxpl) < 0) + FAIL_STACK_ERROR + bt2 = NULL; + + PASSED(); + + /* + * Test inserting many records into v2 B-tree + */ + TESTING("B-tree update: split side leaf into 2 leaves in level 1 B-tree (r->l)"); + + /* Create the v2 B-tree & get its address */ + if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0) + TEST_ERROR + + /* Insert enough records to force root to split into 2 leaves */ + for(u = 0; u < INSERT_SPLIT_ROOT_NREC_REC; u++) { + record.key = u; + record.val = u + 10; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + } /* end for */ + + /* Check up on B-tree */ + bt2_stat.depth = 1; + bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC_REC; + if(check_stats(bt2, &bt2_stat) < 0) + TEST_ERROR + record.key = (INSERT_SPLIT_ROOT_NREC_REC / 2) - 1; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) + TEST_ERROR + + /* Check for closing & re-opening the B-tree */ + if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0) + TEST_ERROR + + /* Force right node to split */ + for(u = 0; u < INSERT_SPLIT_ROOT_NREC_REC; u++) { + record.key = u + INSERT_SPLIT_ROOT_NREC_REC; + record.val = u + INSERT_SPLIT_ROOT_NREC_REC + 10; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + } /* end for */ + + /* Check up on B-tree */ + bt2_stat.depth = 1; + bt2_stat.nrecords = 2 * INSERT_SPLIT_ROOT_NREC_REC; + if(check_stats(bt2, &bt2_stat) < 0) + TEST_ERROR + record.key = 63; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) + TEST_ERROR + record.key = 95; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) + TEST_ERROR + + /* Close the v2 B-tree */ + if(H5B2_close(bt2, dxpl) < 0) + FAIL_STACK_ERROR + bt2 = NULL; + + /* Close file */ + if(H5Fclose(file) < 0) + FAIL_STACK_ERROR + + PASSED(); + + return 0; + +error: + H5E_BEGIN_TRY { + if(bt2) + H5B2_close(bt2, dxpl); + H5Fclose(file); + } H5E_END_TRY; + return 1; +} /* test_update_level1_side_split() */ + + +/*------------------------------------------------------------------------- + * Function: test_update_level1_3leaf_redistrib + * + * Purpose: Basic tests for the B-tree v2 code. This test inserts enough + * records to split the root node and force the tree to depth 1. + * It continues to add a more records to the each of the + * left and right leaf nodes after the split to force a 2 node + * split, adding another node to the B-tree, then continues to + * add records until a 3 node redistribution occurs + * + * Return: Success: 0 + * + * Failure: 1 + * + * Programmer: Quincey Koziol + * Saturday, December 26, 2015 + * + *------------------------------------------------------------------------- + */ +static unsigned +test_update_level1_3leaf_redistrib(hid_t fapl, const H5B2_create_t *cparam, + const bt2_test_param_t *tparam) +{ + hid_t file = -1; /* File ID */ + H5F_t *f = NULL; /* Internal file object pointer */ + hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ + H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ + haddr_t bt2_addr; /* Address of B-tree created */ + H5B2_test_rec_t record; /* Record to insert into tree */ + H5B2_test_rec_t idx; /* Index within B-tree, for iterator */ + H5B2_stat_t bt2_stat; /* Statistics about B-tree created */ + unsigned u; /* Local index variable */ + + /* + * Test inserting many records into v2 B-tree + */ + TESTING("B-tree update: redistribute 3 leaves in level 1 B-tree"); + + /* Create the file for the test */ + if(create_file(&file, &f, fapl) < 0) + TEST_ERROR + + /* Create the v2 B-tree & get its address */ + if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0) + TEST_ERROR + + /* Insert enough records to force root to split into 2 leaves */ + for(u = 0; u < INSERT_SPLIT_ROOT_NREC_REC; u++) { + record.key = u + (INSERT_SPLIT_ROOT_NREC_REC + (INSERT_SPLIT_ROOT_NREC_REC / 2) + 1); + record.val = record.key * 2; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + } /* end for */ + + /* Check up on B-tree */ + bt2_stat.depth = 1; + bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC_REC; + if(check_stats(bt2, &bt2_stat) < 0) + TEST_ERROR + record.key = (2 * INSERT_SPLIT_ROOT_NREC_REC); + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) + TEST_ERROR + + /* Check for closing & re-opening the B-tree */ + if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0) + TEST_ERROR + + /* Force left node to split */ + for(u = 0; u < INSERT_SPLIT_ROOT_NREC_REC; u++) { + record.key = u; + record.val = record.key * 2; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + } /* end for */ + + /* Check up on B-tree */ + bt2_stat.depth = 1; + bt2_stat.nrecords = 2 * INSERT_SPLIT_ROOT_NREC_REC; + if(check_stats(bt2, &bt2_stat) < 0) + TEST_ERROR + record.key = (INSERT_SPLIT_ROOT_NREC_REC / 2) - 1; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) + TEST_ERROR + record.key = INSERT_SPLIT_ROOT_NREC_REC + (INSERT_SPLIT_ROOT_NREC_REC / 2) + 1; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) + TEST_ERROR + + /* Check for closing & re-opening the B-tree */ + if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0) + TEST_ERROR + + /* Insert records to force middle node to redistribute */ + for(u = 0; u < ((INSERT_SPLIT_ROOT_NREC_REC / 2) + 1); u++) { + record.key = u + INSERT_SPLIT_ROOT_NREC_REC; + record.val = record.key * 2; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + } /* end for */ + + /* Check up on B-tree */ + bt2_stat.depth = 1; + bt2_stat.nrecords = (2 * INSERT_SPLIT_ROOT_NREC_REC) + (INSERT_SPLIT_ROOT_NREC_REC / 2) + 1; + if(check_stats(bt2, &bt2_stat) < 0) + TEST_ERROR + record.key = 52; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) + TEST_ERROR + record.key = 107; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) + TEST_ERROR + + /* Check for closing & re-opening the B-tree */ + if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0) + TEST_ERROR + + /* Iterate over B-tree to check records have been inserted correctly */ + idx.key = 0; + idx.val = 0; + if(H5B2_iterate(bt2, dxpl, iter_rec_cb, &idx) < 0) + FAIL_STACK_ERROR + + /* Make certain that the index is correct */ + if(idx.key != ((INSERT_SPLIT_ROOT_NREC_REC * 2) + (INSERT_SPLIT_ROOT_NREC_REC / 2) + 1)) + TEST_ERROR + + /* Close the v2 B-tree */ + if(H5B2_close(bt2, dxpl) < 0) + FAIL_STACK_ERROR + bt2 = NULL; + + /* Close file */ + if(H5Fclose(file) < 0) + FAIL_STACK_ERROR + + PASSED(); + + return 0; + +error: + H5E_BEGIN_TRY { + if(bt2) + H5B2_close(bt2, dxpl); + H5Fclose(file); + } H5E_END_TRY; + return 1; +} /* test_update_level1_3leaf_redistrib() */ + + +/*------------------------------------------------------------------------- + * Function: test_update_level1_middle_split + * + * Purpose: Basic tests for the B-tree v2 code. This test inserts enough + * records to split the root node and force the tree to depth 1. + * It continues to add a more records to the each of the + * left and right leaf nodes after the split to force a 2 node + * split, adding another node to the B-tree, then continues to + * add records until a 3 node split occurs + * + * Return: Success: 0 + * Failure: 1 + * + * Programmer: Quincey Koziol + * Saturday, December 26, 2015 + * + *------------------------------------------------------------------------- + */ +static unsigned +test_update_level1_middle_split(hid_t fapl, const H5B2_create_t *cparam, + const bt2_test_param_t *tparam) +{ + hid_t file = -1; /* File ID */ + H5F_t *f = NULL; /* Internal file object pointer */ + hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ + H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ + haddr_t bt2_addr; /* Address of B-tree created */ + H5B2_test_rec_t record; /* Record to insert into tree */ + H5B2_stat_t bt2_stat; /* Statistics about B-tree created */ + H5B2_test_rec_t idx; /* Index within B-tree, for iterator */ + unsigned u; /* Local index variable */ + + /* + * Test inserting many records into v2 B-tree + */ + TESTING("B-tree update: split middle leaf into 2 leaves in level 1 B-tree"); + + /* Create the file for the test */ + if(create_file(&file, &f, fapl) < 0) + TEST_ERROR + + /* Create the v2 B-tree & get its address */ + if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0) + TEST_ERROR + + /* Insert enough records to force root to split into 2 leaves */ + for(u = 0; u < INSERT_SPLIT_ROOT_NREC_REC; u++) { + record.key = u + (INSERT_SPLIT_ROOT_NREC_REC * 2); + record.val = record.key * 2; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + } /* end for */ + + /* Check up on B-tree */ + bt2_stat.depth = 1; + bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC_REC; + if(check_stats(bt2, &bt2_stat) < 0) + TEST_ERROR + record.key = (2 * INSERT_SPLIT_ROOT_NREC_REC) + (INSERT_SPLIT_ROOT_NREC_REC / 2) - 1; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) + TEST_ERROR + + /* Check for closing & re-opening the B-tree */ + if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0) + TEST_ERROR + + /* Force split from left node into right node */ + for(u = 0; u < (INSERT_SPLIT_ROOT_NREC_REC * 2); u++) { + record.key = u; + record.val = record.key * 2; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + } /* end for */ + + /* Check up on B-tree */ + bt2_stat.depth = 1; + bt2_stat.nrecords = 3 * INSERT_SPLIT_ROOT_NREC_REC; + if(check_stats(bt2, &bt2_stat) < 0) + TEST_ERROR + record.key = 63; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) + TEST_ERROR + record.key = 95; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) + TEST_ERROR + record.key = 128; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) + TEST_ERROR + + /* Check for closing & re-opening the B-tree */ + if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0) + TEST_ERROR + + /* Iterate over B-tree to check records have been inserted correctly */ + idx.key = 0; + idx.val = 0; + if(H5B2_iterate(bt2, dxpl, iter_rec_cb, &idx) < 0) + FAIL_STACK_ERROR + + /* Make certain that the index is correct */ + if(idx.key != (INSERT_SPLIT_ROOT_NREC_REC * 3)) + TEST_ERROR + + /* Close the v2 B-tree */ + if(H5B2_close(bt2, dxpl) < 0) + FAIL_STACK_ERROR + bt2 = NULL; + + /* Close file */ + if(H5Fclose(file) < 0) + STACK_ERROR + + PASSED(); + + return 0; + +error: + H5E_BEGIN_TRY { + if(bt2) + H5B2_close(bt2, dxpl); + H5Fclose(file); + } H5E_END_TRY; + return 1; +} /* test_update_level1_middle_split() */ + + +/*------------------------------------------------------------------------- + * Function: test_update_make_level2 + * + * Purpose: Basic tests for the B-tree v2 code. This test inserts enough + * records to make a level 2 B-tree + * + * Return: Success: 0 + * Failure: 1 + * + * Programmer: Quincey Koziol + * Saturday, December 26, 2015 + * + *------------------------------------------------------------------------- + */ +static unsigned +test_update_make_level2(hid_t fapl, const H5B2_create_t *cparam, + const bt2_test_param_t *tparam) +{ + hid_t file = -1; /* File ID */ + H5F_t *f = NULL; /* Internal file object pointer */ + hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ + H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ + haddr_t bt2_addr; /* Address of B-tree created */ + H5B2_test_rec_t record; /* Record to insert into tree */ + H5B2_test_rec_t find; /* Record to find */ + H5B2_test_rec_t idx; /* Index within B-tree, for iterator */ + H5B2_stat_t bt2_stat; /* Statistics about B-tree created */ + unsigned u; /* Local index variable */ + herr_t ret; /* Generic error return value */ + + /* + * Test inserting many records into v2 B-tree + */ + TESTING("B-tree update: make level 2 B-tree (l->r)"); + + /* Create the file for the test */ + if(create_file(&file, &f, fapl) < 0) + TEST_ERROR + + /* Create the v2 B-tree & get its address */ + if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0) + TEST_ERROR + + /* Insert enough records to force root to split into 2 internal nodes */ + for(u = 0; u < (INSERT_SPLIT_ROOT_NREC_REC * 9); u++) { + record.key = u + 2; /* Leave a gap for later insertion */ + record.val = record.key * 2; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + } /* end for */ + for(; u < (INSERT_SPLIT_ROOT_NREC_REC * 41); u++) { + record.key = u + 4; /* Leave a gap for later insertion */ + record.val = record.key * 2; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + } /* end for */ + + /* Check up on B-tree */ + bt2_stat.depth = 2; + bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC_REC * 41); + if(check_stats(bt2, &bt2_stat) < 0) + TEST_ERROR + record.key = 1347; + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) + TEST_ERROR + + /* Check for closing & re-opening the B-tree */ + if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0) + TEST_ERROR + + /* Add some extra records to left-most leaf */ + record.key = 0; + record.val = record.key * 2; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + record.key = 1; + record.val = record.key * 2; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + + /* Add some extra records to middle leaf */ + record.key = (INSERT_SPLIT_ROOT_NREC_REC * 9) + 2; + record.val = record.key * 2; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + record.key = (INSERT_SPLIT_ROOT_NREC_REC * 9) + 3; + record.val = record.key * 2; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + + /* Check for closing & re-opening the B-tree */ + if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0) + TEST_ERROR + + + /* Iterate over B-tree to check records have been inserted correctly */ + idx.key = 0; + idx.val = 0; + if(H5B2_iterate(bt2, dxpl, iter_rec_cb, &idx) < 0) + FAIL_STACK_ERROR + + /* Make certain that the index is correct */ + if(idx.key != ((INSERT_SPLIT_ROOT_NREC_REC * 41) + 4)) + TEST_ERROR + + /* Attempt to find non-existant record in level-2 B-tree */ + /* (Should not be found, but not fail) */ + find.key = INSERT_SPLIT_ROOT_NREC_REC * 42; + find.val = (hsize_t)-1; + if(H5B2_find(bt2, dxpl, &find, find_rec_cb, &find) != FALSE) + TEST_ERROR + if(find.val != (hsize_t)-1) + TEST_ERROR + + /* Attempt to find existant record in root of level-2 B-tree */ + find.key = 1347; + find.val = (hsize_t)-1; + if(H5B2_find(bt2, dxpl, &find, find_rec_cb, &find) != TRUE) + FAIL_STACK_ERROR + if(find.val != (1347 * 2)) + TEST_ERROR + + /* Check with B-tree */ + record.key = 1347; + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) + TEST_ERROR + + /* Attempt to find existant record in internal node of level-2 B-tree */ + find.key = 513; + find.val = (hsize_t)-1; + if(H5B2_find(bt2, dxpl, &find, find_rec_cb, &find) != TRUE) + FAIL_STACK_ERROR + if(find.val != (513 * 2)) + TEST_ERROR + + /* Check with B-tree */ + record.key = 513; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) + TEST_ERROR + + /* Attempt to find existant record in leaf of level-2 B-tree */ + find.key = 555; + find.val = (hsize_t)-1; + if(H5B2_find(bt2, dxpl, &find, find_rec_cb, &find) != TRUE) + FAIL_STACK_ERROR + if(find.val != (555 * 2)) + TEST_ERROR + + /* Check with B-tree */ + record.key = 555; + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) + TEST_ERROR + + /* Attempt to index non-existant record in level-2 B-tree */ + H5E_BEGIN_TRY { + ret = H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)(INSERT_SPLIT_ROOT_NREC_REC * 42), index_rec_cb, NULL); + } H5E_END_TRY; + /* Should fail */ + if(ret != FAIL) + TEST_ERROR + + /* Attempt to index existing record in root of level-2 B-tree */ + find.key = (hsize_t)-1; + find.val = (hsize_t)-1; + if(H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)1347, index_rec_cb, &find) < 0) + FAIL_STACK_ERROR + if(find.key != 1347) + TEST_ERROR + if(find.val != (1347 * 2)) + TEST_ERROR + + /* Attempt to index existing record in internal node of level-2 B-tree */ + find.key = (hsize_t)-1; + find.val = (hsize_t)-1; + if(H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)513, index_rec_cb, &find) < 0) + FAIL_STACK_ERROR + if(find.key != 513) + TEST_ERROR + if(find.val != (513 * 2)) + TEST_ERROR + + /* Attempt to index existing record in leaf of level-2 B-tree */ + find.key = (hsize_t)-1; + find.val = (hsize_t)-1; + if(H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)555, index_rec_cb, &find) < 0) + FAIL_STACK_ERROR + if(find.key != 555) + TEST_ERROR + if(find.val != (555 * 2)) + TEST_ERROR + + /* Close the v2 B-tree */ + if(H5B2_close(bt2, dxpl) < 0) + FAIL_STACK_ERROR + bt2 = NULL; + + PASSED(); + + + /* + * Test inserting many records into v2 B-tree + */ + TESTING("B-tree update: make level 2 B-tree (r->l)"); + + /* Create the v2 B-tree & get its address */ + if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0) + TEST_ERROR + + /* Insert enough records to force root to split into 2 internal nodes */ + for(u = 0; u < (INSERT_SPLIT_ROOT_NREC_REC * 9); u++) { + record.key = ((INSERT_SPLIT_ROOT_NREC_REC * 41) + 1) - u; + record.val = record.key * 2; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + } /* end for */ + for(; u < (INSERT_SPLIT_ROOT_NREC_REC * 41); u++) { + record.key = ((INSERT_SPLIT_ROOT_NREC_REC * 41) + 1) - (u +2); /* Leave a gap for later insertion */ + record.val = record.key * 2; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + } /* end for */ + + /* Check up on B-tree */ + bt2_stat.depth = 2; + bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC_REC * 41); + if(check_stats(bt2, &bt2_stat) < 0) + TEST_ERROR + record.key = 1344; + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) + TEST_ERROR + + /* Check for closing & re-opening the B-tree */ + if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0) + TEST_ERROR + + /* Add some extra records to right-most leaf */ + record.key = (INSERT_SPLIT_ROOT_NREC_REC * 41) + 2; + record.val = record.key * 2; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + record.key = (INSERT_SPLIT_ROOT_NREC_REC * 41) + 3; + record.val = record.key * 2; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + + /* Add some extra records to middle leaf */ + record.key = ((INSERT_SPLIT_ROOT_NREC_REC * 41) - (INSERT_SPLIT_ROOT_NREC_REC * 9)); + record.val = record.key * 2; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + record.key = ((INSERT_SPLIT_ROOT_NREC_REC * 41) - (INSERT_SPLIT_ROOT_NREC_REC * 9)) + 1; + record.val = record.key * 2; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + + /* Check for closing & re-opening the B-tree */ + if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0) + TEST_ERROR + + + /* Iterate over B-tree to check records have been inserted correctly */ + idx.key = 0; + idx.val = 0; + if(H5B2_iterate(bt2, dxpl, iter_rec_cb, &idx) < 0) + FAIL_STACK_ERROR + + /* Make certain that the index is correct */ + if(idx.key != ((INSERT_SPLIT_ROOT_NREC_REC * 41) + 4)) + TEST_ERROR + + /* Attempt to find non-existant record in level-2 B-tree */ + /* (Should not be found, but not fail) */ + find.key = INSERT_SPLIT_ROOT_NREC_REC * 42; + find.val = (hsize_t)-1; + if(H5B2_find(bt2, dxpl, &find, find_rec_cb, &find) != FALSE) + TEST_ERROR + if(find.val != (hsize_t)-1) + TEST_ERROR + + /* Attempt to find existant record in root of level-2 B-tree */ + find.key = 1344; + find.val = (hsize_t)-1; + if(H5B2_find(bt2, dxpl, &find, find_rec_cb, &find) != TRUE) + FAIL_STACK_ERROR + if(find.val != (1344 * 2)) + TEST_ERROR + + /* Check with B-tree */ + record.key = 1344; + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) + TEST_ERROR + + /* Attempt to find existant record in internal node of level-2 B-tree */ + find.key = 512; + find.val = (hsize_t)-1; + if(H5B2_find(bt2, dxpl, &find, find_rec_cb, &find) != TRUE) + FAIL_STACK_ERROR + if(find.val != (512 * 2)) TEST_ERROR - /* Create the v2 B-tree & get its address */ - if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0) + /* Check with B-tree */ + record.key = 512; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR - /* Insert enough records to force root to split into 3 internal nodes */ - /* (and fill right internal node) */ - for(u = 0; u < (INSERT_SPLIT_ROOT_NREC * 31); u++) { - record = u; - if(H5B2_insert(bt2, dxpl, &record) < 0) - FAIL_STACK_ERROR - } /* end for */ - for(; u < (INSERT_SPLIT_ROOT_NREC * 74); u++) { - record = u + ((INSERT_SPLIT_ROOT_NREC * 13) + ((3 * INSERT_SPLIT_ROOT_NREC) / 4) + 3); - if(H5B2_insert(bt2, dxpl, &record) < 0) - FAIL_STACK_ERROR - } /* end for */ + /* Attempt to find existant record in leaf of level-2 B-tree */ + find.key = 555; + find.val = (hsize_t)-1; + if(H5B2_find(bt2, dxpl, &find, find_rec_cb, &find) != TRUE) + FAIL_STACK_ERROR + if(find.val != (555 * 2)) + TEST_ERROR - /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0) + /* Check with B-tree */ + record.key = 555; + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) TEST_ERROR - /* Check up on B-tree */ - bt2_stat.depth = 2; - bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC * 74; - if(check_stats(bt2, &bt2_stat) < 0) + /* Attempt to index non-existant record in level-2 B-tree */ + H5E_BEGIN_TRY { + ret = H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)(INSERT_SPLIT_ROOT_NREC_REC * 42), index_rec_cb, NULL); + } H5E_END_TRY; + /* Should fail */ + if(ret != FAIL) TEST_ERROR - record = 1889; /* Left record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + + /* Attempt to index existing record in root of level-2 B-tree */ + find.key = (hsize_t)-1; + find.val = (hsize_t)-1; + if(H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)1344, index_rec_cb, &find) < 0) + FAIL_STACK_ERROR + if(find.key != 1344) TEST_ERROR - record = 3703; /* Right record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + if(find.val != (1344 * 2)) TEST_ERROR - record = 1952; /* Record to left of insertion point in middle internal node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + + /* Attempt to index existing record in internal node of level-2 B-tree */ + find.key = (hsize_t)-1; + find.val = (hsize_t)-1; + if(H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)512, index_rec_cb, &find) < 0) + FAIL_STACK_ERROR + if(find.key != 512) TEST_ERROR - record = 2884; /* Record to right of insertion point in middle internal node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(find.val != (512 * 2)) TEST_ERROR - record = 2822; /* Record just after insertion point in leaf node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0) + + /* Attempt to index existing record in leaf of level-2 B-tree */ + find.key = (hsize_t)-1; + find.val = (hsize_t)-1; + if(H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)555, index_rec_cb, &find) < 0) + FAIL_STACK_ERROR + if(find.key != 555) + TEST_ERROR + if(find.val != (555 * 2)) TEST_ERROR - /* Insert records to fill up middle internal node */ - for(u = 0; u < ((INSERT_SPLIT_ROOT_NREC * 13) + ((3 * INSERT_SPLIT_ROOT_NREC) / 4) + 2); u++) { - record = u + (INSERT_SPLIT_ROOT_NREC * 31); - if(H5B2_insert(bt2, dxpl, &record) < 0) + /* Close the v2 B-tree */ + if(H5B2_close(bt2, dxpl) < 0) + FAIL_STACK_ERROR + bt2 = NULL; + + PASSED(); + + + /* + * Test inserting many records into v2 B-tree + */ + TESTING("B-tree update: make level 2 B-tree (l+r->middle)"); + + /* Create the v2 B-tree & get its address */ + if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0) + TEST_ERROR + + /* Insert enough records to force root to split into 2 internal nodes */ + for(u = 0; u < (INSERT_SPLIT_ROOT_NREC_REC * 9); u++) { + record.key = ((INSERT_SPLIT_ROOT_NREC_REC * 41) + 3) - u; + record.val = record.key * 2; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + } /* end for */ + for(; u < (INSERT_SPLIT_ROOT_NREC_REC * 41); u++) { + record.key = u - ((INSERT_SPLIT_ROOT_NREC_REC * 9) - 2); /* Leave a gap for later insertion */ + record.val = record.key * 2; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) FAIL_STACK_ERROR } /* end for */ /* Check up on B-tree */ bt2_stat.depth = 2; - bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC * 87) + ((3 * INSERT_SPLIT_ROOT_NREC) / 4) + 2; + bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC_REC * 41); if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR - record = 1889; /* Left record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) - TEST_ERROR - record = 3703; /* Right record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) - TEST_ERROR - record = 2789; /* Record to left of insertion point in middle internal node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) - TEST_ERROR - record = 2822; /* Record to right of insertion point in middle internal node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + record.key = 1345; + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR - record = 2823; /* Record just above insertion point in leaf node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0) + + /* Check for closing & re-opening the B-tree */ + if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0) TEST_ERROR + /* Add some extra records to right-most leaf */ + record.key = (INSERT_SPLIT_ROOT_NREC_REC * 41) + 4; + record.val = record.key * 2; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + record.key = (INSERT_SPLIT_ROOT_NREC_REC * 41) + 5; + record.val = record.key * 2; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + + /* Add some extra records to middle leaf */ + record.key = ((INSERT_SPLIT_ROOT_NREC_REC * 41) - (INSERT_SPLIT_ROOT_NREC_REC * 9)) + 2; + record.val = record.key * 2; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + record.key = ((INSERT_SPLIT_ROOT_NREC_REC * 41) - (INSERT_SPLIT_ROOT_NREC_REC * 9)) + 3; + record.val = record.key * 2; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + + /* Add some extra records to left-most leaf */ + record.key = 0; + record.val = record.key * 2; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + record.key = 1; + record.val = record.key * 2; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + /* Check for closing & re-opening the B-tree */ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0) TEST_ERROR - /* Insert record to split middle internal node */ - record = u + (INSERT_SPLIT_ROOT_NREC * 31); - if(H5B2_insert(bt2, dxpl, &record) < 0) + + /* Iterate over B-tree to check records have been inserted correctly */ + idx.key = 0; + idx.val = 0; + if(H5B2_iterate(bt2, dxpl, iter_rec_cb, &idx) < 0) FAIL_STACK_ERROR - /* Check up on B-tree */ - bt2_stat.depth = 2; - bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC * 87) + ((3 * INSERT_SPLIT_ROOT_NREC) / 4) + 3; - if(check_stats(bt2, &bt2_stat) < 0) + /* Make certain that the index is correct */ + if(idx.key != ((INSERT_SPLIT_ROOT_NREC_REC * 41) + 6)) TEST_ERROR - record = 1889; /* Left record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + + /* Attempt to find non-existant record in level-2 B-tree */ + /* (Should not be found, but not fail) */ + find.key = INSERT_SPLIT_ROOT_NREC_REC * 42; + find.val = (hsize_t)-1; + if(H5B2_find(bt2, dxpl, &find, find_rec_cb, &find) != FALSE) TEST_ERROR - record = 2789; /* Middle record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + if(find.val != (hsize_t)-1) TEST_ERROR - record = 3703; /* Right record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + + /* Attempt to find existant record in root of level-2 B-tree */ + find.key = 1345; + find.val = (hsize_t)-1; + if(H5B2_find(bt2, dxpl, &find, find_rec_cb, &find) != TRUE) + FAIL_STACK_ERROR + if(find.val != (1345 * 2)) TEST_ERROR -#ifdef NONE - record = 3049; /* Record to left of insertion point in middle internal node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + + /* Check with B-tree */ + record.key = 1345; + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR -#endif /* NONE */ - record = 2822; /* Record to right of insertion point in middle internal node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + + /* Attempt to find existant record in internal node of level-2 B-tree */ + find.key = 513; + find.val = (hsize_t)-1; + if(H5B2_find(bt2, dxpl, &find, find_rec_cb, &find) != TRUE) + FAIL_STACK_ERROR + if(find.val != (513 * 2)) TEST_ERROR - record = 2823; /* Record just above insertion point in leaf node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0) + + /* Check with B-tree */ + record.key = 513; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR - /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0) + /* Attempt to find existant record in leaf of level-2 B-tree */ + find.key = 555; + find.val = (hsize_t)-1; + if(H5B2_find(bt2, dxpl, &find, find_rec_cb, &find) != TRUE) + FAIL_STACK_ERROR + if(find.val != (555 * 2)) TEST_ERROR - /* Iterate over B-tree to check records have been inserted correctly */ - idx = 0; - if(H5B2_iterate(bt2, dxpl, iter_cb, &idx) < 0) + /* Check with B-tree */ + record.key = 555; + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) + TEST_ERROR + + /* Attempt to index non-existant record in level-2 B-tree */ + H5E_BEGIN_TRY { + ret = H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)(INSERT_SPLIT_ROOT_NREC_REC * 42), index_rec_cb, NULL); + } H5E_END_TRY; + /* Should fail */ + if(ret != FAIL) + TEST_ERROR + + /* Attempt to index existing record in level-2 B-tree */ + find.key = (hsize_t)-1; + find.val = (hsize_t)-1; + if(H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)1345, index_rec_cb, &find) < 0) FAIL_STACK_ERROR + if(find.key != 1345) + TEST_ERROR + if(find.val != (1345 * 2)) + TEST_ERROR - /* Make certain that the index is correct */ - if(idx != ((INSERT_SPLIT_ROOT_NREC * 87) + ((3 * INSERT_SPLIT_ROOT_NREC) / 4) + 3)) + /* Attempt to index existing record in internal node of level-2 B-tree */ + find.key = (hsize_t)-1; + find.val = (hsize_t)-1; + if(H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)513, index_rec_cb, &find) < 0) + FAIL_STACK_ERROR + if(find.key != 513) + TEST_ERROR + if(find.val != (513 * 2)) + TEST_ERROR + + /* Attempt to index existing record in leaf of level-2 B-tree */ + find.key = (hsize_t)-1; + find.val = (hsize_t)-1; + if(H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)555, index_rec_cb, &find) < 0) + FAIL_STACK_ERROR + if(find.key != 555) + TEST_ERROR + if(find.val != (555 * 2)) TEST_ERROR /* Close the v2 B-tree */ @@ -2730,103 +4959,95 @@ error: H5Fclose(file); } H5E_END_TRY; return 1; -} /* test_insert_level2_3internal_split() */ +} /* test_update_make_level2() */ /*------------------------------------------------------------------------- - * Function: test_insert_lots + * Function: test_update_lots * * Purpose: Basic tests for the B-tree v2 code. This test inserts many * records in random order, enough to make at a level 4 B-tree. * * Return: Success: 0 - * * Failure: 1 * * Programmer: Quincey Koziol - * Saturday, February 19, 2005 + * Sunday, December 27, 2015 * *------------------------------------------------------------------------- */ static unsigned -test_insert_lots(hid_t fapl, const H5B2_create_t *cparam, +test_update_lots(hid_t fapl, const H5B2_create_t *cparam, const bt2_test_param_t *tparam) { hid_t file = -1; /* File ID */ - char filename[1024]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ haddr_t bt2_addr; /* Address of B-tree created */ - hsize_t record; /* Record to insert into tree */ - hsize_t idx; /* Index within B-tree, for iterator */ time_t curr_time; /* Current time, for seeding random number generator */ - hsize_t *records; /* Record #'s for random insertion */ - unsigned u; /* Local index variable */ - unsigned swap_idx; /* Location to swap with when shuffling */ - hsize_t temp_rec; /* Temporary record */ + H5B2_test_rec_t *records; /* Record #'s for random insertion */ + H5B2_test_rec_t record; /* Record to insert into tree */ + H5B2_test_rec_t modify; /* Modified value */ + H5B2_test_rec_t find; /* Record to find */ + H5B2_test_rec_t iter; /* Index within B-tree, for iterator */ H5B2_stat_t bt2_stat; /* Statistics about B-tree created */ hsize_t nrec; /* Number of records in B-tree */ + unsigned u; /* Local index variable */ herr_t ret; /* Generic error return value */ /* Initialize random number seed */ - curr_time=HDtime(NULL); + curr_time = HDtime(NULL); #ifdef QAK -curr_time=1109170019; -HDfprintf(stderr,"curr_time=%lu\n",(unsigned long)curr_time); +curr_time = 1451342093; +HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time); #endif /* QAK */ HDsrandom((unsigned)curr_time); /* * Test inserting many records into v2 B-tree */ - TESTING("B-tree insert: create random level 4 B-tree"); + TESTING("B-tree update: create random level 4 B-tree"); /* Allocate space for the records */ - if(NULL == (records = (hsize_t *)HDmalloc(sizeof(hsize_t) * INSERT_MANY))) + if(NULL == (records = (H5B2_test_rec_t *)HDmalloc(sizeof(H5B2_test_rec_t) * INSERT_MANY_REC))) TEST_ERROR /* Initialize record #'s */ - for(u = 0; u < INSERT_MANY; u++) - records[u] = u; + for(u = 0; u < INSERT_MANY_REC; u++) { + records[u].key = u; + records[u].val = u * 2; + } /* end for */ /* Shuffle record #'s */ - for(u = 0; u < INSERT_MANY; u++) { - swap_idx = ((unsigned)HDrandom() % (INSERT_MANY - u)) + u; + for(u = 0; u < INSERT_MANY_REC; u++) { + H5B2_test_rec_t temp_rec; /* Temporary record */ + unsigned swap_idx; /* Location to swap with when shuffling */ + + swap_idx = ((unsigned)HDrandom() % (INSERT_MANY_REC - u)) + u; temp_rec = records[u]; records[u] = records[swap_idx]; records[swap_idx] = temp_rec; } /* end for */ - /* Set the filename to use for this test (dependent on fapl) */ - h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); - - /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + /* Create the file for the test */ + if(create_file(&file, &f, fapl) < 0) TEST_ERROR - /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) - STACK_ERROR - - /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(f) < 0) - STACK_ERROR - /* Create the v2 B-tree & get its address */ if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0) TEST_ERROR /* Insert random records */ - for(u = 0; u < INSERT_MANY; u++) { + for(u = 0; u < INSERT_MANY_REC; u++) { record = records[u]; - if(H5B2_insert(bt2, dxpl, &record) < 0) + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) FAIL_STACK_ERROR } /* end for */ /* Check up on B-tree */ bt2_stat.depth = 4; - bt2_stat.nrecords = INSERT_MANY; + bt2_stat.nrecords = INSERT_MANY_REC; if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR @@ -2838,18 +5059,11 @@ HDfprintf(stderr,"curr_time=%lu\n",(unsigned long)curr_time); /* Close file */ if(H5Fclose(file) < 0) STACK_ERROR + file = -1; - /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) - FAIL_STACK_ERROR - - /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) - FAIL_STACK_ERROR - - /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(f) < 0) - STACK_ERROR + /* Re-open the file for the test */ + if(reopen_file(&file, &f, fapl) < 0) + TEST_ERROR /* Re-open v2 B-tree */ if(NULL == (bt2 = H5B2_open(f, dxpl, bt2_addr, f))) @@ -2857,87 +5071,110 @@ HDfprintf(stderr,"curr_time=%lu\n",(unsigned long)curr_time); /* Check up on B-tree after re-open */ bt2_stat.depth = 4; - bt2_stat.nrecords = INSERT_MANY; + bt2_stat.nrecords = INSERT_MANY_REC; if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR /* Iterate over B-tree to check records have been inserted correctly */ - idx = 0; - if(H5B2_iterate(bt2, dxpl, iter_cb, &idx) < 0) + iter.key = 0; + iter.val = 0; + if(H5B2_iterate(bt2, dxpl, iter_rec_cb, &iter) < 0) FAIL_STACK_ERROR /* Make certain that the index is correct */ - if(idx != INSERT_MANY) + if(iter.key != INSERT_MANY_REC) TEST_ERROR /* Attempt to find non-existant record in level-4 B-tree */ /* (Should not be found, but not fail) */ - idx = INSERT_MANY * 2; - if(H5B2_find(bt2, dxpl, &idx, find_cb, &idx) != FALSE) + find.key = INSERT_MANY_REC * 2; + find.val = (hsize_t)-1; + if(H5B2_find(bt2, dxpl, &find, find_rec_cb, &find) != FALSE) + TEST_ERROR + if(find.val != (hsize_t)-1) TEST_ERROR /* Find random records */ - for(u = 0; u < FIND_MANY; u++) { + for(u = 0; u < FIND_MANY_REC; u++) { /* Pick random record */ - idx = (hsize_t)(HDrandom()%INSERT_MANY); + find.key = (hsize_t)(HDrandom() % INSERT_MANY_REC); + find.val = (hsize_t)-1; - /* Attempt to find existant record in root of level-4 B-tree */ - if(H5B2_find(bt2, dxpl, &idx, find_cb, &idx) != TRUE) + /* Attempt to find existant record in level-4 B-tree */ + if(H5B2_find(bt2, dxpl, &find, find_rec_cb, &find) != TRUE) FAIL_STACK_ERROR + if(find.val != (find.key * 2)) + TEST_ERROR } /* end for */ /* Attempt to index non-existant record in level-4 B-tree, in increasing & decreasing order */ H5E_BEGIN_TRY { - ret = H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)(INSERT_MANY*3), find_cb, NULL); + ret = H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)(INSERT_MANY_REC * 3), find_rec_cb, NULL); } H5E_END_TRY; /* Should fail */ if(ret != FAIL) TEST_ERROR H5E_BEGIN_TRY { - ret = H5B2_index(bt2, dxpl, H5_ITER_DEC, (hsize_t)(INSERT_MANY*3), find_cb, NULL); + ret = H5B2_index(bt2, dxpl, H5_ITER_DEC, (hsize_t)(INSERT_MANY_REC * 3), find_rec_cb, NULL); } H5E_END_TRY; /* Should fail */ if(ret != FAIL) TEST_ERROR /* Find random records */ - for(u = 0; u < FIND_MANY; u++) { + for(u = 0; u < FIND_MANY_REC; u++) { + hsize_t idx; /* Record index */ + /* Pick random record */ - idx = (hsize_t)(HDrandom() % INSERT_MANY); + idx = (hsize_t)(HDrandom() % INSERT_MANY_REC); - /* Attempt to find existant record in root of level-4 B-tree */ + /* Reset find record */ + find.key = (hsize_t)-1; + find.val = (hsize_t)-1; + + /* Attempt to find existant record in level-4 B-tree */ /* (in increasing order) */ - if(H5B2_index(bt2, dxpl, H5_ITER_INC, idx, find_cb, &idx) < 0) + if(H5B2_index(bt2, dxpl, H5_ITER_INC, idx, index_rec_cb, &find) < 0) FAIL_STACK_ERROR + if(find.key != idx) + TEST_ERROR + if(find.val != (find.key * 2)) + TEST_ERROR - /* Attempt to find existant record in root of level-4 B-tree */ + /* Reset find record */ + find.key = (hsize_t)-1; + find.val = (hsize_t)-1; + + /* Attempt to find existant record in level-4 B-tree */ /* (in decreasing order) */ - if(H5B2_index(bt2, dxpl, H5_ITER_DEC, idx, find_dec_cb, &idx) < 0) + if(H5B2_index(bt2, dxpl, H5_ITER_DEC, idx, index_rec_cb, &find) < 0) FAIL_STACK_ERROR + if(find.key != (INSERT_MANY_REC - (idx + 1))) + TEST_ERROR + if(find.val != (find.key * 2)) + TEST_ERROR } /* end for */ PASSED(); - TESTING("B-tree insert: attempt duplicate record in level 4 B-tree"); + TESTING("B-tree update: update record in level 4 B-tree"); /* Check for closing & re-opening the B-tree */ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0) TEST_ERROR - record = INSERT_MANY / 2; - H5E_BEGIN_TRY { - ret = H5B2_insert(bt2, dxpl, &record); - } H5E_END_TRY; - /* Should fail */ - if(ret != FAIL) - TEST_ERROR + record.key = INSERT_MANY_REC / 2; + modify.key = INSERT_MANY_REC / 2; + modify.val = record.key * 3; + if(H5B2_update(bt2, dxpl, &record, modify_rec_cb, &modify) < 0) + FAIL_STACK_ERROR /* Query the number of records in the B-tree */ if(H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != INSERT_MANY) + if(nrec != INSERT_MANY_REC) TEST_ERROR /* Close the v2 B-tree */ @@ -2956,14 +5193,16 @@ HDfprintf(stderr,"curr_time=%lu\n",(unsigned long)curr_time); return 0; error: + HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time); H5E_BEGIN_TRY { if(bt2) H5B2_close(bt2, dxpl); H5Fclose(file); } H5E_END_TRY; HDfree(records); + return 1; -} /* test_insert_lots() */ +} /* test_update_lots() */ /*------------------------------------------------------------------------- @@ -3365,13 +5604,13 @@ test_remove_level1_noredistrib(hid_t fapl, const H5B2_create_t *cparam, /* Check up on B-tree */ record = 62; /* Left record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 94; /* Right record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = (INSERT_SPLIT_ROOT_NREC * 2) - 2; - if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) TEST_ERROR rrecord = 0; @@ -3384,10 +5623,10 @@ test_remove_level1_noredistrib(hid_t fapl, const H5B2_create_t *cparam, /* Make certain that the leaf nodes didn't redistribute */ record = 62; /* Left record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 94; /* Right record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR /* Query the number of records in the B-tree */ @@ -3409,7 +5648,7 @@ test_remove_level1_noredistrib(hid_t fapl, const H5B2_create_t *cparam, /* Check up on B-tree */ record = 0; - if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) TEST_ERROR rrecord = 1; @@ -3422,10 +5661,10 @@ test_remove_level1_noredistrib(hid_t fapl, const H5B2_create_t *cparam, /* Make certain that the leaf nodes didn't redistribute */ record = 62; /* Left record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 94; /* Right record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR /* Query the number of records in the B-tree */ @@ -3447,7 +5686,7 @@ test_remove_level1_noredistrib(hid_t fapl, const H5B2_create_t *cparam, /* Check up on B-tree */ record = INSERT_SPLIT_ROOT_NREC; - if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) TEST_ERROR rrecord = 0; @@ -3460,10 +5699,10 @@ test_remove_level1_noredistrib(hid_t fapl, const H5B2_create_t *cparam, /* Make certain that the leaf nodes didn't redistribute */ record = 62; /* Left record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 94; /* Right record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR /* Query the number of records in the B-tree */ @@ -3545,10 +5784,10 @@ test_remove_level1_redistrib(hid_t fapl, const H5B2_create_t *cparam, /* Check record values in root of B-tree */ record = 62; /* Left record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 94; /* Right record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR /* Query the number of records in the B-tree */ @@ -3593,10 +5832,10 @@ test_remove_level1_redistrib(hid_t fapl, const H5B2_create_t *cparam, /* Check record values in root of B-tree */ record = 62; /* Left record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 90; /* Right record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR PASSED(); @@ -3629,10 +5868,10 @@ test_remove_level1_redistrib(hid_t fapl, const H5B2_create_t *cparam, /* Check record values in root of B-tree */ record = 64; /* Left record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 90; /* Right record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR PASSED(); @@ -3665,10 +5904,10 @@ test_remove_level1_redistrib(hid_t fapl, const H5B2_create_t *cparam, /* Check record values in root of B-tree */ record = 64; /* Left record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 91; /* Right record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR /* Close the v2 B-tree */ @@ -3742,7 +5981,7 @@ test_remove_level1_2leaf_merge(hid_t fapl, const H5B2_create_t *cparam, /* Check record values in root of B-tree */ record = 62; /* Left record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR ninfo.depth = 1; ninfo.nrec = 2; @@ -3815,7 +6054,7 @@ test_remove_level1_2leaf_merge(hid_t fapl, const H5B2_create_t *cparam, /* Check record values in root of B-tree */ record = 62; /* Left record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR ninfo.depth = 1; ninfo.nrec = 2; @@ -3921,7 +6160,7 @@ test_remove_level1_3leaf_merge(hid_t fapl, const H5B2_create_t *cparam, /* Check record values in root of B-tree */ record = 62; /* Left record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR ninfo.depth = 1; ninfo.nrec = 2; @@ -4047,13 +6286,13 @@ test_remove_level1_promote(hid_t fapl, const H5B2_create_t *cparam, /* Check record values in root of B-tree */ record = 62; /* Left-most record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 125; /* Center-Left record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 188; /* Center-Right record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR ninfo.depth = 1; ninfo.nrec = 4; @@ -4093,13 +6332,13 @@ test_remove_level1_promote(hid_t fapl, const H5B2_create_t *cparam, /* Check record values in root of B-tree */ record = 62; /* Left-most record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 125; /* Center-Left record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 188; /* Center-Right record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR ninfo.depth = 1; ninfo.nrec = 4; @@ -4139,13 +6378,13 @@ test_remove_level1_promote(hid_t fapl, const H5B2_create_t *cparam, /* Check record values in root of B-tree */ record = 63; /* Left-most record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 125; /* Center-Left record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 188; /* Center-Right record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR ninfo.depth = 1; ninfo.nrec = 4; @@ -4181,13 +6420,13 @@ test_remove_level1_promote(hid_t fapl, const H5B2_create_t *cparam, /* Check record values in root of B-tree */ record = 63; /* Left-most record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 126; /* Center-Left record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 188; /* Center-Right record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR ninfo.depth = 1; ninfo.nrec = 4; @@ -4274,7 +6513,7 @@ test_remove_level1_promote_2leaf_redistrib(hid_t fapl, const H5B2_create_t *cpar /* Check record values in root of B-tree */ record = 62; /* Left-most record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR ninfo.depth = 1; ninfo.nrec = 2; @@ -4335,7 +6574,7 @@ test_remove_level1_promote_2leaf_redistrib(hid_t fapl, const H5B2_create_t *cpar /* Check record values in root of B-tree */ record = 62; /* Left-most record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR ninfo.depth = 1; ninfo.nrec = 2; @@ -4422,7 +6661,7 @@ test_remove_level1_promote_3leaf_redistrib(hid_t fapl, const H5B2_create_t *cpar /* Check record values in root of B-tree */ record = 62; /* Left-most record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR ninfo.depth = 1; ninfo.nrec = 2; @@ -4483,7 +6722,7 @@ test_remove_level1_promote_3leaf_redistrib(hid_t fapl, const H5B2_create_t *cpar /* Check record values in root of B-tree */ record = 39; /* Left record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR ninfo.depth = 1; ninfo.nrec = 2; @@ -4570,7 +6809,7 @@ test_remove_level1_promote_2leaf_merge(hid_t fapl, const H5B2_create_t *cparam, /* Check record values in root of B-tree */ record = 62; /* Left-most record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR ninfo.depth = 1; ninfo.nrec = 2; @@ -4715,7 +6954,7 @@ test_remove_level1_promote_3leaf_merge(hid_t fapl, const H5B2_create_t *cparam, /* Check record values in root of B-tree */ record = 62; /* Left-most record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR ninfo.depth = 1; ninfo.nrec = 2; @@ -4999,7 +7238,7 @@ test_remove_level2_promote(hid_t fapl, const H5B2_create_t *cparam, /* Check record values in root of B-tree */ record = 1889; /* Left record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR ninfo.depth = 2; ninfo.nrec = 2; @@ -5285,7 +7524,7 @@ test_remove_level2_promote_2internal_redistrib(hid_t fapl, const H5B2_create_t * /* Check record values in root of B-tree */ record = 1889; /* Left record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR ninfo.depth = 2; ninfo.nrec = 2; @@ -5435,7 +7674,7 @@ test_remove_level2_promote_3internal_redistrib(hid_t fapl, const H5B2_create_t * /* Check record values in root of B-tree */ record = 1889; /* Left record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR ninfo.depth = 2; ninfo.nrec = 2; @@ -5585,7 +7824,7 @@ test_remove_level2_promote_2internal_merge(hid_t fapl, const H5B2_create_t *cpar /* Check record values in root of B-tree */ record = 1889; /* Left record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR ninfo.depth = 2; ninfo.nrec = 2; @@ -5736,7 +7975,7 @@ test_remove_level2_promote_3internal_merge(hid_t fapl, const H5B2_create_t *cpar /* Check record values in root of B-tree */ record = 1889; /* Left record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR ninfo.depth = 2; ninfo.nrec = 2; @@ -5887,7 +8126,7 @@ test_remove_level2_2internal_merge_left(hid_t fapl, const H5B2_create_t *cparam, /* Check record values in root of B-tree */ record = 1889; /* Left record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR ninfo.depth = 2; ninfo.nrec = 2; @@ -6013,7 +8252,7 @@ test_remove_level2_2internal_merge_right(hid_t fapl, const H5B2_create_t *cparam /* Check record values in root of B-tree */ record = 1889; /* Left record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR ninfo.depth = 2; ninfo.nrec = 2; @@ -6139,7 +8378,7 @@ test_remove_level2_3internal_merge(hid_t fapl, const H5B2_create_t *cparam, /* Check record values in root of B-tree */ record = 1889; /* Left record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR ninfo.depth = 2; ninfo.nrec = 2; @@ -6266,7 +8505,7 @@ test_remove_level2_collapse_right(hid_t fapl, const H5B2_create_t *cparam, /* Check record values in root of B-tree */ record = 1889; /* Left record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR ninfo.depth = 2; ninfo.nrec = 2; @@ -7750,7 +9989,7 @@ error: int main(void) { - H5B2_create_t cparam; /* Creation parameters for v2 B-tree */ + H5B2_create_t cparam, cparam2; /* Creation parameters for v2 B-tree */ bt2_test_param_t tparam; /* Test parameters for v2 B-tree */ hid_t fapl = -1; /* File access property list for data files */ unsigned nerrors = 0; /* Cumulative error count */ @@ -7770,8 +10009,7 @@ main(void) printf("***Express test mode on. Some tests may be skipped\n"); /* Initialize v2 B-tree creation parameters */ - init_cparam(&cparam); - + init_cparam(&cparam, &cparam2); /* Loop over re-opening B-tree during tests */ for(reopen = FALSE; reopen <= TRUE; reopen++) { @@ -7785,7 +10023,7 @@ main(void) } /* end else */ /* Test B-tree record insertion */ - /* Iteration, find & index routines tested in these routines as well */ + /* (Iteration, find & index routines exercised in these routines as well) */ nerrors += test_insert_basic(fapl, &cparam, &tparam); nerrors += test_insert_split_root(fapl, &cparam, &tparam); nerrors += test_insert_level1_2leaf_redistrib(fapl, &cparam, &tparam); @@ -7804,6 +10042,20 @@ main(void) else nerrors += test_insert_lots(fapl, &cparam, &tparam); + /* Test B-tree record update (ie. insert/modify) */ + /* (Iteration, find & index routines exercised in these routines as well) */ + nerrors += test_update_basic(fapl, &cparam2, &tparam); + nerrors += test_update_split_root(fapl, &cparam2, &tparam); + nerrors += test_update_level1_2leaf_redistrib(fapl, &cparam2, &tparam); + nerrors += test_update_level1_side_split(fapl, &cparam2, &tparam); + nerrors += test_update_level1_3leaf_redistrib(fapl, &cparam2, &tparam); + nerrors += test_update_level1_middle_split(fapl, &cparam2, &tparam); + nerrors += test_update_make_level2(fapl, &cparam2, &tparam); + if(ExpressMode > 1) + printf("***Express test mode on. test_update_lots skipped\n"); + else + nerrors += test_update_lots(fapl, &cparam2, &tparam); + /* Test B-tree record removal */ /* Querying the number of records routine also tested in these routines as well */ nerrors += test_remove_basic(fapl, &cparam, &tparam); diff --git a/tools/misc/h5debug.c b/tools/misc/h5debug.c index 480450d..817f583 100644 --- a/tools/misc/h5debug.c +++ b/tools/misc/h5debug.c @@ -121,6 +121,10 @@ get_H5B2_class(const uint8_t *sig) cls = H5A_BT2_CORDER; break; + case H5B2_TEST2_ID: + cls = H5B2_TEST2; + break; + case H5B2_NUM_BTREE_ID: default: HDfprintf(stderr, "Unknown v2 B-tree subtype %u\n", (unsigned)(subtype)); -- cgit v0.12 From c6949efd4fd5f5757f2d0443d51e4d635485595b Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Tue, 29 Dec 2015 20:56:45 -0500 Subject: [svn-r28748] Description: Bump number of records for level 4 B-tree test, so that it's more likely to always get to level 4. Tested on: MacOSX/64 10.11.2 (amazon) w/serial & parallel (h5committest forthcoming) --- test/btree2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/btree2.c b/test/btree2.c index 04c94fd..8a08d3d 100644 --- a/test/btree2.c +++ b/test/btree2.c @@ -38,7 +38,7 @@ const char *FILENAME[] = { #define INSERT_SPLIT_ROOT_NREC 63 #define INSERT_SPLIT_ROOT_NREC_REC 64 #define INSERT_MANY (1000 * 1000) -#define INSERT_MANY_REC (2600 * 1000) +#define INSERT_MANY_REC (2610 * 1000) #define FIND_MANY (INSERT_MANY / 100) #define FIND_MANY_REC (INSERT_MANY_REC / 100) #define FIND_NEIGHBOR 2000 -- cgit v0.12 From 528ab9b810102a7cc7773c6403c8b2be6578d380 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Wed, 30 Dec 2015 13:50:01 -0500 Subject: [svn-r28756] Description: Minor code neatening and cleanups (same as r28755) on revise_chunks branch. Tested on: MacOSX/64 10.11.2 (amazon) w/serial & parallel (Too minor for h5committest) --- src/H5Dchunk.c | 40 ++++++++++++++++++++++++---------------- src/H5Dpkg.h | 10 +++++----- 2 files changed, 29 insertions(+), 21 deletions(-) diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index 2e000e3..6b99a43 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -1034,9 +1034,8 @@ H5D__chunk_mem_alloc(size_t size, const H5O_pline_t *pline) FUNC_ENTER_STATIC_NOERR HDassert(size); - HDassert(pline); - if(pline->nused > 0) + if(pline && pline->nused) ret_value = H5MM_malloc(size); else ret_value = H5FL_BLK_MALLOC(chunk, size); @@ -1064,10 +1063,8 @@ H5D__chunk_mem_xfree(void *chk, const H5O_pline_t *pline) { FUNC_ENTER_STATIC_NOERR - HDassert(pline); - if(chk) { - if(pline->nused > 0) + if(pline && pline->nused) H5MM_xfree(chk); else chk = H5FL_BLK_FREE(chunk, chk); @@ -1751,6 +1748,7 @@ H5D__chunk_cacheable(const H5D_io_info_t *io_info, haddr_t caddr, hbool_t write_ FUNC_ENTER_PACKAGE + /* Sanity check */ HDassert(io_info); HDassert(dataset); @@ -2551,13 +2549,14 @@ H5D__chunk_lookup(const H5D_t *dset, hid_t dxpl_id, const hsize_t *scaled, H5D_chunk_ud_t *udata) { H5D_rdcc_ent_t *ent = NULL; /* Cache entry */ - hbool_t found = FALSE; /* In cache? */ - unsigned u; /* Counter */ H5O_storage_chunk_t *sc = &(dset->shared->layout.storage.u.chunk); - herr_t ret_value = SUCCEED; /* Return value */ + unsigned idx; /* Index of chunk in cache, if present */ + hbool_t found = FALSE; /* In cache? */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE + /* Sanity checks */ HDassert(dset); HDassert(dset->shared->layout.u.chunk.ndims > 0); H5D_CHUNK_STORAGE_INDEX_CHK(sc); @@ -2567,7 +2566,7 @@ H5D__chunk_lookup(const H5D_t *dset, hid_t dxpl_id, const hsize_t *scaled, /* Initialize the query information about the chunk we are looking for */ udata->common.layout = &(dset->shared->layout.u.chunk); udata->common.storage = &(dset->shared->layout.storage.u.chunk); - udata->common.scaled = scaled; + udata->common.scaled = scaled; /* Reset information about the chunk we are looking for */ udata->chunk_block.offset = HADDR_UNDEF; @@ -2576,19 +2575,29 @@ H5D__chunk_lookup(const H5D_t *dset, hid_t dxpl_id, const hsize_t *scaled, /* Check for chunk in cache */ if(dset->shared->cache.chunk.nslots > 0) { - udata->idx_hint = H5D__chunk_hash_val(dset->shared, scaled); - ent = dset->shared->cache.chunk.slot[udata->idx_hint]; + /* Determine the chunk's location in the hash table */ + idx = H5D__chunk_hash_val(dset->shared, scaled); + + /* Get the chunk cache entry for that location */ + ent = dset->shared->cache.chunk.slot[idx]; + if(ent) { + unsigned u; /* Counter */ + + /* Speculatively set the 'found' flag */ + found = TRUE; - if(ent) - for(u = 0, found = TRUE; u < dset->shared->ndims; u++) + /* Verify that the cache entry is the correct chunk */ + for(u = 0; u < dset->shared->ndims; u++) if(scaled[u] != ent->scaled[u]) { found = FALSE; break; } /* end if */ + } /* end if */ } /* end if */ - /* Find chunk addr */ + /* Retrieve chunk addr */ if(found) { + udata->idx_hint = idx; udata->chunk_block.offset = ent->chunk_block.offset; udata->chunk_block.length = ent->chunk_block.length;; udata->chunk_idx = ent->chunk_idx; @@ -3287,6 +3296,7 @@ H5D__chunk_unlock(const H5D_io_info_t *io_info, const H5D_chunk_ud_t *udata, FUNC_ENTER_PACKAGE + /* Sanity check */ HDassert(io_info); HDassert(udata); @@ -3294,8 +3304,6 @@ H5D__chunk_unlock(const H5D_io_info_t *io_info, const H5D_chunk_ud_t *udata, /* * It's not in the cache, probably because it's too big. If it's * dirty then flush it to disk. In any case, free the chunk. - * Note: we have to copy the layout and filter messages so we - * don't discard the `const' qualifier. */ if(dirty) { H5D_rdcc_ent_t fake_ent; /* "fake" chunk cache entry */ diff --git a/src/H5Dpkg.h b/src/H5Dpkg.h index 06e763c..4e6376b 100644 --- a/src/H5Dpkg.h +++ b/src/H5Dpkg.h @@ -250,7 +250,6 @@ typedef struct H5D_chunk_rec_t { * to which the index points. */ typedef struct H5D_chunk_common_ud_t { - /* downward */ const H5O_layout_chunk_t *layout; /* Chunk layout description */ const H5O_storage_chunk_t *storage; /* Chunk storage description */ const hsize_t *scaled; /* Scaled coordinates for a chunk */ @@ -258,13 +257,14 @@ typedef struct H5D_chunk_common_ud_t { /* B-tree callback info for various operations */ typedef struct H5D_chunk_ud_t { + /* Downward */ H5D_chunk_common_ud_t common; /* Common info for B-tree user data (must be first) */ /* Upward */ - unsigned idx_hint; /*index of chunk in cache, if present */ - H5F_block_t chunk_block; /*offset/length of chunk in file */ - unsigned filter_mask; /*excluded filters */ - hsize_t chunk_idx; /*chunk index for EA, FA indexing */ + unsigned idx_hint; /* Index of chunk in cache, if present */ + H5F_block_t chunk_block; /* Offset/length of chunk in file */ + unsigned filter_mask; /* Excluded filters */ + hsize_t chunk_idx; /* Chunk index for EA, FA indexing */ } H5D_chunk_ud_t; /* Typedef for "generic" chunk callbacks */ -- cgit v0.12 From 8d8d56d7d1601a88b90524c7bcb78c2515ce770f Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Thu, 31 Dec 2015 11:23:05 -0500 Subject: [svn-r28759] Description: Bump number of records for level 4 update test, to cut down on number of random failures. Tested on: None - trivial --- test/btree2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/btree2.c b/test/btree2.c index 8a08d3d..b0c0ac3 100644 --- a/test/btree2.c +++ b/test/btree2.c @@ -38,7 +38,7 @@ const char *FILENAME[] = { #define INSERT_SPLIT_ROOT_NREC 63 #define INSERT_SPLIT_ROOT_NREC_REC 64 #define INSERT_MANY (1000 * 1000) -#define INSERT_MANY_REC (2610 * 1000) +#define INSERT_MANY_REC (2650 * 1000) #define FIND_MANY (INSERT_MANY / 100) #define FIND_MANY_REC (INSERT_MANY_REC / 100) #define FIND_NEIGHBOR 2000 -- cgit v0.12 From f60170dac7c491cc75120a6ebdfe73c13c0bab1d Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Fri, 1 Jan 2016 01:28:04 -0500 Subject: [svn-r28761] Description: Clean up many mismatches between malloc/free and H5MM_malloc/H5MM_xfree in the library and tests (and use of H5free_memory and H5Dvlen_reclaim). Also make H5Ocopy use a private version of H5Lexists, which doesn't internally throw (and suppress) errors when an object (or the path to it) isn't found in the destination. Tested on: MacOSX/64 10.11.2 (amazon) w/serial & parallel (h5committest forthcoming) --- fortran/src/H5Pf.c | 2 +- src/H5.c | 5 +- src/H5L.c | 186 ++++++++++++++++++++++++++++++++++++++++++++++++----- src/H5Lprivate.h | 2 + src/H5Ocopy.c | 24 ++----- src/H5TS.c | 17 +++-- src/H5Tvlen.c | 8 +-- src/H5Ztrans.c | 4 +- test/dtypes.c | 99 +++++++++++++++++++++++++--- test/fheap.c | 10 +-- test/file_image.c | 4 +- test/links.c | 57 ++++++++++------ test/objcopy.c | 150 ++++++++++++++++++++++++++++++++++++------ test/tgenprop.c | 4 +- test/tmisc.c | 16 ++++- test/tvlstr.c | 11 ++-- tools/h5ls/h5ls.c | 5 +- 17 files changed, 482 insertions(+), 122 deletions(-) diff --git a/fortran/src/H5Pf.c b/fortran/src/H5Pf.c index 523ed0b..3989512 100644 --- a/fortran/src/H5Pf.c +++ b/fortran/src/H5Pf.c @@ -5273,7 +5273,7 @@ h5pget_file_image_c(hid_t_f *fapl_id, void **buf_ptr, size_t_f *buf_len_ptr) *buf_len_ptr=(size_t_f)c_buf_len_ptr; ret_value = 0; - if(c_buf_ptr) HDfree(c_buf_ptr); + if(c_buf_ptr) H5free_memory(c_buf_ptr); return ret_value; } diff --git a/src/H5.c b/src/H5.c index 33ac340..2086ce8 100644 --- a/src/H5.c +++ b/src/H5.c @@ -942,7 +942,6 @@ H5allocate_memory(size_t size, hbool_t clear) ret_value = H5MM_malloc(size); FUNC_LEAVE_API(ret_value) - } /* end H5allocate_memory() */ @@ -981,7 +980,6 @@ H5resize_memory(void *mem, size_t size) ret_value = H5MM_realloc(mem, size); FUNC_LEAVE_API(ret_value) - } /* end H5resize_memory() */ @@ -1004,10 +1002,9 @@ H5free_memory(void *mem) H5TRACE1("e", "*x", mem); /* At this time, it is impossible for this to fail. */ - HDfree(mem); + H5MM_xfree(mem); FUNC_LEAVE_API(SUCCEED) - } /* end H5free_memory() */ diff --git a/src/H5L.c b/src/H5L.c index a1f3b6e..9daf948 100644 --- a/src/H5L.c +++ b/src/H5L.c @@ -93,6 +93,17 @@ typedef struct { hid_t dxpl_id; /* Dataset transfer property list */ } H5L_trav_mv2_t; +/* User data for path traversal routine for checking if a link exists */ +typedef struct { + /* Down */ + char *sep; /* Pointer to next separator in the string */ + hid_t lapl_id; /* Link access property list */ + hid_t dxpl_id; /* Dataset transfer property list */ + + /* Up */ + hbool_t exists; /* Whether the link exists or not */ +} H5L_trav_le_t; + /* User data for path traversal routine for getting link value */ typedef struct { size_t size; /* Size of user buffer */ @@ -170,10 +181,13 @@ static herr_t H5L_move_cb(H5G_loc_t *grp_loc/*in*/, const char *name, static herr_t H5L_move_dest_cb(H5G_loc_t *grp_loc/*in*/, const char *name, const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, H5G_own_loc_t *own_loc/*out*/); -static herr_t H5L_exists_cb(H5G_loc_t *grp_loc/*in*/, const char *name, +static herr_t H5L__exists_final_cb(H5G_loc_t *grp_loc/*in*/, const char *name, + const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, + H5G_own_loc_t *own_loc/*out*/); +static herr_t H5L__exists_inter_cb(H5G_loc_t *grp_loc/*in*/, const char *name, const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, H5G_own_loc_t *own_loc/*out*/); -static htri_t H5L_exists(const H5G_loc_t *loc, const char *name, hid_t lapl_id, +static htri_t H5L__exists(const H5G_loc_t *loc, const char *name, hid_t lapl_id, hid_t dxpl_id); static herr_t H5L_get_info_cb(H5G_loc_t *grp_loc/*in*/, const char *name, const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, @@ -827,7 +841,7 @@ H5Lexists(hid_t loc_id, const char *name, hid_t lapl_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") /* Check for the existence of the link */ - if((ret_value = H5L_exists(&loc, name, lapl_id, H5AC_ind_dxpl_id)) < 0) + if((ret_value = H5L__exists(&loc, name, lapl_id, H5AC_ind_dxpl_id)) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to get link info") done: @@ -2716,9 +2730,10 @@ done: /*------------------------------------------------------------------------- - * Function: H5L_exists_cb + * Function: H5L__exists_final_cb * - * Purpose: Callback for checking whether a link exists + * Purpose: Callback for checking whether a link exists, as the final + * component of a path * * Return: Non-negative on success/Negative on failure * @@ -2728,30 +2743,162 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5L_exists_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_ATTR_UNUSED *name, +H5L__exists_final_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_ATTR_UNUSED *name, const H5O_link_t *lnk, H5G_loc_t H5_ATTR_UNUSED *obj_loc, void *_udata/*in,out*/, H5G_own_loc_t *own_loc/*out*/) { - hbool_t *udata = (hbool_t *)_udata; /* User data passed in */ + H5L_trav_le_t *udata = (H5L_trav_le_t *)_udata; /* User data passed in */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Check if the name in this group resolved to a valid link */ - *udata = (hbool_t)(lnk != NULL); + udata->exists = (hbool_t)(lnk != NULL); /* Indicate that this callback didn't take ownership of the group * * location for the object */ *own_loc = H5G_OWN_NONE; FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5L_exists_cb() */ +} /* end H5L__exists_final_cb() */ /*------------------------------------------------------------------------- - * Function: H5L_exists + * Function: H5L__exists_inter_cb + * + * Purpose: Callback for checking whether a link exists, as an intermediate + * component of a path + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * Thursday, December 31 2015 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5L__exists_inter_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_ATTR_UNUSED *name, + const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, + H5G_own_loc_t *own_loc/*out*/) +{ + H5L_trav_le_t *udata = (H5L_trav_le_t *)_udata; /* User data passed in */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the name in this group resolved to a valid link */ + if(lnk != NULL) { + /* Check for more components to the path */ + if(udata->sep) { + H5G_traverse_t cb_func; /* Callback function for tranversal */ + char *next; /* Pointer to next component name */ + + /* Look for another separator */ + next = udata->sep; + if(NULL == (udata->sep = HDstrchr(udata->sep, '/'))) + cb_func = H5L__exists_final_cb; + else { + /* Chew through adjacent separators, if present */ + do { + *udata->sep = '\0'; + udata->sep++; + } while('/' == *udata->sep); + cb_func = H5L__exists_inter_cb; + } /* end else */ + if(H5G_traverse(obj_loc, next, H5G_TARGET_SLINK | H5G_TARGET_UDLINK, cb_func, udata, udata->lapl_id, udata->dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't determine if link exists") + } /* end if */ + else + udata->exists = TRUE; + } /* end if */ + else + udata->exists = FALSE; + + /* Indicate that this callback didn't take ownership of the group * + * location for the object */ + *own_loc = H5G_OWN_NONE; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5L__exists_inter_cb() */ + + +/*------------------------------------------------------------------------- + * Function: H5L_exists_tolerant * * Purpose: Returns whether a link exists in a group * + * Note: Same as H5L_exists, except that missing links are reported + * as 'FALSE' instead of causing failures + * + * Return: Non-negative (TRUE/FALSE) on success/Negative on failure + * + * Programmer: Quincey Koziol + * Thursday, December 31 2015 + * + *------------------------------------------------------------------------- + */ +htri_t +H5L_exists_tolerant(const H5G_loc_t *loc, const char *name, hid_t lapl_id, hid_t dxpl_id) +{ + H5L_trav_le_t udata; /* User data for traversal */ + H5G_traverse_t cb_func; /* Callback function for tranversal */ + char *name_copy = NULL; /* Duplicate of name */ + char *name_trav; /* Name to traverse */ + htri_t ret_value = FAIL; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(loc); + HDassert(name); + + /* Copy the name and skip leading '/'s */ + name_trav = name_copy = H5MM_strdup(name); + while('/' == *name_trav) + name_trav++; + + /* A path of "/" will always exist in a file */ + if('\0' == *name_trav) + HGOTO_DONE(TRUE) + + /* Set up user data & correct callback */ + udata.lapl_id = lapl_id; + udata.dxpl_id = dxpl_id; + udata.exists = FALSE; + if(NULL == (udata.sep = HDstrchr(name_trav, '/'))) + cb_func = H5L__exists_final_cb; + else { + /* Chew through adjacent separators, if present */ + do { + *udata.sep = '\0'; + udata.sep++; + } while('/' == *udata.sep); + cb_func = H5L__exists_inter_cb; + } /* end else */ + + /* Traverse the group hierarchy to locate the link to check */ + if(H5G_traverse(loc, name_trav, H5G_TARGET_SLINK | H5G_TARGET_UDLINK, cb_func, &udata, lapl_id, dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't determine if link exists") + + /* Set return value */ + ret_value = (htri_t)udata.exists; + +done: + /* Release duplicated string */ + H5MM_xfree(name_copy); + + FUNC_LEAVE_NOAPI(ret_value) +} /* H5L_exists_tolerant() */ + + +/*------------------------------------------------------------------------- + * Function: H5L__exists + * + * Purpose: Returns whether a link exists in a group + * + * Note: Same as H5L_exists_tolerant, except that missing links are reported + * as failures + * * Return: Non-negative (TRUE/FALSE) on success/Negative on failure * * Programmer: Quincey Koziol @@ -2760,23 +2907,28 @@ H5L_exists_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_ATTR_UNUSED *------------------------------------------------------------------------- */ static htri_t -H5L_exists(const H5G_loc_t *loc, const char *name, hid_t lapl_id, hid_t dxpl_id) +H5L__exists(const H5G_loc_t *loc, const char *name, hid_t lapl_id, hid_t dxpl_id) { - hbool_t exists = FALSE; /* Whether the link exists in the group */ + H5L_trav_le_t udata; /* User data for traversal */ htri_t ret_value = FAIL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC + + /* A path of "/" will always exist in a file */ + if(0 == HDstrcmp(name, "/")) + HGOTO_DONE(TRUE) /* Traverse the group hierarchy to locate the object to get info about */ - if(H5G_traverse(loc, name, H5G_TARGET_SLINK|H5G_TARGET_UDLINK, H5L_exists_cb, &exists, lapl_id, dxpl_id) < 0) + udata.exists = FALSE; + if(H5G_traverse(loc, name, H5G_TARGET_SLINK | H5G_TARGET_UDLINK, H5L__exists_final_cb, &udata, lapl_id, dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_EXISTS, FAIL, "path doesn't exist") /* Set return value */ - ret_value = (htri_t)exists; + ret_value = (htri_t)udata.exists; done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5L_exists() */ +} /* H5L__exists() */ /*------------------------------------------------------------------------- diff --git a/src/H5Lprivate.h b/src/H5Lprivate.h index f3079bc..1c8690b 100644 --- a/src/H5Lprivate.h +++ b/src/H5Lprivate.h @@ -81,6 +81,8 @@ H5_DLL hid_t H5L_get_default_lcpl(void); H5_DLL herr_t H5L_move(H5G_loc_t *src_loc, const char *src_name, H5G_loc_t *dst_loc, const char *dst_name, hbool_t copy_flag, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id); +H5_DLL htri_t H5L_exists_tolerant(const H5G_loc_t *loc, const char *name, hid_t lapl_id, + hid_t dxpl_id); H5_DLL herr_t H5L_get_info(const H5G_loc_t *loc, const char *name, H5L_info_t *linkbuf/*out*/, hid_t lapl_id, hid_t dxpl_id); H5_DLL herr_t H5L_delete(H5G_loc_t *loc, const char *name, hid_t lapl_id, diff --git a/src/H5Ocopy.c b/src/H5Ocopy.c index 02c72e7..6f42a88 100644 --- a/src/H5Ocopy.c +++ b/src/H5Ocopy.c @@ -213,10 +213,10 @@ H5Ocopy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, /* for opening the destination object */ H5G_name_t src_path; /* Opened source object hier. path */ H5O_loc_t src_oloc; /* Opened source object object location */ + htri_t dst_exists; /* Does destination name exist already? */ hbool_t loc_found = FALSE; /* Location at 'name' found */ hbool_t obj_open = FALSE; /* Entry at 'name' found */ - - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE6("e", "i*si*sii", src_loc_id, src_name, dst_loc_id, dst_name, @@ -233,22 +233,10 @@ H5Ocopy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no destination name specified") /* check if destination name already exists */ - { - H5G_name_t tmp_path; - H5O_loc_t tmp_oloc; - H5G_loc_t tmp_loc; - - /* Set up group location */ - tmp_loc.oloc = &tmp_oloc; - tmp_loc.path = &tmp_path; - H5G_loc_reset(&tmp_loc); - - /* Check if object already exists in destination */ - if(H5G_loc_find(&dst_loc, dst_name, &tmp_loc, H5P_DEFAULT, H5AC_ind_dxpl_id) >= 0) { - H5G_name_free(&tmp_path); - HGOTO_ERROR(H5E_SYM, H5E_EXISTS, FAIL, "destination object already exists") - } /* end if */ - } + if((dst_exists = H5L_exists_tolerant(&dst_loc, dst_name, H5P_DEFAULT, H5AC_ind_dxpl_id)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to check if destination name exists") + if(TRUE == dst_exists) + HGOTO_ERROR(H5E_OHDR, H5E_EXISTS, FAIL, "destination object already exists") /* Set up opened group location to fill in */ src_loc.oloc = &src_oloc; diff --git a/src/H5TS.c b/src/H5TS.c index 987bead..6a64a14 100644 --- a/src/H5TS.c +++ b/src/H5TS.c @@ -255,19 +255,18 @@ H5TS_cancel_count_inc(void) if (!cancel_counter) { /* - * First time thread calls library - create new counter and associate + * First time thread calls library - create new counter and associate * with key */ - cancel_counter = (H5TS_cancel_t *)H5MM_calloc(sizeof(H5TS_cancel_t)); + cancel_counter = (H5TS_cancel_t *)HDcalloc(1, sizeof(H5TS_cancel_t)); - if (!cancel_counter) { - H5E_push_stack(NULL, "H5TS_cancel_count_inc", - __FILE__, __LINE__, H5E_ERR_CLS_g, H5E_RESOURCE, H5E_NOSPACE, "memory allocation failed"); - return FAIL; - } + if (!cancel_counter) { + H5E_push_stack(NULL, "H5TS_cancel_count_inc", __FILE__, __LINE__, + H5E_ERR_CLS_g, H5E_RESOURCE, H5E_NOSPACE, "memory allocation failed"); + return FAIL; + } - ret_value = pthread_setspecific(H5TS_cancel_key_g, - (void *)cancel_counter); + ret_value = pthread_setspecific(H5TS_cancel_key_g, (void *)cancel_counter); } if (cancel_counter->cancel_count == 0) diff --git a/src/H5Tvlen.c b/src/H5Tvlen.c index 2abdf6f..0ed8209 100644 --- a/src/H5Tvlen.c +++ b/src/H5Tvlen.c @@ -465,7 +465,7 @@ H5T_vlen_seq_mem_write(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, co HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for VL data") } /* end if */ else { /* Default to system malloc */ - if(NULL==(vl.p=H5MM_malloc(len))) + if(NULL == (vl.p = HDmalloc(len))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for VL data") } /* end else */ @@ -691,7 +691,7 @@ H5T_vlen_str_mem_write(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, co HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for VL data") } /* end if */ else { /* Default to system malloc */ - if(NULL==(t = (char *)H5MM_malloc((seq_len+1)*base_size))) + if(NULL == (t = (char *)HDmalloc((seq_len + 1) * base_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for VL data") } /* end else */ @@ -1073,14 +1073,14 @@ H5T_vlen_reclaim_recurse(void *elem, const H5T_t *dt, H5MM_free_t free_func, voi if(free_func != NULL) (*free_func)(vl->p, free_info); else - H5MM_xfree(vl->p); + HDfree(vl->p); } /* end if */ } else if(dt->shared->u.vlen.type == H5T_VLEN_STRING) { /* Free the VL string */ if(free_func != NULL) (*free_func)(*(char **)elem, free_info); else - H5MM_xfree(*(char **)elem); + HDfree(*(char **)elem); } else { HDassert(0 && "Invalid VL type"); } /* end else */ diff --git a/src/H5Ztrans.c b/src/H5Ztrans.c index 0a9a4da..2627a29 100644 --- a/src/H5Ztrans.c +++ b/src/H5Ztrans.c @@ -1032,7 +1032,7 @@ H5Z_xform_eval(H5Z_data_xform_t *data_xform_prop, void* array, size_t array_size /* Free the temporary arrays we used */ if(data_xform_prop->dat_val_pointers->num_ptrs > 1) for(i=0; idat_val_pointers->num_ptrs; i++) - HDfree(data_xform_prop->dat_val_pointers->ptr_dat_val[i]); + H5MM_xfree(data_xform_prop->dat_val_pointers->ptr_dat_val[i]); } /* end else */ done: @@ -1042,7 +1042,7 @@ done: if(data_xform_prop->dat_val_pointers->num_ptrs > 1) for(i = 0; i < data_xform_prop->dat_val_pointers->num_ptrs; i++) if(data_xform_prop->dat_val_pointers->ptr_dat_val[i]) - HDfree(data_xform_prop->dat_val_pointers->ptr_dat_val[i]); + H5MM_xfree(data_xform_prop->dat_val_pointers->ptr_dat_val[i]); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) diff --git a/test/dtypes.c b/test/dtypes.c index 326294f..984b6c6 100644 --- a/test/dtypes.c +++ b/test/dtypes.c @@ -1789,6 +1789,13 @@ test_compound_9(void) goto error; } /* end if */ + if(H5Dvlen_reclaim(dup_tid, space_id, H5P_DEFAULT, &rdata) < 0) { + H5_FAILED(); AT(); + printf("Can't reclaim read data\n"); + goto error; + } /* end if */ + rdata.str = NULL; + if(H5Dclose(dset_id) < 0) goto error; if(H5Tclose(cmpd_tid) < 0) @@ -1815,6 +1822,12 @@ test_compound_9(void) goto error; } /* end if */ + if((space_id = H5Dget_space(dset_id)) < 0) { + H5_FAILED(); AT(); + printf("Can't get space\n"); + goto error; + } /* end if */ + if((cmpd_tid = H5Dget_type(dset_id)) < 0) { H5_FAILED(); AT(); printf("cannot open dataset\n"); @@ -1842,10 +1855,19 @@ test_compound_9(void) goto error; } /* end if */ + if(H5Dvlen_reclaim(dup_tid, space_id, H5P_DEFAULT, &rdata) < 0) { + H5_FAILED(); AT(); + printf("Can't read data\n"); + goto error; + } /* end if */ + rdata.str = NULL; + if(rdata.str) HDfree(rdata.str); if(H5Dclose(dset_id) < 0) goto error; + if(H5Sclose(space_id) < 0) + goto error; if(H5Tclose(cmpd_tid) < 0) goto error; if(H5Tclose(dup_tid) < 0) @@ -2020,12 +2042,17 @@ test_compound_10(void) printf("incorrect VL read data\n"); goto error; } - - HDfree(t1); - HDfree(t2); - HDfree(wdata[i].str); - HDfree(rdata[i].str); } /* end for */ + if(H5Dvlen_reclaim(arr_tid, space_id, H5P_DEFAULT, &rdata) < 0) { + H5_FAILED(); AT(); + printf("Can't reclaim read data\n"); + goto error; + } /* end if */ + if(H5Dvlen_reclaim(arr_tid, space_id, H5P_DEFAULT, &wdata) < 0) { + H5_FAILED(); AT(); + printf("Can't reclaim read data\n"); + goto error; + } /* end if */ if(H5Dclose(dset_id) < 0) goto error; @@ -2090,6 +2117,8 @@ test_compound_11(void) hid_t big_tid, little_tid; /* Datatype IDs for type conversion */ hid_t big_tid2, little_tid2; /* Datatype IDs for type conversion */ hid_t opaq_src_tid, opaq_dst_tid; /* Datatype IDs for type conversion */ + hid_t space_id; /* Dataspace for buffer elements */ + hsize_t dim[1]; /* Dimensions for dataspace */ void *buf = NULL; /* Conversion buffer */ void *buf_orig = NULL; /* Copy of original conversion buffer */ void *bkg = NULL; /* Background buffer */ @@ -2138,6 +2167,13 @@ test_compound_11(void) /* Make copy of buffer before conversion */ HDmemcpy(buf_orig,buf,sizeof(big_t)*NTESTELEM); + dim[0] = NTESTELEM; + if((space_id = H5Screate_simple(1, dim, NULL)) < 0) { + H5_FAILED(); AT(); + printf("Can't create space\n"); + goto error; + } /* end if */ + /* Make copies of the 'big' and 'little' datatypes, so the type * conversion routine doesn't use the same ones this time and next time */ @@ -2169,8 +2205,12 @@ test_compound_11(void) (unsigned)u,((big_t *)buf_orig)[u].s1,(unsigned)u,((little_t *)buf)[u].s1); TEST_ERROR } /* end if */ - HDfree(((little_t *)buf)[u].s1); } /* end for */ + if(H5Dvlen_reclaim(little_tid2, space_id, H5P_DEFAULT, buf) < 0) { + H5_FAILED(); AT(); + printf("Can't reclaim data\n"); + goto error; + } /* end if */ /* Build source and destination types for conversion routine */ if((opaq_src_tid=H5Tcreate(H5T_OPAQUE, (size_t)4)) < 0) TEST_ERROR @@ -2209,8 +2249,12 @@ test_compound_11(void) (unsigned)u,((big_t *)buf_orig)[u].s1,(unsigned)u,((little_t *)buf)[u].s1); TEST_ERROR } /* end if */ - HDfree(((little_t *)buf)[u].s1); } /* end for */ + if(H5Dvlen_reclaim(little_tid, space_id, H5P_DEFAULT, buf) < 0) { + H5_FAILED(); AT(); + printf("Can't reclaim data\n"); + goto error; + } /* end if */ /* Unregister the conversion routine */ if(H5Tunregister(H5T_PERS_HARD, "opaq_test", opaq_src_tid, opaq_dst_tid, convert_opaque) < 0) TEST_ERROR @@ -2243,12 +2287,17 @@ test_compound_11(void) (unsigned)u,((big_t *)buf_orig)[u].s1,(unsigned)u,((little_t *)buf)[u].s1); TEST_ERROR } /* end if */ - HDfree(((little_t *)buf)[u].s1); } /* end for */ + if(H5Dvlen_reclaim(little_tid, space_id, H5P_DEFAULT, buf) < 0) { + H5_FAILED(); AT(); + printf("Can't reclaim data\n"); + goto error; + } /* end if */ /* Free everything */ for(u=0; udel_dir == FHEAP_DEL_FORWARD) if(tparam->drain_half == FHEAP_DEL_DRAIN_ALL) - str = HDstrdup("(all - forward)"); + str = H5MM_strdup("(all - forward)"); else - str = HDstrdup("(half, refill, all - forward)"); + str = H5MM_strdup("(half, refill, all - forward)"); else if(tparam->del_dir == FHEAP_DEL_REVERSE) if(tparam->drain_half == FHEAP_DEL_DRAIN_ALL) - str = HDstrdup("(all - reverse)"); + str = H5MM_strdup("(all - reverse)"); else - str = HDstrdup("(half, refill, all - reverse)"); + str = H5MM_strdup("(half, refill, all - reverse)"); else - str = HDstrdup("(all - deleting heap)"); + str = H5MM_strdup("(all - deleting heap)"); return(str); } /* get_del_string() */ diff --git a/test/file_image.c b/test/file_image.c index 52d0b28..6d1845f 100644 --- a/test/file_image.c +++ b/test/file_image.c @@ -156,8 +156,8 @@ error: if(H5Pclose(fapl_1) < 0) retval = 1; if(H5Pclose(fapl_2) < 0) retval = 1; HDfree(buffer); - HDfree(temp); - HDfree(temp2); + H5free_memory(temp); + H5free_memory(temp2); if(retval == 0) PASSED(); diff --git a/test/links.c b/test/links.c index 2886304..c87d2b6 100644 --- a/test/links.c +++ b/test/links.c @@ -136,7 +136,7 @@ const char *FILENAME[] = { #define H5L_DIM1 100 #define H5L_DIM2 100 -#define FILTER_FILESIZE_MAX_FRACTION 0.9F +#define FILTER_FILESIZE_MAX_FRACTION (double)0.9F /* Creation order macros */ #define CORDER_GROUP_NAME "corder_group" @@ -548,8 +548,27 @@ cklinks(hid_t fapl, hbool_t new_format) HDputs(" expected file location."); TEST_ERROR } /* end if */ + if(H5Lexists(file, "/", H5P_DEFAULT) != TRUE) FAIL_STACK_ERROR if(H5Lexists(file, "d1", H5P_DEFAULT) != TRUE) FAIL_STACK_ERROR if(H5Lexists(file, "grp1/hard", H5P_DEFAULT) != TRUE) FAIL_STACK_ERROR + if(H5Lexists(file, "/grp1", H5P_DEFAULT) != TRUE) FAIL_STACK_ERROR + if(H5Lexists(file, "/grp1/hard", H5P_DEFAULT) != TRUE) FAIL_STACK_ERROR + H5E_BEGIN_TRY { + status = H5Lexists(file, "no_grp1/hard", H5P_DEFAULT); + } H5E_END_TRY; + if(status >= 0) { + H5_FAILED(); + HDputs(" H5Lexists() should have failed for a path with missing components."); + TEST_ERROR + } /* end if */ + H5E_BEGIN_TRY { + status = H5Lexists(file, "/no_grp1/hard", H5P_DEFAULT); + } H5E_END_TRY; + if(status >= 0) { + H5_FAILED(); + HDputs(" H5Lexists() should have failed for a path with missing components."); + TEST_ERROR + } /* end if */ /* Symbolic link */ if(H5Oget_info_by_name(file, "grp1/soft", &oinfo2, H5P_DEFAULT) < 0) FAIL_STACK_ERROR @@ -10985,6 +11004,7 @@ link_info_by_idx(hid_t fapl) char filename[NAME_BUF_SIZE];/* File name */ char tmpname[NAME_BUF_SIZE]; /* Temporary link name */ unsigned u; /* Local index variable */ + ssize_t name_len; /* Length of name */ herr_t ret; /* Generic return value */ /* Loop over creating hard or soft links */ @@ -11026,9 +11046,9 @@ link_info_by_idx(hid_t fapl) } H5E_END_TRY; if(ret >= 0) TEST_ERROR H5E_BEGIN_TRY { - ret = H5Lget_name_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)0, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); + name_len = H5Lget_name_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)0, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); } H5E_END_TRY; - if(ret >= 0) TEST_ERROR + if(name_len >= 0) TEST_ERROR /* Create several links, up to limit of compact form */ for(u = 0; u < max_compact; u++) { @@ -11068,9 +11088,9 @@ link_info_by_idx(hid_t fapl) } H5E_END_TRY; if(ret >= 0) TEST_ERROR H5E_BEGIN_TRY { - ret = H5Lget_name_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); + name_len = H5Lget_name_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); } H5E_END_TRY; - if(ret >= 0) TEST_ERROR + if(name_len >= 0) TEST_ERROR /* Create more links, to push group into dense form */ for(; u < (max_compact * 2); u++) { @@ -11110,9 +11130,9 @@ link_info_by_idx(hid_t fapl) } H5E_END_TRY; if(ret >= 0) TEST_ERROR H5E_BEGIN_TRY { - ret = H5Lget_name_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); + name_len = H5Lget_name_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); } H5E_END_TRY; - if(ret >= 0) TEST_ERROR + if(name_len >= 0) TEST_ERROR /* Close the group */ if(H5Gclose(group_id) < 0) TEST_ERROR @@ -11167,6 +11187,7 @@ link_info_by_idx_old(hid_t fapl) char tmpname[NAME_BUF_SIZE]; /* Temporary link name */ char tmpval[NAME_BUF_SIZE]; /* Temporary link value */ unsigned u; /* Local index variable */ + ssize_t name_len; /* Length of name */ herr_t ret; /* Generic return value */ /* Loop over creating hard or soft links */ @@ -11278,9 +11299,9 @@ link_info_by_idx_old(hid_t fapl) } H5E_END_TRY; if(ret >= 0) TEST_ERROR H5E_BEGIN_TRY { - ret = H5Lget_name_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); + name_len = H5Lget_name_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); } H5E_END_TRY; - if(ret >= 0) TEST_ERROR + if(name_len >= 0) TEST_ERROR /* Verify state of group */ if(H5G__has_stab_test(group_id) != TRUE) TEST_ERROR @@ -12038,7 +12059,7 @@ link_iterate_check(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order, iter_info->order = order; iter_info->stop = -1; iter_info->ncalled = 0; - iter_info->curr = order != H5_ITER_DEC ? skip : ((max_links - 1) - skip); + iter_info->curr = (int64_t)(order != H5_ITER_DEC ? skip : ((max_links - 1) - skip)); HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit); if(H5Literate(group_id, idx_type, order, &skip, link_iterate_cb, iter_info) < 0) TEST_ERROR @@ -12066,11 +12087,11 @@ link_iterate_check(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order, #ifndef H5_NO_DEPRECATED_SYMBOLS /* Skip over some links in group, with H5Giterate */ - iter_info->nskipped = gskip = max_links / 2; + iter_info->nskipped = (unsigned)(gskip = (int)(max_links / 2)); iter_info->order = order; iter_info->stop = -1; iter_info->ncalled = 0; - iter_info->curr = order != H5_ITER_DEC ? (unsigned)gskip : ((max_links - 1) - gskip); + iter_info->curr = order != H5_ITER_DEC ? (unsigned)gskip : ((max_links - 1) - (unsigned)gskip); HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit); if(H5Giterate(group_id, ".", &gskip, group_iterate_cb, iter_info) < 0) TEST_ERROR @@ -12111,7 +12132,7 @@ link_iterate_check(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order, #ifndef H5_NO_DEPRECATED_SYMBOLS /* Iterate over links in group, stopping in the middle, with H5Giterate() */ - iter_info->nskipped = gskip = 0; + iter_info->nskipped = (unsigned)(gskip = 0); iter_info->order = order; iter_info->stop = 3; iter_info->ncalled = 0; @@ -12468,7 +12489,7 @@ link_iterate_old_check(hid_t group_id, H5_iter_order_t order, #ifndef H5_NO_DEPRECATED_SYMBOLS /* Iterate over links in group, with H5Giterate */ - iter_info->nskipped = gskip = 0; + iter_info->nskipped = (unsigned)(gskip = 0); iter_info->order = order; iter_info->stop = -1; iter_info->ncalled = 0; @@ -12488,7 +12509,7 @@ link_iterate_old_check(hid_t group_id, H5_iter_order_t order, iter_info->order = order; iter_info->stop = -1; iter_info->ncalled = 0; - iter_info->curr = order != H5_ITER_DEC ? skip : ((max_links - 1) - skip); + iter_info->curr = (int64_t)(order != H5_ITER_DEC ? skip : ((max_links - 1) - skip)); HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit); if(H5Literate(group_id, H5_INDEX_NAME, order, &skip, link_iterate_old_cb, iter_info) < 0) TEST_ERROR @@ -12516,11 +12537,11 @@ link_iterate_old_check(hid_t group_id, H5_iter_order_t order, #ifndef H5_NO_DEPRECATED_SYMBOLS /* Skip over some links in group, with H5Giterate */ - iter_info->nskipped = gskip = max_links / 2; + iter_info->nskipped = (unsigned)(gskip = (int)(max_links / 2)); iter_info->order = order; iter_info->stop = -1; iter_info->ncalled = 0; - iter_info->curr = order != H5_ITER_DEC ? (unsigned)gskip : ((max_links - 1) - gskip); + iter_info->curr = order != H5_ITER_DEC ? (unsigned)gskip : ((max_links - 1) - (unsigned)gskip); HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit); if(H5Giterate(group_id, ".", &gskip, group_iterate_old_cb, iter_info) < 0) TEST_ERROR @@ -12561,7 +12582,7 @@ link_iterate_old_check(hid_t group_id, H5_iter_order_t order, #ifndef H5_NO_DEPRECATED_SYMBOLS /* Iterate over links in group, stopping in the middle, with H5Giterate() */ - iter_info->nskipped = gskip = 0; + iter_info->nskipped = (unsigned)(gskip = 0); iter_info->order = order; iter_info->stop = 3; iter_info->ncalled = 0; diff --git a/test/objcopy.c b/test/objcopy.c index f3806cd..cd978f2 100644 --- a/test/objcopy.c +++ b/test/objcopy.c @@ -197,7 +197,7 @@ addr_insert(H5O_info_t *oi) * *------------------------------------------------------------------------- */ -static hbool_t +static H5_ATTR_PURE hbool_t addr_lookup(H5O_info_t *oi) { size_t n; @@ -512,8 +512,12 @@ test_copy_attach_attribute_vl(hid_t loc_id) ret_value = 0; done: - if(tid >0 && sid > 0) - H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf); + if(tid >0 && sid > 0) { + hid_t dxpl_id = H5Pcreate(H5P_DATASET_XFER); + H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL); + H5Dvlen_reclaim(tid, sid, dxpl_id, buf); + H5Pclose(dxpl_id); + } if(sid > 0) H5Sclose(sid); if(tid > 0) @@ -4028,6 +4032,7 @@ test_copy_dataset_contig_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_ hid_t tid = -1; /* Datatype ID */ hid_t sid = -1; /* Dataspace ID */ hid_t did = -1, did2 = -1; /* Dataset IDs */ + hid_t dxpl_id = -1; /* Dataset transfer property list ID */ unsigned int i, j; /* Local index variables */ hsize_t dim1d[1]; /* Dataset dimensions */ hvl_t buf[DIM_SIZE_1]; /* Buffer for writing data */ @@ -4111,7 +4116,12 @@ test_copy_dataset_contig_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_ /* Reclaim vlen buffer */ - if(H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf) < 0) TEST_ERROR + if(H5Tdetect_class(tid, H5T_VLEN) == TRUE) { + if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR + if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR + if(H5Dvlen_reclaim(tid, sid, dxpl_id, buf) < 0) TEST_ERROR + if(H5Pclose(dxpl_id) < 0) TEST_ERROR + } /* end if */ /* close datatype */ if(H5Tclose(tid) < 0) TEST_ERROR @@ -4127,6 +4137,7 @@ error: H5Dclose(did2); H5Dclose(did); H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf); + H5Pclose(dxpl_id); H5Tclose(tid); H5Sclose(sid); H5Fclose(fid_dst); @@ -4158,6 +4169,7 @@ test_copy_dataset_chunked_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid hid_t sid = -1; /* Dataspace ID */ hid_t pid = -1; /* Dataset creation property list ID */ hid_t did = -1, did2 = -1; /* Dataset IDs */ + hid_t dxpl_id = -1; /* Dataset transfer property list ID */ unsigned int i, j; /* Local index variables */ hsize_t dim1d[1]; /* Dataset dimensions */ hsize_t chunk_dim1d[1] = {CHUNK_SIZE_1}; /* Chunk dimensions */ @@ -4250,7 +4262,12 @@ test_copy_dataset_chunked_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid /* Reclaim vlen buffer */ - if(H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf) < 0) TEST_ERROR + if(H5Tdetect_class(tid, H5T_VLEN) == TRUE) { + if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR + if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR + if(H5Dvlen_reclaim(tid, sid, dxpl_id, buf) < 0) TEST_ERROR + if(H5Pclose(dxpl_id) < 0) TEST_ERROR + } /* end if */ /* close datatype */ if(H5Tclose(tid) < 0) TEST_ERROR @@ -4266,6 +4283,8 @@ error: H5Dclose(did2); H5Dclose(did); H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf); + H5Pclose(dxpl_id); + H5Pclose(pid); H5Tclose(tid); H5Sclose(sid); H5Fclose(fid_dst); @@ -4297,6 +4316,7 @@ test_copy_dataset_compact_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid hid_t sid = -1; /* Dataspace ID */ hid_t pid = -1; /* Dataset creation property list ID */ hid_t did = -1, did2 = -1; /* Dataset IDs */ + hid_t dxpl_id = -1; /* Dataset transfer property list ID */ unsigned int i, j; /* Local index variables */ hsize_t dim1d[1]; /* Dataset dimensions */ hvl_t buf[DIM_SIZE_1]; /* Buffer for writing data */ @@ -4387,7 +4407,12 @@ test_copy_dataset_compact_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid /* Reclaim vlen buffer */ - if(H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf) < 0) TEST_ERROR + if(H5Tdetect_class(tid, H5T_VLEN) == TRUE) { + if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR + if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR + if(H5Dvlen_reclaim(tid, sid, dxpl_id, buf) < 0) TEST_ERROR + if(H5Pclose(dxpl_id) < 0) TEST_ERROR + } /* end if */ /* close datatype */ if(H5Tclose(tid) < 0) TEST_ERROR @@ -4403,6 +4428,7 @@ error: H5Dclose(did2); H5Dclose(did); H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf); + H5Pclose(dxpl_id); H5Tclose(tid); H5Sclose(sid); H5Fclose(fid_dst); @@ -4550,6 +4576,7 @@ test_copy_dataset_compressed_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t tid = -1; /* Datatype ID */ hid_t pid = -1; /* Dataset creation property list ID */ hid_t did = -1, did2 = -1; /* Dataset IDs */ + hid_t dxpl_id = -1; /* Dataset transfer property list ID */ hsize_t dim2d[2]; /* Dataset dimensions */ hsize_t chunk_dim2d[2] ={CHUNK_SIZE_1, CHUNK_SIZE_2}; /* Chunk dimensions */ hvl_t buf[DIM_SIZE_1][DIM_SIZE_2]; /* Buffer for writing data */ @@ -4649,7 +4676,12 @@ test_copy_dataset_compressed_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, if(H5Fclose(fid_dst) < 0) TEST_ERROR /* Reclaim vlen buffer */ - if(H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf) < 0) TEST_ERROR + if(H5Tdetect_class(tid, H5T_VLEN) == TRUE) { + if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR + if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR + if(H5Dvlen_reclaim(tid, sid, dxpl_id, buf) < 0) TEST_ERROR + if(H5Pclose(dxpl_id) < 0) TEST_ERROR + } /* end if */ /* close datatype */ if(H5Tclose(tid) < 0) TEST_ERROR @@ -4668,6 +4700,7 @@ error: H5Dclose(did); H5Pclose(pid); H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf); + H5Pclose(dxpl_id); H5Tclose(tid); H5Sclose(sid); H5Fclose(fid_dst); @@ -6357,6 +6390,7 @@ test_copy_dataset_compact_named_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fap hid_t sid = -1; /* Dataspace ID */ hid_t pid = -1; /* Dataset creation property list ID */ hid_t did = -1, did2 = -1; /* Dataset IDs */ + hid_t dxpl_id = -1; /* Dataset transfer property list ID */ unsigned int i, j; /* Local index variables */ hsize_t dim1d[1]; /* Dataset dimensions */ hvl_t buf[DIM_SIZE_1]; /* Buffer for writing data */ @@ -6456,7 +6490,12 @@ test_copy_dataset_compact_named_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fap /* Reclaim vlen buffer */ - if(H5Dvlen_reclaim(tid_copy, sid, H5P_DEFAULT, buf) < 0) TEST_ERROR + if(H5Tdetect_class(tid_copy, H5T_VLEN) == TRUE) { + if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR + if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR + if(H5Dvlen_reclaim(tid_copy, sid, dxpl_id, buf) < 0) TEST_ERROR + if(H5Pclose(dxpl_id) < 0) TEST_ERROR + } /* end if */ /* close datatype */ if(H5Tclose(tid_copy) < 0) TEST_ERROR @@ -6473,6 +6512,7 @@ error: H5Dclose(did2); H5Dclose(did); H5Dvlen_reclaim(tid_copy, sid, H5P_DEFAULT, buf); + H5Pclose(dxpl_id); H5Tclose(tid); H5Tclose(tid_copy); H5Sclose(sid); @@ -6504,6 +6544,7 @@ test_copy_dataset_contig_named_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl hid_t tid = -1, tid_copy=-1; /* Datatype ID */ hid_t sid = -1; /* Dataspace ID */ hid_t did = -1, did2 = -1; /* Dataset IDs */ + hid_t dxpl_id = -1; /* Dataset transfer property list ID */ unsigned int i, j; /* Local index variables */ hsize_t dim1d[1]; /* Dataset dimensions */ hvl_t buf[DIM_SIZE_1]; /* Buffer for writing data */ @@ -6596,7 +6637,12 @@ test_copy_dataset_contig_named_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl /* Reclaim vlen buffer */ - if(H5Dvlen_reclaim(tid_copy, sid, H5P_DEFAULT, buf) < 0) TEST_ERROR + if(H5Tdetect_class(tid_copy, H5T_VLEN) == TRUE) { + if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR + if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR + if(H5Dvlen_reclaim(tid_copy, sid, dxpl_id, buf) < 0) TEST_ERROR + if(H5Pclose(dxpl_id) < 0) TEST_ERROR + } /* end if */ /* close datatype */ if(H5Tclose(tid_copy) < 0) TEST_ERROR @@ -6612,6 +6658,7 @@ error: H5Dclose(did2); H5Dclose(did); H5Dvlen_reclaim(tid_copy, sid, H5P_DEFAULT, buf); + H5Pclose(dxpl_id); H5Tclose(tid); H5Tclose(tid_copy); H5Sclose(sid); @@ -6644,6 +6691,7 @@ test_copy_dataset_chunked_named_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fap hid_t sid = -1; /* Dataspace ID */ hid_t pid = -1; /* Dataset creation property list ID */ hid_t did = -1, did2 = -1; /* Dataset IDs */ + hid_t dxpl_id = -1; /* Dataset transfer property list ID */ unsigned int i, j; /* Local index variables */ hsize_t dim1d[1]; /* Dataset dimensions */ hvl_t buf[DIM_SIZE_1]; /* Buffer for writing data */ @@ -6744,7 +6792,12 @@ test_copy_dataset_chunked_named_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fap /* Reclaim vlen buffer */ - if(H5Dvlen_reclaim(tid_copy, sid, H5P_DEFAULT, buf) < 0) TEST_ERROR + if(H5Tdetect_class(tid_copy, H5T_VLEN) == TRUE) { + if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR + if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR + if(H5Dvlen_reclaim(tid_copy, sid, dxpl_id, buf) < 0) TEST_ERROR + if(H5Pclose(dxpl_id) < 0) TEST_ERROR + } /* end if */ /* close datatype */ if(H5Tclose(tid_copy) < 0) TEST_ERROR @@ -6761,6 +6814,7 @@ error: H5Dclose(did2); H5Dclose(did); H5Dvlen_reclaim(tid_copy, sid, H5P_DEFAULT, buf); + H5Pclose(dxpl_id); H5Tclose(tid); H5Tclose(tid_copy); H5Sclose(sid); @@ -6793,6 +6847,7 @@ test_copy_dataset_compressed_named_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_ hid_t sid = -1; /* Dataspace ID */ hid_t pid = -1; /* Dataset creation property list ID */ hid_t did = -1, did2 = -1; /* Dataset IDs */ + hid_t dxpl_id = -1; /* Dataset transfer property list ID */ unsigned int i, j; /* Local index variables */ hsize_t dim1d[1]; /* Dataset dimensions */ hvl_t buf[DIM_SIZE_1]; /* Buffer for writing data */ @@ -6894,7 +6949,12 @@ test_copy_dataset_compressed_named_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_ /* Reclaim vlen buffer */ - if(H5Dvlen_reclaim(tid_copy, sid, H5P_DEFAULT, buf) < 0) TEST_ERROR + if(H5Tdetect_class(tid_copy, H5T_VLEN) == TRUE) { + if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR + if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR + if(H5Dvlen_reclaim(tid_copy, sid, dxpl_id, buf) < 0) TEST_ERROR + if(H5Pclose(dxpl_id) < 0) TEST_ERROR + } /* end if */ /* close datatype */ if(H5Tclose(tid_copy) < 0) TEST_ERROR @@ -6911,6 +6971,7 @@ error: H5Dclose(did2); H5Dclose(did); H5Dvlen_reclaim(tid_copy, sid, H5P_DEFAULT, buf); + H5Pclose(dxpl_id); H5Tclose(tid); H5Tclose(tid_copy); H5Sclose(sid); @@ -6943,6 +7004,7 @@ test_copy_dataset_compact_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t sid = -1; /* Dataspace ID */ hid_t pid = -1; /* Dataset creation property list ID */ hid_t did = -1, did2 = -1; /* Dataset IDs */ + hid_t dxpl_id = -1; /* Dataset transfer property list ID */ unsigned int i, j, k; /* Local index variables */ hsize_t dim1d[1]; /* Dataset dimensions */ hvl_t buf[DIM_SIZE_1]; /* Buffer for writing data */ @@ -7049,7 +7111,12 @@ test_copy_dataset_compact_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, if(H5Fclose(fid_dst) < 0) TEST_ERROR /* Reclaim vlen buffer */ - if(H5Dvlen_reclaim(tid2, sid, H5P_DEFAULT, buf) < 0) TEST_ERROR + if(H5Tdetect_class(tid2, H5T_VLEN) == TRUE) { + if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR + if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR + if(H5Dvlen_reclaim(tid2, sid, dxpl_id, buf) < 0) TEST_ERROR + if(H5Pclose(dxpl_id) < 0) TEST_ERROR + } /* end if */ /* close datatype */ if(H5Tclose(tid) < 0) TEST_ERROR @@ -7066,6 +7133,8 @@ error: H5Dclose(did2); H5Dclose(did); H5Dvlen_reclaim(tid2, sid, H5P_DEFAULT, buf); + H5Pclose(dxpl_id); + H5Pclose(pid); H5Tclose(tid); H5Tclose(tid2); H5Sclose(sid); @@ -7098,6 +7167,7 @@ test_copy_dataset_contig_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, h hid_t sid = -1; /* Dataspace ID */ hid_t pid = -1; /* Dataset creation property list ID */ hid_t did = -1, did2 = -1; /* Dataset IDs */ + hid_t dxpl_id = -1; /* Dataset transfer property list ID */ unsigned int i, j, k; /* Local index variables */ hsize_t dim1d[1]; /* Dataset dimensions */ hvl_t buf[DIM_SIZE_1]; /* Buffer for writing data */ @@ -7203,7 +7273,12 @@ test_copy_dataset_contig_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, h if(H5Fclose(fid_dst) < 0) TEST_ERROR /* Reclaim vlen buffer */ - if(H5Dvlen_reclaim(tid2, sid, H5P_DEFAULT, buf) < 0) TEST_ERROR + if(H5Tdetect_class(tid2, H5T_VLEN) == TRUE) { + if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR + if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR + if(H5Dvlen_reclaim(tid2, sid, dxpl_id, buf) < 0) TEST_ERROR + if(H5Pclose(dxpl_id) < 0) TEST_ERROR + } /* end if */ /* close datatype */ if(H5Tclose(tid) < 0) TEST_ERROR @@ -7220,6 +7295,8 @@ error: H5Dclose(did2); H5Dclose(did); H5Dvlen_reclaim(tid2, sid, H5P_DEFAULT, buf); + H5Pclose(dxpl_id); + H5Pclose(pid); H5Tclose(tid); H5Tclose(tid2); H5Sclose(sid); @@ -7252,6 +7329,7 @@ test_copy_dataset_chunked_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t sid = -1; /* Dataspace ID */ hid_t pid = -1; /* Dataset creation property list ID */ hid_t did = -1, did2 = -1; /* Dataset IDs */ + hid_t dxpl_id = -1; /* Dataset transfer property list ID */ unsigned int i, j, k; /* Local index variables */ hsize_t dim1d[1]; /* Dataset dimensions */ hvl_t buf[DIM_SIZE_1]; /* Buffer for writing data */ @@ -7359,7 +7437,12 @@ test_copy_dataset_chunked_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, /* Reclaim vlen buffer */ - if(H5Dvlen_reclaim(tid2, sid, H5P_DEFAULT, buf) < 0) TEST_ERROR + if(H5Tdetect_class(tid2, H5T_VLEN) == TRUE) { + if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR + if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR + if(H5Dvlen_reclaim(tid2, sid, dxpl_id, buf) < 0) TEST_ERROR + if(H5Pclose(dxpl_id) < 0) TEST_ERROR + } /* end if */ /* close datatype */ if(H5Tclose(tid) < 0) TEST_ERROR @@ -7377,6 +7460,7 @@ error: H5Dclose(did2); H5Dclose(did); H5Dvlen_reclaim(tid2, sid, H5P_DEFAULT, buf); + H5Pclose(dxpl_id); H5Tclose(tid); H5Tclose(tid2); H5Sclose(sid); @@ -7409,6 +7493,7 @@ test_copy_dataset_compressed_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fap hid_t sid = -1; /* Dataspace ID */ hid_t pid = -1; /* Dataset creation property list ID */ hid_t did = -1, did2 = -1; /* Dataset IDs */ + hid_t dxpl_id = -1; /* Dataset transfer property list ID */ unsigned int i, j, k; /* Local index variables */ hsize_t dim1d[1]; /* Dataset dimensions */ hvl_t buf[DIM_SIZE_1]; /* Buffer for writing data */ @@ -7516,7 +7601,12 @@ test_copy_dataset_compressed_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fap /* Reclaim vlen buffer */ - if(H5Dvlen_reclaim(tid2, sid, H5P_DEFAULT, buf) < 0) TEST_ERROR + if(H5Tdetect_class(tid2, H5T_VLEN) == TRUE) { + if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR + if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR + if(H5Dvlen_reclaim(tid2, sid, dxpl_id, buf) < 0) TEST_ERROR + if(H5Pclose(dxpl_id) < 0) TEST_ERROR + } /* end if */ /* close datatype */ if(H5Tclose(tid) < 0) TEST_ERROR @@ -7534,6 +7624,7 @@ error: H5Dclose(did2); H5Dclose(did); H5Dvlen_reclaim(tid2, sid, H5P_DEFAULT, buf); + H5Pclose(dxpl_id); H5Tclose(tid); H5Tclose(tid2); H5Sclose(sid); @@ -7576,6 +7667,7 @@ test_copy_dataset_contig_cmpd_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t sid = -1; /* Dataspace ID */ hid_t did = -1; /* Dataset ID */ hid_t did2 = -1; /* Dataset ID */ + hid_t dxpl_id = -1; /* Dataset transfer property list ID */ unsigned int i, j; /* Local index variables */ hsize_t dim1d[1]; /* Dataset dimensions */ cmpd_vl_t buf[DIM_SIZE_1]; /* Buffer for writing data */ @@ -7665,7 +7757,12 @@ test_copy_dataset_contig_cmpd_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, /* Reclaim vlen buffer */ - if(H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf) < 0) TEST_ERROR + if(H5Tdetect_class(tid, H5T_VLEN) == TRUE) { + if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR + if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR + if(H5Dvlen_reclaim(tid, sid, dxpl_id, buf) < 0) TEST_ERROR + if(H5Pclose(dxpl_id) < 0) TEST_ERROR + } /* end if */ /* close datatype */ if(H5Tclose(tid2) < 0) TEST_ERROR @@ -7682,6 +7779,7 @@ error: H5Dclose(did2); H5Dclose(did); H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf); + H5Pclose(dxpl_id); H5Tclose(tid2); H5Tclose(tid); H5Sclose(sid); @@ -7714,6 +7812,7 @@ test_copy_dataset_chunked_cmpd_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl hid_t sid = -1; /* Dataspace ID */ hid_t pid = -1; /* Dataset creation property list ID */ hid_t did = -1, did2 = -1; /* Dataset IDs */ + hid_t dxpl_id = -1; /* Dataset transfer property list ID */ unsigned int i, j; /* Local index variables */ hsize_t dim1d[1]; /* Dataset dimensions */ hsize_t chunk_dim1d[1] = {CHUNK_SIZE_1}; /* Chunk dimensions */ @@ -7811,7 +7910,12 @@ test_copy_dataset_chunked_cmpd_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl /* Reclaim vlen buffer */ - if(H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf) < 0) TEST_ERROR + if(H5Tdetect_class(tid, H5T_VLEN) == TRUE) { + if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR + if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR + if(H5Dvlen_reclaim(tid, sid, dxpl_id, buf) < 0) TEST_ERROR + if(H5Pclose(dxpl_id) < 0) TEST_ERROR + } /* end if */ /* close datatype */ if(H5Tclose(tid2) < 0) TEST_ERROR @@ -7828,6 +7932,8 @@ error: H5Dclose(did2); H5Dclose(did); H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf); + H5Pclose(dxpl_id); + H5Pclose(pid); H5Tclose(tid2); H5Tclose(tid); H5Sclose(sid); @@ -7860,6 +7966,7 @@ test_copy_dataset_compact_cmpd_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl hid_t sid = -1; /* Dataspace ID */ hid_t pid = -1; /* Dataset creation property list ID */ hid_t did = -1, did2 = -1; /* Dataset IDs */ + hid_t dxpl_id = -1; /* Dataset transfer property list ID */ unsigned int i, j; /* Local index variables */ hsize_t dim1d[1]; /* Dataset dimensions */ cmpd_vl_t buf[DIM_SIZE_1]; /* Buffer for writing data */ @@ -7956,7 +8063,12 @@ test_copy_dataset_compact_cmpd_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl /* Reclaim vlen buffer */ - if(H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf) < 0) TEST_ERROR + if(H5Tdetect_class(tid, H5T_VLEN) == TRUE) { + if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR + if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR + if(H5Dvlen_reclaim(tid, sid, dxpl_id, buf) < 0) TEST_ERROR + if(H5Pclose(dxpl_id) < 0) TEST_ERROR + } /* end if */ /* close datatype */ if(H5Tclose(tid2) < 0) TEST_ERROR @@ -7973,6 +8085,8 @@ error: H5Dclose(did2); H5Dclose(did); H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf); + H5Pclose(dxpl_id); + H5Pclose(pid); H5Tclose(tid2); H5Tclose(tid); H5Sclose(sid); diff --git a/test/tgenprop.c b/test/tgenprop.c index c4f3a3f..b670c0d 100644 --- a/test/tgenprop.c +++ b/test/tgenprop.c @@ -1780,7 +1780,7 @@ test_genprop_path(void) CHECK_PTR(path, "H5P_get_class_path_test"); if(HDstrcmp(path,CLASS1_PATH)!=0) TestErrPrintf("Class names don't match!, path=%s, CLASS1_PATH=%s\n",path,CLASS1_PATH); - HDfree(path); + H5free_memory(path); /* Create another new generic class, derived from first class */ cid2 = H5Pcreate_class(cid1,CLASS2_NAME, NULL, NULL, NULL, NULL, NULL, NULL); @@ -1805,7 +1805,7 @@ test_genprop_path(void) VERIFY(ret, 1, "H5Pequal"); /* Release the path string */ - HDfree(path); + H5free_memory(path); /* Close class */ ret = H5Pclose_class(cid3); diff --git a/test/tmisc.c b/test/tmisc.c index 1298f6b..011486a 100644 --- a/test/tmisc.c +++ b/test/tmisc.c @@ -462,7 +462,8 @@ static void test_misc2_write_attribute(void) ret = H5Aread(att1, type, &data_check); CHECK(ret, FAIL, "H5Aread"); - HDfree(data_check.string); + ret = H5Dvlen_reclaim(type, dataspace, H5P_DEFAULT, &data_check); + CHECK(ret, FAIL, "H5Dvlen_reclaim"); ret = H5Aclose(att1); CHECK(ret, FAIL, "HAclose"); @@ -487,7 +488,8 @@ static void test_misc2_write_attribute(void) ret = H5Aread(att2, type, &data_check); CHECK(ret, FAIL, "H5Aread"); - HDfree(data_check.string); + ret = H5Dvlen_reclaim(type, dataspace, H5P_DEFAULT, &data_check); + CHECK(ret, FAIL, "H5Dvlen_reclaim"); ret = H5Aclose(att2); CHECK(ret, FAIL, "HAclose"); @@ -514,6 +516,7 @@ static void test_misc2_read_attribute(const char *filename, const char *att_name { hid_t file, root, att; hid_t type; + hid_t space; herr_t ret; misc2_struct data_check; @@ -528,10 +531,17 @@ static void test_misc2_read_attribute(const char *filename, const char *att_name att = H5Aopen(root, att_name, H5P_DEFAULT); CHECK(att, FAIL, "H5Aopen"); + space = H5Aget_space(att); + CHECK(space, FAIL, "H5Aget_space"); + ret = H5Aread(att, type, &data_check); CHECK(ret, FAIL, "H5Aread"); - HDfree(data_check.string); + ret = H5Dvlen_reclaim(type, space, H5P_DEFAULT, &data_check); + CHECK(ret, FAIL, "H5Dvlen_reclaim"); + + ret = H5Sclose(space); + CHECK(ret, FAIL, "H5Sclose"); ret = H5Aclose(att); CHECK(ret, FAIL, "H5Aclose"); diff --git a/test/tvlstr.c b/test/tvlstr.c index 02bd59d..dbc3083 100644 --- a/test/tvlstr.c +++ b/test/tvlstr.c @@ -604,7 +604,7 @@ static void test_write_vl_string_attribute(void) if(HDstrcmp(string_att_check,string_att) != 0) TestErrPrintf("VL string attributes don't match!, string_att=%s, string_att_check=%s\n",string_att,string_att_check); - HDfree(string_att_check); + H5free_memory(string_att_check); string_att_check = NULL; ret = H5Aclose(att); @@ -626,7 +626,7 @@ static void test_write_vl_string_attribute(void) if(HDstrcmp(string_att_check,string_att_write) != 0) TestErrPrintf("VL string attributes don't match!, string_att_write=%s, string_att_check=%s\n",string_att_write,string_att_check); - HDfree(string_att_check); + H5free_memory(string_att_check); string_att_check = NULL; /* The attribute string written is freed below, in the test_read_vl_string_attribute() test */ @@ -687,7 +687,7 @@ static void test_read_vl_string_attribute(void) if(HDstrcmp(string_att_check,string_att) != 0) TestErrPrintf("VL string attributes don't match!, string_att=%s, string_att_check=%s\n",string_att,string_att_check); - HDfree(string_att_check); + H5free_memory(string_att_check); string_att_check = NULL; ret = H5Aclose(att); @@ -704,7 +704,7 @@ static void test_read_vl_string_attribute(void) if(HDstrcmp(string_att_check,string_att_write) != 0) TestErrPrintf("VL string attributes don't match!, string_att_write=%s, string_att_check=%s\n",string_att_write,string_att_check); - HDfree(string_att_check); + H5free_memory(string_att_check); string_att_check = NULL; } @@ -762,7 +762,8 @@ static void read_scalar_dset(hid_t file, hid_t type, hid_t space, char *name, ch if(HDstrcmp(data, data_read)) TestErrPrintf("Expected %s for dataset %s but read %s\n", data, name, data_read); - HDfree(data_read); + ret = H5Dvlen_reclaim(type, space, H5P_DEFAULT, &data_read); + CHECK(ret, FAIL, "H5Dvlen_reclaim"); } /**************************************************************** diff --git a/tools/h5ls/h5ls.c b/tools/h5ls/h5ls.c index cce5f3d..98468c9 100644 --- a/tools/h5ls/h5ls.c +++ b/tools/h5ls/h5ls.c @@ -973,7 +973,7 @@ print_enum_type(h5tools_str_t *buffer, hid_t type, int ind) /* Release resources */ for(i = 0; i < (unsigned)nmembs; i++) - HDfree(name[i]); + H5free_memory(name[i]); HDfree(name); HDfree(value); } @@ -1856,13 +1856,10 @@ dataset_list2(hid_t dset, const char H5_ATTR_UNUSED *name) if (vmaps) { size_t next; - ssize_t ssize_out; h5tools_str_append(&buffer, " %-10s {%ld} Source {\n", "Maps:", vmaps); for (next = 0; next < (unsigned) vmaps; next++) { - ssize_out = H5Pget_virtual_filename(dcpl, next, NULL, 0); H5Pget_virtual_filename(dcpl, next, f_name, sizeof(f_name)); - ssize_out = H5Pget_virtual_dsetname(dcpl, next, NULL, 0); H5Pget_virtual_dsetname(dcpl, next, dset_name, sizeof(dset_name)); h5tools_str_append(&buffer, " %-10s ", " "); print_string(&buffer, f_name, TRUE); -- cgit v0.12 From 42bf0e2136a60a9dc18a2a2a5fb029fa5a0d6562 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Fri, 1 Jan 2016 20:58:18 -0500 Subject: [svn-r28765] Description: Bump the nunmber of v2 B-tree records for the random 4-level B-tree update test by another 25,000 records. Tested on: MacOSX/64 10.11.2 (amazon) w/serial & parallel (Too minor to require h5committest) --- test/btree2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/btree2.c b/test/btree2.c index b0c0ac3..3278b67 100644 --- a/test/btree2.c +++ b/test/btree2.c @@ -38,7 +38,7 @@ const char *FILENAME[] = { #define INSERT_SPLIT_ROOT_NREC 63 #define INSERT_SPLIT_ROOT_NREC_REC 64 #define INSERT_MANY (1000 * 1000) -#define INSERT_MANY_REC (2650 * 1000) +#define INSERT_MANY_REC (2675 * 1000) #define FIND_MANY (INSERT_MANY / 100) #define FIND_MANY_REC (INSERT_MANY_REC / 100) #define FIND_NEIGHBOR 2000 -- cgit v0.12 From d4f3d93b8d9188548407453e10df12dc9ba0480f Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Sat, 2 Jan 2016 20:03:08 -0500 Subject: [svn-r28769] Description: More memory cleanups and leak elimination. Tested on: MacOSX/64 10.11.2 (amazon) w/serial & parallel (h5committest forthcoming) --- src/H5Dcompact.c | 5 +---- src/H5Eint.c | 5 +++++ tools/h5repack/h5repacktst.c | 2 ++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/H5Dcompact.c b/src/H5Dcompact.c index ebe75bd..df2a740 100644 --- a/src/H5Dcompact.c +++ b/src/H5Dcompact.c @@ -440,12 +440,9 @@ H5D__compact_copy(H5F_t *f_src, H5O_storage_compact_t *storage_src, H5F_t *f_dst HDassert(storage_src); HDassert(f_dst); HDassert(storage_dst); + HDassert(storage_dst->buf); HDassert(dt_src); - /* Allocate space for destination data */ - if(NULL == (storage_dst->buf = H5MM_malloc(storage_src->size))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "unable to allocate memory for compact dataset") - /* Create datatype ID for src datatype, so it gets freed */ if((tid_src = H5I_register(H5I_DATATYPE, dt_src, FALSE)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register source file datatype") diff --git a/src/H5Eint.c b/src/H5Eint.c index 6e84a09..6ed405f 100644 --- a/src/H5Eint.c +++ b/src/H5Eint.c @@ -743,8 +743,13 @@ H5E_printf_stack(H5E_t *estack, const char *file, const char *func, unsigned lin done: if(va_started) va_end(ap); +#ifdef H5_HAVE_VASPRINTF + if(tmp) + HDfree(tmp); +#else /* H5_HAVE_VASPRINTF */ if(tmp) H5MM_xfree(tmp); +#endif /* H5_HAVE_VASPRINTF */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5E_printf_stack() */ diff --git a/tools/h5repack/h5repacktst.c b/tools/h5repack/h5repacktst.c index 3959300..972014d 100644 --- a/tools/h5repack/h5repacktst.c +++ b/tools/h5repack/h5repacktst.c @@ -1554,6 +1554,8 @@ int main (void) puts("All h5repack tests passed."); + h5tools_close(); + return 0; error: -- cgit v0.12 From f8465bd1243d16783b4df44b40193d8f5137a781 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Sun, 3 Jan 2016 09:22:49 -0500 Subject: [svn-r28773] Description: Clear memory for shared message info when "deferring" and using memory checker, so valgrind doesn't whine. Tested on: MacOSX/64 10.11.2 (amazon) w/serial & parallel (h5committest forthcoming) --- src/H5SM.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/H5SM.c b/src/H5SM.c index 4a562dd..413ad1f 100644 --- a/src/H5SM.c +++ b/src/H5SM.c @@ -1375,11 +1375,23 @@ H5SM_write_mesg(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, } /* end else */ } /* end else */ - if(found) + if(found) { /* If the message was found, it's shared in the heap (now). Set up a * shared message so we can mark it as shared. */ shared.type = H5O_SHARE_TYPE_SOHM; + +#ifdef H5_USING_MEMCHECKER + /* Reset the shared message payload if deferring. This doesn't matter + * in the long run since the payload will get overwritten when the + * non-deferred call to this routine occurs, but it stops memory + * checkers like valgrind from whining when the partially initialized + * shared message is serialized. -QAK + */ + if(defer) + HDmemset(&shared.u, 0, sizeof(shared.u)); +#endif /* H5_USING_MEMCHECKER */ + } /* end if */ else { htri_t share_in_ohdr; /* Whether the new message can be shared in another object's header */ -- cgit v0.12 From f017eb6fc09d74aa83eb5391028be5fd12380d34 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Sun, 3 Jan 2016 17:06:52 -0500 Subject: [svn-r28777] Description: Add --enable-memory-alloc-sanity-check option to configure, to track and sanity check memory allocations within the library. This is orthogonal to the --enable-using-memchecker option and can be used with/without it. Tested on: MacOSX/64 10.11.2 (amazon) w/serial & parallel (h5committest forthcoming) --- CMakeLists.txt | 8 + config/cmake/cacheinit.cmake | 2 + config/cmake/libhdf5.settings.cmake.in | 1 + config/cmake/mccacheinit.cmake | 2 + configure.ac | 31 ++++ release_docs/INSTALL_CMake.txt | 2 + src/H5.c | 5 + src/H5Dchunk.c | 32 +++- src/H5Dpkg.h | 25 +-- src/H5MM.c | 323 +++++++++++++++++++++++++++++++-- src/H5MMprivate.h | 13 +- src/libhdf5.settings.in | 1 + 12 files changed, 397 insertions(+), 48 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 65124ab..23b55c6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -376,6 +376,14 @@ if (HDF5_ENABLE_USING_MEMCHECKER) endif (HDF5_ENABLE_USING_MEMCHECKER) #----------------------------------------------------------------------------- +# Option to indicate internal memory allocation sanity checks are enabled +#----------------------------------------------------------------------------- +option (HDF5_MEMORY_ALLOC_SANITY_CHECK "Indicate that internal memory allocation sanity checks are enabled" OFF) +if (HDF5_MEMORY_ALLOC_SANITY_CHECK) + set (H5_MEMORY_ALLOC_SANITY_CHECK 1) +endif (HDF5_MEMORY_ALLOC_SANITY_CHECK) + +#----------------------------------------------------------------------------- # Option to use deprecated public API symbols #----------------------------------------------------------------------------- option (HDF5_ENABLE_DEPRECATED_SYMBOLS "Enable deprecated public API symbols" ON) diff --git a/config/cmake/cacheinit.cmake b/config/cmake/cacheinit.cmake index 4bef99f..5cae21b 100644 --- a/config/cmake/cacheinit.cmake +++ b/config/cmake/cacheinit.cmake @@ -36,6 +36,8 @@ set (HDF5_ENABLE_COVERAGE OFF CACHE BOOL "Enable code coverage for Libraries and set (HDF5_ENABLE_USING_MEMCHECKER OFF CACHE BOOL "Indicate that a memory checker is used" FORCE) +set (HDF5_MEMORY_ALLOC_SANITY_CHECK OFF CACHE BOOL "Indicate that internal memory allocation sanity checks are enabled" FORCE) + set (HDF5_DISABLE_COMPILER_WARNINGS OFF CACHE BOOL "Disable compiler warnings" FORCE) set (HDF5_USE_FOLDERS ON CACHE BOOL "Enable folder grouping of projects in IDEs." FORCE) diff --git a/config/cmake/libhdf5.settings.cmake.in b/config/cmake/libhdf5.settings.cmake.in index ba764a4..cc6ae3e 100644 --- a/config/cmake/libhdf5.settings.cmake.in +++ b/config/cmake/libhdf5.settings.cmake.in @@ -65,6 +65,7 @@ Features: dmalloc: @H5_HAVE_LIBDMALLOC@ Clear file buffers before write: @HDF5_Enable_Clear_File_Buffers@ Using memory checker: @HDF5_ENABLE_USING_MEMCHECKER@ +Memory allocation sanity checks: @HDF5_MEMORY_ALLOC_SANITY_CHECK@ Function Stack Tracing: @HDF5_ENABLE_CODESTACK@ Strict File Format Checks: @HDF5_STRICT_FORMAT_CHECKS@ Optimization Instrumentation: @HDF5_Enable_Instrument@ diff --git a/config/cmake/mccacheinit.cmake b/config/cmake/mccacheinit.cmake index 19ecc15..e54db1f 100644 --- a/config/cmake/mccacheinit.cmake +++ b/config/cmake/mccacheinit.cmake @@ -48,6 +48,8 @@ set (HDF5_ENABLE_COVERAGE OFF CACHE BOOL "Enable code coverage for Libraries and set (HDF5_ENABLE_USING_MEMCHECKER ON CACHE BOOL "Indicate that a memory checker is used" FORCE) +set (HDF5_MEMORY_ALLOC_SANITY_CHECK OFF CACHE BOOL "Indicate that internal memory allocation sanity checks are enabled" FORCE) + set (HDF5_DISABLE_COMPILER_WARNINGS OFF CACHE BOOL "Disable compiler warnings" FORCE) set (HDF5_USE_FOLDERS ON CACHE BOOL "Enable folder grouping of projects in IDEs." FORCE) diff --git a/configure.ac b/configure.ac index 0e853a8..9c1d5b0 100644 --- a/configure.ac +++ b/configure.ac @@ -2044,6 +2044,8 @@ AC_ARG_ENABLE([using-memchecker], library. Enabling this causes the library to be more picky about it's memory operations and also disables the library's free space manager code. + This option is orthogonal to the + --enable-memory-alloc-sanity-check option. Default=no.])], [USINGMEMCHECKER=$enableval]) @@ -2062,6 +2064,35 @@ case "X-$USINGMEMCHECKER" in ;; esac +## ---------------------------------------------------------------------- +## Check if they would like to enable the internal memory allocation sanity +## checking code. +## +AC_SUBST([MEMORYALLOCSANITYCHECK]) +AC_MSG_CHECKING([whether internal memory allocation sanity checking is used]) +AC_ARG_ENABLE([memory-alloc-sanity-check], + [AS_HELP_STRING([--enable-memory-alloc-sanity-check], + [Enable this option to turn on internal memory + allocation sanity checking. This could cause + more memory use and somewhat slower allocation. + This option is orthogonal to the + --enable-using-memchecker option. + Default=no.])], + [MEMORYALLOCSANITYCHECK=$enableval]) + +case "X-$MEMORYALLOCSANITYCHECK" in + X-yes) + MEMORYALLOCSANITYCHECK=yes + AC_MSG_RESULT([yes]) + AC_DEFINE([MEMORY_ALLOC_SANITY_CHECK], [1], + [Define to enable internal memory allocation sanity checking.]) + ;; + *) + MEMORYALLOCSANITYCHECK=no + AC_MSG_RESULT([no]) + ;; +esac + ## Checkpoint the cache AC_CACHE_SAVE diff --git a/release_docs/INSTALL_CMake.txt b/release_docs/INSTALL_CMake.txt index e745084..37326ed 100644 --- a/release_docs/INSTALL_CMake.txt +++ b/release_docs/INSTALL_CMake.txt @@ -411,6 +411,7 @@ These five steps are described in detail below. set (HDF5_BUILD_PARALLEL_ALL OFF CACHE BOOL "Build Parallel Programs" FORCE) set (HDF5_ENABLE_COVERAGE OFF CACHE BOOL "Enable code coverage for Libraries and Programs" FORCE) set (HDF5_ENABLE_USING_MEMCHECKER OFF CACHE BOOL "Indicate that a memory checker is used" FORCE) + set (HDF5_MEMORY_ALLOC_SANITY_CHECK OFF CACHE BOOL "Indicate that internal memory allocation sanity checks are enabled" FORCE) set (HDF5_DISABLE_COMPILER_WARNINGS OFF CACHE BOOL "Disable compiler warnings" FORCE) set (HDF5_USE_FOLDERS ON CACHE BOOL "Enable folder grouping of projects in IDEs." FORCE) set (HDF5_USE_16_API_DEFAULT OFF CACHE BOOL "Use the HDF5 1.6.x API by default" FORCE) @@ -587,6 +588,7 @@ HDF5_ENABLE_LARGE_FILE "Enable support for large (64-bit) files on Linux HDF5_ENABLE_PARALLEL "Enable parallel build (requires MPI)" OFF HDF5_ENABLE_TRACE "Enable API tracing capability" OFF HDF5_ENABLE_USING_MEMCHECKER "Indicate that a memory checker is used" OFF +HDF5_MEMORY_ALLOC_SANITY_CHECK "Indicate that internal memory allocation sanity checks are enabled" OFF HDF5_METADATA_TRACE_FILE "Enable metadata trace file collection" OFF HDF5_NO_PACKAGES "Do not include CPack Packaging" OFF HDF5_PACKAGE_EXTLIBS "CPACK - include external libraries" OFF diff --git a/src/H5.c b/src/H5.c index 2086ce8..a522398 100644 --- a/src/H5.c +++ b/src/H5.c @@ -396,6 +396,11 @@ H5_term_library(void) (void)H5MM_free(tmp_open_stream); } /* end while */ +#if defined H5_MEMORY_ALLOC_SANITY_CHECK + /* Sanity check memory allocations */ + H5MM_final_sanity_check(); +#endif /* H5_MEMORY_ALLOC_SANITY_CHECK */ + /* Reset flag indicating that the library is being shut down */ H5_TERM_GLOBAL = FALSE; diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index 6b99a43..0c4cba1 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -107,6 +107,25 @@ /* Local Typedefs */ /******************/ +/* Raw data chunks are cached. Each entry in the cache is: */ +typedef struct H5D_rdcc_ent_t { + hbool_t locked; /*entry is locked in cache */ + hbool_t dirty; /*needs to be written to disk? */ + hbool_t deleted; /*chunk about to be deleted */ + hsize_t scaled[H5O_LAYOUT_NDIMS]; /*scaled chunk 'name' (coordinates) */ + uint32_t rd_count; /*bytes remaining to be read */ + uint32_t wr_count; /*bytes remaining to be written */ + H5F_block_t chunk_block; /*offset/length of chunk in file */ + hsize_t chunk_idx; /*index of chunk in dataset */ + uint8_t *chunk; /*the unfiltered chunk data */ + unsigned idx; /*index in hash table */ + struct H5D_rdcc_ent_t *next;/*next item in doubly-linked list */ + struct H5D_rdcc_ent_t *prev;/*previous item in doubly-linked list */ + struct H5D_rdcc_ent_t *tmp_next;/*next item in temporary doubly-linked list */ + struct H5D_rdcc_ent_t *tmp_prev;/*previous item in temporary doubly-linked list */ +} H5D_rdcc_ent_t; +typedef H5D_rdcc_ent_t *H5D_rdcc_ent_ptr_t; /* For free lists */ + /* Callback info for iteration to prune chunks */ typedef struct H5D_chunk_it_ud1_t { H5D_chunk_common_ud_t common; /* Common info for B-tree user data (must be first) */ @@ -244,6 +263,11 @@ static herr_t H5D__chunk_flush_entry(const H5D_t *dset, hid_t dxpl_id, const H5D_dxpl_cache_t *dxpl_cache, H5D_rdcc_ent_t *ent, hbool_t reset); static herr_t H5D__chunk_cache_evict(const H5D_t *dset, hid_t dxpl_id, const H5D_dxpl_cache_t *dxpl_cache, H5D_rdcc_ent_t *ent, hbool_t flush); +static void *H5D__chunk_lock(const H5D_io_info_t *io_info, + H5D_chunk_ud_t *udata, hbool_t relax); +static herr_t H5D__chunk_unlock(const H5D_io_info_t *io_info, + const H5D_chunk_ud_t *udata, hbool_t dirty, void *chunk, + uint32_t naccessed); static herr_t H5D__chunk_cache_prune(const H5D_t *dset, hid_t dxpl_id, const H5D_dxpl_cache_t *dxpl_cache, size_t size); static herr_t H5D__chunk_prune_fill(H5D_chunk_it_ud1_t *udata); @@ -3008,7 +3032,7 @@ done: * *------------------------------------------------------------------------- */ -void * +static void * H5D__chunk_lock(const H5D_io_info_t *io_info, H5D_chunk_ud_t *udata, hbool_t relax) { @@ -3024,7 +3048,7 @@ H5D__chunk_lock(const H5D_io_info_t *io_info, H5D_chunk_ud_t *udata, void *chunk = NULL; /*the file chunk */ void *ret_value = NULL; /* Return value */ - FUNC_ENTER_PACKAGE + FUNC_ENTER_STATIC HDassert(io_info); HDassert(io_info->dxpl_cache); @@ -3286,7 +3310,7 @@ done: * *------------------------------------------------------------------------- */ -herr_t +static herr_t H5D__chunk_unlock(const H5D_io_info_t *io_info, const H5D_chunk_ud_t *udata, hbool_t dirty, void *chunk, uint32_t naccessed) { @@ -3294,7 +3318,7 @@ H5D__chunk_unlock(const H5D_io_info_t *io_info, const H5D_chunk_ud_t *udata, const H5D_rdcc_t *rdcc = &(io_info->dset->shared->cache.chunk); herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_PACKAGE + FUNC_ENTER_STATIC /* Sanity check */ HDassert(io_info); diff --git a/src/H5Dpkg.h b/src/H5Dpkg.h index 4e6376b..97fc442 100644 --- a/src/H5Dpkg.h +++ b/src/H5Dpkg.h @@ -369,6 +369,7 @@ typedef struct H5D_chunk_cached_t { } H5D_chunk_cached_t; /* The raw data chunk cache */ +struct H5D_rdcc_ent_t; /* Forward declaration of struct used below */ typedef struct H5D_rdcc_t { struct { unsigned ninits; /* Number of chunk creations */ @@ -497,25 +498,6 @@ typedef struct { hsize_t size; /* Accumulated number of bytes for the selection */ } H5D_vlen_bufsize_t; -/* Raw data chunks are cached. Each entry in the cache is: */ -typedef struct H5D_rdcc_ent_t { - hbool_t locked; /*entry is locked in cache */ - hbool_t dirty; /*needs to be written to disk? */ - hbool_t deleted; /*chunk about to be deleted */ - hsize_t scaled[H5O_LAYOUT_NDIMS]; /*scaled chunk 'name' (coordinates) */ - uint32_t rd_count; /*bytes remaining to be read */ - uint32_t wr_count; /*bytes remaining to be written */ - H5F_block_t chunk_block; /*offset/length of chunk in file */ - hsize_t chunk_idx; /*index of chunk in dataset */ - uint8_t *chunk; /*the unfiltered chunk data */ - unsigned idx; /*index in hash table */ - struct H5D_rdcc_ent_t *next;/*next item in doubly-linked list */ - struct H5D_rdcc_ent_t *prev;/*previous item in doubly-linked list */ - struct H5D_rdcc_ent_t *tmp_next;/*next item in temporary doubly-linked list */ - struct H5D_rdcc_ent_t *tmp_prev;/*previous item in temporary doubly-linked list */ -} H5D_rdcc_ent_t; -typedef H5D_rdcc_ent_t *H5D_rdcc_ent_ptr_t; /* For free lists */ - /*****************************/ /* Package Private Variables */ @@ -623,11 +605,6 @@ H5_DLL herr_t H5D__chunk_set_info(const H5D_t *dset); H5_DLL hbool_t H5D__chunk_is_space_alloc(const H5O_storage_t *storage); H5_DLL herr_t H5D__chunk_lookup(const H5D_t *dset, hid_t dxpl_id, const hsize_t *scaled, H5D_chunk_ud_t *udata); -H5_DLL void *H5D__chunk_lock(const H5D_io_info_t *io_info, - H5D_chunk_ud_t *udata, hbool_t relax); -H5_DLL herr_t H5D__chunk_unlock(const H5D_io_info_t *io_info, - const H5D_chunk_ud_t *udata, hbool_t dirty, void *chunk, - uint32_t naccessed); H5_DLL herr_t H5D__chunk_allocated(H5D_t *dset, hid_t dxpl_id, hsize_t *nbytes); H5_DLL herr_t H5D__chunk_allocate(const H5D_t *dset, hid_t dxpl_id, hbool_t full_overwrite, hsize_t old_dim[]); diff --git a/src/H5MM.c b/src/H5MM.c index a37bbff..05bfb9e 100644 --- a/src/H5MM.c +++ b/src/H5MM.c @@ -25,9 +25,195 @@ */ -#include "H5private.h" -#include "H5Eprivate.h" -#include "H5MMprivate.h" +/****************/ +/* Module Setup */ +/****************/ + + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5MMprivate.h" /* Memory management */ + + +/****************/ +/* Local Macros */ +/****************/ +#if defined H5_MEMORY_ALLOC_SANITY_CHECK +#define H5MM_SIG_SIZE 4 +#define H5MM_HEAD_GUARD_SIZE 8 +#define H5MM_TAIL_GUARD_SIZE 8 +#define H5MM_BLOCK_FROM_BUF(mem) ((H5MM_block_t *)((unsigned char *)mem - (offsetof(H5MM_block_t, b) + H5MM_HEAD_GUARD_SIZE))) +#endif /* H5_MEMORY_ALLOC_SANITY_CHECK */ + + +/******************/ +/* Local Typedefs */ +/******************/ + +#if defined H5_MEMORY_ALLOC_SANITY_CHECK +/* Memory allocation "block", wrapped around each allocation */ +struct H5MM_block_t; /* Forward declaration for typedef */ +typedef struct H5MM_block_t { + unsigned char sig[H5MM_SIG_SIZE]; /* Signature for the block, to indicate it was allocated with H5MM* interface */ + struct H5MM_block_t *next; /* Pointer to next block in the list of allocated blocks */ + struct H5MM_block_t *prev; /* Pointer to previous block in the list of allocated blocks */ + size_t size; + hbool_t in_use; + unsigned char b[]; +} H5MM_block_t; +#endif /* H5_MEMORY_ALLOC_SANITY_CHECK */ + + +/********************/ +/* Local Prototypes */ +/********************/ +#if defined H5_MEMORY_ALLOC_SANITY_CHECK +static hbool_t H5MM__is_our_block(void *mem); +static void H5MM__sanity_check_block(const H5MM_block_t *block); +static void H5MM__sanity_check(void *mem); +#endif /* H5_MEMORY_ALLOC_SANITY_CHECK */ + + +/*********************/ +/* Package Variables */ +/*********************/ + + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + + +/*******************/ +/* Local Variables */ +/*******************/ + +#if defined H5_MEMORY_ALLOC_SANITY_CHECK +/* Constant strings for block signature, head & tail guards */ +static const char H5MM_block_signature_s[H5MM_SIG_SIZE] = {'H', '5', 'M', 'M'}; +static const char H5MM_block_head_guard_s[H5MM_HEAD_GUARD_SIZE] = {'D', 'E', 'A', 'D', 'B', 'E', 'E', 'F'}; +static const char H5MM_block_tail_guard_s[H5MM_TAIL_GUARD_SIZE] = {'B', 'E', 'E', 'F', 'D', 'E', 'A', 'D'}; + +/* Flag to indicate the the interface has been initialized */ +static hbool_t H5MM_init_s = FALSE; + +/* Head of the list of allocated blocks */ +static H5MM_block_t H5MM_block_head_s; + +/* Statistics about block allocations */ +static unsigned long long H5MM_total_alloc_bytes_s = 0; +static unsigned long long H5MM_curr_alloc_bytes_s = 0; +static unsigned long long H5MM_peak_alloc_bytes_s = 0; +static size_t H5MM_max_block_size_s = 0; +static size_t H5MM_total_alloc_blocks_count_s = 0; +static size_t H5MM_curr_alloc_blocks_count_s = 0; +static size_t H5MM_peak_alloc_blocks_count_s = 0; +#endif /* H5_MEMORY_ALLOC_SANITY_CHECK */ + + +#if defined H5_MEMORY_ALLOC_SANITY_CHECK + +/*------------------------------------------------------------------------- + * Function: H5MM__is_our_block + * + * Purpose: Try to determine if a memory buffer has been allocated through + * the H5MM* interface, instead of the system's malloc() routines. + * + * Return: Success: TRUE/FALSE + * Failure: (Can't fail) + * + * Programmer: Quincey Koziol + * Dec 30 2015 + * + *------------------------------------------------------------------------- + */ +static hbool_t +H5MM__is_our_block(void *mem) +{ + H5MM_block_t *block = H5MM_BLOCK_FROM_BUF(mem); + + return(0 == HDmemcmp(block->sig, H5MM_block_signature_s, H5MM_SIG_SIZE)); +} + + +/*------------------------------------------------------------------------- + * Function: H5MM__sanity_check_block + * + * Purpose: Check a block wrapper around a buffer to validate it. + * + * Return: N/A (void) + * + * Programmer: Quincey Koziol + * Dec 30 2015 + * + *------------------------------------------------------------------------- + */ +static void +H5MM__sanity_check_block(const H5MM_block_t *block) +{ + HDassert(block->size > 0); + HDassert(block->in_use); + /* Check for head & tail guards, if not head of linked list */ + if(block->size != SIZE_T_MAX) { + HDassert(0 == HDmemcmp(block->b, H5MM_block_head_guard_s, H5MM_HEAD_GUARD_SIZE)); + HDassert(0 == HDmemcmp(block->b + H5MM_HEAD_GUARD_SIZE + block->size, H5MM_block_tail_guard_s, H5MM_TAIL_GUARD_SIZE)); + } +} + + +/*------------------------------------------------------------------------- + * Function: H5MM__sanity_check + * + * Purpose: Check a buffer to validate it (just calls + * H5MM__sanity_check_block after finding block for buffer) + * + * Return: N/A (void) + * + * Programmer: Quincey Koziol + * Dec 30 2015 + * + *------------------------------------------------------------------------- + */ +static void +H5MM__sanity_check(void *mem) +{ + H5MM_block_t *block = H5MM_BLOCK_FROM_BUF(mem); + + H5MM__sanity_check_block(block); +} + + +/*------------------------------------------------------------------------- + * Function: H5MM_final_sanity_check + * + * Purpose: Final sanity checks on memory allocation. + * + * Return: N/A (void) + * + * Programmer: Quincey Koziol + * Jan 1 2016 + * + *------------------------------------------------------------------------- + */ +void +H5MM_final_sanity_check(void) +{ + HDassert(0 == H5MM_curr_alloc_bytes_s); + HDassert(0 == H5MM_curr_alloc_blocks_count_s); + HDassert(H5MM_block_head_s.next == &H5MM_block_head_s); + HDassert(H5MM_block_head_s.prev == &H5MM_block_head_s); +#ifdef H5MM_PRINT_MEMORY_STATS + HDfprintf(stderr, "%s: H5MM_total_alloc_bytes_s = %llu\n", __func__, H5MM_total_alloc_bytes_s); + HDfprintf(stderr, "%s: H5MM_peak_alloc_bytes_s = %llu\n", __func__, H5MM_peak_alloc_bytes_s); + HDfprintf(stderr, "%s: H5MM_max_block_size_s = %zu\n", __func__, H5MM_max_block_size_s); + HDfprintf(stderr, "%s: H5MM_total_alloc_blocks_count_s = %zu\n", __func__, H5MM_total_alloc_blocks_count_s); + HDfprintf(stderr, "%s: H5MM_peak_alloc_blocks_count_s = %zu\n", __func__, H5MM_peak_alloc_blocks_count_s); +#endif /* H5MM_PRINT_MEMORY_STATS */ +} +#endif /* H5_MEMORY_ALLOC_SANITY_CHECK */ /*------------------------------------------------------------------------- @@ -42,7 +228,6 @@ * bytes usually indicate problems. * * Return: Success: Pointer new memory - * * Failure: NULL * * Programmer: Quincey Koziol @@ -60,12 +245,61 @@ H5MM_malloc(size_t size) /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOERR - if(size) +#if defined H5_MEMORY_ALLOC_SANITY_CHECK + /* Initialize block list head singleton */ + if(!H5MM_init_s) { + HDmemcpy(H5MM_block_head_s.sig, H5MM_block_signature_s, H5MM_SIG_SIZE); + H5MM_block_head_s.next = &H5MM_block_head_s; + H5MM_block_head_s.prev = &H5MM_block_head_s; + H5MM_block_head_s.size = SIZE_T_MAX; + H5MM_block_head_s.in_use = TRUE; + + H5MM_init_s = TRUE; + } /* end if */ +#endif /* H5_MEMORY_ALLOC_SANITY_CHECK */ + + if(size) { +#if defined H5_MEMORY_ALLOC_SANITY_CHECK + H5MM_block_t *block; + size_t alloc_size = sizeof(H5MM_block_t) + size + H5MM_HEAD_GUARD_SIZE + H5MM_TAIL_GUARD_SIZE; + + if(NULL != (block = (H5MM_block_t *)HDmalloc(alloc_size))) { + /* Set up block */ + HDmemcpy(block->sig, H5MM_block_signature_s, H5MM_SIG_SIZE); + block->next = H5MM_block_head_s.next; + H5MM_block_head_s.next = block; + block->next->prev = block; + block->prev = &H5MM_block_head_s; + block->size = size; + block->in_use = TRUE; + HDmemcpy(block->b, H5MM_block_head_guard_s, H5MM_HEAD_GUARD_SIZE); + HDmemcpy(block->b + H5MM_HEAD_GUARD_SIZE + size, H5MM_block_tail_guard_s, H5MM_TAIL_GUARD_SIZE); + + /* Update statistics */ + H5MM_total_alloc_bytes_s += size; + H5MM_curr_alloc_bytes_s += size; + if(H5MM_curr_alloc_bytes_s > H5MM_peak_alloc_bytes_s) + H5MM_peak_alloc_bytes_s = H5MM_curr_alloc_bytes_s; + if(size > H5MM_max_block_size_s) + H5MM_max_block_size_s = size; + H5MM_total_alloc_blocks_count_s++; + H5MM_curr_alloc_blocks_count_s++; + if(H5MM_curr_alloc_blocks_count_s > H5MM_peak_alloc_blocks_count_s) + H5MM_peak_alloc_blocks_count_s = H5MM_curr_alloc_blocks_count_s; + + /* Set buffer to return */ + ret_value = block->b + H5MM_HEAD_GUARD_SIZE; + } /* end if */ + else + ret_value = NULL; +#else /* H5_MEMORY_ALLOC_SANITY_CHECK */ ret_value = HDmalloc(size); +#endif /* H5_MEMORY_ALLOC_SANITY_CHECK */ + } /* end if */ else ret_value = NULL; - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5MM_malloc() */ @@ -83,7 +317,6 @@ H5MM_malloc(size_t size) * * * Return: Success: Pointer new memory - * * Failure: NULL * * Programmer: Quincey Koziol @@ -101,12 +334,18 @@ H5MM_calloc(size_t size) /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOERR - if(size) + if(size) { +#if defined H5_MEMORY_ALLOC_SANITY_CHECK + if(NULL != (ret_value = H5MM_malloc(size))) + HDmemset(ret_value, 0, size); +#else /* H5_MEMORY_ALLOC_SANITY_CHECK */ ret_value = HDcalloc((size_t)1, size); +#endif /* H5_MEMORY_ALLOC_SANITY_CHECK */ + } /* end if */ else ret_value = NULL; - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5MM_calloc() */ @@ -123,9 +362,7 @@ H5MM_calloc(size_t size) * Note that the (NULL, 0) combination is undefined behavior * in the C standard. * - * Return: Success: Ptr to new memory if size > 0 - * NULL if size is zero - * + * Return: Success: Ptr to new memory if size > 0, NULL if size is zero * Failure: NULL (input buffer is unchanged on failure) * * Programmer: Robb Matzke @@ -143,17 +380,39 @@ H5MM_realloc(void *mem, size_t size) HDassert(mem || size); - if(NULL == mem && 0 == size) { + if(NULL == mem && 0 == size) /* Not defined in the standard, return NULL */ ret_value = NULL; - } else { +#if defined H5_MEMORY_ALLOC_SANITY_CHECK + if(size > 0) { + if(mem) { + if(H5MM__is_our_block(mem)) { + H5MM_block_t *block = H5MM_BLOCK_FROM_BUF(mem); + size_t old_size = block->size; + + H5MM__sanity_check(mem); + + ret_value = H5MM_malloc(size); + HDmemcpy(ret_value, mem, MIN(size, old_size)); + H5MM_xfree(mem); + } /* end if */ + else + ret_value = HDrealloc(mem, size); + } + else + ret_value = H5MM_malloc(size); + } + else + ret_value = H5MM_xfree(mem); +#else /* H5_MEMORY_ALLOC_SANITY_CHECK */ ret_value = HDrealloc(mem, size); /* Some platforms do not return NULL if size is zero. */ if(0 == size) ret_value = NULL; - } +#endif /* H5_MEMORY_ALLOC_SANITY_CHECK */ + } /* end else */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5MM_realloc() */ @@ -250,8 +509,38 @@ H5MM_xfree(void *mem) /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOERR - if(mem) + if(mem) { +#if defined H5_MEMORY_ALLOC_SANITY_CHECK + if(H5MM__is_our_block(mem)) { + H5MM_block_t *block = H5MM_BLOCK_FROM_BUF(mem); + + /* Run sanity checks on this block and its neighbors */ + H5MM__sanity_check(mem); + H5MM__sanity_check_block(block->next); + H5MM__sanity_check_block(block->prev); + + /* Update statistics */ + H5MM_curr_alloc_bytes_s -= block->size; + H5MM_curr_alloc_blocks_count_s--; + + /* Reset block info */ + HDmemset(block->sig, 0, H5MM_SIG_SIZE); + block->next->prev = block->prev; + block->prev->next = block->next; + block->next = NULL; + block->prev = NULL; + block->in_use = FALSE; + + /* Free the block (finally!) */ + HDfree(block); + } + else + HDfree(mem); +#else /* H5_MEMORY_ALLOC_SANITY_CHECK */ HDfree(mem); +#endif /* H5_MEMORY_ALLOC_SANITY_CHECK */ + } /* end if */ - FUNC_LEAVE_NOAPI(NULL); + FUNC_LEAVE_NOAPI(NULL) } /* end H5MM_xfree() */ + diff --git a/src/H5MMprivate.h b/src/H5MMprivate.h index 0d608b2..c494a60 100644 --- a/src/H5MMprivate.h +++ b/src/H5MMprivate.h @@ -21,8 +21,6 @@ * * Purpose: Private header for memory management. * - * Modifications: - * *------------------------------------------------------------------------- */ #ifndef _H5MMprivate_H @@ -33,7 +31,12 @@ /* Private headers needed by this file */ #include "H5private.h" +#if defined H5_MEMORY_ALLOC_SANITY_CHECK +/*#define H5MM_PRINT_MEMORY_STATS */ +#define H5MM_free(Z) H5MM_xfree(Z) +#else /* H5_MEMORY_ALLOC_SANITY_CHECK */ #define H5MM_free(Z) HDfree(Z) +#endif /* H5_MEMORY_ALLOC_SANITY_CHECK */ /* * Library prototypes... @@ -44,5 +47,9 @@ H5_DLL void *H5MM_realloc(void *mem, size_t size); H5_DLL char *H5MM_xstrdup(const char *s); H5_DLL char *H5MM_strdup(const char *s); H5_DLL void *H5MM_xfree(void *mem); +#if defined H5_MEMORY_ALLOC_SANITY_CHECK +H5_DLL void H5MM_final_sanity_check(void); +#endif /* H5_MEMORY_ALLOC_SANITY_CHECK */ + +#endif /* _H5MMprivate_H */ -#endif diff --git a/src/libhdf5.settings.in b/src/libhdf5.settings.in index 2355543..90224c1 100644 --- a/src/libhdf5.settings.in +++ b/src/libhdf5.settings.in @@ -66,6 +66,7 @@ Features: dmalloc: @HAVE_DMALLOC@ Clear file buffers before write: @CLEARFILEBUF@ Using memory checker: @USINGMEMCHECKER@ +Memory allocation sanity checks: @MEMORYALLOCSANITYCHECK@ Function Stack Tracing: @CODESTACK@ Strict File Format Checks: @STRICT_FORMAT_CHECKS@ Optimization Instrumentation: @INSTRUMENT@ -- cgit v0.12 From 064b2f6dd85330a7e06f07c5fd2b8b26c29c8f28 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Mon, 4 Jan 2016 12:21:05 -0500 Subject: [svn-r28788] Added extern C block to H5Epubgen.h (via bin/make_err). Tested on: 64-bit Ubuntu 15.10 (Linux 4.2.0 x86_64) gcc 5.2.1 serial only --- bin/make_err | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/bin/make_err b/bin/make_err index 4b1f474..1b39d53fb 100755 --- a/bin/make_err +++ b/bin/make_err @@ -175,6 +175,12 @@ sub create_public ($) { print_warning(*HEADER); print_startprotect(*HEADER, $file); + # Begin extern C block + print HEADER "\n"; + print HEADER "#ifdef __cplusplus\n"; + print HEADER "extern \"C\" {\n"; + print HEADER "#endif\n"; + # Iterate over all the major errors print HEADER "\n/*********************/\n"; print HEADER "/* Major error codes */\n"; @@ -202,6 +208,12 @@ sub create_public ($) { } } + # End extern C block + print HEADER "\n"; + print HEADER "#ifdef __cplusplus\n"; + print HEADER "}\n"; + print HEADER "#endif\n"; + print_endprotect(*HEADER, $file); # Close header file -- cgit v0.12 From cdc21e0cb2d8a987790660b660a56744d54c5bed Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Mon, 4 Jan 2016 15:56:08 -0500 Subject: [svn-r28790] Description: Correct non-portable 'SIZE_T_MAX' to 'SIZET_MAX'. Tested on: Linux/32 2.6.x (jam) w/default compilers (h5committest forthcoming) --- src/H5MM.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/H5MM.c b/src/H5MM.c index 05bfb9e..b6e77eb 100644 --- a/src/H5MM.c +++ b/src/H5MM.c @@ -157,7 +157,7 @@ H5MM__sanity_check_block(const H5MM_block_t *block) HDassert(block->size > 0); HDassert(block->in_use); /* Check for head & tail guards, if not head of linked list */ - if(block->size != SIZE_T_MAX) { + if(block->size != SIZET_MAX) { HDassert(0 == HDmemcmp(block->b, H5MM_block_head_guard_s, H5MM_HEAD_GUARD_SIZE)); HDassert(0 == HDmemcmp(block->b + H5MM_HEAD_GUARD_SIZE + block->size, H5MM_block_tail_guard_s, H5MM_TAIL_GUARD_SIZE)); } @@ -251,7 +251,7 @@ H5MM_malloc(size_t size) HDmemcpy(H5MM_block_head_s.sig, H5MM_block_signature_s, H5MM_SIG_SIZE); H5MM_block_head_s.next = &H5MM_block_head_s; H5MM_block_head_s.prev = &H5MM_block_head_s; - H5MM_block_head_s.size = SIZE_T_MAX; + H5MM_block_head_s.size = SIZET_MAX; H5MM_block_head_s.in_use = TRUE; H5MM_init_s = TRUE; -- cgit v0.12 From 1cbc72e1ef6d5a0341713b4c7d8b113310a52551 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Mon, 4 Jan 2016 16:12:14 -0500 Subject: [svn-r28792] Added cleanup for new test files to tfile.c. Tested on: 64-bit Ubuntu 15.10 (Linux 4.2.0 x86_64) gcc 5.2.1 serial only --- test/tfile.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/tfile.c b/test/tfile.c index c36045b..927ecab 100644 --- a/test/tfile.c +++ b/test/tfile.c @@ -3715,5 +3715,7 @@ cleanup_file(void) HDremove(FILE3); HDremove(FILE4); HDremove(FILE5); + HDremove(FILE6); + HDremove(FILE7); } -- cgit v0.12 From 3e0e79aa6eaa26106d22c0b860d523fe945cb0ac Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Mon, 4 Jan 2016 21:46:26 -0500 Subject: [svn-r28795] Description: Clean up more memory allocation mis-matches. Tested on: Linux/32 2.6.x (jam) w/serial MacOSX/64 10.11.2 (amazon) w/serial & parallel --- src/H5E.c | 5 +++++ src/H5PL.c | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/H5E.c b/src/H5E.c index 4374f1d..efa83e4 100644 --- a/src/H5E.c +++ b/src/H5E.c @@ -1417,8 +1417,13 @@ H5Epush2(hid_t err_stack, const char *file, const char *func, unsigned line, done: if(va_started) va_end(ap); +#ifdef H5_HAVE_VASPRINTF + if(tmp) + HDfree(tmp); +#else /* H5_HAVE_VASPRINTF */ if(tmp) H5MM_xfree(tmp); +#endif /* H5_HAVE_VASPRINTF */ FUNC_LEAVE_API(ret_value) } /* end H5Epush2() */ diff --git a/src/H5PL.c b/src/H5PL.c index 4c35c09..a196884 100644 --- a/src/H5PL.c +++ b/src/H5PL.c @@ -413,9 +413,9 @@ H5PL__init_path_table(void) */ origin_dl_path = HDgetenv("HDF5_PLUGIN_PATH"); if(NULL == origin_dl_path) - dl_path = HDstrdup(H5PL_DEFAULT_PATH); + dl_path = H5MM_strdup(H5PL_DEFAULT_PATH); else - dl_path = HDstrdup(origin_dl_path); + dl_path = H5MM_strdup(origin_dl_path); if(NULL == dl_path) HGOTO_ERROR(H5E_PLUGIN, H5E_CANTALLOC, FAIL, "can't allocate memory for path") @@ -425,7 +425,7 @@ H5PL__init_path_table(void) /* Check for too many directories in path */ if(H5PL_num_paths_g == H5PL_MAX_PATH_NUM) HGOTO_ERROR(H5E_PLUGIN, H5E_NOSPACE, FAIL, "too many directories in path for table") - if(NULL == (H5PL_path_table_g[H5PL_num_paths_g] = HDstrdup(dir))) + if(NULL == (H5PL_path_table_g[H5PL_num_paths_g] = H5MM_strdup(dir))) HGOTO_ERROR(H5E_PLUGIN, H5E_CANTALLOC, FAIL, "can't allocate memory for path") H5PL_num_paths_g++; dir = HDstrtok(NULL, H5PL_PATH_SEPARATOR); -- cgit v0.12 From 4c5bb2b8db3c16c9ec7a3f7f7eebf7fbeac8c48b Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Mon, 4 Jan 2016 22:28:43 -0500 Subject: [svn-r28797] Description: Clean up another round of memory allocation mis-matches. Tested on: Linux/32 2.6.x (jam) w/serial MacOSX/64 10.11.2 (amazon) w/serial & parallel --- src/H5B2.c | 8 ++++---- src/H5B2hdr.c | 12 ++++-------- src/H5B2int.c | 32 ++++++++++++-------------------- src/H5Dchunk.c | 4 ++-- src/H5Dmpio.c | 30 +++++++++++++++++------------- src/H5Dvirtual.c | 10 +++++----- src/H5FDlog.c | 14 ++++++-------- src/H5Ocopy.c | 4 ++-- src/H5Pdcpl.c | 4 ++-- 9 files changed, 54 insertions(+), 64 deletions(-) diff --git a/src/H5B2.c b/src/H5B2.c index c105a93..62aded3 100644 --- a/src/H5B2.c +++ b/src/H5B2.c @@ -614,7 +614,7 @@ H5B2_find(H5B2_t *bt2, hid_t dxpl_id, void *udata, H5B2_found_t op, if(idx == 0) { if(H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) { if(hdr->min_native_rec == NULL) - if(NULL == (hdr->min_native_rec = (uint8_t *)HDmalloc(hdr->cls->nrec_size))) + if(NULL == (hdr->min_native_rec = (uint8_t *)H5MM_malloc(hdr->cls->nrec_size))) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for v2 B-tree min record info") HDmemcpy(hdr->min_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size); } /* end if */ @@ -622,7 +622,7 @@ H5B2_find(H5B2_t *bt2, hid_t dxpl_id, void *udata, H5B2_found_t op, if(idx == (unsigned)(leaf->nrec - 1)) { if(H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) { if(hdr->max_native_rec == NULL) - if(NULL == (hdr->max_native_rec = (uint8_t *)HDmalloc(hdr->cls->nrec_size))) + if(NULL == (hdr->max_native_rec = (uint8_t *)H5MM_malloc(hdr->cls->nrec_size))) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for v2 B-tree max record info") HDmemcpy(hdr->max_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size); } /* end if */ @@ -1224,7 +1224,7 @@ H5B2_modify(H5B2_t *bt2, hid_t dxpl_id, void *udata, H5B2_modify_t op, if(idx == 0) { if(H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) { if(hdr->min_native_rec == NULL) - if(NULL == (hdr->min_native_rec = (uint8_t *)HDmalloc(hdr->cls->nrec_size))) + if(NULL == (hdr->min_native_rec = (uint8_t *)H5MM_malloc(hdr->cls->nrec_size))) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for v2 B-tree min record info") HDmemcpy(hdr->min_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size); } /* end if */ @@ -1232,7 +1232,7 @@ H5B2_modify(H5B2_t *bt2, hid_t dxpl_id, void *udata, H5B2_modify_t op, if(idx == (unsigned)(leaf->nrec - 1)) { if(H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) { if(hdr->max_native_rec == NULL) - if(NULL == (hdr->max_native_rec = (uint8_t *)HDmalloc(hdr->cls->nrec_size))) + if(NULL == (hdr->max_native_rec = (uint8_t *)H5MM_malloc(hdr->cls->nrec_size))) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for v2 B-tree max record info") HDmemcpy(hdr->max_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size); } /* end if */ diff --git a/src/H5B2hdr.c b/src/H5B2hdr.c index 25ac141..036e81a 100644 --- a/src/H5B2hdr.c +++ b/src/H5B2hdr.c @@ -619,14 +619,10 @@ H5B2__hdr_free(H5B2_hdr_t *hdr) } /* end if */ /* Release the min & max record info, if set */ - if(hdr->min_native_rec) { - HDfree(hdr->min_native_rec); - hdr->min_native_rec = NULL; - } /* end if */ - if(hdr->max_native_rec) { - HDfree(hdr->max_native_rec); - hdr->max_native_rec = NULL; - } /* end if */ + if(hdr->min_native_rec) + hdr->min_native_rec = H5MM_free(hdr->min_native_rec); + if(hdr->max_native_rec) + hdr->max_native_rec = H5MM_free(hdr->max_native_rec); /* Free B-tree header info */ hdr = H5FL_FREE(H5B2_hdr_t, hdr); diff --git a/src/H5B2int.c b/src/H5B2int.c index 363d903..105dad4 100644 --- a/src/H5B2int.c +++ b/src/H5B2int.c @@ -1640,7 +1640,7 @@ H5B2__insert_leaf(H5B2_hdr_t *hdr, hid_t dxpl_id, H5B2_node_ptr_t *curr_node_ptr if(idx == 0) { if(H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) { if(hdr->min_native_rec == NULL) - if(NULL == (hdr->min_native_rec = (uint8_t *)HDmalloc(hdr->cls->nrec_size))) + if(NULL == (hdr->min_native_rec = (uint8_t *)H5MM_malloc(hdr->cls->nrec_size))) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for v2 B-tree min record info") HDmemcpy(hdr->min_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size); } /* end if */ @@ -1648,7 +1648,7 @@ H5B2__insert_leaf(H5B2_hdr_t *hdr, hid_t dxpl_id, H5B2_node_ptr_t *curr_node_ptr if(idx == (unsigned)(leaf->nrec - 1)) { if(H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) { if(hdr->max_native_rec == NULL) - if(NULL == (hdr->max_native_rec = (uint8_t *)HDmalloc(hdr->cls->nrec_size))) + if(NULL == (hdr->max_native_rec = (uint8_t *)H5MM_malloc(hdr->cls->nrec_size))) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for v2 B-tree max record info") HDmemcpy(hdr->max_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size); } /* end if */ @@ -1929,7 +1929,7 @@ H5B2__update_leaf(H5B2_hdr_t *hdr, hid_t dxpl_id, H5B2_node_ptr_t *curr_node_ptr if(idx == 0) { if(H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) { if(hdr->min_native_rec == NULL) - if(NULL == (hdr->min_native_rec = (uint8_t *)HDmalloc(hdr->cls->nrec_size))) + if(NULL == (hdr->min_native_rec = (uint8_t *)H5MM_malloc(hdr->cls->nrec_size))) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for v2 B-tree min record info") HDmemcpy(hdr->min_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size); } /* end if */ @@ -1937,7 +1937,7 @@ H5B2__update_leaf(H5B2_hdr_t *hdr, hid_t dxpl_id, H5B2_node_ptr_t *curr_node_ptr if(idx == (unsigned)(leaf->nrec - 1)) { if(H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) { if(hdr->max_native_rec == NULL) - if(NULL == (hdr->max_native_rec = (uint8_t *)HDmalloc(hdr->cls->nrec_size))) + if(NULL == (hdr->max_native_rec = (uint8_t *)H5MM_malloc(hdr->cls->nrec_size))) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for v2 B-tree max record info") HDmemcpy(hdr->max_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size); } /* end if */ @@ -2552,18 +2552,14 @@ H5B2__remove_leaf(H5B2_hdr_t *hdr, hid_t dxpl_id, H5B2_node_ptr_t *curr_node_ptr /* (Don't use 'else' for the idx check, to allow for root leaf node) */ if(idx == 0) { if(H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) { - if(hdr->min_native_rec) { - HDfree(hdr->min_native_rec); - hdr->min_native_rec = NULL; - } /* end if */ + if(hdr->min_native_rec) + hdr->min_native_rec = H5MM_free(hdr->min_native_rec); } /* end if */ } /* end if */ if(idx == (unsigned)(leaf->nrec - 1)) { if(H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) { - if(hdr->max_native_rec) { - HDfree(hdr->max_native_rec); - hdr->max_native_rec = NULL; - } /* end if */ + if(hdr->max_native_rec) + hdr->max_native_rec = H5MM_free(hdr->max_native_rec); } /* end if */ } /* end if */ } /* end if */ @@ -2867,18 +2863,14 @@ H5B2__remove_leaf_by_idx(H5B2_hdr_t *hdr, hid_t dxpl_id, /* (Don't use 'else' for the idx check, to allow for root leaf node) */ if(idx == 0) { if(H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) { - if(hdr->min_native_rec) { - HDfree(hdr->min_native_rec); - hdr->min_native_rec = NULL; - } /* end if */ + if(hdr->min_native_rec) + hdr->min_native_rec = H5MM_free(hdr->min_native_rec); } /* end if */ } /* end if */ if(idx == (unsigned)(leaf->nrec - 1)) { if(H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) { - if(hdr->max_native_rec) { - HDfree(hdr->max_native_rec); - hdr->max_native_rec = NULL; - } /* end if */ + if(hdr->max_native_rec) + hdr->max_native_rec = H5MM_free(hdr->max_native_rec); } /* end if */ } /* end if */ } /* end if */ diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index 0c4cba1..b0abdf1 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -3746,7 +3746,7 @@ H5D__chunk_allocate(const H5D_t *dset, hid_t dxpl_id, hbool_t full_overwrite, write collectively at the end */ /* allocate/resize address array if no more space left */ if(0 == chunk_info.num_io % 1024) - if(NULL == (chunk_info.addr = (haddr_t *)HDrealloc(chunk_info.addr, (chunk_info.num_io + 1024) * sizeof(haddr_t)))) + if(NULL == (chunk_info.addr = (haddr_t *)H5MM_realloc(chunk_info.addr, (chunk_info.num_io + 1024) * sizeof(haddr_t)))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "memory allocation failed for chunk addresses") /* Store the chunk's address for later */ @@ -3813,7 +3813,7 @@ done: #ifdef H5_HAVE_PARALLEL if(using_mpi && chunk_info.addr) - HDfree(chunk_info.addr); + H5MM_free(chunk_info.addr); #endif FUNC_LEAVE_NOAPI_TAG(ret_value, FAIL) diff --git a/src/H5Dmpio.c b/src/H5Dmpio.c index a5f34d1..0ba340a 100644 --- a/src/H5Dmpio.c +++ b/src/H5Dmpio.c @@ -1680,7 +1680,6 @@ H5D__obtain_mpio_mode(H5D_io_info_t* io_info, H5D_chunk_map_t *fm, MPI_Comm comm; int ic, root; int mpi_code; - hbool_t mem_cleanup = FALSE; #ifdef H5_HAVE_INSTRUMENTED_LIBRARY int new_value; htri_t check_prop; @@ -1715,12 +1714,14 @@ H5D__obtain_mpio_mode(H5D_io_info_t* io_info, H5D_chunk_map_t *fm, threshold_nproc_per_chunk = mpi_size * percent_nproc_per_chunk/100; /* Allocate memory */ - io_mode_info = (uint8_t *)H5MM_calloc(total_chunks); - mergebuf = H5MM_malloc((sizeof(haddr_t) + 1) * total_chunks); + if(NULL == (io_mode_info = (uint8_t *)H5MM_calloc(total_chunks))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate I/O mode info buffer") + if(NULL == (mergebuf = H5MM_malloc((sizeof(haddr_t) + 1) * total_chunks))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate mergebuf buffer") tempbuf = mergebuf + total_chunks; if(mpi_rank == root) - recv_io_mode_info = (uint8_t *)H5MM_malloc(total_chunks * mpi_size); - mem_cleanup = TRUE; + if(NULL == (recv_io_mode_info = (uint8_t *)H5MM_malloc(total_chunks * mpi_size))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate recv I/O mode info buffer") /* Obtain the regularity and selection information for all chunks in this process. */ chunk_node = H5SL_first(fm->sel_chunks); @@ -1742,11 +1743,12 @@ H5D__obtain_mpio_mode(H5D_io_info_t* io_info, H5D_chunk_map_t *fm, /* pre-computing: calculate number of processes and regularity of the selection occupied in each chunk */ - nproc_per_chunk = (int*)H5MM_calloc(total_chunks * sizeof(int)); + if(NULL == (nproc_per_chunk = (int*)H5MM_calloc(total_chunks * sizeof(int)))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate nproc_per_chunk buffer") /* calculating the chunk address */ if(H5D__chunk_addrmap(io_info, chunk_addr) < 0) { - HDfree(nproc_per_chunk); + H5MM_free(nproc_per_chunk); HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get chunk address") } /* end if */ @@ -1774,7 +1776,7 @@ H5D__obtain_mpio_mode(H5D_io_info_t* io_info, H5D_chunk_map_t *fm, HDmemcpy(mergebuf, assign_io_mode, total_chunks); HDmemcpy(tempbuf, chunk_addr, sizeof(haddr_t) * total_chunks); - HDfree(nproc_per_chunk); + H5MM_free(nproc_per_chunk); } /* end if */ /* Broadcasting the MPI_IO option info. and chunk address info. */ @@ -1824,11 +1826,13 @@ H5D__obtain_mpio_mode(H5D_io_info_t* io_info, H5D_chunk_map_t *fm, #endif done: - if(mem_cleanup) { - HDfree(io_mode_info); - HDfree(mergebuf); - if(mpi_rank == root) - HDfree(recv_io_mode_info); + if(io_mode_info) + H5MM_free(io_mode_info); + if(mergebuf) + H5MM_free(mergebuf); + if(recv_io_mode_info) { + HDassert(mpi_rank == root); + H5MM_free(recv_io_mode_info); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Dvirtual.c b/src/H5Dvirtual.c index 7c5186d..bf754cb 100644 --- a/src/H5Dvirtual.c +++ b/src/H5Dvirtual.c @@ -446,10 +446,10 @@ H5D__virtual_copy_layout(H5O_layout_t *layout) /* Copy original source names */ if(NULL == (layout->storage.u.virt.list[i].source_file_name - = HDstrdup(orig_list[i].source_file_name))) + = H5MM_strdup(orig_list[i].source_file_name))) HGOTO_ERROR(H5E_DATASET, H5E_RESOURCE, FAIL, "unable to duplicate source file name") if(NULL == (layout->storage.u.virt.list[i].source_dset_name - = HDstrdup(orig_list[i].source_dset_name))) + = H5MM_strdup(orig_list[i].source_dset_name))) HGOTO_ERROR(H5E_DATASET, H5E_RESOURCE, FAIL, "unable to duplicate source dataset name") /* Copy source selection */ @@ -488,7 +488,7 @@ H5D__virtual_copy_layout(H5O_layout_t *layout) } /* end if */ else if(NULL == (layout->storage.u.virt.list[i].source_dset.file_name - = HDstrdup(orig_list[i].source_dset.file_name))) + = H5MM_strdup(orig_list[i].source_dset.file_name))) HGOTO_ERROR(H5E_DATASET, H5E_RESOURCE, FAIL, "unable to duplicate source file name") } /* end if */ if(orig_list[i].source_dset.dset_name) { @@ -504,7 +504,7 @@ H5D__virtual_copy_layout(H5O_layout_t *layout) } /* end if */ else if(NULL == (layout->storage.u.virt.list[i].source_dset.dset_name - = HDstrdup(orig_list[i].source_dset.dset_name))) + = H5MM_strdup(orig_list[i].source_dset.dset_name))) HGOTO_ERROR(H5E_DATASET, H5E_RESOURCE, FAIL, "unable to duplicate source dataset name") } /* end if */ @@ -1124,7 +1124,7 @@ H5D__virtual_copy_parsed_name(H5O_storage_virtual_name_seg_t **dst, /* Duplicate name segment */ if(p_src->name_segment) { - if(NULL == ((*p_dst)->name_segment = HDstrdup(p_src->name_segment))) + if(NULL == ((*p_dst)->name_segment = H5MM_strdup(p_src->name_segment))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "unable to duplicate name segment") } /* end if */ diff --git a/src/H5FDlog.c b/src/H5FDlog.c index a8228e0..435ee70 100644 --- a/src/H5FDlog.c +++ b/src/H5FDlog.c @@ -406,7 +406,7 @@ H5FD_log_fapl_copy(const void *_old_fa) /* Deep copy the log file name */ if(old_fa->logfile != NULL) - if(NULL == (new_fa->logfile = H5MM_xstrdup(old_fa->logfile))) + if(NULL == (new_fa->logfile = H5MM_strdup(old_fa->logfile))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to allocate log file name") /* Set return value */ @@ -416,7 +416,7 @@ done: if(NULL == ret_value) if(new_fa) { if(new_fa->logfile) - H5MM_free(new_fa->logfile); + new_fa->logfile = H5MM_free(new_fa->logfile); H5MM_free(new_fa); } /* end if */ @@ -445,7 +445,7 @@ H5FD_log_fapl_free(void *_fa) /* Free the fapl information */ if(fa->logfile) - H5MM_xfree(fa->logfile); + fa->logfile = H5MM_free(fa->logfile); H5MM_xfree(fa); FUNC_LEAVE_NOAPI(SUCCEED) @@ -594,7 +594,7 @@ H5FD_log_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) /* Get the flags for logging */ file->fa.flags = fa->flags; if(fa->logfile) - file->fa.logfile = HDstrdup(fa->logfile); + file->fa.logfile = H5MM_strdup(fa->logfile); else file->fa.logfile = NULL; file->fa.buf_size = fa->buf_size; @@ -798,10 +798,8 @@ H5FD_log_close(H5FD_t *_file) HDfclose(file->logfp); } /* end if */ - if(file->fa.logfile) { - HDfree(file->fa.logfile); - file->fa.logfile = NULL; - } + if(file->fa.logfile) + file->fa.logfile = H5MM_free(file->fa.logfile); /* Release the file info */ file = H5FL_FREE(H5FD_log_t, file); diff --git a/src/H5Ocopy.c b/src/H5Ocopy.c index 6f42a88..70dc560 100644 --- a/src/H5Ocopy.c +++ b/src/H5Ocopy.c @@ -463,7 +463,7 @@ H5O_copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, /* Allocate memory for "deleted" array. This array marks the message in * the source that shouldn't be copied to the destination. */ - if(NULL == (deleted = (hbool_t *)HDmalloc(sizeof(hbool_t) * oh_src->nmesgs))) + if(NULL == (deleted = (hbool_t *)H5MM_malloc(sizeof(hbool_t) * oh_src->nmesgs))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") HDmemset(deleted, FALSE, sizeof(hbool_t) * oh_src->nmesgs); @@ -870,7 +870,7 @@ H5O_copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, done: /* Free deleted array */ if(deleted) - HDfree(deleted); + H5MM_free(deleted); /* Release pointer to source object header and its derived objects */ if(oh_src && H5O_unprotect(oloc_src, dxpl_id, oh_src, H5AC__NO_FLAGS_SET) < 0) diff --git a/src/H5Pdcpl.c b/src/H5Pdcpl.c index 03d987f..971394c 100644 --- a/src/H5Pdcpl.c +++ b/src/H5Pdcpl.c @@ -2227,9 +2227,9 @@ H5Pset_virtual(hid_t dcpl_id, hid_t vspace_id, const char *src_file_name, HDmemset(ent, 0, sizeof(H5O_storage_virtual_ent_t)); /* Clear before starting to set up */ if(NULL == (ent->source_dset.virtual_select = H5S_copy(vspace, FALSE, TRUE))) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "unable to copy virtual selection") - if(NULL == (ent->source_file_name = HDstrdup(src_file_name))) + if(NULL == (ent->source_file_name = H5MM_xstrdup(src_file_name))) HGOTO_ERROR(H5E_PLIST, H5E_RESOURCE, FAIL, "can't duplicate source file name") - if(NULL == (ent->source_dset_name = HDstrdup(src_dset_name))) + if(NULL == (ent->source_dset_name = H5MM_xstrdup(src_dset_name))) HGOTO_ERROR(H5E_PLIST, H5E_RESOURCE, FAIL, "can't duplicate source file name") if(NULL == (ent->source_select = H5S_copy(src_space, FALSE, TRUE))) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "unable to copy source selection") -- cgit v0.12 From 4b90bb3317c39b347fd67dc753d70fe6808e4f2b Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Mon, 4 Jan 2016 22:37:06 -0500 Subject: [svn-r28798] Description: Add missing H5MMprivate.h header file Tested on: Linux/32 2.6.x (jam) w/serial MacOSX/64 10.11.2 (amazon) w/serial & parallel --- src/H5B2.c | 1 + src/H5B2hdr.c | 3 ++- src/H5B2int.c | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/H5B2.c b/src/H5B2.c index 62aded3..3a712da 100644 --- a/src/H5B2.c +++ b/src/H5B2.c @@ -42,6 +42,7 @@ #include "H5private.h" /* Generic Functions */ #include "H5B2pkg.h" /* v2 B-trees */ #include "H5Eprivate.h" /* Error handling */ +#include "H5MMprivate.h" /* Memory management */ /****************/ diff --git a/src/H5B2hdr.c b/src/H5B2hdr.c index 036e81a..b6e0b26 100644 --- a/src/H5B2hdr.c +++ b/src/H5B2hdr.c @@ -38,7 +38,8 @@ #include "H5B2pkg.h" /* v2 B-trees */ #include "H5Eprivate.h" /* Error handling */ #include "H5MFprivate.h" /* File memory management */ -#include "H5VMprivate.h" /* Vectors and arrays */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5VMprivate.h" /* Vectors and arrays */ /****************/ /* Local Macros */ diff --git a/src/H5B2int.c b/src/H5B2int.c index 105dad4..fe82604 100644 --- a/src/H5B2int.c +++ b/src/H5B2int.c @@ -38,7 +38,8 @@ #include "H5B2pkg.h" /* v2 B-trees */ #include "H5Eprivate.h" /* Error handling */ #include "H5MFprivate.h" /* File memory management */ -#include "H5VMprivate.h" /* Vectors and arrays */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5VMprivate.h" /* Vectors and arrays */ /****************/ /* Local Macros */ -- cgit v0.12 From 63102599575c860b0f5b839e0e3ab8e5944fd1fc Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Mon, 4 Jan 2016 22:46:10 -0500 Subject: [svn-r28800] Description: Correct H5MM_free => H5MM_xfree Tested on: MacOSX/64 10.11.2 (amazon) w/serial & parallel --- src/H5B2hdr.c | 4 ++-- src/H5B2int.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/H5B2hdr.c b/src/H5B2hdr.c index b6e0b26..ab424b7 100644 --- a/src/H5B2hdr.c +++ b/src/H5B2hdr.c @@ -621,9 +621,9 @@ H5B2__hdr_free(H5B2_hdr_t *hdr) /* Release the min & max record info, if set */ if(hdr->min_native_rec) - hdr->min_native_rec = H5MM_free(hdr->min_native_rec); + hdr->min_native_rec = H5MM_xfree(hdr->min_native_rec); if(hdr->max_native_rec) - hdr->max_native_rec = H5MM_free(hdr->max_native_rec); + hdr->max_native_rec = H5MM_xfree(hdr->max_native_rec); /* Free B-tree header info */ hdr = H5FL_FREE(H5B2_hdr_t, hdr); diff --git a/src/H5B2int.c b/src/H5B2int.c index fe82604..f3bae69 100644 --- a/src/H5B2int.c +++ b/src/H5B2int.c @@ -2554,13 +2554,13 @@ H5B2__remove_leaf(H5B2_hdr_t *hdr, hid_t dxpl_id, H5B2_node_ptr_t *curr_node_ptr if(idx == 0) { if(H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) { if(hdr->min_native_rec) - hdr->min_native_rec = H5MM_free(hdr->min_native_rec); + hdr->min_native_rec = H5MM_xfree(hdr->min_native_rec); } /* end if */ } /* end if */ if(idx == (unsigned)(leaf->nrec - 1)) { if(H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) { if(hdr->max_native_rec) - hdr->max_native_rec = H5MM_free(hdr->max_native_rec); + hdr->max_native_rec = H5MM_xfree(hdr->max_native_rec); } /* end if */ } /* end if */ } /* end if */ @@ -2865,13 +2865,13 @@ H5B2__remove_leaf_by_idx(H5B2_hdr_t *hdr, hid_t dxpl_id, if(idx == 0) { if(H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) { if(hdr->min_native_rec) - hdr->min_native_rec = H5MM_free(hdr->min_native_rec); + hdr->min_native_rec = H5MM_xfree(hdr->min_native_rec); } /* end if */ } /* end if */ if(idx == (unsigned)(leaf->nrec - 1)) { if(H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) { if(hdr->max_native_rec) - hdr->max_native_rec = H5MM_free(hdr->max_native_rec); + hdr->max_native_rec = H5MM_xfree(hdr->max_native_rec); } /* end if */ } /* end if */ } /* end if */ -- cgit v0.12 From fb1525c2b2bb606a39fa6b2d2a50cfa4d3fee640 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Mon, 4 Jan 2016 22:47:55 -0500 Subject: [svn-r28802] Description: Correct another H5MM_free => H5MM_xfree Tested on: MacOSX/64 10.11.2 (amazon) w/serial & parallel --- src/H5FDlog.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/H5FDlog.c b/src/H5FDlog.c index 435ee70..4bb72ce 100644 --- a/src/H5FDlog.c +++ b/src/H5FDlog.c @@ -416,7 +416,7 @@ done: if(NULL == ret_value) if(new_fa) { if(new_fa->logfile) - new_fa->logfile = H5MM_free(new_fa->logfile); + new_fa->logfile = H5MM_xfree(new_fa->logfile); H5MM_free(new_fa); } /* end if */ @@ -445,7 +445,7 @@ H5FD_log_fapl_free(void *_fa) /* Free the fapl information */ if(fa->logfile) - fa->logfile = H5MM_free(fa->logfile); + fa->logfile = H5MM_xfree(fa->logfile); H5MM_xfree(fa); FUNC_LEAVE_NOAPI(SUCCEED) @@ -799,7 +799,7 @@ H5FD_log_close(H5FD_t *_file) } /* end if */ if(file->fa.logfile) - file->fa.logfile = H5MM_free(file->fa.logfile); + file->fa.logfile = H5MM_xfree(file->fa.logfile); /* Release the file info */ file = H5FL_FREE(H5FD_log_t, file); -- cgit v0.12 From 48f7ad2df147d92851c6246155712f430a9f39f0 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Wed, 6 Jan 2016 10:46:02 -0500 Subject: [svn-r28811] Description: Switch v2 B-tree min & max records to be void*'s to be cleaner and generate less warnings. Tested on: Linux/32 2.6.x (jam) w/serial MacOSX/64 10.11.2 (amazon) w/serial & parallel --- src/H5B2.c | 8 ++++---- src/H5B2int.c | 8 ++++---- src/H5B2pkg.h | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/H5B2.c b/src/H5B2.c index 3a712da..a1e9d37 100644 --- a/src/H5B2.c +++ b/src/H5B2.c @@ -615,7 +615,7 @@ H5B2_find(H5B2_t *bt2, hid_t dxpl_id, void *udata, H5B2_found_t op, if(idx == 0) { if(H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) { if(hdr->min_native_rec == NULL) - if(NULL == (hdr->min_native_rec = (uint8_t *)H5MM_malloc(hdr->cls->nrec_size))) + if(NULL == (hdr->min_native_rec = H5MM_malloc(hdr->cls->nrec_size))) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for v2 B-tree min record info") HDmemcpy(hdr->min_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size); } /* end if */ @@ -623,7 +623,7 @@ H5B2_find(H5B2_t *bt2, hid_t dxpl_id, void *udata, H5B2_found_t op, if(idx == (unsigned)(leaf->nrec - 1)) { if(H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) { if(hdr->max_native_rec == NULL) - if(NULL == (hdr->max_native_rec = (uint8_t *)H5MM_malloc(hdr->cls->nrec_size))) + if(NULL == (hdr->max_native_rec = H5MM_malloc(hdr->cls->nrec_size))) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for v2 B-tree max record info") HDmemcpy(hdr->max_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size); } /* end if */ @@ -1225,7 +1225,7 @@ H5B2_modify(H5B2_t *bt2, hid_t dxpl_id, void *udata, H5B2_modify_t op, if(idx == 0) { if(H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) { if(hdr->min_native_rec == NULL) - if(NULL == (hdr->min_native_rec = (uint8_t *)H5MM_malloc(hdr->cls->nrec_size))) + if(NULL == (hdr->min_native_rec = H5MM_malloc(hdr->cls->nrec_size))) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for v2 B-tree min record info") HDmemcpy(hdr->min_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size); } /* end if */ @@ -1233,7 +1233,7 @@ H5B2_modify(H5B2_t *bt2, hid_t dxpl_id, void *udata, H5B2_modify_t op, if(idx == (unsigned)(leaf->nrec - 1)) { if(H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) { if(hdr->max_native_rec == NULL) - if(NULL == (hdr->max_native_rec = (uint8_t *)H5MM_malloc(hdr->cls->nrec_size))) + if(NULL == (hdr->max_native_rec = H5MM_malloc(hdr->cls->nrec_size))) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for v2 B-tree max record info") HDmemcpy(hdr->max_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size); } /* end if */ diff --git a/src/H5B2int.c b/src/H5B2int.c index f3bae69..a69774a 100644 --- a/src/H5B2int.c +++ b/src/H5B2int.c @@ -1641,7 +1641,7 @@ H5B2__insert_leaf(H5B2_hdr_t *hdr, hid_t dxpl_id, H5B2_node_ptr_t *curr_node_ptr if(idx == 0) { if(H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) { if(hdr->min_native_rec == NULL) - if(NULL == (hdr->min_native_rec = (uint8_t *)H5MM_malloc(hdr->cls->nrec_size))) + if(NULL == (hdr->min_native_rec = H5MM_malloc(hdr->cls->nrec_size))) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for v2 B-tree min record info") HDmemcpy(hdr->min_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size); } /* end if */ @@ -1649,7 +1649,7 @@ H5B2__insert_leaf(H5B2_hdr_t *hdr, hid_t dxpl_id, H5B2_node_ptr_t *curr_node_ptr if(idx == (unsigned)(leaf->nrec - 1)) { if(H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) { if(hdr->max_native_rec == NULL) - if(NULL == (hdr->max_native_rec = (uint8_t *)H5MM_malloc(hdr->cls->nrec_size))) + if(NULL == (hdr->max_native_rec = H5MM_malloc(hdr->cls->nrec_size))) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for v2 B-tree max record info") HDmemcpy(hdr->max_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size); } /* end if */ @@ -1930,7 +1930,7 @@ H5B2__update_leaf(H5B2_hdr_t *hdr, hid_t dxpl_id, H5B2_node_ptr_t *curr_node_ptr if(idx == 0) { if(H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) { if(hdr->min_native_rec == NULL) - if(NULL == (hdr->min_native_rec = (uint8_t *)H5MM_malloc(hdr->cls->nrec_size))) + if(NULL == (hdr->min_native_rec = H5MM_malloc(hdr->cls->nrec_size))) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for v2 B-tree min record info") HDmemcpy(hdr->min_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size); } /* end if */ @@ -1938,7 +1938,7 @@ H5B2__update_leaf(H5B2_hdr_t *hdr, hid_t dxpl_id, H5B2_node_ptr_t *curr_node_ptr if(idx == (unsigned)(leaf->nrec - 1)) { if(H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) { if(hdr->max_native_rec == NULL) - if(NULL == (hdr->max_native_rec = (uint8_t *)H5MM_malloc(hdr->cls->nrec_size))) + if(NULL == (hdr->max_native_rec = H5MM_malloc(hdr->cls->nrec_size))) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for v2 B-tree max record info") HDmemcpy(hdr->max_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size); } /* end if */ diff --git a/src/H5B2pkg.h b/src/H5B2pkg.h index d6b6c04..2b2c145 100644 --- a/src/H5B2pkg.h +++ b/src/H5B2pkg.h @@ -182,8 +182,8 @@ typedef struct H5B2_hdr_t { uint8_t *page; /* Common disk page for I/O */ size_t *nat_off; /* Array of offsets of native records */ H5B2_node_info_t *node_info; /* Table of node info structs for current depth of B-tree */ - uint8_t *min_native_rec; /* Pointer to minimum native record */ - uint8_t *max_native_rec; /* Pointer to maximum native record */ + void *min_native_rec; /* Pointer to minimum native record */ + void *max_native_rec; /* Pointer to maximum native record */ /* Client information (not stored) */ const H5B2_class_t *cls; /* Class of B-tree client */ -- cgit v0.12 From 4bf63f78e71aed68ba946dbfda545d657a9a94b5 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Wed, 6 Jan 2016 12:04:15 -0500 Subject: [svn-r28815] Description: Add internal routine to sanity check all blocks allocated through H5MM interface. Tested on: Linux/32 2.6.x (jam) w/serial Linux/64 2.6.x (mayll) w/serial MacOSX/64 10.11.2 (amazon) w/serial & parallel --- src/H5MM.c | 25 +++++++++++++++++++++++++ src/H5MMprivate.h | 1 + 2 files changed, 26 insertions(+) diff --git a/src/H5MM.c b/src/H5MM.c index b6e77eb..fd9a4a9 100644 --- a/src/H5MM.c +++ b/src/H5MM.c @@ -187,6 +187,31 @@ H5MM__sanity_check(void *mem) /*------------------------------------------------------------------------- + * Function: H5MM_sanity_check_all + * + * Purpose: Sanity check all current memory allocations. + * + * Return: N/A (void) + * + * Programmer: Quincey Koziol + * Jan 5 2016 + * + *------------------------------------------------------------------------- + */ +void +H5MM_sanity_check_all(void) +{ + H5MM_block_t *curr; + + curr = H5MM_block_head_s.next; + while(curr != &H5MM_block_head_s) { + H5MM__sanity_check_block(curr); + curr = curr->next; + } /* end while */ +} /* end H5MM_sanity_check_all() */ + + +/*------------------------------------------------------------------------- * Function: H5MM_final_sanity_check * * Purpose: Final sanity checks on memory allocation. diff --git a/src/H5MMprivate.h b/src/H5MMprivate.h index c494a60..14bd28d 100644 --- a/src/H5MMprivate.h +++ b/src/H5MMprivate.h @@ -48,6 +48,7 @@ H5_DLL char *H5MM_xstrdup(const char *s); H5_DLL char *H5MM_strdup(const char *s); H5_DLL void *H5MM_xfree(void *mem); #if defined H5_MEMORY_ALLOC_SANITY_CHECK +H5_DLL void H5MM_sanity_check_all(void); H5_DLL void H5MM_final_sanity_check(void); #endif /* H5_MEMORY_ALLOC_SANITY_CHECK */ -- cgit v0.12 From 06da6031a596c2d19dcc4a253253b6ea33378728 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Wed, 6 Jan 2016 12:50:08 -0500 Subject: [svn-r28819] Description: Align internal memory sanity checking buffer, to avoid problems when optimization is enabled. Tested on: MacOSX/64 10.11.2 (amazon) w/serial & parallel Linux/32 2.6.x (jam) w/serial --- src/H5MM.c | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/src/H5MM.c b/src/H5MM.c index fd9a4a9..b830d21 100644 --- a/src/H5MM.c +++ b/src/H5MM.c @@ -60,9 +60,14 @@ typedef struct H5MM_block_t { unsigned char sig[H5MM_SIG_SIZE]; /* Signature for the block, to indicate it was allocated with H5MM* interface */ struct H5MM_block_t *next; /* Pointer to next block in the list of allocated blocks */ struct H5MM_block_t *prev; /* Pointer to previous block in the list of allocated blocks */ - size_t size; - hbool_t in_use; - unsigned char b[]; + union { + struct { + size_t size; /* Size of allocated block */ + hbool_t in_use; /* Whether the block is in use or is free */ + } info; + double _align; /* Align following buffer (b) to double boundary (unused) */ + } u; + unsigned char b[]; /* Buffer for caller (includes header and footer) */ } H5MM_block_t; #endif /* H5_MEMORY_ALLOC_SANITY_CHECK */ @@ -154,12 +159,12 @@ H5MM__is_our_block(void *mem) static void H5MM__sanity_check_block(const H5MM_block_t *block) { - HDassert(block->size > 0); - HDassert(block->in_use); + HDassert(block->u.info.size > 0); + HDassert(block->u.info.in_use); /* Check for head & tail guards, if not head of linked list */ - if(block->size != SIZET_MAX) { + if(block->u.info.size != SIZET_MAX) { HDassert(0 == HDmemcmp(block->b, H5MM_block_head_guard_s, H5MM_HEAD_GUARD_SIZE)); - HDassert(0 == HDmemcmp(block->b + H5MM_HEAD_GUARD_SIZE + block->size, H5MM_block_tail_guard_s, H5MM_TAIL_GUARD_SIZE)); + HDassert(0 == HDmemcmp(block->b + H5MM_HEAD_GUARD_SIZE + block->u.info.size, H5MM_block_tail_guard_s, H5MM_TAIL_GUARD_SIZE)); } } @@ -271,13 +276,16 @@ H5MM_malloc(size_t size) FUNC_ENTER_NOAPI_NOINIT_NOERR #if defined H5_MEMORY_ALLOC_SANITY_CHECK + /* Make certain that the buffer in the struct is properly aligned */ + HDcompile_assert(offsetof(H5MM_block_t, b) % sizeof(double) == 0); + /* Initialize block list head singleton */ if(!H5MM_init_s) { HDmemcpy(H5MM_block_head_s.sig, H5MM_block_signature_s, H5MM_SIG_SIZE); H5MM_block_head_s.next = &H5MM_block_head_s; H5MM_block_head_s.prev = &H5MM_block_head_s; - H5MM_block_head_s.size = SIZET_MAX; - H5MM_block_head_s.in_use = TRUE; + H5MM_block_head_s.u.info.size = SIZET_MAX; + H5MM_block_head_s.u.info.in_use = TRUE; H5MM_init_s = TRUE; } /* end if */ @@ -295,8 +303,8 @@ H5MM_malloc(size_t size) H5MM_block_head_s.next = block; block->next->prev = block; block->prev = &H5MM_block_head_s; - block->size = size; - block->in_use = TRUE; + block->u.info.size = size; + block->u.info.in_use = TRUE; HDmemcpy(block->b, H5MM_block_head_guard_s, H5MM_HEAD_GUARD_SIZE); HDmemcpy(block->b + H5MM_HEAD_GUARD_SIZE + size, H5MM_block_tail_guard_s, H5MM_TAIL_GUARD_SIZE); @@ -414,7 +422,7 @@ H5MM_realloc(void *mem, size_t size) if(mem) { if(H5MM__is_our_block(mem)) { H5MM_block_t *block = H5MM_BLOCK_FROM_BUF(mem); - size_t old_size = block->size; + size_t old_size = block->u.info.size; H5MM__sanity_check(mem); @@ -545,7 +553,7 @@ H5MM_xfree(void *mem) H5MM__sanity_check_block(block->prev); /* Update statistics */ - H5MM_curr_alloc_bytes_s -= block->size; + H5MM_curr_alloc_bytes_s -= block->u.info.size; H5MM_curr_alloc_blocks_count_s--; /* Reset block info */ @@ -554,7 +562,7 @@ H5MM_xfree(void *mem) block->prev->next = block->next; block->next = NULL; block->prev = NULL; - block->in_use = FALSE; + block->u.info.in_use = FALSE; /* Free the block (finally!) */ HDfree(block); -- cgit v0.12 From b834ac36535d72dd5013514bad5448bf0baa465e Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Wed, 6 Jan 2016 13:33:23 -0500 Subject: [svn-r28821] Merge of r28816 from revise_chunks (tarray.c cleanup). Tested on: 64-bit Ubuntu 15.10 (Linux 4.2.0 x86_64) gcc 5.2.1 serial only --- test/tarray.c | 168 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 84 insertions(+), 84 deletions(-) diff --git a/test/tarray.c b/test/tarray.c index 9c79f41..28798c2 100644 --- a/test/tarray.c +++ b/test/tarray.c @@ -178,7 +178,7 @@ test_array_funcs(void) { hid_t type; /* Datatype ID */ hsize_t tdims1[] = {ARRAY1_DIM1}; - int size; + size_t size; H5T_pad_t inpad; H5T_norm_t norm; H5T_cset_t cset; @@ -190,13 +190,13 @@ test_array_funcs(void) CHECK(type, FAIL, "H5Tarray_create2"); size=H5Tget_precision(type); - CHECK(size, FAIL, "H5Tget_precision"); + CHECK(size, 0, "H5Tget_precision"); size=H5Tget_size(type); - CHECK(size, FAIL, "H5Tget_size"); + CHECK(size, 0, "H5Tget_size"); size=H5Tget_ebias(type); - CHECK(size, FAIL, "H5Tget_ebias"); + CHECK(size, 0, "H5Tget_ebias"); ret=H5Tset_pad(type, H5T_PAD_ZERO, H5T_PAD_ONE); CHECK(ret, FAIL, "H5Tset_pad"); @@ -541,7 +541,7 @@ test_array_compound_atomic(void) for(i = 0; i < SPACE1_DIM1; i++) for(j = 0; j < ARRAY1_DIM1; j++) { wdata[i][j].i = i * 10 + j; - wdata[i][j].f = (float)(i * 2.5F + j); + wdata[i][j].f = (float)i * 2.5F + (float)j; } /* end for */ /* Create file */ @@ -745,7 +745,7 @@ test_array_compound_array(void) for(j=0; jnsubfields = 3; /* Initialize the offsets */ /* ----------------------- */ - dtsinfo.offset[0] = HOFFSET(CmpField, a); - dtsinfo.offset[1] = HOFFSET(CmpField, b); - dtsinfo.offset[2] = HOFFSET(CmpField, c); + dtsinfo->offset[0] = HOFFSET(CmpField, a); + dtsinfo->offset[1] = HOFFSET(CmpField, b); + dtsinfo->offset[2] = HOFFSET(CmpField, c); /* Initialize the data type IDs */ /* ---------------------------- */ - dtsinfo.datatype[0] = H5T_NATIVE_INT; - dtsinfo.datatype[1] = H5T_NATIVE_FLOAT; - dtsinfo.datatype[2] = H5T_NATIVE_DOUBLE; + dtsinfo->datatype[0] = H5T_NATIVE_INT; + dtsinfo->datatype[1] = H5T_NATIVE_FLOAT; + dtsinfo->datatype[2] = H5T_NATIVE_DOUBLE; /* Initialize the names of data members */ /* ------------------------------------ */ - for (i = 0; i < dtsinfo.nsubfields; i++) - dtsinfo.name[i] = (char *)HDcalloc((size_t)20, sizeof(char)); + for (i = 0; i < dtsinfo->nsubfields; i++) + dtsinfo->name[i] = (char *)HDcalloc((size_t)20, sizeof(char)); - strcpy(dtsinfo.name[0], "One"); - strcpy(dtsinfo.name[1], "Two"); - strcpy(dtsinfo.name[2], "Three"); + strcpy(dtsinfo->name[0], "One"); + strcpy(dtsinfo->name[1], "Two"); + strcpy(dtsinfo->name[2], "Three"); /* Create file */ @@ -1585,17 +1584,16 @@ test_array_bkg(void) /* Add members to the compound data type */ /* -------------------------------------- */ - for ( i = 0; i < dtsinfo.nsubfields; i++) - { - array_dt = H5Tarray_create2(dtsinfo.datatype[i], ndims[i], dima); + for ( i = 0; i < dtsinfo->nsubfields; i++) { + array_dt = H5Tarray_create2(dtsinfo->datatype[i], ndims[i], dima); CHECK(array_dt, FAIL, "H5Tarray_create2"); - status = H5Tinsert (type, dtsinfo.name[i], dtsinfo.offset[i], array_dt); + status = H5Tinsert (type, dtsinfo->name[i], dtsinfo->offset[i], array_dt); CHECK(status, FAIL, "H5Tinsert"); status = H5Tclose(array_dt); CHECK(status, FAIL, "H5Tclose"); - } + } /* end for */ /* Create the dataset */ /* ------------------ */ @@ -1617,23 +1615,23 @@ test_array_bkg(void) if(cf[i].a[j]!=cfr[i].a[j]) { TestErrPrintf("Field a data doesn't match, cf[%d].a[%d]=%d, cfr[%d].a[%d]=%d\n",(int)i,(int)j,(int)cf[i].a[j],(int)i,(int)j,(int)cfr[i].a[j]); continue; - } + } /* end if */ if(!H5_FLT_ABS_EQUAL(cf[i].b[j],cfr[i].b[j])) { TestErrPrintf("Field b data doesn't match, cf[%d].b[%d]=%f, cfr[%d].b[%d]=%f\n",(int)i,(int)j,(double)cf[i].b[j],(int)i,(int)j,(double)cfr[i].b[j]); continue; - } + } /* end if */ if(!H5_DBL_ABS_EQUAL(cf[i].c[j],cfr[i].c[j])) { TestErrPrintf("Field c data doesn't match, cf[%d].b[%d]=%f, cfr[%d].b[%d]=%f\n",(int)i,(int)j,(double)cf[i].c[j],(int)i,(int)j,(double)cfr[i].c[j]); continue; - } - } - } + } /* end if */ + } /* end for */ + } /* end for */ /* Release memory resources */ /* ------------------------ */ - for (i = 0; i < dtsinfo.nsubfields; i++) - HDfree(dtsinfo.name[i]); + for (i = 0; i < dtsinfo->nsubfields; i++) + HDfree(dtsinfo->name[i]); /* Release IDs */ @@ -1651,9 +1649,9 @@ test_array_bkg(void) CHECK(status, FAIL, "H5Fclose"); -/******************************/ -/* Reopen the file and update */ -/******************************/ + /******************************/ + /* Reopen the file and update */ + /******************************/ fid = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT); CHECK(fid, FAIL, "H5Fopen"); @@ -1674,7 +1672,7 @@ test_array_bkg(void) /* -------------------------------- */ for (i=0; i< LENGTH; i++) for (j = 0; j < ALEN; j++) - cf[i].b[j]=fld[i].b[j] = 1.313F; + cf[i].b[j] = fld[i].b[j] = 1.313F; status = H5Dwrite (dataset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, fld); CHECK(status, FAIL, "H5Dwrite"); @@ -1688,7 +1686,7 @@ test_array_bkg(void) if(!H5_FLT_ABS_EQUAL(fld[i].b[j],fldr[i].b[j])) { TestErrPrintf("Field data doesn't match, fld[%d].b[%d]=%f, fldr[%d].b[%d]=%f\n",(int)i,(int)j,(double)fld[i].b[j],(int)i,(int)j,(double)fldr[i].b[j]); continue; - } + } /* end if */ status = H5Tclose (type); CHECK(status, FAIL, "H5Tclose"); @@ -1710,17 +1708,17 @@ test_array_bkg(void) if(cf[i].a[j]!=cfr[i].a[j]) { TestErrPrintf("Field a data doesn't match, cf[%d].a[%d]=%d, cfr[%d].a[%d]=%d\n",(int)i,(int)j,(int)cf[i].a[j],(int)i,(int)j,(int)cfr[i].a[j]); continue; - } + } /* end if */ if(!H5_FLT_ABS_EQUAL(cf[i].b[j],cfr[i].b[j])) { TestErrPrintf("Field b data doesn't match, cf[%d].b[%d]=%f, cfr[%d].b[%d]=%f\n",(int)i,(int)j,(double)cf[i].b[j],(int)i,(int)j,(double)cfr[i].b[j]); continue; - } + } /* end if */ if(!H5_DBL_ABS_EQUAL(cf[i].c[j],cfr[i].c[j])) { TestErrPrintf("Field c data doesn't match, cf[%d].b[%d]=%f, cfr[%d].b[%d]=%f\n",(int)i,(int)j,(double)cf[i].c[j],(int)i,(int)j,(double)cfr[i].c[j]); continue; - } - } - } + } /* end if */ + } /* end for */ + } /* end for */ status = H5Dclose(dataset); CHECK(status, FAIL, "H5Dclose"); @@ -1731,9 +1729,9 @@ test_array_bkg(void) status = H5Fclose(fid); CHECK(status, FAIL, "H5Fclose"); -/****************************************************/ -/* Reopen the file and print out all the data again */ -/****************************************************/ + /****************************************************/ + /* Reopen the file and print out all the data again */ + /****************************************************/ fid = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT); CHECK(fid, FAIL, "H5Fopen"); @@ -1759,17 +1757,17 @@ test_array_bkg(void) if(cf[i].a[j]!=cfr[i].a[j]) { TestErrPrintf("Field a data doesn't match, cf[%d].a[%d]=%d, cfr[%d].a[%d]=%d\n",(int)i,(int)j,(int)cf[i].a[j],(int)i,(int)j,(int)cfr[i].a[j]); continue; - } + } /* end if */ if(!H5_FLT_ABS_EQUAL(cf[i].b[j],cfr[i].b[j])) { TestErrPrintf("Field b data doesn't match, cf[%d].b[%d]=%f, cfr[%d].b[%d]=%f\n",(int)i,(int)j,(double)cf[i].b[j],(int)i,(int)j,(double)cfr[i].b[j]); continue; - } + } /* end if */ if(!H5_DBL_ABS_EQUAL(cf[i].c[j],cfr[i].c[j])) { TestErrPrintf("Field c data doesn't match, cf[%d].b[%d]=%f, cfr[%d].b[%d]=%f\n",(int)i,(int)j,(double)cf[i].c[j],(int)i,(int)j,(double)cfr[i].c[j]); continue; - } - } - } + } /* end if */ + } /* end for */ + } /* end for */ status = H5Dclose(dataset); CHECK(status, FAIL, "H5Dclose"); @@ -1779,6 +1777,8 @@ test_array_bkg(void) status = H5Fclose(fid); CHECK(status, FAIL, "H5Fclose"); + + HDfree(dtsinfo); } /* end test_array_bkg() */ /**************************************************************** -- cgit v0.12 From 971af2d7333584e021564f4f50f3afcfba57716f Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Wed, 6 Jan 2016 14:10:21 -0500 Subject: [svn-r28824] Description: Reduce asserts on buffer alignment. Tested on: Linux/32 & Linux/64 2.6.x (jam & myall) w/serial --- src/H5MM.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/H5MM.c b/src/H5MM.c index b830d21..09e6461 100644 --- a/src/H5MM.c +++ b/src/H5MM.c @@ -276,9 +276,6 @@ H5MM_malloc(size_t size) FUNC_ENTER_NOAPI_NOINIT_NOERR #if defined H5_MEMORY_ALLOC_SANITY_CHECK - /* Make certain that the buffer in the struct is properly aligned */ - HDcompile_assert(offsetof(H5MM_block_t, b) % sizeof(double) == 0); - /* Initialize block list head singleton */ if(!H5MM_init_s) { HDmemcpy(H5MM_block_head_s.sig, H5MM_block_signature_s, H5MM_SIG_SIZE); -- cgit v0.12 From e9a63d30df37fba8b879f18f39cf96b3d46bd615 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Wed, 6 Jan 2016 15:45:25 -0500 Subject: [svn-r28828] Description: Switch filter plugin to use H5allocate_memory and H5free_memory instead of malloc and free. Tested on: Linux/32 2.6.x (jam) w/serial Linux/64 2.6.x (jam) w/serial MacOSX/64 10.11.2 (amazon) w/serial & parallel --- test/dynlib3.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/dynlib3.c b/test/dynlib3.c index b3a02ed..e509a52 100644 --- a/test/dynlib3.c +++ b/test/dynlib3.c @@ -81,7 +81,7 @@ H5Z_filter_dynlib3(unsigned int flags, size_t cd_nelmts, void *outbuf = NULL; /* Pointer to new buffer */ unsigned char *dst; /* Temporary pointer to destination buffer */ - dst = (unsigned char *)(outbuf = malloc(nbytes + SUFFIX_LEN)); + dst = (unsigned char *)(outbuf = H5allocate_memory(nbytes + SUFFIX_LEN, 0)); /* Copy raw data */ memcpy((void*)dst, (void*)(*buf), nbytes); @@ -91,7 +91,7 @@ H5Z_filter_dynlib3(unsigned int flags, size_t cd_nelmts, memcpy(dst, (void*)GROUP_SUFFIX, SUFFIX_LEN); /* Free input buffer */ - free(*buf); + H5free_memory(*buf); /* Set return values */ *buf_size = nbytes + SUFFIX_LEN; -- cgit v0.12 From dc63336a4a863f1222f698d882e0862b72aa93fc Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Wed, 6 Jan 2016 17:05:32 -0500 Subject: [svn-r28832] Description: Reset driver info message when superblock load fails. Tested on: MacOSX/64 10.11.2 (amazon) w/serial & parallel Linux/32 2.6.x (jam) w/serial Linux/64 2.6.x (mayll) w/serial --- src/H5Fsuper.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/H5Fsuper.c b/src/H5Fsuper.c index a0f9536..332dfa6 100644 --- a/src/H5Fsuper.c +++ b/src/H5Fsuper.c @@ -510,8 +510,10 @@ H5F__super_read(H5F_t *f, hid_t dxpl_id) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "driver info message not present") /* Validate and decode driver information */ - if(H5FD_sb_load(f->shared->lf, drvinfo.name, drvinfo.buf) < 0) + if(H5FD_sb_load(f->shared->lf, drvinfo.name, drvinfo.buf) < 0) { + H5O_msg_reset(H5O_DRVINFO_ID, &drvinfo); HGOTO_ERROR(H5E_FILE, H5E_CANTDECODE, FAIL, "unable to decode driver information") + } /* end if */ /* Reset driver info message */ H5O_msg_reset(H5O_DRVINFO_ID, &drvinfo); -- cgit v0.12 From ed380746fe131bf1aeb3d8135c5ff31705312cb0 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Thu, 7 Jan 2016 12:45:11 -0500 Subject: [svn-r28837] Merged r28836 from revise_chunks (tarray.c fix). Tested on ostrich w/ gcc --- test/tarray.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/tarray.c b/test/tarray.c index 28798c2..cb5fef9 100644 --- a/test/tarray.c +++ b/test/tarray.c @@ -1031,8 +1031,8 @@ test_array_vlen_atomic(void) H5T_class_t mclass; /* Datatype class for VL */ hid_t xfer_pid; /* Dataset transfer property list ID */ hsize_t size; /* Number of bytes which will be used */ - int mem_used=0; /* Memory used during allocation */ - int i,j,k; /* counting variables */ + size_t mem_used=0; /* Memory used during allocation */ + int i,j,k; /* counting variables */ herr_t ret; /* Generic return value */ /* Output message about test being performed */ @@ -1242,8 +1242,8 @@ test_array_vlen_array(void) H5T_class_t mclass; /* Datatype class for VL */ hid_t xfer_pid; /* Dataset transfer property list ID */ hsize_t size; /* Number of bytes which will be used */ - int mem_used=0; /* Memory used during allocation */ - int i,j,k,l; /* Index variables */ + size_t mem_used=0; /* Memory used during allocation */ + int i,j,k,l; /* Index variables */ herr_t ret; /* Generic return value */ /* Output message about test being performed */ -- cgit v0.12 From 74fbe507ae0e69d689409560c37974d92d28ad10 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Thu, 7 Jan 2016 15:27:37 -0500 Subject: [svn-r28841] indentations were messed up by some previous commit. Restored them to more readable spacing. No code change. Test: visual inspection. --- bin/cmakehdf5 | 222 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 111 insertions(+), 111 deletions(-) diff --git a/bin/cmakehdf5 b/bin/cmakehdf5 index 48869cf..6e22e17 100755 --- a/bin/cmakehdf5 +++ b/bin/cmakehdf5 @@ -124,12 +124,12 @@ STEP() echo "$banner" with output saved in $logfile (TIMESTAMP; nerror=0 ; - echo "eval $command" - eval $command || nerror=1 ; - TIMESTAMP; exit $nerror) < /dev/null > "$logfile" 2>&1 + echo "eval $command" + eval $command || nerror=1 ; + TIMESTAMP; exit $nerror) < /dev/null > "$logfile" 2>&1 if [ $? -ne 0 ]; then - echo "error in '$banner'. $progname aborted." - exit 1 + echo "error in '$banner'. $progname aborted." + exit 1 fi } @@ -143,26 +143,26 @@ INSTALL_HDF5() { myos="`uname -s`" case "$myos" in - Linux) - install_file=./HDF5-${version}-Linux.sh - $install_file --skip-license $* - ;; - Darwin) # Mac OSX DMG file - install_file=HDF5-${version}-Darwin.dmg - test -d hdf5 || mkdir hdf5 - basename=`basename $install_file .dmg` - # mount the DMG file as /Volumes/$basename - # echo 'Y' as yes for license. - echo Y | hdiutil mount $install_file - # copy the contents to the install location - cp -R "/Volumes/$basename/HDF_Group" hdf5 - # unmount the DMG file - hdiutil unmount /Volumes/$basename - ;; - *) # unknown/unsupported OS. - echo "INSTALL_HDF5: Error--unknown/unsupported OS($myos)" - return 1 - ;; + Linux) + install_file=./HDF5-${version}-Linux.sh + $install_file --skip-license $* + ;; + Darwin) # Mac OSX DMG file + install_file=HDF5-${version}-Darwin.dmg + test -d hdf5 || mkdir hdf5 + basename=`basename $install_file .dmg` + # mount the DMG file as /Volumes/$basename + # echo 'Y' as yes for license. + echo Y | hdiutil mount $install_file + # copy the contents to the install location + cp -R "/Volumes/$basename/HDF_Group" hdf5 + # unmount the DMG file + hdiutil unmount /Volumes/$basename + ;; + *) # unknown/unsupported OS. + echo "INSTALL_HDF5: Error--unknown/unsupported OS($myos)" + return 1 + ;; esac } @@ -172,14 +172,14 @@ INSTALL_HDF5() DUMP_LOGFILE() { for x in $*; do - if [ -f $x ]; then - echo "==================================" - echo "Dumping $x" - echo "==================================" - cat $x - echo "==== END $x =====" - echo - fi + if [ -f $x ]; then + echo "==================================" + echo "Dumping $x" + echo "==================================" + cat $x + echo "==== END $x =====" + echo + fi done } @@ -207,84 +207,84 @@ fi # tools Build tools while [ $# -gt 0 ]; do case "$1" in - --enable-fortran) - build_fortran=-DHDF5_BUILD_FORTRAN:BOOL=ON - ;; - --disable-fortran) - build_fortran=-DHDF5_BUILD_FORTRAN:BOOL=OFF - ;; - --enable-cxx) - build_cpp_lib=-DHDF5_BUILD_CPP_LIB:BOOL=ON - ;; - --disable-cxx) - build_cpp_lib=-DHDF5_BUILD_CPP_LIB:BOOL=OFF - ;; - --enable-hl) - build_hl_lib=-DHDF5_BUILD_HL_LIB:BOOL=ON - ;; - --disable-hl) - build_hl_lib=-DHDF5_BUILD_HL_LIB:BOOL=OFF - ;; - --enable-shared) - shared_lib=-DBUILD_SHARED_LIBS:BOOL=ON - ;; - --disable-shared) - shared_lib=-DBUILD_SHARED_LIBS:BOOL=OFF - ;; - --enable-tools) - build_tools=-DHDF5_BUILD_TOOLS:BOOL=ON - ;; - --disable-tools) - build_tools=-DHDF5_BUILD_TOOLS:BOOL=OFF - ;; - --enable-testing) - build_testing=-DBUILD_TESTING:BOOL=ON - ;; - --disable-testing) - build_testing=-DBUILD_TESTING:BOOL=OFF - ;; - --with-zlib) - with_zlib=-DHDF5_ENABLE_Z_LIB_SUPPORT:BOOL=ON - ;; - --with-zlib=*) - xarg=`echo $1 | cut -d= -f2-` - with_zlib="-DHDF5_ENABLE_Z_LIB_SUPPORT:BOOL=ON -DZLIB_ROOT=$xarg" - ;; - --without-zlib) - with_zlib=-DHDF5_ENABLE_Z_LIB_SUPPORT:BOOL=OFF - ;; - --with-szlib) - with_szlib=-DHDF5_ENABLE_SZIP_SUPPORT:BOOL=ON - szlib_path="" # szlib is in default paths - ;; - --with-szlib=*) - xarg=`echo $1 | cut -d= -f2-` - with_szlib="-DHDF5_ENABLE_SZIP_SUPPORT:BOOL=ON" - szlib_path="SZIP_INSTALL=$xarg" - ;; - --without-szlib) - with_szlib=-DHDF5_ENABLE_SZIP_SUPPORT:BOOL=OFF - szlib_path="" # reset the path - ;; - --njobs=*) - njobs=`echo $1 | cut -d= -f2-` - ;; - --enable-verbose) - vflag=1 - ;; - --disable-verbose) - vflag=0 - ;; - --help) - # print the detail help page and exit - HELP - exit 0 - ;; - *) - echo "Unknown options: $1" - HELP - exit 1 - ;; + --enable-fortran) + build_fortran=-DHDF5_BUILD_FORTRAN:BOOL=ON + ;; + --disable-fortran) + build_fortran=-DHDF5_BUILD_FORTRAN:BOOL=OFF + ;; + --enable-cxx) + build_cpp_lib=-DHDF5_BUILD_CPP_LIB:BOOL=ON + ;; + --disable-cxx) + build_cpp_lib=-DHDF5_BUILD_CPP_LIB:BOOL=OFF + ;; + --enable-hl) + build_hl_lib=-DHDF5_BUILD_HL_LIB:BOOL=ON + ;; + --disable-hl) + build_hl_lib=-DHDF5_BUILD_HL_LIB:BOOL=OFF + ;; + --enable-shared) + shared_lib=-DBUILD_SHARED_LIBS:BOOL=ON + ;; + --disable-shared) + shared_lib=-DBUILD_SHARED_LIBS:BOOL=OFF + ;; + --enable-tools) + build_tools=-DHDF5_BUILD_TOOLS:BOOL=ON + ;; + --disable-tools) + build_tools=-DHDF5_BUILD_TOOLS:BOOL=OFF + ;; + --enable-testing) + build_testing=-DBUILD_TESTING:BOOL=ON + ;; + --disable-testing) + build_testing=-DBUILD_TESTING:BOOL=OFF + ;; + --with-zlib) + with_zlib=-DHDF5_ENABLE_Z_LIB_SUPPORT:BOOL=ON + ;; + --with-zlib=*) + xarg=`echo $1 | cut -d= -f2-` + with_zlib="-DHDF5_ENABLE_Z_LIB_SUPPORT:BOOL=ON -DZLIB_ROOT=$xarg" + ;; + --without-zlib) + with_zlib=-DHDF5_ENABLE_Z_LIB_SUPPORT:BOOL=OFF + ;; + --with-szlib) + with_szlib=-DHDF5_ENABLE_SZIP_SUPPORT:BOOL=ON + szlib_path="" # szlib is in default paths + ;; + --with-szlib=*) + xarg=`echo $1 | cut -d= -f2-` + with_szlib="-DHDF5_ENABLE_SZIP_SUPPORT:BOOL=ON" + szlib_path="SZIP_INSTALL=$xarg" + ;; + --without-szlib) + with_szlib=-DHDF5_ENABLE_SZIP_SUPPORT:BOOL=OFF + szlib_path="" # reset the path + ;; + --njobs=*) + njobs=`echo $1 | cut -d= -f2-` + ;; + --enable-verbose) + vflag=1 + ;; + --disable-verbose) + vflag=0 + ;; + --help) + # print the detail help page and exit + HELP + exit 0 + ;; + *) + echo "Unknown options: $1" + HELP + exit 1 + ;; esac shift done -- cgit v0.12 From 887cf130ff773568f90ec8bae66dafa761a77712 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Fri, 8 Jan 2016 09:08:00 -0500 Subject: [svn-r28843] Description: Bump number of records for random update test again. Tested on: MacOSX/64 10.11.2 (amazon) w/serial & parallel (h5committest forthcoming) --- test/btree2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/btree2.c b/test/btree2.c index 3278b67..2c9bbae 100644 --- a/test/btree2.c +++ b/test/btree2.c @@ -38,7 +38,7 @@ const char *FILENAME[] = { #define INSERT_SPLIT_ROOT_NREC 63 #define INSERT_SPLIT_ROOT_NREC_REC 64 #define INSERT_MANY (1000 * 1000) -#define INSERT_MANY_REC (2675 * 1000) +#define INSERT_MANY_REC (2700 * 1000) #define FIND_MANY (INSERT_MANY / 100) #define FIND_MANY_REC (INSERT_MANY_REC / 100) #define FIND_NEIGHBOR 2000 -- cgit v0.12