diff options
Diffstat (limited to 'src/H5T.c')
-rw-r--r-- | src/H5T.c | 197 |
1 files changed, 129 insertions, 68 deletions
@@ -1696,95 +1696,41 @@ done: /*------------------------------------------------------------------------- - * Function: H5Tclose + * Function: H5Tclose * - * Purpose: Frees a datatype and all associated memory. + * Purpose: Frees a datatype and all associated memory. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Robb Matzke - * Tuesday, December 9, 1997 + * Programmer: Robb Matzke + * Tuesday, December 9, 1997 + * + * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Tclose(hid_t type_id) { - herr_t ret_value = SUCCEED; /* Return value */ + H5T_t *dt; /* Pointer to datatype to close */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", type_id); - /* Call internal function */ - if(H5T_close_id(type_id) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "unable to close object") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5Tclose() */ - - -/*------------------------------------------------------------------------- - * Function: H5T_close_id - * - * Purpose: Internal function to free a datatype and all associated - * memory. - * - * Return: SUCCEED/FAIL - * - * Programmer: Dana Robinson - * Summer 2016 - * - *------------------------------------------------------------------------- - */ -herr_t -H5T_close_id(hid_t type_id) -{ - H5T_t *dt; /* Pointer to datatype to close */ - H5F_t *file = NULL; /* File */ - hbool_t evict = FALSE; /* Evict metadata on close? */ - haddr_t tag = HADDR_UNDEF; /* Metadata tag for evictions */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - /* Check args */ if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") if(H5T_STATE_IMMUTABLE == dt->shared->state) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "immutable datatype") - - /* Check if this is the last object reference and we'll be evicting - * on close. We need to cache this info since it will be gone after the - * decrement call frees the struct. - */ - file = dt->oloc.file; - if(file && 1 == dt->shared->fo_count && H5F_EVICT_ON_CLOSE(file)) { - evict = TRUE; - tag = dt->oloc.addr; - } /* end if */ + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "immutable datatype") /* When the reference count reaches zero the resources are freed */ if(H5I_dec_app_ref(type_id) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "problem freeing id") - - /* Clean up metadata in the metadata cache if evicting on close */ - if(evict && H5F_SHARED(file)) { -// printf("DUMPING CACHE - BEFORE FLUSH\n"); -// H5AC_dump_cache(file); - if(H5AC_flush_tagged_metadata(file, tag, H5AC_ind_read_dxpl_id) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush tagged metadata") -// printf("DUMPING CACHE - BETWEEN FLUSH AND EVICT\n"); -// H5AC_dump_cache(file); - if(H5AC_evict_tagged_metadata(file, tag, FALSE, H5AC_ind_read_dxpl_id) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to evict tagged metadata") -// printf("DUMPING CACHE - AFTER EVICT\n"); -// H5AC_dump_cache(file); - } /* end if */ + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "problem freeing id") done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5T_close_id() */ + FUNC_LEAVE_API(ret_value) +} /* end H5Tclose() */ /*------------------------------------------------------------------------- @@ -5057,6 +5003,49 @@ done: FUNC_LEAVE_NOAPI(ret_value) } +/*------------------------------------------------------------------------- + * Function: H5T_convert_committed_datatype + * + * Purpose: To convert the committed datatype "dt" to a transient embedded + * type if the file location associated with the committed datatype is + * different from the parameter "f". + * "f" is the file location where the dataset or attribute will be created. + * + * Notes: See HDFFV-9940 + * + * Return: Success: non-negative + * Failure: negative + * + * Programmer: Vailin Choi; June 2016 + * + *------------------------------------------------------------------------- + */ +herr_t +H5T_convert_committed_datatype(H5T_t *dt, H5F_t *f) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + HDassert(dt); + HDassert(f); + + if(H5T_is_named(dt) && (dt->sh_loc.file != f)) { + HDassert(dt->sh_loc.type == H5O_SHARE_TYPE_COMMITTED); + + H5O_msg_reset_share(H5O_DTYPE_ID, dt); + if(H5O_loc_free(&dt->oloc) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTRESET, FAIL, "unable to initialize location") + if(H5G_name_free(&dt->path) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, FAIL, "unable to reset path") + + dt->shared->state = H5T_STATE_TRANSIENT; + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5T_convert_committed_datatype() */ + /*-------------------------------------------------------------------------- NAME @@ -5549,3 +5538,75 @@ H5T_patch_vlen_file(H5T_t *dt, H5F_t *f) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5T_patch_vlen_file() */ + +/*------------------------------------------------------------------------- + * Function: H5Tflush + * + * Purpose: Flushes all buffers associated with a named datatype to disk. + * + * Return: Non-negative on success, negative on failure + * + * Programmer: Mike McGreevy + * May 19, 2010 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Tflush(hid_t type_id) +{ + H5T_t *dt; /* Datatype for this operation */ + herr_t ret_value = SUCCEED; /* return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE1("e", "i", type_id); + + /* Check args */ + if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") + if(!H5T_is_named(dt)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a committed datatype") + + /* To flush metadata and invoke flush callback if there is */ + if(H5O_flush_common(&dt->oloc, type_id, H5AC_ind_read_dxpl_id) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFLUSH, FAIL, "unable to flush datatype and object flush callback") + +done: + FUNC_LEAVE_API(ret_value) +} /* H5Tflush */ + + +/*------------------------------------------------------------------------- + * Function: H5Trefresh + * + * Purpose: Refreshes all buffers associated with a named datatype. + * + * Return: Non-negative on success, negative on failure + * + * Programmer: Mike McGreevy + * July 21, 2010 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Trefresh(hid_t type_id) +{ + H5T_t * dt = NULL; + herr_t ret_value = SUCCEED; /* return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE1("e", "i", type_id); + + /* Check args */ + if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") + if(!H5T_is_named(dt)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a committed datatype") + + /* Call private function to refresh datatype object */ + if ((H5O_refresh_metadata(type_id, dt->oloc, H5AC_ind_read_dxpl_id)) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTLOAD, FAIL, "unable to refresh datatype") + +done: + FUNC_LEAVE_API(ret_value) +} /* H5Trefresh */ + |