summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/H5AC.c4
-rw-r--r--src/H5ACprivate.h2
-rw-r--r--src/H5Cprivate.h2
-rw-r--r--src/H5Ctag.c6
-rw-r--r--src/H5D.c20
-rw-r--r--src/H5Dint.c44
-rw-r--r--src/H5Fint.c16
-rw-r--r--src/H5Fio.c2
-rw-r--r--src/H5Fpkg.h1
-rw-r--r--src/H5Fprivate.h4
-rw-r--r--src/H5Fquery.c27
-rw-r--r--src/H5G.c4
-rw-r--r--src/H5Gint.c19
-rw-r--r--src/H5O.c10
-rw-r--r--src/H5Pfapl.c87
-rw-r--r--src/H5Ppublic.h2
-rw-r--r--src/H5T.c82
-rw-r--r--src/H5Tprivate.h1
18 files changed, 281 insertions, 52 deletions
diff --git a/src/H5AC.c b/src/H5AC.c
index 77a58fc..4dac680 100644
--- a/src/H5AC.c
+++ b/src/H5AC.c
@@ -2383,7 +2383,7 @@ done:
*------------------------------------------------------------------------------
*/
herr_t
-H5AC_evict_tagged_metadata(H5F_t * f, haddr_t metadata_tag, hid_t dxpl_id)
+H5AC_evict_tagged_metadata(H5F_t * f, haddr_t metadata_tag, hbool_t match_global, hid_t dxpl_id)
{
/* Variable Declarations */
herr_t ret_value = SUCCEED;
@@ -2396,7 +2396,7 @@ H5AC_evict_tagged_metadata(H5F_t * f, haddr_t metadata_tag, hid_t dxpl_id)
HDassert(f->shared);
/* Call cache level function to evict metadata entries with specified tag */
- if(H5C_evict_tagged_entries(f, dxpl_id, metadata_tag) < 0)
+ if(H5C_evict_tagged_entries(f, dxpl_id, metadata_tag, match_global) < 0)
HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Cannot evict metadata")
done:
diff --git a/src/H5ACprivate.h b/src/H5ACprivate.h
index d1d41c9..84c9e93 100644
--- a/src/H5ACprivate.h
+++ b/src/H5ACprivate.h
@@ -364,7 +364,7 @@ H5_DLL herr_t H5AC_validate_config(H5AC_cache_config_t *config_ptr);
/* Tag & Ring routines */
H5_DLL herr_t H5AC_tag(hid_t dxpl_id, haddr_t metadata_tag, haddr_t *prev_tag);
H5_DLL herr_t H5AC_flush_tagged_metadata(H5F_t * f, haddr_t metadata_tag, hid_t dxpl_id);
-H5_DLL herr_t H5AC_evict_tagged_metadata(H5F_t * f, haddr_t metadata_tag, hid_t dxpl_id);
+H5_DLL herr_t H5AC_evict_tagged_metadata(H5F_t * f, haddr_t metadata_tag, hbool_t match_global, hid_t dxpl_id);
H5_DLL herr_t H5AC_retag_copied_metadata(const H5F_t *f, haddr_t metadata_tag);
H5_DLL herr_t H5AC_ignore_tags(const H5F_t *f);
H5_DLL herr_t H5AC_cork(H5F_t *f, haddr_t obj_addr, unsigned action, hbool_t *corked);
diff --git a/src/H5Cprivate.h b/src/H5Cprivate.h
index 975ea3e..4137edf 100644
--- a/src/H5Cprivate.h
+++ b/src/H5Cprivate.h
@@ -1970,7 +1970,7 @@ H5_DLL herr_t H5C_expunge_entry(H5F_t *f, hid_t dxpl_id,
const H5C_class_t *type, haddr_t addr, unsigned flags);
H5_DLL herr_t H5C_flush_cache(H5F_t *f, hid_t dxpl_id, unsigned flags);
H5_DLL herr_t H5C_flush_tagged_entries(H5F_t * f, hid_t dxpl_id, haddr_t tag);
-H5_DLL herr_t H5C_evict_tagged_entries(H5F_t * f, hid_t dxpl_id, haddr_t tag);
+H5_DLL herr_t H5C_evict_tagged_entries(H5F_t * f, hid_t dxpl_id, haddr_t tag, hbool_t match_global);
H5_DLL herr_t H5C_expunge_tag_type_metadata(H5F_t *f, hid_t dxpl_id, haddr_t tag, int type_id, unsigned flags);
#if H5C_DO_TAGGING_SANITY_CHECKS
herr_t H5C_verify_tag(int id, haddr_t tag, H5C_tag_globality_t globality);
diff --git a/src/H5Ctag.c b/src/H5Ctag.c
index d560e25..fc01ecb 100644
--- a/src/H5Ctag.c
+++ b/src/H5Ctag.c
@@ -352,7 +352,7 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5C_evict_tagged_entries(H5F_t * f, hid_t dxpl_id, haddr_t tag)
+H5C_evict_tagged_entries(H5F_t * f, hid_t dxpl_id, haddr_t tag, hbool_t match_global)
{
H5C_t *cache; /* Pointer to cache structure */
H5C_tag_iter_evict_ctx_t ctx; /* Context for iterator callback */
@@ -379,8 +379,8 @@ H5C_evict_tagged_entries(H5F_t * f, hid_t dxpl_id, haddr_t tag)
ctx.evicted_entries_last_pass = FALSE;
/* Iterate through entries in the cache */
- if(H5C__iter_tagged_entries(cache, tag, TRUE, H5C__evict_tagged_entries_cb, &ctx) < 0)
- HGOTO_ERROR(H5E_CACHE, H5E_BADITER, FAIL, "Iteration of tagged entries failed")
+ if(H5C__iter_tagged_entries(cache, tag, match_global, H5C__evict_tagged_entries_cb, &ctx) < 0)
+ HGOTO_ERROR(H5E_CACHE, H5E_BADITER, match_global, "Iteration of tagged entries failed")
/* Keep doing this until we have stopped evicted entries */
} while(TRUE == ctx.evicted_entries_last_pass);
diff --git a/src/H5D.c b/src/H5D.c
index 23397ad..44e4baa 100644
--- a/src/H5D.c
+++ b/src/H5D.c
@@ -308,37 +308,37 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5Dclose
+ * Function: H5Dclose
*
- * Purpose: Closes access to a dataset (DATASET_ID) and releases
- * resources used by it. It is illegal to subsequently use that
- * same dataset ID in calls to other dataset functions.
+ * Purpose: Closes access to a dataset (DATASET_ID) and releases
+ * resources used by it. It is illegal to subsequently use that
+ * same dataset ID in calls to other dataset functions.
*
- * Return: Non-negative on success/Negative on failure
+ * Return: Non-negative on success/Negative on failure
*
- * Programmer: Robb Matzke
- * Thursday, December 4, 1997
+ * Programmer: Robb Matzke
+ * Thursday, December 4, 1997
*
*-------------------------------------------------------------------------
*/
herr_t
H5Dclose(hid_t dset_id)
{
- herr_t ret_value = SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE1("e", "i", dset_id);
/* Check args */
if(NULL == H5I_object_verify(dset_id, H5I_DATASET))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset")
/*
* Decrement the counter on the dataset. It will be freed if the count
* reaches zero.
*/
if(H5I_dec_app_ref_always_close(dset_id) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "can't decrement count on dataset ID")
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "can't decrement count on dataset ID")
done:
FUNC_LEAVE_API(ret_value)
diff --git a/src/H5Dint.c b/src/H5Dint.c
index 8a00be2..5ae3bd3 100644
--- a/src/H5Dint.c
+++ b/src/H5Dint.c
@@ -1780,9 +1780,9 @@ done:
herr_t
H5D_close(H5D_t *dataset)
{
- hbool_t free_failed = FALSE;
- hbool_t corked; /* Whether the dataset is corked or not */
- herr_t ret_value = SUCCEED; /* Return value */
+ hbool_t free_failed = FALSE; /* Set if freeing sub-components failed */
+ hbool_t corked; /* Whether the dataset is corked or not */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
@@ -1797,6 +1797,7 @@ H5D_close(H5D_t *dataset)
dataset->shared->fo_count--;
if(dataset->shared->fo_count == 0) {
+
/* Flush the dataset's information. Continue to close even if it fails. */
if(H5D__flush_real(dataset, H5AC_ind_read_dxpl_id) < 0)
HDONE_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to flush cached dataset info")
@@ -1891,12 +1892,12 @@ H5D_close(H5D_t *dataset)
(H5O_msg_reset(H5O_FILL_ID, &dataset->shared->dcpl_cache.fill) < 0) ||
(H5O_msg_reset(H5O_EFL_ID, &dataset->shared->dcpl_cache.efl) < 0);
- /* Uncork cache entries with object address tag */
- if(H5AC_cork(dataset->oloc.file, dataset->oloc.addr, H5AC__GET_CORKED, &corked) < 0)
- HDONE_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to retrieve an object's cork status")
- if(corked)
- if(H5AC_cork(dataset->oloc.file, dataset->oloc.addr, H5AC__UNCORK, NULL) < 0)
- HDONE_ERROR(H5E_DATASET, H5E_CANTUNCORK, FAIL, "unable to uncork an object")
+ /* Uncork cache entries with object address tag */
+ if(H5AC_cork(dataset->oloc.file, dataset->oloc.addr, H5AC__GET_CORKED, &corked) < 0)
+ HDONE_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to retrieve an object's cork status")
+ if(corked)
+ if(H5AC_cork(dataset->oloc.file, dataset->oloc.addr, H5AC__UNCORK, NULL) < 0)
+ HDONE_ERROR(H5E_DATASET, H5E_CANTUNCORK, FAIL, "unable to uncork an object")
/*
* Release datatype, dataspace and creation property list -- there isn't
@@ -1917,6 +1918,21 @@ H5D_close(H5D_t *dataset)
if(H5O_close(&(dataset->oloc)) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release object header")
+ /* Evict dataset metadata if evicting on close */
+ if(H5F_SHARED(dataset->oloc.file) && H5F_EVICT_ON_CLOSE(dataset->oloc.file)) {
+// printf("EVICTING DATASET (TAG: 0x%3llx)\n", dataset->oloc.addr);
+// printf("DUMPING CACHE - BEFORE FLUSH\n");
+// H5AC_dump_cache(dataset->oloc.file);
+ if(H5AC_flush_tagged_metadata(dataset->oloc.file, dataset->oloc.addr, 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(dataset->oloc.file);
+ if(H5AC_evict_tagged_metadata(dataset->oloc.file, dataset->oloc.addr, 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(dataset->oloc.file);
+ } /* end if */
+
/*
* Free memory. Before freeing the memory set the file pointer to NULL.
* We always check for a null file pointer in other H5D functions to be
@@ -1924,8 +1940,8 @@ H5D_close(H5D_t *dataset)
* above).
*/
dataset->oloc.file = NULL;
-
dataset->shared = H5FL_FREE(H5D_shared_t, dataset->shared);
+
} /* end if */
else {
/* Decrement the ref. count for this object in the top file */
@@ -1943,16 +1959,16 @@ H5D_close(H5D_t *dataset)
HGOTO_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "problem attempting to free location")
} /* end else */
- /* Release the dataset's path info */
- if(H5G_name_free(&(dataset->path)) < 0)
- free_failed = TRUE;
+ /* Release the dataset's path info */
+ if(H5G_name_free(&(dataset->path)) < 0)
+ free_failed = TRUE;
/* Free the dataset's memory structure */
dataset = H5FL_FREE(H5D_t, dataset);
/* Check if anything failed in the middle... */
if(free_failed)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "couldn't free a component of the dataset, but the dataset was freed anyway.")
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "couldn't free a component of the dataset, but the dataset was freed anyway.")
done:
FUNC_LEAVE_NOAPI(ret_value)
diff --git a/src/H5Fint.c b/src/H5Fint.c
index 80c593b..5b7fdda 100644
--- a/src/H5Fint.c
+++ b/src/H5Fint.c
@@ -954,6 +954,7 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id,
H5FD_class_t *drvr; /*file driver class info */
H5P_genplist_t *a_plist; /*file access property list */
H5F_close_degree_t fc_degree; /*file close degree */
+ hbool_t evict_on_close; /* evict on close value from plist */
H5F_t *ret_value = NULL; /*actual return value */
FUNC_ENTER_NOAPI(NULL)
@@ -1118,6 +1119,21 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id,
HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "file close degree doesn't match")
} /* end if */
+ /* Record the evict-on-close MDC behavior. If it's the first time opening
+ * the file, set it to access property list value; if it's the second time
+ * or later, verify that the access property list value matches the value
+ * in shared file structure.
+ */
+ if(H5P_get(a_plist, H5F_ACS_EVICT_ON_CLOSE_FLAG_NAME, &evict_on_close) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get evict on close value")
+
+ if(shared->nrefs == 1) {
+ shared->evict_on_close = evict_on_close;
+ } else if(shared->nrefs > 1) {
+ if(shared->evict_on_close != evict_on_close)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "file evict-on-close value doesn't match")
+ } /* end if */
+
/* Formulate the absolute path for later search of target file for external links */
if(H5_build_extpath(name, &file->extpath) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to build extpath")
diff --git a/src/H5Fio.c b/src/H5Fio.c
index b9bd354..2ccd3f3 100644
--- a/src/H5Fio.c
+++ b/src/H5Fio.c
@@ -271,7 +271,7 @@ H5F_evict_tagged_metadata(H5F_t * f, haddr_t tag, hid_t dxpl_id)
f->shared->sblock = NULL;
/* Evict the object's metadata */
- if(H5AC_evict_tagged_metadata(f, tag, dxpl_id)<0)
+ if(H5AC_evict_tagged_metadata(f, tag, TRUE, dxpl_id) < 0)
HGOTO_ERROR(H5E_CACHE, H5E_CANTEXPUNGE, FAIL, "unable to evict tagged metadata")
/* Re-read the superblock. */
diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h
index c5aed3b..8ec2a93 100644
--- a/src/H5Fpkg.h
+++ b/src/H5Fpkg.h
@@ -261,6 +261,7 @@ struct H5F_file_t {
/* not change thereafter. */
hid_t fcpl_id; /* File creation property list ID */
H5F_close_degree_t fc_degree; /* File close behavior degree */
+ hbool_t evict_on_close; /* If the file's objects should be evicted from the metadata cache on close */
size_t rdcc_nslots; /* Size of raw data chunk cache (slots) */
size_t rdcc_nbytes; /* Size of raw data chunk cache (bytes) */
double rdcc_w0; /* Preempt read chunks first? [0.0..1.0]*/
diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h
index b5c24e9..40e5ff2 100644
--- a/src/H5Fprivate.h
+++ b/src/H5Fprivate.h
@@ -303,6 +303,7 @@
#define H5F_SET_SOHM_NINDEXES(F, N) ((F)->shared->sohm_nindexes = (N))
#define H5F_FCPL(F) ((F)->shared->fcpl_id)
#define H5F_GET_FC_DEGREE(F) ((F)->shared->fc_degree)
+#define H5F_EVICT_ON_CLOSE(F) ((F)->shared->evict_on_close)
#define H5F_RDCC_NSLOTS(F) ((F)->shared->rdcc_nslots)
#define H5F_RDCC_NBYTES(F) ((F)->shared->rdcc_nbytes)
#define H5F_RDCC_W0(F) ((F)->shared->rdcc_w0)
@@ -348,6 +349,7 @@
#define H5F_SET_SOHM_NINDEXES(F, N) (H5F_set_sohm_nindexes((F), (N)))
#define H5F_FCPL(F) (H5F_get_fcpl(F))
#define H5F_GET_FC_DEGREE(F) (H5F_get_fc_degree(F))
+#define H5F_EVICT_ON_CLOSE(F) (H5F_get_evict_on_close(F))
#define H5F_RDCC_NSLOTS(F) (H5F_rdcc_nslots(F))
#define H5F_RDCC_NBYTES(F) (H5F_rdcc_nbytes(F))
#define H5F_RDCC_W0(F) (H5F_rdcc_w0(F))
@@ -463,6 +465,7 @@
#define H5F_ACS_EFC_SIZE_NAME "efc_size" /* Size of external file cache */
#define H5F_ACS_FILE_IMAGE_INFO_NAME "file_image_info" /* struct containing initial file image and callback info */
#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 */
@@ -660,6 +663,7 @@ H5_DLL unsigned H5F_get_sohm_nindexes(const H5F_t *f);
H5_DLL herr_t H5F_set_sohm_nindexes(H5F_t *f, unsigned nindexes);
H5_DLL hid_t H5F_get_fcpl(const H5F_t *f);
H5_DLL H5F_close_degree_t H5F_get_fc_degree(const H5F_t *f);
+H5_DLL hbool_t H5F_get_evict_on_close(const H5F_t *f);
H5_DLL size_t H5F_rdcc_nbytes(const H5F_t *f);
H5_DLL size_t H5F_rdcc_nslots(const H5F_t *f);
H5_DLL double H5F_rdcc_w0(const H5F_t *f);
diff --git a/src/H5Fquery.c b/src/H5Fquery.c
index dd6e8e3..f59a9b7 100644
--- a/src/H5Fquery.c
+++ b/src/H5Fquery.c
@@ -835,6 +835,33 @@ H5F_get_fc_degree(const H5F_t *f)
/*-------------------------------------------------------------------------
+ * Function: H5F_get_evict_on_close
+ *
+ * Purpose: Retrieve the 'file close degree' for the file.
+ *
+ * Return: Success: Flag indicating whether the evict-on-close
+ * property was set for the file.
+ * Failure: (can't happen)
+ *
+ * Programmer: Dana Robinson
+ * Spring 2016
+ *
+ *-------------------------------------------------------------------------
+ */
+hbool_t
+H5F_get_evict_on_close(const H5F_t *f)
+{
+ /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
+ FUNC_ENTER_NOAPI_NOINIT_NOERR
+
+ HDassert(f);
+ HDassert(f->shared);
+
+ FUNC_LEAVE_NOAPI(f->shared->evict_on_close)
+} /* end H5F_get_evict_on_close() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5F_store_msg_crt_idx
*
* Purpose: Retrieve the 'store message creation index' flag for the file.
diff --git a/src/H5G.c b/src/H5G.c
index 5d920a4..1a18dc0 100644
--- a/src/H5G.c
+++ b/src/H5G.c
@@ -715,14 +715,14 @@ done:
herr_t
H5Gclose(hid_t group_id)
{
- herr_t ret_value = SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE1("e", "i", group_id);
/* Check args */
if(NULL == H5I_object_verify(group_id,H5I_GROUP))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group")
/*
* Decrement the counter on the group atom. It will be freed if the count
diff --git a/src/H5Gint.c b/src/H5Gint.c
index f5bccc3..ff92ecc 100644
--- a/src/H5Gint.c
+++ b/src/H5Gint.c
@@ -486,7 +486,7 @@ H5G_close(H5G_t *grp)
if(0 == grp->shared->fo_count) {
HDassert(grp != H5G_rootof(H5G_fileof(grp)));
- /* Uncork cache entries with object address tag */
+ /* Uncork cache entries with object address tag */
if(H5AC_cork(grp->oloc.file, grp->oloc.addr, H5AC__GET_CORKED, &corked) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to retrieve an object's cork status")
if(corked)
@@ -500,6 +500,23 @@ H5G_close(H5G_t *grp)
HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't remove group from list of open objects")
if(H5O_close(&(grp->oloc)) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to close")
+
+ /* Evict group metadata if evicting on close */
+ if(H5F_SHARED(grp->oloc.file) && H5F_EVICT_ON_CLOSE(grp->oloc.file)) {
+// printf("EVICTING GROUP (TAG: 0x%3llx)\n", grp->oloc.addr);
+// printf("DUMPING CACHE - BEFORE FLUSH\n");
+// H5AC_dump_cache(grp->oloc.file);
+ if(H5AC_flush_tagged_metadata(grp->oloc.file, grp->oloc.addr, 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(grp->oloc.file);
+ if(H5AC_evict_tagged_metadata(grp->oloc.file, grp->oloc.addr, 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(grp->oloc.file);
+ } /* end if */
+
+ /* Free memory */
grp->shared = H5FL_FREE(H5G_shared_t, grp->shared);
} else {
/* Decrement the ref. count for this object in the top file */
diff --git a/src/H5O.c b/src/H5O.c
index 3daf09e..aa30e79 100644
--- a/src/H5O.c
+++ b/src/H5O.c
@@ -1051,7 +1051,7 @@ done:
* the same effect as calling H5Gclose, H5Dclose, or H5Tclose.
*
* Return: Success: Non-negative
- * Failure: Negative
+ * Failure: Negative
*
* Programmer: James Laird
* July 14 2006
@@ -1069,14 +1069,18 @@ H5Oclose(hid_t object_id)
/* Get the type of the object and close it in the correct way */
switch(H5I_get_type(object_id)) {
case H5I_GROUP:
- case H5I_DATATYPE:
case H5I_DATASET:
if(H5I_object(object_id) == NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a valid object")
if(H5I_dec_app_ref(object_id) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "unable to close object")
break;
-
+ case H5I_DATATYPE:
+ if(H5I_object(object_id) == NULL)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a valid object")
+ if(H5T_close_id(object_id) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "unable to close object")
+ break;
case H5I_UNINIT:
case H5I_BADID:
case H5I_FILE:
diff --git a/src/H5Pfapl.c b/src/H5Pfapl.c
index 96de39c..d96bd54 100644
--- a/src/H5Pfapl.c
+++ b/src/H5Pfapl.c
@@ -181,6 +181,11 @@
/* Definition for object flush callback */
#define H5F_ACS_OBJECT_FLUSH_CB_SIZE sizeof(H5F_object_flush_t)
#define H5F_ACS_OBJECT_FLUSH_CB_DEF {NULL, NULL}
+/* Definition for evict on close property */
+#define H5F_ACS_EVICT_ON_CLOSE_FLAG_SIZE sizeof(hbool_t)
+#define H5F_ACS_EVICT_ON_CLOSE_FLAG_DEF FALSE
+#define H5F_ACS_EVICT_ON_CLOSE_FLAG_ENC H5P__encode_hbool_t
+#define H5F_ACS_EVICT_ON_CLOSE_FLAG_DEC H5P__decode_hbool_t
#ifdef H5_HAVE_PARALLEL
/* Definition of collective metadata read mode flag */
#define H5F_ACS_COLL_MD_READ_FLAG_SIZE sizeof(H5P_coll_md_read_flag_t)
@@ -296,6 +301,7 @@ static const H5FD_file_image_info_t H5F_def_file_image_info_g = H5F_ACS_FILE_IMA
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 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_evict_on_close_flag_g = H5F_ACS_EVICT_ON_CLOSE_FLAG_DEF; /* Default setting for evict on close property */
#ifdef H5_HAVE_PARALLEL
static const H5P_coll_md_read_flag_t H5F_def_coll_md_read_flag_g = H5F_ACS_COLL_MD_READ_FLAG_DEF; /* Default setting for the collective metedata read flag */
static const hbool_t H5F_def_coll_md_write_flag_g = H5F_ACS_COLL_MD_WRITE_FLAG_DEF; /* Default setting for the collective metedata write flag */
@@ -462,6 +468,12 @@ H5P__facc_reg_prop(H5P_genclass_t *pclass)
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
+ /* Register the evict on close flag */
+ if(H5P_register_real(pclass, H5F_ACS_EVICT_ON_CLOSE_FLAG_NAME, H5F_ACS_EVICT_ON_CLOSE_FLAG_SIZE, &H5F_def_evict_on_close_flag_g,
+ NULL, NULL, NULL, H5F_ACS_EVICT_ON_CLOSE_FLAG_ENC, H5F_ACS_EVICT_ON_CLOSE_FLAG_DEC,
+ NULL, NULL, NULL, NULL) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
+
#ifdef H5_HAVE_PARALLEL
/* Register the metadata collective read flag */
if(H5P_register_real(pclass, H5_COLL_MD_READ_FLAG_NAME, H5F_ACS_COLL_MD_READ_FLAG_SIZE, &H5F_def_coll_md_read_flag_g,
@@ -3605,6 +3617,81 @@ done:
FUNC_LEAVE_API(ret_value)
} /* H5Pget_obj_flush_cb() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5Pset_evict_on_close
+ *
+ * Purpose:
+ *
+ * Return: SUCCEED/FAIL
+ *
+ * Programmer: Dana Robinson
+ * Spring 2016
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5Pset_evict_on_close(hid_t fapl_id, hbool_t evict_on_close)
+{
+ H5P_genplist_t *plist; /* property list pointer */
+ herr_t ret_value = SUCCEED; /* return value */
+
+ FUNC_ENTER_API(FAIL)
+ H5TRACE2("e", "ib", fapl_id, evict_on_close);
+
+ /* Compare the property list's class against the other class */
+ if(TRUE != H5P_isa_class(fapl_id, H5P_FILE_ACCESS))
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "property list is not a file access plist")
+
+ /* Get the plist structure */
+ if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id)))
+ HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
+
+ /* Set values */
+ if(H5P_set(plist, H5F_ACS_EVICT_ON_CLOSE_FLAG_NAME, &evict_on_close) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set evict on close property")
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Pset_evict_on_close() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5Pget_evict_on_close
+ *
+ * Purpose:
+ *
+ * Return: SUCCEED/FAIL
+ *
+ * Programmer: Dana Robinson
+ * Spring 2016
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5Pget_evict_on_close(hid_t fapl_id, hbool_t *evict_on_close)
+{
+ H5P_genplist_t *plist; /* property list pointer */
+ herr_t ret_value = SUCCEED; /* return value */
+
+ FUNC_ENTER_API(FAIL)
+ H5TRACE2("e", "i*b", fapl_id, evict_on_close);
+
+ /* Compare the property list's class against the other class */
+ if(TRUE != H5P_isa_class(fapl_id, H5P_FILE_ACCESS))
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "property list is not an access plist")
+
+ /* Get the plist structure */
+ if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id)))
+ HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
+
+ if(H5P_get(plist, H5F_ACS_EVICT_ON_CLOSE_FLAG_NAME, evict_on_close) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get evict on close property")
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Pget_evict_on_close() */
+
#ifdef H5_HAVE_PARALLEL
/*-------------------------------------------------------------------------
diff --git a/src/H5Ppublic.h b/src/H5Ppublic.h
index 0318c8f..b807a37 100644
--- a/src/H5Ppublic.h
+++ b/src/H5Ppublic.h
@@ -353,6 +353,8 @@ H5_DLL herr_t H5Pset_core_write_tracking(hid_t fapl_id, hbool_t is_enabled, size
H5_DLL herr_t H5Pget_core_write_tracking(hid_t fapl_id, hbool_t *is_enabled, size_t *page_size);
H5_DLL herr_t H5Pset_object_flush_cb(hid_t plist_id, H5F_flush_cb_t func, void *udata);
H5_DLL herr_t H5Pget_object_flush_cb(hid_t plist_id, H5F_flush_cb_t *func, void **udata);
+H5_DLL herr_t H5Pset_evict_on_close(hid_t fapl_id, hbool_t evict_on_close);
+H5_DLL herr_t H5Pget_evict_on_close(hid_t fapl_id, hbool_t *evict_on_close);
#ifdef H5_HAVE_PARALLEL
H5_DLL herr_t H5Pset_all_coll_metadata_ops(hid_t plist_id, hbool_t is_collective);
H5_DLL herr_t H5Pget_all_coll_metadata_ops(hid_t plist_id, hbool_t *is_collective);
diff --git a/src/H5T.c b/src/H5T.c
index b2575d5..cc0e782 100644
--- a/src/H5T.c
+++ b/src/H5T.c
@@ -1696,41 +1696,95 @@ 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
- *
- * Modifications:
+ * Programmer: Robb Matzke
+ * Tuesday, December 9, 1997
*
*-------------------------------------------------------------------------
*/
herr_t
H5Tclose(hid_t type_id)
{
- H5T_t *dt; /* Pointer to datatype to close */
- herr_t ret_value = SUCCEED; /* Return value */
+ 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")
+ 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 */
/* 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")
+ 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 */
done:
- FUNC_LEAVE_API(ret_value)
-} /* end H5Tclose() */
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5T_close_id() */
/*-------------------------------------------------------------------------
diff --git a/src/H5Tprivate.h b/src/H5Tprivate.h
index 7efcb41..5fd0cf3 100644
--- a/src/H5Tprivate.h
+++ b/src/H5Tprivate.h
@@ -108,6 +108,7 @@ H5_DLL herr_t H5T_init(void);
H5_DLL H5T_t *H5T_copy(H5T_t *old_dt, H5T_copy_t method);
H5_DLL herr_t H5T_lock(H5T_t *dt, hbool_t immutable);
H5_DLL herr_t H5T_close(H5T_t *dt);
+H5_DLL herr_t H5T_close_id(hid_t type_id);
H5_DLL H5T_t *H5T_get_super(const H5T_t *dt);
H5_DLL H5T_class_t H5T_get_class(const H5T_t *dt, htri_t internal);
H5_DLL htri_t H5T_detect_class(const H5T_t *dt, H5T_class_t cls, hbool_t from_api);