From a4750dfae7e187f95c4515939968e6fce880efed Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Tue, 1 Dec 2009 13:34:23 -0500 Subject: [svn-r17946] Description: Bring r17899:17945 from trunk to revise_chunks branch Tested on: FreeBSD/32 6.3 (duty) in debug mode FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x, w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64-amd64 2.6 (smirom) w/Intel compilers, w/default API=1.6.x, w/C++ & FORTRAN, in production mode Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN, w/szip filter, in production mode Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN, in production mode Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in debug mode Mac OS X/32 10.6.2 (amazon) in debug mode Mac OS X/32 10.6.2 (amazon) w/C++ & FORTRAN, w/threadsafe, in production mode --- MANIFEST | 1 + README.txt | 2 +- c++/src/Makefile.in | 2 +- config/lt_vers.am | 2 +- config/powerpc-ibm-aix5.x | 2 +- configure | 40 +-- configure.in | 13 +- fortran/src/Makefile.in | 2 +- hl/c++/src/Makefile.in | 2 +- hl/fortran/src/Makefile.in | 2 +- hl/src/Makefile.in | 2 +- perform/sio_standalone.h | 5 +- release_docs/RELEASE.txt | 18 +- src/H5AC.c | 2 +- src/H5Abtree2.c | 36 ++- src/H5Adense.c | 32 +- src/H5Aint.c | 4 +- src/H5B2.c | 73 +++-- src/H5B2cache.c | 13 +- src/H5B2dbg.c | 42 ++- src/H5B2hdr.c | 34 ++- src/H5B2pkg.h | 9 +- src/H5B2private.h | 32 +- src/H5B2test.c | 155 +++++++++- src/H5F.c | 198 +++++++------ src/H5FAtest.c | 49 +++- src/H5FD.c | 6 +- src/H5FDlog.c | 20 +- src/H5FDpublic.h | 6 + src/H5FDsec2.c | 83 ++++-- src/H5FDsec2.h | 1 + src/H5Fdbg.c | 4 +- src/H5Fpkg.h | 12 +- src/H5Fprivate.h | 21 +- src/H5Fquery.c | 130 +++++++-- src/H5Gbtree2.c | 36 ++- src/H5Gdense.c | 30 +- src/H5Gloc.c | 4 +- src/H5Gobj.c | 2 +- src/H5Goh.c | 4 +- src/H5Gtest.c | 4 +- src/H5HFbtree2.c | 532 +++++++++++++++++++++++----------- src/H5HFhuge.c | 24 +- src/H5HFpkg.h | 8 +- src/H5HFstat.c | 2 +- src/H5Lexternal.c | 205 +++++++------ src/H5Oattribute.c | 4 +- src/H5Otest.c | 8 +- src/H5SM.c | 101 +------ src/H5SMbtree2.c | 308 +++++++------------- src/H5SMcache.c | 8 +- src/H5SMmessage.c | 358 +++++++++++++++++++++++ src/H5SMpkg.h | 21 +- src/H5config.h.in | 9 +- src/H5private.h | 23 +- src/H5public.h | 4 +- src/H5system.c | 89 +++--- src/H5win32defs.h | 1 + src/Makefile.am | 6 +- src/Makefile.in | 23 +- test/btree2.c | 22 +- test/links.c | 372 +++++++++++++++++------- tools/h5diff/testfiles/h5diff_200.txt | 1 + tools/h5diff/testfiles/h5diff_201.txt | 1 + tools/h5diff/testfiles/h5diff_202.txt | 1 + tools/h5diff/testfiles/h5diff_203.txt | 1 + tools/h5diff/testfiles/h5diff_204.txt | 1 + tools/h5diff/testfiles/h5diff_205.txt | 1 + tools/h5diff/testfiles/h5diff_206.txt | 1 + tools/h5diff/testfiles/h5diff_207.txt | 1 + tools/h5diff/testfiles/h5diff_609.txt | 2 + tools/h5diff/testfiles/h5diff_618.txt | 2 + tools/lib/h5diff.c | 50 +--- tools/lib/h5diff_attr.c | 110 +++---- tools/misc/h5debug.c | 8 +- vms/src/h5pubconf.h | 12 +- windows/src/H5pubconf.h | 12 +- 77 files changed, 2250 insertions(+), 1217 deletions(-) create mode 100644 src/H5SMmessage.c diff --git a/MANIFEST b/MANIFEST index 919ffad..bc6c704 100644 --- a/MANIFEST +++ b/MANIFEST @@ -732,6 +732,7 @@ ./src/H5SM.c ./src/H5SMbtree2.c ./src/H5SMcache.c +./src/H5SMmessage.c ./src/H5SMpkg.h ./src/H5SMprivate.h ./src/H5SMtest.c diff --git a/README.txt b/README.txt index 99f457d..5078ec9 100644 --- a/README.txt +++ b/README.txt @@ -1,4 +1,4 @@ -HDF5 version 1.9.51-FA_a4 currently under development +HDF5 version 1.9.52-FA_a4 currently under development Please refer to the release_docs/INSTALL file for installation instructions. ------------------------------------------------------------------------------ diff --git a/c++/src/Makefile.in b/c++/src/Makefile.in index 39dee40..a76df89 100644 --- a/c++/src/Makefile.in +++ b/c++/src/Makefile.in @@ -390,7 +390,7 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog # Add libtool shared library version numbers to the HDF5 library # See libtool versioning documentation online. LT_VERS_INTERFACE = 6 -LT_VERS_REVISION = 41 +LT_VERS_REVISION = 42 LT_VERS_AGE = 0 # Include src directory diff --git a/config/lt_vers.am b/config/lt_vers.am index f784c48..7e4079b 100644 --- a/config/lt_vers.am +++ b/config/lt_vers.am @@ -17,7 +17,7 @@ # Add libtool shared library version numbers to the HDF5 library # See libtool versioning documentation online. LT_VERS_INTERFACE = 6 -LT_VERS_REVISION = 41 +LT_VERS_REVISION = 42 LT_VERS_AGE = 0 ## If the API changes *at all*, increment LT_VERS_INTERFACE and diff --git a/config/powerpc-ibm-aix5.x b/config/powerpc-ibm-aix5.x index ac70bac..96ad26a 100644 --- a/config/powerpc-ibm-aix5.x +++ b/config/powerpc-ibm-aix5.x @@ -43,7 +43,7 @@ fi # `--enable-debug' switch of configure. case $CC_BASENAME in - xlc|mpcc_r) + xlc|xlc-*|mpcc_r|mpcc_r-*) # Turn off shared lib option. It causes some test suite to fail. enable_shared="${enable_shared:-no}" # Use -D_LARGE_FILES by default to support large file size. diff --git a/configure b/configure index 2a82389..5e73b43 100755 --- a/configure +++ b/configure @@ -1,7 +1,7 @@ #! /bin/sh -# From configure.in Id: configure.in 17547 2009-09-29 15:21:35Z koziol . +# From configure.in Id: configure.in 17896 2009-11-16 21:45:05Z koziol . # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.64 for HDF5 1.9.51-FA_a4. +# Generated by GNU Autoconf 2.64 for HDF5 1.9.52-FA_a4. # # Report bugs to . # @@ -699,8 +699,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='HDF5' PACKAGE_TARNAME='hdf5' -PACKAGE_VERSION='1.9.51-FA_a4' -PACKAGE_STRING='HDF5 1.9.51-FA_a4' +PACKAGE_VERSION='1.9.52-FA_a4' +PACKAGE_STRING='HDF5 1.9.52-FA_a4' PACKAGE_BUGREPORT='help@hdfgroup.org' PACKAGE_URL='' @@ -1571,7 +1571,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures HDF5 1.9.51-FA_a4 to adapt to many kinds of systems. +\`configure' configures HDF5 1.9.52-FA_a4 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1641,7 +1641,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of HDF5 1.9.51-FA_a4:";; + short | recursive ) echo "Configuration of HDF5 1.9.52-FA_a4:";; esac cat <<\_ACEOF @@ -1828,7 +1828,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -HDF5 configure 1.9.51-FA_a4 +HDF5 configure 1.9.52-FA_a4 generated by GNU Autoconf 2.64 Copyright (C) 2009 Free Software Foundation, Inc. @@ -2912,7 +2912,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by HDF5 $as_me 1.9.51-FA_a4, which was +It was created by HDF5 $as_me 1.9.52-FA_a4, which was generated by GNU Autoconf 2.64. Invocation command line was $ $0 $@ @@ -3725,7 +3725,7 @@ fi # Define the identity of the package. PACKAGE='hdf5' - VERSION='1.9.51-FA_a4' + VERSION='1.9.52-FA_a4' cat >>confdefs.h <<_ACEOF @@ -24740,7 +24740,7 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -for ac_func in alarm fork frexpf frexpl gethostname getpwuid getrusage +for ac_func in alarm BSDgettimeofday fork frexpf frexpl do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" @@ -24753,7 +24753,7 @@ _ACEOF fi done -for ac_func in BSDgettimeofday siglongjmp longjmp setsysinfo sigaction +for ac_func in gethostname getpwuid getrusage longjmp lstat do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" @@ -24766,7 +24766,7 @@ _ACEOF fi done -for ac_func in signal snprintf vasprintf strdup system waitpid +for ac_func in rand_r random setsysinfo siglongjmp signal do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" @@ -24779,7 +24779,7 @@ _ACEOF fi done -for ac_func in rand_r random srandom +for ac_func in snprintf srandom strdup symlink system do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" @@ -24792,12 +24792,14 @@ _ACEOF fi done -for ac_func in tmpfile +for ac_func in tmpfile vasprintf waitpid do : - ac_fn_c_check_func "$LINENO" "tmpfile" "ac_cv_func_tmpfile" -if test "x$ac_cv_func_tmpfile" = x""yes; then : + as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" +eval as_val=\$$as_ac_var + if test "x$as_val" = x""yes; then : cat >>confdefs.h <<_ACEOF -#define HAVE_TMPFILE 1 +#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi @@ -28845,7 +28847,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by HDF5 $as_me 1.9.51-FA_a4, which was +This file was extended by HDF5 $as_me 1.9.52-FA_a4, which was generated by GNU Autoconf 2.64. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -28909,7 +28911,7 @@ Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_version="\\ -HDF5 config.status 1.9.51-FA_a4 +HDF5 config.status 1.9.52-FA_a4 configured by $0, generated by GNU Autoconf 2.64, with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" diff --git a/configure.in b/configure.in index 09483fc..11868e7 100644 --- a/configure.in +++ b/configure.in @@ -26,7 +26,7 @@ dnl dnl NOTE: Don't forget to change the version number here when we do a dnl release!!! dnl -AC_INIT([HDF5], [1.9.51-FA_a4], [help@hdfgroup.org]) +AC_INIT([HDF5], [1.9.52-FA_a4], [help@hdfgroup.org]) AC_CONFIG_SRCDIR([src/H5.c]) AM_CONFIG_HEADER([src/H5config.h]) @@ -1974,13 +1974,12 @@ AC_MSG_RESULT([no])) dnl ---------------------------------------------------------------------- dnl Check for functions. -dnl tmpfile needed by h5pdiff. dnl -AC_CHECK_FUNCS(alarm fork frexpf frexpl gethostname getpwuid getrusage) -AC_CHECK_FUNCS(BSDgettimeofday siglongjmp longjmp setsysinfo sigaction) -AC_CHECK_FUNCS(signal snprintf vasprintf strdup system waitpid) -AC_CHECK_FUNCS(rand_r random srandom) -AC_CHECK_FUNCS(tmpfile) +AC_CHECK_FUNCS(alarm BSDgettimeofday fork frexpf frexpl) +AC_CHECK_FUNCS(gethostname getpwuid getrusage longjmp lstat) +AC_CHECK_FUNCS(rand_r random setsysinfo siglongjmp signal) +AC_CHECK_FUNCS(snprintf srandom strdup symlink system) +AC_CHECK_FUNCS(tmpfile vasprintf waitpid) dnl Check for vsnprintf() separately, so we can detect situations where it dnl doesn't return the correct size for formatted strings that are too large diff --git a/fortran/src/Makefile.in b/fortran/src/Makefile.in index a25b09e..3205695 100644 --- a/fortran/src/Makefile.in +++ b/fortran/src/Makefile.in @@ -424,7 +424,7 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog # Add libtool shared library version numbers to the HDF5 library # See libtool versioning documentation online. LT_VERS_INTERFACE = 6 -LT_VERS_REVISION = 41 +LT_VERS_REVISION = 42 LT_VERS_AGE = 0 # Include src directory in both Fortran and C flags (C compiler is used diff --git a/hl/c++/src/Makefile.in b/hl/c++/src/Makefile.in index ad49fe4..069db9c 100644 --- a/hl/c++/src/Makefile.in +++ b/hl/c++/src/Makefile.in @@ -380,7 +380,7 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog # Add libtool shared library version numbers to the HDF5 library # See libtool versioning documentation online. LT_VERS_INTERFACE = 6 -LT_VERS_REVISION = 41 +LT_VERS_REVISION = 42 LT_VERS_AGE = 0 # Include src directory diff --git a/hl/fortran/src/Makefile.in b/hl/fortran/src/Makefile.in index def1880..a3ce044 100644 --- a/hl/fortran/src/Makefile.in +++ b/hl/fortran/src/Makefile.in @@ -389,7 +389,7 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog # Add libtool shared library version numbers to the HDF5 library # See libtool versioning documentation online. LT_VERS_INTERFACE = 6 -LT_VERS_REVISION = 41 +LT_VERS_REVISION = 42 LT_VERS_AGE = 0 INCLUDES = -I$(top_srcdir)/src -I$(top_srcdir)/hl/src -I$(top_builddir)/hl/src \ -I$(top_srcdir)/fortran/src -I$(top_builddir)/fortran/src diff --git a/hl/src/Makefile.in b/hl/src/Makefile.in index 35282d2..2aca5fa 100644 --- a/hl/src/Makefile.in +++ b/hl/src/Makefile.in @@ -380,7 +380,7 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog # Add libtool shared library version numbers to the HDF5 library # See libtool versioning documentation online. LT_VERS_INTERFACE = 6 -LT_VERS_REVISION = 41 +LT_VERS_REVISION = 42 LT_VERS_AGE = 0 # This library is our main target. diff --git a/perform/sio_standalone.h b/perform/sio_standalone.h index 9faaac1..b31d4846 100644 --- a/perform/sio_standalone.h +++ b/perform/sio_standalone.h @@ -177,22 +177,26 @@ H5_DLL int HDfprintf (FILE *stream, const char *fmt, ...); #ifdef _WIN32 #ifdef __MWERKS__ #define HDfstat(F,B) fstat(F,B) + #define HDlstat(S,B) lstat(S,B) #define HDstat(S,B) stat(S,B) typedef struct stat h5_stat_t; typedef off_t h5_stat_size_t; #else /*MSVC*/ #define HDfstat(F,B) _fstati64(F,B) + #define HDlstat(S,B) _lstati64(S,B) #define HDstat(S,B) _stati64(S,B) typedef struct _stati64 h5_stat_t; typedef __int64 h5_stat_size_t; #endif #elif H5_SIZEOF_OFF_T!=8 && H5_SIZEOF_OFF64_T==8 && defined(H5_HAVE_STAT64) #define HDfstat(F,B) fstat64(F,B) + #define HDlstat(S,B) lstat64(S,B) #define HDstat(S,B) stat64(S,B) typedef struct stat64 h5_stat_t; typedef off64_t h5_stat_size_t; #else #define HDfstat(F,B) fstat(F,B) + #define HDlstat(S,B) lstat(S,B) #define HDstat(S,B) stat(S,B) typedef struct stat h5_stat_t; typedef off_t h5_stat_size_t; @@ -349,7 +353,6 @@ int HDremove_all(const char * fname); #else #define HDsetvbuf(F,S,M,Z) setvbuf(F,S,M,(Z>1?Z:2)) #endif -#define HDsigaction(N,A) sigaction(N,A) #define HDsigaddset(S,N) sigaddset(S,N) #define HDsigdelset(S,N) sigdelset(S,N) #define HDsigemptyset(S) sigemptyset(S) diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index e122005..9264bc1 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -1,4 +1,4 @@ -HDF5 version 1.9.51-FA_a4 currently under development +HDF5 version 1.9.52-FA_a4 currently under development ================================================================================ @@ -39,6 +39,10 @@ New Features Configuration: ------------- + - Added the xlc-* and mpcc_r-* BASENAME patterns to be recognized as IBM + compilers so that the ibm compiler options can be added properly. This + allows non-system-default compiler command names (e.g. xlc-m.n.k.l) be + recognized. AKC 2009/11/26. - Configuration suite now uses Automake 1.11 and Autoconf 2.64. MAM 2009/08/11. - Changed default Gnu fortran compiler from g95 to gfortran since @@ -138,6 +142,8 @@ New Features Tools: ------ + - h5diff: fix for displaying garbage value on LE machine for BE data. + (JKM - 2009/11/20) - h5dump subsetting now allows default for count. Also trailing ; in short form can be omitted after last specified value. (ADB - 2009/09/04) - h5dump/h5ls now can display data in region references @@ -464,11 +470,11 @@ Bug Fixes since HDF5-1.8.0 release Platforms Tested ================ - AIX 5.2 (32/64 bit) xlc 8.0.0.11 - xlC 8.0 - xlf 10.01.0000.0 - mpcc_r 6.0.0.8 - mpxlf_r 8.1.1.7 + AIX 5.3 xlc 7.0.0.8, 8.0.0.20, 9.0.0.4 + (LLNL Up) xlC 7.0.0.8, 8.0.0.20, 9.0.0.4 + xlf 9.1.0.8, 10.1.0.9, 11.1.0.7 + mpcc_r 7.0.0.8 + mpxlf_r 09.01.0000.0008 FreeBSD 6.2-STABLE i386 gcc 3.4.6 [FreeBSD] 20060305 (duty) g++ 3.4.6 [FreeBSD] 20060305 gcc 4.2.1 20080123 diff --git a/src/H5AC.c b/src/H5AC.c index 2084bfe..36527215 100644 --- a/src/H5AC.c +++ b/src/H5AC.c @@ -2494,7 +2494,7 @@ H5AC_stats(const H5F_t *f) HDassert(f->shared->cache); /* at present, this can't fail */ - (void)H5C_stats(f->shared->cache, f->name, FALSE); + (void)H5C_stats(f->shared->cache, H5F_OPEN_NAME(f), FALSE); done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Abtree2.c b/src/H5Abtree2.c index 7d0bb4c..eb2c741 100644 --- a/src/H5Abtree2.c +++ b/src/H5Abtree2.c @@ -81,20 +81,20 @@ typedef struct H5A_fh_ud_cmp_t { /* v2 B-tree driver callbacks for 'creation order' index */ static herr_t H5A_dense_btree2_corder_store(void *native, const void *udata); static herr_t H5A_dense_btree2_corder_compare(const void *rec1, const void *rec2); -static herr_t H5A_dense_btree2_corder_encode(const H5F_t *f, uint8_t *raw, - const void *native); -static herr_t H5A_dense_btree2_corder_decode(const H5F_t *f, const uint8_t *raw, - void *native); +static herr_t H5A_dense_btree2_corder_encode(uint8_t *raw, const void *native, + void *ctx); +static herr_t H5A_dense_btree2_corder_decode(const uint8_t *raw, void *native, + void *ctx); static herr_t H5A_dense_btree2_corder_debug(FILE *stream, const H5F_t *f, hid_t dxpl_id, int indent, int fwidth, const void *record, const void *_udata); /* v2 B-tree driver callbacks for 'name' index */ static herr_t H5A_dense_btree2_name_store(void *native, const void *udata); static herr_t H5A_dense_btree2_name_compare(const void *rec1, const void *rec2); -static herr_t H5A_dense_btree2_name_encode(const H5F_t *f, uint8_t *raw, - const void *native); -static herr_t H5A_dense_btree2_name_decode(const H5F_t *f, const uint8_t *raw, - void *native); +static herr_t H5A_dense_btree2_name_encode(uint8_t *raw, const void *native, + void *ctx); +static herr_t H5A_dense_btree2_name_decode(const uint8_t *raw, void *native, + void *ctx); static herr_t H5A_dense_btree2_name_debug(FILE *stream, const H5F_t *f, hid_t dxpl_id, int indent, int fwidth, const void *record, const void *_udata); @@ -110,11 +110,15 @@ const H5B2_class_t H5A_BT2_NAME[1]={{ /* B-tree class information */ H5B2_ATTR_DENSE_NAME_ID, /* Type of B-tree */ "H5B2_ATTR_DENSE_NAME_ID", /* Name of B-tree class */ sizeof(H5A_dense_bt2_name_rec_t), /* Size of native record */ + NULL, /* Create client callback context */ + NULL, /* Destroy client callback context */ H5A_dense_btree2_name_store, /* Record storage callback */ 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 */ + H5A_dense_btree2_name_debug, /* Record debugging callback */ + NULL, /* Create debugging context */ + NULL /* Destroy debugging context */ }}; /* v2 B-tree class for indexing 'creation order' field of attributes */ @@ -122,11 +126,15 @@ const H5B2_class_t H5A_BT2_CORDER[1]={{ /* B-tree class information */ H5B2_ATTR_DENSE_CORDER_ID, /* Type of B-tree */ "H5B2_ATTR_DENSE_CORDER_ID", /* Name of B-tree class */ sizeof(H5A_dense_bt2_corder_rec_t),/* Size of native record */ + NULL, /* Create client callback context */ + NULL, /* Destroy client callback context */ H5A_dense_btree2_corder_store, /* Record storage callback */ 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 */ + H5A_dense_btree2_corder_debug, /* Record debugging callback */ + NULL, /* Create debugging context */ + NULL /* Destroy debugging context */ }}; @@ -311,7 +319,7 @@ H5A_dense_btree2_name_compare(const void *_bt2_udata, const void *_bt2_rec) *------------------------------------------------------------------------- */ static herr_t -H5A_dense_btree2_name_encode(const H5F_t UNUSED *f, uint8_t *raw, const void *_nrecord) +H5A_dense_btree2_name_encode(uint8_t *raw, const void *_nrecord, void UNUSED *ctx) { const H5A_dense_bt2_name_rec_t *nrecord = (const H5A_dense_bt2_name_rec_t *)_nrecord; @@ -341,7 +349,7 @@ H5A_dense_btree2_name_encode(const H5F_t UNUSED *f, uint8_t *raw, const void *_n *------------------------------------------------------------------------- */ static herr_t -H5A_dense_btree2_name_decode(const H5F_t UNUSED *f, const uint8_t *raw, void *_nrecord) +H5A_dense_btree2_name_decode(const uint8_t *raw, void *_nrecord, void UNUSED *ctx) { H5A_dense_bt2_name_rec_t *nrecord = (H5A_dense_bt2_name_rec_t *)_nrecord; @@ -469,7 +477,7 @@ H5A_dense_btree2_corder_compare(const void *_bt2_udata, const void *_bt2_rec) *------------------------------------------------------------------------- */ static herr_t -H5A_dense_btree2_corder_encode(const H5F_t UNUSED *f, uint8_t *raw, const void *_nrecord) +H5A_dense_btree2_corder_encode(uint8_t *raw, const void *_nrecord, void UNUSED *ctx) { const H5A_dense_bt2_corder_rec_t *nrecord = (const H5A_dense_bt2_corder_rec_t *)_nrecord; @@ -498,7 +506,7 @@ H5A_dense_btree2_corder_encode(const H5F_t UNUSED *f, uint8_t *raw, const void * *------------------------------------------------------------------------- */ static herr_t -H5A_dense_btree2_corder_decode(const H5F_t UNUSED *f, const uint8_t *raw, void *_nrecord) +H5A_dense_btree2_corder_decode(const uint8_t *raw, void *_nrecord, void UNUSED *ctx) { H5A_dense_bt2_corder_rec_t *nrecord = (H5A_dense_bt2_corder_rec_t *)_nrecord; diff --git a/src/H5Adense.c b/src/H5Adense.c index c9da207..889889e 100644 --- a/src/H5Adense.c +++ b/src/H5Adense.c @@ -246,7 +246,7 @@ HDfprintf(stderr, "%s: fheap_id_len = %Zu\n", FUNC, fheap_id_len); H5O_FHEAP_ID_LEN; /* Fractal heap ID */ bt2_cparam.split_percent = H5A_NAME_BT2_SPLIT_PERC; bt2_cparam.merge_percent = H5A_NAME_BT2_MERGE_PERC; - if(NULL == (bt2_name = H5B2_create(f, dxpl_id, &bt2_cparam))) + if(NULL == (bt2_name = H5B2_create(f, dxpl_id, &bt2_cparam, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to create v2 B-tree for name index") /* Retrieve the v2 B-tree's address in the file */ @@ -267,7 +267,7 @@ HDfprintf(stderr, "%s: ainfo->name_bt2_addr = %a\n", FUNC, ainfo->name_bt2_addr) H5O_FHEAP_ID_LEN; /* Fractal heap ID */ bt2_cparam.split_percent = H5A_CORDER_BT2_SPLIT_PERC; bt2_cparam.merge_percent = H5A_CORDER_BT2_MERGE_PERC; - if(NULL == (bt2_corder = H5B2_create(f, dxpl_id, &bt2_cparam))) + if(NULL == (bt2_corder = H5B2_create(f, dxpl_id, &bt2_cparam, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to create v2 B-tree for creation order index") /* Retrieve the v2 B-tree's address in the file */ @@ -383,7 +383,7 @@ H5A_dense_open(H5F_t *f, hid_t dxpl_id, const H5O_ainfo_t *ainfo, const char *na } /* end if */ /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(f, dxpl_id, ainfo->name_bt2_addr))) + if(NULL == (bt2_name = H5B2_open(f, dxpl_id, ainfo->name_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "unable to open v2 B-tree for name index") /* Create the "udata" information for v2 B-tree record find */ @@ -528,7 +528,7 @@ H5A_dense_insert(H5F_t *f, hid_t dxpl_id, const H5O_ainfo_t *ainfo, H5A_t *attr) } /* end else */ /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(f, dxpl_id, ainfo->name_bt2_addr))) + if(NULL == (bt2_name = H5B2_open(f, dxpl_id, ainfo->name_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Create the callback information for v2 B-tree record insertion */ @@ -552,7 +552,7 @@ H5A_dense_insert(H5F_t *f, hid_t dxpl_id, const H5O_ainfo_t *ainfo, H5A_t *attr) if(ainfo->index_corder) { /* Open the creation order index v2 B-tree */ HDassert(H5F_addr_defined(ainfo->corder_bt2_addr)); - if(NULL == (bt2_corder = H5B2_open(f, dxpl_id, ainfo->corder_bt2_addr))) + if(NULL == (bt2_corder = H5B2_open(f, dxpl_id, ainfo->corder_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for creation order index") /* Insert the record into the creation order index v2 B-tree */ @@ -660,7 +660,7 @@ H5A_dense_write_bt2_cb(void *_record, void *_op_data, hbool_t *changed) H5A_bt2_ud_common_t udata; /* User data for v2 B-tree modify */ /* Open the creation order index v2 B-tree */ - if(NULL == (bt2_corder = H5B2_open(op_data->f, op_data->dxpl_id, op_data->corder_bt2_addr))) + if(NULL == (bt2_corder = H5B2_open(op_data->f, op_data->dxpl_id, op_data->corder_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for creation order index") /* Create the "udata" information for v2 B-tree record modify */ @@ -790,7 +790,7 @@ H5A_dense_write(H5F_t *f, hid_t dxpl_id, const H5O_ainfo_t *ainfo, H5A_t *attr) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(f, dxpl_id, ainfo->name_bt2_addr))) + if(NULL == (bt2_name = H5B2_open(f, dxpl_id, ainfo->name_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Create the "udata" information for v2 B-tree record modify */ @@ -936,7 +936,7 @@ H5A_dense_rename(H5F_t *f, hid_t dxpl_id, const H5O_ainfo_t *ainfo, const char * HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(f, dxpl_id, ainfo->name_bt2_addr))) + if(NULL == (bt2_name = H5B2_open(f, dxpl_id, ainfo->name_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Create the "udata" information for v2 B-tree record modify */ @@ -1215,7 +1215,7 @@ H5A_dense_iterate(H5F_t *f, hid_t dxpl_id, hid_t loc_id, const H5O_ainfo_t *ainf } /* end if */ /* Open the index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, dxpl_id, bt2_addr))) + if(NULL == (bt2 = H5B2_open(f, dxpl_id, bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for index") /* Construct the user data for v2 B-tree iterator callback */ @@ -1291,7 +1291,7 @@ H5A_dense_remove_bt2_cb(const void *_record, void *_udata) /* Check for removing the link from the creation order index */ if(H5F_addr_defined(udata->corder_bt2_addr)) { /* Open the creation order index v2 B-tree */ - if(NULL == (bt2_corder = H5B2_open(udata->common.f, udata->common.dxpl_id, udata->corder_bt2_addr))) + if(NULL == (bt2_corder = H5B2_open(udata->common.f, udata->common.dxpl_id, udata->corder_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for creation order index") /* Set up the user data for the v2 B-tree 'record remove' callback */ @@ -1386,7 +1386,7 @@ H5A_dense_remove(H5F_t *f, hid_t dxpl_id, const H5O_ainfo_t *ainfo, const char * } /* end if */ /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(f, dxpl_id, ainfo->name_bt2_addr))) + if(NULL == (bt2_name = H5B2_open(f, dxpl_id, ainfo->name_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Set up the user data for the v2 B-tree 'record remove' callback */ @@ -1500,7 +1500,7 @@ H5A_dense_remove_by_idx_bt2_cb(const void *_record, void *_bt2_udata) } /* end else */ /* Open the index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(bt2_udata->f, bt2_udata->dxpl_id, bt2_udata->other_bt2_addr))) + if(NULL == (bt2 = H5B2_open(bt2_udata->f, bt2_udata->dxpl_id, bt2_udata->other_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for index") /* Set the common information for the v2 B-tree remove operation */ @@ -1632,7 +1632,7 @@ H5A_dense_remove_by_idx(H5F_t *f, hid_t dxpl_id, const H5O_ainfo_t *ainfo, } /* end if */ /* Open the index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, dxpl_id, bt2_addr))) + if(NULL == (bt2 = H5B2_open(f, dxpl_id, bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for index") /* Set up the user data for the v2 B-tree 'record remove' callback */ @@ -1735,7 +1735,7 @@ H5A_dense_exists(H5F_t *f, hid_t dxpl_id, const H5O_ainfo_t *ainfo, const char * } /* end if */ /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(f, dxpl_id, ainfo->name_bt2_addr))) + if(NULL == (bt2_name = H5B2_open(f, dxpl_id, ainfo->name_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Create the "udata" information for v2 B-tree record 'find' */ @@ -1876,7 +1876,7 @@ H5A_dense_delete(H5F_t *f, hid_t dxpl_id, H5O_ainfo_t *ainfo) udata.found_op_data = NULL; /* Delete name index v2 B-tree */ - if(H5B2_delete(f, dxpl_id, ainfo->name_bt2_addr, H5A_dense_delete_bt2_cb, &udata) < 0) + if(H5B2_delete(f, dxpl_id, ainfo->name_bt2_addr, NULL, H5A_dense_delete_bt2_cb, &udata) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete v2 B-tree for name index") ainfo->name_bt2_addr = HADDR_UNDEF; @@ -1888,7 +1888,7 @@ H5A_dense_delete(H5F_t *f, hid_t dxpl_id, H5O_ainfo_t *ainfo) /* Check if we should delete the creation order index v2 B-tree */ if(H5F_addr_defined(ainfo->corder_bt2_addr)) { /* Delete the creation order index, without adjusting the ref. count on the attributes */ - if(H5B2_delete(f, dxpl_id, ainfo->corder_bt2_addr, NULL, NULL) < 0) + if(H5B2_delete(f, dxpl_id, ainfo->corder_bt2_addr, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete v2 B-tree for creation order index") ainfo->corder_bt2_addr = HADDR_UNDEF; } /* end if */ diff --git a/src/H5Aint.c b/src/H5Aint.c index ab1d32c..c50126a 100644 --- a/src/H5Aint.c +++ b/src/H5Aint.c @@ -328,7 +328,7 @@ H5A_dense_build_table(H5F_t *f, hid_t dxpl_id, const H5O_ainfo_t *ainfo, HDassert(atable); /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(f, dxpl_id, ainfo->name_bt2_addr))) + if(NULL == (bt2_name = H5B2_open(f, dxpl_id, ainfo->name_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Retrieve # of records in "name" B-tree */ @@ -724,7 +724,7 @@ H5A_get_ainfo(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5O_ainfo_t *ainfo) /* Check if we are using "dense" attribute storage */ if(H5F_addr_defined(ainfo->fheap_addr)) { /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(f, dxpl_id, ainfo->name_bt2_addr))) + if(NULL == (bt2_name = H5B2_open(f, dxpl_id, ainfo->name_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Retrieve # of records in "name" B-tree */ diff --git a/src/H5B2.c b/src/H5B2.c index b6e8392..5ab9e8a 100644 --- a/src/H5B2.c +++ b/src/H5B2.c @@ -73,10 +73,10 @@ * client class.. */ extern const H5B2_class_t H5B2_TEST[1]; -extern const H5B2_class_t H5HF_BT2_INDIR[1]; -extern const H5B2_class_t H5HF_BT2_FILT_INDIR[1]; -extern const H5B2_class_t H5HF_BT2_DIR[1]; -extern const H5B2_class_t H5HF_BT2_FILT_DIR[1]; +extern const H5B2_class_t H5HF_HUGE_BT2_INDIR[1]; +extern const H5B2_class_t H5HF_HUGE_BT2_FILT_INDIR[1]; +extern const H5B2_class_t H5HF_HUGE_BT2_DIR[1]; +extern const H5B2_class_t H5HF_HUGE_BT2_FILT_DIR[1]; extern const H5B2_class_t H5G_BT2_NAME[1]; extern const H5B2_class_t H5G_BT2_CORDER[1]; extern const H5B2_class_t H5SM_INDEX[1]; @@ -85,10 +85,10 @@ extern const H5B2_class_t H5A_BT2_CORDER[1]; const H5B2_class_t *const H5B2_client_class_g[] = { H5B2_TEST, /* 0 - H5B2_TEST_ID */ - H5HF_BT2_INDIR, /* 1 - H5B2_FHEAP_HUGE_INDIR_ID */ - H5HF_BT2_FILT_INDIR, /* 2 - H5B2_FHEAP_HUGE_FILT_INDIR_ID */ - H5HF_BT2_DIR, /* 3 - H5B2_FHEAP_HUGE_DIR_ID */ - H5HF_BT2_FILT_DIR, /* 4 - H5B2_FHEAP_HUGE_FILT_DIR_ID */ + H5HF_HUGE_BT2_INDIR, /* 1 - H5B2_FHEAP_HUGE_INDIR_ID */ + H5HF_HUGE_BT2_FILT_INDIR, /* 2 - H5B2_FHEAP_HUGE_FILT_INDIR_ID */ + H5HF_HUGE_BT2_DIR, /* 3 - H5B2_FHEAP_HUGE_DIR_ID */ + H5HF_HUGE_BT2_FILT_DIR, /* 4 - H5B2_FHEAP_HUGE_FILT_DIR_ID */ H5G_BT2_NAME, /* 5 - H5B2_GRP_DENSE_NAME_ID */ H5G_BT2_CORDER, /* 6 - H5B2_GRP_DENSE_CORDER_ID */ H5SM_INDEX, /* 7 - H5B2_SOHM_INDEX_ID */ @@ -126,7 +126,7 @@ H5FL_DEFINE_STATIC(H5B2_t); *------------------------------------------------------------------------- */ H5B2_t * -H5B2_create(H5F_t *f, hid_t dxpl_id, const H5B2_create_t *cparam) +H5B2_create(H5F_t *f, hid_t dxpl_id, const H5B2_create_t *cparam, void *ctx_udata) { H5B2_t *bt2 = NULL; /* Pointer to the B-tree */ H5B2_hdr_t *hdr = NULL; /* Pointer to the B-tree header */ @@ -145,7 +145,7 @@ H5B2_create(H5F_t *f, hid_t dxpl_id, const H5B2_create_t *cparam) HDcompile_assert(H5B2_NUM_BTREE_ID == NELMTS(H5B2_client_class_g)); /* Create shared v2 B-tree header */ - if(HADDR_UNDEF == (hdr_addr = H5B2_hdr_create(f, dxpl_id, cparam))) + if(HADDR_UNDEF == (hdr_addr = H5B2_hdr_create(f, dxpl_id, cparam, ctx_udata))) HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, NULL, "can't create v2 B-tree header") /* Create v2 B-tree wrapper */ @@ -153,7 +153,7 @@ H5B2_create(H5F_t *f, hid_t dxpl_id, const H5B2_create_t *cparam) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "memory allocation failed for v2 B-tree info") /* Look up the B-tree header */ - if(NULL == (hdr = (H5B2_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, hdr_addr, NULL, NULL, H5AC_WRITE))) + if(NULL == (hdr = (H5B2_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, hdr_addr, NULL, ctx_udata, H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, NULL, "unable to load B-tree header") /* Point v2 B-tree wrapper at header and bump it's ref count */ @@ -197,7 +197,7 @@ done: *------------------------------------------------------------------------- */ H5B2_t * -H5B2_open(H5F_t *f, hid_t dxpl_id, haddr_t addr) +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 */ @@ -210,7 +210,7 @@ H5B2_open(H5F_t *f, hid_t dxpl_id, haddr_t addr) HDassert(H5F_addr_defined(addr)); /* Look up the B-tree header */ - if(NULL == (hdr = (H5B2_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, NULL, NULL, H5AC_READ))) + if(NULL == (hdr = (H5B2_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, NULL, ctx_udata, H5AC_READ))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, NULL, "unable to load B-tree header") /* Check for pending heap deletion */ @@ -1140,13 +1140,6 @@ H5B2_close(H5B2_t *bt2, hid_t dxpl_id) } /* end if */ } /* end if */ - /* Decrement the reference count on the B-tree header */ - /* (don't put in H5B2_hdr_fuse_decr() as the B-tree header may be evicted - * immediately -QAK) - */ - if(H5B2_hdr_decr(bt2->hdr) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTDEC, FAIL, "can't decrement reference count on shared v2 B-tree header") - /* Check for pending v2 B-tree deletion */ if(pending_delete) { H5B2_hdr_t *hdr; /* Another pointer to v2 B-tree header */ @@ -1154,17 +1147,49 @@ H5B2_close(H5B2_t *bt2, hid_t dxpl_id) /* Sanity check */ HDassert(H5F_addr_defined(bt2_addr)); +#ifndef NDEBUG +{ + unsigned hdr_status = 0; /* Header's status in the metadata cache */ + + /* Check the header's status in the metadata cache */ + if(H5AC_get_entry_status(bt2->f, bt2_addr, &hdr_status) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "unable to check metadata cache status for v2 B-tree header, address = %llu", (unsigned long long)bt2_addr) + + /* Sanity checks on header */ + HDassert(hdr_status & H5AC_ES__IN_CACHE); + HDassert(hdr_status & H5AC_ES__IS_PINNED); + HDassert(!(hdr_status & H5AC_ES__IS_PROTECTED)); +} +#endif /* NDEBUG */ + /* 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, NULL, H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load v2 B-tree header") /* Set the shared v2 B-tree header's file context for this operation */ hdr->f = bt2->f; + /* Decrement the reference count on the B-tree header */ + /* (don't put in H5B2_hdr_fuse_decr() as the B-tree header may be evicted + * immediately -QAK) + */ + if(H5B2_hdr_decr(bt2->hdr) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTDEC, FAIL, "can't decrement reference count on shared v2 B-tree header") + /* Delete v2 B-tree, starting with header (unprotects header) */ if(H5B2_hdr_delete(hdr, dxpl_id) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDELETE, FAIL, "unable to delete v2 B-tree") } /* end if */ + else { + /* Decrement the reference count on the B-tree header */ + /* (don't put in H5B2_hdr_fuse_decr() as the B-tree header may be evicted + * immediately -QAK) + */ + if(H5B2_hdr_decr(bt2->hdr) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTDEC, FAIL, "can't decrement reference count on shared v2 B-tree header") + + } /* end else */ /* Release the v2 B-tree wrapper */ bt2 = H5FL_FREE(H5B2_t, bt2); @@ -1197,8 +1222,8 @@ done: *------------------------------------------------------------------------- */ herr_t -H5B2_delete(H5F_t *f, hid_t dxpl_id, haddr_t addr, H5B2_remove_t op, - void *op_data) +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 */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1213,8 +1238,8 @@ H5B2_delete(H5F_t *f, hid_t dxpl_id, haddr_t addr, H5B2_remove_t op, #ifdef QAK HDfprintf(stderr, "%s: addr = %a\n", FUNC, addr); #endif /* QAK */ - if(NULL == (hdr = (H5B2_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, NULL, NULL, H5AC_WRITE))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load v2 B-tree header") + if(NULL == (hdr = (H5B2_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, NULL, ctx_udata, H5AC_WRITE))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect v2 B-tree header") /* Remember the callback & context for later */ hdr->remove_op = op; diff --git a/src/H5B2cache.c b/src/H5B2cache.c index 6737076..15dcb26 100644 --- a/src/H5B2cache.c +++ b/src/H5B2cache.c @@ -147,7 +147,8 @@ const H5AC_class_t H5AC_BT2_LEAF[1] = {{ *------------------------------------------------------------------------- */ static H5B2_hdr_t * -H5B2_cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED *udata1, void UNUSED *udata2) +H5B2_cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED *udata1, + void *ctx_udata) { H5B2_create_t cparam; /* B-tree creation parameters */ H5B2_subid_t id; /* ID of B-tree class, as found in file */ @@ -237,7 +238,7 @@ H5B2_cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED *ud /* Initialize B-tree header info */ cparam.cls = H5B2_client_class_g[id]; - if(H5B2_hdr_init(f, hdr, &cparam, depth) < 0) + if(H5B2_hdr_init(f, hdr, &cparam, ctx_udata, depth) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, NULL, "can't initialize B-tree header info") /* Set the B-tree header's address */ @@ -564,7 +565,7 @@ H5B2_cache_internal_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_uda native = internal->int_native; for(u = 0; u < internal->nrec; u++) { /* Decode record */ - if((udata->hdr->cls->decode)(f, p, native) < 0) + if((udata->hdr->cls->decode)(p, native, udata->hdr->cb_ctx) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, NULL, "unable to decode B-tree record") /* Move to next record */ @@ -663,7 +664,7 @@ H5B2_cache_internal_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr native = internal->int_native; for(u = 0; u < internal->nrec; u++) { /* Encode record */ - if((internal->hdr->cls->encode)(f, p, native) < 0) + if((internal->hdr->cls->encode)(p, native, internal->hdr->cb_ctx) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTENCODE, FAIL, "unable to encode B-tree record") /* Move to next record */ @@ -916,7 +917,7 @@ H5B2_cache_leaf_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_nrec, v native = leaf->leaf_native; for(u = 0; u < leaf->nrec; u++) { /* Decode record */ - if((hdr->cls->decode)(f, p, native) < 0) + if((hdr->cls->decode)(p, native, hdr->cb_ctx) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTENCODE, NULL, "unable to decode B-tree record") /* Move to next record */ @@ -999,7 +1000,7 @@ H5B2_cache_leaf_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5 native = leaf->leaf_native; for(u = 0; u < leaf->nrec; u++) { /* Encode record */ - if((leaf->hdr->cls->encode)(f, p, native) < 0) + if((leaf->hdr->cls->encode)(p, native, leaf->hdr->cb_ctx) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTENCODE, FAIL, "unable to encode B-tree record") /* Move to next record */ diff --git a/src/H5B2dbg.c b/src/H5B2dbg.c index 17a64cd..f8a1fc9 100644 --- a/src/H5B2dbg.c +++ b/src/H5B2dbg.c @@ -91,6 +91,7 @@ H5B2_hdr_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, const H5B2_class_t *type) { 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 */ @@ -106,11 +107,20 @@ 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, 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_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, type, NULL, H5AC_READ))) + if(NULL == (hdr = (H5B2_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, type, dbg_ctx, H5AC_READ))) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree header") /* Set file pointer for this B-tree operation */ @@ -162,6 +172,8 @@ 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) { hdr->f = NULL; if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_HDR, addr, hdr, H5AC__NO_FLAGS_SET) < 0) @@ -191,6 +203,7 @@ 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 */ @@ -206,13 +219,22 @@ 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(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, 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_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, hdr_addr, type, NULL, H5AC_READ))) + if(NULL == (hdr = (H5B2_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, hdr_addr, type, dbg_ctx, H5AC_READ))) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree header") /* Set file pointer for this B-tree operation */ @@ -276,6 +298,8 @@ 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) { hdr->f = NULL; if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_HDR, hdr_addr, hdr, H5AC__NO_FLAGS_SET) < 0) @@ -307,6 +331,7 @@ 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 */ @@ -322,13 +347,22 @@ 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(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, 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_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, hdr_addr, type, NULL, H5AC_READ))) + if(NULL == (hdr = (H5B2_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, hdr_addr, type, dbg_ctx, H5AC_READ))) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree header") /* Set file pointer for this B-tree operation */ @@ -373,6 +407,8 @@ H5B2_leaf_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) { hdr->f = NULL; if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_HDR, hdr_addr, hdr, H5AC__NO_FLAGS_SET) < 0) diff --git a/src/H5B2hdr.c b/src/H5B2hdr.c index ec46729..f1d5d84 100644 --- a/src/H5B2hdr.c +++ b/src/H5B2hdr.c @@ -108,7 +108,7 @@ H5FL_SEQ_DEFINE(H5B2_node_info_t); */ herr_t H5B2_hdr_init(H5F_t *f, H5B2_hdr_t *hdr, const H5B2_create_t *cparam, - uint16_t depth) + void *ctx_udata, uint16_t depth) { size_t sz_max_nrec; /* Temporary variable for range checking */ unsigned u_max_nrec_size; /* Temporary variable for range checking */ @@ -124,6 +124,8 @@ H5B2_hdr_init(H5F_t *f, H5B2_hdr_t *hdr, const H5B2_create_t *cparam, HDassert(hdr); HDassert(cparam); HDassert(cparam->cls); + HDassert((cparam->cls->crt_context && cparam->cls->dst_context) || + (NULL == cparam->cls->crt_context && NULL == cparam->cls->dst_context)); HDassert(cparam->node_size > 0); HDassert(cparam->rrec_size > 0); HDassert(cparam->merge_percent > 0 && cparam->merge_percent <= 100); @@ -149,14 +151,14 @@ H5B2_hdr_init(H5F_t *f, H5B2_hdr_t *hdr, const H5B2_create_t *cparam, /* Allocate "page" for node I/O */ if(NULL == (hdr->page = H5FL_BLK_MALLOC(node_page, hdr->node_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + HGOTO_ERROR(H5E_BTREE, H5E_NOSPACE, FAIL, "memory allocation failed") #ifdef H5_CLEAR_MEMORY HDmemset(hdr->page, 0, hdr->node_size); #endif /* H5_CLEAR_MEMORY */ /* Allocate array of node info structs */ if(NULL == (hdr->node_info = H5FL_SEQ_MALLOC(H5B2_node_info_t, (size_t)(hdr->depth + 1)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + HGOTO_ERROR(H5E_BTREE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Initialize leaf node info */ sz_max_nrec = H5B2_NUM_LEAF_REC(hdr->node_size, hdr->rrec_size); @@ -166,13 +168,13 @@ HDmemset(hdr->page, 0, hdr->node_size); hdr->node_info[0].cum_max_nrec = hdr->node_info[0].max_nrec; hdr->node_info[0].cum_max_nrec_size = 0; if(NULL == (hdr->node_info[0].nat_rec_fac = H5FL_fac_init(hdr->cls->nrec_size * hdr->node_info[0].max_nrec))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't create node native key block factory") + HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "can't create node native key block factory") hdr->node_info[0].node_ptr_fac = NULL; /* Allocate array of pointers to internal node native keys */ /* (uses leaf # of records because its the largest) */ if(NULL == (hdr->nat_off = H5FL_SEQ_MALLOC(size_t, (size_t)hdr->node_info[0].max_nrec))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + HGOTO_ERROR(H5E_BTREE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Initialize offsets in native key block */ /* (uses leaf # of records because its the largest) */ @@ -201,12 +203,18 @@ HDmemset(hdr->page, 0, hdr->node_size); H5_ASSIGN_OVERFLOW(/* To: */ hdr->node_info[u].cum_max_nrec_size, /* From: */ u_max_nrec_size, /* From: */ unsigned, /* To: */ uint8_t) if(NULL == (hdr->node_info[u].nat_rec_fac = H5FL_fac_init(hdr->cls->nrec_size * hdr->node_info[u].max_nrec))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't create node native key block factory") + HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "can't create node native key block factory") if(NULL == (hdr->node_info[u].node_ptr_fac = H5FL_fac_init(sizeof(H5B2_node_ptr_t) * (hdr->node_info[u].max_nrec + 1)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't create internal 'branch' node node pointer block factory") + HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "can't create internal 'branch' node node pointer block factory") } /* end for */ } /* end if */ + /* Create the callback context, if the callback exists */ + 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) if(H5B2_hdr_free(hdr) < 0) @@ -278,7 +286,8 @@ done: *------------------------------------------------------------------------- */ haddr_t -H5B2_hdr_create(H5F_t *f, hid_t dxpl_id, const H5B2_create_t *cparam) +H5B2_hdr_create(H5F_t *f, hid_t dxpl_id, const H5B2_create_t *cparam, + void *ctx_udata) { H5B2_hdr_t *hdr = NULL; /* The new v2 B-tree header information */ haddr_t ret_value; /* Return value */ @@ -296,7 +305,7 @@ H5B2_hdr_create(H5F_t *f, hid_t dxpl_id, const H5B2_create_t *cparam) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, HADDR_UNDEF, "allocation failed for B-tree header") /* Initialize shared B-tree info */ - if(H5B2_hdr_init(f, hdr, cparam, (uint16_t)0) < 0) + if(H5B2_hdr_init(f, hdr, cparam, ctx_udata, (uint16_t)0) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, HADDR_UNDEF, "can't create shared B-tree info") /* Allocate space for the header on disk */ @@ -507,6 +516,13 @@ H5B2_hdr_free(H5B2_hdr_t *hdr) /* Sanity check */ HDassert(hdr); + /* Destroy the callback context */ + if(hdr->cb_ctx) { + if((*hdr->cls->dst_context)(hdr->cb_ctx) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTRELEASE, FAIL, "can't destroy v2 B-tree client callback context") + hdr->cb_ctx = NULL; + } /* end if */ + /* Free the B-tree node buffer */ if(hdr->page) (void)H5FL_BLK_FREE(node_page, hdr->page); diff --git a/src/H5B2pkg.h b/src/H5B2pkg.h index 8b68d1e..c336227 100644 --- a/src/H5B2pkg.h +++ b/src/H5B2pkg.h @@ -168,10 +168,13 @@ typedef struct H5B2_hdr_t { uint8_t sizeof_addr; /* Size of file addresses */ H5B2_remove_t remove_op; /* Callback operator for deleting B-tree */ void *remove_op_data;/* B-tree deletion callback's context */ - const H5B2_class_t *cls; /* Class of B-tree client */ 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 */ + + /* Client information (not stored) */ + const H5B2_class_t *cls; /* Class of B-tree client */ + void *cb_ctx; /* Client callback context */ } H5B2_hdr_t; /* B-tree leaf node information */ @@ -255,9 +258,9 @@ extern const H5B2_class_t *const H5B2_client_class_g[]; /* Routines for managing B-tree header info */ H5_DLL H5B2_hdr_t *H5B2_hdr_alloc(H5F_t *f); H5_DLL haddr_t H5B2_hdr_create(H5F_t *f, hid_t dxpl_id, - const H5B2_create_t *cparam); + const H5B2_create_t *cparam, void *ctx_udata); H5_DLL herr_t H5B2_hdr_init(H5F_t *f, H5B2_hdr_t *hdr, - const H5B2_create_t *cparam, uint16_t depth); + const H5B2_create_t *cparam, void *ctx_udata, uint16_t depth); H5_DLL herr_t H5B2_hdr_incr(H5B2_hdr_t *hdr); H5_DLL herr_t H5B2_hdr_decr(H5B2_hdr_t *hdr); H5_DLL herr_t H5B2_hdr_fuse_incr(H5B2_hdr_t *hdr); diff --git a/src/H5B2private.h b/src/H5B2private.h index cfdf868..4880ab2 100644 --- a/src/H5B2private.h +++ b/src/H5B2private.h @@ -85,20 +85,17 @@ struct H5B2_class_t { const char *name; /* Name of B-tree class, for debugging */ size_t nrec_size; /* Size of native (memory) record */ - /* Store record from application to B-tree 'native' form */ - herr_t (*store)(void *nrecord, const void *udata); /* Store record in native record table */ - - /* Compare records, according to a key */ - herr_t (*compare)(const void *rec1, const void *rec2); /* Compare two native records */ - - /* Encode & decode record values */ - herr_t (*encode)(const H5F_t *f, uint8_t *raw, const void *record); /* Encode record from native form to disk storage form */ - herr_t (*decode)(const H5F_t *f, const uint8_t *raw, void *record); /* Decode record from disk storage form to native form */ - - /* Debug record values */ - herr_t (*debug)(FILE *stream, const H5F_t *f, hid_t dxpl_id, /* Print a record for debugging */ - int indent, int fwidth, const void *record, - const void *udata); + /* Extensible array client callback methods */ + void *(*crt_context)(void *udata); /* Create context for other client callbacks */ + herr_t (*dst_context)(void *ctx); /* Destroy client callback context */ + herr_t (*store)(void *nrecord, const void *udata); /* Store application record in native record table */ + herr_t (*compare)(const void *rec1, const void *rec2); /* Compare two native records */ + herr_t (*encode)(uint8_t *raw, const void *record, void *ctx); /* Encode record from native form to disk storage form */ + 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, const H5F_t *f, hid_t dxpl_id, /* Print a record for debugging */ + int indent, int fwidth, const void *record, const void *udata); + 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 */ @@ -128,8 +125,9 @@ typedef struct H5B2_t H5B2_t; /***************************************/ /* Library-private Function Prototypes */ /***************************************/ -H5_DLL H5B2_t *H5B2_create(H5F_t *f, hid_t dxpl_id, const H5B2_create_t *cparam); -H5_DLL H5B2_t *H5B2_open(H5F_t *f, hid_t dxpl_id, haddr_t addr); +H5_DLL H5B2_t *H5B2_create(H5F_t *f, hid_t dxpl_id, const H5B2_create_t *cparam, + void *ctx_udata); +H5_DLL H5B2_t *H5B2_open(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *ctx_udata); H5_DLL herr_t H5B2_get_addr(const H5B2_t *bt2, haddr_t *addr/*out*/); H5_DLL herr_t H5B2_insert(H5B2_t *bt2, hid_t dxpl_id, void *udata); H5_DLL herr_t H5B2_iterate(H5B2_t *bt2, hid_t dxpl_id, H5B2_operator_t op, @@ -151,7 +149,7 @@ H5_DLL herr_t H5B2_size(H5B2_t *bt2, hid_t dxpl_id, hsize_t *btree_size); H5_DLL herr_t H5B2_close(H5B2_t *bt2, hid_t dxpl_id); H5_DLL herr_t H5B2_delete(H5F_t *f, hid_t dxpl_id, haddr_t addr, - H5B2_remove_t op, void *op_data); + void *ctx_udata, H5B2_remove_t op, void *op_data); /* Statistics routines */ H5_DLL herr_t H5B2_stat_info(H5B2_t *bt2, H5B2_stat_t *info); diff --git a/src/H5B2test.c b/src/H5B2test.c index 863c886..72eb793 100644 --- a/src/H5B2test.c +++ b/src/H5B2test.c @@ -46,6 +46,11 @@ /* Local Typedefs */ /******************/ +/* v2 B-tree client callback context */ +typedef struct H5B2_test_ctx_t { + uint8_t sizeof_size; /* Size of file sizes */ +} H5B2_test_ctx_t; + /********************/ /* Package Typedefs */ @@ -56,14 +61,15 @@ /* Local Prototypes */ /********************/ +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); static herr_t H5B2_test_compare(const void *rec1, const void *rec2); -static herr_t H5B2_test_encode(const H5F_t *f, uint8_t *raw, - const void *nrecord); -static herr_t H5B2_test_decode(const H5F_t *f, const uint8_t *raw, - void *nrecord); +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, const H5F_t *f, hid_t dxpl_id, 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); /*********************/ @@ -74,11 +80,15 @@ 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 */ sizeof(hsize_t), /* Size of native record */ + H5B2_test_crt_context, /* Create client callback context */ + H5B2_test_dst_context, /* Destroy client callback context */ H5B2_test_store, /* Record storage callback */ 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_debug, /* Record debugging callback */ + H5B2_test_crt_dbg_context, /* Create debugging context */ + H5B2_test_dst_context /* Destroy debugging context */ }}; @@ -92,6 +102,79 @@ const H5B2_class_t H5B2_TEST[1]={{ /* B-tree class information */ /*******************/ +/* Declare a free list to manage the H5B2_test_ctx_t struct */ +H5FL_DEFINE_STATIC(H5B2_test_ctx_t); + + +/*------------------------------------------------------------------------- + * Function: H5B2_test_crt_context + * + * Purpose: Create client callback context + * + * Return: Success: non-NULL + * Failure: NULL + * + * Programmer: Quincey Koziol + * Thursday, November 26, 2009 + * + *------------------------------------------------------------------------- + */ +static void * +H5B2_test_crt_context(void *_f) +{ + H5F_t *f = (H5F_t *)_f; /* User data for building callback context */ + H5B2_test_ctx_t *ctx; /* Callback context structure */ + void *ret_value; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5B2_test_crt_context) + + /* Sanity check */ + HDassert(f); + + /* Allocate callback context */ + if(NULL == (ctx = H5FL_MALLOC(H5B2_test_ctx_t))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "can't allocate callback context") + + /* Determine the size of lengths in the file */ + ctx->sizeof_size = H5F_SIZEOF_SIZE(f); + + /* Set return value */ + ret_value = ctx; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5B2_test_crt_context() */ + + +/*------------------------------------------------------------------------- + * Function: H5B2_test_dst_context + * + * Purpose: Destroy client callback context + * + * Return: Success: non-negative + * Failure: negative + * + * Programmer: Quincey Koziol + * Thursday, November 26, 2009 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5B2_test_dst_context(void *_ctx) +{ + H5B2_test_ctx_t *ctx = (H5B2_test_ctx_t *)_ctx; /* Callback context structure */ + + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5B2_test_dst_context) + + /* Sanity check */ + HDassert(ctx); + + /* Release callback context */ + ctx = H5FL_FREE(H5B2_test_ctx_t, ctx); + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* H5B2_test_dst_context() */ + /*------------------------------------------------------------------------- * Function: H5B2_test_store @@ -99,7 +182,6 @@ const H5B2_class_t H5B2_TEST[1]={{ /* B-tree class information */ * Purpose: Store native information into record for B-tree * * Return: Success: non-negative - * * Failure: negative * * Programmer: Quincey Koziol @@ -147,7 +229,6 @@ H5B2_test_compare(const void *rec1, const void *rec2) * Purpose: Encode native information into raw form for storing on disk * * Return: Success: non-negative - * * Failure: negative * * Programmer: Quincey Koziol @@ -156,11 +237,16 @@ H5B2_test_compare(const void *rec1, const void *rec2) *------------------------------------------------------------------------- */ static herr_t -H5B2_test_encode(const H5F_t *f, uint8_t *raw, const void *nrecord) +H5B2_test_encode(uint8_t *raw, const void *nrecord, void *_ctx) { + H5B2_test_ctx_t *ctx = (H5B2_test_ctx_t *)_ctx; /* Callback context structure */ + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5B2_test_encode) - H5F_ENCODE_LENGTH(f, raw, *(const hsize_t *)nrecord); + /* Sanity check */ + HDassert(ctx); + + H5F_ENCODE_LENGTH_LEN(raw, *(const hsize_t *)nrecord, ctx->sizeof_size); FUNC_LEAVE_NOAPI(SUCCEED) } /* H5B2_test_encode() */ @@ -172,7 +258,6 @@ H5B2_test_encode(const H5F_t *f, uint8_t *raw, const void *nrecord) * Purpose: Decode raw disk form of record into native form * * Return: Success: non-negative - * * Failure: negative * * Programmer: Quincey Koziol @@ -181,11 +266,16 @@ H5B2_test_encode(const H5F_t *f, uint8_t *raw, const void *nrecord) *------------------------------------------------------------------------- */ static herr_t -H5B2_test_decode(const H5F_t *f, const uint8_t *raw, void *nrecord) +H5B2_test_decode(const uint8_t *raw, void *nrecord, void *_ctx) { + H5B2_test_ctx_t *ctx = (H5B2_test_ctx_t *)_ctx; /* Callback context structure */ + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5B2_test_decode) - H5F_DECODE_LENGTH(f, raw, *(hsize_t *)nrecord); + /* Sanity check */ + HDassert(ctx); + + H5F_DECODE_LENGTH_LEN(raw, *(hsize_t *)nrecord, ctx->sizeof_size); FUNC_LEAVE_NOAPI(SUCCEED) } /* H5B2_test_decode() */ @@ -197,7 +287,6 @@ H5B2_test_decode(const H5F_t *f, const uint8_t *raw, void *nrecord) * Purpose: Debug native form of record * * Return: Success: non-negative - * * Failure: negative * * Programmer: Quincey Koziol @@ -222,6 +311,46 @@ H5B2_test_debug(FILE *stream, const H5F_t UNUSED *f, hid_t UNUSED dxpl_id, /*------------------------------------------------------------------------- + * Function: H5B2_test_crt_dbg_context + * + * Purpose: Create context for debugging callback + * + * Return: Success: non-NULL + * Failure: NULL + * + * Programmer: Quincey Koziol + * Tuesday, December 1, 2009 + * + *------------------------------------------------------------------------- + */ +static void * +H5B2_test_crt_dbg_context(H5F_t *f, hid_t UNUSED dxpl_id, haddr_t UNUSED addr) +{ + H5B2_test_ctx_t *ctx; /* Callback context structure */ + void *ret_value; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5B2_test_crt_dbg_context) + + /* Sanity check */ + HDassert(f); + HDassert(H5F_addr_defined(addr)); + + /* Allocate callback context */ + if(NULL == (ctx = H5FL_MALLOC(H5B2_test_ctx_t))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "can't allocate callback context") + + /* Determine the size of addresses & lengths in the file */ + ctx->sizeof_size = H5F_SIZEOF_SIZE(f); + + /* Set return value */ + ret_value = ctx; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5B2_test_crt_dbg_context() */ + + +/*------------------------------------------------------------------------- * Function: H5B2_get_root_addr_test * * Purpose: Retrieve the root node's address diff --git a/src/H5F.c b/src/H5F.c index 064988e..68a5789 100644 --- a/src/H5F.c +++ b/src/H5F.c @@ -67,7 +67,6 @@ typedef struct H5F_olist_t { /* PRIVATE PROTOTYPES */ static size_t H5F_get_objects(const H5F_t *f, unsigned types, size_t max_objs, hid_t *obj_id_list, hbool_t app_ref); static int H5F_get_objects_cb(void *obj_ptr, hid_t obj_id, void *key); -static herr_t H5F_get_vfd_handle(const H5F_t *file, hid_t fapl, void** file_handle); static H5F_t *H5F_new(H5F_file_t *shared, hid_t fcpl_id, hid_t fapl_id, H5FD_t *lf); static herr_t H5F_dest(H5F_t *f, hid_t dxpl_id); @@ -705,21 +704,18 @@ done: * driver. * * Return: Success: non-negative value. - * - * Failture: negative. + * Failure: negative. * * Programmer: Raymond Lu * Sep. 16, 2002 * - * Modification: - * *------------------------------------------------------------------------- */ herr_t H5Fget_vfd_handle(hid_t file_id, hid_t fapl, void **file_handle) { H5F_t *file; /* File to query */ - herr_t ret_value; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(H5Fget_vfd_handle, FAIL) H5TRACE3("e", "ii**x", file_id, fapl, file_handle); @@ -732,7 +728,9 @@ H5Fget_vfd_handle(hid_t file_id, hid_t fapl, void **file_handle) if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file id") - ret_value = H5F_get_vfd_handle(file, fapl, file_handle); + /* Retrieve the VFD handle for the file */ + if(H5F_get_vfd_handle(file, fapl, file_handle) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve VFD handle") done: FUNC_LEAVE_API(ret_value) @@ -740,39 +738,6 @@ done: /*------------------------------------------------------------------------- - * Function: H5F_get_vfd_handle - * - * Purpose: Returns a pointer to the file handle of the low-level file - * driver. This is the private function for H5Fget_vfd_handle. - * - * Return: Success: Non-negative. - * - * Failture: negative. - * - * Programmer: Raymond Lu - * Sep. 16, 2002 - * - * Modification: - * - *------------------------------------------------------------------------- - */ -static herr_t -H5F_get_vfd_handle(const H5F_t *file, hid_t fapl, void**file_handle) -{ - herr_t ret_value; - - FUNC_ENTER_NOAPI_NOINIT(H5F_get_vfd_handle) - - assert(file_handle); - if((ret_value=H5FD_get_vfd_handle(file->shared->lf, fapl, file_handle)) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get file handle for file driver") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} - - -/*------------------------------------------------------------------------- * Function: H5Fis_hdf5 * * Purpose: Check the file signature to detect an HDF5 file. @@ -1118,7 +1083,8 @@ H5F_dest(H5F_t *f, hid_t dxpl_id) } /* Free the non-shared part of the file */ - f->name = (char *)H5MM_xfree(f->name); + f->open_name = (char *)H5MM_xfree(f->open_name); + f->actual_name = (char *)H5MM_xfree(f->actual_name); f->extpath = (char *)H5MM_xfree(f->extpath); if(H5FO_top_dest(f) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "problems closing file") @@ -1168,7 +1134,6 @@ H5F_dest(H5F_t *f, hid_t dxpl_id) * cause the default file access parameters to be used. * * Return: Success: A new file pointer. - * * Failure: NULL * * Programmer: Robb Matzke @@ -1198,7 +1163,7 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t d * Otherwise it is the application's responsibility to never open the * same file more than once at a time. */ - if((drvr = H5FD_get_class(fapl_id)) == NULL) + if(NULL == (drvr = H5FD_get_class(fapl_id))) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "unable to retrieve VFL class") /* @@ -1291,7 +1256,7 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t d * file can be accessed through the C library. */ file->intent = flags; - file->name = H5MM_xstrdup(name); + file->open_name = H5MM_xstrdup(name); /* * Read or write the file superblock, depending on whether the file is @@ -1349,10 +1314,14 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t d HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "file close degree doesn't match") } /* end if */ - /* formulate the absolute path for later search of target file for external link */ - if (H5_build_extpath(name, &file->extpath) < 0) + /* Formulate the absolute path for later search of target file for external links */ + if(H5_build_extpath(name, &file->extpath) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to build extpath") + /* Formulate the actual file name, after following symlinks, etc. */ + if(H5F_build_actual_name(file, name, &file->actual_name) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to build actual name") + /* Success */ ret_value = file; @@ -2020,8 +1989,9 @@ H5Freopen(hid_t file_id) /* Keep old file's read/write intent in new file */ new_file->intent = old_file->intent; - /* Duplicate old file's name */ - new_file->name = H5MM_xstrdup(old_file->name); + /* Duplicate old file's names */ + new_file->open_name = H5MM_xstrdup(old_file->open_name); + new_file->actual_name = H5MM_xstrdup(old_file->actual_name); if((ret_value = H5I_register(H5I_FILE, new_file, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file handle") @@ -2132,37 +2102,6 @@ done: /*------------------------------------------------------------------------- - * Function: H5F_get_eoa - * - * Purpose: Quick and dirty routine to retrieve the file's 'eoa' value - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * June 1, 2004 - * - *------------------------------------------------------------------------- - */ -haddr_t -H5F_get_eoa(const H5F_t *f, H5FD_mem_t type) -{ - haddr_t ret_value; - - FUNC_ENTER_NOAPI(H5F_get_eoa, HADDR_UNDEF) - - HDassert(f); - HDassert(f->shared); - - /* Dispatch to driver */ - if(HADDR_UNDEF == (ret_value = H5FD_get_eoa(f->shared->lf, type))) - HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, HADDR_UNDEF, "driver get_eoa request failed") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5F_get_eoa() */ - - -/*------------------------------------------------------------------------- * Function: H5F_incr_nopen_objs * * Purpose: Increment the number of open objects for a file. @@ -2217,6 +2156,100 @@ H5F_decr_nopen_objs(H5F_t *f) /*------------------------------------------------------------------------- + * Function: H5F_build_actual_name + * + * Purpose: Retrieve the name of a file, after following symlinks, etc. + * + * Note: Currently only working for "POSIX I/O compatible" VFDs + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Quincey Koziol + * November 25, 2009 + * + *------------------------------------------------------------------------- + */ +herr_t +H5F_build_actual_name(const H5F_t *f, const char *name, char **actual_name/*out*/) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5F_build_actual_name) + + /* Sanity check */ + HDassert(f); + HDassert(name); + HDassert(actual_name); + + /* Clear actual name pointer to begin with */ + *actual_name = NULL; + +/* Assume that if the OS can't create symlinks, that we don't need to worry + * about resolving them either. -QAK + */ +#ifdef H5_HAVE_SYMLINK + /* Check for POSIX I/O compatible file handle */ + if(H5F_HAS_FEATURE(f, H5FD_FEAT_POSIX_COMPAT_HANDLE)) { + h5_stat_t lst; /* Stat info from lstat() call */ + + /* Call lstat() on the file's name */ + if(HDlstat(name, &lst) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve stat info for file") + + /* Check for symbolic link */ + if(S_IFLNK == (lst.st_mode & S_IFMT)) { + int *fd; /* POSIX I/O file descriptor */ + h5_stat_t st; /* Stat info from stat() call */ + h5_stat_t fst; /* Stat info from fstat() call */ + char realname[PATH_MAX]; /* Fully resolved path name of file */ + + /* Perform a sanity check that the file or link wasn't switched + * between when we opened it and when we called lstat(). This is + * according to the security best practices for lstat() documented + * here: https://www.securecoding.cert.org/confluence/display/seccode/POS35-C.+Avoid+race+conditions+while+checking+for+the+existence+of+a+symbolic+link + */ + + /* Retrieve the file handle */ + if(H5F_get_vfd_handle(f, H5P_DEFAULT, (void **)&fd) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve POSIX file descriptor") + + /* Stat the filename we're resolving */ + if(HDstat(name, &st) < 0) + HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "unable to stat file") + + /* Stat the file we opened */ + if(HDfstat(*fd, &fst) < 0) + HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "unable to fstat file") + + /* Verify that the files are really the same */ + if(st.st_mode != fst.st_mode || st.st_ino != fst.st_ino || st.st_dev != fst.st_dev) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "files' st_ino or st_dev fields changed!") + + /* Get the resolved path for the file name */ + if(NULL == HDrealpath(name, realname)) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve real path for file") + + /* Duplicate the resolved path for the file name */ + if(NULL == (*actual_name = (char *)H5MM_strdup(realname))) + HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, FAIL, "can't duplicate real path") + } /* end if */ + } /* end if */ +#endif /* H5_HAVE_SYMLINK */ + + /* Check if we've resolved the file's name */ + if(NULL == *actual_name) { + /* Just duplicate the name used to open the file */ + if(NULL == (*actual_name = (char *)H5MM_strdup(name))) + HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, FAIL, "can't duplicate open name") + } /* end else */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5F_build_actual_name() */ + + +/*------------------------------------------------------------------------- * Function: H5F_addr_encode_len * * Purpose: Encodes an address into the buffer pointed to by *PP and @@ -2752,6 +2785,9 @@ done: * If an error occurs then the buffer pointed to by `name' (NULL or non-NULL) * is unchanged and the function returns a negative value. * + * Note: This routine returns the name that was used to open the file, + * not the actual name after resolving symlinks, etc. + * * Return: Success: The length of the file name * Failure: Negative * @@ -2787,10 +2823,10 @@ H5Fget_name(hid_t obj_id, char *name/*out*/, size_t size) f = loc.oloc->file; } /* end else */ - len = HDstrlen(f->name); + len = HDstrlen(H5F_OPEN_NAME(f)); if(name) { - HDstrncpy(name, f->name, MIN(len+1,size)); + HDstrncpy(name, H5F_OPEN_NAME(f), MIN(len + 1,size)); if(len >= size) name[size-1]='\0'; } /* end if */ diff --git a/src/H5FAtest.c b/src/H5FAtest.c index 98abd16..187b5be 100644 --- a/src/H5FAtest.c +++ b/src/H5FAtest.c @@ -80,6 +80,8 @@ static herr_t H5FA__test_decode(const void *raw, void *elmt, size_t nelmts, void *ctx); static herr_t H5FA__test_debug(FILE *stream, int indent, int fwidth, hsize_t idx, const void *elmt); +static void *H5FA__test_crt_dbg_context(H5F_t *f, hid_t dxpl_id, + haddr_t obj_addr); /*********************/ @@ -97,8 +99,8 @@ const H5FA_class_t H5FA_CLS_TEST[1]={{ H5FA__test_encode, /* Element encoding callback */ H5FA__test_decode, /* Element decoding callback */ H5FA__test_debug, /* Element debugging callback */ - NULL, /* Create debugging context */ - NULL /* Destroy debugging context */ + H5FA__test_crt_dbg_context, /* Create debugging context */ + H5FA__test_dst_context /* Destroy debugging context */ }}; @@ -224,10 +226,12 @@ END_FUNC(STATIC) /* end H5FA__test_fill() */ */ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, -H5FA__test_encode(void *raw, const void *_elmt, size_t nelmts, void *_ctx)) +H5FA__test_encode(void *raw, const void *_elmt, size_t nelmts, void UNUSED *_ctx)) /* Local variables */ +#ifndef NDEBUG H5FA__test_ctx_t *ctx = (H5FA__test_ctx_t *)_ctx; /* Callback context to destroy */ +#endif /* NDEBUG */ const uint64_t *elmt = (const uint64_t *)_elmt; /* Convenience pointer to native elements */ /* Sanity checks */ @@ -267,10 +271,12 @@ END_FUNC(STATIC) /* end H5FA__test_encode() */ */ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, -H5FA__test_decode(const void *_raw, void *_elmt, size_t nelmts, void *_ctx)) +H5FA__test_decode(const void *_raw, void *_elmt, size_t nelmts, void UNUSED *_ctx)) /* Local variables */ +#ifndef NDEBUG H5FA__test_ctx_t *ctx = (H5FA__test_ctx_t *)_ctx; /* Callback context to destroy */ +#endif /* NDEBUG */ uint64_t *elmt = (uint64_t *)_elmt; /* Convenience pointer to native elements */ const uint8_t *raw = (const uint8_t *)_raw; /* Convenience pointer to raw elements */ @@ -330,6 +336,41 @@ END_FUNC(STATIC) /* end H5FA__test_debug() */ /*------------------------------------------------------------------------- + * Function: H5FA__test_crt_dbg_context + * + * Purpose: Create context for debugging callback + * + * Return: Success: non-NULL + * Failure: NULL + * + * Programmer: Quincey Koziol + * Tuesday, December 1, 2009 + * + *------------------------------------------------------------------------- + */ +BEGIN_FUNC(STATIC, ERR, +void *, NULL, NULL, +H5FA__test_crt_dbg_context(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, haddr_t UNUSED obj_addr)) + + /* Local variables */ + H5FA__test_ctx_t *ctx; /* Context for callbacks */ + + /* Allocate new context structure */ + if(NULL == (ctx = H5FL_MALLOC(H5FA__test_ctx_t))) + H5E_THROW(H5E_CANTALLOC, "can't allocate fixed array client callback context") + + /* Initialize the context */ + ctx->bogus = H5FA__TEST_BOGUS_VAL; + + /* Set return value */ + ret_value = ctx; + +CATCH + +END_FUNC(STATIC) /* end H5FA__test_crt_dbg_context() */ + + +/*------------------------------------------------------------------------- * Function: H5FA_get_cparam_test * * Purpose: Retrieve the parameters used to create the fixed array diff --git a/src/H5FD.c b/src/H5FD.c index 8a0e230..4c0da40 100644 --- a/src/H5FD.c +++ b/src/H5FD.c @@ -2036,8 +2036,6 @@ done: * Programmer: Raymond Lu * Sep. 16, 2002 * - * Modifications: - * *-------------------------------------------------------------------------- */ herr_t @@ -2047,11 +2045,13 @@ H5FD_get_vfd_handle(H5FD_t *file, hid_t fapl, void **file_handle) FUNC_ENTER_NOAPI(H5FD_get_vfd_handle, FAIL) + /* Sanity check */ + HDassert(file); HDassert(file_handle); if(NULL == file->cls->get_handle) HGOTO_ERROR(H5E_VFL, H5E_UNSUPPORTED, FAIL, "file driver has no `get_vfd_handle' method") - if((ret_value = file->cls->get_handle(file, fapl, file_handle)) < 0) + if((file->cls->get_handle)(file, fapl, file_handle) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get file handle for file driver") done: diff --git a/src/H5FDlog.c b/src/H5FDlog.c index 906e73a..fe15005 100644 --- a/src/H5FDlog.c +++ b/src/H5FDlog.c @@ -808,22 +808,20 @@ done: static herr_t H5FD_log_query(const H5FD_t UNUSED * _f, unsigned long *flags /* out */) { - herr_t ret_value=SUCCEED; - - FUNC_ENTER_NOAPI(H5FD_log_query, FAIL) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FD_log_query) /* Set the VFL feature flags that this driver supports */ if(flags) { *flags = 0; - *flags|=H5FD_FEAT_AGGREGATE_METADATA; /* OK to aggregate metadata allocations */ - *flags|=H5FD_FEAT_ACCUMULATE_METADATA; /* OK to accumulate metadata for faster writes */ - *flags|=H5FD_FEAT_DATA_SIEVE; /* OK to perform data sieving for faster raw data reads & writes */ - *flags|=H5FD_FEAT_AGGREGATE_SMALLDATA; /* OK to aggregate "small" raw data allocations */ - } + *flags |= H5FD_FEAT_AGGREGATE_METADATA; /* OK to aggregate metadata allocations */ + *flags |= H5FD_FEAT_ACCUMULATE_METADATA; /* OK to accumulate metadata for faster writes */ + *flags |= H5FD_FEAT_DATA_SIEVE; /* OK to perform data sieving for faster raw data reads & writes */ + *flags |= H5FD_FEAT_AGGREGATE_SMALLDATA; /* OK to aggregate "small" raw data allocations */ + *flags |= H5FD_FEAT_POSIX_COMPAT_HANDLE; /* VFD handle is POSIX I/O call compatible */ + } /* end if */ -done: - FUNC_LEAVE_NOAPI(ret_value) -} + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FD_log_query() */ /*------------------------------------------------------------------------- diff --git a/src/H5FDpublic.h b/src/H5FDpublic.h index ed24506..c8ec658 100644 --- a/src/H5FDpublic.h +++ b/src/H5FDpublic.h @@ -204,6 +204,12 @@ typedef enum H5F_mem_t H5FD_mem_t; * is flushed/closed. */ #define H5FD_FEAT_DIRTY_SBLK_LOAD 0x00000040 + /* + * Defining the H5FD_FEAT_POSIX_COMPAT_HANDLE for a VFL driver means that + * the handle for the VFD (returned with the 'get_handle' callback) is + * of type 'int' and is compatible with POSIX I/O calls. + */ +#define H5FD_FEAT_POSIX_COMPAT_HANDLE 0x00000080 /* Forward declaration */ diff --git a/src/H5FDsec2.c b/src/H5FDsec2.c index 318839d..324f489 100644 --- a/src/H5FDsec2.c +++ b/src/H5FDsec2.c @@ -43,9 +43,13 @@ static hid_t H5FD_SEC2_g = 0; /* File operations */ -#define OP_UNKNOWN 0 -#define OP_READ 1 -#define OP_WRITE 2 +typedef enum { + OP_UNKNOWN = 0, /* Unknown last file operation */ + OP_READ = 1, /* Last file I/O operation was a read */ + OP_WRITE = 2 /* Last file I/O operation was a write */ +} H5FD_sec2_file_op_t; + +#define H5FD_SEC2_MAX_FILENAME_LEN 1024 /* * The description of a file belonging to this driver. The `eoa' and `eof' @@ -65,7 +69,8 @@ typedef struct H5FD_sec2_t { haddr_t eoa; /*end of allocated region */ haddr_t eof; /*end of file; current file size*/ haddr_t pos; /*current file I/O position */ - int op; /*last operation */ + H5FD_sec2_file_op_t op; /*last operation */ + char filename[H5FD_SEC2_MAX_FILENAME_LEN]; /* Copy of file name from open operation */ #ifndef _WIN32 /* * On most systems the combination of device and i-node number uniquely @@ -261,8 +266,6 @@ done: * Programmer: Quincey Koziol * Friday, Jan 30, 2004 * - * Modification: - * *--------------------------------------------------------------------------- */ void @@ -271,7 +274,7 @@ H5FD_sec2_term(void) FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FD_sec2_term) /* Reset VFL ID */ - H5FD_SEC2_g=0; + H5FD_SEC2_g = 0; FUNC_LEAVE_NOAPI_VOID } /* end H5FD_sec2_term() */ @@ -289,8 +292,6 @@ H5FD_sec2_term(void) * Programmer: Robb Matzke * Thursday, February 19, 1998 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t @@ -347,34 +348,41 @@ H5FD_sec2_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) FUNC_ENTER_NOAPI(H5FD_sec2_open, NULL) /* Sanity check on file offsets */ - assert(sizeof(file_offset_t)>=sizeof(size_t)); + HDassert(sizeof(file_offset_t) >= sizeof(size_t)); /* Check arguments */ - if (!name || !*name) + if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid file name") - if (0==maxaddr || HADDR_UNDEF==maxaddr) + if(0 == maxaddr || HADDR_UNDEF == maxaddr) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "bogus maxaddr") - if (ADDR_OVERFLOW(maxaddr)) + if(ADDR_OVERFLOW(maxaddr)) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, NULL, "bogus maxaddr") /* Build the open flags */ o_flags = (H5F_ACC_RDWR & flags) ? O_RDWR : O_RDONLY; - if (H5F_ACC_TRUNC & flags) o_flags |= O_TRUNC; - if (H5F_ACC_CREAT & flags) o_flags |= O_CREAT; - if (H5F_ACC_EXCL & flags) o_flags |= O_EXCL; + if(H5F_ACC_TRUNC & flags) + o_flags |= O_TRUNC; + if(H5F_ACC_CREAT & flags) + o_flags |= O_CREAT; + if(H5F_ACC_EXCL & flags) + o_flags |= O_EXCL; /* Open the file */ - if ((fd=HDopen(name, o_flags, 0666))<0) - HSYS_GOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file") - if (HDfstat(fd, &sb)<0) + if((fd = HDopen(name, o_flags, 0666)) < 0) { + int myerrno = errno; + time_t mytime = HDtime(NULL); + + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file: time = %s, name = '%s', errno = %d, error message = '%s', flags = %x, o_flags = %x", HDctime(&mytime), name, myerrno, HDstrerror(myerrno), flags, (unsigned)o_flags); + } /* end if */ + if(HDfstat(fd, &sb) < 0) HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, NULL, "unable to fstat file") /* Create the new file struct */ - if (NULL==(file=H5FL_CALLOC(H5FD_sec2_t))) + if(NULL == (file = H5FL_CALLOC(H5FD_sec2_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to allocate file struct") file->fd = fd; - H5_ASSIGN_OVERFLOW(file->eof,sb.st_size,h5_stat_size_t,haddr_t); + H5_ASSIGN_OVERFLOW(file->eof, sb.st_size, h5_stat_size_t, haddr_t); file->pos = HADDR_UNDEF; file->op = OP_UNKNOWN; #ifdef _WIN32 @@ -382,7 +390,7 @@ H5FD_sec2_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) (void)GetFileInformationByHandle((HANDLE)filehandle, &fileinfo); file->fileindexhi = fileinfo.nFileIndexHigh; file->fileindexlo = fileinfo.nFileIndexLow; -#else +#else /* _WIN32 */ file->device = sb.st_dev; #ifdef H5_VMS file->inode[0] = sb.st_ino[0]; @@ -392,7 +400,11 @@ H5FD_sec2_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) file->inode = sb.st_ino; #endif /*H5_VMS*/ -#endif +#endif /* _WIN32 */ + + /* Retain a copy of the name used to open the file, for possible error reporting */ + HDstrncpy(file->filename, name, sizeof(file->filename)); + file->filename[sizeof(file->filename) - 1] = '\0'; /* Check for SWMR reader access */ if(flags & H5F_ACC_SWMR_READ) @@ -556,6 +568,7 @@ H5FD_sec2_query(const H5FD_t *_file, unsigned long *flags /* out */) *flags |= H5FD_FEAT_ACCUMULATE_METADATA; /* OK to accumulate metadata for faster writes */ *flags |= H5FD_FEAT_DATA_SIEVE; /* OK to perform data sieving for faster raw data reads & writes */ *flags |= H5FD_FEAT_AGGREGATE_SMALLDATA; /* OK to aggregate "small" raw data allocations */ + *flags |= H5FD_FEAT_POSIX_COMPAT_HANDLE; /* VFD handle is POSIX I/O call compatible */ /* Check for flags that are set by h5repart */ if(file->fam_to_sec2) @@ -685,13 +698,11 @@ done: * Programmer: Raymond Lu * Sept. 16, 2002 * - * Modifications: - * *------------------------------------------------------------------------- */ /* ARGSUSED */ static herr_t -H5FD_sec2_get_handle(H5FD_t *_file, hid_t UNUSED fapl, void** file_handle) +H5FD_sec2_get_handle(H5FD_t *_file, hid_t UNUSED fapl, void **file_handle) { H5FD_sec2_t *file = (H5FD_sec2_t *)_file; herr_t ret_value = SUCCEED; @@ -704,7 +715,7 @@ H5FD_sec2_get_handle(H5FD_t *_file, hid_t UNUSED fapl, void** file_handle) done: FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5FD_sec2_get_handle() */ /*------------------------------------------------------------------------- @@ -758,8 +769,13 @@ H5FD_sec2_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, do { nbytes = HDread(file->fd, buf, size); } while(-1 == nbytes && EINTR == errno); - if(-1 == nbytes) /* error */ - HSYS_GOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file read failed") + if(-1 == nbytes) { /* error */ + int myerrno = errno; + time_t mytime = HDtime(NULL); + file_offset_t myoffset = HDlseek(file->fd, (file_offset_t)0, SEEK_CUR); + + HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file read failed: time = %s, filename = '%s', file descriptor = %d, errno = %d, error message = '%s', buf = %p, size = %lu, offset = %llu", HDctime(&mytime), file->filename, file->fd, myerrno, HDstrerror(myerrno), buf, (unsigned long)size, (unsigned long long)myoffset); + } /* end if */ if(0 == nbytes) { /* end of file but not end of format address space */ HDmemset(buf, 0, size); @@ -845,8 +861,13 @@ H5FD_sec2_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, had do { nbytes = HDwrite(file->fd, buf, size); } while(-1 == nbytes && EINTR == errno); - if(-1 == nbytes) /* error */ - HSYS_GOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed") + if(-1 == nbytes) { /* error */ + int myerrno = errno; + time_t mytime = HDtime(NULL); + file_offset_t myoffset = HDlseek(file->fd, (file_offset_t)0, SEEK_CUR); + + HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed: time = %s, filename = '%s', file descriptor = %d, errno = %d, error message = '%s', buf = %p, size = %lu, offset = %llu", HDctime(&mytime), file->filename, file->fd, myerrno, HDstrerror(myerrno), buf, (unsigned long)size, (unsigned long long)myoffset); + } /* end if */ HDassert(nbytes > 0); HDassert((size_t)nbytes <= size); H5_CHECK_OVERFLOW(nbytes, ssize_t, size_t); diff --git a/src/H5FDsec2.h b/src/H5FDsec2.h index 9c3f59d..b7db0d5 100644 --- a/src/H5FDsec2.h +++ b/src/H5FDsec2.h @@ -39,3 +39,4 @@ H5_DLL herr_t H5Pset_fapl_sec2(hid_t fapl_id); #endif #endif + diff --git a/src/H5Fdbg.c b/src/H5Fdbg.c index 2b13f11..723005e 100644 --- a/src/H5Fdbg.c +++ b/src/H5Fdbg.c @@ -73,7 +73,9 @@ H5F_debug(H5F_t *f, FILE *stream, int indent, int fwidth) HDfprintf(stream, "%*sFile Super Block...\n", indent, ""); HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "File name:", f->name); + "File name (as opened):", H5F_OPEN_NAME(f)); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, + "File name (after resolving symlinks):", H5F_ACTUAL_NAME(f)); HDfprintf(stream, "%*s%-*s 0x%08x\n", indent, "", fwidth, "File access flags", f->shared->flags); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h index e664ca8..9a63b6a 100644 --- a/src/H5Fpkg.h +++ b/src/H5Fpkg.h @@ -224,7 +224,7 @@ typedef struct H5F_file_t { unsigned gc_ref; /* Garbage-collect references? */ hbool_t latest_format; /* Always use the latest format? */ hbool_t store_msg_crt_idx; /* Store creation index for object header messages? */ - int ncwfs; /* Num entries on cwfs list */ + int ncwfs; /* Num entries on cwfs list */ struct H5HG_heap_t **cwfs; /* Global heap cache */ struct H5G_t *root_grp; /* Open root group */ H5FO_t *open_objs; /* Open objects in file */ @@ -232,7 +232,7 @@ typedef struct H5F_file_t { /* File space allocation information */ H5F_file_space_type_t fs_strategy; /* File space handling strategy */ - hsize_t fs_threshold; /* Free space section threshold */ + hsize_t fs_threshold; /* Free space section threshold */ hbool_t use_tmp_space; /* Whether temp. file space allocation is allowed */ haddr_t tmp_addr; /* Next address to use for temp. space in the file */ unsigned fs_aggr_merge[H5FD_MEM_NTYPES]; /* Flags for whether free space can merge with aggregator(s) */ @@ -252,14 +252,12 @@ typedef struct H5F_file_t { /* * This is the top-level file descriptor. One of these structures is * allocated every time H5Fopen() is called although they may contain pointers - * to shared H5F_file_t structs. The reference count (nrefs) indicates the - * number of times the file has been opened (the application can only open a - * file once explicitly, but the library can open the file a second time to - * indicate that the file is mounted on some other file). + * to shared H5F_file_t structs. */ struct H5F_t { unsigned intent; /* The flags passed to H5F_open()*/ - char *name; /* Name used to open file */ + char *open_name; /* Name used to open file */ + char *actual_name; /* Actual name of the file, after resolving symlinks, etc. */ char *extpath; /* Path for searching target external link file */ H5F_file_t *shared; /* The shared file info */ unsigned nopen_objs; /* Number of open object headers*/ diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index 6ddbae3..e86a99e 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -249,8 +249,9 @@ typedef struct H5F_blk_aggr_t H5F_blk_aggr_t; #define H5F_SIEVE_BUF_SIZE(F) ((F)->shared->sieve_buf_size) #define H5F_GC_REF(F) ((F)->shared->gc_ref) #define H5F_USE_LATEST_FORMAT(F) ((F)->shared->latest_format) +#define H5F_OPEN_NAME(F) ((F)->open_name) +#define H5F_ACTUAL_NAME(F) ((F)->actual_name) #define H5F_EXTPATH(F) ((F)->extpath) -#define H5F_NAME(F) ((F)->name) #define H5F_GET_FC_DEGREE(F) ((F)->shared->fc_degree) #define H5F_STORE_MSG_CRT_IDX(F) ((F)->shared->store_msg_crt_idx) #define H5F_HAS_FEATURE(F,FL) ((F)->shared->lf->feature_flags & (FL)) @@ -273,8 +274,9 @@ typedef struct H5F_blk_aggr_t H5F_blk_aggr_t; #define H5F_SIEVE_BUF_SIZE(F) (H5F_sieve_buf_size(F)) #define H5F_GC_REF(F) (H5F_gc_ref(F)) #define H5F_USE_LATEST_FORMAT(F) (H5F_use_latest_format(F)) +#define H5F_OPEN_NAME(F) (H5F_get_open_name(F)) +#define H5F_ACTUAL_NAME(F) (H5F_get_actual_name(F)) #define H5F_EXTPATH(F) (H5F_get_extpath(F)) -#define H5F_NAME(F) (H5F_get_name(F)) #define H5F_GET_FC_DEGREE(F) (H5F_get_fc_degree(F)) #define H5F_STORE_MSG_CRT_IDX(F) (H5F_store_msg_crt_idx(F)) #define H5F_HAS_FEATURE(F,FL) (H5F_has_feature(F,FL)) @@ -298,20 +300,24 @@ typedef struct H5F_blk_aggr_t H5F_blk_aggr_t; case 2: UINT16DECODE(p, o); break; \ } -#define H5F_ENCODE_LENGTH(f,p,l) switch(H5F_SIZEOF_SIZE(f)) { \ +#define H5F_ENCODE_LENGTH_LEN(p,l,s) switch(s) { \ case 4: UINT32ENCODE(p,l); break; \ case 8: UINT64ENCODE(p,l); break; \ case 2: UINT16ENCODE(p,l); break; \ default: HDassert("bad sizeof size" && 0); \ } -#define H5F_DECODE_LENGTH(f,p,l) switch(H5F_SIZEOF_SIZE(f)) { \ +#define H5F_ENCODE_LENGTH(f,p,l) H5F_ENCODE_LENGTH_LEN(p,l,H5F_SIZEOF_SIZE(f)) + +#define H5F_DECODE_LENGTH_LEN(p,l,s) switch(s) { \ case 4: UINT32DECODE(p,l); break; \ case 8: UINT64DECODE(p,l); break; \ case 2: UINT16DECODE(p,l); break; \ default: HDassert("bad sizeof size" && 0); \ } +#define H5F_DECODE_LENGTH(f,p,l) H5F_DECODE_LENGTH_LEN(p,l,H5F_SIZEOF_SIZE(f)) + /* * Macros that check for overflows. These are somewhat dangerous to fiddle * with. @@ -469,12 +475,15 @@ H5_DLL H5F_t *H5F_open(const char *name, unsigned flags, hid_t fcpl_id, H5_DLL herr_t H5F_try_close(H5F_t *f); H5_DLL unsigned H5F_incr_nopen_objs(H5F_t *f); H5_DLL unsigned H5F_decr_nopen_objs(H5F_t *f); +H5_DLL herr_t H5F_build_actual_name(const H5F_t *f, const char *, + char ** /*out*/ ); /* Functions than retrieve values from the file struct */ H5_DLL unsigned H5F_get_intent(const H5F_t *f); H5_DLL hid_t H5F_get_access_plist(H5F_t *f, hbool_t app_ref); H5_DLL char *H5F_get_extpath(const H5F_t *f); -H5_DLL char *H5F_get_name(const H5F_t *f); +H5_DLL char *H5F_get_open_name(const H5F_t *f); +H5_DLL char *H5F_get_actual_name(const H5F_t *f); H5_DLL hid_t H5F_get_id(H5F_t *file, hbool_t app_ref); H5_DLL size_t H5F_get_obj_count(const H5F_t *f, unsigned types, hbool_t app_ref); H5_DLL size_t H5F_get_obj_ids(const H5F_t *f, unsigned types, size_t max_objs, hid_t *obj_id_list, hbool_t app_ref); @@ -504,6 +513,8 @@ H5_DLL hbool_t H5F_has_feature(const H5F_t *f, unsigned feature); 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 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); /* Functions than check file mounting information */ H5_DLL hbool_t H5F_is_mount(const H5F_t *file); diff --git a/src/H5Fquery.c b/src/H5Fquery.c index 70c5ff1..c5ecf6b 100644 --- a/src/H5Fquery.c +++ b/src/H5Fquery.c @@ -103,54 +103,81 @@ H5F_get_intent(const H5F_t *f) /*------------------------------------------------------------------------- - * Function: H5F_get_extpath + * Function: H5F_get_open_name * - * Purpose: Retrieve the file's 'extpath' flags - * This is used by H5L_extern_traverse() to retrieve the main file's location - * when searching the target file. + * Purpose: Retrieve the name used to open a file. * - * Return: 'extpath' on success/abort on failure (shouldn't fail) + * Return: Success: The name of the file. + * Failure: ? (should not happen) * - * Programmer: Vailin Choi, April 2, 2008 + * Programmer: Neil Fortner + * December 15 2008 * *------------------------------------------------------------------------- */ char * -H5F_get_extpath(const H5F_t *f) +H5F_get_open_name(const H5F_t *f) { /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_get_extpath) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_get_open_name) HDassert(f); + HDassert(f->open_name); - FUNC_LEAVE_NOAPI(f->extpath) -} /* end H5F_get_extpath() */ + FUNC_LEAVE_NOAPI(f->open_name) +} /* end H5F_get_open_name() */ /*------------------------------------------------------------------------- - * Function: H5F_get_name + * Function: H5F_get_actual_name * - * Purpose: Retrieve the name of a file. + * Purpose: Retrieve the actual name of a file, after resolving symlinks, etc. * * Return: Success: The name of the file. - * * Failure: ? (should not happen) * - * Programmer: Neil Fortner - * December 15 2008 + * Programmer: Quincey Koziol + * November 25 2009 * *------------------------------------------------------------------------- */ char * -H5F_get_name(const H5F_t *f) +H5F_get_actual_name(const H5F_t *f) { /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_get_name) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_get_actual_name) HDassert(f); + HDassert(f->actual_name); - FUNC_LEAVE_NOAPI(f->name) -} /* end H5F_get_name() */ + FUNC_LEAVE_NOAPI(f->actual_name) +} /* end H5F_get_actual_name() */ + + +/*------------------------------------------------------------------------- + * Function: H5F_get_extpath + * + * Purpose: Retrieve the file's 'extpath' flags + * This is used by H5L_extern_traverse() to retrieve the main file's location + * when searching the target file. + * + * Return: 'extpath' on success/abort on failure (shouldn't fail) + * + * Programmer: Vailin Choi, April 2, 2008 + * + *------------------------------------------------------------------------- + */ +char * +H5F_get_extpath(const H5F_t *f) +{ + /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */ + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_get_extpath) + + HDassert(f); + HDassert(f->extpath); + + FUNC_LEAVE_NOAPI(f->extpath) +} /* end H5F_get_extpath() */ /*------------------------------------------------------------------------- @@ -690,6 +717,71 @@ done: /*------------------------------------------------------------------------- + * Function: H5F_get_eoa + * + * Purpose: Quick and dirty routine to retrieve the file's 'eoa' value + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * June 1, 2004 + * + *------------------------------------------------------------------------- + */ +haddr_t +H5F_get_eoa(const H5F_t *f, H5FD_mem_t type) +{ + haddr_t ret_value; + + FUNC_ENTER_NOAPI(H5F_get_eoa, HADDR_UNDEF) + + HDassert(f); + HDassert(f->shared); + + /* Dispatch to driver */ + if(HADDR_UNDEF == (ret_value = H5FD_get_eoa(f->shared->lf, type))) + HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, HADDR_UNDEF, "driver get_eoa request failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5F_get_eoa() */ + + +/*------------------------------------------------------------------------- + * Function: H5F_get_vfd_handle + * + * Purpose: Returns a pointer to the file handle of the low-level file + * driver. This is the private function for H5Fget_vfd_handle. + * + * Return: Success: Non-negative. + * Failure: negative. + * + * Programmer: Raymond Lu + * Sep. 16, 2002 + * + *------------------------------------------------------------------------- + */ +herr_t +H5F_get_vfd_handle(const H5F_t *file, hid_t fapl, void **file_handle) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(H5F_get_vfd_handle, FAIL) + + /* Sanity check */ + HDassert(file); + HDassert(file_handle); + + /* Get the VFD handle */ + if(H5FD_get_vfd_handle(file->shared->lf, fapl, file_handle) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get file handle for file driver") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5F_get_vfd_handle() */ + + +/*------------------------------------------------------------------------- * Function: H5F_is_tmp_addr * * Purpose: Quick and dirty routine to determine if an address is in diff --git a/src/H5Gbtree2.c b/src/H5Gbtree2.c index 29ab309..5ae9db1 100644 --- a/src/H5Gbtree2.c +++ b/src/H5Gbtree2.c @@ -79,20 +79,20 @@ typedef struct H5G_fh_ud_cmp_t { /* v2 B-tree driver callbacks for 'creation order' index */ static herr_t H5G_dense_btree2_corder_store(void *native, const void *udata); static herr_t H5G_dense_btree2_corder_compare(const void *rec1, const void *rec2); -static herr_t H5G_dense_btree2_corder_encode(const H5F_t *f, uint8_t *raw, - const void *native); -static herr_t H5G_dense_btree2_corder_decode(const H5F_t *f, const uint8_t *raw, - void *native); +static herr_t H5G_dense_btree2_corder_encode(uint8_t *raw, const void *native, + void *ctx); +static herr_t H5G_dense_btree2_corder_decode(const uint8_t *raw, void *native, + void *ctx); static herr_t H5G_dense_btree2_corder_debug(FILE *stream, const H5F_t *f, hid_t dxpl_id, int indent, int fwidth, const void *record, const void *_udata); /* v2 B-tree driver callbacks for 'name' index */ static herr_t H5G_dense_btree2_name_store(void *native, const void *udata); static herr_t H5G_dense_btree2_name_compare(const void *rec1, const void *rec2); -static herr_t H5G_dense_btree2_name_encode(const H5F_t *f, uint8_t *raw, - const void *native); -static herr_t H5G_dense_btree2_name_decode(const H5F_t *f, const uint8_t *raw, - void *native); +static herr_t H5G_dense_btree2_name_encode(uint8_t *raw, const void *native, + void *ctx); +static herr_t H5G_dense_btree2_name_decode(const uint8_t *raw, void *native, + void *ctx); static herr_t H5G_dense_btree2_name_debug(FILE *stream, const H5F_t *f, hid_t dxpl_id, int indent, int fwidth, const void *record, const void *_udata); @@ -108,11 +108,15 @@ const H5B2_class_t H5G_BT2_NAME[1]={{ /* B-tree class information */ H5B2_GRP_DENSE_NAME_ID, /* Type of B-tree */ "H5B2_GRP_DENSE_NAME_ID", /* Name of B-tree class */ sizeof(H5G_dense_bt2_name_rec_t), /* Size of native record */ + NULL, /* Create client callback context */ + NULL, /* Destroy client callback context */ H5G_dense_btree2_name_store, /* Record storage callback */ 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 */ + H5G_dense_btree2_name_debug, /* Record debugging callback */ + NULL, /* Create debugging context */ + NULL /* Destroy debugging context */ }}; /* v2 B-tree class for indexing 'creation order' field of links */ @@ -120,11 +124,15 @@ const H5B2_class_t H5G_BT2_CORDER[1]={{ /* B-tree class information */ H5B2_GRP_DENSE_CORDER_ID, /* Type of B-tree */ "H5B2_GRP_DENSE_CORDER_ID", /* Name of B-tree class */ sizeof(H5G_dense_bt2_corder_rec_t), /* Size of native record */ + NULL, /* Create client callback context */ + NULL, /* Destroy client callback context */ H5G_dense_btree2_corder_store, /* Record storage callback */ 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 */ + H5G_dense_btree2_corder_debug, /* Record debugging callback */ + NULL, /* Create debugging context */ + NULL /* Destroy debugging context */ }}; /*****************************/ @@ -298,7 +306,7 @@ for(u = 0; u < H5G_DENSE_FHEAP_ID_LEN; u++) *------------------------------------------------------------------------- */ static herr_t -H5G_dense_btree2_name_encode(const H5F_t UNUSED *f, uint8_t *raw, const void *_nrecord) +H5G_dense_btree2_name_encode(uint8_t *raw, const void *_nrecord, void UNUSED *ctx) { const H5G_dense_bt2_name_rec_t *nrecord = (const H5G_dense_bt2_name_rec_t *)_nrecord; @@ -326,7 +334,7 @@ H5G_dense_btree2_name_encode(const H5F_t UNUSED *f, uint8_t *raw, const void *_n *------------------------------------------------------------------------- */ static herr_t -H5G_dense_btree2_name_decode(const H5F_t UNUSED *f, const uint8_t *raw, void *_nrecord) +H5G_dense_btree2_name_decode(const uint8_t *raw, void *_nrecord, void UNUSED *ctx) { H5G_dense_bt2_name_rec_t *nrecord = (H5G_dense_bt2_name_rec_t *)_nrecord; @@ -464,7 +472,7 @@ for(u = 0; u < H5G_DENSE_FHEAP_ID_LEN; u++) *------------------------------------------------------------------------- */ static herr_t -H5G_dense_btree2_corder_encode(const H5F_t UNUSED *f, uint8_t *raw, const void *_nrecord) +H5G_dense_btree2_corder_encode(uint8_t *raw, const void *_nrecord, void UNUSED *ctx) { const H5G_dense_bt2_corder_rec_t *nrecord = (const H5G_dense_bt2_corder_rec_t *)_nrecord; @@ -492,7 +500,7 @@ H5G_dense_btree2_corder_encode(const H5F_t UNUSED *f, uint8_t *raw, const void * *------------------------------------------------------------------------- */ static herr_t -H5G_dense_btree2_corder_decode(const H5F_t UNUSED *f, const uint8_t *raw, void *_nrecord) +H5G_dense_btree2_corder_decode(const uint8_t *raw, void *_nrecord, void UNUSED *ctx) { H5G_dense_bt2_corder_rec_t *nrecord = (H5G_dense_bt2_corder_rec_t *)_nrecord; diff --git a/src/H5Gdense.c b/src/H5Gdense.c index f935a74..9a8e764 100644 --- a/src/H5Gdense.c +++ b/src/H5Gdense.c @@ -326,7 +326,7 @@ HDfprintf(stderr, "%s: fheap_id_len = %Zu\n", FUNC, fheap_id_len); fheap_id_len; /* Fractal heap ID */ bt2_cparam.split_percent = H5G_NAME_BT2_SPLIT_PERC; bt2_cparam.merge_percent = H5G_NAME_BT2_MERGE_PERC; - if(NULL == (bt2_name = H5B2_create(f, dxpl_id, &bt2_cparam))) + if(NULL == (bt2_name = H5B2_create(f, dxpl_id, &bt2_cparam, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create v2 B-tree for name index") /* Retrieve the v2 B-tree's address in the file */ @@ -346,7 +346,7 @@ HDfprintf(stderr, "%s: linfo->name_bt2_addr = %a\n", FUNC, linfo->name_bt2_addr) fheap_id_len; /* Fractal heap ID */ bt2_cparam.split_percent = H5G_CORDER_BT2_SPLIT_PERC; bt2_cparam.merge_percent = H5G_CORDER_BT2_MERGE_PERC; - if(NULL == (bt2_corder = H5B2_create(f, dxpl_id, &bt2_cparam))) + if(NULL == (bt2_corder = H5B2_create(f, dxpl_id, &bt2_cparam, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create v2 B-tree for creation order index") /* Retrieve the v2 B-tree's address in the file */ @@ -438,7 +438,7 @@ HDfprintf(stderr, "%s: HDstrlen(lnk->name) = %Zu, link_size = %Zu\n", FUNC, HDst HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "unable to insert link into fractal heap") /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(f, dxpl_id, linfo->name_bt2_addr))) + if(NULL == (bt2_name = H5B2_open(f, dxpl_id, linfo->name_bt2_addr, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Create the callback information for v2 B-tree record insertion */ @@ -460,7 +460,7 @@ HDfprintf(stderr, "%s: HDstrlen(lnk->name) = %Zu, link_size = %Zu\n", FUNC, HDst if(linfo->index_corder) { /* Open the creation order index v2 B-tree */ HDassert(H5F_addr_defined(linfo->corder_bt2_addr)); - if(NULL == (bt2_corder = H5B2_open(f, dxpl_id, linfo->corder_bt2_addr))) + if(NULL == (bt2_corder = H5B2_open(f, dxpl_id, linfo->corder_bt2_addr, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for creation order index") /* Insert the record into the creation order index v2 B-tree */ @@ -557,7 +557,7 @@ H5G_dense_lookup(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo, HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(f, dxpl_id, linfo->name_bt2_addr))) + if(NULL == (bt2_name = H5B2_open(f, dxpl_id, linfo->name_bt2_addr, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Construct the user data for v2 B-tree callback */ @@ -733,7 +733,7 @@ H5G_dense_lookup_by_idx(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo, HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Open the index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, dxpl_id, bt2_addr))) + if(NULL == (bt2 = H5B2_open(f, dxpl_id, bt2_addr, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for index") /* Construct the user data for v2 B-tree callback */ @@ -1042,7 +1042,7 @@ H5G_dense_iterate(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo, HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Open the index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, dxpl_id, bt2_addr))) + if(NULL == (bt2 = H5B2_open(f, dxpl_id, bt2_addr, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for index") /* Construct the user data for v2 B-tree iterator callback */ @@ -1244,7 +1244,7 @@ H5G_dense_get_name_by_idx(H5F_t *f, hid_t dxpl_id, H5O_linfo_t *linfo, HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Open the index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, dxpl_id, bt2_addr))) + if(NULL == (bt2 = H5B2_open(f, dxpl_id, bt2_addr, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for index") /* Set up the user data for the v2 B-tree 'record remove' callback */ @@ -1326,7 +1326,7 @@ H5G_dense_remove_fh_cb(const void *obj, size_t UNUSED obj_len, void *_udata) H5G_bt2_ud_common_t bt2_udata; /* Info for B-tree callbacks */ /* Open the creation order index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(udata->f, udata->dxpl_id, udata->corder_bt2_addr))) + if(NULL == (bt2 = H5B2_open(udata->f, udata->dxpl_id, udata->corder_bt2_addr, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for creation order index") /* Set up the user data for the v2 B-tree 'record remove' callback */ @@ -1440,7 +1440,7 @@ H5G_dense_remove(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo, HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Open the name index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, dxpl_id, linfo->name_bt2_addr))) + if(NULL == (bt2 = H5B2_open(f, dxpl_id, linfo->name_bt2_addr, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Set up the user data for the v2 B-tree 'record remove' callback */ @@ -1577,7 +1577,7 @@ H5G_dense_remove_by_idx_bt2_cb(const void *_record, void *_bt2_udata) } /* end else */ /* Open the index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(bt2_udata->f, bt2_udata->dxpl_id, bt2_udata->other_bt2_addr))) + if(NULL == (bt2 = H5B2_open(bt2_udata->f, bt2_udata->dxpl_id, bt2_udata->other_bt2_addr, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for 'other' index") /* Set the common information for the v2 B-tree remove operation */ @@ -1682,7 +1682,7 @@ H5G_dense_remove_by_idx(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo, HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Open the index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, dxpl_id, bt2_addr))) + if(NULL == (bt2 = H5B2_open(f, dxpl_id, bt2_addr, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for index") /* Set up the user data for the v2 B-tree 'remove by index' callback */ @@ -1776,7 +1776,7 @@ H5G_dense_delete(H5F_t *f, hid_t dxpl_id, H5O_linfo_t *linfo, hbool_t adj_link) udata.replace_names = FALSE; /* Delete the name index, adjusting the ref. count on links removed */ - if(H5B2_delete(f, dxpl_id, linfo->name_bt2_addr, H5G_dense_remove_bt2_cb, &udata) < 0) + if(H5B2_delete(f, dxpl_id, linfo->name_bt2_addr, NULL, H5G_dense_remove_bt2_cb, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to delete v2 B-tree for name index") /* Close the fractal heap */ @@ -1785,7 +1785,7 @@ H5G_dense_delete(H5F_t *f, hid_t dxpl_id, H5O_linfo_t *linfo, hbool_t adj_link) } /* end if */ else { /* Delete the name index, without adjusting the ref. count on the links */ - if(H5B2_delete(f, dxpl_id, linfo->name_bt2_addr, NULL, NULL) < 0) + if(H5B2_delete(f, dxpl_id, linfo->name_bt2_addr, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to delete v2 B-tree for name index") } /* end else */ linfo->name_bt2_addr = HADDR_UNDEF; @@ -1794,7 +1794,7 @@ H5G_dense_delete(H5F_t *f, hid_t dxpl_id, H5O_linfo_t *linfo, hbool_t adj_link) if(linfo->index_corder) { /* Delete the creation order index, without adjusting the ref. count on the links */ HDassert(H5F_addr_defined(linfo->corder_bt2_addr)); - if(H5B2_delete(f, dxpl_id, linfo->corder_bt2_addr, NULL, NULL) < 0) + if(H5B2_delete(f, dxpl_id, linfo->corder_bt2_addr, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to delete v2 B-tree for creation order index") linfo->corder_bt2_addr = HADDR_UNDEF; } /* end if */ diff --git a/src/H5Gloc.c b/src/H5Gloc.c index b6a3a17..47214a4 100644 --- a/src/H5Gloc.c +++ b/src/H5Gloc.c @@ -409,7 +409,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5G_loc_find_cb(H5G_loc_t UNUSED *grp_loc/*in*/, const char UNUSED *name, +H5G_loc_find_cb(H5G_loc_t UNUSED *grp_loc/*in*/, const char *name, const H5O_link_t UNUSED *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, H5G_own_loc_t *own_loc/*out*/) { @@ -420,7 +420,7 @@ H5G_loc_find_cb(H5G_loc_t UNUSED *grp_loc/*in*/, const char UNUSED *name, /* Check if the name in this group resolved to a valid object */ if(obj_loc == NULL) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object doesn't exist") + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object '%s' doesn't exist", name) /* Take ownership of the object's group location */ /* (Group traversal callbacks are responsible for either taking ownership diff --git a/src/H5Gobj.c b/src/H5Gobj.c index 4281ac0..271501f 100644 --- a/src/H5Gobj.c +++ b/src/H5Gobj.c @@ -331,7 +331,7 @@ H5G_obj_get_linfo(const H5O_loc_t *grp_oloc, H5O_linfo_t *linfo, hid_t dxpl_id) /* Check if we are using "dense" link storage */ if(H5F_addr_defined(linfo->fheap_addr)) { /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(grp_oloc->file, dxpl_id, linfo->name_bt2_addr))) + if(NULL == (bt2_name = H5B2_open(grp_oloc->file, dxpl_id, linfo->name_bt2_addr, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Retrieve # of records in "name" B-tree */ diff --git a/src/H5Goh.c b/src/H5Goh.c index 2494838..ea51179 100644 --- a/src/H5Goh.c +++ b/src/H5Goh.c @@ -360,7 +360,7 @@ H5O_group_bh_info(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5_ih_info_t *bh_info) /* Check if name index available */ if(H5F_addr_defined(linfo.name_bt2_addr)) { /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(f, dxpl_id, linfo.name_bt2_addr))) + if(NULL == (bt2_name = H5B2_open(f, dxpl_id, linfo.name_bt2_addr, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Get name index B-tree size */ @@ -371,7 +371,7 @@ H5O_group_bh_info(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5_ih_info_t *bh_info) /* Check if creation order index available */ if(H5F_addr_defined(linfo.corder_bt2_addr)) { /* Open the creation order index v2 B-tree */ - if(NULL == (bt2_corder = H5B2_open(f, dxpl_id, linfo.corder_bt2_addr))) + if(NULL == (bt2_corder = H5B2_open(f, dxpl_id, linfo.corder_bt2_addr, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for creation order index") /* Get creation order index B-tree size */ diff --git a/src/H5Gtest.c b/src/H5Gtest.c index 791c13a..26de267 100644 --- a/src/H5Gtest.c +++ b/src/H5Gtest.c @@ -405,7 +405,7 @@ H5G_new_dense_info_test(hid_t gid, hsize_t *name_count, hsize_t *corder_count) HGOTO_DONE(FAIL) /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(grp->oloc.file, H5AC_dxpl_id, linfo.name_bt2_addr))) + if(NULL == (bt2_name = H5B2_open(grp->oloc.file, H5AC_dxpl_id, linfo.name_bt2_addr, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Retrieve # of records in name index */ @@ -415,7 +415,7 @@ H5G_new_dense_info_test(hid_t gid, hsize_t *name_count, hsize_t *corder_count) /* Check if there is a creation order index */ if(H5F_addr_defined(linfo.corder_bt2_addr)) { /* Open the creation order index v2 B-tree */ - if(NULL == (bt2_corder = H5B2_open(grp->oloc.file, H5AC_dxpl_id, linfo.corder_bt2_addr))) + if(NULL == (bt2_corder = H5B2_open(grp->oloc.file, H5AC_dxpl_id, linfo.corder_bt2_addr, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for creation order index") /* Retrieve # of records in creation order index */ diff --git a/src/H5HFbtree2.c b/src/H5HFbtree2.c index ae50bf3..3f208e7 100644 --- a/src/H5HFbtree2.c +++ b/src/H5HFbtree2.c @@ -49,6 +49,12 @@ /* Local Typedefs */ /******************/ +/* v2 B-tree client callback context */ +typedef struct H5HF_huge_bt2_ctx_t { + uint8_t sizeof_size; /* Size of file sizes */ + uint8_t sizeof_addr; /* Size of file addresses */ +} H5HF_huge_bt2_ctx_t; + /********************/ /* Package Typedefs */ @@ -59,92 +65,114 @@ /* Local Prototypes */ /********************/ + /* v2 B-tree driver callbacks */ -static herr_t H5HF_huge_btree2_indir_store(void *native, const void *udata); -static herr_t H5HF_huge_btree2_indir_compare(const void *rec1, const void *rec2); -static herr_t H5HF_huge_btree2_indir_encode(const H5F_t *f, uint8_t *raw, - const void *native); -static herr_t H5HF_huge_btree2_indir_decode(const H5F_t *f, const uint8_t *raw, - void *native); -static herr_t H5HF_huge_btree2_indir_debug(FILE *stream, const H5F_t *f, hid_t dxpl_id, + +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); + +static herr_t H5HF_huge_bt2_indir_store(void *native, const void *udata); +static herr_t H5HF_huge_bt2_indir_compare(const void *rec1, const void *rec2); +static herr_t H5HF_huge_bt2_indir_encode(uint8_t *raw, const void *native, + void *ctx); +static herr_t H5HF_huge_bt2_indir_decode(const uint8_t *raw, void *native, + void *ctx); +static herr_t H5HF_huge_bt2_indir_debug(FILE *stream, const H5F_t *f, hid_t dxpl_id, int indent, int fwidth, const void *record, const void *_udata); -static herr_t H5HF_huge_btree2_filt_indir_store(void *native, const void *udata); -static herr_t H5HF_huge_btree2_filt_indir_compare(const void *rec1, const void *rec2); -static herr_t H5HF_huge_btree2_filt_indir_encode(const H5F_t *f, uint8_t *raw, - const void *native); -static herr_t H5HF_huge_btree2_filt_indir_decode(const H5F_t *f, const uint8_t *raw, - void *native); -static herr_t H5HF_huge_btree2_filt_indir_debug(FILE *stream, const H5F_t *f, hid_t dxpl_id, +static herr_t H5HF_huge_bt2_filt_indir_store(void *native, const void *udata); +static herr_t H5HF_huge_bt2_filt_indir_compare(const void *rec1, const void *rec2); +static herr_t H5HF_huge_bt2_filt_indir_encode(uint8_t *raw, const void *native, + void *ctx); +static herr_t H5HF_huge_bt2_filt_indir_decode(const uint8_t *raw, void *native, + void *ctx); +static herr_t H5HF_huge_bt2_filt_indir_debug(FILE *stream, const H5F_t *f, hid_t dxpl_id, int indent, int fwidth, const void *record, const void *_udata); -static herr_t H5HF_huge_btree2_dir_store(void *native, const void *udata); -static herr_t H5HF_huge_btree2_dir_compare(const void *rec1, const void *rec2); -static herr_t H5HF_huge_btree2_dir_encode(const H5F_t *f, uint8_t *raw, - const void *native); -static herr_t H5HF_huge_btree2_dir_decode(const H5F_t *f, const uint8_t *raw, - void *native); -static herr_t H5HF_huge_btree2_dir_debug(FILE *stream, const H5F_t *f, hid_t dxpl_id, +static herr_t H5HF_huge_bt2_dir_store(void *native, const void *udata); +static herr_t H5HF_huge_bt2_dir_compare(const void *rec1, const void *rec2); +static herr_t H5HF_huge_bt2_dir_encode(uint8_t *raw, const void *native, + void *ctx); +static herr_t H5HF_huge_bt2_dir_decode(const uint8_t *raw, void *native, + void *ctx); +static herr_t H5HF_huge_bt2_dir_debug(FILE *stream, const H5F_t *f, hid_t dxpl_id, int indent, int fwidth, const void *record, const void *_udata); -static herr_t H5HF_huge_btree2_filt_dir_store(void *native, const void *udata); -static herr_t H5HF_huge_btree2_filt_dir_compare(const void *rec1, const void *rec2); -static herr_t H5HF_huge_btree2_filt_dir_encode(const H5F_t *f, uint8_t *raw, - const void *native); -static herr_t H5HF_huge_btree2_filt_dir_decode(const H5F_t *f, const uint8_t *raw, - void *native); -static herr_t H5HF_huge_btree2_filt_dir_debug(FILE *stream, const H5F_t *f, hid_t dxpl_id, +static herr_t H5HF_huge_bt2_filt_dir_store(void *native, const void *udata); +static herr_t H5HF_huge_bt2_filt_dir_compare(const void *rec1, const void *rec2); +static herr_t H5HF_huge_bt2_filt_dir_encode(uint8_t *raw, const void *native, + void *ctx); +static herr_t H5HF_huge_bt2_filt_dir_decode(const uint8_t *raw, void *native, + void *ctx); +static herr_t H5HF_huge_bt2_filt_dir_debug(FILE *stream, const H5F_t *f, hid_t dxpl_id, int indent, int fwidth, const void *record, const void *_udata); /*********************/ /* Package Variables */ /*********************/ /* v2 B-tree class for indirectly accessed 'huge' objects */ -const H5B2_class_t H5HF_BT2_INDIR[1]={{ /* B-tree class information */ - H5B2_FHEAP_HUGE_INDIR_ID, /* Type of B-tree */ - "H5B2_FHEAP_HUGE_INDIR_ID", /* Name of B-tree class */ - sizeof(H5HF_huge_bt2_indir_rec_t), /* Size of native record */ - H5HF_huge_btree2_indir_store, /* Record storage callback */ - H5HF_huge_btree2_indir_compare, /* Record comparison callback */ - H5HF_huge_btree2_indir_encode, /* Record encoding callback */ - H5HF_huge_btree2_indir_decode, /* Record decoding callback */ - H5HF_huge_btree2_indir_debug /* Record debugging callback */ +const H5B2_class_t H5HF_HUGE_BT2_INDIR[1]={{ /* B-tree class information */ + H5B2_FHEAP_HUGE_INDIR_ID, /* Type of B-tree */ + "H5B2_FHEAP_HUGE_INDIR_ID", /* Name of B-tree class */ + sizeof(H5HF_huge_bt2_indir_rec_t), /* Size of native record */ + H5HF_huge_bt2_crt_context, /* Create client callback context */ + H5HF_huge_bt2_dst_context, /* Destroy client callback context */ + H5HF_huge_bt2_indir_store, /* Record storage callback */ + 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 */ }}; /* v2 B-tree class for indirectly accessed, filtered 'huge' objects */ -const H5B2_class_t H5HF_BT2_FILT_INDIR[1]={{ /* B-tree class information */ - H5B2_FHEAP_HUGE_FILT_INDIR_ID, /* Type of B-tree */ - "H5B2_FHEAP_HUGE_FILT_INDIR_ID", /* Name of B-tree class */ - sizeof(H5HF_huge_bt2_filt_indir_rec_t), /* Size of native record */ - H5HF_huge_btree2_filt_indir_store, /* Record storage callback */ - H5HF_huge_btree2_filt_indir_compare, /* Record comparison callback */ - H5HF_huge_btree2_filt_indir_encode, /* Record encoding callback */ - H5HF_huge_btree2_filt_indir_decode, /* Record decoding callback */ - H5HF_huge_btree2_filt_indir_debug /* Record debugging callback */ +const H5B2_class_t H5HF_HUGE_BT2_FILT_INDIR[1]={{ /* B-tree class information */ + H5B2_FHEAP_HUGE_FILT_INDIR_ID, /* Type of B-tree */ + "H5B2_FHEAP_HUGE_FILT_INDIR_ID", /* Name of B-tree class */ + sizeof(H5HF_huge_bt2_filt_indir_rec_t), /* Size of native record */ + H5HF_huge_bt2_crt_context, /* Create client callback context */ + H5HF_huge_bt2_dst_context, /* Destroy client callback context */ + H5HF_huge_bt2_filt_indir_store, /* Record storage callback */ + 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 */ }}; /* v2 B-tree class for directly accessed 'huge' objects */ -const H5B2_class_t H5HF_BT2_DIR[1]={{ /* B-tree class information */ - H5B2_FHEAP_HUGE_DIR_ID, /* Type of B-tree */ - "H5B2_FHEAP_HUGE_DIR_ID", /* Name of B-tree class */ - sizeof(H5HF_huge_bt2_dir_rec_t), /* Size of native record */ - H5HF_huge_btree2_dir_store, /* Record storage callback */ - H5HF_huge_btree2_dir_compare, /* Record comparison callback */ - H5HF_huge_btree2_dir_encode, /* Record encoding callback */ - H5HF_huge_btree2_dir_decode, /* Record decoding callback */ - H5HF_huge_btree2_dir_debug /* Record debugging callback */ +const H5B2_class_t H5HF_HUGE_BT2_DIR[1]={{ /* B-tree class information */ + H5B2_FHEAP_HUGE_DIR_ID, /* Type of B-tree */ + "H5B2_FHEAP_HUGE_DIR_ID", /* Name of B-tree class */ + sizeof(H5HF_huge_bt2_dir_rec_t), /* Size of native record */ + H5HF_huge_bt2_crt_context, /* Create client callback context */ + H5HF_huge_bt2_dst_context, /* Destroy client callback context */ + H5HF_huge_bt2_dir_store, /* Record storage callback */ + 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 */ }}; /* v2 B-tree class for directly accessed, filtered 'huge' objects */ -const H5B2_class_t H5HF_BT2_FILT_DIR[1]={{ /* B-tree class information */ - H5B2_FHEAP_HUGE_FILT_DIR_ID, /* Type of B-tree */ - "H5B2_FHEAP_HUGE_FILT_DIR_ID", /* Name of B-tree class */ - sizeof(H5HF_huge_bt2_filt_dir_rec_t),/* Size of native record */ - H5HF_huge_btree2_filt_dir_store, /* Record storage callback */ - H5HF_huge_btree2_filt_dir_compare, /* Record comparison callback */ - H5HF_huge_btree2_filt_dir_encode, /* Record encoding callback */ - H5HF_huge_btree2_filt_dir_decode, /* Record decoding callback */ - H5HF_huge_btree2_filt_dir_debug /* Record debugging callback */ +const H5B2_class_t H5HF_HUGE_BT2_FILT_DIR[1]={{ /* B-tree class information */ + H5B2_FHEAP_HUGE_FILT_DIR_ID, /* Type of B-tree */ + "H5B2_FHEAP_HUGE_FILT_DIR_ID", /* Name of B-tree class */ + sizeof(H5HF_huge_bt2_filt_dir_rec_t), /* Size of native record */ + H5HF_huge_bt2_crt_context, /* Create client callback context */ + H5HF_huge_bt2_dst_context, /* Destroy client callback context */ + H5HF_huge_bt2_filt_dir_store, /* Record storage callback */ + 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 */ }}; /*****************************/ @@ -156,6 +184,126 @@ const H5B2_class_t H5HF_BT2_FILT_DIR[1]={{ /* B-tree class information */ /* Local Variables */ /*******************/ +/* Declare a free list to manage the H5HF_huge_bt2_ctx_t struct */ +H5FL_DEFINE_STATIC(H5HF_huge_bt2_ctx_t); + + + +/*------------------------------------------------------------------------- + * Function: H5HF_huge_bt2_crt_context + * + * Purpose: Create client callback context + * + * Note: Common to all 'huge' v2 B-tree clients + * + * Return: Success: non-NULL + * Failure: NULL + * + * Programmer: Quincey Koziol + * Thursday, November 26, 2009 + * + *------------------------------------------------------------------------- + */ +static void * +H5HF_huge_bt2_crt_context(void *_f) +{ + H5F_t *f = (H5F_t *)_f; /* User data for building callback context */ + H5HF_huge_bt2_ctx_t *ctx; /* Callback context structure */ + void *ret_value; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5HF_huge_bt2_crt_context) + + /* 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_context() */ + + +/*------------------------------------------------------------------------- + * Function: H5HF_huge_bt2_dst_context + * + * Purpose: Destroy client callback context + * + * Note: Common to all 'huge' v2 B-tree clients + * + * Return: Success: non-negative + * Failure: negative + * + * Programmer: Quincey Koziol + * Thursday, November 26, 2009 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5HF_huge_bt2_dst_context(void *_ctx) +{ + H5HF_huge_bt2_ctx_t *ctx = (H5HF_huge_bt2_ctx_t *)_ctx; /* Callback context structure */ + + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_bt2_dst_context) + + /* Sanity check */ + HDassert(ctx); + + /* Release callback context */ + ctx = H5FL_FREE(H5HF_huge_bt2_ctx_t, ctx); + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* H5HF_huge_bt2_dst_context() */ + + +/*------------------------------------------------------------------------- + * 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 UNUSED dxpl_id, haddr_t UNUSED addr) +{ + H5HF_huge_bt2_ctx_t *ctx; /* Callback context structure */ + void *ret_value; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5HF_huge_bt2_crt_dbg_context) + + /* Sanity check */ + HDassert(f); + HDassert(H5F_addr_defined(addr)); + + /* 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 @@ -223,7 +371,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5HF_huge_btree2_indir_store + * Function: H5HF_huge_bt2_indir_store * * Purpose: Store native information into record for v2 B-tree * @@ -236,18 +384,18 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5HF_huge_btree2_indir_store(void *nrecord, const void *udata) +H5HF_huge_bt2_indir_store(void *nrecord, const void *udata) { - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_btree2_indir_store) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_bt2_indir_store) *(H5HF_huge_bt2_indir_rec_t *)nrecord = *(const H5HF_huge_bt2_indir_rec_t *)udata; FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5HF_huge_btree2_indir_store() */ +} /* H5HF_huge_bt2_indir_store() */ /*------------------------------------------------------------------------- - * Function: H5HF_huge_btree2_indir_compare + * Function: H5HF_huge_bt2_indir_compare * * Purpose: Compare two native information records, according to some key * @@ -261,25 +409,25 @@ H5HF_huge_btree2_indir_store(void *nrecord, const void *udata) *------------------------------------------------------------------------- */ static herr_t -H5HF_huge_btree2_indir_compare(const void *_rec1, const void *_rec2) +H5HF_huge_bt2_indir_compare(const void *_rec1, const void *_rec2) { - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_btree2_indir_compare) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_bt2_indir_compare) #ifdef QAK { const H5HF_huge_bt2_indir_rec_t *rec1 = (const H5HF_huge_bt2_indir_rec_t *)_rec1; const H5HF_huge_bt2_indir_rec_t *rec2 = (const H5HF_huge_bt2_indir_rec_t *)_rec2; -HDfprintf(stderr, "%s: rec1 = {%a, %Hu, %Hu}\n", "H5HF_huge_btree2_indir_compare", rec1->addr, rec1->len, rec1->id); -HDfprintf(stderr, "%s: rec2 = {%a, %Hu, %Hu}\n", "H5HF_huge_btree2_indir_compare", rec2->addr, rec2->len, rec2->id); +HDfprintf(stderr, "%s: rec1 = {%a, %Hu, %Hu}\n", "H5HF_huge_bt2_indir_compare", rec1->addr, rec1->len, rec1->id); +HDfprintf(stderr, "%s: rec2 = {%a, %Hu, %Hu}\n", "H5HF_huge_bt2_indir_compare", rec2->addr, rec2->len, rec2->id); } #endif /* QAK */ FUNC_LEAVE_NOAPI((herr_t)(((const H5HF_huge_bt2_indir_rec_t *)_rec1)->id - ((const H5HF_huge_bt2_indir_rec_t *)_rec2)->id)) -} /* H5HF_huge_btree2_indir_compare() */ +} /* H5HF_huge_bt2_indir_compare() */ /*------------------------------------------------------------------------- - * Function: H5HF_huge_btree2_indir_encode + * Function: H5HF_huge_bt2_indir_encode * * Purpose: Encode native information into raw form for storing on disk * @@ -292,23 +440,27 @@ HDfprintf(stderr, "%s: rec2 = {%a, %Hu, %Hu}\n", "H5HF_huge_btree2_indir_compare *------------------------------------------------------------------------- */ static herr_t -H5HF_huge_btree2_indir_encode(const H5F_t *f, uint8_t *raw, const void *_nrecord) +H5HF_huge_bt2_indir_encode(uint8_t *raw, const void *_nrecord, void *_ctx) { + H5HF_huge_bt2_ctx_t *ctx = (H5HF_huge_bt2_ctx_t *)_ctx; /* Callback context structure */ const H5HF_huge_bt2_indir_rec_t *nrecord = (const H5HF_huge_bt2_indir_rec_t *)_nrecord; - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_btree2_indir_encode) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_bt2_indir_encode) + + /* Sanity check */ + HDassert(ctx); /* Encode the record's fields */ - H5F_addr_encode(f, &raw, nrecord->addr); - H5F_ENCODE_LENGTH(f, raw, nrecord->len); - H5F_ENCODE_LENGTH(f, raw, nrecord->id); + H5F_addr_encode_len(ctx->sizeof_addr, &raw, nrecord->addr); + H5F_ENCODE_LENGTH_LEN(raw, nrecord->len, ctx->sizeof_size); + H5F_ENCODE_LENGTH_LEN(raw, nrecord->id, ctx->sizeof_size); FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5HF_huge_btree2_indir_encode() */ +} /* H5HF_huge_bt2_indir_encode() */ /*------------------------------------------------------------------------- - * Function: H5HF_huge_btree2_indir_decode + * Function: H5HF_huge_bt2_indir_decode * * Purpose: Decode raw disk form of record into native form * @@ -321,23 +473,27 @@ H5HF_huge_btree2_indir_encode(const H5F_t *f, uint8_t *raw, const void *_nrecord *------------------------------------------------------------------------- */ static herr_t -H5HF_huge_btree2_indir_decode(const H5F_t *f, const uint8_t *raw, void *_nrecord) +H5HF_huge_bt2_indir_decode(const uint8_t *raw, void *_nrecord, void *_ctx) { + H5HF_huge_bt2_ctx_t *ctx = (H5HF_huge_bt2_ctx_t *)_ctx; /* Callback context structure */ H5HF_huge_bt2_indir_rec_t *nrecord = (H5HF_huge_bt2_indir_rec_t *)_nrecord; - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_btree2_indir_decode) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_bt2_indir_decode) + + /* Sanity check */ + HDassert(ctx); /* Decode the record's fields */ - H5F_addr_decode(f, &raw, &nrecord->addr); - H5F_DECODE_LENGTH(f, raw, nrecord->len); - H5F_DECODE_LENGTH(f, raw, nrecord->id); + H5F_addr_decode_len(ctx->sizeof_addr, &raw, &nrecord->addr); + H5F_DECODE_LENGTH_LEN(raw, nrecord->len, ctx->sizeof_size); + H5F_DECODE_LENGTH_LEN(raw, nrecord->id, ctx->sizeof_size); FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5HF_huge_btree2_indir_decode() */ +} /* H5HF_huge_bt2_indir_decode() */ /*------------------------------------------------------------------------- - * Function: H5HF_huge_btree2_indir_debug + * Function: H5HF_huge_bt2_indir_debug * * Purpose: Debug native form of record * @@ -350,19 +506,19 @@ H5HF_huge_btree2_indir_decode(const H5F_t *f, const uint8_t *raw, void *_nrecord *------------------------------------------------------------------------- */ static herr_t -H5HF_huge_btree2_indir_debug(FILE *stream, const H5F_t UNUSED *f, hid_t UNUSED dxpl_id, +H5HF_huge_bt2_indir_debug(FILE *stream, const H5F_t UNUSED *f, hid_t UNUSED dxpl_id, int indent, int fwidth, const void *_nrecord, const void UNUSED *_udata) { const H5HF_huge_bt2_indir_rec_t *nrecord = (const H5HF_huge_bt2_indir_rec_t *)_nrecord; - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_btree2_indir_debug) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_bt2_indir_debug) HDfprintf(stream, "%*s%-*s {%a, %Hu, %Hu}\n", indent, "", fwidth, "Record:", nrecord->addr, nrecord->len, nrecord->id); FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5HF_huge_btree2_indir_debug() */ +} /* H5HF_huge_bt2_indir_debug() */ /*------------------------------------------------------------------------- @@ -433,7 +589,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5HF_huge_btree2_filt_indir_store + * Function: H5HF_huge_bt2_filt_indir_store * * Purpose: Store native information into record for v2 B-tree * @@ -446,18 +602,18 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5HF_huge_btree2_filt_indir_store(void *nrecord, const void *udata) +H5HF_huge_bt2_filt_indir_store(void *nrecord, const void *udata) { - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_btree2_filt_indir_store) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_bt2_filt_indir_store) *(H5HF_huge_bt2_filt_indir_rec_t *)nrecord = *(const H5HF_huge_bt2_filt_indir_rec_t *)udata; FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5HF_huge_btree2_filt_indir_store() */ +} /* H5HF_huge_bt2_filt_indir_store() */ /*------------------------------------------------------------------------- - * Function: H5HF_huge_btree2_filt_indir_compare + * Function: H5HF_huge_bt2_filt_indir_compare * * Purpose: Compare two native information records, according to some key * @@ -471,25 +627,25 @@ H5HF_huge_btree2_filt_indir_store(void *nrecord, const void *udata) *------------------------------------------------------------------------- */ static herr_t -H5HF_huge_btree2_filt_indir_compare(const void *_rec1, const void *_rec2) +H5HF_huge_bt2_filt_indir_compare(const void *_rec1, const void *_rec2) { - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_btree2_filt_indir_compare) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_bt2_filt_indir_compare) #ifdef QAK { const H5HF_huge_bt2_filt_indir_rec_t *rec1 = (const H5HF_huge_bt2_filt_indir_rec_t *)_rec1; const H5HF_huge_bt2_filt_indir_rec_t *rec2 = (const H5HF_huge_bt2_filt_indir_rec_t *)_rec2; -HDfprintf(stderr, "%s: rec1 = {%a, %Hu, %x, %Hu, %Hu}\n", "H5HF_huge_btree2_filt_indir_compare", rec1->addr, rec1->len, rec1->filter_mask, rec1->obj_size, rec1->id); -HDfprintf(stderr, "%s: rec2 = {%a, %Hu, %x, %Hu, %Hu}\n", "H5HF_huge_btree2_filt_indir_compare", rec2->addr, rec2->len, rec2->filter_mask, rec2->obj_size, rec2->id); +HDfprintf(stderr, "%s: rec1 = {%a, %Hu, %x, %Hu, %Hu}\n", "H5HF_huge_bt2_filt_indir_compare", rec1->addr, rec1->len, rec1->filter_mask, rec1->obj_size, rec1->id); +HDfprintf(stderr, "%s: rec2 = {%a, %Hu, %x, %Hu, %Hu}\n", "H5HF_huge_bt2_filt_indir_compare", rec2->addr, rec2->len, rec2->filter_mask, rec2->obj_size, rec2->id); } #endif /* QAK */ FUNC_LEAVE_NOAPI((herr_t)(((const H5HF_huge_bt2_filt_indir_rec_t *)_rec1)->id - ((const H5HF_huge_bt2_filt_indir_rec_t *)_rec2)->id)) -} /* H5HF_huge_btree2_filt_indir_compare() */ +} /* H5HF_huge_bt2_filt_indir_compare() */ /*------------------------------------------------------------------------- - * Function: H5HF_huge_btree2_filt_indir_encode + * Function: H5HF_huge_bt2_filt_indir_encode * * Purpose: Encode native information into raw form for storing on disk * @@ -502,25 +658,29 @@ HDfprintf(stderr, "%s: rec2 = {%a, %Hu, %x, %Hu, %Hu}\n", "H5HF_huge_btree2_filt *------------------------------------------------------------------------- */ static herr_t -H5HF_huge_btree2_filt_indir_encode(const H5F_t *f, uint8_t *raw, const void *_nrecord) +H5HF_huge_bt2_filt_indir_encode(uint8_t *raw, const void *_nrecord, void *_ctx) { + H5HF_huge_bt2_ctx_t *ctx = (H5HF_huge_bt2_ctx_t *)_ctx; /* Callback context structure */ const H5HF_huge_bt2_filt_indir_rec_t *nrecord = (const H5HF_huge_bt2_filt_indir_rec_t *)_nrecord; - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_btree2_filt_indir_encode) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_bt2_filt_indir_encode) + + /* Sanity check */ + HDassert(ctx); /* Encode the record's fields */ - H5F_addr_encode(f, &raw, nrecord->addr); - H5F_ENCODE_LENGTH(f, raw, nrecord->len); + H5F_addr_encode_len(ctx->sizeof_addr, &raw, nrecord->addr); + H5F_ENCODE_LENGTH_LEN(raw, nrecord->len, ctx->sizeof_size); UINT32ENCODE(raw, nrecord->filter_mask); - H5F_ENCODE_LENGTH(f, raw, nrecord->obj_size); - H5F_ENCODE_LENGTH(f, raw, nrecord->id); + H5F_ENCODE_LENGTH_LEN(raw, nrecord->obj_size, ctx->sizeof_size); + H5F_ENCODE_LENGTH_LEN(raw, nrecord->id, ctx->sizeof_size); FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5HF_huge_btree2_filt_indir_encode() */ +} /* H5HF_huge_bt2_filt_indir_encode() */ /*------------------------------------------------------------------------- - * Function: H5HF_huge_btree2_filt_indir_decode + * Function: H5HF_huge_bt2_filt_indir_decode * * Purpose: Decode raw disk form of record into native form * @@ -533,25 +693,29 @@ H5HF_huge_btree2_filt_indir_encode(const H5F_t *f, uint8_t *raw, const void *_nr *------------------------------------------------------------------------- */ static herr_t -H5HF_huge_btree2_filt_indir_decode(const H5F_t *f, const uint8_t *raw, void *_nrecord) +H5HF_huge_bt2_filt_indir_decode(const uint8_t *raw, void *_nrecord, void *_ctx) { + H5HF_huge_bt2_ctx_t *ctx = (H5HF_huge_bt2_ctx_t *)_ctx; /* Callback context structure */ H5HF_huge_bt2_filt_indir_rec_t *nrecord = (H5HF_huge_bt2_filt_indir_rec_t *)_nrecord; - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_btree2_filt_indir_decode) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_bt2_filt_indir_decode) + + /* Sanity check */ + HDassert(ctx); /* Decode the record's fields */ - H5F_addr_decode(f, &raw, &nrecord->addr); - H5F_DECODE_LENGTH(f, raw, nrecord->len); + H5F_addr_decode_len(ctx->sizeof_addr, &raw, &nrecord->addr); + H5F_DECODE_LENGTH_LEN(raw, nrecord->len, ctx->sizeof_size); UINT32DECODE(raw, nrecord->filter_mask); - H5F_DECODE_LENGTH(f, raw, nrecord->obj_size); - H5F_DECODE_LENGTH(f, raw, nrecord->id); + H5F_DECODE_LENGTH_LEN(raw, nrecord->obj_size, ctx->sizeof_size); + H5F_DECODE_LENGTH_LEN(raw, nrecord->id, ctx->sizeof_size); FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5HF_huge_btree2_filt_indir_decode() */ +} /* H5HF_huge_bt2_filt_indir_decode() */ /*------------------------------------------------------------------------- - * Function: H5HF_huge_btree2_filt_indir_debug + * Function: H5HF_huge_bt2_filt_indir_debug * * Purpose: Debug native form of record * @@ -564,19 +728,19 @@ H5HF_huge_btree2_filt_indir_decode(const H5F_t *f, const uint8_t *raw, void *_nr *------------------------------------------------------------------------- */ static herr_t -H5HF_huge_btree2_filt_indir_debug(FILE *stream, const H5F_t UNUSED *f, hid_t UNUSED dxpl_id, +H5HF_huge_bt2_filt_indir_debug(FILE *stream, const H5F_t UNUSED *f, hid_t UNUSED dxpl_id, int indent, int fwidth, const void *_nrecord, const void UNUSED *_udata) { const H5HF_huge_bt2_filt_indir_rec_t *nrecord = (const H5HF_huge_bt2_filt_indir_rec_t *)_nrecord; - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_btree2_filt_indir_debug) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_bt2_filt_indir_debug) HDfprintf(stream, "%*s%-*s {%a, %Hu, %x, %Hu, %Hu}\n", indent, "", fwidth, "Record:", nrecord->addr, nrecord->len, nrecord->filter_mask, nrecord->obj_size, nrecord->id); FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5HF_huge_btree2_filt_indir_debug() */ +} /* H5HF_huge_bt2_filt_indir_debug() */ /*------------------------------------------------------------------------- @@ -614,7 +778,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5HF_huge_btree2_dir_store + * Function: H5HF_huge_bt2_dir_store * * Purpose: Store native information into record for v2 B-tree * @@ -627,18 +791,18 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5HF_huge_btree2_dir_store(void *nrecord, const void *udata) +H5HF_huge_bt2_dir_store(void *nrecord, const void *udata) { - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_btree2_dir_store) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_bt2_dir_store) *(H5HF_huge_bt2_dir_rec_t *)nrecord = *(const H5HF_huge_bt2_dir_rec_t *)udata; FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5HF_huge_btree2_dir_store() */ +} /* H5HF_huge_bt2_dir_store() */ /*------------------------------------------------------------------------- - * Function: H5HF_huge_btree2_dir_compare + * Function: H5HF_huge_bt2_dir_compare * * Purpose: Compare two native information records, according to some key * @@ -652,17 +816,17 @@ H5HF_huge_btree2_dir_store(void *nrecord, const void *udata) *------------------------------------------------------------------------- */ static herr_t -H5HF_huge_btree2_dir_compare(const void *_rec1, const void *_rec2) +H5HF_huge_bt2_dir_compare(const void *_rec1, const void *_rec2) { const H5HF_huge_bt2_dir_rec_t *rec1 = (const H5HF_huge_bt2_dir_rec_t *)_rec1; const H5HF_huge_bt2_dir_rec_t *rec2 = (const H5HF_huge_bt2_dir_rec_t *)_rec2; herr_t ret_value; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_btree2_dir_compare) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_bt2_dir_compare) #ifdef QAK -HDfprintf(stderr, "%s: rec1 = {%a, %Hu}\n", "H5HF_huge_btree2_dir_compare", rec1->addr, rec1->len); -HDfprintf(stderr, "%s: rec2 = {%a, %Hu}\n", "H5HF_huge_btree2_dir_compare", rec2->addr, rec2->len); +HDfprintf(stderr, "%s: rec1 = {%a, %Hu}\n", "H5HF_huge_bt2_dir_compare", rec1->addr, rec1->len); +HDfprintf(stderr, "%s: rec2 = {%a, %Hu}\n", "H5HF_huge_bt2_dir_compare", rec2->addr, rec2->len); #endif /* QAK */ if(rec1->addr < rec2->addr) ret_value = -1; @@ -676,11 +840,11 @@ HDfprintf(stderr, "%s: rec2 = {%a, %Hu}\n", "H5HF_huge_btree2_dir_compare", rec2 ret_value = 0; FUNC_LEAVE_NOAPI(ret_value) -} /* H5HF_huge_btree2_dir_compare() */ +} /* H5HF_huge_bt2_dir_compare() */ /*------------------------------------------------------------------------- - * Function: H5HF_huge_btree2_dir_encode + * Function: H5HF_huge_bt2_dir_encode * * Purpose: Encode native information into raw form for storing on disk * @@ -693,22 +857,26 @@ HDfprintf(stderr, "%s: rec2 = {%a, %Hu}\n", "H5HF_huge_btree2_dir_compare", rec2 *------------------------------------------------------------------------- */ static herr_t -H5HF_huge_btree2_dir_encode(const H5F_t *f, uint8_t *raw, const void *_nrecord) +H5HF_huge_bt2_dir_encode(uint8_t *raw, const void *_nrecord, void *_ctx) { + H5HF_huge_bt2_ctx_t *ctx = (H5HF_huge_bt2_ctx_t *)_ctx; /* Callback context structure */ const H5HF_huge_bt2_dir_rec_t *nrecord = (const H5HF_huge_bt2_dir_rec_t *)_nrecord; - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_btree2_dir_encode) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_bt2_dir_encode) + + /* Sanity check */ + HDassert(ctx); /* Encode the record's fields */ - H5F_addr_encode(f, &raw, nrecord->addr); - H5F_ENCODE_LENGTH(f, raw, nrecord->len); + H5F_addr_encode_len(ctx->sizeof_addr, &raw, nrecord->addr); + H5F_ENCODE_LENGTH_LEN(raw, nrecord->len, ctx->sizeof_size); FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5HF_huge_btree2_dir_encode() */ +} /* H5HF_huge_bt2_dir_encode() */ /*------------------------------------------------------------------------- - * Function: H5HF_huge_btree2_dir_decode + * Function: H5HF_huge_bt2_dir_decode * * Purpose: Decode raw disk form of record into native form * @@ -721,22 +889,26 @@ H5HF_huge_btree2_dir_encode(const H5F_t *f, uint8_t *raw, const void *_nrecord) *------------------------------------------------------------------------- */ static herr_t -H5HF_huge_btree2_dir_decode(const H5F_t *f, const uint8_t *raw, void *_nrecord) +H5HF_huge_bt2_dir_decode(const uint8_t *raw, void *_nrecord, void *_ctx) { + H5HF_huge_bt2_ctx_t *ctx = (H5HF_huge_bt2_ctx_t *)_ctx; /* Callback context structure */ H5HF_huge_bt2_dir_rec_t *nrecord = (H5HF_huge_bt2_dir_rec_t *)_nrecord; - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_btree2_dir_decode) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_bt2_dir_decode) + + /* Sanity check */ + HDassert(ctx); /* Decode the record's fields */ - H5F_addr_decode(f, &raw, &nrecord->addr); - H5F_DECODE_LENGTH(f, raw, nrecord->len); + H5F_addr_decode_len(ctx->sizeof_addr, &raw, &nrecord->addr); + H5F_DECODE_LENGTH_LEN(raw, nrecord->len, ctx->sizeof_size); FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5HF_huge_btree2_dir_decode() */ +} /* H5HF_huge_bt2_dir_decode() */ /*------------------------------------------------------------------------- - * Function: H5HF_huge_btree2_dir_debug + * Function: H5HF_huge_bt2_dir_debug * * Purpose: Debug native form of record * @@ -749,19 +921,19 @@ H5HF_huge_btree2_dir_decode(const H5F_t *f, const uint8_t *raw, void *_nrecord) *------------------------------------------------------------------------- */ static herr_t -H5HF_huge_btree2_dir_debug(FILE *stream, const H5F_t UNUSED *f, hid_t UNUSED dxpl_id, +H5HF_huge_bt2_dir_debug(FILE *stream, const H5F_t UNUSED *f, hid_t UNUSED dxpl_id, int indent, int fwidth, const void *_nrecord, const void UNUSED *_udata) { const H5HF_huge_bt2_dir_rec_t *nrecord = (const H5HF_huge_bt2_dir_rec_t *)_nrecord; - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_btree2_dir_debug) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_bt2_dir_debug) HDfprintf(stream, "%*s%-*s {%a, %Hu}\n", indent, "", fwidth, "Record:", nrecord->addr, nrecord->len); FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5HF_huge_btree2_dir_debug() */ +} /* H5HF_huge_bt2_dir_debug() */ /*------------------------------------------------------------------------- @@ -831,7 +1003,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5HF_huge_btree2_filt_dir_store + * Function: H5HF_huge_bt2_filt_dir_store * * Purpose: Store native information into record for v2 B-tree * @@ -844,18 +1016,18 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5HF_huge_btree2_filt_dir_store(void *nrecord, const void *udata) +H5HF_huge_bt2_filt_dir_store(void *nrecord, const void *udata) { - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_btree2_filt_dir_store) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_bt2_filt_dir_store) *(H5HF_huge_bt2_filt_dir_rec_t *)nrecord = *(const H5HF_huge_bt2_filt_dir_rec_t *)udata; FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5HF_huge_btree2_filt_dir_store() */ +} /* H5HF_huge_bt2_filt_dir_store() */ /*------------------------------------------------------------------------- - * Function: H5HF_huge_btree2_filt_dir_compare + * Function: H5HF_huge_bt2_filt_dir_compare * * Purpose: Compare two native information records, according to some key * @@ -869,17 +1041,17 @@ H5HF_huge_btree2_filt_dir_store(void *nrecord, const void *udata) *------------------------------------------------------------------------- */ static herr_t -H5HF_huge_btree2_filt_dir_compare(const void *_rec1, const void *_rec2) +H5HF_huge_bt2_filt_dir_compare(const void *_rec1, const void *_rec2) { const H5HF_huge_bt2_filt_dir_rec_t *rec1 = (const H5HF_huge_bt2_filt_dir_rec_t *)_rec1; const H5HF_huge_bt2_filt_dir_rec_t *rec2 = (const H5HF_huge_bt2_filt_dir_rec_t *)_rec2; herr_t ret_value; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_btree2_filt_dir_compare) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_bt2_filt_dir_compare) #ifdef QAK -HDfprintf(stderr, "%s: rec1 = {%a, %Hu, %x, %Hu}\n", "H5HF_huge_btree2_filt_dir_compare", rec1->addr, rec1->len, rec1->filter_mask, rec1->obj_size); -HDfprintf(stderr, "%s: rec2 = {%a, %Hu, %x, %Hu}\n", "H5HF_huge_btree2_filt_dir_compare", rec2->addr, rec2->len, rec2->filter_mask, rec2->obj_size); +HDfprintf(stderr, "%s: rec1 = {%a, %Hu, %x, %Hu}\n", "H5HF_huge_bt2_filt_dir_compare", rec1->addr, rec1->len, rec1->filter_mask, rec1->obj_size); +HDfprintf(stderr, "%s: rec2 = {%a, %Hu, %x, %Hu}\n", "H5HF_huge_bt2_filt_dir_compare", rec2->addr, rec2->len, rec2->filter_mask, rec2->obj_size); #endif /* QAK */ if(rec1->addr < rec2->addr) ret_value = -1; @@ -893,11 +1065,11 @@ HDfprintf(stderr, "%s: rec2 = {%a, %Hu, %x, %Hu}\n", "H5HF_huge_btree2_filt_dir_ ret_value = 0; FUNC_LEAVE_NOAPI(ret_value) -} /* H5HF_huge_btree2_filt_dir_compare() */ +} /* H5HF_huge_bt2_filt_dir_compare() */ /*------------------------------------------------------------------------- - * Function: H5HF_huge_btree2_filt_dir_encode + * Function: H5HF_huge_bt2_filt_dir_encode * * Purpose: Encode native information into raw form for storing on disk * @@ -910,24 +1082,28 @@ HDfprintf(stderr, "%s: rec2 = {%a, %Hu, %x, %Hu}\n", "H5HF_huge_btree2_filt_dir_ *------------------------------------------------------------------------- */ static herr_t -H5HF_huge_btree2_filt_dir_encode(const H5F_t *f, uint8_t *raw, const void *_nrecord) +H5HF_huge_bt2_filt_dir_encode(uint8_t *raw, const void *_nrecord, void *_ctx) { + H5HF_huge_bt2_ctx_t *ctx = (H5HF_huge_bt2_ctx_t *)_ctx; /* Callback context structure */ const H5HF_huge_bt2_filt_dir_rec_t *nrecord = (const H5HF_huge_bt2_filt_dir_rec_t *)_nrecord; - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_btree2_filt_dir_encode) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_bt2_filt_dir_encode) + + /* Sanity check */ + HDassert(ctx); /* Encode the record's fields */ - H5F_addr_encode(f, &raw, nrecord->addr); - H5F_ENCODE_LENGTH(f, raw, nrecord->len); + H5F_addr_encode_len(ctx->sizeof_addr, &raw, nrecord->addr); + H5F_ENCODE_LENGTH_LEN(raw, nrecord->len, ctx->sizeof_size); UINT32ENCODE(raw, nrecord->filter_mask); - H5F_ENCODE_LENGTH(f, raw, nrecord->obj_size); + H5F_ENCODE_LENGTH_LEN(raw, nrecord->obj_size, ctx->sizeof_size); FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5HF_huge_btree2_filt_dir_encode() */ +} /* H5HF_huge_bt2_filt_dir_encode() */ /*------------------------------------------------------------------------- - * Function: H5HF_huge_btree2_filt_dir_decode + * Function: H5HF_huge_bt2_filt_dir_decode * * Purpose: Decode raw disk form of record into native form * @@ -940,24 +1116,28 @@ H5HF_huge_btree2_filt_dir_encode(const H5F_t *f, uint8_t *raw, const void *_nrec *------------------------------------------------------------------------- */ static herr_t -H5HF_huge_btree2_filt_dir_decode(const H5F_t *f, const uint8_t *raw, void *_nrecord) +H5HF_huge_bt2_filt_dir_decode(const uint8_t *raw, void *_nrecord, void *_ctx) { + H5HF_huge_bt2_ctx_t *ctx = (H5HF_huge_bt2_ctx_t *)_ctx; /* Callback context structure */ H5HF_huge_bt2_filt_dir_rec_t *nrecord = (H5HF_huge_bt2_filt_dir_rec_t *)_nrecord; - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_btree2_filt_dir_decode) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_bt2_filt_dir_decode) + + /* Sanity check */ + HDassert(ctx); /* Decode the record's fields */ - H5F_addr_decode(f, &raw, &nrecord->addr); - H5F_DECODE_LENGTH(f, raw, nrecord->len); + H5F_addr_decode_len(ctx->sizeof_addr, &raw, &nrecord->addr); + H5F_DECODE_LENGTH_LEN(raw, nrecord->len, ctx->sizeof_size); UINT32DECODE(raw, nrecord->filter_mask); - H5F_DECODE_LENGTH(f, raw, nrecord->obj_size); + H5F_DECODE_LENGTH_LEN(raw, nrecord->obj_size, ctx->sizeof_size); FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5HF_huge_btree2_filt_dir_decode() */ +} /* H5HF_huge_bt2_filt_dir_decode() */ /*------------------------------------------------------------------------- - * Function: H5HF_huge_btree2_filt_dir_debug + * Function: H5HF_huge_bt2_filt_dir_debug * * Purpose: Debug native form of record * @@ -970,16 +1150,16 @@ H5HF_huge_btree2_filt_dir_decode(const H5F_t *f, const uint8_t *raw, void *_nrec *------------------------------------------------------------------------- */ static herr_t -H5HF_huge_btree2_filt_dir_debug(FILE *stream, const H5F_t UNUSED *f, hid_t UNUSED dxpl_id, +H5HF_huge_bt2_filt_dir_debug(FILE *stream, const H5F_t UNUSED *f, hid_t UNUSED dxpl_id, int indent, int fwidth, const void *_nrecord, const void UNUSED *_udata) { const H5HF_huge_bt2_filt_dir_rec_t *nrecord = (const H5HF_huge_bt2_filt_dir_rec_t *)_nrecord; - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_btree2_filt_dir_debug) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_bt2_filt_dir_debug) HDfprintf(stream, "%*s%-*s {%a, %Hu, %x, %Hu}\n", indent, "", fwidth, "Record:", nrecord->addr, nrecord->len, nrecord->filter_mask, nrecord->obj_size); FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5HF_huge_btree2_filt_dir_debug() */ +} /* H5HF_huge_bt2_filt_dir_debug() */ diff --git a/src/H5HFhuge.c b/src/H5HFhuge.c index 353ceb3..5490c22 100644 --- a/src/H5HFhuge.c +++ b/src/H5HFhuge.c @@ -128,12 +128,12 @@ H5HF_huge_bt2_create(H5HF_hdr_t *hdr, hid_t dxpl_id) + hdr->sizeof_size /* Length of object */ + 4 /* Filter mask for filtered object */ + hdr->sizeof_size); /* Size of de-filtered object in memory */ - bt2_cparam.cls = H5HF_BT2_FILT_DIR; + bt2_cparam.cls = H5HF_HUGE_BT2_FILT_DIR; } /* end if */ else { bt2_cparam.rrec_size = (size_t)(hdr->sizeof_addr /* Address of object */ + hdr->sizeof_size); /* Length of object */ - bt2_cparam.cls = H5HF_BT2_DIR; + bt2_cparam.cls = H5HF_HUGE_BT2_DIR; } /* end else */ } /* end if */ else { @@ -143,13 +143,13 @@ H5HF_huge_bt2_create(H5HF_hdr_t *hdr, hid_t dxpl_id) + 4 /* Filter mask for filtered object */ + hdr->sizeof_size /* Size of de-filtered object in memory */ + hdr->sizeof_size); /* Unique ID for object */ - bt2_cparam.cls = H5HF_BT2_FILT_INDIR; + bt2_cparam.cls = H5HF_HUGE_BT2_FILT_INDIR; } /* end if */ else { bt2_cparam.rrec_size = (size_t)(hdr->sizeof_addr /* Address of object */ + hdr->sizeof_size /* Length of object */ + hdr->sizeof_size); /* Unique ID for object */ - bt2_cparam.cls = H5HF_BT2_INDIR; + bt2_cparam.cls = H5HF_HUGE_BT2_INDIR; } /* end else */ } /* end else */ bt2_cparam.node_size = (size_t)H5HF_HUGE_BT2_NODE_SIZE; @@ -157,7 +157,7 @@ H5HF_huge_bt2_create(H5HF_hdr_t *hdr, hid_t dxpl_id) bt2_cparam.merge_percent = H5HF_HUGE_BT2_MERGE_PERC; /* Create v2 B-tree for tracking 'huge' objects */ - if(NULL == (hdr->huge_bt2 = H5B2_create(hdr->f, dxpl_id, &bt2_cparam))) + if(NULL == (hdr->huge_bt2 = H5B2_create(hdr->f, dxpl_id, &bt2_cparam, hdr->f))) HGOTO_ERROR(H5E_HEAP, H5E_CANTCREATE, FAIL, "can't create v2 B-tree for tracking 'huge' heap objects") /* Retrieve the v2 B-tree's address in the file */ @@ -339,7 +339,7 @@ HDfprintf(stderr, "%s: obj_size = %Zu\n", FUNC, obj_size); /* Check if v2 B-tree is open yet */ if(NULL == hdr->huge_bt2) { /* Open existing v2 B-tree */ - if(NULL == (hdr->huge_bt2 = H5B2_open(hdr->f, dxpl_id, hdr->huge_bt2_addr))) + if(NULL == (hdr->huge_bt2 = H5B2_open(hdr->f, dxpl_id, hdr->huge_bt2_addr, hdr->f))) HGOTO_ERROR(H5E_HEAP, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for tracking 'huge' heap objects") } /* end if */ } /* end else */ @@ -545,7 +545,7 @@ H5HF_huge_get_obj_len(H5HF_hdr_t *hdr, hid_t dxpl_id, const uint8_t *id, /* Check if v2 B-tree is open yet */ if(NULL == hdr->huge_bt2) { /* Open existing v2 B-tree */ - if(NULL == (hdr->huge_bt2 = H5B2_open(hdr->f, dxpl_id, hdr->huge_bt2_addr))) + if(NULL == (hdr->huge_bt2 = H5B2_open(hdr->f, dxpl_id, hdr->huge_bt2_addr, hdr->f))) HGOTO_ERROR(H5E_HEAP, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for tracking 'huge' heap objects") } /* end if */ @@ -636,7 +636,7 @@ H5HF_huge_op_real(H5HF_hdr_t *hdr, hid_t dxpl_id, const uint8_t *id, /* Check if v2 B-tree is open yet */ if(NULL == hdr->huge_bt2) { /* Open existing v2 B-tree */ - if(NULL == (hdr->huge_bt2 = H5B2_open(hdr->f, dxpl_id, hdr->huge_bt2_addr))) + if(NULL == (hdr->huge_bt2 = H5B2_open(hdr->f, dxpl_id, hdr->huge_bt2_addr, hdr->f))) HGOTO_ERROR(H5E_HEAP, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for tracking 'huge' heap objects") } /* end if */ @@ -784,7 +784,7 @@ H5HF_huge_write(H5HF_hdr_t *hdr, hid_t dxpl_id, const uint8_t *id, /* Check if v2 B-tree is open yet */ if(NULL == hdr->huge_bt2) { /* Open existing v2 B-tree */ - if(NULL == (hdr->huge_bt2 = H5B2_open(hdr->f, dxpl_id, hdr->huge_bt2_addr))) + if(NULL == (hdr->huge_bt2 = H5B2_open(hdr->f, dxpl_id, hdr->huge_bt2_addr, hdr->f))) HGOTO_ERROR(H5E_HEAP, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for tracking 'huge' heap objects") } /* end if */ @@ -914,7 +914,7 @@ H5HF_huge_remove(H5HF_hdr_t *hdr, hid_t dxpl_id, const uint8_t *id) /* Check if v2 B-tree is open yet */ if(NULL == hdr->huge_bt2) { /* Open existing v2 B-tree */ - if(NULL == (hdr->huge_bt2 = H5B2_open(hdr->f, dxpl_id, hdr->huge_bt2_addr))) + if(NULL == (hdr->huge_bt2 = H5B2_open(hdr->f, dxpl_id, hdr->huge_bt2_addr, hdr->f))) HGOTO_ERROR(H5E_HEAP, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for tracking 'huge' heap objects") } /* end if */ @@ -1037,7 +1037,7 @@ H5HF_huge_term(H5HF_hdr_t *hdr, hid_t dxpl_id) /* Delete the v2 B-tree */ /* (any v2 B-tree class will work here) */ - if(H5B2_delete(hdr->f, dxpl_id, hdr->huge_bt2_addr, NULL, NULL) < 0) + if(H5B2_delete(hdr->f, dxpl_id, hdr->huge_bt2_addr, hdr->f, NULL, NULL) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDELETE, FAIL, "can't delete v2 B-tree") /* Reset the information about 'huge' objects in the file */ @@ -1105,7 +1105,7 @@ H5HF_huge_delete(H5HF_hdr_t *hdr, hid_t dxpl_id) } /* end else */ /* Delete the v2 B-tree */ - if(H5B2_delete(hdr->f, dxpl_id, hdr->huge_bt2_addr, op, &udata) < 0) + if(H5B2_delete(hdr->f, dxpl_id, hdr->huge_bt2_addr, hdr->f, op, &udata) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDELETE, FAIL, "can't delete v2 B-tree") done: diff --git a/src/H5HFpkg.h b/src/H5HFpkg.h index dac6d39..3c5567c 100644 --- a/src/H5HFpkg.h +++ b/src/H5HFpkg.h @@ -481,16 +481,16 @@ H5_DLLVAR const H5AC_class_t H5AC_FHEAP_IBLOCK[1]; H5_DLLVAR const H5AC_class_t H5AC_FHEAP_DBLOCK[1]; /* The v2 B-tree class for tracking indirectly accessed 'huge' objects */ -H5_DLLVAR const H5B2_class_t H5HF_BT2_INDIR[1]; +H5_DLLVAR const H5B2_class_t H5HF_HUGE_BT2_INDIR[1]; /* The v2 B-tree class for tracking indirectly accessed filtered 'huge' objects */ -H5_DLLVAR const H5B2_class_t H5HF_BT2_FILT_INDIR[1]; +H5_DLLVAR const H5B2_class_t H5HF_HUGE_BT2_FILT_INDIR[1]; /* The v2 B-tree class for tracking directly accessed 'huge' objects */ -H5_DLLVAR const H5B2_class_t H5HF_BT2_DIR[1]; +H5_DLLVAR const H5B2_class_t H5HF_HUGE_BT2_DIR[1]; /* The v2 B-tree class for tracking directly accessed filtered 'huge' objects */ -H5_DLLVAR const H5B2_class_t H5HF_BT2_FILT_DIR[1]; +H5_DLLVAR const H5B2_class_t H5HF_HUGE_BT2_FILT_DIR[1]; /* H5HF single section inherits serializable properties from H5FS_section_class_t */ H5_DLLVAR H5FS_section_class_t H5HF_FSPACE_SECT_CLS_SINGLE[1]; diff --git a/src/H5HFstat.c b/src/H5HFstat.c index fb535b9..2ab5240 100644 --- a/src/H5HFstat.c +++ b/src/H5HFstat.c @@ -155,7 +155,7 @@ H5HF_size(const H5HF_t *fh, hid_t dxpl_id, hsize_t *heap_size) /* Check for B-tree storage of huge objects in fractal heap */ if(H5F_addr_defined(hdr->huge_bt2_addr)) { /* Open the huge object index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(hdr->f, dxpl_id, hdr->huge_bt2_addr))) + if(NULL == (bt2 = H5B2_open(hdr->f, dxpl_id, hdr->huge_bt2_addr, hdr->f))) HGOTO_ERROR(H5E_HEAP, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for tracking 'huge' objects") /* Get the B-tree storage */ diff --git a/src/H5Lexternal.c b/src/H5Lexternal.c index 640ac07..b99012c 100644 --- a/src/H5Lexternal.c +++ b/src/H5Lexternal.c @@ -202,18 +202,14 @@ H5L_extern_traverse(const char UNUSED *link_name, hid_t cur_group, size_t fname_len; /* Length of external link file name */ unsigned intent; /* File access permissions */ H5L_elink_cb_t cb_info; /* Callback info struct */ - const char *parent_file_name = NULL; /* Parent file name */ - const char *parent_group_name = NULL; /* Parent group name */ hid_t fapl_id = -1; /* File access property list for external link's file */ hid_t ext_obj = -1; /* ID for external link's object */ - hid_t ret_value; /* Return value */ - - char *tempname=NULL, *ptr=NULL, *extpath=NULL; - char *env_prefix=NULL, *tmp_env_prefix=NULL; - char *out_prefix_name=NULL, *pp=NULL; - - H5P_genplist_t *fa_plist; /* File access property list pointer */ + char *temp_group_name = NULL;/* Temporary pointer to group name */ + char *temp_file_name = NULL; /* Temporary pointer to file name */ + char *actual_file_name = NULL; /* Parent file's actual name */ + H5P_genplist_t *fa_plist; /* File access property list pointer */ H5F_close_degree_t fc_degree = H5F_CLOSE_WEAK; /* File close degree for target file */ + hid_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5L_extern_traverse, FAIL) @@ -236,7 +232,7 @@ H5L_extern_traverse(const char UNUSED *link_name, hid_t cur_group, if(NULL == (plist = H5P_object_verify(lapl_id, H5P_LINK_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") - /* get the fapl_id set for lapl_id if any */ + /* Get the fapl_id set for lapl_id if any */ if(H5P_get(plist, H5L_ACS_ELINK_FAPL_NAME, &fapl_id) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fapl for links") @@ -266,8 +262,11 @@ H5L_extern_traverse(const char UNUSED *link_name, hid_t cur_group, /* Make callback if it exists */ if(cb_info.func) { + const char *parent_file_name; /* Parent file name */ + const char *parent_group_name; /* Parent group name */ + /* Get parent file name */ - parent_file_name = H5F_NAME(loc.oloc->file); + parent_file_name = H5F_OPEN_NAME(loc.oloc->file); /* Get parent group name */ if(loc.path->user_path_r != NULL && loc.path->obj_hidden == 0) @@ -285,20 +284,19 @@ H5L_extern_traverse(const char UNUSED *link_name, hid_t cur_group, group_name_len++; /* Copy parent group name */ - if(NULL == (tempname = (char *) H5MM_malloc((size_t) group_name_len))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - if(H5G_get_name(cur_group, tempname, (size_t) group_name_len, lapl_id, H5AC_ind_dxpl_id) < 0) + if(NULL == (temp_group_name = (char *)H5MM_malloc((size_t)group_name_len))) + HGOTO_ERROR(H5E_LINK, H5E_NOSPACE, FAIL, "memory allocation failed") + if(H5G_get_name(cur_group, temp_group_name, (size_t) group_name_len, lapl_id, H5AC_ind_dxpl_id) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "unable to retrieve group name") - parent_group_name = tempname; + parent_group_name = temp_group_name; } /* end else */ /* Make callback */ - if((cb_info.func)(parent_file_name, parent_group_name, file_name, obj_name, - &intent, fapl_id, cb_info.user_data) < 0) + if((cb_info.func)(parent_file_name, parent_group_name, file_name, obj_name, &intent, fapl_id, cb_info.user_data) < 0) HGOTO_ERROR(H5E_LINK, H5E_CALLBACK, FAIL, "traversal operator failed") - /* Free tempname */ - tempname = (char *)H5MM_xfree(tempname); + /* Free temp_group_name */ + temp_group_name = (char *)H5MM_xfree(temp_group_name); /* Check access flags */ if((intent & H5F_ACC_TRUNC) || (intent & H5F_ACC_EXCL)) @@ -312,88 +310,128 @@ H5L_extern_traverse(const char UNUSED *link_name, hid_t cur_group, /* * Start searching for the target file */ - if ((tempname=H5MM_strdup(file_name)) == NULL) + + /* Simplify intent flags for open calls */ + intent = ((intent & H5F_ACC_RDWR) ? H5F_ACC_RDWR : H5F_ACC_RDONLY); + + /* Copy the file name to use */ + if(NULL == (temp_file_name = H5MM_strdup(file_name))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* target file_name is an absolute pathname: see RM for detailed description */ - if (CHECK_ABSOLUTE(file_name) || CHECK_ABS_PATH(file_name)) { - if(NULL == (ext_file = H5F_open(file_name, ((intent & H5F_ACC_RDWR) ? H5F_ACC_RDWR : H5F_ACC_RDONLY), - H5P_FILE_CREATE_DEFAULT, fapl_id, H5AC_dxpl_id))) { + if(CHECK_ABSOLUTE(file_name) || CHECK_ABS_PATH(file_name)) { + /* Try opening file */ + if(NULL == (ext_file = H5F_open(file_name, intent, H5P_FILE_CREATE_DEFAULT, fapl_id, H5AC_dxpl_id))) { + char *ptr = NULL; + H5E_clear_stack(NULL); + /* get last component of file_name */ GET_LAST_DELIMITER(file_name, ptr) HDassert(ptr); - HDstrcpy(tempname, ++ptr); - } - } else if (CHECK_ABS_DRIVE(file_name)) { - if(NULL == (ext_file = H5F_open(file_name, ((intent & H5F_ACC_RDWR) ? H5F_ACC_RDWR : H5F_ACC_RDONLY), - H5P_FILE_CREATE_DEFAULT, fapl_id, H5AC_dxpl_id))) { + HDstrcpy(temp_file_name, ++ptr); + } /* end if */ + } /* end if */ + else if(CHECK_ABS_DRIVE(file_name)) { + if(NULL == (ext_file = H5F_open(file_name, intent, H5P_FILE_CREATE_DEFAULT, fapl_id, H5AC_dxpl_id))) { H5E_clear_stack(NULL); /* strip ":" */ - HDstrcpy(tempname, &file_name[2]); - } - } + HDstrcpy(temp_file_name, &file_name[2]); + } /* end if */ + } /* end if */ /* try searching from paths set in the environment variable */ - if ((ext_file == NULL) && (env_prefix=HDgetenv("HDF5_EXT_PREFIX"))) { - - if ((tmp_env_prefix = H5MM_strdup(env_prefix)) == NULL) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - pp = tmp_env_prefix; - - while ((tmp_env_prefix) && (*tmp_env_prefix)) { - out_prefix_name = H5L_getenv_prefix_name(&tmp_env_prefix/*in,out*/); - if ((out_prefix_name) && (*out_prefix_name)) { - - if (H5L_build_name(out_prefix_name, tempname, &full_name/*out*/) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't prepend prefix to filename") - - ext_file = H5F_open(full_name, ((intent & H5F_ACC_RDWR) ? H5F_ACC_RDWR : H5F_ACC_RDONLY), - H5P_FILE_CREATE_DEFAULT, fapl_id, H5AC_dxpl_id); - if (full_name) - H5MM_free(full_name); - if (ext_file != NULL) - break; - H5E_clear_stack(NULL); - } - } /* end while */ - pp = (char *)H5MM_xfree(pp); - } + if(ext_file == NULL) { + char *env_prefix; + + if(NULL != (env_prefix = HDgetenv("HDF5_EXT_PREFIX"))) { + char *tmp_env_prefix; + + if(NULL == (tmp_env_prefix = H5MM_strdup(env_prefix))) + HGOTO_ERROR(H5E_LINK, H5E_NOSPACE, FAIL, "memory allocation failed") + + while((tmp_env_prefix) && (*tmp_env_prefix)) { + char *out_prefix_name; + + out_prefix_name = H5L_getenv_prefix_name(&tmp_env_prefix/*in,out*/); + if(out_prefix_name && (*out_prefix_name)) { + if(H5L_build_name(out_prefix_name, temp_file_name, &full_name/*out*/) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't prepend prefix to filename") + + ext_file = H5F_open(full_name, intent, H5P_FILE_CREATE_DEFAULT, fapl_id, H5AC_dxpl_id); + full_name = (char *)H5MM_xfree(full_name); + if(ext_file != NULL) + break; + H5E_clear_stack(NULL); + } /* end if */ + } /* end while */ + } /* end if */ + } /* end if */ /* try searching from property list */ - if (ext_file == NULL) { + if(ext_file == NULL) { if(H5P_get(plist, H5L_ACS_ELINK_PREFIX_NAME, &my_prefix) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get external link prefix") - if (my_prefix) { - if (H5L_build_name(my_prefix, tempname, &full_name/*out*/) < 0) + if(my_prefix) { + if(H5L_build_name(my_prefix, temp_file_name, &full_name/*out*/) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't prepend prefix to filename") - if ((ext_file=H5F_open(full_name, ((intent & H5F_ACC_RDWR) ? H5F_ACC_RDWR : H5F_ACC_RDONLY), - H5P_FILE_CREATE_DEFAULT, fapl_id, H5AC_dxpl_id)) == NULL) + if(NULL == (ext_file = H5F_open(full_name, intent, H5P_FILE_CREATE_DEFAULT, fapl_id, H5AC_dxpl_id))) H5E_clear_stack(NULL); - if (full_name) - H5MM_free(full_name); - } - } + full_name = (char *)H5MM_xfree(full_name); + } /* end if */ + } /* end if */ + + /* try searching from main file's "extpath": see description in H5F_open() & H5_build_extpath() */ + if(ext_file == NULL) { + char *extpath; + + if(NULL != (extpath = H5F_EXTPATH(loc.oloc->file))) { + if(H5L_build_name(extpath, temp_file_name, &full_name/*out*/) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't prepend prefix to filename") + if(NULL == (ext_file = H5F_open(full_name, intent, H5P_FILE_CREATE_DEFAULT, fapl_id, H5AC_dxpl_id))) + H5E_clear_stack(NULL); + full_name = (char *)H5MM_xfree(full_name); + } /* end if */ + } /* end if */ - /* try searching from main file's "extpath":see description in H5F_open() & H5_build_extpath() */ - if ((ext_file == NULL) && (extpath=H5F_EXTPATH(loc.oloc->file))) { - if (H5L_build_name(extpath, tempname, &full_name/*out*/) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't prepend prefix to filename") - if ((ext_file = H5F_open(full_name, ((intent & H5F_ACC_RDWR) ? H5F_ACC_RDWR : H5F_ACC_RDONLY), - H5P_FILE_CREATE_DEFAULT, fapl_id, H5AC_dxpl_id)) == NULL) + /* try the relative file_name stored in temp_file_name */ + if(ext_file == NULL) { + if(NULL == (ext_file = H5F_open(temp_file_name, intent, H5P_FILE_CREATE_DEFAULT, fapl_id, H5AC_dxpl_id))) H5E_clear_stack(NULL); - if (full_name) - H5MM_free(full_name); - } + } /* end if */ - /* try the relative file_name stored in tempname */ - if (ext_file == NULL) { - if ((ext_file=H5F_open(tempname, ((intent & H5F_ACC_RDWR) ? H5F_ACC_RDWR : H5F_ACC_RDONLY), - H5P_FILE_CREATE_DEFAULT, fapl_id, H5AC_dxpl_id)) == NULL) - HGOTO_ERROR(H5E_LINK, H5E_CANTOPENFILE, FAIL, "unable to open external file") - } + /* try the 'resolved' name for the parent file (i.e. the name after symlinks + * were resolved) + */ + if(ext_file == NULL) { + char *ptr = NULL; + + /* Copy resolved file name */ + if(NULL == (actual_file_name = H5MM_strdup(H5F_ACTUAL_NAME(loc.oloc->file)))) + HGOTO_ERROR(H5E_LINK, H5E_CANTALLOC, FAIL, "can't duplicate resolved file name string") + + /* get last component of file_name */ + GET_LAST_DELIMITER(actual_file_name, ptr) + if(ptr) { + /* Truncate filename portion from actual file name path */ + *ptr = '\0'; + + /* Build new file name for the external file */ + if(H5L_build_name(actual_file_name, temp_file_name, &full_name/*out*/) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't prepend prefix to filename") + } /* end if */ + else { + /* Transfer ownership of actual file name to 'full_name' variable */ + full_name = actual_file_name; + actual_file_name = NULL; + } /* end else */ + + /* Try opening with the resolved name */ + if(NULL == (ext_file = H5F_open(full_name, intent, H5P_FILE_CREATE_DEFAULT, fapl_id, H5AC_dxpl_id))) + HGOTO_ERROR(H5E_LINK, H5E_CANTOPENFILE, FAIL, "unable to open external file, external link file name = '%s', temp_file_name = '%s'", file_name, temp_file_name) + full_name = (char *)H5MM_xfree(full_name); + } /* end if */ - tempname = (char *)H5MM_xfree(tempname); /* Increment the number of open objects, to hold the file open */ H5F_incr_nopen_objs(ext_file); @@ -425,11 +463,12 @@ done: HDONE_ERROR(H5E_ATOM, H5E_CANTRELEASE, FAIL, "unable to close atom for file access property list") if(ext_file && H5F_try_close(ext_file) < 0) HDONE_ERROR(H5E_LINK, H5E_CANTCLOSEFILE, FAIL, "problem closing external file") + full_name = (char *)H5MM_xfree(full_name); + temp_group_name = (char *)H5MM_xfree(temp_group_name); + temp_file_name = (char *)H5MM_xfree(temp_file_name); + actual_file_name = (char *)H5MM_xfree(actual_file_name); if(ret_value < 0) { - H5MM_xfree(tempname); - H5MM_xfree(pp); - /* Close object if it's open and something failed */ if(ext_obj >= 0 && H5I_dec_ref(ext_obj, FALSE) < 0) HDONE_ERROR(H5E_ATOM, H5E_CANTRELEASE, FAIL, "unable to close atom for external object") diff --git a/src/H5Oattribute.c b/src/H5Oattribute.c index c624ee1..67d0a92 100644 --- a/src/H5Oattribute.c +++ b/src/H5Oattribute.c @@ -1881,7 +1881,7 @@ H5O_attr_bh_info(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5_ih_info_t *bh_info) /* Check if name index available */ if(H5F_addr_defined(ainfo.name_bt2_addr)) { /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(f, dxpl_id, ainfo.name_bt2_addr))) + if(NULL == (bt2_name = H5B2_open(f, dxpl_id, ainfo.name_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Get name index B-tree size */ @@ -1892,7 +1892,7 @@ H5O_attr_bh_info(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5_ih_info_t *bh_info) /* Check if creation order index available */ if(H5F_addr_defined(ainfo.corder_bt2_addr)) { /* Open the creation order index v2 B-tree */ - if(NULL == (bt2_corder = H5B2_open(f, dxpl_id, ainfo.corder_bt2_addr))) + if(NULL == (bt2_corder = H5B2_open(f, dxpl_id, ainfo.corder_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for creation order index") /* Get creation order index B-tree size */ diff --git a/src/H5Otest.c b/src/H5Otest.c index 45ade3a..c7cd8a9 100644 --- a/src/H5Otest.c +++ b/src/H5Otest.c @@ -194,7 +194,7 @@ H5O_is_attr_empty_test(hid_t oid) HDassert(nattrs == 0); /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(oloc->file, H5AC_ind_dxpl_id, ainfo.name_bt2_addr))) + if(NULL == (bt2_name = H5B2_open(oloc->file, H5AC_ind_dxpl_id, ainfo.name_bt2_addr, NULL))) HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Retrieve # of records in name index */ @@ -281,7 +281,7 @@ H5O_num_attrs_test(hid_t oid, hsize_t *nattrs) HDassert(obj_nattrs == 0); /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(oloc->file, H5AC_ind_dxpl_id, ainfo.name_bt2_addr))) + if(NULL == (bt2_name = H5B2_open(oloc->file, H5AC_ind_dxpl_id, ainfo.name_bt2_addr, NULL))) HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Retrieve # of records in name index */ @@ -363,7 +363,7 @@ H5O_attr_dense_info_test(hid_t oid, hsize_t *name_count, hsize_t *corder_count) HGOTO_DONE(FAIL) /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(oloc->file, H5AC_ind_dxpl_id, ainfo.name_bt2_addr))) + if(NULL == (bt2_name = H5B2_open(oloc->file, H5AC_ind_dxpl_id, ainfo.name_bt2_addr, NULL))) HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Retrieve # of records in name index */ @@ -373,7 +373,7 @@ H5O_attr_dense_info_test(hid_t oid, hsize_t *name_count, hsize_t *corder_count) /* Check if there is a creation order index */ if(H5F_addr_defined(ainfo.corder_bt2_addr)) { /* Open the creation order index v2 B-tree */ - if(NULL == (bt2_corder = H5B2_open(oloc->file, H5AC_ind_dxpl_id, ainfo.corder_bt2_addr))) + if(NULL == (bt2_corder = H5B2_open(oloc->file, H5AC_ind_dxpl_id, ainfo.corder_bt2_addr, NULL))) HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for creation order index") /* Retrieve # of records in creation order index */ diff --git a/src/H5SM.c b/src/H5SM.c index 7a678cb..cbb063b 100755 --- a/src/H5SM.c +++ b/src/H5SM.c @@ -43,6 +43,7 @@ /******************/ /* Local Typedefs */ /******************/ + /* Udata struct for calls to H5SM_read_iter_op */ typedef struct H5SM_read_udata_t { H5F_t *file; /* File in which sharing is happening (in) */ @@ -475,7 +476,7 @@ H5SM_create_index(H5F_t *f, H5SM_index_header_t *header, hid_t dxpl_id) bt2_cparam.rrec_size = (size_t)H5SM_SOHM_ENTRY_SIZE(f); bt2_cparam.split_percent = H5SM_B2_SPLIT_PERCENT; bt2_cparam.merge_percent = H5SM_B2_MERGE_PERCENT; - if(NULL == (bt2 = H5B2_create(f, dxpl_id, &bt2_cparam))) + if(NULL == (bt2 = H5B2_create(f, dxpl_id, &bt2_cparam, f))) HGOTO_ERROR(H5E_SOHM, H5E_CANTCREATE, FAIL, "B-tree creation failed for SOHM index") /* Retrieve the v2 B-tree's address in the file */ @@ -575,7 +576,7 @@ H5SM_delete_index(H5F_t *f, H5SM_index_header_t *header, hid_t dxpl_id, HDassert(header->index_type == H5SM_BTREE); /* Delete the B-tree. */ - if(H5B2_delete(f, dxpl_id, header->index_addr, NULL, NULL) < 0) + if(H5B2_delete(f, dxpl_id, header->index_addr, f, NULL, NULL) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTDELETE, FAIL, "unable to delete B-tree") /* Revert to list unless B-trees can have zero records */ @@ -721,7 +722,7 @@ H5SM_convert_list_to_btree(H5F_t *f, H5SM_index_header_t *header, bt2_cparam.rrec_size = (size_t)H5SM_SOHM_ENTRY_SIZE(f); bt2_cparam.split_percent = H5SM_B2_SPLIT_PERCENT; bt2_cparam.merge_percent = H5SM_B2_MERGE_PERCENT; - if(NULL == (bt2 = H5B2_create(f, dxpl_id, &bt2_cparam))) + if(NULL == (bt2 = H5B2_create(f, dxpl_id, &bt2_cparam, f))) HGOTO_ERROR(H5E_SOHM, H5E_CANTCREATE, FAIL, "B-tree creation failed for SOHM index") /* Retrieve the v2 B-tree's address in the file */ @@ -828,7 +829,7 @@ H5SM_convert_btree_to_list(H5F_t * f, H5SM_index_header_t * header, hid_t dxpl_i /* Delete the B-tree and have messages copy themselves to the * list as they're deleted */ - if(H5B2_delete(f, dxpl_id, btree_addr, H5SM_btree_convert_to_list_op, list) < 0) + if(H5B2_delete(f, dxpl_id, btree_addr, f, H5SM_bt2_convert_to_list_op, list) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTDELETE, FAIL, "unable to delete B-tree") done: @@ -1250,7 +1251,7 @@ H5SM_write_mesg(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, HDassert(header->index_type == H5SM_BTREE); /* Open the index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, dxpl_id, header->index_addr))) + if(NULL == (bt2 = H5B2_open(f, dxpl_id, header->index_addr, f))) HGOTO_ERROR(H5E_SOHM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for SOHM index") /* Set up callback info */ @@ -1344,7 +1345,7 @@ H5SM_write_mesg(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, /* Open the index v2 B-tree, if it isn't already */ if(NULL == bt2) { - if(NULL == (bt2 = H5B2_open(f, dxpl_id, header->index_addr))) + if(NULL == (bt2 = H5B2_open(f, dxpl_id, header->index_addr, f))) HGOTO_ERROR(H5E_SOHM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for SOHM index") } /* end if */ @@ -1703,7 +1704,7 @@ H5SM_delete_from_index(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, HDassert(header->index_type == H5SM_BTREE); /* Open the index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, dxpl_id, header->index_addr))) + if(NULL == (bt2 = H5B2_open(f, dxpl_id, header->index_addr, f))) HGOTO_ERROR(H5E_SOHM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for SOHM index") /* If this returns failure, it means that the message wasn't found. @@ -1733,7 +1734,7 @@ H5SM_delete_from_index(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, else { /* Open the index v2 B-tree, if it isn't already */ if(NULL == bt2) { - if(NULL == (bt2 = H5B2_open(f, dxpl_id, header->index_addr))) + if(NULL == (bt2 = H5B2_open(f, dxpl_id, header->index_addr, f))) HGOTO_ERROR(H5E_SOHM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for SOHM index") } /* end if */ @@ -1909,86 +1910,6 @@ done: /*------------------------------------------------------------------------- - * Function: H5SM_message_encode - * - * Purpose: Serialize a H5SM_sohm_t struct into a buffer RAW. - * - * Return: Non-negative on success - * Negative on failure - * - * Programmer: James Laird - * Monday, November 6, 2006 - * - *------------------------------------------------------------------------- - */ -herr_t -H5SM_message_encode(const H5F_t *f, uint8_t *raw, const void *_nrecord) -{ - const H5SM_sohm_t *message = (const H5SM_sohm_t *)_nrecord; - - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SM_message_encode) - - *raw++ = message->location; - UINT32ENCODE(raw, message->hash); - - if(message->location == H5SM_IN_HEAP) { - UINT32ENCODE(raw, message->u.heap_loc.ref_count); - UINT64ENCODE(raw, message->u.heap_loc.fheap_id); - } /* end if */ - else { - HDassert(message->location == H5SM_IN_OH); - - *raw++ = 0; /* reserved (possible flags byte) */ - *raw++ = (uint8_t)message->msg_type_id; - UINT16ENCODE(raw, message->u.mesg_loc.index); - H5F_addr_encode(f, &raw, message->u.mesg_loc.oh_addr); - } /* end else */ - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5SM_message_encode */ - - -/*------------------------------------------------------------------------- - * Function: H5SM_message_decode - * - * Purpose: Read an encoded SOHM message from RAW into an H5SM_sohm_t struct. - * - * Return: Non-negative on success - * Negative on failure - * - * Programmer: James Laird - * Monday, November 6, 2006 - * - *------------------------------------------------------------------------- - */ -herr_t -H5SM_message_decode(const H5F_t UNUSED *f, const uint8_t *raw, void *_nrecord) -{ - H5SM_sohm_t *message = (H5SM_sohm_t *)_nrecord; - - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SM_message_decode) - - message->location = (H5SM_storage_loc_t)*raw++; - UINT32DECODE(raw, message->hash); - - if(message->location == H5SM_IN_HEAP) { - UINT32DECODE(raw, message->u.heap_loc.ref_count); - UINT64DECODE(raw, message->u.heap_loc.fheap_id); - } /* end if */ - else { - HDassert(message->location == H5SM_IN_OH); - - raw++; /* reserved */ - message->msg_type_id = *raw++; - UINT16DECODE(raw, message->u.mesg_loc.index); - H5F_addr_decode(f, &raw, &message->u.mesg_loc.oh_addr); - } /* end else */ - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5SM_message_decode */ - - -/*------------------------------------------------------------------------- * Function: H5SM_reconstitute * * Purpose: Reconstitute a shared object header message structure from @@ -2140,7 +2061,7 @@ H5SM_get_refcount(H5F_t *f, hid_t dxpl_id, unsigned type_id, HDassert(header->index_type == H5SM_BTREE); /* Open the index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, dxpl_id, header->index_addr))) + if(NULL == (bt2 = H5B2_open(f, dxpl_id, header->index_addr, f))) HGOTO_ERROR(H5E_SOHM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for SOHM index") /* Look up the message in the v2 B-tree */ @@ -2586,7 +2507,7 @@ H5SM_ih_size(H5F_t *f, hid_t dxpl_id, hsize_t *hdr_size, H5_ih_info_t *ih_info) if(table->indexes[u].index_type == H5SM_BTREE) { if(H5F_addr_defined(table->indexes[u].index_addr)) { /* Open the index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, dxpl_id, table->indexes[u].index_addr))) + if(NULL == (bt2 = H5B2_open(f, dxpl_id, table->indexes[u].index_addr, f))) HGOTO_ERROR(H5E_SOHM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for SOHM index") if(H5B2_size(bt2, dxpl_id, &(ih_info->index_size)) < 0) diff --git a/src/H5SMbtree2.c b/src/H5SMbtree2.c index 2be7745..95527f9 100755 --- a/src/H5SMbtree2.c +++ b/src/H5SMbtree2.c @@ -20,6 +20,7 @@ #define H5O_PACKAGE /*suppress error about including H5Opkg */ #define H5SM_PACKAGE /*suppress error about including H5SMpkg */ + /***********/ /* Headers */ /***********/ @@ -38,23 +39,18 @@ /* Local Typedefs */ /******************/ -/* Udata struct for calls to H5SM_btree_compare_cb and H5SM_compare_iter_op*/ -typedef struct H5SM_compare_udata_t { - const H5SM_mesg_key_t *key; /* Key; compare this against stored message */ - H5O_msg_crt_idx_t idx; /* Index of the message in the OH, if applicable */ - herr_t ret; /* Return value; set this to result of memcmp */ -} H5SM_compare_udata_t; - /********************/ /* Local Prototypes */ /********************/ /* v2 B-tree callbacks */ -static herr_t H5SM_btree_compare_cb(const void *obj, size_t obj_len, void *_udata); -static herr_t H5SM_btree_store(void *native, const void *udata); -static herr_t H5SM_btree_debug(FILE *stream, const H5F_t *f, hid_t dxpl_id, +static void *H5SM_bt2_crt_context(void *udata); +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, const H5F_t *f, hid_t dxpl_id, 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); /*****************************/ @@ -65,221 +61,99 @@ const H5B2_class_t H5SM_INDEX[1]={{ /* B-tree class information */ H5B2_SOHM_INDEX_ID, /* Type of B-tree */ "H5B2_SOHM_INDEX_ID", /* Name of B-tree class */ sizeof(H5SM_sohm_t), /* Size of native record */ - H5SM_btree_store, /* Record storage callback */ + H5SM_bt2_crt_context, /* Create client callback context */ + H5SM_bt2_dst_context, /* Destroy client callback context */ + H5SM_bt2_store, /* Record storage callback */ H5SM_message_compare, /* Record comparison callback */ H5SM_message_encode, /* Record encoding callback */ H5SM_message_decode, /* Record decoding callback */ - H5SM_btree_debug /* Record debugging callback */ + H5SM_bt2_debug, /* Record debugging callback */ + H5SM_bt2_crt_dbg_context, /* Create debugging context */ + H5SM_bt2_dst_context /* Destroy debugging context */ }}; + /*******************/ /* Local Variables */ /*******************/ +/* Declare a free list to manage the H5SM_bt2_ctx_t struct */ +H5FL_DEFINE_STATIC(H5SM_bt2_ctx_t); + + /*------------------------------------------------------------------------- - * Function: H5SM_btree_compare_cb - * - * Purpose: Callback for H5HF_op, used in H5SM_message_compare below. - * Determines whether the search key passed in in _UDATA is - * equal to OBJ or not. + * Function: H5SM_bt2_crt_context * - * Passes back the result in _UDATA->RET + * Purpose: Create client callback context * - * Return: Negative on error, non-negative on success + * Return: Success: non-NULL + * Failure: NULL * - * Programmer: James Laird - * Monday, January 8, 2007 + * Programmer: Quincey Koziol + * Thursday, November 26, 2009 * *------------------------------------------------------------------------- */ -static herr_t -H5SM_btree_compare_cb(const void *obj, size_t obj_len, void *_udata) +static void * +H5SM_bt2_crt_context(void *_f) { - H5SM_compare_udata_t *udata = (H5SM_compare_udata_t *)_udata; + H5F_t *f = (H5F_t *)_f; /* User data for building callback context */ + H5SM_bt2_ctx_t *ctx; /* Callback context structure */ + void *ret_value; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SM_btree_compare_cb) + FUNC_ENTER_NOAPI_NOINIT(H5SM_bt2_crt_context) - /* If the encoding sizes are different, it's not the same object */ - if(udata->key->encoding_size > obj_len) - udata->ret = 1; - else if(udata->key->encoding_size < obj_len) - udata->ret = -1; - else - /* Sizes are the same. Return result of memcmp */ - udata->ret = HDmemcmp(udata->key->encoding, obj, obj_len); + /* Sanity check */ + HDassert(f); - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5SM_btree_compare_cb() */ + /* Allocate callback context */ + if(NULL == (ctx = H5FL_MALLOC(H5SM_bt2_ctx_t))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "can't allocate callback context") - -/*------------------------------------------------------------------------- - * Function: H5SM_compare_iter_op - * - * Purpose: OH iteration callback to compare a key against a message in - * an OH - * - * Return: 0 if this is not the message we're searching for - * 1 if this is the message we're searching for (with memcmp - * result returned in udata) - * negative on error - * - * Programmer: James Laird - * Wednesday, February 7, 2007 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5SM_compare_iter_op(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, unsigned sequence, - hbool_t UNUSED *oh_modified, void *_udata/*in,out*/) -{ - H5SM_compare_udata_t *udata = (H5SM_compare_udata_t *) _udata; - herr_t ret_value = H5_ITER_CONT; - - FUNC_ENTER_NOAPI_NOINIT(H5SM_compare_iter_op) - - /* - * Check arguments. - */ - HDassert(oh); - HDassert(mesg); - HDassert(udata && udata->key); - - /* Check the creation index for this message */ - if(sequence == udata->idx) { - size_t aligned_encoded_size = H5O_ALIGN_OH(oh, udata->key->encoding_size); - - /* Sanity check the message's length */ - HDassert(mesg->raw_size > 0); - - if(aligned_encoded_size > mesg->raw_size) - udata->ret = 1; - else if(aligned_encoded_size < mesg->raw_size) - udata->ret = -1; - else { - /* Check if the message is dirty & flush it to the object header if so */ - if(mesg->dirty) - if(H5O_msg_flush(udata->key->file, oh, mesg) < 0) - HGOTO_ERROR(H5E_SOHM, H5E_CANTENCODE, H5_ITER_ERROR, "unable to encode object header message") - - HDassert(udata->key->encoding_size <= mesg->raw_size); - udata->ret = HDmemcmp(udata->key->encoding, mesg->raw, udata->key->encoding_size); - } /* end else */ - - /* Indicate that we found the message we were looking for */ - ret_value = H5_ITER_STOP; - } /* end if */ + /* 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) -} /* end H5SM_compare_iter_op() */ +} /* H5SM_bt2_crt_context() */ /*------------------------------------------------------------------------- - * Function: H5SM_message_compare + * Function: H5SM_bt2_dst_context * - * Purpose: Determine whether the search key rec1 represents a shared - * message that is equal to rec2 or not, and if not, whether - * rec1 is "greater than" or "less than" rec2. + * Purpose: Destroy client callback context * - * Return: 0 if rec1 == rec2 - * Negative if rec1 < rec2 - * Positive if rec1 > rec2 + * Return: Success: non-negative + * Failure: negative * - * Programmer: James Laird - * Monday, November 6, 2006 + * Programmer: Quincey Koziol + * Thursday, November 26, 2009 * *------------------------------------------------------------------------- */ -herr_t -H5SM_message_compare(const void *rec1, const void *rec2) +static herr_t +H5SM_bt2_dst_context(void *_ctx) { - const H5SM_mesg_key_t *key = (const H5SM_mesg_key_t *) rec1; - const H5SM_sohm_t *mesg = (const H5SM_sohm_t *) rec2; - herr_t ret_value = 0; - - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SM_message_compare) - - /* If the key has an fheap ID, we're looking for a message that's - * already in the index; if the fheap ID matches, we've found the message - * and can stop immediately. - * Likewise, if the message has an OH location that is matched by the - * message in the index, we've found the message. - */ - if(mesg->location == H5SM_IN_HEAP && key->message.location == H5SM_IN_HEAP) { - if(key->message.u.heap_loc.fheap_id == mesg->u.heap_loc.fheap_id) - HGOTO_DONE(0); - } /* end if */ - else if(mesg->location == H5SM_IN_OH && key->message.location == H5SM_IN_OH) { - if(key->message.u.mesg_loc.oh_addr == mesg->u.mesg_loc.oh_addr && - key->message.u.mesg_loc.index == mesg->u.mesg_loc.index && - key->message.msg_type_id == mesg->msg_type_id) - HGOTO_DONE(0); - } /* end if */ - - /* Compare hash values */ - if(key->message.hash > mesg->hash) - ret_value = 1; - else if(key->message.hash < mesg->hash) - ret_value = -1; - /* If the hash values match, make sure the messages are really the same */ - else { - /* Hash values match; compare the encoded message with the one in - * the index. - */ - H5SM_compare_udata_t udata; - herr_t status; - - HDassert(key->message.hash == mesg->hash); - HDassert(key->encoding_size > 0 && key->encoding); - - /* Set up user data for callback */ - udata.key = key; - - /* Compare the encoded message with either the message in the heap or - * the message in an object header. - */ - if(mesg->location == H5SM_IN_HEAP) { - /* Call heap op routine with comparison callback */ - status = H5HF_op(key->fheap, key->dxpl_id, &(mesg->u.heap_loc.fheap_id), H5SM_btree_compare_cb, &udata); - HDassert(status >= 0); - } /* end if */ - else { - H5O_loc_t oloc; /* Object owning the message */ - H5O_mesg_operator_t op; /* Message operator */ - - /* Sanity checks */ - HDassert(key->file); - HDassert(mesg->location == H5SM_IN_OH); - - /* Reset the object location */ - status = H5O_loc_reset(&oloc); - HDassert(status >= 0); - - /* Set up object location */ - oloc.file = key->file; - oloc.addr = mesg->u.mesg_loc.oh_addr; - - /* Finish setting up user data for iterator */ - udata.idx = mesg->u.mesg_loc.index; - - /* Locate the right message and compare with it */ - op.op_type = H5O_MESG_OP_LIB; - op.u.lib_op = H5SM_compare_iter_op; - status = H5O_msg_iterate(&oloc, mesg->msg_type_id, &op, &udata, key->dxpl_id); - HDassert(status >= 0); - } /* end else */ - - ret_value = udata.ret; - } /* end if */ + H5SM_bt2_ctx_t *ctx = (H5SM_bt2_ctx_t *)_ctx; /* Callback context structure */ -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5SM_message_compare */ + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SM_bt2_dst_context) + + /* Sanity check */ + HDassert(ctx); + + /* Release callback context */ + ctx = H5FL_FREE(H5SM_bt2_ctx_t, ctx); + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* H5SM_bt2_dst_context() */ /*------------------------------------------------------------------------- - * Function: H5SM_btree_store + * Function: H5SM_bt2_store * * Purpose: Store a H5SM_sohm_t SOHM message in the B-tree. The message * comes in UDATA as a H5SM_mesg_key_t* and is copied to @@ -294,21 +168,21 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5SM_btree_store(void *native, const void *udata) +H5SM_bt2_store(void *native, const void *udata) { const H5SM_mesg_key_t *key = (const H5SM_mesg_key_t *)udata; - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SM_btree_store) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SM_bt2_store) /* Copy the source message to the B-tree */ *(H5SM_sohm_t *)native = key->message; FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5SM_btree_store */ +} /* end H5SM_bt2_store */ /*------------------------------------------------------------------------- - * Function: H5SM_btree_debug + * Function: H5SM_bt2_debug * * Purpose: Print debugging information for a H5SM_sohm_t. * @@ -321,12 +195,12 @@ H5SM_btree_store(void *native, const void *udata) *------------------------------------------------------------------------- */ static herr_t -H5SM_btree_debug(FILE *stream, const H5F_t UNUSED *f, hid_t UNUSED dxpl_id, +H5SM_bt2_debug(FILE *stream, const H5F_t UNUSED *f, hid_t UNUSED dxpl_id, int indent, int fwidth, const void *record, const void UNUSED *_udata) { const H5SM_sohm_t *sohm = (const H5SM_sohm_t *)record; - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SM_btree_debug) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SM_bt2_debug) if(sohm->location == H5SM_IN_HEAP) HDfprintf(stream, "%*s%-*s {%a, %lo, %Hx}\n", indent, "", fwidth, @@ -340,11 +214,51 @@ H5SM_btree_debug(FILE *stream, const H5F_t UNUSED *f, hid_t UNUSED dxpl_id, } /* end else */ FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5SM_btree_debug */ +} /* end H5SM_bt2_debug */ + + +/*------------------------------------------------------------------------- + * 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 UNUSED dxpl_id, haddr_t UNUSED addr) +{ + H5SM_bt2_ctx_t *ctx; /* Callback context structure */ + void *ret_value; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5SM_bt2_crt_dbg_context) + + /* Sanity check */ + HDassert(f); + HDassert(H5F_addr_defined(addr)); + + /* 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_btree_convert_to_list_op + * Function: H5SM_bt2_convert_to_list_op * * Purpose: An H5B2_remove_t callback function to convert a SOHM * B-tree index to a list. @@ -360,13 +274,13 @@ H5SM_btree_debug(FILE *stream, const H5F_t UNUSED *f, hid_t UNUSED dxpl_id, *------------------------------------------------------------------------- */ herr_t -H5SM_btree_convert_to_list_op(const void * record, void *op_data) +H5SM_bt2_convert_to_list_op(const void * record, void *op_data) { const H5SM_sohm_t *message = (const H5SM_sohm_t *)record; const H5SM_list_t *list = (const H5SM_list_t *)op_data; size_t mesg_idx; /* Index of message to modify */ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SM_btree_convert_to_list_op) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SM_bt2_convert_to_list_op) /* Sanity checks */ HDassert(record); @@ -382,5 +296,5 @@ H5SM_btree_convert_to_list_op(const void * record, void *op_data) HDmemcpy(&(list->messages[mesg_idx]), message, sizeof(H5SM_sohm_t)); FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5SM_btree_convert_to_list_op() */ +} /* end H5SM_bt2_convert_to_list_op() */ diff --git a/src/H5SMcache.c b/src/H5SMcache.c index 9048b9f..1380e71 100644 --- a/src/H5SMcache.c +++ b/src/H5SMcache.c @@ -462,6 +462,7 @@ H5SM_list_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED *udata1, { H5SM_list_t *list; /* The SOHM list being read in */ H5SM_index_header_t *header = (H5SM_index_header_t *) udata2; /* Index header for this list */ + H5SM_bt2_ctx_t ctx; /* Message encoding context */ size_t size; /* Size of SOHM list on disk */ H5WB_t *wb = NULL; /* Wrapped buffer for list index data */ uint8_t lst_buf[H5SM_LST_BUF_SIZE]; /* Buffer for list index */ @@ -512,8 +513,9 @@ H5SM_list_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED *udata1, p += H5_SIZEOF_MAGIC; /* Read messages into the list array */ + ctx.sizeof_addr = H5F_SIZEOF_ADDR(f); for(x = 0; x < header->num_messages; x++) { - if(H5SM_message_decode(f, p, &(list->messages[x])) < 0) + if(H5SM_message_decode(p, &(list->messages[x]), &ctx) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTLOAD, NULL, "can't decode shared message") p += H5SM_SOHM_ENTRY_SIZE(f); } /* end for */ @@ -580,6 +582,7 @@ H5SM_list_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5SM_lis HDassert(list->header); if(list->cache_info.is_dirty) { + H5SM_bt2_ctx_t ctx; /* Message encoding context */ uint8_t *buf; /* Temporary buffer */ uint8_t *p; /* Pointer into raw data buffer */ size_t size; /* Header size on disk */ @@ -606,9 +609,10 @@ H5SM_list_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5SM_lis /* Write messages from the messages array to disk */ mesgs_written = 0; + ctx.sizeof_addr = H5F_SIZEOF_ADDR(f); for(x = 0; x < list->header->list_max && mesgs_written < list->header->num_messages; x++) { if(list->messages[x].location != H5SM_NO_LOC) { - if(H5SM_message_encode(f, p, &(list->messages[x])) < 0) + if(H5SM_message_encode(p, &(list->messages[x]), &ctx) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTFLUSH, FAIL, "unable to write shared message to disk") p+=H5SM_SOHM_ENTRY_SIZE(f); diff --git a/src/H5SMmessage.c b/src/H5SMmessage.c new file mode 100644 index 0000000..9a214ea --- /dev/null +++ b/src/H5SMmessage.c @@ -0,0 +1,358 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/****************/ +/* Module Setup */ +/****************/ + +#define H5O_PACKAGE /*suppress error about including H5Opkg */ +#define H5SM_PACKAGE /*suppress error about including H5SMpkg */ + + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Opkg.h" /* Object Headers */ +#include "H5SMpkg.h" /* Shared object header messages */ + + +/****************/ +/* Local Macros */ +/****************/ + + +/******************/ +/* Local Typedefs */ +/******************/ + +/* Udata struct for calls to H5SM_compare_cb and H5SM_compare_iter_op*/ +typedef struct H5SM_compare_udata_t { + const H5SM_mesg_key_t *key; /* Key; compare this against stored message */ + H5O_msg_crt_idx_t idx; /* Index of the message in the OH, if applicable */ + herr_t ret; /* Return value; set this to result of memcmp */ +} H5SM_compare_udata_t; + + +/********************/ +/* Local Prototypes */ +/********************/ +static herr_t H5SM_compare_cb(const void *obj, size_t obj_len, void *udata); +static herr_t H5SM_compare_iter_op(H5O_t *oh, H5O_mesg_t *mesg, unsigned sequence, + hbool_t *oh_modified, void *udata); + + +/*********************/ +/* Package Variables */ +/*********************/ + + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + + +/*******************/ +/* Local Variables */ +/*******************/ + + + +/*------------------------------------------------------------------------- + * Function: H5SM_compare_cb + * + * Purpose: Callback for H5HF_op, used in H5SM_message_compare below. + * Determines whether the search key passed in in _UDATA is + * equal to OBJ or not. + * + * Passes back the result in _UDATA->RET + * + * Return: Negative on error, non-negative on success + * + * Programmer: James Laird + * Monday, January 8, 2007 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5SM_compare_cb(const void *obj, size_t obj_len, void *_udata) +{ + H5SM_compare_udata_t *udata = (H5SM_compare_udata_t *)_udata; + + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SM_compare_cb) + + /* If the encoding sizes are different, it's not the same object */ + if(udata->key->encoding_size > obj_len) + udata->ret = 1; + else if(udata->key->encoding_size < obj_len) + udata->ret = -1; + else + /* Sizes are the same. Return result of memcmp */ + udata->ret = HDmemcmp(udata->key->encoding, obj, obj_len); + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5SM_compare_cb() */ + + +/*------------------------------------------------------------------------- + * Function: H5SM_compare_iter_op + * + * Purpose: OH iteration callback to compare a key against a message in + * an OH + * + * Return: 0 if this is not the message we're searching for + * 1 if this is the message we're searching for (with memcmp + * result returned in udata) + * negative on error + * + * Programmer: James Laird + * Wednesday, February 7, 2007 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5SM_compare_iter_op(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, unsigned sequence, + hbool_t UNUSED *oh_modified, void *_udata/*in,out*/) +{ + H5SM_compare_udata_t *udata = (H5SM_compare_udata_t *) _udata; + herr_t ret_value = H5_ITER_CONT; + + FUNC_ENTER_NOAPI_NOINIT(H5SM_compare_iter_op) + + /* + * Check arguments. + */ + HDassert(oh); + HDassert(mesg); + HDassert(udata && udata->key); + + /* Check the creation index for this message */ + if(sequence == udata->idx) { + size_t aligned_encoded_size = H5O_ALIGN_OH(oh, udata->key->encoding_size); + + /* Sanity check the message's length */ + HDassert(mesg->raw_size > 0); + + if(aligned_encoded_size > mesg->raw_size) + udata->ret = 1; + else if(aligned_encoded_size < mesg->raw_size) + udata->ret = -1; + else { + /* Check if the message is dirty & flush it to the object header if so */ + if(mesg->dirty) + if(H5O_msg_flush(udata->key->file, oh, mesg) < 0) + HGOTO_ERROR(H5E_SOHM, H5E_CANTENCODE, H5_ITER_ERROR, "unable to encode object header message") + + HDassert(udata->key->encoding_size <= mesg->raw_size); + udata->ret = HDmemcmp(udata->key->encoding, mesg->raw, udata->key->encoding_size); + } /* end else */ + + /* Indicate that we found the message we were looking for */ + ret_value = H5_ITER_STOP; + } /* end if */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5SM_compare_iter_op() */ + + +/*------------------------------------------------------------------------- + * Function: H5SM_message_compare + * + * Purpose: Determine whether the search key rec1 represents a shared + * message that is equal to rec2 or not, and if not, whether + * rec1 is "greater than" or "less than" rec2. + * + * Return: 0 if rec1 == rec2 + * Negative if rec1 < rec2 + * Positive if rec1 > rec2 + * + * Programmer: James Laird + * Monday, November 6, 2006 + * + *------------------------------------------------------------------------- + */ +herr_t +H5SM_message_compare(const void *rec1, const void *rec2) +{ + const H5SM_mesg_key_t *key = (const H5SM_mesg_key_t *) rec1; + const H5SM_sohm_t *mesg = (const H5SM_sohm_t *) rec2; + herr_t ret_value = 0; + + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SM_message_compare) + + /* If the key has an fheap ID, we're looking for a message that's + * already in the index; if the fheap ID matches, we've found the message + * and can stop immediately. + * Likewise, if the message has an OH location that is matched by the + * message in the index, we've found the message. + */ + if(mesg->location == H5SM_IN_HEAP && key->message.location == H5SM_IN_HEAP) { + if(key->message.u.heap_loc.fheap_id == mesg->u.heap_loc.fheap_id) + HGOTO_DONE(0); + } /* end if */ + else if(mesg->location == H5SM_IN_OH && key->message.location == H5SM_IN_OH) { + if(key->message.u.mesg_loc.oh_addr == mesg->u.mesg_loc.oh_addr && + key->message.u.mesg_loc.index == mesg->u.mesg_loc.index && + key->message.msg_type_id == mesg->msg_type_id) + HGOTO_DONE(0); + } /* end if */ + + /* Compare hash values */ + if(key->message.hash > mesg->hash) + ret_value = 1; + else if(key->message.hash < mesg->hash) + ret_value = -1; + /* If the hash values match, make sure the messages are really the same */ + else { + /* Hash values match; compare the encoded message with the one in + * the index. + */ + H5SM_compare_udata_t udata; + herr_t status; + + HDassert(key->message.hash == mesg->hash); + HDassert(key->encoding_size > 0 && key->encoding); + + /* Set up user data for callback */ + udata.key = key; + + /* Compare the encoded message with either the message in the heap or + * the message in an object header. + */ + if(mesg->location == H5SM_IN_HEAP) { + /* Call heap op routine with comparison callback */ + status = H5HF_op(key->fheap, key->dxpl_id, &(mesg->u.heap_loc.fheap_id), H5SM_compare_cb, &udata); + HDassert(status >= 0); + } /* end if */ + else { + H5O_loc_t oloc; /* Object owning the message */ + H5O_mesg_operator_t op; /* Message operator */ + + /* Sanity checks */ + HDassert(key->file); + HDassert(mesg->location == H5SM_IN_OH); + + /* Reset the object location */ + status = H5O_loc_reset(&oloc); + HDassert(status >= 0); + + /* Set up object location */ + oloc.file = key->file; + oloc.addr = mesg->u.mesg_loc.oh_addr; + + /* Finish setting up user data for iterator */ + udata.idx = mesg->u.mesg_loc.index; + + /* Locate the right message and compare with it */ + op.op_type = H5O_MESG_OP_LIB; + op.u.lib_op = H5SM_compare_iter_op; + status = H5O_msg_iterate(&oloc, mesg->msg_type_id, &op, &udata, key->dxpl_id); + HDassert(status >= 0); + } /* end else */ + + ret_value = udata.ret; + } /* end if */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5SM_message_compare */ + + +/*------------------------------------------------------------------------- + * Function: H5SM_message_encode + * + * Purpose: Serialize a H5SM_sohm_t struct into a buffer RAW. + * + * Return: Non-negative on success + * Negative on failure + * + * Programmer: James Laird + * Monday, November 6, 2006 + * + *------------------------------------------------------------------------- + */ +herr_t +H5SM_message_encode(uint8_t *raw, const void *_nrecord, void *_ctx) +{ + H5SM_bt2_ctx_t *ctx = (H5SM_bt2_ctx_t *)_ctx; /* Callback context structure */ + const H5SM_sohm_t *message = (const H5SM_sohm_t *)_nrecord; + + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SM_message_encode) + + /* Sanity check */ + HDassert(ctx); + + *raw++ = message->location; + UINT32ENCODE(raw, message->hash); + + if(message->location == H5SM_IN_HEAP) { + UINT32ENCODE(raw, message->u.heap_loc.ref_count); + UINT64ENCODE(raw, message->u.heap_loc.fheap_id); + } /* end if */ + else { + HDassert(message->location == H5SM_IN_OH); + + *raw++ = 0; /* reserved (possible flags byte) */ + *raw++ = (uint8_t)message->msg_type_id; + UINT16ENCODE(raw, message->u.mesg_loc.index); + H5F_addr_encode_len(ctx->sizeof_addr, &raw, message->u.mesg_loc.oh_addr); + } /* end else */ + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5SM_message_encode */ + + +/*------------------------------------------------------------------------- + * Function: H5SM_message_decode + * + * Purpose: Read an encoded SOHM message from RAW into an H5SM_sohm_t struct. + * + * Return: Non-negative on success + * Negative on failure + * + * Programmer: James Laird + * Monday, November 6, 2006 + * + *------------------------------------------------------------------------- + */ +herr_t +H5SM_message_decode(const uint8_t *raw, void *_nrecord, void *_ctx) +{ + H5SM_bt2_ctx_t *ctx = (H5SM_bt2_ctx_t *)_ctx; /* Callback context structure */ + H5SM_sohm_t *message = (H5SM_sohm_t *)_nrecord; + + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SM_message_decode) + + message->location = (H5SM_storage_loc_t)*raw++; + UINT32DECODE(raw, message->hash); + + if(message->location == H5SM_IN_HEAP) { + UINT32DECODE(raw, message->u.heap_loc.ref_count); + UINT64DECODE(raw, message->u.heap_loc.fheap_id); + } /* end if */ + else { + HDassert(message->location == H5SM_IN_OH); + + raw++; /* reserved */ + message->msg_type_id = *raw++; + UINT16DECODE(raw, message->u.mesg_loc.index); + H5F_addr_decode_len(ctx->sizeof_addr, &raw, &message->u.mesg_loc.oh_addr); + } /* end else */ + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5SM_message_decode */ + diff --git a/src/H5SMpkg.h b/src/H5SMpkg.h index 093fb04..64f0ccb 100755 --- a/src/H5SMpkg.h +++ b/src/H5SMpkg.h @@ -213,6 +213,11 @@ typedef struct { hid_t dxpl_id; } H5SM_incr_ref_opdata; +/* v2 B-tree client callback context */ +typedef struct H5SM_bt2_ctx_t { + uint8_t sizeof_addr; /* Size of file addresses */ +} H5SM_bt2_ctx_t; + /****************************/ /* Package Variables */ @@ -236,20 +241,12 @@ H5_DLLVAR const H5B2_class_t H5SM_INDEX[1]; H5_DLL ssize_t H5SM_get_index(const H5SM_master_table_t *table, unsigned type_id); /* Encode and decode routines, used for B-tree and cache encoding/decoding */ -H5_DLL herr_t H5SM_message_encode(const H5F_t *f, uint8_t *raw, - const void *native); -H5_DLL herr_t H5SM_message_decode(const H5F_t *f, const uint8_t *raw, - void *native); - -/* Callbacks to give to B-tree traversals */ -/* H5SM_message_compare is in H5SMbtree2.c, but is also used by list code - * in H5SM.c. - */ -H5_DLL herr_t H5SM_message_compare(const void *rec1, - const void *rec2); +H5_DLL herr_t H5SM_message_compare(const void *rec1, const void *rec2); +H5_DLL herr_t H5SM_message_encode(uint8_t *raw, const void *native, void *ctx); +H5_DLL herr_t H5SM_message_decode(const uint8_t *raw, void *native, void *ctx); /* H5B2_remove_t callback to add messages to a list index */ -H5_DLL herr_t H5SM_btree_convert_to_list_op(const void * record, void *op_data); +H5_DLL herr_t H5SM_bt2_convert_to_list_op(const void * record, void *op_data); /* Fractal heap 'op' callback to compute hash value for message "in place" */ H5_DLL herr_t H5SM_get_hash_fh_cb(const void *obj, size_t obj_len, void *_udata); diff --git a/src/H5config.h.in b/src/H5config.h.in index bb03fc7..bdc8ed4 100644 --- a/src/H5config.h.in +++ b/src/H5config.h.in @@ -220,6 +220,9 @@ /* Define to 1 if you have the `lseek64' function. */ #undef HAVE_LSEEK64 +/* Define to 1 if you have the `lstat' function. */ +#undef HAVE_LSTAT + /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H @@ -256,9 +259,6 @@ /* Define to 1 if you have the `setsysinfo' function. */ #undef HAVE_SETSYSINFO -/* Define to 1 if you have the `sigaction' function. */ -#undef HAVE_SIGACTION - /* Define to 1 if you have the `siglongjmp' function. */ #undef HAVE_SIGLONGJMP @@ -307,6 +307,9 @@ /* Define if `struct videoconfig' is defined */ #undef HAVE_STRUCT_VIDEOCONFIG +/* Define to 1 if you have the `symlink' function. */ +#undef HAVE_SYMLINK + /* Define to 1 if you have the `system' function. */ #undef HAVE_SYSTEM diff --git a/src/H5private.h b/src/H5private.h index 65800fc..8f56db0 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -730,11 +730,14 @@ H5_DLL int HDfprintf (FILE *stream, const char *fmt, ...); * For Unix, if off_t is not 64bit big, try use the pseudo-standard * xxx64 versions if available. */ -#if !defined(HDfstat) || !defined(HDstat) +#if !defined(HDfstat) || !defined(HDstat) || !defined(HDlstat) #if H5_SIZEOF_OFF_T!=8 && H5_SIZEOF_OFF64_T==8 && defined(H5_HAVE_STAT64) #ifndef HDfstat #define HDfstat(F,B) fstat64(F,B) #endif /* HDfstat */ + #ifndef HDlstat + #define HDlstat(S,B) lstat64(S,B) + #endif /* HDlstat */ #ifndef HDstat #define HDstat(S,B) stat64(S,B) #endif /* HDstat */ @@ -745,6 +748,9 @@ H5_DLL int HDfprintf (FILE *stream, const char *fmt, ...); #ifndef HDfstat #define HDfstat(F,B) fstat(F,B) #endif /* HDfstat */ + #ifndef HDlstat + #define HDlstat(S,B) lstat(S,B) + #endif /* HDlstat */ #ifndef HDstat #define HDstat(S,B) stat(S,B) #endif /* HDstat */ @@ -1027,6 +1033,9 @@ H5_DLL int HDfprintf (FILE *stream, const char *fmt, ...); #ifndef HDrealloc #define HDrealloc(M,Z) realloc(M,Z) #endif /* HDrealloc */ +#ifndef HDrealpath + #define HDrealpath(F1,F2) realpath(F1,F2) +#endif /* HDrealloc */ #ifdef H5_VMS #ifdef __cplusplus extern "C" { @@ -1080,9 +1089,6 @@ H5_DLL int HDfprintf (FILE *stream, const char *fmt, ...); #ifndef HDsetvbuf #define HDsetvbuf(F,S,M,Z) setvbuf(F,S,M,Z) #endif /* HDsetvbuf */ -#ifndef HDsigaction - #define HDsigaction(N,A) sigaction(N,A) -#endif /* HDsigaction */ #ifndef HDsigaddset #define HDsigaddset(S,N) sigaddset(S,N) #endif /* HDsigaddset */ @@ -1224,6 +1230,11 @@ H5_DLL int64_t HDstrtoll (const char *s, const char **rest, int base); #ifndef HDstrxfrm #define HDstrxfrm(X,Y,Z) strxfrm(X,Y,Z) #endif /* HDstrxfrm */ +#ifdef H5_HAVE_SYMLINK + #ifndef HDsymlink + #define HDsymlink(F1,F2) symlink(F1,F2) + #endif /* HDsymlink */ +#endif /* H5_HAVE_SYMLINK */ #ifndef HDsysconf #define HDsysconf(N) sysconf(N) #endif /* HDsysconf */ @@ -1478,7 +1489,6 @@ extern char *strdup(const char *s); #endif #define COLON_SEPC ':' -H5_DLL herr_t H5_build_extpath(const char *, char ** /*out*/ ); /* @@ -2285,6 +2295,9 @@ H5_DLL uint32_t H5_checksum_lookup3(const void *data, size_t len, uint32_t initv H5_DLL uint32_t H5_checksum_metadata(const void *data, size_t len, uint32_t initval); H5_DLL uint32_t H5_hash_string(const char *str); +/* Functions for building paths, etc. */ +H5_DLL herr_t H5_build_extpath(const char *, char ** /*out*/ ); + /* Functions for debugging */ H5_DLL herr_t H5_buffer_dump(FILE *stream, int indent, uint8_t *buf, uint8_t *marker, size_t buf_offset, size_t buf_size); diff --git a/src/H5public.h b/src/H5public.h index 9422968..7a9c948 100644 --- a/src/H5public.h +++ b/src/H5public.h @@ -71,10 +71,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 51 /* For tweaks, bug-fixes, or development */ +#define H5_VERS_RELEASE 52 /* For tweaks, bug-fixes, or development */ #define H5_VERS_SUBRELEASE "FA_a4" /* For pre-releases like snap0 */ /* Empty string for real releases. */ -#define H5_VERS_INFO "HDF5 library version: 1.9.51-FA_a4" /* Full version string */ +#define H5_VERS_INFO "HDF5 library version: 1.9.52-FA_a4" /* Full version string */ #define H5check() H5check_version(H5_VERS_MAJOR,H5_VERS_MINOR, \ H5_VERS_RELEASE) diff --git a/src/H5system.c b/src/H5system.c index 36ec1c1..9d93d9c 100644 --- a/src/H5system.c +++ b/src/H5system.c @@ -627,28 +627,21 @@ HDgettimeofday(struct timeval *tv, void *tz) #endif -/* - *------------------------------------------------------------------------- - * +/*------------------------------------------------------------------------- * Function: H5_build_extpath * - * Purpose: To build the path for later searching of target file for external link. - * This path can be either: - * 1. The absolute path of NAME + * Purpose: To build the path for later searching of target file for external + * link. This path can be either: + * 1. The absolute path of NAME * or - * 2. The current working directory + relative path of NAME + * 2. The current working directory + relative path of NAME * * Return: Success: 0 * Failure: -1 * * Programmer: Vailin Choi * April 2, 2008 - * Modifications: 2nd Oct, 2008; Vailin Choi - * Remove compiler warning for "if condition" - * - * Raymond Lu - * 14 Jan. 2009 - * Add support for OpenVMS pathname + * *------------------------------------------------------------------------- */ #define MAX_PATH_LEN 1024 @@ -656,14 +649,14 @@ HDgettimeofday(struct timeval *tv, void *tz) herr_t H5_build_extpath(const char *name, char **extpath/*out*/) { - char *full_path=NULL, *ptr=NULL; - char *retcwd=NULL, *cwdpath=NULL, *new_name=NULL; - int drive; - size_t cwdlen, path_len; + char *full_path = NULL; /* Pointer to the full path, as built or passed in */ + char *cwdpath = NULL; /* Pointer to the current working directory path */ + char *new_name = NULL; /* Pointer to the name of the file */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5_build_extpath) + /* Clear external path pointer to begin with */ *extpath = NULL; /* @@ -672,14 +665,18 @@ H5_build_extpath(const char *name, char **extpath/*out*/) * OpenVMS: $:[path] * i.g. SYS$SYSUSERS:[LU.HDF5.SRC]H5system.c */ - if (CHECK_ABSOLUTE(name)) { - if ((full_path=H5MM_strdup(name)) == NULL) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - } else { /* relative pathname */ - if (NULL == (cwdpath = (char *)H5MM_malloc(MAX_PATH_LEN))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - if (NULL == (new_name = (char *)H5MM_strdup(name))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + if(CHECK_ABSOLUTE(name)) { + if(NULL == (full_path = (char *)H5MM_strdup(name))) + HGOTO_ERROR(H5E_INTERNAL, H5E_NOSPACE, FAIL, "memory allocation failed") + } /* end if */ + else { /* relative pathname */ + char *retcwd; + int drive; + + if(NULL == (cwdpath = (char *)H5MM_malloc(MAX_PATH_LEN))) + HGOTO_ERROR(H5E_INTERNAL, H5E_NOSPACE, FAIL, "memory allocation failed") + if(NULL == (new_name = (char *)H5MM_strdup(name))) + HGOTO_ERROR(H5E_INTERNAL, H5E_NOSPACE, FAIL, "memory allocation failed") /* * Windows: name[0-1] is ":" @@ -687,29 +684,35 @@ H5_build_extpath(const char *name, char **extpath/*out*/) * Unix: does not apply * OpenVMS: does not apply */ - if (CHECK_ABS_DRIVE(name)) { + if(CHECK_ABS_DRIVE(name)) { drive = name[0] - 'A' + 1; retcwd = HDgetdcwd(drive, cwdpath, MAX_PATH_LEN); HDstrcpy(new_name, &name[2]); + } /* end if */ /* * Windows: name[0] is a '/' or '\' * Get current drive * Unix: does not apply * OpenVMS: does not apply */ - } else if (CHECK_ABS_PATH(name) && ((drive=HDgetdrive()) != 0)) { + else if(CHECK_ABS_PATH(name) && (0 != (drive = HDgetdrive()))) { sprintf(cwdpath, "%c:%c", (drive+'A'-1), name[0]); retcwd = cwdpath; HDstrcpy(new_name, &name[1]); - } else /* totally relative for Unix, Windows, and OpenVMS: get current working directory */ + } + /* totally relative for Unix, Windows, and OpenVMS: get current working directory */ + else retcwd = HDgetcwd(cwdpath, MAX_PATH_LEN); - if (retcwd != NULL) { + if(retcwd != NULL) { + size_t cwdlen; + size_t path_len; + cwdlen = HDstrlen(cwdpath); HDassert(cwdlen); path_len = cwdlen + HDstrlen(new_name) + 2; - if (NULL == (full_path = (char *)H5MM_malloc(path_len))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + if(NULL == (full_path = (char *)H5MM_malloc(path_len))) + HGOTO_ERROR(H5E_INTERNAL, H5E_NOSPACE, FAIL, "memory allocation failed") HDstrcpy(full_path, cwdpath); #ifdef H5_VMS @@ -721,30 +724,36 @@ H5_build_extpath(const char *name, char **extpath/*out*/) */ if(new_name[0] == '[') { char *tmp = new_name; - full_path[cwdlen-1] = '\0'; + full_path[cwdlen - 1] = '\0'; HDstrcat(full_path, ++tmp); - } else + } /* end if */ + else HDstrcat(full_path, new_name); #else - if (!CHECK_DELIMITER(cwdpath[cwdlen-1])) + if(!CHECK_DELIMITER(cwdpath[cwdlen - 1])) HDstrcat(full_path, DIR_SEPS); HDstrcat(full_path, new_name); #endif - } - } + } /* end if */ + } /* end else */ /* strip out the last component (the file name itself) from the path */ - if (full_path) { + if(full_path) { + char *ptr = NULL; + GET_LAST_DELIMITER(full_path, ptr) HDassert(ptr); *++ptr = '\0'; *extpath = full_path; - } + } /* end if */ done: - if (cwdpath) + /* Release resources */ + if(cwdpath) H5MM_xfree(cwdpath); - if (new_name) + if(new_name) H5MM_xfree(new_name); + FUNC_LEAVE_NOAPI(ret_value) } /* H5_build_extpath() */ + diff --git a/src/H5win32defs.h b/src/H5win32defs.h index 2a170ea..141ec82 100644 --- a/src/H5win32defs.h +++ b/src/H5win32defs.h @@ -40,6 +40,7 @@ typedef __int64 h5_stat_size_t; #endif #define HDfstat(F,B) _fstati64(F,B) #define HDisatty(F) _isatty(F) +#define HDlstat(S,B) _lstati64(S,B) #define HDstat(S,B) _stati64(S,B) #define HDgetcwd(S,Z) _getcwd(S,Z) #define HDgetdcwd(D,S,Z) _getdcwd(D,S,Z) diff --git a/src/Makefile.am b/src/Makefile.am index 58902fa..307ce51 100755 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -95,8 +95,10 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ H5RC.c \ H5RS.c \ H5S.c H5Sall.c H5Sdbg.c H5Shyper.c H5Smpio.c H5Snone.c H5Spoint.c \ - H5Sselect.c H5Stest.c H5SL.c H5SM.c H5SMbtree2.c \ - H5SMcache.c H5SMtest.c H5ST.c \ + H5Sselect.c H5Stest.c \ + H5SL.c \ + H5SM.c H5SMbtree2.c H5SMcache.c H5SMmessage.c H5SMtest.c \ + H5ST.c \ H5T.c H5Tarray.c H5Tbit.c H5Tcommit.c H5Tcompound.c H5Tconv.c \ H5Tcset.c H5Tdbg.c H5Tdeprec.c H5Tenum.c H5Tfields.c \ H5Tfixed.c \ diff --git a/src/Makefile.in b/src/Makefile.in index f56cab5..def44c2 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -138,13 +138,13 @@ am_libhdf5_la_OBJECTS = H5.lo H5checksum.lo H5dbg.lo H5system.lo \ H5Pocpypl.lo H5Pstrcpl.lo H5Ptest.lo H5R.lo H5Rdeprec.lo \ H5RC.lo H5RS.lo H5S.lo H5Sall.lo H5Sdbg.lo H5Shyper.lo \ H5Smpio.lo H5Snone.lo H5Spoint.lo H5Sselect.lo H5Stest.lo \ - H5SL.lo H5SM.lo H5SMbtree2.lo H5SMcache.lo H5SMtest.lo H5ST.lo \ - H5T.lo H5Tarray.lo H5Tbit.lo H5Tcommit.lo H5Tcompound.lo \ - H5Tconv.lo H5Tcset.lo H5Tdbg.lo H5Tdeprec.lo H5Tenum.lo \ - H5Tfields.lo H5Tfixed.lo H5Tfloat.lo H5Tinit.lo H5Tnative.lo \ - H5Toffset.lo H5Toh.lo H5Topaque.lo H5Torder.lo H5Tpad.lo \ - H5Tprecis.lo H5Tstrpad.lo H5Tvisit.lo H5Tvlen.lo H5TS.lo \ - H5V.lo H5WB.lo H5Z.lo H5Zdeflate.lo H5Zfletcher32.lo \ + H5SL.lo H5SM.lo H5SMbtree2.lo H5SMcache.lo H5SMmessage.lo \ + H5SMtest.lo H5ST.lo H5T.lo H5Tarray.lo H5Tbit.lo H5Tcommit.lo \ + H5Tcompound.lo H5Tconv.lo H5Tcset.lo H5Tdbg.lo H5Tdeprec.lo \ + H5Tenum.lo H5Tfields.lo H5Tfixed.lo H5Tfloat.lo H5Tinit.lo \ + H5Tnative.lo H5Toffset.lo H5Toh.lo H5Topaque.lo H5Torder.lo \ + H5Tpad.lo H5Tprecis.lo H5Tstrpad.lo H5Tvisit.lo H5Tvlen.lo \ + H5TS.lo H5V.lo H5WB.lo H5Z.lo H5Zdeflate.lo H5Zfletcher32.lo \ H5Znbit.lo H5Zshuffle.lo H5Zszip.lo H5Zscaleoffset.lo \ H5Ztrans.lo libhdf5_la_OBJECTS = $(am_libhdf5_la_OBJECTS) @@ -441,7 +441,7 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog # Add libtool shared library version numbers to the HDF5 library # See libtool versioning documentation online. LT_VERS_INTERFACE = 6 -LT_VERS_REVISION = 41 +LT_VERS_REVISION = 42 LT_VERS_AGE = 0 H5detect_CFLAGS = -g $(AM_CFLAGS) @@ -511,8 +511,10 @@ libhdf5_la_SOURCES = H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ H5RC.c \ H5RS.c \ H5S.c H5Sall.c H5Sdbg.c H5Shyper.c H5Smpio.c H5Snone.c H5Spoint.c \ - H5Sselect.c H5Stest.c H5SL.c H5SM.c H5SMbtree2.c \ - H5SMcache.c H5SMtest.c H5ST.c \ + H5Sselect.c H5Stest.c \ + H5SL.c \ + H5SM.c H5SMbtree2.c H5SMcache.c H5SMmessage.c H5SMtest.c \ + H5ST.c \ H5T.c H5Tarray.c H5Tbit.c H5Tcommit.c H5Tcompound.c H5Tconv.c \ H5Tcset.c H5Tdbg.c H5Tdeprec.c H5Tenum.c H5Tfields.c \ H5Tfixed.c \ @@ -867,6 +869,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5SM.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5SMbtree2.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5SMcache.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5SMmessage.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5SMtest.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5ST.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Sall.Plo@am__quote@ diff --git a/test/btree2.c b/test/btree2.c index 6006dc8..fb24433 100644 --- a/test/btree2.c +++ b/test/btree2.c @@ -133,7 +133,7 @@ create_btree(H5F_t *f, hid_t dxpl, const H5B2_create_t *cparam, H5B2_t **bt2, haddr_t *bt2_addr) { /* Create the v2 B-tree & get its address */ - if(NULL == (*bt2 = H5B2_create(f, dxpl, cparam))) + if(NULL == (*bt2 = H5B2_create(f, dxpl, cparam, f))) FAIL_STACK_ERROR if(H5B2_get_addr(*bt2, bt2_addr/*out*/) < 0) FAIL_STACK_ERROR @@ -172,7 +172,7 @@ reopen_btree(H5F_t *f, hid_t dxpl, H5B2_t **bt2, haddr_t bt2_addr, FAIL_STACK_ERROR /* Re-open v2 B-tree */ - if(NULL == (*bt2 = H5B2_open(f, dxpl, bt2_addr))) + if(NULL == (*bt2 = H5B2_open(f, dxpl, bt2_addr, f))) FAIL_STACK_ERROR } /* end if */ @@ -2839,7 +2839,7 @@ HDfprintf(stderr,"curr_time=%lu\n",(unsigned long)curr_time); FAIL_STACK_ERROR /* Re-open v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, dxpl, bt2_addr))) + if(NULL == (bt2 = H5B2_open(f, dxpl, bt2_addr, f))) FAIL_STACK_ERROR /* Check up on B-tree after re-open */ @@ -6526,7 +6526,7 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time); } /* end for */ /* Re-open v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, dxpl, bt2_addr))) + if(NULL == (bt2 = H5B2_open(f, dxpl, bt2_addr, f))) FAIL_STACK_ERROR /* Remove all records */ @@ -6606,7 +6606,7 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time); FAIL_STACK_ERROR /* Re-open v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, dxpl, bt2_addr))) + if(NULL == (bt2 = H5B2_open(f, dxpl, bt2_addr, f))) FAIL_STACK_ERROR /* Remove all records */ @@ -6690,7 +6690,7 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time); FAIL_STACK_ERROR /* Re-open v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, dxpl, bt2_addr))) + if(NULL == (bt2 = H5B2_open(f, dxpl, bt2_addr, f))) FAIL_STACK_ERROR /* Remove all records */ @@ -6771,7 +6771,7 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time); FAIL_STACK_ERROR /* Re-open v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, dxpl, bt2_addr))) + if(NULL == (bt2 = H5B2_open(f, dxpl, bt2_addr, f))) FAIL_STACK_ERROR /* Remove all records */ @@ -7128,7 +7128,7 @@ test_delete(hid_t fapl, const H5B2_create_t *cparam) /* * Delete v2 B-tree */ - if(H5B2_delete(f, dxpl, bt2_addr, NULL, NULL) < 0) + if(H5B2_delete(f, dxpl, bt2_addr, f, NULL, NULL) < 0) FAIL_STACK_ERROR /* Close the file */ @@ -7181,7 +7181,7 @@ test_delete(hid_t fapl, const H5B2_create_t *cparam) /* * Delete v2 B-tree */ - if(H5B2_delete(f, H5P_DATASET_XFER_DEFAULT, bt2_addr, NULL, NULL) < 0) + if(H5B2_delete(f, H5P_DATASET_XFER_DEFAULT, bt2_addr, f, NULL, NULL) < 0) FAIL_STACK_ERROR /* Close file */ @@ -7234,7 +7234,7 @@ test_delete(hid_t fapl, const H5B2_create_t *cparam) /* * Delete v2 B-tree */ - if(H5B2_delete(f, dxpl, bt2_addr, NULL, NULL) < 0) + if(H5B2_delete(f, dxpl, bt2_addr, f, NULL, NULL) < 0) FAIL_STACK_ERROR /* Close file */ @@ -7287,7 +7287,7 @@ test_delete(hid_t fapl, const H5B2_create_t *cparam) /* * Delete v2 B-tree */ - if(H5B2_delete(f, dxpl, bt2_addr, NULL, NULL) < 0) + if(H5B2_delete(f, dxpl, bt2_addr, f, NULL, NULL) < 0) FAIL_STACK_ERROR /* Close file */ diff --git a/test/links.c b/test/links.c index 60607c9..37b03cf 100644 --- a/test/links.c +++ b/test/links.c @@ -36,57 +36,17 @@ #define LINKED_FILE "be_extlink2.h5" #ifdef H5_VMS -const char *FILENAME[] = { - "links0", - "links1", - "links2", - "links3", - "links4a", /* 4 */ - "links4b", /* 5 */ - "links4c", /* 6 */ - "links4d", /* 7 */ - "links5", /* 8 */ - "links6", /* 9 */ - "links7", /* 10 */ - "links8", /* 11 */ - "extlinks0", /* 12: main files */ - "[.tmp]extlinks0", /* 13: */ - "extlinks1", /* 14: target files */ - "[.tmp]extlinks1", /* 15: */ - "extlinks2", /* 16: */ - "[.tmp]extlinks2", /* 17: */ - "extlinks3", /* 18: */ - "[.tmp]extlinks3", /* 19: */ - "extlinks4", /* 20: */ - "[.tmp]extlinks4", /* 21: */ - "extlinks5", /* 22: */ - "[.tmp]extlinks6", /* 23: */ - "extlinks7", /* 24: */ - "[.tmp]extlinks7", /* 25: */ - "[.tmp]extlinks8", /* 26: */ - "extlinks9", /* 27: */ - "[.tmp]extlinks9", /* 28: */ - "extlinks10", /* 29: */ /* TESTS for windows */ - "[.tmp]extlinks10", /* 30: */ - "[.tmp]extlinks11", /* 31: */ - "[.tmp]extlinks12", /* 32: */ - "extlinks13", /* 33: */ - "[.tmp]extlinks13", /* 34: */ - "[.tmp]extlinks14", /* 35: */ - "[.tmp]extlinks15", /* 36: */ - "extlinks16A", /* 37: */ /* TESTS for H5P_set_elink_fapl */ - "extlinks16B", /* 38: */ - "extlinks17", /* 39: */ - "extlinks18A", /* 40: */ - "extlinks18B", /* 41: */ - "extlinks19A", /* 42: */ - "extlinks19B", /* 43: */ - "extlinks20", /* 44: */ - NULL -}; - #define TMPDIR "[.tmp]" -#else +#define TMPDIR2 "[.tmp2]" +#else /* H5_VMS */ +#define TMPDIR "tmp/" +#define TMPDIR2 "tmp2/" +#endif /* H5_VMS */ + +/* Symlinks for external link symlink test */ +#define SYMLINK1 TMPDIR "sym1.h5" +#define SYMLINK2 TMPDIR2 "sym2.h5" + const char *FILENAME[] = { "links0", "links1", @@ -101,30 +61,30 @@ const char *FILENAME[] = { "links7", /* 10 */ "links8", /* 11 */ "extlinks0", /* 12: main files */ - "tmp/extlinks0", /* 13: */ + TMPDIR "extlinks0", /* 13: */ "extlinks1", /* 14: target files */ - "tmp/extlinks1", /* 15: */ + TMPDIR "extlinks1", /* 15: */ "extlinks2", /* 16: */ - "tmp/extlinks2", /* 17: */ + TMPDIR "extlinks2", /* 17: */ "extlinks3", /* 18: */ - "tmp/extlinks3", /* 19: */ + TMPDIR "extlinks3", /* 19: */ "extlinks4", /* 20: */ - "tmp/extlinks4", /* 21: */ + TMPDIR "extlinks4", /* 21: */ "extlinks5", /* 22: */ - "tmp/extlinks6", /* 23: */ + TMPDIR "extlinks6", /* 23: */ "extlinks7", /* 24: */ - "tmp/extlinks7", /* 25: */ - "tmp/extlinks8", /* 26: */ + TMPDIR "extlinks7", /* 25: */ + TMPDIR "extlinks8", /* 26: */ "extlinks9", /* 27: */ - "tmp/extlinks9", /* 28: */ + TMPDIR "extlinks9", /* 28: */ "extlinks10", /* 29: */ /* TESTS for windows */ - "tmp/extlinks10", /* 30: */ - "tmp/extlinks11", /* 31: */ - "tmp/extlinks12", /* 32: */ + TMPDIR "extlinks10",/* 30: */ + TMPDIR "extlinks11",/* 31: */ + TMPDIR "extlinks12",/* 32: */ "extlinks13", /* 33: */ - "tmp/extlinks13", /* 34: */ - "tmp/extlinks14", /* 35: */ - "tmp/extlinks15", /* 36: */ + TMPDIR "extlinks13",/* 34: */ + TMPDIR "extlinks14",/* 35: */ + TMPDIR "extlinks15",/* 36: */ "extlinks16A", /* 37: */ /* TESTS for H5P_set_elink_fapl */ "extlinks16B", /* 38: */ "extlinks17", /* 39: */ @@ -133,12 +93,16 @@ const char *FILENAME[] = { "extlinks19A", /* 42: */ "extlinks19B", /* 43: */ "extlinks20", /* 44: */ + "extlinks21A", /* 45: Files for symlink() tests*/ + TMPDIR2 "extlinks21B",/* 46: */ + TMPDIR2 "extlinks21C",/* 47: */ + "extlinks21C", /* 48: (same as #47, only without the TMPDIR2 prefix) */ + TMPDIR "extlinks21D",/* 49: */ + TMPDIR "extlinks21E",/* 50: */ + "extlinks21E", /* 51: (same as #50, only without the TMPDIR prefix) */ NULL }; -#define TMPDIR "tmp" -#endif - #define FAMILY_SIZE 1024 #define CORE_INCREMENT 1024 #define NUM40 40 @@ -352,6 +316,37 @@ typedef struct { /*------------------------------------------------------------------------- + * Function: fix_ext_filename + * + * Purpose: Internal function to append path to file name. It handles + * path name of Unix, Windows, and OpenVMS. + * + * Return: void + * + * Programmer: Raymond Lu + * 14 Jan. 2009 + *------------------------------------------------------------------------- + */ +static void +fix_ext_filename(char *path_name, char *cwd, const char *file_name) +{ + HDstrcpy(path_name, cwd); + +#ifdef H5_VMS + if(file_name[0] == '[') { + char *tmp = file_name; + path_name[strlen(cwd)-1] = '\0'; + HDstrcat(path_name, ++tmp); + } else + HDstrcat(path_name, file_name); +#else + HDstrcat(path_name, "/"); + HDstrcat(path_name, file_name); +#endif +} + + +/*------------------------------------------------------------------------- * Function: mklinks * * Purpose: Build a file with assorted links. @@ -2754,7 +2749,7 @@ external_link_env(hid_t fapl, hbool_t new_format) /* set up name for external linked target file: "extlinks1" */ h5_fixname(FILENAME[14], fapl, filename2, sizeof filename2); - if (HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) + if(HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) TEST_ERROR /* set up name for target file: "tmp/extlinks1" */ @@ -2899,37 +2894,6 @@ external_link_prefix(hid_t fapl, hbool_t new_format) /*------------------------------------------------------------------------- - * Function: fix_ext_filename - * - * Purpose: Internal function to append path to file name. It handles - * path name of Unix, Windows, and OpenVMS. - * - * Return: void - * - * Programmer: Raymond Lu - * 14 Jan. 2009 - *------------------------------------------------------------------------- - */ -static void -fix_ext_filename(char *path_name, char *cwd, const char *file_name) -{ - HDstrcpy(path_name, cwd); - -#ifdef H5_VMS - if(file_name[0] == '[') { - char *tmp = file_name; - path_name[strlen(cwd)-1] = '\0'; - HDstrcat(path_name, ++tmp); - } else - HDstrcat(path_name, file_name); -#else - HDstrcat(path_name, "/"); - HDstrcat(path_name, file_name); -#endif -} - - -/*------------------------------------------------------------------------- * Function: external_link_abs_mainpath: test 3 * * Purpose: 1. target link: "extlinks3" @@ -6431,6 +6395,208 @@ error: /*------------------------------------------------------------------------- + * Function: external_symlink + * + * Purpose: Verify functionality of external links when symlinks are + * used for parent/child files + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Quincey Koziol + * Nov. 23, 2009 + * + *------------------------------------------------------------------------- + */ +static int +external_symlink(hid_t fapl, hbool_t new_format) +{ +#ifdef H5_HAVE_SYMLINK + hid_t file1 = -1, file2 = -1, file3 = -1, file4 = -1, file5 = -1; + hid_t group2 = -1, group3 = -1, group4 = -1, group5 = -1; + char filename1[NAME_BUF_SIZE], + filename2a[NAME_BUF_SIZE], + filename2b[NAME_BUF_SIZE], + filename3a[NAME_BUF_SIZE], + filename3b[NAME_BUF_SIZE], + filename4a[NAME_BUF_SIZE], + filename4b[NAME_BUF_SIZE], + filename5a[NAME_BUF_SIZE], + filename5b[NAME_BUF_SIZE], + tmpname[NAME_BUF_SIZE], + cwdpath[NAME_BUF_SIZE]; +#endif /* H5_HAVE_SYMLINK */ + + if(new_format) + TESTING("external links w/symlink files (w/new group format)") + else + TESTING("external links w/symlink files") + +#ifdef H5_HAVE_SYMLINK + /* set up name for main file: "extlinks21A" */ + h5_fixname(FILENAME[45], fapl, filename1, sizeof(filename1)); + + /* create tmp directory and get current working directory path */ + if(HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) + TEST_ERROR + if(HDmkdir(TMPDIR2, (mode_t)0755) < 0 && errno != EEXIST) + TEST_ERROR + if(NULL == HDgetcwd(cwdpath, NAME_BUF_SIZE)) + TEST_ERROR + + /* Set up names for files in the subdirectories */ + + /* set up names for file #2 in temporary directory #2: "tmp2/extlinks21B" */ + h5_fixname(FILENAME[46], fapl, filename2a, sizeof(filename2a)); + fix_ext_filename(tmpname, cwdpath, FILENAME[46]); + h5_fixname(tmpname, fapl, filename2b, sizeof(filename2b)); + + /* Create symbolic link #1 in temporary directory #1 to file #2 in temporary directory #2 */ + /* (i.e. tmp/sym1.h5 -> /tmp2/extlinks21B.h5) */ + if(HDsymlink(filename2b, SYMLINK1) < 0 && errno != EEXIST) TEST_ERROR + + /* set up name for file #3 in temporary directory #2: "tmp2/extlinks21C" */ + h5_fixname(FILENAME[47], fapl, filename3a, sizeof(filename3a)); + h5_fixname(FILENAME[48], fapl, filename3b, sizeof(filename3b)); + + /* set up name for file #4 in temporary directory #1: "tmp/extlinks21D" */ + h5_fixname(FILENAME[49], fapl, filename4a, sizeof(filename4a)); + fix_ext_filename(tmpname, cwdpath, FILENAME[49]); + h5_fixname(tmpname, fapl, filename4b, sizeof(filename4b)); + + /* Create symbolic link #2 in temporary directory #2 to file #4 in temporary directory #1 */ + /* (i.e. tmp2/sym2.h5 -> /tmp/extlinks21D.h5) */ + if(HDsymlink(filename4b, SYMLINK2) < 0 && errno != EEXIST) TEST_ERROR + + /* set up name for file #5 in temporary directory #1: "tmp/extlinks21E" */ + h5_fixname(FILENAME[50], fapl, filename5a, sizeof(filename5a)); + h5_fixname(FILENAME[51], fapl, filename5b, sizeof(filename5b)); + + + /* Create file #1 in current directory */ + if((file1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + + /* Create external link to file & object in temporary directory #2, using symlink #1 name */ + if(H5Lcreate_external(SYMLINK1, "group2", file1, "extlink2-sym", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + + /* Close file #1 */ + if(H5Fclose(file1) < 0) TEST_ERROR + + + /* Create file #2 in tmp directory #2 */ + if((file2 = H5Fcreate(filename2a, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if(H5Fclose(file2) < 0) TEST_ERROR + + /* Re-open file #2 in tmp directory through symlink */ + if((file2 = H5Fopen(SYMLINK1, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR + + /* Create group in file #2 in temporary directory */ + if((group2 = H5Gcreate2(file2, "group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + + /* Create external link to file #3 & object in temporary directory #2 */ + if(H5Lcreate_external(filename3b, "group3", group2, "extlink3", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + + /* Close group in file #2 */ + if(H5Gclose(group2) < 0) TEST_ERROR + + /* Close file #2 */ + if(H5Fclose(file2) < 0) TEST_ERROR + + + /* Create file #3 in temp. directory #2 */ + if((file3 = H5Fcreate(filename3a, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + + /* Create group in file #3 */ + if((group3 = H5Gcreate2(file3, "group3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + + /* Create external link to file & object in temporary directory #1, using symlink #2 name */ + if(H5Lcreate_external(SYMLINK2, "group4", group3, "extlink4-sym", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + + /* Close group in file #3 */ + if(H5Gclose(group3) < 0) TEST_ERROR + + /* Close file #3 */ + if(H5Fclose(file3) < 0) TEST_ERROR + + + /* Create file #4 in temporary directory #1 */ + if((file4 = H5Fcreate(filename4b, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + + /* Create group in file #4 in 'temporary' directory */ + if((group4 = H5Gcreate2(file4, "group4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + + /* Create external link to file #5 & object in temporary directory #1 */ + if(H5Lcreate_external(filename5b, "group5", group4, "extlink5", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + + /* Close group in file #4 */ + if(H5Gclose(group4) < 0) TEST_ERROR + + /* Close file #4 */ + if(H5Fclose(file4) < 0) TEST_ERROR + + + /* Create file #5 in temporary directory #1 */ + if((file5 = H5Fcreate(filename5a, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + + /* Create group in file #5 in 'temporary' directory #1 */ + if((group5 = H5Gcreate2(file5, "group5", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if(H5Gclose(group5) < 0) TEST_ERROR + + /* Close file #5 */ + if(H5Fclose(file5) < 0) TEST_ERROR + + + /* Actual tests... */ + + /* Reopen file #1 */ + if((file1 = H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR + + /* Open group in file #2, through external link w/symlink */ + if((group2 = H5Gopen2(file1, "extlink2-sym", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if(H5Gclose(group2) < 0) TEST_ERROR + + /* Open group in file #3, through external link w/symlink to external link */ + if((group3 = H5Gopen2(file1, "extlink2-sym/extlink3", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if(H5Gclose(group3) < 0) TEST_ERROR + + /* Open group in file #4, through external link w/symlink to external link w/symlink */ + if((group4 = H5Gopen2(file1, "extlink2-sym/extlink3/extlink4-sym", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if(H5Gclose(group4) < 0) TEST_ERROR + + /* Open group in file #5, through external link w/symlink to external link w/symlink to external link */ + if((group5 = H5Gopen2(file1, "extlink2-sym/extlink3/extlink4-sym/extlink5", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if(H5Gclose(group5) < 0) TEST_ERROR + + /* Close file #1 */ + if(H5Fclose(file1) < 0) TEST_ERROR + + + PASSED(); + return 0; + + error: + H5E_BEGIN_TRY { + H5Gclose(group5); + H5Gclose(group4); + H5Gclose(group3); + H5Gclose(group2); + H5Fclose(file5); + H5Fclose(file4); + H5Fclose(file3); + H5Fclose(file2); + H5Fclose(file1); + } H5E_END_TRY; + return -1; +#else /* H5_HAVE_SYMLINK */ + SKIPPED(); + puts(" Current file system or operating system doesn't support symbolic links"); + + return 0; +#endif /* H5_HAVE_SYMLINK */ +} /* end external_symlink() */ + + +/*------------------------------------------------------------------------- * Function: ud_hard_links * * Purpose: Check that the functionality of hard links can be duplicated @@ -13434,6 +13600,7 @@ main(void) nerrors += external_link_win8(my_fapl, new_format) < 0 ? 1 : 0; nerrors += external_link_win9(my_fapl, new_format) < 0 ? 1 : 0; #endif + nerrors += external_symlink(my_fapl, new_format) < 0 ? 1 : 0; /* These tests assume that external links are a form of UD links, * so assume that everything that passed for external links @@ -13506,8 +13673,13 @@ main(void) } printf("All link tests passed.\n"); + /* clean up symlink created by external link tests */ + HDremove(SYMLINK1); + HDremove(SYMLINK2); + /* clean up tmp directory created by external link tests */ HDrmdir(TMPDIR); + HDrmdir(TMPDIR2); return 0; diff --git a/tools/h5diff/testfiles/h5diff_200.txt b/tools/h5diff/testfiles/h5diff_200.txt index 56d723d..5a4d02e 100644 --- a/tools/h5diff/testfiles/h5diff_200.txt +++ b/tools/h5diff/testfiles/h5diff_200.txt @@ -1,3 +1,4 @@ +dataset: and -------------------------------- Some objects are not comparable -------------------------------- diff --git a/tools/h5diff/testfiles/h5diff_201.txt b/tools/h5diff/testfiles/h5diff_201.txt index 84d6766..da916ea 100644 --- a/tools/h5diff/testfiles/h5diff_201.txt +++ b/tools/h5diff/testfiles/h5diff_201.txt @@ -1 +1,2 @@ +dataset: and Not comparable: or is an empty dataset diff --git a/tools/h5diff/testfiles/h5diff_202.txt b/tools/h5diff/testfiles/h5diff_202.txt index fd4a191..8e3c7ac 100644 --- a/tools/h5diff/testfiles/h5diff_202.txt +++ b/tools/h5diff/testfiles/h5diff_202.txt @@ -1,2 +1,3 @@ +dataset: and Not comparable: is of class H5T_FLOAT and is of class H5T_INTEGER Not comparable: has sign H5T_SGN_ERROR and has sign H5T_SGN_2 diff --git a/tools/h5diff/testfiles/h5diff_203.txt b/tools/h5diff/testfiles/h5diff_203.txt index 496523c..90294e3 100644 --- a/tools/h5diff/testfiles/h5diff_203.txt +++ b/tools/h5diff/testfiles/h5diff_203.txt @@ -1,2 +1,3 @@ +dataset: and Not comparable: has rank 1, dimensions [6], max dimensions [6] and has rank 2, dimensions [3x2], max dimensions [3x2] diff --git a/tools/h5diff/testfiles/h5diff_204.txt b/tools/h5diff/testfiles/h5diff_204.txt index 098a203..a94091d 100644 --- a/tools/h5diff/testfiles/h5diff_204.txt +++ b/tools/h5diff/testfiles/h5diff_204.txt @@ -1,2 +1,3 @@ +dataset: and Not comparable: has rank 2, dimensions [3x2], max dimensions [3x2] and has rank 2, dimensions [2x2], max dimensions [2x2] diff --git a/tools/h5diff/testfiles/h5diff_205.txt b/tools/h5diff/testfiles/h5diff_205.txt index 3e2d1f2..c3708cb 100644 --- a/tools/h5diff/testfiles/h5diff_205.txt +++ b/tools/h5diff/testfiles/h5diff_205.txt @@ -1,3 +1,4 @@ +dataset: and Not comparable: has rank 2, dimensions [2x2], max dimensions [2x2] and has rank 2, dimensions [3x2], max dimensions [3x2] Not comparable: has sign H5T_SGN_2 and has sign H5T_SGN_NONE diff --git a/tools/h5diff/testfiles/h5diff_206.txt b/tools/h5diff/testfiles/h5diff_206.txt index 164aed9..3557b1e 100644 --- a/tools/h5diff/testfiles/h5diff_206.txt +++ b/tools/h5diff/testfiles/h5diff_206.txt @@ -1 +1,2 @@ +dataset: and Not comparable: has a class H5T_FLOAT and has a class H5T_INTEGER diff --git a/tools/h5diff/testfiles/h5diff_207.txt b/tools/h5diff/testfiles/h5diff_207.txt index bb8e23f..4dfcbb7 100644 --- a/tools/h5diff/testfiles/h5diff_207.txt +++ b/tools/h5diff/testfiles/h5diff_207.txt @@ -1,2 +1,3 @@ +dataset: and Not comparable: or is an empty dataset Not comparable: has 2 members has 1 members diff --git a/tools/h5diff/testfiles/h5diff_609.txt b/tools/h5diff/testfiles/h5diff_609.txt index e69de29..9369dd9 100644 --- a/tools/h5diff/testfiles/h5diff_609.txt +++ b/tools/h5diff/testfiles/h5diff_609.txt @@ -0,0 +1,2 @@ +dataset: and +0 differences found diff --git a/tools/h5diff/testfiles/h5diff_618.txt b/tools/h5diff/testfiles/h5diff_618.txt index e69de29..9369dd9 100644 --- a/tools/h5diff/testfiles/h5diff_618.txt +++ b/tools/h5diff/testfiles/h5diff_618.txt @@ -0,0 +1,2 @@ +dataset: and +0 differences found diff --git a/tools/lib/h5diff.c b/tools/lib/h5diff.c index 5a4e2f2..7d11f2f 100644 --- a/tools/lib/h5diff.c +++ b/tools/lib/h5diff.c @@ -916,45 +916,27 @@ hsize_t diff(hid_t file1_id, *------------------------------------------------------------------------- */ case H5TRAV_TYPE_DATASET: - /*------------------------------------------------------------------------- - * verbose, always print name - *------------------------------------------------------------------------- - */ - if(options->m_verbose) + /* verbose (-v) and report (-r) mode */ + if(options->m_verbose || options->m_report) { - if(print_objname(options, (hsize_t)1)) - do_print_objname("dataset", path1, path2); + do_print_objname("dataset", path1, path2); nfound = diff_dataset(file1_id, file2_id, path1, path2, options); print_found(nfound); - } /* end if */ - /*------------------------------------------------------------------------- - * non verbose, check first if we have differences by enabling quiet mode - * so that printing is off, and compare again if differences found, - * disabling quiet mode - *------------------------------------------------------------------------- - */ + } + /* quiet mode (-q), just count differences */ + else if(options->m_quiet) + { + nfound = diff_dataset(file1_id, file2_id, path1, path2, options); + } + /* the rest (-c, none, ...) */ else { - if(options->m_quiet == 0) - { - /* shut up temporarily */ - options->m_quiet = 1; - nfound = diff_dataset(file1_id, file2_id, path1, path2, options); - - /* print again */ - options->m_quiet = 0; - if(nfound) - { - if(print_objname(options,nfound)) - do_print_objname("dataset", path1, path2); - nfound = diff_dataset(file1_id, file2_id, path1, path2, options); - print_found(nfound); - } /* end if */ - } /* end if */ - /* in quiet mode, just count differences */ - else - nfound = diff_dataset(file1_id, file2_id, path1, path2, options); - } /* end else */ + do_print_objname("dataset", path1, path2); + nfound = diff_dataset(file1_id, file2_id, path1, path2, options); + /* not comparable, no display the different number */ + if (!options->not_cmp) + print_found(nfound); + } break; /*------------------------------------------------------------------------- diff --git a/tools/lib/h5diff_attr.c b/tools/lib/h5diff_attr.c index 69bd44c..73a7ee7 100644 --- a/tools/lib/h5diff_attr.c +++ b/tools/lib/h5diff_attr.c @@ -130,9 +130,9 @@ hsize_t diff_attr(hid_t loc1_id, goto error; - /*------------------------------------------------------------------------- + /*---------------------------------------------------------------------- * check for comparable TYPE and SPACE - *------------------------------------------------------------------------- + *---------------------------------------------------------------------- */ if ( msize1 != msize2 @@ -175,9 +175,9 @@ hsize_t diff_attr(hid_t loc1_id, } - /*------------------------------------------------------------------------- + /*--------------------------------------------------------------------- * read - *------------------------------------------------------------------------- + *---------------------------------------------------------------------- */ nelmts1=1; for (j=0; j",name1,path1); sprintf(np2,"%s of <%s>",name2,path2); - /*------------------------------------------------------------------------- + /*--------------------------------------------------------------------- * array compare - *------------------------------------------------------------------------- + *---------------------------------------------------------------------- */ /* always print name */ - if (options->m_verbose) + /* verbose (-v) and report (-r) mode */ + if(options->m_verbose || options->m_report) { do_print_objname ("attribute", np1, np2); nfound = diff_array(buf1, @@ -222,67 +223,48 @@ hsize_t diff_attr(hid_t loc1_id, print_found(nfound); } - /* check first if we have differences */ + /* quiet mode (-q), just count differences */ + else if(options->m_quiet) + { + nfound = diff_array(buf1, + buf2, + nelmts1, + (hsize_t)0, + rank1, + dims1, + options, + np1, + np2, + mtype1_id, + attr1_id, + attr2_id); + } + /* the rest (-c, none, ...) */ else { - if (options->m_quiet==0) - { - /* shut up temporarily */ - options->m_quiet=1; - nfound = diff_array(buf1, - buf2, - nelmts1, - (hsize_t)0, - rank1, - dims1, - options, - np1, - np2, - mtype1_id, - attr1_id, - attr2_id); - /* print again */ - options->m_quiet=0; - if (nfound) - { - do_print_objname ("attribute", np1, np2); - nfound = diff_array(buf1, - buf2, - nelmts1, - (hsize_t)0, - rank1, - dims1, - options, - np1, - np2, - mtype1_id, - attr1_id, - attr2_id); + do_print_objname ("attribute", np1, np2); + nfound = diff_array(buf1, + buf2, + nelmts1, + (hsize_t)0, + rank1, + dims1, + options, + np1, + np2, + mtype1_id, + attr1_id, + attr2_id); + + /* not comparable, no display the different number */ + if (!options->not_cmp) print_found(nfound); - } /*if*/ - } /*if*/ - /* in quiet mode, just count differences */ - else - { - nfound = diff_array(buf1, - buf2, - nelmts1, - (hsize_t)0, - rank1, - dims1, - options, - np1, - np2, - mtype1_id, - attr1_id, - attr2_id); - } /*else quiet */ - } /*else verbose */ - - - /*------------------------------------------------------------------------- + } + + + /*---------------------------------------------------------------------- * close - *------------------------------------------------------------------------- + *---------------------------------------------------------------------- */ if (H5Tclose(ftype1_id)<0) diff --git a/tools/misc/h5debug.c b/tools/misc/h5debug.c index c79a5b6..27e9741 100644 --- a/tools/misc/h5debug.c +++ b/tools/misc/h5debug.c @@ -87,19 +87,19 @@ get_H5B2_class(const uint8_t *sig) break; case H5B2_FHEAP_HUGE_INDIR_ID: - cls = H5HF_BT2_INDIR; + cls = H5HF_HUGE_BT2_INDIR; break; case H5B2_FHEAP_HUGE_FILT_INDIR_ID: - cls = H5HF_BT2_FILT_INDIR; + cls = H5HF_HUGE_BT2_FILT_INDIR; break; case H5B2_FHEAP_HUGE_DIR_ID: - cls = H5HF_BT2_DIR; + cls = H5HF_HUGE_BT2_DIR; break; case H5B2_FHEAP_HUGE_FILT_DIR_ID: - cls = H5HF_BT2_FILT_DIR; + cls = H5HF_HUGE_BT2_FILT_DIR; break; case H5B2_GRP_DENSE_NAME_ID: diff --git a/vms/src/h5pubconf.h b/vms/src/h5pubconf.h index 5087006..395feaf 100644 --- a/vms/src/h5pubconf.h +++ b/vms/src/h5pubconf.h @@ -229,6 +229,9 @@ /* Define to 1 if you have the `lseek64' function. */ /* #define H5_HAVE_LSEEK64 1 */ +/* Define to 1 if you have the `lstat' function. */ +/* #define H5_HAVE_LSTAT 1 */ + /* Define to 1 if you have the header file. */ #define H5_HAVE_MEMORY_H 1 @@ -265,9 +268,6 @@ /* Define to 1 if you have the `setsysinfo' function. */ /* #undef H5_HAVE_SETSYSINFO */ -/* Define to 1 if you have the `sigaction' function. */ -#define H5_HAVE_SIGACTION 1 - /* Define to 1 if you have the `siglongjmp' function. */ #define H5_HAVE_SIGLONGJMP 1 @@ -480,13 +480,13 @@ #define H5_PACKAGE_NAME "HDF5" /* Define to the full name and version of this package. */ -#define H5_PACKAGE_STRING "HDF5 1.9.51-FA_a4" +#define H5_PACKAGE_STRING "HDF5 1.9.52-FA_a4" /* Define to the one symbol short name of this package. */ #define H5_PACKAGE_TARNAME "hdf5" /* Define to the version of this package. */ -#define H5_PACKAGE_VERSION "1.9.51-FA_a4" +#define H5_PACKAGE_VERSION "1.9.52-FA_a4" /* Width for printf() for type `long long' or `__int64', use `ll' */ #define H5_PRINTF_LL_WIDTH "ll" @@ -639,7 +639,7 @@ /* #undef H5_USING_MEMCHECKER */ /* Version number of package */ -#define H5_VERSION "1.9.51-FA_a4" +#define H5_VERSION "1.9.52-FA_a4" /* Define if vsnprintf() returns the correct value for formatted strings that don't fit into size allowed */ diff --git a/windows/src/H5pubconf.h b/windows/src/H5pubconf.h index 52ca244..98916a4 100755 --- a/windows/src/H5pubconf.h +++ b/windows/src/H5pubconf.h @@ -231,6 +231,9 @@ /* Define to 1 if you have the `lseek64' function. */ /* #undef H5_HAVE_LSEEK64 */ +/* Define to 1 if you have the `lstat' function. */ +/* #undef H5_HAVE_LSTAT */ + /* Define to 1 if you have the header file. */ #define H5_HAVE_MEMORY_H 1 @@ -267,9 +270,6 @@ /* Define to 1 if you have the `setsysinfo' function. */ /* #undef H5_HAVE_SETSYSINFO */ -/* Define to 1 if you have the `sigaction' function. */ -/* #undef H5_HAVE_SIGACTION */ - /* Define to 1 if you have the `siglongjmp' function. */ /* #undef H5_HAVE_SIGLONGJMP */ @@ -479,13 +479,13 @@ #define H5_PACKAGE_NAME "HDF5" /* Define to the full name and version of this package. */ -#define H5_PACKAGE_STRING "HDF5 1.9.51-FA_a4" +#define H5_PACKAGE_STRING "HDF5 1.9.52-FA_a4" /* Define to the one symbol short name of this package. */ #define H5_PACKAGE_TARNAME "hdf5" /* Define to the version of this package. */ -#define H5_PACKAGE_VERSION "1.9.51-FA_a4" +#define H5_PACKAGE_VERSION "1.9.52-FA_a4" /* Width for printf() for type `long long' or `__int64', use `ll' */ #define H5_PRINTF_LL_WIDTH "I64" @@ -642,7 +642,7 @@ /* #undef H5_USING_MEMCHECKER */ /* Version number of package */ -#define H5_VERSION "1.9.51-FA_a4" +#define H5_VERSION "1.9.52-FA_a4" /* Define if vsnprintf() returns the correct value for formatted strings that don't fit into size allowed */ -- cgit v0.12