diff options
Diffstat (limited to 'src/H5Fint.c')
-rw-r--r-- | src/H5Fint.c | 187 |
1 files changed, 94 insertions, 93 deletions
diff --git a/src/H5Fint.c b/src/H5Fint.c index 49538f4..abc638a 100644 --- a/src/H5Fint.c +++ b/src/H5Fint.c @@ -21,22 +21,22 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Aprivate.h" /* Attributes */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5Gprivate.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Lprivate.h" /* Links */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5SMprivate.h" /* Shared Object Header Messages */ -#include "H5Tprivate.h" /* Datatypes */ +#include "H5private.h" /* Generic Functions */ +#include "H5Aprivate.h" /* Attributes */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Lprivate.h" /* Links */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5SMprivate.h" /* Shared Object Header Messages */ +#include "H5Tprivate.h" /* Datatypes */ /****************/ @@ -74,11 +74,9 @@ typedef struct H5F_olist_t { /********************/ 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*/); +static herr_t H5F__build_name(const char *prefix, const char *file_name, char **full_name/*out*/); static char *H5F__getenv_prefix_name(char **env_prefix/*in,out*/); -static herr_t H5F_build_actual_name(const H5F_t *f, const H5P_genplist_t *fapl, - const char *name, char ** /*out*/ actual_name);/* Declare a free list to manage the H5F_t struct */ +static herr_t H5F_build_actual_name(const H5F_t *f, const H5P_genplist_t *fapl, const char *name, char ** /*out*/ actual_name); static herr_t H5F__flush_phase1(H5F_t *f); static herr_t H5F__flush_phase2(H5F_t *f, hbool_t closing); @@ -175,7 +173,7 @@ H5F_get_access_plist(H5F_t *f, hbool_t app_ref) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set object flush callback") if(f->shared->efc) - efc_size = H5F_efc_max_nfiles(f->shared->efc); + efc_size = H5F__efc_max_nfiles(f->shared->efc); if(H5P_set(new_plist, H5F_ACS_EFC_SIZE_NAME, &efc_size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set elink file cache size") if(f->shared->page_buf != NULL) { @@ -486,11 +484,12 @@ done: /*-------------------------------------------------------------------------- - * Function: H5F__build_name + * Function: H5F__build_name * - * Purpose: Prepend PREFIX to FILE_NAME and store in FULL_NAME + * Purpose: Prepend PREFIX to FILE_NAME and store in FULL_NAME + * + * Return: SUCCEED/FAIL * - * Return: Non-negative on success/Negative on failure *--------------------------------------------------------------------------*/ static herr_t H5F__build_name(const char *prefix, const char *file_name, char **full_name/*out*/) @@ -510,7 +509,7 @@ H5F__build_name(const char *prefix, const char *file_name, char **full_name/*out /* Compose the full file name */ HDsnprintf(*full_name, (prefix_len + fname_len + 2), "%s%s%s", prefix, - (H5_CHECK_DELIMITER(prefix[prefix_len - 1]) ? "" : H5_DIR_SEPS), file_name); + ((prefix_len == 0 || H5_CHECK_DELIMITER(prefix[prefix_len - 1])) ? "" : H5_DIR_SEPS), file_name); done: FUNC_LEAVE_NOAPI(ret_value) @@ -818,34 +817,37 @@ done: /*------------------------------------------------------------------------- - * Function: H5F_new + * Function: H5F__new * - * Purpose: Creates a new file object and initializes it. The - * H5Fopen and H5Fcreate functions then fill in various fields. - * If SHARED is a non-null pointer then the shared info - * to which it points has the reference count incremented. - * Otherwise a new, empty shared info struct is created and - * initialized with the specified file access property list. + * Purpose: Creates a new file object and initializes it. The + * H5Fopen and H5Fcreate functions then fill in various fields. + * If SHARED is a non-null pointer then the shared info + * to which it points has the reference count incremented. + * Otherwise a new, empty shared info struct is created and + * initialized with the specified file access property list. + * + * Return: Success: Pointer to a new file struct + * + * Failure: NULL * - * Return: Success: Ptr to a new file struct. - * Failure: NULL *------------------------------------------------------------------------- */ H5F_t * -H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t *lf) +H5F__new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t *lf) { - H5F_t *f = NULL, *ret_value = NULL; + H5F_t *f = NULL; + H5F_t *ret_value = NULL; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_PACKAGE if(NULL == (f = H5FL_CALLOC(H5F_t))) HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, NULL, "can't allocate top file structure") - f->file_id = -1; + f->file_id = H5I_INVALID_HID; if(shared) { HDassert(lf == NULL); f->shared = shared; - } /* end if */ + } else { H5P_genplist_t *plist; /* Property list */ unsigned efc_size; /* External file cache size */ @@ -866,7 +868,7 @@ H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t f->shared->fs_state[u] = H5F_FS_STATE_CLOSED; f->shared->fs_addr[u] = HADDR_UNDEF; f->shared->fs_man[u] = NULL; - } /* end for */ + } f->shared->first_alloc_dealloc = FALSE; f->shared->eoa_pre_fsm_fsalloc = HADDR_UNDEF; f->shared->eoa_post_fsm_fsalloc = HADDR_UNDEF; @@ -878,9 +880,8 @@ H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t /* intialize point of no return */ f->shared->point_of_no_return = FALSE; - /* - * Copy the file creation and file access property lists into the - * new file handle. We do this early because some values might need + /* Copy the file creation and file access property lists into the + * new file handle. We do this early because some values might need * to change as the file is being opened. */ if(NULL == (plist = (H5P_genplist_t *)H5I_object(fcpl_id))) @@ -906,7 +907,8 @@ H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t HDassert(f->shared->fs_page_size >= H5F_FILE_SPACE_PAGE_SIZE_MIN); /* Temporary for multi/split drivers: fail file creation - when persisting free-space or using paged aggregation strategy */ + * when persisting free-space or using paged aggregation strategy. + */ if(H5F_HAS_FEATURE(f, H5FD_FEAT_PAGED_AGGR)) if(f->shared->fs_strategy == H5F_FSPACE_STRATEGY_PAGE || f->shared->fs_persist) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't open with this strategy or persistent fs") @@ -947,7 +949,7 @@ H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t if(H5P_get(plist, H5F_ACS_EFC_SIZE_NAME, &efc_size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get elink file cache size") if(efc_size > 0) - if(NULL == (f->shared->efc = H5F_efc_create(efc_size))) + if(NULL == (f->shared->efc = H5F__efc_create(efc_size))) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "can't create external file cache") #ifdef H5_HAVE_PARALLEL if(H5P_get(plist, H5_COLL_MD_READ_FLAG_NAME, &(f->coll_md_read)) < 0) @@ -1000,12 +1002,12 @@ H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t f->shared->feature_flags &= ~(unsigned)H5FD_FEAT_ACCUMULATE_METADATA; if(H5FD_set_feature_flags(f->shared->lf, f->shared->feature_flags) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, NULL, "can't set feature_flags in VFD") - } /* end if */ + } else { /* If no value for read attempts has been set, use the default */ if(!f->shared->read_attempts) f->shared->read_attempts = H5F_METADATA_READ_ATTEMPTS; - } /* end else */ + } /* Determine the # of bins for metdata read retries */ if(H5F_set_retries(f) < 0) @@ -1031,8 +1033,7 @@ H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t 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") - /* - * Create a metadata cache with the specified number of elements. + /* 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. */ @@ -1069,12 +1070,12 @@ done: HDONE_ERROR(H5E_FILE, H5E_CANTDEC, NULL, "can't close property list") f->shared = H5FL_FREE(H5F_file_t, f->shared); - } /* end if */ + } f = H5FL_FREE(H5F_t, f); - } /* end if */ + } FUNC_LEAVE_NOAPI(ret_value) -} /* end H5F_new() */ +} /* end H5F__new() */ /*------------------------------------------------------------------------- @@ -1343,8 +1344,8 @@ H5F__dest(H5F_t *f, hbool_t flush) * Return: Success: Non-NULL, pointer to new file object. * Failure: NULL * - * Programmer: Quincey Koziol - * December 13, 2017 + * Programmer: Quincey Koziol + * December 13, 2017 * *------------------------------------------------------------------------- */ @@ -1379,8 +1380,8 @@ done: * Return: Success: Non-NULL, pointer to new file object. * Failure: NULL * - * Programmer: Quincey Koziol - * December 13, 2017 + * Programmer: Quincey Koziol + * December 13, 2017 * *------------------------------------------------------------------------- */ @@ -1587,7 +1588,7 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "SWMR read access flag not the same for file that is already open") /* Allocate new "high-level" file struct */ - if((file = H5F_new(shared, flags, fcpl_id, fapl_id, NULL)) == NULL) + if((file = H5F__new(shared, flags, fcpl_id, fapl_id, NULL)) == NULL) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to create new file object") } /* end if */ else { @@ -1615,7 +1616,7 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) } /* end if */ /* Create the 'top' file structure */ - if(NULL == (file = H5F_new(NULL, flags, fcpl_id, fapl_id, lf))) { + if(NULL == (file = H5F__new(NULL, flags, fcpl_id, fapl_id, lf))) { /* If this is the only time the file has been opened and the struct * returned is NULL, H5FD_close() will never be called via H5F_dest() * so we have to close lf here before heading to the error handling. @@ -1881,8 +1882,8 @@ H5F__flush_phase2(H5F_t *f, hbool_t closing) #ifdef H5_HAVE_PARALLEL if(H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI)) - /* Since we just returned from a call to H5AC_flush(), we just - * passed through a barrier. Hence we can skip the barrier on + /* Since we just returned from a call to H5AC_flush(), we just + * passed through a barrier. Hence we can skip the barrier on * entry to the mpio file driver truncate call below, and the first * barrier in the following call to flush the cache again. */ @@ -1967,8 +1968,8 @@ H5F__flush_real(H5F_t *f) * * Return: Non-negative on success / Negative on failure * - * Programmer: Quincey Koziol - * December 13, 2017 + * Programmer: Quincey Koziol + * December 13, 2017 * *------------------------------------------------------------------------- */ @@ -2085,7 +2086,7 @@ H5F__close_cb(H5F_t *f) unsigned nopen_objs = 0; /* Number of open objects in file/mount hierarchy */ /* Get the number of open objects and open files on this file/mount hierarchy */ - if(H5F_mount_count_ids(f, &nopen_files, &nopen_objs) < 0) + if(H5F__mount_count_ids(f, &nopen_files, &nopen_objs) < 0) HGOTO_ERROR(H5E_SYM, H5E_MOUNT, FAIL, "problem checking mount hierarchy") /* If there are no other file IDs open on this file/mount hier., but @@ -2150,7 +2151,7 @@ H5F_try_close(H5F_t *f, hbool_t *was_closed /*out*/) } /* end if */ /* Get the number of open objects and open files on this file/mount hierarchy */ - if(H5F_mount_count_ids(f, &nopen_files, &nopen_objs) < 0) + if(H5F__mount_count_ids(f, &nopen_files, &nopen_objs) < 0) HGOTO_ERROR(H5E_SYM, H5E_MOUNT, FAIL, "problem checking mount hierarchy") /* @@ -2792,19 +2793,19 @@ H5F__set_libver_bounds(H5F_t *f, H5F_libver_t low, H5F_libver_t high) * metadata entry class changes when the file format low / high * bounds are changed and an unwritten entry of that class is * sitting in the metadata cache. - * + * * If that happens, it's possible that the entry's size could * become larger, potentially corrupting the file (if the larger * entry is fully written, overwriting data outside its allocated * space), or corrupting the entry (if the entry is truncated to * fit into the allocated space). - * + * * Although I'm not aware of any metadata with this behavior * currently, it would be very difficult to guard against and / or * detect, but if we flush everything here, the format version * for metadata entries in the cache will be finalized and these * sorts of problems can be avoided. - * + * * QAK - April, 2018 */ if(H5F__flush_real(f) < 0) @@ -3635,7 +3636,7 @@ done: herr_t H5F__format_convert(H5F_t *f) { - hbool_t mark_dirty = FALSE; /* Whether to mark the file's superblock dirty */ + hbool_t mark_dirty = FALSE; /* Whether to mark the file's superblock dirty */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_VOL @@ -3646,39 +3647,39 @@ H5F__format_convert(H5F_t *f) /* Check if the superblock should be downgraded */ if(f->shared->sblock->super_vers > HDF5_SUPERBLOCK_VERSION_V18_LATEST) { - f->shared->sblock->super_vers = HDF5_SUPERBLOCK_VERSION_V18_LATEST; - mark_dirty = TRUE; + f->shared->sblock->super_vers = HDF5_SUPERBLOCK_VERSION_V18_LATEST; + mark_dirty = TRUE; } /* end if */ /* Check for persistent freespace manager, which needs to be downgraded */ if(!(f->shared->fs_strategy == H5F_FILE_SPACE_STRATEGY_DEF && - f->shared->fs_persist == H5F_FREE_SPACE_PERSIST_DEF && - f->shared->fs_threshold == H5F_FREE_SPACE_THRESHOLD_DEF && - f->shared->fs_page_size == H5F_FILE_SPACE_PAGE_SIZE_DEF)) { - /* Check to remove free-space manager info message from superblock extension */ - if(H5F_addr_defined(f->shared->sblock->ext_addr)) - if(H5F__super_ext_remove_msg(f, H5O_FSINFO_ID) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "error in removing message from superblock extension") - - /* Close freespace manager */ - if(H5MF_try_close(f) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "unable to free free-space address") - - /* Set non-persistent freespace manager */ - f->shared->fs_strategy = H5F_FILE_SPACE_STRATEGY_DEF; - f->shared->fs_persist = H5F_FREE_SPACE_PERSIST_DEF; - f->shared->fs_threshold = H5F_FREE_SPACE_THRESHOLD_DEF; - f->shared->fs_page_size = H5F_FILE_SPACE_PAGE_SIZE_DEF; - - /* Indicate that the superblock should be marked dirty */ - mark_dirty = TRUE; + f->shared->fs_persist == H5F_FREE_SPACE_PERSIST_DEF && + f->shared->fs_threshold == H5F_FREE_SPACE_THRESHOLD_DEF && + f->shared->fs_page_size == H5F_FILE_SPACE_PAGE_SIZE_DEF)) { + /* Check to remove free-space manager info message from superblock extension */ + if(H5F_addr_defined(f->shared->sblock->ext_addr)) + if(H5F__super_ext_remove_msg(f, H5O_FSINFO_ID) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "error in removing message from superblock extension") + + /* Close freespace manager */ + if(H5MF_try_close(f) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "unable to free free-space address") + + /* Set non-persistent freespace manager */ + f->shared->fs_strategy = H5F_FILE_SPACE_STRATEGY_DEF; + f->shared->fs_persist = H5F_FREE_SPACE_PERSIST_DEF; + f->shared->fs_threshold = H5F_FREE_SPACE_THRESHOLD_DEF; + f->shared->fs_page_size = H5F_FILE_SPACE_PAGE_SIZE_DEF; + + /* Indicate that the superblock should be marked dirty */ + mark_dirty = TRUE; } /* end if */ /* Check if we should mark the superblock dirty */ if(mark_dirty) - /* Mark superblock as dirty */ - if(H5F_super_dirty(f) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTMARKDIRTY, FAIL, "unable to mark superblock as dirty") + /* Mark superblock as dirty */ + if(H5F_super_dirty(f) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTMARKDIRTY, FAIL, "unable to mark superblock as dirty") done: FUNC_LEAVE_NOAPI_VOL(ret_value) |