summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2008-06-09 21:58:27 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2008-06-09 21:58:27 (GMT)
commitd0acd2431f5151d25e32d67667cda93587dc33e4 (patch)
treec95693a891b54562f389faede5c9da847332e372 /src
parent32f3fe6586828a0a04263bb34464b6ea0057900b (diff)
downloadhdf5-d0acd2431f5151d25e32d67667cda93587dc33e4.zip
hdf5-d0acd2431f5151d25e32d67667cda93587dc33e4.tar.gz
hdf5-d0acd2431f5151d25e32d67667cda93587dc33e4.tar.bz2
[svn-r15185] Description:
Added a pointer to the cache that an entry is contained within to the cache entry structure. This allows us to remove the file pointer from some of the H5AC2 calls, easing the conversion of some of the cache clients (the free space section info and fractal heap direct blocks, and probably others). Removed file pointer from the H5AC2_unpin_entry() call. Tested on: FreeBSD/32 6.2 (duty) in debug mode FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64-amd64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN, in production mode Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN, in production mode Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN, w/szip filter, in production mode Mac OS X/32 10.5.2 (amazon) in debug mode Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
Diffstat (limited to 'src')
-rw-r--r--src/H5AC2.c20
-rw-r--r--src/H5AC2private.h13
-rw-r--r--src/H5C2.c83
-rw-r--r--src/H5C2private.h9
-rw-r--r--src/H5HL.c2
5 files changed, 76 insertions, 51 deletions
diff --git a/src/H5AC2.c b/src/H5AC2.c
index 5967497..13d5c12 100644
--- a/src/H5AC2.c
+++ b/src/H5AC2.c
@@ -2454,29 +2454,29 @@ done:
* Modified code in support of revised cache API needed
* to permit journaling. JRM - 10/18/07
*
+ * Removed file pointer parameter. QAK - 6/9/08
+ *
*-------------------------------------------------------------------------
*/
herr_t
-H5AC2_unpin_entry(H5F_t * f,
- void * thing)
+H5AC2_unpin_entry(void * thing)
{
- herr_t result;
- herr_t ret_value = SUCCEED; /* Return value */
#if H5AC2__TRACE_FILE_ENABLED
char trace[128] = "";
FILE * trace_file_ptr = NULL;
#endif /* H5AC2__TRACE_FILE_ENABLED */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5AC2_unpin_entry, FAIL)
+ /* Sanity check */
+ HDassert(thing);
+
#if H5AC2__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 ( ( f != NULL ) &&
- ( f->shared != NULL ) &&
- ( f->shared->cache2 != NULL ) &&
- ( H5C2_get_trace_file_ptr(f->shared->cache2, &trace_file_ptr) >= 0) &&
+ if ( ( H5C2_get_trace_file_ptr_from_entry(thing, &trace_file_ptr) >= 0) &&
( trace_file_ptr != NULL ) ) {
sprintf(trace, "H5AC2_unpin_entry 0x%lx",
@@ -2484,9 +2484,7 @@ H5AC2_unpin_entry(H5F_t * f,
}
#endif /* H5AC2__TRACE_FILE_ENABLED */
- result = H5C2_unpin_entry(f, thing);
-
- if ( result < 0 ) {
+ if ( H5C2_unpin_entry(thing) < 0 ) {
HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPIN, FAIL, "H5C2_unpin_entry() failed.")
}
diff --git a/src/H5AC2private.h b/src/H5AC2private.h
index 4113842..b17b09e 100644
--- a/src/H5AC2private.h
+++ b/src/H5AC2private.h
@@ -265,7 +265,6 @@ H5_DLL herr_t H5AC2_init(void);
H5_DLL herr_t H5AC2_create(H5F_t *f,
hid_t dxpl_id,
H5AC2_cache_config_t *config_ptr);
-#if 1 /* new version */
H5_DLL herr_t H5AC2_begin_transaction(hid_t id,
hbool_t * do_transaction_ptr,
H5O_loc_t * id_oloc_ptr,
@@ -273,21 +272,12 @@ H5_DLL herr_t H5AC2_begin_transaction(hid_t id,
hbool_t * transaction_begun_ptr,
uint64_t * trans_num_ptr,
const char * api_call_name);
-
H5_DLL herr_t H5AC2_end_transaction(hbool_t do_transaction,
H5O_loc_t * id_oloc_ptr,
hbool_t id_oloc_open,
hbool_t transaction_begun,
uint64_t trans_num,
const char * api_call_name);
-#else /* old version */
-H5_DLL herr_t H5AC2_begin_transaction(H5F_t * f,
- uint64_t * trans_num_ptr,
- const char * api_call_name);
-H5_DLL herr_t H5AC2_end_transaction(H5F_t * f,
- uint64_t trans_num,
- const char * api_call_name);
-#endif /* old version */
H5_DLL herr_t H5AC2_get_entry_status(H5F_t * f, haddr_t addr,
unsigned * status_ptr);
H5_DLL herr_t H5AC2_set(H5F_t *f, hid_t dxpl_id, const H5AC2_class_t *type,
@@ -300,8 +290,7 @@ H5_DLL void * H5AC2_protect(H5F_t *f, hid_t dxpl_id, const H5AC2_class_t *type,
H5_DLL herr_t H5AC2_resize_pinned_entry(H5F_t * f,
void * thing,
size_t new_size);
-H5_DLL herr_t H5AC2_unpin_entry(H5F_t * f,
- void * thing);
+H5_DLL herr_t H5AC2_unpin_entry(void * thing);
H5_DLL herr_t H5AC2_unprotect(H5F_t *f, hid_t dxpl_id,
const H5AC2_class_t *type, haddr_t addr,
size_t new_size, void *thing, unsigned flags);
diff --git a/src/H5C2.c b/src/H5C2.c
index a85a78c..6945084 100644
--- a/src/H5C2.c
+++ b/src/H5C2.c
@@ -2243,33 +2243,60 @@ done:
*/
herr_t
-H5C2_get_trace_file_ptr(H5C2_t * cache_ptr,
+H5C2_get_trace_file_ptr(const H5C2_t * cache_ptr,
FILE ** trace_file_ptr_ptr)
{
- herr_t ret_value = SUCCEED; /* Return value */
+ FUNC_ENTER_NOAPI_NOFUNC(H5C2_get_trace_file_ptr)
- FUNC_ENTER_NOAPI(H5C2_get_trace_file_ptr, FAIL)
+ HDassert( cache_ptr );
+ HDassert( cache_ptr->magic == H5C2__H5C2_T_MAGIC );
+ HDassert( trace_file_ptr_ptr );
- /* This would normally be an assert, but we need to use an HGOTO_ERROR
- * call to shut up the compiler.
- */
- if ( ( ! cache_ptr ) || ( cache_ptr->magic != H5C2__H5C2_T_MAGIC ) ) {
+ *trace_file_ptr_ptr = cache_ptr->trace_file_ptr;
- HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad cache_ptr")
- }
+ FUNC_LEAVE_NOAPI(SUCCEED)
- if ( trace_file_ptr_ptr == NULL ) {
+} /* H5C2_get_trace_file_ptr() */
- HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "NULL trace_file_ptr_ptr")
- }
+
+/*-------------------------------------------------------------------------
+ * Function: H5C2_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-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * 6/9/08
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
- *trace_file_ptr_ptr = cache_ptr->trace_file_ptr;
+herr_t
+H5C2_get_trace_file_ptr_from_entry(const H5C2_cache_entry_t *entry_ptr,
+ FILE ** trace_file_ptr_ptr)
+{
+ const H5C2_t *cache_ptr; /* Cache pointer, from entry */
-done:
+ FUNC_ENTER_NOAPI_NOFUNC(H5C2_get_trace_file_ptr)
- FUNC_LEAVE_NOAPI(ret_value)
+ /* Sanity checks */
+ HDassert( entry_ptr );
+ HDassert( entry_ptr->cache_ptr );
-} /* H5C2_get_trace_file_ptr() */
+ cache_ptr = entry_ptr->cache_ptr;
+
+ H5C2_get_trace_file_ptr(cache_ptr, trace_file_ptr_ptr);
+
+ FUNC_LEAVE_NOAPI(SUCCEED)
+
+} /* H5C2_get_trace_file_ptr_from_entry() */
/*-------------------------------------------------------------------------
@@ -2426,6 +2453,7 @@ H5C2_insert_entry(H5F_t * f,
#ifndef NDEBUG
entry_ptr->magic = H5C2__H5C2_CACHE_ENTRY_T_MAGIC;
#endif /* NDEBUG */
+ entry_ptr->cache_ptr = cache_ptr;
entry_ptr->addr = addr;
entry_ptr->type = type;
@@ -5278,28 +5306,27 @@ H5C2_stats__reset(H5C2_t UNUSED * cache_ptr)
* Modified routine to allow it to operate on protected
* entries.
*
+ * QAK -- 6/9/08
+ * Dropped file pointer parameter and retrieve cache pointer from
+ * entry.
+ *
*-------------------------------------------------------------------------
*/
herr_t
-H5C2_unpin_entry(H5F_t * f,
- void * thing)
+H5C2_unpin_entry(void *_entry_ptr)
{
H5C2_t *cache_ptr;
+ H5C2_cache_entry_t *entry_ptr = (H5C2_cache_entry_t *)_entry_ptr;
herr_t ret_value = SUCCEED; /* Return value */
- H5C2_cache_entry_t * entry_ptr;
FUNC_ENTER_NOAPI(H5C2_unpin_entry, FAIL)
- HDassert( f );
- HDassert( f->shared );
+ HDassert( entry_ptr );
- cache_ptr = f->shared->cache2;
+ cache_ptr = entry_ptr->cache_ptr;
HDassert( cache_ptr );
HDassert( cache_ptr->magic == H5C2__H5C2_T_MAGIC );
- HDassert( thing );
-
- entry_ptr = (H5C2_cache_entry_t *)thing;
if ( ! ( entry_ptr->is_pinned ) ) {
@@ -8712,10 +8739,13 @@ H5C2_flush_single_entry(const H5F_t * f,
/* we are about to discard the in core representation --
* set the magic field to bad magic so we can detect a
* freed entry if we see one.
+ *
+ * Also reset the pointer to the cache the entry is within. -QAK
*/
#ifndef NDEBUG
entry_ptr->magic = H5C2__H5C2_CACHE_ENTRY_T_BAD_MAGIC;
#endif /* NDEBUG */
+ entry_ptr->cache_ptr = NULL;
if ( type_ptr->free_icr(entry_ptr->addr, entry_ptr->size,
(void *)entry_ptr) != SUCCEED )
{
@@ -8820,6 +8850,8 @@ H5C2_load_entry(H5F_t * f,
FUNC_ENTER_NOAPI_NOINIT(H5C2_load_entry)
HDassert( f );
+ HDassert( f->shared );
+ HDassert( f->shared->cache2 );
HDassert( type );
HDassert( H5F_addr_defined(addr) );
HDassert( len > 0 );
@@ -8924,6 +8956,7 @@ H5C2_load_entry(H5F_t * f,
#ifndef NDEBUG
entry_ptr->magic = H5C2__H5C2_CACHE_ENTRY_T_MAGIC;
#endif /* NDEBUG */
+ entry_ptr->cache_ptr = f->shared->cache2;
entry_ptr->addr = addr;
entry_ptr->size = len;
entry_ptr->image_ptr = image_ptr;
diff --git a/src/H5C2private.h b/src/H5C2private.h
index a7b421c..20111df 100644
--- a/src/H5C2private.h
+++ b/src/H5C2private.h
@@ -550,6 +550,8 @@ typedef herr_t (*H5C2_log_flush_func_t)(H5C2_t * cache_ptr,
* detect this case, and re-start its scan from the bottom
* of the LRU when this situation occurs.
*
+ * cache_ptr: Pointer to the cache that this entry is contained within.
+ *
* addr: Base address of the cache entry on disk.
*
* size: Length of the cache entry on disk. Note that unlike normal
@@ -849,6 +851,7 @@ typedef struct H5C2_cache_entry_t
#ifndef NDEBUG
uint32_t magic;
#endif /* NDEBUG */
+ H5C2_t * cache_ptr;
haddr_t addr;
size_t size;
void * image_ptr;
@@ -1373,8 +1376,10 @@ H5_DLL herr_t H5C2_get_entry_status(H5F_t * f,
H5_DLL herr_t H5C2_get_evictions_enabled(H5C2_t * cache_ptr,
hbool_t * evictions_enabled_ptr);
-H5_DLL herr_t H5C2_get_trace_file_ptr(H5C2_t * cache_ptr,
+H5_DLL herr_t H5C2_get_trace_file_ptr(const H5C2_t * cache_ptr,
FILE ** trace_file_ptr_ptr);
+H5_DLL herr_t H5C2_get_trace_file_ptr_from_entry(const H5C2_cache_entry_t *entry_ptr,
+ FILE ** trace_file_ptr_ptr);
H5_DLL herr_t H5C2_insert_entry(H5F_t * f,
hid_t dxpl_id,
@@ -1440,7 +1445,7 @@ H5_DLL herr_t H5C2_stats(H5C2_t * cache_ptr,
H5_DLL void H5C2_stats__reset(H5C2_t * cache_ptr);
-H5_DLL herr_t H5C2_unpin_entry(H5F_t * file_ptr, void * thing);
+H5_DLL herr_t H5C2_unpin_entry(void * thing);
H5_DLL herr_t H5C2_unprotect(H5F_t * f,
hid_t dxpl_id,
diff --git a/src/H5HL.c b/src/H5HL.c
index c861978..1cf3c9f 100644
--- a/src/H5HL.c
+++ b/src/H5HL.c
@@ -1124,7 +1124,7 @@ H5HL_remove(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, size_t offset, size_t size)
* if an error occurs -QAK)
*/
if(H5AC_mark_pinned_or_protected_entry_dirty(f, heap) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTMARKDIRTY, (size_t)(-1), "unable to mark heap as dirty")
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTMARKDIRTY, FAIL, "unable to mark heap as dirty")
/*
* Check if this chunk can be prepended or appended to an already