diff options
author | M. Scot Breitenfeld <brtnfld@hdfgroup.org> | 2019-01-07 15:49:52 (GMT) |
---|---|---|
committer | M. Scot Breitenfeld <brtnfld@hdfgroup.org> | 2019-01-07 15:49:52 (GMT) |
commit | b4828e7feb8fd11514683c6eef8809356751760a (patch) | |
tree | 0364fb7dceb3573fe95d8512669f027595c2fa83 /src | |
parent | 390a3f67282e64752a14e2c1ed13545fde8712d1 (diff) | |
parent | 7bf6d847ae36940f1b1147820356795c7764dbeb (diff) | |
download | hdf5-b4828e7feb8fd11514683c6eef8809356751760a.zip hdf5-b4828e7feb8fd11514683c6eef8809356751760a.tar.gz hdf5-b4828e7feb8fd11514683c6eef8809356751760a.tar.bz2 |
Merge branch 'develop' of https://bitbucket.hdfgroup.org/scm/hdffv/hdf5 into develop
Diffstat (limited to 'src')
93 files changed, 9313 insertions, 7252 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 12b7db0..40b64f5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -39,7 +39,6 @@ IDE_GENERATED_PROPERTIES ("H5A" "${H5A_HDRS}" "${H5A_SOURCES}" ) set (H5AC_SOURCES ${HDF5_SRC_DIR}/H5AC.c ${HDF5_SRC_DIR}/H5ACdbg.c - ${HDF5_SRC_DIR}/H5AClog.c ${HDF5_SRC_DIR}/H5ACmpio.c ${HDF5_SRC_DIR}/H5ACproxy_entry.c ) @@ -81,6 +80,8 @@ set (H5C_SOURCES ${HDF5_SRC_DIR}/H5Cepoch.c ${HDF5_SRC_DIR}/H5Cimage.c ${HDF5_SRC_DIR}/H5Clog.c + ${HDF5_SRC_DIR}/H5Clog_json.c + ${HDF5_SRC_DIR}/H5Clog_trace.c ${HDF5_SRC_DIR}/H5Cmpio.c ${HDF5_SRC_DIR}/H5Cprefetched.c ${HDF5_SRC_DIR}/H5Cquery.c @@ -628,6 +629,13 @@ set (H5VL_SOURCES ${HDF5_SRC_DIR}/H5VLcallback.c ${HDF5_SRC_DIR}/H5VLint.c ${HDF5_SRC_DIR}/H5VLnative.c + ${HDF5_SRC_DIR}/H5VLnative_attr.c + ${HDF5_SRC_DIR}/H5VLnative_dataset.c + ${HDF5_SRC_DIR}/H5VLnative_datatype.c + ${HDF5_SRC_DIR}/H5VLnative_file.c + ${HDF5_SRC_DIR}/H5VLnative_group.c + ${HDF5_SRC_DIR}/H5VLnative_link.c + ${HDF5_SRC_DIR}/H5VLnative_object.c ${HDF5_SRC_DIR}/H5VLpassthru.c ) set (H5VL_HDRS @@ -772,6 +780,7 @@ set (H5_PRIVATE_HEADERS ${HDF5_SRC_DIR}/H5B2pkg.h ${HDF5_SRC_DIR}/H5B2private.h + ${HDF5_SRC_DIR}/H5Clog.h ${HDF5_SRC_DIR}/H5Cpkg.h ${HDF5_SRC_DIR}/H5Cprivate.h @@ -869,6 +878,7 @@ set (H5_PRIVATE_HEADERS ${HDF5_SRC_DIR}/H5UCprivate.h + ${HDF5_SRC_DIR}/H5VLnative_private.h ${HDF5_SRC_DIR}/H5VLpkg.h ${HDF5_SRC_DIR}/H5VLprivate.h @@ -950,6 +960,7 @@ if (NOT EXISTS ${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c) ) add_custom_command ( OUTPUT ${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c + ${HDF5_GENERATED_SOURCE_DIR}/gen_SRCS.stamp1 COMMAND ${HDF5_BATCH_CMD} ARGS ${HDF5_BINARY_DIR}/${HDF5_BATCH_H5DETECT_SCRIPT} COMMAND ${CMAKE_COMMAND} @@ -965,6 +976,7 @@ if (NOT EXISTS ${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c) if (BUILD_SHARED_LIBS) add_custom_command ( OUTPUT ${HDF5_GENERATED_SOURCE_DIR}/shared/H5Tinit.c + ${HDF5_GENERATED_SOURCE_DIR}/shared/shared_gen_SRCS.stamp1 COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different "${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c" "${HDF5_GENERATED_SOURCE_DIR}/shared/H5Tinit.c" COMMAND ${CMAKE_COMMAND} @@ -977,6 +989,7 @@ if (NOT EXISTS ${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c) else () add_custom_command ( OUTPUT ${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c + ${HDF5_GENERATED_SOURCE_DIR}/gen_SRCS.stamp1 COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR}$<TARGET_FILE:H5detect> ARGS ${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c COMMAND ${CMAKE_COMMAND} @@ -987,6 +1000,7 @@ if (NOT EXISTS ${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c) if (BUILD_SHARED_LIBS) add_custom_command ( OUTPUT ${HDF5_GENERATED_SOURCE_DIR}/shared/H5Tinit.c + ${HDF5_GENERATED_SOURCE_DIR}/shared/shared_gen_SRCS.stamp1 COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different "${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c" "${HDF5_GENERATED_SOURCE_DIR}/shared/H5Tinit.c" COMMAND ${CMAKE_COMMAND} @@ -998,6 +1012,26 @@ if (NOT EXISTS ${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c) endif () endif () set_source_files_properties (${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c PROPERTIES GENERATED TRUE) +else () + add_custom_command ( + OUTPUT ${HDF5_GENERATED_SOURCE_DIR}/gen_SRCS.stamp1 + COMMAND ${CMAKE_COMMAND} + ARGS -E touch ${HDF5_GENERATED_SOURCE_DIR}/gen_SRCS.stamp1 + DEPENDS ${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c + WORKING_DIRECTORY ${HDF5_GENERATED_SOURCE_DIR} + ) + if (BUILD_SHARED_LIBS) + add_custom_command ( + OUTPUT ${HDF5_GENERATED_SOURCE_DIR}/shared/shared_gen_SRCS.stamp1 + COMMAND ${CMAKE_COMMAND} + ARGS -E copy_if_different "${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c" "${HDF5_GENERATED_SOURCE_DIR}/shared/H5Tinit.c" + COMMAND ${CMAKE_COMMAND} + ARGS -E touch ${HDF5_GENERATED_SOURCE_DIR}/shared/shared_gen_SRCS.stamp1 + DEPENDS ${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c + WORKING_DIRECTORY ${HDF5_GENERATED_SOURCE_DIR} + ) + set_source_files_properties (${HDF5_GENERATED_SOURCE_DIR}/shared/H5Tinit.c PROPERTIES GENERATED TRUE) + endif () endif () add_executable (H5make_libsettings ${HDF5_SRC_DIR}/H5make_libsettings.c) @@ -1011,6 +1045,7 @@ target_link_libraries (H5make_libsettings add_custom_command ( OUTPUT ${HDF5_BINARY_DIR}/H5lib_settings.c + ${HDF5_BINARY_DIR}/gen_SRCS.stamp2 COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR}$<TARGET_FILE:H5make_libsettings> ARGS ${HDF5_BINARY_DIR}/H5lib_settings.c COMMAND ${CMAKE_COMMAND} @@ -1022,6 +1057,7 @@ set_source_files_properties (${HDF5_BINARY_DIR}/H5lib_settings.c PROPERTIES GENE if (BUILD_SHARED_LIBS) add_custom_command ( OUTPUT ${HDF5_BINARY_DIR}/shared/H5lib_settings.c + ${HDF5_BINARY_DIR}/shared/shared_gen_SRCS.stamp2 COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different "${HDF5_BINARY_DIR}/H5lib_settings.c" "${HDF5_BINARY_DIR}/shared/H5lib_settings.c" COMMAND ${CMAKE_COMMAND} @@ -1201,10 +1201,16 @@ H5Arename(hid_t loc_id, const char *old_name, const char *new_name) H5TRACE3("e", "i*s*s", loc_id, old_name, new_name); /* check arguments */ - if(!old_name || !new_name) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "name is nil") if(H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") + if(!old_name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "old attribute name cannot be NULL") + if(!*old_name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "old attribute name cannot be an empty string") + if(!new_name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "new attribute name cannot be NULL") + if(!*new_name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "new attribute name cannot be an empty string") /* Avoid thrashing things if the names are the same */ if(HDstrcmp(old_name, new_name)) { @@ -1360,7 +1366,7 @@ H5Aiterate2(hid_t loc_id, H5_index_t idx_type, H5_iter_order_t order, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Iterate over attributes */ - if((ret_value = H5VL_attr_specific(vol_obj, &loc_params, H5VL_ATTR_ITER, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, idx_type, order, idx, op, op_data)) < 0) + if((ret_value = H5VL_attr_specific(vol_obj, &loc_params, H5VL_ATTR_ITER, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, (int)idx_type, (int)order, idx, op, op_data)) < 0) HERROR(H5E_ATTR, H5E_BADITER, "error iterating over attributes"); done: @@ -1448,7 +1454,7 @@ H5Aiterate_by_name(hid_t loc_id, const char *obj_name, H5_index_t idx_type, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Iterate over attributes */ - if((ret_value = H5VL_attr_specific(vol_obj, &loc_params, H5VL_ATTR_ITER, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, idx_type, order, idx, op, op_data)) < 0) + if((ret_value = H5VL_attr_specific(vol_obj, &loc_params, H5VL_ATTR_ITER, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, (int)idx_type, (int)order, idx, op, op_data)) < 0) HERROR(H5E_ATTR, H5E_BADITER, "attribute iteration failed"); done: @@ -30,22 +30,24 @@ /****************/ #include "H5ACmodule.h" /* This source code file is part of the H5AC module */ -#define H5F_FRIEND /* Suppress error about including H5Fpkg */ +#define H5C_FRIEND /* Suppress error about including H5Cpkg */ +#define H5F_FRIEND /* Suppress error about including H5Fpkg */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACpkg.h" /* Metadata cache */ -#include "H5Cprivate.h" /* Cache */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* Files */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5SLprivate.h" /* Skip Lists */ +#include "H5private.h" /* Generic Functions */ +#include "H5ACpkg.h" /* Metadata cache */ +#include "H5Clog.h" /* Cache logging */ +#include "H5Cpkg.h" /* Cache */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* Files */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5SLprivate.h" /* Skip Lists */ /****************/ @@ -128,7 +130,7 @@ static const H5AC_class_t *const H5AC_class_s[] = { H5AC_DRVRINFO, /* (26) driver info block (supplements superblock) */ H5AC_EPOCH_MARKER, /* (27) epoch marker - always internal to cache */ H5AC_PROXY_ENTRY, /* (28) cache entry proxy */ - H5AC_PREFETCHED_ENTRY /* (29) prefetched entry - always internal to cache */ + H5AC_PREFETCHED_ENTRY /* (29) prefetched entry - always internal to cache */ }; @@ -178,13 +180,16 @@ H5AC__init_package(void) #ifdef H5_HAVE_PARALLEL /* check whether to enable strict collective function calling - sanity checks using MPI barriers */ + * sanity checks using MPI barriers + */ { const char *s; /* String for environment variables */ s = HDgetenv("H5_COLL_API_SANITY_CHECK"); - if(s && HDisdigit(*s)) - H5_coll_api_sanity_check_g = (hbool_t)HDstrtol(s, NULL, 0); + if(s && HDisdigit(*s)) { + long env_val = HDstrtol(s, NULL, 0); + H5_coll_api_sanity_check_g = (0 == env_val) ? FALSE : TRUE; + } } #endif /* H5_HAVE_PARALLEL */ @@ -403,15 +408,13 @@ H5AC_create(const H5F_t *f, H5AC_cache_config_t *config_ptr, H5AC_cache_image_co HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "H5C_set_prefix() failed") #endif /* H5_HAVE_PARALLEL */ - /* Turn on metadata cache logging, if being used */ - if(H5F_USE_MDC_LOGGING(f)) { - if(H5C_set_up_logging(f->shared->cache, H5F_MDC_LOG_LOCATION(f), H5F_START_MDC_LOG_ON_ACCESS(f)) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTINIT, FAIL, "mdc logging setup failed") - - /* Write the log header regardless of current logging status */ - if(H5AC__write_create_cache_log_msg(f->shared->cache) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to emit log message") - } /* end if */ + /* Turn on metadata cache logging, if being used + * This will be JSON until we create a special API call. Trace output + * is generated when logging is controlled by the struct. + */ + if(H5F_USE_MDC_LOGGING(f)) + if(H5C_log_set_up(f->shared->cache, H5F_MDC_LOG_LOCATION(f), H5C_LOG_STYLE_JSON, H5F_START_MDC_LOG_ON_ACCESS(f)) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "mdc logging setup failed") /* Set the cache parameters */ if(H5AC_set_cache_auto_resize_config(f->shared->cache, config_ptr) < 0) @@ -431,6 +434,11 @@ H5AC_create(const H5F_t *f, H5AC_cache_config_t *config_ptr, H5AC_cache_image_co HGOTO_ERROR(H5E_CACHE, H5E_CANTSET, FAIL, "auto resize configuration failed") done: + /* If currently logging, generate a message */ + if(f->shared->cache->log_info->logging) + if(H5C_log_write_create_cache_msg(f->shared->cache, ret_value) < 0) + HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + #ifdef H5_HAVE_PARALLEL /* if there is a failure, try to tidy up the auxiliary structure */ if(ret_value < 0) { @@ -469,6 +477,8 @@ done: herr_t H5AC_dest(H5F_t *f) { + hbool_t log_enabled; /* TRUE if logging was set up */ + hbool_t curr_logging; /* TRUE if currently logging */ #ifdef H5_HAVE_PARALLEL H5AC_aux_t * aux_ptr = NULL; #endif /* H5_HAVE_PARALLEL */ @@ -486,18 +496,16 @@ H5AC_dest(H5F_t *f) H5AC_stats(f); #endif /* H5AC_DUMP_STATS_ON_CLOSE */ -#if H5AC__TRACE_FILE_ENABLED - if(H5AC__close_trace_file(f->shared->cache) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC__close_trace_file() failed") -#endif /* H5AC__TRACE_FILE_ENABLED */ - - if(H5F_USE_MDC_LOGGING(f)) { - /* Write the log footer regardless of current logging status */ - if(H5AC__write_destroy_cache_log_msg(f->shared->cache) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to emit log message") - if(H5C_tear_down_logging(f->shared->cache) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "mdc logging tear-down failed") - } /* end if */ + /* Check if log messages are being emitted */ + if(H5C_get_logging_status(f->shared->cache, &log_enabled, &curr_logging) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to get logging status") + if(log_enabled && curr_logging) + if(H5C_log_write_destroy_cache_msg(f->shared->cache) < 0) + HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + /* Tear down logging */ + if(log_enabled) + if(H5C_log_tear_down(f->shared->cache) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "mdc logging tear-down failed") #ifdef H5_HAVE_PARALLEL /* destroying the cache, so clear all collective entries */ @@ -565,8 +573,6 @@ done: herr_t H5AC_evict(H5F_t *f) { - hbool_t log_enabled; /* TRUE if logging was set up */ - hbool_t curr_logging; /* TRUE if currently logging */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -576,10 +582,6 @@ H5AC_evict(H5F_t *f) HDassert(f->shared); HDassert(f->shared->cache); - /* Check if log messages are being emitted */ - if(H5C_get_logging_status(f->shared->cache, &log_enabled, &curr_logging) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to get logging status") - /* Evict all entries in the cache except the pinned superblock entry */ if(H5C_evict(f) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFREE, FAIL, "can't evict cache") @@ -587,9 +589,9 @@ H5AC_evict(H5F_t *f) done: /* If currently logging, generate a message */ - if(curr_logging) - if(H5AC__write_evict_cache_log_msg(f->shared->cache, ret_value) < 0) - HDONE_ERROR(H5E_CACHE, H5E_LOGFAIL, FAIL, "unable to emit log message") + if(f->shared->cache->log_info->logging) + if(H5C_log_write_evict_cache_msg(f->shared->cache, ret_value) < 0) + HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_evict() */ @@ -613,12 +615,6 @@ herr_t H5AC_expunge_entry(H5F_t *f, const H5AC_class_t *type, haddr_t addr, unsigned flags) { -#if H5AC__TRACE_FILE_ENABLED - char trace[128] = ""; - FILE * trace_file_ptr = NULL; -#endif /* H5AC__TRACE_FILE_ENABLED */ - hbool_t log_enabled; /* TRUE if logging was set up */ - hbool_t curr_logging; /* TRUE if currently logging */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -631,36 +627,14 @@ H5AC_expunge_entry(H5F_t *f, const H5AC_class_t *type, haddr_t addr, HDassert(type->serialize); HDassert(H5F_addr_defined(addr)); - /* Check if log messages are being emitted */ - if(H5C_get_logging_status(f->shared->cache, &log_enabled, &curr_logging) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to get logging status") - -#if H5AC__TRACE_FILE_ENABLED -{ - H5AC_t * cache_ptr = f->shared->cache; - - /* For the expunge entry call, only the addr, and type id are really - * necessary in the trace file. Write the return value to catch occult - * errors. - */ - if(NULL != (trace_file_ptr = H5C_get_trace_file_ptr(cache_ptr))) - sprintf(trace, "%s 0x%lx %d", FUNC, (unsigned long)addr, (int)(type->id)); -} -#endif /* H5AC__TRACE_FILE_ENABLED */ - if(H5C_expunge_entry(f, type, addr, flags) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTEXPUNGE, FAIL, "H5C_expunge_entry() failed") done: -#if H5AC__TRACE_FILE_ENABLED - if(trace_file_ptr != NULL) - HDfprintf(trace_file_ptr, "%s %d\n", trace, (int)ret_value); -#endif /* H5AC__TRACE_FILE_ENABLED */ - /* If currently logging, generate a message */ - if(curr_logging) - if(H5AC__write_expunge_entry_log_msg(f->shared->cache, addr, type->id, ret_value) < 0) - HDONE_ERROR(H5E_CACHE, H5E_LOGFAIL, FAIL, "unable to emit log message") + if(f->shared->cache->log_info->logging) + if(H5C_log_write_expunge_entry_msg(f->shared->cache, addr, type->id, ret_value) < 0) + HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_expunge_entry() */ @@ -689,12 +663,6 @@ done: herr_t H5AC_flush(H5F_t *f) { -#if H5AC__TRACE_FILE_ENABLED - char trace[128] = ""; - FILE * trace_file_ptr = NULL; -#endif /* H5AC__TRACE_FILE_ENABLED */ - hbool_t log_enabled; /* TRUE if logging was set up */ - hbool_t curr_logging; /* TRUE if currently logging */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -704,18 +672,6 @@ H5AC_flush(H5F_t *f) HDassert(f->shared); HDassert(f->shared->cache); - /* Check if log messages are being emitted */ - if(H5C_get_logging_status(f->shared->cache, &log_enabled, &curr_logging) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to get logging status") - -#if H5AC__TRACE_FILE_ENABLED - /* For the flush, only the flags are really necessary in the trace file. - * Write the result to catch occult errors. - */ - if(NULL != (trace_file_ptr = H5C_get_trace_file_ptr(cache_ptr))) - sprintf(trace, "%s", FUNC); -#endif /* H5AC__TRACE_FILE_ENABLED */ - #ifdef H5_HAVE_PARALLEL /* flushing the cache, so clear all collective entries */ if(H5C_clear_coll_entries(f->shared->cache, FALSE) < 0) @@ -732,15 +688,10 @@ H5AC_flush(H5F_t *f) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't flush cache") done: -#if H5AC__TRACE_FILE_ENABLED - if(trace_file_ptr != NULL) - HDfprintf(trace_file_ptr, "%s %d\n", trace, (int)ret_value); -#endif /* H5AC__TRACE_FILE_ENABLED */ - /* If currently logging, generate a message */ - if(curr_logging) - if(H5AC__write_flush_cache_log_msg(f->shared->cache, ret_value) < 0) - HDONE_ERROR(H5E_CACHE, H5E_LOGFAIL, FAIL, "unable to emit log message") + if(f->shared->cache->log_info->logging) + if(H5C_log_write_flush_cache_msg(f->shared->cache, ret_value) < 0) + HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_flush() */ @@ -873,13 +824,6 @@ herr_t H5AC_insert_entry(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *thing, unsigned int flags) { -#if H5AC__TRACE_FILE_ENABLED - char trace[128] = ""; - size_t trace_entry_size = 0; - FILE * trace_file_ptr = NULL; -#endif /* H5AC__TRACE_FILE_ENABLED */ - hbool_t log_enabled; /* TRUE if logging was set up */ - hbool_t curr_logging; /* TRUE if currently logging */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -893,26 +837,9 @@ H5AC_insert_entry(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *thing, HDassert(H5F_addr_defined(addr)); HDassert(thing); - /* Check if log messages are being emitted */ - if(H5C_get_logging_status(f->shared->cache, &log_enabled, &curr_logging) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to get logging status") - /* Check for invalid access request */ if(0 == (H5F_INTENT(f) & H5F_ACC_RDWR)) - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "no write intent on file") - -#if H5AC__TRACE_FILE_ENABLED - /* For the insert, only the addr, size, type id and flags are really - * necessary in the trace file. Write the result to catch occult - * errors. - * - * Note that some data is not available right now -- put what we can - * in the trace buffer now, and fill in the rest at the end. - */ - if(NULL != (trace_file_ptr = H5C_get_trace_file_ptr(cache_ptr))) - sprintf(trace, "%s 0x%lx %d 0x%x", FUNC, (unsigned long)addr, type->id, - flags); -#endif /* H5AC__TRACE_FILE_ENABLED */ + HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "no write intent on file") #if H5AC_DO_TAGGING_SANITY_CHECKS if(!H5C_get_ignore_tags(f->shared->cache) && H5AC__verify_tag(type) < 0) @@ -923,12 +850,6 @@ H5AC_insert_entry(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *thing, if(H5C_insert_entry(f, type, addr, thing, flags) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTINS, FAIL, "H5C_insert_entry() failed") -#if H5AC__TRACE_FILE_ENABLED - if(trace_file_ptr != NULL) - /* make note of the entry size */ - trace_entry_size = ((H5C_cache_entry_t *)thing)->size; -#endif /* H5AC__TRACE_FILE_ENABLED */ - #ifdef H5_HAVE_PARALLEL { H5AC_aux_t *aux_ptr; @@ -947,14 +868,10 @@ H5AC_insert_entry(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *thing, #endif /* H5_HAVE_PARALLEL */ done: -#if H5AC__TRACE_FILE_ENABLED - if(trace_file_ptr != NULL) - HDfprintf(trace_file_ptr, "%s %d %d\n", trace, (int)trace_entry_size, (int)ret_value); -#endif /* H5AC__TRACE_FILE_ENABLED */ /* If currently logging, generate a message */ - if(curr_logging) - if(H5AC__write_insert_entry_log_msg(f->shared->cache, addr, type->id, flags, ((H5C_cache_entry_t *)thing)->size, ret_value) < 0) - HDONE_ERROR(H5E_CACHE, H5E_LOGFAIL, FAIL, "unable to emit log message") + if(f->shared->cache->log_info->logging) + if(H5C_log_write_insert_entry_msg(f->shared->cache, addr, type->id, flags, ((H5C_cache_entry_t *)thing)->size, ret_value) < 0) + HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_insert_entry() */ @@ -1011,12 +928,6 @@ done: herr_t H5AC_mark_entry_dirty(void *thing) { -#if H5AC__TRACE_FILE_ENABLED - char trace[128] = ""; - FILE * trace_file_ptr = NULL; -#endif /* H5AC__TRACE_FILE_ENABLED */ - hbool_t log_enabled; /* TRUE if logging was set up */ - hbool_t curr_logging; /* TRUE if currently logging */ H5AC_info_t *entry_ptr = NULL; /* Pointer to the cache entry */ H5C_t *cache_ptr = NULL; /* Pointer to the entry's associated metadata cache */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1030,19 +941,6 @@ H5AC_mark_entry_dirty(void *thing) entry_ptr = (H5AC_info_t *)thing; cache_ptr = entry_ptr->cache_ptr; -#if H5AC__TRACE_FILE_ENABLED - /* For the mark pinned or protected entry dirty call, only the addr - * is really necessary in the trace file. Write the result to catch - * occult errors. - */ - if(NULL != (trace_file_ptr = H5C_get_trace_file_ptr_from_entry(thing))) - sprintf(trace, "%s 0x%lx", FUNC, (unsigned long)(entry_ptr->addr)); -#endif /* H5AC__TRACE_FILE_ENABLED */ - - /* Check if log messages are being emitted */ - if(H5C_get_logging_status(cache_ptr, &log_enabled, &curr_logging) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to get logging status") - #ifdef H5_HAVE_PARALLEL { H5AC_aux_t *aux_ptr; @@ -1059,15 +957,10 @@ H5AC_mark_entry_dirty(void *thing) HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKDIRTY, FAIL, "can't mark pinned or protected entry dirty") done: -#if H5AC__TRACE_FILE_ENABLED - if(trace_file_ptr) - HDfprintf(trace_file_ptr, "%s %d\n", trace, (int)ret_value); -#endif /* H5AC__TRACE_FILE_ENABLED */ - /* If currently logging, generate a message */ - if(curr_logging) - if(H5AC__write_mark_dirty_entry_log_msg(cache_ptr, entry_ptr, ret_value) < 0) - HDONE_ERROR(H5E_CACHE, H5E_LOGFAIL, FAIL, "unable to emit log message") + if(cache_ptr->log_info->logging) + if(H5C_log_write_mark_entry_dirty_msg(cache_ptr, entry_ptr, ret_value) < 0) + HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_mark_entry_dirty() */ @@ -1076,7 +969,7 @@ done: /*------------------------------------------------------------------------- * Function: H5AC_mark_entry_clean * - * Purpose: Mark a pinned entry as dirty. The target + * Purpose: Mark a pinned entry as clean. The target * entry MUST be pinned. * * Return: Non-negative on success/Negative on failure @@ -1089,12 +982,6 @@ done: herr_t H5AC_mark_entry_clean(void *thing) { -#if H5AC__TRACE_FILE_ENABLED - char trace[128] = ""; - FILE * trace_file_ptr = NULL; -#endif /* H5AC__TRACE_FILE_ENABLED */ - hbool_t log_enabled; /* TRUE if logging was set up */ - hbool_t curr_logging; /* TRUE if currently logging */ H5AC_info_t *entry_ptr = NULL; /* Pointer to the cache entry */ H5C_t *cache_ptr = NULL; /* Pointer to the entry's associated metadata cache */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1104,23 +991,9 @@ H5AC_mark_entry_clean(void *thing) /* Sanity check */ HDassert(thing); -#if H5AC__TRACE_FILE_ENABLED - /* For the mark pinned or protected entry clean call, only the addr - * is really necessary in the trace file. Write the result to catch - * occult errors. - */ - if(NULL != (trace_file_ptr = H5C_get_trace_file_ptr_from_entry(thing))) - sprintf(trace, "%s 0x%lx", FUNC, - (unsigned long)(((H5C_cache_entry_t *)thing)->addr)); -#endif /* H5AC__TRACE_FILE_ENABLED */ - entry_ptr = (H5AC_info_t *)thing; cache_ptr = entry_ptr->cache_ptr; - /* Check if log messages are being emitted */ - if(H5C_get_logging_status(cache_ptr, &log_enabled, &curr_logging) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to get logging status") - #ifdef H5_HAVE_PARALLEL { H5AC_aux_t *aux_ptr; @@ -1137,15 +1010,10 @@ H5AC_mark_entry_clean(void *thing) HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKCLEAN, FAIL, "can't mark pinned or protected entry clean") done: -#if H5AC__TRACE_FILE_ENABLED - if(trace_file_ptr) - HDfprintf(trace_file_ptr, "%s %d\n", trace, (int)ret_value); -#endif /* H5AC__TRACE_FILE_ENABLED */ - /* If currently logging, generate a message */ - if(curr_logging) - if(H5AC__write_mark_clean_entry_log_msg(cache_ptr, entry_ptr, ret_value) < 0) - HDONE_ERROR(H5E_CACHE, H5E_LOGFAIL, FAIL, "unable to emit log message") + if(cache_ptr->log_info->logging) + if(H5C_log_write_mark_entry_clean_msg(cache_ptr, entry_ptr, ret_value) < 0) + HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_mark_entry_clean() */ @@ -1167,12 +1035,6 @@ done: herr_t H5AC_mark_entry_unserialized(void *thing) { -#if H5AC__TRACE_FILE_ENABLED - char trace[128] = ""; - FILE * trace_file_ptr = NULL; -#endif /* H5AC__TRACE_FILE_ENABLED */ - hbool_t log_enabled; /* TRUE if logging was set up */ - hbool_t curr_logging; /* TRUE if currently logging */ H5AC_info_t *entry_ptr = NULL; /* Pointer to the cache entry */ H5C_t *cache_ptr = NULL; /* Pointer to the entry's associated metadata cache */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1186,32 +1048,14 @@ H5AC_mark_entry_unserialized(void *thing) entry_ptr = (H5AC_info_t *)thing; cache_ptr = entry_ptr->cache_ptr; -#if H5AC__TRACE_FILE_ENABLED - /* For the mark entry unserialized call, only the addr - * is really necessary in the trace file. Write the result to catch - * occult errors. - */ - if(NULL != (trace_file_ptr = H5C_get_trace_file_ptr_from_entry(thing))) - sprintf(trace, "%s 0x%lx", FUNC, (unsigned long)(entry_ptr->addr)); -#endif /* H5AC__TRACE_FILE_ENABLED */ - - /* Check if log messages are being emitted */ - if(H5C_get_logging_status(cache_ptr, &log_enabled, &curr_logging) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, FAIL, "unable to get logging status") - if(H5C_mark_entry_unserialized(thing) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKUNSERIALIZED, FAIL, "can't mark entry unserialized") done: -#if H5AC__TRACE_FILE_ENABLED - if(trace_file_ptr) - HDfprintf(trace_file_ptr, "%s %d\n", trace, (int)ret_value); -#endif /* H5AC__TRACE_FILE_ENABLED */ - /* If currently logging, generate a message */ - if(curr_logging) - if(H5AC__write_mark_unserialized_entry_log_msg(cache_ptr, entry_ptr, ret_value) < 0) - HDONE_ERROR(H5E_CACHE, H5E_LOGFAIL, FAIL, "unable to emit log message") + if(cache_ptr->log_info->logging) + if(H5C_log_write_mark_unserialized_entry_msg(cache_ptr, entry_ptr, ret_value) < 0) + HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_mark_entry_unserialized() */ @@ -1233,12 +1077,6 @@ done: herr_t H5AC_mark_entry_serialized(void *thing) { -#if H5AC__TRACE_FILE_ENABLED - char trace[128] = ""; - FILE * trace_file_ptr = NULL; -#endif /* H5AC__TRACE_FILE_ENABLED */ - hbool_t log_enabled; /* TRUE if logging was set up */ - hbool_t curr_logging; /* TRUE if currently logging */ H5AC_info_t *entry_ptr = NULL; /* Pointer to the cache entry */ H5C_t *cache_ptr = NULL; /* Pointer to the entry's associated metadata cache */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1248,36 +1086,17 @@ H5AC_mark_entry_serialized(void *thing) /* Sanity check */ HDassert(thing); -#if H5AC__TRACE_FILE_ENABLED - /* For the mark entry serializedn call, only the addr - * is really necessary in the trace file. Write the result to catch - * occult errors. - */ - if(NULL != (trace_file_ptr = H5C_get_trace_file_ptr_from_entry(thing))) - sprintf(trace, "%s 0x%lx", FUNC, - (unsigned long)(((H5C_cache_entry_t *)thing)->addr)); -#endif /* H5AC__TRACE_FILE_ENABLED */ - entry_ptr = (H5AC_info_t *)thing; cache_ptr = entry_ptr->cache_ptr; - /* Check if log messages are being emitted */ - if(H5C_get_logging_status(cache_ptr, &log_enabled, &curr_logging) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, FAIL, "unable to get logging status") - if(H5C_mark_entry_serialized(thing) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKSERIALIZED, FAIL, "can't mark entry serialized") done: -#if H5AC__TRACE_FILE_ENABLED - if(trace_file_ptr) - HDfprintf(trace_file_ptr, "%s %d\n", trace, (int)ret_value); -#endif /* H5AC__TRACE_FILE_ENABLED */ - /* If currently logging, generate a message */ - if(curr_logging) - if(H5AC__write_mark_serialized_entry_log_msg(cache_ptr, entry_ptr, ret_value) < 0) - HDONE_ERROR(H5E_CACHE, H5E_LOGFAIL, FAIL, "unable to emit log message") + if(cache_ptr->log_info->logging) + if(H5C_log_write_mark_serialized_entry_msg(cache_ptr, entry_ptr, ret_value) < 0) + HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_mark_entry_serialized() */ @@ -1300,15 +1119,9 @@ done: herr_t H5AC_move_entry(H5F_t *f, const H5AC_class_t *type, haddr_t old_addr, haddr_t new_addr) { -#if H5AC__TRACE_FILE_ENABLED - char trace[128] = ""; - FILE * trace_file_ptr = NULL; -#endif /* H5AC__TRACE_FILE_ENABLED */ #ifdef H5_HAVE_PARALLEL H5AC_aux_t *aux_ptr; #endif /* H5_HAVE_PARALLEL */ - hbool_t log_enabled; /* TRUE if logging was set up */ - hbool_t curr_logging; /* TRUE if currently logging */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1321,20 +1134,6 @@ H5AC_move_entry(H5F_t *f, const H5AC_class_t *type, haddr_t old_addr, haddr_t ne HDassert(H5F_addr_defined(new_addr)); HDassert(H5F_addr_ne(old_addr, new_addr)); - /* Check if log messages are being emitted */ - if(H5C_get_logging_status(f->shared->cache, &log_enabled, &curr_logging) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to get logging status") - -#if H5AC__TRACE_FILE_ENABLED - /* For the move call, only the old addr and new addr are really - * necessary in the trace file. Include the type id so we don't have to - * look it up. Also write the result to catch occult errors. - */ - if(NULL != (trace_file_ptr = H5C_get_trace_file_ptr(cache_ptr))) - sprintf(trace, "%s 0x%lx 0x%lx %d", FUNC, (unsigned long)old_addr, - (unsigned long)new_addr, (int)(type->id)); -#endif /* H5AC__TRACE_FILE_ENABLED */ - #ifdef H5_HAVE_PARALLEL /* Log moving the entry */ if(NULL != (aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(f->shared->cache))) @@ -1353,15 +1152,10 @@ H5AC_move_entry(H5F_t *f, const H5AC_class_t *type, haddr_t old_addr, haddr_t ne #endif /* H5_HAVE_PARALLEL */ done: -#if H5AC__TRACE_FILE_ENABLED - if(trace_file_ptr != NULL) - HDfprintf(trace_file_ptr, "%s %d\n", trace, (int)ret_value); -#endif /* H5AC__TRACE_FILE_ENABLED */ - /* If currently logging, generate a message */ - if(curr_logging) - if(H5AC__write_move_entry_log_msg(f->shared->cache, old_addr, new_addr, type->id, ret_value) < 0) - HDONE_ERROR(H5E_CACHE, H5E_LOGFAIL, FAIL, "unable to emit log message") + if(f->shared->cache->log_info->logging) + if(H5C_log_write_move_entry_msg(f->shared->cache, old_addr, new_addr, type->id, ret_value) < 0) + HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_move_entry() */ @@ -1383,12 +1177,6 @@ done: herr_t H5AC_pin_protected_entry(void *thing) { -#if H5AC__TRACE_FILE_ENABLED - char trace[128] = ""; - FILE * trace_file_ptr = NULL; -#endif /* H5AC__TRACE_FILE_ENABLED */ - hbool_t log_enabled; /* TRUE if logging was set up */ - hbool_t curr_logging; /* TRUE if currently logging */ H5AC_info_t *entry_ptr = NULL; /* Pointer to the cache entry */ H5C_t *cache_ptr = NULL; /* Pointer to the entry's associated metadata cache */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1398,37 +1186,19 @@ H5AC_pin_protected_entry(void *thing) /* Sanity check */ HDassert(thing); -#if H5AC__TRACE_FILE_ENABLED - /* For the pin protected entry call, only the addr is really necessary - * in the trace file. Also write the result to catch occult errors. - */ - if(NULL != (trace_file_ptr = H5C_get_trace_file_ptr_from_entry(thing))) - sprintf(trace, "%s 0x%lx", FUNC, - (unsigned long)(((H5C_cache_entry_t *)thing)->addr)); -#endif /* H5AC__TRACE_FILE_ENABLED */ - entry_ptr = (H5AC_info_t *)thing; cache_ptr = entry_ptr->cache_ptr; HDassert(cache_ptr); - /* Check if log messages are being emitted */ - if(H5C_get_logging_status(cache_ptr, &log_enabled, &curr_logging) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to get logging status") - /* Pin entry */ if(H5C_pin_protected_entry(thing) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTPIN, FAIL, "can't pin entry") done: -#if H5AC__TRACE_FILE_ENABLED - if(trace_file_ptr) - HDfprintf(trace_file_ptr, "%s %d\n", trace, (int)ret_value); -#endif /* H5AC__TRACE_FILE_ENABLED */ - /* If currently logging, generate a message */ - if(curr_logging) - if(H5AC__write_pin_entry_log_msg(cache_ptr, entry_ptr, ret_value) < 0) - HDONE_ERROR(H5E_CACHE, H5E_LOGFAIL, FAIL, "unable to emit log message") + if(cache_ptr->log_info->logging) + if(H5C_log_write_pin_entry_msg(cache_ptr, entry_ptr, ret_value) < 0) + HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_pin_protected_entry() */ @@ -1488,12 +1258,6 @@ done: herr_t H5AC_create_flush_dependency(void * parent_thing, void * child_thing) { -#if H5AC__TRACE_FILE_ENABLED - char trace[128] = ""; - FILE * trace_file_ptr = NULL; -#endif /* H5AC__TRACE_FILE_ENABLED */ - hbool_t log_enabled; /* TRUE if logging was set up */ - hbool_t curr_logging; /* TRUE if currently logging */ H5AC_info_t *entry_ptr = NULL; /* Pointer to the cache entry */ H5C_t *cache_ptr = NULL; /* Pointer to the entry's associated metadata cache */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1504,35 +1268,19 @@ H5AC_create_flush_dependency(void * parent_thing, void * child_thing) HDassert(parent_thing); HDassert(child_thing); -#if H5AC__TRACE_FILE_ENABLED - if(NULL != (trace_file_ptr = H5C_get_trace_file_ptr_from_entry(parent_thing))) - sprintf(trace, "%s %lx %lx", FUNC, - (unsigned long)(((H5C_cache_entry_t *)parent_thing)->addr), - (unsigned long)(((H5C_cache_entry_t *)child_thing)->addr)); -#endif /* H5AC__TRACE_FILE_ENABLED */ - entry_ptr = (H5AC_info_t *)parent_thing; cache_ptr = entry_ptr->cache_ptr; HDassert(cache_ptr); - /* Check if log messages are being emitted */ - if(H5C_get_logging_status(cache_ptr, &log_enabled, &curr_logging) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to get logging status") - /* Create the flush dependency */ if(H5C_create_flush_dependency(parent_thing, child_thing) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTDEPEND, FAIL, "H5C_create_flush_dependency() failed") done: -#if H5AC__TRACE_FILE_ENABLED - if(trace_file_ptr != NULL) - HDfprintf(trace_file_ptr, "%s %d\n", trace, (int)ret_value); -#endif /* H5AC__TRACE_FILE_ENABLED */ - /* If currently logging, generate a message */ - if(curr_logging) - if(H5AC__write_create_fd_log_msg(cache_ptr, (H5AC_info_t *)parent_thing, (H5AC_info_t *)child_thing, ret_value) < 0) - HDONE_ERROR(H5E_CACHE, H5E_LOGFAIL, FAIL, "unable to emit log message") + if(cache_ptr->log_info->logging) + if(H5C_log_write_create_fd_msg(cache_ptr, (H5AC_info_t *)parent_thing, (H5AC_info_t *)child_thing, ret_value) < 0) + HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_create_flush_dependency() */ @@ -1566,14 +1314,7 @@ void * H5AC_protect(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *udata, unsigned flags) { -#if H5AC__TRACE_FILE_ENABLED - char trace[128] = ""; - size_t trace_entry_size = 0; - FILE * trace_file_ptr = NULL; -#endif /* H5AC__TRACE_FILE_ENABLED */ void * thing = NULL; /* Pointer to native data structure for entry */ - hbool_t log_enabled; /* TRUE if logging was set up */ - hbool_t curr_logging; /* TRUE if currently logging */ void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -1586,10 +1327,6 @@ H5AC_protect(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *udata, HDassert(type->serialize); HDassert(H5F_addr_defined(addr)); - /* Check if log messages are being emitted */ - if(H5C_get_logging_status(f->shared->cache, &log_enabled, &curr_logging) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, NULL, "unable to get logging status") - /* Check for unexpected flags -- H5C__FLUSH_COLLECTIVELY_FLAG * only permitted in the parallel case. */ @@ -1606,16 +1343,6 @@ H5AC_protect(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *udata, if((0 == (H5F_INTENT(f) & H5F_ACC_RDWR)) && (0 == (flags & H5C__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, NULL, "no write intent on file") -#if H5AC__TRACE_FILE_ENABLED - /* For the protect call, only the addr, size, type id, and flags are - * necessary in the trace file. Also indicate whether the call was - * successful to catch occult errors. - */ - if(NULL != (trace_file_ptr = H5C_get_trace_file_ptr(cache_ptr))) - sprintf(trace, "%s 0x%lx %d 0x%x", FUNC, (unsigned long)addr, - (int)(type->id), flags); -#endif /* H5AC__TRACE_FILE_ENABLED */ - #if H5AC_DO_TAGGING_SANITY_CHECKS if(!H5C_get_ignore_tags(f->shared->cache) && H5AC__verify_tag(type) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, NULL, "Bad tag value") @@ -1624,28 +1351,18 @@ H5AC_protect(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *udata, if(NULL == (thing = H5C_protect(f, type, addr, udata, flags))) HGOTO_ERROR(H5E_CACHE, H5E_CANTPROTECT, NULL, "H5C_protect() failed") -#if H5AC__TRACE_FILE_ENABLED - if(trace_file_ptr != NULL) - /* Make note of the entry size */ - trace_entry_size = ((H5C_cache_entry_t *)thing)->size; -#endif /* H5AC__TRACE_FILE_ENABLED */ - /* Set return value */ ret_value = thing; done: -#if H5AC__TRACE_FILE_ENABLED - if(trace_file_ptr != NULL) - HDfprintf(trace_file_ptr, "%s %d %d\n", trace, (int)trace_entry_size, (int)(ret_value != NULL)); -#endif /* H5AC__TRACE_FILE_ENABLED */ - /* If currently logging, generate a message */ - if(curr_logging) { + { herr_t fake_ret_value = (NULL == ret_value) ? FAIL : SUCCEED; - if(H5AC__write_protect_entry_log_msg(f->shared->cache, (H5AC_info_t *)thing, flags, fake_ret_value) < 0) - HDONE_ERROR(H5E_CACHE, H5E_LOGFAIL, NULL, "unable to emit log message") - } /* end if */ + if(f->shared->cache->log_info->logging) + if(H5C_log_write_protect_entry_msg(f->shared->cache, (H5AC_info_t *)thing, type->id, flags, fake_ret_value) < 0) + HDONE_ERROR(H5E_CACHE, H5E_LOGGING, NULL, "unable to emit log message") + } FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_protect() */ @@ -1666,12 +1383,6 @@ done: herr_t H5AC_resize_entry(void *thing, size_t new_size) { -#if H5AC__TRACE_FILE_ENABLED - char trace[128] = ""; - FILE * trace_file_ptr = NULL; -#endif /* H5AC__TRACE_FILE_ENABLED */ - hbool_t log_enabled; /* TRUE if logging was set up */ - hbool_t curr_logging; /* TRUE if currently logging */ H5AC_info_t *entry_ptr = NULL; /* Pointer to the cache entry */ H5C_t *cache_ptr = NULL; /* Pointer to the entry's associated metadata cache */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1681,25 +1392,10 @@ H5AC_resize_entry(void *thing, size_t new_size) /* Sanity check */ HDassert(thing); -#if H5AC__TRACE_FILE_ENABLED - /* For the resize pinned entry call, only the addr, and new_size are - * really necessary in the trace file. Write the result to catch - * occult errors. - */ - if(NULL != (trace_file_ptr = H5C_get_trace_file_ptr_from_entry(thing))) - sprintf(trace, "%s 0x%lx %d", FUNC, - (unsigned long)(((H5C_cache_entry_t *)thing)->addr), - (int)new_size); -#endif /* H5AC__TRACE_FILE_ENABLED */ - entry_ptr = (H5AC_info_t *)thing; cache_ptr = entry_ptr->cache_ptr; HDassert(cache_ptr); - /* Check if log messages are being emitted */ - if(H5C_get_logging_status(cache_ptr, &log_enabled, &curr_logging) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to get logging status") - /* Resize the entry */ if(H5C_resize_entry(thing, new_size) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTRESIZE, FAIL, "can't resize entry") @@ -1716,15 +1412,10 @@ H5AC_resize_entry(void *thing, size_t new_size) #endif /* H5_HAVE_PARALLEL */ done: -#if H5AC__TRACE_FILE_ENABLED - if(trace_file_ptr) - HDfprintf(trace_file_ptr, "%s %d\n", trace, (int)ret_value); -#endif /* H5AC__TRACE_FILE_ENABLED */ - /* If currently logging, generate a message */ - if(curr_logging) - if(H5AC__write_resize_entry_log_msg(cache_ptr, entry_ptr, new_size, ret_value) < 0) - HDONE_ERROR(H5E_CACHE, H5E_LOGFAIL, FAIL, "unable to emit log message") + if(cache_ptr->log_info->logging) + if(H5C_log_write_resize_entry_msg(cache_ptr, entry_ptr, new_size, ret_value) < 0) + HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_resize_entry() */ @@ -1746,12 +1437,6 @@ done: herr_t H5AC_unpin_entry(void *thing) { -#if H5AC__TRACE_FILE_ENABLED - char trace[128] = ""; - FILE * trace_file_ptr = NULL; -#endif /* H5AC__TRACE_FILE_ENABLED */ - hbool_t log_enabled; /* TRUE if logging was set up */ - hbool_t curr_logging; /* TRUE if currently logging */ H5AC_info_t *entry_ptr = NULL; /* Pointer to the cache entry */ H5C_t *cache_ptr = NULL; /* Pointer to the entry's associated metadata cache */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1761,37 +1446,19 @@ H5AC_unpin_entry(void *thing) /* Sanity check */ HDassert(thing); -#if H5AC__TRACE_FILE_ENABLED - /* For the unpin entry call, only the addr is really necessary - * in the trace file. Also write the result to catch occult errors. - */ - if(NULL != (trace_file_ptr = H5C_get_trace_file_ptr_from_entry(thing))) - sprintf(trace, "%s 0x%lx", FUNC, - (unsigned long)(((H5C_cache_entry_t *)thing)->addr)); -#endif /* H5AC__TRACE_FILE_ENABLED */ - entry_ptr = (H5AC_info_t *)thing; cache_ptr = entry_ptr->cache_ptr; HDassert(cache_ptr); - /* Check if log messages are being emitted */ - if(H5C_get_logging_status(cache_ptr, &log_enabled, &curr_logging) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to get logging status") - /* Unpin the entry */ if(H5C_unpin_entry(thing) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPIN, FAIL, "can't unpin entry") done: -#if H5AC__TRACE_FILE_ENABLED - if(trace_file_ptr) - HDfprintf(trace_file_ptr, "%s %d\n", trace, (int)ret_value); -#endif /* H5AC__TRACE_FILE_ENABLED */ - /* If currently logging, generate a message */ - if(curr_logging) - if(H5AC__write_unpin_entry_log_msg(cache_ptr, entry_ptr, ret_value) < 0) - HDONE_ERROR(H5E_CACHE, H5E_LOGFAIL, FAIL, "unable to emit log message") + if(cache_ptr->log_info->logging) + if(H5C_log_write_unpin_entry_msg(cache_ptr, entry_ptr, ret_value) < 0) + HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_unpin_entry() */ @@ -1812,12 +1479,6 @@ done: herr_t H5AC_destroy_flush_dependency(void * parent_thing, void * child_thing) { -#if H5AC__TRACE_FILE_ENABLED - char trace[128] = ""; - FILE * trace_file_ptr = NULL; -#endif /* H5AC__TRACE_FILE_ENABLED */ - hbool_t log_enabled; /* TRUE if logging was set up */ - hbool_t curr_logging; /* TRUE if currently logging */ H5AC_info_t *entry_ptr = NULL; /* Pointer to the cache entry */ H5C_t *cache_ptr = NULL; /* Pointer to the entry's associated metadata cache */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1828,35 +1489,19 @@ H5AC_destroy_flush_dependency(void * parent_thing, void * child_thing) HDassert(parent_thing); HDassert(child_thing); -#if H5AC__TRACE_FILE_ENABLED - if(NULL != (trace_file_ptr = H5C_get_trace_file_ptr_from_entry(parent_thing))) - sprintf(trace, "%s %llx %llx", FUNC, - (unsigned long long)(((H5C_cache_entry_t *)parent_thing)->addr), - (unsigned long long)(((H5C_cache_entry_t *)child_thing)->addr)); -#endif /* H5AC__TRACE_FILE_ENABLED */ - entry_ptr = (H5AC_info_t *)parent_thing; cache_ptr = entry_ptr->cache_ptr; HDassert(cache_ptr); - /* Check if log messages are being emitted */ - if(H5C_get_logging_status(cache_ptr, &log_enabled, &curr_logging) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to get logging status") - /* Destroy the flush dependency */ if(H5C_destroy_flush_dependency(parent_thing, child_thing) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTUNDEPEND, FAIL, "H5C_destroy_flush_dependency() failed") done: -#if H5AC__TRACE_FILE_ENABLED - if(trace_file_ptr != NULL) - HDfprintf(trace_file_ptr, "%s %d\n", trace, (int)ret_value); -#endif /* H5AC__TRACE_FILE_ENABLED */ - /* If currently logging, generate a message */ - if(curr_logging) - if(H5AC__write_destroy_fd_log_msg(cache_ptr, (H5AC_info_t *)parent_thing, (H5AC_info_t *)child_thing, ret_value) < 0) - HDONE_ERROR(H5E_CACHE, H5E_LOGFAIL, FAIL, "unable to emit log message") + if(cache_ptr->log_info->logging) + if(H5C_log_write_destroy_fd_msg(cache_ptr, (H5AC_info_t *)parent_thing, (H5AC_info_t *)child_thing, ret_value) < 0) + HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_destroy_flush_dependency() */ @@ -1904,17 +1549,11 @@ herr_t H5AC_unprotect(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *thing, unsigned flags) { -#if H5AC__TRACE_FILE_ENABLED - char trace[128] = ""; - FILE * trace_file_ptr = NULL; -#endif /* H5AC__TRACE_FILE_ENABLED */ hbool_t dirtied; hbool_t deleted; #ifdef H5_HAVE_PARALLEL H5AC_aux_t * aux_ptr = NULL; #endif /* H5_HAVE_PARALLEL */ - hbool_t log_enabled; /* TRUE if logging was set up */ - hbool_t curr_logging; /* TRUE if currently logging */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1931,19 +1570,6 @@ H5AC_unprotect(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *thing, HDassert( ((H5AC_info_t *)thing)->addr == addr ); HDassert( ((H5AC_info_t *)thing)->type == type ); - /* Check if log messages are being emitted */ - if(H5C_get_logging_status(f->shared->cache, &log_enabled, &curr_logging) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to get logging status") - -#if H5AC__TRACE_FILE_ENABLED - /* For the unprotect call, only the addr, type id, flags, and possible - * new size are really necessary in the trace file. Write the return - * value to catch occult errors. - */ - if(NULL != (trace_file_ptr = H5C_get_trace_file_ptr(cache_ptr))) - sprintf(trace, "%s 0x%lx %d", FUNC, (unsigned long)addr, (int)(type->id)); -#endif /* H5AC__TRACE_FILE_ENABLED */ - dirtied = (hbool_t)(((flags & H5AC__DIRTIED_FLAG) == H5AC__DIRTIED_FLAG) || (((H5AC_info_t *)thing)->dirtied)); deleted = (hbool_t)((flags & H5C__DELETED_FLAG) == H5C__DELETED_FLAG); @@ -1984,15 +1610,10 @@ H5AC_unprotect(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *thing, #endif /* H5_HAVE_PARALLEL */ done: -#if H5AC__TRACE_FILE_ENABLED - if(trace_file_ptr != NULL) - HDfprintf(trace_file_ptr, "%s 0x%x %d\n", trace, (unsigned)flags, (int)ret_value); -#endif /* H5AC__TRACE_FILE_ENABLED */ - /* If currently logging, generate a message */ - if(curr_logging) - if(H5AC__write_unprotect_entry_log_msg(f->shared->cache, (H5AC_info_t *)thing, type->id, flags, ret_value) < 0) - HDONE_ERROR(H5E_CACHE, H5E_LOGFAIL, FAIL, "unable to emit log message") + if(f->shared->cache->log_info->logging) + if(H5C_log_write_unprotect_entry_msg(f->shared->cache, (H5AC_info_t *)thing, type->id, flags, ret_value) < 0) + HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_unprotect() */ @@ -2191,12 +1812,6 @@ done: herr_t H5AC_set_cache_auto_resize_config(H5AC_t *cache_ptr, H5AC_cache_config_t *config_ptr) { -#if H5AC__TRACE_FILE_ENABLED - H5AC_cache_config_t trace_config = H5AC__DEFAULT_CACHE_CONFIG; - FILE * trace_file_ptr = NULL; -#endif /* H5AC__TRACE_FILE_ENABLED */ - hbool_t log_enabled; /* TRUE if logging was set up */ - hbool_t curr_logging; /* TRUE if currently logging */ H5C_auto_size_ctl_t internal_config; herr_t ret_value = SUCCEED; /* Return value */ @@ -2205,18 +1820,6 @@ H5AC_set_cache_auto_resize_config(H5AC_t *cache_ptr, H5AC_cache_config_t *config /* Sanity checks */ HDassert(cache_ptr); - /* Check if log messages are being emitted */ - if(H5C_get_logging_status(cache_ptr, &log_enabled, &curr_logging) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to get logging status") - -#if H5AC__TRACE_FILE_ENABLED - /* Make note of the new configuration. Don't look up the trace file - * pointer, as that may change before we use it. - */ - if(config_ptr != NULL) - trace_config = *config_ptr; -#endif /* H5AC__TRACE_FILE_ENABLED */ - if(cache_ptr == NULL) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "bad cache_ptr on entry") #ifdef H5_HAVE_PARALLEL @@ -2233,23 +1836,25 @@ H5AC_set_cache_auto_resize_config(H5AC_t *cache_ptr, H5AC_cache_config_t *config if(H5AC_validate_config(config_ptr) != SUCCEED) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "Bad cache configuration") - if(config_ptr->open_trace_file) { - FILE * file_ptr; - - if(NULL == (file_ptr = H5C_get_trace_file_ptr(cache_ptr))) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C_get_trace_file_ptr() failed") - - if((!(config_ptr->close_trace_file)) && (file_ptr != NULL)) - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "Trace file already open") - } /* end if */ - - /* Close & reopen trace file, if requested */ + /* If the cache config struct is being used to control logging, perform + * the open/close operations. Note that this is the only place where the + * struct-based control opens and closes the log files so we also have + * to write start/stop messages. + */ + /* close */ if(config_ptr->close_trace_file) - if(H5AC__close_trace_file(cache_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC__close_trace_file() failed") - if(config_ptr->open_trace_file) - if(H5AC__open_trace_file(cache_ptr, config_ptr->trace_file_name) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "H5AC__open_trace_file() failed") + if(H5C_log_tear_down((H5C_t *)cache_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "mdc logging tear-down failed") + + /* open */ + if(config_ptr->open_trace_file) { + /* Turn on metadata cache logging. + * This will be trace output until we create a special API call. JSON + * output is generated when logging is controlled by the H5P calls. + */ + if(H5C_log_set_up((H5C_t *)cache_ptr, config_ptr->trace_file_name, H5C_LOG_STYLE_TRACE, TRUE) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "mdc logging setup failed") + } /* Convert external configuration to internal representation */ if(H5AC__ext_config_2_int_config(config_ptr, &internal_config) < 0) @@ -2275,52 +1880,10 @@ H5AC_set_cache_auto_resize_config(H5AC_t *cache_ptr, H5AC_cache_config_t *config #endif /* H5_HAVE_PARALLEL */ done: -#if H5AC__TRACE_FILE_ENABLED - /* For the set cache auto resize config call, only the contents - * of the config is necessary in the trace file. Write the return - * value to catch occult errors. - */ - if(NULL != (trace_file_ptr = H5C_get_trace_file_ptr(cache_ptr))) - HDfprintf(trace_file_ptr, - "%s %d %d %d %d \"%s\" %d %d %d %f %d %d %ld %d %f %f %d %f %f %d %d %d %f %f %d %d %d %d %f %zu %d %d\n", - "H5AC_set_cache_auto_resize_config", - trace_config.version, - (int)(trace_config.rpt_fcn_enabled), - (int)(trace_config.open_trace_file), - (int)(trace_config.close_trace_file), - trace_config.trace_file_name, - (int)(trace_config.evictions_enabled), - (int)(trace_config.set_initial_size), - (int)(trace_config.initial_size), - trace_config.min_clean_fraction, - (int)(trace_config.max_size), - (int)(trace_config.min_size), - trace_config.epoch_length, - (int)(trace_config.incr_mode), - trace_config.lower_hr_threshold, - trace_config.increment, - (int)(trace_config.flash_incr_mode), - trace_config.flash_multiple, - trace_config.flash_threshold, - (int)(trace_config.apply_max_increment), - (int)(trace_config.max_increment), - (int)(trace_config.decr_mode), - trace_config.upper_hr_threshold, - trace_config.decrement, - (int)(trace_config.apply_max_decrement), - (int)(trace_config.max_decrement), - trace_config.epochs_before_eviction, - (int)(trace_config.apply_empty_reserve), - trace_config.empty_reserve, - trace_config.dirty_bytes_threshold, - trace_config.metadata_write_strategy, - (int)ret_value); -#endif /* H5AC__TRACE_FILE_ENABLED */ - /* If currently logging, generate a message */ - if(curr_logging) - if(H5AC__write_set_cache_config_log_msg(cache_ptr, config_ptr, ret_value) < 0) - HDONE_ERROR(H5E_CACHE, H5E_LOGFAIL, FAIL, "unable to emit log message") + if(cache_ptr->log_info->logging) + if(H5C_log_write_set_cache_config_msg(cache_ptr, config_ptr, ret_value) < 0) + HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_set_cache_auto_resize_config() */ @@ -2366,12 +1929,12 @@ H5AC_validate_config(H5AC_cache_config_t *config_ptr) if(config_ptr->open_trace_file) { size_t name_len; - /* Can't really test the trace_file_name field without trying to - * open the file, so we will content ourselves with a couple of - * sanity checks on the length of the file name. - */ - name_len = HDstrlen(config_ptr->trace_file_name); - if(name_len == 0) + /* Can't really test the trace_file_name field without trying to + * open the file, so we will content ourselves with a couple of + * sanity checks on the length of the file name. + */ + name_len = HDstrlen(config_ptr->trace_file_name); + if(name_len == 0) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "config_ptr->trace_file_name is empty") else if(name_len > H5AC__MAX_TRACE_FILE_NAME_LEN) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "config_ptr->trace_file_name too long") @@ -3062,12 +2625,6 @@ H5AC_remove_entry(void *_entry) { H5AC_info_t *entry = (H5AC_info_t *)_entry; /* Entry to remove */ H5C_t *cache = NULL; /* Pointer to the entry's associated metadata cache */ -#if H5AC__TRACE_FILE_ENABLED - char trace[128] = ""; - FILE * trace_file_ptr = NULL; -#endif /* H5AC__TRACE_FILE_ENABLED */ - hbool_t log_enabled; /* TRUE if logging was set up */ - hbool_t curr_logging; /* TRUE if currently logging */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -3077,32 +2634,15 @@ H5AC_remove_entry(void *_entry) cache = entry->cache_ptr; HDassert(cache); -#if H5AC__TRACE_FILE_ENABLED - /* For the remove entry call, only the addr is really necessary - * in the trace file. Also write the result to catch occult errors. - */ - if(NULL != (trace_file_ptr = H5C_get_trace_file_ptr_from_entry(entry))) - sprintf(trace, "%s 0x%lx", FUNC, (unsigned long)(entry->addr)); -#endif /* H5AC__TRACE_FILE_ENABLED */ - - /* Check if log messages are being emitted */ - if(H5C_get_logging_status(cache, &log_enabled, &curr_logging) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, FAIL, "unable to get logging status") - /* Remove the entry from the cache*/ if(H5C_remove_entry(entry) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, "can't remove entry") done: -#if H5AC__TRACE_FILE_ENABLED - if(trace_file_ptr) - HDfprintf(trace_file_ptr, "%s %d\n", trace, (int)ret_value); -#endif /* H5AC__TRACE_FILE_ENABLED */ - /* If currently logging, generate a message */ - if(curr_logging) - if(H5AC__write_remove_entry_log_msg(cache, entry, ret_value) < 0) - HDONE_ERROR(H5E_CACHE, H5E_LOGFAIL, FAIL, "unable to emit log message") + if(cache->log_info->logging) + if(H5C_log_write_remove_entry_msg(cache, entry, ret_value) < 0) + HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_remove_entry() */ diff --git a/src/H5ACdbg.c b/src/H5ACdbg.c index c6d71a8..1235206 100644 --- a/src/H5ACdbg.c +++ b/src/H5ACdbg.c @@ -136,121 +136,6 @@ done: /*------------------------------------------------------------------------- - * Function: H5AC__close_trace_file() - * - * Purpose: If a trace file is open, stop logging calls to the cache, - * and close the file. - * - * Note that the function does nothing if there is no trace - * file. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: John Mainzer - * 6/2/06 - * - *------------------------------------------------------------------------- - */ -herr_t -H5AC__close_trace_file(H5AC_t *cache_ptr) -{ - FILE * trace_file_ptr; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE - - if(cache_ptr == NULL) - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "NULL cache_ptr on entry.") - - if(NULL == (trace_file_ptr = H5C_get_trace_file_ptr(cache_ptr))) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C_get_trace_file_ptr() failed.") - - if(trace_file_ptr != NULL) { - if(H5C_set_trace_file_ptr(cache_ptr, NULL) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C_set_trace_file_ptr() failed.") - - if(HDfclose(trace_file_ptr) != 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close metadata cache trace file") - } /* end if */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5AC__close_trace_file() */ - - -/*------------------------------------------------------------------------- - * Function: H5AC__open_trace_file() - * - * Purpose: Open a trace file, and start logging calls to the cache. - * - * This logging is done at the H5C level, and will only take - * place if H5C_TRACE_FILE_ENABLED (defined in H5Cprivate.h) - * is TRUE. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: John Mainzer - * 6/1/06 - * - *------------------------------------------------------------------------- - */ -herr_t -H5AC__open_trace_file(H5AC_t *cache_ptr, const char *trace_file_name) -{ - char file_name[H5AC__MAX_TRACE_FILE_NAME_LEN + H5C__PREFIX_LEN + 2]; - FILE * file_ptr; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE - - HDassert(cache_ptr); - - /* Check args */ - if(cache_ptr == NULL) - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "cache_ptr NULL on entry.") - if(trace_file_name == NULL) - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "NULL trace_file_name on entry.") - if(HDstrlen(trace_file_name) > H5AC__MAX_TRACE_FILE_NAME_LEN) - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "trace file name too long.") - if(NULL != (file_ptr = H5C_get_trace_file_ptr(cache_ptr))) - HGOTO_ERROR(H5E_CACHE, H5E_FILEOPEN, FAIL, "trace file already open.") - -#ifdef H5_HAVE_PARALLEL -{ - H5AC_aux_t * aux_ptr; - - aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); - if(aux_ptr == NULL) - sprintf(file_name, "%s", trace_file_name); - else { - if(aux_ptr->magic != H5AC__H5AC_AUX_T_MAGIC) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad aux_ptr->magic.") - - sprintf(file_name, "%s.%d", trace_file_name, aux_ptr->mpi_rank); - } /* end else */ - - if(HDstrlen(file_name) > H5AC__MAX_TRACE_FILE_NAME_LEN + H5C__PREFIX_LEN + 1) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "cooked trace file name too long.") -} -#else /* H5_HAVE_PARALLEL */ - HDsnprintf(file_name, (size_t)(H5AC__MAX_TRACE_FILE_NAME_LEN + H5C__PREFIX_LEN + 1), - "%s", trace_file_name); -#endif /* H5_HAVE_PARALLEL */ - - if((file_ptr = HDfopen(file_name, "w")) == NULL) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "trace file open failed.") - - HDfprintf(file_ptr, "### HDF5 metadata cache trace file version 1 ###\n"); - - if(H5C_set_trace_file_ptr(cache_ptr, file_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C_set_trace_file_ptr() failed.") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5AC__open_trace_file() */ - - -/*------------------------------------------------------------------------- * * Function: H5AC_get_entry_ptr_from_addr() * diff --git a/src/H5AClog.c b/src/H5AClog.c deleted file mode 100644 index 51a2050..0000000 --- a/src/H5AClog.c +++ /dev/null @@ -1,1105 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * 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 COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * - * If you do not have access to either file, you may request a copy from * - * help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/*------------------------------------------------------------------------- - * - * Created: H5AClog.c - * - * Purpose: Functions for metadata cache logging in JSON format - * - *------------------------------------------------------------------------- - */ - -/****************/ -/* Module Setup */ -/****************/ -#include "H5ACmodule.h" /* This source code file is part of the H5AC module */ - -/***********/ -/* Headers */ -/***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACpkg.h" /* Metadata cache */ -#include "H5Cprivate.h" /* Cache */ -#include "H5Eprivate.h" /* Error handling */ - - -/****************/ -/* Local Macros */ -/****************/ - -#define MSG_SIZE 128 - - -/******************/ -/* Local Typedefs */ -/******************/ - - -/********************/ -/* Package Typedefs */ -/********************/ - - -/********************/ -/* Local Prototypes */ -/********************/ - - -/*********************/ -/* Package Variables */ -/*********************/ - - -/*****************************/ -/* Library Private Variables */ -/*****************************/ - - -/*******************/ -/* Local Variables */ -/*******************/ - - - -/*------------------------------------------------------------------------- - * Function: H5AC__write_create_cache_log_msg - * - * Purpose: Write a log message for cache creation. - * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: Dana Robinson - * Sunday, March 16, 2014 - * - *------------------------------------------------------------------------- - */ -herr_t -H5AC__write_create_cache_log_msg(H5AC_t *cache) -{ - char msg[MSG_SIZE]; - hbool_t log_enabled; /* TRUE if logging was set up */ - hbool_t curr_logging; /* TRUE if currently logging */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity checks */ - HDassert(cache); - - /* Check if log messages are being emitted */ - if(H5C_get_logging_status(cache, &log_enabled, &curr_logging) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to get logging status") - - /* Since we're about to override the current logging flag, - * check the "log enabled" flag to see if we didn't get here - * by mistake. - */ - if(!log_enabled) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "attempt to write opening log message when logging is disabled") - - /* Create the log message string */ - HDsnprintf(msg, MSG_SIZE, -"\ -{\n\ -\"create_time\":%lld,\n\ -\"messages\":\n\ -[\n\ -" - , (long long)HDtime(NULL)); - - /* Have to temporarily enable logging, if it isn't currently */ - if(!curr_logging) - if(H5C_start_logging(cache) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_LOGFAIL, FAIL, "unable to start mdc logging") - - /* Write the log message to the file */ - if(H5C_write_log_message(cache, msg) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to emit log message") - - /* Stop logging, if it wasn't started originally */ - if(!curr_logging) - if(H5C_stop_logging(cache) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_LOGFAIL, FAIL, "unable to stop mdc logging") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5AC__write_create_cache_log_msg() */ - - -/*------------------------------------------------------------------------- - * Function: H5AC__write_destroy_cache_log_msg - * - * Purpose: Write a log message for cache destruction. - * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: Dana Robinson - * Sunday, March 16, 2014 - * - *------------------------------------------------------------------------- - */ -herr_t -H5AC__write_destroy_cache_log_msg(H5AC_t *cache) -{ - char msg[MSG_SIZE]; - hbool_t log_enabled; /* TRUE if logging was set up */ - hbool_t curr_logging; /* TRUE if currently logging */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity checks */ - HDassert(cache); - - /* Check if log messages are being emitted */ - if(H5C_get_logging_status(cache, &log_enabled, &curr_logging) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to get logging status") - - /* Since we're about to override the current logging flag, - * check the "log enabled" flag to see if we didn't get here - * by mistake. - */ - if(!log_enabled) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "attempt to write closing log message when logging is disabled") - - /* Create the log message string */ - HDsnprintf(msg, MSG_SIZE, -"\ -],\n\ -\"close_time\":%lld,\n\ -}\n\ -" - , (long long)HDtime(NULL)); - - /* Have to temporarily enable logging, if it isn't currently */ - if(!curr_logging) - if(H5C_start_logging(cache) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_LOGFAIL, FAIL, "unable to start mdc logging") - - /* Write the log message to the file */ - if(H5C_write_log_message(cache, msg) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to emit log message") - - /* Stop logging, if it wasn't started originally */ - if(!curr_logging) - if(H5C_stop_logging(cache) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_LOGFAIL, FAIL, "unable to stop mdc logging") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5AC__write_destroy_cache_log_msg() */ - - -/*------------------------------------------------------------------------- - * Function: H5AC__write_evict_cache_log_msg - * - * Purpose: Write a log message for eviction of cache entries. - * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: Dana Robinson - * Sunday, March 16, 2014 - * - *------------------------------------------------------------------------- - */ -herr_t -H5AC__write_evict_cache_log_msg(const H5AC_t *cache, - herr_t fxn_ret_value) -{ - char msg[MSG_SIZE]; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity checks */ - HDassert(cache); - - /* Create the log message string */ - HDsnprintf(msg, MSG_SIZE, -"\ -{\ -\"timestamp\":%lld,\ -\"action\":\"evict\",\ -\"returned\":%d\ -},\n\ -" - , (long long)HDtime(NULL), (int)fxn_ret_value); - - /* Write the log message to the file */ - if(H5C_write_log_message(cache, msg) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to emit log message") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5AC__write_evict_cache_log_msg() */ - - -/*------------------------------------------------------------------------- - * Function: H5AC__write_expunge_entry_log_msg - * - * Purpose: Write a log message for expunge of cache entries. - * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: Dana Robinson - * Sunday, March 16, 2014 - * - *------------------------------------------------------------------------- - */ -herr_t -H5AC__write_expunge_entry_log_msg(const H5AC_t *cache, - haddr_t address, - int type_id, - herr_t fxn_ret_value) -{ - char msg[MSG_SIZE]; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity checks */ - HDassert(cache); - - /* Create the log message string */ - HDsnprintf(msg, MSG_SIZE, -"\ -{\ -\"timestamp\":%lld,\ -\"action\":\"expunge\",\ -\"address\":0x%lx,\ -\"type_id\":%d,\ -\"returned\":%d\ -},\n\ -" - , (long long)HDtime(NULL), (unsigned long)address, (int)type_id, (int)fxn_ret_value); - - - /* Write the log message to the file */ - if(H5C_write_log_message(cache, msg) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to emit log message") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5AC__write_expunge_entry_log_msg() */ - - -/*------------------------------------------------------------------------- - * Function: H5AC__write_flush_cache_log_msg - * - * Purpose: Write a log message for cache flushes. - * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: Dana Robinson - * Sunday, March 16, 2014 - * - *------------------------------------------------------------------------- - */ -herr_t -H5AC__write_flush_cache_log_msg(const H5AC_t *cache, - herr_t fxn_ret_value) -{ - char msg[MSG_SIZE]; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity checks */ - HDassert(cache); - - /* Create the log message string */ - HDsnprintf(msg, MSG_SIZE, -"\ -{\ -\"timestamp\":%lld,\ -\"action\":\"flush\",\ -\"returned\":%d\ -},\n\ -" - , (long long)HDtime(NULL), (int)fxn_ret_value); - - /* Write the log message to the file */ - if(H5C_write_log_message(cache, msg) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to emit log message") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5AC__write_flush_cache_log_msg() */ - - -/*------------------------------------------------------------------------- - * Function: H5AC__write_insert_entry_log_msg - * - * Purpose: Write a log message for insertion of cache entries. - * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: Dana Robinson - * Sunday, March 16, 2014 - * - *------------------------------------------------------------------------- - */ -herr_t -H5AC__write_insert_entry_log_msg(const H5AC_t *cache, - haddr_t address, - int type_id, - unsigned flags, - size_t size, - herr_t fxn_ret_value) -{ - char msg[MSG_SIZE]; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity checks */ - HDassert(cache); - - - /* Create the log message string */ - HDsnprintf(msg, MSG_SIZE, -"\ -{\ -\"timestamp\":%lld,\ -\"action\":\"insert\",\ -\"address\":0x%lx,\ -\"flags\":0x%x,\ -\"type_id\":%d,\ -\"size\":%d,\ -\"returned\":%d\ -},\n\ -" - , (long long)HDtime(NULL), (unsigned long)address, flags, type_id, - (int)size, (int)fxn_ret_value); - - /* Write the log message to the file */ - if(H5C_write_log_message(cache, msg) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to emit log message") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5AC__write_insert_entry_log_msg() */ - - -/*------------------------------------------------------------------------- - * Function: H5AC__write_mark_dirty_entry_log_msg - * - * Purpose: Write a log message for marking cache entries as dirty. - * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: Dana Robinson - * Sunday, March 16, 2014 - * - *------------------------------------------------------------------------- - */ -herr_t -H5AC__write_mark_dirty_entry_log_msg(const H5AC_t *cache, - const H5AC_info_t *entry, - herr_t fxn_ret_value) -{ - char msg[MSG_SIZE]; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity checks */ - HDassert(cache); - HDassert(entry); - - /* Create the log message string */ - HDsnprintf(msg, MSG_SIZE, -"\ -{\ -\"timestamp\":%lld,\ -\"action\":\"dirty\",\ -\"address\":0x%lx,\ -\"returned\":%d\ -},\n\ -" - , (long long)HDtime(NULL), (unsigned long)entry->addr, (int)fxn_ret_value); - - /* Write the log message to the file */ - if(H5C_write_log_message(cache, msg) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to emit log message") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5AC__write_mark_dirty_entry_log_msg() */ - - -/*------------------------------------------------------------------------- - * Function: H5AC__write_mark_clean_entry_log_msg - * - * Purpose: Write a log message for marking cache entries as clean. - * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: Quincey Koziol - * Saturday, July 23, 2016 - * - *------------------------------------------------------------------------- - */ -herr_t -H5AC__write_mark_clean_entry_log_msg(const H5AC_t *cache, const H5AC_info_t *entry, - herr_t fxn_ret_value) -{ - char msg[MSG_SIZE]; /* Log message buffer */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity checks */ - HDassert(cache); - HDassert(entry); - - /* Create the log message string */ - HDsnprintf(msg, MSG_SIZE, -"\ -{\ -\"timestamp\":%lld,\ -\"action\":\"clean\",\ -\"address\":0x%lx,\ -\"returned\":%d\ -},\n\ -" - , (long long)HDtime(NULL), (unsigned long)entry->addr, (int)fxn_ret_value); - - /* Write the log message to the file */ - if(H5C_write_log_message(cache, msg) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to emit log message") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5AC__write_mark_clean_entry_log_msg() */ - - -/*------------------------------------------------------------------------- - * Function: H5AC__write_mark_unserialized_entry_log_msg - * - * Purpose: Write a log message for marking cache entries as unserialized. - * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: Quincey Koziol - * Thursday, December 22, 2016 - * - *------------------------------------------------------------------------- - */ -herr_t -H5AC__write_mark_unserialized_entry_log_msg(const H5AC_t *cache, - const H5AC_info_t *entry, - herr_t fxn_ret_value) -{ - char msg[MSG_SIZE]; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity checks */ - HDassert(cache); - HDassert(entry); - - /* Create the log message string */ - HDsnprintf(msg, MSG_SIZE, -"\ -{\ -\"timestamp\":%lld,\ -\"action\":\"unserialized\",\ -\"address\":0x%lx,\ -\"returned\":%d\ -},\n\ -" - , (long long)HDtime(NULL), (unsigned long)entry->addr, (int)fxn_ret_value); - - /* Write the log message to the file */ - if(H5C_write_log_message(cache, msg) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to emit log message") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5AC__write_mark_unserialized_entry_log_msg() */ - - -/*------------------------------------------------------------------------- - * Function: H5AC__write_mark_serialize_entry_log_msg - * - * Purpose: Write a log message for marking cache entries as serialize. - * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: Quincey Koziol - * Thursday, December 22, 2016 - * - *------------------------------------------------------------------------- - */ -herr_t -H5AC__write_mark_serialized_entry_log_msg(const H5AC_t *cache, const H5AC_info_t *entry, - herr_t fxn_ret_value) -{ - char msg[MSG_SIZE]; /* Log message buffer */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity checks */ - HDassert(cache); - HDassert(entry); - - /* Create the log message string */ - HDsnprintf(msg, MSG_SIZE, -"\ -{\ -\"timestamp\":%lld,\ -\"action\":\"serialized\",\ -\"address\":0x%lx,\ -\"returned\":%d\ -},\n\ -" - , (long long)HDtime(NULL), (unsigned long)entry->addr, (int)fxn_ret_value); - - /* Write the log message to the file */ - if(H5C_write_log_message(cache, msg) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to emit log message") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5AC__write_mark_serialized_entry_log_msg() */ - - -/*------------------------------------------------------------------------- - * Function: H5AC__write_move_entry_log_msg - * - * Purpose: Write a log message for moving a cache entry. - * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: Dana Robinson - * Sunday, March 16, 2014 - * - *------------------------------------------------------------------------- - */ -herr_t -H5AC__write_move_entry_log_msg(const H5AC_t *cache, - haddr_t old_addr, - haddr_t new_addr, - int type_id, - herr_t fxn_ret_value) -{ - char msg[MSG_SIZE]; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity checks */ - HDassert(cache); - - /* Create the log message string */ - HDsnprintf(msg, MSG_SIZE, -"\ -{\ -\"timestamp\":%lld,\ -\"action\":\"move\",\ -\"old_address\":0x%lx,\ -\"new_address\":0x%lx,\ -\"type_id\":%d,\ -\"returned\":%d\ -},\n\ -" - , (long long)HDtime(NULL), (unsigned long)old_addr, - (unsigned long)new_addr, type_id, (int)fxn_ret_value); - - /* Write the log message to the file */ - if(H5C_write_log_message(cache, msg) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to emit log message") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5AC__write_move_entry_log_msg() */ - - -/*------------------------------------------------------------------------- - * Function: H5AC__write_pin_entry_log_msg - * - * Purpose: Write a log message for pinning a cache entry. - * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: Dana Robinson - * Sunday, March 16, 2014 - * - *------------------------------------------------------------------------- - */ -herr_t -H5AC__write_pin_entry_log_msg(const H5AC_t *cache, - const H5AC_info_t *entry, - herr_t fxn_ret_value) -{ - char msg[MSG_SIZE]; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity checks */ - HDassert(cache); - HDassert(entry); - - /* Create the log message string */ - HDsnprintf(msg, MSG_SIZE, -"\ -{\ -\"timestamp\":%lld,\ -\"action\":\"pin\",\ -\"address\":0x%lx,\ -\"returned\":%d\ -},\n\ -" - , (long long)HDtime(NULL), (unsigned long)entry->addr, - (int)fxn_ret_value); - - /* Write the log message to the file */ - if(H5C_write_log_message(cache, msg) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to emit log message") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5AC__write_pin_entry_log_msg() */ - - -/*------------------------------------------------------------------------- - * Function: H5AC__write_create_fd_log_msg - * - * Purpose: Write a log message for creating a flush dependency between - * two cache entries. - * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: Dana Robinson - * Sunday, March 16, 2014 - * - *------------------------------------------------------------------------- - */ -herr_t -H5AC__write_create_fd_log_msg(const H5AC_t *cache, - const H5AC_info_t *parent, - const H5AC_info_t *child, - herr_t fxn_ret_value) -{ - char msg[MSG_SIZE]; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity checks */ - HDassert(cache); - HDassert(parent); - HDassert(child); - - /* Create the log message string */ - HDsnprintf(msg, MSG_SIZE, -"\ -{\ -\"timestamp\":%lld,\ -\"action\":\"create_fd\",\ -\"parent_addr\":0x%lx,\ -\"child_addr\":0x%lx,\ -\"returned\":%d\ -},\n\ -" - , (long long)HDtime(NULL), (unsigned long)parent->addr, - (unsigned long)child->addr, (int)fxn_ret_value); - - /* Write the log message to the file */ - if(H5C_write_log_message(cache, msg) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to emit log message") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5AC__write_create_fd_log_msg() */ - - -/*------------------------------------------------------------------------- - * Function: H5AC__write_protect_entry_log_msg - * - * Purpose: Write a log message for protecting a cache entry. - * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: Dana Robinson - * Sunday, March 16, 2014 - * - *------------------------------------------------------------------------- - */ -herr_t -H5AC__write_protect_entry_log_msg(const H5AC_t *cache, - const H5AC_info_t *entry, - unsigned flags, - herr_t fxn_ret_value) -{ - char msg[MSG_SIZE]; - char rw_s[16]; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity checks */ - HDassert(cache); - HDassert(entry); - - if(H5AC__READ_ONLY_FLAG == flags) - HDstrcpy(rw_s, "READ"); - else - HDstrcpy(rw_s, "WRITE"); - - /* Create the log message string */ - HDsnprintf(msg, MSG_SIZE, -"\ -{\ -\"timestamp\":%lld,\ -\"action\":\"protect\",\ -\"address\":0x%lx,\ -\"readwrite\":\"%s\",\ -\"size\":%d,\ -\"returned\":%d\ -},\n\ -" - , (long long)HDtime(NULL), (unsigned long)entry->addr, - rw_s, (int)entry->size, (int)fxn_ret_value); - - /* Write the log message to the file */ - if(H5C_write_log_message(cache, msg) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to emit log message") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5AC__write_protect_entry_log_msg() */ - - -/*------------------------------------------------------------------------- - * Function: H5AC__write_resize_entry_log_msg - * - * Purpose: Write a log message for resizing a cache entry. - * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: Dana Robinson - * Sunday, March 16, 2014 - * - *------------------------------------------------------------------------- - */ -herr_t -H5AC__write_resize_entry_log_msg(const H5AC_t *cache, - const H5AC_info_t *entry, - size_t new_size, - herr_t fxn_ret_value) -{ - char msg[MSG_SIZE]; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity checks */ - HDassert(cache); - HDassert(entry); - - /* Create the log message string */ - HDsnprintf(msg, MSG_SIZE, -"\ -{\ -\"timestamp\":%lld,\ -\"action\":\"resize\",\ -\"address\":0x%lx,\ -\"new_size\":%d,\ -\"returned\":%d\ -},\n\ -" - , (long long)HDtime(NULL), (unsigned long)entry->addr, - (int)new_size, (int)fxn_ret_value); - - /* Write the log message to the file */ - if(H5C_write_log_message(cache, msg) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to emit log message") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5AC__write_resize_entry_log_msg() */ - - -/*------------------------------------------------------------------------- - * Function: H5AC__write_unpin_entry_log_msg - * - * Purpose: Write a log message for unpinning a cache entry. - * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: Dana Robinson - * Sunday, March 16, 2014 - * - *------------------------------------------------------------------------- - */ -herr_t -H5AC__write_unpin_entry_log_msg(const H5AC_t *cache, - const H5AC_info_t *entry, - herr_t fxn_ret_value) -{ - char msg[MSG_SIZE]; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity checks */ - HDassert(cache); - HDassert(entry); - - /* Create the log message string */ - HDsnprintf(msg, MSG_SIZE, -"\ -{\ -\"timestamp\":%lld,\ -\"action\":\"unpin\",\ -\"address\":0x%lx,\ -\"returned\":%d\ -},\n\ -" - , (long long)HDtime(NULL), (unsigned long)entry->addr, - (int)fxn_ret_value); - - /* Write the log message to the file */ - if(H5C_write_log_message(cache, msg) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to emit log message") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5AC__write_unpin_entry_log_msg() */ - - -/*------------------------------------------------------------------------- - * Function: H5AC__write_destroy_fd_log_msg - * - * Purpose: Write a log message for destroying a flush dependency - * between two cache entries. - * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: Dana Robinson - * Sunday, March 16, 2014 - * - *------------------------------------------------------------------------- - */ -herr_t -H5AC__write_destroy_fd_log_msg(const H5AC_t *cache, - const H5AC_info_t *parent, - const H5AC_info_t *child, - herr_t fxn_ret_value) -{ - char msg[MSG_SIZE]; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity checks */ - HDassert(cache); - HDassert(parent); - HDassert(child); - - /* Create the log message string */ - HDsnprintf(msg, MSG_SIZE, -"\ -{\ -\"timestamp\":%lld,\ -\"action\":\"destroy_fd\",\ -\"parent_addr\":0x%lx,\ -\"child_addr\":0x%lx,\ -\"returned\":%d\ -},\n\ -" - , (long long)HDtime(NULL), (unsigned long)parent->addr, - (unsigned long)child->addr, (int)fxn_ret_value); - - /* Write the log message to the file */ - if(H5C_write_log_message(cache, msg) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to emit log message") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5AC__write_destroy_fd_log_msg() */ - - -/*------------------------------------------------------------------------- - * Function: H5AC__write_unprotect_entry_log_msg - * - * Purpose: Write a log message for unprotecting a cache entry. - * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: Dana Robinson - * Sunday, March 16, 2014 - * - *------------------------------------------------------------------------- - */ -herr_t -H5AC__write_unprotect_entry_log_msg(const H5AC_t *cache, - const H5AC_info_t *entry, - int type_id, - unsigned flags, - herr_t fxn_ret_value) -{ - char msg[MSG_SIZE]; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity checks */ - HDassert(cache); - HDassert(entry); - - /* Create the log message string */ - HDsnprintf(msg, MSG_SIZE, -"\ -{\ -\"timestamp\":%lld,\ -\"action\":\"unprotect\",\ -\"address\":0x%lx,\ -\"id\":%d,\ -\"flags\":%x,\ -\"returned\":%d\ -},\n\ -" - , (long long)HDtime(NULL), (unsigned long)entry->addr, - type_id, flags, (int)fxn_ret_value); - - HDsnprintf(msg, MSG_SIZE, " "); - - /* Write the log message to the file */ - if(H5C_write_log_message(cache, msg) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to emit log message") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5AC__write_unprotect_entry_log_msg() */ - - -/*------------------------------------------------------------------------- - * Function: H5AC__write_set_cache_config_log_msg - * - * Purpose: Write a log message for setting the cache configuration. - * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: Dana Robinson - * Sunday, March 16, 2014 - * - *------------------------------------------------------------------------- - */ -herr_t -H5AC__write_set_cache_config_log_msg(const H5AC_t *cache, - const H5AC_cache_config_t *config, - herr_t fxn_ret_value) -{ - char msg[MSG_SIZE]; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity checks */ - HDassert(cache); - HDassert(config); - - /* Create the log message string */ - HDsnprintf(msg, MSG_SIZE, -"\ -{\ -\"timestamp\":%lld,\ -\"action\":\"set_config\",\ -\"returned\":%d\ -},\n\ -" - , (long long)HDtime(NULL), (int)fxn_ret_value); - - - /* Write the log message to the file */ - if(H5C_write_log_message(cache, msg) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to emit log message") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5AC__write_set_cache_config_log_msg() */ - - -/*------------------------------------------------------------------------- - * Function: H5AC__write_remove_entry_log_msg - * - * Purpose: Write a log message for removing a cache entry. - * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: Quincey Koziol - * September 17, 2016 - * - *------------------------------------------------------------------------- - */ -herr_t -H5AC__write_remove_entry_log_msg(const H5AC_t *cache, const H5AC_info_t *entry, - herr_t fxn_ret_value) -{ - char msg[MSG_SIZE]; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity checks */ - HDassert(cache); - HDassert(entry); - - /* Create the log message string */ - HDsnprintf(msg, MSG_SIZE, -"\ -{\ -\"timestamp\":%lld,\ -\"action\":\"remove\",\ -\"address\":0x%lx,\ -\"returned\":%d\ -},\n\ -" - , (long long)HDtime(NULL), (unsigned long)entry->addr, - (int)fxn_ret_value); - - /* Write the log message to the file */ - if(H5C_write_log_message(cache, msg) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to emit log message") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5AC__write_remove_entry_log_msg() */ - diff --git a/src/H5ACpkg.h b/src/H5ACpkg.h index 9bf84bf..8997382 100644 --- a/src/H5ACpkg.h +++ b/src/H5ACpkg.h @@ -433,74 +433,5 @@ H5_DLL herr_t H5AC__set_write_done_callback(H5C_t * cache_ptr, void (* write_done)(void)); #endif /* H5_HAVE_PARALLEL */ -/* Trace file routines */ -H5_DLL herr_t H5AC__close_trace_file(H5AC_t *cache_ptr); -H5_DLL herr_t H5AC__open_trace_file(H5AC_t *cache_ptr, const char *trace_file_name); - -/* Cache logging routines */ -H5_DLL herr_t H5AC__write_create_cache_log_msg(H5AC_t *cache); -H5_DLL herr_t H5AC__write_destroy_cache_log_msg(H5AC_t *cache); -H5_DLL herr_t H5AC__write_evict_cache_log_msg(const H5AC_t *cache, - herr_t fxn_ret_value); -H5_DLL herr_t H5AC__write_expunge_entry_log_msg(const H5AC_t *cache, - haddr_t address, - int type_id, - herr_t fxn_ret_value); -H5_DLL herr_t H5AC__write_flush_cache_log_msg(const H5AC_t *cache, - herr_t fxn_ret_value); -H5_DLL herr_t H5AC__write_insert_entry_log_msg(const H5AC_t *cache, - haddr_t address, - int type_id, - unsigned flags, - size_t size, - herr_t fxn_ret_value); -H5_DLL herr_t H5AC__write_mark_dirty_entry_log_msg(const H5AC_t *cache, - const H5AC_info_t *entry, - herr_t fxn_ret_value); -H5_DLL herr_t H5AC__write_mark_clean_entry_log_msg(const H5AC_t *cache, - const H5AC_info_t *entry, herr_t fxn_ret_value); -H5_DLL herr_t H5AC__write_mark_unserialized_entry_log_msg(const H5AC_t *cache, - const H5AC_info_t *entry, herr_t fxn_ret_value); -H5_DLL herr_t H5AC__write_mark_serialized_entry_log_msg(const H5AC_t *cache, - const H5AC_info_t *entry, herr_t fxn_ret_value); -H5_DLL herr_t H5AC__write_move_entry_log_msg(const H5AC_t *cache, - haddr_t old_addr, - haddr_t new_addr, - int type_id, - herr_t fxn_ret_value); -H5_DLL herr_t H5AC__write_pin_entry_log_msg(const H5AC_t *cache, - const H5AC_info_t *entry, - herr_t fxn_ret_value); -H5_DLL herr_t H5AC__write_create_fd_log_msg(const H5AC_t *cache, - const H5AC_info_t *parent, - const H5AC_info_t *child, - herr_t fxn_ret_value); -H5_DLL herr_t H5AC__write_protect_entry_log_msg(const H5AC_t *cache, - const H5AC_info_t *entry, - unsigned flags, - herr_t fxn_ret_value); -H5_DLL herr_t H5AC__write_resize_entry_log_msg(const H5AC_t *cache, - const H5AC_info_t *entry, - size_t new_size, - herr_t fxn_ret_value); -H5_DLL herr_t H5AC__write_unpin_entry_log_msg(const H5AC_t *cache, - const H5AC_info_t *entry, - herr_t fxn_ret_value); -H5_DLL herr_t H5AC__write_destroy_fd_log_msg(const H5AC_t *cache, - const H5AC_info_t *parent, - const H5AC_info_t *child, - herr_t fxn_ret_value); -H5_DLL herr_t H5AC__write_unprotect_entry_log_msg(const H5AC_t *cache, - const H5AC_info_t *entry, - int type_id, - unsigned flags, - herr_t fxn_ret_value); -H5_DLL herr_t H5AC__write_set_cache_config_log_msg(const H5AC_t *cache, - const H5AC_cache_config_t *config, - herr_t fxn_ret_value); -H5_DLL herr_t H5AC__write_remove_entry_log_msg(const H5AC_t *cache, - const H5AC_info_t *entry, - herr_t fxn_ret_value); - #endif /* _H5ACpkg_H */ diff --git a/src/H5ACprivate.h b/src/H5ACprivate.h index 0e8620d..e1fdedf 100644 --- a/src/H5ACprivate.h +++ b/src/H5ACprivate.h @@ -35,12 +35,6 @@ #include "H5Pprivate.h" /* Property lists */ #include "H5SLprivate.h" /* Skip lists */ -#ifdef H5_METADATA_TRACE_FILE -#define H5AC__TRACE_FILE_ENABLED 1 -#else /* H5_METADATA_TRACE_FILE */ -#define H5AC__TRACE_FILE_ENABLED 0 -#endif /* H5_METADATA_TRACE_FILE */ - /* Global metadata tag values */ #define H5AC__INVALID_TAG (haddr_t)0 #define H5AC__IGNORE_TAG (haddr_t)1 diff --git a/src/H5Adense.c b/src/H5Adense.c index 5bed82d..021fa76 100644 --- a/src/H5Adense.c +++ b/src/H5Adense.c @@ -300,18 +300,49 @@ static herr_t H5A__dense_fnd_cb(const H5A_t *attr, hbool_t *took_ownership, void *_user_attr) { H5A_t const **user_attr = (H5A_t const **)_user_attr; /* User data from v2 B-tree attribute lookup */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_STATIC_NOERR + FUNC_ENTER_STATIC /* Check arguments */ HDassert(attr); HDassert(user_attr); + HDassert(took_ownership); + /* + * If there is an attribute already stored in "user_attr", + * we need to free the dynamially allocated spaces for the + * attribute, otherwise we got infinite loop closing library due to + * outstanding allocation. (HDFFV-10659) + * + * This callback is used by H5A__dense_remove() to close/free the + * attribute stored in "user_attr" (via H5O__msg_free_real()) after + * the attribute node is deleted from the name index v2 B-tree. + * The issue is: + * When deleting the attribute node from the B-tree, + * if the attribute is found in the intermediate B-tree nodes, + * which may be merged/redistributed, we need to free the dynamically + * allocated spaces for the intermediate decoded attribute. + */ + if(*user_attr != NULL) { + H5A_t *old_attr = *user_attr; + if(old_attr->shared) { + /* Free any dynamically allocated items */ + if(H5A__free(old_attr) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't release attribute info") + + /* Destroy shared attribute struct */ + old_attr->shared = H5FL_FREE(H5A_shared_t, old_attr->shared); + } /* end if */ + + old_attr = H5FL_FREE(H5A_t, old_attr); + } /* end if */ /* Take over attribute ownership */ *user_attr = attr; *took_ownership = TRUE; - FUNC_LEAVE_NOAPI(SUCCEED) +done: + FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_fnd_cb() */ diff --git a/src/H5Adeprec.c b/src/H5Adeprec.c index b43e41d..b438cd2 100644 --- a/src/H5Adeprec.c +++ b/src/H5Adeprec.c @@ -45,6 +45,8 @@ #include "H5Opkg.h" /* Object headers */ #include "H5VLprivate.h" /* Virtual object layer */ +#include "H5VLnative_private.h" /* Native VOL connector */ + /****************/ /* Local Macros */ @@ -343,7 +345,7 @@ H5Aget_num_attrs(hid_t loc_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid location identifier") /* Get the number of attributes for the object */ - if(H5VL_object_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_OBJECT_GET_INFO, &loc_params, &oinfo, H5O_INFO_ALL) < 0) + if(H5VL_object_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_OBJECT_GET_INFO, &loc_params, &oinfo, H5O_INFO_ALL) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, (-1), "unable to get attribute count for object") H5_CHECKED_ASSIGN(ret_value, int, oinfo.num_attrs, hsize_t); @@ -408,7 +410,7 @@ H5Aiterate1(hid_t loc_id, unsigned *attr_num, H5A_operator1_t op, void *op_data) HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, H5_ITER_ERROR, "invalid location identifier") /* Call attribute iteration routine */ - if((ret_value = H5VL_attr_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_ATTR_ITERATE_OLD, loc_id, attr_num, op, op_data)) < 0) + if((ret_value = H5VL_attr_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_ATTR_ITERATE_OLD, loc_id, attr_num, op, op_data)) < 0) HERROR(H5E_VOL, H5E_BADITER, "error iterating over attributes"); done: diff --git a/src/H5Apkg.h b/src/H5Apkg.h index cfe9dae..91061cd 100644 --- a/src/H5Apkg.h +++ b/src/H5Apkg.h @@ -155,21 +155,6 @@ typedef struct { H5A_t **attrs; /* Pointer to array of attribute pointers */ } H5A_attr_table_t; -/* Types for optional attribute VOL operations */ -typedef enum H5VL_attr_optional_t { - H5VL_ATTR_ITERATE_OLD /* H5Aiterate (deprecated routine) */ - /* (This enum value should have an - * "#ifndefH5_NO_DEPRECATED_SYMBOLS" - * around it, but the compiler - * complains about an empty enum - * when deprecated symbols are - * disabled currently. When - * another enum value is added, - * please put the #ifdef around - * this symbol. QAK - 2018/12/06 - */ -} H5VL_attr_optional_t; - /*****************************/ /* Package Private Variables */ diff --git a/src/H5Apublic.h b/src/H5Apublic.h index 586940b..7162f6e 100644 --- a/src/H5Apublic.h +++ b/src/H5Apublic.h @@ -22,10 +22,6 @@ #include "H5Opublic.h" /* Object Headers */ #include "H5Tpublic.h" /* Datatypes */ -#ifdef __cplusplus -extern "C" { -#endif - /* Information struct for attribute (for H5Aget_info/H5Aget_info_by_idx) */ typedef struct { hbool_t corder_valid; /* Indicate if creation order is valid */ @@ -38,7 +34,19 @@ typedef struct { typedef herr_t (*H5A_operator2_t)(hid_t location_id/*in*/, const char *attr_name/*in*/, const H5A_info_t *ainfo/*in*/, void *op_data/*in,out*/); -/* Public function prototypes */ + +/********************/ +/* Public Variables */ +/********************/ + + +/*********************/ +/* Public Prototypes */ +/*********************/ +#ifdef __cplusplus +extern "C" { +#endif + H5_DLL hid_t H5Acreate2(hid_t loc_id, const char *attr_name, hid_t type_id, hid_t space_id, hid_t acpl_id, hid_t aapl_id); H5_DLL hid_t H5Acreate_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, @@ -282,13 +282,8 @@ H5C_create(size_t max_cache_size, cache_ptr->flush_in_progress = FALSE; - cache_ptr->logging_enabled = FALSE; - - cache_ptr->currently_logging = FALSE; - - cache_ptr->log_file_ptr = NULL; - - cache_ptr->trace_file_ptr = NULL; + if(NULL == (cache_ptr->log_info = (H5C_log_info_t *)H5MM_calloc(sizeof(H5C_log_info_t)))) + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, NULL, "memory allocation failed") cache_ptr->aux_ptr = aux_ptr; @@ -493,6 +488,9 @@ done: if(cache_ptr->tag_list != NULL) H5SL_close(cache_ptr->tag_list); + if(cache_ptr->log_info != NULL) + H5MM_xfree(cache_ptr->log_info); + cache_ptr->magic = 0; cache_ptr = H5FL_FREE(H5C_t, cache_ptr); } /* end if */ @@ -865,6 +863,9 @@ H5C_dest(H5F_t * f) cache_ptr->tag_list = NULL; } /* end if */ + if(cache_ptr->log_info != NULL) + H5MM_xfree(cache_ptr->log_info); + #ifndef NDEBUG #if H5C_DO_SANITY_CHECKS if(cache_ptr->get_entry_ptr_from_addr_counter > 0) @@ -269,9 +269,11 @@ typedef struct H5CX_t { size_t nlinks; /* Number of soft / UD links to traverse (H5L_ACS_NLINKS_NAME) */ hbool_t nlinks_valid; /* Whether number of soft / UD links to traverse is valid */ - /* Cached VOL properties */ - void *vol_wrap_ctx; /* VOL plugin's "wrap context" for creating IDs */ - hbool_t vol_wrap_ctx_valid; /* Whether VOL plugin's "wrap context" for creating IDs is valid */ + /* Cached VOL settings */ + H5VL_connector_prop_t vol_connector_prop; /* Property for VOL connector ID & info */ + hbool_t vol_connector_prop_valid; /* Whether property for VOL connector ID & info is valid */ + void *vol_wrap_ctx; /* VOL connector's "wrap context" for creating IDs */ + hbool_t vol_wrap_ctx_valid; /* Whether VOL connector's "wrap context" for creating IDs is valid */ } H5CX_t; /* Typedef for nodes on the API context stack */ @@ -957,6 +959,40 @@ done: /*------------------------------------------------------------------------- + * Function: H5CX_set_vol_connector_prop + * + * Purpose: Sets the VOL connector ID & info for an operation. + * + * Return: Non-negative on success / Negative on failure + * + * Programmer: Quincey Koziol + * January 3, 2019 + * + *------------------------------------------------------------------------- + */ +herr_t +H5CX_set_vol_connector_prop(const H5VL_connector_prop_t *vol_connector_prop) +{ + H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity check */ + HDassert(head && *head); + + /* Set the API context value */ + HDmemcpy(&(*head)->ctx.vol_connector_prop, vol_connector_prop, sizeof(H5VL_connector_prop_t)); + + /* Mark the value as valid */ + (*head)->ctx.vol_connector_prop_valid = TRUE; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5CX_set_vol_connector_prop() */ + + +/*------------------------------------------------------------------------- * Function: H5CX_get_dxpl * * Purpose: Retrieves the DXPL ID for the current API call context. @@ -1045,6 +1081,42 @@ done: /*------------------------------------------------------------------------- + * Function: H5CX_get_vol_connector_prop + * + * Purpose: Retrieves the VOL connector ID & info for an operation. + * + * Return: Non-negative on success / Negative on failure + * + * Programmer: Quincey Koziol + * January 3, 2019 + * + *------------------------------------------------------------------------- + */ +herr_t +H5CX_get_vol_connector_prop(H5VL_connector_prop_t *vol_connector_prop) +{ + H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity check */ + HDassert(vol_connector_prop); + HDassert(head && *head); + + /* Check for value that was set */ + if((*head)->ctx.vol_connector_prop_valid) + /* Get the value */ + HDmemcpy(vol_connector_prop, &(*head)->ctx.vol_connector_prop, sizeof(H5VL_connector_prop_t)); + else + HDmemset(vol_connector_prop, 0, sizeof(H5VL_connector_prop_t)); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5CX_get_vol_connector_prop() */ + + +/*------------------------------------------------------------------------- * Function: H5CX_get_tag * * Purpose: Retrieves the object tag for the current API call context. diff --git a/src/H5CXprivate.h b/src/H5CXprivate.h index f93121c..22c6ebe 100644 --- a/src/H5CXprivate.h +++ b/src/H5CXprivate.h @@ -64,11 +64,13 @@ H5_DLL herr_t H5CX_set_apl(hid_t *acspl_id, const H5P_libclass_t *libclass, hid_t loc_id, hbool_t is_collective); H5_DLL herr_t H5CX_set_loc(hid_t loc_id); H5_DLL herr_t H5CX_set_vol_wrap_ctx(void *wrap_ctx); +H5_DLL herr_t H5CX_set_vol_connector_prop(const H5VL_connector_prop_t *vol_connector_prop); /* "Getter" routines for API context info */ H5_DLL hid_t H5CX_get_dxpl(void); H5_DLL hid_t H5CX_get_lapl(void); H5_DLL herr_t H5CX_get_vol_wrap_ctx(void **wrap_ctx); +H5_DLL herr_t H5CX_get_vol_connector_prop(H5VL_connector_prop_t *vol_connector_prop); H5_DLL haddr_t H5CX_get_tag(void); H5_DLL H5AC_ring_t H5CX_get_ring(void); #ifdef H5_HAVE_PARALLEL diff --git a/src/H5Cdbg.c b/src/H5Cdbg.c index 08c70d9..1f55e86 100644 --- a/src/H5Cdbg.c +++ b/src/H5Cdbg.c @@ -476,42 +476,6 @@ done: /*------------------------------------------------------------------------- - * Function: H5C_set_trace_file_ptr - * - * Purpose: Set the trace_file_ptr field for the cache. - * - * This field must either be NULL (which turns of trace - * file logging), or be a pointer to an open file to which - * trace file data is to be written. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: John Mainzer - * 1/20/06 - * - *------------------------------------------------------------------------- - */ -herr_t -H5C_set_trace_file_ptr(H5C_t * cache_ptr, FILE * trace_file_ptr) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* This would normally be an assert, but we need to use an HGOTO_ERROR - * call to shut up the compiler. - */ - if((NULL == cache_ptr) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad cache_ptr") - - cache_ptr->trace_file_ptr = trace_file_ptr; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C_set_trace_file_ptr() */ - - -/*------------------------------------------------------------------------- * Function: H5C_stats * * Purpose: Prints statistics about the cache. diff --git a/src/H5Clog.c b/src/H5Clog.c index 3353619..0ae7f13 100644 --- a/src/H5Clog.c +++ b/src/H5Clog.c @@ -13,11 +13,9 @@ /*------------------------------------------------------------------------- * - * Created: H5Clog.c - * May 30 2016 - * Quincey Koziol + * Created: H5Clog.c * - * Purpose: Functions for generic cache logging in JSON format + * Purpose: Functions for metadata cache logging * *------------------------------------------------------------------------- */ @@ -30,14 +28,12 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#ifdef H5_HAVE_PARALLEL -#define H5AC_FRIEND /*suppress error about including H5ACpkg */ -#include "H5ACpkg.h" /* Metadata cache */ -#endif /* H5_HAVE_PARALLEL */ -#include "H5Cpkg.h" /* Metadata cache */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5MMprivate.h" /* Memory management */ +#include "H5private.h" /* Generic Functions */ +#define H5AC_FRIEND /* Suppress error about including H5ACpkg */ +#include "H5ACpkg.h" /* Metadata cache */ +#include "H5Cpkg.h" /* Cache */ +#include "H5Clog.h" /* Cache logging */ +#include "H5Eprivate.h" /* Error handling */ /****************/ @@ -77,133 +73,109 @@ /*------------------------------------------------------------------------- - * Function: H5C_set_up_logging + * Function: H5C_log_set_up * * Purpose: Setup for metadata cache logging. * - * Metadata logging is enabled and disabled at two levels. This - * function and the associated tear_down function open and close - * the log file. the start_ and stop_logging functions are then - * used to switch logging on/off. Optionally, logging can begin - * as soon as the log file is opened (set via the start_immediately - * parameter to this function). - * - * The log functionality is split between the H5C and H5AC - * packages. Log state and direct log manipulation resides in - * H5C. Log messages are generated in H5AC and sent to - * the H5C_write_log_message function. + * Return: SUCCEED/FAIL * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Dana Robinson - * Sunday, March 16, 2014 + * Programmer: Dana Robinson + * Fall 2018 * *------------------------------------------------------------------------- */ herr_t -H5C_set_up_logging(H5C_t *cache_ptr, const char log_location[], - hbool_t start_immediately) +H5C_log_set_up(H5C_t *cache, const char log_location[], H5C_log_style_t style, hbool_t start_immediately) { -#ifdef H5_HAVE_PARALLEL - H5AC_aux_t *aux_ptr = NULL; -#endif /*H5_HAVE_PARALLEL*/ - char *file_name = NULL; - size_t n_chars; - herr_t ret_value = SUCCEED; /* Return value */ + int mpi_rank = -1; /* -1 indicates serial (no MPI rank) */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity checks */ - if(NULL == cache_ptr) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "cache_ptr == NULL") - if(H5C__H5C_T_MAGIC != cache_ptr->magic) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "cache magic value incorrect") - if(cache_ptr->logging_enabled) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "logging already set up") - if(NULL == log_location) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL log location not allowed") - - /* Possibly fix up the log file name. - * The extra 39 characters are for adding the rank to the file name - * under parallel HDF5. 39 characters allows > 2^127 processes which - * should be enough for anybody. - * - * allocation size = <path length> + dot + <rank # length> + \0 - */ - n_chars = HDstrlen(log_location) + 1 + 39 + 1; - if(NULL == (file_name = (char *)H5MM_calloc(n_chars * sizeof(char)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "can't allocate memory for mdc log file name manipulation") + HDassert(cache); + HDassert(log_location); + /* Check logging flags */ + if(cache->log_info->enabled) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "logging already set up") + + /* Get the rank when MPI is in use. Logging clients will usually + * use that to create per-process logs. + */ #ifdef H5_HAVE_PARALLEL - /* Add the rank to the log file name when MPI is in use */ - aux_ptr = (H5AC_aux_t *)(cache_ptr->aux_ptr); - - if(NULL == aux_ptr) - HDsnprintf(file_name, n_chars, "%s", log_location); - else { - if(aux_ptr->magic != H5AC__H5AC_AUX_T_MAGIC) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "bad aux_ptr->magic") - HDsnprintf(file_name, n_chars, "%s.%d", log_location, aux_ptr->mpi_rank); - } /* end else */ -#else /* H5_HAVE_PARALLEL */ - HDsnprintf(file_name, n_chars, "%s", log_location); -#endif /* H5_HAVE_PARALLEL */ - - /* Open log file */ - if(NULL == (cache_ptr->log_file_ptr = HDfopen(file_name, "w"))) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "can't create mdc log file") + if(NULL != cache->aux_ptr) + mpi_rank = ((H5AC_aux_t *)(cache->aux_ptr))->mpi_rank; +#endif /*H5_HAVE_PARALLEL*/ + + /* Set up logging */ + if(H5C_LOG_STYLE_JSON == style) { + if(H5C_log_json_set_up(cache->log_info, log_location, mpi_rank) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to set up json logging") + } + else if(H5C_LOG_STYLE_TRACE == style) { + if(H5C_log_trace_set_up(cache->log_info, log_location, mpi_rank) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to set up trace logging") + } + else + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unknown logging style") /* Set logging flags */ - cache_ptr->logging_enabled = TRUE; - cache_ptr->currently_logging = start_immediately; + cache->log_info->enabled = TRUE; + + /* Start logging if requested */ + if(start_immediately) + if(H5C_start_logging(cache) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to start logging") done: - if(file_name) - file_name = (char *)H5MM_xfree(file_name); FUNC_LEAVE_NOAPI(ret_value) -} /* H5C_set_up_logging() */ +} /* H5C_log_set_up() */ /*------------------------------------------------------------------------- - * Function: H5C_tear_down_logging + * Function: H5C_log_tear_down * * Purpose: Tear-down for metadata cache logging. * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * - * Programmer: Dana Robinson - * Sunday, March 16, 2014 + * Programmer: Dana Robinson + * Fall 2018 * *------------------------------------------------------------------------- */ herr_t -H5C_tear_down_logging(H5C_t *cache_ptr) +H5C_log_tear_down(H5C_t *cache) { herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity checks */ - if(NULL == cache_ptr) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "cache_ptr == NULL") - if(H5C__H5C_T_MAGIC != cache_ptr->magic) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "cache magic value incorrect") - if(FALSE == cache_ptr->logging_enabled) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "logging not enabled") + HDassert(cache); - /* Unset logging flags */ - cache_ptr->logging_enabled = FALSE; - cache_ptr->currently_logging = FALSE; + /* Check logging flags */ + if(FALSE == cache->log_info->enabled) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "logging not enabled") - /* Close log file */ - if(EOF == HDfclose(cache_ptr->log_file_ptr)) - HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "problem closing mdc log file") - cache_ptr->log_file_ptr = NULL; + /* Stop logging if that's going on */ + if(cache->log_info->logging) + if(H5C_stop_logging(cache) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to stop logging") + + /* Tear down logging */ + if(cache->log_info->cls->tear_down_logging) + if(cache->log_info->cls->tear_down_logging(cache->log_info) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific tear down call failed") + + /* Unset logging flags */ + cache->log_info->enabled = FALSE; done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5C_tear_down_logging() */ +} /* H5C_log_tear_down() */ /*------------------------------------------------------------------------- @@ -211,37 +183,39 @@ H5C_tear_down_logging(H5C_t *cache_ptr) * * Purpose: Start logging metadata cache operations. * - * TODO: Add a function that dumps the current state of the - * metadata cache. + * Return: SUCCEED/FAIL * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Dana Robinson - * Sunday, March 16, 2014 + * Programmer: Dana Robinson + * Fall 2018 * *------------------------------------------------------------------------- */ herr_t -H5C_start_logging(H5C_t *cache_ptr) +H5C_start_logging(H5C_t *cache) { herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity checks */ - if(NULL == cache_ptr) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "cache_ptr == NULL") - if(H5C__H5C_T_MAGIC != cache_ptr->magic) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "cache magic value incorrect") - if(FALSE == cache_ptr->logging_enabled) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "logging not enabled") - if(cache_ptr->currently_logging) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "logging already in progress") + HDassert(cache); + + /* Check logging flags */ + if(FALSE == cache->log_info->enabled) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "logging not enabled") + + /* Start logging */ + if(cache->log_info->cls->start_logging) + if(cache->log_info->cls->start_logging(cache->log_info) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific start call failed") /* Set logging flags */ - cache_ptr->currently_logging = TRUE; + cache->log_info->logging = TRUE; - /* TODO - Dump cache state */ + /* Write a log message */ + if(cache->log_info->cls->write_start_log_msg) + if(cache->log_info->cls->write_start_log_msg(cache->log_info->udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific write start call failed") done: FUNC_LEAVE_NOAPI(ret_value) @@ -253,32 +227,41 @@ H5C_start_logging(H5C_t *cache_ptr) * * Purpose: Stop logging metadata cache operations. * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * - * Programmer: Dana Robinson - * Sunday, March 16, 2014 + * Programmer: Dana Robinson + * Fall 2018 * *------------------------------------------------------------------------- */ herr_t -H5C_stop_logging(H5C_t *cache_ptr) +H5C_stop_logging(H5C_t *cache) { herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity checks */ - if(NULL == cache_ptr) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "cache_ptr == NULL") - if(H5C__H5C_T_MAGIC != cache_ptr->magic) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "cache magic value incorrect") - if(FALSE == cache_ptr->logging_enabled) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "logging not enabled") - if(FALSE == cache_ptr->currently_logging) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "logging not in progress") + HDassert(cache); + + /* Check logging flags */ + if(FALSE == cache->log_info->enabled) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "logging not enabled") + if(FALSE == cache->log_info->logging) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "logging not in progress") + + /* Write a log message */ + if(cache->log_info->cls->write_stop_log_msg) + if(cache->log_info->cls->write_stop_log_msg(cache->log_info->udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific write stop call failed") + + /* Stop logging */ + if(cache->log_info->cls->stop_logging) + if(cache->log_info->cls->stop_logging(cache->log_info) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific stop call failed") /* Set logging flags */ - cache_ptr->currently_logging = FALSE; + cache->log_info->logging = FALSE; done: FUNC_LEAVE_NOAPI(ret_value) @@ -289,80 +272,706 @@ H5C_stop_logging(H5C_t *cache_ptr) * Function: H5C_get_logging_status * * Purpose: Determines if the cache is actively logging (via the OUT - * parameter). + * parameters). * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * - * Programmer: Dana Robinson - * Sunday, March 16, 2014 + * Programmer: Dana Robinson + * Fall 2018 * *------------------------------------------------------------------------- */ herr_t -H5C_get_logging_status(const H5C_t *cache_ptr, /*OUT*/ hbool_t *is_enabled, +H5C_get_logging_status(const H5C_t *cache, /*OUT*/ hbool_t *is_enabled, /*OUT*/ hbool_t *is_currently_logging) { - herr_t ret_value = SUCCEED; /* Return value */ + FUNC_ENTER_NOAPI_NOERR + + /* Sanity checks */ + HDassert(cache); + HDassert(is_enabled); + HDassert(is_currently_logging); + + /* Get logging flags */ + *is_enabled = cache->log_info->enabled; + *is_currently_logging = cache->log_info->logging; + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* H5C_get_logging_status() */ + + +/*------------------------------------------------------------------------- + * Function: H5C_log_write_create_cache_msg + * + * Purpose: Write a log message for cache creation. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +herr_t +H5C_log_write_create_cache_msg(H5C_t *cache, herr_t fxn_ret_value) +{ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity checks */ - if(NULL == cache_ptr) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "cache_ptr == NULL") - if(H5C__H5C_T_MAGIC != cache_ptr->magic) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "cache magic value incorrect") - if(NULL == is_enabled) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "cache magic value incorrect") - if(NULL == is_currently_logging) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "cache magic value incorrect") - - *is_enabled = cache_ptr->logging_enabled; - *is_currently_logging = cache_ptr->currently_logging; + HDassert(cache); + + /* Write a log message */ + if(cache->log_info->cls->write_create_cache_log_msg) + if(cache->log_info->cls->write_create_cache_log_msg(cache->log_info->udata, fxn_ret_value) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific write create cache call failed") done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5C_get_logging_status() */ +} /* H5C_log_write_create_cache_msg() */ + +/*------------------------------------------------------------------------- + * Function: H5C_log_write_destroy_cache_msg + * + * Purpose: Write a log message for cache destruction. + * + * NOTE: This can't print out the H5AC call return value, since we + * won't know that until the cache is destroyed and at that + * point we no longer have pointers to the logging information. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +herr_t +H5C_log_write_destroy_cache_msg(H5C_t *cache) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(cache); + + /* Write a log message */ + if(cache->log_info->cls->write_destroy_cache_log_msg) + if(cache->log_info->cls->write_destroy_cache_log_msg(cache->log_info->udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific write destroy cache call failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C_log_write_destroy_cache_msg() */ /*------------------------------------------------------------------------- - * Function: H5C_write_log_message + * Function: H5C_log_write_evict_cache_msg * - * Purpose: Write a message to the log file and flush the file. - * The message string is neither modified nor freed. + * Purpose: Write a log message for eviction of cache entries. * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * - * Programmer: Dana Robinson - * Sunday, March 16, 2014 + * Programmer: Dana Robinson + * Fall 2018 * *------------------------------------------------------------------------- */ herr_t -H5C_write_log_message(const H5C_t *cache_ptr, const char message[]) +H5C_log_write_evict_cache_msg(H5C_t *cache, herr_t fxn_ret_value) { - size_t n_chars; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(cache); + + /* Write a log message */ + if(cache->log_info->cls->write_evict_cache_log_msg) + if(cache->log_info->cls->write_evict_cache_log_msg(cache->log_info->udata, fxn_ret_value) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific write evict cache call failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C_log_write_evict_cache_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C_log_write_expunge_entry_msg + * + * Purpose: Write a log message for expunge of cache entries. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +herr_t +H5C_log_write_expunge_entry_msg(H5C_t *cache, haddr_t address, + int type_id, herr_t fxn_ret_value) +{ + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) /* Sanity checks */ - if(NULL == cache_ptr) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "cache_ptr == NULL") - if(H5C__H5C_T_MAGIC != cache_ptr->magic) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "cache magic value incorrect") - if(FALSE == cache_ptr->currently_logging) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "not currently logging") - if(NULL == message) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL log message not allowed") - - /* Write the log message and flush */ - n_chars = HDstrlen(message); - if((int)n_chars != HDfprintf(cache_ptr->log_file_ptr, message)) - HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "error writing log message") - if(EOF == HDfflush(cache_ptr->log_file_ptr)) - HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "error flushing log message") + HDassert(cache); + + /* Write a log message */ + if(cache->log_info->cls->write_expunge_entry_log_msg) + if(cache->log_info->cls->write_expunge_entry_log_msg(cache->log_info->udata, address, type_id, fxn_ret_value) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific write expunge entry call failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C_log_write_expunge_entry_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C_log_write_flush_cache_msg + * + * Purpose: Write a log message for cache flushes. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +herr_t +H5C_log_write_flush_cache_msg(H5C_t *cache, herr_t fxn_ret_value) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(cache); + + /* Write a log message */ + if(cache->log_info->cls->write_flush_cache_log_msg) + if(cache->log_info->cls->write_flush_cache_log_msg(cache->log_info->udata, fxn_ret_value) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific flush cache call failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C_log_write_flush_cache_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C_log_write_insert_entry_msg + * + * Purpose: Write a log message for insertion of cache entries. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +herr_t +H5C_log_write_insert_entry_msg(H5C_t *cache, haddr_t address, + int type_id, unsigned flags, size_t size, herr_t fxn_ret_value) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(cache); + + /* Write a log message */ + if(cache->log_info->cls->write_insert_entry_log_msg) + if(cache->log_info->cls->write_insert_entry_log_msg(cache->log_info->udata, address, type_id, flags, size, fxn_ret_value) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific insert entry call failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C_log_write_insert_entry_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C_log_write_mark_entry_dirty_msg + * + * Purpose: Write a log message for marking cache entries as dirty. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +herr_t +H5C_log_write_mark_entry_dirty_msg(H5C_t *cache, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(cache); + + /* Write a log message */ + HDassert(entry); + if(cache->log_info->cls->write_mark_entry_dirty_log_msg) + if(cache->log_info->cls->write_mark_entry_dirty_log_msg(cache->log_info->udata, entry, fxn_ret_value) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific mark dirty entry call failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C_log_write_mark_entry_dirty_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C_log_write_mark_entry_clean_msg + * + * Purpose: Write a log message for marking cache entries as clean. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +herr_t +H5C_log_write_mark_entry_clean_msg(H5C_t *cache, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(cache); + + /* Write a log message */ + HDassert(entry); + if(cache->log_info->cls->write_mark_entry_clean_log_msg) + if(cache->log_info->cls->write_mark_entry_clean_log_msg(cache->log_info->udata, entry, fxn_ret_value) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific mark clean entry call failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C_log_write_mark_entry_clean_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C_log_write_mark_unserialized_entry_msg + * + * Purpose: Write a log message for marking cache entries as unserialized. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +herr_t +H5C_log_write_mark_unserialized_entry_msg(H5C_t *cache, + const H5C_cache_entry_t *entry, herr_t fxn_ret_value) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(cache); + + /* Write a log message */ + HDassert(entry); + if(cache->log_info->cls->write_mark_unserialized_entry_log_msg) + if(cache->log_info->cls->write_mark_unserialized_entry_log_msg(cache->log_info->udata, entry, fxn_ret_value) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific mark unserialized entry call failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C_log_write_mark_unserialized_entry_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C_log_write_mark_serialized_entry_msg + * + * Purpose: Write a log message for marking cache entries as serialize. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +herr_t +H5C_log_write_mark_serialized_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(cache); + + /* Write a log message */ + HDassert(entry); + if(cache->log_info->cls->write_mark_serialized_entry_log_msg) + if(cache->log_info->cls->write_mark_serialized_entry_log_msg(cache->log_info->udata, entry, fxn_ret_value) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific mark serialized entry call failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C_log_write_mark_serialized_entry_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C_log_write_move_entry_msg + * + * Purpose: Write a log message for moving a cache entry. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +herr_t +H5C_log_write_move_entry_msg(H5C_t *cache, haddr_t old_addr, haddr_t new_addr, + int type_id, herr_t fxn_ret_value) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(cache); + + /* Write a log message */ + if(cache->log_info->cls->write_move_entry_log_msg) + if(cache->log_info->cls->write_move_entry_log_msg(cache->log_info->udata, old_addr, new_addr, type_id, fxn_ret_value) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific move entry call failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C_log_write_move_entry_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C_log_write_pin_entry_msg + * + * Purpose: Write a log message for pinning a cache entry. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +herr_t +H5C_log_write_pin_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(cache); + + /* Write a log message */ + HDassert(entry); + if(cache->log_info->cls->write_pin_entry_log_msg) + if(cache->log_info->cls->write_pin_entry_log_msg(cache->log_info->udata, entry, fxn_ret_value) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific pin entry call failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C_log_write_pin_entry_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C_log_write_create_fd_msg + * + * Purpose: Write a log message for creating a flush dependency between + * two cache entries. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +herr_t +H5C_log_write_create_fd_msg(H5C_t *cache, const H5C_cache_entry_t *parent, + const H5C_cache_entry_t *child, herr_t fxn_ret_value) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(cache); + + /* Write a log message */ + HDassert(parent); + HDassert(child); + if(cache->log_info->cls->write_create_fd_log_msg) + if(cache->log_info->cls->write_create_fd_log_msg(cache->log_info->udata, parent, child, fxn_ret_value) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific create fd call failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C_log_write_create_fd_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C_log_write_protect_entry_msg + * + * Purpose: Write a log message for protecting a cache entry. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +herr_t +H5C_log_write_protect_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, + int type_id, unsigned flags, herr_t fxn_ret_value) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(cache); + + /* Write a log message */ + HDassert(entry); + if(cache->log_info->cls->write_protect_entry_log_msg) + if(cache->log_info->cls->write_protect_entry_log_msg(cache->log_info->udata, entry, type_id, flags, fxn_ret_value) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific protect entry call failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C_log_write_protect_entry_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C_log_write_resize_entry_msg + * + * Purpose: Write a log message for resizing a cache entry. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +herr_t +H5C_log_write_resize_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, + size_t new_size, herr_t fxn_ret_value) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(cache); + + /* Write a log message */ + HDassert(entry); + if(cache->log_info->cls->write_resize_entry_log_msg) + if(cache->log_info->cls->write_resize_entry_log_msg(cache->log_info->udata, entry, new_size, fxn_ret_value) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific resize entry call failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C_log_write_resize_entry_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C_log_write_unpin_entry_msg + * + * Purpose: Write a log message for unpinning a cache entry. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +herr_t +H5C_log_write_unpin_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(cache); + + /* Write a log message */ + HDassert(entry); + if(cache->log_info->cls->write_unpin_entry_log_msg) + if(cache->log_info->cls->write_unpin_entry_log_msg(cache->log_info->udata, entry, fxn_ret_value) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific unpin entry call failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C_log_write_unpin_entry_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C_log_write_destroy_fd_msg + * + * Purpose: Write a log message for destroying a flush dependency + * between two cache entries. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +herr_t +H5C_log_write_destroy_fd_msg(H5C_t *cache, const H5C_cache_entry_t *parent, + const H5C_cache_entry_t *child, herr_t fxn_ret_value) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(cache); + + /* Write a log message */ + HDassert(parent); + HDassert(child); + if(cache->log_info->cls->write_destroy_fd_log_msg) + if(cache->log_info->cls->write_destroy_fd_log_msg(cache->log_info->udata, parent, child, fxn_ret_value) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific destroy fd call failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C_log_write_destroy_fd_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C_log_write_unprotect_entry_msg + * + * Purpose: Write a log message for unprotecting a cache entry. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +herr_t +H5C_log_write_unprotect_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, + int type_id, unsigned flags, herr_t fxn_ret_value) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(cache); + + /* Write a log message */ + HDassert(entry); + if(cache->log_info->cls->write_unprotect_entry_log_msg) + if(cache->log_info->cls->write_unprotect_entry_log_msg(cache->log_info->udata, entry, type_id, flags, fxn_ret_value) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific unprotect entry call failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C_log_write_unprotect_entry_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C_log_write_set_cache_config_msg + * + * Purpose: Write a log message for setting the cache configuration. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +herr_t +H5C_log_write_set_cache_config_msg(H5C_t *cache, const H5AC_cache_config_t *config, + herr_t fxn_ret_value) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(cache); + + /* Write a log message */ + HDassert(config); + if(cache->log_info->cls->write_set_cache_config_log_msg) + if(cache->log_info->cls->write_set_cache_config_log_msg(cache->log_info->udata, config, fxn_ret_value) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific set cache config call failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C_log_write_set_cache_config_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C_log_write_remove_entry_msg + * + * Purpose: Write a log message for removing a cache entry. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +herr_t +H5C_log_write_remove_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(cache); + + /* Write a log message */ + HDassert(entry); + if(cache->log_info->cls->write_remove_entry_log_msg) + if(cache->log_info->cls->write_remove_entry_log_msg(cache->log_info->udata, entry, fxn_ret_value) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific remove entry call failed") done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5C_write_log_message() */ +} /* H5C_log_write_remove_entry_msg() */ diff --git a/src/H5Clog.h b/src/H5Clog.h new file mode 100644 index 0000000..9ba6786 --- /dev/null +++ b/src/H5Clog.h @@ -0,0 +1,114 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: Cache logging header file + */ + +#ifndef _H5Clog_H +#define _H5Clog_H + +/* Get package's private header */ +#include "H5Cprivate.h" /* Cache */ + +/**************************/ +/* Package Private Macros */ +/**************************/ + +/****************************/ +/* Package Private Typedefs */ +/****************************/ + +/* Forward declaration for class struct */ +typedef struct H5C_log_info_t H5C_log_info_t; + +/* Class for generating logging messages */ +typedef struct H5C_log_class_t { + const char *name; /* String for debugging */ + + /* Callbacks for writing log messages */ + herr_t (*tear_down_logging)(H5C_log_info_t *log_info); + herr_t (*start_logging)(H5C_log_info_t *log_info); + herr_t (*stop_logging)(H5C_log_info_t *log_info); + herr_t (*write_start_log_msg)(void *udata); + herr_t (*write_stop_log_msg)(void *udata); + herr_t (*write_create_cache_log_msg)(void *udata, herr_t fxn_ret_value); + herr_t (*write_destroy_cache_log_msg)(void *udata); + herr_t (*write_evict_cache_log_msg)(void *udata, herr_t fxn_ret_value); + herr_t (*write_expunge_entry_log_msg)(void *udata, haddr_t address, int type_id, herr_t fxn_ret_value); + herr_t (*write_flush_cache_log_msg)(void *udata, herr_t fxn_ret_value); + herr_t (*write_insert_entry_log_msg)(void *udata, haddr_t address, int type_id, unsigned flags, size_t size, herr_t fxn_ret_value); + herr_t (*write_mark_entry_dirty_log_msg)(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); + herr_t (*write_mark_entry_clean_log_msg)(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); + herr_t (*write_mark_unserialized_entry_log_msg)(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); + herr_t (*write_mark_serialized_entry_log_msg)(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); + herr_t (*write_move_entry_log_msg)(void *udata, haddr_t old_addr, haddr_t new_addr, int type_id, herr_t fxn_ret_value); + herr_t (*write_pin_entry_log_msg)(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); + herr_t (*write_create_fd_log_msg)(void *udata, const H5C_cache_entry_t *parent, const H5C_cache_entry_t *child, herr_t fxn_ret_value); + herr_t (*write_protect_entry_log_msg)(void *udata, const H5C_cache_entry_t *entry, int type_id, unsigned flags, herr_t fxn_ret_value); + herr_t (*write_resize_entry_log_msg)(void *udata, const H5C_cache_entry_t *entry, size_t new_size, herr_t fxn_ret_value); + herr_t (*write_unpin_entry_log_msg)(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); + herr_t (*write_destroy_fd_log_msg)(void *udata, const H5C_cache_entry_t *parent, const H5C_cache_entry_t *child, herr_t fxn_ret_value); + herr_t (*write_unprotect_entry_log_msg)(void *udata, const H5C_cache_entry_t *entry, int type_id, unsigned flags, herr_t fxn_ret_value); + herr_t (*write_set_cache_config_log_msg)(void *udata, const H5AC_cache_config_t *config, herr_t fxn_ret_value); + herr_t (*write_remove_entry_log_msg)(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); + +} H5C_log_class_t; + +/* Logging information */ +struct H5C_log_info_t { + hbool_t enabled; /* Was the logging set up? */ + hbool_t logging; /* Are we currently logging? */ + H5C_log_class_t *cls; /* Callbacks for writing log messages */ + void *udata; /* Log-specific data */ +}; + + +/*****************************/ +/* Package Private Variables */ +/*****************************/ + + +/******************************/ +/* Package Private Prototypes */ +/******************************/ +H5_DLL herr_t H5C_log_set_up(H5C_t *cache, const char log_location[], H5C_log_style_t style, hbool_t start_immediately); +H5_DLL herr_t H5C_log_tear_down(H5C_t *cache); + +H5_DLL herr_t H5C_log_write_create_cache_msg(H5C_t *cache, herr_t fxn_ret_value); +H5_DLL herr_t H5C_log_write_destroy_cache_msg(H5C_t *cache); +H5_DLL herr_t H5C_log_write_evict_cache_msg(H5C_t *cache, herr_t fxn_ret_value); +H5_DLL herr_t H5C_log_write_expunge_entry_msg(H5C_t *cache, haddr_t address, int type_id, herr_t fxn_ret_value); +H5_DLL herr_t H5C_log_write_flush_cache_msg(H5C_t *cache, herr_t fxn_ret_value); +H5_DLL herr_t H5C_log_write_insert_entry_msg(H5C_t *cache, haddr_t address, int type_id, unsigned flags, size_t size, herr_t fxn_ret_value); +H5_DLL herr_t H5C_log_write_mark_entry_dirty_msg(H5C_t *cache, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); +H5_DLL herr_t H5C_log_write_mark_entry_clean_msg(H5C_t *cache, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); +H5_DLL herr_t H5C_log_write_mark_unserialized_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); +H5_DLL herr_t H5C_log_write_mark_serialized_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); +H5_DLL herr_t H5C_log_write_move_entry_msg(H5C_t *cache, haddr_t old_addr, haddr_t new_addr, int type_id, herr_t fxn_ret_value); +H5_DLL herr_t H5C_log_write_pin_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); +H5_DLL herr_t H5C_log_write_create_fd_msg(H5C_t *cache, const H5C_cache_entry_t *parent, const H5C_cache_entry_t *child, herr_t fxn_ret_value); +H5_DLL herr_t H5C_log_write_protect_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, int type_id, unsigned flags, herr_t fxn_ret_value); +H5_DLL herr_t H5C_log_write_resize_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, size_t new_size, herr_t fxn_ret_value); +H5_DLL herr_t H5C_log_write_unpin_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); +H5_DLL herr_t H5C_log_write_destroy_fd_msg(H5C_t *cache, const H5C_cache_entry_t *parent, const H5C_cache_entry_t *child, herr_t fxn_ret_value); +H5_DLL herr_t H5C_log_write_unprotect_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, int type_id, unsigned flags, herr_t fxn_ret_value); +H5_DLL herr_t H5C_log_write_set_cache_config_msg(H5C_t *cache, const H5AC_cache_config_t *config, herr_t fxn_ret_value); +H5_DLL herr_t H5C_log_write_remove_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); + +/* Logging-specific setup functions */ +H5_DLL herr_t H5C_log_json_set_up(H5C_log_info_t *log_info, const char log_location[], int mpi_rank); +H5_DLL herr_t H5C_log_trace_set_up(H5C_log_info_t *log_info, const char log_location[], int mpi_rank); + +#endif /* _H5Clog_H */ + diff --git a/src/H5Clog_json.c b/src/H5Clog_json.c new file mode 100644 index 0000000..ccfa222 --- /dev/null +++ b/src/H5Clog_json.c @@ -0,0 +1,1365 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/*------------------------------------------------------------------------- + * + * Created: H5Clog_json.c + * + * Purpose: Cache log implementation that emits JSON-formatted log + * entries for consumption by new-fangled data analysis tools. + * + *------------------------------------------------------------------------- + */ + +/****************/ +/* Module Setup */ +/****************/ +#include "H5Cmodule.h" /* This source code file is part of the H5C module */ + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5Cpkg.h" /* Cache */ +#include "H5Clog.h" /* Cache logging */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5MMprivate.h" /* Memory management */ + + +/****************/ +/* Local Macros */ +/****************/ + +/* Max log message size */ +#define H5C_MAX_JSON_LOG_MSG_SIZE 128 + + +/******************/ +/* Local Typedefs */ +/******************/ + + +/********************/ +/* Package Typedefs */ +/********************/ + +typedef struct H5C_log_json_udata_t { + FILE *outfile; + char *message; +} H5C_log_json_udata_t; + + +/********************/ +/* Local Prototypes */ +/********************/ + +/* Internal message handling calls */ +static herr_t H5C__json_write_log_message(H5C_log_json_udata_t *json_udata); + +/* Log message callbacks */ +static herr_t H5C__json_tear_down_logging(H5C_log_info_t *log_info); +static herr_t H5C__json_write_start_log_msg(void *udata); +static herr_t H5C__json_write_stop_log_msg(void *udata); +static herr_t H5C__json_write_create_cache_log_msg(void *udata, herr_t fxn_ret_value); +static herr_t H5C__json_write_destroy_cache_log_msg(void *udata); +static herr_t H5C__json_write_evict_cache_log_msg(void *udata, herr_t fxn_ret_value); +static herr_t H5C__json_write_expunge_entry_log_msg(void *udata, haddr_t address, int type_id, herr_t fxn_ret_value); +static herr_t H5C__json_write_flush_cache_log_msg(void *udata, herr_t fxn_ret_value); +static herr_t H5C__json_write_insert_entry_log_msg(void *udata, haddr_t address, int type_id, unsigned flags, size_t size, herr_t fxn_ret_value); +static herr_t H5C__json_write_mark_entry_dirty_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); +static herr_t H5C__json_write_mark_entry_clean_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); +static herr_t H5C__json_write_mark_unserialized_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); +static herr_t H5C__json_write_mark_serialized_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); +static herr_t H5C__json_write_move_entry_log_msg(void *udata, haddr_t old_addr, haddr_t new_addr, int type_id, herr_t fxn_ret_value); +static herr_t H5C__json_write_pin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); +static herr_t H5C__json_write_create_fd_log_msg(void *udata, const H5C_cache_entry_t *parent, const H5C_cache_entry_t *child, herr_t fxn_ret_value); +static herr_t H5C__json_write_protect_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, int type_id, unsigned flags, herr_t fxn_ret_value); +static herr_t H5C__json_write_resize_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, size_t new_size, herr_t fxn_ret_value); +static herr_t H5C__json_write_unpin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); +static herr_t H5C__json_write_destroy_fd_log_msg(void *udata, const H5C_cache_entry_t *parent, const H5C_cache_entry_t *child, herr_t fxn_ret_value); +static herr_t H5C__json_write_unprotect_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, int type_id, unsigned flags, herr_t fxn_ret_value); +static herr_t H5C__json_write_set_cache_config_log_msg(void *udata, const H5AC_cache_config_t *config, herr_t fxn_ret_value); +static herr_t H5C__json_write_remove_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); + + +/*********************/ +/* Package Variables */ +/*********************/ + + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + + +/*******************/ +/* Local Variables */ +/*******************/ + +/* Note that there's no cache set up call since that's the + * place where this struct is wired into the cache. + */ +static H5C_log_class_t H5C_json_log_class_g = { + "json", + H5C__json_tear_down_logging, + NULL, /* start logging */ + NULL, /* stop logging */ + H5C__json_write_start_log_msg, + H5C__json_write_stop_log_msg, + H5C__json_write_create_cache_log_msg, + H5C__json_write_destroy_cache_log_msg, + H5C__json_write_evict_cache_log_msg, + H5C__json_write_expunge_entry_log_msg, + H5C__json_write_flush_cache_log_msg, + H5C__json_write_insert_entry_log_msg, + H5C__json_write_mark_entry_dirty_log_msg, + H5C__json_write_mark_entry_clean_log_msg, + H5C__json_write_mark_unserialized_entry_log_msg, + H5C__json_write_mark_serialized_entry_log_msg, + H5C__json_write_move_entry_log_msg, + H5C__json_write_pin_entry_log_msg, + H5C__json_write_create_fd_log_msg, + H5C__json_write_protect_entry_log_msg, + H5C__json_write_resize_entry_log_msg, + H5C__json_write_unpin_entry_log_msg, + H5C__json_write_destroy_fd_log_msg, + H5C__json_write_unprotect_entry_log_msg, + H5C__json_write_set_cache_config_log_msg, + H5C__json_write_remove_entry_log_msg +}; + + + +/*------------------------------------------------------------------------- + * Function: H5C__json_write_log_message + * + * Purpose: Write a message to the log file and flush the file. + * The message string is neither modified nor freed. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__json_write_log_message(H5C_log_json_udata_t *json_udata) +{ + size_t n_chars; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(json_udata); + HDassert(json_udata->outfile); + HDassert(json_udata->message); + + /* Write the log message and flush */ + n_chars = HDstrlen(json_udata->message); + if((int)n_chars != HDfprintf(json_udata->outfile, json_udata->message)) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "error writing log message") + HDmemset((void *)(json_udata->message), 0, (size_t)(n_chars * sizeof(char))); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__json_write_log_message() */ + + +/*------------------------------------------------------------------------- + * Function: H5C_log_json_set_up + * + * Purpose: Setup for metadata cache logging. + * + * Metadata logging is enabled and disabled at two levels. This + * function and the associated tear_down function open and close + * the log file. the start_ and stop_logging functions are then + * used to switch logging on/off. Optionally, logging can begin + * as soon as the log file is opened (set via the start_immediately + * parameter to this function). + * + * The log functionality is split between the H5C and H5AC + * packages. Log state and direct log manipulation resides in + * H5C. Log messages are generated in H5AC and sent to + * the H5C__json_write_log_message function. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +herr_t +H5C_log_json_set_up(H5C_log_info_t *log_info, const char log_location[], int mpi_rank) +{ + H5C_log_json_udata_t *json_udata = NULL; + char *file_name = NULL; + size_t n_chars; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(log_info); + HDassert(log_location); + + /* Set up the class struct */ + log_info->cls = &H5C_json_log_class_g; + + /* Allocate memory for the JSON-specific data */ + if(NULL == (log_info->udata = H5MM_calloc(sizeof(H5C_log_json_udata_t)))) + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed") + json_udata = (H5C_log_json_udata_t *)(log_info->udata); + + /* Allocate memory for the message buffer */ + if(NULL == (json_udata->message = (char *)H5MM_calloc(H5C_MAX_JSON_LOG_MSG_SIZE * sizeof(char)))) + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed") + + /* Possibly fix up the log file name. + * The extra 39 characters are for adding the rank to the file name + * under parallel HDF5. 39 characters allows > 2^127 processes which + * should be enough for anybody. + * + * allocation size = "RANK_" + <rank # length> + dot + <path length> + \0 + */ + n_chars = 5 + 39 + 1 + HDstrlen(log_location) + 1; + if(NULL == (file_name = (char *)H5MM_calloc(n_chars * sizeof(char)))) + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "can't allocate memory for mdc log file name manipulation") + + /* Add the rank to the log file name when MPI is in use */ + if(-1 == mpi_rank) + HDsnprintf(file_name, n_chars, "%s", log_location); + else + HDsnprintf(file_name, n_chars, "RANK_%d.%s", mpi_rank, log_location); + + /* Open log file and set it to be unbuffered */ + if(NULL == (json_udata->outfile = HDfopen(file_name, "w"))) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "can't create mdc log file") + HDsetbuf(json_udata->outfile, NULL); + + done: + if(file_name) + H5MM_xfree(file_name); + + /* Free and reset the log info struct on errors */ + if(FAIL == ret_value) { + /* Free */ + if(json_udata && json_udata->message) + H5MM_xfree(json_udata->message); + if(json_udata) + H5MM_xfree(json_udata); + + /* Reset */ + log_info->udata = NULL; + log_info->cls = NULL; + } + + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C_log_json_set_up() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__json_tear_down_logging + * + * Purpose: Tear-down for metadata cache logging. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__json_tear_down_logging(H5C_log_info_t *log_info) +{ + H5C_log_json_udata_t *json_udata = NULL; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(log_info); + + /* Alias */ + json_udata = (H5C_log_json_udata_t *)(log_info->udata); + + /* Free the message buffer */ + H5MM_xfree(json_udata->message); + + /* Close log file */ + if(EOF == HDfclose(json_udata->outfile)) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "problem closing mdc log file") + json_udata->outfile = NULL; + + /* Fre the udata */ + H5MM_xfree(json_udata); + + /* Reset the log class info and udata */ + log_info->cls = NULL; + log_info->udata = NULL; + + done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__json_tear_down_logging() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__json_write_start_log_msg + * + * Purpose: Write a log message when logging starts. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__json_write_start_log_msg(void *udata) +{ + H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(json_udata); + HDassert(json_udata->message); + + /* Create the log message string (opens the JSON array) */ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, +"\ +{\n\ +\"HDF5 metadata cache log messages\" : [\n\ +{\ +\"timestamp\":%lld,\ +\"action\":\"logging start\"\ +},\n\ +" + , (long long)HDtime(NULL)); + + /* Write the log message to the file */ + if(H5C__json_write_log_message(json_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__json_write_start_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__json_write_stop_log_msg + * + * Purpose: Write a log message when logging ends. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__json_write_stop_log_msg(void *udata) +{ + H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(json_udata); + HDassert(json_udata->message); + + /* Create the log message string (closes the JSON array) */ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, +"\ +{\ +\"timestamp\":%lld,\ +\"action\":\"logging stop\"\ +}\n\ +]}\n\ +" + , (long long)HDtime(NULL)); + + /* Write the log message to the file */ + if(H5C__json_write_log_message(json_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__json_write_stop_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__json_write_create_cache_log_msg + * + * Purpose: Write a log message for cache creation. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__json_write_create_cache_log_msg(void *udata, herr_t fxn_ret_value) +{ + H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(json_udata); + HDassert(json_udata->message); + + /* Create the log message string */ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, +"\ +{\ +\"timestamp\":%lld,\ +\"action\":\"create\",\ +\"returned\":%d\ +},\n\ +" + , (long long)HDtime(NULL), (int)fxn_ret_value); + + /* Write the log message to the file */ + if(H5C__json_write_log_message(json_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__json_write_create_cache_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__json_write_destroy_cache_log_msg + * + * Purpose: Write a log message for cache destruction. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__json_write_destroy_cache_log_msg(void *udata) +{ + H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(json_udata); + HDassert(json_udata->message); + + /* Create the log message string */ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, +"\ +{\ +\"timestamp\":%lld,\ +\"action\":\"destroy\"\ +},\n\ +" + , (long long)HDtime(NULL)); + + /* Write the log message to the file */ + if(H5C__json_write_log_message(json_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__json_write_destroy_cache_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__json_write_evict_cache_log_msg + * + * Purpose: Write a log message for eviction of cache entries. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__json_write_evict_cache_log_msg(void *udata, herr_t fxn_ret_value) +{ + H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(json_udata); + HDassert(json_udata->message); + + /* Create the log message string */ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, +"\ +{\ +\"timestamp\":%lld,\ +\"action\":\"evict\",\ +\"returned\":%d\ +},\n\ +" + , (long long)HDtime(NULL), (int)fxn_ret_value); + + /* Write the log message to the file */ + if(H5C__json_write_log_message(json_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__json_write_evict_cache_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__json_write_expunge_entry_log_msg + * + * Purpose: Write a log message for expunge of cache entries. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__json_write_expunge_entry_log_msg(void *udata, haddr_t address, + int type_id, herr_t fxn_ret_value) +{ + H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(json_udata); + HDassert(json_udata->message); + + /* Create the log message string */ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, +"\ +{\ +\"timestamp\":%lld,\ +\"action\":\"expunge\",\ +\"address\":0x%lx,\ +\"type_id\":%d,\ +\"returned\":%d\ +},\n\ +" + , (long long)HDtime(NULL), (unsigned long)address, (int)type_id, (int)fxn_ret_value); + + + /* Write the log message to the file */ + if(H5C__json_write_log_message(json_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__json_write_expunge_entry_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__json_write_flush_cache_log_msg + * + * Purpose: Write a log message for cache flushes. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__json_write_flush_cache_log_msg(void *udata, herr_t fxn_ret_value) +{ + H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(json_udata); + HDassert(json_udata->message); + + /* Create the log message string */ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, +"\ +{\ +\"timestamp\":%lld,\ +\"action\":\"flush\",\ +\"returned\":%d\ +},\n\ +" + , (long long)HDtime(NULL), (int)fxn_ret_value); + + /* Write the log message to the file */ + if(H5C__json_write_log_message(json_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__json_write_flush_cache_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__json_write_insert_entry_log_msg + * + * Purpose: Write a log message for insertion of cache entries. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__json_write_insert_entry_log_msg(void *udata, haddr_t address, + int type_id, unsigned flags, size_t size, herr_t fxn_ret_value) +{ + H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(json_udata); + HDassert(json_udata->message); + + /* Create the log message string */ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, +"\ +{\ +\"timestamp\":%lld,\ +\"action\":\"insert\",\ +\"address\":0x%lx,\ +\"type_id\":%d,\ +\"flags\":0x%x,\ +\"size\":%d,\ +\"returned\":%d\ +},\n\ +" + , (long long)HDtime(NULL), (unsigned long)address, type_id, flags, + (int)size, (int)fxn_ret_value); + + /* Write the log message to the file */ + if(H5C__json_write_log_message(json_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__json_write_insert_entry_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__json_write_mark_entry_dirty_log_msg + * + * Purpose: Write a log message for marking cache entries as dirty. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__json_write_mark_entry_dirty_log_msg(void *udata, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value) +{ + H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(json_udata); + HDassert(json_udata->message); + HDassert(entry); + + /* Create the log message string */ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, +"\ +{\ +\"timestamp\":%lld,\ +\"action\":\"dirty\",\ +\"address\":0x%lx,\ +\"returned\":%d\ +},\n\ +" + , (long long)HDtime(NULL), (unsigned long)entry->addr, (int)fxn_ret_value); + + /* Write the log message to the file */ + if(H5C__json_write_log_message(json_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__json_write_mark_entry_dirty_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__json_write_mark_entry_clean_log_msg + * + * Purpose: Write a log message for marking cache entries as clean. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__json_write_mark_entry_clean_log_msg(void *udata, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value) +{ + H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(json_udata); + HDassert(json_udata->message); + HDassert(entry); + + /* Create the log message string */ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, +"\ +{\ +\"timestamp\":%lld,\ +\"action\":\"clean\",\ +\"address\":0x%lx,\ +\"returned\":%d\ +},\n\ +" + , (long long)HDtime(NULL), (unsigned long)entry->addr, (int)fxn_ret_value); + + /* Write the log message to the file */ + if(H5C__json_write_log_message(json_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__json_write_mark_entry_clean_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__json_write_mark_unserialized_entry_log_msg + * + * Purpose: Write a log message for marking cache entries as unserialized. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__json_write_mark_unserialized_entry_log_msg(void *udata, + const H5C_cache_entry_t *entry, herr_t fxn_ret_value) +{ + H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(json_udata); + HDassert(json_udata->message); + HDassert(entry); + + /* Create the log message string */ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, +"\ +{\ +\"timestamp\":%lld,\ +\"action\":\"unserialized\",\ +\"address\":0x%lx,\ +\"returned\":%d\ +},\n\ +" + , (long long)HDtime(NULL), (unsigned long)entry->addr, (int)fxn_ret_value); + + /* Write the log message to the file */ + if(H5C__json_write_log_message(json_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__json_write_mark_unserialized_entry_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__json_write_mark_serialize_entry_log_msg + * + * Purpose: Write a log message for marking cache entries as serialize. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__json_write_mark_serialized_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value) +{ + H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(json_udata); + HDassert(json_udata->message); + HDassert(entry); + + /* Create the log message string */ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, +"\ +{\ +\"timestamp\":%lld,\ +\"action\":\"serialized\",\ +\"address\":0x%lx,\ +\"returned\":%d\ +},\n\ +" + , (long long)HDtime(NULL), (unsigned long)entry->addr, (int)fxn_ret_value); + + /* Write the log message to the file */ + if(H5C__json_write_log_message(json_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__json_write_mark_serialized_entry_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__json_write_move_entry_log_msg + * + * Purpose: Write a log message for moving a cache entry. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__json_write_move_entry_log_msg(void *udata, haddr_t old_addr, haddr_t new_addr, + int type_id, herr_t fxn_ret_value) +{ + H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(json_udata); + HDassert(json_udata->message); + + /* Create the log message string */ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, +"\ +{\ +\"timestamp\":%lld,\ +\"action\":\"move\",\ +\"old_address\":0x%lx,\ +\"new_address\":0x%lx,\ +\"type_id\":%d,\ +\"returned\":%d\ +},\n\ +" + , (long long)HDtime(NULL), (unsigned long)old_addr, + (unsigned long)new_addr, type_id, (int)fxn_ret_value); + + /* Write the log message to the file */ + if(H5C__json_write_log_message(json_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__json_write_move_entry_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__json_write_pin_entry_log_msg + * + * Purpose: Write a log message for pinning a cache entry. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__json_write_pin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value) +{ + H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(json_udata); + HDassert(json_udata->message); + HDassert(entry); + + /* Create the log message string */ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, +"\ +{\ +\"timestamp\":%lld,\ +\"action\":\"pin\",\ +\"address\":0x%lx,\ +\"returned\":%d\ +},\n\ +" + , (long long)HDtime(NULL), (unsigned long)entry->addr, + (int)fxn_ret_value); + + /* Write the log message to the file */ + if(H5C__json_write_log_message(json_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__json_write_pin_entry_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__json_write_create_fd_log_msg + * + * Purpose: Write a log message for creating a flush dependency between + * two cache entries. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__json_write_create_fd_log_msg(void *udata, const H5C_cache_entry_t *parent, + const H5C_cache_entry_t *child, herr_t fxn_ret_value) +{ + H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(json_udata); + HDassert(json_udata->message); + HDassert(parent); + HDassert(child); + + /* Create the log message string */ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, +"\ +{\ +\"timestamp\":%lld,\ +\"action\":\"create_fd\",\ +\"parent_addr\":0x%lx,\ +\"child_addr\":0x%lx,\ +\"returned\":%d\ +},\n\ +" + , (long long)HDtime(NULL), (unsigned long)parent->addr, + (unsigned long)child->addr, (int)fxn_ret_value); + + /* Write the log message to the file */ + if(H5C__json_write_log_message(json_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__json_write_create_fd_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__json_write_protect_entry_log_msg + * + * Purpose: Write a log message for protecting a cache entry. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__json_write_protect_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, + int type_id, unsigned flags, herr_t fxn_ret_value) +{ + H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); + char rw_s[16]; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(json_udata); + HDassert(json_udata->message); + HDassert(entry); + + if(H5C__READ_ONLY_FLAG == flags) + HDstrcpy(rw_s, "READ"); + else + HDstrcpy(rw_s, "WRITE"); + + /* Create the log message string */ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, +"\ +{\ +\"timestamp\":%lld,\ +\"action\":\"protect\",\ +\"address\":0x%lx,\ +\"type_id\":%d,\ +\"readwrite\":\"%s\",\ +\"size\":%d,\ +\"returned\":%d\ +},\n\ +" + , (long long)HDtime(NULL), (unsigned long)entry->addr, + type_id, rw_s, (int)entry->size, (int)fxn_ret_value); + + /* Write the log message to the file */ + if(H5C__json_write_log_message(json_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__json_write_protect_entry_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__json_write_resize_entry_log_msg + * + * Purpose: Write a log message for resizing a cache entry. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__json_write_resize_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, + size_t new_size, herr_t fxn_ret_value) +{ + H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(json_udata); + HDassert(json_udata->message); + HDassert(entry); + + /* Create the log message string */ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, +"\ +{\ +\"timestamp\":%lld,\ +\"action\":\"resize\",\ +\"address\":0x%lx,\ +\"new_size\":%d,\ +\"returned\":%d\ +},\n\ +" + , (long long)HDtime(NULL), (unsigned long)entry->addr, + (int)new_size, (int)fxn_ret_value); + + /* Write the log message to the file */ + if(H5C__json_write_log_message(json_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__json_write_resize_entry_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__json_write_unpin_entry_log_msg + * + * Purpose: Write a log message for unpinning a cache entry. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__json_write_unpin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value) +{ + H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(json_udata); + HDassert(json_udata->message); + HDassert(entry); + + /* Create the log message string */ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, +"\ +{\ +\"timestamp\":%lld,\ +\"action\":\"unpin\",\ +\"address\":0x%lx,\ +\"returned\":%d\ +},\n\ +" + , (long long)HDtime(NULL), (unsigned long)entry->addr, + (int)fxn_ret_value); + + /* Write the log message to the file */ + if(H5C__json_write_log_message(json_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__json_write_unpin_entry_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__json_write_destroy_fd_log_msg + * + * Purpose: Write a log message for destroying a flush dependency + * between two cache entries. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__json_write_destroy_fd_log_msg(void *udata, const H5C_cache_entry_t *parent, + const H5C_cache_entry_t *child, herr_t fxn_ret_value) +{ + H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(json_udata); + HDassert(json_udata->message); + HDassert(parent); + HDassert(child); + + /* Create the log message string */ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, +"\ +{\ +\"timestamp\":%lld,\ +\"action\":\"destroy_fd\",\ +\"parent_addr\":0x%lx,\ +\"child_addr\":0x%lx,\ +\"returned\":%d\ +},\n\ +" + , (long long)HDtime(NULL), (unsigned long)parent->addr, + (unsigned long)child->addr, (int)fxn_ret_value); + + /* Write the log message to the file */ + if(H5C__json_write_log_message(json_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__json_write_destroy_fd_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__json_write_unprotect_entry_log_msg + * + * Purpose: Write a log message for unprotecting a cache entry. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__json_write_unprotect_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, + int type_id, unsigned flags, herr_t fxn_ret_value) +{ + H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(json_udata); + HDassert(json_udata->message); + HDassert(entry); + + /* Create the log message string */ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, +"\ +{\ +\"timestamp\":%lld,\ +\"action\":\"unprotect\",\ +\"address\":0x%lx,\ +\"id\":%d,\ +\"flags\":%x,\ +\"returned\":%d\ +},\n\ +" + , (long long)HDtime(NULL), (unsigned long)entry->addr, + type_id, flags, (int)fxn_ret_value); + + /* Write the log message to the file */ + if(H5C__json_write_log_message(json_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__json_write_unprotect_entry_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__json_write_set_cache_config_log_msg + * + * Purpose: Write a log message for setting the cache configuration. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__json_write_set_cache_config_log_msg(void *udata, const H5AC_cache_config_t *config, + herr_t fxn_ret_value) +{ + H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(json_udata); + HDassert(json_udata->message); + HDassert(config); + + /* Create the log message string */ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, +"\ +{\ +\"timestamp\":%lld,\ +\"action\":\"set_config\",\ +\"returned\":%d\ +},\n\ +" + , (long long)HDtime(NULL), (int)fxn_ret_value); + + + /* Write the log message to the file */ + if(H5C__json_write_log_message(json_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__json_write_set_cache_config_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__json_write_remove_entry_log_msg + * + * Purpose: Write a log message for removing a cache entry. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__json_write_remove_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value) +{ + H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(json_udata); + HDassert(json_udata->message); + HDassert(entry); + + /* Create the log message string */ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, +"\ +{\ +\"timestamp\":%lld,\ +\"action\":\"remove\",\ +\"address\":0x%lx,\ +\"returned\":%d\ +},\n\ +" + , (long long)HDtime(NULL), (unsigned long)entry->addr, + (int)fxn_ret_value); + + /* Write the log message to the file */ + if(H5C__json_write_log_message(json_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__json_write_remove_entry_log_msg() */ + diff --git a/src/H5Clog_trace.c b/src/H5Clog_trace.c new file mode 100644 index 0000000..f7d6889 --- /dev/null +++ b/src/H5Clog_trace.c @@ -0,0 +1,1008 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/*------------------------------------------------------------------------- + * + * Created: H5Clog_trace.c + * + * Purpose: Cache log implementation that emits trace entries intended + * for consumption by a future 'cache replay' feature. + * + *------------------------------------------------------------------------- + */ + +/****************/ +/* Module Setup */ +/****************/ +#include "H5Cmodule.h" /* This source code file is part of the H5C module */ + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5Cpkg.h" /* Cache */ +#include "H5Clog.h" /* Cache logging */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5MMprivate.h" /* Memory management */ + + +/****************/ +/* Local Macros */ +/****************/ + +/* Max log message size */ +#define H5C_MAX_TRACE_LOG_MSG_SIZE 2048 + + +/******************/ +/* Local Typedefs */ +/******************/ + + +/********************/ +/* Package Typedefs */ +/********************/ + +typedef struct H5C_log_trace_udata_t { + FILE *outfile; + char *message; +} H5C_log_trace_udata_t; + + +/********************/ +/* Local Prototypes */ +/********************/ + +/* Internal message handling calls */ +static herr_t H5C__trace_write_log_message(H5C_log_trace_udata_t *trace_udata); + +/* Log message callbacks */ +static herr_t H5C__trace_tear_down_logging(H5C_log_info_t *log_info); +static herr_t H5C__trace_write_expunge_entry_log_msg(void *udata, haddr_t address, int type_id, herr_t fxn_ret_value); +static herr_t H5C__trace_write_flush_cache_log_msg(void *udata, herr_t fxn_ret_value); +static herr_t H5C__trace_write_insert_entry_log_msg(void *udata, haddr_t address, int type_id, unsigned flags, size_t size, herr_t fxn_ret_value); +static herr_t H5C__trace_write_mark_entry_dirty_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); +static herr_t H5C__trace_write_mark_entry_clean_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); +static herr_t H5C__trace_write_mark_unserialized_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); +static herr_t H5C__trace_write_mark_serialized_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); +static herr_t H5C__trace_write_move_entry_log_msg(void *udata, haddr_t old_addr, haddr_t new_addr, int type_id, herr_t fxn_ret_value); +static herr_t H5C__trace_write_pin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); +static herr_t H5C__trace_write_create_fd_log_msg(void *udata, const H5C_cache_entry_t *parent, const H5C_cache_entry_t *child, herr_t fxn_ret_value); +static herr_t H5C__trace_write_protect_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, int type_id, unsigned flags, herr_t fxn_ret_value); +static herr_t H5C__trace_write_resize_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, size_t new_size, herr_t fxn_ret_value); +static herr_t H5C__trace_write_unpin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); +static herr_t H5C__trace_write_destroy_fd_log_msg(void *udata, const H5C_cache_entry_t *parent, const H5C_cache_entry_t *child, herr_t fxn_ret_value); +static herr_t H5C__trace_write_unprotect_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, int type_id, unsigned flags, herr_t fxn_ret_value); +static herr_t H5C__trace_write_set_cache_config_log_msg(void *udata, const H5AC_cache_config_t *config, herr_t fxn_ret_value); +static herr_t H5C__trace_write_remove_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); + + +/*********************/ +/* Package Variables */ +/*********************/ + + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + + +/*******************/ +/* Local Variables */ +/*******************/ + +/* Note that there's no cache set up call since that's the + * place where this struct is wired into the cache. + */ +static H5C_log_class_t H5C_trace_log_class_g = { + "trace", + H5C__trace_tear_down_logging, + NULL, /* start logging */ + NULL, /* stop logging */ + NULL, /* write start message */ + NULL, /* write stop message */ + NULL, /* write create cache message */ + NULL, /* write destroy cache message */ + NULL, /* write evict cache message */ + H5C__trace_write_expunge_entry_log_msg, + H5C__trace_write_flush_cache_log_msg, + H5C__trace_write_insert_entry_log_msg, + H5C__trace_write_mark_entry_dirty_log_msg, + H5C__trace_write_mark_entry_clean_log_msg, + H5C__trace_write_mark_unserialized_entry_log_msg, + H5C__trace_write_mark_serialized_entry_log_msg, + H5C__trace_write_move_entry_log_msg, + H5C__trace_write_pin_entry_log_msg, + H5C__trace_write_create_fd_log_msg, + H5C__trace_write_protect_entry_log_msg, + H5C__trace_write_resize_entry_log_msg, + H5C__trace_write_unpin_entry_log_msg, + H5C__trace_write_destroy_fd_log_msg, + H5C__trace_write_unprotect_entry_log_msg, + H5C__trace_write_set_cache_config_log_msg, + H5C__trace_write_remove_entry_log_msg +}; + + + +/*------------------------------------------------------------------------- + * Function: H5C__trace_write_log_message + * + * Purpose: Write a message to the log file and flush the file. + * The message string is neither modified nor freed. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__trace_write_log_message(H5C_log_trace_udata_t *trace_udata) +{ + size_t n_chars; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(trace_udata); + HDassert(trace_udata->outfile); + HDassert(trace_udata->message); + + /* Write the log message and flush */ + n_chars = HDstrlen(trace_udata->message); + if((int)n_chars != HDfprintf(trace_udata->outfile, trace_udata->message)) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "error writing log message") + HDmemset((void *)(trace_udata->message), 0, (size_t)(n_chars * sizeof(char))); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__trace_write_log_message() */ + + +/*------------------------------------------------------------------------- + * Function: H5C_log_trace_set_up + * + * Purpose: Setup for metadata cache logging. + * + * Metadata logging is enabled and disabled at two levels. This + * function and the associated tear_down function open and close + * the log file. the start_ and stop_logging functions are then + * used to switch logging on/off. Optionally, logging can begin + * as soon as the log file is opened (set via the start_immediately + * parameter to this function). + * + * The log functionality is split between the H5C and H5AC + * packages. Log state and direct log manipulation resides in + * H5C. Log messages are generated in H5AC and sent to + * the H5C__trace_write_log_message function. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +herr_t +H5C_log_trace_set_up(H5C_log_info_t *log_info, const char log_location[], int mpi_rank) +{ + H5C_log_trace_udata_t *trace_udata = NULL; + char *file_name = NULL; + size_t n_chars; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(log_info); + HDassert(log_location); + + /* Set up the class struct */ + log_info->cls = &H5C_trace_log_class_g; + + /* Allocate memory for the JSON-specific data */ + if(NULL == (log_info->udata = H5MM_calloc(sizeof(H5C_log_trace_udata_t)))) + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed") + trace_udata = (H5C_log_trace_udata_t *)(log_info->udata); + + /* Allocate memory for the message buffer */ + if(NULL == (trace_udata->message = (char *)H5MM_calloc(H5C_MAX_TRACE_LOG_MSG_SIZE * sizeof(char)))) + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed") + + /* Possibly fix up the log file name. + * The extra 39 characters are for adding the rank to the file name + * under parallel HDF5. 39 characters allows > 2^127 processes which + * should be enough for anybody. + * + * allocation size = <path length> + dot + <rank # length> + \0 + */ + n_chars = HDstrlen(log_location) + 1 + 39 + 1; + if(NULL == (file_name = (char *)H5MM_calloc(n_chars * sizeof(char)))) + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "can't allocate memory for mdc log file name manipulation") + + /* Add the rank to the log file name when MPI is in use */ + if(-1 == mpi_rank) + HDsnprintf(file_name, n_chars, "%s", log_location); + else + HDsnprintf(file_name, n_chars, "%s.%d", log_location, mpi_rank); + + /* Open log file and set it to be unbuffered */ + if(NULL == (trace_udata->outfile = HDfopen(file_name, "w"))) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "can't create mdc log file") + HDsetbuf(trace_udata->outfile, NULL); + + /* Write the header */ + HDfprintf(trace_udata->outfile, "### HDF5 metadata cache trace file version 1 ###\n"); + + done: + if(file_name) + H5MM_xfree(file_name); + + /* Free and reset the log info struct on errors */ + if(FAIL == ret_value) { + /* Free */ + if(trace_udata && trace_udata->message) + H5MM_xfree(trace_udata->message); + if(trace_udata) + H5MM_xfree(trace_udata); + + /* Reset */ + log_info->udata = NULL; + log_info->cls = NULL; + } + + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C_log_trace_set_up() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__trace_tear_down_logging + * + * Purpose: Tear-down for metadata cache logging. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__trace_tear_down_logging(H5C_log_info_t *log_info) +{ + H5C_log_trace_udata_t *trace_udata = NULL; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(log_info); + + /* Alias */ + trace_udata = (H5C_log_trace_udata_t *)(log_info->udata); + + /* Free the message buffer */ + H5MM_xfree(trace_udata->message); + + /* Close log file */ + if(EOF == HDfclose(trace_udata->outfile)) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "problem closing mdc log file") + trace_udata->outfile = NULL; + + /* Fre the udata */ + H5MM_xfree(trace_udata); + + /* Reset the log class info and udata */ + log_info->cls = NULL; + log_info->udata = NULL; + + done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__trace_tear_down_logging() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__trace_write_expunge_entry_log_msg + * + * Purpose: Write a log message for expunge of cache entries. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__trace_write_expunge_entry_log_msg(void *udata, haddr_t address, + int type_id, herr_t fxn_ret_value) +{ + H5C_log_trace_udata_t *trace_udata = (H5C_log_trace_udata_t *)(udata); + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(trace_udata); + HDassert(trace_udata->message); + + /* Create the log message string */ + HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, "H5AC_expunge_entry 0x%lx %d %d\n", + (unsigned long)address, type_id, (int)fxn_ret_value); + + /* Write the log message to the file */ + if(H5C__trace_write_log_message(trace_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__trace_write_expunge_entry_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__trace_write_flush_cache_log_msg + * + * Purpose: Write a log message for cache flushes. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__trace_write_flush_cache_log_msg(void *udata, herr_t fxn_ret_value) +{ + H5C_log_trace_udata_t *trace_udata = (H5C_log_trace_udata_t *)(udata); + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(trace_udata); + HDassert(trace_udata->message); + + /* Create the log message string */ + HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, "H5AC_flush %d\n", + (int)fxn_ret_value); + + /* Write the log message to the file */ + if(H5C__trace_write_log_message(trace_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__trace_write_flush_cache_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__trace_write_insert_entry_log_msg + * + * Purpose: Write a log message for insertion of cache entries. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__trace_write_insert_entry_log_msg(void *udata, haddr_t address, + int type_id, unsigned flags, size_t size, herr_t fxn_ret_value) +{ + H5C_log_trace_udata_t *trace_udata = (H5C_log_trace_udata_t *)(udata); + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(trace_udata); + HDassert(trace_udata->message); + + /* Create the log message string */ + HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, "H5AC_insert_entry 0x%lx %d 0x%x %d %d\n", + (unsigned long)address, type_id, flags, (int)size, (int)fxn_ret_value); + + /* Write the log message to the file */ + if(H5C__trace_write_log_message(trace_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__trace_write_insert_entry_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__trace_write_mark_entry_dirty_log_msg + * + * Purpose: Write a log message for marking cache entries as dirty. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__trace_write_mark_entry_dirty_log_msg(void *udata, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value) +{ + H5C_log_trace_udata_t *trace_udata = (H5C_log_trace_udata_t *)(udata); + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(trace_udata); + HDassert(trace_udata->message); + HDassert(entry); + + /* Create the log message string */ + HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, "H5AC_mark_entry_dirty 0x%lx %d\n", + (unsigned long)(entry->addr), (int)fxn_ret_value); + + /* Write the log message to the file */ + if(H5C__trace_write_log_message(trace_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__trace_write_mark_entry_dirty_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__trace_write_mark_entry_clean_log_msg + * + * Purpose: Write a log message for marking cache entries as clean. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__trace_write_mark_entry_clean_log_msg(void *udata, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value) +{ + H5C_log_trace_udata_t *trace_udata = (H5C_log_trace_udata_t *)(udata); + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(trace_udata); + HDassert(trace_udata->message); + HDassert(entry); + + /* Create the log message string */ + HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, "H5AC_mark_entry_clean 0x%lx %d\n", + (unsigned long)(entry->addr), (int)fxn_ret_value); + + /* Write the log message to the file */ + if(H5C__trace_write_log_message(trace_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__trace_write_mark_entry_clean_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__trace_write_mark_unserialized_entry_log_msg + * + * Purpose: Write a log message for marking cache entries as unserialized. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__trace_write_mark_unserialized_entry_log_msg(void *udata, + const H5C_cache_entry_t *entry, herr_t fxn_ret_value) +{ + H5C_log_trace_udata_t *trace_udata = (H5C_log_trace_udata_t *)(udata); + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(trace_udata); + HDassert(trace_udata->message); + HDassert(entry); + + /* Create the log message string */ + HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, "H5AC_mark_entry_unserialized 0x%lx %d\n", + (unsigned long)(entry->addr), (int)fxn_ret_value); + + /* Write the log message to the file */ + if(H5C__trace_write_log_message(trace_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__trace_write_mark_unserialized_entry_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__trace_write_mark_serialized_entry_log_msg + * + * Purpose: Write a log message for marking cache entries as serialize. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__trace_write_mark_serialized_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value) +{ + H5C_log_trace_udata_t *trace_udata = (H5C_log_trace_udata_t *)(udata); + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(trace_udata); + HDassert(trace_udata->message); + HDassert(entry); + + /* Create the log message string */ + HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, "H5AC_mark_entry_serialized 0x%lx %d\n", + (unsigned long)(entry->addr), (int)fxn_ret_value); + + /* Write the log message to the file */ + if(H5C__trace_write_log_message(trace_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__trace_write_mark_serialized_entry_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__trace_write_move_entry_log_msg + * + * Purpose: Write a log message for moving a cache entry. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__trace_write_move_entry_log_msg(void *udata, haddr_t old_addr, haddr_t new_addr, + int type_id, herr_t fxn_ret_value) +{ + H5C_log_trace_udata_t *trace_udata = (H5C_log_trace_udata_t *)(udata); + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(trace_udata); + HDassert(trace_udata->message); + + /* Create the log message string */ + HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, "H5AC_move_entry 0x%lx 0x%lx %d %d\n", + (unsigned long)old_addr, (unsigned long)new_addr, type_id, (int)fxn_ret_value); + + /* Write the log message to the file */ + if(H5C__trace_write_log_message(trace_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__trace_write_move_entry_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__trace_write_pin_entry_log_msg + * + * Purpose: Write a log message for pinning a cache entry. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__trace_write_pin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value) +{ + H5C_log_trace_udata_t *trace_udata = (H5C_log_trace_udata_t *)(udata); + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(trace_udata); + HDassert(trace_udata->message); + HDassert(entry); + + /* Create the log message string */ + HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, "H5AC_pin_protected_entry 0x%lx %d\n", + (unsigned long)(entry->addr), (int)fxn_ret_value); + + /* Write the log message to the file */ + if(H5C__trace_write_log_message(trace_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__trace_write_pin_entry_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__trace_write_create_fd_log_msg + * + * Purpose: Write a log message for creating a flush dependency between + * two cache entries. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__trace_write_create_fd_log_msg(void *udata, const H5C_cache_entry_t *parent, + const H5C_cache_entry_t *child, herr_t fxn_ret_value) +{ + H5C_log_trace_udata_t *trace_udata = (H5C_log_trace_udata_t *)(udata); + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(trace_udata); + HDassert(trace_udata->message); + HDassert(parent); + HDassert(child); + + /* Create the log message string */ + HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, "H5AC_create_flush_dependency 0x%lx 0x%lx %d\n", + (unsigned long)(parent->addr), (unsigned long)(child->addr), (int)fxn_ret_value); + + /* Write the log message to the file */ + if(H5C__trace_write_log_message(trace_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__trace_write_create_fd_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__trace_write_protect_entry_log_msg + * + * Purpose: Write a log message for protecting a cache entry. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__trace_write_protect_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, + int type_id, unsigned flags, herr_t fxn_ret_value) +{ + H5C_log_trace_udata_t *trace_udata = (H5C_log_trace_udata_t *)(udata); + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(trace_udata); + HDassert(trace_udata->message); + HDassert(entry); + + /* Create the log message string */ + HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, "H5AC_protect 0x%lx %d 0x%x %d %d\n", + (unsigned long)(entry->addr), type_id, flags, (int)(entry->size), (int)fxn_ret_value); + + /* Write the log message to the file */ + if(H5C__trace_write_log_message(trace_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__trace_write_protect_entry_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__trace_write_resize_entry_log_msg + * + * Purpose: Write a log message for resizing a cache entry. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__trace_write_resize_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, + size_t new_size, herr_t fxn_ret_value) +{ + H5C_log_trace_udata_t *trace_udata = (H5C_log_trace_udata_t *)(udata); + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(trace_udata); + HDassert(trace_udata->message); + HDassert(entry); + + /* Create the log message string */ + HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, "H5AC_resize_entry 0x%lx %d %d\n", + (unsigned long)(entry->addr), (int)new_size, (int)fxn_ret_value); + + /* Write the log message to the file */ + if(H5C__trace_write_log_message(trace_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__trace_write_resize_entry_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__trace_write_unpin_entry_log_msg + * + * Purpose: Write a log message for unpinning a cache entry. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__trace_write_unpin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value) +{ + H5C_log_trace_udata_t *trace_udata = (H5C_log_trace_udata_t *)(udata); + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(trace_udata); + HDassert(trace_udata->message); + HDassert(entry); + + /* Create the log message string */ + HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, "H5AC_unpin_entry 0x%lx %d\n", + (unsigned long)(entry->addr), (int)fxn_ret_value); + + /* Write the log message to the file */ + if(H5C__trace_write_log_message(trace_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__trace_write_unpin_entry_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__trace_write_destroy_fd_log_msg + * + * Purpose: Write a log message for destroying a flush dependency + * between two cache entries. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__trace_write_destroy_fd_log_msg(void *udata, const H5C_cache_entry_t *parent, + const H5C_cache_entry_t *child, herr_t fxn_ret_value) +{ + H5C_log_trace_udata_t *trace_udata = (H5C_log_trace_udata_t *)(udata); + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(trace_udata); + HDassert(trace_udata->message); + HDassert(parent); + HDassert(child); + + /* Create the log message string */ + HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, "H5AC_destroy_flush_dependency 0x%lx 0x%lx %d\n", + (unsigned long)(parent->addr), (unsigned long)(child->addr), (int)fxn_ret_value); + + /* Write the log message to the file */ + if(H5C__trace_write_log_message(trace_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__trace_write_destroy_fd_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__trace_write_unprotect_entry_log_msg + * + * Purpose: Write a log message for unprotecting a cache entry. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__trace_write_unprotect_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, + int type_id, unsigned flags, herr_t fxn_ret_value) +{ + H5C_log_trace_udata_t *trace_udata = (H5C_log_trace_udata_t *)(udata); + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(trace_udata); + HDassert(trace_udata->message); + HDassert(entry); + + /* Create the log message string */ + HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, "H5AC_unprotect 0x%lx %d 0x%x %d\n", + (unsigned long)(entry->addr), type_id, flags, (int)fxn_ret_value); + + /* Write the log message to the file */ + if(H5C__trace_write_log_message(trace_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__trace_write_unprotect_entry_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__trace_write_set_cache_config_log_msg + * + * Purpose: Write a log message for setting the cache configuration. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__trace_write_set_cache_config_log_msg(void *udata, const H5AC_cache_config_t *config, + herr_t fxn_ret_value) +{ + H5C_log_trace_udata_t *trace_udata = (H5C_log_trace_udata_t *)(udata); + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(trace_udata); + HDassert(trace_udata->message); + HDassert(config); + + /* Create the log message string */ + HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, + "H5AC_set_cache_auto_resize_config %d %d %d %d \"%s\" %d %d %d %f %d %d %ld %d %f %f %d %f %f %d %d %d %f %f %d %d %d %d %f %zu %d %d\n", + config->version, + (int)(config->rpt_fcn_enabled), + (int)(config->open_trace_file), + (int)(config->close_trace_file), + config->trace_file_name, + (int)(config->evictions_enabled), + (int)(config->set_initial_size), + (int)(config->initial_size), + config->min_clean_fraction, + (int)(config->max_size), + (int)(config->min_size), + config->epoch_length, + (int)(config->incr_mode), + config->lower_hr_threshold, + config->increment, + (int)(config->flash_incr_mode), + config->flash_multiple, + config->flash_threshold, + (int)(config->apply_max_increment), + (int)(config->max_increment), + (int)(config->decr_mode), + config->upper_hr_threshold, + config->decrement, + (int)(config->apply_max_decrement), + (int)(config->max_decrement), + config->epochs_before_eviction, + (int)(config->apply_empty_reserve), + config->empty_reserve, + config->dirty_bytes_threshold, + config->metadata_write_strategy, + (int)fxn_ret_value); + + /* Write the log message to the file */ + if(H5C__trace_write_log_message(trace_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__trace_write_set_cache_config_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__trace_write_remove_entry_log_msg + * + * Purpose: Write a log message for removing a cache entry. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__trace_write_remove_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value) +{ + H5C_log_trace_udata_t *trace_udata = (H5C_log_trace_udata_t *)(udata); + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(trace_udata); + HDassert(trace_udata->message); + HDassert(entry); + + /* Create the log message string */ + HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, "H5AC_remove_entry 0x%lx %d\n", + (unsigned long)(entry->addr), (int)fxn_ret_value); + + /* Write the log message to the file */ + if(H5C__trace_write_log_message(trace_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__trace_write_remove_entry_log_msg() */ + diff --git a/src/H5Cpkg.h b/src/H5Cpkg.h index 98d7a01..9201afb 100644 --- a/src/H5Cpkg.h +++ b/src/H5Cpkg.h @@ -37,6 +37,7 @@ #include "H5Cprivate.h" /* Other private headers needed by this file */ +#include "H5Clog.h" /* Cache logging */ #include "H5SLprivate.h" /* Skip lists */ /**************************/ @@ -3497,40 +3498,8 @@ typedef struct H5C_tag_info_t { * flush_in_progress: Boolean flag indicating whether a flush is in * progress. * - * trace_file_ptr: File pointer pointing to the trace file, which is used - * to record cache operations for use in simulations and design - * studies. This field will usually be NULL, indicating that - * no trace file should be recorded. - * - * Since much of the code supporting the parallel metadata - * cache is in H5AC, we don't write the trace file from - * H5C. Instead, H5AC reads the trace_file_ptr as needed. - * - * When we get to using H5C in other places, we may add - * code to write trace file data at the H5C level as well. - * - * logging_enabled: Boolean flag indicating whether cache logging - * which is used to record cache operations for use in - * debugging and performance analysis. When this flag is set - * to TRUE, it means that the log file is open and ready to - * receive log entries. It does NOT mean that cache operations - * are currently being recorded. That is controlled by the - * currently_logging flag (below). - * - * Since much of the code supporting the parallel metadata - * cache is in H5AC, we don't write the trace file from - * H5C. Instead, H5AC reads the trace_file_ptr as needed. - * - * When we get to using H5C in other places, we may add - * code to write trace file data at the H5C level as well. - * - * currently_logging: Boolean flag that indicates if cache operations are - * currently being logged. This flag is flipped by the - * H5Fstart/stop_mdc_logging functions. - * - * log_file_ptr: File pointer pointing to the log file. The I/O functions - * in stdio.h are used to write to the log file regardless of - * the VFD selected. + * log_info: Information used by the MDC logging functionality. + * Described in H5Clog.h. * * aux_ptr: Pointer to void used to allow wrapper code to associate * its data with an instance of H5C_t. The H5C cache code @@ -4676,10 +4645,7 @@ typedef struct H5C_tag_info_t { struct H5C_t { uint32_t magic; hbool_t flush_in_progress; - FILE * trace_file_ptr; - hbool_t logging_enabled; - hbool_t currently_logging; - FILE * log_file_ptr; + H5C_log_info_t *log_info; void * aux_ptr; int32_t max_type_id; const H5C_class_t * const *class_table_ptr; diff --git a/src/H5Cprivate.h b/src/H5Cprivate.h index 38a86ee..c39c1df 100644 --- a/src/H5Cprivate.h +++ b/src/H5Cprivate.h @@ -2219,6 +2219,12 @@ typedef struct H5C_cache_image_ctl_t { unsigned flags; } H5C_cache_image_ctl_t; +/* The cache logging output style */ +typedef enum H5C_log_style_t { + H5C_LOG_STYLE_JSON, + H5C_LOG_STYLE_TRACE +} H5C_log_style_t; + /***************************************/ /* Library-private Function Prototypes */ /***************************************/ @@ -2227,13 +2233,6 @@ H5_DLL H5C_t *H5C_create(size_t max_cache_size, size_t min_clean_size, int max_type_id, const H5C_class_t * const *class_table_ptr, H5C_write_permitted_func_t check_write_permitted, hbool_t write_permitted, H5C_log_flush_func_t log_flush, void *aux_ptr); -H5_DLL herr_t H5C_set_up_logging(H5C_t *cache_ptr, const char log_location[], hbool_t start_immediately); -H5_DLL herr_t H5C_tear_down_logging(H5C_t *cache_ptr); -H5_DLL herr_t H5C_start_logging(H5C_t *cache_ptr); -H5_DLL herr_t H5C_stop_logging(H5C_t *cache_ptr); -H5_DLL herr_t H5C_get_logging_status(const H5C_t *cache_ptr, /*OUT*/ hbool_t *is_enabled, - /*OUT*/ hbool_t *is_currently_logging); -H5_DLL herr_t H5C_write_log_message(const H5C_t *cache_ptr, const char message[]); H5_DLL void H5C_def_auto_resize_rpt_fcn(H5C_t *cache_ptr, int32_t version, double hit_rate, enum H5C_resize_status status, size_t old_max_cache_size, size_t new_max_cache_size, @@ -2267,8 +2266,6 @@ H5_DLL herr_t H5C_get_entry_status(const H5F_t *f, haddr_t addr, hbool_t *image_up_to_date_ptr); H5_DLL herr_t H5C_get_evictions_enabled(const H5C_t *cache_ptr, hbool_t *evictions_enabled_ptr); H5_DLL void * H5C_get_aux_ptr(const H5C_t *cache_ptr); -H5_DLL FILE *H5C_get_trace_file_ptr(const H5C_t *cache_ptr); -H5_DLL FILE *H5C_get_trace_file_ptr_from_entry(const H5C_cache_entry_t *entry_ptr); H5_DLL herr_t H5C_image_stats(H5C_t * cache_ptr, hbool_t print_header); H5_DLL herr_t H5C_insert_entry(H5F_t *f, const H5C_class_t *type, haddr_t addr, void *thing, unsigned int flags); @@ -2292,7 +2289,6 @@ H5_DLL herr_t H5C_set_cache_image_config(const H5F_t *f, H5C_t *cache_ptr, H5C_cache_image_ctl_t *config_ptr); H5_DLL herr_t H5C_set_evictions_enabled(H5C_t *cache_ptr, hbool_t evictions_enabled); H5_DLL herr_t H5C_set_prefix(H5C_t *cache_ptr, char *prefix); -H5_DLL herr_t H5C_set_trace_file_ptr(H5C_t *cache_ptr, FILE *trace_file_ptr); H5_DLL herr_t H5C_stats(H5C_t *cache_ptr, const char *cache_name, hbool_t display_detailed_stats); H5_DLL void H5C_stats__reset(H5C_t *cache_ptr); @@ -2316,6 +2312,11 @@ H5_DLL herr_t H5C_cache_image_status(H5F_t * f, hbool_t *load_ci_ptr, H5_DLL hbool_t H5C_cache_image_pending(const H5C_t *cache_ptr); H5_DLL herr_t H5C_get_mdc_image_info(H5C_t *cache_ptr, haddr_t *image_addr, hsize_t *image_len); +/* Logging functions */ +H5_DLL herr_t H5C_start_logging(H5C_t *cache); +H5_DLL herr_t H5C_stop_logging(H5C_t *cache); +H5_DLL herr_t H5C_get_logging_status(const H5C_t *cache, /*OUT*/ hbool_t *is_enabled, /*OUT*/ hbool_t *is_currently_logging); + #ifdef H5_HAVE_PARALLEL H5_DLL herr_t H5C_apply_candidate_list(H5F_t *f, H5C_t *cache_ptr, unsigned num_candidates, haddr_t *candidates_list_ptr, int mpi_rank, diff --git a/src/H5Cquery.c b/src/H5Cquery.c index e4f3133..51ce1c2 100644 --- a/src/H5Cquery.c +++ b/src/H5Cquery.c @@ -351,64 +351,6 @@ H5C_get_aux_ptr(const H5C_t *cache_ptr) /*------------------------------------------------------------------------- - * Function: H5C_get_trace_file_ptr - * - * Purpose: Get the trace_file_ptr field from the cache. - * - * This field will either be NULL (which indicates that trace - * file logging is turned off), or contain a pointer to the - * open file to which trace file data is to be written. - * - * Return: Non-NULL trace file pointer (can't fail) - * - * Programmer: John Mainzer - * 1/20/06 - * - *------------------------------------------------------------------------- - */ -FILE * -H5C_get_trace_file_ptr(const H5C_t *cache_ptr) -{ - FUNC_ENTER_NOAPI_NOERR - - /* Check arguments */ - HDassert(cache_ptr); - HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); - - FUNC_LEAVE_NOAPI(cache_ptr->trace_file_ptr) -} /* H5C_get_trace_file_ptr() */ - - -/*------------------------------------------------------------------------- - * Function: H5C_get_trace_file_ptr_from_entry - * - * Purpose: Get the trace_file_ptr field from the cache, via an entry. - * - * This field will either be NULL (which indicates that trace - * file logging is turned off), or contain a pointer to the - * open file to which trace file data is to be written. - * - * Return: Non-NULL trace file pointer (can't fail) - * - * Programmer: Quincey Koziol - * 6/9/08 - * - *------------------------------------------------------------------------- - */ -FILE * -H5C_get_trace_file_ptr_from_entry(const H5C_cache_entry_t *entry_ptr) -{ - FUNC_ENTER_NOAPI_NOERR - - /* Sanity checks */ - HDassert(entry_ptr); - HDassert(entry_ptr->cache_ptr); - - FUNC_LEAVE_NOAPI(H5C_get_trace_file_ptr(entry_ptr->cache_ptr)) -} /* H5C_get_trace_file_ptr_from_entry() */ - - -/*------------------------------------------------------------------------- * Function: H5C_get_entry_ring * * Purpose: Given a file address, retrieve the ring for an entry at that @@ -29,6 +29,8 @@ #include "H5Iprivate.h" /* IDs */ #include "H5VLprivate.h" /* Virtual Object Layer */ +#include "H5VLnative_private.h" /* Native VOL connector */ + /****************/ /* Local Macros */ @@ -1027,7 +1029,7 @@ H5Dformat_convert(hid_t dset_id) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set collective metadata read info") /* Convert the dataset */ - if(H5VL_dataset_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_DATASET_FORMAT_CONVERT) < 0) + if(H5VL_dataset_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_DATASET_FORMAT_CONVERT) < 0) HGOTO_ERROR(H5E_DATASET, H5E_INTERNAL, FAIL, "can't convert dataset format") done: @@ -1063,7 +1065,7 @@ H5Dget_chunk_index_type(hid_t dset_id, H5D_chunk_index_t *idx_type) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "idx_type parameter cannot be NULL") /* Get the chunk indexing type */ - if(H5VL_dataset_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_DATASET_GET_CHUNK_INDEX_TYPE, idx_type) < 0) + if(H5VL_dataset_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_DATASET_GET_CHUNK_INDEX_TYPE, idx_type) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get chunk index type") done: @@ -1104,7 +1106,7 @@ H5Dget_chunk_storage_size(hid_t dset_id, const hsize_t *offset, hsize_t *chunk_n HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "chunk_nbytes parameter cannot be NULL") /* Get the dataset creation property list */ - if(H5VL_dataset_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_DATASET_GET_CHUNK_STORAGE_SIZE, offset, chunk_nbytes) < 0) + if(H5VL_dataset_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_DATASET_GET_CHUNK_STORAGE_SIZE, offset, chunk_nbytes) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get storage size of chunk") done: diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index 91f3b91..b5a5c39 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -1493,6 +1493,9 @@ H5D__create_chunk_map_single(H5D_chunk_map_t *fm, const H5D_io_info_t /* Set chunk location & hyperslab size */ for(u = 0; u < fm->f_ndims; u++) { + /* Validate this chunk dimension */ + if(fm->layout->u.chunk.dim[u] == 0) + HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "chunk size must be > 0, dim = %u ", u) HDassert(sel_start[u] == sel_end[u]); chunk_info->scaled[u] = sel_start[u] / fm->layout->u.chunk.dim[u]; coords[u] = chunk_info->scaled[u] * fm->layout->u.chunk.dim[u]; @@ -1580,6 +1583,9 @@ H5D__create_chunk_file_map_hyper(H5D_chunk_map_t *fm, const H5D_io_info_t /* Set initial chunk location & hyperslab size */ for(u = 0; u < fm->f_ndims; u++) { + /* Validate this chunk dimension */ + if(fm->layout->u.chunk.dim[u] == 0) + HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "chunk size must be > 0, dim = %u ", u) scaled[u] = start_scaled[u] = sel_start[u] / fm->layout->u.chunk.dim[u]; coords[u] = start_coords[u] = scaled[u] * fm->layout->u.chunk.dim[u]; end[u] = (coords[u] + fm->chunk_dim[u]) - 1; @@ -4043,6 +4049,9 @@ H5D__chunk_allocate(const H5D_io_info_t *io_info, hbool_t full_overwrite, hsize_ * assume here that all elements of space_dim are > 0. This is checked at * the top of this function. */ for(op_dim=0; op_dim<space_ndims; op_dim++) { + /* Validate this chunk dimension */ + if(chunk_dim[op_dim] == 0) + HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "chunk size must be > 0, dim = %u ", op_dim) min_unalloc[op_dim] = (old_dim[op_dim] + chunk_dim[op_dim] - 1) / chunk_dim[op_dim]; max_unalloc[op_dim] = (space_dim[op_dim] - 1) / chunk_dim[op_dim]; @@ -4484,13 +4493,17 @@ H5D__chunk_update_old_edge_chunks(H5D_t *dset, hsize_t old_dim[]) /* Start off with this dimension marked as not needing to be modified */ new_full_dim[op_dim] = FALSE; + /* Validate this chunk dimension */ + if(chunk_dim[op_dim] == 0) + HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "chunk size must be > 0, dim = %u ", op_dim) + /* Calculate offset of first previously incomplete chunk in this * dimension */ - old_edge_chunk_sc[op_dim] = (old_dim[op_dim] / chunk_dim[op_dim]); + old_edge_chunk_sc[op_dim] = (old_dim[op_dim] / chunk_dim[op_dim]); /* Calculate the largest offset of chunks that might need to be * modified in this dimension */ - max_edge_chunk_sc[op_dim] = MIN((old_dim[op_dim] - 1) / chunk_dim[op_dim], + max_edge_chunk_sc[op_dim] = MIN((old_dim[op_dim] - 1) / chunk_dim[op_dim], MAX((space_dim[op_dim] / chunk_dim[op_dim]), 1) - 1); /* Check for old_dim aligned with chunk boundary in this dimension, if @@ -4626,6 +4639,8 @@ H5D__chunk_collective_fill(const H5D_t *dset, H5D_chunk_coll_info_t *chunk_info, HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "Can't retrieve MPI size") /* Distribute evenly the number of blocks between processes. */ + if(mpi_size == 0) + HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "Resulted in division by zero") num_blocks = chunk_info->num_io / mpi_size; /* value should be the same on all procs */ /* after evenly distributing the blocks between processes, are @@ -5066,6 +5081,10 @@ H5D__chunk_prune_by_extent(H5D_t *dset, const hsize_t *old_dim) HDmemset(min_mod_chunk_sc, 0, sizeof(min_mod_chunk_sc)); HDmemset(max_mod_chunk_sc, 0, sizeof(max_mod_chunk_sc)); for(op_dim = 0; op_dim < (unsigned)space_ndims; op_dim++) { + /* Validate this chunk dimension */ + if(chunk_dim[op_dim] == 0) + HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "chunk size must be > 0, dim = %u ", op_dim) + /* Calculate the largest offset of chunks that might need to be * modified in this dimension */ max_mod_chunk_sc[op_dim] = (old_dim[op_dim] - 1) / chunk_dim[op_dim]; @@ -5721,9 +5740,12 @@ H5D__chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) /* (background buffer has already been zeroed out, if not expanding) */ if(udata->cpy_info->expand_ref) { size_t ref_count; + size_t dt_size; /* Determine # of reference elements to copy */ - ref_count = nbytes / H5T_get_size(udata->dt_src); + if((dt_size = H5T_get_size(udata->dt_src)) == 0) + HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "size must not be 0") + ref_count = nbytes / dt_size; /* Copy the reference elements */ if(H5O_copy_expand_ref(udata->file_src, buf, udata->idx_info_dst->f, bkg, ref_count, H5T_get_ref_type(udata->dt_src), udata->cpy_info) < 0) diff --git a/src/H5Dint.c b/src/H5Dint.c index 6bb3343..7eb1aaf 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -25,6 +25,7 @@ #include "H5CXprivate.h" /* API Contexts */ #include "H5Dpkg.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* Files */ #include "H5FLprivate.h" /* Free Lists */ #include "H5FOprivate.h" /* File objects */ #include "H5Iprivate.h" /* IDs */ @@ -59,6 +60,9 @@ static herr_t H5D__init_storage(const H5D_io_info_t *io_info, hbool_t full_overw hsize_t old_dim[]); static herr_t H5D__append_flush_setup(H5D_t *dset, hid_t dapl_id); static herr_t H5D__close_cb(H5VL_object_t *dset_vol_obj); +static herr_t H5D__use_minimized_dset_headers(H5F_t *file, H5D_t *dset, hbool_t *minimize); +static herr_t H5D__prepare_minimized_oh(H5F_t *file, H5D_t *dset, H5O_loc_t *oloc); +static size_t H5D__calculate_minimum_header_size(H5F_t *file, H5D_t *dset, H5O_t *ohdr); /*********************/ @@ -658,6 +662,211 @@ done: /*------------------------------------------------------------------------- + * Function: H5D__use_minimized_dset_headers + * + * Purpose: Compartmentalize check for file- or dcpl-set values indicating + * to create a "minimized" dataset object header. + * Upon success, write resulting value to out pointer `minimize`. + * + * Return: Success: SUCCEED (0) (non-negative value) + * Failure: FAIL (-1) (negative value) + * + * Programmer: Jacob Smith + * 16 August 2018 + *------------------------------------------------------------------------- + */ +static herr_t +H5D__use_minimized_dset_headers(H5F_t *file, H5D_t *dset, hbool_t *minimize) +{ + H5P_genplist_t *plist = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI_NOINIT; + + HDassert(file); + HDassert(dset); + HDassert(minimize); + + plist = H5P_object_verify(dset->shared->dcpl_id, H5P_DATASET_CREATE); + if(NULL == plist) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "problem getting dcpl") + if(H5P_get(plist, H5D_CRT_MIN_DSET_HDR_SIZE_NAME, minimize) == FAIL) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get minimize value from dcpl") + + if(FALSE == *minimize) + *minimize = H5F_get_min_dset_ohdr(file); + +done: + if(FAIL == ret_value) + *minimize = FALSE; + FUNC_LEAVE_NOAPI(ret_value); +} /* H5D__use_minimized_dset_headers */ + + +/*------------------------------------------------------------------------- + * Function: H5D__calculate_minimium_header_size + * + * Purpose: Calculate the size required for the minimized object header. + * + * Return: Success: Positive value > 0 + * Failure: 0 + * + * Programmer: Jacob Smith + * 16 August 2018 + *------------------------------------------------------------------------- + */ +static size_t +H5D__calculate_minimum_header_size(H5F_t *file, H5D_t *dset, H5O_t *ohdr) +{ + H5T_t *type = NULL; + H5O_fill_t *fill_prop = NULL; + hbool_t use_at_least_v18 = FALSE; + const char continuation[1] = ""; /* requred for work-around */ + size_t get_value = 0; + size_t ret_value = 0; + + FUNC_ENTER_NOAPI_NOINIT; + + HDassert(file); + HDassert(dset); + HDassert(ohdr); + + type = dset->shared->type; + fill_prop = &(dset->shared->dcpl_cache.fill); + use_at_least_v18 = (H5F_LOW_BOUND(file) >= H5F_LIBVER_V18); + + /* Datatype message size */ + get_value = H5O_msg_size_oh(file, ohdr, H5O_DTYPE_ID, type, 0); + if (get_value == 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, 0, "Can't get size of datatype message") + ret_value += get_value; + + /* Shared Dataspace message size */ + get_value = H5O_msg_size_oh(file, ohdr, H5O_SDSPACE_ID, dset->shared->space, 0); + if (get_value == 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, 0, "can't get size of dataspace message") + ret_value += get_value; + + /* "Layout" message size */ + get_value = H5O_msg_size_oh(file, ohdr, H5O_LAYOUT_ID, &dset->shared->layout, 0); + if (get_value == 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, 0, "can't get size of layout message") + ret_value += get_value; + + /* Fill Value message size */ + get_value = H5O_msg_size_oh(file, ohdr, H5O_FILL_NEW_ID, fill_prop, 0); + if (get_value == 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, 0, "can't get size of fill value message") + ret_value += get_value; + + /* "Continuation" message size */ + /* message pointer "continuation" is unused by raw get function, however, + * a null pointer would be intercepted by an assert in H5O_msg_size_oh(). + */ + get_value = H5O_msg_size_oh(file, ohdr, H5O_CONT_ID, continuation, 0); + if (get_value == 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, 0, "can't get size of continuation message") + ret_value += get_value; + + /* Fill Value (backwards compatability) message size */ + if(fill_prop->buf && !use_at_least_v18) { + H5O_fill_t old_fill_prop; /* Copy for writing "old" fill value */ + + /* Shallow copy the fill value property */ + /* guards against shared component modification */ + HDmemcpy(&old_fill_prop, fill_prop, sizeof(old_fill_prop)); + + if (H5O_msg_reset_share(H5O_FILL_ID, &old_fill_prop) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, 0, "can't reset the copied fill property") + + get_value = H5O_msg_size_oh(file, ohdr, H5O_FILL_ID, &old_fill_prop, 0); + if (get_value == 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, 0, "can't get size of fill value (backwards compat) message") + ret_value += get_value; + } + + /* Filter/Pipeline message size */ + if(H5D_CHUNKED == dset->shared->layout.type) { + H5O_pline_t *pline = &dset->shared->dcpl_cache.pline; + if(pline->nused > 0) { + get_value = H5O_msg_size_oh(file, ohdr, H5O_PLINE_ID, pline, 0); + if (get_value == 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, 0, "can't get size of filter message") + ret_value += get_value; + } + } + + /* External File Link message size */ + if(dset->shared->dcpl_cache.efl.nused > 0) { + get_value = H5O_msg_size_oh(file, ohdr, H5O_EFL_ID, &dset->shared->dcpl_cache.efl, 0); + if (get_value == 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, 0, "can't get size of external file link message") + ret_value += get_value; + } + + /* Modification Time message size */ + if(H5O_HDR_STORE_TIMES & H5O_OH_GET_FLAGS(ohdr)) { + HDassert(H5O_OH_GET_VERSION(ohdr) >= 1); /* 1 :: H5O_VERSION_1 (H5Opkg.h) */ + + if(H5O_OH_GET_VERSION(ohdr) == 1) { + /* v1 object headers store modification time as a message */ + time_t mtime; + get_value = H5O_msg_size_oh(file, ohdr, H5O_MTIME_NEW_ID, &mtime, 0); + if (get_value == 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, 0, "can't get size of modification time message") + ret_value += get_value; + } + } + +done: + FUNC_LEAVE_NOAPI(ret_value); +} /* H5D__calculate_minimum_header_size */ + + +/*------------------------------------------------------------------------- + * Function: H5D__prepare_minimized_oh + * + * Purpose: Create an object header (H5O_t) allocated with the smallest + * possible size. + * + * Return: Success: SUCCEED (0) (non-negative value) + * Failure: FAIL (-1) (negative value) + * + * Programmer: Jacob Smith + * 16 August 2018 + *------------------------------------------------------------------------- + */ +static herr_t +H5D__prepare_minimized_oh(H5F_t *file, H5D_t *dset, H5O_loc_t *oloc) +{ + H5O_t *oh = NULL; + size_t ohdr_size = 0; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI_NOINIT; + + HDassert(file); + HDassert(dset); + HDassert(oloc); + + oh = H5O__create_ohdr(file, dset->shared->dcpl_id); + if(NULL == oh) + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "can't instantiate object header") + + ohdr_size = H5D__calculate_minimum_header_size(file, dset, oh); + if (ohdr_size == 0) + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "computed header size is invalid") + + /* Special allocation of space for compact datsets is handled by the call here. */ + if(H5O__apply_ohdr(file, oh, dset->shared->dcpl_id, ohdr_size, (size_t)1, oloc) == FAIL) + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "can't apply object header to file") + +done: + FUNC_LEAVE_NOAPI(ret_value); +} /* H5D__prepare_minimized_oh */ + + +/*------------------------------------------------------------------------- * Function: H5D__update_oh_info * * Purpose: Create and fill object header for dataset @@ -669,17 +878,18 @@ done: static herr_t H5D__update_oh_info(H5F_t *file, H5D_t *dset, hid_t dapl_id) { - H5O_t *oh = NULL; /* Pointer to dataset's object header */ - size_t ohdr_size = H5D_MINHDR_SIZE; /* Size of dataset's object header */ - H5O_loc_t *oloc = NULL; /* Dataset's object location */ - H5O_layout_t *layout; /* Dataset's layout information */ - H5T_t *type; /* Dataset's datatype */ - H5O_fill_t *fill_prop; /* Pointer to dataset's fill value information */ - H5D_fill_value_t fill_status; /* Fill value status */ - hbool_t fill_changed = FALSE; /* Flag indicating the fill value was changed */ - hbool_t layout_init = FALSE; /* Flag to indicate that chunk information was initialized */ - hbool_t use_at_least_v18; /* Flag indicating to use at least v18 format versions */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_t *oh = NULL; /* Pointer to dataset's object header */ + size_t ohdr_size = H5D_MINHDR_SIZE; /* Size of dataset's object header */ + H5O_loc_t *oloc = NULL; /* Dataset's object location */ + H5O_layout_t *layout; /* Dataset's layout information */ + H5T_t *type; /* Dataset's datatype */ + H5O_fill_t *fill_prop; /* Pointer to dataset's fill value information */ + H5D_fill_value_t fill_status; /* Fill value status */ + hbool_t fill_changed = FALSE; /* Flag indicating the fill value was changed */ + hbool_t layout_init = FALSE; /* Flag to indicate that chunk information was initialized */ + hbool_t use_at_least_v18; /* Flag indicating to use at least v18 format versions */ + hbool_t minimize_header = FALSE; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -747,13 +957,24 @@ H5D__update_oh_info(H5F_t *file, H5D_t *dset, hid_t dapl_id) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set fill value info") } /* end if */ - /* Add the dataset's raw data size to the size of the header, if the raw data will be stored as compact */ - if(layout->type == H5D_COMPACT) - ohdr_size += layout->storage.u.compact.size; + if(H5D__use_minimized_dset_headers(file, dset, &minimize_header) == FAIL) + HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get minimize settings") + + if(TRUE == minimize_header) { + if(H5D__prepare_minimized_oh(file, dset, oloc) == FAIL) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't create minimized dataset object header") + } else { + /* Add the dataset's raw data size to the size of the header, if the + * raw data will be stored as compact + */ + if(H5D_COMPACT == layout->type) + ohdr_size += layout->storage.u.compact.size; + + /* Create an object header for the dataset */ + if(H5O_create(file, ohdr_size, (size_t)1, dset->shared->dcpl_id, oloc/*out*/) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create dataset object header") + } /* If use minimum/standard object header space */ - /* Create an object header for the dataset */ - if(H5O_create(file, ohdr_size, (size_t)1, dset->shared->dcpl_id, oloc/*out*/) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create dataset object header") HDassert(file == dset->oloc.file); /* Pin the object header */ @@ -910,7 +1131,7 @@ H5D__build_file_prefix(const H5D_t *dset, hid_t dapl_id, const char *prefix_type HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") } /* end if */ else { - if (HDstrncmp(prefix, "${ORIGIN}", HDstrlen("${ORIGIN}")) == 0) { + if(HDstrncmp(prefix, "${ORIGIN}", HDstrlen("${ORIGIN}")) == 0) { /* Replace ${ORIGIN} at beginning of prefix by directory of HDF5 file */ filepath_len = HDstrlen(filepath); prefix_len = HDstrlen(prefix); diff --git a/src/H5Dio.c b/src/H5Dio.c index f977b0e..fe85d23 100644 --- a/src/H5Dio.c +++ b/src/H5Dio.c @@ -30,6 +30,8 @@ #include "H5MMprivate.h" /* Memory management */ #include "H5Sprivate.h" /* Dataspace */ +#include "H5VLnative_private.h" /* Native VOL connector */ + #ifdef H5_HAVE_PARALLEL /* Remove this if H5R_DATASET_REGION is no longer used in this file */ #include "H5Rpublic.h" @@ -242,7 +244,7 @@ H5Dread_chunk(hid_t dset_id, hid_t dxpl_id, const hsize_t *offset, uint32_t *fil H5CX_set_dxpl(dxpl_id); /* Read the raw chunk */ - if(H5VL_dataset_optional(vol_obj, dxpl_id, H5_REQUEST_NULL, H5VL_DATASET_CHUNK_READ, offset, filters, buf) < 0) + if(H5VL_dataset_optional(vol_obj, dxpl_id, H5_REQUEST_NULL, H5VL_NATIVE_DATASET_CHUNK_READ, offset, filters, buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read unprocessed chunk data") done: @@ -370,7 +372,7 @@ H5Dwrite_chunk(hid_t dset_id, hid_t dxpl_id, uint32_t filters, const hsize_t *of H5CX_set_dxpl(dxpl_id); /* Write chunk */ - if(H5VL_dataset_optional(vol_obj, dxpl_id, H5_REQUEST_NULL, H5VL_DATASET_CHUNK_WRITE, filters, offset, data_size_32, buf) < 0) + if(H5VL_dataset_optional(vol_obj, dxpl_id, H5_REQUEST_NULL, H5VL_NATIVE_DATASET_CHUNK_WRITE, filters, offset, data_size_32, buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write unprocessed chunk data") done: diff --git a/src/H5Dpkg.h b/src/H5Dpkg.h index 30652a5..2767aa1 100644 --- a/src/H5Dpkg.h +++ b/src/H5Dpkg.h @@ -110,15 +110,6 @@ typedef struct H5D_type_info_t { hbool_t bkg_buf_allocated; /* Whether the background buffer was allocated */ } H5D_type_info_t; -/* Types for dataset optional VOL operations */ -typedef enum H5VL_dataset_optional_t { - H5VL_DATASET_FORMAT_CONVERT, /* H5Dformat_convert (internal) */ - H5VL_DATASET_GET_CHUNK_INDEX_TYPE, /* H5Dget_chunk_index_type */ - H5VL_DATASET_GET_CHUNK_STORAGE_SIZE, /* H5Dget_chunk_storage_size */ - H5VL_DATASET_CHUNK_READ, /* H5Dchunk_read */ - H5VL_DATASET_CHUNK_WRITE, /* H5Dchunk_write */ -} H5VL_dataset_optional_t; - /* Forward declaration of structs used below */ struct H5D_io_info_t; struct H5D_chunk_map_t; diff --git a/src/H5Dprivate.h b/src/H5Dprivate.h index 4e9cda8..aaa3db2 100644 --- a/src/H5Dprivate.h +++ b/src/H5Dprivate.h @@ -45,6 +45,7 @@ #define H5D_CRT_FILL_VALUE_NAME "fill_value" /* Fill value */ #define H5D_CRT_ALLOC_TIME_STATE_NAME "alloc_time_state" /* Space allocation time state */ #define H5D_CRT_EXT_FILE_LIST_NAME "efl" /* External file list */ +#define H5D_CRT_MIN_DSET_HDR_SIZE_NAME "dset_oh_minimize"/* Minimize object header */ /* ======== Dataset access property names ======== */ #define H5D_ACS_DATA_CACHE_NUM_SLOTS_NAME "rdcc_nslots" /* Size of raw data chunk cache(slots) */ diff --git a/src/H5Dpublic.h b/src/H5Dpublic.h index a1ccda0..63f1a24 100644 --- a/src/H5Dpublic.h +++ b/src/H5Dpublic.h @@ -104,17 +104,6 @@ typedef enum H5D_vds_view_t { /* Callback for H5Pset_append_flush() in a dataset access property list */ typedef herr_t (*H5D_append_cb_t)(hid_t dataset_id, hsize_t *cur_dims, void *op_data); -/********************/ -/* Public Variables */ -/********************/ - -/*********************/ -/* Public Prototypes */ -/*********************/ -#ifdef __cplusplus -extern "C" { -#endif - /* Define the operator function pointer for H5Diterate() */ typedef herr_t (*H5D_operator_t)(void *elem, hid_t type_id, unsigned ndim, const hsize_t *point, void *operator_data); @@ -128,6 +117,18 @@ typedef herr_t (*H5D_scatter_func_t)(const void **src_buf/*out*/, typedef herr_t (*H5D_gather_func_t)(const void *dst_buf, size_t dst_buf_bytes_used, void *op_data); + +/********************/ +/* Public Variables */ +/********************/ + +/*********************/ +/* Public Prototypes */ +/*********************/ +#ifdef __cplusplus +extern "C" { +#endif + H5_DLL hid_t H5Dcreate2(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, hid_t lcpl_id, hid_t dcpl_id, hid_t dapl_id); H5_DLL hid_t H5Dcreate_anon(hid_t file_id, hid_t type_id, hid_t space_id, @@ -38,6 +38,8 @@ #include "H5Tprivate.h" /* Datatypes */ #include "H5VLprivate.h" /* Virtual Object Layer */ +#include "H5VLnative_private.h" /* Native VOL connector */ + /****************/ /* Local Macros */ @@ -545,7 +547,7 @@ H5Fget_vfd_handle(hid_t file_id, hid_t fapl_id, void **file_handle) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") /* Retrieve the VFD handle for the file */ - if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_FILE_GET_VFD_HANDLE, file_handle, fapl_id) < 0) + if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_FILE_GET_VFD_HANDLE, file_handle, fapl_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get VFD handle") done: @@ -651,11 +653,17 @@ H5Fcreate(const char *filename, unsigned flags, hid_t fcpl_id, hid_t fapl_id) if(H5CX_set_apl(&fapl_id, H5P_CLS_FACC, H5I_INVALID_HID, TRUE) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") - /* get the VOL info from the fapl */ + /* Get the VOL info from the fapl */ if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a file access property list") if(H5P_peek(plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't get VOL connector info") + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, "can't get VOL connector info") + + /* Stash a copy of the "top-level" connector property, before any pass-through + * connectors modify or unwrap it. + */ + if(H5CX_set_vol_connector_prop(&connector_prop) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set VOL connector info in API context") /* Adjust bit flags by turning on the creation bit and making sure that * the EXCL or TRUNC bit is set. All newly-created files are opened for @@ -731,7 +739,13 @@ H5Fopen(const char *filename, unsigned flags, hid_t fapl_id) if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a file access property list") if(H5P_peek(plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't get VOL connector info") + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, "can't get VOL connector info") + + /* Stash a copy of the "top-level" connector property, before any pass-through + * connectors modify or unwrap it. + */ + if(H5CX_set_vol_connector_prop(&connector_prop) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set VOL connector info in API context") /* Open the file through the VOL layer */ if(NULL == (new_file = (H5F_t *)H5VL_file_open(&connector_prop, filename, flags, fapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) @@ -778,7 +792,7 @@ H5Fflush(hid_t object_id, H5F_scope_t scope) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") /* Flush the object */ - if(H5VL_file_specific(vol_obj, H5VL_FILE_FLUSH, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, obj_type, scope) < 0) + if(H5VL_file_specific(vol_obj, H5VL_FILE_FLUSH, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, (int)obj_type, (int)scope) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush file") done: @@ -931,7 +945,7 @@ H5Fget_freespace(hid_t file_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid file identifier") /* Get the amount of free space in the file */ - if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_FILE_GET_FREE_SPACE, &ret_value) < 0) + if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_FILE_GET_FREE_SPACE, &ret_value) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, (-1), "unable to get file free space") done: @@ -966,7 +980,7 @@ H5Fget_filesize(hid_t file_id, hsize_t *size) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") /* Get the file size */ - if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_FILE_GET_SIZE, size) < 0) + if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_FILE_GET_SIZE, size) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get file size") done: @@ -1027,7 +1041,7 @@ H5Fget_file_image(hid_t file_id, void *buf_ptr, size_t buf_len) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "not a file ID") /* Get the file image */ - if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_FILE_GET_FILE_IMAGE, buf_ptr, &ret_value, buf_len) < 0) + if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_FILE_GET_FILE_IMAGE, buf_ptr, &ret_value, buf_len) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, (-1), "unable to get file image") done: @@ -1067,7 +1081,7 @@ H5Fget_mdc_config(hid_t file_id, H5AC_cache_config_t *config_ptr) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") /* Get the metadata cache configuration */ - if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_FILE_GET_MDC_CONF, config_ptr) < 0) + if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_FILE_GET_MDC_CONF, config_ptr) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get metadata cache configuration") done: @@ -1100,7 +1114,7 @@ H5Fset_mdc_config(hid_t file_id, H5AC_cache_config_t *config_ptr) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") /* Set the metadata cache configuration */ - if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_FILE_SET_MDC_CONFIG, config_ptr) < 0) + if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_FILE_SET_MDC_CONFIG, config_ptr) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to set metadata cache configuration") done: @@ -1136,7 +1150,7 @@ H5Fget_mdc_hit_rate(hid_t file_id, double *hit_rate_ptr) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") /* Get the current hit rate */ - if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_FILE_GET_MDC_HR, hit_rate_ptr) < 0) + if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_FILE_GET_MDC_HR, hit_rate_ptr) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get MDC hit rate") done: @@ -1173,7 +1187,7 @@ H5Fget_mdc_size(hid_t file_id, size_t *max_size_ptr, size_t *min_clean_size_ptr, HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") /* Get the size data */ - if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_FILE_GET_MDC_SIZE, max_size_ptr, min_clean_size_ptr, cur_size_ptr, cur_num_entries_ptr) < 0) + if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_FILE_GET_MDC_SIZE, max_size_ptr, min_clean_size_ptr, cur_size_ptr, cur_num_entries_ptr) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get MDC size") done: @@ -1211,7 +1225,7 @@ H5Freset_mdc_hit_rate_stats(hid_t file_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") /* Reset the hit rate statistic */ - if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_FILE_RESET_MDC_HIT_RATE) < 0) + if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_FILE_RESET_MDC_HIT_RATE) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't reset cache hit rate") done: @@ -1260,7 +1274,7 @@ H5Fget_name(hid_t obj_id, char *name/*out*/, size_t size) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid file identifier") /* Get the filename via the VOL */ - if(H5VL_file_get(vol_obj, H5VL_FILE_GET_NAME, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, type, size, name, &ret_value) < 0) + if(H5VL_file_get(vol_obj, H5VL_FILE_GET_NAME, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, (int)type, size, name, &ret_value) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, (-1), "unable to get file name") done: @@ -1305,7 +1319,7 @@ H5Fget_info2(hid_t obj_id, H5F_info2_t *finfo) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") /* Get the file information */ - if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_FILE_GET_INFO, type, finfo) < 0) + if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_FILE_GET_INFO, (int)type, finfo) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to retrieve file info") done: @@ -1333,7 +1347,7 @@ H5Fget_metadata_read_retry_info(hid_t file_id, H5F_retry_info_t *info) H5TRACE2("e", "i*x", file_id, info); /* Check args */ - if (!info) + if(!info) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct") /* Get the file pointer */ @@ -1341,7 +1355,7 @@ H5Fget_metadata_read_retry_info(hid_t file_id, H5F_retry_info_t *info) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") /* Get the retry info */ - if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_FILE_GET_METADATA_READ_RETRY_INFO, info) < 0) + if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_FILE_GET_METADATA_READ_RETRY_INFO, info) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't get metadata read retry info") done: @@ -1380,7 +1394,7 @@ H5Fget_free_sections(hid_t file_id, H5F_mem_t type, size_t nsects, HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "nsects must be > 0") /* Get the free-space section information in the file */ - if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_FILE_GET_FREE_SECTIONS, sect_info, &ret_value, type, nsects) < 0) + if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_FILE_GET_FREE_SECTIONS, sect_info, &ret_value, (int)type, nsects) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, (-1), "unable to get file free sections") done: @@ -1413,7 +1427,7 @@ H5Fclear_elink_file_cache(hid_t file_id) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") /* Release the EFC */ - if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_FILE_CLEAR_ELINK_CACHE) < 0) + if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_FILE_CLEAR_ELINK_CACHE) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't release external file cache") done: @@ -1473,7 +1487,7 @@ H5Fstart_swmr_write(hid_t file_id) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set collective metadata read info") /* Start SWMR writing */ - if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_FILE_START_SWMR_WRITE) < 0) + if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_FILE_START_SWMR_WRITE) < 0) HGOTO_ERROR(H5E_FILE, H5E_SYSTEM, FAIL, "unable to start SWMR writing") done: @@ -1505,8 +1519,8 @@ H5Fstart_mdc_logging(hid_t file_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "hid_t identifier is not a file ID") /* Call mdc logging function */ - if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_FILE_START_MDC_LOGGING) < 0) - HGOTO_ERROR(H5E_FILE, H5E_LOGFAIL, FAIL, "unable to start mdc logging") + if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_FILE_START_MDC_LOGGING) < 0) + HGOTO_ERROR(H5E_FILE, H5E_LOGGING, FAIL, "unable to start mdc logging") done: FUNC_LEAVE_API(ret_value) @@ -1538,8 +1552,8 @@ H5Fstop_mdc_logging(hid_t file_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "hid_t identifier is not a file ID") /* Call mdc logging function */ - if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_FILE_STOP_MDC_LOGGING) < 0) - HGOTO_ERROR(H5E_FILE, H5E_LOGFAIL, FAIL, "unable to stop mdc logging") + if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_FILE_STOP_MDC_LOGGING) < 0) + HGOTO_ERROR(H5E_FILE, H5E_LOGGING, FAIL, "unable to stop mdc logging") done: FUNC_LEAVE_API(ret_value) @@ -1572,8 +1586,8 @@ H5Fget_mdc_logging_status(hid_t file_id, hbool_t *is_enabled, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "hid_t identifier is not a file ID") /* Call mdc logging function */ - if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_FILE_GET_MDC_LOGGING_STATUS, is_enabled, is_currently_logging) < 0) - HGOTO_ERROR(H5E_FILE, H5E_LOGFAIL, FAIL, "unable to get logging status") + if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_FILE_GET_MDC_LOGGING_STATUS, is_enabled, is_currently_logging) < 0) + HGOTO_ERROR(H5E_FILE, H5E_LOGGING, FAIL, "unable to get logging status") done: FUNC_LEAVE_API(ret_value) @@ -1610,7 +1624,7 @@ H5Fset_libver_bounds(hid_t file_id, H5F_libver_t low, H5F_libver_t high) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set collective metadata read info") /* Set the library's version bounds */ - if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_FILE_SET_LIBVER_BOUNDS, low, high) < 0) + if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_FILE_SET_LIBVER_BOUNDS, low, high) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set library version bounds") done: @@ -1647,7 +1661,7 @@ H5Fformat_convert(hid_t file_id) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set collective metadata read info") /* Convert the format */ - if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_FILE_FORMAT_CONVERT) < 0) + if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_FILE_FORMAT_CONVERT) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCONVERT, FAIL, "can't convert file format") done: @@ -1678,7 +1692,7 @@ H5Freset_page_buffering_stats(hid_t file_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") /* Reset the statistics */ - if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_FILE_RESET_PAGE_BUFFERING_STATS) < 0) + if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_FILE_RESET_PAGE_BUFFERING_STATS) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't reset stats for page buffering") done: @@ -1713,7 +1727,7 @@ H5Fget_page_buffering_stats(hid_t file_id, unsigned accesses[2], unsigned hits[2 HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL input parameters for stats") /* Get the statistics */ - if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_FILE_GET_PAGE_BUFFERING_STATS, accesses, hits, misses, evictions, bypasses) < 0) + if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_FILE_GET_PAGE_BUFFERING_STATS, accesses, hits, misses, evictions, bypasses) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve stats for page buffering") done: @@ -1748,7 +1762,7 @@ H5Fget_mdc_image_info(hid_t file_id, haddr_t *image_addr, hsize_t *image_len) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "hid_t identifier is not a file ID") /* Go get the address and size of the cache image */ - if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_FILE_GET_MDC_IMAGE_INFO, image_addr, image_len) < 0) + if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_FILE_GET_MDC_IMAGE_INFO, image_addr, image_len) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve cache image info") done: @@ -1782,7 +1796,7 @@ H5Fget_eoa(hid_t file_id, haddr_t *eoa) /* Only do work if valid pointer to fill in */ if(eoa) { /* Retrieve the EOA for the file */ - if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_FILE_GET_EOA, eoa) < 0) + if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_FILE_GET_EOA, eoa) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get EOA") } /* end if */ @@ -1813,10 +1827,96 @@ H5Fincrement_filesize(hid_t file_id, hsize_t increment) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "hid_t identifier is not a file ID") /* Increment the file size */ - if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_FILE_INCR_FILESIZE, increment) < 0) + if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_FILE_INCR_FILESIZE, increment) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to increment file size") done: FUNC_LEAVE_API(ret_value) } /* H5Fincrement_filesize() */ + +/*------------------------------------------------------------------------- + * Function: H5Fget_dset_no_attrs_hint + * + * Purpose: + * + * Get the file-level setting to create minimized dataset object headers. + * Result is stored at pointer `minimize`. + * + * Return: + * + * Success: SUCCEED (0) (non-negative value) + * Failure: FAIL (-1) (negative value) + * + * Programmer: + * + * Jacob Smith + * 15 August 2018 + * + * Changes: None. + *------------------------------------------------------------------------- + */ +herr_t +H5Fget_dset_no_attrs_hint(hid_t file_id, hbool_t *minimize) +{ + H5VL_object_t *vol_obj = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE2("e", "i*b", file_id, minimize); + + if(NULL == minimize) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "out pointer 'minimize' cannot be NULL") + + vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE); + if(NULL == vol_obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") + + if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_FILE_GET_MIN_DSET_OHDR_FLAG, minimize) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to set file's dataset header minimization flag") + +done: + FUNC_LEAVE_API(ret_value) +} /* H5Fget_dset_no_attrs_hint */ + + +/*------------------------------------------------------------------------- + * Function: H5Fset_dset_no_attrs_hint + * + * Purpose: + * + * Set the file-level setting to create minimized dataset object headers. + * + * Return: + * + * Success: SUCCEED (0) (non-negative value) + * Failure: FAIL (-1) (negative value) + * + * Programmer: + * + * Jacob Smith + * 15 August 2018 + * + * Changes: None. + *------------------------------------------------------------------------- + */ +herr_t +H5Fset_dset_no_attrs_hint(hid_t file_id, hbool_t minimize) +{ + H5VL_object_t *vol_obj = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE2("e", "ib", file_id, minimize); + + vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE); + if(NULL == vol_obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") + + if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_FILE_SET_MIN_DSET_OHDR_FLAG, minimize) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to set file's dataset header minimization flag") + +done: + FUNC_LEAVE_API(ret_value) +} /* H5Fset_dset_no_attrs_hint */ + diff --git a/src/H5FDcore.c b/src/H5FDcore.c index 2ab04dc..ed05e95 100644 --- a/src/H5FDcore.c +++ b/src/H5FDcore.c @@ -54,6 +54,7 @@ typedef struct H5FD_core_t { haddr_t eof; /* current allocated size */ size_t increment; /* multiples for mem allocation */ hbool_t backing_store; /* write to file name on flush */ + hbool_t write_tracking; /* Whether to track writes */ size_t bstore_page_size; /* backing store page size */ int fd; /* backing store file descriptor */ /* Information for determining uniqueness of a file with a backing store */ @@ -93,10 +94,14 @@ typedef struct H5FD_core_t { typedef struct H5FD_core_fapl_t { size_t increment; /* how much to grow memory */ hbool_t backing_store; /* write to file name on flush */ + hbool_t write_tracking; /* Whether to track writes */ + size_t page_size; /* Page size for tracked writes */ } H5FD_core_fapl_t; /* Allocate memory in multiples of this size by default */ -#define H5FD_CORE_INCREMENT 8192 +#define H5FD_CORE_INCREMENT 8192 +#define H5FD_CORE_WRITE_TRACKING_FLAG FALSE +#define H5FD_CORE_WRITE_TRACKING_PAGE_SIZE 524288 /* These macros check for overflow of various quantities. These macros * assume that file_offset_t is signed and haddr_t and size_t are unsigned. @@ -415,8 +420,8 @@ done: * Purpose: Initialize this driver by registering the driver with the * library. * - * Return: Success: The driver ID for the core driver. - * Failure: Negative. + * Return: Success: The driver ID for the core driver + * Failure: H5I_INVALID_HID * * Programmer: Robb Matzke * Thursday, July 29, 1999 @@ -428,7 +433,7 @@ H5FD_core_init(void) { hid_t ret_value = H5I_INVALID_HID; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI(H5I_INVALID_HID) if(H5I_VFL != H5I_get_type(H5FD_CORE_g)) H5FD_CORE_g = H5FD_register(&H5FD_core_g, sizeof(H5FD_class_t), FALSE); @@ -466,6 +471,100 @@ H5FD__core_term(void) /*------------------------------------------------------------------------- + * Function: H5Pset_core_write_tracking + * + * Purpose: Enables/disables core VFD write tracking and page + * aggregation size. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Dana Robinson + * Tuesday, April 8, 2014 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Pset_core_write_tracking(hid_t plist_id, hbool_t is_enabled, size_t page_size) +{ + H5P_genplist_t *plist; /* Property list pointer */ + H5FD_core_fapl_t fa; /* Core VFD info */ + const H5FD_core_fapl_t *old_fa; /* Old core VFD info */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE3("e", "ibz", plist_id, is_enabled, page_size); + + /* The page size cannot be zero */ + if(page_size == 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "page_size cannot be zero") + + /* Get the plist structure */ + if(NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) + HGOTO_ERROR(H5E_PLIST, H5E_BADATOM, FAIL, "can't find object for ID") + if(H5FD_CORE != H5P_peek_driver(plist)) + HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver") + if(NULL == (old_fa = (const H5FD_core_fapl_t *)H5P_peek_driver_info(plist))) + HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "bad VFL driver info") + + /* Set VFD info values */ + HDmemset(&fa, 0, sizeof(H5FD_core_fapl_t)); + fa.increment = old_fa->increment; + fa.backing_store = old_fa->backing_store; + fa.write_tracking = is_enabled; + fa.page_size = page_size; + + /* Set the property values & the driver for the FAPL */ + if(H5P_set_driver(plist, H5FD_CORE, &fa) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set core VFD as driver") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Pset_core_write_tracking() */ + + +/*------------------------------------------------------------------------- + * Function: H5Pget_core_write_tracking + * + * Purpose: Gets information about core VFD write tracking and page + * aggregation size. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Dana Robinson + * Tuesday, April 8, 2014 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Pget_core_write_tracking(hid_t plist_id, hbool_t *is_enabled, size_t *page_size) +{ + H5P_genplist_t *plist; /* Property list pointer */ + const H5FD_core_fapl_t *fa; /* Core VFD info */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE3("e", "i*b*z", plist_id, is_enabled, page_size); + + /* Get the plist structure */ + if(NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) + HGOTO_ERROR(H5E_PLIST, H5E_BADATOM, FAIL, "can't find object for ID") + if(H5FD_CORE != H5P_peek_driver(plist)) + HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver") + if(NULL == (fa = (const H5FD_core_fapl_t *)H5P_peek_driver_info(plist))) + HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "bad VFL driver info") + + /* Get values */ + if(is_enabled) + *is_enabled = fa->write_tracking; + if(page_size) + *page_size = fa->page_size; + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Pget_core_write_tracking() */ + + +/*------------------------------------------------------------------------- * Function: H5Pset_fapl_core * * Purpose: Modify the file access property list to use the H5FD_CORE @@ -482,9 +581,9 @@ H5FD__core_term(void) herr_t H5Pset_fapl_core(hid_t fapl_id, size_t increment, hbool_t backing_store) { - H5FD_core_fapl_t fa; - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value; + H5P_genplist_t *plist; /* Property list pointer */ + H5FD_core_fapl_t fa; /* Core VFD info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "izb", fapl_id, increment, backing_store); @@ -493,10 +592,16 @@ H5Pset_fapl_core(hid_t fapl_id, size_t increment, hbool_t backing_store) if(NULL == (plist = H5P_object_verify(fapl_id,H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") + /* Set VFD info values */ + HDmemset(&fa, 0, sizeof(H5FD_core_fapl_t)); fa.increment = increment; fa.backing_store = backing_store; + fa.write_tracking = H5FD_CORE_WRITE_TRACKING_FLAG; + fa.page_size = H5FD_CORE_WRITE_TRACKING_PAGE_SIZE; - ret_value = H5P_set_driver(plist, H5FD_CORE, &fa); + /* Set the property values & the driver for the FAPL */ + if(H5P_set_driver(plist, H5FD_CORE, &fa) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set core VFD as driver") done: FUNC_LEAVE_API(ret_value) @@ -518,9 +623,9 @@ done: herr_t H5Pget_fapl_core(hid_t fapl_id, size_t *increment /*out*/, hbool_t *backing_store /*out*/) { - H5P_genplist_t *plist; /* Property list pointer */ - const H5FD_core_fapl_t *fa; - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + const H5FD_core_fapl_t *fa; /* Core VFD info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "ixx", fapl_id, increment, backing_store); @@ -559,7 +664,7 @@ static void * H5FD__core_fapl_get(H5FD_t *_file) { H5FD_core_t *file = (H5FD_core_t*)_file; - H5FD_core_fapl_t *fa; + H5FD_core_fapl_t *fa; /* Core VFD info */ void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -569,6 +674,8 @@ H5FD__core_fapl_get(H5FD_t *_file) fa->increment = file->increment; fa->backing_store = (hbool_t)(file->fd >= 0); + fa->write_tracking = file->write_tracking; + fa->page_size = file->bstore_page_size; /* Set return value */ ret_value = fa; @@ -776,35 +883,28 @@ H5FD__core_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr } /* end if */ } /* end if */ + /* Get the write tracking & page size */ + file->write_tracking = fa->write_tracking; + file->bstore_page_size = fa->page_size; + /* Set up write tracking if the backing store is on */ file->dirty_list = NULL; if(fa->backing_store) { - hbool_t write_tracking_flag = FALSE; /* what the user asked for */ hbool_t use_write_tracking = FALSE; /* what we're actually doing */ - /* Get the write tracking flag */ - if(H5P_get(plist, H5F_ACS_CORE_WRITE_TRACKING_FLAG_NAME, &write_tracking_flag) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get core VFD write tracking flag"); - - /* Get the page size */ - if(H5P_get(plist, H5F_ACS_CORE_WRITE_TRACKING_PAGE_SIZE_NAME, &(file->bstore_page_size)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get core VFD write tracking page size"); - /* default is to have write tracking OFF for create (hence the check to see * if the user explicitly set a page size) and ON with the default page size * on open (when not read-only). */ /* Only use write tracking if the file is open for writing */ - use_write_tracking = - TRUE == write_tracking_flag /* user asked for write tracking */ - && !(o_flags & O_RDONLY) /* file is open for writing (i.e. not read-only) */ - && file->bstore_page_size != 0; /* page size is not zero */ + use_write_tracking = (TRUE == fa->write_tracking) /* user asked for write tracking */ + && !(o_flags & O_RDONLY) /* file is open for writing (i.e. not read-only) */ + && (file->bstore_page_size != 0); /* page size is not zero */ /* initialize the dirty list */ - if(use_write_tracking) { + if(use_write_tracking) if(NULL == (file->dirty_list = H5SL_create(H5SL_TYPE_HADDR, NULL))) HGOTO_ERROR(H5E_SLIST, H5E_CANTCREATE, NULL, "can't create core vfd dirty region list"); - } /* end if */ } /* end if */ /* Set return value */ diff --git a/src/H5FDdirect.c b/src/H5FDdirect.c index 906ec28..10c368a 100644 --- a/src/H5FDdirect.c +++ b/src/H5FDdirect.c @@ -206,30 +206,27 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_direct_init + * Function: H5FD_direct_init * - * Purpose: Initialize this driver by registering the driver with the - * library. + * Purpose: Initialize this driver by registering the driver with the + * library. * - * Return: Success: The driver ID for the direct driver. - * - * Failure: Negative. + * Return: Success: The driver ID for the direct driver + * Failure: H5I_INVALID_HID * * Programmer: Raymond Lu * Wednesday, 20 September 2006 * - * Modifications: - * *------------------------------------------------------------------------- */ hid_t H5FD_direct_init(void) { - hid_t ret_value; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI(H5I_INVALID_HID) - if (H5I_VFL!=H5I_get_type(H5FD_DIRECT_g)) + if (H5I_VFL != H5I_get_type(H5FD_DIRECT_g)) H5FD_DIRECT_g = H5FD_register(&H5FD_direct_g,sizeof(H5FD_class_t),FALSE); /* Set return value */ @@ -237,7 +234,7 @@ H5FD_direct_init(void) done: FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5FD_direct_init() */ /*--------------------------------------------------------------------------- @@ -291,6 +288,7 @@ H5Pset_fapl_direct(hid_t fapl_id, size_t boundary, size_t block_size, size_t cbu if(NULL == (plist = H5P_object_verify(fapl_id,H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") + HDmemset(&fa, 0, sizeof(H5FD_direct_fapl_t)); if(boundary != 0) fa.mboundary = boundary; else @@ -417,7 +415,7 @@ static void * H5FD_direct_fapl_copy(const void *_old_fa) { const H5FD_direct_fapl_t *old_fa = (const H5FD_direct_fapl_t*)_old_fa; - H5FD_direct_fapl_t *new_fa = H5MM_malloc(sizeof(H5FD_direct_fapl_t)); + H5FD_direct_fapl_t *new_fa = H5MM_calloc(sizeof(H5FD_direct_fapl_t)); FUNC_ENTER_NOAPI_NOINIT_NOERR diff --git a/src/H5FDfamily.c b/src/H5FDfamily.c index e52a71a..4d40cf3 100644 --- a/src/H5FDfamily.c +++ b/src/H5FDfamily.c @@ -171,28 +171,25 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_family_init + * Function: H5FD_family_init * - * Purpose: Initialize this driver by registering the driver with the - * library. + * Purpose: Initialize this driver by registering the driver with the + * library. * - * Return: Success: The driver ID for the family driver. + * Return: Success: The driver ID for the family driver + * Failure: H5I_INVALID_HID * - * Failure: Negative - * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Wednesday, August 4, 1999 * - * Modifications: - * *------------------------------------------------------------------------- */ hid_t H5FD_family_init(void) { - hid_t ret_value = H5FD_FAMILY_g; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI(H5I_INVALID_HID) if(H5I_VFL != H5I_get_type(H5FD_FAMILY_g)) H5FD_FAMILY_g = H5FD_register(&H5FD_family_g, sizeof(H5FD_class_t), FALSE); diff --git a/src/H5FDlog.c b/src/H5FDlog.c index 3dcd7f5..97d1b41 100644 --- a/src/H5FDlog.c +++ b/src/H5FDlog.c @@ -252,8 +252,8 @@ done: * Purpose: Initialize this driver by registering the driver with the * library. * - * Return: Success: The driver ID for the log driver. - * Failure: Negative. + * Return: Success: The driver ID for the log driver + * Failure: H5I_INVALID_HID * * Programmer: Robb Matzke * Thursday, July 29, 1999 @@ -265,7 +265,7 @@ H5FD_log_init(void) { hid_t ret_value = H5I_INVALID_HID; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI(H5I_INVALID_HID) if(H5I_VFL != H5I_get_type(H5FD_LOG_g)) H5FD_LOG_g = H5FD_register(&H5FD_log_g, sizeof(H5FD_class_t), FALSE); @@ -329,6 +329,8 @@ H5Pset_fapl_log(hid_t fapl_id, const char *logfile, unsigned long long flags, si if(NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") + HDmemset(&fa, 0, sizeof(H5FD_log_fapl_t)); + /* This shallow copy is correct! The string will be properly * copied deep down in the H5P code. */ diff --git a/src/H5FDmpio.c b/src/H5FDmpio.c index a4b9ef3..911a5b6 100644 --- a/src/H5FDmpio.c +++ b/src/H5FDmpio.c @@ -73,69 +73,69 @@ typedef struct H5FD_mpio_t { /* Private Prototypes */ /* Callbacks */ -static herr_t H5FD_mpio_term(void); -static void *H5FD_mpio_fapl_get(H5FD_t *_file); -static void *H5FD_mpio_fapl_copy(const void *_old_fa); -static herr_t H5FD_mpio_fapl_free(void *_fa); -static H5FD_t *H5FD_mpio_open(const char *name, unsigned flags, hid_t fapl_id, +static herr_t H5FD__mpio_term(void); +static void *H5FD__mpio_fapl_get(H5FD_t *_file); +static void *H5FD__mpio_fapl_copy(const void *_old_fa); +static herr_t H5FD__mpio_fapl_free(void *_fa); +static H5FD_t *H5FD__mpio_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); -static herr_t H5FD_mpio_close(H5FD_t *_file); -static herr_t H5FD_mpio_query(const H5FD_t *_f1, unsigned long *flags); -static haddr_t H5FD_mpio_get_eoa(const H5FD_t *_file, H5FD_mem_t type); -static herr_t H5FD_mpio_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr); -static haddr_t H5FD_mpio_get_eof(const H5FD_t *_file, H5FD_mem_t type); -static herr_t H5FD_mpio_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle); -static herr_t H5FD_mpio_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, +static herr_t H5FD__mpio_close(H5FD_t *_file); +static herr_t H5FD__mpio_query(const H5FD_t *_f1, unsigned long *flags); +static haddr_t H5FD__mpio_get_eoa(const H5FD_t *_file, H5FD_mem_t type); +static herr_t H5FD__mpio_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr); +static haddr_t H5FD__mpio_get_eof(const H5FD_t *_file, H5FD_mem_t type); +static herr_t H5FD__mpio_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle); +static herr_t H5FD__mpio_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, void *buf); -static herr_t H5FD_mpio_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, +static herr_t H5FD__mpio_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, const void *buf); -static herr_t H5FD_mpio_flush(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); -static herr_t H5FD_mpio_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); -static int H5FD_mpio_mpi_rank(const H5FD_t *_file); -static int H5FD_mpio_mpi_size(const H5FD_t *_file); -static MPI_Comm H5FD_mpio_communicator(const H5FD_t *_file); -static herr_t H5FD_mpio_get_info(H5FD_t *_file, void** mpi_info); +static herr_t H5FD__mpio_flush(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); +static herr_t H5FD__mpio_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); +static int H5FD__mpio_mpi_rank(const H5FD_t *_file); +static int H5FD__mpio_mpi_size(const H5FD_t *_file); +static MPI_Comm H5FD__mpio_communicator(const H5FD_t *_file); +static herr_t H5FD__mpio_get_info(H5FD_t *_file, void** mpi_info); /* The MPIO file driver information */ static const H5FD_class_mpi_t H5FD_mpio_g = { { /* Start of superclass information */ "mpio", /*name */ HADDR_MAX, /*maxaddr */ - H5F_CLOSE_SEMI, /* fc_degree */ - H5FD_mpio_term, /*terminate */ + H5F_CLOSE_SEMI, /*fc_degree */ + H5FD__mpio_term, /*terminate */ NULL, /*sb_size */ NULL, /*sb_encode */ NULL, /*sb_decode */ sizeof(H5FD_mpio_fapl_t), /*fapl_size */ - H5FD_mpio_fapl_get, /*fapl_get */ - H5FD_mpio_fapl_copy, /*fapl_copy */ - H5FD_mpio_fapl_free, /*fapl_free */ + H5FD__mpio_fapl_get, /*fapl_get */ + H5FD__mpio_fapl_copy, /*fapl_copy */ + H5FD__mpio_fapl_free, /*fapl_free */ 0, /*dxpl_size */ NULL, /*dxpl_copy */ NULL, /*dxpl_free */ - H5FD_mpio_open, /*open */ - H5FD_mpio_close, /*close */ + H5FD__mpio_open, /*open */ + H5FD__mpio_close, /*close */ NULL, /*cmp */ - H5FD_mpio_query, /*query */ + H5FD__mpio_query, /*query */ NULL, /*get_type_map */ NULL, /*alloc */ NULL, /*free */ - H5FD_mpio_get_eoa, /*get_eoa */ - H5FD_mpio_set_eoa, /*set_eoa */ - H5FD_mpio_get_eof, /*get_eof */ - H5FD_mpio_get_handle, /*get_handle */ - H5FD_mpio_read, /*read */ - H5FD_mpio_write, /*write */ - H5FD_mpio_flush, /*flush */ - H5FD_mpio_truncate, /*truncate */ + H5FD__mpio_get_eoa, /*get_eoa */ + H5FD__mpio_set_eoa, /*set_eoa */ + H5FD__mpio_get_eof, /*get_eof */ + H5FD__mpio_get_handle, /*get_handle */ + H5FD__mpio_read, /*read */ + H5FD__mpio_write, /*write */ + H5FD__mpio_flush, /*flush */ + H5FD__mpio_truncate, /*truncate */ NULL, /*lock */ NULL, /*unlock */ H5FD_FLMAP_DICHOTOMY /*fl_map */ }, /* End of superclass information */ - H5FD_mpio_mpi_rank, /*get_rank */ - H5FD_mpio_mpi_size, /*get_size */ - H5FD_mpio_communicator, /*get_comm */ - H5FD_mpio_get_info /*get_info */ + H5FD__mpio_mpi_rank, /*get_rank */ + H5FD__mpio_mpi_size, /*get_size */ + H5FD__mpio_communicator, /*get_comm */ + H5FD__mpio_get_info /*get_info */ }; #ifdef H5FDmpio_DEBUG @@ -162,10 +162,13 @@ static int H5FD_mpio_Debug[256] = /*-------------------------------------------------------------------------- NAME H5FD__init_package -- Initialize interface-specific information + USAGE herr_t H5FD__init_package() + RETURNS Non-negative on success/Negative on failure + DESCRIPTION Initializes any interface-specific data or routines. (Just calls H5FD_mpio_init currently). @@ -187,15 +190,15 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_mpio_init + * Function: H5FD_mpio_init * - * Purpose: Initialize this driver by registering the driver with the - * library. + * Purpose: Initialize this driver by registering the driver with the + * library. * - * Return: Success: The driver ID for the mpio driver. - * Failure: Negative. + * Return: Success: The driver ID for the mpio driver + * Failure: H5I_INVALID_HID * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, August 5, 1999 * *------------------------------------------------------------------------- @@ -206,10 +209,10 @@ H5FD_mpio_init(void) #ifdef H5FDmpio_DEBUG static int H5FD_mpio_Debug_inited = 0; #endif /* H5FDmpio_DEBUG */ - const char *s; /* String for environment variables */ - hid_t ret_value; /* Return value */ + const char *s; /* String for environment variables */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI(H5I_INVALID_HID) /* Register the MPI-IO VFD, if it isn't already */ if(H5I_VFL != H5I_get_type(H5FD_MPIO_g)) @@ -217,8 +220,10 @@ H5FD_mpio_init(void) /* Allow MPI buf-and-file-type optimizations? */ s = HDgetenv("HDF5_MPI_OPT_TYPES"); - if(s && HDisdigit(*s)) - H5FD_mpi_opt_types_g = (hbool_t)HDstrtol(s, NULL, 0); + if(s && HDisdigit(*s)) { + long env_val = HDstrtol(s, NULL, 0); + H5FD_mpi_opt_types_g = (0 == env_val) ? FALSE : TRUE; + } #ifdef H5FDmpio_DEBUG if(!H5FD_mpio_Debug_inited) { @@ -226,12 +231,12 @@ H5FD_mpio_init(void) s = HDgetenv("H5FD_mpio_Debug"); if(s) { /* Set debug mask */ - while(*s) { - H5FD_mpio_Debug[(int)*s]++; - s++; - } /* end while */ + while(*s) { + H5FD_mpio_Debug[(int)*s]++; + s++; + } /* end while */ } /* end if */ - H5FD_mpio_Debug_inited++; + H5FD_mpio_Debug_inited++; } /* end if */ #endif /* H5FDmpio_DEBUG */ @@ -244,7 +249,7 @@ done: /*--------------------------------------------------------------------------- - * Function: H5FD_mpio_term + * Function: H5FD__mpio_term * * Purpose: Shut down the VFD * @@ -256,15 +261,15 @@ done: *--------------------------------------------------------------------------- */ static herr_t -H5FD_mpio_term(void) +H5FD__mpio_term(void) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC /* Reset VFL ID */ - H5FD_MPIO_g=0; + H5FD_MPIO_g = 0; FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5FD_mpio_term() */ +} /* end H5FD__mpio_term() */ /*------------------------------------------------------------------------- @@ -291,7 +296,6 @@ H5FD_mpio_term(void) * are freed. * * Return: Success: Non-negative - * * Failure: Negative * * Programmer: Albert Cheng @@ -309,16 +313,16 @@ H5Pset_fapl_mpio(hid_t fapl_id, MPI_Comm comm, MPI_Info info) FUNC_ENTER_API(FAIL) H5TRACE3("e", "iMcMi", fapl_id, comm, info); + /* Check arguments */ if(fapl_id == H5P_DEFAULT) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "can't set values in default property list") - - /* Check arguments */ if(NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a file access list") if(MPI_COMM_NULL == comm) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a valid communicator") /* Initialize driver specific properties */ + HDmemset(&fa, 0, sizeof(H5FD_mpio_fapl_t)); fa.comm = comm; fa.info = info; @@ -346,7 +350,6 @@ done: * modifications to the access property list do * not affect them and it is the responsibility * of the application to free them. - * * Failure: Negative * * Programmer: Robb Matzke @@ -367,6 +370,7 @@ H5Pget_fapl_mpio(hid_t fapl_id, MPI_Comm *comm/*out*/, MPI_Info *info/*out*/) FUNC_ENTER_API(FAIL) H5TRACE3("e", "ixx", fapl_id, comm, info); + /* Check arguments */ if(NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a file access list") if(H5FD_MPIO != H5P_peek_driver(plist)) @@ -439,10 +443,9 @@ H5Pset_dxpl_mpio(hid_t dxpl_id, H5FD_mpio_xfer_t xfer_mode) FUNC_ENTER_API(FAIL) H5TRACE2("e", "iDt", dxpl_id, xfer_mode); + /* Check arguments */ if(dxpl_id == H5P_DEFAULT) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "can't set values in default property list") - - /* Check arguments */ if(NULL == (plist = H5P_object_verify(dxpl_id, H5P_DATASET_XFER))) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a dxpl") if(H5FD_MPIO_INDEPENDENT != xfer_mode && H5FD_MPIO_COLLECTIVE != xfer_mode) @@ -466,7 +469,6 @@ done: * Return: Success: Non-negative, with the transfer mode returned * through the XFER_MODE argument if it is * non-null. - * * Failure: Negative * * Programmer: Albert Cheng @@ -483,6 +485,7 @@ H5Pget_dxpl_mpio(hid_t dxpl_id, H5FD_mpio_xfer_t *xfer_mode/*out*/) FUNC_ENTER_API(FAIL) H5TRACE2("e", "ix", dxpl_id, xfer_mode); + /* Check arguments */ if(NULL == (plist = H5P_object_verify(dxpl_id, H5P_DATASET_XFER))) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a dxpl") @@ -524,10 +527,9 @@ H5Pset_dxpl_mpio_collective_opt(hid_t dxpl_id, H5FD_mpio_collective_opt_t opt_mo FUNC_ENTER_API(FAIL) H5TRACE2("e", "iDc", dxpl_id, opt_mode); + /* Check arguments */ if(dxpl_id == H5P_DEFAULT) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "can't set values in default property list") - - /* Check arguments */ if(NULL == (plist = H5P_object_verify(dxpl_id, H5P_DATASET_XFER))) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a dxpl") @@ -568,10 +570,9 @@ H5Pset_dxpl_mpio_chunk_opt(hid_t dxpl_id, H5FD_mpio_chunk_opt_t opt_mode) FUNC_ENTER_API(FAIL) H5TRACE2("e", "iDh", dxpl_id, opt_mode); + /* Check arguments */ if(dxpl_id == H5P_DEFAULT) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "can't set values in default property list") - - /* Check arguments */ if(NULL == (plist = H5P_object_verify(dxpl_id, H5P_DATASET_XFER))) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a dxpl") @@ -610,10 +611,9 @@ H5Pset_dxpl_mpio_chunk_opt_num(hid_t dxpl_id, unsigned num_chunk_per_proc) FUNC_ENTER_API(FAIL) H5TRACE2("e", "iIu", dxpl_id, num_chunk_per_proc); + /* Check arguments */ if(dxpl_id == H5P_DEFAULT) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "can't set values in default property list") - - /* Check arguments */ if(NULL == (plist = H5P_object_verify(dxpl_id, H5P_DATASET_XFER))) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a dxpl") @@ -655,10 +655,9 @@ H5Pset_dxpl_mpio_chunk_opt_ratio(hid_t dxpl_id, unsigned percent_num_proc_per_ch FUNC_ENTER_API(FAIL) H5TRACE2("e", "iIu", dxpl_id, percent_num_proc_per_chunk); + /* Check arguments */ if(dxpl_id == H5P_DEFAULT) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "can't set values in default property list") - - /* Check arguments */ if(NULL == (plist = H5P_object_verify(dxpl_id, H5P_DATASET_XFER))) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a dxpl") @@ -672,14 +671,13 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_mpio_fapl_get + * Function: H5FD__mpio_fapl_get * * Purpose: Returns a file access property list which could be used to * create another file the same as this one. * * Return: Success: Ptr to new file access property list with all * fields copied from the file pointer. - * * Failure: NULL * * Programmer: Robb Matzke @@ -688,17 +686,19 @@ done: *------------------------------------------------------------------------- */ static void * -H5FD_mpio_fapl_get(H5FD_t *_file) +H5FD__mpio_fapl_get(H5FD_t *_file) { H5FD_mpio_t *file = (H5FD_mpio_t*)_file; H5FD_mpio_fapl_t *fa = NULL; void *ret_value; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC + /* Sanity checks */ HDassert(file); HDassert(H5FD_MPIO == file->pub.driver_id); + /* Check arguments */ if(NULL == (fa = (H5FD_mpio_fapl_t *)H5MM_calloc(sizeof(H5FD_mpio_fapl_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") @@ -711,16 +711,15 @@ H5FD_mpio_fapl_get(H5FD_t *_file) done: FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5FD__mpio_fapl_get() */ /*------------------------------------------------------------------------- - * Function: H5FD_mpio_fapl_copy + * Function: H5FD__mpio_fapl_copy * * Purpose: Copies the mpio-specific file access properties. * * Return: Success: Ptr to a new property list - * * Failure: NULL * * Programmer: Albert Cheng @@ -729,16 +728,17 @@ done: *------------------------------------------------------------------------- */ static void * -H5FD_mpio_fapl_copy(const void *_old_fa) +H5FD__mpio_fapl_copy(const void *_old_fa) { - void *ret_value = NULL; const H5FD_mpio_fapl_t *old_fa = (const H5FD_mpio_fapl_t*)_old_fa; H5FD_mpio_fapl_t *new_fa = NULL; + void *ret_value = NULL; + + FUNC_ENTER_STATIC - FUNC_ENTER_NOAPI_NOINIT #ifdef H5FDmpio_DEBUG -if (H5FD_mpio_Debug[(int)'t']) -fprintf(stderr, "enter H5FD_mpio_fapl_copy\n"); +if(H5FD_mpio_Debug[(int)'t']) + HDfprintf(stderr, "%s: entering\n", FUNC); #endif if(NULL == (new_fa = (H5FD_mpio_fapl_t *)H5MM_malloc(sizeof(H5FD_mpio_fapl_t)))) @@ -748,65 +748,68 @@ fprintf(stderr, "enter H5FD_mpio_fapl_copy\n"); HDmemcpy(new_fa, old_fa, sizeof(H5FD_mpio_fapl_t)); /* Duplicate communicator and Info object. */ - if(FAIL == H5FD_mpi_comm_info_dup(old_fa->comm, old_fa->info, &new_fa->comm, &new_fa->info)) + if(H5FD_mpi_comm_info_dup(old_fa->comm, old_fa->info, &new_fa->comm, &new_fa->info) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTCOPY, NULL, "Communicator/Info duplicate failed") + + /* Set return value */ ret_value = new_fa; done: - if (NULL == ret_value){ + if(NULL == ret_value) /* cleanup */ - if (new_fa) + if(new_fa) H5MM_xfree(new_fa); - } #ifdef H5FDmpio_DEBUG -if (H5FD_mpio_Debug[(int)'t']) -fprintf(stderr, "leaving H5FD_mpio_fapl_copy\n"); +if(H5FD_mpio_Debug[(int)'t']) + HDfprintf(stderr, "%s: leaving\n", FUNC); #endif + FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_mpio_fapl_copy() */ +} /* end H5FD__mpio_fapl_copy() */ /*------------------------------------------------------------------------- - * Function: H5FD_mpio_fapl_free + * Function: H5FD__mpio_fapl_free * * Purpose: Frees the mpio-specific file access properties. * * Return: Success: 0 - * * Failure: -1 * * Programmer: Albert Cheng * Jan 8, 2003 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t -H5FD_mpio_fapl_free(void *_fa) +H5FD__mpio_fapl_free(void *_fa) { - herr_t ret_value = SUCCEED; H5FD_mpio_fapl_t *fa = (H5FD_mpio_fapl_t*)_fa; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC - FUNC_ENTER_NOAPI_NOINIT_NOERR #ifdef H5FDmpio_DEBUG -if (H5FD_mpio_Debug[(int)'t']) -fprintf(stderr, "in H5FD_mpio_fapl_free\n"); +if(H5FD_mpio_Debug[(int)'t']) + HDfprintf(stderr, "%s: Entering\n", FUNC); #endif + + /* Sanity checks */ HDassert(fa); /* Free the internal communicator and INFO object */ - HDassert(MPI_COMM_NULL!=fa->comm); + HDassert(MPI_COMM_NULL != fa->comm); H5FD_mpi_comm_info_free(&fa->comm, &fa->info); H5MM_xfree(fa); #ifdef H5FDmpio_DEBUG -if (H5FD_mpio_Debug[(int)'t']) -fprintf(stderr, "leaving H5FD_mpio_fapl_free\n"); +if(H5FD_mpio_Debug[(int)'t']) + HDfprintf(stderr, "%s: leaving\n", FUNC); #endif + FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_mpio_fapl_free() */ +} /* end H5FD__mpio_fapl_free() */ /*------------------------------------------------------------------------- @@ -834,26 +837,27 @@ H5FD_set_mpio_atomicity(H5FD_t *_file, hbool_t flag) FUNC_ENTER_NOAPI_NOINIT #ifdef H5FDmpio_DEBUG - if (H5FD_mpio_Debug[(int)'t']) - fprintf(stdout, "Entering H5FD_set_mpio_atomicity\n"); + if(H5FD_mpio_Debug[(int)'t']) + HDfprintf(stdout, "%s: Entering\n", FUNC); #endif - if (FALSE == flag) + if(FALSE == flag) temp_flag = 0; else temp_flag = 1; /* set atomicity value */ - if (MPI_SUCCESS != (mpi_code=MPI_File_set_atomicity(file->f, temp_flag))) + if(MPI_SUCCESS != (mpi_code = MPI_File_set_atomicity(file->f, temp_flag))) HMPI_GOTO_ERROR(FAIL, "MPI_File_set_atomicity", mpi_code) done: #ifdef H5FDmpio_DEBUG - if (H5FD_mpio_Debug[(int)'t']) - fprintf(stdout, "Leaving H5FD_set_mpio_atomicity\n"); + if(H5FD_mpio_Debug[(int)'t']) + HDfprintf(stdout, "%s: Leaving\n", FUNC); #endif + FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5FD_set_mpio_atomicity() */ /*------------------------------------------------------------------------- @@ -881,30 +885,31 @@ H5FD_get_mpio_atomicity(H5FD_t *_file, hbool_t *flag) FUNC_ENTER_NOAPI_NOINIT #ifdef H5FDmpio_DEBUG - if (H5FD_mpio_Debug[(int)'t']) - fprintf(stdout, "Entering H5FD_get_mpio_atomicity\n"); + if(H5FD_mpio_Debug[(int)'t']) + HDfprintf(stdout, "%s: Entering\n", FUNC); #endif - /* get atomicity value */ - if (MPI_SUCCESS != (mpi_code=MPI_File_get_atomicity(file->f, &temp_flag))) + /* Get atomicity value */ + if(MPI_SUCCESS != (mpi_code = MPI_File_get_atomicity(file->f, &temp_flag))) HMPI_GOTO_ERROR(FAIL, "MPI_File_get_atomicity", mpi_code) - if (0 != temp_flag) + if(0 != temp_flag) *flag = TRUE; else *flag = FALSE; done: #ifdef H5FDmpio_DEBUG - if (H5FD_mpio_Debug[(int)'t']) - fprintf(stdout, "Leaving H5FD_get_mpio_atomicity\n"); + if(H5FD_mpio_Debug[(int)'t']) + HDfprintf(stdout, "%s: Leaving\n", FUNC); #endif + FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5FD_get_mpio_atomicity() */ /*------------------------------------------------------------------------- - * Function: H5FD_mpio_open + * Function: H5FD__mpio_open * * Purpose: Opens a file with name NAME. The FLAGS are a bit field with * purpose similar to the second argument of open(2) and which @@ -914,21 +919,20 @@ done: * access. This is collective. * * Return: Success: A new file pointer. - * * Failure: NULL * - * Programmer: + * Programmer: Robert Kim Yates * January 30, 1998 * *------------------------------------------------------------------------- */ static H5FD_t * -H5FD_mpio_open(const char *name, unsigned flags, hid_t fapl_id, - haddr_t H5_ATTR_UNUSED maxaddr) +H5FD__mpio_open(const char *name, unsigned flags, hid_t fapl_id, + haddr_t H5_ATTR_UNUSED maxaddr) { - H5FD_mpio_t *file=NULL; + H5FD_mpio_t *file = NULL; MPI_File fh; - unsigned file_opened=0; /* Flag to indicate that the file was successfully opened */ + unsigned file_opened = 0; /* Flag to indicate that the file was successfully opened */ int mpi_amode; int mpi_rank; /* MPI rank of this process */ int mpi_size; /* Total number of MPI processes */ @@ -941,13 +945,11 @@ H5FD_mpio_open(const char *name, unsigned flags, hid_t fapl_id, MPI_Info info_dup = MPI_INFO_NULL; H5FD_t *ret_value; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC #ifdef H5FDmpio_DEBUG - if (H5FD_mpio_Debug[(int)'t']) { - fprintf(stdout, "Entering H5FD_mpio_open(name=\"%s\", flags=0x%x, " - "fapl_id=%d, maxaddr=%lu)\n", name, flags, (int)fapl_id, (unsigned long)maxaddr); - } + if(H5FD_mpio_Debug[(int)'t']) + HDfprintf(stdout, "%s: Entering - name = \"%s\", flags = 0x%x, fapl_id = %d, maxaddr = %lu\n", FUNC, name, flags, (int)fapl_id, (unsigned long)maxaddr); #endif /* Obtain a pointer to mpio-specific file access properties */ @@ -958,10 +960,9 @@ H5FD_mpio_open(const char *name, unsigned flags, hid_t fapl_id, _fa.info = MPI_INFO_NULL; /*default*/ fa = &_fa; } /* end if */ - else { + else if(NULL == (fa = (const H5FD_mpio_fapl_t *)H5P_peek_driver_info(plist))) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, NULL, "bad VFL driver info") - } /* end else */ /* Duplicate communicator and Info object for use by this file. */ if(FAIL == H5FD_mpi_comm_info_dup(fa->comm, fa->info, &comm_dup, &info_dup)) @@ -977,21 +978,19 @@ H5FD_mpio_open(const char *name, unsigned flags, hid_t fapl_id, #ifdef H5FDmpio_DEBUG /* Check for debug commands in the info parameter */ - { - if(MPI_INFO_NULL != info_dup) { - char debug_str[128]; - int flag; - - MPI_Info_get(fa->info, H5F_MPIO_DEBUG_KEY, sizeof(debug_str) - 1, debug_str, &flag); - if(flag) { - int i; - - fprintf(stdout, "H5FD_mpio debug flags = '%s'\n", debug_str); - for(i = 0; debug_str[i]/*end of string*/ && i < 128/*just in case*/; ++i) - H5FD_mpio_Debug[(int)debug_str[i]] = 1; - } - } - } + if(MPI_INFO_NULL != info_dup) { + char debug_str[128]; + int flag; + + MPI_Info_get(fa->info, H5F_MPIO_DEBUG_KEY, sizeof(debug_str) - 1, debug_str, &flag); + if(flag) { + int i; + + HDfprintf(stdout, "H5FD_mpio debug flags = '%s'\n", debug_str); + for(i = 0; debug_str[i]/*end of string*/ && i < 128/*just in case*/; ++i) + H5FD_mpio_Debug[(int)debug_str[i]] = 1; + } /* end if */ + } /* end if */ #endif if(MPI_SUCCESS != (mpi_code = MPI_File_open(comm_dup, name, mpi_amode, info_dup, &fh))) @@ -1041,69 +1040,62 @@ H5FD_mpio_open(const char *name, unsigned flags, hid_t fapl_id, file->local_eof = file->eof; /* Set return value */ - ret_value=(H5FD_t*)file; + ret_value = (H5FD_t*)file; done: - if(ret_value==NULL) { + if(ret_value == NULL) { if(file_opened) MPI_File_close(&fh); - if (MPI_COMM_NULL != comm_dup) + if(MPI_COMM_NULL != comm_dup) MPI_Comm_free(&comm_dup); - if (MPI_INFO_NULL != info_dup) + if(MPI_INFO_NULL != info_dup) MPI_Info_free(&info_dup); - if (file) + if(file) H5MM_xfree(file); } /* end if */ #ifdef H5FDmpio_DEBUG - if (H5FD_mpio_Debug[(int)'t']) - fprintf(stdout, "Leaving H5FD_mpio_open\n" ); + if(H5FD_mpio_Debug[(int)'t']) + HDfprintf(stdout, "%s: Leaving\n", FUNC); #endif + FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_mpio_open() */ +} /* end H5FD__mpio_open() */ /*------------------------------------------------------------------------- - * Function: H5FD_mpio_close + * Function: H5FD__mpio_close * * Purpose: Closes a file. This is collective. * * Return: Success: Non-negative - * * Failure: Negative * * Programmer: Unknown * January 30, 1998 * - * Modifications: - * Robb Matzke, 1998-02-18 - * Added the ACCESS_PARMS argument. - * - * Robb Matzke, 1999-08-06 - * Modified to work with the virtual file layer. - * - * Albert Cheng, 2003-04-17 - * Free the communicator stored. *------------------------------------------------------------------------- */ static herr_t -H5FD_mpio_close(H5FD_t *_file) +H5FD__mpio_close(H5FD_t *_file) { H5FD_mpio_t *file = (H5FD_mpio_t*)_file; int mpi_code; /* MPI return code */ - herr_t ret_value=SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC #ifdef H5FDmpio_DEBUG - if (H5FD_mpio_Debug[(int)'t']) - fprintf(stdout, "Entering H5FD_mpio_close\n"); + if(H5FD_mpio_Debug[(int)'t']) + HDfprintf(stdout, "%s: Entering\n", FUNC); #endif + + /* Sanity checks */ HDassert(file); - HDassert(H5FD_MPIO==file->pub.driver_id); + HDassert(H5FD_MPIO == file->pub.driver_id); /* MPI_File_close sets argument to MPI_FILE_NULL */ - if (MPI_SUCCESS != (mpi_code=MPI_File_close(&(file->f)/*in,out*/))) + if(MPI_SUCCESS != (mpi_code = MPI_File_close(&(file->f)/*in,out*/))) HMPI_GOTO_ERROR(FAIL, "MPI_File_close failed", mpi_code) /* Clean up other stuff */ @@ -1112,45 +1104,36 @@ H5FD_mpio_close(H5FD_t *_file) done: #ifdef H5FDmpio_DEBUG - if (H5FD_mpio_Debug[(int)'t']) - fprintf(stdout, "Leaving H5FD_mpio_close\n"); + if(H5FD_mpio_Debug[(int)'t']) + HDfprintf(stdout, "%s: Leaving\n", FUNC); #endif + FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5FD__mpio_close() */ /*------------------------------------------------------------------------- - * Function: H5FD_mpio_query + * Function: H5FD__mpio_query * * Purpose: Set the flags that this VFL driver is capable of supporting. * (listed in H5FDpublic.h) * * Return: Success: non-negative - * * Failure: negative * * Programmer: Quincey Koziol * Friday, August 25, 2000 * - * Modifications: - * - * John Mainzer -- 9/21/05 - * Modified code to turn off the - * H5FD_FEAT_ACCUMULATE_METADATA_WRITE flag. - * With the movement of - * all cache writes to process 0, this flag has become - * problematic in PHDF5. - * *------------------------------------------------------------------------- */ static herr_t -H5FD_mpio_query(const H5FD_t H5_ATTR_UNUSED *_file, unsigned long *flags /* out */) +H5FD__mpio_query(const H5FD_t H5_ATTR_UNUSED *_file, unsigned long *flags /* out */) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC /* Set the VFL feature flags that this driver supports */ if(flags) { - *flags=0; + *flags = 0; *flags |= H5FD_FEAT_AGGREGATE_METADATA; /* OK to aggregate metadata allocations */ *flags |= H5FD_FEAT_AGGREGATE_SMALLDATA; /* OK to aggregate "small" raw data allocations */ *flags |= H5FD_FEAT_HAS_MPI; /* This driver uses MPI */ @@ -1159,83 +1142,73 @@ H5FD_mpio_query(const H5FD_t H5_ATTR_UNUSED *_file, unsigned long *flags /* out } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) -} +} /* end H5FD__mpio_query() */ /*------------------------------------------------------------------------- - * Function: H5FD_mpio_get_eoa + * Function: H5FD__mpio_get_eoa * * Purpose: Gets the end-of-address marker for the file. The EOA marker * is the first address past the last byte allocated in the * format address space. * * Return: Success: The end-of-address marker. - * * Failure: HADDR_UNDEF * * Programmer: Robb Matzke * Friday, August 6, 1999 * - * Modifications: - * Raymond Lu - * 21 Dec. 2006 - * Added the parameter TYPE. It's only used for MULTI driver. - * *------------------------------------------------------------------------- */ static haddr_t -H5FD_mpio_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) +H5FD__mpio_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) { const H5FD_mpio_t *file = (const H5FD_mpio_t*)_file; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC + /* Sanity checks */ HDassert(file); - HDassert(H5FD_MPIO==file->pub.driver_id); + HDassert(H5FD_MPIO == file->pub.driver_id); FUNC_LEAVE_NOAPI(file->eoa) -} +} /* end H5FD__mpio_get_eoa() */ /*------------------------------------------------------------------------- - * Function: H5FD_mpio_set_eoa + * Function: H5FD__mpio_set_eoa * * Purpose: Set the end-of-address marker for the file. This function is * called shortly after an existing HDF5 file is opened in order * to tell the driver where the end of the HDF5 data is located. * * Return: Success: 0 - * * Failure: -1 * * Programmer: Robb Matzke * Friday, August 6, 1999 * - * Modifications: - * Raymond Lu - * 21 Dec. 2006 - * Added the parameter TYPE. It's only used for MULTI driver. - * *------------------------------------------------------------------------- */ static herr_t -H5FD_mpio_set_eoa(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr) +H5FD__mpio_set_eoa(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr) { H5FD_mpio_t *file = (H5FD_mpio_t*)_file; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC + /* Sanity checks */ HDassert(file); - HDassert(H5FD_MPIO==file->pub.driver_id); + HDassert(H5FD_MPIO == file->pub.driver_id); file->eoa = addr; FUNC_LEAVE_NOAPI(SUCCEED) -} +} /* end H5FD__mpio_set_eoa() */ /*------------------------------------------------------------------------- - * Function: H5FD_mpio_get_eof + * Function: H5FD__mpio_get_eof * * Purpose: Gets the end-of-file marker for the file. The EOF marker * is the real size of the file. @@ -1253,32 +1226,30 @@ H5FD_mpio_set_eoa(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr) * file. -QAK * * Return: Success: The end-of-address marker. - * * Failure: HADDR_UNDEF * * Programmer: Robb Matzke * Friday, August 6, 1999 * - * Modifications: - * *------------------------------------------------------------------------- */ static haddr_t -H5FD_mpio_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) +H5FD__mpio_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) { const H5FD_mpio_t *file = (const H5FD_mpio_t*)_file; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC + /* Sanity checks */ HDassert(file); - HDassert(H5FD_MPIO==file->pub.driver_id); + HDassert(H5FD_MPIO == file->pub.driver_id); FUNC_LEAVE_NOAPI(file->eof) -} +} /* end H5FD__mpio_get_eof() */ /*------------------------------------------------------------------------- - * Function: H5FD_mpio_get_handle + * Function: H5FD__mpio_get_handle * * Purpose: Returns the file handle of MPIO file driver. * @@ -1287,17 +1258,15 @@ H5FD_mpio_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) * Programmer: Raymond Lu * Sept. 16, 2002 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t -H5FD_mpio_get_handle(H5FD_t *_file, hid_t H5_ATTR_UNUSED fapl, void** file_handle) +H5FD__mpio_get_handle(H5FD_t *_file, hid_t H5_ATTR_UNUSED fapl, void** file_handle) { - H5FD_mpio_t *file = (H5FD_mpio_t *)_file; - herr_t ret_value = SUCCEED; + H5FD_mpio_t *file = (H5FD_mpio_t *)_file; + herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC if(!file_handle) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file handle not valid") @@ -1306,7 +1275,7 @@ H5FD_mpio_get_handle(H5FD_t *_file, hid_t H5_ATTR_UNUSED fapl, void** file_handl done: FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5FD__mpio_get_handle() */ /*------------------------------------------------------------------------- @@ -1343,7 +1312,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_mpio_read + * Function: H5FD__mpio_read * * Purpose: Reads SIZE bytes of data from FILE beginning at address ADDR * into buffer BUF according to data transfer properties in @@ -1361,59 +1330,13 @@ done: * * Programmer: rky, 1998-01-30 * - * Modifications: - * Robb Matzke, 1998-02-18 - * Added the ACCESS_PARMS argument. - * - * rky, 1998-04-10 - * Call independent or collective MPI read, based on - * ACCESS_PARMS. - * - * Albert Cheng, 1998-06-01 - * Added XFER_MODE to control independent or collective MPI - * read. - * - * rky, 1998-08-16 - * Use BTYPE, FTYPE, and DISP from access parms. The guts of - * H5FD_mpio_read and H5FD_mpio_write should be replaced by a - * single dual-purpose routine. - * - * Robb Matzke, 1999-04-21 - * Changed XFER_MODE to XFER_PARMS for all H5F_*_read() - * callbacks. - * - * Robb Matzke, 1999-07-28 - * The ADDR argument is passed by value. - * - * Robb Matzke, 1999-08-06 - * Modified to work with the virtual file layer. - * - * Quincey Koziol, 2002-05-14 - * Only call MPI_Get_count if we can use MPI_BYTE for the MPI type - * for the I/O transfer. Someday we might include code to decode - * the MPI type used for more complicated transfers and call - * MPI_Get_count all the time. - * - * Quincey Koziol - 2002/06/17 - * Removed 'disp' parameter from H5FD_mpio_setup routine and use - * the address of the dataset in MPI_File_set_view() calls, as - * necessary. - * - * Quincey Koziol - 2002/06/24 - * Removed "lazy" MPI_File_set_view() calls, since they would fail - * if the first I/O was a collective I/O using MPI derived types - * and the next I/O was an independent I/O. - * - * Quincey Koziol - 2003/10/22-31 - * Restructured code massively, straightening out logic and finally - * getting the bytes_read stuff working. - * *------------------------------------------------------------------------- */ static herr_t -H5FD_mpio_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, +H5FD__mpio_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, size_t size, void *buf/*out*/) { +<<<<<<< HEAD H5FD_mpio_t *file = (H5FD_mpio_t*)_file; MPI_Offset mpi_off; MPI_Status mpi_stat; /* Status from I/O operation */ @@ -1434,13 +1357,41 @@ H5FD_mpio_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hbool_t use_view_this_time = FALSE; hbool_t Proc0_BCast_enabled = FALSE; /* If read-proc0-and-bcast option was used */ herr_t ret_value = SUCCEED; +======= + H5FD_mpio_t *file = (H5FD_mpio_t*)_file; + MPI_Offset mpi_off; + MPI_Status mpi_stat; /* Status from I/O operation */ + int mpi_code; /* mpi return code */ + MPI_Datatype buf_type = MPI_BYTE; /* MPI description of the selection in memory */ + int size_i; /* Integer copy of 'size' to read */ +#if MPI_VERSION >= 3 + MPI_Count bytes_read = 0; /* Number of bytes read in */ + MPI_Count type_size; /* MPI datatype used for I/O's size */ + MPI_Count io_size; /* Actual number of bytes requested */ + MPI_Count n; +#else + int bytes_read = 0; /* Number of bytes read in */ + int type_size; /* MPI datatype used for I/O's size */ + int io_size; /* Actual number of bytes requested */ + int n; +#endif + hbool_t use_view_this_time = FALSE; + herr_t ret_value = SUCCEED; +>>>>>>> 7bf6d847ae36940f1b1147820356795c7764dbeb - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC #ifdef H5FDmpio_DEBUG +<<<<<<< HEAD if (H5FD_mpio_Debug[(int)'t']) fprintf(stdout, "Entering H5FD_mpio_read\n" ); +======= + if(H5FD_mpio_Debug[(int)'t']) + HDfprintf(stdout, "%s: Entering\n", FUNC); +>>>>>>> 7bf6d847ae36940f1b1147820356795c7764dbeb #endif + + /* Sanity checks */ HDassert(file); HDassert(H5FD_MPIO==file->pub.driver_id); HDassert(buf); @@ -1449,16 +1400,21 @@ H5FD_mpio_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, HDmemset(&mpi_stat,0,sizeof(MPI_Status)); /* some numeric conversions */ - if (H5FD_mpi_haddr_to_MPIOff(addr, &mpi_off/*out*/)<0) + if(H5FD_mpi_haddr_to_MPIOff(addr, &mpi_off/*out*/) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_BADRANGE, FAIL, "can't convert from haddr to MPI off") size_i = (int)size; - if ((hsize_t)size_i != size) + if((hsize_t)size_i != size) HGOTO_ERROR(H5E_INTERNAL, H5E_BADRANGE, FAIL, "can't convert from size to size_i") #ifdef H5FDmpio_DEBUG +<<<<<<< HEAD if (H5FD_mpio_Debug[(int)'r']) fprintf(stdout, "in H5FD_mpio_read mpi_off=%ld size_i=%d\n", (long)mpi_off, size_i ); +======= + if(H5FD_mpio_Debug[(int)'r']) + HDfprintf(stdout, "%s: mpi_off = %ld size_i = %d\n", FUNC, (long)mpi_off, size_i); +>>>>>>> 7bf6d847ae36940f1b1147820356795c7764dbeb #endif /* Only look for MPI views for raw data transfers */ @@ -1475,7 +1431,11 @@ H5FD_mpio_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, * us to test that btype=ftype=MPI_BYTE (or even MPI_TYPE_NULL, which * could mean "use MPI_BYTE" by convention). */ +<<<<<<< HEAD if(xfer_mode==H5FD_MPIO_COLLECTIVE) { +======= + if(xfer_mode == H5FD_MPIO_COLLECTIVE) { +>>>>>>> 7bf6d847ae36940f1b1147820356795c7764dbeb MPI_Datatype file_type; /* Remember that views are used */ @@ -1503,8 +1463,13 @@ H5FD_mpio_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, H5FD_mpio_collective_opt_t coll_opt_mode; #ifdef H5FDmpio_DEBUG +<<<<<<< HEAD if (H5FD_mpio_Debug[(int)'t']) fprintf(stdout, "H5FD_mpio_read: using MPIO collective mode\n"); +======= + if(H5FD_mpio_Debug[(int)'r']) + HDfprintf(stdout, "%s: using MPIO collective mode\n", FUNC); +>>>>>>> 7bf6d847ae36940f1b1147820356795c7764dbeb #endif /* Get the collective_opt property to check whether the application wants to do IO individually. */ if(H5CX_get_mpio_coll_opt(&coll_opt_mode) < 0) @@ -1512,8 +1477,8 @@ H5FD_mpio_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, if(coll_opt_mode == H5FD_MPIO_COLLECTIVE_IO) { #ifdef H5FDmpio_DEBUG - if(H5FD_mpio_Debug[(int)'t']) - fprintf(stdout, "H5FD_mpio_read: doing MPI collective IO\n"); + if(H5FD_mpio_Debug[(int)'r']) + HDfprintf(stdout, "%s: doing MPI collective IO\n", FUNC); #endif if(H5CX_get_mpio_Proc0_BCast()) { #ifdef H5FDmpio_DEBUG @@ -1535,8 +1500,8 @@ H5FD_mpio_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, } /* end if */ else { #ifdef H5FDmpio_DEBUG - if(H5FD_mpio_Debug[(int)'t']) - fprintf(stdout, "H5FD_mpio_read: doing MPI independent IO\n"); + if(H5FD_mpio_Debug[(int)'r']) + HDfprintf(stdout, "%s: doing MPI independent IO\n", FUNC); #endif if(MPI_SUCCESS != (mpi_code = MPI_File_read_at(file->f, mpi_off, buf, size_i, buf_type, &mpi_stat))) @@ -1548,17 +1513,28 @@ H5FD_mpio_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, */ if(MPI_SUCCESS != (mpi_code = MPI_File_set_view(file->f, (MPI_Offset)0, MPI_BYTE, MPI_BYTE, H5FD_mpi_native_g, file->info))) HMPI_GOTO_ERROR(FAIL, "MPI_File_set_view failed", mpi_code) - } else { + } /* end if */ + else if(MPI_SUCCESS != (mpi_code = MPI_File_read_at(file->f, mpi_off, buf, size_i, buf_type, &mpi_stat))) +<<<<<<< HEAD HMPI_GOTO_ERROR(FAIL, "MPI_File_read_at failed", mpi_code) } +======= + HMPI_GOTO_ERROR(FAIL, "MPI_File_read_at failed", mpi_code) +>>>>>>> 7bf6d847ae36940f1b1147820356795c7764dbeb if( !Proc0_BCast_enabled || (Proc0_BCast_enabled && file->mpi_rank == 0) ) { /* How many bytes were actually read? */ #if MPI_VERSION >= 3 +<<<<<<< HEAD if(MPI_SUCCESS != (mpi_code = MPI_Get_elements_x(&mpi_stat, buf_type, &bytes_read))) #else if(MPI_SUCCESS != (mpi_code = MPI_Get_elements(&mpi_stat, MPI_BYTE, &bytes_read))) +======= + if(MPI_SUCCESS != (mpi_code = MPI_Get_elements_x(&mpi_stat, buf_type, &bytes_read))) +#else + if(MPI_SUCCESS != (mpi_code = MPI_Get_elements(&mpi_stat, MPI_BYTE, &bytes_read))) +>>>>>>> 7bf6d847ae36940f1b1147820356795c7764dbeb #endif HMPI_GOTO_ERROR(FAIL, "MPI_Get_elements failed", mpi_code) } @@ -1577,15 +1553,16 @@ H5FD_mpio_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, HMPI_GOTO_ERROR(FAIL, "MPI_Type_size failed", mpi_code) /* Compute the actual number of bytes requested */ - io_size=type_size*size_i; + io_size = type_size * size_i; /* Check for read failure */ - if (bytes_read<0 || bytes_read>io_size) + if(bytes_read < 0 || bytes_read > io_size) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file read failed") /* * This gives us zeroes beyond end of physical MPI file. */ +<<<<<<< HEAD if ((n=(io_size-bytes_read)) > 0) HDmemset((char*)buf+bytes_read, 0, (size_t)n); @@ -1593,14 +1570,23 @@ done: #ifdef H5FDmpio_DEBUG if (H5FD_mpio_Debug[(int)'t']) fprintf(stdout, "Leaving H5FD_mpio_read\n" ); +======= + if((n = (io_size - bytes_read)) > 0) + HDmemset((char*)buf+bytes_read, 0, (size_t)n); + +done: +#ifdef H5FDmpio_DEBUG + if(H5FD_mpio_Debug[(int)'t']) + HDfprintf(stdout, "%s: Leaving\n", FUNC); +>>>>>>> 7bf6d847ae36940f1b1147820356795c7764dbeb #endif FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5FD__mpio_read() */ /*------------------------------------------------------------------------- - * Function: H5FD_mpio_write + * Function: H5FD__mpio_write * * Purpose: Writes SIZE bytes of data to FILE beginning at address ADDR * from buffer BUF according to data transfer properties in @@ -1612,116 +1598,16 @@ done: * * Return: Success: Zero. USE_TYPES and OLD_USE_TYPES in the * access params are altered. - * * Failure: -1, USE_TYPES and OLD_USE_TYPES in the * access params may be altered. * - * Programmer: Unknown + * Programmer: Robert Kim Yates * January 30, 1998 * - * Modifications: - * rky, 1998-08-28 - * If the file->allsame flag is set, we assume that all the - * procs in the relevant MPI communicator will write identical - * data at identical offsets in the file, so only proc 0 will - * write, and all other procs will wait for p0 to finish. This - * is useful for writing metadata, for example. Note that we - * don't _check_ that the data is identical. Also, the mechanism - * we use to eliminate the redundant writes is by requiring a - * call to H5FD_mpio_tas_allsame before the write, which is - * rather klugey. Would it be better to pass a parameter to - * low-level writes like H5F_block_write and H5F_low_write, - * instead? Or...??? Also, when I created this mechanism I - * wanted to minimize the difference in behavior between the old - * way of doing things (i.e., all procs write) and the new way, - * so the writes are eliminated at the very lowest level, here - * in H5FD_mpio_write. It may be better to rethink that, and - * short-circuit the writes at a higher level (e.g., at the - * points in the code where H5FD_mpio_tas_allsame is called). - * - * - * Robb Matzke, 1998-02-18 - * Added the ACCESS_PARMS argument. - * - * rky, 1998-04-10 - * Call independent or collective MPI write, based on - * ACCESS_PARMS. - * - * rky, 1998-04-24 - * Removed redundant write from H5FD_mpio_write. - * - * Albert Cheng, 1998-06-01 - * Added XFER_MODE to control independent or collective MPI - * write. - * - * rky, 1998-08-16 - * Use BTYPE, FTYPE, and DISP from access parms. The guts of - * H5FD_mpio_read and H5FD_mpio_write should be replaced by a - * single dual-purpose routine. - * - * rky, 1998-08-28 - * Added ALLSAME parameter to make all but proc 0 skip the - * actual write. - * - * Robb Matzke, 1999-04-21 - * Changed XFER_MODE to XFER_PARMS for all H5FD_*_write() - * callbacks. - * - * Robb Matzke, 1999-07-28 - * The ADDR argument is passed by value. - * - * Robb Matzke, 1999-08-06 - * Modified to work with the virtual file layer. - * - * Albert Cheng, 1999-12-19 - * When only-p0-write-allsame-data, p0 Bcasts the - * ret_value to other processes. This prevents - * a racing condition (that other processes try to - * read the file before p0 finishes writing) and also - * allows all processes to report the same ret_value. - * - * Kim Yates, Pat Weidhaas, 2000-09-26 - * Move block of coding where only p0 writes after the - * MPI_File_set_view call. - * - * Quincey Koziol, 2002-05-10 - * Instead of always writing metadata from process 0, spread the - * burden among all the processes by using a round-robin rotation - * scheme. - * - * Quincey Koziol, 2002-05-10 - * Removed allsame code, keying off the type parameter instead. - * - * Quincey Koziol, 2002-05-14 - * Only call MPI_Get_count if we can use MPI_BYTE for the MPI type - * for the I/O transfer. Someday we might include code to decode - * the MPI type used for more complicated transfers and call - * MPI_Get_count all the time. - * - * Quincey Koziol - 2002/06/17 - * Removed 'disp' parameter from H5FD_mpio_setup routine and use - * the address of the dataset in MPI_File_set_view() calls, as - * necessary. - * - * Quincey Koziol - 2002/06/24 - * Removed "lazy" MPI_File_set_view() calls, since they would fail - * if the first I/O was a collective I/O using MPI derived types - * and the next I/O was an independent I/O. - * - * Quincey Koziol - 2002/07/18 - * Added "block_before_meta_write" dataset transfer flag, which - * is set during writes from a metadata cache flush and indicates - * that all the processes must sync up before (one of them) - * writing metadata. - * - * Quincey Koziol - 2003/10/22-31 - * Restructured code massively, straightening out logic and finally - * getting the bytes_written stuff working. - * *------------------------------------------------------------------------- */ static herr_t -H5FD_mpio_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, +H5FD__mpio_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, size_t size, const void *buf) { H5FD_mpio_t *file = (H5FD_mpio_t*)_file; @@ -1743,12 +1629,14 @@ H5FD_mpio_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, H5FD_mpio_xfer_t xfer_mode; /* I/O transfer mode */ herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC #ifdef H5FDmpio_DEBUG - if (H5FD_mpio_Debug[(int)'t']) - fprintf(stdout, "Entering H5FD_mpio_write\n" ); + if(H5FD_mpio_Debug[(int)'t']) + HDfprintf(stdout, "%s: Entering\n", FUNC); #endif + + /* Sanity checks */ HDassert(file); HDassert(H5FD_MPIO==file->pub.driver_id); HDassert(buf); @@ -1768,7 +1656,7 @@ H5FD_mpio_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, #ifdef H5FDmpio_DEBUG if(H5FD_mpio_Debug[(int)'w']) - fprintf(stdout, "in H5FD_mpio_write mpi_off=%ld size_i=%d\n", (long)mpi_off, size_i); + HDfprintf(stdout, "%s: mpi_off = %ld size_i = %d\n", FUNC, (long)mpi_off, size_i); #endif /* Get the transfer mode from the API context */ @@ -1808,8 +1696,8 @@ H5FD_mpio_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, H5FD_mpio_collective_opt_t coll_opt_mode; #ifdef H5FDmpio_DEBUG - if(H5FD_mpio_Debug[(int)'t']) - fprintf(stdout, "H5FD_mpio_write: using MPIO collective mode\n"); + if(H5FD_mpio_Debug[(int)'w']) + HDfprintf(stdout, "%s: using MPIO collective mode\n", FUNC); #endif /* Get the collective_opt property to check whether the application wants to do IO individually. */ @@ -1818,8 +1706,8 @@ H5FD_mpio_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, if(coll_opt_mode == H5FD_MPIO_COLLECTIVE_IO) { #ifdef H5FDmpio_DEBUG - if(H5FD_mpio_Debug[(int)'t']) - fprintf(stdout, "H5FD_mpio_write: doing MPI collective IO\n"); + if(H5FD_mpio_Debug[(int)'w']) + HDfprintf(stdout, "%s: doing MPI collective IO\n", FUNC); #endif if(MPI_SUCCESS != (mpi_code = MPI_File_write_at_all(file->f, mpi_off, buf, size_i, buf_type, &mpi_stat))) HMPI_GOTO_ERROR(FAIL, "MPI_File_write_at_all failed", mpi_code) @@ -1828,8 +1716,8 @@ H5FD_mpio_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, if(type != H5FD_MEM_DRAW) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "Metadata Coll opt property should be collective at this point") #ifdef H5FDmpio_DEBUG - if(H5FD_mpio_Debug[(int)'t']) - fprintf(stdout, "H5FD_mpio_write: doing MPI independent IO\n"); + if(H5FD_mpio_Debug[(int)'w']) + HDfprintf(stdout, "%s: doing MPI independent IO\n", FUNC); #endif if(MPI_SUCCESS != (mpi_code = MPI_File_write_at(file->f, mpi_off, buf, size_i, buf_type, &mpi_stat))) HMPI_GOTO_ERROR(FAIL, "MPI_File_write_at failed", mpi_code) @@ -1838,10 +1726,10 @@ H5FD_mpio_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, /* Reset the file view when we used MPI derived types */ if(MPI_SUCCESS != (mpi_code = MPI_File_set_view(file->f, (MPI_Offset)0, MPI_BYTE, MPI_BYTE, H5FD_mpi_native_g, file->info))) HMPI_GOTO_ERROR(FAIL, "MPI_File_set_view failed", mpi_code) - } else { + } /* end if */ + else if(MPI_SUCCESS != (mpi_code = MPI_File_write_at(file->f, mpi_off, buf, size_i, buf_type, &mpi_stat))) HMPI_GOTO_ERROR(FAIL, "MPI_File_write_at failed", mpi_code) - } /* How many bytes were actually written? */ #if MPI_VERSION >= 3 @@ -1880,15 +1768,15 @@ H5FD_mpio_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, done: #ifdef H5FDmpio_DEBUG if(H5FD_mpio_Debug[(int)'t']) - fprintf(stdout, "proc %d: Leaving H5FD_mpio_write with ret_value=%d\n", - file->mpi_rank, ret_value ); + HDfprintf(stdout, "%s: Leaving, proc %d: ret_value = %d\n", FUNC, file->mpi_rank, ret_value ); #endif + FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_mpio_write() */ +} /* end H5FD__mpio_write() */ /*------------------------------------------------------------------------- - * Function: H5FD_mpio_flush + * Function: H5FD__mpio_flush * * Purpose: Makes sure that all data is on disk. This is collective. * @@ -1902,18 +1790,20 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_mpio_flush(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t closing) +H5FD__mpio_flush(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t closing) { H5FD_mpio_t *file = (H5FD_mpio_t*)_file; int mpi_code; /* mpi return code */ herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC #ifdef H5FDmpio_DEBUG if(H5FD_mpio_Debug[(int)'t']) - HDfprintf(stdout, "Entering %s\n", FUNC); + HDfprintf(stdout, "%s: Entering\n", FUNC); #endif + + /* Sanity checks */ HDassert(file); HDassert(H5FD_MPIO == file->pub.driver_id); @@ -1925,15 +1815,15 @@ H5FD_mpio_flush(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t closing) done: #ifdef H5FDmpio_DEBUG if(H5FD_mpio_Debug[(int)'t']) - HDfprintf(stdout, "Leaving %s\n", FUNC); + HDfprintf(stdout, "%s: Leaving\n", FUNC); #endif FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_mpio_flush() */ +} /* end H5FD__mpio_flush() */ /*------------------------------------------------------------------------- - * Function: H5FD_mpio_truncate + * Function: H5FD__mpio_truncate * * Purpose: Make certain the file's size matches it's allocated size * @@ -1953,31 +1843,22 @@ done: * Programmer: Quincey Koziol * January 31, 2008 * - * Changes: Heavily reworked to avoid unnecessary MPI_File_set_size() - * calls. The hope is that these calls are superfluous in the - * typical case, allowing us to avoid truncates most of the - * time. - * - * The basic idea is to query the file system to get the - * current eof, and only truncate if the file systems - * conception of the eof disagrees with our eoa. - * - * JRM -- 10/27/17 - * *------------------------------------------------------------------------- */ static herr_t -H5FD_mpio_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR_UNUSED closing) +H5FD__mpio_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR_UNUSED closing) { - H5FD_mpio_t *file = (H5FD_mpio_t*)_file; - herr_t ret_value = SUCCEED; + H5FD_mpio_t *file = (H5FD_mpio_t*)_file; + herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC #ifdef H5FDmpio_DEBUG if(H5FD_mpio_Debug[(int)'t']) - HDfprintf(stdout, "Entering %s\n", FUNC); + HDfprintf(stdout, "%s: Entering\n", FUNC); #endif + + /* Sanity checks */ HDassert(file); HDassert(H5FD_MPIO == file->pub.driver_id); @@ -2043,15 +1924,15 @@ H5FD_mpio_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR_ done: #ifdef H5FDmpio_DEBUG if(H5FD_mpio_Debug[(int)'t']) - HDfprintf(stdout, "Leaving %s\n", FUNC); + HDfprintf(stdout, "%s: Leaving\n", FUNC); #endif FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_mpio_truncate() */ +} /* end H5FD__mpio_truncate() */ /*------------------------------------------------------------------------- - * Function: H5FD_mpio_mpi_rank + * Function: H5FD__mpio_mpi_rank * * Purpose: Returns the MPI rank for a process * @@ -2061,26 +1942,25 @@ done: * Programmer: Quincey Koziol * Thursday, May 16, 2002 * - * Modifications: - * *------------------------------------------------------------------------- */ static int -H5FD_mpio_mpi_rank(const H5FD_t *_file) +H5FD__mpio_mpi_rank(const H5FD_t *_file) { const H5FD_mpio_t *file = (const H5FD_mpio_t*)_file; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC + /* Sanity checks */ HDassert(file); - HDassert(H5FD_MPIO==file->pub.driver_id); + HDassert(H5FD_MPIO == file->pub.driver_id); FUNC_LEAVE_NOAPI(file->mpi_rank) -} /* end H5FD_mpio_mpi_rank() */ +} /* end H5FD__mpio_mpi_rank() */ /*------------------------------------------------------------------------- - * Function: H5FD_mpio_mpi_size + * Function: H5FD__mpio_mpi_size * * Purpose: Returns the number of MPI processes * @@ -2090,26 +1970,25 @@ H5FD_mpio_mpi_rank(const H5FD_t *_file) * Programmer: Quincey Koziol * Thursday, May 16, 2002 * - * Modifications: - * *------------------------------------------------------------------------- */ static int -H5FD_mpio_mpi_size(const H5FD_t *_file) +H5FD__mpio_mpi_size(const H5FD_t *_file) { const H5FD_mpio_t *file = (const H5FD_mpio_t*)_file; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC + /* Sanity checks */ HDassert(file); - HDassert(H5FD_MPIO==file->pub.driver_id); + HDassert(H5FD_MPIO == file->pub.driver_id); FUNC_LEAVE_NOAPI(file->mpi_size) -} /* end H5FD_mpio_mpi_size() */ +} /* end H5FD__mpio_mpi_size() */ /*------------------------------------------------------------------------- - * Function: H5FD_mpio_communicator + * Function: H5FD__mpio_communicator * * Purpose: Returns the MPI communicator for the file. * @@ -2120,22 +1999,53 @@ H5FD_mpio_mpi_size(const H5FD_t *_file) * Programmer: Robb Matzke * Monday, August 9, 1999 * - * Modifications: - * *------------------------------------------------------------------------- */ static MPI_Comm -H5FD_mpio_communicator(const H5FD_t *_file) +H5FD__mpio_communicator(const H5FD_t *_file) { const H5FD_mpio_t *file = (const H5FD_mpio_t*)_file; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC + /* Sanity checks */ HDassert(file); - HDassert(H5FD_MPIO==file->pub.driver_id); + HDassert(H5FD_MPIO == file->pub.driver_id); FUNC_LEAVE_NOAPI(file->comm) -} /* end H5FD_mpio_communicator() */ +} /* end H5FD__mpio_communicator() */ + + +/*------------------------------------------------------------------------- + * Function: H5FD__mpio_get_info + * + * Purpose: Returns the file info of MPIO file driver. + * + * Returns: Non-negative if succeed or negative if fails. + * + * Programmer: John Mainzer + * April 4, 2017 + * + * Modifications: + * + *------------------------------------------------------------------------- +*/ +static herr_t +H5FD__mpio_get_info(H5FD_t *_file, void **mpi_info) +{ + H5FD_mpio_t *file = (H5FD_mpio_t *)_file; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + if(!mpi_info) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "mpi info not valid") + + *mpi_info = &(file->info); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5FD__mpio_get_info() */ #endif /* H5_HAVE_PARALLEL */ diff --git a/src/H5FDmulti.c b/src/H5FDmulti.c index aa1b118..fac0909 100644 --- a/src/H5FDmulti.c +++ b/src/H5FDmulti.c @@ -26,11 +26,6 @@ #include <stdlib.h> #include <string.h> -/* Disable certain warnings in PC-Lint: */ -/*lint --emacro( {534, 830}, H5P_DEFAULT, H5P_FILE_ACCESS, H5P_DATASET_XFER) */ -/*lint --emacro( {534, 830}, H5FD_MULTI) */ -/*lint -esym( 534, H5Eclear2, H5Epush2) */ - #include "hdf5.h" @@ -211,16 +206,15 @@ my_strdup(const char *s) /*------------------------------------------------------------------------- - * Function: H5FD_multi_init - * - * Purpose: Initialize this driver by registering the driver with the - * library. + * Function: H5FD_multi_init * - * Return: Success: The driver ID for the multi driver. + * Purpose: Initialize this driver by registering the driver with the + * library. * - * Failure: Negative + * Return: Success: The driver ID for the multi driver + * Failure: H5I_INVALID_HID * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Wednesday, August 4, 1999 * *------------------------------------------------------------------------- @@ -231,11 +225,11 @@ H5FD_multi_init(void) /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); - if(H5I_VFL!=H5Iget_type(H5FD_MULTI_g)) + if(H5I_VFL != H5Iget_type(H5FD_MULTI_g)) H5FD_MULTI_g = H5FDregister(&H5FD_multi_g); return H5FD_MULTI_g; -} +} /* end H5FD_multi_init() */ /*--------------------------------------------------------------------------- @@ -497,6 +491,7 @@ H5Pset_fapl_multi(hid_t fapl_id, const H5FD_mem_t *memb_map, * Initialize driver specific information. No need to copy it into the FA * struct since all members will be copied by H5Pset_driver(). */ + memset(&fa, 0, sizeof(H5FD_multi_fapl_t)); memcpy(fa.memb_map, memb_map, H5FD_MEM_NTYPES*sizeof(H5FD_mem_t)); memcpy(fa.memb_fapl, memb_fapl, H5FD_MEM_NTYPES*sizeof(hid_t)); memcpy(fa.memb_name, memb_name, H5FD_MEM_NTYPES*sizeof(char*)); @@ -892,7 +887,7 @@ static void * H5FD_multi_fapl_copy(const void *_old_fa) { const H5FD_multi_fapl_t *old_fa = (const H5FD_multi_fapl_t*)_old_fa; - H5FD_multi_fapl_t *new_fa = (H5FD_multi_fapl_t *)malloc(sizeof(H5FD_multi_fapl_t)); + H5FD_multi_fapl_t *new_fa = (H5FD_multi_fapl_t *)calloc(1, sizeof(H5FD_multi_fapl_t)); int nerrors = 0; static const char *func="H5FD_multi_fapl_copy"; /* Function Name for error reporting */ diff --git a/src/H5FDsec2.c b/src/H5FDsec2.c index 06c008d..c507387 100644 --- a/src/H5FDsec2.c +++ b/src/H5FDsec2.c @@ -208,8 +208,8 @@ done: * Purpose: Initialize this driver by registering the driver with the * library. * - * Return: Success: The driver ID for the sec2 driver. - * Failure: Negative + * Return: Success: The driver ID for the sec2 driver + * Failure: H5I_INVALID_HID * * Programmer: Robb Matzke * Thursday, July 29, 1999 @@ -221,7 +221,7 @@ H5FD_sec2_init(void) { hid_t ret_value = H5I_INVALID_HID; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI(H5I_INVALID_HID) if(H5I_VFL != H5I_get_type(H5FD_SEC2_g)) H5FD_SEC2_g = H5FD_register(&H5FD_sec2_g, sizeof(H5FD_class_t), FALSE); diff --git a/src/H5Fdeprec.c b/src/H5Fdeprec.c index dfc1441..18e915f 100644 --- a/src/H5Fdeprec.c +++ b/src/H5Fdeprec.c @@ -42,6 +42,8 @@ #include "H5Iprivate.h" /* IDs */ #include "H5SMprivate.h" /* Shared object header messages */ +#include "H5VLnative_private.h" /* Native VOL connector */ + /****************/ /* Local Macros */ @@ -118,7 +120,7 @@ H5Fget_info1(hid_t obj_id, H5F_info1_t *finfo) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") /* Get the file information */ - if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_FILE_GET_INFO, type, &finfo2) < 0) + if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_FILE_GET_INFO, type, &finfo2) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to retrieve file info") /* Copy the compatible fields into the older struct */ @@ -225,7 +227,7 @@ H5Fset_latest_format(hid_t file_id, hbool_t latest_format) low = H5F_LIBVER_EARLIEST; /* Set the library's version bounds */ - if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_FILE_SET_LIBVER_BOUNDS, low, high) < 0) + if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_FILE_SET_LIBVER_BOUNDS, (int)low, (int)high) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set library version bounds") done: diff --git a/src/H5Fefc.c b/src/H5Fefc.c index a394071..f3881d4 100644 --- a/src/H5Fefc.c +++ b/src/H5Fefc.c @@ -29,8 +29,10 @@ /* Packages needed by this file... */ #include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fpkg.h" /* File access */ +#include "H5Iprivate.h" /* IDs */ #include "H5MMprivate.h" /* Memory management */ #include "H5Pprivate.h" /* Property lists */ @@ -144,6 +146,8 @@ H5F__efc_open(H5F_t *parent, const char *name, unsigned flags, hid_t fcpl_id, hi H5F_efc_t *efc = NULL; /* External file cache for parent file */ H5F_efc_ent_t *ent = NULL; /* Entry for target file in efc */ hbool_t open_file = FALSE; /* Whether ent->file needs to be closed in case of error */ + H5P_genplist_t *plist; /* Property list pointer for FAPL */ + H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */ H5F_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -153,6 +157,18 @@ H5F__efc_open(H5F_t *parent, const char *name, unsigned flags, hid_t fcpl_id, hi HDassert(parent->shared); HDassert(name); + /* Get the VOL info from the fapl */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) + HGOTO_ERROR(H5E_FILE, H5E_BADTYPE, NULL, "not a file access property list") + if(H5P_peek(plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "can't get VOL connector info") + + /* Stash a copy of the "top-level" connector property, before any pass-through + * connectors modify or unwrap it. + */ + if(H5CX_set_vol_connector_prop(&connector_prop) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, NULL, "can't set VOL connector info in API context") + /* Get external file cache */ efc = parent->shared->efc; diff --git a/src/H5Fint.c b/src/H5Fint.c index 056a98b..8a7019d 100644 --- a/src/H5Fint.c +++ b/src/H5Fint.c @@ -39,6 +39,8 @@ #include "H5Tprivate.h" /* Datatypes */ #include "H5VLprivate.h" /* Virtual Object Layer */ +#include "H5VLnative_private.h" /* Native VOL connector */ + /****************/ /* Local Macros */ @@ -74,6 +76,7 @@ typedef struct H5F_olist_t { /* Local Prototypes */ /********************/ +static herr_t H5F__set_vol_conn(H5F_t *file); static herr_t H5F__get_objects(const H5F_t *f, unsigned types, size_t max_index, hid_t *obj_id_list, hbool_t app_ref, size_t *obj_id_count_ptr); static int H5F__get_objects_cb(void *obj_ptr, hid_t obj_id, void *key); static herr_t H5F__build_name(const char *prefix, const char *file_name, char **full_name/*out*/); @@ -115,39 +118,46 @@ H5FL_DEFINE(H5F_file_t); * *------------------------------------------------------------------------- */ -herr_t -H5F__set_vol_conn(H5F_t *file, hid_t vol_id, const void *vol_info) +static herr_t +H5F__set_vol_conn(H5F_t *file) { + H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */ void *new_connector_info = NULL; /* Copy of connector info */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_PACKAGE + FUNC_ENTER_STATIC /* Sanity check */ HDassert(file); - /* Only cache VOL connector ID & info the first time the file is opened */ - if(file->shared->nrefs == 1) { - /* Copy connector info, if it exists */ - if(vol_info) { - H5VL_class_t *connector; /* Pointer to connector */ + /* Retrieve a copy of the "top-level" connector property, before any pass-through + * connectors modified or unwrapped it. + */ + if(H5CX_get_vol_connector_prop(&connector_prop) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get VOL connector info from API context") - /* Retrieve the connector for the ID */ - if(NULL == (connector = (H5VL_class_t *)H5I_object(vol_id))) - HGOTO_ERROR(H5E_FILE, H5E_BADTYPE, FAIL, "not a VOL connector ID") + /* Sanity check */ + HDassert(0 != connector_prop.connector_id); - /* Allocate and copy connector info */ - if(H5VL_copy_connector_info(connector, &new_connector_info, vol_info) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTCOPY, FAIL, "connector info copy failed") - } /* end if */ + /* Copy connector info, if it exists */ + if(connector_prop.connector_info) { + H5VL_class_t *connector; /* Pointer to connector */ - /* Cache the connector ID & info for the container */ - file->shared->vol_id = vol_id; - file->shared->vol_info = new_connector_info; - if(H5I_inc_ref(file->shared->vol_id, FALSE) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTINC, FAIL, "incrementing VOL connector ID failed") + /* Retrieve the connector for the ID */ + if(NULL == (connector = (H5VL_class_t *)H5I_object(connector_prop.connector_id))) + HGOTO_ERROR(H5E_FILE, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Allocate and copy connector info */ + if(H5VL_copy_connector_info(connector, &new_connector_info, connector_prop.connector_info) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTCOPY, FAIL, "connector info copy failed") } /* end if */ + /* Cache the connector ID & info for the container */ + file->shared->vol_id = connector_prop.connector_id; + file->shared->vol_info = new_connector_info; + if(H5I_inc_ref(file->shared->vol_id, FALSE) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINC, FAIL, "incrementing VOL connector ID failed") + done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__set_vol_conn() */ @@ -492,7 +502,6 @@ H5F__get_objects_cb(void *obj_ptr, hid_t obj_id, void *key) case H5I_BADID: case H5I_FILE: case H5I_DATASPACE: - case H5I_REFERENCE: case H5I_VFL: case H5I_VOL: case H5I_GENPROP_CLS: @@ -793,14 +802,12 @@ H5F_prefix_open_file(H5F_t *primary_file, H5F_prefix_open_t prefix_type, /* get last component of file_name */ H5_GET_LAST_DELIMITER(actual_file_name, ptr) - if(!ptr) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file, file name = '%s', temp_file_name = '%s'", file_name, temp_file_name) - - /* Truncate filename portion from actual file name path */ - *ptr = '\0'; + if(ptr) + /* Truncate filename portion from actual file name path */ + *ptr = '\0'; /* Build new file name for the external file */ - if(H5F__build_name(actual_file_name, temp_file_name, &full_name/*out*/) < 0) + if(H5F__build_name((ptr ? actual_file_name : ""), temp_file_name, &full_name/*out*/) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "can't prepend prefix to filename") actual_file_name = (char *)H5MM_xfree(actual_file_name); @@ -816,7 +823,7 @@ H5F_prefix_open_file(H5F_t *primary_file, H5F_prefix_open_t prefix_type, H5E_clear_stack(NULL); } /* end if */ - /* Success */ + /* Set return value (possibly NULL or valid H5F_t *) */ ret_value = src_file; done: @@ -1090,6 +1097,10 @@ H5F__new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_ if(H5P_get(plist, H5F_ACS_OBJECT_FLUSH_CB_NAME, &(f->shared->object_flush)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "can't get object flush cb info") + /* Get the VOL connector info */ + if(H5F__set_vol_conn(f) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "can't cache VOL connector info") + /* Create a metadata cache with the specified number of elements. * The cache might be created with a different number of elements and * the access property list should be updated to reflect that. @@ -3601,7 +3612,6 @@ H5F__get_file(void *obj, H5I_type_t type) case H5I_UNINIT: case H5I_BADID: case H5I_DATASPACE: - case H5I_REFERENCE: case H5I_VFL: case H5I_VOL: case H5I_GENPROP_CLS: @@ -3695,7 +3705,7 @@ H5F_get_file_id(hid_t obj_id, H5I_type_t type) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid identifier") /* Get the file through the VOL */ - if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_FILE_GET_FILE_ID, type, &file_id) < 0) + if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_FILE_GET_FILE_ID, (int)type, &file_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, H5I_INVALID_HID, "unable to get file ID") if(H5I_INVALID_HID == file_id) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, H5I_INVALID_HID, "unable to get the file ID through the VOL") @@ -3707,3 +3717,27 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_get_file_id() */ + +/*------------------------------------------------------------------------- + * Function: H5F_set_min_dset_ohdr + * + * Purpose: Set the crt_dset_ohdr_flag field with a new value. + * + * Return: SUCCEED/FAIL + *------------------------------------------------------------------------- + */ +herr_t +H5F_set_min_dset_ohdr(H5F_t *f, hbool_t minimize) +{ + /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ + FUNC_ENTER_NOAPI_NOINIT_NOERR + + /* Sanity check */ + HDassert(f); + HDassert(f->shared); + + f->shared->crt_dset_min_ohdr_flag = minimize; + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* H5F_set_min_dset_ohdr() */ + diff --git a/src/H5Fmount.c b/src/H5Fmount.c index d7f8915..13d95aa 100644 --- a/src/H5Fmount.c +++ b/src/H5Fmount.c @@ -482,7 +482,7 @@ H5Fmount(hid_t loc_id, const char *name, hid_t child_id, hid_t plist_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "Can't mount file onto object from different VOL connector") /* Perform the mount operation */ - if(H5VL_file_specific(loc_vol_obj, H5VL_FILE_MOUNT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, loc_type, name, child_vol_obj->data, plist_id) < 0) + if(H5VL_file_specific(loc_vol_obj, H5VL_FILE_MOUNT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, (int)loc_type, name, child_vol_obj->data, plist_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to mount file") done: @@ -534,7 +534,7 @@ H5Funmount(hid_t loc_id, const char *name) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "could not get location object") /* Perform the unmount operation */ - if(H5VL_file_specific(vol_obj, H5VL_FILE_UNMOUNT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, loc_type, name) < 0) + if(H5VL_file_specific(vol_obj, H5VL_FILE_UNMOUNT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, (int)loc_type, name) < 0) HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to unmount file") done: diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h index fc902b0..335d0a7 100644 --- a/src/H5Fpkg.h +++ b/src/H5Fpkg.h @@ -358,6 +358,7 @@ struct H5F_file_t { /* Object flush info */ H5F_object_flush_t object_flush; /* Information for object flush callback */ + hbool_t crt_dset_min_ohdr_flag; /* flag to minimize created dataset object header */ }; /* @@ -382,36 +383,6 @@ struct H5F_t { #endif /* H5_HAVE_PARALLEL */ }; -/* types for file optional VOL operations */ -typedef enum H5VL_file_optional_t { - H5VL_FILE_CLEAR_ELINK_CACHE, /* Clear external link cache */ - H5VL_FILE_GET_FILE_IMAGE, /* file image */ - H5VL_FILE_GET_FREE_SECTIONS, /* file free selections */ - H5VL_FILE_GET_FREE_SPACE, /* file freespace */ - H5VL_FILE_GET_INFO, /* file info */ - H5VL_FILE_GET_MDC_CONF, /* file metadata cache configuration */ - H5VL_FILE_GET_MDC_HR, /* file metadata cache hit rate */ - H5VL_FILE_GET_MDC_SIZE, /* file metadata cache size */ - H5VL_FILE_GET_SIZE, /* file size */ - H5VL_FILE_GET_VFD_HANDLE, /* file VFD handle */ - H5VL_FILE_GET_FILE_ID, /* retrieve or resurrect file ID of object */ - H5VL_FILE_RESET_MDC_HIT_RATE, /* get metadata cache hit rate */ - H5VL_FILE_SET_MDC_CONFIG, /* set metadata cache configuration */ - H5VL_FILE_GET_METADATA_READ_RETRY_INFO, - H5VL_FILE_START_SWMR_WRITE, - H5VL_FILE_START_MDC_LOGGING, - H5VL_FILE_STOP_MDC_LOGGING, - H5VL_FILE_GET_MDC_LOGGING_STATUS, - H5VL_FILE_FORMAT_CONVERT, - H5VL_FILE_RESET_PAGE_BUFFERING_STATS, - H5VL_FILE_GET_PAGE_BUFFERING_STATS, - H5VL_FILE_GET_MDC_IMAGE_INFO, - H5VL_FILE_GET_EOA, - H5VL_FILE_INCR_FILESIZE, - H5VL_FILE_SET_LIBVER_BOUNDS -} H5VL_file_optional_t; - - /*****************************/ /* Package Private Variables */ /*****************************/ @@ -440,7 +411,6 @@ H5_DLL herr_t H5F__close(H5F_t *f); H5_DLL herr_t H5F__set_libver_bounds(H5F_t *f, H5F_libver_t low, H5F_libver_t high); H5_DLL H5F_t *H5F__get_file(void *obj, H5I_type_t type); H5_DLL hid_t H5F__get_file_id(H5F_t *file); -H5_DLL herr_t H5F__set_vol_conn(H5F_t *file, hid_t vol_id, const void *vol_info); /* File mount related routines */ H5_DLL herr_t H5F__mount(H5G_loc_t *loc, const char *name, H5F_t *child, hid_t plist_id); diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index 83513a5..5f7a1b2 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -331,6 +331,8 @@ typedef struct H5F_t H5F_t; #define H5F_POINT_OF_NO_RETURN(F) ((F)->shared->fs.point_of_no_return) #define H5F_FIRST_ALLOC_DEALLOC(F) ((F)->shared->first_alloc_dealloc) #define H5F_EOA_PRE_FSM_FSALLOC(F) ((F)->shared->eoa_pre_fsm_fsalloc) +#define H5F_GET_MIN_DSET_OHDR(F) ((F)->shared->crt_dset_min_ohdr_flag) +#define H5F_SET_MIN_DSET_OHDR(F, V) ((F)->shared->crt_dset_min_ohdr_flag = (V)) #else /* H5F_MODULE */ #define H5F_LOW_BOUND(F) (H5F_get_low_bound(F)) #define H5F_HIGH_BOUND(F) (H5F_get_high_bound(F)) @@ -388,6 +390,8 @@ typedef struct H5F_t H5F_t; #define H5F_POINT_OF_NO_RETURN(F) (H5F_get_point_of_no_return(F)) #define H5F_FIRST_ALLOC_DEALLOC(F) (H5F_get_first_alloc_dealloc(F)) #define H5F_EOA_PRE_FSM_FSALLOC(F) (H5F_get_eoa_pre_fsm_fsalloc(F)) +#define H5F_GET_MIN_DSET_OHDR(F) (H5F_get_min_dset_ohdr(F)) +#define H5F_SET_MIN_DSET_OHDR(F, V) (H5F_set_min_dset_ohdr((F), (V))) #endif /* H5F_MODULE */ @@ -500,9 +504,7 @@ typedef struct H5F_t H5F_t; #define H5F_ACS_USE_MDC_LOGGING_NAME "use_mdc_logging" /* Whether to use metadata cache logging */ #define H5F_ACS_MDC_LOG_LOCATION_NAME "mdc_log_location" /* Name of metadata cache log location */ #define H5F_ACS_START_MDC_LOG_ON_ACCESS_NAME "start_mdc_log_on_access" /* Whether logging starts on file create/open */ -#define H5F_ACS_CORE_WRITE_TRACKING_FLAG_NAME "core_write_tracking_flag" /* Whether or not core VFD backing store write tracking is enabled */ #define H5F_ACS_EVICT_ON_CLOSE_FLAG_NAME "evict_on_close_flag" /* Whether or not the metadata cache will evict objects on close */ -#define H5F_ACS_CORE_WRITE_TRACKING_PAGE_SIZE_NAME "core_write_tracking_page_size" /* The page size in kiB when core VFD write tracking is enabled */ #define H5F_ACS_COLL_MD_WRITE_FLAG_NAME "collective_metadata_write" /* property indicating whether metadata writes are done collectively or not */ #define H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_NAME "mdc_initCacheImageCfg" /* Initial metadata cache image creation configuration */ #define H5F_ACS_PAGE_BUFFER_SIZE_NAME "page_buffer_size" /* the maximum size for the page buffer cache */ @@ -742,6 +744,8 @@ H5_DLL hsize_t H5F_get_pgend_meta_thres(const H5F_t *f); H5_DLL hbool_t H5F_get_point_of_no_return(const H5F_t *f); H5_DLL hbool_t H5F_get_first_alloc_dealloc(const H5F_t *f); H5_DLL haddr_t H5F_get_eoa_pre_fsm_fsalloc(const H5F_t *f); +H5_DLL hbool_t H5F_get_min_dset_ohdr(const H5F_t *f); +H5_DLL herr_t H5F_set_min_dset_ohdr(H5F_t *f, hbool_t minimize); /* Functions than retrieve values set/cached from the superblock/FCPL */ H5_DLL haddr_t H5F_get_base_addr(const H5F_t *f); diff --git a/src/H5Fpublic.h b/src/H5Fpublic.h index 8e54e7f..c4bf0b4 100644 --- a/src/H5Fpublic.h +++ b/src/H5Fpublic.h @@ -217,12 +217,13 @@ typedef struct H5F_retry_info_t { /* Callback for H5Pset_object_flush_cb() in a file access property list */ typedef herr_t (*H5F_flush_cb_t)(hid_t object_id, void *udata); - +/*********************/ +/* Public Prototypes */ +/*********************/ #ifdef __cplusplus extern "C" { #endif -/* Functions in H5F.c */ H5_DLL htri_t H5Fis_accessible(const char *container_name, hid_t fapl_id); H5_DLL hid_t H5Fcreate(const char *filename, unsigned flags, hid_t create_plist, hid_t access_plist); @@ -273,6 +274,8 @@ H5_DLL herr_t H5Freset_page_buffering_stats(hid_t file_id); H5_DLL herr_t H5Fget_page_buffering_stats(hid_t file_id, unsigned accesses[2], unsigned hits[2], unsigned misses[2], unsigned evictions[2], unsigned bypasses[2]); H5_DLL herr_t H5Fget_mdc_image_info(hid_t file_id, haddr_t *image_addr, hsize_t *image_size); +H5_DLL herr_t H5Fget_dset_no_attrs_hint(hid_t file_id, hbool_t *minimize); +H5_DLL herr_t H5Fset_dset_no_attrs_hint(hid_t file_id, hbool_t minimize); #ifdef H5_HAVE_PARALLEL H5_DLL herr_t H5Fset_mpi_atomicity(hid_t file_id, hbool_t flag); diff --git a/src/H5Fquery.c b/src/H5Fquery.c index 3147e95..103ad3b 100644 --- a/src/H5Fquery.c +++ b/src/H5Fquery.c @@ -514,6 +514,25 @@ H5F_sym_leaf_k(const H5F_t *f) /*------------------------------------------------------------------------- + * Function: H5F_get_min_dset_ohdr + * + * Purpose: Get the setting flag for minimized dataset object headers + * + * Return: TRUE/FALSE as set in file + *------------------------------------------------------------------------- + */ +hbool_t +H5F_get_min_dset_ohdr(const H5F_t *f) +{ + FUNC_ENTER_NOAPI_NOINIT_NOERR + + HDassert(f); + + FUNC_LEAVE_NOAPI(f->shared->crt_dset_min_ohdr_flag) +} /* end H5F_get_min_dset_ohdr */ + + +/*------------------------------------------------------------------------- * Function: H5F_Kvalue * * Purpose: Replaced a macro to retrieve a B-tree key value for a certain diff --git a/src/H5Gdeprec.c b/src/H5Gdeprec.c index a15703e..cb03b5e 100644 --- a/src/H5Gdeprec.c +++ b/src/H5Gdeprec.c @@ -45,6 +45,8 @@ #include "H5Pprivate.h" /* Property lists */ #include "H5VLprivate.h" /* Virtual Object Layer */ +#include "H5VLnative_private.h" /* Native VOL connector */ + /****************/ /* Local Macros */ @@ -734,7 +736,7 @@ H5Gset_comment(hid_t loc_id, const char *name, const char *comment) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Set the comment */ - if(H5VL_object_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_OBJECT_SET_COMMENT, &loc_params, comment) < 0) + if(H5VL_object_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_OBJECT_SET_COMMENT, &loc_params, comment) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "unable to set comment value") done: @@ -770,19 +772,20 @@ H5Gget_comment(hid_t loc_id, const char *name, size_t bufsize, char *buf) { H5VL_object_t *vol_obj; /* Object token of loc_id */ H5VL_loc_params_t loc_params; + ssize_t op_ret; /* Return value from operation */ int ret_value; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API(-1) H5TRACE4("Is", "i*sz*s", loc_id, name, bufsize, buf); if(!name || !*name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, -1, "no name specified") if(bufsize > 0 && !buf) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no buffer specified") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, -1, "no buffer specified") /* Set up collective metadata if appropriate */ if(H5CX_set_loc(loc_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set collective metadata read info") + HGOTO_ERROR(H5E_SYM, H5E_CANTSET, -1, "can't set collective metadata read info") /* Fill in location struct fields */ loc_params.type = H5VL_OBJECT_BY_NAME; @@ -792,11 +795,14 @@ H5Gget_comment(hid_t loc_id, const char *name, size_t bufsize, char *buf) /* Get the location object */ if(NULL == (vol_obj = H5VL_vol_object(loc_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, -1, "invalid location identifier") /* Get the comment */ - if(H5VL_object_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_OBJECT_GET_COMMENT, &loc_params, buf, bufsize, &ret_value) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to get comment value") + if(H5VL_object_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_OBJECT_GET_COMMENT, &loc_params, buf, bufsize, &op_ret) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, -1, "unable to get comment value") + + /* Set return value */ + ret_value = (int)op_ret; done: FUNC_LEAVE_API(ret_value) @@ -868,7 +874,7 @@ H5Giterate(hid_t loc_id, const char *name, int *idx_p, H5G_iterate_t op, HGOTO_ERROR(H5E_ATOM, H5E_BADTYPE, (-1), "invalid identifier") /* Call private iteration function, through VOL callback */ - if((ret_value = H5VL_group_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_GROUP_ITERATE_OLD, &loc_params, idx, &last_obj, &lnk_op, op_data)) < 0) + if((ret_value = H5VL_group_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_GROUP_ITERATE_OLD, &loc_params, idx, &last_obj, &lnk_op, op_data)) < 0) HERROR(H5E_SYM, H5E_BADITER, "error iterating over group's links"); /* Set the index we stopped at */ @@ -985,7 +991,7 @@ H5Gget_objinfo(hid_t loc_id, const char *name, hbool_t follow_link, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Retrieve the object's information */ - if(H5VL_group_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_GROUP_GET_OBJINFO, &loc_params, (unsigned)follow_link, statbuf) < 0) + if(H5VL_group_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_GROUP_GET_OBJINFO, &loc_params, (unsigned)follow_link, statbuf) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get info for object: '%s'", name) } /* end if */ @@ -1239,7 +1245,7 @@ H5Gget_objtype_by_idx(hid_t loc_id, hsize_t idx) /* Retrieve the object's basic information (which includes its type) */ fields = H5O_INFO_BASIC; - if(H5VL_object_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_OBJECT_GET_INFO, &loc_params, &oinfo, fields) < 0) + if(H5VL_object_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_OBJECT_GET_INFO, &loc_params, &oinfo, fields) < 0) HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, H5G_UNKNOWN, "can't get object info") /* Map to group object type */ diff --git a/src/H5Gloc.c b/src/H5Gloc.c index 2dacd94..5724031 100644 --- a/src/H5Gloc.c +++ b/src/H5Gloc.c @@ -210,9 +210,6 @@ H5G_loc_real(void *obj, H5I_type_t type, H5G_loc_t *loc) break; } - case H5I_REFERENCE: - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get group location of reference") - case H5I_DATASPACE: HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get group location of dataspace") diff --git a/src/H5Gname.c b/src/H5Gname.c index f6ddeeb..2aece2b 100644 --- a/src/H5Gname.c +++ b/src/H5Gname.c @@ -821,7 +821,6 @@ H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key) case H5I_FILE: case H5I_DATASPACE: case H5I_ATTR: - case H5I_REFERENCE: case H5I_VFL: case H5I_VOL: case H5I_GENPROP_CLS: diff --git a/src/H5Gpkg.h b/src/H5Gpkg.h index 159b6f5..f475bde 100644 --- a/src/H5Gpkg.h +++ b/src/H5Gpkg.h @@ -299,22 +299,6 @@ typedef struct H5G_copy_file_ud_t { H5G_cache_t cache; /* Cached data for symbol table entry */ } H5G_copy_file_ud_t; -/* Types for optional group VOL operations */ -typedef enum H5VL_group_optional_t { - H5VL_GROUP_ITERATE_OLD, /* HG5Giterate (deprecated routine) */ - H5VL_GROUP_GET_OBJINFO /* HG5Gget_objinfo (deprecated routine) */ - /* (These two enum values should have an - * "#ifndefH5_NO_DEPRECATED_SYMBOLS" - * around them, but the compiler - * complains about an empty enum - * when deprecated symbols are - * disabled currently. When - * another enum value is added, - * please put the #ifdef around - * these symbols. QAK - 2018/12/06 - */ -} H5VL_group_optional_t; - /*****************************/ /* Package Private Variables */ diff --git a/src/H5Gpublic.h b/src/H5Gpublic.h index ab6f200..170b74d 100644 --- a/src/H5Gpublic.h +++ b/src/H5Gpublic.h @@ -37,10 +37,6 @@ /* Public Macros */ /*****************/ -#ifdef __cplusplus -extern "C" { -#endif - /*******************/ /* Public Typedefs */ /*******************/ @@ -62,6 +58,7 @@ typedef struct H5G_info_t { hbool_t mounted; /* Whether group has a file mounted on it */ } H5G_info_t; + /********************/ /* Public Variables */ /********************/ @@ -70,6 +67,10 @@ typedef struct H5G_info_t { /*********************/ /* Public Prototypes */ /*********************/ +#ifdef __cplusplus +extern "C" { +#endif + H5_DLL hid_t H5Gcreate2(hid_t loc_id, const char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id); H5_DLL hid_t H5Gcreate_anon(hid_t loc_id, hid_t gcpl_id, hid_t gapl_id); diff --git a/src/H5Gtest.c b/src/H5Gtest.c index 1995015..af6acb3 100644 --- a/src/H5Gtest.c +++ b/src/H5Gtest.c @@ -609,7 +609,6 @@ H5G__user_path_test(hid_t obj_id, char *user_path, size_t *user_path_len, unsign case H5I_FILE: case H5I_DATASPACE: case H5I_ATTR: - case H5I_REFERENCE: case H5I_VFL: case H5I_VOL: case H5I_GENPROP_CLS: @@ -2372,7 +2372,6 @@ H5I__id_dump_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) case H5I_FILE: case H5I_DATASPACE: case H5I_ATTR: - case H5I_REFERENCE: case H5I_VFL: case H5I_VOL: case H5I_GENPROP_CLS: diff --git a/src/H5Ipublic.h b/src/H5Ipublic.h index f4b5cc9..56873ec 100644 --- a/src/H5Ipublic.h +++ b/src/H5Ipublic.h @@ -29,9 +29,6 @@ * * When adding types here, add a section to the 'misc19' test in test/tmisc.c * to verify that the H5I{inc|dec|get}_ref() routines work correctly with it. - * - * NOTE: H5I_REFERENCE is not used by the library and has been deprecated - * with a tentative removal version of 1.12.0. (DER, July 2017) */ typedef enum H5I_type_t { H5I_UNINIT = (-2), /* uninitialized type */ @@ -42,7 +39,6 @@ typedef enum H5I_type_t { H5I_DATASPACE, /* type ID for Dataspace objects */ H5I_DATASET, /* type ID for Dataset objects */ H5I_ATTR, /* type ID for Attribute objects */ - H5I_REFERENCE, /* *DEPRECATED* type ID for Reference objects */ H5I_VFL, /* type ID for virtual file layer */ H5I_VOL, /* type ID for virtual object layer */ H5I_GENPROP_CLS, /* type ID for generic property list classes */ @@ -648,6 +648,8 @@ H5Lcreate_ud(hid_t link_loc_id, const char *link_name, H5L_type_t link_type, HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no link name specified") if(link_type < H5L_TYPE_UD_MIN || link_type > H5L_TYPE_MAX) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid link class") + if(!udata && udata_size) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "udata cannot be NULL if udata_size is non-zero") /* Check the group access property list */ if(H5P_DEFAULT == lcpl_id) @@ -1332,7 +1334,7 @@ H5Literate(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order, loc_params.obj_type = H5I_get_type(group_id); /* Iterate over the links */ - if((ret_value = H5VL_link_specific(vol_obj, &loc_params, H5VL_LINK_ITER, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, FALSE, idx_type, order, idx_p, op, op_data)) < 0) + if((ret_value = H5VL_link_specific(vol_obj, &loc_params, H5VL_LINK_ITER, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, (unsigned)FALSE, (int)idx_type, (int)order, idx_p, op, op_data)) < 0) HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link iteration failed") done: @@ -38,6 +38,8 @@ #include "H5Lprivate.h" /* Links */ #include "H5Opkg.h" /* Object headers */ +#include "H5VLnative_private.h" /* Native VOL connector */ + /****************/ /* Local Macros */ @@ -575,7 +577,7 @@ H5Oget_info2(hid_t loc_id, H5O_info_t *oinfo, unsigned fields) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Retrieve the object's information */ - if(H5VL_object_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_OBJECT_GET_INFO, &loc_params, oinfo, fields) < 0) + if(H5VL_object_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_OBJECT_GET_INFO, &loc_params, oinfo, fields) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get info for object") done: @@ -633,7 +635,7 @@ H5Oget_info_by_name2(hid_t loc_id, const char *name, H5O_info_t *oinfo, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Retrieve the object's information */ - if(H5VL_object_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_OBJECT_GET_INFO, &loc_params, oinfo, fields) < 0) + if(H5VL_object_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_OBJECT_GET_INFO, &loc_params, oinfo, fields) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get info for object: '%s'", name) done: @@ -698,7 +700,7 @@ H5Oget_info_by_idx2(hid_t loc_id, const char *group_name, H5_index_t idx_type, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Retrieve the object's information */ - if(H5VL_object_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_OBJECT_GET_INFO, &loc_params, oinfo, fields) < 0) + if(H5VL_object_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_OBJECT_GET_INFO, &loc_params, oinfo, fields) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get info for object") done: @@ -746,7 +748,7 @@ H5Oset_comment(hid_t obj_id, const char *comment) loc_params.obj_type = H5I_get_type(obj_id); /* (Re)set the object's comment */ - if(H5VL_object_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_OBJECT_SET_COMMENT, &loc_params, comment) < 0) + if(H5VL_object_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_OBJECT_SET_COMMENT, &loc_params, comment) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set comment for object") done: @@ -801,7 +803,7 @@ H5Oset_comment_by_name(hid_t loc_id, const char *name, const char *comment, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* (Re)set the object's comment */ - if(H5VL_object_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_OBJECT_SET_COMMENT, &loc_params, comment) < 0) + if(H5VL_object_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_OBJECT_SET_COMMENT, &loc_params, comment) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set comment for object: '%s'", name) done: @@ -844,7 +846,7 @@ H5Oget_comment(hid_t obj_id, char *comment, size_t bufsize) loc_params.obj_type = H5I_get_type(obj_id); /* Retrieve the object's comment */ - if(H5VL_object_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_OBJECT_GET_COMMENT, &loc_params, comment, bufsize, &ret_value) < 0) + if(H5VL_object_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_OBJECT_GET_COMMENT, &loc_params, comment, bufsize, &ret_value) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, (-1), "can't get comment for object") done: @@ -898,7 +900,7 @@ H5Oget_comment_by_name(hid_t loc_id, const char *name, char *comment, size_t buf HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid location identifier") /* Retrieve the object's comment */ - if(H5VL_object_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_OBJECT_GET_COMMENT, &loc_params, comment, bufsize, &ret_value) < 0) + if(H5VL_object_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_OBJECT_GET_COMMENT, &loc_params, comment, bufsize, &ret_value) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, (-1), "can't get comment for object: '%s'", name) done: @@ -971,7 +973,7 @@ H5Ovisit2(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, loc_params.obj_type = H5I_get_type(obj_id); /* Visit the objects */ - if((ret_value = H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_VISIT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, idx_type, order, op, op_data, fields)) < 0) + if((ret_value = H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_VISIT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, (int)idx_type, (int)order, op, op_data, fields)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object iteration failed") done: @@ -1055,7 +1057,7 @@ H5Ovisit_by_name2(hid_t loc_id, const char *obj_name, H5_index_t idx_type, loc_params.obj_type = H5I_get_type(loc_id); /* Visit the objects */ - if((ret_value = H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_VISIT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, idx_type, order, op, op_data, fields)) < 0) + if((ret_value = H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_VISIT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, (int)idx_type, (int)order, op, op_data, fields)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object iteration failed") done: @@ -1104,7 +1106,6 @@ H5Oclose(hid_t object_id) case H5I_FILE: case H5I_DATASPACE: case H5I_ATTR: - case H5I_REFERENCE: case H5I_VFL: case H5I_VOL: case H5I_GENPROP_CLS: diff --git a/src/H5Odeprec.c b/src/H5Odeprec.c index 93fc18a..7aefc67 100644 --- a/src/H5Odeprec.c +++ b/src/H5Odeprec.c @@ -37,6 +37,8 @@ #include "H5Iprivate.h" /* IDs */ #include "H5Opkg.h" /* Object headers */ +#include "H5VLnative_private.h" /* Native VOL connector */ + /****************/ /* Local Macros */ @@ -109,7 +111,7 @@ H5Oget_info1(hid_t loc_id, H5O_info_t *oinfo) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Retrieve the object's information */ - if(H5VL_object_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_OBJECT_GET_INFO, &loc_params, oinfo, H5O_INFO_ALL) < 0) + if(H5VL_object_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_OBJECT_GET_INFO, &loc_params, oinfo, H5O_INFO_ALL) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get info for object") done: @@ -160,7 +162,7 @@ H5Oget_info_by_name1(hid_t loc_id, const char *name, H5O_info_t *oinfo, hid_t la HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Retrieve the object's information */ - if(H5VL_object_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_OBJECT_GET_INFO, &loc_params, oinfo, H5O_INFO_ALL) < 0) + if(H5VL_object_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_OBJECT_GET_INFO, &loc_params, oinfo, H5O_INFO_ALL) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get info for object: '%s'", name) done: @@ -221,7 +223,7 @@ H5Oget_info_by_idx1(hid_t loc_id, const char *group_name, H5_index_t idx_type, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Retrieve the object's information */ - if(H5VL_object_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_OBJECT_GET_INFO, &loc_params, oinfo, H5O_INFO_ALL) < 0) + if(H5VL_object_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_OBJECT_GET_INFO, &loc_params, oinfo, H5O_INFO_ALL) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get info for object") done: @@ -289,7 +291,7 @@ H5Ovisit1(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, loc_params.obj_type = H5I_get_type(obj_id); /* Visit the objects */ - if((ret_value = H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_VISIT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, idx_type, order, op, op_data, H5O_INFO_ALL)) < 0) + if((ret_value = H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_VISIT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, (int)idx_type, (int)order, op, op_data, H5O_INFO_ALL)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed") done: @@ -368,7 +370,7 @@ H5Ovisit_by_name1(hid_t loc_id, const char *obj_name, H5_index_t idx_type, loc_params.obj_type = H5I_get_type(loc_id); /* Visit the objects */ - if((ret_value = H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_VISIT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, idx_type, order, op, op_data, H5O_INFO_ALL)) < 0) + if((ret_value = H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_VISIT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, (int)idx_type, (int)order, op, op_data, H5O_INFO_ALL)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed") done: diff --git a/src/H5Oflush.c b/src/H5Oflush.c index 3e1ae46..da9d1d0 100644 --- a/src/H5Oflush.c +++ b/src/H5Oflush.c @@ -484,7 +484,6 @@ H5O_refresh_metadata_reopen(hid_t oid, H5G_loc_t *obj_loc, H5VL_t *vol_connector case H5I_FILE: case H5I_DATASPACE: case H5I_ATTR: - case H5I_REFERENCE: case H5I_VFL: case H5I_VOL: case H5I_GENPROP_CLS: diff --git a/src/H5Oint.c b/src/H5Oint.c index 52290f2..2503eb7 100644 --- a/src/H5Oint.c +++ b/src/H5Oint.c @@ -83,7 +83,6 @@ static herr_t H5O__visit_cb(hid_t group, const char *name, const H5L_info_t *lin void *_udata); static const H5O_obj_class_t *H5O__obj_class_real(const H5O_t *oh); - /*********************/ /* Package Variables */ /*********************/ @@ -277,99 +276,183 @@ done: * matzke@llnl.gov * Aug 5 1997 * + * Changes: 2018 August 17 + * Jacob Smith + * Refactor out the operations into two separate steps -- + * preparation and application -- to facilitate overriding the + * library-default size allocated for the object header. This + * function is retained as a wrapper, to minimize changes to + * unaffected calling functions. + * *------------------------------------------------------------------------- */ herr_t -H5O_create(H5F_t *f, size_t size_hint, size_t initial_rc, hid_t ocpl_id, - H5O_loc_t *loc/*out*/) +H5O_create(H5F_t *f, size_t size_hint, size_t initial_rc, hid_t ocpl_id, H5O_loc_t *loc /*out*/) { - H5P_genplist_t *oc_plist; /* Object creation property list */ - H5O_t *oh = NULL; /* Object header created */ - haddr_t oh_addr; /* Address of initial object header */ - size_t oh_size; /* Size of initial object header */ - uint8_t oh_flags; /* Object header's initial status flags */ - unsigned insert_flags = H5AC__NO_FLAGS_SET; /* Flags for inserting object header into cache */ - hbool_t store_msg_crt_idx; /* Whether to always store message creation indices for this file */ - herr_t ret_value = SUCCEED; /* return value */ + H5O_t *oh = NULL; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) - /* check args */ HDassert(f); HDassert(loc); HDassert(TRUE == H5P_isa_class(ocpl_id, H5P_OBJECT_CREATE)); + /* create object header in freelist + * header version is set internally + */ + oh = H5O__create_ohdr(f, ocpl_id); + if(NULL == oh) + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "Can't instantiate object header") + + /* apply object header information to file + */ + if(H5O__apply_ohdr(f, oh, ocpl_id, size_hint, initial_rc, loc) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "Can't apply object header to file") + +done: + if((FAIL == ret_value) && (NULL != oh) && (H5O__free(oh) < 0)) + HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "can't delete object header") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_create() */ + + +/*----------------------------------------------------------------------------- + * Function: H5O__create_ohdr + * + * Purpose: Create the object header, set version and flags. + * + * Return: Success: Pointer to the newly-crated header object. + * Failure: NULL + * + * Programmer: Jacob Smith + * 2018 August 17 + * + *----------------------------------------------------------------------------- + */ +H5O_t * +H5O__create_ohdr(H5F_t *f, hid_t ocpl_id) +{ + H5P_genplist_t *oc_plist; + H5O_t *oh = NULL; /* Object header in Freelist */ + uint8_t oh_flags; /* Initial status flags */ + H5O_t *ret_value = NULL; + + FUNC_ENTER_NOAPI(NULL) + + HDassert(f); + HDassert(TRUE == H5P_isa_class(ocpl_id, H5P_OBJECT_CREATE)); + /* Check for invalid access request */ if(0 == (H5F_INTENT(f) & H5F_ACC_RDWR)) - HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "no write intent on file") + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "no write intent on file") - /* Make certain we allocate at least a reasonable size for the object header */ - size_hint = H5O_ALIGN_F(f, MAX(H5O_MIN_SIZE, size_hint)); + oh = H5FL_CALLOC(H5O_t); + if(NULL == oh) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") - /* Get the property list */ - if(NULL == (oc_plist = (H5P_genplist_t *)H5I_object(ocpl_id))) - HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a property list") + oc_plist = (H5P_genplist_t *)H5I_object(ocpl_id); + if(NULL == oc_plist) + HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, NULL, "not a property list") /* Get any object header status flags set by properties */ if(H5P_get(oc_plist, H5O_CRT_OHDR_FLAGS_NAME, &oh_flags) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get object header flags") + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get object header flags") - /* Allocate the object header and zero out header fields */ - if(NULL == (oh = H5FL_CALLOC(H5O_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + if(H5O_set_version(f, oh, oh_flags, H5F_STORE_MSG_CRT_IDX(f)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, NULL, "can't set version of object header") + + oh->flags = oh_flags; + + ret_value = oh; + +done: + if((NULL == ret_value) && (NULL != oh) && (H5O__free(oh) < 0)) + HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, NULL, "can't delete object header") + + FUNC_LEAVE_NOAPI(ret_value) +} /* H5O__create_ohdr() */ - /* Initialize file-specific information for object header */ - store_msg_crt_idx = H5F_STORE_MSG_CRT_IDX(f); + +/*----------------------------------------------------------------------------- + * Function: H5O__apply_ohdr + * + * Purpose: Initialize and set the object header in the file. + * Record some information at `loc_out`. + * + * Return: Success: SUCCEED (0) (non-negative value) + * Failure: FAIL (-1) (negative value) + * + * Programmer: Jacob Smith + * 2018 August 17 + * + *----------------------------------------------------------------------------- + */ +herr_t +H5O__apply_ohdr(H5F_t *f, H5O_t *oh, hid_t ocpl_id, size_t size_hint, size_t initial_rc, H5O_loc_t *loc_out) +{ + haddr_t oh_addr; + size_t oh_size; + H5P_genplist_t *oc_plist = NULL; + unsigned insert_flags = H5AC__NO_FLAGS_SET; + herr_t ret_value = SUCCEED; - if(H5O_set_version(f, oh, oh_flags, store_msg_crt_idx) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set version of objecdt header") + FUNC_ENTER_NOAPI(FAIL) + + HDassert(f); + HDassert(loc_out); + HDassert(oh); + HDassert(TRUE == H5P_isa_class(ocpl_id, H5P_OBJECT_CREATE)); + + /* Allocate at least a reasonable size for the object header */ + size_hint = H5O_ALIGN_F(f, MAX(H5O_MIN_SIZE, size_hint)); oh->sizeof_size = H5F_SIZEOF_SIZE(f); oh->sizeof_addr = H5F_SIZEOF_ADDR(f); - oh->swmr_write = !!(H5F_INTENT(f) & H5F_ACC_SWMR_WRITE); + oh->swmr_write = !!(H5F_INTENT(f) & H5F_ACC_SWMR_WRITE); /* funky cast */ + #ifdef H5O_ENABLE_BAD_MESG_COUNT /* Check whether the "bad message count" property is set */ - if(H5P_exist_plist(oc_plist, H5O_BAD_MESG_COUNT_NAME) > 0) { - /* Retrieve bad message count flag */ + if(0 < H5P_exist_plist(oc_plist, H5O_BAD_MESG_COUNT_NAME)) + /* Get bad message count flag -- from property list */ if(H5P_get(oc_plist, H5O_BAD_MESG_COUNT_NAME, &oh->store_bad_mesg_count) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get bad message count flag") - } #endif /* H5O_ENABLE_BAD_MESG_COUNT */ /* Create object header proxy if doing SWMR writes */ if(oh->swmr_write) { - /* Create virtual entry, for use as proxy */ - if(NULL == (oh->proxy = H5AC_proxy_entry_create())) + oh->proxy = H5AC_proxy_entry_create(); + if(NULL == oh->proxy) HGOTO_ERROR(H5E_OHDR, H5E_CANTCREATE, FAIL, "can't create object header proxy") - } - else + } else { oh->proxy = NULL; + } - /* Set initial status flags */ - oh->flags = oh_flags; + oc_plist = (H5P_genplist_t *)H5I_object(ocpl_id); + if(NULL == oc_plist) + HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a property list") /* Initialize version-specific fields */ if(oh->version > H5O_VERSION_1) { - /* Initialize all time fields with current time, if we are storing them */ + /* Initialize all time fields */ if(oh->flags & H5O_HDR_STORE_TIMES) oh->atime = oh->mtime = oh->ctime = oh->btime = H5_now(); else oh->atime = oh->mtime = oh->ctime = oh->btime = 0; - /* Make certain attribute creation order tracking is enabled if - * attributes can be shared in this file. - */ - if(store_msg_crt_idx) + if(H5F_STORE_MSG_CRT_IDX(f)) + /* flag to record message creation indices */ oh->flags |= H5O_HDR_ATTR_CRT_ORDER_TRACKED; - /* Retrieve attribute storage phase change values from property list */ + /* Get attribute storage phase change values -- from property list */ if(H5P_get(oc_plist, H5O_CRT_ATTR_MAX_COMPACT_NAME, &oh->max_compact) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get max. # of compact attributes") if(H5P_get(oc_plist, H5O_CRT_ATTR_MIN_DENSE_NAME, &oh->min_dense) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get min. # of dense attributes") /* Check for non-default attribute storage phase change values */ - if(oh->max_compact != H5O_CRT_ATTR_MAX_COMPACT_DEF || oh->min_dense != H5O_CRT_ATTR_MIN_DENSE_DEF) + if(H5O_CRT_ATTR_MAX_COMPACT_DEF != oh->max_compact || H5O_CRT_ATTR_MIN_DENSE_DEF != oh->min_dense ) oh->flags |= H5O_HDR_ATTR_STORE_PHASE_CHANGE; /* Determine correct value for chunk #0 size bits */ @@ -383,23 +466,25 @@ H5O_create(H5F_t *f, size_t size_hint, size_t initial_rc, hid_t ocpl_id, oh->flags |= H5O_HDR_CHUNK0_4; else if(size_hint > 255) oh->flags |= H5O_HDR_CHUNK0_2; - } /* end if */ - else { + } else { /* Reset unused time fields */ oh->atime = oh->mtime = oh->ctime = oh->btime = 0; - } /* end else */ + } /* end if/else header version >1 */ /* Compute total size of initial object header */ /* (i.e. object header prefix and first chunk) */ oh_size = (size_t)H5O_SIZEOF_HDR(oh) + size_hint; /* Allocate disk space for header and first chunk */ - if(HADDR_UNDEF == (oh_addr = H5MF_alloc(f, H5FD_MEM_OHDR, (hsize_t)oh_size))) + oh_addr = H5MF_alloc(f, H5FD_MEM_OHDR, (hsize_t)oh_size); + if(HADDR_UNDEF == oh_addr) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "file allocation failed for object header") /* Create the chunk list */ - oh->nchunks = oh->alloc_nchunks = 1; - if(NULL == (oh->chunk = H5FL_SEQ_MALLOC(H5O_chunk_t, (size_t)oh->alloc_nchunks))) + oh->nchunks = 1; + oh->alloc_nchunks = 1; + oh->chunk = H5FL_SEQ_MALLOC(H5O_chunk_t, (size_t)oh->alloc_nchunks); + if(NULL == oh->chunk) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Initialize the first chunk */ @@ -409,25 +494,27 @@ H5O_create(H5F_t *f, size_t size_hint, size_t initial_rc, hid_t ocpl_id, /* Allocate enough space for the first chunk */ /* (including space for serializing the object header prefix */ - if(NULL == (oh->chunk[0].image = H5FL_BLK_CALLOC(chunk_image, oh_size))) + oh->chunk[0].image = H5FL_BLK_CALLOC(chunk_image, oh_size); + if(NULL == oh->chunk[0].image) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") oh->chunk[0].chunk_proxy = NULL; /* Put magic # for object header in first chunk */ - if(oh->version > H5O_VERSION_1) + if(H5O_VERSION_1 < oh->version) HDmemcpy(oh->chunk[0].image, H5O_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC); /* Create the message list */ oh->nmesgs = 1; oh->alloc_nmesgs = H5O_NMESGS; - if(NULL == (oh->mesg = H5FL_SEQ_CALLOC(H5O_mesg_t, oh->alloc_nmesgs))) + oh->mesg = H5FL_SEQ_CALLOC(H5O_mesg_t, oh->alloc_nmesgs); + if(NULL == oh->mesg) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - /* Initialize the initial "null" message, covering the entire first chunk */ + /* Initialize the initial "null" message; covers the entire first chunk */ oh->mesg[0].type = H5O_MSG_NULL; oh->mesg[0].dirty = TRUE; oh->mesg[0].native = NULL; - oh->mesg[0].raw = oh->chunk[0].image + (H5O_SIZEOF_HDR(oh) - H5O_SIZEOF_CHKSUM_OH(oh)) + H5O_SIZEOF_MSGHDR_OH(oh); + oh->mesg[0].raw = oh->chunk[0].image + H5O_SIZEOF_HDR(oh) - H5O_SIZEOF_CHKSUM_OH(oh) + H5O_SIZEOF_MSGHDR_OH(oh); oh->mesg[0].raw_size = size_hint - (size_t)H5O_SIZEOF_MSGHDR_OH(oh); oh->mesg[0].chunkno = 0; @@ -452,20 +539,15 @@ H5O_create(H5F_t *f, size_t size_hint, size_t initial_rc, hid_t ocpl_id, H5_END_TAG /* Set up object location */ - loc->file = f; - loc->addr = oh_addr; + loc_out->file = f; + loc_out->addr = oh_addr; - /* Open it */ - if(H5O_open(loc) < 0) + if(H5O_open(loc_out) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open object header") done: - if(ret_value < 0 && oh) - if(H5O__free(oh) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to destroy object header data") - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_create() */ + FUNC_LEAVE_NOAPI(ret_value); +} /* H5O__apply_ohdr() */ /*------------------------------------------------------------------------- @@ -1765,7 +1847,6 @@ H5O_get_loc(hid_t object_id) case H5I_FILE: case H5I_DATASPACE: case H5I_ATTR: - case H5I_REFERENCE: case H5I_VFL: case H5I_VOL: case H5I_GENPROP_CLS: @@ -2421,6 +2502,63 @@ H5O_get_oh_addr(const H5O_t *oh) /*------------------------------------------------------------------------- + * Function: H5O_get_oh_flags + * + * Programmer: Jacob Smith + * 2018 August 17 + * + *------------------------------------------------------------------------- + */ +uint8_t +H5O_get_oh_flags(const H5O_t *oh) +{ + FUNC_ENTER_NOAPI_NOINIT_NOERR + HDassert(oh); + FUNC_LEAVE_NOAPI(oh->flags); /* flags can be 0 */ +} /* H5O_get_oh_flags() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_get_oh_mtime + * + * Purpose: Retrieve an object's modification time. Assumes that the + * caller has verified that accessing this variable is appropriate + * to the header in question. + * + * Programmer: Jacob Smith + * 2018 August 17 + * + *------------------------------------------------------------------------- + */ +time_t +H5O_get_oh_mtime(const H5O_t *oh) +{ + FUNC_ENTER_NOAPI_NOINIT_NOERR + HDassert(oh); + HDassert(oh->mtime); + FUNC_LEAVE_NOAPI(oh->mtime); +} /* H5O_get_oh_mtime() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_get_oh_version + * + * Programmer: Jacob Smith + * 2018 August 17 + * + *------------------------------------------------------------------------- + */ +uint8_t +H5O_get_oh_version(const H5O_t *oh) +{ + FUNC_ENTER_NOAPI_NOINIT_NOERR + HDassert(oh); + HDassert(oh->version); + FUNC_LEAVE_NOAPI(oh->version); +} /* H5O_get_oh_version() */ + + +/*------------------------------------------------------------------------- * Function: H5O_get_rc_and_type * * Purpose: Retrieve an object's reference count and type diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h index e8565b9..e0926e2 100644 --- a/src/H5Oprivate.h +++ b/src/H5Oprivate.h @@ -121,8 +121,14 @@ typedef struct H5O_mesg_t H5O_mesg_t; /* If the module using this macro is allowed access to the private variables, access them directly */ #ifdef H5O_MODULE #define H5O_OH_GET_ADDR(O) ((O)->chunk[0].addr) +#define H5O_OH_GET_VERSION(O) ((O)->version) +#define H5O_OH_GET_FLAGS(O) ((O)->flags) +#define H5O_OH_GET_MTIME(O) ((O)->mtime) #else /* H5O_MODULE */ #define H5O_OH_GET_ADDR(O) (H5O_get_oh_addr(O)) +#define H5O_OH_GET_VERSION(O) (H5O_get_oh_version(O)) +#define H5O_OH_GET_FLAGS(O) (H5O_get_oh_flags(O)) +#define H5O_OH_GET_MTIME(O) (H5O_get_oh_mtime(O)) #endif /* H5O_MODULE */ /* Set the fields in a shared message structure */ @@ -851,13 +857,6 @@ typedef struct { } u; } H5O_mesg_operator_t; -/* Types for object optional VOL operations */ -typedef enum H5VL_object_optional_t { - H5VL_OBJECT_GET_COMMENT, /* get object comment */ - H5VL_OBJECT_GET_INFO, /* get object info */ - H5VL_OBJECT_SET_COMMENT /* set object comment */ -} H5VL_object_optional_t; - /* Typedef for abstract object creation */ typedef struct { H5O_type_t obj_type; /* Type of object to create */ @@ -872,6 +871,9 @@ struct H5P_genplist_t; H5_DLL herr_t H5O_init(void); H5_DLL herr_t H5O_create(H5F_t *f, size_t size_hint, size_t initial_rc, hid_t ocpl_id, H5O_loc_t *loc/*out*/); +H5_DLL H5O_t *H5O__create_ohdr(H5F_t *f, hid_t ocpl_id); +H5_DLL herr_t H5O__apply_ohdr(H5F_t *f, H5O_t *oh, hid_t ocpl_id, + size_t size_hint, size_t initial_rc, H5O_loc_t *loc_out); H5_DLL herr_t H5O_open(H5O_loc_t *loc); H5_DLL void *H5O_open_by_idx(const H5G_loc_t *loc, const char *name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5I_type_t *opened_type/*out*/); @@ -898,6 +900,9 @@ H5_DLL void *H5O_open_name(const H5G_loc_t *loc, const char *name, H5I_type_t *o H5_DLL herr_t H5O_get_nlinks(const H5O_loc_t *loc, hsize_t *nlinks); H5_DLL void *H5O_obj_create(H5F_t *f, H5O_type_t obj_type, void *crt_info, H5G_loc_t *obj_loc); H5_DLL haddr_t H5O_get_oh_addr(const H5O_t *oh); +H5_DLL uint8_t H5O_get_oh_flags(const H5O_t *oh); +H5_DLL time_t H5O_get_oh_mtime(const H5O_t *oh); +H5_DLL uint8_t H5O_get_oh_version(const H5O_t *oh); H5_DLL herr_t H5O_get_rc_and_type(const H5O_loc_t *oloc, unsigned *rc, H5O_type_t *otype); H5_DLL H5AC_proxy_entry_t *H5O_get_proxy(const H5O_t *oh); diff --git a/src/H5Opublic.h b/src/H5Opublic.h index da2910d..c868e72 100644 --- a/src/H5Opublic.h +++ b/src/H5Opublic.h @@ -150,18 +150,19 @@ typedef enum H5O_mcdt_search_ret_t { /* Callback to invoke when completing the search for a matching committed datatype from the committed dtype list */ typedef H5O_mcdt_search_ret_t (*H5O_mcdt_search_cb_t)(void *op_data); + /********************/ /* Public Variables */ /********************/ +/*********************/ +/* Public Prototypes */ +/*********************/ #ifdef __cplusplus extern "C" { #endif -/*********************/ -/* Public Prototypes */ -/*********************/ H5_DLL hid_t H5Oopen(hid_t loc_id, const char *name, hid_t lapl_id); H5_DLL hid_t H5Oopen_by_addr(hid_t loc_id, haddr_t addr); H5_DLL hid_t H5Oopen_by_idx(hid_t loc_id, const char *group_name, diff --git a/src/H5PLint.c b/src/H5PLint.c index bbe71fe..8dec14b 100644 --- a/src/H5PLint.c +++ b/src/H5PLint.c @@ -262,7 +262,7 @@ H5PL_load(H5PL_type_t type, const H5PL_key_t *key) /* Set up the search parameters */ search_params.type = type; - search_params.key.id = key->id; + search_params.key = key; /* Search in the table of already loaded plugin libraries */ if(H5PL__find_plugin_in_cache(&search_params, &found, &plugin_info) < 0) @@ -311,6 +311,7 @@ H5PL__open(const char *path, H5PL_type_t type, const H5PL_key_t *key, hbool_t *success, const void **plugin_info) { H5PL_HANDLE handle = NULL; + H5PL_get_plugin_type_t get_plugin_type = NULL; H5PL_get_plugin_info_t get_plugin_info = NULL; herr_t ret_value = SUCCEED; @@ -333,12 +334,22 @@ H5PL__open(const char *path, H5PL_type_t type, const H5PL_key_t *key, HGOTO_DONE(SUCCEED) } + /* Return a handle for the function H5PLget_plugin_type in the dynamic library. + * The plugin library is supposed to define this function. + */ + if (NULL == (get_plugin_type = (H5PL_get_plugin_type_t)H5PL_GET_LIB_FUNC(handle, "H5PLget_plugin_type"))) + HGOTO_DONE(SUCCEED) + /* Return a handle for the function H5PLget_plugin_info in the dynamic library. - * The plugin library is suppose to define this function. + * The plugin library is supposed to define this function. */ if (NULL == (get_plugin_info = (H5PL_get_plugin_info_t)H5PL_GET_LIB_FUNC(handle, "H5PLget_plugin_info"))) HGOTO_DONE(SUCCEED) + /* Check the plugin type and return if it doesn't match the one passed in */ + if(type != (H5PL_type_t)(*get_plugin_type)()) + HGOTO_DONE(SUCCEED) + /* Get the plugin information */ switch (type) { case H5PL_TYPE_FILTER: @@ -364,7 +375,7 @@ H5PL__open(const char *path, H5PL_type_t type, const H5PL_key_t *key, /* Get the plugin info */ if(NULL == (cls = (const H5VL_class_t *)(*get_plugin_info)())) - HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "can't get VOL driver info from plugin") + HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "can't get VOL connector info from plugin") /* Which kind of key are we looking for? */ if(key->vol.kind == H5VL_GET_CONNECTOR_BY_NAME) { diff --git a/src/H5PLpath.c b/src/H5PLpath.c index d53007b..04248b5 100644 --- a/src/H5PLpath.c +++ b/src/H5PLpath.c @@ -242,6 +242,7 @@ H5PL__create_path_table(void) * environment variable or the default. */ char *next_path = NULL; /* A path tokenized from the paths string */ + char *lasts = NULL; /* Context pointer for strtok_r() call */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -265,8 +266,7 @@ H5PL__create_path_table(void) HGOTO_ERROR(H5E_PLUGIN, H5E_CANTALLOC, FAIL, "can't allocate memory for path copy") /* Separate the paths and store them */ - /* XXX: strtok() is not thread-safe */ - next_path = HDstrtok(paths, H5PL_PATH_SEPARATOR); + next_path = HDstrtok_r(paths, H5PL_PATH_SEPARATOR, &lasts); while (next_path) { /* Insert the path into the table */ @@ -274,7 +274,7 @@ H5PL__create_path_table(void) HGOTO_ERROR(H5E_PLUGIN, H5E_CANTALLOC, FAIL, "can't insert path: %s", next_path) /* Get the next path from the environment string */ - next_path = HDstrtok(NULL, H5PL_PATH_SEPARATOR); + next_path = HDstrtok_r(NULL, H5PL_PATH_SEPARATOR, &lasts); } /* end while */ done: @@ -689,7 +689,7 @@ H5PL__find_plugin_in_path(const H5PL_search_params_t *search_params, hbool_t *fo continue; /* attempt to open the dynamic library as a filter library */ - if (H5PL__open(path, search_params->type, &(search_params->key), found, plugin_info) < 0) + if (H5PL__open(path, search_params->type, search_params->key, found, plugin_info) < 0) HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "search in directory failed") if (*found) HGOTO_DONE(SUCCEED) @@ -755,7 +755,7 @@ H5PL__find_plugin_in_path(const H5PL_search_params_t *search_params, hbool_t *fo continue; /* attempt to open the dynamic library as a filter library */ - if (H5PL__open(path, search_params->type, &(search_params->key), found, plugin_info) < 0) + if (H5PL__open(path, search_params->type, search_params->key, found, plugin_info) < 0) HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "search in directory failed") if (*found) HGOTO_DONE(SUCCEED) diff --git a/src/H5PLpkg.h b/src/H5PLpkg.h index d60da82..8c2367f 100644 --- a/src/H5PLpkg.h +++ b/src/H5PLpkg.h @@ -79,6 +79,7 @@ /* maximum size for expanding env vars */ # define H5PL_EXPAND_BUFFER_SIZE 32767 + typedef H5PL_type_t(__cdecl *H5PL_get_plugin_type_t)(void); typedef const void *(__cdecl *H5PL_get_plugin_info_t)(void); #else /* H5_HAVE_WIN32_API */ @@ -105,6 +106,7 @@ /* Clear error */ # define H5PL_CLR_ERROR HERROR(H5E_PLUGIN, H5E_CANTGET, "can't dlopen:%s", dlerror()) + typedef H5PL_type_t(*H5PL_get_plugin_type_t)(void); typedef const void *(*H5PL_get_plugin_info_t)(void); #endif /* H5_HAVE_WIN32_API */ @@ -116,7 +118,7 @@ /* Data used to search for plugins */ typedef struct H5PL_search_params_t { H5PL_type_t type; - H5PL_key_t key; + const H5PL_key_t *key; } H5PL_search_params_t; diff --git a/src/H5PLplugin_cache.c b/src/H5PLplugin_cache.c index 7fe676d..cd0b4d6 100644 --- a/src/H5PLplugin_cache.c +++ b/src/H5PLplugin_cache.c @@ -276,7 +276,7 @@ H5PL__find_plugin_in_cache(const H5PL_search_params_t *search_params, hbool_t *f for (u = 0; u < H5PL_num_plugins_g; u++) { /* If the plugin type (filter, etc.) and ID match, query the plugin for its info */ - if ((search_params->type == (H5PL_cache_g[u]).type) && (search_params->key.id == (H5PL_cache_g[u]).key.id)) { + if ((search_params->type == (H5PL_cache_g[u]).type) && (search_params->key->id == (H5PL_cache_g[u]).key.id)) { H5PL_get_plugin_info_t get_plugin_info_function; const H5Z_class2_t *filter_info; diff --git a/src/H5Pdcpl.c b/src/H5Pdcpl.c index a5a16bb..b85f105 100644 --- a/src/H5Pdcpl.c +++ b/src/H5Pdcpl.c @@ -117,6 +117,11 @@ #define H5D_CRT_EXT_FILE_LIST_COPY H5P__dcrt_ext_file_list_copy #define H5D_CRT_EXT_FILE_LIST_CMP H5P__dcrt_ext_file_list_cmp #define H5D_CRT_EXT_FILE_LIST_CLOSE H5P__dcrt_ext_file_list_close +/* Definitions for dataset object header minimization */ +#define H5D_CRT_MIN_DSET_HDR_SIZE_SIZE sizeof(hbool_t) +#define H5D_CRT_MIN_DSET_HDR_SIZE_DEF FALSE +#define H5D_CRT_MIN_DSET_HDR_SIZE_ENC H5P__encode_hbool_t +#define H5D_CRT_MIN_DSET_HDR_SIZE_DEC H5P__decode_hbool_t /******************/ @@ -209,6 +214,7 @@ static const H5O_layout_t H5D_def_layout_g = H5D_CRT_LAYOUT_DEF; /* Defau static const H5O_fill_t H5D_def_fill_g = H5D_CRT_FILL_VALUE_DEF; /* Default fill value */ static const unsigned H5D_def_alloc_time_state_g = H5D_CRT_ALLOC_TIME_STATE_DEF; /* Default allocation time state */ static const H5O_efl_t H5D_def_efl_g = H5D_CRT_EXT_FILE_LIST_DEF; /* Default external file list */ +static const unsigned H5O_ohdr_min_g = H5D_CRT_MIN_DSET_HDR_SIZE_DEF; /* Default object header minimization */ /* Defaults for each type of layout */ #ifdef H5_HAVE_C99_DESIGNATED_INITIALIZER @@ -271,6 +277,12 @@ H5P__dcrt_reg_prop(H5P_genclass_t *pclass) H5D_CRT_EXT_FILE_LIST_DEL, H5D_CRT_EXT_FILE_LIST_COPY, H5D_CRT_EXT_FILE_LIST_CMP, H5D_CRT_EXT_FILE_LIST_CLOSE) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + /* Register the object header minimization property */ + if(H5P__register_real(pclass, H5D_CRT_MIN_DSET_HDR_SIZE_NAME, H5D_CRT_MIN_DSET_HDR_SIZE_SIZE, &H5O_ohdr_min_g, + NULL, NULL, NULL, H5D_CRT_MIN_DSET_HDR_SIZE_ENC, H5D_CRT_MIN_DSET_HDR_SIZE_DEC, + NULL, NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + /* Register the type ID property*/ if(H5P__register_real(pclass, H5VL_PROP_DSET_TYPE_ID, sizeof(hid_t), &type_id, NULL, NULL, NULL, NULL, NULL, NULL, NULL, H5P_ignore_cmp, NULL) < 0) @@ -3749,3 +3761,95 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_fill_time() */ + +/*----------------------------------------------------------------------------- + * Function: H5Pget_dset_no_attrs_hint + * + * Purpose: + * + * Access the flag for whether or not datasets created by the given dcpl + * will be created with a "minimized" object header. + * + * Return: + * + * Failure: Negative value (FAIL) + * Success: Non-negative value (SUCCEED) + * + * Programmer: Jacob Smith + * 2018 August 14 + * + * Modifications: None. + * + *----------------------------------------------------------------------------- + */ +herr_t +H5Pget_dset_no_attrs_hint(hid_t dcpl_id, hbool_t *minimize) +{ + hbool_t setting = FALSE; + H5P_genplist_t *plist = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE2("e", "i*b", dcpl_id, minimize); + + if(NULL == minimize) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "receiving pointer cannot be NULL") + + plist = H5P_object_verify(dcpl_id, H5P_DATASET_CREATE); + if(NULL == plist) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") + + if(H5P_peek(plist, H5D_CRT_MIN_DSET_HDR_SIZE_NAME, &setting) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get dset oh minimize flag value") + + *minimize = setting; + +done: + FUNC_LEAVE_API(ret_value) +} /* H5Pget_dset_no_attrs_hint() */ + + +/*----------------------------------------------------------------------------- + * Function: H5Pset_dset_no_attrs_hint + * + * Purpose: + * + * Set the dcpl to minimize (or explicitly to not minimized) dataset object + * headers upon creation. + * + * Return: + * + * Failure: Negative value (FAIL) + * Success: Non-negative value (SUCCEED) + * + * Programmer: Jacob Smith + * 2018 August 14 + * + * Modifications: None. + * + *----------------------------------------------------------------------------- + */ +herr_t +H5Pset_dset_no_attrs_hint(hid_t dcpl_id, hbool_t minimize) +{ + H5P_genplist_t *plist = NULL; + hbool_t prev_set = FALSE; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE2("e", "ib", dcpl_id, minimize); + + plist = H5P_object_verify(dcpl_id, H5P_DATASET_CREATE); + if(NULL == plist) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") + + if(H5P_peek(plist, H5D_CRT_MIN_DSET_HDR_SIZE_NAME, &prev_set) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get extant dset oh minimize flag value") + + if(H5P_poke(plist, H5D_CRT_MIN_DSET_HDR_SIZE_NAME, &minimize) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't get dset oh minimize flag value") + +done: + FUNC_LEAVE_API(ret_value) +} /* H5Pset_dset_no_attrs_hint() */ + diff --git a/src/H5Pfapl.c b/src/H5Pfapl.c index 923c792..452ea3f 100644 --- a/src/H5Pfapl.c +++ b/src/H5Pfapl.c @@ -49,7 +49,7 @@ #endif /* Includes needed to set default VOL connector */ -#include "H5VLnative.h" /* Native VOL connector */ +#include "H5VLnative_private.h" /* Native VOL connector */ /****************/ @@ -177,16 +177,6 @@ #define H5F_ACS_FILE_IMAGE_INFO_COPY H5P__facc_file_image_info_copy #define H5F_ACS_FILE_IMAGE_INFO_CMP H5P__facc_file_image_info_cmp #define H5F_ACS_FILE_IMAGE_INFO_CLOSE H5P__facc_file_image_info_close -/* Definition of core VFD write tracking flag */ -#define H5F_ACS_CORE_WRITE_TRACKING_FLAG_SIZE sizeof(hbool_t) -#define H5F_ACS_CORE_WRITE_TRACKING_FLAG_DEF FALSE -#define H5F_ACS_CORE_WRITE_TRACKING_FLAG_ENC H5P__encode_hbool_t -#define H5F_ACS_CORE_WRITE_TRACKING_FLAG_DEC H5P__decode_hbool_t -/* Definition of core VFD write tracking page size */ -#define H5F_ACS_CORE_WRITE_TRACKING_PAGE_SIZE_SIZE sizeof(size_t) -#define H5F_ACS_CORE_WRITE_TRACKING_PAGE_SIZE_DEF 524288 -#define H5F_ACS_CORE_WRITE_TRACKING_PAGE_SIZE_ENC H5P__encode_size_t -#define H5F_ACS_CORE_WRITE_TRACKING_PAGE_SIZE_DEC H5P__decode_size_t /* Definition for # of metadata read attempts */ #define H5F_ACS_METADATA_READ_ATTEMPTS_SIZE sizeof(unsigned) #define H5F_ACS_METADATA_READ_ATTEMPTS_DEF 0 @@ -401,8 +391,6 @@ static const H5F_libver_t H5F_def_libver_high_bound_g = H5F_ACS_LIBVER_HIGH_BOUN static const hbool_t H5F_def_want_posix_fd_g = H5F_ACS_WANT_POSIX_FD_DEF; /* Default setting for retrieving 'handle' from core VFD */ static const unsigned H5F_def_efc_size_g = H5F_ACS_EFC_SIZE_DEF; /* Default external file cache size */ static const H5FD_file_image_info_t H5F_def_file_image_info_g = H5F_ACS_FILE_IMAGE_INFO_DEF; /* Default file image info and callbacks */ -static const hbool_t H5F_def_core_write_tracking_flag_g = H5F_ACS_CORE_WRITE_TRACKING_FLAG_DEF; /* Default setting for core VFD write tracking */ -static const size_t H5F_def_core_write_tracking_page_size_g = H5F_ACS_CORE_WRITE_TRACKING_PAGE_SIZE_DEF; /* Default core VFD write tracking page size */ static const unsigned H5F_def_metadata_read_attempts_g = H5F_ACS_METADATA_READ_ATTEMPTS_DEF; /* Default setting for the # of metadata read attempts */ static const H5F_object_flush_t H5F_def_object_flush_cb_g = H5F_ACS_OBJECT_FLUSH_CB_DEF; /* Default setting for object flush callback */ static const hbool_t H5F_def_clear_status_flags_g = H5F_ACS_CLEAR_STATUS_FLAGS_DEF; /* Default to clear the superblock status_flags */ @@ -572,18 +560,6 @@ H5P__facc_reg_prop(H5P_genclass_t *pclass) H5F_ACS_FILE_IMAGE_INFO_DEL, H5F_ACS_FILE_IMAGE_INFO_COPY, H5F_ACS_FILE_IMAGE_INFO_CMP, H5F_ACS_FILE_IMAGE_INFO_CLOSE) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") - /* Register the core VFD backing store write tracking flag */ - if(H5P__register_real(pclass, H5F_ACS_CORE_WRITE_TRACKING_FLAG_NAME, H5F_ACS_CORE_WRITE_TRACKING_FLAG_SIZE, &H5F_def_core_write_tracking_flag_g, - NULL, NULL, NULL, H5F_ACS_CORE_WRITE_TRACKING_FLAG_ENC, H5F_ACS_CORE_WRITE_TRACKING_FLAG_DEC, - NULL, NULL, NULL, NULL) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") - - /* Register the size of the core VFD backing store page size */ - if(H5P__register_real(pclass, H5F_ACS_CORE_WRITE_TRACKING_PAGE_SIZE_NAME, H5F_ACS_CORE_WRITE_TRACKING_PAGE_SIZE_SIZE, &H5F_def_core_write_tracking_page_size_g, - NULL, NULL, NULL, H5F_ACS_CORE_WRITE_TRACKING_PAGE_SIZE_ENC, H5F_ACS_CORE_WRITE_TRACKING_PAGE_SIZE_DEC, - NULL, NULL, NULL, NULL) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") - /* Register the # of read attempts */ if(H5P__register_real(pclass, H5F_ACS_METADATA_READ_ATTEMPTS_NAME, H5F_ACS_METADATA_READ_ATTEMPTS_SIZE, &H5F_def_metadata_read_attempts_g, NULL, NULL, NULL, H5F_ACS_METADATA_READ_ATTEMPTS_ENC, H5F_ACS_METADATA_READ_ATTEMPTS_DEC, @@ -3957,89 +3933,6 @@ H5P__facc_libver_type_dec(const void **_pp, void *_value) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__facc_libver_type_dec() */ - -/*------------------------------------------------------------------------- - * Function: H5Pset_core_write_tracking - * - * Purpose: Enables/disables core VFD write tracking and page - * aggregation size. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Dana Robinson - * Tuesday, April 8, 2014 - * - *------------------------------------------------------------------------- - */ -herr_t -H5Pset_core_write_tracking(hid_t plist_id, hbool_t is_enabled, size_t page_size) -{ - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ - - FUNC_ENTER_API(FAIL) - H5TRACE3("e", "ibz", plist_id, is_enabled, page_size); - - /* The page size cannot be zero */ - if(page_size == 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "page_size cannot be zero") - - /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") - - /* Set values */ - if(H5P_set(plist, H5F_ACS_CORE_WRITE_TRACKING_FLAG_NAME, &is_enabled) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set core VFD write tracking flag") - if(H5P_set(plist, H5F_ACS_CORE_WRITE_TRACKING_PAGE_SIZE_NAME, &page_size) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set core VFD write tracking page size") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5Pset_core_write_tracking() */ - - -/*------------------------------------------------------------------------- - * Function: H5Pget_core_write_tracking - * - * Purpose: Gets information about core VFD write tracking and page - * aggregation size. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Dana Robinson - * Tuesday, April 8, 2014 - * - *------------------------------------------------------------------------- - */ -herr_t -H5Pget_core_write_tracking(hid_t plist_id, hbool_t *is_enabled, size_t *page_size) -{ - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ - - FUNC_ENTER_API(FAIL) - H5TRACE3("e", "i*b*z", plist_id, is_enabled, page_size); - - /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") - - /* Get values */ - if(is_enabled) { - if(H5P_get(plist, H5F_ACS_CORE_WRITE_TRACKING_FLAG_NAME, is_enabled) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get core VFD write tracking flag") - } /* end if */ - - if(page_size) { - if(H5P_get(plist, H5F_ACS_CORE_WRITE_TRACKING_PAGE_SIZE_NAME, page_size) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get core VFD write tracking page size") - } /* end if */ - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5Pget_core_write_tracking() */ - /*------------------------------------------------------------------------- * Function: H5Pset_metadata_read_attempts diff --git a/src/H5Ppublic.h b/src/H5Ppublic.h index 86c6687..2f094ea 100644 --- a/src/H5Ppublic.h +++ b/src/H5Ppublic.h @@ -412,6 +412,8 @@ H5_DLL herr_t H5Pget_alloc_time(hid_t plist_id, H5D_alloc_time_t H5_DLL herr_t H5Pset_fill_time(hid_t plist_id, H5D_fill_time_t fill_time); H5_DLL herr_t H5Pget_fill_time(hid_t plist_id, H5D_fill_time_t *fill_time/*out*/); +H5_DLL herr_t H5Pget_dset_no_attrs_hint(hid_t dcpl_id, hbool_t *minimize); +H5_DLL herr_t H5Pset_dset_no_attrs_hint(hid_t dcpl_id, hbool_t minimize); /* Dataset access property list (DAPL) routines */ H5_DLL herr_t H5Pset_chunk_cache(hid_t dapl_id, size_t rdcc_nslots, @@ -127,7 +127,7 @@ H5Rcreate(void *ref, hid_t loc_id, const char *name, H5R_type_t ref_type, hid_t HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, FAIL, "can't set access property list info") /* Create reference */ - if((ret_value = H5VL_object_specific(vol_obj, &loc_params, H5VL_REF_CREATE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, ref, name, ref_type, space_id)) < 0) + if((ret_value = H5VL_object_specific(vol_obj, &loc_params, H5VL_REF_CREATE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, ref, name, (int)ref_type, space_id)) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCREATE, FAIL, "unable to create reference") done: @@ -257,7 +257,7 @@ H5Rget_region(hid_t id, H5R_type_t ref_type, const void *ref) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid file identifier") /* Get the dataspace with the correct region selected */ - if(H5VL_object_get(vol_obj, &loc_params, H5VL_REF_GET_REGION, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value, ref_type, ref) < 0) + if(H5VL_object_get(vol_obj, &loc_params, H5VL_REF_GET_REGION, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value, (int)ref_type, ref) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, H5I_INVALID_HID, "unable to retrieve dataspace") done: @@ -314,7 +314,7 @@ H5Rget_obj_type2(hid_t id, H5R_type_t ref_type, const void *ref, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") /* Get the object type */ - if(H5VL_object_get(vol_obj, &loc_params, H5VL_REF_GET_TYPE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, obj_type, ref_type, ref) < 0) + if(H5VL_object_get(vol_obj, &loc_params, H5VL_REF_GET_TYPE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, obj_type, (int)ref_type, ref) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to determine object type") done: @@ -381,7 +381,7 @@ H5Rget_name(hid_t id, H5R_type_t ref_type, const void *_ref, char *name, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid file identifier") /* Get name */ - if(H5VL_object_get(vol_obj, &loc_params, H5VL_REF_GET_NAME, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value, name, size, ref_type, _ref) < 0) + if(H5VL_object_get(vol_obj, &loc_params, H5VL_REF_GET_NAME, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value, name, size, (int)ref_type, _ref) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, (-1), "unable to determine object path") done: diff --git a/src/H5Rdeprec.c b/src/H5Rdeprec.c index 827506e..ab8d3b4 100644 --- a/src/H5Rdeprec.c +++ b/src/H5Rdeprec.c @@ -126,7 +126,7 @@ H5Rget_obj_type1(hid_t id, H5R_type_t ref_type, const void *ref) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5G_UNKNOWN, "invalid file identifier") /* Get the object information */ - if(H5VL_object_get(vol_obj, &loc_params, H5VL_REF_GET_TYPE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &obj_type, ref_type, ref) < 0) + if(H5VL_object_get(vol_obj, &loc_params, H5VL_REF_GET_TYPE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &obj_type, (int)ref_type, ref) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, H5G_UNKNOWN, "unable to determine object type") /* Set return value */ diff --git a/src/H5Rint.c b/src/H5Rint.c index 365facd..a4f76ce 100644 --- a/src/H5Rint.c +++ b/src/H5Rint.c @@ -62,18 +62,6 @@ hbool_t H5_PKG_INIT_VAR = FALSE; /* Local Variables */ /*******************/ -/* Reference ID class - * - * NOTE: H5I_REFERENCE is not used by the library and has been deprecated - * with a tentative removal version of 1.12.0. (DER, July 2017) - */ -static const H5I_class_t H5I_REFERENCE_CLS[1] = {{ - H5I_REFERENCE, /* ID class value */ - 0, /* Class flags */ - 0, /* # of reserved IDs for class */ - NULL /* Callback routine for closing objects of this class */ -}}; - /* Flag indicating "top" of interface has been initialized */ static hbool_t H5R_top_package_initialize_s = FALSE; @@ -97,11 +85,7 @@ H5R__init_package(void) FUNC_ENTER_NOAPI_NOINIT - /* Initialize the atom group for the file IDs */ - if (H5I_register_type(H5I_REFERENCE_CLS) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, FAIL, "unable to initialize interface") - - /* Mark "top" of interface as initialized, too */ + /* Mark "top" of interface as initialized */ H5R_top_package_initialize_s = TRUE; done: @@ -134,16 +118,10 @@ H5R_top_term_package(void) FUNC_ENTER_NOAPI_NOINIT_NOERR - if (H5R_top_package_initialize_s) { - if (H5I_nmembers(H5I_REFERENCE) > 0) { - (void)H5I_clear_type(H5I_REFERENCE, FALSE, FALSE); - n++; - } - - /* Mark closed */ - if (0 == n) + /* Mark closed if initialized */ + if(H5R_top_package_initialize_s) + if(0 == n) H5R_top_package_initialize_s = FALSE; - } FUNC_LEAVE_NOAPI(n) } /* end H5R_top_term_package() */ @@ -176,16 +154,12 @@ H5R_term_package(void) FUNC_ENTER_NOAPI_NOINIT_NOERR - if (H5_PKG_INIT_VAR) { + if(H5_PKG_INIT_VAR) { /* Sanity checks */ - HDassert(0 == H5I_nmembers(H5I_REFERENCE)); HDassert(FALSE == H5R_top_package_initialize_s); - /* Destroy the reference id group */ - n += (H5I_dec_type_ref(H5I_REFERENCE) > 0); - /* Mark closed */ - if (0 == n) + if(0 == n) H5_PKG_INIT_VAR = FALSE; } @@ -1729,7 +1729,6 @@ H5Tcopy(hid_t type_id) case H5I_GROUP: case H5I_DATASPACE: case H5I_ATTR: - case H5I_REFERENCE: case H5I_VFL: case H5I_VOL: case H5I_GENPROP_CLS: @@ -11,7 +11,7 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Purpose: The Virtual Object Layer as described in documentation. + * Purpose: The Virtual Object Layer as described in documentation. * The pupose is to provide an abstraction on how to access the * underlying HDF5 container, whether in a local file with * a specific file format, or remotely on other machines, etc... @@ -295,7 +295,7 @@ H5VLregister_connector_by_value(H5VL_class_value_t value, hid_t vipl_id) const H5VL_class_t *cls; /* Try loading the connector */ - key.vol.kind = H5VL_GET_CONNECTOR_BY_NAME; + key.vol.kind = H5VL_GET_CONNECTOR_BY_VALUE; key.vol.u.value = value; if(NULL == (cls = (const H5VL_class_t *)H5PL_load(H5PL_TYPE_VOL, &key))) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, H5I_INVALID_HID, "unable to load VOL connector") @@ -486,14 +486,11 @@ done: /*--------------------------------------------------------------------------- * Function: H5VLcmp_connector_cls * - * Purpose: Compares two connector classes + * Purpose: Compares two connector classes (based on their value field) * - * Return: Success: Non-negative, with *cmp set to positive if - * connector_id1 is greater than connector_id2, negative if connector_id2 - * is greater than connector_id1 and zero if connector_id1 and connector_id2 - * are equal. + * Return: Success: Non-negative, *cmp set to a value like strcmp * - * Failure: Negative + * Failure: Negative, *cmp unset * *--------------------------------------------------------------------------- */ diff --git a/src/H5VLcallback.c b/src/H5VLcallback.c index 2828262..811162d 100644 --- a/src/H5VLcallback.c +++ b/src/H5VLcallback.c @@ -95,8 +95,6 @@ static herr_t H5VL__dataset_optional(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, void **req, va_list arguments); static herr_t H5VL__dataset_close(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, void **req); -static herr_t H5VL__file_cache_connector(void *obj, const H5VL_class_t *cls, - hid_t dxpl_id, void **req, ...); static void * H5VL__file_create(const H5VL_class_t *cls, const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id, void **req); static void * H5VL__file_open(const H5VL_class_t *cls, const char *name, @@ -1360,7 +1358,7 @@ H5VL_attr_get(const H5VL_object_t *vol_obj, H5VL_attr_get_t get_type, vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - va_start(arguments, req); + HDva_start(arguments, req); arg_started = TRUE; if(H5VL__attr_get(vol_obj->data, vol_obj->connector->cls, get_type, dxpl_id, req, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "attribute get failed") @@ -1368,7 +1366,7 @@ H5VL_attr_get(const H5VL_object_t *vol_obj, H5VL_attr_get_t get_type, done: /* End access to the va_list, if we started it */ if(arg_started) - va_end(arguments); + HDva_end(arguments); /* Reset object wrapping info in API context */ if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) @@ -1473,7 +1471,7 @@ H5VL_attr_specific(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_pa vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - va_start(arguments, req); + HDva_start(arguments, req); arg_started = TRUE; if((ret_value = H5VL__attr_specific(vol_obj->data, loc_params, vol_obj->connector->cls, specific_type, dxpl_id, req, arguments)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute attribute specific callback") @@ -1481,7 +1479,7 @@ H5VL_attr_specific(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_pa done: /* End access to the va_list, if we started it */ if(arg_started) - va_end(arguments); + HDva_end(arguments); /* Reset object wrapping info in API context */ if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) @@ -1584,7 +1582,7 @@ H5VL_attr_optional(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req, ...) vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - va_start(arguments, req); + HDva_start(arguments, req); arg_started = TRUE; if((ret_value = H5VL__attr_optional(vol_obj->data, vol_obj->connector->cls, dxpl_id, req, arguments)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute attribute optional callback") @@ -1592,7 +1590,7 @@ H5VL_attr_optional(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req, ...) done: /* End access to the va_list, if we started it */ if(arg_started) - va_end(arguments); + HDva_end(arguments); /* Reset object wrapping info in API context */ if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) @@ -2207,7 +2205,7 @@ H5VL_dataset_get(const H5VL_object_t *vol_obj, H5VL_dataset_get_t get_type, vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - va_start(arguments, req); + HDva_start(arguments, req); arg_started = TRUE; if(H5VL__dataset_get(vol_obj->data, vol_obj->connector->cls, get_type, dxpl_id, req, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "dataset get failed") @@ -2215,7 +2213,7 @@ H5VL_dataset_get(const H5VL_object_t *vol_obj, H5VL_dataset_get_t get_type, done: /* End access to the va_list, if we started it */ if(arg_started) - va_end(arguments); + HDva_end(arguments); /* Reset object wrapping info in API context */ if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) @@ -2319,7 +2317,7 @@ H5VL_dataset_specific(const H5VL_object_t *vol_obj, H5VL_dataset_specific_t spec vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - va_start(arguments, req); + HDva_start(arguments, req); arg_started = TRUE; if(H5VL__dataset_specific(vol_obj->data, vol_obj->connector->cls, specific_type, dxpl_id, req, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute dataset specific callback") @@ -2327,7 +2325,7 @@ H5VL_dataset_specific(const H5VL_object_t *vol_obj, H5VL_dataset_specific_t spec done: /* End access to the va_list, if we started it */ if(arg_started) - va_end(arguments); + HDva_end(arguments); /* Reset object wrapping info in API context */ if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) @@ -2432,7 +2430,7 @@ H5VL_dataset_optional(const H5VL_object_t *vol_obj, hid_t dxpl_id, vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - va_start(arguments, req); + HDva_start(arguments, req); arg_started = TRUE; if(H5VL__dataset_optional(vol_obj->data, vol_obj->connector->cls, dxpl_id, req, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute dataset optional callback") @@ -2440,7 +2438,7 @@ H5VL_dataset_optional(const H5VL_object_t *vol_obj, hid_t dxpl_id, done: /* End access to the va_list, if we started it */ if(arg_started) - va_end(arguments); + HDva_end(arguments); /* Reset object wrapping info in API context */ if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) @@ -2596,42 +2594,6 @@ done: /*------------------------------------------------------------------------- - * Function: H5VL__file_cache_connector - * - * Purpose: Wrap varargs and reissue 'cache VOL connector' operation - * to file specific call - * - * Return: Success: Non-negative - * Failure: Negative - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL__file_cache_connector(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, - void **req, ...) -{ - va_list arguments; /* Argument list passed from the API call */ - hbool_t arg_started = FALSE; /* Whether the va_list has been started */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - /* Re-issue call to internal file specific callback routine */ - va_start(arguments, req); - arg_started = TRUE; - if(H5VL__file_specific(obj, cls, H5VL_FILE_CACHE_VOL_CONN, dxpl_id, req, arguments) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "file specific failed") - -done: - /* End access to the va_list, if we started it */ - if(arg_started) - va_end(arguments); - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__file_cache_connector() */ - - -/*------------------------------------------------------------------------- * Function: H5VL__file_create * * Purpose: Creates a file through the VOL @@ -2695,10 +2657,6 @@ H5VL_file_create(const H5VL_connector_prop_t *connector_prop, const char *name, if(NULL == (ret_value = H5VL__file_create(cls, name, flags, fcpl_id, fapl_id, dxpl_id, req))) HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "file create failed") - /* Cache the connector ID & info */ - if(H5VL__file_cache_connector(ret_value, cls, dxpl_id, req, connector_prop->connector_id, connector_prop->connector_info) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTSET, NULL, "caching VOL connector ID & info failed") - done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_file_create() */ @@ -2806,10 +2764,6 @@ H5VL_file_open(const H5VL_connector_prop_t *connector_prop, const char *name, if(NULL == (ret_value = H5VL__file_open(cls, name, flags, fapl_id, dxpl_id, req))) HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "open failed") - /* Cache the connector ID & info */ - if(H5VL__file_cache_connector(ret_value, cls, dxpl_id, req, connector_prop->connector_id, connector_prop->connector_info) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTSET, NULL, "caching VOL connector ID & info failed") - done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_file_open() */ @@ -2914,7 +2868,7 @@ H5VL_file_get(const H5VL_object_t *vol_obj, H5VL_file_get_t get_type, vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - va_start(arguments, req); + HDva_start(arguments, req); arg_started = TRUE; if(H5VL__file_get(vol_obj->data, vol_obj->connector->cls, get_type, dxpl_id, req, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "file get failed") @@ -2922,7 +2876,7 @@ H5VL_file_get(const H5VL_object_t *vol_obj, H5VL_file_get_t get_type, done: /* End access to the va_list, if we started it */ if(arg_started) - va_end(arguments); + HDva_end(arguments); /* Reset object wrapping info in API context */ if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) @@ -3022,7 +2976,7 @@ H5VL_file_specific(const H5VL_object_t *vol_obj, H5VL_file_specific_t specific_t FUNC_ENTER_NOAPI(FAIL) /* Start access to the varargs, so they are available in all situations below */ - va_start(arguments, req); + HDva_start(arguments, req); arg_started = TRUE; /* Special treatment of file access check */ @@ -3033,9 +2987,9 @@ H5VL_file_specific(const H5VL_object_t *vol_obj, H5VL_file_specific_t specific_t hid_t fapl_id; /* File access property list for accessing the file */ /* Get the file access property list to access the file */ - va_copy(tmp_args, arguments); + HDva_copy(tmp_args, arguments); fapl_id = va_arg(tmp_args, hid_t); - va_end(tmp_args); + HDva_end(tmp_args); /* Get the VOL info from the FAPL */ if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) @@ -3067,7 +3021,7 @@ H5VL_file_specific(const H5VL_object_t *vol_obj, H5VL_file_specific_t specific_t done: /* End access to the va_list, if we started it */ if(arg_started) - va_end(arguments); + HDva_end(arguments); /* Reset object wrapping info in API context */ if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) @@ -3170,7 +3124,7 @@ H5VL_file_optional(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req, ...) vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - va_start(arguments, req); + HDva_start(arguments, req); arg_started = TRUE; if(H5VL__file_optional(vol_obj->data, vol_obj->connector->cls, dxpl_id, req, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "file optional failed") @@ -3178,7 +3132,7 @@ H5VL_file_optional(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req, ...) done: /* End access to the va_list, if we started it */ if(arg_started) - va_end(arguments); + HDva_end(arguments); /* Reset object wrapping info in API context */ if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) @@ -3593,7 +3547,7 @@ H5VL_group_get(const H5VL_object_t *vol_obj, H5VL_group_get_t get_type, vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - va_start(arguments, req); + HDva_start(arguments, req); arg_started = TRUE; if(H5VL__group_get(vol_obj->data, vol_obj->connector->cls, get_type, dxpl_id, req, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "group get failed") @@ -3601,7 +3555,7 @@ H5VL_group_get(const H5VL_object_t *vol_obj, H5VL_group_get_t get_type, done: /* End access to the va_list, if we started it */ if(arg_started) - va_end(arguments); + HDva_end(arguments); /* Reset object wrapping info in API context */ if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) @@ -3705,7 +3659,7 @@ H5VL_group_specific(const H5VL_object_t *vol_obj, H5VL_group_specific_t specific vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - va_start(arguments, req); + HDva_start(arguments, req); arg_started = TRUE; if(H5VL__group_specific(vol_obj->data, vol_obj->connector->cls, specific_type, dxpl_id, req, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute group specific callback") @@ -3713,7 +3667,7 @@ H5VL_group_specific(const H5VL_object_t *vol_obj, H5VL_group_specific_t specific done: /* End access to the va_list, if we started it */ if(arg_started) - va_end(arguments); + HDva_end(arguments); /* Reset object wrapping info in API context */ if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) @@ -3816,7 +3770,7 @@ H5VL_group_optional(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req, ... vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - va_start(arguments, req); + HDva_start(arguments, req); arg_started = TRUE; if((ret_value = H5VL__group_optional(vol_obj->data, vol_obj->connector->cls, dxpl_id, req, arguments)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute group optional callback") @@ -3824,7 +3778,7 @@ H5VL_group_optional(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req, ... done: /* End access to the va_list, if we started it */ if(arg_started) - va_end(arguments); + HDva_end(arguments); /* Reset object wrapping info in API context */ if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) @@ -4372,7 +4326,7 @@ H5VL_link_get(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - va_start(arguments, req); + HDva_start(arguments, req); arg_started = TRUE; if(H5VL__link_get(vol_obj->data, loc_params, vol_obj->connector->cls, get_type, dxpl_id, req, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "link get failed") @@ -4380,7 +4334,7 @@ H5VL_link_get(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, done: /* End access to the va_list, if we started it */ if(arg_started) - va_end(arguments); + HDva_end(arguments); /* Reset object wrapping info in API context */ if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) @@ -4484,7 +4438,7 @@ H5VL_link_specific(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_pa vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - va_start(arguments, req); + HDva_start(arguments, req); arg_started = TRUE; if((ret_value = H5VL__link_specific(vol_obj->data, loc_params, vol_obj->connector->cls, specific_type, dxpl_id, req, arguments)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute link specific callback") @@ -4492,7 +4446,7 @@ H5VL_link_specific(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_pa done: /* End access to the va_list, if we started it */ if(arg_started) - va_end(arguments); + HDva_end(arguments); /* Reset object wrapping info in API context */ if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) @@ -4595,7 +4549,7 @@ H5VL_link_optional(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req, ...) vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - va_start(arguments, req); + HDva_start(arguments, req); arg_started = TRUE; if(H5VL__link_optional(vol_obj->data, vol_obj->connector->cls, dxpl_id, req, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute link optional callback") @@ -4603,7 +4557,7 @@ H5VL_link_optional(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req, ...) done: /* End access to the va_list, if we started it */ if(arg_started) - va_end(arguments); + HDva_end(arguments); /* Reset object wrapping info in API context */ if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) @@ -4924,7 +4878,7 @@ H5VL_object_get(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_param vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - va_start(arguments, req); + HDva_start(arguments, req); arg_started = TRUE; if(H5VL__object_get(vol_obj->data, loc_params, vol_obj->connector->cls, get_type, dxpl_id, req, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "get failed") @@ -4932,7 +4886,7 @@ H5VL_object_get(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_param done: /* End access to the va_list, if we started it */ if(arg_started) - va_end(arguments); + HDva_end(arguments); /* Reset object wrapping info in API context */ if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) @@ -5037,7 +4991,7 @@ H5VL_object_specific(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_ vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - va_start(arguments, req); + HDva_start(arguments, req); arg_started = TRUE; if((ret_value = H5VL__object_specific(vol_obj->data, loc_params, vol_obj->connector->cls, specific_type, dxpl_id, req, arguments)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "object specific failed") @@ -5045,7 +4999,7 @@ H5VL_object_specific(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_ done: /* End access to the va_list, if we started it */ if(arg_started) - va_end(arguments); + HDva_end(arguments); /* Reset object wrapping info in API context */ if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) @@ -5152,7 +5106,7 @@ H5VL_object_optional(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req, .. vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - va_start(arguments, req); + HDva_start(arguments, req); arg_started = TRUE; if(H5VL__object_optional(vol_obj->data, vol_obj->connector->cls, dxpl_id, req, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute object optional callback") @@ -5160,7 +5114,7 @@ H5VL_object_optional(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req, .. done: /* End access to the va_list, if we started it */ if(arg_started) - va_end(arguments); + HDva_end(arguments); /* Reset object wrapping info in API context */ if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) @@ -5473,7 +5427,7 @@ H5VL_datatype_get(const H5VL_object_t *vol_obj, H5VL_datatype_get_t get_type, vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - va_start(arguments, req); + HDva_start(arguments, req); arg_started = TRUE; if(H5VL__datatype_get(vol_obj->data, vol_obj->connector->cls, get_type, dxpl_id, req, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "datatype get failed") @@ -5481,7 +5435,7 @@ H5VL_datatype_get(const H5VL_object_t *vol_obj, H5VL_datatype_get_t get_type, done: /* End access to the va_list, if we started it */ if(arg_started) - va_end(arguments); + HDva_end(arguments); /* Reset object wrapping info in API context */ if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) @@ -5589,7 +5543,7 @@ H5VL_datatype_specific(const H5VL_object_t *vol_obj, H5VL_datatype_specific_t sp vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - va_start(arguments, req); + HDva_start(arguments, req); arg_started = TRUE; if(H5VL__datatype_specific(vol_obj->data, vol_obj->connector->cls, specific_type, dxpl_id, req, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute datatype specific callback") @@ -5597,7 +5551,7 @@ H5VL_datatype_specific(const H5VL_object_t *vol_obj, H5VL_datatype_specific_t sp done: /* End access to the va_list, if we started it */ if(arg_started) - va_end(arguments); + HDva_end(arguments); /* Reset object wrapping info in API context */ if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) @@ -5701,7 +5655,7 @@ H5VL_datatype_optional(const H5VL_object_t *vol_obj, hid_t dxpl_id, vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - va_start(arguments, req); + HDva_start(arguments, req); arg_started = TRUE; if(H5VL__datatype_optional(vol_obj->data, vol_obj->connector->cls, dxpl_id, req, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute datatype optional callback") @@ -5709,7 +5663,7 @@ H5VL_datatype_optional(const H5VL_object_t *vol_obj, hid_t dxpl_id, done: /* End access to the va_list, if we started it */ if(arg_started) - va_end(arguments); + HDva_end(arguments); /* Reset object wrapping info in API context */ if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) @@ -6265,7 +6219,7 @@ H5VL_request_specific(const H5VL_object_t *vol_obj, vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - va_start(arguments, specific_type); + HDva_start(arguments, specific_type); arg_started = TRUE; if((ret_value = H5VL__request_specific(vol_obj->data, vol_obj->connector->cls, specific_type, arguments)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute asynchronous request specific callback") @@ -6273,7 +6227,7 @@ H5VL_request_specific(const H5VL_object_t *vol_obj, done: /* End access to the va_list, if we started it */ if(arg_started) - va_end(arguments); + HDva_end(arguments); /* Reset object wrapping info in API context */ if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) @@ -6379,7 +6333,7 @@ H5VL_request_optional(const H5VL_object_t *vol_obj, ...) vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - va_start(arguments, vol_obj); + HDva_start(arguments, vol_obj); arg_started = TRUE; if((ret_value = H5VL__request_optional(vol_obj->data, vol_obj->connector->cls, arguments)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute asynchronous request optional callback") @@ -6387,7 +6341,7 @@ H5VL_request_optional(const H5VL_object_t *vol_obj, ...) done: /* End access to the va_list, if we started it */ if(arg_started) - va_end(arguments); + HDva_end(arguments); /* Reset object wrapping info in API context */ if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) diff --git a/src/H5VLint.c b/src/H5VLint.c index 82886cd..bdb2908 100644 --- a/src/H5VLint.c +++ b/src/H5VLint.c @@ -625,9 +625,12 @@ H5VL_register_connector(const void *_cls, hbool_t app_ref, hid_t vipl_id) HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register VOL connector ID") done: - if (ret_value < 0) - if (saved) - H5FL_FREE(H5VL_class_t, saved); + if (ret_value < 0 && saved) { + if (saved->name) + H5MM_xfree((void *)(saved->name)); /* Casting away const OK -QAK */ + + H5FL_FREE(H5VL_class_t, saved); + } FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_register_connector() */ @@ -793,7 +796,6 @@ H5VL__object(hid_t id, H5I_type_t obj_type) case H5I_UNINIT: case H5I_BADID: case H5I_DATASPACE: - case H5I_REFERENCE: case H5I_VFL: case H5I_VOL: case H5I_GENPROP_CLS: @@ -877,9 +879,11 @@ done: * * Purpose: Compare VOL class for a connector * - * Return: Positive if VALUE1 is greater than VALUE2, negative if - * VALUE2 is greater than VALUE1 and zero if VALUE1 and - * VALUE2 are equal. + * Note: Sets *cmp_value positive if VALUE1 is greater than VALUE2, + * negative if VALUE2 is greater than VALUE1, and zero if VALUE1 + * and VALUE2 are equal (like strcmp). + * + * Return: SUCCEED / FAIL * *------------------------------------------------------------------------- */ diff --git a/src/H5VLnative.c b/src/H5VLnative.c index 3fc1a7c..fe0fd4e 100644 --- a/src/H5VLnative.c +++ b/src/H5VLnative.c @@ -11,113 +11,25 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Purpose: The native VOL connector where access is to a single HDF5 file + * Purpose: The native VOL connector where access is to a single HDF5 file * using HDF5 VFDs. */ -#define H5A_FRIEND /* Suppress error about including H5Apkg */ -#define H5D_FRIEND /* Suppress error about including H5Dpkg */ -#define H5F_FRIEND /* Suppress error about including H5Fpkg */ -#define H5G_FRIEND /* Suppress error about including H5Gpkg */ -#define H5L_FRIEND /* Suppress error about including H5Lpkg */ -#define H5O_FRIEND /* Suppress error about including H5Opkg */ -#define H5R_FRIEND /* Suppress error about including H5Rpkg */ -#define H5T_FRIEND /* Suppress error about including H5Tpkg */ - - #include "H5private.h" /* Generic Functions */ -#include "H5Apkg.h" /* Attributes */ -#include "H5Dpkg.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* Files */ -#include "H5Gpkg.h" /* Groups */ #include "H5Iprivate.h" /* IDs */ -#include "H5Lpkg.h" /* Links */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Opkg.h" /* Object headers */ #include "H5Pprivate.h" /* Property lists */ -#include "H5Rpkg.h" /* References */ -#include "H5SMprivate.h" /* Shared Object Header Messages */ -#include "H5Tpkg.h" /* Datatypes */ #include "H5VLprivate.h" /* Virtual Object Layer */ -#include "H5VLnative.h" /* Native VOL connector */ -/* - * The VOL connector identification number. - */ -static hid_t H5VL_NATIVE_ID_g = H5I_INVALID_HID; +#include "H5VLnative_private.h" /* Native VOL connector */ +/* The VOL connector identification number */ +static hid_t H5VL_NATIVE_ID_g = H5I_INVALID_HID; + /* Prototypes */ static herr_t H5VL__native_term(void); -/* Atrribute callbacks */ -static void *H5VL__native_attr_create(void *obj, const H5VL_loc_params_t *loc_params, const char *attr_name, hid_t acpl_id, hid_t aapl_id, hid_t dxpl_id, void **req); -static void *H5VL__native_attr_open(void *obj, const H5VL_loc_params_t *loc_params, const char *attr_name, hid_t aapl_id, hid_t dxpl_id, void **req); -static herr_t H5VL__native_attr_read(void *attr, hid_t dtype_id, void *buf, hid_t dxpl_id, void **req); -static herr_t H5VL__native_attr_write(void *attr, hid_t dtype_id, const void *buf, hid_t dxpl_id, void **req); -static herr_t H5VL__native_attr_get(void *obj, H5VL_attr_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL__native_attr_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_attr_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL__native_attr_optional(void *obj, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL__native_attr_close(void *attr, hid_t dxpl_id, void **req); - -/* Dataset callbacks */ -static void *H5VL__native_dataset_create(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req); -static void *H5VL__native_dataset_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t dapl_id, hid_t dxpl_id, void **req); -static herr_t H5VL__native_dataset_read(void *dset, hid_t mem_type_id, hid_t mem_space_id, - hid_t file_space_id, hid_t plist_id, void *buf, void **req); -static herr_t H5VL__native_dataset_write(void *dset, hid_t mem_type_id, hid_t mem_space_id, - hid_t file_space_id, hid_t plist_id, const void *buf, void **req); -static herr_t H5VL__native_dataset_get(void *dset, H5VL_dataset_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL__native_dataset_specific(void *dset, H5VL_dataset_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL__native_dataset_optional(void *dset, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL__native_dataset_close(void *dset, hid_t dxpl_id, void **req); - -/* File callbacks */ -static void *H5VL__native_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id, void **req); -static void *H5VL__native_file_open(const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_id, void **req); -static herr_t H5VL__native_file_get(void *file, H5VL_file_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL__native_file_specific(void *file, H5VL_file_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL__native_file_optional(void *file, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL__native_file_close(void *file, hid_t dxpl_id, void **req); - -/* Group callbacks */ -static void *H5VL__native_group_create(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req); -static void *H5VL__native_group_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t gapl_id, hid_t dxpl_id, void **req); -static herr_t H5VL__native_group_get(void *obj, H5VL_group_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL__native_group_specific(void *obj, H5VL_group_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL__native_group_optional(void *obj, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL__native_group_close(void *grp, hid_t dxpl_id, void **req); - -/* Link callbacks */ -static herr_t H5VL__native_link_create(H5VL_link_create_type_t create_type, void *obj, - const H5VL_loc_params_t *loc_params, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); -static herr_t H5VL__native_link_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, - void *dst_obj, const H5VL_loc_params_t *loc_params2, - hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); -static herr_t H5VL__native_link_move(void *src_obj, const H5VL_loc_params_t *loc_params1, - void *dst_obj, const H5VL_loc_params_t *loc_params2, - hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); -static herr_t H5VL__native_link_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL__native_link_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); - -/* Object callbacks */ -static void *H5VL__native_object_open(void *obj, const H5VL_loc_params_t *loc_params, H5I_type_t *opened_type, hid_t dxpl_id, void **req); -static herr_t H5VL__native_object_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, const char *src_name, - void *dst_obj, const H5VL_loc_params_t *loc_params2, const char *dst_name, - hid_t ocpypl_id, hid_t lcpl_id, hid_t dxpl_id, void **req); -static herr_t H5VL__native_object_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_object_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL__native_object_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_object_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL__native_object_optional(void *obj, hid_t dxpl_id, void **req, va_list arguments); - -/* Datatype callbacks */ -static void *H5VL__native_datatype_commit(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, hid_t dxpl_id, void **req); -static void *H5VL__native_datatype_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t tapl_id, hid_t dxpl_id, void **req); -static herr_t H5VL__native_datatype_get(void *dt, H5VL_datatype_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL__native_datatype_specific(void *dt, H5VL_datatype_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL__native_datatype_close(void *dt, hid_t dxpl_id, void **req); - /* Native VOL connector class struct */ static H5VL_class_t H5VL_native_cls_g = { H5VL_NATIVE_VERSION, /* version */ @@ -210,7 +122,7 @@ static H5VL_class_t H5VL_native_cls_g = { /*------------------------------------------------------------------------- * Function: H5VL_native_register * - * Purpose: Register the native VOL connector and retrieve an ID for it. + * Purpose: Register the native VOL connector and retrieve an ID for it. * * Return: Success: The ID for the native connector * Failure: H5I_INVALID_HID @@ -257,3380 +169,3 @@ H5VL__native_term(void) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5VL__native_term() */ - -/*------------------------------------------------------------------------- - * Function: H5VL__native_attr_create - * - * Purpose: Creates an attribute on an object. - * - * Return: Success: Pointer to attribute object - * Failure: NULL - * - *------------------------------------------------------------------------- - */ -static void * -H5VL__native_attr_create(void *obj, const H5VL_loc_params_t *loc_params, const char *attr_name, - hid_t acpl_id, hid_t H5_ATTR_UNUSED aapl_id, hid_t H5_ATTR_UNUSED dxpl_id, - void H5_ATTR_UNUSED **req) -{ - H5G_loc_t loc; /* Object location */ - H5G_loc_t obj_loc; /* Location used to open group */ - hbool_t loc_found = FALSE; - H5P_genplist_t *plist; /* Property list pointer */ - hid_t type_id, space_id; - H5T_t *type, *dt; /* Datatype to use for attribute */ - H5S_t *space; /* Dataspace to use for attribute */ - H5A_t *attr = NULL; - void *ret_value = NULL; - - FUNC_ENTER_STATIC - - /* Get the plist structure */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(acpl_id))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, NULL, "can't find object for ID") - - /* get creation properties */ - if(H5P_get(plist, H5VL_PROP_ATTR_TYPE_ID, &type_id) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for datatype id") - if(H5P_get(plist, H5VL_PROP_ATTR_SPACE_ID, &space_id) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for space id") - - if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") - if(0 == (H5F_INTENT(loc.oloc->file) & H5F_ACC_RDWR)) - HGOTO_ERROR(H5E_ARGS, H5E_WRITEERROR, NULL, "no write intent on file") - - if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a datatype") - /* If this is a named datatype, get the connector's pointer to the datatype */ - type = H5T_get_actual_type(dt); - - if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data space") - - if(loc_params->type == H5VL_OBJECT_BY_SELF) { - /* H5Acreate */ - /* Go do the real work for attaching the attribute to the dataset */ - if(NULL == (attr = H5A__create(&loc, attr_name, type, space, acpl_id))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, NULL, "unable to create attribute") - } /* end if */ - else if(loc_params->type == H5VL_OBJECT_BY_NAME) { - /* H5Acreate_by_name */ - if(NULL == (attr = H5A__create_by_name(&loc, loc_params->loc_data.loc_by_name.name, attr_name, type, space, acpl_id))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, NULL, "unable to create attribute") - } /* end else-if */ - else - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "unknown attribute create parameters") - - ret_value = (void *)attr; - -done: - /* Release resources */ - if(loc_found && H5G_loc_free(&obj_loc) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, NULL, "can't free location") - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_attr_create() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_attr_open - * - * Purpose: Opens an attr inside a native H5 file. - * - * Return: Success: Pointer to attribute object - * Failure: NULL - * - * Programmer: Mohamad Chaarawi - * March, 2012 - * - *------------------------------------------------------------------------- - */ -static void * -H5VL__native_attr_open(void *obj, const H5VL_loc_params_t *loc_params, const char *attr_name, - hid_t H5_ATTR_UNUSED aapl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) -{ - H5G_loc_t loc; /* Object location */ - H5A_t *attr = NULL; /* Attribute opened */ - void *ret_value; - - FUNC_ENTER_STATIC - - /* check arguments */ - if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") - - if(loc_params->type == H5VL_OBJECT_BY_SELF) { - /* H5Aopen */ - /* Open the attribute */ - if(NULL == (attr = H5A__open(&loc, attr_name))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "unable to open attribute: '%s'", attr_name) - } /* end if */ - else if(loc_params->type == H5VL_OBJECT_BY_NAME) { - /* H5Aopen_by_name */ - /* Open the attribute on the object header */ - if(NULL == (attr = H5A__open_by_name(&loc, loc_params->loc_data.loc_by_name.name, attr_name))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "can't open attribute") - } /* end else-if */ - else if(loc_params->type == H5VL_OBJECT_BY_IDX) { - /* H5Aopen_by_idx */ - /* Open the attribute in the object header */ - if(NULL == (attr = H5A__open_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, - loc_params->loc_data.loc_by_idx.idx_type, - loc_params->loc_data.loc_by_idx.order, - loc_params->loc_data.loc_by_idx.n))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "unable to open attribute") - } /* end else-if */ - else - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "unknown attribute open parameters") - - ret_value = (void *)attr; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_attr_open() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_attr_read - * - * Purpose: Reads data from attribute. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Mohamad Chaarawi - * March, 2012 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL__native_attr_read(void *attr, hid_t dtype_id, void *buf, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) -{ - H5T_t *mem_type; /* Memory datatype */ - herr_t ret_value; /* Return value */ - - FUNC_ENTER_STATIC - - if(NULL == (mem_type = (H5T_t *)H5I_object_verify(dtype_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - - /* Go write the actual data to the attribute */ - if((ret_value = H5A__read((H5A_t*)attr, mem_type, buf)) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_READERROR, FAIL, "unable to read attribute") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_attr_read() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_attr_write - * - * Purpose: Writes data to attribute. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Mohamad Chaarawi - * March, 2012 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL__native_attr_write(void *attr, hid_t dtype_id, const void *buf, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) -{ - H5T_t *mem_type; /* Memory datatype */ - herr_t ret_value; /* Return value */ - - FUNC_ENTER_STATIC - - if(NULL == (mem_type = (H5T_t *)H5I_object_verify(dtype_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - - /* Go write the actual data to the attribute */ - if((ret_value = H5A__write((H5A_t*)attr, mem_type, buf)) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_WRITEERROR, FAIL, "unable to write attribute") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_attr_write() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_attr_get - * - * Purpose: Gets information about an attribute - * - * Return: Success: 0 - * Failure: -1 - * - * Programmer: Mohamad Chaarawi - * March, 2012 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL__native_attr_get(void *obj, H5VL_attr_get_t get_type, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - switch(get_type) { - /* H5Aget_space */ - case H5VL_ATTR_GET_SPACE: - { - hid_t *ret_id = va_arg(arguments, hid_t *); - H5A_t *attr = (H5A_t *)obj; - - if((*ret_id = H5A_get_space(attr)) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get space ID of attribute") - break; - } - - /* H5Aget_type */ - case H5VL_ATTR_GET_TYPE: - { - hid_t *ret_id = va_arg(arguments, hid_t *); - H5A_t *attr = (H5A_t *)obj; - - if((*ret_id = H5A__get_type(attr)) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get datatype ID of attribute") - break; - } - - /* H5Aget_create_plist */ - case H5VL_ATTR_GET_ACPL: - { - hid_t *ret_id = va_arg(arguments, hid_t *); - H5A_t *attr = (H5A_t *)obj; - - if((*ret_id = H5A__get_create_plist(attr)) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get creation property list for attr") - - break; - } - - /* H5Aget_name */ - case H5VL_ATTR_GET_NAME: - { - const H5VL_loc_params_t *loc_params = va_arg(arguments, const H5VL_loc_params_t *); - size_t buf_size = va_arg(arguments, size_t); - char *buf = va_arg(arguments, char *); - ssize_t *ret_val = va_arg(arguments, ssize_t *); - H5A_t *attr = NULL; - - if(H5VL_OBJECT_BY_SELF == loc_params->type) { - attr = (H5A_t *)obj; - /* Call private function in turn */ - if(0 > (*ret_val = H5A__get_name(attr, buf_size, buf))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get attribute name") - } - else if(H5VL_OBJECT_BY_IDX == loc_params->type) { - H5G_loc_t loc; - - /* check arguments */ - if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - /* Open the attribute on the object header */ - if(NULL == (attr = H5A__open_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, - loc_params->loc_data.loc_by_idx.idx_type, - loc_params->loc_data.loc_by_idx.order, - loc_params->loc_data.loc_by_idx.n))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute") - - /* Get the length of the name */ - *ret_val = (ssize_t)HDstrlen(attr->shared->name); - - /* Copy the name into the user's buffer, if given */ - if(buf) { - HDstrncpy(buf, attr->shared->name, MIN((size_t)(*ret_val + 1), buf_size)); - if((size_t)(*ret_val) >= buf_size) - buf[buf_size - 1]='\0'; - } /* end if */ - - /* Release resources */ - if(attr && H5A__close(attr) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute") - } - else - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get name of attr") - - break; - } - - /* H5Aget_info */ - case H5VL_ATTR_GET_INFO: - { - const H5VL_loc_params_t *loc_params = va_arg(arguments, const H5VL_loc_params_t *); - H5A_info_t *ainfo = va_arg(arguments, H5A_info_t *); - H5A_t *attr = NULL; - - if(H5VL_OBJECT_BY_SELF == loc_params->type) { - attr = (H5A_t *)obj; - if(H5A__get_info(attr, ainfo) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get attribute info") - } - else if(H5VL_OBJECT_BY_NAME == loc_params->type) { - char *attr_name = va_arg(arguments, char *); - H5G_loc_t loc; - - /* check arguments */ - if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - /* Open the attribute on the object header */ - if(NULL == (attr = H5A__open_by_name(&loc, loc_params->loc_data.loc_by_name.name, attr_name))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute") - - /* Get the attribute information */ - if(H5A__get_info(attr, ainfo) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to get attribute info") - - /* Release resources */ - if(attr && H5A__close(attr) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute") - } - else if(H5VL_OBJECT_BY_IDX == loc_params->type) { - H5G_loc_t loc; - - /* check arguments */ - if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - /* Open the attribute on the object header */ - if(NULL == (attr = H5A__open_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, - loc_params->loc_data.loc_by_idx.idx_type, - loc_params->loc_data.loc_by_idx.order, - loc_params->loc_data.loc_by_idx.n))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute") - - /* Get the attribute information */ - if(H5A__get_info(attr, ainfo) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to get attribute info") - - /* Release resources */ - if(attr && H5A__close(attr) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute") - } - else - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get name of attr") - - break; - } - - case H5VL_ATTR_GET_STORAGE_SIZE: - { - hsize_t *ret = va_arg(arguments, hsize_t *); - H5A_t *attr = (H5A_t *)obj; - - /* Set return value */ - *ret = attr->shared->data_size; - break; - } - - default: - HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from attr") - } /* end switch */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_attr_get() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_attr_specific - * - * Purpose: Specific operation on attribute - * - * Return: Success: 0 - * Failure: -1 - * - * Programmer: Mohamad Chaarawi - * August, 2014 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL__native_attr_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_attr_specific_t specific_type, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) -{ - H5G_loc_t loc; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - /* Get location for passed-in object */ - if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - switch(specific_type) { - case H5VL_ATTR_DELETE: - { - char *attr_name = va_arg(arguments, char *); - - if(H5VL_OBJECT_BY_SELF == loc_params->type) { - /* H5Adelete */ - /* Delete the attribute from the location */ - if(H5O__attr_remove(loc.oloc, attr_name) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") - } /* end if */ - else if(H5VL_OBJECT_BY_NAME == loc_params->type) { - /* H5Adelete_by_name */ - /* Delete the attribute */ - if(H5A__delete_by_name(&loc, loc_params->loc_data.loc_by_name.name, attr_name) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") - } /* end else-if */ - else if(H5VL_OBJECT_BY_IDX == loc_params->type) { - /* H5Adelete_by_idx */ - /* Delete the attribute from the location */ - if(H5A__delete_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, loc_params->loc_data.loc_by_idx.idx_type, - loc_params->loc_data.loc_by_idx.order, loc_params->loc_data.loc_by_idx.n) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") - } /* end else-if */ - else - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown attribute remove parameters") - break; - } - - case H5VL_ATTR_EXISTS: - { - const char *attr_name = va_arg(arguments, const char *); - htri_t *ret = va_arg(arguments, htri_t *); - - if(loc_params->type == H5VL_OBJECT_BY_SELF) { /* H5Aexists */ - /* Check if the attribute exists */ - if((*ret = H5O__attr_exists(loc.oloc, attr_name)) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to determine if attribute exists") - } /* end if */ - else if(loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Aexists_by_name */ - /* Check if the attribute exists */ - if((*ret = H5A__exists_by_name(loc, loc_params->loc_data.loc_by_name.name, attr_name)) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to determine if attribute exists") - } /* end else-if */ - else - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown parameters") - break; - } - - case H5VL_ATTR_ITER: - { - H5_index_t idx_type = va_arg(arguments, H5_index_t); - H5_iter_order_t order = va_arg(arguments, H5_iter_order_t); - hsize_t *idx = va_arg(arguments, hsize_t *); - H5A_operator2_t op = va_arg(arguments, H5A_operator2_t); - void *op_data = va_arg(arguments, void *); - - if(loc_params->type == H5VL_OBJECT_BY_SELF) { /* H5Aiterate2 */ - /* Iterate over attributes */ - if((ret_value = H5A__iterate(&loc, ".", idx_type, order, idx, op, op_data)) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_BADITER, FAIL, "error iterating over attributes") - } /* end if */ - else if(loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Aiterate_by_name */ - /* Iterate over attributes by name */ - if((ret_value = H5A__iterate(&loc, loc_params->loc_data.loc_by_name.name, idx_type, order, idx, op, op_data)) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_BADITER, FAIL, "attribute iteration failed"); - } /* end else-if */ - else - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown parameters") - break; - } - - /* H5Arename/rename_by_name */ - case H5VL_ATTR_RENAME: - { - const char *old_name = va_arg(arguments, const char *); - const char *new_name = va_arg(arguments, const char *); - - if(loc_params->type == H5VL_OBJECT_BY_SELF) { /* H5Arename */ - /* Call attribute rename routine */ - if(H5O__attr_rename(loc.oloc, old_name, new_name) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTRENAME, FAIL, "can't rename attribute") - } /* end if */ - else if(loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Arename_by_name */ - /* Call attribute rename routine */ - if(H5A__rename_by_name(loc, loc_params->loc_data.loc_by_name.name, old_name, new_name) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTRENAME, FAIL, "can't rename attribute") - } /* end else-if */ - else - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown attribute rename parameters") - break; - } - - default: - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation") - } /* end switch */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_attr_specific() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_attr_optional - * - * Purpose: Perform a connector-specific operation on a native attribute - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL__native_attr_optional(void H5_ATTR_UNUSED *obj, hid_t H5_ATTR_UNUSED dxpl_id, - void H5_ATTR_UNUSED **req, va_list arguments) -{ - H5VL_attr_optional_t optional_type; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - optional_type = va_arg(arguments, H5VL_attr_optional_t); - switch(optional_type) { -#ifndef H5_NO_DEPRECATED_SYMBOLS - case H5VL_ATTR_ITERATE_OLD: - { - hid_t loc_id = va_arg(arguments, hid_t); - unsigned *attr_num = va_arg(arguments, unsigned *); - H5A_operator1_t op = va_arg(arguments, H5A_operator1_t); - void *op_data = va_arg(arguments, void *); - - /* Call the actual iteration routine */ - if((ret_value = H5A__iterate_old(loc_id, attr_num, op, op_data)) < 0) - HERROR(H5E_VOL, H5E_BADITER, "error iterating over attributes"); - - break; - } -#endif /* H5_NO_DEPRECATED_SYMBOLS */ - - default: - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid optional operation") - } /* end switch */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_attr_optional() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_attr_close - * - * Purpose: Closes an attribute. - * - * Return: Success: 0 - * Failure: -1, attr not closed. - * - * Programmer: Mohamad Chaarawi - * March, 2012 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL__native_attr_close(void *attr, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - if(H5A__close((H5A_t*)attr) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "can't close attribute") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_attr_close() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_dataset_create - * - * Purpose: Creates a dataset in a native HDF5 file - * - * Return: Success: Pointer to a dataset struct - * Failure: NULL - * - *------------------------------------------------------------------------- - */ -static void * -H5VL__native_dataset_create(void *obj, const H5VL_loc_params_t *loc_params, - const char *name, hid_t dcpl_id, hid_t dapl_id, hid_t H5_ATTR_UNUSED dxpl_id, - void H5_ATTR_UNUSED **req) -{ - H5P_genplist_t *plist; /* Property list pointer */ - H5G_loc_t loc; /* Object location to insert dataset into */ - hid_t type_id = H5I_INVALID_HID; - hid_t space_id = H5I_INVALID_HID; - hid_t lcpl_id = H5I_INVALID_HID; - H5D_t *dset = NULL; /* New dataset's info */ - const H5S_t *space; /* Dataspace for dataset */ - void *ret_value; - - FUNC_ENTER_STATIC - - /* Get the plist structure */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(dcpl_id))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, NULL, "can't find object for ID") - - /* Get creation properties */ - if(H5P_get(plist, H5VL_PROP_DSET_TYPE_ID, &type_id) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for datatype id") - if(H5P_get(plist, H5VL_PROP_DSET_SPACE_ID, &space_id) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for space id") - if(H5P_get(plist, H5VL_PROP_DSET_LCPL_ID, &lcpl_id) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for lcpl id") - - /* Check arguments */ - if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") - if(H5I_DATATYPE != H5I_get_type(type_id)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a datatype ID") - if(NULL == (space = (const H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a dataspace ID") - - /* H5Dcreate_anon */ - if(NULL == name) { - /* build and open the new dataset */ - if(NULL == (dset = H5D__create(loc.oloc->file, type_id, space, dcpl_id, dapl_id))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to create dataset") - } /* end if */ - /* H5Dcreate2 */ - else { - /* Create the new dataset & get its ID */ - if(NULL == (dset = H5D__create_named(&loc, name, type_id, space, lcpl_id, dcpl_id, dapl_id))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to create dataset") - } /* end else */ - - ret_value = (void *)dset; - -done: - if(NULL == name) { - /* Release the dataset's object header, if it was created */ - if(dset) { - H5O_loc_t *oloc; /* Object location for dataset */ - - /* Get the new dataset's object location */ - if(NULL == (oloc = H5D_oloc(dset))) - HDONE_ERROR(H5E_DATASET, H5E_CANTGET, NULL, "unable to get object location of dataset") - - /* Decrement refcount on dataset's object header in memory */ - if(H5O_dec_rc_by_loc(oloc) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, NULL, "unable to decrement refcount on newly created object") - } /* end if */ - } /* end if */ - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_dataset_create() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_dataset_open - * - * Purpose: Opens a dataset in a native HDF5 file. - * - * Return: Success: Pointer to a dataset struct - * Failure: NULL - * - *------------------------------------------------------------------------- - */ -static void * -H5VL__native_dataset_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, - hid_t dapl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) -{ - H5D_t *dset = NULL; - H5G_loc_t loc; /* Object location of group */ - void *ret_value = NULL; - - FUNC_ENTER_STATIC - - if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") - - /* Open the dataset */ - if(NULL == (dset = H5D__open_name(&loc, name, dapl_id))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, NULL, "unable to open dataset") - - ret_value = (void *)dset; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_dataset_open() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_dataset_read - * - * Purpose: Reads raw data from a dataset into a buffer. - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL__native_dataset_read(void *obj, hid_t mem_type_id, hid_t mem_space_id, - hid_t file_space_id, hid_t H5_ATTR_UNUSED dxpl_id, void *buf, - void H5_ATTR_UNUSED **req) -{ - H5D_t *dset = (H5D_t *)obj; - const H5S_t *mem_space = NULL; - const H5S_t *file_space = NULL; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - /* Check arguments */ - if(NULL == dset->oloc.file) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not associated with a file") - - /* Get validated dataspace pointers */ - if(H5S_get_validated_dataspace(mem_space_id, &mem_space) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not get a validated dataspace from mem_space_id") - if(H5S_get_validated_dataspace(file_space_id, &file_space) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not get a validated dataspace from file_space_id") - - /* Read raw data */ - if(H5D__read(dset, mem_type_id, mem_space, file_space, buf/*out*/) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read data") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_dataset_read() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_dataset_write - * - * Purpose: Writes raw data from a buffer into a dataset. - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL__native_dataset_write(void *obj, hid_t mem_type_id, hid_t mem_space_id, - hid_t file_space_id, hid_t H5_ATTR_UNUSED dxpl_id, const void *buf, - void H5_ATTR_UNUSED **req) -{ - H5D_t *dset = (H5D_t *)obj; - const H5S_t *mem_space = NULL; - const H5S_t *file_space = NULL; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - /* check arguments */ - if(NULL == dset->oloc.file) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not associated with a file") - - /* Get validated dataspace pointers */ - if(H5S_get_validated_dataspace(mem_space_id, &mem_space) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not get a validated dataspace from mem_space_id") - if(H5S_get_validated_dataspace(file_space_id, &file_space) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not get a validated dataspace from file_space_id") - - /* Write the data */ - if(H5D__write(dset, mem_type_id, mem_space, file_space, buf) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write data") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_dataset_write() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_dataset_get - * - * Purpose: Gets certain information about a dataset - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL__native_dataset_get(void *obj, H5VL_dataset_get_t get_type, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) -{ - H5D_t *dset = (H5D_t *)obj; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - switch(get_type) { - /* H5Dget_space */ - case H5VL_DATASET_GET_SPACE: - { - hid_t *ret_id = va_arg(arguments, hid_t *); - - if((*ret_id = H5D__get_space(dset)) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get space ID of dataset") - - break; - } - - /* H5Dget_space_statuc */ - case H5VL_DATASET_GET_SPACE_STATUS: - { - H5D_space_status_t *allocation = va_arg(arguments, H5D_space_status_t *); - - /* Read data space address and return */ - if(H5D__get_space_status(dset, allocation) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to get space status") - - break; - } - - /* H5Dget_type */ - case H5VL_DATASET_GET_TYPE: - { - hid_t *ret_id = va_arg(arguments, hid_t *); - - if((*ret_id = H5D__get_type(dset)) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get datatype ID of dataset") - - break; - } - - /* H5Dget_create_plist */ - case H5VL_DATASET_GET_DCPL: - { - hid_t *ret_id = va_arg(arguments, hid_t *); - - if((*ret_id = H5D_get_create_plist(dset)) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get creation property list for dataset") - - break; - } - - /* H5Dget_access_plist */ - case H5VL_DATASET_GET_DAPL: - { - hid_t *ret_id = va_arg(arguments, hid_t *); - - if((*ret_id = H5D_get_access_plist(dset)) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get access property list for dataset") - - break; - } - - /* H5Dget_storage_size */ - case H5VL_DATASET_GET_STORAGE_SIZE: - { - hsize_t *ret = va_arg(arguments, hsize_t *); - - /* Set return value */ - if(H5D__get_storage_size(dset, ret) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get size of dataset's storage") - break; - } - - /* H5Dget_offset */ - case H5VL_DATASET_GET_OFFSET: - { - haddr_t *ret = va_arg(arguments, haddr_t *); - - /* Set return value */ - *ret = H5D__get_offset(dset); - if(!H5F_addr_defined(*ret)) - *ret = HADDR_UNDEF; - break; - } - - default: - HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from dataset") - } /* end switch */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_dataset_get() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_dataset_specific - * - * Purpose: Specific operation on dataset - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL__native_dataset_specific(void *obj, H5VL_dataset_specific_t specific_type, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) -{ - H5D_t *dset = (H5D_t *)obj; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - switch(specific_type) { - /* H5Dspecific_space */ - case H5VL_DATASET_SET_EXTENT: - { - const hsize_t *size = va_arg(arguments, const hsize_t *); - - if(H5D__set_extent(dset, size) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to set extent of dataset") - break; - } - - case H5VL_DATASET_FLUSH: - { - hid_t dset_id = va_arg(arguments, hid_t); - - /* Flush the dataset */ - if(H5D__flush(dset, dset_id) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTFLUSH, FAIL, "unable to flush dataset") - - break; - } - - case H5VL_DATASET_REFRESH: - { - hid_t dset_id = va_arg(arguments, hid_t); - - /* Refresh the dataset */ - if((H5D__refresh(dset_id, dset)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTLOAD, FAIL, "unable to refresh dataset") - - break; - } - - default: - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation") - } /* end switch */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_dataset_specific() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_dataset_optional - * - * Purpose: Perform a connector-specific operation on a native dataset - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL__native_dataset_optional(void *obj, hid_t H5_ATTR_UNUSED dxpl_id, - void H5_ATTR_UNUSED **req, va_list arguments) -{ - H5D_t *dset = NULL; /* Dataset */ - H5VL_dataset_optional_t optional_type = va_arg(arguments, H5VL_dataset_optional_t); - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - switch(optional_type) { - case H5VL_DATASET_FORMAT_CONVERT: - { - dset = (H5D_t *)obj; - - switch(dset->shared->layout.type) { - case H5D_CHUNKED: - /* Convert the chunk indexing type to version 1 B-tree if not */ - if(dset->shared->layout.u.chunk.idx_type != H5D_CHUNK_IDX_BTREE) - if((H5D__format_convert(dset)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTLOAD, FAIL, "unable to downgrade chunk indexing type for dataset") - break; - - case H5D_CONTIGUOUS: - case H5D_COMPACT: - /* Downgrade the layout version to 3 if greater than 3 */ - if(dset->shared->layout.version > H5O_LAYOUT_VERSION_DEFAULT) - if((H5D__format_convert(dset)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTLOAD, FAIL, "unable to downgrade layout version for dataset") - break; - - case H5D_VIRTUAL: - /* Nothing to do even though layout is version 4 */ - break; - - case H5D_LAYOUT_ERROR: - case H5D_NLAYOUTS: - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset layout type") - - default: - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "unknown dataset layout type") - } /* end switch */ - - break; - } - - case H5VL_DATASET_GET_CHUNK_INDEX_TYPE: - { - H5D_chunk_index_t *idx_type = va_arg(arguments, H5D_chunk_index_t *); - - dset = (H5D_t *)obj; - - /* Make sure the dataset is chunked */ - if(H5D_CHUNKED != dset->shared->layout.type) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") - - /* Get the chunk indexing type */ - *idx_type = dset->shared->layout.u.chunk.idx_type; - - break; - } - - case H5VL_DATASET_GET_CHUNK_STORAGE_SIZE: - { - hsize_t *offset = va_arg(arguments, hsize_t *); - hsize_t *chunk_nbytes = va_arg(arguments, hsize_t *); - - dset = (H5D_t *)obj; - - /* Make sure the dataset is chunked */ - if(H5D_CHUNKED != dset->shared->layout.type) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") - - /* Call private function */ - if(H5D__get_chunk_storage_size(dset, offset, chunk_nbytes) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get storage size of chunk") - - break; - } - - case H5VL_DATASET_CHUNK_READ: - { - const hsize_t *offset = va_arg(arguments, hsize_t *); - uint32_t *filters = va_arg(arguments, uint32_t *); - void *buf = va_arg(arguments, void *); - hsize_t offset_copy[H5O_LAYOUT_NDIMS]; /* Internal copy of chunk offset */ - - dset = (H5D_t *)obj; - - /* Check arguments */ - if(NULL == dset->oloc.file) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not associated with a file") - if(H5D_CHUNKED != dset->shared->layout.type) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") - - /* Copy the user's offset array so we can be sure it's terminated properly. - * (we don't want to mess with the user's buffer). - */ - if(H5D__get_offset_copy(dset, offset, offset_copy) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "failure to copy offset array") - - /* Read the raw chunk */ - if(H5D__chunk_direct_read(dset, offset_copy, filters, buf) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read unprocessed chunk data") - - break; - } - - case H5VL_DATASET_CHUNK_WRITE: - { - uint32_t filters = va_arg(arguments, uint32_t); - const hsize_t *offset = va_arg(arguments, const hsize_t *); - uint32_t data_size_32 = va_arg(arguments, uint32_t); - const void *buf = va_arg(arguments, const void *); - hsize_t offset_copy[H5O_LAYOUT_NDIMS]; /* Internal copy of chunk offset */ - - dset = (H5D_t *)obj; - - /* Check arguments */ - if(NULL == dset->oloc.file) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not associated with a file") - if(H5D_CHUNKED != dset->shared->layout.type) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") - - /* Copy the user's offset array so we can be sure it's terminated properly. - * (we don't want to mess with the user's buffer). - */ - if(H5D__get_offset_copy(dset, offset, offset_copy) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "failure to copy offset array") - - /* Write chunk */ - if(H5D__chunk_direct_write(dset, filters, offset_copy, data_size_32, buf) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write unprocessed chunk data") - - break; - } - - default: - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid optional operation") - } /* end switch */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_dataset_optional() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_dataset_close - * - * Purpose: Closes a dataset. - * - * Return: Success: SUCCEED - * Failure: FAIL (dataset will not be closed) - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL__native_dataset_close(void *dset, hid_t H5_ATTR_UNUSED dxpl_id, - void H5_ATTR_UNUSED **req) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - if(H5D_close((H5D_t*)dset) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "can't close dataset") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_dataset_close() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_file_create - * - * Purpose: Creates a file as a native HDF5 file. - * - * Return: Success: A pointer to an H5F_t file struct - * - * Failure: NULL - * - *------------------------------------------------------------------------- - */ -static void * -H5VL__native_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) -{ - H5F_t *new_file = NULL; - void *ret_value = NULL; - - FUNC_ENTER_STATIC - - /* Adjust bit flags by turning on the creation bit and making sure that - * the EXCL or TRUNC bit is set. All newly-created files are opened for - * reading and writing. - */ - if(0 == (flags & (H5F_ACC_EXCL|H5F_ACC_TRUNC))) - flags |= H5F_ACC_EXCL; /*default*/ - flags |= H5F_ACC_RDWR | H5F_ACC_CREAT; - - /* Create the file */ - if(NULL == (new_file = H5F_open(name, flags, fcpl_id, fapl_id))) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to create file") - new_file->id_exists = TRUE; - - ret_value = (void *)new_file; - -done: - if(NULL == ret_value && new_file) - if(H5F__close(new_file) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "problems closing file") - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_file_create() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_file_open - * - * Purpose: Opens a file as a native HDF5 file. - * - * Return: Success: A pointer to an H5F_t file struct - * - * Failure: NULL - * - *------------------------------------------------------------------------- - */ -static void * -H5VL__native_file_open(const char *name, unsigned flags, hid_t fapl_id, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) -{ - H5F_t *new_file = NULL; - void *ret_value = NULL; - - FUNC_ENTER_STATIC - - /* Open the file */ - if(NULL == (new_file = H5F_open(name, flags, H5P_FILE_CREATE_DEFAULT, fapl_id))) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file") - new_file->id_exists = TRUE; - - ret_value = (void *)new_file; - -done: - if(NULL == ret_value && new_file && H5F_try_close(new_file, NULL) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "problems closing file") - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_file_open() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_file_get - * - * Purpose: Get info about a file - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL__native_file_get(void *obj, H5VL_file_get_t get_type, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) -{ - H5F_t *f = NULL; /* File struct */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - switch(get_type) { - /* H5Fget_access_plist */ - case H5VL_FILE_GET_FAPL: - { - H5P_genplist_t *new_plist; /* New property list */ - hid_t *plist_id = va_arg(arguments, hid_t *); - - f = (H5F_t *)obj; - - /* Retrieve the file's access property list */ - if((*plist_id = H5F_get_access_plist(f, TRUE)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get file access property list") - - if(NULL == (new_plist = (H5P_genplist_t *)H5I_object(*plist_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") - break; - } - - /* H5Fget_create_plist */ - case H5VL_FILE_GET_FCPL: - { - H5P_genplist_t *plist; /* Property list */ - hid_t *plist_id = va_arg(arguments, hid_t *); - - f = (H5F_t *)obj; - if(NULL == (plist = (H5P_genplist_t *)H5I_object(f->shared->fcpl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") - - /* Create the property list object to return */ - if((*plist_id = H5P_copy_plist(plist, TRUE)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "unable to copy file creation properties") - - break; - } - - /* H5Fget_obj_count */ - case H5VL_FILE_GET_OBJ_COUNT: - { - unsigned types = va_arg(arguments, unsigned); - ssize_t *ret = va_arg(arguments, ssize_t *); - size_t obj_count = 0; /* Number of opened objects */ - - f = (H5F_t *)obj; - /* Perform the query */ - if(H5F_get_obj_count(f, types, TRUE, &obj_count) < 0) - HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "H5F_get_obj_count failed") - - /* Set the return value */ - *ret = (ssize_t)obj_count; - break; - } - - /* H5Fget_obj_ids */ - case H5VL_FILE_GET_OBJ_IDS: - { - unsigned types = va_arg(arguments, unsigned); - size_t max_objs = va_arg(arguments, size_t); - hid_t *oid_list = va_arg(arguments, hid_t *); - ssize_t *ret = va_arg(arguments, ssize_t *); - size_t obj_count = 0; /* Number of opened objects */ - - f = (H5F_t *)obj; - /* Perform the query */ - if(H5F_get_obj_ids(f, types, max_objs, oid_list, TRUE, &obj_count) < 0) - HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "H5F_get_obj_ids failed") - - /* Set the return value */ - *ret = (ssize_t)obj_count; - break; - } - - /* H5Fget_intent */ - case H5VL_FILE_GET_INTENT: - { - unsigned *intent_flags = va_arg(arguments, unsigned *); - - f = (H5F_t *)obj; - - /* HDF5 uses some flags internally that users don't know about. - * Simplify things for them so that they only get either H5F_ACC_RDWR - * or H5F_ACC_RDONLY and any SWMR flags. - */ - if(H5F_INTENT(f) & H5F_ACC_RDWR) { - *intent_flags = H5F_ACC_RDWR; - - /* Check for SWMR write access on the file */ - if(H5F_INTENT(f) & H5F_ACC_SWMR_WRITE) - *intent_flags |= H5F_ACC_SWMR_WRITE; - } /* end if */ - else { - *intent_flags = H5F_ACC_RDONLY; - - /* Check for SWMR read access on the file */ - if(H5F_INTENT(f) & H5F_ACC_SWMR_READ) - *intent_flags |= H5F_ACC_SWMR_READ; - } /* end else */ - - break; - } - - /* H5Fget_name */ - case H5VL_FILE_GET_NAME: - { - H5I_type_t type = va_arg(arguments, H5I_type_t); - size_t size = va_arg(arguments, size_t); - char *name = va_arg(arguments, char *); - ssize_t *ret = va_arg(arguments, ssize_t *); - size_t len; - - if(NULL == (f = H5F__get_file(obj, type))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - len = HDstrlen(H5F_OPEN_NAME(f)); - - if(name) { - HDstrncpy(name, H5F_OPEN_NAME(f), MIN(len + 1,size)); - if(len >= size) - name[size-1]='\0'; - } /* end if */ - - /* Set the return value for the API call */ - *ret = (ssize_t)len; - break; - } - - default: - HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information") - } /* end switch */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_file_get() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_file_specific - * - * Purpose: Specific operation on file - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL__native_file_specific(void *obj, H5VL_file_specific_t specific_type, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - switch(specific_type) { - /* H5Fflush */ - case H5VL_FILE_FLUSH: - { - H5I_type_t type = va_arg(arguments, H5I_type_t); - H5F_scope_t scope = va_arg(arguments, H5F_scope_t); - H5F_t *f = NULL; /* File to flush */ - - /* Get the file for the object */ - if(NULL == (f = H5F__get_file(obj, type))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - /* Nothing to do if the file is read only. This determination is - * made at the shared open(2) flags level, implying that opening a - * file twice, once for read-only and once for read-write, and then - * calling H5Fflush() with the read-only handle, still causes data - * to be flushed. - */ - if(H5F_ACC_RDWR & H5F_INTENT(f)) { - /* Flush other files, depending on scope */ - if(H5F_SCOPE_GLOBAL == scope) { - /* Call the flush routine for mounted file hierarchies */ - if(H5F_flush_mounts(f) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush mounted file hierarchy") - } /* end if */ - else { - /* Call the flush routine, for this file */ - if(H5F__flush(f) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush file's cached information") - } /* end else */ - } /* end if */ - break; - } - - /* H5Freopen */ - case H5VL_FILE_REOPEN: - { - void **ret = va_arg(arguments, void **); - H5F_t *new_file = NULL; - - /* Reopen the file through the VOL connector */ - if(NULL == (new_file = H5F__reopen((H5F_t *)obj))) - HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to reopen file") - new_file->id_exists = TRUE; - - *ret = (void *)new_file; - break; - } - - /* H5Fmount */ - case H5VL_FILE_MOUNT: - { - H5I_type_t type = va_arg(arguments, H5I_type_t); - const char *name = va_arg(arguments, const char *); - H5F_t *child = va_arg(arguments, H5F_t *); - hid_t plist_id = va_arg(arguments, hid_t); - H5G_loc_t loc; - - if(H5G_loc_real(obj, type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - /* Do the mount */ - if(H5F__mount(&loc, name, child, plist_id) < 0) - HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to mount file") - - break; - } - - /* H5Funmount */ - case H5VL_FILE_UNMOUNT: - { - H5I_type_t type = va_arg(arguments, H5I_type_t); - const char *name = va_arg(arguments, const char *); - H5G_loc_t loc; - - if(H5G_loc_real(obj, type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - /* Unmount */ - if(H5F__unmount(&loc, name) < 0) - HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to unmount file") - - break; - } - - /* H5Fis_accessible */ - case H5VL_FILE_IS_ACCESSIBLE: - { - hid_t fapl_id = va_arg(arguments, hid_t); - const char *name = va_arg(arguments, const char *); - htri_t *ret = va_arg(arguments, htri_t *); - - /* Call private routine */ - if((*ret = H5F__is_hdf5(name, fapl_id)) < 0) - HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "error in HDF5 file check") - break; - } - - /* H5Fcreate / H5Fopen */ - case H5VL_FILE_CACHE_VOL_CONN: - { - hid_t vol_id = va_arg(arguments, hid_t); - void *vol_info = va_arg(arguments, void *); - - /* Call private routine */ - if(H5F__set_vol_conn((H5F_t *)obj, vol_id, vol_info) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "cache VOL connector ID & info failed") - break; - } - - default: - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation") - } /* end switch */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_file_specific() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_file_optional - * - * Purpose: Perform a connector-specific operation on a native file - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL__native_file_optional(void *obj, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) -{ - H5F_t *f = NULL; /* File */ - H5VL_file_optional_t optional_type = va_arg(arguments, H5VL_file_optional_t); - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - f = (H5F_t *)obj; - switch(optional_type) { - /* H5Fget_filesize */ - case H5VL_FILE_GET_SIZE: - { - haddr_t max_eof_eoa; /* Maximum of the EOA & EOF */ - haddr_t base_addr; /* Base address for the file */ - hsize_t *size = va_arg(arguments, hsize_t *); - - /* Go get the actual file size */ - if(H5F__get_max_eof_eoa(f, &max_eof_eoa) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "file can't get max eof/eoa ") - - base_addr = H5FD_get_base_addr(f->shared->lf); - - if(size) - *size = (hsize_t)(max_eof_eoa + base_addr); /* Convert relative base address for file to absolute address */ - - break; - } - - /* H5Fget_file_image */ - case H5VL_FILE_GET_FILE_IMAGE: - { - void *buf_ptr = va_arg(arguments, void *); - ssize_t *ret = va_arg(arguments, ssize_t *); - size_t buf_len = va_arg(arguments, size_t ); - - /* Do the actual work */ - if((*ret = H5F__get_file_image(f, buf_ptr, buf_len)) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "get file image failed") - break; - } - - /* H5Fget_freespace */ - case H5VL_FILE_GET_FREE_SPACE: - { - hsize_t tot_space; /* Amount of free space in the file */ - hssize_t *ret = va_arg(arguments, hssize_t *); - - /* Go get the actual amount of free space in the file */ - if(H5MF_get_freespace(f, &tot_space, NULL) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to check free space for file") - *ret = (hssize_t)tot_space; - break; - } - - case H5VL_FILE_GET_FREE_SECTIONS: - { - H5F_sect_info_t *sect_info = va_arg(arguments, H5F_sect_info_t *); - ssize_t *ret = va_arg(arguments, ssize_t *); - H5F_mem_t type = va_arg(arguments, H5F_mem_t); - size_t nsects = va_arg(arguments, size_t); - - /* Go get the free-space section information in the file */ - if((*ret = H5MF_get_free_sections(f, type, nsects, sect_info)) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to check free space for file") - break; - } - - /* H5Fget_info2 */ - case H5VL_FILE_GET_INFO: - { - H5I_type_t type = va_arg(arguments, H5I_type_t); - H5F_info2_t *finfo = va_arg(arguments, H5F_info2_t *); - - /* Get the file struct. This call is careful to not return the file pointer - * for the top file in a mount hierarchy. - */ - if(NULL == (f = H5F__get_file(obj, type))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "could not get a file struct") - - /* Get the file info */ - if(H5F__get_info(f, finfo) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to retrieve file info") - - break; - } - - /* H5Fget_mdc_config */ - case H5VL_FILE_GET_MDC_CONF: - { - H5AC_cache_config_t *config_ptr = va_arg(arguments, H5AC_cache_config_t *); - - /* Go get the resize configuration */ - if(H5AC_get_cache_auto_resize_config(f->shared->cache, config_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC_get_cache_auto_resize_config() failed.") - break; - } - - /* H5Fget_mdc_hit_rate */ - case H5VL_FILE_GET_MDC_HR: - { - double *hit_rate_ptr = va_arg(arguments, double *); - - /* Go get the current hit rate */ - if(H5AC_get_cache_hit_rate(f->shared->cache, hit_rate_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC_get_cache_hit_rate() failed.") - break; - } - - /* H5Fget_mdc_size */ - case H5VL_FILE_GET_MDC_SIZE: - { - size_t *max_size_ptr = va_arg(arguments, size_t *); - size_t *min_clean_size_ptr = va_arg(arguments, size_t *); - size_t *cur_size_ptr = va_arg(arguments, size_t *); - int *cur_num_entries_ptr = va_arg(arguments, int *); - uint32_t cur_num_entries; - - /* Go get the size data */ - if(H5AC_get_cache_size(f->shared->cache, max_size_ptr, min_clean_size_ptr, - cur_size_ptr, &cur_num_entries) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC_get_cache_size() failed.") - - if(cur_num_entries_ptr != NULL) - *cur_num_entries_ptr = (int)cur_num_entries; - break; - } - - /* H5Fget_vfd_handle */ - case H5VL_FILE_GET_VFD_HANDLE: - { - void **file_handle = va_arg(arguments, void **); - hid_t fapl_id = va_arg(arguments, hid_t); - - /* Retrieve the VFD handle for the file */ - if(H5F_get_vfd_handle(f, fapl_id, file_handle) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve VFD handle") - break; - } - - /* H5Iget_file_id */ - case H5VL_FILE_GET_FILE_ID: - { - H5I_type_t type = va_arg(arguments, H5I_type_t); - hid_t *file_id = va_arg(arguments, hid_t *); - - if(NULL == (f = H5F__get_file(obj, type))) - HGOTO_ERROR(H5E_FILE, H5E_BADTYPE, FAIL, "not a file or file object") - if((*file_id = H5F__get_file_id(f)) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get file ID") - break; - } - - /* H5Fclear_elink_file_cache */ - case H5VL_FILE_CLEAR_ELINK_CACHE: - { - /* Release the EFC */ - if(f->shared->efc) - if(H5F__efc_release(f->shared->efc) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't release external file cache") - break; - } - - /* H5Freset_mdc_hit_rate_stats */ - case H5VL_FILE_RESET_MDC_HIT_RATE: - { - /* Reset the hit rate statistic */ - if(H5AC_reset_cache_hit_rate_stats(f->shared->cache) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "can't reset cache hit rate") - break; - } - - case H5VL_FILE_SET_MDC_CONFIG: - { - H5AC_cache_config_t *config_ptr = va_arg(arguments, H5AC_cache_config_t *); - - /* set the resize configuration */ - if(H5AC_set_cache_auto_resize_config(f->shared->cache, config_ptr) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "H5AC_set_cache_auto_resize_config() failed") - break; - } - - case H5VL_FILE_GET_METADATA_READ_RETRY_INFO: - { - H5F_retry_info_t *info = va_arg(arguments, H5F_retry_info_t *); - - if(H5F_get_metadata_read_retry_info(f, info) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "can't get metadata read retry info") - - break; - } - - case H5VL_FILE_START_SWMR_WRITE: - { - if(H5F__start_swmr_write(f) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "can't start SWMR write") - - break; - } - - case H5VL_FILE_START_MDC_LOGGING: - { - /* Call mdc logging function */ - if(H5C_start_logging(f->shared->cache) < 0) - HGOTO_ERROR(H5E_FILE, H5E_LOGFAIL, FAIL, "unable to start mdc logging") - - break; - } - - case H5VL_FILE_STOP_MDC_LOGGING: - { - /* Call mdc logging function */ - if(H5C_stop_logging(f->shared->cache) < 0) - HGOTO_ERROR(H5E_FILE, H5E_LOGFAIL, FAIL, "unable to stop mdc logging") - - break; - } - - case H5VL_FILE_GET_MDC_LOGGING_STATUS: - { - hbool_t *is_enabled = va_arg(arguments, hbool_t *); - hbool_t *is_currently_logging = va_arg(arguments, hbool_t *); - - /* Call mdc logging function */ - if(H5C_get_logging_status(f->shared->cache, is_enabled, is_currently_logging) < 0) - HGOTO_ERROR(H5E_FILE, H5E_LOGFAIL, FAIL, "unable to get logging status") - - break; - } - - case H5VL_FILE_FORMAT_CONVERT: - { - /* Convert the format */ - if(H5F__format_convert(f) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTCONVERT, FAIL, "can't convert file format") - - break; - } - - case H5VL_FILE_RESET_PAGE_BUFFERING_STATS: - { - /* Sanity check */ - if(NULL == f->shared->page_buf) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "page buffering not enabled on file") - - /* Reset the statistics */ - if (H5PB_reset_stats(f->shared->page_buf) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't reset stats for page buffering") - - break; - } - - case H5VL_FILE_GET_PAGE_BUFFERING_STATS: - { - unsigned *accesses = va_arg(arguments, unsigned *); - unsigned *hits = va_arg(arguments, unsigned *); - unsigned *misses = va_arg(arguments, unsigned *); - unsigned *evictions = va_arg(arguments, unsigned *); - unsigned *bypasses = va_arg(arguments, unsigned *); - - /* Sanity check */ - if(NULL == f->shared->page_buf) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "page buffering not enabled on file") - - /* Get the statistics */ - if(H5PB_get_stats(f->shared->page_buf, accesses, hits, misses, evictions, bypasses) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve stats for page buffering") - - break; - } - - case H5VL_FILE_GET_MDC_IMAGE_INFO: - { - haddr_t *image_addr = va_arg(arguments, haddr_t *); - hsize_t *image_len = va_arg(arguments, hsize_t *); - - /* Go get the address and size of the cache image */ - if(H5AC_get_mdc_image_info(f->shared->cache, image_addr, image_len) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve cache image info") - - break; - } - - case H5VL_FILE_GET_EOA: - { - haddr_t *eoa = va_arg(arguments, haddr_t *); - haddr_t rel_eoa; /* Relative address of EOA */ - - /* Sanity check */ - HDassert(eoa); - - /* This routine will work only for drivers with this feature enabled.*/ - /* We might introduce a new feature flag in the future */ - if(!H5F_HAS_FEATURE(f, H5FD_FEAT_SUPPORTS_SWMR_IO)) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "must use a SWMR-compatible VFD for this public routine") - - /* The real work */ - if(HADDR_UNDEF == (rel_eoa = H5F_get_eoa(f, H5FD_MEM_DEFAULT))) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "get_eoa request failed") - - /* Set return value */ - /* (Note compensating for base address subtraction in internal routine) */ - *eoa = rel_eoa + H5F_get_base_addr(f); - - break; - } - - case H5VL_FILE_INCR_FILESIZE: - { - hsize_t increment = va_arg(arguments, hsize_t); - haddr_t max_eof_eoa; /* Maximum of the relative EOA & EOF */ - - /* This public routine will work only for drivers with this feature enabled.*/ - /* We might introduce a new feature flag in the future */ - if(!H5F_HAS_FEATURE(f, H5FD_FEAT_SUPPORTS_SWMR_IO)) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "must use a SWMR-compatible VFD for this public routine") - - /* Get the maximum of EOA and EOF */ - if(H5F__get_max_eof_eoa(f, &max_eof_eoa) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "file can't get max eof/eoa ") - - /* Set EOA to the maximum value + increment */ - if(H5F__set_eoa(f, H5FD_MEM_DEFAULT, max_eof_eoa + increment) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "driver set_eoa request failed") - - break; - } - - case H5VL_FILE_SET_LIBVER_BOUNDS: - { - H5F_libver_t low = va_arg(arguments, H5F_libver_t); - H5F_libver_t high = va_arg(arguments, H5F_libver_t); - - /* Call internal set_libver_bounds function */ - if(H5F__set_libver_bounds(f, low, high) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "cannot set low/high bounds") - - break; - } - - default: - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid optional operation") - } /* end switch */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_file_optional() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_file_close - * - * Purpose: Closes a file. - * - * Return: SUCCEED/FAIL (the file will not be closed on failure) - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL__native_file_close(void *file, hid_t H5_ATTR_UNUSED dxpl_id, - void H5_ATTR_UNUSED **req) -{ - int nref; - H5F_t *f = (H5F_t *)file; - hid_t file_id = H5I_INVALID_HID; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - /* This routine should only be called when a file ID's ref count drops to zero */ - HDassert(H5F_ID_EXISTS(f)); - - /* Flush file if this is the last reference to this id and we have write - * intent, unless it will be flushed by the "shared" file being closed. - * This is only necessary to replicate previous behaviour, and could be - * disabled by an option/property to improve performance. - */ - if((H5F_NREFS(f) > 1) && (H5F_INTENT(f) & H5F_ACC_RDWR)) { - /* Get the file ID corresponding to the H5F_t struct */ - if(H5I_find_id(f, H5I_FILE, &file_id) < 0 || H5I_INVALID_HID == file_id) - HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "invalid atom") - - /* Get the number of references outstanding for this file ID */ - if((nref = H5I_get_ref(file_id, FALSE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't get ID ref count") - if(nref == 1) - if(H5F__flush(f) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush cache") - } /* end if */ - - /* Close the file */ - if(H5F__close(f) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "can't close file") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_file_close() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_group_create - * - * Purpose: Creates a group inside a native h5 file. - * - * Return: Success: Pointer to a group struct - * - * Failure: NULL - * - *------------------------------------------------------------------------- - */ -static void * -H5VL__native_group_create(void *obj, const H5VL_loc_params_t *loc_params, const char *name, - hid_t gcpl_id, hid_t H5_ATTR_UNUSED gapl_id, hid_t H5_ATTR_UNUSED dxpl_id, - void H5_ATTR_UNUSED **req) -{ - H5P_genplist_t *plist; /* Property list pointer */ - H5G_loc_t loc; /* Location to create group */ - H5G_t *grp = NULL; /* New group created */ - hid_t lcpl_id; - void *ret_value; - - FUNC_ENTER_STATIC - - /* Get the property list structure */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(gcpl_id))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, NULL, "can't find object for ID") - - /* Get creation properties */ - if(H5P_get(plist, H5VL_PROP_GRP_LCPL_ID, &lcpl_id) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for lcpl id") - - /* Set up the location */ - if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") - - /* if name is NULL then this is from H5Gcreate_anon */ - if(name == NULL) { - H5G_obj_create_t gcrt_info; /* Information for group creation */ - - /* Set up group creation info */ - gcrt_info.gcpl_id = gcpl_id; - gcrt_info.cache_type = H5G_NOTHING_CACHED; - HDmemset(&gcrt_info.cache, 0, sizeof(gcrt_info.cache)); - - /* Create the new group & get its ID */ - if(NULL == (grp = H5G__create(loc.oloc->file, &gcrt_info))) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "unable to create group") - } /* end if */ - /* otherwise it's from H5Gcreate */ - else { - /* Create the new group & get its ID */ - if(NULL == (grp = H5G__create_named(&loc, name, lcpl_id, gcpl_id))) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "unable to create group") - } /* end else */ - - ret_value = (void *)grp; - -done: - if(name == NULL) { - /* Release the group's object header, if it was created */ - if(grp) { - H5O_loc_t *oloc; /* Object location for group */ - - /* Get the new group's object location */ - if(NULL == (oloc = H5G_oloc(grp))) - HDONE_ERROR(H5E_SYM, H5E_CANTGET, NULL, "unable to get object location of group") - - /* Decrement refcount on group's object header in memory */ - if(H5O_dec_rc_by_loc(oloc) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTDEC, NULL, "unable to decrement refcount on newly created object") - } /* end if */ - } /* end if */ - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_group_create() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_group_open - * - * Purpose: Opens a group inside a native h5 file. - * - * Return: Success: Pointer to a group struct - * - * Failure: NULL - * - *------------------------------------------------------------------------- - */ -static void * -H5VL__native_group_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, - hid_t H5_ATTR_UNUSED gapl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) -{ - H5G_loc_t loc; /* Location to open group */ - H5G_t *grp = NULL; /* New group opend */ - void *ret_value; - - FUNC_ENTER_STATIC - - /* Set up the location */ - if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") - - /* Open the group */ - if((grp = H5G__open_name(&loc, name)) == NULL) - HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, NULL, "unable to open group") - - ret_value = (void *)grp; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_group_open() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_group_get - * - * Purpose: Get info about a group - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL__native_group_get(void *obj, H5VL_group_get_t get_type, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - switch(get_type) { - /* H5Gget_create_plist */ - case H5VL_GROUP_GET_GCPL: - { - hid_t *new_gcpl_id = va_arg(arguments, hid_t *); - H5G_t *grp = (H5G_t *)obj; - - if((*new_gcpl_id = H5G_get_create_plist(grp)) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get creation property list for group") - break; - } - - /* H5Gget_info */ - case H5VL_GROUP_GET_INFO: - { - const H5VL_loc_params_t *loc_params = va_arg(arguments, const H5VL_loc_params_t *); - H5G_info_t *group_info = va_arg(arguments, H5G_info_t *); - H5G_loc_t loc; - - if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - if(loc_params->type == H5VL_OBJECT_BY_SELF) { - /* H5Gget_info */ - - /* Retrieve the group's information */ - if(H5G__obj_info(loc.oloc, group_info) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") - } /* end if */ - else if(loc_params->type == H5VL_OBJECT_BY_NAME) { - /* H5Gget_info_by_name */ - - /* Retrieve the group's information */ - if(H5G__get_info_by_name(&loc, loc_params->loc_data.loc_by_name.name, group_info) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") - } /* end else-if */ - else if(loc_params->type == H5VL_OBJECT_BY_IDX) { - /* H5Gget_info_by_idx */ - - /* Retrieve the group's information */ - if(H5G__get_info_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, loc_params->loc_data.loc_by_idx.idx_type, - loc_params->loc_data.loc_by_idx.order, loc_params->loc_data.loc_by_idx.n, group_info) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") - } /* end else-if */ - else - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown get info parameters") - break; - } - - default: - HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from group") - } /* end switch */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_group_get() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_group_specific - * - * Purpose: Specific operations for groups - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL__native_group_specific(void *obj, H5VL_group_specific_t specific_type, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) -{ - H5G_t *grp = (H5G_t *)obj; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - switch(specific_type) { - case H5VL_GROUP_FLUSH: - { - hid_t group_id = va_arg(arguments, hid_t); - - /* Flush object's metadata to file */ - if(H5O_flush_common(&grp->oloc, group_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTFLUSH, FAIL, "unable to flush group") - - break; - } - - case H5VL_GROUP_REFRESH: - { - hid_t group_id = va_arg(arguments, hid_t); - - /* Call private function to refresh group object */ - if((H5O_refresh_metadata(group_id, grp->oloc)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, FAIL, "unable to refresh group") - - break; - } - - default: - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation") - } /* end switch */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_group_specific() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_group_optional - * - * Purpose: Perform a connector-specific operation on a native group - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL__native_group_optional(void *obj, hid_t H5_ATTR_UNUSED dxpl_id, - void H5_ATTR_UNUSED **req, va_list arguments) -{ - H5VL_group_optional_t optional_type; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - optional_type = va_arg(arguments, H5VL_group_optional_t); - switch(optional_type) { -#ifndef H5_NO_DEPRECATED_SYMBOLS - /* H5Giterate (deprecated) */ - case H5VL_GROUP_ITERATE_OLD: - { - const H5VL_loc_params_t *loc_params = va_arg(arguments, const H5VL_loc_params_t *); - hsize_t idx = va_arg(arguments, hsize_t); - hsize_t *last_obj = va_arg(arguments, hsize_t *); - const H5G_link_iterate_t *lnk_op = va_arg(arguments, const H5G_link_iterate_t *); - void *op_data = va_arg(arguments, void *); - H5G_loc_t grp_loc; - - /* Get the location struct for the object */ - if(H5G_loc_real(obj, loc_params->obj_type, &grp_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - /* Call the actual iteration routine */ - if((ret_value = H5G_iterate(&grp_loc, loc_params->loc_data.loc_by_name.name, H5_INDEX_NAME, H5_ITER_INC, idx, last_obj, lnk_op, op_data)) < 0) - HERROR(H5E_VOL, H5E_BADITER, "error iterating over group's links"); - - break; - } - - /* H5Gget_objinfo (deprecated) */ - case H5VL_GROUP_GET_OBJINFO: - { - const H5VL_loc_params_t *loc_params = va_arg(arguments, const H5VL_loc_params_t *); - hbool_t follow_link = va_arg(arguments, unsigned); - H5G_stat_t *statbuf = va_arg(arguments, H5G_stat_t *); - H5G_loc_t grp_loc; - - /* Get the location struct for the object */ - if(H5G_loc_real(obj, loc_params->obj_type, &grp_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - /* Call the actual group objinfo routine */ - if(H5G__get_objinfo(&grp_loc, loc_params->loc_data.loc_by_name.name, follow_link, statbuf) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "cannot stat object") - - break; - } -#endif /* H5_NO_DEPRECATED_SYMBOLS */ - - default: - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid optional operation") - } /* end switch */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_group_optional() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_group_close - * - * Purpose: Closes a group. - * - * Return: SUCCEED/FAIL (the group will not be closed on failure) - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL__native_group_close(void *grp, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - if(H5G_close((H5G_t *)grp) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close group") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_group_close() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_link_create - * - * Purpose: Creates an hard/soft/UD/external links. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Mohamad Chaarawi - * April, 2012 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL__native_link_create(H5VL_link_create_type_t create_type, void *obj, - const H5VL_loc_params_t *loc_params, hid_t lcpl_id, hid_t H5_ATTR_UNUSED lapl_id, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) -{ - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - /* Get the plist structure */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(lcpl_id))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); - - switch(create_type) { - case H5VL_LINK_CREATE_HARD: - { - H5G_loc_t cur_loc; - H5G_loc_t link_loc; - void *cur_obj; - H5VL_loc_params_t cur_params; - - if(H5P_get(plist, H5VL_PROP_LINK_TARGET, &cur_obj) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for current location id") - if(H5P_get(plist, H5VL_PROP_LINK_TARGET_LOC_PARAMS, &cur_params) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for current name") - - if(NULL != cur_obj && H5G_loc_real(cur_obj, cur_params.obj_type, &cur_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - if(NULL != obj && H5G_loc_real(obj, loc_params->obj_type, &link_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - /* H5Lcreate_hard */ - if(H5VL_OBJECT_BY_NAME == cur_params.type) { - H5G_loc_t *cur_loc_p, *link_loc_p; - - /* Set up current & new location pointers */ - cur_loc_p = &cur_loc; - link_loc_p = &link_loc; - if(NULL == cur_obj) - cur_loc_p = link_loc_p; - else if(NULL == obj) - link_loc_p = cur_loc_p; - else if(cur_loc_p->oloc->file != link_loc_p->oloc->file) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "source and destination should be in the same file.") - - /* Create the link */ - if((ret_value = H5L_create_hard(cur_loc_p, cur_params.loc_data.loc_by_name.name, - link_loc_p, loc_params->loc_data.loc_by_name.name, lcpl_id)) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") - } /* end if */ - else { /* H5Olink */ - /* Link to the object */ - if(H5L_link(&link_loc, loc_params->loc_data.loc_by_name.name, &cur_loc, lcpl_id) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to create link") - } /* end else */ - break; - } - - case H5VL_LINK_CREATE_SOFT: - { - char *target_name; - H5G_loc_t link_loc; /* Group location for new link */ - - if(H5G_loc_real(obj, loc_params->obj_type, &link_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - if(H5P_get(plist, H5VL_PROP_LINK_TARGET_NAME, &target_name) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for targe name") - - /* Create the link */ - if((ret_value = H5L_create_soft(target_name, &link_loc, loc_params->loc_data.loc_by_name.name, lcpl_id)) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") - break; - } - - case H5VL_LINK_CREATE_UD: - { - H5G_loc_t link_loc; /* Group location for new link */ - H5L_type_t link_type; - void *udata; - size_t udata_size; - - if(H5G_loc_real(obj, loc_params->obj_type, &link_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - if(H5P_get(plist, H5VL_PROP_LINK_TYPE, &link_type) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for link type") - if(H5P_get(plist, H5VL_PROP_LINK_UDATA, &udata) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for udata") - if(H5P_get(plist, H5VL_PROP_LINK_UDATA_SIZE, &udata_size) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for udata size") - - /* Create link */ - if(H5L__create_ud(&link_loc, loc_params->loc_data.loc_by_name.name, udata, udata_size, - link_type, lcpl_id) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") - break; - } - - default: - HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "invalid link creation call") - } /* end switch */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_link_create() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_link_copy - * - * Purpose: Renames an object within an HDF5 file and copies it to a new - * group. The original name SRC is unlinked from the group graph - * and then inserted with the new name DST (which can specify a - * new path for the object) as an atomic operation. The names - * are interpreted relative to SRC_LOC_ID and - * DST_LOC_ID, which are either file IDs or group ID. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Mohamad Chaarawi - * April, 2012 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL__native_link_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, - void *dst_obj, const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, - hid_t H5_ATTR_UNUSED lapl_id, hid_t H5_ATTR_UNUSED dxpl_id, - void H5_ATTR_UNUSED **req) -{ - H5G_loc_t src_loc, *src_loc_p; - H5G_loc_t dst_loc, *dst_loc_p; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - if(NULL != src_obj && H5G_loc_real(src_obj, loc_params1->obj_type, &src_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - if(NULL != dst_obj && H5G_loc_real(dst_obj, loc_params2->obj_type, &dst_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - /* Set up src & dst location pointers */ - src_loc_p = &src_loc; - dst_loc_p = &dst_loc; - if(NULL == src_obj) - src_loc_p = dst_loc_p; - else if(NULL == dst_obj) - dst_loc_p = src_loc_p; - - /* Copy the link */ - if(H5L_move(src_loc_p, loc_params1->loc_data.loc_by_name.name, - dst_loc_p, loc_params2->loc_data.loc_by_name.name, - TRUE, lcpl_id) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTCOPY, FAIL, "unable to copy link") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_link_copy() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_link_move - * - * Purpose: Renames an object within an HDF5 file and moves it to a new - * group. The original name SRC is unlinked from the group graph - * and then inserted with the new name DST (which can specify a - * new path for the object) as an atomic operation. The names - * are interpreted relative to SRC_LOC_ID and - * DST_LOC_ID, which are either file IDs or group ID. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Mohamad Chaarawi - * April, 2012 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL__native_link_move(void *src_obj, const H5VL_loc_params_t *loc_params1, - void *dst_obj, const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, - hid_t H5_ATTR_UNUSED lapl_id, hid_t H5_ATTR_UNUSED dxpl_id, - void H5_ATTR_UNUSED **req) -{ - H5G_loc_t src_loc, *src_loc_p; - H5G_loc_t dst_loc, *dst_loc_p; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - if(NULL != src_obj && H5G_loc_real(src_obj, loc_params1->obj_type, &src_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - if(NULL != dst_obj && H5G_loc_real(dst_obj, loc_params2->obj_type, &dst_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - /* Set up src & dst location pointers */ - src_loc_p = &src_loc; - dst_loc_p = &dst_loc; - if(NULL == src_obj) - src_loc_p = dst_loc_p; - else if(NULL == dst_obj) - dst_loc_p = src_loc_p; - - /* Move the link */ - if(H5L_move(src_loc_p, loc_params1->loc_data.loc_by_name.name, - dst_loc_p, loc_params2->loc_data.loc_by_name.name, - FALSE, lcpl_id) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTMOVE, FAIL, "unable to move link") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_link_move() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_link_get - * - * Purpose: Get info about a link - * - * Return: Success: 0 - * Failure: -1 - * - * Programmer: Mohamad Chaarawi - * April, 2012 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL__native_link_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_get_t get_type, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) -{ - H5G_loc_t loc; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - switch(get_type) { - /* H5Lget_info/H5Lget_info_by_idx */ - case H5VL_LINK_GET_INFO: - { - H5L_info_t *linfo = va_arg(arguments, H5L_info_t *); - - /* Get the link information */ - if(loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Lget_info */ - if(H5L_get_info(&loc, loc_params->loc_data.loc_by_name.name, linfo) < 0) - HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link info") - } /* end if */ - else if(loc_params->type == H5VL_OBJECT_BY_IDX) { /* H5Lget_info_by_idx */ - if(H5L_get_info_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, loc_params->loc_data.loc_by_idx.idx_type, - loc_params->loc_data.loc_by_idx.order, loc_params->loc_data.loc_by_idx.n, linfo) < 0) - HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link info") - } /* end else-if */ - else - HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link info") - break; - } - - /* H5Lget_name_by_idx */ - case H5VL_LINK_GET_NAME: - { - char *name = va_arg(arguments, char *); - size_t size = va_arg(arguments, size_t); - ssize_t *ret = va_arg(arguments, ssize_t *); - - /* Get the link name */ - if((*ret = H5L_get_name_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, loc_params->loc_data.loc_by_idx.idx_type, - loc_params->loc_data.loc_by_idx.order, loc_params->loc_data.loc_by_idx.n, name, size)) < 0) - HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link info") - - break; - } - - /* H5Lget_val/H5Lget_val_by_idx */ - case H5VL_LINK_GET_VAL: - { - void *buf = va_arg(arguments, void *); - size_t size = va_arg(arguments, size_t); - - /* Get the link information */ - if(loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Lget_val */ - if(H5L_get_val(&loc, loc_params->loc_data.loc_by_name.name, buf, size) < 0) - HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link value") - } - else if(loc_params->type == H5VL_OBJECT_BY_IDX) { /* H5Lget_val_by_idx */ - - if(H5L_get_val_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, loc_params->loc_data.loc_by_idx.idx_type, - loc_params->loc_data.loc_by_idx.order, loc_params->loc_data.loc_by_idx.n, buf, size) < 0) - HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link val") - } - else - HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link val") - - break; - } - - default: - HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from link") - } /* end switch */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_link_get() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_link_specific - * - * Purpose: Specific operation on a link - * - * Return: Success: 0 - * Failure: -1 - * - * Programmer: Mohamad Chaarawi - * April, 2012 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL__native_link_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_specific_t specific_type, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - switch(specific_type) { - case H5VL_LINK_EXISTS: - { - htri_t *ret = va_arg(arguments, htri_t *); - H5G_loc_t loc; - - if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - /* Check for the existence of the link */ - if((*ret = H5L_exists(&loc, loc_params->loc_data.loc_by_name.name)) < 0) - HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to specific link info") - break; - } - - case H5VL_LINK_ITER: - { - H5G_loc_t loc; - hbool_t recursive = va_arg(arguments, int); - H5_index_t idx_type = va_arg(arguments, H5_index_t); - H5_iter_order_t order = va_arg(arguments, H5_iter_order_t); - hsize_t *idx_p = va_arg(arguments, hsize_t *); - H5L_iterate_t op = va_arg(arguments, H5L_iterate_t); - void *op_data = va_arg(arguments, void *); - - /* Get the location */ - if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - - /* Visit or iterate over the links */ - if(loc_params->type == H5VL_OBJECT_BY_SELF) { - if(recursive) { - /* H5Lvisit */ - if((ret_value = H5G_visit(&loc, ".", idx_type, order, op, op_data)) < 0) - HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link visitation failed") - } /* end if */ - else { - /* H5Literate */ - if((ret_value = H5L_iterate(&loc, ".", idx_type, order, idx_p, op, op_data)) < 0) - HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "error iterating over links") - } /* end else */ - } /* end if */ - else if(loc_params->type == H5VL_OBJECT_BY_NAME) { - if(recursive) { - /* H5Lvisit_by_name */ - if((ret_value = H5G_visit(&loc, loc_params->loc_data.loc_by_name.name, idx_type, order, op, op_data)) < 0) - HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link visitation failed") - } /* end if */ - else { - /* H5Literate_by_name */ - if((ret_value = H5L_iterate(&loc, loc_params->loc_data.loc_by_name.name, idx_type, order, idx_p, op, op_data)) < 0) - HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "error iterating over links") - } /* end else */ - } /* end else-if */ - else - HGOTO_ERROR(H5E_LINK, H5E_UNSUPPORTED, FAIL, "unknown link iterate params") - - break; - } - - case H5VL_LINK_DELETE: - { - H5G_loc_t loc; - - if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - /* Unlink */ - if(loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Ldelete */ - if(H5L_delete(&loc, loc_params->loc_data.loc_by_name.name) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "unable to delete link") - } /* end if */ - else if(loc_params->type == H5VL_OBJECT_BY_IDX) { /* H5Ldelete_by_idx */ - if(H5L_delete_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, loc_params->loc_data.loc_by_idx.idx_type, - loc_params->loc_data.loc_by_idx.order, loc_params->loc_data.loc_by_idx.n) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "unable to delete link") - } /* end else-if */ - else - HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "unable to delete link") - break; - } - - default: - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation") - } /* end switch */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_link_specific() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_object_open - * - * Purpose: Opens an object inside a native h5 file. - * - * Return: Success: object id. - * Failure: NULL - * - * Programmer: Mohamad Chaarawi - * March, 2012 - * - *------------------------------------------------------------------------- - */ -static void * -H5VL__native_object_open(void *obj, const H5VL_loc_params_t *loc_params, H5I_type_t *opened_type, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) -{ - H5G_loc_t loc; - void *ret_value = NULL; - - FUNC_ENTER_STATIC - - if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") - - switch(loc_params->type) { - case H5VL_OBJECT_BY_NAME: - { - /* Open the object */ - if(NULL == (ret_value = H5O_open_name(&loc, loc_params->loc_data.loc_by_name.name, opened_type))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, NULL, "unable to open object by name") - break; - } - - case H5VL_OBJECT_BY_IDX: - { - /* Open the object */ - if(NULL == (ret_value = H5O_open_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, loc_params->loc_data.loc_by_idx.idx_type, - loc_params->loc_data.loc_by_idx.order, loc_params->loc_data.loc_by_idx.n, opened_type))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, NULL, "unable to open object by index") - break; - } - - case H5VL_OBJECT_BY_ADDR: - { - /* Open the object */ - if(NULL == (ret_value = H5O_open_by_addr(&loc, loc_params->loc_data.loc_by_addr.addr, opened_type))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, NULL, "unable to open object by address") - break; - } - - case H5VL_OBJECT_BY_REF: - { - hid_t temp_id = H5I_INVALID_HID; - H5F_t *file = NULL; - - /* Get the file pointer from the entry */ - file = loc.oloc->file; - - /* Create reference */ - if((temp_id = H5R__dereference(file, loc_params->loc_data.loc_by_ref.lapl_id, - loc_params->loc_data.loc_by_ref.ref_type, - loc_params->loc_data.loc_by_ref._ref)) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTOPENOBJ, NULL, "unable to dereference object") - - *opened_type = H5I_get_type(temp_id); - if(NULL == (ret_value = H5I_remove(temp_id))) - HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, NULL, "unable to open object") - break; - } - - case H5VL_OBJECT_BY_SELF: - default: - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "unknown open parameters") - } /* end switch */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_object_open() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_object_copy - * - * Purpose: Copies an object inside a native h5 file. - * - * Return: Success: 0 - * Failure: -1 - * - * Programmer: Mohamad Chaarawi - * March, 2012 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL__native_object_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, const char *src_name, - void *dst_obj, const H5VL_loc_params_t *loc_params2, const char *dst_name, - hid_t ocpypl_id, hid_t lcpl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) -{ - H5G_loc_t src_loc; /* Source object group location */ - H5G_loc_t dst_loc; /* Destination group location */ - herr_t ret_value = FAIL; - - FUNC_ENTER_STATIC - - /* get location for objects */ - if(H5G_loc_real(src_obj, loc_params1->obj_type, &src_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - if(H5G_loc_real(dst_obj, loc_params2->obj_type, &dst_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - /* Copy the object */ - if((ret_value = H5O_copy(&src_loc, src_name, &dst_loc, dst_name, ocpypl_id, lcpl_id)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, FAIL, "unable to copy object") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_object_copy() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_object_get - * - * Purpose: Gets certain data about an object - * - * Return: SUCCEED/FAIL - * - * Programmer: Mohamad Chaarawi - * March, 2012 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL__native_object_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_object_get_t get_type, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) -{ - herr_t ret_value = SUCCEED; /* Return value */ - H5G_loc_t loc; /* Location of group */ - - FUNC_ENTER_STATIC - - if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - switch(get_type) { - /* H5Rget_region */ - case H5VL_REF_GET_REGION: - { - hid_t *ret = va_arg(arguments, hid_t *); - H5R_type_t H5_ATTR_UNUSED ref_type = va_arg(arguments, H5R_type_t); - void *ref = va_arg(arguments, void *); - H5S_t *space = NULL; /* Dataspace object */ - - /* Get the dataspace with the correct region selected */ - if((space = H5R__get_region(loc.oloc->file, ref)) == NULL) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to retrieve region") - - /* Atomize */ - if((*ret = H5I_register(H5I_DATASPACE, space, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace atom") - - break; - } - - /* H5Rget_obj_type2 */ - case H5VL_REF_GET_TYPE: - { - H5O_type_t *obj_type = va_arg(arguments, H5O_type_t *); - H5R_type_t ref_type = va_arg(arguments, H5R_type_t); - void *ref = va_arg(arguments, void *); - - /* Get the object information */ - if(H5R__get_obj_type(loc.oloc->file, ref_type, ref, obj_type) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to determine object type") - break; - } - - /* H5Rget_name */ - case H5VL_REF_GET_NAME: - { - ssize_t *ret = va_arg(arguments, ssize_t *); - char *name = va_arg(arguments, char *); - size_t size = va_arg(arguments, size_t); - H5R_type_t ref_type = va_arg(arguments, H5R_type_t); - void *ref = va_arg(arguments, void *); - - /* Get name */ - if((*ret = H5R__get_name(loc.oloc->file, ref_type, ref, name, size)) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to determine object path") - break; - } - - /* H5Iget_name */ - case H5VL_ID_GET_NAME: - { - ssize_t *ret = va_arg(arguments, ssize_t *); - char *name = va_arg(arguments, char *); - size_t size = va_arg(arguments, size_t); - - /* Retrieve object's name */ - if((*ret = H5G_get_name(&loc, name, size, NULL)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't retrieve object name") - - break; - } - - default: - HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from object") - } /* end switch */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_object_get() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_object_specific - * - * Purpose: Specific operation on an object - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL__native_object_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_object_specific_t specific_type, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) -{ - H5G_loc_t loc; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - switch(specific_type) { - /* H5Oincr_refcount / H5Odecr_refcount */ - case H5VL_OBJECT_CHANGE_REF_COUNT: - { - int update_ref = va_arg(arguments, int); - H5O_loc_t *oloc = loc.oloc; - - if(H5O_link(oloc, update_ref) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "modifying object link count failed") - - break; - } - - /* H5Oexists_by_name */ - case H5VL_OBJECT_EXISTS: - { - htri_t *ret = va_arg(arguments, htri_t *); - - if(loc_params->type == H5VL_OBJECT_BY_NAME) { - /* Check if the object exists */ - if((*ret = H5G_loc_exists(&loc, loc_params->loc_data.loc_by_name.name)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to determine if '%s' exists", loc_params->loc_data.loc_by_name.name) - } /* end if */ - else - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown object exists parameters") - break; - } - - case H5VL_OBJECT_VISIT: - { - H5_index_t idx_type = va_arg(arguments, H5_index_t); - H5_iter_order_t order = va_arg(arguments, H5_iter_order_t); - H5O_iterate_t op = va_arg(arguments, H5O_iterate_t); - void *op_data = va_arg(arguments, void *); - unsigned fields = va_arg(arguments, unsigned); - - /* Call internal object visitation routine */ - if(loc_params->type == H5VL_OBJECT_BY_SELF) { - /* H5Ovisit */ - if((ret_value = H5O__visit(&loc, ".", idx_type, order, op, op_data, fields)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed") - } /* end if */ - else if(loc_params->type == H5VL_OBJECT_BY_NAME) { - /* H5Ovisit_by_name */ - if((ret_value = H5O__visit(&loc, loc_params->loc_data.loc_by_name.name, idx_type, order, op, op_data, fields)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed") - } /* end else-if */ - else - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown object visit params"); - break; - } - - case H5VL_OBJECT_FLUSH: - { - hid_t oid = va_arg(arguments, hid_t); - - /* Flush the object's metadata */ - if(H5O_flush(loc.oloc, oid) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTFLUSH, FAIL, "unable to flush object") - - break; - } - - case H5VL_OBJECT_REFRESH: - { - hid_t oid = va_arg(arguments, hid_t); - H5O_loc_t *oloc = loc.oloc; - - /* Refresh the metadata */ - if(H5O_refresh_metadata(oid, *oloc) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to refresh object") - - break; - } - - case H5VL_REF_CREATE: - { - void *ref = va_arg(arguments, void *); - const char *name = va_arg(arguments, char *); - H5R_type_t ref_type = va_arg(arguments, H5R_type_t); - hid_t space_id = va_arg(arguments, hid_t); - H5S_t *space = NULL; /* Pointer to dataspace containing region */ - - if(space_id != (-1) && (NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE)))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") - - /* Create reference */ - if(H5R__create(ref, &loc, name, ref_type, space) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCREATE, FAIL, "unable to create reference") - - break; - } - - default: - HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't recognize this operation type") - } /* end switch */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_object_specific() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_object_optional - * - * Purpose: Perform a connector-specific operation for an objectibute - * - * Return: Success: 0 - * Failure: -1 - * - * Programmer: Mohamad Chaarawi - * April, 2012 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL__native_object_optional(void *obj, hid_t H5_ATTR_UNUSED dxpl_id, - void H5_ATTR_UNUSED **req, va_list arguments) -{ - H5VL_object_optional_t optional_type = va_arg(arguments, H5VL_object_optional_t); - H5VL_loc_params_t *loc_params = va_arg(arguments, H5VL_loc_params_t *); - H5G_loc_t loc; /* Location of group */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - switch(optional_type) { - /* H5Oget_info / H5Oget_info_by_name / H5Oget_info_by_idx */ - case H5VL_OBJECT_GET_INFO: - { - H5O_info_t *obj_info = va_arg(arguments, H5O_info_t *); - unsigned fields = va_arg(arguments, unsigned); - - if(loc_params->type == H5VL_OBJECT_BY_SELF) { /* H5Oget_info */ - /* Retrieve the object's information */ - if(H5G_loc_info(&loc, ".", obj_info, fields) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") - } /* end if */ - else if(loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Oget_info_by_name */ - /* Retrieve the object's information */ - if(H5G_loc_info(&loc, loc_params->loc_data.loc_by_name.name, obj_info, fields) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") - } /* end else-if */ - else if(loc_params->type == H5VL_OBJECT_BY_IDX) { /* H5Oget_info_by_idx */ - H5G_loc_t obj_loc; /* Location used to open group */ - H5G_name_t obj_path; /* Opened object group hier. path */ - H5O_loc_t obj_oloc; /* Opened object object location */ - - /* Set up opened group location to fill in */ - obj_loc.oloc = &obj_oloc; - obj_loc.path = &obj_path; - H5G_loc_reset(&obj_loc); - - /* Find the object's location, according to the order in the index */ - if(H5G_loc_find_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, - loc_params->loc_data.loc_by_idx.idx_type, - loc_params->loc_data.loc_by_idx.order, - loc_params->loc_data.loc_by_idx.n, &obj_loc/*out*/) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "group not found") - - /* Retrieve the object's information */ - if(H5O_get_info(obj_loc.oloc, obj_info, fields) < 0) { - H5G_loc_free(&obj_loc); - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve object info") - } /* end if */ - - /* Release the object location */ - if(H5G_loc_free(&obj_loc) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "can't free location") - } /* end else-if */ - else - HGOTO_ERROR(H5E_OHDR, H5E_UNSUPPORTED, FAIL, "unknown get info parameters") - break; - } - - /* H5Oget_comment / H5Oget_comment_by_name */ - case H5VL_OBJECT_GET_COMMENT: - { - char *comment = va_arg(arguments, char *); - size_t bufsize = va_arg(arguments, size_t); - ssize_t *ret = va_arg(arguments, ssize_t *); - - /* Retrieve the object's comment */ - if(loc_params->type == H5VL_OBJECT_BY_SELF) { /* H5Oget_comment */ - if((*ret = H5G_loc_get_comment(&loc, ".", comment/*out*/, bufsize)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") - } /* end if */ - else if(loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Oget_comment_by_name */ - if((*ret = H5G_loc_get_comment(&loc, loc_params->loc_data.loc_by_name.name, comment/*out*/, bufsize)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") - } /* end else-if */ - else - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown set_coment parameters") - break; - } - - /* H5Oset_comment */ - case H5VL_OBJECT_SET_COMMENT: - { - const char *comment = va_arg(arguments, char *); - - if(loc_params->type == H5VL_OBJECT_BY_SELF) { /* H5Oset_comment */ - /* (Re)set the object's comment */ - if(H5G_loc_set_comment(&loc, ".", comment) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") - } /* end if */ - else if(loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Oset_comment_by_name */ - /* (Re)set the object's comment */ - if(H5G_loc_set_comment(&loc, loc_params->loc_data.loc_by_name.name, comment) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") - } /* end else-if */ - else - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown set_coment parameters") - break; - } - - default: - HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't perform this operation on object"); - } /* end switch */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_object_optional() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_datatype_commit - * - * Purpose: Commits a datatype inside a native h5 file. - * - * Return: Success: datatype id. - * Failure: NULL - * - * Programmer: Mohamad Chaarawi - * March, 2012 - * - *------------------------------------------------------------------------- - */ -static void * -H5VL__native_datatype_commit(void *obj, const H5VL_loc_params_t *loc_params, const char *name, - hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t H5_ATTR_UNUSED tapl_id, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) -{ - H5G_loc_t loc; /* Location to commit datatype */ - H5T_t *dt; /* Datatype for ID */ - H5T_t *type = NULL; /* copy of the original type which will be committed */ - void *ret_value = NULL; /* Return value */ - - FUNC_ENTER_STATIC - - /* check arguments */ - if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") - - if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a datatype") - - /* Check arguments. We cannot commit an immutable type because H5Tclose() - * normally fails on such types (try H5Tclose(H5T_NATIVE_INT)) but closing - * a named type should always succeed. - */ - if(H5T_STATE_NAMED == dt->shared->state || H5T_STATE_OPEN == dt->shared->state) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "datatype is already committed") - if(H5T_STATE_IMMUTABLE == dt->shared->state) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "datatype is immutable") - - /* Check for a "sensible" datatype to store on disk */ - if(H5T_is_sensible(dt) <= 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "datatype is not sensible") - - /* Copy the datatype - the copied one will be the type that is - * committed, and attached to original datatype above the VOL - * layer - */ - if(NULL == (type = H5T_copy(dt, H5T_COPY_TRANSIENT))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to copy"); - - /* Commit the datatype */ - if(NULL != name) { - /* H5Tcommit */ - if(H5T__commit_named(&loc, name, type, lcpl_id, tcpl_id) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to commit datatype") - } /* end if */ - else { - /* H5Tcommit_anon */ - if(H5T__commit_anon(loc.oloc->file, type, tcpl_id) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to commit datatype") - } /* end else */ - - ret_value = (void *)type; - -done: - if(NULL == ret_value && type) - H5T_close(type); - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_datatype_commit() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_datatype_open - * - * Purpose: Opens a named datatype inside a native h5 file. - * - * Return: Success: datatype pointer - * Failure: NULL - * - *------------------------------------------------------------------------- - */ -static void * -H5VL__native_datatype_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, - hid_t H5_ATTR_UNUSED tapl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) -{ - H5T_t *type = NULL; /* Datatype opened in file */ - H5G_loc_t loc; /* Group location of object to open */ - void *ret_value = NULL; - - FUNC_ENTER_STATIC - - if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") - - /* Open the datatype */ - if(NULL == (type = H5T__open_name(&loc, name))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, NULL, "unable to open named datatype") - - type->vol_obj = NULL; - - ret_value = (void *)type; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_datatype_open() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_datatype_get - * - * Purpose: Get information about a datatype - * - * Return: Success: 0 - * Failure: -1 - * - * Programmer: Mohamad Chaarawi - * June, 2013 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL__native_datatype_get(void *obj, H5VL_datatype_get_t get_type, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) -{ - H5T_t *dt = (H5T_t *)obj; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - switch (get_type) { - case H5VL_DATATYPE_GET_BINARY: - { - ssize_t *nalloc = va_arg(arguments, ssize_t *); - void *buf = va_arg(arguments, void *); - size_t size = va_arg(arguments, size_t); - - if(H5T_encode(dt, (unsigned char *)buf, &size) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't determine serialized length of datatype") - - *nalloc = (ssize_t) size; - break; - } - - /* H5Tget_create_plist */ - case H5VL_DATATYPE_GET_TCPL: - { - hid_t *ret_id = va_arg(arguments, hid_t *); - - if(H5I_INVALID_HID == (*ret_id = H5T__get_create_plist(dt))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't get object creation info"); - - break; - } - - default: - HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from datatype") - } /* end switch */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_datatype_get() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_datatype_specific - * - * Purpose: Specific operations for datatype - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL__native_datatype_specific(void *obj, H5VL_datatype_specific_t specific_type, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) -{ - H5T_t *dt = (H5T_t *)obj; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - switch(specific_type) { - case H5VL_DATATYPE_FLUSH: - { - hid_t type_id = va_arg(arguments, hid_t); - - /* To flush metadata and invoke flush callback if there is */ - if (H5O_flush_common(&dt->oloc, type_id) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFLUSH, FAIL, "unable to flush datatype") - - break; - } - - case H5VL_DATATYPE_REFRESH: - { - hid_t type_id = va_arg(arguments, hid_t); - - /* Call private function to refresh datatype object */ - if ((H5O_refresh_metadata(type_id, dt->oloc)) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTLOAD, FAIL, "unable to refresh datatype") - - break; - } - - default: - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation") - } /* end switch */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_datatype_specific() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_datatype_close - * - * Purpose: Closes a datatype. - * - * Return: Success: 0 - * Failure: -1, datatype not closed. - * - * Programmer: Mohamad Chaarawi - * March, 2012 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL__native_datatype_close(void *dt, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - if(H5T_close((H5T_t*)dt) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "can't close datatype") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_datatype_close() */ - diff --git a/src/H5VLnative.h b/src/H5VLnative.h index 8ae3a66..1a3007a 100644 --- a/src/H5VLnative.h +++ b/src/H5VLnative.h @@ -25,14 +25,70 @@ #define H5VL_NATIVE_VALUE H5_VOL_NATIVE /* enum value */ #define H5VL_NATIVE_VERSION 0 +/* Typedef and values for native VOL connector attribute optional VOL operations */ +typedef int H5VL_native_attr_optional_t; +#ifndef H5_NO_DEPRECATED_SYMBOLS +#define H5VL_NATIVE_ATTR_ITERATE_OLD 0 /* H5Aiterate (deprecated routine) */ +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + +/* Typedef and values for native VOL connector dataset optional VOL operations */ +typedef int H5VL_native_dataset_optional_t; +#define H5VL_NATIVE_DATASET_FORMAT_CONVERT 0 /* H5Dformat_convert (internal) */ +#define H5VL_NATIVE_DATASET_GET_CHUNK_INDEX_TYPE 1 /* H5Dget_chunk_index_type */ +#define H5VL_NATIVE_DATASET_GET_CHUNK_STORAGE_SIZE 2 /* H5Dget_chunk_storage_size */ +#define H5VL_NATIVE_DATASET_CHUNK_READ 3 /* H5Dchunk_read */ +#define H5VL_NATIVE_DATASET_CHUNK_WRITE 4 /* H5Dchunk_write */ + +/* Typedef and values for native VOL connector file optional VOL operations */ +typedef int H5VL_native_file_optional_t; +#define H5VL_NATIVE_FILE_CLEAR_ELINK_CACHE 0 /* H5Fclear_elink_file_cache */ +#define H5VL_NATIVE_FILE_GET_FILE_IMAGE 1 /* H5Fget_file_image */ +#define H5VL_NATIVE_FILE_GET_FREE_SECTIONS 2 /* H5Fget_free_sections */ +#define H5VL_NATIVE_FILE_GET_FREE_SPACE 3 /* H5Fget_freespace */ +#define H5VL_NATIVE_FILE_GET_INFO 4 /* H5Fget_info1/2 */ +#define H5VL_NATIVE_FILE_GET_MDC_CONF 5 /* H5Fget_mdc_config */ +#define H5VL_NATIVE_FILE_GET_MDC_HR 6 /* H5Fget_mdc_hit_rate */ +#define H5VL_NATIVE_FILE_GET_MDC_SIZE 7 /* H5Fget_mdc_size */ +#define H5VL_NATIVE_FILE_GET_SIZE 8 /* H5Fget_filesize */ +#define H5VL_NATIVE_FILE_GET_VFD_HANDLE 9 /* H5Fget_vfd_handle */ +#define H5VL_NATIVE_FILE_GET_FILE_ID 10 /* H5Fget_file_id */ +#define H5VL_NATIVE_FILE_RESET_MDC_HIT_RATE 11 /* H5Freset_mdc_hit_rate_stats */ +#define H5VL_NATIVE_FILE_SET_MDC_CONFIG 12 /* H5Fset_mdc_config */ +#define H5VL_NATIVE_FILE_GET_METADATA_READ_RETRY_INFO 13 /* H5Fget_metadata_read_retry_info */ +#define H5VL_NATIVE_FILE_START_SWMR_WRITE 14 /* H5Fstart_swmr_write */ +#define H5VL_NATIVE_FILE_START_MDC_LOGGING 15 /* H5Fstart_mdc_logging */ +#define H5VL_NATIVE_FILE_STOP_MDC_LOGGING 16 /* H5Fstop_mdc_logging */ +#define H5VL_NATIVE_FILE_GET_MDC_LOGGING_STATUS 17 /* H5Fget_mdc_logging_status */ +#define H5VL_NATIVE_FILE_FORMAT_CONVERT 18 /* H5Fformat_convert */ +#define H5VL_NATIVE_FILE_RESET_PAGE_BUFFERING_STATS 19 /* H5Freset_page_buffering_stats */ +#define H5VL_NATIVE_FILE_GET_PAGE_BUFFERING_STATS 20 /* H5Fget_page_buffering_stats */ +#define H5VL_NATIVE_FILE_GET_MDC_IMAGE_INFO 21 /* H5Fget_mdc_image_info */ +#define H5VL_NATIVE_FILE_GET_EOA 22 /* H5Fget_eoa */ +#define H5VL_NATIVE_FILE_INCR_FILESIZE 23 /* H5Fincrement_filesize */ +#define H5VL_NATIVE_FILE_SET_LIBVER_BOUNDS 24 /* H5Fset_latest_format/libver_bounds */ +#define H5VL_NATIVE_FILE_GET_MIN_DSET_OHDR_FLAG 25 /* H5Fget_dset_no_attrs_hint */ +#define H5VL_NATIVE_FILE_SET_MIN_DSET_OHDR_FLAG 26 /* H5Fset_dset_no_attrs_hint */ + +/* Typedef and values for native VOL connector group optional VOL operations */ +typedef int H5VL_native_group_optional_t; +#ifndef H5_NO_DEPRECATED_SYMBOLS +#define H5VL_NATIVE_GROUP_ITERATE_OLD 0 /* HG5Giterate (deprecated routine) */ +#define H5VL_NATIVE_GROUP_GET_OBJINFO 1 /* HG5Gget_objinfo (deprecated routine) */ +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + +/* Typedef and values for native VOL connector object optional VOL operations */ +typedef int H5VL_native_object_optional_t; +#define H5VL_NATIVE_OBJECT_GET_COMMENT 0 /* H5G|H5Oget_comment, H5Oget_comment_by_name */ +#define H5VL_NATIVE_OBJECT_GET_INFO 1 /* H5Oget_info(_by_idx, _by_name)(2) */ +#define H5VL_NATIVE_OBJECT_SET_COMMENT 2 /* H5G|H5Oset_comment, H5Oset_comment_by_name */ #ifdef __cplusplus extern "C" { #endif +/* Private functions */ H5_DLL hid_t H5VL_native_register(void); - #ifdef __cplusplus } #endif diff --git a/src/H5VLnative_attr.c b/src/H5VLnative_attr.c new file mode 100644 index 0000000..7d9f0ac --- /dev/null +++ b/src/H5VLnative_attr.c @@ -0,0 +1,597 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * 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 COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: Attribute callbacks for the native VOL connector + * + */ + +#define H5A_FRIEND /* Suppress error about including H5Apkg */ + +#include "H5private.h" /* Generic Functions */ +#include "H5Apkg.h" /* Attributes */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* Files */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5Sprivate.h" /* Dataspaces */ +#include "H5Tprivate.h" /* Datatypes */ +#include "H5VLprivate.h" /* Virtual Object Layer */ + +#include "H5VLnative_private.h" /* Native VOL connector */ + + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_attr_create + * + * Purpose: Handles the attribute create callback + * + * Return: Success: attribute pointer + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL__native_attr_create(void *obj, const H5VL_loc_params_t *loc_params, const char *attr_name, + hid_t acpl_id, hid_t H5_ATTR_UNUSED aapl_id, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req) +{ + H5G_loc_t loc; /* Object location */ + H5G_loc_t obj_loc; /* Location used to open group */ + hbool_t loc_found = FALSE; + H5P_genplist_t *plist; /* Property list pointer */ + hid_t type_id, space_id; + H5T_t *type, *dt; /* Datatype to use for attribute */ + H5S_t *space; /* Dataspace to use for attribute */ + H5A_t *attr = NULL; + void *ret_value = NULL; + + FUNC_ENTER_PACKAGE + + /* Get the plist structure */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(acpl_id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, NULL, "can't find object for ID") + + /* get creation properties */ + if(H5P_get(plist, H5VL_PROP_ATTR_TYPE_ID, &type_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for datatype id") + if(H5P_get(plist, H5VL_PROP_ATTR_SPACE_ID, &space_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for space id") + + if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") + if(0 == (H5F_INTENT(loc.oloc->file) & H5F_ACC_RDWR)) + HGOTO_ERROR(H5E_ARGS, H5E_WRITEERROR, NULL, "no write intent on file") + + if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a datatype") + /* If this is a named datatype, get the connector's pointer to the datatype */ + type = H5T_get_actual_type(dt); + + if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data space") + + if(loc_params->type == H5VL_OBJECT_BY_SELF) { + /* H5Acreate */ + /* Go do the real work for attaching the attribute to the dataset */ + if(NULL == (attr = H5A__create(&loc, attr_name, type, space, acpl_id))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, NULL, "unable to create attribute") + } /* end if */ + else if(loc_params->type == H5VL_OBJECT_BY_NAME) { + /* H5Acreate_by_name */ + if(NULL == (attr = H5A__create_by_name(&loc, loc_params->loc_data.loc_by_name.name, attr_name, type, space, acpl_id))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, NULL, "unable to create attribute") + } /* end else-if */ + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "unknown attribute create parameters") + + ret_value = (void *)attr; + +done: + /* Release resources */ + if(loc_found && H5G_loc_free(&obj_loc) < 0) + HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, NULL, "can't free location") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_attr_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_attr_open + * + * Purpose: Handles the attribute open callback + * + * Return: Success: attribute pointer + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL__native_attr_open(void *obj, const H5VL_loc_params_t *loc_params, const char *attr_name, + hid_t H5_ATTR_UNUSED aapl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + H5G_loc_t loc; /* Object location */ + H5A_t *attr = NULL; /* Attribute opened */ + void *ret_value; + + FUNC_ENTER_PACKAGE + + /* check arguments */ + if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") + + if(loc_params->type == H5VL_OBJECT_BY_SELF) { + /* H5Aopen */ + /* Open the attribute */ + if(NULL == (attr = H5A__open(&loc, attr_name))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "unable to open attribute: '%s'", attr_name) + } /* end if */ + else if(loc_params->type == H5VL_OBJECT_BY_NAME) { + /* H5Aopen_by_name */ + /* Open the attribute on the object header */ + if(NULL == (attr = H5A__open_by_name(&loc, loc_params->loc_data.loc_by_name.name, attr_name))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "can't open attribute") + } /* end else-if */ + else if(loc_params->type == H5VL_OBJECT_BY_IDX) { + /* H5Aopen_by_idx */ + /* Open the attribute in the object header */ + if(NULL == (attr = H5A__open_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, + loc_params->loc_data.loc_by_idx.idx_type, + loc_params->loc_data.loc_by_idx.order, + loc_params->loc_data.loc_by_idx.n))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "unable to open attribute") + } /* end else-if */ + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "unknown attribute open parameters") + + ret_value = (void *)attr; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_attr_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_attr_read + * + * Purpose: Handles the attribute read callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_attr_read(void *attr, hid_t dtype_id, void *buf, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + H5T_t *mem_type; /* Memory datatype */ + herr_t ret_value; /* Return value */ + + FUNC_ENTER_PACKAGE + + if(NULL == (mem_type = (H5T_t *)H5I_object_verify(dtype_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") + + /* Go write the actual data to the attribute */ + if((ret_value = H5A__read((H5A_t*)attr, mem_type, buf)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_READERROR, FAIL, "unable to read attribute") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_attr_read() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_attr_write + * + * Purpose: Handles the attribute write callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_attr_write(void *attr, hid_t dtype_id, const void *buf, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + H5T_t *mem_type; /* Memory datatype */ + herr_t ret_value; /* Return value */ + + FUNC_ENTER_PACKAGE + + if(NULL == (mem_type = (H5T_t *)H5I_object_verify(dtype_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") + + /* Go write the actual data to the attribute */ + if((ret_value = H5A__write((H5A_t*)attr, mem_type, buf)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_WRITEERROR, FAIL, "unable to write attribute") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_attr_write() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_attr_get + * + * Purpose: Handles the attribute get callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_attr_get(void *obj, H5VL_attr_get_t get_type, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + switch(get_type) { + /* H5Aget_space */ + case H5VL_ATTR_GET_SPACE: + { + hid_t *ret_id = HDva_arg(arguments, hid_t *); + H5A_t *attr = (H5A_t *)obj; + + if((*ret_id = H5A_get_space(attr)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get space ID of attribute") + break; + } + + /* H5Aget_type */ + case H5VL_ATTR_GET_TYPE: + { + hid_t *ret_id = HDva_arg(arguments, hid_t *); + H5A_t *attr = (H5A_t *)obj; + + if((*ret_id = H5A__get_type(attr)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get datatype ID of attribute") + break; + } + + /* H5Aget_create_plist */ + case H5VL_ATTR_GET_ACPL: + { + hid_t *ret_id = HDva_arg(arguments, hid_t *); + H5A_t *attr = (H5A_t *)obj; + + if((*ret_id = H5A__get_create_plist(attr)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get creation property list for attr") + + break; + } + + /* H5Aget_name */ + case H5VL_ATTR_GET_NAME: + { + const H5VL_loc_params_t *loc_params = HDva_arg(arguments, const H5VL_loc_params_t *); + size_t buf_size = HDva_arg(arguments, size_t); + char *buf = HDva_arg(arguments, char *); + ssize_t *ret_val = HDva_arg(arguments, ssize_t *); + H5A_t *attr = NULL; + + if(H5VL_OBJECT_BY_SELF == loc_params->type) { + attr = (H5A_t *)obj; + /* Call private function in turn */ + if(0 > (*ret_val = H5A__get_name(attr, buf_size, buf))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get attribute name") + } + else if(H5VL_OBJECT_BY_IDX == loc_params->type) { + H5G_loc_t loc; + + /* check arguments */ + if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Open the attribute on the object header */ + if(NULL == (attr = H5A__open_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, + loc_params->loc_data.loc_by_idx.idx_type, + loc_params->loc_data.loc_by_idx.order, + loc_params->loc_data.loc_by_idx.n))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute") + + /* Get the length of the name */ + *ret_val = (ssize_t)HDstrlen(attr->shared->name); + + /* Copy the name into the user's buffer, if given */ + if(buf) { + HDstrncpy(buf, attr->shared->name, MIN((size_t)(*ret_val + 1), buf_size)); + if((size_t)(*ret_val) >= buf_size) + buf[buf_size - 1]='\0'; + } /* end if */ + + /* Release resources */ + if(attr && H5A__close(attr) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute") + } + else + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get name of attr") + + break; + } + + /* H5Aget_info */ + case H5VL_ATTR_GET_INFO: + { + const H5VL_loc_params_t *loc_params = HDva_arg(arguments, const H5VL_loc_params_t *); + H5A_info_t *ainfo = HDva_arg(arguments, H5A_info_t *); + H5A_t *attr = NULL; + + if(H5VL_OBJECT_BY_SELF == loc_params->type) { + attr = (H5A_t *)obj; + if(H5A__get_info(attr, ainfo) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get attribute info") + } + else if(H5VL_OBJECT_BY_NAME == loc_params->type) { + char *attr_name = HDva_arg(arguments, char *); + H5G_loc_t loc; + + /* check arguments */ + if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Open the attribute on the object header */ + if(NULL == (attr = H5A__open_by_name(&loc, loc_params->loc_data.loc_by_name.name, attr_name))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute") + + /* Get the attribute information */ + if(H5A__get_info(attr, ainfo) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to get attribute info") + + /* Release resources */ + if(attr && H5A__close(attr) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute") + } + else if(H5VL_OBJECT_BY_IDX == loc_params->type) { + H5G_loc_t loc; + + /* check arguments */ + if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Open the attribute on the object header */ + if(NULL == (attr = H5A__open_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, + loc_params->loc_data.loc_by_idx.idx_type, + loc_params->loc_data.loc_by_idx.order, + loc_params->loc_data.loc_by_idx.n))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute") + + /* Get the attribute information */ + if(H5A__get_info(attr, ainfo) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to get attribute info") + + /* Release resources */ + if(attr && H5A__close(attr) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute") + } + else + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get name of attr") + + break; + } + + case H5VL_ATTR_GET_STORAGE_SIZE: + { + hsize_t *ret = HDva_arg(arguments, hsize_t *); + H5A_t *attr = (H5A_t *)obj; + + /* Set return value */ + *ret = attr->shared->data_size; + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from attr") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_attr_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_attr_specific + * + * Purpose: Handles the attribute specific callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_attr_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_attr_specific_t specific_type, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +{ + H5G_loc_t loc; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Get location for passed-in object */ + if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + switch(specific_type) { + case H5VL_ATTR_DELETE: + { + char *attr_name = HDva_arg(arguments, char *); + + if(H5VL_OBJECT_BY_SELF == loc_params->type) { + /* H5Adelete */ + /* Delete the attribute from the location */ + if(H5O__attr_remove(loc.oloc, attr_name) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") + } /* end if */ + else if(H5VL_OBJECT_BY_NAME == loc_params->type) { + /* H5Adelete_by_name */ + /* Delete the attribute */ + if(H5A__delete_by_name(&loc, loc_params->loc_data.loc_by_name.name, attr_name) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") + } /* end else-if */ + else if(H5VL_OBJECT_BY_IDX == loc_params->type) { + /* H5Adelete_by_idx */ + /* Delete the attribute from the location */ + if(H5A__delete_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, loc_params->loc_data.loc_by_idx.idx_type, + loc_params->loc_data.loc_by_idx.order, loc_params->loc_data.loc_by_idx.n) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") + } /* end else-if */ + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown attribute remove parameters") + break; + } + + case H5VL_ATTR_EXISTS: + { + const char *attr_name = HDva_arg(arguments, const char *); + htri_t *ret = HDva_arg(arguments, htri_t *); + + if(loc_params->type == H5VL_OBJECT_BY_SELF) { /* H5Aexists */ + /* Check if the attribute exists */ + if((*ret = H5O__attr_exists(loc.oloc, attr_name)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to determine if attribute exists") + } /* end if */ + else if(loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Aexists_by_name */ + /* Check if the attribute exists */ + if((*ret = H5A__exists_by_name(loc, loc_params->loc_data.loc_by_name.name, attr_name)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to determine if attribute exists") + } /* end else-if */ + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown parameters") + break; + } + + case H5VL_ATTR_ITER: + { + H5_index_t idx_type = (H5_index_t)HDva_arg(arguments, int); /* enum work-around */ + H5_iter_order_t order = (H5_iter_order_t)HDva_arg(arguments, int); /* enum work-around */ + hsize_t *idx = HDva_arg(arguments, hsize_t *); + H5A_operator2_t op = HDva_arg(arguments, H5A_operator2_t); + void *op_data = HDva_arg(arguments, void *); + + if(loc_params->type == H5VL_OBJECT_BY_SELF) { /* H5Aiterate2 */ + /* Iterate over attributes */ + if((ret_value = H5A__iterate(&loc, ".", idx_type, order, idx, op, op_data)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_BADITER, FAIL, "error iterating over attributes") + } /* end if */ + else if(loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Aiterate_by_name */ + /* Iterate over attributes by name */ + if((ret_value = H5A__iterate(&loc, loc_params->loc_data.loc_by_name.name, idx_type, order, idx, op, op_data)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_BADITER, FAIL, "attribute iteration failed"); + } /* end else-if */ + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown parameters") + break; + } + + /* H5Arename/rename_by_name */ + case H5VL_ATTR_RENAME: + { + const char *old_name = HDva_arg(arguments, const char *); + const char *new_name = HDva_arg(arguments, const char *); + + if(loc_params->type == H5VL_OBJECT_BY_SELF) { /* H5Arename */ + /* Call attribute rename routine */ + if(H5O__attr_rename(loc.oloc, old_name, new_name) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTRENAME, FAIL, "can't rename attribute") + } /* end if */ + else if(loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Arename_by_name */ + /* Call attribute rename routine */ + if(H5A__rename_by_name(loc, loc_params->loc_data.loc_by_name.name, old_name, new_name) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTRENAME, FAIL, "can't rename attribute") + } /* end else-if */ + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown attribute rename parameters") + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_attr_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_attr_optional + * + * Purpose: Handles the attribute optional callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_attr_optional(void H5_ATTR_UNUSED *obj, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req, va_list arguments) +{ + H5VL_native_attr_optional_t optional_type; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + optional_type = HDva_arg(arguments, H5VL_native_attr_optional_t); + switch(optional_type) { +#ifndef H5_NO_DEPRECATED_SYMBOLS + case H5VL_NATIVE_ATTR_ITERATE_OLD: + { + hid_t loc_id = HDva_arg(arguments, hid_t); + unsigned *attr_num = HDva_arg(arguments, unsigned *); + H5A_operator1_t op = HDva_arg(arguments, H5A_operator1_t); + void *op_data = HDva_arg(arguments, void *); + + /* Call the actual iteration routine */ + if((ret_value = H5A__iterate_old(loc_id, attr_num, op, op_data)) < 0) + HERROR(H5E_VOL, H5E_BADITER, "error iterating over attributes"); + + break; + } +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + + default: + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid optional operation") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_attr_optional() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_attr_close + * + * Purpose: Handles the attribute close callback + * + * Return: Success: SUCCEED + * Failure: FAIL (attribute will not be closed) + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_attr_close(void *attr, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + if(H5A__close((H5A_t*)attr) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "can't close attribute") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_attr_close() */ + diff --git a/src/H5VLnative_dataset.c b/src/H5VLnative_dataset.c new file mode 100644 index 0000000..8f7351c --- /dev/null +++ b/src/H5VLnative_dataset.c @@ -0,0 +1,575 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * 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 COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: Dataset callbacks for the native VOL connector + * + */ + +#define H5D_FRIEND /* Suppress error about including H5Dpkg */ + +#include "H5private.h" /* Generic Functions */ +#include "H5Dpkg.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* Files */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5Sprivate.h" /* Dataspaces */ +#include "H5VLprivate.h" /* Virtual Object Layer */ + +#include "H5VLnative_private.h" /* Native VOL connector */ + + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_dataset_create + * + * Purpose: Handles the dataset create callback + * + * Return: Success: dataset pointer + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL__native_dataset_create(void *obj, const H5VL_loc_params_t *loc_params, + const char *name, hid_t dcpl_id, hid_t dapl_id, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req) +{ + H5P_genplist_t *plist; /* Property list pointer */ + H5G_loc_t loc; /* Object location to insert dataset into */ + hid_t type_id = H5I_INVALID_HID; + hid_t space_id = H5I_INVALID_HID; + hid_t lcpl_id = H5I_INVALID_HID; + H5D_t *dset = NULL; /* New dataset's info */ + const H5S_t *space; /* Dataspace for dataset */ + void *ret_value; + + FUNC_ENTER_PACKAGE + + /* Get the plist structure */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(dcpl_id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, NULL, "can't find object for ID") + + /* Get creation properties */ + if(H5P_get(plist, H5VL_PROP_DSET_TYPE_ID, &type_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for datatype id") + if(H5P_get(plist, H5VL_PROP_DSET_SPACE_ID, &space_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for space id") + if(H5P_get(plist, H5VL_PROP_DSET_LCPL_ID, &lcpl_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for lcpl id") + + /* Check arguments */ + if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") + if(H5I_DATATYPE != H5I_get_type(type_id)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a datatype ID") + if(NULL == (space = (const H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a dataspace ID") + + /* H5Dcreate_anon */ + if(NULL == name) { + /* build and open the new dataset */ + if(NULL == (dset = H5D__create(loc.oloc->file, type_id, space, dcpl_id, dapl_id))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to create dataset") + } /* end if */ + /* H5Dcreate2 */ + else { + /* Create the new dataset & get its ID */ + if(NULL == (dset = H5D__create_named(&loc, name, type_id, space, lcpl_id, dcpl_id, dapl_id))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to create dataset") + } /* end else */ + + ret_value = (void *)dset; + +done: + if(NULL == name) { + /* Release the dataset's object header, if it was created */ + if(dset) { + H5O_loc_t *oloc; /* Object location for dataset */ + + /* Get the new dataset's object location */ + if(NULL == (oloc = H5D_oloc(dset))) + HDONE_ERROR(H5E_DATASET, H5E_CANTGET, NULL, "unable to get object location of dataset") + + /* Decrement refcount on dataset's object header in memory */ + if(H5O_dec_rc_by_loc(oloc) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, NULL, "unable to decrement refcount on newly created object") + } /* end if */ + } /* end if */ + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_dataset_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_dataset_open + * + * Purpose: Handles the dataset open callback + * + * Return: Success: dataset pointer + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL__native_dataset_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, + hid_t dapl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + H5D_t *dset = NULL; + H5G_loc_t loc; /* Object location of group */ + void *ret_value = NULL; + + FUNC_ENTER_PACKAGE + + if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") + + /* Open the dataset */ + if(NULL == (dset = H5D__open_name(&loc, name, dapl_id))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, NULL, "unable to open dataset") + + ret_value = (void *)dset; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_dataset_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_dataset_read + * + * Purpose: Handles the dataset read callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_dataset_read(void *obj, hid_t mem_type_id, hid_t mem_space_id, + hid_t file_space_id, hid_t H5_ATTR_UNUSED dxpl_id, void *buf, + void H5_ATTR_UNUSED **req) +{ + H5D_t *dset = (H5D_t *)obj; + const H5S_t *mem_space = NULL; + const H5S_t *file_space = NULL; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Check arguments */ + if(NULL == dset->oloc.file) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not associated with a file") + + /* Get validated dataspace pointers */ + if(H5S_get_validated_dataspace(mem_space_id, &mem_space) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not get a validated dataspace from mem_space_id") + if(H5S_get_validated_dataspace(file_space_id, &file_space) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not get a validated dataspace from file_space_id") + + /* Read raw data */ + if(H5D__read(dset, mem_type_id, mem_space, file_space, buf/*out*/) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read data") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_dataset_read() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_dataset_write + * + * Purpose: Handles the dataset write callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_dataset_write(void *obj, hid_t mem_type_id, hid_t mem_space_id, + hid_t file_space_id, hid_t H5_ATTR_UNUSED dxpl_id, const void *buf, + void H5_ATTR_UNUSED **req) +{ + H5D_t *dset = (H5D_t *)obj; + const H5S_t *mem_space = NULL; + const H5S_t *file_space = NULL; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* check arguments */ + if(NULL == dset->oloc.file) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not associated with a file") + + /* Get validated dataspace pointers */ + if(H5S_get_validated_dataspace(mem_space_id, &mem_space) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not get a validated dataspace from mem_space_id") + if(H5S_get_validated_dataspace(file_space_id, &file_space) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not get a validated dataspace from file_space_id") + + /* Write the data */ + if(H5D__write(dset, mem_type_id, mem_space, file_space, buf) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write data") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_dataset_write() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_dataset_get + * + * Purpose: Handles the dataset get callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_dataset_get(void *obj, H5VL_dataset_get_t get_type, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +{ + H5D_t *dset = (H5D_t *)obj; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + switch(get_type) { + /* H5Dget_space */ + case H5VL_DATASET_GET_SPACE: + { + hid_t *ret_id = HDva_arg(arguments, hid_t *); + + if((*ret_id = H5D__get_space(dset)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get space ID of dataset") + + break; + } + + /* H5Dget_space_statuc */ + case H5VL_DATASET_GET_SPACE_STATUS: + { + H5D_space_status_t *allocation = HDva_arg(arguments, H5D_space_status_t *); + + /* Read data space address and return */ + if(H5D__get_space_status(dset, allocation) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to get space status") + + break; + } + + /* H5Dget_type */ + case H5VL_DATASET_GET_TYPE: + { + hid_t *ret_id = HDva_arg(arguments, hid_t *); + + if((*ret_id = H5D__get_type(dset)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get datatype ID of dataset") + + break; + } + + /* H5Dget_create_plist */ + case H5VL_DATASET_GET_DCPL: + { + hid_t *ret_id = HDva_arg(arguments, hid_t *); + + if((*ret_id = H5D_get_create_plist(dset)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get creation property list for dataset") + + break; + } + + /* H5Dget_access_plist */ + case H5VL_DATASET_GET_DAPL: + { + hid_t *ret_id = HDva_arg(arguments, hid_t *); + + if((*ret_id = H5D_get_access_plist(dset)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get access property list for dataset") + + break; + } + + /* H5Dget_storage_size */ + case H5VL_DATASET_GET_STORAGE_SIZE: + { + hsize_t *ret = HDva_arg(arguments, hsize_t *); + + /* Set return value */ + if(H5D__get_storage_size(dset, ret) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get size of dataset's storage") + break; + } + + /* H5Dget_offset */ + case H5VL_DATASET_GET_OFFSET: + { + haddr_t *ret = HDva_arg(arguments, haddr_t *); + + /* Set return value */ + *ret = H5D__get_offset(dset); + if(!H5F_addr_defined(*ret)) + *ret = HADDR_UNDEF; + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from dataset") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_dataset_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_dataset_specific + * + * Purpose: Handles the dataset specific callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_dataset_specific(void *obj, H5VL_dataset_specific_t specific_type, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +{ + H5D_t *dset = (H5D_t *)obj; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + switch(specific_type) { + /* H5Dspecific_space */ + case H5VL_DATASET_SET_EXTENT: + { + const hsize_t *size = HDva_arg(arguments, const hsize_t *); + + if(H5D__set_extent(dset, size) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to set extent of dataset") + break; + } + + case H5VL_DATASET_FLUSH: + { + hid_t dset_id = HDva_arg(arguments, hid_t); + + /* Flush the dataset */ + if(H5D__flush(dset, dset_id) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTFLUSH, FAIL, "unable to flush dataset") + + break; + } + + case H5VL_DATASET_REFRESH: + { + hid_t dset_id = HDva_arg(arguments, hid_t); + + /* Refresh the dataset */ + if((H5D__refresh(dset_id, dset)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTLOAD, FAIL, "unable to refresh dataset") + + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_dataset_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_dataset_optional + * + * Purpose: Handles the dataset optional callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_dataset_optional(void *obj, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req, va_list arguments) +{ + H5D_t *dset = NULL; /* Dataset */ + H5VL_native_dataset_optional_t optional_type = HDva_arg(arguments, H5VL_native_dataset_optional_t); + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + switch(optional_type) { + case H5VL_NATIVE_DATASET_FORMAT_CONVERT: + { + dset = (H5D_t *)obj; + + switch(dset->shared->layout.type) { + case H5D_CHUNKED: + /* Convert the chunk indexing type to version 1 B-tree if not */ + if(dset->shared->layout.u.chunk.idx_type != H5D_CHUNK_IDX_BTREE) + if((H5D__format_convert(dset)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTLOAD, FAIL, "unable to downgrade chunk indexing type for dataset") + break; + + case H5D_CONTIGUOUS: + case H5D_COMPACT: + /* Downgrade the layout version to 3 if greater than 3 */ + if(dset->shared->layout.version > H5O_LAYOUT_VERSION_DEFAULT) + if((H5D__format_convert(dset)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTLOAD, FAIL, "unable to downgrade layout version for dataset") + break; + + case H5D_VIRTUAL: + /* Nothing to do even though layout is version 4 */ + break; + + case H5D_LAYOUT_ERROR: + case H5D_NLAYOUTS: + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset layout type") + + default: + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "unknown dataset layout type") + } /* end switch */ + + break; + } + + case H5VL_NATIVE_DATASET_GET_CHUNK_INDEX_TYPE: + { + H5D_chunk_index_t *idx_type = HDva_arg(arguments, H5D_chunk_index_t *); + + dset = (H5D_t *)obj; + + /* Make sure the dataset is chunked */ + if(H5D_CHUNKED != dset->shared->layout.type) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") + + /* Get the chunk indexing type */ + *idx_type = dset->shared->layout.u.chunk.idx_type; + + break; + } + + case H5VL_NATIVE_DATASET_GET_CHUNK_STORAGE_SIZE: + { + hsize_t *offset = HDva_arg(arguments, hsize_t *); + hsize_t *chunk_nbytes = HDva_arg(arguments, hsize_t *); + + dset = (H5D_t *)obj; + + /* Make sure the dataset is chunked */ + if(H5D_CHUNKED != dset->shared->layout.type) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") + + /* Call private function */ + if(H5D__get_chunk_storage_size(dset, offset, chunk_nbytes) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get storage size of chunk") + + break; + } + + case H5VL_NATIVE_DATASET_CHUNK_READ: + { + const hsize_t *offset = HDva_arg(arguments, hsize_t *); + uint32_t *filters = HDva_arg(arguments, uint32_t *); + void *buf = HDva_arg(arguments, void *); + hsize_t offset_copy[H5O_LAYOUT_NDIMS]; /* Internal copy of chunk offset */ + + dset = (H5D_t *)obj; + + /* Check arguments */ + if(NULL == dset->oloc.file) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not associated with a file") + if(H5D_CHUNKED != dset->shared->layout.type) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") + + /* Copy the user's offset array so we can be sure it's terminated properly. + * (we don't want to mess with the user's buffer). + */ + if(H5D__get_offset_copy(dset, offset, offset_copy) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "failure to copy offset array") + + /* Read the raw chunk */ + if(H5D__chunk_direct_read(dset, offset_copy, filters, buf) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read unprocessed chunk data") + + break; + } + + case H5VL_NATIVE_DATASET_CHUNK_WRITE: + { + uint32_t filters = HDva_arg(arguments, uint32_t); + const hsize_t *offset = HDva_arg(arguments, const hsize_t *); + uint32_t data_size_32 = HDva_arg(arguments, uint32_t); + const void *buf = HDva_arg(arguments, const void *); + hsize_t offset_copy[H5O_LAYOUT_NDIMS]; /* Internal copy of chunk offset */ + + dset = (H5D_t *)obj; + + /* Check arguments */ + if(NULL == dset->oloc.file) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not associated with a file") + if(H5D_CHUNKED != dset->shared->layout.type) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") + + /* Copy the user's offset array so we can be sure it's terminated properly. + * (we don't want to mess with the user's buffer). + */ + if(H5D__get_offset_copy(dset, offset, offset_copy) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "failure to copy offset array") + + /* Write chunk */ + if(H5D__chunk_direct_write(dset, filters, offset_copy, data_size_32, buf) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write unprocessed chunk data") + + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid optional operation") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_dataset_optional() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_dataset_close + * + * Purpose: Handles the dataset close callback + * + * Return: Success: SUCCEED + * Failure: FAIL (dataset will not be closed) + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_dataset_close(void *dset, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + if(H5D_close((H5D_t*)dset) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "can't close dataset") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_dataset_close() */ + diff --git a/src/H5VLnative_datatype.c b/src/H5VLnative_datatype.c new file mode 100644 index 0000000..3c9463d --- /dev/null +++ b/src/H5VLnative_datatype.c @@ -0,0 +1,265 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * 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 COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: Datatype callbacks for the native VOL connector + * + */ + +#define H5T_FRIEND /* Suppress error about including H5Tpkg */ + +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5Tpkg.h" /* Datatypes */ +#include "H5VLprivate.h" /* Virtual Object Layer */ + +#include "H5VLnative_private.h" /* Native VOL connector */ + + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_datatype_commit + * + * Purpose: Handles the datatype commit callback + * + * Return: Success: datatype pointer + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL__native_datatype_commit(void *obj, const H5VL_loc_params_t *loc_params, const char *name, + hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t H5_ATTR_UNUSED tapl_id, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + H5G_loc_t loc; /* Location to commit datatype */ + H5T_t *dt; /* Datatype for ID */ + H5T_t *type = NULL; /* copy of the original type which will be committed */ + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* check arguments */ + if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") + + if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a datatype") + + /* Check arguments. We cannot commit an immutable type because H5Tclose() + * normally fails on such types (try H5Tclose(H5T_NATIVE_INT)) but closing + * a named type should always succeed. + */ + if(H5T_STATE_NAMED == dt->shared->state || H5T_STATE_OPEN == dt->shared->state) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "datatype is already committed") + if(H5T_STATE_IMMUTABLE == dt->shared->state) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "datatype is immutable") + + /* Check for a "sensible" datatype to store on disk */ + if(H5T_is_sensible(dt) <= 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "datatype is not sensible") + + /* Copy the datatype - the copied one will be the type that is + * committed, and attached to original datatype above the VOL + * layer + */ + if(NULL == (type = H5T_copy(dt, H5T_COPY_TRANSIENT))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to copy"); + + /* Commit the datatype */ + if(NULL != name) { + /* H5Tcommit */ + if(H5T__commit_named(&loc, name, type, lcpl_id, tcpl_id) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to commit datatype") + } /* end if */ + else { + /* H5Tcommit_anon */ + if(H5T__commit_anon(loc.oloc->file, type, tcpl_id) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to commit datatype") + } /* end else */ + + ret_value = (void *)type; + +done: + if(NULL == ret_value && type) + H5T_close(type); + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_datatype_commit() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_datatype_open + * + * Purpose: Handles the datatype open callback + * + * Return: Success: datatype pointer + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL__native_datatype_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, + hid_t H5_ATTR_UNUSED tapl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + H5T_t *type = NULL; /* Datatype opened in file */ + H5G_loc_t loc; /* Group location of object to open */ + void *ret_value = NULL; + + FUNC_ENTER_PACKAGE + + if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") + + /* Open the datatype */ + if(NULL == (type = H5T__open_name(&loc, name))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, NULL, "unable to open named datatype") + + type->vol_obj = NULL; + + ret_value = (void *)type; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_datatype_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_datatype_get + * + * Purpose: Handles the datatype get callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_datatype_get(void *obj, H5VL_datatype_get_t get_type, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +{ + H5T_t *dt = (H5T_t *)obj; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + switch (get_type) { + case H5VL_DATATYPE_GET_BINARY: + { + ssize_t *nalloc = HDva_arg(arguments, ssize_t *); + void *buf = HDva_arg(arguments, void *); + size_t size = HDva_arg(arguments, size_t); + + if(H5T_encode(dt, (unsigned char *)buf, &size) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't determine serialized length of datatype") + + *nalloc = (ssize_t) size; + break; + } + + /* H5Tget_create_plist */ + case H5VL_DATATYPE_GET_TCPL: + { + hid_t *ret_id = HDva_arg(arguments, hid_t *); + + if(H5I_INVALID_HID == (*ret_id = H5T__get_create_plist(dt))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't get object creation info"); + + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from datatype") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_datatype_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_datatype_specific + * + * Purpose: Handles the datatype specific callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_datatype_specific(void *obj, H5VL_datatype_specific_t specific_type, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +{ + H5T_t *dt = (H5T_t *)obj; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + switch(specific_type) { + case H5VL_DATATYPE_FLUSH: + { + hid_t type_id = HDva_arg(arguments, hid_t); + + /* To flush metadata and invoke flush callback if there is */ + if(H5O_flush_common(&dt->oloc, type_id) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFLUSH, FAIL, "unable to flush datatype") + + break; + } + + case H5VL_DATATYPE_REFRESH: + { + hid_t type_id = HDva_arg(arguments, hid_t); + + /* Call private function to refresh datatype object */ + if((H5O_refresh_metadata(type_id, dt->oloc)) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTLOAD, FAIL, "unable to refresh datatype") + + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_datatype_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_datatype_close + * + * Purpose: Handles the datatype close callback + * + * Return: Success: SUCCEED + * Failure: FAIL (datatype will not be closed) + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_datatype_close(void *dt, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + if(H5T_close((H5T_t*)dt) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "can't close datatype") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_datatype_close() */ + diff --git a/src/H5VLnative_file.c b/src/H5VLnative_file.c new file mode 100644 index 0000000..e7f27e1 --- /dev/null +++ b/src/H5VLnative_file.c @@ -0,0 +1,830 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * 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 COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: File callbacks for the native VOL connector + * + */ + +#define H5F_FRIEND /* Suppress error about including H5Fpkg */ + +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5Cprivate.h" /* Cache */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* Files */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5PBprivate.h" /* Page buffering */ +#include "H5VLprivate.h" /* Virtual Object Layer */ + +#include "H5VLnative_private.h" /* Native VOL connector */ + + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_file_create + * + * Purpose: Handles the file create callback + * + * Return: Success: file pointer + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL__native_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + H5F_t *new_file = NULL; + void *ret_value = NULL; + + FUNC_ENTER_PACKAGE + + /* Adjust bit flags by turning on the creation bit and making sure that + * the EXCL or TRUNC bit is set. All newly-created files are opened for + * reading and writing. + */ + if(0 == (flags & (H5F_ACC_EXCL|H5F_ACC_TRUNC))) + flags |= H5F_ACC_EXCL; /* default */ + flags |= H5F_ACC_RDWR | H5F_ACC_CREAT; + + /* Create the file */ + if(NULL == (new_file = H5F_open(name, flags, fcpl_id, fapl_id))) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to create file") + new_file->id_exists = TRUE; + + ret_value = (void *)new_file; + +done: + if(NULL == ret_value && new_file) + if(H5F__close(new_file) < 0) + HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "problems closing file") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_file_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_file_open + * + * Purpose: Handles the file open callback + * + * Return: Success: file pointer + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL__native_file_open(const char *name, unsigned flags, hid_t fapl_id, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + H5F_t *new_file = NULL; + void *ret_value = NULL; + + FUNC_ENTER_PACKAGE + + /* Open the file */ + if(NULL == (new_file = H5F_open(name, flags, H5P_FILE_CREATE_DEFAULT, fapl_id))) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file") + new_file->id_exists = TRUE; + + ret_value = (void *)new_file; + +done: + if(NULL == ret_value && new_file && H5F_try_close(new_file, NULL) < 0) + HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "problems closing file") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_file_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_file_get + * + * Purpose: Handles the file get callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_file_get(void *obj, H5VL_file_get_t get_type, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +{ + H5F_t *f = NULL; /* File struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + switch(get_type) { + /* H5Fget_access_plist */ + case H5VL_FILE_GET_FAPL: + { + H5P_genplist_t *new_plist; /* New property list */ + hid_t *plist_id = HDva_arg(arguments, hid_t *); + + f = (H5F_t *)obj; + + /* Retrieve the file's access property list */ + if((*plist_id = H5F_get_access_plist(f, TRUE)) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get file access property list") + + if(NULL == (new_plist = (H5P_genplist_t *)H5I_object(*plist_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") + break; + } + + /* H5Fget_create_plist */ + case H5VL_FILE_GET_FCPL: + { + H5P_genplist_t *plist; /* Property list */ + hid_t *plist_id = HDva_arg(arguments, hid_t *); + + f = (H5F_t *)obj; + if(NULL == (plist = (H5P_genplist_t *)H5I_object(f->shared->fcpl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") + + /* Create the property list object to return */ + if((*plist_id = H5P_copy_plist(plist, TRUE)) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "unable to copy file creation properties") + + break; + } + + /* H5Fget_obj_count */ + case H5VL_FILE_GET_OBJ_COUNT: + { + unsigned types = HDva_arg(arguments, unsigned); + ssize_t *ret = HDva_arg(arguments, ssize_t *); + size_t obj_count = 0; /* Number of opened objects */ + + f = (H5F_t *)obj; + /* Perform the query */ + if(H5F_get_obj_count(f, types, TRUE, &obj_count) < 0) + HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "H5F_get_obj_count failed") + + /* Set the return value */ + *ret = (ssize_t)obj_count; + break; + } + + /* H5Fget_obj_ids */ + case H5VL_FILE_GET_OBJ_IDS: + { + unsigned types = HDva_arg(arguments, unsigned); + size_t max_objs = HDva_arg(arguments, size_t); + hid_t *oid_list = HDva_arg(arguments, hid_t *); + ssize_t *ret = HDva_arg(arguments, ssize_t *); + size_t obj_count = 0; /* Number of opened objects */ + + f = (H5F_t *)obj; + /* Perform the query */ + if(H5F_get_obj_ids(f, types, max_objs, oid_list, TRUE, &obj_count) < 0) + HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "H5F_get_obj_ids failed") + + /* Set the return value */ + *ret = (ssize_t)obj_count; + break; + } + + /* H5Fget_intent */ + case H5VL_FILE_GET_INTENT: + { + unsigned *intent_flags = HDva_arg(arguments, unsigned *); + + f = (H5F_t *)obj; + + /* HDF5 uses some flags internally that users don't know about. + * Simplify things for them so that they only get either H5F_ACC_RDWR + * or H5F_ACC_RDONLY and any SWMR flags. + */ + if(H5F_INTENT(f) & H5F_ACC_RDWR) { + *intent_flags = H5F_ACC_RDWR; + + /* Check for SWMR write access on the file */ + if(H5F_INTENT(f) & H5F_ACC_SWMR_WRITE) + *intent_flags |= H5F_ACC_SWMR_WRITE; + } /* end if */ + else { + *intent_flags = H5F_ACC_RDONLY; + + /* Check for SWMR read access on the file */ + if(H5F_INTENT(f) & H5F_ACC_SWMR_READ) + *intent_flags |= H5F_ACC_SWMR_READ; + } /* end else */ + + break; + } + + /* H5Fget_name */ + case H5VL_FILE_GET_NAME: + { + H5I_type_t type = (H5I_type_t)HDva_arg(arguments, int); /* enum work-around */ + size_t size = HDva_arg(arguments, size_t); + char *name = HDva_arg(arguments, char *); + ssize_t *ret = HDva_arg(arguments, ssize_t *); + size_t len; + + if(NULL == (f = H5F__get_file(obj, type))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + len = HDstrlen(H5F_OPEN_NAME(f)); + + if(name) { + HDstrncpy(name, H5F_OPEN_NAME(f), MIN(len + 1,size)); + if(len >= size) + name[size-1]='\0'; + } /* end if */ + + /* Set the return value for the API call */ + *ret = (ssize_t)len; + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_file_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_file_specific + * + * Purpose: Handles the file specific callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_file_specific(void *obj, H5VL_file_specific_t specific_type, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + switch(specific_type) { + /* H5Fflush */ + case H5VL_FILE_FLUSH: + { + H5I_type_t type = (H5I_type_t)HDva_arg(arguments, int); /* enum work-around */ + H5F_scope_t scope = (H5F_scope_t)HDva_arg(arguments, int); /* enum work-around */ + H5F_t *f = NULL; /* File to flush */ + + /* Get the file for the object */ + if(NULL == (f = H5F__get_file(obj, type))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Nothing to do if the file is read only. This determination is + * made at the shared open(2) flags level, implying that opening a + * file twice, once for read-only and once for read-write, and then + * calling H5Fflush() with the read-only handle, still causes data + * to be flushed. + */ + if(H5F_ACC_RDWR & H5F_INTENT(f)) { + /* Flush other files, depending on scope */ + if(H5F_SCOPE_GLOBAL == scope) { + /* Call the flush routine for mounted file hierarchies */ + if(H5F_flush_mounts(f) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush mounted file hierarchy") + } /* end if */ + else { + /* Call the flush routine, for this file */ + if(H5F__flush(f) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush file's cached information") + } /* end else */ + } /* end if */ + break; + } + + /* H5Freopen */ + case H5VL_FILE_REOPEN: + { + void **ret = HDva_arg(arguments, void **); + H5F_t *new_file = NULL; + + /* Reopen the file through the VOL connector */ + if(NULL == (new_file = H5F__reopen((H5F_t *)obj))) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to reopen file") + new_file->id_exists = TRUE; + + *ret = (void *)new_file; + break; + } + + /* H5Fmount */ + case H5VL_FILE_MOUNT: + { + H5I_type_t type = (H5I_type_t)HDva_arg(arguments, int); /* enum work-around */ + const char *name = HDva_arg(arguments, const char *); + H5F_t *child = HDva_arg(arguments, H5F_t *); + hid_t plist_id = HDva_arg(arguments, hid_t); + H5G_loc_t loc; + + if(H5G_loc_real(obj, type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Do the mount */ + if(H5F__mount(&loc, name, child, plist_id) < 0) + HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to mount file") + + break; + } + + /* H5Funmount */ + case H5VL_FILE_UNMOUNT: + { + H5I_type_t type = (H5I_type_t)HDva_arg(arguments, int); /* enum work-around */ + const char *name = HDva_arg(arguments, const char *); + H5G_loc_t loc; + + if(H5G_loc_real(obj, type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Unmount */ + if(H5F__unmount(&loc, name) < 0) + HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to unmount file") + + break; + } + + /* H5Fis_accessible */ + case H5VL_FILE_IS_ACCESSIBLE: + { + hid_t fapl_id = HDva_arg(arguments, hid_t); + const char *name = HDva_arg(arguments, const char *); + htri_t *ret = HDva_arg(arguments, htri_t *); + + /* Call private routine */ + if((*ret = H5F__is_hdf5(name, fapl_id)) < 0) + HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "error in HDF5 file check") + break; + } + + + + default: + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_file_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_file_optional + * + * Purpose: Handles the file optional callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_file_optional(void *obj, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +{ + H5F_t *f = NULL; /* File */ + H5VL_native_file_optional_t optional_type = HDva_arg(arguments, H5VL_native_file_optional_t); + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + f = (H5F_t *)obj; + switch(optional_type) { + /* H5Fget_filesize */ + case H5VL_NATIVE_FILE_GET_SIZE: + { + haddr_t max_eof_eoa; /* Maximum of the EOA & EOF */ + haddr_t base_addr; /* Base address for the file */ + hsize_t *size = HDva_arg(arguments, hsize_t *); + + /* Go get the actual file size */ + if(H5F__get_max_eof_eoa(f, &max_eof_eoa) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "file can't get max eof/eoa ") + + base_addr = H5FD_get_base_addr(f->shared->lf); + + if(size) + *size = (hsize_t)(max_eof_eoa + base_addr); /* Convert relative base address for file to absolute address */ + + break; + } + + /* H5Fget_file_image */ + case H5VL_NATIVE_FILE_GET_FILE_IMAGE: + { + void *buf_ptr = HDva_arg(arguments, void *); + ssize_t *ret = HDva_arg(arguments, ssize_t *); + size_t buf_len = HDva_arg(arguments, size_t ); + + /* Do the actual work */ + if((*ret = H5F__get_file_image(f, buf_ptr, buf_len)) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "get file image failed") + break; + } + + /* H5Fget_freespace */ + case H5VL_NATIVE_FILE_GET_FREE_SPACE: + { + hsize_t tot_space; /* Amount of free space in the file */ + hssize_t *ret = HDva_arg(arguments, hssize_t *); + + /* Go get the actual amount of free space in the file */ + if(H5MF_get_freespace(f, &tot_space, NULL) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to check free space for file") + *ret = (hssize_t)tot_space; + break; + } + + /* H5Fget_free_sections */ + case H5VL_NATIVE_FILE_GET_FREE_SECTIONS: + { + H5F_sect_info_t *sect_info = HDva_arg(arguments, H5F_sect_info_t *); + ssize_t *ret = HDva_arg(arguments, ssize_t *); + H5F_mem_t type = (H5F_mem_t)HDva_arg(arguments, int); /* enum work-around */ + size_t nsects = HDva_arg(arguments, size_t); + + /* Go get the free-space section information in the file */ + if((*ret = H5MF_get_free_sections(f, type, nsects, sect_info)) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to check free space for file") + break; + } + + /* H5Fget_info1/2 */ + case H5VL_NATIVE_FILE_GET_INFO: + { + H5I_type_t type = (H5I_type_t)HDva_arg(arguments, int); /* enum work-around */ + H5F_info2_t *finfo = HDva_arg(arguments, H5F_info2_t *); + + /* Get the file struct. This call is careful to not return the file pointer + * for the top file in a mount hierarchy. + */ + if(NULL == (f = H5F__get_file(obj, type))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "could not get a file struct") + + /* Get the file info */ + if(H5F__get_info(f, finfo) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to retrieve file info") + + break; + } + + /* H5Fget_mdc_config */ + case H5VL_NATIVE_FILE_GET_MDC_CONF: + { + H5AC_cache_config_t *config_ptr = HDva_arg(arguments, H5AC_cache_config_t *); + + /* Go get the resize configuration */ + if(H5AC_get_cache_auto_resize_config(f->shared->cache, config_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC_get_cache_auto_resize_config() failed.") + break; + } + + /* H5Fget_mdc_hit_rate */ + case H5VL_NATIVE_FILE_GET_MDC_HR: + { + double *hit_rate_ptr = HDva_arg(arguments, double *); + + /* Go get the current hit rate */ + if(H5AC_get_cache_hit_rate(f->shared->cache, hit_rate_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC_get_cache_hit_rate() failed.") + break; + } + + /* H5Fget_mdc_size */ + case H5VL_NATIVE_FILE_GET_MDC_SIZE: + { + size_t *max_size_ptr = HDva_arg(arguments, size_t *); + size_t *min_clean_size_ptr = HDva_arg(arguments, size_t *); + size_t *cur_size_ptr = HDva_arg(arguments, size_t *); + int *cur_num_entries_ptr = HDva_arg(arguments, int *); + uint32_t cur_num_entries; + + /* Go get the size data */ + if(H5AC_get_cache_size(f->shared->cache, max_size_ptr, min_clean_size_ptr, + cur_size_ptr, &cur_num_entries) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC_get_cache_size() failed.") + + if(cur_num_entries_ptr != NULL) + *cur_num_entries_ptr = (int)cur_num_entries; + break; + } + + /* H5Fget_vfd_handle */ + case H5VL_NATIVE_FILE_GET_VFD_HANDLE: + { + void **file_handle = HDva_arg(arguments, void **); + hid_t fapl_id = HDva_arg(arguments, hid_t); + + /* Retrieve the VFD handle for the file */ + if(H5F_get_vfd_handle(f, fapl_id, file_handle) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve VFD handle") + break; + } + + /* H5Iget_file_id */ + case H5VL_NATIVE_FILE_GET_FILE_ID: + { + H5I_type_t type = (H5I_type_t)HDva_arg(arguments, int); /* enum work-around */ + hid_t *file_id = HDva_arg(arguments, hid_t *); + + if(NULL == (f = H5F__get_file(obj, type))) + HGOTO_ERROR(H5E_FILE, H5E_BADTYPE, FAIL, "not a file or file object") + if((*file_id = H5F__get_file_id(f)) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get file ID") + break; + } + + /* H5Fclear_elink_file_cache */ + case H5VL_NATIVE_FILE_CLEAR_ELINK_CACHE: + { + /* Release the EFC */ + if(f->shared->efc) + if(H5F__efc_release(f->shared->efc) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't release external file cache") + break; + } + + /* H5Freset_mdc_hit_rate_stats */ + case H5VL_NATIVE_FILE_RESET_MDC_HIT_RATE: + { + /* Reset the hit rate statistic */ + if(H5AC_reset_cache_hit_rate_stats(f->shared->cache) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "can't reset cache hit rate") + break; + } + + /* H5Fset_mdc_config */ + case H5VL_NATIVE_FILE_SET_MDC_CONFIG: + { + H5AC_cache_config_t *config_ptr = HDva_arg(arguments, H5AC_cache_config_t *); + + /* set the resize configuration */ + if(H5AC_set_cache_auto_resize_config(f->shared->cache, config_ptr) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "H5AC_set_cache_auto_resize_config() failed") + break; + } + + /* H5Fget_metadata_read_retry_info */ + case H5VL_NATIVE_FILE_GET_METADATA_READ_RETRY_INFO: + { + H5F_retry_info_t *info = HDva_arg(arguments, H5F_retry_info_t *); + + if(H5F_get_metadata_read_retry_info(f, info) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "can't get metadata read retry info") + + break; + } + + /* H5Fstart_swmr_write */ + case H5VL_NATIVE_FILE_START_SWMR_WRITE: + { + if(H5F__start_swmr_write(f) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "can't start SWMR write") + + break; + } + + /* H5Fstart_mdc_logging */ + case H5VL_NATIVE_FILE_START_MDC_LOGGING: + { + /* Call mdc logging function */ + if(H5C_start_logging(f->shared->cache) < 0) + HGOTO_ERROR(H5E_FILE, H5E_LOGGING, FAIL, "unable to start mdc logging") + + break; + } + + /* H5Fstop_mdc_logging */ + case H5VL_NATIVE_FILE_STOP_MDC_LOGGING: + { + /* Call mdc logging function */ + if(H5C_stop_logging(f->shared->cache) < 0) + HGOTO_ERROR(H5E_FILE, H5E_LOGGING, FAIL, "unable to stop mdc logging") + + break; + } + + /* H5Fget_mdc_logging_status */ + case H5VL_NATIVE_FILE_GET_MDC_LOGGING_STATUS: + { + hbool_t *is_enabled = HDva_arg(arguments, hbool_t *); + hbool_t *is_currently_logging = HDva_arg(arguments, hbool_t *); + + /* Call mdc logging function */ + if(H5C_get_logging_status(f->shared->cache, is_enabled, is_currently_logging) < 0) + HGOTO_ERROR(H5E_FILE, H5E_LOGGING, FAIL, "unable to get logging status") + + break; + } + + /* H5Fformat_convert */ + case H5VL_NATIVE_FILE_FORMAT_CONVERT: + { + /* Convert the format */ + if(H5F__format_convert(f) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTCONVERT, FAIL, "can't convert file format") + + break; + } + + /* H5Freset_page_buffering_stats */ + case H5VL_NATIVE_FILE_RESET_PAGE_BUFFERING_STATS: + { + /* Sanity check */ + if(NULL == f->shared->page_buf) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "page buffering not enabled on file") + + /* Reset the statistics */ + if(H5PB_reset_stats(f->shared->page_buf) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't reset stats for page buffering") + + break; + } + + /* H5Fget_page_buffering_stats */ + case H5VL_NATIVE_FILE_GET_PAGE_BUFFERING_STATS: + { + unsigned *accesses = HDva_arg(arguments, unsigned *); + unsigned *hits = HDva_arg(arguments, unsigned *); + unsigned *misses = HDva_arg(arguments, unsigned *); + unsigned *evictions = HDva_arg(arguments, unsigned *); + unsigned *bypasses = HDva_arg(arguments, unsigned *); + + /* Sanity check */ + if(NULL == f->shared->page_buf) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "page buffering not enabled on file") + + /* Get the statistics */ + if(H5PB_get_stats(f->shared->page_buf, accesses, hits, misses, evictions, bypasses) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve stats for page buffering") + + break; + } + + /* H5Fget_mdc_image_info */ + case H5VL_NATIVE_FILE_GET_MDC_IMAGE_INFO: + { + haddr_t *image_addr = HDva_arg(arguments, haddr_t *); + hsize_t *image_len = HDva_arg(arguments, hsize_t *); + + /* Go get the address and size of the cache image */ + if(H5AC_get_mdc_image_info(f->shared->cache, image_addr, image_len) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve cache image info") + + break; + } + + /* H5Fget_eoa */ + case H5VL_NATIVE_FILE_GET_EOA: + { + haddr_t *eoa = HDva_arg(arguments, haddr_t *); + haddr_t rel_eoa; /* Relative address of EOA */ + + /* Sanity check */ + HDassert(eoa); + + /* This routine will work only for drivers with this feature enabled.*/ + /* We might introduce a new feature flag in the future */ + if(!H5F_HAS_FEATURE(f, H5FD_FEAT_SUPPORTS_SWMR_IO)) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "must use a SWMR-compatible VFD for this public routine") + + /* The real work */ + if(HADDR_UNDEF == (rel_eoa = H5F_get_eoa(f, H5FD_MEM_DEFAULT))) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "get_eoa request failed") + + /* Set return value */ + /* (Note compensating for base address subtraction in internal routine) */ + *eoa = rel_eoa + H5F_get_base_addr(f); + + break; + } + + /* H5Fincrement_filesize */ + case H5VL_NATIVE_FILE_INCR_FILESIZE: + { + hsize_t increment = HDva_arg(arguments, hsize_t); + haddr_t max_eof_eoa; /* Maximum of the relative EOA & EOF */ + + /* This public routine will work only for drivers with this feature enabled.*/ + /* We might introduce a new feature flag in the future */ + if(!H5F_HAS_FEATURE(f, H5FD_FEAT_SUPPORTS_SWMR_IO)) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "must use a SWMR-compatible VFD for this public routine") + + /* Get the maximum of EOA and EOF */ + if(H5F__get_max_eof_eoa(f, &max_eof_eoa) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "file can't get max eof/eoa ") + + /* Set EOA to the maximum value + increment */ + if(H5F__set_eoa(f, H5FD_MEM_DEFAULT, max_eof_eoa + increment) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "driver set_eoa request failed") + + break; + } + + /* H5Fset_latest_format, H5Fset_libver_bounds */ + case H5VL_NATIVE_FILE_SET_LIBVER_BOUNDS: + { + H5F_libver_t low = (H5F_libver_t)HDva_arg(arguments, int); /* enum work-around */ + H5F_libver_t high = (H5F_libver_t)HDva_arg(arguments, int); /* enum work-around */ + + /* Call internal set_libver_bounds function */ + if(H5F__set_libver_bounds(f, low, high) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "cannot set low/high bounds") + + break; + } + + /* H5Fget_dset_no_attrs_hint */ + case H5VL_NATIVE_FILE_GET_MIN_DSET_OHDR_FLAG: + { + hbool_t *minimize = va_arg(arguments, hbool_t *); + *minimize = H5F_GET_MIN_DSET_OHDR(f); + break; + } + + /* H5Fset_dset_no_attrs_hint */ + case H5VL_NATIVE_FILE_SET_MIN_DSET_OHDR_FLAG: + { + int minimize = va_arg(arguments, int); + if(H5F_set_min_dset_ohdr(f, (hbool_t)minimize) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "cannot set file's dataset object header minimization flag") + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid optional operation") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_file_optional() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_file_close + * + * Purpose: Handles the file close callback + * + * Return: Success: SUCCEED + * Failure: FAIL (file will not be closed) + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_file_close(void *file, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req) +{ + int nref; + H5F_t *f = (H5F_t *)file; + hid_t file_id = H5I_INVALID_HID; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* This routine should only be called when a file ID's ref count drops to zero */ + HDassert(H5F_ID_EXISTS(f)); + + /* Flush file if this is the last reference to this id and we have write + * intent, unless it will be flushed by the "shared" file being closed. + * This is only necessary to replicate previous behaviour, and could be + * disabled by an option/property to improve performance. + */ + if((H5F_NREFS(f) > 1) && (H5F_INTENT(f) & H5F_ACC_RDWR)) { + /* Get the file ID corresponding to the H5F_t struct */ + if(H5I_find_id(f, H5I_FILE, &file_id) < 0 || H5I_INVALID_HID == file_id) + HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "invalid atom") + + /* Get the number of references outstanding for this file ID */ + if((nref = H5I_get_ref(file_id, FALSE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't get ID ref count") + if(nref == 1) + if(H5F__flush(f) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush cache") + } /* end if */ + + /* Close the file */ + if(H5F__close(f) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "can't close file") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_file_close() */ + diff --git a/src/H5VLnative_group.c b/src/H5VLnative_group.c new file mode 100644 index 0000000..9c07b3d --- /dev/null +++ b/src/H5VLnative_group.c @@ -0,0 +1,363 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * 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 COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: Group callbacks for the native VOL connector + * + */ + +#define H5G_FRIEND /* Suppress error about including H5Gpkg */ + +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Gpkg.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5VLprivate.h" /* Virtual Object Layer */ + +#include "H5VLnative_private.h" /* Native VOL connector */ + + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_group_create + * + * Purpose: Handles the group create callback + * + * Return: Success: group pointer + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL__native_group_create(void *obj, const H5VL_loc_params_t *loc_params, const char *name, + hid_t gcpl_id, hid_t H5_ATTR_UNUSED gapl_id, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req) +{ + H5P_genplist_t *plist; /* Property list pointer */ + H5G_loc_t loc; /* Location to create group */ + H5G_t *grp = NULL; /* New group created */ + hid_t lcpl_id; + void *ret_value; + + FUNC_ENTER_PACKAGE + + /* Get the property list structure */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(gcpl_id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, NULL, "can't find object for ID") + + /* Get creation properties */ + if(H5P_get(plist, H5VL_PROP_GRP_LCPL_ID, &lcpl_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for lcpl id") + + /* Set up the location */ + if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") + + /* if name is NULL then this is from H5Gcreate_anon */ + if(name == NULL) { + H5G_obj_create_t gcrt_info; /* Information for group creation */ + + /* Set up group creation info */ + gcrt_info.gcpl_id = gcpl_id; + gcrt_info.cache_type = H5G_NOTHING_CACHED; + HDmemset(&gcrt_info.cache, 0, sizeof(gcrt_info.cache)); + + /* Create the new group & get its ID */ + if(NULL == (grp = H5G__create(loc.oloc->file, &gcrt_info))) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "unable to create group") + } /* end if */ + /* otherwise it's from H5Gcreate */ + else { + /* Create the new group & get its ID */ + if(NULL == (grp = H5G__create_named(&loc, name, lcpl_id, gcpl_id))) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "unable to create group") + } /* end else */ + + ret_value = (void *)grp; + +done: + if(name == NULL) { + /* Release the group's object header, if it was created */ + if(grp) { + H5O_loc_t *oloc; /* Object location for group */ + + /* Get the new group's object location */ + if(NULL == (oloc = H5G_oloc(grp))) + HDONE_ERROR(H5E_SYM, H5E_CANTGET, NULL, "unable to get object location of group") + + /* Decrement refcount on group's object header in memory */ + if(H5O_dec_rc_by_loc(oloc) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTDEC, NULL, "unable to decrement refcount on newly created object") + } /* end if */ + } /* end if */ + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_group_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_group_open + * + * Purpose: Handles the group open callback + * + * Return: Success: group pointer + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL__native_group_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, + hid_t H5_ATTR_UNUSED gapl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + H5G_loc_t loc; /* Location to open group */ + H5G_t *grp = NULL; /* New group opend */ + void *ret_value; + + FUNC_ENTER_PACKAGE + + /* Set up the location */ + if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") + + /* Open the group */ + if((grp = H5G__open_name(&loc, name)) == NULL) + HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, NULL, "unable to open group") + + ret_value = (void *)grp; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_group_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_group_get + * + * Purpose: Handles the group get callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_group_get(void *obj, H5VL_group_get_t get_type, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + switch(get_type) { + /* H5Gget_create_plist */ + case H5VL_GROUP_GET_GCPL: + { + hid_t *new_gcpl_id = HDva_arg(arguments, hid_t *); + H5G_t *grp = (H5G_t *)obj; + + if((*new_gcpl_id = H5G_get_create_plist(grp)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get creation property list for group") + break; + } + + /* H5Gget_info */ + case H5VL_GROUP_GET_INFO: + { + const H5VL_loc_params_t *loc_params = HDva_arg(arguments, const H5VL_loc_params_t *); + H5G_info_t *group_info = HDva_arg(arguments, H5G_info_t *); + H5G_loc_t loc; + + if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + if(loc_params->type == H5VL_OBJECT_BY_SELF) { + /* H5Gget_info */ + + /* Retrieve the group's information */ + if(H5G__obj_info(loc.oloc, group_info) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") + } /* end if */ + else if(loc_params->type == H5VL_OBJECT_BY_NAME) { + /* H5Gget_info_by_name */ + + /* Retrieve the group's information */ + if(H5G__get_info_by_name(&loc, loc_params->loc_data.loc_by_name.name, group_info) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") + } /* end else-if */ + else if(loc_params->type == H5VL_OBJECT_BY_IDX) { + /* H5Gget_info_by_idx */ + + /* Retrieve the group's information */ + if(H5G__get_info_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, loc_params->loc_data.loc_by_idx.idx_type, + loc_params->loc_data.loc_by_idx.order, loc_params->loc_data.loc_by_idx.n, group_info) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") + } /* end else-if */ + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown get info parameters") + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from group") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_group_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_group_specific + * + * Purpose: Handles the group specific callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_group_specific(void *obj, H5VL_group_specific_t specific_type, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +{ + H5G_t *grp = (H5G_t *)obj; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + switch(specific_type) { + case H5VL_GROUP_FLUSH: + { + hid_t group_id = HDva_arg(arguments, hid_t); + + /* Flush object's metadata to file */ + if(H5O_flush_common(&grp->oloc, group_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTFLUSH, FAIL, "unable to flush group") + + break; + } + + case H5VL_GROUP_REFRESH: + { + hid_t group_id = HDva_arg(arguments, hid_t); + + /* Call private function to refresh group object */ + if((H5O_refresh_metadata(group_id, grp->oloc)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, FAIL, "unable to refresh group") + + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_group_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_group_optional + * + * Purpose: Handles the group optional callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_group_optional(void *obj, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req, va_list arguments) +{ + H5VL_native_group_optional_t optional_type; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + optional_type = HDva_arg(arguments, H5VL_native_group_optional_t); + switch(optional_type) { +#ifndef H5_NO_DEPRECATED_SYMBOLS + /* H5Giterate (deprecated) */ + case H5VL_NATIVE_GROUP_ITERATE_OLD: + { + const H5VL_loc_params_t *loc_params = HDva_arg(arguments, const H5VL_loc_params_t *); + hsize_t idx = HDva_arg(arguments, hsize_t); + hsize_t *last_obj = HDva_arg(arguments, hsize_t *); + const H5G_link_iterate_t *lnk_op = HDva_arg(arguments, const H5G_link_iterate_t *); + void *op_data = HDva_arg(arguments, void *); + H5G_loc_t grp_loc; + + /* Get the location struct for the object */ + if(H5G_loc_real(obj, loc_params->obj_type, &grp_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Call the actual iteration routine */ + if((ret_value = H5G_iterate(&grp_loc, loc_params->loc_data.loc_by_name.name, H5_INDEX_NAME, H5_ITER_INC, idx, last_obj, lnk_op, op_data)) < 0) + HERROR(H5E_VOL, H5E_BADITER, "error iterating over group's links"); + + break; + } + + /* H5Gget_objinfo (deprecated) */ + case H5VL_NATIVE_GROUP_GET_OBJINFO: + { + const H5VL_loc_params_t *loc_params = HDva_arg(arguments, const H5VL_loc_params_t *); + hbool_t follow_link = (hbool_t)HDva_arg(arguments, unsigned); + H5G_stat_t *statbuf = HDva_arg(arguments, H5G_stat_t *); + H5G_loc_t grp_loc; + + /* Get the location struct for the object */ + if(H5G_loc_real(obj, loc_params->obj_type, &grp_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Call the actual group objinfo routine */ + if(H5G__get_objinfo(&grp_loc, loc_params->loc_data.loc_by_name.name, follow_link, statbuf) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "cannot stat object") + + break; + } +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + + default: + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid optional operation") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_group_optional() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_group_close + * + * Purpose: Handles the group close callback + * + * Return: Success: SUCCEED + * Failure: FAIL (group will not be closed) + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_group_close(void *grp, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + if(H5G_close((H5G_t *)grp) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close group") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_group_close() */ + diff --git a/src/H5VLnative_link.c b/src/H5VLnative_link.c new file mode 100644 index 0000000..98d2ccd --- /dev/null +++ b/src/H5VLnative_link.c @@ -0,0 +1,435 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * 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 COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: Link callbacks for the native VOL connector + * + */ + +#define H5L_FRIEND /* Suppress error about including H5Lpkg */ + +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Lpkg.h" /* Links */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5VLprivate.h" /* Virtual Object Layer */ + +#include "H5VLnative_private.h" /* Native VOL connector */ + + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_link_create + * + * Purpose: Handles the link create callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_link_create(H5VL_link_create_type_t create_type, void *obj, + const H5VL_loc_params_t *loc_params, hid_t lcpl_id, hid_t H5_ATTR_UNUSED lapl_id, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Get the plist structure */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(lcpl_id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); + + switch(create_type) { + case H5VL_LINK_CREATE_HARD: + { + H5G_loc_t cur_loc; + H5G_loc_t link_loc; + void *cur_obj; + H5VL_loc_params_t cur_params; + + if(H5P_get(plist, H5VL_PROP_LINK_TARGET, &cur_obj) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for current location id") + if(H5P_get(plist, H5VL_PROP_LINK_TARGET_LOC_PARAMS, &cur_params) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for current name") + + if(NULL != cur_obj && H5G_loc_real(cur_obj, cur_params.obj_type, &cur_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + if(NULL != obj && H5G_loc_real(obj, loc_params->obj_type, &link_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* H5Lcreate_hard */ + if(H5VL_OBJECT_BY_NAME == cur_params.type) { + H5G_loc_t *cur_loc_p, *link_loc_p; + + /* Set up current & new location pointers */ + cur_loc_p = &cur_loc; + link_loc_p = &link_loc; + if(NULL == cur_obj) + cur_loc_p = link_loc_p; + else if(NULL == obj) + link_loc_p = cur_loc_p; + else if(cur_loc_p->oloc->file != link_loc_p->oloc->file) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "source and destination should be in the same file.") + + /* Create the link */ + if((ret_value = H5L_create_hard(cur_loc_p, cur_params.loc_data.loc_by_name.name, + link_loc_p, loc_params->loc_data.loc_by_name.name, lcpl_id)) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") + } /* end if */ + else { /* H5Olink */ + /* Link to the object */ + if(H5L_link(&link_loc, loc_params->loc_data.loc_by_name.name, &cur_loc, lcpl_id) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to create link") + } /* end else */ + break; + } + + case H5VL_LINK_CREATE_SOFT: + { + char *target_name; + H5G_loc_t link_loc; /* Group location for new link */ + + if(H5G_loc_real(obj, loc_params->obj_type, &link_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + if(H5P_get(plist, H5VL_PROP_LINK_TARGET_NAME, &target_name) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for targe name") + + /* Create the link */ + if((ret_value = H5L_create_soft(target_name, &link_loc, loc_params->loc_data.loc_by_name.name, lcpl_id)) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") + break; + } + + case H5VL_LINK_CREATE_UD: + { + H5G_loc_t link_loc; /* Group location for new link */ + H5L_type_t link_type; + void *udata; + size_t udata_size; + + if(H5G_loc_real(obj, loc_params->obj_type, &link_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + if(H5P_get(plist, H5VL_PROP_LINK_TYPE, &link_type) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for link type") + if(H5P_get(plist, H5VL_PROP_LINK_UDATA, &udata) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for udata") + if(H5P_get(plist, H5VL_PROP_LINK_UDATA_SIZE, &udata_size) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for udata size") + + /* Create link */ + if(H5L__create_ud(&link_loc, loc_params->loc_data.loc_by_name.name, udata, udata_size, + link_type, lcpl_id) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") + break; + } + + default: + HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "invalid link creation call") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_link_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_link_copy + * + * Purpose: Handles the link copy callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_link_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, + void *dst_obj, const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, + hid_t H5_ATTR_UNUSED lapl_id, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req) +{ + H5G_loc_t src_loc, *src_loc_p; + H5G_loc_t dst_loc, *dst_loc_p; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + if(NULL != src_obj && H5G_loc_real(src_obj, loc_params1->obj_type, &src_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + if(NULL != dst_obj && H5G_loc_real(dst_obj, loc_params2->obj_type, &dst_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Set up src & dst location pointers */ + src_loc_p = &src_loc; + dst_loc_p = &dst_loc; + if(NULL == src_obj) + src_loc_p = dst_loc_p; + else if(NULL == dst_obj) + dst_loc_p = src_loc_p; + + /* Copy the link */ + if(H5L_move(src_loc_p, loc_params1->loc_data.loc_by_name.name, + dst_loc_p, loc_params2->loc_data.loc_by_name.name, + TRUE, lcpl_id) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTCOPY, FAIL, "unable to copy link") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_link_copy() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_link_move + * + * Purpose: Handles the link move callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_link_move(void *src_obj, const H5VL_loc_params_t *loc_params1, + void *dst_obj, const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, + hid_t H5_ATTR_UNUSED lapl_id, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req) +{ + H5G_loc_t src_loc, *src_loc_p; + H5G_loc_t dst_loc, *dst_loc_p; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + if(NULL != src_obj && H5G_loc_real(src_obj, loc_params1->obj_type, &src_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + if(NULL != dst_obj && H5G_loc_real(dst_obj, loc_params2->obj_type, &dst_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Set up src & dst location pointers */ + src_loc_p = &src_loc; + dst_loc_p = &dst_loc; + if(NULL == src_obj) + src_loc_p = dst_loc_p; + else if(NULL == dst_obj) + dst_loc_p = src_loc_p; + + /* Move the link */ + if(H5L_move(src_loc_p, loc_params1->loc_data.loc_by_name.name, + dst_loc_p, loc_params2->loc_data.loc_by_name.name, + FALSE, lcpl_id) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTMOVE, FAIL, "unable to move link") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_link_move() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_link_get + * + * Purpose: Handles the link get callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_link_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_get_t get_type, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +{ + H5G_loc_t loc; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + switch(get_type) { + /* H5Lget_info/H5Lget_info_by_idx */ + case H5VL_LINK_GET_INFO: + { + H5L_info_t *linfo = HDva_arg(arguments, H5L_info_t *); + + /* Get the link information */ + if(loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Lget_info */ + if(H5L_get_info(&loc, loc_params->loc_data.loc_by_name.name, linfo) < 0) + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link info") + } /* end if */ + else if(loc_params->type == H5VL_OBJECT_BY_IDX) { /* H5Lget_info_by_idx */ + if(H5L_get_info_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, loc_params->loc_data.loc_by_idx.idx_type, + loc_params->loc_data.loc_by_idx.order, loc_params->loc_data.loc_by_idx.n, linfo) < 0) + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link info") + } /* end else-if */ + else + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link info") + break; + } + + /* H5Lget_name_by_idx */ + case H5VL_LINK_GET_NAME: + { + char *name = HDva_arg(arguments, char *); + size_t size = HDva_arg(arguments, size_t); + ssize_t *ret = HDva_arg(arguments, ssize_t *); + + /* Get the link name */ + if((*ret = H5L_get_name_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, loc_params->loc_data.loc_by_idx.idx_type, + loc_params->loc_data.loc_by_idx.order, loc_params->loc_data.loc_by_idx.n, name, size)) < 0) + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link info") + + break; + } + + /* H5Lget_val/H5Lget_val_by_idx */ + case H5VL_LINK_GET_VAL: + { + void *buf = HDva_arg(arguments, void *); + size_t size = HDva_arg(arguments, size_t); + + /* Get the link information */ + if(loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Lget_val */ + if(H5L_get_val(&loc, loc_params->loc_data.loc_by_name.name, buf, size) < 0) + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link value") + } + else if(loc_params->type == H5VL_OBJECT_BY_IDX) { /* H5Lget_val_by_idx */ + + if(H5L_get_val_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, loc_params->loc_data.loc_by_idx.idx_type, + loc_params->loc_data.loc_by_idx.order, loc_params->loc_data.loc_by_idx.n, buf, size) < 0) + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link val") + } + else + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link val") + + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from link") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_link_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_link_specific + * + * Purpose: Handles the link specific callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_link_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_specific_t specific_type, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + switch(specific_type) { + case H5VL_LINK_EXISTS: + { + htri_t *ret = HDva_arg(arguments, htri_t *); + H5G_loc_t loc; + + if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Check for the existence of the link */ + if((*ret = H5L_exists(&loc, loc_params->loc_data.loc_by_name.name)) < 0) + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to specific link info") + break; + } + + case H5VL_LINK_ITER: + { + H5G_loc_t loc; + hbool_t recursive = (hbool_t)HDva_arg(arguments, unsigned); + H5_index_t idx_type = (H5_index_t)HDva_arg(arguments, int); /* enum work-around */ + H5_iter_order_t order = (H5_iter_order_t)HDva_arg(arguments, int); /* enum work-around */ + hsize_t *idx_p = HDva_arg(arguments, hsize_t *); + H5L_iterate_t op = HDva_arg(arguments, H5L_iterate_t); + void *op_data = HDva_arg(arguments, void *); + + /* Get the location */ + if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + + /* Visit or iterate over the links */ + if(loc_params->type == H5VL_OBJECT_BY_SELF) { + if(recursive) { + /* H5Lvisit */ + if((ret_value = H5G_visit(&loc, ".", idx_type, order, op, op_data)) < 0) + HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link visitation failed") + } /* end if */ + else { + /* H5Literate */ + if((ret_value = H5L_iterate(&loc, ".", idx_type, order, idx_p, op, op_data)) < 0) + HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "error iterating over links") + } /* end else */ + } /* end if */ + else if(loc_params->type == H5VL_OBJECT_BY_NAME) { + if(recursive) { + /* H5Lvisit_by_name */ + if((ret_value = H5G_visit(&loc, loc_params->loc_data.loc_by_name.name, idx_type, order, op, op_data)) < 0) + HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link visitation failed") + } /* end if */ + else { + /* H5Literate_by_name */ + if((ret_value = H5L_iterate(&loc, loc_params->loc_data.loc_by_name.name, idx_type, order, idx_p, op, op_data)) < 0) + HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "error iterating over links") + } /* end else */ + } /* end else-if */ + else + HGOTO_ERROR(H5E_LINK, H5E_UNSUPPORTED, FAIL, "unknown link iterate params") + + break; + } + + case H5VL_LINK_DELETE: + { + H5G_loc_t loc; + + if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Unlink */ + if(loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Ldelete */ + if(H5L_delete(&loc, loc_params->loc_data.loc_by_name.name) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "unable to delete link") + } /* end if */ + else if(loc_params->type == H5VL_OBJECT_BY_IDX) { /* H5Ldelete_by_idx */ + if(H5L_delete_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, loc_params->loc_data.loc_by_idx.idx_type, + loc_params->loc_data.loc_by_idx.order, loc_params->loc_data.loc_by_idx.n) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "unable to delete link") + } /* end else-if */ + else + HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "unable to delete link") + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_link_specific() */ + diff --git a/src/H5VLnative_object.c b/src/H5VLnative_object.c new file mode 100644 index 0000000..0b1d73a --- /dev/null +++ b/src/H5VLnative_object.c @@ -0,0 +1,482 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * 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 COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: Object callbacks for the native VOL connector + * + */ + +#define H5O_FRIEND /* Suppress error about including H5Opkg */ +#define H5R_FRIEND /* Suppress error about including H5Rpkg */ + +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* Files */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Opkg.h" /* Object headers */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5Rpkg.h" /* References */ +#include "H5VLprivate.h" /* Virtual Object Layer */ + +#include "H5VLnative_private.h" /* Native VOL connector */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_object_open + * + * Purpose: Handles the object open callback + * + * Return: Success: object pointer + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL__native_object_open(void *obj, const H5VL_loc_params_t *loc_params, H5I_type_t *opened_type, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + H5G_loc_t loc; + void *ret_value = NULL; + + FUNC_ENTER_PACKAGE + + if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") + + switch(loc_params->type) { + case H5VL_OBJECT_BY_NAME: + { + /* Open the object */ + if(NULL == (ret_value = H5O_open_name(&loc, loc_params->loc_data.loc_by_name.name, opened_type))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, NULL, "unable to open object by name") + break; + } + + case H5VL_OBJECT_BY_IDX: + { + /* Open the object */ + if(NULL == (ret_value = H5O_open_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, loc_params->loc_data.loc_by_idx.idx_type, + loc_params->loc_data.loc_by_idx.order, loc_params->loc_data.loc_by_idx.n, opened_type))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, NULL, "unable to open object by index") + break; + } + + case H5VL_OBJECT_BY_ADDR: + { + /* Open the object */ + if(NULL == (ret_value = H5O_open_by_addr(&loc, loc_params->loc_data.loc_by_addr.addr, opened_type))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, NULL, "unable to open object by address") + break; + } + + case H5VL_OBJECT_BY_REF: + { + hid_t temp_id = H5I_INVALID_HID; + H5F_t *file = NULL; + + /* Get the file pointer from the entry */ + file = loc.oloc->file; + + /* Create reference */ + if((temp_id = H5R__dereference(file, loc_params->loc_data.loc_by_ref.lapl_id, + loc_params->loc_data.loc_by_ref.ref_type, + loc_params->loc_data.loc_by_ref._ref)) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTOPENOBJ, NULL, "unable to dereference object") + + *opened_type = H5I_get_type(temp_id); + if(NULL == (ret_value = H5I_remove(temp_id))) + HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, NULL, "unable to open object") + break; + } + + case H5VL_OBJECT_BY_SELF: + default: + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "unknown open parameters") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_object_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_object_copy + * + * Purpose: Handles the object copy callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_object_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, const char *src_name, + void *dst_obj, const H5VL_loc_params_t *loc_params2, const char *dst_name, + hid_t ocpypl_id, hid_t lcpl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + H5G_loc_t src_loc; /* Source object group location */ + H5G_loc_t dst_loc; /* Destination group location */ + herr_t ret_value = FAIL; + + FUNC_ENTER_PACKAGE + + /* get location for objects */ + if(H5G_loc_real(src_obj, loc_params1->obj_type, &src_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + if(H5G_loc_real(dst_obj, loc_params2->obj_type, &dst_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Copy the object */ + if((ret_value = H5O_copy(&src_loc, src_name, &dst_loc, dst_name, ocpypl_id, lcpl_id)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, FAIL, "unable to copy object") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_object_copy() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_object_get + * + * Purpose: Handles the object get callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_object_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_object_get_t get_type, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + H5G_loc_t loc; /* Location of group */ + + FUNC_ENTER_PACKAGE + + if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + switch(get_type) { + /* H5Rget_region */ + case H5VL_REF_GET_REGION: + { + hid_t *ret = HDva_arg(arguments, hid_t *); + H5R_type_t H5_ATTR_UNUSED ref_type = (H5R_type_t)HDva_arg(arguments, int); /* enum work-around */ + void *ref = HDva_arg(arguments, void *); + H5S_t *space = NULL; /* Dataspace object */ + + /* Get the dataspace with the correct region selected */ + if((space = H5R__get_region(loc.oloc->file, ref)) == NULL) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to retrieve region") + + /* Atomize */ + if((*ret = H5I_register(H5I_DATASPACE, space, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace atom") + + break; + } + + /* H5Rget_obj_type1/2 */ + case H5VL_REF_GET_TYPE: + { + H5O_type_t *obj_type = HDva_arg(arguments, H5O_type_t *); + H5R_type_t ref_type = (H5R_type_t)HDva_arg(arguments, int); /* enum work-around */ + void *ref = HDva_arg(arguments, void *); + + /* Get the object information */ + if(H5R__get_obj_type(loc.oloc->file, ref_type, ref, obj_type) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to determine object type") + break; + } + + /* H5Rget_name */ + case H5VL_REF_GET_NAME: + { + ssize_t *ret = HDva_arg(arguments, ssize_t *); + char *name = HDva_arg(arguments, char *); + size_t size = HDva_arg(arguments, size_t); + H5R_type_t ref_type = (H5R_type_t)HDva_arg(arguments, int); /* enum work-around */ + void *ref = HDva_arg(arguments, void *); + + /* Get name */ + if((*ret = H5R__get_name(loc.oloc->file, ref_type, ref, name, size)) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to determine object path") + break; + } + + /* H5Iget_name */ + case H5VL_ID_GET_NAME: + { + ssize_t *ret = HDva_arg(arguments, ssize_t *); + char *name = HDva_arg(arguments, char *); + size_t size = HDva_arg(arguments, size_t); + + /* Retrieve object's name */ + if((*ret = H5G_get_name(&loc, name, size, NULL)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't retrieve object name") + + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from object") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_object_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_object_specific + * + * Purpose: Handles the object specific callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_object_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_object_specific_t specific_type, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +{ + H5G_loc_t loc; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + switch(specific_type) { + /* H5Oincr_refcount / H5Odecr_refcount */ + case H5VL_OBJECT_CHANGE_REF_COUNT: + { + int update_ref = HDva_arg(arguments, int); + H5O_loc_t *oloc = loc.oloc; + + if(H5O_link(oloc, update_ref) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "modifying object link count failed") + + break; + } + + /* H5Oexists_by_name */ + case H5VL_OBJECT_EXISTS: + { + htri_t *ret = HDva_arg(arguments, htri_t *); + + if(loc_params->type == H5VL_OBJECT_BY_NAME) { + /* Check if the object exists */ + if((*ret = H5G_loc_exists(&loc, loc_params->loc_data.loc_by_name.name)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to determine if '%s' exists", loc_params->loc_data.loc_by_name.name) + } /* end if */ + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown object exists parameters") + break; + } + + case H5VL_OBJECT_VISIT: + { + H5_index_t idx_type = (H5_index_t)HDva_arg(arguments, int); /* enum work-around */ + H5_iter_order_t order = (H5_iter_order_t)HDva_arg(arguments, int); /* enum work-around */ + H5O_iterate_t op = HDva_arg(arguments, H5O_iterate_t); + void *op_data = HDva_arg(arguments, void *); + unsigned fields = HDva_arg(arguments, unsigned); + + /* Call internal object visitation routine */ + if(loc_params->type == H5VL_OBJECT_BY_SELF) { + /* H5Ovisit */ + if((ret_value = H5O__visit(&loc, ".", idx_type, order, op, op_data, fields)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed") + } /* end if */ + else if(loc_params->type == H5VL_OBJECT_BY_NAME) { + /* H5Ovisit_by_name */ + if((ret_value = H5O__visit(&loc, loc_params->loc_data.loc_by_name.name, idx_type, order, op, op_data, fields)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed") + } /* end else-if */ + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown object visit params"); + break; + } + + case H5VL_OBJECT_FLUSH: + { + hid_t oid = HDva_arg(arguments, hid_t); + + /* Flush the object's metadata */ + if(H5O_flush(loc.oloc, oid) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTFLUSH, FAIL, "unable to flush object") + + break; + } + + case H5VL_OBJECT_REFRESH: + { + hid_t oid = HDva_arg(arguments, hid_t); + H5O_loc_t *oloc = loc.oloc; + + /* Refresh the metadata */ + if(H5O_refresh_metadata(oid, *oloc) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to refresh object") + + break; + } + + case H5VL_REF_CREATE: + { + void *ref = HDva_arg(arguments, void *); + const char *name = HDva_arg(arguments, char *); + H5R_type_t ref_type = (H5R_type_t)HDva_arg(arguments, int); /* enum work-around */ + hid_t space_id = HDva_arg(arguments, hid_t); + H5S_t *space = NULL; /* Pointer to dataspace containing region */ + + if(space_id != (-1) && (NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE)))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") + + /* Create reference */ + if(H5R__create(ref, &loc, name, ref_type, space) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCREATE, FAIL, "unable to create reference") + + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't recognize this operation type") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_object_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_object_optional + * + * Purpose: Handles the object optional callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_object_optional(void *obj, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req, va_list arguments) +{ + H5VL_native_object_optional_t optional_type = HDva_arg(arguments, H5VL_native_object_optional_t); + H5VL_loc_params_t *loc_params = HDva_arg(arguments, H5VL_loc_params_t *); + H5G_loc_t loc; /* Location of group */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + switch(optional_type) { + /* H5Oget_info / H5Oget_info_by_name / H5Oget_info_by_idx */ + case H5VL_NATIVE_OBJECT_GET_INFO: + { + H5O_info_t *obj_info = HDva_arg(arguments, H5O_info_t *); + unsigned fields = HDva_arg(arguments, unsigned); + + if(loc_params->type == H5VL_OBJECT_BY_SELF) { /* H5Oget_info */ + /* Retrieve the object's information */ + if(H5G_loc_info(&loc, ".", obj_info, fields) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") + } /* end if */ + else if(loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Oget_info_by_name */ + /* Retrieve the object's information */ + if(H5G_loc_info(&loc, loc_params->loc_data.loc_by_name.name, obj_info, fields) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") + } /* end else-if */ + else if(loc_params->type == H5VL_OBJECT_BY_IDX) { /* H5Oget_info_by_idx */ + H5G_loc_t obj_loc; /* Location used to open group */ + H5G_name_t obj_path; /* Opened object group hier. path */ + H5O_loc_t obj_oloc; /* Opened object object location */ + + /* Set up opened group location to fill in */ + obj_loc.oloc = &obj_oloc; + obj_loc.path = &obj_path; + H5G_loc_reset(&obj_loc); + + /* Find the object's location, according to the order in the index */ + if(H5G_loc_find_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, + loc_params->loc_data.loc_by_idx.idx_type, + loc_params->loc_data.loc_by_idx.order, + loc_params->loc_data.loc_by_idx.n, &obj_loc/*out*/) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "group not found") + + /* Retrieve the object's information */ + if(H5O_get_info(obj_loc.oloc, obj_info, fields) < 0) { + H5G_loc_free(&obj_loc); + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve object info") + } /* end if */ + + /* Release the object location */ + if(H5G_loc_free(&obj_loc) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "can't free location") + } /* end else-if */ + else + HGOTO_ERROR(H5E_OHDR, H5E_UNSUPPORTED, FAIL, "unknown get info parameters") + break; + } + + /* H5Oget_comment / H5Oget_comment_by_name */ + case H5VL_NATIVE_OBJECT_GET_COMMENT: + { + char *comment = HDva_arg(arguments, char *); + size_t bufsize = HDva_arg(arguments, size_t); + ssize_t *ret = HDva_arg(arguments, ssize_t *); + + /* Retrieve the object's comment */ + if(loc_params->type == H5VL_OBJECT_BY_SELF) { /* H5Oget_comment */ + if((*ret = H5G_loc_get_comment(&loc, ".", comment/*out*/, bufsize)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") + } /* end if */ + else if(loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Oget_comment_by_name */ + if((*ret = H5G_loc_get_comment(&loc, loc_params->loc_data.loc_by_name.name, comment/*out*/, bufsize)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") + } /* end else-if */ + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown set_coment parameters") + break; + } + + /* H5Oset_comment */ + case H5VL_NATIVE_OBJECT_SET_COMMENT: + { + const char *comment = HDva_arg(arguments, char *); + + if(loc_params->type == H5VL_OBJECT_BY_SELF) { /* H5Oset_comment */ + /* (Re)set the object's comment */ + if(H5G_loc_set_comment(&loc, ".", comment) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") + } /* end if */ + else if(loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Oset_comment_by_name */ + /* (Re)set the object's comment */ + if(H5G_loc_set_comment(&loc, loc_params->loc_data.loc_by_name.name, comment) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") + } /* end else-if */ + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown set_coment parameters") + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't perform this operation on object"); + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_object_optional() */ + diff --git a/src/H5VLnative_private.h b/src/H5VLnative_private.h new file mode 100644 index 0000000..1bf4da2 --- /dev/null +++ b/src/H5VLnative_private.h @@ -0,0 +1,88 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * 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 COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: The private header file for the native VOL connector. + */ + +#ifndef _H5VLnative_private_H +#define _H5VLnative_private_H + +#include "H5VLnative.h" /* Native VOL connector */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* Atrribute callbacks */ +H5_DLL void *H5VL__native_attr_create(void *obj, const H5VL_loc_params_t *loc_params, const char *attr_name, hid_t acpl_id, hid_t aapl_id, hid_t dxpl_id, void **req); +void *H5VL__native_attr_open(void *obj, const H5VL_loc_params_t *loc_params, const char *attr_name, hid_t aapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_attr_read(void *attr, hid_t dtype_id, void *buf, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_attr_write(void *attr, hid_t dtype_id, const void *buf, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_attr_get(void *obj, H5VL_attr_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_attr_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_attr_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_attr_optional(void *obj, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_attr_close(void *attr, hid_t dxpl_id, void **req); + +/* Dataset callbacks */ +H5_DLL void *H5VL__native_dataset_create(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req); +H5_DLL void *H5VL__native_dataset_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t dapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_dataset_read(void *dset, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, void *buf, void **req); +H5_DLL herr_t H5VL__native_dataset_write(void *dset, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, const void *buf, void **req); +H5_DLL herr_t H5VL__native_dataset_get(void *dset, H5VL_dataset_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_dataset_specific(void *dset, H5VL_dataset_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_dataset_optional(void *dset, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_dataset_close(void *dset, hid_t dxpl_id, void **req); + +/* File callbacks */ +H5_DLL void *H5VL__native_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id, void **req); +H5_DLL void *H5VL__native_file_open(const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_file_get(void *file, H5VL_file_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_file_specific(void *file, H5VL_file_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_file_optional(void *file, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_file_close(void *file, hid_t dxpl_id, void **req); + +/* Group callbacks */ +H5_DLL void *H5VL__native_group_create(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req); +H5_DLL void *H5VL__native_group_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t gapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_group_get(void *obj, H5VL_group_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_group_specific(void *obj, H5VL_group_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_group_optional(void *obj, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_group_close(void *grp, hid_t dxpl_id, void **req); + +/* Link callbacks */ +H5_DLL herr_t H5VL__native_link_create(H5VL_link_create_type_t create_type, void *obj, const H5VL_loc_params_t *loc_params, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_link_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_link_move(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_link_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_link_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); + +/* Object callbacks */ +H5_DLL void *H5VL__native_object_open(void *obj, const H5VL_loc_params_t *loc_params, H5I_type_t *opened_type, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_object_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, const char *src_name, void *dst_obj, const H5VL_loc_params_t *loc_params2, const char *dst_name, hid_t ocpypl_id, hid_t lcpl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_object_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_object_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_object_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_object_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_object_optional(void *obj, hid_t dxpl_id, void **req, va_list arguments); + +/* Datatype callbacks */ +H5_DLL void *H5VL__native_datatype_commit(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, hid_t dxpl_id, void **req); +H5_DLL void *H5VL__native_datatype_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t tapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_datatype_get(void *dt, H5VL_datatype_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_datatype_specific(void *dt, H5VL_datatype_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_datatype_close(void *dt, hid_t dxpl_id, void **req); + +#ifdef __cplusplus +} +#endif + +#endif /* _H5VLnative_private_H */ + diff --git a/src/H5VLpassthru.c b/src/H5VLpassthru.c index a93ac9a..13d8d8e 100644 --- a/src/H5VLpassthru.c +++ b/src/H5VLpassthru.c @@ -11,14 +11,14 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Purpose: This is a "pass through" VOL connector, which forwards each - * VOL callback to an underlying connector. - * - * It is designed as an example VOL connector for developers to - * use when creating new connectors, especially connectors that - * are outside of the HDF5 library. As such, it should _NOT_ - * include _any_ private HDF5 header files. This connector should - * therefore only make public HDF5 API calls and use standard C / + * Purpose: This is a "pass through" VOL connector, which forwards each + * VOL callback to an underlying connector. + * + * It is designed as an example VOL connector for developers to + * use when creating new connectors, especially connectors that + * are outside of the HDF5 library. As such, it should _NOT_ + * include _any_ private HDF5 header files. This connector should + * therefore only make public HDF5 API calls and use standard C / * POSIX calls. */ @@ -26,6 +26,7 @@ /* Header files needed */ /* (Public HDF5 and standard C / POSIX only) */ #include <assert.h> +#include <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -39,8 +40,14 @@ /* Whether to display log messge when callback is invoked */ /* (Uncomment to enable) */ -/* #define ENABLE_LOGGING */ +/* #define ENABLE_PASSTHRU_LOGGING */ +/* Hack for missing va_copy() in old Visual Studio editions + * (from H5win2_defs.h - used on VS2012 and earlier) + */ +#if defined(_WIN32) && defined(_MSC_VER) && (_MSC_VER < 1800) +#define va_copy(D,S) ((D) = (S)) +#endif /************/ /* Typedefs */ @@ -161,11 +168,11 @@ static herr_t H5VL_pass_through_request_free(void *req); static const H5VL_class_t H5VL_pass_through_g = { H5VL_PASSTHRU_VERSION, /* version */ (H5VL_class_value_t)H5VL_PASSTHRU_VALUE, /* value */ - H5VL_PASSTHRU_NAME, /* name */ + H5VL_PASSTHRU_NAME, /* name */ 0, /* capability flags */ H5VL_pass_through_init, /* initialize */ H5VL_pass_through_term, /* terminate */ - sizeof(H5VL_pass_through_t), /* info size */ + sizeof(H5VL_pass_through_info_t), /* info size */ H5VL_pass_through_info_copy, /* info copy */ H5VL_pass_through_info_cmp, /* info compare */ H5VL_pass_through_info_free, /* info free */ @@ -252,10 +259,10 @@ static hid_t H5VL_PASSTHRU_g = H5I_INVALID_HID; /*------------------------------------------------------------------------- * Function: H5VL__pass_through_new_obj * - * Purpose: Create a new pass through object for an underlying object + * Purpose: Create a new pass through object for an underlying object * - * Return: Success: Pointer to the new pass through object - * Failure: NULL + * Return: Success: Pointer to the new pass through object + * Failure: NULL * * Programmer: Quincey Koziol * Monday, December 3, 2018 @@ -272,17 +279,17 @@ H5VL_pass_through_new_obj(void *under_obj, hid_t under_vol_id) new_obj->under_vol_id = under_vol_id; H5Iinc_ref(new_obj->under_vol_id); - return(new_obj); + return new_obj; } /* end H5VL__pass_through_new_obj() */ /*------------------------------------------------------------------------- * Function: H5VL__pass_through_free_obj * - * Purpose: Release a pass through object + * Purpose: Release a pass through object * - * Return: Success: 0 - * Failure: -1 + * Return: Success: 0 + * Failure: -1 * * Programmer: Quincey Koziol * Monday, December 3, 2018 @@ -295,18 +302,18 @@ H5VL_pass_through_free_obj(H5VL_pass_through_t *obj) H5Idec_ref(obj->under_vol_id); free(obj); - return(0); + return 0; } /* end H5VL__pass_through_free_obj() */ /*------------------------------------------------------------------------- * Function: H5VL_pass_through_register * - * Purpose: Register the pass-through VOL connector and retrieve an ID - * for it. + * Purpose: Register the pass-through VOL connector and retrieve an ID + * for it. * - * Return: Success: The ID for the pass-through VOL connector - * Failure: -1 + * Return: Success: The ID for the pass-through VOL connector + * Failure: -1 * * Programmer: Quincey Koziol * Wednesday, November 28, 2018 @@ -323,7 +330,7 @@ H5VL_pass_through_register(void) if(H5I_VOL != H5Iget_type(H5VL_PASSTHRU_g)) H5VL_PASSTHRU_g = H5VLregister_connector(&H5VL_pass_through_g, H5P_DEFAULT); - return(H5VL_PASSTHRU_g); + return H5VL_PASSTHRU_g; } /* end H5VL_pass_through_register() */ @@ -331,25 +338,25 @@ H5VL_pass_through_register(void) * Function: H5VL_pass_through_init * * Purpose: Initialize this VOL connector, performing any necessary - * operations for the connector that will apply to all containers + * operations for the connector that will apply to all containers * accessed with the connector. * - * Return: Success: 0 - * Failure: -1 + * Return: Success: 0 + * Failure: -1 * *------------------------------------------------------------------------- */ static herr_t H5VL_pass_through_init(hid_t vipl_id) { -#ifdef ENABLE_LOGGING +#ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL INIT\n"); #endif /* Shut compiler up about unused parameter */ vipl_id = vipl_id; - return(0); + return 0; } /* end H5VL_pass_through_init() */ @@ -357,26 +364,26 @@ H5VL_pass_through_init(hid_t vipl_id) * Function: H5VL_pass_through_term * * Purpose: Terminate this VOL connector, performing any necessary - * operations for the connector that release connector-wide - * resources (usually created / initialized with the 'init' - * callback). + * operations for the connector that release connector-wide + * resources (usually created / initialized with the 'init' + * callback). * - * Return: Success: 0 - * Failure: (Can't fail) + * Return: Success: 0 + * Failure: (Can't fail) * *--------------------------------------------------------------------------- */ static herr_t H5VL_pass_through_term(void) { -#ifdef ENABLE_LOGGING +#ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL TERM\n"); #endif /* Reset VOL ID */ H5VL_PASSTHRU_g = H5I_INVALID_HID; - return(0); + return 0; } /* end H5VL_pass_through_term() */ @@ -385,8 +392,8 @@ H5VL_pass_through_term(void) * * Purpose: Duplicate the connector's info object. * - * Returns: Success: New connector info object - * Failure: NULL + * Returns: Success: New connector info object + * Failure: NULL * *--------------------------------------------------------------------------- */ @@ -396,7 +403,7 @@ H5VL_pass_through_info_copy(const void *_info) const H5VL_pass_through_info_t *info = (const H5VL_pass_through_info_t *)_info; H5VL_pass_through_info_t *new_info; -#ifdef ENABLE_LOGGING +#ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL INFO Copy\n"); #endif @@ -409,7 +416,7 @@ H5VL_pass_through_info_copy(const void *_info) if(info->under_vol_info) H5VLcopy_connector_info(new_info->under_vol_id, &(new_info->under_vol_info), info->under_vol_info); - return(new_info); + return new_info; } /* end H5VL_pass_through_info_copy() */ @@ -417,10 +424,10 @@ H5VL_pass_through_info_copy(const void *_info) * Function: H5VL_pass_through_info_cmp * * Purpose: Compare two of the connector's info objects, setting *cmp_value, - * following the same rules as strcmp(). + * following the same rules as strcmp(). * - * Return: Success: 0 - * Failure: -1 + * Return: Success: 0 + * Failure: -1 * *--------------------------------------------------------------------------- */ @@ -430,7 +437,7 @@ H5VL_pass_through_info_cmp(int *cmp_value, const void *_info1, const void *_info const H5VL_pass_through_info_t *info1 = (const H5VL_pass_through_info_t *)_info1; const H5VL_pass_through_info_t *info2 = (const H5VL_pass_through_info_t *)_info2; -#ifdef ENABLE_LOGGING +#ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL INFO Compare\n"); #endif @@ -444,14 +451,14 @@ H5VL_pass_through_info_cmp(int *cmp_value, const void *_info1, const void *_info /* Compare under VOL connector classes */ H5VLcmp_connector_cls(cmp_value, info1->under_vol_id, info2->under_vol_id); if(*cmp_value != 0) - return(0); + return 0; /* Compare under VOL connector info objects */ H5VLcmp_connector_info(cmp_value, info1->under_vol_id, info1->under_vol_info, info2->under_vol_info); if(*cmp_value != 0) - return(0); + return 0; - return(0); + return 0; } /* end H5VL_pass_through_info_cmp() */ @@ -460,8 +467,8 @@ H5VL_pass_through_info_cmp(int *cmp_value, const void *_info1, const void *_info * * Purpose: Release an info object for the connector. * - * Return: Success: 0 - * Failure: -1 + * Return: Success: 0 + * Failure: -1 * *--------------------------------------------------------------------------- */ @@ -470,7 +477,7 @@ H5VL_pass_through_info_free(void *_info) { H5VL_pass_through_info_t *info = (H5VL_pass_through_info_t *)_info; -#ifdef ENABLE_LOGGING +#ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL INFO Free\n"); #endif @@ -482,7 +489,7 @@ H5VL_pass_through_info_free(void *_info) /* Free pass through info object itself */ free(info); - return(0); + return 0; } /* end H5VL_pass_through_info_free() */ @@ -491,8 +498,8 @@ H5VL_pass_through_info_free(void *_info) * * Purpose: Serialize an info object for this connector into a string * - * Return: Success: 0 - * Failure: -1 + * Return: Success: 0 + * Failure: -1 * *--------------------------------------------------------------------------- */ @@ -504,7 +511,7 @@ H5VL_pass_through_info_to_str(const void *_info, char **str) char *under_vol_string = NULL; size_t under_vol_str_len = 0; -#ifdef ENABLE_LOGGING +#ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL INFO To String\n"); #endif @@ -520,10 +527,14 @@ H5VL_pass_through_info_to_str(const void *_info, char **str) *str = (char *)H5allocate_memory(32 + under_vol_str_len, (hbool_t)0); assert(*str); - /* Encode our info */ - snprintf(*str, 32 + under_vol_str_len, "under_vol=%u;under_info={%s}", (unsigned)under_value, (under_vol_string ? under_vol_string : "")); + /* Encode our info + * Normally we'd use snprintf() here for a little extra safety, but that + * call had problems on Windows until recently. So, to be as platform-independent + * as we can, we're using sprintf() instead. + */ + sprintf(*str, "under_vol=%u;under_info={%s}", (unsigned)under_value, (under_vol_string ? under_vol_string : "")); - return(0); + return 0; } /* end H5VL_pass_through_info_to_str() */ @@ -532,8 +543,8 @@ H5VL_pass_through_info_to_str(const void *_info, char **str) * * Purpose: Deserialize a string into an info object for this connector. * - * Return: Success: 0 - * Failure: -1 + * Return: Success: 0 + * Failure: -1 * *--------------------------------------------------------------------------- */ @@ -546,7 +557,7 @@ H5VL_pass_through_str_to_info(const char *str, void **_info) hid_t under_vol_id; void *under_vol_info = NULL; -#ifdef ENABLE_LOGGING +#ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL INFO String To Info\n"); #endif @@ -576,7 +587,7 @@ H5VL_pass_through_str_to_info(const char *str, void **_info) /* Set return value */ *_info = info; - return(0); + return 0; } /* end H5VL_pass_through_str_to_info() */ @@ -585,8 +596,8 @@ H5VL_pass_through_str_to_info(const char *str, void **_info) * * Purpose: Retrieve the 'data' for a VOL object. * - * Return: Success: 0 - * Failure: -1 + * Return: Success: 0 + * Failure: -1 * *--------------------------------------------------------------------------- */ @@ -595,11 +606,11 @@ H5VL_pass_through_get_object(const void *obj) { const H5VL_pass_through_t *o = (const H5VL_pass_through_t *)obj; -#ifdef ENABLE_LOGGING +#ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL Get object\n"); #endif - return(H5VLget_object(o->under_object, o->under_vol_id)); + return H5VLget_object(o->under_object, o->under_vol_id); } /* end H5VL_pass_through_get_object() */ @@ -608,8 +619,8 @@ H5VL_pass_through_get_object(const void *obj) * * Purpose: Retrieve a "wrapper context" for an object * - * Return: Success: 0 - * Failure: -1 + * Return: Success: 0 + * Failure: -1 * *--------------------------------------------------------------------------- */ @@ -619,7 +630,7 @@ H5VL_pass_through_get_wrap_ctx(const void *obj, void **wrap_ctx) const H5VL_pass_through_t *o = (const H5VL_pass_through_t *)obj; H5VL_pass_through_wrap_ctx_t *new_wrap_ctx; -#ifdef ENABLE_LOGGING +#ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL WRAP CTX Get\n"); #endif @@ -634,7 +645,7 @@ H5VL_pass_through_get_wrap_ctx(const void *obj, void **wrap_ctx) /* Set wrap context to return */ *wrap_ctx = new_wrap_ctx; - return(0); + return 0; } /* end H5VL_pass_through_get_wrap_ctx() */ @@ -643,8 +654,8 @@ H5VL_pass_through_get_wrap_ctx(const void *obj, void **wrap_ctx) * * Purpose: Use a "wrapper context" to wrap a data object * - * Return: Success: 0 - * Failure: -1 + * Return: Success: 0 + * Failure: -1 * *--------------------------------------------------------------------------- */ @@ -655,7 +666,7 @@ H5VL_pass_through_wrap_object(void *obj, void *_wrap_ctx) H5VL_pass_through_t *new_obj; void *under; -#ifdef ENABLE_LOGGING +#ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL WRAP Object\n"); #endif @@ -666,7 +677,7 @@ H5VL_pass_through_wrap_object(void *obj, void *_wrap_ctx) else new_obj = NULL; - return(new_obj); + return new_obj; } /* end H5VL_pass_through_wrap_object() */ @@ -675,8 +686,8 @@ H5VL_pass_through_wrap_object(void *obj, void *_wrap_ctx) * * Purpose: Release a "wrapper context" for an object * - * Return: Success: 0 - * Failure: -1 + * Return: Success: 0 + * Failure: -1 * *--------------------------------------------------------------------------- */ @@ -685,7 +696,7 @@ H5VL_pass_through_free_wrap_ctx(void *_wrap_ctx) { H5VL_pass_through_wrap_ctx_t *wrap_ctx = (H5VL_pass_through_wrap_ctx_t *)_wrap_ctx; -#ifdef ENABLE_LOGGING +#ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL WRAP CTX Free\n"); #endif @@ -697,17 +708,17 @@ H5VL_pass_through_free_wrap_ctx(void *_wrap_ctx) /* Free pass through wrap context object itself */ free(wrap_ctx); - return(0); + return 0; } /* end H5VL_pass_through_free_wrap_ctx() */ /*------------------------------------------------------------------------- - * Function: H5VL_pass_through_attr_create + * Function: H5VL_pass_through_attr_create * - * Purpose: Creates an attribute on an object. + * Purpose: Creates an attribute on an object. * - * Return: Success: Pointer to attribute object - * Failure: NULL + * Return: Success: Pointer to attribute object + * Failure: NULL * *------------------------------------------------------------------------- */ @@ -719,7 +730,7 @@ H5VL_pass_through_attr_create(void *obj, const H5VL_loc_params_t *loc_params, H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; void *under; -#ifdef ENABLE_LOGGING +#ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL ATTRIBUTE Create\n"); #endif @@ -734,17 +745,17 @@ H5VL_pass_through_attr_create(void *obj, const H5VL_loc_params_t *loc_params, else attr = NULL; - return((void*)attr); + return (void*)attr; } /* end H5VL_pass_through_attr_create() */ /*------------------------------------------------------------------------- - * Function: H5VL_pass_through_attr_open + * Function: H5VL_pass_through_attr_open * - * Purpose: Opens an attribute on an object. + * Purpose: Opens an attribute on an object. * - * Return: Success: Pointer to attribute object - * Failure: NULL + * Return: Success: Pointer to attribute object + * Failure: NULL * *------------------------------------------------------------------------- */ @@ -756,7 +767,7 @@ H5VL_pass_through_attr_open(void *obj, const H5VL_loc_params_t *loc_params, H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; void *under; -#ifdef ENABLE_LOGGING +#ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL ATTRIBUTE Open\n"); #endif @@ -771,17 +782,17 @@ H5VL_pass_through_attr_open(void *obj, const H5VL_loc_params_t *loc_params, else attr = NULL; - return((void *)attr); + return (void *)attr; } /* end H5VL_pass_through_attr_open() */ /*------------------------------------------------------------------------- - * Function: H5VL_pass_through_attr_read + * Function: H5VL_pass_through_attr_read * - * Purpose: Reads data from attribute. + * Purpose: Reads data from attribute. * - * Return: Success: 0 - * Failure: -1 + * Return: Success: 0 + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -792,7 +803,7 @@ H5VL_pass_through_attr_read(void *attr, hid_t mem_type_id, void *buf, H5VL_pass_through_t *o = (H5VL_pass_through_t *)attr; herr_t ret_value; -#ifdef ENABLE_LOGGING +#ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL ATTRIBUTE Read\n"); #endif @@ -802,17 +813,17 @@ H5VL_pass_through_attr_read(void *attr, hid_t mem_type_id, void *buf, if(req && *req) *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); - return(ret_value); + return ret_value; } /* end H5VL_pass_through_attr_read() */ /*------------------------------------------------------------------------- - * Function: H5VL_pass_through_attr_write + * Function: H5VL_pass_through_attr_write * - * Purpose: Writes data to attribute. + * Purpose: Writes data to attribute. * - * Return: Success: 0 - * Failure: -1 + * Return: Success: 0 + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -823,7 +834,7 @@ H5VL_pass_through_attr_write(void *attr, hid_t mem_type_id, const void *buf, H5VL_pass_through_t *o = (H5VL_pass_through_t *)attr; herr_t ret_value; -#ifdef ENABLE_LOGGING +#ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL ATTRIBUTE Write\n"); #endif @@ -833,17 +844,17 @@ H5VL_pass_through_attr_write(void *attr, hid_t mem_type_id, const void *buf, if(req && *req) *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); - return(ret_value); + return ret_value; } /* end H5VL_pass_through_attr_write() */ /*------------------------------------------------------------------------- - * Function: H5VL_pass_through_attr_get + * Function: H5VL_pass_through_attr_get * - * Purpose: Gets information about an attribute + * Purpose: Gets information about an attribute * - * Return: Success: 0 - * Failure: -1 + * Return: Success: 0 + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -854,7 +865,7 @@ H5VL_pass_through_attr_get(void *obj, H5VL_attr_get_t get_type, hid_t dxpl_id, H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; herr_t ret_value; -#ifdef ENABLE_LOGGING +#ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL ATTRIBUTE Get\n"); #endif @@ -864,17 +875,17 @@ H5VL_pass_through_attr_get(void *obj, H5VL_attr_get_t get_type, hid_t dxpl_id, if(req && *req) *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); - return(ret_value); + return ret_value; } /* end H5VL_pass_through_attr_get() */ /*------------------------------------------------------------------------- - * Function: H5VL_pass_through_attr_specific + * Function: H5VL_pass_through_attr_specific * - * Purpose: Specific operation on attribute + * Purpose: Specific operation on attribute * - * Return: Success: 0 - * Failure: -1 + * Return: Success: 0 + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -885,7 +896,7 @@ H5VL_pass_through_attr_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; herr_t ret_value; -#ifdef ENABLE_LOGGING +#ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL ATTRIBUTE Specific\n"); #endif @@ -895,7 +906,7 @@ H5VL_pass_through_attr_specific(void *obj, const H5VL_loc_params_t *loc_params, if(req && *req) *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); - return(ret_value); + return ret_value; } /* end H5VL_pass_through_attr_specific() */ @@ -904,8 +915,8 @@ H5VL_pass_through_attr_specific(void *obj, const H5VL_loc_params_t *loc_params, * * Purpose: Perform a connector-specific operation on an attribute * - * Return: Success: 0 - * Failure: -1 + * Return: Success: 0 + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -916,7 +927,7 @@ H5VL_pass_through_attr_optional(void *obj, hid_t dxpl_id, void **req, H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; herr_t ret_value; -#ifdef ENABLE_LOGGING +#ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL ATTRIBUTE Optional\n"); #endif @@ -926,17 +937,17 @@ H5VL_pass_through_attr_optional(void *obj, hid_t dxpl_id, void **req, if(req && *req) *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); - return(ret_value); + return ret_value; } /* end H5VL_pass_through_attr_optional() */ /*------------------------------------------------------------------------- - * Function: H5VL_pass_through_attr_close + * Function: H5VL_pass_through_attr_close * - * Purpose: Closes an attribute. + * Purpose: Closes an attribute. * - * Return: Success: 0 - * Failure: -1, attr not closed. + * Return: Success: 0 + * Failure: -1, attr not closed. * *------------------------------------------------------------------------- */ @@ -946,7 +957,7 @@ H5VL_pass_through_attr_close(void *attr, hid_t dxpl_id, void **req) H5VL_pass_through_t *o = (H5VL_pass_through_t *)attr; herr_t ret_value; -#ifdef ENABLE_LOGGING +#ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL ATTRIBUTE Close\n"); #endif @@ -960,7 +971,7 @@ H5VL_pass_through_attr_close(void *attr, hid_t dxpl_id, void **req) if(ret_value >= 0) H5VL_pass_through_free_obj(o); - return(ret_value); + return ret_value; } /* end H5VL_pass_through_attr_close() */ @@ -982,7 +993,7 @@ H5VL_pass_through_dataset_create(void *obj, const H5VL_loc_params_t *loc_params, H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; void *under; -#ifdef ENABLE_LOGGING +#ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL DATASET Create\n"); #endif @@ -997,7 +1008,7 @@ H5VL_pass_through_dataset_create(void *obj, const H5VL_loc_params_t *loc_params, else dset = NULL; - return((void *)dset); + return (void *)dset; } /* end H5VL_pass_through_dataset_create() */ @@ -1019,7 +1030,7 @@ H5VL_pass_through_dataset_open(void *obj, const H5VL_loc_params_t *loc_params, H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; void *under; -#ifdef ENABLE_LOGGING +#ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL DATASET Open\n"); #endif @@ -1034,7 +1045,7 @@ H5VL_pass_through_dataset_open(void *obj, const H5VL_loc_params_t *loc_params, else dset = NULL; - return((void *)dset); + return (void *)dset; } /* end H5VL_pass_through_dataset_open() */ @@ -1043,8 +1054,8 @@ H5VL_pass_through_dataset_open(void *obj, const H5VL_loc_params_t *loc_params, * * Purpose: Reads data elements from a dataset into a buffer. * - * Return: Success: 0 - * Failure: -1 + * Return: Success: 0 + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -1055,7 +1066,7 @@ H5VL_pass_through_dataset_read(void *dset, hid_t mem_type_id, hid_t mem_space_id H5VL_pass_through_t *o = (H5VL_pass_through_t *)dset; herr_t ret_value; -#ifdef ENABLE_LOGGING +#ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL DATASET Read\n"); #endif @@ -1065,7 +1076,7 @@ H5VL_pass_through_dataset_read(void *dset, hid_t mem_type_id, hid_t mem_space_id if(req && *req) *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); - return(ret_value); + return ret_value; } /* end H5VL_pass_through_dataset_read() */ @@ -1074,8 +1085,8 @@ H5VL_pass_through_dataset_read(void *dset, hid_t mem_type_id, hid_t mem_space_id * * Purpose: Writes data elements from a buffer into a dataset. * - * Return: Success: 0 - * Failure: -1 + * Return: Success: 0 + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -1086,7 +1097,7 @@ H5VL_pass_through_dataset_write(void *dset, hid_t mem_type_id, hid_t mem_space_i H5VL_pass_through_t *o = (H5VL_pass_through_t *)dset; herr_t ret_value; -#ifdef ENABLE_LOGGING +#ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL DATASET Write\n"); #endif @@ -1096,7 +1107,7 @@ H5VL_pass_through_dataset_write(void *dset, hid_t mem_type_id, hid_t mem_space_i if(req && *req) *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); - return(ret_value); + return ret_value; } /* end H5VL_pass_through_dataset_write() */ @@ -1105,8 +1116,8 @@ H5VL_pass_through_dataset_write(void *dset, hid_t mem_type_id, hid_t mem_space_i * * Purpose: Gets information about a dataset * - * Return: Success: 0 - * Failure: -1 + * Return: Success: 0 + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -1117,7 +1128,7 @@ H5VL_pass_through_dataset_get(void *dset, H5VL_dataset_get_t get_type, H5VL_pass_through_t *o = (H5VL_pass_through_t *)dset; herr_t ret_value; -#ifdef ENABLE_LOGGING +#ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL DATASET Get\n"); #endif @@ -1127,17 +1138,17 @@ H5VL_pass_through_dataset_get(void *dset, H5VL_dataset_get_t get_type, if(req && *req) *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); - return(ret_value); + return ret_value; } /* end H5VL_pass_through_dataset_get() */ /*------------------------------------------------------------------------- * Function: H5VL_pass_through_dataset_specific * - * Purpose: Specific operation on a dataset + * Purpose: Specific operation on a dataset * - * Return: Success: 0 - * Failure: -1 + * Return: Success: 0 + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -1148,7 +1159,7 @@ H5VL_pass_through_dataset_specific(void *obj, H5VL_dataset_specific_t specific_t H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; herr_t ret_value; -#ifdef ENABLE_LOGGING +#ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL H5Dspecific\n"); #endif @@ -1158,7 +1169,7 @@ H5VL_pass_through_dataset_specific(void *obj, H5VL_dataset_specific_t specific_t if(req && *req) *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); - return(ret_value); + return ret_value; } /* end H5VL_pass_through_dataset_specific() */ @@ -1167,8 +1178,8 @@ H5VL_pass_through_dataset_specific(void *obj, H5VL_dataset_specific_t specific_t * * Purpose: Perform a connector-specific operation on a dataset * - * Return: Success: 0 - * Failure: -1 + * Return: Success: 0 + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -1179,7 +1190,7 @@ H5VL_pass_through_dataset_optional(void *obj, hid_t dxpl_id, void **req, H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; herr_t ret_value; -#ifdef ENABLE_LOGGING +#ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL DATASET Optional\n"); #endif @@ -1189,7 +1200,7 @@ H5VL_pass_through_dataset_optional(void *obj, hid_t dxpl_id, void **req, if(req && *req) *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); - return(ret_value); + return ret_value; } /* end H5VL_pass_through_dataset_optional() */ @@ -1198,8 +1209,8 @@ H5VL_pass_through_dataset_optional(void *obj, hid_t dxpl_id, void **req, * * Purpose: Closes a dataset. * - * Return: Success: 0 - * Failure: -1, dataset not closed. + * Return: Success: 0 + * Failure: -1, dataset not closed. * *------------------------------------------------------------------------- */ @@ -1209,7 +1220,7 @@ H5VL_pass_through_dataset_close(void *dset, hid_t dxpl_id, void **req) H5VL_pass_through_t *o = (H5VL_pass_through_t *)dset; herr_t ret_value; -#ifdef ENABLE_LOGGING +#ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL DATASET Close\n"); #endif @@ -1223,17 +1234,17 @@ H5VL_pass_through_dataset_close(void *dset, hid_t dxpl_id, void **req) if(ret_value >= 0) H5VL_pass_through_free_obj(o); - return(ret_value); + return ret_value; } /* end H5VL_pass_through_dataset_close() */ /*------------------------------------------------------------------------- - * Function: H5VL_pass_through_datatype_commit + * Function: H5VL_pass_through_datatype_commit * - * Purpose: Commits a datatype inside a container. + * Purpose: Commits a datatype inside a container. * - * Return: Success: Pointer to datatype object - * Failure: NULL + * Return: Success: Pointer to datatype object + * Failure: NULL * *------------------------------------------------------------------------- */ @@ -1246,7 +1257,7 @@ H5VL_pass_through_datatype_commit(void *obj, const H5VL_loc_params_t *loc_params H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; void *under; -#ifdef ENABLE_LOGGING +#ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL DATATYPE Commit\n"); #endif @@ -1261,7 +1272,7 @@ H5VL_pass_through_datatype_commit(void *obj, const H5VL_loc_params_t *loc_params else dt = NULL; - return((void *)dt); + return (void *)dt; } /* end H5VL_pass_through_datatype_commit() */ @@ -1283,7 +1294,7 @@ H5VL_pass_through_datatype_open(void *obj, const H5VL_loc_params_t *loc_params, H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; void *under; -#ifdef ENABLE_LOGGING +#ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL DATATYPE Open\n"); #endif @@ -1298,17 +1309,17 @@ H5VL_pass_through_datatype_open(void *obj, const H5VL_loc_params_t *loc_params, else dt = NULL; - return((void *)dt); + return (void *)dt; } /* end H5VL_pass_through_datatype_open() */ /*------------------------------------------------------------------------- - * Function: H5VL_pass_through_datatype_get + * Function: H5VL_pass_through_datatype_get * - * Purpose: Get information about a datatype + * Purpose: Get information about a datatype * - * Return: Success: 0 - * Failure: -1 + * Return: Success: 0 + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -1319,7 +1330,7 @@ H5VL_pass_through_datatype_get(void *dt, H5VL_datatype_get_t get_type, H5VL_pass_through_t *o = (H5VL_pass_through_t *)dt; herr_t ret_value; -#ifdef ENABLE_LOGGING +#ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL DATATYPE Get\n"); #endif @@ -1329,7 +1340,7 @@ H5VL_pass_through_datatype_get(void *dt, H5VL_datatype_get_t get_type, if(req && *req) *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); - return(ret_value); + return ret_value; } /* end H5VL_pass_through_datatype_get() */ @@ -1338,8 +1349,8 @@ H5VL_pass_through_datatype_get(void *dt, H5VL_datatype_get_t get_type, * * Purpose: Specific operations for datatypes * - * Return: Success: 0 - * Failure: -1 + * Return: Success: 0 + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -1350,7 +1361,7 @@ H5VL_pass_through_datatype_specific(void *obj, H5VL_datatype_specific_t specific H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; herr_t ret_value; -#ifdef ENABLE_LOGGING +#ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL DATATYPE Specific\n"); #endif @@ -1360,7 +1371,7 @@ H5VL_pass_through_datatype_specific(void *obj, H5VL_datatype_specific_t specific if(req && *req) *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); - return(ret_value); + return ret_value; } /* end H5VL_pass_through_datatype_specific() */ @@ -1369,8 +1380,8 @@ H5VL_pass_through_datatype_specific(void *obj, H5VL_datatype_specific_t specific * * Purpose: Perform a connector-specific operation on a datatype * - * Return: Success: 0 - * Failure: -1 + * Return: Success: 0 + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -1381,7 +1392,7 @@ H5VL_pass_through_datatype_optional(void *obj, hid_t dxpl_id, void **req, H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; herr_t ret_value; -#ifdef ENABLE_LOGGING +#ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL DATATYPE Optional\n"); #endif @@ -1391,17 +1402,17 @@ H5VL_pass_through_datatype_optional(void *obj, hid_t dxpl_id, void **req, if(req && *req) *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); - return(ret_value); + return ret_value; } /* end H5VL_pass_through_datatype_optional() */ /*------------------------------------------------------------------------- - * Function: H5VL_pass_through_datatype_close + * Function: H5VL_pass_through_datatype_close * - * Purpose: Closes a datatype. + * Purpose: Closes a datatype. * - * Return: Success: 0 - * Failure: -1, datatype not closed. + * Return: Success: 0 + * Failure: -1, datatype not closed. * *------------------------------------------------------------------------- */ @@ -1411,7 +1422,7 @@ H5VL_pass_through_datatype_close(void *dt, hid_t dxpl_id, void **req) H5VL_pass_through_t *o = (H5VL_pass_through_t *)dt; herr_t ret_value; -#ifdef ENABLE_LOGGING +#ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL DATATYPE Close\n"); #endif @@ -1427,7 +1438,7 @@ H5VL_pass_through_datatype_close(void *dt, hid_t dxpl_id, void **req) if(ret_value >= 0) H5VL_pass_through_free_obj(o); - return(ret_value); + return ret_value; } /* end H5VL_pass_through_datatype_close() */ @@ -1450,7 +1461,7 @@ H5VL_pass_through_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t under_fapl_id; void *under; -#ifdef ENABLE_LOGGING +#ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL FILE Create\n"); #endif @@ -1481,7 +1492,7 @@ H5VL_pass_through_file_create(const char *name, unsigned flags, hid_t fcpl_id, /* Release copy of our VOL info */ H5VL_pass_through_info_free(info); - return((void *)file); + return (void *)file; } /* end H5VL_pass_through_file_create() */ @@ -1504,7 +1515,7 @@ H5VL_pass_through_file_open(const char *name, unsigned flags, hid_t fapl_id, hid_t under_fapl_id; void *under; -#ifdef ENABLE_LOGGING +#ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL FILE Open\n"); #endif @@ -1535,7 +1546,7 @@ H5VL_pass_through_file_open(const char *name, unsigned flags, hid_t fapl_id, /* Release copy of our VOL info */ H5VL_pass_through_info_free(info); - return((void *)file); + return (void *)file; } /* end H5VL_pass_through_file_open() */ @@ -1544,8 +1555,8 @@ H5VL_pass_through_file_open(const char *name, unsigned flags, hid_t fapl_id, * * Purpose: Get info about a file * - * Return: Success: 0 - * Failure: -1 + * Return: Success: 0 + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -1556,7 +1567,7 @@ H5VL_pass_through_file_get(void *file, H5VL_file_get_t get_type, hid_t dxpl_id, H5VL_pass_through_t *o = (H5VL_pass_through_t *)file; herr_t ret_value; -#ifdef ENABLE_LOGGING +#ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL FILE Get\n"); #endif @@ -1566,18 +1577,18 @@ H5VL_pass_through_file_get(void *file, H5VL_file_get_t get_type, hid_t dxpl_id, if(req && *req) *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); - return(ret_value); + return ret_value; } /* end H5VL_pass_through_file_get() */ /*------------------------------------------------------------------------- * Function: H5VL_pass_through_file_specific_reissue * - * Purpose: Re-wrap vararg arguments into a va_list and reissue the - * file specific callback to the underlying VOL connector. + * Purpose: Re-wrap vararg arguments into a va_list and reissue the + * file specific callback to the underlying VOL connector. * - * Return: Success: 0 - * Failure: -1 + * Return: Success: 0 + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -1592,17 +1603,17 @@ H5VL_pass_through_file_specific_reissue(void *obj, hid_t connector_id, ret_value = H5VLfile_specific(obj, connector_id, specific_type, dxpl_id, req, arguments); va_end(arguments); - return(ret_value); + return ret_value; } /* end H5VL_pass_through_file_specific_reissue() */ /*------------------------------------------------------------------------- * Function: H5VL_pass_through_file_specific * - * Purpose: Specific operation on file + * Purpose: Specific operation on file * - * Return: Success: 0 - * Failure: -1 + * Return: Success: 0 + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -1614,7 +1625,7 @@ H5VL_pass_through_file_specific(void *file, H5VL_file_specific_t specific_type, hid_t under_vol_id = -1; herr_t ret_value; -#ifdef ENABLE_LOGGING +#ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL FILE Specific\n"); #endif @@ -1626,7 +1637,7 @@ H5VL_pass_through_file_specific(void *file, H5VL_file_specific_t specific_type, hid_t plist_id; /* Retrieve parameters for 'mount' operation, so we can unwrap the child file */ - loc_type = va_arg(arguments, H5I_type_t); + loc_type = (H5I_type_t)va_arg(arguments, int); /* enum work-around */ name = va_arg(arguments, const char *); child_file = (H5VL_pass_through_t *)va_arg(arguments, void *); plist_id = va_arg(arguments, hid_t); @@ -1635,7 +1646,7 @@ H5VL_pass_through_file_specific(void *file, H5VL_file_specific_t specific_type, under_vol_id = o->under_vol_id; /* Re-issue 'file specific' call, using the unwrapped pieces */ - ret_value = H5VL_pass_through_file_specific_reissue(o->under_object, o->under_vol_id, specific_type, dxpl_id, req, loc_type, name, child_file->under_object, plist_id); + ret_value = H5VL_pass_through_file_specific_reissue(o->under_object, o->under_vol_id, specific_type, dxpl_id, req, (int)loc_type, name, child_file->under_object, plist_id); } /* end if */ else if(specific_type == H5VL_FILE_IS_ACCESSIBLE) { H5VL_pass_through_info_t *info; @@ -1699,7 +1710,7 @@ H5VL_pass_through_file_specific(void *file, H5VL_file_specific_t specific_type, if(req && *req) *req = H5VL_pass_through_new_obj(*req, under_vol_id); - return(ret_value); + return ret_value; } /* end H5VL_pass_through_file_specific() */ @@ -1708,8 +1719,8 @@ H5VL_pass_through_file_specific(void *file, H5VL_file_specific_t specific_type, * * Purpose: Perform a connector-specific operation on a file * - * Return: Success: 0 - * Failure: -1 + * Return: Success: 0 + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -1720,7 +1731,7 @@ H5VL_pass_through_file_optional(void *file, hid_t dxpl_id, void **req, H5VL_pass_through_t *o = (H5VL_pass_through_t *)file; herr_t ret_value; -#ifdef ENABLE_LOGGING +#ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL File Optional\n"); #endif @@ -1730,7 +1741,7 @@ H5VL_pass_through_file_optional(void *file, hid_t dxpl_id, void **req, if(req && *req) *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); - return(ret_value); + return ret_value; } /* end H5VL_pass_through_file_optional() */ @@ -1739,8 +1750,8 @@ H5VL_pass_through_file_optional(void *file, hid_t dxpl_id, void **req, * * Purpose: Closes a file. * - * Return: Success: 0 - * Failure: -1, file not closed. + * Return: Success: 0 + * Failure: -1, file not closed. * *------------------------------------------------------------------------- */ @@ -1750,7 +1761,7 @@ H5VL_pass_through_file_close(void *file, hid_t dxpl_id, void **req) H5VL_pass_through_t *o = (H5VL_pass_through_t *)file; herr_t ret_value; -#ifdef ENABLE_LOGGING +#ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL FILE Close\n"); #endif @@ -1764,7 +1775,7 @@ H5VL_pass_through_file_close(void *file, hid_t dxpl_id, void **req) if(ret_value >= 0) H5VL_pass_through_free_obj(o); - return(ret_value); + return ret_value; } /* end H5VL_pass_through_file_close() */ @@ -1786,7 +1797,7 @@ H5VL_pass_through_group_create(void *obj, const H5VL_loc_params_t *loc_params, H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; void *under; -#ifdef ENABLE_LOGGING +#ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL GROUP Create\n"); #endif @@ -1801,7 +1812,7 @@ H5VL_pass_through_group_create(void *obj, const H5VL_loc_params_t *loc_params, else group = NULL; - return((void *)group); + return (void *)group; } /* end H5VL_pass_through_group_create() */ @@ -1823,7 +1834,7 @@ H5VL_pass_through_group_open(void *obj, const H5VL_loc_params_t *loc_params, H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; void *under; -#ifdef ENABLE_LOGGING +#ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL GROUP Open\n"); #endif @@ -1838,7 +1849,7 @@ H5VL_pass_through_group_open(void *obj, const H5VL_loc_params_t *loc_params, else group = NULL; - return((void *)group); + return (void *)group; } /* end H5VL_pass_through_group_open() */ @@ -1847,8 +1858,8 @@ H5VL_pass_through_group_open(void *obj, const H5VL_loc_params_t *loc_params, * * Purpose: Get info about a group * - * Return: Success: 0 - * Failure: -1 + * Return: Success: 0 + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -1859,7 +1870,7 @@ H5VL_pass_through_group_get(void *obj, H5VL_group_get_t get_type, hid_t dxpl_id, H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; herr_t ret_value; -#ifdef ENABLE_LOGGING +#ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL GROUP Get\n"); #endif @@ -1869,17 +1880,17 @@ H5VL_pass_through_group_get(void *obj, H5VL_group_get_t get_type, hid_t dxpl_id, if(req && *req) *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); - return(ret_value); + return ret_value; } /* end H5VL_pass_through_group_get() */ /*------------------------------------------------------------------------- * Function: H5VL_pass_through_group_specific * - * Purpose: Specific operation on a group + * Purpose: Specific operation on a group * - * Return: Success: 0 - * Failure: -1 + * Return: Success: 0 + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -1890,7 +1901,7 @@ H5VL_pass_through_group_specific(void *obj, H5VL_group_specific_t specific_type, H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; herr_t ret_value; -#ifdef ENABLE_LOGGING +#ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL GROUP Specific\n"); #endif @@ -1900,7 +1911,7 @@ H5VL_pass_through_group_specific(void *obj, H5VL_group_specific_t specific_type, if(req && *req) *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); - return(ret_value); + return ret_value; } /* end H5VL_pass_through_group_specific() */ @@ -1909,8 +1920,8 @@ H5VL_pass_through_group_specific(void *obj, H5VL_group_specific_t specific_type, * * Purpose: Perform a connector-specific operation on a group * - * Return: Success: 0 - * Failure: -1 + * Return: Success: 0 + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -1921,7 +1932,7 @@ H5VL_pass_through_group_optional(void *obj, hid_t dxpl_id, void **req, H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; herr_t ret_value; -#ifdef ENABLE_LOGGING +#ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL GROUP Optional\n"); #endif @@ -1931,7 +1942,7 @@ H5VL_pass_through_group_optional(void *obj, hid_t dxpl_id, void **req, if(req && *req) *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); - return(ret_value); + return ret_value; } /* end H5VL_pass_through_group_optional() */ @@ -1940,8 +1951,8 @@ H5VL_pass_through_group_optional(void *obj, hid_t dxpl_id, void **req, * * Purpose: Closes a group. * - * Return: Success: 0 - * Failure: -1, group not closed. + * Return: Success: 0 + * Failure: -1, group not closed. * *------------------------------------------------------------------------- */ @@ -1951,7 +1962,7 @@ H5VL_pass_through_group_close(void *grp, hid_t dxpl_id, void **req) H5VL_pass_through_t *o = (H5VL_pass_through_t *)grp; herr_t ret_value; -#ifdef ENABLE_LOGGING +#ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL H5Gclose\n"); #endif @@ -1965,17 +1976,17 @@ H5VL_pass_through_group_close(void *grp, hid_t dxpl_id, void **req) if(ret_value >= 0) H5VL_pass_through_free_obj(o); - return(ret_value); + return ret_value; } /* end H5VL_pass_through_group_close() */ /*------------------------------------------------------------------------- - * Function: H5VL_pass_through_link_create + * Function: H5VL_pass_through_link_create * - * Purpose: Creates a hard / soft / UD / external link. + * Purpose: Creates a hard / soft / UD / external link. * - * Return: Success: 0 - * Failure: -1 + * Return: Success: 0 + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -1986,7 +1997,7 @@ H5VL_pass_through_link_create(H5VL_link_create_type_t create_type, void *obj, co hid_t under_vol_id = -1; herr_t ret_value; -#ifdef ENABLE_LOGGING +#ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL LINK Create\n"); #endif @@ -2018,22 +2029,22 @@ H5VL_pass_through_link_create(H5VL_link_create_type_t create_type, void *obj, co if(req && *req) *req = H5VL_pass_through_new_obj(*req, under_vol_id); - return(ret_value); + return ret_value; } /* end H5VL_pass_through_link_create() */ /*------------------------------------------------------------------------- - * Function: H5VL_pass_through_link_copy + * Function: H5VL_pass_through_link_copy * - * Purpose: Renames an object within an HDF5 container and copies it to a new + * Purpose: Renames an object within an HDF5 container and copies it to a new * group. The original name SRC is unlinked from the group graph * and then inserted with the new name DST (which can specify a * new path for the object) as an atomic operation. The names * are interpreted relative to SRC_LOC_ID and * DST_LOC_ID, which are either file IDs or group ID. * - * Return: Success: 0 - * Failure: -1 + * Return: Success: 0 + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -2047,7 +2058,7 @@ H5VL_pass_through_link_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, hid_t under_vol_id = -1; herr_t ret_value; -#ifdef ENABLE_LOGGING +#ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL LINK Copy\n"); #endif @@ -2064,23 +2075,22 @@ H5VL_pass_through_link_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, if(req && *req) *req = H5VL_pass_through_new_obj(*req, under_vol_id); - return(ret_value); + return ret_value; } /* end H5VL_pass_through_link_copy() */ /*------------------------------------------------------------------------- - * Function: -H5VL_pass_through_link_move(void *src_obj, const H5VL_loc_params_t *loc_params1, + * Function: H5VL_pass_through_link_move * - * Purpose: Moves a link within an HDF5 file to a new group. The original - * name SRC is unlinked from the group graph + * Purpose: Moves a link within an HDF5 file to a new group. The original + * name SRC is unlinked from the group graph * and then inserted with the new name DST (which can specify a * new path for the object) as an atomic operation. The names * are interpreted relative to SRC_LOC_ID and * DST_LOC_ID, which are either file IDs or group ID. * - * Return: Success: 0 - * Failure: -1 + * Return: Success: 0 + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -2094,7 +2104,7 @@ H5VL_pass_through_link_move(void *src_obj, const H5VL_loc_params_t *loc_params1, hid_t under_vol_id = -1; herr_t ret_value; -#ifdef ENABLE_LOGGING +#ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL LINK Move\n"); #endif @@ -2111,17 +2121,17 @@ H5VL_pass_through_link_move(void *src_obj, const H5VL_loc_params_t *loc_params1, if(req && *req) *req = H5VL_pass_through_new_obj(*req, under_vol_id); - return(ret_value); + return ret_value; } /* end H5VL_pass_through_link_move() */ /*------------------------------------------------------------------------- - * Function: H5VL_pass_through_link_get + * Function: H5VL_pass_through_link_get * - * Purpose: Get info about a link + * Purpose: Get info about a link * - * Return: Success: 0 - * Failure: -1 + * Return: Success: 0 + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -2132,7 +2142,7 @@ H5VL_pass_through_link_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; herr_t ret_value; -#ifdef ENABLE_LOGGING +#ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL LINK Get\n"); #endif @@ -2142,17 +2152,17 @@ H5VL_pass_through_link_get(void *obj, const H5VL_loc_params_t *loc_params, if(req && *req) *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); - return(ret_value); + return ret_value; } /* end H5VL_pass_through_link_get() */ /*------------------------------------------------------------------------- - * Function: H5VL_pass_through_link_specific + * Function: H5VL_pass_through_link_specific * - * Purpose: Specific operation on a link + * Purpose: Specific operation on a link * - * Return: Success: 0 - * Failure: -1 + * Return: Success: 0 + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -2163,7 +2173,7 @@ H5VL_pass_through_link_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; herr_t ret_value; -#ifdef ENABLE_LOGGING +#ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL LINK Specific\n"); #endif @@ -2173,7 +2183,7 @@ H5VL_pass_through_link_specific(void *obj, const H5VL_loc_params_t *loc_params, if(req && *req) *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); - return(ret_value); + return ret_value; } /* end H5VL_pass_through_link_specific() */ @@ -2182,8 +2192,8 @@ H5VL_pass_through_link_specific(void *obj, const H5VL_loc_params_t *loc_params, * * Purpose: Perform a connector-specific operation on a link * - * Return: Success: 0 - * Failure: -1 + * Return: Success: 0 + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -2194,7 +2204,7 @@ H5VL_pass_through_link_optional(void *obj, hid_t dxpl_id, void **req, H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; herr_t ret_value; -#ifdef ENABLE_LOGGING +#ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL LINK Optional\n"); #endif @@ -2204,17 +2214,17 @@ H5VL_pass_through_link_optional(void *obj, hid_t dxpl_id, void **req, if(req && *req) *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); - return(ret_value); + return ret_value; } /* end H5VL_pass_through_link_optional() */ /*------------------------------------------------------------------------- - * Function: H5VL_pass_through_object_open + * Function: H5VL_pass_through_object_open * - * Purpose: Opens an object inside a container. + * Purpose: Opens an object inside a container. * - * Return: Success: Pointer to object - * Failure: NULL + * Return: Success: Pointer to object + * Failure: NULL * *------------------------------------------------------------------------- */ @@ -2226,7 +2236,7 @@ H5VL_pass_through_object_open(void *obj, const H5VL_loc_params_t *loc_params, H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; void *under; -#ifdef ENABLE_LOGGING +#ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL OBJECT Open\n"); #endif @@ -2241,17 +2251,17 @@ H5VL_pass_through_object_open(void *obj, const H5VL_loc_params_t *loc_params, else new_obj = NULL; - return((void *)new_obj); + return (void *)new_obj; } /* end H5VL_pass_through_object_open() */ /*------------------------------------------------------------------------- - * Function: H5VL_pass_through_object_copy + * Function: H5VL_pass_through_object_copy * - * Purpose: Copies an object inside a container. + * Purpose: Copies an object inside a container. * - * Return: Success: 0 - * Failure: -1 + * Return: Success: 0 + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -2265,7 +2275,7 @@ H5VL_pass_through_object_copy(void *src_obj, const H5VL_loc_params_t *src_loc_pa H5VL_pass_through_t *o_dst = (H5VL_pass_through_t *)dst_obj; herr_t ret_value; -#ifdef ENABLE_LOGGING +#ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL OBJECT Copy\n"); #endif @@ -2275,17 +2285,17 @@ H5VL_pass_through_object_copy(void *src_obj, const H5VL_loc_params_t *src_loc_pa if(req && *req) *req = H5VL_pass_through_new_obj(*req, o_src->under_vol_id); - return(ret_value); + return ret_value; } /* end H5VL_pass_through_object_copy() */ /*------------------------------------------------------------------------- - * Function: H5VL_pass_through_object_get + * Function: H5VL_pass_through_object_get * - * Purpose: Get info about an object + * Purpose: Get info about an object * - * Return: Success: 0 - * Failure: -1 + * Return: Success: 0 + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -2295,7 +2305,7 @@ H5VL_pass_through_object_get(void *obj, const H5VL_loc_params_t *loc_params, H5V H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; herr_t ret_value; -#ifdef ENABLE_LOGGING +#ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL OBJECT Get\n"); #endif @@ -2305,17 +2315,17 @@ H5VL_pass_through_object_get(void *obj, const H5VL_loc_params_t *loc_params, H5V if(req && *req) *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); - return(ret_value); + return ret_value; } /* end H5VL_pass_through_object_get() */ /*------------------------------------------------------------------------- * Function: H5VL_pass_through_object_specific * - * Purpose: Specific operation on an object + * Purpose: Specific operation on an object * - * Return: Success: 0 - * Failure: -1 + * Return: Success: 0 + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -2327,7 +2337,7 @@ H5VL_pass_through_object_specific(void *obj, const H5VL_loc_params_t *loc_params H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; herr_t ret_value; -#ifdef ENABLE_LOGGING +#ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL OBJECT Specific\n"); #endif @@ -2337,17 +2347,17 @@ H5VL_pass_through_object_specific(void *obj, const H5VL_loc_params_t *loc_params if(req && *req) *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); - return(ret_value); + return ret_value; } /* end H5VL_pass_through_object_specific() */ /*------------------------------------------------------------------------- - * Function: H5VL_pass_through_object_optional + * Function: H5VL_pass_through_object_optional * - * Purpose: Perform a connector-specific operation for an object + * Purpose: Perform a connector-specific operation for an object * - * Return: Success: 0 - * Failure: -1 + * Return: Success: 0 + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -2358,7 +2368,7 @@ H5VL_pass_through_object_optional(void *obj, hid_t dxpl_id, void **req, H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; herr_t ret_value; -#ifdef ENABLE_LOGGING +#ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL OBJECT Optional\n"); #endif @@ -2368,20 +2378,20 @@ H5VL_pass_through_object_optional(void *obj, hid_t dxpl_id, void **req, if(req && *req) *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); - return(ret_value); + return ret_value; } /* end H5VL_pass_through_object_optional() */ /*------------------------------------------------------------------------- - * Function: H5VL_pass_through_request_wait + * Function: H5VL_pass_through_request_wait * - * Purpose: Wait (with a timeout) for an async operation to complete + * Purpose: Wait (with a timeout) for an async operation to complete * - * Note: Releases the request if the operation has completed and the - * connector callback succeeds + * Note: Releases the request if the operation has completed and the + * connector callback succeeds * - * Return: Success: 0 - * Failure: -1 + * Return: Success: 0 + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -2392,7 +2402,7 @@ H5VL_pass_through_request_wait(void *obj, uint64_t timeout, H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; herr_t ret_value; -#ifdef ENABLE_LOGGING +#ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL REQUEST Wait\n"); #endif @@ -2401,20 +2411,20 @@ H5VL_pass_through_request_wait(void *obj, uint64_t timeout, if(ret_value >= 0 && *status != H5ES_STATUS_IN_PROGRESS) H5VL_pass_through_free_obj(o); - return(ret_value); + return ret_value; } /* end H5VL_pass_through_request_wait() */ /*------------------------------------------------------------------------- - * Function: H5VL_pass_through_request_notify + * Function: H5VL_pass_through_request_notify * * Purpose: Registers a user callback to be invoked when an asynchronous - * operation completes + * operation completes * - * Note: Releases the request, if connector callback succeeds + * Note: Releases the request, if connector callback succeeds * - * Return: Success: 0 - * Failure: -1 + * Return: Success: 0 + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -2424,7 +2434,7 @@ H5VL_pass_through_request_notify(void *obj, H5VL_request_notify_t cb, void *ctx) H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; herr_t ret_value; -#ifdef ENABLE_LOGGING +#ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL REQUEST Wait\n"); #endif @@ -2433,19 +2443,19 @@ H5VL_pass_through_request_notify(void *obj, H5VL_request_notify_t cb, void *ctx) if(ret_value >= 0) H5VL_pass_through_free_obj(o); - return(ret_value); + return ret_value; } /* end H5VL_pass_through_request_notify() */ /*------------------------------------------------------------------------- - * Function: H5VL_pass_through_request_cancel + * Function: H5VL_pass_through_request_cancel * * Purpose: Cancels an asynchronous operation * - * Note: Releases the request, if connector callback succeeds + * Note: Releases the request, if connector callback succeeds * - * Return: Success: 0 - * Failure: -1 + * Return: Success: 0 + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -2455,7 +2465,7 @@ H5VL_pass_through_request_cancel(void *obj) H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; herr_t ret_value; -#ifdef ENABLE_LOGGING +#ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL REQUEST Cancel\n"); #endif @@ -2464,18 +2474,18 @@ H5VL_pass_through_request_cancel(void *obj) if(ret_value >= 0) H5VL_pass_through_free_obj(o); - return(ret_value); + return ret_value; } /* end H5VL_pass_through_request_cancel() */ /*------------------------------------------------------------------------- * Function: H5VL_pass_through_request_specific_reissue * - * Purpose: Re-wrap vararg arguments into a va_list and reissue the - * request specific callback to the underlying VOL connector. + * Purpose: Re-wrap vararg arguments into a va_list and reissue the + * request specific callback to the underlying VOL connector. * - * Return: Success: 0 - * Failure: -1 + * Return: Success: 0 + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -2490,17 +2500,17 @@ H5VL_pass_through_request_specific_reissue(void *obj, hid_t connector_id, ret_value = H5VLrequest_specific(obj, connector_id, specific_type, arguments); va_end(arguments); - return(ret_value); + return ret_value; } /* end H5VL_pass_through_request_specific_reissue() */ /*------------------------------------------------------------------------- * Function: H5VL_pass_through_request_specific * - * Purpose: Specific operation on a request + * Purpose: Specific operation on a request * - * Return: Success: 0 - * Failure: -1 + * Return: Success: 0 + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -2510,7 +2520,7 @@ H5VL_pass_through_request_specific(void *obj, H5VL_request_specific_t specific_t { herr_t ret_value = -1; -#ifdef ENABLE_LOGGING +#ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL REQUEST Specific\n"); #endif @@ -2632,17 +2642,17 @@ H5VL_pass_through_request_specific(void *obj, H5VL_request_specific_t specific_t else assert(0 && "Unknown 'specific' operation"); - return(ret_value); + return ret_value; } /* end H5VL_pass_through_request_specific() */ /*------------------------------------------------------------------------- - * Function: H5VL_pass_through_request_optional + * Function: H5VL_pass_through_request_optional * - * Purpose: Perform a connector-specific operation for a request + * Purpose: Perform a connector-specific operation for a request * - * Return: Success: 0 - * Failure: -1 + * Return: Success: 0 + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -2652,24 +2662,24 @@ H5VL_pass_through_request_optional(void *obj, va_list arguments) H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; herr_t ret_value; -#ifdef ENABLE_LOGGING +#ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL REQUEST Optional\n"); #endif ret_value = H5VLrequest_optional(o->under_object, o->under_vol_id, arguments); - return(ret_value); + return ret_value; } /* end H5VL_pass_through_request_optional() */ /*------------------------------------------------------------------------- - * Function: H5VL_pass_through_request_free + * Function: H5VL_pass_through_request_free * * Purpose: Releases a request, allowing the operation to complete without - * application tracking + * application tracking * - * Return: Success: 0 - * Failure: -1 + * Return: Success: 0 + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -2679,7 +2689,7 @@ H5VL_pass_through_request_free(void *obj) H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; herr_t ret_value; -#ifdef ENABLE_LOGGING +#ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL REQUEST Free\n"); #endif @@ -2688,6 +2698,6 @@ H5VL_pass_through_request_free(void *obj) if(ret_value >= 0) H5VL_pass_through_free_obj(o); - return(ret_value); + return ret_value; } /* end H5VL_pass_through_request_free() */ diff --git a/src/H5VLpublic.h b/src/H5VLpublic.h index b276128..5de36c8 100644 --- a/src/H5VLpublic.h +++ b/src/H5VLpublic.h @@ -115,7 +115,7 @@ typedef enum H5VL_file_get_t { H5VL_FILE_GET_INTENT, /* file intent */ H5VL_FILE_GET_NAME, /* file name */ H5VL_FILE_GET_OBJ_COUNT, /* object count in file */ - H5VL_FILE_GET_OBJ_IDS /* object ids in file */ + H5VL_FILE_GET_OBJ_IDS /* object ids in file */ } H5VL_file_get_t; /* types for file SPECIFIC callback */ @@ -124,8 +124,7 @@ typedef enum H5VL_file_specific_t { H5VL_FILE_REOPEN, /* Reopen the file */ H5VL_FILE_MOUNT, /* Mount a file */ H5VL_FILE_UNMOUNT, /* Unmount a file */ - H5VL_FILE_IS_ACCESSIBLE, /* Check if a file is accessible */ - H5VL_FILE_CACHE_VOL_CONN /* Cache VOL connector ID & info */ + H5VL_FILE_IS_ACCESSIBLE /* Check if a file is accessible */ } H5VL_file_specific_t; /* types for group GET callback */ diff --git a/src/H5err.txt b/src/H5err.txt index 3965242..93a3abd 100644 --- a/src/H5err.txt +++ b/src/H5err.txt @@ -181,7 +181,7 @@ MINOR, CACHE, H5E_CANTRESIZE, Unable to resize a metadata cache entry MINOR, CACHE, H5E_CANTDEPEND, Unable to create a flush dependency MINOR, CACHE, H5E_CANTUNDEPEND, Unable to destroy a flush dependency MINOR, CACHE, H5E_CANTNOTIFY, Unable to notify object about action -MINOR, CACHE, H5E_LOGFAIL, Failure in the cache logging framework +MINOR, CACHE, H5E_LOGGING, Failure in the cache logging framework MINOR, CACHE, H5E_CANTCORK, Unable to cork an object MINOR, CACHE, H5E_CANTUNCORK, Unable to uncork an object diff --git a/src/H5private.h b/src/H5private.h index 05bfc63..a3056a4 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -1396,6 +1396,9 @@ typedef off_t h5_stat_size_t; #ifndef HDstrtok #define HDstrtok(X,Y) strtok(X,Y) #endif /* HDstrtok */ +#ifndef HDstrtok_r + #define HDstrtok_r(X,Y,Z) strtok_r(X,Y,Z) +#endif /* HDstrtok */ #ifndef HDstrtol #define HDstrtol(S,R,N) strtol(S,R,N) #endif /* HDstrtol */ @@ -1498,6 +1501,9 @@ typedef off_t h5_stat_size_t; #ifndef HDva_arg #define HDva_arg(A,T) va_arg(A,T) #endif /* HDva_arg */ +#ifndef HDva_copy +#define HDva_copy(D,S) va_copy(D,S) +#endif /* HDva_copy */ #ifndef HDva_end #define HDva_end(A) va_end(A) #endif /* HDva_end */ diff --git a/src/H5system.c b/src/H5system.c index 2d29650..f47d057 100644 --- a/src/H5system.c +++ b/src/H5system.c @@ -121,7 +121,7 @@ HDfprintf(FILE *stream, const char *fmt, ...) HDassert(stream); HDassert(fmt); - va_start (ap, fmt); + HDva_start (ap, fmt); while (*fmt) { fwidth = prec = 0; zerofill = 0; @@ -170,7 +170,7 @@ HDfprintf(FILE *stream, const char *fmt, ...) s = rest; } /* end if */ else if ('*'==*s) { - fwidth = va_arg(ap, int); + fwidth = HDva_arg(ap, int); if(fwidth < 0) { leftjust = 1; fwidth = -fwidth; @@ -185,7 +185,7 @@ HDfprintf(FILE *stream, const char *fmt, ...) prec = (int)HDstrtol(s, &rest, 10); s = rest; } else if('*'==*s) { - prec = va_arg(ap, int); + prec = HDva_arg(ap, int); s++; } if(prec < 1) @@ -272,16 +272,16 @@ HDfprintf(FILE *stream, const char *fmt, ...) case 'd': case 'i': if(!HDstrcmp(modifier, "h")) { - short x = (short)va_arg(ap, int); + short x = (short)HDva_arg(ap, int); n = fprintf(stream, format_templ, x); } else if(!*modifier) { - int x = va_arg(ap, int); + int x = HDva_arg(ap, int); n = fprintf(stream, format_templ, x); } else if(!HDstrcmp(modifier, "l")) { - long x = va_arg(ap, long); + long x = HDva_arg(ap, long); n = fprintf(stream, format_templ, x); } else { - int64_t x = va_arg(ap, int64_t); + int64_t x = HDva_arg(ap, int64_t); n = fprintf(stream, format_templ, x); } break; @@ -291,16 +291,16 @@ HDfprintf(FILE *stream, const char *fmt, ...) case 'x': case 'X': if(!HDstrcmp(modifier, "h")) { - unsigned short x = (unsigned short)va_arg(ap, unsigned int); + unsigned short x = (unsigned short)HDva_arg(ap, unsigned int); n = fprintf(stream, format_templ, x); } else if(!*modifier) { - unsigned int x = va_arg(ap, unsigned int); + unsigned int x = HDva_arg(ap, unsigned int); n = fprintf(stream, format_templ, x); } else if(!HDstrcmp(modifier, "l")) { - unsigned long x = va_arg(ap, unsigned long); + unsigned long x = HDva_arg(ap, unsigned long); n = fprintf(stream, format_templ, x); } else { - uint64_t x = va_arg(ap, uint64_t); + uint64_t x = HDva_arg(ap, uint64_t); n = fprintf(stream, format_templ, x); } break; @@ -311,10 +311,10 @@ HDfprintf(FILE *stream, const char *fmt, ...) case 'g': case 'G': if(!HDstrcmp(modifier, "h")) { - float x = (float)va_arg(ap, double); + float x = (float)HDva_arg(ap, double); n = fprintf(stream, format_templ, (double)x); } else if(!*modifier || !HDstrcmp(modifier, "l")) { - double x = va_arg(ap, double); + double x = HDva_arg(ap, double); n = fprintf(stream, format_templ, x); } else { /* @@ -322,10 +322,10 @@ HDfprintf(FILE *stream, const char *fmt, ...) * `double' are the same thing. */ #if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE - long double x = va_arg(ap, long double); + long double x = HDva_arg(ap, long double); n = fprintf(stream, format_templ, x); #else - double x = va_arg(ap, double); + double x = HDva_arg(ap, double); n = fprintf(stream, format_templ, x); #endif } @@ -333,7 +333,7 @@ HDfprintf(FILE *stream, const char *fmt, ...) case 'a': { - haddr_t x = va_arg(ap, haddr_t); + haddr_t x = HDva_arg(ap, haddr_t); if(H5F_addr_defined(x)) { len = 0; @@ -379,7 +379,7 @@ HDfprintf(FILE *stream, const char *fmt, ...) case 'c': { - char x = (char)va_arg(ap, int); + char x = (char)HDva_arg(ap, int); n = fprintf(stream, format_templ, x); } break; @@ -387,7 +387,7 @@ HDfprintf(FILE *stream, const char *fmt, ...) case 's': case 'p': { - char *x = va_arg(ap, char*); + char *x = HDva_arg(ap, char*); n = fprintf(stream, format_templ, x); } break; @@ -399,7 +399,7 @@ HDfprintf(FILE *stream, const char *fmt, ...) case 't': { - htri_t tri_var = va_arg(ap, htri_t); + htri_t tri_var = HDva_arg(ap, htri_t); if(tri_var > 0) fprintf(stream, "TRUE"); @@ -423,7 +423,7 @@ HDfprintf(FILE *stream, const char *fmt, ...) nout++; } } - va_end(ap); + HDva_end(ap); return nout; } /* end HDfprintf() */ @@ -492,7 +492,8 @@ HDstrtoll(const char *s, const char **rest, int base) /* Optional minus or plus sign */ if ('+'==*s) { s++; - } else if ('-'==*s) { + } + else if ('-'==*s) { sign = -1; s++; } @@ -501,10 +502,12 @@ HDstrtoll(const char *s, const char **rest, int base) if (0==base && '0'==*s && ('x'==s[1] || 'X'==s[1])) { base = 16; s += 2; - } else if (0==base && '0'==*s) { + } + else if (0==base && '0'==*s) { base = 8; s++; - } else if (0==base) { + } + else if (0==base) { base = 10; } @@ -525,7 +528,8 @@ HDstrtoll(const char *s, const char **rest, int base) if (acc*base+digit < acc) { overflow = TRUE; - } else { + } + else { acc = acc*base + digit; } } @@ -536,7 +540,8 @@ HDstrtoll(const char *s, const char **rest, int base) if (overflow) { if (sign>0) { acc = ((uint64_t)1<<(8*sizeof(int64_t)-1))-1; - } else { + } + else { acc = (int64_t)((uint64_t)1<<(8*sizeof(int64_t)-1)); } errno = ERANGE; @@ -843,9 +848,9 @@ int c99_snprintf(char* str, size_t size, const char* format, ...) int count; va_list ap; - va_start(ap, format); + HDva_start(ap, format); count = c99_vsnprintf(str, size, format, ap); - va_end(ap); + HDva_end(ap); return count; } diff --git a/src/H5trace.c b/src/H5trace.c index d5aad06..9a13193 100644 --- a/src/H5trace.c +++ b/src/H5trace.c @@ -135,7 +135,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) if(!out) return 0.0F; /*tracing is off*/ - va_start(ap, type); + HDva_start(ap, type); if(H5_debug_g.ttop) { if(returning) { @@ -227,7 +227,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) * name is the null pointer then don't print the argument or the * following `='. This is used for return values. */ - argname = va_arg(ap, char *); + argname = HDva_arg(ap, char *); if(argname) { unsigned n = (unsigned)MAX (0, (int)HDstrlen(argname) - 3); @@ -243,7 +243,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) /* The value */ if(ptr) - vp = va_arg(ap, void *); + vp = HDva_arg(ap, void *); switch(type[0]) { case 'a': if(ptr) { @@ -253,7 +253,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - haddr_t addr = va_arg(ap, haddr_t); + haddr_t addr = HDva_arg(ap, haddr_t); HDfprintf(out, "%a", addr); } /* end else */ @@ -267,8 +267,8 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - /* Can't pass hbool_t to va_arg() */ - hbool_t bool_var = (hbool_t)va_arg(ap, int); + /* Can't pass hbool_t to HDva_arg() */ + hbool_t bool_var = (hbool_t)HDva_arg(ap, int); if(TRUE == bool_var) HDfprintf(out, "TRUE"); else if(!bool_var) @@ -286,7 +286,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - double dbl = va_arg(ap, double); + double dbl = HDva_arg(ap, double); HDfprintf(out, "%g", dbl); } /* end else */ @@ -302,7 +302,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5D_alloc_time_t alloc_time = (H5D_alloc_time_t)va_arg(ap, int); + H5D_alloc_time_t alloc_time = (H5D_alloc_time_t)HDva_arg(ap, int); switch(alloc_time) { case H5D_ALLOC_TIME_ERROR: @@ -340,7 +340,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5FD_mpio_collective_opt_t opt = (H5FD_mpio_collective_opt_t)va_arg(ap, int); + H5FD_mpio_collective_opt_t opt = (H5FD_mpio_collective_opt_t)HDva_arg(ap, int); switch(opt) { case H5FD_MPIO_COLLECTIVE_IO: @@ -366,7 +366,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5D_fill_time_t fill_time = (H5D_fill_time_t)va_arg(ap, int); + H5D_fill_time_t fill_time = (H5D_fill_time_t)HDva_arg(ap, int); switch(fill_time) { case H5D_FILL_TIME_ERROR: @@ -400,7 +400,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5D_fill_value_t fill_value = (H5D_fill_value_t)va_arg(ap, int); + H5D_fill_value_t fill_value = (H5D_fill_value_t)HDva_arg(ap, int); switch(fill_value) { case H5D_FILL_VALUE_ERROR: @@ -434,7 +434,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5FD_mpio_chunk_opt_t opt = (H5FD_mpio_chunk_opt_t)va_arg(ap, int); + H5FD_mpio_chunk_opt_t opt = (H5FD_mpio_chunk_opt_t)HDva_arg(ap, int); switch(opt) { case H5FD_MPIO_CHUNK_DEFAULT: @@ -464,7 +464,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5D_mpio_actual_io_mode_t actual_io_mode = (H5D_mpio_actual_io_mode_t)va_arg(ap, int); + H5D_mpio_actual_io_mode_t actual_io_mode = (H5D_mpio_actual_io_mode_t)HDva_arg(ap, int); switch(actual_io_mode) { case H5D_MPIO_NO_COLLECTIVE: @@ -502,7 +502,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5D_chunk_index_t idx = (H5D_chunk_index_t)va_arg(ap, int); + H5D_chunk_index_t idx = (H5D_chunk_index_t)HDva_arg(ap, int); switch(idx) { case H5D_CHUNK_IDX_BTREE: @@ -548,7 +548,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5D_layout_t layout = (H5D_layout_t)va_arg(ap, int); + H5D_layout_t layout = (H5D_layout_t)HDva_arg(ap, int); switch(layout) { case H5D_LAYOUT_ERROR: @@ -590,7 +590,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5D_mpio_no_collective_cause_t nocol_cause_mode = (H5D_mpio_no_collective_cause_t)va_arg(ap, int); + H5D_mpio_no_collective_cause_t nocol_cause_mode = (H5D_mpio_no_collective_cause_t)HDva_arg(ap, int); hbool_t flag_already_displayed = FALSE; /* Check for all bit-flags which might be set */ @@ -637,7 +637,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5D_mpio_actual_chunk_opt_mode_t chunk_opt_mode = (H5D_mpio_actual_chunk_opt_mode_t)va_arg(ap, int); + H5D_mpio_actual_chunk_opt_mode_t chunk_opt_mode = (H5D_mpio_actual_chunk_opt_mode_t)HDva_arg(ap, int); switch(chunk_opt_mode) { case H5D_MPIO_NO_CHUNK_OPTIMIZATION: @@ -667,7 +667,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5D_space_status_t space_status = (H5D_space_status_t)va_arg(ap, int); + H5D_space_status_t space_status = (H5D_space_status_t)HDva_arg(ap, int); switch(space_status) { case H5D_SPACE_STATUS_NOT_ALLOCATED: @@ -701,7 +701,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5FD_mpio_xfer_t transfer = (H5FD_mpio_xfer_t)va_arg(ap, int); + H5FD_mpio_xfer_t transfer = (H5FD_mpio_xfer_t)HDva_arg(ap, int); switch(transfer) { case H5FD_MPIO_INDEPENDENT: @@ -727,7 +727,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5D_vds_view_t view = (H5D_vds_view_t)va_arg(ap, int); + H5D_vds_view_t view = (H5D_vds_view_t)HDva_arg(ap, int); switch(view) { case H5D_VDS_ERROR: @@ -763,7 +763,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - herr_t status = va_arg(ap, herr_t); + herr_t status = HDva_arg(ap, herr_t); if(status >= 0) HDfprintf(out, "SUCCEED"); @@ -782,7 +782,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5E_direction_t direction = (H5E_direction_t)va_arg(ap, int); + H5E_direction_t direction = (H5E_direction_t)HDva_arg(ap, int); switch(direction) { case H5E_WALK_UPWARD: @@ -808,7 +808,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5E_error2_t *error = va_arg(ap, H5E_error2_t *); + H5E_error2_t *error = HDva_arg(ap, H5E_error2_t *); HDfprintf(out, "0x%lx", (unsigned long)error); } /* end else */ @@ -822,7 +822,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5ES_status_t status = (H5ES_status_t)va_arg(ap, int); + H5ES_status_t status = (H5ES_status_t)HDva_arg(ap, int); switch(status) { case H5ES_STATUS_IN_PROGRESS: @@ -853,7 +853,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5E_type_t etype = (H5E_type_t)va_arg(ap, int); + H5E_type_t etype = (H5E_type_t)HDva_arg(ap, int); switch(etype) { case H5E_MAJOR: @@ -887,7 +887,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5F_close_degree_t degree = (H5F_close_degree_t)va_arg(ap, int); + H5F_close_degree_t degree = (H5F_close_degree_t)HDva_arg(ap, int); switch(degree) { case H5F_CLOSE_DEFAULT: @@ -921,7 +921,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5F_fspace_strategy_t fs_strategy = (H5F_fspace_strategy_t)va_arg(ap, int); + H5F_fspace_strategy_t fs_strategy = (H5F_fspace_strategy_t)HDva_arg(ap, int); switch(fs_strategy) { case H5F_FSPACE_STRATEGY_FSM_AGGR: @@ -956,7 +956,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5F_mem_t mem_type = (H5F_mem_t)va_arg(ap, int); + H5F_mem_t mem_type = (H5F_mem_t)HDva_arg(ap, int); switch(mem_type) { case H5FD_MEM_NOLIST: @@ -1007,7 +1007,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5F_scope_t scope = (H5F_scope_t)va_arg(ap, int); + H5F_scope_t scope = (H5F_scope_t)HDva_arg(ap, int); switch(scope) { case H5F_SCOPE_LOCAL: @@ -1042,7 +1042,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5F_libver_t libver_vers = (H5F_libver_t)va_arg(ap, int); + H5F_libver_t libver_vers = (H5F_libver_t)HDva_arg(ap, int); switch(libver_vers) { case H5F_LIBVER_EARLIEST: @@ -1084,7 +1084,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5G_obj_t obj_type = (H5G_obj_t)va_arg(ap, int); + H5G_obj_t obj_type = (H5G_obj_t)HDva_arg(ap, int); switch(obj_type) { case H5G_UNKNOWN: @@ -1132,7 +1132,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5G_stat_t *statbuf = va_arg(ap, H5G_stat_t*); + H5G_stat_t *statbuf = HDva_arg(ap, H5G_stat_t*); HDfprintf(out, "0x%lx", (unsigned long)statbuf); } @@ -1166,7 +1166,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - hsize_t hsize = va_arg(ap, hsize_t); + hsize_t hsize = HDva_arg(ap, hsize_t); if(H5S_UNLIMITED == hsize) HDfprintf(out, "H5S_UNLIMITED"); @@ -1196,7 +1196,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - hssize_t hssize = va_arg(ap, hssize_t); + hssize_t hssize = HDva_arg(ap, hssize_t); HDfprintf(out, "%Hd", hssize); asize[argno] = (hssize_t)hssize; @@ -1217,7 +1217,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - hid_t obj = va_arg(ap, hid_t); + hid_t obj = HDva_arg(ap, hid_t); if(H5P_DEFAULT == obj) HDfprintf(out, "H5P_DEFAULT"); @@ -1355,10 +1355,6 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld (attr)", (long)obj); break; - case H5I_REFERENCE: - HDfprintf(out, "%ld (reference)", (long)obj); - break; - case H5I_VFL: HDfprintf(out, "%ld (file driver)", (long)obj); break; @@ -1409,7 +1405,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5_index_t idx_type = (H5_index_t)va_arg(ap, int); + H5_index_t idx_type = (H5_index_t)HDva_arg(ap, int); switch(idx_type) { case H5_INDEX_UNKNOWN: @@ -1443,7 +1439,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5_iter_order_t order = (H5_iter_order_t)va_arg(ap, int); + H5_iter_order_t order = (H5_iter_order_t)HDva_arg(ap, int); switch(order) { case H5_ITER_UNKNOWN: @@ -1490,7 +1486,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - int is = va_arg(ap, int); + int is = HDva_arg(ap, int); HDfprintf (out, "%d", is); asize[argno] = is; @@ -1505,7 +1501,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5I_type_t id_type = (H5I_type_t)va_arg(ap, int); + H5I_type_t id_type = (H5I_type_t)HDva_arg(ap, int); switch (id_type) { case H5I_UNINIT: @@ -1540,10 +1536,6 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "H5I_ATTR"); break; - case H5I_REFERENCE: - HDfprintf(out, "H5I_REFERENCE"); - break; - case H5I_VFL: HDfprintf(out, "H5I_VFL"); break; @@ -1600,7 +1592,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - unsigned iu = va_arg(ap, unsigned); + unsigned iu = HDva_arg(ap, unsigned); HDfprintf(out, "%u", iu); asize[argno] = iu; @@ -1623,7 +1615,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5L_type_t link_type = (H5L_type_t)va_arg(ap, int); + H5L_type_t link_type = (H5L_type_t)HDva_arg(ap, int); switch(link_type) { case H5L_TYPE_ERROR: @@ -1670,7 +1662,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) } /* end if */ #ifdef H5_HAVE_PARALLEL else { - MPI_Comm comm = va_arg(ap, MPI_Comm); + MPI_Comm comm = HDva_arg(ap, MPI_Comm); HDfprintf(out, "%ld", (long)comm); } /* end else */ @@ -1686,7 +1678,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) } /* end if */ #ifdef H5_HAVE_PARALLEL else { - MPI_Info info = va_arg(ap, MPI_Info); + MPI_Info info = HDva_arg(ap, MPI_Info); HDfprintf(out, "%ld", (long)info); } /* end else */ @@ -1701,7 +1693,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5FD_mem_t mt = (H5FD_mem_t)va_arg(ap, int); + H5FD_mem_t mt = (H5FD_mem_t)HDva_arg(ap, int); switch(mt) { case H5FD_MEM_NOLIST: @@ -1760,7 +1752,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - off_t offset = va_arg(ap, off_t); + off_t offset = HDva_arg(ap, off_t); HDfprintf (out, "%ld", (long)offset); } /* end else */ @@ -1776,7 +1768,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5O_type_t objtype = (H5O_type_t)va_arg(ap, int); + H5O_type_t objtype = (H5O_type_t)HDva_arg(ap, int); switch(objtype) { case H5O_TYPE_UNKNOWN: @@ -1820,7 +1812,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - hid_t pclass_id = va_arg(ap, hid_t); + hid_t pclass_id = HDva_arg(ap, hid_t); char *class_name = NULL; H5P_genclass_t *pclass; @@ -1844,7 +1836,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - hobj_ref_t ref = va_arg(ap, hobj_ref_t); + hobj_ref_t ref = HDva_arg(ap, hobj_ref_t); HDfprintf(out, "Reference Object=%a", ref); } /* end else */ @@ -1860,7 +1852,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5R_type_t reftype = (H5R_type_t)va_arg(ap, int); + H5R_type_t reftype = (H5R_type_t)HDva_arg(ap, int); switch(reftype) { case H5R_BADTYPE: @@ -1902,7 +1894,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5S_class_t cls = (H5S_class_t)va_arg(ap, int); + H5S_class_t cls = (H5S_class_t)HDva_arg(ap, int); switch(cls) { case H5S_NO_CLASS: @@ -1936,7 +1928,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5S_seloper_t so = (H5S_seloper_t)va_arg(ap, int); + H5S_seloper_t so = (H5S_seloper_t)HDva_arg(ap, int); switch(so) { case H5S_SELECT_NOOP: @@ -1994,7 +1986,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5S_sel_type st = (H5S_sel_type)va_arg(ap, int); + H5S_sel_type st = (H5S_sel_type)HDva_arg(ap, int); switch(st) { case H5S_SEL_ERROR: @@ -2042,7 +2034,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - const char *str = va_arg(ap, const char *); + const char *str = HDva_arg(ap, const char *); HDfprintf(out, "\"%s\"", str); } /* end else */ @@ -2058,7 +2050,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5T_cset_t cset = (H5T_cset_t)va_arg(ap, int); + H5T_cset_t cset = (H5T_cset_t)HDva_arg(ap, int); switch(cset) { case H5T_CSET_ERROR: @@ -2105,7 +2097,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5T_direction_t direct = (H5T_direction_t)va_arg(ap, int); + H5T_direction_t direct = (H5T_direction_t)HDva_arg(ap, int); switch(direct) { case H5T_DIR_DEFAULT: @@ -2135,7 +2127,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5T_pers_t pers = (H5T_pers_t)va_arg(ap, int); + H5T_pers_t pers = (H5T_pers_t)HDva_arg(ap, int); switch(pers) { case H5T_PERS_DONTCARE: @@ -2165,7 +2157,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5T_norm_t norm = (H5T_norm_t)va_arg(ap, int); + H5T_norm_t norm = (H5T_norm_t)HDva_arg(ap, int); switch(norm) { case H5T_NORM_ERROR: @@ -2199,7 +2191,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5T_order_t order = (H5T_order_t)va_arg(ap, int); + H5T_order_t order = (H5T_order_t)HDva_arg(ap, int); switch(order) { case H5T_ORDER_ERROR: @@ -2241,7 +2233,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5T_pad_t pad = (H5T_pad_t)va_arg(ap, int); + H5T_pad_t pad = (H5T_pad_t)HDva_arg(ap, int); switch(pad) { case H5T_PAD_ERROR: @@ -2279,7 +2271,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5T_sign_t sign = (H5T_sign_t)va_arg(ap, int); + H5T_sign_t sign = (H5T_sign_t)HDva_arg(ap, int); switch(sign) { case H5T_SGN_ERROR: @@ -2313,7 +2305,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5T_class_t type_class = (H5T_class_t)va_arg(ap, int); + H5T_class_t type_class = (H5T_class_t)HDva_arg(ap, int); switch(type_class) { case H5T_NO_CLASS: @@ -2383,7 +2375,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5T_str_t str = (H5T_str_t)va_arg(ap, int); + H5T_str_t str = (H5T_str_t)HDva_arg(ap, int); switch(str) { case H5T_STR_ERROR: @@ -2439,7 +2431,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - htri_t tri_var = va_arg (ap, htri_t); + htri_t tri_var = HDva_arg (ap, htri_t); if(tri_var>0) HDfprintf (out, "TRUE"); @@ -2469,7 +2461,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - unsigned long iul = va_arg(ap, unsigned long); + unsigned long iul = HDva_arg(ap, unsigned long); HDfprintf(out, "%lu", iul); asize[argno] = (hssize_t)iul; @@ -2493,7 +2485,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - unsigned long long iull = va_arg(ap, unsigned long long); + unsigned long long iull = HDva_arg(ap, unsigned long long); HDfprintf(out, "%llu", iull); asize[argno] = (hssize_t)iull; @@ -2516,7 +2508,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5VL_attr_get_t get = (H5VL_attr_get_t)va_arg(ap, int); + H5VL_attr_get_t get = (H5VL_attr_get_t)HDva_arg(ap, int); switch(get) { case H5VL_ATTR_GET_SPACE: @@ -2551,7 +2543,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5VL_attr_specific_t specific = (H5VL_attr_specific_t)va_arg(ap, int); + H5VL_attr_specific_t specific = (H5VL_attr_specific_t)HDva_arg(ap, int); switch(specific) { case H5VL_ATTR_DELETE: @@ -2580,7 +2572,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5VL_class_value_t class_val = (H5VL_class_value_t)va_arg(ap, H5VL_class_value_t); + H5VL_class_value_t class_val = (H5VL_class_value_t)HDva_arg(ap, H5VL_class_value_t); if(H5_VOL_NATIVE == class_val) HDfprintf(out, "H5_VOL_NATIVE"); @@ -2596,7 +2588,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5VL_dataset_get_t get = (H5VL_dataset_get_t)va_arg(ap, int); + H5VL_dataset_get_t get = (H5VL_dataset_get_t)HDva_arg(ap, int); switch(get) { case H5VL_DATASET_GET_SPACE: @@ -2634,7 +2626,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5VL_dataset_specific_t specific = (H5VL_dataset_specific_t)va_arg(ap, int); + H5VL_dataset_specific_t specific = (H5VL_dataset_specific_t)HDva_arg(ap, int); switch(specific) { case H5VL_DATASET_SET_EXTENT: @@ -2660,7 +2652,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5VL_datatype_get_t get = (H5VL_datatype_get_t)va_arg(ap, int); + H5VL_datatype_get_t get = (H5VL_datatype_get_t)HDva_arg(ap, int); switch(get) { case H5VL_DATATYPE_GET_BINARY: @@ -2683,7 +2675,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5VL_datatype_specific_t specific = (H5VL_datatype_specific_t)va_arg(ap, int); + H5VL_datatype_specific_t specific = (H5VL_datatype_specific_t)HDva_arg(ap, int); switch(specific) { case H5VL_DATATYPE_FLUSH: @@ -2706,7 +2698,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5VL_file_get_t get = (H5VL_file_get_t)va_arg(ap, int); + H5VL_file_get_t get = (H5VL_file_get_t)HDva_arg(ap, int); switch(get) { case H5VL_FILE_GET_FAPL: @@ -2741,7 +2733,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5VL_file_specific_t specific = (H5VL_file_specific_t)va_arg(ap, int); + H5VL_file_specific_t specific = (H5VL_file_specific_t)HDva_arg(ap, int); switch(specific) { case H5VL_FILE_FLUSH: @@ -2759,9 +2751,6 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case H5VL_FILE_IS_ACCESSIBLE: HDfprintf(out, "H5VL_FILE_IS_ACCESSIBLE"); break; - case H5VL_FILE_CACHE_VOL_CONN: - HDfprintf(out, "H5VL_FILE_CACHE_VOL_CONN"); - break; default: HDfprintf(out, "%ld", (long)specific); break; @@ -2776,7 +2765,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5VL_group_get_t get = (H5VL_group_get_t)va_arg(ap, int); + H5VL_group_get_t get = (H5VL_group_get_t)HDva_arg(ap, int); switch(get) { case H5VL_GROUP_GET_GCPL: @@ -2799,7 +2788,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5VL_group_specific_t specific = (H5VL_group_specific_t)va_arg(ap, int); + H5VL_group_specific_t specific = (H5VL_group_specific_t)HDva_arg(ap, int); switch(specific) { case H5VL_GROUP_FLUSH: @@ -2822,7 +2811,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5VL_link_create_type_t create = (H5VL_link_create_type_t)va_arg(ap, int); + H5VL_link_create_type_t create = (H5VL_link_create_type_t)HDva_arg(ap, int); switch(create) { case H5VL_LINK_CREATE_HARD: @@ -2848,7 +2837,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5VL_link_get_t get = (H5VL_link_get_t)va_arg(ap, int); + H5VL_link_get_t get = (H5VL_link_get_t)HDva_arg(ap, int); switch(get) { case H5VL_LINK_GET_INFO: @@ -2874,7 +2863,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5VL_link_specific_t specific = (H5VL_link_specific_t)va_arg(ap, int); + H5VL_link_specific_t specific = (H5VL_link_specific_t)HDva_arg(ap, int); switch(specific) { case H5VL_LINK_DELETE: @@ -2900,7 +2889,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5VL_object_get_t get = (H5VL_object_get_t)va_arg(ap, int); + H5VL_object_get_t get = (H5VL_object_get_t)HDva_arg(ap, int); switch(get) { case H5VL_REF_GET_REGION: @@ -2929,7 +2918,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5VL_object_specific_t specific = (H5VL_object_specific_t)va_arg(ap, int); + H5VL_object_specific_t specific = (H5VL_object_specific_t)HDva_arg(ap, int); switch(specific) { case H5VL_OBJECT_CHANGE_REF_COUNT: @@ -2964,7 +2953,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5VL_request_specific_t specific = (H5VL_request_specific_t)va_arg(ap, int); + H5VL_request_specific_t specific = (H5VL_request_specific_t)HDva_arg(ap, int); switch(specific) { case H5VL_REQUEST_WAITANY: @@ -3009,7 +2998,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - vp = va_arg (ap, void *); + vp = HDva_arg (ap, void *); if(vp) HDfprintf(out, "0x%lx", (unsigned long)vp); @@ -3035,7 +3024,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - size_t size = va_arg(ap, size_t); + size_t size = HDva_arg(ap, size_t); HDfprintf(out, "%Zu", size); asize[argno] = (hssize_t)size; @@ -3052,7 +3041,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5Z_SO_scale_type_t scale_type = (H5Z_SO_scale_type_t)va_arg(ap, int); + H5Z_SO_scale_type_t scale_type = (H5Z_SO_scale_type_t)HDva_arg(ap, int); switch(scale_type) { case H5Z_SO_FLOAT_DSCALE: @@ -3082,7 +3071,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5Z_class2_t *filter = va_arg(ap, H5Z_class2_t*); + H5Z_class2_t *filter = HDva_arg(ap, H5Z_class2_t*); HDfprintf(out, "0x%lx", (unsigned long)filter); } /* end else */ @@ -3096,7 +3085,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5Z_EDC_t edc = (H5Z_EDC_t)va_arg(ap, int); + H5Z_EDC_t edc = (H5Z_EDC_t)HDva_arg(ap, int); if(H5Z_DISABLE_EDC == edc) HDfprintf(out, "H5Z_DISABLE_EDC"); @@ -3115,7 +3104,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5Z_filter_t id = va_arg(ap, H5Z_filter_t); + H5Z_filter_t id = HDva_arg(ap, H5Z_filter_t); if(H5Z_FILTER_DEFLATE == id) HDfprintf(out, "H5Z_FILTER_DEFLATE"); @@ -3141,7 +3130,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - ssize_t ssize = va_arg(ap, ssize_t); + ssize_t ssize = HDva_arg(ap, ssize_t); HDfprintf(out, "%Zd", ssize); asize[argno] = (hssize_t)ssize; @@ -3169,7 +3158,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) (event_time.etime - *returning)); error: - va_end(ap); + HDva_end(ap); if(returning) HDfprintf(out, ";\n"); else { diff --git a/src/H5win32defs.h b/src/H5win32defs.h index 4522228..140afc3 100644 --- a/src/H5win32defs.h +++ b/src/H5win32defs.h @@ -62,9 +62,17 @@ typedef __int64 h5_stat_size_t; #define HDstat(S,B) _stati64(S,B) #define HDstrcasecmp(A,B) _stricmp(A,B) #define HDstrdup(S) _strdup(S) +#define HDstrtok_r(X,Y,Z) strtok_s(X,Y,Z) #define HDtzset() _tzset() #define HDunlink(S) _unlink(S) #define HDwrite(F,M,Z) _write(F,M,Z) +#if (_MSC_VER < 1800) +/* va_copy() does not exist on pre-2013 Visual Studio. Since va_lists are + * just pointers into the stack in those CRTs, the usual work-around + * is to just define the operation as a pointer copy. + */ +#define HDva_copy(D,S) ((D) = (S)) +#endif /* MSC_VER < 1800 */ #ifdef H5_HAVE_VISUAL_STUDIO diff --git a/src/Makefile.am b/src/Makefile.am index 69b51b2..5532655 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -40,12 +40,12 @@ DISTCLEANFILES=H5pubconf.h # library sources libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ H5A.c H5Abtree2.c H5Adense.c H5Adeprec.c H5Aint.c H5Atest.c \ - H5AC.c H5ACdbg.c H5AClog.c H5ACproxy_entry.c \ + H5AC.c H5ACdbg.c H5ACproxy_entry.c \ H5B.c H5Bcache.c H5Bdbg.c \ H5B2.c H5B2cache.c H5B2dbg.c H5B2hdr.c H5B2int.c H5B2internal.c \ H5B2leaf.c H5B2stat.c H5B2test.c \ - H5C.c H5Cdbg.c H5Cepoch.c H5Cimage.c H5Clog.c H5Cprefetched.c \ - H5Cquery.c H5Ctag.c H5Ctest.c \ + H5C.c H5Cdbg.c H5Cepoch.c H5Cimage.c H5Clog.c H5Clog_json.c H5Clog_trace.c \ + H5Cprefetched.c H5Cquery.c H5Ctag.c H5Ctest.c \ H5CS.c \ H5CX.c \ H5D.c H5Dbtree.c H5Dbtree2.c H5Dchunk.c H5Dcompact.c H5Dcontig.c H5Ddbg.c \ @@ -114,7 +114,10 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ H5Topaque.c \ H5Torder.c \ H5Tpad.c H5Tprecis.c H5Tstrpad.c H5Tvisit.c H5Tvlen.c H5TS.c \ - H5VL.c H5VLcallback.c H5VLint.c H5VLnative.c H5VLpassthru.c \ + H5VL.c H5VLcallback.c H5VLint.c H5VLnative.c \ + H5VLnative_attr.c H5VLnative_dataset.c H5VLnative_datatype.c \ + H5VLnative_file.c H5VLnative_group.c H5VLnative_link.c H5VLnative_object.c \ + H5VLpassthru.c \ H5VM.c H5WB.c H5Z.c \ H5Zdeflate.c H5Zfletcher32.c H5Znbit.c H5Zshuffle.c \ H5Zscaleoffset.c H5Zszip.c H5Ztrans.c diff --git a/src/libhdf5.settings.in b/src/libhdf5.settings.in index 531cd00..9d0e29f 100644 --- a/src/libhdf5.settings.in +++ b/src/libhdf5.settings.in @@ -82,7 +82,6 @@ Parallel Filtered Dataset Writes: @PARALLEL_FILTERED_WRITES@ API tracing: @TRACE_API@ Using memory checker: @USINGMEMCHECKER@ Memory allocation sanity checks: @MEMORYALLOCSANITYCHECK@ - Metadata trace file: @METADATATRACEFILE@ Function stack tracing: @CODESTACK@ Strict file format checks: @STRICT_FORMAT_CHECKS@ Optimization instrumentation: @INSTRUMENT_LIBRARY@ |