summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDana Robinson <derobins@hdfgroup.org>2016-06-25 13:30:11 (GMT)
committerDana Robinson <derobins@hdfgroup.org>2016-06-25 13:30:11 (GMT)
commitf9312d49d52ba6e6af4549907dd73a4901db6f70 (patch)
tree28856d57c852c41c8444d7ecbf151a6c6c128538 /src
parent29cb102f121f79c2a678f036ff211a8bad91517f (diff)
downloadhdf5-f9312d49d52ba6e6af4549907dd73a4901db6f70.zip
hdf5-f9312d49d52ba6e6af4549907dd73a4901db6f70.tar.gz
hdf5-f9312d49d52ba6e6af4549907dd73a4901db6f70.tar.bz2
[svn-r30105] Datatypes and Groups now support evict-on-close.
Diffstat (limited to 'src')
-rw-r--r--src/H5G.c32
-rw-r--r--src/H5T.c31
2 files changed, 59 insertions, 4 deletions
diff --git a/src/H5G.c b/src/H5G.c
index 9bbd43f..e4313fe 100644
--- a/src/H5G.c
+++ b/src/H5G.c
@@ -715,15 +715,29 @@ done:
herr_t
H5Gclose(hid_t group_id)
{
- herr_t ret_value = SUCCEED; /* Return value */
+ H5G_t *grp = NULL; /* Group */
+ 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_API(FAIL)
H5TRACE1("e", "i", group_id);
/* Check args */
- if(NULL == H5I_object_verify(group_id,H5I_GROUP))
+ if(NULL == (grp = (H5G_t *)H5I_object_verify(group_id,H5I_GROUP)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group")
+ /* 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 = grp->oloc.file;
+ if(1 == grp->shared->fo_count && H5F_EVICT_ON_CLOSE(file)) {
+ evict = TRUE;
+ tag = grp->oloc.addr;
+ } /* end if */
+
/*
* Decrement the counter on the group atom. It will be freed if the count
* reaches zero.
@@ -731,6 +745,20 @@ H5Gclose(hid_t group_id)
if(H5I_dec_app_ref(group_id) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close group")
+ /* 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 H5Gclose() */
diff --git a/src/H5T.c b/src/H5T.c
index 775cfdb..2fbc193 100644
--- a/src/H5T.c
+++ b/src/H5T.c
@@ -1712,8 +1712,11 @@ done:
herr_t
H5Tclose(hid_t type_id)
{
- H5T_t *dt; /* Pointer to datatype to close */
- herr_t ret_value = SUCCEED; /* Return value */
+ 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_API(FAIL)
H5TRACE1("e", "i", type_id);
@@ -1724,10 +1727,34 @@ H5Tclose(hid_t type_id)
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 */
+
/* 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 */
+
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Tclose() */