diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2009-08-15 07:03:44 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2009-08-15 07:03:44 (GMT) |
commit | 6c5e37a5938f3dc614f908d5d955b3103db4f367 (patch) | |
tree | 26cf3732aac362d9014ae0d9e81bd62767d6fe83 | |
parent | 58067df6c710c92c596ceac6b570f085e69c25d4 (diff) | |
download | hdf5-6c5e37a5938f3dc614f908d5d955b3103db4f367.zip hdf5-6c5e37a5938f3dc614f908d5d955b3103db4f367.tar.gz hdf5-6c5e37a5938f3dc614f908d5d955b3103db4f367.tar.bz2 |
[svn-r17366] Description:
Bring r17346:17365 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/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.5.8 (amazon) in debug mode
Mac OS X/32 10.5.8 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
43 files changed, 2229 insertions, 1417 deletions
@@ -527,6 +527,7 @@ ./src/H5Fquery.c ./src/H5Fsfile.c ./src/H5Fsuper.c +./src/H5Fsuper_cache.c ./src/H5Fpkg.h ./src/H5Fprivate.h ./src/H5Fpublic.h diff --git a/bin/install-sh b/bin/install-sh index b41a245..6781b98 100755 --- a/bin/install-sh +++ b/bin/install-sh @@ -1,251 +1,520 @@ #!/bin/sh -# # install - install a program, script, or datafile -# This comes from X11R5 (mit/util/scripts/install.sh). + +scriptversion=2009-04-28.21; # UTC + +# This originates from X11R5 (mit/util/scripts/install.sh), which was +# later released in X11R6 (xc/config/util/install.sh) with the +# following copyright and license. +# +# Copyright (C) 1994 X Consortium +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- +# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -# Copyright 1991 by the Massachusetts Institute of Technology +# Except as contained in this notice, the name of the X Consortium shall not +# be used in advertising or otherwise to promote the sale, use or other deal- +# ings in this Software without prior written authorization from the X Consor- +# tium. # -# Permission to use, copy, modify, distribute, and sell this software and its -# documentation for any purpose is hereby granted without fee, provided that -# the above copyright notice appear in all copies and that both that -# copyright notice and this permission notice appear in supporting -# documentation, and that the name of M.I.T. not be used in advertising or -# publicity pertaining to distribution of the software without specific, -# written prior permission. M.I.T. makes no representations about the -# suitability of this software for any purpose. It is provided "as is" -# without express or implied warranty. +# +# FSF changes to this file are in the public domain. # # Calling this script install-sh is preferred over install.sh, to prevent # `make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written -# from scratch. It can only install one file at a time, a restriction -# shared with many OS's install programs. +# from scratch. +nl=' +' +IFS=" "" $nl" # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. -doit="${DOITPROG-}" - - -# put in absolute paths if you don't have them in your path; or use env. vars. - -mvprog="${MVPROG-mv}" -cpprog="${CPPROG-cp}" -chmodprog="${CHMODPROG-chmod}" -chownprog="${CHOWNPROG-chown}" -chgrpprog="${CHGRPPROG-chgrp}" -stripprog="${STRIPPROG-strip}" -rmprog="${RMPROG-rm}" -mkdirprog="${MKDIRPROG-mkdir}" - -transformbasename="" -transform_arg="" -instcmd="$mvprog" -chmodcmd="$chmodprog 0755" -chowncmd="" -chgrpcmd="" -stripcmd="" -rmcmd="$rmprog -f" -mvcmd="$mvprog" -src="" -dst="" -dir_arg="" - -while [ x"$1" != x ]; do - case $1 in - -c) instcmd="$cpprog" - shift - continue;; - - -d) dir_arg=true - shift - continue;; - - -m) chmodcmd="$chmodprog $2" - shift - shift - continue;; - - -o) chowncmd="$chownprog $2" - shift - shift - continue;; - - -g) chgrpcmd="$chgrpprog $2" - shift - shift - continue;; - - -s) stripcmd="$stripprog" - shift - continue;; - - -t=*) transformarg=`echo $1 | sed 's/-t=//'` - shift - continue;; - - -b=*) transformbasename=`echo $1 | sed 's/-b=//'` - shift - continue;; - - *) if [ x"$src" = x ] - then - src=$1 - else - # this colon is to work around a 386BSD /bin/sh bug - : - dst=$1 - fi - shift - continue;; - esac -done - -if [ x"$src" = x ] -then - echo "install: no input file specified" - exit 1 +doit=${DOITPROG-} +if test -z "$doit"; then + doit_exec=exec else - true + doit_exec=$doit fi -if [ x"$dir_arg" != x ]; then - dst=$src - src="" - - if [ -d $dst ]; then - instcmd=: - chmodcmd="" - else - instcmd=$mkdirprog - fi -else +# Put in absolute file names if you don't have them in your path; +# or use environment vars. + +chgrpprog=${CHGRPPROG-chgrp} +chmodprog=${CHMODPROG-chmod} +chownprog=${CHOWNPROG-chown} +cmpprog=${CMPPROG-cmp} +cpprog=${CPPROG-cp} +mkdirprog=${MKDIRPROG-mkdir} +mvprog=${MVPROG-mv} +rmprog=${RMPROG-rm} +stripprog=${STRIPPROG-strip} + +posix_glob='?' +initialize_posix_glob=' + test "$posix_glob" != "?" || { + if (set -f) 2>/dev/null; then + posix_glob= + else + posix_glob=: + fi + } +' + +posix_mkdir= + +# Desired mode of installed file. +mode=0755 + +chgrpcmd= +chmodcmd=$chmodprog +chowncmd= +mvcmd=$mvprog +rmcmd="$rmprog -f" +stripcmd= -# Waiting for this to be detected by the "$instcmd $src $dsttmp" command -# might cause directories to be created, which would be especially bad -# if $src (and thus $dsttmp) contains '*'. +src= +dst= +dir_arg= +dst_arg= - if [ -f $src -o -d $src ] - then - true - else - echo "install: $src does not exist" - exit 1 - fi - - if [ x"$dst" = x ] - then - echo "install: no destination specified" - exit 1 - else - true - fi +copy_on_change=false +no_target_directory= -# If destination is a directory, append the input filename; if your system -# does not like double slashes in filenames, you may need to add some logic +usage="\ +Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE + or: $0 [OPTION]... SRCFILES... DIRECTORY + or: $0 [OPTION]... -t DIRECTORY SRCFILES... + or: $0 [OPTION]... -d DIRECTORIES... - if [ -d $dst ] - then - dst="$dst"/`basename $src` - else - true - fi -fi +In the 1st form, copy SRCFILE to DSTFILE. +In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. +In the 4th, create DIRECTORIES. -## this sed command emulates the dirname command -dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` +Options: + --help display this help and exit. + --version display version info and exit. -# Make sure that the destination directory exists. -# this part is taken from Noah Friedman's mkinstalldirs script + -c (ignored) + -C install only if different (preserve the last data modification time) + -d create directories instead of installing files. + -g GROUP $chgrpprog installed files to GROUP. + -m MODE $chmodprog installed files to MODE. + -o USER $chownprog installed files to USER. + -s $stripprog installed files. + -t DIRECTORY install into DIRECTORY. + -T report an error if DSTFILE is a directory. -# Skip lots of stat calls in the usual case. -if [ ! -d "$dstdir" ]; then -defaultIFS=' - ' -IFS="${IFS-${defaultIFS}}" +Environment variables override the default commands: + CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG + RMPROG STRIPPROG +" -oIFS="${IFS}" -# Some sh's can't handle IFS=/ for some reason. -IFS='%' -set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` -IFS="${oIFS}" +while test $# -ne 0; do + case $1 in + -c) ;; -pathcomp='' + -C) copy_on_change=true;; -while [ $# -ne 0 ] ; do - pathcomp="${pathcomp}${1}" - shift + -d) dir_arg=true;; - if [ ! -d "${pathcomp}" ] ; - then - $mkdirprog "${pathcomp}" - else - true - fi + -g) chgrpcmd="$chgrpprog $2" + shift;; - pathcomp="${pathcomp}/" -done -fi + --help) echo "$usage"; exit $?;; -if [ x"$dir_arg" != x ] -then - $doit $instcmd $dst && + -m) mode=$2 + case $mode in + *' '* | *' '* | *' +'* | *'*'* | *'?'* | *'['*) + echo "$0: invalid mode: $mode" >&2 + exit 1;; + esac + shift;; - if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && - if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && - if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && - if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi -else + -o) chowncmd="$chownprog $2" + shift;; -# If we're going to rename the final executable, determine the name now. + -s) stripcmd=$stripprog;; - if [ x"$transformarg" = x ] - then - dstfile=`basename $dst` - else - dstfile=`basename $dst $transformbasename | - sed $transformarg`$transformbasename - fi + -t) dst_arg=$2 + shift;; -# don't allow the sed command to completely eliminate the filename + -T) no_target_directory=true;; - if [ x"$dstfile" = x ] - then - dstfile=`basename $dst` - else - true - fi - -# Make a temp file name in the proper directory. + --version) echo "$0 $scriptversion"; exit $?;; - dsttmp=$dstdir/#inst.$$# + --) shift + break;; -# Move or copy the file name to the temp name + -*) echo "$0: invalid option: $1" >&2 + exit 1;; - $doit $instcmd $src $dsttmp && - - trap "rm -f ${dsttmp}" 0 && + *) break;; + esac + shift +done -# and set any options; do chmod last to preserve setuid bits +if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then + # When -d is used, all remaining arguments are directories to create. + # When -t is used, the destination is already specified. + # Otherwise, the last argument is the destination. Remove it from $@. + for arg + do + if test -n "$dst_arg"; then + # $@ is not empty: it contains at least $arg. + set fnord "$@" "$dst_arg" + shift # fnord + fi + shift # arg + dst_arg=$arg + done +fi -# If any of these fail, we abort the whole thing. If we want to -# ignore errors from any of these, just make sure not to ignore -# errors from the above "$doit $instcmd $src $dsttmp" command. +if test $# -eq 0; then + if test -z "$dir_arg"; then + echo "$0: no input file specified." >&2 + exit 1 + fi + # It's OK to call `install-sh -d' without argument. + # This can happen when creating conditional directories. + exit 0 +fi - if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && - if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && - if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && - if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && +if test -z "$dir_arg"; then + trap '(exit $?); exit' 1 2 13 15 + + # Set umask so as not to create temps with too-generous modes. + # However, 'strip' requires both read and write access to temps. + case $mode in + # Optimize common cases. + *644) cp_umask=133;; + *755) cp_umask=22;; + + *[0-7]) + if test -z "$stripcmd"; then + u_plus_rw= + else + u_plus_rw='% 200' + fi + cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; + *) + if test -z "$stripcmd"; then + u_plus_rw= + else + u_plus_rw=,u+rw + fi + cp_umask=$mode$u_plus_rw;; + esac +fi -# Now rename the file to the real destination. +for src +do + # Protect names starting with `-'. + case $src in + -*) src=./$src;; + esac + + if test -n "$dir_arg"; then + dst=$src + dstdir=$dst + test -d "$dstdir" + dstdir_status=$? + else + + # Waiting for this to be detected by the "$cpprog $src $dsttmp" command + # might cause directories to be created, which would be especially bad + # if $src (and thus $dsttmp) contains '*'. + if test ! -f "$src" && test ! -d "$src"; then + echo "$0: $src does not exist." >&2 + exit 1 + fi + + if test -z "$dst_arg"; then + echo "$0: no destination specified." >&2 + exit 1 + fi + + dst=$dst_arg + # Protect names starting with `-'. + case $dst in + -*) dst=./$dst;; + esac - $doit $rmcmd -f $dstdir/$dstfile && - $doit $mvcmd $dsttmp $dstdir/$dstfile + # If destination is a directory, append the input filename; won't work + # if double slashes aren't ignored. + if test -d "$dst"; then + if test -n "$no_target_directory"; then + echo "$0: $dst_arg: Is a directory" >&2 + exit 1 + fi + dstdir=$dst + dst=$dstdir/`basename "$src"` + dstdir_status=0 + else + # Prefer dirname, but fall back on a substitute if dirname fails. + dstdir=` + (dirname "$dst") 2>/dev/null || + expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$dst" : 'X\(//\)[^/]' \| \ + X"$dst" : 'X\(//\)$' \| \ + X"$dst" : 'X\(/\)' \| . 2>/dev/null || + echo X"$dst" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q' + ` + + test -d "$dstdir" + dstdir_status=$? + fi + fi + + obsolete_mkdir_used=false + + if test $dstdir_status != 0; then + case $posix_mkdir in + '') + # Create intermediate dirs using mode 755 as modified by the umask. + # This is like FreeBSD 'install' as of 1997-10-28. + umask=`umask` + case $stripcmd.$umask in + # Optimize common cases. + *[2367][2367]) mkdir_umask=$umask;; + .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; + + *[0-7]) + mkdir_umask=`expr $umask + 22 \ + - $umask % 100 % 40 + $umask % 20 \ + - $umask % 10 % 4 + $umask % 2 + `;; + *) mkdir_umask=$umask,go-w;; + esac + + # With -d, create the new directory with the user-specified mode. + # Otherwise, rely on $mkdir_umask. + if test -n "$dir_arg"; then + mkdir_mode=-m$mode + else + mkdir_mode= + fi -fi && + posix_mkdir=false + case $umask in + *[123567][0-7][0-7]) + # POSIX mkdir -p sets u+wx bits regardless of umask, which + # is incompatible with FreeBSD 'install' when (umask & 300) != 0. + ;; + *) + tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ + trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 + + if (umask $mkdir_umask && + exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 + then + if test -z "$dir_arg" || { + # Check for POSIX incompatibilities with -m. + # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or + # other-writeable bit of parent directory when it shouldn't. + # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. + ls_ld_tmpdir=`ls -ld "$tmpdir"` + case $ls_ld_tmpdir in + d????-?r-*) different_mode=700;; + d????-?--*) different_mode=755;; + *) false;; + esac && + $mkdirprog -m$different_mode -p -- "$tmpdir" && { + ls_ld_tmpdir_1=`ls -ld "$tmpdir"` + test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" + } + } + then posix_mkdir=: + fi + rmdir "$tmpdir/d" "$tmpdir" + else + # Remove any dirs left behind by ancient mkdir implementations. + rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null + fi + trap '' 0;; + esac;; + esac + if + $posix_mkdir && ( + umask $mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" + ) + then : + else + + # The umask is ridiculous, or mkdir does not conform to POSIX, + # or it failed possibly due to a race condition. Create the + # directory the slow way, step by step, checking for races as we go. + + case $dstdir in + /*) prefix='/';; + -*) prefix='./';; + *) prefix='';; + esac + + eval "$initialize_posix_glob" + + oIFS=$IFS + IFS=/ + $posix_glob set -f + set fnord $dstdir + shift + $posix_glob set +f + IFS=$oIFS + + prefixes= + + for d + do + test -z "$d" && continue + + prefix=$prefix$d + if test -d "$prefix"; then + prefixes= + else + if $posix_mkdir; then + (umask=$mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break + # Don't fail if two instances are running concurrently. + test -d "$prefix" || exit 1 + else + case $prefix in + *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; + *) qprefix=$prefix;; + esac + prefixes="$prefixes '$qprefix'" + fi + fi + prefix=$prefix/ + done + + if test -n "$prefixes"; then + # Don't fail if two instances are running concurrently. + (umask $mkdir_umask && + eval "\$doit_exec \$mkdirprog $prefixes") || + test -d "$dstdir" || exit 1 + obsolete_mkdir_used=true + fi + fi + fi + + if test -n "$dir_arg"; then + { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && + { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && + { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || + test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 + else + + # Make a couple of temp file names in the proper directory. + dsttmp=$dstdir/_inst.$$_ + rmtmp=$dstdir/_rm.$$_ + + # Trap to clean up those temp files at exit. + trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 + + # Copy the file name to the temp name. + (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && + + # and set any options; do chmod last to preserve setuid bits. + # + # If any of these fail, we abort the whole thing. If we want to + # ignore errors from any of these, just make sure not to ignore + # errors from the above "$doit $cpprog $src $dsttmp" command. + # + { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && + { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && + { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && + { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && + + # If -C, don't bother to copy if it wouldn't change the file. + if $copy_on_change && + old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && + new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && + + eval "$initialize_posix_glob" && + $posix_glob set -f && + set X $old && old=:$2:$4:$5:$6 && + set X $new && new=:$2:$4:$5:$6 && + $posix_glob set +f && + + test "$old" = "$new" && + $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 + then + rm -f "$dsttmp" + else + # Rename the file to the real destination. + $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || + + # The rename failed, perhaps because mv can't rename something else + # to itself, or perhaps because mv is so ancient that it does not + # support -f. + { + # Now remove or move aside any old file at destination location. + # We try this two ways since rm can't unlink itself on some + # systems and the destination file might be busy for other + # reasons. In this case, the final cleanup might fail but the new + # file should still install successfully. + { + test ! -f "$dst" || + $doit $rmcmd -f "$dst" 2>/dev/null || + { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && + { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } + } || + { echo "$0: cannot unlink or rename $dst" >&2 + (exit 1); exit 1 + } + } && + + # Now rename the file to the real destination. + $doit $mvcmd "$dsttmp" "$dst" + } + fi || exit 1 + + trap '' 0 + fi +done -exit 0 +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-time-zone: "UTC" +# time-stamp-end: "; # UTC" +# End: @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Id: configure.in 17309 2009-08-06 19:13:07Z koziol . +# From configure.in Id: configure.in 17347 2009-08-12 22:04:35Z koziol . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.64 for HDF5 1.9.45-FA_a3. # @@ -500,6 +500,7 @@ static const char * H5AC_entry_type_names[H5AC_NTYPES] = "fixed array headers", "fixed array data block", "fixed array data block pages", + "superblock", "test entry" /* for testing only -- not used for actual files */ }; diff --git a/src/H5ACprivate.h b/src/H5ACprivate.h index b58d24f..f264401 100644 --- a/src/H5ACprivate.h +++ b/src/H5ACprivate.h @@ -71,6 +71,7 @@ typedef enum { H5AC_FARRAY_HDR_ID, /*fixed array header */ H5AC_FARRAY_DBLOCK_ID, /*fixed array data block */ H5AC_FARRAY_DBLK_PAGE_ID, /*fixed array data block page */ + H5AC_SUPERBLOCK_ID, /* file superblock */ H5AC_TEST_ID, /*test entry -- not used for actual files */ H5AC_NTYPES /* Number of types, must be last */ } H5AC_type_t; diff --git a/src/H5Bcache.c b/src/H5Bcache.c index a3b49e9..0424134 100644 --- a/src/H5Bcache.c +++ b/src/H5Bcache.c @@ -355,7 +355,7 @@ H5B_dest(H5F_t *f, H5B_t *bt) } /* end if */ /* Release resources for B-tree node */ - H5FL_SEQ_FREE(haddr_t, bt->child); + bt->child = H5FL_SEQ_FREE(haddr_t, bt->child); bt->native = H5FL_BLK_FREE(native_block, bt->native); H5RC_DEC(bt->rc_shared); bt = H5FL_FREE(H5B_t, bt); @@ -6274,6 +6274,10 @@ H5C_protect(H5F_t * f, if ( entry_ptr != NULL ) { + /* Check for trying to load the wrong type of entry from an address */ + if(entry_ptr->type != type) + HGOTO_ERROR(H5E_CACHE, H5E_BADTYPE, NULL, "not a dataset creation property list") + hit = TRUE; thing = (void *)entry_ptr; diff --git a/src/H5Cpkg.h b/src/H5Cpkg.h index 4bc105d..719dec9 100644 --- a/src/H5Cpkg.h +++ b/src/H5Cpkg.h @@ -857,7 +857,7 @@ ****************************************************************************/ #define H5C__H5C_T_MAGIC 0x005CAC0E -#define H5C__MAX_NUM_TYPE_IDS 25 +#define H5C__MAX_NUM_TYPE_IDS 26 #define H5C__PREFIX_LEN 32 struct H5C_t diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index 5acee1f..2c8ef5d 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -4068,7 +4068,9 @@ H5D_chunk_delete(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5O_storage_t *storage) { H5D_chk_idx_info_t idx_info; /* Chunked index info */ H5O_layout_t layout; /* Dataset layout message */ + hbool_t layout_read = FALSE; /* Whether the layout message was read from the file */ H5O_pline_t pline; /* I/O pipeline message */ + hbool_t pline_read = FALSE; /* Whether the I/O pipeline message was read from the file */ htri_t exists; /* Flag if header message of interest exists */ herr_t ret_value = SUCCEED; /* Return value */ @@ -4091,6 +4093,7 @@ H5D_chunk_delete(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5O_storage_t *storage) else if(exists) { if(NULL == H5O_msg_read_oh(f, dxpl_id, oh, H5O_PLINE_ID, &pline)) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get I/O pipeline message") + pline_read = TRUE; } /* end else if */ else HDmemset(&pline, 0, sizeof(pline)); @@ -4101,6 +4104,7 @@ H5D_chunk_delete(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5O_storage_t *storage) else if(exists) { if(NULL == H5O_msg_read_oh(f, dxpl_id, oh, H5O_LAYOUT_ID, &layout)) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get layout message") + layout_read = TRUE; } /* end else if */ else HGOTO_ERROR(H5E_DATASET, H5E_NOTFOUND, FAIL, "can't find layout message") @@ -4117,6 +4121,14 @@ H5D_chunk_delete(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5O_storage_t *storage) HGOTO_ERROR(H5E_DATASET, H5E_CANTDELETE, FAIL, "unable to delete chunk index") done: + /* Clean up any messages read in */ + if(pline_read) + if(H5O_msg_reset(H5O_PLINE_ID, &pline) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, FAIL, "unable to reset I/O pipeline message") + if(layout_read) + if(H5O_msg_reset(H5O_LAYOUT_ID, &layout) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, FAIL, "unable to reset layout message") + FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_chunk_delete() */ @@ -861,23 +861,20 @@ H5F_new(H5F_file_t *shared, hid_t fcpl_id, hid_t fapl_id, H5FD_t *lf) f->shared = shared; } /* end if */ else { - unsigned super_vers = HDF5_SUPERBLOCK_VERSION_DEF; /* Superblock version for file */ H5P_genplist_t *plist; /* Property list */ size_t u; /* Local index variable */ HDassert(lf != NULL); if(NULL == (f->shared = H5FL_CALLOC(H5F_file_t))) HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, NULL, "can't allocate shared file structure") - f->shared->base_addr = HADDR_UNDEF; - f->shared->extension_addr = HADDR_UNDEF; + + f->shared->super_addr = HADDR_UNDEF; f->shared->sohm_addr = HADDR_UNDEF; f->shared->sohm_vers = HDF5_SHAREDHEADER_VERSION; for(u = 0; u < NELMTS(f->shared->fs_addr); u++) f->shared->fs_addr[u] = HADDR_UNDEF; - f->shared->driver_addr = HADDR_UNDEF; f->shared->accum.loc = HADDR_UNDEF; f->shared->lf = lf; - f->shared->root_addr = HADDR_UNDEF; /* * Copy the file creation and file access property lists into the @@ -893,10 +890,6 @@ H5F_new(H5F_file_t *shared, hid_t fcpl_id, hid_t fapl_id, H5FD_t *lf) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get byte number for address") if(H5P_get(plist, H5F_CRT_OBJ_BYTE_NUM_NAME, &f->shared->sizeof_size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get byte number for object size") - if(H5P_get(plist, H5F_CRT_SYM_LEAF_NAME, &f->shared->sym_leaf_k) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get byte number for object size") - if(H5P_get(plist, H5F_CRT_BTREE_RANK_NAME, &f->shared->btree_k[0]) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "unable to get rank for btree internal nodes") if(H5P_get(plist, H5F_CRT_SHMSG_NINDEXES_NAME, &f->shared->sohm_nindexes)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get number of SOHM indexes") HDassert(f->shared->sohm_nindexes < 255); @@ -951,29 +944,6 @@ H5F_new(H5F_file_t *shared, hid_t fcpl_id, hid_t fapl_id, H5FD_t *lf) */ f->shared->use_tmp_space = !(IS_H5FD_MPI(f)); - /* Bump superblock version if we are to use the latest version of the format */ - if(f->shared->latest_format) - super_vers = HDF5_SUPERBLOCK_VERSION_LATEST; - /* Bump superblock version to create superblock extension for SOHM info */ - else if(f->shared->sohm_nindexes > 0) - super_vers = HDF5_SUPERBLOCK_VERSION_2; - /* Check for non-default indexed storage B-tree internal 'K' value - * and set the version # of the superblock to 1 if it is a non-default - * value. - */ - else if(f->shared->btree_k[H5B_CHUNK_ID] != HDF5_BTREE_CHUNK_IK_DEF) - super_vers = HDF5_SUPERBLOCK_VERSION_1; - - /* If a newer superblock version is required, set it here */ - if(super_vers != HDF5_SUPERBLOCK_VERSION_DEF) { - H5P_genplist_t *c_plist; /* Property list */ - - if(NULL == (c_plist = (H5P_genplist_t *)H5I_object(f->shared->fcpl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not property list") - if(H5P_set(c_plist, H5F_CRT_SUPER_VERS_NAME, &super_vers) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, NULL, "unable to set superblock version") - } /* end if */ - /* * Create a metadata cache with the specified number of elements. * The cache might be created with a different number of elements and @@ -1050,8 +1020,20 @@ H5F_dest(H5F_t *f, hid_t dxpl_id) H5AC_stats(f); #endif /* H5AC_DUMP_STATS_ON_CLOSE */ - /* Flush and invalidate all caches */ - if(H5F_flush(f, dxpl_id, H5F_SCOPE_LOCAL, H5F_FLUSH_INVALIDATE | H5F_FLUSH_CLOSING) < 0) + /* Flush all caches and indicate we are closing the file */ + if(H5F_flush(f, dxpl_id, H5F_SCOPE_LOCAL, H5F_FLUSH_CLOSING) < 0) + /* Push error, but keep going*/ + HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush cache") + + /* Unpin the superblock, since we're about to destroy the cache */ + if(H5AC_unpin_entry(f, f->shared->sblock) < 0) + /* Push error, but keep going*/ + HDONE_ERROR(H5E_FSPACE, H5E_CANTUNPIN, FAIL, "unable to unpin superblock") + f->shared->sblock = NULL; + + /* Flush all caches and indicate all cached objects should be invalidated */ + /* (The caches should already be clean and we should just be invalidating objects) */ + if(H5F_flush(f, dxpl_id, H5F_SCOPE_LOCAL, H5F_FLUSH_INVALIDATE) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush cache") } /* end if */ @@ -1110,9 +1092,6 @@ H5F_dest(H5F_t *f, hid_t dxpl_id) f->shared->mtab.child = (H5F_mount_t *)H5MM_xfree(f->shared->mtab.child); f->shared->mtab.nalloc = 0; - /* Free root group symbol table entry, if any */ - f->shared->root_ent = (H5G_entry_t *)H5MM_xfree(f->shared->root_ent); - /* Destroy shared file struct */ f->shared = (H5F_file_t *)H5FL_FREE(H5F_file_t, f->shared); @@ -1300,22 +1279,6 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t d file->intent = flags; file->name = H5MM_xstrdup(name); - /* Get the file access property list, for future queries */ - if(NULL == (a_plist = (H5P_genplist_t *)H5I_object(fapl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not file access property list") - - /* This step is for h5repart tool only. If user wants to change file driver from - * family to sec2 while using h5repart, this private property should be set so that - * in the later step, the library can ignore the family driver information saved - * in the superblock. - */ - if(H5P_exist_plist(a_plist, H5F_ACS_FAMILY_TO_SEC2_NAME) > 0) { - if(H5P_get(a_plist, H5F_ACS_FAMILY_TO_SEC2_NAME, &shared->fam_to_sec2) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property of changing family to sec2") - } /* end if */ - else - shared->fam_to_sec2 = FALSE; - /* * Read or write the file superblock, depending on whether the file is * empty or not. @@ -1337,13 +1300,6 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t d */ if(H5G_mkroot(file, dxpl_id, TRUE) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to create/open root group") - - /* Write the superblock to the file */ - /* (This must be after the root group is created, since the root - * group's symbol table entry is part of the superblock) - */ - if(H5F_super_write(file, dxpl_id) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to write file superblock") } else if (1 == shared->nrefs) { /* Read the superblock if it hasn't been read before. */ if(H5F_super_read(file, dxpl_id) < 0) @@ -1358,7 +1314,7 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t d * file by the application performing SWMR write operations. */ /* (Account for the stored EOA being absolute offset -NAF) */ - if(H5FD_set_eoa(lf, H5FD_MEM_SUPER, (file->shared->maxaddr - file->shared->base_addr)) < 0) + if(H5FD_set_eoa(lf, H5FD_MEM_SUPER, (file->shared->maxaddr - file->shared->sblock->base_addr)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, NULL, "can't relax 'eoa' for SWMR read access") } /* end if */ @@ -1367,6 +1323,10 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t d HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to read root group") } /* end if */ + /* Get the file access property list, for future queries */ + if(NULL == (a_plist = (H5P_genplist_t *)H5I_object(fapl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not file access property list") + /* * Decide the file close degree. If it's the first time to open the * file, set the degree to access property list value; if it's the @@ -1748,13 +1708,6 @@ H5F_flush(H5F_t *f, hid_t dxpl_id, H5F_scope_t scope, unsigned flags) if(H5FD_truncate(f->shared->lf, dxpl_id, (unsigned)((flags & H5F_FLUSH_CLOSING) > 0)) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "low level truncate failed") - /* Write the superblock to disk */ - /* (needs to happen before metadata flush (H5AC_flush), since the information - * in the superblock extension may be updated - 2008/10/14, QAK) - */ - if(H5F_super_write(f, dxpl_id) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_WRITEERROR, FAIL, "unable to write superblock to file") - /* Flush (and invalidate, if requested) the entire metadata cache */ H5AC_flags = 0; if((flags & H5F_FLUSH_INVALIDATE) != 0 ) @@ -555,7 +555,6 @@ done: * Purpose: Decodes the driver information block. * * Return: Success: Non-negative - * * Failure: Negative * * Programmer: Robb Matzke @@ -566,18 +565,17 @@ done: herr_t H5FD_sb_decode(H5FD_t *file, const char *name, const uint8_t *buf) { - herr_t ret_value=SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_sb_decode, FAIL) - assert(file && file->cls); - if(file->cls->sb_decode && - (file->cls->sb_decode)(file, name, buf) < 0) + HDassert(file && file->cls); + if(file->cls->sb_decode && (file->cls->sb_decode)(file, name, buf) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "driver sb_decode request failed") done: FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5FD_sb_decode() */ /*------------------------------------------------------------------------- @@ -1407,10 +1405,6 @@ done: * Programmer: Robb Matzke * Tuesday, July 27, 1999 * - * Modifications: - * Vailin Choi, 29th July 2008 - * Two more parameters were added to H5FD_alloc() for handling alignment - * *------------------------------------------------------------------------- */ haddr_t @@ -1435,7 +1429,7 @@ H5FDalloc(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, HADDR_UNDEF, "not a data transfer property list") /* Do the real work */ - if(HADDR_UNDEF == (ret_value = H5FD_alloc(file, dxpl_id, type, size, NULL, NULL))) + if(HADDR_UNDEF == (ret_value = H5FD_alloc_real(file, dxpl_id, type, size, NULL, NULL))) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, HADDR_UNDEF, "unable to allocate file memory") /* (Note compensating for base address subtraction in internal routine) */ @@ -1488,7 +1482,7 @@ H5FDfree(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t siz /* Do the real work */ /* (Note compensating for base address addition in internal routine) */ - if(H5FD_free(file, dxpl_id, type, addr - file->base_addr, size) < 0) + if(H5FD_free_real(file, dxpl_id, type, addr - file->base_addr, size) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTFREE, FAIL, "file deallocation request failed") done: diff --git a/src/H5FDfamily.c b/src/H5FDfamily.c index e259a4e..9817270 100644 --- a/src/H5FDfamily.c +++ b/src/H5FDfamily.c @@ -61,14 +61,19 @@ typedef struct H5FD_family_t { hid_t memb_fapl_id; /*file access property list for members */ hsize_t memb_size; /*actual size of each member file */ hsize_t pmem_size; /*member size passed in from property */ - hsize_t mem_newsize; /*new member size passed in as private - *property. It's used only by h5repart */ unsigned nmembs; /*number of family members */ unsigned amembs; /*number of member slots allocated */ H5FD_t **memb; /*dynamic array of member pointers */ haddr_t eoa; /*end of allocated addresses */ char *name; /*name generator printf format */ unsigned flags; /*flags for opening additional members */ + + /* Information from properties set by 'h5repart' tool */ + hsize_t mem_newsize; /*new member size passed in as private + * property. It's used only by h5repart */ + hbool_t repart_members; /* Whether to mark the superblock dirty + * when it is loaded, so that the family + * member sizes can be re-encoded */ } H5FD_family_t; /* Driver-specific file access properties */ @@ -741,9 +746,7 @@ H5FD_family_open(const char *name, unsigned flags, hid_t fapl_id, H5FD_t *ret_value=NULL; char memb_name[4096], temp[4096]; hsize_t eof=HADDR_UNDEF; - hsize_t fam_newsize = 0; unsigned t_flags = flags & ~H5F_ACC_CREAT; - H5P_genplist_t *plist; /* Property list pointer */ FUNC_ENTER_NOAPI(H5FD_family_open, NULL) @@ -765,6 +768,7 @@ H5FD_family_open(const char *name, unsigned flags, hid_t fapl_id, file->mem_newsize = 0; /*New member size used by h5repart only */ } /* end if */ else { + H5P_genplist_t *plist; /* Property list pointer */ H5FD_family_fapl_t *fa; if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) @@ -772,11 +776,19 @@ H5FD_family_open(const char *name, unsigned flags, hid_t fapl_id, fa = (H5FD_family_fapl_t *)H5P_get_driver_info(plist); HDassert(fa); - /* New family file size. It's used by h5repart only. */ - if(H5P_exist_plist(plist, H5F_ACS_FAMILY_NEWSIZE_NAME) > 0) + /* Check for new family file size. It's used by h5repart only. */ + if(H5P_exist_plist(plist, H5F_ACS_FAMILY_NEWSIZE_NAME) > 0) { + hsize_t fam_newsize = 0; /* New member size, when repartitioning */ + + /* Get the new family file size */ if(H5P_get(plist, H5F_ACS_FAMILY_NEWSIZE_NAME, &fam_newsize) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get new family member size") + /* Store information for later */ + file->mem_newsize = fam_newsize; /* New member size passed in through property */ + file->repart_members = TRUE; + } /* end if */ + if(fa->memb_fapl_id==H5P_FILE_ACCESS_DEFAULT) { if(H5I_inc_ref(fa->memb_fapl_id, FALSE)<0) HGOTO_ERROR(H5E_VFL, H5E_CANTINC, NULL, "unable to increment ref count on VFL driver") @@ -789,7 +801,6 @@ H5FD_family_open(const char *name, unsigned flags, hid_t fapl_id, } /* end else */ file->memb_size = fa->memb_size; /* Actual member size to be updated later */ file->pmem_size = fa->memb_size; /* Member size passed in through property */ - file->mem_newsize = fam_newsize; /* New member size passed in through property */ } /* end else */ file->name = H5MM_strdup(name); file->flags = flags; @@ -797,8 +808,7 @@ H5FD_family_open(const char *name, unsigned flags, hid_t fapl_id, /* Check that names are unique */ sprintf(memb_name, name, 0); sprintf(temp, name, 1); - - if (!strcmp(memb_name, temp)) + if(!HDstrcmp(memb_name, temp)) HGOTO_ERROR(H5E_FILE, H5E_FILEEXISTS, NULL, "file names not unique") /* Open all the family members */ @@ -968,23 +978,20 @@ done: * (listed in H5FDpublic.h) * * Return: Success: non-negative - * * Failure: negative * * Programmer: Quincey Koziol * Friday, August 25, 2000 * - * Modifications: - * *------------------------------------------------------------------------- */ /* ARGSUSED */ static herr_t -H5FD_family_query(const H5FD_t UNUSED * _f, unsigned long *flags /* out */) +H5FD_family_query(const H5FD_t * _file, unsigned long *flags /* out */) { - herr_t ret_value = SUCCEED; + const H5FD_family_t *file = (const H5FD_family_t*)_file; /* Family VFD info */ - FUNC_ENTER_NOAPI(H5FD_family_query, FAIL) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FD_family_query) /* Set the VFL feature flags that this driver supports */ if(flags) { @@ -993,10 +1000,13 @@ H5FD_family_query(const H5FD_t UNUSED * _f, 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 */ + + /* Check for flags that are set by h5repart */ + if(file->repart_members) + *flags |= H5FD_FEAT_DIRTY_SBLK_LOAD; /* Mark the superblock dirty when it is loaded (so the family member sizes are rewritten) */ } /* end if */ -done: - FUNC_LEAVE_NOAPI(ret_value) + FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD_family_query() */ diff --git a/src/H5FDmulti.c b/src/H5FDmulti.c index e0421a7..328b530 100644 --- a/src/H5FDmulti.c +++ b/src/H5FDmulti.c @@ -837,8 +837,6 @@ H5FD_multi_sb_encode(H5FD_t *_file, char *name/*out*/, * Programmer: Robb Matzke * Monday, August 16, 1999 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t diff --git a/src/H5FDpkg.h b/src/H5FDpkg.h index 9401b52..7c0988e 100644 --- a/src/H5FDpkg.h +++ b/src/H5FDpkg.h @@ -53,6 +53,10 @@ /* Package Private Prototypes */ /******************************/ H5_DLL herr_t H5FD_init(void); +H5_DLL haddr_t H5FD_alloc_real(H5FD_t *file, hid_t dxpl_id, H5FD_mem_t type, + hsize_t size, haddr_t *align_addr, hsize_t *align_size); +H5_DLL herr_t H5FD_free_real(H5FD_t *file, hid_t dxpl_id, H5FD_mem_t type, + haddr_t addr, hsize_t size); /* Testing routines */ diff --git a/src/H5FDprivate.h b/src/H5FDprivate.h index 25b2f24..6b2e4fe 100644 --- a/src/H5FDprivate.h +++ b/src/H5FDprivate.h @@ -35,6 +35,7 @@ /* Forward declarations for prototype arguments */ struct H5P_genplist_t; +struct H5F_t; /* Prototypes */ H5_DLL int H5FD_term_interface(void); @@ -55,10 +56,12 @@ H5_DLL H5FD_t *H5FD_open(const char *name, unsigned flags, hid_t fapl_id, H5_DLL herr_t H5FD_close(H5FD_t *file); H5_DLL int H5FD_cmp(const H5FD_t *f1, const H5FD_t *f2); H5_DLL int H5FD_query(const H5FD_t *f, unsigned long *flags/*out*/); -H5_DLL haddr_t H5FD_alloc(H5FD_t *file, hid_t dxpl_id, H5FD_mem_t type, hsize_t size, haddr_t *align_addr, hsize_t *align_size); -H5_DLL herr_t H5FD_free(H5FD_t *file, hid_t dxpl_id, H5FD_mem_t type, haddr_t addr, hsize_t size); -H5_DLL htri_t H5FD_try_extend(H5FD_t *file, H5FD_mem_t type, haddr_t blk_end, - hsize_t extra_requested); +H5_DLL haddr_t H5FD_alloc(H5FD_t *file, hid_t dxpl_id, H5FD_mem_t type, struct H5F_t *f, + hsize_t size, haddr_t *align_addr, hsize_t *align_size); +H5_DLL herr_t H5FD_free(H5FD_t *file, hid_t dxpl_id, H5FD_mem_t type, struct H5F_t *f, + haddr_t addr, hsize_t size); +H5_DLL htri_t H5FD_try_extend(H5FD_t *file, H5FD_mem_t type, struct H5F_t *f, + haddr_t blk_end, hsize_t extra_requested); H5_DLL haddr_t H5FD_get_eoa(const H5FD_t *file, H5FD_mem_t type); H5_DLL herr_t H5FD_set_eoa(H5FD_t *file, H5FD_mem_t type, haddr_t addr); H5_DLL haddr_t H5FD_get_eof(const H5FD_t *file); diff --git a/src/H5FDpublic.h b/src/H5FDpublic.h index fde8556..ed24506 100644 --- a/src/H5FDpublic.h +++ b/src/H5FDpublic.h @@ -190,6 +190,20 @@ typedef enum H5F_mem_t H5FD_mem_t; * and then sub-allocate "small" raw data requests from that larger block. */ #define H5FD_FEAT_AGGREGATE_SMALLDATA 0x00000010 + /* + * Defining the H5FD_FEAT_IGNORE_DRVRINFO for a VFL driver means that + * the library will ignore the driver info that is encoded in the file + * for the VFL driver. (This will cause the driver info to be eliminated + * from the file when it is flushed/closed, if the file is opened R/W). + */ +#define H5FD_FEAT_IGNORE_DRVRINFO 0x00000020 + /* + * Defining the H5FD_FEAT_DIRTY_SBLK_LOAD for a VFL driver means that + * the library will mark the superblock dirty when the file is opened + * R/W. This will cause the driver info to be re-encoded when the file + * is flushed/closed. + */ +#define H5FD_FEAT_DIRTY_SBLK_LOAD 0x00000040 /* Forward declaration */ diff --git a/src/H5FDsec2.c b/src/H5FDsec2.c index 35ade20..0b4632d 100644 --- a/src/H5FDsec2.c +++ b/src/H5FDsec2.c @@ -90,6 +90,10 @@ typedef struct H5FD_sec2_t { DWORD fileindexlo; DWORD fileindexhi; #endif + + /* Information from properties set by 'h5repart' tool */ + hbool_t fam_to_sec2; /* Whether to eliminate the family driver info + * and convert this file to a single file */ } H5FD_sec2_t; @@ -325,8 +329,7 @@ done: */ /* ARGSUSED */ static H5FD_t * -H5FD_sec2_open(const char *name, unsigned flags, hid_t UNUSED fapl_id, - haddr_t maxaddr) +H5FD_sec2_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) { int o_flags; int fd=(-1); @@ -388,8 +391,26 @@ H5FD_sec2_open(const char *name, unsigned flags, hid_t UNUSED fapl_id, #endif + /* Check for non-default FAPL */ + if(H5P_FILE_ACCESS_DEFAULT != fapl_id) { + H5P_genplist_t *plist; /* Property list pointer */ + + /* Get the FAPL */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") + + /* This step is for h5repart tool only. If user wants to change file driver from + * family to sec2 while using h5repart, this private property should be set so that + * in the later step, the library can ignore the family driver information saved + * in the superblock. + */ + if(H5P_exist_plist(plist, H5F_ACS_FAMILY_TO_SEC2_NAME) > 0) + if(H5P_get(plist, H5F_ACS_FAMILY_TO_SEC2_NAME, &file->fam_to_sec2) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property of changing family to sec2") + } /* end if */ + /* Set return value */ - ret_value=(H5FD_t*)file; + ret_value = (H5FD_t*)file; done: if(ret_value==NULL) { @@ -398,7 +419,7 @@ done: } /* end if */ FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5FD_sec2_open() */ /*------------------------------------------------------------------------- @@ -516,11 +537,11 @@ done: */ /* ARGSUSED */ static herr_t -H5FD_sec2_query(const H5FD_t UNUSED * _f, unsigned long *flags /* out */) +H5FD_sec2_query(const H5FD_t *_file, unsigned long *flags /* out */) { - herr_t ret_value = SUCCEED; /* Return value */ + const H5FD_sec2_t *file = (const H5FD_sec2_t*)_file; /* sec2 VFD info */ - FUNC_ENTER_NOAPI(H5FD_sec2_query, FAIL) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FD_sec2_query) /* Set the VFL feature flags that this driver supports */ if(flags) { @@ -529,10 +550,13 @@ H5FD_sec2_query(const H5FD_t UNUSED * _f, 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 */ + + /* Check for flags that are set by h5repart */ + if(file->fam_to_sec2) + *flags |= H5FD_FEAT_IGNORE_DRVRINFO; /* Ignore the driver info when file is opened (which eliminates it) */ } /* end if */ -done: - FUNC_LEAVE_NOAPI(ret_value) + FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD_sec2_query() */ diff --git a/src/H5FDspace.c b/src/H5FDspace.c index 0fadc1e..5526b03 100644 --- a/src/H5FDspace.c +++ b/src/H5FDspace.c @@ -42,7 +42,6 @@ #include "H5Fprivate.h" /* File access */ #include "H5FDpkg.h" /* File Drivers */ #include "H5FDmulti.h" /* Usage-partitioned file family */ -#include "H5MMprivate.h" /* Memory management */ /****************/ @@ -122,10 +121,6 @@ H5FD_space_init_interface(void) * Programmer: Bill Wendling * Wednesday, 04. December, 2002 * - * Modifications: - * Vailin Choi, 29th July 2008 - * Add 2 more parameters for handling alignment: address and size of the fragment - * *------------------------------------------------------------------------- */ static haddr_t @@ -180,9 +175,9 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_alloc + * Function: H5FD_alloc_real * - * Purpose: Private version of H5FDalloc(). + * Purpose: Allocate space in the file with the VFD * * Return: Success: The format address of the new file memory. * Failure: The undefined address HADDR_UNDEF @@ -190,18 +185,14 @@ done: * Programmer: Robb Matzke * Wednesday, August 4, 1999 * - * Modification: - * Vailin Choi, 29th July 2008 - * Add two more parameters () for handling alignment: address & size of the fragment - * *------------------------------------------------------------------------- */ haddr_t -H5FD_alloc(H5FD_t *file, hid_t dxpl_id, H5FD_mem_t type, hsize_t size, haddr_t *frag_addr, hsize_t *frag_size) +H5FD_alloc_real(H5FD_t *file, hid_t dxpl_id, H5FD_mem_t type, hsize_t size, haddr_t *frag_addr, hsize_t *frag_size) { - haddr_t ret_value = HADDR_UNDEF; + haddr_t ret_value; /* Return value */ - FUNC_ENTER_NOAPI(H5FD_alloc, HADDR_UNDEF) + FUNC_ENTER_NOAPI(H5FD_alloc_real, HADDR_UNDEF) #ifdef H5FD_ALLOC_DEBUG HDfprintf(stderr, "%s: type = %u, size = %Hu\n", FUNC, (unsigned)type, size); #endif /* H5FD_ALLOC_DEBUG */ @@ -230,13 +221,59 @@ done: HDfprintf(stderr, "%s: ret_value = %a\n", FUNC, ret_value); #endif /* H5FD_ALLOC_DEBUG */ FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FD_alloc_real() */ + + +/*------------------------------------------------------------------------- + * Function: H5FD_alloc + * + * Purpose: Wrapper for H5FD_alloc, to make certain EOA changes are + * reflected in superblock. + * + * Note: When the metadata cache routines are updated to allow + * marking an entry dirty without a H5F_t*, this routine should + * be changed to take a H5F_super_t* directly. + * + * Return: Success: The format address of the new file memory. + * Failure: The undefined address HADDR_UNDEF + * + * Programmer: Quincey Koziol + * Friday, August 14, 2009 + * + *------------------------------------------------------------------------- + */ +haddr_t +H5FD_alloc(H5FD_t *file, hid_t dxpl_id, H5FD_mem_t type, H5F_t *f, hsize_t size, + haddr_t *frag_addr, hsize_t *frag_size) +{ + haddr_t ret_value; /* Return value */ + + FUNC_ENTER_NOAPI(H5FD_alloc, HADDR_UNDEF) + + /* check args */ + HDassert(file); + HDassert(file->cls); + HDassert(type >= H5FD_MEM_DEFAULT && type < H5FD_MEM_NTYPES); + HDassert(size > 0); + + /* Call the real 'alloc' routine */ + ret_value = H5FD_alloc_real(file, dxpl_id, type, size, frag_addr, frag_size); + if(!H5F_addr_defined(ret_value)) + HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, HADDR_UNDEF, "real 'alloc' request failed") + + /* Mark superblock dirty in cache, so change to EOA will get encoded */ + if(H5F_super_dirty(f) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTMARKDIRTY, HADDR_UNDEF, "unable to mark superblock as dirty") + +done: + FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_alloc() */ /*------------------------------------------------------------------------- - * Function: H5FD_free + * Function: H5FD_free_real * - * Purpose: Private version of H5FDfree() + * Purpose: Release space back to the VFD * * Return: Success: Non-negative * Failure: Negative @@ -247,11 +284,11 @@ HDfprintf(stderr, "%s: ret_value = %a\n", FUNC, ret_value); *------------------------------------------------------------------------- */ herr_t -H5FD_free(H5FD_t *file, hid_t dxpl_id, H5FD_mem_t type, haddr_t addr, hsize_t size) +H5FD_free_real(H5FD_t *file, hid_t dxpl_id, H5FD_mem_t type, haddr_t addr, hsize_t size) { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5FD_free, FAIL) + FUNC_ENTER_NOAPI_NOINIT(H5FD_free_real) /* Check args */ HDassert(file); @@ -265,14 +302,14 @@ HDfprintf(stderr, "%s: type = %u, addr = %a, size = %Hu\n", FUNC, (unsigned)type /* Sanity checking */ if(!H5F_addr_defined(addr)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file offset") + HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "invalid file offset") /* Convert address to absolute file offset */ addr += file->base_addr; /* More sanity checking */ if(addr > file->maxaddr || H5F_addr_overflow(addr, size) || (addr + size) > file->maxaddr) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file free space region to free") + HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "invalid file free space region to free") /* Check for file driver 'free' callback and call it if available */ if(file->cls->free) { @@ -309,6 +346,51 @@ HDfprintf(stderr, "%s: LEAKED MEMORY!!! type = %u, addr = %a, size = %Hu\n", FUN done: FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FD_free_real() */ + + +/*------------------------------------------------------------------------- + * Function: H5FD_free + * + * Purpose: Wrapper for H5FD_free_real, to make certain EOA changes are + * reflected in superblock. + * + * Note: When the metadata cache routines are updated to allow + * marking an entry dirty without a H5F_t*, this routine should + * be changed to take a H5F_super_t* directly. + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * Friday, August 14, 2009 + * + *------------------------------------------------------------------------- + */ +herr_t +H5FD_free(H5FD_t *file, hid_t dxpl_id, H5FD_mem_t type, H5F_t *f, haddr_t addr, + hsize_t size) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(H5FD_free, FAIL) + + /* Check args */ + HDassert(file); + HDassert(file->cls); + HDassert(type >= H5FD_MEM_DEFAULT && type < H5FD_MEM_NTYPES); + HDassert(size > 0); + + /* Call the real 'free' routine */ + if(H5FD_free_real(file, dxpl_id, type, addr, size) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTFREE, FAIL, "real 'free' request failed") + + /* Mark superblock dirty in cache, so change to EOA will get encoded */ + if(H5F_super_dirty(f) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTMARKDIRTY, FAIL, "unable to mark superblock as dirty") + +done: + FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_free() */ @@ -317,6 +399,10 @@ done: * * Purpose: Extend a block at the end of the file, if possible. * + * Note: When the metadata cache routines are updated to allow + * marking an entry dirty without a H5F_t*, this routine should + * be changed to take a H5F_super_t* directly. + * * Return: Success: TRUE(1) - Block was extended * FALSE(0) - Block could not be extended * Failure: FAIL @@ -324,14 +410,11 @@ done: * Programmer: Quincey Koziol * Thursday, 17. January, 2008 * - * Modification: - * Vailin Choi, 29th July 2008 - * Two more parameters were added to FD_extend() for handling alignment - * *------------------------------------------------------------------------- */ htri_t -H5FD_try_extend(H5FD_t *file, H5FD_mem_t type, haddr_t blk_end, hsize_t extra_requested) +H5FD_try_extend(H5FD_t *file, H5FD_mem_t type, H5F_t *f, haddr_t blk_end, + hsize_t extra_requested) { haddr_t eoa; /* End of allocated space in file */ htri_t ret_value = FALSE; /* Return value */ @@ -343,10 +426,11 @@ H5FD_try_extend(H5FD_t *file, H5FD_mem_t type, haddr_t blk_end, hsize_t extra_re HDassert(file->cls); HDassert(type >= H5FD_MEM_DEFAULT && type < H5FD_MEM_NTYPES); HDassert(extra_requested > 0); + HDassert(f); /* Retrieve the end of the address space */ if(HADDR_UNDEF == (eoa = file->cls->get_eoa(file, type))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "driver get_eoa request failed") + HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "driver get_eoa request failed") /* Adjust block end by base address of the file, to create absolute address */ blk_end += file->base_addr; @@ -355,7 +439,11 @@ H5FD_try_extend(H5FD_t *file, H5FD_mem_t type, haddr_t blk_end, hsize_t extra_re if(H5F_addr_eq(blk_end, eoa)) { /* Extend the object by extending the underlying file */ if(HADDR_UNDEF == H5FD_extend(file, type, FALSE, extra_requested, NULL, NULL)) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTEXTEND, FAIL, "driver extend request failed") + HGOTO_ERROR(H5E_VFL, H5E_CANTEXTEND, FAIL, "driver extend request failed") + + /* Mark superblock dirty in cache, so change to EOA will get encoded */ + if(H5F_super_dirty(f) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTMARKDIRTY, FAIL, "unable to mark superblock as dirty") /* Indicate success */ HGOTO_DONE(TRUE) diff --git a/src/H5FSsection.c b/src/H5FSsection.c index 51229cb..26ff7b9 100644 --- a/src/H5FSsection.c +++ b/src/H5FSsection.c @@ -1124,7 +1124,6 @@ done: } /* H5FS_sect_link() */ - /*------------------------------------------------------------------------- * Function: H5FS_sect_merge * @@ -1508,10 +1507,15 @@ if(_section_) * (or it would have been eliminated), etc) */ if(sect->size >= extra_requested && (addr + size) == sect->addr) { + H5FS_section_class_t *cls; /* Section's class */ + /* Remove section from data structures */ if(H5FS_sect_remove_real(fspace, sect) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, "can't remove section from internal data structures") + /* Get class for section */ + cls = &fspace->sect_cls[sect->type]; + /* Check for the section needing to be adjusted and re-added */ /* (Note: we should probably add a can_adjust/adjust callback * to the section class structure, but we don't need it @@ -1519,11 +1523,6 @@ if(_section_) * it. - QAK - 2008/01/08) */ if(sect->size > extra_requested) { - H5FS_section_class_t *cls; /* Section's class */ - - /* Get class for section */ - cls = &fspace->sect_cls[sect->type]; - /* Sanity check (for now) */ HDassert(cls->flags & H5FS_CLS_ADJUST_OK); @@ -1535,6 +1534,14 @@ if(_section_) if(H5FS_sect_link(fspace, sect, 0) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "can't insert free space section into skip list") } /* end if */ + else { + /* Sanity check */ + HDassert(sect->size == extra_requested); + + /* Exact match, so just free section */ + if((*cls->free)(sect) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, "can't free section") + } /* end else */ /* Note that we modified the section info */ sinfo_modified = TRUE; diff --git a/src/H5Fdbg.c b/src/H5Fdbg.c index a4577c9..5f14357 100644 --- a/src/H5Fdbg.c +++ b/src/H5Fdbg.c @@ -51,7 +51,6 @@ H5F_debug(H5F_t *f, FILE *stream, int indent, int fwidth) { H5P_genplist_t *plist; /* File creation property list */ hsize_t userblock_size; /* Userblock size */ - unsigned super_vers; /* Superblock version # */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5F_debug, FAIL) @@ -61,6 +60,7 @@ H5F_debug(H5F_t *f, FILE *stream, int indent, int fwidth) HDassert(stream); HDassert(indent >= 0); HDassert(fwidth >= 0); + HDassert(f->shared->super_addr != HADDR_UNDEF); /* Get property list */ if(NULL == (plist = (H5P_genplist_t *)H5I_object(f->shared->fcpl_id))) @@ -69,8 +69,6 @@ H5F_debug(H5F_t *f, FILE *stream, int indent, int fwidth) /* Retrieve file creation properties */ if(H5P_get(plist, H5F_CRT_USER_BLOCK_NAME, &userblock_size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get userblock size") - if(H5P_get(plist, H5F_CRT_SUPER_VERS_NAME, &super_vers) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get superblock version") /* debug */ HDfprintf(stream, "%*sFile Super Block...\n", indent, ""); @@ -82,12 +80,12 @@ H5F_debug(H5F_t *f, FILE *stream, int indent, int fwidth) HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "File open reference count:", f->shared->nrefs); HDfprintf(stream, "%*s%-*s %a (abs)\n", indent, "", fwidth, - "Address of super block:", f->shared->base_addr); + "Address of super block:", f->shared->sblock->base_addr); HDfprintf(stream, "%*s%-*s %Hu bytes\n", indent, "", fwidth, "Size of userblock:", userblock_size); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Superblock version number:", super_vers); + "Superblock version number:", f->shared->sblock->super_vers); /* Hard-wired versions */ HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, @@ -102,13 +100,13 @@ H5F_debug(H5F_t *f, FILE *stream, int indent, int fwidth) HDfprintf(stream, "%*s%-*s %u bytes\n", indent, "", fwidth, "Size of file lengths (hsize_t type):", (unsigned) f->shared->sizeof_size); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Symbol table leaf node 1/2 rank:", f->shared->sym_leaf_k); + "Symbol table leaf node 1/2 rank:", f->shared->sblock->sym_leaf_k); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Symbol table internal node 1/2 rank:", f->shared->btree_k[H5B_SNODE_ID]); + "Symbol table internal node 1/2 rank:", f->shared->sblock->btree_k[H5B_SNODE_ID]); HDfprintf(stream, "%*s%-*s 0x%02x\n", indent, "", fwidth, - "File status flags:", (unsigned)(f->shared->status_flags)); + "File status flags:", (unsigned)(f->shared->sblock->status_flags)); HDfprintf(stream, "%*s%-*s %a (rel)\n", indent, "", fwidth, - "Superblock extension address:", f->shared->extension_addr); + "Superblock extension address:", f->shared->sblock->ext_addr); HDfprintf(stream, "%*s%-*s %a (rel)\n", indent, "", fwidth, "Shared object header message table address:", f->shared->sohm_addr); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, @@ -117,14 +115,14 @@ H5F_debug(H5F_t *f, FILE *stream, int indent, int fwidth) "Number of shared object header message indexes:", (unsigned) f->shared->sohm_nindexes); HDfprintf(stream, "%*s%-*s %a (rel)\n", indent, "", fwidth, - "Address of driver information block:", f->shared->driver_addr); + "Address of driver information block:", f->shared->sblock->driver_addr); HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Root group symbol table entry:", f->shared->root_grp ? "" : "(none)"); if(f->shared->root_grp) { - if(f->shared->root_ent) /* Use real root group symbol table entry */ - H5G_ent_debug(f, f->shared->root_ent, stream, indent + 3, + if(f->shared->sblock->root_ent) /* Use real root group symbol table entry */ + H5G_ent_debug(f, f->shared->sblock->root_ent, stream, indent + 3, MAX(0, fwidth - 3), NULL); else { H5O_loc_t *root_oloc; /* Root object location */ @@ -142,7 +140,7 @@ H5F_debug(H5F_t *f, FILE *stream, int indent, int fwidth) /* Display root group symbol table entry info */ H5G_ent_debug(f, &root_ent, stream, indent + 3, MAX(0, fwidth - 3), NULL); - } + } /* end else */ } /* end if */ done: diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h index d0f1b26..c9d2f46 100644 --- a/src/H5Fpkg.h +++ b/src/H5Fpkg.h @@ -71,6 +71,58 @@ /* Macro to abstract checking whether file is using a free space manager */ #define H5F_HAVE_FREE_SPACE_MANAGER(F) TRUE /* Currently always have a free space manager */ +/* Macros for encoding/decoding superblock */ +#define H5F_MAX_DRVINFOBLOCK_SIZE 1024 /* Maximum size of superblock driver info buffer */ +#define H5F_DRVINFOBLOCK_HDR_SIZE 16 /* Size of superblock driver info header */ + +/* Superblock sizes for various versions */ +#define H5F_SIZEOF_CHKSUM 4 /* Checksum size in the file */ + +/* Fixed-size portion at the beginning of all superblocks */ +#define H5F_SUPERBLOCK_FIXED_SIZE ( H5F_SIGNATURE_LEN \ + + 1) /* superblock version */ + +/* Macros for computing variable-size superblock size */ +#define H5F_SUPERBLOCK_VARLEN_SIZE_COMMON \ + (2 /* freespace, and root group versions */ \ + + 1 /* reserved */ \ + + 3 /* shared header vers, size of address, size of lengths */ \ + + 1 /* reserved */ \ + + 4 /* group leaf k, group internal k */ \ + + 4) /* consistency flags */ +#define H5F_SUPERBLOCK_VARLEN_SIZE_V0(f) \ + ( H5F_SUPERBLOCK_VARLEN_SIZE_COMMON /* Common variable-length info */ \ + + H5F_SIZEOF_ADDR(f) /* base address */ \ + + H5F_SIZEOF_ADDR(f) /* <unused> */ \ + + H5F_SIZEOF_ADDR(f) /* EOF address */ \ + + H5F_SIZEOF_ADDR(f) /* driver block address */ \ + + H5G_SIZEOF_ENTRY(f)) /* root group ptr */ +#define H5F_SUPERBLOCK_VARLEN_SIZE_V1(f) \ + ( H5F_SUPERBLOCK_VARLEN_SIZE_COMMON /* Common variable-length info */ \ + + 2 /* indexed B-tree internal k */ \ + + 2 /* reserved */ \ + + H5F_SIZEOF_ADDR(f) /* base address */ \ + + H5F_SIZEOF_ADDR(f) /* <unused> */ \ + + H5F_SIZEOF_ADDR(f) /* EOF address */ \ + + H5F_SIZEOF_ADDR(f) /* driver block address */ \ + + H5G_SIZEOF_ENTRY(f)) /* root group ptr */ +#define H5F_SUPERBLOCK_VARLEN_SIZE_V2(f) \ + ( 2 /* size of address, size of lengths */ \ + + 1 /* consistency flags */ \ + + H5F_SIZEOF_ADDR(f) /* base address */ \ + + H5F_SIZEOF_ADDR(f) /* superblock extension address */ \ + + H5F_SIZEOF_ADDR(f) /* EOF address */ \ + + H5F_SIZEOF_ADDR(f) /* root group object header address */ \ + + H5F_SIZEOF_CHKSUM) /* superblock checksum (keep this last) */ +#define H5F_SUPERBLOCK_VARLEN_SIZE(v, f) ( \ + (v == 0 ? H5F_SUPERBLOCK_VARLEN_SIZE_V0(f) : 0) \ + + (v == 1 ? H5F_SUPERBLOCK_VARLEN_SIZE_V1(f) : 0) \ + + (v == 2 ? H5F_SUPERBLOCK_VARLEN_SIZE_V2(f) : 0)) + +/* Total size of superblock, depends on superblock version */ +#define H5F_SUPERBLOCK_SIZE(v, f) ( H5F_SUPERBLOCK_FIXED_SIZE \ + + H5F_SUPERBLOCK_VARLEN_SIZE(v, f)) + /* Structure for metadata & "small [raw] data" block aggregation fields */ struct H5F_blk_aggr_t { @@ -113,6 +165,23 @@ typedef struct H5F_mtab_t { H5F_mount_t *child; /* An array of mount records */ } H5F_mtab_t; +/* Structure specifically to store superblock. This was originally + * maintained entirely within H5F_file_t, but is now extracted + * here because the superblock is now handled by the cache */ +typedef struct H5F_super_t { + H5AC_info_t cache_info; /* Cache entry information structure */ + unsigned super_vers; /* Superblock version */ + uint8_t status_flags; /* File status flags */ + unsigned sym_leaf_k; /* Size of leaves in symbol tables */ + unsigned btree_k[H5B_NUM_BTREE_ID]; /* B-tree key values for each type */ + haddr_t base_addr; /* Absolute base address for rel.addrs. */ + /* (superblock for file is at this offset) */ + haddr_t ext_addr; /* Relative address of superblock extension */ + haddr_t driver_addr; /* File driver information block address */ + haddr_t root_addr; /* Root group address */ + H5G_entry_t *root_ent; /* Root group symbol table entry */ +} H5F_super_t; + /* * Define the structure to store the file information for HDF5 files. One of * these structures is allocated per file, not per H5Fopen(). That is, set of @@ -122,23 +191,18 @@ typedef struct H5F_mtab_t { */ typedef struct H5F_file_t { H5FD_t *lf; /* Lower level file handle for I/O */ + H5F_super_t *sblock; /* Pointer to (pinned) superblock for file */ + haddr_t super_addr; /* Address of superblock signature */ unsigned nrefs; /* Ref count for times file is opened */ - uint8_t status_flags; /* File status flags */ unsigned flags; /* Access Permissions for file */ H5F_mtab_t mtab; /* File mount table */ /* Cached values from FCPL/superblock */ - unsigned sym_leaf_k; /* Size of leaves in symbol tables */ - unsigned btree_k[H5B_NUM_BTREE_ID]; /* B-tree key values for each type */ size_t sizeof_addr; /* Size of addresses in file */ size_t sizeof_size; /* Size of offsets in file */ - haddr_t base_addr; /* Absolute base address for rel.addrs. */ - /* (superblock for file is at this offset) */ - haddr_t extension_addr; /* Relative address of superblock extension */ haddr_t sohm_addr; /* Relative address of shared object header message table */ unsigned sohm_vers; /* Version of shared message table on disk */ unsigned sohm_nindexes; /* Number of shared messages indexes in the table */ - haddr_t driver_addr; /* File driver information block address*/ unsigned long feature_flags; /* VFL Driver feature Flags */ haddr_t maxaddr; /* Maximum address for file */ @@ -159,12 +223,9 @@ 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? */ - hbool_t fam_to_sec2; /* Is h5repart changing driver from family to sec2? */ int ncwfs; /* Num entries on cwfs list */ struct H5HG_heap_t **cwfs; /* Global heap cache */ struct H5G_t *root_grp; /* Open root group */ - H5G_entry_t *root_ent; /* Root group symbol table entry */ - haddr_t root_addr; /* Root group address */ H5FO_t *open_objs; /* Open objects in file */ H5RC_t *grp_btree_shared; /* Ref-counted group B-tree node info */ @@ -217,6 +278,8 @@ H5FL_EXTERN(H5F_t); /* Declare a free list to manage the H5F_file_t struct */ H5FL_EXTERN(H5F_file_t); +H5_DLLVAR const H5AC_class_t H5AC_SUPERBLOCK[1]; + /******************************/ /* Package Private Prototypes */ @@ -233,10 +296,14 @@ H5_DLL herr_t H5F_mount_count_ids(H5F_t *f, unsigned *nopen_files, unsigned *nop /* Superblock related routines */ H5_DLL herr_t H5F_super_init(H5F_t *f, hid_t dxpl_id); -H5_DLL herr_t H5F_super_write(H5F_t *f, hid_t dxpl_id); H5_DLL herr_t H5F_super_read(H5F_t *f, hid_t dxpl_id); H5_DLL herr_t H5F_super_size(H5F_t *f, hid_t dxpl_id, hsize_t *super_size, hsize_t *super_ext_size); +/* Superblock extension related routines */ +H5_DLL herr_t H5F_super_ext_open(H5F_t *f, haddr_t ext_addr, H5O_loc_t *ext_ptr); +H5_DLL herr_t H5F_super_ext_write_msg(H5F_t *f, hid_t dxpl_id, void *mesg, unsigned id, hbool_t may_create); +H5_DLL herr_t H5F_super_ext_close(H5F_t *f, H5O_loc_t *ext_ptr); + /* Metadata accumulator routines */ H5_DLL htri_t H5F_accum_read(const H5F_t *f, hid_t dxpl_id, H5FD_mem_t type, haddr_t addr, size_t size, void *buf); diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index 1497f03..f2223d0 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -248,12 +248,12 @@ typedef struct H5F_blk_aggr_t H5F_blk_aggr_t; #define H5F_FCPL(F) ((F)->shared->fcpl_id) #define H5F_SIZEOF_ADDR(F) ((F)->shared->sizeof_addr) #define H5F_SIZEOF_SIZE(F) ((F)->shared->sizeof_size) -#define H5F_SYM_LEAF_K(F) ((F)->shared->sym_leaf_k) -#define H5F_KVALUE(F,T) ((F)->shared->btree_k[(T)->id]) +#define H5F_SYM_LEAF_K(F) ((F)->shared->sblock->sym_leaf_k) +#define H5F_KVALUE(F,T) ((F)->shared->sblock->btree_k[(T)->id]) #define H5F_RDCC_NSLOTS(F) ((F)->shared->rdcc_nslots) #define H5F_RDCC_NBYTES(F) ((F)->shared->rdcc_nbytes) #define H5F_RDCC_W0(F) ((F)->shared->rdcc_w0) -#define H5F_BASE_ADDR(F) ((F)->shared->base_addr) +#define H5F_BASE_ADDR(F) ((F)->shared->sblock->base_addr) #define H5F_GRP_BTREE_SHARED(F) ((F)->shared->grp_btree_shared) #define H5F_SIEVE_BUF_SIZE(F) ((F)->shared->sieve_buf_size) #define H5F_GC_REF(F) ((F)->shared->gc_ref) @@ -535,6 +535,9 @@ H5_DLL herr_t H5F_sfile_assert_num(unsigned n); H5_DLL H5F_t *H5F_fake_alloc(size_t sizeof_size); H5_DLL herr_t H5F_fake_free(H5F_t *f); +/* Superblock related routines */ +H5_DLL herr_t H5F_super_dirty(H5F_t *f); + /* Parallel I/O (i.e. MPI) related routines */ #ifdef H5_HAVE_PARALLEL H5_DLL int H5F_mpi_get_rank(const H5F_t *f); diff --git a/src/H5Fquery.c b/src/H5Fquery.c index 564a088..93f2d6e 100644 --- a/src/H5Fquery.c +++ b/src/H5Fquery.c @@ -261,8 +261,9 @@ H5F_sym_leaf_k(const H5F_t *f) HDassert(f); HDassert(f->shared); + HDassert(f->shared->sblock); - FUNC_LEAVE_NOAPI(f->shared->sym_leaf_k) + FUNC_LEAVE_NOAPI(f->shared->sblock->sym_leaf_k) } /* end H5F_sym_leaf_k() */ @@ -292,9 +293,10 @@ H5F_Kvalue(const H5F_t *f, const H5B_class_t *type) HDassert(f); HDassert(f->shared); + HDassert(f->shared->sblock); HDassert(type); - FUNC_LEAVE_NOAPI(f->shared->btree_k[type->id]) + FUNC_LEAVE_NOAPI(f->shared->sblock->btree_k[type->id]) } /* end H5F_Kvalue() */ @@ -413,8 +415,9 @@ H5F_get_base_addr(const H5F_t *f) HDassert(f); HDassert(f->shared); + HDassert(f->shared->sblock); - FUNC_LEAVE_NOAPI(f->shared->base_addr) + FUNC_LEAVE_NOAPI(f->shared->sblock->base_addr) } /* end H5F_get_base_addr() */ diff --git a/src/H5Fsuper.c b/src/H5Fsuper.c index f5973e9..b0096cb 100644 --- a/src/H5Fsuper.c +++ b/src/H5Fsuper.c @@ -26,14 +26,13 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Pprivate.h" /* Property lists */ #include "H5SMprivate.h" /* Shared Object Header Messages */ @@ -41,61 +40,6 @@ /* Local Macros */ /****************/ -/* Superblock sizes for various versions */ -#define H5F_SIZEOF_CHKSUM 4 /* Checksum size in the file */ - -/* Fixed-size portion at the beginning of all superblocks */ -#define H5F_SUPERBLOCK_FIXED_SIZE ( H5F_SIGNATURE_LEN \ - + 1) /* superblock version */ - -/* Macros for computing variable-size superblock size */ -#define H5F_SUPERBLOCK_VARLEN_SIZE_COMMON \ - (2 /* freespace, and root group versions */ \ - + 1 /* reserved */ \ - + 3 /* shared header vers, size of address, size of lengths */ \ - + 1 /* reserved */ \ - + 4 /* group leaf k, group internal k */ \ - + 4) /* consistency flags */ -#define H5F_SUPERBLOCK_VARLEN_SIZE_V0(f) \ - ( H5F_SUPERBLOCK_VARLEN_SIZE_COMMON /* Common variable-length info */ \ - + H5F_SIZEOF_ADDR(f) /* base address */ \ - + H5F_SIZEOF_ADDR(f) /* <unused> */ \ - + H5F_SIZEOF_ADDR(f) /* EOF address */ \ - + H5F_SIZEOF_ADDR(f) /* driver block address */ \ - + H5G_SIZEOF_ENTRY(f)) /* root group ptr */ -#define H5F_SUPERBLOCK_VARLEN_SIZE_V1(f) \ - ( H5F_SUPERBLOCK_VARLEN_SIZE_COMMON /* Common variable-length info */ \ - + 2 /* indexed B-tree internal k */ \ - + 2 /* reserved */ \ - + H5F_SIZEOF_ADDR(f) /* base address */ \ - + H5F_SIZEOF_ADDR(f) /* <unused> */ \ - + H5F_SIZEOF_ADDR(f) /* EOF address */ \ - + H5F_SIZEOF_ADDR(f) /* driver block address */ \ - + H5G_SIZEOF_ENTRY(f)) /* root group ptr */ -#define H5F_SUPERBLOCK_VARLEN_SIZE_V2(f) \ - ( 2 /* size of address, size of lengths */ \ - + 1 /* consistency flags */ \ - + H5F_SIZEOF_ADDR(f) /* base address */ \ - + H5F_SIZEOF_ADDR(f) /* superblock extension address */ \ - + H5F_SIZEOF_ADDR(f) /* EOF address */ \ - + H5F_SIZEOF_ADDR(f) /* root group object header address */ \ - + H5F_SIZEOF_CHKSUM) /* superblock checksum (keep this last) */ -#define H5F_SUPERBLOCK_VARLEN_SIZE(v, f) ( \ - (v == 0 ? H5F_SUPERBLOCK_VARLEN_SIZE_V0(f) : 0) \ - + (v == 1 ? H5F_SUPERBLOCK_VARLEN_SIZE_V1(f) : 0) \ - + (v == 2 ? H5F_SUPERBLOCK_VARLEN_SIZE_V2(f) : 0)) - -/* Total size of superblock, depends on superblock version */ -#define H5F_SUPERBLOCK_SIZE(v, f) ( H5F_SUPERBLOCK_FIXED_SIZE \ - + H5F_SUPERBLOCK_VARLEN_SIZE(v, f)) - -/* Driver info block macros */ -#define H5F_DRVINFOBLOCK_HDR_SIZE 16 - -/* Maximum size of super-block buffers */ -#define H5F_MAX_SUPERBLOCK_SIZE 134 -#define H5F_MAX_DRVINFOBLOCK_SIZE 1024 - /******************/ /* Local Typedefs */ @@ -111,9 +55,6 @@ /* Local Prototypes */ /********************/ static herr_t H5F_super_ext_create(H5F_t *f, hid_t dxpl_id, H5O_loc_t *ext_ptr); -static herr_t H5F_super_ext_open(H5F_t *f, H5O_loc_t *ext_ptr); -static herr_t H5F_super_ext_write_msg(H5F_t *f, hid_t dxpl_id, void *mesg, unsigned id, hbool_t may_create); -static herr_t H5F_super_ext_close(H5F_t *f, H5O_loc_t *ext_ptr); /*********************/ @@ -125,6 +66,9 @@ static herr_t H5F_super_ext_close(H5F_t *f, H5O_loc_t *ext_ptr); /* Library Private Variables */ /*****************************/ +/* Declare a free list to manage the H5F_super_t struct */ +H5FL_DEFINE(H5F_super_t); + /*******************/ /* Local Variables */ @@ -238,15 +182,17 @@ H5F_super_ext_create(H5F_t *f, hid_t dxpl_id, H5O_loc_t *ext_ptr) /* Sanity check */ HDassert(f); + HDassert(f->shared); + HDassert(f->shared->sblock); + HDassert(!H5F_addr_defined(f->shared->sblock->ext_addr)); HDassert(ext_ptr); - HDassert(!H5F_addr_defined(f->shared->extension_addr)); H5O_loc_reset(ext_ptr); if(H5O_create(f, dxpl_id, 0, H5P_GROUP_CREATE_DEFAULT, ext_ptr) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCREATE, FAIL, "unable to create superblock extension") /* Record the address of the superblock extension */ - f->shared->extension_addr = ext_ptr->addr; + f->shared->sblock->ext_addr = ext_ptr->addr; done: FUNC_LEAVE_NOAPI(ret_value) @@ -265,8 +211,8 @@ done: * *------------------------------------------------------------------------- */ -static herr_t -H5F_super_ext_open(H5F_t *f, H5O_loc_t *ext_ptr) +herr_t +H5F_super_ext_open(H5F_t *f, haddr_t ext_addr, H5O_loc_t *ext_ptr) { herr_t ret_value = SUCCEED; /* Return value */ @@ -274,17 +220,17 @@ H5F_super_ext_open(H5F_t *f, H5O_loc_t *ext_ptr) /* Sanity check */ HDassert(f); + HDassert(H5F_addr_defined(ext_addr)); HDassert(ext_ptr); - HDassert(H5F_addr_defined(f->shared->extension_addr)); /* Set up "fake" object location for superblock extension */ H5O_loc_reset(ext_ptr); ext_ptr->file = f; - ext_ptr->addr = f->shared->extension_addr; + ext_ptr->addr = ext_addr; /* Open the superblock extension object header */ if(H5O_open(ext_ptr) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENFILE, FAIL, "unable to open superblock extension") + HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open superblock extension") done: FUNC_LEAVE_NOAPI(ret_value) @@ -303,7 +249,7 @@ done: * *------------------------------------------------------------------------- */ -static herr_t +herr_t H5F_super_ext_close(H5F_t *f, H5O_loc_t *ext_ptr) { herr_t ret_value = SUCCEED; /* Return value */ @@ -317,7 +263,7 @@ H5F_super_ext_close(H5F_t *f, H5O_loc_t *ext_ptr) /* Twiddle the number of open objects to avoid closing the file. */ f->nopen_objs++; if(H5O_close(ext_ptr) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "unable to close superblock extension") + HGOTO_ERROR(H5E_OHDR, H5E_CANTCLOSEOBJ, FAIL, "unable to close superblock extension") f->nopen_objs--; done: @@ -345,421 +291,44 @@ done: herr_t H5F_super_read(H5F_t *f, hid_t dxpl_id) { - uint8_t sbuf[H5F_MAX_SUPERBLOCK_SIZE]; /* Buffer for superblock */ - H5P_genplist_t *c_plist; /* File creation property list */ - H5F_file_t *shared; /* shared part of `file' */ - H5FD_t *lf; /* file driver part of `shared' */ - haddr_t abs_super_addr; /* Absolute offset of superblock in file */ - haddr_t stored_eoa; /*relative end-of-addr in file */ - haddr_t eof; /*end of file address */ - size_t sizeof_addr; /* Size of offsets in the file (in bytes) */ - size_t sizeof_size; /* Size of lengths in the file (in bytes) */ - const size_t fixed_size = H5F_SUPERBLOCK_FIXED_SIZE; /*fixed sizeof superblock */ - size_t variable_size; /*variable sizeof superblock */ - uint8_t *p; /* Temporary pointer into encoding buffer */ - unsigned super_vers; /* Superblock version */ - herr_t ret_value = SUCCEED; + H5F_super_t * sblock = NULL; /* superblock structure */ + unsigned sblock_flags = H5AC__NO_FLAGS_SET; /* flags used in superblock unprotect call */ + H5AC_protect_t rw; /* read/write permissions for file */ + hbool_t dirtied = FALSE; /* Bool for sblock protect call */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_NOAPI(H5F_super_read, FAIL) - /* Short cuts */ - shared = f->shared; - lf = shared->lf; - - /* Get the shared file creation property list */ - if(NULL == (c_plist = (H5P_genplist_t *)H5I_object(shared->fcpl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") - /* Find the superblock */ - if(HADDR_UNDEF == (abs_super_addr = H5F_locate_signature(lf, dxpl_id))) + if(HADDR_UNDEF == (f->shared->super_addr = H5F_locate_signature(f->shared->lf, dxpl_id))) HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, FAIL, "unable to find file signature") - /* Read fixed-size portion of the superblock */ - p = sbuf; - if(H5FD_set_eoa(lf, H5FD_MEM_SUPER, abs_super_addr + fixed_size) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "set end of space allocation request failed") - if(H5FD_read(lf, dxpl_id, H5FD_MEM_SUPER, abs_super_addr, fixed_size, p) < 0) - HGOTO_ERROR(H5E_FILE, H5E_READERROR, FAIL, "unable to read superblock") - - /* Skip over signature (already checked when locating the superblock) */ - p += H5F_SIGNATURE_LEN; - - /* Superblock version */ - super_vers = *p++; - if(super_vers > HDF5_SUPERBLOCK_VERSION_LATEST) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "bad superblock version number") - if(H5P_set(c_plist, H5F_CRT_SUPER_VERS_NAME, &super_vers) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set superblock version") - - /* Sanity check */ - HDassert(((size_t)(p - sbuf)) == fixed_size); - - /* Determine the size of the variable-length part of the superblock */ - variable_size = H5F_SUPERBLOCK_VARLEN_SIZE(super_vers, f); - HDassert(variable_size > 0); - HDassert(fixed_size + variable_size <= sizeof(sbuf)); - - /* Read in variable-sized portion of superblock */ - if(H5FD_set_eoa(lf, H5FD_MEM_SUPER, abs_super_addr + fixed_size + variable_size) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "set end of space allocation request failed") - if(H5FD_read(lf, dxpl_id, H5FD_MEM_SUPER, abs_super_addr + fixed_size, variable_size, p) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to read superblock") - - /* Check for older version of superblock format */ - if(super_vers < HDF5_SUPERBLOCK_VERSION_2) { - uint32_t status_flags; /* File status flags */ - unsigned btree_k[H5B_NUM_BTREE_ID]; /* B-tree internal node 'K' values */ - unsigned sym_leaf_k; /* Symbol table leaf node's 'K' value */ - - /* Freespace version (hard-wired) */ - if(HDF5_FREESPACE_VERSION != *p++) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "bad free space version number") - - /* Root group version number (hard-wired) */ - if(HDF5_OBJECTDIR_VERSION != *p++) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "bad object directory version number") - - /* Skip over reserved byte */ - p++; - - /* Shared header version number (hard-wired) */ - if(HDF5_SHAREDHEADER_VERSION != *p++) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "bad shared-header format version number") - - /* Size of file addresses */ - sizeof_addr = *p++; - if(sizeof_addr != 2 && sizeof_addr != 4 && - sizeof_addr != 8 && sizeof_addr != 16 && sizeof_addr != 32) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "bad byte number in an address") - if(H5P_set(c_plist, H5F_CRT_ADDR_BYTE_NUM_NAME, &sizeof_addr) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set byte number in an address") - shared->sizeof_addr = sizeof_addr; /* Keep a local copy also */ - - /* Size of file sizes */ - sizeof_size = *p++; - if(sizeof_size != 2 && sizeof_size != 4 && - sizeof_size != 8 && sizeof_size != 16 && sizeof_size != 32) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "bad byte number for object size") - if(H5P_set(c_plist, H5F_CRT_OBJ_BYTE_NUM_NAME, &sizeof_size) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set byte number for object size") - shared->sizeof_size = sizeof_size; /* Keep a local copy also */ - - /* Skip over reserved byte */ - p++; - - /* Various B-tree sizes */ - UINT16DECODE(p, sym_leaf_k); - if(sym_leaf_k == 0) - HGOTO_ERROR(H5E_FILE, H5E_BADRANGE, FAIL, "bad symbol table leaf node 1/2 rank") - if(H5P_set(c_plist, H5F_CRT_SYM_LEAF_NAME, &sym_leaf_k) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set rank for symbol table leaf nodes") - shared->sym_leaf_k = sym_leaf_k; /* Keep a local copy also */ - - /* Need 'get' call to set other array values */ - if(H5P_get(c_plist, H5F_CRT_BTREE_RANK_NAME, btree_k) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get rank for btree internal nodes") - UINT16DECODE(p, btree_k[H5B_SNODE_ID]); - if(btree_k[H5B_SNODE_ID] == 0) - HGOTO_ERROR(H5E_FILE, H5E_BADRANGE, FAIL, "bad 1/2 rank for btree internal nodes") - /* - * Delay setting the value in the property list until we've checked - * for the indexed storage B-tree internal 'K' value later. - */ - - /* File status flags (not really used yet) */ - UINT32DECODE(p, status_flags); - HDassert(status_flags <= 255); - shared->status_flags = (uint8_t)status_flags; - if(shared->status_flags & ~H5F_SUPER_ALL_FLAGS) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "bad flag value for superblock") - - /* - * If the superblock version # is greater than 0, read in the indexed - * storage B-tree internal 'K' value - */ - if(super_vers > HDF5_SUPERBLOCK_VERSION_DEF) { - UINT16DECODE(p, btree_k[H5B_CHUNK_ID]); - /* Reserved bytes are present only in version 1 */ - if(super_vers == HDF5_SUPERBLOCK_VERSION_1) - p += 2; /* reserved */ - } /* end if */ - else - btree_k[H5B_CHUNK_ID] = HDF5_BTREE_CHUNK_IK_DEF; - - /* Set the B-tree internal node values, etc */ - if(H5P_set(c_plist, H5F_CRT_BTREE_RANK_NAME, btree_k) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set rank for btree internal nodes") - HDmemcpy(shared->btree_k, btree_k, sizeof(unsigned) * (size_t)H5B_NUM_BTREE_ID); /* Keep a local copy also */ - - /* Remainder of "variable-sized" portion of superblock */ - H5F_addr_decode(f, (const uint8_t **)&p, &shared->base_addr/*out*/); - H5F_addr_decode(f, (const uint8_t **)&p, &shared->extension_addr/*out*/); - H5F_addr_decode(f, (const uint8_t **)&p, &stored_eoa/*out*/); - H5F_addr_decode(f, (const uint8_t **)&p, &shared->driver_addr/*out*/); - - /* Decode the symbol table entry */ - if(H5G_root_ent_decode(f, (const uint8_t **)&p) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to read root symbol entry") - - /* - * Check if superblock address is different from base address and - * adjust base address and "end of address" address if so. - */ - if(!H5F_addr_eq(abs_super_addr, shared->base_addr)) { - /* Check if the superblock moved earlier in the file */ - if(H5F_addr_lt(abs_super_addr, shared->base_addr)) - stored_eoa -= (shared->base_addr - abs_super_addr); - else - /* The superblock moved later in the file */ - stored_eoa += (abs_super_addr - shared->base_addr); - - shared->base_addr = abs_super_addr; - } /* end if */ - - /* Set the base address for the file in the VFD now, after adjusting - * space for possible offsets of the HDF5 data in the file. - */ - if(H5FD_set_base_addr(lf, shared->base_addr) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "failed to set base address for file driver") - - /* This step is for h5repart tool only. If user wants to change file driver - * from family to sec2 while using h5repart, set the driver address to - * undefined to let the library ignore the family driver information saved - * in the superblock. - */ - if(shared->fam_to_sec2) - shared->driver_addr = HADDR_UNDEF; - - /* Decode the optional driver information block */ - if(H5F_addr_defined(shared->driver_addr)) { - uint8_t dbuf[H5F_MAX_DRVINFOBLOCK_SIZE]; /* Buffer for driver info block */ - char drv_name[9]; /* Name of driver */ - unsigned drv_vers; /* Version of driver info block */ - size_t drv_variable_size; /* Size of variable-length portion of driver info block, in bytes */ - - /* Read in fixed-sized portion of driver info block */ - p = dbuf; - if(H5FD_set_eoa(lf, H5FD_MEM_SUPER, shared->driver_addr + H5F_DRVINFOBLOCK_HDR_SIZE) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "set end of space allocation request failed") - if(H5FD_read(lf, dxpl_id, H5FD_MEM_SUPER, shared->driver_addr, (size_t)H5F_DRVINFOBLOCK_HDR_SIZE, p) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to read driver information block") - - /* Version number */ - drv_vers = *p++; - if(drv_vers != HDF5_DRIVERINFO_VERSION_0) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "bad driver information block version number") - - p += 3; /* reserved bytes */ - - /* Driver info size */ - UINT32DECODE(p, drv_variable_size); - - /* Sanity check */ - HDassert(H5F_DRVINFOBLOCK_HDR_SIZE + drv_variable_size <= sizeof(dbuf)); - - /* Driver name and/or version */ - HDstrncpy(drv_name, (const char *)p, (size_t)8); - drv_name[8] = '\0'; - p += 8; /* advance past name/version */ - - /* Check if driver matches driver information saved. Unfortunately, we can't push this - * function to each specific driver because we're checking if the driver is correct. - */ - if(!HDstrncmp(drv_name, "NCSAfami", (size_t)8) && HDstrcmp(lf->cls->name, "family")) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "family driver should be used") - if(!HDstrncmp(drv_name, "NCSAmult", (size_t)8) && HDstrcmp(lf->cls->name, "multi")) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "multi driver should be used") - - /* Read in variable-sized portion of driver info block */ - if(H5FD_set_eoa(lf, H5FD_MEM_SUPER, shared->driver_addr + H5F_DRVINFOBLOCK_HDR_SIZE + drv_variable_size) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "set end of space allocation request failed") - if(H5FD_read(lf, dxpl_id, H5FD_MEM_SUPER, shared->driver_addr + H5F_DRVINFOBLOCK_HDR_SIZE, drv_variable_size, p) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to read file driver information") - - /* Decode driver information */ - if(H5FD_sb_decode(lf, drv_name, p) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to decode driver information") - } /* end if */ - } /* end if */ - else { - uint32_t computed_chksum; /* Computed checksum */ - uint32_t read_chksum; /* Checksum read from file */ - - /* Size of file addresses */ - sizeof_addr = *p++; - if(sizeof_addr != 2 && sizeof_addr != 4 && - sizeof_addr != 8 && sizeof_addr != 16 && sizeof_addr != 32) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "bad byte number in an address") - if(H5P_set(c_plist, H5F_CRT_ADDR_BYTE_NUM_NAME, &sizeof_addr) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set byte number in an address") - shared->sizeof_addr = sizeof_addr; /* Keep a local copy also */ - - /* Size of file sizes */ - sizeof_size = *p++; - if(sizeof_size != 2 && sizeof_size != 4 && - sizeof_size != 8 && sizeof_size != 16 && sizeof_size != 32) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "bad byte number for object size") - if(H5P_set(c_plist, H5F_CRT_OBJ_BYTE_NUM_NAME, &sizeof_size) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set byte number for object size") - shared->sizeof_size = sizeof_size; /* Keep a local copy also */ - - /* File status flags (not really used yet) */ - shared->status_flags = *p++; - if(shared->status_flags & ~H5F_SUPER_ALL_FLAGS) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "bad flag value for superblock") - - /* Base, superblock extension, end of file & root group object header addresses */ - H5F_addr_decode(f, (const uint8_t **)&p, &shared->base_addr/*out*/); - H5F_addr_decode(f, (const uint8_t **)&p, &shared->extension_addr/*out*/); - H5F_addr_decode(f, (const uint8_t **)&p, &stored_eoa/*out*/); - H5F_addr_decode(f, (const uint8_t **)&p, &shared->root_addr/*out*/); - - /* Compute checksum for superblock */ - computed_chksum = H5_checksum_metadata(sbuf, (size_t)(p - sbuf), 0); - - /* Decode checksum */ - UINT32DECODE(p, read_chksum); - - /* Verify correct checksum */ - if(read_chksum != computed_chksum) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "bad checksum on driver information block") - - /* - * Check if superblock address is different from base address and - * adjust base address and "end of address" address if so. - */ - if(!H5F_addr_eq(abs_super_addr, shared->base_addr)) { - /* Check if the superblock moved earlier in the file */ - if(H5F_addr_lt(abs_super_addr, shared->base_addr)) - stored_eoa -= (shared->base_addr - abs_super_addr); - else - /* The superblock moved later in the file */ - stored_eoa += (abs_super_addr - shared->base_addr); - - shared->base_addr = abs_super_addr; - } /* end if */ - - /* Set the base address for the file in the VFD now, after adjusting - * space for possible offsets of the HDF5 data in the file. - */ - if(H5FD_set_base_addr(lf, shared->base_addr) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "failed to set base address for file driver") - } /* end else */ - - /* - * The user-defined data is the area of the file before the base - * address. - */ - if(H5P_set(c_plist, H5F_CRT_USER_BLOCK_NAME, &shared->base_addr) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set userblock size") - - /* - * Make sure that the data is not truncated. One case where this is - * possible is if the first file of a family of files was opened - * individually. - */ - if(HADDR_UNDEF == (eof = H5FD_get_eof(lf))) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to determine file size") - /* (Account for the stored EOA being absolute offset -QAK) */ - if((eof + H5F_BASE_ADDR(f)) < stored_eoa) - HGOTO_ERROR(H5E_FILE, H5E_TRUNCATED, FAIL, "truncated file") - - /* - * Tell the file driver how much address space has already been - * allocated so that it knows how to allocate additional memory. - */ - /* (Account for the stored EOA being absolute offset -NAF) */ - if(H5FD_set_eoa(lf, H5FD_MEM_SUPER, stored_eoa - H5F_BASE_ADDR(f)) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to set end-of-address marker for file") - - /* Read the file's superblock extension, if there is one. */ - if(H5F_addr_defined(shared->extension_addr)) { - H5O_loc_t ext_loc; /* "Object location" for superblock extension */ - H5O_btreek_t btreek; /* v1 B-tree 'K' value message from superblock extension */ - H5O_drvinfo_t drvinfo; /* Driver info message from superblock extension */ - htri_t status; /* Status for message existing */ - - /* Sanity check - superblock extension should only be defined for - * superblock version >= 2. - */ - HDassert(super_vers >= HDF5_SUPERBLOCK_VERSION_2); - - /* Check for superblock extension being located "outside" the stored - * 'eoa' value, which can occur with the split/multi VFD. - */ - if(H5F_addr_gt(shared->extension_addr, stored_eoa)) { - /* Set the 'eoa' for the object header memory type large enough - * to give some room for a reasonably sized superblock extension. - * (This is _rather_ a kludge -QAK) - */ - if(H5FD_set_eoa(lf, H5FD_MEM_OHDR, (haddr_t)(shared->extension_addr + 1024)) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to set end-of-address marker for file") - } /* end if */ + /* Determine file intent for superblock protect */ + if(H5F_INTENT(f) & H5F_ACC_RDWR) + rw = H5AC_WRITE; + else + rw = H5AC_READ; - /* Open the superblock extension */ - if(H5F_super_ext_open(f, &ext_loc) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENOBJ, FAIL, "unable to start file's superblock extension") - - /* Check for the extension having a 'driver info' message */ - if((status = H5O_msg_exists(&ext_loc, H5O_DRVINFO_ID, dxpl_id)) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to read object header") - if(status) { - /* Retrieve the 'driver info' structure */ - if(NULL == H5O_msg_read(&ext_loc, H5O_DRVINFO_ID, &drvinfo, dxpl_id)) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "driver info message not present") - - /* Check if driver matches driver information saved. Unfortunately, we can't push this - * function to each specific driver because we're checking if the driver is correct. - */ - if(!HDstrncmp(drvinfo.name, "NCSAfami", (size_t)8) && HDstrcmp(lf->cls->name, "family")) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "family driver should be used") - if(!HDstrncmp(drvinfo.name, "NCSAmult", (size_t)8) && HDstrcmp(lf->cls->name, "multi")) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "multi driver should be used") - - /* Decode driver information */ - if(H5FD_sb_decode(lf, drvinfo.name, drvinfo.buf) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to decode driver information") - - /* Reset driver info message */ - H5O_msg_reset(H5O_DRVINFO_ID, &drvinfo); - } /* end if */ + /* Look up the superblock */ + if(NULL == (sblock = (H5F_super_t *)H5AC_protect(f, dxpl_id, H5AC_SUPERBLOCK, f->shared->super_addr, NULL, &dirtied, rw))) + HGOTO_ERROR(H5E_CACHE, H5E_CANTPROTECT, FAIL, "unable to load superblock") + + /* Mark the superblock dirty if it was modified during loading or VFD indicated to do so */ + if((H5AC_WRITE == rw) && (dirtied || H5F_HAS_FEATURE(f, H5FD_FEAT_DIRTY_SBLK_LOAD))) + sblock_flags |= H5AC__DIRTIED_FLAG; - /* Read in the shared OH message information if there is any */ - if(H5SM_get_info(&ext_loc, c_plist, dxpl_id) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to read SOHM table information") - - /* Check for the extension having a 'v1 B-tree "K"' message */ - if((status = H5O_msg_exists(&ext_loc, H5O_BTREEK_ID, dxpl_id)) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to read object header") - if(status) { - /* Retrieve the 'v1 B-tree "K"' structure */ - if(NULL == H5O_msg_read(&ext_loc, H5O_BTREEK_ID, &btreek, dxpl_id)) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "v1 B-tree 'K' info message not present") - - /* Set non-default v1 B-tree 'K' value info from file */ - shared->btree_k[H5B_CHUNK_ID] = btreek.btree_k[H5B_CHUNK_ID]; - shared->btree_k[H5B_SNODE_ID] = btreek.btree_k[H5B_SNODE_ID]; - shared->sym_leaf_k = btreek.sym_leaf_k; - - /* Set non-default v1 B-tree 'K' values in the property list */ - if(H5P_set(c_plist, H5F_CRT_BTREE_RANK_NAME, btreek.btree_k) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set rank for btree internal nodes") - if(H5P_set(c_plist, H5F_CRT_SYM_LEAF_NAME, &btreek.sym_leaf_k) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set rank for symbol table leaf nodes") - } /* end if */ - else { - /* No non-default v1 B-tree 'K' value info in file, use defaults */ - shared->btree_k[H5B_CHUNK_ID] = HDF5_BTREE_CHUNK_IK_DEF; - shared->btree_k[H5B_SNODE_ID] = HDF5_BTREE_SNODE_IK_DEF; - shared->sym_leaf_k = H5F_CRT_SYM_LEAF_DEF; - } /* end if */ + /* Pin the superblock in the cache */ + if(H5AC_pin_protected_entry(f, sblock) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTPIN, FAIL, "unable to pin superblock") - /* Close superblock extension */ - if(H5F_super_ext_close(f, &ext_loc) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "unable to close file's superblock extension") - } /* end if */ + /* Set the pointer to the pinned superblock */ + f->shared->sblock = sblock; done: + /* Release the superblock */ + if(sblock && H5AC_unprotect(f, dxpl_id, H5AC_SUPERBLOCK, f->shared->super_addr, sblock, sblock_flags) < 0) + HDONE_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "unable to close superblock") + FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_super_read() */ @@ -783,21 +352,64 @@ done: herr_t H5F_super_init(H5F_t *f, hid_t dxpl_id) { - H5P_genplist_t *plist; /* File creation property list */ - hsize_t userblock_size; /* Size of userblock, in bytes */ - hsize_t superblock_size; /* Size of superblock, in bytes */ - size_t driver_size; /* Size of driver info block (bytes) */ - unsigned super_vers; /* Superblock version */ - haddr_t super_addr; /* Address of superblock */ + H5F_super_t *sblock = NULL; /* Superblock cache structure */ + hbool_t sblock_in_cache = FALSE; /* Whether the superblock has been inserted into the metadata cache */ + H5P_genplist_t *plist; /* File creation property list */ + hsize_t userblock_size; /* Size of userblock, in bytes */ + hsize_t superblock_size; /* Size of superblock, in bytes */ + size_t driver_size; /* Size of driver info block (bytes) */ + unsigned super_vers = HDF5_SUPERBLOCK_VERSION_DEF; /* Superblock version for file */ + haddr_t super_addr; /* Address of superblock */ hbool_t need_ext; /* Whether the superblock extension is needed */ - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; /* Return Value */ FUNC_ENTER_NOAPI(H5F_super_init, FAIL) + /* Allocate space for the superblock */ + if(NULL == (sblock = H5FL_CALLOC(H5F_super_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + + /* Initialize various address information */ + sblock->base_addr = HADDR_UNDEF; + sblock->ext_addr = HADDR_UNDEF; + sblock->driver_addr = HADDR_UNDEF; + sblock->root_addr = HADDR_UNDEF; + /* Get the shared file creation property list */ if(NULL == (plist = (H5P_genplist_t *)H5I_object(f->shared->fcpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") + /* Initialize sym_leaf_k */ + if(H5P_get(plist, H5F_CRT_SYM_LEAF_NAME, &sblock->sym_leaf_k) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get byte number for object size") + + /* Initialize btree_k */ + if(H5P_get(plist, H5F_CRT_BTREE_RANK_NAME, &sblock->btree_k[0]) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get rank for btree internal nodes") + + /* Bump superblock version if we are to use the latest version of the format */ + if(f->shared->latest_format) + super_vers = HDF5_SUPERBLOCK_VERSION_LATEST; + /* Bump superblock version to create superblock extension for SOHM info */ + else if(f->shared->sohm_nindexes > 0) + super_vers = HDF5_SUPERBLOCK_VERSION_2; + /* Check for non-default indexed storage B-tree internal 'K' value + * and set the version # of the superblock to 1 if it is a non-default + * value. + */ + else if(sblock->btree_k[H5B_CHUNK_ID] != HDF5_BTREE_CHUNK_IK_DEF) + super_vers = HDF5_SUPERBLOCK_VERSION_1; + + /* If a newer superblock version is required, set it here */ + if(super_vers != HDF5_SUPERBLOCK_VERSION_DEF) { + H5P_genplist_t *c_plist; /* Property list */ + + if(NULL == (c_plist = (H5P_genplist_t *)H5I_object(f->shared->fcpl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not property list") + if(H5P_set(c_plist, H5F_CRT_SUPER_VERS_NAME, &super_vers) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set superblock version") + } /* end if */ + /* * The superblock starts immediately after the user-defined * header, which we have already insured is a proper size. The @@ -806,8 +418,9 @@ H5F_super_init(H5F_t *f, hid_t dxpl_id) */ if(H5P_get(plist, H5F_CRT_USER_BLOCK_NAME, &userblock_size) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get userblock size") - f->shared->base_addr = userblock_size; - f->shared->status_flags = 0; + + sblock->base_addr = userblock_size; + sblock->status_flags = 0; /* Reserve space for the userblock */ if(H5FD_set_eoa(f->shared->lf, H5FD_MEM_SUPER, userblock_size) < 0) @@ -816,12 +429,11 @@ H5F_super_init(H5F_t *f, hid_t dxpl_id) /* Set the base address for the file in the VFD now, after allocating * space for userblock. */ - if(H5FD_set_base_addr(f->shared->lf, f->shared->base_addr) < 0) + if(H5FD_set_base_addr(f->shared->lf, sblock->base_addr) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "failed to set base address for file driver") - /* Grab superblock version from property list */ - if(H5P_get(plist, H5F_CRT_SUPER_VERS_NAME, &super_vers) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get superblock version") + /* Save a local copy of the superblock version number */ + sblock->super_vers = super_vers; /* Compute the size of the superblock */ superblock_size = H5F_SUPERBLOCK_SIZE(super_vers, f); @@ -835,7 +447,7 @@ H5F_super_init(H5F_t *f, hid_t dxpl_id) * The file driver information block begins immediately after the * superblock. (relative to base address in file) */ - f->shared->driver_addr = superblock_size; + sblock->driver_addr = superblock_size; } /* end if */ /* @@ -846,11 +458,22 @@ H5F_super_init(H5F_t *f, hid_t dxpl_id) */ if(super_vers < HDF5_SUPERBLOCK_VERSION_2) superblock_size += driver_size; - super_addr = H5MF_alloc(f, H5FD_MEM_SUPER, dxpl_id, superblock_size); - if(HADDR_UNDEF == super_addr) - HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to allocate file space for userblock and/or superblock") - if(0 != super_addr) - HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "file driver failed to allocate userblock and/or superblock at address zero") + + /* Reserve space in the file for the superblock, instead of allocating it */ + if(H5FD_set_eoa(f->shared->lf, H5FD_MEM_SUPER, superblock_size) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to set EOA value for superblock") + + /* Set the superblock's address, it must be immediately after any userblock */ + super_addr = (haddr_t)0; + + /* Insert superblock into cache, pinned */ + if(H5AC_set(f, dxpl_id, H5AC_SUPERBLOCK, super_addr, sblock, H5AC__PIN_ENTRY_FLAG) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTINS, FAIL, "can't add superblock to cache") + sblock_in_cache = TRUE; + + /* Keep a copy of the superblock info */ + f->shared->sblock = sblock; + f->shared->super_addr = super_addr; /* * Determine if we will need a superblock extension @@ -867,9 +490,9 @@ H5F_super_init(H5F_t *f, hid_t dxpl_id) */ else if(super_vers >= HDF5_SUPERBLOCK_VERSION_2) { /* Check for non-default v1 B-tree 'K' values to store */ - if(f->shared->btree_k[H5B_SNODE_ID] != HDF5_BTREE_SNODE_IK_DEF || - f->shared->btree_k[H5B_CHUNK_ID] != HDF5_BTREE_CHUNK_IK_DEF || - f->shared->sym_leaf_k != H5F_CRT_SYM_LEAF_DEF) + if(sblock->btree_k[H5B_SNODE_ID] != HDF5_BTREE_SNODE_IK_DEF || + sblock->btree_k[H5B_CHUNK_ID] != HDF5_BTREE_CHUNK_IK_DEF || + sblock->sym_leaf_k != H5F_CRT_SYM_LEAF_DEF) need_ext = TRUE; /* Check for driver info to store */ else if(driver_size > 0) @@ -905,15 +528,15 @@ H5F_super_init(H5F_t *f, hid_t dxpl_id) } /* end if */ /* Check for non-default v1 B-tree 'K' values to store */ - if(f->shared->btree_k[H5B_SNODE_ID] != HDF5_BTREE_SNODE_IK_DEF || - f->shared->btree_k[H5B_CHUNK_ID] != HDF5_BTREE_CHUNK_IK_DEF || - f->shared->sym_leaf_k != H5F_CRT_SYM_LEAF_DEF) { + if(sblock->btree_k[H5B_SNODE_ID] != HDF5_BTREE_SNODE_IK_DEF || + sblock->btree_k[H5B_CHUNK_ID] != HDF5_BTREE_CHUNK_IK_DEF || + sblock->sym_leaf_k != H5F_CRT_SYM_LEAF_DEF) { H5O_btreek_t btreek; /* v1 B-tree 'K' value message for superblock extension */ /* Write v1 B-tree 'K' value information to the superblock extension */ - btreek.btree_k[H5B_CHUNK_ID] = f->shared->btree_k[H5B_CHUNK_ID]; - btreek.btree_k[H5B_SNODE_ID] = f->shared->btree_k[H5B_SNODE_ID]; - btreek.sym_leaf_k = f->shared->sym_leaf_k; + btreek.btree_k[H5B_CHUNK_ID] = sblock->btree_k[H5B_CHUNK_ID]; + btreek.btree_k[H5B_SNODE_ID] = sblock->btree_k[H5B_SNODE_ID]; + btreek.sym_leaf_k = sblock->sym_leaf_k; if(H5O_msg_create(&ext_loc, H5O_BTREEK_ID, H5O_MSG_FLAG_CONSTANT | H5O_MSG_FLAG_DONTSHARE, H5O_UPDATE_TIME, &btreek, dxpl_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to update v1 B-tree 'K' value header message") } /* end if */ @@ -943,194 +566,66 @@ H5F_super_init(H5F_t *f, hid_t dxpl_id) } /* end if */ done: + /* Cleanup on failure */ + if(ret_value < 0) { + /* Check if the superblock has been allocated yet */ + if(sblock) { + /* Check if we've cached it already */ + if(sblock_in_cache) { + /* Unpin superblock in cache */ + if(H5AC_unpin_entry(f, sblock) < 0) + HDONE_ERROR(H5E_FILE, H5E_CANTUNPIN, FAIL, "unable to unpin superblock") + + /* Evict the superblock from the cache */ + if(H5AC_expunge_entry(f, dxpl_id, H5AC_SUPERBLOCK, super_addr, H5AC__NO_FLAGS_SET) < 0) + HDONE_ERROR(H5E_FILE, H5E_CANTEXPUNGE, FAIL, "unable to expunge superblock") + } /* end if */ + else + /* Free superblock */ + sblock = (H5F_super_t *)H5FL_FREE(H5F_super_t, sblock); + + /* Reset variables in file structure */ + f->shared->sblock = NULL; + f->shared->super_addr = HADDR_UNDEF; + } /* end if */ + } /* end if */ + FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_super_init() */ /*------------------------------------------------------------------------- - * Function: H5F_super_write + * Function: H5F_super_dirty * - * Purpose: Writes the superblock for the file. + * Purpose: Mark the file's superblock dirty * - * Return: Success: SUCCEED - * Failure: FAIL + * Return: Success: non-negative on success + * Failure: Negative * - * Programmer: Bill Wendling - * wendling@ncsa.uiuc.edu - * Sept 12, 2003 + * Programmer: Quincey Koziol + * August 14, 2009 * *------------------------------------------------------------------------- */ herr_t -H5F_super_write(H5F_t *f, hid_t dxpl_id) +H5F_super_dirty(H5F_t *f) { - H5P_genplist_t *plist; /* File creation property list */ - uint8_t buf[H5F_MAX_SUPERBLOCK_SIZE + H5F_MAX_DRVINFOBLOCK_SIZE]; /* Superblock & driver info blockencoding buffer */ - uint8_t *p; /* Ptr into encoding buffer */ - haddr_t rel_eoa; /* Relative EOA for file */ - size_t superblock_size; /* Size of superblock, in bytes */ - size_t driver_size; /* Size of driver info block (bytes)*/ - unsigned super_vers; /* Superblock version */ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(H5F_super_write, FAIL) - - /* Get the shared file creation property list */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(f->shared->fcpl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") - - /* Grab values from property list */ - if(H5P_get(plist, H5F_CRT_SUPER_VERS_NAME, &super_vers) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get superblock version") - - /* Encode the common portion of the file superblock for all versions */ - p = buf; - HDmemcpy(p, H5F_SIGNATURE, (size_t)H5F_SIGNATURE_LEN); - p += H5F_SIGNATURE_LEN; - *p++ = (uint8_t)super_vers; - - /* Check for older version of superblock format */ - if(super_vers < HDF5_SUPERBLOCK_VERSION_2) { - *p++ = (uint8_t)HDF5_FREESPACE_VERSION; /* (hard-wired) */ - *p++ = (uint8_t)HDF5_OBJECTDIR_VERSION; /* (hard-wired) */ - *p++ = 0; /* reserved*/ - - *p++ = (uint8_t)HDF5_SHAREDHEADER_VERSION; /* (hard-wired) */ - HDassert(H5F_SIZEOF_ADDR(f) <= 255); - *p++ = (uint8_t)H5F_SIZEOF_ADDR(f); - HDassert(H5F_SIZEOF_SIZE(f) <= 255); - *p++ = (uint8_t)H5F_SIZEOF_SIZE(f); - *p++ = 0; /* reserved */ - - UINT16ENCODE(p, f->shared->sym_leaf_k); - UINT16ENCODE(p, f->shared->btree_k[H5B_SNODE_ID]); - UINT32ENCODE(p, (uint32_t)f->shared->status_flags); - - /* - * Versions of the superblock >0 have the indexed storage B-tree - * internal 'K' value stored - */ - if(super_vers > HDF5_SUPERBLOCK_VERSION_DEF) { - UINT16ENCODE(p, f->shared->btree_k[H5B_CHUNK_ID]); - *p++ = 0; /*reserved */ - *p++ = 0; /*reserved */ - } /* end if */ - - H5F_addr_encode(f, &p, f->shared->base_addr); - H5F_addr_encode(f, &p, f->shared->extension_addr); - rel_eoa = H5FD_get_eoa(f->shared->lf, H5FD_MEM_SUPER); - H5F_addr_encode(f, &p, (rel_eoa + f->shared->base_addr)); - H5F_addr_encode(f, &p, f->shared->driver_addr); - - /* Encode the root group object entry, including the cached stab info */ - if(H5G_root_ent_encode(f, &p) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to encode root group information") - - /* Encode the driver information block. */ - H5_ASSIGN_OVERFLOW(driver_size, H5FD_sb_size(f->shared->lf), hsize_t, size_t); - - /* Checking whether driver block address is defined here is to handle backward - * compatibility. If the file was created with v1.6 library or earlier and no - * driver info block was written in the superblock, we don't write it either even - * though there's some driver info. Otherwise, the driver block extended will - * overwrite the (meta)data right after the superblock. This situation happens to - * the family driver particularly. SLU - 2009/3/24 - */ - if(driver_size > 0 && H5F_addr_defined(f->shared->driver_addr)) { - char driver_name[9]; /* Name of driver, for driver info block */ - uint8_t *dbuf = p; /* Pointer to beginning of driver info */ - - /* Encode the driver information block */ - *p++ = HDF5_DRIVERINFO_VERSION_0; /* Version */ - *p++ = 0; /* reserved */ - *p++ = 0; /* reserved */ - *p++ = 0; /* reserved */ - - /* Driver info size, excluding header */ - UINT32ENCODE(p, driver_size); - - /* Encode driver-specific data */ - if(H5FD_sb_encode(f->shared->lf, driver_name, dbuf + H5F_DRVINFOBLOCK_HDR_SIZE) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to encode driver information") - - /* Store driver name (set in 'H5FD_sb_encode' call above) */ - HDmemcpy(p, driver_name, (size_t)8); - - /* Advance buffer pointer past name & variable-sized portion of driver info */ - /* (for later use in computing the superblock size) */ - p += 8 + driver_size; - } /* end if */ - } /* end if */ - else { - uint32_t chksum; /* Checksum temporary variable */ - H5O_loc_t *root_oloc; /* Pointer to root group's object location */ - - /* Size of file addresses & offsets, and status flags */ - HDassert(H5F_SIZEOF_ADDR(f) <= 255); - *p++ = (uint8_t)H5F_SIZEOF_ADDR(f); - HDassert(H5F_SIZEOF_SIZE(f) <= 255); - *p++ = (uint8_t)H5F_SIZEOF_SIZE(f); - *p++ = f->shared->status_flags; - - /* Base, superblock extension & end of file addresses */ - H5F_addr_encode(f, &p, f->shared->base_addr); - H5F_addr_encode(f, &p, f->shared->extension_addr); - rel_eoa = H5FD_get_eoa(f->shared->lf, H5FD_MEM_SUPER); - H5F_addr_encode(f, &p, (rel_eoa + f->shared->base_addr)); - - /* Retrieve information for root group */ - if(NULL == (root_oloc = H5G_oloc(f->shared->root_grp))) - HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to retrieve root group information") - - /* Encode address of root group's object header */ - H5F_addr_encode(f, &p, root_oloc->addr); - - /* Compute superblock checksum */ - chksum = H5_checksum_metadata(buf, (H5F_SUPERBLOCK_SIZE(super_vers, f) - H5F_SIZEOF_CHKSUM), 0); - - /* Superblock checksum */ - UINT32ENCODE(p, chksum); - - /* Sanity check */ - HDassert((size_t)(p - buf) == H5F_SUPERBLOCK_SIZE(super_vers, f)); - } /* end else */ - - /* Retrieve the total size of the superblock info */ - H5_ASSIGN_OVERFLOW(superblock_size, (p - buf), int, size_t); - - /* Double check we didn't overrun the block (unlikely) */ - HDassert(superblock_size <= sizeof(buf)); - - /* Write superblock (always at relative offset 0) */ - if(H5FD_write(f->shared->lf, dxpl_id, H5FD_MEM_SUPER, (haddr_t)0, superblock_size, buf) < 0) - HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to write superblock") - - /* Check for newer version of superblock format & superblock extension */ - if(super_vers >= HDF5_SUPERBLOCK_VERSION_2 && H5F_addr_defined(f->shared->extension_addr)) { - /* Check for driver info message */ - H5_ASSIGN_OVERFLOW(driver_size, H5FD_sb_size(f->shared->lf), hsize_t, size_t); - if(driver_size > 0) { - H5O_drvinfo_t drvinfo; /* Driver info */ - uint8_t dbuf[H5F_MAX_DRVINFOBLOCK_SIZE]; /* Driver info block encoding buffer */ + herr_t ret_value = SUCCEED; /* Return value */ - /* Sanity check */ - HDassert(driver_size <= H5F_MAX_DRVINFOBLOCK_SIZE); + FUNC_ENTER_NOAPI(H5F_super_dirty, FAIL) - /* Encode driver-specific data */ - if(H5FD_sb_encode(f->shared->lf, drvinfo.name, dbuf) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to encode driver information") + /* Sanity check */ + HDassert(f); + HDassert(f->shared); + HDassert(f->shared->sblock); - /* Write driver info information to the superblock extension */ - drvinfo.len = driver_size; - drvinfo.buf = dbuf; - if(H5F_super_ext_write_msg(f, dxpl_id, &drvinfo, H5O_DRVINFO_ID, FALSE) < 0) - HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "unable to update driver info header message") - } /* end if */ - } /* end if */ + /* Mark superblock dirty in cache, so change to EOA will get encoded */ + if(H5AC_mark_pinned_or_protected_entry_dirty(f, f->shared->sblock) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTMARKDIRTY, FAIL, "unable to mark superblock as dirty") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5F_super_write() */ +} /* H5F_super_dirty() */ /*------------------------------------------------------------------------- @@ -1143,6 +638,7 @@ done: * * Programmer: Vailin Choi * July 11, 2007 + * *------------------------------------------------------------------------- */ herr_t @@ -1154,34 +650,23 @@ H5F_super_size(H5F_t *f, hid_t dxpl_id, hsize_t *super_size, hsize_t *super_ext_ /* Sanity check */ HDassert(f); + HDassert(f->shared); + HDassert(f->shared->sblock); /* Set the superblock size */ - if(super_size) { - H5P_genplist_t *plist; /* File creation property list */ - unsigned super_vers; /* Superblock version */ - - /* Get the shared file creation property list */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(f->shared->fcpl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") - - /* Grab values from property list */ - if(H5P_get(plist, H5F_CRT_SUPER_VERS_NAME, &super_vers) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get superblock version") - - /* Set the superblock size */ - *super_size = H5F_SUPERBLOCK_SIZE(super_vers, f); - } /* end if */ + if(super_size) + *super_size = H5F_SUPERBLOCK_SIZE(f->shared->sblock->super_vers, f); /* Set the superblock extension size */ if(super_ext_size) { - if(H5F_addr_defined(f->shared->extension_addr)) { + if(H5F_addr_defined(f->shared->sblock->ext_addr)) { H5O_loc_t ext_loc; /* "Object location" for superblock extension */ H5O_info_t oinfo; /* Object info for superblock extension */ /* Set up "fake" object location for superblock extension */ H5O_loc_reset(&ext_loc); ext_loc.file = f; - ext_loc.addr = f->shared->extension_addr; + ext_loc.addr = f->shared->sblock->ext_addr; /* Get object header info for superblock extension */ if(H5O_get_info(&ext_loc, dxpl_id, FALSE, &oinfo) < 0) @@ -1211,24 +696,31 @@ done: * *------------------------------------------------------------------------- */ -static herr_t +herr_t H5F_super_ext_write_msg(H5F_t *f, hid_t dxpl_id, void *mesg, unsigned id, hbool_t may_create) { + hbool_t sblock_dirty = FALSE; /* Whether superblock was dirtied */ H5O_loc_t ext_loc; /* "Object location" for superblock extension */ htri_t status; /* Indicate whether the message exists or not */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5F_super_ext_write_msg) + /* Sanity checks */ + HDassert(f); + HDassert(f->shared); + HDassert(f->shared->sblock); + /* Open/create the superblock extension object header */ - if(H5F_addr_defined(f->shared->extension_addr)) { - if(H5F_super_ext_open(f, &ext_loc) < 0) + if(H5F_addr_defined(f->shared->sblock->ext_addr)) { + if(H5F_super_ext_open(f, f->shared->sblock->ext_addr, &ext_loc) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENOBJ, FAIL, "unable to open file's superblock extension") } /* end if */ else { HDassert(may_create); if(H5F_super_ext_create(f, dxpl_id, &ext_loc) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCREATE, FAIL, "unable to create file's superblock extension") + sblock_dirty = TRUE; } /* end else */ HDassert(H5F_addr_defined(ext_loc.addr)); @@ -1259,6 +751,11 @@ H5F_super_ext_write_msg(H5F_t *f, hid_t dxpl_id, void *mesg, unsigned id, hbool_ HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "unable to close file's superblock extension") done: + /* Mark superblock dirty in cache, if necessary */ + if(sblock_dirty) + if(H5AC_mark_pinned_or_protected_entry_dirty(f, f->shared->sblock) < 0) + HDONE_ERROR(H5E_FILE, H5E_CANTMARKDIRTY, FAIL, "unable to mark superblock as dirty") + FUNC_LEAVE_NOAPI(ret_value) } /* H5F_super_ext_write_msg() */ diff --git a/src/H5Fsuper_cache.c b/src/H5Fsuper_cache.c new file mode 100644 index 0000000..7df8f31 --- /dev/null +++ b/src/H5Fsuper_cache.c @@ -0,0 +1,854 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 H5F_PACKAGE /*suppress error about including H5Fpkg */ +#define H5G_PACKAGE /*suppress error about including H5Gpkg */ + + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Gpkg.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5SMprivate.h" /* Shared Object Header Messages */ + + +/****************/ +/* Local Macros */ +/****************/ + +/* Maximum size of super-block buffers */ +#define H5F_MAX_SUPERBLOCK_SIZE 134 + + +/******************/ +/* Local Typedefs */ +/******************/ + + +/********************/ +/* Package Typedefs */ +/********************/ + + +/********************/ +/* Local Prototypes */ +/********************/ + +/* Metadata cache (H5AC) callbacks */ +static H5F_super_t *H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *udata1, void *udata2); +static herr_t H5F_sblock_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5F_super_t *sblock); +static herr_t H5F_sblock_dest(H5F_t *f, H5F_super_t * sblock); +static herr_t H5F_sblock_clear(H5F_t *f, H5F_super_t *sblock, hbool_t destroy); +static herr_t H5F_sblock_size(const H5F_t *f, const H5F_super_t *sblock, size_t *size_ptr); + + +/*********************/ +/* Package Variables */ +/*********************/ + +/* H5F inherits cache-like properties from H5AC */ +const H5AC_class_t H5AC_SUPERBLOCK[1] = {{ + H5AC_SUPERBLOCK_ID, + (H5AC_load_func_t)H5F_sblock_load, + (H5AC_flush_func_t)H5F_sblock_flush, + (H5AC_dest_func_t)H5F_sblock_dest, + (H5AC_clear_func_t)H5F_sblock_clear, + (H5AC_notify_func_t)NULL, + (H5AC_size_func_t)H5F_sblock_size, +}}; + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + +/* Declare extern the free list to manage the H5F_super_t struct */ +H5FL_EXTERN(H5F_super_t); + + +/*******************/ +/* Local Variables */ +/*******************/ + + + +/*------------------------------------------------------------------------- + * Function: H5F_sblock_load + * + * Purpose: Loads the superblock from the file, and deserializes + * its information into the H5F_super_t structure. + * + * Return: Success: SUCCEED + * Failure: NULL + * + * Programmer: Mike McGreevy + * mamcgree@hdfgroup.org + * April 8, 2009 + * + *------------------------------------------------------------------------- + */ +static H5F_super_t * +H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t UNUSED addr, const void UNUSED *udata1, void *udata2/*out*/) +{ + H5F_super_t *sblock = NULL; /* File's superblock */ + uint8_t sbuf[H5F_MAX_SUPERBLOCK_SIZE]; /* Buffer for superblock */ + H5P_genplist_t *c_plist; /* File creation property list */ + H5F_file_t *shared; /* shared part of `file' */ + H5FD_t *lf; /* file driver part of `shared' */ + haddr_t stored_eoa; /*relative end-of-addr in file */ + haddr_t eof; /*end of file address */ + size_t sizeof_addr; /* Size of offsets in the file (in bytes) */ + size_t sizeof_size; /* Size of lengths in the file (in bytes) */ + const size_t fixed_size = H5F_SUPERBLOCK_FIXED_SIZE; /*fixed sizeof superblock */ + size_t variable_size; /*variable sizeof superblock */ + uint8_t *p; /* Temporary pointer into encoding buffer */ + unsigned super_vers; /* Superblock version */ + hbool_t *dirtied = (hbool_t *)udata2; /* Set up dirtied out value */ + H5F_super_t *ret_value; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5F_sblock_load) + + /* Short cuts */ + shared = f->shared; + lf = shared->lf; + + /* Get the shared file creation property list */ + if(NULL == (c_plist = (H5P_genplist_t *)H5I_object(shared->fcpl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "can't get property list") + + /* Allocate space for the superblock */ + if(NULL == (sblock = H5FL_CALLOC(H5F_super_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + + /* Read fixed-size portion of the superblock */ + p = sbuf; + if(H5FD_set_eoa(lf, H5FD_MEM_SUPER, f->shared->super_addr + fixed_size) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "set end of space allocation request failed") + if(H5FD_read(lf, dxpl_id, H5FD_MEM_SUPER, f->shared->super_addr, fixed_size, p) < 0) + HGOTO_ERROR(H5E_FILE, H5E_READERROR, NULL, "unable to read superblock") + + /* Skip over signature (already checked when locating the superblock) */ + p += H5F_SIGNATURE_LEN; + + /* Superblock version */ + super_vers = *p++; + if(super_vers > HDF5_SUPERBLOCK_VERSION_LATEST) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad superblock version number") + if(H5P_set(c_plist, H5F_CRT_SUPER_VERS_NAME, &super_vers) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, NULL, "unable to set superblock version") + + /* Record the superblock version */ + sblock->super_vers = super_vers; + + /* Sanity check */ + HDassert(((size_t)(p - sbuf)) == fixed_size); + + /* Determine the size of the variable-length part of the superblock */ + variable_size = H5F_SUPERBLOCK_VARLEN_SIZE(super_vers, f); + HDassert(variable_size > 0); + HDassert(fixed_size + variable_size <= sizeof(sbuf)); + + /* Read in variable-sized portion of superblock */ + if(H5FD_set_eoa(lf, H5FD_MEM_SUPER, f->shared->super_addr + fixed_size + variable_size) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "set end of space allocation request failed") + if(H5FD_read(lf, dxpl_id, H5FD_MEM_SUPER, f->shared->super_addr + fixed_size, variable_size, p) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to read superblock") + /* Check for older version of superblock format */ + if(super_vers < HDF5_SUPERBLOCK_VERSION_2) { + uint32_t status_flags; /* File status flags */ + unsigned btree_k[H5B_NUM_BTREE_ID]; /* B-tree internal node 'K' values */ + unsigned sym_leaf_k; /* Symbol table leaf node's 'K' value */ + + /* Freespace version (hard-wired) */ + if(HDF5_FREESPACE_VERSION != *p++) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad free space version number") + + /* Root group version number (hard-wired) */ + if(HDF5_OBJECTDIR_VERSION != *p++) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad object directory version number") + + /* Skip over reserved byte */ + p++; + + /* Shared header version number (hard-wired) */ + if(HDF5_SHAREDHEADER_VERSION != *p++) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad shared-header format version number") + + /* Size of file addresses */ + sizeof_addr = *p++; + if(sizeof_addr != 2 && sizeof_addr != 4 && + sizeof_addr != 8 && sizeof_addr != 16 && sizeof_addr != 32) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad byte number in an address") + if(H5P_set(c_plist, H5F_CRT_ADDR_BYTE_NUM_NAME, &sizeof_addr) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, NULL, "unable to set byte number in an address") + shared->sizeof_addr = sizeof_addr; /* Keep a local copy also */ + + /* Size of file sizes */ + sizeof_size = *p++; + if(sizeof_size != 2 && sizeof_size != 4 && + sizeof_size != 8 && sizeof_size != 16 && sizeof_size != 32) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad byte number for object size") + if(H5P_set(c_plist, H5F_CRT_OBJ_BYTE_NUM_NAME, &sizeof_size) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, NULL, "unable to set byte number for object size") + shared->sizeof_size = sizeof_size; /* Keep a local copy also */ + + /* Skip over reserved byte */ + p++; + + /* Various B-tree sizes */ + UINT16DECODE(p, sym_leaf_k); + if(sym_leaf_k == 0) + HGOTO_ERROR(H5E_FILE, H5E_BADRANGE, NULL, "bad symbol table leaf node 1/2 rank") + if(H5P_set(c_plist, H5F_CRT_SYM_LEAF_NAME, &sym_leaf_k) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, NULL, "unable to set rank for symbol table leaf nodes") + sblock->sym_leaf_k = sym_leaf_k; /* Keep a local copy also */ + + /* Need 'get' call to set other array values */ + if(H5P_get(c_plist, H5F_CRT_BTREE_RANK_NAME, btree_k) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "unable to get rank for btree internal nodes") + UINT16DECODE(p, btree_k[H5B_SNODE_ID]); + if(btree_k[H5B_SNODE_ID] == 0) + HGOTO_ERROR(H5E_FILE, H5E_BADRANGE, NULL, "bad 1/2 rank for btree internal nodes") + /* + * Delay setting the value in the property list until we've checked + * for the indexed storage B-tree internal 'K' value later. + */ + + /* File status flags (not really used yet) */ + UINT32DECODE(p, status_flags); + HDassert(status_flags <= 255); + sblock->status_flags = (uint8_t)status_flags; + if(sblock->status_flags & ~H5F_SUPER_ALL_FLAGS) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad flag value for superblock") + + /* + * If the superblock version # is greater than 0, read in the indexed + * storage B-tree internal 'K' value + */ + if(super_vers > HDF5_SUPERBLOCK_VERSION_DEF) { + UINT16DECODE(p, btree_k[H5B_CHUNK_ID]); + /* Reserved bytes are present only in version 1 */ + if(super_vers == HDF5_SUPERBLOCK_VERSION_1) + p += 2; /* reserved */ + } /* end if */ + else + btree_k[H5B_CHUNK_ID] = HDF5_BTREE_CHUNK_IK_DEF; + + /* Set the B-tree internal node values, etc */ + if(H5P_set(c_plist, H5F_CRT_BTREE_RANK_NAME, btree_k) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, NULL, "unable to set rank for btree internal nodes") + HDmemcpy(sblock->btree_k, btree_k, sizeof(unsigned) * (size_t)H5B_NUM_BTREE_ID); /* Keep a local copy also */ + + /* Remainder of "variable-sized" portion of superblock */ + H5F_addr_decode(f, (const uint8_t **)&p, &sblock->base_addr/*out*/); + H5F_addr_decode(f, (const uint8_t **)&p, &sblock->ext_addr/*out*/); + H5F_addr_decode(f, (const uint8_t **)&p, &stored_eoa/*out*/); + H5F_addr_decode(f, (const uint8_t **)&p, &sblock->driver_addr/*out*/); + + /* Allocate space for the root group symbol table entry */ + HDassert(!sblock->root_ent); + if(NULL == (sblock->root_ent = (H5G_entry_t *)H5MM_calloc(sizeof(H5G_entry_t)))) + HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, NULL, "can't allocate space for root group symbol table entry") + + /* decode the root group symbol table entry */ + if(H5G_ent_decode(f, (const uint8_t **)&p, sblock->root_ent) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTDECODE, NULL, "can't decode root group symbol table entry") + + /* Set the root group address to the correct value */ + sblock->root_addr = sblock->root_ent->header; + + /* + * Check if superblock address is different from base address and + * adjust base address and "end of address" address if so. + */ + if(!H5F_addr_eq(f->shared->super_addr, sblock->base_addr)) { + /* Check if the superblock moved earlier in the file */ + if(H5F_addr_lt(f->shared->super_addr, sblock->base_addr)) + stored_eoa -= (sblock->base_addr - f->shared->super_addr); + else + /* The superblock moved later in the file */ + stored_eoa += (f->shared->super_addr - sblock->base_addr); + + sblock->base_addr = f->shared->super_addr; + } /* end if */ + + /* Set the base address for the file in the VFD now, after adjusting + * space for possible offsets of the HDF5 data in the file. + */ + if(H5FD_set_base_addr(lf, sblock->base_addr) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "failed to set base address for file driver") + + /* This step is for h5repart tool only. If user wants to change file driver + * from family to sec2 while using h5repart, set the driver address to + * undefined to let the library ignore the family driver information saved + * in the superblock. + */ + if(H5F_HAS_FEATURE(f, H5FD_FEAT_IGNORE_DRVRINFO)) { + /* Eliminate the driver info */ + sblock->driver_addr = HADDR_UNDEF; + + /* Indicate that the superblock should be marked dirty */ + *dirtied = TRUE; + } /* end if */ + + /* Decode the optional driver information block */ + if(H5F_addr_defined(sblock->driver_addr)) { + uint8_t dbuf[H5F_MAX_DRVINFOBLOCK_SIZE]; /* Buffer for driver info block */ + char drv_name[9]; /* Name of driver */ + unsigned drv_vers; /* Version of driver info block */ + size_t drv_variable_size; /* Size of variable-length portion of driver info block, in bytes */ + + /* Read in fixed-sized portion of driver info block */ + p = dbuf; + if(H5FD_set_eoa(lf, H5FD_MEM_SUPER, sblock->driver_addr + H5F_DRVINFOBLOCK_HDR_SIZE) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "set end of space allocation request failed") + if(H5FD_read(lf, dxpl_id, H5FD_MEM_SUPER, sblock->driver_addr, (size_t)H5F_DRVINFOBLOCK_HDR_SIZE, p) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to read driver information block") + + /* Version number */ + drv_vers = *p++; + if(drv_vers != HDF5_DRIVERINFO_VERSION_0) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "bad driver information block version number") + + p += 3; /* reserved bytes */ + + /* Driver info size */ + UINT32DECODE(p, drv_variable_size); + + /* Sanity check */ + HDassert(H5F_DRVINFOBLOCK_HDR_SIZE + drv_variable_size <= sizeof(dbuf)); + + /* Driver name and/or version */ + HDstrncpy(drv_name, (const char *)p, (size_t)8); + drv_name[8] = '\0'; + p += 8; /* advance past name/version */ + + /* Check if driver matches driver information saved. Unfortunately, we can't push this + * function to each specific driver because we're checking if the driver is correct. + */ + if(!HDstrncmp(drv_name, "NCSAfami", (size_t)8) && HDstrcmp(lf->cls->name, "family")) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "family driver should be used") + if(!HDstrncmp(drv_name, "NCSAmult", (size_t)8) && HDstrcmp(lf->cls->name, "multi")) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "multi driver should be used") + + /* Read in variable-sized portion of driver info block */ + if(H5FD_set_eoa(lf, H5FD_MEM_SUPER, sblock->driver_addr + H5F_DRVINFOBLOCK_HDR_SIZE + drv_variable_size) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "set end of space allocation request failed") + if(H5FD_read(lf, dxpl_id, H5FD_MEM_SUPER, sblock->driver_addr + H5F_DRVINFOBLOCK_HDR_SIZE, drv_variable_size, p) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to read file driver information") + + /* Decode driver information */ + if(H5FD_sb_decode(lf, drv_name, p) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to decode driver information") + } /* end if */ + } /* end if */ + else { + uint32_t computed_chksum; /* Computed checksum */ + uint32_t read_chksum; /* Checksum read from file */ + + /* Size of file addresses */ + sizeof_addr = *p++; + if(sizeof_addr != 2 && sizeof_addr != 4 && + sizeof_addr != 8 && sizeof_addr != 16 && sizeof_addr != 32) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad byte number in an address") + if(H5P_set(c_plist, H5F_CRT_ADDR_BYTE_NUM_NAME, &sizeof_addr) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, NULL, "unable to set byte number in an address") + shared->sizeof_addr = sizeof_addr; /* Keep a local copy also */ + + /* Size of file sizes */ + sizeof_size = *p++; + if(sizeof_size != 2 && sizeof_size != 4 && + sizeof_size != 8 && sizeof_size != 16 && sizeof_size != 32) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad byte number for object size") + if(H5P_set(c_plist, H5F_CRT_OBJ_BYTE_NUM_NAME, &sizeof_size) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, NULL, "unable to set byte number for object size") + shared->sizeof_size = sizeof_size; /* Keep a local copy also */ + + /* File status flags (not really used yet) */ + sblock->status_flags = *p++; + if(sblock->status_flags & ~H5F_SUPER_ALL_FLAGS) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad flag value for superblock") + + /* Base, superblock extension, end of file & root group object header addresses */ + H5F_addr_decode(f, (const uint8_t **)&p, &sblock->base_addr/*out*/); + H5F_addr_decode(f, (const uint8_t **)&p, &sblock->ext_addr/*out*/); + H5F_addr_decode(f, (const uint8_t **)&p, &stored_eoa/*out*/); + H5F_addr_decode(f, (const uint8_t **)&p, &sblock->root_addr/*out*/); + + /* Compute checksum for superblock */ + computed_chksum = H5_checksum_metadata(sbuf, (size_t)(p - sbuf), 0); + + /* Decode checksum */ + UINT32DECODE(p, read_chksum); + + /* Verify correct checksum */ + if(read_chksum != computed_chksum) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "bad checksum on driver information block") + + /* + * Check if superblock address is different from base address and + * adjust base address and "end of address" address if so. + */ + if(!H5F_addr_eq(f->shared->super_addr, sblock->base_addr)) { + /* Check if the superblock moved earlier in the file */ + if(H5F_addr_lt(f->shared->super_addr, sblock->base_addr)) + stored_eoa -= (sblock->base_addr - f->shared->super_addr); + else + /* The superblock moved later in the file */ + stored_eoa += (f->shared->super_addr - sblock->base_addr); + + sblock->base_addr = f->shared->super_addr; + } /* end if */ + + /* Set the base address for the file in the VFD now, after adjusting + * space for possible offsets of the HDF5 data in the file. + */ + if(H5FD_set_base_addr(lf, sblock->base_addr) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "failed to set base address for file driver") + + /* Get the B-tree internal node values, etc */ + if(H5P_get(c_plist, H5F_CRT_BTREE_RANK_NAME, sblock->btree_k) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "unable to get rank for btree internal nodes") + } /* end else */ + + /* + * The user-defined data is the area of the file before the base + * address. + */ + if(H5P_set(c_plist, H5F_CRT_USER_BLOCK_NAME, &sblock->base_addr) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, NULL, "unable to set userblock size") + + /* + * Make sure that the data is not truncated. One case where this is + * possible is if the first file of a family of files was opened + * individually. + */ + if(HADDR_UNDEF == (eof = H5FD_get_eof(lf))) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to determine file size") + + /* (Account for the stored EOA being absolute offset -QAK) */ + if((eof + sblock->base_addr) < stored_eoa) + HGOTO_ERROR(H5E_FILE, H5E_TRUNCATED, NULL, "truncated file") + + /* + * Tell the file driver how much address space has already been + * allocated so that it knows how to allocate additional memory. + */ + /* (Account for the stored EOA being absolute offset -NAF) */ + if(H5FD_set_eoa(lf, H5FD_MEM_SUPER, stored_eoa - sblock->base_addr) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to set end-of-address marker for file") + + /* Read the file's superblock extension, if there is one. */ + if(H5F_addr_defined(sblock->ext_addr)) { + H5O_loc_t ext_loc; /* "Object location" for superblock extension */ + H5O_btreek_t btreek; /* v1 B-tree 'K' value message from superblock extension */ + H5O_drvinfo_t drvinfo; /* Driver info message from superblock extension */ + htri_t status; /* Status for message existing */ + + /* Sanity check - superblock extension should only be defined for + * superblock version >= 2. + */ + HDassert(super_vers >= HDF5_SUPERBLOCK_VERSION_2); + + /* Check for superblock extension being located "outside" the stored + * 'eoa' value, which can occur with the split/multi VFD. + */ + if(H5F_addr_gt(sblock->ext_addr, stored_eoa)) { + /* Set the 'eoa' for the object header memory type large enough + * to give some room for a reasonably sized superblock extension. + * (This is _rather_ a kludge -QAK) + */ + if(H5FD_set_eoa(lf, H5FD_MEM_OHDR, (haddr_t)(sblock->ext_addr + 1024)) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to set end-of-address marker for file") + } /* end if */ + + /* Open the superblock extension */ + if(H5F_super_ext_open(f, sblock->ext_addr, &ext_loc) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENOBJ, NULL, "unable to open file's superblock extension") + + /* Check for the extension having a 'driver info' message */ + if((status = H5O_msg_exists(&ext_loc, H5O_DRVINFO_ID, dxpl_id)) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "unable to read object header") + if(status) { + /* Check for ignoring the driver info for this file */ + if(H5F_HAS_FEATURE(f, H5FD_FEAT_IGNORE_DRVRINFO)) { + /* Indicate that the superblock should be marked dirty */ + *dirtied = TRUE; + } /* end if */ + else { + /* Retrieve the 'driver info' structure */ + if(NULL == H5O_msg_read(&ext_loc, H5O_DRVINFO_ID, &drvinfo, dxpl_id)) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "driver info message not present") + + /* Check if driver matches driver information saved. Unfortunately, we can't push this + * function to each specific driver because we're checking if the driver is correct. + */ + if(!HDstrncmp(drvinfo.name, "NCSAfami", (size_t)8) && HDstrcmp(lf->cls->name, "family")) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "family driver should be used") + if(!HDstrncmp(drvinfo.name, "NCSAmult", (size_t)8) && HDstrcmp(lf->cls->name, "multi")) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "multi driver should be used") + + /* Decode driver information */ + if(H5FD_sb_decode(lf, drvinfo.name, drvinfo.buf) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to decode driver information") + + /* Reset driver info message */ + H5O_msg_reset(H5O_DRVINFO_ID, &drvinfo); + } /* end else */ + } /* end if */ + + /* Read in the shared OH message information if there is any */ + if(H5SM_get_info(&ext_loc, c_plist, dxpl_id) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to read SOHM table information") + + /* Check for the extension having a 'v1 B-tree "K"' message */ + if((status = H5O_msg_exists(&ext_loc, H5O_BTREEK_ID, dxpl_id)) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "unable to read object header") + if(status) { + /* Retrieve the 'v1 B-tree "K"' structure */ + if(NULL == H5O_msg_read(&ext_loc, H5O_BTREEK_ID, &btreek, dxpl_id)) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "v1 B-tree 'K' info message not present") + + /* Set non-default v1 B-tree 'K' value info from file */ + sblock->btree_k[H5B_CHUNK_ID] = btreek.btree_k[H5B_CHUNK_ID]; + sblock->btree_k[H5B_SNODE_ID] = btreek.btree_k[H5B_SNODE_ID]; + sblock->sym_leaf_k = btreek.sym_leaf_k; + + /* Set non-default v1 B-tree 'K' values in the property list */ + if(H5P_set(c_plist, H5F_CRT_BTREE_RANK_NAME, btreek.btree_k) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, NULL, "unable to set rank for btree internal nodes") + if(H5P_set(c_plist, H5F_CRT_SYM_LEAF_NAME, &btreek.sym_leaf_k) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, NULL, "unable to set rank for symbol table leaf nodes") + } /* end if */ + else { + /* No non-default v1 B-tree 'K' value info in file, use defaults */ + sblock->btree_k[H5B_CHUNK_ID] = HDF5_BTREE_CHUNK_IK_DEF; + sblock->btree_k[H5B_SNODE_ID] = HDF5_BTREE_SNODE_IK_DEF; + sblock->sym_leaf_k = H5F_CRT_SYM_LEAF_DEF; + } /* end if */ + + /* Close superblock extension */ + if(H5F_super_ext_close(f, &ext_loc) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, NULL, "unable to close file's superblock extension") + } /* end if */ + + /* Set return value */ + ret_value = sblock; + +done: + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5F_sblock_load() */ + + +/*------------------------------------------------------------------------- + * Function: H5F_sblock_flush + * + * Purpose: Flushes the superblock. + * + * Return: Success: SUCCEED + * Failure: NULL + * + * Programmer: Mike McGreevy + * mamcgree@hdfgroup.org + * April 8, 2009 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5F_sblock_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5F_super_t *sblock) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI_NOINIT(H5F_sblock_flush) + + /* check arguments */ + HDassert(f); + HDassert(sblock); + + if(sblock->cache_info.is_dirty) { + uint8_t buf[H5F_MAX_SUPERBLOCK_SIZE + H5F_MAX_DRVINFOBLOCK_SIZE]; /* Superblock & driver info blockencoding buffer */ + uint8_t *p; /* Ptr into encoding buffer */ + haddr_t rel_eoa; /* Relative EOA for file */ + size_t superblock_size; /* Size of superblock, in bytes */ + size_t driver_size; /* Size of driver info block (bytes)*/ + + /* Encode the common portion of the file superblock for all versions */ + p = buf; + HDmemcpy(p, H5F_SIGNATURE, (size_t)H5F_SIGNATURE_LEN); + p += H5F_SIGNATURE_LEN; + *p++ = (uint8_t)sblock->super_vers; + + /* Check for older version of superblock format */ + if(sblock->super_vers < HDF5_SUPERBLOCK_VERSION_2) { + *p++ = (uint8_t)HDF5_FREESPACE_VERSION; /* (hard-wired) */ + *p++ = (uint8_t)HDF5_OBJECTDIR_VERSION; /* (hard-wired) */ + *p++ = 0; /* reserved*/ + + *p++ = (uint8_t)HDF5_SHAREDHEADER_VERSION; /* (hard-wired) */ + HDassert(H5F_SIZEOF_ADDR(f) <= 255); + *p++ = (uint8_t)H5F_SIZEOF_ADDR(f); + HDassert(H5F_SIZEOF_SIZE(f) <= 255); + *p++ = (uint8_t)H5F_SIZEOF_SIZE(f); + *p++ = 0; /* reserved */ + + UINT16ENCODE(p, sblock->sym_leaf_k); + UINT16ENCODE(p, sblock->btree_k[H5B_SNODE_ID]); + UINT32ENCODE(p, (uint32_t)sblock->status_flags); + + /* + * Versions of the superblock >0 have the indexed storage B-tree + * internal 'K' value stored + */ + if(sblock->super_vers > HDF5_SUPERBLOCK_VERSION_DEF) { + UINT16ENCODE(p, sblock->btree_k[H5B_CHUNK_ID]); + *p++ = 0; /*reserved */ + *p++ = 0; /*reserved */ + } /* end if */ + + H5F_addr_encode(f, &p, sblock->base_addr); + H5F_addr_encode(f, &p, sblock->ext_addr); + rel_eoa = H5FD_get_eoa(f->shared->lf, H5FD_MEM_SUPER); + H5F_addr_encode(f, &p, (rel_eoa + sblock->base_addr)); + H5F_addr_encode(f, &p, sblock->driver_addr); + + /* Encode the root group object entry, including the cached stab info */ + if(H5G_ent_encode(f, &p, sblock->root_ent) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTENCODE, FAIL, "can't encode root group symbol table entry") + + /* Encode the driver information block. */ + H5_ASSIGN_OVERFLOW(driver_size, H5FD_sb_size(f->shared->lf), hsize_t, size_t); + + /* Checking whether driver block address is defined here is to handle backward + * compatibility. If the file was created with v1.6 library or earlier and no + * driver info block was written in the superblock, we don't write it either even + * though there's some driver info. Otherwise, the driver block extended will + * overwrite the (meta)data right after the superblock. This situation happens to + * the family driver particularly. SLU - 2009/3/24 + */ + if(driver_size > 0 && H5F_addr_defined(sblock->driver_addr)) { + char driver_name[9]; /* Name of driver, for driver info block */ + uint8_t *dbuf = p; /* Pointer to beginning of driver info */ + + /* Encode the driver information block */ + *p++ = HDF5_DRIVERINFO_VERSION_0; /* Version */ + *p++ = 0; /* reserved */ + *p++ = 0; /* reserved */ + *p++ = 0; /* reserved */ + + /* Driver info size, excluding header */ + UINT32ENCODE(p, driver_size); + + /* Encode driver-specific data */ + if(H5FD_sb_encode(f->shared->lf, driver_name, dbuf + H5F_DRVINFOBLOCK_HDR_SIZE) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to encode driver information") + + /* Store driver name (set in 'H5FD_sb_encode' call above) */ + HDmemcpy(p, driver_name, (size_t)8); + + /* Advance buffer pointer past name & variable-sized portion of driver info */ + /* (for later use in computing the superblock size) */ + p += 8 + driver_size; + } /* end if */ + } /* end if */ + else { + uint32_t chksum; /* Checksum temporary variable */ + H5O_loc_t *root_oloc; /* Pointer to root group's object location */ + + /* Size of file addresses & offsets, and status flags */ + HDassert(H5F_SIZEOF_ADDR(f) <= 255); + *p++ = (uint8_t)H5F_SIZEOF_ADDR(f); + HDassert(H5F_SIZEOF_SIZE(f) <= 255); + *p++ = (uint8_t)H5F_SIZEOF_SIZE(f); + *p++ = sblock->status_flags; + + /* Base, superblock extension & end of file addresses */ + H5F_addr_encode(f, &p, sblock->base_addr); + H5F_addr_encode(f, &p, sblock->ext_addr); + rel_eoa = H5FD_get_eoa(f->shared->lf, H5FD_MEM_SUPER); + H5F_addr_encode(f, &p, (rel_eoa + sblock->base_addr)); + + /* Retrieve information for root group */ + if(NULL == (root_oloc = H5G_oloc(f->shared->root_grp))) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to retrieve root group information") + + /* Encode address of root group's object header */ + H5F_addr_encode(f, &p, root_oloc->addr); + + /* Compute superblock checksum */ + chksum = H5_checksum_metadata(buf, (H5F_SUPERBLOCK_SIZE(sblock->super_vers, f) - H5F_SIZEOF_CHKSUM), 0); + + /* Superblock checksum */ + UINT32ENCODE(p, chksum); + + /* Sanity check */ + HDassert((size_t)(p - buf) == H5F_SUPERBLOCK_SIZE(sblock->super_vers, f)); + } /* end else */ + + /* Retrieve the total size of the superblock info */ + H5_ASSIGN_OVERFLOW(superblock_size, (p - buf), int, size_t); + + /* Double check we didn't overrun the block (unlikely) */ + HDassert(superblock_size <= sizeof(buf)); + + /* Write superblock */ + /* (always at relative address 0) */ + if(H5FD_write(f->shared->lf, dxpl_id, H5FD_MEM_SUPER, (haddr_t)0, superblock_size, buf) < 0) + HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to write superblock") + + /* Check for newer version of superblock format & superblock extension */ + if(sblock->super_vers >= HDF5_SUPERBLOCK_VERSION_2 && H5F_addr_defined(sblock->ext_addr)) { + /* Check for ignoring the driver info for this file */ + if(!H5F_HAS_FEATURE(f, H5FD_FEAT_IGNORE_DRVRINFO)) { + /* Check for driver info message */ + H5_ASSIGN_OVERFLOW(driver_size, H5FD_sb_size(f->shared->lf), hsize_t, size_t); + if(driver_size > 0) { + H5O_drvinfo_t drvinfo; /* Driver info */ + uint8_t dbuf[H5F_MAX_DRVINFOBLOCK_SIZE]; /* Driver info block encoding buffer */ + + /* Sanity check */ + HDassert(driver_size <= H5F_MAX_DRVINFOBLOCK_SIZE); + + /* Encode driver-specific data */ + if(H5FD_sb_encode(f->shared->lf, drvinfo.name, dbuf) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to encode driver information") + + /* Write driver info information to the superblock extension */ + drvinfo.len = driver_size; + drvinfo.buf = dbuf; + if(H5F_super_ext_write_msg(f, dxpl_id, &drvinfo, H5O_DRVINFO_ID, FALSE) < 0) + HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "unable to update driver info header message") + } /* end if */ + } /* end if */ + } /* end if */ + + /* Reset the dirty flag. */ + sblock->cache_info.is_dirty = FALSE; + } /* end if */ + + if(destroy) + if(H5F_sblock_dest(f, sblock) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CLOSEERROR, FAIL, "can't close superblock") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5F_sblock_flush() */ + + +/*------------------------------------------------------------------------- + * Function: H5F_sblock_dest + * + * Purpose: Frees memory used by the superblock. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Mike McGreevy + * April 8, 2009 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5F_sblock_dest(H5F_t UNUSED *f, H5F_super_t* sblock) +{ + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_sblock_dest) + + /* Sanity check */ + HDassert(sblock); + + /* Free root group symbol table entry, if any */ + sblock->root_ent = (H5G_entry_t *)H5MM_xfree(sblock->root_ent); + + /* Free superblock */ + sblock = (H5F_super_t *)H5FL_FREE(H5F_super_t, sblock); + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5F_sblock_dest() */ + + +/*------------------------------------------------------------------------- + * Function: H5F_sblock_clear + * + * Purpose: Mark the superblock as no longer being dirty. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Mike McGreevy + * April 8, 2009 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5F_sblock_clear(H5F_t *f, H5F_super_t *sblock, hbool_t destroy) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5F_sblock_clear) + + /* + * Check arguments. + */ + HDassert(sblock); + + /* Reset the dirty flag. */ + sblock->cache_info.is_dirty = FALSE; + + if(destroy) + if(H5F_sblock_dest(f, sblock) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTFREE, FAIL, "unable to delete superblock") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5F_sblock_clear() */ + + +/*------------------------------------------------------------------------- + * Function: H5F_sblock_size + * + * Purpose: Returns the size of the superblock encoded on disk. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Mike McGreevy + * April 8, 2009 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5F_sblock_size(const H5F_t *f, const H5F_super_t *sblock, size_t *size_ptr) +{ + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_sblock_size) + + /* check arguments */ + HDassert(f); + HDassert(sblock); + HDassert(size_ptr); + + /* Set size value */ + *size_ptr = H5F_SUPERBLOCK_SIZE(sblock->super_vers, f); + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5F_sblock_size() */ + diff --git a/src/H5Ftest.c b/src/H5Ftest.c index 72fee96..e2ee606 100644 --- a/src/H5Ftest.c +++ b/src/H5Ftest.c @@ -146,7 +146,7 @@ H5F_check_cached_stab_test(hid_t file_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") /* Verify the cached stab info */ - if(H5G_verify_cached_stab_test(H5G_oloc(file->shared->root_grp), file->shared->root_ent) < 0) + if(H5G_verify_cached_stab_test(H5G_oloc(file->shared->root_grp), file->shared->sblock->root_ent) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to verify cached symbol table info") done: diff --git a/src/H5Gent.c b/src/H5Gent.c index 7a9e9e5..65f302c 100644 --- a/src/H5Gent.c +++ b/src/H5Gent.c @@ -28,15 +28,10 @@ #include "H5FLprivate.h" /* Free Lists */ #include "H5Gpkg.h" /* Groups */ #include "H5HLprivate.h" /* Local Heaps */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory Management */ /* Private macros */ /* Private prototypes */ -static herr_t H5G_ent_encode(H5F_t *f, uint8_t **pp, const H5G_entry_t *ent); -static herr_t H5G_ent_decode(H5F_t *f, const uint8_t **pp, - H5G_entry_t *ent/*out*/); /* Declare extern the PQ free list for the wrapped strings */ H5FL_BLK_EXTERN(str_buf); @@ -48,9 +43,6 @@ H5FL_BLK_EXTERN(str_buf); * Purpose: Same as H5G_ent_decode() except it does it for an array of * symbol table entries. * - * Errors: - * SYM CANTDECODE Can't decode. - * * Return: Success: Non-negative, with *pp pointing to the first byte * after the last symbol. * @@ -60,31 +52,29 @@ H5FL_BLK_EXTERN(str_buf); * matzke@llnl.gov * Jul 18 1997 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t H5G_ent_decode_vec(H5F_t *f, const uint8_t **pp, H5G_entry_t *ent, unsigned n) { - unsigned u; - herr_t ret_value=SUCCEED; /* Return value */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5G_ent_decode_vec, FAIL); + FUNC_ENTER_NOAPI(H5G_ent_decode_vec, FAIL) /* check arguments */ - assert(f); - assert(pp); - assert(ent); + HDassert(f); + HDassert(pp); + HDassert(ent); /* decode entries */ - for (u = 0; u < n; u++) - if (H5G_ent_decode(f, pp, ent + u) < 0) + for(u = 0; u < n; u++) + if(H5G_ent_decode(f, pp, ent + u) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDECODE, FAIL, "can't decode") done: - FUNC_LEAVE_NOAPI(ret_value); -} + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5G_ent_decode_vec() */ /*------------------------------------------------------------------------- @@ -92,8 +82,6 @@ done: * * Purpose: Decodes a symbol table entry pointed to by `*pp'. * - * Errors: - * * Return: Success: Non-negative with *pp pointing to the first byte * following the symbol table entry. * @@ -103,25 +91,23 @@ done: * matzke@llnl.gov * Jul 18 1997 * - * Modifications: - * Robb Matzke, 17 Jul 1998 - * Added a 4-byte padding field for alignment and future expansion. - * *------------------------------------------------------------------------- */ -static herr_t +herr_t H5G_ent_decode(H5F_t *f, const uint8_t **pp, H5G_entry_t *ent) { const uint8_t *p_ret = *pp; uint32_t tmp; + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_ent_decode) + FUNC_ENTER_NOAPI(H5G_ent_decode, FAIL) /* check arguments */ HDassert(f); HDassert(pp); HDassert(ent); + /* Set the entry's file pointer */ ent->file = f; /* decode header */ @@ -129,31 +115,31 @@ H5G_ent_decode(H5F_t *f, const uint8_t **pp, H5G_entry_t *ent) H5F_addr_decode(f, pp, &(ent->header)); UINT32DECODE(*pp, tmp); *pp += 4; /*reserved*/ - ent->type=(H5G_cache_type_t)tmp; + ent->type = (H5G_cache_type_t)tmp; /* decode scratch-pad */ - switch (ent->type) { + switch(ent->type) { case H5G_NOTHING_CACHED: break; case H5G_CACHED_STAB: - assert(2 * H5F_SIZEOF_ADDR(f) <= H5G_SIZEOF_SCRATCH); + HDassert(2 * H5F_SIZEOF_ADDR(f) <= H5G_SIZEOF_SCRATCH); H5F_addr_decode(f, pp, &(ent->cache.stab.btree_addr)); H5F_addr_decode(f, pp, &(ent->cache.stab.heap_addr)); break; case H5G_CACHED_SLINK: - UINT32DECODE (*pp, ent->cache.slink.lval_offset); + UINT32DECODE(*pp, ent->cache.slink.lval_offset); break; default: - /* Error or unknown type. Bail out. */ - return -1; - } + HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "unknown symbol table entry cache type") + } /* end switch */ *pp = p_ret + H5G_SIZEOF_ENTRY(f); - FUNC_LEAVE_NOAPI(SUCCEED) +done: + FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_ent_decode() */ @@ -163,9 +149,6 @@ H5G_ent_decode(H5F_t *f, const uint8_t **pp, H5G_entry_t *ent) * Purpose: Same as H5G_ent_encode() except it does it for an array of * symbol table entries. * - * Errors: - * SYM CANTENCODE Can't encode. - * * Return: Success: Non-negative, with *pp pointing to the first byte * after the last symbol. * @@ -175,31 +158,29 @@ H5G_ent_decode(H5F_t *f, const uint8_t **pp, H5G_entry_t *ent) * matzke@llnl.gov * Jul 18 1997 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t H5G_ent_encode_vec(H5F_t *f, uint8_t **pp, const H5G_entry_t *ent, unsigned n) { - unsigned u; - herr_t ret_value=SUCCEED; /* Return value */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5G_ent_encode_vec, FAIL); + FUNC_ENTER_NOAPI(H5G_ent_encode_vec, FAIL) /* check arguments */ - assert(f); - assert(pp); - assert(ent); + HDassert(f); + HDassert(pp); + HDassert(ent); /* encode entries */ - for (u = 0; u < n; u++) - if (H5G_ent_encode(f, pp, ent + u) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTENCODE, FAIL, "can't encode"); + for(u = 0; u < n; u++) + if(H5G_ent_encode(f, pp, ent + u) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTENCODE, FAIL, "can't encode") done: - FUNC_LEAVE_NOAPI(ret_value); -} + FUNC_LEAVE_NOAPI(ret_value) +} /* H5G_ent_encode_vec() */ /*------------------------------------------------------------------------- @@ -208,8 +189,6 @@ done: * Purpose: Encodes the specified symbol table entry into the buffer * pointed to by *pp. * - * Errors: - * * Return: Success: Non-negative, with *pp pointing to the first byte * after the symbol table entry. * @@ -219,26 +198,22 @@ done: * matzke@llnl.gov * Jul 18 1997 * - * Modifications: - * - * Robb Matzke, 8 Aug 1997 - * Writes zeros for the bytes that aren't used so the file doesn't - * contain junk. - * *------------------------------------------------------------------------- */ -static herr_t -H5G_ent_encode(H5F_t *f, uint8_t **pp, const H5G_entry_t *ent) +herr_t +H5G_ent_encode(const H5F_t *f, uint8_t **pp, const H5G_entry_t *ent) { - uint8_t *p_ret = *pp + H5G_SIZEOF_ENTRY(f); + uint8_t *p_ret = *pp + H5G_SIZEOF_ENTRY(f); + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_ent_encode); + FUNC_ENTER_NOAPI(H5G_ent_encode, FAIL) /* check arguments */ - assert(f); - assert(pp); + HDassert(f); + HDassert(pp); - if (ent) { + /* Check for actual entry to encode */ + if(ent) { /* encode header */ H5F_ENCODE_LENGTH(f, *pp, ent->name_off); H5F_addr_encode(f, pp, ent->header); @@ -246,37 +221,39 @@ H5G_ent_encode(H5F_t *f, uint8_t **pp, const H5G_entry_t *ent) UINT32ENCODE(*pp, 0); /*reserved*/ /* encode scratch-pad */ - switch (ent->type) { + switch(ent->type) { case H5G_NOTHING_CACHED: break; case H5G_CACHED_STAB: - assert(2 * H5F_SIZEOF_ADDR(f) <= H5G_SIZEOF_SCRATCH); + HDassert(2 * H5F_SIZEOF_ADDR(f) <= H5G_SIZEOF_SCRATCH); H5F_addr_encode(f, pp, ent->cache.stab.btree_addr); H5F_addr_encode(f, pp, ent->cache.stab.heap_addr); break; case H5G_CACHED_SLINK: - UINT32ENCODE (*pp, ent->cache.slink.lval_offset); + UINT32ENCODE(*pp, ent->cache.slink.lval_offset); break; default: - /* Unknown cached type. Bail out. */ - return -1; - } - } else { + HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "unknown symbol table entry cache type") + } /* end switch */ + } /* end if */ + else { H5F_ENCODE_LENGTH(f, *pp, 0); H5F_addr_encode(f, pp, HADDR_UNDEF); UINT32ENCODE(*pp, H5G_NOTHING_CACHED); UINT32ENCODE(*pp, 0); /*reserved*/ - } + } /* end else */ /* fill with zero */ - while (*pp < p_ret) *(*pp)++ = 0; + while(*pp < p_ret) + *(*pp)++ = 0; *pp = p_ret; - FUNC_LEAVE_NOAPI(SUCCEED); -} +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5G_ent_encode() */ /*------------------------------------------------------------------------- diff --git a/src/H5Gprivate.h b/src/H5Gprivate.h index 7f001e0..ff20fe6 100644 --- a/src/H5Gprivate.h +++ b/src/H5Gprivate.h @@ -129,10 +129,8 @@ typedef struct { } H5G_name_t; /* Forward declarations (for prototypes & struct definitions) */ -struct H5P_genplist_t; struct H5O_loc_t; struct H5O_link_t; -struct H5O_t; /* * The "location" of an object in a group hierarchy. This points to an object @@ -181,8 +179,9 @@ H5_DLL herr_t H5G_node_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream /* * These functions operate on group object locations. */ -H5_DLL herr_t H5G_root_ent_decode(H5F_t *f, const uint8_t **pp); -H5_DLL herr_t H5G_root_ent_encode(H5F_t *f, uint8_t **pp); +H5_DLL herr_t H5G_ent_encode(const H5F_t *f, uint8_t **pp, + const H5G_entry_t *ent); +H5_DLL herr_t H5G_ent_decode(H5F_t *f, const uint8_t **pp, H5G_entry_t *ent/*out*/); /* * These functions operate on group hierarchy names. diff --git a/src/H5Groot.c b/src/H5Groot.c index b8a1468..5d07142 100644 --- a/src/H5Groot.c +++ b/src/H5Groot.c @@ -13,7 +13,7 @@ * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - /*------------------------------------------------------------------------- +/*------------------------------------------------------------------------- * * Created: H5Gobj.c * Apr 8 2009 @@ -76,99 +76,6 @@ H5G_rootof(H5F_t *f) /*------------------------------------------------------------------------- - * Function: H5G_root_ent_decode - * - * Purpose: Decodes the root group symbol table entry into the file - * structure, and updates the root group address in the file - * structure. - * - * Return: Success: Non-negative with *pp pointing to the first byte - * following the symbol table entry. - * - * Failure: Negative - * - * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu - * Sep 26 2005 - * - *------------------------------------------------------------------------- - */ -herr_t -H5G_root_ent_decode(H5F_t *f, const uint8_t **pp) -{ - const uint8_t *p_ret = *pp + H5G_SIZEOF_ENTRY(f); - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(H5G_root_ent_decode, FAIL) - - /* check arguments */ - HDassert(f); - HDassert(pp); - - /* Allocate space for the root group symbol table entry */ - HDassert(!f->shared->root_ent); - if(NULL == (f->shared->root_ent = (H5G_entry_t *) H5MM_calloc(sizeof(H5G_entry_t)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "can't allocate space for symbol table entry") - - /* decode the root group symbol table entry */ - if(H5G_ent_decode_vec(f, pp, f->shared->root_ent, 1) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTDECODE, FAIL, "can't decode symbol table entry") - - /* Set the root group address to the correct value */ - f->shared->root_addr = f->shared->root_ent->header; - - /* Set decode pointer */ - *pp = p_ret; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G_root_ent_decode() */ - - -/*------------------------------------------------------------------------- - * Function: H5G_root_ent_encode - * - * Purpose: Encodes the root group symbol table entry into the buffer - * pointed to by *pp. - * - * Return: Success: Non-negative, with *pp pointing to the first byte - * after the symbol table entry. - * - * Failure: Negative - * - * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu - * Sep 26 2005 - * - *------------------------------------------------------------------------- - */ -herr_t -H5G_root_ent_encode(H5F_t *f, uint8_t **pp) -{ - uint8_t *p_ret = *pp + H5G_SIZEOF_ENTRY(f); - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(H5G_root_ent_encode, FAIL) - - /* check arguments */ - HDassert(f); - HDassert(f->shared); - HDassert(f->shared->root_ent); - HDassert(pp); - - /* Encode entry */ - if(H5G_ent_encode_vec(f, pp, f->shared->root_ent, 1) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTENCODE, FAIL, "can't encode symbol table entry") - - /* Set encode pointer */ - *pp = p_ret; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G_root_ent_encode() */ - - -/*------------------------------------------------------------------------- * Function: H5G_mkroot * * Purpose: Creates a root group in an empty file and opens it. If a @@ -191,12 +98,15 @@ H5G_mkroot(H5F_t *f, hid_t dxpl_id, hbool_t create_root) { H5G_loc_t root_loc; /* Root location information */ htri_t stab_exists = -1; /* Whether the symbol table exists */ - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t sblock_dirty = FALSE; /* Whether superblock was dirtied */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5G_mkroot, FAIL) /* check args */ HDassert(f); + HDassert(f->shared); + HDassert(f->shared->sblock); /* Check if the root group is already initialized */ if(f->shared->root_grp) @@ -230,7 +140,6 @@ H5G_mkroot(H5F_t *f, hid_t dxpl_id, hbool_t create_root) H5P_genplist_t *fc_plist; /* File creation property list */ H5O_ginfo_t ginfo; /* Group info parameters */ H5O_linfo_t linfo; /* Link info parameters */ - unsigned super_vers; /* Superblock version */ /* Get the file creation property list */ /* (Which is a sub-class of the group creation property class) */ @@ -245,34 +154,33 @@ H5G_mkroot(H5F_t *f, hid_t dxpl_id, hbool_t create_root) if(H5P_get(fc_plist, H5G_CRT_LINK_INFO_NAME, &linfo) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get link info") - /* Get the superblock version */ - if(H5P_get(fc_plist, H5F_CRT_SUPER_VERS_NAME, &super_vers) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get superblock version") - /* Create root group */ if(H5G_obj_create(f, dxpl_id, &ginfo, &linfo, f->shared->fcpl_id, root_loc.oloc/*out*/) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group entry") if(1 != H5O_link(root_loc.oloc, 1, dxpl_id)) HGOTO_ERROR(H5E_SYM, H5E_LINKCOUNT, FAIL, "internal error (wrong link count)") + /* Mark superblock dirty, so root group info is flushed */ + sblock_dirty = TRUE; + /* Create the root group symbol table entry */ - HDassert(!f->shared->root_ent); - if(super_vers < HDF5_SUPERBLOCK_VERSION_2) { + HDassert(!f->shared->sblock->root_ent); + if(f->shared->sblock->super_vers < HDF5_SUPERBLOCK_VERSION_2) { /* Allocate space for the root group symbol table entry */ - if(NULL == (f->shared->root_ent = (H5G_entry_t *) H5MM_calloc(sizeof(H5G_entry_t)))) + if(NULL == (f->shared->sblock->root_ent = (H5G_entry_t *)H5MM_calloc(sizeof(H5G_entry_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "can't allocate space for symbol table entry") /* Initialize the root group symbol table entry */ - f->shared->root_ent->dirty = TRUE; - f->shared->root_ent->type = H5G_NOTHING_CACHED; /* We will cache the stab later */ - f->shared->root_ent->name_off = 0; /* No name (yet) */ - f->shared->root_ent->header = root_loc.oloc->addr; - f->shared->root_ent->file = root_loc.oloc->file; + f->shared->sblock->root_ent->dirty = TRUE; + f->shared->sblock->root_ent->type = H5G_NOTHING_CACHED; /* We will cache the stab later */ + f->shared->sblock->root_ent->name_off = 0; /* No name (yet) */ + f->shared->sblock->root_ent->header = root_loc.oloc->addr; + f->shared->sblock->root_ent->file = root_loc.oloc->file; } /* end if */ } /* end if */ else { /* Create root group object location from f */ - root_loc.oloc->addr = f->shared->root_addr; + root_loc.oloc->addr = f->shared->sblock->root_addr; root_loc.oloc->file = f; /* @@ -282,7 +190,7 @@ H5G_mkroot(H5F_t *f, hid_t dxpl_id, hbool_t create_root) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open root group") /* Actions to take if the symbol table information is cached */ - if(f->shared->root_ent && f->shared->root_ent->type == H5G_CACHED_STAB) { + if(f->shared->sblock->root_ent && f->shared->sblock->root_ent->type == H5G_CACHED_STAB) { /* Check for the situation where the symbol table is cached but does * not exist. This can happen if, for example, an external link is * added to the root group. */ @@ -291,7 +199,7 @@ H5G_mkroot(H5F_t *f, hid_t dxpl_id, hbool_t create_root) /* Remove the cache if the stab does not exist */ if(!stab_exists) - f->shared->root_ent->type = H5G_NOTHING_CACHED; + f->shared->sblock->root_ent->type = H5G_NOTHING_CACHED; #ifndef H5_STRICT_FORMAT_CHECKS /* If symbol table information is cached, check if we should replace the * symbol table message with the cached symbol table information */ @@ -299,8 +207,8 @@ H5G_mkroot(H5F_t *f, hid_t dxpl_id, hbool_t create_root) H5O_stab_t cached_stab; /* Retrieve the cached symbol table information */ - cached_stab.btree_addr = f->shared->root_ent->cache.stab.btree_addr; - cached_stab.heap_addr = f->shared->root_ent->cache.stab.heap_addr; + cached_stab.btree_addr = f->shared->sblock->root_ent->cache.stab.btree_addr; + cached_stab.heap_addr = f->shared->sblock->root_ent->cache.stab.heap_addr; /* Check if the symbol table message is valid, and replace with the * cached symbol table if necessary */ @@ -316,8 +224,8 @@ H5G_mkroot(H5F_t *f, hid_t dxpl_id, hbool_t create_root) * present, so we don't need to check the superblock version. We do this if * we have write access, the root entry has been allocated (i.e. * super_vers < 2) and the stab info is not already cached. */ - if((H5F_INTENT(f) & H5F_ACC_RDWR) && stab_exists != FALSE && f->shared->root_ent - && f->shared->root_ent->type != H5G_CACHED_STAB) { + if((H5F_INTENT(f) & H5F_ACC_RDWR) && stab_exists != FALSE && f->shared->sblock->root_ent + && f->shared->sblock->root_ent->type != H5G_CACHED_STAB) { H5O_stab_t stab; /* Symbol table */ /* Check if the stab message exists. It's possible for the root group @@ -332,9 +240,12 @@ H5G_mkroot(H5F_t *f, hid_t dxpl_id, hbool_t create_root) HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "unable to read symbol table message") /* Update the root group symbol table entry */ - f->shared->root_ent->type = H5G_CACHED_STAB; - f->shared->root_ent->cache.stab.btree_addr = stab.btree_addr; - f->shared->root_ent->cache.stab.heap_addr = stab.heap_addr; + f->shared->sblock->root_ent->type = H5G_CACHED_STAB; + f->shared->sblock->root_ent->cache.stab.btree_addr = stab.btree_addr; + f->shared->sblock->root_ent->cache.stab.heap_addr = stab.heap_addr; + + /* Mark superblock dirty, so root group info is flushed */ + sblock_dirty = TRUE; } /* end if */ } /* end if */ @@ -347,7 +258,7 @@ H5G_mkroot(H5F_t *f, hid_t dxpl_id, hbool_t create_root) * in the number of open objects in the file. */ HDassert((1 == f->nopen_objs) || - (2 == f->nopen_objs && HADDR_UNDEF != f->shared->extension_addr)); + (2 == f->nopen_objs && HADDR_UNDEF != f->shared->sblock->ext_addr)); f->nopen_objs--; done: @@ -359,10 +270,16 @@ done: f->shared->root_grp->shared = H5FL_FREE(H5G_shared_t, f->shared->root_grp->shared); f->shared->root_grp = H5FL_FREE(H5G_t, f->shared->root_grp); } /* end if */ - f->shared->root_ent = (H5G_entry_t *) H5MM_xfree(f->shared->root_ent); + if(f->shared->sblock) + f->shared->sblock->root_ent = (H5G_entry_t *)H5MM_xfree(f->shared->sblock->root_ent); H5G_name_free(root_loc.path); } /* end if */ + /* Mark superblock dirty in cache, if necessary */ + if(sblock_dirty) + if(H5AC_mark_pinned_or_protected_entry_dirty(f, f->shared->sblock) < 0) + HDONE_ERROR(H5E_FILE, H5E_CANTMARKDIRTY, FAIL, "unable to mark superblock as dirty") + FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_mkroot() */ @@ -719,11 +719,15 @@ H5MF_try_extend(H5F_t *f, hid_t dxpl_id, H5FD_mem_t alloc_type, haddr_t addr, HDfprintf(stderr, "%s: Entering: alloc_type = %u, addr = %a, size = %Hu, extra_requested = %Hu\n", FUNC, (unsigned)alloc_type, addr, size, extra_requested); #endif /* H5MF_ALLOC_DEBUG */ + /* Sanity check */ + HDassert(f); + HDassert(H5F_INTENT(f) & H5F_ACC_RDWR); + /* Compute end of block to extend */ end = addr + size; /* Check if the block is exactly at the end of the file */ - if((ret_value = H5FD_try_extend(f->shared->lf, alloc_type, end, extra_requested)) < 0) + if((ret_value = H5FD_try_extend(f->shared->lf, alloc_type, f, end, extra_requested)) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTEXTEND, FAIL, "error extending file") else if(ret_value == FALSE) { H5F_blk_aggr_t *aggr; /* Aggregator to use */ @@ -757,6 +761,7 @@ HDfprintf(stderr, "%s: Leaving: ret_value = %t\n", FUNC, ret_value); #ifdef H5MF_ALLOC_DEBUG_DUMP H5MF_sects_dump(f, dxpl_id, stderr); #endif /* H5MF_ALLOC_DEBUG_DUMP */ + FUNC_LEAVE_NOAPI(ret_value) } /* end H5MF_try_extend() */ diff --git a/src/H5MFaggr.c b/src/H5MFaggr.c index 0526ef2..0b1bc91 100644 --- a/src/H5MFaggr.c +++ b/src/H5MFaggr.c @@ -152,13 +152,12 @@ haddr_t H5MF_aggr_alloc(H5F_t *f, hid_t dxpl_id, H5F_blk_aggr_t *aggr, H5F_blk_aggr_t *other_aggr, H5FD_mem_t type, hsize_t size) { - haddr_t ret_value; hsize_t alignment = 0, mis_align = 0; haddr_t frag_addr = 0, eoa_frag_addr = 0; hsize_t frag_size = 0, eoa_frag_size = 0; - haddr_t eoa = 0, new_space = 0; - htri_t extended = 0; + haddr_t eoa = 0; /* Initial EOA for the file */ H5FD_mem_t alloc_type, other_alloc_type; + haddr_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5MF_aggr_alloc, HADDR_UNDEF) #ifdef H5MF_AGGR_DEBUG @@ -202,6 +201,7 @@ HDfprintf(stderr, "%s: aggr = {%a, %Hu, %Hu}\n", FUNC, aggr->addr, aggr->tot_siz /* Check if the space requested is larger than the space left in the block */ if((size + frag_size) > aggr->size) { + htri_t extended = FALSE; /* Whether the file was extended */ /* Check if the block asked for is too large for 'normal' aggregator block */ if(size >= aggr->alloc_size) { @@ -211,7 +211,7 @@ HDfprintf(stderr, "%s: aggr = {%a, %Hu, %Hu}\n", FUNC, aggr->addr, aggr->tot_siz if(H5F_addr_gt((aggr->addr + aggr->size + ext_size), f->shared->tmp_addr)) HGOTO_ERROR(H5E_RESOURCE, H5E_BADRANGE, HADDR_UNDEF, "'normal' file space allocation request will overlap into 'temporary' file space") - if ((aggr->addr > 0) && (extended = H5FD_try_extend(f->shared->lf, alloc_type, aggr->addr + aggr->size, ext_size)) < 0) + if ((aggr->addr > 0) && (extended = H5FD_try_extend(f->shared->lf, alloc_type, f, aggr->addr + aggr->size, ext_size)) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't extending space") else if (extended) { /* aggr->size is unchanged */ @@ -226,7 +226,7 @@ HDfprintf(stderr, "%s: aggr = {%a, %Hu, %Hu}\n", FUNC, aggr->addr, aggr->tot_siz if ((other_aggr->size > 0) && (H5F_addr_eq((other_aggr->addr + other_aggr->size), eoa)) && ((other_aggr->tot_size - other_aggr->size) >= other_aggr->alloc_size)) { - if(H5FD_free(f->shared->lf, dxpl_id, other_alloc_type, other_aggr->addr, other_aggr->size) < 0) + if(H5FD_free(f->shared->lf, dxpl_id, other_alloc_type, f, other_aggr->addr, other_aggr->size) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTFREE, HADDR_UNDEF, "can't free aggregation block") other_aggr->addr = 0; @@ -234,11 +234,9 @@ HDfprintf(stderr, "%s: aggr = {%a, %Hu, %Hu}\n", FUNC, aggr->addr, aggr->tot_siz other_aggr->size = 0; } /* end if */ - if(HADDR_UNDEF == (new_space = H5FD_alloc(f->shared->lf, dxpl_id, type, size, &eoa_frag_addr, &eoa_frag_size))) + /* Allocate space from the VFD (i.e. at the end of the file) */ + if(HADDR_UNDEF == (ret_value = H5FD_alloc(f->shared->lf, dxpl_id, type, f, size, &eoa_frag_addr, &eoa_frag_size))) HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, HADDR_UNDEF, "can't allocate aggregation block") - - /* Use the new space allocated, leaving the old block */ - ret_value = new_space; } /* end else */ } /* end if */ else { @@ -256,13 +254,15 @@ HDfprintf(stderr, "%s: Allocating block\n", FUNC); if(H5F_addr_gt((aggr->addr + aggr->size + ext_size), f->shared->tmp_addr)) HGOTO_ERROR(H5E_RESOURCE, H5E_BADRANGE, HADDR_UNDEF, "'normal' file space allocation request will overlap into 'temporary' file space") - if((aggr->addr > 0) && (extended = H5FD_try_extend(f->shared->lf, alloc_type, aggr->addr + aggr->size, ext_size)) < 0) + if((aggr->addr > 0) && (extended = H5FD_try_extend(f->shared->lf, alloc_type, f, aggr->addr + aggr->size, ext_size)) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't extending space") else if (extended) { aggr->addr += frag_size; aggr->size += (ext_size - frag_size); aggr->tot_size += ext_size; } else { + haddr_t new_space; /* Address of new space allocated */ + /* Check for overlapping into file's temporary allocation space */ if(H5F_addr_gt((eoa + aggr->alloc_size), f->shared->tmp_addr)) HGOTO_ERROR(H5E_RESOURCE, H5E_BADRANGE, HADDR_UNDEF, "'normal' file space allocation request will overlap into 'temporary' file space") @@ -270,14 +270,15 @@ HDfprintf(stderr, "%s: Allocating block\n", FUNC); if((other_aggr->size > 0) && (H5F_addr_eq((other_aggr->addr + other_aggr->size), eoa)) && ((other_aggr->tot_size - other_aggr->size) >= other_aggr->alloc_size)) { - if(H5FD_free(f->shared->lf, dxpl_id, other_alloc_type, other_aggr->addr, other_aggr->size) < 0) + if(H5FD_free(f->shared->lf, dxpl_id, other_alloc_type, f, other_aggr->addr, other_aggr->size) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTFREE, HADDR_UNDEF, "can't free aggregation block") other_aggr->addr = 0; other_aggr->tot_size = 0; other_aggr->size = 0; } /* end if */ - if(HADDR_UNDEF == (new_space = H5FD_alloc(f->shared->lf, dxpl_id, alloc_type, aggr->alloc_size, &eoa_frag_addr, &eoa_frag_size))) + /* Allocate space from the VFD (i.e. at the end of the file) */ + if(HADDR_UNDEF == (new_space = H5FD_alloc(f->shared->lf, dxpl_id, alloc_type, f, aggr->alloc_size, &eoa_frag_addr, &eoa_frag_size))) HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, HADDR_UNDEF, "can't allocate aggregation block") /* Return the unused portion of the block to a free list */ @@ -297,12 +298,12 @@ HDfprintf(stderr, "%s: Allocating block\n", FUNC); aggr->addr += size; } /* end else */ - /* freeing any possible fragment due to file allocation */ + /* Freeing any possible fragment due to file allocation */ if(eoa_frag_size) if(H5MF_xfree(f, type, dxpl_id, eoa_frag_addr, eoa_frag_size) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTFREE, HADDR_UNDEF, "can't free eoa fragment") - /* freeing any possible fragment due to alignment in the block after extension */ + /* Freeing any possible fragment due to alignment in the block after extension */ if(extended && frag_size) if(H5MF_xfree(f, type, dxpl_id, frag_addr, frag_size) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTFREE, HADDR_UNDEF, "can't free aggregation fragment") @@ -325,9 +326,12 @@ HDfprintf(stderr, "%s: Allocating block\n", FUNC); HGOTO_ERROR(H5E_RESOURCE, H5E_BADRANGE, HADDR_UNDEF, "'normal' file space allocation request will overlap into 'temporary' file space") /* Allocate data from the file */ - if(HADDR_UNDEF == (ret_value = H5FD_alloc(f->shared->lf, dxpl_id, type, size, &eoa_frag_addr, &eoa_frag_size))) + if(HADDR_UNDEF == (ret_value = H5FD_alloc(f->shared->lf, dxpl_id, type, f, size, &eoa_frag_addr, &eoa_frag_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't allocate file space") + + /* Check if fragment was generated */ if(eoa_frag_size) + /* Put fragment on the free list */ if(H5MF_xfree(f, type, dxpl_id, eoa_frag_addr, eoa_frag_size) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTFREE, HADDR_UNDEF, "can't free eoa fragment") } /* end else */ @@ -339,7 +343,8 @@ done: #ifdef H5MF_AGGR_DEBUG HDfprintf(stderr, "%s: ret_value = %a\n", FUNC, ret_value); #endif /* H5MF_AGGR_DEBUG */ - if (alignment) + + if(alignment) HDassert(!(ret_value % alignment)); FUNC_LEAVE_NOAPI(ret_value) } /* end H5MF_aggr_alloc() */ @@ -382,7 +387,7 @@ H5MF_aggr_try_extend(const H5F_t *f, H5F_blk_aggr_t *aggr, H5FD_mem_t type, /* If the aggregator block is at the end of the file, extend the * file and "bubble" the aggregator up */ - if((ret_value = H5FD_try_extend(f->shared->lf, type, (aggr->addr + aggr->size), extra_requested)) < 0) + if((ret_value = H5FD_try_extend(f->shared->lf, type, f, (aggr->addr + aggr->size), extra_requested)) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTEXTEND, FAIL, "error extending file") else if(ret_value == TRUE) { /* Shift the aggregator block by the extra requested */ @@ -634,8 +639,8 @@ HDfprintf(stderr, "%s: tmp_addr = %a, tmp_size = %Hu\n", FUNC, tmp_addr, tmp_siz aggr->size = 0; /* Return the unused portion of the metadata block to the file */ - if(tmp_size > 0) - if(H5FD_free(f->shared->lf, dxpl_id, alloc_type, tmp_addr, tmp_size) < 0) + if(tmp_size > 0 && (H5F_INTENT(f) & H5F_ACC_RDWR)) + if(H5FD_free(f->shared->lf, dxpl_id, alloc_type, f, tmp_addr, tmp_size) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "can't free space") } /* end if */ diff --git a/src/H5MFsection.c b/src/H5MFsection.c index 0dc43c3..d10b6b1 100644 --- a/src/H5MFsection.c +++ b/src/H5MFsection.c @@ -404,8 +404,11 @@ H5MF_sect_simple_shrink(H5FS_section_info_t **_sect, void *_udata) /* Check for shrinking file */ if(H5MF_SHRINK_EOA == udata->shrink) { + /* Sanity check */ + HDassert(H5F_INTENT(udata->f) & H5F_ACC_RDWR); + /* Release section's space at EOA with file driver */ - if(H5FD_free(udata->f->shared->lf, udata->dxpl_id, udata->alloc_type, (*sect)->sect_info.addr, (*sect)->sect_info.size) < 0) + if(H5FD_free(udata->f->shared->lf, udata->dxpl_id, udata->alloc_type, udata->f, (*sect)->sect_info.addr, (*sect)->sect_info.size) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "driver free request failed") } /* end if */ else { @@ -139,10 +139,6 @@ H5SM_init(H5F_t *f, H5P_genplist_t * fc_plist, const H5O_loc_t *ext_loc, hid_t d /* File should not already have a SOHM table */ HDassert(f->shared->sohm_addr == HADDR_UNDEF); - /* Initialize master table */ - if(NULL == (table = H5FL_MALLOC(H5SM_master_table_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for SOHM table") - /* Get information from fcpl */ if(H5P_get(fc_plist, H5F_CRT_SHMSG_NINDEXES_NAME, &num_indexes)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get number of indexes") @@ -167,6 +163,10 @@ H5SM_init(H5F_t *f, H5P_genplist_t * fc_plist, const H5O_loc_t *ext_loc, hid_t d type_flags_used |= index_type_flags[x]; } /* end for */ + /* Initialize master table */ + if(NULL == (table = H5FL_MALLOC(H5SM_master_table_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for SOHM table") + /* Set version and number of indexes in table and in superblock. * Right now we just use one byte to hold the number of indexes. */ @@ -235,7 +235,7 @@ done: if(table_addr != HADDR_UNDEF) H5MF_xfree(f, H5FD_MEM_SOHM_TABLE, dxpl_id, table_addr, (hsize_t)H5SM_TABLE_SIZE(f)); if(table != NULL) - (void)H5FL_FREE(H5SM_master_table_t, table); + table = H5FL_FREE(H5SM_master_table_t, table); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/Makefile.am b/src/Makefile.am index 8610c16..ce84332 100755 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -54,7 +54,7 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ H5EA.c H5EAcache.c H5EAdbg.c H5EAdblkpage.c H5EAdblock.c H5EAhdr.c \ H5EAiblock.c H5EAint.c H5EAsblock.c H5EAstat.c H5EAtest.c \ H5F.c H5Faccum.c H5Fdbg.c H5Ffake.c H5Fio.c H5Fmount.c H5Fmpi.c H5Fquery.c \ - H5Fsfile.c H5Fsuper.c H5Ftest.c \ + H5Fsfile.c H5Fsuper.c H5Fsuper_cache.c H5Ftest.c \ H5FA.c H5FAcache.c H5FAdbg.c H5FAdblock.c H5FAdblkpage.c H5FAhdr.c \ H5FAstat.c H5FAtest.c \ H5FD.c H5FDcore.c \ diff --git a/src/Makefile.in b/src/Makefile.in index 1afd985..96bd804 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -108,14 +108,14 @@ am_libhdf5_la_OBJECTS = H5.lo H5checksum.lo H5dbg.lo H5system.lo \ H5EAdblock.lo H5EAhdr.lo H5EAiblock.lo H5EAint.lo \ H5EAsblock.lo H5EAstat.lo H5EAtest.lo H5F.lo H5Faccum.lo \ H5Fdbg.lo H5Ffake.lo H5Fio.lo H5Fmount.lo H5Fmpi.lo \ - H5Fquery.lo H5Fsfile.lo H5Fsuper.lo H5Ftest.lo H5FA.lo \ - H5FAcache.lo H5FAdbg.lo H5FAdblock.lo H5FAdblkpage.lo \ - H5FAhdr.lo H5FAstat.lo H5FAtest.lo H5FD.lo H5FDcore.lo \ - H5FDdirect.lo H5FDfamily.lo H5FDint.lo H5FDlog.lo H5FDmpi.lo \ - H5FDmpio.lo H5FDmpiposix.lo H5FDmulti.lo H5FDsec2.lo \ - H5FDspace.lo H5FDstdio.lo H5FL.lo H5FO.lo H5FS.lo H5FScache.lo \ - H5FSdbg.lo H5FSsection.lo H5FSstat.lo H5FStest.lo H5G.lo \ - H5Gbtree2.lo H5Gcache.lo H5Gcompact.lo H5Gdense.lo \ + H5Fquery.lo H5Fsfile.lo H5Fsuper.lo H5Fsuper_cache.lo \ + H5Ftest.lo H5FA.lo H5FAcache.lo H5FAdbg.lo H5FAdblock.lo \ + H5FAdblkpage.lo H5FAhdr.lo H5FAstat.lo H5FAtest.lo H5FD.lo \ + H5FDcore.lo H5FDdirect.lo H5FDfamily.lo H5FDint.lo H5FDlog.lo \ + H5FDmpi.lo H5FDmpio.lo H5FDmpiposix.lo H5FDmulti.lo \ + H5FDsec2.lo H5FDspace.lo H5FDstdio.lo H5FL.lo H5FO.lo H5FS.lo \ + H5FScache.lo H5FSdbg.lo H5FSsection.lo H5FSstat.lo H5FStest.lo \ + H5G.lo H5Gbtree2.lo H5Gcache.lo H5Gcompact.lo H5Gdense.lo \ H5Gdeprec.lo H5Gent.lo H5Gint.lo H5Glink.lo H5Gloc.lo \ H5Gname.lo H5Gnode.lo H5Gobj.lo H5Goh.lo H5Groot.lo H5Gstab.lo \ H5Gtest.lo H5Gtraverse.lo H5HF.lo H5HFbtree2.lo H5HFcache.lo \ @@ -462,7 +462,7 @@ libhdf5_la_SOURCES = H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ H5EA.c H5EAcache.c H5EAdbg.c H5EAdblkpage.c H5EAdblock.c H5EAhdr.c \ H5EAiblock.c H5EAint.c H5EAsblock.c H5EAstat.c H5EAtest.c \ H5F.c H5Faccum.c H5Fdbg.c H5Ffake.c H5Fio.c H5Fmount.c H5Fmpi.c H5Fquery.c \ - H5Fsfile.c H5Fsuper.c H5Ftest.c \ + H5Fsfile.c H5Fsuper.c H5Fsuper_cache.c H5Ftest.c \ H5FA.c H5FAcache.c H5FAdbg.c H5FAdblock.c H5FAdblkpage.c H5FAhdr.c \ H5FAstat.c H5FAtest.c \ H5FD.c H5FDcore.c \ @@ -744,6 +744,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Fquery.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Fsfile.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Fsuper.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Fsuper_cache.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Ftest.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5G.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Gbtree2.Plo@am__quote@ diff --git a/test/tattr.c b/test/tattr.c index 20058fc..afe45eb 100644 --- a/test/tattr.c +++ b/test/tattr.c @@ -5293,13 +5293,13 @@ test_attr_corder_transition(hid_t fcpl, hid_t fapl) ret = H5Dclose(dset3); CHECK(ret, FAIL, "H5Dclose"); - /* Close dataspace */ - ret = H5Sclose(sid); - CHECK(ret, FAIL, "H5Sclose"); - /* Close file */ ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); + + /* Close dataspace */ + ret = H5Sclose(sid); + CHECK(ret, FAIL, "H5Sclose"); } /* test_attr_corder_transition() */ diff --git a/test/testhdf5.c b/test/testhdf5.c index 95ec90c..f14c2c3 100644 --- a/test/testhdf5.c +++ b/test/testhdf5.c @@ -88,3 +88,4 @@ main(int argc, char *argv[]) return (GetTestNumErrs()); } /* end main() */ + diff --git a/test/tfile.c b/test/tfile.c index 25c1590..518138c 100644 --- a/test/tfile.c +++ b/test/tfile.c @@ -1351,7 +1351,7 @@ test_file_ishdf5(void) /* Create non-HDF5 file and check it */ fd=HDopen(FILE1, O_RDWR|O_CREAT|O_TRUNC, 0666); - CHECK(ret, FAIL, "HDopen"); + CHECK(fd, FAIL, "HDopen"); /* Initialize information to write */ for(u=0; u<1024; u++) @@ -2026,6 +2026,59 @@ test_cached_stab_info(void) /**************************************************************** ** +** test_rw_noupdate(): low-level file test routine. +** This test checks to ensure that opening and closing a file +** with read/write permissions does not write anything to the +** file if the file does not change. +** +** Programmer: Mike McGreevy +** mamcgree@hdfgroup.org +** June 29, 2009 +** +*****************************************************************/ +static void +test_rw_noupdate(void) +{ + hid_t file_id; /* HDF5 File ID */ + h5_stat_t sb1, sb2; /* Info from 'stat' call */ + double diff; /* Difference in modification times */ + herr_t ret; /* Generic return value */ + + /* Output message about test being performed */ + MESSAGE(5, ("Testing to verify that nothing is written if nothing is changed.\n")); + + /* Create and Close File */ + file_id = H5Fcreate(FILE1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + CHECK(file_id, FAIL, "H5Fcreate"); + ret = H5Fclose(file_id); + CHECK(ret, FAIL, "H5Fclose"); + + /* Determine File's Initial Timestamp */ + ret = HDstat(FILE1, &sb1); + VERIFY(ret, 0, "HDfstat"); + + /* Wait for 2 seconds */ + /* This ensures a system time difference between the two file accesses */ + HDsleep(2); + + /* Open and Close File With Read/Write Permission */ + file_id = H5Fopen(FILE1, H5F_ACC_RDWR, H5P_DEFAULT); + CHECK(file_id, FAIL, "H5Fopen"); + ret = H5Fclose(file_id); + CHECK(ret, FAIL, "H5Fclose"); + + /* Determine File's New Timestamp */ + ret = HDstat(FILE1, &sb2); + VERIFY(ret, 0, "HDstat"); + + /* Ensure That Timestamps Are Equal */ + diff = HDdifftime(sb2.st_mtime, sb1.st_mtime); + ret = (diff > 0.0); + VERIFY(ret, 0, "Timestamp"); +} /* end test_rw_noupdate() */ + +/**************************************************************** +** ** test_swmr_write(): low-level file test routine. ** This test checks that the H5F_ACC_SWMR_WRITE access flag is ** working properly. @@ -2253,6 +2306,7 @@ test_file(void) #endif /*H5_CANNOT_OPEN_TWICE*/ test_userblock_file_size(); /* Tests that files created with a userblock have the correct size */ test_cached_stab_info(); /* Tests that files are created with cached stab info in the superblock */ + test_rw_noupdate(); /* Test to ensure that RW permissions don't write the file unless dirtied */ test_swmr_write(); /* Tests for SWMR write access flag */ test_swmr_read(); /* Tests for SWMR read access flag */ } /* test_file() */ diff --git a/test/tvltypes.c b/test/tvltypes.c index 867d8d5..ab4d880 100644 --- a/test/tvltypes.c +++ b/test/tvltypes.c @@ -2831,7 +2831,7 @@ test_vltypes_fill_value(void) } /* end for */ /* Release the space */ - ret = H5Dvlen_reclaim(dtype1_id, dset_dspace_id, xfer_pid, rbuf); + ret = H5Dvlen_reclaim(dtype1_id, dset_select_dspace_id, xfer_pid, rbuf); CHECK(ret, FAIL, "H5Dvlen_reclaim"); ret = H5Dclose(dset_id); @@ -3001,7 +3001,7 @@ test_vltypes_fill_value(void) } /* end for */ /* Release the space */ - ret = H5Dvlen_reclaim(dtype1_id, dset_dspace_id, xfer_pid, rbuf); + ret = H5Dvlen_reclaim(dtype1_id, dset_select_dspace_id, xfer_pid, rbuf); CHECK(ret, FAIL, "H5Dvlen_reclaim"); ret = H5Dclose(dset_id); @@ -3097,7 +3097,7 @@ test_vltypes_fill_value(void) } /* end for */ /* Release the space */ - ret = H5Dvlen_reclaim(dtype1_id, dset_dspace_id, xfer_pid, rbuf); + ret = H5Dvlen_reclaim(dtype1_id, dset_select_dspace_id, xfer_pid, rbuf); CHECK(ret, FAIL, "H5Dvlen_reclaim"); ret = H5Dclose(dset_id); diff --git a/testpar/t_cache.c b/testpar/t_cache.c index 0b94170..4e1e5ba 100644 --- a/testpar/t_cache.c +++ b/testpar/t_cache.c @@ -704,6 +704,10 @@ addr_to_datum_index(haddr_t base_addr) * JRM -- 2/4/09 * Added initialization for the cleared and flushed fields. * + * Mike McGreevy, July 2, 2009 + * Changed base address from 0 to 512 since the superblock will + * always be at address 0. + * *****************************************************************************/ static void @@ -724,7 +728,7 @@ init_data(void) 1974, 3194, 5168, 8362, 13539}; int i; int j = 0; - haddr_t addr = 0; + haddr_t addr = 512; /* this must hold so renames don't change entry size. */ HDassert( (NUM_DATA_ENTRIES / 2) % 20 == 0 ); diff --git a/tools/h5copy/testfiles/h5copytst.out.ls b/tools/h5copy/testfiles/h5copytst.out.ls index 9cad76f..5ff1e90 100644 --- a/tools/h5copy/testfiles/h5copytst.out.ls +++ b/tools/h5copy/testfiles/h5copytst.out.ls @@ -6,57 +6,57 @@ Opened "../testfiles/h5copytst.out.h5" with sec2 driver. Location: 1:96 Links: 1 /A Group - Location: 1:89936 + Location: 1:90032 Links: 1 /A/B1 Group - Location: 1:90640 + Location: 1:90736 Links: 1 /A/B1/simple Dataset {6/6} - Location: 1:89808 + Location: 1:89904 Links: 1 Storage: <details removed for portability> Type: 32-bit little-endian integer /A/B2 Group - Location: 1:94176 + Location: 1:94272 Links: 1 /A/B2/simple2 Dataset {6/6} - Location: 1:94048 + Location: 1:94144 Links: 1 Storage: <details removed for portability> Type: 32-bit little-endian integer /C Group - Location: 1:97384 + Location: 1:97480 Links: 1 /C/D Group - Location: 1:98088 + Location: 1:98184 Links: 1 /C/D/simple Dataset {6/6} - Location: 1:97256 + Location: 1:97352 Links: 1 Storage: <details removed for portability> Type: 32-bit little-endian integer /E Group - Location: 1:112000 + Location: 1:112096 Links: 1 /E/F Group - Location: 1:112704 + Location: 1:112800 Links: 1 /E/F/grp_dsets Group - Location: 1:100200 + Location: 1:100296 Links: 1 /E/F/grp_dsets/chunk Dataset {6/6} - Location: 1:104384 + Location: 1:104480 Links: 1 Chunks: {2} 8 bytes Storage: <details removed for portability> Type: 32-bit little-endian integer /E/F/grp_dsets/compact Dataset {6/6} - Location: 1:104840 + Location: 1:104936 Links: 1 Storage: <details removed for portability> Type: 32-bit little-endian integer /E/F/grp_dsets/compound Dataset {2/2} - Location: 1:104976 + Location: 1:105072 Links: 1 Storage: <details removed for portability> Type: struct { @@ -64,60 +64,60 @@ Opened "../testfiles/h5copytst.out.h5" with sec2 driver. "str2" +20 20-byte null-terminated ASCII string } 40 bytes /E/F/grp_dsets/compressed Dataset {6/6} - Location: 1:107288 + Location: 1:107384 Links: 1 Chunks: {2} 8 bytes Storage: <details removed for portability> Filter-0: deflate-1 OPT {1} Type: 32-bit little-endian integer /E/F/grp_dsets/named_vl Dataset {2/2} - Location: 1:111600 + Location: 1:111696 Links: 1 Storage: <details removed for portability> - Type: shared-1:107456 variable length of + Type: shared-1:107552 variable length of 32-bit little-endian integer /E/F/grp_dsets/nested_vl Dataset {2/2} - Location: 1:111728 + Location: 1:111824 Links: 1 Storage: <details removed for portability> Type: variable length of variable length of 32-bit little-endian integer /E/F/grp_dsets/simple Dataset {6/6} - Location: 1:111872 + Location: 1:111968 Links: 1 Storage: <details removed for portability> Type: 32-bit little-endian integer /E/F/grp_dsets/vl Type - Location: 1:107456 + Location: 1:107552 Links: 2 - Type: shared-1:107456 variable length of + Type: shared-1:107552 variable length of 32-bit little-endian integer /G Group - Location: 1:127648 + Location: 1:127744 Links: 1 /G/H Group - Location: 1:128352 + Location: 1:128448 Links: 1 /G/H/grp_nested Group - Location: 1:114728 + Location: 1:114824 Links: 1 /G/H/grp_nested/grp_dsets Group - Location: 1:115520 + Location: 1:115616 Links: 1 /G/H/grp_nested/grp_dsets/chunk Dataset {6/6} - Location: 1:119704 + Location: 1:119800 Links: 1 Chunks: {2} 8 bytes Storage: <details removed for portability> Type: 32-bit little-endian integer /G/H/grp_nested/grp_dsets/compact Dataset {6/6} - Location: 1:120160 + Location: 1:120256 Links: 1 Storage: <details removed for portability> Type: 32-bit little-endian integer /G/H/grp_nested/grp_dsets/compound Dataset {2/2} - Location: 1:120296 + Location: 1:120392 Links: 1 Storage: <details removed for portability> Type: struct { @@ -125,48 +125,48 @@ Opened "../testfiles/h5copytst.out.h5" with sec2 driver. "str2" +20 20-byte null-terminated ASCII string } 40 bytes /G/H/grp_nested/grp_dsets/compressed Dataset {6/6} - Location: 1:122608 + Location: 1:122704 Links: 1 Chunks: {2} 8 bytes Storage: <details removed for portability> Filter-0: deflate-1 OPT {1} Type: 32-bit little-endian integer /G/H/grp_nested/grp_dsets/named_vl Dataset {2/2} - Location: 1:126920 + Location: 1:127016 Links: 1 Storage: <details removed for portability> - Type: shared-1:122776 variable length of + Type: shared-1:122872 variable length of 32-bit little-endian integer /G/H/grp_nested/grp_dsets/nested_vl Dataset {2/2} - Location: 1:127048 + Location: 1:127144 Links: 1 Storage: <details removed for portability> Type: variable length of variable length of 32-bit little-endian integer /G/H/grp_nested/grp_dsets/simple Dataset {6/6} - Location: 1:127192 + Location: 1:127288 Links: 1 Storage: <details removed for portability> Type: 32-bit little-endian integer /G/H/grp_nested/grp_dsets/vl Type - Location: 1:122776 + Location: 1:122872 Links: 2 - Type: shared-1:122776 variable length of + Type: shared-1:122872 variable length of 32-bit little-endian integer /chunk Dataset {6/6} - Location: 1:6216 + Location: 1:6312 Links: 1 Chunks: {2} 8 bytes Storage: <details removed for portability> Type: 32-bit little-endian integer /compact Dataset {6/6} - Location: 1:6344 + Location: 1:6440 Links: 1 Storage: <details removed for portability> Type: 32-bit little-endian integer /compound Dataset {2/2} - Location: 1:8528 + Location: 1:8624 Links: 1 Storage: <details removed for portability> Type: struct { @@ -174,28 +174,28 @@ Opened "../testfiles/h5copytst.out.h5" with sec2 driver. "str2" +20 20-byte null-terminated ASCII string } 40 bytes /compressed Dataset {6/6} - Location: 1:12888 + Location: 1:12984 Links: 1 Chunks: {2} 8 bytes Storage: <details removed for portability> Filter-0: deflate-1 OPT {1} Type: 32-bit little-endian integer /grp_dsets Group - Location: 1:33760 + Location: 1:33856 Links: 1 /grp_dsets/chunk Dataset {6/6} - Location: 1:37944 + Location: 1:38040 Links: 1 Chunks: {2} 8 bytes Storage: <details removed for portability> Type: 32-bit little-endian integer /grp_dsets/compact Dataset {6/6} - Location: 1:38400 + Location: 1:38496 Links: 1 Storage: <details removed for portability> Type: 32-bit little-endian integer /grp_dsets/compound Dataset {2/2} - Location: 1:38536 + Location: 1:38632 Links: 1 Storage: <details removed for portability> Type: struct { @@ -203,62 +203,62 @@ Opened "../testfiles/h5copytst.out.h5" with sec2 driver. "str2" +20 20-byte null-terminated ASCII string } 40 bytes /grp_dsets/compressed Dataset {6/6} - Location: 1:40848 + Location: 1:40944 Links: 1 Chunks: {2} 8 bytes Storage: <details removed for portability> Filter-0: deflate-1 OPT {1} Type: 32-bit little-endian integer /grp_dsets/named_vl Dataset {2/2} - Location: 1:45160 + Location: 1:45256 Links: 1 Storage: <details removed for portability> - Type: shared-1:41016 variable length of + Type: shared-1:41112 variable length of 32-bit little-endian integer /grp_dsets/nested_vl Dataset {2/2} - Location: 1:45288 + Location: 1:45384 Links: 1 Storage: <details removed for portability> Type: variable length of variable length of 32-bit little-endian integer /grp_dsets/simple Dataset {6/6} - Location: 1:45432 + Location: 1:45528 Links: 1 Storage: <details removed for portability> Type: 32-bit little-endian integer /grp_dsets/simple_group Dataset {6/6} - Location: 1:61544 + Location: 1:61640 Links: 1 Storage: <details removed for portability> Type: 32-bit little-endian integer /grp_dsets/vl Type - Location: 1:41016 + Location: 1:41112 Links: 2 - Type: shared-1:41016 variable length of + Type: shared-1:41112 variable length of 32-bit little-endian integer /grp_empty Group - Location: 1:32968 + Location: 1:33064 Links: 1 /grp_nested Group - Location: 1:46224 + Location: 1:46320 Links: 1 /grp_nested/grp_dsets Group - Location: 1:47016 + Location: 1:47112 Links: 1 /grp_nested/grp_dsets/chunk Dataset {6/6} - Location: 1:51200 + Location: 1:51296 Links: 1 Chunks: {2} 8 bytes Storage: <details removed for portability> Type: 32-bit little-endian integer /grp_nested/grp_dsets/compact Dataset {6/6} - Location: 1:51656 + Location: 1:51752 Links: 1 Storage: <details removed for portability> Type: 32-bit little-endian integer /grp_nested/grp_dsets/compound Dataset {2/2} - Location: 1:51792 + Location: 1:51888 Links: 1 Storage: <details removed for portability> Type: struct { @@ -266,51 +266,51 @@ Opened "../testfiles/h5copytst.out.h5" with sec2 driver. "str2" +20 20-byte null-terminated ASCII string } 40 bytes /grp_nested/grp_dsets/compressed Dataset {6/6} - Location: 1:54104 + Location: 1:54200 Links: 1 Chunks: {2} 8 bytes Storage: <details removed for portability> Filter-0: deflate-1 OPT {1} Type: 32-bit little-endian integer /grp_nested/grp_dsets/named_vl Dataset {2/2} - Location: 1:58416 + Location: 1:58512 Links: 1 Storage: <details removed for portability> - Type: shared-1:54272 variable length of + Type: shared-1:54368 variable length of 32-bit little-endian integer /grp_nested/grp_dsets/nested_vl Dataset {2/2} - Location: 1:58544 + Location: 1:58640 Links: 1 Storage: <details removed for portability> Type: variable length of variable length of 32-bit little-endian integer /grp_nested/grp_dsets/simple Dataset {6/6} - Location: 1:58688 + Location: 1:58784 Links: 1 Storage: <details removed for portability> Type: 32-bit little-endian integer /grp_nested/grp_dsets/vl Type - Location: 1:54272 + Location: 1:54368 Links: 2 - Type: shared-1:54272 variable length of + Type: shared-1:54368 variable length of 32-bit little-endian integer /grp_rename Group - Location: 1:62752 + Location: 1:62848 Links: 1 /grp_rename/chunk Dataset {6/6} - Location: 1:66936 + Location: 1:67032 Links: 1 Chunks: {2} 8 bytes Storage: <details removed for portability> Type: 32-bit little-endian integer /grp_rename/compact Dataset {6/6} - Location: 1:67392 + Location: 1:67488 Links: 1 Storage: <details removed for portability> Type: 32-bit little-endian integer /grp_rename/compound Dataset {2/2} - Location: 1:67528 + Location: 1:67624 Links: 1 Storage: <details removed for portability> Type: struct { @@ -318,28 +318,28 @@ Opened "../testfiles/h5copytst.out.h5" with sec2 driver. "str2" +20 20-byte null-terminated ASCII string } 40 bytes /grp_rename/compressed Dataset {6/6} - Location: 1:69840 + Location: 1:69936 Links: 1 Chunks: {2} 8 bytes Storage: <details removed for portability> Filter-0: deflate-1 OPT {1} Type: 32-bit little-endian integer /grp_rename/grp_dsets Group - Location: 1:75632 + Location: 1:75728 Links: 1 /grp_rename/grp_dsets/chunk Dataset {6/6} - Location: 1:79816 + Location: 1:79912 Links: 1 Chunks: {2} 8 bytes Storage: <details removed for portability> Type: 32-bit little-endian integer /grp_rename/grp_dsets/compact Dataset {6/6} - Location: 1:80272 + Location: 1:80368 Links: 1 Storage: <details removed for portability> Type: 32-bit little-endian integer /grp_rename/grp_dsets/compound Dataset {2/2} - Location: 1:80408 + Location: 1:80504 Links: 1 Storage: <details removed for portability> Type: struct { @@ -347,73 +347,73 @@ Opened "../testfiles/h5copytst.out.h5" with sec2 driver. "str2" +20 20-byte null-terminated ASCII string } 40 bytes /grp_rename/grp_dsets/compressed Dataset {6/6} - Location: 1:82720 + Location: 1:82816 Links: 1 Chunks: {2} 8 bytes Storage: <details removed for portability> Filter-0: deflate-1 OPT {1} Type: 32-bit little-endian integer /grp_rename/grp_dsets/named_vl Dataset {2/2} - Location: 1:87032 + Location: 1:87128 Links: 1 Storage: <details removed for portability> - Type: shared-1:82888 variable length of + Type: shared-1:82984 variable length of 32-bit little-endian integer /grp_rename/grp_dsets/nested_vl Dataset {2/2} - Location: 1:87160 + Location: 1:87256 Links: 1 Storage: <details removed for portability> Type: variable length of variable length of 32-bit little-endian integer /grp_rename/grp_dsets/simple Dataset {6/6} - Location: 1:87304 + Location: 1:87400 Links: 1 Storage: <details removed for portability> Type: 32-bit little-endian integer /grp_rename/grp_dsets/vl Type - Location: 1:82888 + Location: 1:82984 Links: 2 - Type: shared-1:82888 variable length of + Type: shared-1:82984 variable length of 32-bit little-endian integer /grp_rename/named_vl Dataset {2/2} - Location: 1:74152 + Location: 1:74248 Links: 1 Storage: <details removed for portability> - Type: shared-1:70008 variable length of + Type: shared-1:70104 variable length of 32-bit little-endian integer /grp_rename/nested_vl Dataset {2/2} - Location: 1:74280 + Location: 1:74376 Links: 1 Storage: <details removed for portability> Type: variable length of variable length of 32-bit little-endian integer /grp_rename/simple Dataset {6/6} - Location: 1:74424 + Location: 1:74520 Links: 1 Storage: <details removed for portability> Type: 32-bit little-endian integer /grp_rename/vl Type - Location: 1:70008 + Location: 1:70104 Links: 2 - Type: shared-1:70008 variable length of + Type: shared-1:70104 variable length of 32-bit little-endian integer /named_vl Dataset {2/2} - Location: 1:13104 + Location: 1:13200 Links: 1 Storage: <details removed for portability> - Type: shared-1:13056 variable length of + Type: shared-1:13152 variable length of 32-bit little-endian integer /nested_vl Dataset {2/2} - Location: 1:27392 + Location: 1:27488 Links: 1 Storage: <details removed for portability> Type: variable length of variable length of 32-bit little-endian integer /rename Dataset {2/2} - Location: 1:31760 + Location: 1:31856 Links: 1 Storage: <details removed for portability> Type: struct { @@ -426,7 +426,7 @@ Opened "../testfiles/h5copytst.out.h5" with sec2 driver. Storage: <details removed for portability> Type: 32-bit little-endian integer /simple_top Dataset {6/6} - Location: 1:29584 + Location: 1:29680 Links: 1 Storage: <details removed for portability> Type: 32-bit little-endian integer diff --git a/vms/build.com b/vms/build.com index af5cc6d..3949da5 100644 --- a/vms/build.com +++ b/vms/build.com @@ -29,6 +29,7 @@ $ hdf5toolstest_h5diff = tmp + ".TOOLS.H5DIFF.TESTFILES]" $ hdf5toolstest_h5repack = tmp + ".TOOLS.H5REPACK.TESTFILES]" $ hdf5toolstest_h5copy = tmp + ".TOOLS.H5COPY.TESTFILES]" $ hdf5toolstest_h5import = tmp + ".TOOLS.H5IMPORT.TESTFILES]" +$ hdf5toolstest_h5jam = tmp + ".TOOLS.H5JAM.TESTFILES]" $ set def 'hdf5vms' $@make $ set def 'hdf5ctest' @@ -56,5 +57,9 @@ $! $ set def 'hdf5toolstest_h5import' $ copy [.-]check_h5import.com check_h5import.com $@check_h5import.com +$! +$ set def 'hdf5toolstest_h5jam' +$ copy [.-]check_h5jam.com check_h5jam.com +$@check_h5jam.com $ $ exit diff --git a/vms/tools/misc/make.com b/vms/tools/misc/make.com index 4c8e223..ed2d061 100644 --- a/vms/tools/misc/make.com +++ b/vms/tools/misc/make.com @@ -49,6 +49,42 @@ $ type sys$input Created h5mkgrp $! $ type sys$input + Creating h5repart +$! +$ cobj= " h5repart " +$! +$ ccc 'cobj +$ type sys$input +$ link/exe=h5repart.exe - + h5repart, - + [-.lib]libh5tools.olb/lib,[-.-.src]hdf5.olb/lib,zlib_dir:libz.olb/lib +$ type sys$input + Created h5repart +$! +$ cobj= " h5repart_gentest " +$! +$ ccc 'cobj +$ type sys$input +$ link/exe=h5repart_gentest.exe - + h5repart_gentest, - + [-.lib]libh5tools.olb/lib,[-.-.src]hdf5.olb/lib,zlib_dir:libz.olb/lib +$ type sys$input + Created h5repart_gentest +$! +$ type sys$input + Creating repart_test +$! +$ cobj= " repart_test " +$! +$ ccc 'cobj +$ type sys$input +$ link/exe=repart_test.exe - + repart_test, - + [-.lib]libh5tools.olb/lib,[-.-.src]hdf5.olb/lib,zlib_dir:libz.olb/lib +$ type sys$input + Created repart_test +$! +$ type sys$input Done with misc tools compilation $! $ exit |